@poe-platform/safe-js 0.1.251 → 0.1.253
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-QN4BNY6V.js → chunk-F46UKJYT.js} +32 -3
- package/dist/safe-js/chunks/{chunk-QN4BNY6V.js.map → chunk-F46UKJYT.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-EEO344SX.js → chunk-FTO62YAZ.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-EEO344SX.js.map → chunk-FTO62YAZ.js.map} +0 -0
|
@@ -22164,6 +22164,7 @@ function f16round(value) {
|
|
|
22164
22164
|
}
|
|
22165
22165
|
function createMathGlobals(options = {}) {
|
|
22166
22166
|
const random = options.random ?? Math.random;
|
|
22167
|
+
const budget = options.budget ?? new Budget();
|
|
22167
22168
|
const mathObject = {
|
|
22168
22169
|
E: Math.E,
|
|
22169
22170
|
LN2: Math.LN2,
|
|
@@ -22176,9 +22177,10 @@ function createMathGlobals(options = {}) {
|
|
|
22176
22177
|
random: createSandboxClosure({ sandbox: true, call: () => random(), name: "random" })
|
|
22177
22178
|
};
|
|
22178
22179
|
for (const [name, method] of Object.entries(mathMethods)) {
|
|
22180
|
+
const variadic = method === Math.max || method === Math.min || method === Math.hypot;
|
|
22179
22181
|
mathObject[name] = createSandboxClosure({
|
|
22180
22182
|
sandbox: true,
|
|
22181
|
-
call: (args) =>
|
|
22183
|
+
call: (args, context) => callNumericMethod(method, args, variadic, budget, context),
|
|
22182
22184
|
name
|
|
22183
22185
|
});
|
|
22184
22186
|
}
|
|
@@ -22197,6 +22199,33 @@ function createMathGlobals(options = {}) {
|
|
|
22197
22199
|
NaN: Number.NaN
|
|
22198
22200
|
};
|
|
22199
22201
|
}
|
|
22202
|
+
function callNumericMethod(method, args, variadic, budget, context) {
|
|
22203
|
+
const count = variadic ? args.length : Math.min(args.length, method.length);
|
|
22204
|
+
const numbers = [];
|
|
22205
|
+
const release = retainValues(budget, () => [...args, numbers]);
|
|
22206
|
+
try {
|
|
22207
|
+
const result = advance();
|
|
22208
|
+
if (result instanceof Promise) return result.finally(release);
|
|
22209
|
+
release();
|
|
22210
|
+
return result;
|
|
22211
|
+
} catch (error) {
|
|
22212
|
+
release();
|
|
22213
|
+
throw error;
|
|
22214
|
+
}
|
|
22215
|
+
function advance() {
|
|
22216
|
+
while (numbers.length < count) {
|
|
22217
|
+
budget.visitNode();
|
|
22218
|
+
const input = args[numbers.length];
|
|
22219
|
+
const number = context === void 0 ? +input : sandboxNumber(input, budget, context);
|
|
22220
|
+
if (number instanceof Promise) return number.then((value) => {
|
|
22221
|
+
numbers.push(value);
|
|
22222
|
+
return advance();
|
|
22223
|
+
});
|
|
22224
|
+
numbers.push(number);
|
|
22225
|
+
}
|
|
22226
|
+
return Reflect.apply(method, Math, numbers);
|
|
22227
|
+
}
|
|
22228
|
+
}
|
|
22200
22229
|
function createSeededRandom(seed) {
|
|
22201
22230
|
let state = normalizeSeed(seed);
|
|
22202
22231
|
return {
|
|
@@ -22860,7 +22889,7 @@ function createBuiltinBindings(options) {
|
|
|
22860
22889
|
Symbol: createSymbolGlobal(options.budget),
|
|
22861
22890
|
BigInt: createBigIntGlobal(options.budget),
|
|
22862
22891
|
...createErrorGlobals(options),
|
|
22863
|
-
...createMathGlobals({ random: options.random }),
|
|
22892
|
+
...createMathGlobals({ random: options.random, budget: options.budget }),
|
|
22864
22893
|
...createObjectArrayGlobals(options),
|
|
22865
22894
|
...createMiscGlobals(options),
|
|
22866
22895
|
...createUriGlobals(options.budget),
|
|
@@ -39585,4 +39614,4 @@ export {
|
|
|
39585
39614
|
FileSnapshotBackend,
|
|
39586
39615
|
run
|
|
39587
39616
|
};
|
|
39588
|
-
//# sourceMappingURL=chunk-
|
|
39617
|
+
//# sourceMappingURL=chunk-F46UKJYT.js.map
|