Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions packages/gambit-core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3022,21 +3022,30 @@ function collectLocalImportGraph(entryPath: string): Set<string> {
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<string> | undefined;
function builtinSchemaBootstrapReads(): Array<string> {
if (!BUILTIN_SCHEMAS_DIR) return [];
if (builtinSchemaBootstrapCache) return builtinSchemaBootstrapCache;
const schemaModules: Array<string> = [];
const stack: Array<string> = [BUILTIN_SCHEMAS_DIR];
Expand Down Expand Up @@ -3072,6 +3081,7 @@ function builtinSchemaBootstrapReads(): Array<string> {

let builtinSnippetBootstrapCache: Array<string> | undefined;
function builtinSnippetBootstrapReads(): Array<string> {
if (!BUILTIN_SNIPPETS_DIR) return [];
if (builtinSnippetBootstrapCache) return builtinSnippetBootstrapCache;
const snippetFiles: Array<string> = [];
const stack: Array<string> = [BUILTIN_SNIPPETS_DIR];
Expand Down Expand Up @@ -3115,6 +3125,10 @@ function workerBootstrapReadAllowlist(deckPath: string): Array<string> {
let trustedWorkerBootstrapCache: Array<string> | undefined;
function trustedWorkerBootstrapReads(): Array<string> {
if (trustedWorkerBootstrapCache) return trustedWorkerBootstrapCache;
if (!moduleBaseFilePath) {
trustedWorkerBootstrapCache = [];
return trustedWorkerBootstrapCache;
}
const definitionsPath = path.fromFileUrl(
new URL("./definitions.ts", import.meta.url),
);
Expand Down
12 changes: 12 additions & 0 deletions scripts/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ const resolveCoreDir = async (): Promise<string> => {
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",
Expand All @@ -54,7 +62,11 @@ const includePaths = [
"deno.jsonc",
...docIncludes,
coreCards,
coreSnippets,
coreSchemas,
coreDecks,
coreRuntimeWorker,
coreRuntimeOrchestrationWorker,
"src/decks",
"scaffolds",
"simulator-ui/dist",
Expand Down