poe-code 13.0.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "13.0.1",
3
+ "version": "13.0.3",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18670,14 +18670,6 @@ function enterRunningState(object) {
18670
18670
  runningObjects.delete(object);
18671
18671
  };
18672
18672
  }
18673
- function enterCollectionCallback(object) {
18674
- const leaveRunning = enterRunningState(object);
18675
- lockedCollections.add(object);
18676
- return () => {
18677
- lockedCollections.delete(object);
18678
- leaveRunning();
18679
- };
18680
- }
18681
18673
  function assertCollectionMutable(object) {
18682
18674
  if (lockedCollections.has(object)) {
18683
18675
  throw new SandboxError("reentry");
@@ -24158,6 +24150,85 @@ function assertStructuredCloneable(value, seen) {
24158
24150
  }
24159
24151
  }
24160
24152
 
24153
+ // packages/safe-js/src/interp/string-coercion.ts
24154
+ function sandboxString(value, budget, context, joining = /* @__PURE__ */ new Set()) {
24155
+ if (value === null || typeof value !== "object") {
24156
+ if (typeof value === "function") throw new TypeError("Expected a sandbox value.");
24157
+ return budget.allocateString(String(value));
24158
+ }
24159
+ return stringifyObject2(value, budget, context, joining);
24160
+ }
24161
+ async function stringifyObject2(value, budget, context, joining) {
24162
+ const leaveCall = budget.enterCall();
24163
+ try {
24164
+ budget.visitNode();
24165
+ for (const name of ["toString", "valueOf"]) {
24166
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
24167
+ let result;
24168
+ if (descriptor === void 0) {
24169
+ if (name === "valueOf") continue;
24170
+ result = await defaultToString(value, budget, context, joining);
24171
+ } else {
24172
+ const hook = ownDataValue(value, name);
24173
+ if (!isSandboxClosure(hook)) continue;
24174
+ if (context?.invokeClosure === void 0) {
24175
+ throw new TypeError("String hooks require a sandbox call context.");
24176
+ }
24177
+ result = await context.invokeClosure(hook, [], value);
24178
+ }
24179
+ if (result === null || typeof result !== "object") {
24180
+ return sandboxString(result, budget, context, joining);
24181
+ }
24182
+ }
24183
+ throw new TypeError("Cannot convert object to primitive value");
24184
+ } finally {
24185
+ leaveCall();
24186
+ }
24187
+ }
24188
+ async function defaultToString(value, budget, context, joining) {
24189
+ if (Array.isArray(value) || isFloat32Array(value)) {
24190
+ if (Object.hasOwn(value, "join")) {
24191
+ const join = ownDataValue(value, "join");
24192
+ if (!isSandboxClosure(join))
24193
+ return isFloat32Array(value) ? "[object Float32Array]" : "[object Array]";
24194
+ if (context?.invokeClosure === void 0) {
24195
+ throw new TypeError("String hooks require a sandbox call context.");
24196
+ }
24197
+ return context.invokeClosure(join, [], value);
24198
+ }
24199
+ if (joining.has(value)) return "";
24200
+ joining.add(value);
24201
+ try {
24202
+ const length = isFloat32Array(value) ? float32Storage(value).length : value.length;
24203
+ let text = "";
24204
+ for (let index = 0; index < length; index++) {
24205
+ budget.visitNode();
24206
+ const element = ownDataValue(value, String(index));
24207
+ const part = element === null || element === void 0 ? "" : await sandboxString(element, budget, context, joining);
24208
+ text = budget.allocateString(text + (index === 0 ? "" : ",") + part);
24209
+ }
24210
+ return text;
24211
+ } finally {
24212
+ joining.delete(value);
24213
+ }
24214
+ }
24215
+ if (sandboxErrorTypes.has(value)) {
24216
+ const nameValue = ownDataValue(value, "name");
24217
+ const name = nameValue === void 0 ? "Error" : await sandboxString(nameValue, budget, context, joining);
24218
+ const messageValue = ownDataValue(value, "message");
24219
+ const message = messageValue === void 0 ? "" : await sandboxString(messageValue, budget, context, joining);
24220
+ return name === "" ? message : message === "" ? name : `${name}: ${message}`;
24221
+ }
24222
+ return isSandboxPromise(value) ? "[object Promise]" : "[object Object]";
24223
+ }
24224
+ function ownDataValue(value, name) {
24225
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
24226
+ if (descriptor !== void 0 && !Object.hasOwn(descriptor, "value")) {
24227
+ throw new TypeError("String conversion requires sandbox data properties.");
24228
+ }
24229
+ return descriptor?.value;
24230
+ }
24231
+
24161
24232
  // packages/safe-js/src/interp/globals/object-array.ts
24162
24233
  function createObjectArrayGlobals(options) {
24163
24234
  return {
@@ -24253,9 +24324,7 @@ function createObjectArrayGlobals(options) {
24253
24324
  }),
24254
24325
  String: createSandboxClosure({
24255
24326
  sandbox: true,
24256
- call: ([value]) => options.budget.allocateString(
24257
- typeof value === "object" && value !== null && sandboxErrorTypes.has(value) && !Object.hasOwn(value, "toString") ? Error.prototype.toString.call(value) : String(value)
24258
- ),
24327
+ call: (args, context) => sandboxString(args.length === 0 ? "" : args[0], options.budget, context),
24259
24328
  name: "String",
24260
24329
  properties: {
24261
24330
  raw: createSandboxClosure({
@@ -24543,7 +24612,7 @@ async function callArrayMethod(value, methodName, args, options, stack = []) {
24543
24612
  if (isCallbackArrayMethod(methodName)) {
24544
24613
  let callbackState = activeArrayCallbacks.get(value);
24545
24614
  if (callbackState === void 0) {
24546
- callbackState = { depth: 0, leave: enterCollectionCallback(value) };
24615
+ callbackState = { depth: 0, leave: enterRunningState(value) };
24547
24616
  activeArrayCallbacks.set(value, callbackState);
24548
24617
  }
24549
24618
  callbackState.depth += 1;
@@ -24794,42 +24863,63 @@ function getRequiredCallback(methodName, value) {
24794
24863
  async function mapArray(value, callback, options, stack, thisValue) {
24795
24864
  const length = value.length;
24796
24865
  const result = new Array(length);
24797
- for (let index = 0; index < length; index += 1) {
24798
- if (!(index in value)) {
24799
- continue;
24866
+ options.budget.setRetainedValues(result, () => [result]);
24867
+ try {
24868
+ for (let index = 0; index < length; index += 1) {
24869
+ options.budget.visitNode();
24870
+ if (!(index in value)) {
24871
+ continue;
24872
+ }
24873
+ result[index] = await callArrayCallback(
24874
+ callback,
24875
+ value[index],
24876
+ index,
24877
+ value,
24878
+ options,
24879
+ stack,
24880
+ thisValue
24881
+ );
24800
24882
  }
24801
- result[index] = await callArrayCallback(
24802
- callback,
24803
- value[index],
24804
- index,
24805
- value,
24806
- options,
24807
- stack,
24808
- thisValue
24809
- );
24883
+ return result;
24884
+ } finally {
24885
+ options.budget.setRetainedValues(result, void 0);
24810
24886
  }
24811
- return result;
24812
24887
  }
24813
24888
  async function filterArray(value, callback, options, stack, thisValue) {
24814
24889
  const length = value.length;
24815
24890
  const result = [];
24816
- for (let index = 0; index < length; index += 1) {
24817
- if (!(index in value)) {
24818
- continue;
24819
- }
24820
- if (await callArrayCallback(callback, value[index], index, value, options, stack, thisValue)) {
24821
- result.push(value[index]);
24891
+ options.budget.setRetainedValues(result, () => [result]);
24892
+ try {
24893
+ for (let index = 0; index < length; index += 1) {
24894
+ options.budget.visitNode();
24895
+ if (!(index in value)) {
24896
+ continue;
24897
+ }
24898
+ const entry = value[index];
24899
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24900
+ result.push(entry);
24901
+ }
24822
24902
  }
24903
+ return result;
24904
+ } finally {
24905
+ options.budget.setRetainedValues(result, void 0);
24823
24906
  }
24824
- return result;
24825
24907
  }
24826
24908
  async function findInArray(value, callback, options, stack, thisValue) {
24827
- const index = await findIndexInArray(value, callback, options, stack, thisValue);
24828
- return index < 0 ? void 0 : value[index];
24909
+ const length = value.length;
24910
+ for (let index = 0; index < length; index += 1) {
24911
+ options.budget.visitNode();
24912
+ const entry = index in value ? value[index] : void 0;
24913
+ if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24914
+ return entry;
24915
+ }
24916
+ }
24917
+ return void 0;
24829
24918
  }
24830
24919
  async function findIndexInArray(value, callback, options, stack, thisValue) {
24831
24920
  const length = value.length;
24832
24921
  for (let index = 0; index < length; index += 1) {
24922
+ options.budget.visitNode();
24833
24923
  const entry = index in value ? value[index] : void 0;
24834
24924
  if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24835
24925
  return index;
@@ -24840,6 +24930,7 @@ async function findIndexInArray(value, callback, options, stack, thisValue) {
24840
24930
  async function findLastInArray(value, callback, options, stack, thisValue) {
24841
24931
  const length = value.length;
24842
24932
  for (let index = length - 1; index >= 0; index -= 1) {
24933
+ options.budget.visitNode();
24843
24934
  const entry = index in value ? value[index] : void 0;
24844
24935
  if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24845
24936
  return entry;
@@ -24850,6 +24941,7 @@ async function findLastInArray(value, callback, options, stack, thisValue) {
24850
24941
  async function findLastIndexInArray(value, callback, options, stack, thisValue) {
24851
24942
  const length = value.length;
24852
24943
  for (let index = length - 1; index >= 0; index -= 1) {
24944
+ options.budget.visitNode();
24853
24945
  const entry = index in value ? value[index] : void 0;
24854
24946
  if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
24855
24947
  return index;
@@ -24860,6 +24952,7 @@ async function findLastIndexInArray(value, callback, options, stack, thisValue)
24860
24952
  async function someInArray(value, callback, options, stack, thisValue) {
24861
24953
  const length = value.length;
24862
24954
  for (let index = 0; index < length; index += 1) {
24955
+ options.budget.visitNode();
24863
24956
  if (!(index in value)) {
24864
24957
  continue;
24865
24958
  }
@@ -24872,6 +24965,7 @@ async function someInArray(value, callback, options, stack, thisValue) {
24872
24965
  async function everyInArray(value, callback, options, stack, thisValue) {
24873
24966
  const length = value.length;
24874
24967
  for (let index = 0; index < length; index += 1) {
24968
+ options.budget.visitNode();
24875
24969
  if (!(index in value)) {
24876
24970
  continue;
24877
24971
  }
@@ -24883,10 +24977,10 @@ async function everyInArray(value, callback, options, stack, thisValue) {
24883
24977
  }
24884
24978
  async function reduceArray(value, callback, hasInitialValue, initialValue, options, stack) {
24885
24979
  const length = value.length;
24886
- const start = findNextDefinedIndex(value, 0, 1, length);
24887
24980
  if (hasInitialValue) {
24888
- return reduceFromLeft(value, callback, initialValue, start, length, options, stack);
24981
+ return reduceFromLeft(value, callback, initialValue, 0, length, options, stack);
24889
24982
  }
24983
+ const start = findNextDefinedIndex(value, 0, 1, length, options.budget);
24890
24984
  if (start < 0) {
24891
24985
  throw new TypeError("Reduce of empty array with no initial value.");
24892
24986
  }
@@ -24894,10 +24988,10 @@ async function reduceArray(value, callback, hasInitialValue, initialValue, optio
24894
24988
  }
24895
24989
  async function reduceRightArray(value, callback, hasInitialValue, initialValue, options, stack) {
24896
24990
  const length = value.length;
24897
- const start = findNextDefinedIndex(value, length - 1, -1, length);
24898
24991
  if (hasInitialValue) {
24899
- return reduceFromRight(value, callback, initialValue, start, length, options, stack);
24992
+ return reduceFromRight(value, callback, initialValue, length - 1, length, options, stack);
24900
24993
  }
24994
+ const start = findNextDefinedIndex(value, length - 1, -1, length, options.budget);
24901
24995
  if (start < 0) {
24902
24996
  throw new TypeError("Reduce of empty array with no initial value.");
24903
24997
  }
@@ -24905,27 +24999,42 @@ async function reduceRightArray(value, callback, hasInitialValue, initialValue,
24905
24999
  }
24906
25000
  async function reduceFromLeft(value, callback, accumulator, startIndex, length, options, stack) {
24907
25001
  let current = accumulator;
24908
- for (let index = startIndex; index < length; index += 1) {
24909
- if (!(index in value)) {
24910
- continue;
25002
+ const retainedAccumulator = {};
25003
+ options.budget.setRetainedValues(retainedAccumulator, () => [current]);
25004
+ try {
25005
+ for (let index = startIndex; index < length; index += 1) {
25006
+ options.budget.visitNode();
25007
+ if (!(index in value)) {
25008
+ continue;
25009
+ }
25010
+ current = await options.callClosure(callback, [current, value[index], index, value], stack);
24911
25011
  }
24912
- current = await options.callClosure(callback, [current, value[index], index, value], stack);
25012
+ return current;
25013
+ } finally {
25014
+ options.budget.setRetainedValues(retainedAccumulator, void 0);
24913
25015
  }
24914
- return current;
24915
25016
  }
24916
25017
  async function reduceFromRight(value, callback, accumulator, startIndex, length, options, stack) {
24917
25018
  let current = accumulator;
24918
- for (let index = Math.min(startIndex, length - 1); index >= 0; index -= 1) {
24919
- if (!(index in value)) {
24920
- continue;
25019
+ const retainedAccumulator = {};
25020
+ options.budget.setRetainedValues(retainedAccumulator, () => [current]);
25021
+ try {
25022
+ for (let index = Math.min(startIndex, length - 1); index >= 0; index -= 1) {
25023
+ options.budget.visitNode();
25024
+ if (!(index in value)) {
25025
+ continue;
25026
+ }
25027
+ current = await options.callClosure(callback, [current, value[index], index, value], stack);
24921
25028
  }
24922
- current = await options.callClosure(callback, [current, value[index], index, value], stack);
25029
+ return current;
25030
+ } finally {
25031
+ options.budget.setRetainedValues(retainedAccumulator, void 0);
24923
25032
  }
24924
- return current;
24925
25033
  }
24926
25034
  async function forEachArray(value, callback, options, stack, thisValue) {
24927
25035
  const length = value.length;
24928
25036
  for (let index = 0; index < length; index += 1) {
25037
+ options.budget.visitNode();
24929
25038
  if (!(index in value)) {
24930
25039
  continue;
24931
25040
  }
@@ -24935,33 +25044,40 @@ async function forEachArray(value, callback, options, stack, thisValue) {
24935
25044
  async function flatMapArray(value, callback, options, stack, thisValue) {
24936
25045
  const length = value.length;
24937
25046
  const result = [];
24938
- for (let index = 0; index < length; index += 1) {
24939
- if (!(index in value)) {
24940
- continue;
24941
- }
24942
- const mapped = await callArrayCallback(
24943
- callback,
24944
- value[index],
24945
- index,
24946
- value,
24947
- options,
24948
- stack,
24949
- thisValue
24950
- );
24951
- if (Array.isArray(mapped)) {
24952
- for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
24953
- if (!(mappedIndex in mapped)) {
24954
- continue;
25047
+ options.budget.setRetainedValues(result, () => [result]);
25048
+ try {
25049
+ for (let index = 0; index < length; index += 1) {
25050
+ options.budget.visitNode();
25051
+ if (!(index in value)) {
25052
+ continue;
25053
+ }
25054
+ const mapped = await callArrayCallback(
25055
+ callback,
25056
+ value[index],
25057
+ index,
25058
+ value,
25059
+ options,
25060
+ stack,
25061
+ thisValue
25062
+ );
25063
+ if (Array.isArray(mapped)) {
25064
+ for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
25065
+ options.budget.visitNode();
25066
+ if (!(mappedIndex in mapped)) {
25067
+ continue;
25068
+ }
25069
+ result.push(mapped[mappedIndex]);
25070
+ options.budget.allocateArrayLength(result.length);
24955
25071
  }
24956
- result.push(mapped[mappedIndex]);
24957
- options.budget.allocateArrayLength(result.length);
25072
+ continue;
24958
25073
  }
24959
- continue;
25074
+ result.push(mapped);
25075
+ options.budget.allocateArrayLength(result.length);
24960
25076
  }
24961
- result.push(mapped);
24962
- options.budget.allocateArrayLength(result.length);
25077
+ return result;
25078
+ } finally {
25079
+ options.budget.setRetainedValues(result, void 0);
24963
25080
  }
24964
- return result;
24965
25081
  }
24966
25082
  function flattenArray(value, depth, budget) {
24967
25083
  const result = [];
@@ -24983,47 +25099,59 @@ function appendFlattenedEntries(value, depth, result, budget) {
24983
25099
  }
24984
25100
  }
24985
25101
  async function sortArray(value, comparator, options, stack) {
25102
+ const length = value.length;
24986
25103
  const definedValues = [];
24987
25104
  let undefinedCount = 0;
24988
- for (let index = 0; index < value.length; index += 1) {
24989
- if (!(index in value)) {
24990
- continue;
25105
+ let currentEntry;
25106
+ options.budget.setRetainedValues(definedValues, () => [definedValues, currentEntry]);
25107
+ try {
25108
+ for (let index = 0; index < length; index += 1) {
25109
+ options.budget.visitNode();
25110
+ if (!(index in value)) {
25111
+ continue;
25112
+ }
25113
+ const entry = value[index];
25114
+ if (entry === void 0) {
25115
+ undefinedCount += 1;
25116
+ continue;
25117
+ }
25118
+ definedValues.push(entry);
24991
25119
  }
24992
- const entry = value[index];
24993
- if (entry === void 0) {
24994
- undefinedCount += 1;
24995
- continue;
25120
+ for (let index = 1; index < definedValues.length; index += 1) {
25121
+ currentEntry = definedValues[index];
25122
+ let cursor = index - 1;
25123
+ while (cursor >= 0 && await compareEntries(definedValues[cursor], currentEntry, comparator, options, stack) > 0) {
25124
+ definedValues[cursor + 1] = definedValues[cursor];
25125
+ cursor -= 1;
25126
+ }
25127
+ definedValues[cursor + 1] = currentEntry;
24996
25128
  }
24997
- definedValues.push(entry);
24998
- }
24999
- for (let index = 1; index < definedValues.length; index += 1) {
25000
- const entry = definedValues[index];
25001
- let cursor = index - 1;
25002
- while (cursor >= 0 && await compareEntries(definedValues[cursor], entry, comparator, options, stack) > 0) {
25003
- definedValues[cursor + 1] = definedValues[cursor];
25004
- cursor -= 1;
25129
+ currentEntry = void 0;
25130
+ for (let index = 0; index < definedValues.length; index += 1) {
25131
+ value[index] = definedValues[index];
25005
25132
  }
25006
- definedValues[cursor + 1] = entry;
25007
- }
25008
- for (let index = 0; index < definedValues.length; index += 1) {
25009
- value[index] = definedValues[index];
25010
- }
25011
- for (let index = 0; index < undefinedCount; index += 1) {
25012
- value[definedValues.length + index] = void 0;
25013
- }
25014
- for (let index = definedValues.length + undefinedCount; index < value.length; index += 1) {
25015
- delete value[index];
25133
+ for (let index = 0; index < undefinedCount; index += 1) {
25134
+ value[definedValues.length + index] = void 0;
25135
+ }
25136
+ for (let index = definedValues.length + undefinedCount; index < length; index += 1) {
25137
+ options.budget.visitNode();
25138
+ delete value[index];
25139
+ }
25140
+ } finally {
25141
+ options.budget.setRetainedValues(definedValues, void 0);
25016
25142
  }
25017
25143
  }
25018
25144
  async function compareEntries(left, right, comparator, options, stack) {
25145
+ options.budget.visitNode();
25019
25146
  const result = Number(await options.callClosure(comparator, [left, right], stack));
25020
25147
  return Number.isNaN(result) ? 0 : result;
25021
25148
  }
25022
25149
  async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
25023
25150
  return options.callClosure(callback, [value, index, array], stack, thisValue);
25024
25151
  }
25025
- function findNextDefinedIndex(value, startIndex, direction, length) {
25152
+ function findNextDefinedIndex(value, startIndex, direction, length, budget) {
25026
25153
  for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
25154
+ budget.visitNode();
25027
25155
  if (index in value) {
25028
25156
  return index;
25029
25157
  }
@@ -28712,6 +28840,7 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
28712
28840
  {
28713
28841
  stack,
28714
28842
  thisValue,
28843
+ invokeClosure: (closure, argumentsList, receiver) => invokeSandboxClosure(closure, argumentsList, context, stack, span, receiver),
28715
28844
  ...span === void 0 ? {} : { span }
28716
28845
  }
28717
28846
  ]);
@@ -29763,4 +29892,4 @@ export {
29763
29892
  FileSnapshotBackend,
29764
29893
  run
29765
29894
  };
29766
- //# sourceMappingURL=chunk-DALBPQDZ.js.map
29895
+ //# sourceMappingURL=chunk-73LWNNUG.js.map