@poe-platform/safe-js 0.1.190 → 0.1.191
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-YEZOXLY4.js → chunk-DXCKCEDV.js} +145 -11
- package/dist/safe-js/chunks/chunk-DXCKCEDV.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-JR2ZFJJM.js → chunk-YGFHNJKK.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/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-YGFHNJKK.js.map} +0 -0
|
@@ -6723,9 +6723,13 @@ function isSandboxRegExpIterator(value) {
|
|
|
6723
6723
|
return typeof value === "object" && value !== null && states2.has(value);
|
|
6724
6724
|
}
|
|
6725
6725
|
function restoreSandboxRegExpIterator(state, target = /* @__PURE__ */ Object.create(null)) {
|
|
6726
|
+
if ((state.global !== void 0 || state.unicode !== void 0) && (typeof state.global !== "boolean" || typeof state.unicode !== "boolean"))
|
|
6727
|
+
throw new TypeError("Invalid RegExp iterator modes.");
|
|
6728
|
+
if (state.matcher !== void 0 && (state.matcher === null || typeof state.matcher !== "object"))
|
|
6729
|
+
throw new TypeError("Invalid RegExp iterator matcher.");
|
|
6726
6730
|
if (!state.exhausted && (state.matcher === void 0 || state.input === void 0))
|
|
6727
6731
|
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 });
|
|
6732
|
+
states2.set(target, state.exhausted ? { ...state, matcher: void 0, input: void 0, exhausted: true } : { ...state });
|
|
6729
6733
|
return target;
|
|
6730
6734
|
}
|
|
6731
6735
|
function regexpIteratorState(value) {
|
|
@@ -7956,11 +7960,14 @@ function serializeHeapReference(value, path, state) {
|
|
|
7956
7960
|
if (isSandboxRegExpIterator(value)) {
|
|
7957
7961
|
const snapshot = regexpIteratorState(value);
|
|
7958
7962
|
const matcher = snapshot.matcher;
|
|
7963
|
+
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);
|
|
7964
|
+
if (serializedMatcher === SKIP_VALUE) throw new TypeError("Unsupported RegExp iterator matcher in public dump.");
|
|
7959
7965
|
const entries = /* @__PURE__ */ Object.create(null);
|
|
7960
7966
|
state.heap[String(id)] = {
|
|
7961
7967
|
kind: "regexp-iterator",
|
|
7962
7968
|
exhausted: snapshot.exhausted,
|
|
7963
|
-
matcher:
|
|
7969
|
+
matcher: serializedMatcher,
|
|
7970
|
+
...snapshot.global === void 0 ? {} : { global: snapshot.global, unicode: snapshot.unicode },
|
|
7964
7971
|
input: snapshot.input ?? { kind: "undefined" },
|
|
7965
7972
|
entries,
|
|
7966
7973
|
symbolEntries: serializeSymbolProperties(value, (entry) => {
|
|
@@ -8442,6 +8449,8 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
8442
8449
|
}
|
|
8443
8450
|
if (record2.kind === "set") requireArray(record2.values, `${path}.values`, state);
|
|
8444
8451
|
if (record2.kind === "regexp-iterator") {
|
|
8452
|
+
if ((record2.global !== void 0 || record2.unicode !== void 0) && (typeof record2.global !== "boolean" || typeof record2.unicode !== "boolean"))
|
|
8453
|
+
fail("invalidValue", path, "invalid RegExp iterator modes");
|
|
8445
8454
|
if (typeof record2.exhausted !== "boolean") fail("invalidValue", `${path}.exhausted`, "invalid iterator exhaustion");
|
|
8446
8455
|
if (!Object.hasOwn(record2, "matcher") || !Object.hasOwn(record2, "input")) fail("invalidValue", path, "missing RegExp iterator state");
|
|
8447
8456
|
requireRecord(record2.entries, `${path}.entries`);
|
|
@@ -16727,9 +16736,10 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16727
16736
|
budget?.visitNode();
|
|
16728
16737
|
if (state.exhausted) return { value: void 0, done: true };
|
|
16729
16738
|
const matcher = state.matcher;
|
|
16739
|
+
if (!isSandboxRegex(matcher)) throw new TypeError("Custom RegExp iterator execution requires a sandbox context.");
|
|
16730
16740
|
const input = state.input;
|
|
16731
16741
|
const match = executeRegex(matcher, input, Number(matcher.lastIndex));
|
|
16732
|
-
if (match === null || !matcher.flags.includes("g")) {
|
|
16742
|
+
if (match === null || !(state.global ?? matcher.flags.includes("g"))) {
|
|
16733
16743
|
state.exhausted = true;
|
|
16734
16744
|
state.matcher = void 0;
|
|
16735
16745
|
state.input = void 0;
|
|
@@ -16737,13 +16747,54 @@ function nextRegExpIterator(iterator, budget) {
|
|
|
16737
16747
|
if (match === null) return { value: void 0, done: true };
|
|
16738
16748
|
if (!state.exhausted && match.text.length === 0) {
|
|
16739
16749
|
const index = Number(matcher.lastIndex);
|
|
16740
|
-
const unicode = matcher.flags.includes("u") || matcher.flags.includes("v");
|
|
16750
|
+
const unicode = state.unicode ?? (matcher.flags.includes("u") || matcher.flags.includes("v"));
|
|
16741
16751
|
const codePoint = input.codePointAt(index);
|
|
16742
16752
|
matcher.lastIndex = index + (unicode && codePoint !== void 0 && codePoint > 65535 ? 2 : 1);
|
|
16743
16753
|
}
|
|
16744
16754
|
budget?.allocateArrayLength(match.captures.length + 1);
|
|
16745
16755
|
return { value: toMatchArray(match, input), done: false };
|
|
16746
16756
|
}
|
|
16757
|
+
async function nextObservableRegExpIterator(iterator, budget, context) {
|
|
16758
|
+
const state = regexpIteratorState(iterator);
|
|
16759
|
+
if (state.exhausted) return { value: void 0, done: true };
|
|
16760
|
+
const matcher = state.matcher;
|
|
16761
|
+
if (isSandboxRegex(matcher) && !hasRegexPropertyOverride(matcher, ["exec"], budget) && (matcher.lastIndex === null || typeof matcher.lastIndex !== "object"))
|
|
16762
|
+
return nextRegExpIterator(iterator, budget);
|
|
16763
|
+
const input = state.input;
|
|
16764
|
+
let result;
|
|
16765
|
+
let field;
|
|
16766
|
+
const release = retainValues(budget, () => [iterator, matcher, input, result, field]);
|
|
16767
|
+
const read = (value, key) => {
|
|
16768
|
+
if (context.getProperty !== void 0) return context.getProperty(value, key);
|
|
16769
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
16770
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
16771
|
+
};
|
|
16772
|
+
try {
|
|
16773
|
+
budget.visitNode();
|
|
16774
|
+
result = await regexExec(matcher, input, budget, context);
|
|
16775
|
+
const global = state.global ?? (isSandboxRegex(matcher) && matcher.flags.includes("g"));
|
|
16776
|
+
if (result === null || !global) {
|
|
16777
|
+
state.exhausted = true;
|
|
16778
|
+
state.matcher = void 0;
|
|
16779
|
+
state.input = void 0;
|
|
16780
|
+
return result === null ? { value: void 0, done: true } : { value: result, done: false };
|
|
16781
|
+
}
|
|
16782
|
+
field = await read(result, "0");
|
|
16783
|
+
const text = await sandboxString(field, budget, context);
|
|
16784
|
+
field = void 0;
|
|
16785
|
+
if (text.length === 0) {
|
|
16786
|
+
field = await read(matcher, "lastIndex");
|
|
16787
|
+
const index = normalizeLastIndex(await sandboxNumber(field, budget, context));
|
|
16788
|
+
field = void 0;
|
|
16789
|
+
const unicode = state.unicode ?? (isSandboxRegex(matcher) && (matcher.flags.includes("u") || matcher.flags.includes("v")));
|
|
16790
|
+
const point = input.codePointAt(index);
|
|
16791
|
+
await setSandboxProperty(matcher, "lastIndex", index + (unicode && point !== void 0 && point > 65535 ? 2 : 1), budget, true, context);
|
|
16792
|
+
}
|
|
16793
|
+
return { value: result, done: false };
|
|
16794
|
+
} finally {
|
|
16795
|
+
release();
|
|
16796
|
+
}
|
|
16797
|
+
}
|
|
16747
16798
|
function getRegExpIteratorMember(property, budget) {
|
|
16748
16799
|
if (property === Symbol.toStringTag) return "RegExp String Iterator";
|
|
16749
16800
|
if (property === Symbol.iterator) return createSandboxClosure({
|
|
@@ -16759,7 +16810,7 @@ function getRegExpIteratorMember(property, budget) {
|
|
|
16759
16810
|
const receiver = context?.thisValue;
|
|
16760
16811
|
if (!isSandboxRegExpIterator(receiver))
|
|
16761
16812
|
throw new TypeError("RegExp string iterator next requires a matching receiver.");
|
|
16762
|
-
return nextRegExpIterator(receiver, budget);
|
|
16813
|
+
return context === void 0 ? nextRegExpIterator(receiver, budget) : nextObservableRegExpIterator(receiver, budget, context);
|
|
16763
16814
|
}
|
|
16764
16815
|
});
|
|
16765
16816
|
}
|
|
@@ -16947,8 +16998,11 @@ function getSandboxIterator(value, budget, context) {
|
|
|
16947
16998
|
}
|
|
16948
16999
|
if (isSandboxCollectionIterator(value))
|
|
16949
17000
|
return { next: () => nextCollectionIterator(value, budget), snapshotIndex: () => 0 };
|
|
16950
|
-
if (isSandboxRegExpIterator(value))
|
|
17001
|
+
if (isSandboxRegExpIterator(value)) {
|
|
17002
|
+
if (context !== void 0 && budget !== void 0)
|
|
17003
|
+
return { asynchronous: true, next: () => nextObservableRegExpIterator(value, budget, context), snapshotIndex: () => 0 };
|
|
16951
17004
|
return { next: () => nextRegExpIterator(value, budget), snapshotIndex: () => 0 };
|
|
17005
|
+
}
|
|
16952
17006
|
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
16953
17007
|
if (isFloat32Array(value)) {
|
|
16954
17008
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
@@ -17755,7 +17809,16 @@ function encodeReplayData(value, options = {}) {
|
|
|
17755
17809
|
}
|
|
17756
17810
|
let symbolIndex = 0;
|
|
17757
17811
|
const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
|
|
17758
|
-
nodes[id] = {
|
|
17812
|
+
nodes[id] = {
|
|
17813
|
+
kind: "regexp-iterator",
|
|
17814
|
+
matcher: child(snapshot.matcher, "<matcher>"),
|
|
17815
|
+
input: child(snapshot.input, "<input>"),
|
|
17816
|
+
exhausted: snapshot.exhausted,
|
|
17817
|
+
properties,
|
|
17818
|
+
extensible: Object.isExtensible(entry),
|
|
17819
|
+
symbolEntries,
|
|
17820
|
+
...snapshot.global === void 0 ? {} : { global: snapshot.global, unicode: snapshot.unicode }
|
|
17821
|
+
};
|
|
17759
17822
|
} else if (isSandboxCollectionIterator(entry)) {
|
|
17760
17823
|
const snapshot = snapshotCollectionIterator(entry);
|
|
17761
17824
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -17953,9 +18016,15 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
17953
18016
|
restored.set(id, result3);
|
|
17954
18017
|
const matcher = child(own(node, "matcher"));
|
|
17955
18018
|
const input2 = child(own(node, "input"));
|
|
17956
|
-
if (
|
|
18019
|
+
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.");
|
|
18020
|
+
if (matcher !== void 0 && (node.global === void 0 ? !isSandboxRegex(matcher) : matcher === null || typeof matcher !== "object")) throw new TypeError("Invalid replay RegExp iterator matcher.");
|
|
17957
18021
|
if (input2 !== void 0 && typeof input2 !== "string") throw new TypeError("Invalid replay RegExp iterator input.");
|
|
17958
|
-
restoreSandboxRegExpIterator({
|
|
18022
|
+
restoreSandboxRegExpIterator({
|
|
18023
|
+
matcher,
|
|
18024
|
+
input: input2,
|
|
18025
|
+
exhausted,
|
|
18026
|
+
...node.global === void 0 ? {} : { global: node.global, unicode: node.unicode }
|
|
18027
|
+
}, result3);
|
|
17959
18028
|
defineProperties(result3, record(own(node, "properties")), child, node.symbolEntries);
|
|
17960
18029
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
17961
18030
|
return result3;
|
|
@@ -21472,7 +21541,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
21472
21541
|
const copy = restoreSandboxRegExpIterator({ matcher: void 0, input: void 0, exhausted: true });
|
|
21473
21542
|
state.seen.set(value, copy);
|
|
21474
21543
|
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.");
|
|
21544
|
+
if (matcher !== void 0 && (snapshot.global === void 0 ? !isSandboxRegex(matcher) : matcher === null || typeof matcher !== "object")) throw new TypeError("Invalid RegExp iterator matcher.");
|
|
21476
21545
|
restoreSandboxRegExpIterator({ ...snapshot, matcher }, copy);
|
|
21477
21546
|
for (const entry of getEnumerableObjectEntries(value, path)) {
|
|
21478
21547
|
defineOwnDataProperty(copy, entry.key, copyToSandbox(entry.value, state, joinPath2(path, entry.key), true, depth + 1));
|
|
@@ -34453,6 +34522,15 @@ function createRegexGlobals(options) {
|
|
|
34453
34522
|
};
|
|
34454
34523
|
const constructor = createSandboxClosure({ guest: true, sandbox: true, name: "RegExp", length: 2, call: invoke(false), construct: invoke(true) });
|
|
34455
34524
|
const prototype = /* @__PURE__ */ Object.create(null);
|
|
34525
|
+
Object.defineProperty(materializeFunctionProperties(constructor), Symbol.species, {
|
|
34526
|
+
get: accessorAdapter(createSandboxClosure({
|
|
34527
|
+
sandbox: true,
|
|
34528
|
+
name: "get [Symbol.species]",
|
|
34529
|
+
length: 0,
|
|
34530
|
+
call: (_args, context) => context?.thisValue
|
|
34531
|
+
}), "get"),
|
|
34532
|
+
configurable: true
|
|
34533
|
+
});
|
|
34456
34534
|
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
|
|
34457
34535
|
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
34458
34536
|
Object.defineProperty(prototype, Symbol.search, {
|
|
@@ -34495,6 +34573,62 @@ function createRegexGlobals(options) {
|
|
|
34495
34573
|
writable: true,
|
|
34496
34574
|
configurable: true
|
|
34497
34575
|
});
|
|
34576
|
+
Object.defineProperty(prototype, Symbol.matchAll, {
|
|
34577
|
+
value: createSandboxClosure({
|
|
34578
|
+
guest: true,
|
|
34579
|
+
sandbox: true,
|
|
34580
|
+
name: "[Symbol.matchAll]",
|
|
34581
|
+
length: 1,
|
|
34582
|
+
call: async (args, context) => {
|
|
34583
|
+
const target = context?.thisValue;
|
|
34584
|
+
if (target === null || typeof target !== "object") throw new TypeError("RegExp matchAll requires an object receiver.");
|
|
34585
|
+
let input = args[0];
|
|
34586
|
+
let string;
|
|
34587
|
+
let species;
|
|
34588
|
+
let field;
|
|
34589
|
+
let flags;
|
|
34590
|
+
let matcher;
|
|
34591
|
+
const release = retainValues(options.budget, () => [target, input, string, species, field, flags, matcher]);
|
|
34592
|
+
const read = (value, key) => {
|
|
34593
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
34594
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, options.budget);
|
|
34595
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
34596
|
+
};
|
|
34597
|
+
try {
|
|
34598
|
+
string = await sandboxString(input, options.budget, context);
|
|
34599
|
+
input = void 0;
|
|
34600
|
+
field = await read(target, "constructor");
|
|
34601
|
+
species = constructor;
|
|
34602
|
+
if (field !== void 0) {
|
|
34603
|
+
if (field === null || typeof field !== "object") throw new TypeError("Invalid RegExp species constructor.");
|
|
34604
|
+
species = await read(field, Symbol.species);
|
|
34605
|
+
if (species === null || species === void 0) species = constructor;
|
|
34606
|
+
}
|
|
34607
|
+
field = void 0;
|
|
34608
|
+
if (!isSandboxClosure(species) || species.construct === void 0) throw new TypeError("RegExp species must be a constructor.");
|
|
34609
|
+
field = await read(target, "flags");
|
|
34610
|
+
flags = await sandboxString(field, options.budget, context);
|
|
34611
|
+
field = void 0;
|
|
34612
|
+
matcher = await invokeBuiltinClosure(species, [target, flags], options.budget, context, void 0, true);
|
|
34613
|
+
field = await read(target, "lastIndex");
|
|
34614
|
+
const cursor = normalizeLastIndex(await sandboxNumber(field, options.budget, context));
|
|
34615
|
+
field = void 0;
|
|
34616
|
+
await setSandboxProperty(matcher, "lastIndex", cursor, options.budget, true, context);
|
|
34617
|
+
return restoreSandboxRegExpIterator({
|
|
34618
|
+
matcher,
|
|
34619
|
+
input: string,
|
|
34620
|
+
exhausted: false,
|
|
34621
|
+
global: flags.includes("g"),
|
|
34622
|
+
unicode: flags.includes("u") || flags.includes("v")
|
|
34623
|
+
});
|
|
34624
|
+
} finally {
|
|
34625
|
+
release();
|
|
34626
|
+
}
|
|
34627
|
+
}
|
|
34628
|
+
}),
|
|
34629
|
+
writable: true,
|
|
34630
|
+
configurable: true
|
|
34631
|
+
});
|
|
34498
34632
|
for (const name of ["exec", "test", "toString"]) {
|
|
34499
34633
|
Object.defineProperty(prototype, name, {
|
|
34500
34634
|
value: createSandboxClosure({
|
|
@@ -36839,4 +36973,4 @@ export {
|
|
|
36839
36973
|
FileSnapshotBackend,
|
|
36840
36974
|
run
|
|
36841
36975
|
};
|
|
36842
|
-
//# sourceMappingURL=chunk-
|
|
36976
|
+
//# sourceMappingURL=chunk-DXCKCEDV.js.map
|