@powersync/capacitor 0.2.0 → 0.4.0

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 (33) hide show
  1. package/dist/esm/PowerSyncDatabase.d.ts +2 -1
  2. package/dist/esm/PowerSyncDatabase.js +14 -3
  3. package/dist/esm/PowerSyncDatabase.js.map +1 -1
  4. package/dist/esm/adapter/CapacitorSQLiteAdapter.d.ts +4 -3
  5. package/dist/esm/adapter/CapacitorSQLiteAdapter.js +11 -10
  6. package/dist/esm/adapter/CapacitorSQLiteAdapter.js.map +1 -1
  7. package/dist/esm/adapter/CapacitorSQLiteOpenFactory.js +1 -1
  8. package/dist/esm/adapter/CapacitorSQLiteOpenFactory.js.map +1 -1
  9. package/dist/esm/index.d.ts +3 -3
  10. package/dist/esm/index.js +3 -3
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/plugin/PowerSyncCore.d.ts +1 -1
  13. package/dist/esm/plugin/PowerSyncCore.js +1 -1
  14. package/dist/esm/plugin/PowerSyncCore.js.map +1 -1
  15. package/dist/esm/plugin/web.d.ts +1 -1
  16. package/dist/esm/plugin/web.js.map +1 -1
  17. package/dist/esm/sync/CapacitorSyncImplementation.d.ts +2 -2
  18. package/dist/esm/sync/CapacitorSyncImplementation.js +41 -5
  19. package/dist/esm/sync/CapacitorSyncImplementation.js.map +1 -1
  20. package/dist/{plugin.cjs.js → plugin.cjs} +58 -10
  21. package/dist/plugin.cjs.map +1 -0
  22. package/dist/plugin.d.cts +88 -0
  23. package/dist/plugin.js +58 -10
  24. package/dist/plugin.js.map +1 -1
  25. package/package.json +22 -8
  26. package/src/PowerSyncDatabase.ts +16 -2
  27. package/src/adapter/CapacitorSQLiteAdapter.ts +39 -28
  28. package/src/adapter/CapacitorSQLiteOpenFactory.ts +1 -1
  29. package/src/index.ts +4 -3
  30. package/src/plugin/PowerSyncCore.ts +2 -2
  31. package/src/plugin/web.ts +1 -1
  32. package/src/sync/CapacitorSyncImplementation.ts +55 -5
  33. package/dist/plugin.cjs.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","sources":["esm/plugin/PowerSyncCore.js","esm/plugin/PowerSyncPlugin.js","esm/adapter/CapacitorSQLiteOpenFactory.js","esm/adapter/CapacitorSQLiteAdapter.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.js').then((m) => new m.PowerSyncWeb())\n});\n//# sourceMappingURL=PowerSyncCore.js.map","export const messageForErrorCode = (code) => {\n switch (code) {\n case 0:\n return 'Success';\n default:\n return `Extension registration failed with SQLite error code: ${code}`;\n }\n};\n//# sourceMappingURL=PowerSyncPlugin.js.map","import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter.js';\nvar SqliteSynchronous;\n(function (SqliteSynchronous) {\n SqliteSynchronous[\"normal\"] = \"NORMAL\";\n SqliteSynchronous[\"full\"] = \"FULL\";\n SqliteSynchronous[\"off\"] = \"OFF\";\n})(SqliteSynchronous || (SqliteSynchronous = {}));\nexport const DEFAULT_SQLITE_OPTIONS = {\n journalSizeLimit: 6 * 1024 * 1024,\n synchronous: SqliteSynchronous.normal,\n cacheSizeKb: 50 * 1024\n};\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 { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\nimport { BaseObserver, mutexRunExclusive } from '@powersync/web';\nimport { Mutex } from 'async-mutex';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore.js';\nimport { messageForErrorCode } from '../plugin/PowerSyncPlugin.js';\nimport { DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory.js';\n/**\n * Monitors the execution time of a query and logs it to the performance timeline.\n */\nasync function monitorQuery(sql, executor) {\n const start = performance.now();\n try {\n const r = await executor();\n performance.measure(`[SQL] ${sql}`, { start });\n return r;\n }\n catch (e) {\n performance.measure(`[SQL] [ERROR: ${e.message}] ${sql}`, { start });\n throw e;\n }\n}\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.writeMutex = new Mutex();\n this.readMutex = new Mutex();\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 get name() {\n return this.options.dbFilename;\n }\n async init() {\n const { responseCode: registrationResponseCode } = await PowerSyncCore.registerCore();\n if (registrationResponseCode != 0) {\n throw new Error(`Could not register PowerSync core extension: ${messageForErrorCode(registrationResponseCode)}`);\n }\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 await this._writeConnection.open();\n const { cacheSizeKb, journalSizeLimit, synchronous } = Object.assign(Object.assign({}, DEFAULT_SQLITE_OPTIONS), this.options.sqliteOptions);\n await this.writeConnection.query('PRAGMA journal_mode = WAL');\n await this.writeConnection.query(`PRAGMA journal_size_limit = ${journalSizeLimit}`);\n await this.writeConnection.query(`PRAGMA temp_store = memory`);\n await this.writeConnection.query(`PRAGMA synchronous = ${synchronous}`);\n await this.writeConnection.query(`PRAGMA cache_size = -${cacheSizeKb}`);\n await this._readConnection.open();\n const platform = Capacitor.getPlatform();\n if (platform == 'android') {\n /**\n * SQLCipher for Android enables dynamic loading of extensions.\n * On iOS we use a static auto extension registration.\n */\n const extensionQuery = \"SELECT load_extension('libpowersync.so', 'sqlite3_powersync_init')\";\n await this.writeConnection.query(extensionQuery);\n await this.readConnection.query(extensionQuery);\n }\n await 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 generateLockContext(db) {\n const _query = async (query, params = []) => {\n var _a;\n const result = await db.query(query, params);\n const 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 _execute = async (query, params = []) => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n const platform = Capacitor.getPlatform();\n if (db.getConnectionReadOnly()) {\n return _query(query, params);\n }\n if (platform == 'android') {\n // Android: use query for SELECT and executeSet for mutations\n // We cannot use `run` here for both cases.\n if (query.toLowerCase().trim().startsWith('select')) {\n return _query(query, params);\n }\n else {\n const result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: (_a = result.changes) === null || _a === void 0 ? void 0 : _a.lastId,\n rowsAffected: (_c = (_b = result.changes) === null || _b === void 0 ? void 0 : _b.changes) !== null && _c !== void 0 ? _c : 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\n };\n }\n }\n // iOS (and other platforms): use run(\"all\")\n const result = await db.run(query, params, false, 'all');\n const resultSet = (_e = (_d = result.changes) === null || _d === void 0 ? void 0 : _d.values) !== null && _e !== void 0 ? _e : [];\n return {\n insertId: (_f = result.changes) === null || _f === void 0 ? void 0 : _f.lastId,\n rowsAffected: (_h = (_g = result.changes) === null || _g === void 0 ? void 0 : _g.changes) !== null && _h !== void 0 ? _h : 0,\n rows: {\n _array: resultSet,\n length: resultSet.length,\n item: (idx) => resultSet[idx]\n }\n };\n };\n const execute = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _execute(sql, params))\n : _execute;\n const executeQuery = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _query(sql, params))\n : _query;\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 var _a, _b;\n // This is a workaround, we don't support multiple columns of the same name\n const results = await execute(query, params);\n return (_b = (_a = results.rows) === null || _a === void 0 ? void 0 : _a._array.map((row) => Object.values(row))) !== null && _b !== void 0 ? _b : [];\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 mutexRunExclusive(this.readMutex, async () => {\n await this.initializedPromise;\n return await fn(this.generateLockContext(this.readConnection));\n }, options);\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 mutexRunExclusive(this.writeMutex, 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 }, options);\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 { AbstractStreamingSyncImplementation, LockType, mutexRunExclusive } from '@powersync/web';\nimport { Mutex } from 'async-mutex';\nconst GLOBAL_MUTEX_STORE = new Map();\n/**\n * Used to identify multiple instances of CapacitorStreamingSyncImplementation\n */\nlet _CAPACITOR_STREAMING_SYNC_SEQUENCE = 0;\nexport class CapacitorStreamingSyncImplementation extends AbstractStreamingSyncImplementation {\n constructor() {\n super(...arguments);\n // A unique ID for tacking this specific instance of CapacitorStreamingSyncImplementation\n this.instanceId = _CAPACITOR_STREAMING_SYNC_SEQUENCE++;\n }\n async dispose() {\n await super.dispose();\n // Clear up any global mutexes which aren't used anymore\n for (const mutexEntry of GLOBAL_MUTEX_STORE.entries()) {\n const [identifier, mutex] = mutexEntry;\n if (!mutex.tracking.has(this.instanceId)) {\n continue;\n }\n mutex.tracking.delete(this.instanceId);\n if (mutex.tracking.size == 0) {\n GLOBAL_MUTEX_STORE.delete(identifier);\n }\n }\n }\n async obtainLock(lockOptions) {\n // If we don't have an identifier for some reason (should not happen), we use a shared Mutex\n const { identifier: baseIdentifier = 'DEFAULT' } = this.options;\n if (!GLOBAL_MUTEX_STORE.has(baseIdentifier)) {\n GLOBAL_MUTEX_STORE.set(baseIdentifier, {\n tracking: new Set([this.instanceId]),\n locks: {\n [LockType.CRUD]: new Mutex(),\n [LockType.SYNC]: new Mutex()\n }\n });\n }\n const mutexRecord = GLOBAL_MUTEX_STORE.get(baseIdentifier);\n mutexRecord.tracking.add(this.instanceId);\n const mutex = mutexRecord.locks[lockOptions.type];\n return mutexRunExclusive(mutex, 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 { MEMORY_TRIGGER_CLAIM_MANAGER, PowerSyncDatabase as WebPowerSyncDatabase, WebRemote } from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';\nimport { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation.js';\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(Object.assign({}, options.database));\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 generateTriggerManagerConfig() {\n const config = super.generateTriggerManagerConfig();\n if (this.isNativeCapacitorPlatform) {\n /**\n * We usually only ever have a single tab for capacitor.\n * Avoiding navigator locks allows insecure contexts (during development).\n */\n config.claimManager = MEMORY_TRIGGER_CLAIM_MANAGER;\n }\n return config;\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","Mutex","sqlite","SQLiteConnection","CapacitorSQLite","Capacitor","mutexRunExclusive","AbstractStreamingSyncImplementation","LockType","WebPowerSyncDatabase","MEMORY_TRIGGER_CLAIM_MANAGER","WebRemote","WebPlugin"],"mappings":";;;;;;;AACO,MAAM,aAAa,GAAGA,mBAAc,CAAC,WAAW,EAAE;AACzD,IAAI,GAAG,EAAE,MAAM,mDAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,YAAY,EAAE;AAClE,CAAC,CAAC;;ACHK,MAAM,mBAAmB,GAAG,CAAC,IAAI,KAAK;AAC7C,IAAI,QAAQ,IAAI;AAChB,QAAQ,KAAK,CAAC;AACd,YAAY,OAAO,SAAS;AAC5B,QAAQ;AACR,YAAY,OAAO,CAAC,sDAAsD,EAAE,IAAI,CAAC,CAAC;AAClF;AACA,CAAC;;ACND,IAAI,iBAAiB;AACrB,CAAC,UAAU,iB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CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,EAAE,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY;AACzQ,oBAAoB,MAAM,IAAI,CAAC,YAAY,EAAE;AAC7C,oBAAoB,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;AACpD,gBAAgB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;AAChH,QAAQ;AACR,aAAa;AACb,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,sDAAsD,CAAC,CAAC;AACvF,YAAY,OAAO,KAAK,CAAC,gCAAgC,CAAC,SAAS,EAAE,OAAO,CAAC;AAC7E,QAAQ;AACR,IAAI;AACJ;;AC5EO,MAAM,YAAY,SAASC,cAAS,CAAC;AAC5C,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;AAClE,IAAI;AACJ;;;;;;;;;;;"}
@@ -0,0 +1,88 @@
1
+ import { SQLiteDBConnection } from '@capacitor-community/sqlite';
2
+ import { SQLOpenOptions, SQLOpenFactory, DBAdapter, BaseObserver, DBAdapterListener, LockContext, QueryResult, DBLockOptions, Transaction, PowerSyncDatabase as PowerSyncDatabase$1, WebPowerSyncDatabaseOptionsWithSettings, TriggerManagerConfig, PowerSyncBackendConnector, RequiredAdditionalConnectionOptions, StreamingSyncImplementation } from '@powersync/web';
3
+ import { Mutex } from 'async-mutex';
4
+
5
+ declare enum SqliteSynchronous {
6
+ normal = "NORMAL",
7
+ full = "FULL",
8
+ off = "OFF"
9
+ }
10
+ interface CapacitorSQLiteOptions {
11
+ /**
12
+ * Journal/WAL size limit. Defaults to 6MB.
13
+ * The WAL may grow larger than this limit during writes, but SQLite will
14
+ * attempt to truncate the file afterwards.
15
+ */
16
+ journalSizeLimit?: number;
17
+ /**
18
+ * SQLite synchronous flag. Defaults to [SqliteSynchronous.normal], which
19
+ * is safe for WAL mode.
20
+ */
21
+ synchronous?: SqliteSynchronous;
22
+ /**
23
+ * Maximum SQLite cache size. Defaults to 50MB.
24
+ *
25
+ * For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size
26
+ */
27
+ cacheSizeKb?: number;
28
+ }
29
+ interface CapacitorSQLiteOpenFactoryOptions extends SQLOpenOptions {
30
+ sqliteOptions?: CapacitorSQLiteOptions;
31
+ }
32
+ declare class CapacitorSQLiteOpenFactory implements SQLOpenFactory {
33
+ protected options: CapacitorSQLiteOpenFactoryOptions;
34
+ constructor(options: CapacitorSQLiteOpenFactoryOptions);
35
+ openDB(): DBAdapter;
36
+ }
37
+
38
+ /**
39
+ * An implementation of {@link DBAdapter} using the Capacitor Community SQLite [plugin](https://github.com/capacitor-community/sqlite).
40
+ *
41
+ * @experimental
42
+ * @alpha This is currently experimental and may change without a major version bump.
43
+ */
44
+ declare class CapacitorSQLiteAdapter extends BaseObserver<DBAdapterListener> implements DBAdapter {
45
+ protected options: CapacitorSQLiteOpenFactoryOptions;
46
+ protected _writeConnection: SQLiteDBConnection | null;
47
+ protected _readConnection: SQLiteDBConnection | null;
48
+ protected initializedPromise: Promise<void>;
49
+ protected writeMutex: Mutex;
50
+ protected readMutex: Mutex;
51
+ constructor(options: CapacitorSQLiteOpenFactoryOptions);
52
+ protected get writeConnection(): SQLiteDBConnection;
53
+ protected get readConnection(): SQLiteDBConnection;
54
+ get name(): string;
55
+ private init;
56
+ close(): Promise<void>;
57
+ protected generateLockContext(db: SQLiteDBConnection): LockContext;
58
+ execute(query: string, params?: any[]): Promise<QueryResult>;
59
+ executeRaw(query: string, params?: any[]): Promise<any[][]>;
60
+ executeBatch(query: string, params?: any[][]): Promise<QueryResult>;
61
+ readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
62
+ readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
63
+ writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
64
+ writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
65
+ refreshSchema(): Promise<void>;
66
+ getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
67
+ getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
68
+ get<T>(sql: string, parameters?: any[]): Promise<T>;
69
+ protected internalTransaction<T>(ctx: LockContext, fn: (tx: Transaction) => Promise<T>): Promise<T>;
70
+ }
71
+
72
+ /**
73
+ * PowerSyncDatabase class for managing database connections and sync implementations.
74
+ * This extends the WebPowerSyncDatabase to provide platform-specific implementations
75
+ * for Capacitor environments (iOS and Android).
76
+ *
77
+ * @experimental
78
+ * @alpha
79
+ */
80
+ declare class PowerSyncDatabase extends PowerSyncDatabase$1 {
81
+ protected get isNativeCapacitorPlatform(): boolean;
82
+ protected openDBAdapter(options: WebPowerSyncDatabaseOptionsWithSettings): DBAdapter;
83
+ protected generateTriggerManagerConfig(): TriggerManagerConfig;
84
+ protected runExclusive<T>(cb: () => Promise<T>): Promise<T>;
85
+ protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
86
+ }
87
+
88
+ export { CapacitorSQLiteAdapter, CapacitorSQLiteOpenFactory, PowerSyncDatabase };
package/dist/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
1
+ var capacitorPowerSync = (function (exports, sqlite, core, web$1, asyncMutex) {
2
2
  'use strict';
3
3
 
4
4
  const PowerSyncCore = core.registerPlugin('PowerSync', {
@@ -61,7 +61,8 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
61
61
  this.options = options;
62
62
  this._writeConnection = null;
63
63
  this._readConnection = null;
64
- this.lock = new Lock();
64
+ this.writeMutex = new asyncMutex.Mutex();
65
+ this.readMutex = new asyncMutex.Mutex();
65
66
  this.initializedPromise = this.init();
66
67
  }
67
68
  get writeConnection() {
@@ -227,10 +228,10 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
227
228
  });
228
229
  }
229
230
  readLock(fn, options) {
230
- return this.lock.acquire('read_lock', async () => {
231
+ return web$1.mutexRunExclusive(this.readMutex, async () => {
231
232
  await this.initializedPromise;
232
233
  return await fn(this.generateLockContext(this.readConnection));
233
- });
234
+ }, options);
234
235
  }
235
236
  readTransaction(fn, options) {
236
237
  return this.readLock(async (ctx) => {
@@ -238,7 +239,7 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
238
239
  });
239
240
  }
240
241
  writeLock(fn, options) {
241
- return this.lock.acquire('write_lock', async () => {
242
+ return web$1.mutexRunExclusive(this.writeMutex, async () => {
242
243
  var _a;
243
244
  await this.initializedPromise;
244
245
  const result = await fn(this.generateLockContext(this.writeConnection));
@@ -255,7 +256,7 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
255
256
  };
256
257
  this.iterateListeners((l) => { var _a; return (_a = l.tablesUpdated) === null || _a === void 0 ? void 0 : _a.call(l, notification); });
257
258
  return result;
258
- });
259
+ }, options);
259
260
  }
260
261
  writeTransaction(fn, options) {
261
262
  return this.writeLock(async (ctx) => {
@@ -316,10 +317,47 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
316
317
  }
317
318
  }
318
319
 
320
+ const GLOBAL_MUTEX_STORE = new Map();
321
+ /**
322
+ * Used to identify multiple instances of CapacitorStreamingSyncImplementation
323
+ */
324
+ let _CAPACITOR_STREAMING_SYNC_SEQUENCE = 0;
319
325
  class CapacitorStreamingSyncImplementation extends web$1.AbstractStreamingSyncImplementation {
326
+ constructor() {
327
+ super(...arguments);
328
+ // A unique ID for tacking this specific instance of CapacitorStreamingSyncImplementation
329
+ this.instanceId = _CAPACITOR_STREAMING_SYNC_SEQUENCE++;
330
+ }
331
+ async dispose() {
332
+ await super.dispose();
333
+ // Clear up any global mutexes which aren't used anymore
334
+ for (const mutexEntry of GLOBAL_MUTEX_STORE.entries()) {
335
+ const [identifier, mutex] = mutexEntry;
336
+ if (!mutex.tracking.has(this.instanceId)) {
337
+ continue;
338
+ }
339
+ mutex.tracking.delete(this.instanceId);
340
+ if (mutex.tracking.size == 0) {
341
+ GLOBAL_MUTEX_STORE.delete(identifier);
342
+ }
343
+ }
344
+ }
320
345
  async obtainLock(lockOptions) {
321
- const identifier = `streaming-sync-${lockOptions.type}-${this.options.identifier}`;
322
- return CapacitorStreamingSyncImplementation.GLOBAL_LOCK.acquire(identifier, async () => {
346
+ // If we don't have an identifier for some reason (should not happen), we use a shared Mutex
347
+ const { identifier: baseIdentifier = 'DEFAULT' } = this.options;
348
+ if (!GLOBAL_MUTEX_STORE.has(baseIdentifier)) {
349
+ GLOBAL_MUTEX_STORE.set(baseIdentifier, {
350
+ tracking: new Set([this.instanceId]),
351
+ locks: {
352
+ [web$1.LockType.CRUD]: new asyncMutex.Mutex(),
353
+ [web$1.LockType.SYNC]: new asyncMutex.Mutex()
354
+ }
355
+ });
356
+ }
357
+ const mutexRecord = GLOBAL_MUTEX_STORE.get(baseIdentifier);
358
+ mutexRecord.tracking.add(this.instanceId);
359
+ const mutex = mutexRecord.locks[lockOptions.type];
360
+ return web$1.mutexRunExclusive(mutex, async () => {
323
361
  var _a;
324
362
  if ((_a = lockOptions.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
325
363
  throw new Error('Aborted');
@@ -328,7 +366,6 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
328
366
  });
329
367
  }
330
368
  }
331
- CapacitorStreamingSyncImplementation.GLOBAL_LOCK = new Lock();
332
369
 
333
370
  /**
334
371
  * PowerSyncDatabase class for managing database connections and sync implementations.
@@ -361,6 +398,17 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
361
398
  return super.openDBAdapter(options);
362
399
  }
363
400
  }
401
+ generateTriggerManagerConfig() {
402
+ const config = super.generateTriggerManagerConfig();
403
+ if (this.isNativeCapacitorPlatform) {
404
+ /**
405
+ * We usually only ever have a single tab for capacitor.
406
+ * Avoiding navigator locks allows insecure contexts (during development).
407
+ */
408
+ config.claimManager = web$1.MEMORY_TRIGGER_CLAIM_MANAGER;
409
+ }
410
+ return config;
411
+ }
364
412
  runExclusive(cb) {
365
413
  if (this.isNativeCapacitorPlatform) {
366
414
  // Use mutex for mobile platforms.
@@ -411,5 +459,5 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
411
459
 
412
460
  return exports;
413
461
 
414
- })({}, sqlite, capacitorExports, web$1, Lock);
462
+ })({}, sqlite, capacitorExports, web$1, asyncMutex);
415
463
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/plugin/PowerSyncCore.js","esm/plugin/PowerSyncPlugin.js","esm/adapter/CapacitorSQLiteOpenFactory.js","esm/adapter/CapacitorSQLiteAdapter.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","export const messageForErrorCode = (code) => {\n switch (code) {\n case 0:\n return 'Success';\n default:\n return `Extension registration failed with SQLite error code: ${code}`;\n }\n};\n//# sourceMappingURL=PowerSyncPlugin.js.map","import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter';\nvar SqliteSynchronous;\n(function (SqliteSynchronous) {\n SqliteSynchronous[\"normal\"] = \"NORMAL\";\n SqliteSynchronous[\"full\"] = \"FULL\";\n SqliteSynchronous[\"off\"] = \"OFF\";\n})(SqliteSynchronous || (SqliteSynchronous = {}));\nexport const DEFAULT_SQLITE_OPTIONS = {\n journalSizeLimit: 6 * 1024 * 1024,\n synchronous: SqliteSynchronous.normal,\n cacheSizeKb: 50 * 1024\n};\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 { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\nimport { BaseObserver } from '@powersync/web';\nimport Lock from 'async-lock';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore';\nimport { messageForErrorCode } from '../plugin/PowerSyncPlugin';\nimport { DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory';\n/**\n * Monitors the execution time of a query and logs it to the performance timeline.\n */\nasync function monitorQuery(sql, executor) {\n const start = performance.now();\n try {\n const r = await executor();\n performance.measure(`[SQL] ${sql}`, { start });\n return r;\n }\n catch (e) {\n performance.measure(`[SQL] [ERROR: ${e.message}] ${sql}`, { start });\n throw e;\n }\n}\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 get name() {\n return this.options.dbFilename;\n }\n async init() {\n const { responseCode: registrationResponseCode } = await PowerSyncCore.registerCore();\n if (registrationResponseCode != 0) {\n throw new Error(`Could not register PowerSync core extension: ${messageForErrorCode(registrationResponseCode)}`);\n }\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 await this._writeConnection.open();\n const { cacheSizeKb, journalSizeLimit, synchronous } = Object.assign(Object.assign({}, DEFAULT_SQLITE_OPTIONS), this.options.sqliteOptions);\n await this.writeConnection.query('PRAGMA journal_mode = WAL');\n await this.writeConnection.query(`PRAGMA journal_size_limit = ${journalSizeLimit}`);\n await this.writeConnection.query(`PRAGMA temp_store = memory`);\n await this.writeConnection.query(`PRAGMA synchronous = ${synchronous}`);\n await this.writeConnection.query(`PRAGMA cache_size = -${cacheSizeKb}`);\n await this._readConnection.open();\n const platform = Capacitor.getPlatform();\n if (platform == 'android') {\n /**\n * SQLCipher for Android enables dynamic loading of extensions.\n * On iOS we use a static auto extension registration.\n */\n const extensionQuery = \"SELECT load_extension('libpowersync.so', 'sqlite3_powersync_init')\";\n await this.writeConnection.query(extensionQuery);\n await this.readConnection.query(extensionQuery);\n }\n await 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 generateLockContext(db) {\n const _query = async (query, params = []) => {\n var _a;\n const result = await db.query(query, params);\n const 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 _execute = async (query, params = []) => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n const platform = Capacitor.getPlatform();\n if (db.getConnectionReadOnly()) {\n return _query(query, params);\n }\n if (platform == 'android') {\n // Android: use query for SELECT and executeSet for mutations\n // We cannot use `run` here for both cases.\n if (query.toLowerCase().trim().startsWith('select')) {\n return _query(query, params);\n }\n else {\n const result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: (_a = result.changes) === null || _a === void 0 ? void 0 : _a.lastId,\n rowsAffected: (_c = (_b = result.changes) === null || _b === void 0 ? void 0 : _b.changes) !== null && _c !== void 0 ? _c : 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\n };\n }\n }\n // iOS (and other platforms): use run(\"all\")\n const result = await db.run(query, params, false, 'all');\n const resultSet = (_e = (_d = result.changes) === null || _d === void 0 ? void 0 : _d.values) !== null && _e !== void 0 ? _e : [];\n return {\n insertId: (_f = result.changes) === null || _f === void 0 ? void 0 : _f.lastId,\n rowsAffected: (_h = (_g = result.changes) === null || _g === void 0 ? void 0 : _g.changes) !== null && _h !== void 0 ? _h : 0,\n rows: {\n _array: resultSet,\n length: resultSet.length,\n item: (idx) => resultSet[idx]\n }\n };\n };\n const execute = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _execute(sql, params))\n : _execute;\n const executeQuery = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _query(sql, params))\n : _query;\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 var _a, _b;\n // This is a workaround, we don't support multiple columns of the same name\n const results = await execute(query, params);\n return (_b = (_a = results.rows) === null || _a === void 0 ? void 0 : _a._array.map((row) => Object.values(row))) !== null && _b !== void 0 ? _b : [];\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 { AbstractStreamingSyncImplementation } from '@powersync/web';\nimport Lock from 'async-lock';\nexport class CapacitorStreamingSyncImplementation extends AbstractStreamingSyncImplementation {\n async obtainLock(lockOptions) {\n const identifier = `streaming-sync-${lockOptions.type}-${this.options.identifier}`;\n return CapacitorStreamingSyncImplementation.GLOBAL_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}\nCapacitorStreamingSyncImplementation.GLOBAL_LOCK = new Lock();\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(Object.assign({}, options.database));\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","Capacitor","AbstractStreamingSyncImplementation","WebPowerSyncDatabase","WebRemote","WebPlugin"],"mappings":";;;IACO,MAAM,aAAa,GAAGA,mBAAc,CAAC,WAAW,EAAE;IACzD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,YAAY,EAAE;IAC/D,CAAC,CAAC;;ICHK,MAAM,mBAAmB,GAAG,CAAC,IAAI,KAAK;IAC7C,IAAI,QAAQ,IAAI;IAChB,QAAQ,KAAK,CAAC;IACd,YAAY,OAAO,SAAS;IAC5B,QAAQ;IACR,YAAY,OAAO,CAAC,sDAAsD,EAAE,IAAI,CAAC,CAAC;IAClF;IACA,CAAC;;ICND,IAAI,iBAAiB;IACrB,CAAC,UAAU,iBAAiB,EAAE;IAC9B,IAAI,iBAAiB,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAC1C,IAAI,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM;IACtC,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,KAAK;IACpC,CAAC,EAAE,iBAAiB,KAAK,iBAAiB,GAAG,EAAE,CAAC,CAAC;IAC1C,MAAM,sBAAsB,GAAG;IACtC,IAAI,gBAAgB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IACrC,IAAI,WAAW,EAAE,iBAAiB,CAAC,MAAM;IACzC,IAAI,WAAW,EAAE,EAAE,GAAG;IACtB,CAAC;IACM,MAAM,0BAA0B,CAAC;IACxC,IAAI,WAAW,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO;IAC9B,IAAI;IACJ,IAA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apter.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.js').then((m) => new m.PowerSyncWeb())\n});\n//# sourceMappingURL=PowerSyncCore.js.map","export const messageForErrorCode = (code) => {\n switch (code) {\n case 0:\n return 'Success';\n default:\n return `Extension registration failed with SQLite error code: ${code}`;\n }\n};\n//# sourceMappingURL=PowerSyncPlugin.js.map","import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter.js';\nvar SqliteSynchronous;\n(function (SqliteSynchronous) {\n SqliteSynchronous[\"normal\"] = \"NORMAL\";\n SqliteSynchronous[\"full\"] = \"FULL\";\n SqliteSynchronous[\"off\"] = \"OFF\";\n})(SqliteSynchronous || (SqliteSynchronous = {}));\nexport const DEFAULT_SQLITE_OPTIONS = {\n journalSizeLimit: 6 * 1024 * 1024,\n synchronous: SqliteSynchronous.normal,\n cacheSizeKb: 50 * 1024\n};\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 { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\nimport { BaseObserver, mutexRunExclusive } from '@powersync/web';\nimport { Mutex } from 'async-mutex';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore.js';\nimport { messageForErrorCode } from '../plugin/PowerSyncPlugin.js';\nimport { DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory.js';\n/**\n * Monitors the execution time of a query and logs it to the performance timeline.\n */\nasync function monitorQuery(sql, executor) {\n const start = performance.now();\n try {\n const r = await executor();\n performance.measure(`[SQL] ${sql}`, { start });\n return r;\n }\n catch (e) {\n performance.measure(`[SQL] [ERROR: ${e.message}] ${sql}`, { start });\n throw e;\n }\n}\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.writeMutex = new Mutex();\n this.readMutex = new Mutex();\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 get name() {\n return this.options.dbFilename;\n }\n async init() {\n const { responseCode: registrationResponseCode } = await PowerSyncCore.registerCore();\n if (registrationResponseCode != 0) {\n throw new Error(`Could not register PowerSync core extension: ${messageForErrorCode(registrationResponseCode)}`);\n }\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 await this._writeConnection.open();\n const { cacheSizeKb, journalSizeLimit, synchronous } = Object.assign(Object.assign({}, DEFAULT_SQLITE_OPTIONS), this.options.sqliteOptions);\n await this.writeConnection.query('PRAGMA journal_mode = WAL');\n await this.writeConnection.query(`PRAGMA journal_size_limit = ${journalSizeLimit}`);\n await this.writeConnection.query(`PRAGMA temp_store = memory`);\n await this.writeConnection.query(`PRAGMA synchronous = ${synchronous}`);\n await this.writeConnection.query(`PRAGMA cache_size = -${cacheSizeKb}`);\n await this._readConnection.open();\n const platform = Capacitor.getPlatform();\n if (platform == 'android') {\n /**\n * SQLCipher for Android enables dynamic loading of extensions.\n * On iOS we use a static auto extension registration.\n */\n const extensionQuery = \"SELECT load_extension('libpowersync.so', 'sqlite3_powersync_init')\";\n await this.writeConnection.query(extensionQuery);\n await this.readConnection.query(extensionQuery);\n }\n await 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 generateLockContext(db) {\n const _query = async (query, params = []) => {\n var _a;\n const result = await db.query(query, params);\n const 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 _execute = async (query, params = []) => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n const platform = Capacitor.getPlatform();\n if (db.getConnectionReadOnly()) {\n return _query(query, params);\n }\n if (platform == 'android') {\n // Android: use query for SELECT and executeSet for mutations\n // We cannot use `run` here for both cases.\n if (query.toLowerCase().trim().startsWith('select')) {\n return _query(query, params);\n }\n else {\n const result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: (_a = result.changes) === null || _a === void 0 ? void 0 : _a.lastId,\n rowsAffected: (_c = (_b = result.changes) === null || _b === void 0 ? void 0 : _b.changes) !== null && _c !== void 0 ? _c : 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\n };\n }\n }\n // iOS (and other platforms): use run(\"all\")\n const result = await db.run(query, params, false, 'all');\n const resultSet = (_e = (_d = result.changes) === null || _d === void 0 ? void 0 : _d.values) !== null && _e !== void 0 ? _e : [];\n return {\n insertId: (_f = result.changes) === null || _f === void 0 ? void 0 : _f.lastId,\n rowsAffected: (_h = (_g = result.changes) === null || _g === void 0 ? void 0 : _g.changes) !== null && _h !== void 0 ? _h : 0,\n rows: {\n _array: resultSet,\n length: resultSet.length,\n item: (idx) => resultSet[idx]\n }\n };\n };\n const execute = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _execute(sql, params))\n : _execute;\n const executeQuery = this.options.debugMode\n ? (sql, params) => monitorQuery(sql, () => _query(sql, params))\n : _query;\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 var _a, _b;\n // This is a workaround, we don't support multiple columns of the same name\n const results = await execute(query, params);\n return (_b = (_a = results.rows) === null || _a === void 0 ? void 0 : _a._array.map((row) => Object.values(row))) !== null && _b !== void 0 ? _b : [];\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 mutexRunExclusive(this.readMutex, async () => {\n await this.initializedPromise;\n return await fn(this.generateLockContext(this.readConnection));\n }, options);\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 mutexRunExclusive(this.writeMutex, 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 }, options);\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 { AbstractStreamingSyncImplementation, LockType, mutexRunExclusive } from '@powersync/web';\nimport { Mutex } from 'async-mutex';\nconst GLOBAL_MUTEX_STORE = new Map();\n/**\n * Used to identify multiple instances of CapacitorStreamingSyncImplementation\n */\nlet _CAPACITOR_STREAMING_SYNC_SEQUENCE = 0;\nexport class CapacitorStreamingSyncImplementation extends AbstractStreamingSyncImplementation {\n constructor() {\n super(...arguments);\n // A unique ID for tacking this specific instance of CapacitorStreamingSyncImplementation\n this.instanceId = _CAPACITOR_STREAMING_SYNC_SEQUENCE++;\n }\n async dispose() {\n await super.dispose();\n // Clear up any global mutexes which aren't used anymore\n for (const mutexEntry of GLOBAL_MUTEX_STORE.entries()) {\n const [identifier, mutex] = mutexEntry;\n if (!mutex.tracking.has(this.instanceId)) {\n continue;\n }\n mutex.tracking.delete(this.instanceId);\n if (mutex.tracking.size == 0) {\n GLOBAL_MUTEX_STORE.delete(identifier);\n }\n }\n }\n async obtainLock(lockOptions) {\n // If we don't have an identifier for some reason (should not happen), we use a shared Mutex\n const { identifier: baseIdentifier = 'DEFAULT' } = this.options;\n if (!GLOBAL_MUTEX_STORE.has(baseIdentifier)) {\n GLOBAL_MUTEX_STORE.set(baseIdentifier, {\n tracking: new Set([this.instanceId]),\n locks: {\n [LockType.CRUD]: new Mutex(),\n [LockType.SYNC]: new Mutex()\n }\n });\n }\n const mutexRecord = GLOBAL_MUTEX_STORE.get(baseIdentifier);\n mutexRecord.tracking.add(this.instanceId);\n const mutex = mutexRecord.locks[lockOptions.type];\n return mutexRunExclusive(mutex, 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 { MEMORY_TRIGGER_CLAIM_MANAGER, PowerSyncDatabase as WebPowerSyncDatabase, WebRemote } from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';\nimport { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation.js';\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(Object.assign({}, options.database));\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 generateTriggerManagerConfig() {\n const config = super.generateTriggerManagerConfig();\n if (this.isNativeCapacitorPlatform) {\n /**\n * We usually only ever have a single tab for capacitor.\n * Avoiding navigator locks allows insecure contexts (during development).\n */\n config.claimManager = MEMORY_TRIGGER_CLAIM_MANAGER;\n }\n return config;\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","Mutex","sqlite","SQLiteConnection","CapacitorSQLite","Capacitor","mutexRunExclusive","AbstractStreamingSyncImplementation","LockType","WebPowerSyncDatabase","MEMORY_TRIGGER_CLAIM_MANAGER","WebRemote","WebPlugin"],"mappings":";;;IACO,MAAM,aAAa,GAAGA,mBAAc,CAAC,WAAW,EAAE;IACzD,IAAI,GAAG,EAAE,MAAM,mDAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,YAAY,EAAE;IAClE,CAAC,CAAC;;ICHK,MAAM,mBAAmB,GAAG,CAAC,IAAI,KAAK;IAC7C,IAAI,QAAQ,IAAI;IAChB,QAAQ,KAAK,CAAC;IACd,YAAY,OAAO,SAAS;IAC5B,QAAQ;IACR,YAAY,OAAO,CAAC,sDAAsD,EAAE,IAAI,CAAC,CAAC;IAClF;IACA,CAAC;;ICND,IAAI,iBAAiB;IACrB,CAAC,UAAU,iBAAiB,EAAE;IAC9B,IAAI,iBAAiB,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAC1C,IAAI,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM;IACtC,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,KAAK;IACpC,CAAC,EAAE,iBAAiB,KAAK,i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,EAAE;IAC7C,oBAAoB,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;IACpD,gBAAgB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAChH,QAAQ;IACR,aAAa;IACb,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,sDAAsD,CAAC,CAAC;IACvF,YAAY,OAAO,KAAK,CAAC,gCAAgC,CAAC,SAAS,EAAE,OAAO,CAAC;IAC7E,QAAQ;IACR,IAAI;IACJ;;IC5EO,MAAM,YAAY,SAASC,cAAS,CAAC;IAC5C,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;IAClE,IAAI;IACJ;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@powersync/capacitor",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Adds PowerSync Capacitor support for iOS/Android",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
7
7
  "access": "public"
8
8
  },
9
- "main": "dist/plugin.cjs.js",
9
+ "type": "module",
10
+ "main": "dist/plugin.cjs",
10
11
  "module": "dist/esm/index.js",
11
12
  "types": "dist/esm/index.d.ts",
12
13
  "unpkg": "dist/plugin.js",
@@ -21,7 +22,19 @@
21
22
  "Package.swift",
22
23
  "PowersyncCapacitor.podspec"
23
24
  ],
