@pol-studios/db 1.0.11 → 1.0.13

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 (32) hide show
  1. package/dist/{DataLayerContext-CL6alnkb.d.ts → DataLayerContext-Cm1nAvT7.d.ts} +55 -3
  2. package/dist/auth/context.js +2 -2
  3. package/dist/auth/hooks.js +3 -3
  4. package/dist/auth/index.js +3 -3
  5. package/dist/{chunk-DJ6VLEAL.js → chunk-3KLFEVN4.js} +2 -2
  6. package/dist/{chunk-LNJ3WF7V.js → chunk-HSSYOLI6.js} +4 -4
  7. package/dist/{chunk-XU3SBFAG.js → chunk-MOYWSMXW.js} +34 -7
  8. package/dist/chunk-MOYWSMXW.js.map +1 -0
  9. package/dist/{chunk-WGDJ4IXR.js → chunk-QAWFLRWC.js} +2 -2
  10. package/dist/{chunk-ZVBHWU7O.js → chunk-SSOQECSM.js} +43 -6
  11. package/dist/chunk-SSOQECSM.js.map +1 -0
  12. package/dist/{chunk-NZON56CB.js → chunk-YHUGHEF6.js} +3 -3
  13. package/dist/hooks/index.d.ts +12 -2
  14. package/dist/hooks/index.js +5 -1
  15. package/dist/{index-CQLyNG6A.d.ts → index-BHFInYVr.d.ts} +1 -1
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +14 -6
  18. package/dist/index.native.d.ts +5 -5
  19. package/dist/index.native.js +10 -6
  20. package/dist/index.web.d.ts +5 -5
  21. package/dist/index.web.js +5 -5
  22. package/dist/types/index.d.ts +2 -2
  23. package/dist/{useDbCount-BG356T9i.d.ts → useDbCount-Cu2Q5ZdH.d.ts} +64 -6
  24. package/dist/{useResolveFeedback-BWmatBlE.d.ts → useResolveFeedback-Bg3JDRs8.d.ts} +3 -3
  25. package/dist/with-auth/index.js +4 -4
  26. package/package.json +1 -1
  27. package/dist/chunk-XU3SBFAG.js.map +0 -1
  28. package/dist/chunk-ZVBHWU7O.js.map +0 -1
  29. /package/dist/{chunk-DJ6VLEAL.js.map → chunk-3KLFEVN4.js.map} +0 -0
  30. /package/dist/{chunk-LNJ3WF7V.js.map → chunk-HSSYOLI6.js.map} +0 -0
  31. /package/dist/{chunk-WGDJ4IXR.js.map → chunk-QAWFLRWC.js.map} +0 -0
  32. /package/dist/{chunk-NZON56CB.js.map → chunk-YHUGHEF6.js.map} +0 -0
@@ -722,7 +722,44 @@ interface DataLayerStatus {
722
722
  hasSynced: boolean;
723
723
  }
724
724
  /**
725
- * Context value for the data layer
725
+ * STABLE core context - values that don't change after initialization
726
+ *
727
+ * Use useDataLayerCore() to access these values in query/mutation hooks
728
+ * to avoid re-renders when sync status changes.
729
+ */
730
+ interface DataLayerCoreContextValue {
731
+ /** Adapter registry for getting table adapters */
732
+ registry: AdapterRegistry;
733
+ /** Get adapter for a specific table */
734
+ getAdapter: (table: string) => TableDataAdapter;
735
+ /** PowerSync database instance (null when not available) */
736
+ powerSync: PowerSyncDatabase | null;
737
+ /** Supabase client (always available) */
738
+ supabase: SupabaseClient;
739
+ /** React Query client */
740
+ queryClient: QueryClient;
741
+ /** Database schema */
742
+ schema: DatabaseSchema;
743
+ }
744
+ /**
745
+ * DYNAMIC status context - values that change during runtime
746
+ *
747
+ * Use useDataLayerStatus() for UI components that display sync status,
748
+ * online indicator, etc. Components using this WILL re-render when status changes.
749
+ */
750
+ interface DataLayerStatusContextValue {
751
+ /** Current status */
752
+ status: DataLayerStatus;
753
+ /** Sync status (for PowerSync, no-op for Supabase-only) */
754
+ syncStatus: SyncStatus;
755
+ /** Sync controls (for PowerSync, no-op for Supabase-only) */
756
+ syncControl: SyncControl;
757
+ }
758
+ /**
759
+ * Context value for the data layer (combines core and status)
760
+ *
761
+ * @deprecated Prefer using useDataLayerCore() or useDataLayerStatus() for better performance.
762
+ * This combined interface is kept for backward compatibility.
726
763
  */
