@poe-platform/safe-js 0.1.115 → 0.1.117
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-G2KH7I4M.js → chunk-L7PHF62H.js} +46 -54
- package/dist/safe-js/chunks/{chunk-G2KH7I4M.js.map → chunk-L7PHF62H.js.map} +3 -3
- package/dist/safe-js/chunks/{chunk-HFCKNAQK.js → chunk-WXZUZEV2.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-HFCKNAQK.js.map → chunk-WXZUZEV2.js.map} +0 -0
|
@@ -24826,63 +24826,42 @@ function getNumberMember(property, budget) {
|
|
|
24826
24826
|
return createSandboxClosure({
|
|
24827
24827
|
sandbox: true,
|
|
24828
24828
|
name: `Number#${property}`,
|
|
24829
|
-
call: (args, context) => callNumberMethod(context?.thisValue, property, args, budget)
|
|
24829
|
+
call: (args, context) => callNumberMethod(context?.thisValue, property, args, budget, context)
|
|
24830
24830
|
});
|
|
24831
24831
|
}
|
|
24832
24832
|
function isNumberMethodName(property) {
|
|
24833
24833
|
return typeof property === "string" && numberMethodNames.has(property);
|
|
24834
24834
|
}
|
|
24835
|
-
function callNumberMethod(value, methodName, args, budget) {
|
|
24835
|
+
function callNumberMethod(value, methodName, args, budget, context) {
|
|
24836
24836
|
if (typeof value !== "number") {
|
|
24837
24837
|
throw new TypeError(`Number#${methodName} requires a number receiver.`);
|
|
24838
24838
|
}
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
switch (methodName) {
|
|
24843
|
-
case "toString":
|
|
24844
|
-
return value.toString(asValidatedRadix(args[0]));
|
|
24845
|
-
case "toExponential":
|
|
24846
|
-
return args[0] === void 0 ? value.toExponential() : value.toExponential(asValidatedFractionDigits(args[0], methodName));
|
|
24847
|
-
case "toFixed":
|
|
24848
|
-
return value.toFixed(asValidatedFractionDigits(args[0], methodName));
|
|
24849
|
-
case "toPrecision":
|
|
24850
|
-
return args[0] === void 0 ? value.toPrecision() : value.toPrecision(asValidatedPrecision(args[0]));
|
|
24851
|
-
}
|
|
24852
|
-
}
|
|
24853
|
-
function asValidatedRadix(value) {
|
|
24854
|
-
if (value === void 0) {
|
|
24855
|
-
return void 0;
|
|
24856
|
-
}
|
|
24857
|
-
const radix = toIntegerOrInfinity2(value);
|
|
24858
|
-
if (radix < 2 || radix > 36) {
|
|
24859
|
-
throw new RangeError("Number#toString radix must be between 2 and 36.");
|
|
24860
|
-
}
|
|
24861
|
-
return radix;
|
|
24862
|
-
}
|
|
24863
|
-
function asValidatedFractionDigits(value, methodName) {
|
|
24864
|
-
const digits = toIntegerOrInfinity2(value);
|
|
24865
|
-
if (digits < 0 || digits > 100) {
|
|
24866
|
-
throw new RangeError(`Number#${methodName} digits must be between 0 and 100.`);
|
|
24839
|
+
const argument = args[0];
|
|
24840
|
+
if (argument !== null && typeof argument === "object") {
|
|
24841
|
+
return formatObjectArgument(value, methodName, argument, budget, context);
|
|
24867
24842
|
}
|
|
24868
|
-
return
|
|
24843
|
+
return formatNumber(value, methodName, argument === void 0 ? void 0 : Number(argument), budget);
|
|
24869
24844
|
}
|
|
24870
|
-
function
|
|
24871
|
-
const
|
|
24872
|
-
|
|
24873
|
-
|
|
24845
|
+
async function formatObjectArgument(value, methodName, argument, budget, context) {
|
|
24846
|
+
const retainedArgument = {};
|
|
24847
|
+
budget.setRetainedValues(retainedArgument, () => [argument]);
|
|
24848
|
+
try {
|
|
24849
|
+
const number = await sandboxNumber(argument, budget, context);
|
|
24850
|
+
return formatNumber(value, methodName, number, budget);
|
|
24851
|
+
} finally {
|
|
24852
|
+
budget.setRetainedValues(retainedArgument, void 0);
|
|
24874
24853
|
}
|
|
24875
|
-
return precision;
|
|
24876
24854
|
}
|
|
24877
|
-
function
|
|
24878
|
-
|
|
24879
|
-
|
|
24880
|
-
|
|
24881
|
-
}
|
|
24882
|
-
|
|
24883
|
-
|
|
24855
|
+
function formatNumber(value, methodName, argument, budget) {
|
|
24856
|
+
let result;
|
|
24857
|
+
try {
|
|
24858
|
+
result = value[methodName](argument);
|
|
24859
|
+
} catch (error) {
|
|
24860
|
+
if (!(error instanceof RangeError)) throw error;
|
|
24861
|
+
const detail = methodName === "toString" ? "radix must be between 2 and 36." : methodName === "toPrecision" ? "precision must be between 1 and 100." : "digits must be between 0 and 100.";
|
|
24862
|
+
throw new RangeError(`Number#${methodName} ${detail}`);
|
|
24884
24863
|
}
|
|
24885
|
-
return
|
|
24864
|
+
return budget.allocateString(result);
|
|
24886
24865
|
}
|
|
24887
24866
|
|
|
24888
24867
|
// packages/safe-js/src/interp/methods/generator.ts
|
|
@@ -24956,14 +24935,27 @@ function getStringMember(value, property, budget) {
|
|
|
24956
24935
|
name: `String#${property}`,
|
|
24957
24936
|
...property === "localeCompare" ? { length: 1 } : {},
|
|
24958
24937
|
...property === "isWellFormed" || property === "toWellFormed" ? { length: 0 } : {},
|
|
24959
|
-
call: (args, context) =>
|
|
24960
|
-
|
|
24961
|
-
|
|
24962
|
-
|
|
24963
|
-
|
|
24964
|
-
|
|
24965
|
-
|
|
24966
|
-
|
|
24938
|
+
call: async (args, context) => {
|
|
24939
|
+
const receiver = context?.thisValue;
|
|
24940
|
+
if (receiver === null || receiver === void 0) {
|
|
24941
|
+
throw new TypeError(`String#${property} requires a non-null receiver.`);
|
|
24942
|
+
}
|
|
24943
|
+
const retainedReceiver = {};
|
|
24944
|
+
budget.setRetainedValues(retainedReceiver, () => [receiver]);
|
|
24945
|
+
try {
|
|
24946
|
+
const string = await sandboxString(receiver, budget, context);
|
|
24947
|
+
return await callStringMethod(
|
|
24948
|
+
string,
|
|
24949
|
+
property,
|
|
24950
|
+
args,
|
|
24951
|
+
budget,
|
|
24952
|
+
(closure, closureArgs) => invokeBuiltinClosure(closure, closureArgs, budget, context, void 0),
|
|
24953
|
+
context?.compilation
|
|
24954
|
+
);
|
|
24955
|
+
} finally {
|
|
24956
|
+
budget.setRetainedValues(retainedReceiver, void 0);
|
|
24957
|
+
}
|
|
24958
|
+
}
|
|
24967
24959
|
});
|
|
24968
24960
|
}
|
|
24969
24961
|
function getStringIndex(property) {
|
|
@@ -28707,7 +28699,7 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
|
|
|
28707
28699
|
return {
|
|
28708
28700
|
kind: "normal",
|
|
28709
28701
|
hasValue: true,
|
|
28710
|
-
value: callNumberMethod(target, methodName, args.value, context.budget)
|
|
28702
|
+
value: await callNumberMethod(target, methodName, args.value, context.budget, createCoercionContext(context))
|
|
28711
28703
|
};
|
|
28712
28704
|
} catch (error) {
|
|
28713
28705
|
if (isFatalSandboxError(error)) {
|
|
@@ -33304,4 +33296,4 @@ export {
|
|
|
33304
33296
|
FileSnapshotBackend,
|
|
33305
33297
|
run
|
|
33306
33298
|
};
|
|
33307
|
-
//# sourceMappingURL=chunk-
|
|
33299
|
+
//# sourceMappingURL=chunk-L7PHF62H.js.map
|