@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.
Files changed (103) hide show
  1. package/README.md +933 -0
  2. package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
  3. package/dist/attachments/index.d.ts +709 -6
  4. package/dist/attachments/index.js +133 -5
  5. package/dist/chunk-24RDMMCL.js +44 -0
  6. package/dist/chunk-24RDMMCL.js.map +1 -0
  7. package/dist/chunk-4TXTAEF2.js +2060 -0
  8. package/dist/chunk-4TXTAEF2.js.map +1 -0
  9. package/dist/chunk-63PXSPIN.js +358 -0
  10. package/dist/chunk-63PXSPIN.js.map +1 -0
  11. package/dist/chunk-654ERHA7.js +1 -0
  12. package/dist/{chunk-BREGB4WL.js → chunk-BRXQNASY.js} +287 -335
  13. package/dist/chunk-BRXQNASY.js.map +1 -0
  14. package/dist/{chunk-DHYUBVP7.js → chunk-CAB26E6F.js} +20 -9
  15. package/dist/chunk-CAB26E6F.js.map +1 -0
  16. package/dist/{chunk-H772V6XQ.js → chunk-CUCAYK7Z.js} +7 -43
  17. package/dist/chunk-CUCAYK7Z.js.map +1 -0
  18. package/dist/{chunk-4C3RY5SU.js → chunk-HWSNV45P.js} +76 -1
  19. package/dist/chunk-HWSNV45P.js.map +1 -0
  20. package/dist/{chunk-HFOFLW5F.js → chunk-KN2IZERF.js} +139 -6
  21. package/dist/chunk-KN2IZERF.js.map +1 -0
  22. package/dist/{chunk-UEYRTLKE.js → chunk-P4HZA6ZT.js} +20 -9
  23. package/dist/chunk-P4HZA6ZT.js.map +1 -0
  24. package/dist/chunk-T4AO7JIG.js +1 -0
  25. package/dist/{chunk-XQAJM2MW.js → chunk-VACPAAQZ.js} +33 -2
  26. package/dist/{chunk-XQAJM2MW.js.map → chunk-VACPAAQZ.js.map} +1 -1
  27. package/dist/{chunk-53WH2JJV.js → chunk-WN5ZJ3E2.js} +5 -8
  28. package/dist/chunk-WN5ZJ3E2.js.map +1 -0
  29. package/dist/chunk-XAEII4ZX.js +456 -0
  30. package/dist/chunk-XAEII4ZX.js.map +1 -0
  31. package/dist/chunk-XOY2CJ67.js +289 -0
  32. package/dist/chunk-XOY2CJ67.js.map +1 -0
  33. package/dist/chunk-YHTZ7VMV.js +1 -0
  34. package/dist/{chunk-MKD2VCX3.js → chunk-Z6VOBGTU.js} +8 -8
  35. package/dist/chunk-Z6VOBGTU.js.map +1 -0
  36. package/dist/chunk-ZM4ENYMF.js +230 -0
  37. package/dist/chunk-ZM4ENYMF.js.map +1 -0
  38. package/dist/connector/index.d.ts +56 -3
  39. package/dist/connector/index.js +8 -5
  40. package/dist/core/index.d.ts +12 -1
  41. package/dist/core/index.js +3 -2
  42. package/dist/error/index.js +0 -1
  43. package/dist/generator/cli.js +527 -0
  44. package/dist/generator/index.d.ts +168 -0
  45. package/dist/generator/index.js +370 -0
  46. package/dist/generator/index.js.map +1 -0
  47. package/dist/index.d.ts +12 -10
  48. package/dist/index.js +191 -29
  49. package/dist/index.native.d.ts +11 -9
  50. package/dist/index.native.js +191 -29
  51. package/dist/index.web.d.ts +11 -9
  52. package/dist/index.web.js +191 -29
  53. package/dist/maintenance/index.js +0 -1
  54. package/dist/platform/index.js +0 -2
  55. package/dist/platform/index.js.map +1 -1
  56. package/dist/platform/index.native.js +1 -2
  57. package/dist/platform/index.web.js +0 -1
  58. package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
  59. package/dist/provider/index.d.ts +38 -34
  60. package/dist/provider/index.js +11 -12
  61. package/dist/react/index.d.ts +372 -0
  62. package/dist/react/index.js +25 -0
  63. package/dist/storage/index.d.ts +3 -3
  64. package/dist/storage/index.js +22 -8
  65. package/dist/storage/index.native.d.ts +3 -3
  66. package/dist/storage/index.native.js +21 -7
  67. package/dist/storage/index.web.d.ts +3 -3
  68. package/dist/storage/index.web.js +21 -7
  69. package/dist/storage/upload/index.d.ts +7 -8
  70. package/dist/storage/upload/index.js +3 -3
  71. package/dist/storage/upload/index.native.d.ts +7 -8
  72. package/dist/storage/upload/index.native.js +4 -3
  73. package/dist/storage/upload/index.web.d.ts +1 -4
  74. package/dist/storage/upload/index.web.js +3 -3
  75. package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
  76. package/dist/sync/index.js +3 -3
  77. package/dist/{supabase-connector-qLm-WHkM.d.ts → types-B212hgfA.d.ts} +48 -170
  78. package/dist/{types-BVacP54t.d.ts → types-CyvBaAl8.d.ts} +12 -4
  79. package/dist/types-D0WcHrq6.d.ts +234 -0
  80. package/package.json +28 -4
  81. package/dist/CacheSettingsManager-1exbOC6S.d.ts +0 -261
  82. package/dist/chunk-4C3RY5SU.js.map +0 -1
  83. package/dist/chunk-53WH2JJV.js.map +0 -1
  84. package/dist/chunk-BREGB4WL.js.map +0 -1
  85. package/dist/chunk-DGUM43GV.js +0 -11
  86. package/dist/chunk-DHYUBVP7.js.map +0 -1
  87. package/dist/chunk-GKF7TOMT.js +0 -1
  88. package/dist/chunk-H772V6XQ.js.map +0 -1
  89. package/dist/chunk-HFOFLW5F.js.map +0 -1
  90. package/dist/chunk-KGSFAE5B.js +0 -1
  91. package/dist/chunk-LNL64IJZ.js +0 -1
  92. package/dist/chunk-MKD2VCX3.js.map +0 -1
  93. package/dist/chunk-UEYRTLKE.js.map +0 -1
  94. package/dist/chunk-WQ5MPAVC.js +0 -449
  95. package/dist/chunk-WQ5MPAVC.js.map +0 -1
  96. package/dist/chunk-ZEOKPWUC.js +0 -1165
  97. package/dist/chunk-ZEOKPWUC.js.map +0 -1
  98. package/dist/pol-attachment-queue-C7YNXXhK.d.ts +0 -676
  99. package/dist/types-Bgvx7-E8.d.ts +0 -187
  100. /package/dist/{chunk-DGUM43GV.js.map → chunk-654ERHA7.js.map} +0 -0
  101. /package/dist/{chunk-GKF7TOMT.js.map → chunk-T4AO7JIG.js.map} +0 -0
  102. /package/dist/{chunk-KGSFAE5B.js.map → chunk-YHTZ7VMV.js.map} +0 -0
  103. /package/dist/{chunk-LNL64IJZ.js.map → react/index.js.map} +0 -0