24
- "author": "",
25
+ "exports": {
26
+ ".": {
27
+ "import": {
28
+ "types": "./dist/esm/index.d.ts",
29
+ "default": "./dist/esm/index.js"
30
+ },
31
+ "require": {
32
+ "types": "./dist/plugin.d.cts",
33
+ "default": "./dist/plugin.cjs"
34
+ }
35
+ }
36
+ },
37
+ "author": "POWERSYNC",
25
38
  "license": "Apache-2.0",
26
39
  "repository": {
27
40
  "type": "git",
@@ -45,15 +58,16 @@
45
58
  "@ionic/prettier-config": "^4.0.0",
46
59
  "@ionic/swiftlint-config": "^2.0.0",
47
60
  "eslint": "^8.57.0",
48
- "prettier": "^3.4.2",
61
+ "prettier": "^3.7.4",
49
62
  "prettier-plugin-java": "^2.6.6",
50
63
  "rimraf": "^6.0.1",
51
- "rollup": "^4.30.1",
64
+ "rollup": "^4.52.5",
65
+ "rollup-plugin-dts": "^6.2.1",
52
66
  "swiftlint": "^2.0.0"
53
67
  },
54
68
  "peerDependencies": {
55
69
  "@capacitor-community/sqlite": "^7.0.2",
56
- "@powersync/web": "^1.30.0"
70
+ "@powersync/web": "^1.33.0"
57
71
  },
