@poe-platform/safe-js 0.1.199 → 0.1.201
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-YWBUORD7.js → chunk-ARZPYB67.js} +2 -2
- package/dist/safe-js/chunks/{chunk-X5VIB5JV.js → chunk-JWZXP3IL.js} +243 -24
- package/dist/safe-js/chunks/chunk-JWZXP3IL.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/dist/safe-js/interp/regex/parse.d.ts +19 -4
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-X5VIB5JV.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-YWBUORD7.js.map → chunk-ARZPYB67.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-JWZXP3IL.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-ARZPYB67.js.map
|
|
@@ -753,8 +753,10 @@ function measureNode(node) {
|
|
|
753
753
|
return 3;
|
|
754
754
|
case "characterClass": {
|
|
755
755
|
let usage = 5 + node.items.length;
|
|
756
|
+
if (node.operation !== void 0) usage += 1 + node.operation.length;
|
|
757
|
+
if (node.strings !== void 0) usage += 1;
|
|
756
758
|
for (const item of node.items) {
|
|
757
|
-
usage += item.type === "character" ? 3 + item.value.length : item.type === "range" ? 4 + item.from.length + item.to.length : item.type === "property" ? 4 + item.value.length : 4;
|
|
759
|
+
usage += item.type === "character" ? 3 + item.value.length : item.type === "range" ? 4 + item.from.length + item.to.length : item.type === "property" ? 4 + item.value.length + (item.strings === void 0 ? 0 : 1) : item.type === "set" ? 3 + measureNode({ type: "characterClass", ...item.value }) : item.type === "strings" ? 4 + item.values.reduce((total, value) => total + 1 + value.length, 0) : 4;
|
|
758
760
|
}
|
|
759
761
|
return usage;
|
|
760
762
|
}
|
|
@@ -766,7 +768,7 @@ function measureNode(node) {
|
|
|
766
768
|
return usage;
|
|
767
769
|
}
|
|
768
770
|
case "group":
|
|
769
|
-
return 5 + measureNode(node.body) + (node.name === void 0 ? 0 : 1 + node.name.length);
|
|
771
|
+
return 5 + measureNode(node.body) + (node.name === void 0 ? 0 : 1 + node.name.length) + (node.modifiers === void 0 ? 0 : 2 + Object.keys(node.modifiers).length);
|
|
770
772
|
case "lookahead":
|
|
771
773
|
case "lookbehind":
|
|
772
774
|
return 4 + measureNode(node.body);
|
|
@@ -2068,7 +2070,7 @@ function parseRegex(source, flags = "", compilation, valueUnits = 0) {
|
|
|
2068
2070
|
guard.checkLength(flags.length, true);
|
|
2069
2071
|
guard.allocate(5 + valueUnits);
|
|
2070
2072
|
const parsedFlags = parseFlags(flags, guard);
|
|
2071
|
-
const parser = new RegexParser(source, guard, parsedFlags.unicode);
|
|
2073
|
+
const parser = new RegexParser(source, guard, parsedFlags.unicode || parsedFlags.unicodeSets, parsedFlags.unicodeSets);
|
|
2072
2074
|
const body = parser.parse();
|
|
2073
2075
|
guard.allocate(5 + source.length);
|
|
2074
2076
|
const pattern = { source, flags: parsedFlags, captureCount: parser.captureCount, body };
|
|
@@ -2080,14 +2082,16 @@ function parseRegex(source, flags = "", compilation, valueUnits = 0) {
|
|
|
2080
2082
|
}
|
|
2081
2083
|
}
|
|
2082
2084
|
var RegexParser = class {
|
|
2083
|
-
constructor(source, guard, unicode) {
|
|
2085
|
+
constructor(source, guard, unicode, unicodeSets) {
|
|
2084
2086
|
this.source = source;
|
|
2085
2087
|
this.guard = guard;
|
|
2086
2088
|
this.unicode = unicode;
|
|
2089
|
+
this.unicodeSets = unicodeSets;
|
|
2087
2090
|
}
|
|
2088
2091
|
source;
|
|
2089
2092
|
guard;
|
|
2090
2093
|
unicode;
|
|
2094
|
+
unicodeSets;
|
|
2091
2095
|
captureCount = 0;
|
|
2092
2096
|
cursor = 0;
|
|
2093
2097
|
totalCaptureCount;
|
|
@@ -2187,6 +2191,7 @@ var RegexParser = class {
|
|
|
2187
2191
|
parseGroup(start) {
|
|
2188
2192
|
let capturing = true;
|
|
2189
2193
|
let name;
|
|
2194
|
+
let modifiers;
|
|
2190
2195
|
let assertionNegated;
|
|
2191
2196
|
let lookbehind = false;
|
|
2192
2197
|
if (this.peek() === "?") {
|
|
@@ -2208,6 +2213,10 @@ var RegexParser = class {
|
|
|
2208
2213
|
} else if (extension.startsWith("?<")) {
|
|
2209
2214
|
this.position += 2;
|
|
2210
2215
|
name = this.parseGroupName(start);
|
|
2216
|
+
} else if ("ims-".includes(extension[1] ?? "") && extension.length > 1) {
|
|
2217
|
+
capturing = false;
|
|
2218
|
+
this.position++;
|
|
2219
|
+
modifiers = this.parseModifiers(start);
|
|
2211
2220
|
} else {
|
|
2212
2221
|
this.fail("Unsupported group construct", start);
|
|
2213
2222
|
}
|
|
@@ -2236,9 +2245,35 @@ var RegexParser = class {
|
|
|
2236
2245
|
return { type: lookbehind ? "lookbehind" : "lookahead", negated: assertionNegated, body };
|
|
2237
2246
|
}
|
|
2238
2247
|
this.guard.allocate(5);
|
|
2239
|
-
return {
|
|
2248
|
+
return {
|
|
2249
|
+
type: "group",
|
|
2250
|
+
capturing,
|
|
2251
|
+
index,
|
|
2252
|
+
body,
|
|
2253
|
+
...name === void 0 ? {} : { name },
|
|
2254
|
+
...modifiers === void 0 ? {} : { modifiers }
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
parseModifiers(start) {
|
|
2258
|
+
this.guard.allocate(2);
|
|
2259
|
+
const modifiers = {};
|
|
2260
|
+
let enabled = true;
|
|
2261
|
+
while (!this.atEnd() && this.peek() !== ":") {
|
|
2262
|
+
const flag = this.take();
|
|
2263
|
+
if (flag === "-" && enabled) {
|
|
2264
|
+
enabled = false;
|
|
2265
|
+
continue;
|
|
2266
|
+
}
|
|
2267
|
+
const name = flag === "i" ? "ignoreCase" : flag === "m" ? "multiline" : flag === "s" ? "dotAll" : void 0;
|
|
2268
|
+
if (name === void 0 || Object.hasOwn(modifiers, name)) this.fail("Invalid regex modifiers", start);
|
|
2269
|
+
this.guard.allocate(1);
|
|
2270
|
+
modifiers[name] = enabled;
|
|
2271
|
+
}
|
|
2272
|
+
if (this.take() !== ":" || Object.keys(modifiers).length === 0) this.fail("Invalid regex modifiers", start);
|
|
2273
|
+
return modifiers;
|
|
2240
2274
|
}
|
|
2241
2275
|
parseCharacterClass(start) {
|
|
2276
|
+
if (this.unicodeSets) return { type: "characterClass", ...this.parseUnicodeSet(start) };
|
|
2242
2277
|
const negated = this.peek() === "^";
|
|
2243
2278
|
if (negated) {
|
|
2244
2279
|
this.position += 1;
|
|
@@ -2291,6 +2326,95 @@ var RegexParser = class {
|
|
|
2291
2326
|
this.guard.allocate(4);
|
|
2292
2327
|
return { type: "character", value: this.takeCharacter() };
|
|
2293
2328
|
}
|
|
2329
|
+
parseUnicodeSet(start) {
|
|
2330
|
+
this.guard.enterGroup();
|
|
2331
|
+
try {
|
|
2332
|
+
const negated = this.peek() === "^";
|
|
2333
|
+
if (negated) this.position++;
|
|
2334
|
+
this.guard.allocate(5);
|
|
2335
|
+
const items = [];
|
|
2336
|
+
let operation;
|
|
2337
|
+
while (!this.atEnd() && this.peek() !== "]") {
|
|
2338
|
+
this.guard.array(items.length + 1);
|
|
2339
|
+
let item = this.parseUnicodeSetItem(start);
|
|
2340
|
+
if (this.peek() === "-" && this.source[this.position + 1] !== "-") {
|
|
2341
|
+
this.position++;
|
|
2342
|
+
const right = this.parseUnicodeSetItem(start);
|
|
2343
|
+
if (item.type !== "character" || right.type !== "character") this.fail("Invalid set range", start);
|
|
2344
|
+
if (item.value.codePointAt(0) > right.value.codePointAt(0)) this.fail("Set range is out of order", start);
|
|
2345
|
+
this.guard.allocate(4 + item.value.length + right.value.length);
|
|
2346
|
+
item = { type: "range", from: item.value, to: right.value };
|
|
2347
|
+
}
|
|
2348
|
+
if (operation !== void 0 && item.type === "range") this.fail("Set operations require nested ranges", start);
|
|
2349
|
+
items.push(item);
|
|
2350
|
+
const operator = this.source.slice(this.position, this.position + 2);
|
|
2351
|
+
if (operator === "&&" || operator === "--") {
|
|
2352
|
+
const next = operator === "&&" ? "intersection" : "subtraction";
|
|
2353
|
+
if (operation === void 0 && (items.length !== 1 || item.type === "range") || operation !== void 0 && operation !== next) this.fail("Mixed set operations", start);
|
|
2354
|
+
if (operation === void 0) this.guard.allocate(1 + next.length);
|
|
2355
|
+
operation = next;
|
|
2356
|
+
this.position += 2;
|
|
2357
|
+
if (this.peek() === "]" || this.atEnd()) this.fail("Missing set operand", start);
|
|
2358
|
+
} else if (operation !== void 0 && this.peek() !== "]") this.fail("Missing set operator", start);
|
|
2359
|
+
}
|
|
2360
|
+
if (this.take() !== "]") this.fail("Unterminated character set", start);
|
|
2361
|
+
const mayContainStrings = (item) => {
|
|
2362
|
+
if (item.type === "set") return item.value.strings === true;
|
|
2363
|
+
if (item.type === "property") return item.strings === true;
|
|
2364
|
+
if (item.type === "strings") return item.values.some((value) => value.length !== ((value.codePointAt(0) ?? 0) > 65535 ? 2 : 1));
|
|
2365
|
+
return false;
|
|
2366
|
+
};
|
|
2367
|
+
const strings = operation === "intersection" ? items.every(mayContainStrings) : operation === "subtraction" ? mayContainStrings(items[0]) : items.some(mayContainStrings);
|
|
2368
|
+
if (negated && strings) this.fail("Cannot complement a set containing strings", start);
|
|
2369
|
+
if (strings) this.guard.allocate(1);
|
|
2370
|
+
return { negated, items, ...operation === void 0 ? {} : { operation }, ...strings ? { strings: true } : {} };
|
|
2371
|
+
} finally {
|
|
2372
|
+
this.guard.leaveGroup();
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
parseUnicodeSetItem(start) {
|
|
2376
|
+
if (this.peek() === "[") {
|
|
2377
|
+
this.position++;
|
|
2378
|
+
this.guard.allocate(3);
|
|
2379
|
+
return { type: "set", value: this.parseUnicodeSet(start) };
|
|
2380
|
+
}
|
|
2381
|
+
if (this.source.startsWith("\\q{", this.position)) {
|
|
2382
|
+
this.position += 3;
|
|
2383
|
+
this.guard.allocate(4);
|
|
2384
|
+
const values = [];
|
|
2385
|
+
let value2 = "";
|
|
2386
|
+
while (!this.atEnd()) {
|
|
2387
|
+
if (this.peek() === "|" || this.peek() === "}") {
|
|
2388
|
+
this.guard.array(values.length + 1);
|
|
2389
|
+
this.guard.allocate(1);
|
|
2390
|
+
values.push(value2);
|
|
2391
|
+
value2 = "";
|
|
2392
|
+
if (this.take() === "}") return { type: "strings", values };
|
|
2393
|
+
} else {
|
|
2394
|
+
const item = this.parseSetCharacter(start);
|
|
2395
|
+
this.guard.allocate(item.length);
|
|
2396
|
+
value2 += item;
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
this.fail("Unterminated class string", start);
|
|
2400
|
+
}
|
|
2401
|
+
if (this.peek() === "\\") return this.parseClassItem(start);
|
|
2402
|
+
const value = this.parseSetCharacter(start);
|
|
2403
|
+
this.guard.allocate(3 + value.length);
|
|
2404
|
+
return { type: "character", value };
|
|
2405
|
+
}
|
|
2406
|
+
parseSetCharacter(start) {
|
|
2407
|
+
if (this.peek() === "\\") {
|
|
2408
|
+
this.position++;
|
|
2409
|
+
const node = this.parseEscape(true, start);
|
|
2410
|
+
if (node.type !== "literal") this.fail("Class strings require literal characters", start);
|
|
2411
|
+
return node.value;
|
|
2412
|
+
}
|
|
2413
|
+
const character = this.takeCharacter();
|
|
2414
|
+
if (!character || "()[]{}/-|".includes(character) || "!#$%&*+,.:;<=>?@^`~".includes(character) && this.peek() === character)
|
|
2415
|
+
this.fail("Invalid character in Unicode set", start);
|
|
2416
|
+
return character;
|
|
2417
|
+
}
|
|
2294
2418
|
parseEscape(inCharacterClass, start) {
|
|
2295
2419
|
if (this.atEnd()) {
|
|
2296
2420
|
this.fail("Trailing escape", start);
|
|
@@ -2344,12 +2468,20 @@ var RegexParser = class {
|
|
|
2344
2468
|
const value = this.source.slice(begin, this.position);
|
|
2345
2469
|
if (this.take() !== "}") this.fail("Unterminated Unicode property escape", start);
|
|
2346
2470
|
try {
|
|
2347
|
-
new RegExp(
|
|
2471
|
+
new RegExp(`\\${escaped}{${value}}`, this.unicodeSets ? "v" : "u");
|
|
2348
2472
|
} catch {
|
|
2349
2473
|
this.fail("Unknown Unicode property", start);
|
|
2350
2474
|
}
|
|
2475
|
+
let strings = false;
|
|
2476
|
+
if (this.unicodeSets) {
|
|
2477
|
+
try {
|
|
2478
|
+
new RegExp(`\\p{${value}}`, "u");
|
|
2479
|
+
} catch {
|
|
2480
|
+
strings = true;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2351
2483
|
this.guard.array(1);
|
|
2352
|
-
return { type: "characterClass", negated: false, items: [{ type: "property", value, negated: escaped === "P" }] };
|
|
2484
|
+
return { type: "characterClass", negated: false, items: [{ type: "property", value, negated: escaped === "P", ...strings ? { strings: true } : {} }] };
|
|
2353
2485
|
}
|
|
2354
2486
|
if (escaped === "x") {
|
|
2355
2487
|
this.guard.allocate(4);
|
|
@@ -2417,7 +2549,7 @@ var RegexParser = class {
|
|
|
2417
2549
|
this.guard.allocate(4);
|
|
2418
2550
|
return { type: "literal", value: String.fromCharCode(letter.charCodeAt(0) % 32) };
|
|
2419
2551
|
}
|
|
2420
|
-
if (this.unicode && controls[escaped] === void 0 && !"^$\\.*+?()[]{}|/".includes(escaped) && !(inCharacterClass && escaped === "-"))
|
|
2552
|
+
if (this.unicode && controls[escaped] === void 0 && !"^$\\.*+?()[]{}|/".includes(escaped) && !(inCharacterClass && (escaped === "-" || this.unicodeSets && "!#$%&+,.:;<=>?@`~".includes(escaped))))
|
|
2421
2553
|
this.fail("Invalid identity escape", start);
|
|
2422
2554
|
this.guard.allocate(4);
|
|
2423
2555
|
return { type: "literal", value: controls[escaped] ?? escaped };
|
|
@@ -2591,6 +2723,7 @@ function parseFlags(flags, guard) {
|
|
|
2591
2723
|
global: false,
|
|
2592
2724
|
sticky: false,
|
|
2593
2725
|
unicode: false,
|
|
2726
|
+
unicodeSets: false,
|
|
2594
2727
|
ignoreCase: false,
|
|
2595
2728
|
multiline: false,
|
|
2596
2729
|
dotAll: false
|
|
@@ -2602,7 +2735,8 @@ function parseFlags(flags, guard) {
|
|
|
2602
2735
|
m: "multiline",
|
|
2603
2736
|
s: "dotAll",
|
|
2604
2737
|
y: "sticky",
|
|
2605
|
-
u: "unicode"
|
|
2738
|
+
u: "unicode",
|
|
2739
|
+
v: "unicodeSets"
|
|
2606
2740
|
};
|
|
2607
2741
|
for (let position = 0; position < flags.length; position += 1) {
|
|
2608
2742
|
guard.work(1);
|
|
@@ -2616,6 +2750,7 @@ function parseFlags(flags, guard) {
|
|
|
2616
2750
|
}
|
|
2617
2751
|
parsed[name] = true;
|
|
2618
2752
|
}
|
|
2753
|
+
if (parsed.unicode && parsed.unicodeSets) throw new SyntaxError("Unicode flags u and v cannot be combined");
|
|
2619
2754
|
return parsed;
|
|
2620
2755
|
}
|
|
2621
2756
|
function isDecimalDigit2(character) {
|
|
@@ -9518,8 +9653,9 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9518
9653
|
if (startIndex > input.length) {
|
|
9519
9654
|
return null;
|
|
9520
9655
|
}
|
|
9521
|
-
|
|
9522
|
-
|
|
9656
|
+
const unicode = pattern.flags.unicode || pattern.flags.unicodeSets;
|
|
9657
|
+
if (unicode && startIndex > 0 && startIndex < input.length && input.charCodeAt(startIndex) >= 56320 && input.charCodeAt(startIndex) <= 57343 && input.charCodeAt(startIndex - 1) >= 55296 && input.charCodeAt(startIndex - 1) <= 56319) startIndex--;
|
|
9658
|
+
for (let attempt = startIndex; attempt <= input.length; attempt = advanceStringIndex(input, attempt, unicode)) {
|
|
9523
9659
|
const context = { input, flags: pattern.flags, groups: pattern.groups, direction: 1, work: { steps: 0 } };
|
|
9524
9660
|
charge(context);
|
|
9525
9661
|
const initialState = {
|
|
@@ -9536,13 +9672,14 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9536
9672
|
}
|
|
9537
9673
|
function* matchNode(node, state, context) {
|
|
9538
9674
|
charge(context);
|
|
9539
|
-
const
|
|
9675
|
+
const unicode = context.flags.unicode || context.flags.unicodeSets;
|
|
9676
|
+
const character = readCharacter(context.input, state.position, context.direction, unicode);
|
|
9540
9677
|
switch (node.type) {
|
|
9541
9678
|
case "empty":
|
|
9542
9679
|
yield state;
|
|
9543
9680
|
return;
|
|
9544
9681
|
case "literal":
|
|
9545
|
-
if (charactersEqual(character, node.value, context.flags.ignoreCase,
|
|
9682
|
+
if (charactersEqual(character, node.value, context.flags.ignoreCase, unicode)) {
|
|
9546
9683
|
yield { ...state, position: state.position + context.direction * character.length };
|
|
9547
9684
|
}
|
|
9548
9685
|
return;
|
|
@@ -9568,9 +9705,9 @@ function* matchNode(node, state, context) {
|
|
|
9568
9705
|
const end = context.direction === 1 ? capture.end : capture.start;
|
|
9569
9706
|
while (reference !== end) {
|
|
9570
9707
|
charge(context);
|
|
9571
|
-
const expected = readCharacter(context.input, reference, context.direction,
|
|
9572
|
-
const actual = readCharacter(context.input, position, context.direction,
|
|
9573
|
-
if (!charactersEqual(actual, expected, context.flags.ignoreCase,
|
|
9708
|
+
const expected = readCharacter(context.input, reference, context.direction, unicode);
|
|
9709
|
+
const actual = readCharacter(context.input, position, context.direction, unicode);
|
|
9710
|
+
if (!charactersEqual(actual, expected, context.flags.ignoreCase, unicode)) return;
|
|
9574
9711
|
reference += context.direction * expected.length;
|
|
9575
9712
|
position += context.direction * actual.length;
|
|
9576
9713
|
}
|
|
@@ -9588,14 +9725,22 @@ function* matchNode(node, state, context) {
|
|
|
9588
9725
|
}
|
|
9589
9726
|
return;
|
|
9590
9727
|
case "wordBoundary": {
|
|
9591
|
-
const previousWord = state.position > 0 && matchesCharacterClassItem(context.input[state.position - 1], { type: "kind", kind: "word", negated: false }, context.flags.ignoreCase,
|
|
9592
|
-
const nextWord = state.position < context.input.length && matchesCharacterClassItem(context.input[state.position], { type: "kind", kind: "word", negated: false }, context.flags.ignoreCase,
|
|
9728
|
+
const previousWord = state.position > 0 && matchesCharacterClassItem(context.input[state.position - 1], { type: "kind", kind: "word", negated: false }, context.flags.ignoreCase, unicode);
|
|
9729
|
+
const nextWord = state.position < context.input.length && matchesCharacterClassItem(context.input[state.position], { type: "kind", kind: "word", negated: false }, context.flags.ignoreCase, unicode);
|
|
9593
9730
|
if (previousWord !== nextWord !== node.negated) {
|
|
9594
9731
|
yield state;
|
|
9595
9732
|
}
|
|
9596
9733
|
return;
|
|
9597
9734
|
}
|
|
9598
9735
|
case "characterClass": {
|
|
9736
|
+
if (context.flags.unicodeSets) {
|
|
9737
|
+
const lengths = [...matchUnicodeSet(node, state.position, context)].sort((a, b) => b - a);
|
|
9738
|
+
for (const length of lengths) {
|
|
9739
|
+
charge(context);
|
|
9740
|
+
yield { ...state, position: state.position + context.direction * length };
|
|
9741
|
+
}
|
|
9742
|
+
return;
|
|
9743
|
+
}
|
|
9599
9744
|
if (character !== void 0 && matchesCharacterClass(character, node.items, node.negated, context)) {
|
|
9600
9745
|
yield { ...state, position: state.position + context.direction * character.length };
|
|
9601
9746
|
}
|
|
@@ -9623,7 +9768,10 @@ function* matchNode(node, state, context) {
|
|
|
9623
9768
|
return;
|
|
9624
9769
|
}
|
|
9625
9770
|
case "group":
|
|
9626
|
-
for (const result of matchNode(node.body, cloneState(state), context
|
|
9771
|
+
for (const result of matchNode(node.body, cloneState(state), node.modifiers === void 0 ? context : {
|
|
9772
|
+
...context,
|
|
9773
|
+
flags: { ...context.flags, ...node.modifiers }
|
|
9774
|
+
})) {
|
|
9627
9775
|
if (!node.capturing || node.index === void 0) {
|
|
9628
9776
|
yield result;
|
|
9629
9777
|
continue;
|
|
@@ -9687,7 +9835,8 @@ function matchesCharacterClass(character, items, negated, context) {
|
|
|
9687
9835
|
});
|
|
9688
9836
|
return negated ? !matched : matched;
|
|
9689
9837
|
}
|
|
9690
|
-
function matchesCharacterClassItem(character, item, ignoreCase, unicode) {
|
|
9838
|
+
function matchesCharacterClassItem(character, item, ignoreCase, unicode, unicodeSets = false) {
|
|
9839
|
+
if (item.type === "strings" || item.type === "set") return false;
|
|
9691
9840
|
if (unicode) {
|
|
9692
9841
|
const hex = (value) => `\\u{${value.codePointAt(0).toString(16)}}`;
|
|
9693
9842
|
let atom;
|
|
@@ -9698,7 +9847,7 @@ function matchesCharacterClassItem(character, item, ignoreCase, unicode) {
|
|
|
9698
9847
|
const kind = item.kind === "digit" ? "d" : item.kind === "word" ? "w" : "s";
|
|
9699
9848
|
atom = `\\${item.negated ? kind.toUpperCase() : kind}`;
|
|
9700
9849
|
}
|
|
9701
|
-
return new RegExp(`^(?:${atom})$`, ignoreCase ? "
|
|
9850
|
+
return new RegExp(`^(?:${atom})$`, (ignoreCase ? "i" : "") + (unicodeSets ? "v" : "u")).test(character);
|
|
9702
9851
|
}
|
|
9703
9852
|
if (item.type === "property") return false;
|
|
9704
9853
|
if (item.type === "character") {
|
|
@@ -9722,6 +9871,76 @@ function matchesCharacterClassItem(character, item, ignoreCase, unicode) {
|
|
|
9722
9871
|
const matched = item.kind === "digit" ? isDigit(character) : item.kind === "word" ? isWordCharacter(character) : isSpaceCharacter(character);
|
|
9723
9872
|
return item.negated ? !matched : matched;
|
|
9724
9873
|
}
|
|
9874
|
+
function matchUnicodeSet(set, position, context) {
|
|
9875
|
+
charge(context);
|
|
9876
|
+
let lengths = /* @__PURE__ */ new Set();
|
|
9877
|
+
for (let index = 0; index < set.items.length; index++) {
|
|
9878
|
+
const next = matchUnicodeSetItem(set.items[index], position, context);
|
|
9879
|
+
if (index === 0) lengths = next;
|
|
9880
|
+
else if (set.operation === void 0) {
|
|
9881
|
+
for (const length of next) {
|
|
9882
|
+
charge(context);
|
|
9883
|
+
lengths.add(length);
|
|
9884
|
+
}
|
|
9885
|
+
} else {
|
|
9886
|
+
for (const length of lengths) {
|
|
9887
|
+
charge(context);
|
|
9888
|
+
if (set.operation === "intersection" ? !next.has(length) : next.has(length)) lengths.delete(length);
|
|
9889
|
+
}
|
|
9890
|
+
}
|
|
9891
|
+
}
|
|
9892
|
+
if (set.negated) {
|
|
9893
|
+
const character = readCharacter(context.input, position, context.direction, true);
|
|
9894
|
+
return new Set(character !== void 0 && !lengths.has(character.length) ? [character.length] : []);
|
|
9895
|
+
}
|
|
9896
|
+
return lengths;
|
|
9897
|
+
}
|
|
9898
|
+
function matchUnicodeSetItem(item, position, context) {
|
|
9899
|
+
charge(context);
|
|
9900
|
+
if (item.type === "set") return matchUnicodeSet(item.value, position, context);
|
|
9901
|
+
const lengths = /* @__PURE__ */ new Set();
|
|
9902
|
+
if (item.type === "strings") {
|
|
9903
|
+
for (const value of item.values) {
|
|
9904
|
+
charge(context);
|
|
9905
|
+
let reference = context.direction === 1 ? 0 : value.length;
|
|
9906
|
+
let cursor = position;
|
|
9907
|
+
const end = context.direction === 1 ? value.length : 0;
|
|
9908
|
+
while (reference !== end) {
|
|
9909
|
+
charge(context);
|
|
9910
|
+
const expected = readCharacter(value, reference, context.direction, true);
|
|
9911
|
+
const actual = readCharacter(context.input, cursor, context.direction, true);
|
|
9912
|
+
if (!charactersEqual(actual, expected, context.flags.ignoreCase, true)) break;
|
|
9913
|
+
reference += context.direction * expected.length;
|
|
9914
|
+
cursor += context.direction * actual.length;
|
|
9915
|
+
}
|
|
9916
|
+
if (reference === end) lengths.add(Math.abs(cursor - position));
|
|
9917
|
+
}
|
|
9918
|
+
return lengths;
|
|
9919
|
+
}
|
|
9920
|
+
if (item.type === "property" && item.strings) {
|
|
9921
|
+
const atom = `\\p{${item.value}}`;
|
|
9922
|
+
const flags = (context.flags.ignoreCase ? "i" : "") + "v";
|
|
9923
|
+
const matcher = new RegExp(context.direction === 1 ? atom : `(?<=(${atom}))`, flags + "y");
|
|
9924
|
+
matcher.lastIndex = position;
|
|
9925
|
+
const match = matcher.exec(context.input);
|
|
9926
|
+
if (match === null) return lengths;
|
|
9927
|
+
const longest = context.direction === 1 ? match[0] : match[1];
|
|
9928
|
+
const member = new RegExp(`^(?:${atom})$`, flags);
|
|
9929
|
+
let consumed = 0;
|
|
9930
|
+
while (consumed < longest.length) {
|
|
9931
|
+
charge(context);
|
|
9932
|
+
const cursor = context.direction === 1 ? consumed : longest.length - consumed;
|
|
9933
|
+
consumed += readCharacter(longest, cursor, context.direction, true).length;
|
|
9934
|
+
const candidate = context.direction === 1 ? longest.slice(0, consumed) : longest.slice(longest.length - consumed);
|
|
9935
|
+
if (member.test(candidate)) lengths.add(consumed);
|
|
9936
|
+
}
|
|
9937
|
+
return lengths;
|
|
9938
|
+
}
|
|
9939
|
+
const character = readCharacter(context.input, position, context.direction, true);
|
|
9940
|
+
if (character !== void 0 && matchesCharacterClassItem(character, item, context.flags.ignoreCase, true, true))
|
|
9941
|
+
lengths.add(character.length);
|
|
9942
|
+
return lengths;
|
|
9943
|
+
}
|
|
9725
9944
|
function toRegexMatch(input, start, state, hasIndices, groups) {
|
|
9726
9945
|
const match = {
|
|
9727
9946
|
index: start,
|
|
@@ -10640,7 +10859,7 @@ function splitNormalized(value, separator, limit, budget, parent) {
|
|
|
10640
10859
|
while (result2.length < limit) {
|
|
10641
10860
|
const match = executeRegex(splitter, value, Number(splitter.lastIndex));
|
|
10642
10861
|
if (match === null) break;
|
|
10643
|
-
if (match.text.length === 0) splitter.lastIndex = advanceStringIndex(value, match.index, splitter.flags.includes("u"));
|
|
10862
|
+
if (match.text.length === 0) splitter.lastIndex = advanceStringIndex(value, match.index, splitter.flags.includes("u") || splitter.flags.includes("v"));
|
|
10644
10863
|
endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
|
|
10645
10864
|
if (match.text.length === 0 && (match.index === copiedThrough || match.index === value.length))
|
|
10646
10865
|
continue;
|
|
@@ -10815,7 +11034,7 @@ function collectRegexMatches(regex, value, all, budget, lastIndex = 0) {
|
|
|
10815
11034
|
budget?.allocateArrayLength(matches.length + 1);
|
|
10816
11035
|
matches.push(match);
|
|
10817
11036
|
lastIndex = match.index + match.text.length;
|
|
10818
|
-
if (all && match.text.length === 0) regex.lastIndex = lastIndex = advanceStringIndex(value, lastIndex, regex.flags.includes("u"));
|
|
11037
|
+
if (all && match.text.length === 0) regex.lastIndex = lastIndex = advanceStringIndex(value, lastIndex, regex.flags.includes("u") || regex.flags.includes("v"));
|
|
10819
11038
|
} while (all);
|
|
10820
11039
|
return matches;
|
|
10821
11040
|
}
|
|
@@ -37381,4 +37600,4 @@ export {
|
|
|
37381
37600
|
FileSnapshotBackend,
|
|
37382
37601
|
run
|
|
37383
37602
|
};
|
|
37384
|
-
//# sourceMappingURL=chunk-
|
|
37603
|
+
//# sourceMappingURL=chunk-JWZXP3IL.js.map
|