@pol-studios/powersync 1.0.25 → 1.0.30

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 (49) hide show
  1. package/README.md +0 -1
  2. package/dist/attachments/index.d.ts +1 -1
  3. package/dist/{background-sync-ChCXW-EV.d.ts → background-sync-CVR3PkFi.d.ts} +1 -1
  4. package/dist/{chunk-BGBQYQV3.js → chunk-BC2SRII2.js} +180 -299
  5. package/dist/chunk-BC2SRII2.js.map +1 -0
  6. package/dist/{chunk-YSTEESEG.js → chunk-C2ACBYBZ.js} +208 -11
  7. package/dist/chunk-C2ACBYBZ.js.map +1 -0
  8. package/dist/{chunk-24RDMMCL.js → chunk-FNYQFILT.js} +1 -1
  9. package/dist/chunk-FNYQFILT.js.map +1 -0
  10. package/dist/{chunk-VB737IVN.js → chunk-JCGOZVWL.js} +406 -323
  11. package/dist/chunk-JCGOZVWL.js.map +1 -0
  12. package/dist/{chunk-WGHNIAF7.js → chunk-QREWE3NR.js} +2 -2
  13. package/dist/{chunk-TIFL2KWE.js → chunk-RBPWEOIV.js} +3 -3
  14. package/dist/{chunk-55DKCJV4.js → chunk-RE5HWLCB.js} +124 -13
  15. package/dist/chunk-RE5HWLCB.js.map +1 -0
  16. package/dist/connector/index.d.ts +4 -4
  17. package/dist/connector/index.js +1 -2
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/index.d.ts +7 -7
  20. package/dist/index.js +27 -17
  21. package/dist/index.native.d.ts +5 -5
  22. package/dist/index.native.js +27 -17
  23. package/dist/index.web.d.ts +5 -5
  24. package/dist/index.web.js +27 -17
  25. package/dist/maintenance/index.d.ts +2 -2
  26. package/dist/maintenance/index.js +2 -2
  27. package/dist/platform/index.d.ts +1 -1
  28. package/dist/platform/index.native.d.ts +1 -1
  29. package/dist/platform/index.web.d.ts +1 -1
  30. package/dist/provider/index.d.ts +188 -28
  31. package/dist/provider/index.js +17 -7
  32. package/dist/react/index.d.ts +2 -2
  33. package/dist/react/index.js +3 -3
  34. package/dist/storage/index.d.ts +1 -1
  35. package/dist/storage/index.native.d.ts +1 -1
  36. package/dist/storage/index.web.d.ts +1 -1
  37. package/dist/{supabase-connector-D2oIl2t8.d.ts → supabase-connector-C4YpH_l3.d.ts} +23 -25
  38. package/dist/sync/index.d.ts +42 -5
  39. package/dist/sync/index.js +2 -2
  40. package/dist/{types-DiBvmGEi.d.ts → types-CpM2_LhU.d.ts} +17 -24
  41. package/dist/{types-CDqWh56B.d.ts → types-Dv1uf0LZ.d.ts} +16 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-24RDMMCL.js.map +0 -1
  44. package/dist/chunk-55DKCJV4.js.map +0 -1
  45. package/dist/chunk-BGBQYQV3.js.map +0 -1
  46. package/dist/chunk-VB737IVN.js.map +0 -1
  47. package/dist/chunk-YSTEESEG.js.map +0 -1
  48. /package/dist/{chunk-WGHNIAF7.js.map → chunk-QREWE3NR.js.map} +0 -0
  49. /package/dist/{chunk-TIFL2KWE.js.map → chunk-RBPWEOIV.js.map} +0 -0
@@ -8,12 +8,12 @@ import {
8
8
  HealthMonitor,
9
9
  MetricsCollector,
10
10
  SyncStatusTracker
11
- } from "./chunk-55DKCJV4.js";
11
+ } from "./chunk-RE5HWLCB.js";
12
12
  import {
13
13
  DEFAULT_CONNECTION_HEALTH,
14
14
  DEFAULT_SYNC_METRICS,
15
15
  DEFAULT_SYNC_STATUS
16
- } from "./chunk-24RDMMCL.js";
16
+ } from "./chunk-FNYQFILT.js";
17
17
  import {
18
18
  AttachmentQueueContext,
19
19
  CompletedTransactionsContext,
@@ -30,7 +30,7 @@ import {
30
30
  usePendingMutationsContext,
31
31
  usePowerSync,
32
32
  useSyncStatus
33
- } from "./chunk-YSTEESEG.js";
33
+ } from "./chunk-C2ACBYBZ.js";
34
34
  import {
35
35
  createSupabaseUploadHandler
36
36
  } from "./chunk-CAB26E6F.js";
@@ -42,7 +42,7 @@ import {
42
42
  } from "./chunk-WN5ZJ3E2.js";
43
43
  import {
44
44
  SupabaseConnector
45
- } from "./chunk-BGBQYQV3.js";
45
+ } from "./chunk-BC2SRII2.js";
46
46
  import {
47
47
  createSyncError,
48
48
  extractEntityIds,
@@ -120,6 +120,10 @@ var ConflictBus = class _ConflictBus {
120
120
  }
121
121
  };
122
122
 
123
+ // src/provider/constants.ts
124
+ var UPLOAD_MAX_RETRIES = 7;
125
+ var UPLOAD_BACKOFF_DELAYS = [4, 8, 16, 32, 64, 128, 256];
126
+
123
127
  // src/provider/PowerSyncProvider.tsx
124
128
  import { jsx } from "react/jsx-runtime";
