import assert from "node:assert/strict"; import { createHash } from "node:crypto"; import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import test from "node:test"; const root = resolve(import.meta.dirname, ".."); const packageRoot = resolve(root, "node_modules/@rerun-io/web-viewer"); const readJson = (path) => JSON.parse(readFileSync(path, "utf8")); test("Mission Core pins Rerun 0.36.3 with the bounded native navigation installer", () => { const application = readJson(resolve(root, "package.json")); const installed = readJson(resolve(packageRoot, "package.json")); assert.equal(application.dependencies["@rerun-io/web-viewer"], "0.36.3"); assert.equal(installed.version, "0.36.3"); assert.equal(application.scripts.postinstall, "node scripts/install-rerun-navigation.mjs"); assert.equal(application.scripts.prebuild, application.scripts.postinstall); }); test("native navigation artifacts and source patch match their provenance", () => { const vendorRoot = resolve(root, "vendor/rerun-web-viewer-0.36.3"); const manifest = readJson(resolve(vendorRoot, "navigation-build.json")); const sha = bytes => createHash("sha256").update(bytes).digest("hex"); assert.equal(manifest.upstreamVersion, "0.36.3"); assert.equal(manifest.upstreamCommit, "6ded109d33c549e98185f7c95fa8009d44e4adef"); assert.equal(sha(readFileSync(resolve(vendorRoot, "NODEDC_NAVIGATION.patch"))), manifest.patchSha256); for (const [name, identity] of Object.entries(manifest.files)) { if (!identity.artifact) continue; assert.equal(sha(readFileSync(resolve(vendorRoot, identity.artifact))), identity.sha256, name); assert.equal(sha(readFileSync(resolve(packageRoot, name))), identity.sha256, name); } }); test("generated JS and native WASM share one ABI including the camera snapshot", () => { const glue = readFileSync(resolve(packageRoot, "re_viewer.js"), "utf8"); const wasm = new WebAssembly.Module(readFileSync(resolve(packageRoot, "re_viewer_bg.wasm"))); const names = new Set(WebAssembly.Module.exports(wasm).map(item => item.name)); assert.ok(names.has("webhandle_nodedc_camera_eye")); for (const [, name] of glue.matchAll(/\bwasm\.([a-zA-Z_$][\w$]*)/g)) { assert.ok(names.has(name), `Missing WASM export: ${name}`); } assert.match(readFileSync(resolve(packageRoot, "index.js"), "utf8"), /this\.#handle\.nodedc_camera_eye\(\)/); assert.match(readFileSync(resolve(packageRoot, "index.d.ts"), "utf8"), /get_camera_eye\(\)/); assert.match(readFileSync(resolve(packageRoot, "re_viewer.d.ts"), "utf8"), /nodedc_camera_eye\(\)/); }); test("the active application never imports or installs the archived vendor fork", () => { const application = readFileSync(resolve(root, "package.json"), "utf8"); const viewport = readFileSync(resolve(root, "src/components/RerunViewport.tsx"), "utf8"); assert.doesNotMatch(application, /patch-rerun-web-viewer/); assert.doesNotMatch(application, /vendor\/rerun-web-viewer/); assert.doesNotMatch(viewport, /vendor\/rerun-web-viewer/); assert.doesNotMatch(viewport, /0\.34\.1/); }); test("upstream WebViewer exposes one three-argument start contract", () => { const declaration = readFileSync(resolve(packageRoot, "index.d.ts"), "utf8"); assert.match( declaration, /start\(rrd: string \| string\[\] \| null, parent: HTMLElement \| null, options: WebViewerOptions \| null\): Promise/, ); });