Skip to content

Commit 319e403

Browse files
committed
Merge branch 'main' into configurable-vfs
# Conflicts: # demos/react-supabase-todolist/package.json # packages/web/package.json # pnpm-lock.yaml
2 parents 77543e3 + f0b6394 commit 319e403

File tree

105 files changed

+30580
-19396
lines changed

Some content is hidden

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

105 files changed

+30580
-19396
lines changed

demos/angular-supabase-todolist/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,5 @@ testem.log
166166
# System files
167167
.DS_Store
168168
Thumbs.db
169+
170+
src/assets/@powersync

demos/angular-supabase-todolist/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This demo is currently in an alpha release.
88

99
Demo app demonstrating use of the [PowerSync SDK for Web](https://www.npmjs.com/package/@powersync/web) together with Supabase.
1010

11-
A step-by-step guide on Supabase<>PowerSync integration is available [here](https://docs.powersync.com/integration-guides/supabase).
11+
A step-by-step guide on Supabase<>PowerSync integration is available [here](https://docs.powersync.com/integration-guides/supabase-+-powersync).
1212

1313
## Quick Start
1414

@@ -19,7 +19,10 @@ A step-by-step guide on Supabase<>PowerSync integration is available [here](http
1919
5. In a new terminal run `pnpm start` to start the server
2020
6. Go to <http://localhost:8080>
2121

22-
**Note:** The Angular development server (`pnpm serve`) doesn't support service worker applications
22+
### Notes
23+
24+
- The Angular development server (`pnpm serve`) doesn't support service worker applications
25+
- For Angular, workers need to be configured when instantiating `PowerSyncDatabase`. To do this, copy the worker assets (`pnpm powersync-web copy-assets -o src/assets` - done automatically in this demo for serving and building) and ensure the worker paths are specified ([example here](./src/app/powersync.service.ts)).
2326

2427
## Development Server
2528

demos/angular-supabase-todolist/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"name": "angular-supabase-todolist",
33
"version": "0.0.25",
44
"scripts": {
5+
"copy-assets": "pnpm powersync-web copy-assets -o src/assets",
56
"ng": "ng",
6-
"serve": "ng serve",
7+
"serve": "pnpm copy-assets && ng serve",
78
"start": "http-server -p 8080 -c-1 dist/",
8-
"build": "ng build",
9+
"build": "pnpm copy-assets && ng build",
910
"format": "prettier --write .",
1011
"test:build": "pnpm build",
12+
"prewatch": "pnpm copy-assets",
1113
"watch": "ng build --watch --configuration development"
1214
},
1315
"private": true,
@@ -21,7 +23,7 @@
2123
"@angular/platform-browser-dynamic": "^18.1.1",
2224
"@angular/router": "^18.1.1",
2325
"@angular/service-worker": "^18.1.1",
24-
"@journeyapps/wa-sqlite": "^1.0.0",
26+
"@journeyapps/wa-sqlite": "^1.2.0",
2527
"@powersync/web": "workspace:*",
2628
"@supabase/supabase-js": "^2.44.4",
2729
"rxjs": "~7.8.1",

demos/angular-supabase-todolist/src/app/powersync.service.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import {
66
Index,
77
IndexedColumn,
88
PowerSyncBackendConnector,
9+
PowerSyncDatabase,
910
Schema,
1011
Table,
11-
WASQLitePowerSyncDatabaseOpenFactory
12+
WASQLiteOpenFactory
1213
} from '@powersync/web';
1314

1415
export interface ListRecord {
@@ -63,11 +64,21 @@ export class PowerSyncService {
6364
db: AbstractPowerSyncDatabase;
6465

6566
constructor() {
66-
const PowerSyncFactory = new WASQLitePowerSyncDatabaseOpenFactory({
67+
const factory = new WASQLiteOpenFactory({
68+
dbFilename: 'test.db',
69+
70+
// Specify the path to the worker script
71+
worker: 'assets/@powersync/worker/WASQLiteDB.umd.js'
72+
});
73+
74+
this.db = new PowerSyncDatabase({
6775
schema: AppSchema,
68-
dbFilename: 'test.db'
76+
database: factory,
77+
sync: {
78+
// Specify the path to the worker script
79+
worker: 'assets/@powersync/worker/SharedSyncImplementation.umd.js'
80+
}
6981
});
70-
this.db = PowerSyncFactory.getInstance();
7182
}
7283

7384
setupPowerSync = async (connector: PowerSyncBackendConnector) => {

demos/angular-supabase-todolist/src/app/supabase.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ export class SupabaseService implements PowerSyncBackendConnector {
6565
}
6666

6767
return {
68-
client: this.supabase,
6968
endpoint: environment.powersyncUrl,
70-
token: session.access_token ?? '',
71-
expiresAt: session.expires_at ? new Date(session.expires_at * 1000) : undefined
69+
token: session.access_token ?? ''
7270
};
7371
}
7472

demos/django-react-native-todolist/app/views/todos/lists.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const App = () => {
3434
return;
3535
}
3636

37-
const { userID } = await system.djangoConnector.fetchCredentials();
37+
const userID = await system.djangoConnector.userId();
3838

3939
await system.powersync.execute(
4040
`INSERT INTO ${LIST_TABLE} (id, created_at, name, owner_id) VALUES (uuid(), datetime(), ?, ?)`,

demos/django-react-native-todolist/library/django/DjangoConnector.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export class DjangoConnector implements PowerSyncBackendConnector {
3535
return this.apiClient.register(username, password);
3636
}
3737

38+
async userId() {
39+
return Storage.getItem('id');
40+
}
41+
3842
async fetchCredentials() {
3943
// The demo does not invalidate or update a user token, you should implement this in your app
4044
// The app stores the user id in local storage
@@ -45,9 +49,7 @@ export class DjangoConnector implements PowerSyncBackendConnector {
4549
const session = await this.apiClient.getToken(userId);
4650
return {
4751
endpoint: AppConfig.powersyncUrl,
48-
token: session.token ?? '',
49-
expiresAt: undefined,
50-
userID: userId
52+
token: session.token ?? ''
5153
};
5254
}
5355

demos/django-react-native-todolist/library/powersync/AppSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { column, Schema, TableV2 } from '@powersync/react-native';
1+
import { column, Schema, Table } from '@powersync/react-native';
22

33
export const LIST_TABLE = 'lists';
44
export const TODO_TABLE = 'todos';
55

6-
const todos = new TableV2(
6+
const todos = new Table(
77
{
88
list_id: column.text,
99
created_at: column.text,
@@ -17,7 +17,7 @@ const todos = new TableV2(
1717
{ indexes: { list: ['list_id'] } }
1818
);
1919

20-
const lists = new TableV2({
20+
const lists = new Table({
2121
created_at: column.text,
2222
name: column.text,
2323
owner_id: column.text

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@azure/core-asynciterator-polyfill": "^1.0.2",
1212
"@expo/vector-icons": "^14.0.0",
13-
"@journeyapps/react-native-quick-sqlite": "^2.2.0",
13+
"@journeyapps/react-native-quick-sqlite": "^2.3.0",
1414
"@powersync/common": "workspace:*",
1515
"@powersync/react": "workspace:*",
1616
"@powersync/react-native": "workspace:*",

demos/example-capacitor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@capacitor/core": "latest",
2424
"@capacitor/ios": "^6.0.0",
2525
"@capacitor/splash-screen": "latest",
26-
"@journeyapps/wa-sqlite": "^1.0.0",
26+
"@journeyapps/wa-sqlite": "^1.2.0",
2727
"@powersync/react": "workspace:*",
2828
"@powersync/web": "workspace:*",
2929
"js-logger": "^1.6.1",

0 commit comments

Comments
 (0)