Skip to content

Commit 6fb26d9

Browse files
committed
Migrate Yjs demo to vite.
1 parent 493979f commit 6fb26d9

36 files changed

+3336
-927
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copy this template: `cp .env.local.template .env.local`
22
# Edit .env.local and enter your Supabase and PowerSync project details.
3-
SUPABASE_URL=https://foo.supabase.co
4-
SUPABASE_ANON_KEY=foo
5-
POWERSYNC_URL=https://foo.powersync.journeyapps.com
3+
VITE_SUPABASE_URL=https://foo.supabase.co
4+
VITE_SUPABASE_ANON_KEY=foo
5+
VITE_POWERSYNC_URL=https://foo.powersync.journeyapps.com

demos/react-supabase-todolist/src/library/powersync/SupabaseConnector.ts

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
UpdateType
77
} from '@journeyapps/powersync-sdk-web';
88

9-
import { SupabaseClient, createClient, Session, PostgrestError } from '@supabase/supabase-js';
9+
import { Session, SupabaseClient, createClient } from '@supabase/supabase-js';
1010

1111
export type SupabaseConfig = {
1212
supabaseUrl: string;
@@ -32,49 +32,35 @@ export type SupabaseConnectorListener = {
3232
};
3333

3434
export class SupabaseConnector extends BaseObserver<SupabaseConnectorListener> implements PowerSyncBackendConnector {
35-
private _client: SupabaseClient | null;
36-
private _config: SupabaseConfig | null;
35+
readonly client: SupabaseClient;
36+
readonly config: SupabaseConfig;
3737

3838
ready: boolean;
3939

4040
currentSession: Session | null;
4141

4242
constructor() {
4343
super();
44-
this._client = null;
45-
this._config = {
44+
this.config = {
4645
supabaseUrl: import.meta.env.VITE_SUPABASE_URL,
4746
powersyncUrl: import.meta.env.VITE_POWERSYNC_URL,
4847
supabaseAnonKey: import.meta.env.VITE_SUPABASE_ANON_KEY
4948
};
49+
50+
this.client = createClient(this.config.supabaseUrl, this.config.supabaseAnonKey, {
51+
auth: {
52+
persistSession: true
53+
}
54+
});
5055
this.currentSession = null;
5156
this.ready = false;
5257
}
5358

54-
get client(): SupabaseClient {
55-
if (!this._client) {
56-
throw new Error('Supabase client has not been initialized yet');
57-
}
58-
return this._client;
59-
}
60-
61-
get config(): SupabaseConfig {
62-
if (!this._config) {
63-
throw new Error('Supabase client has not been initialized yet');
64-
}
65-
return this._config;
66-
}
67-
6859
async init() {
6960
if (this.ready) {
7061
return;
7162
}
7263

73-
this._client = createClient(this.config.supabaseUrl, this.config.supabaseAnonKey, {
74-
auth: {
75-
persistSession: true
76-
}
77-
});
7864
const sessionResponse = await this.client.auth.getSession();
7965
this.updateSession(sessionResponse.data.session);
8066

demos/react-supabase-todolist/tsconfig.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

demos/yjs-nextjs-supabase-text-collab/.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

demos/yjs-nextjs-supabase-text-collab/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ yarn-debug.log*
3030

3131
# typescript
3232
*.tsbuildinfo
33-
next-env.d.ts
3433

3534
# ide
3635
.idea

demos/yjs-nextjs-supabase-text-collab/next.config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

demos/yjs-nextjs-supabase-text-collab/package.json

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33
"version": "0.0.5",
44
"private": true,
55
"scripts": {
6-
"build": "next build",
7-
"clean": "rm -rf .next",
8-
"watch": "next dev",
9-
"start": "next start",
10-
"lint": "next lint"
6+
"dev": "vite",
7+
"build": "tsc -b && vite build",
8+
"preview": "vite preview",
9+
"start": "pnpm build && pnpm preview"
1110
},
1211
"dependencies": {
13-
"@emotion/react": "^11.11.3",
12+
"@emotion/react": "^11.11.4",
1413
"@emotion/styled": "^11.11.0",
15-
"@fontsource/roboto": "^5.0.8",
14+
"@fontsource/roboto": "^5.0.12",
1615
"@journeyapps/powersync-react": "workspace:*",
1716
"@journeyapps/powersync-sdk-web": "workspace:*",
1817
"@journeyapps/wa-sqlite": "~0.1.1",
19-
"@lexical/react": "^0.11.1",
20-
"@mui/icons-material": "^5.15.8",
21-
"@mui/material": "^5.15.7",
22-
"@mui/x-data-grid": "^6.19.3",
23-
"@supabase/supabase-js": "^2.39.3",
18+
"@lexical/react": "^0.11.3",
19+
"@mui/icons-material": "^5.15.11",
20+
"@mui/material": "^5.15.11",
21+
"@mui/x-data-grid": "^6.19.6",
22+
"@supabase/supabase-js": "^2.39.7",
2423
"@tiptap/extension-collaboration": "2.2.2",
2524
"@tiptap/extension-collaboration-cursor": "2.2.2",
2625
"@tiptap/extension-highlight": "2.2.2",
@@ -35,37 +34,33 @@
3534
"js-logger": "^1.6.1",
3635
"lato-font": "^3.0.0",
3736
"lexical": "^0.11.3",
38-
"lib0": "^0.2.88",
37+
"lib0": "^0.2.91",
3938
"lodash": "^4.17.21",
4039
"lowlight": "^2.9.0",
41-
"next": "14.1.0",
42-
"next-images": "1.8.5",
43-
"react": "^18",
44-
"react-dom": "^18",
40+
"react": "^18.2.0",
41+
"react-dom": "^18.2.0",
42+
"react-router": "^6.22.2",
43+
"react-router-dom": "^6.22.2",
4544
"remixicon": "^2.5.0",
46-
"shiki": "^0.10.0",
45+
"shiki": "^0.10.1",
4746
"simplify-js": "^1.2.4",
4847
"uuid": "9.0.1",
4948
"y-prosemirror": "1.0.20",
5049
"y-protocols": "1.0.6",
51-
"yjs": "^13.6.11"
50+
"yjs": "^13.6.14"
5251
},
5352
"devDependencies": {
5453
"@types/lodash": "^4.14.202",
55-
"@types/node": "^20.11.16",
56-
"@types/react": "^18.2.55",
54+
"@types/node": "^20.11.24",
55+
"@types/react": "^18.2.63",
5756
"@types/react-dom": "^18.2.19",
5857
"@types/uuid": "9.0.8",
59-
"autoprefixer": "^10.4.17",
60-
"babel-loader": "^9.1.3",
61-
"css-loader": "^6.10.0",
62-
"eslint": "^8",
63-
"eslint-config-next": "14.0.0",
58+
"autoprefixer": "^10.4.18",
6459
"postcss": "^8.4.35",
65-
"sass": "^1.49.7",
66-
"sass-loader": "^13.3.3",
6760
"style-loader": "^3.3.4",
6861
"supabase": "1.142.2",
69-
"tailwindcss": "^3.4.1"
62+
"vite": "^5.1.5",
63+
"vite-plugin-top-level-await": "^1.4.1",
64+
"vite-plugin-wasm": "^3.3.0"
7065
}
7166
}

demos/yjs-nextjs-supabase-text-collab/postcss.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.
1.18 KB
Binary file not shown.
14.3 KB
Loading

0 commit comments

Comments
 (0)