Skip to content

Commit 1a644f9

Browse files
committed
Remove react native polyfills and RNQS support (#1010)
1 parent 367ad55 commit 1a644f9

74 files changed

Lines changed: 3165 additions & 6134 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/dirty-planets-battle.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@powersync/react-native': major
3+
---
4+
5+
This release removes polyfills previously embedded into the React Native SDK to support
6+
older React Native versions.
7+
8+
In particular, the following polyfills have been removed:
9+
10+
- `TextEncoder` and `TextDecoder`: Support for `TextDecoder` has recently been added to React Native,
11+
and the SDK only uses it with very old PowerSync service versions as binary streams are preferred.
12+
- `react-native-fetch-api`: The package was effectively unmaintained. We now use `expo/fetch` as a default
13+
HTTP client. When unavailable, we fall back to the builtin `fetch` polyfill in React Native.
14+
Note that this doesn't support streams, so we recommend enabling `{ connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET }` for non-Expo apps with PowerSync.
15+
- `ReadableStream`: We expect that `fetch` implementations correctly implement `Response.getReader()`.

.changeset/sixty-peas-grow.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
'@powersync/react-native': major
33
'@powersync/web': major
44
'@powersync/common': major
5-
'@powersync/op-sqlite': minor
65
'@powersync/node': minor
76
'tauri-plugin-powersync': patch
87
'@powersync/tauri-plugin': patch

.changeset/wicked-waves-doubt.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@powersync/react-native': major
3+
---
4+
5+
Remove support for React Native Quick SQLite (RNQS). Additionally, `OPSqliteOpenFactory` is now the default and part
6+
of the `@powersync/react-native` package.
7+
8+
To upgrade, drop dependencies on `@powersync/op-sqlite`. If you've previously used RNQS, also add a dependency on
9+
`@op-engineering/op-sqlite`.
10+
11+
If you've previously used a `OPSqliteOpenFactory`, all options are now available on the `PowerSyncDatabase`
12+
constructor directly:
13+
14+
```TypeScript
15+
// Before
16+
const db = new PowerSyncDatabase({
17+
database: new OPSqliteOpenFactory({dbFilename: 'test.db'})
18+
});
19+
20+
// After
21+
const db = new PowerSyncDatabase({
22+
database: { dbFilename: 'test.db' }
23+
});
24+
```

demos/react-native-barebones-opsqlite/App.tsx

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ import {
1111
ActivityIndicator
1212
} from 'react-native';
1313
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
14-
import { OPSqliteOpenFactory } from '@powersync/op-sqlite';
15-
import { column, Table, Schema, type PowerSyncBackendConnector, PowerSyncDatabase } from '@powersync/react-native';
14+
import {
15+
column,
16+
Table,
17+
Schema,
18+
type PowerSyncBackendConnector,
19+
PowerSyncDatabase,
20+
createConsoleLogger,
21+
LogLevels
22+
} from '@powersync/react-native';
1623

1724
const Colors = {
1825
primary: '#0a7ea4',
@@ -24,18 +31,7 @@ const Colors = {
2431
darker: '#1a1a1a'
2532
};
2633

27-
const RANDOM_NAMES = [
28-
'Alex',
29-
'Jordan',
30-
'Sam',
31-
'Casey',
32-
'Riley',
33-
'Morgan',
34-
'Quinn',
35-
'Avery',
36-
'Taylor',
37-
'Jamie'
38-
];
34+
const RANDOM_NAMES = ['Alex', 'Jordan', 'Sam', 'Casey', 'Riley', 'Morgan', 'Quinn', 'Avery', 'Taylor', 'Jamie'];
3935

4036
/**
4137
* A placeholder connector which doesn't do anything but used to confirm connect can run.
@@ -59,13 +55,12 @@ let powerSync: PowerSyncDatabase | null = null;
5955
const setupDatabase = async (): Promise<PowerSyncDatabase> => {
6056
if (powerSync) return powerSync;
6157

62-
const factory = new OPSqliteOpenFactory({
63-
dbFilename: 'powersync.db'
64-
});
65-
6658
powerSync = new PowerSyncDatabase({
6759
schema,
68-
database: factory
60+
database: {
61+
dbFilename: 'powersync.db'
62+
},
63+
logger: createConsoleLogger({ minLevel: LogLevels.debug })
6964
});
7065

7166
await powerSync.init();
@@ -155,9 +150,7 @@ function App(): React.JSX.Element {
155150
/>
156151
<View style={styles.header}>
157152
<Text style={[styles.headerTitle, { color: textColor }]}>Customers</Text>
158-
<Text style={[styles.headerSubtitle, { color: mutedColor }]}>
159-
PowerSync + OP-SQLite
160-
</Text>
153+
<Text style={[styles.headerSubtitle, { color: mutedColor }]}>PowerSync + OP-SQLite</Text>
161154
</View>
162155

163156
{loading ? (
@@ -169,8 +162,7 @@ function App(): React.JSX.Element {
169162
<ScrollView
170163
contentInsetAdjustmentBehavior="automatic"
171164
style={backgroundStyle}
172-
contentContainerStyle={styles.scrollContent}
173-
>
165+
contentContainerStyle={styles.scrollContent}>
174166
<View style={[styles.card, { backgroundColor: cardBg }]}>
175167
{customers.length === 0 ? (
176168
<Text style={[styles.emptyText, { color: mutedColor }]}>No customers yet.</Text>
@@ -181,8 +173,7 @@ function App(): React.JSX.Element {
181173
<TouchableOpacity
182174
style={styles.deleteButton}
183175
onPress={() => deleteCustomer(c.id)}
184-
disabled={deletingId !== null}
185-
>
176+
disabled={deletingId !== null}>
186177
{deletingId === c.id ? (
187178
<ActivityIndicator size="small" color={Colors.primary} />
188179
) : (
@@ -197,8 +188,7 @@ function App(): React.JSX.Element {
197188
<TouchableOpacity
198189
style={[styles.button, adding && styles.buttonDisabled]}
199190
onPress={addRandomCustomer}
200-
disabled={adding}
201-
>
191+
disabled={adding}>
202192
{adding ? (
203193
<ActivityIndicator size="small" color={Colors.white} />
204194
) : (

0 commit comments

Comments
 (0)