@powersync/react-native 1.8.4 → 1.10.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.
- package/README.md +3 -64
- package/dist/index.js +10 -0
- package/lib/db/PowerSyncDatabase.d.ts +2 -2
- package/lib/db/PowerSyncDatabase.js +2 -1
- package/lib/db/PowerSyncDatabase.js.map +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.js +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBAdapter.js.map +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/RNQSDBOpenFactory.js.map +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js +1 -0
- package/lib/db/adapters/react-native-quick-sqlite/ReactNativeQuickSQLiteOpenFactory.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/sync/stream/ReactNativeRemote.js +1 -40
- package/lib/sync/stream/ReactNativeRemote.js.map +1 -0
- package/lib/sync/stream/ReactNativeStreamingSyncImplementation.js +1 -0
- package/lib/sync/stream/ReactNativeStreamingSyncImplementation.js.map +1 -0
- package/package.json +26 -14
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
# PowerSync SDK for React Native
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
This package (`packages/react-native`) is the PowerSync SDK for React Native clients. It is an extension of `packages/common`.
|
|
9
|
+
This package (`packages/react-native`) is the PowerSync SDK for React Native clients. It is an extension of `packages/common`. It connects to a PowerSync instance via HTTP streams (enabled by default) or WebSockets.
|
|
10
10
|
|
|
11
11
|
See a summary of features [here](https://docs.powersync.co/client-sdk-references/react-native-and-expo).
|
|
12
12
|
|
|
@@ -30,68 +30,7 @@ npx expo install @journeyapps/react-native-quick-sqlite
|
|
|
30
30
|
|
|
31
31
|
## Install Polyfills
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
* Both connection methods require the [React Native Common Polyfills](#react-native-common-polyfills), as detailed below.
|
|
35
|
-
* The WebSocket method requires an [additional polyfill](#web-sockets-buffer) for the `Buffer` interface.
|
|
36
|
-
* Other polyfills are required for [watched queries](#babel-plugins-watched-queries) using the Async Iterator response format.
|
|
37
|
-
|
|
38
|
-
### React Native Common Polyfills
|
|
39
|
-
|
|
40
|
-
This package requires polyfills for HTTP streaming and other text encoding functions. These functions can be provided with [react-native-polyfill-globals](https://www.npmjs.com/package/react-native-polyfill-globals).
|
|
41
|
-
|
|
42
|
-
Install the collection of polyfills with:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npx expo install react-native-polyfill-globals
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
The `react-native-polyfill-globals` package uses peer dependencies for individual functions. Most modern package managers install peer dependencies by default, however currently the peer dependency version ranges are quite broad and might result in certain packages being incompatible. Currently an [issue](https://github.com/acostalima/react-native-polyfill-globals/issues/6) is open for a breaking change in one of the dependencies. The best practice is to currently add the packages as explicit dependencies with version ranges to your project with the command below.
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npx expo install react-native-fetch-api@^3.0.0 react-native-url-polyfill@^2.0.0 text-encoding@^0.7.0 web-streams-polyfill@3.2.1 base-64@^1.0.0
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Enable the polyfills in React Native app by adding the following in your top level entry point
|
|
55
|
-
|
|
56
|
-
```JavaScript
|
|
57
|
-
// App.js
|
|
58
|
-
import 'react-native-polyfill-globals/auto';
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### HTTP Connections
|
|
62
|
-
|
|
63
|
-
HTTP connections require the HTTP streaming polyfills included in the [common section](#react-native-common-polyfills). See additional [setup](https://docs.powersync.com/client-sdk-references/react-native-and-expo#android-flipper-network-plugin) required for Android.
|
|
64
|
-
|
|
65
|
-
### WebSocket Connections: Buffer
|
|
66
|
-
|
|
67
|
-
Note: Beta Release - WebSockets are currently in a beta release. It should be safe to use in production if sufficient testing is done on the client side.
|
|
68
|
-
|
|
69
|
-
Our WebSocket implementation supports binary payloads which are encoded as BSON documents.
|
|
70
|
-
|
|
71
|
-
This requires support for the `Buffer` interface.
|
|
72
|
-
|
|
73
|
-
Apply the `Buffer` polyfill
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
npx expo install @craftzdog/react-native-buffer
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
import { Buffer } from '@craftzdog/react-native-buffer';
|
|
81
|
-
|
|
82
|
-
if (typeof global.Buffer == 'undefined') {
|
|
83
|
-
// @ts-ignore If using TypeScript
|
|
84
|
-
global.Buffer = Buffer;
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
This library uses `RSocket` for reactive WebSocket streams which requires `process.nextTick` to be available. Apply a polyfill if not available.
|
|
89
|
-
|
|
90
|
-
```javascript
|
|
91
|
-
if (typeof process.nextTick == 'undefined') {
|
|
92
|
-
process.nextTick = setImmediate;
|
|
93
|
-
}
|
|
94
|
-
```
|
|
33
|
+
- Polyfills are required for [watched queries](#babel-plugins-watched-queries) using the Async Iterator response format.
|
|
95
34
|
|
|
96
35
|
### Babel Plugins: Watched Queries
|
|
97
36
|
|