Skip to content

Commit 2077244

Browse files
mugikhansimolus3
andauthored
Feat: Web sync worker (#200)
* Add shared sync worker * Use sync worker in example * Reconnect with other tab on close * Mention why collection is necessary * Update lock files * Remove dependency overrides * Bump sqlite_async versions * Add crudThrottleTime to create a throttled update notification stream for sync worker * Bump sqlite-async to v0.10.1 * chore(release): publish packages - powersync@1.9.0 - powersync_attachments_helper@0.6.14 * Copy sync worker to demos --------- Co-authored-by: Simon Binder <oss@simonbinder.eu>
1 parent 4230188 commit 2077244

File tree

42 files changed

+1212
-169
lines changed

Some content is hidden

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

42 files changed

+1212
-169
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
tag="${{ github.ref_name }}"
3737
body="Release $tag"
3838
gh release create --draft "$tag" --title "$tag" --notes "$body" --generate-notes
39-
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js
39+
gh release upload "${{ github.ref_name }}" packages/powersync/assets/powersync_db.worker.js packages/powersync/assets/powersync_sync.worker.js

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ assets/*
1919
powersync_db.worker.js
2020
powersync_db.worker.js*
2121
sqlite3.wasm
22+
powersync_sync.worker.js
23+
powersync_sync.worker.js*
2224

2325
#Core binaries
2426
*.dylib

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## 2024-11-01
7+
8+
### Changes
9+
10+
---
11+
12+
Packages with breaking changes:
13+
14+
- There are no breaking changes in this release.
15+
16+
Packages with other changes:
17+
18+
- [`powersync` - `v1.9.0`](#powersync---v190)
19+
- [`powersync_attachments_helper` - `v0.6.14`](#powersync_attachments_helper---v0614)
20+
21+
---
22+
23+
#### `powersync` - `v1.9.0`
24+
25+
- **FEAT**: Use a sync worker for web that offloads the task of synchronizing databases to a separate worker, allowing it to be coordinated across tabs even when the database itself is not in a shared worker.
26+
27+
#### `powersync_attachments_helper` - `v0.6.14`
28+
29+
- Update a dependency to the latest release.
30+
631
## 2024-10-31
732

833
### Changes
@@ -62,7 +87,7 @@ Packages with other changes:
6287

6388
#### `powersync_flutter_libs` - `v0.4.1`
6489

65-
- powersync-sqlite-core v0.3.4
90+
- powersync-sqlite-core v0.3.4
6691

6792
## 2024-10-17
6893

demos/django-todolist/.metadata

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "5874a72aa4c779a02553007c47dacbefba2374dc"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
17+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
18+
- platform: android
19+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
20+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
21+
- platform: ios
22+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
23+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
24+
- platform: linux
25+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
26+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
27+
- platform: macos
28+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
29+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
30+
- platform: web
31+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
32+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
33+
- platform: windows
34+
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
35+
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package co.powersync.django_todolist
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Flutter
2+
import UIKit
3+
import XCTest
4+
5+
class RunnerTests: XCTestCase {
6+
7+
func testExample() {
8+
// If you add code to the Runner application, consider adding tests here.
9+
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10+
}
11+
12+
}

demos/django-todolist/lib/powersync.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This file performs setup of the PowerSync database
2+
import 'package:flutter/foundation.dart';
23
import 'package:logging/logging.dart';
34
import 'package:path/path.dart';
45
import 'package:path_provider/path_provider.dart';
@@ -99,8 +100,14 @@ Future<bool> isLoggedIn() async {
99100
}
100101

101102
Future<String> getDatabasePath() async {
103+
const dbFilename = 'powersync-demo.db';
104+
// getApplicationSupportDirectory is not supported on Web
105+
if (kIsWeb) {
106+
return dbFilename;
107+
}
108+
102109
final dir = await getApplicationSupportDirectory();
103-
return join(dir.path, 'powersync-demo.db');
110+
return join(dir.path, dbFilename);
104111
}
105112

106113
// opens the database and connects if logged in

demos/django-todolist/pubspec.lock

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ packages:
152152
url: "https://pub.dev"
153153
source: hosted
154154
version: "4.0.2"
155+
js:
156+
dependency: transitive
157+
description:
158+
name: js
159+
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
160+
url: "https://pub.dev"
161+
source: hosted
162+
version: "0.7.1"
155163
json_annotation:
156164
dependency: transitive
157165
description:
@@ -164,18 +172,18 @@ packages:
164172
dependency: transitive
165173
description:
166174
name: leak_tracker
167-
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
175+
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
168176
url: "https://pub.dev"
169177
source: hosted
170-
version: "10.0.4"
178+
version: "10.0.5"
171179
leak_tracker_flutter_testing:
172180
dependency: transitive
173181
description:
174182
name: leak_tracker_flutter_testing
175-
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
183+
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
176184
url: "https://pub.dev"
177185
source: hosted
178-
version: "3.0.3"
186+
version: "3.0.5"
179187
leak_tracker_testing:
180188
dependency: transitive
181189
description:
@@ -212,18 +220,18 @@ packages:
212220
dependency: transitive
213221
description:
214222
name: material_color_utilities
215-
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
223+
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
216224
url: "https://pub.dev"
217225
source: hosted
218-
version: "0.8.0"
226+
version: "0.11.1"
219227
meta:
220228
dependency: transitive
221229
description:
222230
name: meta
223-
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
231+
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
224232
url: "https://pub.dev"
225233
source: hosted
226-
version: "1.12.0"
234+
version: "1.15.0"
227235
mutex:
228236
dependency: transitive
229237
description:
@@ -310,14 +318,14 @@ packages:
310318
path: "../../packages/powersync"
311319
relative: true
312320
source: path
313-
version: "1.8.8"
321+
version: "1.9.0"
314322
powersync_flutter_libs:
315323
dependency: "direct overridden"
316324
description:
317325
path: "../../packages/powersync_flutter_libs"
318326
relative: true
319327
source: path
320-
version: "0.4.1"
328+
version: "0.4.2"
321329
pub_semver:
322330
dependency: transitive
323331
description:
@@ -439,10 +447,10 @@ packages:
439447
dependency: "direct main"
440448
description:
441449
name: sqlite_async
442-
sha256: "1f7b36e6b5b459bae89941ae1d3ae8151a3c14b8242c3b94e75aea4a692361e2"
450+
sha256: "4a921c53f12b850c5c7337aa7b2c7a0249efd07696180c1ee6de9750632543c7"
443451
url: "https://pub.dev"
444452
source: hosted
445-
version: "0.9.1"
453+
version: "0.10.1"
446454
stack_trace:
447455
dependency: transitive
448456
description:
@@ -479,10 +487,10 @@ packages:
479487
dependency: transitive
480488
description:
481489
name: test_api
482-
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
490+
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
483491
url: "https://pub.dev"
484492
source: hosted
485-
version: "0.7.0"
493+
version: "0.7.2"
486494
typed_data:
487495
dependency: transitive
488496
description:
@@ -519,10 +527,10 @@ packages:
519527
dependency: transitive
520528
description:
521529
name: vm_service
522-
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
530+
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
523531
url: "https://pub.dev"
524532
source: hosted
525-
version: "14.2.1"
533+
version: "14.2.5"
526534
web:
527535
dependency: transitive
528536
description:

demos/django-todolist/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ environment:
1010
dependencies:
1111
flutter:
1212
sdk: flutter
13-
powersync: ^1.8.9
13+
powersync: ^1.9.0
1414
path_provider: ^2.1.1
1515
path: ^1.8.3
1616
logging: ^1.2.0
17-
sqlite_async: ^0.9.0
17+
sqlite_async: ^0.10.1
1818
http: ^1.2.1
1919
shared_preferences: ^2.2.3
2020

demos/django-todolist/web/favicon.png

917 Bytes
Loading
5.17 KB
Loading
8.06 KB
Loading
Loading
Loading

demos/django-todolist/web/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!--
5+
If you are serving your web app in a path other than the root, change the
6+
href value below to reflect the base path you are serving from.
7+
8+
The path provided below has to start and end with a slash "/" in order for
9+
it to work correctly.
10+
11+
For more details:
12+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
13+
14+
This is a placeholder for base href that will be replaced by the value of
15+
the `--base-href` argument provided to `flutter build`.
16+
-->
17+
<base href="$FLUTTER_BASE_HREF">
18+
19+
<meta charset="UTF-8">
20+
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
21+
<meta name="description" content="A new Flutter project.">
22+
23+
<!-- iOS meta tags & icons -->
24+
<meta name="apple-mobile-web-app-capable" content="yes">
25+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
26+
<meta name="apple-mobile-web-app-title" content="django_todolist">
27+
<link rel="apple-touch-icon" href="icons/Icon-192.png">
28+
29+
<!-- Favicon -->
30+
<link rel="icon" type="image/png" href="favicon.png"/>
31+
32+
<title>django_todolist</title>
33+
<link rel="manifest" href="manifest.json">
34+
</head>
35+
<body>
36+
<script src="flutter_bootstrap.js" async></script>
37+
</body>
38+
</html>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "django_todolist",
3+
"short_name": "django_todolist",
4+
"start_url": ".",
5+
"display": "standalone",
6+
"background_color": "#0175C2",
7+
"theme_color": "#0175C2",
8+
"description": "A new Flutter project.",
9+
"orientation": "portrait-primary",
10+
"prefer_related_applications": false,
11+
"icons": [
12+
{
13+
"src": "icons/Icon-192.png",
14+
"sizes": "192x192",
15+
"type": "image/png"
16+
},
17+
{
18+
"src": "icons/Icon-512.png",
19+
"sizes": "512x512",
20+
"type": "image/png"
21+
},
22+
{
23+
"src": "icons/Icon-maskable-192.png",
24+
"sizes": "192x192",
25+
"type": "image/png",
26+
"purpose": "maskable"
27+
},
28+
{
29+
"src": "icons/Icon-maskable-512.png",
30+
"sizes": "512x512",
31+
"type": "image/png",
32+
"purpose": "maskable"
33+
}
34+
]
35+
}

0 commit comments

Comments
 (0)