fix(dashboard): pass Vite BASE_URL to worker for GH-Pages base resolution

Worker was resolving /nvsim-pkg/ against self.location.origin, which
under GitHub Pages stripped the /RuView/nvsim/ prefix and 404'd on the
WASM module. Main thread now reads import.meta.env.BASE_URL and forwards
it in the boot RPC; worker resolves against that.

Verified live at https://ruvnet.github.io/RuView/nvsim/ — boot succeeds,
witness verified, determinism gate ✓.

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
ruv 2026-04-26 20:15:48 -04:00
parent 5846c3d6d2
commit 79826b9a4d
2 changed files with 13 additions and 5 deletions

View File

@ -91,8 +91,12 @@ export class WasmClient implements NvsimClient {
async boot(): Promise<WasmBootInfo> {
if (this.bootInfo) return this.bootInfo;
// Pass Vite's resolved BASE_URL so the worker can locate /nvsim-pkg/
// under the same prefix the dashboard is served from (e.g. /RuView/nvsim/
// on GitHub Pages, "/" in dev).
const base = import.meta.env.BASE_URL ?? '/';
const r = await this.rpc<{ buildVersion: string; frameMagic: number; frameBytes: number; expectedWitnessHex: string }>(
{ type: 'boot' },
{ type: 'boot', base },
);
this.bootInfo = {
buildVersion: r.buildVersion,

View File

@ -38,9 +38,12 @@ let expectedReferenceWitnessHex!: () => string;
let hexWitness!: (b: Uint8Array) => string;
let referenceWitness!: () => Uint8Array;
async function loadPkg(): Promise<void> {
const baseHref = `${ws.location.origin}/`;
const pkgUrl = new URL('nvsim-pkg/nvsim.js', baseHref).href;
async function loadPkg(base: string): Promise<void> {
// `base` is the dashboard's BASE_URL injected by Vite, prefixed with the
// origin so we get an absolute URL the dynamic import can resolve. In dev
// this is "/", in prod under GitHub Pages it's "/RuView/nvsim/".
const absoluteBase = new URL(base, ws.location.origin).href;
const pkgUrl = new URL('nvsim-pkg/nvsim.js', absoluteBase).href;
const pkg = (await import(/* @vite-ignore */ pkgUrl)) as NvsimPkg;
await pkg.default();
_WasmPipeline = pkg.WasmPipeline;
@ -119,7 +122,8 @@ ws.addEventListener('message', async (ev: MessageEvent): Promise<void> => {
try {
switch (m.type) {
case 'boot': {
await loadPkg();
const base = (m.base as string | undefined) ?? '/';
await loadPkg(base);
ensureRebuild();
post({
type: 'booted',