@poe-platform/safe-js 0.1.289 → 0.1.291
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-BNVOTMJ4.js → chunk-DYGBPKZA.js} +2 -2
- package/dist/safe-js/chunks/{chunk-KKMT52LR.js → chunk-ZOLHW4OV.js} +117 -47
- package/dist/safe-js/chunks/chunk-ZOLHW4OV.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/package.json +2 -2
- package/dist/safe-js/chunks/chunk-KKMT52LR.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-BNVOTMJ4.js.map → chunk-DYGBPKZA.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ZOLHW4OV.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-DYGBPKZA.js.map
|
|
@@ -10501,6 +10501,107 @@ function formatNumber(value, methodName, argument, budget) {
|
|
|
10501
10501
|
|
|
10502
10502
|
// packages/safe-js/src/interp/methods/string.ts
|
|
10503
10503
|
import { types as types5 } from "node:util";
|
|
10504
|
+
|
|
10505
|
+
// packages/safe-js/src/interp/intl-options.ts
|
|
10506
|
+
var canonicalLocales = Intl.getCanonicalLocales;
|
|
10507
|
+
function readIntlProperty(value, key, budget, context) {
|
|
10508
|
+
budget.visitNode();
|
|
10509
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
10510
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
10511
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
10512
|
+
}
|
|
10513
|
+
function intlOptionsObject(value, budget) {
|
|
10514
|
+
if (value === void 0) return /* @__PURE__ */ Object.create(null);
|
|
10515
|
+
if (value === null) throw new TypeError("Cannot convert null to an object.");
|
|
10516
|
+
if (typeof value === "object") return value;
|
|
10517
|
+
const box = createSandboxBox(value);
|
|
10518
|
+
allocateProducedSandboxValue(box, budget);
|
|
10519
|
+
return box;
|
|
10520
|
+
}
|
|
10521
|
+
async function canonicalizeGuestLocales(input, budget, context) {
|
|
10522
|
+
const locales = [];
|
|
10523
|
+
if (input === void 0) return locales;
|
|
10524
|
+
if (input === null) return Reflect.apply(canonicalLocales, Intl, [input]);
|
|
10525
|
+
const release = retainValues(budget, () => [locales]);
|
|
10526
|
+
try {
|
|
10527
|
+
const list2 = typeof input === "string" ? [input] : intlOptionsObject(input, budget);
|
|
10528
|
+
const count = await sandboxNumber(await readIntlProperty(list2, "length", budget, context), budget, context);
|
|
10529
|
+
const length = Number.isNaN(count) || count <= 0 ? 0 : Math.min(Math.floor(count), Number.MAX_SAFE_INTEGER);
|
|
10530
|
+
for (let index = 0; index < length; index++) {
|
|
10531
|
+
budget.visitNode();
|
|
10532
|
+
const key = String(index);
|
|
10533
|
+
if (getSandboxPropertyDescriptor(list2, key, budget) === void 0 && !(isFloat32Array(list2) && Object.hasOwn(list2, key))) continue;
|
|
10534
|
+
const value = await readIntlProperty(list2, key, budget, context);
|
|
10535
|
+
if (typeof value !== "string" && (typeof value !== "object" || value === null))
|
|
10536
|
+
return Reflect.apply(canonicalLocales, Intl, [[value]]);
|
|
10537
|
+
const tag = await sandboxString(value, budget, context);
|
|
10538
|
+
budget.visitNode(tag.length);
|
|
10539
|
+
const canonical = canonicalLocales(tag)[0];
|
|
10540
|
+
budget.visitNode(locales.length);
|
|
10541
|
+
if (!locales.includes(canonical)) locales.push(budget.allocateString(canonical));
|
|
10542
|
+
}
|
|
10543
|
+
return locales;
|
|
10544
|
+
} finally {
|
|
10545
|
+
release();
|
|
10546
|
+
}
|
|
10547
|
+
}
|
|
10548
|
+
async function convertIntlOption(value, key, type, budget, context, invalid) {
|
|
10549
|
+
if (type === "boolean") return Boolean(value);
|
|
10550
|
+
const text = await sandboxString(value, budget, context);
|
|
10551
|
+
budget.visitNode(text.length);
|
|
10552
|
+
if (type === "unicodeType") {
|
|
10553
|
+
const valid = text.split("-").every((part) => part.length >= 3 && part.length <= 8 && [...part].every((char) => char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9"));
|
|
10554
|
+
if (valid) return text;
|
|
10555
|
+
} else if (type.includes(text)) return text;
|
|
10556
|
+
invalid?.(text);
|
|
10557
|
+
throw new RangeError(`Invalid ${key} option.`);
|
|
10558
|
+
}
|
|
10559
|
+
|
|
10560
|
+
// packages/safe-js/src/interp/methods/string-locale.ts
|
|
10561
|
+
var collatorOptions = [
|
|
10562
|
+
["usage", ["sort", "search"]],
|
|
10563
|
+
["localeMatcher", ["lookup", "best fit"]],
|
|
10564
|
+
["collation", "unicodeType"],
|
|
10565
|
+
["numeric", "boolean"],
|
|
10566
|
+
["caseFirst", ["upper", "lower", "false"]],
|
|
10567
|
+
["sensitivity", ["base", "accent", "case", "variant"]],
|
|
10568
|
+
["ignorePunctuation", "boolean"]
|
|
10569
|
+
];
|
|
10570
|
+
async function changeStringLocaleCase(value, method, args, budget, context) {
|
|
10571
|
+
let locales = [];
|
|
10572
|
+
const release = retainValues(budget, () => [value, locales]);
|
|
10573
|
+
try {
|
|
10574
|
+
locales = await canonicalizeGuestLocales(args[0], budget, context);
|
|
10575
|
+
budget.visitNode(value.length);
|
|
10576
|
+
return budget.allocateString(Reflect.apply(String.prototype[method], value, [locales]));
|
|
10577
|
+
} finally {
|
|
10578
|
+
release();
|
|
10579
|
+
}
|
|
10580
|
+
}
|
|
10581
|
+
async function compareStringLocale(value, args, budget, context) {
|
|
10582
|
+
let comparison = "";
|
|
10583
|
+
let locales = [];
|
|
10584
|
+
const options = /* @__PURE__ */ Object.create(null);
|
|
10585
|
+
const release = retainValues(budget, () => [value, comparison, locales, options]);
|
|
10586
|
+
try {
|
|
10587
|
+
comparison = await sandboxString(args[0], budget, context);
|
|
10588
|
+
locales = await canonicalizeGuestLocales(args[1], budget, context);
|
|
10589
|
+
if (args[2] === null) return Reflect.apply(String.prototype.localeCompare, value, [comparison, locales, null]);
|
|
10590
|
+
const inputOptions = intlOptionsObject(args[2], budget);
|
|
10591
|
+
for (const [key, type] of collatorOptions) {
|
|
10592
|
+
const option = await readIntlProperty(inputOptions, key, budget, context);
|
|
10593
|
+
if (option !== void 0) options[key] = await convertIntlOption(option, key, type, budget, context, (text) => {
|
|
10594
|
+
Reflect.apply(String.prototype.localeCompare, "", ["", [], { [key]: text }]);
|
|
10595
|
+
});
|
|
10596
|
+
}
|
|
10597
|
+
budget.visitNode(value.length + comparison.length);
|
|
10598
|
+
return Reflect.apply(String.prototype.localeCompare, value, [comparison, locales, options]);
|
|
10599
|
+
} finally {
|
|
10600
|
+
release();
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10603
|
+
|
|
10604
|
+
// packages/safe-js/src/interp/methods/string.ts
|
|
10504
10605
|
var stringMethodNames = /* @__PURE__ */ new Set([
|
|
10505
10606
|
"at",
|
|
10506
10607
|
"charAt",
|
|
@@ -10529,6 +10630,8 @@ var stringMethodNames = /* @__PURE__ */ new Set([
|
|
|
10529
10630
|
"substring",
|
|
10530
10631
|
"toLowerCase",
|
|
10531
10632
|
"toUpperCase",
|
|
10633
|
+
"toLocaleLowerCase",
|
|
10634
|
+
"toLocaleUpperCase",
|
|
10532
10635
|
"toWellFormed",
|
|
10533
10636
|
"trim",
|
|
10534
10637
|
"trimEnd",
|
|
@@ -10548,6 +10651,7 @@ function getStringMember(value, property, budget) {
|
|
|
10548
10651
|
return createSandboxClosure({
|
|
10549
10652
|
sandbox: true,
|
|
10550
10653
|
name: `String#${property}`,
|
|
10654
|
+
...property === "toLocaleLowerCase" || property === "toLocaleUpperCase" ? { guest: true, name: property, length: 0 } : {},
|
|
10551
10655
|
...property === "localeCompare" ? { length: 1 } : {},
|
|
10552
10656
|
...property === "isWellFormed" || property === "toWellFormed" ? { length: 0 } : {},
|
|
10553
10657
|
call: async (args, context) => {
|
|
@@ -10685,6 +10789,10 @@ function callStringMethodBody(value, methodName, args, budget, parent, context)
|
|
|
10685
10789
|
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
10686
10790
|
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
10687
10791
|
}
|
|
10792
|
+
if (methodName === "toLocaleLowerCase" || methodName === "toLocaleUpperCase")
|
|
10793
|
+
return changeStringLocaleCase(value, methodName, args, budget, context);
|
|
10794
|
+
if (methodName === "localeCompare" && context?.getProperty !== void 0)
|
|
10795
|
+
return compareStringLocale(value, args, budget, context);
|
|
10688
10796
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
10689
10797
|
const compilation = new CompileScope(operation.owner);
|
|
10690
10798
|
try {
|
|
@@ -20371,7 +20479,6 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
|
20371
20479
|
|
|
20372
20480
|
// packages/safe-js/src/interp/date-locale.ts
|
|
20373
20481
|
var NativeDateTimeFormat = Intl.DateTimeFormat;
|
|
20374
|
-
var canonicalLocales = Intl.getCanonicalLocales;
|
|
20375
20482
|
var dateTimeOptions = [
|
|
20376
20483
|
["localeMatcher", ["lookup", "best fit"]],
|
|
20377
20484
|
["calendar", "unicodeType"],
|
|
@@ -20396,63 +20503,26 @@ var dateTimeOptions = [
|
|
|
20396
20503
|
];
|
|
20397
20504
|
async function formatDateLocale(name, time, args, budget, context) {
|
|
20398
20505
|
if (Number.isNaN(time)) return budget.allocateString("Invalid Date");
|
|
20399
|
-
|
|
20506
|
+
let locales = [];
|
|
20400
20507
|
const options = /* @__PURE__ */ Object.create(null);
|
|
20401
20508
|
const release = retainValues(budget, () => [locales, options]);
|
|
20402
|
-
const read = (value, key) => {
|
|
20403
|
-
budget.visitNode();
|
|
20404
|
-
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
20405
|
-
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
20406
|
-
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
20407
|
-
};
|
|
20408
|
-
const toObject = (value) => {
|
|
20409
|
-
if (value === null || value === void 0) throw new TypeError("Cannot convert null or undefined to an object.");
|
|
20410
|
-
if (typeof value === "object") return value;
|
|
20411
|
-
const box = createSandboxBox(value);
|
|
20412
|
-
allocateProducedSandboxValue(box, budget);
|
|
20413
|
-
return box;
|
|
20414
|
-
};
|
|
20415
20509
|
try {
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
const list2 = typeof inputLocales === "string" ? [inputLocales] : toObject(inputLocales);
|
|
20419
|
-
const count = await sandboxNumber(await read(list2, "length"), budget, context);
|
|
20420
|
-
const length = Number.isNaN(count) || count <= 0 ? 0 : Math.min(Math.floor(count), Number.MAX_SAFE_INTEGER);
|
|
20421
|
-
for (let index = 0; index < length; index++) {
|
|
20422
|
-
budget.visitNode();
|
|
20423
|
-
const key = String(index);
|
|
20424
|
-
if (getSandboxPropertyDescriptor(list2, key, budget) === void 0 && !(isFloat32Array(list2) && Object.hasOwn(list2, key))) continue;
|
|
20425
|
-
const value = await read(list2, key);
|
|
20426
|
-
if (typeof value !== "string" && (typeof value !== "object" || value === null))
|
|
20427
|
-
throw new TypeError("Locale entries must be strings or objects.");
|
|
20428
|
-
const tag = await sandboxString(value, budget, context);
|
|
20429
|
-
budget.visitNode(tag.length);
|
|
20430
|
-
const canonical = canonicalLocales(tag)[0];
|
|
20431
|
-
budget.visitNode(locales.length);
|
|
20432
|
-
if (!locales.includes(canonical)) locales.push(budget.allocateString(canonical));
|
|
20433
|
-
}
|
|
20434
|
-
}
|
|
20435
|
-
const inputOptions = args[1] === void 0 ? /* @__PURE__ */ Object.create(null) : toObject(args[1]);
|
|
20510
|
+
locales = await canonicalizeGuestLocales(args[0], budget, context);
|
|
20511
|
+
const inputOptions = intlOptionsObject(args[1], budget);
|
|
20436
20512
|
for (const [key, type] of dateTimeOptions) {
|
|
20437
|
-
const value = await
|
|
20513
|
+
const value = await readIntlProperty(inputOptions, key, budget, context);
|
|
20438
20514
|
if (value === void 0) continue;
|
|
20439
|
-
if (type === "
|
|
20440
|
-
else if (type === "number") {
|
|
20515
|
+
if (type === "number") {
|
|
20441
20516
|
const number = await sandboxNumber(value, budget, context);
|
|
20442
20517
|
if (!Number.isFinite(number) || number < 1 || number > 3)
|
|
20443
20518
|
throw new RangeError("fractionalSecondDigits must be between 1 and 3.");
|
|
20444
20519
|
options[key] = Math.floor(number);
|
|
20445
|
-
} else {
|
|
20520
|
+
} else if (type === "zone") {
|
|
20446
20521
|
const text = await sandboxString(value, budget, context);
|
|
20447
20522
|
budget.visitNode(text.length);
|
|
20448
|
-
|
|
20449
|
-
const valid = text.split("-").every((part) => part.length >= 3 && part.length <= 8 && [...part].every((char) => char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9"));
|
|
20450
|
-
if (!valid) throw new RangeError(`Invalid ${key} option.`);
|
|
20451
|
-
} else if (type === "zone") {
|
|
20452
|
-
new NativeDateTimeFormat("en", { timeZone: text });
|
|
20453
|
-
} else if (!type.includes(text)) throw new RangeError(`Invalid ${key} option.`);
|
|
20523
|
+
new NativeDateTimeFormat("en", { timeZone: text });
|
|
20454
20524
|
options[key] = text;
|
|
20455
|
-
}
|
|
20525
|
+
} else options[key] = await convertIntlOption(value, key, type, budget, context);
|
|
20456
20526
|
}
|
|
20457
20527
|
const date = name !== "toLocaleTimeString";
|
|
20458
20528
|
const clock = name !== "toLocaleDateString";
|
|
@@ -40449,4 +40519,4 @@ export {
|
|
|
40449
40519
|
FileSnapshotBackend,
|
|
40450
40520
|
run
|
|
40451
40521
|
};
|
|
40452
|
-
//# sourceMappingURL=chunk-
|
|
40522
|
+
//# sourceMappingURL=chunk-ZOLHW4OV.js.map
|