@powersync/react-native 1.6.2 → 1.7.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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # PowerSync SDK for React Native
6
6
 
7
- [PowerSync](https://powersync.com) is a service and set of SDKs that keeps Postgres databases in sync with on-device SQLite databases.
7
+ *[PowerSync](https://www.powersync.com) is a Postgres-SQLite sync layer, which helps developers to create local-first real-time reactive apps that work seamlessly both online and offline.*
8
8
 
9
9
  This package (`packages/react-native`) is the PowerSync SDK for React Native clients. It is an extension of `packages/common`.
10
10
 
@@ -1,6 +1,10 @@
1
- import { AbstractRemote, BSONImplementation, DataStream, StreamingSyncLine, SyncStreamOptions } from '@powersync/common';
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/react-native",
3
- "version": "1.6.2",
3
+ "version": "1.7.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -26,13 +26,14 @@
26
26
  "react": "*",
27
27
  "react-native": "*",
28
28
  "react-native-polyfill-globals": "^3.1.0",
29
- "@powersync/common": "^1.10.0"
29
+ "@powersync/common": "^1.11.1"
30
30
  },
31
31
  "dependencies": {
32
32
  "async-lock": "^1.4.0",
33
33
  "bson": "^6.6.0",
34
+ "react-native-fetch-api": "^3.0.0",
34
35
  "@powersync/react": "1.3.5",
35
- "@powersync/common": "1.10.0"
36
+ "@powersync/common": "1.11.1"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@journeyapps/react-native-quick-sqlite": "^1.1.6",