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/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-N3CN2ACZ.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-H4O5OPM2.js.map
|
|
@@ -7623,7 +7623,7 @@ function validateTaggedValue(record2, path, state) {
|
|
|
7623
7623
|
case "undefined":
|
|
7624
7624
|
return;
|
|
7625
7625
|
case "number":
|
|
7626
|
-
if (!["-Infinity", "Infinity", "NaN"].includes(String(record2.value))) {
|
|
7626
|
+
if (!["-Infinity", "Infinity", "NaN", "-0"].includes(String(record2.value))) {
|
|
7627
7627
|
fail("invalidValue", `${path}.value`, "unknown non-finite number value");
|
|
7628
7628
|
}
|
|
7629
7629
|
return;
|
|
@@ -7645,6 +7645,11 @@ function validateTaggedValue(record2, path, state) {
|
|
|
7645
7645
|
requireString(record2.flags, `${path}.flags`, state.limits);
|
|
7646
7646
|
requireSafeInteger(record2.lastIndex, `${path}.lastIndex`, 0);
|
|
7647
7647
|
return;
|
|
7648
|
+
case "regex-object":
|
|
7649
|
+
requireString(record2.source, `${path}.source`, state.limits);
|
|
7650
|
+
requireString(record2.flags, `${path}.flags`, state.limits);
|
|
7651
|
+
if (!Object.hasOwn(record2, "lastIndex")) fail("invalidValue", `${path}.lastIndex`, "missing regex cursor");
|
|
7652
|
+
return;
|
|
7648
7653
|
case "array":
|
|
7649
7654
|
case "arguments":
|
|
7650
7655
|
case "object":
|
|
@@ -8472,10 +8477,10 @@ function charge(context) {
|
|
|
8472
8477
|
allocateRegexSteps(context.steps);
|
|
8473
8478
|
}
|
|
8474
8479
|
function normalizeLastIndex(lastIndex) {
|
|
8475
|
-
if (
|
|
8480
|
+
if (Number.isNaN(lastIndex) || lastIndex <= 0) {
|
|
8476
8481
|
return 0;
|
|
8477
8482
|
}
|
|
8478
|
-
return Math.floor(lastIndex);
|
|
8483
|
+
return Math.min(Math.floor(lastIndex), Number.MAX_SAFE_INTEGER);
|
|
8479
8484
|
}
|
|
8480
8485
|
function charactersEqual(left, right, ignoreCase) {
|
|
8481
8486
|
return left !== void 0 && foldCharacter(left, ignoreCase) === foldCharacter(right, ignoreCase);
|
|
@@ -8508,6 +8513,16 @@ function isLineTerminator(character) {
|
|
|
8508
8513
|
|
|
8509
8514
|
// packages/safe-js/src/interp/methods/regex.ts
|
|
8510
8515
|
var regexMethodNames = /* @__PURE__ */ new Set(["exec", "test"]);
|
|
8516
|
+
var regexFlagProperties = {
|
|
8517
|
+
hasIndices: "d",
|
|
8518
|
+
global: "g",
|
|
8519
|
+
ignoreCase: "i",
|
|
8520
|
+
multiline: "m",
|
|
8521
|
+
dotAll: "s",
|
|
8522
|
+
unicode: "u",
|
|
8523
|
+
unicodeSets: "v",
|
|
8524
|
+
sticky: "y"
|
|
8525
|
+
};
|
|
8511
8526
|
function isRegexMethodName(property) {
|
|
8512
8527
|
return typeof property === "string" && regexMethodNames.has(property);
|
|
8513
8528
|
}
|
|
@@ -8518,6 +8533,7 @@ function getRegexMember(target, property, budget) {
|
|
|
8518
8533
|
return budget === void 0 ? flags : budget.allocateString(flags);
|
|
8519
8534
|
}
|
|
8520
8535
|
if (property === "lastIndex") return target.lastIndex;
|
|
8536
|
+
if (Object.hasOwn(regexFlagProperties, property)) return target.flags.includes(regexFlagProperties[property]);
|
|
8521
8537
|
if (!isRegexMethodName(property)) {
|
|
8522
8538
|
return void 0;
|
|
8523
8539
|
}
|
|
@@ -8552,14 +8568,16 @@ function setRegexMember(target, property, value) {
|
|
|
8552
8568
|
if (property !== "lastIndex") {
|
|
8553
8569
|
throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
8554
8570
|
}
|
|
8555
|
-
target.lastIndex =
|
|
8571
|
+
target.lastIndex = value;
|
|
8556
8572
|
}
|
|
8557
8573
|
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
8558
8574
|
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
8559
8575
|
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
8560
8576
|
}
|
|
8561
8577
|
const retained = {};
|
|
8562
|
-
|
|
8578
|
+
let cursor;
|
|
8579
|
+
let convertedInput;
|
|
8580
|
+
budget.setRetainedValues(retained, () => [target, ...args, cursor, convertedInput]);
|
|
8563
8581
|
try {
|
|
8564
8582
|
const input = await sandboxString(args[0], budget, context);
|
|
8565
8583
|
if (methodName === "test") {
|
|
@@ -8573,15 +8591,18 @@ async function callRegexMethod(target, methodName, args, budget, context) {
|
|
|
8573
8591
|
}
|
|
8574
8592
|
}
|
|
8575
8593
|
if (!isSandboxRegex(target)) throw new TypeError("RegExp execution requires a regex receiver.");
|
|
8576
|
-
|
|
8594
|
+
if (typeof args[0] !== "string") convertedInput = input;
|
|
8595
|
+
cursor = target.lastIndex;
|
|
8596
|
+
const lastIndex = await sandboxNumber(cursor, budget, context);
|
|
8597
|
+
const match = executeRegex(target, input, lastIndex);
|
|
8577
8598
|
return methodName === "test" ? match !== null : toMatchArray(match, input);
|
|
8578
8599
|
} finally {
|
|
8579
8600
|
budget.setRetainedValues(retained, void 0);
|
|
8580
8601
|
}
|
|
8581
8602
|
}
|
|
8582
|
-
function executeRegex(target, input) {
|
|
8603
|
+
function executeRegex(target, input, lastIndex) {
|
|
8583
8604
|
const pattern = getSandboxRegexPattern(target);
|
|
8584
|
-
const match = matchRegex(pattern, input,
|
|
8605
|
+
const match = matchRegex(pattern, input, lastIndex);
|
|
8585
8606
|
if (pattern.flags.global) {
|
|
8586
8607
|
target.lastIndex = match === null ? 0 : match.index + match.text.length;
|
|
8587
8608
|
}
|
|
@@ -10505,13 +10526,14 @@ function deepCopyToSandbox(value) {
|
|
|
10505
10526
|
seen: /* @__PURE__ */ new WeakMap()
|
|
10506
10527
|
});
|
|
10507
10528
|
}
|
|
10508
|
-
function cloneSandboxValue(value) {
|
|
10529
|
+
function cloneSandboxValue(value, options = {}) {
|
|
10509
10530
|
const initializeIterators = [];
|
|
10510
10531
|
const copy = copyToSandbox(
|
|
10511
10532
|
value,
|
|
10512
10533
|
{
|
|
10513
10534
|
seen: /* @__PURE__ */ new WeakMap(),
|
|
10514
|
-
initializeIterators
|
|
10535
|
+
initializeIterators,
|
|
10536
|
+
...options
|
|
10515
10537
|
},
|
|
10516
10538
|
"<root>",
|
|
10517
10539
|
true
|
|
@@ -10610,11 +10632,12 @@ function measureSandboxData(values, options = {}) {
|
|
|
10610
10632
|
}
|
|
10611
10633
|
if (isSandboxPromise(value)) return;
|
|
10612
10634
|
if (isSandboxRegex(value)) {
|
|
10613
|
-
const { source, flags } = captureRegexData(value);
|
|
10635
|
+
const { source, flags, lastIndex } = captureRegexData(value);
|
|
10614
10636
|
const compiled = regexCompiledData(getSandboxRegexPattern(value));
|
|
10615
10637
|
const staged = compiled.ticket === void 0 ? 0 : compiled.ticket.owner.budget.compileTicketUsage(compiled.ticket);
|
|
10616
10638
|
usage += Math.max(6 + source.length + flags.length + compiled.units, staged - 1);
|
|
10617
10639
|
if (compiled.ticket !== void 0) options.compileTickets?.add(compiled.ticket);
|
|
10640
|
+
visit(lastIndex, depth + 1);
|
|
10618
10641
|
return;
|
|
10619
10642
|
}
|
|
10620
10643
|
if (isSandboxArguments(value)) {
|
|
@@ -10695,7 +10718,16 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
10695
10718
|
return value;
|
|
10696
10719
|
}
|
|
10697
10720
|
if (isLiveCapability(value)) throw new TypeError("Live capabilities require their owning realm bridge.");
|
|
10698
|
-
if (
|
|
10721
|
+
if (isSandboxRegex(value)) {
|
|
10722
|
+
if (!cloneSandboxCollections) return value;
|
|
10723
|
+
const existing = state.seen.get(value);
|
|
10724
|
+
if (existing !== void 0) return existing;
|
|
10725
|
+
const copy = createSandboxRegex(value.source, value.flags, 0, state.compilation);
|
|
10726
|
+
state.seen.set(value, copy);
|
|
10727
|
+
if (!state.resetRegexLastIndex) copy.lastIndex = copyToSandbox(value.lastIndex, state, `${path}.lastIndex`, true, depth + 1);
|
|
10728
|
+
return copy;
|
|
10729
|
+
}
|
|
10730
|
+
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxPromise(value)) {
|
|
10699
10731
|
return value;
|
|
10700
10732
|
}
|
|
10701
10733
|
if (isSandboxCollectionIterator(value)) {
|
|
@@ -10904,9 +10936,9 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
10904
10936
|
if (existing !== void 0) return existing;
|
|
10905
10937
|
guard.allocate(1 + source.length + flags.length);
|
|
10906
10938
|
const regex = new RegExp(source, flags);
|
|
10907
|
-
regex.lastIndex = lastIndex;
|
|
10908
|
-
guard.retainScratch();
|
|
10909
10939
|
state.seen.set(value, regex);
|
|
10940
|
+
Reflect.set(regex, "lastIndex", copyFromSandbox(lastIndex, state, `${path}.lastIndex`, options, depth + 1));
|
|
10941
|
+
guard.retainScratch();
|
|
10910
10942
|
return regex;
|
|
10911
10943
|
} finally {
|
|
10912
10944
|
guard.close();
|
|
@@ -11293,7 +11325,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
11293
11325
|
kind: "regex",
|
|
11294
11326
|
source: entry.source,
|
|
11295
11327
|
flags: entry.flags,
|
|
11296
|
-
lastIndex: entry.lastIndex
|
|
11328
|
+
lastIndex: child(entry.lastIndex, "lastIndex")
|
|
11297
11329
|
};
|
|
11298
11330
|
} else if (isSandboxArguments(entry)) {
|
|
11299
11331
|
nodes[id] = { kind: "arguments", data: serializeArguments(entry, child) };
|
|
@@ -11460,11 +11492,12 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
11460
11492
|
return result3;
|
|
11461
11493
|
}
|
|
11462
11494
|
if (kind === "regex") {
|
|
11463
|
-
if (typeof node.source !== "string" || typeof node.flags !== "string" ||
|
|
11495
|
+
if (typeof node.source !== "string" || typeof node.flags !== "string" || !Object.hasOwn(node, "lastIndex")) {
|
|
11464
11496
|
throw new TypeError("Invalid replay regular expression.");
|
|
11465
11497
|
}
|
|
11466
|
-
const result3 = createSandboxRegex(node.source, node.flags,
|
|
11498
|
+
const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
|
|
11467
11499
|
restored.set(id, result3);
|
|
11500
|
+
result3.lastIndex = child(own(node, "lastIndex"));
|
|
11468
11501
|
return result3;
|
|
11469
11502
|
}
|
|
11470
11503
|
if (kind === "arguments") {
|
|
@@ -25029,7 +25062,11 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
25029
25062
|
return budget.allocateString(result + value.slice(spanStart));
|
|
25030
25063
|
}
|
|
25031
25064
|
if (methodName === "replace" || methodName === "replaceAll") {
|
|
25032
|
-
return callReplaceLikeMethod(value, methodName, args, budget, callClosure);
|
|
25065
|
+
return callReplaceLikeMethod(value, methodName, args, budget, callClosure, context);
|
|
25066
|
+
}
|
|
25067
|
+
const regex = args[0];
|
|
25068
|
+
if (isSandboxRegex(regex) && regex.lastIndex !== null && typeof regex.lastIndex === "object" && (methodName === "match" && !regex.flags.includes("g") || methodName === "matchAll" && regex.flags.includes("g"))) {
|
|
25069
|
+
return callStringRegexCursor(value, methodName, regex, budget, parent, context);
|
|
25033
25070
|
}
|
|
25034
25071
|
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
25035
25072
|
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
@@ -25144,7 +25181,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
25144
25181
|
operation.release();
|
|
25145
25182
|
}
|
|
25146
25183
|
}
|
|
25147
|
-
function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
25184
|
+
function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
|
|
25148
25185
|
const search = args[0];
|
|
25149
25186
|
const replacement = args[1];
|
|
25150
25187
|
if (!isSandboxRegex(search) && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
|
|
@@ -25162,7 +25199,8 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
25162
25199
|
replacement,
|
|
25163
25200
|
methodName === "replaceAll",
|
|
25164
25201
|
budget,
|
|
25165
|
-
callClosure
|
|
25202
|
+
callClosure,
|
|
25203
|
+
context
|
|
25166
25204
|
);
|
|
25167
25205
|
}
|
|
25168
25206
|
if (typeof replacement === "string") {
|
|
@@ -25179,20 +25217,28 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
25179
25217
|
callClosure
|
|
25180
25218
|
);
|
|
25181
25219
|
}
|
|
25182
|
-
async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure) {
|
|
25220
|
+
async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure, context) {
|
|
25183
25221
|
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
25184
|
-
const
|
|
25185
|
-
|
|
25186
|
-
|
|
25187
|
-
|
|
25188
|
-
|
|
25189
|
-
|
|
25190
|
-
|
|
25191
|
-
|
|
25192
|
-
|
|
25222
|
+
const cursor = regex.lastIndex;
|
|
25223
|
+
const retained = {};
|
|
25224
|
+
budget.setRetainedValues(retained, () => [value, regex, cursor, replacement]);
|
|
25225
|
+
try {
|
|
25226
|
+
const lastIndex = await sandboxNumber(cursor, budget, context);
|
|
25227
|
+
const matches = collectRegexMatches(regex, value, replaceAll || regex.flags.includes("g"), void 0, lastIndex);
|
|
25228
|
+
let result = "";
|
|
25229
|
+
let copiedThrough = 0;
|
|
25230
|
+
for (const match of matches) {
|
|
25231
|
+
result += value.slice(copiedThrough, match.index);
|
|
25232
|
+
result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures, value, match.index) : String(
|
|
25233
|
+
await callClosure(replacement, [match.text, ...match.captures, match.index, value])
|
|
25234
|
+
);
|
|
25235
|
+
copiedThrough = match.index + match.text.length;
|
|
25236
|
+
}
|
|
25237
|
+
result += value.slice(copiedThrough);
|
|
25238
|
+
return budget.allocateString(result);
|
|
25239
|
+
} finally {
|
|
25240
|
+
budget.setRetainedValues(retained, void 0);
|
|
25193
25241
|
}
|
|
25194
|
-
result += value.slice(copiedThrough);
|
|
25195
|
-
return budget.allocateString(result);
|
|
25196
25242
|
}
|
|
25197
25243
|
function expandReplacement(replacement, match, captures, input, matchIndex) {
|
|
25198
25244
|
let result = "";
|
|
@@ -25308,7 +25354,7 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
25308
25354
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25309
25355
|
const compilation = new CompileScope(operation.owner);
|
|
25310
25356
|
const retainedPattern = {};
|
|
25311
|
-
budget.setRetainedValues(retainedPattern, () => [pattern]);
|
|
25357
|
+
budget.setRetainedValues(retainedPattern, () => [value, pattern]);
|
|
25312
25358
|
try {
|
|
25313
25359
|
const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
|
|
25314
25360
|
const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
|
|
@@ -25319,35 +25365,51 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
25319
25365
|
operation.release();
|
|
25320
25366
|
}
|
|
25321
25367
|
}
|
|
25322
|
-
function
|
|
25368
|
+
async function callStringRegexCursor(value, methodName, regex, budget, parent, context) {
|
|
25369
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25370
|
+
const compilation = new CompileScope(operation.owner);
|
|
25371
|
+
const cursor = regex.lastIndex;
|
|
25372
|
+
const retained = {};
|
|
25373
|
+
budget.setRetainedValues(retained, () => [value, regex, cursor]);
|
|
25374
|
+
try {
|
|
25375
|
+
const lastIndex = await sandboxNumber(cursor, budget, context);
|
|
25376
|
+
return callMatchLikeMethod(value, methodName, [regex], compilation, lastIndex);
|
|
25377
|
+
} finally {
|
|
25378
|
+
budget.setRetainedValues(retained, void 0);
|
|
25379
|
+
compilation.dispose();
|
|
25380
|
+
operation.release();
|
|
25381
|
+
}
|
|
25382
|
+
}
|
|
25383
|
+
function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
|
|
25323
25384
|
const regex = args[0];
|
|
25324
25385
|
if (!isSandboxRegex(regex))
|
|
25325
25386
|
throw new TypeError(`String#${methodName} requires a regex argument.`);
|
|
25326
25387
|
if (methodName === "search") {
|
|
25327
|
-
const
|
|
25328
|
-
if (!Object.is(
|
|
25329
|
-
const match = executeRegex(regex, value);
|
|
25330
|
-
if (!Object.is(regex.lastIndex,
|
|
25388
|
+
const lastIndex2 = regex.lastIndex;
|
|
25389
|
+
if (!Object.is(lastIndex2, 0)) regex.lastIndex = 0;
|
|
25390
|
+
const match = executeRegex(regex, value, 0);
|
|
25391
|
+
if (!Object.is(regex.lastIndex, lastIndex2)) regex.lastIndex = lastIndex2;
|
|
25331
25392
|
return match?.index ?? -1;
|
|
25332
25393
|
}
|
|
25333
25394
|
if (methodName === "matchAll" && !regex.flags.includes("g"))
|
|
25334
25395
|
throw new TypeError("String#matchAll requires a global regex.");
|
|
25335
25396
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
25336
|
-
return toMatchArray(executeRegex(regex, value), value);
|
|
25397
|
+
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
|
|
25337
25398
|
if (methodName === "match") regex.lastIndex = 0;
|
|
25338
|
-
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
|
|
25339
|
-
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget);
|
|
25399
|
+
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, normalizeLastIndex(lastIndex ?? Number(regex.lastIndex)), compilation) : regex;
|
|
25400
|
+
const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget, Number(matcher.lastIndex));
|
|
25340
25401
|
if (methodName === "match" && matches.length === 0) return null;
|
|
25341
25402
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
25342
25403
|
}
|
|
25343
|
-
function collectRegexMatches(regex, value, all, budget) {
|
|
25404
|
+
function collectRegexMatches(regex, value, all, budget, lastIndex = 0) {
|
|
25344
25405
|
const matches = [];
|
|
25345
25406
|
do {
|
|
25346
|
-
const match = executeRegex(regex, value);
|
|
25407
|
+
const match = executeRegex(regex, value, lastIndex);
|
|
25347
25408
|
if (match === null) break;
|
|
25348
25409
|
budget?.allocateArrayLength(matches.length + 1);
|
|
25349
25410
|
matches.push(match);
|
|
25350
|
-
|
|
25411
|
+
lastIndex = match.index + match.text.length;
|
|
25412
|
+
if (all && match.text.length === 0) regex.lastIndex = ++lastIndex;
|
|
25351
25413
|
} while (all);
|
|
25352
25414
|
return matches;
|
|
25353
25415
|
}
|
|
@@ -30678,7 +30740,7 @@ function createMiscGlobals(options) {
|
|
|
30678
30740
|
return {
|
|
30679
30741
|
structuredClone: createSandboxClosure({
|
|
30680
30742
|
sandbox: true,
|
|
30681
|
-
call: ([value]) => structuredCloneSandboxValue(value, options.budget),
|
|
30743
|
+
call: ([value], context) => structuredCloneSandboxValue(value, options.budget, context?.compilation),
|
|
30682
30744
|
name: "structuredClone"
|
|
30683
30745
|
}),
|
|
30684
30746
|
parseInt: createSandboxClosure({
|
|
@@ -30703,11 +30765,20 @@ function createMiscGlobals(options) {
|
|
|
30703
30765
|
})
|
|
30704
30766
|
};
|
|
30705
30767
|
}
|
|
30706
|
-
function structuredCloneSandboxValue(value, budget) {
|
|
30707
|
-
|
|
30708
|
-
const
|
|
30709
|
-
|
|
30710
|
-
|
|
30768
|
+
function structuredCloneSandboxValue(value, budget, parent) {
|
|
30769
|
+
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
30770
|
+
const compilation = parent?.owner === operation.owner ? parent : new CompileScope(operation.owner);
|
|
30771
|
+
try {
|
|
30772
|
+
const clone = cloneSandboxValue(value, { compilation, resetRegexLastIndex: true });
|
|
30773
|
+
assertSandboxGraphDepth(clone);
|
|
30774
|
+
assertStructuredCloneable(clone, /* @__PURE__ */ new WeakSet());
|
|
30775
|
+
allocateProducedSandboxValue(clone, budget);
|
|
30776
|
+
if (compilation !== parent) reconcileCompiledValues(budget, [clone], compilation);
|
|
30777
|
+
return clone;
|
|
30778
|
+
} finally {
|
|
30779
|
+
if (compilation !== parent) compilation.dispose();
|
|
30780
|
+
operation.release();
|
|
30781
|
+
}
|
|
30711
30782
|
}
|
|
30712
30783
|
function assertStructuredCloneable(value, seen) {
|
|
30713
30784
|
if (isSandboxClosure(value) || isSandboxPromise(value) || isSandboxCollectionIterator(value)) {
|
|
@@ -33349,4 +33420,4 @@ export {
|
|
|
33349
33420
|
FileSnapshotBackend,
|
|
33350
33421
|
run
|
|
33351
33422
|
};
|
|
33352
|
-
//# sourceMappingURL=chunk-
|
|
33423
|
+
//# sourceMappingURL=chunk-N3CN2ACZ.js.map
|