@pol-studios/powersync 1.0.6 → 1.0.10

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 (128) hide show
  1. package/README.md +933 -0
  2. package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
  3. package/dist/attachments/index.d.ts +745 -332
  4. package/dist/attachments/index.js +152 -6
  5. package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
  6. package/dist/chunk-24RDMMCL.js +44 -0
  7. package/dist/chunk-24RDMMCL.js.map +1 -0
  8. package/dist/chunk-4TXTAEF2.js +2060 -0
  9. package/dist/chunk-4TXTAEF2.js.map +1 -0
  10. package/dist/chunk-63PXSPIN.js +358 -0
  11. package/dist/chunk-63PXSPIN.js.map +1 -0
  12. package/dist/chunk-654ERHA7.js +1 -0
  13. package/dist/chunk-A4IBBWGO.js +377 -0
  14. package/dist/chunk-A4IBBWGO.js.map +1 -0
  15. package/dist/chunk-BRXQNASY.js +1720 -0
  16. package/dist/chunk-BRXQNASY.js.map +1 -0
  17. package/dist/chunk-CAB26E6F.js +142 -0
  18. package/dist/chunk-CAB26E6F.js.map +1 -0
  19. package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
  20. package/dist/chunk-CGL33PL4.js.map +1 -0
  21. package/dist/{chunk-R4YFWQ3Q.js → chunk-CUCAYK7Z.js} +309 -92
  22. package/dist/chunk-CUCAYK7Z.js.map +1 -0
  23. package/dist/chunk-FV2HXEIY.js +124 -0
  24. package/dist/chunk-FV2HXEIY.js.map +1 -0
  25. package/dist/chunk-HWSNV45P.js +279 -0
  26. package/dist/chunk-HWSNV45P.js.map +1 -0
  27. package/dist/{chunk-62J2DPKX.js → chunk-KN2IZERF.js} +530 -413
  28. package/dist/chunk-KN2IZERF.js.map +1 -0
  29. package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
  30. package/dist/chunk-N75DEF5J.js.map +1 -0
  31. package/dist/chunk-P4HZA6ZT.js +83 -0
  32. package/dist/chunk-P4HZA6ZT.js.map +1 -0
  33. package/dist/chunk-P6WOZO7H.js +49 -0
  34. package/dist/chunk-P6WOZO7H.js.map +1 -0
  35. package/dist/chunk-T4AO7JIG.js +1 -0
  36. package/dist/chunk-TGBT5XBE.js +1 -0
  37. package/dist/{chunk-FPTDATY5.js → chunk-VACPAAQZ.js} +54 -12
  38. package/dist/chunk-VACPAAQZ.js.map +1 -0
  39. package/dist/chunk-WGHNIAF7.js +329 -0
  40. package/dist/chunk-WGHNIAF7.js.map +1 -0
  41. package/dist/{chunk-3AYXHQ4W.js → chunk-WN5ZJ3E2.js} +108 -47
  42. package/dist/chunk-WN5ZJ3E2.js.map +1 -0
  43. package/dist/chunk-XAEII4ZX.js +456 -0
  44. package/dist/chunk-XAEII4ZX.js.map +1 -0
  45. package/dist/chunk-XOY2CJ67.js +289 -0
  46. package/dist/chunk-XOY2CJ67.js.map +1 -0
  47. package/dist/chunk-YHTZ7VMV.js +1 -0
  48. package/dist/chunk-YSTEESEG.js +676 -0
  49. package/dist/chunk-YSTEESEG.js.map +1 -0
  50. package/dist/chunk-Z6VOBGTU.js +32 -0
  51. package/dist/chunk-Z6VOBGTU.js.map +1 -0
  52. package/dist/chunk-ZM4ENYMF.js +230 -0
  53. package/dist/chunk-ZM4ENYMF.js.map +1 -0
  54. package/dist/connector/index.d.ts +236 -4
  55. package/dist/connector/index.js +15 -4
  56. package/dist/core/index.d.ts +16 -3
  57. package/dist/core/index.js +6 -2
  58. package/dist/error/index.d.ts +54 -0
  59. package/dist/error/index.js +7 -0
  60. package/dist/error/index.js.map +1 -0
  61. package/dist/index.d.ts +102 -12
  62. package/dist/index.js +309 -37
  63. package/dist/index.native.d.ts +22 -10
  64. package/dist/index.native.js +309 -38
  65. package/dist/index.web.d.ts +22 -10
  66. package/dist/index.web.js +310 -38
  67. package/dist/maintenance/index.d.ts +118 -0
  68. package/dist/maintenance/index.js +16 -0
  69. package/dist/maintenance/index.js.map +1 -0
  70. package/dist/platform/index.d.ts +16 -1
  71. package/dist/platform/index.js.map +1 -1
  72. package/dist/platform/index.native.d.ts +2 -2
  73. package/dist/platform/index.native.js +1 -1
  74. package/dist/platform/index.web.d.ts +1 -1
  75. package/dist/platform/index.web.js +1 -1
  76. package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
  77. package/dist/provider/index.d.ts +451 -21
  78. package/dist/provider/index.js +32 -13
  79. package/dist/react/index.d.ts +372 -0
  80. package/dist/react/index.js +25 -0
  81. package/dist/react/index.js.map +1 -0
  82. package/dist/storage/index.d.ts +6 -0
  83. package/dist/storage/index.js +42 -0
  84. package/dist/storage/index.js.map +1 -0
  85. package/dist/storage/index.native.d.ts +6 -0
  86. package/dist/storage/index.native.js +40 -0
  87. package/dist/storage/index.native.js.map +1 -0
  88. package/dist/storage/index.web.d.ts +6 -0
  89. package/dist/storage/index.web.js +40 -0
  90. package/dist/storage/index.web.js.map +1 -0
  91. package/dist/storage/upload/index.d.ts +54 -0
  92. package/dist/storage/upload/index.js +15 -0
  93. package/dist/storage/upload/index.js.map +1 -0
  94. package/dist/storage/upload/index.native.d.ts +56 -0
  95. package/dist/storage/upload/index.native.js +15 -0
  96. package/dist/storage/upload/index.native.js.map +1 -0
  97. package/dist/storage/upload/index.web.d.ts +2 -0
  98. package/dist/storage/upload/index.web.js +14 -0
  99. package/dist/storage/upload/index.web.js.map +1 -0
  100. package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
  101. package/dist/sync/index.d.ts +288 -23
  102. package/dist/sync/index.js +22 -10
  103. package/dist/{index-l3iL9Jte.d.ts → types-B212hgfA.d.ts} +101 -158
  104. package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
  105. package/dist/types-CyvBaAl8.d.ts +60 -0
  106. package/dist/types-D0WcHrq6.d.ts +234 -0
  107. package/package.json +89 -5
  108. package/dist/chunk-32OLICZO.js +0 -1
  109. package/dist/chunk-3AYXHQ4W.js.map +0 -1
  110. package/dist/chunk-5FIMA26D.js +0 -1
  111. package/dist/chunk-62J2DPKX.js.map +0 -1
  112. package/dist/chunk-7EMDVIZX.js.map +0 -1
  113. package/dist/chunk-EJ23MXPQ.js.map +0 -1
  114. package/dist/chunk-FPTDATY5.js.map +0 -1
  115. package/dist/chunk-KCDG2MNP.js +0 -1431
  116. package/dist/chunk-KCDG2MNP.js.map +0 -1
  117. package/dist/chunk-OLHGI472.js +0 -1
  118. package/dist/chunk-PAFBKNL3.js +0 -99
  119. package/dist/chunk-PAFBKNL3.js.map +0 -1
  120. package/dist/chunk-R4YFWQ3Q.js.map +0 -1
  121. package/dist/chunk-V6LJ6MR2.js +0 -740
  122. package/dist/chunk-V6LJ6MR2.js.map +0 -1
  123. package/dist/chunk-VJCL2SWD.js +0 -1
  124. package/dist/failed-upload-store-C0cLxxPz.d.ts +0 -33
  125. /package/dist/{chunk-32OLICZO.js.map → chunk-654ERHA7.js.map} +0 -0
  126. /package/dist/{chunk-5FIMA26D.js.map → chunk-T4AO7JIG.js.map} +0 -0
  127. /package/dist/{chunk-OLHGI472.js.map → chunk-TGBT5XBE.js.map} +0 -0
  128. /package/dist/{chunk-VJCL2SWD.js.map → chunk-YHTZ7VMV.js.map} +0 -0
