@tursodatabase/sync-react-native 0.5.0-pre.4

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 (72) hide show
  1. package/README.md +117 -0
  2. package/android/CMakeLists.txt +53 -0
  3. package/android/build.gradle +84 -0
  4. package/android/cpp-adapter.cpp +49 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/turso/sync/reactnative/TursoBridge.java +44 -0
  7. package/android/src/main/java/com/turso/sync/reactnative/TursoModule.java +82 -0
  8. package/android/src/main/java/com/turso/sync/reactnative/TursoPackage.java +29 -0
  9. package/cpp/TursoConnectionHostObject.cpp +179 -0
  10. package/cpp/TursoConnectionHostObject.h +52 -0
  11. package/cpp/TursoDatabaseHostObject.cpp +98 -0
  12. package/cpp/TursoDatabaseHostObject.h +49 -0
  13. package/cpp/TursoHostObject.cpp +561 -0
  14. package/cpp/TursoHostObject.h +24 -0
  15. package/cpp/TursoStatementHostObject.cpp +414 -0
  16. package/cpp/TursoStatementHostObject.h +65 -0
  17. package/cpp/TursoSyncChangesHostObject.cpp +41 -0
  18. package/cpp/TursoSyncChangesHostObject.h +52 -0
  19. package/cpp/TursoSyncDatabaseHostObject.cpp +328 -0
  20. package/cpp/TursoSyncDatabaseHostObject.h +61 -0
  21. package/cpp/TursoSyncIoItemHostObject.cpp +304 -0
  22. package/cpp/TursoSyncIoItemHostObject.h +52 -0
  23. package/cpp/TursoSyncOperationHostObject.cpp +168 -0
  24. package/cpp/TursoSyncOperationHostObject.h +53 -0
  25. package/ios/TursoModule.h +8 -0
  26. package/ios/TursoModule.mm +95 -0
  27. package/lib/commonjs/Database.js +445 -0
  28. package/lib/commonjs/Database.js.map +1 -0
  29. package/lib/commonjs/Statement.js +339 -0
  30. package/lib/commonjs/Statement.js.map +1 -0
  31. package/lib/commonjs/index.js +229 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/internal/asyncOperation.js +124 -0
  34. package/lib/commonjs/internal/asyncOperation.js.map +1 -0
  35. package/lib/commonjs/internal/ioProcessor.js +315 -0
  36. package/lib/commonjs/internal/ioProcessor.js.map +1 -0
  37. package/lib/commonjs/package.json +1 -0
  38. package/lib/commonjs/types.js +133 -0
  39. package/lib/commonjs/types.js.map +1 -0
  40. package/lib/module/Database.js +441 -0
  41. package/lib/module/Database.js.map +1 -0
  42. package/lib/module/Statement.js +335 -0
  43. package/lib/module/Statement.js.map +1 -0
  44. package/lib/module/index.js +205 -0
  45. package/lib/module/index.js.map +1 -0
  46. package/lib/module/internal/asyncOperation.js +116 -0
  47. package/lib/module/internal/asyncOperation.js.map +1 -0
  48. package/lib/module/internal/ioProcessor.js +309 -0
  49. package/lib/module/internal/ioProcessor.js.map +1 -0
  50. package/lib/module/package.json +1 -0
  51. package/lib/module/types.js +163 -0
  52. package/lib/module/types.js.map +1 -0
  53. package/lib/typescript/Database.d.ts +140 -0
  54. package/lib/typescript/Database.d.ts.map +1 -0
  55. package/lib/typescript/Statement.d.ts +105 -0
  56. package/lib/typescript/Statement.d.ts.map +1 -0
  57. package/lib/typescript/index.d.ts +175 -0
  58. package/lib/typescript/index.d.ts.map +1 -0
  59. package/lib/typescript/internal/asyncOperation.d.ts +39 -0
  60. package/lib/typescript/internal/asyncOperation.d.ts.map +1 -0
  61. package/lib/typescript/internal/ioProcessor.d.ts +48 -0
  62. package/lib/typescript/internal/ioProcessor.d.ts.map +1 -0
  63. package/lib/typescript/types.d.ts +316 -0
  64. package/lib/typescript/types.d.ts.map +1 -0
  65. package/package.json +97 -0
  66. package/src/Database.ts +480 -0
  67. package/src/Statement.ts +372 -0
  68. package/src/index.ts +240 -0
  69. package/src/internal/asyncOperation.ts +147 -0
  70. package/src/internal/ioProcessor.ts +328 -0
  71. package/src/types.ts +391 -0
  72. package/turso-sync-react-native.podspec +56 -0
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Statement
5
+ *
6
+ * High-level wrapper around NativeStatement providing a clean API.
7
+ * Handles parameter binding, row conversion, and result collection.
8
+ */
9
+
10
+ import { TursoStatus, TursoType } from './types';
11
+
12
+ /**
13
+ * Prepared SQL statement
14
+ */
15
+ export class Statement {
16
+ _finalized = false;
17
+ constructor(statement, extraIo) {
18
+ this._statement = statement;
19
+ this._extraIo = extraIo;
20
+ }
21
+
22
+ /**
23
+ * Bind parameters to the statement
24
+ *
25
+ * @param params - Parameters to bind (array, object, or single value)
26
+ * @returns this for chaining
27
+ */
28
+ bind(...params) {
29
+ if (this._finalized) {
30
+ throw new Error('Statement has been finalized');
31
+ }
32
+
33
+ // Flatten parameters if single array passed
34
+ let flatParams;
35
+ if (params.length === 1 && Array.isArray(params[0])) {
36
+ flatParams = params[0];
37
+ } else if (params.length === 1 && typeof params[0] === 'object' && params[0] !== null) {
38
+ // Named parameters
39
+ const namedParams = params[0];
40
+ this.bindNamed(namedParams);
41
+ return this;
42
+ } else {
43
+ flatParams = params;
44
+ }
45
+
46
+ // Bind positional parameters
47
+ this.bindPositional(flatParams);
48
+ return this;
49
+ }
50
+
51
+ /**
52
+ * Bind positional parameters (1-indexed)
53
+ *
54
+ * @param params - Array of values to bind
55
+ */
56
+ bindPositional(params) {
57
+ for (let i = 0; i < params.length; i++) {
58
+ const position = i + 1; // 1-indexed
59
+ const value = params[i];
60
+ this.bindValue(position, value);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Bind named parameters
66
+ *
67
+ * @param params - Object with named parameters
68
+ */
69
+ bindNamed(params) {
70
+ for (const [name, value] of Object.entries(params)) {
71
+ // Get position for named parameter
72
+ const position = this._statement.namedPosition(name);
73
+ if (position < 0) {
74
+ throw new Error(`Unknown parameter name: ${name}`);
75
+ }
76
+ this.bindValue(position, value);
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Bind a single value at a position
82
+ *
83
+ * @param position - 1-indexed position
84
+ * @param value - Value to bind
85
+ */
86
+ bindValue(position, value) {
87
+ if (value === null || value === undefined) {
88
+ this._statement.bindPositionalNull(position);
89
+ } else if (typeof value === 'number') {
90
+ // Check if integer or float
91
+ if (Number.isInteger(value)) {
92
+ this._statement.bindPositionalInt(position, value);
93
+ } else {
94
+ this._statement.bindPositionalDouble(position, value);
95
+ }
96
+ } else if (typeof value === 'string') {
97
+ this._statement.bindPositionalText(position, value);
98
+ } else if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
99
+ const buffer = value;
100
+ this._statement.bindPositionalBlob(position, buffer);
101
+ } else {
102
+ throw new Error(`Unsupported parameter type: ${typeof value}`);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Execute statement without returning rows (for INSERT, UPDATE, DELETE)
108
+ *
109
+ * @param params - Optional parameters to bind
110
+ * @returns Result with changes and lastInsertRowid
111
+ */
112
+ async run(...params) {
113
+ if (this._finalized) {
114
+ throw new Error('Statement has been finalized');
115
+ }
116
+
117
+ // Bind parameters if provided
118
+ if (params.length > 0) {
119
+ this.bind(...params);
120
+ }
121
+
122
+ // Execute statement with IO handling
123
+ const result = await this.executeWithIo();
124
+
125
+ // Reset for next execution
126
+ this._statement.reset();
127
+ return {
128
+ changes: result.rowsChanged,
129
+ lastInsertRowid: 0 // Not available from execute, would need connection
130
+ };
131
+ }
132
+
133
+ /**
134
+ * Execute statement handling potential IO (for partial sync)
135
+ * Matches Python's _run_execute_with_io pattern
136
+ *
137
+ * @returns Execution result
138
+ */
139
+ async executeWithIo() {
140
+ while (true) {
141
+ const result = this._statement.execute();
142
+ if (result.status === TursoStatus.IO) {
143
+ // Statement needs IO (e.g., loading missing pages with partial sync)
144
+ this._statement.runIo();
145
+
146
+ // Drain sync engine IO queue
147
+ if (this._extraIo) {
148
+ await this._extraIo();
149
+ }
150
+ continue;
151
+ }
152
+ if (result.status !== TursoStatus.DONE) {
153
+ throw new Error(`Statement execution failed with status: ${result.status}`);
154
+ }
155
+ return result;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Step statement once handling potential IO (for partial sync)
161
+ * Matches Python's _step_once_with_io pattern
162
+ *
163
+ * @returns Status code
164
+ */
165
+ async stepWithIo() {
166
+ while (true) {
167
+ const status = this._statement.step();
168
+ if (status === TursoStatus.IO) {
169
+ // Statement needs IO (e.g., loading missing pages with partial sync)
170
+ this._statement.runIo();
171
+
172
+ // Drain sync engine IO queue
173
+ if (this._extraIo) {
174
+ await this._extraIo();
175
+ }
176
+ continue;
177
+ }
178
+ return status;
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Execute statement and return first row
184
+ *
185
+ * @param params - Optional parameters to bind
186
+ * @returns First row or undefined
187
+ */
188
+ async get(...params) {
189
+ if (this._finalized) {
190
+ throw new Error('Statement has been finalized');
191
+ }
192
+
193
+ // Bind parameters if provided
194
+ if (params.length > 0) {
195
+ this.bind(...params);
196
+ }
197
+
198
+ // Step once with async IO handling
199
+ const status = await this.stepWithIo();
200
+ if (status === TursoStatus.ROW) {
201
+ const row = this.readRow();
202
+ this._statement.reset();
203
+ return row;
204
+ }
205
+ if (status === TursoStatus.DONE) {
206
+ this._statement.reset();
207
+ return undefined;
208
+ }
209
+ throw new Error(`Statement step failed with status: ${status}`);
210
+ }
211
+
212
+ /**
213
+ * Execute statement and return all rows
214
+ *
215
+ * @param params - Optional parameters to bind
216
+ * @returns Array of rows
217
+ */
218
+ async all(...params) {
219
+ if (this._finalized) {
220
+ throw new Error('Statement has been finalized');
221
+ }
222
+
223
+ // Bind parameters if provided
224
+ if (params.length > 0) {
225
+ this.bind(...params);
226
+ }
227
+ const rows = [];
228
+
229
+ // Step through all rows with async IO handling
230
+ while (true) {
231
+ const status = await this.stepWithIo();
232
+ if (status === TursoStatus.ROW) {
233
+ rows.push(this.readRow());
234
+ } else if (status === TursoStatus.DONE) {
235
+ break;
236
+ } else {
237
+ throw new Error(`Statement step failed with status: ${status}`);
238
+ }
239
+ }
240
+ this._statement.reset();
241
+ return rows;
242
+ }
243
+
244
+ /**
245
+ * Read current row into an object
246
+ *
247
+ * @returns Row object with column name keys
248
+ */
249
+ readRow() {
250
+ const row = {};
251
+ const columnCount = this._statement.columnCount();
252
+ for (let i = 0; i < columnCount; i++) {
253
+ const name = this._statement.columnName(i);
254
+ if (!name) {
255
+ throw new Error(`Failed to get column name at index ${i}`);
256
+ }
257
+ const value = this.readColumnValue(i);
258
+ row[name] = value;
259
+ }
260
+ return row;
261
+ }
262
+
263
+ /**
264
+ * Read value at column index
265
+ *
266
+ * @param index - Column index
267
+ * @returns Column value
268
+ */
269
+ readColumnValue(index) {
270
+ const kind = this._statement.rowValueKind(index);
271
+ switch (kind) {
272
+ case TursoType.NULL:
273
+ return null;
274
+ case TursoType.INTEGER:
275
+ return this._statement.rowValueInt(index);
276
+ case TursoType.REAL:
277
+ return this._statement.rowValueDouble(index);
278
+ case TursoType.TEXT:
279
+ // Use rowValueText which directly returns a string from C++ (avoids encoding issues)
280
+ return this._statement.rowValueText(index);
281
+ case TursoType.BLOB:
282
+ return this._statement.rowValueBytesPtr(index) || new ArrayBuffer(0);
283
+ default:
284
+ throw new Error(`Unknown column type: ${kind}`);
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Reset statement for re-execution
290
+ *
291
+ * @returns this for chaining
292
+ */
293
+ reset() {
294
+ if (this._finalized) {
295
+ throw new Error('Statement has been finalized');
296
+ }
297
+ this._statement.reset();
298
+ return this;
299
+ }
300
+
301
+ /**
302
+ * Finalize and release statement resources
303
+ */
304
+ async finalize() {
305
+ if (this._finalized) {
306
+ return;
307
+ }
308
+ while (true) {
309
+ const status = this._statement.finalize();
310
+ if (status === TursoStatus.IO) {
311
+ // Statement needs IO (e.g., loading missing pages with partial sync)
312
+ this._statement.runIo();
313
+
314
+ // Drain sync engine IO queue
315
+ if (this._extraIo) {
316
+ await this._extraIo();
317
+ }
318
+ continue;
319
+ }
320
+ if (status !== TursoStatus.DONE) {
321
+ throw new Error(`Statement finalization failed with status: ${status}`);
322
+ }
323
+ break;
324
+ }
325
+ this._finalized = true;
326
+ }
327
+
328
+ /**
329
+ * Check if statement has been finalized
330
+ */
331
+ get finalized() {
332
+ return this._finalized;
333
+ }
334
+ }
335
+ //# sourceMappingURL=Statement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TursoStatus","TursoType","Statement","_finalized","constructor","statement","extraIo","_statement","_extraIo","bind","params","Error","flatParams","length","Array","isArray","namedParams","bindNamed","bindPositional","i","position","value","bindValue","name","Object","entries","namedPosition","undefined","bindPositionalNull","Number","isInteger","bindPositionalInt","bindPositionalDouble","bindPositionalText","ArrayBuffer","isView","buffer","bindPositionalBlob","run","result","executeWithIo","reset","changes","rowsChanged","lastInsertRowid","execute","status","IO","runIo","DONE","stepWithIo","step","get","ROW","row","readRow","all","rows","push","columnCount","columnName","readColumnValue","index","kind","rowValueKind","NULL","INTEGER","rowValueInt","REAL","rowValueDouble","TEXT","rowValueText","BLOB","rowValueBytesPtr","finalize","finalized"],"sourceRoot":"../../src","sources":["Statement.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,SAAS,QAAQ,SAAS;;AAEhD;AACA;AACA;AACA,OAAO,MAAMC,SAAS,CAAC;EAEbC,UAAU,GAAG,KAAK;EAG1BC,WAAWA,CAACC,SAA0B,EAAEC,OAA6B,EAAE;IACrE,IAAI,CAACC,UAAU,GAAGF,SAAS;IAC3B,IAAI,CAACG,QAAQ,GAAGF,OAAO;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEG,IAAIA,CAAC,GAAGC,MAAoB,EAAQ;IAClC,IAAI,IAAI,CAACP,UAAU,EAAE;MACnB,MAAM,IAAIQ,KAAK,CAAC,8BAA8B,CAAC;IACjD;;IAEA;IACA,IAAIC,UAAyB;IAC7B,IAAIF,MAAM,CAACG,MAAM,KAAK,CAAC,IAAIC,KAAK,CAACC,OAAO,CAACL,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;MACnDE,UAAU,GAAGF,MAAM,CAAC,CAAC,CAAC;IACxB,CAAC,MAAM,IAAIA,MAAM,CAACG,MAAM,KAAK,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KAAK,CAAC,IAAI,IAAI5B,WAAW,CAAC,CAAC,CAAC;MAEtE;QACE,MAAM,IAAIvB,KAAK,CAAC,wBAAwBoD,IAAI,EAAE,CAAC;IACnD;EACF;;EAEA;AACF;AACA;AACA;AACA;EACEtB,KAAKA,CAAA,EAAS;IACZ,IAAI,IAAI,CAACtC,UAAU,EAAE;MACnB,MAAM,IAAIQ,KAAK,CAAC,8BAA8B,CAAC;IACjD;IAEA,IAAI,CAACJ,UAAU,CAACkC,KAAK,CAAC,CAAC;IACvB,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,MAAMiC,QAAQA,CAAA,EAAkB;IAC9B,IAAI,IAAI,CAACvE,UAAU,EAAE;MACnB;IACF;IAEA,OAAO,IAAI,EAAE;MACX,MAAM2C,MAAM,GAAG,IAAI,CAACvC,UAAU,CAACmE,QAAQ,CAAC,CAAC;MAEzC,IAAI5B,MAAM,KAAK9C,WAAW,CAAC+C,EAAE,EAAE;QAC7B;QACA,IAAI,CAACxC,UAAU,CAACyC,KAAK,CAAC,CAAC;;QAEvB;QACA,IAAI,IAAI,CAACxC,QAAQ,EAAE;UACjB,MAAM,IAAI,CAACA,QAAQ,CAAC,CAAC;QACvB;QAEA;MACF;MAEA,IAAIsC,MAAM,KAAK9C,WAAW,CAACiD,IAAI,EAAE;QAC/B,MAAM,IAAItC,KAAK,CAAC,8CAA8CmC,MAAM,EAAE,CAAC;MACzE;MACA;IACF;IACA,IAAI,CAAC3C,UAAU,GAAG,IAAI;EACxB;;EAEA;AACF;AACA;EACE,IAAIwE,SAASA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACxE,UAAU;EACxB;AACF","ignoreList":[]}
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Turso React Native SDK
5
+ *
6
+ * Main entry point for the SDK. Supports both local-only and sync databases.
7
+ */
8
+
9
+ import { NativeModules } from 'react-native';
10
+ import { Database } from './Database';
11
+ import { setFileSystemImpl } from './internal/ioProcessor';
12
+
13
+ // Re-export all public types
14
+
15
+ // Re-export classes
16
+ export { Database } from './Database';
17
+ export { Statement } from './Statement';
18
+
19
+ // Export file system configuration function
20
+ export { setFileSystemImpl } from './internal/ioProcessor';
21
+
22
+ // Get the native module
23
+ const TursoNative = NativeModules.Turso;
24
+
25
+ // Check if native module is available
26
+ if (!TursoNative) {
27
+ throw new Error(`@tursodatabase/sync-react-native: Native module not found. Make sure you have properly linked the library.\n` + `- iOS: Run 'pod install' in your ios directory\n` + `- Android: Make sure the package is properly included in your MainApplication.java`);
28
+ }
29
+
30
+ // Install the JSI bindings
31
+ const installed = TursoNative.install();
32
+ if (!installed) {
33
+ throw new Error('@tursodatabase/sync-react-native: Failed to install JSI bindings. Make sure the New Architecture is enabled.');
34
+ }
35
+
36
+ // Get the proxy that was installed on the global object
37
+ // __TursoProxy is declared globally in types.ts
38
+ const TursoProxy = __TursoProxy;
39
+ if (!TursoProxy) {
40
+ throw new Error('@tursodatabase/sync-react-native: JSI bindings not found on global object. This is a bug.');
41
+ }
42
+
43
+ /**
44
+ * Helper function to construct a database path in a writable directory.
45
+ * On mobile platforms, you must use writable directories (not relative paths).
46
+ *
47
+ * @param filename - Database filename (e.g., 'mydb.db')
48
+ * @param directory - Directory to use ('documents', 'database', or 'library')
49
+ * @returns Absolute path to the database file
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { getDbPath, connect } from '@tursodatabase/sync-react-native';
54
+ *
55
+ * const dbPath = getDbPath('mydb.db');
56
+ * const db = await connect({ path: dbPath });
57
+ * ```
58
+ */
59
+ export function getDbPath(filename, directory = 'documents') {
60
+ const basePath = paths[directory];
61
+ if (!basePath || basePath === '.') {
62
+ throw new Error(`Unable to get ${directory} path for this platform. ` + 'Make sure the native module is properly loaded.');
63
+ }
64
+ return `${basePath}/${filename}`;
65
+ }
66
+
67
+ /**
68
+ * Connect to a database asynchronously (matches JavaScript bindings API)
69
+ *
70
+ * This is the main entry point for the SDK, matching the API from
71
+ * @tursodatabase/sync-native and @tursodatabase/database-native.
72
+ *
73
+ * **Path handling**: Relative paths are automatically placed in writable directories:
74
+ * - Android: app's database directory (`/data/data/com.app/databases/`)
75
+ * - iOS: app's documents directory
76
+ *
77
+ * Absolute paths and `:memory:` are used as-is.
78
+ *
79
+ * @param opts - Database options
80
+ * @returns Promise resolving to Database instance
81
+ *
82
+ * @example Local database (relative path)
83
+ * ```ts
84
+ * import { connect } from '@tursodatabase/sync-react-native';
85
+ *
86
+ * // Relative path automatically placed in writable directory
87
+ * const db = await connect({ path: 'local.db' });
88
+ * await db.exec('CREATE TABLE users (id INTEGER, name TEXT)');
89
+ * ```
90
+ *
91
+ * @example Using :memory: for in-memory database
92
+ * ```ts
93
+ * const db = await connect({ path: ':memory:' });
94
+ * ```
95
+ *
96
+ * @example Sync database
97
+ * ```ts
98
+ * const db = await connect({
99
+ * path: 'replica.db',
100
+ * url: 'libsql://mydb.turso.io',
101
+ * authToken: 'token-here',
102
+ * });
103
+ * const users = await db.all('SELECT * FROM users');
104
+ * await db.push();
105
+ * await db.pull();
106
+ * ```
107
+ *
108
+ * @example Using absolute path (advanced)
109
+ * ```ts
110
+ * import { connect, paths } from '@tursodatabase/sync-react-native';
111
+ *
112
+ * const db = await connect({ path: `${paths.documents}/mydb.db` });
113
+ * ```
114
+ */
115
+ export async function connect(opts) {
116
+ const db = new Database(opts);
117
+ await db.connect();
118
+ return db;
119
+ }
120
+
121
+ /**
122
+ * Returns the Turso library version.
123
+ */
124
+ export function version() {
125
+ return TursoProxy.version();
126
+ }
127
+
128
+ /**
129
+ * Configure Turso settings such as logging.
130
+ * Should be called before any database operations.
131
+ *
132
+ * @param options - Configuration options
133
+ * @example
134
+ * ```ts
135
+ * import { setup } from '@tursodatabase/sync-react-native';
136
+ *
137
+ * setup({ logLevel: 'debug' });
138
+ * ```
139
+ */
140
+ export function setup(options) {
141
+ TursoProxy.setup(options);
142
+ }
143
+
144
+ /**
145
+ * Platform-specific writable directory paths.
146
+ * Use these to construct absolute paths for database files.
147
+ *
148
+ * NOTE: With automatic path normalization, you typically don't need this.
149
+ * Just pass relative paths like 'mydb.db' and they'll be placed in the correct directory.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * import { paths, connect } from '@tursodatabase/sync-react-native';
154
+ *
155
+ * // Create database in app's documents/files directory
156
+ * const dbPath = `${paths.documents}/mydb.db`;
157
+ * const db = await connect({ path: dbPath });
158
+ * ```
159
+ */
160
+ export const paths = {
161
+ /**
162
+ * Primary documents/database directory (writable)
163
+ * - iOS: App's Documents directory (absolute path)
164
+ * - Android: App's database directory (absolute path) - preferred for databases
165
+ */
166
+ get documents() {
167
+ return TursoNative?.IOS_DOCUMENT_PATH || TursoNative?.ANDROID_DATABASE_PATH || '.';
168
+ },
169
+ /**
170
+ * Database-specific directory (writable)
171
+ * - iOS: Same as documents
172
+ * - Android: Database directory (absolute path)
173
+ */
174
+ get database() {
175
+ return TursoNative?.IOS_DOCUMENT_PATH || TursoNative?.ANDROID_DATABASE_PATH || '.';
176
+ },
177
+ /**
178
+ * Files directory (writable)
179
+ * - iOS: Same as documents
180
+ * - Android: App's files directory (absolute path)
181
+ */
182
+ get files() {
183
+ return TursoNative?.IOS_DOCUMENT_PATH || TursoNative?.ANDROID_FILES_PATH || '.';
184
+ },
185
+ /**
186
+ * Library directory (iOS only, writable)
187
+ * - iOS: App's Library directory (absolute path)
188
+ * - Android: Same as files
189
+ */
190
+ get library() {
191
+ return TursoNative?.IOS_LIBRARY_PATH || TursoNative?.ANDROID_FILES_PATH || '.';
192
+ }
193
+ };
194
+
195
+ // Default export
196
+ export default {
197
+ connect,
198
+ version,
199
+ setup,
200
+ setFileSystemImpl,
201
+ getDbPath,
202
+ paths,
203
+ Database
204
+ };
205
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Database","setFileSystemImpl","Statement","TursoNative","Turso","Error","installed","install","TursoProxy","__TursoProxy","getDbPath","filename","directory","basePath","paths","connect","opts","db","version","setup","options","documents","IOS_DOCUMENT_PATH","ANDROID_DATABASE_PATH","database","files","ANDROID_FILES_PATH","library","IOS_LIBRARY_PATH"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Async Operation Driver
5
+ *
6
+ * Drives async operations returned by sync SDK-KIT methods.
7
+ * This is where ALL the async logic lives - the C++ layer is just a thin bridge.
8
+ *
9
+ * Key responsibilities:
10
+ * - Call resume() in a loop until DONE
11
+ * - When IO is needed, process all pending IO items
12
+ * - Extract and return the final result
13
+ */
14
+
15
+ import { TursoStatus, SyncOperationResultType } from '../types';
16
+ import { processIoItem } from './ioProcessor';
17
+ /**
18
+ * Drive an async operation to completion
19
+ *
20
+ * @param operation - The native operation to drive
21
+ * @param database - The native sync database (for IO queue access)
22
+ * @param context - IO context with auth and URL information
23
+ * @returns Promise that resolves when operation completes
24
+ */
25
+ export async function driveOperation(operation, database, context) {
26
+ while (true) {
27
+ // Resume the operation
28
+ const status = operation.resume();
29
+
30
+ // Operation completed successfully
31
+ if (status === TursoStatus.DONE) {
32
+ // Extract and return the result based on result type
33
+ const resultKind = operation.resultKind();
34
+ switch (resultKind) {
35
+ case SyncOperationResultType.NONE:
36
+ return undefined;
37
+ case SyncOperationResultType.CONNECTION:
38
+ return operation.extractConnection();
39
+ case SyncOperationResultType.CHANGES:
40
+ return operation.extractChanges();
41
+ case SyncOperationResultType.STATS:
42
+ return operation.extractStats();
43
+ default:
44
+ throw new Error(`Unknown result type: ${resultKind}`);
45
+ }
46
+ }
47
+
48
+ // Operation needs IO
49
+ if (status === TursoStatus.IO) {
50
+ // Process all pending IO items
51
+ await processIoQueue(database, context);
52
+
53
+ // Step callbacks after IO processing
54
+ database.ioStepCallbacks();
55
+
56
+ // Continue resume loop
57
+ continue;
58
+ }
59
+
60
+ // Any other status is an error
61
+ throw new Error(`Unexpected status from operation.resume(): ${status}`);
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Process all pending IO items in the queue
67
+ *
68
+ * @param database - The native sync database
69
+ * @param context - IO context with auth and URL information
70
+ */
71
+ async function processIoQueue(database, context) {
72
+ const promises = [];
73
+
74
+ // Take all available IO items from the queue
75
+ while (true) {
76
+ const ioItem = database.ioTakeItem();
77
+ if (!ioItem) {
78
+ break; // No more items
79
+ }
80
+
81
+ // Process each item (potentially in parallel)
82
+ promises.push(processIoItem(ioItem, context));
83
+ }
84
+
85
+ // Wait for all IO operations to complete
86
+ await Promise.all(promises);
87
+ }
88
+
89
+ /**
90
+ * Helper type for operations that return connections
91
+ */
92
+ export async function driveConnectionOperation(operation, database, context) {
93
+ return driveOperation(operation, database, context);
94
+ }
95
+
96
+ /**
97
+ * Helper type for operations that return changes
98
+ */
99
+ export async function driveChangesOperation(operation, database, context) {
100
+ return driveOperation(operation, database, context);
101
+ }
102
+
103
+ /**
104
+ * Helper type for operations that return stats
105
+ */
106
+ export async function driveStatsOperation(operation, database, context) {
107
+ return driveOperation(operation, database, context);
108
+ }
109
+
110
+ /**
111
+ * Helper type for operations that return void
112
+ */
113
+ export async function driveVoidOperation(operation, database, context) {
114
+ return driveOperation(operation, database, context);
115
+ }
116
+ //# sourceMappingURL=asyncOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TursoStatus","SyncOperationResultType","processIoItem","driveOperation","operation","database","context","status","resume","DONE","resultKind","NONE","undefined","CONNECTION","extractConnection","CHANGES","extractChanges","STATS","extractStats","Error","IO","processIoQueue","ioStepCallbacks","promises","ioItem","ioTakeItem","push","Promise","all","driveConnectionOperation","driveChangesOperation","driveStatsOperation","driveVoidOperation"],"sourceRoot":"../../../src","sources":["internal/asyncOperation.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,uBAAuB,QAAQ,U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