@poe-platform/safe-js 0.1.402 → 0.1.403
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.
- package/dist/safe-js/chunks/{chunk-3DXEWN6Z.js → chunk-5KXKPBGW.js} +2 -2
- package/dist/safe-js/chunks/{chunk-5RNME7ZM.js → chunk-DXLKDLGM.js} +32 -17
- package/dist/safe-js/chunks/chunk-DXLKDLGM.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/promise-continuations.d.ts +5 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +5 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-5RNME7ZM.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-3DXEWN6Z.js.map → chunk-5KXKPBGW.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DXLKDLGM.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-5KXKPBGW.js.map
|
|
@@ -8812,6 +8812,7 @@ async function flushPromiseJobs() {
|
|
|
8812
8812
|
var promiseStates = /* @__PURE__ */ new WeakMap();
|
|
8813
8813
|
|
|
8814
8814
|
// packages/safe-js/src/interp/promise-continuations.ts
|
|
8815
|
+
var promiseCapabilityExecutors = /* @__PURE__ */ new WeakMap();
|
|
8815
8816
|
var promiseAggregateHandlers = /* @__PURE__ */ new WeakMap();
|
|
8816
8817
|
var promiseAggregateStates = /* @__PURE__ */ new WeakMap();
|
|
8817
8818
|
var promiseAggregateEntries = /* @__PURE__ */ new WeakMap();
|
|
@@ -21516,19 +21517,8 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21516
21517
|
if (!isSandboxClosure(constructor) || constructor.construct === void 0) {
|
|
21517
21518
|
throw new TypeError("Promise method requires a constructor receiver.");
|
|
21518
21519
|
}
|
|
21519
|
-
|
|
21520
|
-
|
|
21521
|
-
const executor = createSandboxClosure({
|
|
21522
|
-
sandbox: true,
|
|
21523
|
-
retainedValues: () => [resolve, reject],
|
|
21524
|
-
call: (args) => {
|
|
21525
|
-
if (resolve !== void 0 || reject !== void 0) {
|
|
21526
|
-
throw new TypeError("Promise capability is already initialized.");
|
|
21527
|
-
}
|
|
21528
|
-
[resolve, reject] = args;
|
|
21529
|
-
return void 0;
|
|
21530
|
-
}
|
|
21531
|
-
});
|
|
21520
|
+
const state = { resolve: void 0, reject: void 0 };
|
|
21521
|
+
const executor = createPromiseCapabilityExecutor(state);
|
|
21532
21522
|
const leaveCall = budget.enterCall();
|
|
21533
21523
|
try {
|
|
21534
21524
|
const promise = await constructor.construct([executor], {
|
|
@@ -21537,6 +21527,7 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21537
21527
|
thisValue: void 0,
|
|
21538
21528
|
newTarget: constructor
|
|
21539
21529
|
});
|
|
21530
|
+
const { resolve, reject } = state;
|
|
21540
21531
|
if (!isSandboxClosure(resolve) || !isSandboxClosure(reject)) {
|
|
21541
21532
|
throw new TypeError("Promise capability requires callable resolve and reject functions.");
|
|
21542
21533
|
}
|
|
@@ -21545,6 +21536,24 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21545
21536
|
leaveCall();
|
|
21546
21537
|
}
|
|
21547
21538
|
}
|
|
21539
|
+
function createPromiseCapabilityExecutor(state) {
|
|
21540
|
+
const executor = createSandboxClosure({
|
|
21541
|
+
sandbox: true,
|
|
21542
|
+
guest: true,
|
|
21543
|
+
name: "",
|
|
21544
|
+
length: 2,
|
|
21545
|
+
retainedValues: () => [state.resolve, state.reject],
|
|
21546
|
+
call: ([resolve, reject]) => {
|
|
21547
|
+
if (state.resolve !== void 0 || state.reject !== void 0)
|
|
21548
|
+
throw new TypeError("Promise capability is already initialized.");
|
|
21549
|
+
state.resolve = resolve;
|
|
21550
|
+
state.reject = reject;
|
|
21551
|
+
return void 0;
|
|
21552
|
+
}
|
|
21553
|
+
});
|
|
21554
|
+
promiseCapabilityExecutors.set(executor, state);
|
|
21555
|
+
return executor;
|
|
21556
|
+
}
|
|
21548
21557
|
async function callPromiseClosure(callback, args, thisValue, budget, context) {
|
|
21549
21558
|
const leaveCall = budget.enterCall();
|
|
21550
21559
|
try {
|
|
@@ -22359,6 +22368,9 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22359
22368
|
|
|
22360
22369
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22361
22370
|
function captureGuestHeapNode(value, encode) {
|
|
22371
|
+
const executor = isSandboxClosure(value) ? promiseCapabilityExecutors.get(value) : void 0;
|
|
22372
|
+
if (executor !== void 0)
|
|
22373
|
+
return { kind: "capability-executor", resolve: encode(executor.resolve), reject: encode(executor.reject), state: captureObjectState(value, encode) };
|
|
22362
22374
|
const aggregate = promiseAggregateStates.get(value);
|
|
22363
22375
|
if (aggregate !== void 0) {
|
|
22364
22376
|
if (aggregate.iteration === "active") throw new TypeError("Cannot snapshot an active promise aggregate iterator.");
|
|
@@ -27901,7 +27913,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27901
27913
|
createRawJson(node.text);
|
|
27902
27914
|
return true;
|
|
27903
27915
|
}
|
|
27904
|
-
if (!["promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27916
|
+
if (!["capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27905
27917
|
const reference = (value, kinds) => {
|
|
27906
27918
|
const ref = record3(value);
|
|
27907
27919
|
fields(ref, ["kind", "id"]);
|
|
@@ -27912,7 +27924,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27912
27924
|
};
|
|
27913
27925
|
const callable = (value) => {
|
|
27914
27926
|
if (absent(value)) return;
|
|
27915
|
-
const target = reference(value, ["intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27927
|
+
const target = reference(value, ["capability-executor", "intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27916
27928
|
if (target.kind === "intrinsic" && intrinsicCatalogue().get(String(target.id)) !== true)
|
|
27917
27929
|
throw new TypeError("Guest accessor reference is not callable.");
|
|
27918
27930
|
};
|
|
@@ -27993,7 +28005,10 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27993
28005
|
});
|
|
27994
28006
|
return false;
|
|
27995
28007
|
}
|
|
27996
|
-
if (node.kind === "
|
|
28008
|
+
if (node.kind === "capability-executor") {
|
|
28009
|
+
fields(node, ["kind", "resolve", "reject", "state"]);
|
|
28010
|
+
state(node.state);
|
|
28011
|
+
} else if (node.kind === "promise-aggregate") {
|
|
27997
28012
|
fields(node, ["kind", "method", "capability", "values", "remaining", "size", "iteration"]);
|
|
27998
28013
|
if (!["all", "allSettled", "race", "any"].includes(String(node.method))) throw new TypeError("Invalid promise aggregate method.");
|
|
27999
28014
|
const size = integer(node.size);
|
|
@@ -45359,4 +45374,4 @@ export {
|
|
|
45359
45374
|
FileSnapshotBackend,
|
|
45360
45375
|
run
|
|
45361
45376
|
};
|
|
45362
|
-
//# sourceMappingURL=chunk-
|
|
45377
|
+
//# sourceMappingURL=chunk-DXLKDLGM.js.map
|