@pol-studios/powersync 1.0.4 → 1.0.7
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/CacheSettingsManager-1exbOC6S.d.ts +261 -0
- package/dist/attachments/index.d.ts +65 -355
- package/dist/attachments/index.js +24 -6
- package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
- package/dist/chunk-4C3RY5SU.js +204 -0
- package/dist/chunk-4C3RY5SU.js.map +1 -0
- package/dist/{chunk-3AYXHQ4W.js → chunk-53WH2JJV.js} +111 -47
- package/dist/chunk-53WH2JJV.js.map +1 -0
- package/dist/chunk-A4IBBWGO.js +377 -0
- package/dist/chunk-A4IBBWGO.js.map +1 -0
- package/dist/chunk-BREGB4WL.js +1768 -0
- package/dist/chunk-BREGB4WL.js.map +1 -0
- package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
- package/dist/chunk-CGL33PL4.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DHYUBVP7.js +131 -0
- package/dist/chunk-DHYUBVP7.js.map +1 -0
- package/dist/chunk-FV2HXEIY.js +124 -0
- package/dist/chunk-FV2HXEIY.js.map +1 -0
- package/dist/chunk-GKF7TOMT.js +1 -0
- package/dist/{chunk-OTJXIRWX.js → chunk-H772V6XQ.js} +304 -51
- package/dist/chunk-H772V6XQ.js.map +1 -0
- package/dist/{chunk-C2RSTGDC.js → chunk-HFOFLW5F.js} +525 -87
- package/dist/chunk-HFOFLW5F.js.map +1 -0
- package/dist/chunk-KGSFAE5B.js +1 -0
- package/dist/chunk-LNL64IJZ.js +1 -0
- package/dist/chunk-MKD2VCX3.js +32 -0
- package/dist/chunk-MKD2VCX3.js.map +1 -0
- package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
- package/dist/chunk-N75DEF5J.js.map +1 -0
- package/dist/chunk-P6WOZO7H.js +49 -0
- package/dist/chunk-P6WOZO7H.js.map +1 -0
- package/dist/chunk-TGBT5XBE.js +1 -0
- package/dist/chunk-TGBT5XBE.js.map +1 -0
- package/dist/chunk-UEYRTLKE.js +72 -0
- package/dist/chunk-UEYRTLKE.js.map +1 -0
- package/dist/chunk-WGHNIAF7.js +329 -0
- package/dist/chunk-WGHNIAF7.js.map +1 -0
- package/dist/chunk-WQ5MPAVC.js +449 -0
- package/dist/chunk-WQ5MPAVC.js.map +1 -0
- package/dist/{chunk-FPTDATY5.js → chunk-XQAJM2MW.js} +22 -11
- package/dist/chunk-XQAJM2MW.js.map +1 -0
- package/dist/chunk-YSTEESEG.js +676 -0
- package/dist/chunk-YSTEESEG.js.map +1 -0
- package/dist/chunk-ZEOKPWUC.js +1165 -0
- package/dist/chunk-ZEOKPWUC.js.map +1 -0
- package/dist/connector/index.d.ts +182 -2
- package/dist/connector/index.js +14 -3
- package/dist/core/index.d.ts +5 -3
- package/dist/core/index.js +5 -2
- package/dist/error/index.d.ts +54 -0
- package/dist/error/index.js +8 -0
- package/dist/error/index.js.map +1 -0
- package/dist/index.d.ts +237 -11
- package/dist/index.js +183 -27
- package/dist/index.native.d.ts +20 -9
- package/dist/index.native.js +183 -28
- package/dist/index.web.d.ts +20 -9
- package/dist/index.web.js +184 -28
- package/dist/maintenance/index.d.ts +118 -0
- package/dist/maintenance/index.js +17 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/platform/index.d.ts +16 -1
- package/dist/platform/index.js +2 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.d.ts +2 -2
- package/dist/platform/index.native.js +2 -1
- package/dist/platform/index.web.d.ts +1 -1
- package/dist/platform/index.web.js +2 -1
- package/dist/pol-attachment-queue-C7YNXXhK.d.ts +676 -0
- package/dist/provider/index.d.ts +693 -12
- package/dist/provider/index.js +57 -12
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.js +28 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.native.d.ts +6 -0
- package/dist/storage/index.native.js +26 -0
- package/dist/storage/index.native.js.map +1 -0
- package/dist/storage/index.web.d.ts +6 -0
- package/dist/storage/index.web.js +26 -0
- package/dist/storage/index.web.js.map +1 -0
- package/dist/storage/upload/index.d.ts +55 -0
- package/dist/storage/upload/index.js +15 -0
- package/dist/storage/upload/index.js.map +1 -0
- package/dist/storage/upload/index.native.d.ts +57 -0
- package/dist/storage/upload/index.native.js +14 -0
- package/dist/storage/upload/index.native.js.map +1 -0
- package/dist/storage/upload/index.web.d.ts +5 -0
- package/dist/storage/upload/index.web.js +14 -0
- package/dist/storage/upload/index.web.js.map +1 -0
- package/dist/{index-Cb-NI0Ct.d.ts → supabase-connector-qLm-WHkM.d.ts} +146 -10
- package/dist/sync/index.d.ts +288 -22
- package/dist/sync/index.js +23 -5
- package/dist/types-BVacP54t.d.ts +52 -0
- package/dist/types-Bgvx7-E8.d.ts +187 -0
- package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
- package/package.json +72 -2
- package/dist/chunk-32OLICZO.js +0 -1
- package/dist/chunk-3AYXHQ4W.js.map +0 -1
- package/dist/chunk-7EMDVIZX.js.map +0 -1
- package/dist/chunk-7JQZBZ5N.js +0 -1
- package/dist/chunk-C2RSTGDC.js.map +0 -1
- package/dist/chunk-EJ23MXPQ.js.map +0 -1
- package/dist/chunk-FPTDATY5.js.map +0 -1
- package/dist/chunk-GMFDCVMZ.js +0 -1285
- package/dist/chunk-GMFDCVMZ.js.map +0 -1
- package/dist/chunk-OLHGI472.js +0 -1
- package/dist/chunk-OTJXIRWX.js.map +0 -1
- package/dist/chunk-V6LJ6MR2.js +0 -740
- package/dist/chunk-V6LJ6MR2.js.map +0 -1
- package/dist/chunk-VJCL2SWD.js +0 -1
- /package/dist/{chunk-32OLICZO.js.map → chunk-DGUM43GV.js.map} +0 -0
- /package/dist/{chunk-7JQZBZ5N.js.map → chunk-GKF7TOMT.js.map} +0 -0
- /package/dist/{chunk-OLHGI472.js.map → chunk-KGSFAE5B.js.map} +0 -0
- /package/dist/{chunk-VJCL2SWD.js.map → chunk-LNL64IJZ.js.map} +0 -0
package/dist/index.web.js
CHANGED
|
@@ -1,47 +1,117 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-KGSFAE5B.js";
|
|
2
|
+
import "./chunk-GKF7TOMT.js";
|
|
3
3
|
import {
|
|
4
|
-
AttachmentQueueContext,
|
|
5
4
|
ConflictBus,
|
|
5
|
+
OfflineDataProvider,
|
|
6
|
+
PowerSyncProvider,
|
|
7
|
+
ProviderBridge
|
|
8
|
+
} from "./chunk-BREGB4WL.js";
|
|
9
|
+
import {
|
|
10
|
+
PowerSyncErrorBoundary
|
|
11
|
+
} from "./chunk-P6WOZO7H.js";
|
|
12
|
+
import {
|
|
13
|
+
ATTACHMENT_TABLE,
|
|
14
|
+
AbstractAttachmentQueue,
|
|
15
|
+
AttachmentState,
|
|
16
|
+
AttachmentTable,
|
|
17
|
+
DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
|
|
18
|
+
DEFAULT_CACHE_CONFIG,
|
|
19
|
+
DEFAULT_COMPRESSION_CONFIG,
|
|
20
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
21
|
+
EncodingType,
|
|
22
|
+
PolAttachmentQueue,
|
|
23
|
+
PolAttachmentState,
|
|
24
|
+
PolStorageAdapter,
|
|
25
|
+
createPolAttachmentQueue
|
|
26
|
+
} from "./chunk-ZEOKPWUC.js";
|
|
27
|
+
import {
|
|
28
|
+
DeadLetterQueue,
|
|
29
|
+
createDeadLetterEntry,
|
|
30
|
+
defineBackgroundSyncTask,
|
|
31
|
+
generateDLQEntryId,
|
|
32
|
+
initializeBackgroundSync,
|
|
33
|
+
isBackgroundSyncRegistered,
|
|
34
|
+
registerBackgroundSync,
|
|
35
|
+
unregisterBackgroundSync
|
|
36
|
+
} from "./chunk-A4IBBWGO.js";
|
|
37
|
+
import {
|
|
38
|
+
DEFAULT_CONNECTION_HEALTH,
|
|
39
|
+
DEFAULT_SYNC_CONFIG,
|
|
40
|
+
DEFAULT_SYNC_METRICS,
|
|
41
|
+
DEFAULT_SYNC_STATUS,
|
|
42
|
+
HealthMonitor,
|
|
43
|
+
MetricsCollector,
|
|
44
|
+
SyncStatusTracker
|
|
45
|
+
} from "./chunk-H772V6XQ.js";
|
|
46
|
+
import {
|
|
47
|
+
checkIntegrityImpl,
|
|
48
|
+
checkStorageQuotaImpl,
|
|
49
|
+
compactDatabaseImpl,
|
|
50
|
+
formatBytes,
|
|
51
|
+
getCacheStatsImpl,
|
|
52
|
+
useDatabaseMaintenance
|
|
53
|
+
} from "./chunk-WGHNIAF7.js";
|
|
54
|
+
import {
|
|
55
|
+
AttachmentQueueContext,
|
|
56
|
+
CompletedTransactionsContext,
|
|
6
57
|
ConnectionHealthContext,
|
|
58
|
+
ConnectionStatusContext,
|
|
59
|
+
FailedTransactionsContext,
|
|
60
|
+
PendingMutationsContext,
|
|
7
61
|
PowerSyncContext,
|
|
8
|
-
|
|
62
|
+
SyncActivityContext,
|
|
9
63
|
SyncMetricsContext,
|
|
64
|
+
SyncModeContext,
|
|
10
65
|
SyncStatusContext,
|
|
11
66
|
useAttachmentQueue,
|
|
67
|
+
useAttachmentQueueReady,
|
|
68
|
+
useCompletedTransactions,
|
|
69
|
+
useCompletedTransactionsContext,
|
|
12
70
|
useConnectionHealth,
|
|
71
|
+
useConnectionStatus,
|
|
13
72
|
useDatabase,
|
|
14
73
|
useDownloadProgress,
|
|
15
74
|
useEntitySyncStatus,
|
|
75
|
+
useFailedTransactions,
|
|
76
|
+
useFailedTransactionsContext,
|
|
16
77
|
useIsSyncing,
|
|
17
78
|
useOnlineStatus,
|
|
18
79
|
usePendingMutations,
|
|
80
|
+
usePendingMutationsContext,
|
|
19
81
|
usePlatform,
|
|
20
82
|
usePowerSync,
|
|
21
83
|
useSyncActivity,
|
|
84
|
+
useSyncActivityContext,
|
|
22
85
|
useSyncControl,
|
|
23
86
|
useSyncMetrics,
|
|
24
87
|
useSyncMode,
|
|
88
|
+
useSyncModeContext,
|
|
25
89
|
useSyncStatus,
|
|
26
90
|
useUploadStatus
|
|
27
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-YSTEESEG.js";
|
|
92
|
+
import "./chunk-LNL64IJZ.js";
|
|
28
93
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
CacheSettingsManager,
|
|
95
|
+
DEFAULT_CACHE_SETTINGS,
|
|
96
|
+
SupabaseStorageAdapter,
|
|
97
|
+
createSupabaseStorageAdapter,
|
|
98
|
+
getExtensionFromMimeType,
|
|
99
|
+
getMimeType,
|
|
100
|
+
getMimeTypeFromPath,
|
|
101
|
+
isAudioMimeType,
|
|
102
|
+
isDocumentMimeType,
|
|
103
|
+
isImageMimeType,
|
|
104
|
+
isVideoMimeType
|
|
105
|
+
} from "./chunk-WQ5MPAVC.js";
|
|
106
|
+
import "./chunk-TGBT5XBE.js";
|
|
36
107
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} from "./chunk-OTJXIRWX.js";
|
|
108
|
+
SupabaseUploadHandler,
|
|
109
|
+
createSupabaseUploadHandler
|
|
110
|
+
} from "./chunk-UEYRTLKE.js";
|
|
111
|
+
import {
|
|
112
|
+
DEFAULT_UPLOAD_NOTIFICATION,
|
|
113
|
+
resolveBucketFromConfig
|
|
114
|
+
} from "./chunk-MKD2VCX3.js";
|
|
45
115
|
import "./chunk-W7HSR35B.js";
|
|
46
116
|
import {
|
|
47
117
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -68,25 +138,42 @@ import {
|
|
|
68
138
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
69
139
|
STORAGE_CRITICAL_THRESHOLD,
|
|
70
140
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
141
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
71
142
|
STORAGE_KEY_ENABLED,
|
|
72
143
|
STORAGE_KEY_METRICS,
|
|
73
144
|
STORAGE_KEY_PAUSED,
|
|
74
145
|
STORAGE_KEY_PREFIX,
|
|
75
146
|
STORAGE_KEY_SYNC_MODE,
|
|
76
147
|
STORAGE_WARNING_THRESHOLD
|
|
77
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-CGL33PL4.js";
|
|
149
|
+
import "./chunk-53WH2JJV.js";
|
|
78
150
|
import {
|
|
79
151
|
createWebPlatformAdapter
|
|
80
|
-
} from "./chunk-
|
|
81
|
-
import
|
|
152
|
+
} from "./chunk-N75DEF5J.js";
|
|
153
|
+
import {
|
|
154
|
+
CircuitBreaker,
|
|
155
|
+
CircuitOpenError,
|
|
156
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG
|
|
157
|
+
} from "./chunk-4C3RY5SU.js";
|
|
82
158
|
import {
|
|
159
|
+
ConflictDetectionError,
|
|
160
|
+
DEFAULT_RETRY_CONFIG,
|
|
83
161
|
SupabaseConnector,
|
|
84
162
|
defaultSchemaRouter,
|
|
85
163
|
detectConflicts,
|
|
86
164
|
fetchServerVersion,
|
|
87
165
|
getLocalVersion,
|
|
88
166
|
hasVersionColumn
|
|
89
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-HFOFLW5F.js";
|
|
168
|
+
import {
|
|
169
|
+
AbortError,
|
|
170
|
+
DEFAULT_BACKOFF_CONFIG,
|
|
171
|
+
RetryExhaustedError,
|
|
172
|
+
addJitter,
|
|
173
|
+
calculateBackoffDelay,
|
|
174
|
+
sleep,
|
|
175
|
+
withExponentialBackoff
|
|
176
|
+
} from "./chunk-FV2HXEIY.js";
|
|
90
177
|
import {
|
|
91
178
|
AttachmentError,
|
|
92
179
|
ConfigurationError,
|
|
@@ -102,39 +189,58 @@ import {
|
|
|
102
189
|
extractTableNames,
|
|
103
190
|
generateFailureId,
|
|
104
191
|
toSyncOperationError
|
|
105
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-XQAJM2MW.js";
|
|
193
|
+
import "./chunk-DGUM43GV.js";
|
|
106
194
|
export {
|
|
107
195
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
108
196
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
197
|
+
ATTACHMENT_TABLE,
|
|
198
|
+
AbortError,
|
|
199
|
+
AbstractAttachmentQueue,
|
|
109
200
|
AttachmentError,
|
|
110
|
-
AttachmentQueue,
|
|
111
201
|
AttachmentQueueContext,
|
|
112
202
|
AttachmentState,
|
|
203
|
+
AttachmentTable,
|
|
113
204
|
COMPRESSION_MAX_WIDTH,
|
|
114
205
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
115
206
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
207
|
+
CacheSettingsManager,
|
|
208
|
+
CircuitBreaker,
|
|
209
|
+
CircuitOpenError,
|
|
210
|
+
CompletedTransactionsContext,
|
|
116
211
|
ConfigurationError,
|
|
117
212
|
ConflictBus,
|
|
213
|
+
ConflictDetectionError,
|
|
118
214
|
ConnectionHealthContext,
|
|
215
|
+
ConnectionStatusContext,
|
|
119
216
|
ConnectorError,
|
|
120
217
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
|
121
218
|
DEFAULT_ATTACHMENT_CONCURRENCY,
|
|
219
|
+
DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
|
|
220
|
+
DEFAULT_BACKOFF_CONFIG,
|
|
122
221
|
DEFAULT_CACHE_CONFIG,
|
|
222
|
+
DEFAULT_CACHE_SETTINGS,
|
|
223
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
123
224
|
DEFAULT_COMPRESSION_CONFIG,
|
|
124
225
|
DEFAULT_COMPRESSION_QUALITY,
|
|
125
226
|
DEFAULT_CONNECTION_HEALTH,
|
|
126
|
-
DEFAULT_DOWNLOAD_CONFIG,
|
|
127
227
|
DEFAULT_MAX_RETRY_ATTEMPTS,
|
|
128
228
|
DEFAULT_RETRY_BACKOFF_MULTIPLIER,
|
|
129
229
|
DEFAULT_RETRY_BASE_DELAY_MS,
|
|
230
|
+
DEFAULT_RETRY_CONFIG,
|
|
130
231
|
DEFAULT_RETRY_MAX_DELAY_MS,
|
|
131
232
|
DEFAULT_SYNC_CONFIG,
|
|
132
233
|
DEFAULT_SYNC_INTERVAL_MS,
|
|
133
234
|
DEFAULT_SYNC_METRICS,
|
|
134
235
|
DEFAULT_SYNC_MODE,
|
|
135
236
|
DEFAULT_SYNC_STATUS,
|
|
237
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
238
|
+
DEFAULT_UPLOAD_NOTIFICATION,
|
|
136
239
|
DOWNLOAD_STOP_THRESHOLD,
|
|
240
|
+
DeadLetterQueue,
|
|
137
241
|
EVICTION_TRIGGER_THRESHOLD,
|
|
242
|
+
EncodingType,
|
|
243
|
+
FailedTransactionsContext,
|
|
138
244
|
HEALTH_CHECK_INTERVAL_MS,
|
|
139
245
|
HEALTH_CHECK_TIMEOUT_MS,
|
|
140
246
|
HealthMonitor,
|
|
@@ -142,14 +248,23 @@ export {
|
|
|
142
248
|
LATENCY_DEGRADED_THRESHOLD_MS,
|
|
143
249
|
MAX_CONSECUTIVE_FAILURES,
|
|
144
250
|
MetricsCollector,
|
|
251
|
+
OfflineDataProvider,
|
|
252
|
+
PendingMutationsContext,
|
|
145
253
|
PlatformAdapterError,
|
|
254
|
+
PolAttachmentQueue,
|
|
255
|
+
PolAttachmentState,
|
|
256
|
+
PolStorageAdapter,
|
|
146
257
|
PowerSyncContext,
|
|
147
258
|
PowerSyncError,
|
|
259
|
+
PowerSyncErrorBoundary,
|
|
148
260
|
PowerSyncProvider,
|
|
261
|
+
ProviderBridge,
|
|
262
|
+
RetryExhaustedError,
|
|
149
263
|
STATS_CACHE_TTL_MS,
|
|
150
264
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
151
265
|
STORAGE_CRITICAL_THRESHOLD,
|
|
152
266
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
267
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
153
268
|
STORAGE_KEY_ENABLED,
|
|
154
269
|
STORAGE_KEY_METRICS,
|
|
155
270
|
STORAGE_KEY_PAUSED,
|
|
@@ -157,38 +272,79 @@ export {
|
|
|
157
272
|
STORAGE_KEY_SYNC_MODE,
|
|
158
273
|
STORAGE_WARNING_THRESHOLD,
|
|
159
274
|
SupabaseConnector,
|
|
275
|
+
SupabaseStorageAdapter,
|
|
276
|
+
SupabaseUploadHandler,
|
|
277
|
+
SyncActivityContext,
|
|
160
278
|
SyncMetricsContext,
|
|
279
|
+
SyncModeContext,
|
|
161
280
|
SyncOperationError,
|
|
162
281
|
SyncStatusContext,
|
|
163
282
|
SyncStatusTracker,
|
|
283
|
+
addJitter,
|
|
284
|
+
calculateBackoffDelay,
|
|
285
|
+
checkIntegrityImpl,
|
|
286
|
+
checkStorageQuotaImpl,
|
|
164
287
|
classifyError,
|
|
165
288
|
classifySupabaseError,
|
|
289
|
+
compactDatabaseImpl,
|
|
290
|
+
createDeadLetterEntry,
|
|
291
|
+
createPolAttachmentQueue,
|
|
292
|
+
createSupabaseStorageAdapter,
|
|
293
|
+
createSupabaseUploadHandler,
|
|
166
294
|
createSyncError,
|
|
167
295
|
createWebPlatformAdapter,
|
|
168
296
|
defaultSchemaRouter,
|
|
297
|
+
defineBackgroundSyncTask,
|
|
169
298
|
detectConflicts,
|
|
170
299
|
extractEntityIds,
|
|
171
300
|
extractTableNames,
|
|
172
301
|
fetchServerVersion,
|
|
302
|
+
formatBytes,
|
|
303
|
+
generateDLQEntryId,
|
|
173
304
|
generateFailureId,
|
|
305
|
+
getCacheStatsImpl,
|
|
306
|
+
getExtensionFromMimeType,
|
|
174
307
|
getLocalVersion,
|
|
308
|
+
getMimeType,
|
|
309
|
+
getMimeTypeFromPath,
|
|
175
310
|
hasVersionColumn,
|
|
311
|
+
initializeBackgroundSync,
|
|
312
|
+
isAudioMimeType,
|
|
313
|
+
isBackgroundSyncRegistered,
|
|
314
|
+
isDocumentMimeType,
|
|
315
|
+
isImageMimeType,
|
|
316
|
+
isVideoMimeType,
|
|
317
|
+
registerBackgroundSync,
|
|
318
|
+
resolveBucketFromConfig,
|
|
319
|
+
sleep,
|
|
176
320
|
toSyncOperationError,
|
|
321
|
+
unregisterBackgroundSync,
|
|
177
322
|
useAttachmentQueue,
|
|
323
|
+
useAttachmentQueueReady,
|
|
324
|
+
useCompletedTransactions,
|
|
325
|
+
useCompletedTransactionsContext,
|
|
178
326
|
useConnectionHealth,
|
|
327
|
+
useConnectionStatus,
|
|
179
328
|
useDatabase,
|
|
329
|
+
useDatabaseMaintenance,
|
|
180
330
|
useDownloadProgress,
|
|
181
331
|
useEntitySyncStatus,
|
|
332
|
+
useFailedTransactions,
|
|
333
|
+
useFailedTransactionsContext,
|
|
182
334
|
useIsSyncing,
|
|
183
335
|
useOnlineStatus,
|
|
184
336
|
usePendingMutations,
|
|
337
|
+
usePendingMutationsContext,
|
|
185
338
|
usePlatform,
|
|
186
339
|
usePowerSync,
|
|
187
340
|
useSyncActivity,
|
|
341
|
+
useSyncActivityContext,
|
|
188
342
|
useSyncControl,
|
|
189
343
|
useSyncMetrics,
|
|
190
344
|
useSyncMode,
|
|
345
|
+
useSyncModeContext,
|
|
191
346
|
useSyncStatus,
|
|
192
|
-
useUploadStatus
|
|
347
|
+
useUploadStatus,
|
|
348
|
+
withExponentialBackoff
|
|
193
349
|
};
|
|
194
350
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { k as CacheStats, j as CompactResult, I as IntegrityResult, d as StorageQuota, A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
|
|
2
|
+
export { c as StorageInfo } from '../types-CDqWh56B.js';
|
|
3
|
+
import { LoggerAdapter } from '../platform/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Database Maintenance Module Types for @pol-studios/powersync
|
|
7
|
+
*
|
|
8
|
+
* This module provides types for database maintenance operations including
|
|
9
|
+
* cache inspection, compaction, integrity checking, and storage quota monitoring.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Return type for the useDatabaseMaintenance hook.
|
|
14
|
+
* Provides utilities for inspecting and maintaining the PowerSync database.
|
|
15
|
+
*/
|
|
16
|
+
interface DatabaseMaintenanceUtils {
|
|
17
|
+
/**
|
|
18
|
+
* Get detailed cache statistics for all tables.
|
|
19
|
+
* Returns null if the database is not available.
|
|
20
|
+
*
|
|
21
|
+
* @returns Cache statistics including table-level details and storage info
|
|
22
|
+
*/
|
|
23
|
+
getCacheStats: () => Promise<CacheStats | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Compact the database by running VACUUM.
|
|
26
|
+
* This reclaims free pages and reduces the database file size.
|
|
27
|
+
*
|
|
28
|
+
* @returns Result of the compaction operation
|
|
29
|
+
*/
|
|
30
|
+
compactDatabase: () => Promise<CompactResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Check the integrity of the database.
|
|
33
|
+
* Runs SQLite integrity_check pragma.
|
|
34
|
+
*
|
|
35
|
+
* @returns Result indicating health status and any issues found
|
|
36
|
+
*/
|
|
37
|
+
checkIntegrity: () => Promise<IntegrityResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Check device storage quota and database size.
|
|
40
|
+
* Useful for warning users about low storage situations.
|
|
41
|
+
*
|
|
42
|
+
* @returns Storage quota information with status
|
|
43
|
+
*/
|
|
44
|
+
checkStorageQuota: () => Promise<StorageQuota>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Pure Database Maintenance Functions for @pol-studios/powersync
|
|
49
|
+
*
|
|
50
|
+
* This module contains stateless, pure functions for database maintenance operations.
|
|
51
|
+
* These functions can be called by hooks or used directly in other contexts.
|
|
52
|
+
*
|
|
53
|
+
* All functions accept the database as a parameter rather than accessing it from context,
|
|
54
|
+
* making them testable and reusable across different environments.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get detailed cache statistics for all tables in the database.
|
|
59
|
+
*
|
|
60
|
+
* This function:
|
|
61
|
+
* - Queries all tables from sqlite_master
|
|
62
|
+
* - Tries to get table sizes from dbstat (with fallback estimation)
|
|
63
|
+
* - Batches table row counts in groups of 50
|
|
64
|
+
* - Calculates storage info from PRAGMA page_size, page_count, freelist_count
|
|
65
|
+
*
|
|
66
|
+
* @param db - The PowerSync database instance
|
|
67
|
+
* @param logger - Optional logger for debug output
|
|
68
|
+
* @returns Cache statistics or null if operation times out or fails
|
|
69
|
+
*/
|
|
70
|
+
declare function getCacheStatsImpl(db: AbstractPowerSyncDatabase, logger?: LoggerAdapter): Promise<CacheStats | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Compact the database by running VACUUM.
|
|
73
|
+
* This reclaims free pages and reduces the database file size.
|
|
74
|
+
*
|
|
75
|
+
* @param db - The PowerSync database instance
|
|
76
|
+
* @returns Result of the compaction operation including bytes reclaimed
|
|
77
|
+
*/
|
|
78
|
+
declare function compactDatabaseImpl(db: AbstractPowerSyncDatabase): Promise<CompactResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Check the integrity of the database.
|
|
81
|
+
* Runs SQLite's PRAGMA integrity_check.
|
|
82
|
+
*
|
|
83
|
+
* @param db - The PowerSync database instance
|
|
84
|
+
* @returns Result indicating health status and any issues found
|
|
85
|
+
*/
|
|
86
|
+
declare function checkIntegrityImpl(db: AbstractPowerSyncDatabase): Promise<IntegrityResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Check device storage quota and database size.
|
|
89
|
+
* Useful for warning users about low storage situations.
|
|
90
|
+
*
|
|
91
|
+
* @param db - The PowerSync database instance (can be null)
|
|
92
|
+
* @param getFreeDiskSpace - Callback to get free disk space in bytes
|
|
93
|
+
* @returns Storage quota information with status
|
|
94
|
+
*/
|
|
95
|
+
declare function checkStorageQuotaImpl(db: AbstractPowerSyncDatabase | null, getFreeDiskSpace: () => Promise<number>): Promise<StorageQuota>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* React Hook for Database Maintenance Utilities
|
|
99
|
+
*
|
|
100
|
+
* This module provides a React hook that wraps the pure database maintenance
|
|
101
|
+
* functions with stable function references via useCallback.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Hook for database maintenance utilities.
|
|
106
|
+
*
|
|
107
|
+
* Use this hook when you need to perform database maintenance operations.
|
|
108
|
+
* These operations are expensive - call sparingly (e.g., settings screens).
|
|
109
|
+
*
|
|
110
|
+
* Each function has a stable reference via useCallback.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const { getCacheStats, compactDatabase } = useDatabaseMaintenance();
|
|
114
|
+
* const stats = await getCacheStats();
|
|
115
|
+
*/
|
|
116
|
+
declare function useDatabaseMaintenance(): DatabaseMaintenanceUtils;
|
|
117
|
+
|
|
118
|
+
export { CacheStats, CompactResult, type DatabaseMaintenanceUtils, IntegrityResult, StorageQuota, checkIntegrityImpl, checkStorageQuotaImpl, compactDatabaseImpl, getCacheStatsImpl, useDatabaseMaintenance };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkIntegrityImpl,
|
|
3
|
+
checkStorageQuotaImpl,
|
|
4
|
+
compactDatabaseImpl,
|
|
5
|
+
getCacheStatsImpl,
|
|
6
|
+
useDatabaseMaintenance
|
|
7
|
+
} from "../chunk-WGHNIAF7.js";
|
|
8
|
+
import "../chunk-YSTEESEG.js";
|
|
9
|
+
import "../chunk-DGUM43GV.js";
|
|
10
|
+
export {
|
|
11
|
+
checkIntegrityImpl,
|
|
12
|
+
checkStorageQuotaImpl,
|
|
13
|
+
compactDatabaseImpl,
|
|
14
|
+
getCacheStatsImpl,
|
|
15
|
+
useDatabaseMaintenance
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/platform/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AbstractPowerSyncDatabase } from '../types-
|
|
1
|
+
import { A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Platform Adapter Types for @pol-studios/powersync
|
|
@@ -95,6 +95,21 @@ interface FileSystemAdapter {
|
|
|
95
95
|
* Get the free disk space in bytes
|
|
96
96
|
*/
|
|
97
97
|
getFreeDiskSpace(): Promise<number>;
|
|
98
|
+
/**
|
|
99
|
+
* Download a file from a URL directly to a local path.
|
|
100
|
+
*
|
|
101
|
+
* React Native: Uses expo-file-system downloadAsync which streams
|
|
102
|
+
* directly to disk without loading the entire file into memory,
|
|
103
|
+
* making it suitable for large files.
|
|
104
|
+
*
|
|
105
|
+
* Web: Uses fetch + blob + base64 conversion to IndexedDB. Note that
|
|
106
|
+
* the file is temporarily held in memory during conversion, so very
|
|
107
|
+
* large files (>50MB) may cause memory pressure on web platforms.
|
|
108
|
+
*
|
|
109
|
+
* @param url - The URL to download from
|
|
110
|
+
* @param localPath - The local path to save the file to
|
|
111
|
+
*/
|
|
112
|
+
downloadFile(url: string, localPath: string): Promise<void>;
|
|
98
113
|
}
|
|
99
114
|
/**
|
|
100
115
|
* Key-value storage interface for persisting preferences and state.
|
package/dist/platform/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/platform/types.ts"],"sourcesContent":["/**\n * Platform Adapter Types for @pol-studios/powersync\n *\n * This module defines the interfaces that platform-specific adapters must implement.\n * Consumers provide an adapter for their platform (React Native or Web) that handles\n * platform-specific operations like file system access, async storage, and network status.\n */\n\nimport type { AbstractPowerSyncDatabase } from '../core/types';\n\n// ─── Database Factory Options ────────────────────────────────────────────────\n\n/**\n * Options for creating a PowerSync database instance\n */\nexport interface DatabaseOptions {\n /** Database file name (e.g., \"pol-offline.db\") */\n dbFilename: string;\n /** PowerSync schema definition */\n schema: unknown; // Schema type from @powersync/common\n /** Optional: Encryption key for SQLite */\n encryptionKey?: string;\n}\n\n// ─── File System Adapter ─────────────────────────────────────────────────────\n\n/**\n * Information about a file or directory\n */\nexport interface FileInfo {\n /** Whether the file/directory exists */\n exists: boolean;\n /** Size in bytes (0 for directories) */\n size: number;\n /** Last modification time */\n modificationTime?: Date;\n /** Whether this is a directory */\n isDirectory: boolean;\n}\n\n/**\n * File system operations interface.\n *\n * React Native: Implemented using expo-file-system\n * Web: Implemented using IndexedDB or Cache API\n */\nexport interface FileSystemAdapter {\n /**\n * Read a file's contents\n * @param uri - The file URI/path\n * @param encoding - How to encode the result ('base64' or 'utf8')\n */\n readFile(uri: string, encoding?: 'base64' | 'utf8'): Promise<string>;\n\n /**\n * Write data to a file (creates parent directories if needed)\n * @param uri - The file URI/path\n * @param data - The data to write\n * @param encoding - How the data is encoded ('base64' or 'utf8')\n */\n writeFile(uri: string, data: string, encoding?: 'base64' | 'utf8'): Promise<void>;\n\n /**\n * Delete a file\n * @param uri - The file URI/path\n */\n deleteFile(uri: string): Promise<void>;\n\n /**\n * Copy a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n copyFile(source: string, destination: string): Promise<void>;\n\n /**\n * Move a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n moveFile(source: string, destination: string): Promise<void>;\n\n /**\n * Get information about a file or directory\n * @param uri - The file URI/path\n * @returns File info or null if it doesn't exist\n */\n getFileInfo(uri: string): Promise<FileInfo | null>;\n\n /**\n * Create a directory\n * @param uri - The directory URI/path\n * @param options - Options for directory creation\n */\n makeDirectory(uri: string, options?: {\n intermediates?: boolean;\n }): Promise<void>;\n\n /**\n * Get the documents directory path for this platform\n */\n getDocumentsDirectory(): string;\n\n /**\n * Get the cache directory path for this platform\n */\n getCacheDirectory(): string;\n\n /**\n * Get the free disk space in bytes\n */\n getFreeDiskSpace(): Promise<number>;\n}\n\n// ─── Async Storage Adapter ───────────────────────────────────────────────────\n\n/**\n * Key-value storage interface for persisting preferences and state.\n *\n * React Native: Implemented using @react-native-async-storage/async-storage\n * Web: Implemented using localStorage\n */\nexport interface AsyncStorageAdapter {\n /**\n * Get a value by key\n * @param key - The storage key\n * @returns The stored value or null if not found\n */\n getItem(key: string): Promise<string | null>;\n\n /**\n * Set a value by key\n * @param key - The storage key\n * @param value - The value to store\n */\n setItem(key: string, value: string): Promise<void>;\n\n /**\n * Remove a value by key\n * @param key - The storage key\n */\n removeItem(key: string): Promise<void>;\n\n /**\n * Get multiple values by keys\n * @param keys - Array of storage keys\n * @returns Array of [key, value] tuples\n */\n multiGet(keys: string[]): Promise<[string, string | null][]>;\n\n /**\n * Set multiple values\n * @param entries - Array of [key, value] tuples\n */\n multiSet(entries: [string, string][]): Promise<void>;\n}\n\n// ─── Network Adapter ─────────────────────────────────────────────────────────\n\n/** Network connection types */\nexport type ConnectionType = 'wifi' | 'cellular' | 'ethernet' | 'unknown' | 'none';\n\n/**\n * Network connectivity monitoring interface.\n *\n * React Native: Implemented using @react-native-community/netinfo\n * Web: Implemented using navigator.onLine + online/offline events\n */\nexport interface NetworkAdapter {\n /**\n * Check if the device is currently connected to the internet\n */\n isConnected(): Promise<boolean>;\n\n /**\n * Get the current connection type\n */\n getConnectionType(): Promise<ConnectionType>;\n\n /**\n * Add a listener for connection status changes\n * @param callback - Called when connection status changes\n * @returns Unsubscribe function\n */\n addConnectionListener(callback: (isConnected: boolean) => void): () => void;\n}\n\n// ─── Logger Adapter ──────────────────────────────────────────────────────────\n\n/**\n * Logging interface for debugging and monitoring.\n * Allows consumers to use their existing logging infrastructure.\n */\nexport interface LoggerAdapter {\n /**\n * Log a debug message (verbose, for development)\n */\n debug(message: string, ...args: unknown[]): void;\n\n /**\n * Log an info message (general information)\n */\n info(message: string, ...args: unknown[]): void;\n\n /**\n * Log a warning message (potential issues)\n */\n warn(message: string, ...args: unknown[]): void;\n\n /**\n * Log an error message (failures)\n */\n error(message: string, ...args: unknown[]): void;\n}\n\n// ─── Image Processor Adapter ─────────────────────────────────────────────────\n\n/**\n * Result of an image compression operation\n */\nexport interface CompressedImage {\n /** URI/path to the compressed image */\n uri: string;\n /** Width of the compressed image in pixels */\n width: number;\n /** Height of the compressed image in pixels */\n height: number;\n}\n\n/**\n * Options for image compression\n */\nexport interface CompressionOptions {\n /** Compression quality (0.0 to 1.0, where 1.0 is best quality) */\n quality: number;\n /** Maximum width in pixels (will scale down if larger) */\n maxWidth?: number;\n /** Maximum height in pixels (will scale down if larger) */\n maxHeight?: number;\n /** Output format */\n format?: 'jpeg' | 'png' | 'webp';\n}\n\n/**\n * Image processing interface for attachment compression.\n *\n * React Native: Implemented using expo-image-manipulator\n * Web: Implemented using canvas API\n *\n * This is optional - if not provided, attachments won't be compressed.\n */\nexport interface ImageProcessorAdapter {\n /**\n * Compress an image\n * @param uri - The source image URI/path\n * @param options - Compression options\n * @returns The compressed image result\n */\n compress(uri: string, options: CompressionOptions): Promise<CompressedImage>;\n}\n\n// ─── Main Platform Adapter Interface ─────────────────────────────────────────\n\n/**\n * Platform-specific adapter that consumers must provide.\n * This allows the package to work across React Native and Web.\n *\n * @example React Native\n * ```typescript\n * import { createNativePlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createNativePlatformAdapter(logger);\n * ```\n *\n * @example Web\n * ```typescript\n * import { createWebPlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createWebPlatformAdapter(logger);\n * ```\n */\nexport interface PlatformAdapter {\n /**\n * Create a PowerSync database instance for this platform.\n *\n * React Native: Uses PowerSyncDatabase from @powersync/react-native\n * Web: Uses PowerSyncDatabase from @powersync/web\n *\n * @param options - Database creation options\n * @returns Initialized PowerSync database\n */\n createDatabase(options: DatabaseOptions): Promise<AbstractPowerSyncDatabase>;\n\n /**\n * File system operations for attachment caching.\n */\n fileSystem: FileSystemAdapter;\n\n /**\n * Key-value storage for preferences and metrics persistence.\n */\n storage: AsyncStorageAdapter;\n\n /**\n * Network connectivity monitoring.\n */\n network: NetworkAdapter;\n\n /**\n * Logging interface.\n */\n logger: LoggerAdapter;\n\n /**\n * Optional: Image compression for attachment optimization.\n * If not provided, attachments won't be compressed.\n */\n imageProcessor?: ImageProcessorAdapter;\n}\n\n// ─── Platform Detection ──────────────────────────────────────────────────────\n\n/** Supported platform types */\nexport type PlatformType = 'react-native' | 'web' | 'unknown';\n\n/**\n * Detect the current platform based on environment\n */\nexport function detectPlatform(): PlatformType {\n // Check for React Native\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return 'react-native';\n }\n\n // Check for browser environment\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n return 'web';\n }\n return 'unknown';\n}"],"mappings":";AAwUO,SAAS,iBAA+B;AAE7C,MAAI,OAAO,cAAc,eAAe,UAAU,YAAY,eAAe;AAC3E,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/platform/types.ts"],"sourcesContent":["/**\n * Platform Adapter Types for @pol-studios/powersync\n *\n * This module defines the interfaces that platform-specific adapters must implement.\n * Consumers provide an adapter for their platform (React Native or Web) that handles\n * platform-specific operations like file system access, async storage, and network status.\n */\n\nimport type { AbstractPowerSyncDatabase } from '../core/types';\n\n// ─── Database Factory Options ────────────────────────────────────────────────\n\n/**\n * Options for creating a PowerSync database instance\n */\nexport interface DatabaseOptions {\n /** Database file name (e.g., \"pol-offline.db\") */\n dbFilename: string;\n /** PowerSync schema definition */\n schema: unknown; // Schema type from @powersync/common\n /** Optional: Encryption key for SQLite */\n encryptionKey?: string;\n}\n\n// ─── File System Adapter ─────────────────────────────────────────────────────\n\n/**\n * Information about a file or directory\n */\nexport interface FileInfo {\n /** Whether the file/directory exists */\n exists: boolean;\n /** Size in bytes (0 for directories) */\n size: number;\n /** Last modification time */\n modificationTime?: Date;\n /** Whether this is a directory */\n isDirectory: boolean;\n}\n\n/**\n * File system operations interface.\n *\n * React Native: Implemented using expo-file-system\n * Web: Implemented using IndexedDB or Cache API\n */\nexport interface FileSystemAdapter {\n /**\n * Read a file's contents\n * @param uri - The file URI/path\n * @param encoding - How to encode the result ('base64' or 'utf8')\n */\n readFile(uri: string, encoding?: 'base64' | 'utf8'): Promise<string>;\n\n /**\n * Write data to a file (creates parent directories if needed)\n * @param uri - The file URI/path\n * @param data - The data to write\n * @param encoding - How the data is encoded ('base64' or 'utf8')\n */\n writeFile(uri: string, data: string, encoding?: 'base64' | 'utf8'): Promise<void>;\n\n /**\n * Delete a file\n * @param uri - The file URI/path\n */\n deleteFile(uri: string): Promise<void>;\n\n /**\n * Copy a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n copyFile(source: string, destination: string): Promise<void>;\n\n /**\n * Move a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n moveFile(source: string, destination: string): Promise<void>;\n\n /**\n * Get information about a file or directory\n * @param uri - The file URI/path\n * @returns File info or null if it doesn't exist\n */\n getFileInfo(uri: string): Promise<FileInfo | null>;\n\n /**\n * Create a directory\n * @param uri - The directory URI/path\n * @param options - Options for directory creation\n */\n makeDirectory(uri: string, options?: {\n intermediates?: boolean;\n }): Promise<void>;\n\n /**\n * Get the documents directory path for this platform\n */\n getDocumentsDirectory(): string;\n\n /**\n * Get the cache directory path for this platform\n */\n getCacheDirectory(): string;\n\n /**\n * Get the free disk space in bytes\n */\n getFreeDiskSpace(): Promise<number>;\n\n /**\n * Download a file from a URL directly to a local path.\n *\n * React Native: Uses expo-file-system downloadAsync which streams\n * directly to disk without loading the entire file into memory,\n * making it suitable for large files.\n *\n * Web: Uses fetch + blob + base64 conversion to IndexedDB. Note that\n * the file is temporarily held in memory during conversion, so very\n * large files (>50MB) may cause memory pressure on web platforms.\n *\n * @param url - The URL to download from\n * @param localPath - The local path to save the file to\n */\n downloadFile(url: string, localPath: string): Promise<void>;\n}\n\n// ─── Async Storage Adapter ───────────────────────────────────────────────────\n\n/**\n * Key-value storage interface for persisting preferences and state.\n *\n * React Native: Implemented using @react-native-async-storage/async-storage\n * Web: Implemented using localStorage\n */\nexport interface AsyncStorageAdapter {\n /**\n * Get a value by key\n * @param key - The storage key\n * @returns The stored value or null if not found\n */\n getItem(key: string): Promise<string | null>;\n\n /**\n * Set a value by key\n * @param key - The storage key\n * @param value - The value to store\n */\n setItem(key: string, value: string): Promise<void>;\n\n /**\n * Remove a value by key\n * @param key - The storage key\n */\n removeItem(key: string): Promise<void>;\n\n /**\n * Get multiple values by keys\n * @param keys - Array of storage keys\n * @returns Array of [key, value] tuples\n */\n multiGet(keys: string[]): Promise<[string, string | null][]>;\n\n /**\n * Set multiple values\n * @param entries - Array of [key, value] tuples\n */\n multiSet(entries: [string, string][]): Promise<void>;\n}\n\n// ─── Network Adapter ─────────────────────────────────────────────────────────\n\n/** Network connection types */\nexport type ConnectionType = 'wifi' | 'cellular' | 'ethernet' | 'unknown' | 'none';\n\n/**\n * Network connectivity monitoring interface.\n *\n * React Native: Implemented using @react-native-community/netinfo\n * Web: Implemented using navigator.onLine + online/offline events\n */\nexport interface NetworkAdapter {\n /**\n * Check if the device is currently connected to the internet\n */\n isConnected(): Promise<boolean>;\n\n /**\n * Get the current connection type\n */\n getConnectionType(): Promise<ConnectionType>;\n\n /**\n * Add a listener for connection status changes\n * @param callback - Called when connection status changes\n * @returns Unsubscribe function\n */\n addConnectionListener(callback: (isConnected: boolean) => void): () => void;\n}\n\n// ─── Logger Adapter ──────────────────────────────────────────────────────────\n\n/**\n * Logging interface for debugging and monitoring.\n * Allows consumers to use their existing logging infrastructure.\n */\nexport interface LoggerAdapter {\n /**\n * Log a debug message (verbose, for development)\n */\n debug(message: string, ...args: unknown[]): void;\n\n /**\n * Log an info message (general information)\n */\n info(message: string, ...args: unknown[]): void;\n\n /**\n * Log a warning message (potential issues)\n */\n warn(message: string, ...args: unknown[]): void;\n\n /**\n * Log an error message (failures)\n */\n error(message: string, ...args: unknown[]): void;\n}\n\n// ─── Image Processor Adapter ─────────────────────────────────────────────────\n\n/**\n * Result of an image compression operation\n */\nexport interface CompressedImage {\n /** URI/path to the compressed image */\n uri: string;\n /** Width of the compressed image in pixels */\n width: number;\n /** Height of the compressed image in pixels */\n height: number;\n}\n\n/**\n * Options for image compression\n */\nexport interface CompressionOptions {\n /** Compression quality (0.0 to 1.0, where 1.0 is best quality) */\n quality: number;\n /** Maximum width in pixels (will scale down if larger) */\n maxWidth?: number;\n /** Maximum height in pixels (will scale down if larger) */\n maxHeight?: number;\n /** Output format */\n format?: 'jpeg' | 'png' | 'webp';\n}\n\n/**\n * Image processing interface for attachment compression.\n *\n * React Native: Implemented using expo-image-manipulator\n * Web: Implemented using canvas API\n *\n * This is optional - if not provided, attachments won't be compressed.\n */\nexport interface ImageProcessorAdapter {\n /**\n * Compress an image\n * @param uri - The source image URI/path\n * @param options - Compression options\n * @returns The compressed image result\n */\n compress(uri: string, options: CompressionOptions): Promise<CompressedImage>;\n}\n\n// ─── Main Platform Adapter Interface ─────────────────────────────────────────\n\n/**\n * Platform-specific adapter that consumers must provide.\n * This allows the package to work across React Native and Web.\n *\n * @example React Native\n * ```typescript\n * import { createNativePlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createNativePlatformAdapter(logger);\n * ```\n *\n * @example Web\n * ```typescript\n * import { createWebPlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createWebPlatformAdapter(logger);\n * ```\n */\nexport interface PlatformAdapter {\n /**\n * Create a PowerSync database instance for this platform.\n *\n * React Native: Uses PowerSyncDatabase from @powersync/react-native\n * Web: Uses PowerSyncDatabase from @powersync/web\n *\n * @param options - Database creation options\n * @returns Initialized PowerSync database\n */\n createDatabase(options: DatabaseOptions): Promise<AbstractPowerSyncDatabase>;\n\n /**\n * File system operations for attachment caching.\n */\n fileSystem: FileSystemAdapter;\n\n /**\n * Key-value storage for preferences and metrics persistence.\n */\n storage: AsyncStorageAdapter;\n\n /**\n * Network connectivity monitoring.\n */\n network: NetworkAdapter;\n\n /**\n * Logging interface.\n */\n logger: LoggerAdapter;\n\n /**\n * Optional: Image compression for attachment optimization.\n * If not provided, attachments won't be compressed.\n */\n imageProcessor?: ImageProcessorAdapter;\n}\n\n// ─── Platform Detection ──────────────────────────────────────────────────────\n\n/** Supported platform types */\nexport type PlatformType = 'react-native' | 'web' | 'unknown';\n\n/**\n * Detect the current platform based on environment\n */\nexport function detectPlatform(): PlatformType {\n // Check for React Native\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return 'react-native';\n }\n\n // Check for browser environment\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n return 'web';\n }\n return 'unknown';\n}"],"mappings":";;;AAwVO,SAAS,iBAA+B;AAE7C,MAAI,OAAO,cAAc,eAAe,UAAU,YAAY,eAAe;AAC3E,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LoggerAdapter, PlatformAdapter } from './index.js';
|
|
2
|
-
import '../types-
|
|
2
|
+
import '../types-CDqWh56B.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* React Native Platform Adapter for @pol-studios/powersync
|
|
6
6
|
*
|
|
7
7
|
* Implements the PlatformAdapter interface using React Native specific APIs:
|
|
8
8
|
* - @powersync/react-native for SQLite database
|
|
9
|
-
* - expo-file-system for file operations
|
|
9
|
+
* - expo-file-system for file operations (new class-based API)
|
|
10
10
|
* - @react-native-async-storage/async-storage for key-value storage
|
|
11
11
|
* - @react-native-community/netinfo for network monitoring
|
|
12
12
|
* - expo-image-manipulator for image compression
|