@poe-platform/safe-js 0.1.191 → 0.1.193
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-YGFHNJKK.js → chunk-2N7Z7ETR.js} +2 -2
- package/dist/safe-js/chunks/{chunk-DXCKCEDV.js → chunk-IBLBXKUC.js} +122 -12
- package/dist/safe-js/chunks/chunk-IBLBXKUC.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 +2 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-DXCKCEDV.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-YGFHNJKK.js.map → chunk-2N7Z7ETR.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-IBLBXKUC.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-2N7Z7ETR.js.map
|
|
@@ -2391,16 +2391,20 @@ var RegexParser = class {
|
|
|
2391
2391
|
function parseFlags(flags, guard) {
|
|
2392
2392
|
guard.allocate(10);
|
|
2393
2393
|
const parsed = {
|
|
2394
|
+
hasIndices: false,
|
|
2394
2395
|
global: false,
|
|
2396
|
+
sticky: false,
|
|
2395
2397
|
ignoreCase: false,
|
|
2396
2398
|
multiline: false,
|
|
2397
2399
|
dotAll: false
|
|
2398
2400
|
};
|
|
2399
2401
|
const names = {
|
|
2402
|
+
d: "hasIndices",
|
|
2400
2403
|
g: "global",
|
|
2401
2404
|
i: "ignoreCase",
|
|
2402
2405
|
m: "multiline",
|
|
2403
|
-
s: "dotAll"
|
|
2406
|
+
s: "dotAll",
|
|
2407
|
+
y: "sticky"
|
|
2404
2408
|
};
|
|
2405
2409
|
for (let position = 0; position < flags.length; position += 1) {
|
|
2406
2410
|
guard.work(1);
|
|
@@ -9299,7 +9303,7 @@ async function withRunResources(signal, execute) {
|
|
|
9299
9303
|
|
|
9300
9304
|
// packages/safe-js/src/interp/regex/engine.ts
|
|
9301
9305
|
function matchRegex(pattern, input, lastIndex = 0) {
|
|
9302
|
-
const startIndex = pattern.flags.global ? normalizeLastIndex(lastIndex) : 0;
|
|
9306
|
+
const startIndex = pattern.flags.global || pattern.flags.sticky ? normalizeLastIndex(lastIndex) : 0;
|
|
9303
9307
|
return matchRegexFrom(pattern, input, startIndex);
|
|
9304
9308
|
}
|
|
9305
9309
|
function matchRegexFrom(pattern, input, startIndex) {
|
|
@@ -9315,8 +9319,9 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9315
9319
|
};
|
|
9316
9320
|
const result = matchNode(pattern.body, initialState, context).next();
|
|
9317
9321
|
if (!result.done) {
|
|
9318
|
-
return toRegexMatch(input, attempt, result.value);
|
|
9322
|
+
return toRegexMatch(input, attempt, result.value, pattern.flags.hasIndices);
|
|
9319
9323
|
}
|
|
9324
|
+
if (pattern.flags.sticky) break;
|
|
9320
9325
|
}
|
|
9321
9326
|
return null;
|
|
9322
9327
|
}
|
|
@@ -9447,14 +9452,18 @@ function matchesCharacterClassItem(character, item, ignoreCase) {
|
|
|
9447
9452
|
const matched = item.kind === "digit" ? isDigit(character) : item.kind === "word" ? isWordCharacter(character) : isSpaceCharacter(character);
|
|
9448
9453
|
return item.negated ? !matched : matched;
|
|
9449
9454
|
}
|
|
9450
|
-
function toRegexMatch(input, start, state) {
|
|
9451
|
-
|
|
9455
|
+
function toRegexMatch(input, start, state, hasIndices) {
|
|
9456
|
+
const match = {
|
|
9452
9457
|
index: start,
|
|
9453
9458
|
text: input.slice(start, state.position),
|
|
9454
9459
|
captures: state.captures.map(
|
|
9455
9460
|
(capture) => capture === void 0 ? void 0 : input.slice(capture.start, capture.end)
|
|
9456
9461
|
)
|
|
9457
9462
|
};
|
|
9463
|
+
if (hasIndices) {
|
|
9464
|
+
match.indices = [[start, state.position], ...state.captures.map((capture) => capture === void 0 ? void 0 : [capture.start, capture.end])];
|
|
9465
|
+
}
|
|
9466
|
+
return match;
|
|
9458
9467
|
}
|
|
9459
9468
|
function cloneState(state) {
|
|
9460
9469
|
return { position: state.position, captures: state.captures.slice() };
|
|
@@ -10500,7 +10509,7 @@ function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
|
|
|
10500
10509
|
return match?.index ?? -1;
|
|
10501
10510
|
}
|
|
10502
10511
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
10503
|
-
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
|
|
10512
|
+
return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value, compilation.owner?.budget);
|
|
10504
10513
|
if (methodName === "match") regex.lastIndex = 0;
|
|
10505
10514
|
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, normalizeLastIndex(lastIndex ?? Number(regex.lastIndex)), compilation) : regex;
|
|
10506
10515
|
if (methodName === "matchAll")
|
|
@@ -16665,7 +16674,7 @@ async function callRegexMethod(target, methodName, args, budget, context) {
|
|
|
16665
16674
|
cursor = target.lastIndex;
|
|
16666
16675
|
const lastIndex = await sandboxNumber(cursor, budget, context);
|
|
16667
16676
|
const match = executeRegex(target, input, lastIndex);
|
|
16668
|
-
return toMatchArray(match, input);
|
|
16677
|
+
return toMatchArray(match, input, budget);
|
|
16669
16678
|
} finally {
|
|
16670
16679
|
budget.setRetainedValues(retained, void 0);
|
|
16671
16680
|
}
|
|
@@ -16716,17 +16725,24 @@ async function regexToString(target, budget, context) {
|
|
|
16716
16725
|
function executeRegex(target, input, lastIndex) {
|
|
16717
16726
|
const pattern = getSandboxRegexPattern(target);
|
|
16718
16727
|
const match = matchRegex(pattern, input, lastIndex);
|
|
16719
|
-
if (pattern.flags.global) {
|
|
16728
|
+
if (pattern.flags.global || pattern.flags.sticky) {
|
|
16720
16729
|
target.lastIndex = match === null ? 0 : match.index + match.text.length;
|
|
16721
16730
|
}
|
|
16722
16731
|
return match;
|
|
16723
16732
|
}
|
|
16724
|
-
function toMatchArray(match, input) {
|
|
16733
|
+
function toMatchArray(match, input, budget) {
|
|
16725
16734
|
if (match === null) {
|
|
16726
16735
|
return null;
|
|
16727
16736
|
}
|
|
16737
|
+
budget?.allocateArrayLength(match.captures.length + 1);
|
|
16728
16738
|
const result = [match.text, ...match.captures];
|
|
16729
16739
|
Object.assign(result, { index: match.index, input, groups: void 0 });
|
|
16740
|
+
if (match.indices !== void 0) {
|
|
16741
|
+
budget?.allocateArrayLength(match.indices.length);
|
|
16742
|
+
budget?.allocateArrayLength(2);
|
|
16743
|
+
Object.assign(match.indices, { groups: void 0 });
|
|
16744
|
+
Object.assign(result, { indices: match.indices });
|
|
16745
|
+
}
|
|
16730
16746
|
return result;
|
|
16731
16747
|
}
|
|
16732
16748
|
|
|
@@ -16751,8 +16767,7 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16751
16767
|
const codePoint = input.codePointAt(index);
|
|
16752
16768
|
matcher.lastIndex = index + (unicode && codePoint !== void 0 && codePoint > 65535 ? 2 : 1);
|
|
16753
16769
|
}
|
|
16754
|
-
|
|
16755
|
-
return { value: toMatchArray(match, input), done: false };
|
|
16770
|
+
return { value: toMatchArray(match, input, budget), done: false };
|
|
16756
16771
|
}
|
|
16757
16772
|
async function nextObservableRegExpIterator(iterator, budget, context) {
|
|
16758
16773
|
const state = regexpIteratorState(iterator);
|
|
@@ -34457,6 +34472,90 @@ function defineDataProperty2(target, key, value) {
|
|
|
34457
34472
|
});
|
|
34458
34473
|
}
|
|
34459
34474
|
|
|
34475
|
+
// packages/safe-js/src/interp/methods/regex-split.ts
|
|
34476
|
+
async function regexSplit(target, input, limit, constructor, budget, context) {
|
|
34477
|
+
if (target === null || typeof target !== "object") throw new TypeError("RegExp split requires an object receiver.");
|
|
34478
|
+
let string;
|
|
34479
|
+
let species;
|
|
34480
|
+
let field;
|
|
34481
|
+
let flags;
|
|
34482
|
+
let matcher;
|
|
34483
|
+
let match;
|
|
34484
|
+
const result = [];
|
|
34485
|
+
const release = retainValues(budget, () => [target, input, limit, string, species, field, flags, matcher, match, result]);
|
|
34486
|
+
const read = (value, key) => {
|
|
34487
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
34488
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
34489
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
34490
|
+
};
|
|
34491
|
+
const append = (value) => {
|
|
34492
|
+
budget.allocateArrayLength(result.length + 1);
|
|
34493
|
+
result.push(value);
|
|
34494
|
+
};
|
|
34495
|
+
try {
|
|
34496
|
+
string = await sandboxString(input, budget, context);
|
|
34497
|
+
input = void 0;
|
|
34498
|
+
field = await read(target, "constructor");
|
|
34499
|
+
species = constructor;
|
|
34500
|
+
if (field !== void 0) {
|
|
34501
|
+
if (field === null || typeof field !== "object") throw new TypeError("Invalid RegExp species constructor.");
|
|
34502
|
+
species = await read(field, Symbol.species);
|
|
34503
|
+
if (species === null || species === void 0) species = constructor;
|
|
34504
|
+
}
|
|
34505
|
+
field = void 0;
|
|
34506
|
+
if (!isSandboxClosure(species) || species.construct === void 0) throw new TypeError("RegExp species must be a constructor.");
|
|
34507
|
+
field = await read(target, "flags");
|
|
34508
|
+
flags = await sandboxString(field, budget, context);
|
|
34509
|
+
field = void 0;
|
|
34510
|
+
const unicode = flags.includes("u") || flags.includes("v");
|
|
34511
|
+
if (!flags.includes("y")) flags = budget.allocateString(flags + "y");
|
|
34512
|
+
matcher = await invokeBuiltinClosure(species, [target, flags], budget, context, void 0, true);
|
|
34513
|
+
const maximum = limit === void 0 ? 2 ** 32 - 1 : await sandboxNumber(limit, budget, context) >>> 0;
|
|
34514
|
+
limit = void 0;
|
|
34515
|
+
if (maximum === 0) return result;
|
|
34516
|
+
if (string.length === 0) {
|
|
34517
|
+
match = await regexExec(matcher, string, budget, context);
|
|
34518
|
+
if (match === null) append(string);
|
|
34519
|
+
return result;
|
|
34520
|
+
}
|
|
34521
|
+
let end = 0;
|
|
34522
|
+
let index = 0;
|
|
34523
|
+
while (index < string.length) {
|
|
34524
|
+
budget.visitNode();
|
|
34525
|
+
match = void 0;
|
|
34526
|
+
await setSandboxProperty(matcher, "lastIndex", index, budget, true, context);
|
|
34527
|
+
match = await regexExec(matcher, string, budget, context);
|
|
34528
|
+
if (match !== null) {
|
|
34529
|
+
field = await read(matcher, "lastIndex");
|
|
34530
|
+
const next = Math.min(normalizeLastIndex(await sandboxNumber(field, budget, context)), string.length);
|
|
34531
|
+
field = void 0;
|
|
34532
|
+
if (next !== end) {
|
|
34533
|
+
append(budget.allocateString(string.slice(end, index)));
|
|
34534
|
+
if (result.length === maximum) return result;
|
|
34535
|
+
end = next;
|
|
34536
|
+
field = await read(match, "length");
|
|
34537
|
+
const length = normalizeLastIndex(await sandboxNumber(field, budget, context));
|
|
34538
|
+
field = void 0;
|
|
34539
|
+
for (let capture = 1; capture < length; capture++) {
|
|
34540
|
+
budget.visitNode();
|
|
34541
|
+
field = await read(match, String(capture));
|
|
34542
|
+
append(field);
|
|
34543
|
+
field = void 0;
|
|
34544
|
+
if (result.length === maximum) return result;
|
|
34545
|
+
}
|
|
34546
|
+
index = end;
|
|
34547
|
+
continue;
|
|
34548
|
+
}
|
|
34549
|
+
}
|
|
34550
|
+
index += unicode && (string.codePointAt(index) ?? 0) > 65535 ? 2 : 1;
|
|
34551
|
+
}
|
|
34552
|
+
append(budget.allocateString(string.slice(end)));
|
|
34553
|
+
return result;
|
|
34554
|
+
} finally {
|
|
34555
|
+
release();
|
|
34556
|
+
}
|
|
34557
|
+
}
|
|
34558
|
+
|
|
34460
34559
|
// packages/safe-js/src/interp/globals/regex.ts
|
|
34461
34560
|
function createRegexGlobals(options) {
|
|
34462
34561
|
const invoke = (construct) => async (args, context) => {
|
|
@@ -34629,6 +34728,17 @@ function createRegexGlobals(options) {
|
|
|
34629
34728
|
writable: true,
|
|
34630
34729
|
configurable: true
|
|
34631
34730
|
});
|
|
34731
|
+
Object.defineProperty(prototype, Symbol.split, {
|
|
34732
|
+
value: createSandboxClosure({
|
|
34733
|
+
guest: true,
|
|
34734
|
+
sandbox: true,
|
|
34735
|
+
name: "[Symbol.split]",
|
|
34736
|
+
length: 2,
|
|
34737
|
+
call: (args, context) => regexSplit(context?.thisValue, args[0], args[1], constructor, options.budget, context)
|
|
34738
|
+
}),
|
|
34739
|
+
writable: true,
|
|
34740
|
+
configurable: true
|
|
34741
|
+
});
|
|
34632
34742
|
for (const name of ["exec", "test", "toString"]) {
|
|
34633
34743
|
Object.defineProperty(prototype, name, {
|
|
34634
34744
|
value: createSandboxClosure({
|
|
@@ -36973,4 +37083,4 @@ export {
|
|
|
36973
37083
|
FileSnapshotBackend,
|
|
36974
37084
|
run
|
|
36975
37085
|
};
|
|
36976
|
-
//# sourceMappingURL=chunk-
|
|
37086
|
+
//# sourceMappingURL=chunk-IBLBXKUC.js.map
|