@@ -1,13 +1,17 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
- import { A as AbstractPowerSyncDatabase, a as SyncStatus, C as CrudEntry, S as SyncMode, F as FailedTransaction, h as CompletedTransaction, b as ConnectionHealth, e as SyncMetrics, D as DownloadProgress, E as EntitySyncState, f as SyncError } from '../types-afHtE1U_.js';
3
+ import { A as AbstractPowerSyncDatabase, a as SyncStatus, C as CrudEntry, S as SyncMode, F as FailedTransaction, h as CompletedTransaction, b as ConnectionHealth, e as SyncMetrics, D as DownloadProgress, E as EntitySyncState, f as SyncError } from '../types-CDqWh56B.js';
4
4
  import { PlatformAdapter } from '../platform/index.js';
5
- import { C as ConnectorConfig, S as SupabaseConnector, f as ConflictBus } from '../index-l3iL9Jte.js';
6
- import { AttachmentQueueConfig, AttachmentQueue } from '../attachments/index.js';
5
+ import { a as ConnectorConfig, g as ConflictBus } from '../types-B212hgfA.js';
6
+ import { e as AttachmentConfig, P as PolAttachmentQueue, A as AttachmentSourceConfig, z as AttachmentRecord, C as CompressionConfig, i as DownloadConfig } from '../pol-attachment-queue-BVAIueoP.js';
7
+ import { S as SupabaseConnector } from '../supabase-connector-T9vHq_3i.js';
7
8
  import * as react from 'react';
