@pol-studios/powersync 1.0.25 → 1.0.32

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 (118) hide show
  1. package/README.md +0 -1
  2. package/dist/{CacheSettingsManager-uz-kbnRH.d.ts → CacheSettingsManager-0H_7thHW.d.ts} +21 -3
  3. package/dist/attachments/index.d.ts +30 -30
  4. package/dist/attachments/index.js +13 -4
  5. package/dist/{background-sync-ChCXW-EV.d.ts → background-sync-BujnI3IR.d.ts} +1 -1
  6. package/dist/{chunk-55DKCJV4.js → chunk-2RDWLXJW.js} +408 -78
  7. package/dist/chunk-2RDWLXJW.js.map +1 -0
  8. package/dist/{chunk-P4HZA6ZT.js → chunk-4665ZSE5.js} +2 -2
  9. package/dist/chunk-4665ZSE5.js.map +1 -0
  10. package/dist/{chunk-XOY2CJ67.js → chunk-4F5B5CZ7.js} +3 -3
  11. package/dist/chunk-5WRI5ZAA.js +31 -0
  12. package/dist/{chunk-BGBQYQV3.js → chunk-65A3SYJZ.js} +193 -299
  13. package/dist/chunk-65A3SYJZ.js.map +1 -0
  14. package/dist/chunk-6SZ64KCZ.js +755 -0
  15. package/dist/chunk-6SZ64KCZ.js.map +1 -0
  16. package/dist/{chunk-YSTEESEG.js → chunk-74TBHWJ4.js} +122 -11
  17. package/dist/chunk-74TBHWJ4.js.map +1 -0
  18. package/dist/chunk-ANXWYQEJ.js +1 -0
  19. package/dist/chunk-ANXWYQEJ.js.map +1 -0
  20. package/dist/{chunk-CAB26E6F.js → chunk-C4J4MLER.js} +29 -24
  21. package/dist/chunk-C4J4MLER.js.map +1 -0
  22. package/dist/{chunk-C5ODS3XH.js → chunk-EOW7JK7Q.js} +9 -16
  23. package/dist/chunk-EOW7JK7Q.js.map +1 -0
  24. package/dist/chunk-HRAVPIAZ.js +220 -0
  25. package/dist/chunk-HRAVPIAZ.js.map +1 -0
  26. package/dist/{chunk-XAEII4ZX.js → chunk-NUGQOTEM.js} +32 -4
  27. package/dist/chunk-NUGQOTEM.js.map +1 -0
  28. package/dist/chunk-OGUFUZSY.js +5415 -0
  29. package/dist/chunk-OGUFUZSY.js.map +1 -0
  30. package/dist/{chunk-VB737IVN.js → chunk-P4D6BQ4X.js} +328 -706
  31. package/dist/chunk-P4D6BQ4X.js.map +1 -0
  32. package/dist/{chunk-CACKC6XG.js → chunk-PGEDE6IM.js} +136 -89
  33. package/dist/chunk-PGEDE6IM.js.map +1 -0
  34. package/dist/{chunk-A4IBBWGO.js → chunk-RALHHPTU.js} +1 -1
  35. package/dist/chunk-RIDSPLE5.js +42 -0
  36. package/dist/chunk-RIDSPLE5.js.map +1 -0
  37. package/dist/{chunk-Z6VOBGTU.js → chunk-UOMHWUHV.js} +2 -12
  38. package/dist/chunk-UOMHWUHV.js.map +1 -0
  39. package/dist/{chunk-WGHNIAF7.js → chunk-YONQYTVH.js} +2 -2
  40. package/dist/chunk-ZAN22NGL.js +13 -0
  41. package/dist/chunk-ZAN22NGL.js.map +1 -0
  42. package/dist/config/index.d.ts +200 -0
  43. package/dist/config/index.js +23 -0
  44. package/dist/config/index.js.map +1 -0
  45. package/dist/connector/index.d.ts +23 -5
  46. package/dist/connector/index.js +4 -2
  47. package/dist/core/index.d.ts +2 -2
  48. package/dist/core/index.js +1 -0
  49. package/dist/error/index.js +1 -0
  50. package/dist/generator/index.js +2 -0
  51. package/dist/generator/index.js.map +1 -1
  52. package/dist/index.d.ts +19 -16
  53. package/dist/index.js +88 -46
  54. package/dist/index.native.d.ts +18 -14
  55. package/dist/index.native.js +93 -44
  56. package/dist/index.web.d.ts +17 -14
  57. package/dist/index.web.js +88 -46
  58. package/dist/maintenance/index.d.ts +2 -2
  59. package/dist/maintenance/index.js +3 -2
  60. package/dist/platform/index.d.ts +1 -1
  61. package/dist/platform/index.js +2 -0
  62. package/dist/platform/index.js.map +1 -1
  63. package/dist/platform/index.native.d.ts +1 -1
  64. package/dist/platform/index.native.js +1 -0
  65. package/dist/platform/index.web.d.ts +1 -1
  66. package/dist/platform/index.web.js +1 -0
  67. package/dist/pol-attachment-queue-DqBvLAEY.d.ts +255 -0
  68. package/dist/provider/index.d.ts +319 -124
  69. package/dist/provider/index.js +21 -16
  70. package/dist/provider/index.native.d.ts +108 -0
  71. package/dist/provider/index.native.js +121 -0
  72. package/dist/provider/index.native.js.map +1 -0
  73. package/dist/provider/index.web.d.ts +16 -0
  74. package/dist/provider/index.web.js +112 -0
  75. package/dist/provider/index.web.js.map +1 -0
  76. package/dist/react/index.d.ts +16 -65
  77. package/dist/react/index.js +2 -9
  78. package/dist/storage/index.d.ts +5 -4
  79. package/dist/storage/index.js +12 -9
  80. package/dist/storage/index.native.d.ts +5 -4
  81. package/dist/storage/index.native.js +8 -5
  82. package/dist/storage/index.web.d.ts +5 -4
  83. package/dist/storage/index.web.js +11 -8
  84. package/dist/storage/upload/index.d.ts +4 -3
  85. package/dist/storage/upload/index.js +4 -2
  86. package/dist/storage/upload/index.native.d.ts +4 -3
  87. package/dist/storage/upload/index.native.js +4 -2
  88. package/dist/storage/upload/index.web.d.ts +2 -1
  89. package/dist/storage/upload/index.web.js +4 -2
  90. package/dist/{supabase-connector-D2oIl2t8.d.ts → supabase-connector-HMxBA9Kg.d.ts} +23 -25
  91. package/dist/sync/index.d.ts +183 -11
  92. package/dist/sync/index.js +13 -3
  93. package/dist/{types-CyvBaAl8.d.ts → types-6QHGELuY.d.ts} +4 -1
  94. package/dist/{types-CDqWh56B.d.ts → types-B9MptP7E.d.ts} +13 -1
  95. package/dist/types-BhAEsJj-.d.ts +330 -0
  96. package/dist/{types-D0WcHrq6.d.ts → types-CGMibJKD.d.ts} +8 -0
  97. package/dist/{types-DiBvmGEi.d.ts → types-DqJnP50o.d.ts} +22 -24
  98. package/dist/{pol-attachment-queue-BE2HU3Us.d.ts → types-JCEhw2Lf.d.ts} +139 -346
  99. package/package.json +18 -4
  100. package/dist/chunk-24RDMMCL.js +0 -44
  101. package/dist/chunk-24RDMMCL.js.map +0 -1
  102. package/dist/chunk-55DKCJV4.js.map +0 -1
  103. package/dist/chunk-654ERHA7.js +0 -1
  104. package/dist/chunk-BGBQYQV3.js.map +0 -1
  105. package/dist/chunk-C5ODS3XH.js.map +0 -1
  106. package/dist/chunk-CAB26E6F.js.map +0 -1
  107. package/dist/chunk-CACKC6XG.js.map +0 -1
  108. package/dist/chunk-P4HZA6ZT.js.map +0 -1
  109. package/dist/chunk-TIFL2KWE.js +0 -358
  110. package/dist/chunk-TIFL2KWE.js.map +0 -1
  111. package/dist/chunk-VB737IVN.js.map +0 -1
  112. package/dist/chunk-XAEII4ZX.js.map +0 -1
  113. package/dist/chunk-YSTEESEG.js.map +0 -1
  114. package/dist/chunk-Z6VOBGTU.js.map +0 -1
  115. /package/dist/{chunk-XOY2CJ67.js.map → chunk-4F5B5CZ7.js.map} +0 -0
  116. /package/dist/{chunk-654ERHA7.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  117. /package/dist/{chunk-A4IBBWGO.js.map → chunk-RALHHPTU.js.map} +0 -0
  118. /package/dist/{chunk-WGHNIAF7.js.map → chunk-YONQYTVH.js.map} +0 -0
@@ -0,0 +1,755 @@
1
+ import {
2
+ createSupabaseUploadHandler
3
+ } from "./chunk-C4J4MLER.js";
4
+ import {
5
+ PowerSyncErrorBoundary
6
+ } from "./chunk-P6WOZO7H.js";
7
+ import {
8
+ PowerSyncProvider,
9
+ ProviderBridge
10
+ } from "./chunk-P4D6BQ4X.js";
11
+ import {
12
+ createNativePlatformAdapter
13
+ } from "./chunk-WN5ZJ3E2.js";
14
+
15
+ // src/provider/OfflineDataProvider.tsx
16
+ import { c as _c } from "react/compiler-runtime";
17
+ import { useEffect, useRef, useState } from "react";
18
+ import { View, Text, StyleSheet, Pressable } from "react-native";
19
+ import { DataLayerProvider } from "@pol-studios/db";
20
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
+ var defaultLogger = {
22
+ debug: (...args) => console.debug("[OfflineData]", ...args),
23
+ info: (...args) => console.info("[OfflineData]", ...args),
24
+ warn: (...args) => console.warn("[OfflineData]", ...args),
25
+ error: (...args) => console.error("[OfflineData]", ...args)
26
+ };
27
+ var errorStyles = StyleSheet.create({
28
+ container: {
29
+ flex: 1,
30
+ justifyContent: "center",
31
+ alignItems: "center",
32
+ backgroundColor: "#f5f5f5",
33
+ padding: 20
34
+ },
35
+ content: {
36
+ backgroundColor: "white",
37
+ borderRadius: 12,
38
+ padding: 24,
39
+ maxWidth: 400,
40
+ width: "100%",
41
+ shadowColor: "#000",
42
+ shadowOffset: {
43
+ width: 0,
44
+ height: 2
45
+ },
46
+ shadowOpacity: 0.1,
47
+ shadowRadius: 8,
48
+ elevation: 4
49
+ },
50
+ title: {
51
+ fontSize: 20,
52
+ fontWeight: "600",
53
+ color: "#1a1a1a",
54
+ marginBottom: 12,
55
+ textAlign: "center"
56
+ },
57
+ message: {
58
+ fontSize: 14,
59
+ color: "#666",
60
+ marginBottom: 16,
61
+ textAlign: "center",
62
+ lineHeight: 20
63
+ },
64
+ errorDetail: {
65
+ fontSize: 12,
66
+ color: "#999",
67
+ marginBottom: 20,
68
+ textAlign: "center",
69
+ fontFamily: "monospace"
70
+ },
71
+ retryButton: {
72
+ backgroundColor: "#007AFF",
73
+ borderRadius: 8,
74
+ paddingVertical: 12,
75
+ paddingHorizontal: 24,
76
+ alignItems: "center"
77
+ },
78
+ retryButtonText: {
79
+ color: "white",
80
+ fontSize: 16,
81
+ fontWeight: "600"
82
+ }
83
+ });
84
+ function DefaultErrorRecoveryUI(t0) {
85
+ const $ = _c(10);
86
+ const {
87
+ error,
88
+ onRetry
89
+ } = t0;
90
+ let t1;
91
+ let t2;
92
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
93
+ t1 = /* @__PURE__ */ jsx(Text, { style: errorStyles.title, children: "Database Error" });
94
+ t2 = /* @__PURE__ */ jsx(Text, { style: errorStyles.message, children: "The local database encountered an error. This can happen if the app was interrupted during startup." });
95
+ $[0] = t1;
96
+ $[1] = t2;
97
+ } else {
98
+ t1 = $[0];
99
+ t2 = $[1];
100
+ }
101
+ let t3;
102
+ if ($[2] !== error.message) {
103
+ t3 = /* @__PURE__ */ jsx(Text, { style: errorStyles.errorDetail, children: error.message });
104
+ $[2] = error.message;
105
+ $[3] = t3;
106
+ } else {
107
+ t3 = $[3];
108
+ }
109
+ let t4;
110
+ if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
111
+ t4 = /* @__PURE__ */ jsx(Text, { style: errorStyles.retryButtonText, children: "Retry" });
112
+ $[4] = t4;
113
+ } else {
114
+ t4 = $[4];
115
+ }
116
+ let t5;
117
+ if ($[5] !== onRetry) {
118
+ t5 = /* @__PURE__ */ jsx(Pressable, { style: errorStyles.retryButton, onPress: onRetry, children: t4 });
119
+ $[5] = onRetry;
120
+ $[6] = t5;
121
+ } else {
122
+ t5 = $[6];
123
+ }
124
+ let t6;
125
+ if ($[7] !== t3 || $[8] !== t5) {
126
+ t6 = /* @__PURE__ */ jsx(View, { style: errorStyles.container, children: /* @__PURE__ */ jsxs(View, { style: errorStyles.content, children: [
127
+ t1,
128
+ t2,
129
+ t3,
130
+ t5
131
+ ] }) });
132
+ $[7] = t3;
133
+ $[8] = t5;
134
+ $[9] = t6;
135
+ } else {
136
+ t6 = $[9];
137
+ }
138
+ return t6;
139
+ }
140
+ function OfflineDataProvider(t0) {
141
+ const $ = _c(132);
142
+ const {
143
+ config,
144
+ polConfig,
145
+ supabaseClient: polConfigSupabase,
146
+ queryClient: polConfigQueryClient,
147
+ children,
148
+ dataLayer,
149
+ backgroundSync,
150
+ skipConflictProvider: t1,
151
+ skipStorageQueueProvider: t2,
152
+ storageBackend,
153
+ platform: customPlatformProp,
154
+ attachments: attachmentsOverride,
155
+ renderInitError,
156
+ renderError,
157
+ onReady,
158
+ onError,
159
+ onSyncStatusChange,
160
+ onBackgroundSyncSystemReady: onBackgroundSyncSystemReadyProp
161
+ } = t0;
162
+ const skipConflictProvider = t1 === void 0 ? false : t1;
163
+ const skipStorageQueueProvider = t2 === void 0 ? false : t2;
164
+ let t3;
165
+ bb0: {
166
+ if (polConfig) {
167
+ if (!polConfigSupabase) {
168
+ throw new Error("[OfflineDataProvider] supabaseClient is required when using polConfig");
169
+ }
170
+ if (!polConfigQueryClient) {
171
+ throw new Error("[OfflineDataProvider] queryClient is required when using polConfig");
172
+ }
173
+ let t43;
174
+ if ($[0] !== attachmentsOverride?.watchPaths || $[1] !== polConfig.attachments) {
175
+ t43 = polConfig.attachments ? {
176
+ source: polConfig.attachments.source,
177
+ watchPaths: attachmentsOverride?.watchPaths ?? polConfig.attachments.watchPaths
178
+ } : void 0;
179
+ $[0] = attachmentsOverride?.watchPaths;
180
+ $[1] = polConfig.attachments;
181
+ $[2] = t43;
182
+ } else {
183
+ t43 = $[2];
184
+ }
185
+ const attachmentsConfig = t43;
186
+ const t53 = polConfig.dbFilename ?? "powersync.db";
187
+ let t63;
188
+ if ($[3] !== polConfig.__schemaRouter || $[4] !== polConfig.connector) {
189
+ t63 = polConfig.connector ? {
190
+ schemaRouter: polConfig.__schemaRouter,
191
+ conflictDetection: polConfig.connector.conflictDetection ? {
192
+ enabled: polConfig.connector.conflictDetection
193
+ } : void 0,
194
+ uploadErrorMiddleware: polConfig.connector.uploadErrorMiddleware
195
+ } : {
196
+ schemaRouter: polConfig.__schemaRouter
197
+ };
198
+ $[3] = polConfig.__schemaRouter;
199
+ $[4] = polConfig.connector;
200
+ $[5] = t63;
201
+ } else {
202
+ t63 = $[5];
203
+ }
204
+ let t72;
205
+ if ($[6] !== polConfig.sync) {
206
+ t72 = polConfig.sync ? {
207
+ autoConnect: polConfig.sync.autoConnect,
208
+ enableHealthMonitoring: polConfig.sync.enableHealthMonitoring,
209
+ enableMetrics: polConfig.sync.enableMetrics
210
+ } : void 0;
211
+ $[6] = polConfig.sync;
212
+ $[7] = t72;
213
+ } else {
214
+ t72 = $[7];
215
+ }
216
+ const t82 = polConfig.sync?.backgroundSync;
217
+ let t92;
218
+ if ($[8] !== attachmentsConfig || $[9] !== customPlatformProp || $[10] !== polConfig.__generatedSchema || $[11] !== polConfig.powerSyncUrl || $[12] !== polConfigQueryClient || $[13] !== polConfigSupabase || $[14] !== t53 || $[15] !== t63 || $[16] !== t72 || $[17] !== t82) {
219
+ t92 = {
220
+ schema: polConfig.__generatedSchema,
221
+ supabaseClient: polConfigSupabase,
222
+ queryClient: polConfigQueryClient,
223
+ powerSyncUrl: polConfig.powerSyncUrl,
224
+ dbFilename: t53,
225
+ attachments: attachmentsConfig,
226
+ platform: customPlatformProp,
227
+ connector: t63,
228
+ sync: t72,
229
+ backgroundSyncFromPolConfig: t82
230
+ };
231
+ $[8] = attachmentsConfig;
232
+ $[9] = customPlatformProp;
233
+ $[10] = polConfig.__generatedSchema;
234
+ $[11] = polConfig.powerSyncUrl;
235
+ $[12] = polConfigQueryClient;
236
+ $[13] = polConfigSupabase;
237
+ $[14] = t53;
238
+ $[15] = t63;
239
+ $[16] = t72;
240
+ $[17] = t82;
241
+ $[18] = t92;
242
+ } else {
243
+ t92 = $[18];
244
+ }
245
+ t3 = t92;
246
+ break bb0;
247
+ }
248
+ if (!config) {
249
+ throw new Error("[OfflineDataProvider] Either config or polConfig is required");
250
+ }
251
+ const t42 = config.dbFilename ?? "powersync.db";
252
+ const t52 = customPlatformProp ?? config.platform;
253
+ let t62;
254
+ if ($[19] !== config.attachments || $[20] !== config.connector || $[21] !== config.powerSyncUrl || $[22] !== config.queryClient || $[23] !== config.schema || $[24] !== config.supabaseClient || $[25] !== config.sync || $[26] !== t42 || $[27] !== t52) {
255
+ t62 = {
256
+ schema: config.schema,
257
+ supabaseClient: config.supabaseClient,
258
+ queryClient: config.queryClient,
259
+ powerSyncUrl: config.powerSyncUrl,
260
+ dbFilename: t42,
261
+ attachments: config.attachments,
262
+ platform: t52,
263
+ connector: config.connector,
264
+ sync: config.sync,
265
+ backgroundSyncFromPolConfig: void 0
266
+ };
267
+ $[19] = config.attachments;
268
+ $[20] = config.connector;
269
+ $[21] = config.powerSyncUrl;
270
+ $[22] = config.queryClient;
271
+ $[23] = config.schema;
272
+ $[24] = config.supabaseClient;
273
+ $[25] = config.sync;
274
+ $[26] = t42;
275
+ $[27] = t52;
276
+ $[28] = t62;
277
+ } else {
278
+ t62 = $[28];
279
+ }
280
+ t3 = t62;
281
+ }
282
+ const resolvedConfig = t3;
283
+ const {
284
+ schema,
285
+ supabaseClient,
286
+ queryClient,
287
+ powerSyncUrl,
288
+ dbFilename,
289
+ attachments,
290
+ platform: customPlatform,
291
+ connector: connectorConfig,
292
+ sync: syncConfig,
293
+ backgroundSyncFromPolConfig
294
+ } = resolvedConfig;
295
+ let t4;
296
+ if ($[29] !== backgroundSync || $[30] !== backgroundSyncFromPolConfig) {
297
+ t4 = backgroundSync ?? (backgroundSyncFromPolConfig ? {
298
+ enabled: backgroundSyncFromPolConfig.enabled,
299
+ minimumInterval: backgroundSyncFromPolConfig.minimumInterval
300
+ } : void 0);
301
+ $[29] = backgroundSync;
302
+ $[30] = backgroundSyncFromPolConfig;
303
+ $[31] = t4;
304
+ } else {
305
+ t4 = $[31];
306
+ }
307
+ const effectiveBackgroundSync = t4;
308
+ const [initError, setInitError] = useState(null);
309
+ const [retryKey, setRetryKey] = useState(0);
310
+ const [powerSyncInstance, setPowerSyncInstance] = useState(null);
311
+ const [powerSyncSyncStatus, setPowerSyncSyncStatus] = useState(void 0);
312
+ const addPendingMutationRef = useRef(null);
313
+ const removePendingMutationRef = useRef(null);
314
+ const backgroundSyncSystemRef = useRef(null);
315
+ let t5;
316
+ if ($[32] !== customPlatform) {
317
+ t5 = customPlatform ?? createNativePlatformAdapter(defaultLogger);
318
+ $[32] = customPlatform;
319
+ $[33] = t5;
320
+ } else {
321
+ t5 = $[33];
322
+ }
323
+ const platform = t5;
324
+ let t10;
325
+ let t11;
326
+ let t6;
327
+ let t7;
328
+ let t8;
329
+ let t9;
330
+ if ($[34] !== platform.logger) {
331
+ t6 = async () => {
332
+ platform.logger.warn("Sync not available: Use useSyncControl from PowerSync context");
333
+ };
334
+ t7 = async () => {
335
+ platform.logger.warn("Live sync not available: Use useSyncControl from PowerSync context");
336
+ };
337
+ t8 = () => {
338
+ platform.logger.warn("Live sync not available: Use useSyncControl from PowerSync context");
339
+ };
340
+ t9 = async () => {
341
+ platform.logger.warn("Scope control not available: Use useSyncControl from PowerSync context");
342
+ };
343
+ t10 = async () => {
344
+ platform.logger.warn("Retry not available: Use useSyncControl from PowerSync context");
345
+ };
346
+ t11 = () => {
347
+ platform.logger.warn("Clear failed uploads not available: Use useSyncControl from PowerSync context");
348
+ };
349
+ $[34] = platform.logger;
350
+ $[35] = t10;
351
+ $[36] = t11;
352
+ $[37] = t6;
353
+ $[38] = t7;
354
+ $[39] = t8;
355
+ $[40] = t9;
356
+ } else {
357
+ t10 = $[35];
358
+ t11 = $[36];
359
+ t6 = $[37];
360
+ t7 = $[38];
361
+ t8 = $[39];
362
+ t9 = $[40];
363
+ }
364
+ let t12;
365
+ let t13;
366
+ let t14;
367
+ if ($[41] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
368
+ t12 = [];
369
+ t13 = (entry) => {
370
+ if (addPendingMutationRef.current) {
371
+ addPendingMutationRef.current(entry);
372
+ }
373
+ };
374
+ t14 = (id) => {
375
+ if (removePendingMutationRef.current) {
376
+ removePendingMutationRef.current(id);
377
+ }
378
+ };
379
+ $[41] = t12;
380
+ $[42] = t13;
381
+ $[43] = t14;
382
+ } else {
383
+ t12 = $[41];
384
+ t13 = $[42];
385
+ t14 = $[43];
386
+ }
387
+ let t15;
388
+ if ($[44] !== t10 || $[45] !== t11 || $[46] !== t6 || $[47] !== t7 || $[48] !== t8 || $[49] !== t9) {
389
+ t15 = {
390
+ triggerSync: t6,
391
+ startLiveSync: t7,
392
+ stopLiveSync: t8,
393
+ setScope: t9,
394
+ retryFailedUploads: t10,
395
+ clearFailedUploads: t11,
396
+ failedUploads: t12,
397
+ addPendingMutation: t13,
398
+ removePendingMutation: t14
399
+ };
400
+ $[44] = t10;
401
+ $[45] = t11;
402
+ $[46] = t6;
403
+ $[47] = t7;
404
+ $[48] = t8;
405
+ $[49] = t9;
406
+ $[50] = t15;
407
+ } else {
408
+ t15 = $[50];
409
+ }
410
+ const syncControl = t15;
411
+ let t16;
412
+ bb1: {
413
+ if (!attachments) {
414
+ t16 = void 0;
415
+ break bb1;
416
+ }
417
+ const fullAttachments = attachments;
418
+ const bucket = fullAttachments.source?.type === "supabase-bucket" ? fullAttachments.source.bucket : void 0;
419
+ let t172;
420
+ if ($[51] !== bucket || $[52] !== storageBackend || $[53] !== supabaseClient) {
421
+ t172 = supabaseClient && bucket ? createSupabaseUploadHandler(supabaseClient, {
422
+ defaultBucket: bucket,
423
+ resolver: storageBackend?.resolveBucket?.bind(storageBackend)
424
+ }) : void 0;
425
+ $[51] = bucket;
426
+ $[52] = storageBackend;
427
+ $[53] = supabaseClient;
428
+ $[54] = t172;
429
+ } else {
430
+ t172 = $[54];
431
+ }
432
+ const nativeUploadHandler = t172;
433
+ const t182 = storageBackend;
434
+ let t192;
435
+ if ($[55] !== fullAttachments.compression || $[56] !== fullAttachments.download || $[57] !== fullAttachments.maxCacheBytes || $[58] !== fullAttachments.onUploadComplete || $[59] !== fullAttachments.onUploadFailed || $[60] !== fullAttachments.source || $[61] !== fullAttachments.watchPaths || $[62] !== nativeUploadHandler || $[63] !== t182) {
436
+ t192 = {
437
+ source: fullAttachments.source,
438
+ watchPaths: fullAttachments.watchPaths,
439
+ onUploadComplete: fullAttachments.onUploadComplete,
440
+ onUploadFailed: fullAttachments.onUploadFailed,
441
+ maxCacheBytes: fullAttachments.maxCacheBytes,
442
+ compression: fullAttachments.compression,
443
+ download: fullAttachments.download,
444
+ remoteStorage: t182,
445
+ uploadHandler: nativeUploadHandler
446
+ };
447
+ $[55] = fullAttachments.compression;
448
+ $[56] = fullAttachments.download;
449
+ $[57] = fullAttachments.maxCacheBytes;
450
+ $[58] = fullAttachments.onUploadComplete;
451
+ $[59] = fullAttachments.onUploadFailed;
452
+ $[60] = fullAttachments.source;
453
+ $[61] = fullAttachments.watchPaths;
454
+ $[62] = nativeUploadHandler;
455
+ $[63] = t182;
456
+ $[64] = t192;
457
+ } else {
458
+ t192 = $[64];
459
+ }
460
+ t16 = t192;
461
+ }
462
+ const attachmentConfig = t16;
463
+ const t17 = powerSyncUrl ?? "";
464
+ const t18 = syncConfig?.autoConnect ?? true;
465
+ const t19 = syncConfig?.enableHealthMonitoring ?? true;
466
+ const t20 = syncConfig?.enableMetrics ?? true;
467
+ let t21;
468
+ if ($[65] !== t18 || $[66] !== t19 || $[67] !== t20) {
469
+ t21 = {
470
+ autoConnect: t18,
471
+ enableHealthMonitoring: t19,
472
+ enableMetrics: t20
473
+ };
474
+ $[65] = t18;
475
+ $[66] = t19;
476
+ $[67] = t20;
477
+ $[68] = t21;
478
+ } else {
479
+ t21 = $[68];
480
+ }
481
+ let t22;
482
+ if ($[69] !== attachmentConfig || $[70] !== connectorConfig || $[71] !== dbFilename || $[72] !== platform || $[73] !== queryClient || $[74] !== schema || $[75] !== supabaseClient || $[76] !== t17 || $[77] !== t21) {
483
+ t22 = {
484
+ platform,
485
+ schema,
486
+ powerSyncUrl: t17,
487
+ supabaseClient,
488
+ queryClient,
489
+ dbFilename,
490
+ connector: connectorConfig,
491
+ attachments: attachmentConfig,
492
+ sync: t21
493
+ };
494
+ $[69] = attachmentConfig;
495
+ $[70] = connectorConfig;
496
+ $[71] = dbFilename;
497
+ $[72] = platform;
498
+ $[73] = queryClient;
499
+ $[74] = schema;
500
+ $[75] = supabaseClient;
501
+ $[76] = t17;
502
+ $[77] = t21;
503
+ $[78] = t22;
504
+ } else {
505
+ t22 = $[78];
506
+ }
507
+ const powerSyncConfig = t22;
508
+ let t23;
509
+ if ($[79] !== onError || $[80] !== platform.logger) {
510
+ t23 = (err) => {
511
+ platform.logger.error("PowerSync error:", err);
512
+ const errorMessage = err.message ?? "";
513
+ if (errorMessage.includes("not open") || errorMessage.includes("closed") || errorMessage.includes("failed to open") || errorMessage.includes("initialization failed")) {
514
+ setInitError(err);
515
+ }
516
+ onError?.(err);
517
+ };
518
+ $[79] = onError;
519
+ $[80] = platform.logger;
520
+ $[81] = t23;
521
+ } else {
522
+ t23 = $[81];
523
+ }
524
+ const handlePowerSyncError = t23;
525
+ let t24;
526
+ if ($[82] !== platform.logger) {
527
+ t24 = () => {
528
+ platform.logger.info("Retrying PowerSync initialization...");
529
+ setInitError(null);
530
+ setRetryKey(_temp);
531
+ };
532
+ $[82] = platform.logger;
533
+ $[83] = t24;
534
+ } else {
535
+ t24 = $[83];
536
+ }
537
+ const handleRetry = t24;
538
+ let t25;
539
+ if ($[84] !== effectiveBackgroundSync || $[85] !== onBackgroundSyncSystemReadyProp || $[86] !== platform.logger) {
540
+ t25 = (system) => {
541
+ backgroundSyncSystemRef.current = system;
542
+ const bgSyncCallbacks = effectiveBackgroundSync?.callbacks;
543
+ bgSyncCallbacks?.onSyncStart?.();
544
+ onBackgroundSyncSystemReadyProp?.(system);
545
+ platform.logger.info("[Background Sync] System ready");
546
+ };
547
+ $[84] = effectiveBackgroundSync;
548
+ $[85] = onBackgroundSyncSystemReadyProp;
549
+ $[86] = platform.logger;
550
+ $[87] = t25;
551
+ } else {
552
+ t25 = $[87];
553
+ }
554
+ const handleBackgroundSyncSystemReady = t25;
555
+ let t26;
556
+ if ($[88] !== renderError || $[89] !== renderInitError) {
557
+ t26 = (error, retry) => {
558
+ const customRenderer = renderInitError ?? renderError;
559
+ if (customRenderer) {
560
+ return customRenderer(error, retry);
561
+ }
562
+ return /* @__PURE__ */ jsx(DefaultErrorRecoveryUI, { error, onRetry: retry });
563
+ };
564
+ $[88] = renderError;
565
+ $[89] = renderInitError;
566
+ $[90] = t26;
567
+ } else {
568
+ t26 = $[90];
569
+ }
570
+ const errorFallback = t26;
571
+ let t27;
572
+ if ($[91] !== powerSyncSyncStatus || $[92] !== powerSyncUrl) {
573
+ t27 = !powerSyncUrl ? {
574
+ hasSynced: true,
575
+ connected: true,
576
+ connecting: false,
577
+ isOnline: true
578
+ } : powerSyncSyncStatus;
579
+ $[91] = powerSyncSyncStatus;
580
+ $[92] = powerSyncUrl;
581
+ $[93] = t27;
582
+ } else {
583
+ t27 = $[93];
584
+ }
585
+ const effectiveSyncStatus = t27;
586
+ let t28;
587
+ let t29;
588
+ if ($[94] !== effectiveSyncStatus || $[95] !== onSyncStatusChange) {
589
+ t28 = () => {
590
+ if (effectiveSyncStatus) {
591
+ onSyncStatusChange?.(effectiveSyncStatus);
592
+ }
593
+ };
594
+ t29 = [effectiveSyncStatus, onSyncStatusChange];
595
+ $[94] = effectiveSyncStatus;
596
+ $[95] = onSyncStatusChange;
597
+ $[96] = t28;
598
+ $[97] = t29;
599
+ } else {
600
+ t28 = $[96];
601
+ t29 = $[97];
602
+ }
603
+ useEffect(t28, t29);
604
+ let t30;
605
+ let t31;
606
+ if ($[98] !== children || $[99] !== dataLayer?.config || $[100] !== dataLayer?.skip || $[101] !== effectiveBackgroundSync || $[102] !== effectiveSyncStatus || $[103] !== errorFallback || $[104] !== handleBackgroundSyncSystemReady || $[105] !== handlePowerSyncError || $[106] !== handleRetry || $[107] !== initError || $[108] !== onReady || $[109] !== platform.logger || $[110] !== polConfig || $[111] !== powerSyncConfig || $[112] !== powerSyncInstance || $[113] !== powerSyncUrl || $[114] !== queryClient || $[115] !== renderError || $[116] !== renderInitError || $[117] !== retryKey || $[118] !== skipConflictProvider || $[119] !== skipStorageQueueProvider || $[120] !== supabaseClient || $[121] !== syncControl) {
607
+ t31 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
608
+ bb2: {
609
+ const renderContent = () => {
610
+ if (!powerSyncUrl) {
611
+ return /* @__PURE__ */ jsx(Fragment, { children });
612
+ }
613
+ if (initError) {
614
+ const customRenderer_0 = renderInitError ?? renderError;
615
+ if (customRenderer_0) {
616
+ return /* @__PURE__ */ jsx(Fragment, { children: customRenderer_0(initError, handleRetry) });
617
+ }
618
+ return /* @__PURE__ */ jsx(DefaultErrorRecoveryUI, { error: initError, onRetry: handleRetry });
619
+ }
620
+ return /* @__PURE__ */ jsx(PowerSyncErrorBoundary, { fallback: errorFallback, onError: handlePowerSyncError, children: /* @__PURE__ */ jsx(PowerSyncProvider, { config: powerSyncConfig, onReady: () => {
621
+ platform.logger.info("PowerSync initialized and ready");
622
+ setInitError(null);
623
+ onReady?.();
624
+ }, onError: handlePowerSyncError, children: /* @__PURE__ */ jsx(ProviderBridge, { skipConflictProvider, skipStorageQueueProvider, backgroundSync: effectiveBackgroundSync, onBackgroundSyncSystemReady: handleBackgroundSyncSystemReady, onDbReady: (db, syncStatus) => {
625
+ setPowerSyncInstance(db);
626
+ setPowerSyncSyncStatus(syncStatus);
627
+ }, onSyncStatusChange: (syncStatus_0) => {
628
+ setPowerSyncSyncStatus(syncStatus_0);
629
+ }, onAddPendingMutationReady: (add) => {
630
+ addPendingMutationRef.current = add;
631
+ }, onRemovePendingMutationReady: (remove) => {
632
+ removePendingMutationRef.current = remove;
633
+ }, children }) }, retryKey) });
634
+ };
635
+ let t32;
636
+ bb3: {
637
+ if (!polConfig) {
638
+ t32 = null;
639
+ break bb3;
640
+ }
641
+ let tables;
642
+ if ($[124] !== polConfig.__tableStrategies) {
643
+ tables = {};
644
+ for (const [tableName, strategyInfo] of Object.entries(polConfig.__tableStrategies)) {
645
+ tables[tableName] = {
646
+ strategy: strategyInfo.strategy,
647
+ alias: strategyInfo.alias
648
+ };
649
+ }
650
+ $[124] = polConfig.__tableStrategies;
651
+ $[125] = tables;
652
+ } else {
653
+ tables = $[125];
654
+ }
655
+ let t33;
656
+ if ($[126] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
657
+ t33 = {};
658
+ $[126] = t33;
659
+ } else {
660
+ t33 = $[126];
661
+ }
662
+ let t34;
663
+ if ($[127] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
664
+ t34 = {};
665
+ $[127] = t34;
666
+ } else {
667
+ t34 = $[127];
668
+ }
669
+ let t35;
670
+ if ($[128] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
671
+ t35 = {
672
+ syncMode: "live"
673
+ };
674
+ $[128] = t35;
675
+ } else {
676
+ t35 = $[128];
677
+ }
678
+ let t36;
679
+ if ($[129] !== polConfig.databaseSchema || $[130] !== tables) {
680
+ t36 = {
681
+ schema: polConfig.databaseSchema,
682
+ connections: t33,
683
+ tables,
684
+ scopes: t34,
685
+ defaults: t35
686
+ };
687
+ $[129] = polConfig.databaseSchema;
688
+ $[130] = tables;
689
+ $[131] = t36;
690
+ } else {
691
+ t36 = $[131];
692
+ }
693
+ t32 = t36;
694
+ }
695
+ const autoGeneratedDataLayerConfig = t32;
696
+ const effectiveDataLayerConfig = dataLayer?.config ?? autoGeneratedDataLayerConfig;
697
+ if (__DEV__) {
698
+ console.log("[OfflineDataProvider] DataLayer wrapping check:", {
699
+ hasPolConfig: !!polConfig,
700
+ hasAutoGeneratedConfig: !!autoGeneratedDataLayerConfig,
701
+ hasDataLayerConfig: !!dataLayer?.config,
702
+ hasEffectiveConfig: !!effectiveDataLayerConfig,
703
+ dataLayerSkip: dataLayer?.skip,
704
+ willWrapWithDataLayer: !!effectiveDataLayerConfig && !dataLayer?.skip
705
+ });
706
+ }
707
+ if (effectiveDataLayerConfig && !dataLayer?.skip) {
708
+ t31 = /* @__PURE__ */ jsx(DataLayerProvider, { config: effectiveDataLayerConfig, powerSyncInstance, supabaseClient, queryClient, powerSyncSyncStatus: effectiveSyncStatus, syncControl, children: renderContent() });
709
+ break bb2;
710
+ }
711
+ t30 = renderContent();
712
+ }
713
+ $[98] = children;
714
+ $[99] = dataLayer?.config;
715
+ $[100] = dataLayer?.skip;
716
+ $[101] = effectiveBackgroundSync;
717
+ $[102] = effectiveSyncStatus;
718
+ $[103] = errorFallback;
719
+ $[104] = handleBackgroundSyncSystemReady;
720
+ $[105] = handlePowerSyncError;
721
+ $[106] = handleRetry;
722
+ $[107] = initError;
723
+ $[108] = onReady;
724
+ $[109] = platform.logger;
725
+ $[110] = polConfig;
726
+ $[111] = powerSyncConfig;
727
+ $[112] = powerSyncInstance;
728
+ $[113] = powerSyncUrl;
729
+ $[114] = queryClient;
730
+ $[115] = renderError;
731
+ $[116] = renderInitError;
732
+ $[117] = retryKey;
733
+ $[118] = skipConflictProvider;
734
+ $[119] = skipStorageQueueProvider;
735
+ $[120] = supabaseClient;
736
+ $[121] = syncControl;
737
+ $[122] = t30;
738
+ $[123] = t31;
739
+ } else {
740
+ t30 = $[122];
741
+ t31 = $[123];
742
+ }
743
+ if (t31 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel")) {
744
+ return t31;
745
+ }
746
+ return t30;
747
+ }
748
+ function _temp(prev) {
749
+ return prev + 1;
750
+ }
751
+
752
+ export {
753
+ OfflineDataProvider
754
+ };
755
+ //# sourceMappingURL=chunk-6SZ64KCZ.js.map