From adc9008a20e121618eedf7dcc9c7ff4bc6b1f0e7 Mon Sep 17 00:00:00 2001 From: Satya Date: Wed, 18 Nov 2026 07:59:48 +0800 Subject: [PATCH 1/2] Viewer: load Script Lab's julc engine from the @julclang/julc-wasm npm 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 --- applications/viewer/.dockerignore | 1 - applications/viewer/.gitignore | 1 - applications/viewer/README.md | 26 +++--- applications/viewer/julc.lock.json | 8 -- applications/viewer/package.json | 3 +- applications/viewer/scripts/fetch-julc.mjs | 84 ------------------- applications/viewer/scripts/lib/untar.mjs | 32 ------- applications/viewer/scripts/lib/untar.test.ts | 48 ----------- .../lib/julc/authoring/JavaDebugger.svelte | 2 +- .../viewer/src/lib/julc/authoring/examples.ts | 25 +++++- .../viewer/src/lib/julc/engine.svelte.ts | 40 ++++----- .../viewer/src/lib/julc/replay/build.ts | 2 +- applications/viewer/src/lib/julc/types.ts | 30 ++----- applications/viewer/vite.config.js | 4 +- 14 files changed, 69 insertions(+), 237 deletions(-) delete mode 100644 applications/viewer/julc.lock.json delete mode 100644 applications/viewer/scripts/fetch-julc.mjs delete mode 100644 applications/viewer/scripts/lib/untar.mjs delete mode 100644 applications/viewer/scripts/lib/untar.test.ts diff --git a/applications/viewer/.dockerignore b/applications/viewer/.dockerignore index 4cda9105..89d5fdb4 100644 --- a/applications/viewer/.dockerignore +++ b/applications/viewer/.dockerignore @@ -8,4 +8,3 @@ deno.lock .env .env.* *.log -static/julc diff --git a/applications/viewer/.gitignore b/applications/viewer/.gitignore index de53264b..0befb9d0 100644 --- a/applications/viewer/.gitignore +++ b/applications/viewer/.gitignore @@ -9,7 +9,6 @@ node_modules vite.config.js.timestamp-* vite.config.ts.timestamp-* .idea -/static/julc /test-results /playwright-report /.cache diff --git a/applications/viewer/README.md b/applications/viewer/README.md index 9158eded..72178208 100644 --- a/applications/viewer/README.md +++ b/applications/viewer/README.md @@ -60,7 +60,6 @@ Set these in the environment, or in a `.env` file in the directory you start Yac | `PUBLIC_INDEXER_CLIENT_BASE_URL` | same as above | Yaci Store as the browser sees it, when that differs (e.g. Docker) | | `PUBLIC_INDEXER_WS_URL` | `ws://localhost:8080/ws/liveblocks` | Live updates. Leave empty for a store without the live module; the viewer polls instead | | `PUBLIC_MAINTENANCE_MSG` | | Optional banner shown on every page | -| `PUBLIC_JULC_BASE_URL` | `/julc/` | Where the browser loads the julc engine from, if not served by Yaci Viewer itself | | `PORT`, `HOST` | `3000`, `0.0.0.0` | Where Yaci Viewer listens | | `HEAVY_ADDRESS_GUARD` | `true` | Protects a large Yaci Store from busy addresses (below). `false` restores the plain behaviour | | `YACI_ANALYTICS` | `auto` | `off` stops Yaci Viewer from using the store's analytics query API (below) even when the store has it | @@ -153,15 +152,22 @@ npm run build # production build in build/, run with `node build` ### Script Lab and the julc engine -Script Lab uses the julc WebAssembly engine. It is not built here: `npm run dev` and `npm run build` run -`scripts/fetch-julc.mjs`, which downloads the julc release pinned in `julc.lock.json`, checks its SHA-256 and unpacks it -into `static/julc/` (git-ignored). The engine is only downloaded by the browser when a user decodes a script (about -5.5 MB with compression, then cached). - -- A production build fails if the engine can't be installed. Set `JULC_SKIP=1` to build without Script Lab (its - panels then say so), or `JULC_ARCHIVE=/path/to/julc-wasm-.tar.gz` to install from a local copy. -- To upgrade julc, change `tag`, `version`, `file` and `sha256` in `julc.lock.json` together; the checksum is in the - release's `julc-wasm--SHA256SUMS.txt`. +Script Lab uses the julc WebAssembly engine from the npm package +[`@julclang/julc-wasm`](https://www.npmjs.com/package/@julclang/julc-wasm) (with its client, `@julclang/wasm-client`). +julc is never built here: the package is an ordinary dependency, pinned to an exact julc release in `package.json`, and +Vite bundles its worker, launcher and WebAssembly module into the build as assets, served by Yaci Viewer itself (the +engine only loads them from the page's own origin). The engine is only downloaded by the browser when a feature needs it +(a 35 MB WebAssembly module, about 9 MB with Brotli, which the production server sends precompressed; then cached). + +- To upgrade julc, change the version of `@julclang/julc-wasm` in `package.json` (exact; it brings the client at the + same version) and run `npm install`. +- The Vite dev server must not pre-bundle the julc packages (`optimizeDeps.exclude` in `vite.config.js`): their files + are named relative to their own modules. Production builds need nothing. +- A Content Security Policy in front of Yaci Viewer must allow `script-src 'self' 'wasm-unsafe-eval'`, on the page and + on the engine's worker scripts. +- The validator lab compiles plain Java: a validator imports the ledger and stdlib classes it uses (for example + `import org.julclang.stdlib.annotation.SpendingValidator;`). Since julc 0.1.0-pre21 they are no longer imported + implicitly, so a source saved in the browser by an earlier version may need its imports added. - The engine needs WebAssembly GC and exception handling (exnref): current Chrome, Edge, Firefox and Safari. Other browsers get a message instead. Playwright's bundled Chromium is too old, so run the Script Lab test with Chrome: `SCRIPT_LAB_HASH= SCRIPT_LAB_TX= SCRIPT_LAB_RUN= SCRIPT_LAB_PROPOSAL=_ PW_CHANNEL=chrome npx playwright test script-lab`. diff --git a/applications/viewer/julc.lock.json b/applications/viewer/julc.lock.json deleted file mode 100644 index ab4f9c9b..00000000 --- a/applications/viewer/julc.lock.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "comment": "julc WebAssembly engine used by Script Lab. Downloaded from the GitHub release by scripts/fetch-julc.mjs and checked against sha256. To upgrade, change tag, version, file and sha256 together (sha256 from the release's julc-wasm--SHA256SUMS.txt).", - "repo": "bloxbean/julc", - "tag": "v0.1.0-pre18", - "version": "0.1.0-pre18", - "file": "julc-wasm-0.1.0-pre18.tar.gz", - "sha256": "475cb97719f882ae889f24a341b6f2713e3a7ac0164d32f25e048792936ffa28" -} diff --git a/applications/viewer/package.json b/applications/viewer/package.json index 3895fe3b..aa445336 100644 --- a/applications/viewer/package.json +++ b/applications/viewer/package.json @@ -11,9 +11,7 @@ "homepage": "https://devkit.yaci.xyz/", "repository": "github:bloxbean/yaci-devkit", "scripts": { - "predev": "node scripts/fetch-julc.mjs --optional", "dev": "vite dev --host 0.0.0.0", - "prebuild": "node scripts/fetch-julc.mjs", "build": "vite build", "preview": "vite preview --host 0.0.0.0", "test": "playwright test", @@ -34,6 +32,7 @@ "@fontsource-variable/inter": "5.3.0", "@fontsource-variable/jetbrains-mono": "5.3.0", "@fontsource-variable/space-grotesk": "5.3.0", + "@julclang/julc-wasm": "0.1.0-pre21", "@lucide/svelte": "1.47.0", "@playwright/test": "^1.46.0", "@sveltejs/adapter-node": "5.5.7", diff --git a/applications/viewer/scripts/fetch-julc.mjs b/applications/viewer/scripts/fetch-julc.mjs deleted file mode 100644 index 3a557f6e..00000000 --- a/applications/viewer/scripts/fetch-julc.mjs +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env node -/* - * Installs the julc WebAssembly engine (Script Lab) into static/julc/ from the julc GitHub release pinned in - * julc.lock.json. julc is never built here: the release archive is downloaded, checked against the pinned sha256 - * and unpacked (plain files only). - * - * node scripts/fetch-julc.mjs required: fails the build if the engine can't be installed - * node scripts/fetch-julc.mjs --optional dev: warns and carries on; Script Lab hides itself - * - * JULC_SKIP=1 skip entirely (Script Lab hidden) - * JULC_ARCHIVE= use a local copy of the release archive (offline builds); it is still checked - */ -import { createHash } from 'node:crypto'; -import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { gunzipSync } from 'node:zlib'; -import { untar } from './lib/untar.mjs'; - -const root = join(dirname(fileURLToPath(import.meta.url)), '..'); -const optional = process.argv.includes('--optional'); -const lock = JSON.parse(readFileSync(join(root, 'julc.lock.json'), 'utf8')); -const target = join(root, 'static', 'julc'); -const marker = join(root, 'node_modules', '.cache', 'julc', 'installed'); -const cacheFile = join(root, 'node_modules', '.cache', 'julc', lock.file); -const url = `https://github.com/${lock.repo}/releases/download/${lock.tag}/${lock.file}`; - -const log = (msg) => console.log(`[julc] ${msg}`); -const sha256 = (buf) => createHash('sha256').update(buf).digest('hex'); - -async function archive() { - if (process.env.JULC_ARCHIVE) return readFileSync(process.env.JULC_ARCHIVE); - if (existsSync(cacheFile)) { - const cached = readFileSync(cacheFile); - if (sha256(cached) === lock.sha256) return cached; - } - log(`downloading ${url}`); - const res = await fetch(url, { signal: AbortSignal.timeout(120_000) }); - if (!res.ok) throw new Error(`download failed: HTTP ${res.status}`); - const buf = Buffer.from(await res.arrayBuffer()); - mkdirSync(dirname(cacheFile), { recursive: true }); - writeFileSync(cacheFile, buf); - return buf; -} - -async function install() { - if (existsSync(marker) && existsSync(join(target, 'engine.json')) && readFileSync(marker, 'utf8').trim() === lock.sha256) { - log(`engine ${lock.version} already installed`); - return; - } - const buf = await archive(); - const actual = sha256(buf); - if (actual !== lock.sha256) throw new Error(`checksum mismatch for ${lock.file}: expected ${lock.sha256}, got ${actual}`); - - const files = untar(gunzipSync(buf)); - const engine = files.get('engine.json'); - if (!engine) throw new Error('archive has no engine.json'); - const manifest = JSON.parse(engine.toString('utf8')); - if (manifest.julcVersion !== lock.version) throw new Error(`archive is julc ${manifest.julcVersion}, lock says ${lock.version}`); - if (!files.has(manifest.launcher) || !files.has(`${manifest.launcher}.wasm`)) throw new Error('archive is missing the engine launcher'); - - rmSync(target, { recursive: true, force: true }); - mkdirSync(target, { recursive: true }); - // Type declarations aren't needed at runtime (the viewer has its own, src/lib/julc/types.ts). - for (const [name, body] of files) if (!name.endsWith('.d.ts')) writeFileSync(join(target, name), body); - mkdirSync(dirname(marker), { recursive: true }); - writeFileSync(marker, lock.sha256 + '\n'); - log(`installed engine ${lock.version} (${manifest.variant}, ${manifest.version}) into static/julc`); -} - -if (process.env.JULC_SKIP === '1') { - log('JULC_SKIP=1: skipping; Script Lab will be hidden'); -} else { - try { - await install(); - } catch (e) { - const msg = e instanceof Error ? e.message : String(e); - if (!optional) { - console.error(`[julc] ${msg}\n[julc] Set JULC_ARCHIVE to a local copy of ${lock.file}, or JULC_SKIP=1 to build without Script Lab.`); - process.exit(1); - } - log(`${msg}; continuing without Script Lab`); - } -} diff --git a/applications/viewer/scripts/lib/untar.mjs b/applications/viewer/scripts/lib/untar.mjs deleted file mode 100644 index 3f9dd6f3..00000000 --- a/applications/viewer/scripts/lib/untar.mjs +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Minimal reader for the flat tar archives julc releases ship. Only regular files at the top level are returned; - * directories, links, pax headers and anything with a nested or unusual name are skipped, so an archive can't - * write outside the target folder. - */ -const SAFE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/; - -function field(block, start, length) { - const end = block.indexOf(0, start); - return block.toString('utf8', start, end === -1 || end > start + length ? start + length : end); -} - -/** @param {Buffer} tar @returns {Map} */ -export function untar(tar) { - const files = new Map(); - let offset = 0; - while (offset + 512 <= tar.length) { - const header = tar.subarray(offset, offset + 512); - if (header.every((b) => b === 0)) break; - const size = parseInt(field(header, 124, 12).trim() || '0', 8); - if (!Number.isFinite(size) || size < 0) throw new Error('corrupt tar header'); - const type = String.fromCharCode(header[156] || 48); - const prefix = field(header, 345, 155); - const name = (prefix ? `${prefix}/` : '') + field(header, 0, 100); - const body = tar.subarray(offset + 512, offset + 512 + size); - if (body.length !== size) throw new Error('truncated tar archive'); - const base = name.replace(/^\.\//, ''); - if (type === '0' && SAFE_NAME.test(base)) files.set(base, Buffer.from(body)); - offset += 512 + Math.ceil(size / 512) * 512; - } - return files; -} diff --git a/applications/viewer/scripts/lib/untar.test.ts b/applications/viewer/scripts/lib/untar.test.ts deleted file mode 100644 index b42591ba..00000000 --- a/applications/viewer/scripts/lib/untar.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { describe, expect, it } from 'vitest'; -import { untar } from './untar.mjs'; - -/* Build a tar archive in memory: entries of [name, body, typeflag]. */ -function tar(entries: [string, string, string?][]): Buffer { - const blocks: Buffer[] = []; - for (const [name, body, type = '0'] of entries) { - const header = Buffer.alloc(512); - header.write(name, 0, 100, 'utf8'); - header.write(body.length.toString(8).padStart(11, '0') + '\0', 124, 12, 'utf8'); - header.write(type, 156, 1, 'utf8'); - blocks.push(header); - const data = Buffer.alloc(Math.ceil(body.length / 512) * 512); - data.write(body, 0, 'utf8'); - blocks.push(data); - } - blocks.push(Buffer.alloc(1024)); - return Buffer.concat(blocks); -} - -describe('untar', () => { - it('returns top-level regular files', () => { - const files = untar(tar([['./', '', '5'], ['./engine.json', '{"a":1}'], ['julc-x.js', 'x'.repeat(700)]])); - expect([...files.keys()]).toEqual(['engine.json', 'julc-x.js']); - expect(files.get('engine.json')!.toString()).toBe('{"a":1}'); - expect(files.get('julc-x.js')!.length).toBe(700); - }); - - it('skips paths that could escape the target folder, links and pax headers', () => { - const files = untar( - tar([ - ['../evil.js', 'x'], - ['/etc/passwd', 'x'], - ['sub/dir.js', 'x'], - ['.hidden', 'x'], - ['link.js', '', '2'], - ['./PaxHeaders/x', 'path=a', 'x'], - ['ok.js', 'y'] - ]) - ); - expect([...files.keys()]).toEqual(['ok.js']); - }); - - it('rejects a truncated archive', () => { - const t = tar([['a.js', 'x'.repeat(600)]]); - expect(() => untar(t.subarray(0, 700))).toThrow(/truncated/); - }); -}); diff --git a/applications/viewer/src/lib/julc/authoring/JavaDebugger.svelte b/applications/viewer/src/lib/julc/authoring/JavaDebugger.svelte index e26d691f..3a4a54b3 100644 --- a/applications/viewer/src/lib/julc/authoring/JavaDebugger.svelte +++ b/applications/viewer/src/lib/julc/authoring/JavaDebugger.svelte @@ -156,7 +156,7 @@ {:else}
- Experimental (julc 0.1.0-pre18). {warning ?? 'This debug build is compiled without the optimizer, so its budget differs from your script’s.'} Only some steps map to Java lines (reliably the one a validator fails on), and many locals aren’t tracked yet. + Experimental (julc {julc.manifest?.julcVersion ?? ''}). {warning ?? 'This debug build is compiled without the optimizer, so its budget differs from your script’s.'} Only some steps map to Java lines (reliably the one a validator fails on), and many locals aren’t tracked yet.
{#if unmapped}

julc mapped none of this run’s steps to a Java line, so there is nothing to stop on. The UPLC debugger steps through every term.

{/if}
diff --git a/applications/viewer/src/lib/julc/authoring/examples.ts b/applications/viewer/src/lib/julc/authoring/examples.ts index 7d2a143e..5489dc34 100644 --- a/applications/viewer/src/lib/julc/authoring/examples.ts +++ b/applications/viewer/src/lib/julc/authoring/examples.ts @@ -1,4 +1,5 @@ -/* Starter validators for the validator lab, in julc Java. Each compiles with julc 0.1.0-pre18. */ +/* Starter validators for the validator lab, in julc Java. Each compiles with julc 0.1.0-pre21, which reads plain Java: every + * class is imported, as javac needs (the ledger and stdlib are no longer imported implicitly). */ export interface Example { id: string; @@ -14,6 +15,13 @@ export const EXAMPLES: Example[] = [ summary: 'Spend: the beneficiary can claim after a time; the owner can cancel at any time.', source: `import java.math.BigInteger; +import org.julclang.ledger.ScriptContext; +import org.julclang.ledger.TxInfo; +import org.julclang.stdlib.annotation.Entrypoint; +import org.julclang.stdlib.annotation.SpendingValidator; +import org.julclang.stdlib.lib.ContextsLib; +import org.julclang.stdlib.lib.IntervalLib; + @SpendingValidator class Vesting { record VestingDatum(byte[] owner, byte[] beneficiary, BigInteger unlockAt) {} @@ -42,7 +50,14 @@ class Vesting { id: 'owner', name: 'Owner only', summary: 'Spend: a script parameter fixes the one key that may spend.', - source: `@SpendingValidator + source: `import org.julclang.core.PlutusData; +import org.julclang.ledger.ScriptContext; +import org.julclang.stdlib.annotation.Entrypoint; +import org.julclang.stdlib.annotation.Param; +import org.julclang.stdlib.annotation.SpendingValidator; +import org.julclang.stdlib.lib.ContextsLib; + +@SpendingValidator class OwnerOnly { @Param static byte[] owner; @@ -61,6 +76,12 @@ class OwnerOnly { summary: 'Mint: minting needs the issuer’s signature; anyone may burn.', source: `import java.math.BigInteger; +import org.julclang.ledger.ScriptContext; +import org.julclang.stdlib.annotation.Entrypoint; +import org.julclang.stdlib.annotation.MintingValidator; +import org.julclang.stdlib.annotation.Param; +import org.julclang.stdlib.lib.ContextsLib; + @MintingValidator class SignedMint { @Param static byte[] issuer; diff --git a/applications/viewer/src/lib/julc/engine.svelte.ts b/applications/viewer/src/lib/julc/engine.svelte.ts index 41f88f14..7af400cd 100644 --- a/applications/viewer/src/lib/julc/engine.svelte.ts +++ b/applications/viewer/src/lib/julc/engine.svelte.ts @@ -1,11 +1,12 @@ import { browser } from '$app/environment'; -import { env } from '$env/dynamic/public'; import type { JulcClient, JulcError, Manifest } from './types'; /* - * The julc engine (Script Lab), loaded on first use and shared by every page. It runs in its own worker, so a long - * evaluation never blocks the page. Nothing is downloaded until a feature asks for the client; installs without the - * engine (JULC_SKIP) report 'absent' and the features hide themselves. + * The julc engine (Script Lab), loaded on first use and shared by every page. It comes from the @julclang/julc-wasm + * package, which the build bundles: its worker, launcher and WebAssembly module are emitted as assets and served by + * this viewer (the engine only loads them from the page's own origin). It runs in its own worker, so a long evaluation + * never blocks the page. Nothing is downloaded until a feature asks for the client. The package is imported in the + * browser only, never during server rendering. */ export type EngineStatus = 'idle' | 'checking' | 'absent' | 'unsupported' | 'loading' | 'ready' | 'error'; @@ -27,19 +28,6 @@ export function wasmSupported(): boolean { } } -export function engineBaseUrl(): URL { - const configured = env.PUBLIC_JULC_BASE_URL; - const raw = (configured || '/julc/').replace(/\/?$/, '/'); - return new URL(raw, browser ? location.href : 'http://localhost/'); -} - -/** Workers must be same-origin; for an engine on another host, start a tiny worker that imports julc's. */ -function workerFactory(url: URL): Worker { - if (url.origin === location.origin) return new Worker(url); - const shim = new Blob([`importScripts(${JSON.stringify(url.href)});`], { type: 'text/javascript' }); - return new Worker(URL.createObjectURL(shim)); -} - class JulcEngine { status = $state('idle'); error = $state(null); @@ -50,19 +38,23 @@ class JulcEngine { #manifest: Promise | null = null; #client: Promise | null = null; - /** Is an engine installed with this viewer? Reads engine.json (a few hundred bytes). */ + /** + * The engine this viewer was built with: its manifest, from the package's small `engine` module (the engine itself + * is not downloaded). Null during server rendering, or when that module can't be loaded (e.g. the network failed). + */ available(): Promise { if (!browser) return Promise.resolve(null); this.#manifest ??= (async () => { if (this.status === 'idle') this.status = 'checking'; try { - const res = await fetch(new URL('engine.json', engineBaseUrl()), { cache: 'no-cache' }); - const manifest = res.ok ? ((await res.json()) as Manifest) : null; + const { engineFiles } = await import('@julclang/julc-wasm/engine'); + const manifest: Manifest = engineFiles().manifest; this.manifest = manifest; - if (this.status === 'checking') this.status = manifest ? 'idle' : 'absent'; + if (this.status === 'checking') this.status = 'idle'; return manifest; } catch { if (this.status === 'checking') this.status = 'absent'; + this.#manifest = null; return null; } })(); @@ -125,9 +117,9 @@ class JulcEngine { this.error = null; const started = performance.now(); try { - const baseUrl = engineBaseUrl(); - const mod = await import(/* @vite-ignore */ new URL(`julc-wasm.js?engine=${encodeURIComponent(manifest.version)}`, baseUrl).href); - const client = (await mod.createJulc({ baseUrl, manifest, workerFactory, timeoutMs: 60_000 })) as JulcClient; + const { createJulc } = await import('@julclang/julc-wasm'); + // The package names its own engine files and checks they are of its release; rest is off in package mode. + const client: JulcClient = await createJulc({ timeoutMs: 60_000 }); this.loadMs = Math.round(performance.now() - started); this.status = 'ready'; return client; diff --git a/applications/viewer/src/lib/julc/replay/build.ts b/applications/viewer/src/lib/julc/replay/build.ts index 93cb0f16..0b75a305 100644 --- a/applications/viewer/src/lib/julc/replay/build.ts +++ b/applications/viewer/src/lib/julc/replay/build.ts @@ -393,7 +393,7 @@ export function buildRuns(input: ReplayInput): RunPlan[] { if (runs.length > 1) plan.notes.push('Only this script’s redeemer is in the context (julc#244). A script that reads the other redeemers, such as a withdraw-zero validator, can fail here although it passed on chain.'); if (input.certificates.length && !certsComplete) plan.notes.push('Some certificates in this transaction couldn’t be rebuilt, so the context lists only part of them.'); if (input.paramsEpoch === null) plan.notes.push('The store has no parameters for this transaction’s epoch, so the latest epoch’s cost model was used.'); - if (language === 'V1') plan.notes.push('Plutus V1 contexts from julc 0.1.0-pre18 can differ from the ledger’s (V1/V2 translation fixes are on julc main), so some V1 runs fail here although they passed on chain.'); + if (language === 'V1') plan.notes.push('Plutus V1 contexts built by julc can still differ from the ledger’s, so some V1 runs fail here although they passed on chain.'); if (pv != null && pv !== protocol) plan.notes.push(`Evaluated with protocol ${protocol} rules; the transaction ran under protocol ${pv}.`); if (pv === 10 && language === 'V3') plan.notes.push('Under protocol 10 the ledger costed some builtins differently from julc, so CPU can differ slightly from the declared budget (memory is unaffected).'); diff --git a/applications/viewer/src/lib/julc/types.ts b/applications/viewer/src/lib/julc/types.ts index 5ce7a6c0..84ff119b 100644 --- a/applications/viewer/src/lib/julc/types.ts +++ b/applications/viewer/src/lib/julc/types.ts @@ -1,8 +1,9 @@ /* - * The parts of the julc WebAssembly API (julc-wasm.d.ts, API version 0) that the viewer uses. The engine itself is - * downloaded at build time (scripts/fetch-julc.mjs), so its own typings aren't available to the type checker. - * Long and BigInteger fields are bigint. + * The parts of the julc WebAssembly API (API version 0) that the viewer uses, written against what it reads; the + * client of @julclang/julc-wasm must stay assignable to JulcClient (engine.svelte.ts checks it). Long and BigInteger + * fields are bigint. */ +import type { Features } from '@julclang/julc-wasm'; export type PlutusVersion = 'V1' | 'V2' | 'V3'; @@ -206,23 +207,8 @@ export interface DebugSession { close(): Promise<{ closed: boolean }>; } -export type FeatureGroup = 'vm' | 'debug' | 'compiler' | 'uplc' | 'sourceDebug' | 'sourceDebugLocals'; - -export interface Features { - api: 0; - variant: 'full' | 'vm'; - groups: FeatureGroup[]; - defaultProtocol: number; -} - -export interface Manifest { - api: 0; - version: string; - launcher: string; - variant: 'full' | 'vm'; - groups?: FeatureGroup[]; - julcVersion: string; -} +/** The engine's description and capabilities, as @julclang/julc-wasm declares them. */ +export type { FeatureGroup, Features, Manifest } from '@julclang/julc-wasm'; export interface JulcClient { version(): string; @@ -249,8 +235,8 @@ export interface JulcClient { /** Full engine only. */ uplc?: { evaluateTransaction(request: TransactionRequest): Promise; - /** julc's sample transaction for a purpose (one key input and output). */ - defaultTransaction?(request: { purpose: MockPurpose['type'] }): Promise; + /** julc's sample transaction for a purpose (one key input and output); the package types every field nullable. */ + defaultTransaction?(request: { purpose: MockPurpose['type'] }): Promise; }; } diff --git a/applications/viewer/vite.config.js b/applications/viewer/vite.config.js index e524313b..66e482a1 100644 --- a/applications/viewer/vite.config.js +++ b/applications/viewer/vite.config.js @@ -5,7 +5,9 @@ export default { plugins: [sveltekit()], optimizeDeps: { // Icons are imported one file each; pre-bundling them on demand reloads the dev page mid-hydration. - exclude: ['@lucide/svelte'] + // The julc engine names its worker and engine files relative to its own modules (new URL(…, import.meta.url)), + // which pre-bundling moves: the dev server then can't find the worker. Production builds need nothing. + exclude: ['@lucide/svelte', '@julclang/wasm-client', '@julclang/julc-wasm'] }, test: { include: ['src/**/*.{test,spec}.{js,ts}', 'scripts/**/*.test.ts'] From c1227d33521f0cf850c9d29474d36b4d3f1abb9e Mon Sep 17 00:00:00 2001 From: Satya Date: Wed, 18 Nov 2026 16:47:51 +0800 Subject: [PATCH 2/2] Viewer: lock @julclang/julc-wasm 0.1.0-pre21 from npm 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 --- applications/viewer/package-lock.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/applications/viewer/package-lock.json b/applications/viewer/package-lock.json index 8aaa853f..1b43e3af 100644 --- a/applications/viewer/package-lock.json +++ b/applications/viewer/package-lock.json @@ -19,6 +19,7 @@ "@fontsource-variable/inter": "5.3.0", "@fontsource-variable/jetbrains-mono": "5.3.0", "@fontsource-variable/space-grotesk": "5.3.0", + "@julclang/julc-wasm": "0.1.0-pre21", "@lucide/svelte": "1.47.0", "@playwright/test": "^1.46.0", "@sveltejs/adapter-node": "5.5.7", @@ -764,6 +765,29 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@julclang/julc-wasm": { + "version": "0.1.0-pre21", + "resolved": "https://registry.npmjs.org/@julclang/julc-wasm/-/julc-wasm-0.1.0-pre21.tgz", + "integrity": "sha512-kCvgFGFn/fiGXRh41Hlm+pWb8JDYHmSlLDHI4sRRa6BAp4kQ40nbUhi9OlP3QwZL1AMoLC/27u93HKDD7w4xkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@julclang/wasm-client": "0.1.0-pre21" + }, + "engines": { + "node": ">=22.3.0" + } + }, + "node_modules/@julclang/wasm-client": { + "version": "0.1.0-pre21", + "resolved": "https://registry.npmjs.org/@julclang/wasm-client/-/wasm-client-0.1.0-pre21.tgz", + "integrity": "sha512-7lqQns01Px8Opeo/Rgr8Ijqj4sCcrs/g2/+HRvYc8BXSxNnQzIqsyEHeli3tetCpXS8HDCxUC145An0rLLZl3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.3.0" + } + }, "node_modules/@lucide/svelte": { "version": "1.47.0", "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-1.47.0.tgz",