8
- import react__default from 'react';
9
- import { c as SyncControlActions } from '../types-Cd7RhNqf.js';
10
- import '../failed-upload-store-C0cLxxPz.js';
9
+ import react__default, { ReactNode } from 'react';
10
+ import { Schema } from '@powersync/react-native';
11
+ import { a as StorageBackend } from '../types-D0WcHrq6.js';
12
+ import { h as BackgroundSyncSystem, c as SyncControlActions } from '../background-sync-ChCXW-EV.js';
13
+ import '@powersync/attachments';
14
+ import '@powersync/common';
11
15
 
12
16
  /**
13
17
  * Provider Types for @pol-studios/powersync
@@ -71,8 +75,16 @@ interface PowerSyncConfig<TSchema = unknown> {
71
75
  connector?: ConnectorConfig;
72
76
  /**
73
77
  * Optional: Attachment queue configuration for offline file caching.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * attachments: {
82
+ * source: { table: 'photos', idColumn: 'storage_path' },
83
+ * remoteStorage: supabaseStorageAdapter,
84
+ * }
85
+ * ```
74
86
  */
75
- attachments?: AttachmentQueueConfig;
87
+ attachments?: AttachmentConfig;
76
88
  /**
77
89
  * Optional: Sync behavior configuration.
78
90
  */
@@ -124,7 +136,7 @@ interface PowerSyncContextValue<TSchema = unknown> {
124
136
  * The attachment queue instance.
125
137
  * Will be null if attachments are not configured or not initialized.
126
138
  */
127
- attachmentQueue: AttachmentQueue | null;
139
+ attachmentQueue: PolAttachmentQueue | null;
128
140
  /**
129
141
  * Whether the PowerSync database is ready for use.
130
142
  */
@@ -133,6 +145,17 @@ interface PowerSyncContextValue<TSchema = unknown> {
133
145
  * Whether the provider is currently initializing.
134
146
  */
135
147
  isInitializing: boolean;
148
+ /**
149
+ * Whether the attachment queue is ready for use.
150
+ * This is separate from isReady because the attachment queue initializes
151
+ * asynchronously after the database is ready.
152
+ *
153
+ * States:
154
+ * - `false`: Attachment queue is still initializing
155
+ * - `true` with `attachmentQueue !== null`: Ready and available
156
+ * - `true` with `attachmentQueue === null`: Either attachments not configured, OR initialization failed
157
+ */
158
+ attachmentQueueReady: boolean;
136
159
  /**
137
160
  * Error that occurred during initialization, if any.
138
161
  */
@@ -252,10 +275,6 @@ interface SyncStatusContextValue {
252
275
  * Resume automatic retry of failed uploads.
253
276
  */
254
277
  resumeAutoRetry: () => void;
255
- /**
256
- * Manually retry all failed uploads that are ready for retry.
257
- */
258
- retryFailedUploads: () => Promise<void>;
259
278
  }
260
279
  /**
261
280
  * Connection state - changes rarely (on connect/disconnect).
@@ -298,6 +317,17 @@ interface PendingMutationsContextValue {
298
317
  discardPendingMutation: (clientId: number) => Promise<void>;
299
318
  /** Discard all pending mutations */
300
319
  discardAllPendingMutations: () => Promise<void>;
320
+ /**
321
+ * Add a pending mutation to the list.
322
+ * Called by mutation hooks (useDbInsert, useDbUpdate, useDbDelete, useDbUpsert)
323
+ * after a successful write. Includes createdAt timestamp for display.
324
+ */
325
+ addPendingMutation: (entry: CrudEntry) => void;
326
+ /**
327
+ * Remove a pending mutation by its entity ID.
328
+ * Called when a transaction completes sync.
329
+ */
330
+ removePendingMutation: (id: string) => void;
301
331
  }
302
332
  /**
303
333
  * Failed transactions - changes on failures.
@@ -318,8 +348,16 @@ interface FailedTransactionsContextValue {
318
348
  pauseAutoRetry: () => void;
319
349
  /** Resume automatic retry of failed uploads */
320
350
  resumeAutoRetry: () => void;
321
- /** Manually retry all failed uploads */
322
- retryFailedUploads: () => Promise<void>;
351
+ /**
352
+ * Retry a specific failed transaction.
353
+ *
354
+ * This removes the failure from tracking and triggers a sync.
355
+ * The actual CRUD entries remain in PowerSync's queue - this just
356
+ * clears our error tracking so the sync can retry them.
357
+ *
358
+ * If the sync fails to start, the failure is re-recorded.
359
+ */
360
+ retryFailure: (failureId: string) => Promise<void>;
323
361
  }
324
362
  /**
325
363
  * Completed transactions - changes on successful syncs.
@@ -330,6 +368,18 @@ interface CompletedTransactionsContextValue {
330
368
  completedTransactions: CompletedTransaction[];
331
369
  /** Clear the completed transaction history */
332
370
  clearCompletedHistory: () => void;
