@powersync/react-native 1.21.0 → 1.22.1

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,7 +1,8 @@
1
- import { AbstractPowerSyncDatabase, SqliteBucketStorage } from '@powersync/common';
1
+ import { AbstractPowerSyncDatabase } from '@powersync/common';
2
2
  import { ReactNativeRemote } from '../sync/stream/ReactNativeRemote';
3
3
  import { ReactNativeStreamingSyncImplementation } from '../sync/stream/ReactNativeStreamingSyncImplementation';
4
4
  import { ReactNativeQuickSqliteOpenFactory } from './adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
5
+ import { ReactNativeBucketStorageAdapter } from './../sync/bucket/ReactNativeBucketStorageAdapter';
5
6
  /**
6
7
  * A PowerSync database which provides SQLite functionality
7
8
  * which is automatically synced.
@@ -27,7 +28,7 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
27
28
  return defaultFactory.openDB();
28
29
  }
29
30
  generateBucketStorageAdapter() {
30
- return new SqliteBucketStorage(this.database, AbstractPowerSyncDatabase.transactionMutex);
31
+ return new ReactNativeBucketStorageAdapter(this.database, AbstractPowerSyncDatabase.transactionMutex);
31
32
  }
32
33
  generateSyncStreamImplementation(connector, options) {
33
34
  const remote = new ReactNativeRemote(connector);
@@ -0,0 +1,4 @@
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
+ }
@@ -0,0 +1,22 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/react-native",
3
- "version": "1.21.0",
3
+ "version": "1.22.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "homepage": "https://docs.powersync.com/",
26
26
  "peerDependencies": {
27
- "@journeyapps/react-native-quick-sqlite": "^2.4.4",
28
- "@powersync/common": "^1.32.0",
27
+ "@journeyapps/react-native-quick-sqlite": "^2.4.5",
28
+ "@powersync/common": "^1.33.1",
29
29
  "react": "*",
30
30
  "react-native": "*"
31
31
  },
@@ -35,12 +35,12 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@powersync/common": "1.32.0",
38
+ "@powersync/common": "1.33.1",
39
39
  "@powersync/react": "1.5.3"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@craftzdog/react-native-buffer": "^6.0.5",
43
- "@journeyapps/react-native-quick-sqlite": "^2.4.4",
43
+ "@journeyapps/react-native-quick-sqlite": "^2.4.5",
44
44
  "@rollup/plugin-alias": "^5.1.0",
45
45
  "@rollup/plugin-commonjs": "^25.0.7",
46
46
  "@rollup/plugin-inject": "^5.0.5",