@pol-studios/powersync 1.0.24 → 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.
- package/README.md +0 -1
- package/dist/attachments/index.d.ts +1 -1
- package/dist/{background-sync-ChCXW-EV.d.ts → background-sync-CVR3PkFi.d.ts} +1 -1
- package/dist/{chunk-BGBQYQV3.js → chunk-BC2SRII2.js} +180 -299
- package/dist/chunk-BC2SRII2.js.map +1 -0
- package/dist/{chunk-YSTEESEG.js → chunk-C2ACBYBZ.js} +208 -11
- package/dist/chunk-C2ACBYBZ.js.map +1 -0
- package/dist/{chunk-24RDMMCL.js → chunk-FNYQFILT.js} +1 -1
- package/dist/chunk-FNYQFILT.js.map +1 -0
- package/dist/{chunk-YVX3A36I.js → chunk-JCGOZVWL.js} +406 -331
- package/dist/chunk-JCGOZVWL.js.map +1 -0
- package/dist/{chunk-WGHNIAF7.js → chunk-QREWE3NR.js} +2 -2
- package/dist/{chunk-TIFL2KWE.js → chunk-RBPWEOIV.js} +3 -3
- package/dist/{chunk-55DKCJV4.js → chunk-RE5HWLCB.js} +124 -13
- package/dist/chunk-RE5HWLCB.js.map +1 -0
- package/dist/connector/index.d.ts +4 -4
- package/dist/connector/index.js +1 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/generator/cli.js +6 -1
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.js +9 -1
- package/dist/generator/index.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +27 -17
- package/dist/index.native.d.ts +5 -5
- package/dist/index.native.js +27 -17
- package/dist/index.web.d.ts +5 -5
- package/dist/index.web.js +27 -17
- package/dist/maintenance/index.d.ts +2 -2
- package/dist/maintenance/index.js +2 -2
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.native.d.ts +1 -1
- package/dist/platform/index.web.d.ts +1 -1
- package/dist/provider/index.d.ts +188 -28
- package/dist/provider/index.js +17 -7
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +3 -3
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.native.d.ts +1 -1
- package/dist/storage/index.web.d.ts +1 -1
- package/dist/{supabase-connector-D2oIl2t8.d.ts → supabase-connector-C4YpH_l3.d.ts} +23 -25
- package/dist/sync/index.d.ts +42 -5
- package/dist/sync/index.js +2 -2
- package/dist/{types-DiBvmGEi.d.ts → types-CpM2_LhU.d.ts} +17 -24
- package/dist/{types-CDqWh56B.d.ts → types-Dv1uf0LZ.d.ts} +16 -1
- package/package.json +2 -2
- package/dist/chunk-24RDMMCL.js.map +0 -1
- package/dist/chunk-55DKCJV4.js.map +0 -1
- package/dist/chunk-BGBQYQV3.js.map +0 -1
- package/dist/chunk-YSTEESEG.js.map +0 -1
- package/dist/chunk-YVX3A36I.js.map +0 -1
- /package/dist/{chunk-WGHNIAF7.js.map → chunk-QREWE3NR.js.map} +0 -0
- /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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
402
|
-
|
|
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((
|
|
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((
|
|
554
|
-
const newMutations = [...
|
|
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((
|
|
560
|
-
setPendingMutations((
|
|
561
|
-
const newMutations_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 (
|
|
683
|
+
} catch (err_2) {
|
|
609
684
|
if (!controller_0.cancelled) {
|
|
610
|
-
logger.error("[PowerSyncProvider] Attachment queue initialization failed:",
|
|
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 (
|
|
645
|
-
const errorMessage =
|
|
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:",
|
|
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 (
|
|
705
|
-
logger.warn("[PowerSyncProvider] Failed to reconnect after network restore:",
|
|
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((
|
|
737
|
-
logger.warn("[PowerSyncProvider] Failed to reconnect after auto-resume on startup:",
|
|
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
|
|
836
|
+
const clearCompletedHistory = useCallback(() => {
|
|
758
837
|
const tracker_4 = statusTrackerRef.current;
|
|
759
838
|
if (!tracker_4) {
|
|
760
|
-
logger.warn("[PowerSyncProvider] Cannot clear
|
|
839
|
+
logger.warn("[PowerSyncProvider] Cannot clear completed history - tracker not initialized");
|
|
761
840
|
return;
|
|
762
841
|
}
|
|
763
|
-
tracker_4.
|
|
764
|
-
|
|
842
|
+
tracker_4.clearCompletedHistory();
|
|
843
|
+
setCompletedTransactions(tracker_4.getCompletedTransactions());
|
|
844
|
+
setNewCompletedTransactions(tracker_4.getNewCompletedTransactions());
|
|
765
845
|
}, [logger]);
|
|
766
|
-
const
|
|
846
|
+
const clearCompletedItem = useCallback((completedId) => {
|
|
767
847
|
const tracker_5 = statusTrackerRef.current;
|
|
768
848
|
if (!tracker_5) {
|
|
769
|
-
logger.warn("[PowerSyncProvider] Cannot clear completed
|
|
849
|
+
logger.warn("[PowerSyncProvider] Cannot clear completed item - tracker not initialized");
|
|
770
850
|
return;
|
|
771
851
|
}
|
|
772
|
-
tracker_5.
|
|
852
|
+
tracker_5.clearCompletedItem(completedId);
|
|
773
853
|
setCompletedTransactions(tracker_5.getCompletedTransactions());
|
|
774
854
|
setNewCompletedTransactions(tracker_5.getNewCompletedTransactions());
|
|
775
855
|
}, [logger]);
|
|
776
|
-
const
|
|
856
|
+
const markNotificationsAsSeen = useCallback(() => {
|
|
777
857
|
const tracker_6 = statusTrackerRef.current;
|
|
778
858
|
if (!tracker_6) {
|
|
779
|
-
logger.warn("[PowerSyncProvider] Cannot
|
|
859
|
+
logger.warn("[PowerSyncProvider] Cannot mark notifications as seen - tracker not initialized");
|
|
780
860
|
return;
|
|
781
861
|
}
|
|
782
|
-
tracker_6.
|
|
783
|
-
setCompletedTransactions(tracker_6.getCompletedTransactions());
|
|
862
|
+
tracker_6.markNotificationsAsSeen();
|
|
784
863
|
setNewCompletedTransactions(tracker_6.getNewCompletedTransactions());
|
|
785
864
|
}, [logger]);
|
|
786
|
-
const
|
|
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
|
|
871
|
+
await tracker_7.setIsAutoOffline(false);
|
|
802
872
|
setIsAutoOffline(false);
|
|
803
|
-
await
|
|
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
|
|
811
|
-
if (!
|
|
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
|
-
|
|
885
|
+
tracker_8.setForceNextUpload(force);
|
|
816
886
|
}, [logger]);
|
|
817
887
|
const setAutoOfflineMode = useCallback(async (mode_0, isAuto) => {
|
|
818
|
-
const
|
|
819
|
-
if (!
|
|
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
|
|
893
|
+
await tracker_9.setIsAutoOffline(isAuto);
|
|
824
894
|
setIsAutoOffline(isAuto);
|
|
825
|
-
await
|
|
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
|
|
857
|
-
|
|
858
|
-
|
|
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 (
|
|
862
|
-
|
|
932
|
+
if (uploadRetryTimeoutRef.current) {
|
|
933
|
+
clearTimeout(uploadRetryTimeoutRef.current);
|
|
934
|
+
uploadRetryTimeoutRef.current = null;
|
|
863
935
|
}
|
|
864
|
-
|
|
865
|
-
|
|
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
|
-
|
|
868
|
-
|
|
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,
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
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
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
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
|
-
|
|
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
|
|
900
|
-
if (!
|
|
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(
|
|
910
|
-
retryCount:
|
|
911
|
-
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 (
|
|
923
|
-
logger.error("[PowerSyncProvider] Retry failed, re-recording failure:",
|
|
924
|
-
tracker_11.recordTransactionFailure(
|
|
925
|
-
retryCount:
|
|
926
|
-
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((
|
|
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
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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,
|
|
1101
|
+
}), [pendingMutations, discardPendingMutation, addPendingMutation, removePendingMutation]);
|
|
1001
1102
|
const failedTransactionsValue = useMemo(() => ({
|
|
1002
1103
|
failedTransactions,
|
|
1003
1104
|
hasUploadErrors: failedTransactions.length > 0,
|
|
1004
|
-
permanentErrorCount: failedTransactions.filter((
|
|
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,
|
|
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
|
-
|
|
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(
|
|
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 ($[
|
|
1364
|
-
|
|
1365
|
-
|
|
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
|
-
|
|
1469
|
+
t13 = (id) => {
|
|
1386
1470
|
if (removePendingMutationRef.current) {
|
|
1387
1471
|
removePendingMutationRef.current(id);
|
|
1388
1472
|
}
|
|
1389
1473
|
};
|
|
1390
|
-
$[
|
|
1391
|
-
$[
|
|
1474
|
+
$[9] = t11;
|
|
1475
|
+
$[10] = t12;
|
|
1476
|
+
$[11] = t13;
|
|
1392
1477
|
} else {
|
|
1393
|
-
|
|
1394
|
-
|
|
1478
|
+
t11 = $[9];
|
|
1479
|
+
t12 = $[10];
|
|
1480
|
+
t13 = $[11];
|
|
1395
1481
|
}
|
|
1396
|
-
let
|
|
1397
|
-
if ($[
|
|
1398
|
-
|
|
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
|
-
|
|
1407
|
-
|
|
1408
|
-
isAutoRetryPaused: false,
|
|
1409
|
-
addPendingMutation: t14,
|
|
1410
|
-
removePendingMutation: t15
|
|
1492
|
+
addPendingMutation: t12,
|
|
1493
|
+
removePendingMutation: t13
|
|
1411
1494
|
};
|
|
1412
|
-
$[
|
|
1413
|
-
$[
|
|
1414
|
-
$[
|
|
1415
|
-
$[
|
|
1416
|
-
$[
|
|
1417
|
-
$[
|
|
1418
|
-
$[
|
|
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
|
-
|
|
1503
|
+
t14 = $[18];
|
|
1423
1504
|
}
|
|
1424
|
-
const syncControl =
|
|
1425
|
-
let
|
|
1505
|
+
const syncControl = t14;
|
|
1506
|
+
let t15;
|
|
1426
1507
|
bb0: {
|
|
1427
1508
|
if (!attachments) {
|
|
1428
|
-
|
|
1509
|
+
t15 = void 0;
|
|
1429
1510
|
break bb0;
|
|
1430
1511
|
}
|
|
1431
|
-
let
|
|
1432
|
-
if ($[
|
|
1433
|
-
|
|
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
|
-
$[
|
|
1438
|
-
$[
|
|
1439
|
-
$[
|
|
1440
|
-
$[
|
|
1518
|
+
$[19] = attachments.bucket;
|
|
1519
|
+
$[20] = storageBackend;
|
|
1520
|
+
$[21] = supabaseClient;
|
|
1521
|
+
$[22] = t162;
|
|
1441
1522
|
} else {
|
|
1442
|
-
|
|
1523
|
+
t162 = $[22];
|
|
1443
1524
|
}
|
|
1444
|
-
const nativeUploadHandler =
|
|
1445
|
-
const
|
|
1446
|
-
let
|
|
1447
|
-
if ($[
|
|
1448
|
-
|
|
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:
|
|
1538
|
+
remoteStorage: t172,
|
|
1458
1539
|
uploadHandler: nativeUploadHandler
|
|
1459
1540
|
};
|
|
1460
|
-
$[
|
|
1461
|
-
$[
|
|
1462
|
-
$[
|
|
1463
|
-
$[
|
|
1464
|
-
$[
|
|
1465
|
-
$[
|
|
1466
|
-
$[
|
|
1467
|
-
$[
|
|
1468
|
-
$[
|
|
1469
|
-
$[
|
|
1470
|
-
$[
|
|
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
|
-
|
|
1553
|
+
t182 = $[33];
|
|
1473
1554
|
}
|
|
1474
|
-
|
|
1555
|
+
t15 = t182;
|
|
1475
1556
|
}
|
|
1476
|
-
const attachmentConfig =
|
|
1477
|
-
const
|
|
1478
|
-
const
|
|
1479
|
-
const
|
|
1480
|
-
const
|
|
1481
|
-
let
|
|
1482
|
-
if ($[
|
|
1483
|
-
|
|
1484
|
-
autoConnect:
|
|
1485
|
-
enableHealthMonitoring:
|
|
1486
|
-
enableMetrics:
|
|
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
|
-
$[
|
|
1489
|
-
$[
|
|
1490
|
-
$[
|
|
1491
|
-
$[
|
|
1569
|
+
$[34] = t17;
|
|
1570
|
+
$[35] = t18;
|
|
1571
|
+
$[36] = t19;
|
|
1572
|
+
$[37] = t20;
|
|
1492
1573
|
} else {
|
|
1493
|
-
|
|
1574
|
+
t20 = $[37];
|
|
1494
1575
|
}
|
|
1495
|
-
let
|
|
1496
|
-
if ($[
|
|
1497
|
-
|
|
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:
|
|
1581
|
+
powerSyncUrl: t16,
|
|
1501
1582
|
supabaseClient,
|
|
1502
1583
|
queryClient,
|
|
1503
1584
|
dbFilename,
|
|
1504
1585
|
connector: connectorConfig,
|
|
1505
1586
|
attachments: attachmentConfig,
|
|
1506
|
-
sync:
|
|
1587
|
+
sync: t20
|
|
1507
1588
|
};
|
|
1508
|
-
$[
|
|
1509
|
-
$[
|
|
1510
|
-
$[
|
|
1511
|
-
$[
|
|
1512
|
-
$[
|
|
1513
|
-
$[
|
|
1514
|
-
$[
|
|
1515
|
-
$[
|
|
1516
|
-
$[
|
|
1517
|
-
$[
|
|
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
|
-
|
|
1600
|
+
t21 = $[47];
|
|
1520
1601
|
}
|
|
1521
|
-
const powerSyncConfig =
|
|
1522
|
-
let
|
|
1523
|
-
if ($[
|
|
1524
|
-
|
|
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
|
-
$[
|
|
1533
|
-
$[
|
|
1534
|
-
$[
|
|
1613
|
+
$[48] = onError;
|
|
1614
|
+
$[49] = platform.logger;
|
|
1615
|
+
$[50] = t22;
|
|
1535
1616
|
} else {
|
|
1536
|
-
|
|
1617
|
+
t22 = $[50];
|
|
1537
1618
|
}
|
|
1538
|
-
const handlePowerSyncError =
|
|
1539
|
-
let
|
|
1540
|
-
if ($[
|
|
1541
|
-
|
|
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
|
-
$[
|
|
1547
|
-
$[
|
|
1627
|
+
$[51] = platform.logger;
|
|
1628
|
+
$[52] = t23;
|
|
1548
1629
|
} else {
|
|
1549
|
-
|
|
1630
|
+
t23 = $[52];
|
|
1550
1631
|
}
|
|
1551
|
-
const handleRetry =
|
|
1552
|
-
let
|
|
1553
|
-
if ($[
|
|
1554
|
-
|
|
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
|
-
$[
|
|
1561
|
-
$[
|
|
1562
|
-
$[
|
|
1563
|
-
$[
|
|
1641
|
+
$[53] = backgroundSync?.callbacks;
|
|
1642
|
+
$[54] = onBackgroundSyncSystemReadyProp;
|
|
1643
|
+
$[55] = platform.logger;
|
|
1644
|
+
$[56] = t24;
|
|
1564
1645
|
} else {
|
|
1565
|
-
|
|
1646
|
+
t24 = $[56];
|
|
1566
1647
|
}
|
|
1567
1648
|
backgroundSync?.callbacks;
|
|
1568
|
-
const handleBackgroundSyncSystemReady =
|
|
1569
|
-
let
|
|
1570
|
-
if ($[
|
|
1571
|
-
|
|
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
|
-
$[
|
|
1579
|
-
$[
|
|
1580
|
-
$[
|
|
1659
|
+
$[57] = renderError;
|
|
1660
|
+
$[58] = renderInitError;
|
|
1661
|
+
$[59] = t25;
|
|
1581
1662
|
} else {
|
|
1582
|
-
|
|
1663
|
+
t25 = $[59];
|
|
1583
1664
|
}
|
|
1584
|
-
const errorFallback =
|
|
1585
|
-
let
|
|
1586
|
-
if ($[
|
|
1587
|
-
|
|
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
|
-
$[
|
|
1594
|
-
$[
|
|
1595
|
-
$[
|
|
1674
|
+
$[60] = powerSyncSyncStatus;
|
|
1675
|
+
$[61] = powerSyncUrl;
|
|
1676
|
+
$[62] = t26;
|
|
1596
1677
|
} else {
|
|
1597
|
-
|
|
1678
|
+
t26 = $[62];
|
|
1598
1679
|
}
|
|
1599
|
-
const effectiveSyncStatus =
|
|
1600
|
-
let
|
|
1601
|
-
let
|
|
1602
|
-
if ($[
|
|
1603
|
-
|
|
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
|
-
|
|
1609
|
-
$[
|
|
1610
|
-
$[
|
|
1611
|
-
$[
|
|
1612
|
-
$[
|
|
1689
|
+
t28 = [effectiveSyncStatus, onSyncStatusChange];
|
|
1690
|
+
$[63] = effectiveSyncStatus;
|
|
1691
|
+
$[64] = onSyncStatusChange;
|
|
1692
|
+
$[65] = t27;
|
|
1693
|
+
$[66] = t28;
|
|
1613
1694
|
} else {
|
|
1614
|
-
|
|
1615
|
-
|
|
1695
|
+
t27 = $[65];
|
|
1696
|
+
t28 = $[66];
|
|
1616
1697
|
}
|
|
1617
|
-
useEffect3(
|
|
1618
|
-
let
|
|
1619
|
-
let
|
|
1620
|
-
if ($[
|
|
1621
|
-
|
|
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,66 +1727,58 @@ function OfflineDataProvider(t0) {
|
|
|
1646
1727
|
removePendingMutationRef.current = remove;
|
|
1647
1728
|
}, children }) }, retryKey) });
|
|
1648
1729
|
};
|
|
1649
|
-
let
|
|
1650
|
-
if ($[
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
$[
|
|
1658
|
-
$[
|
|
1659
|
-
$[99] = onError;
|
|
1660
|
-
$[100] = platform.logger;
|
|
1661
|
-
$[101] = powerSyncInstance;
|
|
1662
|
-
$[102] = queryClient;
|
|
1663
|
-
$[103] = supabaseClient;
|
|
1664
|
-
$[104] = syncControl;
|
|
1665
|
-
$[105] = 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;
|
|
1666
1740
|
} else {
|
|
1667
|
-
|
|
1741
|
+
t31 = $[97];
|
|
1668
1742
|
}
|
|
1669
|
-
const renderWithDataLayer =
|
|
1743
|
+
const renderWithDataLayer = t31;
|
|
1670
1744
|
if (dataLayer && !dataLayer.skip) {
|
|
1671
|
-
|
|
1745
|
+
t30 = renderWithDataLayer(renderContent());
|
|
1672
1746
|
break bb1;
|
|
1673
1747
|
}
|
|
1674
|
-
|
|
1748
|
+
t29 = renderContent();
|
|
1675
1749
|
}
|
|
1676
|
-
$[
|
|
1677
|
-
$[
|
|
1678
|
-
$[
|
|
1679
|
-
$[
|
|
1680
|
-
$[
|
|
1681
|
-
$[
|
|
1682
|
-
$[
|
|
1683
|
-
$[
|
|
1684
|
-
$[
|
|
1685
|
-
$[
|
|
1686
|
-
$[
|
|
1687
|
-
$[
|
|
1688
|
-
$[
|
|
1689
|
-
$[
|
|
1690
|
-
$[
|
|
1691
|
-
$[
|
|
1692
|
-
$[
|
|
1693
|
-
$[
|
|
1694
|
-
$[
|
|
1695
|
-
$[
|
|
1696
|
-
$[
|
|
1697
|
-
$[
|
|
1698
|
-
$[
|
|
1699
|
-
$[
|
|
1700
|
-
$[96] = 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;
|
|
1701
1774
|
} else {
|
|
1702
|
-
|
|
1703
|
-
|
|
1775
|
+
t29 = $[89];
|
|
1776
|
+
t30 = $[90];
|
|
1704
1777
|
}
|
|
1705
|
-
if (
|
|
1706
|
-
return
|
|
1778
|
+
if (t30 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel")) {
|
|
1779
|
+
return t30;
|
|
1707
1780
|
}
|
|
1708
|
-
return
|
|
1781
|
+
return t29;
|
|
1709
1782
|
}
|
|
1710
1783
|
function _temp(prev) {
|
|
1711
1784
|
return prev + 1;
|
|
@@ -1713,8 +1786,10 @@ function _temp(prev) {
|
|
|
1713
1786
|
|
|
1714
1787
|
export {
|
|
1715
1788
|
ConflictBus,
|
|
1789
|
+
UPLOAD_MAX_RETRIES,
|
|
1790
|
+
UPLOAD_BACKOFF_DELAYS,
|
|
1716
1791
|
PowerSyncProvider,
|
|
1717
1792
|
ProviderBridge,
|
|
1718
1793
|
OfflineDataProvider
|
|
1719
1794
|
};
|
|
1720
|
-
//# sourceMappingURL=chunk-
|
|
1795
|
+
//# sourceMappingURL=chunk-JCGOZVWL.js.map
|