@poe-platform/safe-js 0.1.719 → 0.1.721

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 (66) hide show
  1. package/README.md +15 -2
  2. package/dist/safe-js/chunks/{chunk-APKV5Y6T.js → chunk-4CX3HYRY.js} +2 -2
  3. package/dist/safe-js/chunks/{chunk-NJM2Q74Z.js → chunk-A4L72WXV.js} +4 -4
  4. package/dist/safe-js/chunks/{chunk-B2SQLK4O.js → chunk-B4M6QVUV.js} +2 -2
  5. package/dist/safe-js/chunks/{chunk-A7CADQAD.js → chunk-BEXRQET4.js} +3 -3
  6. package/dist/safe-js/chunks/{chunk-OP3H3ZDN.js → chunk-BHYBD6SY.js} +2 -2
  7. package/dist/safe-js/chunks/{chunk-KP6I45ET.js → chunk-DNA7BMBY.js} +192 -38
  8. package/dist/safe-js/chunks/{chunk-KP6I45ET.js.map → chunk-DNA7BMBY.js.map} +3 -3
  9. package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js → chunk-GMPZBMPA.js} +3 -3
  10. package/dist/safe-js/chunks/{chunk-IDQ67DY2.js → chunk-ILYJBA2D.js} +24 -3
  11. package/dist/safe-js/chunks/chunk-ILYJBA2D.js.map +7 -0
  12. package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js → chunk-IS7YUCOF.js} +2 -2
  13. package/dist/safe-js/chunks/{chunk-BGJXQN4A.js → chunk-JNLY7IMV.js} +4 -4
  14. package/dist/safe-js/chunks/{chunk-RML35GIF.js → chunk-LPBTSTDG.js} +3 -3
  15. package/dist/safe-js/chunks/{chunk-KK5NCR5R.js → chunk-Q7B6JIMI.js} +110 -46
  16. package/dist/safe-js/chunks/chunk-Q7B6JIMI.js.map +7 -0
  17. package/dist/safe-js/chunks/{chunk-XMA6FOJU.js → chunk-Y4LNCDCP.js} +2 -2
  18. package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js → cli-runtime-YK2WE33M.js} +13 -13
  19. package/dist/safe-js/chunks/{dump-TRGFSCJ7.js → dump-ATWBOZWV.js} +4 -4
  20. package/dist/safe-js/chunks/{fs-4T5MZW5J.js → fs-D72Y52I5.js} +4 -4
  21. package/dist/safe-js/chunks/harness-LUYCGWHZ.js +10 -0
  22. package/dist/safe-js/chunks/mcp-IWKZB2R2.js +11 -0
  23. package/dist/safe-js/chunks/migration-file-IXO5MLP4.js +12 -0
  24. package/dist/safe-js/chunks/restore-SI7HOC6C.js +13 -0
  25. package/dist/safe-js/chunks/run-SHI2PYR6.js +17 -0
  26. package/dist/safe-js/chunks/runtime-modules-OO72HTVF.js +10 -0
  27. package/dist/safe-js/cli.js +2 -2
  28. package/dist/safe-js/core.js +7 -7
  29. package/dist/safe-js/extensions.d.ts +3 -1
  30. package/dist/safe-js/index.js +13 -13
  31. package/dist/safe-js/interp/budget.d.ts +3 -0
  32. package/dist/safe-js/interp/scope.d.ts +4 -1
  33. package/dist/safe-js/interp/typed-array.d.ts +3 -0
  34. package/dist/safe-js/parse/dynamic-source.d.ts +1 -1
  35. package/dist/safe-js/parse/parser.d.ts +1 -1
  36. package/dist/safe-js/realm.d.ts +1 -0
  37. package/dist/safe-js/snapshot/guest-heap.d.ts +1 -0
  38. package/dist/toolcraft-design/prompts/primitives/note.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/dist/safe-js/chunks/chunk-IDQ67DY2.js.map +0 -7
  41. package/dist/safe-js/chunks/chunk-KK5NCR5R.js.map +0 -7
  42. package/dist/safe-js/chunks/harness-DLEQ2Z3O.js +0 -10
  43. package/dist/safe-js/chunks/mcp-TNVEFJ6K.js +0 -11
  44. package/dist/safe-js/chunks/migration-file-IDIUFLKY.js +0 -12
  45. package/dist/safe-js/chunks/restore-P27AUZR2.js +0 -13
  46. package/dist/safe-js/chunks/run-KGAEHYMV.js +0 -17
  47. package/dist/safe-js/chunks/runtime-modules-KICK45EE.js +0 -10
  48. /package/dist/safe-js/chunks/{chunk-APKV5Y6T.js.map → chunk-4CX3HYRY.js.map} +0 -0
  49. /package/dist/safe-js/chunks/{chunk-NJM2Q74Z.js.map → chunk-A4L72WXV.js.map} +0 -0
  50. /package/dist/safe-js/chunks/{chunk-B2SQLK4O.js.map → chunk-B4M6QVUV.js.map} +0 -0
  51. /package/dist/safe-js/chunks/{chunk-A7CADQAD.js.map → chunk-BEXRQET4.js.map} +0 -0
  52. /package/dist/safe-js/chunks/{chunk-OP3H3ZDN.js.map → chunk-BHYBD6SY.js.map} +0 -0
  53. /package/dist/safe-js/chunks/{chunk-U6KZ2DQ2.js.map → chunk-GMPZBMPA.js.map} +0 -0
  54. /package/dist/safe-js/chunks/{chunk-NEJ44T4Y.js.map → chunk-IS7YUCOF.js.map} +0 -0
  55. /package/dist/safe-js/chunks/{chunk-BGJXQN4A.js.map → chunk-JNLY7IMV.js.map} +0 -0
  56. /package/dist/safe-js/chunks/{chunk-RML35GIF.js.map → chunk-LPBTSTDG.js.map} +0 -0
  57. /package/dist/safe-js/chunks/{chunk-XMA6FOJU.js.map → chunk-Y4LNCDCP.js.map} +0 -0
  58. /package/dist/safe-js/chunks/{cli-runtime-PO6DQDHP.js.map → cli-runtime-YK2WE33M.js.map} +0 -0
  59. /package/dist/safe-js/chunks/{dump-TRGFSCJ7.js.map → dump-ATWBOZWV.js.map} +0 -0
  60. /package/dist/safe-js/chunks/{fs-4T5MZW5J.js.map → fs-D72Y52I5.js.map} +0 -0
  61. /package/dist/safe-js/chunks/{harness-DLEQ2Z3O.js.map → harness-LUYCGWHZ.js.map} +0 -0
  62. /package/dist/safe-js/chunks/{mcp-TNVEFJ6K.js.map → mcp-IWKZB2R2.js.map} +0 -0
  63. /package/dist/safe-js/chunks/{migration-file-IDIUFLKY.js.map → migration-file-IXO5MLP4.js.map} +0 -0
  64. /package/dist/safe-js/chunks/{restore-P27AUZR2.js.map → restore-SI7HOC6C.js.map} +0 -0
  65. /package/dist/safe-js/chunks/{run-KGAEHYMV.js.map → run-SHI2PYR6.js.map} +0 -0
  66. /package/dist/safe-js/chunks/{runtime-modules-KICK45EE.js.map → runtime-modules-OO72HTVF.js.map} +0 -0
