poe-code 11.0.23 → 11.0.25

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 CHANGED
@@ -136635,7 +136635,7 @@ var init_dump_format = __esm({
136635
136635
  init_arguments2();
136636
136636
  init_arrays();
136637
136637
  DUMP_FORMAT_VERSION = 1;
136638
- EXECUTION_SEMANTICS = "jobs-v6";
136638
+ EXECUTION_SEMANTICS = "jobs-v7";
136639
136639
  SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
136640
136640
  }
136641
136641
  });
@@ -140703,9 +140703,11 @@ var init_random = __esm({
140703
140703
 
140704
140704
  // packages/safejs/src/snapshot/migration.ts
140705
140705
  function validateMigrationSemantics(value) {
140706
- if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6"].includes(value))
140706
+ if (!["jobs-v1", "jobs-v2", "jobs-v3", "jobs-v4", "jobs-v5", "jobs-v6", "jobs-v7"].includes(
140707
+ value
140708
+ ))
140707
140709
  throw new TypeError(
140708
- "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v6)."
140710
+ "Migration requires a supported execution-semantics marker (jobs-v1 through jobs-v7)."
140709
140711
  );
140710
140712
  }
140711
140713
  function validateMigrationJournal(sourceHash, replay, hostCalls = []) {
@@ -140797,7 +140799,7 @@ function restore2(snapshot2, options) {
140797
140799
  assertSnapshotInactive(snapshot2);
140798
140800
  validateDumpEnvelope(snapshot2);
140799
140801
  validateSnapshotMigration(snapshot2.migration, snapshot2.sourceHash);
140800
- if (snapshot2.executionSemantics !== EXECUTION_SEMANTICS && (snapshot2.executionSemantics !== void 0 || snapshot2.promiseReplay !== void 0 || snapshot2.replay !== void 0 || snapshot2.initialInputs !== void 0)) {
140802
+ if (snapshot2.executionSemantics !== EXECUTION_SEMANTICS && snapshot2.executionSemantics !== "jobs-v6" && (snapshot2.executionSemantics !== void 0 || snapshot2.promiseReplay !== void 0 || snapshot2.replay !== void 0 || snapshot2.initialInputs !== void 0)) {
140801
140803
  throw new SnapshotValidationError(
140802
140804
  "unsupportedVersion",
140803
140805
  "$.executionSemantics",
@@ -143060,7 +143062,7 @@ function isAssignableSandboxTarget(value) {
143060
143062
  return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
143061
143063
  }
143062
143064
  async function arrayFromSandboxValues(args, budget) {
143063
- const [items, mapFn] = args;
143065
+ const [items, mapFn, thisValue] = args;
143064
143066
  const iterator = getSandboxIterator(items);
143065
143067
  const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
143066
143068
  if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
@@ -143071,7 +143073,7 @@ async function arrayFromSandboxValues(args, budget) {
143071
143073
  }
143072
143074
  const mappedValues = [];
143073
143075
  for (const [index, value] of values.entries()) {
143074
- const result = await mapFn.call([value, index]);
143076
+ const result = await mapFn.call([value, index], { stack: [], thisValue });
143075
143077
  if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
143076
143078
  await result.synchronousPrefix;
143077
143079
  }
@@ -143205,17 +143207,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143205
143207
  switch (methodName) {
143206
143208
  case "map":
143207
143209
  return budgetProducedValue(
143208
- await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143210
+ await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143209
143211
  options.budget
143210
143212
  );
143211
143213
  case "filter":
143212
143214
  return budgetProducedValue(
143213
- await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143215
+ await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143214
143216
  options.budget
143215
143217
  );
143216
143218
  case "find":
143217
143219
  return budgetProducedValue(
143218
- await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143220
+ await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
143219
143221
  options.budget
143220
143222
  );
143221
143223
  case "findIndex":
@@ -143223,11 +143225,18 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143223
143225
  value,
143224
143226
  getRequiredCallback(methodName, args[0]),
143225
143227
  options,
143226
- stack
143228
+ stack,
143229
+ args[1]
143227
143230
  );
143228
143231
  case "findLast":
143229
143232
  return budgetProducedValue(
143230
- await findLastInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143233
+ await findLastInArray(
143234
+ value,
143235
+ getRequiredCallback(methodName, args[0]),
143236
+ options,
143237
+ stack,
143238
+ args[1]
143239
+ ),
143231
143240
  options.budget
143232
143241
  );
143233
143242
  case "findLastIndex":
@@ -143235,12 +143244,25 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143235
143244
  value,
143236
143245
  getRequiredCallback(methodName, args[0]),
143237
143246
  options,
143238
- stack
143247
+ stack,
143248
+ args[1]
143239
143249
  );
143240
143250
  case "some":
143241
- return await someInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143251
+ return await someInArray(
143252
+ value,
143253
+ getRequiredCallback(methodName, args[0]),
143254
+ options,
143255
+ stack,
143256
+ args[1]
143257
+ );
143242
143258
  case "every":
143243
- return await everyInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143259
+ return await everyInArray(
143260
+ value,
143261
+ getRequiredCallback(methodName, args[0]),
143262
+ options,
143263
+ stack,
143264
+ args[1]
143265
+ );
143244
143266
  case "reduce":
143245
143267
  return budgetProducedValue(
143246
143268
  await reduceArray(
@@ -143266,11 +143288,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
143266
143288
  options.budget
143267
143289
  );
143268
143290
  case "forEach":
143269
- await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack);
143291
+ await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]);
143270
143292
  return void 0;
143271
143293
  case "flatMap":
143272
143294
  return budgetProducedValue(
143273
- await flatMapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
143295
+ await flatMapArray(
143296
+ value,
143297
+ getRequiredCallback(methodName, args[0]),
143298
+ options,
143299
+ stack,
143300
+ args[1]
143301
+ ),
143274
143302
  options.budget
143275
143303
  );
143276
143304
  case "flat":
@@ -143407,83 +143435,91 @@ function getRequiredCallback(methodName, value) {
143407
143435
  }
143408
143436
  return value;
143409
143437
  }
143410
- async function mapArray(value, callback, options, stack) {
143438
+ async function mapArray(value, callback, options, stack, thisValue) {
143411
143439
  const length = value.length;
143412
143440
  const result = new Array(length);
143413
143441
  for (let index = 0; index < length; index += 1) {
143414
143442
  if (!(index in value)) {
143415
143443
  continue;
143416
143444
  }
143417
- result[index] = await callArrayCallback(callback, value[index], index, value, options, stack);
143445
+ result[index] = await callArrayCallback(
143446
+ callback,
143447
+ value[index],
143448
+ index,
143449
+ value,
143450
+ options,
143451
+ stack,
143452
+ thisValue
143453
+ );
143418
143454
  }
143419
143455
  return result;
143420
143456
  }
143421
- async function filterArray(value, callback, options, stack) {
143457
+ async function filterArray(value, callback, options, stack, thisValue) {
143422
143458
  const length = value.length;
143423
143459
  const result = [];
143424
143460
  for (let index = 0; index < length; index += 1) {
143425
143461
  if (!(index in value)) {
143426
143462
  continue;
143427
143463
  }
143428
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
143464
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143429
143465
  result.push(value[index]);
143430
143466
  }
143431
143467
  }
143432
143468
  return result;
143433
143469
  }
143434
- async function findInArray(value, callback, options, stack) {
143435
- const index = await findIndexInArray(value, callback, options, stack);
143470
+ async function findInArray(value, callback, options, stack, thisValue) {
143471
+ const index = await findIndexInArray(value, callback, options, stack, thisValue);
143436
143472
  return index < 0 ? void 0 : value[index];
143437
143473
  }
143438
- async function findIndexInArray(value, callback, options, stack) {
143474
+ async function findIndexInArray(value, callback, options, stack, thisValue) {
143439
143475
  const length = value.length;
143440
143476
  for (let index = 0; index < length; index += 1) {
143441
143477
  const entry = index in value ? value[index] : void 0;
143442
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143478
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143443
143479
  return index;
143444
143480
  }
143445
143481
  }
143446
143482
  return -1;
143447
143483
  }
143448
- async function findLastInArray(value, callback, options, stack) {
143484
+ async function findLastInArray(value, callback, options, stack, thisValue) {
143449
143485
  const length = value.length;
143450
143486
  for (let index = length - 1; index >= 0; index -= 1) {
143451
143487
  const entry = index in value ? value[index] : void 0;
143452
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143488
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143453
143489
  return entry;
143454
143490
  }
143455
143491
  }
143456
143492
  return void 0;
143457
143493
  }
143458
- async function findLastIndexInArray(value, callback, options, stack) {
143494
+ async function findLastIndexInArray(value, callback, options, stack, thisValue) {
143459
143495
  const length = value.length;
143460
143496
  for (let index = length - 1; index >= 0; index -= 1) {
143461
143497
  const entry = index in value ? value[index] : void 0;
143462
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
143498
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
143463
143499
  return index;
143464
143500
  }
143465
143501
  }
143466
143502
  return -1;
143467
143503
  }
143468
- async function someInArray(value, callback, options, stack) {
143504
+ async function someInArray(value, callback, options, stack, thisValue) {
143469
143505
  const length = value.length;
143470
143506
  for (let index = 0; index < length; index += 1) {
143471
143507
  if (!(index in value)) {
143472
143508
  continue;
143473
143509
  }
143474
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
143510
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143475
143511
  return true;
143476
143512
  }
143477
143513
  }
143478
143514
  return false;
143479
143515
  }
143480
- async function everyInArray(value, callback, options, stack) {
143516
+ async function everyInArray(value, callback, options, stack, thisValue) {
143481
143517
  const length = value.length;
143482
143518
  for (let index = 0; index < length; index += 1) {
143483
143519
  if (!(index in value)) {
143484
143520
  continue;
143485
143521
  }
143486
- if (!await callArrayCallback(callback, value[index], index, value, options, stack)) {
143522
+ if (!await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
143487
143523
  return false;
143488
143524
  }
143489
143525
  }
@@ -143531,23 +143567,31 @@ async function reduceFromRight(value, callback, accumulator, startIndex, length,
143531
143567
  }
143532
143568
  return current;
143533
143569
  }
143534
- async function forEachArray(value, callback, options, stack) {
143570
+ async function forEachArray(value, callback, options, stack, thisValue) {
143535
143571
  const length = value.length;
143536
143572
  for (let index = 0; index < length; index += 1) {
143537
143573
  if (!(index in value)) {
143538
143574
  continue;
143539
143575
  }
143540
- await callArrayCallback(callback, value[index], index, value, options, stack);
143576
+ await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
143541
143577
  }
143542
143578
  }
143543
- async function flatMapArray(value, callback, options, stack) {
143579
+ async function flatMapArray(value, callback, options, stack, thisValue) {
143544
143580
  const length = value.length;
143545
143581
  const result = [];
143546
143582
  for (let index = 0; index < length; index += 1) {
143547
143583
  if (!(index in value)) {
143548
143584
  continue;
143549
143585
  }
143550
- const mapped = await callArrayCallback(callback, value[index], index, value, options, stack);
143586
+ const mapped = await callArrayCallback(
143587
+ callback,
143588
+ value[index],
143589
+ index,
143590
+ value,
143591
+ options,
143592
+ stack,
143593
+ thisValue
143594
+ );
143551
143595
  if (Array.isArray(mapped)) {
143552
143596
  for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
143553
143597
  if (!(mappedIndex in mapped)) {
@@ -143619,8 +143663,8 @@ async function compareEntries(left, right, comparator, options, stack) {
143619
143663
  const result = Number(await options.callClosure(comparator, [left, right], stack));
143620
143664
  return Number.isNaN(result) ? 0 : result;
143621
143665
  }
143622
- async function callArrayCallback(callback, value, index, array, options, stack) {
143623
- return options.callClosure(callback, [value, index, array], stack);
143666
+ async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
143667
+ return options.callClosure(callback, [value, index, array], stack, thisValue);
143624
143668
  }
143625
143669
  function findNextDefinedIndex(value, startIndex, direction, length) {
143626
143670
  for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
@@ -143850,7 +143894,7 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
143850
143894
  const entries = [...target.entries];
143851
143895
  for (let index = 0; index < entries.length; index += 1) {
143852
143896
  const [key3, value] = entries[index];
143853
- await options.callClosure(callback, [value, key3, target], stack);
143897
+ await options.callClosure(callback, [value, key3, target], stack, args[1]);
143854
143898
  }
143855
143899
  } finally {
143856
143900
  leaveCallback();
@@ -144665,7 +144709,7 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
144665
144709
  const values = [...target.values];
144666
144710
  for (let index = 0; index < values.length; index += 1) {
144667
144711
  const value = values[index];
144668
- await options.callClosure(callback, [value, value, target], stack);
144712
+ await options.callClosure(callback, [value, value, target], stack, args[1]);
144669
144713
  }
144670
144714
  } finally {
144671
144715
  leaveCallback();
@@ -147219,19 +147263,19 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
147219
147263
  function createArrayMethodOptions(context) {
147220
147264
  return {
147221
147265
  budget: context.budget,
147222
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147266
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147223
147267
  };
147224
147268
  }
147225
147269
  function createMapMethodOptions(context) {
147226
147270
  return {
147227
147271
  budget: context.budget,
147228
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147272
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147229
147273
  };
147230
147274
  }
147231
147275
  function createSetMethodOptions(context) {
147232
147276
  return {
147233
147277
  budget: context.budget,
147234
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
147278
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
147235
147279
  };
147236
147280
  }
147237
147281
  function createFunctionMethodOptions(context) {
@@ -148196,6 +148240,8 @@ function run(source, options = {}) {
148196
148240
  options.signal?.addEventListener("abort", captureCancellationSnapshot, { once: true });
148197
148241
  try {
148198
148242
  const restoredSnapshot = options.snapshot === void 0 ? void 0 : restore2(options.snapshot, { source });
148243
+ const executionSemantics = restoredSnapshot?.executionSemantics === "jobs-v6" ? "jobs-v6" : EXECUTION_SEMANTICS;
148244
+ const convertInitialInput = (convert) => executionSemantics === "jobs-v6" ? convert() : promiseReplayContext.exit(convert);
148199
148245
  if (restoredSnapshot !== void 0) {
148200
148246
  leaveSnapshotRun = enterSnapshotRun(restoredSnapshot);
148201
148247
  }
@@ -148221,13 +148267,15 @@ function run(source, options = {}) {
148221
148267
  ...restoredSnapshot,
148222
148268
  resumeNodeId: restoredSnapshot.pendingAwaits?.[0]?.nodeId
148223
148269
  } : void 0;
148224
- const callerBindings = options.bindings === void 0 ? {} : wrapCallerInjectedBindings(options.bindings, {
148225
- budget,
148226
- hostCalls,
148227
- moduleId: "<bindings>",
148228
- signal: options.signal,
148229
- lifecycle
148230
- });
148270
+ const callerBindings = convertInitialInput(
148271
+ () => options.bindings === void 0 ? {} : wrapCallerInjectedBindings(options.bindings, {
148272
+ budget,
148273
+ hostCalls,
148274
+ moduleId: "<bindings>",
148275
+ signal: options.signal,
148276
+ lifecycle
148277
+ })
148278
+ );
148231
148279
  const builtinBindings = {
148232
148280
  ...createConsoleJsonGlobals({
148233
148281
  budget,
@@ -148252,7 +148300,9 @@ function run(source, options = {}) {
148252
148300
  }),
148253
148301
  ...createRegexGlobals()
148254
148302
  };
148255
- const importMeta = deepCopyToSandbox(options.importMeta ?? {});
148303
+ const importMeta = convertInitialInput(
148304
+ () => deepCopyToSandbox(options.importMeta ?? {})
148305
+ );
148256
148306
  if (restoredSnapshot?.migration !== void 0) {
148257
148307
  if (Object.hasOwn(importMeta, "migration"))
148258
148308
  throw new TypeError("import.meta.migration is reserved for migrated checkpoint state.");
@@ -148266,13 +148316,17 @@ function run(source, options = {}) {
148266
148316
  const initialInputs = prepareReplayInputs(
148267
148317
  {
148268
148318
  bindings: callerBindings,
148269
- imports: resolveModuleImports(module, options.modules, {
148270
- budget,
148271
- hostCalls,
148272
- signal: options.signal,
148273
- allowMissing: restoredSnapshot?.initialInputs !== void 0
148274
- }),
148275
- entryPointArgs: options.entryPointArgs === void 0 ? void 0 : deepCopyToSandbox([...options.entryPointArgs]),
148319
+ imports: convertInitialInput(
148320
+ () => resolveModuleImports(module, options.modules, {
148321
+ budget,
148322
+ hostCalls,
148323
+ signal: options.signal,
148324
+ allowMissing: restoredSnapshot?.initialInputs !== void 0
148325
+ })
148326
+ ),
148327
+ entryPointArgs: convertInitialInput(
148328
+ () => options.entryPointArgs === void 0 ? void 0 : deepCopyToSandbox([...options.entryPointArgs])
148329
+ ),
148276
148330
  importMeta
148277
148331
  },
148278
148332
  restoredSnapshot?.initialInputs,
@@ -148338,6 +148392,7 @@ function run(source, options = {}) {
148338
148392
  });
148339
148393
  snapshotScheduler = activeSnapshotScheduler;
148340
148394
  createFailureSnapshot = () => createRunSnapshot({
148395
+ executionSemantics,
148341
148396
  migration: restoredSnapshot?.migration,
148342
148397
  bindings: executionScope.snapshot().bindings,
148343
148398
  clock: options.clock,
@@ -148364,6 +148419,7 @@ function run(source, options = {}) {
148364
148419
  }
148365
148420
  const interpreterSnapshot2 = yieldPoint.snapshot();
148366
148421
  snapshot3 = createRunSnapshot({
148422
+ executionSemantics,
148367
148423
  migration: restoredSnapshot?.migration,
148368
148424
  bindings: interpreterSnapshot2.bindings,
148369
148425
  clock: options.clock,
@@ -148406,6 +148462,7 @@ function run(source, options = {}) {
148406
148462
  }
148407
148463
  const interpreterSnapshot2 = yieldPoint.snapshot();
148408
148464
  snapshot3 = createRunSnapshot({
148465
+ executionSemantics,
148409
148466
  migration: restoredSnapshot?.migration,
148410
148467
  bindings: interpreterSnapshot2.bindings,
148411
148468
  clock: options.clock,
@@ -148440,6 +148497,7 @@ function run(source, options = {}) {
148440
148497
  replayError = error3.message;
148441
148498
  }
148442
148499
  const snapshot2 = createRunSnapshot({
148500
+ executionSemantics,
148443
148501
  migration: restoredSnapshot?.migration,
148444
148502
  bindings: executionScope.snapshot().bindings,
148445
148503
  clock: options.clock,
@@ -148609,7 +148667,7 @@ function createExecutableNode(module) {
148609
148667
  function createRunSnapshot(input) {
148610
148668
  return {
148611
148669
  version: DUMP_FORMAT_VERSION,
148612
- executionSemantics: EXECUTION_SEMANTICS,
148670
+ executionSemantics: input.executionSemantics,
148613
148671
  sourceHash: input.sourceHash,
148614
148672
  ...input.migration === void 0 ? {} : { migration: structuredClone(input.migration) },
148615
148673
  bindings: input.bindings,
@@ -155717,7 +155775,7 @@ var init_package2 = __esm({
155717
155775
  "package.json"() {
155718
155776
  package_default2 = {
155719
155777
  name: "poe-code",
155720
- version: "11.0.23",
155778
+ version: "11.0.25",
155721
155779
  description: "CLI tool to configure Poe API for developer workflows.",
155722
155780
  license: "MIT",
155723
155781
  type: "module",