@poe-platform/safe-js 0.1.457 → 0.1.459
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-js/chunks/{chunk-OXTOMAYL.js → chunk-7A542ATS.js} +247 -54
- package/dist/safe-js/chunks/{chunk-OXTOMAYL.js.map → chunk-7A542ATS.js.map} +4 -4
- package/dist/safe-js/chunks/{chunk-ENSU5YTC.js → chunk-TQ4EDT4V.js} +2 -2
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/intl-datetimeformat.d.ts +16 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +6 -0
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-ENSU5YTC.js.map → chunk-TQ4EDT4V.js.map} +0 -0
|
@@ -8258,13 +8258,13 @@ function createLiveHostObject(definition, controller) {
|
|
|
8258
8258
|
controller.chargeWork(properties.size + Object.keys(operations).length + 1);
|
|
8259
8259
|
const host = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
8260
8260
|
const guest = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
8261
|
-
const
|
|
8261
|
+
const methods3 = new Map(
|
|
8262
8262
|
Object.entries(operations).map(([name, operation]) => [
|
|
8263
8263
|
name,
|
|
8264
8264
|
controller.method(operation)
|
|
8265
8265
|
])
|
|
8266
8266
|
);
|
|
8267
|
-
const state = { host, guest, controller, properties, methods:
|
|
8267
|
+
const state = { host, guest, controller, properties, methods: methods3, indexed, named };
|
|
8268
8268
|
hostObjects.set(host, state);
|
|
8269
8269
|
guestObjects.set(guest, state);
|
|
8270
8270
|
return host;
|
|
@@ -8691,11 +8691,11 @@ function isIntrinsicFunction(value) {
|
|
|
8691
8691
|
function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
8692
8692
|
if (constructor.name === void 0) throw new TypeError("Intrinsic constructors require an installation name.");
|
|
8693
8693
|
registerBuiltinIdentities(budget, { [constructor.name]: constructor });
|
|
8694
|
-
const
|
|
8694
|
+
const methods3 = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).flatMap((key) => {
|
|
8695
8695
|
const descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
8696
8696
|
return [descriptor.value, ...retainedAccessorClosures(descriptor)];
|
|
8697
8697
|
})).filter(isGuestClosure);
|
|
8698
|
-
trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...
|
|
8698
|
+
trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...methods3]);
|
|
8699
8699
|
}
|
|
8700
8700
|
function registerIntrinsicFunction(budget, closure) {
|
|
8701
8701
|
if (closure.name === void 0) throw new TypeError("Intrinsic functions require an installation name.");
|
|
@@ -8704,8 +8704,8 @@ function registerIntrinsicFunction(budget, closure) {
|
|
|
8704
8704
|
trackIntrinsicState(budget, closure, closure, [closure]);
|
|
8705
8705
|
}
|
|
8706
8706
|
function registerIntrinsicObject(budget, value, trackMethods = true) {
|
|
8707
|
-
const
|
|
8708
|
-
trackIntrinsicState(budget, value, value, [value, ...
|
|
8707
|
+
const methods3 = trackMethods ? Object.values(Object.getOwnPropertyDescriptors(value)).map((descriptor) => descriptor.value).filter(isGuestClosure) : [];
|
|
8708
|
+
trackIntrinsicState(budget, value, value, [value, ...methods3]);
|
|
8709
8709
|
}
|
|
8710
8710
|
function completeIntrinsicObjectInitialization(budget, value) {
|
|
8711
8711
|
for (const records of intrinsicRetentionGroups.get(budget)?.values() ?? []) {
|
|
@@ -10199,7 +10199,7 @@ async function nextArrayIterator(value, budget, context) {
|
|
|
10199
10199
|
}
|
|
10200
10200
|
|
|
10201
10201
|
// packages/safe-js/src/interp/globals/object.ts
|
|
10202
|
-
function createObjectGlobal(
|
|
10202
|
+
function createObjectGlobal(methods3, budget) {
|
|
10203
10203
|
const construct = ([value]) => {
|
|
10204
10204
|
if (value === null || value === void 0) {
|
|
10205
10205
|
budget.chargeDataUsage(1);
|
|
@@ -10235,7 +10235,7 @@ function createObjectGlobal(methods2, budget) {
|
|
|
10235
10235
|
const prototype = createIntrinsicObject(properties.prototype);
|
|
10236
10236
|
properties.prototype = prototype;
|
|
10237
10237
|
Object.defineProperty(properties, "prototype", { writable: false });
|
|
10238
|
-
for (const [name, method] of Object.entries(
|
|
10238
|
+
for (const [name, method] of Object.entries(methods3)) {
|
|
10239
10239
|
Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
|
|
10240
10240
|
}
|
|
10241
10241
|
const prototypeMethods = {
|
|
@@ -19916,6 +19916,7 @@ function getStringMember(value, property, budget) {
|
|
|
19916
19916
|
return createSandboxClosure({
|
|
19917
19917
|
sandbox: true,
|
|
19918
19918
|
name: `String#${property}`,
|
|
19919
|
+
...property === "trimStart" || property === "trimEnd" ? { guest: true, name: property, length: 0 } : {},
|
|
19919
19920
|
...property === "toLocaleLowerCase" || property === "toLocaleUpperCase" ? { guest: true, name: property, length: 0 } : {},
|
|
19920
19921
|
...property === "localeCompare" ? { length: 1 } : {},
|
|
19921
19922
|
...property === "isWellFormed" || property === "toWellFormed" ? { length: 0 } : {},
|
|
@@ -20723,7 +20724,7 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
20723
20724
|
writable: isSandboxClosure(value),
|
|
20724
20725
|
configurable: isSandboxClosure(value)
|
|
20725
20726
|
});
|
|
20726
|
-
const
|
|
20727
|
+
const methods3 = /* @__PURE__ */ new Map([
|
|
20727
20728
|
[
|
|
20728
20729
|
"valueOf",
|
|
20729
20730
|
createSandboxClosure({
|
|
@@ -20735,9 +20736,9 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
20735
20736
|
]
|
|
20736
20737
|
]);
|
|
20737
20738
|
if (kind === "number") {
|
|
20738
|
-
for (const name of numberMethodNames)
|
|
20739
|
+
for (const name of numberMethodNames) methods3.set(name, getNumberMember(name, budget));
|
|
20739
20740
|
} else {
|
|
20740
|
-
|
|
20741
|
+
methods3.set(
|
|
20741
20742
|
"toString",
|
|
20742
20743
|
createSandboxClosure({
|
|
20743
20744
|
sandbox: true,
|
|
@@ -20746,10 +20747,13 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
20746
20747
|
call: (_args, context) => budget.allocateString(String(primitiveReceiver(context?.thisValue, kind)))
|
|
20747
20748
|
})
|
|
20748
20749
|
);
|
|
20749
|
-
if (kind === "string")
|
|
20750
|
-
for (const name of stringMethodNames)
|
|
20750
|
+
if (kind === "string") {
|
|
20751
|
+
for (const name of stringMethodNames) methods3.set(name, getStringMember("", name, budget));
|
|
20752
|
+
methods3.set("trimLeft", methods3.get("trimStart"));
|
|
20753
|
+
methods3.set("trimRight", methods3.get("trimEnd"));
|
|
20754
|
+
}
|
|
20751
20755
|
}
|
|
20752
|
-
for (const [name, value] of
|
|
20756
|
+
for (const [name, value] of methods3)
|
|
20753
20757
|
Object.defineProperty(prototype, name, { value, writable: true, configurable: true });
|
|
20754
20758
|
if (kind === "string") {
|
|
20755
20759
|
const iteratorPrototype = createIntrinsicObject();
|
|
@@ -28744,6 +28748,36 @@ function formatNumberValue(receiver, method, values) {
|
|
|
28744
28748
|
return numberFormatterResult2(native, method, values);
|
|
28745
28749
|
}
|
|
28746
28750
|
|
|
28751
|
+
// packages/safe-js/src/interp/intl-datetimeformat.ts
|
|
28752
|
+
var NativeDateTimeFormat = Intl.DateTimeFormat;
|
|
28753
|
+
var resolvedOptions5 = NativeDateTimeFormat.prototype.resolvedOptions;
|
|
28754
|
+
var format3 = Object.getOwnPropertyDescriptor(NativeDateTimeFormat.prototype, "format").get;
|
|
28755
|
+
var methods = {
|
|
28756
|
+
formatToParts: NativeDateTimeFormat.prototype.formatToParts,
|
|
28757
|
+
formatRange: NativeDateTimeFormat.prototype.formatRange,
|
|
28758
|
+
formatRangeToParts: NativeDateTimeFormat.prototype.formatRangeToParts
|
|
28759
|
+
};
|
|
28760
|
+
var states10 = /* @__PURE__ */ new WeakMap();
|
|
28761
|
+
function createSandboxDateTimeFormat(locales2, options, restoring = false) {
|
|
28762
|
+
const input = { ...options };
|
|
28763
|
+
if (restoring) delete input.hour12;
|
|
28764
|
+
const native = new NativeDateTimeFormat(locales2, input);
|
|
28765
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
28766
|
+
states10.set(value, { native, options: { ...Reflect.apply(resolvedOptions5, native, []) } });
|
|
28767
|
+
return value;
|
|
28768
|
+
}
|
|
28769
|
+
function isSandboxDateTimeFormat(value) {
|
|
28770
|
+
return typeof value === "object" && value !== null && states10.has(value);
|
|
28771
|
+
}
|
|
28772
|
+
function dateTimeFormatState(value) {
|
|
28773
|
+
if (!isSandboxDateTimeFormat(value)) throw new TypeError("Intl.DateTimeFormat requires a DateTimeFormat receiver.");
|
|
28774
|
+
return states10.get(value);
|
|
28775
|
+
}
|
|
28776
|
+
function formatDateTimeValue(receiver, method, values) {
|
|
28777
|
+
const { native } = dateTimeFormatState(receiver);
|
|
28778
|
+
return method === "format" ? Reflect.apply(format3, native, [])(values[0]) : Reflect.apply(methods[method], native, values);
|
|
28779
|
+
}
|
|
28780
|
+
|
|
28747
28781
|
// packages/safe-js/src/interp/iterator-helper.ts
|
|
28748
28782
|
var iteratorHelperStates = /* @__PURE__ */ new WeakMap();
|
|
28749
28783
|
|
|
@@ -29086,9 +29120,13 @@ function captureGuestHeapNode(value, encode) {
|
|
|
29086
29120
|
if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
|
|
29087
29121
|
if (isSandboxRelativeTimeFormat(value)) return { kind: "guest-relativetimeformat", options: { ...relativeTimeFormatState(value).options }, state: captureObjectState(value, encode) };
|
|
29088
29122
|
if (isSandboxDisplayNames(value)) return { kind: "guest-displaynames", options: { ...displayNamesState(value).options }, state: captureObjectState(value, encode) };
|
|
29123
|
+
if (isSandboxDateTimeFormat(value)) {
|
|
29124
|
+
const { options, format: format4 } = dateTimeFormatState(value);
|
|
29125
|
+
return { kind: "guest-datetimeformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
|
|
29126
|
+
}
|
|
29089
29127
|
if (isSandboxNumberFormat(value)) {
|
|
29090
|
-
const { options, format:
|
|
29091
|
-
return { kind: "guest-numberformat", options: { ...options }, ...
|
|
29128
|
+
const { options, format: format4 } = numberFormatState(value);
|
|
29129
|
+
return { kind: "guest-numberformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
|
|
29092
29130
|
}
|
|
29093
29131
|
if (isSandboxCollator(value)) {
|
|
29094
29132
|
const { options, compare } = collatorState(value);
|
|
@@ -30166,7 +30204,7 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
|
30166
30204
|
}
|
|
30167
30205
|
|
|
30168
30206
|
// packages/safe-js/src/interp/date-locale.ts
|
|
30169
|
-
var
|
|
30207
|
+
var NativeDateTimeFormat2 = Intl.DateTimeFormat;
|
|
30170
30208
|
var dateTimeOptions = [
|
|
30171
30209
|
["localeMatcher", ["lookup", "best fit"]],
|
|
30172
30210
|
["calendar", "unicodeType"],
|
|
@@ -30189,14 +30227,11 @@ var dateTimeOptions = [
|
|
|
30189
30227
|
["dateStyle", ["full", "long", "medium", "short"]],
|
|
30190
30228
|
["timeStyle", ["full", "long", "medium", "short"]]
|
|
30191
30229
|
];
|
|
30192
|
-
async function
|
|
30193
|
-
if (Number.isNaN(time)) return budget.allocateString("Invalid Date");
|
|
30194
|
-
let locales2 = [];
|
|
30230
|
+
async function readDateTimeFormatOptions(input, budget, context) {
|
|
30195
30231
|
const options = /* @__PURE__ */ Object.create(null);
|
|
30196
|
-
const release = retainValues(budget, () => [
|
|
30232
|
+
const release = retainValues(budget, () => [input, options]);
|
|
30197
30233
|
try {
|
|
30198
|
-
|
|
30199
|
-
const inputOptions = intlOptionsObject(args[1], budget);
|
|
30234
|
+
const inputOptions = intlOptionsObject(input, budget);
|
|
30200
30235
|
for (const [key, type] of dateTimeOptions) {
|
|
30201
30236
|
const value = await readIntlProperty(inputOptions, key, budget, context);
|
|
30202
30237
|
if (value === void 0) continue;
|
|
@@ -30208,10 +30243,23 @@ async function formatDateLocale(name, time, args, budget, context) {
|
|
|
30208
30243
|
} else if (type === "zone") {
|
|
30209
30244
|
const text = await sandboxString(value, budget, context);
|
|
30210
30245
|
budget.visitNode(text.length);
|
|
30211
|
-
new
|
|
30246
|
+
new NativeDateTimeFormat2("en", { timeZone: text });
|
|
30212
30247
|
options[key] = text;
|
|
30213
30248
|
} else options[key] = await convertIntlOption(value, key, type, budget, context);
|
|
30214
30249
|
}
|
|
30250
|
+
return options;
|
|
30251
|
+
} finally {
|
|
30252
|
+
release();
|
|
30253
|
+
}
|
|
30254
|
+
}
|
|
30255
|
+
async function formatDateLocale(name, time, args, budget, context) {
|
|
30256
|
+
if (Number.isNaN(time)) return budget.allocateString("Invalid Date");
|
|
30257
|
+
let locales2 = [];
|
|
30258
|
+
let options = /* @__PURE__ */ Object.create(null);
|
|
30259
|
+
const release = retainValues(budget, () => [locales2, options]);
|
|
30260
|
+
try {
|
|
30261
|
+
locales2 = await canonicalizeGuestLocales(args[0], budget, context);
|
|
30262
|
+
options = await readDateTimeFormatOptions(args[1], budget, context);
|
|
30215
30263
|
const date = name !== "toLocaleTimeString";
|
|
30216
30264
|
const clock = name !== "toLocaleDateString";
|
|
30217
30265
|
if (options.dateStyle !== void 0 || options.timeStyle !== void 0) {
|
|
@@ -30225,7 +30273,7 @@ async function formatDateLocale(name, time, args, budget, context) {
|
|
|
30225
30273
|
if (clock) for (const key of ["hour", "minute", "second"]) options[key] = "numeric";
|
|
30226
30274
|
}
|
|
30227
30275
|
}
|
|
30228
|
-
const formatter = new
|
|
30276
|
+
const formatter = new NativeDateTimeFormat2(locales2, options);
|
|
30229
30277
|
return budget.allocateString(formatter.format(time));
|
|
30230
30278
|
} finally {
|
|
30231
30279
|
release();
|
|
@@ -30310,9 +30358,9 @@ function createDateGlobal(options) {
|
|
|
30310
30358
|
call: (args, context) => coerceDateParts(args, true, options.budget, context)
|
|
30311
30359
|
})
|
|
30312
30360
|
};
|
|
30313
|
-
const
|
|
30361
|
+
const methods3 = /* @__PURE__ */ new Map();
|
|
30314
30362
|
for (const [name, method] of dateMethods)
|
|
30315
|
-
|
|
30363
|
+
methods3.set(
|
|
30316
30364
|
name,
|
|
30317
30365
|
createSandboxClosure({
|
|
30318
30366
|
guest: true,
|
|
@@ -30332,8 +30380,8 @@ function createDateGlobal(options) {
|
|
|
30332
30380
|
}
|
|
30333
30381
|
})
|
|
30334
30382
|
);
|
|
30335
|
-
|
|
30336
|
-
|
|
30383
|
+
methods3.set("toGMTString", methods3.get("toUTCString"));
|
|
30384
|
+
methods3.set(Symbol.toPrimitive, createSandboxClosure({
|
|
30337
30385
|
guest: true,
|
|
30338
30386
|
sandbox: true,
|
|
30339
30387
|
name: "[Symbol.toPrimitive]",
|
|
@@ -30349,7 +30397,7 @@ function createDateGlobal(options) {
|
|
|
30349
30397
|
for (const [key, value] of Object.entries(staticProperties))
|
|
30350
30398
|
Object.defineProperty(properties, key, { value, writable: key !== "prototype", configurable: key !== "prototype" });
|
|
30351
30399
|
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
30352
|
-
for (const [key, value] of
|
|
30400
|
+
for (const [key, value] of methods3)
|
|
30353
30401
|
Object.defineProperty(prototype, key, { value, writable: key !== Symbol.toPrimitive, configurable: true });
|
|
30354
30402
|
installDatePrototype(options.budget, prototype, constructor);
|
|
30355
30403
|
return constructor;
|
|
@@ -30889,7 +30937,7 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
30889
30937
|
return context.thisValue.values.size;
|
|
30890
30938
|
}
|
|
30891
30939
|
});
|
|
30892
|
-
for (const { name, constructor, methods:
|
|
30940
|
+
for (const { name, constructor, methods: methods3, size, iterator } of [
|
|
30893
30941
|
{ name: "Map", constructor: mapConstructor, methods: mapMethods, size: mapSize, iterator: mapMethods.entries },
|
|
30894
30942
|
{ name: "Set", constructor: setConstructor, methods: setMethods, size: setSize, iterator: setMethods.values }
|
|
30895
30943
|
]) {
|
|
@@ -30904,13 +30952,13 @@ function installCollectionPrototypes(budget, mapConstructor, setConstructor) {
|
|
|
30904
30952
|
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
|
|
30905
30953
|
Object.defineProperty(materializeFunctionProperties(constructor), Symbol.species, { get: accessorAdapter(species, "get"), configurable: true });
|
|
30906
30954
|
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
30907
|
-
for (const [key, method] of Object.entries(
|
|
30955
|
+
for (const [key, method] of Object.entries(methods3))
|
|
30908
30956
|
Object.defineProperty(prototype, key, { value: method, writable: true, configurable: true });
|
|
30909
30957
|
Object.defineProperty(prototype, "size", { get: accessorAdapter(size, "get"), configurable: true });
|
|
30910
30958
|
Object.defineProperty(prototype, Symbol.toStringTag, { value: name, configurable: true });
|
|
30911
30959
|
Object.defineProperty(prototype, Symbol.iterator, { value: iterator, writable: true, configurable: true });
|
|
30912
30960
|
installCollectionPrototype(budget, name, prototype, constructor);
|
|
30913
|
-
for (const method of /* @__PURE__ */ new Set([...Object.values(
|
|
30961
|
+
for (const method of /* @__PURE__ */ new Set([...Object.values(methods3), size, species])) registerIntrinsicFunction(budget, method);
|
|
30914
30962
|
}
|
|
30915
30963
|
}
|
|
30916
30964
|
function installCollectionIteratorPrototypes(budget) {
|
|
@@ -32793,7 +32841,7 @@ function createSymbolGlobal(budget) {
|
|
|
32793
32841
|
});
|
|
32794
32842
|
const properties = materializeFunctionProperties(constructor);
|
|
32795
32843
|
Object.defineProperty(properties, "prototype", { value: prototype });
|
|
32796
|
-
const
|
|
32844
|
+
const methods3 = {
|
|
32797
32845
|
for: createSandboxClosure({
|
|
32798
32846
|
sandbox: true,
|
|
32799
32847
|
name: "for",
|
|
@@ -32821,7 +32869,7 @@ function createSymbolGlobal(budget) {
|
|
|
32821
32869
|
}
|
|
32822
32870
|
})
|
|
32823
32871
|
};
|
|
32824
|
-
for (const [name, method] of Object.entries(
|
|
32872
|
+
for (const [name, method] of Object.entries(methods3)) {
|
|
32825
32873
|
symbolRegistryOrigins.set(method, entries);
|
|
32826
32874
|
Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
|
|
32827
32875
|
}
|
|
@@ -33084,17 +33132,17 @@ function createArrayBufferGlobal(budget) {
|
|
|
33084
33132
|
}
|
|
33085
33133
|
|
|
33086
33134
|
// packages/safe-js/src/interp/globals/data-view.ts
|
|
33087
|
-
var
|
|
33135
|
+
var methods2 = Object.fromEntries(["Int8", "Uint8", "Int16", "Uint16", "Int32", "Uint32", "Float32", "Float64", "BigInt64", "BigUint64"].flatMap((type) => ["get", "set"].map((operation) => [operation + type, Object.getOwnPropertyDescriptor(DataView.prototype, operation + type).value])));
|
|
33088
33136
|
var readUint16 = DataView.prototype.getUint16;
|
|
33089
33137
|
var writeUint16 = DataView.prototype.setUint16;
|
|
33090
|
-
|
|
33138
|
+
methods2.getFloat16 = function(...args) {
|
|
33091
33139
|
const bits = Reflect.apply(readUint16, this, args);
|
|
33092
33140
|
const sign = bits & 32768 ? -1 : 1;
|
|
33093
33141
|
const exponent = bits >> 10 & 31, fraction = bits & 1023;
|
|
33094
33142
|
if (exponent === 31) return fraction === 0 ? sign * Infinity : NaN;
|
|
33095
33143
|
return sign * (exponent === 0 ? fraction * 2 ** -24 : (1 + fraction / 1024) * 2 ** (exponent - 15));
|
|
33096
33144
|
};
|
|
33097
|
-
|
|
33145
|
+
methods2.setFloat16 = function(...args) {
|
|
33098
33146
|
const rounded = f16round(args[1]);
|
|
33099
33147
|
const sign = rounded < 0 || Object.is(rounded, -0) ? 32768 : 0;
|
|
33100
33148
|
const magnitude = Math.abs(rounded);
|
|
@@ -33166,7 +33214,7 @@ function createDataViewGlobal(budget) {
|
|
|
33166
33214
|
Object.defineProperty(prototype, name, { get: accessorAdapter(closure, "get"), configurable: true });
|
|
33167
33215
|
getters.push(closure);
|
|
33168
33216
|
}
|
|
33169
|
-
for (const [name, method] of Object.entries(
|
|
33217
|
+
for (const [name, method] of Object.entries(methods2)) {
|
|
33170
33218
|
const setter = name.startsWith("set");
|
|
33171
33219
|
Object.defineProperty(prototype, name, {
|
|
33172
33220
|
writable: true,
|
|
@@ -33209,7 +33257,7 @@ async function dataViewIndex(value, budget, context) {
|
|
|
33209
33257
|
// packages/safe-js/src/interp/globals/reflect.ts
|
|
33210
33258
|
var nativeReflectPropertyNames = Object.getOwnPropertyNames(Reflect);
|
|
33211
33259
|
function createReflectGlobal(budget) {
|
|
33212
|
-
const
|
|
33260
|
+
const methods3 = {
|
|
33213
33261
|
ownKeys: { length: 1, call: ([target]) => {
|
|
33214
33262
|
const properties = objectProperties(target);
|
|
33215
33263
|
return allocateProducedSandboxValue([...Object.getOwnPropertyNames(properties), ...ownSandboxSymbolKeys(target)], budget);
|
|
@@ -33308,7 +33356,7 @@ function createReflectGlobal(budget) {
|
|
|
33308
33356
|
};
|
|
33309
33357
|
const reflect = createIntrinsicObject({});
|
|
33310
33358
|
for (const name of nativeReflectPropertyNames) {
|
|
33311
|
-
const method =
|
|
33359
|
+
const method = methods3[name];
|
|
33312
33360
|
if (method === void 0) continue;
|
|
33313
33361
|
const closure = createSandboxClosure({
|
|
33314
33362
|
guest: true,
|
|
@@ -33365,9 +33413,9 @@ function createLocaleConstructor(budget) {
|
|
|
33365
33413
|
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false, configurable: false });
|
|
33366
33414
|
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
33367
33415
|
Object.defineProperty(prototype, Symbol.toStringTag, { value: "Intl.Locale", configurable: true });
|
|
33368
|
-
const
|
|
33416
|
+
const methods3 = ["toString", "maximize", "minimize", "getCalendars", "getCollations", "getHourCycles", "getNumberingSystems", "getTimeZones", "getTextInfo", "getWeekInfo"];
|
|
33369
33417
|
const getters = ["baseName", "language", "script", "region", "variants", "calendar", "collation", "firstDayOfWeek", "hourCycle", "caseFirst", "numeric", "numberingSystem"];
|
|
33370
|
-
for (const name of [...
|
|
33418
|
+
for (const name of [...methods3, ...getters]) {
|
|
33371
33419
|
const getter = getters.includes(name);
|
|
33372
33420
|
const closure = createSandboxClosure({
|
|
33373
33421
|
guest: true,
|
|
@@ -33909,10 +33957,132 @@ function createDisplayNamesConstructor(budget) {
|
|
|
33909
33957
|
return constructor;
|
|
33910
33958
|
}
|
|
33911
33959
|
|
|
33960
|
+
// packages/safe-js/src/interp/globals/intl-datetimeformat.ts
|
|
33961
|
+
var supportedLocalesOf7 = Intl.DateTimeFormat.supportedLocalesOf;
|
|
33962
|
+
function createDateTimeFormatConstructor(budget, now) {
|
|
33963
|
+
const prototype = createIntrinsicObject();
|
|
33964
|
+
const formatTarget = createSandboxClosure({
|
|
33965
|
+
guest: true,
|
|
33966
|
+
sandbox: true,
|
|
33967
|
+
name: "",
|
|
33968
|
+
length: 1,
|
|
33969
|
+
call: async ([input], context) => {
|
|
33970
|
+
dateTimeFormatState(context?.thisValue);
|
|
33971
|
+
let value = 0;
|
|
33972
|
+
const release = retainValues(budget, () => [context?.thisValue, value]);
|
|
33973
|
+
try {
|
|
33974
|
+
value = input === void 0 ? await now.call([], context) : await sandboxNumber(input, budget, context);
|
|
33975
|
+
return allocateProducedSandboxValue(formatDateTimeValue(context?.thisValue, "format", [value]), budget);
|
|
33976
|
+
} finally {
|
|
33977
|
+
release();
|
|
33978
|
+
}
|
|
33979
|
+
}
|
|
33980
|
+
});
|
|
33981
|
+
registerBuiltinIdentities(budget, { "%DateTimeFormatFormat%": formatTarget });
|
|
33982
|
+
registerIntrinsicFunction(budget, formatTarget);
|
|
33983
|
+
const initialize = async ([input, options], context) => {
|
|
33984
|
+
const target = context?.newTarget;
|
|
33985
|
+
const selected = target === void 0 || target === constructor ? prototype : context?.getProperty !== void 0 ? await context.getProperty(target, "prototype") : await readPropertyDescriptor(getSandboxPropertyDescriptor(target, "prototype", budget) ?? { value: void 0 }, target, context);
|
|
33986
|
+
let locales2 = [];
|
|
33987
|
+
const release = retainValues(budget, () => [selected, locales2]);
|
|
33988
|
+
try {
|
|
33989
|
+
locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
33990
|
+
const converted = await readDateTimeFormatOptions(options, budget, context);
|
|
33991
|
+
const value = createSandboxDateTimeFormat(locales2, converted);
|
|
33992
|
+
setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
|
|
33993
|
+
return allocateProducedSandboxValue(value, budget);
|
|
33994
|
+
} finally {
|
|
33995
|
+
release();
|
|
33996
|
+
}
|
|
33997
|
+
};
|
|
33998
|
+
const constructor = createSandboxClosure({
|
|
33999
|
+
guest: true,
|
|
34000
|
+
sandbox: true,
|
|
34001
|
+
name: "DateTimeFormat",
|
|
34002
|
+
length: 0,
|
|
34003
|
+
construct: initialize,
|
|
34004
|
+
call: (args, context) => initialize(args, { ...context, stack: context?.stack ?? [], thisValue: context?.thisValue, newTarget: void 0 })
|
|
34005
|
+
});
|
|
34006
|
+
const properties = materializeFunctionProperties(constructor);
|
|
34007
|
+
Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
|
|
34008
|
+
Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
|
|
34009
|
+
guest: true,
|
|
34010
|
+
sandbox: true,
|
|
34011
|
+
name: "supportedLocalesOf",
|
|
34012
|
+
length: 1,
|
|
34013
|
+
call: async ([input, options], context) => {
|
|
34014
|
+
const locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
34015
|
+
const release = retainValues(budget, () => [locales2]);
|
|
34016
|
+
try {
|
|
34017
|
+
const source = intlOptionsObject(options, budget);
|
|
34018
|
+
const raw = await readIntlProperty(source, "localeMatcher", budget, context);
|
|
34019
|
+
const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
|
|
34020
|
+
return allocateProducedSandboxValue(supportedLocalesOf7(locales2, { localeMatcher: matcher }), budget);
|
|
34021
|
+
} finally {
|
|
34022
|
+
release();
|
|
34023
|
+
}
|
|
34024
|
+
}
|
|
34025
|
+
}), writable: true, configurable: true });
|
|
34026
|
+
Object.defineProperties(prototype, {
|
|
34027
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
34028
|
+
[Symbol.toStringTag]: { value: "Intl.DateTimeFormat", configurable: true },
|
|
34029
|
+
resolvedOptions: { value: createSandboxClosure({
|
|
34030
|
+
guest: true,
|
|
34031
|
+
sandbox: true,
|
|
34032
|
+
name: "resolvedOptions",
|
|
34033
|
+
length: 0,
|
|
34034
|
+
call: (_args, context) => allocateProducedSandboxValue({ ...dateTimeFormatState(context?.thisValue).options }, budget)
|
|
34035
|
+
}), writable: true, configurable: true },
|
|
34036
|
+
format: { get: accessorAdapter(createSandboxClosure({
|
|
34037
|
+
guest: true,
|
|
34038
|
+
sandbox: true,
|
|
34039
|
+
name: "get format",
|
|
34040
|
+
length: 0,
|
|
34041
|
+
call: (_args, context) => {
|
|
34042
|
+
const receiver = context?.thisValue;
|
|
34043
|
+
const state = dateTimeFormatState(receiver);
|
|
34044
|
+
if (state.format === void 0) {
|
|
34045
|
+
state.format = createBoundFunction(
|
|
34046
|
+
{ target: formatTarget, thisValue: receiver, args: [] },
|
|
34047
|
+
"",
|
|
34048
|
+
1,
|
|
34049
|
+
(target, args, stack, thisValue) => invokeBuiltinClosure(target, args, budget, { stack, thisValue }, thisValue)
|
|
34050
|
+
);
|
|
34051
|
+
allocateProducedSandboxValue(state.format, budget);
|
|
34052
|
+
}
|
|
34053
|
+
return state.format;
|
|
34054
|
+
}
|
|
34055
|
+
}), "get"), configurable: true }
|
|
34056
|
+
});
|
|
34057
|
+
for (const method of ["formatToParts", "formatRange", "formatRangeToParts"]) {
|
|
34058
|
+
const range = method !== "formatToParts";
|
|
34059
|
+
Object.defineProperty(prototype, method, { value: createSandboxClosure({
|
|
34060
|
+
guest: true,
|
|
34061
|
+
sandbox: true,
|
|
34062
|
+
name: method,
|
|
34063
|
+
length: range ? 2 : 1,
|
|
34064
|
+
call: async ([first, second], context) => {
|
|
34065
|
+
dateTimeFormatState(context?.thisValue);
|
|
34066
|
+
if (range && (first === void 0 || second === void 0)) throw new TypeError("DateTimeFormat range requires both values.");
|
|
34067
|
+
const values = [];
|
|
34068
|
+
const release = retainValues(budget, () => [context?.thisValue, values]);
|
|
34069
|
+
try {
|
|
34070
|
+
values.push(!range && first === void 0 ? await now.call([], context) : await sandboxNumber(first, budget, context));
|
|
34071
|
+
if (range) values.push(await sandboxNumber(second, budget, context));
|
|
34072
|
+
return allocateProducedSandboxValue(formatDateTimeValue(context?.thisValue, method, values), budget);
|
|
34073
|
+
} finally {
|
|
34074
|
+
release();
|
|
34075
|
+
}
|
|
34076
|
+
}
|
|
34077
|
+
}), writable: true, configurable: true });
|
|
34078
|
+
}
|
|
34079
|
+
return constructor;
|
|
34080
|
+
}
|
|
34081
|
+
|
|
33912
34082
|
// packages/safe-js/src/interp/globals/intl.ts
|
|
33913
34083
|
var supportedValuesOf = Intl.supportedValuesOf;
|
|
33914
|
-
function createIntlGlobal(budget) {
|
|
33915
|
-
const
|
|
34084
|
+
function createIntlGlobal(budget, now) {
|
|
34085
|
+
const methods3 = {
|
|
33916
34086
|
getCanonicalLocales: async ([locales2], context) => allocateProducedSandboxValue(await canonicalizeGuestLocales(locales2, budget, context), budget),
|
|
33917
34087
|
supportedValuesOf: async ([key], context) => {
|
|
33918
34088
|
const text = await sandboxString(key, budget, context);
|
|
@@ -33927,19 +34097,21 @@ function createIntlGlobal(budget) {
|
|
|
33927
34097
|
const listFormat = createListFormatConstructor(budget);
|
|
33928
34098
|
const relativeTimeFormat = createRelativeTimeFormatConstructor(budget);
|
|
33929
34099
|
const displayNames = createDisplayNamesConstructor(budget);
|
|
34100
|
+
const dateTimeFormat = createDateTimeFormatConstructor(budget, now);
|
|
33930
34101
|
Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
|
|
33931
34102
|
Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
|
|
33932
34103
|
Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
|
|
33933
34104
|
Object.defineProperty(intl, "ListFormat", { value: listFormat, writable: true, configurable: true });
|
|
33934
34105
|
Object.defineProperty(intl, "RelativeTimeFormat", { value: relativeTimeFormat, writable: true, configurable: true });
|
|
33935
34106
|
Object.defineProperty(intl, "DisplayNames", { value: displayNames, writable: true, configurable: true });
|
|
33936
|
-
|
|
34107
|
+
Object.defineProperty(intl, "DateTimeFormat", { value: dateTimeFormat, writable: true, configurable: true });
|
|
34108
|
+
for (const [name, call] of Object.entries(methods3)) {
|
|
33937
34109
|
const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
|
|
33938
34110
|
Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
|
|
33939
34111
|
}
|
|
33940
34112
|
Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
|
|
33941
34113
|
registerBuiltinIdentities(budget, { Intl: intl });
|
|
33942
|
-
for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames]) {
|
|
34114
|
+
for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat]) {
|
|
33943
34115
|
const prototype = constructor.properties.prototype;
|
|
33944
34116
|
for (const owner of [prototype, constructor.properties])
|
|
33945
34117
|
for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
|
|
@@ -33947,18 +34119,19 @@ function createIntlGlobal(budget) {
|
|
|
33947
34119
|
if (isSandboxClosure(closure)) registerIntrinsicFunction(budget, closure);
|
|
33948
34120
|
registerIntrinsicObject(budget, prototype);
|
|
33949
34121
|
}
|
|
33950
|
-
for (const name of Object.keys(
|
|
34122
|
+
for (const name of Object.keys(methods3)) registerIntrinsicFunction(budget, intl[name]);
|
|
33951
34123
|
registerIntrinsicObject(budget, intl);
|
|
33952
34124
|
return intl;
|
|
33953
34125
|
}
|
|
33954
34126
|
|
|
33955
34127
|
// packages/safe-js/src/interp/globals.ts
|
|
33956
34128
|
function createBuiltinBindings(options) {
|
|
34129
|
+
const date = createDateGlobal(options);
|
|
33957
34130
|
const bindings = {
|
|
33958
34131
|
...createConsoleJsonGlobals(options),
|
|
33959
34132
|
...createCollectionGlobals(options),
|
|
33960
34133
|
...Object.fromEntries(Object.entries(numericTypedArrayConstructors).map(([name, Native]) => [name, createNumericTypedArrayGlobal(options.budget, options.typedArrayPrototypes !== false, Native)])),
|
|
33961
|
-
Date:
|
|
34134
|
+
Date: date,
|
|
33962
34135
|
Symbol: createSymbolGlobal(options.budget),
|
|
33963
34136
|
BigInt: createBigIntGlobal(options.budget),
|
|
33964
34137
|
...createErrorGlobals({ ...options, errorPrototypes: options.errorPrototypes !== false }),
|
|
@@ -33968,7 +34141,7 @@ function createBuiltinBindings(options) {
|
|
|
33968
34141
|
DisposableStack: createDisposableStackGlobal(options.budget),
|
|
33969
34142
|
AsyncDisposableStack: createAsyncDisposableStackGlobal(options.budget),
|
|
33970
34143
|
Reflect: createReflectGlobal(options.budget),
|
|
33971
|
-
Intl: createIntlGlobal(options.budget),
|
|
34144
|
+
Intl: createIntlGlobal(options.budget, date.properties.now),
|
|
33972
34145
|
ArrayBuffer: createArrayBufferGlobal(options.budget),
|
|
33973
34146
|
DataView: createDataViewGlobal(options.budget),
|
|
33974
34147
|
...createMiscGlobals(options),
|
|
@@ -34056,7 +34229,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
34056
34229
|
createRawJson(node.text);
|
|
34057
34230
|
return true;
|
|
34058
34231
|
}
|
|
34059
|
-
if (!["module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-displaynames", "guest-relativetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
34232
|
+
if (!["module-function", "async-generator-driver", "async-generator-handler", "async-function-driver", "async-function-handler", "thenable-state", "thenable-resolver", "construction-environment", "capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-locale", "guest-listformat", "guest-displaynames", "guest-relativetimeformat", "guest-datetimeformat", "guest-numberformat", "guest-collator", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "async-disposable-stack", "async-cleanup", "async-cleanup-handler", "disposable-stack", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
34060
34233
|
const reference = (value, kinds) => {
|
|
34061
34234
|
const ref = record2(value);
|
|
34062
34235
|
fields(ref, ["kind", "id"]);
|
|
@@ -34325,6 +34498,21 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
34325
34498
|
fields(node, ["kind", "source", "flags", "state"]);
|
|
34326
34499
|
if (typeof node.source !== "string" || typeof node.flags !== "string") throw new TypeError("Invalid guest RegExp payload.");
|
|
34327
34500
|
state(node.state);
|
|
34501
|
+
} else if (node.kind === "guest-datetimeformat") {
|
|
34502
|
+
fields(node, ["kind", "options", "state"], ["format"]);
|
|
34503
|
+
const options = record2(node.options);
|
|
34504
|
+
fields(options, ["locale", "calendar", "numberingSystem", "timeZone"], ["hourCycle", "hour12", "weekday", "era", "year", "month", "day", "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits", "timeZoneName", "dateStyle", "timeStyle"]);
|
|
34505
|
+
if (typeof options.locale !== "string" || Object.values(options).some((value) => !["string", "number", "boolean"].includes(typeof value)))
|
|
34506
|
+
throw new TypeError("Invalid DateTimeFormat option type.");
|
|
34507
|
+
const restored = dateTimeFormatState(createSandboxDateTimeFormat(options.locale, options, true)).options;
|
|
34508
|
+
if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
|
|
34509
|
+
throw new TypeError("Invalid resolved DateTimeFormat options.");
|
|
34510
|
+
if (node.format !== void 0) {
|
|
34511
|
+
const format4 = reference(node.format, ["bound-function"]);
|
|
34512
|
+
if (reference(format4.thisValue) !== node || array(format4.args).length !== 0 || format4.name !== "" || format4.length !== 1 || reference(format4.target, ["intrinsic"]).id !== '["%DateTimeFormatFormat%"]')
|
|
34513
|
+
throw new TypeError("Invalid cached DateTimeFormat function.");
|
|
34514
|
+
}
|
|
34515
|
+
state(node.state);
|
|
34328
34516
|
} else if (node.kind === "guest-numberformat") {
|
|
34329
34517
|
fields(node, ["kind", "options", "state"], ["format"]);
|
|
34330
34518
|
const options = record2(node.options);
|
|
@@ -34335,8 +34523,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
34335
34523
|
if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
|
|
34336
34524
|
throw new TypeError("Invalid resolved NumberFormat options.");
|
|
34337
34525
|
if (node.format !== void 0) {
|
|
34338
|
-
const
|
|
34339
|
-
if (reference(
|
|
34526
|
+
const format4 = reference(node.format, ["bound-function"]);
|
|
34527
|
+
if (reference(format4.thisValue) !== node || array(format4.args).length !== 0 || format4.name !== "" || format4.length !== 1 || reference(format4.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
|
|
34340
34528
|
throw new TypeError("Invalid cached NumberFormat function.");
|
|
34341
34529
|
}
|
|
34342
34530
|
state(node.state);
|
|
@@ -38130,6 +38318,11 @@ function measureSandboxData(values, options = {}) {
|
|
|
38130
38318
|
visit(state.options, depth + 1);
|
|
38131
38319
|
visit(state.format, depth + 1);
|
|
38132
38320
|
}
|
|
38321
|
+
if (isSandboxDateTimeFormat(value)) {
|
|
38322
|
+
const state = dateTimeFormatState(value);
|
|
38323
|
+
visit(state.options, depth + 1);
|
|
38324
|
+
visit(state.format, depth + 1);
|
|
38325
|
+
}
|
|
38133
38326
|
if (isSandboxCollator(value)) {
|
|
38134
38327
|
const state = collatorState(value);
|
|
38135
38328
|
visit(state.options, depth + 1);
|
|
@@ -56110,4 +56303,4 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
56110
56303
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
56111
56304
|
|
|
56112
56305
|
*/
|
|
56113
|
-
//# sourceMappingURL=chunk-
|
|
56306
|
+
//# sourceMappingURL=chunk-7A542ATS.js.map
|