@poe-platform/safe-js 0.1.723 → 0.1.725

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 (63) hide show
  1. package/README.md +3 -0
  2. package/dist/safe-js/chunks/{chunk-WF7HYDJ4.js → chunk-6OE64YMG.js} +2 -2
  3. package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js → chunk-6YSHQ5ET.js} +2 -2
  4. package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js → chunk-ECTNNLWN.js} +4 -4
  5. package/dist/safe-js/chunks/{chunk-5MT2LF3W.js → chunk-FYSWUSHN.js} +3 -3
  6. package/dist/safe-js/chunks/{chunk-3QQYJ4RQ.js → chunk-HG5QP5UC.js} +2 -2
  7. package/dist/safe-js/chunks/{chunk-QMZG576E.js → chunk-K6F5QLZQ.js} +3 -3
  8. package/dist/safe-js/chunks/{chunk-RYVHEOHM.js → chunk-KOO6YGQG.js} +21 -5
  9. package/dist/safe-js/chunks/chunk-KOO6YGQG.js.map +7 -0
  10. package/dist/safe-js/chunks/{chunk-SWQHZKYM.js → chunk-O2CPPE6M.js} +2 -2
  11. package/dist/safe-js/chunks/{chunk-M6HUSN7X.js → chunk-PKRGP34X.js} +37 -10
  12. package/dist/safe-js/chunks/chunk-PKRGP34X.js.map +7 -0
  13. package/dist/safe-js/chunks/{chunk-IZ52PAOD.js → chunk-QU2F65UQ.js} +890 -495
  14. package/dist/safe-js/chunks/{chunk-IZ52PAOD.js.map → chunk-QU2F65UQ.js.map} +4 -4
  15. package/dist/safe-js/chunks/{chunk-KHJDAEET.js → chunk-V2ESZF34.js} +4 -4
  16. package/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js → chunk-Y7LSEUWV.js} +3 -3
  17. package/dist/safe-js/chunks/{chunk-HY3Q377V.js → chunk-YRALPIEZ.js} +2 -2
  18. package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js → cli-runtime-5HVEFMDB.js} +13 -13
  19. package/dist/safe-js/chunks/{dump-TWVEBH5W.js → dump-VKSKINUI.js} +4 -4
  20. package/dist/safe-js/chunks/{fs-DSNHTHBT.js → fs-CZ2TAPHK.js} +4 -4
  21. package/dist/safe-js/chunks/harness-WNABEKDH.js +10 -0
  22. package/dist/safe-js/chunks/mcp-ZZDGN5CA.js +11 -0
  23. package/dist/safe-js/chunks/migration-file-QVT4W464.js +12 -0
  24. package/dist/safe-js/chunks/restore-PTIQHGKI.js +13 -0
  25. package/dist/safe-js/chunks/run-WNR7QYUJ.js +17 -0
  26. package/dist/safe-js/chunks/runtime-modules-YEOG62RU.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 +2 -0
  30. package/dist/safe-js/index.js +13 -13
  31. package/dist/safe-js/interp/arguments.d.ts +1 -2
  32. package/dist/safe-js/interp/host-bridge.d.ts +1 -1
  33. package/dist/safe-js/interp/scope.d.ts +1 -0
  34. package/dist/safe-js/interp/values.d.ts +1 -0
  35. package/dist/safe-js/parse/compact-spans.d.ts +4 -0
  36. package/package.json +2 -2
  37. package/dist/safe-js/chunks/chunk-M6HUSN7X.js.map +0 -7
  38. package/dist/safe-js/chunks/chunk-RYVHEOHM.js.map +0 -7
  39. package/dist/safe-js/chunks/harness-RLA643GD.js +0 -10
  40. package/dist/safe-js/chunks/mcp-IEY7HXXT.js +0 -11
  41. package/dist/safe-js/chunks/migration-file-QMI45CSP.js +0 -12
  42. package/dist/safe-js/chunks/restore-R5PLLBST.js +0 -13
  43. package/dist/safe-js/chunks/run-QATVEFVQ.js +0 -17
  44. package/dist/safe-js/chunks/runtime-modules-5D7KDFMZ.js +0 -10
  45. /package/dist/safe-js/chunks/{chunk-WF7HYDJ4.js.map → chunk-6OE64YMG.js.map} +0 -0
  46. /package/dist/safe-js/chunks/{chunk-7TL6Z6LT.js.map → chunk-6YSHQ5ET.js.map} +0 -0
  47. /package/dist/safe-js/chunks/{chunk-7FCMZUZJ.js.map → chunk-ECTNNLWN.js.map} +0 -0
  48. /package/dist/safe-js/chunks/{chunk-5MT2LF3W.js.map → chunk-FYSWUSHN.js.map} +0 -0
  49. /package/dist/safe-js/chunks/{chunk-3QQYJ4RQ.js.map → chunk-HG5QP5UC.js.map} +0 -0
  50. /package/dist/safe-js/chunks/{chunk-QMZG576E.js.map → chunk-K6F5QLZQ.js.map} +0 -0
  51. /package/dist/safe-js/chunks/{chunk-SWQHZKYM.js.map → chunk-O2CPPE6M.js.map} +0 -0
  52. /package/dist/safe-js/chunks/{chunk-KHJDAEET.js.map → chunk-V2ESZF34.js.map} +0 -0
  53. /package/dist/safe-js/chunks/{chunk-Y5ZXQHL6.js.map → chunk-Y7LSEUWV.js.map} +0 -0
  54. /package/dist/safe-js/chunks/{chunk-HY3Q377V.js.map → chunk-YRALPIEZ.js.map} +0 -0
  55. /package/dist/safe-js/chunks/{cli-runtime-EPXCJ5AG.js.map → cli-runtime-5HVEFMDB.js.map} +0 -0
  56. /package/dist/safe-js/chunks/{dump-TWVEBH5W.js.map → dump-VKSKINUI.js.map} +0 -0
  57. /package/dist/safe-js/chunks/{fs-DSNHTHBT.js.map → fs-CZ2TAPHK.js.map} +0 -0
  58. /package/dist/safe-js/chunks/{harness-RLA643GD.js.map → harness-WNABEKDH.js.map} +0 -0
  59. /package/dist/safe-js/chunks/{mcp-IEY7HXXT.js.map → mcp-ZZDGN5CA.js.map} +0 -0
  60. /package/dist/safe-js/chunks/{migration-file-QMI45CSP.js.map → migration-file-QVT4W464.js.map} +0 -0
  61. /package/dist/safe-js/chunks/{restore-R5PLLBST.js.map → restore-PTIQHGKI.js.map} +0 -0
  62. /package/dist/safe-js/chunks/{run-QATVEFVQ.js.map → run-WNR7QYUJ.js.map} +0 -0
  63. /package/dist/safe-js/chunks/{runtime-modules-5D7KDFMZ.js.map → runtime-modules-YEOG62RU.js.map} +0 -0
