@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.mjs CHANGED
@@ -462,6 +462,8 @@ function ActionProvider(props) {
462
462
  });
463
463
  let __ok = true;
464
464
  let __error = void 0;
465
+ let __cancelled = false;
466
+ let __confirmMs = void 0;
465
467
  try {
466
468
  if (resolved.action === "setState" && resolved.params) {
467
469
  const statePath = resolved.params.statePath;
@@ -547,39 +549,28 @@ function ActionProvider(props) {
547
549
  return;
548
550
  }
549
551
  if (resolved.confirm) {
550
- return new Promise((resolve, reject) => {
552
+ pendingConfirmation()?.reject();
553
+ const confirmOpenedAt = Date.now();
554
+ const confirmed = await new Promise((res) => {
551
555
  setPendingConfirmation({
552
556
  action: resolved,
553
557
  handler,
554
558
  resolve: () => {
555
559
  setPendingConfirmation(null);
556
- resolve();
560
+ res(true);
557
561
  },
558
562
  reject: () => {
559
563
  setPendingConfirmation(null);
560
- reject(new Error("Action cancelled"));
564
+ res(false);
561
565
  }
562
566
  });
563
- }).then(async () => {
564
- setLoadingActions((prev) => new Set(prev).add(resolved.action));
565
- try {
566
- await executeAction({
567
- action: resolved,
568
- handler,
569
- setState: set,
570
- navigate: props.navigate,
571
- executeAction: async (binding2) => {
572
- await execute(binding2);
573
- }
574
- });
575
- } finally {
576
- setLoadingActions((prev) => {
577
- const next = new Set(prev);
578
- next.delete(resolved.action);
579
- return next;
580
- });
581
- }
582
567
  });
568
+ __confirmMs = Date.now() - confirmOpenedAt;
569
+ if (!confirmed) {
570
+ __ok = false;
571
+ __cancelled = true;
572
+ return;
573
+ }
583
574
  }
584
575
  setLoadingActions((prev) => new Set(prev).add(resolved.action));
585
576
  try {
@@ -611,6 +602,8 @@ function ActionProvider(props) {
611
602
  ok: __ok,
612
603
  at: now,
613
604
  durationMs: now - dispatchedAt,
605
+ cancelled: __cancelled || void 0,
606
+ confirmMs: __confirmMs,
614
607
  error: __error
615
608
  });
616
609
  }