@poe-platform/safe-js 0.1.721 → 0.1.722

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +36 -6
  2. package/dist/config-mutations/types.d.ts +3 -1
  3. package/dist/safe-js/chunks/{chunk-B4M6QVUV.js → chunk-3QQYJ4RQ.js} +3 -2
  4. package/dist/safe-js/chunks/chunk-3QQYJ4RQ.js.map +7 -0
  5. package/dist/safe-js/chunks/{chunk-BHYBD6SY.js → chunk-55RIIUGG.js} +23 -7
  6. package/dist/safe-js/chunks/chunk-55RIIUGG.js.map +7 -0
  7. package/dist/safe-js/chunks/{chunk-A4L72WXV.js → chunk-7SBQ7WTV.js} +10 -11
  8. package/dist/safe-js/chunks/chunk-7SBQ7WTV.js.map +7 -0
  9. package/dist/safe-js/chunks/{chunk-DNA7BMBY.js → chunk-BNIEPGDU.js} +8520 -7312
  10. package/dist/safe-js/chunks/{chunk-DNA7BMBY.js.map → chunk-BNIEPGDU.js.map} +4 -4
  11. package/dist/safe-js/chunks/{chunk-HYD4K4HN.js → chunk-D3GC5QPZ.js} +63 -1
  12. package/dist/safe-js/chunks/chunk-D3GC5QPZ.js.map +7 -0
  13. package/dist/safe-js/chunks/{chunk-Q7B6JIMI.js → chunk-EH5A2EQI.js} +404 -117
  14. package/dist/safe-js/chunks/chunk-EH5A2EQI.js.map +7 -0
  15. package/dist/safe-js/chunks/{chunk-4CX3HYRY.js → chunk-FA5CQO6V.js} +2 -2
  16. package/dist/safe-js/chunks/{chunk-LPBTSTDG.js → chunk-GCOLKRMY.js} +4 -4
  17. package/dist/safe-js/chunks/{chunk-GMPZBMPA.js → chunk-K3ZRBAG5.js} +3 -3
  18. package/dist/safe-js/chunks/{chunk-JNLY7IMV.js → chunk-QL2ALAE6.js} +4 -4
  19. package/dist/safe-js/chunks/{chunk-ILYJBA2D.js → chunk-RYVHEOHM.js} +1109 -100
  20. package/dist/safe-js/chunks/chunk-RYVHEOHM.js.map +7 -0
  21. package/dist/safe-js/chunks/{chunk-BEXRQET4.js → chunk-S2GFVXSI.js} +3 -3
  22. package/dist/safe-js/chunks/{chunk-Y4LNCDCP.js → chunk-WF7HYDJ4.js} +4 -5
  23. package/dist/safe-js/chunks/{chunk-Y4LNCDCP.js.map → chunk-WF7HYDJ4.js.map} +2 -2
  24. package/dist/safe-js/chunks/{chunk-IS7YUCOF.js → chunk-XHSOM5CG.js} +2 -2
  25. package/dist/safe-js/chunks/{cli-runtime-YK2WE33M.js → cli-runtime-6QPGM3TX.js} +14 -14
  26. package/dist/safe-js/chunks/{dump-ATWBOZWV.js → dump-TU6SYRFD.js} +4 -4
  27. package/dist/safe-js/chunks/{fs-D72Y52I5.js → fs-HTZT32MQ.js} +4 -4
  28. package/dist/safe-js/chunks/harness-RYAMI444.js +10 -0
  29. package/dist/safe-js/chunks/mcp-DO2IRFGQ.js +11 -0
  30. package/dist/safe-js/chunks/migration-file-K7UH5ZG6.js +12 -0
  31. package/dist/safe-js/chunks/restore-7LRP4BM3.js +13 -0
  32. package/dist/safe-js/chunks/run-6SETM7SV.js +17 -0
  33. package/dist/safe-js/chunks/runtime-modules-MCQS2SHQ.js +10 -0
  34. package/dist/safe-js/cli.js +2 -2
  35. package/dist/safe-js/core.js +7 -7
  36. package/dist/safe-js/index.js +14 -14
  37. package/dist/safe-js/interp/async.d.ts +4 -1
  38. package/dist/safe-js/interp/budget.d.ts +12 -6
  39. package/dist/safe-js/interp/collection-iterator.d.ts +1 -1
  40. package/dist/safe-js/interp/host-bridge.d.ts +1 -0
  41. package/dist/safe-js/interp/host-capabilities.d.ts +13 -4
  42. package/dist/safe-js/interp/interpreter.d.ts +5 -1
  43. package/dist/safe-js/interp/intl-numberformat.d.ts +2 -2
  44. package/dist/safe-js/interp/jobs.d.ts +8 -0
  45. package/dist/safe-js/interp/scope.d.ts +9 -2
  46. package/dist/safe-js/interp/typed-array.d.ts +2 -2
  47. package/dist/safe-js/interp/values.d.ts +1 -0
  48. package/dist/safe-js/modules/registry.d.ts +4 -1
  49. package/dist/safe-js/modules/source-graph.d.ts +19 -1
  50. package/dist/safe-js/parse/compact-spans.d.ts +18 -0
  51. package/dist/safe-js/parse/dynamic-source.d.ts +3 -1
  52. package/dist/safe-js/parse/function-source.d.ts +1 -1
  53. package/dist/safe-js/parse/parser.d.ts +8 -3
  54. package/dist/safe-js/parse/tokenizer.d.ts +4 -0
  55. package/dist/safe-js/realm.d.ts +16 -3
  56. package/dist/safe-js/restore.d.ts +1 -0
  57. package/dist/safe-js/run.d.ts +10 -0
  58. package/package.json +2 -2
  59. package/dist/safe-js/chunks/chunk-A4L72WXV.js.map +0 -7
  60. package/dist/safe-js/chunks/chunk-B4M6QVUV.js.map +0 -7
  61. package/dist/safe-js/chunks/chunk-BHYBD6SY.js.map +0 -7
  62. package/dist/safe-js/chunks/chunk-HYD4K4HN.js.map +0 -7
  63. package/dist/safe-js/chunks/chunk-ILYJBA2D.js.map +0 -7
  64. package/dist/safe-js/chunks/chunk-Q7B6JIMI.js.map +0 -7
  65. package/dist/safe-js/chunks/harness-LUYCGWHZ.js +0 -10
  66. package/dist/safe-js/chunks/mcp-IWKZB2R2.js +0 -11
  67. package/dist/safe-js/chunks/migration-file-IXO5MLP4.js +0 -12
  68. package/dist/safe-js/chunks/restore-SI7HOC6C.js +0 -13
  69. package/dist/safe-js/chunks/run-SHI2PYR6.js +0 -17
  70. package/dist/safe-js/chunks/runtime-modules-OO72HTVF.js +0 -10
  71. /package/dist/safe-js/chunks/{chunk-4CX3HYRY.js.map → chunk-FA5CQO6V.js.map} +0 -0
  72. /package/dist/safe-js/chunks/{chunk-LPBTSTDG.js.map → chunk-GCOLKRMY.js.map} +0 -0
  73. /package/dist/safe-js/chunks/{chunk-GMPZBMPA.js.map → chunk-K3ZRBAG5.js.map} +0 -0
  74. /package/dist/safe-js/chunks/{chunk-JNLY7IMV.js.map → chunk-QL2ALAE6.js.map} +0 -0
  75. /package/dist/safe-js/chunks/{chunk-BEXRQET4.js.map → chunk-S2GFVXSI.js.map} +0 -0
  76. /package/dist/safe-js/chunks/{chunk-IS7YUCOF.js.map → chunk-XHSOM5CG.js.map} +0 -0
  77. /package/dist/safe-js/chunks/{cli-runtime-YK2WE33M.js.map → cli-runtime-6QPGM3TX.js.map} +0 -0
  78. /package/dist/safe-js/chunks/{dump-ATWBOZWV.js.map → dump-TU6SYRFD.js.map} +0 -0
  79. /package/dist/safe-js/chunks/{fs-D72Y52I5.js.map → fs-HTZT32MQ.js.map} +0 -0
  80. /package/dist/safe-js/chunks/{harness-LUYCGWHZ.js.map → harness-RYAMI444.js.map} +0 -0
  81. /package/dist/safe-js/chunks/{mcp-IWKZB2R2.js.map → mcp-DO2IRFGQ.js.map} +0 -0
  82. /package/dist/safe-js/chunks/{migration-file-IXO5MLP4.js.map → migration-file-K7UH5ZG6.js.map} +0 -0
  83. /package/dist/safe-js/chunks/{restore-SI7HOC6C.js.map → restore-7LRP4BM3.js.map} +0 -0
  84. /package/dist/safe-js/chunks/{run-SHI2PYR6.js.map → run-6SETM7SV.js.map} +0 -0
  85. /package/dist/safe-js/chunks/{runtime-modules-OO72HTVF.js.map → runtime-modules-MCQS2SHQ.js.map} +0 -0