package/README.md CHANGED
@@ -324,6 +324,7 @@ Supply your own bounded `journal`; this does not add browser console behavior. W
324
324
  | `invokeCallback(callback, { thisValue?, args? })` | Invoke a captured guest function with the realm's state, cancellation and budgets. Same operation as on the realm. |
325
325
  | `startCallback(callback, { thisValue?, args? })` | Return separate `synchronous` and `result` promises for the same realm-owned invocation. Also available on the realm. |
326
326
  | `releaseCallback(callback)` | Revoke the callback and release its retained guest state. |
327
+ | `retainCallbackArguments(operation)` | During setup, give each call independent callback wrappers in its copied arguments. Requires declared and granted `guest:retain`. The host owns these wrappers and releases each with `releaseCallback`; aliases within one call still share a wrapper. |
327
328
  | `retainGuestArguments(operation, from)` | During setup, opt an operation into opaque argument references starting at the zero-based index `from`. Requires declared and granted `guest:retain`. Earlier arguments keep normal conversion; live host methods preserve the declaration. |
328
329
  | `releaseGuestReference(reference)` | Revoke one reference and release its retained state. Also available on the realm. |
329
330
  | `nestedOperation(fn)` | During setup, mark a host operation authorized to run nested source. Requires declared and granted `source:nested`. |
@@ -333,6 +334,8 @@ Use `expandos: { maxKeys, maxKeyCodeUnits, assertActive? }` to allow guest assig
333
334
 
334
335
  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.
335
336
 
