@poe-platform/safe-js 0.1.176 → 0.1.178
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-7CBZ6QP7.js → chunk-BM7QYQOS.js} +58 -13
- package/dist/safe-js/chunks/chunk-BM7QYQOS.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-CBG2KJVU.js → chunk-S43OS5GO.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/package.json +2 -2
- package/dist/safe-js/chunks/chunk-7CBZ6QP7.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-CBG2KJVU.js.map → chunk-S43OS5GO.js.map} +0 -0
|
@@ -9497,7 +9497,7 @@ function isLineTerminator(character) {
|
|
|
9497
9497
|
}
|
|
9498
9498
|
|
|
9499
9499
|
// packages/safe-js/src/interp/methods/regex.ts
|
|
9500
|
-
var regexMethodNames = /* @__PURE__ */ new Set(["exec", "test"]);
|
|
9500
|
+
var regexMethodNames = /* @__PURE__ */ new Set(["exec", "test", "toString"]);
|
|
9501
9501
|
var regexFlagProperties = {
|
|
9502
9502
|
hasIndices: "d",
|
|
9503
9503
|
global: "g",
|
|
@@ -9511,11 +9511,33 @@ var regexFlagProperties = {
|
|
|
9511
9511
|
function isRegexMethodName(property) {
|
|
9512
9512
|
return typeof property === "string" && regexMethodNames.has(property);
|
|
9513
9513
|
}
|
|
9514
|
-
function getRegexMember(target, property, budget) {
|
|
9514
|
+
function getRegexMember(target, property, budget, context) {
|
|
9515
9515
|
if (property === "source") return escapeRegexSource(target.source, budget);
|
|
9516
9516
|
if (property === "flags") {
|
|
9517
|
-
|
|
9518
|
-
|
|
9517
|
+
let flags = "";
|
|
9518
|
+
const entries = Object.entries(regexFlagProperties);
|
|
9519
|
+
const release = retainValues(budget, () => [target, flags]);
|
|
9520
|
+
const read = (index) => {
|
|
9521
|
+
if (index === entries.length) return budget.allocateString(flags);
|
|
9522
|
+
budget.visitNode();
|
|
9523
|
+
const [key, flag] = entries[index];
|
|
9524
|
+
const descriptor = context?.getProperty === void 0 ? getSandboxPropertyDescriptor(target, key, budget) : void 0;
|
|
9525
|
+
const value = context?.getProperty !== void 0 ? context.getProperty(target, key) : descriptor !== void 0 ? readPropertyDescriptor(descriptor, target, context) : target.flags.includes(flag);
|
|
9526
|
+
const append = (value2) => {
|
|
9527
|
+
if (value2) flags += flag;
|
|
9528
|
+
return read(index + 1);
|
|
9529
|
+
};
|
|
9530
|
+
return value instanceof Promise ? value.then(append) : append(value);
|
|
9531
|
+
};
|
|
9532
|
+
try {
|
|
9533
|
+
const result = read(0);
|
|
9534
|
+
if (result instanceof Promise) return result.finally(release);
|
|
9535
|
+
release();
|
|
9536
|
+
return result;
|
|
9537
|
+
} catch (error) {
|
|
9538
|
+
release();
|
|
9539
|
+
throw error;
|
|
9540
|
+
}
|
|
9519
9541
|
}
|
|
9520
9542
|
if (property === "lastIndex") return target.lastIndex;
|
|
9521
9543
|
if (Object.hasOwn(regexFlagProperties, property)) return target.flags.includes(regexFlagProperties[property]);
|
|
@@ -9524,8 +9546,8 @@ function getRegexMember(target, property, budget) {
|
|
|
9524
9546
|
}
|
|
9525
9547
|
return createSandboxClosure({
|
|
9526
9548
|
sandbox: true,
|
|
9527
|
-
name: `RegExp#${property}`,
|
|
9528
|
-
call: (args,
|
|
9549
|
+
name: property === "toString" ? "toString" : `RegExp#${property}`,
|
|
9550
|
+
call: (args, context2) => callRegexMethod(context2?.thisValue, property, args, budget, context2)
|
|
9529
9551
|
});
|
|
9530
9552
|
}
|
|
9531
9553
|
function escapeRegexSource(source, budget) {
|
|
@@ -9557,6 +9579,7 @@ function setRegexMember(target, property, value) {
|
|
|
9557
9579
|
if (!Reflect.set(properties, property, value)) throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
9558
9580
|
}
|
|
9559
9581
|
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
9582
|
+
if (methodName === "toString") return regexToString(target, budget, context);
|
|
9560
9583
|
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
9561
9584
|
throw new TypeError(`RegExp#${methodName} requires ${methodName === "exec" ? "a regex" : "an object"} receiver.`);
|
|
9562
9585
|
}
|
|
@@ -9586,6 +9609,32 @@ async function callRegexMethod(target, methodName, args, budget, context) {
|
|
|
9586
9609
|
budget.setRetainedValues(retained, void 0);
|
|
9587
9610
|
}
|
|
9588
9611
|
}
|
|
9612
|
+
async function regexToString(target, budget, context) {
|
|
9613
|
+
if (target === null || typeof target !== "object")
|
|
9614
|
+
throw new TypeError("RegExp#toString requires an object receiver.");
|
|
9615
|
+
const read = (key) => {
|
|
9616
|
+
if (context?.getProperty !== void 0) return context.getProperty(target, key);
|
|
9617
|
+
const descriptor = getSandboxPropertyDescriptor(target, key, budget);
|
|
9618
|
+
if (descriptor !== void 0) return readPropertyDescriptor(descriptor, target, context);
|
|
9619
|
+
return isSandboxRegex(target) ? getRegexMember(target, key, budget, context) : void 0;
|
|
9620
|
+
};
|
|
9621
|
+
let sourceValue;
|
|
9622
|
+
let flagsValue;
|
|
9623
|
+
let source;
|
|
9624
|
+
let flags;
|
|
9625
|
+
const release = retainValues(budget, () => [target, sourceValue, flagsValue, source, flags]);
|
|
9626
|
+
try {
|
|
9627
|
+
sourceValue = await read("source");
|
|
9628
|
+
source = await sandboxString(sourceValue, budget, context);
|
|
9629
|
+
sourceValue = void 0;
|
|
9630
|
+
flagsValue = await read("flags");
|
|
9631
|
+
flags = await sandboxString(flagsValue, budget, context);
|
|
9632
|
+
flagsValue = void 0;
|
|
9633
|
+
return budget.allocateString(`/${source}/${flags}`);
|
|
9634
|
+
} finally {
|
|
9635
|
+
release();
|
|
9636
|
+
}
|
|
9637
|
+
}
|
|
9589
9638
|
function executeRegex(target, input, lastIndex) {
|
|
9590
9639
|
const pattern = getSandboxRegexPattern(target);
|
|
9591
9640
|
const match = matchRegex(pattern, input, lastIndex);
|
|
@@ -15878,7 +15927,7 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
15878
15927
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
15879
15928
|
if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
|
|
15880
15929
|
if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
|
|
15881
|
-
if (isSandboxRegex(target)) return getRegexMember(target, property, context.budget);
|
|
15930
|
+
if (isSandboxRegex(target)) return getRegexMember(target, property, context.budget, createCoercionContext(context));
|
|
15882
15931
|
if (!isIndexableSandboxValue(target)) {
|
|
15883
15932
|
throw new TypeError("Attempted to read a property from a non-object value.");
|
|
15884
15933
|
}
|
|
@@ -18978,11 +19027,7 @@ async function defaultToString(value, budget, context, joining) {
|
|
|
18978
19027
|
if (isSandboxCollectionIterator(value))
|
|
18979
19028
|
return collectionIteratorState(value).collectionKind === "map" ? "[object Map Iterator]" : "[object Set Iterator]";
|
|
18980
19029
|
if (isSandboxGenerator(value)) return "[object Generator]";
|
|
18981
|
-
if (isSandboxRegex(value))
|
|
18982
|
-
return budget.allocateString(
|
|
18983
|
-
`/${String(getRegexMember(value, "source", budget))}/${String(getRegexMember(value, "flags", budget))}`
|
|
18984
|
-
);
|
|
18985
|
-
}
|
|
19030
|
+
if (isSandboxRegex(value)) return regexToString(value, budget, context);
|
|
18986
19031
|
if (isSandboxDate(value)) return budget.allocateString(dateString(value));
|
|
18987
19032
|
if (Array.isArray(value) || isFloat32Array(value)) {
|
|
18988
19033
|
if (Object.hasOwn(value, "join")) {
|
|
@@ -36413,4 +36458,4 @@ export {
|
|
|
36413
36458
|
FileSnapshotBackend,
|
|
36414
36459
|
run
|
|
36415
36460
|
};
|
|
36416
|
-
//# sourceMappingURL=chunk-
|
|
36461
|
+
//# sourceMappingURL=chunk-BM7QYQOS.js.map
|