@powersync/capacitor 0.2.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { DBAdapter, PowerSyncBackendConnector, RequiredAdditionalConnectionOptions, StreamingSyncImplementation, PowerSyncDatabase as WebPowerSyncDatabase, WebPowerSyncDatabaseOptionsWithSettings } from '@powersync/web';
1
+ import { DBAdapter, PowerSyncBackendConnector, RequiredAdditionalConnectionOptions, StreamingSyncImplementation, TriggerManagerConfig, PowerSyncDatabase as WebPowerSyncDatabase, WebPowerSyncDatabaseOptionsWithSettings } from '@powersync/web';
2
2
  /**
3
3
  * PowerSyncDatabase class for managing database connections and sync implementations.
4
4
  * This extends the WebPowerSyncDatabase to provide platform-specific implementations
@@ -10,6 +10,7 @@ import { DBAdapter, PowerSyncBackendConnector, RequiredAdditionalConnectionOptio
10
10
  export declare class PowerSyncDatabase extends WebPowerSyncDatabase {
11
11
  protected get isNativeCapacitorPlatform(): boolean;
12
12
  protected openDBAdapter(options: WebPowerSyncDatabaseOptionsWithSettings): DBAdapter;
13
+ protected generateTriggerManagerConfig(): TriggerManagerConfig;
13
14
  protected runExclusive<T>(cb: () => Promise<T>): Promise<T>;
14
15
  protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
15
16
  }
@@ -1,7 +1,7 @@
1
1
  import { Capacitor } from '@capacitor/core';
2
- import { PowerSyncDatabase as WebPowerSyncDatabase, WebRemote } from '@powersync/web';
3
- import { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';
4
- import { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation';
2
+ import { MEMORY_TRIGGER_CLAIM_MANAGER, PowerSyncDatabase as WebPowerSyncDatabase, WebRemote } from '@powersync/web';
3
+ import { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';
4
+ import { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation.js';
5
5
  /**
6
6
  * PowerSyncDatabase class for managing database connections and sync implementations.
7
7
  * This extends the WebPowerSyncDatabase to provide platform-specific implementations
@@ -33,6 +33,17 @@ export class PowerSyncDatabase extends WebPowerSyncDatabase {
33
33
  return super.openDBAdapter(options);
34
34
  }
35
35
  }
36
+ generateTriggerManagerConfig() {
37
+ const config = super.generateTriggerManagerConfig();
38
+ if (this.isNativeCapacitorPlatform) {
39
+ /**
40
+ * We usually only ever have a single tab for capacitor.
41
+ * Avoiding navigator locks allows insecure contexts (during development).
42
+ */
43
+ config.claimManager = MEMORY_TRIGGER_CLAIM_MANAGER;
44
+ }
45
+ return config;
46
+ }
36
47
  runExclusive(cb) {
37
48
  if (this.isNativeCapacitorPlatform) {
38
49
  // Use mutex for mobile platforms.
@@ -1 +1 @@
1
- {"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAKL,iBAAiB,IAAI,oBAAoB,EAEzC,SAAS,EACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,oBAAoB;IACzD,IAAc,yBAAyB;QACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QACzC,OAAO,QAAQ,IAAI,KAAK,IAAI,QAAQ,IAAI,SAAS,CAAC;IACpD,CAAC;IAES,aAAa,CAAC,OAAgD;;QACtE,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/C,IAAI,OAAO,CA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,EAAE,OAAO,CAAC,oBAAoB,EAClD,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAClC,MAAM,EACN,UAAU,EAAE,KAAK,IAAI,EAAE;oBACrB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;oBAC1B,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC,EACD,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,aAAa,EAAE,OAAO,CAAC,aAAa,IACpC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YAC5E,OAAO,KAAK,CAAC,gCAAgC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport {\n DBAdapter,\n PowerSyncBackendConnector,\n RequiredAdditionalConnectionOptions,\n StreamingSyncImplementation,\n PowerSyncDatabase as WebPowerSyncDatabase,\n WebPowerSyncDatabaseOptionsWithSettings,\n WebRemote\n} from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';\nimport { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation';\n\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 protected get isNativeCapacitorPlatform(): boolean {\n const platform = Capacitor.getPlatform();\n return platform == 'ios' || platform == 'android';\n }\n\n protected openDBAdapter(options: WebPowerSyncDatabaseOptionsWithSettings): DBAdapter {\n const platform = Capacitor.getPlatform();\n if (platform == 'ios' || platform == 'android') {\n if (options.database.dbLocation) {\n options.logger?.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 options.logger?.debug(`Using CapacitorSQLiteAdapter for platform: ${platform}`);\n return new CapacitorSQLiteAdapter({\n ...options.database\n });\n } else {\n options.logger?.debug(`Using default web adapter for web platform`);\n return super.openDBAdapter(options);\n }\n }\n\n protected runExclusive<T>(cb: () => Promise<T>): Promise<T> {\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 } else {\n // Use navigator.locks for web platform\n return super.runExclusive(cb);\n }\n }\n\n protected generateSyncStreamImplementation(\n connector: PowerSyncBackendConnector,\n options: RequiredAdditionalConnectionOptions\n ): StreamingSyncImplementation {\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 (this.options.flags?.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\n return new CapacitorStreamingSyncImplementation({\n ...(this.options as {}),\n retryDelayMs: options.retryDelayMs,\n crudUploadThrottleMs: options.crudUploadThrottleMs,\n adapter: this.bucketStorageAdapter,\n remote,\n uploadCrud: async () => {\n await this.waitForReady();\n await connector.uploadData(this);\n },\n identifier: this.database.name,\n logger: this.logger,\n 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"]}
1
+ {"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,4BAA4B,EAK5B,iBAAiB,IAAI,oBAAoB,EAEzC,SAAS,EAC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,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport {\n DBAdapter,\n MEMORY_TRIGGER_CLAIM_MANAGER,\n PowerSyncBackendConnector,\n RequiredAdditionalConnectionOptions,\n StreamingSyncImplementation,\n TriggerManagerConfig,\n PowerSyncDatabase as WebPowerSyncDatabase,\n WebPowerSyncDatabaseOptionsWithSettings,\n WebRemote\n} from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';\nimport { CapacitorStreamingSyncImplementation } from './sync/CapacitorSyncImplementation.js';\n\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 protected get isNativeCapacitorPlatform(): boolean {\n const platform = Capacitor.getPlatform();\n return platform == 'ios' || platform == 'android';\n }\n\n protected openDBAdapter(options: WebPowerSyncDatabaseOptionsWithSettings): DBAdapter {\n const platform = Capacitor.getPlatform();\n if (platform == 'ios' || platform == 'android') {\n if (options.database.dbLocation) {\n options.logger?.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 options.logger?.debug(`Using CapacitorSQLiteAdapter for platform: ${platform}`);\n return new CapacitorSQLiteAdapter({\n ...options.database\n });\n } else {\n options.logger?.debug(`Using default web adapter for web platform`);\n return super.openDBAdapter(options);\n }\n }\n\n protected generateTriggerManagerConfig(): TriggerManagerConfig {\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\n protected runExclusive<T>(cb: () => Promise<T>): Promise<T> {\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 } else {\n // Use navigator.locks for web platform\n return super.runExclusive(cb);\n }\n }\n\n protected generateSyncStreamImplementation(\n connector: PowerSyncBackendConnector,\n options: RequiredAdditionalConnectionOptions\n ): StreamingSyncImplementation {\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 (this.options.flags?.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\n return new CapacitorStreamingSyncImplementation({\n ...(this.options as {}),\n retryDelayMs: options.retryDelayMs,\n crudUploadThrottleMs: options.crudUploadThrottleMs,\n adapter: this.bucketStorageAdapter,\n remote,\n uploadCrud: async () => {\n await this.waitForReady();\n await connector.uploadData(this);\n },\n identifier: this.database.name,\n logger: this.logger,\n 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"]}
@@ -1,7 +1,7 @@
1
1
  import { SQLiteDBConnection } from '@capacitor-community/sqlite';
