Skip to content

Viewer: load Script Lab's julc engine from the @julclang/julc-wasm npm package - #222

Open
satran004 wants to merge 2 commits into
mainfrom
feat/viewer-julc-npm
Open

satran004 wants to merge 2 commits into
mainfrom
feat/viewer-julc-npm

Conversation

@satran004

@satran004 satran004 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Script Lab now loads the julc engine from the @julclang/julc-wasm npm package (JuLC ADR-077), instead of downloading the pre18 release archive into static/julc/.

JuLC 0.1.0-pre21 is published. package-lock.json now resolves @julclang/julc-wasm and @julclang/wasm-client 0.1.0-pre21 from registry.npmjs.org (c1227d3):

  • each lock integrity equals the sha512 of the matching GitHub release asset (gh release download v0.1.0-pre21);
  • npm audit signatures verifies both packages' registry signatures and SLSA v1 provenance (bloxbean/julc, native-image-release.yml, refs/tags/v0.1.0-pre21).

Changes (applications/viewer)

  • package.json: adds @julclang/julc-wasm 0.1.0-pre21 (exact) to devDependencies; the build bundles it, and the server output never imports it. The predev and prebuild fetch hooks are removed.
  • src/lib/julc/engine.svelte.ts:
    • Browser only: const { createJulc } = await import('@julclang/julc-wasm'), then createJulc({ timeoutMs: 60_000 }). The package names its own engine files and checks they belong to its release.
    • available() reads the manifest from the small @julclang/julc-wasm/engine module, without downloading the engine.
    • The loading, unsupported, error and timeout states are unchanged.
  • src/lib/julc/types.ts: Manifest, Features and FeatureGroup come from the package. The package's client is assigned to JulcClient without a cast, so API drift shows up in svelte-check.
  • vite.config.js: optimizeDeps.exclude for @julclang/wasm-client and @julclang/julc-wasm. The dev server needs it (without it the worker 404s); production builds don't.
  • Removed: scripts/fetch-julc.mjs, julc.lock.json, scripts/lib/untar.mjs and its test, and the static/julc ignore lines.
  • The built-in Java examples now have explicit imports. JuLC pre21 (ADR-068) no longer imports the ledger and stdlib implicitly.
  • Version text: the debugger shows the engine's real version. The V1 replay note no longer refers to pre18.
  • README: package install and upgrade, the dev-server exclude, CSP, and the explicit imports.

Behaviour changes

  • The engine can't be loaded from another host any more. PUBLIC_JULC_BASE_URL is gone: the package loads its engine only from the page's own origin, and refuses blob: URLs. JULC_SKIP and JULC_ARCHIVE are gone too, so Script Lab is always in the build.
  • The engine moves from pre18 to pre21:
    • Lab sources saved in the browser by older versions may need imports added; they show "cannot find symbol" until then.
    • V1 replays use pre21's V1/V2 context translation.
  • Size: the production build includes the engine assets. The full engine downloads lazily, about 8.7 MB Brotli (34.5 MB raw).
  • Leftovers: delete any old applications/viewer/static/julc. It's no longer git-ignored, so the build would copy it in.

Tested locally

Tested with tarballs built from JuLC main 77b2bab2, against the Yaci Store at https://yaci-playground.cf-app.org (Mainnet, read-only), with Node 22.12, Vite 6.0.6, SvelteKit 2.70.3, and Chromium 156 / Chrome 157.

  • Dev server and production build (node build), both passing:
    • chain data loads;
    • the lab compiles the Vesting, Owner-only and Signed-mint examples (engine start about 1.3 s);
    • "accepted" and "rejected (failed on line 16)" results;
    • the Java debugger and the UPLC debugger;
    • decoding a V3 script;
    • re-running real V3, V2 and V1 transactions, which reproduce;
    • the transaction debugger page (18,818 steps).
  • Strict CSP: script-src 'self' 'wasm-unsafe-eval' on worker and asset responses, with no 'unsafe-eval'. No violations.
  • Build output: the worker, runtime, launcher and .wasm are emitted as immutable assets, and the .wasm is served as application/wasm.
  • Checks:
    • svelte-check: 0 errors, 0 warnings.
    • vitest: 181 tests pass.
    • The viewer's Playwright suite: 26 passed, 2 skipped (no data on this store). 1 failed, in a blueprint-naming test unrelated to the engine: it fails with that store's script and passes with a script whose redeemer has no fields.
  • Re-tested with the published 0.1.0-pre21, from the lockfile:
    • npm ci, npm run check (0 errors) and vitest (181 tests) pass;
    • in the production build, the production build under a strict CSP, and the dev server, chain data loads, and compile, run, the debuggers, decode and a transaction re-run all pass, and the debugger shows "julc 0.1.0-pre21";
    • the Docker image now builds (npm ci inside it, about 1 min) and runs with the same checks passing.
  • Not tested: Firefox and Safari.

🤖 Generated with Claude Code

…m package

Script Lab now depends on @julclang/julc-wasm (0.1.0-pre21, exact; it brings
@julclang/wasm-client at the same version) instead of downloading the julc
release archive at build time. Vite bundles the package's worker, launcher and
WebAssembly module as hashed assets of the build, served by the viewer itself.

- engine.svelte.ts imports createJulc from the package in the browser only
  (SSR never imports it) and creates the client in package mode, keeping the
  60 s request timeout and the existing states (checking, unsupported,
  loading, ready, error). The manifest comes from the package's small
  `engine` module; nothing large is fetched before a feature needs the engine.
- Removed scripts/fetch-julc.mjs, julc.lock.json, scripts/lib/untar.mjs (and
  its test), the predev/prebuild hooks and the static/julc ignores.
- Removed PUBLIC_JULC_BASE_URL and the blob: worker shim for an engine on
  another host: the package's worker loads engine files from the page's own
  origin only.
- vite.config.js: the dev server must not pre-bundle the julc packages (their
  worker and engine files are named relative to their own modules); without
  this the dev worker 404s. Production builds need nothing.
- types.ts: Manifest, Features and FeatureGroup are the package's own types;
  the package's client is assigned to the viewer's JulcClient without a cast,
  so a change in the engine's API shows up in svelte-check.
- julc 0.1.0-pre21 reads plain Java (ADR-068): the ledger and stdlib are no
  longer imported implicitly, so the lab's examples import what they use.
- User-facing texts no longer name julc 0.1.0-pre18: the Java debugger shows
  the engine's version, and the V1 replay note drops the pre18 claim.
- README: how the engine is installed and upgraded, the dev-server and CSP
  requirements, and the explicit imports.

package-lock.json is not updated: 0.1.0-pre21 is not published yet. Run
npm install once it is, before merging (npm ci fails until then).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown

Initial automated review · Aster

Hi @satran004, thanks for the PR! 🙏 This is an automatic first check by an AI reviewer. It does not replace maintainer review and may be wrong.

I reviewed this while it was still a draft.

Reviewed commit: adc9008a20e121618eedf7dcc9c7ff4bc6b1f0e7

No issues found in this first check.

Not tested: I did not install dependencies, build, or run browser tests, and the published package contents remain unverified.

JuLC 0.1.0-pre21 is published. The lock adds only @julclang/julc-wasm and
@julclang/wasm-client 0.1.0-pre21 from registry.npmjs.org; their integrity
matches the tarballs attached to the julc v0.1.0-pre21 GitHub release, and
npm audit signatures verifies their registry signatures and provenance
(native-image-release.yml at v0.1.0-pre21). npm ci works again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@satran004
satran004 marked this pull request as ready for review November 18, 2026 08:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants