@pol-studios/db 1.0.23 → 1.0.25
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/{DataLayerContext-ZmLPYR_s.d.ts → DataLayerContext-BnDyYvkg.d.ts} +2 -2
- package/dist/auth/context.js +2 -2
- package/dist/auth/hooks.js +3 -3
- package/dist/auth/index.js +3 -3
- package/dist/{chunk-TSXQTYUG.js → chunk-DJWC43OA.js} +4 -4
- package/dist/{chunk-3L4HOEXV.js → chunk-GXMSZ5S6.js} +3 -3
- package/dist/{chunk-MBU4KE3V.js → chunk-IZX7ZEUF.js} +2 -2
- package/dist/{chunk-Q7WJEOQ5.js → chunk-LVUK5USN.js} +139 -202
- package/dist/chunk-LVUK5USN.js.map +1 -0
- package/dist/{chunk-3UYBZHEV.js → chunk-PZLVL7DU.js} +2 -2
- package/dist/{chunk-KDORWXGS.js → chunk-U4NPP76X.js} +16 -7
- package/dist/chunk-U4NPP76X.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -4
- package/dist/hooks/index.js +1 -1
- package/dist/{index-2YySlz7X.d.ts → index-B6xGmPRV.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/index.native.d.ts +5 -5
- package/dist/index.native.js +6 -6
- package/dist/index.web.d.ts +6 -6
- package/dist/index.web.js +5 -5
- package/dist/types/index.d.ts +2 -2
- package/dist/{useDbCount-s-aR9YeV.d.ts → useDbCount-Dn_1uI69.d.ts} +1 -1
- package/dist/{useResolveFeedback-DTGcHpCs.d.ts → useResolveFeedback-CBHY2Z1Q.d.ts} +3 -3
- package/dist/with-auth/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-KDORWXGS.js.map +0 -1
- package/dist/chunk-Q7WJEOQ5.js.map +0 -1
- /package/dist/{chunk-TSXQTYUG.js.map → chunk-DJWC43OA.js.map} +0 -0
- /package/dist/{chunk-3L4HOEXV.js.map → chunk-GXMSZ5S6.js.map} +0 -0
- /package/dist/{chunk-MBU4KE3V.js.map → chunk-IZX7ZEUF.js.map} +0 -0
- /package/dist/{chunk-3UYBZHEV.js.map → chunk-PZLVL7DU.js.map} +0 -0
|
@@ -74,12 +74,10 @@ function useDbQuery(table, options = {}) {
|
|
|
74
74
|
const tableName = typeof table === "string" ? table : resolveTableName(table);
|
|
75
75
|
const {
|
|
76
76
|
registry,
|
|
77
|
-
queryClient
|
|
77
|
+
queryClient,
|
|
78
|
+
powerSync
|
|
78
79
|
} = useDataLayerCore();
|
|
79
|
-
const
|
|
80
|
-
status
|
|
81
|
-
} = useDataLayerStatus();
|
|
82
|
-
const isPowerSync = status.currentBackend === "powersync";
|
|
80
|
+
const isPowerSync = powerSync !== null;
|
|
83
81
|
const {
|
|
84
82
|
enabled = true,
|
|
85
83
|
staleTime = isPowerSync ? 0 : 3e4,
|
|
@@ -92,13 +90,12 @@ function useDbQuery(table, options = {}) {
|
|
|
92
90
|
...queryOptions
|
|
93
91
|
} = options;
|
|
94
92
|
const adapter = useMemo(() => {
|
|
95
|
-
if (!status.isInitialized) return null;
|
|
96
93
|
try {
|
|
97
94
|
return registry.getAdapter(tableName);
|
|
98
95
|
} catch {
|
|
99
96
|
return null;
|
|
100
97
|
}
|
|
101
|
-
}, [registry, tableName
|
|
98
|
+
}, [registry, tableName]);
|
|
102
99
|
const queryKey = useMemo(() => buildQueryKey(tableName, options), [tableName, serializeQueryOptions(options)]);
|
|
103
100
|
const memoizedQueryOptions = useMemo(() => ({
|
|
104
101
|
select: queryOptions.select,
|
|
@@ -117,14 +114,14 @@ function useDbQuery(table, options = {}) {
|
|
|
117
114
|
const query = useQuery({
|
|
118
115
|
queryKey,
|
|
119
116
|
queryFn,
|
|
120
|
-
enabled: enabled &&
|
|
117
|
+
enabled: enabled && adapter !== null,
|
|
121
118
|
staleTime,
|
|
122
119
|
gcTime,
|
|
123
120
|
refetchOnWindowFocus,
|
|
124
121
|
refetchOnMount
|
|
125
122
|
});
|
|
126
123
|
useEffect(() => {
|
|
127
|
-
if (!realtime || !adapter?.subscribe
|
|
124
|
+
if (!realtime || !adapter?.subscribe) {
|
|
128
125
|
return;
|
|
129
126
|
}
|
|
130
127
|
let isFirstCallback = true;
|
|
@@ -148,7 +145,7 @@ function useDbQuery(table, options = {}) {
|
|
|
148
145
|
return () => {
|
|
149
146
|
unsubscribe();
|
|
150
147
|
};
|
|
151
|
-
}, [realtime, adapter, tableName, memoizedQueryOptions, queryClient, queryKey
|
|
148
|
+
}, [realtime, adapter, tableName, memoizedQueryOptions, queryClient, queryKey]);
|
|
152
149
|
const refetch = useCallback(async () => {
|
|
153
150
|
await query.refetch();
|
|
154
151
|
}, [query]);
|
|
@@ -179,22 +176,18 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
179
176
|
const {
|
|
180
177
|
registry
|
|
181
178
|
} = useDataLayerCore();
|
|
182
|
-
const {
|
|
183
|
-
status
|
|
184
|
-
} = useDataLayerStatus();
|
|
185
179
|
const {
|
|
186
180
|
select,
|
|
187
181
|
enabled = id != null,
|
|
188
182
|
staleTime = 3e4
|
|
189
183
|
} = options;
|
|
190
184
|
const adapter = useMemo2(() => {
|
|
191
|
-
if (!status.isInitialized) return null;
|
|
192
185
|
try {
|
|
193
186
|
return registry.getAdapter(table);
|
|
194
187
|
} catch {
|
|
195
188
|
return null;
|
|
196
189
|
}
|
|
197
|
-
}, [registry, table
|
|
190
|
+
}, [registry, table]);
|
|
198
191
|
const queryKey = useMemo2(() => buildQueryKey2(table, id, select), [table, id, select]);
|
|
199
192
|
const queryFn = useCallback2(async () => {
|
|
200
193
|
if (!adapter) {
|
|
@@ -220,7 +213,7 @@ function useDbQueryById(table, id, options = {}) {
|
|
|
220
213
|
const query = useQuery2({
|
|
221
214
|
queryKey,
|
|
222
215
|
queryFn,
|
|
223
|
-
enabled: enabled &&
|
|
216
|
+
enabled: enabled && adapter !== null && id != null,
|
|
224
217
|
staleTime
|
|
225
218
|
});
|
|
226
219
|
const refetch = useCallback2(async () => {
|
|
@@ -252,11 +245,9 @@ function useAdvanceQuery(table, options) {
|
|
|
252
245
|
const tableName = typeof table === "string" ? table : `${table.schema}.${table.table}`;
|
|
253
246
|
const {
|
|
254
247
|
registry,
|
|
255
|
-
queryClient
|
|
248
|
+
queryClient,
|
|
249
|
+
powerSync
|
|
256
250
|
} = useDataLayerCore();
|
|
257
|
-
const {
|
|
258
|
-
status
|
|
259
|
-
} = useDataLayerStatus();
|
|
260
251
|
const supabase = useSupabase();
|
|
261
252
|
const {
|
|
262
253
|
filterKey,
|
|
@@ -272,7 +263,7 @@ function useAdvanceQuery(table, options) {
|
|
|
272
263
|
offset,
|
|
273
264
|
...restOptions
|
|
274
265
|
} = options;
|
|
275
|
-
const isPowerSync =
|
|
266
|
+
const isPowerSync = powerSync !== null;
|
|
276
267
|
const realtimeEnabled = realtime ?? isPowerSync;
|
|
277
268
|
const defaultFilterState = useMemo3(
|
|
278
269
|
() => initialFilters ?? createDefaultFilterState(),
|
|
@@ -311,7 +302,7 @@ function useAdvanceQuery(table, options) {
|
|
|
311
302
|
// Enable watch() subscriptions for reactive updates
|
|
312
303
|
});
|
|
313
304
|
const [extraData, setExtraData] = useState({});
|
|
314
|
-
const edgeFunctionQueryKey = useMemo3(() => ["v3", "advance-query", tableName, select, JSON.stringify(where), JSON.stringify(filters)
|
|
305
|
+
const edgeFunctionQueryKey = useMemo3(() => ["v3", "advance-query", tableName, select, JSON.stringify(where), JSON.stringify(filters)], [tableName, select, where, filters]);
|
|
315
306
|
const edgeFunctionResult = useQuery3({
|
|
316
307
|
queryKey: edgeFunctionQueryKey,
|
|
317
308
|
queryFn: async ({
|
|
@@ -488,9 +479,6 @@ function useDbInsert(table, t0) {
|
|
|
488
479
|
const {
|
|
489
480
|
registry
|
|
490
481
|
} = useDataLayerCore();
|
|
491
|
-
const {
|
|
492
|
-
status
|
|
493
|
-
} = useDataLayerStatus();
|
|
494
482
|
const queryClient = useQueryClient();
|
|
495
483
|
const {
|
|
496
484
|
onSuccess,
|
|
@@ -508,25 +496,19 @@ function useDbInsert(table, t0) {
|
|
|
508
496
|
}
|
|
509
497
|
const invalidateTables = t3;
|
|
510
498
|
let t4;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
$[5] = registry;
|
|
521
|
-
$[6] = table;
|
|
522
|
-
$[7] = t52;
|
|
523
|
-
} else {
|
|
524
|
-
t52 = $[7];
|
|
525
|
-
}
|
|
526
|
-
t4 = t52;
|
|
527
|
-
} catch {
|
|
528
|
-
t4 = null;
|
|
499
|
+
try {
|
|
500
|
+
let t52;
|
|
501
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
502
|
+
t52 = registry.getAdapter(table);
|
|
503
|
+
$[5] = registry;
|
|
504
|
+
$[6] = table;
|
|
505
|
+
$[7] = t52;
|
|
506
|
+
} else {
|
|
507
|
+
t52 = $[7];
|
|
529
508
|
}
|
|
509
|
+
t4 = t52;
|
|
510
|
+
} catch {
|
|
511
|
+
t4 = null;
|
|
530
512
|
}
|
|
531
513
|
const adapter = t4;
|
|
532
514
|
let t5;
|
|
@@ -627,9 +609,6 @@ function useDbUpdate(table, t0) {
|
|
|
627
609
|
const {
|
|
628
610
|
registry
|
|
629
611
|
} = useDataLayerCore();
|
|
630
|
-
const {
|
|
631
|
-
status
|
|
632
|
-
} = useDataLayerStatus();
|
|
633
612
|
const queryClient = useQueryClient2();
|
|
634
613
|
const {
|
|
635
614
|
onSuccess,
|
|
@@ -649,25 +628,19 @@ function useDbUpdate(table, t0) {
|
|
|
649
628
|
const invalidateTables = t4;
|
|
650
629
|
const optimistic = t3 === void 0 ? false : t3;
|
|
651
630
|
let t5;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
$[5] = registry;
|
|
662
|
-
$[6] = table;
|
|
663
|
-
$[7] = t62;
|
|
664
|
-
} else {
|
|
665
|
-
t62 = $[7];
|
|
666
|
-
}
|
|
667
|
-
t5 = t62;
|
|
668
|
-
} catch {
|
|
669
|
-
t5 = null;
|
|
631
|
+
try {
|
|
632
|
+
let t62;
|
|
633
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
634
|
+
t62 = registry.getAdapter(table);
|
|
635
|
+
$[5] = registry;
|
|
636
|
+
$[6] = table;
|
|
637
|
+
$[7] = t62;
|
|
638
|
+
} else {
|
|
639
|
+
t62 = $[7];
|
|
670
640
|
}
|
|
641
|
+
t5 = t62;
|
|
642
|
+
} catch {
|
|
643
|
+
t5 = null;
|
|
671
644
|
}
|
|
672
645
|
const adapter = t5;
|
|
673
646
|
let t6;
|
|
@@ -798,9 +771,6 @@ function useDbUpsert(table, t0) {
|
|
|
798
771
|
const {
|
|
799
772
|
registry
|
|
800
773
|
} = useDataLayerCore();
|
|
801
|
-
const {
|
|
802
|
-
status
|
|
803
|
-
} = useDataLayerStatus();
|
|
804
774
|
const queryClient = useQueryClient3();
|
|
805
775
|
const {
|
|
806
776
|
onSuccess,
|
|
@@ -818,36 +788,29 @@ function useDbUpsert(table, t0) {
|
|
|
818
788
|
}
|
|
819
789
|
const invalidateTables = t3;
|
|
820
790
|
let t4;
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
791
|
+
;
|
|
792
|
+
try {
|
|
793
|
+
let t62;
|
|
794
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
795
|
+
t62 = registry.getAdapter(table);
|
|
796
|
+
$[5] = registry;
|
|
797
|
+
$[6] = table;
|
|
798
|
+
$[7] = t62;
|
|
799
|
+
} else {
|
|
800
|
+
t62 = $[7];
|
|
825
801
|
}
|
|
826
|
-
;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
$[5] = registry;
|
|
832
|
-
$[6] = table;
|
|
833
|
-
$[7] = t62;
|
|
834
|
-
} else {
|
|
835
|
-
t62 = $[7];
|
|
836
|
-
}
|
|
837
|
-
const resolvedAdapter = t62;
|
|
838
|
-
t4 = resolvedAdapter;
|
|
839
|
-
} catch (t52) {
|
|
840
|
-
const error = t52;
|
|
841
|
-
if (__DEV__) {
|
|
842
|
-
console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
|
|
843
|
-
}
|
|
844
|
-
t4 = null;
|
|
802
|
+
t4 = t62;
|
|
803
|
+
} catch (t5) {
|
|
804
|
+
const error = t5;
|
|
805
|
+
if (__DEV__) {
|
|
806
|
+
console.warn(`[useDbUpsert] Failed to get adapter for table "${table}":`, error);
|
|
845
807
|
}
|
|
808
|
+
t4 = null;
|
|
846
809
|
}
|
|
847
810
|
const adapter = t4;
|
|
848
|
-
let
|
|
811
|
+
let t6;
|
|
849
812
|
if ($[8] !== adapter || $[9] !== table) {
|
|
850
|
-
|
|
813
|
+
t6 = async (data) => {
|
|
851
814
|
if (__DEV__) {
|
|
852
815
|
console.log(`[useDbUpsert] mutationFn called for table "${table}":`, {
|
|
853
816
|
adapterName: adapter?.name ?? "null",
|
|
@@ -869,14 +832,14 @@ function useDbUpsert(table, t0) {
|
|
|
869
832
|
};
|
|
870
833
|
$[8] = adapter;
|
|
871
834
|
$[9] = table;
|
|
872
|
-
$[10] =
|
|
835
|
+
$[10] = t6;
|
|
873
836
|
} else {
|
|
874
|
-
|
|
837
|
+
t6 = $[10];
|
|
875
838
|
}
|
|
876
|
-
const mutationFn =
|
|
877
|
-
let
|
|
839
|
+
const mutationFn = t6;
|
|
840
|
+
let t7;
|
|
878
841
|
if ($[11] !== invalidateTables || $[12] !== onSuccess || $[13] !== queryClient) {
|
|
879
|
-
|
|
842
|
+
t7 = (data_0) => {
|
|
880
843
|
invalidateTables.forEach((t) => {
|
|
881
844
|
queryClient.invalidateQueries({
|
|
882
845
|
predicate: (query) => query.queryKey[0] === "v3" && query.queryKey[2] === t
|
|
@@ -887,43 +850,43 @@ function useDbUpsert(table, t0) {
|
|
|
887
850
|
$[11] = invalidateTables;
|
|
888
851
|
$[12] = onSuccess;
|
|
889
852
|
$[13] = queryClient;
|
|
890
|
-
$[14] =
|
|
853
|
+
$[14] = t7;
|
|
891
854
|
} else {
|
|
892
|
-
|
|
855
|
+
t7 = $[14];
|
|
893
856
|
}
|
|
894
|
-
let
|
|
857
|
+
let t8;
|
|
895
858
|
if ($[15] !== onError) {
|
|
896
|
-
|
|
859
|
+
t8 = (error_0) => {
|
|
897
860
|
onError?.(error_0 instanceof Error ? error_0 : new Error(String(error_0)));
|
|
898
861
|
};
|
|
899
862
|
$[15] = onError;
|
|
900
|
-
$[16] =
|
|
863
|
+
$[16] = t8;
|
|
901
864
|
} else {
|
|
902
|
-
|
|
865
|
+
t8 = $[16];
|
|
903
866
|
}
|
|
904
|
-
let
|
|
905
|
-
if ($[17] !== mutationFn || $[18] !==
|
|
906
|
-
|
|
867
|
+
let t9;
|
|
868
|
+
if ($[17] !== mutationFn || $[18] !== t7 || $[19] !== t8) {
|
|
869
|
+
t9 = {
|
|
907
870
|
mutationFn,
|
|
908
|
-
onSuccess:
|
|
909
|
-
onError:
|
|
871
|
+
onSuccess: t7,
|
|
872
|
+
onError: t8
|
|
910
873
|
};
|
|
911
874
|
$[17] = mutationFn;
|
|
912
|
-
$[18] =
|
|
913
|
-
$[19] =
|
|
914
|
-
$[20] =
|
|
875
|
+
$[18] = t7;
|
|
876
|
+
$[19] = t8;
|
|
877
|
+
$[20] = t9;
|
|
915
878
|
} else {
|
|
916
|
-
|
|
879
|
+
t9 = $[20];
|
|
917
880
|
}
|
|
918
|
-
const mutation = useMutation3(
|
|
919
|
-
const
|
|
920
|
-
let
|
|
921
|
-
if ($[21] !== mutation.data || $[22] !== mutation.isPending || $[23] !== mutation.mutate || $[24] !== mutation.mutateAsync || $[25] !== mutation.reset || $[26] !==
|
|
922
|
-
|
|
881
|
+
const mutation = useMutation3(t9);
|
|
882
|
+
const t10 = mutation.error;
|
|
883
|
+
let t11;
|
|
884
|
+
if ($[21] !== mutation.data || $[22] !== mutation.isPending || $[23] !== mutation.mutate || $[24] !== mutation.mutateAsync || $[25] !== mutation.reset || $[26] !== t10) {
|
|
885
|
+
t11 = {
|
|
923
886
|
mutate: mutation.mutate,
|
|
924
887
|
mutateAsync: mutation.mutateAsync,
|
|
925
888
|
isPending: mutation.isPending,
|
|
926
|
-
error:
|
|
889
|
+
error: t10,
|
|
927
890
|
reset: mutation.reset,
|
|
928
891
|
data: mutation.data
|
|
929
892
|
};
|
|
@@ -932,12 +895,12 @@ function useDbUpsert(table, t0) {
|
|
|
932
895
|
$[23] = mutation.mutate;
|
|
933
896
|
$[24] = mutation.mutateAsync;
|
|
934
897
|
$[25] = mutation.reset;
|
|
935
|
-
$[26] =
|
|
936
|
-
$[27] =
|
|
898
|
+
$[26] = t10;
|
|
899
|
+
$[27] = t11;
|
|
937
900
|
} else {
|
|
938
|
-
|
|
901
|
+
t11 = $[27];
|
|
939
902
|
}
|
|
940
|
-
return
|
|
903
|
+
return t11;
|
|
941
904
|
}
|
|
942
905
|
|
|
943
906
|
// src/hooks/useDbDelete.ts
|
|
@@ -957,9 +920,6 @@ function useDbDelete(table, t0) {
|
|
|
957
920
|
const {
|
|
958
921
|
registry
|
|
959
922
|
} = useDataLayerCore();
|
|
960
|
-
const {
|
|
961
|
-
status
|
|
962
|
-
} = useDataLayerStatus();
|
|
963
923
|
const queryClient = useQueryClient4();
|
|
964
924
|
const {
|
|
965
925
|
onSuccess,
|
|
@@ -979,25 +939,19 @@ function useDbDelete(table, t0) {
|
|
|
979
939
|
const invalidateTables = t4;
|
|
980
940
|
const optimistic = t3 === void 0 ? false : t3;
|
|
981
941
|
let t5;
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
$[5] = registry;
|
|
992
|
-
$[6] = table;
|
|
993
|
-
$[7] = t62;
|
|
994
|
-
} else {
|
|
995
|
-
t62 = $[7];
|
|
996
|
-
}
|
|
997
|
-
t5 = t62;
|
|
998
|
-
} catch {
|
|
999
|
-
t5 = null;
|
|
942
|
+
try {
|
|
943
|
+
let t62;
|
|
944
|
+
if ($[5] !== registry || $[6] !== table) {
|
|
945
|
+
t62 = registry.getAdapter(table);
|
|
946
|
+
$[5] = registry;
|
|
947
|
+
$[6] = table;
|
|
948
|
+
$[7] = t62;
|
|
949
|
+
} else {
|
|
950
|
+
t62 = $[7];
|
|
1000
951
|
}
|
|
952
|
+
t5 = t62;
|
|
953
|
+
} catch {
|
|
954
|
+
t5 = null;
|
|
1001
955
|
}
|
|
1002
956
|
const adapter = t5;
|
|
1003
957
|
let t6;
|
|
@@ -1163,9 +1117,6 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1163
1117
|
const {
|
|
1164
1118
|
registry
|
|
1165
1119
|
} = useDataLayerCore();
|
|
1166
|
-
const {
|
|
1167
|
-
status
|
|
1168
|
-
} = useDataLayerStatus();
|
|
1169
1120
|
const {
|
|
1170
1121
|
enabled = true,
|
|
1171
1122
|
staleTime = 3e4,
|
|
@@ -1176,13 +1127,12 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1176
1127
|
...queryOptions
|
|
1177
1128
|
} = options;
|
|
1178
1129
|
const adapter = useMemo4(() => {
|
|
1179
|
-
if (!status.isInitialized) return null;
|
|
1180
1130
|
try {
|
|
1181
1131
|
return registry.getAdapter(tableName);
|
|
1182
1132
|
} catch {
|
|
1183
1133
|
return null;
|
|
1184
1134
|
}
|
|
1185
|
-
}, [registry, tableName
|
|
1135
|
+
}, [registry, tableName]);
|
|
1186
1136
|
const queryKey = useMemo4(() => buildInfiniteQueryKey(tableName, options), [tableName, serializeInfiniteQueryOptions(options)]);
|
|
1187
1137
|
const effectiveWhere = useMemo4(() => {
|
|
1188
1138
|
if (searchText && searchFields && searchFields.length > 0) {
|
|
@@ -1226,7 +1176,7 @@ function useDbInfiniteQuery(table, options = {}) {
|
|
|
1226
1176
|
}
|
|
1227
1177
|
return allPages.length + 1;
|
|
1228
1178
|
},
|
|
1229
|
-
enabled: enabled &&
|
|
1179
|
+
enabled: enabled && adapter !== null,
|
|
1230
1180
|
staleTime,
|
|
1231
1181
|
refetchOnWindowFocus
|
|
1232
1182
|
});
|
|
@@ -1277,9 +1227,6 @@ function useDbCount(table, t0) {
|
|
|
1277
1227
|
const {
|
|
1278
1228
|
registry
|
|
1279
1229
|
} = useDataLayerCore();
|
|
1280
|
-
const {
|
|
1281
|
-
status
|
|
1282
|
-
} = useDataLayerStatus();
|
|
1283
1230
|
const {
|
|
1284
1231
|
enabled: t2,
|
|
1285
1232
|
staleTime: t3,
|
|
@@ -1288,25 +1235,19 @@ function useDbCount(table, t0) {
|
|
|
1288
1235
|
const enabled = t2 === void 0 ? true : t2;
|
|
1289
1236
|
const staleTime = t3 === void 0 ? 3e4 : t3;
|
|
1290
1237
|
let t4;
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
$[2] = registry;
|
|
1301
|
-
$[3] = table;
|
|
1302
|
-
$[4] = t52;
|
|
1303
|
-
} else {
|
|
1304
|
-
t52 = $[4];
|
|
1305
|
-
}
|
|
1306
|
-
t4 = t52;
|
|
1307
|
-
} catch {
|
|
1308
|
-
t4 = null;
|
|
1238
|
+
try {
|
|
1239
|
+
let t52;
|
|
1240
|
+
if ($[2] !== registry || $[3] !== table) {
|
|
1241
|
+
t52 = registry.getAdapter(table);
|
|
1242
|
+
$[2] = registry;
|
|
1243
|
+
$[3] = table;
|
|
1244
|
+
$[4] = t52;
|
|
1245
|
+
} else {
|
|
1246
|
+
t52 = $[4];
|
|
1309
1247
|
}
|
|
1248
|
+
t4 = t52;
|
|
1249
|
+
} catch {
|
|
1250
|
+
t4 = null;
|
|
1310
1251
|
}
|
|
1311
1252
|
const adapter = t4;
|
|
1312
1253
|
let t5;
|
|
@@ -1347,7 +1288,7 @@ function useDbCount(table, t0) {
|
|
|
1347
1288
|
t7 = $[13];
|
|
1348
1289
|
}
|
|
1349
1290
|
const queryFn = t7;
|
|
1350
|
-
const t8 = enabled &&
|
|
1291
|
+
const t8 = enabled && adapter !== null;
|
|
1351
1292
|
let t9;
|
|
1352
1293
|
if ($[14] !== queryFn || $[15] !== queryKey || $[16] !== staleTime || $[17] !== t8) {
|
|
1353
1294
|
t9 = {
|
|
@@ -1483,25 +1424,22 @@ function notifyFailedUploadListeners() {
|
|
|
1483
1424
|
failedUploadListeners.forEach((listener) => listener());
|
|
1484
1425
|
}
|
|
1485
1426
|
function useSyncControl() {
|
|
1486
|
-
const $ = _c7(
|
|
1487
|
-
const statusContext = useContext3(DataLayerStatusContext);
|
|
1427
|
+
const $ = _c7(11);
|
|
1488
1428
|
const coreContext = useContext3(DataLayerCoreContext);
|
|
1489
|
-
if (!
|
|
1429
|
+
if (!coreContext) {
|
|
1490
1430
|
throw new Error("useSyncControl must be used within a DataLayerProvider. Make sure you have wrapped your app with <DataLayerProvider>.");
|
|
1491
1431
|
}
|
|
1492
1432
|
const {
|
|
1493
1433
|
syncControl,
|
|
1494
|
-
status
|
|
1495
|
-
} = statusContext;
|
|
1496
|
-
const {
|
|
1497
1434
|
powerSync
|
|
1498
1435
|
} = coreContext;
|
|
1436
|
+
const isPowerSyncActive = powerSync !== null;
|
|
1499
1437
|
const [isAutoRetryPaused, setIsAutoRetryPaused] = useState3(false);
|
|
1500
1438
|
const failedUploads = useSyncExternalStore(subscribeToFailedUploads, getFailedUploadsSnapshot, _temp);
|
|
1501
1439
|
let t0;
|
|
1502
|
-
if ($[0] !==
|
|
1440
|
+
if ($[0] !== isPowerSyncActive || $[1] !== syncControl) {
|
|
1503
1441
|
t0 = async () => {
|
|
1504
|
-
if (!
|
|
1442
|
+
if (!isPowerSyncActive) {
|
|
1505
1443
|
console.warn("[useSyncControl] retryFailedUploads called but PowerSync is not available");
|
|
1506
1444
|
return;
|
|
1507
1445
|
}
|
|
@@ -1513,39 +1451,38 @@ function useSyncControl() {
|
|
|
1513
1451
|
notifyFailedUploadListeners();
|
|
1514
1452
|
await syncControl.triggerSync();
|
|
1515
1453
|
};
|
|
1516
|
-
$[0] =
|
|
1517
|
-
$[1] =
|
|
1518
|
-
$[2] =
|
|
1519
|
-
$[3] = t0;
|
|
1454
|
+
$[0] = isPowerSyncActive;
|
|
1455
|
+
$[1] = syncControl;
|
|
1456
|
+
$[2] = t0;
|
|
1520
1457
|
} else {
|
|
1521
|
-
t0 = $[
|
|
1458
|
+
t0 = $[2];
|
|
1522
1459
|
}
|
|
1523
1460
|
const retryFailedUploads = t0;
|
|
1524
1461
|
const clearFailedUploads = _temp2;
|
|
1525
1462
|
let t1;
|
|
1526
|
-
if ($[
|
|
1463
|
+
if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1527
1464
|
t1 = () => {
|
|
1528
1465
|
setIsAutoRetryPaused(true);
|
|
1529
1466
|
console.log("[useSyncControl] Auto-retry paused");
|
|
1530
1467
|
};
|
|
1531
|
-
$[
|
|
1468
|
+
$[3] = t1;
|
|
1532
1469
|
} else {
|
|
1533
|
-
t1 = $[
|
|
1470
|
+
t1 = $[3];
|
|
1534
1471
|
}
|
|
1535
1472
|
const pauseAutoRetry = t1;
|
|
1536
1473
|
let t2;
|
|
1537
|
-
if ($[
|
|
1474
|
+
if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1538
1475
|
t2 = () => {
|
|
1539
1476
|
setIsAutoRetryPaused(false);
|
|
1540
1477
|
console.log("[useSyncControl] Auto-retry resumed");
|
|
1541
1478
|
};
|
|
1542
|
-
$[
|
|
1479
|
+
$[4] = t2;
|
|
1543
1480
|
} else {
|
|
1544
|
-
t2 = $[
|
|
1481
|
+
t2 = $[4];
|
|
1545
1482
|
}
|
|
1546
1483
|
const resumeAutoRetry = t2;
|
|
1547
1484
|
let t3;
|
|
1548
|
-
if ($[
|
|
1485
|
+
if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
1549
1486
|
t3 = {
|
|
1550
1487
|
triggerSync: _temp3,
|
|
1551
1488
|
startLiveSync: _temp4,
|
|
@@ -1558,16 +1495,16 @@ function useSyncControl() {
|
|
|
1558
1495
|
resumeAutoRetry: _temp0,
|
|
1559
1496
|
isAutoRetryPaused: false
|
|
1560
1497
|
};
|
|
1561
|
-
$[
|
|
1498
|
+
$[5] = t3;
|
|
1562
1499
|
} else {
|
|
1563
|
-
t3 = $[
|
|
1500
|
+
t3 = $[5];
|
|
1564
1501
|
}
|
|
1565
1502
|
const noOpControls = t3;
|
|
1566
1503
|
let t4;
|
|
1567
1504
|
bb0: {
|
|
1568
|
-
if (
|
|
1505
|
+
if (isPowerSyncActive) {
|
|
1569
1506
|
let t5;
|
|
1570
|
-
if ($[
|
|
1507
|
+
if ($[6] !== failedUploads || $[7] !== isAutoRetryPaused || $[8] !== retryFailedUploads || $[9] !== syncControl) {
|
|
1571
1508
|
t5 = {
|
|
1572
1509
|
...syncControl,
|
|
1573
1510
|
retryFailedUploads,
|
|
@@ -1577,13 +1514,13 @@ function useSyncControl() {
|
|
|
1577
1514
|
resumeAutoRetry,
|
|
1578
1515
|
isAutoRetryPaused
|
|
1579
1516
|
};
|
|
1580
|
-
$[
|
|
1581
|
-
$[
|
|
1582
|
-
$[
|
|
1583
|
-
$[
|
|
1584
|
-
$[
|
|
1517
|
+
$[6] = failedUploads;
|
|
1518
|
+
$[7] = isAutoRetryPaused;
|
|
1519
|
+
$[8] = retryFailedUploads;
|
|
1520
|
+
$[9] = syncControl;
|
|
1521
|
+
$[10] = t5;
|
|
1585
1522
|
} else {
|
|
1586
|
-
t5 = $[
|
|
1523
|
+
t5 = $[10];
|
|
1587
1524
|
}
|
|
1588
1525
|
t4 = t5;
|
|
1589
1526
|
break bb0;
|
|
@@ -1678,4 +1615,4 @@ export {
|
|
|
1678
1615
|
useSyncControl,
|
|
1679
1616
|
useOnlineStatus
|
|
1680
1617
|
};
|
|
1681
|
-
//# sourceMappingURL=chunk-
|
|
1618
|
+
//# sourceMappingURL=chunk-LVUK5USN.js.map
|