337
+ Also register `context.retainCallbackArguments(schedule)` when each scheduled task owns its callback. Different calls then receive independently releasable wrappers, even for the same guest function; normal exports keep their shared callback identity. Release a timer's wrapper after cancellation or after all its invocation phases settle. Copied callbacks count against `limits.callbacks` and data budgets. Argument-copy failure or synchronous host failure revokes that call's owned wrappers; asynchronous operations must release theirs in host cleanup. Returning a wrapper to guest code preserves the original function identity and does not release it.
338
+
336
339
  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.
337
340
 
338
341
  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.
@@ -14,7 +14,7 @@ import {
14
14
  safeRecordException,
15
15
  safeStartSpan,
16
16
  splitSourceLines
17
- } from "./chunk-RYVHEOHM.js";
17
+ } from "./chunk-KOO6YGQG.js";
18
18
 
19
19
  // packages/safe-js/src/error/format.ts
20
20
  var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
@@ -2841,4 +2841,4 @@ export {
2841
2841
  makeLogModule,
2842
2842
  makeMetricModule
2843
2843
  };
2844
- //# sourceMappingURL=chunk-WF7HYDJ4.js.map
2844
+ //# sourceMappingURL=chunk-6OE64YMG.js.map
@@ -5,7 +5,7 @@ import {
5
5
  accessDeniedSystemError,
6
6
  declareBudgetedHostOperation,
7
7
  declareHostOperation
8
- } from "./chunk-IZ52PAOD.js";
8
+ } from "./chunk-QU2F65UQ.js";
9
9
 
10
10
  // packages/safe-js/src/modules/fs.ts
11
11
  import { constants as nodeFsConstants } from "node:fs";
@@ -721,4 +721,4 @@ export {
721
721
  FS_OPTION_SURFACE,
722
722
  makeFsModule
723
723
  };
724
- //# sourceMappingURL=chunk-7TL6Z6LT.js.map
724
+ //# sourceMappingURL=chunk-6YSHQ5ET.js.map
@@ -7,7 +7,7 @@ import {
7
7
  validateMigrationReconciliation,
8
8
  validateMigrationSemantics,
9
9
  validateSnapshotMigration
10
- } from "./chunk-Y5ZXQHL6.js";
10
+ } from "./chunk-Y7LSEUWV.js";
11
11
  import {
12
12
  DUMP_FORMAT_VERSION,
13
13
  EXECUTION_SEMANTICS,
@@ -17,10 +17,10 @@ import {
17
17
  serializeSafeJSSnapshot,
18
18
  validateDumpEnvelope,
19
19
  validateSnapshotData
20
- } from "./chunk-IZ52PAOD.js";
20
+ } from "./chunk-QU2F65UQ.js";
21
21
  import {
22
22
  parseModule
23
- } from "./chunk-RYVHEOHM.js";
23
+ } from "./chunk-KOO6YGQG.js";
24
24
 
25
25
  // packages/safe-js/src/migration-file.ts
26
26
  import { randomUUID } from "node:crypto";
@@ -179,4 +179,4 @@ export {
179
179
  migrateSnapshot,
180
180
  migrateSnapshotFile
181
181
  };
182
- //# sourceMappingURL=chunk-7FCMZUZJ.js.map
182
+ //# sourceMappingURL=chunk-ECTNNLWN.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SnapshotNotReadyError,
3
3
  serializeSafeJSSnapshot
4
- } from "./chunk-IZ52PAOD.js";
4
+ } from "./chunk-QU2F65UQ.js";
5
5
  import {
6
6
  SandboxError
7
- } from "./chunk-RYVHEOHM.js";
7
+ } from "./chunk-KOO6YGQG.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-5MT2LF3W.js.map
198
+ //# sourceMappingURL=chunk-FYSWUSHN.js.map
@@ -8,7 +8,7 @@ import {
8
8
  numericTypedArrayConstructors,
9
9
  parseModule,
10
10
  tokenize
11
- } from "./chunk-RYVHEOHM.js";
11
+ } from "./chunk-KOO6YGQG.js";
12
12
 
13
13
  // packages/safe-js/src/lint/rules/AS001.ts
