@poe-platform/safe-js 0.1.448 → 0.1.450
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-HPTZH7MW.js → chunk-6BQOHEVM.js} +2 -2
- package/dist/safe-js/chunks/{chunk-D32JKK5K.js → chunk-D5ZEIZYV.js} +406 -31
- package/dist/safe-js/chunks/chunk-D5ZEIZYV.js.map +7 -0
- package/dist/safe-js/chunks/numberformat-portable-TXZMY2EF.js +7313 -0
- package/dist/safe-js/chunks/numberformat-portable-TXZMY2EF.js.map +7 -0
- 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-collator.d.ts +20 -0
- package/dist/safe-js/interp/intl-numberformat.d.ts +13 -0
- package/dist/safe-js/interp/numberformat-backend.d.ts +7 -0
- package/dist/safe-js/interp/numberformat-portable.d.ts +9 -0
- package/dist/safe-js/intl-data/dist/numberformat-engine.d.ts +1 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +12 -0
- package/package.json +5 -2
- package/dist/safe-js/chunks/chunk-D32JKK5K.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-HPTZH7MW.js.map → chunk-6BQOHEVM.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-D5ZEIZYV.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-6BQOHEVM.js.map
|
|
@@ -11184,18 +11184,28 @@ function decodeBase64(text, alphabet, mode, budget, maxLength = Number.MAX_SAFE_
|
|
|
11184
11184
|
}
|
|
11185
11185
|
}
|
|
11186
11186
|
|
|
11187
|
-
// packages/safe-js/src/interp/
|
|
11187
|
+
// packages/safe-js/src/interp/numberformat-backend.ts
|
|
11188
11188
|
var NativeNumberFormat = Intl.NumberFormat;
|
|
11189
|
+
var modernNative = new NativeNumberFormat("en", { maximumFractionDigits: 0, ...{ roundingMode: "floor" } }).format(1.9) === "1" && typeof Object.getOwnPropertyDescriptor(NativeNumberFormat.prototype, "formatRange")?.value === "function";
|
|
11190
|
+
var portable = modernNative ? void 0 : await import("./numberformat-portable-TXZMY2EF.js");
|
|
11191
|
+
function createNumberFormatter(locales2, options) {
|
|
11192
|
+
return portable === void 0 ? new NativeNumberFormat(locales2, options) : portable.createPortableNumberFormatter(locales2, options);
|
|
11193
|
+
}
|
|
11194
|
+
function numberFormatterOptions(formatter) {
|
|
11195
|
+
return portable === void 0 ? { ...formatter.resolvedOptions() } : portable.numberFormatterOptions(formatter);
|
|
11196
|
+
}
|
|
11197
|
+
function numberFormatterResult(formatter, method, values) {
|
|
11198
|
+
return portable === void 0 ? Reflect.apply(Reflect.get(formatter, method), formatter, values) : portable.numberFormatterResult(formatter, method, values);
|
|
11199
|
+
}
|
|
11200
|
+
|
|
11201
|
+
// packages/safe-js/src/interp/number-locale.ts
|
|
11189
11202
|
var roundingIncrements = [1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3, 2e3, 2500, 5e3];
|
|
11190
|
-
async function
|
|
11191
|
-
let locales2 = [];
|
|
11203
|
+
async function readNumberFormatOptions(inputValue, locales2, budget, context) {
|
|
11192
11204
|
const options = /* @__PURE__ */ Object.create(null);
|
|
11193
11205
|
const digits = /* @__PURE__ */ Object.create(null);
|
|
11194
|
-
const release = retainValues(budget, () => [
|
|
11195
|
-
const allocation = {};
|
|
11206
|
+
const release = retainValues(budget, () => [inputValue, locales2, options, digits]);
|
|
11196
11207
|
try {
|
|
11197
|
-
|
|
11198
|
-
const input = intlOptionsObject(args[1], budget);
|
|
11208
|
+
const input = intlOptionsObject(inputValue, budget);
|
|
11199
11209
|
const readString = async (key, type) => {
|
|
11200
11210
|
const raw = await readIntlProperty(input, key, budget, context);
|
|
11201
11211
|
if (raw === void 0) return void 0;
|
|
@@ -11224,13 +11234,13 @@ async function formatNumberLocale(value, args, budget, context) {
|
|
|
11224
11234
|
const unit = await readString("unit");
|
|
11225
11235
|
if (unit === void 0) {
|
|
11226
11236
|
if (style === "unit") throw new TypeError("Unit formatting requires a unit.");
|
|
11227
|
-
} else
|
|
11237
|
+
} else createNumberFormatter("en", { style: "unit", unit });
|
|
11228
11238
|
await readString("unitDisplay", ["short", "narrow", "long"]);
|
|
11229
11239
|
const notation = await readString("notation", ["standard", "scientific", "engineering", "compact"]) ?? "standard";
|
|
11230
11240
|
let minimumDefault = 0;
|
|
11231
11241
|
let maximumDefault = style === "percent" ? 0 : 3;
|
|
11232
11242
|
if (style === "currency" && notation === "standard") {
|
|
11233
|
-
const currencyDefaults =
|
|
11243
|
+
const currencyDefaults = numberFormatterOptions(createNumberFormatter("en", { style: "currency", currency }));
|
|
11234
11244
|
minimumDefault = currencyDefaults.minimumFractionDigits;
|
|
11235
11245
|
maximumDefault = currencyDefaults.maximumFractionDigits;
|
|
11236
11246
|
}
|
|
@@ -11265,16 +11275,29 @@ async function formatNumberLocale(value, args, budget, context) {
|
|
|
11265
11275
|
options.minimumFractionDigits = minimum;
|
|
11266
11276
|
options.maximumFractionDigits = maximum;
|
|
11267
11277
|
}
|
|
11268
|
-
|
|
11278
|
+
createNumberFormatter(locales2, options);
|
|
11269
11279
|
await readString("compactDisplay", ["short", "long"]);
|
|
11270
11280
|
const grouping = await readIntlProperty(input, "useGrouping", budget, context);
|
|
11271
11281
|
if (grouping !== void 0) options.useGrouping = grouping === true ? true : !grouping ? false : await convertIntlOption(grouping, "useGrouping", ["min2", "auto", "always", "true", "false"], budget, context);
|
|
11272
11282
|
await readString("signDisplay", ["auto", "never", "always", "exceptZero", "negative"]);
|
|
11283
|
+
return options;
|
|
11284
|
+
} finally {
|
|
11285
|
+
release();
|
|
11286
|
+
}
|
|
11287
|
+
}
|
|
11288
|
+
async function formatNumberLocale(value, args, budget, context) {
|
|
11289
|
+
let locales2 = [];
|
|
11290
|
+
let options = /* @__PURE__ */ Object.create(null);
|
|
11291
|
+
const release = retainValues(budget, () => [value, locales2, options]);
|
|
11292
|
+
const allocation = {};
|
|
11293
|
+
try {
|
|
11294
|
+
locales2 = await canonicalizeGuestLocales(args[0], budget, context);
|
|
11295
|
+
options = await readNumberFormatOptions(args[1], locales2, budget, context);
|
|
11273
11296
|
const size = typeof value === "bigint" ? value.toString(16).length * 4 : 64;
|
|
11274
11297
|
budget.visitNode(size);
|
|
11275
11298
|
budget.setRetainedDataUsage(allocation, size);
|
|
11276
|
-
const formatter =
|
|
11277
|
-
return budget.allocateString(formatter
|
|
11299
|
+
const formatter = createNumberFormatter(locales2, options);
|
|
11300
|
+
return budget.allocateString(numberFormatterResult(formatter, "format", [value]));
|
|
11278
11301
|
} finally {
|
|
11279
11302
|
budget.setRetainedDataUsage(allocation, 0);
|
|
11280
11303
|
release();
|
|
@@ -12376,8 +12399,12 @@ function formatNumber(value, methodName, argument, budget) {
|
|
|
12376
12399
|
// packages/safe-js/src/interp/methods/string.ts
|
|
12377
12400
|
import { types as types7 } from "node:util";
|
|
12378
12401
|
|
|
12379
|
-
// packages/safe-js/src/interp/
|
|
12380
|
-
var
|
|
12402
|
+
// packages/safe-js/src/interp/intl-collator.ts
|
|
12403
|
+
var NativeCollator = Intl.Collator;
|
|
12404
|
+
var nativeResolvedOptions = NativeCollator.prototype.resolvedOptions;
|
|
12405
|
+
var nativeCompare = Object.getOwnPropertyDescriptor(NativeCollator.prototype, "compare").get;
|
|
12406
|
+
var states5 = /* @__PURE__ */ new WeakMap();
|
|
12407
|
+
var optionTypes = [
|
|
12381
12408
|
["usage", ["sort", "search"]],
|
|
12382
12409
|
["localeMatcher", ["lookup", "best fit"]],
|
|
12383
12410
|
["collation", "unicodeType"],
|
|
@@ -12386,6 +12413,50 @@ var collatorOptions = [
|
|
|
12386
12413
|
["sensitivity", ["base", "accent", "case", "variant"]],
|
|
12387
12414
|
["ignorePunctuation", "boolean"]
|
|
12388
12415
|
];
|
|
12416
|
+
async function readCollatorOptions(input, budget, context, invalid) {
|
|
12417
|
+
const source = intlOptionsObject(input, budget);
|
|
12418
|
+
const options = /* @__PURE__ */ Object.create(null);
|
|
12419
|
+
const release = retainValues(budget, () => [source, options]);
|
|
12420
|
+
try {
|
|
12421
|
+
for (const [key, type] of optionTypes) {
|
|
12422
|
+
const value = await readIntlProperty(source, key, budget, context);
|
|
12423
|
+
if (value !== void 0) options[key] = await convertIntlOption(
|
|
12424
|
+
value,
|
|
12425
|
+
key,
|
|
12426
|
+
type,
|
|
12427
|
+
budget,
|
|
12428
|
+
context,
|
|
12429
|
+
(text) => {
|
|
12430
|
+
invalid?.(key, text);
|
|
12431
|
+
new NativeCollator([], { [key]: text });
|
|
12432
|
+
}
|
|
12433
|
+
);
|
|
12434
|
+
}
|
|
12435
|
+
return options;
|
|
12436
|
+
} finally {
|
|
12437
|
+
release();
|
|
12438
|
+
}
|
|
12439
|
+
}
|
|
12440
|
+
function createSandboxCollator(locales2, options) {
|
|
12441
|
+
const native = new NativeCollator(locales2, options);
|
|
12442
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
12443
|
+
states5.set(value, { native, options: Reflect.apply(nativeResolvedOptions, native, []) });
|
|
12444
|
+
return value;
|
|
12445
|
+
}
|
|
12446
|
+
function isSandboxCollator(value) {
|
|
12447
|
+
return typeof value === "object" && value !== null && states5.has(value);
|
|
12448
|
+
}
|
|
12449
|
+
function collatorState(value) {
|
|
12450
|
+
if (!isSandboxCollator(value)) throw new TypeError("Intl.Collator requires a Collator receiver.");
|
|
12451
|
+
return states5.get(value);
|
|
12452
|
+
}
|
|
12453
|
+
function compareCollatorStrings(value, first, second) {
|
|
12454
|
+
const state = collatorState(value);
|
|
12455
|
+
const compare = Reflect.apply(nativeCompare, state.native, []);
|
|
12456
|
+
return Reflect.apply(compare, void 0, [first, second]);
|
|
12457
|
+
}
|
|
12458
|
+
|
|
12459
|
+
// packages/safe-js/src/interp/methods/string-locale.ts
|
|
12389
12460
|
async function changeStringLocaleCase(value, method, args, budget, context) {
|
|
12390
12461
|
let locales2 = [];
|
|
12391
12462
|
const release = retainValues(budget, () => [value, locales2]);
|
|
@@ -12400,19 +12471,15 @@ async function changeStringLocaleCase(value, method, args, budget, context) {
|
|
|
12400
12471
|
async function compareStringLocale(value, args, budget, context) {
|
|
12401
12472
|
let comparison = "";
|
|
12402
12473
|
let locales2 = [];
|
|
12403
|
-
|
|
12474
|
+
let options = /* @__PURE__ */ Object.create(null);
|
|
12404
12475
|
const release = retainValues(budget, () => [value, comparison, locales2, options]);
|
|
12405
12476
|
try {
|
|
12406
12477
|
comparison = await sandboxString(args[0], budget, context);
|
|
12407
12478
|
locales2 = await canonicalizeGuestLocales(args[1], budget, context);
|
|
12408
12479
|
if (args[2] === null) return Reflect.apply(String.prototype.localeCompare, value, [comparison, locales2, null]);
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
if (option !== void 0) options[key] = await convertIntlOption(option, key, type, budget, context, (text) => {
|
|
12413
|
-
Reflect.apply(String.prototype.localeCompare, "", ["", [], { [key]: text }]);
|
|
12414
|
-
});
|
|
12415
|
-
}
|
|
12480
|
+
options = await readCollatorOptions(args[2], budget, context, (key, text) => {
|
|
12481
|
+
Reflect.apply(String.prototype.localeCompare, "", ["", [], { [key]: text }]);
|
|
12482
|
+
});
|
|
12416
12483
|
budget.visitNode(value.length + comparison.length);
|
|
12417
12484
|
return Reflect.apply(String.prototype.localeCompare, value, [comparison, locales2, options]);
|
|
12418
12485
|
} finally {
|
|
@@ -21172,7 +21239,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
|
|
|
21172
21239
|
}
|
|
21173
21240
|
const updated = Object.values(base).filter((value) => value !== void 0).join("-") + canonical.slice(native.baseName.length);
|
|
21174
21241
|
const extension = unicodeKeywords(updated);
|
|
21175
|
-
const
|
|
21242
|
+
const optionTypes2 = [
|
|
21176
21243
|
["calendar", "ca", "unicodeType"],
|
|
21177
21244
|
["collation", "co", "unicodeType"],
|
|
21178
21245
|
["firstDayOfWeek", "fw", "unicodeType"],
|
|
@@ -21181,7 +21248,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
|
|
|
21181
21248
|
["numeric", "kn", "boolean"],
|
|
21182
21249
|
["numberingSystem", "nu", "unicodeType"]
|
|
21183
21250
|
];
|
|
21184
|
-
for (const [key, extensionKey, type] of
|
|
21251
|
+
for (const [key, extensionKey, type] of optionTypes2) {
|
|
21185
21252
|
let value = await readIntlProperty(options, key, budget, context);
|
|
21186
21253
|
if (value === void 0) continue;
|
|
21187
21254
|
if (key === "firstDayOfWeek") {
|
|
@@ -21201,6 +21268,34 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
|
|
|
21201
21268
|
return budget.allocateString(Reflect.apply(nativeToString, result, []));
|
|
21202
21269
|
}
|
|
21203
21270
|
|
|
21271
|
+
// packages/safe-js/src/interp/intl-numberformat.ts
|
|
21272
|
+
var states6 = /* @__PURE__ */ new WeakMap();
|
|
21273
|
+
function createSandboxNumberFormat(locales2, options) {
|
|
21274
|
+
const native = createNumberFormatter(locales2, options);
|
|
21275
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
21276
|
+
states6.set(value, { native, options: numberFormatterOptions(native) });
|
|
21277
|
+
return value;
|
|
21278
|
+
}
|
|
21279
|
+
function isSandboxNumberFormat(value) {
|
|
21280
|
+
return typeof value === "object" && value !== null && states6.has(value);
|
|
21281
|
+
}
|
|
21282
|
+
function numberFormatState(value) {
|
|
21283
|
+
if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
|
|
21284
|
+
return states6.get(value);
|
|
21285
|
+
}
|
|
21286
|
+
async function numberFormatValue(value, budget, context) {
|
|
21287
|
+
const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
|
|
21288
|
+
if (typeof primitive === "string" || typeof primitive === "bigint") {
|
|
21289
|
+
budget.visitNode(typeof primitive === "string" ? primitive.length : primitive.toString(16).length * 4);
|
|
21290
|
+
return primitive;
|
|
21291
|
+
}
|
|
21292
|
+
return Number(primitive);
|
|
21293
|
+
}
|
|
21294
|
+
function formatNumberValue(receiver, method, values) {
|
|
21295
|
+
const { native } = numberFormatState(receiver);
|
|
21296
|
+
return numberFormatterResult(native, method, values);
|
|
21297
|
+
}
|
|
21298
|
+
|
|
21204
21299
|
// packages/safe-js/src/interp/iterator-helper.ts
|
|
21205
21300
|
var iteratorHelperStates = /* @__PURE__ */ new WeakMap();
|
|
21206
21301
|
|
|
@@ -21540,6 +21635,14 @@ function captureGuestHeapNode(value, encode) {
|
|
|
21540
21635
|
return void 0;
|
|
21541
21636
|
}
|
|
21542
21637
|
if (isSandboxLocale(value)) return { kind: "guest-locale", tag: localeTag(value), state: captureObjectState(value, encode) };
|
|
21638
|
+
if (isSandboxNumberFormat(value)) {
|
|
21639
|
+
const { options, format } = numberFormatState(value);
|
|
21640
|
+
return { kind: "guest-numberformat", options: { ...options }, ...format === void 0 ? {} : { format: encode(format) }, state: captureObjectState(value, encode) };
|
|
21641
|
+
}
|
|
21642
|
+
if (isSandboxCollator(value)) {
|
|
21643
|
+
const { options, compare } = collatorState(value);
|
|
21644
|
+
return { kind: "guest-collator", options: { ...options }, ...compare === void 0 ? {} : { compare: encode(compare) }, state: captureObjectState(value, encode) };
|
|
21645
|
+
}
|
|
21543
21646
|
if (hasGuestObjectState(value) || privateElements.has(value)) {
|
|
21544
21647
|
if (isSandboxRegex(value)) return { kind: "guest-regex", source: value.source, flags: value.flags, state: captureObjectState(value, encode) };
|
|
21545
21648
|
if (isSandboxBox(value)) return { kind: "guest-boxed", value: encode(boxedValue(value)), state: captureObjectState(value, encode) };
|
|
@@ -25742,6 +25845,229 @@ function createLocaleConstructor(budget) {
|
|
|
25742
25845
|
return constructor;
|
|
25743
25846
|
}
|
|
25744
25847
|
|
|
25848
|
+
// packages/safe-js/src/interp/globals/intl-collator.ts
|
|
25849
|
+
var supportedLocalesOf = Intl.Collator.supportedLocalesOf;
|
|
25850
|
+
function createCollatorConstructor(budget) {
|
|
25851
|
+
const prototype = createIntrinsicObject();
|
|
25852
|
+
const compareTarget = createSandboxClosure({
|
|
25853
|
+
guest: true,
|
|
25854
|
+
sandbox: true,
|
|
25855
|
+
name: "",
|
|
25856
|
+
length: 2,
|
|
25857
|
+
call: async ([first, second], context) => {
|
|
25858
|
+
let left = "";
|
|
25859
|
+
const release = retainValues(budget, () => [context?.thisValue, left]);
|
|
25860
|
+
try {
|
|
25861
|
+
left = await sandboxString(first, budget, context);
|
|
25862
|
+
const right = await sandboxString(second, budget, context);
|
|
25863
|
+
budget.visitNode(left.length + right.length);
|
|
25864
|
+
return compareCollatorStrings(context?.thisValue, left, right);
|
|
25865
|
+
} finally {
|
|
25866
|
+
release();
|
|
25867
|
+
}
|
|
25868
|
+
}
|
|
25869
|
+
});
|
|
25870
|
+
registerBuiltinIdentities(budget, { "%CollatorCompare%": compareTarget });
|
|
25871
|
+
registerIntrinsicFunction(budget, compareTarget);
|
|
25872
|
+
const initialize = async ([input, options], context) => {
|
|
25873
|
+
const target = context?.newTarget;
|
|
25874
|
+
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);
|
|
25875
|
+
let locales2 = [];
|
|
25876
|
+
const release = retainValues(budget, () => [selected, locales2]);
|
|
25877
|
+
try {
|
|
25878
|
+
locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
25879
|
+
const converted = await readCollatorOptions(options, budget, context);
|
|
25880
|
+
const value = createSandboxCollator(locales2, converted);
|
|
25881
|
+
setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
|
|
25882
|
+
return allocateProducedSandboxValue(value, budget);
|
|
25883
|
+
} finally {
|
|
25884
|
+
release();
|
|
25885
|
+
}
|
|
25886
|
+
};
|
|
25887
|
+
const constructor = createSandboxClosure({
|
|
25888
|
+
guest: true,
|
|
25889
|
+
sandbox: true,
|
|
25890
|
+
name: "Collator",
|
|
25891
|
+
length: 0,
|
|
25892
|
+
construct: initialize,
|
|
25893
|
+
call: (args, context) => initialize(args, { ...context, stack: context?.stack ?? [], thisValue: context?.thisValue, newTarget: void 0 })
|
|
25894
|
+
});
|
|
25895
|
+
const properties = materializeFunctionProperties(constructor);
|
|
25896
|
+
Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
|
|
25897
|
+
Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
|
|
25898
|
+
guest: true,
|
|
25899
|
+
sandbox: true,
|
|
25900
|
+
name: "supportedLocalesOf",
|
|
25901
|
+
length: 1,
|
|
25902
|
+
call: async ([input, options], context) => {
|
|
25903
|
+
const locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
25904
|
+
const release = retainValues(budget, () => [locales2]);
|
|
25905
|
+
try {
|
|
25906
|
+
const source = intlOptionsObject(options, budget);
|
|
25907
|
+
const option = await readIntlProperty(source, "localeMatcher", budget, context);
|
|
25908
|
+
const matcher = option === void 0 ? void 0 : await convertIntlOption(option, "localeMatcher", ["lookup", "best fit"], budget, context);
|
|
25909
|
+
return allocateProducedSandboxValue(supportedLocalesOf(locales2, { localeMatcher: matcher }), budget);
|
|
25910
|
+
} finally {
|
|
25911
|
+
release();
|
|
25912
|
+
}
|
|
25913
|
+
}
|
|
25914
|
+
}), writable: true, configurable: true });
|
|
25915
|
+
Object.defineProperties(prototype, {
|
|
25916
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
25917
|
+
[Symbol.toStringTag]: { value: "Intl.Collator", configurable: true },
|
|
25918
|
+
resolvedOptions: { value: createSandboxClosure({
|
|
25919
|
+
guest: true,
|
|
25920
|
+
sandbox: true,
|
|
25921
|
+
name: "resolvedOptions",
|
|
25922
|
+
length: 0,
|
|
25923
|
+
call: (_args, context) => allocateProducedSandboxValue({ ...collatorState(context?.thisValue).options }, budget)
|
|
25924
|
+
}), writable: true, configurable: true },
|
|
25925
|
+
compare: { get: accessorAdapter(createSandboxClosure({
|
|
25926
|
+
guest: true,
|
|
25927
|
+
sandbox: true,
|
|
25928
|
+
name: "get compare",
|
|
25929
|
+
length: 0,
|
|
25930
|
+
call: (_args, context) => {
|
|
25931
|
+
const receiver = context?.thisValue;
|
|
25932
|
+
const state = collatorState(receiver);
|
|
25933
|
+
if (state.compare === void 0) {
|
|
25934
|
+
state.compare = createBoundFunction(
|
|
25935
|
+
{ target: compareTarget, thisValue: receiver, args: [] },
|
|
25936
|
+
"",
|
|
25937
|
+
2,
|
|
25938
|
+
(target, args, stack, thisValue) => invokeBuiltinClosure(target, args, budget, { stack, thisValue }, thisValue)
|
|
25939
|
+
);
|
|
25940
|
+
allocateProducedSandboxValue(state.compare, budget);
|
|
25941
|
+
}
|
|
25942
|
+
return state.compare;
|
|
25943
|
+
}
|
|
25944
|
+
}), "get"), configurable: true }
|
|
25945
|
+
});
|
|
25946
|
+
return constructor;
|
|
25947
|
+
}
|
|
25948
|
+
|
|
25949
|
+
// packages/safe-js/src/interp/globals/intl-numberformat.ts
|
|
25950
|
+
var supportedLocalesOf2 = Intl.NumberFormat.supportedLocalesOf;
|
|
25951
|
+
function createNumberFormatConstructor(budget) {
|
|
25952
|
+
const prototype = createIntrinsicObject();
|
|
25953
|
+
const formatTarget = createSandboxClosure({
|
|
25954
|
+
guest: true,
|
|
25955
|
+
sandbox: true,
|
|
25956
|
+
name: "",
|
|
25957
|
+
length: 1,
|
|
25958
|
+
call: async ([input], context) => {
|
|
25959
|
+
numberFormatState(context?.thisValue);
|
|
25960
|
+
let value = 0;
|
|
25961
|
+
const release = retainValues(budget, () => [context?.thisValue, value]);
|
|
25962
|
+
try {
|
|
25963
|
+
value = await numberFormatValue(input, budget, context);
|
|
25964
|
+
return allocateProducedSandboxValue(formatNumberValue(context?.thisValue, "format", [value]), budget);
|
|
25965
|
+
} finally {
|
|
25966
|
+
release();
|
|
25967
|
+
}
|
|
25968
|
+
}
|
|
25969
|
+
});
|
|
25970
|
+
registerBuiltinIdentities(budget, { "%NumberFormatFormat%": formatTarget });
|
|
25971
|
+
registerIntrinsicFunction(budget, formatTarget);
|
|
25972
|
+
const initialize = async ([input, options], context) => {
|
|
25973
|
+
const target = context?.newTarget;
|
|
25974
|
+
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);
|
|
25975
|
+
let locales2 = [];
|
|
25976
|
+
const release = retainValues(budget, () => [selected, locales2]);
|
|
25977
|
+
try {
|
|
25978
|
+
locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
25979
|
+
const converted = await readNumberFormatOptions(options, locales2, budget, context);
|
|
25980
|
+
const value = createSandboxNumberFormat(locales2, converted);
|
|
25981
|
+
setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
|
|
25982
|
+
return allocateProducedSandboxValue(value, budget);
|
|
25983
|
+
} finally {
|
|
25984
|
+
release();
|
|
25985
|
+
}
|
|
25986
|
+
};
|
|
25987
|
+
const constructor = createSandboxClosure({
|
|
25988
|
+
guest: true,
|
|
25989
|
+
sandbox: true,
|
|
25990
|
+
name: "NumberFormat",
|
|
25991
|
+
length: 0,
|
|
25992
|
+
construct: initialize,
|
|
25993
|
+
call: (args, context) => initialize(args, { ...context, stack: context?.stack ?? [], thisValue: context?.thisValue, newTarget: void 0 })
|
|
25994
|
+
});
|
|
25995
|
+
const properties = materializeFunctionProperties(constructor);
|
|
25996
|
+
Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
|
|
25997
|
+
Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
|
|
25998
|
+
guest: true,
|
|
25999
|
+
sandbox: true,
|
|
26000
|
+
name: "supportedLocalesOf",
|
|
26001
|
+
length: 1,
|
|
26002
|
+
call: async ([input, options], context) => {
|
|
26003
|
+
const locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
26004
|
+
const release = retainValues(budget, () => [locales2]);
|
|
26005
|
+
try {
|
|
26006
|
+
const source = intlOptionsObject(options, budget);
|
|
26007
|
+
const raw = await readIntlProperty(source, "localeMatcher", budget, context);
|
|
26008
|
+
const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
|
|
26009
|
+
return allocateProducedSandboxValue(supportedLocalesOf2(locales2, { localeMatcher: matcher }), budget);
|
|
26010
|
+
} finally {
|
|
26011
|
+
release();
|
|
26012
|
+
}
|
|
26013
|
+
}
|
|
26014
|
+
}), writable: true, configurable: true });
|
|
26015
|
+
Object.defineProperties(prototype, {
|
|
26016
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
26017
|
+
[Symbol.toStringTag]: { value: "Intl.NumberFormat", configurable: true },
|
|
26018
|
+
resolvedOptions: { value: createSandboxClosure({
|
|
26019
|
+
guest: true,
|
|
26020
|
+
sandbox: true,
|
|
26021
|
+
name: "resolvedOptions",
|
|
26022
|
+
length: 0,
|
|
26023
|
+
call: (_args, context) => allocateProducedSandboxValue({ ...numberFormatState(context?.thisValue).options }, budget)
|
|
26024
|
+
}), writable: true, configurable: true },
|
|
26025
|
+
format: { get: accessorAdapter(createSandboxClosure({
|
|
26026
|
+
guest: true,
|
|
26027
|
+
sandbox: true,
|
|
26028
|
+
name: "get format",
|
|
26029
|
+
length: 0,
|
|
26030
|
+
call: (_args, context) => {
|
|
26031
|
+
const receiver = context?.thisValue;
|
|
26032
|
+
const state = numberFormatState(receiver);
|
|
26033
|
+
if (state.format === void 0) {
|
|
26034
|
+
state.format = createBoundFunction(
|
|
26035
|
+
{ target: formatTarget, thisValue: receiver, args: [] },
|
|
26036
|
+
"",
|
|
26037
|
+
1,
|
|
26038
|
+
(target, args, stack, thisValue) => invokeBuiltinClosure(target, args, budget, { stack, thisValue }, thisValue)
|
|
26039
|
+
);
|
|
26040
|
+
allocateProducedSandboxValue(state.format, budget);
|
|
26041
|
+
}
|
|
26042
|
+
return state.format;
|
|
26043
|
+
}
|
|
26044
|
+
}), "get"), configurable: true }
|
|
26045
|
+
});
|
|
26046
|
+
for (const method of ["formatToParts", "formatRange", "formatRangeToParts"]) {
|
|
26047
|
+
const range = method !== "formatToParts";
|
|
26048
|
+
Object.defineProperty(prototype, method, { value: createSandboxClosure({
|
|
26049
|
+
guest: true,
|
|
26050
|
+
sandbox: true,
|
|
26051
|
+
name: method,
|
|
26052
|
+
length: range ? 2 : 1,
|
|
26053
|
+
call: async ([first, second], context) => {
|
|
26054
|
+
numberFormatState(context?.thisValue);
|
|
26055
|
+
if (range && (first === void 0 || second === void 0)) throw new TypeError("NumberFormat range requires both values.");
|
|
26056
|
+
const values = [];
|
|
26057
|
+
const release = retainValues(budget, () => [context?.thisValue, values]);
|
|
26058
|
+
try {
|
|
26059
|
+
values.push(await numberFormatValue(first, budget, context));
|
|
26060
|
+
if (range) values.push(await numberFormatValue(second, budget, context));
|
|
26061
|
+
return allocateProducedSandboxValue(formatNumberValue(context?.thisValue, method, values), budget);
|
|
26062
|
+
} finally {
|
|
26063
|
+
release();
|
|
26064
|
+
}
|
|
26065
|
+
}
|
|
26066
|
+
}), writable: true, configurable: true });
|
|
26067
|
+
}
|
|
26068
|
+
return constructor;
|
|
26069
|
+
}
|
|
26070
|
+
|
|
25745
26071
|
// packages/safe-js/src/interp/globals/intl.ts
|
|
25746
26072
|
var supportedValuesOf = Intl.supportedValuesOf;
|
|
25747
26073
|
function createIntlGlobal(budget) {
|
|
@@ -25755,18 +26081,25 @@ function createIntlGlobal(budget) {
|
|
|
25755
26081
|
};
|
|
25756
26082
|
const intl = createIntrinsicObject();
|
|
25757
26083
|
const locale = createLocaleConstructor(budget);
|
|
26084
|
+
const collator = createCollatorConstructor(budget);
|
|
26085
|
+
const numberFormat = createNumberFormatConstructor(budget);
|
|
25758
26086
|
Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
|
|
26087
|
+
Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
|
|
26088
|
+
Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
|
|
25759
26089
|
for (const [name, call] of Object.entries(methods2)) {
|
|
25760
26090
|
const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
|
|
25761
26091
|
Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
|
|
25762
26092
|
}
|
|
25763
26093
|
Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
|
|
25764
26094
|
registerBuiltinIdentities(budget, { Intl: intl });
|
|
25765
|
-
const
|
|
25766
|
-
|
|
25767
|
-
for (const
|
|
25768
|
-
|
|
25769
|
-
|
|
26095
|
+
for (const constructor of [locale, collator, numberFormat]) {
|
|
26096
|
+
const prototype = constructor.properties.prototype;
|
|
26097
|
+
for (const owner of [prototype, constructor.properties])
|
|
26098
|
+
for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
|
|
26099
|
+
for (const closure of [descriptor.value, ...retainedAccessorClosures(descriptor)])
|
|
26100
|
+
if (isSandboxClosure(closure)) registerIntrinsicFunction(budget, closure);
|
|
26101
|
+
registerIntrinsicObject(budget, prototype);
|
|
26102
|
+
}
|
|
25770
26103
|
for (const name of Object.keys(methods2)) registerIntrinsicFunction(budget, intl[name]);
|
|
25771
26104
|
registerIntrinsicObject(budget, intl);
|
|
25772
26105
|
return intl;
|
|
@@ -25876,7 +26209,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
25876
26209
|
createRawJson(node.text);
|
|
25877
26210
|
return true;
|
|
25878
26211
|
}
|
|
25879
|
-
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-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;
|
|
26212
|
+
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-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;
|
|
25880
26213
|
const reference = (value, kinds) => {
|
|
25881
26214
|
const ref = record2(value);
|
|
25882
26215
|
fields(ref, ["kind", "id"]);
|
|
@@ -26145,6 +26478,38 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
26145
26478
|
fields(node, ["kind", "source", "flags", "state"]);
|
|
26146
26479
|
if (typeof node.source !== "string" || typeof node.flags !== "string") throw new TypeError("Invalid guest RegExp payload.");
|
|
26147
26480
|
state(node.state);
|
|
26481
|
+
} else if (node.kind === "guest-numberformat") {
|
|
26482
|
+
fields(node, ["kind", "options", "state"], ["format"]);
|
|
26483
|
+
const options = record2(node.options);
|
|
26484
|
+
fields(options, ["locale"], ["numberingSystem", "style", "currency", "currencyDisplay", "currencySign", "unit", "unitDisplay", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits", "useGrouping", "notation", "compactDisplay", "signDisplay", "roundingIncrement", "roundingMode", "roundingPriority", "trailingZeroDisplay"]);
|
|
26485
|
+
if (typeof options.locale !== "string" || Object.values(options).some((value) => !["string", "number", "boolean"].includes(typeof value)))
|
|
26486
|
+
throw new TypeError("Invalid NumberFormat option type.");
|
|
26487
|
+
const restored = numberFormatState(createSandboxNumberFormat(options.locale, options)).options;
|
|
26488
|
+
if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => options[key] !== restored[key]))
|
|
26489
|
+
throw new TypeError("Invalid resolved NumberFormat options.");
|
|
26490
|
+
if (node.format !== void 0) {
|
|
26491
|
+
const format = reference(node.format, ["bound-function"]);
|
|
26492
|
+
if (reference(format.thisValue) !== node || array(format.args).length !== 0 || format.name !== "" || format.length !== 1 || reference(format.target, ["intrinsic"]).id !== '["%NumberFormatFormat%"]')
|
|
26493
|
+
throw new TypeError("Invalid cached NumberFormat function.");
|
|
26494
|
+
}
|
|
26495
|
+
state(node.state);
|
|
26496
|
+
} else if (node.kind === "guest-collator") {
|
|
26497
|
+
fields(node, ["kind", "options", "state"], ["compare"]);
|
|
26498
|
+
const options = record2(node.options);
|
|
26499
|
+
const names = ["locale", "usage", "sensitivity", "ignorePunctuation", "collation", "numeric", "caseFirst"];
|
|
26500
|
+
fields(options, names);
|
|
26501
|
+
for (const key of names)
|
|
26502
|
+
if (typeof options[key] !== (key === "numeric" || key === "ignorePunctuation" ? "boolean" : "string"))
|
|
26503
|
+
throw new TypeError("Invalid Collator option type.");
|
|
26504
|
+
const restored = collatorState(createSandboxCollator(options.locale, options)).options;
|
|
26505
|
+
for (const key of names)
|
|
26506
|
+
if (options[key] !== restored[key]) throw new TypeError("Invalid resolved Collator options.");
|
|
26507
|
+
if (node.compare !== void 0) {
|
|
26508
|
+
const compare = reference(node.compare, ["bound-function"]);
|
|
26509
|
+
if (reference(compare.thisValue) !== node || array(compare.args).length !== 0 || compare.name !== "" || compare.length !== 2 || reference(compare.target, ["intrinsic"]).id !== '["%CollatorCompare%"]')
|
|
26510
|
+
throw new TypeError("Invalid cached Collator comparison.");
|
|
26511
|
+
}
|
|
26512
|
+
state(node.state);
|
|
26148
26513
|
} else if (node.kind === "guest-locale") {
|
|
26149
26514
|
fields(node, ["kind", "tag", "state"]);
|
|
26150
26515
|
if (typeof node.tag !== "string" || localeTag(createSandboxLocale(node.tag)) !== node.tag)
|
|
@@ -29883,6 +30248,16 @@ function measureSandboxData(values, options = {}) {
|
|
|
29883
30248
|
}
|
|
29884
30249
|
if (isSandboxDate(value)) usage += 8;
|
|
29885
30250
|
if (isSandboxLocale(value)) usage += localeTag(value).length;
|
|
30251
|
+
if (isSandboxNumberFormat(value)) {
|
|
30252
|
+
const state = numberFormatState(value);
|
|
30253
|
+
visit(state.options, depth + 1);
|
|
30254
|
+
visit(state.format, depth + 1);
|
|
30255
|
+
}
|
|
30256
|
+
if (isSandboxCollator(value)) {
|
|
30257
|
+
const state = collatorState(value);
|
|
30258
|
+
visit(state.options, depth + 1);
|
|
30259
|
+
visit(state.compare, depth + 1);
|
|
30260
|
+
}
|
|
29886
30261
|
if (isGuestHostObject(value)) {
|
|
29887
30262
|
usage += measureHostObjectData(value);
|
|
29888
30263
|
return;
|
|
@@ -47846,4 +48221,4 @@ export {
|
|
|
47846
48221
|
FileSnapshotBackend,
|
|
47847
48222
|
run
|
|
47848
48223
|
};
|
|
47849
|
-
//# sourceMappingURL=chunk-
|
|
48224
|
+
//# sourceMappingURL=chunk-D5ZEIZYV.js.map
|