@@ -19,7 +19,11 @@ export declare class SourceModuleGraph {
19
19
  private readonly records;
20
20
  private readonly requests;
21
21
  private requestDataSize;
22
+ private lookupDataSize;
22
23
  private readonly pendingImports;
24
+ private fulfilledImports;
25
+ private rejectedImports;
26
+ private readonly importGroup;
23
27
  private readonly jobs;
24
28
  private readonly evaluationStack;
25
29
  private evaluationIndex;
@@ -27,10 +31,24 @@ export declare class SourceModuleGraph {
27
31
  scope: Scope;
28
32
  resolver: SourceResolver;
29
33
  modules: ModuleEnvironment;
34
+ serializePreparation?: boolean;
35
+ importDeadline?: {
36
+ timeoutMs: number;
37
+ abort(reason: unknown): void;
38
+ };
30
39
  });
31
40
  close(): void;
41
+ sourceModuleStatus(): Readonly<{
42
+ pendingImports: number;
43
+ preparedModules: number;
44
+ fulfilledImports: number;
45
+ rejectedImports: number;
46
+ }>;
32
47
  import(specifier: string, referrer: string): Promise<SandboxObject>;
33
- settle(): Promise<void>;
48
+ private startImportDeadline;
49
+ withoutImportGroup<Result>(task: () => Result): Result;
50
+ withImportGroup<Result>(task: () => Promise<Result>): Promise<Result>;
51
+ settle(pendingImports?: Set<Promise<SandboxObject>>): Promise<void>;
34
52
  evaluateSource(source: SourceModule, beforeEvaluation?: (module: Module) => void): Promise<SandboxObject>;
