@powersync/react-native 0.0.0-dev-20240626101022 → 0.0.0-dev-20240701142654

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,25 +1,6 @@
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
- */
1
+ import { AbstractPowerSyncDatabase, AbstractStreamingSyncImplementation, PowerSyncBackendConnector, BucketStorageAdapter } from '@powersync/common';
16
2
  export declare class PowerSyncDatabase extends AbstractPowerSyncDatabase {
17
3
  _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;
23
4
  protected generateBucketStorageAdapter(): BucketStorageAdapter;
24
5
  protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector): AbstractStreamingSyncImplementation;
25
6
  }
@@ -1,31 +1,8 @@
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
- */
19
4
  export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
20
5
  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
- }
29
6
  generateBucketStorageAdapter() {
30
7
  return new SqliteBucketStorage(this.database, AbstractPowerSyncDatabase.transactionMutex);
31
8
  }
@@ -40,7 +17,8 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
40
17
  },
41
18
  retryDelayMs: this.options.retryDelay,
42
19
  crudUploadThrottleMs: this.options.crudUploadThrottleMs,
43
- identifier: this.database.name
20
+ identifier: this.options.database.name
44
21
  });
45
22
  }
46
23
  }
24
+ //# sourceMappingURL=PowerSyncDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PowerSyncDatabase.js","sourceRoot":"","sources":["../../src/db/PowerSyncDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAGzB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,sCAAsC,EAAE,MAAM,uDAAuD,CAAC;AAE/G,MAAM,OAAO,iBAAkB,SAAQ,yBAAyB;IAC9D,KAAK,CAAC,WAAW,KAAmB,CAAC;IAE3B,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,OAAO,CAAC,QAAQ,CAAC,IAAI;SACvC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -98,3 +98,4 @@ export class RNQSDBAdapter extends BaseObserver {
98
98
  };
99
99
  }
100
100
  }
101
+ //# sourceMappingURL=RNQSDBAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RNQSDBAdapter.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAA+B;IAMpD;IACH;IANT,MAAM,CAAuD;IAC7D,WAAW,CAA4D;IACvE,GAAG,CAAqD;IAExD,YACY,MAA6B,EAChC,IAAY;QAEnB,KAAK,EAAE,CAAC;QAHE,WAAM,GAAN,MAAM,CAAuB;QAChC,SAAI,GAAJ,IAAI,CAAQ;QAGnB,6BAA6B;QAC7B,MAAM,CAAC,yBAAyB,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1C,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC;YAC3C,yDAAyD;YACzD,OAAO,EAAE,CAAC,GAAW,EAAE,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC;SAC5E,CAAC,CAAC;QAC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,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;CACF"}
@@ -1,18 +1,6 @@
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
- */
1
+ import { AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, DBAdapter, PowerSyncDatabaseOptions, PowerSyncOpenFactoryOptions } from '@powersync/common';
13
2
  export declare class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
14
3
  protected instanceGenerated: boolean;
15
- protected sqlOpenFactory: SQLOpenFactory;
16
4
  constructor(options: PowerSyncOpenFactoryOptions);
17
5
  protected openDB(): DBAdapter;
18
6
  generateInstance(options: PowerSyncDatabaseOptions): AbstractPowerSyncDatabase;
@@ -1,27 +1,39 @@
1
+ import { open, QuickSQLite } from '@journeyapps/react-native-quick-sqlite';
1
2
  import { AbstractPowerSyncDatabaseOpenFactory } from '@powersync/common';
2
3
  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
- */
4
+ import { RNQSDBAdapter } from './RNQSDBAdapter';
15
5
  export class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseOpenFactory {
16
6
  instanceGenerated;
17
- sqlOpenFactory;
18
7
  constructor(options) {
19
8
  super(options);
20
9
  this.instanceGenerated = false;
21
- this.sqlOpenFactory = new ReactNativeQuickSqliteOpenFactory(options);
22
10
  }
23
11
  openDB() {
24
- return this.sqlOpenFactory.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);
25
37
  }
26
38
  generateInstance(options) {
27
39
  if (this.instanceGenerated) {
@@ -31,3 +43,4 @@ export class RNQSPowerSyncDatabaseOpenFactory extends AbstractPowerSyncDatabaseO
31
43
  return new PowerSyncDatabase(options);
32
44
  }
33
45
  }
