diff --git a/packages/gambit-core/src/runtime.ts b/packages/gambit-core/src/runtime.ts index 0785a82a..b0fb8f22 100644 --- a/packages/gambit-core/src/runtime.ts +++ b/packages/gambit-core/src/runtime.ts @@ -3022,21 +3022,30 @@ function collectLocalImportGraph(entryPath: string): Set { return visited; } -const WORKER_ENTRY_PATHS = [ - "./runtime_worker.ts", - "./runtime_orchestration_worker.ts", -].map((relative) => path.fromFileUrl(new URL(relative, import.meta.url))); -const BUILTIN_SCHEMAS_DIR = path.resolve( - path.dirname(path.fromFileUrl(import.meta.url)), - "../schemas", -); -const BUILTIN_SNIPPETS_DIR = path.resolve( - path.dirname(path.fromFileUrl(import.meta.url)), - "../snippets", -); +const moduleBaseFilePath = (() => { + try { + return path.fromFileUrl(import.meta.url); + } catch { + return undefined; + } +})(); + +const WORKER_ENTRY_PATHS = moduleBaseFilePath + ? [ + "./runtime_worker.ts", + "./runtime_orchestration_worker.ts", + ].map((relative) => path.fromFileUrl(new URL(relative, import.meta.url))) + : []; +const BUILTIN_SCHEMAS_DIR = moduleBaseFilePath + ? path.resolve(path.dirname(moduleBaseFilePath), "../schemas") + : undefined; +const BUILTIN_SNIPPETS_DIR = moduleBaseFilePath + ? path.resolve(path.dirname(moduleBaseFilePath), "../snippets") + : undefined; let builtinSchemaBootstrapCache: Array | undefined; function builtinSchemaBootstrapReads(): Array { + if (!BUILTIN_SCHEMAS_DIR) return []; if (builtinSchemaBootstrapCache) return builtinSchemaBootstrapCache; const schemaModules: Array = []; const stack: Array = [BUILTIN_SCHEMAS_DIR]; @@ -3072,6 +3081,7 @@ function builtinSchemaBootstrapReads(): Array { let builtinSnippetBootstrapCache: Array | undefined; function builtinSnippetBootstrapReads(): Array { + if (!BUILTIN_SNIPPETS_DIR) return []; if (builtinSnippetBootstrapCache) return builtinSnippetBootstrapCache; const snippetFiles: Array = []; const stack: Array = [BUILTIN_SNIPPETS_DIR]; @@ -3115,6 +3125,10 @@ function workerBootstrapReadAllowlist(deckPath: string): Array { let trustedWorkerBootstrapCache: Array | undefined; function trustedWorkerBootstrapReads(): Array { if (trustedWorkerBootstrapCache) return trustedWorkerBootstrapCache; + if (!moduleBaseFilePath) { + trustedWorkerBootstrapCache = []; + return trustedWorkerBootstrapCache; + } const definitionsPath = path.fromFileUrl( new URL("./definitions.ts", import.meta.url), ); diff --git a/scripts/compile.ts b/scripts/compile.ts index 15e6ea6e..c7a9a8d7 100644 --- a/scripts/compile.ts +++ b/scripts/compile.ts @@ -32,7 +32,15 @@ const resolveCoreDir = async (): Promise => { const coreDir = await resolveCoreDir(); const coreRel = normalizePath(path.relative(packageRoot, coreDir)); const coreCards = normalizePath(path.join(coreRel, "cards")); +const coreSnippets = normalizePath(path.join(coreRel, "snippets")); const coreSchemas = normalizePath(path.join(coreRel, "schemas")); +const coreDecks = normalizePath(path.join(coreRel, "decks")); +const coreRuntimeWorker = normalizePath( + path.join(coreRel, "src", "runtime_worker.ts"), +); +const coreRuntimeOrchestrationWorker = normalizePath( + path.join(coreRel, "src", "runtime_orchestration_worker.ts"), +); const docIncludeCandidates = [ "docs/cli/commands", @@ -54,7 +62,11 @@ const includePaths = [ "deno.jsonc", ...docIncludes, coreCards, + coreSnippets, coreSchemas, + coreDecks, + coreRuntimeWorker, + coreRuntimeOrchestrationWorker, "src/decks", "scaffolds", "simulator-ui/dist",