@powersync/capacitor 0.0.0-dev-20250922105508

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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +95 -0
  3. package/android/build.gradle +71 -0
  4. package/android/src/main/AndroidManifest.xml +2 -0
  5. package/android/src/main/cpp/powersync_capacitor_jni.c +58 -0
  6. package/android/src/main/java/com/powersync/capacitor/PowerSync.java +13 -0
  7. package/android/src/main/java/com/powersync/capacitor/PowerSyncPlugin.java +20 -0
  8. package/android/src/main/res/.gitkeep +0 -0
  9. package/dist/docs.json +39 -0
  10. package/dist/esm/PowerSyncDatabase.d.ts +15 -0
  11. package/dist/esm/PowerSyncDatabase.js +70 -0
  12. package/dist/esm/PowerSyncDatabase.js.map +1 -0
  13. package/dist/esm/adapter/CapacitorSQLiteAdapter.d.ts +35 -0
  14. package/dist/esm/adapter/CapacitorSQLiteAdapter.js +234 -0
  15. package/dist/esm/adapter/CapacitorSQLiteAdapter.js.map +1 -0
  16. package/dist/esm/adapter/CapacitorSQLiteOpenFactory.d.ts +6 -0
  17. package/dist/esm/adapter/CapacitorSQLiteOpenFactory.js +10 -0
  18. package/dist/esm/adapter/CapacitorSQLiteOpenFactory.js.map +1 -0
  19. package/dist/esm/index.d.ts +3 -0
  20. package/dist/esm/index.js +4 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/plugin/PowerSyncCore.d.ts +2 -0
  23. package/dist/esm/plugin/PowerSyncCore.js +5 -0
  24. package/dist/esm/plugin/PowerSyncCore.js.map +1 -0
  25. package/dist/esm/plugin/PowerSyncPlugin.d.ts +15 -0
  26. package/dist/esm/plugin/PowerSyncPlugin.js +2 -0
  27. package/dist/esm/plugin/PowerSyncPlugin.js.map +1 -0
  28. package/dist/esm/plugin/web.d.ts +5 -0
  29. package/dist/esm/plugin/web.js +7 -0
  30. package/dist/esm/plugin/web.js.map +1 -0
  31. package/dist/esm/sync/CapacitorSyncImplementation.d.ts +7 -0
  32. package/dist/esm/sync/CapacitorSyncImplementation.js +20 -0
  33. package/dist/esm/sync/CapacitorSyncImplementation.js.map +1 -0
  34. package/dist/plugin.cjs.js +349 -0
  35. package/dist/plugin.cjs.js.map +1 -0
  36. package/dist/plugin.js +349 -0
  37. package/dist/plugin.js.map +1 -0
  38. package/ios/Sources/CPowerSyncCore/PowerSyncCore.c +13 -0
  39. package/ios/Sources/CPowerSyncCore/include/PowerSyncCore.h +6 -0
  40. package/ios/Sources/PowerSyncPlugin/PowerSync.swift +7 -0
  41. package/ios/Sources/PowerSyncPlugin/PowerSyncPlugin.swift +22 -0
  42. package/ios/Tests/PowerSyncPluginTests/PowerSyncPluginTests.swift +15 -0
  43. package/package.json +84 -0
