@poe-platform/safe-js 0.1.200 → 0.1.202
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-OX7524JW.js → chunk-JBRG5INL.js} +74 -21
- package/dist/safe-js/chunks/chunk-JBRG5INL.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-6HCV5BAA.js → chunk-TIWFGODB.js} +2 -2
- 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 +3 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-OX7524JW.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-6HCV5BAA.js.map → chunk-TIWFGODB.js.map} +0 -0
|
@@ -768,7 +768,7 @@ function measureNode(node) {
|
|
|
768
768
|
return usage;
|
|
769
769
|
}
|
|
770
770
|
case "group":
|
|
771
|
-
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);
|
|
772
772
|
case "lookahead":
|
|
773
773
|
case "lookbehind":
|
|
774
774
|
return 4 + measureNode(node.body);
|
|
@@ -2146,9 +2146,14 @@ var RegexParser = class {
|
|
|
2146
2146
|
parseQuantifiedAtom() {
|
|
2147
2147
|
const quantifierStart = this.position;
|
|
2148
2148
|
const current = this.peek();
|
|
2149
|
-
if (current === "*" || current === "+" || current === "?" || current === "{") {
|
|
2149
|
+
if (current === "*" || current === "+" || current === "?" || current === "{" && this.unicode) {
|
|
2150
2150
|
this.fail("Nothing to repeat", quantifierStart);
|
|
2151
2151
|
}
|
|
2152
|
+
if (current === "{") {
|
|
2153
|
+
const quantifier2 = this.parseQuantifier();
|
|
2154
|
+
this.position = quantifierStart;
|
|
2155
|
+
if (quantifier2 !== void 0) this.fail("Nothing to repeat", quantifierStart);
|
|
2156
|
+
}
|
|
2152
2157
|
const body = this.parseAtom();
|
|
2153
2158
|
const quantifier = this.parseQuantifier();
|
|
2154
2159
|
if (quantifier === void 0) {
|
|
@@ -2191,6 +2196,7 @@ var RegexParser = class {
|
|
|
2191
2196
|
parseGroup(start) {
|
|
2192
2197
|
let capturing = true;
|
|
2193
2198
|
let name;
|
|
2199
|
+
let modifiers;
|
|
2194
2200
|
let assertionNegated;
|
|
2195
2201
|
let lookbehind = false;
|
|
2196
2202
|
if (this.peek() === "?") {
|
|
@@ -2212,6 +2218,10 @@ var RegexParser = class {
|
|
|
2212
2218
|
} else if (extension.startsWith("?<")) {
|
|
2213
2219
|
this.position += 2;
|
|
2214
2220
|
name = this.parseGroupName(start);
|
|
2221
|
+
} else if ("ims-".includes(extension[1] ?? "") && extension.length > 1) {
|
|
2222
|
+
capturing = false;
|
|
2223
|
+
this.position++;
|
|
2224
|
+
modifiers = this.parseModifiers(start);
|
|
2215
2225
|
} else {
|
|
2216
2226
|
this.fail("Unsupported group construct", start);
|
|
2217
2227
|
}
|
|
@@ -2240,7 +2250,32 @@ var RegexParser = class {
|
|
|
2240
2250
|
return { type: lookbehind ? "lookbehind" : "lookahead", negated: assertionNegated, body };
|
|
2241
2251
|
}
|
|
2242
2252
|
this.guard.allocate(5);
|
|
2243
|
-
return {
|
|
2253
|
+
return {
|
|
2254
|
+
type: "group",
|
|
2255
|
+
capturing,
|
|
2256
|
+
index,
|
|
2257
|
+
body,
|
|
2258
|
+
...name === void 0 ? {} : { name },
|
|
2259
|
+
...modifiers === void 0 ? {} : { modifiers }
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
parseModifiers(start) {
|
|
2263
|
+
this.guard.allocate(2);
|
|
2264
|
+
const modifiers = {};
|
|
2265
|
+
let enabled = true;
|
|
2266
|
+
while (!this.atEnd() && this.peek() !== ":") {
|
|
2267
|
+
const flag = this.take();
|
|
2268
|
+
if (flag === "-" && enabled) {
|
|
2269
|
+
enabled = false;
|
|
2270
|
+
continue;
|
|
2271
|
+
}
|
|
2272
|
+
const name = flag === "i" ? "ignoreCase" : flag === "m" ? "multiline" : flag === "s" ? "dotAll" : void 0;
|
|
2273
|
+
if (name === void 0 || Object.hasOwn(modifiers, name)) this.fail("Invalid regex modifiers", start);
|
|
2274
|
+
this.guard.allocate(1);
|
|
2275
|
+
modifiers[name] = enabled;
|
|
2276
|
+
}
|
|
2277
|
+
if (this.take() !== ":" || Object.keys(modifiers).length === 0) this.fail("Invalid regex modifiers", start);
|
|
2278
|
+
return modifiers;
|
|
2244
2279
|
}
|
|
2245
2280
|
parseCharacterClass(start) {
|
|
2246
2281
|
if (this.unicodeSets) return { type: "characterClass", ...this.parseUnicodeSet(start) };
|
|
@@ -2263,7 +2298,11 @@ var RegexParser = class {
|
|
|
2263
2298
|
this.position += 1;
|
|
2264
2299
|
const right = this.parseClassItem(start);
|
|
2265
2300
|
if (left.type !== "character" || right.type !== "character") {
|
|
2266
|
-
this.fail("Character class ranges require literal endpoints", rangePosition);
|
|
2301
|
+
if (this.unicode) this.fail("Character class ranges require literal endpoints", rangePosition);
|
|
2302
|
+
this.guard.array(items.length + 3);
|
|
2303
|
+
this.guard.allocate(4);
|
|
2304
|
+
items.push(left, { type: "character", value: "-" }, right);
|
|
2305
|
+
continue;
|
|
2267
2306
|
}
|
|
2268
2307
|
if (left.value.codePointAt(0) > right.value.codePointAt(0)) {
|
|
2269
2308
|
this.fail("Character class range is out of order", rangePosition);
|
|
@@ -2425,8 +2464,7 @@ var RegexParser = class {
|
|
|
2425
2464
|
}
|
|
2426
2465
|
return { type: "literal", value: String.fromCharCode(code) };
|
|
2427
2466
|
}
|
|
2428
|
-
if (escaped === "p" || escaped === "P") {
|
|
2429
|
-
if (!this.unicode) this.fail("Unicode property escapes are not supported", start);
|
|
2467
|
+
if (this.unicode && (escaped === "p" || escaped === "P")) {
|
|
2430
2468
|
if (this.take() !== "{") this.fail("Invalid Unicode property escape", start);
|
|
2431
2469
|
const begin = this.position;
|
|
2432
2470
|
while (!this.atEnd() && this.peek() !== "}") {
|
|
@@ -2455,7 +2493,7 @@ var RegexParser = class {
|
|
|
2455
2493
|
}
|
|
2456
2494
|
if (escaped === "x") {
|
|
2457
2495
|
this.guard.allocate(4);
|
|
2458
|
-
return { type: "literal", value: this.parseHexEscape(2, "hexadecimal", start) };
|
|
2496
|
+
return { type: "literal", value: this.parseHexEscape(2, "hexadecimal", start, this.unicode ? void 0 : "x") };
|
|
2459
2497
|
}
|
|
2460
2498
|
if (escaped === "u") {
|
|
2461
2499
|
this.guard.allocate(4);
|
|
@@ -2470,7 +2508,7 @@ var RegexParser = class {
|
|
|
2470
2508
|
this.fail("Invalid Unicode escape", start);
|
|
2471
2509
|
return { type: "literal", value: String.fromCodePoint(point) };
|
|
2472
2510
|
}
|
|
2473
|
-
let value = this.parseHexEscape(4, "Unicode", start);
|
|
2511
|
+
let value = this.parseHexEscape(4, "Unicode", start, this.unicode ? void 0 : "u");
|
|
2474
2512
|
if (this.unicode && value.charCodeAt(0) >= 55296 && value.charCodeAt(0) <= 56319 && this.source.startsWith("\\u", this.position)) {
|
|
2475
2513
|
const digits = this.source.slice(this.position + 2, this.position + 6);
|
|
2476
2514
|
const point = Number.parseInt(digits, 16);
|
|
@@ -2512,24 +2550,29 @@ var RegexParser = class {
|
|
|
2512
2550
|
v: "\v",
|
|
2513
2551
|
"0": "\0"
|
|
2514
2552
|
};
|
|
2515
|
-
if (escaped === "c"
|
|
2516
|
-
const letter = this.
|
|
2517
|
-
if (!(letter >= "a" && letter <= "z") && !(letter >= "A" && letter <= "Z"))
|
|
2518
|
-
this.fail("Invalid control escape", start);
|
|
2553
|
+
if (escaped === "c") {
|
|
2554
|
+
const letter = this.peek();
|
|
2519
2555
|
this.guard.allocate(4);
|
|
2520
|
-
|
|
2556
|
+
if (letter >= "a" && letter <= "z" || letter >= "A" && letter <= "Z" || !this.unicode && inCharacterClass && (isDecimalDigit2(letter) || letter === "_")) {
|
|
2557
|
+
this.position++;
|
|
2558
|
+
return { type: "literal", value: String.fromCharCode(letter.charCodeAt(0) % 32) };
|
|
2559
|
+
}
|
|
2560
|
+
if (this.unicode) this.fail("Invalid control escape", start);
|
|
2561
|
+
this.position--;
|
|
2562
|
+
return { type: "literal", value: "\\" };
|
|
2521
2563
|
}
|
|
2522
2564
|
if (this.unicode && controls[escaped] === void 0 && !"^$\\.*+?()[]{}|/".includes(escaped) && !(inCharacterClass && (escaped === "-" || this.unicodeSets && "!#$%&+,.:;<=>?@`~".includes(escaped))))
|
|
2523
2565
|
this.fail("Invalid identity escape", start);
|
|
2524
2566
|
this.guard.allocate(4);
|
|
2525
2567
|
return { type: "literal", value: controls[escaped] ?? escaped };
|
|
2526
2568
|
}
|
|
2527
|
-
parseHexEscape(length, name, start) {
|
|
2569
|
+
parseHexEscape(length, name, start, identity) {
|
|
2528
2570
|
const end = this.position + length;
|
|
2529
2571
|
this.guard.allocate(Math.min(length, this.source.length - this.position));
|
|
2530
2572
|
this.guard.work(Math.min(length, this.source.length - this.position));
|
|
2531
2573
|
const digits = this.source.slice(this.position, end);
|
|
2532
2574
|
if (digits.length !== length || !allHexDigits(digits)) {
|
|
2575
|
+
if (identity !== void 0) return identity;
|
|
2533
2576
|
this.fail(`Invalid ${name} escape`, start);
|
|
2534
2577
|
}
|
|
2535
2578
|
this.position = end;
|
|
@@ -2631,18 +2674,29 @@ var RegexParser = class {
|
|
|
2631
2674
|
}
|
|
2632
2675
|
if (this.peek() === "}") {
|
|
2633
2676
|
this.position += 1;
|
|
2677
|
+
if (!Number.isSafeInteger(min)) this.fail("Quantifier is too large", start);
|
|
2634
2678
|
this.guard.allocate(3);
|
|
2635
2679
|
return { min, max: min };
|
|
2636
2680
|
}
|
|
2637
2681
|
if (this.peek() !== ",") {
|
|
2682
|
+
if (!this.unicode) {
|
|
2683
|
+
this.position = start;
|
|
2684
|
+
return void 0;
|
|
2685
|
+
}
|
|
2638
2686
|
this.fail("Invalid quantifier", start);
|
|
2639
2687
|
}
|
|
2640
2688
|
this.position += 1;
|
|
2641
2689
|
const max = this.parseDecimal();
|
|
2642
2690
|
if (this.peek() !== "}") {
|
|
2691
|
+
if (!this.unicode) {
|
|
2692
|
+
this.position = start;
|
|
2693
|
+
return void 0;
|
|
2694
|
+
}
|
|
2643
2695
|
this.fail("Unterminated quantifier", start);
|
|
2644
2696
|
}
|
|
2645
2697
|
this.position += 1;
|
|
2698
|
+
if (!Number.isSafeInteger(min) || max !== void 0 && !Number.isSafeInteger(max))
|
|
2699
|
+
this.fail("Quantifier is too large", start);
|
|
2646
2700
|
if (max !== void 0 && min > max) {
|
|
2647
2701
|
this.fail("Quantifier range is out of order", start);
|
|
2648
2702
|
}
|
|
@@ -2659,11 +2713,7 @@ var RegexParser = class {
|
|
|
2659
2713
|
}
|
|
2660
2714
|
this.guard.allocate(this.position - start);
|
|
2661
2715
|
this.guard.work(this.position - start);
|
|
2662
|
-
|
|
2663
|
-
if (!Number.isSafeInteger(value)) {
|
|
2664
|
-
this.fail("Quantifier is too large", start);
|
|
2665
|
-
}
|
|
2666
|
-
return value;
|
|
2716
|
+
return Number(this.source.slice(start, this.position));
|
|
2667
2717
|
}
|
|
2668
2718
|
peek() {
|
|
2669
2719
|
return this.source[this.position] ?? "";
|
|
@@ -9738,7 +9788,10 @@ function* matchNode(node, state, context) {
|
|
|
9738
9788
|
return;
|
|
9739
9789
|
}
|
|
9740
9790
|
case "group":
|
|
9741
|
-
for (const result of matchNode(node.body, cloneState(state), context
|
|
9791
|
+
for (const result of matchNode(node.body, cloneState(state), node.modifiers === void 0 ? context : {
|
|
9792
|
+
...context,
|
|
9793
|
+
flags: { ...context.flags, ...node.modifiers }
|
|
9794
|
+
})) {
|
|
9742
9795
|
if (!node.capturing || node.index === void 0) {
|
|
9743
9796
|
yield result;
|
|
9744
9797
|
continue;
|
|
@@ -37567,4 +37620,4 @@ export {
|
|
|
37567
37620
|
FileSnapshotBackend,
|
|
37568
37621
|
run
|
|
37569
37622
|
};
|
|
37570
|
-
//# sourceMappingURL=chunk-
|
|
37623
|
+
//# sourceMappingURL=chunk-JBRG5INL.js.map
|