@poe-platform/safe-js 0.1.461 → 0.1.463
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-N63L3JON.js → chunk-KCQ7OJWN.js} +2 -2
- package/dist/safe-js/chunks/{chunk-RMMSTECW.js → chunk-NYT6Z4RI.js} +214 -42
- package/dist/safe-js/chunks/{chunk-RMMSTECW.js.map → chunk-NYT6Z4RI.js.map} +4 -4
- 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-pluralrules.d.ts +9 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +5 -0
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-N63L3JON.js.map → chunk-KCQ7OJWN.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-NYT6Z4RI.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-KCQ7OJWN.js.map
|
|
@@ -11854,7 +11854,7 @@ function ResolvePlural(pl, n, { getInternalSlots: getInternalSlots3, PluralRuleS
|
|
|
11854
11854
|
}).pluralCategory;
|
|
11855
11855
|
}
|
|
11856
11856
|
function ResolvePluralRange(pluralRules, x, y, { getInternalSlots: getInternalSlots3, PluralRuleSelect: PluralRuleSelect2, PluralRuleSelectRange: PluralRuleSelectRange2 }) {
|
|
11857
|
-
if (
|
|
11857
|
+
if (x.isNaN() || y.isNaN()) throw new RangeError("selectRange endpoints must not be NaN");
|
|
11858
11858
|
const internalSlots = getInternalSlots3(pluralRules);
|
|
11859
11859
|
invariant$1(Type(internalSlots) === "Object", "pluralRules has to be an object");
|
|
11860
11860
|
invariant$1("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
@@ -18508,14 +18508,16 @@ function numberFormatterResult2(formatter, method, values) {
|
|
|
18508
18508
|
return portable === void 0 ? Reflect.apply(Reflect.get(formatter, method), formatter, values) : portable.numberFormatterResult(formatter, method, values);
|
|
18509
18509
|
}
|
|
18510
18510
|
|
|
18511
|
-
// packages/safe-js/src/interp/
|
|
18511
|
+
// packages/safe-js/src/interp/intl-digit-options.ts
|
|
18512
18512
|
var roundingIncrements = [1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3, 2e3, 2500, 5e3];
|
|
18513
|
-
async function
|
|
18513
|
+
async function readIntlDigitOptions(input, defaults, budget, context) {
|
|
18514
18514
|
const options = /* @__PURE__ */ Object.create(null);
|
|
18515
18515
|
const digits = /* @__PURE__ */ Object.create(null);
|
|
18516
|
-
const
|
|
18516
|
+
const minimumDefault = defaults.minimum;
|
|
18517
|
+
let maximumDefault = defaults.maximum;
|
|
18518
|
+
const notation = defaults.notation;
|
|
18519
|
+
const release = retainValues(budget, () => [input, options, digits]);
|
|
18517
18520
|
try {
|
|
18518
|
-
const input = intlOptionsObject(inputValue, budget);
|
|
18519
18521
|
const readString = async (key, type) => {
|
|
18520
18522
|
const raw = await readIntlProperty(input, key, budget, context);
|
|
18521
18523
|
if (raw === void 0) return void 0;
|
|
@@ -18531,29 +18533,6 @@ async function readNumberFormatOptions(inputValue, locales2, budget, context) {
|
|
|
18531
18533
|
throw new RangeError(`Invalid ${key} option.`);
|
|
18532
18534
|
return Math.floor(number);
|
|
18533
18535
|
};
|
|
18534
|
-
await readString("localeMatcher", ["lookup", "best fit"]);
|
|
18535
|
-
await readString("numberingSystem", "unicodeType");
|
|
18536
|
-
const style = await readString("style", ["decimal", "percent", "currency", "unit"]) ?? "decimal";
|
|
18537
|
-
const currency = await readString("currency");
|
|
18538
|
-
if (currency === void 0) {
|
|
18539
|
-
if (style === "currency") throw new TypeError("Currency formatting requires a currency.");
|
|
18540
|
-
} else if (currency.length !== 3 || ![...currency].every((char) => char >= "A" && char <= "Z" || char >= "a" && char <= "z"))
|
|
18541
|
-
throw new RangeError("Invalid currency code.");
|
|
18542
|
-
await readString("currencyDisplay", ["code", "symbol", "narrowSymbol", "name"]);
|
|
18543
|
-
await readString("currencySign", ["standard", "accounting"]);
|
|
18544
|
-
const unit = await readString("unit");
|
|
18545
|
-
if (unit === void 0) {
|
|
18546
|
-
if (style === "unit") throw new TypeError("Unit formatting requires a unit.");
|
|
18547
|
-
} else createNumberFormatter("en", { style: "unit", unit });
|
|
18548
|
-
await readString("unitDisplay", ["short", "narrow", "long"]);
|
|
18549
|
-
const notation = await readString("notation", ["standard", "scientific", "engineering", "compact"]) ?? "standard";
|
|
18550
|
-
let minimumDefault = 0;
|
|
18551
|
-
let maximumDefault = style === "percent" ? 0 : 3;
|
|
18552
|
-
if (style === "currency" && notation === "standard") {
|
|
18553
|
-
const currencyDefaults = numberFormatterOptions2(createNumberFormatter("en", { style: "currency", currency }));
|
|
18554
|
-
minimumDefault = currencyDefaults.minimumFractionDigits;
|
|
18555
|
-
maximumDefault = currencyDefaults.maximumFractionDigits;
|
|
18556
|
-
}
|
|
18557
18536
|
options.minimumIntegerDigits = await numberOption(await readIntlProperty(input, "minimumIntegerDigits", budget, context), "minimumIntegerDigits", 1, 21, 1);
|
|
18558
18537
|
for (const key of ["minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"])
|
|
18559
18538
|
digits[key] = await readIntlProperty(input, key, budget, context);
|
|
@@ -18585,6 +18564,50 @@ async function readNumberFormatOptions(inputValue, locales2, budget, context) {
|
|
|
18585
18564
|
options.minimumFractionDigits = minimum;
|
|
18586
18565
|
options.maximumFractionDigits = maximum;
|
|
18587
18566
|
}
|
|
18567
|
+
return options;
|
|
18568
|
+
} finally {
|
|
18569
|
+
release();
|
|
18570
|
+
}
|
|
18571
|
+
}
|
|
18572
|
+
|
|
18573
|
+
// packages/safe-js/src/interp/number-locale.ts
|
|
18574
|
+
async function readNumberFormatOptions(inputValue, locales2, budget, context) {
|
|
18575
|
+
const options = /* @__PURE__ */ Object.create(null);
|
|
18576
|
+
const release = retainValues(budget, () => [inputValue, locales2, options]);
|
|
18577
|
+
try {
|
|
18578
|
+
const input = intlOptionsObject(inputValue, budget);
|
|
18579
|
+
const readString = async (key, type) => {
|
|
18580
|
+
const raw = await readIntlProperty(input, key, budget, context);
|
|
18581
|
+
if (raw === void 0) return void 0;
|
|
18582
|
+
const text = type === void 0 ? await sandboxString(raw, budget, context) : await convertIntlOption(raw, key, type, budget, context);
|
|
18583
|
+
if (type === void 0) budget.visitNode(text.length);
|
|
18584
|
+
options[key] = text;
|
|
18585
|
+
return text;
|
|
18586
|
+
};
|
|
18587
|
+
await readString("localeMatcher", ["lookup", "best fit"]);
|
|
18588
|
+
await readString("numberingSystem", "unicodeType");
|
|
18589
|
+
const style = await readString("style", ["decimal", "percent", "currency", "unit"]) ?? "decimal";
|
|
18590
|
+
const currency = await readString("currency");
|
|
18591
|
+
if (currency === void 0) {
|
|
18592
|
+
if (style === "currency") throw new TypeError("Currency formatting requires a currency.");
|
|
18593
|
+
} else if (currency.length !== 3 || ![...currency].every((char) => char >= "A" && char <= "Z" || char >= "a" && char <= "z"))
|
|
18594
|
+
throw new RangeError("Invalid currency code.");
|
|
18595
|
+
await readString("currencyDisplay", ["code", "symbol", "narrowSymbol", "name"]);
|
|
18596
|
+
await readString("currencySign", ["standard", "accounting"]);
|
|
18597
|
+
const unit = await readString("unit");
|
|
18598
|
+
if (unit === void 0) {
|
|
18599
|
+
if (style === "unit") throw new TypeError("Unit formatting requires a unit.");
|
|
18600
|
+
} else createNumberFormatter("en", { style: "unit", unit });
|
|
18601
|
+
await readString("unitDisplay", ["short", "narrow", "long"]);
|
|
18602
|
+
const notation = await readString("notation", ["standard", "scientific", "engineering", "compact"]) ?? "standard";
|
|
18603
|
+
let minimumDefault = 0;
|
|
18604
|
+
let maximumDefault = style === "percent" ? 0 : 3;
|
|
18605
|
+
if (style === "currency" && notation === "standard") {
|
|
18606
|
+
const currencyDefaults = numberFormatterOptions2(createNumberFormatter("en", { style: "currency", currency }));
|
|
18607
|
+
minimumDefault = currencyDefaults.minimumFractionDigits;
|
|
18608
|
+
maximumDefault = currencyDefaults.maximumFractionDigits;
|
|
18609
|
+
}
|
|
18610
|
+
Object.assign(options, await readIntlDigitOptions(input, { minimum: minimumDefault, maximum: maximumDefault, notation }, budget, context));
|
|
18588
18611
|
createNumberFormatter(locales2, options);
|
|
18589
18612
|
await readString("compactDisplay", ["short", "long"]);
|
|
18590
18613
|
const grouping = await readIntlProperty(input, "useGrouping", budget, context);
|
|
@@ -28629,7 +28652,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
|
|
|
28629
28652
|
}
|
|
28630
28653
|
const updated = Object.values(base).filter((value) => value !== void 0).join("-") + canonical.slice(native.baseName.length);
|
|
28631
28654
|
const extension = unicodeKeywords(updated);
|
|
28632
|
-
const
|
|
28655
|
+
const optionTypes6 = [
|
|
28633
28656
|
["calendar", "ca", "unicodeType"],
|
|
28634
28657
|
["collation", "co", "unicodeType"],
|
|
28635
28658
|
["firstDayOfWeek", "fw", "unicodeType"],
|
|
@@ -28638,7 +28661,7 @@ async function buildLocaleTag(input, optionsInput, budget, context) {
|
|
|
28638
28661
|
["numeric", "kn", "boolean"],
|
|
28639
28662
|
["numberingSystem", "nu", "unicodeType"]
|
|
28640
28663
|
];
|
|
28641
|
-
for (const [key, extensionKey, type] of
|
|
28664
|
+
for (const [key, extensionKey, type] of optionTypes6) {
|
|
28642
28665
|
let value = await readIntlProperty(options, key, budget, context);
|
|
28643
28666
|
if (value === void 0) continue;
|
|
28644
28667
|
if (key === "firstDayOfWeek") {
|
|
@@ -28726,20 +28749,48 @@ function displayName(value, code) {
|
|
|
28726
28749
|
return Reflect.apply(of, displayNamesState(value).native, [code]);
|
|
28727
28750
|
}
|
|
28728
28751
|
|
|
28729
|
-
// packages/safe-js/src/interp/intl-
|
|
28752
|
+
// packages/safe-js/src/interp/intl-pluralrules.ts
|
|
28753
|
+
var PortablePluralRules = numberFormatIntl.PluralRules;
|
|
28754
|
+
var select = PortablePluralRules.prototype.select;
|
|
28755
|
+
var selectRange = PortablePluralRules.prototype.selectRange;
|
|
28756
|
+
var resolvedOptions5 = PortablePluralRules.prototype.resolvedOptions;
|
|
28730
28757
|
var states9 = /* @__PURE__ */ new WeakMap();
|
|
28758
|
+
function createSandboxPluralRules(locales2, options) {
|
|
28759
|
+
const native = new PortablePluralRules(locales2, options);
|
|
28760
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
28761
|
+
states9.set(value, { native, options: { ...Reflect.apply(resolvedOptions5, native, []) } });
|
|
28762
|
+
return value;
|
|
28763
|
+
}
|
|
28764
|
+
function isSandboxPluralRules(value) {
|
|
28765
|
+
return typeof value === "object" && value !== null && states9.has(value);
|
|
28766
|
+
}
|
|
28767
|
+
function pluralRulesState(value) {
|
|
28768
|
+
if (!isSandboxPluralRules(value)) throw new TypeError("Intl.PluralRules requires a PluralRules receiver.");
|
|
28769
|
+
return states9.get(value);
|
|
28770
|
+
}
|
|
28771
|
+
function selectPlural2(value, inputs) {
|
|
28772
|
+
inputs = inputs.map((input) => {
|
|
28773
|
+
if (typeof input !== "string") return input;
|
|
28774
|
+
const number = Number(input);
|
|
28775
|
+
return !Number.isFinite(number) || number === 0 ? number : input.trim();
|
|
28776
|
+
});
|
|
28777
|
+
return Reflect.apply(inputs.length === 1 ? select : selectRange, pluralRulesState(value).native, inputs);
|
|
28778
|
+
}
|
|
28779
|
+
|
|
28780
|
+
// packages/safe-js/src/interp/intl-numberformat.ts
|
|
28781
|
+
var states10 = /* @__PURE__ */ new WeakMap();
|
|
28731
28782
|
function createSandboxNumberFormat(locales2, options) {
|
|
28732
28783
|
const native = createNumberFormatter(locales2, options);
|
|
28733
28784
|
const value = /* @__PURE__ */ Object.create(null);
|
|
28734
|
-
|
|
28785
|
+
states10.set(value, { native, options: numberFormatterOptions2(native) });
|
|
28735
28786
|
return value;
|
|
28736
28787
|
}
|
|
28737
28788
|
function isSandboxNumberFormat(value) {
|
|
28738
|
-
return typeof value === "object" && value !== null &&
|
|
28789
|
+
return typeof value === "object" && value !== null && states10.has(value);
|
|
28739
28790
|
}
|
|
28740
28791
|
function numberFormatState(value) {
|
|
28741
28792
|
if (!isSandboxNumberFormat(value)) throw new TypeError("Intl.NumberFormat requires a NumberFormat receiver.");
|
|
28742
|
-
return
|
|
28793
|
+
return states10.get(value);
|
|
28743
28794
|
}
|
|
28744
28795
|
async function numberFormatValue(value, budget, context) {
|
|
28745
28796
|
const primitive = typeof value === "object" && value !== null ? await objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number") : value;
|
|
@@ -28756,28 +28807,28 @@ function formatNumberValue(receiver, method, values) {
|
|
|
28756
28807
|
|
|
28757
28808
|
// packages/safe-js/src/interp/intl-datetimeformat.ts
|
|
28758
28809
|
var NativeDateTimeFormat = Intl.DateTimeFormat;
|
|
28759
|
-
var
|
|
28810
|
+
var resolvedOptions6 = NativeDateTimeFormat.prototype.resolvedOptions;
|
|
28760
28811
|
var format3 = Object.getOwnPropertyDescriptor(NativeDateTimeFormat.prototype, "format").get;
|
|
28761
28812
|
var methods = {
|
|
28762
28813
|
formatToParts: NativeDateTimeFormat.prototype.formatToParts,
|
|
28763
28814
|
formatRange: NativeDateTimeFormat.prototype.formatRange,
|
|
28764
28815
|
formatRangeToParts: NativeDateTimeFormat.prototype.formatRangeToParts
|
|
28765
28816
|
};
|
|
28766
|
-
var
|
|
28817
|
+
var states11 = /* @__PURE__ */ new WeakMap();
|
|
28767
28818
|
function createSandboxDateTimeFormat(locales2, options, restoring = false) {
|
|
28768
28819
|
const input = { ...options };
|
|
28769
28820
|
if (restoring) delete input.hour12;
|
|
28770
28821
|
const native = new NativeDateTimeFormat(locales2, input);
|
|
28771
28822
|
const value = /* @__PURE__ */ Object.create(null);
|
|
28772
|
-
|
|
28823
|
+
states11.set(value, { native, options: { ...Reflect.apply(resolvedOptions6, native, []) } });
|
|
28773
28824
|
return value;
|
|
28774
28825
|
}
|
|
28775
28826
|
function isSandboxDateTimeFormat(value) {
|
|
28776
|
-
return typeof value === "object" && value !== null &&
|
|
28827
|
+
return typeof value === "object" && value !== null && states11.has(value);
|
|
28777
28828
|
}
|
|
28778
28829
|
function dateTimeFormatState(value) {
|
|
28779
28830
|
if (!isSandboxDateTimeFormat(value)) throw new TypeError("Intl.DateTimeFormat requires a DateTimeFormat receiver.");
|
|
28780
|
-
return
|
|
28831
|
+
return states11.get(value);
|
|
28781
28832
|
}
|
|
28782
28833
|
function formatDateTimeValue(receiver, method, values) {
|
|
28783
28834
|
const { native } = dateTimeFormatState(receiver);
|
|
@@ -29126,6 +29177,10 @@ function captureGuestHeapNode(value, encode) {
|
|
|
29126
29177
|
if (isSandboxListFormat(value)) return { kind: "guest-listformat", options: { ...listFormatState(value).options }, state: captureObjectState(value, encode) };
|
|
29127
29178
|
if (isSandboxRelativeTimeFormat(value)) return { kind: "guest-relativetimeformat", options: { ...relativeTimeFormatState(value).options }, state: captureObjectState(value, encode) };
|
|
29128
29179
|
if (isSandboxDisplayNames(value)) return { kind: "guest-displaynames", options: { ...displayNamesState(value).options }, state: captureObjectState(value, encode) };
|
|
29180
|
+
if (isSandboxPluralRules(value)) {
|
|
29181
|
+
const options = pluralRulesState(value).options;
|
|
29182
|
+
return { kind: "guest-pluralrules", options: { ...options, pluralCategories: [...options.pluralCategories] }, state: captureObjectState(value, encode) };
|
|
29183
|
+
}
|
|
29129
29184
|
if (isSandboxDateTimeFormat(value)) {
|
|
29130
29185
|
const { options, format: format4 } = dateTimeFormatState(value);
|
|
29131
29186
|
return { kind: "guest-datetimeformat", options: { ...options }, ...format4 === void 0 ? {} : { format: encode(format4) }, state: captureObjectState(value, encode) };
|
|
@@ -34085,6 +34140,104 @@ function createDateTimeFormatConstructor(budget, now) {
|
|
|
34085
34140
|
return constructor;
|
|
34086
34141
|
}
|
|
34087
34142
|
|
|
34143
|
+
// packages/safe-js/src/interp/globals/intl-pluralrules.ts
|
|
34144
|
+
var supportedLocalesOf8 = Intl.PluralRules.supportedLocalesOf;
|
|
34145
|
+
var optionTypes5 = [
|
|
34146
|
+
["localeMatcher", ["lookup", "best fit"]],
|
|
34147
|
+
["type", ["cardinal", "ordinal"]]
|
|
34148
|
+
];
|
|
34149
|
+
function createPluralRulesConstructor(budget) {
|
|
34150
|
+
const prototype = createIntrinsicObject();
|
|
34151
|
+
const constructor = createSandboxClosure({
|
|
34152
|
+
guest: true,
|
|
34153
|
+
sandbox: true,
|
|
34154
|
+
name: "PluralRules",
|
|
34155
|
+
length: 0,
|
|
34156
|
+
call: () => {
|
|
34157
|
+
throw new TypeError("Constructor PluralRules requires 'new'.");
|
|
34158
|
+
},
|
|
34159
|
+
construct: async ([input, options], context) => {
|
|
34160
|
+
const target = context?.newTarget;
|
|
34161
|
+
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);
|
|
34162
|
+
let locales2 = [];
|
|
34163
|
+
const converted = /* @__PURE__ */ Object.create(null);
|
|
34164
|
+
const release = retainValues(budget, () => [selected, locales2, converted]);
|
|
34165
|
+
try {
|
|
34166
|
+
locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
34167
|
+
const source = intlOptionsObject(options, budget);
|
|
34168
|
+
for (const [key, type] of optionTypes5) {
|
|
34169
|
+
const raw = await readIntlProperty(source, key, budget, context);
|
|
34170
|
+
if (raw !== void 0) converted[key] = await convertIntlOption(raw, key, type, budget, context);
|
|
34171
|
+
}
|
|
34172
|
+
Object.assign(converted, await readIntlDigitOptions(source, { minimum: 0, maximum: 3, notation: "standard" }, budget, context));
|
|
34173
|
+
const value = createSandboxPluralRules(locales2, converted);
|
|
34174
|
+
setSandboxPrototype(value, typeof selected === "object" && selected !== null ? selected : prototype, budget);
|
|
34175
|
+
return allocateProducedSandboxValue(value, budget);
|
|
34176
|
+
} finally {
|
|
34177
|
+
release();
|
|
34178
|
+
}
|
|
34179
|
+
}
|
|
34180
|
+
});
|
|
34181
|
+
const properties = materializeFunctionProperties(constructor);
|
|
34182
|
+
Object.defineProperty(properties, "prototype", { value: prototype, writable: false, configurable: false });
|
|
34183
|
+
Object.defineProperty(properties, "supportedLocalesOf", { value: createSandboxClosure({
|
|
34184
|
+
guest: true,
|
|
34185
|
+
sandbox: true,
|
|
34186
|
+
name: "supportedLocalesOf",
|
|
34187
|
+
length: 1,
|
|
34188
|
+
call: async ([input, options], context) => {
|
|
34189
|
+
const locales2 = await canonicalizeGuestLocales(input, budget, context);
|
|
34190
|
+
const release = retainValues(budget, () => [locales2]);
|
|
34191
|
+
try {
|
|
34192
|
+
const source = intlOptionsObject(options, budget);
|
|
34193
|
+
const raw = await readIntlProperty(source, "localeMatcher", budget, context);
|
|
34194
|
+
const matcher = raw === void 0 ? void 0 : await convertIntlOption(raw, "localeMatcher", ["lookup", "best fit"], budget, context);
|
|
34195
|
+
return allocateProducedSandboxValue(supportedLocalesOf8(locales2, { localeMatcher: matcher }), budget);
|
|
34196
|
+
} finally {
|
|
34197
|
+
release();
|
|
34198
|
+
}
|
|
34199
|
+
}
|
|
34200
|
+
}), writable: true, configurable: true });
|
|
34201
|
+
Object.defineProperties(prototype, {
|
|
34202
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
34203
|
+
[Symbol.toStringTag]: { value: "Intl.PluralRules", configurable: true },
|
|
34204
|
+
resolvedOptions: { value: createSandboxClosure({
|
|
34205
|
+
guest: true,
|
|
34206
|
+
sandbox: true,
|
|
34207
|
+
name: "resolvedOptions",
|
|
34208
|
+
length: 0,
|
|
34209
|
+
call: (_args, context) => {
|
|
34210
|
+
const options = pluralRulesState(context?.thisValue).options;
|
|
34211
|
+
return allocateProducedSandboxValue({ ...options, pluralCategories: [...options.pluralCategories] }, budget);
|
|
34212
|
+
}
|
|
34213
|
+
}), writable: true, configurable: true }
|
|
34214
|
+
});
|
|
34215
|
+
for (const method of ["select", "selectRange"]) {
|
|
34216
|
+
const range = method === "selectRange";
|
|
34217
|
+
Object.defineProperty(prototype, method, { value: createSandboxClosure({
|
|
34218
|
+
guest: true,
|
|
34219
|
+
sandbox: true,
|
|
34220
|
+
name: method,
|
|
34221
|
+
length: range ? 2 : 1,
|
|
34222
|
+
call: async ([first, second], context) => {
|
|
34223
|
+
const receiver = context?.thisValue;
|
|
34224
|
+
pluralRulesState(receiver);
|
|
34225
|
+
if (range && (first === void 0 || second === void 0)) throw new TypeError("PluralRules range requires both values.");
|
|
34226
|
+
const inputs = [];
|
|
34227
|
+
const release = retainValues(budget, () => [receiver, first, second, inputs]);
|
|
34228
|
+
try {
|
|
34229
|
+
inputs.push(await numberFormatValue(first, budget, context));
|
|
34230
|
+
if (range) inputs.push(await numberFormatValue(second, budget, context));
|
|
34231
|
+
return allocateProducedSandboxValue(selectPlural2(receiver, inputs), budget);
|
|
34232
|
+
} finally {
|
|
34233
|
+
release();
|
|
34234
|
+
}
|
|
34235
|
+
}
|
|
34236
|
+
}), writable: true, configurable: true });
|
|
34237
|
+
}
|
|
34238
|
+
return constructor;
|
|
34239
|
+
}
|
|
34240
|
+
|
|
34088
34241
|
// packages/safe-js/src/interp/globals/intl.ts
|
|
34089
34242
|
var supportedValuesOf = Intl.supportedValuesOf;
|
|
34090
34243
|
function createIntlGlobal(budget, now) {
|
|
@@ -34104,6 +34257,7 @@ function createIntlGlobal(budget, now) {
|
|
|
34104
34257
|
const relativeTimeFormat = createRelativeTimeFormatConstructor(budget);
|
|
34105
34258
|
const displayNames = createDisplayNamesConstructor(budget);
|
|
34106
34259
|
const dateTimeFormat = createDateTimeFormatConstructor(budget, now);
|
|
34260
|
+
const pluralRules = createPluralRulesConstructor(budget);
|
|
34107
34261
|
Object.defineProperty(intl, "Locale", { value: locale, writable: true, configurable: true });
|
|
34108
34262
|
Object.defineProperty(intl, "Collator", { value: collator, writable: true, configurable: true });
|
|
34109
34263
|
Object.defineProperty(intl, "NumberFormat", { value: numberFormat, writable: true, configurable: true });
|
|
@@ -34111,13 +34265,14 @@ function createIntlGlobal(budget, now) {
|
|
|
34111
34265
|
Object.defineProperty(intl, "RelativeTimeFormat", { value: relativeTimeFormat, writable: true, configurable: true });
|
|
34112
34266
|
Object.defineProperty(intl, "DisplayNames", { value: displayNames, writable: true, configurable: true });
|
|
34113
34267
|
Object.defineProperty(intl, "DateTimeFormat", { value: dateTimeFormat, writable: true, configurable: true });
|
|
34268
|
+
Object.defineProperty(intl, "PluralRules", { value: pluralRules, writable: true, configurable: true });
|
|
34114
34269
|
for (const [name, call] of Object.entries(methods3)) {
|
|
34115
34270
|
const closure = createSandboxClosure({ guest: true, sandbox: true, name, length: 1, call });
|
|
34116
34271
|
Object.defineProperty(intl, name, { value: closure, writable: true, configurable: true });
|
|
34117
34272
|
}
|
|
34118
34273
|
Object.defineProperty(intl, Symbol.toStringTag, { value: "Intl", configurable: true });
|
|
34119
34274
|
registerBuiltinIdentities(budget, { Intl: intl });
|
|
34120
|
-
for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat]) {
|
|
34275
|
+
for (const constructor of [locale, collator, numberFormat, listFormat, relativeTimeFormat, displayNames, dateTimeFormat, pluralRules]) {
|
|
34121
34276
|
const prototype = constructor.properties.prototype;
|
|
34122
34277
|
for (const owner of [prototype, constructor.properties])
|
|
34123
34278
|
for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(owner)))
|
|
@@ -34235,7 +34390,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
34235
34390
|
createRawJson(node.text);
|
|
34236
34391
|
return true;
|
|
34237
34392
|
}
|
|
34238
|
-
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;
|
|
34393
|
+
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-pluralrules", "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;
|
|
34239
34394
|
const reference = (value, kinds) => {
|
|
34240
34395
|
const ref = record2(value);
|
|
34241
34396
|
fields(ref, ["kind", "id"]);
|
|
@@ -34543,6 +34698,22 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
34543
34698
|
const restored = listFormatState(createSandboxListFormat(options.locale, options)).options;
|
|
34544
34699
|
if (names.some((key) => options[key] !== restored[key])) throw new TypeError("Invalid resolved ListFormat options.");
|
|
34545
34700
|
state(node.state);
|
|
34701
|
+
} else if (node.kind === "guest-pluralrules") {
|
|
34702
|
+
fields(node, ["kind", "options", "state"]);
|
|
34703
|
+
const options = record2(node.options);
|
|
34704
|
+
fields(
|
|
34705
|
+
options,
|
|
34706
|
+
["locale", "type", "minimumIntegerDigits", "pluralCategories", "roundingIncrement", "roundingMode", "roundingPriority", "trailingZeroDisplay"],
|
|
34707
|
+
["minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits"]
|
|
34708
|
+
);
|
|
34709
|
+
if (typeof options.locale !== "string" || !Array.isArray(options.pluralCategories) || options.pluralCategories.some((value) => typeof value !== "string") || Object.entries(options).some(([key, value]) => key !== "pluralCategories" && typeof value !== "string" && typeof value !== "number"))
|
|
34710
|
+
throw new TypeError("Invalid PluralRules option type.");
|
|
34711
|
+
const restored = pluralRulesState(createSandboxPluralRules(options.locale, options)).options;
|
|
34712
|
+
if (Object.keys(options).length !== Object.keys(restored).length || Object.keys(restored).some((key) => {
|
|
34713
|
+
const value = restored[key];
|
|
34714
|
+
return Array.isArray(value) ? options[key].length !== value.length || value.some((item, index) => options[key][index] !== item) : options[key] !== value;
|
|
34715
|
+
})) throw new TypeError("Invalid resolved PluralRules options.");
|
|
34716
|
+
state(node.state);
|
|
34546
34717
|
} else if (node.kind === "guest-displaynames") {
|
|
34547
34718
|
fields(node, ["kind", "options", "state"]);
|
|
34548
34719
|
const options = record2(node.options);
|
|
@@ -38319,6 +38490,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
38319
38490
|
if (isSandboxListFormat(value)) visit(listFormatState(value).options, depth + 1);
|
|
38320
38491
|
if (isSandboxRelativeTimeFormat(value)) visit(relativeTimeFormatState(value).options, depth + 1);
|
|
38321
38492
|
if (isSandboxDisplayNames(value)) visit(displayNamesState(value).options, depth + 1);
|
|
38493
|
+
if (isSandboxPluralRules(value)) visit(pluralRulesState(value).options, depth + 1);
|
|
38322
38494
|
if (isSandboxNumberFormat(value)) {
|
|
38323
38495
|
const state = numberFormatState(value);
|
|
38324
38496
|
visit(state.options, depth + 1);
|
|
@@ -56309,4 +56481,4 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
56309
56481
|
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.
|
|
56310
56482
|
|
|
56311
56483
|
*/
|
|
56312
|
-
//# sourceMappingURL=chunk-
|
|
56484
|
+
//# sourceMappingURL=chunk-NYT6Z4RI.js.map
|