@poe-platform/safe-js 0.1.192 → 0.1.194
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-Q6OWZDNT.js → chunk-CU4ESS5Q.js} +2 -2
- package/dist/safe-js/chunks/{chunk-SKWFZYFI.js → chunk-WRASETAY.js} +41 -11
- package/dist/safe-js/chunks/chunk-WRASETAY.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 +5 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-SKWFZYFI.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-Q6OWZDNT.js.map → chunk-CU4ESS5Q.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-WRASETAY.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-CU4ESS5Q.js.map
|
|
@@ -756,6 +756,8 @@ function measureNode(node) {
|
|
|
756
756
|
}
|
|
757
757
|
case "group":
|
|
758
758
|
return 5 + measureNode(node.body);
|
|
759
|
+
case "lookahead":
|
|
760
|
+
return 4 + measureNode(node.body);
|
|
759
761
|
case "quantifier":
|
|
760
762
|
return (Object.hasOwn(node, "max") ? 6 : 5) + measureNode(node.body);
|
|
761
763
|
}
|
|
@@ -2162,6 +2164,7 @@ var RegexParser = class {
|
|
|
2162
2164
|
}
|
|
2163
2165
|
parseGroup(start) {
|
|
2164
2166
|
let capturing = true;
|
|
2167
|
+
let lookahead;
|
|
2165
2168
|
if (this.peek() === "?") {
|
|
2166
2169
|
this.guard.allocate(Math.min(3, this.source.length - this.position));
|
|
2167
2170
|
this.guard.work(Math.min(3, this.source.length - this.position));
|
|
@@ -2170,7 +2173,9 @@ var RegexParser = class {
|
|
|
2170
2173
|
capturing = false;
|
|
2171
2174
|
this.position += 2;
|
|
2172
2175
|
} else if (extension.startsWith("?=") || extension.startsWith("?!")) {
|
|
2173
|
-
|
|
2176
|
+
capturing = false;
|
|
2177
|
+
lookahead = extension.startsWith("?!");
|
|
2178
|
+
this.position += 2;
|
|
2174
2179
|
} else if (extension.startsWith("?<=") || extension.startsWith("?<!")) {
|
|
2175
2180
|
this.fail("Lookbehind is not supported", start);
|
|
2176
2181
|
} else if (extension.startsWith("?<")) {
|
|
@@ -2192,6 +2197,10 @@ var RegexParser = class {
|
|
|
2192
2197
|
this.fail("Unterminated group", start);
|
|
2193
2198
|
}
|
|
2194
2199
|
this.position += 1;
|
|
2200
|
+
if (lookahead !== void 0) {
|
|
2201
|
+
this.guard.allocate(4);
|
|
2202
|
+
return { type: "lookahead", negated: lookahead, body };
|
|
2203
|
+
}
|
|
2195
2204
|
this.guard.allocate(5);
|
|
2196
2205
|
return { type: "group", capturing, index, body };
|
|
2197
2206
|
}
|
|
@@ -2391,6 +2400,7 @@ var RegexParser = class {
|
|
|
2391
2400
|
function parseFlags(flags, guard) {
|
|
2392
2401
|
guard.allocate(10);
|
|
2393
2402
|
const parsed = {
|
|
2403
|
+
hasIndices: false,
|
|
2394
2404
|
global: false,
|
|
2395
2405
|
sticky: false,
|
|
2396
2406
|
ignoreCase: false,
|
|
@@ -2398,6 +2408,7 @@ function parseFlags(flags, guard) {
|
|
|
2398
2408
|
dotAll: false
|
|
2399
2409
|
};
|
|
2400
2410
|
const names = {
|
|
2411
|
+
d: "hasIndices",
|
|
2401
2412
|
g: "global",
|
|
2402
2413
|
i: "ignoreCase",
|
|
2403
2414
|
m: "multiline",
|
|
@@ -9317,7 +9328,7 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9317
9328
|
};
|
|
9318
9329
|
const result = matchNode(pattern.body, initialState, context).next();
|
|
9319
9330
|
if (!result.done) {
|
|
9320
|
-
return toRegexMatch(input, attempt, result.value);
|
|
9331
|
+
return toRegexMatch(input, attempt, result.value, pattern.flags.hasIndices);
|
|
9321
9332
|
}
|
|
9322
9333
|
if (pattern.flags.sticky) break;
|
|
9323
9334
|
}
|
|
@@ -9367,6 +9378,15 @@ function* matchNode(node, state, context) {
|
|
|
9367
9378
|
yield* matchNode(alternative, cloneState(state), context);
|
|
9368
9379
|
}
|
|
9369
9380
|
return;
|
|
9381
|
+
case "lookahead": {
|
|
9382
|
+
const result = matchNode(node.body, cloneState(state), context).next();
|
|
9383
|
+
if (node.negated) {
|
|
9384
|
+
if (result.done) yield state;
|
|
9385
|
+
} else if (!result.done) {
|
|
9386
|
+
yield { position: state.position, captures: result.value.captures };
|
|
9387
|
+
}
|
|
9388
|
+
return;
|
|
9389
|
+
}
|
|
9370
9390
|
case "group":
|
|
9371
9391
|
for (const result of matchNode(node.body, cloneState(state), context)) {
|
|
9372
9392
|
if (!node.capturing || node.index === void 0) {
|
|
@@ -9450,14 +9470,18 @@ function matchesCharacterClassItem(character, item, ignoreCase) {
|
|
|
9450
9470
|
const matched = item.kind === "digit" ? isDigit(character) : item.kind === "word" ? isWordCharacter(character) : isSpaceCharacter(character);
|
|
9451
9471
|
return item.negated ? !matched : matched;
|
|
9452
9472
|
}
|
|
9453
|
-
function toRegexMatch(input, start, state) {
|
|
9454
|
-
|
|
9473
|
+
function toRegexMatch(input, start, state, hasIndices) {
|
|
9474
|
+
const match = {
|
|
9455
9475
|
index: start,
|
|
9456
9476
|
text: input.slice(start, state.position),
|
|
9457
9477
|
captures: state.captures.map(
|
|
9458
9478
|
(capture) => capture === void 0 ? void 0 : input.slice(capture.start, capture.end)
|
|
9459
9479
|
)
|
|
9460
9480
|
};
|
|
9481
|
+
if (hasIndices) {
|
|
9482
|
+
match.indices = [[start, state.position], ...state.captures.map((capture) => capture === void 0 ? void 0 : [capture.start, capture.end])];
|
|
9483
|
+
}
|
|
9484
|
+
return match;
|
|
9461
9485
|
}
|
|
9462
9486
|
function cloneState(state) {
|
|
9463
9487
|
return { position: state.position, captures: state.captures.slice() };
|
|
@@ -9487,7 +9511,7 @@ function clearNodeCaptures(node, captures) {
|
|
|
9487
9511
|
}
|
|
9488
9512
|
return;
|
|
9489
9513
|
}
|
|
9490
|
-
if (node.type === "quantifier") {
|
|
9514
|
+
if (node.type === "quantifier" || node.type === "lookahead") {
|
|
9491
9515
|
clearNodeCaptures(node.body, captures);
|
|
9492
9516
|
}
|
|
9493
9517
|
}
|
|
@@ -10503,7 +10527,7 @@ function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
|
|
|
10503
10527
|
return match?.index ?? -1;
|
|
10504
10528
|
}
|
|
10505
10529
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
10506
|
-
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
|
|
10530
|
+
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value, compilation.owner?.budget);
|
|
10507
10531
|
if (methodName === "match") regex.lastIndex = 0;
|
|
10508
10532
|
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, normalizeLastIndex(lastIndex ?? Number(regex.lastIndex)), compilation) : regex;
|
|
10509
10533
|
if (methodName === "matchAll")
|
|
@@ -16668,7 +16692,7 @@ async function callRegexMethod(target, methodName, args, budget, context) {
|
|
|
16668
16692
|
cursor = target.lastIndex;
|
|
16669
16693
|
const lastIndex = await sandboxNumber(cursor, budget, context);
|
|
16670
16694
|
const match = executeRegex(target, input, lastIndex);
|
|
16671
|
-
return toMatchArray(match, input);
|
|
16695
|
+
return toMatchArray(match, input, budget);
|
|
16672
16696
|
} finally {
|
|
16673
16697
|
budget.setRetainedValues(retained, void 0);
|
|
16674
16698
|
}
|
|
@@ -16724,12 +16748,19 @@ function executeRegex(target, input, lastIndex) {
|
|
|
16724
16748
|
}
|
|
16725
16749
|
return match;
|
|
16726
16750
|
}
|
|
16727
|
-
function toMatchArray(match, input) {
|
|
16751
|
+
function toMatchArray(match, input, budget) {
|
|
16728
16752
|
if (match === null) {
|
|
16729
16753
|
return null;
|
|
16730
16754
|
}
|
|
16755
|
+
budget?.allocateArrayLength(match.captures.length + 1);
|
|
16731
16756
|
const result = [match.text, ...match.captures];
|
|
16732
16757
|
Object.assign(result, { index: match.index, input, groups: void 0 });
|
|
16758
|
+
if (match.indices !== void 0) {
|
|
16759
|
+
budget?.allocateArrayLength(match.indices.length);
|
|
16760
|
+
budget?.allocateArrayLength(2);
|
|
16761
|
+
Object.assign(match.indices, { groups: void 0 });
|
|
16762
|
+
Object.assign(result, { indices: match.indices });
|
|
16763
|
+
}
|
|
16733
16764
|
return result;
|
|
16734
16765
|
}
|
|
16735
16766
|
|
|
@@ -16754,8 +16785,7 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16754
16785
|
const codePoint = input.codePointAt(index);
|
|
16755
16786
|
matcher.lastIndex = index + (unicode && codePoint !== void 0 && codePoint > 65535 ? 2 : 1);
|
|
16756
16787
|
}
|
|
16757
|
-
|
|
16758
|
-
return { value: toMatchArray(match, input), done: false };
|
|
16788
|
+
return { value: toMatchArray(match, input, budget), done: false };
|
|
16759
16789
|
}
|
|
16760
16790
|
async function nextObservableRegExpIterator(iterator, budget, context) {
|
|
16761
16791
|
const state = regexpIteratorState(iterator);
|
|
@@ -37071,4 +37101,4 @@ export {
|
|
|
37071
37101
|
FileSnapshotBackend,
|
|
37072
37102
|
run
|
|
37073
37103
|
};
|
|
37074
|
-
//# sourceMappingURL=chunk-
|
|
37104
|
+
//# sourceMappingURL=chunk-WRASETAY.js.map
|