@poe-platform/safe-js 0.1.194 → 0.1.195
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-WRASETAY.js → chunk-37QJBJ72.js} +32 -21
- package/dist/safe-js/chunks/chunk-37QJBJ72.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-CU4ESS5Q.js → chunk-6TZXNW5P.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 +4 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-WRASETAY.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-CU4ESS5Q.js.map → chunk-6TZXNW5P.js.map} +0 -0
|
@@ -757,6 +757,7 @@ function measureNode(node) {
|
|
|
757
757
|
case "group":
|
|
758
758
|
return 5 + measureNode(node.body);
|
|
759
759
|
case "lookahead":
|
|
760
|
+
case "lookbehind":
|
|
760
761
|
return 4 + measureNode(node.body);
|
|
761
762
|
case "quantifier":
|
|
762
763
|
return (Object.hasOwn(node, "max") ? 6 : 5) + measureNode(node.body);
|
|
@@ -2129,7 +2130,7 @@ var RegexParser = class {
|
|
|
2129
2130
|
if (quantifier === void 0) {
|
|
2130
2131
|
return body;
|
|
2131
2132
|
}
|
|
2132
|
-
if (body.type === "anchor" || body.type === "wordBoundary") {
|
|
2133
|
+
if (body.type === "anchor" || body.type === "wordBoundary" || body.type === "lookbehind") {
|
|
2133
2134
|
this.fail("Invalid quantifier target", quantifierStart);
|
|
2134
2135
|
}
|
|
2135
2136
|
const greedy = this.peek() !== "?";
|
|
@@ -2164,7 +2165,8 @@ var RegexParser = class {
|
|
|
2164
2165
|
}
|
|
2165
2166
|
parseGroup(start) {
|
|
2166
2167
|
let capturing = true;
|
|
2167
|
-
let
|
|
2168
|
+
let assertionNegated;
|
|
2169
|
+
let lookbehind = false;
|
|
2168
2170
|
if (this.peek() === "?") {
|
|
2169
2171
|
this.guard.allocate(Math.min(3, this.source.length - this.position));
|
|
2170
2172
|
this.guard.work(Math.min(3, this.source.length - this.position));
|
|
@@ -2174,10 +2176,13 @@ var RegexParser = class {
|
|
|
2174
2176
|
this.position += 2;
|
|
2175
2177
|
} else if (extension.startsWith("?=") || extension.startsWith("?!")) {
|
|
2176
2178
|
capturing = false;
|
|
2177
|
-
|
|
2179
|
+
assertionNegated = extension.startsWith("?!");
|
|
2178
2180
|
this.position += 2;
|
|
2179
2181
|
} else if (extension.startsWith("?<=") || extension.startsWith("?<!")) {
|
|
2180
|
-
|
|
2182
|
+
capturing = false;
|
|
2183
|
+
assertionNegated = extension.startsWith("?<!");
|
|
2184
|
+
lookbehind = true;
|
|
2185
|
+
this.position += 3;
|
|
2181
2186
|
} else if (extension.startsWith("?<")) {
|
|
2182
2187
|
this.fail("Named groups are not supported", start);
|
|
2183
2188
|
} else {
|
|
@@ -2197,9 +2202,9 @@ var RegexParser = class {
|
|
|
2197
2202
|
this.fail("Unterminated group", start);
|
|
2198
2203
|
}
|
|
2199
2204
|
this.position += 1;
|
|
2200
|
-
if (
|
|
2205
|
+
if (assertionNegated !== void 0) {
|
|
2201
2206
|
this.guard.allocate(4);
|
|
2202
|
-
return { type: "lookahead", negated:
|
|
2207
|
+
return { type: lookbehind ? "lookbehind" : "lookahead", negated: assertionNegated, body };
|
|
2203
2208
|
}
|
|
2204
2209
|
this.guard.allocate(5);
|
|
2205
2210
|
return { type: "group", capturing, index, body };
|
|
@@ -9320,7 +9325,7 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9320
9325
|
return null;
|
|
9321
9326
|
}
|
|
9322
9327
|
for (let attempt = startIndex; attempt <= input.length; attempt += 1) {
|
|
9323
|
-
const context = { input, flags: pattern.flags, steps: 0 };
|
|
9328
|
+
const context = { input, flags: pattern.flags, direction: 1, work: { steps: 0 } };
|
|
9324
9329
|
charge(context);
|
|
9325
9330
|
const initialState = {
|
|
9326
9331
|
position: attempt,
|
|
@@ -9336,18 +9341,19 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9336
9341
|
}
|
|
9337
9342
|
function* matchNode(node, state, context) {
|
|
9338
9343
|
charge(context);
|
|
9344
|
+
const characterIndex = context.direction === 1 ? state.position : state.position - 1;
|
|
9339
9345
|
switch (node.type) {
|
|
9340
9346
|
case "empty":
|
|
9341
9347
|
yield state;
|
|
9342
9348
|
return;
|
|
9343
9349
|
case "literal":
|
|
9344
|
-
if (charactersEqual(context.input[
|
|
9345
|
-
yield { ...state, position: state.position +
|
|
9350
|
+
if (charactersEqual(context.input[characterIndex], node.value, context.flags.ignoreCase)) {
|
|
9351
|
+
yield { ...state, position: state.position + context.direction };
|
|
9346
9352
|
}
|
|
9347
9353
|
return;
|
|
9348
9354
|
case "dot":
|
|
9349
|
-
if (
|
|
9350
|
-
yield { ...state, position: state.position +
|
|
9355
|
+
if (characterIndex >= 0 && characterIndex < context.input.length && (context.flags.dotAll || !isLineTerminator(context.input[characterIndex]))) {
|
|
9356
|
+
yield { ...state, position: state.position + context.direction };
|
|
9351
9357
|
}
|
|
9352
9358
|
return;
|
|
9353
9359
|
case "anchor":
|
|
@@ -9364,9 +9370,9 @@ function* matchNode(node, state, context) {
|
|
|
9364
9370
|
return;
|
|
9365
9371
|
}
|
|
9366
9372
|
case "characterClass": {
|
|
9367
|
-
const character = context.input[
|
|
9373
|
+
const character = context.input[characterIndex];
|
|
9368
9374
|
if (character !== void 0 && matchesCharacterClass(character, node.items, node.negated, context.flags.ignoreCase)) {
|
|
9369
|
-
yield { ...state, position: state.position +
|
|
9375
|
+
yield { ...state, position: state.position + context.direction };
|
|
9370
9376
|
}
|
|
9371
9377
|
return;
|
|
9372
9378
|
}
|
|
@@ -9378,8 +9384,12 @@ function* matchNode(node, state, context) {
|
|
|
9378
9384
|
yield* matchNode(alternative, cloneState(state), context);
|
|
9379
9385
|
}
|
|
9380
9386
|
return;
|
|
9381
|
-
case "lookahead":
|
|
9382
|
-
|
|
9387
|
+
case "lookahead":
|
|
9388
|
+
case "lookbehind": {
|
|
9389
|
+
const result = matchNode(node.body, cloneState(state), {
|
|
9390
|
+
...context,
|
|
9391
|
+
direction: node.type === "lookbehind" ? -1 : 1
|
|
9392
|
+
}).next();
|
|
9383
9393
|
if (node.negated) {
|
|
9384
9394
|
if (result.done) yield state;
|
|
9385
9395
|
} else if (!result.done) {
|
|
@@ -9394,7 +9404,7 @@ function* matchNode(node, state, context) {
|
|
|
9394
9404
|
continue;
|
|
9395
9405
|
}
|
|
9396
9406
|
const captures = result.captures.slice();
|
|
9397
|
-
captures[node.index - 1] = { start: state.position, end: result.position };
|
|
9407
|
+
captures[node.index - 1] = { start: Math.min(state.position, result.position), end: Math.max(state.position, result.position) };
|
|
9398
9408
|
yield { position: result.position, captures };
|
|
9399
9409
|
}
|
|
9400
9410
|
return;
|
|
@@ -9408,7 +9418,8 @@ function* matchSequence(elements, index, state, context) {
|
|
|
9408
9418
|
yield state;
|
|
9409
9419
|
return;
|
|
9410
9420
|
}
|
|
9411
|
-
|
|
9421
|
+
const element = elements[context.direction === 1 ? index : elements.length - 1 - index];
|
|
9422
|
+
for (const result of matchNode(element, state, context)) {
|
|
9412
9423
|
yield* matchSequence(elements, index + 1, result, context);
|
|
9413
9424
|
}
|
|
9414
9425
|
}
|
|
@@ -9511,13 +9522,13 @@ function clearNodeCaptures(node, captures) {
|
|
|
9511
9522
|
}
|
|
9512
9523
|
return;
|
|
9513
9524
|
}
|
|
9514
|
-
if (node.type === "quantifier" || node.type === "lookahead") {
|
|
9525
|
+
if (node.type === "quantifier" || node.type === "lookahead" || node.type === "lookbehind") {
|
|
9515
9526
|
clearNodeCaptures(node.body, captures);
|
|
9516
9527
|
}
|
|
9517
9528
|
}
|
|
9518
9529
|
function charge(context) {
|
|
9519
|
-
context.steps += 1;
|
|
9520
|
-
allocateRegexSteps(context.steps);
|
|
9530
|
+
context.work.steps += 1;
|
|
9531
|
+
allocateRegexSteps(context.work.steps);
|
|
9521
9532
|
}
|
|
9522
9533
|
function normalizeLastIndex(lastIndex) {
|
|
9523
9534
|
if (Number.isNaN(lastIndex) || lastIndex <= 0) {
|
|
@@ -37101,4 +37112,4 @@ export {
|
|
|
37101
37112
|
FileSnapshotBackend,
|
|
37102
37113
|
run
|
|
37103
37114
|
};
|
|
37104
|
-
//# sourceMappingURL=chunk-
|
|
37115
|
+
//# sourceMappingURL=chunk-37QJBJ72.js.map
|