poe-code 14.0.55 → 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 +150 -53
- 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-G5LQ37D4.js → chunk-H4O5OPM2.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-6LFWVA64.js → chunk-N3CN2ACZ.js} +145 -53
- 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 +4 -4
- package/packages/safe-js/dist/interp/methods/regex.js +47 -8
- 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-6LFWVA64.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-G5LQ37D4.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,13 +8533,14 @@ 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
|
}
|
|
8524
8540
|
return createSandboxClosure({
|
|
8525
8541
|
sandbox: true,
|
|
8526
8542
|
name: `RegExp#${property}`,
|
|
8527
|
-
call: (args) => callRegexMethod(
|
|
8543
|
+
call: (args, context) => callRegexMethod(context?.thisValue, property, args, budget, context)
|
|
8528
8544
|
});
|
|
8529
8545
|
}
|
|
8530
8546
|
function escapeRegexSource(source, budget) {
|
|
@@ -8552,15 +8568,41 @@ 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
|
-
function callRegexMethod(target, methodName, args) {
|
|
8558
|
-
|
|
8559
|
-
|
|
8573
|
+
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
8574
|
+
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
8575
|
+
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
8576
|
+
}
|
|
8577
|
+
const retained = {};
|
|
8578
|
+
let cursor;
|
|
8579
|
+
let convertedInput;
|
|
8580
|
+
budget.setRetainedValues(retained, () => [target, ...args, cursor, convertedInput]);
|
|
8581
|
+
try {
|
|
8582
|
+
const input = await sandboxString(args[0], budget, context);
|
|
8583
|
+
if (methodName === "test") {
|
|
8584
|
+
const exec = context?.getProperty === void 0 ? getSandboxDataProperty(target, "exec", budget) : context.getProperty(target, "exec");
|
|
8585
|
+
if (isSandboxClosure(exec)) {
|
|
8586
|
+
const result = await invokeBuiltinClosure(exec, [input], budget, context, target);
|
|
8587
|
+
if (result !== null && typeof result !== "object") {
|
|
8588
|
+
throw new TypeError("RegExp#test exec must return an object or null.");
|
|
8589
|
+
}
|
|
8590
|
+
return result !== null;
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
if (!isSandboxRegex(target)) throw new TypeError("RegExp execution requires a regex receiver.");
|
|
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);
|
|
8598
|
+
return methodName === "test" ? match !== null : toMatchArray(match, input);
|
|
8599
|
+
} finally {
|
|
8600
|
+
budget.setRetainedValues(retained, void 0);
|
|
8601
|
+
}
|
|
8560
8602
|
}
|
|
8561
|
-
function executeRegex(target, input) {
|
|
8603
|
+
function executeRegex(target, input, lastIndex) {
|
|
8562
8604
|
const pattern = getSandboxRegexPattern(target);
|
|
8563
|
-
const match = matchRegex(pattern, input,
|
|
8605
|
+
const match = matchRegex(pattern, input, lastIndex);
|
|
8564
8606
|
if (pattern.flags.global) {
|
|
8565
8607
|
target.lastIndex = match === null ? 0 : match.index + match.text.length;
|
|
8566
8608
|
}
|
|
@@ -10484,13 +10526,14 @@ function deepCopyToSandbox(value) {
|
|
|
10484
10526
|
seen: /* @__PURE__ */ new WeakMap()
|
|
10485
10527
|
});
|
|
10486
10528
|
}
|
|
10487
|
-
function cloneSandboxValue(value) {
|
|
10529
|
+
function cloneSandboxValue(value, options = {}) {
|
|
10488
10530
|
const initializeIterators = [];
|
|
10489
10531
|
const copy = copyToSandbox(
|
|
10490
10532
|
value,
|
|
10491
10533
|
{
|
|
10492
10534
|
seen: /* @__PURE__ */ new WeakMap(),
|
|
10493
|
-
initializeIterators
|
|
10535
|
+
initializeIterators,
|
|
10536
|
+
...options
|
|
10494
10537
|
},
|
|
10495
10538
|
"<root>",
|
|
10496
10539
|
true
|
|
@@ -10589,11 +10632,12 @@ function measureSandboxData(values, options = {}) {
|
|
|
10589
10632
|
}
|
|
10590
10633
|
if (isSandboxPromise(value)) return;
|
|
10591
10634
|
if (isSandboxRegex(value)) {
|
|
10592
|
-
const { source, flags } = captureRegexData(value);
|
|
10635
|
+
const { source, flags, lastIndex } = captureRegexData(value);
|
|
10593
10636
|
const compiled = regexCompiledData(getSandboxRegexPattern(value));
|
|
10594
10637
|
const staged = compiled.ticket === void 0 ? 0 : compiled.ticket.owner.budget.compileTicketUsage(compiled.ticket);
|
|
10595
10638
|
usage += Math.max(6 + source.length + flags.length + compiled.units, staged - 1);
|
|
10596
10639
|
if (compiled.ticket !== void 0) options.compileTickets?.add(compiled.ticket);
|
|
10640
|
+
visit(lastIndex, depth + 1);
|
|
10597
10641
|
return;
|
|
10598
10642
|
}
|
|
10599
10643
|
if (isSandboxArguments(value)) {
|
|
@@ -10674,7 +10718,16 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
10674
10718
|
return value;
|
|
10675
10719
|
}
|
|
10676
10720
|
if (isLiveCapability(value)) throw new TypeError("Live capabilities require their owning realm bridge.");
|
|
10677
|
-
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)) {
|
|
10678
10731
|
return value;
|
|
10679
10732
|
}
|
|
10680
10733
|
if (isSandboxCollectionIterator(value)) {
|
|
@@ -10883,9 +10936,9 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
10883
10936
|
if (existing !== void 0) return existing;
|
|
10884
10937
|
guard.allocate(1 + source.length + flags.length);
|
|
10885
10938
|
const regex = new RegExp(source, flags);
|
|
10886
|
-
regex.lastIndex = lastIndex;
|
|
10887
|
-
guard.retainScratch();
|
|
10888
10939
|
state.seen.set(value, regex);
|
|
10940
|
+
Reflect.set(regex, "lastIndex", copyFromSandbox(lastIndex, state, `${path}.lastIndex`, options, depth + 1));
|
|
10941
|
+
guard.retainScratch();
|
|
10889
10942
|
return regex;
|
|
10890
10943
|
} finally {
|
|
10891
10944
|
guard.close();
|
|
@@ -11272,7 +11325,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
11272
11325
|
kind: "regex",
|
|
11273
11326
|
source: entry.source,
|
|
11274
11327
|
flags: entry.flags,
|
|
11275
|
-
lastIndex: entry.lastIndex
|
|
11328
|
+
lastIndex: child(entry.lastIndex, "lastIndex")
|
|
11276
11329
|
};
|
|
11277
11330
|
} else if (isSandboxArguments(entry)) {
|
|
11278
11331
|
nodes[id] = { kind: "arguments", data: serializeArguments(entry, child) };
|
|
@@ -11439,11 +11492,12 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
11439
11492
|
return result3;
|
|
11440
11493
|
}
|
|
11441
11494
|
if (kind === "regex") {
|
|
11442
|
-
if (typeof node.source !== "string" || typeof node.flags !== "string" ||
|
|
11495
|
+
if (typeof node.source !== "string" || typeof node.flags !== "string" || !Object.hasOwn(node, "lastIndex")) {
|
|
11443
11496
|
throw new TypeError("Invalid replay regular expression.");
|
|
11444
11497
|
}
|
|
11445
|
-
const result3 = createSandboxRegex(node.source, node.flags,
|
|
11498
|
+
const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
|
|
11446
11499
|
restored.set(id, result3);
|
|
11500
|
+
result3.lastIndex = child(own(node, "lastIndex"));
|
|
11447
11501
|
return result3;
|
|
11448
11502
|
}
|
|
11449
11503
|
if (kind === "arguments") {
|
|
@@ -25008,7 +25062,11 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
25008
25062
|
return budget.allocateString(result + value.slice(spanStart));
|
|
25009
25063
|
}
|
|
25010
25064
|
if (methodName === "replace" || methodName === "replaceAll") {
|
|
25011
|
-
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);
|
|
25012
25070
|
}
|
|
25013
25071
|
if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
|
|
25014
25072
|
return callStringPattern(value, methodName, args[0], budget, parent, context);
|
|
@@ -25123,7 +25181,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
|
|
|
25123
25181
|
operation.release();
|
|
25124
25182
|
}
|
|
25125
25183
|
}
|
|
25126
|
-
function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
25184
|
+
function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
|
|
25127
25185
|
const search = args[0];
|
|
25128
25186
|
const replacement = args[1];
|
|
25129
25187
|
if (!isSandboxRegex(search) && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
|
|
@@ -25141,7 +25199,8 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
25141
25199
|
replacement,
|
|
25142
25200
|
methodName === "replaceAll",
|
|
25143
25201
|
budget,
|
|
25144
|
-
callClosure
|
|
25202
|
+
callClosure,
|
|
25203
|
+
context
|
|
25145
25204
|
);
|
|
25146
25205
|
}
|
|
25147
25206
|
if (typeof replacement === "string") {
|
|
@@ -25158,20 +25217,28 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
25158
25217
|
callClosure
|
|
25159
25218
|
);
|
|
25160
25219
|
}
|
|
25161
|
-
async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure) {
|
|
25220
|
+
async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure, context) {
|
|
25162
25221
|
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
25163
|
-
const
|
|
25164
|
-
|
|
25165
|
-
|
|
25166
|
-
|
|
25167
|
-
|
|
25168
|
-
|
|
25169
|
-
|
|
25170
|
-
|
|
25171
|
-
|
|
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);
|
|
25172
25241
|
}
|
|
25173
|
-
result += value.slice(copiedThrough);
|
|
25174
|
-
return budget.allocateString(result);
|
|
25175
25242
|
}
|
|
25176
25243
|
function expandReplacement(replacement, match, captures, input, matchIndex) {
|
|
25177
25244
|
let result = "";
|
|
@@ -25287,7 +25354,7 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
25287
25354
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25288
25355
|
const compilation = new CompileScope(operation.owner);
|
|
25289
25356
|
const retainedPattern = {};
|
|
25290
|
-
budget.setRetainedValues(retainedPattern, () => [pattern]);
|
|
25357
|
+
budget.setRetainedValues(retainedPattern, () => [value, pattern]);
|
|
25291
25358
|
try {
|
|
25292
25359
|
const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
|
|
25293
25360
|
const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
|
|
@@ -25298,35 +25365,51 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
|
|
|
25298
25365
|
operation.release();
|
|
25299
25366
|
}
|
|
25300
25367
|
}
|
|
25301
|
-
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) {
|
|
25302
25384
|
const regex = args[0];
|
|
25303
25385
|
if (!isSandboxRegex(regex))
|
|
25304
25386
|
throw new TypeError(`String#${methodName} requires a regex argument.`);
|
|
25305
25387
|
if (methodName === "search") {
|
|
25306
|
-
const
|
|
25307
|
-
if (!Object.is(
|
|
25308
|
-
const match = executeRegex(regex, value);
|
|
25309
|
-
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;
|
|
25310
25392
|
return match?.index ?? -1;
|
|
25311
25393
|
}
|
|
25312
25394
|
if (methodName === "matchAll" && !regex.flags.includes("g"))
|
|
25313
25395
|
throw new TypeError("String#matchAll requires a global regex.");
|
|
25314
25396
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
25315
|
-
return toMatchArray(executeRegex(regex, value), value);
|
|
25397
|
+
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
|
|
25316
25398
|
if (methodName === "match") regex.lastIndex = 0;
|
|
25317
|
-
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
|
|
25318
|
-
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));
|
|
25319
25401
|
if (methodName === "match" && matches.length === 0) return null;
|
|
25320
25402
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
25321
25403
|
}
|
|
25322
|
-
function collectRegexMatches(regex, value, all, budget) {
|
|
25404
|
+
function collectRegexMatches(regex, value, all, budget, lastIndex = 0) {
|
|
25323
25405
|
const matches = [];
|
|
25324
25406
|
do {
|
|
25325
|
-
const match = executeRegex(regex, value);
|
|
25407
|
+
const match = executeRegex(regex, value, lastIndex);
|
|
25326
25408
|
if (match === null) break;
|
|
25327
25409
|
budget?.allocateArrayLength(matches.length + 1);
|
|
25328
25410
|
matches.push(match);
|
|
25329
|
-
|
|
25411
|
+
lastIndex = match.index + match.text.length;
|
|
25412
|
+
if (all && match.text.length === 0) regex.lastIndex = ++lastIndex;
|
|
25330
25413
|
} while (all);
|
|
25331
25414
|
return matches;
|
|
25332
25415
|
}
|
|
@@ -30657,7 +30740,7 @@ function createMiscGlobals(options) {
|
|
|
30657
30740
|
return {
|
|
30658
30741
|
structuredClone: createSandboxClosure({
|
|
30659
30742
|
sandbox: true,
|
|
30660
|
-
call: ([value]) => structuredCloneSandboxValue(value, options.budget),
|
|
30743
|
+
call: ([value], context) => structuredCloneSandboxValue(value, options.budget, context?.compilation),
|
|
30661
30744
|
name: "structuredClone"
|
|
30662
30745
|
}),
|
|
30663
30746
|
parseInt: createSandboxClosure({
|
|
@@ -30682,11 +30765,20 @@ function createMiscGlobals(options) {
|
|
|
30682
30765
|
})
|
|
30683
30766
|
};
|
|
30684
30767
|
}
|
|
30685
|
-
function structuredCloneSandboxValue(value, budget) {
|
|
30686
|
-
|
|
30687
|
-
const
|
|
30688
|
-
|
|
30689
|
-
|
|
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
|
+
}
|
|
30690
30782
|
}
|
|
30691
30783
|
function assertStructuredCloneable(value, seen) {
|
|
30692
30784
|
if (isSandboxClosure(value) || isSandboxPromise(value) || isSandboxCollectionIterator(value)) {
|
|
@@ -33328,4 +33420,4 @@ export {
|
|
|
33328
33420
|
FileSnapshotBackend,
|
|
33329
33421
|
run
|
|
33330
33422
|
};
|
|
33331
|
-
//# sourceMappingURL=chunk-
|
|
33423
|
+
//# sourceMappingURL=chunk-N3CN2ACZ.js.map
|