@powersync/react-native 0.0.0-dev-20260128170746 → 0.0.0-dev-20260202160933
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.
- package/package.json +4 -4
- package/dist/index.js +0 -19562
- package/dist/index.js.map +0 -1
- package/lib/db/PowerSyncDatabase.d.ts +0 -25
- package/lib/db/PowerSyncDatabase.js +0 -48
- package/lib/db/PowerSyncDatabase.js.map +0 -1
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.d.ts +0 -41
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.js +0 -123
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.js.map +0 -1
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.d.ts +0 -19
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js +0 -34
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js.map +0 -1
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.d.ts +0 -9
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js +0 -45
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -10
- package/lib/index.js.map +0 -1
- package/lib/sync/bucket/ReactNativeBucketStorageAdapter.d.ts +0 -4
- package/lib/sync/bucket/ReactNativeBucketStorageAdapter.js +0 -23
- package/lib/sync/bucket/ReactNativeBucketStorageAdapter.js.map +0 -1
- package/lib/sync/stream/ReactNativeRemote.d.ts +0 -12
- package/lib/sync/stream/ReactNativeRemote.js +0 -71
- package/lib/sync/stream/ReactNativeRemote.js.map +0 -1
- package/lib/sync/stream/ReactNativeStreamingSyncImplementation.d.ts +0 -11
- package/lib/sync/stream/ReactNativeStreamingSyncImplementation.js +0 -43
- package/lib/sync/stream/ReactNativeStreamingSyncImplementation.js.map +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabase, AbstractStreamingSyncImplementation, BucketStorageAdapter, DBAdapter, PowerSyncBackendConnector, PowerSyncDatabaseOptionsWithSettings, type RequiredAdditionalConnectionOptions } from '@powersync/common';
|
|
2
|
-
/**
|
|
3
|
-
* A PowerSync database which provides SQLite functionality
|
|
4
|
-
* which is automatically synced.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* export const db = new PowerSyncDatabase({
|
|
9
|
-
* schema: AppSchema,
|
|
10
|
-
* database: {
|
|
11
|
-
* dbFilename: 'example.db'
|
|
12
|
-
* }
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
17
|
-
_initialize(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Opens a DBAdapter using React Native Quick SQLite as the
|
|
20
|
-
* default SQLite open factory.
|
|
21
|
-
*/
|
|
22
|
-
protected openDBAdapter(options: PowerSyncDatabaseOptionsWithSettings): DBAdapter;
|
|
23
|
-
protected generateBucketStorageAdapter(): BucketStorageAdapter;
|
|
24
|
-
protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): AbstractStreamingSyncImplementation;
|
|
25
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabase } from '@powersync/common';
|
|
2
|
-
import { ReactNativeRemote } from '../sync/stream/ReactNativeRemote';
|
|
3
|
-
import { ReactNativeStreamingSyncImplementation } from '../sync/stream/ReactNativeStreamingSyncImplementation';
|
|
4
|
-
import { ReactNativeBucketStorageAdapter } from './../sync/bucket/ReactNativeBucketStorageAdapter';
|
|
5
|
-
import { ReactNativeQuickSqliteOpenFactory } from './adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
|
6
|
-
/**
|
|
7
|
-
* A PowerSync database which provides SQLite functionality
|
|
8
|
-
* which is automatically synced.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* export const db = new PowerSyncDatabase({
|
|
13
|
-
* schema: AppSchema,
|
|
14
|
-
* database: {
|
|
15
|
-
* dbFilename: 'example.db'
|
|
16
|
-
* }
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
21
|
-
async _initialize() { }
|
|
22
|
-
/**
|
|
23
|
-
* Opens a DBAdapter using React Native Quick SQLite as the
|
|
24
|
-
* default SQLite open factory.
|
|
25
|
-
*/
|
|
26
|
-
openDBAdapter(options) {
|
|
27
|
-
const defaultFactory = new ReactNativeQuickSqliteOpenFactory(options.database);
|
|
28
|
-
return defaultFactory.openDB();
|
|
29
|
-
}
|
|
30
|
-
generateBucketStorageAdapter() {
|
|
31
|
-
return new ReactNativeBucketStorageAdapter(this.database, this.logger);
|
|
32
|
-
}
|
|
33
|
-
generateSyncStreamImplementation(connector, options) {
|
|
34
|
-
const remote = new ReactNativeRemote(connector, this.logger);
|
|
35
|
-
return new ReactNativeStreamingSyncImplementation({
|
|
36
|
-
...options,
|
|
37
|
-
adapter: this.bucketStorageAdapter,
|
|
38
|
-
remote,
|
|
39
|
-
uploadCrud: async () => {
|
|
40
|
-
await this.waitForReady();
|
|
41
|
-
await connector.uploadData(this);
|
|
42
|
-
},
|
|
43
|
-
identifier: this.database.name,
|
|
44
|
-
logger: this.logger
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=PowerSyncDatabase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/db/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAO1B,M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Options, QueryResult } from '@powersync/common';
|
|
2
|
-
import type { QuickSQLiteConnection, LockContext as RNQSLockContext } from '@journeyapps/react-native-quick-sqlite';
|
|
3
|
-
/**
|
|
4
|
-
* Adapter for React Native Quick SQLite
|
|
5
|
-
*/
|
|
6
|
-
export declare class RNQSDBAdapter extends BaseObserver<DBAdapterListener> implements DBAdapter {
|
|
7
|
-
protected baseDB: QuickSQLiteConnection;
|
|
8
|
-
name: string;
|
|
9
|
-
getAll: <T>(sql: string, parameters?: any[]) => Promise<T[]>;
|
|
10
|
-
getOptional: <T>(sql: string, parameters?: any[]) => Promise<T | null>;
|
|
11
|
-
get: <T>(sql: string, parameters?: any[]) => Promise<T>;
|
|
12
|
-
constructor(baseDB: QuickSQLiteConnection, name: string);
|
|
13
|
-
close(): void;
|
|
14
|
-
readLock<T>(fn: (tx: PowerSyncLockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
15
|
-
readTransaction<T>(fn: (tx: PowerSyncTransaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
16
|
-
writeLock<T>(fn: (tx: PowerSyncLockContext) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
17
|
-
writeTransaction<T>(fn: (tx: PowerSyncTransaction) => Promise<T>, options?: DBLockOptions): Promise<T>;
|
|
18
|
-
execute(query: string, params?: any[]): Promise<import("@journeyapps/react-native-quick-sqlite").QueryResult>;
|
|
19
|
-
/**
|
|
20
|
-
* 'executeRaw' is not implemented in RNQS, this falls back to 'execute'.
|
|
21
|
-
*/
|
|
22
|
-
executeRaw(query: string, params?: any[]): Promise<any[][]>;
|
|
23
|
-
executeBatch(query: string, params?: any[][]): Promise<QueryResult>;
|
|
24
|
-
generateContext<T extends RNQSLockContext>(ctx: T): T & {
|
|
25
|
-
executeRaw: (sql: string, params?: any[]) => Promise<unknown[][]>;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* This provides a top-level read only execute method which is executed inside a read-lock.
|
|
29
|
-
* This is necessary since the high level `execute` method uses a write-lock under
|
|
30
|
-
* the hood. Helper methods such as `get`, `getAll` and `getOptional` are read only,
|
|
31
|
-
* and should use this method.
|
|
32
|
-
*/
|
|
33
|
-
private readOnlyExecute;
|
|
34
|
-
/**
|
|
35
|
-
* Adds DB get utils to lock contexts and transaction contexts
|
|
36
|
-
* @param tx
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
private generateDBHelpers;
|
|
40
|
-
refreshSchema(): Promise<void>;
|
|
41
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { BaseObserver } from '@powersync/common';
|
|
2
|
-
/**
|
|
3
|
-
* Adapter for React Native Quick SQLite
|
|
4
|
-
*/
|
|
5
|
-
export class RNQSDBAdapter extends BaseObserver {
|
|
6
|
-
baseDB;
|
|
7
|
-
name;
|
|
8
|
-
getAll;
|
|
9
|
-
getOptional;
|
|
10
|
-
get;
|
|
11
|
-
constructor(baseDB, name) {
|
|
12
|
-
super();
|
|
13
|
-
this.baseDB = baseDB;
|
|
14
|
-
this.name = name;
|
|
15
|
-
// link table update commands
|
|
16
|
-
baseDB.registerTablesChangedHook((update) => {
|
|
17
|
-
this.iterateListeners((cb) => cb.tablesUpdated?.(update));
|
|
18
|
-
});
|
|
19
|
-
const topLevelUtils = this.generateDBHelpers({
|
|
20
|
-
// Arrow function binds `this` for use in readOnlyExecute
|
|
21
|
-
execute: (sql, params) => this.readOnlyExecute(sql, params)
|
|
22
|
-
});
|
|
23
|
-
// Only assigning get helpers
|
|
24
|
-
this.getAll = topLevelUtils.getAll;
|
|
25
|
-
this.getOptional = topLevelUtils.getOptional;
|
|
26
|
-
this.get = topLevelUtils.get;
|
|
27
|
-
}
|
|
28
|
-
close() {
|
|
29
|
-
return this.baseDB.close();
|
|
30
|
-
}
|
|
31
|
-
readLock(fn, options) {
|
|
32
|
-
return this.baseDB.readLock((dbTx) => fn(this.generateDBHelpers(this.generateContext(dbTx))), options);
|
|
33
|
-
}
|
|
34
|
-
readTransaction(fn, options) {
|
|
35
|
-
return this.baseDB.readTransaction((dbTx) => fn(this.generateDBHelpers(this.generateContext(dbTx))), options);
|
|
36
|
-
}
|
|
37
|
-
writeLock(fn, options) {
|
|
38
|
-
return this.baseDB.writeLock((dbTx) => fn(this.generateDBHelpers(this.generateContext(dbTx))), options);
|
|
39
|
-
}
|
|
40
|
-
writeTransaction(fn, options) {
|
|
41
|
-
return this.baseDB.writeTransaction((dbTx) => fn(this.generateDBHelpers(this.generateContext(dbTx))), options);
|
|
42
|
-
}
|
|
43
|
-
execute(query, params) {
|
|
44
|
-
return this.baseDB.execute(query, params);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 'executeRaw' is not implemented in RNQS, this falls back to 'execute'.
|
|
48
|
-
*/
|
|
49
|
-
async executeRaw(query, params) {
|
|
50
|
-
const result = await this.baseDB.execute(query, params);
|
|
51
|
-
const rows = result.rows?._array ?? [];
|
|
52
|
-
return rows.map((row) => Object.values(row));
|
|
53
|
-
}
|
|
54
|
-
async executeBatch(query, params = []) {
|
|
55
|
-
const commands = [];
|
|
56
|
-
for (let i = 0; i < params.length; i++) {
|
|
57
|
-
commands.push([query, params[i]]);
|
|
58
|
-
}
|
|
59
|
-
const result = await this.baseDB.executeBatch(commands);
|
|
60
|
-
return {
|
|
61
|
-
rowsAffected: result.rowsAffected ? result.rowsAffected : 0
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
generateContext(ctx) {
|
|
65
|
-
return {
|
|
66
|
-
...ctx,
|
|
67
|
-
// 'executeRaw' is not implemented in RNQS, this falls back to 'execute'.
|
|
68
|
-
executeRaw: async (sql, params) => {
|
|
69
|
-
const result = await ctx.execute(sql, params);
|
|
70
|
-
const rows = result.rows?._array ?? [];
|
|
71
|
-
return rows.map((row) => Object.values(row));
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* This provides a top-level read only execute method which is executed inside a read-lock.
|
|
77
|
-
* This is necessary since the high level `execute` method uses a write-lock under
|
|
78
|
-
* the hood. Helper methods such as `get`, `getAll` and `getOptional` are read only,
|
|
79
|
-
* and should use this method.
|
|
80
|
-
*/
|
|
81
|
-
readOnlyExecute(sql, params) {
|
|
82
|
-
return this.baseDB.readLock((ctx) => ctx.execute(sql, params));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Adds DB get utils to lock contexts and transaction contexts
|
|
86
|
-
* @param tx
|
|
87
|
-
* @returns
|
|
88
|
-
*/
|
|
89
|
-
generateDBHelpers(tx) {
|
|
90
|
-
return {
|
|
91
|
-
...tx,
|
|
92
|
-
/**
|
|
93
|
-
* Execute a read-only query and return results
|
|
94
|
-
*/
|
|
95
|
-
getAll: async (sql, parameters) => {
|
|
96
|
-
const res = await tx.execute(sql, parameters);
|
|
97
|
-
return res.rows?._array ?? [];
|
|
98
|
-
},
|
|
99
|
-
/**
|
|
100
|
-
* Execute a read-only query and return the first result, or null if the ResultSet is empty.
|
|
101
|
-
*/
|
|
102
|
-
getOptional: async (sql, parameters) => {
|
|
103
|
-
const res = await tx.execute(sql, parameters);
|
|
104
|
-
return res.rows?.item(0) ?? null;
|
|
105
|
-
},
|
|
106
|
-
/**
|
|
107
|
-
* Execute a read-only query and return the first result, error if the ResultSet is empty.
|
|
108
|
-
*/
|
|
109
|
-
get: async (sql, parameters) => {
|
|
110
|
-
const res = await tx.execute(sql, parameters);
|
|
111
|
-
const first = res.rows?.item(0);
|
|
112
|
-
if (!first) {
|
|
113
|
-
throw new Error('Result set is empty');
|
|
114
|
-
}
|
|
115
|
-
return first;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
async refreshSchema() {
|
|
120
|
-
await this.baseDB.refreshSchema();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=RNQSDBAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RNQSDBAdapter.js","source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L,GAAG,EAAE;YACL;;eAEG;YACH,MAAM,EAAE,KAAK,EAAK,GAAW,EAAE,UAAkB,EAAgB,EAAE;gBACjE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC9C,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC;YAChC,CAAC;YAED;;eAEG;YACH,WAAW,EAAE,KAAK,EAAK,GAAW,EAAE,UAAkB,EAAqB,EAAE;gBAC3E,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC9C,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YACnC,CAAC;YAED;;eAEG;YACH,GAAG,EAAE,KAAK,EAAK,GAAW,EAAE,UAAkB,EAAc,EAAE;gBAC5D,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;gBACzC,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, DBAdapter, PowerSyncDatabaseOptions, PowerSyncOpenFactoryOptions, SQLOpenFactory } from '@powersync/common';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated {@link PowerSyncDatabase} can now be constructed directly
|
|
4
|
-
* @example
|
|
5
|
-
* ```typescript
|
|
6
|
-
* const powersync = new PowerSyncDatabase({
|
|
7
|
-
* database: {
|
|
8
|
-
* dbFileName: 'powersync.db'
|
|
9
|
-
* }
|
|
10
|
-
* });
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
|
|
14
|
-
protected instanceGenerated: boolean;
|
|
15
|
-
protected sqlOpenFactory: SQLOpenFactory;
|
|
16
|
-
constructor(options: PowerSyncOpenFactoryOptions);
|
|
17
|
-
protected openDB(): DBAdapter;
|
|
18
|
-
generateInstance(options: PowerSyncDatabaseOptions): AbstractPowerSyncDatabase;
|
|
19
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabaseOpenFactory } from '@powersync/common';
|
|
2
|
-
import { PowerSyncDatabase } from '../../../db/PowerSyncDatabase';
|
|
3
|
-
import { ReactNativeQuickSqliteOpenFactory } from './ReactNativeQuickSQLiteOpenFactory';
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated {@link PowerSyncDatabase} can now be constructed directly
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const powersync = new PowerSyncDatabase({
|
|
9
|
-
* database: {
|
|
10
|
-
* dbFileName: 'powersync.db'
|
|
11
|
-
* }
|
|
12
|
-
* });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
|
|
16
|
-
instanceGenerated;
|
|
17
|
-
sqlOpenFactory;
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super(options);
|
|
20
|
-
this.instanceGenerated = false;
|
|
21
|
-
this.sqlOpenFactory = new ReactNativeQuickSqliteOpenFactory(options);
|
|
22
|
-
}
|
|
23
|
-
openDB() {
|
|
24
|
-
return this.sqlOpenFactory.openDB();
|
|
25
|
-
}
|
|
26
|
-
generateInstance(options) {
|
|
27
|
-
if (this.instanceGenerated) {
|
|
28
|
-
this.options.logger?.warn('Generating multiple PowerSync instances can sometimes cause unexpected results.');
|
|
29
|
-
}
|
|
30
|
-
this.instanceGenerated = true;
|
|
31
|
-
return new PowerSyncDatabase(options);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=RNQSDBOpenFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RNQSDBOpenFactory.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oCAAoC,EAKrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gCAAiC,SAAQ,oCAAoC;IAC9E,iBAAiB,CAAU;IAC3B,cAAc,CAAiB;IAEzC,YAAY,OAAoC;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,iCAAiC,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;IAES,MAAM;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;IACtC,CAAC;IAED,gBAAgB,CAAC,OAAiC;QAChD,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,iFAAiF,CAAC,CAAC;QAC/G,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DBAdapter, SQLOpenFactory, SQLOpenOptions } from '@powersync/common';
|
|
2
|
-
/**
|
|
3
|
-
* Opens a SQLite connection using React Native Quick SQLite
|
|
4
|
-
*/
|
|
5
|
-
export declare class ReactNativeQuickSqliteOpenFactory implements SQLOpenFactory {
|
|
6
|
-
protected options: SQLOpenOptions;
|
|
7
|
-
constructor(options: SQLOpenOptions);
|
|
8
|
-
openDB(): DBAdapter;
|
|
9
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { RNQSDBAdapter } from './RNQSDBAdapter';
|
|
2
|
-
/**
|
|
3
|
-
* Opens a SQLite connection using React Native Quick SQLite
|
|
4
|
-
*/
|
|
5
|
-
export class ReactNativeQuickSqliteOpenFactory {
|
|
6
|
-
options;
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
}
|
|
10
|
-
openDB() {
|
|
11
|
-
/**
|
|
12
|
-
* React Native Quick SQLite opens files relative to the `Documents`dir on iOS and the `Files`
|
|
13
|
-
* dir on Android. Locations need to be relative to those dirs using with dot ("../") notation
|
|
14
|
-
* to navigate up the directory tree.
|
|
15
|
-
* This simple adapter assumes any platform specific relative directory is already catered for
|
|
16
|
-
* in the options (if provided)
|
|
17
|
-
* https://github.com/margelo/react-native-quick-sqlite/blob/main/README.md#loading-existing-dbs
|
|
18
|
-
*/
|
|
19
|
-
try {
|
|
20
|
-
var rnqs = require('@journeyapps/react-native-quick-sqlite');
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
throw new Error(`Could not resolve @journeyapps/react-native-quick-sqlite.
|
|
24
|
-
To open databases with React Native Quick SQLite please install @journeyapps/react-native-quick-sqlite.`);
|
|
25
|
-
}
|
|
26
|
-
const { dbFilename } = this.options;
|
|
27
|
-
const openOptions = { location: this.options.dbLocation };
|
|
28
|
-
let DB;
|
|
29
|
-
try {
|
|
30
|
-
// Hot reloads can sometimes clear global JS state, but not close DB on native side
|
|
31
|
-
DB = rnqs.open(dbFilename, openOptions);
|
|
32
|
-
}
|
|
33
|
-
catch (ex) {
|
|
34
|
-
if (ex.message.includes('already open')) {
|
|
35
|
-
rnqs.QuickSQLite.close(dbFilename);
|
|
36
|
-
DB = rnqs.open(dbFilename, openOptions);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw ex;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return new RNQSDBAdapter(DB, this.options.dbFilename);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=ReactNativeQuickSQLiteOpenFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeQuickSQLiteOpenFactory.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,iCAAiC;IACtB;IAAtB,YAAsB,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAEjD,MAAM;QACJ;;;;;;;WAOG;QAEH,IAAI,CAAC;YACH,IAAI,IAAI,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC;wGACkF,CAAC,CAAC;QACtG,CAAC;QACD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACpC,MAAM,WAAW,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1D,IAAI,EAAE,CAAC;QACP,IAAI,CAAC;YACH,mFAAmF;YACnF,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACxC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACnC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAC1C,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACF"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from '@powersync/common';
|
|
2
|
-
export * from '@powersync/react';
|
|
3
|
-
export * from './db/PowerSyncDatabase';
|
|
4
|
-
export * from './db/adapters/react-native-quick-sqlite/RNQSDBAdapter';
|
|
5
|
-
export * from './db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory';
|
|
6
|
-
export * from './sync/stream/ReactNativeRemote';
|
|
7
|
-
export * from './sync/stream/ReactNativeStreamingSyncImplementation';
|
|
8
|
-
export * from './db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
package/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Re export to only require one import in client side code
|
|
2
|
-
export * from '@powersync/common';
|
|
3
|
-
export * from '@powersync/react';
|
|
4
|
-
export * from './db/PowerSyncDatabase';
|
|
5
|
-
export * from './db/adapters/react-native-quick-sqlite/RNQSDBAdapter';
|
|
6
|
-
export * from './db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory';
|
|
7
|
-
export * from './sync/stream/ReactNativeRemote';
|
|
8
|
-
export * from './sync/stream/ReactNativeStreamingSyncImplementation';
|
|
9
|
-
export * from './db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uDAAuD,CAAC;AACtE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,iCAAiC,CAAC;AAChD,cAAc,sDAAsD,CAAC;AACrE,cAAc,2EAA2E,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PowerSyncControlCommand, SqliteBucketStorage } from '@powersync/common';
|
|
2
|
-
export declare class ReactNativeBucketStorageAdapter extends SqliteBucketStorage {
|
|
3
|
-
control(op: PowerSyncControlCommand, payload: string | Uint8Array | ArrayBuffer | null): Promise<string>;
|
|
4
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SqliteBucketStorage } from '@powersync/common';
|
|
2
|
-
export class ReactNativeBucketStorageAdapter extends SqliteBucketStorage {
|
|
3
|
-
control(op, payload) {
|
|
4
|
-
if (payload instanceof Uint8Array) {
|
|
5
|
-
// RNQS doesn't accept Uint8Array arguments - convert to ArrayBuffer first.
|
|
6
|
-
payload = uint8ArrayToArrayBuffer(payload);
|
|
7
|
-
}
|
|
8
|
-
return super.control(op, payload);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function uint8ArrayToArrayBuffer(array) {
|
|
12
|
-
// SharedArrayBuffer isn't defined on ReactNative, so don't need to cater for that.
|
|
13
|
-
const arrayBuffer = array.buffer;
|
|
14
|
-
if (array.byteOffset == 0 && array.byteLength == arrayBuffer.byteLength) {
|
|
15
|
-
// No copying needed - can use ArrayBuffer as-is
|
|
16
|
-
return arrayBuffer;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
// Need to make a copy
|
|
20
|
-
return arrayBuffer.slice(array.byteOffset, array.byteOffset + array.byteLength);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=ReactNativeBucketStorageAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeBucketStorageAdapter.js","sourceRoot":"","sources":["../../../src/sync/bucket/ReactNativeBucketStorageAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEjF,MAAM,OAAO,+BAAgC,SAAQ,mBAAmB;IACtE,OAAO,CAAC,EAA2B,EAAE,OAAiD;QACpF,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;YAClC,2EAA2E;YAC3E,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;CACF;AAED,SAAS,uBAAuB,CAAC,KAAiB;IAChD,mFAAmF;IACnF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAqB,CAAC;IAChD,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;QACxE,gDAAgD;QAChD,OAAO,WAAW,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,sBAAsB;QACtB,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAClF,CAAC;AACH,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, DataStream, ILogger, RemoteConnector, SyncStreamOptions } from '@powersync/common';
|
|
2
|
-
import { TextDecoder } from 'text-encoding';
|
|
3
|
-
export declare const STREAMING_POST_TIMEOUT_MS = 30000;
|
|
4
|
-
export declare class ReactNativeRemote extends AbstractRemote {
|
|
5
|
-
protected connector: RemoteConnector;
|
|
6
|
-
protected logger: ILogger;
|
|
7
|
-
constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
|
|
8
|
-
getUserAgent(): string;
|
|
9
|
-
getBSON(): Promise<BSONImplementation>;
|
|
10
|
-
protected createTextDecoder(): TextDecoder;
|
|
11
|
-
postStreamRaw<T>(options: SyncStreamOptions, mapLine: (line: string) => T): Promise<DataStream<T>>;
|
|
12
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { AbstractRemote, DEFAULT_REMOTE_LOGGER, FetchImplementationProvider } from '@powersync/common';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
// Note docs for React Native https://github.com/mongodb/js-bson?tab=readme-ov-file#react-native
|
|
4
|
-
import { BSON } from 'bson';
|
|
5
|
-
import { TextDecoder } from 'text-encoding';
|
|
6
|
-
import { fetch } from 'react-native-fetch-api';
|
|
7
|
-
export const STREAMING_POST_TIMEOUT_MS = 30_000;
|
|
8
|
-
/**
|
|
9
|
-
* Directly imports fetch implementation from react-native-fetch-api.
|
|
10
|
-
* This removes the requirement for the global `fetch` to be overridden by
|
|
11
|
-
* a polyfill.
|
|
12
|
-
*/
|
|
13
|
-
class ReactNativeFetchProvider extends FetchImplementationProvider {
|
|
14
|
-
getFetch() {
|
|
15
|
-
return fetch.bind(globalThis);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export class ReactNativeRemote extends AbstractRemote {
|
|
19
|
-
connector;
|
|
20
|
-
logger;
|
|
21
|
-
constructor(connector, logger = DEFAULT_REMOTE_LOGGER, options) {
|
|
22
|
-
super(connector, logger, {
|
|
23
|
-
...(options ?? {}),
|
|
24
|
-
fetchImplementation: options?.fetchImplementation ?? new ReactNativeFetchProvider()
|
|
25
|
-
});
|
|
26
|
-
this.connector = connector;
|
|
27
|
-
this.logger = logger;
|
|
28
|
-
}
|
|
29
|
-
getUserAgent() {
|
|
30
|
-
return [
|
|
31
|
-
super.getUserAgent(),
|
|
32
|
-
`powersync-react-native`,
|
|
33
|
-
`react-native/${Platform.constants.reactNativeVersion.major}.${Platform.constants.reactNativeVersion.minor}`,
|
|
34
|
-
`${Platform.OS}/${Platform.Version}`
|
|
35
|
-
].join(' ');
|
|
36
|
-
}
|
|
37
|
-
async getBSON() {
|
|
38
|
-
return BSON;
|
|
39
|
-
}
|
|
40
|
-
createTextDecoder() {
|
|
41
|
-
return new TextDecoder();
|
|
42
|
-
}
|
|
43
|
-
async postStreamRaw(options, mapLine) {
|
|
44
|
-
const timeout = Platform.OS == 'android'
|
|
45
|
-
? setTimeout(() => {
|
|
46
|
-
this.logger.warn(`HTTP Streaming POST is taking longer than ${Math.ceil(STREAMING_POST_TIMEOUT_MS / 1000)} seconds to resolve. If using a debug build, please ensure Flipper Network plugin is disabled.`);
|
|
47
|
-
}, STREAMING_POST_TIMEOUT_MS)
|
|
48
|
-
: null;
|
|
49
|
-
try {
|
|
50
|
-
return await super.postStreamRaw({
|
|
51
|
-
...options,
|
|
52
|
-
fetchOptions: {
|
|
53
|
-
...options.fetchOptions,
|
|
54
|
-
/**
|
|
55
|
-
* The `react-native-fetch-api` polyfill provides streaming support via
|
|
56
|
-
* this non-standard flag
|
|
57
|
-
* https://github.com/react-native-community/fetch#enable-text-streaming
|
|
58
|
-
*/
|
|
59
|
-
// @ts-expect-error https://github.com/react-native-community/fetch#enable-text-streaming
|
|
60
|
-
reactNative: { textStreaming: true }
|
|
61
|
-
}
|
|
62
|
-
}, mapLine);
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
if (timeout) {
|
|
66
|
-
clearTimeout(timeout);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=ReactNativeRemote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"AAAA,OAAO,E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,CAAC;IAED,KAAK,CAAC,aAAa,CAAI,OAA0B,EAAE,OAA4B;QAC7E,MAAM,OAAO,GACX,QAAQ,CAAC,EAAE,IAAI,SAAS;YACtB,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,6CAA6C,IAAI,CAAC,IAAI,CACpD,yBAAyB,GAAG,IAAI,CACjC,gGAAgG,CAClG,CAAC;YACJ,CAAC,EAAE,yBAAyB,CAAC;YAC/B,CAAC,CAAC,IAAI,CAAC;QAEX,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,aAAa,CAC9B;gBACE,GAAG,OAAO;gBACV,YAAY,EAAE;oBACZ,GAAG,OAAO,CAAC,YAAY;oBACvB;;;;uBAIG;oBACH,yFAAyF;oBACzF,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;iBACrC;aACF,EACD,OAAO,CACR,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,IAAI,OAAO,EAAE,CAAC;gBACZ,YAAY,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AbstractStreamingSyncImplementation, AbstractStreamingSyncImplementationOptions, LockOptions, LockType } from '@powersync/common';
|
|
2
|
-
import { Mutex } from 'async-mutex';
|
|
3
|
-
export declare class ReactNativeStreamingSyncImplementation extends AbstractStreamingSyncImplementation {
|
|
4
|
-
locks: Map<LockType, Mutex>;
|
|
5
|
-
constructor(options: AbstractStreamingSyncImplementationOptions);
|
|
6
|
-
/**
|
|
7
|
-
* Configures global locks on sync process
|
|
8
|
-
*/
|
|
9
|
-
initLocks(): void;
|
|
10
|
-
obtainLock<T>(lockOptions: LockOptions<T>): Promise<T>;
|
|
11
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AbstractStreamingSyncImplementation, LockType } from '@powersync/common';
|
|
2
|
-
import { Mutex } from 'async-mutex';
|
|
3
|
-
/**
|
|
4
|
-
* Global locks which prevent multiple instances from syncing
|
|
5
|
-
* concurrently.
|
|
6
|
-
*/
|
|
7
|
-
const LOCKS = new Map();
|
|
8
|
-
export class ReactNativeStreamingSyncImplementation extends AbstractStreamingSyncImplementation {
|
|
9
|
-
locks;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super(options);
|
|
12
|
-
this.initLocks();
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Configures global locks on sync process
|
|
16
|
-
*/
|
|
17
|
-
initLocks() {
|
|
18
|
-
const { identifier } = this.options;
|
|
19
|
-
if (identifier && LOCKS.has(identifier)) {
|
|
20
|
-
this.locks = LOCKS.get(identifier);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.locks = new Map();
|
|
24
|
-
this.locks.set(LockType.CRUD, new Mutex());
|
|
25
|
-
this.locks.set(LockType.SYNC, new Mutex());
|
|
26
|
-
if (identifier) {
|
|
27
|
-
LOCKS.set(identifier, this.locks);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
obtainLock(lockOptions) {
|
|
31
|
-
const lock = this.locks.get(lockOptions.type);
|
|
32
|
-
if (!lock) {
|
|
33
|
-
throw new Error(`Lock type ${lockOptions.type} not found`);
|
|
34
|
-
}
|
|
35
|
-
return lock.runExclusive(async () => {
|
|
36
|
-
if (lockOptions.signal?.aborted) {
|
|
37
|
-
throw new Error('Aborted');
|
|
38
|
-
}
|
|
39
|
-
return lockOptions.callback();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=ReactNativeStreamingSyncImplementation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeStreamingSyncImplementation.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeStreamingSyncImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EAGnC,QAAQ,EACT,MAAM,mB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