371
+ /** Clear a specific completed transaction by ID */
372
+ clearCompletedItem: (completedId: string) => void;
373
+ /**
374
+ * Completed transactions that occurred AFTER the last notification display.
375
+ * Use this for toast/banner notifications to avoid showing stale historical counts.
376
+ */
377
+ newCompletedTransactions: CompletedTransaction[];
378
+ /**
379
+ * Mark notifications as seen (updates the lastNotificationTime).
380
+ * Call this when a sync notification is displayed or auto-dismissed.
381
+ */
382
+ markNotificationsAsSeen: () => void;
333
383
  }
334
384
  /**
335
385
  * Sync mode control - changes rarely (user action).
@@ -340,7 +390,18 @@ interface SyncModeContextValue {
340
390
  syncMode: SyncMode;
341
391
  /** Whether sync is currently paused (offline mode) */
342
392
  isPaused: boolean;
343
- /** Set the sync mode */
393
+ /**
394
+ * Whether offline mode was automatically set due to network loss.
395
+ * When true, sync will auto-resume when network returns.
396
+ * When false (user manually chose offline), sync won't auto-resume.
397
+ */
398
+ isAutoOffline: boolean;
399
+ /**
400
+ * Whether the network is currently reachable.
401
+ * This is used as a gate to block uploads even when syncMode is 'push-pull'.
402
+ */
403
+ networkReachable: boolean;
404
+ /** Set the sync mode (manual - won't auto-resume) */
344
405
  setSyncMode: (mode: SyncMode) => Promise<void>;
345
406
  /** Set the force next upload flag */
346
407
  setForceNextUpload: (force: boolean) => void;
@@ -518,7 +579,7 @@ declare const SyncMetricsContext: react.Context<SyncMetricsContextValue>;
518
579
  * }
