poe-code 11.0.22 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "11.0.22",
3
+ "version": "11.0.24",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22177,7 +22177,7 @@ function invokeHostCallback(invoke, options) {
22177
22177
  }
22178
22178
  lifecycle.hostCallbackDepth += 1;
22179
22179
  try {
22180
- const result = invoke();
22180
+ const result = lifecycle.hostCallbackContext.run(true, invoke);
22181
22181
  if (isPromiseLike3(result)) {
22182
22182
  return Promise.resolve(result).finally(() => {
22183
22183
  lifecycle.hostCallbackDepth -= 1;
@@ -22877,8 +22877,8 @@ function createDumpController(lifecycle) {
22877
22877
  }
22878
22878
  settlePendingSnapshot(createSnapshot());
22879
22879
  },
22880
- requestCurrentSnapshot() {
22881
- assertDumpAllowed();
22880
+ requestCurrentSnapshot(options = {}) {
22881
+ assertDumpAllowed(options);
22882
22882
  if (failed !== void 0) {
22883
22883
  return Promise.reject(failed.error);
22884
22884
  }
@@ -22889,10 +22889,10 @@ function createDumpController(lifecycle) {
22889
22889
  return Promise.reject(error);
22890
22890
  }
22891
22891
  }
22892
- return this.requestSnapshot();
22892
+ return this.requestSnapshot(options);
22893
22893
  },
22894
22894
  requestSnapshot(options = {}) {
22895
- assertDumpAllowed();
22895
+ assertDumpAllowed(options);
22896
22896
  if (failed !== void 0) {
22897
22897
  if ((options.onFailure === "checkpoint" || options.onFailure === void 0 && isDataBudgetError(failed.error)) && finalSnapshot !== void 0) {
22898
22898
  try {
@@ -22914,6 +22914,9 @@ function createDumpController(lifecycle) {
22914
22914
  return Promise.reject(error);
22915
22915
  }
22916
22916
  }
22917
+ if (options.mode === "replay" && (latestSnapshot !== void 0 || latestSnapshotFactory !== void 0)) {
22918
+ return this.requestCurrentSnapshot(options);
22919
+ }
22917
22920
  if (pendingRequest !== void 0) {
22918
22921
  return pendingRequest.promise;
22919
22922
  }
@@ -22931,8 +22934,8 @@ function createDumpController(lifecycle) {
22931
22934
  return promise;
22932
22935
  }
22933
22936
  };
22934
- function assertDumpAllowed() {
22935
- if ((lifecycle?.hostCallbackDepth ?? 0) > 0) {
22937
+ function assertDumpAllowed(options) {
22938
+ if ((lifecycle?.hostCallbackDepth ?? 0) > 0 && (options.mode !== "replay" || lifecycle?.hostCallbackContext.getStore() === true)) {
22936
22939
  throw new SandboxError("reentry");
22937
22940
  }
22938
22941
  }
@@ -23170,6 +23173,9 @@ function isLockedFileError(error) {
23170
23173
  return code !== void 0 && LOCKED_FILE_ERROR_CODES.has(code);
23171
23174
  }
23172
23175
 
23176
+ // packages/safejs/src/run.ts
23177
+ import { AsyncLocalStorage as AsyncLocalStorage6 } from "node:async_hooks";
23178
+
23173
23179
  // packages/safejs/src/interp/resources.ts
23174
23180
  import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
23175
23181
  var runResources = new AsyncLocalStorage5();
@@ -23936,7 +23942,7 @@ function isAssignableSandboxTarget(value) {
23936
23942
  return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
23937
23943
  }
23938
23944
  async function arrayFromSandboxValues(args, budget) {
23939
- const [items, mapFn] = args;
23945
+ const [items, mapFn, thisValue] = args;
23940
23946
  const iterator = getSandboxIterator(items);
23941
23947
  const values = iterator === void 0 ? Reflect.apply(Array.from, Array, [items]) : await collectIteratorValues(iterator);
23942
23948
  if (mapFn === void 0 || !isSandboxClosure(mapFn)) {
@@ -23947,7 +23953,7 @@ async function arrayFromSandboxValues(args, budget) {
23947
23953
  }
23948
23954
  const mappedValues = [];
23949
23955
  for (const [index, value] of values.entries()) {
23950
- const result = await mapFn.call([value, index]);
23956
+ const result = await mapFn.call([value, index], { stack: [], thisValue });
23951
23957
  if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
23952
23958
  await result.synchronousPrefix;
23953
23959
  }
@@ -24110,17 +24116,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
24110
24116
  switch (methodName) {
24111
24117
  case "map":
24112
24118
  return budgetProducedValue(
24113
- await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
24119
+ await mapArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
24114
24120
  options.budget
24115
24121
  );
24116
24122
  case "filter":
24117
24123
  return budgetProducedValue(
24118
- await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack),
24124
+ await filterArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
24119
24125
  options.budget
24120
24126
  );
24121
24127
  case "find":
24122
24128
  return budgetProducedValue(
24123
- await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
24129
+ await findInArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]),
24124
24130
  options.budget
24125
24131
  );
24126
24132
  case "findIndex":
@@ -24128,11 +24134,18 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
24128
24134
  value,
24129
24135
  getRequiredCallback(methodName, args[0]),
24130
24136
  options,
24131
- stack
24137
+ stack,
24138
+ args[1]
24132
24139
  );
24133
24140
  case "findLast":
24134
24141
  return budgetProducedValue(
24135
- await findLastInArray(value, getRequiredCallback(methodName, args[0]), options, stack),
24142
+ await findLastInArray(
24143
+ value,
24144
+ getRequiredCallback(methodName, args[0]),
24145
+ options,
24146
+ stack,
24147
+ args[1]
24148
+ ),
24136
24149
  options.budget
24137
24150
  );
24138
24151
  case "findLastIndex":
@@ -24140,12 +24153,25 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
24140
24153
  value,
24141
24154
  getRequiredCallback(methodName, args[0]),
24142
24155
  options,
24143
- stack
24156
+ stack,
24157
+ args[1]
24144
24158
  );
24145
24159
  case "some":
24146
- return await someInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
24160
+ return await someInArray(
24161
+ value,
24162
+ getRequiredCallback(methodName, args[0]),
24163
+ options,
24164
+ stack,
24165
+ args[1]
24166
+ );
24147
24167
  case "every":
24148
- return await everyInArray(value, getRequiredCallback(methodName, args[0]), options, stack);
24168
+ return await everyInArray(
24169
+ value,
24170
+ getRequiredCallback(methodName, args[0]),
24171
+ options,
24172
+ stack,
24173
+ args[1]
24174
+ );
24149
24175
  case "reduce":
24150
24176
  return budgetProducedValue(
24151
24177
  await reduceArray(
@@ -24171,11 +24197,17 @@ async function callArrayMethodUnlocked(value, methodName, args, options, stack)
24171
24197
  options.budget
24172
24198
  );
24173
24199
  case "forEach":
24174
- await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack);
24200
+ await forEachArray(value, getRequiredCallback(methodName, args[0]), options, stack, args[1]);
24175
24201
  return void 0;
24176
24202
  case "flatMap":
24177
24203
  return budgetProducedValue(
24178
- await flatMapArray(value, getRequiredCallback(methodName, args[0]), options, stack),
24204
+ await flatMapArray(
24205
+ value,
24206
+ getRequiredCallback(methodName, args[0]),
24207
+ options,
24208
+ stack,
24209
+ args[1]
24210
+ ),
24179
24211
  options.budget
24180
24212
  );
24181
24213
  case "flat":
@@ -24312,83 +24344,91 @@ function getRequiredCallback(methodName, value) {
24312
24344
  }
24313
24345
  return value;
24314
24346
  }
24315
- async function mapArray(value, callback, options, stack) {
24347
+ async function mapArray(value, callback, options, stack, thisValue) {
24316
24348
  const length = value.length;
24317
24349
  const result = new Array(length);
24318
24350
  for (let index = 0; index < length; index += 1) {
24319
24351
  if (!(index in value)) {
24320
24352
  continue;
24321
24353
  }
24322
- result[index] = await callArrayCallback(callback, value[index], index, value, options, stack);
24354
+ result[index] = await callArrayCallback(
24355
+ callback,
24356
+ value[index],
24357
+ index,
24358
+ value,
24359
+ options,
24360
+ stack,
24361
+ thisValue
24362
+ );
24323
24363
  }
24324
24364
  return result;
24325
24365
  }
24326
- async function filterArray(value, callback, options, stack) {
24366
+ async function filterArray(value, callback, options, stack, thisValue) {
24327
24367
  const length = value.length;
24328
24368
  const result = [];
24329
24369
  for (let index = 0; index < length; index += 1) {
24330
24370
  if (!(index in value)) {
24331
24371
  continue;
24332
24372
  }
24333
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
24373
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
24334
24374
  result.push(value[index]);
24335
24375
  }
24336
24376
  }
24337
24377
  return result;
24338
24378
  }
24339
- async function findInArray(value, callback, options, stack) {
24340
- 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);
24341
24381
  return index < 0 ? void 0 : value[index];
24342
24382
  }
24343
- async function findIndexInArray(value, callback, options, stack) {
24383
+ async function findIndexInArray(value, callback, options, stack, thisValue) {
24344
24384
  const length = value.length;
24345
24385
  for (let index = 0; index < length; index += 1) {
24346
24386
  const entry = index in value ? value[index] : void 0;
24347
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
24387
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24348
24388
  return index;
24349
24389
  }
24350
24390
  }
24351
24391
  return -1;
24352
24392
  }
24353
- async function findLastInArray(value, callback, options, stack) {
24393
+ async function findLastInArray(value, callback, options, stack, thisValue) {
24354
24394
  const length = value.length;
24355
24395
  for (let index = length - 1; index >= 0; index -= 1) {
24356
24396
  const entry = index in value ? value[index] : void 0;
24357
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
24397
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24358
24398
  return entry;
24359
24399
  }
24360
24400
  }
24361
24401
  return void 0;
24362
24402
  }
24363
- async function findLastIndexInArray(value, callback, options, stack) {
24403
+ async function findLastIndexInArray(value, callback, options, stack, thisValue) {
24364
24404
  const length = value.length;
24365
24405
  for (let index = length - 1; index >= 0; index -= 1) {
24366
24406
  const entry = index in value ? value[index] : void 0;
24367
- if (await callArrayCallback(callback, entry, index, value, options, stack)) {
24407
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24368
24408
  return index;
24369
24409
  }
24370
24410
  }
24371
24411
  return -1;
24372
24412
  }
24373
- async function someInArray(value, callback, options, stack) {
24413
+ async function someInArray(value, callback, options, stack, thisValue) {
24374
24414
  const length = value.length;
24375
24415
  for (let index = 0; index < length; index += 1) {
24376
24416
  if (!(index in value)) {
24377
24417
  continue;
24378
24418
  }
24379
- if (await callArrayCallback(callback, value[index], index, value, options, stack)) {
24419
+ if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
24380
24420
  return true;
24381
24421
  }
24382
24422
  }
24383
24423
  return false;
24384
24424
  }
24385
- async function everyInArray(value, callback, options, stack) {
24425
+ async function everyInArray(value, callback, options, stack, thisValue) {
24386
24426
  const length = value.length;
24387
24427
  for (let index = 0; index < length; index += 1) {
24388
24428
  if (!(index in value)) {
24389
24429
  continue;
24390
24430
  }
24391
- if (!await callArrayCallback(callback, value[index], index, value, options, stack)) {
24431
+ if (!await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
24392
24432
  return false;
24393
24433
  }
24394
24434
  }
@@ -24436,23 +24476,31 @@ async function reduceFromRight(value, callback, accumulator, startIndex, length,
24436
24476
  }
24437
24477
  return current;
24438
24478
  }
24439
- async function forEachArray(value, callback, options, stack) {
24479
+ async function forEachArray(value, callback, options, stack, thisValue) {
24440
24480
  const length = value.length;
24441
24481
  for (let index = 0; index < length; index += 1) {
24442
24482
  if (!(index in value)) {
24443
24483
  continue;
24444
24484
  }
24445
- await callArrayCallback(callback, value[index], index, value, options, stack);
24485
+ await callArrayCallback(callback, value[index], index, value, options, stack, thisValue);
24446
24486
  }
24447
24487
  }
24448
- async function flatMapArray(value, callback, options, stack) {
24488
+ async function flatMapArray(value, callback, options, stack, thisValue) {
24449
24489
  const length = value.length;
24450
24490
  const result = [];
24451
24491
  for (let index = 0; index < length; index += 1) {
24452
24492
  if (!(index in value)) {
24453
24493
  continue;
24454
24494
  }
24455
- const mapped = await callArrayCallback(callback, value[index], index, value, options, stack);
24495
+ const mapped = await callArrayCallback(
24496
+ callback,
24497
+ value[index],
24498
+ index,
24499
+ value,
24500
+ options,
24501
+ stack,
24502
+ thisValue
24503
+ );
24456
24504
  if (Array.isArray(mapped)) {
24457
24505
  for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
24458
24506
  if (!(mappedIndex in mapped)) {
@@ -24524,8 +24572,8 @@ async function compareEntries(left, right, comparator, options, stack) {
24524
24572
  const result = Number(await options.callClosure(comparator, [left, right], stack));
24525
24573
  return Number.isNaN(result) ? 0 : result;
24526
24574
  }
24527
- async function callArrayCallback(callback, value, index, array, options, stack) {
24528
- 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);
24529
24577
  }
24530
24578
  function findNextDefinedIndex(value, startIndex, direction, length) {
24531
24579
  for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
@@ -24715,7 +24763,7 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
24715
24763
  const entries = [...target.entries];
24716
24764
  for (let index = 0; index < entries.length; index += 1) {
24717
24765
  const [key, value] = entries[index];
24718
- await options.callClosure(callback, [value, key, target], stack);
24766
+ await options.callClosure(callback, [value, key, target], stack, args[1]);
24719
24767
  }
24720
24768
  } finally {
24721
24769
  leaveCallback();
@@ -25484,7 +25532,7 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
25484
25532
  const values = [...target.values];
25485
25533
  for (let index = 0; index < values.length; index += 1) {
25486
25534
  const value = values[index];
25487
- await options.callClosure(callback, [value, value, target], stack);
25535
+ await options.callClosure(callback, [value, value, target], stack, args[1]);
25488
25536
  }
25489
25537
  } finally {
25490
25538
  leaveCallback();
@@ -28063,19 +28111,19 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
28063
28111
  function createArrayMethodOptions(context) {
28064
28112
  return {
28065
28113
  budget: context.budget,
28066
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
28114
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
28067
28115
  };
28068
28116
  }
28069
28117
  function createMapMethodOptions(context) {
28070
28118
  return {
28071
28119
  budget: context.budget,
28072
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
28120
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
28073
28121
  };
28074
28122
  }
28075
28123
  function createSetMethodOptions(context) {
28076
28124
  return {
28077
28125
  budget: context.budget,
28078
- callClosure: (closure, args, stack) => invokeSandboxClosure(closure, args, context, stack)
28126
+ callClosure: (closure, args, stack, thisValue) => invokeSandboxClosure(closure, args, context, stack, void 0, thisValue)
28079
28127
  };
28080
28128
  }
28081
28129
  function createFunctionMethodOptions(context) {
@@ -28575,7 +28623,10 @@ var UnhandledRejectionError = class extends Error {
28575
28623
  };
28576
28624
  var DEFAULT_MAX_CALL_DEPTH = 1e3;
28577
28625
  function run(source, options = {}) {
28578
- const lifecycle = { hostCallbackDepth: 0 };
28626
+ const lifecycle = {
28627
+ hostCallbackDepth: 0,
28628
+ hostCallbackContext: new AsyncLocalStorage6()
28629
+ };
28579
28630
  const dumpController = createDumpController(lifecycle);
28580
28631
  const promiseTracker = createSandboxPromiseRejectionTracker();
28581
28632
  let completedSnapshot;
@@ -28881,6 +28932,7 @@ function run(source, options = {}) {
28881
28932
  dumpController.fail(error);
28882
28933
  throw error;
28883
28934
  } finally {
28935
+ lifecycle.hostCallbackContext.disable();
28884
28936
  options.signal?.removeEventListener("abort", captureCancellationSnapshot);
28885
28937
  leaveInputReplay?.();
28886
28938
  leaveHostReplay?.();
@@ -29125,4 +29177,4 @@ export {
29125
29177
  FileSnapshotBackend,
29126
29178
  run
29127
29179
  };
29128
- //# sourceMappingURL=chunk-IB5DSFBQ.js.map
29180
+ //# sourceMappingURL=chunk-CGS4H4L3.js.map