package/dist/index.web.js CHANGED
@@ -1,11 +1,41 @@
1
- import "./chunk-KGSFAE5B.js";
2
- import "./chunk-GKF7TOMT.js";
1
+ import "./chunk-654ERHA7.js";
2
+ import {
3
+ SlimPowerSyncProvider,
4
+ useAttachmentQueueContext,
5
+ usePowerSyncContext,
6
+ useSyncStatusContext
7
+ } from "./chunk-63PXSPIN.js";
8
+ import {
9
+ DOWNLOAD_WORKFLOW_STATES,
10
+ STATE_MAPPING,
11
+ STATE_NAMES,
12
+ TERMINAL_STATES,
13
+ UPLOAD_WORKFLOW_STATES,
14
+ VALID_STATES,
15
+ buildIdOnlyWatchQuery,
16
+ buildRecordFetchQuery,
17
+ buildWatchQuery,
18
+ createMigrationStats,
19
+ formatMigrationStats,
20
+ getStateName,
21
+ isDownloadWorkflowState,
22
+ isTerminalState,
23
+ isUploadWorkflowState,
24
+ isValidAttachmentState,
25
+ migrateAttachmentState,
26
+ migrateAttachmentStateSafe,
27
+ recordMigration,
28
+ validateSqlIdentifier as validateSqlIdentifier2,
29
+ validateWhereClause,
30
+ watchConfigToSourceConfig
31
+ } from "./chunk-ZM4ENYMF.js";
3
32
  import {
4
33
  ConflictBus,
5
34
  OfflineDataProvider,
6
35
  PowerSyncProvider,
7
36
  ProviderBridge
8
- } from "./chunk-BREGB4WL.js";
37
+ } from "./chunk-BRXQNASY.js";
38
+ import "./chunk-YHTZ7VMV.js";
9
39
  import {
10
40
  PowerSyncErrorBoundary
11
41
  } from "./chunk-P6WOZO7H.js";
