@powersync/react-native 0.0.0-dev-20240701142654 → 0.0.0-dev-20240703080040
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/dist/main.js +3714 -1001
- package/dist/main.js.map +1 -1
- package/lib/db/PowerSyncDatabase.d.ts +20 -1
- package/lib/db/PowerSyncDatabase.js +24 -1
- package/lib/db/PowerSyncDatabase.js.map +1 -1
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.d.ts +13 -1
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js +15 -27
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js.map +1 -1
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.d.ts +9 -0
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js +39 -0
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/sync/stream/ReactNativeRemote.d.ts +5 -1
- package/lib/sync/stream/ReactNativeRemote.js +22 -1
- package/lib/sync/stream/ReactNativeRemote.js.map +1 -1
- package/package.json +7 -16
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabase, AbstractStreamingSyncImplementation, PowerSyncBackendConnector, BucketStorageAdapter } from '@powersync/common';
|
|
1
|
+
import { AbstractPowerSyncDatabase, AbstractStreamingSyncImplementation, PowerSyncBackendConnector, BucketStorageAdapter, DBAdapter, SQLOpenOptions } 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
|
+
*/
|
|
2
16
|
export declare class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
3
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: SQLOpenOptions): DBAdapter;
|
|
4
23
|
protected generateBucketStorageAdapter(): BucketStorageAdapter;
|
|
5
24
|
protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector): AbstractStreamingSyncImplementation;
|
|
6
25
|
}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { AbstractPowerSyncDatabase, SqliteBucketStorage } from '@powersync/common';
|
|
2
2
|
import { ReactNativeRemote } from '../sync/stream/ReactNativeRemote';
|
|
3
3
|
import { ReactNativeStreamingSyncImplementation } from '../sync/stream/ReactNativeStreamingSyncImplementation';
|
|
4
|
+
import { ReactNativeQuickSqliteOpenFactory } from './adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
|
5
|
+
/**
|
|
6
|
+
* A PowerSync database which provides SQLite functionality
|
|
7
|
+
* which is automatically synced.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* export const db = new PowerSyncDatabase({
|
|
12
|
+
* schema: AppSchema,
|
|
13
|
+
* database: {
|
|
14
|
+
* dbFilename: 'example.db'
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
5
20
|
async _initialize() { }
|
|
21
|
+
/**
|
|
22
|
+
* Opens a DBAdapter using React Native Quick SQLite as the
|
|
23
|
+
* default SQLite open factory.
|
|
24
|
+
*/
|
|
25
|
+
openDBAdapter(options) {
|
|
26
|
+
const defaultFactory = new ReactNativeQuickSqliteOpenFactory(options);
|
|
27
|
+
return defaultFactory.openDB();
|
|
28
|
+
}
|
|
6
29
|
generateBucketStorageAdapter() {
|
|
7
30
|
return new SqliteBucketStorage(this.database, AbstractPowerSyncDatabase.transactionMutex);
|
|
8
31
|
}
|
|
@@ -17,7 +40,7 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
|
|
|
17
40
|
},
|
|
18
41
|
retryDelayMs: this.options.retryDelay,
|
|
19
42
|
crudUploadThrottleMs: this.options.crudUploadThrottleMs,
|
|
20
|
-
identifier: this.
|
|
43
|
+
identifier: this.database.name
|
|
21
44
|
});
|
|
22
45
|
}
|
|
23
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/db/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAGzB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/db/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAGzB,mBAAmB,EAIpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sCAAsC,EAAE,MAAM,uDAAuD,CAAC;AAC/G,OAAO,EAAE,iCAAiC,EAAE,MAAM,wEAAwE,CAAC;AAE3H;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAkB,SAAQ,yBAAyB;IAC9D,KAAK,CAAC,WAAW,KAAmB,CAAC;IAErC;;;OAGG;IACO,aAAa,CAAC,OAAuB;QAC7C,MAAM,cAAc,GAAG,IAAI,iCAAiC,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAES,4BAA4B;QACpC,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;IAES,gCAAgC,CACxC,SAAoC;QAEpC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAEhD,OAAO,IAAI,sCAAsC,CAAC;YAChD,OAAO,EAAE,IAAI,CAAC,oBAAoB;YAClC,MAAM;YACN,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC1B,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACrC,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB;YACvD,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;SAC/B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import { AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, DBAdapter, PowerSyncDatabaseOptions, PowerSyncOpenFactoryOptions } from '@powersync/common';
|
|
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
|
+
*/
|
|
2
13
|
export declare class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
|
|
3
14
|
protected instanceGenerated: boolean;
|
|
15
|
+
protected sqlOpenFactory: SQLOpenFactory;
|
|
4
16
|
constructor(options: PowerSyncOpenFactoryOptions);
|
|
5
17
|
protected openDB(): DBAdapter;
|
|
6
18
|
generateInstance(options: PowerSyncDatabaseOptions): AbstractPowerSyncDatabase;
|
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
import { open, QuickSQLite } from '@journeyapps/react-native-quick-sqlite';
|
|
2
1
|
import { AbstractPowerSyncDatabaseOpenFactory } from '@powersync/common';
|
|
3
2
|
import { PowerSyncDatabase } from '../../../db/PowerSyncDatabase';
|
|
4
|
-
import {
|
|
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
|
+
*/
|
|
5
15
|
export class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
|
|
6
16
|
instanceGenerated;
|
|
17
|
+
sqlOpenFactory;
|
|
7
18
|
constructor(options) {
|
|
8
19
|
super(options);
|
|
9
20
|
this.instanceGenerated = false;
|
|
21
|
+
this.sqlOpenFactory = new ReactNativeQuickSqliteOpenFactory(options);
|
|
10
22
|
}
|
|
11
23
|
openDB() {
|
|
12
|
-
|
|
13
|
-
* React Native Quick SQLite opens files relative to the `Documents`dir on iOS and the `Files`
|
|
14
|
-
* dir on Android. Locations need to be relative to those dirs using with dot ("../") notation
|
|
15
|
-
* to navigate up the directory tree.
|
|
16
|
-
* This simple adapter assumes any platform specific relative directory is already catered for
|
|
17
|
-
* in the options (if provided)
|
|
18
|
-
* https://github.com/margelo/react-native-quick-sqlite/blob/main/README.md#loading-existing-dbs
|
|
19
|
-
*/
|
|
20
|
-
const { dbFilename } = this.options;
|
|
21
|
-
const openOptions = { location: this.options.dbLocation };
|
|
22
|
-
let DB;
|
|
23
|
-
try {
|
|
24
|
-
// Hot reloads can sometimes clear global JS state, but not close DB on native side
|
|
25
|
-
DB = open(dbFilename, openOptions);
|
|
26
|
-
}
|
|
27
|
-
catch (ex) {
|
|
28
|
-
if (ex.message.includes('already open')) {
|
|
29
|
-
QuickSQLite.close(dbFilename);
|
|
30
|
-
DB = open(dbFilename, openOptions);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
throw ex;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return new RNQSDBAdapter(DB, this.options.dbFilename);
|
|
24
|
+
return this.sqlOpenFactory.openDB();
|
|
37
25
|
}
|
|
38
26
|
generateInstance(options) {
|
|
39
27
|
if (this.instanceGenerated) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNQSDBOpenFactory.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DBAdapter, SQLOpenOptions, SQLOpenFactory } 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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { open, QuickSQLite } from '@journeyapps/react-native-quick-sqlite';
|
|
2
|
+
import { RNQSDBAdapter } from './RNQSDBAdapter';
|
|
3
|
+
/**
|
|
4
|
+
* Opens a SQLite connection using React Native Quick SQLite
|
|
5
|
+
*/
|
|
6
|
+
export class ReactNativeQuickSqliteOpenFactory {
|
|
7
|
+
options;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
openDB() {
|
|
12
|
+
/**
|
|
13
|
+
* React Native Quick SQLite opens files relative to the `Documents`dir on iOS and the `Files`
|
|
14
|
+
* dir on Android. Locations need to be relative to those dirs using with dot ("../") notation
|
|
15
|
+
* to navigate up the directory tree.
|
|
16
|
+
* This simple adapter assumes any platform specific relative directory is already catered for
|
|
17
|
+
* in the options (if provided)
|
|
18
|
+
* https://github.com/margelo/react-native-quick-sqlite/blob/main/README.md#loading-existing-dbs
|
|
19
|
+
*/
|
|
20
|
+
const { dbFilename } = this.options;
|
|
21
|
+
const openOptions = { location: this.options.dbLocation };
|
|
22
|
+
let DB;
|
|
23
|
+
try {
|
|
24
|
+
// Hot reloads can sometimes clear global JS state, but not close DB on native side
|
|
25
|
+
DB = open(dbFilename, openOptions);
|
|
26
|
+
}
|
|
27
|
+
catch (ex) {
|
|
28
|
+
if (ex.message.includes('already open')) {
|
|
29
|
+
QuickSQLite.close(dbFilename);
|
|
30
|
+
DB = open(dbFilename, openOptions);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw ex;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return new RNQSDBAdapter(DB, this.options.dbFilename);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=ReactNativeQuickSQLiteOpenFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactNativeQuickSQLiteOpenFactory.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAyB,MAAM,wCAAwC,CAAC;AAGlG,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;QACH,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,EAAyB,CAAC;QAC9B,IAAI,CAAC;YACH,mFAAmF;YACnF,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACxC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC9B,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YACrC,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
CHANGED
|
@@ -5,3 +5,4 @@ export * from './db/adapters/react-native-quick-sqlite/RNQSDBAdapter';
|
|
|
5
5
|
export * from './db/adapters/react-native-quick-sqlite//RNQSDBOpenFactory';
|
|
6
6
|
export * from './sync/stream/ReactNativeRemote';
|
|
7
7
|
export * from './sync/stream/ReactNativeStreamingSyncImplementation';
|
|
8
|
+
export * from './db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
package/lib/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export * from './db/adapters/react-native-quick-sqlite/RNQSDBAdapter';
|
|
|
6
6
|
export * from './db/adapters/react-native-quick-sqlite//RNQSDBOpenFactory';
|
|
7
7
|
export * from './sync/stream/ReactNativeRemote';
|
|
8
8
|
export * from './sync/stream/ReactNativeStreamingSyncImplementation';
|
|
9
|
+
export * from './db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,4DAA4D,CAAC;AAC3E,cAAc,iCAAiC,CAAC;AAChD,cAAc,sDAAsD,CAAC"}
|
|
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,4DAA4D,CAAC;AAC3E,cAAc,iCAAiC,CAAC;AAChD,cAAc,sDAAsD,CAAC;AACrE,cAAc,2EAA2E,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ILogger } from 'js-logger';
|
|
2
|
+
import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, DataStream, RemoteConnector, StreamingSyncLine, SyncStreamOptions } from '@powersync/common';
|
|
2
3
|
export declare const STREAMING_POST_TIMEOUT_MS = 30000;
|
|
3
4
|
export declare class ReactNativeRemote extends AbstractRemote {
|
|
5
|
+
protected connector: RemoteConnector;
|
|
6
|
+
protected logger: ILogger;
|
|
7
|
+
constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
|
|
4
8
|
getBSON(): Promise<BSONImplementation>;
|
|
5
9
|
socketStream(options: SyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
|
|
6
10
|
postStream(options: SyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { AbstractRemote } from '@powersync/common';
|
|
1
|
+
import { AbstractRemote, DEFAULT_REMOTE_LOGGER, FetchImplementationProvider } from '@powersync/common';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
// Note docs for React Native https://github.com/mongodb/js-bson?tab=readme-ov-file#react-native
|
|
4
4
|
import { BSON } from 'bson';
|
|
5
|
+
import { fetch } from 'react-native-fetch-api';
|
|
5
6
|
export const STREAMING_POST_TIMEOUT_MS = 30_000;
|
|
7
|
+
/**
|
|
8
|
+
* Directly imports fetch implementation from react-native-fetch-api.
|
|
9
|
+
* This removes the requirement for the global `fetch` to be overridden by
|
|
10
|
+
* a polyfill.
|
|
11
|
+
*/
|
|
12
|
+
class ReactNativeFetchProvider extends FetchImplementationProvider {
|
|
13
|
+
getFetch() {
|
|
14
|
+
return fetch.bind(globalThis);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
const CommonPolyfills = [
|
|
7
18
|
// {
|
|
8
19
|
// name: 'TextEncoder',
|
|
@@ -42,6 +53,16 @@ ${missingPolyfills.join('\n')}`);
|
|
|
42
53
|
}
|
|
43
54
|
};
|
|
44
55
|
export class ReactNativeRemote extends AbstractRemote {
|
|
56
|
+
connector;
|
|
57
|
+
logger;
|
|
58
|
+
constructor(connector, logger = DEFAULT_REMOTE_LOGGER, options) {
|
|
59
|
+
super(connector, logger, {
|
|
60
|
+
...(options ?? {}),
|
|
61
|
+
fetchImplementation: options?.fetchImplementation ?? new ReactNativeFetchProvider()
|
|
62
|
+
});
|
|
63
|
+
this.connector = connector;
|
|
64
|
+
this.logger = logger;
|
|
65
|
+
}
|
|
45
66
|
async getBSON() {
|
|
46
67
|
return BSON;
|
|
47
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAGd,qBAAqB,EAGrB,2BAA2B,EAI5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,gGAAgG;AAChG,OAAO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0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20240703080040",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -24,24 +24,20 @@
|
|
|
24
24
|
"homepage": "https://docs.powersync.com/",
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@journeyapps/react-native-quick-sqlite": "^1.1.6",
|
|
27
|
-
"@powersync/common": "^1.10.0",
|
|
28
27
|
"react": "*",
|
|
29
|
-
"react-native": "*"
|
|
28
|
+
"react-native": "*",
|
|
29
|
+
"react-native-polyfill-globals": "^3.1.0",
|
|
30
|
+
"@powersync/common": "^1.13.01.13.0"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"async-lock": "^1.4.0",
|
|
33
34
|
"bson": "^6.6.0",
|
|
34
35
|
"react-native-fetch-api": "^3.0.0",
|
|
35
|
-
"
|
|
36
|
-
"@craftzdog/react-native-buffer": "^6.0.5",
|
|
37
|
-
"web-streams-polyfill": "3.2.1",
|
|
38
|
-
"@powersync/common": "1.10.0",
|
|
36
|
+
"@powersync/common": "1.13.0",
|
|
39
37
|
"@powersync/react": "1.3.5"
|
|
40
38
|
},
|
|
41
39
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@babel/preset-env": "^7.24.6",
|
|
44
|
-
"@babel/preset-react": "^7.24.6",
|
|
40
|
+
"@craftzdog/react-native-buffer": "^6.0.5",
|
|
45
41
|
"@journeyapps/react-native-quick-sqlite": "^1.1.6",
|
|
46
42
|
"@rollup/plugin-inject": "^5.0.5",
|
|
47
43
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
@@ -49,16 +45,12 @@
|
|
|
49
45
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
50
46
|
"@rollup/plugin-json": "^6.1.0",
|
|
51
47
|
"@types/async-lock": "^1.4.0",
|
|
52
|
-
"babel-loader": "^9.1.3",
|
|
53
|
-
"magic-string": "0.30.10",
|
|
54
48
|
"react": "18.2.0",
|
|
55
49
|
"react-native": "0.72.4",
|
|
56
50
|
"rollup": "4.14.3",
|
|
57
|
-
"rollup-plugin-esbuild": "^6.1.1",
|
|
58
51
|
"text-encoding": "^0.7.0",
|
|
59
52
|
"typescript": "^5.1.3",
|
|
60
|
-
"
|
|
61
|
-
"webpack-cli": "^5.1.4"
|
|
53
|
+
"web-streams-polyfill": "3.2.1"
|
|
62
54
|
},
|
|
63
55
|
"keywords": [
|
|
64
56
|
"data sync",
|
|
@@ -69,7 +61,6 @@
|
|
|
69
61
|
],
|
|
70
62
|
"scripts": {
|
|
71
63
|
"build": "tsc -b && rollup -c rollup.config.mjs",
|
|
72
|
-
"build:bundle": "rollup -c rollup.config.mjs",
|
|
73
64
|
"clean": "rm -rf lib tsconfig.tsbuildinfo",
|
|
74
65
|
"watch": "tsc -b -w"
|
|
75
66
|
}
|