@@ -0,0 +1,349 @@
1
+ 'use strict';
2
+
3
+ var sqlite = require('@capacitor-community/sqlite');
4
+ var web$1 = require('@powersync/web');
5
+ var Lock = require('async-lock');
6
+ var core = require('@capacitor/core');
7
+
8
+ const PowerSyncCore = core.registerPlugin('PowerSync', {
9
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.PowerSyncWeb())
10
+ });
11
+
12
+ /**
13
+ * An implementation of {@link DBAdapter} using the Capacitor Community SQLite [plugin](https://github.com/capacitor-community/sqlite).
14
+ *
15
+ * @experimental
16
+ * @alpha This is currently experimental and may change without a major version bump.
17
+ */
18
+ class CapacitorSQLiteAdapter extends web$1.BaseObserver {
19
+ constructor(options) {
20
+ super();
21
+ this.options = options;
22
+ this._writeConnection = null;
23
+ this._readConnection = null;
24
+ this.lock = new Lock();
25
+ this.initializedPromise = this.init();
26
+ }
27
+ get writeConnection() {
28
+ if (!this._writeConnection) {
29
+ throw new Error('Init not completed yet');
30
+ }
31
+ return this._writeConnection;
32
+ }
33
+ get readConnection() {
34
+ if (!this._readConnection) {
35
+ throw new Error('Init not completed yet');
36
+ }
37
+ return this._readConnection;
38
+ }
39
+ async init() {
40
+ await PowerSyncCore.registerCore();
41
+ const sqlite$1 = new sqlite.SQLiteConnection(sqlite.CapacitorSQLite);
42
+ // It seems like the isConnection and retrieveConnection methods
43
+ // only check a JS side map of connections.
44
+ // On hot reload this JS cache can be cleared, while the connection
45
+ // still exists natively. and `createConnection` will fail if it already exists.
46
+ await sqlite$1.closeConnection(this.options.dbFilename, false).catch(() => { });
47
+ await sqlite$1.closeConnection(this.options.dbFilename, true).catch(() => { });
48
+ // TODO support encryption eventually
49
+ this._writeConnection = await sqlite$1.createConnection(this.options.dbFilename, false, 'no-encryption', 1, false);
50
+ this._readConnection = await sqlite$1.createConnection(this.options.dbFilename, false, 'no-encryption', 1, true);
51
+ // TODO validate WAL mode
52
+ await this._writeConnection.open();
53
+ await this._readConnection.open();
54
+ this.writeConnection.query("SELECT powersync_update_hooks('install')");
55
+ }
56
+ async close() {
57
+ await this.initializedPromise;
58
+ await this.writeConnection.close();
59
+ await this.readConnection.close();
60
+ }
61
+ get name() {
62
+ return this.options.dbFilename;
63
+ }
64
+ generateLockContext(db) {
65
+ const execute = async (query, params = []) => {
66
+ var _a, _b, _c, _d;
67
+ // This driver does not support returning results for execute methods
68
+ if (query.toLowerCase().trim().startsWith('select')) {
69
+ let result = await db.query(query, params);
70
+ let arrayResult = (_a = result.values) !== null && _a !== void 0 ? _a : [];
71
+ return {
72
+ rowsAffected: 0,
73
+ rows: {
74
+ _array: arrayResult,
75
+ length: arrayResult.length,
76
+ item: (idx) => arrayResult[idx]
77
+ }
78
+ };
79
+ }
80
+ else {
81
+ let result = await db.executeSet([{ statement: query, values: params }], false);
82
+ return {
83
+ insertId: (_b = result.changes) === null || _b === void 0 ? void 0 : _b.lastId,
84
+ rowsAffected: (_d = (_c = result.changes) === null || _c === void 0 ? void 0 : _c.changes) !== null && _d !== void 0 ? _d : 0,
85
+ rows: {
86
+ _array: [],
87
+ length: 0,
88
+ item: () => null
89
+ }
90
+ };
91
+ }
92
+ };
93
+ const executeQuery = async (query, params) => {
94
+ var _a;
95
+ let result = await db.query(query, params);
96
+ let arrayResult = (_a = result.values) !== null && _a !== void 0 ? _a : [];
97
+ return {
98
+ rowsAffected: 0,
99
+ rows: {
100
+ _array: arrayResult,
101
+ length: arrayResult.length,
102
+ item: (idx) => arrayResult[idx]
103
+ }
104
+ };
105
+ };
106
+ const getAll = async (query, params) => {
107
+ var _a, _b;
108
+ const result = await executeQuery(query, params);
109
+ return (_b = (_a = result.rows) === null || _a === void 0 ? void 0 : _a._array) !== null && _b !== void 0 ? _b : [];
110
+ };
111
+ const getOptional = async (query, params) => {
112
+ const results = await getAll(query, params);
113
+ return results.length > 0 ? results[0] : null;
114
+ };
115
+ const get = async (query, params) => {
116
+ const result = await getOptional(query, params);
117
+ if (!result) {
118
+ throw new Error(`No results for query: ${query}`);
119
+ }
120
+ return result;
121
+ };
122
+ const executeRaw = async (query, params) => {
123
+ throw new Error('Not supported');
124
+ };
125
+ return {
126
+ getAll,
127
+ getOptional,
128
+ get,
129
+ executeRaw,
130
+ execute
131
+ };
132
+ }
133
+ execute(query, params) {
134
+ return this.writeLock((tx) => tx.execute(query, params));
135
+ }
136
+ executeRaw(query, params) {
137
+ return this.writeLock((tx) => tx.executeRaw(query, params));
138
+ }
139
+ async executeBatch(query, params = []) {
140
+ return this.writeLock(async (tx) => {
141
+ var _a, _b, _c;
142
+ let result = await this.writeConnection.executeSet(params.map((param) => ({
143
+ statement: query,
144
+ values: param
145
+ })));
146
+ return {
147
+ rowsAffected: (_b = (_a = result.changes) === null || _a === void 0 ? void 0 : _a.changes) !== null && _b !== void 0 ? _b : 0,
148
+ insertId: (_c = result.changes) === null || _c === void 0 ? void 0 : _c.lastId
149
+ };
150
+ });
151
+ }
152
+ readLock(fn, options) {
153
+ return this.lock.acquire('read_lock', async () => {
154
+ await this.initializedPromise;
155
+ return await fn(this.generateLockContext(this.readConnection));
156
+ });
157
+ }
158
+ readTransaction(fn, options) {
159
+ return this.readLock(async (ctx) => {
160
+ return this.internalTransaction(ctx, fn);
161
+ });
162
+ }
163
+ writeLock(fn, options) {
164
+ return this.lock.acquire('write_lock', async () => {
165
+ var _a;
166
+ await this.initializedPromise;
167
+ const result = await fn(this.generateLockContext(this.writeConnection));
168
+ // Fetch table updates
169
+ const updates = await this.writeConnection.query("SELECT powersync_update_hooks('get') AS table_name");
170
+ const jsonUpdates = (_a = updates.values) === null || _a === void 0 ? void 0 : _a[0];
171
+ if (!jsonUpdates || !jsonUpdates.table_name) {
172
+ throw new Error('Could not fetch table updates');
173
+ }
174
+ const notification = {
175
+ rawUpdates: [],
176
+ tables: JSON.parse(jsonUpdates.table_name),
177
+ groupedUpdates: {}
178
+ };
179
+ this.iterateListeners((l) => { var _a; return (_a = l.tablesUpdated) === null || _a === void 0 ? void 0 : _a.call(l, notification); });
180
+ return result;
181
+ });
182
+ }
183
+ writeTransaction(fn, options) {
184
+ return this.writeLock(async (ctx) => {
185
+ return this.internalTransaction(ctx, fn);
186
+ });
187
+ }
188
+ refreshSchema() {
189
+ return this.writeLock(async (writeTx) => {
190
+ return this.readLock(async (readTx) => {
191
+ const updateQuery = `PRAGMA table_info('sqlite_master')`;
192
+ await writeTx.get(updateQuery);
193
+ await readTx.get(updateQuery);
194
+ });
195
+ });
196
+ }
197
+ getAll(sql, parameters) {
198
+ return this.readLock((tx) => tx.getAll(sql, parameters));
199
+ }
200
+ getOptional(sql, parameters) {
201
+ return this.readLock((tx) => tx.getOptional(sql, parameters));
202
+ }
203
+ get(sql, parameters) {
204
+ return this.readLock((tx) => tx.get(sql, parameters));
205
+ }
206
+ async internalTransaction(ctx, fn) {
207
+ let finalized = false;
208
+ const commit = async () => {
209
+ if (finalized) {
210
+ return { rowsAffected: 0 };
211
+ }
212
+ finalized = true;
213
+ return ctx.execute('COMMIT');
214
+ };
215
+ const rollback = async () => {
216
+ if (finalized) {
217
+ return { rowsAffected: 0 };
218
+ }
219
+ finalized = true;
220
+ return ctx.execute('ROLLBACK');
221
+ };
222
+ try {
223
+ await ctx.execute('BEGIN');
224
+ const result = await fn(Object.assign(Object.assign({}, ctx), { commit,
225
+ rollback }));
226
+ await commit();
227
+ return result;
228
+ }
229
+ catch (ex) {
230
+ try {
231
+ await rollback();
232
+ }
233
+ catch (ex2) {
234
+ // In rare cases, a rollback may fail.
235
+ // Safe to ignore.
236
+ }
237
+ throw ex;
238
+ }
239
+ }
240
+ }
241
+
242
+ class CapacitorSQLiteOpenFactory {
243
+ constructor(options) {
244
+ this.options = options;
245
+ }
246
+ openDB() {
247
+ return new CapacitorSQLiteAdapter(this.options);
248
+ }
249
+ }
250
+
251
+ class CapacitorStreamingSyncImplementation extends web$1.AbstractStreamingSyncImplementation {
252
+ constructor(options) {
253
+ // Super will store and provide default values for options
254
+ super(options);
255
+ this.lock = new Lock();
256
+ }
257
+ async obtainLock(lockOptions) {
258
+ const identifier = `streaming-sync-${lockOptions.type}-${this.options.identifier}`;
259
+ return this.lock.acquire(identifier, async () => {
260
+ var _a;
261
+ if ((_a = lockOptions.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
262
+ throw new Error('Aborted');
263
+ }
264
+ return await lockOptions.callback();
265
+ });
266
+ }
267
+ }
268
+
269
+ /**
270
+ * PowerSyncDatabase class for managing database connections and sync implementations.
271
+ * This extends the WebPowerSyncDatabase to provide platform-specific implementations
272
+ * for Capacitor environments (iOS and Android).
273
+ *
274
+ * @experimental
275
+ * @alpha
276
+ */
277
+ class PowerSyncDatabase extends web$1.PowerSyncDatabase {
278
+ get isNativeCapacitorPlatform() {
279
+ const platform = core.Capacitor.getPlatform();
280
+ return platform == 'ios' || platform == 'android';
281
+ }
282
+ openDBAdapter(options) {
283
+ var _a, _b, _c;
284
+ const platform = core.Capacitor.getPlatform();
285
+ if (platform == 'ios' || platform == 'android') {
286
+ if (options.database.dbLocation) {
287
+ (_a = options.logger) === null || _a === void 0 ? void 0 : _a.warn(`
288
+ dbLocation is ignored on iOS and Android platforms.
289
+ The database directory can be configured in the Capacitor project.
290
+ See https://github.com/capacitor-community/sqlite?tab=readme-ov-file#installation`);
291
+ }
292
+ (_b = options.logger) === null || _b === void 0 ? void 0 : _b.debug(`Using CapacitorSQLiteAdapter for platform: ${platform}`);
293
+ return new CapacitorSQLiteAdapter({
294
+ dbFilename: options.database.dbFilename
295
+ });
296
+ }
297
+ else {
298
+ (_c = options.logger) === null || _c === void 0 ? void 0 : _c.debug(`Using default web adapter for web platform`);
299
+ return super.openDBAdapter(options);
300
+ }
301
+ }
302
+ runExclusive(cb) {
303
+ if (this.isNativeCapacitorPlatform) {
304
+ // Use mutex for mobile platforms.
305
+ // This is mainly for testing purposes since navigator.locks require secure contexts.
306
+ return this.runExclusiveMutex.runExclusive(cb);
307
+ }
308
+ else {
309
+ // Use navigator.locks for web platform
310
+ return super.runExclusive(cb);
311
+ }
312
+ }
313
+ generateSyncStreamImplementation(connector, options) {
314
+ var _a;
315
+ if (this.isNativeCapacitorPlatform) {
316
+ // We don't want to support multi-tab on mobile platforms.
317
+ // We technically can, but it's not a common use case and requires additional work/testing.
318
+ this.logger.debug(`Using Capacitor sync implementation`);
319
+ if ((_a = this.options.flags) === null || _a === void 0 ? void 0 : _a.enableMultiTabs) {
320
+ this.logger.warn(`enableMultiTabs is not supported on Capacitor mobile platforms. Ignoring the flag.`);
321
+ }
322
+ const remote = new web$1.WebRemote(connector, this.logger);
323
+ return new CapacitorStreamingSyncImplementation(Object.assign(Object.assign({}, this.options), { retryDelayMs: options.retryDelayMs, crudUploadThrottleMs: options.crudUploadThrottleMs, adapter: this.bucketStorageAdapter, remote, uploadCrud: async () => {
324
+ await this.waitForReady();
325
+ await connector.uploadData(this);
326
+ }, identifier: this.database.name, logger: this.logger, subscriptions: options.subscriptions }));
327
+ }
328
+ else {
329
+ this.logger.debug(`Using default web sync implementation for web platform`);
330
+ return super.generateSyncStreamImplementation(connector, options);
331
+ }
332
+ }
333
+ }
334
+
335
+ class PowerSyncWeb extends core.WebPlugin {
336
+ async registerCore() {
337
+ throw new Error('This code path is not supported on web.');
338
+ }
339
+ }
340
+
341
+ var web = /*#__PURE__*/Object.freeze({
342
+ __proto__: null,
343
+ PowerSyncWeb: PowerSyncWeb
344
+ });
345
+
346
+ exports.CapacitorSQLiteAdapter = CapacitorSQLiteAdapter;
347
+ exports.CapacitorSQLiteOpenFactory = CapacitorSQLiteOpenFactory;
348
+ exports.PowerSyncDatabase = PowerSyncDatabase;
349
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/plugin/PowerSyncCore.js","esm/adapter/CapacitorSQLiteAdapter.js","esm/adapter/CapacitorSQLiteOpenFactory.js","esm/sync/CapacitorSyncImplementation.js","esm/PowerSyncDatabase.js","esm/plugin/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nexport const PowerSyncCore = registerPlugin('PowerSync', {\n web: () => import('./web').then((m) => new m.PowerSyncWeb())\n});\n//# sourceMappingURL=PowerSyncCore.js.map","import { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';\nimport { BaseObserver } from '@powersync/web';\nimport Lock from 'async-lock';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore';\n/**\n * An implementation of {@link DBAdapter} using the Capacitor Community SQLite [plugin](https://github.com/capacitor-community/sqlite).\n *\n * @experimental\n * @alpha This is currently experimental and may change without a major version bump.\n */\nexport class CapacitorSQLiteAdapter extends BaseObserver {\n constructor(options) {\n super();\n this.options = options;\n this._writeConnection = null;\n this._readConnection = null;\n this.lock = new Lock();\n this.initializedPromise = this.init();\n }\n get writeConnection() {\n if (!this._writeConnection) {\n throw new Error('Init not completed yet');\n }\n return this._writeConnection;\n }\n get readConnection() {\n if (!this._readConnection) {\n throw new Error('Init not completed yet');\n }\n return this._readConnection;\n }\n async init() {\n await PowerSyncCore.registerCore();\n const sqlite = new SQLiteConnection(CapacitorSQLite);\n // It seems like the isConnection and retrieveConnection methods\n // only check a JS side map of connections.\n // On hot reload this JS cache can be cleared, while the connection\n // still exists natively. and `createConnection` will fail if it already exists.\n await sqlite.closeConnection(this.options.dbFilename, false).catch(() => { });\n await sqlite.closeConnection(this.options.dbFilename, true).catch(() => { });\n // TODO support encryption eventually\n this._writeConnection = await sqlite.createConnection(this.options.dbFilename, false, 'no-encryption', 1, false);\n this._readConnection = await sqlite.createConnection(this.options.dbFilename, false, 'no-encryption', 1, true);\n // TODO validate WAL mode\n await this._writeConnection.open();\n await this._readConnection.open();\n this.writeConnection.query(\"SELECT powersync_update_hooks('install')\");\n }\n async close() {\n await this.initializedPromise;\n await this.writeConnection.close();\n await this.readConnection.close();\n }\n get name() {\n return this.options.dbFilename;\n }\n generateLockContext(db) {\n const execute = async (query, params = []) => {\n var _a, _b, _c, _d;\n // This driver does not support returning results for execute methods\n if (query.toLowerCase().trim().startsWith('select')) {\n let result = await db.query(query, params);\n let arrayResult = (_a = result.values) !== null && _a !== void 0 ? _a : [];\n return {\n rowsAffected: 0,\n rows: {\n _array: arrayResult,\n length: arrayResult.length,\n item: (idx) => arrayResult[idx]\n }\n };\n }\n else {\n let result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: (_b = result.changes) === null || _b === void 0 ? void 0 : _b.lastId,\n rowsAffected: (_d = (_c = result.changes) === null || _c === void 0 ? void 0 : _c.changes) !== null && _d !== void 0 ? _d : 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\n };\n }\n };\n const executeQuery = async (query, params) => {\n var _a;\n let result = await db.query(query, params);\n let arrayResult = (_a = result.values) !== null && _a !== void 0 ? _a : [];\n return {\n rowsAffected: 0,\n rows: {\n _array: arrayResult,\n length: arrayResult.length,\n item: (idx) => arrayResult[idx]\n }\n };\n };\n const getAll = async (query, params) => {\n var _a, _b;\n const result = await executeQuery(query, params);\n return (_b = (_a = result.rows) === null || _a === void 0 ? void 0 : _a._array) !== null && _b !== void 0 ? _b : [];\n };\n const getOptional = async (query, params) => {\n const results = await getAll(query, params);\n return results.length > 0 ? results[0] : null;\n };\n const get = async (query, params) => {\n const result = await getOptional(query, params);\n if (!result) {\n throw new Error(`No results for query: ${query}`);\n }\n return result;\n };\n const executeRaw = async (query, params) => {\n throw new Error('Not supported');\n };\n return {\n getAll,\n getOptional,\n get,\n executeRaw,\n execute\n };\n }\n execute(query, params) {\n return this.writeLock((tx) => tx.execute(query, params));\n }\n executeRaw(query, params) {\n return this.writeLock((tx) => tx.executeRaw(query, params));\n }\n async executeBatch(query, params = []) {\n return this.writeLock(async (tx) => {\n var _a, _b, _c;\n let result = await this.writeConnection.executeSet(params.map((param) => ({\n statement: query,\n values: param\n })));\n return {\n rowsAffected: (_b = (_a = result.changes) === null || _a === void 0 ? void 0 : _a.changes) !== null && _b !== void 0 ? _b : 0,\n insertId: (_c = result.changes) === null || _c === void 0 ? void 0 : _c.lastId\n };\n });\n }\n readLock(fn, options) {\n return this.lock.acquire('read_lock', async () => {\n await this.initializedPromise;\n return await fn(this.generateLockContext(this.readConnection));\n });\n }\n readTransaction(fn, options) {\n return this.readLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n writeLock(fn, options) {\n return this.lock.acquire('write_lock', async () => {\n var _a;\n await this.initializedPromise;\n const result = await fn(this.generateLockContext(this.writeConnection));\n // Fetch table updates\n const updates = await this.writeConnection.query(\"SELECT powersync_update_hooks('get') AS table_name\");\n const jsonUpdates = (_a = updates.values) === null || _a === void 0 ? void 0 : _a[0];\n if (!jsonUpdates || !jsonUpdates.table_name) {\n throw new Error('Could not fetch table updates');\n }\n const notification = {\n rawUpdates: [],\n tables: JSON.parse(jsonUpdates.table_name),\n groupedUpdates: {}\n };\n this.iterateListeners((l) => { var _a; return (_a = l.tablesUpdated) === null || _a === void 0 ? void 0 : _a.call(l, notification); });\n return result;\n });\n }\n writeTransaction(fn, options) {\n return this.writeLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n refreshSchema() {\n return this.writeLock(async (writeTx) => {\n return this.readLock(async (readTx) => {\n const updateQuery = `PRAGMA table_info('sqlite_master')`;\n await writeTx.get(updateQuery);\n await readTx.get(updateQuery);\n });\n });\n }\n getAll(sql, parameters) {\n return this.readLock((tx) => tx.getAll(sql, parameters));\n }\n getOptional(sql, parameters) {\n return this.readLock((tx) => tx.getOptional(sql, parameters));\n }\n get(sql, parameters) {\n return this.readLock((tx) => tx.get(sql, parameters));\n }\n async internalTransaction(ctx, fn) {\n let finalized = false;\n const commit = async () => {\n if (finalized) {\n return { rowsAffected: 0 };\n }\n finalized = true;\n return ctx.execute('COMMIT');\n };\n const rollback = async () => {\n if (finalized) {\n return { rowsAffected: 0 };\n }\n finalized = true;\n return ctx.execute('ROLLBACK');\n };\n try {\n await ctx.execute('BEGIN');\n const result = await fn(Object.assign(Object.assign({}, ctx), { commit,\n rollback }));\n await commit();\n return result;\n }\n catch (ex) {\n try {\n await rollback();\n }\n catch (ex2) {\n // In rare cases, a rollback may fail.\n // Safe to ignore.\n }\n throw ex;\n }\n }\n}\n//# sourceMappingURL=CapacitorSQLiteAdapter.js.map","import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter';\nexport class CapacitorSQLiteOpenFactory {\n constructor(options) {\n this.options = options;\n }\n openDB() {\n return new CapacitorSQLiteAdapter(this.options);\n }\n}\n//# sourceMappingURL=CapacitorSQLiteOpenFactory.js.map","import { AbstractStreamingSyncImplementation } from '@powersync/web';\nimport Lock from 'async-lock';\nexport class CapacitorStreamingSyncImplementation extends AbstractStreamingSyncImplementation {\n constructor(options) {\n // Super will store and provide default values for options\n super(options);\n this.lock = new Lock();\n }\n async obtainLock(lockOptions) {\n const identifier = `streaming-sync-${lockOptions.type}-${this.options.identifier}`;\n return this.lock.acquire(identifier, async () => {\n var _a;\n if ((_a = lockOptions.signal) === null || _a === void 0 ? void 0 : _a.aborted) {\n throw new Error('Aborted');\n }\n return await lockOptions.callback();\n });\n }\n}\n//# sourceMappingURL=CapacitorSyncImplementation.js.map","import { Capacitor } from '@capacitor/core';\nimport { PowerSyncDatabase as WebPowerSyncDatabase, WebRemote } from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';\nimport { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation';\n/**\n * PowerSyncDatabase class for managing database connections and sync implementations.\n * This extends the WebPowerSyncDatabase to provide platform-specific implementations\n * for Capacitor environments (iOS and Android).\n *\n * @experimental\n * @alpha\n */\nexport class PowerSyncDatabase extends WebPowerSyncDatabase {\n get isNativeCapacitorPlatform() {\n const platform = Capacitor.getPlatform();\n return platform == 'ios' || platform == 'android';\n }\n openDBAdapter(options) {\n var _a, _b, _c;\n const platform = Capacitor.getPlatform();\n if (platform == 'ios' || platform == 'android') {\n if (options.database.dbLocation) {\n (_a = options.logger) === null || _a === void 0 ? void 0 : _a.warn(`\n dbLocation is ignored on iOS and Android platforms. \n The database directory can be configured in the Capacitor project.\n See https://github.com/capacitor-community/sqlite?tab=readme-ov-file#installation`);\n }\n (_b = options.logger) === null || _b === void 0 ? void 0 : _b.debug(`Using CapacitorSQLiteAdapter for platform: ${platform}`);\n return new CapacitorSQLiteAdapter({\n dbFilename: options.database.dbFilename\n });\n }\n else {\n (_c = options.logger) === null || _c === void 0 ? void 0 : _c.debug(`Using default web adapter for web platform`);\n return super.openDBAdapter(options);\n }\n }\n runExclusive(cb) {\n if (this.isNativeCapacitorPlatform) {\n // Use mutex for mobile platforms.\n // This is mainly for testing purposes since navigator.locks require secure contexts.\n return this.runExclusiveMutex.runExclusive(cb);\n }\n else {\n // Use navigator.locks for web platform\n return super.runExclusive(cb);\n }\n }\n generateSyncStreamImplementation(connector, options) {\n var _a;\n if (this.isNativeCapacitorPlatform) {\n // We don't want to support multi-tab on mobile platforms.\n // We technically can, but it's not a common use case and requires additional work/testing.\n this.logger.debug(`Using Capacitor sync implementation`);\n if ((_a = this.options.flags) === null || _a === void 0 ? void 0 : _a.enableMultiTabs) {\n this.logger.warn(`enableMultiTabs is not supported on Capacitor mobile platforms. Ignoring the flag.`);\n }\n const remote = new WebRemote(connector, this.logger);\n return new CapacitorStreamingSyncImplementation(Object.assign(Object.assign({}, this.options), { retryDelayMs: options.retryDelayMs, crudUploadThrottleMs: options.crudUploadThrottleMs, adapter: this.bucketStorageAdapter, remote, uploadCrud: async () => {\n await this.waitForReady();\n await connector.uploadData(this);\n }, identifier: this.database.name, logger: this.logger, subscriptions: options.subscriptions }));\n }\n else {\n this.logger.debug(`Using default web sync implementation for web platform`);\n return super.generateSyncStreamImplementation(connector, options);\n }\n }\n}\n//# sourceMappingURL=PowerSyncDatabase.js.map","import { WebPlugin } from '@capacitor/core';\nexport class PowerSyncWeb extends WebPlugin {\n async registerCore() {\n throw new Error('This code path is not supported on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","BaseObserver","sqlite","SQLiteConnection","CapacitorSQLite","AbstractStreamingSyncImplementation","WebPowerSyncDatabase","Capacitor","WebRemote","WebPlugin"],"mappings":";;;;;;;AACO,MAAM,aAAa,GAAGA,mBAAc,CAAC,WAAW,EAAE;AACzD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,YAAY,EAAE;AAC/D,CAAC,CAAC;;ACCF;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,sBAAsB,SAASC,kBAAY,CAAC;AACzD,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,KAAK,EAAE;AACf,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO;AAC9B,QAAQ,IAAI,CAAC,gBAAgB,GAAG,IAAI;AACpC,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI;AACnC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE;AAC9B,QAAQ,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,IAAI,EAAE;AAC7C;AACA,IAAI,IAAI,eAAe,GAAG;AAC1B,QAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACpC,YAAY,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC;AACrD;AACA,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