@pol-studios/powersync 1.0.30 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CacheSettingsManager-uz-kbnRH.d.ts → CacheSettingsManager-0H_7thHW.d.ts} +21 -3
- package/dist/attachments/index.d.ts +30 -30
- package/dist/attachments/index.js +13 -4
- package/dist/{background-sync-CVR3PkFi.d.ts → background-sync-BujnI3IR.d.ts} +1 -1
- package/dist/{chunk-RE5HWLCB.js → chunk-2RDWLXJW.js} +322 -103
- package/dist/chunk-2RDWLXJW.js.map +1 -0
- package/dist/{chunk-P4HZA6ZT.js → chunk-4665ZSE5.js} +2 -2
- package/dist/chunk-4665ZSE5.js.map +1 -0
- package/dist/{chunk-XOY2CJ67.js → chunk-4F5B5CZ7.js} +3 -3
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/{chunk-BC2SRII2.js → chunk-65A3SYJZ.js} +14 -1
- package/dist/chunk-65A3SYJZ.js.map +1 -0
- package/dist/chunk-6SZ64KCZ.js +755 -0
- package/dist/chunk-6SZ64KCZ.js.map +1 -0
- package/dist/{chunk-C2ACBYBZ.js → chunk-74TBHWJ4.js} +10 -96
- package/dist/{chunk-C2ACBYBZ.js.map → chunk-74TBHWJ4.js.map} +1 -1
- package/dist/chunk-ANXWYQEJ.js +1 -0
- package/dist/chunk-ANXWYQEJ.js.map +1 -0
- package/dist/{chunk-CAB26E6F.js → chunk-C4J4MLER.js} +29 -24
- package/dist/chunk-C4J4MLER.js.map +1 -0
- package/dist/{chunk-C5ODS3XH.js → chunk-EOW7JK7Q.js} +9 -16
- package/dist/chunk-EOW7JK7Q.js.map +1 -0
- package/dist/chunk-HRAVPIAZ.js +220 -0
- package/dist/chunk-HRAVPIAZ.js.map +1 -0
- package/dist/{chunk-XAEII4ZX.js → chunk-NUGQOTEM.js} +32 -4
- package/dist/chunk-NUGQOTEM.js.map +1 -0
- package/dist/chunk-OGUFUZSY.js +5415 -0
- package/dist/chunk-OGUFUZSY.js.map +1 -0
- package/dist/{chunk-JCGOZVWL.js → chunk-P4D6BQ4X.js} +115 -576
- package/dist/chunk-P4D6BQ4X.js.map +1 -0
- package/dist/{chunk-CACKC6XG.js → chunk-PGEDE6IM.js} +136 -89
- package/dist/chunk-PGEDE6IM.js.map +1 -0
- package/dist/{chunk-A4IBBWGO.js → chunk-RALHHPTU.js} +1 -1
- package/dist/chunk-RIDSPLE5.js +42 -0
- package/dist/chunk-RIDSPLE5.js.map +1 -0
- package/dist/{chunk-Z6VOBGTU.js → chunk-UOMHWUHV.js} +2 -12
- package/dist/chunk-UOMHWUHV.js.map +1 -0
- package/dist/{chunk-QREWE3NR.js → chunk-YONQYTVH.js} +2 -2
- package/dist/chunk-ZAN22NGL.js +13 -0
- package/dist/chunk-ZAN22NGL.js.map +1 -0
- package/dist/config/index.d.ts +200 -0
- package/dist/config/index.js +23 -0
- package/dist/config/index.js.map +1 -0
- package/dist/connector/index.d.ts +23 -5
- package/dist/connector/index.js +4 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -0
- package/dist/error/index.js +1 -0
- package/dist/generator/index.js +2 -0
- package/dist/generator/index.js.map +1 -1
- package/dist/index.d.ts +19 -16
- package/dist/index.js +68 -36
- package/dist/index.native.d.ts +18 -14
- package/dist/index.native.js +73 -34
- package/dist/index.web.d.ts +17 -14
- package/dist/index.web.js +68 -36
- package/dist/maintenance/index.d.ts +2 -2
- package/dist/maintenance/index.js +3 -2
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +2 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.d.ts +1 -1
- package/dist/platform/index.native.js +1 -0
- package/dist/platform/index.web.d.ts +1 -1
- package/dist/platform/index.web.js +1 -0
- package/dist/pol-attachment-queue-DqBvLAEY.d.ts +255 -0
- package/dist/provider/index.d.ts +149 -114
- package/dist/provider/index.js +9 -14
- package/dist/provider/index.native.d.ts +108 -0
- package/dist/provider/index.native.js +121 -0
- package/dist/provider/index.native.js.map +1 -0
- package/dist/provider/index.web.d.ts +16 -0
- package/dist/provider/index.web.js +112 -0
- package/dist/provider/index.web.js.map +1 -0
- package/dist/react/index.d.ts +16 -65
- package/dist/react/index.js +2 -9
- package/dist/storage/index.d.ts +5 -4
- package/dist/storage/index.js +12 -9
- package/dist/storage/index.native.d.ts +5 -4
- package/dist/storage/index.native.js +8 -5
- package/dist/storage/index.web.d.ts +5 -4
- package/dist/storage/index.web.js +11 -8
- package/dist/storage/upload/index.d.ts +4 -3
- package/dist/storage/upload/index.js +4 -2
- package/dist/storage/upload/index.native.d.ts +4 -3
- package/dist/storage/upload/index.native.js +4 -2
- package/dist/storage/upload/index.web.d.ts +2 -1
- package/dist/storage/upload/index.web.js +4 -2
- package/dist/{supabase-connector-C4YpH_l3.d.ts → supabase-connector-HMxBA9Kg.d.ts} +2 -2
- package/dist/sync/index.d.ts +155 -20
- package/dist/sync/index.js +13 -3
- package/dist/{types-CyvBaAl8.d.ts → types-6QHGELuY.d.ts} +4 -1
- package/dist/{types-Dv1uf0LZ.d.ts → types-B9MptP7E.d.ts} +7 -10
- package/dist/types-BhAEsJj-.d.ts +330 -0
- package/dist/{types-D0WcHrq6.d.ts → types-CGMibJKD.d.ts} +8 -0
- package/dist/{types-CpM2_LhU.d.ts → types-DqJnP50o.d.ts} +6 -1
- package/dist/{pol-attachment-queue-BE2HU3Us.d.ts → types-JCEhw2Lf.d.ts} +139 -346
- package/package.json +18 -4
- package/dist/chunk-654ERHA7.js +0 -1
- package/dist/chunk-BC2SRII2.js.map +0 -1
- package/dist/chunk-C5ODS3XH.js.map +0 -1
- package/dist/chunk-CAB26E6F.js.map +0 -1
- package/dist/chunk-CACKC6XG.js.map +0 -1
- package/dist/chunk-FNYQFILT.js +0 -44
- package/dist/chunk-FNYQFILT.js.map +0 -1
- package/dist/chunk-JCGOZVWL.js.map +0 -1
- package/dist/chunk-P4HZA6ZT.js.map +0 -1
- package/dist/chunk-RBPWEOIV.js +0 -358
- package/dist/chunk-RBPWEOIV.js.map +0 -1
- package/dist/chunk-RE5HWLCB.js.map +0 -1
- package/dist/chunk-XAEII4ZX.js.map +0 -1
- package/dist/chunk-Z6VOBGTU.js.map +0 -1
- /package/dist/{chunk-XOY2CJ67.js.map → chunk-4F5B5CZ7.js.map} +0 -0
- /package/dist/{chunk-654ERHA7.js.map → chunk-5WRI5ZAA.js.map} +0 -0
- /package/dist/{chunk-A4IBBWGO.js.map → chunk-RALHHPTU.js.map} +0 -0
- /package/dist/{chunk-QREWE3NR.js.map → chunk-YONQYTVH.js.map} +0 -0
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
createPolAttachmentQueue,
|
|
3
|
+
getCustomUrlResolver,
|
|
4
|
+
isCustomSource,
|
|
5
|
+
isSignedUrlSource,
|
|
6
|
+
resolveBucketFromConfig
|
|
7
|
+
} from "./chunk-PGEDE6IM.js";
|
|
7
8
|
import {
|
|
9
|
+
DEFAULT_CONNECTION_HEALTH,
|
|
10
|
+
DEFAULT_SYNC_METRICS,
|
|
11
|
+
DEFAULT_SYNC_STATUS,
|
|
8
12
|
HealthMonitor,
|
|
9
13
|
MetricsCollector,
|
|
10
14
|
SyncStatusTracker
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
DEFAULT_CONNECTION_HEALTH,
|
|
14
|
-
DEFAULT_SYNC_METRICS,
|
|
15
|
-
DEFAULT_SYNC_STATUS
|
|
16
|
-
} from "./chunk-FNYQFILT.js";
|
|
15
|
+
} from "./chunk-2RDWLXJW.js";
|
|
17
16
|
import {
|
|
18
17
|
AttachmentQueueContext,
|
|
19
18
|
CompletedTransactionsContext,
|
|
@@ -30,19 +29,13 @@ import {
|
|
|
30
29
|
usePendingMutationsContext,
|
|
31
30
|
usePowerSync,
|
|
32
31
|
useSyncStatus
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import {
|
|
35
|
-
createSupabaseUploadHandler
|
|
36
|
-
} from "./chunk-CAB26E6F.js";
|
|
32
|
+
} from "./chunk-74TBHWJ4.js";
|
|
37
33
|
import {
|
|
38
34
|
SupabaseStorageAdapter
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import {
|
|
41
|
-
createNativePlatformAdapter
|
|
42
|
-
} from "./chunk-WN5ZJ3E2.js";
|
|
35
|
+
} from "./chunk-NUGQOTEM.js";
|
|
43
36
|
import {
|
|
44
37
|
SupabaseConnector
|
|
45
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-65A3SYJZ.js";
|
|
46
39
|
import {
|
|
47
40
|
createSyncError,
|
|
48
41
|
extractEntityIds,
|
|
@@ -138,6 +131,7 @@ function PowerSyncProvider({
|
|
|
138
131
|
schema,
|
|
139
132
|
powerSyncUrl,
|
|
140
133
|
supabaseClient,
|
|
134
|
+
queryClient,
|
|
141
135
|
dbFilename = "powersync.db",
|
|
142
136
|
connector: connectorConfig,
|
|
143
137
|
attachments: attachmentConfig,
|
|
@@ -203,6 +197,8 @@ function PowerSyncProvider({
|
|
|
203
197
|
const syncModeRef = useRef("push-pull");
|
|
204
198
|
const removePendingMutationRef = useRef(() => {
|
|
205
199
|
});
|
|
200
|
+
const removePendingMutationsRef = useRef(() => {
|
|
201
|
+
});
|
|
206
202
|
const uploadRetryTimeoutRef = useRef(null);
|
|
207
203
|
const onSyncStatusChangeRef = useRef(onSyncStatusChange);
|
|
208
204
|
const onReadyRef = useRef(onReady);
|
|
@@ -325,6 +321,13 @@ function PowerSyncProvider({
|
|
|
325
321
|
setIsReady(true);
|
|
326
322
|
setIsInitializing(false);
|
|
327
323
|
healthMonitorRef.current?.setDatabase(database);
|
|
324
|
+
if (statusTrackerRef.current) {
|
|
325
|
+
statusTrackerRef.current.setDatabaseAndInit(database).then(() => {
|
|
326
|
+
setCompletedTransactions(statusTrackerRef.current?.getCompletedTransactions() ?? []);
|
|
327
|
+
setNewCompletedTransactions(statusTrackerRef.current?.getNewCompletedTransactions() ?? []);
|
|
328
|
+
setFailedTransactions(statusTrackerRef.current?.getFailedTransactions() ?? []);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
328
331
|
if (mergedSyncConfig.enableHealthMonitoring) {
|
|
329
332
|
healthMonitorRef.current?.start();
|
|
330
333
|
}
|
|
@@ -399,6 +402,7 @@ function PowerSyncProvider({
|
|
|
399
402
|
schemaRouter: connectorConfig?.schemaRouter,
|
|
400
403
|
crudHandler: connectorConfig?.crudHandler,
|
|
401
404
|
retryConfig: connectorConfig?.retryConfig,
|
|
405
|
+
uploadErrorMiddleware: connectorConfig?.uploadErrorMiddleware,
|
|
402
406
|
logger,
|
|
403
407
|
// Conflict detection - enabled by default
|
|
404
408
|
conflictDetection: {
|
|
@@ -492,6 +496,7 @@ function PowerSyncProvider({
|
|
|
492
496
|
statusTracker_0.recordTransactionComplete(entries_1);
|
|
493
497
|
setCompletedTransactions(statusTracker_0.getCompletedTransactions());
|
|
494
498
|
setNewCompletedTransactions(statusTracker_0.getNewCompletedTransactions());
|
|
499
|
+
removePendingMutationsRef.current(entries_1.map((e_0) => e_0.id));
|
|
495
500
|
}
|
|
496
501
|
});
|
|
497
502
|
if (abortController.signal.aborted) {
|
|
@@ -612,7 +617,7 @@ function PowerSyncProvider({
|
|
|
612
617
|
} catch {
|
|
613
618
|
return null;
|
|
614
619
|
}
|
|
615
|
-
}).filter((
|
|
620
|
+
}).filter((e_1) => e_1 !== null);
|
|
616
621
|
if (!dbClosedRef.current) {
|
|
617
622
|
statusTrackerRef.current?.updatePendingMutations(mutations);
|
|
618
623
|
setPendingMutations(mutations);
|
|
@@ -638,9 +643,19 @@ function PowerSyncProvider({
|
|
|
638
643
|
return newMutations_0;
|
|
639
644
|
});
|
|
640
645
|
}, []);
|
|
646
|
+
const removePendingMutations = useCallback((ids) => {
|
|
647
|
+
if (ids.length === 0) return;
|
|
648
|
+
const idSet = new Set(ids);
|
|
649
|
+
setPendingMutations((prev_2) => {
|
|
650
|
+
const newMutations_1 = prev_2.filter((m_0) => !idSet.has(m_0.id));
|
|
651
|
+
statusTrackerRef.current?.updatePendingMutations(newMutations_1);
|
|
652
|
+
return newMutations_1;
|
|
653
|
+
});
|
|
654
|
+
}, []);
|
|
641
655
|
useEffect(() => {
|
|
642
656
|
removePendingMutationRef.current = removePendingMutation;
|
|
643
|
-
|
|
657
|
+
removePendingMutationsRef.current = removePendingMutations;
|
|
658
|
+
}, [removePendingMutation, removePendingMutations]);
|
|
644
659
|
useEffect(() => {
|
|
645
660
|
if (!db) return;
|
|
646
661
|
dbClosedRef.current = false;
|
|
@@ -656,19 +671,36 @@ function PowerSyncProvider({
|
|
|
656
671
|
const initAttachmentQueue = async () => {
|
|
657
672
|
try {
|
|
658
673
|
logger.info("[PowerSyncProvider] Initializing attachment queue...");
|
|
674
|
+
const bucket = resolveBucketFromConfig(attachmentConfig);
|
|
675
|
+
if (!bucket && !isCustomSource(attachmentConfig)) {
|
|
676
|
+
throw new Error("[PowerSyncProvider] Attachment config requires source.bucket or a custom source");
|
|
677
|
+
}
|
|
678
|
+
if (isCustomSource(attachmentConfig)) {
|
|
679
|
+
const resolver = getCustomUrlResolver(attachmentConfig);
|
|
680
|
+
if (!resolver) {
|
|
681
|
+
throw new Error('[PowerSyncProvider] Custom attachment source requires a getUrl function. Provide: source: { type: "custom", getUrl: (path) => "https://..." }');
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
const useSignedUrls = isSignedUrlSource(attachmentConfig);
|
|
685
|
+
const customUrlResolver = getCustomUrlResolver(attachmentConfig);
|
|
686
|
+
const sourceCompression = attachmentConfig.source?.type === "supabase-bucket" ? attachmentConfig.source.compression : void 0;
|
|
659
687
|
const remoteStorage = new SupabaseStorageAdapter({
|
|
660
688
|
client: supabaseClient,
|
|
661
|
-
defaultBucket:
|
|
689
|
+
defaultBucket: bucket ?? "",
|
|
662
690
|
logger,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
691
|
+
useSignedUrls,
|
|
692
|
+
customUrlResolver,
|
|
693
|
+
imageTransform: sourceCompression ? {
|
|
694
|
+
enabled: sourceCompression.enabled ?? true,
|
|
695
|
+
width: sourceCompression.maxWidth,
|
|
696
|
+
quality: sourceCompression.quality ? Math.round(sourceCompression.quality * 100) : void 0
|
|
667
697
|
} : void 0
|
|
668
698
|
}, platform.fileSystem);
|
|
669
699
|
const queueOptions = {
|
|
670
700
|
...attachmentConfig,
|
|
671
|
-
remoteStorage
|
|
701
|
+
remoteStorage,
|
|
702
|
+
supabaseClient
|
|
703
|
+
// Pass supabase client for watchPaths callback
|
|
672
704
|
};
|
|
673
705
|
const queue = createPolAttachmentQueue(db, platform, queueOptions);
|
|
674
706
|
await queue.init();
|
|
@@ -970,7 +1002,7 @@ function PowerSyncProvider({
|
|
|
970
1002
|
if (tracker_10) {
|
|
971
1003
|
const failures = tracker_10.getFailedTransactions();
|
|
972
1004
|
for (const failure of failures) {
|
|
973
|
-
const hasEntry = failure.entries.some((
|
|
1005
|
+
const hasEntry = failure.entries.some((e_2) => e_2.clientId === entryId);
|
|
974
1006
|
if (hasEntry) {
|
|
975
1007
|
tracker_10.clearFailure(failure.id);
|
|
976
1008
|
break;
|
|
@@ -1028,6 +1060,55 @@ function PowerSyncProvider({
|
|
|
1028
1060
|
setFailedTransactions(tracker_11.getFailedTransactions());
|
|
1029
1061
|
}
|
|
1030
1062
|
}, [db, connector, logger]);
|
|
1063
|
+
const resetSync = useCallback(async (options) => {
|
|
1064
|
+
const {
|
|
1065
|
+
clearAttachments = true,
|
|
1066
|
+
clearQueryCache = true,
|
|
1067
|
+
timeout = 3e4
|
|
1068
|
+
} = options ?? {};
|
|
1069
|
+
logger.info("[PowerSyncProvider] Starting sync reset...", {
|
|
1070
|
+
clearAttachments,
|
|
1071
|
+
clearQueryCache,
|
|
1072
|
+
timeout
|
|
1073
|
+
});
|
|
1074
|
+
if (!db) {
|
|
1075
|
+
logger.warn("[PowerSyncProvider] Cannot reset sync: database not initialized");
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
try {
|
|
1079
|
+
logger.info("[PowerSyncProvider] Disconnecting and clearing sync data...");
|
|
1080
|
+
await db.disconnectAndClear({
|
|
1081
|
+
clearLocal: false
|
|
1082
|
+
});
|
|
1083
|
+
logger.info("[PowerSyncProvider] Sync data cleared");
|
|
1084
|
+
if (clearQueryCache && queryClient) {
|
|
1085
|
+
try {
|
|
1086
|
+
logger.info("[PowerSyncProvider] Clearing React Query cache...");
|
|
1087
|
+
queryClient.clear();
|
|
1088
|
+
logger.info("[PowerSyncProvider] React Query cache cleared");
|
|
1089
|
+
} catch (cacheError) {
|
|
1090
|
+
logger.error("[PowerSyncProvider] Failed to clear React Query cache:", cacheError);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (clearAttachments && attachmentQueue) {
|
|
1094
|
+
try {
|
|
1095
|
+
logger.info("[PowerSyncProvider] Clearing attachment cache...");
|
|
1096
|
+
const clearPromise = attachmentQueue.clearCache();
|
|
1097
|
+
const timeoutPromise_0 = new Promise((_, reject) => {
|
|
1098
|
+
setTimeout(() => reject(new Error("Attachment cache clear timed out")), timeout);
|
|
1099
|
+
});
|
|
1100
|
+
await Promise.race([clearPromise, timeoutPromise_0]);
|
|
1101
|
+
logger.info("[PowerSyncProvider] Attachment cache cleared");
|
|
1102
|
+
} catch (attachmentError) {
|
|
1103
|
+
logger.error("[PowerSyncProvider] Failed to clear attachment cache:", attachmentError);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
logger.info("[PowerSyncProvider] Sync reset completed successfully");
|
|
1107
|
+
} catch (err_9) {
|
|
1108
|
+
logger.error("[PowerSyncProvider] Sync reset failed:", err_9);
|
|
1109
|
+
throw err_9;
|
|
1110
|
+
}
|
|
1111
|
+
}, [db, queryClient, attachmentQueue, logger]);
|
|
1031
1112
|
const powerSyncContextValue = useMemo(() => ({
|
|
1032
1113
|
db,
|
|
1033
1114
|
connector,
|
|
@@ -1038,8 +1119,9 @@ function PowerSyncProvider({
|
|
|
1038
1119
|
error,
|
|
1039
1120
|
schema,
|
|
1040
1121
|
platform,
|
|
1041
|
-
conflictBus
|
|
1042
|
-
|
|
1122
|
+
conflictBus,
|
|
1123
|
+
resetSync
|
|
1124
|
+
}), [db, connector, attachmentQueue, isReady, isInitializing, attachmentQueueReady, error, schema, platform, conflictBus, resetSync]);
|
|
1043
1125
|
const syncStatusContextValue = useMemo(() => ({
|
|
1044
1126
|
status: syncStatus,
|
|
1045
1127
|
pendingMutations,
|
|
@@ -1131,12 +1213,6 @@ function PowerSyncProvider({
|
|
|
1131
1213
|
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 }) }) }) }) }) }) }) }) }) }) });
|
|
1132
1214
|
}
|
|
1133
1215
|
|
|
1134
|
-
// src/provider/OfflineDataProvider.tsx
|
|
1135
|
-
import { c as _c } from "react/compiler-runtime";
|
|
1136
|
-
import { useEffect as useEffect3, useRef as useRef3, useState as useState2 } from "react";
|
|
1137
|
-
import { View, Text, StyleSheet, Pressable } from "react-native";
|
|
1138
|
-
import { DataLayerProvider } from "@pol-studios/db";
|
|
1139
|
-
|
|
1140
1216
|
// src/provider/ProviderBridge.tsx
|
|
1141
1217
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
1142
1218
|
import { PowerSyncContext as PowerSyncContext2 } from "@powersync/react-native";
|
|
@@ -1248,548 +1324,11 @@ function ProviderBridge({
|
|
|
1248
1324
|
return /* @__PURE__ */ jsx2(Fragment, { children: content });
|
|
1249
1325
|
}
|
|
1250
1326
|
|
|
1251
|
-
// src/provider/OfflineDataProvider.tsx
|
|
1252
|
-
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
1253
|
-
var defaultLogger = {
|
|
1254
|
-
debug: (...args) => console.debug("[OfflineData]", ...args),
|
|
1255
|
-
info: (...args) => console.info("[OfflineData]", ...args),
|
|
1256
|
-
warn: (...args) => console.warn("[OfflineData]", ...args),
|
|
1257
|
-
error: (...args) => console.error("[OfflineData]", ...args)
|
|
1258
|
-
};
|
|
1259
|
-
var errorStyles = StyleSheet.create({
|
|
1260
|
-
container: {
|
|
1261
|
-
flex: 1,
|
|
1262
|
-
justifyContent: "center",
|
|
1263
|
-
alignItems: "center",
|
|
1264
|
-
backgroundColor: "#f5f5f5",
|
|
1265
|
-
padding: 20
|
|
1266
|
-
},
|
|
1267
|
-
content: {
|
|
1268
|
-
backgroundColor: "white",
|
|
1269
|
-
borderRadius: 12,
|
|
1270
|
-
padding: 24,
|
|
1271
|
-
maxWidth: 400,
|
|
1272
|
-
width: "100%",
|
|
1273
|
-
shadowColor: "#000",
|
|
1274
|
-
shadowOffset: {
|
|
1275
|
-
width: 0,
|
|
1276
|
-
height: 2
|
|
1277
|
-
},
|
|
1278
|
-
shadowOpacity: 0.1,
|
|
1279
|
-
shadowRadius: 8,
|
|
1280
|
-
elevation: 4
|
|
1281
|
-
},
|
|
1282
|
-
title: {
|
|
1283
|
-
fontSize: 20,
|
|
1284
|
-
fontWeight: "600",
|
|
1285
|
-
color: "#1a1a1a",
|
|
1286
|
-
marginBottom: 12,
|
|
1287
|
-
textAlign: "center"
|
|
1288
|
-
},
|
|
1289
|
-
message: {
|
|
1290
|
-
fontSize: 14,
|
|
1291
|
-
color: "#666",
|
|
1292
|
-
marginBottom: 16,
|
|
1293
|
-
textAlign: "center",
|
|
1294
|
-
lineHeight: 20
|
|
1295
|
-
},
|
|
1296
|
-
errorDetail: {
|
|
1297
|
-
fontSize: 12,
|
|
1298
|
-
color: "#999",
|
|
1299
|
-
marginBottom: 20,
|
|
1300
|
-
textAlign: "center",
|
|
1301
|
-
fontFamily: "monospace"
|
|
1302
|
-
},
|
|
1303
|
-
retryButton: {
|
|
1304
|
-
backgroundColor: "#007AFF",
|
|
1305
|
-
borderRadius: 8,
|
|
1306
|
-
paddingVertical: 12,
|
|
1307
|
-
paddingHorizontal: 24,
|
|
1308
|
-
alignItems: "center"
|
|
1309
|
-
},
|
|
1310
|
-
retryButtonText: {
|
|
1311
|
-
color: "white",
|
|
1312
|
-
fontSize: 16,
|
|
1313
|
-
fontWeight: "600"
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
function DefaultErrorRecoveryUI(t0) {
|
|
1317
|
-
const $ = _c(10);
|
|
1318
|
-
const {
|
|
1319
|
-
error,
|
|
1320
|
-
onRetry
|
|
1321
|
-
} = t0;
|
|
1322
|
-
let t1;
|
|
1323
|
-
let t2;
|
|
1324
|
-
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1325
|
-
t1 = /* @__PURE__ */ jsx3(Text, { style: errorStyles.title, children: "Database Error" });
|
|
1326
|
-
t2 = /* @__PURE__ */ jsx3(Text, { style: errorStyles.message, children: "The local database encountered an error. This can happen if the app was interrupted during startup." });
|
|
1327
|
-
$[0] = t1;
|
|
1328
|
-
$[1] = t2;
|
|
1329
|
-
} else {
|
|
1330
|
-
t1 = $[0];
|
|
1331
|
-
t2 = $[1];
|
|
1332
|
-
}
|
|
1333
|
-
let t3;
|
|
1334
|
-
if ($[2] !== error.message) {
|
|
1335
|
-
t3 = /* @__PURE__ */ jsx3(Text, { style: errorStyles.errorDetail, children: error.message });
|
|
1336
|
-
$[2] = error.message;
|
|
1337
|
-
$[3] = t3;
|
|
1338
|
-
} else {
|
|
1339
|
-
t3 = $[3];
|
|
1340
|
-
}
|
|
1341
|
-
let t4;
|
|
1342
|
-
if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1343
|
-
t4 = /* @__PURE__ */ jsx3(Text, { style: errorStyles.retryButtonText, children: "Retry" });
|
|
1344
|
-
$[4] = t4;
|
|
1345
|
-
} else {
|
|
1346
|
-
t4 = $[4];
|
|
1347
|
-
}
|
|
1348
|
-
let t5;
|
|
1349
|
-
if ($[5] !== onRetry) {
|
|
1350
|
-
t5 = /* @__PURE__ */ jsx3(Pressable, { style: errorStyles.retryButton, onPress: onRetry, children: t4 });
|
|
1351
|
-
$[5] = onRetry;
|
|
1352
|
-
$[6] = t5;
|
|
1353
|
-
} else {
|
|
1354
|
-
t5 = $[6];
|
|
1355
|
-
}
|
|
1356
|
-
let t6;
|
|
1357
|
-
if ($[7] !== t3 || $[8] !== t5) {
|
|
1358
|
-
t6 = /* @__PURE__ */ jsx3(View, { style: errorStyles.container, children: /* @__PURE__ */ jsxs(View, { style: errorStyles.content, children: [
|
|
1359
|
-
t1,
|
|
1360
|
-
t2,
|
|
1361
|
-
t3,
|
|
1362
|
-
t5
|
|
1363
|
-
] }) });
|
|
1364
|
-
$[7] = t3;
|
|
1365
|
-
$[8] = t5;
|
|
1366
|
-
$[9] = t6;
|
|
1367
|
-
} else {
|
|
1368
|
-
t6 = $[9];
|
|
1369
|
-
}
|
|
1370
|
-
return t6;
|
|
1371
|
-
}
|
|
1372
|
-
function OfflineDataProvider(t0) {
|
|
1373
|
-
const $ = _c(98);
|
|
1374
|
-
const {
|
|
1375
|
-
config,
|
|
1376
|
-
children,
|
|
1377
|
-
dataLayer,
|
|
1378
|
-
backgroundSync,
|
|
1379
|
-
skipConflictProvider: t1,
|
|
1380
|
-
skipStorageQueueProvider: t2,
|
|
1381
|
-
storageBackend,
|
|
1382
|
-
renderInitError,
|
|
1383
|
-
renderError,
|
|
1384
|
-
onReady,
|
|
1385
|
-
onError,
|
|
1386
|
-
onSyncStatusChange,
|
|
1387
|
-
onBackgroundSyncSystemReady: onBackgroundSyncSystemReadyProp
|
|
1388
|
-
} = t0;
|
|
1389
|
-
const skipConflictProvider = t1 === void 0 ? false : t1;
|
|
1390
|
-
const skipStorageQueueProvider = t2 === void 0 ? false : t2;
|
|
1391
|
-
const {
|
|
1392
|
-
schema,
|
|
1393
|
-
supabaseClient,
|
|
1394
|
-
queryClient,
|
|
1395
|
-
powerSyncUrl,
|
|
1396
|
-
dbFilename: t3,
|
|
1397
|
-
attachments,
|
|
1398
|
-
platform: customPlatform,
|
|
1399
|
-
connector: connectorConfig,
|
|
1400
|
-
sync: syncConfig
|
|
1401
|
-
} = config;
|
|
1402
|
-
const dbFilename = t3 === void 0 ? "powersync.db" : t3;
|
|
1403
|
-
const [initError, setInitError] = useState2(null);
|
|
1404
|
-
const [retryKey, setRetryKey] = useState2(0);
|
|
1405
|
-
const [powerSyncInstance, setPowerSyncInstance] = useState2(null);
|
|
1406
|
-
const [powerSyncSyncStatus, setPowerSyncSyncStatus] = useState2(void 0);
|
|
1407
|
-
const addPendingMutationRef = useRef3(null);
|
|
1408
|
-
const removePendingMutationRef = useRef3(null);
|
|
1409
|
-
const backgroundSyncSystemRef = useRef3(null);
|
|
1410
|
-
let t4;
|
|
1411
|
-
if ($[0] !== customPlatform) {
|
|
1412
|
-
t4 = customPlatform ?? createNativePlatformAdapter(defaultLogger);
|
|
1413
|
-
$[0] = customPlatform;
|
|
1414
|
-
$[1] = t4;
|
|
1415
|
-
} else {
|
|
1416
|
-
t4 = $[1];
|
|
1417
|
-
}
|
|
1418
|
-
const platform = t4;
|
|
1419
|
-
let t10;
|
|
1420
|
-
let t5;
|
|
1421
|
-
let t6;
|
|
1422
|
-
let t7;
|
|
1423
|
-
let t8;
|
|
1424
|
-
let t9;
|
|
1425
|
-
if ($[2] !== platform.logger) {
|
|
1426
|
-
t5 = async () => {
|
|
1427
|
-
platform.logger.warn("Sync not available: Use useSyncControl from PowerSync context");
|
|
1428
|
-
};
|
|
1429
|
-
t6 = async () => {
|
|
1430
|
-
platform.logger.warn("Live sync not available: Use useSyncControl from PowerSync context");
|
|
1431
|
-
};
|
|
1432
|
-
t7 = () => {
|
|
1433
|
-
platform.logger.warn("Live sync not available: Use useSyncControl from PowerSync context");
|
|
1434
|
-
};
|
|
1435
|
-
t8 = async () => {
|
|
1436
|
-
platform.logger.warn("Scope control not available: Use useSyncControl from PowerSync context");
|
|
1437
|
-
};
|
|
1438
|
-
t9 = async () => {
|
|
1439
|
-
platform.logger.warn("Retry not available: Use useSyncControl from PowerSync context");
|
|
1440
|
-
};
|
|
1441
|
-
t10 = () => {
|
|
1442
|
-
platform.logger.warn("Clear failed uploads not available: Use useSyncControl from PowerSync context");
|
|
1443
|
-
};
|
|
1444
|
-
$[2] = platform.logger;
|
|
1445
|
-
$[3] = t10;
|
|
1446
|
-
$[4] = t5;
|
|
1447
|
-
$[5] = t6;
|
|
1448
|
-
$[6] = t7;
|
|
1449
|
-
$[7] = t8;
|
|
1450
|
-
$[8] = t9;
|
|
1451
|
-
} else {
|
|
1452
|
-
t10 = $[3];
|
|
1453
|
-
t5 = $[4];
|
|
1454
|
-
t6 = $[5];
|
|
1455
|
-
t7 = $[6];
|
|
1456
|
-
t8 = $[7];
|
|
1457
|
-
t9 = $[8];
|
|
1458
|
-
}
|
|
1459
|
-
let t11;
|
|
1460
|
-
let t12;
|
|
1461
|
-
let t13;
|
|
1462
|
-
if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1463
|
-
t11 = [];
|
|
1464
|
-
t12 = (entry) => {
|
|
1465
|
-
if (addPendingMutationRef.current) {
|
|
1466
|
-
addPendingMutationRef.current(entry);
|
|
1467
|
-
}
|
|
1468
|
-
};
|
|
1469
|
-
t13 = (id) => {
|
|
1470
|
-
if (removePendingMutationRef.current) {
|
|
1471
|
-
removePendingMutationRef.current(id);
|
|
1472
|
-
}
|
|
1473
|
-
};
|
|
1474
|
-
$[9] = t11;
|
|
1475
|
-
$[10] = t12;
|
|
1476
|
-
$[11] = t13;
|
|
1477
|
-
} else {
|
|
1478
|
-
t11 = $[9];
|
|
1479
|
-
t12 = $[10];
|
|
1480
|
-
t13 = $[11];
|
|
1481
|
-
}
|
|
1482
|
-
let t14;
|
|
1483
|
-
if ($[12] !== t10 || $[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
|
|
1484
|
-
t14 = {
|
|
1485
|
-
triggerSync: t5,
|
|
1486
|
-
startLiveSync: t6,
|
|
1487
|
-
stopLiveSync: t7,
|
|
1488
|
-
setScope: t8,
|
|
1489
|
-
retryFailedUploads: t9,
|
|
1490
|
-
clearFailedUploads: t10,
|
|
1491
|
-
failedUploads: t11,
|
|
1492
|
-
addPendingMutation: t12,
|
|
1493
|
-
removePendingMutation: t13
|
|
1494
|
-
};
|
|
1495
|
-
$[12] = t10;
|
|
1496
|
-
$[13] = t5;
|
|
1497
|
-
$[14] = t6;
|
|
1498
|
-
$[15] = t7;
|
|
1499
|
-
$[16] = t8;
|
|
1500
|
-
$[17] = t9;
|
|
1501
|
-
$[18] = t14;
|
|
1502
|
-
} else {
|
|
1503
|
-
t14 = $[18];
|
|
1504
|
-
}
|
|
1505
|
-
const syncControl = t14;
|
|
1506
|
-
let t15;
|
|
1507
|
-
bb0: {
|
|
1508
|
-
if (!attachments) {
|
|
1509
|
-
t15 = void 0;
|
|
1510
|
-
break bb0;
|
|
1511
|
-
}
|
|
1512
|
-
let t162;
|
|
1513
|
-
if ($[19] !== attachments.bucket || $[20] !== storageBackend || $[21] !== supabaseClient) {
|
|
1514
|
-
t162 = supabaseClient ? createSupabaseUploadHandler(supabaseClient, {
|
|
1515
|
-
defaultBucket: attachments.bucket,
|
|
1516
|
-
resolver: storageBackend?.resolveBucket?.bind(storageBackend)
|
|
1517
|
-
}) : void 0;
|
|
1518
|
-
$[19] = attachments.bucket;
|
|
1519
|
-
$[20] = storageBackend;
|
|
1520
|
-
$[21] = supabaseClient;
|
|
1521
|
-
$[22] = t162;
|
|
1522
|
-
} else {
|
|
1523
|
-
t162 = $[22];
|
|
1524
|
-
}
|
|
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 = {
|
|
1530
|
-
bucket: attachments.bucket,
|
|
1531
|
-
watchIds: attachments.watchIds,
|
|
1532
|
-
skipDownload: attachments.skipDownload,
|
|
1533
|
-
onUploadComplete: attachments.onUploadComplete,
|
|
1534
|
-
onUploadFailed: attachments.onUploadFailed,
|
|
1535
|
-
maxCacheBytes: attachments.maxCacheBytes,
|
|
1536
|
-
compression: attachments.compression,
|
|
1537
|
-
download: attachments.download,
|
|
1538
|
-
remoteStorage: t172,
|
|
1539
|
-
uploadHandler: nativeUploadHandler
|
|
1540
|
-
};
|
|
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;
|
|
1552
|
-
} else {
|
|
1553
|
-
t182 = $[33];
|
|
1554
|
-
}
|
|
1555
|
-
t15 = t182;
|
|
1556
|
-
}
|
|
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
|
|
1568
|
-
};
|
|
1569
|
-
$[34] = t17;
|
|
1570
|
-
$[35] = t18;
|
|
1571
|
-
$[36] = t19;
|
|
1572
|
-
$[37] = t20;
|
|
1573
|
-
} else {
|
|
1574
|
-
t20 = $[37];
|
|
1575
|
-
}
|
|
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 = {
|
|
1579
|
-
platform,
|
|
1580
|
-
schema,
|
|
1581
|
-
powerSyncUrl: t16,
|
|
1582
|
-
supabaseClient,
|
|
1583
|
-
queryClient,
|
|
1584
|
-
dbFilename,
|
|
1585
|
-
connector: connectorConfig,
|
|
1586
|
-
attachments: attachmentConfig,
|
|
1587
|
-
sync: t20
|
|
1588
|
-
};
|
|
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;
|
|
1599
|
-
} else {
|
|
1600
|
-
t21 = $[47];
|
|
1601
|
-
}
|
|
1602
|
-
const powerSyncConfig = t21;
|
|
1603
|
-
let t22;
|
|
1604
|
-
if ($[48] !== onError || $[49] !== platform.logger) {
|
|
1605
|
-
t22 = (err) => {
|
|
1606
|
-
platform.logger.error("PowerSync error:", err);
|
|
1607
|
-
const errorMessage = err.message ?? "";
|
|
1608
|
-
if (errorMessage.includes("not open") || errorMessage.includes("closed") || errorMessage.includes("failed to open") || errorMessage.includes("initialization failed")) {
|
|
1609
|
-
setInitError(err);
|
|
1610
|
-
}
|
|
1611
|
-
onError?.(err);
|
|
1612
|
-
};
|
|
1613
|
-
$[48] = onError;
|
|
1614
|
-
$[49] = platform.logger;
|
|
1615
|
-
$[50] = t22;
|
|
1616
|
-
} else {
|
|
1617
|
-
t22 = $[50];
|
|
1618
|
-
}
|
|
1619
|
-
const handlePowerSyncError = t22;
|
|
1620
|
-
let t23;
|
|
1621
|
-
if ($[51] !== platform.logger) {
|
|
1622
|
-
t23 = () => {
|
|
1623
|
-
platform.logger.info("Retrying PowerSync initialization...");
|
|
1624
|
-
setInitError(null);
|
|
1625
|
-
setRetryKey(_temp);
|
|
1626
|
-
};
|
|
1627
|
-
$[51] = platform.logger;
|
|
1628
|
-
$[52] = t23;
|
|
1629
|
-
} else {
|
|
1630
|
-
t23 = $[52];
|
|
1631
|
-
}
|
|
1632
|
-
const handleRetry = t23;
|
|
1633
|
-
let t24;
|
|
1634
|
-
if ($[53] !== backgroundSync?.callbacks || $[54] !== onBackgroundSyncSystemReadyProp || $[55] !== platform.logger) {
|
|
1635
|
-
t24 = (system) => {
|
|
1636
|
-
backgroundSyncSystemRef.current = system;
|
|
1637
|
-
backgroundSync?.callbacks?.onSyncStart?.();
|
|
1638
|
-
onBackgroundSyncSystemReadyProp?.(system);
|
|
1639
|
-
platform.logger.info("[Background Sync] System ready");
|
|
1640
|
-
};
|
|
1641
|
-
$[53] = backgroundSync?.callbacks;
|
|
1642
|
-
$[54] = onBackgroundSyncSystemReadyProp;
|
|
1643
|
-
$[55] = platform.logger;
|
|
1644
|
-
$[56] = t24;
|
|
1645
|
-
} else {
|
|
1646
|
-
t24 = $[56];
|
|
1647
|
-
}
|
|
1648
|
-
backgroundSync?.callbacks;
|
|
1649
|
-
const handleBackgroundSyncSystemReady = t24;
|
|
1650
|
-
let t25;
|
|
1651
|
-
if ($[57] !== renderError || $[58] !== renderInitError) {
|
|
1652
|
-
t25 = (error, retry) => {
|
|
1653
|
-
const customRenderer = renderInitError ?? renderError;
|
|
1654
|
-
if (customRenderer) {
|
|
1655
|
-
return customRenderer(error, retry);
|
|
1656
|
-
}
|
|
1657
|
-
return /* @__PURE__ */ jsx3(DefaultErrorRecoveryUI, { error, onRetry: retry });
|
|
1658
|
-
};
|
|
1659
|
-
$[57] = renderError;
|
|
1660
|
-
$[58] = renderInitError;
|
|
1661
|
-
$[59] = t25;
|
|
1662
|
-
} else {
|
|
1663
|
-
t25 = $[59];
|
|
1664
|
-
}
|
|
1665
|
-
const errorFallback = t25;
|
|
1666
|
-
let t26;
|
|
1667
|
-
if ($[60] !== powerSyncSyncStatus || $[61] !== powerSyncUrl) {
|
|
1668
|
-
t26 = !powerSyncUrl ? {
|
|
1669
|
-
hasSynced: true,
|
|
1670
|
-
connected: true,
|
|
1671
|
-
connecting: false,
|
|
1672
|
-
isOnline: true
|
|
1673
|
-
} : powerSyncSyncStatus;
|
|
1674
|
-
$[60] = powerSyncSyncStatus;
|
|
1675
|
-
$[61] = powerSyncUrl;
|
|
1676
|
-
$[62] = t26;
|
|
1677
|
-
} else {
|
|
1678
|
-
t26 = $[62];
|
|
1679
|
-
}
|
|
1680
|
-
const effectiveSyncStatus = t26;
|
|
1681
|
-
let t27;
|
|
1682
|
-
let t28;
|
|
1683
|
-
if ($[63] !== effectiveSyncStatus || $[64] !== onSyncStatusChange) {
|
|
1684
|
-
t27 = () => {
|
|
1685
|
-
if (effectiveSyncStatus) {
|
|
1686
|
-
onSyncStatusChange?.(effectiveSyncStatus);
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
t28 = [effectiveSyncStatus, onSyncStatusChange];
|
|
1690
|
-
$[63] = effectiveSyncStatus;
|
|
1691
|
-
$[64] = onSyncStatusChange;
|
|
1692
|
-
$[65] = t27;
|
|
1693
|
-
$[66] = t28;
|
|
1694
|
-
} else {
|
|
1695
|
-
t27 = $[65];
|
|
1696
|
-
t28 = $[66];
|
|
1697
|
-
}
|
|
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");
|
|
1703
|
-
bb1: {
|
|
1704
|
-
const renderContent = () => {
|
|
1705
|
-
if (!powerSyncUrl) {
|
|
1706
|
-
return /* @__PURE__ */ jsx3(Fragment2, { children });
|
|
1707
|
-
}
|
|
1708
|
-
if (initError) {
|
|
1709
|
-
const customRenderer_0 = renderInitError ?? renderError;
|
|
1710
|
-
if (customRenderer_0) {
|
|
1711
|
-
return /* @__PURE__ */ jsx3(Fragment2, { children: customRenderer_0(initError, handleRetry) });
|
|
1712
|
-
}
|
|
1713
|
-
return /* @__PURE__ */ jsx3(DefaultErrorRecoveryUI, { error: initError, onRetry: handleRetry });
|
|
1714
|
-
}
|
|
1715
|
-
return /* @__PURE__ */ jsx3(PowerSyncErrorBoundary, { fallback: errorFallback, onError: handlePowerSyncError, children: /* @__PURE__ */ jsx3(PowerSyncProvider, { config: powerSyncConfig, onReady: () => {
|
|
1716
|
-
platform.logger.info("PowerSync initialized and ready");
|
|
1717
|
-
setInitError(null);
|
|
1718
|
-
onReady?.();
|
|
1719
|
-
}, onError: handlePowerSyncError, children: /* @__PURE__ */ jsx3(ProviderBridge, { skipConflictProvider, skipStorageQueueProvider, backgroundSync, onBackgroundSyncSystemReady: handleBackgroundSyncSystemReady, onDbReady: (db, syncStatus) => {
|
|
1720
|
-
setPowerSyncInstance(db);
|
|
1721
|
-
setPowerSyncSyncStatus(syncStatus);
|
|
1722
|
-
}, onSyncStatusChange: (syncStatus_0) => {
|
|
1723
|
-
setPowerSyncSyncStatus(syncStatus_0);
|
|
1724
|
-
}, onAddPendingMutationReady: (add) => {
|
|
1725
|
-
addPendingMutationRef.current = add;
|
|
1726
|
-
}, onRemovePendingMutationReady: (remove) => {
|
|
1727
|
-
removePendingMutationRef.current = remove;
|
|
1728
|
-
}, children }) }, retryKey) });
|
|
1729
|
-
};
|
|
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;
|
|
1740
|
-
} else {
|
|
1741
|
-
t31 = $[97];
|
|
1742
|
-
}
|
|
1743
|
-
const renderWithDataLayer = t31;
|
|
1744
|
-
if (dataLayer && !dataLayer.skip) {
|
|
1745
|
-
t30 = renderWithDataLayer(renderContent());
|
|
1746
|
-
break bb1;
|
|
1747
|
-
}
|
|
1748
|
-
t29 = renderContent();
|
|
1749
|
-
}
|
|
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;
|
|
1774
|
-
} else {
|
|
1775
|
-
t29 = $[89];
|
|
1776
|
-
t30 = $[90];
|
|
1777
|
-
}
|
|
1778
|
-
if (t30 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel")) {
|
|
1779
|
-
return t30;
|
|
1780
|
-
}
|
|
1781
|
-
return t29;
|
|
1782
|
-
}
|
|
1783
|
-
function _temp(prev) {
|
|
1784
|
-
return prev + 1;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
1327
|
export {
|
|
1788
1328
|
ConflictBus,
|
|
1789
1329
|
UPLOAD_MAX_RETRIES,
|
|
1790
1330
|
UPLOAD_BACKOFF_DELAYS,
|
|
1791
1331
|
PowerSyncProvider,
|
|
1792
|
-
ProviderBridge
|
|
1793
|
-
OfflineDataProvider
|
|
1332
|
+
ProviderBridge
|
|
1794
1333
|
};
|
|
1795
|
-
//# sourceMappingURL=chunk-
|
|
1334
|
+
//# sourceMappingURL=chunk-P4D6BQ4X.js.map
|