519
580
  * ```
520
581
  */
521
- declare const AttachmentQueueContext: react.Context<AttachmentQueue>;
582
+ declare const AttachmentQueueContext: react.Context<PolAttachmentQueue>;
522
583
 
523
584
  /**
524
585
  * PowerSyncProvider Component for @pol-studios/powersync
@@ -563,6 +624,316 @@ declare const AttachmentQueueContext: react.Context<AttachmentQueue>;
563
624
  */
564
625
  declare function PowerSyncProvider<TSchema = unknown>({ config, children, onReady, onError, onSyncStatusChange, }: PowerSyncProviderProps<TSchema>): react__default.ReactElement;
565
626
 
627
+ /**
628
+ * Configuration for @pol-studios/db DataLayerProvider integration.
629
+ * This allows OfflineDataProvider to wrap and configure the DataLayerProvider.
630
+ */
631
+ interface DataLayerConfig {
632
+ /**
633
+ * Entity schemas that define tables and relationships.
634
+ * This is passed directly to DataLayerProvider.
635
+ */
636
+ schema: Record<string, unknown>;
637
+ }
638
+ /**
639
+ * Data layer integration configuration.
640
+ */
641
+ interface DataLayerIntegration {
642
+ /** DataLayer configuration */
643
+ config: DataLayerConfig;
644
+ /** Skip rendering DataLayerProvider (default: false) */
645
+ skip?: boolean;
646
+ }
647
+ /**
648
+ * Callbacks for background sync lifecycle events.
649
+ */
650
+ interface BackgroundSyncCallbacks {
651
+ /** Called when background sync starts */
652
+ onSyncStart?: () => void;
653
+ /** Called when background sync completes successfully */
654
+ onSyncComplete?: () => void;
655
+ /** Called when background sync fails */
656
+ onSyncError?: (error: Error) => void;
657
+ }
658
+ /**
659
+ * Background sync configuration.
660
+ */
661
+ interface BackgroundSyncConfig {
662
+ /** Enable background sync */
663
+ enabled: boolean;
664
+ /** Minimum interval between background syncs in minutes (default: 15) */
665
+ minimumInterval?: number;
666
+ /** Callbacks for sync lifecycle events */
667
+ callbacks?: BackgroundSyncCallbacks;
668
+ }
669
+ /**
670
+ * Status reported by background sync.
671
+ * Compatible with the status callback in BackgroundSyncSystem.
672
+ */
673
+ interface BackgroundSyncStatus {
674
+ /** Last successful sync timestamp */
675
+ lastSyncedAt?: Date | null;
676
+ /** Whether currently downloading */
677
+ downloading: boolean;
678
+ /** Whether currently uploading */
679
+ uploading: boolean;
680
+ }
681
+ /**
682
+ * Snapshot of PowerSync sync status for passing to DataLayerProvider.
683
+ */
684
+ interface PowerSyncSyncStatusSnapshot {
685
+ /** Whether initial sync has completed */
686
+ hasSynced: boolean;
687
+ /** Whether connected to the PowerSync service */
688
+ connected: boolean;
689
+ /** Whether currently attempting to connect */
690
+ connecting: boolean;
691
+ /** Whether the device is online (from platform adapter) */
692
+ isOnline: boolean;
693
+ }
694
+ /**
695
+ * Attachment configuration for OfflineDataProvider.
696
+ * Uses the new 2-callback API (watchIds, skipDownload).
697
+ */
698
+ interface OfflineDataAttachmentConfig extends AttachmentSourceConfig {
699
+ /** Optional: callback when upload completes */
700
+ onUploadComplete?: (attachment: AttachmentRecord) => void;
701
+ /** Optional: callback when upload fails */
702
+ onUploadFailed?: (attachment: AttachmentRecord, error: Error) => void;
703
+ /** Optional: max cache size in bytes */
704
+ maxCacheBytes?: number;
705
+ /**
706
+ * Optional: image compression settings for downloads.
707
+ * Uses Supabase's transform feature to resize/compress images on download.
708
+ */
709
+ compression?: Partial<CompressionConfig>;
710
+ /**
711
+ * Optional: download configuration for performance tuning.
712
+ * Adjusts concurrency and timeout for downloads.
713
+ */
714
+ download?: Partial<DownloadConfig>;
715
+ }
716
+ /**
717
+ * Configuration for OfflineDataProvider
718
+ */
719
+ interface OfflineDataProviderConfig {
720
+ /** PowerSync schema definition */
721
+ schema: Schema;
722
+ /** Supabase client instance */
723
+ supabaseClient: SupabaseClient;
724
+ /** React Query client */
725
+ queryClient: QueryClient;
726
+ /** PowerSync service URL (if missing, runs in online-only mode) */
727
+ powerSyncUrl?: string;
728
+ /** Database filename (default: 'powersync.db') */
729
+ dbFilename?: string;
730
+ /** Attachment configuration */
731
+ attachments?: OfflineDataAttachmentConfig;
732
+ /** Platform adapter (created automatically if not provided) */
733
+ platform?: PlatformAdapter;
734
+ /** Custom connector configuration for CRUD handling */
735
+ connector?: {
736
+ /** Schema router function for table-specific schema lookups */
737
+ schemaRouter?: (table: string) => unknown;
738
+ /** Enable conflict detection */
739
+ conflictDetection?: {
740
+ enabled: boolean;
741
+ };
742
+ };
743
+ /** Sync behavior configuration */
744
+ sync?: {
745
+ /** Automatically connect when the provider mounts and there's an authenticated session */
746
+ autoConnect?: boolean;
747
+ /** Enable health monitoring */
748
+ enableHealthMonitoring?: boolean;
749
+ /** Enable metrics collection */
750
+ enableMetrics?: boolean;
751
+ };
752
+ }
753
+ /**
754
+ * Props for OfflineDataProvider
755
+ */
756
+ interface OfflineDataProviderProps {
757
+ /** Provider configuration */
758
+ config: OfflineDataProviderConfig;
759
+ children: ReactNode;
760
+ /**
761
+ * DataLayer configuration for @pol-studios/db integration.
762
+ * When provided, OfflineDataProvider wraps children with DataLayerProvider
763
+ * and automatically bridges PowerSync context to it.
764
+ */
765
+ dataLayer?: DataLayerIntegration;
766
+ /**
767
+ * Background sync configuration.
768
+ * When enabled, sets up background sync system for iOS/Android.
769
+ */
770
+ backgroundSync?: BackgroundSyncConfig;
771
+ /** Skip rendering ConflictProvider (default: false) */
772
+ skipConflictProvider?: boolean;
773
+ /** Skip rendering StorageQueueProvider (default: false) */
774
+ skipStorageQueueProvider?: boolean;
775
+ /** Custom storage backend (overrides built-in Supabase adapter) */
776
+ storageBackend?: StorageBackend;
777
+ /** Custom error UI for initialization errors */
778
+ renderInitError?: (error: Error, retry: () => void) => ReactNode;
779
+ /** Custom error UI (alias for renderInitError) */
780
+ renderError?: (error: Error, retry: () => void) => ReactNode;
781
+ onReady?: () => void;
782
+ onError?: (error: Error) => void;
783
+ onSyncStatusChange?: (status: PowerSyncSyncStatusSnapshot) => void;
784
+ /**
785
+ * Called when the background sync system is ready.
786
+ * Use this to set up app-level background sync via defineBackgroundSyncTask.
787
+ */
788
+ onBackgroundSyncSystemReady?: (system: BackgroundSyncSystem) => void;
789
+ }
790
+ /**
791
+ * Props for the internal ProviderBridge component.
792
+ */
793
+ interface ProviderBridgeProps {
794
+ children: ReactNode;
795
+ /** Skip ConflictProvider */
796
+ skipConflictProvider?: boolean;
797
+ /** Skip StorageQueueProvider */
798
+ skipStorageQueueProvider?: boolean;
799
+ /** Background sync configuration */
800
+ backgroundSync?: BackgroundSyncConfig;
801
+ /** Callback for background sync system setup */
802
+ onBackgroundSyncSystemReady?: (system: BackgroundSyncSystem | null) => void;
803
+ /** Called once when db becomes ready, with the db instance and initial sync status */
804
+ onDbReady: (db: AbstractPowerSyncDatabase | null, syncStatus: PowerSyncSyncStatusSnapshot) => void;
805
+ /** Called whenever sync status changes after initial readiness */
806
+ onSyncStatusChange: (syncStatus: PowerSyncSyncStatusSnapshot) => void;
807
+ /** Called with the addPendingMutation function once available */
808
+ onAddPendingMutationReady: (add: (entry: CrudEntry) => void) => void;
809
+ /** Called with the removePendingMutation function once available */
810
+ onRemovePendingMutationReady: (remove: (id: string) => void) => void;
811
+ }
812
+
813
+ /**
814
+ * OfflineDataProvider Component for @pol-studios/powersync
815
+ *
816
+ * Batteries-included offline data provider that combines:
817
+ * - PowerSyncProvider for offline-first data sync
818
+ * - DataLayerProvider integration from @pol-studios/db
819
+ * - ConflictProvider for conflict resolution UI
820
+ * - StorageQueueProvider for attachment queue access
821
+ * - Background sync system setup
822
+ * - Error recovery UI with retry capability
823
+ * - Online-only mode fallback (no PowerSync URL)
824
+ *
825
+ * @example
826
+ * ```tsx
827
+ * <OfflineDataProvider
828
+ * config={{
829
+ * schema: AppSchema,
830
+ * supabaseClient: supabase,
831
+ * queryClient: queryClient,
832
+ * powerSyncUrl: env.powerSyncUrl,
833
+ * attachments: {
834
+ * bucket: 'my-bucket',
835
+ * watchIds: (db, onUpdate) => {
836
+ * db.watch('SELECT storagePath as id FROM photos', [], {
837
+ * onResult: (r) => onUpdate(r.rows._array.map(x => x.id)),
838
+ * });
839
+ * },
840
+ * skipDownload: async ({ ids }) => {
841
+ * // Return IDs to skip downloading (e.g., videos)
842
+ * return ids.filter(id => id.endsWith('.mp4'));
843
+ * },
844
+ * },
845
+ * }}
846
+ * dataLayer={{ config: dataLayerConfig }}
847
+ * renderInitError={(error, retry) => <MyErrorUI error={error} onRetry={retry} />}
848
+ * >
849
+ * <App />
850
+ * </OfflineDataProvider>
851
+ * ```
852
+ */
853
+
854
+ /**
855
+ * Batteries-included offline data provider.
856
+ *
857
+ * Combines PowerSyncProvider with error boundary, DataLayerProvider integration,
858
+ * and sensible defaults for a complete offline-first data solution.
859
+ *
860
+ * Key features:
861
+ * - Automatic PowerSync setup and initialization
862
+ * - Integration with @pol-studios/db DataLayerProvider
863
+ * - ConflictProvider and StorageQueueProvider wiring
864
+ * - Background sync system support
865
+ * - Error recovery UI with retry capability
866
+ * - Online-only mode fallback when no PowerSync URL is provided
867
+ *
868
+ * @example
869
+ * ```tsx
870
+ * // Basic usage
871
+ * <OfflineDataProvider
872
+ * config={{
873
+ * schema: AppSchema,
874
+ * supabaseClient: supabase,
875
+ * queryClient: queryClient,
876
+ * powerSyncUrl: process.env.EXPO_PUBLIC_POWERSYNC_URL,
877
+ * }}
878
+ * >
879
+ * <App />
880
+ * </OfflineDataProvider>
881
+ *
882
+ * // With DataLayer integration
883
+ * <OfflineDataProvider
884
+ * config={{ ... }}
885
+ * dataLayer={{ config: dataLayerConfig }}
886
+ * >
887
+ * <App />
888
+ * </OfflineDataProvider>
889
+ *
890
+ * // With custom error UI
891
+ * <OfflineDataProvider
892
+ * config={{ ... }}
893
+ * renderInitError={(error, retry) => <MyErrorUI error={error} onRetry={retry} />}
894
+ * >
895
+ * <App />
896
+ * </OfflineDataProvider>
897
+ * ```
898
+ */
899
+ declare function OfflineDataProvider({ config, children, dataLayer, backgroundSync, skipConflictProvider, skipStorageQueueProvider, storageBackend, renderInitError, renderError, onReady, onError, onSyncStatusChange, onBackgroundSyncSystemReady: onBackgroundSyncSystemReadyProp, }: OfflineDataProviderProps): react__default.ReactElement;
900
+
901
+ /**
902
+ * ProviderBridge Component for @pol-studios/powersync
903
+ *
904
+ * Internal bridge component that connects PowerSync context to external providers:
905
+ * - DataLayerProvider from @pol-studios/db
906
+ * - ConflictProvider from @pol-studios/db
907
+ * - StorageQueueProvider from @pol-studios/db
908
+ *
909
+ * This component is used internally by OfflineDataProvider and should not be
910
+ * exported directly. It handles the complex wiring between packages.
911
+ */
912
+
913
+ /**
914
+ * ProviderBridge connects the PowerSync package context to external providers
915
+ * like ConflictProvider and StorageQueueProvider from @pol-studios/db.
916
+ *
917
+ * This component:
918
+ * 1. Signals the parent when the db is ready (onDbReady)
919
+ * 2. Reports sync status changes (onSyncStatusChange)
920
+ * 3. Exposes pending mutation functions to parent (for DataLayerProvider)
921
+ * 4. Sets up background sync system when enabled
922
+ * 5. Wraps children with ConflictProvider and StorageQueueProvider
923
+ * 6. Exposes PowerSync db via native PowerSyncContext for SDK hooks
924
+ *
925
+ * IMPORTANT: DataLayerProvider is rendered OUTSIDE this component (in OfflineDataProvider)
926
+ * so it always exists in the React tree even before PowerSync is ready.
927
+ * This prevents "useDataLayer must be used within a DataLayerProvider" errors
928
+ * when routes mount before the db is initialized.
929
+ *
930
+ * CRITICAL: The conflictBus is created internally by PowerSyncProvider and
931
+ * passed to the connector. We MUST use the same bus instance from context
932
+ * for ConflictProvider, otherwise conflicts detected by the connector won't
933
+ * reach the UI components subscribed via ConflictProvider.
934
+ */
935
+ declare function ProviderBridge({ children, skipConflictProvider, skipStorageQueueProvider, backgroundSync, onBackgroundSyncSystemReady, onDbReady, onSyncStatusChange, onAddPendingMutationReady, onRemovePendingMutationReady, }: ProviderBridgeProps): react__default.ReactElement | null;
936
+
566
937
  /**
567
938
  * Hook to access the PowerSync database and related services.
568
939
  *
@@ -584,7 +955,17 @@ declare function PowerSyncProvider<TSchema = unknown>({ config, children, onRead
584
955
  */
585
956
  declare function usePowerSync<TSchema = unknown>(): PowerSyncContextValue<TSchema>;
586
957
  /**
587
- * Hook to access the current sync status.
958
+ * @deprecated This hook causes re-renders on any status change.
959
+ * Use focused hooks instead:
960
+ *
961
+ * | Old (useSyncStatus) | New hook |
962
+ * |--------------------------------|-----------------------------|
963
+ * | connected, hasSynced | useConnectionStatus() |
964
+ * | uploading, downloading | useSyncActivityContext() |
965
+ * | pendingCount, pendingMutations | usePendingMutationsContext()|
966
+ * | failedTransactions | useFailedTransactions() |
967
+ * | syncMode, setSyncMode | useSyncMode() |
968
+ * | triggerSync, pause, resume | useSyncControl() |
588
969
  *
589
970
  * @returns Sync status with connection state, pending uploads, and progress
590
971
  * @throws Error if used outside of PowerSyncProvider
@@ -672,11 +1053,11 @@ declare function usePendingMutationsContext(): PendingMutationsContextValue;
672
1053
  * @example
673
1054
  * ```typescript