2
2
  import { BaseObserver, DBAdapter, DBAdapterListener, DBLockOptions, LockContext, QueryResult, Transaction } from '@powersync/web';
3
3
  import Lock from 'async-lock';
4
- import { CapacitorSQLiteOpenFactoryOptions } from './CapacitorSQLiteOpenFactory';
4
+ import { CapacitorSQLiteOpenFactoryOptions } from './CapacitorSQLiteOpenFactory.js';
5
5
  /**
6
6
  * An implementation of {@link DBAdapter} using the Capacitor Community SQLite [plugin](https://github.com/capacitor-community/sqlite).
7
7
  *
@@ -2,9 +2,9 @@ import { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';
2
2
  import { Capacitor } from '@capacitor/core';
3
3
  import { BaseObserver } from '@powersync/web';
4
4
  import Lock from 'async-lock';
5
- import { PowerSyncCore } from '../plugin/PowerSyncCore';
6
- import { messageForErrorCode } from '../plugin/PowerSyncPlugin';
7
- import { DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory';
5
+ import { PowerSyncCore } from '../plugin/PowerSyncCore.js';
6
+ import { messageForErrorCode } from '../plugin/PowerSyncPlugin.js';
7
+ import { DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory.js';
8
8
  /**
9
9
  * Monitors the execution time of a query and logs it to the performance timeline.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CapacitorSQLiteAdapter.js","sourceRoot":"","sources":["../../../src/adapter/CapacitorSQLiteAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAsB,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,YAAY,EAQb,MAAM,gBAAgB,CAAC;AACxB,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAqC,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACzG;;GAEG;AACH,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,QAAoC;IAC3E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,QAAQ,EAAE,CAAC;QAC3B,WAAW,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC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AC;IACH,CAAC;CACF","sourcesContent":["import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\n\nimport {\n BaseObserver,\n BatchedUpdateNotification,\n DBAdapter,\n DBAdapterListener,\n DBLockOptions,\n LockContext,\n QueryResult,\n Transaction\n} from '@powersync/web';\nimport Lock from 'async-lock';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore';\nimport { messageForErrorCode } from '../plugin/PowerSyncPlugin';\nimport { CapacitorSQLiteOpenFactoryOptions, 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: string, executor: () => Promise<QueryResult>): Promise<QueryResult> {\n const start = performance.now();\n try {\n const r = await executor();\n performance.measure(`[SQL] ${sql}`, { start });\n return r;\n } catch (e: any) {\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<DBAdapterListener> implements DBAdapter {\n protected _writeConnection: SQLiteDBConnection | null;\n protected _readConnection: SQLiteDBConnection | null;\n protected initializedPromise: Promise<void>;\n protected lock: Lock;\n\n constructor(protected options: CapacitorSQLiteOpenFactoryOptions) {\n super();\n this._writeConnection = null;\n this._readConnection = null;\n this.lock = new Lock();\n this.initializedPromise = this.init();\n }\n\n protected get writeConnection(): SQLiteDBConnection {\n if (!this._writeConnection) {\n throw new Error('Init not completed yet');\n }\n return this._writeConnection;\n }\n\n protected get readConnection(): SQLiteDBConnection {\n if (!this._readConnection) {\n throw new Error('Init not completed yet');\n }\n return this._readConnection;\n }\n\n get name() {\n return this.options.dbFilename;\n }\n\n private 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\n const sqlite = new SQLiteConnection(CapacitorSQLite);\n\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\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\n await this._writeConnection.open();\n\n const { cacheSizeKb, journalSizeLimit, synchronous } = { ...DEFAULT_SQLITE_OPTIONS, ...this.options.sqliteOptions };\n\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\n await this._readConnection.open();\n\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\n async close(): Promise<void> {\n await this.initializedPromise;\n await this.writeConnection.close();\n await this.readConnection.close();\n }\n\n protected generateLockContext(db: SQLiteDBConnection): LockContext {\n const _query = async (query: string, params: any[] = []) => {\n const result = await db.query(query, params);\n const arrayResult = result.values ?? [];\n return {\n rowsAffected: 0,\n rows: {\n _array: arrayResult,\n length: arrayResult.length,\n item: (idx: number) => arrayResult[idx]\n }\n };\n };\n\n const _execute = async (query: string, params: any[] = []): Promise<QueryResult> => {\n const platform = Capacitor.getPlatform();\n\n if (db.getConnectionReadOnly()) {\n return _query(query, params);\n }\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 } else {\n const result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: result.changes?.lastId,\n rowsAffected: result.changes?.changes ?? 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\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 = result.changes?.values ?? [];\n return {\n insertId: result.changes?.lastId,\n rowsAffected: result.changes?.changes ?? 0,\n rows: {\n _array: resultSet,\n length: resultSet.length,\n item: (idx) => resultSet[idx]\n }\n };\n };\n\n const execute = this.options.debugMode\n ? (sql: string, params?: any[]) => monitorQuery(sql, () => _execute(sql, params))\n : _execute;\n\n const executeQuery = this.options.debugMode\n ? (sql: string, params?: any[]) => monitorQuery(sql, () => _query(sql, params))\n : _query;\n\n const getAll = async <T>(query: string, params?: any[]): Promise<T[]> => {\n const result = await executeQuery(query, params);\n return result.rows?._array ?? ([] as T[]);\n };\n\n const getOptional = async <T>(query: string, params?: any[]): Promise<T | null> => {\n const results = await getAll<T>(query, params);\n return results.length > 0 ? results[0] : null;\n };\n\n const get = async <T>(query: string, params?: any[]): Promise<T> => {\n const result = await getOptional<T>(query, params);\n if (!result) {\n throw new Error(`No results for query: ${query}`);\n }\n return result;\n };\n\n const executeRaw = async (query: string, params?: any[]): Promise<any[][]> => {\n // This is a workaround, we don't support multiple columns of the same name\n const results = await execute(query, params);\n return results.rows?._array.map((row) => Object.values(row)) ?? [];\n };\n\n return {\n getAll,\n getOptional,\n get,\n executeRaw,\n execute\n };\n }\n\n execute(query: string, params?: any[]): Promise<QueryResult> {\n return this.writeLock((tx) => tx.execute(query, params));\n }\n\n executeRaw(query: string, params?: any[]): Promise<any[][]> {\n return this.writeLock((tx) => tx.executeRaw(query, params));\n }\n\n async executeBatch(query: string, params: any[][] = []): Promise<QueryResult> {\n return this.writeLock(async (tx) => {\n let result = await this.writeConnection.executeSet(\n params.map((param) => ({\n statement: query,\n values: param\n }))\n );\n\n return {\n rowsAffected: result.changes?.changes ?? 0,\n insertId: result.changes?.lastId\n };\n });\n }\n\n readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.lock.acquire('read_lock', async () => {\n await this.initializedPromise;\n return await fn(this.generateLockContext(this.readConnection));\n });\n }\n\n readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.readLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n\n writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.lock.acquire('write_lock', async () => {\n await this.initializedPromise;\n const result = await fn(this.generateLockContext(this.writeConnection));\n\n // Fetch table updates\n const updates = await this.writeConnection.query(\"SELECT powersync_update_hooks('get') AS table_name\");\n const jsonUpdates = updates.values?.[0];\n if (!jsonUpdates || !jsonUpdates.table_name) {\n throw new Error('Could not fetch table updates');\n }\n const notification: BatchedUpdateNotification = {\n rawUpdates: [],\n tables: JSON.parse(jsonUpdates.table_name),\n groupedUpdates: {}\n };\n this.iterateListeners((l) => l.tablesUpdated?.(notification));\n return result;\n });\n }\n\n writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.writeLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n\n refreshSchema(): Promise<void> {\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\n getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {\n return this.readLock((tx) => tx.getAll<T>(sql, parameters));\n }\n\n getOptional<T>(sql: string, parameters?: any[]): Promise<T | null> {\n return this.readLock((tx) => tx.getOptional<T>(sql, parameters));\n }\n\n get<T>(sql: string, parameters?: any[]): Promise<T> {\n return this.readLock((tx) => tx.get<T>(sql, parameters));\n }\n\n protected async internalTransaction<T>(ctx: LockContext, fn: (tx: Transaction) => Promise<T>): Promise<T> {\n let finalized = false;\n const commit = async (): Promise<QueryResult> => {\n if (finalized) {\n return { rowsAffected: 0 };\n }\n finalized = true;\n return ctx.execute('COMMIT');\n };\n const rollback = async (): Promise<QueryResult> => {\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({\n ...ctx,\n commit,\n rollback\n });\n await commit();\n return result;\n } catch (ex) {\n try {\n await rollback();\n } catch (ex2) {\n // In rare cases, a rollback may fail.\n // Safe to ignore.\n }\n throw ex;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"CapacitorSQLiteAdapter.js","sourceRoot":"","sources":["../../../src/adapter/CapacitorSQLiteAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAsB,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,YAAY,EAQb,MAAM,gBAAgB,CAAC;AACxB,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAqC,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC5G;;GAEG;AACH,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,QAAoC;IAC3E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,CAAC;QACH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AAE,CAAC;YACf,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,QAAQ,EAAE,CAAC;YACnB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,sCAAsC;gBACtC,kBAAkB;YACpB,CAAC;YACD,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;CACF","sourcesContent":["import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';\nimport { Capacitor } from '@capacitor/core';\n\nimport {\n BaseObserver,\n BatchedUpdateNotification,\n DBAdapter,\n DBAdapterListener,\n DBLockOptions,\n LockContext,\n QueryResult,\n Transaction\n} from '@powersync/web';\nimport Lock from 'async-lock';\nimport { PowerSyncCore } from '../plugin/PowerSyncCore.js';\nimport { messageForErrorCode } from '../plugin/PowerSyncPlugin.js';\nimport { CapacitorSQLiteOpenFactoryOptions, 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: string, executor: () => Promise<QueryResult>): Promise<QueryResult> {\n const start = performance.now();\n try {\n const r = await executor();\n performance.measure(`[SQL] ${sql}`, { start });\n return r;\n } catch (e: any) {\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<DBAdapterListener> implements DBAdapter {\n protected _writeConnection: SQLiteDBConnection | null;\n protected _readConnection: SQLiteDBConnection | null;\n protected initializedPromise: Promise<void>;\n protected lock: Lock;\n\n constructor(protected options: CapacitorSQLiteOpenFactoryOptions) {\n super();\n this._writeConnection = null;\n this._readConnection = null;\n this.lock = new Lock();\n this.initializedPromise = this.init();\n }\n\n protected get writeConnection(): SQLiteDBConnection {\n if (!this._writeConnection) {\n throw new Error('Init not completed yet');\n }\n return this._writeConnection;\n }\n\n protected get readConnection(): SQLiteDBConnection {\n if (!this._readConnection) {\n throw new Error('Init not completed yet');\n }\n return this._readConnection;\n }\n\n get name() {\n return this.options.dbFilename;\n }\n\n private 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\n const sqlite = new SQLiteConnection(CapacitorSQLite);\n\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\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\n await this._writeConnection.open();\n\n const { cacheSizeKb, journalSizeLimit, synchronous } = { ...DEFAULT_SQLITE_OPTIONS, ...this.options.sqliteOptions };\n\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\n await this._readConnection.open();\n\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\n async close(): Promise<void> {\n await this.initializedPromise;\n await this.writeConnection.close();\n await this.readConnection.close();\n }\n\n protected generateLockContext(db: SQLiteDBConnection): LockContext {\n const _query = async (query: string, params: any[] = []) => {\n const result = await db.query(query, params);\n const arrayResult = result.values ?? [];\n return {\n rowsAffected: 0,\n rows: {\n _array: arrayResult,\n length: arrayResult.length,\n item: (idx: number) => arrayResult[idx]\n }\n };\n };\n\n const _execute = async (query: string, params: any[] = []): Promise<QueryResult> => {\n const platform = Capacitor.getPlatform();\n\n if (db.getConnectionReadOnly()) {\n return _query(query, params);\n }\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 } else {\n const result = await db.executeSet([{ statement: query, values: params }], false);\n return {\n insertId: result.changes?.lastId,\n rowsAffected: result.changes?.changes ?? 0,\n rows: {\n _array: [],\n length: 0,\n item: () => null\n }\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 = result.changes?.values ?? [];\n return {\n insertId: result.changes?.lastId,\n rowsAffected: result.changes?.changes ?? 0,\n rows: {\n _array: resultSet,\n length: resultSet.length,\n item: (idx) => resultSet[idx]\n }\n };\n };\n\n const execute = this.options.debugMode\n ? (sql: string, params?: any[]) => monitorQuery(sql, () => _execute(sql, params))\n : _execute;\n\n const executeQuery = this.options.debugMode\n ? (sql: string, params?: any[]) => monitorQuery(sql, () => _query(sql, params))\n : _query;\n\n const getAll = async <T>(query: string, params?: any[]): Promise<T[]> => {\n const result = await executeQuery(query, params);\n return result.rows?._array ?? ([] as T[]);\n };\n\n const getOptional = async <T>(query: string, params?: any[]): Promise<T | null> => {\n const results = await getAll<T>(query, params);\n return results.length > 0 ? results[0] : null;\n };\n\n const get = async <T>(query: string, params?: any[]): Promise<T> => {\n const result = await getOptional<T>(query, params);\n if (!result) {\n throw new Error(`No results for query: ${query}`);\n }\n return result;\n };\n\n const executeRaw = async (query: string, params?: any[]): Promise<any[][]> => {\n // This is a workaround, we don't support multiple columns of the same name\n const results = await execute(query, params);\n return results.rows?._array.map((row) => Object.values(row)) ?? [];\n };\n\n return {\n getAll,\n getOptional,\n get,\n executeRaw,\n execute\n };\n }\n\n execute(query: string, params?: any[]): Promise<QueryResult> {\n return this.writeLock((tx) => tx.execute(query, params));\n }\n\n executeRaw(query: string, params?: any[]): Promise<any[][]> {\n return this.writeLock((tx) => tx.executeRaw(query, params));\n }\n\n async executeBatch(query: string, params: any[][] = []): Promise<QueryResult> {\n return this.writeLock(async (tx) => {\n let result = await this.writeConnection.executeSet(\n params.map((param) => ({\n statement: query,\n values: param\n }))\n );\n\n return {\n rowsAffected: result.changes?.changes ?? 0,\n insertId: result.changes?.lastId\n };\n });\n }\n\n readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.lock.acquire('read_lock', async () => {\n await this.initializedPromise;\n return await fn(this.generateLockContext(this.readConnection));\n });\n }\n\n readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.readLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n\n writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.lock.acquire('write_lock', async () => {\n await this.initializedPromise;\n const result = await fn(this.generateLockContext(this.writeConnection));\n\n // Fetch table updates\n const updates = await this.writeConnection.query(\"SELECT powersync_update_hooks('get') AS table_name\");\n const jsonUpdates = updates.values?.[0];\n if (!jsonUpdates || !jsonUpdates.table_name) {\n throw new Error('Could not fetch table updates');\n }\n const notification: BatchedUpdateNotification = {\n rawUpdates: [],\n tables: JSON.parse(jsonUpdates.table_name),\n groupedUpdates: {}\n };\n this.iterateListeners((l) => l.tablesUpdated?.(notification));\n return result;\n });\n }\n\n writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T> {\n return this.writeLock(async (ctx) => {\n return this.internalTransaction(ctx, fn);\n });\n }\n\n refreshSchema(): Promise<void> {\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\n getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {\n return this.readLock((tx) => tx.getAll<T>(sql, parameters));\n }\n\n getOptional<T>(sql: string, parameters?: any[]): Promise<T | null> {\n return this.readLock((tx) => tx.getOptional<T>(sql, parameters));\n }\n\n get<T>(sql: string, parameters?: any[]): Promise<T> {\n return this.readLock((tx) => tx.get<T>(sql, parameters));\n }\n\n protected async internalTransaction<T>(ctx: LockContext, fn: (tx: Transaction) => Promise<T>): Promise<T> {\n let finalized = false;\n const commit = async (): Promise<QueryResult> => {\n if (finalized) {\n return { rowsAffected: 0 };\n }\n finalized = true;\n return ctx.execute('COMMIT');\n };\n const rollback = async (): Promise<QueryResult> => {\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({\n ...ctx,\n commit,\n rollback\n });\n await commit();\n return result;\n } catch (ex) {\n try {\n await rollback();\n } catch (ex2) {\n // In rare cases, a rollback may fail.\n // Safe to ignore.\n }\n throw ex;\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter';
1
+ import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter.js';
2
2
  var SqliteSynchronous;
3
3
  (function (SqliteSynchronous) {
4
4
  SqliteSynchronous["normal"] = "NORMAL";
@@ -1 +1 @@
1
- {"version":3,"file":"CapacitorSQLiteOpenFactory.js","sourceRoot":"","sources":["../../../src/adapter/CapacitorSQLiteOpenFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,IAAK,iBAIJ;AAJD,WAAK,iBAAiB;IACpB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;IACb,gCAAW,CAAA;AACb,CAAC,EAJI,iBAAiB,KAAjB,iBAAiB,QAIrB;AA4BD,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACtE,gBAAgB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IACjC,WAAW,EAAE,iBAAiB,CAAC,MAAM;IACrC,WAAW,EAAE,EAAE,GAAG,IAAI;CACvB,CAAC;AAEF,MAAM,OAAO,0BAA0B;IACrC,YAAsB,OAA0C;QAA1C,YAAO,GAAP,OAAO,CAAmC;IAAG,CAAC;IAEpE,MAAM;QACJ,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { DBAdapter, SQLOpenFactory, SQLOpenOptions } from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter';\n\nenum SqliteSynchronous {\n normal = 'NORMAL',\n full = 'FULL',\n off = 'OFF'\n}\n\nexport interface CapacitorSQLiteOptions {\n /**\n * Journal/WAL size limit. Defaults to 6MB.\n * The WAL may grow larger than this limit during writes, but SQLite will\n * attempt to truncate the file afterwards.\n */\n journalSizeLimit?: number;\n\n /**\n * SQLite synchronous flag. Defaults to [SqliteSynchronous.normal], which\n * is safe for WAL mode.\n */\n synchronous?: SqliteSynchronous;\n\n /**\n * Maximum SQLite cache size. Defaults to 50MB.\n *\n * For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size\n */\n cacheSizeKb?: number;\n}\n\nexport interface CapacitorSQLiteOpenFactoryOptions extends SQLOpenOptions {\n sqliteOptions?: CapacitorSQLiteOptions;\n}\n\nexport const DEFAULT_SQLITE_OPTIONS: Required<CapacitorSQLiteOptions> = {\n journalSizeLimit: 6 * 1024 * 1024,\n synchronous: SqliteSynchronous.normal,\n cacheSizeKb: 50 * 1024\n};\n\nexport class CapacitorSQLiteOpenFactory implements SQLOpenFactory {\n constructor(protected options: CapacitorSQLiteOpenFactoryOptions) {}\n\n openDB(): DBAdapter {\n return new CapacitorSQLiteAdapter(this.options);\n }\n}\n"]}
1
+ {"version":3,"file":"CapacitorSQLiteOpenFactory.js","sourceRoot":"","sources":["../../../src/adapter/CapacitorSQLiteOpenFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,IAAK,iBAIJ;AAJD,WAAK,iBAAiB;IACpB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;IACb,gCAAW,CAAA;AACb,CAAC,EAJI,iBAAiB,KAAjB,iBAAiB,QAIrB;AA4BD,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACtE,gBAAgB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IACjC,WAAW,EAAE,iBAAiB,CAAC,MAAM;IACrC,WAAW,EAAE,EAAE,GAAG,IAAI;CACvB,CAAC;AAEF,MAAM,OAAO,0BAA0B;IACrC,YAAsB,OAA0C;QAA1C,YAAO,GAAP,OAAO,CAAmC;IAAG,CAAC;IAEpE,MAAM;QACJ,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { DBAdapter, SQLOpenFactory, SQLOpenOptions } from '@powersync/web';\nimport { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter.js';\n\nenum SqliteSynchronous {\n normal = 'NORMAL',\n full = 'FULL',\n off = 'OFF'\n}\n\nexport interface CapacitorSQLiteOptions {\n /**\n * Journal/WAL size limit. Defaults to 6MB.\n * The WAL may grow larger than this limit during writes, but SQLite will\n * attempt to truncate the file afterwards.\n */\n journalSizeLimit?: number;\n\n /**\n * SQLite synchronous flag. Defaults to [SqliteSynchronous.normal], which\n * is safe for WAL mode.\n */\n synchronous?: SqliteSynchronous;\n\n /**\n * Maximum SQLite cache size. Defaults to 50MB.\n *\n * For details, see: https://www.sqlite.org/pragma.html#pragma_cache_size\n */\n cacheSizeKb?: number;\n}\n\nexport interface CapacitorSQLiteOpenFactoryOptions extends SQLOpenOptions {\n sqliteOptions?: CapacitorSQLiteOptions;\n}\n\nexport const DEFAULT_SQLITE_OPTIONS: Required<CapacitorSQLiteOptions> = {\n journalSizeLimit: 6 * 1024 * 1024,\n synchronous: SqliteSynchronous.normal,\n cacheSizeKb: 50 * 1024\n};\n\nexport class CapacitorSQLiteOpenFactory implements SQLOpenFactory {\n constructor(protected options: CapacitorSQLiteOpenFactoryOptions) {}\n\n openDB(): DBAdapter {\n return new CapacitorSQLiteAdapter(this.options);\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';
2
- export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory';
3
- export { PowerSyncDatabase } from './PowerSyncDatabase';
1
+ export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';
2
+ export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory.js';
3
+ export { PowerSyncDatabase } from './PowerSyncDatabase.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';
2
- export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory';
3
- export { PowerSyncDatabase } from './PowerSyncDatabase';
1
+ export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';
2
+ export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory.js';
3
+ export { PowerSyncDatabase } from './PowerSyncDatabase.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';\nexport { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory';\nexport { PowerSyncDatabase } from './PowerSyncDatabase';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';\nexport { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory.js';\nexport { PowerSyncDatabase } from './PowerSyncDatabase.js';\n\n"]}
@@ -1,2 +1,2 @@
1
- import { PowerSyncPlugin } from './PowerSyncPlugin';
1
+ import { PowerSyncPlugin } from './PowerSyncPlugin.js';
2
2
  export declare const PowerSyncCore: PowerSyncPlugin;
@@ -1,5 +1,5 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
2
  export const PowerSyncCore = registerPlugin('PowerSync', {
3
- web: () => import('./web').then((m) => new m.PowerSyncWeb())
3
+ web: () => import('./web.js').then((m) => new m.PowerSyncWeb())
4
4
  });
5
5
  //# sourceMappingURL=PowerSyncCore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PowerSyncCore.js","sourceRoot":"","sources":["../../../src/plugin/PowerSyncCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAkB,WAAW,EAAE;IACxE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAC7D,CAAC,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\nimport { PowerSyncPlugin } from './PowerSyncPlugin';\n\nexport const PowerSyncCore = registerPlugin<PowerSyncPlugin>('PowerSync', {\n web: () => import('./web').then((m) => new m.PowerSyncWeb())\n});\n"]}
1
+ {"version":3,"file":"PowerSyncCore.js","sourceRoot":"","sources":["../../../src/plugin/PowerSyncCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAkB,WAAW,EAAE;IACxE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAChE,CAAC,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\nimport { PowerSyncPlugin } from './PowerSyncPlugin.js';\n\nexport const PowerSyncCore = registerPlugin<PowerSyncPlugin>('PowerSync', {\n web: () => import('./web.js').then((m) => new m.PowerSyncWeb())\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin';
2
+ import type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin.js';
3
3
  export declare class PowerSyncWeb extends WebPlugin implements PowerSyncPlugin {
4
4
  registerCore(): Promise<RegistrationResponse>;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../../src/plugin/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin';\n\nexport class PowerSyncWeb extends WebPlugin implements PowerSyncPlugin {\n async registerCore(): Promise<RegistrationResponse> {\n throw new Error('This code path is not supported on web.');\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../../src/plugin/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin.js';\n\nexport class PowerSyncWeb extends WebPlugin implements PowerSyncPlugin {\n async registerCore(): Promise<RegistrationResponse> {\n throw new Error('This code path is not supported on web.');\n }\n}\n"]}
@@ -365,6 +365,17 @@ class PowerSyncDatabase extends web$1.PowerSyncDatabase {
365
365
  return super.openDBAdapter(options);
366
366
  }
367
367
  }
368
+ generateTriggerManagerConfig() {
369
+ const config = super.generateTriggerManagerConfig();
370
+ if (this.isNativeCapacitorPlatform) {
371
+ /**
372
+ * We usually only ever have a single tab for capacitor.
373
+ * Avoiding navigator locks allows insecure contexts (during development).
374
+ */
375
+ config.claimManager = web$1.MEMORY_TRIGGER_CLAIM_MANAGER;
376
+ }
377
+ return config;
378
+ }
368
379
  runExclusive(cb) {
369
380
  if (this.isNativeCapacitorPlatform) {
370
381
  // Use mutex for mobile platforms.
@@ -412,4 +423,4 @@ var web = /*#__PURE__*/Object.freeze({
412
423
  exports.CapacitorSQLiteAdapter = CapacitorSQLiteAdapter;
413
424
  exports.CapacitorSQLiteOpenFactory = CapacitorSQLiteOpenFactory;
414
425
  exports.PowerSyncDatabase = PowerSyncDatabase;
415
- //# sourceMappingURL=plugin.cjs.js.map
426
+ //# sourceMappingURL=plugin.cjs.map
@@ -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 } from '@powersync/web';\nimport Lock from 'async-lock';\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.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 { 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","sqlite","SQLiteConnection","CapacitorSQLite","Capacitor","AbstractStream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ptions, SQLOpenFactory, DBAdapter, BaseObserver, DBAdapterListener, LockContext, QueryResult, DBLockOptions, Transaction, PowerSyncDatabase as PowerSyncDatabase$1, WebPowerSyncDatabaseOptionsWithSettings, TriggerManagerConfig, PowerSyncBackendConnector, RequiredAdditionalConnectionOptions, StreamingSyncImplementation } from '@powersync/web';
3
+ import Lock from 'async-lock';
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 lock: Lock;
50
+ constructor(options: CapacitorSQLiteOpenFactoryOptions);
51
+ protected get writeConnection(): SQLiteDBConnection;
52
+ protected get readConnection(): SQLiteDBConnection;
53
+ get name(): string;
54
+ private init;
55
+ close(): Promise<void>;
56
+ protected generateLockContext(db: SQLiteDBConnection): LockContext;
57
+ execute(query: string, params?: any[]): Promise<QueryResult>;
58
+ executeRaw(query: string, params?: any[]): Promise<any[][]>;
59
+ executeBatch(query: string, params?: any[][]): Promise<QueryResult>;
60
+ readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
61
+ readTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
62
+ writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
63
+ writeTransaction<T>(fn: (tx: Transaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
64
+ refreshSchema(): Promise<void>;
65
+ getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
66
+ getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
67
+ get<T>(sql: string, parameters?: any[]): Promise<T>;
68
+ protected internalTransaction<T>(ctx: LockContext, fn: (tx: Transaction) => Promise<T>): Promise<T>;
69
+ }
70
+
71
+ /**
72
+ * PowerSyncDatabase class for managing database connections and sync implementations.
73
+ * This extends the WebPowerSyncDatabase to provide platform-specific implementations
74
+ * for Capacitor environments (iOS and Android).
75
+ *
76
+ * @experimental
77
+ * @alpha
78
+ */
79
+ declare class PowerSyncDatabase extends PowerSyncDatabase$1 {
80
+ protected get isNativeCapacitorPlatform(): boolean;
81
+ protected openDBAdapter(options: WebPowerSyncDatabaseOptionsWithSettings): DBAdapter;
82
+ protected generateTriggerManagerConfig(): TriggerManagerConfig;
83
+ protected runExclusive<T>(cb: () => Promise<T>): Promise<T>;
84
+ protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): StreamingSyncImplementation;
85
+ }
86
+
87
+ export { CapacitorSQLiteAdapter, CapacitorSQLiteOpenFactory, PowerSyncDatabase };
package/dist/plugin.js CHANGED
@@ -361,6 +361,17 @@ var capacitorPowerSync = (function (exports, sqlite, core, web$1, Lock) {
361
361
  return super.openDBAdapter(options);
362
362
  }
363
363
  }
364
+ generateTriggerManagerConfig() {
365
+ const config = super.generateTriggerManagerConfig();
366
+ if (this.isNativeCapacitorPlatform) {
367
+ /**
368
+ * We usually only ever have a single tab for capacitor.
369
+ * Avoiding navigator locks allows insecure contexts (during development).
370
+ */
371
+ config.claimManager = web$1.MEMORY_TRIGGER_CLAIM_MANAGER;
372
+ }
373
+ return config;
374
+ }
364
375
  runExclusive(cb) {
365
376
  if (this.isNativeCapacitorPlatform) {
366
377
  // Use mutex for mobile platforms.
@@ -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,IAAI,MAAM,GAAG;IACb,QAAQ,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO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CAAC,CAAC,kFAAkF,CAAC,CAAC;IACtH,YAAY;IACZ,YAAY,MAAM,MAAM,GAAG,IAAIG,eAAS,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC;IAChE,YAAY,OAAO,IAAI,oCAAoC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,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;IACzQ,oBAAoB,MAAM,IAAI,CAAC,YAAY,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;;ICjEO,MAAM,YAAY,SAASC,cAAS,CAAC;IAC5C,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;IAClE,IAAI;IACJ;;;;;;;;;;;;;;;;;"}
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.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 } from '@powersync/web';\nimport Lock from 'async-lock';\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.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 { 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","sqlite","SQLiteConnection","CapacitorSQLite","Capacitor","AbstractStreamingSyncImplementation","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;IACh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MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,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;IACzQ,oBAAoB,MAAM,IAAI,CAAC,YAAY,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.3.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",
@@ -44,16 +57,18 @@
44
57
  "@ionic/eslint-config": "^0.4.0",
45
58
  "@ionic/prettier-config": "^4.0.0",
46
59
  "@ionic/swiftlint-config": "^2.0.0",
60
+ "@types/async-lock": "^1.4.0",
47
61
  "eslint": "^8.57.0",
48
- "prettier": "^3.4.2",
62
+ "prettier": "^3.7.4",
49
63
  "prettier-plugin-java": "^2.6.6",
50
64
  "rimraf": "^6.0.1",
51
- "rollup": "^4.30.1",
65
+ "rollup": "^4.52.5",
66
+ "rollup-plugin-dts": "^6.2.1",
52
67
  "swiftlint": "^2.0.0"
53
68
  },
54
69
  "peerDependencies": {
55
70
  "@capacitor-community/sqlite": "^7.0.2",
56
- "@powersync/web": "^1.30.0"
71
+ "@powersync/web": "^1.32.0"
57
72
  },
58
73
  "swiftlint": "@ionic/swiftlint-config",
59
74
  "capacitor": {
@@ -67,7 +82,7 @@
67
82
  }
68
83
  },
69
84
  "dependencies": {
70
- "async-lock": "^1.4.0"
85
+ "async-lock": "^1.4.1"
71
86
  },
72
87
  "scripts": {
73
88
  "verify": "pnpm verify:ios && pnpm verify:android && pnpm verify:web",
@@ -84,6 +99,6 @@
84
99
  "build:prod": "pnpm build",
85
100
  "clean": "rimraf ./dist",
86
101
  "watch": "tsc --watch",
87
- "test:exports": "attw --pack ."
102
+ "test:exports": "attw --pack --profile=esm-only ."
88
103
  }
89
104
  }
@@ -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.
@@ -12,9 +12,9 @@ import {
12
12
  Transaction
13
13
  } from '@powersync/web';
14
14
  import Lock from 'async-lock';
15
- import { PowerSyncCore } from '../plugin/PowerSyncCore';
16
- import { messageForErrorCode } from '../plugin/PowerSyncPlugin';
17
- import { CapacitorSQLiteOpenFactoryOptions, DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory';
15
+ import { PowerSyncCore } from '../plugin/PowerSyncCore.js';
16
+ import { messageForErrorCode } from '../plugin/PowerSyncPlugin.js';
17
+ import { CapacitorSQLiteOpenFactoryOptions, DEFAULT_SQLITE_OPTIONS } from './CapacitorSQLiteOpenFactory.js';
18
18
  /**
19
19
  * Monitors the execution time of a query and logs it to the performance timeline.
20
20
  */
@@ -1,5 +1,5 @@
1
1
  import { DBAdapter, SQLOpenFactory, SQLOpenOptions } from '@powersync/web';
2
- import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter';
2
+ import { CapacitorSQLiteAdapter } from './CapacitorSQLiteAdapter.js';
3
3
 
4
4
  enum SqliteSynchronous {
5
5
  normal = 'NORMAL',
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter';
2
- export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory';
3
- export { PowerSyncDatabase } from './PowerSyncDatabase';
1
+ export { CapacitorSQLiteAdapter } from './adapter/CapacitorSQLiteAdapter.js';
2
+ export { CapacitorSQLiteOpenFactory } from './adapter/CapacitorSQLiteOpenFactory.js';
3
+ export { PowerSyncDatabase } from './PowerSyncDatabase.js';
4
+
@@ -1,6 +1,6 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
- import { PowerSyncPlugin } from './PowerSyncPlugin';
2
+ import { PowerSyncPlugin } from './PowerSyncPlugin.js';
3
3
 
4
4
  export const PowerSyncCore = registerPlugin<PowerSyncPlugin>('PowerSync', {
5
- web: () => import('./web').then((m) => new m.PowerSyncWeb())
5
+ web: () => import('./web.js').then((m) => new m.PowerSyncWeb())
6
6
  });
package/src/plugin/web.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
 
3
- import type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin';
3
+ import type { PowerSyncPlugin, RegistrationResponse } from './PowerSyncPlugin.js';
4
4
 
5
5
  export class PowerSyncWeb extends WebPlugin implements PowerSyncPlugin {
6
6
  async registerCore(): Promise<RegistrationResponse> {
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.cjs.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":";;;;;;;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;;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,sDAA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