poe-code 14.0.44 → 14.0.46

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.
Files changed (37) hide show
  1. package/dist/index.js +96 -48
  2. package/dist/index.js.map +3 -3
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-bash/dist/browser.js +72 -25
  6. package/packages/safe-bash/dist/browser.js.map +3 -3
  7. package/packages/safe-bash/dist/shell/parser.d.ts +3 -2
  8. package/packages/safe-bash/dist/shell/parser.d.ts.map +1 -1
  9. package/packages/safe-bash/dist/shell/parser.js +18 -21
  10. package/packages/safe-bash/dist/shell/parser.js.map +1 -1
  11. package/packages/safe-bash/dist/shell/runtime.d.ts.map +1 -1
  12. package/packages/safe-bash/dist/shell/runtime.js +14 -6
  13. package/packages/safe-bash/dist/shell/runtime.js.map +1 -1
  14. package/packages/safe-bash/dist/shell/shell.d.ts.map +1 -1
  15. package/packages/safe-bash/dist/shell/shell.js +4 -2
  16. package/packages/safe-bash/dist/shell/shell.js.map +1 -1
  17. package/packages/safe-bash/dist/shell/source-line-index.d.ts +10 -0
  18. package/packages/safe-bash/dist/shell/source-line-index.d.ts.map +1 -0
  19. package/packages/safe-bash/dist/shell/source-line-index.js +41 -0
  20. package/packages/safe-bash/dist/shell/source-line-index.js.map +1 -0
  21. package/packages/safe-js/dist/chunks/{chunk-2GJ635AB.js → chunk-WQY27BRL.js} +2 -2
  22. package/packages/safe-js/dist/chunks/{chunk-JZXAWFPL.js → chunk-XC53RECY.js} +96 -49
  23. package/packages/safe-js/dist/chunks/chunk-XC53RECY.js.map +7 -0
  24. package/packages/safe-js/dist/cli.js +2 -2
  25. package/packages/safe-js/dist/core.js +1 -1
  26. package/packages/safe-js/dist/index.js +2 -2
  27. package/packages/safe-js/dist/interp/budget.d.ts +1 -0
  28. package/packages/safe-js/dist/interp/budget.js +3 -0
  29. package/packages/safe-js/dist/interp/exceptions.d.ts +4 -0
  30. package/packages/safe-js/dist/interp/exceptions.js +68 -23
  31. package/packages/safe-js/dist/interp/interpreter.js +8 -30
  32. package/packages/safe-js/dist/interp/methods/function.js +5 -2
  33. package/packages/safe-js/dist/interp/patterns.js +2 -4
  34. package/packages/safe-js/dist/interp/values.d.ts +1 -1
  35. package/packages/safe-js/dist/interp/values.js +9 -4
  36. package/packages/safe-js/dist/chunks/chunk-JZXAWFPL.js.map +0 -7
  37. /package/packages/safe-js/dist/chunks/{chunk-2GJ635AB.js.map → chunk-WQY27BRL.js.map} +0 -0
package/dist/index.js CHANGED
@@ -119789,6 +119789,9 @@ var init_shape = __esm({
119789
119789
  });
119790
119790
 
119791
119791
  // packages/safe-js/src/interp/budget.ts