125
129
  function PowerSyncProvider({
@@ -170,6 +174,13 @@ function PowerSyncProvider({
170
174
  const [failedTransactions, setFailedTransactions] = useState([]);
171
175
  const [completedTransactions, setCompletedTransactions] = useState([]);
172
176
  const [newCompletedTransactions, setNewCompletedTransactions] = useState([]);
177
+ const [uploadRetryState, setUploadRetryState] = useState({
178
+ retryCount: 0,
179
+ nextRetryAt: null,
180
+ isWaitingForRetry: false,
181
+ maxRetriesReached: false
182
+ });
183
+ const failureHandledThisCycleRef = useRef(false);
173
184
  const [connectionHealth, setConnectionHealth] = useState(DEFAULT_CONNECTION_HEALTH);
174
185
  const [syncMetrics, setSyncMetrics] = useState(DEFAULT_SYNC_METRICS);
175
186
  const [isAutoOffline, setIsAutoOffline] = useState(false);
@@ -192,6 +203,7 @@ function PowerSyncProvider({
192
203
  const syncModeRef = useRef("push-pull");
193
204
  const removePendingMutationRef = useRef(() => {
194
205
  });
206
+ const uploadRetryTimeoutRef = useRef(null);
195
207
  const onSyncStatusChangeRef = useRef(onSyncStatusChange);
196
208
  const onReadyRef = useRef(onReady);
197
209
  const onErrorRef = useRef(onError);
@@ -395,21 +407,84 @@ function PowerSyncProvider({
395
407
  conflictBus,
396
408
  // Check if uploads should be performed based on sync mode
397
409
  shouldUpload: () => statusTrackerRef.current?.shouldUpload() ?? true,
398
- // Clear failures when transaction succeeds
410
+ // Clear failures when transaction succeeds (auto-clear on success)
399
411
  onTransactionSuccess: (entries) => {
400
412
  if (!statusTracker_0) return;
401
- const entityIds = extractEntityIds(entries);
402
- entityIds.forEach((id) => {
403
- const failures = statusTracker_0.getFailuresForEntity(id);
404
- failures.forEach((f) => statusTracker_0.clearFailure(f.id));
405
- });
413
+ const entryIds = entries.map((e) => e.id);
414
+ statusTracker_0.clearSuccessfulEntries(entryIds);
406
415
  setFailedTransactions(statusTracker_0.getFailedTransactions());
416
+ failureHandledThisCycleRef.current = false;
417
+ if (uploadRetryTimeoutRef.current) {
418
+ clearTimeout(uploadRetryTimeoutRef.current);
419
+ uploadRetryTimeoutRef.current = null;
420
+ }
421
+ setUploadRetryState({
422
+ retryCount: 0,
423
+ nextRetryAt: null,
424
+ isWaitingForRetry: false,
425
+ maxRetriesReached: false
426
+ });
407
427
  },
408
- // Record failures when transaction fails
428
+ // Record failures when transaction fails with disconnect-based exponential backoff
409
429
  onTransactionFailure: (entries_0, error_0, classified) => {
410
430
  if (!statusTracker_0) return;
411
431
  statusTracker_0.recordTransactionFailure(entries_0, createSyncError(classified, error_0.message), classified.isPermanent, extractEntityIds(entries_0), extractTableNames(entries_0));
412
432
  setFailedTransactions(statusTracker_0.getFailedTransactions());
433
+ if (failureHandledThisCycleRef.current) {
434
+ logger.debug("[PowerSyncProvider] Failure already handled this cycle, skipping backoff");
435
+ return;
436
+ }
437
+ failureHandledThisCycleRef.current = true;
438
+ const BACKOFF_DELAYS = UPLOAD_BACKOFF_DELAYS;
439
+ const MAX_RETRIES = UPLOAD_MAX_RETRIES;
440
+ if (uploadRetryTimeoutRef.current) {
441
+ clearTimeout(uploadRetryTimeoutRef.current);
442
+ uploadRetryTimeoutRef.current = null;
443
+ }
444
+ setUploadRetryState((prev) => {
445
+ const newRetryCount = prev.retryCount + 1;
446
+ if (newRetryCount > MAX_RETRIES) {
447
+ logger.warn(`[PowerSyncProvider] Max upload retries (${MAX_RETRIES}) reached, staying disconnected`);
448
+ return {
449
+ retryCount: newRetryCount,
450
+ nextRetryAt: null,
451
+ isWaitingForRetry: false,
452
+ maxRetriesReached: true
453
+ };
454
+ }
455
+ const delaySeconds = BACKOFF_DELAYS[Math.min(newRetryCount - 1, BACKOFF_DELAYS.length - 1)];
456
+ const delayMs = delaySeconds * 1e3;
457
+ const nextRetryAt = new Date(Date.now() + delayMs);
458
+ logger.info(`[PowerSyncProvider] Upload failed (attempt ${newRetryCount}/${MAX_RETRIES}), disconnecting and retrying in ${delaySeconds}s`);
459
+ db.disconnect().catch((err_1) => {
460
+ logger.warn("[PowerSyncProvider] Error during backoff disconnect:", err_1);
461
+ });
462
+ uploadRetryTimeoutRef.current = setTimeout(async () => {
463
+ uploadRetryTimeoutRef.current = null;
464
+ failureHandledThisCycleRef.current = false;
465
+ logger.info(`[PowerSyncProvider] Backoff complete, reconnecting for retry attempt ${newRetryCount}`);
466
+ setUploadRetryState((curr) => ({
467
+ ...curr,
468
+ isWaitingForRetry: false,
469
+ nextRetryAt: null
470
+ }));
471
+ const currentConnector = connectorRef.current;
472
+ if (currentConnector && db && !dbClosedRef.current) {
473
+ try {
474
+ await db.connect(currentConnector);
475
+ logger.info("[PowerSyncProvider] Reconnected after backoff");
476
+ } catch (reconnectErr) {
477
+ logger.error("[PowerSyncProvider] Failed to reconnect after backoff:", reconnectErr);
478
+ }
479
+ }
480
+ }, delayMs);
481
+ return {
482
+ retryCount: newRetryCount,
483
+ nextRetryAt,
484
+ isWaitingForRetry: true,
485
+ maxRetriesReached: false
486
+ };
487
+ });
413
488
  },
414
489
  // Record completed transactions
415
490
  onTransactionComplete: (entries_1) => {
@@ -537,7 +612,7 @@ function PowerSyncProvider({
537
612
  } catch {
538
613
  return null;
539
614
  }
540
- }).filter((e) => e !== null);
615
+ }).filter((e_0) => e_0 !== null);
541
616
  if (!dbClosedRef.current) {
542
617
  statusTrackerRef.current?.updatePendingMutations(mutations);
543
618
  setPendingMutations(mutations);
@@ -550,15 +625,15 @@ function PowerSyncProvider({
550
625
  ...entry,
551
626
  createdAt: entry.createdAt ?? /* @__PURE__ */ new Date()
552
627
  };
553
- setPendingMutations((prev) => {
554
- const newMutations = [...prev, entryWithTimestamp];
628
+ setPendingMutations((prev_0) => {
629
+ const newMutations = [...prev_0, entryWithTimestamp];
555
630
  statusTrackerRef.current?.updatePendingMutations(newMutations);
556
631
  return newMutations;
557
632
  });
558
633
  }, []);
559
- const removePendingMutation = useCallback((id_0) => {
560
- setPendingMutations((prev_0) => {
561
- const newMutations_0 = prev_0.filter((m) => m.id !== id_0);
634
+ const removePendingMutation = useCallback((id) => {
635
+ setPendingMutations((prev_1) => {
636
+ const newMutations_0 = prev_1.filter((m) => m.id !== id);
562
637
  statusTrackerRef.current?.updatePendingMutations(newMutations_0);
563
638
  return newMutations_0;
564
639
  });
@@ -605,9 +680,9 @@ function PowerSyncProvider({
605
680
  setAttachmentQueue(queue);
606
681
  setAttachmentQueueReady(true);
607
682
  logger.info("[PowerSyncProvider] Attachment queue initialized successfully");
608
- } catch (err_1) {
683
+ } catch (err_2) {
609
684
  if (!controller_0.cancelled) {
610
- logger.error("[PowerSyncProvider] Attachment queue initialization failed:", err_1);
685
+ logger.error("[PowerSyncProvider] Attachment queue initialization failed:", err_2);
611
686
  setAttachmentQueueReady(true);
612
687
  }
613
688
  }
@@ -635,16 +710,20 @@ function PowerSyncProvider({
635
710
  attachmentQueueRef.current?.dispose();
636
711
  healthMonitorRef.current?.stop();
637
712
  conflictBusRef.current?.destroy();
713
+ if (uploadRetryTimeoutRef.current) {
714
+ clearTimeout(uploadRetryTimeoutRef.current);
715
+ uploadRetryTimeoutRef.current = null;
716
+ }
638
717
  if (db) {
639
718
  cleanupPromiseRef.current = (async () => {
640
719
  try {
641
720
  await db.disconnect();
642
721
  await db.close();
643
722
  logger.debug("[PowerSyncProvider] Database cleanup completed");
644
- } catch (err_2) {
645
- const errorMessage = err_2 instanceof Error ? err_2.message : String(err_2);
723
+ } catch (err_3) {
724
+ const errorMessage = err_3 instanceof Error ? err_3.message : String(err_3);
646
725
  if (!errorMessage.includes("not open") && !errorMessage.includes("closed")) {
647
- logger.warn("[PowerSyncProvider] Error during cleanup:", err_2);
726
+ logger.warn("[PowerSyncProvider] Error during cleanup:", err_3);
648
727
  }
649
728
  } finally {
650
729
  isCleaningUpRef.current = false;
@@ -701,8 +780,8 @@ function PowerSyncProvider({
701
780
  try {
702
781
  await db.connect(connector);
703
782
  logger.info("[PowerSyncProvider] Reconnected after network restore");
704
- } catch (err_3) {
705
- logger.warn("[PowerSyncProvider] Failed to reconnect after network restore:", err_3);
783
+ } catch (err_4) {
784
+ logger.warn("[PowerSyncProvider] Failed to reconnect after network restore:", err_4);
706
785
  }
707
786
  }
708
787
  }
@@ -733,8 +812,8 @@ function PowerSyncProvider({
733
812
  if (db && connector && !db.connected) {
734
813
  db.connect(connector).then(() => {
735
814
  logger.info("[PowerSyncProvider] Reconnected after auto-resume on startup");
736
- }).catch((err_4) => {
737
- logger.warn("[PowerSyncProvider] Failed to reconnect after auto-resume on startup:", err_4);
815
+ }).catch((err_5) => {
816
+ logger.warn("[PowerSyncProvider] Failed to reconnect after auto-resume on startup:", err_5);
738
817
  });
739
818
  }
740
819
  }
@@ -754,75 +833,66 @@ function PowerSyncProvider({
754
833
  tracker_3.clearFailure(failureId);
755
834
  setFailedTransactions(tracker_3.getFailedTransactions());
756
835
  }, [logger]);
757
- const clearAllFailures = useCallback(() => {
836
+ const clearCompletedHistory = useCallback(() => {
758
837
  const tracker_4 = statusTrackerRef.current;
759
838
  if (!tracker_4) {
760
- logger.warn("[PowerSyncProvider] Cannot clear failures - tracker not initialized");
839
+ logger.warn("[PowerSyncProvider] Cannot clear completed history - tracker not initialized");
761
840
  return;
762
841
  }
763
- tracker_4.clearAllFailures();
764
- setFailedTransactions(tracker_4.getFailedTransactions());
842
+ tracker_4.clearCompletedHistory();
843
+ setCompletedTransactions(tracker_4.getCompletedTransactions());
844
+ setNewCompletedTransactions(tracker_4.getNewCompletedTransactions());
765
845
  }, [logger]);
766
- const clearCompletedHistory = useCallback(() => {
846
+ const clearCompletedItem = useCallback((completedId) => {
767
847
  const tracker_5 = statusTrackerRef.current;
768
848
  if (!tracker_5) {
769
- logger.warn("[PowerSyncProvider] Cannot clear completed history - tracker not initialized");
849
+ logger.warn("[PowerSyncProvider] Cannot clear completed item - tracker not initialized");
770
850
  return;
771
851
  }
772
- tracker_5.clearCompletedHistory();
852
+ tracker_5.clearCompletedItem(completedId);
773
853
  setCompletedTransactions(tracker_5.getCompletedTransactions());
774
854
  setNewCompletedTransactions(tracker_5.getNewCompletedTransactions());
775
855
  }, [logger]);
776
- const clearCompletedItem = useCallback((completedId) => {
856
+ const markNotificationsAsSeen = useCallback(() => {
777
857
  const tracker_6 = statusTrackerRef.current;
778
858
  if (!tracker_6) {
779
- logger.warn("[PowerSyncProvider] Cannot clear completed item - tracker not initialized");
859
+ logger.warn("[PowerSyncProvider] Cannot mark notifications as seen - tracker not initialized");
780
860
  return;
781
861
  }
782
- tracker_6.clearCompletedItem(completedId);
783
- setCompletedTransactions(tracker_6.getCompletedTransactions());
862
+ tracker_6.markNotificationsAsSeen();
784
863
  setNewCompletedTransactions(tracker_6.getNewCompletedTransactions());
785
864
  }, [logger]);
786
- const markNotificationsAsSeen = useCallback(() => {
865
+ const setSyncMode = useCallback(async (mode) => {
787
866
  const tracker_7 = statusTrackerRef.current;
788
867
  if (!tracker_7) {
789
- logger.warn("[PowerSyncProvider] Cannot mark notifications as seen - tracker not initialized");
790
- return;
791
- }
792
- tracker_7.markNotificationsAsSeen();
793
- setNewCompletedTransactions(tracker_7.getNewCompletedTransactions());
794
- }, [logger]);
795
- const setSyncMode = useCallback(async (mode) => {
796
- const tracker_8 = statusTrackerRef.current;
797
- if (!tracker_8) {
798
868
  logger.warn("[PowerSyncProvider] Cannot set sync mode - tracker not initialized");
799
869
  return;
800
870
  }
801
- await tracker_8.setIsAutoOffline(false);
871
+ await tracker_7.setIsAutoOffline(false);
802
872
  setIsAutoOffline(false);
803
- await tracker_8.setSyncMode(mode);
873
+ await tracker_7.setSyncMode(mode);
804
874
  setSyncModeState({
805
875
  loaded: true,
806
876
  mode
807
877
  });
808
878
  }, [logger]);
809
879
  const setForceNextUpload = useCallback((force) => {
810
- const tracker_9 = statusTrackerRef.current;
811
- if (!tracker_9) {
880
+ const tracker_8 = statusTrackerRef.current;
881
+ if (!tracker_8) {
812
882
  logger.warn("[PowerSyncProvider] Cannot set force upload - tracker not initialized");
813
883
  return;
814
884
  }
815
- tracker_9.setForceNextUpload(force);
885
+ tracker_8.setForceNextUpload(force);
816
886
  }, [logger]);
817
887
  const setAutoOfflineMode = useCallback(async (mode_0, isAuto) => {
818
- const tracker_10 = statusTrackerRef.current;
819
- if (!tracker_10) {
888
+ const tracker_9 = statusTrackerRef.current;
889
+ if (!tracker_9) {
820
890
  logger.warn("[PowerSyncProvider] Cannot set sync mode - tracker not initialized");
821
891
  return;
822
892
  }
823
- await tracker_10.setIsAutoOffline(isAuto);
893
+ await tracker_9.setIsAutoOffline(isAuto);
824
894
  setIsAutoOffline(isAuto);
825
- await tracker_10.setSyncMode(mode_0);
895
+ await tracker_9.setSyncMode(mode_0);
826
896
  setSyncModeState({
827
897
  loaded: true,
828
898
  mode: mode_0
@@ -853,51 +923,81 @@ function PowerSyncProvider({
853
923
  }
854
924
  }
855
925
  }, [db, connector, syncStatus.uploading, logger]);
856
- const discardAllPendingMutations = useCallback(async () => {
857
- if (!db || !connector) {
858
- logger.warn("[PowerSync] Cannot discard all - not initialized");
926
+ const manualUploadRetry = useCallback(async () => {
927
+ const currentConnector_0 = connectorRef.current;
928
+ if (!db || !currentConnector_0) {
929
+ logger.warn("[PowerSyncProvider] Cannot manual retry - not initialized");
859
930
  return;
860
931
  }
861
- if (syncStatus.uploading) {
862
- throw new Error("Cannot discard while upload is in progress");
932
+ if (uploadRetryTimeoutRef.current) {
933
+ clearTimeout(uploadRetryTimeoutRef.current);
934
+ uploadRetryTimeoutRef.current = null;
863
935
  }
864
- logger.info("[PowerSync] Discarding all pending mutations");
865
- await db.disconnect();
936
+ failureHandledThisCycleRef.current = false;
937
+ setUploadRetryState({
938
+ retryCount: 0,
939
+ nextRetryAt: null,
940
+ isWaitingForRetry: false,
941
+ maxRetriesReached: false
942
+ });
943
+ logger.info("[PowerSyncProvider] Manual upload retry triggered");
866
944
  try {
867
- await db.execute("DELETE FROM ps_crud");
868
- logger.info("[PowerSync] All mutations discarded successfully");
869
- } finally {
870
- const currentConnector = connectorRef.current;
871
- if (currentConnector && db) {
872
- try {
873
- await db.connect(currentConnector);
874
- } catch (reconnectError) {
875
- logger.error("[PowerSync] Failed to reconnect after discard:", reconnectError);
876
- throw reconnectError;
877
- }
945
+ if (db.connected) {
946
+ await db.disconnect();
878
947
  }
948
+ await db.connect(currentConnector_0);
949
+ logger.info("[PowerSyncProvider] Reconnected after manual retry");
950
+ } catch (err_6) {
951
+ logger.error("[PowerSyncProvider] Manual retry failed:", err_6);
879
952
  }
880
- }, [db, connector, syncStatus.uploading, logger]);
881
- const pauseAutoRetry = useCallback(() => {
882
- if (!connector) {
883
- logger.warn("[PowerSyncProvider] Cannot pause auto-retry - connector not initialized");
953
+ }, [db, logger]);
954
+ const discardFailedEntryAndReconnect = useCallback(async (entryId) => {
955
+ const currentConnector_1 = connectorRef.current;
956
+ const tracker_10 = statusTrackerRef.current;
957
+ if (!db || !currentConnector_1) {
958
+ logger.warn("[PowerSyncProvider] Cannot discard failed entry - not initialized");
884
959
  return;
885
960
  }
886
- connector.pauseAutoRetry();
887
- }, [connector, logger]);
888
- const resumeAutoRetry = useCallback(() => {
889
- if (!connector) {
890
- logger.warn("[PowerSyncProvider] Cannot resume auto-retry - connector not initialized");
891
- return;
961
+ if (uploadRetryTimeoutRef.current) {
962
+ clearTimeout(uploadRetryTimeoutRef.current);
963
+ uploadRetryTimeoutRef.current = null;
964
+ }
965
+ logger.info("[PowerSyncProvider] Discarding entry", entryId, "and reconnecting");
966
+ await db.disconnect();
967
+ try {
968
+ await db.execute("DELETE FROM ps_crud WHERE id = ?", [entryId]);
969
+ logger.info("[PowerSyncProvider] Entry", entryId, "discarded");
970
+ if (tracker_10) {
971
+ const failures = tracker_10.getFailedTransactions();
972
+ for (const failure of failures) {
973
+ const hasEntry = failure.entries.some((e_1) => e_1.clientId === entryId);
974
+ if (hasEntry) {
975
+ tracker_10.clearFailure(failure.id);
976
+ break;
977
+ }
978
+ }
979
+ setFailedTransactions(tracker_10.getFailedTransactions());
980
+ }
981
+ failureHandledThisCycleRef.current = false;
982
+ setUploadRetryState({
983
+ retryCount: 0,
984
+ nextRetryAt: null,
985
+ isWaitingForRetry: false,
986
+ maxRetriesReached: false
987
+ });
988
+ await db.connect(currentConnector_1);
989
+ logger.info("[PowerSyncProvider] Reconnected after discarding entry", entryId);
990
+ } catch (err_7) {
991
+ logger.error("[PowerSyncProvider] Failed to discard entry and reconnect:", err_7);
992
+ throw err_7;
892
993
  }
893
- connector.resumeAutoRetry();
894
- }, [connector, logger]);
994
+ }, [db, logger]);
895
995
  const retryFailure = useCallback(async (failureId_0) => {
896
996
  const tracker_11 = statusTrackerRef.current;
897
997
  if (!tracker_11) return;
898
998
  const failures_0 = tracker_11.getFailedTransactions();
899
- const failure = failures_0.find((f_0) => f_0.id === failureId_0);
900
- if (!failure) {
999
+ const failure_0 = failures_0.find((f) => f.id === failureId_0);
1000
+ if (!failure_0) {
901
1001
  logger.warn("[PowerSyncProvider] Failure not found:", failureId_0);
902
1002
  return;
903
1003
  }
@@ -906,9 +1006,9 @@ function PowerSyncProvider({
906
1006
  setFailedTransactions(tracker_11.getFailedTransactions());
907
1007
  if (!db || !connector) {
908
1008
  logger.warn("[PowerSyncProvider] Cannot retry - not initialized");
909
- tracker_11.recordTransactionFailure(failure.entries, failure.error, failure.isPermanent, failure.affectedEntityIds, failure.affectedTables, {
910
- retryCount: failure.retryCount,
911
- firstFailedAt: failure.firstFailedAt
1009
+ tracker_11.recordTransactionFailure(failure_0.entries, failure_0.error, failure_0.isPermanent, failure_0.affectedEntityIds, failure_0.affectedTables, {
1010
+ retryCount: failure_0.retryCount,
1011
+ firstFailedAt: failure_0.firstFailedAt
912
1012
  });
913
1013
  setFailedTransactions(tracker_11.getFailedTransactions());
914
1014
  return;
@@ -919,11 +1019,11 @@ function PowerSyncProvider({
919
1019
  }
920
1020
  await db.connect(connector);
921
1021
  logger.info("[PowerSyncProvider] Retry triggered for failure:", failureId_0);
922
- } catch (err_5) {
923
- logger.error("[PowerSyncProvider] Retry failed, re-recording failure:", err_5);
924
- tracker_11.recordTransactionFailure(failure.entries, failure.error, failure.isPermanent, failure.affectedEntityIds, failure.affectedTables, {
925
- retryCount: failure.retryCount,
926
- firstFailedAt: failure.firstFailedAt
1022
+ } catch (err_8) {
1023
+ logger.error("[PowerSyncProvider] Retry failed, re-recording failure:", err_8);
1024
+ tracker_11.recordTransactionFailure(failure_0.entries, failure_0.error, failure_0.isPermanent, failure_0.affectedEntityIds, failure_0.affectedTables, {
1025
+ retryCount: failure_0.retryCount,
1026
+ firstFailedAt: failure_0.firstFailedAt
927
1027
  });
928
1028
  setFailedTransactions(tracker_11.getFailedTransactions());
929
1029
  }
@@ -955,10 +1055,9 @@ function PowerSyncProvider({
955
1055
  // Failed transaction fields
956
1056
  failedTransactions,
957
1057
  hasUploadErrors: failedTransactions.length > 0,
958
- permanentErrorCount: failedTransactions.filter((f_1) => f_1.isPermanent).length,
1058
+ permanentErrorCount: failedTransactions.filter((f_0) => f_0.isPermanent).length,
959
1059
  // Clear failure functions
960
1060
  clearFailure,
961
- clearAllFailures,
962
1061
  // Completed transaction fields
963
1062
  completedTransactions,
964
1063
  clearCompletedHistory,
@@ -967,11 +1066,14 @@ function PowerSyncProvider({
967
1066
  setForceNextUpload,
968
1067
  // Discard mutation functions
969
1068
  discardPendingMutation,
970
- discardAllPendingMutations,
971
- // Retry control functions
972
- pauseAutoRetry,
973
- resumeAutoRetry
974
- }), [syncStatus, pendingMutations, syncModeState.mode, lastSyncedAt, connectionError, failedTransactions, clearFailure, clearAllFailures, completedTransactions, clearCompletedHistory, setSyncMode, setForceNextUpload, discardPendingMutation, discardAllPendingMutations, pauseAutoRetry, resumeAutoRetry]);
1069
+ // Upload retry state
1070
+ isWaitingForUploadRetry: uploadRetryState.isWaitingForRetry,
1071
+ nextUploadRetryAt: uploadRetryState.nextRetryAt,
1072
+ maxUploadRetriesReached: uploadRetryState.maxRetriesReached,
1073
+ uploadRetryCount: uploadRetryState.retryCount,
1074
+ manualUploadRetry,
1075
+ discardFailedEntryAndReconnect
1076
+ }), [syncStatus, pendingMutations, syncModeState.mode, lastSyncedAt, connectionError, failedTransactions, clearFailure, completedTransactions, clearCompletedHistory, setSyncMode, setForceNextUpload, discardPendingMutation, uploadRetryState, manualUploadRetry, discardFailedEntryAndReconnect]);
975
1077
  const connectionHealthContextValue = useMemo(() => ({
976
1078
  health: connectionHealth
977
1079
  }), [connectionHealth]);
@@ -994,20 +1096,16 @@ function PowerSyncProvider({
994
1096
  pendingMutations,
995
1097
  pendingCount: pendingMutations.length,
996
1098
  discardPendingMutation,
997
- discardAllPendingMutations,
998
1099
  addPendingMutation,
999
1100
  removePendingMutation
1000
- }), [pendingMutations, discardPendingMutation, discardAllPendingMutations, addPendingMutation, removePendingMutation]);
1101
+ }), [pendingMutations, discardPendingMutation, addPendingMutation, removePendingMutation]);
1001
1102
  const failedTransactionsValue = useMemo(() => ({
1002
1103
  failedTransactions,
1003
1104
  hasUploadErrors: failedTransactions.length > 0,
1004
- permanentErrorCount: failedTransactions.filter((f_2) => f_2.isPermanent).length,
1105
+ permanentErrorCount: failedTransactions.filter((f_1) => f_1.isPermanent).length,
1005
1106
  clearFailure,
1006
- clearAllFailures,
1007
- pauseAutoRetry,
1008
- resumeAutoRetry,
1009
1107
  retryFailure
1010
- }), [failedTransactions, clearFailure, clearAllFailures, pauseAutoRetry, resumeAutoRetry, retryFailure]);
1108
+ }), [failedTransactions, clearFailure, retryFailure]);
1011
1109
  const completedTransactionsValue = useMemo(() => ({
1012
1110
  completedTransactions,
1013
1111
  clearCompletedHistory,
@@ -1021,8 +1119,15 @@ function PowerSyncProvider({
1021
1119
  isAutoOffline,
1022
1120
  networkReachable,
1023
1121
  setSyncMode,
1024
- setForceNextUpload
1025
- }), [syncModeState.mode, isAutoOffline, networkReachable, setSyncMode, setForceNextUpload]);
1122
+ setForceNextUpload,
1123
+ // Upload retry state
1124
+ isWaitingForUploadRetry: uploadRetryState.isWaitingForRetry,
1125
+ nextUploadRetryAt: uploadRetryState.nextRetryAt,
1126
+ maxUploadRetriesReached: uploadRetryState.maxRetriesReached,
1127
+ uploadRetryCount: uploadRetryState.retryCount,
1128
+ manualUploadRetry,
1129
+ discardFailedEntryAndReconnect
1130
+ }), [syncModeState.mode, isAutoOffline, networkReachable, setSyncMode, setForceNextUpload, uploadRetryState, manualUploadRetry, discardFailedEntryAndReconnect]);
1026
1131
  return /* @__PURE__ */ jsx(PowerSyncContext.Provider, { value: powerSyncContextValue, children: /* @__PURE__ */ jsx(ConnectionStatusContext.Provider, { value: connectionStatusValue, children: /* @__PURE__ */ jsx(SyncActivityContext.Provider, { value: syncActivityValue, children: /* @__PURE__ */ jsx(PendingMutationsContext.Provider, { value: pendingMutationsValue, children: /* @__PURE__ */ jsx(FailedTransactionsContext.Provider, { value: failedTransactionsValue, children: /* @__PURE__ */ jsx(CompletedTransactionsContext.Provider, { value: completedTransactionsValue, children: /* @__PURE__ */ jsx(SyncModeContext.Provider, { value: syncModeValue, children: /* @__PURE__ */ jsx(SyncStatusContext.Provider, { value: syncStatusContextValue, children: /* @__PURE__ */ jsx(ConnectionHealthContext.Provider, { value: connectionHealthContextValue, children: /* @__PURE__ */ jsx(SyncMetricsContext.Provider, { value: syncMetricsContextValue, children: /* @__PURE__ */ jsx(AttachmentQueueContext.Provider, { value: attachmentQueue, children }) }) }) }) }) }) }) }) }) }) });
1027
1132
  }
1028
1133
 
@@ -1265,7 +1370,7 @@ function DefaultErrorRecoveryUI(t0) {
1265
1370
  return t6;
1266
1371
  }
1267
1372
  function OfflineDataProvider(t0) {
1268
- const $ = _c(103);
1373
+ const $ = _c(98);
1269
1374
  const {
1270
1375
  config,
1271
1376
  children,
@@ -1352,50 +1457,31 @@ function OfflineDataProvider(t0) {
1352
1457
  t9 = $[8];
1353
1458
  }
1354
1459
  let t11;
1355
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1356
- t11 = [];
1357
- $[9] = t11;
1358
- } else {
1359
- t11 = $[9];
1360
- }
1361
1460
  let t12;
1362
1461
  let t13;
1363
- if ($[10] !== platform.logger) {
1364
- t12 = () => {
1365
- platform.logger.warn("Pause auto-retry not available: Use useSyncControl from PowerSync context");
1366
- };
1367
- t13 = () => {
1368
- platform.logger.warn("Resume auto-retry not available: Use useSyncControl from PowerSync context");
1369
- };
1370
- $[10] = platform.logger;
1371
- $[11] = t12;
1372
- $[12] = t13;
1373
- } else {
1374
- t12 = $[11];
1375
- t13 = $[12];
1376
- }
1377
- let t14;
1378
- let t15;
1379
- if ($[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1380
- t14 = (entry) => {
1462
+ if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1463
+ t11 = [];
1464
+ t12 = (entry) => {
1381
1465
  if (addPendingMutationRef.current) {
1382
1466
  addPendingMutationRef.current(entry);
1383
1467
  }
1384
1468
  };
1385
- t15 = (id) => {
1469
+ t13 = (id) => {
1386
1470
  if (removePendingMutationRef.current) {
1387
1471
  removePendingMutationRef.current(id);
1388
1472
  }
1389
1473
  };
1390
- $[13] = t14;
1391
- $[14] = t15;
1474
+ $[9] = t11;
1475
+ $[10] = t12;
1476
+ $[11] = t13;
1392
1477
  } else {
1393
- t14 = $[13];
1394
- t15 = $[14];
1478
+ t11 = $[9];
1479
+ t12 = $[10];
1480
+ t13 = $[11];
1395
1481
  }
1396
- let t16;
1397
- if ($[15] !== t10 || $[16] !== t12 || $[17] !== t13 || $[18] !== t5 || $[19] !== t6 || $[20] !== t7 || $[21] !== t8 || $[22] !== t9) {
1398
- t16 = {
1482
+ let t14;
1483
+ if ($[12] !== t10 || $[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
1484
+ t14 = {
1399
1485
  triggerSync: t5,
1400
1486
  startLiveSync: t6,
1401
1487
  stopLiveSync: t7,
@@ -1403,49 +1489,44 @@ function OfflineDataProvider(t0) {
1403
1489
  retryFailedUploads: t9,
1404
1490
  clearFailedUploads: t10,
1405
1491
  failedUploads: t11,
1406
- pauseAutoRetry: t12,
1407
- resumeAutoRetry: t13,
1408
- isAutoRetryPaused: false,
1409
- addPendingMutation: t14,
1410
- removePendingMutation: t15
1492
+ addPendingMutation: t12,
1493
+ removePendingMutation: t13
1411
1494
  };
1412
- $[15] = t10;
1413
- $[16] = t12;
1414
- $[17] = t13;
1415
- $[18] = t5;
1416
- $[19] = t6;
1417
- $[20] = t7;
1418
- $[21] = t8;
1419
- $[22] = t9;
1420
- $[23] = t16;
1495
+ $[12] = t10;
1496
+ $[13] = t5;
1497
+ $[14] = t6;
1498
+ $[15] = t7;
1499
+ $[16] = t8;
1500
+ $[17] = t9;
1501
+ $[18] = t14;
1421
1502
  } else {
1422
- t16 = $[23];
1503
+ t14 = $[18];
1423
1504
  }
1424
- const syncControl = t16;
1425
- let t17;
1505
+ const syncControl = t14;
1506
+ let t15;
1426
1507
  bb0: {
1427
1508
  if (!attachments) {
1428
- t17 = void 0;
1509
+ t15 = void 0;
1429
1510
  break bb0;
1430
1511
  }
1431
- let t182;
1432
- if ($[24] !== attachments.bucket || $[25] !== storageBackend || $[26] !== supabaseClient) {
1433
- t182 = supabaseClient ? createSupabaseUploadHandler(supabaseClient, {
1512
+ let t162;
1513
+ if ($[19] !== attachments.bucket || $[20] !== storageBackend || $[21] !== supabaseClient) {
1514
+ t162 = supabaseClient ? createSupabaseUploadHandler(supabaseClient, {
1434
1515
  defaultBucket: attachments.bucket,
1435
1516
  resolver: storageBackend?.resolveBucket?.bind(storageBackend)
1436
1517
  }) : void 0;
1437
- $[24] = attachments.bucket;
1438
- $[25] = storageBackend;
1439
- $[26] = supabaseClient;
1440
- $[27] = t182;
1518
+ $[19] = attachments.bucket;
1519
+ $[20] = storageBackend;
1520
+ $[21] = supabaseClient;
1521
+ $[22] = t162;
1441
1522
  } else {
1442
- t182 = $[27];
1523
+ t162 = $[22];
1443
1524
  }
1444
- const nativeUploadHandler = t182;
1445
- const t192 = storageBackend;
1446
- let t202;
1447
- if ($[28] !== attachments.bucket || $[29] !== attachments.compression || $[30] !== attachments.download || $[31] !== attachments.maxCacheBytes || $[32] !== attachments.onUploadComplete || $[33] !== attachments.onUploadFailed || $[34] !== attachments.skipDownload || $[35] !== attachments.watchIds || $[36] !== nativeUploadHandler || $[37] !== t192) {
1448
- t202 = {
1525
+ const nativeUploadHandler = t162;
1526
+ const t172 = storageBackend;
1527
+ let t182;
1528
+ if ($[23] !== attachments.bucket || $[24] !== attachments.compression || $[25] !== attachments.download || $[26] !== attachments.maxCacheBytes || $[27] !== attachments.onUploadComplete || $[28] !== attachments.onUploadFailed || $[29] !== attachments.skipDownload || $[30] !== attachments.watchIds || $[31] !== nativeUploadHandler || $[32] !== t172) {
1529
+ t182 = {
1449
1530
  bucket: attachments.bucket,
1450
1531
  watchIds: attachments.watchIds,
1451
1532
  skipDownload: attachments.skipDownload,
@@ -1454,74 +1535,74 @@ function OfflineDataProvider(t0) {
1454
1535
  maxCacheBytes: attachments.maxCacheBytes,
1455
1536
  compression: attachments.compression,
1456
1537
  download: attachments.download,
1457
- remoteStorage: t192,
1538
+ remoteStorage: t172,
1458
1539
  uploadHandler: nativeUploadHandler
1459
1540
  };
1460
- $[28] = attachments.bucket;
1461
- $[29] = attachments.compression;
1462
- $[30] = attachments.download;
1463
- $[31] = attachments.maxCacheBytes;
1464
- $[32] = attachments.onUploadComplete;
1465
- $[33] = attachments.onUploadFailed;
1466
- $[34] = attachments.skipDownload;
1467
- $[35] = attachments.watchIds;
1468
- $[36] = nativeUploadHandler;
1469
- $[37] = t192;
1470
- $[38] = t202;
1541
+ $[23] = attachments.bucket;
1542
+ $[24] = attachments.compression;
1543
+ $[25] = attachments.download;
1544
+ $[26] = attachments.maxCacheBytes;
1545
+ $[27] = attachments.onUploadComplete;
1546
+ $[28] = attachments.onUploadFailed;
1547
+ $[29] = attachments.skipDownload;
1548
+ $[30] = attachments.watchIds;
1549
+ $[31] = nativeUploadHandler;
1550
+ $[32] = t172;
1551
+ $[33] = t182;
1471
1552
  } else {
1472
- t202 = $[38];
1553
+ t182 = $[33];
1473
1554
  }
1474
- t17 = t202;
1555
+ t15 = t182;
1475
1556
  }
1476
- const attachmentConfig = t17;
1477
- const t18 = powerSyncUrl ?? "";
1478
- const t19 = syncConfig?.autoConnect ?? true;
1479
- const t20 = syncConfig?.enableHealthMonitoring ?? true;
1480
- const t21 = syncConfig?.enableMetrics ?? true;
1481
- let t22;
1482
- if ($[39] !== t19 || $[40] !== t20 || $[41] !== t21) {
1483
- t22 = {
1484
- autoConnect: t19,
1485
- enableHealthMonitoring: t20,
1486
- enableMetrics: t21
1557
+ const attachmentConfig = t15;
1558
+ const t16 = powerSyncUrl ?? "";
1559
+ const t17 = syncConfig?.autoConnect ?? true;
1560
+ const t18 = syncConfig?.enableHealthMonitoring ?? true;
1561
+ const t19 = syncConfig?.enableMetrics ?? true;
1562
+ let t20;
1563
+ if ($[34] !== t17 || $[35] !== t18 || $[36] !== t19) {
1564
+ t20 = {
1565
+ autoConnect: t17,
1566
+ enableHealthMonitoring: t18,
1567
+ enableMetrics: t19
1487
1568
  };
1488
- $[39] = t19;
1489
- $[40] = t20;
1490
- $[41] = t21;
1491
- $[42] = t22;
1569
+ $[34] = t17;
1570
+ $[35] = t18;
1571
+ $[36] = t19;
1572
+ $[37] = t20;
1492
1573
  } else {
1493
- t22 = $[42];
1574
+ t20 = $[37];
1494
1575
  }
1495
- let t23;
1496
- if ($[43] !== attachmentConfig || $[44] !== connectorConfig || $[45] !== dbFilename || $[46] !== platform || $[47] !== queryClient || $[48] !== schema || $[49] !== supabaseClient || $[50] !== t18 || $[51] !== t22) {
1497
- t23 = {
1576
+ let t21;
1577
+ if ($[38] !== attachmentConfig || $[39] !== connectorConfig || $[40] !== dbFilename || $[41] !== platform || $[42] !== queryClient || $[43] !== schema || $[44] !== supabaseClient || $[45] !== t16 || $[46] !== t20) {
1578
+ t21 = {
1498
1579
  platform,
1499
1580
  schema,
1500
- powerSyncUrl: t18,
1581
+ powerSyncUrl: t16,
1501
1582
  supabaseClient,
1502
1583
  queryClient,
1503
1584
  dbFilename,
1504
1585
  connector: connectorConfig,
1505
1586
  attachments: attachmentConfig,
1506
- sync: t22
1587
+ sync: t20
1507
1588
  };
1508
- $[43] = attachmentConfig;
1509
- $[44] = connectorConfig;
1510
- $[45] = dbFilename;
1511
- $[46] = platform;
1512
- $[47] = queryClient;
1513
- $[48] = schema;
1514
- $[49] = supabaseClient;
1515
- $[50] = t18;
1516
- $[51] = t22;
1517
- $[52] = t23;
1589
+ $[38] = attachmentConfig;
1590
+ $[39] = connectorConfig;
1591
+ $[40] = dbFilename;
1592
+ $[41] = platform;
1593
+ $[42] = queryClient;
1594
+ $[43] = schema;
1595
+ $[44] = supabaseClient;
1596
+ $[45] = t16;
1597
+ $[46] = t20;
1598
+ $[47] = t21;
1518
1599
  } else {
1519
- t23 = $[52];
1600
+ t21 = $[47];
1520
1601
  }
1521
- const powerSyncConfig = t23;
1522
- let t24;
1523
- if ($[53] !== onError || $[54] !== platform.logger) {
1524
- t24 = (err) => {
1602
+ const powerSyncConfig = t21;
1603
+ let t22;
1604
+ if ($[48] !== onError || $[49] !== platform.logger) {
1605
+ t22 = (err) => {
1525
1606
  platform.logger.error("PowerSync error:", err);
1526
1607
  const errorMessage = err.message ?? "";
1527
1608
  if (errorMessage.includes("not open") || errorMessage.includes("closed") || errorMessage.includes("failed to open") || errorMessage.includes("initialization failed")) {
@@ -1529,96 +1610,96 @@ function OfflineDataProvider(t0) {
1529
1610
  }
1530
1611
  onError?.(err);
1531
1612
  };
1532
- $[53] = onError;
1533
- $[54] = platform.logger;
1534
- $[55] = t24;
1613
+ $[48] = onError;
1614
+ $[49] = platform.logger;
1615
+ $[50] = t22;
1535
1616
  } else {
1536
- t24 = $[55];
1617
+ t22 = $[50];
1537
1618
  }
1538
- const handlePowerSyncError = t24;
1539
- let t25;
1540
- if ($[56] !== platform.logger) {
1541
- t25 = () => {
1619
+ const handlePowerSyncError = t22;
1620
+ let t23;
1621
+ if ($[51] !== platform.logger) {
1622
+ t23 = () => {
1542
1623
  platform.logger.info("Retrying PowerSync initialization...");
1543
1624
  setInitError(null);
1544
1625
  setRetryKey(_temp);
1545
1626
  };
1546
- $[56] = platform.logger;
1547
- $[57] = t25;
1627
+ $[51] = platform.logger;
1628
+ $[52] = t23;
1548
1629
  } else {
1549
- t25 = $[57];
1630
+ t23 = $[52];
1550
1631
  }
1551
- const handleRetry = t25;
1552
- let t26;
1553
- if ($[58] !== backgroundSync?.callbacks || $[59] !== onBackgroundSyncSystemReadyProp || $[60] !== platform.logger) {
1554
- t26 = (system) => {
1632
+ const handleRetry = t23;
1633
+ let t24;
1634
+ if ($[53] !== backgroundSync?.callbacks || $[54] !== onBackgroundSyncSystemReadyProp || $[55] !== platform.logger) {
1635
+ t24 = (system) => {
1555
1636
  backgroundSyncSystemRef.current = system;
1556
1637
  backgroundSync?.callbacks?.onSyncStart?.();
1557
1638
  onBackgroundSyncSystemReadyProp?.(system);
1558
1639
  platform.logger.info("[Background Sync] System ready");
1559
1640
  };
1560
- $[58] = backgroundSync?.callbacks;
1561
- $[59] = onBackgroundSyncSystemReadyProp;
1562
- $[60] = platform.logger;
1563
- $[61] = t26;
1641
+ $[53] = backgroundSync?.callbacks;
1642
+ $[54] = onBackgroundSyncSystemReadyProp;
1643
+ $[55] = platform.logger;
1644
+ $[56] = t24;
1564
1645
  } else {
1565
- t26 = $[61];
1646
+ t24 = $[56];
1566
1647
  }
1567
1648
  backgroundSync?.callbacks;
1568
- const handleBackgroundSyncSystemReady = t26;
1569
- let t27;
1570
- if ($[62] !== renderError || $[63] !== renderInitError) {
1571
- t27 = (error, retry) => {
1649
+ const handleBackgroundSyncSystemReady = t24;
1650
+ let t25;
1651
+ if ($[57] !== renderError || $[58] !== renderInitError) {
1652
+ t25 = (error, retry) => {
1572
1653
  const customRenderer = renderInitError ?? renderError;
1573
1654
  if (customRenderer) {
1574
1655
  return customRenderer(error, retry);
1575
1656
  }
1576
1657
  return /* @__PURE__ */ jsx3(DefaultErrorRecoveryUI, { error, onRetry: retry });
1577
1658
  };
1578
- $[62] = renderError;
1579
- $[63] = renderInitError;
1580
- $[64] = t27;
1659
+ $[57] = renderError;
1660
+ $[58] = renderInitError;
1661
+ $[59] = t25;
1581
1662
  } else {
1582
- t27 = $[64];
1663
+ t25 = $[59];
1583
1664
  }
1584
- const errorFallback = t27;
1585
- let t28;
1586
- if ($[65] !== powerSyncSyncStatus || $[66] !== powerSyncUrl) {
1587
- t28 = !powerSyncUrl ? {
1665
+ const errorFallback = t25;
1666
+ let t26;
1667
+ if ($[60] !== powerSyncSyncStatus || $[61] !== powerSyncUrl) {
1668
+ t26 = !powerSyncUrl ? {
1588
1669
  hasSynced: true,
1589
1670
  connected: true,
1590
1671
  connecting: false,
1591
1672
  isOnline: true
1592
1673
  } : powerSyncSyncStatus;
1593
- $[65] = powerSyncSyncStatus;
1594
- $[66] = powerSyncUrl;
1595
- $[67] = t28;
1674
+ $[60] = powerSyncSyncStatus;
1675
+ $[61] = powerSyncUrl;
1676
+ $[62] = t26;
1596
1677
  } else {
1597
- t28 = $[67];
1678
+ t26 = $[62];
1598
1679
  }
1599
- const effectiveSyncStatus = t28;
1600
- let t29;
1601
- let t30;
1602
- if ($[68] !== effectiveSyncStatus || $[69] !== onSyncStatusChange) {
1603
- t29 = () => {
1680
+ const effectiveSyncStatus = t26;
1681
+ let t27;
1682
+ let t28;
1683
+ if ($[63] !== effectiveSyncStatus || $[64] !== onSyncStatusChange) {
1684
+ t27 = () => {
1604
1685
  if (effectiveSyncStatus) {
1605
1686
  onSyncStatusChange?.(effectiveSyncStatus);
1606
1687
  }
1607
1688
  };
1608
- t30 = [effectiveSyncStatus, onSyncStatusChange];
1609
- $[68] = effectiveSyncStatus;
1610
- $[69] = onSyncStatusChange;
1611
- $[70] = t29;
1612
- $[71] = t30;
1689
+ t28 = [effectiveSyncStatus, onSyncStatusChange];
1690
+ $[63] = effectiveSyncStatus;
1691
+ $[64] = onSyncStatusChange;
1692
+ $[65] = t27;
1693
+ $[66] = t28;
1613
1694
  } else {
1614
- t29 = $[70];
1615
- t30 = $[71];
1695
+ t27 = $[65];
1696
+ t28 = $[66];
1616
1697
  }
1617
- useEffect3(t29, t30);
1618
- let t31;
1619
- let t32;
1620
- if ($[72] !== backgroundSync || $[73] !== children || $[74] !== dataLayer || $[75] !== effectiveSyncStatus || $[76] !== errorFallback || $[77] !== handleBackgroundSyncSystemReady || $[78] !== handlePowerSyncError || $[79] !== handleRetry || $[80] !== initError || $[81] !== onReady || $[82] !== platform.logger || $[83] !== powerSyncConfig || $[84] !== powerSyncInstance || $[85] !== powerSyncUrl || $[86] !== queryClient || $[87] !== renderError || $[88] !== renderInitError || $[89] !== retryKey || $[90] !== skipConflictProvider || $[91] !== skipStorageQueueProvider || $[92] !== supabaseClient || $[93] !== syncControl) {
1621
- t32 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
1698
+ useEffect3(t27, t28);
1699
+ let t29;
1700
+ let t30;
1701
+ if ($[67] !== backgroundSync || $[68] !== children || $[69] !== dataLayer || $[70] !== effectiveSyncStatus || $[71] !== errorFallback || $[72] !== handleBackgroundSyncSystemReady || $[73] !== handlePowerSyncError || $[74] !== handleRetry || $[75] !== initError || $[76] !== onReady || $[77] !== platform.logger || $[78] !== powerSyncConfig || $[79] !== powerSyncInstance || $[80] !== powerSyncUrl || $[81] !== queryClient || $[82] !== renderError || $[83] !== renderInitError || $[84] !== retryKey || $[85] !== skipConflictProvider || $[86] !== skipStorageQueueProvider || $[87] !== supabaseClient || $[88] !== syncControl) {
1702
+ t30 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
1622
1703
  bb1: {
1623
1704
  const renderContent = () => {
1624
1705
  if (!powerSyncUrl) {
@@ -1646,58 +1727,58 @@ function OfflineDataProvider(t0) {
1646
1727
  removePendingMutationRef.current = remove;
1647
1728
  }, children }) }, retryKey) });
1648
1729
  };
1649
- let t33;
1650
- if ($[96] !== dataLayer.config || $[97] !== effectiveSyncStatus || $[98] !== powerSyncInstance || $[99] !== queryClient || $[100] !== supabaseClient || $[101] !== syncControl) {
1651
- t33 = (content) => /* @__PURE__ */ jsx3(DataLayerProvider, { config: dataLayer.config, powerSyncInstance, supabaseClient, queryClient, powerSyncSyncStatus: effectiveSyncStatus, syncControl, children: content });
1652
- $[96] = dataLayer.config;
1653
- $[97] = effectiveSyncStatus;
1654
- $[98] = powerSyncInstance;
1655
- $[99] = queryClient;
1656
- $[100] = supabaseClient;
1657
- $[101] = syncControl;
1658
- $[102] = t33;
1730
+ let t31;
1731
+ if ($[91] !== dataLayer.config || $[92] !== effectiveSyncStatus || $[93] !== powerSyncInstance || $[94] !== queryClient || $[95] !== supabaseClient || $[96] !== syncControl) {
1732
+ t31 = (content) => /* @__PURE__ */ jsx3(DataLayerProvider, { config: dataLayer.config, powerSyncInstance, supabaseClient, queryClient, powerSyncSyncStatus: effectiveSyncStatus, syncControl, children: content });
1733
+ $[91] = dataLayer.config;
1734
+ $[92] = effectiveSyncStatus;
1735
+ $[93] = powerSyncInstance;
1736
+ $[94] = queryClient;
1737
+ $[95] = supabaseClient;
1738
+ $[96] = syncControl;
1739
+ $[97] = t31;
1659
1740
  } else {
1660
- t33 = $[102];
1741
+ t31 = $[97];
1661
1742
  }
1662
- const renderWithDataLayer = t33;
1743
+ const renderWithDataLayer = t31;
1663
1744
  if (dataLayer && !dataLayer.skip) {
1664
- t32 = renderWithDataLayer(renderContent());
1745
+ t30 = renderWithDataLayer(renderContent());
1665
1746
  break bb1;
1666
1747
  }
1667
- t31 = renderContent();
1748
+ t29 = renderContent();
1668
1749
  }
1669
- $[72] = backgroundSync;
1670
- $[73] = children;
1671
- $[74] = dataLayer;
1672
- $[75] = effectiveSyncStatus;
1673
- $[76] = errorFallback;
1674
- $[77] = handleBackgroundSyncSystemReady;
1675
- $[78] = handlePowerSyncError;
1676
- $[79] = handleRetry;
1677
- $[80] = initError;
1678
- $[81] = onReady;
1679
- $[82] = platform.logger;
1680
- $[83] = powerSyncConfig;
1681
- $[84] = powerSyncInstance;
1682
- $[85] = powerSyncUrl;
1683
- $[86] = queryClient;
1684
- $[87] = renderError;
1685
- $[88] = renderInitError;
1686
- $[89] = retryKey;
1687
- $[90] = skipConflictProvider;
1688
- $[91] = skipStorageQueueProvider;
1689
- $[92] = supabaseClient;
1690
- $[93] = syncControl;
1691
- $[94] = t31;
1692
- $[95] = t32;
1750
+ $[67] = backgroundSync;
1751
+ $[68] = children;
1752
+ $[69] = dataLayer;
1753
+ $[70] = effectiveSyncStatus;
1754
+ $[71] = errorFallback;
1755
+ $[72] = handleBackgroundSyncSystemReady;
1756
+ $[73] = handlePowerSyncError;
1757
+ $[74] = handleRetry;
1758
+ $[75] = initError;
1759
+ $[76] = onReady;
1760
+ $[77] = platform.logger;
1761
+ $[78] = powerSyncConfig;
1762
+ $[79] = powerSyncInstance;
1763
+ $[80] = powerSyncUrl;
1764
+ $[81] = queryClient;
1765
+ $[82] = renderError;
1766
+ $[83] = renderInitError;
1767
+ $[84] = retryKey;
1768
+ $[85] = skipConflictProvider;
1769
+ $[86] = skipStorageQueueProvider;
1770
+ $[87] = supabaseClient;
1771
+ $[88] = syncControl;
1772
+ $[89] = t29;
1773
+ $[90] = t30;
1693
1774
  } else {
1694
- t31 = $[94];
1695
- t32 = $[95];
1775
+ t29 = $[89];
1776
+ t30 = $[90];
1696
1777
  }
1697
- if (t32 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel")) {
1698
- return t32;
1778
+ if (t30 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel")) {
1779
+ return t30;
1699
1780
  }
1700
- return t31;
1781
+ return t29;
1701
1782
  }
1702
1783
  function _temp(prev) {
1703
1784
  return prev + 1;
@@ -1705,8 +1786,10 @@ function _temp(prev) {
1705
1786
 
1706
1787
  export {
1707
1788
  ConflictBus,
1789
+ UPLOAD_MAX_RETRIES,
1790
+ UPLOAD_BACKOFF_DELAYS,
1708
1791
  PowerSyncProvider,
1709
1792
  ProviderBridge,
1710
1793
  OfflineDataProvider
1711
1794
  };
1712
- //# sourceMappingURL=chunk-VB737IVN.js.map
1795
+ //# sourceMappingURL=chunk-JCGOZVWL.js.map