@pol-studios/powersync 1.0.7 → 1.0.11
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/README.md +933 -0
- package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
- package/dist/attachments/index.d.ts +709 -6
- package/dist/attachments/index.js +133 -5
- package/dist/chunk-24RDMMCL.js +44 -0
- package/dist/chunk-24RDMMCL.js.map +1 -0
- package/dist/chunk-4TXTAEF2.js +2060 -0
- package/dist/chunk-4TXTAEF2.js.map +1 -0
- package/dist/chunk-63PXSPIN.js +358 -0
- package/dist/chunk-63PXSPIN.js.map +1 -0
- package/dist/chunk-654ERHA7.js +1 -0
- package/dist/{chunk-BREGB4WL.js → chunk-BRXQNASY.js} +287 -335
- package/dist/chunk-BRXQNASY.js.map +1 -0
- package/dist/{chunk-DHYUBVP7.js → chunk-CAB26E6F.js} +20 -9
- package/dist/chunk-CAB26E6F.js.map +1 -0
- package/dist/{chunk-H772V6XQ.js → chunk-CUCAYK7Z.js} +7 -43
- package/dist/chunk-CUCAYK7Z.js.map +1 -0
- package/dist/{chunk-4C3RY5SU.js → chunk-HWSNV45P.js} +76 -1
- package/dist/chunk-HWSNV45P.js.map +1 -0
- package/dist/{chunk-HFOFLW5F.js → chunk-KN2IZERF.js} +139 -6
- package/dist/chunk-KN2IZERF.js.map +1 -0
- package/dist/{chunk-UEYRTLKE.js → chunk-P4HZA6ZT.js} +20 -9
- package/dist/chunk-P4HZA6ZT.js.map +1 -0
- package/dist/chunk-T4AO7JIG.js +1 -0
- package/dist/{chunk-XQAJM2MW.js → chunk-VACPAAQZ.js} +33 -2
- package/dist/{chunk-XQAJM2MW.js.map → chunk-VACPAAQZ.js.map} +1 -1
- package/dist/{chunk-53WH2JJV.js → chunk-WN5ZJ3E2.js} +5 -8
- package/dist/chunk-WN5ZJ3E2.js.map +1 -0
- package/dist/chunk-XAEII4ZX.js +456 -0
- package/dist/chunk-XAEII4ZX.js.map +1 -0
- package/dist/chunk-XOY2CJ67.js +289 -0
- package/dist/chunk-XOY2CJ67.js.map +1 -0
- package/dist/chunk-YHTZ7VMV.js +1 -0
- package/dist/{chunk-MKD2VCX3.js → chunk-Z6VOBGTU.js} +8 -8
- package/dist/chunk-Z6VOBGTU.js.map +1 -0
- package/dist/chunk-ZM4ENYMF.js +230 -0
- package/dist/chunk-ZM4ENYMF.js.map +1 -0
- package/dist/connector/index.d.ts +56 -3
- package/dist/connector/index.js +8 -5
- package/dist/core/index.d.ts +12 -1
- package/dist/core/index.js +3 -2
- package/dist/error/index.js +0 -1
- package/dist/generator/cli.js +527 -0
- package/dist/generator/index.d.ts +168 -0
- package/dist/generator/index.js +370 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/index.d.ts +12 -10
- package/dist/index.js +191 -29
- package/dist/index.native.d.ts +11 -9
- package/dist/index.native.js +191 -29
- package/dist/index.web.d.ts +11 -9
- package/dist/index.web.js +191 -29
- package/dist/maintenance/index.js +0 -1
- package/dist/platform/index.js +0 -2
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.js +1 -2
- package/dist/platform/index.web.js +0 -1
- package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
- package/dist/provider/index.d.ts +38 -34
- package/dist/provider/index.js +11 -12
- package/dist/react/index.d.ts +372 -0
- package/dist/react/index.js +25 -0
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +22 -8
- package/dist/storage/index.native.d.ts +3 -3
- package/dist/storage/index.native.js +21 -7
- package/dist/storage/index.web.d.ts +3 -3
- package/dist/storage/index.web.js +21 -7
- package/dist/storage/upload/index.d.ts +7 -8
- package/dist/storage/upload/index.js +3 -3
- package/dist/storage/upload/index.native.d.ts +7 -8
- package/dist/storage/upload/index.native.js +4 -3
- package/dist/storage/upload/index.web.d.ts +1 -4
- package/dist/storage/upload/index.web.js +3 -3
- package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
- package/dist/sync/index.js +3 -3
- package/dist/{supabase-connector-qLm-WHkM.d.ts → types-B212hgfA.d.ts} +48 -170
- package/dist/{types-BVacP54t.d.ts → types-CyvBaAl8.d.ts} +12 -4
- package/dist/types-D0WcHrq6.d.ts +234 -0
- package/package.json +28 -4
- package/dist/CacheSettingsManager-1exbOC6S.d.ts +0 -261
- package/dist/chunk-4C3RY5SU.js.map +0 -1
- package/dist/chunk-53WH2JJV.js.map +0 -1
- package/dist/chunk-BREGB4WL.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DHYUBVP7.js.map +0 -1
- package/dist/chunk-GKF7TOMT.js +0 -1
- package/dist/chunk-H772V6XQ.js.map +0 -1
- package/dist/chunk-HFOFLW5F.js.map +0 -1
- package/dist/chunk-KGSFAE5B.js +0 -1
- package/dist/chunk-LNL64IJZ.js +0 -1
- package/dist/chunk-MKD2VCX3.js.map +0 -1
- package/dist/chunk-UEYRTLKE.js.map +0 -1
- package/dist/chunk-WQ5MPAVC.js +0 -449
- package/dist/chunk-WQ5MPAVC.js.map +0 -1
- package/dist/chunk-ZEOKPWUC.js +0 -1165
- package/dist/chunk-ZEOKPWUC.js.map +0 -1
- package/dist/pol-attachment-queue-C7YNXXhK.d.ts +0 -676
- package/dist/types-Bgvx7-E8.d.ts +0 -187
- /package/dist/{chunk-DGUM43GV.js.map → chunk-654ERHA7.js.map} +0 -0
- /package/dist/{chunk-GKF7TOMT.js.map → chunk-T4AO7JIG.js.map} +0 -0
- /package/dist/{chunk-KGSFAE5B.js.map → chunk-YHTZ7VMV.js.map} +0 -0
- /package/dist/{chunk-LNL64IJZ.js.map → react/index.js.map} +0 -0
package/dist/provider/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
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 {
|
|
6
|
-
import {
|
|
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
9
|
import react__default, { ReactNode } from 'react';
|
|
9
10
|
import { Schema } from '@powersync/react-native';
|
|
10
|
-
import {
|
|
11
|
+
import { a as StorageBackend } from '../types-D0WcHrq6.js';
|
|
11
12
|
import { h as BackgroundSyncSystem, c as SyncControlActions } from '../background-sync-ChCXW-EV.js';
|
|
12
13
|
import '@powersync/attachments';
|
|
13
14
|
import '@powersync/common';
|
|
@@ -83,7 +84,7 @@ interface PowerSyncConfig<TSchema = unknown> {
|
|
|
83
84
|
* }
|
|
84
85
|
* ```
|
|
85
86
|
*/
|
|
86
|
-
attachments?:
|
|
87
|
+
attachments?: AttachmentConfig;
|
|
87
88
|
/**
|
|
88
89
|
* Optional: Sync behavior configuration.
|
|
89
90
|
*/
|
|
@@ -691,23 +692,26 @@ interface PowerSyncSyncStatusSnapshot {
|
|
|
691
692
|
isOnline: boolean;
|
|
692
693
|
}
|
|
693
694
|
/**
|
|
694
|
-
* Attachment configuration for OfflineDataProvider
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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>;
|
|
711
715
|
}
|
|
712
716
|
/**
|
|
713
717
|
* Configuration for OfflineDataProvider
|
|
@@ -768,16 +772,11 @@ interface OfflineDataProviderProps {
|
|
|
768
772
|
skipConflictProvider?: boolean;
|
|
769
773
|
/** Skip rendering StorageQueueProvider (default: false) */
|
|
770
774
|
skipStorageQueueProvider?: boolean;
|
|
771
|
-
/** Custom storage
|
|
772
|
-
|
|
773
|
-
/** Custom upload handler */
|
|
774
|
-
uploadHandler?: AttachmentUploadHandler;
|
|
775
|
+
/** Custom storage backend (overrides built-in Supabase adapter) */
|
|
776
|
+
storageBackend?: StorageBackend;
|
|
775
777
|
/** Custom error UI for initialization errors */
|
|
776
778
|
renderInitError?: (error: Error, retry: () => void) => ReactNode;
|
|
777
|
-
/**
|
|
778
|
-
* Custom error UI (alias for renderInitError for backward compatibility)
|
|
779
|
-
* @deprecated Use renderInitError instead
|
|
780
|
-
*/
|
|
779
|
+
/** Custom error UI (alias for renderInitError) */
|
|
781
780
|
renderError?: (error: Error, retry: () => void) => ReactNode;
|
|
782
781
|
onReady?: () => void;
|
|
783
782
|
onError?: (error: Error) => void;
|
|
@@ -823,8 +822,6 @@ interface ProviderBridgeProps {
|
|
|
823
822
|
* - Error recovery UI with retry capability
|
|
824
823
|
* - Online-only mode fallback (no PowerSync URL)
|
|
825
824
|
*
|
|
826
|
-
* This is the recommended entry point for apps using offline-first data.
|
|
827
|
-
*
|
|
828
825
|
* @example
|
|
829
826
|
* ```tsx
|
|
830
827
|
* <OfflineDataProvider
|
|
@@ -835,8 +832,15 @@ interface ProviderBridgeProps {
|
|
|
835
832
|
* powerSyncUrl: env.powerSyncUrl,
|
|
836
833
|
* attachments: {
|
|
837
834
|
* bucket: 'my-bucket',
|
|
838
|
-
*
|
|
839
|
-
*
|
|
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
|
+
* },
|
|
840
844
|
* },
|
|
841
845
|
* }}
|
|
842
846
|
* dataLayer={{ config: dataLayerConfig }}
|
|
@@ -892,7 +896,7 @@ interface ProviderBridgeProps {
|
|
|
892
896
|
* </OfflineDataProvider>
|
|
893
897
|
* ```
|
|
894
898
|
*/
|
|
895
|
-
declare function OfflineDataProvider({ config, children, dataLayer, backgroundSync, skipConflictProvider, skipStorageQueueProvider,
|
|
899
|
+
declare function OfflineDataProvider({ config, children, dataLayer, backgroundSync, skipConflictProvider, skipStorageQueueProvider, storageBackend, renderInitError, renderError, onReady, onError, onSyncStatusChange, onBackgroundSyncSystemReady: onBackgroundSyncSystemReadyProp, }: OfflineDataProviderProps): react__default.ReactElement;
|
|
896
900
|
|
|
897
901
|
/**
|
|
898
902
|
* ProviderBridge Component for @pol-studios/powersync
|
package/dist/provider/index.js
CHANGED
|
@@ -2,15 +2,17 @@ import {
|
|
|
2
2
|
OfflineDataProvider,
|
|
3
3
|
PowerSyncProvider,
|
|
4
4
|
ProviderBridge
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-BRXQNASY.js";
|
|
6
|
+
import "../chunk-YHTZ7VMV.js";
|
|
6
7
|
import "../chunk-P6WOZO7H.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-4TXTAEF2.js";
|
|
9
|
+
import "../chunk-CUCAYK7Z.js";
|
|
8
10
|
import {
|
|
9
11
|
DEFAULT_CONNECTION_HEALTH,
|
|
10
12
|
DEFAULT_SYNC_CONFIG,
|
|
11
13
|
DEFAULT_SYNC_METRICS,
|
|
12
14
|
DEFAULT_SYNC_STATUS
|
|
13
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-24RDMMCL.js";
|
|
14
16
|
import {
|
|
15
17
|
AttachmentQueueContext,
|
|
16
18
|
CompletedTransactionsContext,
|
|
@@ -49,17 +51,14 @@ import {
|
|
|
49
51
|
useSyncStatus,
|
|
50
52
|
useUploadStatus
|
|
51
53
|
} from "../chunk-YSTEESEG.js";
|
|
52
|
-
import "../chunk-
|
|
53
|
-
import "../chunk-
|
|
54
|
-
import "../chunk-
|
|
55
|
-
import "../chunk-UEYRTLKE.js";
|
|
56
|
-
import "../chunk-MKD2VCX3.js";
|
|
54
|
+
import "../chunk-CAB26E6F.js";
|
|
55
|
+
import "../chunk-XAEII4ZX.js";
|
|
56
|
+
import "../chunk-Z6VOBGTU.js";
|
|
57
57
|
import "../chunk-CGL33PL4.js";
|
|
58
|
-
import "../chunk-
|
|
59
|
-
import "../chunk-
|
|
58
|
+
import "../chunk-WN5ZJ3E2.js";
|
|
59
|
+
import "../chunk-KN2IZERF.js";
|
|
60
60
|
import "../chunk-FV2HXEIY.js";
|
|
61
|
-
import "../chunk-
|
|
62
|
-
import "../chunk-DGUM43GV.js";
|
|
61
|
+
import "../chunk-VACPAAQZ.js";
|
|
63
62
|
export {
|
|
64
63
|
AttachmentQueueContext,
|
|
65
64
|
CompletedTransactionsContext,
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ReactNode } from 'react';
|
|
3
|
+
import { Schema } from '@powersync/react-native';
|
|
4
|
+
import { A as AuthProvider } from '../types-B212hgfA.js';
|
|
5
|
+
import { a as StorageBackend } from '../types-D0WcHrq6.js';
|
|
6
|
+
import { e as AttachmentConfig, P as PolAttachmentQueue } from '../pol-attachment-queue-BVAIueoP.js';
|
|
7
|
+
import { PlatformAdapter } from '../platform/index.js';
|
|
8
|
+
import { f as SyncError, a as SyncStatus, A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
|
|
9
|
+
import '@supabase/supabase-js';
|
|
10
|
+
import '@powersync/attachments';
|
|
11
|
+
import '@powersync/common';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Types for the slim PowerSyncProvider
|
|
15
|
+
*
|
|
16
|
+
* This module contains type definitions for the new simplified provider API.
|
|
17
|
+
* The types here are designed for zero domain coupling - all domain-specific
|
|
18
|
+
* logic should be handled via callbacks at the consumer level.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* PowerSync provider configuration.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const config: PowerSyncConfig = {
|
|
27
|
+
* schema: AppSchema,
|
|
28
|
+
* powerSyncUrl: 'https://my-instance.powersync.journeyapps.com',
|
|
29
|
+
* dbFilename: 'myapp.db',
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
interface PowerSyncConfig {
|
|
34
|
+
/**
|
|
35
|
+
* PowerSync schema definition.
|
|
36
|
+
* Defines the tables and their structure for the local database.
|
|
37
|
+
*/
|
|
38
|
+
schema: Schema;
|
|
39
|
+
/**
|
|
40
|
+
* PowerSync service URL.
|
|
41
|
+
* @example "https://your-instance.powersync.journeyapps.com"
|
|
42
|
+
*/
|
|
43
|
+
powerSyncUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* Database filename.
|
|
46
|
+
* @default "powersync.db"
|
|
47
|
+
*/
|
|
48
|
+
dbFilename?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Props for the slim PowerSyncProvider.
|
|
52
|
+
*
|
|
53
|
+
* This provider is designed to be minimal and composable:
|
|
54
|
+
* - No @pol/db coupling
|
|
55
|
+
* - No domain-specific logic
|
|
56
|
+
* - All callbacks are optional
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* <PowerSyncProvider
|
|
61
|
+
* config={{
|
|
62
|
+
* schema: AppSchema,
|
|
63
|
+
* powerSyncUrl: POWERSYNC_URL,
|
|
64
|
+
* dbFilename: 'myapp.db',
|
|
65
|
+
* }}
|
|
66
|
+
* auth={supabaseAuth}
|
|
67
|
+
* storage={supabaseStorage}
|
|
68
|
+
* attachments={{
|
|
69
|
+
* watch: {
|
|
70
|
+
* table: 'MediaContent',
|
|
71
|
+
* idColumn: 'storagePath',
|
|
72
|
+
* },
|
|
73
|
+
* }}
|
|
74
|
+
* onError={(error) => console.error(error)}
|
|
75
|
+
* onReady={() => console.log('Ready!')}
|
|
76
|
+
* >
|
|
77
|
+
* <App />
|
|
78
|
+
* </PowerSyncProvider>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
interface PowerSyncProviderProps {
|
|
82
|
+
/**
|
|
83
|
+
* PowerSync configuration.
|
|
84
|
+
*/
|
|
85
|
+
config: PowerSyncConfig;
|
|
86
|
+
/**
|
|
87
|
+
* Authentication provider.
|
|
88
|
+
* Abstracts auth for the connector - works with any auth backend.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* import { createSupabaseAuth } from '@pol-studios/powersync';
|
|
93
|
+
* const auth = createSupabaseAuth(supabaseClient);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
auth: AuthProvider;
|
|
97
|
+
/**
|
|
98
|
+
* Storage backend for attachments (required if using attachments).
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import { createSupabaseStorage } from '@pol-studios/powersync';
|
|
103
|
+
* const storage = createSupabaseStorage({
|
|
104
|
+
* client: supabaseClient,
|
|
105
|
+
* defaultBucket: 'attachments',
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
storage?: StorageBackend;
|
|
110
|
+
/**
|
|
111
|
+
* Attachment configuration.
|
|
112
|
+
* Zero domain coupling - use skipDownload callback for domain-specific filtering.
|
|
113
|
+
*/
|
|
114
|
+
attachments?: AttachmentConfig;
|
|
115
|
+
/**
|
|
116
|
+
* Platform adapter (auto-detected if omitted).
|
|
117
|
+
* Use createNativePlatformAdapter() for React Native.
|
|
118
|
+
*/
|
|
119
|
+
platform?: PlatformAdapter;
|
|
120
|
+
/**
|
|
121
|
+
* Error handler for sync failures.
|
|
122
|
+
* Receives structured errors with classification and user messages.
|
|
123
|
+
*/
|
|
124
|
+
onError?: (error: SyncError) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Called when PowerSync is initialized and ready.
|
|
127
|
+
*/
|
|
128
|
+
onReady?: () => void;
|
|
129
|
+
/**
|
|
130
|
+
* Called when sync status changes.
|
|
131
|
+
*/
|
|
132
|
+
onSyncStatusChange?: (status: SyncStatus) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Child components to render.
|
|
135
|
+
*/
|
|
136
|
+
children: ReactNode;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Value provided by the main PowerSyncContext.
|
|
140
|
+
*/
|
|
141
|
+
interface PowerSyncContextValue {
|
|
142
|
+
/**
|
|
143
|
+
* The PowerSync database instance.
|
|
144
|
+
* Will be null if not initialized or if initialization failed.
|
|
145
|
+
*/
|
|
146
|
+
db: AbstractPowerSyncDatabase | null;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the PowerSync database is ready for use.
|
|
149
|
+
*/
|
|
150
|
+
isReady: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Whether the provider is currently initializing.
|
|
153
|
+
*/
|
|
154
|
+
isInitializing: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Error that occurred during initialization, if any.
|
|
157
|
+
*/
|
|
158
|
+
error: Error | null;
|
|
159
|
+
/**
|
|
160
|
+
* The platform adapter instance.
|
|
161
|
+
*/
|
|
162
|
+
platform: PlatformAdapter;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Value provided by the SyncStatusContext.
|
|
166
|
+
*/
|
|
167
|
+
interface SyncStatusContextValue {
|
|
168
|
+
/**
|
|
169
|
+
* Current sync status.
|
|
170
|
+
*/
|
|
171
|
+
status: SyncStatus;
|
|
172
|
+
/**
|
|
173
|
+
* Timestamp of the last successful sync.
|
|
174
|
+
*/
|
|
175
|
+
lastSyncedAt: Date | null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Value provided by the AttachmentQueueContext.
|
|
179
|
+
*/
|
|
180
|
+
interface AttachmentQueueContextValue {
|
|
181
|
+
/**
|
|
182
|
+
* The attachment queue instance.
|
|
183
|
+
* Will be null if attachments are not configured or not initialized.
|
|
184
|
+
*/
|
|
185
|
+
queue: PolAttachmentQueue | null;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the attachment queue is ready for use.
|
|
188
|
+
*/
|
|
189
|
+
isReady: boolean;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Slim PowerSyncProvider for @pol-studios/powersync
|
|
194
|
+
*
|
|
195
|
+
* A simplified, composable provider that:
|
|
196
|
+
* - Has zero @pol/db coupling
|
|
197
|
+
* - Uses AuthProvider interface for any auth backend
|
|
198
|
+
* - Delegates domain logic to callbacks
|
|
199
|
+
* - Is ~150 lines vs 1400+ in the legacy provider
|
|
200
|
+
*
|
|
201
|
+
* For backwards compatibility, the legacy OfflineDataProvider is still available.
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Slim PowerSyncProvider - minimal, composable, no domain coupling.
|
|
206
|
+
*
|
|
207
|
+
* This provider handles:
|
|
208
|
+
* - Database initialization via platform adapter
|
|
209
|
+
* - Connector setup using AuthProvider
|
|
210
|
+
* - Attachment queue initialization (if configured)
|
|
211
|
+
* - Sync status tracking
|
|
212
|
+
* - Error classification and callbacks
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```tsx
|
|
216
|
+
* import { PowerSyncProvider, createSupabaseAuth, createSupabaseStorage } from '@pol-studios/powersync/react';
|
|
217
|
+
*
|
|
218
|
+
* function App() {
|
|
219
|
+
* const auth = useMemo(() => createSupabaseAuth(supabase), [supabase]);
|
|
220
|
+
* const storage = useMemo(() => createSupabaseStorage({
|
|
221
|
+
* client: supabase,
|
|
222
|
+
* defaultBucket: 'attachments',
|
|
223
|
+
* }), [supabase]);
|
|
224
|
+
*
|
|
225
|
+
* return (
|
|
226
|
+
* <PowerSyncProvider
|
|
227
|
+
* config={{ schema: AppSchema, powerSyncUrl: URL, dbFilename: 'app.db' }}
|
|
228
|
+
* auth={auth}
|
|
229
|
+
* storage={storage}
|
|
230
|
+
* attachments={{ watch: { table: 'Media', idColumn: 'storagePath' } }}
|
|
231
|
+
* onError={(error) => showToast(error.userMessage)}
|
|
232
|
+
* onReady={() => console.log('Ready!')}
|
|
233
|
+
* >
|
|
234
|
+
* <MyApp />
|
|
235
|
+
* </PowerSyncProvider>
|
|
236
|
+
* );
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function SlimPowerSyncProvider({ config, auth, storage, attachments, platform: customPlatform, onError, onReady, onSyncStatusChange, children, }: PowerSyncProviderProps): react__default.ReactElement;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Main context for PowerSync database instance and initialization state.
|
|
244
|
+
*
|
|
245
|
+
* Provides access to:
|
|
246
|
+
* - PowerSync database instance
|
|
247
|
+
* - Initialization state (isReady, isInitializing, error)
|
|
248
|
+
* - Platform adapter
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* import { useContext } from 'react';
|
|
253
|
+
* import { PowerSyncContext } from '@pol-studios/powersync/react';
|
|
254
|
+
*
|
|
255
|
+
* function MyComponent() {
|
|
256
|
+
* const { db, isReady, error } = useContext(PowerSyncContext);
|
|
257
|
+
* if (!isReady) return <Loading />;
|
|
258
|
+
* if (error) return <Error message={error.message} />;
|
|
259
|
+
* // Use db...
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
declare const PowerSyncContext: react.Context<PowerSyncContextValue>;
|
|
264
|
+
/**
|
|
265
|
+
* Context for sync status updates.
|
|
266
|
+
*
|
|
267
|
+
* Provides access to:
|
|
268
|
+
* - Current sync status (connected, syncing, etc.)
|
|
269
|
+
* - Last synced timestamp
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* import { useContext } from 'react';
|
|
274
|
+
* import { SyncStatusContext } from '@pol-studios/powersync/react';
|
|
275
|
+
*
|
|
276
|
+
* function SyncIndicator() {
|
|
277
|
+
* const { status, lastSyncedAt } = useContext(SyncStatusContext);
|
|
278
|
+
* return (
|
|
279
|
+
* <View>
|
|
280
|
+
* {status.connected ? 'Connected' : 'Offline'}
|
|
281
|
+
* {lastSyncedAt && <Text>Last synced: {lastSyncedAt.toISOString()}</Text>}
|
|
282
|
+
* </View>
|
|
283
|
+
* );
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
declare const SyncStatusContext: react.Context<SyncStatusContextValue>;
|
|
288
|
+
/**
|
|
289
|
+
* Context for the attachment queue (if configured).
|
|
290
|
+
*
|
|
291
|
+
* Provides access to:
|
|
292
|
+
* - AttachmentQueue instance for checking stats, pausing/resuming downloads
|
|
293
|
+
* - Ready state for the attachment queue
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* import { useContext } from 'react';
|
|
298
|
+
* import { AttachmentQueueContext } from '@pol-studios/powersync/react';
|
|
299
|
+
*
|
|
300
|
+
* function AttachmentStatus() {
|
|
301
|
+
* const { queue, isReady } = useContext(AttachmentQueueContext);
|
|
302
|
+
* if (!isReady || !queue) return null;
|
|
303
|
+
*
|
|
304
|
+
* const stats = await queue.getStats();
|
|
305
|
+
* return <Text>Downloaded: {stats.syncedCount}/{stats.totalExpected}</Text>;
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
declare const AttachmentQueueContext: react.Context<AttachmentQueueContextValue>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* React Module for @pol-studios/powersync
|
|
313
|
+
*
|
|
314
|
+
* This module exports the new slim PowerSyncProvider and related contexts/types.
|
|
315
|
+
* For backwards compatibility, the legacy OfflineDataProvider is still available
|
|
316
|
+
* from the main package export.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* import {
|
|
321
|
+
* PowerSyncProvider,
|
|
322
|
+
* usePowerSyncContext,
|
|
323
|
+
* useSyncStatusContext,
|
|
324
|
+
* useAttachmentQueueContext,
|
|
325
|
+
* } from '@pol-studios/powersync/react';
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Hook to access the PowerSync context.
|
|
331
|
+
* Throws if used outside of a PowerSyncProvider.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* function MyComponent() {
|
|
336
|
+
* const { db, isReady, error } = usePowerSyncContext();
|
|
337
|
+
* if (!isReady) return <Loading />;
|
|
338
|
+
* if (error) return <Error message={error.message} />;
|
|
339
|
+
* // Use db...
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function usePowerSyncContext(): PowerSyncContextValue;
|
|
344
|
+
/**
|
|
345
|
+
* Hook to access sync status.
|
|
346
|
+
* Throws if used outside of a PowerSyncProvider.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* function SyncIndicator() {
|
|
351
|
+
* const { status, lastSyncedAt } = useSyncStatusContext();
|
|
352
|
+
* return <Text>{status.connected ? 'Online' : 'Offline'}</Text>;
|
|
353
|
+
* }
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
declare function useSyncStatusContext(): SyncStatusContextValue;
|
|
357
|
+
/**
|
|
358
|
+
* Hook to access the attachment queue.
|
|
359
|
+
* Throws if used outside of a PowerSyncProvider.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* function AttachmentStatus() {
|
|
364
|
+
* const { queue, isReady } = useAttachmentQueueContext();
|
|
365
|
+
* if (!isReady || !queue) return null;
|
|
366
|
+
* // Use queue...
|
|
367
|
+
* }
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
declare function useAttachmentQueueContext(): AttachmentQueueContextValue;
|
|
371
|
+
|
|
372
|
+
export { AttachmentQueueContext, type AttachmentQueueContextValue, type PowerSyncConfig, PowerSyncContext, type PowerSyncContextValue, SlimPowerSyncProvider as PowerSyncProvider, type PowerSyncProviderProps, SlimPowerSyncProvider, SyncStatusContext, type SyncStatusContextValue, useAttachmentQueueContext, usePowerSyncContext, useSyncStatusContext };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AttachmentQueueContext,
|
|
3
|
+
PowerSyncContext,
|
|
4
|
+
SlimPowerSyncProvider,
|
|
5
|
+
SyncStatusContext,
|
|
6
|
+
useAttachmentQueueContext,
|
|
7
|
+
usePowerSyncContext,
|
|
8
|
+
useSyncStatusContext
|
|
9
|
+
} from "../chunk-63PXSPIN.js";
|
|
10
|
+
import "../chunk-4TXTAEF2.js";
|
|
11
|
+
import "../chunk-24RDMMCL.js";
|
|
12
|
+
import "../chunk-KN2IZERF.js";
|
|
13
|
+
import "../chunk-FV2HXEIY.js";
|
|
14
|
+
import "../chunk-VACPAAQZ.js";
|
|
15
|
+
export {
|
|
16
|
+
AttachmentQueueContext,
|
|
17
|
+
PowerSyncContext,
|
|
18
|
+
SlimPowerSyncProvider as PowerSyncProvider,
|
|
19
|
+
SlimPowerSyncProvider,
|
|
20
|
+
SyncStatusContext,
|
|
21
|
+
useAttachmentQueueContext,
|
|
22
|
+
usePowerSyncContext,
|
|
23
|
+
useSyncStatusContext
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-
|
|
1
|
+
export { D as DownloadResult, a as StorageBackend, b as StorageUploadOptions, d as SupabaseClient, S as SupabaseStorage, c as SupabaseStorageOptions, e as SupabaseTransformOptions, U as UploadProgress, r as resolveBucket } from '../types-D0WcHrq6.js';
|
|
2
|
+
export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManagerOptions, D as DEFAULT_CACHE_SETTINGS, I as ImageTransformOptions, S as SupabaseStorageAdapter, e as SupabaseStorageAdapterOptions, c as createSupabaseStorage, d as createSupabaseStorageAdapter, g as getStorageErrorMessage, a as isBlobResult, i as isFileResult, b as isStorageAuthError, n as normalizeStoragePath } from '../CacheSettingsManager-uz-kbnRH.js';
|
|
3
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
|
|
4
4
|
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.js';
|
|
5
5
|
import '../platform/index.js';
|
|
6
6
|
import '../types-CDqWh56B.js';
|
package/dist/storage/index.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-T4AO7JIG.js";
|
|
2
2
|
import {
|
|
3
3
|
CacheSettingsManager,
|
|
4
4
|
DEFAULT_CACHE_SETTINGS,
|
|
5
|
+
createSupabaseStorage,
|
|
6
|
+
isBlobResult,
|
|
7
|
+
isFileResult
|
|
8
|
+
} from "../chunk-XOY2CJ67.js";
|
|
9
|
+
import {
|
|
5
10
|
SupabaseStorageAdapter,
|
|
6
|
-
createSupabaseStorageAdapter
|
|
7
|
-
|
|
11
|
+
createSupabaseStorageAdapter,
|
|
12
|
+
getStorageErrorMessage,
|
|
13
|
+
isStorageAuthError,
|
|
14
|
+
normalizeStoragePath
|
|
15
|
+
} from "../chunk-XAEII4ZX.js";
|
|
8
16
|
import "../chunk-TGBT5XBE.js";
|
|
9
17
|
import {
|
|
10
18
|
SupabaseUploadHandler,
|
|
11
19
|
createSupabaseUploadHandler
|
|
12
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-P4HZA6ZT.js";
|
|
13
21
|
import {
|
|
14
22
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
15
|
-
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
23
|
+
resolveBucket
|
|
24
|
+
} from "../chunk-Z6VOBGTU.js";
|
|
25
|
+
import "../chunk-FV2HXEIY.js";
|
|
18
26
|
export {
|
|
19
27
|
CacheSettingsManager,
|
|
20
28
|
DEFAULT_CACHE_SETTINGS,
|
|
21
29
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
22
30
|
SupabaseStorageAdapter,
|
|
23
31
|
SupabaseUploadHandler,
|
|
32
|
+
createSupabaseStorage,
|
|
24
33
|
createSupabaseStorageAdapter,
|
|
25
34
|
createSupabaseUploadHandler,
|
|
26
|
-
|
|
35
|
+
getStorageErrorMessage,
|
|
36
|
+
isBlobResult,
|
|
37
|
+
isFileResult,
|
|
38
|
+
isStorageAuthError,
|
|
39
|
+
normalizeStoragePath,
|
|
40
|
+
resolveBucket
|
|
27
41
|
};
|
|
28
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-
|
|
1
|
+
export { D as DownloadResult, a as StorageBackend, b as StorageUploadOptions, d as SupabaseClient, S as SupabaseStorage, c as SupabaseStorageOptions, U as UploadProgress, r as resolveBucket } from '../types-D0WcHrq6.js';
|
|
2
|
+
export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManagerOptions, D as DEFAULT_CACHE_SETTINGS, S as SupabaseStorageAdapter, c as createSupabaseStorage, d as createSupabaseStorageAdapter, g as getStorageErrorMessage, a as isBlobResult, i as isFileResult, b as isStorageAuthError, n as normalizeStoragePath } from '../CacheSettingsManager-uz-kbnRH.js';
|
|
3
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
|
|
4
4
|
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.native.js';
|
|
5
5
|
import '../platform/index.js';
|
|
6
6
|
import '../types-CDqWh56B.js';
|