From 7fb9df2b535f1c7547fd37dd3766c2e0c9ad9606 Mon Sep 17 00:00:00 2001
From: stevensJourney <51082125+stevensJourney@users.noreply.github.com>
Date: Mon, 15 Jan 2024 16:10:27 +0200
Subject: [PATCH 1/2] [Update] Throttled updates (#21)
* update throttled changes from common sdk.
* Fix bug where DB watch listeners would be cleared when multiple connections are opened for the same DB.
---
.changeset/famous-frogs-eat.md | 5 +++++
.changeset/lucky-gorillas-hunt.md | 5 +++++
.changeset/twelve-geckos-shop.md | 5 +++++
demos/powersync-nextjs-demo/package.json | 2 +-
.../src/app/views/todo-lists/edit/page.tsx | 2 +-
.../src/app/views/todo-lists/page.tsx | 2 +-
packages/powersync-sdk-web/package.json | 2 +-
.../AbstractWebPowerSyncDatabaseOpenFactory.ts | 1 +
.../powersync-sdk-web/src/worker/db/open-db.ts | 3 ++-
pnpm-lock.yaml | 18 +++++++++---------
10 files changed, 31 insertions(+), 14 deletions(-)
create mode 100644 .changeset/famous-frogs-eat.md
create mode 100644 .changeset/lucky-gorillas-hunt.md
create mode 100644 .changeset/twelve-geckos-shop.md
diff --git a/.changeset/famous-frogs-eat.md b/.changeset/famous-frogs-eat.md
new file mode 100644
index 0000000..e4c97e8
--- /dev/null
+++ b/.changeset/famous-frogs-eat.md
@@ -0,0 +1,5 @@
+---
+'@journeyapps/powersync-sdk-web': patch
+---
+
+Fix bug where opening multiple WA-SQLite instances would erase DB table change watches.
diff --git a/.changeset/lucky-gorillas-hunt.md b/.changeset/lucky-gorillas-hunt.md
new file mode 100644
index 0000000..5ec7a50
--- /dev/null
+++ b/.changeset/lucky-gorillas-hunt.md
@@ -0,0 +1,5 @@
+---
+'@journeyapps/powersync-sdk-web': patch
+---
+
+Update common SDK dependency to v1.0.1: Improved connector CRUD uploads to be triggered whenever an internal CRUD operation change is triggered. Improved CRUD upload debouncing to rather use a throttled approach - executing multiple continuous write/CRUD operations will now trigger a connector upload at most (every) 1 second (by default).
diff --git a/.changeset/twelve-geckos-shop.md b/.changeset/twelve-geckos-shop.md
new file mode 100644
index 0000000..c2f6274
--- /dev/null
+++ b/.changeset/twelve-geckos-shop.md
@@ -0,0 +1,5 @@
+---
+'@journeyapps/powersync-nextjs-demo': patch
+---
+
+Autofocus inputs in creation dialogs for a better UX.
diff --git a/demos/powersync-nextjs-demo/package.json b/demos/powersync-nextjs-demo/package.json
index 76a6cea..d403d16 100644
--- a/demos/powersync-nextjs-demo/package.json
+++ b/demos/powersync-nextjs-demo/package.json
@@ -14,7 +14,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.8",
- "@journeyapps/powersync-react": "1.0.0",
+ "@journeyapps/powersync-react": "1.0.1",
"@journeyapps/powersync-sdk-web": "workspace:*",
"@journeyapps/wa-sqlite": "~0.1.0",
"@mui/icons-material": "^5.14.16",
diff --git a/demos/powersync-nextjs-demo/src/app/views/todo-lists/edit/page.tsx b/demos/powersync-nextjs-demo/src/app/views/todo-lists/edit/page.tsx
index 1d493e6..20048e6 100644
--- a/demos/powersync-nextjs-demo/src/app/views/todo-lists/edit/page.tsx
+++ b/demos/powersync-nextjs-demo/src/app/views/todo-lists/edit/page.tsx
@@ -126,7 +126,7 @@ const TodoEditSection = () => {
{'Create Todo Item'}
Enter a description for a new todo item
-
+
diff --git a/demos/powersync-nextjs-demo/src/app/views/todo-lists/page.tsx b/demos/powersync-nextjs-demo/src/app/views/todo-lists/page.tsx
index 28666a4..1d31ad8 100644
--- a/demos/powersync-nextjs-demo/src/app/views/todo-lists/page.tsx
+++ b/demos/powersync-nextjs-demo/src/app/views/todo-lists/page.tsx
@@ -103,7 +103,7 @@ export default function TodoListsPage() {
{'Create Todo List'}
Enter a name for a new todo list
-
+
diff --git a/packages/powersync-sdk-web/package.json b/packages/powersync-sdk-web/package.json
index 570dd6d..1ef8d77 100644
--- a/packages/powersync-sdk-web/package.json
+++ b/packages/powersync-sdk-web/package.json
@@ -41,7 +41,7 @@
"@journeyapps/wa-sqlite": "~0.1.0"
},
"dependencies": {
- "@journeyapps/powersync-sdk-common": "1.0.0",
+ "@journeyapps/powersync-sdk-common": "1.0.1",
"async-mutex": "^0.4.0",
"comlink": "^4.4.1",
"js-logger": "^1.6.1",
diff --git a/packages/powersync-sdk-web/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts b/packages/powersync-sdk-web/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts
index e107830..e4caf2c 100644
--- a/packages/powersync-sdk-web/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts
+++ b/packages/powersync-sdk-web/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts
@@ -65,6 +65,7 @@ export abstract class AbstractWebPowerSyncDatabaseOpenFactory extends AbstractPo
}
return {
+ ...this.options,
database: isServerSide ? new SSRDBAdapter() : this.openDB(),
schema: this.schema,
flags: resolvedFlags
diff --git a/packages/powersync-sdk-web/src/worker/db/open-db.ts b/packages/powersync-sdk-web/src/worker/db/open-db.ts
index afe7913..69dd176 100644
--- a/packages/powersync-sdk-web/src/worker/db/open-db.ts
+++ b/packages/powersync-sdk-web/src/worker/db/open-db.ts
@@ -24,6 +24,8 @@ export type WASQLiteExecuteMethod = (sql: string, params?: any[]) => Promise void;
export type OpenDB = (dbFileName: string) => DBWorkerInterface;
+const listeners = new Map();
+
export async function _openDB(dbFileName: string): Promise {
const { default: moduleFactory } = await import('@journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs');
const module = await moduleFactory();
@@ -34,7 +36,6 @@ export async function _openDB(dbFileName: string): Promise {
sqlite3.vfs_register(vfs, true);
const db = await sqlite3.open_v2(dbFileName);
- const listeners = new Map();
sqlite3.register_table_onchange_hook(db, (opType: number, tableName: string, rowId: number) => {
Array.from(listeners.values()).forEach((l) => l(opType, tableName, rowId));
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d48b82c..e313cf8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -62,8 +62,8 @@ importers:
specifier: ^5.0.8
version: 5.0.8
'@journeyapps/powersync-react':
- specifier: 1.0.0
- version: 1.0.0(react@18.0.0)
+ specifier: 1.0.1
+ version: 1.0.1(react@18.0.0)
'@journeyapps/powersync-sdk-web':
specifier: workspace:*
version: link:../../packages/powersync-sdk-web
@@ -138,8 +138,8 @@ importers:
packages/powersync-sdk-web:
dependencies:
'@journeyapps/powersync-sdk-common':
- specifier: 1.0.0
- version: 1.0.0
+ specifier: 1.0.1
+ version: 1.0.1
async-mutex:
specifier: ^0.4.0
version: 0.4.0
@@ -1948,17 +1948,17 @@ packages:
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
dev: true
- /@journeyapps/powersync-react@1.0.0(react@18.0.0):
- resolution: {integrity: sha512-WMSIScA4cZbBBFAD9p/v6vn/0ixv0tLaVMcx84pIkUSy9FNn8gI0G9ciwUIcyGSNI1sMnCjyH76NwXo48WtY5w==}
+ /@journeyapps/powersync-react@1.0.1(react@18.0.0):
+ resolution: {integrity: sha512-0DCF4C2OijDnxT03dEsrnP2Qhn4k/XwOzdQeLJR7aPS6vr3TTbn//TFSPO8caJmWfZnh3a65uSVlXOvodfpfXQ==}
peerDependencies:
react: '*'
dependencies:
- '@journeyapps/powersync-sdk-common': 1.0.0
+ '@journeyapps/powersync-sdk-common': 1.0.1
react: 18.0.0
dev: false
- /@journeyapps/powersync-sdk-common@1.0.0:
- resolution: {integrity: sha512-mVyIsWiSQPMvAcQ715x+qomYp9C2LZKi/k+w7ZMpWN3KrwIPNWskF6DYHGOwnl9J0uaDC74T9yrwmVganEa3JQ==}
+ /@journeyapps/powersync-sdk-common@1.0.1:
+ resolution: {integrity: sha512-MTAAHyL3jbvknXBuroDheoNDvyntH1Wt/HPLopnaFupg13eJRx/1vvAPd5KRmMwpPpGL+j7P5zMJ+YgvRYIXzw==}
dependencies:
async-mutex: 0.4.0
can-ndjson-stream: 1.0.2
From e5fcd40ad98055b675868c541685424f30b9cb4e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 15 Jan 2024 16:16:35 +0200
Subject: [PATCH 2/2] chore: update versions (#22)
Co-authored-by: github-actions[bot]
---
.changeset/famous-frogs-eat.md | 5 -----
.changeset/lucky-gorillas-hunt.md | 5 -----
.changeset/twelve-geckos-shop.md | 5 -----
demos/example-vite/CHANGELOG.md | 8 ++++++++
demos/example-vite/package.json | 2 +-
demos/example-webpack/CHANGELOG.md | 8 ++++++++
demos/powersync-nextjs-demo/CHANGELOG.md | 9 +++++++++
demos/powersync-nextjs-demo/package.json | 2 +-
packages/powersync-sdk-web/CHANGELOG.md | 7 +++++++
packages/powersync-sdk-web/package.json | 2 +-
10 files changed, 35 insertions(+), 18 deletions(-)
delete mode 100644 .changeset/famous-frogs-eat.md
delete mode 100644 .changeset/lucky-gorillas-hunt.md
delete mode 100644 .changeset/twelve-geckos-shop.md
diff --git a/.changeset/famous-frogs-eat.md b/.changeset/famous-frogs-eat.md
deleted file mode 100644
index e4c97e8..0000000
--- a/.changeset/famous-frogs-eat.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@journeyapps/powersync-sdk-web': patch
----
-
-Fix bug where opening multiple WA-SQLite instances would erase DB table change watches.
diff --git a/.changeset/lucky-gorillas-hunt.md b/.changeset/lucky-gorillas-hunt.md
deleted file mode 100644
index 5ec7a50..0000000
--- a/.changeset/lucky-gorillas-hunt.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@journeyapps/powersync-sdk-web': patch
----
-
-Update common SDK dependency to v1.0.1: Improved connector CRUD uploads to be triggered whenever an internal CRUD operation change is triggered. Improved CRUD upload debouncing to rather use a throttled approach - executing multiple continuous write/CRUD operations will now trigger a connector upload at most (every) 1 second (by default).
diff --git a/.changeset/twelve-geckos-shop.md b/.changeset/twelve-geckos-shop.md
deleted file mode 100644
index c2f6274..0000000
--- a/.changeset/twelve-geckos-shop.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@journeyapps/powersync-nextjs-demo': patch
----
-
-Autofocus inputs in creation dialogs for a better UX.
diff --git a/demos/example-vite/CHANGELOG.md b/demos/example-vite/CHANGELOG.md
index 8964b80..1f49a9d 100644
--- a/demos/example-vite/CHANGELOG.md
+++ b/demos/example-vite/CHANGELOG.md
@@ -1,5 +1,13 @@
# example-vite
+## 0.0.2
+
+### Patch Changes
+
+- Updated dependencies [7fb9df2]
+- Updated dependencies [7fb9df2]
+ - @journeyapps/powersync-sdk-web@0.1.2
+
## 0.0.1
### Patch Changes
diff --git a/demos/example-vite/package.json b/demos/example-vite/package.json
index b15ce3a..b0a538d 100644
--- a/demos/example-vite/package.json
+++ b/demos/example-vite/package.json
@@ -1,7 +1,7 @@
{
"name": "example-vite",
"private": true,
- "version": "0.0.1",
+ "version": "0.0.2",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/demos/example-webpack/CHANGELOG.md b/demos/example-webpack/CHANGELOG.md
index 04284aa..b905fa4 100644
--- a/demos/example-webpack/CHANGELOG.md
+++ b/demos/example-webpack/CHANGELOG.md
@@ -4,5 +4,13 @@
### Patch Changes
+- Updated dependencies [7fb9df2]
+- Updated dependencies [7fb9df2]
+ - @journeyapps/powersync-sdk-web@0.1.2
+
+## null
+
+### Patch Changes
+
- Updated dependencies [0e17713]
- @journeyapps/powersync-sdk-web@0.1.1
diff --git a/demos/powersync-nextjs-demo/CHANGELOG.md b/demos/powersync-nextjs-demo/CHANGELOG.md
index ab61c15..2535cf4 100644
--- a/demos/powersync-nextjs-demo/CHANGELOG.md
+++ b/demos/powersync-nextjs-demo/CHANGELOG.md
@@ -1,5 +1,14 @@
# @journeyapps/powersync-nextjs-demo
+## 0.1.6
+
+### Patch Changes
+
+- 7fb9df2: Autofocus inputs in creation dialogs for a better UX.
+- Updated dependencies [7fb9df2]
+- Updated dependencies [7fb9df2]
+ - @journeyapps/powersync-sdk-web@0.1.2
+
## 0.1.5
### Patch Changes
diff --git a/demos/powersync-nextjs-demo/package.json b/demos/powersync-nextjs-demo/package.json
index d403d16..6e8274c 100644
--- a/demos/powersync-nextjs-demo/package.json
+++ b/demos/powersync-nextjs-demo/package.json
@@ -1,6 +1,6 @@
{
"name": "@journeyapps/powersync-nextjs-demo",
- "version": "0.1.5",
+ "version": "0.1.6",
"private": true,
"scripts": {
"build": "next build",
diff --git a/packages/powersync-sdk-web/CHANGELOG.md b/packages/powersync-sdk-web/CHANGELOG.md
index 899a160..4c5aafb 100644
--- a/packages/powersync-sdk-web/CHANGELOG.md
+++ b/packages/powersync-sdk-web/CHANGELOG.md
@@ -1,5 +1,12 @@
# @journeyapps/powersync-sdk-web
+## 0.1.2
+
+### Patch Changes
+
+- 7fb9df2: Fix bug where opening multiple WA-SQLite instances would erase DB table change watches.
+- 7fb9df2: Update common SDK dependency to v1.0.1: Improved connector CRUD uploads to be triggered whenever an internal CRUD operation change is triggered. Improved CRUD upload debouncing to rather use a throttled approach - executing multiple continuous write/CRUD operations will now trigger a connector upload at most (every) 1 second (by default).
+
## 0.1.1
### Patch Changes
diff --git a/packages/powersync-sdk-web/package.json b/packages/powersync-sdk-web/package.json
index 1ef8d77..47fd0df 100644
--- a/packages/powersync-sdk-web/package.json
+++ b/packages/powersync-sdk-web/package.json
@@ -1,6 +1,6 @@
{
"name": "@journeyapps/powersync-sdk-web",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "A Web SDK for JourneyApps PowerSync",
"main": "dist/index.js",
"types": "dist/index.d.ts",