35
53
  private register;
36
54
  private load;
@@ -0,0 +1,18 @@
1
+ import type { SourceSpan } from "./parser.js";
2
+ import type { Position } from "./tokenizer.js";
3
+ /** Immutable source coordinates shared by compiler-owned offset spans. */
4
+ export declare class CompactSourcePositions {
5
+ private readonly sourceLength;
6
+ private readonly lines;
7
+ private readonly positions;
8
+ private readonly makeSpan;
9
+ constructor(source: string);
10
+ position(offset: number): Position;
11
+ span(start: number, end: number): SourceSpan;
12
+ compatiblePosition(position: Position): Position | undefined;
13
+ private assertOffset;
14
+ }
15
+ /** Rebased template coordinates compact only when their existing data agrees. */
16
+ export declare function compactDerivedPosition(base: Position, position: Position): Position | undefined;
17
+ /** Only privately owned points from the same source can become offset spans. */
18
+ export declare function compactSourceSpan(start: Position, end: Position): SourceSpan | undefined;
@@ -23,7 +23,9 @@ export declare function createDynamicSource(kind: DynamicFunctionKind, parameter
23
23
  };
24
24
  export declare function createEvalSource(body: string, context: Omit<EvalParseContext, "privateNames"> & {
25
25
  privateNames?: Iterable<string>;
26
- }, owner?: CompileOwner, filename?: string): {
26
+ }, owner?: CompileOwner, filename?: string, options?: {
27
+ compactAst?: boolean;
28
+ }): {
27
29
  source: {
28
30
  body: string;
29
31
  nodes: Map<number, ParseResult>;
@@ -4,7 +4,7 @@ export type FunctionSource = {
4
4
  readonly start: number;
5
5
  readonly end: number;
6
6
  };
7
- export declare const functionSources: WeakMap<ClassNode | FunctionNode, FunctionSource>;
7
+ export declare const functionSources: WeakMap<FunctionNode | ClassNode, FunctionSource>;
8
8
  export declare const templateSources: WeakMap<TemplateLiteral, string>;
9
9
  export declare const functionStrictness: WeakMap<FunctionNode, boolean>;
10
10
  /** Eval-root declarations are instantiated before statement execution. */
@@ -421,8 +421,11 @@ export type Expression = ArrowFunctionExpression | AssignmentExpression | ArrayE
421
421
  export type ParseResult = Expression | Statement;
422
422
  export declare function parse(source: string, filename?: string, owner?: CompileOwner): ParseResult;
423
423
  export declare function parseModule(source: string, filename?: string, owner?: CompileOwner): Module;
424
- export declare function parseSourceModule(source: string, filename?: string, owner?: CompileOwner): ParsedSourceModule;
425
- export declare function parseExecutableModule(source: string, filename?: string, owner?: CompileOwner): Module;
424
+ export declare function parseSourceModule(source: string, filename?: string, owner?: CompileOwner, options?: {
425
+ sharedPositions?: boolean;
426
+ compactAst?: boolean;
427
+ }): ParsedSourceModule;
428
+ export declare function parseExecutableModule(source: string, filename?: string, owner?: CompileOwner, importSpecifiers?: readonly string[]): Module;
426
429
  export type EvalParseContext = {
427
430
  strict?: boolean;
428
431
  newTarget?: boolean;
@@ -431,7 +434,9 @@ export type EvalParseContext = {
431
434
  arguments?: boolean;
432
435
  privateNames?: ReadonlySet<string>;
433
436
  };
434
- export declare function parseEvalScript(source: string, context?: EvalParseContext, owner?: CompileOwner, filename?: string): {
437
+ export declare function parseEvalScript(source: string, context?: EvalParseContext, owner?: CompileOwner, filename?: string, options?: {
438
+ compactAst?: boolean;
439
+ }): {
435
440
  node: Module;
436
441
  strict: boolean;
437
442
  };
@@ -1,3 +1,4 @@
1
+ import type { CompactSourcePositions } from "./compact-spans.js";
1
2
  import { type CompileScope } from "../interp/regex/compile-guard.js";
2
3
  export type Position = {
3
4
  line: number;
@@ -30,7 +31,10 @@ export type TokenizeOptions = {
30
31
  allowHtmlComments?: boolean;
31
32
  comments?: Comment[];
32
33
  compilation?: CompileScope;
34
+ sharedPositions?: boolean;
33
35
  };
34
36
  export declare const RESERVED_IDENTIFIER_SPELLINGS: Set<string>;
35
37
  export declare function tokenize(source: string, options?: TokenizeOptions): Token[];
38
+ /** Internal classic compilation with bounded materialized token/position caches. */
39
+ export declare function tokenizeCompact(source: string, options: TokenizeOptions, positions: CompactSourcePositions): Token[];
36
40
  export declare function collectComments(source: string): Comment[];
@@ -3,7 +3,7 @@ import { type InterpreterResult } from "./interp/interpreter.js";
3
3
  import { SandboxJobQueue, type ExecutionControl } from "./interp/jobs.js";
4
4
  import { type CallerInjectedBinding } from "./interp/host-bridge.js";
5
5
  import { type CallbackOptions, type CallbackInvocation, type SafeJSExtension } from "./extensions.js";
6
- import { type SourceResolver } from "./modules/source-graph.js";
6
+ import { SourceModuleGraph, type SourceResolver } from "./modules/source-graph.js";
7
7
  import { type ModuleRegistry } from "./modules/registry.js";
8
8
  import type { ConsoleSink } from "./interp/globals/console-json.js";
9
9
  import type { RunClock, RunOptions, RunResult } from "./run.js";
@@ -16,8 +16,13 @@ export type RealmLimits = {
16
16
  nestedEvaluations?: number;
17
17
  };
18
18
  export type RealmOptions = {
19
+ stringCompilation?: "allow" | "deny";
19
20
  classicScripts?: boolean;
21
+ classicScriptErrors?: "fatal" | "report";
22
+ callbackScheduling?: "after-prefix";
20
23
  sourceResolver?: SourceResolver;
24
+ /** Elapsed host-time limit per dynamic import; expiry revokes the whole realm. */
25
+ sourceImportTimeoutMs?: number;
21
26
  clock?: RunClock;
22
27
  bindings?: Record<string, CallerInjectedBinding>;
23
28
  modules?: ModuleRegistry;
@@ -36,19 +41,27 @@ export type RealmResult = (Omit<Extract<InterpreterResult, {
36
41
  ok: true;
37
42
  }>, "snapshot" | "returnValue"> & {
38
43
  returnValue?: unknown;
39
- }) | Omit<Extract<InterpreterResult, {
44
+ }) | (Omit<Extract<InterpreterResult, {
40
45
  ok: false;
41
- }>, "snapshot">;
46
+ }>, "snapshot"> & {
47
+ recoverable?: true;
48
+ });
42
49
  export type SafeJSRealm = ExecutionControl & {
50
+ readonly stringCompilation: "allow" | "deny";
51
+ readonly classicScriptErrors: "fatal" | "report";
52
+ readonly supportsDiscardResult: true;
53
+ readonly sourceImportTimeoutMs?: number;
43
54
  readonly extensions: readonly SafeJSExtension["manifest"][];
44
55
  evaluate(source: string, options?: {
45
56
  filename?: string;
46
57
  sourceType?: "module";
58
+ discardResult?: boolean;
47
59
  }): Promise<RealmResult>;
48
60
  startCallback(callback: unknown, options?: CallbackOptions): CallbackInvocation;
49
61
  invokeCallback(callback: unknown, options?: CallbackOptions): Promise<unknown>;
50
62
  releaseCallback(callback: unknown): void;
51
63
  releaseGuestReference(reference: unknown): void;
64
+ sourceModuleStatus(): ReturnType<SourceModuleGraph["sourceModuleStatus"]>;
52
65
  close(): Promise<void>;
53
66
  };
54
67
  export declare function createRealm(options?: RealmOptions): SafeJSRealm;
@@ -17,6 +17,7 @@ export type SafeJSSnapshot = {
17
17
  };
18
18
  export type RestoreOptions = {
19
19
  source: string;
20
+ importSpecifiers?: readonly string[];
20
21
  };
21
22
  export declare class SnapshotMismatchError extends Error {
22
23
  readonly actualHash: string;
@@ -15,6 +15,7 @@ import { type OtelSink } from "./observability/otel.js";
15
15
  import type { SnapshotBackend } from "./snapshot/backend.js";
16
16
  import { type ReplayData } from "./snapshot/replay-data.js";
17
17
  export type RunOptions = {
18
+ importSpecifiers?: readonly string[];
18
19
  sourceType?: "module";
19
20
  sourceResolver?: SourceResolver;
20
21
  sourceRoot?: string;
@@ -27,6 +28,15 @@ export type RunOptions = {
27
28
  clock?: RunClock;
28
29
  entryPointArgs?: readonly unknown[];
29
30
  filename?: string;
31
+ /** Trusted diagnostic mapping; re-supply when resuming a snapshot. Does not change source or execution. */
32
+ sourceLocation?: (position: {
33
+ line: number;
34
+ column: number;
35
+ }) => {
36
+ filename: string;
37
+ line: number;
38
+ column: number;
39
+ } | undefined;
30
40
  importMeta?: Record<string, unknown>;
31
41
  hostCallResumeProvider?: HostCallResumeProvider;
32
42
  modules?: ModuleRegistry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-js",
3
- "version": "0.1.721",
3
+ "version": "0.1.722",
4
4
  "description": "Budgeted JavaScript interpreter with explicit host capabilities and resumable execution",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@poe-platform/safe-fs": "0.1.721",
61
+ "@poe-platform/safe-fs": "0.1.722",
62
62
  "@petamoriken/float16": "^3.9.3",
63
63
  "@formatjs/intl-localematcher": "0.8.13",
64
64
  "@formatjs/bigdecimal": "0.2.7",
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/restore.ts"],
4
- "sourcesContent": ["import { hashSource } from \"./parse/hash.js\";\nimport type { CompileOwner } from \"./interp/budget.js\";\nimport { replaceErrorStack } from \"./error/shape.js\";\nimport { SnapshotValidationError, validateDumpEnvelope, validateRuntimeSnapshotDescriptors } from \"./snapshot/validation.js\";\nimport { inMemoryRunSnapshots, serializeSafeJSSnapshot } from \"./snapshot/dump-format.js\";\nimport { assertSnapshotInactive } from \"./interp/running-state.js\";\nimport { validateSnapshotMigration, type SnapshotMigration } from \"./snapshot/migration.js\";\nimport { parseModule } from \"./parse/parser.js\";\nimport { ParseError } from \"./parse/format-error.js\";\nimport { createModuleSource, createDynamicSource, createEvalSource, type DynamicSource, type EvalSourceContext } from \"./parse/dynamic-source.js\";\nimport { validateGuestFunctionAst } from \"./snapshot/guest-ast-validation.js\";\nimport { validateTemplateObjects } from \"./snapshot/template-validation.js\";\nimport type { ParseResult } from \"./parse.js\";\n\nexport type SafeJSSnapshot = {\n version?: number;\n sourceHash: string;\n migration?: SnapshotMigration;\n clock?: {\n next: number;\n };\n random?: {\n seed: number;\n state: number;\n initialState?: number;\n resumeState?: number;\n };\n [key: string]: unknown;\n};\n\nexport type RestoreOptions = {\n source: string;\n};\n\nexport class SnapshotMismatchError extends Error {\n readonly actualHash: string;\n readonly expectedHash: string;\n\n constructor(expectedHash: string, actualHash: string) {\n super(\n `source changed since snapshot was taken (hash ${expectedHash} expected, got ${actualHash}); pass --reset to discard`\n );\n this.name = \"SnapshotMismatchError\";\n this.actualHash = actualHash;\n this.expectedHash = expectedHash;\n replaceErrorStack(this);\n }\n}\n\nexport function restore<TSnapshot extends SafeJSSnapshot>(\n snapshot: TSnapshot,\n options: RestoreOptions,\n owner?: CompileOwner\n): TSnapshot {\n assertSnapshotInactive(snapshot);\n try {\n validateDumpEnvelope(snapshot, { resume: true });\n } catch (error) {\n if (!(error instanceof SnapshotValidationError) || error.code !== \"invalidState\" ||\n !inMemoryRunSnapshots.has(snapshot)) throw error;\n // Runtime snapshots can retain guest descriptor state. Use the same portable\n // representation as dump(), then apply all normal validation below.\n validateRuntimeSnapshotDescriptors(snapshot);\n snapshot = JSON.parse(serializeSafeJSSnapshot(snapshot)) as TSnapshot;\n validateDumpEnvelope(snapshot, { resume: true });\n }\n validateSnapshotMigration(snapshot.migration, snapshot.sourceHash, owner);\n\n const currentSourceHash = hashSource(\n options.source,\n owner,\n snapshot.executionSemantics !== \"jobs-v6\" && snapshot.executionSemantics !== \"jobs-v7\"\n );\n\n if (snapshot.sourceHash !== currentSourceHash) {\n throw new SnapshotMismatchError(snapshot.sourceHash, currentSourceHash);\n }\n\n if (snapshot.heap !== undefined && typeof snapshot.heap === \"object\" && snapshot.heap !== null) {\n const entries = Object.entries(snapshot.heap);\n const closures = entries.filter(([, value]) =>\n value !== null && typeof value === \"object\" && ([\"guest-function\", \"guest-class\", \"guest-generator\"].includes(String((value as Record<string, unknown>).kind)) ||\n (value as Record<string, unknown>).templateNodeId !== undefined));\n const dynamicSources = new Map<number, DynamicSource>();\n for (const [id, value] of entries) {\n const record = value as Record<string, unknown>;\n if (record.kind === \"guest-source\" || record.kind === \"guest-script\") {\n try {\n const compiled = record.kind === \"guest-script\"\n ? createEvalSource(record.body as string, record.context as EvalSourceContext, owner)\n : record.functionKind === \"module\" ? createModuleSource(record.body as string, owner)\n : createDynamicSource(record.functionKind as Exclude<DynamicSource[\"kind\"], \"eval\" | \"module\">,\n record.parameters as string, record.body as string, owner);\n dynamicSources.set(Number(id), compiled.source);\n } catch (error) {\n if (!(error instanceof SyntaxError) && !(error instanceof ParseError)) throw error;\n throw new SnapshotValidationError(\"invalidValue\", `$.heap[${JSON.stringify(id)}]`, error.message);\n }\n }\n }\n if (closures.length > 0) {\n const functions = new Map<number, Record<string, unknown>>();\n const pending: unknown[] = [parseModule(options.source, \"<input>\", owner)];\n while (pending.length > 0) {\n const value = pending.pop();\n if (value === null || typeof value !== \"object\") continue;\n const node = value as Record<string, unknown>;\n if (typeof node.nodeId === \"number\") {\n functions.set(node.nodeId, node);\n }\n for (const entry of Object.values(node)) pending.push(entry);\n }\n for (const [id, value] of closures) {\n const record = value as Record<string, unknown>;\n if (record.kind === \"guest-array\") continue;\n const nodes = record.dynamicSource === undefined ? functions\n : dynamicSources.get((record.dynamicSource as {id: number}).id)!.nodes;\n const origin = nodes.get(record.astNodeId as number);\n try { validateGuestFunctionAst(record, origin); }\n catch (error) {\n throw new SnapshotValidationError(\"invalidValue\", `$.heap[${JSON.stringify(id)}].astNodeId`, error instanceof Error ? error.message : String(error));\n }\n }\n try { validateTemplateObjects(snapshot.heap as Record<string, unknown>, functions.values() as Iterable<ParseResult>, dynamicSources); }\n catch (error) { throw new SnapshotValidationError(\"invalidValue\", \"$.heap\", String(error)); }\n }\n }\n\n return snapshot;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAkCO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EAET,YAAY,cAAsB,YAAoB;AACpD;AAAA,MACE,iDAAiD,YAAY,kBAAkB,UAAU;AAAA,IAC3F;AACA,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,sBAAkB,IAAI;AAAA,EACxB;AACF;AAEO,SAAS,QACd,UACA,SACA,OACW;AACX,yBAAuB,QAAQ;AAC/B,MAAI;AACF,yBAAqB,UAAU,EA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