package/README.md CHANGED
@@ -88,6 +88,10 @@ const result = await run(`
88
88
  Builtin prototypes retain their originating Object prototype when inspected
89
89
  from another realm, including when a budget is reused. Checkpoints preserve
90
90
  constructor/prototype identity and their supported property mutations.
91
+ Persistent realms can use `budget.forkRealm()` to keep separate globals and
92
+ intrinsic caches while sharing step, call-depth and retained-data limits. A fork
93
+ preserves consumed allowances, including when a sibling closes. Each budget view
94
+ supports one live realm; suspended invocation data remains charged until released.
91
95
  Map and Set instances also retain their selected prototype during inspection
92
96
  from another realm.
93
97
  Mixed-realm intrinsic checkpoints preserve separate constructor/prototype
@@ -218,8 +222,14 @@ This prints `2`. Evaluations share declarations, closures and object identity wi
218
222
  | `grants` | Granted capability names; `[]`. Every requested capability must be granted before any extension setup runs. |
219
223
  | `builtinOverrides` | Optional `{ console: "extension-name" }` authorizes that registered extension to replace only the builtin console. It must declare `console` and export a host object created in the realm. No overrides by default. |
220
224
  | `limits` | Positive integer caps: `extensions: 32`, `hostObjects: 1024`, `callbacks: 1024`, `guestReferences: 1024`, `cleanups: 1024`, `nestedEvaluations: 16`. Collection budgets also apply. |
225
+ | `classicScripts` | Optional boolean, default `false`. Evaluations use classic Script grammar with persistent globals: top-level `this` is the intrinsic global object, `var` and functions create global properties, and `let`/`const` remain lexical. Injected capabilities stay immutable lexical bindings. Explicit source modules retain module semantics. |
221
226
 
222
- Ordinary host arguments/results are still copied. To preserve live native identity, explicitly create a host object. A guest function crossing to the host becomes an opaque callback: invoke it with `realm.invokeCallback(callback, { thisValue?, args? })`, then `realm.releaseCallback(callback)` when no longer needed. Callbacks and live objects cannot cross realms or survive close. For deferred arguments that must preserve guest identity, opt into retained references as described below.
227
+ Classic Scripts reject top-level return, await and static imports/exports. This
228
+ option preserves declaration history across evaluations and checkpoints; browser
229
+ window aliases and callback scheduling belong to the host. Source-resolved dynamic
230
+ imports from classic Scripts require separate support.
231
+
232
+ Ordinary host arguments/results are still copied. To preserve live native identity, explicitly create a host object. A guest function crossing to the host becomes an opaque callback: invoke it with `realm.invokeCallback(callback, { thisValue?, args? })`, then `realm.releaseCallback(callback)` when no longer needed. Inside a declared and granted `context.nestedOperation`, await `context.invokeCallback` to settle the full guest result, including nested host calls and returned promises. Callbacks and live objects cannot cross realms or survive close. For deferred arguments that must preserve guest identity, opt into retained references as described below.
223
233
 
224
234
  Need synchronous effects without waiting for an async callback's tail? Use `realm.startCallback(callback, options)` or `context.startCallback(callback, options)`. The frozen `CallbackInvocation` exposes two promises: await `synchronous` when the guest function returns or its async body reaches its first `await`; await `result` for the final value. Interpreter implementation awaits and budget work do not complete the prefix. Ordinary throws reject both promises; nonfatal async-function errors reject only `result`, even before the first `await`. Close, abort and fatal errors reject still-pending handles without changing a completed prefix. The same callback limits, identity and reentry rules apply; no extra grant is required. Calls started outside a host operation are queued in invocation order. Browser event/default-action policy remains the host's responsibility.
225
235
 
@@ -288,6 +298,7 @@ Supply your own bounded `journal`; this does not add browser console behavior. W
288
298
  | `onCleanup(fn)` | Register a sync/async disposer. Cleanup runs in reverse order, awaits every disposer, and reports failures without skipping the rest. |
289
299
  | `chargeWork(units = 1)` | Charge a nonnegative integer against the shared execution budget. Fatal exhaustion cannot be swallowed to continue execution. |
290
300
  | `createHostObject({ properties?, methods?, indexed?, named? })` | Create a realm-owned capability. Properties declare synchronous `get`/`set` functions; methods are host functions. Optional `indexed` and `named` expose bounded live members. Undeclared members expose no native prototype. |
301
+ | `createArrayBufferReference(buffer)` | Create an opaque live reference to a fixed, attached, plain ArrayBuffer without own metadata. Requires declared and granted `array-buffer:share`; full buffer bytes count against array/data budgets and `limits.guestReferences`. |
291
302
  | `invokeCallback(callback, { thisValue?, args? })` | Invoke a captured guest function with the realm's state, cancellation and budgets. Same operation as on the realm. |
292
303
  | `startCallback(callback, { thisValue?, args? })` | Return separate `synchronous` and `result` promises for the same realm-owned invocation. Also available on the realm. |
293
304
  | `releaseCallback(callback)` | Revoke the callback and release its retained guest state. |
@@ -298,6 +309,8 @@ Supply your own bounded `journal`; this does not add browser console behavior. W
298
309
 
299
310
  For a timer-shaped `schedule(callback, delay, ...args)`, register `context.retainGuestArguments(schedule, 2)`. The host receives normal callback/delay values and opaque `GuestReference` handles for the remaining arguments. Pass those handles to `context.invokeCallback(callback, { args })` to recover the original guest objects and observe mutations made after scheduling. References also work as callback receivers and host return values, including cycles, closures, primitives and live host objects.
300
311
 
312
+ For a trusted native buffer such as WebAssembly memory, use `context.createArrayBufferReference(buffer)` and return the handle from a host property or operation. Guest ArrayBuffer views then share its bytes with the host, preserving identity and bidirectional writes. Ordinary host buffers still copy. Shared, resizable, detached, subclassed and proxy buffers reject, as do buffers with own properties or symbols. After native memory growth detaches the old buffer, create a new reference to the new buffer; the old reference continues to denote the detached buffer.
313
+
301
314
  Release each reference when the host no longer needs it; returning it does not release it. Retained graphs count against data budgets and `limits.guestReferences`. Synchronous native failure releases references captured for that call; asynchronous operations must release theirs in host cleanup. Close revokes all remaining references. Handles cannot be inspected, used in another realm, or serialized into replay/error data. Unmarked operations still copy values.
302
315
 
303
316
  For a live collection, keep the elements in your adapter and expose virtual indices instead of declaring one getter per element:
@@ -426,7 +439,7 @@ Compiling stored module source enforces the owning budget's string-length
426
439
  limit and charges one step per UTF-16 source unit before parsing. Regex
427
440
  compilation retains its additional work charges.
428
441
 
429
- `deepCopyToSandbox(value)` and `deepCopyFromSandbox(value, { wrapClosure? })` convert supported values. `wrapClosure` lets the host choose how to represent an exported sandbox function. Not every native JavaScript object is convertible.
442
+ `deepCopyToSandbox(value)` and `deepCopyFromSandbox(value, { wrapClosure? })` convert supported values. `wrapClosure` lets the host choose how to represent an exported sandbox function. Not every native JavaScript object is convertible. When passing sandbox typed arrays to native APIs, use `deepCopyFromSandbox`: SDK-created views use internal wrappers and do not satisfy the host's native `ArrayBuffer.isView` check. Guest reflection and `ArrayBuffer.isView` retain their normal behavior.
430
443
 
431
444
  Native Promise imports accept genuine promises from other JavaScript realms,
432
445
  preserving aliases and copying fulfillment or rejection values. Own string-keyed
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSandboxClosure
3
- } from "./chunk-KP6I45ET.js";
3
+ } from "./chunk-DNA7BMBY.js";
4
4
 
5
5
  // packages/safe-js/src/lint/runtime-modules.ts
6
6
  var AsyncFunction = (async () => void 0).constructor;
@@ -34,4 +34,4 @@ function isAsyncRuntimeExport(value) {
34
34
  export {
35
35
  createLintModulesFromRuntimeRegistry
36
36
  };
37
- //# sourceMappingURL=chunk-APKV5Y6T.js.map
37
+ //# sourceMappingURL=chunk-4CX3HYRY.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hashSource,
3
3
  validateSnapshotMigration
4
- } from "./chunk-U6KZ2DQ2.js";
4
+ } from "./chunk-GMPZBMPA.js";
5
5
  import {
6
6
  SnapshotValidationError,
7
7
  assertSnapshotInactive,
@@ -14,12 +14,12 @@ import {
14
14
  validateGuestFunctionAst,
15
15
  validateRuntimeSnapshotDescriptors,
16
16
  validateTemplateObjects
17
- } from "./chunk-KP6I45ET.js";
17
+ } from "./chunk-DNA7BMBY.js";
18
18
  import {
19
19
  ParseError,
20
20
  parseModule,
21
21
  replaceErrorStack
22
- } from "./chunk-IDQ67DY2.js";
22
+ } from "./chunk-ILYJBA2D.js";
23
23
 
24
24
  // packages/safe-js/src/restore.ts
25
25
  var SnapshotMismatchError = class extends Error {
@@ -112,4 +112,4 @@ export {
112
112
  SnapshotMismatchError,
113
113
  restore
114
114
  };
115
- //# sourceMappingURL=chunk-NJM2Q74Z.js.map
115
+ //# sourceMappingURL=chunk-A4L72WXV.js.map
@@ -8,7 +8,7 @@ import {
8
8
  numericTypedArrayConstructors,
9
9
  parseModule,
10
10
  tokenize
11
- } from "./chunk-IDQ67DY2.js";
11
+ } from "./chunk-ILYJBA2D.js";
12
12
 
13
13
  // packages/safe-js/src/lint/rules/AS001.ts
14
14
  function AS001(source, options = {}) {
@@ -11176,4 +11176,4 @@ function hasOnlyRegexLiteralDiagnostics(diagnostics) {
11176
11176
  export {
11177
11177
  lint
11178
11178
  };
11179
- //# sourceMappingURL=chunk-B2SQLK4O.js.map
11179
+ //# sourceMappingURL=chunk-B4M6QVUV.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SnapshotNotReadyError,
3
3
  serializeSafeJSSnapshot
4
- } from "./chunk-KP6I45ET.js";
4
+ } from "./chunk-DNA7BMBY.js";
5
5
  import {
6
6
  SandboxError
7
- } from "./chunk-IDQ67DY2.js";
7
+ } from "./chunk-ILYJBA2D.js";
8
8
 
9
9
  // packages/safe-js/src/snapshot/dump.ts
10
10
  var RUN_DUMP_CONTROLLER = /* @__PURE__ */ Symbol("SafeJS.run-dump-controller");
@@ -195,4 +195,4 @@ export {
195
195
  dumpCurrent,
196
196
  serializeRunSnapshot
197
197
  };
198
- //# sourceMappingURL=chunk-A7CADQAD.js.map
198
+ //# sourceMappingURL=chunk-BEXRQET4.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  accessDeniedSystemError,
6
6
  declareHostOperation
7
- } from "./chunk-KP6I45ET.js";
7
+ } from "./chunk-DNA7BMBY.js";
8
8
 
9
9
  // packages/safe-js/src/modules/fs.ts
10
10
  import { constants as nodeFsConstants } from "node:fs";
@@ -671,4 +671,4 @@ export {
671
671
  FS_OPTION_SURFACE,
672
672
  makeFsModule
673
673
  };
674
- //# sourceMappingURL=chunk-OP3H3ZDN.js.map
674
+ //# sourceMappingURL=chunk-BHYBD6SY.js.map