@poe-platform/safe-js 0.1.183 → 0.1.184
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-VZNLY6BP.js → chunk-4XA4KLMD.js} +2 -2
- package/dist/safe-js/chunks/{chunk-7XAXYVOY.js → chunk-Q64VTJKF.js} +144 -33
- package/dist/safe-js/chunks/chunk-Q64VTJKF.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-7XAXYVOY.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-VZNLY6BP.js.map → chunk-4XA4KLMD.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-Q64VTJKF.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-4XA4KLMD.js.map
|
|
@@ -10832,6 +10832,8 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure, use
|
|
|
10832
10832
|
);
|
|
10833
10833
|
}
|
|
10834
10834
|
async function replaceRegex(value, regex, replacement, budget, callClosure, context) {
|
|
10835
|
+
if (["exec", "flags", ...Object.keys(regexFlagProperties)].some((key) => getSandboxPropertyDescriptor(regex, key, budget) !== void 0))
|
|
10836
|
+
return replaceObservableRegex(value, regex, replacement, budget, callClosure, context);
|
|
10835
10837
|
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
10836
10838
|
const cursor = regex.lastIndex;
|
|
10837
10839
|
let result = "";
|
|
@@ -10843,7 +10845,7 @@ async function replaceRegex(value, regex, replacement, budget, callClosure, cont
|
|
|
10843
10845
|
let copiedThrough = 0;
|
|
10844
10846
|
for (const match of matches) {
|
|
10845
10847
|
result += value.slice(copiedThrough, match.index);
|
|
10846
|
-
result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures, value, match.index) : await sandboxString(
|
|
10848
|
+
result += typeof replacement === "string" ? await expandReplacement(replacement, match.text, match.captures, value, match.index, budget, context) : await sandboxString(
|
|
10847
10849
|
await callClosure(replacement, [match.text, ...match.captures, match.index, value]),
|
|
10848
10850
|
budget,
|
|
10849
10851
|
context
|
|
@@ -10856,45 +10858,154 @@ async function replaceRegex(value, regex, replacement, budget, callClosure, cont
|
|
|
10856
10858
|
budget.setRetainedValues(retained, void 0);
|
|
10857
10859
|
}
|
|
10858
10860
|
}
|
|
10859
|
-
function
|
|
10861
|
+
function readReplacementProperty(target, key, budget, context) {
|
|
10862
|
+
if (context?.getProperty !== void 0) return context.getProperty(target, key);
|
|
10863
|
+
const descriptor = getSandboxPropertyDescriptor(target, key, budget);
|
|
10864
|
+
if (descriptor !== void 0) return readPropertyDescriptor(descriptor, target, context);
|
|
10865
|
+
return isSandboxRegex(target) ? getRegexMember(target, key, budget, context) : void 0;
|
|
10866
|
+
}
|
|
10867
|
+
async function replaceObservableRegex(value, regex, replacement, budget, callClosure, context) {
|
|
10868
|
+
const matches = [];
|
|
10869
|
+
let current;
|
|
10870
|
+
let field;
|
|
10871
|
+
let groups;
|
|
10872
|
+
let matched;
|
|
10873
|
+
let captures = [];
|
|
10860
10874
|
let result = "";
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10875
|
+
let flags;
|
|
10876
|
+
const release = retainValues(budget, () => [value, regex, replacement, matches, current, field, groups, matched, captures, result, flags]);
|
|
10877
|
+
try {
|
|
10878
|
+
field = await readReplacementProperty(regex, "flags", budget, context);
|
|
10879
|
+
flags = await sandboxString(field, budget, context);
|
|
10880
|
+
field = void 0;
|
|
10881
|
+
const global = flags.includes("g");
|
|
10882
|
+
const fullUnicode = flags.includes("u") || flags.includes("v");
|
|
10883
|
+
flags = void 0;
|
|
10884
|
+
if (global) regex.lastIndex = 0;
|
|
10885
|
+
while (true) {
|
|
10886
|
+
budget.visitNode();
|
|
10887
|
+
current = await regexExec(regex, value, budget, context);
|
|
10888
|
+
if (current === null) break;
|
|
10889
|
+
budget.allocateArrayLength(matches.length + 1);
|
|
10890
|
+
matches.push(current);
|
|
10891
|
+
if (!global) break;
|
|
10892
|
+
field = await readReplacementProperty(current, "0", budget, context);
|
|
10893
|
+
matched = await sandboxString(field, budget, context);
|
|
10894
|
+
field = void 0;
|
|
10895
|
+
if (matched.length === 0) {
|
|
10896
|
+
field = regex.lastIndex;
|
|
10897
|
+
const index = normalizeLastIndex(await sandboxNumber(field, budget, context));
|
|
10898
|
+
const point = fullUnicode ? value.codePointAt(index) : void 0;
|
|
10899
|
+
regex.lastIndex = index + (point !== void 0 && point > 65535 ? 2 : 1);
|
|
10900
|
+
field = void 0;
|
|
10901
|
+
}
|
|
10902
|
+
matched = void 0;
|
|
10903
|
+
current = void 0;
|
|
10866
10904
|
}
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10905
|
+
let copiedThrough = 0;
|
|
10906
|
+
for (current of matches) {
|
|
10907
|
+
field = await readReplacementProperty(current, "length", budget, context);
|
|
10908
|
+
const count = Math.max(normalizeLastIndex(await sandboxNumber(field, budget, context)) - 1, 0);
|
|
10909
|
+
field = await readReplacementProperty(current, "0", budget, context);
|
|
10910
|
+
matched = await sandboxString(field, budget, context);
|
|
10911
|
+
field = await readReplacementProperty(current, "index", budget, context);
|
|
10912
|
+
const number = await sandboxNumber(field, budget, context);
|
|
10913
|
+
const position = Math.min(Math.max(Number.isNaN(number) ? 0 : Math.trunc(number), 0), value.length);
|
|
10914
|
+
field = void 0;
|
|
10915
|
+
captures = [];
|
|
10916
|
+
budget.allocateArrayLength(count);
|
|
10917
|
+
for (let index = 1; index <= count; index++) {
|
|
10918
|
+
budget.visitNode();
|
|
10919
|
+
field = await readReplacementProperty(current, String(index), budget, context);
|
|
10920
|
+
captures.push(field === void 0 ? void 0 : await sandboxString(field, budget, context));
|
|
10921
|
+
field = void 0;
|
|
10922
|
+
}
|
|
10923
|
+
groups = await readReplacementProperty(current, "groups", budget, context);
|
|
10924
|
+
let text;
|
|
10925
|
+
if (typeof replacement === "string") {
|
|
10926
|
+
if (groups === null) throw new TypeError("Replacement groups cannot be null.");
|
|
10927
|
+
if (groups !== void 0 && typeof groups !== "object") {
|
|
10928
|
+
groups = createSandboxBox(groups);
|
|
10929
|
+
budget.chargeDataUsage(measureSandboxData([groups]));
|
|
10930
|
+
}
|
|
10931
|
+
text = await expandReplacement(replacement, matched, captures, value, position, budget, context, groups);
|
|
10932
|
+
} else {
|
|
10933
|
+
const args = [matched, ...captures, position, value];
|
|
10934
|
+
if (groups !== void 0) args.push(groups);
|
|
10935
|
+
budget.allocateArrayLength(args.length);
|
|
10936
|
+
field = await callClosure(replacement, args);
|
|
10937
|
+
text = await sandboxString(field, budget, context);
|
|
10938
|
+
field = void 0;
|
|
10939
|
+
}
|
|
10940
|
+
if (position >= copiedThrough) {
|
|
10941
|
+
result = budget.allocateString(result + value.slice(copiedThrough, position) + text);
|
|
10942
|
+
copiedThrough = position + matched.length;
|
|
10885
10943
|
}
|
|
10886
|
-
|
|
10944
|
+
matched = void 0;
|
|
10945
|
+
captures = [];
|
|
10946
|
+
groups = void 0;
|
|
10947
|
+
}
|
|
10948
|
+
return budget.allocateString(result + value.slice(copiedThrough));
|
|
10949
|
+
} finally {
|
|
10950
|
+
release();
|
|
10951
|
+
}
|
|
10952
|
+
}
|
|
10953
|
+
async function expandReplacement(replacement, match, captures, input, matchIndex, budget, context, groups) {
|
|
10954
|
+
let result = "";
|
|
10955
|
+
const release = retainValues(budget, () => [replacement, match, captures, input, groups, result]);
|
|
10956
|
+
try {
|
|
10957
|
+
for (let index = 0; index < replacement.length; index += 1) {
|
|
10958
|
+
budget.visitNode();
|
|
10959
|
+
budget.allocateString(result);
|
|
10960
|
+
const character = replacement.charAt(index);
|
|
10961
|
+
if (character !== "$") {
|
|
10962
|
+
result += character;
|
|
10963
|
+
continue;
|
|
10964
|
+
}
|
|
10965
|
+
const token = replacement.charAt(index + 1);
|
|
10966
|
+
if (token === "$") {
|
|
10967
|
+
result += "$";
|
|
10968
|
+
} else if (token === "&") {
|
|
10969
|
+
result += match;
|
|
10970
|
+
} else if (token === "`") {
|
|
10971
|
+
result += input.slice(0, matchIndex);
|
|
10972
|
+
} else if (token === "'") {
|
|
10973
|
+
result += input.slice(matchIndex + match.length);
|
|
10974
|
+
} else if (token === "<" && groups !== void 0) {
|
|
10975
|
+
const end = replacement.indexOf(">", index + 2);
|
|
10976
|
+
if (end === -1) {
|
|
10977
|
+
result += "$";
|
|
10978
|
+
continue;
|
|
10979
|
+
}
|
|
10980
|
+
const capture = await readReplacementProperty(groups, replacement.slice(index + 2, end), budget, context);
|
|
10981
|
+
if (capture !== void 0) result += await sandboxString(capture, budget, context);
|
|
10982
|
+
index = end;
|
|
10983
|
+
continue;
|
|
10984
|
+
} else if (token >= "0" && token <= "9") {
|
|
10985
|
+
let captureIndex = Number(token);
|
|
10986
|
+
const nextDigit = replacement.charAt(index + 2);
|
|
10987
|
+
if (nextDigit >= "0" && nextDigit <= "9") {
|
|
10988
|
+
const twoDigitIndex = Number(token + nextDigit);
|
|
10989
|
+
if (twoDigitIndex > 0 && twoDigitIndex <= captures.length) {
|
|
10990
|
+
captureIndex = twoDigitIndex;
|
|
10991
|
+
index += 1;
|
|
10992
|
+
}
|
|
10993
|
+
}
|
|
10994
|
+
if (captureIndex === 0 || captureIndex > captures.length) {
|
|
10995
|
+
result += "$";
|
|
10996
|
+
continue;
|
|
10997
|
+
}
|
|
10998
|
+
result += captures[captureIndex - 1] ?? "";
|
|
10999
|
+
} else {
|
|
10887
11000
|
result += "$";
|
|
10888
11001
|
continue;
|
|
10889
11002
|
}
|
|
10890
|
-
|
|
10891
|
-
} else {
|
|
10892
|
-
result += "$";
|
|
10893
|
-
continue;
|
|
11003
|
+
index += 1;
|
|
10894
11004
|
}
|
|
10895
|
-
|
|
11005
|
+
return budget.allocateString(result);
|
|
11006
|
+
} finally {
|
|
11007
|
+
release();
|
|
10896
11008
|
}
|
|
10897
|
-
return result;
|
|
10898
11009
|
}
|
|
10899
11010
|
async function replaceWithClosure(value, searchValue, replacer, replaceAll, budget, callClosure, context) {
|
|
10900
11011
|
const offsets = findReplacementOffsets(value, searchValue, replaceAll);
|
|
@@ -36575,4 +36686,4 @@ export {
|
|
|
36575
36686
|
FileSnapshotBackend,
|
|
36576
36687
|
run
|
|
36577
36688
|
};
|
|
36578
|
-
//# sourceMappingURL=chunk-
|
|
36689
|
+
//# sourceMappingURL=chunk-Q64VTJKF.js.map
|