poe-code 14.0.6 → 14.0.8
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 +944 -143
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-2M6MNQBY.js → chunk-MO3YD4ID.js} +888 -133
- package/packages/safe-js/dist/chunks/chunk-MO3YD4ID.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-QSSQJNKE.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/extensions.d.ts +2 -0
- 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/date.d.ts +19 -0
- package/packages/safe-js/dist/interp/date.js +129 -0
- package/packages/safe-js/dist/interp/globals/console-json.js +5 -1
- package/packages/safe-js/dist/interp/globals/date.d.ts +10 -0
- package/packages/safe-js/dist/interp/globals/date.js +95 -0
- package/packages/safe-js/dist/interp/globals/object-array.d.ts +4 -3
- package/packages/safe-js/dist/interp/globals/object-array.js +42 -5
- 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 +4 -1
- package/packages/safe-js/dist/interp/globals.js +2 -0
- package/packages/safe-js/dist/interp/host-bridge.d.ts +4 -0
- package/packages/safe-js/dist/interp/host-bridge.js +21 -2
- package/packages/safe-js/dist/interp/host-call.js +4 -0
- package/packages/safe-js/dist/interp/host-capabilities.d.ts +28 -1
- package/packages/safe-js/dist/interp/host-capabilities.js +220 -5
- package/packages/safe-js/dist/interp/interpreter.js +46 -11
- 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/string-coercion.js +3 -0
- package/packages/safe-js/dist/interp/values.d.ts +3 -1
- package/packages/safe-js/dist/interp/values.js +34 -6
- package/packages/safe-js/dist/lint/rules/known-globals.d.ts +1 -1
- package/packages/safe-js/dist/lint/rules/known-globals.js +1 -0
- package/packages/safe-js/dist/parse/parser.js +4 -2
- package/packages/safe-js/dist/realm.d.ts +4 -1
- package/packages/safe-js/dist/realm.js +89 -10
- package/packages/safe-js/dist/run.d.ts +2 -0
- package/packages/safe-js/dist/run.js +3 -1
- package/packages/safe-js/dist/snapshot/dump-format.js +8 -3
- package/packages/safe-js/dist/snapshot/replay-data.d.ts +4 -1
- package/packages/safe-js/dist/snapshot/replay-data.js +11 -0
- package/packages/safe-js/dist/snapshot/restore.js +6 -0
- package/packages/safe-js/dist/snapshot/serialize.d.ts +5 -2
- package/packages/safe-js/dist/snapshot/serialize.js +8 -2
- package/packages/safe-js/dist/snapshot/validation.js +18 -1
- package/packages/safe-js/dist/chunks/chunk-2M6MNQBY.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-QSSQJNKE.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)) {
|
|
@@ -124460,8 +124460,9 @@ var init_parser3 = __esm({
|
|
|
124460
124460
|
}
|
|
124461
124461
|
break;
|
|
124462
124462
|
}
|
|
124463
|
-
this.
|
|
124464
|
-
|
|
124463
|
+
const optional = this.consumePunctuator("?.");
|
|
124464
|
+
if (optional !== void 0) throw new DisallowedSyntaxError("new optional chain", optional.start);
|
|
124465
|
+
const args = this.consumePunctuator("(") === void 0 ? [] : this.parseArguments();
|
|
124465
124466
|
const end = this.previousToken();
|
|
124466
124467
|
return {
|
|
124467
124468
|
node: {
|
|
@@ -125592,10 +125593,69 @@ var init_extensions = __esm({
|
|
|
125592
125593
|
});
|
|
125593
125594
|
|
|
125594
125595
|
// packages/safe-js/src/interp/host-capabilities.ts
|
|
125596
|
+
import { types as types2 } from "node:util";
|
|
125597
|
+
function createGuestReference(root, owner, assertActive) {
|
|
125598
|
+
const reference = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
125599
|
+
guestReferences.set(reference, { root, owner, assertActive });
|
|
125600
|
+
return reference;
|
|
125601
|
+
}
|
|
125602
|
+
function readGuestReference(reference, owner) {
|
|
125603
|
+
const state = typeof reference === "object" && reference !== null ? guestReferences.get(reference) : void 0;
|
|
125604
|
+
if (state === void 0 || state.owner !== owner)
|
|
125605
|
+
throw new TypeError("Foreign or invalid guest reference.");
|
|
125606
|
+
state.assertActive();
|
|
125607
|
+
if (state.root === void 0) throw new TypeError("Guest reference is revoked.");
|
|
125608
|
+
return state.root[0];
|
|
125609
|
+
}
|
|
125610
|
+
function revokeGuestReference(reference, owner) {
|
|
125611
|
+
const state = guestReferences.get(reference);
|
|
125612
|
+
if (state === void 0 || state.owner !== owner) throw new TypeError("Foreign guest reference.");
|
|
125613
|
+
state.root = void 0;
|
|
125614
|
+
}
|
|
125595
125615
|
function createLiveHostObject(definition, controller) {
|
|
125596
125616
|
const input = readDataRecord(definition, "Host object definition");
|
|
125597
|
-
if (Object.keys(input).some((key3) =>
|
|
125617
|
+
if (Object.keys(input).some((key3) => !["properties", "methods", "indexed", "named"].includes(key3)))
|
|
125598
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
|
+
}
|
|
125599
125659
|
const properties = /* @__PURE__ */ new Map();
|
|
125600
125660
|
for (const [name, inputProperty] of Object.entries(
|
|
125601
125661
|
readDataRecord(input.properties ?? {}, "Host properties")
|
|
@@ -125615,6 +125675,8 @@ function createLiveHostObject(definition, controller) {
|
|
|
125615
125675
|
for (const name of [...properties.keys(), ...Object.keys(operations)]) {
|
|
125616
125676
|
if (["constructor", "prototype", "__proto__"].includes(name))
|
|
125617
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}'.`);
|
|
125618
125680
|
}
|
|
125619
125681
|
controller.assertActive();
|
|
125620
125682
|
controller.chargeWork(properties.size + Object.keys(operations).length + 1);
|
|
@@ -125626,7 +125688,7 @@ function createLiveHostObject(definition, controller) {
|
|
|
125626
125688
|
controller.method(operation)
|
|
125627
125689
|
])
|
|
125628
125690
|
);
|
|
125629
|
-
const state = { host, guest, controller, properties, methods };
|
|
125691
|
+
const state = { host, guest, controller, properties, methods, indexed, named };
|
|
125630
125692
|
hostObjects.set(host, state);
|
|
125631
125693
|
guestObjects.set(guest, state);
|
|
125632
125694
|
return host;
|
|
@@ -125635,9 +125697,10 @@ function isGuestHostObject(value) {
|
|
|
125635
125697
|
return typeof value === "object" && value !== null && guestObjects.has(value);
|
|
125636
125698
|
}
|
|
125637
125699
|
function isLiveCapability(value) {
|
|
125638
|
-
return (typeof value === "object" && value !== null || typeof value === "function") && (hostObjects.has(value) || guestObjects.has(value) || guestCallbacks.has(value));
|
|
125700
|
+
return (typeof value === "object" && value !== null || typeof value === "function") && (hostObjects.has(value) || guestObjects.has(value) || guestCallbacks.has(value) || guestReferences.has(value));
|
|
125639
125701
|
}
|
|
125640
125702
|
function importHostCapability(value, owner) {
|
|
125703
|
+
if (guestReferences.has(value)) return readGuestReference(value, owner);
|
|
125641
125704
|
const object = hostObjects.get(value);
|
|
125642
125705
|
if (object !== void 0) {
|
|
125643
125706
|
if (object.controller.owner !== owner) throw new TypeError("Foreign realm host capability.");
|
|
@@ -125682,15 +125745,29 @@ function revokeHostObject(value, owner) {
|
|
|
125682
125745
|
throw new TypeError("Foreign host object.");
|
|
125683
125746
|
state.properties.clear();
|
|
125684
125747
|
state.methods.clear();
|
|
125748
|
+
state.indexed = void 0;
|
|
125749
|
+
state.named = void 0;
|
|
125685
125750
|
}
|
|
125686
125751
|
function getHostObjectMember(value, key3) {
|
|
125687
125752
|
const state = guestObjects.get(value);
|
|
125688
125753
|
state.controller.assertActive();
|
|
125689
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
|
+
}
|
|
125690
125763
|
const property = state.properties.get(key3);
|
|
125691
125764
|
if (property !== void 0)
|
|
125692
125765
|
return property.get === void 0 ? void 0 : state.controller.read(property.get);
|
|
125693
|
-
|
|
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;
|
|
125694
125771
|
}
|
|
125695
125772
|
function setHostObjectMember(value, key3, entry) {
|
|
125696
125773
|
const state = guestObjects.get(value);
|
|
@@ -125703,16 +125780,119 @@ function setHostObjectMember(value, key3, entry) {
|
|
|
125703
125780
|
function getHostObjectKeys(value) {
|
|
125704
125781
|
const state = guestObjects.get(value);
|
|
125705
125782
|
state.controller.assertActive();
|
|
125706
|
-
|
|
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;
|
|
125707
125816
|
}
|
|
125708
|
-
|
|
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
|
+
});
|
|
125883
|
+
}
|
|
125884
|
+
var MAX_INDEXED_LENGTH, MAX_NAMED_KEYS, MAX_NAMED_KEY_CODE_UNITS, hostObjects, guestObjects, guestCallbacks, guestReferences;
|
|
125709
125885
|
var init_host_capabilities = __esm({
|
|
125710
125886
|
"packages/safe-js/src/interp/host-capabilities.ts"() {
|
|
125711
125887
|
"use strict";
|
|
125712
125888
|
init_extensions();
|
|
125889
|
+
MAX_INDEXED_LENGTH = 65536;
|
|
125890
|
+
MAX_NAMED_KEYS = 65536;
|
|
125891
|
+
MAX_NAMED_KEY_CODE_UNITS = 1048576;
|
|
125713
125892
|
hostObjects = /* @__PURE__ */ new WeakMap();
|
|
125714
125893
|
guestObjects = /* @__PURE__ */ new WeakMap();
|
|
125715
125894
|
guestCallbacks = /* @__PURE__ */ new WeakMap();
|
|
125895
|
+
guestReferences = /* @__PURE__ */ new WeakMap();
|
|
125716
125896
|
}
|
|
125717
125897
|
});
|
|
125718
125898
|
|
|
@@ -125809,6 +125989,134 @@ var init_otel2 = __esm({
|
|
|
125809
125989
|
}
|
|
125810
125990
|
});
|
|
125811
125991
|
|
|
125992
|
+
// packages/safe-js/src/interp/date.ts
|
|
125993
|
+
import { types as types3 } from "node:util";
|
|
125994
|
+
function isSandboxDate(value) {
|
|
125995
|
+
return typeof value === "object" && value !== null && dates.has(value);
|
|
125996
|
+
}
|
|
125997
|
+
function createSandboxDate(time) {
|
|
125998
|
+
const value = new NativeDate(time);
|
|
125999
|
+
dates.add(value);
|
|
126000
|
+
return Object.freeze(value);
|
|
126001
|
+
}
|
|
126002
|
+
function dateTime(value) {
|
|
126003
|
+
return Reflect.apply(readTime, value, []);
|
|
126004
|
+
}
|
|
126005
|
+
function copyNativeDate(value) {
|
|
126006
|
+
if (!types3.isDate(value)) return void 0;
|
|
126007
|
+
if (Object.getPrototypeOf(value) !== NativeDate.prototype || Reflect.ownKeys(value).length > 0)
|
|
126008
|
+
throw new TypeError("Date subclasses and own properties are not supported.");
|
|
126009
|
+
return createSandboxDate(dateTime(value));
|
|
126010
|
+
}
|
|
126011
|
+
function exportDate(value) {
|
|
126012
|
+
return new NativeDate(dateTime(value));
|
|
126013
|
+
}
|
|
126014
|
+
function dateNumber(value) {
|
|
126015
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
126016
|
+
if (typeof value === "object" && value !== null || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint")
|
|
126017
|
+
throw new TypeError("Date arguments require primitive values; custom coercion is unsupported.");
|
|
126018
|
+
return Number(value);
|
|
126019
|
+
}
|
|
126020
|
+
function parseDate2(value, budget) {
|
|
126021
|
+
if (typeof value === "object" && value !== null || typeof value === "function")
|
|
126022
|
+
throw new TypeError("Date parsing requires a primitive value.");
|
|
126023
|
+
const text5 = String(value);
|
|
126024
|
+
if (text5.length > 4096) throw new RangeError("Date input exceeds the 4096 character limit.");
|
|
126025
|
+
budget.allocateString(text5);
|
|
126026
|
+
for (let index = 0; index < text5.length; index++) budget.visitNode();
|
|
126027
|
+
return NativeDate.parse(text5);
|
|
126028
|
+
}
|
|
126029
|
+
function dateFromParts(args, utc) {
|
|
126030
|
+
const parts = args.slice(0, 7).map(dateNumber);
|
|
126031
|
+
return utc ? Reflect.apply(NativeDate.UTC, NativeDate, parts) : dateTime(Reflect.construct(NativeDate, parts));
|
|
126032
|
+
}
|
|
126033
|
+
function dateString(value) {
|
|
126034
|
+
return dateMethods.get("toString").invoke(value, []);
|
|
126035
|
+
}
|
|
126036
|
+
function restoreDateTime(value) {
|
|
126037
|
+
if (value !== null && (typeof value !== "number" || !Number.isInteger(value) || Math.abs(value) > 864e13 || Object.is(value, -0)))
|
|
126038
|
+
throw new TypeError("Invalid serialized Date epoch.");
|
|
126039
|
+
const date = createSandboxDate(0);
|
|
126040
|
+
Reflect.apply(writeTime, date, [value === null ? NaN : value]);
|
|
126041
|
+
return date;
|
|
126042
|
+
}
|
|
126043
|
+
function serializedDateTime(value) {
|
|
126044
|
+
const time = dateTime(value);
|
|
126045
|
+
return Number.isNaN(time) ? null : time;
|
|
126046
|
+
}
|
|
126047
|
+
var NativeDate, readTime, writeTime, dates, methodNames, dateMethods;
|
|
126048
|
+
var init_date = __esm({
|
|
126049
|
+
"packages/safe-js/src/interp/date.ts"() {
|
|
126050
|
+
"use strict";
|
|
126051
|
+
NativeDate = Date;
|
|
126052
|
+
readTime = NativeDate.prototype.getTime;
|
|
126053
|
+
writeTime = NativeDate.prototype.setTime;
|
|
126054
|
+
dates = /* @__PURE__ */ new WeakSet();
|
|
126055
|
+
methodNames = [
|
|
126056
|
+
"getTime",
|
|
126057
|
+
"valueOf",
|
|
126058
|
+
"getDate",
|
|
126059
|
+
"getDay",
|
|
126060
|
+
"getFullYear",
|
|
126061
|
+
"getHours",
|
|
126062
|
+
"getMilliseconds",
|
|
126063
|
+
"getMinutes",
|
|
126064
|
+
"getMonth",
|
|
126065
|
+
"getSeconds",
|
|
126066
|
+
"getTimezoneOffset",
|
|
126067
|
+
"getUTCDate",
|
|
126068
|
+
"getUTCDay",
|
|
126069
|
+
"getUTCFullYear",
|
|
126070
|
+
"getUTCHours",
|
|
126071
|
+
"getUTCMilliseconds",
|
|
126072
|
+
"getUTCMinutes",
|
|
126073
|
+
"getUTCMonth",
|
|
126074
|
+
"getUTCSeconds",
|
|
126075
|
+
"setTime",
|
|
126076
|
+
"setDate",
|
|
126077
|
+
"setFullYear",
|
|
126078
|
+
"setHours",
|
|
126079
|
+
"setMilliseconds",
|
|
126080
|
+
"setMinutes",
|
|
126081
|
+
"setMonth",
|
|
126082
|
+
"setSeconds",
|
|
126083
|
+
"setUTCDate",
|
|
126084
|
+
"setUTCFullYear",
|
|
126085
|
+
"setUTCHours",
|
|
126086
|
+
"setUTCMilliseconds",
|
|
126087
|
+
"setUTCMinutes",
|
|
126088
|
+
"setUTCMonth",
|
|
126089
|
+
"setUTCSeconds",
|
|
126090
|
+
"toDateString",
|
|
126091
|
+
"toISOString",
|
|
126092
|
+
"toString",
|
|
126093
|
+
"toTimeString",
|
|
126094
|
+
"toUTCString",
|
|
126095
|
+
"toJSON"
|
|
126096
|
+
];
|
|
126097
|
+
dateMethods = new Map(
|
|
126098
|
+
methodNames.map((name) => {
|
|
126099
|
+
const native = NativeDate.prototype[name];
|
|
126100
|
+
return [
|
|
126101
|
+
name,
|
|
126102
|
+
{
|
|
126103
|
+
length: native.length,
|
|
126104
|
+
invoke: (date, args) => {
|
|
126105
|
+
if (name === "toJSON")
|
|
126106
|
+
return Number.isNaN(dateTime(date)) ? null : Reflect.apply(NativeDate.prototype.toISOString, date, []);
|
|
126107
|
+
return Reflect.apply(
|
|
126108
|
+
native,
|
|
126109
|
+
date,
|
|
126110
|
+
name.startsWith("set") ? args.slice(0, native.length).map(dateNumber) : []
|
|
126111
|
+
);
|
|
126112
|
+
}
|
|
126113
|
+
}
|
|
126114
|
+
];
|
|
126115
|
+
})
|
|
126116
|
+
);
|
|
126117
|
+
}
|
|
126118
|
+
});
|
|
126119
|
+
|
|
125812
126120
|
// packages/safe-js/src/interp/float32.ts
|
|
125813
126121
|
function isFloat32Array(value) {
|
|
125814
126122
|
return ArrayBuffer.isView(value) && Object.getPrototypeOf(value) === Float32Array.prototype && Reflect.apply(readTag, value, []) === "Float32Array";
|
|
@@ -126479,6 +126787,8 @@ function encodeReplayData(value, options = {}) {
|
|
|
126479
126787
|
id: capabilityId,
|
|
126480
126788
|
properties: child(entry.properties, "properties")
|
|
126481
126789
|
};
|
|
126790
|
+
} else if (isSandboxDate(entry)) {
|
|
126791
|
+
nodes[id] = { kind: "date", time: serializedDateTime(entry) };
|
|
126482
126792
|
} else if (isFloat32Array(entry)) {
|
|
126483
126793
|
const storage2 = encodeFloat32Storage(entry, id, float32Buffers, (id2) => ({
|
|
126484
126794
|
tag: "ref",
|
|
@@ -126629,6 +126939,12 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
126629
126939
|
options.onCapabilityRestored?.(capability, copy);
|
|
126630
126940
|
return copy;
|
|
126631
126941
|
}
|
|
126942
|
+
if (kind === "date") {
|
|
126943
|
+
if (Object.keys(node).length !== 2) throw new TypeError("Invalid serialized Date fields.");
|
|
126944
|
+
const result3 = restoreDateTime(own(node, "time"));
|
|
126945
|
+
restored.set(id, result3);
|
|
126946
|
+
return result3;
|
|
126947
|
+
}
|
|
126632
126948
|
if (kind === "float32array") {
|
|
126633
126949
|
if (typeof node.extensible !== "boolean")
|
|
126634
126950
|
throw new TypeError("Invalid Float32Array extensibility.");
|
|
@@ -126740,6 +127056,7 @@ var init_replay_data = __esm({
|
|
|
126740
127056
|
init_compile_guard();
|
|
126741
127057
|
init_float32();
|
|
126742
127058
|
init_float32array();
|
|
127059
|
+
init_date();
|
|
126743
127060
|
init_shape();
|
|
126744
127061
|
init_values();
|
|
126745
127062
|
init_arguments2();
|
|
@@ -126969,6 +127286,8 @@ function normalize2(value, seen) {
|
|
|
126969
127286
|
if (seen.has(value)) throw new TypeError("Host call arguments cannot contain cycles.");
|
|
126970
127287
|
seen.add(value);
|
|
126971
127288
|
try {
|
|
127289
|
+
const date = copyNativeDate(value);
|
|
127290
|
+
if (date !== void 0) return Object.assign(/* @__PURE__ */ Object.create(null), { $type: "date", time: serializedDateTime(date) });
|
|
126972
127291
|
if (isFloat32Array(value)) {
|
|
126973
127292
|
const storage2 = float32Storage(value);
|
|
126974
127293
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -127017,6 +127336,7 @@ var init_host_call = __esm({
|
|
|
127017
127336
|
"packages/safe-js/src/interp/host-call.ts"() {
|
|
127018
127337
|
"use strict";
|
|
127019
127338
|
init_float32();
|
|
127339
|
+
init_date();
|
|
127020
127340
|
init_values();
|
|
127021
127341
|
init_compile_guard();
|
|
127022
127342
|
init_replay_data();
|
|
@@ -127912,6 +128232,7 @@ var init_running_state = __esm({
|
|
|
127912
128232
|
|
|
127913
128233
|
// packages/safe-js/src/interp/iteration.ts
|
|
127914
128234
|
function getSandboxIterator(value) {
|
|
128235
|
+
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
127915
128236
|
if (isFloat32Array(value)) {
|
|
127916
128237
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
127917
128238
|
}
|
|
@@ -128013,6 +128334,7 @@ var init_iteration = __esm({
|
|
|
128013
128334
|
init_values();
|
|
128014
128335
|
init_running_state();
|
|
128015
128336
|
init_float32();
|
|
128337
|
+
init_host_capabilities();
|
|
128016
128338
|
}
|
|
128017
128339
|
});
|
|
128018
128340
|
|
|
@@ -129067,6 +129389,7 @@ function createSandboxClosure(input) {
|
|
|
129067
129389
|
if (input.sandbox === true) {
|
|
129068
129390
|
Object.defineProperty(closure, "sandbox", { value: true });
|
|
129069
129391
|
}
|
|
129392
|
+
if (input.generator === true) Object.defineProperty(closure, "generator", { value: true });
|
|
129070
129393
|
if (input.length !== void 0) {
|
|
129071
129394
|
Object.defineProperty(closure, "length", { value: input.length });
|
|
129072
129395
|
}
|
|
@@ -129099,7 +129422,13 @@ function createSandboxClosure(input) {
|
|
|
129099
129422
|
return Object.freeze(closure);
|
|
129100
129423
|
}
|
|
129101
129424
|
function ownEnumerableSandboxEntries(value) {
|
|
129102
|
-
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
|
+
}
|
|
129103
129432
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
129104
129433
|
if (isGuestClosure(value)) return Object.entries(value.properties ?? {});
|
|
129105
129434
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
@@ -129252,8 +129581,12 @@ function measureSandboxData(values, options = {}) {
|
|
|
129252
129581
|
assertSandboxDataDepth(depth);
|
|
129253
129582
|
seen.add(value);
|
|
129254
129583
|
usage += 1;
|
|
129584
|
+
if (isSandboxDate(value)) {
|
|
129585
|
+
usage += 8;
|
|
129586
|
+
return;
|
|
129587
|
+
}
|
|
129255
129588
|
if (isGuestHostObject(value)) {
|
|
129256
|
-
|
|
129589
|
+
usage += measureHostObjectData(value);
|
|
129257
129590
|
return;
|
|
129258
129591
|
}
|
|
129259
129592
|
const prototype = getSandboxPrototype(value);
|
|
@@ -129350,7 +129683,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
129350
129683
|
function reconcileCompiledValues(budget, values, compilation, parent, escaping = []) {
|
|
129351
129684
|
while (parent?.closed) parent = parent.parent;
|
|
129352
129685
|
const included = /* @__PURE__ */ new Set();
|
|
129353
|
-
const usage = measureSandboxData(values, { compileTickets: included });
|
|
129686
|
+
const usage = measureSandboxData([...values, ...budget.retainedValues()], { compileTickets: included });
|
|
129354
129687
|
const kept = /* @__PURE__ */ new Set();
|
|
129355
129688
|
if (parent !== void 0) measureSandboxData(escaping, { compileTickets: kept });
|
|
129356
129689
|
const transferred = /* @__PURE__ */ new Set();
|
|
@@ -129446,6 +129779,13 @@ function copyToSandbox(value, state, path193 = "<root>", cloneSandboxCollections
|
|
|
129446
129779
|
}
|
|
129447
129780
|
return sandboxPromise;
|
|
129448
129781
|
}
|
|
129782
|
+
if (nodeTypes.isDate(value)) {
|
|
129783
|
+
const existing = state.seen.get(value);
|
|
129784
|
+
if (existing !== void 0) return existing;
|
|
129785
|
+
const copy = copyNativeDate(value);
|
|
129786
|
+
state.seen.set(value, copy);
|
|
129787
|
+
return copy;
|
|
129788
|
+
}
|
|
129449
129789
|
if (isFloat32Array(value)) {
|
|
129450
129790
|
const existing = state.seen.get(value);
|
|
129451
129791
|
if (existing !== void 0) return existing;
|
|
@@ -129605,6 +129945,13 @@ function copyFromSandbox(value, state, path193 = "<root>", options, depth = 0) {
|
|
|
129605
129945
|
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
129606
129946
|
return copy;
|
|
129607
129947
|
}
|
|
129948
|
+
if (isSandboxDate(value)) {
|
|
129949
|
+
const existing = state.seen.get(value);
|
|
129950
|
+
if (existing !== void 0) return existing;
|
|
129951
|
+
const copy = exportDate(value);
|
|
129952
|
+
state.seen.set(value, copy);
|
|
129953
|
+
return copy;
|
|
129954
|
+
}
|
|
129608
129955
|
if (isSandboxClosure(value)) {
|
|
129609
129956
|
if (options.wrapClosure === void 0) {
|
|
129610
129957
|
throw new TypeError(
|
|
@@ -129873,6 +130220,7 @@ var init_values = __esm({
|
|
|
129873
130220
|
"packages/safe-js/src/interp/values.ts"() {
|
|
129874
130221
|
"use strict";
|
|
129875
130222
|
init_otel2();
|
|
130223
|
+
init_date();
|
|
129876
130224
|
init_host_capabilities();
|
|
129877
130225
|
init_compile_guard();
|
|
129878
130226
|
init_float32();
|
|
@@ -129941,27 +130289,49 @@ function getGuestFunctionProperty(closure, key3) {
|
|
|
129941
130289
|
}
|
|
129942
130290
|
return properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key3)?.value;
|
|
129943
130291
|
}
|
|
129944
|
-
function
|
|
129945
|
-
|
|
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;
|
|
129946
130314
|
}
|
|
129947
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
|
+
}
|
|
129948
130319
|
if (!isPrototypeRecord(value) || prototype !== null && !isPrototypeRecord(prototype)) {
|
|
129949
130320
|
throw new TypeError(
|
|
129950
130321
|
"Prototype links require ordinary sandbox objects; callable and exotic prototype chains are not supported."
|
|
129951
130322
|
);
|
|
129952
130323
|
}
|
|
129953
|
-
if (getSandboxPrototype(value) === prototype) return;
|
|
130324
|
+
if (prototypes.has(value) && getSandboxPrototype(value, budget) === prototype) return;
|
|
129954
130325
|
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : value)) {
|
|
129955
130326
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
129956
130327
|
}
|
|
129957
130328
|
let depth = 0;
|
|
129958
|
-
for (let current = prototype; current !== null; current = getSandboxPrototype(current)) {
|
|
130329
|
+
for (let current = prototype; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
129959
130330
|
budget?.visitNode();
|
|
129960
130331
|
assertSandboxDataDepth(depth++);
|
|
129961
130332
|
if (current === value) throw new TypeError("Cyclic prototype value.");
|
|
129962
130333
|
}
|
|
129963
|
-
|
|
129964
|
-
else prototypes.set(value, prototype);
|
|
130334
|
+
prototypes.set(value, prototype);
|
|
129965
130335
|
}
|
|
129966
130336
|
function isPrototypeRecord(value) {
|
|
129967
130337
|
if (isGuestHostObject(value)) return false;
|
|
@@ -129977,13 +130347,15 @@ function hasManagedDescriptors(value) {
|
|
|
129977
130347
|
return descriptorObjects.has(value);
|
|
129978
130348
|
}
|
|
129979
130349
|
function hasGuestObjectState(value) {
|
|
130350
|
+
const intrinsicUnchanged = intrinsicConstructors.get(value);
|
|
130351
|
+
if (intrinsicUnchanged !== void 0) return !intrinsicUnchanged();
|
|
129980
130352
|
if (isLiveCapability(value)) return true;
|
|
129981
130353
|
if (functionProperties.has(value) || prototypes.has(value)) return true;
|
|
129982
130354
|
return descriptorObjects.has(value) && Object.values(Object.getOwnPropertyDescriptors(value)).some(
|
|
129983
130355
|
(descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
|
|
129984
130356
|
);
|
|
129985
130357
|
}
|
|
129986
|
-
var guestClosures, functionProperties, prototypes, descriptorObjects;
|
|
130358
|
+
var guestClosures, functionProperties, prototypes, intrinsicPrototypes, intrinsicConstructors, descriptorObjects;
|
|
129987
130359
|
var init_object_model = __esm({
|
|
129988
130360
|
"packages/safe-js/src/interp/object-model.ts"() {
|
|
129989
130361
|
"use strict";
|
|
@@ -129993,6 +130365,8 @@ var init_object_model = __esm({
|
|
|
129993
130365
|
guestClosures = /* @__PURE__ */ new WeakSet();
|
|
129994
130366
|
functionProperties = /* @__PURE__ */ new WeakMap();
|
|
129995
130367
|
prototypes = /* @__PURE__ */ new WeakMap();
|
|
130368
|
+
intrinsicPrototypes = /* @__PURE__ */ new WeakMap();
|
|
130369
|
+
intrinsicConstructors = /* @__PURE__ */ new WeakMap();
|
|
129996
130370
|
descriptorObjects = /* @__PURE__ */ new WeakSet();
|
|
129997
130371
|
}
|
|
129998
130372
|
});
|
|
@@ -130089,7 +130463,7 @@ function serializeDumpValue(value, path193, state) {
|
|
|
130089
130463
|
if (hasGuestObjectState(value)) {
|
|
130090
130464
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
130091
130465
|
}
|
|
130092
|
-
if (isFloat32Array(value)) return serializeHeapReference(value, path193, state);
|
|
130466
|
+
if (isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path193, state);
|
|
130093
130467
|
if (Array.isArray(value)) {
|
|
130094
130468
|
const reference2 = serializeHeapReference(value, path193, state);
|
|
130095
130469
|
if (reference2 !== void 0) {
|
|
@@ -130113,7 +130487,9 @@ function serializeHeapReference(value, path193, state) {
|
|
|
130113
130487
|
}
|
|
130114
130488
|
if (!state.serializedHeapIds.has(id)) {
|
|
130115
130489
|
state.serializedHeapIds.add(id);
|
|
130116
|
-
if (
|
|
130490
|
+
if (isSandboxDate(value)) {
|
|
130491
|
+
state.heap[String(id)] = { kind: "date", time: serializedDateTime(value) };
|
|
130492
|
+
} else if (isFloat32Array(value)) {
|
|
130117
130493
|
const storage2 = encodeFloat32Storage(value, id, state.float32Buffers, (id2) => ({
|
|
130118
130494
|
kind: "ref",
|
|
130119
130495
|
id: id2
|
|
@@ -130170,7 +130546,7 @@ function indexHeapContainers(snapshot2) {
|
|
|
130170
130546
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
130171
130547
|
let nextId = 1;
|
|
130172
130548
|
for (const [value, stat35] of stats2.entries()) {
|
|
130173
|
-
if (stat35.count > 1 || stat35.cyclic || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
130549
|
+
if (stat35.count > 1 || stat35.cyclic || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
130174
130550
|
heapIds.set(value, nextId);
|
|
130175
130551
|
nextId += 1;
|
|
130176
130552
|
}
|
|
@@ -130181,7 +130557,7 @@ function collectContainerStats(value, stats2, ancestors) {
|
|
|
130181
130557
|
if (value === null || typeof value !== "object") {
|
|
130182
130558
|
return;
|
|
130183
130559
|
}
|
|
130184
|
-
if (!Array.isArray(value) && !isPlainObject10(value) && !isFloat32Array(value)) {
|
|
130560
|
+
if (!Array.isArray(value) && !isPlainObject10(value) && !isFloat32Array(value) && !isSandboxDate(value)) {
|
|
130185
130561
|
return;
|
|
130186
130562
|
}
|
|
130187
130563
|
let stat35 = stats2.get(value);
|
|
@@ -130252,6 +130628,7 @@ var init_dump_format = __esm({
|
|
|
130252
130628
|
init_arrays();
|
|
130253
130629
|
init_float32();
|
|
130254
130630
|
init_float32array();
|
|
130631
|
+
init_date();
|
|
130255
130632
|
DUMP_FORMAT_VERSION = 1;
|
|
130256
130633
|
EXECUTION_SEMANTICS = "jobs-v7";
|
|
130257
130634
|
SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
@@ -130259,7 +130636,7 @@ var init_dump_format = __esm({
|
|
|
130259
130636
|
});
|
|
130260
130637
|
|
|
130261
130638
|
// packages/safe-js/src/snapshot/validation.ts
|
|
130262
|
-
import { types as
|
|
130639
|
+
import { types as types4 } from "node:util";
|
|
130263
130640
|
function validateSnapshotData(value) {
|
|
130264
130641
|
validateGenericValue(value, "$", 0, {
|
|
130265
130642
|
allowFunctions: false,
|
|
@@ -130305,6 +130682,10 @@ function validateDumpHeap(root, state) {
|
|
|
130305
130682
|
addUnique2(heapIds, id, path193);
|
|
130306
130683
|
const entry = requireRecord3(value, path193);
|
|
130307
130684
|
validateErrorType(entry, path193);
|
|
130685
|
+
if (entry.kind === "date") {
|
|
130686
|
+
validateDateRecord(entry, path193);
|
|
130687
|
+
continue;
|
|
130688
|
+
}
|
|
130308
130689
|
if (entry.kind === "float32array") {
|
|
130309
130690
|
validateFloat32Storage(entry);
|
|
130310
130691
|
requireRecord3(entry.entries, `${path193}.entries`);
|
|
@@ -130462,6 +130843,14 @@ function validateGeneratorShape(record2, path193, state) {
|
|
|
130462
130843
|
}
|
|
130463
130844
|
});
|
|
130464
130845
|
}
|
|
130846
|
+
function validateDateRecord(record2, path193) {
|
|
130847
|
+
if (Object.keys(record2).length !== 2) fail2("invalidValue", path193, "invalid Date fields");
|
|
130848
|
+
try {
|
|
130849
|
+
restoreDateTime(record2.time);
|
|
130850
|
+
} catch {
|
|
130851
|
+
fail2("invalidValue", `${path193}.time`, "invalid Date epoch");
|
|
130852
|
+
}
|
|
130853
|
+
}
|
|
130465
130854
|
function validateArrayHeap(record2, path193, state) {
|
|
130466
130855
|
if (Object.hasOwn(record2, "items")) {
|
|
130467
130856
|
requireArray(record2.items, `${path193}.items`, state);
|
|
@@ -130545,7 +130934,7 @@ function validateGenericValue(value, path193, depth, state) {
|
|
|
130545
130934
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
|
|
130546
130935
|
fail2("invalidState", path193, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
130547
130936
|
}
|
|
130548
|
-
if (state.dataPropertiesOnly &&
|
|
130937
|
+
if (state.dataPropertiesOnly && types4.isProxy(value)) {
|
|
130549
130938
|
fail2("invalidType", path193, "proxy objects are not snapshot data");
|
|
130550
130939
|
}
|
|
130551
130940
|
if (depth > state.limits.maxDepth)
|
|
@@ -130679,6 +131068,7 @@ var init_validation = __esm({
|
|
|
130679
131068
|
init_dump_format();
|
|
130680
131069
|
init_graph_depth();
|
|
130681
131070
|
init_float32array();
|
|
131071
|
+
init_date();
|
|
130682
131072
|
init_object_model();
|
|
130683
131073
|
DEFAULT_MAX_DEPTH = MAX_DATA_DEPTH;
|
|
130684
131074
|
DEFAULT_MAX_ENTRIES = 1e5;
|
|
@@ -131577,6 +131967,7 @@ var init_known_globals = __esm({
|
|
|
131577
131967
|
"AggregateError",
|
|
131578
131968
|
"Array",
|
|
131579
131969
|
"Boolean",
|
|
131970
|
+
"Date",
|
|
131580
131971
|
"Error",
|
|
131581
131972
|
"Infinity",
|
|
131582
131973
|
"isFinite",
|
|
@@ -136840,9 +137231,9 @@ var init_AS_floating_promise = __esm({
|
|
|
136840
137231
|
isPromiseFactoryCall(node) {
|
|
136841
137232
|
return this.isPromiseStaticMethodCall(node, PROMISE_FACTORIES);
|
|
136842
137233
|
}
|
|
136843
|
-
isPromiseStaticMethodCall(node,
|
|
137234
|
+
isPromiseStaticMethodCall(node, methodNames2) {
|
|
136844
137235
|
const member = node.callee.type === "MemberExpression" ? node.callee : void 0;
|
|
136845
|
-
return member !== void 0 && !member.computed && member.object.type === "Identifier" && member.object.name === "Promise" && member.property.type === "Identifier" &&
|
|
137236
|
+
return member !== void 0 && !member.computed && member.object.type === "Identifier" && member.object.name === "Promise" && member.property.type === "Identifier" && methodNames2.has(member.property.name);
|
|
136846
137237
|
}
|
|
136847
137238
|
isPromiseChainCall(node) {
|
|
136848
137239
|
const member = node.callee.type === "MemberExpression" ? node.callee : void 0;
|
|
@@ -142572,6 +142963,95 @@ var init_var_hoist = __esm({
|
|
|
142572
142963
|
}
|
|
142573
142964
|
});
|
|
142574
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
|
+
|
|
142575
143055
|
// packages/safe-js/src/interp/methods/array.ts
|
|
142576
143056
|
function getArrayMember(value, property, options) {
|
|
142577
143057
|
const index = getArrayIndex(property);
|
|
@@ -144724,6 +145204,110 @@ var init_float32array2 = __esm({
|
|
|
144724
145204
|
}
|
|
144725
145205
|
});
|
|
144726
145206
|
|
|
145207
|
+
// packages/safe-js/src/interp/globals/date.ts
|
|
145208
|
+
function createDateGlobal(options) {
|
|
145209
|
+
const validateClockTime = (value) => {
|
|
145210
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || Math.abs(value) > 864e13)
|
|
145211
|
+
throw new TypeError("Date clock must return a finite integer epoch within the Date range.");
|
|
145212
|
+
return value;
|
|
145213
|
+
};
|
|
145214
|
+
const readNow = declareHostOperation(
|
|
145215
|
+
() => {
|
|
145216
|
+
options.budget.visitNode();
|
|
145217
|
+
const value = options.clock?.now === void 0 ? Date.now() : options.clock.now();
|
|
145218
|
+
return validateClockTime(value);
|
|
145219
|
+
},
|
|
145220
|
+
"re-issue",
|
|
145221
|
+
{
|
|
145222
|
+
onReplay: (_args, outcome) => {
|
|
145223
|
+
if (outcome.status === "fulfilled") {
|
|
145224
|
+
const time = validateClockTime(outcome.value);
|
|
145225
|
+
options.clock?.restore?.({ next: time + 1 });
|
|
145226
|
+
}
|
|
145227
|
+
}
|
|
145228
|
+
}
|
|
145229
|
+
);
|
|
145230
|
+
const now = wrapCallerInjectedBindings({ now: readNow }, { ...options, moduleId: "<Date>" }).now;
|
|
145231
|
+
const prototype = createSandboxDate(NaN);
|
|
145232
|
+
const constructor = createSandboxClosure({
|
|
145233
|
+
sandbox: true,
|
|
145234
|
+
name: "Date",
|
|
145235
|
+
length: 7,
|
|
145236
|
+
call: async (_args, context) => options.budget.allocateString(
|
|
145237
|
+
dateString(createSandboxDate(Number(await now.call([], context))))
|
|
145238
|
+
),
|
|
145239
|
+
construct: async (args, context) => {
|
|
145240
|
+
let time;
|
|
145241
|
+
if (args.length === 0) time = Number(await now.call([], context));
|
|
145242
|
+
else if (args.length > 1) time = dateFromParts(args, false);
|
|
145243
|
+
else if (isSandboxDate(args[0])) time = dateTime(args[0]);
|
|
145244
|
+
else if (typeof args[0] === "string") time = parseDate2(args[0], options.budget);
|
|
145245
|
+
else time = dateNumber(args[0]);
|
|
145246
|
+
options.budget.chargeDataUsage(9);
|
|
145247
|
+
return createSandboxDate(time);
|
|
145248
|
+
},
|
|
145249
|
+
properties: {
|
|
145250
|
+
now,
|
|
145251
|
+
prototype,
|
|
145252
|
+
parse: createSandboxClosure({
|
|
145253
|
+
sandbox: true,
|
|
145254
|
+
name: "parse",
|
|
145255
|
+
length: 1,
|
|
145256
|
+
call: ([value]) => parseDate2(value, options.budget)
|
|
145257
|
+
}),
|
|
145258
|
+
UTC: createSandboxClosure({
|
|
145259
|
+
sandbox: true,
|
|
145260
|
+
name: "UTC",
|
|
145261
|
+
length: 7,
|
|
145262
|
+
call: (args) => dateFromParts(args, true)
|
|
145263
|
+
})
|
|
145264
|
+
}
|
|
145265
|
+
});
|
|
145266
|
+
const methods = /* @__PURE__ */ new Map();
|
|
145267
|
+
for (const [name, method] of dateMethods)
|
|
145268
|
+
methods.set(
|
|
145269
|
+
name,
|
|
145270
|
+
createSandboxClosure({
|
|
145271
|
+
sandbox: true,
|
|
145272
|
+
name,
|
|
145273
|
+
length: method.length,
|
|
145274
|
+
call: (args, context) => {
|
|
145275
|
+
const receiver = context?.thisValue;
|
|
145276
|
+
if (!isSandboxDate(receiver))
|
|
145277
|
+
throw new TypeError(`Date#${name} requires a Date receiver.`);
|
|
145278
|
+
options.budget.visitNode();
|
|
145279
|
+
const value = method.invoke(receiver, args);
|
|
145280
|
+
return typeof value === "string" ? options.budget.allocateString(value) : value;
|
|
145281
|
+
}
|
|
145282
|
+
})
|
|
145283
|
+
);
|
|
145284
|
+
constructors2.add(constructor);
|
|
145285
|
+
intrinsics.set(options.compileOwner ?? options.budget, { constructor, prototype, methods });
|
|
145286
|
+
return constructor;
|
|
145287
|
+
}
|
|
145288
|
+
function isDateConstructor(value) {
|
|
145289
|
+
return typeof value === "object" && value !== null && constructors2.has(value);
|
|
145290
|
+
}
|
|
145291
|
+
function getDateMember(property, budget, owner) {
|
|
145292
|
+
const state = intrinsics.get(owner ?? budget);
|
|
145293
|
+
return property === "constructor" ? state?.constructor : state?.methods.get(String(property));
|
|
145294
|
+
}
|
|
145295
|
+
function getDatePrototype(value, budget, owner) {
|
|
145296
|
+
const prototype = intrinsics.get(owner ?? budget)?.prototype;
|
|
145297
|
+
return prototype === value ? null : prototype ?? null;
|
|
145298
|
+
}
|
|
145299
|
+
var intrinsics, constructors2;
|
|
145300
|
+
var init_date2 = __esm({
|
|
145301
|
+
"packages/safe-js/src/interp/globals/date.ts"() {
|
|
145302
|
+
"use strict";
|
|
145303
|
+
init_date();
|
|
145304
|
+
init_host_bridge();
|
|
145305
|
+
init_values();
|
|
145306
|
+
intrinsics = /* @__PURE__ */ new WeakMap();
|
|
145307
|
+
constructors2 = /* @__PURE__ */ new WeakSet();
|
|
145308
|
+
}
|
|
145309
|
+
});
|
|
145310
|
+
|
|
144727
145311
|
// packages/safe-js/src/interp/scope.ts
|
|
144728
145312
|
function defineSnapshotBinding(target, name, value) {
|
|
144729
145313
|
Object.defineProperty(target, name, {
|
|
@@ -145230,6 +145814,9 @@ async function evaluateObjectExpression(node, context) {
|
|
|
145230
145814
|
return value;
|
|
145231
145815
|
}
|
|
145232
145816
|
if (isObjectPrototypeSetterProperty(property, key3.value)) {
|
|
145817
|
+
if (value.value === null || typeof value.value === "object") {
|
|
145818
|
+
setSandboxPrototype(object, value.value, context.budget);
|
|
145819
|
+
}
|
|
145233
145820
|
continue;
|
|
145234
145821
|
}
|
|
145235
145822
|
defineSandboxProperty(object, String(key3.value), value.value);
|
|
@@ -145351,7 +145938,11 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
145351
145938
|
if (right.kind !== "normal") {
|
|
145352
145939
|
return right;
|
|
145353
145940
|
}
|
|
145354
|
-
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);
|
|
145355
145946
|
return {
|
|
145356
145947
|
kind: "normal",
|
|
145357
145948
|
hasValue: true,
|
|
@@ -146034,7 +146625,7 @@ function forInKeys(object, budget) {
|
|
|
146034
146625
|
const keys = [];
|
|
146035
146626
|
const seen = /* @__PURE__ */ new Set();
|
|
146036
146627
|
let depth = 0;
|
|
146037
|
-
for (let current = object; current !== null; current = getSandboxPrototype(current)) {
|
|
146628
|
+
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
146038
146629
|
if (depth > 0) budget.visitNode();
|
|
146039
146630
|
assertSandboxDataDepth(depth++);
|
|
146040
146631
|
const properties = isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : current;
|
|
@@ -146048,9 +146639,9 @@ function forInKeys(object, budget) {
|
|
|
146048
146639
|
return keys;
|
|
146049
146640
|
}
|
|
146050
146641
|
function hasForInProperty(object, key3, budget) {
|
|
146051
|
-
if (isGuestHostObject(object)) return
|
|
146642
|
+
if (isGuestHostObject(object)) return hasHostObjectMember(object, key3, true);
|
|
146052
146643
|
let depth = 0;
|
|
146053
|
-
for (let current = object; current !== null; current = getSandboxPrototype(current)) {
|
|
146644
|
+
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
146054
146645
|
if (depth > 0) budget.visitNode();
|
|
146055
146646
|
assertSandboxDataDepth(depth++);
|
|
146056
146647
|
const properties = isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : current;
|
|
@@ -146545,6 +147136,7 @@ function getPropertyValue(target, property, context) {
|
|
|
146545
147136
|
if (typeof target === "number") return getNumberMember(target, property, context.budget);
|
|
146546
147137
|
if (typeof target === "boolean") return void 0;
|
|
146547
147138
|
if (isFloat32Array(target)) return getFloat32Member(target, property, context.budget);
|
|
147139
|
+
if (isSandboxDate(target)) return getDateMember(property, context.budget, context.compilation?.owner);
|
|
146548
147140
|
if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
|
|
146549
147141
|
if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
|
|
146550
147142
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
@@ -146781,6 +147373,9 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
146781
147373
|
context
|
|
146782
147374
|
);
|
|
146783
147375
|
}
|
|
147376
|
+
if (isSandboxDate(member.object)) {
|
|
147377
|
+
return evaluateResolvedCallExpression(node, getDateMember(member.property, context.budget, context.compilation?.owner), context, member.object);
|
|
147378
|
+
}
|
|
146784
147379
|
if (isFloat32Array(member.object)) {
|
|
146785
147380
|
return evaluateResolvedCallExpression(
|
|
146786
147381
|
node,
|
|
@@ -147033,6 +147628,7 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
147033
147628
|
return true;
|
|
147034
147629
|
}
|
|
147035
147630
|
if (isFloat32ArrayConstructor(right)) return isFloat32Array(left);
|
|
147631
|
+
if (isDateConstructor(right)) return isSandboxDate(left) && getDatePrototype(left, context.budget, context.compilation?.owner) !== null;
|
|
147036
147632
|
if (isSandboxSetConstructor(right) && isSandboxSet(left)) {
|
|
147037
147633
|
return true;
|
|
147038
147634
|
}
|
|
@@ -147046,7 +147642,7 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
147046
147642
|
throw new TypeError("Function has a non-object prototype in instanceof check.");
|
|
147047
147643
|
}
|
|
147048
147644
|
let depth = 0;
|
|
147049
|
-
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)) {
|
|
147050
147646
|
context.budget.visitNode();
|
|
147051
147647
|
assertSandboxDataDepth(depth++);
|
|
147052
147648
|
if (current === prototype) return true;
|
|
@@ -147096,8 +147692,8 @@ function applyAdditionOperator(left, right, context) {
|
|
|
147096
147692
|
return toNumber(leftPrimitive) + toNumber(rightPrimitive);
|
|
147097
147693
|
}
|
|
147098
147694
|
function compareRelational(left, right, operator) {
|
|
147099
|
-
const leftPrimitive = toPrimitive(left);
|
|
147100
|
-
const rightPrimitive = toPrimitive(right);
|
|
147695
|
+
const leftPrimitive = isSandboxDate(left) ? dateTime(left) : toPrimitive(left);
|
|
147696
|
+
const rightPrimitive = isSandboxDate(right) ? dateTime(right) : toPrimitive(right);
|
|
147101
147697
|
if (typeof leftPrimitive === "string" && typeof rightPrimitive === "string") {
|
|
147102
147698
|
switch (operator) {
|
|
147103
147699
|
case "<":
|
|
@@ -147180,6 +147776,7 @@ function toPrimitive(value) {
|
|
|
147180
147776
|
return toString(value);
|
|
147181
147777
|
}
|
|
147182
147778
|
async function toNumericPrimitive(value, context) {
|
|
147779
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
147183
147780
|
if (isPrimitiveCoercionType(getCoercionType(value))) {
|
|
147184
147781
|
return value;
|
|
147185
147782
|
}
|
|
@@ -147209,6 +147806,7 @@ async function toNumericPrimitive(value, context) {
|
|
|
147209
147806
|
return toString(value);
|
|
147210
147807
|
}
|
|
147211
147808
|
function toNumber(value) {
|
|
147809
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
147212
147810
|
if (typeof value === "number") {
|
|
147213
147811
|
return value;
|
|
147214
147812
|
}
|
|
@@ -147227,6 +147825,7 @@ function toNumber(value) {
|
|
|
147227
147825
|
return toNumber(toPrimitive(value));
|
|
147228
147826
|
}
|
|
147229
147827
|
function toString(value) {
|
|
147828
|
+
if (isSandboxDate(value)) return dateString(value);
|
|
147230
147829
|
if (Array.isArray(value)) {
|
|
147231
147830
|
return value.map((entry) => entry === null || entry === void 0 ? "" : toString(entry)).join(",");
|
|
147232
147831
|
}
|
|
@@ -147257,7 +147856,7 @@ function getMemberValue(target, property, context) {
|
|
|
147257
147856
|
return getPropertyValue(current, property, context);
|
|
147258
147857
|
}
|
|
147259
147858
|
if (Object.hasOwn(current, String(property))) return current[String(property)];
|
|
147260
|
-
current = getSandboxPrototype(current);
|
|
147859
|
+
current = getSandboxPrototype(current, context.budget);
|
|
147261
147860
|
if (current !== null) {
|
|
147262
147861
|
context.budget.visitNode();
|
|
147263
147862
|
assertSandboxDataDepth(++depth);
|
|
@@ -147272,6 +147871,7 @@ function getArrayMemberValue(target, property, context) {
|
|
|
147272
147871
|
return getArrayMember(target, property, createArrayMethodOptions(context));
|
|
147273
147872
|
}
|
|
147274
147873
|
function setSandboxProperty(target, property, value, budget) {
|
|
147874
|
+
if (isSandboxDate(target)) throw new TypeError("Date own properties are not supported.");
|
|
147275
147875
|
if (isGuestHostObject(target)) {
|
|
147276
147876
|
setHostObjectMember(target, String(property), value);
|
|
147277
147877
|
return;
|
|
@@ -147306,7 +147906,7 @@ function setSandboxProperty(target, property, value, budget) {
|
|
|
147306
147906
|
} else {
|
|
147307
147907
|
if (typeof prototypeOwner === "object" && prototypeOwner !== null) {
|
|
147308
147908
|
let depth = 0;
|
|
147309
|
-
for (let prototype = getSandboxPrototype(prototypeOwner); prototype !== null; prototype = getSandboxPrototype(prototype)) {
|
|
147909
|
+
for (let prototype = getSandboxPrototype(prototypeOwner, budget); prototype !== null; prototype = getSandboxPrototype(prototype, budget)) {
|
|
147310
147910
|
budget.visitNode();
|
|
147311
147911
|
assertSandboxDataDepth(depth++);
|
|
147312
147912
|
const properties = isSandboxClosure(prototype) ? prototype.properties : prototype;
|
|
@@ -147500,6 +148100,13 @@ async function evaluateObjectSpread(node, context) {
|
|
|
147500
148100
|
value: []
|
|
147501
148101
|
};
|
|
147502
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
|
+
}
|
|
147503
148110
|
if (isSandboxClosure(value.value) && !isGuestClosure(value.value) || isSandboxPromise(value.value)) {
|
|
147504
148111
|
throw new TypeError(
|
|
147505
148112
|
`Cannot spread ${describeObjectSpreadValue(value.value)} into object literal.`
|
|
@@ -147576,6 +148183,7 @@ var init_interpreter = __esm({
|
|
|
147576
148183
|
"use strict";
|
|
147577
148184
|
init_promise_replay();
|
|
147578
148185
|
init_host_capabilities();
|
|
148186
|
+
init_string_coercion();
|
|
147579
148187
|
init_promise_tracker();
|
|
147580
148188
|
init_jobs4();
|
|
147581
148189
|
init_cancel2();
|
|
@@ -147603,6 +148211,8 @@ var init_interpreter = __esm({
|
|
|
147603
148211
|
init_collections();
|
|
147604
148212
|
init_float32array2();
|
|
147605
148213
|
init_float32();
|
|
148214
|
+
init_date();
|
|
148215
|
+
init_date2();
|
|
147606
148216
|
init_values();
|
|
147607
148217
|
init_scope();
|
|
147608
148218
|
init_var_hoist();
|
|
@@ -147770,6 +148380,7 @@ function createInterpretedClosure(node, context, evaluateNode3) {
|
|
|
147770
148380
|
function createGeneratorClosure(node, context, evaluateNode3) {
|
|
147771
148381
|
return createSandboxClosure({
|
|
147772
148382
|
guest: true,
|
|
148383
|
+
generator: true,
|
|
147773
148384
|
sandbox: true,
|
|
147774
148385
|
length: getFunctionLength(node.params),
|
|
147775
148386
|
...node.id === void 0 ? {} : { name: node.id.name },
|
|
@@ -148021,7 +148632,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
148021
148632
|
seen: /* @__PURE__ */ new WeakMap(),
|
|
148022
148633
|
restored: []
|
|
148023
148634
|
};
|
|
148024
|
-
const
|
|
148635
|
+
const copyArguments = (values) => deepCopyFromSandbox([...values], {
|
|
148025
148636
|
compilation,
|
|
148026
148637
|
unwrapHostObject: options.realm === void 0 ? void 0 : (object) => exportHostCapability(object, options.realm.owner),
|
|
148027
148638
|
wrapClosure: (closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
@@ -148032,13 +148643,21 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
148032
148643
|
callbacks
|
|
148033
148644
|
)
|
|
148034
148645
|
});
|
|
148646
|
+
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
148647
|
+
const hostArgs = captured?.args ?? copyArguments(args);
|
|
148035
148648
|
const hostCalls = options.hostCalls;
|
|
148036
148649
|
const operation = options.operation ?? bindingName;
|
|
148037
148650
|
const moduleId = options.moduleId ?? "<bindings>";
|
|
148038
148651
|
const policy = readHostOperationPolicy(value) ?? readRegisteredPendingHostCallPolicy(moduleId, operation) ?? "re-issue";
|
|
148039
148652
|
if (hostCalls === void 0) {
|
|
148040
148653
|
if (options.realm !== void 0) {
|
|
148041
|
-
|
|
148654
|
+
let result;
|
|
148655
|
+
try {
|
|
148656
|
+
result = options.realm.invoke(callable, () => Reflect.apply(callable, void 0, hostArgs));
|
|
148657
|
+
} catch (error3) {
|
|
148658
|
+
captured.rollback();
|
|
148659
|
+
throw error3;
|
|
148660
|
+
}
|
|
148042
148661
|
if (options.realm.awaitResult(callable)) {
|
|
148043
148662
|
return Promise.resolve(result).then((value2) => copyHostResultToSandbox(value2, stackFrames, options));
|
|
148044
148663
|
}
|
|
@@ -148626,6 +149245,14 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path193) {
|
|
|
148626
149245
|
state
|
|
148627
149246
|
);
|
|
148628
149247
|
}
|
|
149248
|
+
const date = copyNativeDate(value);
|
|
149249
|
+
if (date !== void 0) {
|
|
149250
|
+
const existing = state.seen.get(value);
|
|
149251
|
+
if (existing !== void 0) return existing;
|
|
149252
|
+
budget.chargeDataUsage(9);
|
|
149253
|
+
state.seen.set(value, date);
|
|
149254
|
+
return date;
|
|
149255
|
+
}
|
|
148629
149256
|
if (isFloat32Array(value)) {
|
|
148630
149257
|
const existing = state.seen.get(value);
|
|
148631
149258
|
if (existing !== void 0) return existing;
|
|
@@ -148907,6 +149534,7 @@ var init_host_bridge = __esm({
|
|
|
148907
149534
|
"packages/safe-js/src/interp/host-bridge.ts"() {
|
|
148908
149535
|
"use strict";
|
|
148909
149536
|
init_async();
|
|
149537
|
+
init_date();
|
|
148910
149538
|
init_host_capabilities();
|
|
148911
149539
|
init_shape();
|
|
148912
149540
|
init_budget2();
|
|
@@ -149046,7 +149674,9 @@ function toJsonParseText(input) {
|
|
|
149046
149674
|
}
|
|
149047
149675
|
async function stringifyProperty(key3, holder, state, indent = "") {
|
|
149048
149676
|
let value = getOwnDataValue(holder, key3);
|
|
149049
|
-
if (
|
|
149677
|
+
if (isSandboxDate(value)) {
|
|
149678
|
+
value = dateMethods.get("toJSON").invoke(value, []);
|
|
149679
|
+
} else if (isStringifyContainer(value)) {
|
|
149050
149680
|
const toJSON = getOwnDataValue(value, "toJSON");
|
|
149051
149681
|
if (isSandboxClosure(toJSON)) {
|
|
149052
149682
|
value = await callStringifyClosure(toJSON, [key3], value, state);
|
|
@@ -149081,7 +149711,7 @@ async function stringifyValue3(value, state, indent) {
|
|
|
149081
149711
|
return stringifyArray(value, state, indent);
|
|
149082
149712
|
}
|
|
149083
149713
|
if (isStringifyObject(value)) {
|
|
149084
|
-
return
|
|
149714
|
+
return stringifyObject2(value, state, indent);
|
|
149085
149715
|
}
|
|
149086
149716
|
return void 0;
|
|
149087
149717
|
}
|
|
@@ -149107,7 +149737,7 @@ ${indent}]`;
|
|
|
149107
149737
|
leaveStringifyObject(value, state);
|
|
149108
149738
|
}
|
|
149109
149739
|
}
|
|
149110
|
-
async function
|
|
149740
|
+
async function stringifyObject2(value, state, indent) {
|
|
149111
149741
|
enterStringifyObject(value, state);
|
|
149112
149742
|
try {
|
|
149113
149743
|
const nextIndent = indent + state.gap;
|
|
@@ -149232,6 +149862,7 @@ function defineDataProperty8(target, key3, value) {
|
|
|
149232
149862
|
var init_console_json = __esm({
|
|
149233
149863
|
"packages/safe-js/src/interp/globals/console-json.ts"() {
|
|
149234
149864
|
"use strict";
|
|
149865
|
+
init_date();
|
|
149235
149866
|
init_compile_guard();
|
|
149236
149867
|
init_host_bridge();
|
|
149237
149868
|
init_values();
|
|
@@ -149457,89 +150088,143 @@ var init_misc = __esm({
|
|
|
149457
150088
|
}
|
|
149458
150089
|
});
|
|
149459
150090
|
|
|
149460
|
-
// packages/safe-js/src/interp/
|
|
149461
|
-
function
|
|
149462
|
-
|
|
149463
|
-
if (
|
|
149464
|
-
|
|
149465
|
-
|
|
149466
|
-
return stringifyObject2(value, budget, context, joining);
|
|
149467
|
-
}
|
|
149468
|
-
async function stringifyObject2(value, budget, context, joining) {
|
|
149469
|
-
const leaveCall = budget.enterCall();
|
|
149470
|
-
try {
|
|
149471
|
-
budget.visitNode();
|
|
149472
|
-
for (const name of ["toString", "valueOf"]) {
|
|
149473
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
149474
|
-
let result;
|
|
149475
|
-
if (descriptor === void 0) {
|
|
149476
|
-
if (name === "valueOf") continue;
|
|
149477
|
-
result = await defaultToString(value, budget, context, joining);
|
|
149478
|
-
} else {
|
|
149479
|
-
const hook = ownDataValue(value, name);
|
|
149480
|
-
if (!isSandboxClosure(hook)) continue;
|
|
149481
|
-
if (context?.invokeClosure === void 0) {
|
|
149482
|
-
throw new TypeError("String hooks require a sandbox call context.");
|
|
149483
|
-
}
|
|
149484
|
-
result = await context.invokeClosure(hook, [], value);
|
|
149485
|
-
}
|
|
149486
|
-
if (result === null || typeof result !== "object") {
|
|
149487
|
-
return sandboxString(result, budget, context, joining);
|
|
149488
|
-
}
|
|
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);
|
|
149489
150097
|
}
|
|
149490
|
-
throw new TypeError("
|
|
149491
|
-
|
|
149492
|
-
|
|
149493
|
-
|
|
149494
|
-
|
|
149495
|
-
|
|
149496
|
-
|
|
149497
|
-
|
|
149498
|
-
|
|
149499
|
-
|
|
149500
|
-
|
|
149501
|
-
|
|
149502
|
-
|
|
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;
|
|
149503
150131
|
}
|
|
149504
|
-
|
|
149505
|
-
|
|
149506
|
-
|
|
149507
|
-
|
|
149508
|
-
|
|
149509
|
-
|
|
149510
|
-
|
|
149511
|
-
|
|
149512
|
-
|
|
149513
|
-
|
|
149514
|
-
|
|
149515
|
-
|
|
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;
|
|
149516
150167
|
}
|
|
149517
|
-
|
|
149518
|
-
|
|
149519
|
-
|
|
149520
|
-
}
|
|
149521
|
-
}
|
|
149522
|
-
if (sandboxErrorTypes.has(value)) {
|
|
149523
|
-
const nameValue = ownDataValue(value, "name");
|
|
149524
|
-
const name = nameValue === void 0 ? "Error" : await sandboxString(nameValue, budget, context, joining);
|
|
149525
|
-
const messageValue2 = ownDataValue(value, "message");
|
|
149526
|
-
const message2 = messageValue2 === void 0 ? "" : await sandboxString(messageValue2, budget, context, joining);
|
|
149527
|
-
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 });
|
|
149528
150172
|
}
|
|
149529
|
-
|
|
150173
|
+
markDescriptorObject(prototype);
|
|
150174
|
+
installObjectPrototype(budget, prototype, constructor);
|
|
150175
|
+
return constructor;
|
|
149530
150176
|
}
|
|
149531
|
-
function
|
|
149532
|
-
|
|
149533
|
-
|
|
149534
|
-
|
|
149535
|
-
}
|
|
149536
|
-
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;
|
|
149537
150181
|
}
|
|
149538
|
-
|
|
149539
|
-
|
|
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"() {
|
|
149540
150220
|
"use strict";
|
|
149541
|
-
|
|
150221
|
+
init_graph_depth();
|
|
150222
|
+
init_date();
|
|
150223
|
+
init_exceptions();
|
|
149542
150224
|
init_float32();
|
|
150225
|
+
init_host_capabilities();
|
|
150226
|
+
init_object_model();
|
|
150227
|
+
init_string_coercion();
|
|
149543
150228
|
init_values();
|
|
149544
150229
|
}
|
|
149545
150230
|
});
|
|
@@ -149547,7 +150232,7 @@ var init_string_coercion = __esm({
|
|
|
149547
150232
|
// packages/safe-js/src/interp/globals/object-array.ts
|
|
149548
150233
|
function createObjectArrayGlobals(options) {
|
|
149549
150234
|
return {
|
|
149550
|
-
Object: {
|
|
150235
|
+
Object: createObjectGlobal({
|
|
149551
150236
|
keys: createSandboxClosure({
|
|
149552
150237
|
sandbox: true,
|
|
149553
150238
|
call: ([value]) => budgetSandboxValue2(getOwnEnumerableKeys(value), options.budget),
|
|
@@ -149565,7 +150250,11 @@ function createObjectArrayGlobals(options) {
|
|
|
149565
150250
|
}),
|
|
149566
150251
|
hasOwn: createSandboxClosure({
|
|
149567
150252
|
sandbox: true,
|
|
149568
|
-
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
|
+
},
|
|
149569
150258
|
name: "hasOwn"
|
|
149570
150259
|
}),
|
|
149571
150260
|
getOwnPropertyDescriptor: createSandboxClosure({
|
|
@@ -149604,8 +150293,9 @@ function createObjectArrayGlobals(options) {
|
|
|
149604
150293
|
getPrototypeOf: createSandboxClosure({
|
|
149605
150294
|
sandbox: true,
|
|
149606
150295
|
call: ([value]) => {
|
|
150296
|
+
if (isSandboxDate(value)) return getDatePrototype(value, options.budget, options.compileOwner);
|
|
149607
150297
|
objectProperties(value);
|
|
149608
|
-
return getSandboxPrototype(value);
|
|
150298
|
+
return getSandboxPrototype(value, options.budget);
|
|
149609
150299
|
},
|
|
149610
150300
|
name: "getPrototypeOf"
|
|
149611
150301
|
}),
|
|
@@ -149663,6 +150353,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149663
150353
|
freeze: createSandboxClosure({
|
|
149664
150354
|
sandbox: true,
|
|
149665
150355
|
call: ([value]) => {
|
|
150356
|
+
if (isGuestHostObject(value)) throw new TypeError("Live host objects cannot be frozen.");
|
|
149666
150357
|
if (typeof value === "object" && value !== null) {
|
|
149667
150358
|
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
149668
150359
|
}
|
|
@@ -149680,7 +150371,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149680
150371
|
call: ([target, ...sources]) => assignSandboxValues(target, sources, options.budget),
|
|
149681
150372
|
name: "assign"
|
|
149682
150373
|
})
|
|
149683
|
-
},
|
|
150374
|
+
}, options.budget),
|
|
149684
150375
|
Array: createSandboxClosure({
|
|
149685
150376
|
sandbox: true,
|
|
149686
150377
|
call: (args) => createArrayFromConstructorArgs(args, options.budget),
|
|
@@ -149728,7 +150419,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149728
150419
|
}),
|
|
149729
150420
|
Number: createSandboxClosure({
|
|
149730
150421
|
sandbox: true,
|
|
149731
|
-
call: ([value]) => Number(value),
|
|
150422
|
+
call: ([value]) => isSandboxDate(value) ? dateTime(value) : Number(value),
|
|
149732
150423
|
name: "Number",
|
|
149733
150424
|
properties: {
|
|
149734
150425
|
isFinite: createSandboxClosure({
|
|
@@ -149828,6 +150519,10 @@ function assignSandboxValues(target, sources, budget) {
|
|
|
149828
150519
|
return target;
|
|
149829
150520
|
}
|
|
149830
150521
|
function objectProperties(value, mutable = false) {
|
|
150522
|
+
if (isSandboxDate(value)) {
|
|
150523
|
+
if (mutable) throw new TypeError("Date own properties and prototypes are not supported.");
|
|
150524
|
+
return value;
|
|
150525
|
+
}
|
|
149831
150526
|
if (isGuestHostObject(value)) throw new TypeError("Live host object descriptors are not supported.");
|
|
149832
150527
|
if (isGuestClosure(value)) return materializeFunctionProperties(value);
|
|
149833
150528
|
if (isSandboxClosure(value)) {
|
|
@@ -149873,6 +150568,21 @@ function isAssignableSandboxTarget(value) {
|
|
|
149873
150568
|
async function arrayFromSandboxValues(args, budget) {
|
|
149874
150569
|
const [items, mapFn, thisValue] = args;
|
|
149875
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
|
+
}
|
|
149876
150586
|
const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
|
|
149877
150587
|
if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
|
|
149878
150588
|
if (mapFn !== void 0) {
|
|
@@ -149945,6 +150655,9 @@ function getTemplateRawParts(template2) {
|
|
|
149945
150655
|
var init_object_array = __esm({
|
|
149946
150656
|
"packages/safe-js/src/interp/globals/object-array.ts"() {
|
|
149947
150657
|
"use strict";
|
|
150658
|
+
init_date();
|
|
150659
|
+
init_date2();
|
|
150660
|
+
init_object2();
|
|
149948
150661
|
init_host_capabilities();
|
|
149949
150662
|
init_float32();
|
|
149950
150663
|
init_interpreter();
|
|
@@ -149961,6 +150674,7 @@ function createBuiltinBindings(options) {
|
|
|
149961
150674
|
...createConsoleJsonGlobals(options),
|
|
149962
150675
|
...createCollectionGlobals(options),
|
|
149963
150676
|
Float32Array: createFloat32ArrayGlobal(options.budget),
|
|
150677
|
+
Date: createDateGlobal(options),
|
|
149964
150678
|
...createErrorGlobals(options),
|
|
149965
150679
|
...createMathGlobals({ random: options.random }),
|
|
149966
150680
|
...createObjectArrayGlobals(options),
|
|
@@ -149981,6 +150695,7 @@ var init_globals = __esm({
|
|
|
149981
150695
|
init_misc();
|
|
149982
150696
|
init_object_array();
|
|
149983
150697
|
init_promise();
|
|
150698
|
+
init_date2();
|
|
149984
150699
|
}
|
|
149985
150700
|
});
|
|
149986
150701
|
|
|
@@ -150176,10 +150891,10 @@ var init_random = __esm({
|
|
|
150176
150891
|
|
|
150177
150892
|
// packages/safe-js/src/realm.ts
|
|
150178
150893
|
import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
|
|
150179
|
-
import { types as
|
|
150894
|
+
import { types as types5 } from "node:util";
|
|
150180
150895
|
function readModules(input) {
|
|
150181
150896
|
const entries = (value, label) => {
|
|
150182
|
-
if (
|
|
150897
|
+
if (types5.isMap(value) && !types5.isProxy(value)) {
|
|
150183
150898
|
const result = [...Map.prototype.entries.call(value)];
|
|
150184
150899
|
if (result.length > 4096 || result.some(([key3]) => typeof key3 !== "string" || key3.length === 0))
|
|
150185
150900
|
throw new TypeError(`${label} requires bounded string keys.`);
|
|
@@ -150242,6 +150957,7 @@ function readRealmOptions(value, oneShot = false) {
|
|
|
150242
150957
|
"signal",
|
|
150243
150958
|
"sink",
|
|
150244
150959
|
"randomSeed",
|
|
150960
|
+
"clock",
|
|
150245
150961
|
"limits"
|
|
150246
150962
|
]);
|
|
150247
150963
|
for (const [key3, entry] of Object.entries(options)) {
|
|
@@ -150257,6 +150973,7 @@ var init_realm = __esm({
|
|
|
150257
150973
|
init_budget2();
|
|
150258
150974
|
init_compile_guard();
|
|
150259
150975
|
init_globals();
|
|
150976
|
+
init_object_model();
|
|
150260
150977
|
init_interpreter();
|
|
150261
150978
|
init_jobs4();
|
|
150262
150979
|
init_cancel2();
|
|
@@ -150281,6 +150998,7 @@ var init_realm = __esm({
|
|
|
150281
150998
|
extensions: 32,
|
|
150282
150999
|
hostObjects: 1024,
|
|
150283
151000
|
callbacks: 1024,
|
|
151001
|
+
guestReferences: 1024,
|
|
150284
151002
|
cleanups: 1024,
|
|
150285
151003
|
nestedEvaluations: 16
|
|
150286
151004
|
};
|
|
@@ -150289,7 +151007,7 @@ var init_realm = __esm({
|
|
|
150289
151007
|
throw new TypeError("Realm limits must be positive safe integers with supported names.");
|
|
150290
151008
|
this.limits[name] = Number(value);
|
|
150291
151009
|
}
|
|
150292
|
-
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) ||
|
|
151010
|
+
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types5.isProxy(options.extensions)))
|
|
150293
151011
|
throw new TypeError("Extensions must be a registration array.");
|
|
150294
151012
|
const registrations = options.extensions ?? [];
|
|
150295
151013
|
const extensions = [];
|
|
@@ -150317,6 +151035,7 @@ var init_realm = __esm({
|
|
|
150317
151035
|
owner: this,
|
|
150318
151036
|
assertActive: this.assertOpen,
|
|
150319
151037
|
wrapCallback: this.wrapCallback,
|
|
151038
|
+
captureArguments: this.captureArguments,
|
|
150320
151039
|
invoke: this.invokeHost,
|
|
150321
151040
|
awaitResult: (operation) => this.nestedOperations.has(operation)
|
|
150322
151041
|
};
|
|
@@ -150325,6 +151044,7 @@ var init_realm = __esm({
|
|
|
150325
151044
|
budget: this.budget,
|
|
150326
151045
|
compileOwner: this.lease.owner,
|
|
150327
151046
|
sink: options.sink,
|
|
151047
|
+
clock: options.clock,
|
|
150328
151048
|
random: createReplayableRandom({ seed: options.randomSeed }).next
|
|
150329
151049
|
});
|
|
150330
151050
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -150356,9 +151076,10 @@ var init_realm = __esm({
|
|
|
150356
151076
|
}
|
|
150357
151077
|
options.signal?.addEventListener("abort", this.abort, { once: true });
|
|
150358
151078
|
if (options.signal?.aborted) this.abort();
|
|
150359
|
-
this.budget.setRetainedValues(this, this.
|
|
151079
|
+
this.budget.setRetainedValues(this, this.retainedRoots);
|
|
150360
151080
|
this.tracker.onFatalRejection((error3) => this.poison(error3));
|
|
150361
151081
|
} catch (error3) {
|
|
151082
|
+
releaseObjectPrototype(this.budget);
|
|
150362
151083
|
this.compilation.dispose();
|
|
150363
151084
|
this.lease.release();
|
|
150364
151085
|
throw error3;
|
|
@@ -150380,6 +151101,8 @@ var init_realm = __esm({
|
|
|
150380
151101
|
pendingCallbacks = /* @__PURE__ */ new Set();
|
|
150381
151102
|
callbackCache = /* @__PURE__ */ new WeakMap();
|
|
150382
151103
|
hostObjects = /* @__PURE__ */ new Set();
|
|
151104
|
+
guestReferences = /* @__PURE__ */ new Map();
|
|
151105
|
+
retainedOperations = /* @__PURE__ */ new WeakMap();
|
|
150383
151106
|
nestedOperations = /* @__PURE__ */ new WeakMap();
|
|
150384
151107
|
convertedModules = /* @__PURE__ */ new Map();
|
|
150385
151108
|
nativeConversions = { seen: /* @__PURE__ */ new WeakMap() };
|
|
@@ -150399,10 +151122,56 @@ var init_realm = __esm({
|
|
|
150399
151122
|
signal: this.controller.signal,
|
|
150400
151123
|
realm: this.bridge
|
|
150401
151124
|
});
|
|
150402
|
-
|
|
151125
|
+
retainedRoots = () => [
|
|
150403
151126
|
...this.callbacks.values(),
|
|
150404
|
-
...Array.from(this.pendingCallbacks, (pending) => pending.closure)
|
|
151127
|
+
...Array.from(this.pendingCallbacks, (pending) => pending.closure),
|
|
151128
|
+
...this.guestReferences.values()
|
|
150405
151129
|
];
|
|
151130
|
+
captureArguments = (operation, args, copy) => {
|
|
151131
|
+
const from = this.retainedOperations.get(operation)?.from ?? args.length;
|
|
151132
|
+
const values = copy(args.slice(0, from));
|
|
151133
|
+
const captured = [];
|
|
151134
|
+
const rollback = () => {
|
|
151135
|
+
for (const reference of captured) {
|
|
151136
|
+
revokeGuestReference(reference, this);
|
|
151137
|
+
this.guestReferences.delete(reference);
|
|
151138
|
+
}
|
|
151139
|
+
};
|
|
151140
|
+
try {
|
|
151141
|
+
for (const value of args.slice(from)) {
|
|
151142
|
+
this.checkCollection(
|
|
151143
|
+
this.guestReferences.size + 1,
|
|
151144
|
+
this.limits.guestReferences,
|
|
151145
|
+
"guest reference"
|
|
151146
|
+
);
|
|
151147
|
+
const root = [value];
|
|
151148
|
+
const reference = createGuestReference(root, this, this.assertOpen);
|
|
151149
|
+
this.guestReferences.set(reference, root);
|
|
151150
|
+
captured.push(reference);
|
|
151151
|
+
values.push(reference);
|
|
151152
|
+
}
|
|
151153
|
+
if (captured.length > 0)
|
|
151154
|
+
this.budget.reconcileDataUsage(
|
|
151155
|
+
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.retainedRoots()])
|
|
151156
|
+
);
|
|
151157
|
+
return { args: values, rollback };
|
|
151158
|
+
} catch (error3) {
|
|
151159
|
+
rollback();
|
|
151160
|
+
if (error3 instanceof SandboxError) this.poison(error3);
|
|
151161
|
+
throw error3;
|
|
151162
|
+
}
|
|
151163
|
+
};
|
|
151164
|
+
releaseGuestReference = (reference) => {
|
|
151165
|
+
readGuestReference(reference, this);
|
|
151166
|
+
revokeGuestReference(reference, this);
|
|
151167
|
+
this.guestReferences.delete(reference);
|
|
151168
|
+
if (this.active === void 0)
|
|
151169
|
+
reconcileCompiledValues(
|
|
151170
|
+
this.budget,
|
|
151171
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
151172
|
+
this.compilation
|
|
151173
|
+
);
|
|
151174
|
+
};
|
|
150406
151175
|
assertOpen = () => {
|
|
150407
151176
|
if (this.failure !== void 0) throw this.failure.reason;
|
|
150408
151177
|
if (this.closed) throw new Error("SafeJS realm is closed; capabilities are revoked.");
|
|
@@ -150458,7 +151227,7 @@ var init_realm = __esm({
|
|
|
150458
151227
|
return this.phase.run(phase, () => {
|
|
150459
151228
|
try {
|
|
150460
151229
|
const result = call();
|
|
150461
|
-
if (
|
|
151230
|
+
if (types5.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
|
|
150462
151231
|
return Promise.resolve(result).then(
|
|
150463
151232
|
async (value) => {
|
|
150464
151233
|
await Promise.allSettled(phase.pending);
|
|
@@ -150513,17 +151282,26 @@ var init_realm = __esm({
|
|
|
150513
151282
|
owner: this,
|
|
150514
151283
|
assertActive: this.assertOpen,
|
|
150515
151284
|
chargeWork: this.chargeWork,
|
|
150516
|
-
|
|
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) => {
|
|
150517
151295
|
const value = this.invokeHost(operation, operation);
|
|
150518
|
-
if (
|
|
151296
|
+
if (types5.isPromise(value)) {
|
|
150519
151297
|
void Promise.resolve(value).catch(() => void 0);
|
|
150520
151298
|
throw new TypeError("Live property getters must be synchronous.");
|
|
150521
151299
|
}
|
|
150522
|
-
return this.importValue(value);
|
|
151300
|
+
return this.importValue(validate2 === void 0 ? value : validate2(value));
|
|
150523
151301
|
},
|
|
150524
151302
|
write: (operation, value) => {
|
|
150525
151303
|
const result = this.invokeHost(operation, () => operation(this.exportValue(value)));
|
|
150526
|
-
if (
|
|
151304
|
+
if (types5.isPromise(result)) {
|
|
150527
151305
|
void Promise.resolve(result).catch(() => void 0);
|
|
150528
151306
|
throw new TypeError("Live property setters must be synchronous.");
|
|
150529
151307
|
}
|
|
@@ -150570,7 +151348,7 @@ var init_realm = __esm({
|
|
|
150570
151348
|
});
|
|
150571
151349
|
try {
|
|
150572
151350
|
this.budget.reconcileDataUsage(
|
|
150573
|
-
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.
|
|
151351
|
+
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.retainedRoots()])
|
|
150574
151352
|
);
|
|
150575
151353
|
} catch (error3) {
|
|
150576
151354
|
this.poison(error3);
|
|
@@ -150585,7 +151363,7 @@ var init_realm = __esm({
|
|
|
150585
151363
|
if (this.active === void 0)
|
|
150586
151364
|
reconcileCompiledValues(
|
|
150587
151365
|
this.budget,
|
|
150588
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
151366
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150589
151367
|
this.compilation
|
|
150590
151368
|
);
|
|
150591
151369
|
};
|
|
@@ -150644,7 +151422,7 @@ var init_realm = __esm({
|
|
|
150644
151422
|
if (!this.closed && this.active === void 0)
|
|
150645
151423
|
reconcileCompiledValues(
|
|
150646
151424
|
this.budget,
|
|
150647
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
151425
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150648
151426
|
this.compilation
|
|
150649
151427
|
);
|
|
150650
151428
|
}
|
|
@@ -150661,6 +151439,23 @@ var init_realm = __esm({
|
|
|
150661
151439
|
createHostObject: this.createHostObject,
|
|
150662
151440
|
invokeCallback: this.invokeCallback,
|
|
150663
151441
|
releaseCallback: this.releaseCallback,
|
|
151442
|
+
releaseGuestReference: this.releaseGuestReference,
|
|
151443
|
+
retainGuestArguments: (operation, from) => {
|
|
151444
|
+
this.assertOpen();
|
|
151445
|
+
if (!extension.manifest.capabilities?.includes("guest:retain"))
|
|
151446
|
+
throw new TypeError("Retaining arguments requires the guest:retain grant.");
|
|
151447
|
+
if (typeof operation !== "function")
|
|
151448
|
+
throw new TypeError("Retained operation must be a function.");
|
|
151449
|
+
if (!Number.isSafeInteger(from) || from < 0)
|
|
151450
|
+
throw new TypeError("Argument index must be a non-negative safe integer.");
|
|
151451
|
+
if (this.scope !== void 0)
|
|
151452
|
+
throw new TypeError("Retained operations must be registered during setup.");
|
|
151453
|
+
const previous = this.retainedOperations.get(operation);
|
|
151454
|
+
if (previous !== void 0 && (previous.extension !== extension || previous.from !== from))
|
|
151455
|
+
throw new TypeError("Conflicting retained operation declaration.");
|
|
151456
|
+
this.retainedOperations.set(operation, { extension, from });
|
|
151457
|
+
return operation;
|
|
151458
|
+
},
|
|
150664
151459
|
nestedOperation: (operation) => {
|
|
150665
151460
|
this.assertOpen();
|
|
150666
151461
|
if (!extension.manifest.capabilities?.includes("source:nested"))
|
|
@@ -150699,7 +151494,7 @@ var init_realm = __esm({
|
|
|
150699
151494
|
}
|
|
150700
151495
|
});
|
|
150701
151496
|
const output = getExtensionSetup(extension)(context);
|
|
150702
|
-
if (
|
|
151497
|
+
if (types5.isPromise(output)) {
|
|
150703
151498
|
void Promise.resolve(output).catch(() => void 0);
|
|
150704
151499
|
throw new TypeError("Extension setup must be synchronous.");
|
|
150705
151500
|
}
|
|
@@ -150823,7 +151618,7 @@ var init_realm = __esm({
|
|
|
150823
151618
|
if (!this.closed)
|
|
150824
151619
|
reconcileCompiledValues(
|
|
150825
151620
|
this.budget,
|
|
150826
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
151621
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150827
151622
|
this.compilation
|
|
150828
151623
|
);
|
|
150829
151624
|
return result;
|
|
@@ -150857,7 +151652,10 @@ var init_realm = __esm({
|
|
|
150857
151652
|
this.callbacks.clear();
|
|
150858
151653
|
for (const object of this.hostObjects) revokeHostObject(object, this);
|
|
150859
151654
|
this.hostObjects.clear();
|
|
151655
|
+
for (const reference of this.guestReferences.keys()) revokeGuestReference(reference, this);
|
|
151656
|
+
this.guestReferences.clear();
|
|
150860
151657
|
this.budget.setRetainedValues(this, void 0);
|
|
151658
|
+
releaseObjectPrototype(this.budget);
|
|
150861
151659
|
this.disposal = (async () => {
|
|
150862
151660
|
const errors2 = [];
|
|
150863
151661
|
for (const cleanup of this.cleanups.splice(0).reverse()) {
|
|
@@ -151319,6 +152117,7 @@ var init_serialize = __esm({
|
|
|
151319
152117
|
init_arrays();
|
|
151320
152118
|
init_float32();
|
|
151321
152119
|
init_float32array();
|
|
152120
|
+
init_date();
|
|
151322
152121
|
init_values();
|
|
151323
152122
|
UnsnapshotableValueError = class extends Error {
|
|
151324
152123
|
path;
|
|
@@ -151526,7 +152325,7 @@ function run(source, options = {}) {
|
|
|
151526
152325
|
lifecycle
|
|
151527
152326
|
})
|
|
151528
152327
|
);
|
|
151529
|
-
const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next });
|
|
152328
|
+
const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next, clock: options.clock });
|
|
151530
152329
|
const importMeta = convertInitialInput(
|
|
151531
152330
|
() => deepCopyToSandbox(options.importMeta ?? {})
|
|
151532
152331
|
);
|
|
@@ -151787,6 +152586,7 @@ function run(source, options = {}) {
|
|
|
151787
152586
|
}
|
|
151788
152587
|
});
|
|
151789
152588
|
} finally {
|
|
152589
|
+
releaseObjectPrototype(budget);
|
|
151790
152590
|
compilation.dispose();
|
|
151791
152591
|
operation.release();
|
|
151792
152592
|
}
|
|
@@ -151998,6 +152798,7 @@ var init_run7 = __esm({
|
|
|
151998
152798
|
init_promise_tracker();
|
|
151999
152799
|
init_host_call();
|
|
152000
152800
|
init_globals();
|
|
152801
|
+
init_object_model();
|
|
152001
152802
|
init_host_bridge();
|
|
152002
152803
|
init_interpreter();
|
|
152003
152804
|
init_promise();
|
|
@@ -158877,7 +159678,7 @@ var init_package2 = __esm({
|
|
|
158877
159678
|
"package.json"() {
|
|
158878
159679
|
package_default2 = {
|
|
158879
159680
|
name: "poe-code",
|
|
158880
|
-
version: "14.0.
|
|
159681
|
+
version: "14.0.8",
|
|
158881
159682
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
158882
159683
|
license: "MIT",
|
|
158883
159684
|
type: "module",
|