poe-code 14.0.63 → 14.0.64
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/index.js +48 -24
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-KMTTD3BL.js → chunk-3EXDJDQM.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-RU2BCN4G.js → chunk-XO7B4P27.js} +48 -25
- package/packages/safe-js/dist/chunks/chunk-XO7B4P27.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/interpreter.js +4 -3
- package/packages/safe-js/dist/interp/methods/function.js +32 -15
- package/packages/safe-js/dist/interp/object-model.js +25 -11
- package/packages/safe-js/dist/chunks/chunk-RU2BCN4G.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-KMTTD3BL.js.map → chunk-3EXDJDQM.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -131748,16 +131748,24 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
|
131748
131748
|
let roots = intrinsicPrototypeRoots.get(budget);
|
|
131749
131749
|
if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
|
|
131750
131750
|
roots.add(prototype);
|
|
131751
|
-
const records = [prototype,
|
|
131752
|
-
|
|
131753
|
-
|
|
131751
|
+
const records = [prototype, constructor].map((target) => ({
|
|
131752
|
+
target,
|
|
131753
|
+
value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
|
|
131754
|
+
prototype: getSandboxPrototype(target),
|
|
131755
|
+
explicit: hasExplicitSandboxPrototype(target)
|
|
131756
|
+
})).map((record2) => ({
|
|
131757
|
+
...record2,
|
|
131758
|
+
descriptors: new Map(Object.entries(Object.getOwnPropertyDescriptors(record2.value)))
|
|
131754
131759
|
}));
|
|
131755
131760
|
const unchanged = (before, after) => before !== void 0 && after !== void 0 && Object.is(before.value, after.value) && before.writable === after.writable && before.configurable === after.configurable && before.enumerable === after.enumerable;
|
|
131756
|
-
intrinsicConstructors.set(constructor, () => records.every(({ value, descriptors }) => {
|
|
131761
|
+
intrinsicConstructors.set(constructor, () => records.every(({ target, value, descriptors, prototype: parent, explicit }) => {
|
|
131757
131762
|
const current = Object.getOwnPropertyDescriptors(value);
|
|
131758
|
-
return Object.keys(current).length === descriptors.size && Object.keys(current).every((key3) => unchanged(descriptors.get(key3), current[key3]));
|
|
131763
|
+
return getSandboxPrototype(target) === parent && hasExplicitSandboxPrototype(target) === explicit && Object.keys(current).length === descriptors.size && Object.keys(current).every((key3) => unchanged(descriptors.get(key3), current[key3]));
|
|
131759
131764
|
}));
|
|
131760
|
-
budget.setRetainedValues(prototype, () => records.flatMap(({
|
|
131765
|
+
budget.setRetainedValues(prototype, () => records.flatMap(({ target, value, descriptors, prototype: parent }) => [
|
|
131766
|
+
...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
|
|
131767
|
+
...Object.entries(Object.getOwnPropertyDescriptors(value)).flatMap(([key3, descriptor]) => unchanged(descriptors.get(key3), descriptor) ? [] : [key3, descriptor.value])
|
|
131768
|
+
]));
|
|
131761
131769
|
}
|
|
131762
131770
|
function releaseObjectPrototype(budget) {
|
|
131763
131771
|
for (const prototype of intrinsicPrototypeRoots.get(budget) ?? []) budget.setRetainedValues(prototype, void 0);
|
|
@@ -131771,7 +131779,7 @@ function getSandboxPrototype(value, budget) {
|
|
|
131771
131779
|
const prototype = getBoxedPrototype(boxedValue(value), budget);
|
|
131772
131780
|
if (prototype !== void 0 && prototype !== value) return prototype;
|
|
131773
131781
|
}
|
|
131774
|
-
return budget !== void 0 && isPrototypeRecord(value) ? intrinsicPrototypes.get(budget) ?? null : null;
|
|
131782
|
+
return budget !== void 0 && !isSandboxClosure(value) && isPrototypeRecord(value) ? intrinsicPrototypes.get(budget) ?? null : null;
|
|
131775
131783
|
}
|
|
131776
131784
|
function hasExplicitSandboxPrototype(value) {
|
|
131777
131785
|
return prototypes.has(value);
|
|
@@ -131781,14 +131789,16 @@ function getSandboxDataProperty(value, key3, budget) {
|
|
|
131781
131789
|
let depth = 0;
|
|
131782
131790
|
while (typeof current === "object" && current !== null) {
|
|
131783
131791
|
if (isGuestHostObject(current)) return getHostObjectMember(current, String(key3));
|
|
131784
|
-
if (isGuestClosure(current))
|
|
131785
|
-
|
|
131792
|
+
if (isGuestClosure(current)) {
|
|
131793
|
+
const entry = getGuestFunctionProperty(current, String(key3));
|
|
131794
|
+
if (entry !== void 0 || Object.hasOwn(current.properties ?? {}, String(key3))) return entry;
|
|
131795
|
+
} else if (isSandboxClosure(current)) {
|
|
131786
131796
|
const properties = current.properties;
|
|
131787
131797
|
return properties !== void 0 && Object.hasOwn(properties, String(key3)) ? properties[String(key3)] : void 0;
|
|
131788
131798
|
}
|
|
131789
131799
|
if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxGenerator(current))
|
|
131790
131800
|
return void 0;
|
|
131791
|
-
if (Object.hasOwn(current, String(key3))) return current[String(key3)];
|
|
131801
|
+
if (!isSandboxClosure(current) && Object.hasOwn(current, String(key3))) return current[String(key3)];
|
|
131792
131802
|
current = getSandboxPrototype(current, budget);
|
|
131793
131803
|
if (current !== null) {
|
|
131794
131804
|
budget?.visitNode();
|
|
@@ -131803,7 +131813,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
131803
131813
|
}
|
|
131804
131814
|
if (!isPrototypeRecord(value) || prototype !== null && !isPrototypeRecord(prototype)) {
|
|
131805
131815
|
throw new TypeError(
|
|
131806
|
-
"Prototype links require ordinary sandbox objects
|
|
131816
|
+
"Prototype links require ordinary sandbox objects or guest functions."
|
|
131807
131817
|
);
|
|
131808
131818
|
}
|
|
131809
131819
|
if (prototypes.has(value) && getSandboxPrototype(value, budget) === prototype) return;
|
|
@@ -131819,6 +131829,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
131819
131829
|
prototypes.set(value, prototype);
|
|
131820
131830
|
}
|
|
131821
131831
|
function isPrototypeRecord(value) {
|
|
131832
|
+
if (isGuestClosure(value)) return true;
|
|
131822
131833
|
if (isGuestHostObject(value)) return false;
|
|
131823
131834
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxSet(value))
|
|
131824
131835
|
return false;
|
|
@@ -145291,18 +145302,27 @@ var init_array = __esm({
|
|
|
145291
145302
|
|
|
145292
145303
|
// packages/safe-js/src/interp/methods/function.ts
|
|
145293
145304
|
function getFunctionMember(target, property, options) {
|
|
145294
|
-
|
|
145295
|
-
|
|
145296
|
-
|
|
145297
|
-
if (
|
|
145298
|
-
|
|
145299
|
-
|
|
145300
|
-
|
|
145301
|
-
|
|
145302
|
-
|
|
145303
|
-
|
|
145304
|
-
|
|
145305
|
+
let current = target;
|
|
145306
|
+
let depth = 0;
|
|
145307
|
+
while (current !== null) {
|
|
145308
|
+
if (isGuestClosure(current)) {
|
|
145309
|
+
const value = getGuestFunctionProperty(current, String(property));
|
|
145310
|
+
if (value !== void 0 || Object.hasOwn(current.properties ?? {}, String(property))) return value;
|
|
145311
|
+
} else if (isSandboxClosure(current)) {
|
|
145312
|
+
if (current.properties !== void 0 && Object.hasOwn(current.properties, String(property)))
|
|
145313
|
+
return current.properties[String(property)];
|
|
145314
|
+
if (property === "length") return current.length;
|
|
145315
|
+
} else if (Object.hasOwn(current, String(property))) {
|
|
145316
|
+
return current[String(property)];
|
|
145317
|
+
}
|
|
145318
|
+
if (isSandboxClosure(current) && !hasExplicitSandboxPrototype(current)) break;
|
|
145319
|
+
current = getSandboxPrototype(current, options.budget);
|
|
145320
|
+
if (current !== null) {
|
|
145321
|
+
options.budget?.visitNode();
|
|
145322
|
+
assertSandboxDataDepth(++depth);
|
|
145323
|
+
}
|
|
145305
145324
|
}
|
|
145325
|
+
if (current === null) return void 0;
|
|
145306
145326
|
if (property === "toString" && runResources.getStore()?.functionSourceText === false) return void 0;
|
|
145307
145327
|
if (!isFunctionMethodName(property)) {
|
|
145308
145328
|
return void 0;
|
|
@@ -145328,7 +145348,7 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
145328
145348
|
const thisValue = args[0];
|
|
145329
145349
|
if (methodName === "bind") {
|
|
145330
145350
|
const boundArgs = args.slice(1);
|
|
145331
|
-
|
|
145351
|
+
const bound = createSandboxClosure({
|
|
145332
145352
|
guest: true,
|
|
145333
145353
|
sandbox: true,
|
|
145334
145354
|
name: `bound ${target.name ?? ""}`,
|
|
@@ -145346,6 +145366,9 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
145346
145366
|
)
|
|
145347
145367
|
}
|
|
145348
145368
|
});
|
|
145369
|
+
if (hasExplicitSandboxPrototype(target))
|
|
145370
|
+
setSandboxPrototype(bound, getSandboxPrototype(target, options.budget), options.budget);
|
|
145371
|
+
return bound;
|
|
145349
145372
|
}
|
|
145350
145373
|
if (methodName === "call") {
|
|
145351
145374
|
return options.callClosure(target, args.slice(1), stack, thisValue);
|
|
@@ -145365,6 +145388,7 @@ var init_function = __esm({
|
|
|
145365
145388
|
"use strict";
|
|
145366
145389
|
init_values();
|
|
145367
145390
|
init_object_model();
|
|
145391
|
+
init_graph_depth();
|
|
145368
145392
|
init_function_string();
|
|
145369
145393
|
init_resources();
|
|
145370
145394
|
functionMethodNames = /* @__PURE__ */ new Set(["apply", "bind", "call", "toString"]);
|
|
@@ -149287,7 +149311,7 @@ function hasSandboxProperty(value, key3, context) {
|
|
|
149287
149311
|
while (typeof current === "object" && current !== null) {
|
|
149288
149312
|
if (isGuestHostObject(current)) return hasHostObjectMember(current, key3);
|
|
149289
149313
|
if (hasOwnSandboxProperty(current, key3, false)) return true;
|
|
149290
|
-
if (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current)) {
|
|
149314
|
+
if (!(isGuestClosure(current) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current))) {
|
|
149291
149315
|
return getPropertyValue(current, key3, context) !== void 0;
|
|
149292
149316
|
}
|
|
149293
149317
|
current = getSandboxPrototype(current, context.budget);
|