@poe-platform/safe-js 0.1.174 → 0.1.176
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-KWMGOGFY.js → chunk-7CBZ6QP7.js} +27 -20
- package/dist/safe-js/chunks/chunk-7CBZ6QP7.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-ECW7ILI7.js → chunk-CBG2KJVU.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/package.json +2 -2
- package/dist/safe-js/chunks/chunk-KWMGOGFY.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-ECW7ILI7.js.map → chunk-CBG2KJVU.js.map} +0 -0
|
@@ -10511,19 +10511,31 @@ function validateStringMethodArguments(_methodName, _args) {
|
|
|
10511
10511
|
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
|
|
10512
10512
|
if (value === null || value === void 0)
|
|
10513
10513
|
throw new TypeError(`String#${methodName} requires a non-null receiver.`);
|
|
10514
|
-
const fallback = (
|
|
10514
|
+
const fallback = (coercePattern = false) => {
|
|
10515
|
+
const apply = (string) => {
|
|
10516
|
+
if (coercePattern && (methodName === "match" || methodName === "matchAll" || methodName === "search"))
|
|
10517
|
+
return callStringPattern(string, methodName, args[0], budget, parent, context);
|
|
10518
|
+
const useRegex = isSandboxRegex(args[0]) && !coercePattern;
|
|
10519
|
+
if (methodName === "replace" || methodName === "replaceAll")
|
|
10520
|
+
return callReplaceLikeMethod(string, methodName, args, budget, callClosure, useRegex, context);
|
|
10521
|
+
if (methodName === "split") return callSplit(string, args, budget, useRegex, parent, context);
|
|
10522
|
+
return callStringMethodBody(string, methodName, args, budget, parent, context);
|
|
10523
|
+
};
|
|
10524
|
+
return typeof value === "string" ? apply(value) : Promise.resolve(sandboxString(value, budget, context)).then(apply);
|
|
10525
|
+
};
|
|
10515
10526
|
const symbol = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "matchAll" ? Symbol.matchAll : methodName === "replace" || methodName === "replaceAll" ? Symbol.replace : methodName === "split" ? Symbol.split : void 0;
|
|
10516
10527
|
const pattern = args[0];
|
|
10517
10528
|
if (symbol !== void 0 && types6.isRegExp(pattern))
|
|
10518
10529
|
throw new TypeError(`String#${methodName} does not accept unbranded host RegExp values.`);
|
|
10519
10530
|
if (symbol === void 0 || pattern === null || pattern === void 0) return fallback();
|
|
10520
|
-
const applyHook = (hook) => {
|
|
10521
|
-
if (hook === null || hook === void 0) return fallback();
|
|
10522
|
-
if (!isSandboxClosure(hook)) throw new TypeError(`String#${methodName} symbol hook must be callable.`);
|
|
10523
|
-
return invokeBuiltinClosure(hook, symbol === Symbol.split || symbol === Symbol.replace ? [value, args[1]] : [value], budget, context, pattern);
|
|
10524
|
-
};
|
|
10525
10531
|
const readProperty = (key) => context?.getProperty !== void 0 ? context.getProperty(pattern, key) : key === "flags" && isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, key, budget) === void 0 ? pattern.flags : getSandboxDataProperty(pattern, key, budget);
|
|
10526
10532
|
const dispatch = () => {
|
|
10533
|
+
const overriddenRegex = isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, symbol, budget) !== void 0;
|
|
10534
|
+
const applyHook = (hook2) => {
|
|
10535
|
+
if (hook2 === null || hook2 === void 0) return fallback(overriddenRegex);
|
|
10536
|
+
if (!isSandboxClosure(hook2)) throw new TypeError(`String#${methodName} symbol hook must be callable.`);
|
|
10537
|
+
return invokeBuiltinClosure(hook2, symbol === Symbol.split || symbol === Symbol.replace ? [value, args[1]] : [value], budget, context, pattern);
|
|
10538
|
+
};
|
|
10527
10539
|
const hook = readProperty(symbol);
|
|
10528
10540
|
return hook instanceof Promise ? hook.then(applyHook) : applyHook(hook);
|
|
10529
10541
|
};
|
|
@@ -10546,7 +10558,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
10546
10558
|
}
|
|
10547
10559
|
return dispatch();
|
|
10548
10560
|
}
|
|
10549
|
-
function callStringMethodBody(value, methodName, args, budget,
|
|
10561
|
+
function callStringMethodBody(value, methodName, args, budget, parent, context) {
|
|
10550
10562
|
if (methodName === "concat" && args.some((argument) => argument !== null && typeof argument === "object")) {
|
|
10551
10563
|
return callConcat(value, args, budget, context);
|
|
10552
10564
|
}
|
|
@@ -10585,10 +10597,6 @@ function callStringMethodBody(value, methodName, args, budget, callClosure = asy
|
|
|
10585
10597
|
}
|
|
10586
10598
|
return budget.allocateString(result + value.slice(spanStart));
|
|
10587
10599
|
}
|
|
10588
|
-
if (methodName === "replace" || methodName === "replaceAll") {
|
|
10589
|
-
return callReplaceLikeMethod(value, methodName, args, budget, callClosure, context);
|
|
10590
|
-
}
|
|
10591
|
-
if (methodName === "split") return callSplit(value, args, budget, parent, context);
|
|
10592
10600
|
const regex = args[0];
|
|
10593
10601
|
if (isSandboxRegex(regex) && regex.lastIndex !== null && typeof regex.lastIndex === "object" && (methodName === "match" && !regex.flags.includes("g") || methodName === "matchAll")) {
|
|
10594
10602
|
return callStringRegexCursor(value, methodName, regex, budget, parent, context);
|
|
@@ -10716,19 +10724,19 @@ async function callConcat(value, args, budget, context) {
|
|
|
10716
10724
|
release();
|
|
10717
10725
|
}
|
|
10718
10726
|
}
|
|
10719
|
-
function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
|
|
10727
|
+
function callReplaceLikeMethod(value, methodName, args, budget, callClosure, useRegex, context) {
|
|
10720
10728
|
const search = args[0];
|
|
10721
10729
|
const replacement = args[1];
|
|
10722
|
-
const
|
|
10723
|
-
if (!
|
|
10730
|
+
const regexSearch = useRegex && isSandboxRegex(search);
|
|
10731
|
+
if (!regexSearch && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
|
|
10724
10732
|
return (async () => {
|
|
10725
10733
|
let normalizedSearch;
|
|
10726
10734
|
let normalizedReplacement;
|
|
10727
10735
|
const release = retainValues(budget, () => [normalizedSearch, normalizedReplacement]);
|
|
10728
10736
|
try {
|
|
10729
|
-
normalizedSearch =
|
|
10737
|
+
normalizedSearch = regexSearch ? search : await sandboxString(search, budget, context);
|
|
10730
10738
|
normalizedReplacement = isSandboxClosure(replacement) ? replacement : await sandboxString(replacement, budget, context);
|
|
10731
|
-
return await callReplaceLikeMethod(value, methodName, [normalizedSearch, normalizedReplacement], budget, callClosure, context);
|
|
10739
|
+
return await callReplaceLikeMethod(value, methodName, [normalizedSearch, normalizedReplacement], budget, callClosure, useRegex, context);
|
|
10732
10740
|
} finally {
|
|
10733
10741
|
release();
|
|
10734
10742
|
}
|
|
@@ -10852,9 +10860,8 @@ function findReplacementOffsets(value, searchValue, replaceAll) {
|
|
|
10852
10860
|
}
|
|
10853
10861
|
return offsets;
|
|
10854
10862
|
}
|
|
10855
|
-
function callSplit(value, args, budget, parent, context) {
|
|
10863
|
+
function callSplit(value, args, budget, useRegex, parent, context) {
|
|
10856
10864
|
const pattern = args[0];
|
|
10857
|
-
const useRegex = isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, Symbol.split, budget) === void 0;
|
|
10858
10865
|
let separator;
|
|
10859
10866
|
const release = retainValues(budget, () => [value, ...args, separator]);
|
|
10860
10867
|
const withLimit = (number) => {
|
|
@@ -18942,7 +18949,7 @@ function conversionHook(value, name, budget, context) {
|
|
|
18942
18949
|
let current = value;
|
|
18943
18950
|
let depth = 0;
|
|
18944
18951
|
while (current !== null) {
|
|
18945
|
-
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : current;
|
|
18952
|
+
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
|
|
18946
18953
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
|
|
18947
18954
|
if (descriptor !== void 0) {
|
|
18948
18955
|
return readPropertyDescriptor(descriptor, value, context);
|
|
@@ -36406,4 +36413,4 @@ export {
|
|
|
36406
36413
|
FileSnapshotBackend,
|
|
36407
36414
|
run
|
|
36408
36415
|
};
|
|
36409
|
-
//# sourceMappingURL=chunk-
|
|
36416
|
+
//# sourceMappingURL=chunk-7CBZ6QP7.js.map
|