Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-spiders-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@powersync/sql-js": patch
---

Update PowerSync SQLite core extension to version 0.5.1
16 changes: 5 additions & 11 deletions .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ jobs:
name: Build Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
with:
persist-credentials: false

- uses: pnpm/action-setup@v4
name: Install pnpm

- name: Enable Corepack
run: corepack enable
- name: Setup NodeJS
uses: actions/setup-node@v6
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
cache: pnpm

- name: Update npm
run: |
npm install -g npm@latest
npm --version

- name: Install dependencies
run: pnpm install
Expand All @@ -36,7 +30,7 @@ jobs:
sudo apt-get install -y libdigest-sha3-perl

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
uses: emscripten-core/setup-emsdk@v16
with:
version: "latest"
actions-cache-folder: "emsdk-cache"
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
uses: actions/checkout@v7

- name: Enable Corepack
run: corepack enable
- name: Setup NodeJS
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
cache: pnpm
- name: Update npm
run: |
npm install -g npm@latest
npm --version

- name: Install dependencies
run: pnpm install
Expand All @@ -45,9 +39,9 @@ jobs:
sudo apt-get install -y libdigest-sha3-perl

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
uses: emscripten-core/setup-emsdk@v16
with:
version: 4.0.10
version: "latest"
actions-cache-folder: "emsdk-cache"

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v24.10.0
v26.5.0
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

POWERSYNC_CORE_VERSION="0.4.12"
POWERSYNC_CORE_VERSION="0.5.1"
SQLITE_PATH="sql.js"

if [ -d "$SQLITE_PATH" ]; then
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"devDependencies": {
"@changesets/cli": "^2.29.5"
},
"packageManager": "pnpm@10.19.0+sha512.c9fc7236e92adf5c8af42fd5bf1612df99c2ceb62f27047032f4720b33f8eacdde311865e91c411f2774f618d82f320808ecb51718bfa82c060c4ba7c76a32b8"
"packageManager": "pnpm@11.17.0+sha512.cca3cea332ad254bb84145f966d19f4879615210346fc92c79a047f23a0d7b3cca3c3792f0076ba1f1831d277efbcf0a9119b31a9a60eca7fb3d6231f331ef72"
}
16 changes: 0 additions & 16 deletions patches/powersync-update-002.patch

This file was deleted.

34 changes: 0 additions & 34 deletions patches/powersync-update.patch

This file was deleted.

70 changes: 21 additions & 49 deletions patches/powersync.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/Makefile b/Makefile
index 4530653..8c40a26 100644
index 4530653..9435392 100644
--- a/Makefile
+++ b/Makefile
@@ -6,14 +6,15 @@
Expand Down Expand Up @@ -31,15 +31,6 @@ index 4530653..8c40a26 100644

# When compiling to WASM, enabling memory-growth is not expected to make much of an impact, so we enable it for all builds
# Since tihs is a library and not a standalone executable, we don't want to catch unhandled Node process exceptions
@@ -59,7 +61,7 @@ EMFLAGS_DEBUG = \
-s ASSERTIONS=2 \
-O1

-BITCODE_FILES = out/sqlite3.o out/extension-functions.o
+BITCODE_FILES = out/sqlite3.o out/extension-functions.o out/update.o

OUTPUT_WRAPPER_FILES = src/shell-pre.js src/shell-post.js

@@ -76,13 +78,13 @@ all: optimized debug worker
debug: dist/sql-asm-debug.js dist/sql-wasm-debug.js