@@ -14,16 +44,65 @@ import {
14
44
  AbstractAttachmentQueue,
15
45
  AttachmentState,
16
46
  AttachmentTable,
47
+ CACHE_SIZE_PRESETS,
17
48
  DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
18
49
  DEFAULT_CACHE_CONFIG,
19
50
  DEFAULT_COMPRESSION_CONFIG,
51
+ DEFAULT_DOWNLOAD_CONFIG,
20
52
  DEFAULT_UPLOAD_CONFIG,
21
53
  EncodingType,
54
+ LOCALLY_AVAILABLE_STATES,
55
+ PENDING_DOWNLOAD_STATES,
56
+ PROTECTED_UPLOAD_STATES,
22
57
  PolAttachmentQueue,
23
58
  PolAttachmentState,
24
59
  PolStorageAdapter,
25
- createPolAttachmentQueue
26
- } from "./chunk-ZEOKPWUC.js";
60
+ blobToArrayBuffer,
61
+ cacheLocalFile,
62
+ clearCache,
63
+ clearUploadCallback,
64
+ copyToManagedCache,
65
+ createCacheManagerDeps,
66
+ createPolAttachmentQueue,
67
+ createUploadManagerDeps,
68
+ createUploadManagerState,
69
+ determineAttachmentState,
70
+ downloadRecord,
71
+ enforceCacheLimit,
72
+ ensureFileUri,
73
+ extractErrorCode,
74
+ formatCacheSize,
75
+ getCachedSize,
76
+ getEvictionCandidates,
77
+ getExcludeProtectedStatesCondition,
78
+ getExtensionFromMimeType,
79
+ getFailedPermanentUploads,
80
+ getLocalUriForStoragePath,
81
+ getMimeType,
82
+ getMimeTypeFromPath,
83
+ getPendingUploads,
84
+ getProtectedStatesInClause,
85
+ getSoonestRetryTime,
86
+ getStaleUploads,
87
+ getSyncedUploadsWithPendingCallback,
88
+ isAudioMimeType,
89
+ isCacheNearCapacity,
90
+ isDocumentMimeType,
91
+ isImageMimeType,
92
+ isLocallyAvailable,
93
+ isPendingDownloadState,
94
+ isPermanentError,
95
+ isProtectedUploadState,
96
+ isStateTransitionAllowed,
97
+ isVideoMimeType,
98
+ markUploadPermanentFailure,
99
+ markUploadSynced,
100
+ scheduleUploadRetry,
101
+ startUploadProcessing,
102
+ stripFileUri,
103
+ uploadOne,
104
+ validateSqlIdentifier
105
+ } from "./chunk-4TXTAEF2.js";
27
106
  import {
28
107
  DeadLetterQueue,
29
108
  createDeadLetterEntry,
@@ -35,14 +114,16 @@ import {
35
114
  unregisterBackgroundSync
36
115
  } from "./chunk-A4IBBWGO.js";
37
116
  import {
38
- DEFAULT_CONNECTION_HEALTH,
39
- DEFAULT_SYNC_CONFIG,
40
- DEFAULT_SYNC_METRICS,
41
- DEFAULT_SYNC_STATUS,
42
117
  HealthMonitor,
43
118
  MetricsCollector,
44
119
  SyncStatusTracker
45
- } from "./chunk-H772V6XQ.js";
120
+ } from "./chunk-CUCAYK7Z.js";
121
+ import {
122
+ DEFAULT_CONNECTION_HEALTH,
123
+ DEFAULT_SYNC_CONFIG,
124
+ DEFAULT_SYNC_METRICS,
125
+ DEFAULT_SYNC_STATUS
126
+ } from "./chunk-24RDMMCL.js";
46
127
  import {
47
128
  checkIntegrityImpl,
48
129
  checkStorageQuotaImpl,
@@ -89,29 +170,31 @@ import {
89
170
  useSyncStatus,
90
171
  useUploadStatus
91
172
  } from "./chunk-YSTEESEG.js";
92
- import "./chunk-LNL64IJZ.js";
173
+ import "./chunk-T4AO7JIG.js";
174
+ import "./chunk-CAB26E6F.js";
93
175
  import {
94
176
  CacheSettingsManager,
95
177
  DEFAULT_CACHE_SETTINGS,
178
+ createSupabaseStorage,
179
+ isBlobResult,
180
+ isFileResult
181
+ } from "./chunk-XOY2CJ67.js";
182
+ import {
96
183
  SupabaseStorageAdapter,
97
184
  createSupabaseStorageAdapter,
98
- getExtensionFromMimeType,
99
- getMimeType,
100
- getMimeTypeFromPath,
101
- isAudioMimeType,
102
- isDocumentMimeType,
103
- isImageMimeType,
104
- isVideoMimeType
105
- } from "./chunk-WQ5MPAVC.js";
185
+ getStorageErrorMessage,
186
+ isStorageAuthError,
187
+ normalizeStoragePath
188
+ } from "./chunk-XAEII4ZX.js";
106
189
  import "./chunk-TGBT5XBE.js";
