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:
parent
5846c3d6d2
commit
79826b9a4d
|
|
@ -91,8 +91,12 @@ export class WasmClient implements NvsimClient {
|
||||||
|
|
||||||
async boot(): Promise<WasmBootInfo> {
|
async boot(): Promise<WasmBootInfo> {
|
||||||
if (this.bootInfo) return this.bootInfo;
|
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 }>(
|
const r = await this.rpc<{ buildVersion: string; frameMagic: number; frameBytes: number; expectedWitnessHex: string }>(
|
||||||
{ type: 'boot' },
|
{ type: 'boot', base },
|
||||||
);
|
);
|
||||||
this.bootInfo = {
|
this.bootInfo = {
|
||||||
buildVersion: r.buildVersion,
|
buildVersion: r.buildVersion,
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,12 @@ let expectedReferenceWitnessHex!: () => string;
|
||||||
let hexWitness!: (b: Uint8Array) => string;
|
let hexWitness!: (b: Uint8Array) => string;
|
||||||
let referenceWitness!: () => Uint8Array;
|
let referenceWitness!: () => Uint8Array;
|
||||||
|
|
||||||
async function loadPkg(): Promise<void> {
|
async function loadPkg(base: string): Promise<void> {
|
||||||
const baseHref = `${ws.location.origin}/`;
|
// `base` is the dashboard's BASE_URL injected by Vite, prefixed with the
|
||||||
const pkgUrl = new URL('nvsim-pkg/nvsim.js', baseHref).href;
|
// 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;
|
const pkg = (await import(/* @vite-ignore */ pkgUrl)) as NvsimPkg;
|
||||||
await pkg.default();
|
await pkg.default();
|
||||||
_WasmPipeline = pkg.WasmPipeline;
|
_WasmPipeline = pkg.WasmPipeline;
|
||||||
|
|
@ -119,7 +122,8 @@ ws.addEventListener('message', async (ev: MessageEvent): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case 'boot': {
|
case 'boot': {
|
||||||
await loadPkg();
|
const base = (m.base as string | undefined) ?? '/';
|
||||||
|
await loadPkg(base);
|
||||||
ensureRebuild();
|
ensureRebuild();
|
||||||
post({
|
post({
|
||||||
type: 'booted',
|
type: 'booted',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue