@poe-platform/safe-js 0.1.392 → 0.1.394
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-VN2F4GHQ.js → chunk-PRG3UPLV.js} +2 -2
- package/dist/safe-js/chunks/{chunk-GYLSKXNZ.js → chunk-XVBBWKP2.js} +48 -9
- package/dist/safe-js/chunks/chunk-XVBBWKP2.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/snapshot/guest-heap.d.ts +9 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-GYLSKXNZ.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-VN2F4GHQ.js.map → chunk-PRG3UPLV.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XVBBWKP2.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-PRG3UPLV.js.map
|
|
@@ -8792,6 +8792,9 @@ async function flushPromiseJobs() {
|
|
|
8792
8792
|
}
|
|
8793
8793
|
}
|
|
8794
8794
|
|
|
8795
|
+
// packages/safe-js/src/interp/promise-state.ts
|
|
8796
|
+
var promiseStates = /* @__PURE__ */ new WeakMap();
|
|
8797
|
+
|
|
8795
8798
|
// packages/safe-js/src/interp/promise-replay.ts
|
|
8796
8799
|
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
8797
8800
|
|
|
@@ -21168,9 +21171,11 @@ async function copyObjectRest(value, excludedKeys, context) {
|
|
|
21168
21171
|
}
|
|
21169
21172
|
}
|
|
21170
21173
|
|
|
21174
|
+
// packages/safe-js/src/interp/promise-resolvers.ts
|
|
21175
|
+
var promiseResolvingFunctions = /* @__PURE__ */ new WeakMap();
|
|
21176
|
+
|
|
21171
21177
|
// packages/safe-js/src/interp/promise.ts
|
|
21172
21178
|
var promiseConstructors = /* @__PURE__ */ new WeakSet();
|
|
21173
|
-
var promiseResolvingFunctions = /* @__PURE__ */ new WeakSet();
|
|
21174
21179
|
var intrinsicPromiseThenMethods = /* @__PURE__ */ new WeakSet();
|
|
21175
21180
|
var intrinsicPromiseConstructors = /* @__PURE__ */ new WeakMap();
|
|
21176
21181
|
var promisePrototypes2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -21198,10 +21203,10 @@ function createPromiseGlobals(options) {
|
|
|
21198
21203
|
);
|
|
21199
21204
|
if (typeof targetPrototype === "object" && targetPrototype !== null && targetPrototype !== prototype)
|
|
21200
21205
|
setSandboxPrototype(pending, targetPrototype, options.budget);
|
|
21201
|
-
|
|
21206
|
+
const resolverState = { promise: pending, settled: false };
|
|
21202
21207
|
const settle = (state, value) => {
|
|
21203
|
-
if (settled) return;
|
|
21204
|
-
settled = true;
|
|
21208
|
+
if (resolverState.settled) return;
|
|
21209
|
+
resolverState.settled = true;
|
|
21205
21210
|
try {
|
|
21206
21211
|
if (state === "rejected") {
|
|
21207
21212
|
reject(budgetSandboxValue2(value, options.budget));
|
|
@@ -21234,7 +21239,7 @@ function createPromiseGlobals(options) {
|
|
|
21234
21239
|
return void 0;
|
|
21235
21240
|
}
|
|
21236
21241
|
});
|
|
21237
|
-
promiseResolvingFunctions.
|
|
21242
|
+
promiseResolvingFunctions.set(resolver, resolverState);
|
|
21238
21243
|
return resolver;
|
|
21239
21244
|
});
|
|
21240
21245
|
const result = executor.call(resolvers, { stack: context?.stack ?? [], thisValue: void 0 });
|
|
@@ -22239,6 +22244,18 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22239
22244
|
|
|
22240
22245
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22241
22246
|
function captureGuestHeapNode(value, encode) {
|
|
22247
|
+
const resolver = isSandboxClosure(value) ? promiseResolvingFunctions.get(value) : void 0;
|
|
22248
|
+
if (resolver !== void 0) {
|
|
22249
|
+
const settlement = promiseStates.get(resolver.promise);
|
|
22250
|
+
if (!resolver.settled || settlement === void 0 || settlement.status === "pending") return void 0;
|
|
22251
|
+
return { kind: "promise-resolver", promise: encode(resolver.promise), state: captureObjectState(value, encode) };
|
|
22252
|
+
}
|
|
22253
|
+
if (isSandboxPromise(value)) {
|
|
22254
|
+
const settlement = promiseStates.get(value);
|
|
22255
|
+
if (settlement !== void 0 && settlement.status !== "pending")
|
|
22256
|
+
return { kind: "guest-promise", status: settlement.status, value: encode(settlement.value), state: captureObjectState(value, encode) };
|
|
22257
|
+
return void 0;
|
|
22258
|
+
}
|
|
22242
22259
|
if (hasGuestObjectState(value) || privateElements.has(value)) {
|
|
22243
22260
|
if (isSandboxRegex(value)) return { kind: "guest-regex", source: value.source, flags: value.flags, state: captureObjectState(value, encode) };
|
|
22244
22261
|
if (isSandboxBox(value)) return { kind: "guest-boxed", value: encode(boxedValue(value)), state: captureObjectState(value, encode) };
|
|
@@ -22501,6 +22518,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
22501
22518
|
function captureObjectState(value, encode) {
|
|
22502
22519
|
let properties = value;
|
|
22503
22520
|
if (isSandboxRegex(value)) properties = getRegexProperties(value);
|
|
22521
|
+
if (isSandboxPromise(value)) properties = getPromiseProperties(value);
|
|
22504
22522
|
if (isSandboxGenerator(value)) properties = getGeneratorProperties(value);
|
|
22505
22523
|
if (isSandboxClosure(value)) {
|
|
22506
22524
|
properties = value.properties;
|
|
@@ -27681,7 +27699,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27681
27699
|
createRawJson(node.text);
|
|
27682
27700
|
return true;
|
|
27683
27701
|
}
|
|
27684
|
-
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-regex", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27702
|
+
if (!["intrinsic", "bound-function", "promise-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;
|
|
27685
27703
|
const reference = (value, kinds) => {
|
|
27686
27704
|
const ref = record3(value);
|
|
27687
27705
|
fields(ref, ["kind", "id"]);
|
|
@@ -27692,7 +27710,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27692
27710
|
};
|
|
27693
27711
|
const callable = (value) => {
|
|
27694
27712
|
if (absent(value)) return;
|
|
27695
|
-
const target = reference(value, ["intrinsic", "bound-function", "guest-function", "guest-class"]);
|
|
27713
|
+
const target = reference(value, ["intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27696
27714
|
if (target.kind === "intrinsic" && intrinsicCatalogue().get(String(target.id)) !== true)
|
|
27697
27715
|
throw new TypeError("Guest accessor reference is not callable.");
|
|
27698
27716
|
};
|
|
@@ -27762,7 +27780,17 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27762
27780
|
});
|
|
27763
27781
|
return false;
|
|
27764
27782
|
}
|
|
27765
|
-
if (node.kind === "
|
|
27783
|
+
if (node.kind === "promise-resolver") {
|
|
27784
|
+
fields(node, ["kind", "promise", "state"]);
|
|
27785
|
+
reference(node.promise, ["guest-promise"]);
|
|
27786
|
+
state(node.state);
|
|
27787
|
+
} else if (node.kind === "guest-promise") {
|
|
27788
|
+
fields(node, ["kind", "status", "value", "state"]);
|
|
27789
|
+
if (node.status !== "fulfilled" && node.status !== "rejected") throw new TypeError("Invalid guest promise settlement.");
|
|
27790
|
+
if (node.status === "fulfilled" && node.value !== null && typeof node.value === "object" && record3(node.value).kind === "ref" && reference(node.value) === node)
|
|
27791
|
+
throw new TypeError("A promise cannot fulfill with itself.");
|
|
27792
|
+
state(node.state);
|
|
27793
|
+
} else if (node.kind === "guest-regex") {
|
|
27766
27794
|
fields(node, ["kind", "source", "flags", "state"]);
|
|
27767
27795
|
if (typeof node.source !== "string" || typeof node.flags !== "string") throw new TypeError("Invalid guest RegExp payload.");
|
|
27768
27796
|
state(node.state);
|
|
@@ -29546,6 +29574,15 @@ function createSandboxPromise(promise, metadata = {}) {
|
|
|
29546
29574
|
value: metadata.hostCallJournal
|
|
29547
29575
|
});
|
|
29548
29576
|
}
|
|
29577
|
+
promiseStates.set(sandboxPromise, { status: "pending" });
|
|
29578
|
+
original.then(
|
|
29579
|
+
(value) => {
|
|
29580
|
+
promiseStates.set(sandboxPromise, { status: "fulfilled", value });
|
|
29581
|
+
},
|
|
29582
|
+
(value) => {
|
|
29583
|
+
promiseStates.set(sandboxPromise, { status: "rejected", value });
|
|
29584
|
+
}
|
|
29585
|
+
);
|
|
29549
29586
|
trackSandboxPromise(sandboxPromise);
|
|
29550
29587
|
registerPromiseCancellation(sandboxPromise);
|
|
29551
29588
|
return Object.freeze(sandboxPromise);
|
|
@@ -29947,6 +29984,8 @@ function measureSandboxData(values, options = {}) {
|
|
|
29947
29984
|
return;
|
|
29948
29985
|
}
|
|
29949
29986
|
if (isSandboxPromise(value)) {
|
|
29987
|
+
const settlement = promiseStates.get(value);
|
|
29988
|
+
if (settlement !== void 0 && settlement.status !== "pending") visit(settlement.value, depth + 1);
|
|
29950
29989
|
for (const key of Reflect.ownKeys(getPromiseProperties(value))) {
|
|
29951
29990
|
const descriptor = Object.getOwnPropertyDescriptor(getPromiseProperties(value), key);
|
|
29952
29991
|
usage += typeof key === "string" ? key.length + 1 : 1;
|
|
@@ -44962,4 +45001,4 @@ export {
|
|
|
44962
45001
|
FileSnapshotBackend,
|
|
44963
45002
|
run
|
|
44964
45003
|
};
|
|
44965
|
-
//# sourceMappingURL=chunk-
|
|
45004
|
+
//# sourceMappingURL=chunk-XVBBWKP2.js.map
|