674
1055
  * function SyncErrorBanner() {
675
- * const { hasUploadErrors, permanentErrorCount, retryFailedUploads } = useFailedTransactionsContext();
1056
+ * const { hasUploadErrors, permanentErrorCount, retryFailure, failedTransactions } = useFailedTransactionsContext();
676
1057
  *
677
1058
  * if (!hasUploadErrors) return null;
678
1059
  * return (
679
- * <Banner onRetry={retryFailedUploads}>
1060
+ * <Banner onRetry={() => failedTransactions.forEach(f => retryFailure(f.id))}>
680
1061
  * {permanentErrorCount} changes failed to sync
681
1062
  * </Banner>
682
1063
  * );
@@ -781,6 +1162,7 @@ declare function useSyncMode(): {
781
1162
  setMode: (mode: SyncMode) => Promise<void>;
782
1163
  canUpload: boolean;
783
1164
  canDownload: boolean;
1165
+ networkReachable: boolean;
784
1166
  };
785
1167
  /**
786
1168
  * Hook to access connection health status.
@@ -865,7 +1247,36 @@ declare function useSyncMetrics(): SyncMetrics;
865
1247
  * }
866
1248
  * ```
867
1249
  */
868
- declare function useAttachmentQueue(): AttachmentQueue | null;
1250
+ declare function useAttachmentQueue(): PolAttachmentQueue | null;
1251
+ /**
1252
+ * Hook to check if the attachment queue has finished initializing.
1253
+ *
1254
+ * This is useful when you need to wait for the attachment queue to be ready
1255
+ * before performing upload operations. The attachment queue initializes
1256
+ * asynchronously after the database is ready, so there's a brief period
1257
+ * where `isReady` is true but `attachmentQueueReady` is false.
1258
+ *
1259
+ * @returns Whether the attachment queue is ready (true if initialized or if attachments not configured)
1260
+ *
1261
+ * @example
1262
+ * ```typescript
1263
+ * function UploadButton() {
1264
+ * const attachmentQueue = useAttachmentQueue();
1265
+ * const attachmentQueueReady = useAttachmentQueueReady();
1266
+ *
1267
+ * if (!attachmentQueueReady) {
1268
+ * return <Button disabled>Initializing...</Button>;
1269
+ * }
1270
+ *
1271
+ * if (!attachmentQueue) {
1272
+ * return <Text>Uploads not configured</Text>;
1273
+ * }
1274
+ *
1275
+ * return <Button onPress={handleUpload}>Upload</Button>;
1276
+ * }
1277
+ * ```
1278
+ */
1279
+ declare function useAttachmentQueueReady(): boolean;
869
1280
  /**
870
1281
  * Hook to get the PowerSync database instance.
871
1282
  * Throws if not ready.
@@ -1090,20 +1501,29 @@ interface SyncActivityResult {
1090
1501
  failed: FailedTransaction[];
1091
1502
  /** Recently completed transactions */
1092
1503
  completed: CompletedTransaction[];
1504
+ /** New completed transactions since last notification display (for toasts/banners) */
1505
+ newCompleted: CompletedTransaction[];
1093
1506
  /** Counts summary */
1094
1507
  counts: {
1095
1508
  pending: number;
1096
1509
  failed: number;
1097
1510
  completed: number;
1511
+ newCompleted: number;
1098
1512
  };
1099
1513
  /** Whether there is any sync activity to show (pending or failed) */
1100
1514
  hasActivity: boolean;
1101
1515
  /** Retry all failed transactions */
1102
1516
  retryAll: () => Promise<void>;
1517
+ /** Retry a specific failed transaction */
1518
+ retryFailure: (failureId: string) => Promise<void>;
1103
1519
  /** Dismiss a specific failure */
1104
1520
  dismissFailure: (failureId: string) => void;
1105
1521
  /** Clear all completed transactions from the list */
1106
1522
  clearCompleted: () => void;
1523
+ /** Clear a specific completed transaction from the list */
1524
+ clearCompletedItem: (completedId: string) => void;
1525
+ /** Mark notifications as seen (for auto-dismiss functionality) */
1526
+ markNotificationsAsSeen: () => void;
1107
1527
  }
