poe-code 14.0.6 → 14.0.7
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 +454 -39
- 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-BWVASPJX.js} +420 -33
- package/packages/safe-js/dist/chunks/chunk-BWVASPJX.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-QSSQJNKE.js → chunk-ETKM3KPA.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/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 +2 -1
- package/packages/safe-js/dist/interp/globals/object-array.js +10 -1
- package/packages/safe-js/dist/interp/globals.d.ts +3 -0
- 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 +7 -0
- package/packages/safe-js/dist/interp/host-capabilities.js +29 -1
- package/packages/safe-js/dist/interp/interpreter.js +19 -2
- package/packages/safe-js/dist/interp/string-coercion.js +3 -0
- package/packages/safe-js/dist/interp/values.d.ts +1 -1
- package/packages/safe-js/dist/interp/values.js +21 -0
- 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 +74 -8
- package/packages/safe-js/dist/run.d.ts +2 -0
- package/packages/safe-js/dist/run.js +1 -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-ETKM3KPA.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 types5 = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
50275
|
+
if (types5.length === 0 || !types5.every((type) => typeof type === "string" && draftTypeSet.has(type)) || new Set(types5).size !== types5.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 types5 = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
|
|
50995
|
+
if (types5.length > 0 && !types5.some((type) => typeof type === "string" && typeMatches(type, value))) {
|
|
50996
|
+
results.push(invalidResult(issue(path193, types5.join(","), value, `must be ${types5.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,6 +125593,24 @@ var init_extensions = __esm({
|
|
|
125592
125593
|
});
|
|
125593
125594
|
|
|
125594
125595
|
// packages/safe-js/src/interp/host-capabilities.ts
|
|
125596
|
+
function createGuestReference(root, owner, assertActive) {
|
|
125597
|
+
const reference = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
125598
|
+
guestReferences.set(reference, { root, owner, assertActive });
|
|
125599
|
+
return reference;
|
|
125600
|
+
}
|
|
125601
|
+
function readGuestReference(reference, owner) {
|
|
125602
|
+
const state = typeof reference === "object" && reference !== null ? guestReferences.get(reference) : void 0;
|
|
125603
|
+
if (state === void 0 || state.owner !== owner)
|
|
125604
|
+
throw new TypeError("Foreign or invalid guest reference.");
|
|
125605
|
+
state.assertActive();
|
|
125606
|
+
if (state.root === void 0) throw new TypeError("Guest reference is revoked.");
|
|
125607
|
+
return state.root[0];
|
|
125608
|
+
}
|
|
125609
|
+
function revokeGuestReference(reference, owner) {
|
|
125610
|
+
const state = guestReferences.get(reference);
|
|
125611
|
+
if (state === void 0 || state.owner !== owner) throw new TypeError("Foreign guest reference.");
|
|
125612
|
+
state.root = void 0;
|
|
125613
|
+
}
|
|
125595
125614
|
function createLiveHostObject(definition, controller) {
|
|
125596
125615
|
const input = readDataRecord(definition, "Host object definition");
|
|
125597
125616
|
if (Object.keys(input).some((key3) => key3 !== "properties" && key3 !== "methods"))
|
|
@@ -125635,9 +125654,10 @@ function isGuestHostObject(value) {
|
|
|
125635
125654
|
return typeof value === "object" && value !== null && guestObjects.has(value);
|
|
125636
125655
|
}
|
|
125637
125656
|
function isLiveCapability(value) {
|
|
125638
|
-
return (typeof value === "object" && value !== null || typeof value === "function") && (hostObjects.has(value) || guestObjects.has(value) || guestCallbacks.has(value));
|
|
125657
|
+
return (typeof value === "object" && value !== null || typeof value === "function") && (hostObjects.has(value) || guestObjects.has(value) || guestCallbacks.has(value) || guestReferences.has(value));
|
|
125639
125658
|
}
|
|
125640
125659
|
function importHostCapability(value, owner) {
|
|
125660
|
+
if (guestReferences.has(value)) return readGuestReference(value, owner);
|
|
125641
125661
|
const object = hostObjects.get(value);
|
|
125642
125662
|
if (object !== void 0) {
|
|
125643
125663
|
if (object.controller.owner !== owner) throw new TypeError("Foreign realm host capability.");
|
|
@@ -125705,7 +125725,7 @@ function getHostObjectKeys(value) {
|
|
|
125705
125725
|
state.controller.assertActive();
|
|
125706
125726
|
return [...state.properties.keys(), ...state.methods.keys()];
|
|
125707
125727
|
}
|
|
125708
|
-
var hostObjects, guestObjects, guestCallbacks;
|
|
125728
|
+
var hostObjects, guestObjects, guestCallbacks, guestReferences;
|
|
125709
125729
|
var init_host_capabilities = __esm({
|
|
125710
125730
|
"packages/safe-js/src/interp/host-capabilities.ts"() {
|
|
125711
125731
|
"use strict";
|
|
@@ -125713,6 +125733,7 @@ var init_host_capabilities = __esm({
|
|
|
125713
125733
|
hostObjects = /* @__PURE__ */ new WeakMap();
|
|
125714
125734
|
guestObjects = /* @__PURE__ */ new WeakMap();
|
|
125715
125735
|
guestCallbacks = /* @__PURE__ */ new WeakMap();
|
|
125736
|
+
guestReferences = /* @__PURE__ */ new WeakMap();
|
|
125716
125737
|
}
|
|
125717
125738
|
});
|
|
125718
125739
|
|
|
@@ -125809,6 +125830,134 @@ var init_otel2 = __esm({
|
|
|
125809
125830
|
}
|
|
125810
125831
|
});
|
|
125811
125832
|
|
|
125833
|
+
// packages/safe-js/src/interp/date.ts
|
|
125834
|
+
import { types as types2 } from "node:util";
|
|
125835
|
+
function isSandboxDate(value) {
|
|
125836
|
+
return typeof value === "object" && value !== null && dates.has(value);
|
|
125837
|
+
}
|
|
125838
|
+
function createSandboxDate(time) {
|
|
125839
|
+
const value = new NativeDate(time);
|
|
125840
|
+
dates.add(value);
|
|
125841
|
+
return Object.freeze(value);
|
|
125842
|
+
}
|
|
125843
|
+
function dateTime(value) {
|
|
125844
|
+
return Reflect.apply(readTime, value, []);
|
|
125845
|
+
}
|
|
125846
|
+
function copyNativeDate(value) {
|
|
125847
|
+
if (!types2.isDate(value)) return void 0;
|
|
125848
|
+
if (Object.getPrototypeOf(value) !== NativeDate.prototype || Reflect.ownKeys(value).length > 0)
|
|
125849
|
+
throw new TypeError("Date subclasses and own properties are not supported.");
|
|
125850
|
+
return createSandboxDate(dateTime(value));
|
|
125851
|
+
}
|
|
125852
|
+
function exportDate(value) {
|
|
125853
|
+
return new NativeDate(dateTime(value));
|
|
125854
|
+
}
|
|
125855
|
+
function dateNumber(value) {
|
|
125856
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
125857
|
+
if (typeof value === "object" && value !== null || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint")
|
|
125858
|
+
throw new TypeError("Date arguments require primitive values; custom coercion is unsupported.");
|
|
125859
|
+
return Number(value);
|
|
125860
|
+
}
|
|
125861
|
+
function parseDate2(value, budget) {
|
|
125862
|
+
if (typeof value === "object" && value !== null || typeof value === "function")
|
|
125863
|
+
throw new TypeError("Date parsing requires a primitive value.");
|
|
125864
|
+
const text5 = String(value);
|
|
125865
|
+
if (text5.length > 4096) throw new RangeError("Date input exceeds the 4096 character limit.");
|
|
125866
|
+
budget.allocateString(text5);
|
|
125867
|
+
for (let index = 0; index < text5.length; index++) budget.visitNode();
|
|
125868
|
+
return NativeDate.parse(text5);
|
|
125869
|
+
}
|
|
125870
|
+
function dateFromParts(args, utc) {
|
|
125871
|
+
const parts = args.slice(0, 7).map(dateNumber);
|
|
125872
|
+
return utc ? Reflect.apply(NativeDate.UTC, NativeDate, parts) : dateTime(Reflect.construct(NativeDate, parts));
|
|
125873
|
+
}
|
|
125874
|
+
function dateString(value) {
|
|
125875
|
+
return dateMethods.get("toString").invoke(value, []);
|
|
125876
|
+
}
|
|
125877
|
+
function restoreDateTime(value) {
|
|
125878
|
+
if (value !== null && (typeof value !== "number" || !Number.isInteger(value) || Math.abs(value) > 864e13 || Object.is(value, -0)))
|
|
125879
|
+
throw new TypeError("Invalid serialized Date epoch.");
|
|
125880
|
+
const date = createSandboxDate(0);
|
|
125881
|
+
Reflect.apply(writeTime, date, [value === null ? NaN : value]);
|
|
125882
|
+
return date;
|
|
125883
|
+
}
|
|
125884
|
+
function serializedDateTime(value) {
|
|
125885
|
+
const time = dateTime(value);
|
|
125886
|
+
return Number.isNaN(time) ? null : time;
|
|
125887
|
+
}
|
|
125888
|
+
var NativeDate, readTime, writeTime, dates, methodNames, dateMethods;
|
|
125889
|
+
var init_date = __esm({
|
|
125890
|
+
"packages/safe-js/src/interp/date.ts"() {
|
|
125891
|
+
"use strict";
|
|
125892
|
+
NativeDate = Date;
|
|
125893
|
+
readTime = NativeDate.prototype.getTime;
|
|
125894
|
+
writeTime = NativeDate.prototype.setTime;
|
|
125895
|
+
dates = /* @__PURE__ */ new WeakSet();
|
|
125896
|
+
methodNames = [
|
|
125897
|
+
"getTime",
|
|
125898
|
+
"valueOf",
|
|
125899
|
+
"getDate",
|
|
125900
|
+
"getDay",
|
|
125901
|
+
"getFullYear",
|
|
125902
|
+
"getHours",
|
|
125903
|
+
"getMilliseconds",
|
|
125904
|
+
"getMinutes",
|
|
125905
|
+
"getMonth",
|
|
125906
|
+
"getSeconds",
|
|
125907
|
+
"getTimezoneOffset",
|
|
125908
|
+
"getUTCDate",
|
|
125909
|
+
"getUTCDay",
|
|
125910
|
+
"getUTCFullYear",
|
|
125911
|
+
"getUTCHours",
|
|
125912
|
+
"getUTCMilliseconds",
|
|
125913
|
+
"getUTCMinutes",
|
|
125914
|
+
"getUTCMonth",
|
|
125915
|
+
"getUTCSeconds",
|
|
125916
|
+
"setTime",
|
|
125917
|
+
"setDate",
|
|
125918
|
+
"setFullYear",
|
|
125919
|
+
"setHours",
|
|
125920
|
+
"setMilliseconds",
|
|
125921
|
+
"setMinutes",
|
|
125922
|
+
"setMonth",
|
|
125923
|
+
"setSeconds",
|
|
125924
|
+
"setUTCDate",
|
|
125925
|
+
"setUTCFullYear",
|
|
125926
|
+
"setUTCHours",
|
|
125927
|
+
"setUTCMilliseconds",
|
|
125928
|
+
"setUTCMinutes",
|
|
125929
|
+
"setUTCMonth",
|
|
125930
|
+
"setUTCSeconds",
|
|
125931
|
+
"toDateString",
|
|
125932
|
+
"toISOString",
|
|
125933
|
+
"toString",
|
|
125934
|
+
"toTimeString",
|
|
125935
|
+
"toUTCString",
|
|
125936
|
+
"toJSON"
|
|
125937
|
+
];
|
|
125938
|
+
dateMethods = new Map(
|
|
125939
|
+
methodNames.map((name) => {
|
|
125940
|
+
const native = NativeDate.prototype[name];
|
|
125941
|
+
return [
|
|
125942
|
+
name,
|
|
125943
|
+
{
|
|
125944
|
+
length: native.length,
|
|
125945
|
+
invoke: (date, args) => {
|
|
125946
|
+
if (name === "toJSON")
|
|
125947
|
+
return Number.isNaN(dateTime(date)) ? null : Reflect.apply(NativeDate.prototype.toISOString, date, []);
|
|
125948
|
+
return Reflect.apply(
|
|
125949
|
+
native,
|
|
125950
|
+
date,
|
|
125951
|
+
name.startsWith("set") ? args.slice(0, native.length).map(dateNumber) : []
|
|
125952
|
+
);
|
|
125953
|
+
}
|
|
125954
|
+
}
|
|
125955
|
+
];
|
|
125956
|
+
})
|
|
125957
|
+
);
|
|
125958
|
+
}
|
|
125959
|
+
});
|
|
125960
|
+
|
|
125812
125961
|
// packages/safe-js/src/interp/float32.ts
|
|
125813
125962
|
function isFloat32Array(value) {
|
|
125814
125963
|
return ArrayBuffer.isView(value) && Object.getPrototypeOf(value) === Float32Array.prototype && Reflect.apply(readTag, value, []) === "Float32Array";
|
|
@@ -126479,6 +126628,8 @@ function encodeReplayData(value, options = {}) {
|
|
|
126479
126628
|
id: capabilityId,
|
|
126480
126629
|
properties: child(entry.properties, "properties")
|
|
126481
126630
|
};
|
|
126631
|
+
} else if (isSandboxDate(entry)) {
|
|
126632
|
+
nodes[id] = { kind: "date", time: serializedDateTime(entry) };
|
|
126482
126633
|
} else if (isFloat32Array(entry)) {
|
|
126483
126634
|
const storage2 = encodeFloat32Storage(entry, id, float32Buffers, (id2) => ({
|
|
126484
126635
|
tag: "ref",
|
|
@@ -126629,6 +126780,12 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
126629
126780
|
options.onCapabilityRestored?.(capability, copy);
|
|
126630
126781
|
return copy;
|
|
126631
126782
|
}
|
|
126783
|
+
if (kind === "date") {
|
|
126784
|
+
if (Object.keys(node).length !== 2) throw new TypeError("Invalid serialized Date fields.");
|
|
126785
|
+
const result3 = restoreDateTime(own(node, "time"));
|
|
126786
|
+
restored.set(id, result3);
|
|
126787
|
+
return result3;
|
|
126788
|
+
}
|
|
126632
126789
|
if (kind === "float32array") {
|
|
126633
126790
|
if (typeof node.extensible !== "boolean")
|
|
126634
126791
|
throw new TypeError("Invalid Float32Array extensibility.");
|
|
@@ -126740,6 +126897,7 @@ var init_replay_data = __esm({
|
|
|
126740
126897
|
init_compile_guard();
|
|
126741
126898
|
init_float32();
|
|
126742
126899
|
init_float32array();
|
|
126900
|
+
init_date();
|
|
126743
126901
|
init_shape();
|
|
126744
126902
|
init_values();
|
|
126745
126903
|
init_arguments2();
|
|
@@ -126969,6 +127127,8 @@ function normalize2(value, seen) {
|
|
|
126969
127127
|
if (seen.has(value)) throw new TypeError("Host call arguments cannot contain cycles.");
|
|
126970
127128
|
seen.add(value);
|
|
126971
127129
|
try {
|
|
127130
|
+
const date = copyNativeDate(value);
|
|
127131
|
+
if (date !== void 0) return Object.assign(/* @__PURE__ */ Object.create(null), { $type: "date", time: serializedDateTime(date) });
|
|
126972
127132
|
if (isFloat32Array(value)) {
|
|
126973
127133
|
const storage2 = float32Storage(value);
|
|
126974
127134
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -127017,6 +127177,7 @@ var init_host_call = __esm({
|
|
|
127017
127177
|
"packages/safe-js/src/interp/host-call.ts"() {
|
|
127018
127178
|
"use strict";
|
|
127019
127179
|
init_float32();
|
|
127180
|
+
init_date();
|
|
127020
127181
|
init_values();
|
|
127021
127182
|
init_compile_guard();
|
|
127022
127183
|
init_replay_data();
|
|
@@ -129252,6 +129413,10 @@ function measureSandboxData(values, options = {}) {
|
|
|
129252
129413
|
assertSandboxDataDepth(depth);
|
|
129253
129414
|
seen.add(value);
|
|
129254
129415
|
usage += 1;
|
|
129416
|
+
if (isSandboxDate(value)) {
|
|
129417
|
+
usage += 8;
|
|
129418
|
+
return;
|
|
129419
|
+
}
|
|
129255
129420
|
if (isGuestHostObject(value)) {
|
|
129256
129421
|
for (const key3 of getHostObjectKeys(value)) usage += key3.length + 1;
|
|
129257
129422
|
return;
|
|
@@ -129446,6 +129611,13 @@ function copyToSandbox(value, state, path193 = "<root>", cloneSandboxCollections
|
|
|
129446
129611
|
}
|
|
129447
129612
|
return sandboxPromise;
|
|
129448
129613
|
}
|
|
129614
|
+
if (nodeTypes.isDate(value)) {
|
|
129615
|
+
const existing = state.seen.get(value);
|
|
129616
|
+
if (existing !== void 0) return existing;
|
|
129617
|
+
const copy = copyNativeDate(value);
|
|
129618
|
+
state.seen.set(value, copy);
|
|
129619
|
+
return copy;
|
|
129620
|
+
}
|
|
129449
129621
|
if (isFloat32Array(value)) {
|
|
129450
129622
|
const existing = state.seen.get(value);
|
|
129451
129623
|
if (existing !== void 0) return existing;
|
|
@@ -129605,6 +129777,13 @@ function copyFromSandbox(value, state, path193 = "<root>", options, depth = 0) {
|
|
|
129605
129777
|
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
129606
129778
|
return copy;
|
|
129607
129779
|
}
|
|
129780
|
+
if (isSandboxDate(value)) {
|
|
129781
|
+
const existing = state.seen.get(value);
|
|
129782
|
+
if (existing !== void 0) return existing;
|
|
129783
|
+
const copy = exportDate(value);
|
|
129784
|
+
state.seen.set(value, copy);
|
|
129785
|
+
return copy;
|
|
129786
|
+
}
|
|
129608
129787
|
if (isSandboxClosure(value)) {
|
|
129609
129788
|
if (options.wrapClosure === void 0) {
|
|
129610
129789
|
throw new TypeError(
|
|
@@ -129873,6 +130052,7 @@ var init_values = __esm({
|
|
|
129873
130052
|
"packages/safe-js/src/interp/values.ts"() {
|
|
129874
130053
|
"use strict";
|
|
129875
130054
|
init_otel2();
|
|
130055
|
+
init_date();
|
|
129876
130056
|
init_host_capabilities();
|
|
129877
130057
|
init_compile_guard();
|
|
129878
130058
|
init_float32();
|
|
@@ -130089,7 +130269,7 @@ function serializeDumpValue(value, path193, state) {
|
|
|
130089
130269
|
if (hasGuestObjectState(value)) {
|
|
130090
130270
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
130091
130271
|
}
|
|
130092
|
-
if (isFloat32Array(value)) return serializeHeapReference(value, path193, state);
|
|
130272
|
+
if (isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path193, state);
|
|
130093
130273
|
if (Array.isArray(value)) {
|
|
130094
130274
|
const reference2 = serializeHeapReference(value, path193, state);
|
|
130095
130275
|
if (reference2 !== void 0) {
|
|
@@ -130113,7 +130293,9 @@ function serializeHeapReference(value, path193, state) {
|
|
|
130113
130293
|
}
|
|
130114
130294
|
if (!state.serializedHeapIds.has(id)) {
|
|
130115
130295
|
state.serializedHeapIds.add(id);
|
|
130116
|
-
if (
|
|
130296
|
+
if (isSandboxDate(value)) {
|
|
130297
|
+
state.heap[String(id)] = { kind: "date", time: serializedDateTime(value) };
|
|
130298
|
+
} else if (isFloat32Array(value)) {
|
|
130117
130299
|
const storage2 = encodeFloat32Storage(value, id, state.float32Buffers, (id2) => ({
|
|
130118
130300
|
kind: "ref",
|
|
130119
130301
|
id: id2
|
|
@@ -130170,7 +130352,7 @@ function indexHeapContainers(snapshot2) {
|
|
|
130170
130352
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
130171
130353
|
let nextId = 1;
|
|
130172
130354
|
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)) {
|
|
130355
|
+
if (stat35.count > 1 || stat35.cyclic || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
130174
130356
|
heapIds.set(value, nextId);
|
|
130175
130357
|
nextId += 1;
|
|
130176
130358
|
}
|
|
@@ -130181,7 +130363,7 @@ function collectContainerStats(value, stats2, ancestors) {
|
|
|
130181
130363
|
if (value === null || typeof value !== "object") {
|
|
130182
130364
|
return;
|
|
130183
130365
|
}
|
|
130184
|
-
if (!Array.isArray(value) && !isPlainObject10(value) && !isFloat32Array(value)) {
|
|
130366
|
+
if (!Array.isArray(value) && !isPlainObject10(value) && !isFloat32Array(value) && !isSandboxDate(value)) {
|
|
130185
130367
|
return;
|
|
130186
130368
|
}
|
|
130187
130369
|
let stat35 = stats2.get(value);
|
|
@@ -130252,6 +130434,7 @@ var init_dump_format = __esm({
|
|
|
130252
130434
|
init_arrays();
|
|
130253
130435
|
init_float32();
|
|
130254
130436
|
init_float32array();
|
|
130437
|
+
init_date();
|
|
130255
130438
|
DUMP_FORMAT_VERSION = 1;
|
|
130256
130439
|
EXECUTION_SEMANTICS = "jobs-v7";
|
|
130257
130440
|
SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
@@ -130259,7 +130442,7 @@ var init_dump_format = __esm({
|
|
|
130259
130442
|
});
|
|
130260
130443
|
|
|
130261
130444
|
// packages/safe-js/src/snapshot/validation.ts
|
|
130262
|
-
import { types as
|
|
130445
|
+
import { types as types3 } from "node:util";
|
|
130263
130446
|
function validateSnapshotData(value) {
|
|
130264
130447
|
validateGenericValue(value, "$", 0, {
|
|
130265
130448
|
allowFunctions: false,
|
|
@@ -130305,6 +130488,10 @@ function validateDumpHeap(root, state) {
|
|
|
130305
130488
|
addUnique2(heapIds, id, path193);
|
|
130306
130489
|
const entry = requireRecord3(value, path193);
|
|
130307
130490
|
validateErrorType(entry, path193);
|
|
130491
|
+
if (entry.kind === "date") {
|
|
130492
|
+
validateDateRecord(entry, path193);
|
|
130493
|
+
continue;
|
|
130494
|
+
}
|
|
130308
130495
|
if (entry.kind === "float32array") {
|
|
130309
130496
|
validateFloat32Storage(entry);
|
|
130310
130497
|
requireRecord3(entry.entries, `${path193}.entries`);
|
|
@@ -130462,6 +130649,14 @@ function validateGeneratorShape(record2, path193, state) {
|
|
|
130462
130649
|
}
|
|
130463
130650
|
});
|
|
130464
130651
|
}
|
|
130652
|
+
function validateDateRecord(record2, path193) {
|
|
130653
|
+
if (Object.keys(record2).length !== 2) fail2("invalidValue", path193, "invalid Date fields");
|
|
130654
|
+
try {
|
|
130655
|
+
restoreDateTime(record2.time);
|
|
130656
|
+
} catch {
|
|
130657
|
+
fail2("invalidValue", `${path193}.time`, "invalid Date epoch");
|
|
130658
|
+
}
|
|
130659
|
+
}
|
|
130465
130660
|
function validateArrayHeap(record2, path193, state) {
|
|
130466
130661
|
if (Object.hasOwn(record2, "items")) {
|
|
130467
130662
|
requireArray(record2.items, `${path193}.items`, state);
|
|
@@ -130545,7 +130740,7 @@ function validateGenericValue(value, path193, depth, state) {
|
|
|
130545
130740
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
|
|
130546
130741
|
fail2("invalidState", path193, "guest function properties, prototype links and custom descriptors cannot be restored");
|
|
130547
130742
|
}
|
|
130548
|
-
if (state.dataPropertiesOnly &&
|
|
130743
|
+
if (state.dataPropertiesOnly && types3.isProxy(value)) {
|
|
130549
130744
|
fail2("invalidType", path193, "proxy objects are not snapshot data");
|
|
130550
130745
|
}
|
|
130551
130746
|
if (depth > state.limits.maxDepth)
|
|
@@ -130679,6 +130874,7 @@ var init_validation = __esm({
|
|
|
130679
130874
|
init_dump_format();
|
|
130680
130875
|
init_graph_depth();
|
|
130681
130876
|
init_float32array();
|
|
130877
|
+
init_date();
|
|
130682
130878
|
init_object_model();
|
|
130683
130879
|
DEFAULT_MAX_DEPTH = MAX_DATA_DEPTH;
|
|
130684
130880
|
DEFAULT_MAX_ENTRIES = 1e5;
|
|
@@ -131577,6 +131773,7 @@ var init_known_globals = __esm({
|
|
|
131577
131773
|
"AggregateError",
|
|
131578
131774
|
"Array",
|
|
131579
131775
|
"Boolean",
|
|
131776
|
+
"Date",
|
|
131580
131777
|
"Error",
|
|
131581
131778
|
"Infinity",
|
|
131582
131779
|
"isFinite",
|
|
@@ -136840,9 +137037,9 @@ var init_AS_floating_promise = __esm({
|
|
|
136840
137037
|
isPromiseFactoryCall(node) {
|
|
136841
137038
|
return this.isPromiseStaticMethodCall(node, PROMISE_FACTORIES);
|
|
136842
137039
|
}
|
|
136843
|
-
isPromiseStaticMethodCall(node,
|
|
137040
|
+
isPromiseStaticMethodCall(node, methodNames2) {
|
|
136844
137041
|
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" &&
|
|
137042
|
+
return member !== void 0 && !member.computed && member.object.type === "Identifier" && member.object.name === "Promise" && member.property.type === "Identifier" && methodNames2.has(member.property.name);
|
|
136846
137043
|
}
|
|
136847
137044
|
isPromiseChainCall(node) {
|
|
136848
137045
|
const member = node.callee.type === "MemberExpression" ? node.callee : void 0;
|
|
@@ -144724,6 +144921,110 @@ var init_float32array2 = __esm({
|
|
|
144724
144921
|
}
|
|
144725
144922
|
});
|
|
144726
144923
|
|
|
144924
|
+
// packages/safe-js/src/interp/globals/date.ts
|
|
144925
|
+
function createDateGlobal(options) {
|
|
144926
|
+
const validateClockTime = (value) => {
|
|
144927
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || Math.abs(value) > 864e13)
|
|
144928
|
+
throw new TypeError("Date clock must return a finite integer epoch within the Date range.");
|
|
144929
|
+
return value;
|
|
144930
|
+
};
|
|
144931
|
+
const readNow = declareHostOperation(
|
|
144932
|
+
() => {
|
|
144933
|
+
options.budget.visitNode();
|
|
144934
|
+
const value = options.clock?.now === void 0 ? Date.now() : options.clock.now();
|
|
144935
|
+
return validateClockTime(value);
|
|
144936
|
+
},
|
|
144937
|
+
"re-issue",
|
|
144938
|
+
{
|
|
144939
|
+
onReplay: (_args, outcome) => {
|
|
144940
|
+
if (outcome.status === "fulfilled") {
|
|
144941
|
+
const time = validateClockTime(outcome.value);
|
|
144942
|
+
options.clock?.restore?.({ next: time + 1 });
|
|
144943
|
+
}
|
|
144944
|
+
}
|
|
144945
|
+
}
|
|
144946
|
+
);
|
|
144947
|
+
const now = wrapCallerInjectedBindings({ now: readNow }, { ...options, moduleId: "<Date>" }).now;
|
|
144948
|
+
const prototype = createSandboxDate(NaN);
|
|
144949
|
+
const constructor = createSandboxClosure({
|
|
144950
|
+
sandbox: true,
|
|
144951
|
+
name: "Date",
|
|
144952
|
+
length: 7,
|
|
144953
|
+
call: async (_args, context) => options.budget.allocateString(
|
|
144954
|
+
dateString(createSandboxDate(Number(await now.call([], context))))
|
|
144955
|
+
),
|
|
144956
|
+
construct: async (args, context) => {
|
|
144957
|
+
let time;
|
|
144958
|
+
if (args.length === 0) time = Number(await now.call([], context));
|
|
144959
|
+
else if (args.length > 1) time = dateFromParts(args, false);
|
|
144960
|
+
else if (isSandboxDate(args[0])) time = dateTime(args[0]);
|
|
144961
|
+
else if (typeof args[0] === "string") time = parseDate2(args[0], options.budget);
|
|
144962
|
+
else time = dateNumber(args[0]);
|
|
144963
|
+
options.budget.chargeDataUsage(9);
|
|
144964
|
+
return createSandboxDate(time);
|
|
144965
|
+
},
|
|
144966
|
+
properties: {
|
|
144967
|
+
now,
|
|
144968
|
+
prototype,
|
|
144969
|
+
parse: createSandboxClosure({
|
|
144970
|
+
sandbox: true,
|
|
144971
|
+
name: "parse",
|
|
144972
|
+
length: 1,
|
|
144973
|
+
call: ([value]) => parseDate2(value, options.budget)
|
|
144974
|
+
}),
|
|
144975
|
+
UTC: createSandboxClosure({
|
|
144976
|
+
sandbox: true,
|
|
144977
|
+
name: "UTC",
|
|
144978
|
+
length: 7,
|
|
144979
|
+
call: (args) => dateFromParts(args, true)
|
|
144980
|
+
})
|
|
144981
|
+
}
|
|
144982
|
+
});
|
|
144983
|
+
const methods = /* @__PURE__ */ new Map();
|
|
144984
|
+
for (const [name, method] of dateMethods)
|
|
144985
|
+
methods.set(
|
|
144986
|
+
name,
|
|
144987
|
+
createSandboxClosure({
|
|
144988
|
+
sandbox: true,
|
|
144989
|
+
name,
|
|
144990
|
+
length: method.length,
|
|
144991
|
+
call: (args, context) => {
|
|
144992
|
+
const receiver = context?.thisValue;
|
|
144993
|
+
if (!isSandboxDate(receiver))
|
|
144994
|
+
throw new TypeError(`Date#${name} requires a Date receiver.`);
|
|
144995
|
+
options.budget.visitNode();
|
|
144996
|
+
const value = method.invoke(receiver, args);
|
|
144997
|
+
return typeof value === "string" ? options.budget.allocateString(value) : value;
|
|
144998
|
+
}
|
|
144999
|
+
})
|
|
145000
|
+
);
|
|
145001
|
+
constructors2.add(constructor);
|
|
145002
|
+
intrinsics.set(options.compileOwner ?? options.budget, { constructor, prototype, methods });
|
|
145003
|
+
return constructor;
|
|
145004
|
+
}
|
|
145005
|
+
function isDateConstructor(value) {
|
|
145006
|
+
return typeof value === "object" && value !== null && constructors2.has(value);
|
|
145007
|
+
}
|
|
145008
|
+
function getDateMember(property, budget, owner) {
|
|
145009
|
+
const state = intrinsics.get(owner ?? budget);
|
|
145010
|
+
return property === "constructor" ? state?.constructor : state?.methods.get(String(property));
|
|
145011
|
+
}
|
|
145012
|
+
function getDatePrototype(value, budget, owner) {
|
|
145013
|
+
const prototype = intrinsics.get(owner ?? budget)?.prototype;
|
|
145014
|
+
return prototype === value ? null : prototype ?? null;
|
|
145015
|
+
}
|
|
145016
|
+
var intrinsics, constructors2;
|
|
145017
|
+
var init_date2 = __esm({
|
|
145018
|
+
"packages/safe-js/src/interp/globals/date.ts"() {
|
|
145019
|
+
"use strict";
|
|
145020
|
+
init_date();
|
|
145021
|
+
init_host_bridge();
|
|
145022
|
+
init_values();
|
|
145023
|
+
intrinsics = /* @__PURE__ */ new WeakMap();
|
|
145024
|
+
constructors2 = /* @__PURE__ */ new WeakSet();
|
|
145025
|
+
}
|
|
145026
|
+
});
|
|
145027
|
+
|
|
144727
145028
|
// packages/safe-js/src/interp/scope.ts
|
|
144728
145029
|
function defineSnapshotBinding(target, name, value) {
|
|
144729
145030
|
Object.defineProperty(target, name, {
|
|
@@ -146545,6 +146846,7 @@ function getPropertyValue(target, property, context) {
|
|
|
146545
146846
|
if (typeof target === "number") return getNumberMember(target, property, context.budget);
|
|
146546
146847
|
if (typeof target === "boolean") return void 0;
|
|
146547
146848
|
if (isFloat32Array(target)) return getFloat32Member(target, property, context.budget);
|
|
146849
|
+
if (isSandboxDate(target)) return getDateMember(property, context.budget, context.compilation?.owner);
|
|
146548
146850
|
if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
|
|
146549
146851
|
if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
|
|
146550
146852
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
@@ -146781,6 +147083,9 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
146781
147083
|
context
|
|
146782
147084
|
);
|
|
146783
147085
|
}
|
|
147086
|
+
if (isSandboxDate(member.object)) {
|
|
147087
|
+
return evaluateResolvedCallExpression(node, getDateMember(member.property, context.budget, context.compilation?.owner), context, member.object);
|
|
147088
|
+
}
|
|
146784
147089
|
if (isFloat32Array(member.object)) {
|
|
146785
147090
|
return evaluateResolvedCallExpression(
|
|
146786
147091
|
node,
|
|
@@ -147033,6 +147338,7 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
147033
147338
|
return true;
|
|
147034
147339
|
}
|
|
147035
147340
|
if (isFloat32ArrayConstructor(right)) return isFloat32Array(left);
|
|
147341
|
+
if (isDateConstructor(right)) return isSandboxDate(left) && getDatePrototype(left, context.budget, context.compilation?.owner) !== null;
|
|
147036
147342
|
if (isSandboxSetConstructor(right) && isSandboxSet(left)) {
|
|
147037
147343
|
return true;
|
|
147038
147344
|
}
|
|
@@ -147096,8 +147402,8 @@ function applyAdditionOperator(left, right, context) {
|
|
|
147096
147402
|
return toNumber(leftPrimitive) + toNumber(rightPrimitive);
|
|
147097
147403
|
}
|
|
147098
147404
|
function compareRelational(left, right, operator) {
|
|
147099
|
-
const leftPrimitive = toPrimitive(left);
|
|
147100
|
-
const rightPrimitive = toPrimitive(right);
|
|
147405
|
+
const leftPrimitive = isSandboxDate(left) ? dateTime(left) : toPrimitive(left);
|
|
147406
|
+
const rightPrimitive = isSandboxDate(right) ? dateTime(right) : toPrimitive(right);
|
|
147101
147407
|
if (typeof leftPrimitive === "string" && typeof rightPrimitive === "string") {
|
|
147102
147408
|
switch (operator) {
|
|
147103
147409
|
case "<":
|
|
@@ -147180,6 +147486,7 @@ function toPrimitive(value) {
|
|
|
147180
147486
|
return toString(value);
|
|
147181
147487
|
}
|
|
147182
147488
|
async function toNumericPrimitive(value, context) {
|
|
147489
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
147183
147490
|
if (isPrimitiveCoercionType(getCoercionType(value))) {
|
|
147184
147491
|
return value;
|
|
147185
147492
|
}
|
|
@@ -147209,6 +147516,7 @@ async function toNumericPrimitive(value, context) {
|
|
|
147209
147516
|
return toString(value);
|
|
147210
147517
|
}
|
|
147211
147518
|
function toNumber(value) {
|
|
147519
|
+
if (isSandboxDate(value)) return dateTime(value);
|
|
147212
147520
|
if (typeof value === "number") {
|
|
147213
147521
|
return value;
|
|
147214
147522
|
}
|
|
@@ -147227,6 +147535,7 @@ function toNumber(value) {
|
|
|
147227
147535
|
return toNumber(toPrimitive(value));
|
|
147228
147536
|
}
|
|
147229
147537
|
function toString(value) {
|
|
147538
|
+
if (isSandboxDate(value)) return dateString(value);
|
|
147230
147539
|
if (Array.isArray(value)) {
|
|
147231
147540
|
return value.map((entry) => entry === null || entry === void 0 ? "" : toString(entry)).join(",");
|
|
147232
147541
|
}
|
|
@@ -147272,6 +147581,7 @@ function getArrayMemberValue(target, property, context) {
|
|
|
147272
147581
|
return getArrayMember(target, property, createArrayMethodOptions(context));
|
|
147273
147582
|
}
|
|
147274
147583
|
function setSandboxProperty(target, property, value, budget) {
|
|
147584
|
+
if (isSandboxDate(target)) throw new TypeError("Date own properties are not supported.");
|
|
147275
147585
|
if (isGuestHostObject(target)) {
|
|
147276
147586
|
setHostObjectMember(target, String(property), value);
|
|
147277
147587
|
return;
|
|
@@ -147603,6 +147913,8 @@ var init_interpreter = __esm({
|
|
|
147603
147913
|
init_collections();
|
|
147604
147914
|
init_float32array2();
|
|
147605
147915
|
init_float32();
|
|
147916
|
+
init_date();
|
|
147917
|
+
init_date2();
|
|
147606
147918
|
init_values();
|
|
147607
147919
|
init_scope();
|
|
147608
147920
|
init_var_hoist();
|
|
@@ -148021,7 +148333,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
148021
148333
|
seen: /* @__PURE__ */ new WeakMap(),
|
|
148022
148334
|
restored: []
|
|
148023
148335
|
};
|
|
148024
|
-
const
|
|
148336
|
+
const copyArguments = (values) => deepCopyFromSandbox([...values], {
|
|
148025
148337
|
compilation,
|
|
148026
148338
|
unwrapHostObject: options.realm === void 0 ? void 0 : (object) => exportHostCapability(object, options.realm.owner),
|
|
148027
148339
|
wrapClosure: (closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
@@ -148032,13 +148344,21 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
148032
148344
|
callbacks
|
|
148033
148345
|
)
|
|
148034
148346
|
});
|
|
148347
|
+
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
148348
|
+
const hostArgs = captured?.args ?? copyArguments(args);
|
|
148035
148349
|
const hostCalls = options.hostCalls;
|
|
148036
148350
|
const operation = options.operation ?? bindingName;
|
|
148037
148351
|
const moduleId = options.moduleId ?? "<bindings>";
|
|
148038
148352
|
const policy = readHostOperationPolicy(value) ?? readRegisteredPendingHostCallPolicy(moduleId, operation) ?? "re-issue";
|
|
148039
148353
|
if (hostCalls === void 0) {
|
|
148040
148354
|
if (options.realm !== void 0) {
|
|
148041
|
-
|
|
148355
|
+
let result;
|
|
148356
|
+
try {
|
|
148357
|
+
result = options.realm.invoke(callable, () => Reflect.apply(callable, void 0, hostArgs));
|
|
148358
|
+
} catch (error3) {
|
|
148359
|
+
captured.rollback();
|
|
148360
|
+
throw error3;
|
|
148361
|
+
}
|
|
148042
148362
|
if (options.realm.awaitResult(callable)) {
|
|
148043
148363
|
return Promise.resolve(result).then((value2) => copyHostResultToSandbox(value2, stackFrames, options));
|
|
148044
148364
|
}
|
|
@@ -148626,6 +148946,14 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path193) {
|
|
|
148626
148946
|
state
|
|
148627
148947
|
);
|
|
148628
148948
|
}
|
|
148949
|
+
const date = copyNativeDate(value);
|
|
148950
|
+
if (date !== void 0) {
|
|
148951
|
+
const existing = state.seen.get(value);
|
|
148952
|
+
if (existing !== void 0) return existing;
|
|
148953
|
+
budget.chargeDataUsage(9);
|
|
148954
|
+
state.seen.set(value, date);
|
|
148955
|
+
return date;
|
|
148956
|
+
}
|
|
148629
148957
|
if (isFloat32Array(value)) {
|
|
148630
148958
|
const existing = state.seen.get(value);
|
|
148631
148959
|
if (existing !== void 0) return existing;
|
|
@@ -148907,6 +149235,7 @@ var init_host_bridge = __esm({
|
|
|
148907
149235
|
"packages/safe-js/src/interp/host-bridge.ts"() {
|
|
148908
149236
|
"use strict";
|
|
148909
149237
|
init_async();
|
|
149238
|
+
init_date();
|
|
148910
149239
|
init_host_capabilities();
|
|
148911
149240
|
init_shape();
|
|
148912
149241
|
init_budget2();
|
|
@@ -149046,7 +149375,9 @@ function toJsonParseText(input) {
|
|
|
149046
149375
|
}
|
|
149047
149376
|
async function stringifyProperty(key3, holder, state, indent = "") {
|
|
149048
149377
|
let value = getOwnDataValue(holder, key3);
|
|
149049
|
-
if (
|
|
149378
|
+
if (isSandboxDate(value)) {
|
|
149379
|
+
value = dateMethods.get("toJSON").invoke(value, []);
|
|
149380
|
+
} else if (isStringifyContainer(value)) {
|
|
149050
149381
|
const toJSON = getOwnDataValue(value, "toJSON");
|
|
149051
149382
|
if (isSandboxClosure(toJSON)) {
|
|
149052
149383
|
value = await callStringifyClosure(toJSON, [key3], value, state);
|
|
@@ -149232,6 +149563,7 @@ function defineDataProperty8(target, key3, value) {
|
|
|
149232
149563
|
var init_console_json = __esm({
|
|
149233
149564
|
"packages/safe-js/src/interp/globals/console-json.ts"() {
|
|
149234
149565
|
"use strict";
|
|
149566
|
+
init_date();
|
|
149235
149567
|
init_compile_guard();
|
|
149236
149568
|
init_host_bridge();
|
|
149237
149569
|
init_values();
|
|
@@ -149493,6 +149825,7 @@ async function stringifyObject2(value, budget, context, joining) {
|
|
|
149493
149825
|
}
|
|
149494
149826
|
}
|
|
149495
149827
|
async function defaultToString(value, budget, context, joining) {
|
|
149828
|
+
if (isSandboxDate(value)) return budget.allocateString(dateString(value));
|
|
149496
149829
|
if (Array.isArray(value) || isFloat32Array(value)) {
|
|
149497
149830
|
if (Object.hasOwn(value, "join")) {
|
|
149498
149831
|
const join21 = ownDataValue(value, "join");
|
|
@@ -149539,6 +149872,7 @@ var init_string_coercion = __esm({
|
|
|
149539
149872
|
"packages/safe-js/src/interp/string-coercion.ts"() {
|
|
149540
149873
|
"use strict";
|
|
149541
149874
|
init_shape();
|
|
149875
|
+
init_date();
|
|
149542
149876
|
init_float32();
|
|
149543
149877
|
init_values();
|
|
149544
149878
|
}
|
|
@@ -149604,6 +149938,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149604
149938
|
getPrototypeOf: createSandboxClosure({
|
|
149605
149939
|
sandbox: true,
|
|
149606
149940
|
call: ([value]) => {
|
|
149941
|
+
if (isSandboxDate(value)) return getDatePrototype(value, options.budget, options.compileOwner);
|
|
149607
149942
|
objectProperties(value);
|
|
149608
149943
|
return getSandboxPrototype(value);
|
|
149609
149944
|
},
|
|
@@ -149728,7 +150063,7 @@ function createObjectArrayGlobals(options) {
|
|
|
149728
150063
|
}),
|
|
149729
150064
|
Number: createSandboxClosure({
|
|
149730
150065
|
sandbox: true,
|
|
149731
|
-
call: ([value]) => Number(value),
|
|
150066
|
+
call: ([value]) => isSandboxDate(value) ? dateTime(value) : Number(value),
|
|
149732
150067
|
name: "Number",
|
|
149733
150068
|
properties: {
|
|
149734
150069
|
isFinite: createSandboxClosure({
|
|
@@ -149828,6 +150163,10 @@ function assignSandboxValues(target, sources, budget) {
|
|
|
149828
150163
|
return target;
|
|
149829
150164
|
}
|
|
149830
150165
|
function objectProperties(value, mutable = false) {
|
|
150166
|
+
if (isSandboxDate(value)) {
|
|
150167
|
+
if (mutable) throw new TypeError("Date own properties and prototypes are not supported.");
|
|
150168
|
+
return value;
|
|
150169
|
+
}
|
|
149831
150170
|
if (isGuestHostObject(value)) throw new TypeError("Live host object descriptors are not supported.");
|
|
149832
150171
|
if (isGuestClosure(value)) return materializeFunctionProperties(value);
|
|
149833
150172
|
if (isSandboxClosure(value)) {
|
|
@@ -149945,6 +150284,8 @@ function getTemplateRawParts(template2) {
|
|
|
149945
150284
|
var init_object_array = __esm({
|
|
149946
150285
|
"packages/safe-js/src/interp/globals/object-array.ts"() {
|
|
149947
150286
|
"use strict";
|
|
150287
|
+
init_date();
|
|
150288
|
+
init_date2();
|
|
149948
150289
|
init_host_capabilities();
|
|
149949
150290
|
init_float32();
|
|
149950
150291
|
init_interpreter();
|
|
@@ -149961,6 +150302,7 @@ function createBuiltinBindings(options) {
|
|
|
149961
150302
|
...createConsoleJsonGlobals(options),
|
|
149962
150303
|
...createCollectionGlobals(options),
|
|
149963
150304
|
Float32Array: createFloat32ArrayGlobal(options.budget),
|
|
150305
|
+
Date: createDateGlobal(options),
|
|
149964
150306
|
...createErrorGlobals(options),
|
|
149965
150307
|
...createMathGlobals({ random: options.random }),
|
|
149966
150308
|
...createObjectArrayGlobals(options),
|
|
@@ -149981,6 +150323,7 @@ var init_globals = __esm({
|
|
|
149981
150323
|
init_misc();
|
|
149982
150324
|
init_object_array();
|
|
149983
150325
|
init_promise();
|
|
150326
|
+
init_date2();
|
|
149984
150327
|
}
|
|
149985
150328
|
});
|
|
149986
150329
|
|
|
@@ -150176,10 +150519,10 @@ var init_random = __esm({
|
|
|
150176
150519
|
|
|
150177
150520
|
// packages/safe-js/src/realm.ts
|
|
150178
150521
|
import { AsyncLocalStorage as AsyncLocalStorage9 } from "node:async_hooks";
|
|
150179
|
-
import { types as
|
|
150522
|
+
import { types as types4 } from "node:util";
|
|
150180
150523
|
function readModules(input) {
|
|
150181
150524
|
const entries = (value, label) => {
|
|
150182
|
-
if (
|
|
150525
|
+
if (types4.isMap(value) && !types4.isProxy(value)) {
|
|
150183
150526
|
const result = [...Map.prototype.entries.call(value)];
|
|
150184
150527
|
if (result.length > 4096 || result.some(([key3]) => typeof key3 !== "string" || key3.length === 0))
|
|
150185
150528
|
throw new TypeError(`${label} requires bounded string keys.`);
|
|
@@ -150242,6 +150585,7 @@ function readRealmOptions(value, oneShot = false) {
|
|
|
150242
150585
|
"signal",
|
|
150243
150586
|
"sink",
|
|
150244
150587
|
"randomSeed",
|
|
150588
|
+
"clock",
|
|
150245
150589
|
"limits"
|
|
150246
150590
|
]);
|
|
150247
150591
|
for (const [key3, entry] of Object.entries(options)) {
|
|
@@ -150281,6 +150625,7 @@ var init_realm = __esm({
|
|
|
150281
150625
|
extensions: 32,
|
|
150282
150626
|
hostObjects: 1024,
|
|
150283
150627
|
callbacks: 1024,
|
|
150628
|
+
guestReferences: 1024,
|
|
150284
150629
|
cleanups: 1024,
|
|
150285
150630
|
nestedEvaluations: 16
|
|
150286
150631
|
};
|
|
@@ -150289,7 +150634,7 @@ var init_realm = __esm({
|
|
|
150289
150634
|
throw new TypeError("Realm limits must be positive safe integers with supported names.");
|
|
150290
150635
|
this.limits[name] = Number(value);
|
|
150291
150636
|
}
|
|
150292
|
-
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) ||
|
|
150637
|
+
if (options.extensions !== void 0 && (!Array.isArray(options.extensions) || types4.isProxy(options.extensions)))
|
|
150293
150638
|
throw new TypeError("Extensions must be a registration array.");
|
|
150294
150639
|
const registrations = options.extensions ?? [];
|
|
150295
150640
|
const extensions = [];
|
|
@@ -150317,6 +150662,7 @@ var init_realm = __esm({
|
|
|
150317
150662
|
owner: this,
|
|
150318
150663
|
assertActive: this.assertOpen,
|
|
150319
150664
|
wrapCallback: this.wrapCallback,
|
|
150665
|
+
captureArguments: this.captureArguments,
|
|
150320
150666
|
invoke: this.invokeHost,
|
|
150321
150667
|
awaitResult: (operation) => this.nestedOperations.has(operation)
|
|
150322
150668
|
};
|
|
@@ -150325,6 +150671,7 @@ var init_realm = __esm({
|
|
|
150325
150671
|
budget: this.budget,
|
|
150326
150672
|
compileOwner: this.lease.owner,
|
|
150327
150673
|
sink: options.sink,
|
|
150674
|
+
clock: options.clock,
|
|
150328
150675
|
random: createReplayableRandom({ seed: options.randomSeed }).next
|
|
150329
150676
|
});
|
|
150330
150677
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -150356,7 +150703,7 @@ var init_realm = __esm({
|
|
|
150356
150703
|
}
|
|
150357
150704
|
options.signal?.addEventListener("abort", this.abort, { once: true });
|
|
150358
150705
|
if (options.signal?.aborted) this.abort();
|
|
150359
|
-
this.budget.setRetainedValues(this, this.
|
|
150706
|
+
this.budget.setRetainedValues(this, this.retainedRoots);
|
|
150360
150707
|
this.tracker.onFatalRejection((error3) => this.poison(error3));
|
|
150361
150708
|
} catch (error3) {
|
|
150362
150709
|
this.compilation.dispose();
|
|
@@ -150380,6 +150727,8 @@ var init_realm = __esm({
|
|
|
150380
150727
|
pendingCallbacks = /* @__PURE__ */ new Set();
|
|
150381
150728
|
callbackCache = /* @__PURE__ */ new WeakMap();
|
|
150382
150729
|
hostObjects = /* @__PURE__ */ new Set();
|
|
150730
|
+
guestReferences = /* @__PURE__ */ new Map();
|
|
150731
|
+
retainedOperations = /* @__PURE__ */ new WeakMap();
|
|
150383
150732
|
nestedOperations = /* @__PURE__ */ new WeakMap();
|
|
150384
150733
|
convertedModules = /* @__PURE__ */ new Map();
|
|
150385
150734
|
nativeConversions = { seen: /* @__PURE__ */ new WeakMap() };
|
|
@@ -150399,10 +150748,56 @@ var init_realm = __esm({
|
|
|
150399
150748
|
signal: this.controller.signal,
|
|
150400
150749
|
realm: this.bridge
|
|
150401
150750
|
});
|
|
150402
|
-
|
|
150751
|
+
retainedRoots = () => [
|
|
150403
150752
|
...this.callbacks.values(),
|
|
150404
|
-
...Array.from(this.pendingCallbacks, (pending) => pending.closure)
|
|
150753
|
+
...Array.from(this.pendingCallbacks, (pending) => pending.closure),
|
|
150754
|
+
...this.guestReferences.values()
|
|
150405
150755
|
];
|
|
150756
|
+
captureArguments = (operation, args, copy) => {
|
|
150757
|
+
const from = this.retainedOperations.get(operation)?.from ?? args.length;
|
|
150758
|
+
const values = copy(args.slice(0, from));
|
|
150759
|
+
const captured = [];
|
|
150760
|
+
const rollback = () => {
|
|
150761
|
+
for (const reference of captured) {
|
|
150762
|
+
revokeGuestReference(reference, this);
|
|
150763
|
+
this.guestReferences.delete(reference);
|
|
150764
|
+
}
|
|
150765
|
+
};
|
|
150766
|
+
try {
|
|
150767
|
+
for (const value of args.slice(from)) {
|
|
150768
|
+
this.checkCollection(
|
|
150769
|
+
this.guestReferences.size + 1,
|
|
150770
|
+
this.limits.guestReferences,
|
|
150771
|
+
"guest reference"
|
|
150772
|
+
);
|
|
150773
|
+
const root = [value];
|
|
150774
|
+
const reference = createGuestReference(root, this, this.assertOpen);
|
|
150775
|
+
this.guestReferences.set(reference, root);
|
|
150776
|
+
captured.push(reference);
|
|
150777
|
+
values.push(reference);
|
|
150778
|
+
}
|
|
150779
|
+
if (captured.length > 0)
|
|
150780
|
+
this.budget.reconcileDataUsage(
|
|
150781
|
+
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.retainedRoots()])
|
|
150782
|
+
);
|
|
150783
|
+
return { args: values, rollback };
|
|
150784
|
+
} catch (error3) {
|
|
150785
|
+
rollback();
|
|
150786
|
+
if (error3 instanceof SandboxError) this.poison(error3);
|
|
150787
|
+
throw error3;
|
|
150788
|
+
}
|
|
150789
|
+
};
|
|
150790
|
+
releaseGuestReference = (reference) => {
|
|
150791
|
+
readGuestReference(reference, this);
|
|
150792
|
+
revokeGuestReference(reference, this);
|
|
150793
|
+
this.guestReferences.delete(reference);
|
|
150794
|
+
if (this.active === void 0)
|
|
150795
|
+
reconcileCompiledValues(
|
|
150796
|
+
this.budget,
|
|
150797
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150798
|
+
this.compilation
|
|
150799
|
+
);
|
|
150800
|
+
};
|
|
150406
150801
|
assertOpen = () => {
|
|
150407
150802
|
if (this.failure !== void 0) throw this.failure.reason;
|
|
150408
150803
|
if (this.closed) throw new Error("SafeJS realm is closed; capabilities are revoked.");
|
|
@@ -150458,7 +150853,7 @@ var init_realm = __esm({
|
|
|
150458
150853
|
return this.phase.run(phase, () => {
|
|
150459
150854
|
try {
|
|
150460
150855
|
const result = call();
|
|
150461
|
-
if (
|
|
150856
|
+
if (types4.isPromise(result) || phase.pending.size > 0 || phase.failure !== void 0) {
|
|
150462
150857
|
return Promise.resolve(result).then(
|
|
150463
150858
|
async (value) => {
|
|
150464
150859
|
await Promise.allSettled(phase.pending);
|
|
@@ -150515,7 +150910,7 @@ var init_realm = __esm({
|
|
|
150515
150910
|
chargeWork: this.chargeWork,
|
|
150516
150911
|
read: (operation) => {
|
|
150517
150912
|
const value = this.invokeHost(operation, operation);
|
|
150518
|
-
if (
|
|
150913
|
+
if (types4.isPromise(value)) {
|
|
150519
150914
|
void Promise.resolve(value).catch(() => void 0);
|
|
150520
150915
|
throw new TypeError("Live property getters must be synchronous.");
|
|
150521
150916
|
}
|
|
@@ -150523,7 +150918,7 @@ var init_realm = __esm({
|
|
|
150523
150918
|
},
|
|
150524
150919
|
write: (operation, value) => {
|
|
150525
150920
|
const result = this.invokeHost(operation, () => operation(this.exportValue(value)));
|
|
150526
|
-
if (
|
|
150921
|
+
if (types4.isPromise(result)) {
|
|
150527
150922
|
void Promise.resolve(result).catch(() => void 0);
|
|
150528
150923
|
throw new TypeError("Live property setters must be synchronous.");
|
|
150529
150924
|
}
|
|
@@ -150570,7 +150965,7 @@ var init_realm = __esm({
|
|
|
150570
150965
|
});
|
|
150571
150966
|
try {
|
|
150572
150967
|
this.budget.reconcileDataUsage(
|
|
150573
|
-
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.
|
|
150968
|
+
measureSandboxData([...this.scope?.retainedValues() ?? [], ...this.retainedRoots()])
|
|
150574
150969
|
);
|
|
150575
150970
|
} catch (error3) {
|
|
150576
150971
|
this.poison(error3);
|
|
@@ -150585,7 +150980,7 @@ var init_realm = __esm({
|
|
|
150585
150980
|
if (this.active === void 0)
|
|
150586
150981
|
reconcileCompiledValues(
|
|
150587
150982
|
this.budget,
|
|
150588
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
150983
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150589
150984
|
this.compilation
|
|
150590
150985
|
);
|
|
150591
150986
|
};
|
|
@@ -150644,7 +151039,7 @@ var init_realm = __esm({
|
|
|
150644
151039
|
if (!this.closed && this.active === void 0)
|
|
150645
151040
|
reconcileCompiledValues(
|
|
150646
151041
|
this.budget,
|
|
150647
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
151042
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150648
151043
|
this.compilation
|
|
150649
151044
|
);
|
|
150650
151045
|
}
|
|
@@ -150661,6 +151056,23 @@ var init_realm = __esm({
|
|
|
150661
151056
|
createHostObject: this.createHostObject,
|
|
150662
151057
|
invokeCallback: this.invokeCallback,
|
|
150663
151058
|
releaseCallback: this.releaseCallback,
|
|
151059
|
+
releaseGuestReference: this.releaseGuestReference,
|
|
151060
|
+
retainGuestArguments: (operation, from) => {
|
|
151061
|
+
this.assertOpen();
|
|
151062
|
+
if (!extension.manifest.capabilities?.includes("guest:retain"))
|
|
151063
|
+
throw new TypeError("Retaining arguments requires the guest:retain grant.");
|
|
151064
|
+
if (typeof operation !== "function")
|
|
151065
|
+
throw new TypeError("Retained operation must be a function.");
|
|
151066
|
+
if (!Number.isSafeInteger(from) || from < 0)
|
|
151067
|
+
throw new TypeError("Argument index must be a non-negative safe integer.");
|
|
151068
|
+
if (this.scope !== void 0)
|
|
151069
|
+
throw new TypeError("Retained operations must be registered during setup.");
|
|
151070
|
+
const previous = this.retainedOperations.get(operation);
|
|
151071
|
+
if (previous !== void 0 && (previous.extension !== extension || previous.from !== from))
|
|
151072
|
+
throw new TypeError("Conflicting retained operation declaration.");
|
|
151073
|
+
this.retainedOperations.set(operation, { extension, from });
|
|
151074
|
+
return operation;
|
|
151075
|
+
},
|
|
150664
151076
|
nestedOperation: (operation) => {
|
|
150665
151077
|
this.assertOpen();
|
|
150666
151078
|
if (!extension.manifest.capabilities?.includes("source:nested"))
|
|
@@ -150699,7 +151111,7 @@ var init_realm = __esm({
|
|
|
150699
151111
|
}
|
|
150700
151112
|
});
|
|
150701
151113
|
const output = getExtensionSetup(extension)(context);
|
|
150702
|
-
if (
|
|
151114
|
+
if (types4.isPromise(output)) {
|
|
150703
151115
|
void Promise.resolve(output).catch(() => void 0);
|
|
150704
151116
|
throw new TypeError("Extension setup must be synchronous.");
|
|
150705
151117
|
}
|
|
@@ -150823,7 +151235,7 @@ var init_realm = __esm({
|
|
|
150823
151235
|
if (!this.closed)
|
|
150824
151236
|
reconcileCompiledValues(
|
|
150825
151237
|
this.budget,
|
|
150826
|
-
[...this.scope?.retainedValues() ?? [], ...this.
|
|
151238
|
+
[...this.scope?.retainedValues() ?? [], ...this.retainedRoots()],
|
|
150827
151239
|
this.compilation
|
|
150828
151240
|
);
|
|
150829
151241
|
return result;
|
|
@@ -150857,6 +151269,8 @@ var init_realm = __esm({
|
|
|
150857
151269
|
this.callbacks.clear();
|
|
150858
151270
|
for (const object of this.hostObjects) revokeHostObject(object, this);
|
|
150859
151271
|
this.hostObjects.clear();
|
|
151272
|
+
for (const reference of this.guestReferences.keys()) revokeGuestReference(reference, this);
|
|
151273
|
+
this.guestReferences.clear();
|
|
150860
151274
|
this.budget.setRetainedValues(this, void 0);
|
|
150861
151275
|
this.disposal = (async () => {
|
|
150862
151276
|
const errors2 = [];
|
|
@@ -151319,6 +151733,7 @@ var init_serialize = __esm({
|
|
|
151319
151733
|
init_arrays();
|
|
151320
151734
|
init_float32();
|
|
151321
151735
|
init_float32array();
|
|
151736
|
+
init_date();
|
|
151322
151737
|
init_values();
|
|
151323
151738
|
UnsnapshotableValueError = class extends Error {
|
|
151324
151739
|
path;
|
|
@@ -151526,7 +151941,7 @@ function run(source, options = {}) {
|
|
|
151526
151941
|
lifecycle
|
|
151527
151942
|
})
|
|
151528
151943
|
);
|
|
151529
|
-
const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next });
|
|
151944
|
+
const builtinBindings = createBuiltinBindings({ compileOwner: operation.owner, budget, hostCalls, sink: options.sink, random: random?.generator.next, clock: options.clock });
|
|
151530
151945
|
const importMeta = convertInitialInput(
|
|
151531
151946
|
() => deepCopyToSandbox(options.importMeta ?? {})
|
|
151532
151947
|
);
|
|
@@ -158877,7 +159292,7 @@ var init_package2 = __esm({
|
|
|
158877
159292
|
"package.json"() {
|
|
158878
159293
|
package_default2 = {
|
|
158879
159294
|
name: "poe-code",
|
|
158880
|
-
version: "14.0.
|
|
159295
|
+
version: "14.0.7",
|
|
158881
159296
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
158882
159297
|
license: "MIT",
|
|
158883
159298
|
type: "module",
|