@powersync/react-native 1.22.2 → 1.23.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.
@@ -22,6 +22,4 @@ export declare class PowerSyncDatabase extends AbstractPowerSyncDatabase {
22
22
  protected openDBAdapter(options: PowerSyncDatabaseOptionsWithSettings): DBAdapter;
23
23
  protected generateBucketStorageAdapter(): BucketStorageAdapter;
24
24
  protected generateSyncStreamImplementation(connector: PowerSyncBackendConnector, options: RequiredAdditionalConnectionOptions): AbstractStreamingSyncImplementation;
25
- readLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
26
- writeLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T>;
27
25
  }
@@ -1,8 +1,8 @@
1
1
  import { AbstractPowerSyncDatabase } 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
4
  import { ReactNativeBucketStorageAdapter } from './../sync/bucket/ReactNativeBucketStorageAdapter';
5
+ import { ReactNativeQuickSqliteOpenFactory } from './adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory';
6
6
  /**
7
7
  * A PowerSync database which provides SQLite functionality
8
8
  * which is automatically synced.
@@ -28,10 +28,10 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
28
28
  return defaultFactory.openDB();
29
29
  }
30
30
  generateBucketStorageAdapter() {
31
- return new ReactNativeBucketStorageAdapter(this.database, AbstractPowerSyncDatabase.transactionMutex);
31
+ return new ReactNativeBucketStorageAdapter(this.database, this.logger);
32
32
  }
33
33
  generateSyncStreamImplementation(connector, options) {
34
- const remote = new ReactNativeRemote(connector);
34
+ const remote = new ReactNativeRemote(connector, this.logger);
35
35
  return new ReactNativeStreamingSyncImplementation({
36
36
  adapter: this.bucketStorageAdapter,
37
37
  remote,
@@ -41,15 +41,8 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
41
41
  },
42
42
  retryDelayMs: options.retryDelayMs,
43
43
  crudUploadThrottleMs: options.crudUploadThrottleMs,
44
- identifier: this.database.name
44
+ identifier: this.database.name,
45
+ logger: this.logger
45
46
  });
46
47
  }
47
- async readLock(callback) {
48
- await this.waitForReady();
49
- return this.database.readLock(callback);
50
- }
51
- async writeLock(callback) {
52
- await this.waitForReady();
53
- return this.database.writeLock(callback);
54
- }
55
48
  }
@@ -1,5 +1,5 @@
1
1
  import { ILogger } from 'js-logger';
2
- import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, DataStream, RemoteConnector, SocketSyncStreamOptions, StreamingSyncLine, SyncStreamOptions } from '@powersync/common';
2
+ import { AbstractRemote, AbstractRemoteOptions, BSONImplementation, DataStream, RemoteConnector, SyncStreamOptions } from '@powersync/common';
3
3
  export declare const STREAMING_POST_TIMEOUT_MS = 30000;
4
4
  export declare class ReactNativeRemote extends AbstractRemote {
5
5
  protected connector: RemoteConnector;
@@ -7,6 +7,5 @@ export declare class ReactNativeRemote extends AbstractRemote {
7
7
  constructor(connector: RemoteConnector, logger?: ILogger, options?: Partial<AbstractRemoteOptions>);
8
8
  getUserAgent(): string;
9
9
  getBSON(): Promise<BSONImplementation>;
10
- socketStream(options: SocketSyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
11
- postStream(options: SyncStreamOptions): Promise<DataStream<StreamingSyncLine>>;
10
+ postStreamRaw<T>(options: SyncStreamOptions, mapLine: (line: string) => T): Promise<DataStream<T>>;
12
11
  }
@@ -36,17 +36,14 @@ export class ReactNativeRemote extends AbstractRemote {
36
36
  async getBSON() {
37
37
  return BSON;
38
38
  }
39
- async socketStream(options) {
40
- return super.socketStream(options);
41
- }
42
- async postStream(options) {
39
+ async postStreamRaw(options, mapLine) {
43
40
  const timeout = Platform.OS == 'android'
44
41
  ? setTimeout(() => {
45
42
  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.`);
46
43
  }, STREAMING_POST_TIMEOUT_MS)
47
44
  : null;
48
45
  try {
49
- return await super.postStream({
46
+ return await super.postStreamRaw({
50
47
  ...options,
51
48
  fetchOptions: {
52
49
  ...options.fetchOptions,
@@ -58,7 +55,7 @@ export class ReactNativeRemote extends AbstractRemote {
58
55
  // @ts-expect-error https://github.com/react-native-community/fetch#enable-text-streaming
59
56
  reactNative: { textStreaming: true }
60
57
  }
61
- });
58
+ }, mapLine);
62
59
  }
63
60
  finally {
64
61
  if (timeout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/react-native",
3
- "version": "1.22.2",
3
+ "version": "1.23.0",
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.5",
28
- "@powersync/common": "^1.33.2",
27
+ "@journeyapps/react-native-quick-sqlite": "^2.4.6",
28
+ "@powersync/common": "^1.34.0",
29
29
  "react": "*",
30
30
  "react-native": "*"
31
31
  },
@@ -35,12 +35,12 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@powersync/common": "1.33.2",
38
+ "@powersync/common": "1.34.0",
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.5",
43
+ "@journeyapps/react-native-quick-sqlite": "^2.4.6",
44
44
  "@rollup/plugin-alias": "^5.1.0",
45
45
  "@rollup/plugin-commonjs": "^25.0.7",
46
46
  "@rollup/plugin-inject": "^5.0.5",