poe-code 14.0.47 → 14.0.48
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/index.js +141 -75
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-WQY27BRL.js → chunk-6GXMEFMD.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-XC53RECY.js → chunk-PCHV72VT.js} +131 -75
- package/packages/safe-js/dist/chunks/chunk-PCHV72VT.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/builtin-call.d.ts +3 -0
- package/packages/safe-js/dist/interp/builtin-call.js +24 -0
- package/packages/safe-js/dist/interp/globals/object-array.d.ts +1 -1
- package/packages/safe-js/dist/interp/globals/object-array.js +111 -48
- package/packages/safe-js/dist/interp/interpreter.js +7 -3
- package/packages/safe-js/dist/interp/string-coercion.d.ts +1 -0
- package/packages/safe-js/dist/interp/string-coercion.js +24 -35
- package/packages/safe-js/dist/interp/values.d.ts +3 -1
- package/packages/safe-js/dist/chunks/chunk-XC53RECY.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-WQY27BRL.js.map → chunk-6GXMEFMD.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -128050,6 +128050,34 @@ var init_host_call = __esm({
|
|
|
128050
128050
|
}
|
|
128051
128051
|
});
|
|
128052
128052
|
|
|
128053
|
+
// packages/safe-js/src/interp/builtin-call.ts
|
|
128054
|
+
async function invokeBuiltinClosure(closure, args, budget, context, thisValue, construct = false) {
|
|
128055
|
+
if (context?.invokeClosure !== void 0) {
|
|
128056
|
+
return context.invokeClosure(closure, args, thisValue, construct);
|
|
128057
|
+
}
|
|
128058
|
+
const leaveCall = budget.enterCall();
|
|
128059
|
+
try {
|
|
128060
|
+
const invoke2 = construct ? closure.construct : closure.call;
|
|
128061
|
+
if (invoke2 === void 0) throw new TypeError("Value is not a constructor.");
|
|
128062
|
+
const result = await invoke2(args, {
|
|
128063
|
+
...context,
|
|
128064
|
+
stack: context?.stack ?? [],
|
|
128065
|
+
thisValue,
|
|
128066
|
+
invokeClosure: (target, values, receiver, asConstructor) => invokeBuiltinClosure(target, values, budget, context, receiver, asConstructor)
|
|
128067
|
+
});
|
|
128068
|
+
if (isSandboxPromise(result)) await result.synchronousPrefix;
|
|
128069
|
+
return result;
|
|
128070
|
+
} finally {
|
|
128071
|
+
leaveCall();
|
|
128072
|
+
}
|
|
128073
|
+
}
|
|
128074
|
+
var init_builtin_call = __esm({
|
|
128075
|
+
"packages/safe-js/src/interp/builtin-call.ts"() {
|
|
128076
|
+
"use strict";
|
|
128077
|
+
init_values();
|
|
128078
|
+
}
|
|
128079
|
+
});
|
|
128080
|
+
|
|
128053
128081
|
// packages/safe-js/src/interp/regex/engine.ts
|
|
128054
128082
|
function matchRegex(pattern, input, lastIndex = 0) {
|
|
128055
128083
|
const startIndex = pattern.flags.global ? normalizeLastIndex(lastIndex) : 0;
|
|
@@ -128364,49 +128392,38 @@ var init_regex = __esm({
|
|
|
128364
128392
|
});
|
|
128365
128393
|
|
|
128366
128394
|
// packages/safe-js/src/interp/string-coercion.ts
|
|
128395
|
+
function sandboxNumber(value, budget, context) {
|
|
128396
|
+
if (value === null || typeof value !== "object") {
|
|
128397
|
+
if (typeof value === "function") throw new TypeError("Expected a sandbox value.");
|
|
128398
|
+
return Number(value);
|
|
128399
|
+
}
|
|
128400
|
+
return objectToPrimitive(value, budget, context, /* @__PURE__ */ new Set(), "number").then(Number);
|
|
128401
|
+
}
|
|
128367
128402
|
function sandboxString(value, budget, context, joining = /* @__PURE__ */ new Set()) {
|
|
128368
128403
|
if (value === null || typeof value !== "object") {
|
|
128369
128404
|
if (typeof value === "function") throw new TypeError("Expected a sandbox value.");
|
|
128370
128405
|
return budget.allocateString(String(value));
|
|
128371
128406
|
}
|
|
128372
|
-
|
|
128373
|
-
...context,
|
|
128374
|
-
stack: context?.stack ?? [],
|
|
128375
|
-
thisValue: context?.thisValue,
|
|
128376
|
-
invokeClosure: async (closure, args, thisValue) => {
|
|
128377
|
-
const leaveCall = budget.enterCall();
|
|
128378
|
-
try {
|
|
128379
|
-
const result = closure.call(args, { ...invocation, thisValue });
|
|
128380
|
-
if (isSandboxPromise(result)) {
|
|
128381
|
-
await result.synchronousPrefix;
|
|
128382
|
-
return result;
|
|
128383
|
-
}
|
|
128384
|
-
return await result;
|
|
128385
|
-
} finally {
|
|
128386
|
-
leaveCall();
|
|
128387
|
-
}
|
|
128388
|
-
}
|
|
128389
|
-
};
|
|
128390
|
-
return stringifyObject(value, budget, invocation, joining);
|
|
128407
|
+
return objectToPrimitive(value, budget, context, joining, "string").then((primitive) => budget.allocateString(String(primitive)));
|
|
128391
128408
|
}
|
|
128392
|
-
async function
|
|
128409
|
+
async function objectToPrimitive(value, budget, context, joining, hint) {
|
|
128393
128410
|
const leaveCall = budget.enterCall();
|
|
128394
128411
|
try {
|
|
128395
128412
|
budget.visitNode();
|
|
128396
|
-
for (const name of ["toString", "valueOf"]) {
|
|
128413
|
+
for (const name of hint === "string" ? ["toString", "valueOf"] : ["valueOf", "toString"]) {
|
|
128397
128414
|
const hook = conversionHook(value, name, budget);
|
|
128398
128415
|
let result;
|
|
128399
128416
|
if (hook === defaultStringHook) {
|
|
128400
128417
|
result = await defaultToString(value, budget, context, joining);
|
|
128418
|
+
} else if (hook === defaultValueHook) {
|
|
128419
|
+
result = isSandboxDate(value) ? dateTime(value) : value;
|
|
128401
128420
|
} else {
|
|
128402
128421
|
if (!isSandboxClosure(hook)) continue;
|
|
128403
|
-
|
|
128404
|
-
throw new TypeError("String hooks require a sandbox call context.");
|
|
128405
|
-
}
|
|
128406
|
-
result = await context.invokeClosure(hook, [], value);
|
|
128422
|
+
result = await invokeBuiltinClosure(hook, [], budget, context, value);
|
|
128407
128423
|
}
|
|
128408
128424
|
if (result === null || typeof result !== "object") {
|
|
128409
|
-
|
|
128425
|
+
if (typeof result === "function") throw new TypeError("Expected a sandbox value.");
|
|
128426
|
+
return result;
|
|
128410
128427
|
}
|
|
128411
128428
|
}
|
|
128412
128429
|
throw new TypeError("Cannot convert object to primitive value");
|
|
@@ -128428,7 +128445,7 @@ function conversionHook(value, name, budget) {
|
|
|
128428
128445
|
}
|
|
128429
128446
|
const parent = getSandboxPrototype(current, budget);
|
|
128430
128447
|
if (current === value && (implicitBuiltin || parent === null && !hasExplicitSandboxPrototype(value))) {
|
|
128431
|
-
return name === "toString" ? defaultStringHook :
|
|
128448
|
+
return name === "toString" ? defaultStringHook : defaultValueHook;
|
|
128432
128449
|
}
|
|
128433
128450
|
current = parent;
|
|
128434
128451
|
if (current !== null) {
|
|
@@ -128453,10 +128470,7 @@ async function defaultToString(value, budget, context, joining) {
|
|
|
128453
128470
|
const join21 = ownDataValue(value, "join");
|
|
128454
128471
|
if (!isSandboxClosure(join21))
|
|
128455
128472
|
return isFloat32Array(value) ? "[object Float32Array]" : "[object Array]";
|
|
128456
|
-
|
|
128457
|
-
throw new TypeError("String hooks require a sandbox call context.");
|
|
128458
|
-
}
|
|
128459
|
-
return context.invokeClosure(join21, [], value);
|
|
128473
|
+
return invokeBuiltinClosure(join21, [], budget, context, value);
|
|
128460
128474
|
}
|
|
128461
128475
|
if (joining.has(value)) return "";
|
|
128462
128476
|
joining.add(value);
|
|
@@ -128490,12 +128504,13 @@ function ownDataValue(value, name) {
|
|
|
128490
128504
|
}
|
|
128491
128505
|
return descriptor?.value;
|
|
128492
128506
|
}
|
|
128493
|
-
var defaultStringHook;
|
|
128507
|
+
var defaultStringHook, defaultValueHook;
|
|
128494
128508
|
var init_string_coercion = __esm({
|
|
128495
128509
|
"packages/safe-js/src/interp/string-coercion.ts"() {
|
|
128496
128510
|
"use strict";
|
|
128497
128511
|
init_shape();
|
|
128498
128512
|
init_date();
|
|
128513
|
+
init_builtin_call();
|
|
128499
128514
|
init_float32();
|
|
128500
128515
|
init_graph_depth();
|
|
128501
128516
|
init_host_capabilities();
|
|
@@ -128503,6 +128518,7 @@ var init_string_coercion = __esm({
|
|
|
128503
128518
|
init_regex();
|
|
128504
128519
|
init_values();
|
|
128505
128520
|
defaultStringHook = /* @__PURE__ */ Symbol("defaultStringHook");
|
|
128521
|
+
defaultValueHook = /* @__PURE__ */ Symbol("defaultValueHook");
|
|
128506
128522
|
}
|
|
128507
128523
|
});
|
|
128508
128524
|
|
|
@@ -146309,7 +146325,7 @@ async function evaluateNode2(node, context) {
|
|
|
146309
146325
|
function reconcileDataBudget(budget, stats2, scope, transient, compilation, parent) {
|
|
146310
146326
|
reconcileCompiledValues(
|
|
146311
146327
|
budget,
|
|
146312
|
-
[...scope.retainedValues(),
|
|
146328
|
+
[...scope.retainedValues(), transient],
|
|
146313
146329
|
compilation,
|
|
146314
146330
|
parent,
|
|
146315
146331
|
[transient]
|
|
@@ -148260,7 +148276,9 @@ function createCoercionContext(context) {
|
|
|
148260
148276
|
stack: context.callStack,
|
|
148261
148277
|
thisValue: void 0,
|
|
148262
148278
|
compilation: context.compilation,
|
|
148263
|
-
|
|
148279
|
+
getProperty: (value, property) => getPropertyValue(value, property, context),
|
|
148280
|
+
reconcileData: (value) => reconcileDataBudget(context.budget, context.stats, context.scope, value, context.compilation, context.compilation?.parent),
|
|
148281
|
+
invokeClosure: (closure, args, thisValue, construct) => invokeSandboxClosure(closure, args, context, context.callStack, void 0, thisValue, construct)
|
|
148264
148282
|
};
|
|
148265
148283
|
}
|
|
148266
148284
|
function hasSandboxProperty(value, key3, context) {
|
|
@@ -148637,7 +148655,9 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
148637
148655
|
stack,
|
|
148638
148656
|
thisValue,
|
|
148639
148657
|
compilation: context.compilation,
|
|
148640
|
-
|
|
148658
|
+
getProperty: (value, property) => getPropertyValue(value, property, context),
|
|
148659
|
+
reconcileData: (value) => reconcileDataBudget(context.budget, context.stats, context.scope, value, context.compilation, context.compilation?.parent),
|
|
148660
|
+
invokeClosure: (closure, argumentsList, receiver, asConstructor) => invokeSandboxClosure(closure, argumentsList, context, stack, span, receiver, asConstructor),
|
|
148641
148661
|
...span === void 0 ? {} : { span }
|
|
148642
148662
|
}
|
|
148643
148663
|
]);
|
|
@@ -150338,7 +150358,7 @@ async function stringifyValue3(value, state, indent) {
|
|
|
150338
150358
|
return stringifyArray(value, state, indent);
|
|
150339
150359
|
}
|
|
150340
150360
|
if (isStringifyObject(value)) {
|
|
150341
|
-
return
|
|
150361
|
+
return stringifyObject(value, state, indent);
|
|
150342
150362
|
}
|
|
150343
150363
|
return void 0;
|
|
150344
150364
|
}
|
|
@@ -150364,7 +150384,7 @@ ${indent}]`;
|
|
|
150364
150384
|
leaveStringifyObject(value, state);
|
|
150365
150385
|
}
|
|
150366
150386
|
}
|
|
150367
|
-
async function
|
|
150387
|
+
async function stringifyObject(value, state, indent) {
|
|
150368
150388
|
enterStringifyObject(value, state);
|
|
150369
150389
|
try {
|
|
150370
150390
|
const nextIndent = indent + state.gap;
|
|
@@ -150871,7 +150891,7 @@ function createObjectArrayGlobals(options) {
|
|
|
150871
150891
|
}),
|
|
150872
150892
|
from: createSandboxClosure({
|
|
150873
150893
|
sandbox: true,
|
|
150874
|
-
call: (args) => arrayFromSandboxValues(args, options.budget),
|
|
150894
|
+
call: (args, context) => arrayFromSandboxValues(args, options.budget, context),
|
|
150875
150895
|
name: "from"
|
|
150876
150896
|
}),
|
|
150877
150897
|
of: createSandboxClosure({
|
|
@@ -150905,7 +150925,7 @@ function createObjectArrayGlobals(options) {
|
|
|
150905
150925
|
}),
|
|
150906
150926
|
Number: createSandboxClosure({
|
|
150907
150927
|
sandbox: true,
|
|
150908
|
-
call: (
|
|
150928
|
+
call: (args, context) => sandboxNumber(args.length === 0 ? 0 : args[0], options.budget, context),
|
|
150909
150929
|
name: "Number",
|
|
150910
150930
|
properties: {
|
|
150911
150931
|
isFinite: createSandboxClosure({
|
|
@@ -151051,40 +151071,86 @@ function defineDataProperty9(target, key3, descriptor, budget) {
|
|
|
151051
151071
|
function isAssignableSandboxTarget(value) {
|
|
151052
151072
|
return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxGenerator(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
|
|
151053
151073
|
}
|
|
151054
|
-
async function arrayFromSandboxValues(args, budget) {
|
|
151074
|
+
async function arrayFromSandboxValues(args, budget, context) {
|
|
151055
151075
|
const [items, mapFn, thisValue] = args;
|
|
151076
|
+
if (mapFn !== void 0 && !isSandboxClosure(mapFn)) {
|
|
151077
|
+
throw new TypeError("Array.from mapping callback must be a function.");
|
|
151078
|
+
}
|
|
151079
|
+
if (items === null || items === void 0) {
|
|
151080
|
+
throw new TypeError("Array.from requires a non-null input.");
|
|
151081
|
+
}
|
|
151082
|
+
const read = (property) => context?.getProperty !== void 0 ? context.getProperty(items, property) : getSandboxDataProperty(items, property, budget);
|
|
151056
151083
|
const iterator = getSandboxIterator(items);
|
|
151057
|
-
|
|
151058
|
-
|
|
151059
|
-
|
|
151060
|
-
|
|
151061
|
-
|
|
151062
|
-
|
|
151063
|
-
|
|
151064
|
-
|
|
151065
|
-
|
|
151066
|
-
|
|
151067
|
-
|
|
151068
|
-
|
|
151084
|
+
const constructor = context?.thisValue;
|
|
151085
|
+
let result;
|
|
151086
|
+
let currentValue;
|
|
151087
|
+
let failure;
|
|
151088
|
+
let estimatedDataSize = 0;
|
|
151089
|
+
const retained = {};
|
|
151090
|
+
budget.setRetainedValues(retained, () => [items, mapFn, constructor, result, currentValue, failure]);
|
|
151091
|
+
const checkData = (growth = 0, force = false) => {
|
|
151092
|
+
const limit = budget.limits.dataSize;
|
|
151093
|
+
if (limit === void 0) return;
|
|
151094
|
+
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
151095
|
+
if (!force && estimatedDataSize <= limit) return;
|
|
151096
|
+
if (context?.reconcileData !== void 0) context.reconcileData(result);
|
|
151097
|
+
else reconcileCompiledValues(budget, [], context?.compilation);
|
|
151098
|
+
estimatedDataSize = budget.currentDataSize;
|
|
151099
|
+
};
|
|
151100
|
+
const closeOnThrow = async (error3) => {
|
|
151101
|
+
failure = isCapturedException(error3) ? error3.reason : error3;
|
|
151102
|
+
try {
|
|
151103
|
+
await iterator?.return?.();
|
|
151104
|
+
} catch (closeError) {
|
|
151105
|
+
if (!isFatalSandboxError(error3) && isFatalSandboxError(closeError)) throw closeError;
|
|
151069
151106
|
}
|
|
151070
|
-
|
|
151071
|
-
}
|
|
151072
|
-
|
|
151073
|
-
|
|
151074
|
-
if (
|
|
151075
|
-
|
|
151107
|
+
throw error3;
|
|
151108
|
+
};
|
|
151109
|
+
try {
|
|
151110
|
+
let length = 0;
|
|
151111
|
+
if (iterator === void 0) {
|
|
151112
|
+
const number = await sandboxNumber(read("length"), budget, context);
|
|
151113
|
+
length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
|
|
151076
151114
|
}
|
|
151077
|
-
|
|
151078
|
-
|
|
151079
|
-
|
|
151080
|
-
|
|
151081
|
-
|
|
151082
|
-
|
|
151083
|
-
|
|
151115
|
+
result = isSandboxClosure(constructor) && constructor.construct !== void 0 ? await invokeBuiltinClosure(constructor, iterator === void 0 ? [length] : [], budget, context, void 0, true) : createArrayFromConstructorArgs([length], budget);
|
|
151116
|
+
checkData(0, true);
|
|
151117
|
+
let index = 0;
|
|
151118
|
+
while (iterator !== void 0 || index < length) {
|
|
151119
|
+
try {
|
|
151120
|
+
budget.visitNode();
|
|
151121
|
+
if (iterator !== void 0 && index >= Number.MAX_SAFE_INTEGER) throw new TypeError("Array.from input is too long.");
|
|
151122
|
+
} catch (error3) {
|
|
151123
|
+
await closeOnThrow(error3);
|
|
151124
|
+
}
|
|
151125
|
+
if (iterator !== void 0) {
|
|
151126
|
+
const next = await iterator.next();
|
|
151127
|
+
if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
|
|
151128
|
+
if (next.done) break;
|
|
151129
|
+
currentValue = next.value;
|
|
151130
|
+
} else {
|
|
151131
|
+
currentValue = read(index);
|
|
151132
|
+
}
|
|
151133
|
+
try {
|
|
151134
|
+
if (Array.isArray(result)) budget.allocateArrayLength(index + 1);
|
|
151135
|
+
if (mapFn !== void 0) currentValue = await invokeBuiltinClosure(mapFn, [currentValue, index], budget, context, thisValue);
|
|
151136
|
+
const key3 = String(index);
|
|
151137
|
+
const growth = key3.length + 1 + (Array.isArray(result) ? Math.max(0, index + 1 - result.length) : 0) + (typeof currentValue === "string" ? currentValue.length : 0);
|
|
151138
|
+
const graphChanged = typeof currentValue === "object" && currentValue !== null || isSandboxClosure(result);
|
|
151139
|
+
budget.visitNode();
|
|
151140
|
+
defineOwnDataProperty(objectProperties(result, true), key3, currentValue);
|
|
151141
|
+
currentValue = void 0;
|
|
151142
|
+
checkData(growth, graphChanged);
|
|
151143
|
+
} catch (error3) {
|
|
151144
|
+
await closeOnThrow(error3);
|
|
151145
|
+
}
|
|
151146
|
+
index += 1;
|
|
151084
151147
|
}
|
|
151085
|
-
|
|
151148
|
+
setSandboxProperty(result, "length", index, budget);
|
|
151149
|
+
checkData(0, true);
|
|
151150
|
+
return allocateProducedSandboxValue(result, budget);
|
|
151151
|
+
} finally {
|
|
151152
|
+
budget.setRetainedValues(retained, void 0);
|
|
151086
151153
|
}
|
|
151087
|
-
return budgetSandboxValue2(mappedValues, budget);
|
|
151088
151154
|
}
|
|
151089
151155
|
function createArrayFromConstructorArgs(args, budget) {
|
|
151090
151156
|
if (args.length !== 1) {
|
|
@@ -151098,14 +151164,11 @@ function createArrayFromConstructorArgs(args, budget) {
|
|
|
151098
151164
|
throw new RangeError("Invalid array length.");
|
|
151099
151165
|
}
|
|
151100
151166
|
budget.allocateArrayLength(lengthOrValue);
|
|
151101
|
-
|
|
151102
|
-
|
|
151103
|
-
|
|
151104
|
-
|
|
151105
|
-
|
|
151106
|
-
const result = await iterator.next();
|
|
151107
|
-
if (result.done) return values;
|
|
151108
|
-
values.push(result.value);
|
|
151167
|
+
const release2 = budget.provisionDataUsage(lengthOrValue + 1);
|
|
151168
|
+
try {
|
|
151169
|
+
return new Array(lengthOrValue);
|
|
151170
|
+
} finally {
|
|
151171
|
+
release2();
|
|
151109
151172
|
}
|
|
151110
151173
|
}
|
|
151111
151174
|
function getOwnEnumerableKeys(value) {
|
|
@@ -151141,6 +151204,9 @@ function getTemplateRawParts(template2) {
|
|
|
151141
151204
|
var init_object_array = __esm({
|
|
151142
151205
|
"packages/safe-js/src/interp/globals/object-array.ts"() {
|
|
151143
151206
|
"use strict";
|
|
151207
|
+
init_budget2();
|
|
151208
|
+
init_builtin_call();
|
|
151209
|
+
init_exceptions();
|
|
151144
151210
|
init_date();
|
|
151145
151211
|
init_date2();
|
|
151146
151212
|
init_object2();
|