poe-code 14.0.40 → 14.0.41

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
@@ -146007,6 +146007,7 @@ async function interpret(node, options = {}) {
146007
146007
  budget,
146008
146008
  callStack: [],
146009
146009
  onYield: options.onYield,
146010
+ onSuspend: options.onSuspend,
146010
146011
  captureReplayState: options.captureReplayState,
146011
146012
  rootNode: node,
146012
146013
  scope,
@@ -148818,44 +148819,51 @@ function createInterpretedClosure(node, context, evaluateNode3) {
148818
148819
  };
148819
148820
  if (!node.async)
148820
148821
  return executeClosure(node, args, callContext?.thisValue, invocationContext, evaluateNode3);
148821
- let completePrefix;
148822
- const synchronousPrefix = new Promise((resolve16) => {
148823
- completePrefix = resolve16;
148824
- });
148825
- const promise = new Promise((resolve16, reject) => {
148826
- runAsyncPrefix(async () => {
148827
- try {
148828
- const value = await executeClosure(
148829
- node,
148830
- args,
148831
- callContext?.thisValue,
148832
- { ...invocationContext, onSuspend: completePrefix },
148833
- evaluateNode3
148834
- );
148835
- resolve16(
148836
- isSandboxPromise(value) || getThenable(value) !== void 0 ? awaitSandboxValue(
148837
- createSandboxPromise(resolveSandboxValue(value, { budget: context.budget }), {
148838
- trackReplay: false
148839
- }),
148840
- context.signal,
148841
- context.budget
148842
- ) : allocateProducedSandboxValue(value, context.budget)
148843
- );
148844
- } catch (error3) {
148845
- reject(error3);
148846
- } finally {
148847
- completePrefix();
148848
- }
148849
- }).catch((error3) => {
148850
- reject(error3);
148851
- completePrefix();
148852
- });
148853
- });
148854
- return createSandboxPromise(promise, { synchronousPrefix });
148822
+ return executeAsyncFunction(
148823
+ (onSuspend) => executeClosure(
148824
+ node,
148825
+ args,
148826
+ callContext?.thisValue,
148827
+ { ...invocationContext, onSuspend },
148828
+ evaluateNode3
148829
+ ),
148830
+ context.budget,
148831
+ context.signal
148832
+ );
148855
148833
  }
148856
148834
  });
148857
148835
  return closure;
148858
148836
  }
148837
+ function executeAsyncFunction(execute2, budget, signal) {
148838
+ let completePrefix;
148839
+ const synchronousPrefix = new Promise((resolve16) => {
148840
+ completePrefix = resolve16;
148841
+ });
148842
+ const promise = new Promise((resolve16, reject) => {
148843
+ runAsyncPrefix(async () => {
148844
+ try {
148845
+ const value = await execute2(completePrefix);
148846
+ resolve16(
148847
+ isSandboxPromise(value) || getThenable(value) !== void 0 ? awaitSandboxValue(
148848
+ createSandboxPromise(resolveSandboxValue(value, { budget }), {
148849
+ trackReplay: false
148850
+ }),
148851
+ signal,
148852
+ budget
148853
+ ) : allocateProducedSandboxValue(value, budget)
148854
+ );
148855
+ } catch (error3) {
148856
+ reject(error3);
148857
+ } finally {
148858
+ completePrefix();
148859
+ }
148860
+ }).catch((error3) => {
148861
+ reject(error3);
148862
+ completePrefix();
148863
+ });
148864
+ });
148865
+ return createSandboxPromise(promise, { synchronousPrefix });
148866
+ }
148859
148867
  function createGeneratorClosure(node, context, evaluateNode3) {
148860
148868
  return createSandboxClosure({
148861
148869
  guest: true,