727
764
  interface DataLayerContextValue {
728
765
  /** Adapter registry for getting table adapters */
@@ -745,11 +782,26 @@ interface DataLayerContextValue {
745
782
  syncControl: SyncControl;
746
783
  }
747
784
  /**
748
- * Data layer context
785
+ * STABLE Core context - values that don't change after initialization
786
+ *
787
+ * Use useDataLayerCore() hook to access. Components consuming this context
788
+ * will NOT re-render when sync status or network status changes.
789
+ */
790
+ declare const DataLayerCoreContext: react.Context<DataLayerCoreContextValue>;
791
+ /**
792
+ * DYNAMIC Status context - values that change during runtime
793
+ *
794
+ * Use useDataLayerStatus() hook to access. Components consuming this context
795
+ * WILL re-render when sync status or network status changes.
796
+ */
797
+ declare const DataLayerStatusContext: react.Context<DataLayerStatusContextValue>;
798
+ /**
799
+ * Combined data layer context (backward compatibility)
749
800
  *
801
+ * @deprecated Prefer using DataLayerCoreContext or DataLayerStatusContext for better performance.
750
802
  * Provides access to the V3 data layer throughout the React component tree.
751
803
  * Must be accessed via the useDataLayer hook or similar consumer.
752
804
  */
753
805
  declare const DataLayerContext: react.Context<DataLayerContextValue>;
754
806
 
755
- export { type AdapterQueryResult as A, BackendStatus as B, type CapableDataAdapter as C, DataLayerContext as D, type SyncStatusInfo as S, type TableDataAdapter as T, type AdapterConfig as a, type AdapterFactory as b, type AdapterCapabilities as c, type AdapterDependencies as d, type AdapterStrategyType as e, ADAPTER_STRATEGIES as f, AdapterRegistry as g, createAdapterRegistry as h, AdapterAutoDetector as i, createAdapterAutoDetector as j, type AutoDetectionResult as k, type AutoDetectorOptions as l, type BackendChangeListener as m, type DataLayerContextValue as n, type DataLayerStatus as o };
807
+ export { type AdapterQueryResult as A, BackendStatus as B, type CapableDataAdapter as C, DataLayerContext as D, type SyncStatusInfo as S, type TableDataAdapter as T, type AdapterConfig as a, type AdapterFactory as b, type AdapterCapabilities as c, type AdapterDependencies as d, type AdapterStrategyType as e, ADAPTER_STRATEGIES as f, AdapterRegistry as g, createAdapterRegistry as h, AdapterAutoDetector as i, createAdapterAutoDetector as j, type AutoDetectionResult as k, type AutoDetectorOptions as l, type BackendChangeListener as m, DataLayerCoreContext as n, DataLayerStatusContext as o, type DataLayerContextValue as p, type DataLayerCoreContextValue as q, type DataLayerStatusContextValue as r, type DataLayerStatus as s };
@@ -12,8 +12,8 @@ import {
12
12
  useUserMetadataState,
13
13
  useUserMetadataValue,
14
14
  userMetadataContext
15
- } from "../chunk-WGDJ4IXR.js";
16
- import "../chunk-ZVBHWU7O.js";
15
+ } from "../chunk-QAWFLRWC.js";
16
+ import "../chunk-SSOQECSM.js";
17
17
  import "../chunk-GC3TBUWE.js";
18
18
  import "../chunk-J4ZVCXZ4.js";
19
19
  import "../chunk-OQ7U6EQ3.js";
@@ -11,14 +11,14 @@ import {
11
11
  usePermissionLoading,
12
12
  usePermissionsBatch,
13
13
  useSetupAuth
14
- } from "../chunk-DJ6VLEAL.js";
14
+ } from "../chunk-3KLFEVN4.js";
15
15
  import {
16
16
  useSetUserMetadata,
17
17
  useUserMetadata,
18
18
  useUserMetadataState,
19
19
  useUserMetadataValue
20
- } from "../chunk-WGDJ4IXR.js";
21
- import "../chunk-ZVBHWU7O.js";
20
+ } from "../chunk-QAWFLRWC.js";
21
+ import "../chunk-SSOQECSM.js";
22
22
  import "../chunk-GC3TBUWE.js";
23
23
  import "../chunk-J4ZVCXZ4.js";
24
24
  import "../chunk-OQ7U6EQ3.js";
@@ -12,7 +12,7 @@ import {
12
12
  usePermissionLoading,
13
13
  usePermissionsBatch,
14
14
  useSetupAuth
15
- } from "../chunk-DJ6VLEAL.js";
15
+ } from "../chunk-3KLFEVN4.js";
16
16
  import {
17
17
  AuthProvider,
18
18
  PermissionProvider,
@@ -27,8 +27,8 @@ import {
27
27
  useUserMetadataState,
28
28
  useUserMetadataValue,
29
29
  userMetadataContext
30
- } from "../chunk-WGDJ4IXR.js";
31
- import "../chunk-ZVBHWU7O.js";
30
+ } from "../chunk-QAWFLRWC.js";
31
+ import "../chunk-SSOQECSM.js";
32
32
  import {
33
33
  hasAccess,
34
34
  hasAllAccess,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  permissionContext,
3
3
  setupAuthContext
4
- } from "./chunk-WGDJ4IXR.js";
4
+ } from "./chunk-QAWFLRWC.js";
5
5
  import {
6
6
  isUsable
7
7
  } from "./chunk-OQ7U6EQ3.js";
