@poe-platform/safe-bash 0.1.514 → 0.1.516
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-bash/commands/regex-execution/ascii.d.ts +3 -0
- package/dist/safe-bash/commands/regex-execution/ascii.d.ts.map +1 -0
- package/dist/safe-bash/commands/regex-execution/ascii.js +5 -0
- package/dist/safe-bash/commands/regex-execution/ascii.js.map +1 -0
- package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js +15 -8
- package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/matcher.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/matcher.js +2 -1
- package/dist/safe-bash/commands/regex-execution/ere/matcher.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/syntax.d.ts +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/syntax.d.ts.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/syntax.js +17 -6
- package/dist/safe-bash/commands/regex-execution/ere/syntax.js.map +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/types.d.ts +1 -0
- package/dist/safe-bash/commands/regex-execution/ere/types.d.ts.map +1 -1
- package/dist/safe-bash/core.browser.js +33 -14
- package/dist/safe-bash/core.browser.js.map +3 -3
- package/package.json +2 -2
|
@@ -687,6 +687,12 @@ var AvailableRecords = class {
|
|
|
687
687
|
// packages/safe-bash/src/commands/regex-execution/bounded-provider.ts
|
|
688
688
|
init_platform();
|
|
689
689
|
|
|
690
|
+
// packages/safe-bash/src/commands/regex-execution/ascii.ts
|
|
691
|
+
init_platform();
|
|
692
|
+
function foldAscii(code) {
|
|
693
|
+
return code >= 65 && code <= 90 ? code + 32 : code;
|
|
694
|
+
}
|
|
695
|
+
|
|
690
696
|
// packages/safe-bash/src/commands/expr/bre-engine.ts
|
|
691
697
|
init_platform();
|
|
692
698
|
var Work = class {
|
|
@@ -1352,16 +1358,18 @@ async function flatten(input3, ledger, signal) {
|
|
|
1352
1358
|
return { pattern: output2.join(""), quoted: Object.freeze(quoted2) };
|
|
1353
1359
|
}
|
|
1354
1360
|
var Parser2 = class {
|
|
1355
|
-
constructor(pattern, quoted2, ledger, signal) {
|
|
1361
|
+
constructor(pattern, quoted2, ledger, signal, insensitive) {
|
|
1356
1362
|
this.pattern = pattern;
|
|
1357
1363
|
this.quoted = quoted2;
|
|
1358
1364
|
this.ledger = ledger;
|
|
1359
1365
|
this.signal = signal;
|
|
1366
|
+
this.insensitive = insensitive;
|
|
1360
1367
|
}
|
|
1361
1368
|
pattern;
|
|
1362
1369
|
quoted;
|
|
1363
1370
|
ledger;
|
|
1364
1371
|
signal;
|
|
1372
|
+
insensitive;
|
|
1365
1373
|
offset = 0;
|
|
1366
1374
|
groups = 0;
|
|
1367
1375
|
nodes = 0;
|
|
@@ -1443,7 +1451,7 @@ var Parser2 = class {
|
|
|
1443
1451
|
async atom(depth) {
|
|
1444
1452
|
const begin = this.offset;
|
|
1445
1453
|
const character = this.pattern[this.offset++];
|
|
1446
|
-
if (this.quoted?.[begin]) return this.node(() => ({ kind: "literal", code: character.charCodeAt(0), nullable: false, captured: false }));
|
|
1454
|
+
if (this.quoted?.[begin]) return this.node(() => ({ kind: "literal", code: character.charCodeAt(0), insensitive: this.insensitive, nullable: false, captured: false }));
|
|
1447
1455
|
if (character === "(") {
|
|
1448
1456
|
if (this.at("?")) throw new EreUnsupportedError("extended group syntax", begin);
|
|
1449
1457
|
if (this.groups >= 32) throw new EreUnsupportedError("32-group grammar ceiling", begin);
|
|
@@ -1458,13 +1466,13 @@ var Parser2 = class {
|
|
|
1458
1466
|
const escaped3 = this.pattern[this.offset++];
|
|
1459
1467
|
if (escaped3 === void 0) throw new EreSyntaxError("trailing escape", begin);
|
|
1460
1468
|
if (!special.includes(escaped3)) throw new EreUnsupportedError("backreference or escape extension", begin);
|
|
1461
|
-
return this.node(() => ({ kind: "literal", code: escaped3.charCodeAt(0), nullable: false, captured: false }));
|
|
1469
|
+
return this.node(() => ({ kind: "literal", code: escaped3.charCodeAt(0), insensitive: this.insensitive, nullable: false, captured: false }));
|
|
1462
1470
|
}
|
|
1463
1471
|
if (character === "*" || character === "+" || character === "?" || character === "{") throw new EreSyntaxError("repetition without operand", begin);
|
|
1464
1472
|
if (character === ".") return this.node(() => ({ kind: "dot", nullable: false, captured: false }));
|
|
1465
1473
|
if (character === "^") return this.node(() => ({ kind: "start", nullable: true, captured: false }));
|
|
1466
1474
|
if (character === "$") return this.node(() => ({ kind: "end", nullable: true, captured: false }));
|
|
1467
|
-
return this.node(() => ({ kind: "literal", code: character.charCodeAt(0), nullable: false, captured: false }));
|
|
1475
|
+
return this.node(() => ({ kind: "literal", code: character.charCodeAt(0), insensitive: this.insensitive, nullable: false, captured: false }));
|
|
1468
1476
|
}
|
|
1469
1477
|
async set(begin) {
|
|
1470
1478
|
this.ledger.charge("allocationUnits", 128, this.signal);
|
|
@@ -1477,6 +1485,11 @@ var Parser2 = class {
|
|
|
1477
1485
|
await this.ledger.checkpoint(this.signal);
|
|
1478
1486
|
if (this.at("]") && !first) {
|
|
1479
1487
|
this.offset++;
|
|
1488
|
+
if (this.insensitive) for (let upper = 65; upper <= 90; upper++) {
|
|
1489
|
+
this.ledger.charge("work", 1, this.signal);
|
|
1490
|
+
await this.ledger.checkpoint(this.signal);
|
|
1491
|
+
if (members[upper] || members[upper + 32]) members[upper] = members[upper + 32] = true;
|
|
1492
|
+
}
|
|
1480
1493
|
if (negate2) for (let code = 1; code < 128; code++) {
|
|
1481
1494
|
this.ledger.charge("work", 1, this.signal);
|
|
1482
1495
|
await this.ledger.checkpoint(this.signal);
|
|
@@ -1524,10 +1537,11 @@ var Parser2 = class {
|
|
|
1524
1537
|
throw new EreSyntaxError("unclosed bracket expression", begin);
|
|
1525
1538
|
}
|
|
1526
1539
|
};
|
|
1527
|
-
async function compileEre(input3, ledger, signal) {
|
|
1540
|
+
async function compileEre(input3, ledger, signal, asciiInsensitive = false) {
|
|
1528
1541
|
ledger.check(signal);
|
|
1542
|
+
if (typeof asciiInsensitive !== "boolean") throw new TypeError("ASCII case mode must be boolean");
|
|
1529
1543
|
const { pattern, quoted: quoted2 } = await flatten(input3, ledger, signal);
|
|
1530
|
-
const parser = new Parser2(pattern, quoted2, ledger, signal);
|
|
1544
|
+
const parser = new Parser2(pattern, quoted2, ledger, signal, asciiInsensitive);
|
|
1531
1545
|
const root = await parser.expression(0);
|
|
1532
1546
|
if (parser.offset !== pattern.length) throw new EreSyntaxError("unmatched closing group", parser.offset);
|
|
1533
1547
|
ledger.charge("allocationUnits", 3, signal);
|
|
@@ -1754,7 +1768,7 @@ async function runMatcher(program, subject, ledger, signal, from, materialize) {
|
|
|
1754
1768
|
case "literal":
|
|
1755
1769
|
case "set": {
|
|
1756
1770
|
const code = subject.charCodeAt(state.position);
|
|
1757
|
-
if (state.position < subject.length && (node.kind === "dot" || node.kind === "literal" && node.code === code || node.kind === "set" && (code < 128 ? node.members[code] : node.nonAscii))) {
|
|
1771
|
+
if (state.position < subject.length && (node.kind === "dot" || node.kind === "literal" && (node.insensitive ? foldAscii(node.code) === foldAscii(code) : node.code === code) || node.kind === "set" && (code < 128 ? node.members[code] : node.nonAscii))) {
|
|
1758
1772
|
push(state.position + 1, current.next, state.captures, state.histories);
|
|
1759
1773
|
}
|
|
1760
1774
|
break;
|
|
@@ -1903,7 +1917,7 @@ function descriptor(value2, limits) {
|
|
|
1903
1917
|
record(value2, ["kind", "patterns", ...flags3, ...kind.value === "rg" ? ["case"] : []]);
|
|
1904
1918
|
for (const flag of flags3) if (typeof value2[flag] !== "boolean") fail("protocol", `invalid ${flag} flag`);
|
|
1905
1919
|
if (kind.value === "rg" && !["sensitive", "insensitive", "smart"].includes(value2.case)) fail("protocol", "invalid case flag");
|
|
1906
|
-
if (value2.word || kind.value === "
|
|
1920
|
+
if (value2.word || kind.value === "rg" && value2.case !== "sensitive") fail("unsupported", "word matching and rg case-insensitive selection are unsupported");
|
|
1907
1921
|
if (kind.value === "rg" && !value2.fixed) fail("unsupported", "rg regex modes are unsupported; use fixed UTF-8 patterns");
|
|
1908
1922
|
array(value2.patterns, limits.maxPatterns, "pattern");
|
|
1909
1923
|
let bytes3 = 0;
|
|
@@ -2072,9 +2086,14 @@ async function literalBytes(pattern, selected, ledger, signal) {
|
|
|
2072
2086
|
}
|
|
2073
2087
|
return bytes3;
|
|
2074
2088
|
}
|
|
2075
|
-
async function compileLiteral(bytes3, ledger, signal) {
|
|
2089
|
+
async function compileLiteral(bytes3, ledger, signal, insensitive = false) {
|
|
2090
|
+
if (insensitive) for (let index = 0; index < bytes3.length; index++) {
|
|
2091
|
+
ledger.charge("work", 1, signal);
|
|
2092
|
+
await ledger.checkpoint(signal);
|
|
2093
|
+
bytes3[index] = foldAscii(bytes3[index]);
|
|
2094
|
+
}
|
|
2076
2095
|
ledger.charge("states", bytes3.length, signal);
|
|
2077
|
-
ledger.charge("allocationUnits", bytes3.length * 4 +
|
|
2096
|
+
ledger.charge("allocationUnits", bytes3.length * 4 + 4, signal);
|
|
2078
2097
|
const fallback = new Uint32Array(bytes3.length);
|
|
2079
2098
|
for (let index = 1, prefix3 = 0; index < bytes3.length; ) {
|
|
2080
2099
|
ledger.charge("work", 1, signal);
|
|
@@ -2083,7 +2102,7 @@ async function compileLiteral(bytes3, ledger, signal) {
|
|
|
2083
2102
|
else index++;
|
|
2084
2103
|
await ledger.checkpoint(signal);
|
|
2085
2104
|
}
|
|
2086
|
-
return { bytes: bytes3, fallback };
|
|
2105
|
+
return { bytes: bytes3, fallback, insensitive };
|
|
2087
2106
|
}
|
|
2088
2107
|
async function literalStart(program, subject, whole, ledger, signal, from = 0) {
|
|
2089
2108
|
const { bytes: bytes3, fallback } = program;
|
|
@@ -2093,7 +2112,7 @@ async function literalStart(program, subject, whole, ledger, signal, from = 0) {
|
|
|
2093
2112
|
if (bytes3.length === 0) return from;
|
|
2094
2113
|
for (let index = from, prefix3 = 0; index < subject.length; ) {
|
|
2095
2114
|
ledger.charge("work", 1, signal);
|
|
2096
|
-
if (subject[index] === bytes3[prefix3]) {
|
|
2115
|
+
if ((program.insensitive ? foldAscii(subject[index]) : subject[index]) === bytes3[prefix3]) {
|
|
2097
2116
|
index++;
|
|
2098
2117
|
if (++prefix3 === bytes3.length) return index - prefix3;
|
|
2099
2118
|
} else if (prefix3 > 0) prefix3 = fallback[prefix3 - 1];
|
|
@@ -2141,7 +2160,7 @@ async function executeLiteral(input3, signal) {
|
|
|
2141
2160
|
const { descriptor: selected, rows: rows2, ledger } = input3;
|
|
2142
2161
|
const programs2 = [];
|
|
2143
2162
|
for (const pattern of selected.patterns) {
|
|
2144
|
-
programs2.push(await compileLiteral(await literalBytes(pattern, selected, ledger, signal), ledger, signal));
|
|
2163
|
+
programs2.push(await compileLiteral(await literalBytes(pattern, selected, ledger, signal), ledger, signal, selected.kind === "grep" && selected.insensitive));
|
|
2145
2164
|
}
|
|
2146
2165
|
ledger.charge("allocationUnits", 3, signal);
|
|
2147
2166
|
const results = [];
|
|
@@ -2188,7 +2207,7 @@ async function execute(input3, signal) {
|
|
|
2188
2207
|
if (selected.kind === "rg" && !selected.nullData && pattern.includes("\n")) fail("unsupported", "rg multiline matching is unsupported");
|
|
2189
2208
|
ledger.charge("allocationUnits", (selected.whole ? 3 : 1) * 3 + 2, signal);
|
|
2190
2209
|
const fragments = selected.whole ? [{ text: "^(", literal: false }, { text: pattern, literal: selected.fixed }, { text: ")$", literal: false }] : [{ text: pattern, literal: selected.fixed }];
|
|
2191
|
-
programs2.push(await compileEre(fragments, ledger, signal));
|
|
2210
|
+
programs2.push(await compileEre(fragments, ledger, signal, selected.kind === "grep" && selected.insensitive));
|
|
2192
2211
|
}
|
|
2193
2212
|
ledger.charge("allocationUnits", 3, signal);
|
|
2194
2213
|
const results = [];
|