poe-code 13.0.2 → 13.0.3
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 +146 -95
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-RIQRHKCB.js → chunk-73LWNNUG.js} +146 -95
- package/packages/safe-js/dist/chunks/{chunk-RIQRHKCB.js.map → chunk-73LWNNUG.js.map} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-JP474LP7.js → chunk-QCJ7UAMC.js} +2 -2
- 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/methods/array.js +136 -71
- /package/packages/safe-js/dist/chunks/{chunk-JP474LP7.js.map → chunk-QCJ7UAMC.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-73LWNNUG.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8183,4 +8183,4 @@ export {
|
|
|
8183
8183
|
parseMcpConfig,
|
|
8184
8184
|
makeMcpModule
|
|
8185
8185
|
};
|
|
8186
|
-
//# sourceMappingURL=chunk-
|
|
8186
|
+
//# sourceMappingURL=chunk-QCJ7UAMC.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-QCJ7UAMC.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-73LWNNUG.js";
|
|
38
38
|
import "./chunks/chunk-ZRX5HT5L.js";
|
|
39
39
|
import "./chunks/chunk-WVN5MMDR.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
runWithSpawnUsageAccumulator,
|
|
30
30
|
splitFrontmatter,
|
|
31
31
|
supportsSpawnMode
|
|
32
|
-
} from "./chunks/chunk-
|
|
32
|
+
} from "./chunks/chunk-QCJ7UAMC.js";
|
|
33
33
|
import {
|
|
34
34
|
Budget,
|
|
35
35
|
FileSnapshotBackend,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
registerPendingHostCallPolicy,
|
|
52
52
|
restore,
|
|
53
53
|
run
|
|
54
|
-
} from "./chunks/chunk-
|
|
54
|
+
} from "./chunks/chunk-73LWNNUG.js";
|
|
55
55
|
import "./chunks/chunk-ZRX5HT5L.js";
|
|
56
56
|
import "./chunks/chunk-WVN5MMDR.js";
|
|
57
57
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSandboxClosure, isSandboxClosure, isSandboxMap, isSandboxPromise, isSandboxSet } from "../values.js";
|
|
2
|
-
import { assertCollectionMutable,
|
|
2
|
+
import { assertCollectionMutable, enterRunningState } from "../running-state.js";
|
|
3
3
|
const activeArrayCallbacks = new WeakMap();
|
|
4
4
|
const arrayMethodNames = new Set([
|
|
5
5
|
"map",
|
|
@@ -76,7 +76,7 @@ export async function callArrayMethod(value, methodName, args, options, stack =
|
|
|
76
76
|
if (isCallbackArrayMethod(methodName)) {
|
|
77
77
|
let callbackState = activeArrayCallbacks.get(value);
|
|
78
78
|
if (callbackState === undefined) {
|
|
79
|
-
callbackState = { depth: 0, leave:
|
|
79
|
+
callbackState = { depth: 0, leave: enterRunningState(value) };
|
|
80
80
|
activeArrayCallbacks.set(value, callbackState);
|
|
81
81
|
}
|
|
82
82
|
callbackState.depth += 1;
|
|
@@ -267,34 +267,57 @@ function getRequiredCallback(methodName, value) {
|
|
|
267
267
|
async function mapArray(value, callback, options, stack, thisValue) {
|
|
268
268
|
const length = value.length;
|
|
269
269
|
const result = new Array(length);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
271
|
+
try {
|
|
272
|
+
for (let index = 0; index < length; index += 1) {
|
|
273
|
+
options.budget.visitNode();
|
|
274
|
+
if (!(index in value)) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
result[index] = await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
|
|
273
278
|
}
|
|
274
|
-
result
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
options.budget.setRetainedValues(result, undefined);
|
|
275
283
|
}
|
|
276
|
-
return result;
|
|
277
284
|
}
|
|
278
285
|
async function filterArray(value, callback, options, stack, thisValue) {
|
|
279
286
|
const length = value.length;
|
|
280
287
|
const result = [];
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
288
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
289
|
+
try {
|
|
290
|
+
for (let index = 0; index < length; index += 1) {
|
|
291
|
+
options.budget.visitNode();
|
|
292
|
+
if (!(index in value)) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const entry = value[index];
|
|
296
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
297
|
+
result.push(entry);
|
|
298
|
+
}
|
|
287
299
|
}
|
|
300
|
+
return result;
|
|
301
|
+
}
|
|
302
|
+
finally {
|
|
303
|
+
options.budget.setRetainedValues(result, undefined);
|
|
288
304
|
}
|
|
289
|
-
return result;
|
|
290
305
|
}
|
|
291
306
|
async function findInArray(value, callback, options, stack, thisValue) {
|
|
292
|
-
const
|
|
293
|
-
|
|
307
|
+
const length = value.length;
|
|
308
|
+
for (let index = 0; index < length; index += 1) {
|
|
309
|
+
options.budget.visitNode();
|
|
310
|
+
const entry = index in value ? value[index] : undefined;
|
|
311
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
312
|
+
return entry;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return undefined;
|
|
294
316
|
}
|
|
295
317
|
async function findIndexInArray(value, callback, options, stack, thisValue) {
|
|
296
318
|
const length = value.length;
|
|
297
319
|
for (let index = 0; index < length; index += 1) {
|
|
320
|
+
options.budget.visitNode();
|
|
298
321
|
const entry = index in value ? value[index] : undefined;
|
|
299
322
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
300
323
|
return index;
|
|
@@ -305,6 +328,7 @@ async function findIndexInArray(value, callback, options, stack, thisValue) {
|
|
|
305
328
|
async function findLastInArray(value, callback, options, stack, thisValue) {
|
|
306
329
|
const length = value.length;
|
|
307
330
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
331
|
+
options.budget.visitNode();
|
|
308
332
|
const entry = index in value ? value[index] : undefined;
|
|
309
333
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
310
334
|
return entry;
|
|
@@ -315,6 +339,7 @@ async function findLastInArray(value, callback, options, stack, thisValue) {
|
|
|
315
339
|
async function findLastIndexInArray(value, callback, options, stack, thisValue) {
|
|
316
340
|
const length = value.length;
|
|
317
341
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
342
|
+
options.budget.visitNode();
|
|
318
343
|
const entry = index in value ? value[index] : undefined;
|
|
319
344
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
320
345
|
return index;
|
|
@@ -325,6 +350,7 @@ async function findLastIndexInArray(value, callback, options, stack, thisValue)
|
|
|
325
350
|
async function someInArray(value, callback, options, stack, thisValue) {
|
|
326
351
|
const length = value.length;
|
|
327
352
|
for (let index = 0; index < length; index += 1) {
|
|
353
|
+
options.budget.visitNode();
|
|
328
354
|
if (!(index in value)) {
|
|
329
355
|
continue;
|
|
330
356
|
}
|
|
@@ -337,6 +363,7 @@ async function someInArray(value, callback, options, stack, thisValue) {
|
|
|
337
363
|
async function everyInArray(value, callback, options, stack, thisValue) {
|
|
338
364
|
const length = value.length;
|
|
339
365
|
for (let index = 0; index < length; index += 1) {
|
|
366
|
+
options.budget.visitNode();
|
|
340
367
|
if (!(index in value)) {
|
|
341
368
|
continue;
|
|
342
369
|
}
|
|
@@ -348,10 +375,10 @@ async function everyInArray(value, callback, options, stack, thisValue) {
|
|
|
348
375
|
}
|
|
349
376
|
async function reduceArray(value, callback, hasInitialValue, initialValue, options, stack) {
|
|
350
377
|
const length = value.length;
|
|
351
|
-
const start = findNextDefinedIndex(value, 0, 1, length);
|
|
352
378
|
if (hasInitialValue) {
|
|
353
|
-
return reduceFromLeft(value, callback, initialValue,
|
|
379
|
+
return reduceFromLeft(value, callback, initialValue, 0, length, options, stack);
|
|
354
380
|
}
|
|
381
|
+
const start = findNextDefinedIndex(value, 0, 1, length, options.budget);
|
|
355
382
|
if (start < 0) {
|
|
356
383
|
throw new TypeError("Reduce of empty array with no initial value.");
|
|
357
384
|
}
|
|
@@ -359,10 +386,10 @@ async function reduceArray(value, callback, hasInitialValue, initialValue, optio
|
|
|
359
386
|
}
|
|
360
387
|
async function reduceRightArray(value, callback, hasInitialValue, initialValue, options, stack) {
|
|
361
388
|
const length = value.length;
|
|
362
|
-
const start = findNextDefinedIndex(value, length - 1, -1, length);
|
|
363
389
|
if (hasInitialValue) {
|
|
364
|
-
return reduceFromRight(value, callback, initialValue,
|
|
390
|
+
return reduceFromRight(value, callback, initialValue, length - 1, length, options, stack);
|
|
365
391
|
}
|
|
392
|
+
const start = findNextDefinedIndex(value, length - 1, -1, length, options.budget);
|
|
366
393
|
if (start < 0) {
|
|
367
394
|
throw new TypeError("Reduce of empty array with no initial value.");
|
|
368
395
|
}
|
|
@@ -370,27 +397,44 @@ async function reduceRightArray(value, callback, hasInitialValue, initialValue,
|
|
|
370
397
|
}
|
|
371
398
|
async function reduceFromLeft(value, callback, accumulator, startIndex, length, options, stack) {
|
|
372
399
|
let current = accumulator;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
400
|
+
const retainedAccumulator = {};
|
|
401
|
+
options.budget.setRetainedValues(retainedAccumulator, () => [current]);
|
|
402
|
+
try {
|
|
403
|
+
for (let index = startIndex; index < length; index += 1) {
|
|
404
|
+
options.budget.visitNode();
|
|
405
|
+
if (!(index in value)) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
current = await options.callClosure(callback, [current, value[index], index, value], stack);
|
|
376
409
|
}
|
|
377
|
-
|
|
410
|
+
return current;
|
|
411
|
+
}
|
|
412
|
+
finally {
|
|
413
|
+
options.budget.setRetainedValues(retainedAccumulator, undefined);
|
|
378
414
|
}
|
|
379
|
-
return current;
|
|
380
415
|
}
|
|
381
416
|
async function reduceFromRight(value, callback, accumulator, startIndex, length, options, stack) {
|
|
382
417
|
let current = accumulator;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
418
|
+
const retainedAccumulator = {};
|
|
419
|
+
options.budget.setRetainedValues(retainedAccumulator, () => [current]);
|
|
420
|
+
try {
|
|
421
|
+
for (let index = Math.min(startIndex, length - 1); index >= 0; index -= 1) {
|
|
422
|
+
options.budget.visitNode();
|
|
423
|
+
if (!(index in value)) {
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
current = await options.callClosure(callback, [current, value[index], index, value], stack);
|
|
386
427
|
}
|
|
387
|
-
|
|
428
|
+
return current;
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
options.budget.setRetainedValues(retainedAccumulator, undefined);
|
|
388
432
|
}
|
|
389
|
-
return current;
|
|
390
433
|
}
|
|
391
434
|
async function forEachArray(value, callback, options, stack, thisValue) {
|
|
392
435
|
const length = value.length;
|
|
393
436
|
for (let index = 0; index < length; index += 1) {
|
|
437
|
+
options.budget.visitNode();
|
|
394
438
|
if (!(index in value)) {
|
|
395
439
|
continue;
|
|
396
440
|
}
|
|
@@ -400,25 +444,33 @@ async function forEachArray(value, callback, options, stack, thisValue) {
|
|
|
400
444
|
async function flatMapArray(value, callback, options, stack, thisValue) {
|
|
401
445
|
const length = value.length;
|
|
402
446
|
const result = [];
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
447
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
448
|
+
try {
|
|
449
|
+
for (let index = 0; index < length; index += 1) {
|
|
450
|
+
options.budget.visitNode();
|
|
451
|
+
if (!(index in value)) {
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const mapped = await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
|
|
455
|
+
if (Array.isArray(mapped)) {
|
|
456
|
+
for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
|
|
457
|
+
options.budget.visitNode();
|
|
458
|
+
if (!(mappedIndex in mapped)) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
result.push(mapped[mappedIndex]);
|
|
462
|
+
options.budget.allocateArrayLength(result.length);
|
|
412
463
|
}
|
|
413
|
-
|
|
414
|
-
options.budget.allocateArrayLength(result.length);
|
|
464
|
+
continue;
|
|
415
465
|
}
|
|
416
|
-
|
|
466
|
+
result.push(mapped);
|
|
467
|
+
options.budget.allocateArrayLength(result.length);
|
|
417
468
|
}
|
|
418
|
-
result
|
|
419
|
-
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
finally {
|
|
472
|
+
options.budget.setRetainedValues(result, undefined);
|
|
420
473
|
}
|
|
421
|
-
return result;
|
|
422
474
|
}
|
|
423
475
|
function flattenArray(value, depth, budget) {
|
|
424
476
|
const result = [];
|
|
@@ -440,48 +492,61 @@ function appendFlattenedEntries(value, depth, result, budget) {
|
|
|
440
492
|
}
|
|
441
493
|
}
|
|
442
494
|
async function sortArray(value, comparator, options, stack) {
|
|
495
|
+
const length = value.length;
|
|
443
496
|
const definedValues = [];
|
|
444
497
|
let undefinedCount = 0;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
498
|
+
let currentEntry;
|
|
499
|
+
options.budget.setRetainedValues(definedValues, () => [definedValues, currentEntry]);
|
|
500
|
+
try {
|
|
501
|
+
for (let index = 0; index < length; index += 1) {
|
|
502
|
+
options.budget.visitNode();
|
|
503
|
+
if (!(index in value)) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
const entry = value[index];
|
|
507
|
+
if (entry === undefined) {
|
|
508
|
+
undefinedCount += 1;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
definedValues.push(entry);
|
|
512
|
+
}
|
|
513
|
+
for (let index = 1; index < definedValues.length; index += 1) {
|
|
514
|
+
currentEntry = definedValues[index];
|
|
515
|
+
let cursor = index - 1;
|
|
516
|
+
while (cursor >= 0 &&
|
|
517
|
+
(await compareEntries(definedValues[cursor], currentEntry, comparator, options, stack)) > 0) {
|
|
518
|
+
definedValues[cursor + 1] = definedValues[cursor];
|
|
519
|
+
cursor -= 1;
|
|
520
|
+
}
|
|
521
|
+
definedValues[cursor + 1] = currentEntry;
|
|
448
522
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
continue;
|
|
523
|
+
currentEntry = undefined;
|
|
524
|
+
for (let index = 0; index < definedValues.length; index += 1) {
|
|
525
|
+
value[index] = definedValues[index];
|
|
453
526
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
(await compareEntries(definedValues[cursor], entry, comparator, options, stack)) > 0) {
|
|
461
|
-
definedValues[cursor + 1] = definedValues[cursor];
|
|
462
|
-
cursor -= 1;
|
|
527
|
+
for (let index = 0; index < undefinedCount; index += 1) {
|
|
528
|
+
value[definedValues.length + index] = undefined;
|
|
529
|
+
}
|
|
530
|
+
for (let index = definedValues.length + undefinedCount; index < length; index += 1) {
|
|
531
|
+
options.budget.visitNode();
|
|
532
|
+
delete value[index];
|
|
463
533
|
}
|
|
464
|
-
definedValues[cursor + 1] = entry;
|
|
465
|
-
}
|
|
466
|
-
for (let index = 0; index < definedValues.length; index += 1) {
|
|
467
|
-
value[index] = definedValues[index];
|
|
468
|
-
}
|
|
469
|
-
for (let index = 0; index < undefinedCount; index += 1) {
|
|
470
|
-
value[definedValues.length + index] = undefined;
|
|
471
534
|
}
|
|
472
|
-
|
|
473
|
-
|
|
535
|
+
finally {
|
|
536
|
+
options.budget.setRetainedValues(definedValues, undefined);
|
|
474
537
|
}
|
|
475
538
|
}
|
|
476
539
|
async function compareEntries(left, right, comparator, options, stack) {
|
|
540
|
+
options.budget.visitNode();
|
|
477
541
|
const result = Number(await options.callClosure(comparator, [left, right], stack));
|
|
478
542
|
return Number.isNaN(result) ? 0 : result;
|
|
479
543
|
}
|
|
480
544
|
async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
|
|
481
545
|
return options.callClosure(callback, [value, index, array], stack, thisValue);
|
|
482
546
|
}
|
|
483
|
-
function findNextDefinedIndex(value, startIndex, direction, length) {
|
|
547
|
+
function findNextDefinedIndex(value, startIndex, direction, length, budget) {
|
|
484
548
|
for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
|
|
549
|
+
budget.visitNode();
|
|
485
550
|
if (index in value) {
|
|
486
551
|
return index;
|
|
487
552
|
}
|
|
File without changes
|