@poe-platform/safe-js 0.1.393 → 0.1.395
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-UDQ7HBDC.js → chunk-7V4MG4KI.js} +47 -21
- package/dist/safe-js/chunks/chunk-7V4MG4KI.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-CTMJJJQL.js → chunk-LQ2HXAJ6.js} +2 -2
- 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 +4 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-UDQ7HBDC.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-CTMJJJQL.js.map → chunk-LQ2HXAJ6.js.map} +0 -0
|
@@ -8165,6 +8165,12 @@ var guestClosures = /* @__PURE__ */ new WeakSet();
|
|
|
8165
8165
|
var functionProperties = /* @__PURE__ */ new WeakMap();
|
|
8166
8166
|
var functionPropertyRevisions = /* @__PURE__ */ new WeakMap();
|
|
8167
8167
|
var prototypes = /* @__PURE__ */ new WeakMap();
|
|
8168
|
+
var trackedPrototypes = /* @__PURE__ */ new WeakMap();
|
|
8169
|
+
function storePrototype(value, prototype) {
|
|
8170
|
+
prototypes.set(value, prototype);
|
|
8171
|
+
const tracked = trackedPrototypes.get(value);
|
|
8172
|
+
if (tracked !== void 0) tracked.current = prototype;
|
|
8173
|
+
}
|
|
8168
8174
|
var intrinsicPrototypes = /* @__PURE__ */ new WeakMap();
|
|
8169
8175
|
var boxedPrototypes = /* @__PURE__ */ new WeakMap();
|
|
8170
8176
|
var regexPrototypes = /* @__PURE__ */ new WeakMap();
|
|
@@ -8249,7 +8255,7 @@ function getGuestFunctionProperty(closure, key) {
|
|
|
8249
8255
|
return properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key)?.value;
|
|
8250
8256
|
}
|
|
8251
8257
|
function installObjectPrototype(budget, prototype, constructor) {
|
|
8252
|
-
|
|
8258
|
+
storePrototype(prototype, null);
|
|
8253
8259
|
intrinsicPrototypes.set(budget, prototype);
|
|
8254
8260
|
registerIntrinsicPrototype(budget, prototype, constructor);
|
|
8255
8261
|
}
|
|
@@ -8290,7 +8296,7 @@ function installDatePrototype(budget, prototype, constructor) {
|
|
|
8290
8296
|
}
|
|
8291
8297
|
function installArrayPrototype(budget, prototype, constructor) {
|
|
8292
8298
|
arrayPrototypes.set(budget, prototype);
|
|
8293
|
-
|
|
8299
|
+
storePrototype(prototype, intrinsicPrototypes.get(budget) ?? null);
|
|
8294
8300
|
initialArrayMethods.set(prototype, new Map(Object.entries(Object.getOwnPropertyDescriptors(prototype)).map(([key, descriptor]) => [key, descriptor.value])));
|
|
8295
8301
|
registerIntrinsicPrototype(budget, prototype, constructor);
|
|
8296
8302
|
}
|
|
@@ -8338,12 +8344,20 @@ function trackIntrinsicState(budget, root, owner, targets) {
|
|
|
8338
8344
|
let roots = intrinsicPrototypeRoots.get(budget);
|
|
8339
8345
|
if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
|
|
8340
8346
|
roots.add(root);
|
|
8341
|
-
const records = [...new Set(targets)].map((target) =>
|
|
8342
|
-
target
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
+
const records = [...new Set(targets)].map((target) => {
|
|
8348
|
+
let tracked = trackedPrototypes.get(target);
|
|
8349
|
+
if (tracked === void 0) {
|
|
8350
|
+
tracked = { current: getSandboxPrototype(target) };
|
|
8351
|
+
trackedPrototypes.set(target, tracked);
|
|
8352
|
+
}
|
|
8353
|
+
return {
|
|
8354
|
+
target,
|
|
8355
|
+
value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
|
|
8356
|
+
prototype: tracked.current,
|
|
8357
|
+
tracked,
|
|
8358
|
+
explicit: hasExplicitSandboxPrototype(target)
|
|
8359
|
+
};
|
|
8360
|
+
}).map((record4) => ({
|
|
8347
8361
|
...record4,
|
|
8348
8362
|
revision: functionPropertyRevisions.get(record4.value),
|
|
8349
8363
|
capturedRevision: -1,
|
|
@@ -8364,8 +8378,8 @@ function trackIntrinsicState(budget, root, owner, targets) {
|
|
|
8364
8378
|
budget.setRetainedValues(root, () => {
|
|
8365
8379
|
const retained = [];
|
|
8366
8380
|
for (const record4 of records) {
|
|
8367
|
-
const {
|
|
8368
|
-
const currentPrototype =
|
|
8381
|
+
const { value, descriptors: descriptors2, prototype: parent, revision } = record4;
|
|
8382
|
+
const currentPrototype = record4.tracked.current;
|
|
8369
8383
|
if (currentPrototype !== parent) retained.push(currentPrototype);
|
|
8370
8384
|
if (revision === void 0 || revision.revision !== record4.capturedRevision) {
|
|
8371
8385
|
const captured = [];
|
|
@@ -8503,7 +8517,7 @@ function setSandboxPrototype(value, prototype, budget, throwOnFailure = true) {
|
|
|
8503
8517
|
);
|
|
8504
8518
|
}
|
|
8505
8519
|
if (getSandboxPrototype(value, budget) === prototype) {
|
|
8506
|
-
if (prototype === null)
|
|
8520
|
+
if (prototype === null) storePrototype(value, null);
|
|
8507
8521
|
return true;
|
|
8508
8522
|
}
|
|
8509
8523
|
if (!Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
@@ -8519,7 +8533,7 @@ function setSandboxPrototype(value, prototype, budget, throwOnFailure = true) {
|
|
|
8519
8533
|
throw new TypeError("Cyclic prototype value.");
|
|
8520
8534
|
}
|
|
8521
8535
|
}
|
|
8522
|
-
|
|
8536
|
+
storePrototype(value, prototype);
|
|
8523
8537
|
return true;
|
|
8524
8538
|
}
|
|
8525
8539
|
function isPrototypeRecord(value) {
|
|
@@ -21171,9 +21185,11 @@ async function copyObjectRest(value, excludedKeys, context) {
|
|
|
21171
21185
|
}
|
|
21172
21186
|
}
|
|
21173
21187
|
|
|
21188
|
+
// packages/safe-js/src/interp/promise-resolvers.ts
|
|
21189
|
+
var promiseResolvingFunctions = /* @__PURE__ */ new WeakMap();
|
|
21190
|
+
|
|
21174
21191
|
// packages/safe-js/src/interp/promise.ts
|
|
21175
21192
|
var promiseConstructors = /* @__PURE__ */ new WeakSet();
|
|
21176
|
-
var promiseResolvingFunctions = /* @__PURE__ */ new WeakSet();
|
|
21177
21193
|
var intrinsicPromiseThenMethods = /* @__PURE__ */ new WeakSet();
|
|
21178
21194
|
var intrinsicPromiseConstructors = /* @__PURE__ */ new WeakMap();
|
|
21179
21195
|
var promisePrototypes2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -21201,10 +21217,10 @@ function createPromiseGlobals(options) {
|
|
|
21201
21217
|
);
|
|
21202
21218
|
if (typeof targetPrototype === "object" && targetPrototype !== null && targetPrototype !== prototype)
|
|
21203
21219
|
setSandboxPrototype(pending, targetPrototype, options.budget);
|
|
21204
|
-
|
|
21220
|
+
const resolverState = { promise: pending, settled: false };
|
|
21205
21221
|
const settle = (state, value) => {
|
|
21206
|
-
if (settled) return;
|
|
21207
|
-
settled = true;
|
|
21222
|
+
if (resolverState.settled) return;
|
|
21223
|
+
resolverState.settled = true;
|
|
21208
21224
|
try {
|
|
21209
21225
|
if (state === "rejected") {
|
|
21210
21226
|
reject(budgetSandboxValue2(value, options.budget));
|
|
@@ -21237,7 +21253,7 @@ function createPromiseGlobals(options) {
|
|
|
21237
21253
|
return void 0;
|
|
21238
21254
|
}
|
|
21239
21255
|
});
|
|
21240
|
-
promiseResolvingFunctions.
|
|
21256
|
+
promiseResolvingFunctions.set(resolver, resolverState);
|
|
21241
21257
|
return resolver;
|
|
21242
21258
|
});
|
|
21243
21259
|
const result = executor.call(resolvers, { stack: context?.stack ?? [], thisValue: void 0 });
|
|
@@ -22242,6 +22258,12 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22242
22258
|
|
|
22243
22259
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22244
22260
|
function captureGuestHeapNode(value, encode) {
|
|
22261
|
+
const resolver = isSandboxClosure(value) ? promiseResolvingFunctions.get(value) : void 0;
|
|
22262
|
+
if (resolver !== void 0) {
|
|
22263
|
+
const settlement = promiseStates.get(resolver.promise);
|
|
22264
|
+
if (!resolver.settled || settlement === void 0 || settlement.status === "pending") return void 0;
|
|
22265
|
+
return { kind: "promise-resolver", promise: encode(resolver.promise), state: captureObjectState(value, encode) };
|
|
22266
|
+
}
|
|
22245
22267
|
if (isSandboxPromise(value)) {
|
|
22246
22268
|
const settlement = promiseStates.get(value);
|
|
22247
22269
|
if (settlement !== void 0 && settlement.status !== "pending")
|
|
@@ -27691,7 +27713,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27691
27713
|
createRawJson(node.text);
|
|
27692
27714
|
return true;
|
|
27693
27715
|
}
|
|
27694
|
-
if (!["intrinsic", "bound-function", "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;
|
|
27716
|
+
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;
|
|
27695
27717
|
const reference = (value, kinds) => {
|
|
27696
27718
|
const ref = record3(value);
|
|
27697
27719
|
fields(ref, ["kind", "id"]);
|
|
@@ -27702,7 +27724,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27702
27724
|
};
|
|
27703
27725
|
const callable = (value) => {
|
|
27704
27726
|
if (absent(value)) return;
|
|
27705
|
-
const target = reference(value, ["intrinsic", "bound-function", "guest-function", "guest-class"]);
|
|
27727
|
+
const target = reference(value, ["intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27706
27728
|
if (target.kind === "intrinsic" && intrinsicCatalogue().get(String(target.id)) !== true)
|
|
27707
27729
|
throw new TypeError("Guest accessor reference is not callable.");
|
|
27708
27730
|
};
|
|
@@ -27772,7 +27794,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27772
27794
|
});
|
|
27773
27795
|
return false;
|
|
27774
27796
|
}
|
|
27775
|
-
if (node.kind === "
|
|
27797
|
+
if (node.kind === "promise-resolver") {
|
|
27798
|
+
fields(node, ["kind", "promise", "state"]);
|
|
27799
|
+
reference(node.promise, ["guest-promise"]);
|
|
27800
|
+
state(node.state);
|
|
27801
|
+
} else if (node.kind === "guest-promise") {
|
|
27776
27802
|
fields(node, ["kind", "status", "value", "state"]);
|
|
27777
27803
|
if (node.status !== "fulfilled" && node.status !== "rejected") throw new TypeError("Invalid guest promise settlement.");
|
|
27778
27804
|
if (node.status === "fulfilled" && node.value !== null && typeof node.value === "object" && record3(node.value).kind === "ref" && reference(node.value) === node)
|
|
@@ -44989,4 +45015,4 @@ export {
|
|
|
44989
45015
|
FileSnapshotBackend,
|
|
44990
45016
|
run
|
|
44991
45017
|
};
|
|
44992
|
-
//# sourceMappingURL=chunk-
|
|
45018
|
+
//# sourceMappingURL=chunk-7V4MG4KI.js.map
|