119792
+ function isFatalSandboxError(error3) {
119793
+ return error3 instanceof SandboxError && (error3.code === "budgetExceeded" || error3.code === "reentry");
119794
+ }
119792
119795
  function allocateRegexSteps(steps) {
119793
119796
  if (!Number.isInteger(steps) || steps < 0) {
119794
119797
  throw new Error("steps must be a non-negative integer.");
@@ -128545,7 +128548,19 @@ async function evaluateTryStatement(node, context, evaluateNode3) {
128545
128548
  value: void 0
128546
128549
  };
128547
128550
  }
128548
- const tryOrCatchResult = fatalBudgetError === void 0 && tryResult.kind === "throw" && node.handler !== void 0 ? await evaluateCatchClause(node.handler, tryResult.value, context, evaluateNode3) : tryResult;
128551
+ let tryOrCatchResult = tryResult;
128552
+ let catchFailure;
128553
+ if (fatalBudgetError === void 0 && tryResult.kind === "throw" && node.handler !== void 0) {
128554
+ try {
128555
+ tryOrCatchResult = await evaluateCatchClause(node.handler, tryResult.value, context, evaluateNode3);
128556
+ } catch (error3) {
128557
+ if (isFatalSandboxError(error3) || isInterpreterError(error3) || error3 instanceof HostCallResumabilityError) {
128558
+ throw error3;
128559
+ }
128560
+ catchFailure = createThrowCompletion(error3, context.budget, context.callStack, node.span);
128561
+ tryOrCatchResult = catchFailure;
128562
+ }
128563
+ }
128549
128564
  if (node.finalizer === void 0 || tryOrCatchResult.kind === "error") {
128550
128565
  return tryOrCatchResult;
128551
128566
  }
@@ -128553,14 +128568,38 @@ async function evaluateTryStatement(node, context, evaluateNode3) {
128553
128568
  context,
128554
128569
  () => evaluateBlockCompletion(node.finalizer, context, evaluateNode3)
128555
128570
  ) : evaluateBlockCompletion(node.finalizer, context, evaluateNode3);
128556
- const finalizerResult = await (fatalBudgetError === void 0 ? evaluateFinalizer() : withFatalPromiseCleanup(evaluateFinalizer));
128557
- if (fatalBudgetError !== void 0) {
128558
- throw fatalBudgetError;
128571
+ if (catchFailure !== void 0) {
128572
+ const value = catchFailure.value;
128573
+ context.budget.setRetainedValues(catchFailure, () => [value]);
128559
128574
  }
128560
- if (finalizerResult.kind === "normal") {
128561
- return tryOrCatchResult;
128575
+ try {
128576
+ const finalizerResult = await (fatalBudgetError === void 0 ? evaluateFinalizer() : withFatalPromiseCleanup(evaluateFinalizer));
128577
+ if (fatalBudgetError !== void 0) {
128578
+ throw fatalBudgetError;
128579
+ }
128580
+ if (finalizerResult.kind === "normal") {
128581
+ return tryOrCatchResult;
128582
+ }
128583
+ return finalizerResult;
128584
+ } finally {
128585
+ if (catchFailure !== void 0) context.budget.setRetainedValues(catchFailure, void 0);
128562
128586
  }
128563
- return finalizerResult;
128587
+ }
128588
+ function createThrowCompletion(error3, budget, stackFrames, span) {
128589
+ const value = isCapturedException(error3) ? coerceThrownValue(error3.reason, budget, error3.stackFrames, span, error3.sandbox) : coerceThrownValue(error3, budget, stackFrames, span, true);
128590
+ return {
128591
+ kind: "throw",
128592
+ hasValue: true,
128593
+ span: readErrorSpan(value) ?? span,
128594
+ stackFrames: isCapturedException(error3) ? error3.stackFrames : stackFrames,
128595
+ value
128596
+ };
128597
+ }
128598
+ function isInterpreterError(value) {
128599
+ return typeof value === "object" && value !== null && hasOwnProperty15(value, "code") && hasOwnProperty15(value, "message") && hasOwnProperty15(value, "nodeType") && hasOwnProperty15(value, "span") && (value.code === "UNBOUND_IDENTIFIER" || value.code === "UNSUPPORTED_NODE");
128600
+ }
128601
+ function hasOwnProperty15(value, name) {
128602
+ return Object.prototype.hasOwnProperty.call(value, name);
128564
128603
  }
128565
128604
  function createCapturedException(reason, stackFrames, sandbox = false) {
128566
128605
  return {
@@ -128747,6 +128786,9 @@ async function evaluateCatchClause(node, thrownValue, context, evaluateNode3) {
128747
128786
  scope
128748
128787
  };
128749
128788
  if (node.param !== void 0) {
128789
+ for (const name of getPatternBindingNames(node.param)) {
128790
+ scope.predeclare(name, "let");
128791
+ }
128750
128792
  const binding = await bindPattern(node.param, thrownValue, catchContext, evaluateNode3);
128751
128793
  if (!binding.ok) {
128752
128794
  return binding.result;
@@ -128860,8 +128902,8 @@ async function bindArrayPattern(pattern, value, context, evaluateNode3) {
128860
128902
  return { ok: true };
128861
128903
  }
128862
128904
  async function bindObjectPattern(pattern, value, context, evaluateNode3) {
128863
- if (typeof value !== "object" && !Array.isArray(value) || value === null) {
128864
- throw new TypeError("Object catch bindings require a non-null object value.");
128905
+ if (value === null || value === void 0) {
128906
+ throw new TypeError("Object catch bindings require a non-nullish value.");
128865
128907
  }
128866
128908
  const excludedKeys = /* @__PURE__ */ new Set();
128867
128909
  for (const property of pattern.properties) {
@@ -128880,7 +128922,7 @@ async function bindObjectPattern(pattern, value, context, evaluateNode3) {
128880
128922
  excludedKeys.add(String(key3.value));
128881
128923
  const binding = await bindPattern(
128882
128924
  property.value,
128883
- getObjectPatternValue(value, key3.value),
128925
+ context.getProperty === void 0 ? getSandboxDataProperty(value, key3.value, context.budget) : context.getProperty(value, key3.value),
128884
128926
  context,
128885
128927
  evaluateNode3
128886
128928
  );
@@ -128924,15 +128966,9 @@ function getStaticPropertyKey(property) {
128924
128966
  throw new TypeError(`Unsupported catch binding property key '${property.type}'.`);
128925
128967
  }
128926
128968
  }
128927
- function getObjectPatternValue(value, key3) {
128928
- return value[key3];
128929
- }
128930
128969
  function copyObjectRest(value, excludedKeys) {
128931
128970
  const rest = /* @__PURE__ */ Object.create(null);
128932
- for (const [key3, entryValue] of Object.entries(value)) {
128933
- if (excludedKeys.has(key3)) {
128934
- continue;
128935
- }
128971
+ for (const [key3, entryValue] of ownEnumerableSandboxEntries(value, excludedKeys)) {
128936
128972
  rest[key3] = entryValue;
128937
128973
  }
128938
128974
  return rest;
@@ -128946,6 +128982,7 @@ var init_exceptions = __esm({
128946
128982
  init_host_call();
128947
128983
  init_promise_tracker();
128948
128984
  init_values();
128985
+ init_object_model();
128949
128986
  init_property_key();
128950
128987
  capturedExceptionBrand = /* @__PURE__ */ Symbol("CapturedException");
128951
128988
  }
@@ -130189,18 +130226,21 @@ function createSandboxClosure(input) {
130189
130226
  }
130190
130227
  return Object.freeze(closure);
130191
130228
  }
130192
- function ownEnumerableSandboxEntries(value) {
130229
+ function ownEnumerableSandboxEntries(value, excludedKeys) {
130193
130230
  if (isGuestHostObject(value)) {
130194
- const entries = [];
130231
+ const entries2 = [];
130195
130232
  for (const key3 of getHostObjectKeys(value)) {
130196
- if (hasHostObjectMember(value, key3, true)) entries.push([key3, getHostObjectMember(value, key3)]);
130233
+ if (excludedKeys?.has(key3)) continue;
130234
+ if (hasHostObjectMember(value, key3, true)) entries2.push([key3, getHostObjectMember(value, key3)]);
130197
130235
  }
130198
- return entries;
130236
+ return entries2;
130199
130237
  }
130200
130238
  if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
130201
- if (isGuestClosure(value)) return Object.entries(value.properties ?? {});
130202
- if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
130203
- return Object.entries(Object(value));
130239
+ let entries;
130240
+ if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
130241
+ else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
130242
+ else entries = Object.entries(Object(value));
130243
+ return excludedKeys === void 0 ? entries : entries.filter(([key3]) => !excludedKeys.has(key3));
130204
130244
  }
130205
130245
  function createSandboxPromise(promise, metadata = {}) {
130206
130246
  const original = metadata.trackReplay === false ? promise : promiseReplayContext.getStore()?.track(promise) ?? promise;
@@ -131083,6 +131123,27 @@ function getSandboxPrototype(value, budget) {
131083
131123
  function hasExplicitSandboxPrototype(value) {
131084
131124
  return prototypes.has(value);
131085
131125
  }
131126
+ function getSandboxDataProperty(value, key3, budget) {
131127
+ let current = value;
131128
+ let depth = 0;
131129
+ while (typeof current === "object" && current !== null) {
131130
+ if (isGuestHostObject(current)) return getHostObjectMember(current, String(key3));
131131
+ if (isGuestClosure(current)) return getGuestFunctionProperty(current, String(key3));
131132
+ if (isSandboxClosure(current)) {
131133
+ const properties = current.properties;
131134
+ return properties !== void 0 && Object.hasOwn(properties, String(key3)) ? properties[String(key3)] : void 0;
131135
+ }
131136
+ if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxGenerator(current))
131137
+ return void 0;
131138
+ if (Object.hasOwn(current, String(key3))) return current[String(key3)];
131139
+ current = getSandboxPrototype(current, budget);
131140
+ if (current !== null) {
131141
+ budget?.visitNode();
131142
+ assertSandboxDataDepth(++depth);
131143
+ }
131144
+ }
131145
+ return void 0;
131146
+ }
131086
131147
  function setSandboxPrototype(value, prototype, budget) {
131087
131148
  if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
131088
131149
  throw new TypeError("Object.prototype has an immutable null prototype.");
@@ -143689,10 +143750,8 @@ function describeRuntimeValue(value) {
143689
143750
  }
143690
143751
  function copyObjectRestValue(value, excludedKeys) {
143691
143752
  const rest = /* @__PURE__ */ Object.create(null);
143692
- for (const [key3, entryValue] of ownEnumerableSandboxEntries(value)) {
143693
- if (!excludedKeys.has(key3)) {
143694
- defineProperty(rest, key3, entryValue);
143695
- }
143753
+ for (const [key3, entryValue] of ownEnumerableSandboxEntries(value, excludedKeys)) {
143754
+ defineProperty(rest, key3, entryValue);
143696
143755
  }
143697
143756
  return rest;
143698
143757
  }
@@ -144449,13 +144508,16 @@ function getFunctionMember(target, property, options) {
144449
144508
  return createSandboxClosure({
144450
144509
  sandbox: true,
144451
144510
  name: `Function#${property}`,
144452
- call: (args, context) => callFunctionMethod(target, property, args, options, context?.stack ?? [])
144511
+ call: (args, context) => callFunctionMethod(context?.thisValue, property, args, options, context?.stack ?? [])
144453
144512
  });
144454
144513
  }
144455
144514
  function isFunctionMethodName(property) {
144456
144515
  return typeof property === "string" && functionMethodNames.has(property);
144457
144516
  }
144458
144517
  function callFunctionMethod(target, methodName, args, options, stack) {
144518
+ if (!isSandboxClosure(target)) {
144519
+ throw new TypeError(`Function#${methodName} requires a callable receiver.`);
144520
+ }
144459
144521
  const thisValue = args[0];
144460
144522
  if (methodName === "bind") {
144461
144523
  const boundArgs = args.slice(1);
@@ -146230,22 +146292,16 @@ async function evaluateNode2(node, context) {
146230
146292
  error: error3
146231
146293
  };
146232
146294
  }
146233
- const exception = isCapturedException(error3) ? coerceThrownValue(error3.reason, context.budget, error3.stackFrames, node.span, error3.sandbox) : coerceThrownValue(error3, context.budget, context.callStack, node.span, true);
146295
+ const completion = createThrowCompletion(error3, context.budget, context.callStack, node.span);
146234
146296
  reconcileDataBudget(
146235
146297
  context.budget,
146236
146298
  context.stats,
146237
146299
  context.scope,
146238
- exception,
146300
+ completion.value,
146239
146301
  compilation,
146240
146302
  context.compilation
146241
146303
  );
146242
- return {
146243
- kind: "throw",
146244
- hasValue: true,
146245
- span: readErrorSpan(exception) ?? node.span,
146246
- stackFrames: isCapturedException(error3) ? error3.stackFrames : context.callStack,
146247
- value: exception
146248
- };
146304
+ return completion;
146249
146305
  } finally {
146250
146306
  compilation.dispose();
146251
146307
  }
@@ -147549,7 +147605,8 @@ async function evaluateThrowStatement2(node, context) {
147549
147605
  async function evaluateTryStatement2(node, context) {
147550
147606
  return evaluateTryStatement(node, {
147551
147607
  ...context,
147552
- toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context))
147608
+ toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context)),
147609
+ getProperty: (value, key3) => getPropertyValue(value, key3, context)
147553
147610
  }, evaluateNode2);
147554
147611
  }
147555
147612
  async function evaluateUnaryExpression(node, context) {
@@ -148721,12 +148778,6 @@ function defineSandboxProperty(target, key3, value) {
148721
148778
  writable: true
148722
148779
  });
148723
148780
  }
148724
- function isInterpreterError(value) {
148725
- return typeof value === "object" && value !== null && hasOwnProperty15(value, "code") && hasOwnProperty15(value, "message") && hasOwnProperty15(value, "nodeType") && hasOwnProperty15(value, "span") && (value.code === "UNBOUND_IDENTIFIER" || value.code === "UNSUPPORTED_NODE");
148726
- }
148727
- function hasOwnProperty15(value, name) {
148728
- return Object.prototype.hasOwnProperty.call(value, name);
148729
- }
148730
148781
  function wrapHostResult(result, stack, sandbox) {
148731
148782
  if (!isPromiseLikeResult(result)) {
148732
148783
  return result;
@@ -148741,9 +148792,6 @@ function wrapHostResult(result, stack, sandbox) {
148741
148792
  function captureException(error3, stack, sandbox) {
148742
148793
  return isCapturedException(error3) ? error3 : createCapturedException(error3, stack, sandbox);
148743
148794
  }
148744
- function isFatalSandboxError(error3) {
148745
- return error3 instanceof SandboxError && (error3.code === "budgetExceeded" || error3.code === "reentry");
148746
- }
148747
148795
  function isPromiseLikeResult(value) {
148748
148796
  return typeof value === "object" && value !== null && "then" in value;
148749
148797
  }