107
190
  import {
108
191
  SupabaseUploadHandler,
109
192
  createSupabaseUploadHandler
110
- } from "./chunk-UEYRTLKE.js";
193
+ } from "./chunk-P4HZA6ZT.js";
111
194
  import {
112
195
  DEFAULT_UPLOAD_NOTIFICATION,
113
- resolveBucketFromConfig
114
- } from "./chunk-MKD2VCX3.js";
196
+ resolveBucket
197
+ } from "./chunk-Z6VOBGTU.js";
115
198
  import "./chunk-W7HSR35B.js";
116
199
  import {
117
200
  ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
@@ -146,15 +229,17 @@ import {
146
229
  STORAGE_KEY_SYNC_MODE,
147
230
  STORAGE_WARNING_THRESHOLD
148
231
  } from "./chunk-CGL33PL4.js";
149
- import "./chunk-53WH2JJV.js";
232
+ import "./chunk-WN5ZJ3E2.js";
150
233
  import {
151
234
  createWebPlatformAdapter
152
235
  } from "./chunk-N75DEF5J.js";
153
236
  import {
237
+ AuthRefreshError,
154
238
  CircuitBreaker,
155
239
  CircuitOpenError,
156
- DEFAULT_CIRCUIT_BREAKER_CONFIG
157
- } from "./chunk-4C3RY5SU.js";
240
+ DEFAULT_CIRCUIT_BREAKER_CONFIG,
241
+ createSupabaseAuth
242
+ } from "./chunk-HWSNV45P.js";
158
243
  import {
159
244
  ConflictDetectionError,
160
245
  DEFAULT_RETRY_CONFIG,
@@ -164,7 +249,7 @@ import {
164
249
  fetchServerVersion,
165
250
  getLocalVersion,
166
251
  hasVersionColumn
167
- } from "./chunk-HFOFLW5F.js";
252
+ } from "./chunk-KN2IZERF.js";
168
253
  import {
169
254
  AbortError,
170
255
  DEFAULT_BACKOFF_CONFIG,
@@ -188,9 +273,9 @@ import {
188
273
  extractEntityIds,
189
274
  extractTableNames,
190
275
  generateFailureId,
276
+ isRlsError,
191
277
  toSyncOperationError
192
- } from "./chunk-XQAJM2MW.js";
193
- import "./chunk-DGUM43GV.js";
278
+ } from "./chunk-VACPAAQZ.js";
194
279
  export {
195
280
  ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
196
281
  ATTACHMENT_RETRY_DELAY_MS,
@@ -201,6 +286,8 @@ export {
201
286
  AttachmentQueueContext,
202
287
  AttachmentState,
203
288
  AttachmentTable,
289
+ AuthRefreshError,
290
+ CACHE_SIZE_PRESETS,
204
291
  COMPRESSION_MAX_WIDTH,
205
292
  COMPRESSION_SKIP_SIZE_BYTES,
206
293
  COMPRESSION_TARGET_SIZE_BYTES,
@@ -224,6 +311,7 @@ export {
224
311
  DEFAULT_COMPRESSION_CONFIG,
225
312
  DEFAULT_COMPRESSION_QUALITY,
226
313
  DEFAULT_CONNECTION_HEALTH,
314
+ DEFAULT_DOWNLOAD_CONFIG,
227
315
  DEFAULT_MAX_RETRY_ATTEMPTS,
228
316
  DEFAULT_RETRY_BACKOFF_MULTIPLIER,
229
317
  DEFAULT_RETRY_BASE_DELAY_MS,
@@ -237,6 +325,7 @@ export {
237
325
  DEFAULT_UPLOAD_CONFIG,
238
326
  DEFAULT_UPLOAD_NOTIFICATION,
239
327
  DOWNLOAD_STOP_THRESHOLD,
328
+ DOWNLOAD_WORKFLOW_STATES,
240
329
  DeadLetterQueue,
241
330
  EVICTION_TRIGGER_THRESHOLD,
242
331
  EncodingType,
@@ -246,9 +335,12 @@ export {
246
335
  HealthMonitor,
247
336
  InitializationError,
248
337
  LATENCY_DEGRADED_THRESHOLD_MS,
338
+ LOCALLY_AVAILABLE_STATES,
249
339
  MAX_CONSECUTIVE_FAILURES,
250
340
  MetricsCollector,
251
341
  OfflineDataProvider,
342
+ PENDING_DOWNLOAD_STATES,
343
+ PROTECTED_UPLOAD_STATES,
252
344
  PendingMutationsContext,
253
345
  PlatformAdapterError,
254
346
  PolAttachmentQueue,
@@ -260,6 +352,8 @@ export {
260
352
  PowerSyncProvider,
261
353
  ProviderBridge,
262
354
  RetryExhaustedError,
355
+ STATE_MAPPING,
356
+ STATE_NAMES,
263
357
  STATS_CACHE_TTL_MS,
264
358
  STATUS_NOTIFY_THROTTLE_MS,
265
359
  STORAGE_CRITICAL_THRESHOLD,
@@ -271,6 +365,7 @@ export {
271
365
  STORAGE_KEY_PREFIX,
272
366
  STORAGE_KEY_SYNC_MODE,
273
367
  STORAGE_WARNING_THRESHOLD,
368
+ SlimPowerSyncProvider,
274
369
  SupabaseConnector,
275
370
  SupabaseStorageAdapter,
276
371
  SupabaseUploadHandler,
@@ -280,46 +375,107 @@ export {
280
375
  SyncOperationError,
281
376
  SyncStatusContext,
282
377
  SyncStatusTracker,
378
+ TERMINAL_STATES,
379
+ UPLOAD_WORKFLOW_STATES,
380
+ VALID_STATES,
283
381
  addJitter,
382
+ blobToArrayBuffer,
383
+ buildIdOnlyWatchQuery,
384
+ buildRecordFetchQuery,
385
+ buildWatchQuery,
386
+ cacheLocalFile,
284
387
  calculateBackoffDelay,
285
388
  checkIntegrityImpl,
286
389
  checkStorageQuotaImpl,
287
390
  classifyError,
288
391
  classifySupabaseError,
392
+ clearCache,
393
+ clearUploadCallback,
289
394
  compactDatabaseImpl,
395
+ copyToManagedCache,
396
+ createCacheManagerDeps,
290
397
  createDeadLetterEntry,
398
+ createMigrationStats,
291
399
  createPolAttachmentQueue,
400
+ createSupabaseAuth,
401
+ createSupabaseStorage,
292
402
  createSupabaseStorageAdapter,
293
403
  createSupabaseUploadHandler,
294
404
  createSyncError,
405
+ createUploadManagerDeps,
406
+ createUploadManagerState,
295
407
  createWebPlatformAdapter,
296
408
  defaultSchemaRouter,
297
409
  defineBackgroundSyncTask,
298
410
  detectConflicts,
411
+ determineAttachmentState,
412
+ downloadRecord,
413
+ enforceCacheLimit,
414
+ ensureFileUri,
299
415
  extractEntityIds,
416
+ extractErrorCode,
300
417
  extractTableNames,
301
418
  fetchServerVersion,
302
419
  formatBytes,
420
+ formatCacheSize,
421
+ formatMigrationStats,
303
422
  generateDLQEntryId,
304
423
  generateFailureId,
305
424
  getCacheStatsImpl,
425
+ getCachedSize,
426
+ getEvictionCandidates,
427
+ getExcludeProtectedStatesCondition,
306
428
  getExtensionFromMimeType,
429
+ getFailedPermanentUploads,
430
+ getLocalUriForStoragePath,
307
431
  getLocalVersion,
308
432
  getMimeType,
309
433
  getMimeTypeFromPath,
434
+ getPendingUploads,
435
+ getProtectedStatesInClause,
436
+ getSoonestRetryTime,
437
+ getStaleUploads,
438
+ getStateName,
439
+ getStorageErrorMessage,
440
+ getSyncedUploadsWithPendingCallback,
310
441
  hasVersionColumn,
311
442
  initializeBackgroundSync,
312
443
  isAudioMimeType,
313
444
  isBackgroundSyncRegistered,
445
+ isBlobResult,
446
+ isCacheNearCapacity,
314
447
  isDocumentMimeType,
448
+ isDownloadWorkflowState,
449
+ isFileResult,
315
450
  isImageMimeType,
451
+ isLocallyAvailable,
452
+ isPendingDownloadState,
453
+ isPermanentError,
454
+ isProtectedUploadState,
455
+ isRlsError,
456
+ isStateTransitionAllowed,
457
+ isStorageAuthError,
458
+ isTerminalState,
459
+ isUploadWorkflowState,
460
+ isValidAttachmentState,
316
461
  isVideoMimeType,
462
+ markUploadPermanentFailure,
463
+ markUploadSynced,
464
+ migrateAttachmentState,
465
+ migrateAttachmentStateSafe,
466
+ normalizeStoragePath,
467
+ recordMigration,
317
468
  registerBackgroundSync,
318
- resolveBucketFromConfig,
469
+ resolveBucket,
470
+ scheduleUploadRetry,
319
471
  sleep,
472
+ startUploadProcessing,
473
+ stripFileUri,
320
474
  toSyncOperationError,
321
475
  unregisterBackgroundSync,
476
+ uploadOne,
322
477
  useAttachmentQueue,
478
+ useAttachmentQueueContext,
323
479
  useAttachmentQueueReady,
324
480
  useCompletedTransactions,
325
481
  useCompletedTransactionsContext,
@@ -337,6 +493,7 @@ export {
337
493
  usePendingMutationsContext,
338
494
  usePlatform,
339
495
  usePowerSync,
496
+ usePowerSyncContext,
340
497
  useSyncActivity,
341
498
  useSyncActivityContext,
342
499
  useSyncControl,
@@ -344,7 +501,12 @@ export {
344
501
  useSyncMode,
345
502
  useSyncModeContext,
346
503
  useSyncStatus,
504
+ useSyncStatusContext,
347
505
  useUploadStatus,
506
+ validateSqlIdentifier2 as validateSqlIdentifier,
507
+ validateSqlIdentifier as validateSqlIdentifierFromStateMachine,
508
+ validateWhereClause,
509
+ watchConfigToSourceConfig,
348
510
  withExponentialBackoff
349
511
  };
350
512
  //# sourceMappingURL=index.web.js.map
@@ -6,7 +6,6 @@ import {
6
6
  useDatabaseMaintenance
7
7
  } from "../chunk-WGHNIAF7.js";
8
8
  import "../chunk-YSTEESEG.js";
9
- import "../chunk-DGUM43GV.js";
10
9
  export {
11
10
  checkIntegrityImpl,
12
11
  checkStorageQuotaImpl,
@@ -1,5 +1,3 @@
1
- import "../chunk-DGUM43GV.js";
2
-
3
1
  // src/platform/types.ts
4
2
  function detectPlatform() {
5
3
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
@@ -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 * 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
+ {"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,7 +1,6 @@
1
1
  import {
2
2
  createNativePlatformAdapter
3
- } from "../chunk-53WH2JJV.js";
4
- import "../chunk-DGUM43GV.js";
3
+ } from "../chunk-WN5ZJ3E2.js";
5
4
  export {
6
5
  createNativePlatformAdapter
7
6
  };
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  createWebPlatformAdapter
3
3
  } from "../chunk-N75DEF5J.js";
4
- import "../chunk-DGUM43GV.js";
5
4
  export {
6
5
  createWebPlatformAdapter
7
6
  };