poe-code 14.0.7 → 14.0.9
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 +511 -125
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +3 -3
- package/packages/safe-js/dist/chunks/{chunk-BWVASPJX.js → chunk-MO3YD4ID.js} +479 -111
- package/packages/safe-js/dist/chunks/chunk-MO3YD4ID.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-ETKM3KPA.js → chunk-RXLDJ6LQ.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.d.ts +1 -1
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.d.ts +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/index.js.map +1 -1
- package/packages/safe-js/dist/interp/async.js +1 -0
- package/packages/safe-js/dist/interp/globals/object-array.d.ts +2 -2
- package/packages/safe-js/dist/interp/globals/object-array.js +32 -4
- package/packages/safe-js/dist/interp/globals/object.d.ts +4 -0
- package/packages/safe-js/dist/interp/globals/object.js +153 -0
- package/packages/safe-js/dist/interp/globals.d.ts +1 -1
- package/packages/safe-js/dist/interp/host-capabilities.d.ts +21 -1
- package/packages/safe-js/dist/interp/host-capabilities.js +191 -4
- package/packages/safe-js/dist/interp/interpreter.js +27 -9
- package/packages/safe-js/dist/interp/iteration.js +3 -0
- package/packages/safe-js/dist/interp/object-model.d.ts +3 -1
- package/packages/safe-js/dist/interp/object-model.js +39 -9
- package/packages/safe-js/dist/interp/values.d.ts +2 -0
- package/packages/safe-js/dist/interp/values.js +13 -6
- package/packages/safe-js/dist/realm.js +15 -2
- package/packages/safe-js/dist/run.js +2 -0
- package/packages/safe-js/dist/chunks/chunk-BWVASPJX.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-ETKM3KPA.js.map → chunk-RXLDJ6LQ.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -50271,8 +50271,8 @@ function assertNonNegativeInteger3(value, keyword) {
|
|
|
50271
50271
|
}
|
|
50272
50272
|
function validateSchemaObject(schema, dialect) {
|
|
50273
50273
|
if (schema.type !== void 0) {
|
|
50274
|
-
const
|
|
50275
|
-
if (
|
|
50274
|
+
const types6 = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
50275
|
+
if (types6.length === 0 || !types6.every((type) => typeof type === "string" && draftTypeSet.has(type)) || new Set(types6).size !== types6.length) {
|
|
50276
50276
|
throw new Error("type must be a JSON Schema type or a unique array of JSON Schema types.");
|
|
50277
50277
|
}
|
|
50278
50278
|
}
|
|
@@ -50991,9 +50991,9 @@ function evaluateValidationKeywords(node, schema, value, path193) {
|
|
|
50991
50991
|
if (schema.nullable === true && value === null) {
|
|
50992
50992
|
return results;
|
|
50993
50993
|
}
|
|
50994
|
-
const
|
|
50995
|
-
if (
|
|
50996
|
-
results.push(invalidResult(issue(path193,
|
|
50994
|
+
const types6 = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
|
|
50995
|
+
if (types6.length > 0 && !types6.some((type) => typeof type === "string" && typeMatches(type, value))) {
|
|
50996
|
+
results.push(invalidResult(issue(path193, types6.join(","), value, `must be ${types6.join(",")}`)));
|
|
50997
50997
|
return results;
|
|
50998
50998
|
}
|
|
50999
50999
|
if (schema.const !== void 0 && !deepEqual(schema.const, value)) {
|
|
@@ -125593,6 +125593,7 @@ var init_extensions = __esm({
|
|
|
125593
125593
|
});
|
|
125594
125594
|
|
|
125595
125595
|
// packages/safe-js/src/interp/host-capabilities.ts
|
|
125596
|
+
import { types as types2 } from "node:util";
|
|
125596
125597
|
function createGuestReference(root, owner, assertActive) {
|
|
125597
125598
|
const reference = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
125598
125599
|
guestReferences.set(reference, { root, owner, assertActive });
|
|
@@ -125613,8 +125614,48 @@ function revokeGuestReference(reference, owner) {
|
|
|
125613
125614
|
}
|
|
125614
125615
|
function createLiveHostObject(definition, controller) {
|
|
125615
125616
|
const input = readDataRecord(definition, "Host object definition");
|
|
125616
|
-
if (Object.keys(input).some((key3) =>
|
|
125617
|
+
if (Object.keys(input).some((key3) => !["properties", "methods", "indexed", "named"].includes(key3)))
|
|
125617
125618
|
throw new TypeError("Unknown host object definition field.");
|
|
125619
|
+
let indexed;
|
|
125620
|
+
if (input.indexed !== void 0) {
|
|
125621
|
+
const data = readDataRecord(input.indexed, "Indexed host capability");
|
|
125622
|
+
if (Object.keys(data).some((key3) => !["length", "get", "maxLength"].includes(key3)))
|
|
125623
|
+
throw new TypeError("Unknown indexed host capability field.");
|
|
125624
|
+
if (typeof data.length !== "function" || typeof data.get !== "function")
|
|
125625
|
+
throw new TypeError("Indexed length and get must be synchronous functions.");
|
|
125626
|
+
if (typeof data.maxLength !== "number" || !Number.isInteger(data.maxLength) || data.maxLength < 1 || data.maxLength > MAX_INDEXED_LENGTH)
|
|
125627
|
+
throw new RangeError(`Indexed maxLength must be an integer from 1 to ${MAX_INDEXED_LENGTH}.`);
|
|
125628
|
+
indexed = {
|
|
125629
|
+
length: data.length,
|
|
125630
|
+
get: data.get,
|
|
125631
|
+
maxLength: data.maxLength
|
|
125632
|
+
};
|
|
125633
|
+
}
|
|
125634
|
+
let named;
|
|
125635
|
+
if (input.named !== void 0) {
|
|
125636
|
+
const data = readDataRecord(input.named, "Named host capability");
|
|
125637
|
+
if (Object.keys(data).some(
|
|
125638
|
+
(key3) => !["keys", "get", "maxKeys", "maxKeyCodeUnits", "enumerable"].includes(key3)
|
|
125639
|
+
))
|
|
125640
|
+
throw new TypeError("Unknown named host capability field.");
|
|
125641
|
+
if (typeof data.keys !== "function" || typeof data.get !== "function")
|
|
125642
|
+
throw new TypeError("Named keys and get must be synchronous functions.");
|
|
125643
|
+
if (typeof data.maxKeys !== "number" || !Number.isInteger(data.maxKeys) || data.maxKeys < 1 || data.maxKeys > MAX_NAMED_KEYS)
|
|
125644
|
+
throw new RangeError(`Named maxKeys must be an integer from 1 to ${MAX_NAMED_KEYS}.`);
|
|
125645
|
+
if (typeof data.maxKeyCodeUnits !== "number" || !Number.isInteger(data.maxKeyCodeUnits) || data.maxKeyCodeUnits < 1 || data.maxKeyCodeUnits > MAX_NAMED_KEY_CODE_UNITS)
|
|
125646
|
+
throw new RangeError(
|
|
125647
|
+
`Named maxKeyCodeUnits must be an integer from 1 to ${MAX_NAMED_KEY_CODE_UNITS}.`
|
|
125648
|
+
);
|
|
125649
|
+
if (data.enumerable !== void 0 && typeof data.enumerable !== "boolean")
|
|
125650
|
+
throw new TypeError("Named enumerable must be a boolean.");
|
|
125651
|
+
named = {
|
|
125652
|
+
keys: data.keys,
|
|
125653
|
+
get: data.get,
|
|
125654
|
+
maxKeys: data.maxKeys,
|
|
125655
|
+
maxKeyCodeUnits: data.maxKeyCodeUnits,
|
|
125656
|
+
enumerable: data.enumerable
|
|
125657
|
+
};
|
|
125658
|
+
}
|
|
125618
125659
|
const properties = /* @__PURE__ */ new Map();
|
|
125619
125660
|
for (const [name, inputProperty] of Object.entries(
|
|
125620
125661
|
readDataRecord(input.properties ?? {}, "Host properties")
|
|
@@ -125634,6 +125675,8 @@ function createLiveHostObject(definition, controller) {
|
|
|
125634
125675
|
for (const name of [...properties.keys(), ...Object.keys(operations)]) {
|
|
125635
125676
|
if (["constructor", "prototype", "__proto__"].includes(name))
|
|
125636
125677
|
throw new TypeError(`Reserved host member '${name}'.`);
|
|
125678
|
+
if (indexed !== void 0 && (name === "length" || canonicalIndex(name) !== void 0))
|
|
125679
|
+
throw new TypeError(`Conflicting indexed host member '${name}'.`);
|
|
125637
125680
|
}
|
|
125638
125681
|
controller.assertActive();
|
|
125639
125682
|
controller.chargeWork(properties.size + Object.keys(operations).length + 1);
|
|
@@ -125645,7 +125688,7 @@ function createLiveHostObject(definition, controller) {
|
|
|
125645
125688
|
controller.method(operation)
|
|
125646
125689
|
])
|
|
125647
125690
|
);
|
|
125648
|
-
const state = { host, guest, controller, properties, methods };
|
|
125691
|
+
const state = { host, guest, controller, properties, methods, indexed, named };
|
|
125649
125692
|
hostObjects.set(host, state);
|
|
125650
125693
|
guestObjects.set(guest, state);
|
|
125651
125694
|
return host;
|
|
@@ -125702,15 +125745,29 @@ function revokeHostObject(value, owner) {
|
|
|
125702
125745
|
throw new TypeError("Foreign host object.");
|
|
125703
125746
|
state.properties.clear();
|
|
125704
125747
|
state.methods.clear();
|
|
125748
|
+
state.indexed = void 0;
|
|
125749
|
+
state.named = void 0;
|
|
125705
125750
|
}
|
|
125706
125751
|
function getHostObjectMember(value, key3) {
|
|
125707
125752
|
const state = guestObjects.get(value);
|
|
125708
125753
|
state.controller.assertActive();
|
|
125709
125754
|
state.controller.chargeWork();
|
|
125755
|
+
if (state.indexed !== void 0) {
|
|
125756
|
+
if (key3 === "length") return indexedLength(state);
|
|
125757
|
+
const index = canonicalIndex(key3);
|
|
125758
|
+
if (index !== void 0) {
|
|
125759
|
+
if (index >= state.indexed.maxLength || index >= indexedLength(state)) return void 0;
|
|
125760
|
+
return state.controller.read(() => state.indexed.get(index));
|
|
125761
|
+
}
|
|
125762
|
+
}
|
|
125710
125763
|
const property = state.properties.get(key3);
|
|
125711
125764
|
if (property !== void 0)
|
|
125712
125765
|
return property.get === void 0 ? void 0 : state.controller.read(property.get);
|
|
125713
|
-
|
|
125766
|
+
const method = state.methods.get(key3);
|
|
125767
|
+
if (method !== void 0) return method;
|
|
125768
|
+
if (state.named !== void 0 && namedKeys2(state).includes(key3))
|
|
125769
|
+
return state.controller.read(() => state.named.get(key3));
|
|
125770
|
+
return void 0;
|
|
125714
125771
|
}
|
|
125715
125772
|
function setHostObjectMember(value, key3, entry) {
|
|
125716
125773
|
const state = guestObjects.get(value);
|
|
@@ -125723,13 +125780,115 @@ function setHostObjectMember(value, key3, entry) {
|
|
|
125723
125780
|
function getHostObjectKeys(value) {
|
|
125724
125781
|
const state = guestObjects.get(value);
|
|
125725
125782
|
state.controller.assertActive();
|
|
125726
|
-
|
|
125783
|
+
const length = state.indexed === void 0 ? 0 : indexedLength(state);
|
|
125784
|
+
const names = state.named === void 0 || state.named.enumerable === false ? [] : namedKeys2(state).filter(
|
|
125785
|
+
(key3) => !state.properties.has(key3) && !state.methods.has(key3) && !(state.indexed !== void 0 && (key3 === "length" || canonicalIndex(key3) !== void 0))
|
|
125786
|
+
);
|
|
125787
|
+
const size = length + state.properties.size + state.methods.size + names.length;
|
|
125788
|
+
state.controller.checkLength(size);
|
|
125789
|
+
state.controller.chargeWork(size + 1);
|
|
125790
|
+
return [
|
|
125791
|
+
...Array.from({ length }, (_entry, index) => String(index)),
|
|
125792
|
+
...state.properties.keys(),
|
|
125793
|
+
...state.methods.keys(),
|
|
125794
|
+
...names
|
|
125795
|
+
];
|
|
125796
|
+
}
|
|
125797
|
+
function hasHostObjectMember(value, key3, enumerableOnly = false) {
|
|
125798
|
+
const state = guestObjects.get(value);
|
|
125799
|
+
state.controller.assertActive();
|
|
125800
|
+
state.controller.chargeWork();
|
|
125801
|
+
if (state.indexed !== void 0) {
|
|
125802
|
+
if (key3 === "length") return !enumerableOnly;
|
|
125803
|
+
const index = canonicalIndex(key3);
|
|
125804
|
+
if (index !== void 0) return index < state.indexed.maxLength && index < indexedLength(state);
|
|
125805
|
+
}
|
|
125806
|
+
if (state.properties.has(key3) || state.methods.has(key3)) return true;
|
|
125807
|
+
return state.named !== void 0 && !(enumerableOnly && state.named.enumerable === false) && namedKeys2(state).includes(key3);
|
|
125808
|
+
}
|
|
125809
|
+
function measureHostObjectData(value) {
|
|
125810
|
+
const state = guestObjects.get(value);
|
|
125811
|
+
let size = state.indexed === void 0 ? 0 : 16;
|
|
125812
|
+
if (state.named !== void 0) size += 24;
|
|
125813
|
+
for (const key3 of state.properties.keys()) size += key3.length + 1;
|
|
125814
|
+
for (const key3 of state.methods.keys()) size += key3.length + 1;
|
|
125815
|
+
return size;
|
|
125816
|
+
}
|
|
125817
|
+
function getHostObjectIterator(value) {
|
|
125818
|
+
const state = guestObjects.get(value);
|
|
125819
|
+
state.controller.assertActive();
|
|
125820
|
+
if (state.indexed === void 0) return void 0;
|
|
125821
|
+
let index = 0;
|
|
125822
|
+
let exhausted = false;
|
|
125823
|
+
return {
|
|
125824
|
+
next: () => {
|
|
125825
|
+
state.controller.assertActive();
|
|
125826
|
+
state.controller.chargeWork();
|
|
125827
|
+
if (exhausted) return { done: true, value: void 0 };
|
|
125828
|
+
if (index >= indexedLength(state)) {
|
|
125829
|
+
exhausted = true;
|
|
125830
|
+
return { done: true, value: void 0 };
|
|
125831
|
+
}
|
|
125832
|
+
const position = index++;
|
|
125833
|
+
return { done: false, value: state.controller.read(() => state.indexed.get(position)) };
|
|
125834
|
+
}
|
|
125835
|
+
};
|
|
125836
|
+
}
|
|
125837
|
+
function indexedLength(state) {
|
|
125838
|
+
state.controller.chargeWork();
|
|
125839
|
+
const length = state.controller.read(state.indexed.length);
|
|
125840
|
+
if (typeof length !== "number" || !Number.isInteger(length) || length < 0 || length > state.indexed.maxLength)
|
|
125841
|
+
throw new RangeError("Indexed length must be a non-negative integer within maxLength.");
|
|
125842
|
+
state.controller.checkLength(length);
|
|
125843
|
+
return length;
|
|
125844
|
+
}
|
|
125845
|
+
function canonicalIndex(key3) {
|
|
125846
|
+
const index = Number(key3);
|
|
125847
|
+
return Number.isInteger(index) && index >= 0 && index < 4294967295 && String(index) === key3 ? index : void 0;
|
|
125848
|
+
}
|
|
125849
|
+
function namedKeys2(state) {
|
|
125850
|
+
const named = state.named;
|
|
125851
|
+
return state.controller.read(named.keys, (value) => {
|
|
125852
|
+
if (!Array.isArray(value) || types2.isProxy(value))
|
|
125853
|
+
throw new TypeError("Named keys must be a dense own-data array of strings, not a proxy.");
|
|
125854
|
+
const length = Object.getOwnPropertyDescriptor(value, "length").value;
|
|
125855
|
+
if (length > named.maxKeys) throw new RangeError("Named keys exceed maxKeys.");
|
|
125856
|
+
state.controller.checkLength(length);
|
|
125857
|
+
state.controller.chargeWork(length + 1);
|
|
125858
|
+
if (Reflect.ownKeys(value).length !== length + 1)
|
|
125859
|
+
throw new TypeError("Named keys must contain only dense own-data indices and length.");
|
|
125860
|
+
const result = [];
|
|
125861
|
+
const seen = /* @__PURE__ */ new Set();
|
|
125862
|
+
let units = 0;
|
|
125863
|
+
for (let index = 0; index < length; index++) {
|
|
125864
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
125865
|
+
if (descriptor === void 0 || !("value" in descriptor) || typeof descriptor.value !== "string")
|
|
125866
|
+
throw new TypeError(
|
|
125867
|
+
"Named keys require dense own string data, not accessors or sparse arrays."
|
|
125868
|
+
);
|
|
125869
|
+
const key3 = descriptor.value;
|
|
125870
|
+
units += key3.length;
|
|
125871
|
+
if (units > named.maxKeyCodeUnits)
|
|
125872
|
+
throw new RangeError("Named keys exceed maximum UTF-16 code units.");
|
|
125873
|
+
state.controller.chargeWork(key3.length);
|
|
125874
|
+
if (seen.has(key3)) throw new TypeError("Named keys must be distinct.");
|
|
125875
|
+
if (["constructor", "prototype", "__proto__"].includes(key3))
|
|
125876
|
+
throw new TypeError(`Reserved named host member '${key3}'.`);
|
|
125877
|
+
seen.add(key3);
|
|
125878
|
+
result.push(key3);
|
|
125879
|
+
}
|
|
125880
|
+
state.controller.checkTemporaryDataSize(1 + length + units);
|
|
125881
|
+
return result;
|
|
125882
|
+
});
|
|
125727
125883
|
}
|
|
125728
|
-
var hostObjects, guestObjects, guestCallbacks, guestReferences;
|
|
125884
|
+
var MAX_INDEXED_LENGTH, MAX_NAMED_KEYS, MAX_NAMED_KEY_CODE_UNITS, hostObjects, guestObjects, guestCallbacks, guestReferences;
|
|
125729
125885
|
var init_host_capabilities = __esm({
|
|
125730
125886
|
"packages/safe-js/src/interp/host-capabilities.ts"() {
|
|
125731
125887
|
"use strict";
|
|
125732
125888
|
init_extensions();
|
|
125889
|
+
MAX_INDEXED_LENGTH = 65536;
|
|
125890
|
+
MAX_NAMED_KEYS = 65536;
|
|
125891
|
+
MAX_NAMED_KEY_CODE_UNITS = 1048576;
|
|
125733
125892
|
hostObjects = /* @__PURE__ */ new WeakMap();
|
|
125734
125893
|
guestObjects = /* @__PURE__ */ new WeakMap();
|
|
125735
125894
|
guestCallbacks = /* @__PURE__ */ new WeakMap();
|
|
@@ -125831,7 +125990,7 @@ var init_otel2 = __esm({
|
|
|
125831
125990
|
});
|
|
125832
125991
|
|
|
125833
125992
|
// packages/safe-js/src/interp/date.ts
|
|
125834
|
-
import { types as
|
|
125993
|
+
import { types as types3 } from "node:util";
|
|
125835
125994
|
function isSandboxDate(value) {
|
|
125836
125995
|
return typeof value === "object" && value !== null && dates.has(value);
|
|
125837
125996
|
}
|
|
@@ -125844,7 +126003,7 @@ function dateTime(value) {
|
|
|
125844
126003
|
return Reflect.apply(readTime, value, []);
|
|
125845
126004
|
}
|
|
125846
126005
|
function copyNativeDate(value) {
|
|
125847
|
-
if (!
|
|
126006
|
+
if (!types3.isDate(value)) return void 0;
|
|
125848
126007
|
if (Object.getPrototypeOf(value) !== NativeDate.prototype || Reflect.ownKeys(value).length > 0)
|
|
125849
126008
|
throw new TypeError("Date subclasses and own properties are not supported.");
|
|
125850
126009
|
return createSandboxDate(dateTime(value));
|
|
@@ -128073,6 +128232,7 @@ var init_running_state = __esm({
|
|
|
128073
128232
|
|
|
128074
128233
|
// packages/safe-js/src/interp/iteration.ts
|
|
128075
128234
|
function getSandboxIterator(value) {
|
|
128235
|
+
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
128076
128236
|
if (isFloat32Array(value)) {
|
|
128077
128237
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
128078
128238
|
}
|
|
@@ -128174,6 +128334,7 @@ var init_iteration = __esm({
|
|
|
128174
128334
|
init_values();
|
|
128175
128335
|
init_running_state();
|
|
128176
128336
|
init_float32();
|
|
128337
|
+
init_host_capabilities();
|
|
128177
128338
|
}
|
|
128178
128339
|
});
|
|
128179
128340
|
|
|
@@ -129228,6 +129389,7 @@ function createSandboxClosure(input) {
|
|
|
129228
129389
|
if (input.sandbox === true) {
|
|
129229
129390
|
Object.defineProperty(closure, "sandbox", { value: true });
|
|
129230
129391
|
}
|
|
129392
|
+
if (input.generator === true) Object.defineProperty(closure, "generator", { value: true });
|
|
129231
129393
|
if (input.length !== void 0) {
|
|
129232
129394
|
Object.defineProperty(closure, "length", { value: input.length });
|
|
129233
129395
|
}
|
|
@@ -129260,7 +129422,13 @@ function createSandboxClosure(input) {
|
|
|
129260
129422
|
return Object.freeze(closure);
|
|
129261
129423
|
}
|
|
129262
129424
|
function ownEnumerableSandboxEntries(value) {
|
|
129263
|
-
if (isGuestHostObject(value))
|
|
129425
|
+
if (isGuestHostObject(value)) {
|
|
129426
|
+
const entries = [];
|
|
129427
|
+
for (const key3 of getHostObjectKeys(value)) {
|
|
129428
|
+
if (hasHostObjectMember(value, key3, true)) entries.push([key3, getHostObjectMember(value, key3)]);
|
|
129429
|
+
}
|
|
129430
|
+
return entries;
|
|
129431
|
+
}
|
|
129264
129432
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
129265
129433
|
if (isGuestClosure(value)) return Object.entries(value.properties ?? {});
|
|
129266
129434
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
@@ -129418,7 +129586,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
129418
129586
|
return;
|
|
129419
129587
|
}
|
|
129420
129588
|
if (isGuestHostObject(value)) {
|
|
129421
|
-
|
|
129589
|
+
usage += measureHostObjectData(value);
|
|
129422
129590
|
return;
|
|
129423
129591
|
}
|
|
129424
129592
|
const prototype = getSandboxPrototype(value);
|
|
@@ -129515,7 +129683,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
129515
129683
|
function reconcileCompiledValues(budget, values, compilation, parent, escaping = []) {
|
|
129516
129684
|
while (parent?.closed) parent = parent.parent;
|
|
129517
129685
|
const included = /* @__PURE__ */ new Set();
|
|
129518
|
-
const usage = measureSandboxData(values, { compileTickets: included });
|
|
129686
|
+
const usage = measureSandboxData([...values, ...budget.retainedValues()], { compileTickets: included });
|
|
129519
129687
|
const kept = /* @__PURE__ */ new Set();
|
|
129520
129688
|
if (parent !== void 0) measureSandboxData(escaping, { compileTickets: kept });
|
|
129521
129689
|
const transferred = /* @__PURE__ */ new Set();
|
|
@@ -130121,27 +130289,49 @@ function getGuestFunctionProperty(closure, key3) {
|
|
|
130121
130289
|
}
|
|
130122
130290
|
return properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key3)?.value;
|
|
130123
130291
|
}
|
|
130124
|
-
function
|
|
130125
|
-
|
|
130292
|
+
function installObjectPrototype(budget, prototype, constructor) {
|
|
130293
|
+
prototypes.set(prototype, null);
|
|
130294
|
+
intrinsicPrototypes.set(budget, prototype);
|
|
130295
|
+
const records = [prototype, materializeFunctionProperties(constructor)].map((value) => ({
|
|
130296
|
+
value,
|
|
130297
|
+
descriptors: new Map(Object.entries(Object.getOwnPropertyDescriptors(value)))
|
|
130298
|
+
}));
|
|
130299
|
+
const unchanged = (before, after) => before !== void 0 && after !== void 0 && before.value === after.value && before.writable === after.writable && before.configurable === after.configurable && before.enumerable === after.enumerable;
|
|
130300
|
+
intrinsicConstructors.set(constructor, () => records.every(({ value, descriptors }) => {
|
|
130301
|
+
const current = Object.getOwnPropertyDescriptors(value);
|
|
130302
|
+
return Object.keys(current).length === descriptors.size && Object.keys(current).every((key3) => unchanged(descriptors.get(key3), current[key3]));
|
|
130303
|
+
}));
|
|
130304
|
+
budget.setRetainedValues(prototype, () => records.flatMap(({ value, descriptors }) => Object.entries(Object.getOwnPropertyDescriptors(value)).flatMap(([key3, descriptor]) => unchanged(descriptors.get(key3), descriptor) ? [] : [key3, descriptor.value])));
|
|
130305
|
+
}
|
|
130306
|
+
function releaseObjectPrototype(budget) {
|
|
130307
|
+
const prototype = intrinsicPrototypes.get(budget);
|
|
130308
|
+
if (prototype !== void 0) budget.setRetainedValues(prototype, void 0);
|
|
130309
|
+
intrinsicPrototypes.delete(budget);
|
|
130310
|
+
}
|
|
130311
|
+
function getSandboxPrototype(value, budget) {
|
|
130312
|
+
if (prototypes.has(value)) return prototypes.get(value) ?? null;
|
|
130313
|
+
return budget !== void 0 && isPrototypeRecord(value) ? intrinsicPrototypes.get(budget) ?? null : null;
|
|
130126
130314
|
}
|
|
130127
130315
|
function setSandboxPrototype(value, prototype, budget) {
|
|
130316
|
+
if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
|
|
130317
|
+
throw new TypeError("Object.prototype has an immutable null prototype.");
|
|
130318
|
+
}
|
|
130128
130319
|
if (!isPrototypeRecord(value) || prototype !== null && !isPrototypeRecord(prototype)) {
|
|
130129
130320
|
throw new TypeError(
|
|
130130
130321
|
"Prototype links require ordinary sandbox objects; callable and exotic prototype chains are not supported."
|
|
130131
130322
|
);
|
|
130132
130323
|
}
|
|
130133
|
-
if (getSandboxPrototype(value) === prototype) return;
|
|
130324
|
+
if (prototypes.has(value) && getSandboxPrototype(value, budget) === prototype) return;
|
|
130134
130325
|
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : value)) {
|
|
130135
130326
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
130136
130327
|
}
|
|
130137
130328
|
let depth = 0;
|
|
130138
|
-
for (let current = prototype; current !== null; current = getSandboxPrototype(current)) {
|
|
130329
|
+
for (let current = prototype; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
130139
130330
|
budget?.visitNode();
|
|
130140
130331
|
assertSandboxDataDepth(depth++);
|
|
130141
130332
|
if (current === value) throw new TypeError("Cyclic prototype value.");
|
|
130142
130333
|
}
|
|
130143
|
-
|
|
130144
|
-
else prototypes.set(value, prototype);
|
|
130334
|
+
prototypes.set(value, prototype);
|
|
130145
130335
|
}
|
|
130146
130336
|
function isPrototypeRecord(value) {
|
|
130147
130337
|
if (isGuestHostObject(value)) return false;
|
|
@@ -130157,13 +130347,15 @@ function hasManagedDescriptors(value) {
|
|
|
130157
130347
|
return descriptorObjects.has(value);
|
|
130158
130348
|
}
|
|
130159
130349
|
function hasGuestObjectState(value) {
|
|
130350
|
+
const intrinsicUnchanged = intrinsicConstructors.get(value);
|
|
130351
|
+
if (intrinsicUnchanged !== void 0) return !intrinsicUnchanged();
|
|
130160
130352
|
if (isLiveCapability(value)) return true;
|
|
130161
130353
|
if (functionProperties.has(value) || prototypes.has(value)) return true;
|
|
130162
130354
|
return descriptorObjects.has(value) && Object.values(Object.getOwnPropertyDescriptors(value)).some(
|
|
130163
130355
|
(descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
|
|
130164
130356
|
);
|
|
130165
130357
|
}
|
|
130166
|
-
var guestClosures, functionProperties, prototypes, descriptorObjects;
|
|
130358
|
+
var guestClosures, functionProperties, prototypes, intrinsicPrototypes, intrinsicConstructors, descriptorObjects;
|
|
130167
130359
|
var init_object_model = __esm({
|
|
130168
130360
|
"packages/safe-js/src/interp/object-model.ts"() {
|
|
130169
130361
|
"use strict";
|
|
@@ -130173,6 +130365,8 @@ var init_object_model = __esm({
|
|
|
130173
130365
|
guestClosures = /* @__PURE__ */ new WeakSet();
|
|
130174
130366
|
functionProperties = /* @__PURE__ */ new WeakMap();
|
|
130175
130367
|
prototypes = /* @__PURE__ */ new WeakMap();
|
|
130368
|
+
intrinsicPrototypes = /* @__PURE__ */ new WeakMap();
|
|
130369
|
+
intrinsicConstructors = /* @__PURE__ */ new WeakMap();
|
|
130176
130370
|
descriptorObjects = /* @__PURE__ */ new WeakSet();
|
|
130177
130371
|
}
|
|
130178
130372
|
});
|
|
@@ -130442,7 +130636,7 @@ var init_dump_format = __esm({
|
|
|
130442
130636
|
});
|
|
130443
130637
|
|
|
130444
130638
|
// packages/safe-js/src/snapshot/validation.ts
|
|
130445
|
-
import { types as
|
|
130639
|
+
import { types as types4 } from "node:util";
|
|
130446
130640
|
function validateSnapshotData(value) {
|
|
130447
130641
|
validateGenericValue(value, "$", 0, {
|
|
130448
130642
|
allowFunctions: false,
|
|
@@ -130740,7 +130934,7 @@ function validateGenericValue(value, path193, depth, state) {
|
|
|
130740
130934
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
|
|
130741
130935
|
fail2("invalidState", path193, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
130742
130936
|
}
|
|
130743
|
-
if (state.dataPropertiesOnly &&
|
|
130937
|
+
if (state.dataPropertiesOnly && types4.isProxy(value)) {
|
|
130744
130938
|
fail2("invalidType", path193, "proxy objects are not snapshot data");
|
|
130745
130939
|
}
|
|
130746
130940
|
if (depth > state.limits.maxDepth)
|
|
@@ -142769,6 +142963,95 @@ var init_var_hoist = __esm({
|
|
|
142769
142963
|
}
|
|
142770
142964
|
});
|
|
142771
142965
|
|
|
142966
|
+
// packages/safe-js/src/interp/string-coercion.ts
|
|
142967
|
+
function sandboxString(value, budget, context, joining = /* @__PURE__ */ new Set()) {
|
|
142968
|
+
if (value === null || typeof value !== "object") {
|
|
142969
|
+
if (typeof value === "function") throw new TypeError("Expected a sandbox value.");
|
|
142970
|
+
return budget.allocateString(String(value));
|
|
142971
|
+
}
|
|
142972
|
+
return stringifyObject(value, budget, context, joining);
|
|
142973
|
+
}
|
|
142974
|
+
async function stringifyObject(value, budget, context, joining) {
|
|
142975
|
+
const leaveCall = budget.enterCall();
|
|
142976
|
+
try {
|
|
142977
|
+
budget.visitNode();
|
|
142978
|
+
for (const name of ["toString", "valueOf"]) {
|
|
142979
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
142980
|
+
let result;
|
|
142981
|
+
if (descriptor === void 0) {
|
|
142982
|
+
if (name === "valueOf") continue;
|
|
142983
|
+
result = await defaultToString(value, budget, context, joining);
|
|
142984
|
+
} else {
|
|
142985
|
+
const hook = ownDataValue(value, name);
|
|
142986
|
+
if (!isSandboxClosure(hook)) continue;
|
|
142987
|
+
if (context?.invokeClosure === void 0) {
|
|
142988
|
+
throw new TypeError("String hooks require a sandbox call context.");
|
|
142989
|
+
}
|
|
142990
|
+
result = await context.invokeClosure(hook, [], value);
|
|
142991
|
+
}
|
|
142992
|
+
if (result === null || typeof result !== "object") {
|
|
142993
|
+
return sandboxString(result, budget, context, joining);
|
|
142994
|
+
}
|
|
142995
|
+
}
|
|
142996
|
+
throw new TypeError("Cannot convert object to primitive value");
|
|
142997
|
+
} finally {
|
|
142998
|
+
leaveCall();
|
|
142999
|
+
}
|
|
143000
|
+
}
|
|
143001
|
+
async function defaultToString(value, budget, context, joining) {
|
|
143002
|
+
if (isSandboxDate(value)) return budget.allocateString(dateString(value));
|
|
143003
|
+
if (Array.isArray(value) || isFloat32Array(value)) {
|
|
143004
|
+
if (Object.hasOwn(value, "join")) {
|
|
143005
|
+
const join21 = ownDataValue(value, "join");
|
|
143006
|
+
if (!isSandboxClosure(join21))
|
|
143007
|
+
return isFloat32Array(value) ? "[object Float32Array]" : "[object Array]";
|
|
143008
|
+
if (context?.invokeClosure === void 0) {
|
|
143009
|
+
throw new TypeError("String hooks require a sandbox call context.");
|
|
143010
|
+
}
|
|
143011
|
+
return context.invokeClosure(join21, [], value);
|
|
143012
|
+
}
|
|
143013
|
+
if (joining.has(value)) return "";
|
|
143014
|
+
joining.add(value);
|
|
143015
|
+
try {
|
|
143016
|
+
const length = isFloat32Array(value) ? float32Storage(value).length : value.length;
|
|
143017
|
+
let text5 = "";
|
|
143018
|
+
for (let index = 0; index < length; index++) {
|
|
143019
|
+
budget.visitNode();
|
|
143020
|
+
const element = ownDataValue(value, String(index));
|
|
143021
|
+
const part = element === null || element === void 0 ? "" : await sandboxString(element, budget, context, joining);
|
|
143022
|
+
text5 = budget.allocateString(text5 + (index === 0 ? "" : ",") + part);
|
|
143023
|
+
}
|
|
143024
|
+
return text5;
|
|
143025
|
+
} finally {
|
|
143026
|
+
joining.delete(value);
|
|
143027
|
+
}
|
|
143028
|
+
}
|
|
143029
|
+
if (sandboxErrorTypes.has(value)) {
|
|
143030
|
+
const nameValue = ownDataValue(value, "name");
|
|
143031
|
+
const name = nameValue === void 0 ? "Error" : await sandboxString(nameValue, budget, context, joining);
|
|
143032
|
+
const messageValue2 = ownDataValue(value, "message");
|
|
143033
|
+
const message2 = messageValue2 === void 0 ? "" : await sandboxString(messageValue2, budget, context, joining);
|
|
143034
|
+
return name === "" ? message2 : message2 === "" ? name : `${name}: ${message2}`;
|
|
143035
|
+
}
|
|
143036
|
+
return isSandboxPromise(value) ? "[object Promise]" : "[object Object]";
|
|
143037
|
+
}
|
|
143038
|
+
function ownDataValue(value, name) {
|
|
143039
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
143040
|
+
if (descriptor !== void 0 && !Object.hasOwn(descriptor, "value")) {
|
|
143041
|
+
throw new TypeError("String conversion requires sandbox data properties.");
|
|
143042
|
+
}
|
|
143043
|
+
return descriptor?.value;
|
|
143044
|
+
}
|
|
143045
|
+
var init_string_coercion = __esm({
|
|
143046
|
+
"packages/safe-js/src/interp/string-coercion.ts"() {
|
|
143047
|
+
"use strict";
|
|
143048
|
+
init_shape();
|
|
143049
|
+
init_date();
|
|
143050
|
+
init_float32();
|
|
143051
|
+
init_values();
|
|
143052
|
+
}
|
|
143053
|
+
});
|
|
143054
|
+
|
|
142772
143055
|
// packages/safe-js/src/interp/methods/array.ts
|
|
142773
143056
|
function getArrayMember(value, property, options) {
|
|
142774
143057
|
const index = getArrayIndex(property);
|
|
@@ -145531,6 +145814,9 @@ async function evaluateObjectExpression(node, context) {
|
|
|
145531
145814
|
return value;
|
|
145532
145815
|
}
|
|
145533
145816
|
if (isObjectPrototypeSetterProperty(property, key3.value)) {
|
|
145817
|
+
if (value.value === null || typeof value.value === "object") {
|
|
145818
|
+
setSandboxPrototype(object, value.value, context.budget);
|
|
145819
|
+
}
|
|
145534
145820
|
continue;
|
|
145535
145821
|
}
|
|
145536
145822
|
defineSandboxProperty(object, String(key3.value), value.value);
|
|
@@ -145652,7 +145938,11 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
145652
145938
|
if (right.kind !== "normal") {
|
|
145653
145939
|
return right;
|
|
145654
145940
|
}
|
|
145655
|
-
const value =
|
|
145941
|
+
const value = node.operator === "in" && isGuestHostObject(right.value) ? hasHostObjectMember(right.value, await sandboxString(left.value, context.budget, {
|
|
145942
|
+
stack: context.callStack,
|
|
145943
|
+
thisValue: void 0,
|
|
145944
|
+
invokeClosure: (closure, args, thisValue) => invokeSandboxClosure(closure, args, context, context.callStack, void 0, thisValue)
|
|
145945
|
+
})) : applyBinaryOperator(node, left.value, right.value, context);
|
|
145656
145946
|
return {
|
|
145657
145947
|
kind: "normal",
|
|
145658
145948
|
hasValue: true,
|
|
@@ -146335,7 +146625,7 @@ function forInKeys(object, budget) {
|
|
|
146335
146625
|
const keys = [];
|
|
146336
146626
|
const seen = /* @__PURE__ */ new Set();
|
|
146337
146627
|
let depth = 0;
|
|
146338
|
-
for (let current = object; current !== null; current = getSandboxPrototype(current)) {
|
|
146628
|
+
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
146339
146629
|
if (depth > 0) budget.visitNode();
|
|
146340
146630
|
assertSandboxDataDepth(depth++);
|
|
146341
146631
|
const properties = isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : current;
|
|
@@ -146349,9 +146639,9 @@ function forInKeys(object, budget) {
|
|
|
146349
146639
|
return keys;
|
|
146350
146640
|
}
|
|
146351
146641
|
function hasForInProperty(object, key3, budget) {
|
|
146352
|
-
if (isGuestHostObject(object)) return
|
|
146642
|
+
if (isGuestHostObject(object)) return hasHostObjectMember(object, key3, true);
|
|
146353
146643
|
let depth = 0;
|
|
146354
|
-
for (let current = object; current !== null; current = getSandboxPrototype(current)) {
|
|
146644
|
+
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
146355
146645
|
if (depth > 0) budget.visitNode();
|
|
146356
146646
|
assertSandboxDataDepth(depth++);
|
|
146357
146647
|
const properties = isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : current;
|
|
@@ -147352,7 +147642,7 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
147352
147642
|
throw new TypeError("Function has a non-object prototype in instanceof check.");
|
|
147353
147643
|
}
|
|
147354
147644
|
let depth = 0;
|
|
147355
|
-
for (let current = getSandboxPrototype(left); current !== null; current = getSandboxPrototype(current)) {
|
|
147645
|
+
for (let current = getSandboxPrototype(left, context.budget); current !== null; current = getSandboxPrototype(current, context.budget)) {
|
|
147356
147646
|
context.budget.visitNode();
|
|
147357
147647
|
assertSandboxDataDepth(depth++);
|
|
147358
147648
|
if (current === prototype) return true;
|
|
@@ -147566,7 +147856,7 @@ function getMemberValue(target, property, context) {
|
|
|
147566
147856
|
return getPropertyValue(current, property, context);
|
|
147567
147857
|
}
|
|
147568
147858
|
if (Object.hasOwn(current, String(property))) return current[String(property)];
|
|
147569
|
-
current = getSandboxPrototype(current);
|
|
147859
|
+
current = getSandboxPrototype(current, context.budget);
|
|
147570
147860
|
if (current !== null) {
|
|
147571
147861
|
context.budget.visitNode();
|
|
147572
147862
|
assertSandboxDataDepth(++depth);
|
|
@@ -147616,7 +147906,7 @@ function setSandboxProperty(target, property, value, budget) {
|
|
|
147616
147906
|
} else {
|
|
147617
147907
|
if (typeof prototypeOwner === "object" && prototypeOwner !== null) {
|
|
147618
147908
|
let depth = 0;
|
|
147619
|
-
for (let prototype = getSandboxPrototype(prototypeOwner); prototype !== null; prototype = getSandboxPrototype(prototype)) {
|
|
147909
|
+
for (let prototype = getSandboxPrototype(prototypeOwner, budget); prototype !== null; prototype = getSandboxPrototype(prototype, budget)) {
|
|
147620
147910
|
budget.visitNode();
|
|
147621
147911
|
assertSandboxDataDepth(depth++);
|
|
147622
147912
|
const properties = isSandboxClosure(prototype) ? prototype.properties : prototype;
|
|
@@ -147810,6 +148100,13 @@ async function evaluateObjectSpread(node, context) {
|
|
|
147810
148100
|
value: []
|
|
147811
148101
|
};
|
|
147812
148102
|
}
|
|
148103
|
+
if (isGuestHostObject(value.value)) {
|
|
148104
|
+
const entries = [];
|
|
148105
|
+
for (const key3 of getHostObjectKeys(value.value)) {
|
|
148106
|
+
if (hasHostObjectMember(value.value, key3, true)) entries.push([key3, getHostObjectMember(value.value, key3)]);
|
|
148107
|
+
}
|
|
148108
|
+
return { ok: true, value: entries };
|
|
148109
|
+
}
|
|
147813
148110
|
if (isSandboxClosure(value.value) && !isGuestClosure(value.value) || isSandboxPromise(value.value)) {
|
|
147814
148111
|
throw new TypeError(
|
|
147815
148112
|
`Cannot spread ${describeObjectSpreadValue(value.value)} into object literal.`
|
|
@@ -147886,6 +148183,7 @@ var init_interpreter = __esm({
|
|
|
147886
148183
|
"use strict";
|
|
147887
148184
|
init_promise_replay();
|
|
147888
148185
|
init_host_capabilities();
|
|
148186
|
+
init_string_coercion();
|
|
147889
148187
|
init_promise_tracker();
|
|
147890
148188
|
init_jobs4();
|
|
147891
148189
|
init_cancel2();
|
|
@@ -148082,6 +148380,7 @@ function createInterpretedClosure(node, context, evaluateNode3) {
|
|
|
148082
148380
|
function createGeneratorClosure(node, context, evaluateNode3) {
|
|
148083
148381
|
return createSandboxClosure({
|
|
148084
148382
|
guest: true,
|
|
148383
|
+
generator: true,
|
|
148085
148384
|
sandbox: true,
|
|
148086
148385
|
length: getFunctionLength(node.params),
|
|
148087
148386
|
...node.id === void 0 ? {} : { name: node.id.name },
|
|
@@ -149412,7 +149711,7 @@ async function stringifyValue3(value, state, indent) {
|
|
|
149412
149711
|
return stringifyArray(value, state, indent);
|
|
149413
149712
|
}
|
|
149414
149713
|
if (isStringifyObject(value)) {
|
|
149415
|
-
return
|
|
149714
|
+
return stringifyObject2(value, state, indent);
|
|
149416
149715
|
}
|
|
149417
149716
|
return void 0;
|
|
149418
149717
|
}
|
|
@@ -149438,7 +149737,7 @@ ${indent}]`;
|
|
|
149438
149737
|
leaveStringifyObject(value, state);
|
|
149439
149738
|
}
|
|
149440
149739
|
}
|
|
149441
|
-
async function
|
|
149740
|
+
async function stringifyObject2(value, state, indent) {
|
|
149442
149741
|
enterStringifyObject(value, state);
|
|
149443
149742
|
try {
|
|
149444
149743
|
const nextIndent = indent + state.gap;
|
|
@@ -149789,91 +150088,143 @@ var init_misc = __esm({
|
|
|
149789
150088
|
}
|
|
149790
150089
|
});
|
|
149791
150090
|
|
|
149792
|
-
// packages/safe-js/src/interp/
|
|
149793
|
-
function
|
|
149794
|
-
|
|
149795
|
-
if (
|
|
149796
|
-
|
|
149797
|
-
|
|
149798
|
-
return stringifyObject2(value, budget, context, joining);
|
|
149799
|
-
}
|
|
149800
|
-
async function stringifyObject2(value, budget, context, joining) {
|
|
149801
|
-
const leaveCall = budget.enterCall();
|
|
149802
|
-
try {
|
|
149803
|
-
budget.visitNode();
|
|
149804
|
-
for (const name of ["toString", "valueOf"]) {
|
|
149805
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
149806
|
-
let result;
|
|
149807
|
-
if (descriptor === void 0) {
|
|
149808
|
-
if (name === "valueOf") continue;
|
|
149809
|
-
result = await defaultToString(value, budget, context, joining);
|
|
149810
|
-
} else {
|
|
149811
|
-
const hook = ownDataValue(value, name);
|
|
149812
|
-
if (!isSandboxClosure(hook)) continue;
|
|
149813
|
-
if (context?.invokeClosure === void 0) {
|
|
149814
|
-
throw new TypeError("String hooks require a sandbox call context.");
|
|
149815
|
-
}
|
|
149816
|
-
result = await context.invokeClosure(hook, [], value);
|
|
149817
|
-
}
|
|
149818
|
-
if (result === null || typeof result !== "object") {
|
|
149819
|
-
return sandboxString(result, budget, context, joining);
|
|
149820
|
-
}
|
|
150091
|
+
// packages/safe-js/src/interp/globals/object.ts
|
|
150092
|
+
function createObjectGlobal(methods, budget) {
|
|
150093
|
+
const construct = ([value]) => {
|
|
150094
|
+
if (value === null || value === void 0) {
|
|
150095
|
+
budget.chargeDataUsage(1);
|
|
150096
|
+
return /* @__PURE__ */ Object.create(null);
|
|
149821
150097
|
}
|
|
149822
|
-
throw new TypeError("
|
|
149823
|
-
|
|
149824
|
-
|
|
149825
|
-
|
|
149826
|
-
|
|
149827
|
-
|
|
149828
|
-
|
|
149829
|
-
|
|
149830
|
-
|
|
149831
|
-
|
|
149832
|
-
|
|
149833
|
-
|
|
149834
|
-
|
|
149835
|
-
|
|
150098
|
+
if (typeof value !== "object") throw new TypeError("Object primitive boxing is not supported.");
|
|
150099
|
+
return value;
|
|
150100
|
+
};
|
|
150101
|
+
const constructor = createSandboxClosure({
|
|
150102
|
+
guest: true,
|
|
150103
|
+
sandbox: true,
|
|
150104
|
+
name: "Object",
|
|
150105
|
+
length: 1,
|
|
150106
|
+
call: construct,
|
|
150107
|
+
construct
|
|
150108
|
+
});
|
|
150109
|
+
const properties = materializeFunctionProperties(constructor);
|
|
150110
|
+
const prototype = properties.prototype;
|
|
150111
|
+
Object.defineProperty(properties, "prototype", { writable: false });
|
|
150112
|
+
for (const [name, method] of Object.entries(methods)) {
|
|
150113
|
+
Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
|
|
150114
|
+
}
|
|
150115
|
+
const prototypeMethods = {
|
|
150116
|
+
toString: createSandboxClosure({
|
|
150117
|
+
sandbox: true,
|
|
150118
|
+
name: "toString",
|
|
150119
|
+
length: 0,
|
|
150120
|
+
call: (_args, context) => budget.allocateString(`[object ${typeTag(context?.thisValue)}]`)
|
|
150121
|
+
}),
|
|
150122
|
+
valueOf: createSandboxClosure({
|
|
150123
|
+
sandbox: true,
|
|
150124
|
+
name: "valueOf",
|
|
150125
|
+
length: 0,
|
|
150126
|
+
call: (_args, context) => {
|
|
150127
|
+
const value = requireReceiver(context?.thisValue);
|
|
150128
|
+
if (typeof value !== "object")
|
|
150129
|
+
throw new TypeError("Object primitive boxing is not supported.");
|
|
150130
|
+
return value;
|
|
149836
150131
|
}
|
|
149837
|
-
|
|
149838
|
-
|
|
149839
|
-
|
|
149840
|
-
|
|
149841
|
-
|
|
149842
|
-
|
|
149843
|
-
|
|
149844
|
-
|
|
149845
|
-
|
|
149846
|
-
|
|
149847
|
-
|
|
149848
|
-
|
|
150132
|
+
}),
|
|
150133
|
+
hasOwnProperty: createSandboxClosure({
|
|
150134
|
+
sandbox: true,
|
|
150135
|
+
name: "hasOwnProperty",
|
|
150136
|
+
length: 1,
|
|
150137
|
+
call: async ([key3], context) => hasOwnSandboxProperty(
|
|
150138
|
+
requireReceiver(context?.thisValue),
|
|
150139
|
+
await sandboxString(key3, budget, context),
|
|
150140
|
+
false
|
|
150141
|
+
)
|
|
150142
|
+
}),
|
|
150143
|
+
propertyIsEnumerable: createSandboxClosure({
|
|
150144
|
+
sandbox: true,
|
|
150145
|
+
name: "propertyIsEnumerable",
|
|
150146
|
+
length: 1,
|
|
150147
|
+
call: async ([key3], context) => hasOwnSandboxProperty(
|
|
150148
|
+
requireReceiver(context?.thisValue),
|
|
150149
|
+
await sandboxString(key3, budget, context),
|
|
150150
|
+
true
|
|
150151
|
+
)
|
|
150152
|
+
}),
|
|
150153
|
+
isPrototypeOf: createSandboxClosure({
|
|
150154
|
+
sandbox: true,
|
|
150155
|
+
name: "isPrototypeOf",
|
|
150156
|
+
length: 1,
|
|
150157
|
+
call: ([value], context) => {
|
|
150158
|
+
if (typeof value !== "object" || value === null) return false;
|
|
150159
|
+
const receiver = requireReceiver(context?.thisValue);
|
|
150160
|
+
let depth = 0;
|
|
150161
|
+
for (let current = getSandboxPrototype(value, budget); current !== null; current = getSandboxPrototype(current, budget)) {
|
|
150162
|
+
budget.visitNode();
|
|
150163
|
+
assertSandboxDataDepth(depth++);
|
|
150164
|
+
if (current === receiver) return true;
|
|
150165
|
+
}
|
|
150166
|
+
return false;
|
|
149849
150167
|
}
|
|
149850
|
-
|
|
149851
|
-
|
|
149852
|
-
|
|
149853
|
-
}
|
|
149854
|
-
}
|
|
149855
|
-
if (sandboxErrorTypes.has(value)) {
|
|
149856
|
-
const nameValue = ownDataValue(value, "name");
|
|
149857
|
-
const name = nameValue === void 0 ? "Error" : await sandboxString(nameValue, budget, context, joining);
|
|
149858
|
-
const messageValue2 = ownDataValue(value, "message");
|
|
149859
|
-
const message2 = messageValue2 === void 0 ? "" : await sandboxString(messageValue2, budget, context, joining);
|
|
149860
|
-
return name === "" ? message2 : message2 === "" ? name : `${name}: ${message2}`;
|
|
150168
|
+
})
|
|
150169
|
+
};
|
|
150170
|
+
for (const [name, method] of Object.entries(prototypeMethods)) {
|
|
150171
|
+
Object.defineProperty(prototype, name, { value: method, writable: true, configurable: true });
|
|
149861
150172
|
}
|
|
149862
|
-
|
|
150173
|
+
markDescriptorObject(prototype);
|
|
150174
|
+
installObjectPrototype(budget, prototype, constructor);
|
|
150175
|
+
return constructor;
|
|
149863
150176
|
}
|
|
149864
|
-
function
|
|
149865
|
-
|
|
149866
|
-
|
|
149867
|
-
|
|
149868
|
-
}
|
|
149869
|
-
return descriptor?.value;
|
|
150177
|
+
function requireReceiver(value) {
|
|
150178
|
+
if (value === null || value === void 0)
|
|
150179
|
+
throw new TypeError("Object method requires a non-null receiver.");
|
|
150180
|
+
return value;
|
|
149870
150181
|
}
|
|
149871
|
-
|
|
149872
|
-
|
|
150182
|
+
function hasOwnSandboxProperty(value, key3, enumerable) {
|
|
150183
|
+
requireReceiver(value);
|
|
150184
|
+
if (isGuestHostObject(value)) return hasHostObjectMember(value, key3, enumerable);
|
|
150185
|
+
let properties;
|
|
150186
|
+
if (isGuestClosure(value)) properties = materializeFunctionProperties(value);
|
|
150187
|
+
else if (isSandboxClosure(value)) {
|
|
150188
|
+
if (key3 === "length" || key3 === "name") return !enumerable;
|
|
150189
|
+
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
150190
|
+
} else if (isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxGenerator(value))
|
|
150191
|
+
return false;
|
|
150192
|
+
else if (isSandboxRegex(value)) return key3 === "lastIndex" && !enumerable;
|
|
150193
|
+
else properties = Object(value);
|
|
150194
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key3);
|
|
150195
|
+
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
150196
|
+
}
|
|
150197
|
+
function typeTag(value) {
|
|
150198
|
+
if (value === void 0) return "Undefined";
|
|
150199
|
+
if (value === null) return "Null";
|
|
150200
|
+
if (typeof value === "string") return "String";
|
|
150201
|
+
if (typeof value === "number") return "Number";
|
|
150202
|
+
if (typeof value === "boolean") return "Boolean";
|
|
150203
|
+
if (isSandboxClosure(value)) {
|
|
150204
|
+
while (value.boundTarget !== void 0) value = value.boundTarget;
|
|
150205
|
+
return value.generator ? "GeneratorFunction" : value.async ? "AsyncFunction" : "Function";
|
|
150206
|
+
}
|
|
150207
|
+
if (Array.isArray(value)) return "Array";
|
|
150208
|
+
if (isSandboxDate(value)) return "Date";
|
|
150209
|
+
if (isSandboxErrorConstructorInstance(value, "Error")) return "Error";
|
|
150210
|
+
if (isSandboxRegex(value)) return "RegExp";
|
|
150211
|
+
if (isSandboxMap(value)) return "Map";
|
|
150212
|
+
if (isSandboxSet(value)) return "Set";
|
|
150213
|
+
if (isSandboxPromise(value)) return "Promise";
|
|
150214
|
+
if (isSandboxGenerator(value)) return "Generator";
|
|
150215
|
+
if (isFloat32Array(value)) return "Float32Array";
|
|
150216
|
+
return "Object";
|
|
150217
|
+
}
|
|
150218
|
+
var init_object2 = __esm({
|
|
150219
|
+
"packages/safe-js/src/interp/globals/object.ts"() {
|
|
149873
150220
|
"use strict";
|
|
149874
|
-
|
|
150221
|
+
init_graph_depth();
|
|
149875
150222
|
init_date();
|
|
150223
|
+
init_exceptions();
|
|
149876
150224
|
init_float32();
|
|
150225
|
+
init_host_capabilities();
|
|
150226
|
+
init_object_model();
|
|
150227
|
+
init_string_coercion();
|
|
149877
150228
|
init_values();
|
|
149878
150229
|
}
|
|
149879
150230
|
});
|
|
@@ -149881,7 +150232,7 @@ var init_string_coercion = __esm({
|
|
|
149881
150232
|
// packages/safe-js/src/interp/globals/object-array.ts
|
|
149882
150233
|
function createObjectArrayGlobals(options) {
|
|
149883
150234
|
return {
|
|
149884
|
-
Object: {
|
|
150235
|
+
Object: createObjectGlobal({
|
|
149885
150236
|
keys: createSandboxClosure({
|
|
149886
150237
|
sandbox: true,
|
|
149887
150238
|
call: ([value]) => budgetSandboxValue2(getOwnEnumerableKeys(value), options.budget),
|
|
@@ -149899,7 +150250,11 @@ function createObjectArrayGlobals(options) {
|
|
|
149899
150250
|
}),
|
|
149900
150251
|
hasOwn: createSandboxClosure({
|
|
149901
150252
|
sandbox: true,
|
|
149902
|
-
call: ([value, key3]
|
|
150253
|
+
call: ([value, key3], context) => {
|
|
150254
|
+
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
150255
|
+
const name = sandboxString(key3, options.budget, context);
|
|
150256
|
+
return typeof name === "string" ? hasOwnSandboxProperty(value, name, false) : name.then((property) => hasOwnSandboxProperty(value, property, false));
|
|
150257
|
+
},
|
|
149903
150258
|
name: "hasOwn"
|
|
149904
150259
|
}),
|
|
149905
150260
|
getOwnPropertyDescriptor: createSandboxClosure({
|
|
@@ -149940,7 +150295,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149940
150295
|
call: ([value]) => {
|
|
149941
150296
|
if (isSandboxDate(value)) return getDatePrototype(value, options.budget, options.compileOwner);
|
|
149942
150297
|
objectProperties(value);
|
|
149943
|
-
return getSandboxPrototype(value);
|
|
150298
|
+
return getSandboxPrototype(value, options.budget);
|
|
149944
150299
|
},
|
|
149945
150300
|
name: "getPrototypeOf"
|
|
149946
150301
|
}),
|
|
@@ -149998,6 +150353,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149998
150353
|
freeze: createSandboxClosure({
|
|
149999
150354
|
sandbox: true,
|
|
150000
150355
|
call: ([value]) => {
|
|
150356
|
+
if (isGuestHostObject(value)) throw new TypeError("Live host objects cannot be frozen.");
|
|
150001
150357
|
if (typeof value === "object" && value !== null) {
|
|
150002
150358
|
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
150003
150359
|
}
|
|
@@ -150015,7 +150371,7 @@ function createObjectArrayGlobals(options) {
|
|
|
150015
150371
|
call: ([target, ...sources]) => assignSandboxValues(target, sources, options.budget),
|
|
150016
150372
|
name: "assign"
|
|
150017
150373
|
})
|
|
150018
|
-
},
|
|
150374
|
+
}, options.budget),
|
|
150019
150375
|
Array: createSandboxClosure({
|
|
150020
150376
|
sandbox: true,
|
|
150021
150377
|
call: (args) => createArrayFromConstructorArgs(args, options.budget),
|
|
@@ -150212,6 +150568,21 @@ function isAssignableSandboxTarget(value) {
|
|
|
150212
150568
|
async function arrayFromSandboxValues(args, budget) {
|
|
150213
150569
|
const [items, mapFn, thisValue] = args;
|
|
150214
150570
|
const iterator = getSandboxIterator(items);
|
|
150571
|
+
if (isGuestHostObject(items) && iterator !== void 0) {
|
|
150572
|
+
if (mapFn !== void 0 && !isSandboxClosure(mapFn))
|
|
150573
|
+
throw new TypeError("Array.from mapping callback must be a function.");
|
|
150574
|
+
const values2 = [];
|
|
150575
|
+
while (true) {
|
|
150576
|
+
const next = await iterator.next();
|
|
150577
|
+
if (next.done) break;
|
|
150578
|
+
budget.allocateArrayLength(values2.length + 1);
|
|
150579
|
+
const value = mapFn === void 0 ? next.value : await mapFn.call([next.value, values2.length], { stack: [], thisValue });
|
|
150580
|
+
if (isSandboxPromise(value) && value.synchronousPrefix !== void 0)
|
|
150581
|
+
await value.synchronousPrefix;
|
|
150582
|
+
values2.push(value);
|
|
150583
|
+
}
|
|
150584
|
+
return allocateProducedSandboxValue(values2, budget);
|
|
150585
|
+
}
|
|
150215
150586
|
const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
|
|
150216
150587
|
if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
|
|
150217
150588
|
if (mapFn !== void 0) {
|
|
@@ -150286,6 +150657,7 @@ var init_object_array = __esm({
|
|
|
150286
150657
|
"use strict";
|
|
150287
150658
|
init_date();
|
|
150288
150659
|
init_date2();
|
|
150660
|
+
init_object2();
|
|
150289
150661
|
init_host_capabilities();
|
|
150290
150662
|
init_float32();
|
|
150291
150663
|
init_interpreter();
|
|
@@ -150519,10 +150891,10 @@ var init_random = __esm({
|
|
|
150519
150891
|
|
|
150520
150892
|
// packages/safe-js/src/realm.ts
|
|
150521
150893
|
import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
|
|
150522
|
-
import { types as
|
|
150894
|
+
import { types as types5 } from "node:util";
|
|
150523
150895
|
function readModules(input) {
|
|
150524
150896
|
const entries = (value, label) => {
|
|
150525
|
-
if (
|
|
150897
|
+
if (types5.isMap(value) && !types5.isProxy(value)) {
|
|
150526
150898
|
const result = [...Map.prototype.entries.call(value)];
|
|
150527
150899
|
if (result.length > 4096 || result.some(([key3]) => typeof key3 !== "string" || key3.length === 0))
|
|
150528
150900
|
throw new TypeError(`${label} requires bounded string keys.`);
|
|
@@ -150601,6 +150973,7 @@ var init_realm = __esm({
|
|
|
150601
150973
|
init_budget2();
|
|
150602
150974
|
init_compile_guard();
|
|
150603
150975
|
init_globals();
|
|
150976
|
+
init_object_model();
|
|
150604
150977
|
init_interpreter();
|
|
150605
150978
|
init_jobs4();
|
|
150606
150979
|
init_cancel2();
|
|
@@ -150634,7 +151007,7 @@ var init_realm = __esm({
|
|
|
150634
151007
|
throw new TypeError("Realm limits must be positive safe integers with supported names.");
|
|
150635
151008
|
this.limits[name] = Number(value);
|
|
150636
151009
|
}
|
|
150637
|
-
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) ||
|
|
151010
|
+
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types5.isProxy(options.extensions)))
|
|
150638
151011
|
throw new TypeError("Extensions must be a registration array.");
|
|
150639
151012
|
const registrations = options.extensions ?? [];
|
|
150640
151013
|
const extensions = [];
|
|
@@ -150706,6 +151079,7 @@ var init_realm = __esm({
|
|
|
150706
151079
|
this.budget.setRetainedValues(this, this.retainedRoots);
|
|
150707
151080
|
this.tracker.onFatalRejection((error3) => this.poison(error3));
|
|
150708
151081
|
} catch (error3) {
|
|
151082
|
+
releaseObjectPrototype(this.budget);
|
|
150709
151083
|
this.compilation.dispose();
|
|
150710
151084
|
this.lease.release();
|
|
150711
151085
|
throw error3;
|
|
@@ -150853,7 +151227,7 @@ var init_realm = __esm({
|
|
|
150853
151227
|
return this.phase.run(phase, () => {
|
|
150854
151228
|
try {
|
|
150855
151229
|
const result = call();
|
|
150856
|
-
if (
|
|
151230
|
+
if (types5.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
|
|
150857
151231
|
return Promise.resolve(result).then(
|
|
150858
151232
|
async (value) => {
|
|
150859
151233
|
await Promise.allSettled(phase.pending);
|
|
@@ -150908,17 +151282,26 @@ var init_realm = __esm({
|
|
|
150908
151282
|
owner: this,
|
|
150909
151283
|
assertActive: this.assertOpen,
|
|
150910
151284
|
chargeWork: this.chargeWork,
|
|
150911
|
-
|
|
151285
|
+
checkLength: (length) => this.budget.allocateArrayLength(length),
|
|
151286
|
+
checkTemporaryDataSize: (size) => {
|
|
151287
|
+
const temporary = {};
|
|
151288
|
+
try {
|
|
151289
|
+
this.budget.setRetainedDataUsage(temporary, size);
|
|
151290
|
+
} finally {
|
|
151291
|
+
this.budget.setRetainedDataUsage(temporary, 0);
|
|
151292
|
+
}
|
|
151293
|
+
},
|
|
151294
|
+
read: (operation, validate2) => {
|
|
150912
151295
|
const value = this.invokeHost(operation, operation);
|
|
150913
|
-
if (
|
|
151296
|
+
if (types5.isPromise(value)) {
|
|
150914
151297
|
void Promise.resolve(value).catch(() => void 0);
|
|
150915
151298
|
throw new TypeError("Live property getters must be synchronous.");
|
|
150916
151299
|
}
|
|
150917
|
-
return this.importValue(value);
|
|
151300
|
+
return this.importValue(validate2 === void 0 ? value : validate2(value));
|
|
150918
151301
|
},
|
|
150919
151302
|
write: (operation, value) => {
|
|
150920
151303
|
const result = this.invokeHost(operation, () => operation(this.exportValue(value)));
|
|
150921
|
-
if (
|
|
151304
|
+
if (types5.isPromise(result)) {
|
|
150922
151305
|
void Promise.resolve(result).catch(() => void 0);
|
|
150923
151306
|
throw new TypeError("Live property setters must be synchronous.");
|
|
150924
151307
|
}
|
|
@@ -151111,7 +151494,7 @@ var init_realm = __esm({
|
|
|
151111
151494
|
}
|
|
151112
151495
|
});
|
|
151113
151496
|
const output = getExtensionSetup(extension)(context);
|
|
151114
|
-
if (
|
|
151497
|
+
if (types5.isPromise(output)) {
|
|
151115
151498
|
void Promise.resolve(output).catch(() => void 0);
|
|
151116
151499
|
throw new TypeError("Extension setup must be synchronous.");
|
|
151117
151500
|
}
|
|
@@ -151272,6 +151655,7 @@ var init_realm = __esm({
|
|
|
151272
151655
|
for (const reference of this.guestReferences.keys()) revokeGuestReference(reference, this);
|
|
151273
151656
|
this.guestReferences.clear();
|
|
151274
151657
|
this.budget.setRetainedValues(this, void 0);
|
|
151658
|
+
releaseObjectPrototype(this.budget);
|
|
151275
151659
|
this.disposal = (async () => {
|
|
151276
151660
|
const errors2 = [];
|
|
151277
151661
|
for (const cleanup of this.cleanups.splice(0).reverse()) {
|
|
@@ -152202,6 +152586,7 @@ function run(source, options = {}) {
|
|
|
152202
152586
|
}
|
|
152203
152587
|
});
|
|
152204
152588
|
} finally {
|
|
152589
|
+
releaseObjectPrototype(budget);
|
|
152205
152590
|
compilation.dispose();
|
|
152206
152591
|
operation.release();
|
|
152207
152592
|
}
|
|
@@ -152413,6 +152798,7 @@ var init_run7 = __esm({
|
|
|
152413
152798
|
init_promise_tracker();
|
|
152414
152799
|
init_host_call();
|
|
152415
152800
|
init_globals();
|
|
152801
|
+
init_object_model();
|
|
152416
152802
|
init_host_bridge();
|
|
152417
152803
|
init_interpreter();
|
|
152418
152804
|
init_promise();
|
|
@@ -159292,7 +159678,7 @@ var init_package2 = __esm({
|
|
|
159292
159678
|
"package.json"() {
|
|
159293
159679
|
package_default2 = {
|
|
159294
159680
|
name: "poe-code",
|
|
159295
|
-
version: "14.0.
|
|
159681
|
+
version: "14.0.9",
|
|
159296
159682
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
159297
159683
|
license: "MIT",
|
|
159298
159684
|
type: "module",
|
|
@@ -159761,7 +160147,7 @@ var init_package2 = __esm({
|
|
|
159761
160147
|
"@types/mustache": "^4.2.6",
|
|
159762
160148
|
"@types/node": "^25.2.2",
|
|
159763
160149
|
"@types/semver": "^7.7.1",
|
|
159764
|
-
"@vitest/coverage-v8": "
|
|
160150
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
159765
160151
|
"agent-code-review": "*",
|
|
159766
160152
|
"agent-stash": "*",
|
|
159767
160153
|
"auth-store": "*",
|
|
@@ -159801,7 +160187,7 @@ var init_package2 = __esm({
|
|
|
159801
160187
|
typescript: "^5.9.3",
|
|
159802
160188
|
"typescript-eslint": "8.55.0",
|
|
159803
160189
|
vite: "6.4.3",
|
|
159804
|
-
vitest: "
|
|
160190
|
+
vitest: "4.1.11",
|
|
159805
160191
|
"@poe-code/safe-js": "*",
|
|
159806
160192
|
"virtual-bash": "*",
|
|
159807
160193
|
"poe-code": "file:.",
|