@@ -244,4 +244,4 @@ export {
244
244
  useInvalidatePermission,
245
245
  usePermissionLoading
246
246
  };
247
- //# sourceMappingURL=chunk-DJ6VLEAL.js.map
247
+ //# sourceMappingURL=chunk-3KLFEVN4.js.map
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-SM73S2DY.js";
4
4
  import {
5
5
  useSetupAuth
6
- } from "./chunk-DJ6VLEAL.js";
6
+ } from "./chunk-3KLFEVN4.js";
7
7
  import {
8
8
  useDbQuery
9
- } from "./chunk-WGDJ4IXR.js";
9
+ } from "./chunk-QAWFLRWC.js";
10
10
  import {
11
11
  useDbUpsert
12
- } from "./chunk-ZVBHWU7O.js";
12
+ } from "./chunk-SSOQECSM.js";
13
13
  import {
14
14
  delay,
15
15
  isNullOrWhitespace,
@@ -467,4 +467,4 @@ export {
467
467
  useSetUserMetadata,
468
468
  useUserMetadataState
469
469
  };
470
- //# sourceMappingURL=chunk-LNJ3WF7V.js.map
470
+ //# sourceMappingURL=chunk-HSSYOLI6.js.map
@@ -2,10 +2,12 @@ import {
2
2
  createAdapterAutoDetector,
3
3
  createAdapterRegistry,
4
4
  createSupabaseAdapter
5
- } from "./chunk-NZON56CB.js";
5
+ } from "./chunk-YHUGHEF6.js";
6
6
  import {
7
- DataLayerContext
8
- } from "./chunk-ZVBHWU7O.js";
7
+ DataLayerContext,
8
+ DataLayerCoreContext,
9
+ DataLayerStatusContext
10
+ } from "./chunk-SSOQECSM.js";
9
11
  import {
10
12
  QueryExecutor,
11
13
  extractRelationNames,
@@ -1790,16 +1792,41 @@ function DataLayerProvider({
1790
1792
  syncControl: defaultSyncControl
1791
1793
  };
1792
1794
  }, [registry, getAdapter, powerSyncInstance, supabaseClient, queryClient, config.schema, status]);
1793
- const contextValue = useMemo(() => buildContextValue(), [buildContextValue]);
1795
+ const coreContextValue = useMemo(() => {
1796
+ if (!status.isInitialized) return null;
1797
+ return {
1798
+ registry,
1799
+ getAdapter,
1800
+ powerSync: powerSyncInstance,
1801
+ supabase: supabaseClient,
1802
+ queryClient,
1803
+ schema: config.schema
1804
+ };
1805
+ }, [status.isInitialized, registry, getAdapter, powerSyncInstance, supabaseClient, queryClient, config.schema]);
1806
+ const statusContextValue = useMemo(() => {
1807
+ if (!status.isInitialized) return null;
1808
+ return {
1809
+ status,
1810
+ syncStatus: defaultSyncStatus,
1811
+ syncControl: defaultSyncControl
1812
+ };
1813
+ }, [status]);
1814
+ const contextValue = useMemo(() => {
1815
+ if (!coreContextValue || !statusContextValue) return null;
1816
+ return {
1817
+ ...coreContextValue,
1818
+ ...statusContextValue
1819
+ };
1820
+ }, [coreContextValue, statusContextValue]);
1794
1821
  useEffect(() => {
1795
1822
  return () => {
1796
1823
  registry.dispose();
1797
1824
  };
1798
1825
  }, [registry]);
1799
- if (!contextValue) {
1826
+ if (!contextValue || !coreContextValue || !statusContextValue) {
1800
1827
  return null;
1801
1828
  }
1802
- return /* @__PURE__ */ jsx(DataLayerContext.Provider, { value: contextValue, children });
1829
+ return /* @__PURE__ */ jsx(DataLayerCoreContext.Provider, { value: coreContextValue, children: /* @__PURE__ */ jsx(DataLayerStatusContext.Provider, { value: statusContextValue, children: /* @__PURE__ */ jsx(DataLayerContext.Provider, { value: contextValue, children }) }) });
1803
1830
  }
1804
1831
 
1805
1832
  // src/storage/use-supabase-upload.tsx
@@ -5202,4 +5229,4 @@ object-assign/index.js:
5202
5229
  @license MIT
5203
5230
  *)
5204
5231
  */
5205
- //# sourceMappingURL=chunk-XU3SBFAG.js.map
5232
+ //# sourceMappingURL=chunk-MOYWSMXW.js.map