poe-code 14.0.56 → 14.0.57
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/index.js +124 -51
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-SRYQTOX4.js → chunk-H4O5OPM2.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-XI33TU4X.js → chunk-N3CN2ACZ.js} +122 -51
- package/packages/safe-js/dist/chunks/chunk-N3CN2ACZ.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/globals/misc.js +20 -7
- package/packages/safe-js/dist/interp/methods/regex.d.ts +1 -1
- package/packages/safe-js/dist/interp/methods/regex.js +18 -6
- package/packages/safe-js/dist/interp/methods/string.js +59 -26
- package/packages/safe-js/dist/interp/regex/engine.d.ts +1 -0
- package/packages/safe-js/dist/interp/regex/engine.js +3 -3
- package/packages/safe-js/dist/interp/values.d.ts +6 -3
- package/packages/safe-js/dist/interp/values.js +19 -6
- package/packages/safe-js/dist/snapshot/replay-data.d.ts +1 -1
- package/packages/safe-js/dist/snapshot/replay-data.js +4 -4
- package/packages/safe-js/dist/snapshot/restore.js +8 -0
- package/packages/safe-js/dist/snapshot/serialize.d.ts +6 -1
- package/packages/safe-js/dist/snapshot/serialize.js +14 -1
- package/packages/safe-js/dist/snapshot/validation.js +8 -2
- package/packages/safe-js/dist/chunks/chunk-XI33TU4X.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-SRYQTOX4.js.map → chunk-H4O5OPM2.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -127268,7 +127268,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
127268
127268
|
kind: "regex",
|
|
127269
127269
|
source: entry.source,
|
|
127270
127270
|
flags: entry.flags,
|
|
127271
|
-
lastIndex: entry.lastIndex
|
|
127271
|
+
lastIndex: child(entry.lastIndex, "lastIndex")
|
|
127272
127272
|
};
|
|
127273
127273
|
} else if (isSandboxArguments(entry)) {
|
|
127274
127274
|
nodes[id] = { kind: "arguments", data: serializeArguments(entry, child) };
|
|
@@ -127435,11 +127435,12 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
127435
127435
|
return result3;
|
|
127436
127436
|
}
|
|
127437
127437
|
if (kind === "regex") {
|
|
127438
|
-
if (typeof node.source !== "string" || typeof node.flags !== "string" ||
|
|
127438
|
+
if (typeof node.source !== "string" || typeof node.flags !== "string" || !Object.hasOwn(node, "lastIndex")) {
|
|
127439
127439
|
throw new TypeError("Invalid replay regular expression.");
|
|
127440
127440
|
}
|
|
127441
|
-
const result3 = createSandboxRegex(node.source, node.flags,
|
|
127441
|
+
const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
|
|
127442
127442
|
restored.set(id, result3);
|
|
127443
|
+
result3.lastIndex = child(own(node, "lastIndex"));
|
|
127443
127444
|
return result3;
|
|
127444
127445
|
}
|
|
127445
127446
|
if (kind === "arguments") {
|
|
@@ -128445,10 +128446,10 @@ function charge(context) {
|
|
|
128445
128446
|
allocateRegexSteps(context.steps);
|
|
128446
128447
|
}
|
|
128447
128448
|
function normalizeLastIndex(lastIndex) {
|
|
128448
|
-
if (
|
|
128449
|
+
if (Number.isNaN(lastIndex) || lastIndex <= 0) {
|
|
128449
128450
|
return 0;
|
|
128450
128451
|
}
|
|
128451
|
-
return Math.floor(lastIndex);
|
|
128452
|
+
return Math.min(Math.floor(lastIndex), Number.MAX_SAFE_INTEGER);
|
|
128452
128453
|
}
|
|
128453
128454
|
function charactersEqual(left, right, ignoreCase) {
|
|
128454
128455
|
return left !== void 0 && foldCharacter(left, ignoreCase) === foldCharacter(right, ignoreCase);
|
|
@@ -128496,6 +128497,7 @@ function getRegexMember(target, property, budget) {
|
|
|
128496
128497
|
return budget === void 0 ? flags : budget.allocateString(flags);
|
|
128497
128498
|
}
|
|
128498
128499
|
if (property === "lastIndex") return target.lastIndex;
|
|
128500
|
+
if (Object.hasOwn(regexFlagProperties, property)) return target.flags.includes(regexFlagProperties[property]);
|
|
128499
128501
|
if (!isRegexMethodName(property)) {
|
|
128500
128502
|
return void 0;
|
|
128501
128503
|
}
|
|
@@ -128530,14 +128532,16 @@ function setRegexMember(target, property, value) {
|
|
|
128530
128532
|
if (property !== "lastIndex") {
|
|
128531
128533
|
throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
128532
128534
|
}
|
|
128533
|
-
target.lastIndex =
|
|
128535
|
+
target.lastIndex = value;
|
|
128534
128536
|
}
|
|
128535
128537
|
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
128536
128538
|
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
128537
128539
|
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
128538
128540
|
}
|
|
128539
128541
|
const retained = {};
|
|
128540
|
-
|
|
128542
|
+
let cursor2;
|
|
128543
|
+
let convertedInput;
|
|
128544
|
+
budget.setRetainedValues(retained, () => [target, ...args, cursor2, convertedInput]);
|
|
128541
128545
|
try {
|
|
128542
128546
|
const input = await sandboxString(args[0], budget, context);
|
|
128543
128547
|
if (methodName === "test") {
|
|
@@ -128551,15 +128555,18 @@ async function callRegexMethod(target, methodName, args, budget, context) {
|
|
|
128551
128555
|
}
|
|
128552
128556
|
}
|
|
128553
128557
|
if (!isSandboxRegex(target)) throw new TypeError("RegExp execution requires a regex receiver.");
|
|
128554
|
-
|
|
128558
|
+
if (typeof args[0] !== "string") convertedInput = input;
|
|
128559
|
+
cursor2 = target.lastIndex;
|
|
128560
|
+
const lastIndex = await sandboxNumber(cursor2, budget, context);
|
|
128561
|
+
const match = executeRegex(target, input, lastIndex);
|
|
128555
128562
|
return methodName === "test" ? match !== null : toMatchArray(match, input);
|
|
128556
128563
|
} finally {
|
|
128557
128564
|
budget.setRetainedValues(retained, void 0);
|
|
128558
128565
|
}
|
|
128559
128566
|
}
|
|
128560
|
-
function executeRegex(target, input) {
|
|
128567
|
+
function executeRegex(target, input, lastIndex) {
|
|
128561
128568
|
const pattern = getSandboxRegexPattern(target);
|
|
128562
|
-
const match = matchRegex(pattern, input,
|
|
128569
|
+
const match = matchRegex(pattern, input, lastIndex);
|
|
128563
128570
|
if (pattern.flags.global) {
|
|
128564
128571
|
target.lastIndex = match === null ? 0 : match.index + match.text.length;
|
|
128565
128572
|
}
|
|
@@ -128573,7 +128580,7 @@ function toMatchArray(match, input) {
|
|
|
128573
128580
|
Object.assign(result, { index: match.index, input, groups: void 0 });
|
|
128574
128581
|
return result;
|
|
128575
128582
|
}
|
|
128576
|
-
var regexMethodNames;
|
|
128583
|
+
var regexMethodNames, regexFlagProperties;
|
|
128577
128584
|
var init_regex = __esm({
|
|
128578
128585
|
"packages/safe-js/src/interp/methods/regex.ts"() {
|
|
128579
128586
|
"use strict";
|
|
@@ -128583,6 +128590,16 @@ var init_regex = __esm({
|
|
|
128583
128590
|
init_object_model();
|
|
128584
128591
|
init_string_coercion();
|
|
128585
128592
|
regexMethodNames = /* @__PURE__ */ new Set(["exec", "test"]);
|
|
128593
|
+
regexFlagProperties = {
|
|
128594
|
+
hasIndices: "d",
|
|
128595
|
+
global: "g",
|
|
128596
|
+
ignoreCase: "i",
|
|
128597
|
+
multiline: "m",
|
|
128598
|
+
dotAll: "s",
|
|
128599
|
+
unicode: "u",
|
|
128600
|
+
unicodeSets: "v",
|
|
128601
|
+
sticky: "y"
|
|
128602
|
+
};
|
|
128586
128603
|
}
|
|
128587
128604
|
});
|
|
128588
128605
|
|
|
@@ -130573,13 +130590,14 @@ function deepCopyToSandbox(value) {
|
|
|
130573
130590
|
seen: /* @__PURE__ */ new WeakMap()
|
|
130574
130591
|
});
|
|
130575
130592
|
}
|
|
130576
|
-
function cloneSandboxValue(value) {
|
|
130593
|
+
function cloneSandboxValue(value, options = {}) {
|
|
130577
130594
|
const initializeIterators = [];
|
|
130578
130595
|
const copy = copyToSandbox(
|
|
130579
130596
|
value,
|
|
130580
130597
|
{
|
|
130581
130598
|
seen: /* @__PURE__ */ new WeakMap(),
|
|
130582
|
-
initializeIterators
|
|
130599
|
+
initializeIterators,
|
|
130600
|
+
...options
|
|
130583
130601
|
},
|
|
130584
130602
|
"<root>",
|
|
130585
130603
|
true
|
|
@@ -130678,11 +130696,12 @@ function measureSandboxData(values, options = {}) {
|
|
|
130678
130696
|
}
|
|
130679
130697
|
if (isSandboxPromise(value)) return;
|
|
130680
130698
|
if (isSandboxRegex(value)) {
|
|
130681
|
-
const { source, flags } = captureRegexData(value);
|
|
130699
|
+
const { source, flags, lastIndex } = captureRegexData(value);
|
|
130682
130700
|
const compiled = regexCompiledData(getSandboxRegexPattern(value));
|
|
130683
130701
|
const staged = compiled.ticket === void 0 ? 0 : compiled.ticket.owner.budget.compileTicketUsage(compiled.ticket);
|
|
130684
130702
|
usage += Math.max(6 + source.length + flags.length + compiled.units, staged - 1);
|
|
130685
130703
|
if (compiled.ticket !== void 0) options.compileTickets?.add(compiled.ticket);
|
|
130704
|
+
visit(lastIndex, depth + 1);
|
|
130686
130705
|
return;
|
|
130687
130706
|
}
|
|
130688
130707
|
if (isSandboxArguments(value)) {
|
|
@@ -130763,7 +130782,16 @@ function copyToSandbox(value, state, path193 = "<root>", cloneSandboxCollections
|
|
|
130763
130782
|
return value;
|
|
130764
130783
|
}
|
|
130765
130784
|
if (isLiveCapability(value)) throw new TypeError("Live capabilities require their owning realm bridge.");
|
|
130766
|
-
if (
|
|
130785
|
+
if (isSandboxRegex(value)) {
|
|
130786
|
+
if (!cloneSandboxCollections) return value;
|
|
130787
|
+
const existing = state.seen.get(value);
|
|
130788
|
+
if (existing !== void 0) return existing;
|
|
130789
|
+
const copy = createSandboxRegex(value.source, value.flags, 0, state.compilation);
|
|
130790
|
+
state.seen.set(value, copy);
|
|
130791
|
+
if (!state.resetRegexLastIndex) copy.lastIndex = copyToSandbox(value.lastIndex, state, `${path193}.lastIndex`, true, depth + 1);
|
|
130792
|
+
return copy;
|
|
130793
|
+
}
|
|
130794
|
+
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxPromise(value)) {
|
|
130767
130795
|
return value;
|
|
130768
130796
|
}
|
|
130769
130797
|
if (isSandboxCollectionIterator(value)) {
|
|
@@ -130972,9 +131000,9 @@ function copyFromSandbox(value, state, path193 = "<root>", options, depth = 0) {
|
|
|
130972
131000
|
if (existing !== void 0) return existing;
|
|
130973
131001
|
guard.allocate(1 + source.length + flags.length);
|
|
130974
131002
|
const regex = new RegExp(source, flags);
|
|
130975
|
-
regex.lastIndex = lastIndex;
|
|
130976
|
-
guard.retainScratch();
|
|
130977
131003
|
state.seen.set(value, regex);
|
|
131004
|
+
Reflect.set(regex, "lastIndex", copyFromSandbox(lastIndex, state, `${path193}.lastIndex`, options, depth + 1));
|
|
131005
|
+
guard.retainScratch();
|
|
130978
131006
|
return regex;
|
|
130979
131007
|
} finally {
|
|
130980
131008
|
guard.close();
|
|
@@ -131856,7 +131884,7 @@ function validateTaggedValue(record2, path193, state) {
|
|
|
131856
131884
|
case "undefined":
|
|
131857
131885
|
return;
|
|
131858
131886
|
case "number":
|
|
131859
|
-
if (!["-Infinity", "Infinity", "NaN"].includes(String(record2.value))) {
|
|
131887
|
+
if (!["-Infinity", "Infinity", "NaN", "-0"].includes(String(record2.value))) {
|
|
131860
131888
|
fail2("invalidValue", `${path193}.value`, "unknown non-finite number value");
|
|
131861
131889
|
}
|
|
131862
131890
|
return;
|
|
@@ -131878,6 +131906,11 @@ function validateTaggedValue(record2, path193, state) {
|
|
|
131878
131906
|
requireString2(record2.flags, `${path193}.flags`, state.limits);
|
|
131879
131907
|
requireSafeInteger(record2.lastIndex, `${path193}.lastIndex`, 0);
|
|
131880
131908
|
return;
|
|
131909
|
+
case "regex-object":
|
|
131910
|
+
requireString2(record2.source, `${path193}.source`, state.limits);
|
|
131911
|
+
requireString2(record2.flags, `${path193}.flags`, state.limits);
|
|
131912
|
+
if (!Object.hasOwn(record2, "lastIndex")) fail2("invalidValue", `${path193}.lastIndex`, "missing regex cursor");
|
|
131913
|
+
return;
|
|
131881
131914
|
case "array":
|
|
131882
131915
|
case "arguments":
|
|
131883
131916
|
case "object":
|
|
@@ -145250,7 +145283,11 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
145250
145283
|
return budget.allocateString(result + value.slice(spanStart));
|
|
145251
145284
|
}
|
|
145252
145285
|
if (methodName === "replace" || methodName === "replaceAll") {
|
|
145253
|
-
return callReplaceLikeMethod(value, methodName, args, budget, callClosure);
|
|
145286
|
+
return callReplaceLikeMethod(value, methodName, args, budget, callClosure, context);
|
|
145287
|
+
}
|
|
145288
|
+
const regex = args[0];
|
|
145289
|
+
if (isSandboxRegex(regex) && regex.lastIndex !== null && typeof regex.lastIndex === "object" && (methodName === "match" && !regex.flags.includes("g") || methodName === "matchAll" && regex.flags.includes("g"))) {
|
|
145290
|
+
return callStringRegexCursor(value, methodName, regex, budget, parent, context);
|
|
145254
145291
|
}
|
|
145255
145292
|
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
145256
145293
|
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
@@ -145365,7 +145402,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
145365
145402
|
operation.release();
|
|
145366
145403
|
}
|
|
145367
145404
|
}
|
|
145368
|
-
function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
145405
|
+
function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
|
|
145369
145406
|
const search = args[0];
|
|
145370
145407
|
const replacement = args[1];
|
|
145371
145408
|
if (!isSandboxRegex(search) && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
|
|
@@ -145383,7 +145420,8 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
145383
145420
|
replacement,
|
|
145384
145421
|
methodName === "replaceAll",
|
|
145385
145422
|
budget,
|
|
145386
|
-
callClosure
|
|
145423
|
+
callClosure,
|
|
145424
|
+
context
|
|
145387
145425
|
);
|
|
145388
145426
|
}
|
|
145389
145427
|
if (typeof replacement === "string") {
|
|
@@ -145400,20 +145438,28 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
145400
145438
|
callClosure
|
|
145401
145439
|
);
|
|
145402
145440
|
}
|
|
145403
|
-
async function replaceRegex(value, regex, replacement, replaceAll2, budget, callClosure) {
|
|
145441
|
+
async function replaceRegex(value, regex, replacement, replaceAll2, budget, callClosure, context) {
|
|
145404
145442
|
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
145405
|
-
const
|
|
145406
|
-
|
|
145407
|
-
|
|
145408
|
-
|
|
145409
|
-
|
|
145410
|
-
|
|
145411
|
-
|
|
145412
|
-
|
|
145413
|
-
|
|
145443
|
+
const cursor2 = regex.lastIndex;
|
|
145444
|
+
const retained = {};
|
|
145445
|
+
budget.setRetainedValues(retained, () => [value, regex, cursor2, replacement]);
|
|
145446
|
+
try {
|
|
145447
|
+
const lastIndex = await sandboxNumber(cursor2, budget, context);
|
|
145448
|
+
const matches = collectRegexMatches(regex, value, replaceAll2 || regex.flags.includes("g"), void 0, lastIndex);
|
|
145449
|
+
let result = "";
|
|
145450
|
+
let copiedThrough = 0;
|
|
145451
|
+
for (const match of matches) {
|
|
145452
|
+
result += value.slice(copiedThrough, match.index);
|
|
145453
|
+
result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures, value, match.index) : String(
|
|
145454
|
+
await callClosure(replacement, [match.text, ...match.captures, match.index, value])
|
|
145455
|
+
);
|
|
145456
|
+
copiedThrough = match.index + match.text.length;
|
|
145457
|
+
}
|
|
145458
|
+
result += value.slice(copiedThrough);
|
|
145459
|
+
return budget.allocateString(result);
|
|
145460
|
+
} finally {
|
|
145461
|
+
budget.setRetainedValues(retained, void 0);
|
|
145414
145462
|
}
|
|
145415
|
-
result += value.slice(copiedThrough);
|
|
145416
|
-
return budget.allocateString(result);
|
|
145417
145463
|
}
|
|
145418
145464
|
function expandReplacement(replacement, match, captures, input, matchIndex) {
|
|
145419
145465
|
let result = "";
|
|
@@ -145529,7 +145575,7 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
145529
145575
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
145530
145576
|
const compilation = new CompileScope(operation.owner);
|
|
145531
145577
|
const retainedPattern = {};
|
|
145532
|
-
budget.setRetainedValues(retainedPattern, () => [pattern]);
|
|
145578
|
+
budget.setRetainedValues(retainedPattern, () => [value, pattern]);
|
|
145533
145579
|
try {
|
|
145534
145580
|
const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
|
|
145535
145581
|
const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
|
|
@@ -145540,35 +145586,51 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
145540
145586
|
operation.release();
|
|
145541
145587
|
}
|
|
145542
145588
|
}
|
|
145543
|
-
function
|
|
145589
|
+
async function callStringRegexCursor(value, methodName, regex, budget, parent, context) {
|
|
145590
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
145591
|
+
const compilation = new CompileScope(operation.owner);
|
|
145592
|
+
const cursor2 = regex.lastIndex;
|
|
145593
|
+
const retained = {};
|
|
145594
|
+
budget.setRetainedValues(retained, () => [value, regex, cursor2]);
|
|
145595
|
+
try {
|
|
145596
|
+
const lastIndex = await sandboxNumber(cursor2, budget, context);
|
|
145597
|
+
return callMatchLikeMethod(value, methodName, [regex], compilation, lastIndex);
|
|
145598
|
+
} finally {
|
|
145599
|
+
budget.setRetainedValues(retained, void 0);
|
|
145600
|
+
compilation.dispose();
|
|
145601
|
+
operation.release();
|
|
145602
|
+
}
|
|
145603
|
+
}
|
|
145604
|
+
function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
|
|
145544
145605
|
const regex = args[0];
|
|
145545
145606
|
if (!isSandboxRegex(regex))
|
|
145546
145607
|
throw new TypeError(`String#${methodName} requires a regex argument.`);
|
|
145547
145608
|
if (methodName === "search") {
|
|
145548
|
-
const
|
|
145549
|
-
if (!Object.is(
|
|
145550
|
-
const match = executeRegex(regex, value);
|
|
145551
|
-
if (!Object.is(regex.lastIndex,
|
|
145609
|
+
const lastIndex2 = regex.lastIndex;
|
|
145610
|
+
if (!Object.is(lastIndex2, 0)) regex.lastIndex = 0;
|
|
145611
|
+
const match = executeRegex(regex, value, 0);
|
|
145612
|
+
if (!Object.is(regex.lastIndex, lastIndex2)) regex.lastIndex = lastIndex2;
|
|
145552
145613
|
return match?.index ?? -1;
|
|
145553
145614
|
}
|
|
145554
145615
|
if (methodName === "matchAll" && !regex.flags.includes("g"))
|
|
145555
145616
|
throw new TypeError("String#matchAll requires a global regex.");
|
|
145556
145617
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
145557
|
-
return toMatchArray(executeRegex(regex, value), value);
|
|
145618
|
+
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
|
|
145558
145619
|
if (methodName === "match") regex.lastIndex = 0;
|
|
145559
|
-
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
|
|
145560
|
-
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget);
|
|
145620
|
+
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, normalizeLastIndex(lastIndex ?? Number(regex.lastIndex)), compilation) : regex;
|
|
145621
|
+
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget, Number(matcher.lastIndex));
|
|
145561
145622
|
if (methodName === "match" && matches.length === 0) return null;
|
|
145562
145623
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
145563
145624
|
}
|
|
145564
|
-
function collectRegexMatches(regex, value, all, budget) {
|
|
145625
|
+
function collectRegexMatches(regex, value, all, budget, lastIndex = 0) {
|
|
145565
145626
|
const matches = [];
|
|
145566
145627
|
do {
|
|
145567
|
-
const match = executeRegex(regex, value);
|
|
145628
|
+
const match = executeRegex(regex, value, lastIndex);
|
|
145568
145629
|
if (match === null) break;
|
|
145569
145630
|
budget?.allocateArrayLength(matches.length + 1);
|
|
145570
145631
|
matches.push(match);
|
|
145571
|
-
|
|
145632
|
+
lastIndex = match.index + match.text.length;
|
|
145633
|
+
if (all && match.text.length === 0) regex.lastIndex = ++lastIndex;
|
|
145572
145634
|
} while (all);
|
|
145573
145635
|
return matches;
|
|
145574
145636
|
}
|
|
@@ -145591,6 +145653,7 @@ var init_string = __esm({
|
|
|
145591
145653
|
"use strict";
|
|
145592
145654
|
init_builtin_call();
|
|
145593
145655
|
init_compile_guard();
|
|
145656
|
+
init_engine2();
|
|
145594
145657
|
init_string_coercion();
|
|
145595
145658
|
init_values();
|
|
145596
145659
|
init_regex();
|
|
@@ -151112,7 +151175,7 @@ function createMiscGlobals(options) {
|
|
|
151112
151175
|
return {
|
|
151113
151176
|
structuredClone: createSandboxClosure({
|
|
151114
151177
|
sandbox: true,
|
|
151115
|
-
call: ([value]) => structuredCloneSandboxValue(value, options.budget),
|
|
151178
|
+
call: ([value], context) => structuredCloneSandboxValue(value, options.budget, context?.compilation),
|
|
151116
151179
|
name: "structuredClone"
|
|
151117
151180
|
}),
|
|
151118
151181
|
parseInt: createSandboxClosure({
|
|
@@ -151137,11 +151200,20 @@ function createMiscGlobals(options) {
|
|
|
151137
151200
|
})
|
|
151138
151201
|
};
|
|
151139
151202
|
}
|
|
151140
|
-
function structuredCloneSandboxValue(value, budget) {
|
|
151141
|
-
|
|
151142
|
-
const
|
|
151143
|
-
|
|
151144
|
-
|
|
151203
|
+
function structuredCloneSandboxValue(value, budget, parent) {
|
|
151204
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
151205
|
+
const compilation = parent?.owner === operation.owner ? parent : new CompileScope(operation.owner);
|
|
151206
|
+
try {
|
|
151207
|
+
const clone = cloneSandboxValue(value, { compilation, resetRegexLastIndex: true });
|
|
151208
|
+
assertSandboxGraphDepth(clone);
|
|
151209
|
+
assertStructuredCloneable(clone, /* @__PURE__ */ new WeakSet());
|
|
151210
|
+
allocateProducedSandboxValue(clone, budget);
|
|
151211
|
+
if (compilation !== parent) reconcileCompiledValues(budget, [clone], compilation);
|
|
151212
|
+
return clone;
|
|
151213
|
+
} finally {
|
|
151214
|
+
if (compilation !== parent) compilation.dispose();
|
|
151215
|
+
operation.release();
|
|
151216
|
+
}
|
|
151145
151217
|
}
|
|
151146
151218
|
function assertStructuredCloneable(value, seen) {
|
|
151147
151219
|
if (isSandboxClosure(value) || isSandboxPromise(value) || isSandboxCollectionIterator(value)) {
|
|
@@ -151173,6 +151245,7 @@ var init_misc = __esm({
|
|
|
151173
151245
|
"use strict";
|
|
151174
151246
|
init_collection_iterator();
|
|
151175
151247
|
init_graph_depth();
|
|
151248
|
+
init_compile_guard();
|
|
151176
151249
|
init_values();
|
|
151177
151250
|
}
|
|
151178
151251
|
});
|