@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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  deepCopyToSandbox
3
- } from "./chunk-DNA7BMBY.js";
3
+ } from "./chunk-BNIEPGDU.js";
4
4
 
5
5
  // packages/safe-js/src/modules/harness.ts
6
6
  function makeHarnessModule(frontmatter, meta) {
@@ -52,4 +52,4 @@ ${prompt}`;
52
52
  export {
53
53
  makeHarnessModule
54
54
  };
55
- //# sourceMappingURL=chunk-IS7YUCOF.js.map
55
+ //# sourceMappingURL=chunk-XHSOM5CG.js.map
@@ -12,13 +12,13 @@ import {
12
12
  parseFsConfig,
13
13
  resolveFsConfig,
14
14
  splitFrontmatter
15
- } from "./chunk-Y4LNCDCP.js";
15
+ } from "./chunk-WF7HYDJ4.js";
16
16
  import {
17
17
  parseMcpConfig
18
- } from "./chunk-HYD4K4HN.js";
18
+ } from "./chunk-D3GC5QPZ.js";
19
19
  import {
20
20
  lint
21
- } from "./chunk-B4M6QVUV.js";
21
+ } from "./chunk-3QQYJ4RQ.js";
22
22
  import {
23
23
  createBrokenPipeState,
24
24
  createSafeOutputStream,
@@ -34,7 +34,7 @@ import {
34
34
  parseModule,
35
35
  parseSourceModule,
36
36
  replaceErrorStack
37
- } from "./chunk-ILYJBA2D.js";
37
+ } from "./chunk-RYVHEOHM.js";
38
38
  import "./chunk-4YIDX44G.js";
39
39
 
40
40
  // packages/safe-js/src/cli-runtime.ts
@@ -55,7 +55,7 @@ async function runCli(argv, options, usage) {
55
55
  async () => {
56
56
  try {
57
57
  if (argv[0] === "migrate") {
58
- const { migrateSnapshotFile } = await import("./migration-file-IXO5MLP4.js");
58
+ const { migrateSnapshotFile } = await import("./migration-file-K7UH5ZG6.js");
59
59
  const result = await migrateSnapshotFile({
60
60
  ...parseMigrationArgs(argv.slice(1)),
61
61
  cwd: options.cwd ?? readCurrentWorkingDirectory()
@@ -272,12 +272,12 @@ async function assertHarnessFile(input) {
272
272
  }
273
273
  async function runScriptFile(filepath, parsed, options) {
274
274
  const [{ run }, { restore }, { dump, dumpCurrent }, { createLintModulesFromRuntimeRegistry }, { makeFsModule }, { makeMcpModule }] = await Promise.all([
275
- import("./run-SHI2PYR6.js"),
276
- import("./restore-SI7HOC6C.js"),
277
- import("./dump-ATWBOZWV.js"),
278
- import("./runtime-modules-OO72HTVF.js"),
279
- import("./fs-D72Y52I5.js"),
280
- import("./mcp-IWKZB2R2.js")
275
+ import("./run-6SETM7SV.js"),
276
+ import("./restore-7LRP4BM3.js"),
277
+ import("./dump-TU6SYRFD.js"),
278
+ import("./runtime-modules-MCQS2SHQ.js"),
279
+ import("./fs-HTZT32MQ.js"),
280
+ import("./mcp-DO2IRFGQ.js")
281
281
  ]);
282
282
  const loaded = loadExecutableSource(filepath, await options.readFile(filepath, "utf8"));
283
283
  const meta = {
@@ -513,8 +513,8 @@ async function createRuntime(frontmatter, meta, options) {
513
513
  };
514
514
  }
515
515
  const [{ makeHarnessModule }, { makeFsModule }] = await Promise.all([
516
- import("./harness-LUYCGWHZ.js"),
517
- import("./fs-D72Y52I5.js")
516
+ import("./harness-RYAMI444.js"),
517
+ import("./fs-HTZT32MQ.js")
518
518
  ]);
519
519
  const state = {
520
520
  metricCalls: /* @__PURE__ */ new Map(),
@@ -704,4 +704,4 @@ export {
704
704
  exitCodeForError,
705
705
  runCli
706
706
  };
707
- //# sourceMappingURL=cli-runtime-YK2WE33M.js.map
707
+ //# sourceMappingURL=cli-runtime-6QPGM3TX.js.map
@@ -4,9 +4,9 @@ import {
4
4
  dump,
5
5
  dumpCurrent,
6
6
  serializeRunSnapshot
7
- } from "./chunk-BEXRQET4.js";
8
- import "./chunk-DNA7BMBY.js";
9
- import "./chunk-ILYJBA2D.js";
7
+ } from "./chunk-S2GFVXSI.js";
8
+ import "./chunk-BNIEPGDU.js";
9
+ import "./chunk-RYVHEOHM.js";
10
10
  import "./chunk-4YIDX44G.js";
11
11
  export {
12
12
  attachDumpController,
@@ -15,4 +15,4 @@ export {
15
15
  dumpCurrent,
16
16
  serializeRunSnapshot
17
17
  };
18
- //# sourceMappingURL=dump-ATWBOZWV.js.map
18
+ //# sourceMappingURL=dump-TU6SYRFD.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  FS_OPTION_SURFACE,
3
3
  makeFsModule
4
- } from "./chunk-BHYBD6SY.js";
4
+ } from "./chunk-55RIIUGG.js";
5
5
  import "./chunk-SJZWSPWD.js";
6
- import "./chunk-DNA7BMBY.js";
7
- import "./chunk-ILYJBA2D.js";
6
+ import "./chunk-BNIEPGDU.js";
7
+ import "./chunk-RYVHEOHM.js";
8
8
  import "./chunk-4YIDX44G.js";
9
9
  export {
10
10
  FS_OPTION_SURFACE,
11
11
  makeFsModule
12
12
  };
13
- //# sourceMappingURL=fs-D72Y52I5.js.map
13
+ //# sourceMappingURL=fs-HTZT32MQ.js.map
@@ -0,0 +1,10 @@
1
+ import {
2
+ makeHarnessModule
3
+ } from "./chunk-XHSOM5CG.js";
4
+ import "./chunk-BNIEPGDU.js";
5
+ import "./chunk-RYVHEOHM.js";
6
+ import "./chunk-4YIDX44G.js";
7
+ export {
8
+ makeHarnessModule
9
+ };
10
+ //# sourceMappingURL=harness-RYAMI444.js.map
@@ -0,0 +1,11 @@
1
+ import {
2
+ makeMcpModule
3
+ } from "./chunk-GCOLKRMY.js";
4
+ import "./chunk-D3GC5QPZ.js";
5
+ import "./chunk-BNIEPGDU.js";
6
+ import "./chunk-RYVHEOHM.js";
7
+ import "./chunk-4YIDX44G.js";
8
+ export {
9
+ makeMcpModule
10
+ };
11
+ //# sourceMappingURL=mcp-DO2IRFGQ.js.map
@@ -0,0 +1,12 @@
1
+ import {
2
+ migrateSnapshotFile
3
+ } from "./chunk-QL2ALAE6.js";
4
+ import "./chunk-SJZWSPWD.js";
5
+ import "./chunk-K3ZRBAG5.js";
6
+ import "./chunk-BNIEPGDU.js";
7
+ import "./chunk-RYVHEOHM.js";
8
+ import "./chunk-4YIDX44G.js";
9
+ export {
10
+ migrateSnapshotFile
11
+ };
12
+ //# sourceMappingURL=migration-file-K7UH5ZG6.js.map
@@ -0,0 +1,13 @@
1
+ import {
2
+ SnapshotMismatchError,
3
+ restore
4
+ } from "./chunk-7SBQ7WTV.js";
5
+ import "./chunk-K3ZRBAG5.js";
6
+ import "./chunk-BNIEPGDU.js";
7
+ import "./chunk-RYVHEOHM.js";
8
+ import "./chunk-4YIDX44G.js";
9
+ export {
10
+ SnapshotMismatchError,
11
+ restore
12
+ };
13
+ //# sourceMappingURL=restore-7LRP4BM3.js.map
@@ -0,0 +1,17 @@
1
+ import {
2
+ UnhandledRejectionError,
3
+ run
4
+ } from "./chunk-EH5A2EQI.js";
5
+ import "./chunk-U7ZNMTSQ.js";
6
+ import "./chunk-7SBQ7WTV.js";
7
+ import "./chunk-S2GFVXSI.js";
8
+ import "./chunk-SJZWSPWD.js";
9
+ import "./chunk-K3ZRBAG5.js";
10
+ import "./chunk-BNIEPGDU.js";
11
+ import "./chunk-RYVHEOHM.js";
12
+ import "./chunk-4YIDX44G.js";
13
+ export {
14
+ UnhandledRejectionError,
15
+ run
16
+ };
17
+ //# sourceMappingURL=run-6SETM7SV.js.map
@@ -0,0 +1,10 @@
1
+ import {
2
+ createLintModulesFromRuntimeRegistry
3
+ } from "./chunk-FA5CQO6V.js";
4
+ import "./chunk-BNIEPGDU.js";
5
+ import "./chunk-RYVHEOHM.js";
6
+ import "./chunk-4YIDX44G.js";
7
+ export {
8
+ createLintModulesFromRuntimeRegistry
9
+ };
10
+ //# sourceMappingURL=runtime-modules-MCQS2SHQ.js.map
@@ -13,7 +13,7 @@ import path from "node:path";
13
13
  import { fileURLToPath } from "node:url";
14
14
  async function runCli(argv, options = {}) {
15
15
  if (!argv.includes("--help") && !argv.includes("-h")) {
16
- const runtime = await import("./chunks/cli-runtime-YK2WE33M.js");
16
+ const runtime = await import("./chunks/cli-runtime-6QPGM3TX.js");
17
17
  return runtime.runCli(argv, options, createUsage());
18
18
  }
19
19
  const brokenPipe = createBrokenPipeState();
@@ -32,7 +32,7 @@ async function runCli(argv, options = {}) {
32
32
  stderr.write(`${error instanceof Error ? error.message : String(error)}
33
33
  `);
34
34
  if (brokenPipe.closed) return 0;
35
- const { exitCodeForError } = await import("./chunks/cli-runtime-YK2WE33M.js");
35
+ const { exitCodeForError } = await import("./chunks/cli-runtime-6QPGM3TX.js");
36
36
  return exitCodeForError(error);
37
37
  }
38
38
  }
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  lint
3
- } from "./chunks/chunk-B4M6QVUV.js";
3
+ } from "./chunks/chunk-3QQYJ4RQ.js";
4
4
  import {
5
5
  createRealm,
6
6
  createReplayableRandom,
7
7
  run
8
- } from "./chunks/chunk-Q7B6JIMI.js";
8
+ } from "./chunks/chunk-EH5A2EQI.js";
9
9
  import "./chunks/chunk-U7ZNMTSQ.js";
10
- import "./chunks/chunk-A4L72WXV.js";
11
- import "./chunks/chunk-BEXRQET4.js";
10
+ import "./chunks/chunk-7SBQ7WTV.js";
11
+ import "./chunks/chunk-S2GFVXSI.js";
12
12
  import "./chunks/chunk-SJZWSPWD.js";
13
- import "./chunks/chunk-GMPZBMPA.js";
13
+ import "./chunks/chunk-K3ZRBAG5.js";
14
14
  import {
15
15
  admitNativePromiseProperties,
16
16
  defineExtension
17
- } from "./chunks/chunk-DNA7BMBY.js";
17
+ } from "./chunks/chunk-BNIEPGDU.js";
18
18
  import {
19
19
  Budget
20
- } from "./chunks/chunk-ILYJBA2D.js";
20
+ } from "./chunks/chunk-RYVHEOHM.js";
21
21
  import "./chunks/chunk-4YIDX44G.js";
22
22
  export {
23
23
  Budget,
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  createLintModulesFromRuntimeRegistry
3
- } from "./chunks/chunk-4CX3HYRY.js";
3
+ } from "./chunks/chunk-FA5CQO6V.js";
4
4
  import {
5
5
  makeFsModule
6
- } from "./chunks/chunk-BHYBD6SY.js";
6
+ } from "./chunks/chunk-55RIIUGG.js";
7
7
  import {
8
8
  makeHarnessModule
9
- } from "./chunks/chunk-IS7YUCOF.js";
9
+ } from "./chunks/chunk-XHSOM5CG.js";
10
10
  import {
11
11
  makeMcpModule
12
- } from "./chunks/chunk-LPBTSTDG.js";
12
+ } from "./chunks/chunk-GCOLKRMY.js";
13
13
  import {
14
14
  AgentSpawnError,
15
15
  EnvAccessError,
@@ -30,13 +30,13 @@ import {
30
30
  runWithSpawnUsageAccumulator,
31
31
  splitFrontmatter,
32
32
  supportsSpawnMode
33
- } from "./chunks/chunk-Y4LNCDCP.js";
33
+ } from "./chunks/chunk-WF7HYDJ4.js";
34
34
  import {
35
35
  parseMcpConfig
36
- } from "./chunks/chunk-HYD4K4HN.js";
36
+ } from "./chunks/chunk-D3GC5QPZ.js";
37
37
  import {
38
38
  lint
39
- } from "./chunks/chunk-B4M6QVUV.js";
39
+ } from "./chunks/chunk-3QQYJ4RQ.js";
40
40
  import "./chunks/chunk-OZLTLIHX.js";
41
41
  import {
42
42
  createRootedSourceResolver
@@ -46,23 +46,23 @@ import {
46
46
  createRealm,
47
47
  createReplayableRandom,
48
48
  run
49
- } from "./chunks/chunk-Q7B6JIMI.js";
49
+ } from "./chunks/chunk-EH5A2EQI.js";
50
50
  import "./chunks/chunk-U7ZNMTSQ.js";
51
51
  import {
52
52
  restore
53
- } from "./chunks/chunk-A4L72WXV.js";
53
+ } from "./chunks/chunk-7SBQ7WTV.js";
54
54
  import {
55
55
  dump
56
- } from "./chunks/chunk-BEXRQET4.js";
56
+ } from "./chunks/chunk-S2GFVXSI.js";
57
57
  import {
58
58
  inspectSnapshotMigration,
59
59
  migrateSnapshot,
60
60
  migrateSnapshotFile
61
- } from "./chunks/chunk-JNLY7IMV.js";
61
+ } from "./chunks/chunk-QL2ALAE6.js";
62
62
  import {
63
63
  hasOwnErrorCode
64
64
  } from "./chunks/chunk-SJZWSPWD.js";
65
- import "./chunks/chunk-GMPZBMPA.js";
65
+ import "./chunks/chunk-K3ZRBAG5.js";
66
66
  import {
67
67
  HostCallResumabilityError,
68
68
  HostOperationResumePolicyError,
@@ -74,7 +74,7 @@ import {
74
74
  deepCopyToSandbox,
75
75
  defineExtension,
76
76
  registerPendingHostCallPolicy
77
- } from "./chunks/chunk-DNA7BMBY.js";
77
+ } from "./chunks/chunk-BNIEPGDU.js";
78
78
  import {
79
79
  Budget,
80
80
  SandboxError,
@@ -82,7 +82,7 @@ import {
82
82
  parse,
83
83
  parseModule,
84
84
  parseSourceModule
85
- } from "./chunks/chunk-ILYJBA2D.js";
85
+ } from "./chunks/chunk-RYVHEOHM.js";
86
86
  import "./chunks/chunk-4YIDX44G.js";
87
87
 
88
88
  // packages/safe-js/src/parse.ts
@@ -5,7 +5,7 @@ import { type Budget } from "./budget.js";
5
5
  import { type EvaluationResult } from "./exceptions.js";
6
6
  import type { InterpreterError, InterpreterSnapshot, LoopIterationSnapshot } from "./interpreter.js";
7
7
  import { CompileScope } from "./regex/compile-guard.js";
8
- import type { Scope } from "./scope.js";
8
+ import { type Scope } from "./scope.js";
9
9
  import { type SandboxCallContext, type SandboxClosure, type SandboxGenerator, type SandboxObject, type SandboxPromise, type SandboxValue } from "./values.js";
10
10
  export type InterpreterYieldPoint = {
11
11
  kind: "await" | "generator-yield" | "loop-iteration";
@@ -19,6 +19,9 @@ type ResumeBreakpoint = Omit<InterpreterYieldPoint, "snapshot">;
19
19
  export type AsyncInterpreterError = InterpreterError;
20
20
  export type AsyncEvaluationResult = EvaluationResult<AsyncInterpreterError>;
21
21
  export type AsyncEvaluationContext = {
22
+ sourceReference?: Readonly<{
23
+ referrer: string;
24
+ }>;
22
25
  scriptScope?: Scope;
23
26
  evalCompletion?: boolean;
24
27
  callee?: SandboxClosure;
@@ -4,15 +4,16 @@ export type BudgetOptions = {
4
4
  deadline?: number | Date;
5
5
  maxCallDepth?: number;
6
6
  stringLength?: number;
7
+ regexSourceLength?: number;
8
+ regexCompileAllocations?: number;
7
9
  arrayLength?: number;
8
10
  dataSize?: number;
9
11
  };
10
- export declare const REGEX_STEP_LIMIT = 2000;
11
12
  export declare const REGEX_COMPILE_LIMITS: Readonly<{
12
- sourceLength: 4096;
13
- flagsLength: 8;
14
- depth: 64;
15
- allocations: 16384;
13
+ sourceLength: number;
14
+ flagsLength: number;
15
+ depth: number;
16
+ allocations: number;
16
17
  }>;
17
18
  export declare class SandboxError extends Error {
18
19
  readonly code: "aborted" | "budgetExceeded" | "reentry";
@@ -31,6 +32,8 @@ type BudgetLimits = {
31
32
  maxSteps?: number;
32
33
  maxCallDepth?: number;
33
34
  stringLength?: number;
35
+ regexSourceLength?: number;
36
+ regexCompileAllocations?: number;
34
37
  arrayLength?: number;
35
38
  dataSize?: number;
36
39
  };
@@ -59,15 +62,19 @@ export declare class Budget {
59
62
  set peakDataSize(value: number);
60
63
  get currentCallDepth(): number;
61
64
  set currentCallDepth(value: number);
65
+ acquireDeadline(deadline: number, onExceeded?: (reason: SandboxError) => void): () => void;
62
66
  forkRealm(): Budget;
63
67
  acquireRealmOwner(): ReturnType<Budget["acquireCompileOwner"]>;
64
68
  visitNode(units?: number): void;
65
69
  allocateString(value: string): string;
70
+ allocateStringLength(length: number): void;
66
71
  allocateArrayLength(length: number): void;
67
72
  allocateCollectionEntries(count: number): void;
68
73
  reconcileDataUsage(usage: number): void;
69
74
  setRetainedDataUsage(owner: object, usage: number): void;
70
75
  setRetainedValues(owner: object, values: (() => Iterable<unknown> | undefined) | undefined): void;
76
+ get reconciliationDeferred(): boolean;
77
+ deferReconciliation(): () => void;
71
78
  retainedValues(): Iterable<unknown>;
72
79
  acquireCompileOwner(reset?: boolean, owner?: CompileOwner): {
73
80
  owner: CompileOwner;
@@ -90,5 +97,4 @@ export declare class Budget {
90
97
  private checkSampledDeadline;
91
98
  private enterDepth;
92
99
  }
93
- export declare function allocateRegexSteps(steps: number): void;
94
100
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { Budget } from "./budget.js";
2
2
  import type { SandboxMap, SandboxSet, SandboxValue, SandboxObject } from "./values.js";
3
- export declare const collectionIteratorPrototypes: WeakMap<Budget, Partial<Record<"set" | "map", SandboxObject>>>;
3
+ export declare const collectionIteratorPrototypes: WeakMap<Budget, Partial<Record<"map" | "set", SandboxObject>>>;
4
4
  declare const collectionIteratorBrand: unique symbol;
5
5
  export type SandboxCollectionIterator = {
6
6
  readonly [collectionIteratorBrand]: true;
@@ -37,6 +37,7 @@ export type CallerInjectedBinding = SandboxValue | CallerInjectedFunction | read
37
37
  };
38
38
  export declare function declareHostOperation<TFunction extends CallerInjectedFunction>(operation: TFunction, policy: PendingHostCallPolicyMode, options?: {
39
39
  onReplay?: (args: readonly unknown[], outcome: HostCallOutcome) => void;
40
+ awaitResult?: boolean;
40
41
  }): TFunction;
41
42
  export declare function readHostOperationPolicy(operation: CallerInjectedFunction): PendingHostCallPolicyMode | undefined;
42
43
  export declare function wrapCallerInjectedBindings(bindings: Record<string, CallerInjectedBinding>, options: HostBridgeOptions): Record<string, SandboxValue>;
@@ -19,6 +19,11 @@ export type HostObjectIndexedDefinition = {
19
19
  maxLength: number;
20
20
  };
21
21
  export type HostObjectDefinition = {
22
+ expandos?: {
23
+ maxKeys: number;
24
+ maxKeyCodeUnits: number;
25
+ assertActive?: () => void;
26
+ };
22
27
  indexed?: HostObjectIndexedDefinition;
23
28
  named?: HostObjectNamedDefinition;
24
29
  properties?: Record<string, {
@@ -40,6 +45,7 @@ export type HostObjectController = {
40
45
  owner: object;
41
46
  assertActive(): void;
42
47
  chargeWork(units?: number): void;
48
+ chargeGuestData(units: number): void;
43
49
  checkLength(length: number): void;
44
50
  checkString(value: string): void;
45
51
  checkTemporaryDataSize(size: number): void;
@@ -64,11 +70,14 @@ export declare function registerGuestCallback(callback: HostOperation, state: Gu
64
70
  export declare function readGuestCallback(callback: unknown, owner: object): SandboxClosure;
65
71
  export declare function revokeGuestCallback(callback: object, owner: object): void;
66
72
  export declare function revokeHostObject(value: HostObject, owner: object): void;
67
- export declare function getHostObjectMember(value: SandboxObject, key: string): SandboxValue;
68
- export declare function setHostObjectMember(value: SandboxObject, key: string, entry: SandboxValue): void;
69
- export declare function deleteHostObjectMember(value: SandboxObject, key: string): boolean;
73
+ export declare function getHostObjectMember(value: SandboxObject, key: string | symbol): SandboxValue;
74
+ export declare function setHostObjectMember(value: SandboxObject, key: string | symbol, entry: SandboxValue): void;
75
+ export declare function deleteHostObjectMember(value: SandboxObject, key: string | symbol): boolean;
70
76
  export declare function getHostObjectKeys(value: SandboxObject): string[];
71
- export declare function hasHostObjectMember(value: SandboxObject, key: string, enumerableOnly?: boolean): boolean;
77
+ export declare function hasHostObjectMember(value: SandboxObject, key: string | symbol, enumerableOnly?: boolean): boolean;
72
78
  export declare function measureHostObjectData(value: SandboxObject): number;
73
79
  export declare function getHostObjectIterator(value: SandboxObject): SandboxIterator | undefined;
80
+ export declare function getHostObjectSymbolKeys(value: SandboxObject): symbol[];
81
+ export declare function hostObjectGuestRoot(value: HostObject | SandboxObject): SandboxObject | undefined;
82
+ export declare function hostObjectGuestRoots(value: HostObject | SandboxObject): SandboxValue[];
74
83
  export {};
@@ -22,7 +22,7 @@ export type LoopIterationSnapshot = number | {
22
22
  index: number;
23
23
  values: InterpreterValue[];
24
24
  };
25
- export type InterpreterErrorCode = "LABEL_NOT_FOUND" | "UNBOUND_IDENTIFIER" | "UNSUPPORTED_NODE";
25
+ export type InterpreterErrorCode = "LABEL_NOT_FOUND" | "UNBOUND_IDENTIFIER" | "UNSUPPORTED_NODE" | "UNCAUGHT_EXCEPTION";
26
26
  export type InterpreterError = {
27
27
  code: InterpreterErrorCode;
28
28
  message: string;
@@ -44,7 +44,10 @@ export type InterpreterResult = {
44
44
  stats: InterpreterStats;
45
45
  };
46
46
  export type InterpretOptions = {
47
+ sourceReference?: AsyncEvaluationContext["sourceReference"];
47
48
  modulePhase?: "link" | "evaluate";
49
+ /** Skip unused public bindings; retained data is still reconciled. */
50
+ captureSnapshot?: boolean;
48
51
  script?: {
49
52
  strict: boolean;
50
53
  };
@@ -61,6 +64,7 @@ export type InterpretOptions = {
61
64
  scope?: Scope;
62
65
  signal?: AbortSignal;
63
66
  surfaceUnhandledThrows?: boolean;
67
+ reportUnhandledThrows?: boolean;
64
68
  useScopeDirectly?: boolean;
65
69
  generatorYield?: (value?: SandboxValue, yieldNodeId?: number, yieldedResult?: SandboxValue) => Promise<GeneratorCompletion>;
66
70
  asyncGenerator?: boolean;
@@ -1,4 +1,4 @@
1
- import type { Budget } from "./budget.js";
1
+ import { type Budget } from "./budget.js";
2
2
  import { createNumberFormatter } from "./numberformat-backend.js";
3
3
  import type { SandboxCallContext, SandboxClosure, SandboxObject, SandboxValue } from "./values.js";
4
4
  export type NumberFormatOptions = Record<string, string | number | boolean>;
@@ -10,4 +10,4 @@ export declare function numberFormatState(value: unknown): {
10
10
  format?: SandboxClosure;
11
11
  };
12
12
  export declare function numberFormatValue(value: SandboxValue, budget: Budget, context?: SandboxCallContext): Promise<number | bigint | string>;
13
- export declare function formatNumberValue(receiver: unknown, method: "format" | "formatToParts" | "formatRange" | "formatRangeToParts", values: Array<number | bigint | string>): SandboxValue;
13
+ export declare function formatNumberValue(receiver: unknown, method: "format" | "formatToParts" | "formatRange" | "formatRangeToParts", values: Array<number | bigint | string>, budget: Budget): SandboxValue;
@@ -7,17 +7,23 @@ export type ExecutionControl = {
7
7
  type ExecutionJob = {
8
8
  queue: SandboxJobQueue;
9
9
  ownsExecution: boolean;
10
+ attribution?: ReadonlyMap<object, object | undefined>;
10
11
  prefixParent?: ExecutionJob;
11
12
  keptTargets?: Map<Budget, Set<object | symbol>>;
12
13
  };
14
+ export declare function getJobAttribution(key: object): object | undefined;
15
+ export declare function withJobAttribution<Result>(key: object, value: object | undefined, task: () => Result): Result;
16
+ export declare function captureJobAttribution(): <Result>(task: () => Result) => Result;
13
17
  export declare class SandboxJobQueue {
14
18
  private running;
15
19
  private pending;
16
20
  private ready;
17
21
  private readonly idle;
22
+ private readonly unsettled;
18
23
  private generation;
19
24
  private controlled;
20
25
  private nodesUntilHostTurn;
26
+ private lastHostTurn;
21
27
  private pauseRequest?;
22
28
  private finished;
23
29
  private interruption?;
@@ -33,6 +39,8 @@ export declare class SandboxJobQueue {
33
39
  acquire(job: ExecutionJob): Promise<void>;
34
40
  release(job: ExecutionJob): void;
35
41
  run<T>(task: () => T | Promise<T>): Promise<T>;
42
+ track<T>(pending: Promise<T>): Promise<T>;
43
+ settle(): Promise<void>;
36
44
  drain(): Promise<void>;
37
45
  private advance;
38
46
  }
@@ -2,7 +2,7 @@ import type { VariableDeclarationKind } from "../parse.js";
2
2
  import type { PrivateName } from "./private-state.js";
3
3
  import type { InterpreterSnapshot, InterpreterValue } from "./interpreter.js";
4
4
  import type { ResourceScopeState } from "./resource-management.js";
5
- import type { SandboxObject } from "./values.js";
5
+ import type { SandboxClosure, SandboxObject, SandboxValue } from "./values.js";
6
6
  import type { ModuleEnvironment } from "../modules/registry.js";
7
7
  type ScopeLookupResult = {
8
8
  found: true;
@@ -99,11 +99,14 @@ export declare class Scope {
99
99
  lookupModuleId(): string;
100
100
  lookupModuleEnvironment(): ModuleEnvironment | undefined;
101
101
  retainedValues(): InterpreterValue[];
102
- retainedDataRoots(): InterpreterValue[];
102
+ retainedDataRoots(append?: (values: InterpreterValue[]) => void): InterpreterValue[];
103
+ static captureDataRoots(scope: Scope, append: (values: InterpreterValue[]) => void): InterpreterValue[];
104
+ static visitDataRoots(scope: Scope, append: (value: InterpreterValue) => void): void;
103
105
  declare(name: string, kind: VariableDeclarationKind, value: InterpreterValue, options?: {
104
106
  silentImmutable: true;
105
107
  }): void;
106
108
  declareImport(name: string, target: Scope, targetName: string): void;
109
+ declareDeferredFunction(name: string, kind: VariableDeclarationKind, create: () => SandboxClosure, collect: (append: (value: SandboxValue) => void) => void): void;
107
110
  declareAlias(name: string, target: string): void;
108
111
  declareVar(name: string, options?: {
109
112
  functionValue?: InterpreterValue;
@@ -124,8 +127,12 @@ export declare class Scope {
124
127
  hydrateFrame(frame: ScopeFrame): void;
125
128
  copyInitializedBindingsFrom(source: Scope, names: readonly string[]): void;
126
129
  private writeBindingValue;
130
+ private readBindingValue;
127
131
  private resolveScope;
128
132
  private trackReplacement;
129
133
  private requireInitializedBinding;
130
134
  }
135
+ export declare const captureScopeDataRoots: typeof Scope.captureDataRoots;
136
+ export declare const visitScopeDataRoots: typeof Scope.visitDataRoots;
137
+ export declare function appendScopeDataRoots(values: InterpreterValue[], captured: Iterable<InterpreterValue>, index?: number): number;
131
138
  export {};
@@ -7,7 +7,7 @@ export declare const typedArrayViewLayouts: WeakMap<NumericTypedArray, {
7
7
  }>;
8
8
  export declare function createOwnedTypedArray(Native: NumericTypedArrayConstructor, args: unknown[]): NumericTypedArray;
9
9
  export declare function nativeTypedArrayView<T extends object>(value: T): T;
10
- export declare function restoreTypedArrayView(buffer: ArrayBufferLike, byteOffset: number, length?: number, budget?: Budget, Native?: NumericTypedArrayConstructor): NumericTypedArray;
10
+ export declare function restoreTypedArrayView(buffer: ArrayBufferLike, byteOffset: number, length?: number, budget?: Budget, Native?: NumericTypedArrayConstructor, owned?: boolean): NumericTypedArray;
11
11
  export declare function isNumericTypedArray(value: unknown): value is NumericTypedArray;
12
12
  export declare function typedArrayStorage(value: NumericTypedArray, requireInBounds?: boolean): {
13
13
  buffer: ArrayBufferLike;
@@ -26,5 +26,5 @@ export declare function checkTypedArrayAllocation(length: number, budget: Budget
26
26
  export declare function copyTypedArrayStorage<TValue>(value: NumericTypedArray, state: {
27
27
  seen: WeakMap<object, TValue>;
28
28
  float32Buffers?: WeakMap<ArrayBufferLike, ArrayBufferLike>;
29
- }): NumericTypedArray;
29
+ }, owned?: boolean): NumericTypedArray;
30
30
  export declare function requireUint8Array(value: unknown): Uint8Array<ArrayBuffer>;
@@ -136,6 +136,7 @@ export declare function createSandboxClosure(input: {
136
136
  properties?: SandboxObject | ((closure: SandboxClosure) => SandboxObject);
137
137
  retainedValues?: () => Iterable<SandboxValue>;
138
138
  }): SandboxClosure;
139
+ export declare function registerDeferredClosureChargeIdentity(closure: SandboxClosure, identity: object): void;
139
140
  export declare function ownEnumerableSandboxEntries(value: SandboxValue, excludedKeys?: ReadonlySet<string>): Array<[string, SandboxValue]>;
140
141
  export declare function ownSandboxSymbolKeys(value: SandboxValue): symbol[];
141
142
  export declare function ownEnumerableSandboxKeys(value: SandboxValue): string[];
@@ -20,6 +20,7 @@ export type ModuleEnvironmentOptions = {
20
20
  prepareNamespace?: (namespace: Record<string, SandboxValue>, moduleName: string) => Record<string, SandboxValue>;
21
21
  };
22
22
  export declare function createModuleEnvironment(modules: ModuleRegistry | undefined, options: ModuleEnvironmentOptions, restored?: ModuleEnvironment): ModuleEnvironment;
23
+ export declare function createImmutableEmptyModuleEnvironment(options: ModuleEnvironmentOptions): ModuleEnvironment;
23
24
  export declare function resolveModuleNamespace(environment: ModuleEnvironment, moduleName: string, prepare?: boolean): Record<string, SandboxValue>;
24
25
  export declare function resolveModuleFunction(environment: ModuleEnvironment, origin: ModuleFunctionOrigin): SandboxClosure;
25
26
  export declare function createUnknownModuleMessage(moduleName: string, moduleNames: readonly string[]): string;
@@ -28,5 +29,7 @@ export declare function resolveModuleImports(module: Module, modules: ModuleRegi
28
29
  environment?: ModuleEnvironment;
29
30
  allowMissing?: boolean;
30
31
  }): Record<string, SandboxValue>;
31
- export declare function attachSourceLoader(environment: ModuleEnvironment, loader: (specifier: string, referrer: string) => Promise<Record<string, SandboxValue>>): void;
32
+ export declare function attachSourceLoader(environment: ModuleEnvironment, loader: (specifier: string, referrer: string) => Promise<Record<string, SandboxValue>>, options?: {
33
+ preserveImmutableNamespaces?: true;
34
+ }): void;
32
35
  export declare function importModuleNamespace(environment: ModuleEnvironment, specifier: string, referrer: string): Record<string, SandboxValue> | Promise<Record<string, SandboxValue>>;