@pol-studios/powersync 1.0.6 → 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-R4YFWQ3Q.js → chunk-H772V6XQ.js} +304 -51
- package/dist/chunk-H772V6XQ.js.map +1 -0
- package/dist/{chunk-62J2DPKX.js → chunk-HFOFLW5F.js} +396 -412
- 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 -3
- package/dist/connector/index.js +12 -4
- 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 +100 -12
- package/dist/index.js +148 -38
- package/dist/index.native.d.ts +20 -10
- package/dist/index.native.js +148 -39
- package/dist/index.web.d.ts +20 -10
- package/dist/index.web.js +149 -39
- 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 +447 -21
- package/dist/provider/index.js +33 -13
- 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-l3iL9Jte.d.ts → supabase-connector-qLm-WHkM.d.ts} +90 -25
- package/dist/sync/index.d.ts +288 -23
- package/dist/sync/index.js +22 -10
- 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-5FIMA26D.js +0 -1
- package/dist/chunk-62J2DPKX.js.map +0 -1
- package/dist/chunk-7EMDVIZX.js.map +0 -1
- package/dist/chunk-EJ23MXPQ.js.map +0 -1
- package/dist/chunk-FPTDATY5.js.map +0 -1
- package/dist/chunk-KCDG2MNP.js +0 -1431
- package/dist/chunk-KCDG2MNP.js.map +0 -1
- package/dist/chunk-OLHGI472.js +0 -1
- package/dist/chunk-PAFBKNL3.js +0 -99
- package/dist/chunk-PAFBKNL3.js.map +0 -1
- package/dist/chunk-R4YFWQ3Q.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/failed-upload-store-C0cLxxPz.d.ts +0 -33
- /package/dist/{chunk-32OLICZO.js.map → chunk-DGUM43GV.js.map} +0 -0
- /package/dist/{chunk-5FIMA26D.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,26 +1,78 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-KGSFAE5B.js";
|
|
2
|
+
import "./chunk-GKF7TOMT.js";
|
|
3
|
+
import {
|
|
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";
|
|
3
54
|
import {
|
|
4
55
|
AttachmentQueueContext,
|
|
5
56
|
CompletedTransactionsContext,
|
|
6
|
-
ConflictBus,
|
|
7
57
|
ConnectionHealthContext,
|
|
8
58
|
ConnectionStatusContext,
|
|
9
59
|
FailedTransactionsContext,
|
|
10
60
|
PendingMutationsContext,
|
|
11
61
|
PowerSyncContext,
|
|
12
|
-
PowerSyncProvider,
|
|
13
62
|
SyncActivityContext,
|
|
14
63
|
SyncMetricsContext,
|
|
15
64
|
SyncModeContext,
|
|
16
65
|
SyncStatusContext,
|
|
17
66
|
useAttachmentQueue,
|
|
67
|
+
useAttachmentQueueReady,
|
|
68
|
+
useCompletedTransactions,
|
|
18
69
|
useCompletedTransactionsContext,
|
|
19
70
|
useConnectionHealth,
|
|
20
71
|
useConnectionStatus,
|
|
21
72
|
useDatabase,
|
|
22
73
|
useDownloadProgress,
|
|
23
74
|
useEntitySyncStatus,
|
|
75
|
+
useFailedTransactions,
|
|
24
76
|
useFailedTransactionsContext,
|
|
25
77
|
useIsSyncing,
|
|
26
78
|
useOnlineStatus,
|
|
@@ -36,24 +88,30 @@ import {
|
|
|
36
88
|
useSyncModeContext,
|
|
37
89
|
useSyncStatus,
|
|
38
90
|
useUploadStatus
|
|
39
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-YSTEESEG.js";
|
|
92
|
+
import "./chunk-LNL64IJZ.js";
|
|
40
93
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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";
|
|
48
107
|
import {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} from "./chunk-R4YFWQ3Q.js";
|
|
108
|
+
SupabaseUploadHandler,
|
|
109
|
+
createSupabaseUploadHandler
|
|
110
|
+
} from "./chunk-UEYRTLKE.js";
|
|
111
|
+
import {
|
|
112
|
+
DEFAULT_UPLOAD_NOTIFICATION,
|
|
113
|
+
resolveBucketFromConfig
|
|
114
|
+
} from "./chunk-MKD2VCX3.js";
|
|
57
115
|
import "./chunk-W7HSR35B.js";
|
|
58
116
|
import {
|
|
59
117
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -80,37 +138,42 @@ import {
|
|
|
80
138
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
81
139
|
STORAGE_CRITICAL_THRESHOLD,
|
|
82
140
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
141
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
83
142
|
STORAGE_KEY_ENABLED,
|
|
84
143
|
STORAGE_KEY_METRICS,
|
|
85
144
|
STORAGE_KEY_PAUSED,
|
|
86
145
|
STORAGE_KEY_PREFIX,
|
|
87
146
|
STORAGE_KEY_SYNC_MODE,
|
|
88
147
|
STORAGE_WARNING_THRESHOLD
|
|
89
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-CGL33PL4.js";
|
|
149
|
+
import "./chunk-53WH2JJV.js";
|
|
90
150
|
import {
|
|
91
151
|
createWebPlatformAdapter
|
|
92
|
-
} from "./chunk-
|
|
93
|
-
import "./chunk-VJCL2SWD.js";
|
|
152
|
+
} from "./chunk-N75DEF5J.js";
|
|
94
153
|
import {
|
|
95
|
-
|
|
96
|
-
|
|
154
|
+
CircuitBreaker,
|
|
155
|
+
CircuitOpenError,
|
|
156
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG
|
|
157
|
+
} from "./chunk-4C3RY5SU.js";
|
|
158
|
+
import {
|
|
159
|
+
ConflictDetectionError,
|
|
97
160
|
DEFAULT_RETRY_CONFIG,
|
|
98
|
-
RetryExhaustedError,
|
|
99
161
|
SupabaseConnector,
|
|
100
|
-
addJitter,
|
|
101
|
-
calculateBackoffDelay,
|
|
102
162
|
defaultSchemaRouter,
|
|
103
163
|
detectConflicts,
|
|
104
164
|
fetchServerVersion,
|
|
105
165
|
getLocalVersion,
|
|
106
|
-
hasVersionColumn
|
|
166
|
+
hasVersionColumn
|
|
167
|
+
} from "./chunk-HFOFLW5F.js";
|
|
168
|
+
import {
|
|
169
|
+
AbortError,
|
|
170
|
+
DEFAULT_BACKOFF_CONFIG,
|
|
171
|
+
RetryExhaustedError,
|
|
172
|
+
addJitter,
|
|
173
|
+
calculateBackoffDelay,
|
|
107
174
|
sleep,
|
|
108
175
|
withExponentialBackoff
|
|
109
|
-
} from "./chunk-
|
|
110
|
-
import {
|
|
111
|
-
FailedUploadStore,
|
|
112
|
-
failedUploadStore
|
|
113
|
-
} from "./chunk-PAFBKNL3.js";
|
|
176
|
+
} from "./chunk-FV2HXEIY.js";
|
|
114
177
|
import {
|
|
115
178
|
AttachmentError,
|
|
116
179
|
ConfigurationError,
|
|
@@ -126,32 +189,41 @@ import {
|
|
|
126
189
|
extractTableNames,
|
|
127
190
|
generateFailureId,
|
|
128
191
|
toSyncOperationError
|
|
129
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-XQAJM2MW.js";
|
|
193
|
+
import "./chunk-DGUM43GV.js";
|
|
130
194
|
export {
|
|
131
195
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
132
196
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
197
|
+
ATTACHMENT_TABLE,
|
|
133
198
|
AbortError,
|
|
199
|
+
AbstractAttachmentQueue,
|
|
134
200
|
AttachmentError,
|
|
135
|
-
AttachmentQueue,
|
|
136
201
|
AttachmentQueueContext,
|
|
137
202
|
AttachmentState,
|
|
203
|
+
AttachmentTable,
|
|
138
204
|
COMPRESSION_MAX_WIDTH,
|
|
139
205
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
140
206
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
207
|
+
CacheSettingsManager,
|
|
208
|
+
CircuitBreaker,
|
|
209
|
+
CircuitOpenError,
|
|
141
210
|
CompletedTransactionsContext,
|
|
142
211
|
ConfigurationError,
|
|
143
212
|
ConflictBus,
|
|
213
|
+
ConflictDetectionError,
|
|
144
214
|
ConnectionHealthContext,
|
|
145
215
|
ConnectionStatusContext,
|
|
146
216
|
ConnectorError,
|
|
147
217
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
|
148
218
|
DEFAULT_ATTACHMENT_CONCURRENCY,
|
|
219
|
+
DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
|
|
149
220
|
DEFAULT_BACKOFF_CONFIG,
|
|
150
221
|
DEFAULT_CACHE_CONFIG,
|
|
222
|
+
DEFAULT_CACHE_SETTINGS,
|
|
223
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
151
224
|
DEFAULT_COMPRESSION_CONFIG,
|
|
152
225
|
DEFAULT_COMPRESSION_QUALITY,
|
|
153
226
|
DEFAULT_CONNECTION_HEALTH,
|
|
154
|
-
DEFAULT_DOWNLOAD_CONFIG,
|
|
155
227
|
DEFAULT_MAX_RETRY_ATTEMPTS,
|
|
156
228
|
DEFAULT_RETRY_BACKOFF_MULTIPLIER,
|
|
157
229
|
DEFAULT_RETRY_BASE_DELAY_MS,
|
|
@@ -162,10 +234,13 @@ export {
|
|
|
162
234
|
DEFAULT_SYNC_METRICS,
|
|
163
235
|
DEFAULT_SYNC_MODE,
|
|
164
236
|
DEFAULT_SYNC_STATUS,
|
|
237
|
+
DEFAULT_UPLOAD_CONFIG,
|
|
238
|
+
DEFAULT_UPLOAD_NOTIFICATION,
|
|
165
239
|
DOWNLOAD_STOP_THRESHOLD,
|
|
240
|
+
DeadLetterQueue,
|
|
166
241
|
EVICTION_TRIGGER_THRESHOLD,
|
|
242
|
+
EncodingType,
|
|
167
243
|
FailedTransactionsContext,
|
|
168
|
-
FailedUploadStore,
|
|
169
244
|
HEALTH_CHECK_INTERVAL_MS,
|
|
170
245
|
HEALTH_CHECK_TIMEOUT_MS,
|
|
171
246
|
HealthMonitor,
|
|
@@ -173,16 +248,23 @@ export {
|
|
|
173
248
|
LATENCY_DEGRADED_THRESHOLD_MS,
|
|
174
249
|
MAX_CONSECUTIVE_FAILURES,
|
|
175
250
|
MetricsCollector,
|
|
251
|
+
OfflineDataProvider,
|
|
176
252
|
PendingMutationsContext,
|
|
177
253
|
PlatformAdapterError,
|
|
254
|
+
PolAttachmentQueue,
|
|
255
|
+
PolAttachmentState,
|
|
256
|
+
PolStorageAdapter,
|
|
178
257
|
PowerSyncContext,
|
|
179
258
|
PowerSyncError,
|
|
259
|
+
PowerSyncErrorBoundary,
|
|
180
260
|
PowerSyncProvider,
|
|
261
|
+
ProviderBridge,
|
|
181
262
|
RetryExhaustedError,
|
|
182
263
|
STATS_CACHE_TTL_MS,
|
|
183
264
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
184
265
|
STORAGE_CRITICAL_THRESHOLD,
|
|
185
266
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
267
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
186
268
|
STORAGE_KEY_ENABLED,
|
|
187
269
|
STORAGE_KEY_METRICS,
|
|
188
270
|
STORAGE_KEY_PAUSED,
|
|
@@ -190,6 +272,8 @@ export {
|
|
|
190
272
|
STORAGE_KEY_SYNC_MODE,
|
|
191
273
|
STORAGE_WARNING_THRESHOLD,
|
|
192
274
|
SupabaseConnector,
|
|
275
|
+
SupabaseStorageAdapter,
|
|
276
|
+
SupabaseUploadHandler,
|
|
193
277
|
SyncActivityContext,
|
|
194
278
|
SyncMetricsContext,
|
|
195
279
|
SyncModeContext,
|
|
@@ -198,28 +282,54 @@ export {
|
|
|
198
282
|
SyncStatusTracker,
|
|
199
283
|
addJitter,
|
|
200
284
|
calculateBackoffDelay,
|
|
285
|
+
checkIntegrityImpl,
|
|
286
|
+
checkStorageQuotaImpl,
|
|
201
287
|
classifyError,
|
|
202
288
|
classifySupabaseError,
|
|
289
|
+
compactDatabaseImpl,
|
|
290
|
+
createDeadLetterEntry,
|
|
291
|
+
createPolAttachmentQueue,
|
|
292
|
+
createSupabaseStorageAdapter,
|
|
293
|
+
createSupabaseUploadHandler,
|
|
203
294
|
createSyncError,
|
|
204
295
|
createWebPlatformAdapter,
|
|
205
296
|
defaultSchemaRouter,
|
|
297
|
+
defineBackgroundSyncTask,
|
|
206
298
|
detectConflicts,
|
|
207
299
|
extractEntityIds,
|
|
208
300
|
extractTableNames,
|
|
209
|
-
failedUploadStore,
|
|
210
301
|
fetchServerVersion,
|
|
302
|
+
formatBytes,
|
|
303
|
+
generateDLQEntryId,
|
|
211
304
|
generateFailureId,
|
|
305
|
+
getCacheStatsImpl,
|
|
306
|
+
getExtensionFromMimeType,
|
|
212
307
|
getLocalVersion,
|
|
308
|
+
getMimeType,
|
|
309
|
+
getMimeTypeFromPath,
|
|
213
310
|
hasVersionColumn,
|
|
311
|
+
initializeBackgroundSync,
|
|
312
|
+
isAudioMimeType,
|
|
313
|
+
isBackgroundSyncRegistered,
|
|
314
|
+
isDocumentMimeType,
|
|
315
|
+
isImageMimeType,
|
|
316
|
+
isVideoMimeType,
|
|
317
|
+
registerBackgroundSync,
|
|
318
|
+
resolveBucketFromConfig,
|
|
214
319
|
sleep,
|
|
215
320
|
toSyncOperationError,
|
|
321
|
+
unregisterBackgroundSync,
|
|
216
322
|
useAttachmentQueue,
|
|
323
|
+
useAttachmentQueueReady,
|
|
324
|
+
useCompletedTransactions,
|
|
217
325
|
useCompletedTransactionsContext,
|
|
218
326
|
useConnectionHealth,
|
|
219
327
|
useConnectionStatus,
|
|
220
328
|
useDatabase,
|
|
329
|
+
useDatabaseMaintenance,
|
|
221
330
|
useDownloadProgress,
|
|
222
331
|
useEntitySyncStatus,
|
|
332
|
+
useFailedTransactions,
|
|
223
333
|
useFailedTransactionsContext,
|
|
224
334
|
useIsSyncing,
|
|
225
335
|
useOnlineStatus,
|
|
@@ -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
|