Expand Down Expand Up @@ -79,17 +70,7 @@ index 4530653..8c40a26 100644
mv $@ out/tmp-raw.js
cat src/shell-pre.js out/tmp-raw.js src/shell-post.js > $@
rm out/tmp-raw.js
@@ -153,6 +155,9 @@ out/extension-functions.o: sqlite-src/$(SQLITE_AMALGAMATION)
# Generate llvm bitcode
$(EMCC) $(SQLITE_COMPILATION_FLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@

+out/update.o: sqlite-src/$(SQLITE_AMALGAMATION)
+ $(EMCC) $(SQLITE_COMPILATION_FLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/update.c -o $@
+
# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
# tar --create --gzip $^ > $@
@@ -172,8 +177,8 @@ sqlite-src: sqlite-src/$(SQLITE_AMALGAMATION) sqlite-src/$(SQLITE_AMALGAMATION)/
@@ -172,8 +174,8 @@ sqlite-src: sqlite-src/$(SQLITE_AMALGAMATION) sqlite-src/$(SQLITE_AMALGAMATION)/

sqlite-src/$(SQLITE_AMALGAMATION): cache/$(SQLITE_AMALGAMATION).zip sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTIONS)
mkdir -p sqlite-src/$(SQLITE_AMALGAMATION)
Expand All @@ -100,47 +81,40 @@ index 4530653..8c40a26 100644
# We don't delete the sqlite_amalgamation folder. That's a job for clean
# Also, the extension functions get copied here, and if we get the order of these steps wrong,
# this step could remove the extension functions, and that's not what we want
@@ -182,11 +187,15 @@ sqlite-src/$(SQLITE_AMALGAMATION): cache/$(SQLITE_AMALGAMATION).zip sqlite-src/$

sqlite-src/$(SQLITE_AMALGAMATION)/$(EXTENSION_FUNCTIONS): cache/$(EXTENSION_FUNCTIONS)
mkdir -p sqlite-src/$(SQLITE_AMALGAMATION)
+ cp 'src/update.c' sqlite-src/$(SQLITE_AMALGAMATION)/update.c
echo '$(EXTENSION_FUNCTIONS_SHA1) ./cache/$(EXTENSION_FUNCTIONS)' > cache/check.txt
sha1sum -c cache/check.txt
cp 'cache/$(EXTENSION_FUNCTIONS)' $@


+sqlite-src/$(SQLITE_AMALGAMATION)/update.c: sqlite-src
+ cp 'src/update.c' $@
+
.PHONY: clean
clean:
rm -f out/* dist/* cache/*

diff --git a/src/api.js b/src/api.js
index c7f102b..4c20316 100644
index c7f102b..a40b32a 100644
--- a/src/api.js
+++ b/src/api.js
@@ -72,6 +72,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
@@ -72,6 +72,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
var SQLITE_UPDATE = 23;
var SQLITE_DELETE = 9;
// var - cwrap function
+ Module['ccall']('powersync_init_static', 'int', []);
+ Module['ccall']('register_update_hook_extension', 'void', []);
+
+
var sqlite3_open = cwrap("sqlite3_open", "number", ["string", "number"]);
var sqlite3_close_v2 = cwrap("sqlite3_close_v2", "number", ["number"]);
var sqlite3_exec = cwrap(
@@ -122,6 +126,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
@@ -122,6 +124,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
"number",
["number", "string"]
);
+ var sqlite3_last_insert_rowid = cwrap("sqlite3_last_insert_rowid", "number", ["number"]);
var sqlite3_step = cwrap("sqlite3_step", "number", ["number"]);
var sqlite3_errmsg = cwrap("sqlite3_errmsg", "string", ["number"]);
var sqlite3_column_count = cwrap(
@@ -1155,6 +1160,13 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
@@ -613,6 +616,11 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
if (val === null) {
return this.bindNull(pos);
}
+
+ // Add ArrayBuffer support
+ if (val instanceof ArrayBuffer) {
+ return this.bindBlob(new Uint8Array(val), pos);
+ }
if (val.length != null) {
return this.bindBlob(val, pos);
}
@@ -1155,6 +1163,13 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
return sqlite3_changes(this.db);
};

Expand All @@ -155,10 +129,10 @@ index c7f102b..4c20316 100644
var size = sqlite3_value_bytes(ptr);
var blob_ptr = sqlite3_value_blob(ptr);
diff --git a/src/exported_functions.json b/src/exported_functions.json
index 3be2595..709bc5c 100644
index 3be2595..99b78c4 100644
--- a/src/exported_functions.json
+++ b/src/exported_functions.json
@@ -1,47 +1,50 @@
@@ -1,47 +1,48 @@
[
-"_malloc",
-"_free",
Expand Down Expand Up @@ -250,9 +224,7 @@ index 3be2595..709bc5c 100644
+ "_sqlite3_aggregate_context",
+ "_RegisterExtensionFunctions",
+ "_sqlite3_last_insert_rowid",
+ "_sqlite3_update_hook",
+ "_powersync_init_static",
+ "_register_update_hook_extension"
+ "_powersync_init_static"
]
diff --git a/src/exported_runtime_methods.json b/src/exported_runtime_methods.json
index f099056..b1712fc 100644
Expand Down
Loading