46
+ //# sourceMappingURL=RNQSDBOpenFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RNQSDBOpenFactory.js","sourceRoot":"","sources":["../../../../src/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAyB,MAAM,wCAAwC,CAAC;AAElG,OAAO,EAEL,oCAAoC,EAIrC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,OAAO,gCAAiC,SAAQ,oCAAoC;IAC9E,iBAAiB,CAAU;IAErC,YAAY,OAAoC;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACjC,CAAC;IACS,MAAM;QACd;;;;;;;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;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"}
package/lib/index.d.ts CHANGED
@@ -5,4 +5,3 @@ 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,4 @@ 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
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,10 +1,6 @@
1
- import { ILogger } from 'js-logger';
2
- import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, DataStream, RemoteConnector, StreamingSyncLine, SyncStreamOptions } from '@powersync/common';
1
+ import { AbstractRemote, BSONImplementation, DataStream, StreamingSyncLine, SyncStreamOptions } from '@powersync/common';
3
2
  export declare const STREAMING_POST_TIMEOUT_MS = 30000;
4
3
  export declare class ReactNativeRemote extends AbstractRemote {
5
- protected connector: RemoteConnector;
6
- protected logger: ILogger;
7
- constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
8
4
  getBSON(): Promise<BSONImplementation>;
9
5
  socketStream(options: SyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
10
6
  postStream(options: SyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
@@ -1,46 +1,35 @@
1
- import { AbstractRemote, DEFAULT_REMOTE_LOGGER, FetchImplementationProvider } from '@powersync/common';
1
+ import { AbstractRemote } 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';
6
5
  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
- }
17
6
  const CommonPolyfills = [
18
- {
19
- name: 'TextEncoder',
20
- test: () => typeof TextEncoder == 'undefined'
21
- }
7
+ // {
8
+ // name: 'TextEncoder',
9
+ // test: () => typeof TextEncoder == 'undefined'
10
+ // }
22
11
  ];
23
12
  const SocketPolyfillTests = [
24
- ...CommonPolyfills,
25
- {
26
- name: 'nextTick',
27
- test: () => typeof process.nextTick == 'undefined'
28
- },
29
- {
30
- name: 'Buffer',
31
- test: () => typeof global.Buffer == 'undefined'
32
- }
13
+ ...CommonPolyfills
14
+ // {
15
+ // name: 'nextTick',
16
+ // test: () => typeof process.nextTick == 'undefined'
17
+ // },
18
+ // {
19
+ // name: 'Buffer',
20
+ // test: () => typeof global.Buffer == 'undefined'
21
+ // }
33
22
  ];
34
23
  const HttpPolyfillTests = [
35
- ...CommonPolyfills,
36
- {
37
- name: 'TextDecoder',
38
- test: () => typeof TextDecoder == 'undefined'
39
- },
40
- {
41
- name: 'ReadableStream',
42
- test: () => typeof ReadableStream == 'undefined'
43
- }
24
+ ...CommonPolyfills
25
+ // {
26
+ // name: 'TextDecoder',
27
+ // test: () => typeof TextDecoder == 'undefined'
28
+ // },
29
+ // {
30
+ // name: 'ReadableStream',
31
+ // test: () => typeof ReadableStream == 'undefined'
32
+ // }
44
33
  ];
45
34
  const validatePolyfills = (tests) => {
46
35
  const missingPolyfills = tests.filter((t) => t.test()).map((t) => t.name);
@@ -53,16 +42,6 @@ ${missingPolyfills.join('\n')}`);
53
42
  }
54
43
  };
55
44
  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
- }
66
45
  async getBSON() {
67
46
  return BSON;
68
47
  }
@@ -96,3 +75,4 @@ export class ReactNativeRemote extends AbstractRemote {
96
75
  return result;
97
76
  }
98
77
  }
78
+ //# sourceMappingURL=ReactNativeRemote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeRemote.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,gGAAgG;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAOhD,MAAM,eAAe,GAAmB;AACtC,IAAI;AAC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,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,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC;YACpC,GAAG,OAAO;YACV,YAAY,EAAE;gBACZ,GAAG,OAAO,CAAC,YAAY;gBACvB;;;;mBAIG;gBACH,yFAAyF;gBACzF,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;aACrC;SACF,CAAC,CAAC;QAEH,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -40,3 +40,4 @@ export class ReactNativeStreamingSyncImplementation extends AbstractStreamingSyn
40
40
  });
41
41
  }
42
42
  }
43
+ //# sourceMappingURL=ReactNativeStreamingSyncImplementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeStreamingSyncImplementation.js","sourceRoot":"","sources":["../../../src/sync/stream/ReactNativeStreamingSyncImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EAGnC,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B;;;GAGG;AACH,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;AAErD,MAAM,OAAO,sCAAuC,SAAQ,mCAAmC;IAC7F,KAAK,CAAsB;IAE3B,YAAY,OAAmD;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACpC,IAAI,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAE1C,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,UAAU,CAAI,WAA2B;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;YAC/C,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;YAED,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@powersync/react-native",
3
- "version": "0.0.0-dev-20240626101022",
3
+ "version": "0.0.0-dev-20240701142654",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
7
7
  },
8
8
  "description": "PowerSync - sync Postgres with SQLite in your React Native app for offline-first and real-time data",
9
- "main": "./lib/index.js",
9
+ "main": "./dist/main.js",
10
10
  "types": "./lib/index.d.ts",
11
11
  "files": [
12
- "lib"
12
+ "lib",
13
+ "dist"
13
14
  ],
14
15
  "repository": {
15
16
  "type": "git",
@@ -23,24 +24,41 @@
23
24
  "homepage": "https://docs.powersync.com/",
24
25
  "peerDependencies": {
25
26
  "@journeyapps/react-native-quick-sqlite": "^1.1.6",
27
+ "@powersync/common": "^1.10.0",
26
28
  "react": "*",
27
- "react-native": "*",
28
- "react-native-polyfill-globals": "^3.1.0",
29
- "@powersync/common": "0.0.0-dev-20240626101022"
29
+ "react-native": "*"
30
30
  },
31
31
  "dependencies": {
32
32
  "async-lock": "^1.4.0",
33
33
  "bson": "^6.6.0",
34
34
  "react-native-fetch-api": "^3.0.0",
35
- "@powersync/react": "1.3.5",
36
- "@powersync/common": "0.0.0-dev-20240626101022"
35
+ "react-native-get-random-values": "^1.11.0",
36
+ "@craftzdog/react-native-buffer": "^6.0.5",
37
+ "web-streams-polyfill": "3.2.1",
38
+ "@powersync/common": "1.10.0",
39
+ "@powersync/react": "1.3.5"
37
40
  },
38
41
  "devDependencies": {
42
+ "@babel/core": "^7.24.6",
43
+ "@babel/preset-env": "^7.24.6",
44
+ "@babel/preset-react": "^7.24.6",
39
45
  "@journeyapps/react-native-quick-sqlite": "^1.1.6",
46
+ "@rollup/plugin-inject": "^5.0.5",
47
+ "@rollup/plugin-node-resolve": "15.2.3",
48
+ "@rollup/plugin-typescript": "11.1.6",
49
+ "@rollup/plugin-commonjs": "^25.0.7",
50
+ "@rollup/plugin-json": "^6.1.0",
40
51
  "@types/async-lock": "^1.4.0",
52
+ "babel-loader": "^9.1.3",
53
+ "magic-string": "0.30.10",
41
54
  "react": "18.2.0",
42
55
  "react-native": "0.72.4",
43
- "typescript": "^5.1.3"
56
+ "rollup": "4.14.3",
57
+ "rollup-plugin-esbuild": "^6.1.1",
58
+ "text-encoding": "^0.7.0",
59
+ "typescript": "^5.1.3",
60
+ "webpack": "^5.90.1",
61
+ "webpack-cli": "^5.1.4"
44
62
  },
45
63
  "keywords": [
46
64
  "data sync",
@@ -50,7 +68,8 @@
50
68
  "live data"
51
69
  ],
52
70
  "scripts": {
53
- "build": "tsc -b",
71
+ "build": "tsc -b && rollup -c rollup.config.mjs",
72
+ "build:bundle": "rollup -c rollup.config.mjs",
54
73
  "clean": "rm -rf lib tsconfig.tsbuildinfo",
55
74
  "watch": "tsc -b -w"
56
75
  }
@@ -1,9 +0,0 @@
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
- }
@@ -1,38 +0,0 @@
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
- }