@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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  deepCopyToSandbox
3
- } from "./chunk-IZ52PAOD.js";
3
+ } from "./chunk-QU2F65UQ.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-SWQHZKYM.js.map
55
+ //# sourceMappingURL=chunk-O2CPPE6M.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  restore
3
- } from "./chunk-KHJDAEET.js";
3
+ } from "./chunk-V2ESZF34.js";
4
4
  import {
5
5
  attachDumpController,
6
6
  createDumpController
7
- } from "./chunk-5MT2LF3W.js";
7
+ } from "./chunk-FYSWUSHN.js";
8
8
  import {
9
9
  getOwnErrorCode,
10
10
  hasOwnErrorCode
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  hashParsedAst,
14
14
  hashSource
15
- } from "./chunk-Y5ZXQHL6.js";
15
+ } from "./chunk-Y7LSEUWV.js";
16
16
  import {
17
17
  DUMP_FORMAT_VERSION,
18
18
  EXECUTION_SEMANTICS,
@@ -100,7 +100,7 @@ import {
100
100
  withSandboxPromiseRejectionTracker,
101
101
  wrapCallerInjectedBindings,
102
102
  wrapCancelableBindings
103
- } from "./chunk-IZ52PAOD.js";
103
+ } from "./chunk-QU2F65UQ.js";
104
104
  import {
105
105
  Budget,
106
106
  CompileScope,
@@ -115,7 +115,7 @@ import {
115
115
  parseSourceModule,
116
116
  replaceErrorStack,
117
117
  safeAddEvent
118
- } from "./chunk-RYVHEOHM.js";
118
+ } from "./chunk-KOO6YGQG.js";
119
119
 
120
120
  // packages/safe-js/src/realm.ts
121
121
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
@@ -751,6 +751,7 @@ var RealmState = class {
751
751
  guestReferences = /* @__PURE__ */ new Map();
752
752
  retainedOperations = /* @__PURE__ */ new WeakMap();
753
753
  nestedOperations = /* @__PURE__ */ new WeakMap();
754
+ callbackOperations = /* @__PURE__ */ new WeakMap();
754
755
  convertedModules = /* @__PURE__ */ new Map();
755
756
  nativeConversions = { seen: /* @__PURE__ */ new WeakMap() };
756
757
  modules;
@@ -784,15 +785,27 @@ var RealmState = class {
784
785
  };
785
786
  captureArguments = (operation, args, copy) => {
786
787
  const from = this.retainedOperations.get(operation)?.from ?? args.length;
787
- const values = copy(args.slice(0, from));
788
+ const owned = this.callbackOperations.has(operation) ? /* @__PURE__ */ new Map() : void 0;
788
789
  const captured = [];
789
790
  const rollback = () => {
790
791
  for (const reference of captured) {
791
792
  revokeGuestReference(reference, this);
792
793
  this.guestReferences.delete(reference);
793
794
  }
795
+ for (const callback of owned?.values() ?? []) {
796
+ revokeGuestCallback(callback, this);
797
+ this.callbacks.delete(callback);
798
+ }
794
799
  };
795
800
  try {
801
+ const values = copy(args.slice(0, from), owned === void 0 ? void 0 : (closure) => {
802
+ let callback = owned.get(closure);
803
+ if (callback === void 0) {
804
+ callback = this.wrapCallback(closure, true);
805
+ owned.set(closure, callback);
806
+ }
807
+ return callback;
808
+ });
796
809
  for (const value of args.slice(from)) {
797
810
  this.checkCollection(
798
811
  this.guestReferences.size + 1,
@@ -1053,9 +1066,9 @@ var RealmState = class {
1053
1066
  }
1054
1067
  return object;
1055
1068
  };
1056
- wrapCallback = (closure) => {
1069
+ wrapCallback = (closure, owned = false) => {
1057
1070
  this.assertOpen();
1058
- const existing = this.callbackCache.get(closure);
1071
+ const existing = owned ? void 0 : this.callbackCache.get(closure);
1059
1072
  if (existing !== void 0 && this.callbacks.has(existing)) return existing;
1060
1073
  this.checkCollection(this.callbacks.size + 1, this.limits.callbacks, "callback");
1061
1074
  const invokeCallback = this.invokeCallback;
@@ -1063,7 +1076,7 @@ var RealmState = class {
1063
1076
  return invokeCallback(callback, { args, thisValue: this });
1064
1077
  };
1065
1078
  this.callbacks.set(callback, closure);
1066
- this.callbackCache.set(closure, callback);
1079
+ if (!owned) this.callbackCache.set(closure, callback);
1067
1080
  registerGuestCallback(callback, {
1068
1081
  owner: this,
1069
1082
  closure,
@@ -1221,6 +1234,20 @@ var RealmState = class {
1221
1234
  invokeCallback: this.invokeCallback,
1222
1235
  releaseCallback: this.releaseCallback,
1223
1236
  releaseGuestReference: this.releaseGuestReference,
1237
+ retainCallbackArguments: (operation) => {
1238
+ this.assertOpen();
1239
+ if (!extension.manifest.capabilities?.includes("guest:retain"))
1240
+ throw new TypeError("Retaining callbacks requires the guest:retain grant.");
1241
+ if (typeof operation !== "function")
1242
+ throw new TypeError("Retained callback operation must be a function.");
1243
+ if (this.scope !== void 0)
1244
+ throw new TypeError("Retained callback operations must be registered during setup.");
1245
+ const owner = this.callbackOperations.get(operation);
1246
+ if (owner !== void 0 && owner !== extension)
1247
+ throw new TypeError("Retained callback operation already belongs to another extension.");
1248
+ this.callbackOperations.set(operation, extension);
1249
+ return operation;
1250
+ },
1224
1251
  retainGuestArguments: (operation, from) => {
1225
1252
  this.assertOpen();
1226
1253
  if (!extension.manifest.capabilities?.includes("guest:retain"))
@@ -2798,4 +2825,4 @@ export {
2798
2825
  UnhandledRejectionError,
2799
2826
  run
2800
2827
  };
2801
- //# sourceMappingURL=chunk-M6HUSN7X.js.map
2828
+ //# sourceMappingURL=chunk-PKRGP34X.js.map