14
14
  function AS001(source, options = {}) {
@@ -11177,4 +11177,4 @@ function hasOnlyRegexLiteralDiagnostics(diagnostics) {
11177
11177
  export {
11178
11178
  lint
11179
11179
  };
11180
- //# sourceMappingURL=chunk-3QQYJ4RQ.js.map
11180
+ //# sourceMappingURL=chunk-HG5QP5UC.js.map
@@ -6,10 +6,10 @@ import {
6
6
  import {
7
7
  declareHostOperation,
8
8
  runResources
9
- } from "./chunk-IZ52PAOD.js";
9
+ } from "./chunk-QU2F65UQ.js";
10
10
  import {
11
11
  hostErrorData
12
- } from "./chunk-RYVHEOHM.js";
12
+ } from "./chunk-KOO6YGQG.js";
13
13
 
14
14
  // packages/safe-js/src/modules/mcp.ts
15
15
  var DEFAULT_TOOL_BATCH_CONCURRENCY = 4;
@@ -402,4 +402,4 @@ function isPlainObjectRecord(value) {
402
402
  export {
403
403
  makeMcpModule
404
404
  };
405
- //# sourceMappingURL=chunk-QMZG576E.js.map
405
+ //# sourceMappingURL=chunk-K6F5QLZQ.js.map
@@ -1076,6 +1076,8 @@ var CompactSourcePositions = class {
1076
1076
  sourceLength;
1077
1077
  lines = [0];
1078
1078
  positions = /* @__PURE__ */ new Map();
1079
+ evictionOffsets = new Float64Array(cacheSize);
1080
+ evictionIndex = 0;
1079
1081
  makeSpan;
1080
1082
  constructor(source) {
1081
1083
  this.sourceLength = source.length;
@@ -1143,8 +1145,10 @@ var CompactSourcePositions = class {
1143
1145
  });
1144
1146
  setOwner(position, this);
1145
1147
  if (this.positions.size === cacheSize)
1146
- this.positions.delete(this.positions.keys().next().value);
1148
+ this.positions.delete(this.evictionOffsets[this.evictionIndex]);
1147
1149
  this.positions.set(offset, position);
1150
+ this.evictionOffsets[this.evictionIndex] = offset;
1151
+ this.evictionIndex = (this.evictionIndex + 1) % cacheSize;
1148
1152
  return position;
1149
1153
  }
1150
1154
  span(start, end) {
@@ -1158,6 +1162,18 @@ var CompactSourcePositions = class {
1158
1162
  const point = this.position(position.offset);
1159
1163
  return point.line === position.line && point.column === position.column ? point : void 0;
1160
1164
  }
1165
+ /** Packing validates coordinates without materializing or interning a point. */
1166
+ matchesPosition(position) {
1167
+ if (!Number.isSafeInteger(position.offset) || position.offset < 0 || position.offset > this.sourceLength)
1168
+ return false;
1169
+ const offset = position.offset;
1170
+ this.assertOffset(offset);
1171
+ const line = position.line;
1172
+ if (!Number.isSafeInteger(line) || line < 1 || line > this.lines.length) return false;
1173
+ const start = this.lines[line - 1];
1174
+ if (offset < start || line < this.lines.length && offset >= this.lines[line]) return false;
1175
+ return offset - start + 1 === position.column;
1176
+ }
1161
1177
  assertOffset(offset) {
1162
1178
  if (!Number.isSafeInteger(offset) || offset < 0 || offset > this.sourceLength)
1163
1179
  throw new RangeError("Source coordinate offset is outside its source.");
@@ -1287,9 +1303,9 @@ var CompactModuleAst = class {
1287
1303
  this.write(row + 1, value.length);
1288
1304
  } else if (keys.length === 2 && keys[0] === "start" && keys[1] === "end") {
1289
1305
  const span = value, start = span.start, end = span.end;
1290
- const startPoint = this.positions.compatiblePosition(start);
1291
- const endPoint = this.positions.compatiblePosition(end);
1292
- if (startPoint && endPoint) {
1306
+ const startMatches = this.positions.matchesPosition(start);
1307
+ const endMatches = this.positions.matchesPosition(end);
1308
+ if (startMatches && endMatches) {
1293
1309
  kind = 1;
1294
1310
  row = this.reserve(3);
1295
1311
  this.write(row, kind);
@@ -8645,4 +8661,4 @@ export {
8645
8661
  Float16Array2 as Float16Array,
8646
8662
  numericTypedArrayConstructors
8647
8663
  };
8648
- //# sourceMappingURL=chunk-RYVHEOHM.js.map
8664
+ //# sourceMappingURL=chunk-KOO6YGQG.js.map