poe-code 11.0.23 → 11.0.24
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 +82 -40
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-3627FMJF.js → chunk-CGS4H4L3.js} +82 -40
- package/packages/safejs/dist/chunks/{chunk-3627FMJF.js.map → chunk-CGS4H4L3.js.map} +2 -2
- package/packages/safejs/dist/chunks/{chunk-LRGHMX22.js → chunk-I5FH3SKL.js} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/globals/object-array.js +2 -2
- package/packages/safejs/dist/interp/interpreter.js +3 -3
- package/packages/safejs/dist/interp/methods/array.d.ts +1 -1
- package/packages/safejs/dist/interp/methods/array.js +32 -32
- package/packages/safejs/dist/interp/methods/map.d.ts +1 -1
- package/packages/safejs/dist/interp/methods/map.js +1 -1
- package/packages/safejs/dist/interp/methods/set.d.ts +1 -1
- package/packages/safejs/dist/interp/methods/set.js +1 -1
- /package/packages/safejs/dist/chunks/{chunk-LRGHMX22.js.map → chunk-I5FH3SKL.js.map} +0 -0
package/package.json
CHANGED
|
@@ -23942,7 +23942,7 @@ function isAssignableSandboxTarget(value) {
|
|
|
23942
23942
|
return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
|
|
23943
23943
|
}
|
|
23944
23944
|
async function arrayFromSandboxValues(args, budget) {
|
|
23945
|
-
const [items, mapFn] = args;
|
|
23945
|
+
const [items, mapFn, thisValue] = args;
|
|
23946
23946
|
const iterator = getSandboxIterator(items);
|
|
23947
23947
|
const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
|
|
23948
23948
|
if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
|
|
@@ -23953,7 +23953,7 @@ async function arrayFromSandboxValues(args, budget) {
|
|
|
23953
23953
|
}
|
|
23954
23954
|
const mappedValues = [];
|
|
23955
23955
|
for (const [index, value] of values.entries()) {
|
|
23956
|
-
const result = await mapFn.call([value, index]);
|
|
23956
|
+
const result = await mapFn.call([value, index], { stack: [], thisValue });
|
|
23957
23957
|
if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
|
|
23958
23958
|
await result.synchronousPrefix;
|
|
23959
23959
|
}
|
|
@@ -24116,17 +24116,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
|
|
|
24116
24116
|
switch (methodName) {
|
|
24117
24117
|
case "map":
|
|
24118
24118
|
return budgetProducedValue(
|
|
24119
|
-
await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
|
|
24119
|
+
await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
|
|
24120
24120
|
options.budget
|
|
24121
24121
|
);
|
|
24122
24122
|
case "filter":
|
|
24123
24123
|
return budgetProducedValue(
|
|
24124
|
-
await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack),
|
|
24124
|
+
await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
|
|
24125
24125
|
options.budget
|
|
24126
24126
|
);
|
|
24127
24127
|
case "find":
|
|
24128
24128
|
return budgetProducedValue(
|
|
24129
|
-
await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
|
|
24129
|
+
await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
|
|
24130
24130
|
options.budget
|
|
24131
24131
|
);
|
|
24132
24132
|
case "findIndex":
|
|
@@ -24134,11 +24134,18 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
|
|
|
24134
24134
|
value,
|
|
24135
24135
|
getRequiredCallback(methodName, args[0]),
|
|
24136
24136
|
options,
|
|
24137
|
-
stack
|
|
24137
|
+
stack,
|
|
24138
|
+
args[1]
|
|
24138
24139
|
);
|
|
24139
24140
|
case "findLast":
|
|
24140
24141
|
return budgetProducedValue(
|
|
24141
|
-
await findLastInArray(
|
|
24142
|
+
await findLastInArray(
|
|
24143
|
+
value,
|
|
24144
|
+
getRequiredCallback(methodName, args[0]),
|
|
24145
|
+
options,
|
|
24146
|
+
stack,
|
|
24147
|
+
args[1]
|
|
24148
|
+
),
|
|
24142
24149
|
options.budget
|
|
24143
24150
|
);
|
|
24144
24151
|
case "findLastIndex":
|
|
@@ -24146,12 +24153,25 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
|
|
|
24146
24153
|
value,
|
|
24147
24154
|
getRequiredCallback(methodName, args[0]),
|
|
24148
24155
|
options,
|
|
24149
|
-
stack
|
|
24156
|
+
stack,
|
|
24157
|
+
args[1]
|
|
24150
24158
|
);
|
|
24151
24159
|
case "some":
|
|
24152
|
-
return await someInArray(
|
|
24160
|
+
return await someInArray(
|
|
24161
|
+
value,
|
|
24162
|
+
getRequiredCallback(methodName, args[0]),
|
|
24163
|
+
options,
|
|
24164
|
+
stack,
|
|
24165
|
+
args[1]
|
|
24166
|
+
);
|
|
24153
24167
|
case "every":
|
|
24154
|
-
return await everyInArray(
|
|
24168
|
+
return await everyInArray(
|
|
24169
|
+
value,
|
|
24170
|
+
getRequiredCallback(methodName, args[0]),
|
|
24171
|
+
options,
|
|
24172
|
+
stack,
|
|
24173
|
+
args[1]
|
|
24174
|
+
);
|
|
24155
24175
|
case "reduce":
|
|
24156
24176
|
return budgetProducedValue(
|
|
24157
24177
|
await reduceArray(
|
|
@@ -24177,11 +24197,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
|
|
|
24177
24197
|
options.budget
|
|
24178
24198
|
);
|
|
24179
24199
|
case "forEach":
|
|
24180
|
-
await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack);
|
|
24200
|
+
await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]);
|
|
24181
24201
|
return void 0;
|
|
24182
24202
|
case "flatMap":
|
|
24183
24203
|
return budgetProducedValue(
|
|
24184
|
-
await flatMapArray(
|
|
24204
|
+
await flatMapArray(
|
|
24205
|
+
value,
|
|
24206
|
+
getRequiredCallback(methodName, args[0]),
|
|
24207
|
+
options,
|
|
24208
|
+
stack,
|
|
24209
|
+
args[1]
|
|
24210
|
+
),
|
|
24185
24211
|
options.budget
|
|
24186
24212
|
);
|
|
24187
24213
|
case "flat":
|
|
@@ -24318,83 +24344,91 @@ function getRequiredCallback(methodName, value) {
|
|
|
24318
24344
|
}
|
|
24319
24345
|
return value;
|
|
24320
24346
|
}
|
|
24321
|
-
async function mapArray(value, callback, options, stack) {
|
|
24347
|
+
async function mapArray(value, callback, options, stack, thisValue) {
|
|
24322
24348
|
const length = value.length;
|
|
24323
24349
|
const result = new Array(length);
|
|
24324
24350
|
for (let index = 0; index < length; index += 1) {
|
|
24325
24351
|
if (!(index in value)) {
|
|
24326
24352
|
continue;
|
|
24327
24353
|
}
|
|
24328
|
-
result[index] = await callArrayCallback(
|
|
24354
|
+
result[index] = await callArrayCallback(
|
|
24355
|
+
callback,
|
|
24356
|
+
value[index],
|
|
24357
|
+
index,
|
|
24358
|
+
value,
|
|
24359
|
+
options,
|
|
24360
|
+
stack,
|
|
24361
|
+
thisValue
|
|
24362
|
+
);
|
|
24329
24363
|
}
|
|
24330
24364
|
return result;
|
|
24331
24365
|
}
|
|
24332
|
-
async function filterArray(value, callback, options, stack) {
|
|
24366
|
+
async function filterArray(value, callback, options, stack, thisValue) {
|
|
24333
24367
|
const length = value.length;
|
|
24334
24368
|
const result = [];
|
|
24335
24369
|
for (let index = 0; index < length; index += 1) {
|
|
24336
24370
|
if (!(index in value)) {
|
|
24337
24371
|
continue;
|
|
24338
24372
|
}
|
|
24339
|
-
if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
|
|
24373
|
+
if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
|
|
24340
24374
|
result.push(value[index]);
|
|
24341
24375
|
}
|
|
24342
24376
|
}
|
|
24343
24377
|
return result;
|
|
24344
24378
|
}
|
|
24345
|
-
async function findInArray(value, callback, options, stack) {
|
|
24346
|
-
const index = await findIndexInArray(value, callback, options, stack);
|
|
24379
|
+
async function findInArray(value, callback, options, stack, thisValue) {
|
|
24380
|
+
const index = await findIndexInArray(value, callback, options, stack, thisValue);
|
|
24347
24381
|
return index < 0 ? void 0 : value[index];
|
|
24348
24382
|
}
|
|
24349
|
-
async function findIndexInArray(value, callback, options, stack) {
|
|
24383
|
+
async function findIndexInArray(value, callback, options, stack, thisValue) {
|
|
24350
24384
|
const length = value.length;
|
|
24351
24385
|
for (let index = 0; index < length; index += 1) {
|
|
24352
24386
|
const entry = index in value ? value[index] : void 0;
|
|
24353
|
-
if (await callArrayCallback(callback, entry, index, value, options, stack)) {
|
|
24387
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
24354
24388
|
return index;
|
|
24355
24389
|
}
|
|
24356
24390
|
}
|
|
24357
24391
|
return -1;
|
|
24358
24392
|
}
|
|
24359
|
-
async function findLastInArray(value, callback, options, stack) {
|
|
24393
|
+
async function findLastInArray(value, callback, options, stack, thisValue) {
|
|
24360
24394
|
const length = value.length;
|
|
24361
24395
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
24362
24396
|
const entry = index in value ? value[index] : void 0;
|
|
24363
|
-
if (await callArrayCallback(callback, entry, index, value, options, stack)) {
|
|
24397
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
24364
24398
|
return entry;
|
|
24365
24399
|
}
|
|
24366
24400
|
}
|
|
24367
24401
|
return void 0;
|
|
24368
24402
|
}
|
|
24369
|
-
async function findLastIndexInArray(value, callback, options, stack) {
|
|
24403
|
+
async function findLastIndexInArray(value, callback, options, stack, thisValue) {
|
|
24370
24404
|
const length = value.length;
|
|
24371
24405
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
24372
24406
|
const entry = index in value ? value[index] : void 0;
|
|
24373
|
-
if (await callArrayCallback(callback, entry, index, value, options, stack)) {
|
|
24407
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
24374
24408
|
return index;
|
|
24375
24409
|
}
|
|
24376
24410
|
}
|
|
24377
24411
|
return -1;
|
|
24378
24412
|
}
|
|
24379
|
-
async function someInArray(value, callback, options, stack) {
|
|
24413
|
+
async function someInArray(value, callback, options, stack, thisValue) {
|
|
24380
24414
|
const length = value.length;
|
|
24381
24415
|
for (let index = 0; index < length; index += 1) {
|
|
24382
24416
|
if (!(index in value)) {
|
|
24383
24417
|
continue;
|
|
24384
24418
|
}
|
|
24385
|
-
if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
|
|
24419
|
+
if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
|
|
24386
24420
|
return true;
|
|
24387
24421
|
}
|
|
24388
24422
|
}
|
|
24389
24423
|
return false;
|
|
24390
24424
|
}
|
|
24391
|
-
async function everyInArray(value, callback, options, stack) {
|
|
24425
|
+
async function everyInArray(value, callback, options, stack, thisValue) {
|
|
24392
24426
|
const length = value.length;
|
|
24393
24427
|
for (let index = 0; index < length; index += 1) {
|
|
24394
24428
|
if (!(index in value)) {
|
|
24395
24429
|
continue;
|
|
24396
24430
|
}
|
|
24397
|
-
if (!await callArrayCallback(callback, value[index], index, value, options, stack)) {
|
|
24431
|
+
if (!await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
|
|
24398
24432
|
return false;
|
|
24399
24433
|
}
|
|
24400
24434
|
}
|
|
@@ -24442,23 +24476,31 @@ async function reduceFromRight(value, callback, accumulator, startIndex, length,
|
|
|
24442
24476
|
}
|
|
24443
24477
|
return current;
|
|
24444
24478
|
}
|
|
24445
|
-
async function forEachArray(value, callback, options, stack) {
|
|
24479
|
+
async function forEachArray(value, callback, options, stack, thisValue) {
|
|
24446
24480
|
const length = value.length;
|
|
24447
24481
|
for (let index = 0; index < length; index += 1) {
|
|
24448
24482
|
if (!(index in value)) {
|
|
24449
24483
|
continue;
|
|
24450
24484
|
}
|
|
24451
|
-
await callArrayCallback(callback, value[index], index, value, options, stack);
|
|
24485
|
+
await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
|
|
24452
24486
|
}
|
|
24453
24487
|
}
|
|
24454
|
-
async function flatMapArray(value, callback, options, stack) {
|
|
24488
|
+
async function flatMapArray(value, callback, options, stack, thisValue) {
|
|
24455
24489
|
const length = value.length;
|
|
24456
24490
|
const result = [];
|
|
24457
24491
|
for (let index = 0; index < length; index += 1) {
|
|
24458
24492
|
if (!(index in value)) {
|
|
24459
24493
|
continue;
|
|
24460
24494
|
}
|
|
24461
|
-
const mapped = await callArrayCallback(
|
|
24495
|
+
const mapped = await callArrayCallback(
|
|
24496
|
+
callback,
|
|
24497
|
+
value[index],
|
|
24498
|
+
index,
|
|
24499
|
+
value,
|
|
24500
|
+
options,
|
|
24501
|
+
stack,
|
|
24502
|
+
thisValue
|
|
24503
|
+
);
|
|
24462
24504
|
if (Array.isArray(mapped)) {
|
|
24463
24505
|
for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
|
|
24464
24506
|
if (!(mappedIndex in mapped)) {
|
|
@@ -24530,8 +24572,8 @@ async function compareEntries(left, right, comparator, options, stack) {
|
|
|
24530
24572
|
const result = Number(await options.callClosure(comparator, [left, right], stack));
|
|
24531
24573
|
return Number.isNaN(result) ? 0 : result;
|
|
24532
24574
|
}
|
|
24533
|
-
async function callArrayCallback(callback, value, index, array, options, stack) {
|
|
24534
|
-
return options.callClosure(callback, [value, index, array], stack);
|
|
24575
|
+
async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
|
|
24576
|
+
return options.callClosure(callback, [value, index, array], stack, thisValue);
|
|
24535
24577
|
}
|
|
24536
24578
|
function findNextDefinedIndex(value, startIndex, direction, length) {
|
|
24537
24579
|
for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
|
|
@@ -24721,7 +24763,7 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
|
|
|
24721
24763
|
const entries = [...target.entries];
|
|
24722
24764
|
for (let index = 0; index < entries.length; index += 1) {
|
|
24723
24765
|
const [key, value] = entries[index];
|
|
24724
|
-
await options.callClosure(callback, [value, key, target], stack);
|
|
24766
|
+
await options.callClosure(callback, [value, key, target], stack, args[1]);
|
|
24725
24767
|
}
|
|
24726
24768
|
} finally {
|
|
24727
24769
|
leaveCallback();
|
|
@@ -25490,7 +25532,7 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
|
|
|
25490
25532
|
const values = [...target.values];
|
|
25491
25533
|
for (let index = 0; index < values.length; index += 1) {
|
|
25492
25534
|
const value = values[index];
|
|
25493
|
-
await options.callClosure(callback, [value, value, target], stack);
|
|
25535
|
+
await options.callClosure(callback, [value, value, target], stack, args[1]);
|
|
25494
25536
|
}
|
|
25495
25537
|
} finally {
|
|
25496
25538
|
leaveCallback();
|
|
@@ -28069,19 +28111,19 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
|
|
|
28069
28111
|
function createArrayMethodOptions(context) {
|
|
28070
28112
|
return {
|
|
28071
28113
|
budget: context.budget,
|
|
28072
|
-
callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
|
|
28114
|
+
callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
|
|
28073
28115
|
};
|
|
28074
28116
|
}
|
|
28075
28117
|
function createMapMethodOptions(context) {
|
|
28076
28118
|
return {
|
|
28077
28119
|
budget: context.budget,
|
|
28078
|
-
callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
|
|
28120
|
+
callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
|
|
28079
28121
|
};
|
|
28080
28122
|
}
|
|
28081
28123
|
function createSetMethodOptions(context) {
|
|
28082
28124
|
return {
|
|
28083
28125
|
budget: context.budget,
|
|
28084
|
-
callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
|
|
28126
|
+
callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
|
|
28085
28127
|
};
|
|
28086
28128
|
}
|
|
28087
28129
|
function createFunctionMethodOptions(context) {
|
|
@@ -29135,4 +29177,4 @@ export {
|
|
|
29135
29177
|
FileSnapshotBackend,
|
|
29136
29178
|
run
|
|
29137
29179
|
};
|
|
29138
|
-
//# sourceMappingURL=chunk-
|
|
29180
|
+
//# sourceMappingURL=chunk-CGS4H4L3.js.map
|