1108
1528
  /**
1109
1529
  * Hook to get comprehensive sync activity including pending, failed, and completed transactions.
@@ -1129,5 +1549,15 @@ interface SyncActivityResult {
1129
1549
  * ```
1130
1550
  */
1131
1551
  declare function useSyncActivity(): SyncActivityResult;
1552
+ /**
1553
+ * Get failed transactions state and retry/dismiss functions.
1554
+ * Alias for useFailedTransactionsContext.
1555
+ */
1556
+ declare const useFailedTransactions: typeof useFailedTransactionsContext;
1557
+ /**
1558
+ * Get completed transactions state and clear function.
1559
+ * Alias for useCompletedTransactionsContext.
1560
+ */
1561
+ declare const useCompletedTransactions: typeof useCompletedTransactionsContext;
1132
1562
 
1133
- export { AttachmentQueueContext, CompletedTransactionsContext, type CompletedTransactionsContextValue, ConnectionHealthContext, type ConnectionHealthContextValue, ConnectionStatusContext, type ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, type EntitySyncStatusResult, FailedTransactionsContext, type FailedTransactionsContextValue, PendingMutationsContext, type PendingMutationsContextValue, type PowerSyncConfig, PowerSyncContext, type PowerSyncContextValue, PowerSyncProvider, type PowerSyncProviderProps, SyncActivityContext, type SyncActivityContextValue, type SyncActivityResult, type SyncConfig, SyncMetricsContext, type SyncMetricsContextValue, SyncModeContext, type SyncModeContextValue, SyncStatusContext, type SyncStatusContextValue, type UploadStatusResult, useAttachmentQueue, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus };
1563
+ export { AttachmentQueueContext, type BackgroundSyncCallbacks, type BackgroundSyncConfig, type BackgroundSyncStatus, CompletedTransactionsContext, type CompletedTransactionsContextValue, ConnectionHealthContext, type ConnectionHealthContextValue, ConnectionStatusContext, type ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, type DataLayerConfig, type DataLayerIntegration, type EntitySyncStatusResult, FailedTransactionsContext, type FailedTransactionsContextValue, type OfflineDataAttachmentConfig, OfflineDataProvider, type OfflineDataProviderConfig, type OfflineDataProviderProps, PendingMutationsContext, type PendingMutationsContextValue, type PowerSyncConfig, PowerSyncContext, type PowerSyncContextValue, PowerSyncProvider, type PowerSyncProviderProps, type PowerSyncSyncStatusSnapshot, ProviderBridge, type ProviderBridgeProps, SyncActivityContext, type SyncActivityContextValue, type SyncActivityResult, type SyncConfig, SyncMetricsContext, type SyncMetricsContextValue, SyncModeContext, type SyncModeContextValue, SyncStatusContext, type SyncStatusContextValue, type UploadStatusResult, useAttachmentQueue, useAttachmentQueueReady, useCompletedTransactions, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactions, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus };