@pol-studios/powersync 1.0.6 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +933 -0
  2. package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
  3. package/dist/attachments/index.d.ts +745 -332
  4. package/dist/attachments/index.js +152 -6
  5. package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
  6. package/dist/chunk-24RDMMCL.js +44 -0
  7. package/dist/chunk-24RDMMCL.js.map +1 -0
  8. package/dist/chunk-4TXTAEF2.js +2060 -0
  9. package/dist/chunk-4TXTAEF2.js.map +1 -0
  10. package/dist/chunk-63PXSPIN.js +358 -0
  11. package/dist/chunk-63PXSPIN.js.map +1 -0
  12. package/dist/chunk-654ERHA7.js +1 -0
  13. package/dist/chunk-A4IBBWGO.js +377 -0
  14. package/dist/chunk-A4IBBWGO.js.map +1 -0
  15. package/dist/chunk-BRXQNASY.js +1720 -0
  16. package/dist/chunk-BRXQNASY.js.map +1 -0
  17. package/dist/chunk-CAB26E6F.js +142 -0
  18. package/dist/chunk-CAB26E6F.js.map +1 -0
  19. package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
  20. package/dist/chunk-CGL33PL4.js.map +1 -0
  21. package/dist/{chunk-R4YFWQ3Q.js → chunk-CUCAYK7Z.js} +309 -92
  22. package/dist/chunk-CUCAYK7Z.js.map +1 -0
  23. package/dist/chunk-FV2HXEIY.js +124 -0
  24. package/dist/chunk-FV2HXEIY.js.map +1 -0
  25. package/dist/chunk-HWSNV45P.js +279 -0
  26. package/dist/chunk-HWSNV45P.js.map +1 -0
  27. package/dist/{chunk-62J2DPKX.js → chunk-KN2IZERF.js} +530 -413
  28. package/dist/chunk-KN2IZERF.js.map +1 -0
  29. package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
  30. package/dist/chunk-N75DEF5J.js.map +1 -0
  31. package/dist/chunk-P4HZA6ZT.js +83 -0
  32. package/dist/chunk-P4HZA6ZT.js.map +1 -0
  33. package/dist/chunk-P6WOZO7H.js +49 -0
  34. package/dist/chunk-P6WOZO7H.js.map +1 -0
  35. package/dist/chunk-T4AO7JIG.js +1 -0
  36. package/dist/chunk-TGBT5XBE.js +1 -0
  37. package/dist/{chunk-FPTDATY5.js → chunk-VACPAAQZ.js} +54 -12
  38. package/dist/chunk-VACPAAQZ.js.map +1 -0
  39. package/dist/chunk-WGHNIAF7.js +329 -0
  40. package/dist/chunk-WGHNIAF7.js.map +1 -0
  41. package/dist/{chunk-3AYXHQ4W.js → chunk-WN5ZJ3E2.js} +108 -47
  42. package/dist/chunk-WN5ZJ3E2.js.map +1 -0
  43. package/dist/chunk-XAEII4ZX.js +456 -0
  44. package/dist/chunk-XAEII4ZX.js.map +1 -0
  45. package/dist/chunk-XOY2CJ67.js +289 -0
  46. package/dist/chunk-XOY2CJ67.js.map +1 -0
  47. package/dist/chunk-YHTZ7VMV.js +1 -0
  48. package/dist/chunk-YSTEESEG.js +676 -0
  49. package/dist/chunk-YSTEESEG.js.map +1 -0
  50. package/dist/chunk-Z6VOBGTU.js +32 -0
  51. package/dist/chunk-Z6VOBGTU.js.map +1 -0
  52. package/dist/chunk-ZM4ENYMF.js +230 -0
  53. package/dist/chunk-ZM4ENYMF.js.map +1 -0
  54. package/dist/connector/index.d.ts +236 -4
  55. package/dist/connector/index.js +15 -4
  56. package/dist/core/index.d.ts +16 -3
  57. package/dist/core/index.js +6 -2
  58. package/dist/error/index.d.ts +54 -0
  59. package/dist/error/index.js +7 -0
  60. package/dist/error/index.js.map +1 -0
  61. package/dist/index.d.ts +102 -12
  62. package/dist/index.js +309 -37
  63. package/dist/index.native.d.ts +22 -10
  64. package/dist/index.native.js +309 -38
  65. package/dist/index.web.d.ts +22 -10
  66. package/dist/index.web.js +310 -38
  67. package/dist/maintenance/index.d.ts +118 -0
  68. package/dist/maintenance/index.js +16 -0
  69. package/dist/maintenance/index.js.map +1 -0
  70. package/dist/platform/index.d.ts +16 -1
  71. package/dist/platform/index.js.map +1 -1
  72. package/dist/platform/index.native.d.ts +2 -2
  73. package/dist/platform/index.native.js +1 -1
  74. package/dist/platform/index.web.d.ts +1 -1
  75. package/dist/platform/index.web.js +1 -1
  76. package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
  77. package/dist/provider/index.d.ts +451 -21
  78. package/dist/provider/index.js +32 -13
  79. package/dist/react/index.d.ts +372 -0
  80. package/dist/react/index.js +25 -0
  81. package/dist/react/index.js.map +1 -0
  82. package/dist/storage/index.d.ts +6 -0
  83. package/dist/storage/index.js +42 -0
  84. package/dist/storage/index.js.map +1 -0
  85. package/dist/storage/index.native.d.ts +6 -0
  86. package/dist/storage/index.native.js +40 -0
  87. package/dist/storage/index.native.js.map +1 -0
  88. package/dist/storage/index.web.d.ts +6 -0
  89. package/dist/storage/index.web.js +40 -0
  90. package/dist/storage/index.web.js.map +1 -0
  91. package/dist/storage/upload/index.d.ts +54 -0
  92. package/dist/storage/upload/index.js +15 -0
  93. package/dist/storage/upload/index.js.map +1 -0
  94. package/dist/storage/upload/index.native.d.ts +56 -0
  95. package/dist/storage/upload/index.native.js +15 -0
  96. package/dist/storage/upload/index.native.js.map +1 -0
  97. package/dist/storage/upload/index.web.d.ts +2 -0
  98. package/dist/storage/upload/index.web.js +14 -0
  99. package/dist/storage/upload/index.web.js.map +1 -0
  100. package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
  101. package/dist/sync/index.d.ts +288 -23
  102. package/dist/sync/index.js +22 -10
  103. package/dist/{index-l3iL9Jte.d.ts → types-B212hgfA.d.ts} +101 -158
  104. package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
  105. package/dist/types-CyvBaAl8.d.ts +60 -0
  106. package/dist/types-D0WcHrq6.d.ts +234 -0
  107. package/package.json +89 -5
  108. package/dist/chunk-32OLICZO.js +0 -1
  109. package/dist/chunk-3AYXHQ4W.js.map +0 -1
  110. package/dist/chunk-5FIMA26D.js +0 -1
  111. package/dist/chunk-62J2DPKX.js.map +0 -1
  112. package/dist/chunk-7EMDVIZX.js.map +0 -1
  113. package/dist/chunk-EJ23MXPQ.js.map +0 -1
  114. package/dist/chunk-FPTDATY5.js.map +0 -1
  115. package/dist/chunk-KCDG2MNP.js +0 -1431
  116. package/dist/chunk-KCDG2MNP.js.map +0 -1
  117. package/dist/chunk-OLHGI472.js +0 -1
  118. package/dist/chunk-PAFBKNL3.js +0 -99
  119. package/dist/chunk-PAFBKNL3.js.map +0 -1
  120. package/dist/chunk-R4YFWQ3Q.js.map +0 -1
  121. package/dist/chunk-V6LJ6MR2.js +0 -740
  122. package/dist/chunk-V6LJ6MR2.js.map +0 -1
  123. package/dist/chunk-VJCL2SWD.js +0 -1
  124. package/dist/failed-upload-store-C0cLxxPz.d.ts +0 -33
  125. /package/dist/{chunk-32OLICZO.js.map → chunk-654ERHA7.js.map} +0 -0
  126. /package/dist/{chunk-5FIMA26D.js.map → chunk-T4AO7JIG.js.map} +0 -0
  127. /package/dist/{chunk-OLHGI472.js.map → chunk-TGBT5XBE.js.map} +0 -0
  128. /package/dist/{chunk-VJCL2SWD.js.map → chunk-YHTZ7VMV.js.map} +0 -0
@@ -2,7 +2,9 @@
2
2
  function createNativePlatformAdapter(logger) {
3
3
  let PowerSyncDatabase;
4
4
  let OPSqliteOpenFactory;
5
- let FileSystem;
5
+ let File;
6
+ let Directory;
7
+ let Paths;
6
8
  let AsyncStorage;
7
9
  let NetInfo;
8
10
  let ImageManipulator;
@@ -15,8 +17,11 @@ function createNativePlatformAdapter(logger) {
15
17
  const opSqliteModule = await import("@powersync/op-sqlite");
16
18
  OPSqliteOpenFactory = opSqliteModule.OPSqliteOpenFactory;
17
19
  }
18
- if (!FileSystem) {
19
- FileSystem = await import("expo-file-system");
20
+ if (!File || !Directory || !Paths) {
21
+ const fsModule = await import("expo-file-system");
22
+ File = fsModule.File;
23
+ Directory = fsModule.Directory;
24
+ Paths = fsModule.Paths;
20
25
  }
21
26
  if (!AsyncStorage) {
22
27
  const asModule = await import("@react-native-async-storage/async-storage");
@@ -32,74 +37,125 @@ function createNativePlatformAdapter(logger) {
32
37
  };
33
38
  const fileSystem = {
34
39
  async readFile(uri, encoding = "utf8") {
35
- if (!FileSystem) await loadDependencies();
36
- return FileSystem.readAsStringAsync(uri, {
37
- encoding: encoding === "base64" ? FileSystem.EncodingType.Base64 : FileSystem.EncodingType.UTF8
38
- });
40
+ if (!File) await loadDependencies();
41
+ const file = new File(uri);
42
+ if (encoding === "base64") {
43
+ return file.base64();
44
+ }
45
+ return file.text();
39
46
  },
40
47
  async writeFile(uri, data, encoding = "utf8") {
41
- if (!FileSystem) await loadDependencies();
48
+ if (!File || !Directory) await loadDependencies();
42
49
  const parentDir = uri.substring(0, uri.lastIndexOf("/"));
43
50
  if (parentDir) {
44
- await FileSystem.makeDirectoryAsync(parentDir, {
45
- intermediates: true
46
- }).catch(() => {
51
+ const dir = new Directory(parentDir);
52
+ dir.create({
53
+ intermediates: true,
54
+ idempotent: true
47
55
  });
48
56
  }
49
- await FileSystem.writeAsStringAsync(uri, data, {
50
- encoding: encoding === "base64" ? FileSystem.EncodingType.Base64 : FileSystem.EncodingType.UTF8
51
- });
57
+ const file = new File(uri);
58
+ if (encoding === "base64") {
59
+ const binaryString = atob(data);
60
+ const bytes = new Uint8Array(binaryString.length);
61
+ for (let i = 0; i < binaryString.length; i++) {
62
+ bytes[i] = binaryString.charCodeAt(i);
63
+ }
64
+ file.write(bytes);
65
+ } else {
66
+ file.write(data);
67
+ }
52
68
  },
53
69
  async deleteFile(uri) {
54
- if (!FileSystem) await loadDependencies();
55
- await FileSystem.deleteAsync(uri, {
56
- idempotent: true
57
- });
70
+ if (!File) await loadDependencies();
71
+ const file = new File(uri);
72
+ try {
73
+ if (file.exists) {
74
+ file.delete();
75
+ }
76
+ } catch {
77
+ }
58
78
  },
59
79
  async copyFile(source, destination) {
60
- if (!FileSystem) await loadDependencies();
61
- await FileSystem.copyAsync({
62
- from: source,
63
- to: destination
64
- });
80
+ if (!File) await loadDependencies();
81
+ const sourceFile = new File(source);
82
+ const destFile = new File(destination);
83
+ sourceFile.copy(destFile);
65
84
  },
66
85
  async moveFile(source, destination) {
67
- if (!FileSystem) await loadDependencies();
68
- await FileSystem.moveAsync({
69
- from: source,
70
- to: destination
71
- });
86
+ if (!File) await loadDependencies();
87
+ const sourceFile = new File(source);
88
+ const destFile = new File(destination);
89
+ sourceFile.move(destFile);
72
90
  },
73
91
  async getFileInfo(uri) {
74
- if (!FileSystem) await loadDependencies();
92
+ if (!File || !Paths) await loadDependencies();
75
93
  try {
76
- const info = await FileSystem.getInfoAsync(uri);
77
- if (!info.exists) return null;
78
- return {
79
- exists: true,
80
- size: "size" in info ? info.size ?? 0 : 0,
81
- isDirectory: info.isDirectory ?? false,
82
- modificationTime: "modificationTime" in info && info.modificationTime ? new Date(info.modificationTime * 1e3) : void 0
83
- };
94
+ const pathInfo = Paths.info(uri);
95
+ if (!pathInfo.exists) return null;
96
+ if (pathInfo.isDirectory) {
97
+ const dir = new Directory(uri);
98
+ const dirInfo = dir.info();
99
+ return {
100
+ exists: true,
101
+ size: dirInfo.size ?? 0,
102
+ isDirectory: true,
103
+ modificationTime: dirInfo.modificationTime ? new Date(dirInfo.modificationTime) : void 0
104
+ };
105
+ } else {
106
+ const file = new File(uri);
107
+ const fileInfo = file.info();
108
+ return {
109
+ exists: true,
110
+ size: fileInfo.size ?? 0,
111
+ isDirectory: false,
112
+ modificationTime: fileInfo.modificationTime ? new Date(fileInfo.modificationTime) : void 0
113
+ };
114
+ }
84
115
  } catch {
85
116
  return null;
86
117
  }
87
118
  },
88
119
  async makeDirectory(uri, options) {
89
- if (!FileSystem) await loadDependencies();
90
- await FileSystem.makeDirectoryAsync(uri, {
91
- intermediates: options?.intermediates ?? true
120
+ if (!Directory) await loadDependencies();
121
+ const dir = new Directory(uri);
122
+ dir.create({
123
+ intermediates: options?.intermediates ?? true,
124
+ idempotent: true
92
125
  });
93
126
  },
94
127
  getDocumentsDirectory() {
95
- return FileSystem?.documentDirectory ?? "";
128
+ if (!Paths) {
129
+ throw new Error("[Platform] Paths not loaded. Call an async method first to initialize dependencies.");
130
+ }
131
+ const dir = Paths.document.uri;
132
+ return dir.endsWith("/") ? dir : `${dir}/`;
96
133
  },
97
134
  getCacheDirectory() {
98
- return FileSystem?.cacheDirectory ?? "";
135
+ if (!Paths) {
136
+ throw new Error("[Platform] Paths not loaded. Call an async method first to initialize dependencies.");
137
+ }
138
+ const dir = Paths.cache.uri;
139
+ return dir.endsWith("/") ? dir : `${dir}/`;
99
140
  },
100
141
  async getFreeDiskSpace() {
101
- if (!FileSystem) await loadDependencies();
102
- return FileSystem.getFreeDiskStorageAsync();
142
+ if (!Paths) await loadDependencies();
143
+ return Paths.availableDiskSpace;
144
+ },
145
+ async downloadFile(url, localPath) {
146
+ if (!File || !Directory) await loadDependencies();
147
+ const parentDir = localPath.substring(0, localPath.lastIndexOf("/"));
148
+ if (parentDir) {
149
+ const dir = new Directory(parentDir);
150
+ dir.create({
151
+ intermediates: true,
152
+ idempotent: true
153
+ });
154
+ }
155
+ const destFile = new File(localPath);
156
+ await File.downloadFileAsync(url, destFile, {
157
+ idempotent: true
158
+ });
103
159
  }
104
160
  };
105
161
  const storage = {
@@ -143,13 +199,18 @@ function createNativePlatformAdapter(logger) {
143
199
  },
144
200
  addConnectionListener(callback) {
145
201
  if (!NetInfo) {
146
- logger.warn("[Platform] NetInfo not loaded, connection listener may not work immediately");
202
+ logger.warn("[Platform] NetInfo not loaded, setting up listener asynchronously");
203
+ let realUnsubscribe = null;
204
+ let cancelled = false;
147
205
  loadDependencies().then(() => {
148
- NetInfo.addEventListener((state) => {
206
+ if (cancelled) return;
207
+ realUnsubscribe = NetInfo.addEventListener((state) => {
149
208
  callback(state.isConnected ?? false);
150
209
  });
151
210
  });
152
211
  return () => {
212
+ cancelled = true;
213
+ realUnsubscribe?.();
153
214
  };
154
215
  }
155
216
  const unsubscribe = NetInfo.addEventListener((state) => {
@@ -235,4 +296,4 @@ function createNativePlatformAdapter(logger) {
235
296
  export {
236
297
  createNativePlatformAdapter
237
298
  };
238
- //# sourceMappingURL=chunk-3AYXHQ4W.js.map
299
+ //# sourceMappingURL=chunk-WN5ZJ3E2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/platform/index.native.ts"],"sourcesContent":["/**\n * React Native Platform Adapter for @pol-studios/powersync\n *\n * Implements the PlatformAdapter interface using React Native specific APIs:\n * - @powersync/react-native for SQLite database\n * - expo-file-system for file operations (new class-based API)\n * - @react-native-async-storage/async-storage for key-value storage\n * - @react-native-community/netinfo for network monitoring\n * - expo-image-manipulator for image compression\n */\n\nimport type { PlatformAdapter, DatabaseOptions, FileSystemAdapter, AsyncStorageAdapter, NetworkAdapter, LoggerAdapter, ImageProcessorAdapter, FileInfo, CompressedImage, CompressionOptions, ConnectionType } from './types';\nimport type { AbstractPowerSyncDatabase } from '../core/types';\n\n// Import new expo-file-system API types\nimport type { File as ExpoFile, Directory as ExpoDirectory, Paths as ExpoPaths } from 'expo-file-system';\n\n/**\n * Create a React Native platform adapter\n *\n * @param logger - Logger implementation to use\n * @returns Platform adapter configured for React Native\n *\n * @example\n * ```typescript\n * import { createNativePlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const logger = {\n * debug: console.log,\n * info: console.log,\n * warn: console.warn,\n * error: console.error,\n * };\n *\n * const platform = createNativePlatformAdapter(logger);\n * ```\n */\nexport function createNativePlatformAdapter(logger: LoggerAdapter): PlatformAdapter {\n // Lazy imports to avoid loading these modules until needed\n // This also helps with tree-shaking in web builds\n let PowerSyncDatabase: typeof import('@powersync/react-native').PowerSyncDatabase;\n let OPSqliteOpenFactory: typeof import('@powersync/op-sqlite').OPSqliteOpenFactory;\n // New expo-file-system API classes\n let File: typeof ExpoFile;\n let Directory: typeof ExpoDirectory;\n let Paths: typeof ExpoPaths;\n let AsyncStorage: typeof import('@react-native-async-storage/async-storage').default;\n let NetInfo: typeof import('@react-native-community/netinfo').default;\n let ImageManipulator: typeof import('expo-image-manipulator');\n const loadDependencies = async () => {\n if (!PowerSyncDatabase) {\n const psModule = await import('@powersync/react-native');\n PowerSyncDatabase = psModule.PowerSyncDatabase;\n }\n if (!OPSqliteOpenFactory) {\n const opSqliteModule = await import('@powersync/op-sqlite');\n OPSqliteOpenFactory = opSqliteModule.OPSqliteOpenFactory;\n }\n if (!File || !Directory || !Paths) {\n const fsModule = await import('expo-file-system');\n File = fsModule.File;\n Directory = fsModule.Directory;\n Paths = fsModule.Paths;\n }\n if (!AsyncStorage) {\n const asModule = await import('@react-native-async-storage/async-storage');\n AsyncStorage = asModule.default;\n }\n if (!NetInfo) {\n const niModule = await import('@react-native-community/netinfo');\n NetInfo = niModule.default;\n }\n if (!ImageManipulator) {\n ImageManipulator = await import('expo-image-manipulator');\n }\n };\n\n // File system adapter implementation using new expo-file-system class-based API\n const fileSystem: FileSystemAdapter = {\n async readFile(uri: string, encoding: 'base64' | 'utf8' = 'utf8'): Promise<string> {\n if (!File) await loadDependencies();\n const file = new File!(uri);\n if (encoding === 'base64') {\n return file.base64();\n }\n return file.text();\n },\n async writeFile(uri: string, data: string, encoding: 'base64' | 'utf8' = 'utf8'): Promise<void> {\n if (!File || !Directory) await loadDependencies();\n // Ensure parent directory exists (use idempotent to avoid errors if exists)\n const parentDir = uri.substring(0, uri.lastIndexOf('/'));\n if (parentDir) {\n const dir = new Directory!(parentDir);\n dir.create({\n intermediates: true,\n idempotent: true\n });\n }\n const file = new File!(uri);\n if (encoding === 'base64') {\n // Decode base64 to binary and write as Uint8Array\n const binaryString = atob(data);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n file.write(bytes);\n } else {\n // Write text directly\n file.write(data);\n }\n },\n async deleteFile(uri: string): Promise<void> {\n if (!File) await loadDependencies();\n const file = new File!(uri);\n try {\n if (file.exists) {\n file.delete();\n }\n } catch {\n // File may not exist, treat as idempotent\n }\n },\n async copyFile(source: string, destination: string): Promise<void> {\n if (!File) await loadDependencies();\n const sourceFile = new File!(source);\n const destFile = new File!(destination);\n sourceFile.copy(destFile);\n },\n async moveFile(source: string, destination: string): Promise<void> {\n if (!File) await loadDependencies();\n const sourceFile = new File!(source);\n const destFile = new File!(destination);\n sourceFile.move(destFile);\n },\n async getFileInfo(uri: string): Promise<FileInfo | null> {\n if (!File || !Paths) await loadDependencies();\n try {\n // Use Paths.info() to check if it's a directory or file\n const pathInfo = Paths!.info(uri);\n if (!pathInfo.exists) return null;\n if (pathInfo.isDirectory) {\n const dir = new Directory!(uri);\n const dirInfo = dir.info();\n return {\n exists: true,\n size: dirInfo.size ?? 0,\n isDirectory: true,\n modificationTime: dirInfo.modificationTime ? new Date(dirInfo.modificationTime) : undefined\n };\n } else {\n const file = new File!(uri);\n const fileInfo = file.info();\n return {\n exists: true,\n size: fileInfo.size ?? 0,\n isDirectory: false,\n modificationTime: fileInfo.modificationTime ? new Date(fileInfo.modificationTime) : undefined\n };\n }\n } catch {\n return null;\n }\n },\n async makeDirectory(uri: string, options?: {\n intermediates?: boolean;\n }): Promise<void> {\n if (!Directory) await loadDependencies();\n const dir = new Directory!(uri);\n dir.create({\n intermediates: options?.intermediates ?? true,\n idempotent: true\n });\n },\n getDocumentsDirectory(): string {\n if (!Paths) {\n throw new Error('[Platform] Paths not loaded. Call an async method first to initialize dependencies.');\n }\n // Ensure trailing slash for consistency with legacy FileSystem.documentDirectory\n const dir = Paths.document.uri;\n return dir.endsWith('/') ? dir : `${dir}/`;\n },\n getCacheDirectory(): string {\n if (!Paths) {\n throw new Error('[Platform] Paths not loaded. Call an async method first to initialize dependencies.');\n }\n // Ensure trailing slash for consistency with legacy FileSystem.cacheDirectory\n const dir = Paths.cache.uri;\n return dir.endsWith('/') ? dir : `${dir}/`;\n },\n async getFreeDiskSpace(): Promise<number> {\n if (!Paths) await loadDependencies();\n // New API provides this as a property on Paths\n return Paths!.availableDiskSpace;\n },\n async downloadFile(url: string, localPath: string): Promise<void> {\n if (!File || !Directory) await loadDependencies();\n\n // Ensure parent directory exists\n const parentDir = localPath.substring(0, localPath.lastIndexOf('/'));\n if (parentDir) {\n const dir = new Directory!(parentDir);\n dir.create({\n intermediates: true,\n idempotent: true\n });\n }\n\n // Use new expo-file-system File.downloadFileAsync for memory-efficient streaming download\n const destFile = new File!(localPath);\n await File!.downloadFileAsync(url, destFile, {\n idempotent: true\n });\n }\n };\n\n // Async storage adapter implementation\n const storage: AsyncStorageAdapter = {\n async getItem(key: string): Promise<string | null> {\n if (!AsyncStorage) await loadDependencies();\n return AsyncStorage!.getItem(key);\n },\n async setItem(key: string, value: string): Promise<void> {\n if (!AsyncStorage) await loadDependencies();\n await AsyncStorage!.setItem(key, value);\n },\n async removeItem(key: string): Promise<void> {\n if (!AsyncStorage) await loadDependencies();\n await AsyncStorage!.removeItem(key);\n },\n async multiGet(keys: string[]): Promise<[string, string | null][]> {\n if (!AsyncStorage) await loadDependencies();\n const result = await AsyncStorage!.multiGet(keys);\n return result as [string, string | null][];\n },\n async multiSet(entries: [string, string][]): Promise<void> {\n if (!AsyncStorage) await loadDependencies();\n await AsyncStorage!.multiSet(entries);\n }\n };\n\n // Network adapter implementation\n const network: NetworkAdapter = {\n async isConnected(): Promise<boolean> {\n if (!NetInfo) await loadDependencies();\n const state = await NetInfo!.fetch();\n return state.isConnected ?? false;\n },\n async getConnectionType(): Promise<ConnectionType> {\n if (!NetInfo) await loadDependencies();\n const state = await NetInfo!.fetch();\n const type = state.type;\n if (type === 'wifi') return 'wifi';\n if (type === 'cellular') return 'cellular';\n if (type === 'ethernet') return 'ethernet';\n if (type === 'none') return 'none';\n return 'unknown';\n },\n addConnectionListener(callback: (isConnected: boolean) => void): () => void {\n if (!NetInfo) {\n logger.warn('[Platform] NetInfo not loaded, setting up listener asynchronously');\n let realUnsubscribe: (() => void) | null = null;\n let cancelled = false;\n loadDependencies().then(() => {\n if (cancelled) return;\n realUnsubscribe = NetInfo!.addEventListener(state => {\n callback(state.isConnected ?? false);\n });\n });\n return () => {\n cancelled = true;\n realUnsubscribe?.();\n };\n }\n const unsubscribe = NetInfo.addEventListener(state => {\n callback(state.isConnected ?? false);\n });\n return unsubscribe;\n }\n };\n\n // Image processor adapter implementation\n const imageProcessor: ImageProcessorAdapter = {\n async compress(uri: string, options: CompressionOptions): Promise<CompressedImage> {\n if (!ImageManipulator) await loadDependencies();\n const actions: import('expo-image-manipulator').Action[] = [];\n\n // Add resize action if maxWidth or maxHeight specified\n if (options.maxWidth || options.maxHeight) {\n actions.push({\n resize: {\n width: options.maxWidth,\n height: options.maxHeight\n }\n });\n }\n\n // Determine output format\n let format: import('expo-image-manipulator').SaveFormat;\n switch (options.format) {\n case 'png':\n format = ImageManipulator!.SaveFormat.PNG;\n break;\n case 'webp':\n format = ImageManipulator!.SaveFormat.WEBP;\n break;\n case 'jpeg':\n default:\n format = ImageManipulator!.SaveFormat.JPEG;\n break;\n }\n const result = await ImageManipulator!.manipulateAsync(uri, actions, {\n compress: options.quality,\n format\n });\n return {\n uri: result.uri,\n width: result.width,\n height: result.height\n };\n }\n };\n\n // Main platform adapter\n return {\n async createDatabase(options: DatabaseOptions): Promise<AbstractPowerSyncDatabase> {\n if (!PowerSyncDatabase) await loadDependencies();\n logger.info('[Platform] Creating PowerSync database:', options.dbFilename);\n const db = new PowerSyncDatabase!({\n schema: options.schema as any,\n database: new OPSqliteOpenFactory!({\n dbFilename: options.dbFilename\n })\n });\n logger.info('[Platform] Initializing database...');\n await db.init();\n\n // Verify database is queryable before returning\n // This prevents race conditions where db.connect() is called before SQLite is truly ready\n const maxAttempts = 3;\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n await db.get('SELECT 1');\n logger.info('[Platform] Database initialized and verified');\n return db as unknown as AbstractPowerSyncDatabase;\n } catch (err) {\n if (attempt < maxAttempts - 1) {\n logger.warn(`[Platform] Database readiness check failed (attempt ${attempt + 1}/${maxAttempts}), retrying...`);\n await new Promise(r => setTimeout(r, 100 * Math.pow(2, attempt))); // 100ms, 200ms, 400ms\n } else {\n logger.error('[Platform] Database failed readiness verification after all attempts');\n throw new Error(`Database failed readiness verification: ${err instanceof Error ? err.message : err}`);\n }\n }\n }\n\n // TypeScript: unreachable but needed for return type\n throw new Error('Database readiness verification failed');\n },\n fileSystem,\n storage,\n network,\n logger,\n imageProcessor\n };\n}\n\n// Re-export types for convenience\nexport type { PlatformAdapter, LoggerAdapter } from './types';"],"mappings":";AAqCO,SAAS,4BAA4B,QAAwC;AAGlF,MAAI;AACJ,MAAI;AAEJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,mBAAmB,YAAY;AACnC,QAAI,CAAC,mBAAmB;AACtB,YAAM,WAAW,MAAM,OAAO,yBAAyB;AACvD,0BAAoB,SAAS;AAAA,IAC/B;AACA,QAAI,CAAC,qBAAqB;AACxB,YAAM,iBAAiB,MAAM,OAAO,sBAAsB;AAC1D,4BAAsB,eAAe;AAAA,IACvC;AACA,QAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO;AACjC,YAAM,WAAW,MAAM,OAAO,kBAAkB;AAChD,aAAO,SAAS;AAChB,kBAAY,SAAS;AACrB,cAAQ,SAAS;AAAA,IACnB;AACA,QAAI,CAAC,cAAc;AACjB,YAAM,WAAW,MAAM,OAAO,2CAA2C;AACzE,qBAAe,SAAS;AAAA,IAC1B;AACA,QAAI,CAAC,SAAS;AACZ,YAAM,WAAW,MAAM,OAAO,iCAAiC;AAC/D,gBAAU,SAAS;AAAA,IACrB;AACA,QAAI,CAAC,kBAAkB;AACrB,yBAAmB,MAAM,OAAO,wBAAwB;AAAA,IAC1D;AAAA,EACF;AAGA,QAAM,aAAgC;AAAA,IACpC,MAAM,SAAS,KAAa,WAA8B,QAAyB;AACjF,UAAI,CAAC,KAAM,OAAM,iBAAi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