@xmachines/json-render-solid 0.20.0-xm.2 → 0.20.0-xm.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/dist/index.js CHANGED
@@ -513,6 +513,8 @@ function ActionProvider(props) {
513
513
  });
514
514
  let __ok = true;
515
515
  let __error = void 0;
516
+ let __cancelled = false;
517
+ let __confirmMs = void 0;
516
518
  try {
517
519
  if (resolved.action === "setState" && resolved.params) {
518
520
  const statePath = resolved.params.statePath;
@@ -598,39 +600,28 @@ function ActionProvider(props) {
598
600
  return;
599
601
  }
600
602
  if (resolved.confirm) {
601
- return new Promise((resolve, reject) => {
603
+ pendingConfirmation()?.reject();
604
+ const confirmOpenedAt = Date.now();
605
+ const confirmed = await new Promise((res) => {
602
606
  setPendingConfirmation({
603
607
  action: resolved,
604
608
  handler,
605
609
  resolve: () => {
606
610
  setPendingConfirmation(null);
607
- resolve();
611
+ res(true);
608
612
  },
609
613
  reject: () => {
610
614
  setPendingConfirmation(null);
611
- reject(new Error("Action cancelled"));
615
+ res(false);
612
616
  }
613
617
  });
614
- }).then(async () => {
615
- setLoadingActions((prev) => new Set(prev).add(resolved.action));
616
- try {
617
- await (0, import_core4.executeAction)({
618
- action: resolved,
619
- handler,
620
- setState: set,
621
- navigate: props.navigate,
622
- executeAction: async (binding2) => {
623
- await execute(binding2);
624
- }
625
- });
626
- } finally {
627
- setLoadingActions((prev) => {
628
- const next = new Set(prev);
629
- next.delete(resolved.action);
630
- return next;
631
- });
632
- }
633
618
  });
619
+ __confirmMs = Date.now() - confirmOpenedAt;
620
+ if (!confirmed) {
621
+ __ok = false;
622
+ __cancelled = true;
623
+ return;
624
+ }
634
625
  }
635
626
  setLoadingActions((prev) => new Set(prev).add(resolved.action));
636
627
  try {
@@ -662,6 +653,8 @@ function ActionProvider(props) {
662
653
  ok: __ok,
663
654
  at: now,
664
655
  durationMs: now - dispatchedAt,
656
+ cancelled: __cancelled || void 0,
657
+ confirmMs: __confirmMs,
665
658
  error: __error
666
659
  });
667
660
  }