Skip to content

Commit 9d1dc6f

Browse files
[Feature] Websocket Support (#114)
Co-authored-by: benitav <[email protected]>
1 parent 8f3461d commit 9d1dc6f

File tree

39 files changed

+13954
-7694
lines changed

39 files changed

+13954
-7694
lines changed

.changeset/rich-steaks-bake.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@journeyapps/powersync-yjs-text-collab-demo': patch
3+
'@journeyapps/powersync-react-supabase-todolist': patch
4+
---
5+
6+
Updated Vite config for BSON library

.changeset/thirty-chicken-kick.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@journeyapps/powersync-sdk-react-native': minor
3+
'@journeyapps/powersync-sdk-common': minor
4+
'@journeyapps/powersync-sdk-web': minor
5+
---
6+
7+
Added support for WebSocket sync stream connections.

demos/django-react-native-todolist/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@powersync/react-native": "workspace:*",
1414
"@powersync/react": "workspace:*",
1515
"@powersync/common": "workspace:*",
16-
"@journeyapps/react-native-quick-sqlite": "^1.1.5",
16+
"@journeyapps/react-native-quick-sqlite": "^1.1.6",
1717
"@react-native-community/async-storage": "^1.12.1",
1818
"@react-native-community/masked-view": "^0.1.11",
1919
"@react-navigation/drawer": "^6.6.15",

demos/example-nextjs/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"@emotion/react": "^11.11.4",
1414
"@emotion/styled": "^11.11.0",
1515
"@fontsource/roboto": "^5.0.12",
16-
"@powersync/react": "workspace:*",
17-
"@powersync/web": "workspace:*",
1816
"@journeyapps/wa-sqlite": "~0.1.1",
1917
"@lexical/react": "^0.11.3",
2018
"@mui/icons-material": "^5.15.12",
2119
"@mui/material": "^5.15.12",
20+
"@powersync/react": "workspace:*",
21+
"@powersync/web": "workspace:*",
22+
"buffer": "^6.0.3",
2223
"fast-glob": "^3.3.2",
2324
"formik": "^2.4.5",
2425
"highlight.js": "^11.9.0",

demos/example-nextjs/src/app/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import React, { useEffect } from 'react';
3+
import { useEffect } from 'react';
44
import { CircularProgress, Grid, ListItem, styled } from '@mui/material';
55
import { usePowerSync, useQuery } from '@powersync/react';
66

@@ -14,7 +14,7 @@ export default function EntryPage() {
1414
const name = names[Math.floor(Math.random() * names.length)];
1515
db.execute('INSERT INTO customers(id, name) VALUES(uuid(), ?)', [name]);
1616
return () => {};
17-
}, []);
17+
}, [db]);
1818

1919
if (isLoading) {
2020
return <CircularProgress />;

demos/example-nextjs/src/components/providers/SystemProvider.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { CircularProgress } from '@mui/material';
88
import Logger from 'js-logger';
99
import React, { Suspense } from 'react';
1010

11+
import { Buffer } from 'buffer';
12+
13+
// Polyfill for WebSockets
14+
if (typeof self.Buffer == 'undefined') {
15+
self.Buffer = Buffer;
16+
}
17+
18+
// eslint-disable-next-line react-hooks/rules-of-hooks
1119
Logger.useDefaults();
1220
Logger.setLevel(Logger.DEBUG);
1321

demos/example-vite/vite.config.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export default defineConfig({
1313
},
1414
emptyOutDir: true
1515
},
16+
resolve: {
17+
alias: [
18+
// https://jira.mongodb.org/browse/NODE-5773
19+
{ find: 'bson', replacement: require.resolve('bson') }
20+
]
21+
},
1622
envDir: '..', // Use this dir for env vars, not 'src'.
1723
optimizeDeps: {
1824
// Don't optimize these packages as they contain web workers and WASM files.
@@ -22,7 +28,8 @@ export default defineConfig({
2228
'@powersync/web > event-iterator',
2329
'@powersync/web > js-logger',
2430
'@powersync/web > lodash/throttle',
25-
'@powersync/web > can-ndjson-stream'
31+
'@powersync/web > can-ndjson-stream',
32+
'@powersync/web > bson'
2633
]
2734
},
2835
plugins: [wasm(), topLevelAwait()],

demos/react-native-supabase-group-chat/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@powersync/react-native": "workspace:*",
2525
"@powersync/common": "workspace:*",
2626
"@powersync/react": "workspace:*",
27-
"@journeyapps/react-native-quick-sqlite": "1.1.5",
27+
"@journeyapps/react-native-quick-sqlite": "1.1.6",
2828
"@react-native-async-storage/async-storage": "1.21.0",
2929
"@shopify/flash-list": "1.6.3",
3030
"@supabase/supabase-js": "2.39.0",
@@ -59,7 +59,7 @@
5959
"react-native-web": "0.19.9",
6060
"tamagui": "1.79.6",
6161
"text-encoding": "^0.7.0",
62-
"web-streams-polyfill": "^3.2.1"
62+
"web-streams-polyfill": "3.2.1"
6363
},
6464
"devDependencies": {
6565
"@babel/core": "7.23.5",

demos/react-native-supabase-todolist/android/app/src/main/java/com/powersync/example/MainApplication.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class MainApplication : Application(), ReactApplication {
5252
// If you opted-in for the New Architecture, we load the native entry point for this app.
5353
load()
5454
}
55-
// if (BuildConfig.DEBUG) {
56-
// ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
57-
// }
55+
if (BuildConfig.DEBUG) {
56+
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
57+
}
5858
ApplicationLifecycleDispatcher.onApplicationCreate(this)
5959
}
6060

demos/react-native-supabase-todolist/app/views/todos/_layout.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Stack } from 'expo-router';
2-
import React from 'react';
32

43
/**
54
* Stack to edit a list from the todos view

0 commit comments

Comments
 (0)