58
72
  "swiftlint": "@ionic/swiftlint-config",
59
73
  "capacitor": {
@@ -67,7 +81,7 @@
67
81
  }
68
82
  },
69
83
  "dependencies": {
70
- "async-lock": "^1.4.0"
84
+ "async-mutex": "^0.5.0"
71
85
  },
72
86
  "scripts": {
73
87
  "verify": "pnpm verify:ios && pnpm verify:android && pnpm verify:web",
@@ -84,6 +98,6 @@
84
98
  "build:prod": "pnpm build",
85
99
  "clean": "rimraf ./dist",
86
100
  "watch": "tsc --watch",
87
- "test:exports": "attw --pack ."
101
+ "test:exports": "attw --pack --profile=esm-only ."
88
102
  }
89
103
  }
@@ -1,15 +1,17 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
2
  import {
3
3
  DBAdapter,
4
+ MEMORY_TRIGGER_CLAIM_MANAGER,
4
5
  PowerSyncBackendConnector,
5
6
  RequiredAdditionalConnectionOptions,
6
7
  StreamingSyncImplementation,
8
+ TriggerManagerConfig,
7
9
  PowerSyncDatabase as WebPowerSyncDatabase,
8
10
  WebPowerSyncDatabaseOptionsWithSettings,
9
11
  WebRemote
10
12
  } from '@powersync/web';
11
- import { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';
12
- import { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation';
13
+ import { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';
14
+ import { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation.js';
13
15
 
14
16
  /**
15
17
  * PowerSyncDatabase class for managing database connections and sync implementations.
@@ -44,6 +46,18 @@ export class PowerSyncDatabase extends WebPowerSyncDatabase {
44
46
  }
45
47
  }
46
48
 
49
+ protected generateTriggerManagerConfig(): TriggerManagerConfig {
50
+ const config = super.generateTriggerManagerConfig();
51
+ if (this.isNativeCapacitorPlatform) {
52
+ /**
53
+ * We usually only ever have a single tab for capacitor.
54
+ * Avoiding navigator locks allows insecure contexts (during development).
55
+ */
56
+ config.claimManager = MEMORY_TRIGGER_CLAIM_MANAGER;
57
+ }
58
+ return config;
59
+ }
60
+
47
61
  protected runExclusive<T>(cb: () => Promise<T>): Promise<T> {
48
62
  if (this.isNativeCapacitorPlatform) {
49
63
  // Use mutex for mobile platforms.