@poe-platform/safe-js 0.1.190 → 0.1.192
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-JR2ZFJJM.js → chunk-Q6OWZDNT.js} +2 -2
- package/dist/safe-js/chunks/{chunk-YEZOXLY4.js → chunk-SKWFZYFI.js} +246 -14
- package/dist/safe-js/chunks/chunk-SKWFZYFI.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 +1 -0
- package/dist/safe-js/interp/regexp-iterator.d.ts +4 -2
- package/dist/safe-js/snapshot/replay-data.d.ts +2 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-YEZOXLY4.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-JR2ZFJJM.js.map → chunk-Q6OWZDNT.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-SKWFZYFI.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-Q6OWZDNT.js.map
|
|
@@ -2392,6 +2392,7 @@ function parseFlags(flags, guard) {
|
|
|
2392
2392
|
guard.allocate(10);
|
|
2393
2393
|
const parsed = {
|
|
2394
2394
|
global: false,
|
|
2395
|
+
sticky: false,
|
|
2395
2396
|
ignoreCase: false,
|
|
2396
2397
|
multiline: false,
|
|
2397
2398
|
dotAll: false
|
|
@@ -2400,7 +2401,8 @@ function parseFlags(flags, guard) {
|
|
|
2400
2401
|
g: "global",
|
|
2401
2402
|
i: "ignoreCase",
|
|
2402
2403
|
m: "multiline",
|
|
2403
|
-
s: "dotAll"
|
|
2404
|
+
s: "dotAll",
|
|
2405
|
+
y: "sticky"
|
|
2404
2406
|
};
|
|
2405
2407
|
for (let position = 0; position < flags.length; position += 1) {
|
|
2406
2408
|
guard.work(1);
|
|
@@ -6723,9 +6725,13 @@ function isSandboxRegExpIterator(value) {
|
|
|
6723
6725
|
return typeof value === "object" && value !== null && states2.has(value);
|
|
6724
6726
|
}
|
|
6725
6727
|
function restoreSandboxRegExpIterator(state, target = /* @__PURE__ */ Object.create(null)) {
|
|
6728
|
+
if ((state.global !== void 0 || state.unicode !== void 0) && (typeof state.global !== "boolean" || typeof state.unicode !== "boolean"))
|
|
6729
|
+
throw new TypeError("Invalid RegExp iterator modes.");
|
|
6730
|
+
if (state.matcher !== void 0 && (state.matcher === null || typeof state.matcher !== "object"))
|
|
6731
|
+
throw new TypeError("Invalid RegExp iterator matcher.");
|
|
6726
6732
|
if (!state.exhausted && (state.matcher === void 0 || state.input === void 0))
|
|
6727
6733
|
throw new TypeError("A live RegExp iterator requires its matcher and input.");
|
|
6728
|
-
states2.set(target, state.exhausted ? { matcher: void 0, input: void 0, exhausted: true } : { ...state });
|
|
6734
|
+
states2.set(target, state.exhausted ? { ...state, matcher: void 0, input: void 0, exhausted: true } : { ...state });
|
|
6729
6735
|
return target;
|
|
6730
6736
|
}
|
|
6731
6737
|
function regexpIteratorState(value) {
|
|
@@ -7956,11 +7962,14 @@ function serializeHeapReference(value, path, state) {
|
|
|
7956
7962
|
if (isSandboxRegExpIterator(value)) {
|
|
7957
7963
|
const snapshot = regexpIteratorState(value);
|
|
7958
7964
|
const matcher = snapshot.matcher;
|
|
7965
|
+
const serializedMatcher = snapshot.global === void 0 && isSandboxRegex(matcher) ? { kind: "regex", source: matcher.source, flags: matcher.flags, lastIndex: Number(matcher.lastIndex) } : serializeDumpValue(matcher, `${path}.<matcher>`, state);
|
|
7966
|
+
if (serializedMatcher === SKIP_VALUE) throw new TypeError("Unsupported RegExp iterator matcher in public dump.");
|
|
7959
7967
|
const entries = /* @__PURE__ */ Object.create(null);
|
|
7960
7968
|
state.heap[String(id)] = {
|
|
7961
7969
|
kind: "regexp-iterator",
|
|
7962
7970
|
exhausted: snapshot.exhausted,
|
|
7963
|
-
matcher:
|
|
7971
|
+
matcher: serializedMatcher,
|
|
7972
|
+
...snapshot.global === void 0 ? {} : { global: snapshot.global, unicode: snapshot.unicode },
|
|
7964
7973
|
input: snapshot.input ?? { kind: "undefined" },
|
|
7965
7974
|
entries,
|
|
7966
7975
|
symbolEntries: serializeSymbolProperties(value, (entry) => {
|
|
@@ -8442,6 +8451,8 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
8442
8451
|
}
|
|
8443
8452
|
if (record2.kind === "set") requireArray(record2.values, `${path}.values`, state);
|
|
8444
8453
|
if (record2.kind === "regexp-iterator") {
|
|
8454
|
+
if ((record2.global !== void 0 || record2.unicode !== void 0) && (typeof record2.global !== "boolean" || typeof record2.unicode !== "boolean"))
|
|
8455
|
+
fail("invalidValue", path, "invalid RegExp iterator modes");
|
|
8445
8456
|
if (typeof record2.exhausted !== "boolean") fail("invalidValue", `${path}.exhausted`, "invalid iterator exhaustion");
|
|
8446
8457
|
if (!Object.hasOwn(record2, "matcher") || !Object.hasOwn(record2, "input")) fail("invalidValue", path, "missing RegExp iterator state");
|
|
8447
8458
|
requireRecord(record2.entries, `${path}.entries`);
|
|
@@ -9290,7 +9301,7 @@ async function withRunResources(signal, execute) {
|
|
|
9290
9301
|
|
|
9291
9302
|
// packages/safe-js/src/interp/regex/engine.ts
|
|
9292
9303
|
function matchRegex(pattern, input, lastIndex = 0) {
|
|
9293
|
-
const startIndex = pattern.flags.global ? normalizeLastIndex(lastIndex) : 0;
|
|
9304
|
+
const startIndex = pattern.flags.global || pattern.flags.sticky ? normalizeLastIndex(lastIndex) : 0;
|
|
9294
9305
|
return matchRegexFrom(pattern, input, startIndex);
|
|
9295
9306
|
}
|
|
9296
9307
|
function matchRegexFrom(pattern, input, startIndex) {
|
|
@@ -9308,6 +9319,7 @@ function matchRegexFrom(pattern, input, startIndex) {
|
|
|
9308
9319
|
if (!result.done) {
|
|
9309
9320
|
return toRegexMatch(input, attempt, result.value);
|
|
9310
9321
|
}
|
|
9322
|
+
if (pattern.flags.sticky) break;
|
|
9311
9323
|
}
|
|
9312
9324
|
return null;
|
|
9313
9325
|
}
|
|
@@ -16707,7 +16719,7 @@ async function regexToString(target, budget, context) {
|
|
|
16707
16719
|
function executeRegex(target, input, lastIndex) {
|
|
16708
16720
|
const pattern = getSandboxRegexPattern(target);
|
|
16709
16721
|
const match = matchRegex(pattern, input, lastIndex);
|
|
16710
|
-
if (pattern.flags.global) {
|
|
16722
|
+
if (pattern.flags.global || pattern.flags.sticky) {
|
|
16711
16723
|
target.lastIndex = match === null ? 0 : match.index + match.text.length;
|
|
16712
16724
|
}
|
|
16713
16725
|
return match;
|
|
@@ -16727,9 +16739,10 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16727
16739
|
budget?.visitNode();
|
|
16728
16740
|
if (state.exhausted) return { value: void 0, done: true };
|
|
16729
16741
|
const matcher = state.matcher;
|
|
16742
|
+
if (!isSandboxRegex(matcher)) throw new TypeError("Custom RegExp iterator execution requires a sandbox context.");
|
|
16730
16743
|
const input = state.input;
|
|
16731
16744
|
const match = executeRegex(matcher, input, Number(matcher.lastIndex));
|
|
16732
|
-
if (match === null || !matcher.flags.includes("g")) {
|
|
16745
|
+
if (match === null || !(state.global ?? matcher.flags.includes("g"))) {
|
|
16733
16746
|
state.exhausted = true;
|
|
16734
16747
|
state.matcher = void 0;
|
|
16735
16748
|
state.input = void 0;
|
|
@@ -16737,13 +16750,54 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16737
16750
|
if (match === null) return { value: void 0, done: true };
|
|
16738
16751
|
if (!state.exhausted && match.text.length === 0) {
|
|
16739
16752
|
const index = Number(matcher.lastIndex);
|
|
16740
|
-
const unicode = matcher.flags.includes("u") || matcher.flags.includes("v");
|
|
16753
|
+
const unicode = state.unicode ?? (matcher.flags.includes("u") || matcher.flags.includes("v"));
|
|
16741
16754
|
const codePoint = input.codePointAt(index);
|
|
16742
16755
|
matcher.lastIndex = index + (unicode && codePoint !== void 0 && codePoint > 65535 ? 2 : 1);
|
|
16743
16756
|
}
|
|
16744
16757
|
budget?.allocateArrayLength(match.captures.length + 1);
|
|
16745
16758
|
return { value: toMatchArray(match, input), done: false };
|
|
16746
16759
|
}
|
|
16760
|
+
async function nextObservableRegExpIterator(iterator, budget, context) {
|
|
16761
|
+
const state = regexpIteratorState(iterator);
|
|
16762
|
+
if (state.exhausted) return { value: void 0, done: true };
|
|
16763
|
+
const matcher = state.matcher;
|
|
16764
|
+
if (isSandboxRegex(matcher) && !hasRegexPropertyOverride(matcher, ["exec"], budget) && (matcher.lastIndex === null || typeof matcher.lastIndex !== "object"))
|
|
16765
|
+
return nextRegExpIterator(iterator, budget);
|
|
16766
|
+
const input = state.input;
|
|
16767
|
+
let result;
|
|
16768
|
+
let field;
|
|
16769
|
+
const release = retainValues(budget, () => [iterator, matcher, input, result, field]);
|
|
16770
|
+
const read = (value, key) => {
|
|
16771
|
+
if (context.getProperty !== void 0) return context.getProperty(value, key);
|
|
16772
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
16773
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
16774
|
+
};
|
|
16775
|
+
try {
|
|
16776
|
+
budget.visitNode();
|
|
16777
|
+
result = await regexExec(matcher, input, budget, context);
|
|
16778
|
+
const global = state.global ?? (isSandboxRegex(matcher) && matcher.flags.includes("g"));
|
|
16779
|
+
if (result === null || !global) {
|
|
16780
|
+
state.exhausted = true;
|
|
16781
|
+
state.matcher = void 0;
|
|
16782
|
+
state.input = void 0;
|
|
16783
|
+
return result === null ? { value: void 0, done: true } : { value: result, done: false };
|
|
16784
|
+
}
|
|
16785
|
+
field = await read(result, "0");
|
|
16786
|
+
const text = await sandboxString(field, budget, context);
|
|
16787
|
+
field = void 0;
|
|
16788
|
+
if (text.length === 0) {
|
|
16789
|
+
field = await read(matcher, "lastIndex");
|
|
16790
|
+
const index = normalizeLastIndex(await sandboxNumber(field, budget, context));
|
|
16791
|
+
field = void 0;
|
|
16792
|
+
const unicode = state.unicode ?? (isSandboxRegex(matcher) && (matcher.flags.includes("u") || matcher.flags.includes("v")));
|
|
16793
|
+
const point = input.codePointAt(index);
|
|
16794
|
+
await setSandboxProperty(matcher, "lastIndex", index + (unicode && point !== void 0 && point > 65535 ? 2 : 1), budget, true, context);
|
|
16795
|
+
}
|
|
16796
|
+
return { value: result, done: false };
|
|
16797
|
+
} finally {
|
|
16798
|
+
release();
|
|
16799
|
+
}
|
|
16800
|
+
}
|
|
16747
16801
|
function getRegExpIteratorMember(property, budget) {
|
|
16748
16802
|
if (property === Symbol.toStringTag) return "RegExp String Iterator";
|
|
16749
16803
|
if (property === Symbol.iterator) return createSandboxClosure({
|
|
@@ -16759,7 +16813,7 @@ function getRegExpIteratorMember(property, budget) {
|
|
|
16759
16813
|
const receiver = context?.thisValue;
|
|
16760
16814
|
if (!isSandboxRegExpIterator(receiver))
|
|
16761
16815
|
throw new TypeError("RegExp string iterator next requires a matching receiver.");
|
|
16762
|
-
return nextRegExpIterator(receiver, budget);
|
|
16816
|
+
return context === void 0 ? nextRegExpIterator(receiver, budget) : nextObservableRegExpIterator(receiver, budget, context);
|
|
16763
16817
|
}
|
|
16764
16818
|
});
|
|
16765
16819
|
}
|
|
@@ -16947,8 +17001,11 @@ function getSandboxIterator(value, budget, context) {
|
|
|
16947
17001
|
}
|
|
16948
17002
|
if (isSandboxCollectionIterator(value))
|
|
16949
17003
|
return { next: () => nextCollectionIterator(value, budget), snapshotIndex: () => 0 };
|
|
16950
|
-
if (isSandboxRegExpIterator(value))
|
|
17004
|
+
if (isSandboxRegExpIterator(value)) {
|
|
17005
|
+
if (context !== void 0 && budget !== void 0)
|
|
17006
|
+
return { asynchronous: true, next: () => nextObservableRegExpIterator(value, budget, context), snapshotIndex: () => 0 };
|
|
16951
17007
|
return { next: () => nextRegExpIterator(value, budget), snapshotIndex: () => 0 };
|
|
17008
|
+
}
|
|
16952
17009
|
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
16953
17010
|
if (isFloat32Array(value)) {
|
|
16954
17011
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
@@ -17755,7 +17812,16 @@ function encodeReplayData(value, options = {}) {
|
|
|
17755
17812
|
}
|
|
17756
17813
|
let symbolIndex = 0;
|
|
17757
17814
|
const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
|
|
17758
|
-
nodes[id] = {
|
|
17815
|
+
nodes[id] = {
|
|
17816
|
+
kind: "regexp-iterator",
|
|
17817
|
+
matcher: child(snapshot.matcher, "<matcher>"),
|
|
17818
|
+
input: child(snapshot.input, "<input>"),
|
|
17819
|
+
exhausted: snapshot.exhausted,
|
|
17820
|
+
properties,
|
|
17821
|
+
extensible: Object.isExtensible(entry),
|
|
17822
|
+
symbolEntries,
|
|
17823
|
+
...snapshot.global === void 0 ? {} : { global: snapshot.global, unicode: snapshot.unicode }
|
|
17824
|
+
};
|
|
17759
17825
|
} else if (isSandboxCollectionIterator(entry)) {
|
|
17760
17826
|
const snapshot = snapshotCollectionIterator(entry);
|
|
17761
17827
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -17953,9 +18019,15 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
17953
18019
|
restored.set(id, result3);
|
|
17954
18020
|
const matcher = child(own(node, "matcher"));
|
|
17955
18021
|
const input2 = child(own(node, "input"));
|
|
17956
|
-
if (
|
|
18022
|
+
if ((node.global !== void 0 || node.unicode !== void 0) && (typeof node.global !== "boolean" || typeof node.unicode !== "boolean")) throw new TypeError("Invalid replay RegExp iterator modes.");
|
|
18023
|
+
if (matcher !== void 0 && (node.global === void 0 ? !isSandboxRegex(matcher) : matcher === null || typeof matcher !== "object")) throw new TypeError("Invalid replay RegExp iterator matcher.");
|
|
17957
18024
|
if (input2 !== void 0 && typeof input2 !== "string") throw new TypeError("Invalid replay RegExp iterator input.");
|
|
17958
|
-
restoreSandboxRegExpIterator({
|
|
18025
|
+
restoreSandboxRegExpIterator({
|
|
18026
|
+
matcher,
|
|
18027
|
+
input: input2,
|
|
18028
|
+
exhausted,
|
|
18029
|
+
...node.global === void 0 ? {} : { global: node.global, unicode: node.unicode }
|
|
18030
|
+
}, result3);
|
|
17959
18031
|
defineProperties(result3, record(own(node, "properties")), child, node.symbolEntries);
|
|
17960
18032
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
17961
18033
|
return result3;
|
|
@@ -21472,7 +21544,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
21472
21544
|
const copy = restoreSandboxRegExpIterator({ matcher: void 0, input: void 0, exhausted: true });
|
|
21473
21545
|
state.seen.set(value, copy);
|
|
21474
21546
|
const matcher = copyToSandbox(snapshot.matcher, state, `${path}.<matcher>`, true, depth + 1);
|
|
21475
|
-
if (matcher !== void 0 && !isSandboxRegex(matcher)) throw new TypeError("Invalid RegExp iterator matcher.");
|
|
21547
|
+
if (matcher !== void 0 && (snapshot.global === void 0 ? !isSandboxRegex(matcher) : matcher === null || typeof matcher !== "object")) throw new TypeError("Invalid RegExp iterator matcher.");
|
|
21476
21548
|
restoreSandboxRegExpIterator({ ...snapshot, matcher }, copy);
|
|
21477
21549
|
for (const entry of getEnumerableObjectEntries(value, path)) {
|
|
21478
21550
|
defineOwnDataProperty(copy, entry.key, copyToSandbox(entry.value, state, joinPath2(path, entry.key), true, depth + 1));
|
|
@@ -34388,6 +34460,90 @@ function defineDataProperty2(target, key, value) {
|
|
|
34388
34460
|
});
|
|
34389
34461
|
}
|
|
34390
34462
|
|
|
34463
|
+
// packages/safe-js/src/interp/methods/regex-split.ts
|
|
34464
|
+
async function regexSplit(target, input, limit, constructor, budget, context) {
|
|
34465
|
+
if (target === null || typeof target !== "object") throw new TypeError("RegExp split requires an object receiver.");
|
|
34466
|
+
let string;
|
|
34467
|
+
let species;
|
|
34468
|
+
let field;
|
|
34469
|
+
let flags;
|
|
34470
|
+
let matcher;
|
|
34471
|
+
let match;
|
|
34472
|
+
const result = [];
|
|
34473
|
+
const release = retainValues(budget, () => [target, input, limit, string, species, field, flags, matcher, match, result]);
|
|
34474
|
+
const read = (value, key) => {
|
|
34475
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
34476
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
34477
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
34478
|
+
};
|
|
34479
|
+
const append = (value) => {
|
|
34480
|
+
budget.allocateArrayLength(result.length + 1);
|
|
34481
|
+
result.push(value);
|
|
34482
|
+
};
|
|
34483
|
+
try {
|
|
34484
|
+
string = await sandboxString(input, budget, context);
|
|
34485
|
+
input = void 0;
|
|
34486
|
+
field = await read(target, "constructor");
|
|
34487
|
+
species = constructor;
|
|
34488
|
+
if (field !== void 0) {
|
|
34489
|
+
if (field === null || typeof field !== "object") throw new TypeError("Invalid RegExp species constructor.");
|
|
34490
|
+
species = await read(field, Symbol.species);
|
|
34491
|
+
if (species === null || species === void 0) species = constructor;
|
|
34492
|
+
}
|
|
34493
|
+
field = void 0;
|
|
34494
|
+
if (!isSandboxClosure(species) || species.construct === void 0) throw new TypeError("RegExp species must be a constructor.");
|
|
34495
|
+
field = await read(target, "flags");
|
|
34496
|
+
flags = await sandboxString(field, budget, context);
|
|
34497
|
+
field = void 0;
|
|
34498
|
+
const unicode = flags.includes("u") || flags.includes("v");
|
|
34499
|
+
if (!flags.includes("y")) flags = budget.allocateString(flags + "y");
|
|
34500
|
+
matcher = await invokeBuiltinClosure(species, [target, flags], budget, context, void 0, true);
|
|
34501
|
+
const maximum = limit === void 0 ? 2 ** 32 - 1 : await sandboxNumber(limit, budget, context) >>> 0;
|
|
34502
|
+
limit = void 0;
|
|
34503
|
+
if (maximum === 0) return result;
|
|
34504
|
+
if (string.length === 0) {
|
|
34505
|
+
match = await regexExec(matcher, string, budget, context);
|
|
34506
|
+
if (match === null) append(string);
|
|
34507
|
+
return result;
|
|
34508
|
+
}
|
|
34509
|
+
let end = 0;
|
|
34510
|
+
let index = 0;
|
|
34511
|
+
while (index < string.length) {
|
|
34512
|
+
budget.visitNode();
|
|
34513
|
+
match = void 0;
|
|
34514
|
+
await setSandboxProperty(matcher, "lastIndex", index, budget, true, context);
|
|
34515
|
+
match = await regexExec(matcher, string, budget, context);
|
|
34516
|
+
if (match !== null) {
|
|
34517
|
+
field = await read(matcher, "lastIndex");
|
|
34518
|
+
const next = Math.min(normalizeLastIndex(await sandboxNumber(field, budget, context)), string.length);
|
|
34519
|
+
field = void 0;
|
|
34520
|
+
if (next !== end) {
|
|
34521
|
+
append(budget.allocateString(string.slice(end, index)));
|
|
34522
|
+
if (result.length === maximum) return result;
|
|
34523
|
+
end = next;
|
|
34524
|
+
field = await read(match, "length");
|
|
34525
|
+
const length = normalizeLastIndex(await sandboxNumber(field, budget, context));
|
|
34526
|
+
field = void 0;
|
|
34527
|
+
for (let capture = 1; capture < length; capture++) {
|
|
34528
|
+
budget.visitNode();
|
|
34529
|
+
field = await read(match, String(capture));
|
|
34530
|
+
append(field);
|
|
34531
|
+
field = void 0;
|
|
34532
|
+
if (result.length === maximum) return result;
|
|
34533
|
+
}
|
|
34534
|
+
index = end;
|
|
34535
|
+
continue;
|
|
34536
|
+
}
|
|
34537
|
+
}
|
|
34538
|
+
index += unicode && (string.codePointAt(index) ?? 0) > 65535 ? 2 : 1;
|
|
34539
|
+
}
|
|
34540
|
+
append(budget.allocateString(string.slice(end)));
|
|
34541
|
+
return result;
|
|
34542
|
+
} finally {
|
|
34543
|
+
release();
|
|
34544
|
+
}
|
|
34545
|
+
}
|
|
34546
|
+
|
|
34391
34547
|
// packages/safe-js/src/interp/globals/regex.ts
|
|
34392
34548
|
function createRegexGlobals(options) {
|
|
34393
34549
|
const invoke = (construct) => async (args, context) => {
|
|
@@ -34453,6 +34609,15 @@ function createRegexGlobals(options) {
|
|
|
34453
34609
|
};
|
|
34454
34610
|
const constructor = createSandboxClosure({ guest: true, sandbox: true, name: "RegExp", length: 2, call: invoke(false), construct: invoke(true) });
|
|
34455
34611
|
const prototype = /* @__PURE__ */ Object.create(null);
|
|
34612
|
+
Object.defineProperty(materializeFunctionProperties(constructor), Symbol.species, {
|
|
34613
|
+
get: accessorAdapter(createSandboxClosure({
|
|
34614
|
+
sandbox: true,
|
|
34615
|
+
name: "get [Symbol.species]",
|
|
34616
|
+
length: 0,
|
|
34617
|
+
call: (_args, context) => context?.thisValue
|
|
34618
|
+
}), "get"),
|
|
34619
|
+
configurable: true
|
|
34620
|
+
});
|
|
34456
34621
|
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
|
|
34457
34622
|
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
34458
34623
|
Object.defineProperty(prototype, Symbol.search, {
|
|
@@ -34495,6 +34660,73 @@ function createRegexGlobals(options) {
|
|
|
34495
34660
|
writable: true,
|
|
34496
34661
|
configurable: true
|
|
34497
34662
|
});
|
|
34663
|
+
Object.defineProperty(prototype, Symbol.matchAll, {
|
|
34664
|
+
value: createSandboxClosure({
|
|
34665
|
+
guest: true,
|
|
34666
|
+
sandbox: true,
|
|
34667
|
+
name: "[Symbol.matchAll]",
|
|
34668
|
+
length: 1,
|
|
34669
|
+
call: async (args, context) => {
|
|
34670
|
+
const target = context?.thisValue;
|
|
34671
|
+
if (target === null || typeof target !== "object") throw new TypeError("RegExp matchAll requires an object receiver.");
|
|
34672
|
+
let input = args[0];
|
|
34673
|
+
let string;
|
|
34674
|
+
let species;
|
|
34675
|
+
let field;
|
|
34676
|
+
let flags;
|
|
34677
|
+
let matcher;
|
|
34678
|
+
const release = retainValues(options.budget, () => [target, input, string, species, field, flags, matcher]);
|
|
34679
|
+
const read = (value, key) => {
|
|
34680
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
34681
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, options.budget);
|
|
34682
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
34683
|
+
};
|
|
34684
|
+
try {
|
|
34685
|
+
string = await sandboxString(input, options.budget, context);
|
|
34686
|
+
input = void 0;
|
|
34687
|
+
field = await read(target, "constructor");
|
|
34688
|
+
species = constructor;
|
|
34689
|
+
if (field !== void 0) {
|
|
34690
|
+
if (field === null || typeof field !== "object") throw new TypeError("Invalid RegExp species constructor.");
|
|
34691
|
+
species = await read(field, Symbol.species);
|
|
34692
|
+
if (species === null || species === void 0) species = constructor;
|
|
34693
|
+
}
|
|
34694
|
+
field = void 0;
|
|
34695
|
+
if (!isSandboxClosure(species) || species.construct === void 0) throw new TypeError("RegExp species must be a constructor.");
|
|
34696
|
+
field = await read(target, "flags");
|
|
34697
|
+
flags = await sandboxString(field, options.budget, context);
|
|
34698
|
+
field = void 0;
|
|
34699
|
+
matcher = await invokeBuiltinClosure(species, [target, flags], options.budget, context, void 0, true);
|
|
34700
|
+
field = await read(target, "lastIndex");
|
|
34701
|
+
const cursor = normalizeLastIndex(await sandboxNumber(field, options.budget, context));
|
|
34702
|
+
field = void 0;
|
|
34703
|
+
await setSandboxProperty(matcher, "lastIndex", cursor, options.budget, true, context);
|
|
34704
|
+
return restoreSandboxRegExpIterator({
|
|
34705
|
+
matcher,
|
|
34706
|
+
input: string,
|
|
34707
|
+
exhausted: false,
|
|
34708
|
+
global: flags.includes("g"),
|
|
34709
|
+
unicode: flags.includes("u") || flags.includes("v")
|
|
34710
|
+
});
|
|
34711
|
+
} finally {
|
|
34712
|
+
release();
|
|
34713
|
+
}
|
|
34714
|
+
}
|
|
34715
|
+
}),
|
|
34716
|
+
writable: true,
|
|
34717
|
+
configurable: true
|
|
34718
|
+
});
|
|
34719
|
+
Object.defineProperty(prototype, Symbol.split, {
|
|
34720
|
+
value: createSandboxClosure({
|
|
34721
|
+
guest: true,
|
|
34722
|
+
sandbox: true,
|
|
34723
|
+
name: "[Symbol.split]",
|
|
34724
|
+
length: 2,
|
|
34725
|
+
call: (args, context) => regexSplit(context?.thisValue, args[0], args[1], constructor, options.budget, context)
|
|
34726
|
+
}),
|
|
34727
|
+
writable: true,
|
|
34728
|
+
configurable: true
|
|
34729
|
+
});
|
|
34498
34730
|
for (const name of ["exec", "test", "toString"]) {
|
|
34499
34731
|
Object.defineProperty(prototype, name, {
|
|
34500
34732
|
value: createSandboxClosure({
|
|
@@ -36839,4 +37071,4 @@ export {
|
|
|
36839
37071
|
FileSnapshotBackend,
|
|
36840
37072
|
run
|
|
36841
37073
|
};
|
|
36842
|
-
//# sourceMappingURL=chunk-
|
|
37074
|
+
//# sourceMappingURL=chunk-SKWFZYFI.js.map
|