Skip to content

Commit a9a18d3

Browse files
committed
refactor(wasm): remove sqlite-sync-wasm support
1 parent f69a569 commit a9a18d3

File tree

8 files changed

+12
-295
lines changed

8 files changed

+12
-295
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
1414
container: ${{ matrix.container && matrix.container || '' }}
15-
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'wasm' && matrix.name != 'apple-xcframework' && ' + test' || ''}}
15+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && ' + test' || ''}}
1616
timeout-minutes: 20
1717
strategy:
1818
fail-fast: false
@@ -52,9 +52,6 @@ jobs:
5252
- os: macos-15
5353
name: ios-sim
5454
make: PLATFORM=ios-sim
55-
- os: ubuntu-22.04
56-
name: wasm
57-
make: PLATFORM=wasm
5855
- os: macos-15
5956
name: apple-xcframework
6057
make: xcframework
@@ -109,10 +106,6 @@ jobs:
109106
run: make curl/windows/libcurl.a
110107
shell: msys2 {0}
111108

112-
- name: wasm install wabt
113-
if: matrix.name == 'wasm'
114-
run: sudo apt install wabt
115-
116109
- name: build sqlite-sync
117110
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make extension ${{ matrix.make && matrix.make || ''}}
118111

@@ -201,7 +194,7 @@ jobs:
201194
if: always()
202195
with:
203196
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
204-
path: dist/${{ matrix.name == 'wasm' && 'sqlite-wasm.zip' || matrix.name == 'apple-xcframework' && 'CloudSync.*' || 'cloudsync.*'}}
197+
path: dist/${{ matrix.name == 'apple-xcframework' && 'CloudSync.*' || 'cloudsync.*'}}
205198
if-no-files-found: error
206199

207200
release:
@@ -253,73 +246,14 @@ jobs:
253246
for folder in "artifacts"/*; do
254247
if [ -d "$folder" ]; then
255248
name=$(basename "$folder")
256-
if [[ "$name" != "github-pages" && "$name" != "cloudsync-wasm" ]]; then
249+
if [[ "$name" != "github-pages" ]]; then
257250
if [[ "$name" != "cloudsync-apple-xcframework" ]]; then
258251
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
259252
fi
260253
(cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
261254
fi
262255
fi
263256
done
264-
cp artifacts/cloudsync-wasm/sqlite-wasm.zip "sqlite-$(make sqlite_version)-sync-${{ steps.tag.outputs.version }}-wasm.zip"
265-
266-
- name: wasm publish to npmjs
267-
if: steps.tag.outputs.version != ''
268-
run: |
269-
TAG=$(git ls-remote --tags https://github.com/sqlite/sqlite-wasm.git | \
270-
awk -v ver=$(make sqlite_version) -F'/' '$NF ~ ver"-build[0-9]+$" {print $NF}' | \
271-
sort -V | \
272-
tail -n1)
273-
git clone --branch "$TAG" --depth 1 https://github.com/sqlite/sqlite-wasm.git sqlite-wasm
274-
rm -rf sqlite-wasm/sqlite-wasm/*
275-
unzip artifacts/cloudsync-wasm/sqlite-wasm.zip -d sqlite-wasm/tmp
276-
mv sqlite-wasm/tmp/sqlite-wasm-*/jswasm sqlite-wasm/sqlite-wasm
277-
278-
cd sqlite-wasm && npm i && npm run fix && npm run publint && npm run check-types && cd ..
279-
280-
PKG=sqlite-wasm/package.json
281-
TMP=sqlite-wasm/package.tmp.json
282-
283-
DESC="SQLite Wasm compiled with the automatically initialized sqlite-sync extension. Conveniently packaged as an ES Module for effortless integration."
284-
285-
jq \
286-
--arg name "@sqliteai/sqlite-sync-wasm" \
287-
--arg version "$(make sqlite_version)-sync-$(make version)" \
288-
--arg desc "$DESC" \
289-
--argjson keywords '["sync","offsync","cloudsync","sqliteai"]' \
290-
--arg repo_url "git+https://github.com/sqliteai/sqlite-sync.git" \
291-
--arg author "Gioele Cantoni ([email protected])" \
292-
--arg bugs_url "https://github.com/sqliteai/sqlite-sync/issues" \
293-
--arg homepage "https://github.com/sqliteai/sqlite-sync#readme" \
294-
'
295-
.name = $name
296-
| .version = $version
297-
| .description = $desc
298-
| .keywords += $keywords
299-
| del(.bin)
300-
| .scripts |= with_entries(select(
301-
.key != "build"
302-
and .key != "start"
303-
and .key != "start:node"
304-
and .key != "prepublishOnly"
305-
and .key != "deploy"
306-
))
307-
| .repository.url = $repo_url
308-
| .author = $author
309-
| .bugs.url = $bugs_url
310-
| .homepage = $homepage
311-
| del(.devDependencies.decompress)
312-
| del(.devDependencies["http-server"])
313-
| del(.devDependencies.shx)
314-
' "$PKG" > "$TMP" && mv "$TMP" "$PKG"
315-
316-
sed 's/@sqlite\.org\/sqlite-wasm/@sqliteai\/sqlite-sync-wasm/g' sqlite-wasm/README.md > sqlite-wasm/README.tmp
317-
echo -e "# sqlite-sync WASM $(make version)\nThis README and the TypeScript types are from the [official SQLite wasm repository](https://github.com/sqlite/sqlite-wasm)\n\n$(cat sqlite-wasm/README.tmp)" > sqlite-wasm/README.md
318-
rm -rf sqlite-wasm/tmp sqlite-wasm/bin sqlite-wasm/demo sqlite-wasm/README.tmp sqlite-wasm/package-lock.json
319-
cd sqlite-wasm && npm publish --access public
320-
#add --provenance to npm publish when the repo will be public
321-
env:
322-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
323257
324258
- uses: softprops/[email protected]
325259
if: steps.tag.outputs.version != ''
@@ -331,5 +265,4 @@ jobs:
331265
cloudsync-*-${{ steps.tag.outputs.version }}.tar.gz
332266
CloudSync-*-${{ steps.tag.outputs.version }}.zip
333267
CloudSync-*-${{ steps.tag.outputs.version }}.tar.gz
334-
sqlite-*-sync-${{ steps.tag.outputs.version }}-wasm.zip
335268
make_latest: true

Makefile

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Makefile for SQLite Sync Extension
2-
# Supports compilation for Linux, macOS, Windows, Android, iOS and WASM
2+
# Supports compilation for Linux, macOS, Windows, Android and iOS
33

44
# customize sqlite3 executable with
55
# make test SQLITE3=/opt/homebrew/Cellar/sqlite/3.49.1/bin/sqlite3
@@ -8,9 +8,6 @@ SQLITE3 ?= sqlite3
88
# set curl version to download and build
99
CURL_VERSION ?= 8.12.1
1010

11-
# set sqlite version for WASM static build
12-
SQLITE_VERSION ?= 3.49.2
13-
1411
# Set default platform if not specified
1512
ifeq ($(OS),Windows_NT)
1613
PLATFORM := windows
@@ -50,14 +47,13 @@ CURL_DIR = curl
5047
CURL_SRC = $(CURL_DIR)/src/curl-$(CURL_VERSION)
5148
COV_DIR = coverage
5249
CUSTOM_CSS = $(TEST_DIR)/sqliteai.css
53-
BUILD_WASM = build/wasm
5450

5551
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
5652
TEST_SRC = $(wildcard $(TEST_DIR)/*.c)
5753
TEST_FILES = $(SRC_FILES) $(TEST_SRC) $(wildcard $(SQLITE_DIR)/*.c)
5854
RELEASE_OBJ = $(patsubst %.c, $(BUILD_RELEASE)/%.o, $(notdir $(SRC_FILES)))
5955
TEST_OBJ = $(patsubst %.c, $(BUILD_TEST)/%.o, $(notdir $(TEST_FILES)))
60-
COV_FILES = $(filter-out $(SRC_DIR)/lz4.c $(SRC_DIR)/network.c $(SRC_DIR)/wasm.c, $(SRC_FILES))
56+
COV_FILES = $(filter-out $(SRC_DIR)/lz4.c $(SRC_DIR)/network.c, $(SRC_FILES))
6157
CURL_LIB = $(CURL_DIR)/$(PLATFORM)/libcurl.a
6258
TEST_TARGET = $(patsubst %.c,$(DIST_DIR)/%$(EXE), $(notdir $(TEST_SRC)))
6359

@@ -116,8 +112,6 @@ else ifeq ($(PLATFORM),ios-sim)
116112
CFLAGS += -arch x86_64 -arch arm64 $(SDK)
117113
CURL_CONFIG = --host=arm64-apple-darwin --with-secure-transport CFLAGS="-arch x86_64 -arch arm64 -isysroot $$(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
118114
STRIP = strip -x -S $@
119-
else ifeq ($(PLATFORM),wasm)
120-
TARGET := $(DIST_DIR)/sqlite-wasm.zip
121115
else # linux
122116
TARGET := $(DIST_DIR)/cloudsync.so
123117
LDFLAGS += -shared -lssl -lcrypto
@@ -159,7 +153,6 @@ $(shell mkdir -p $(BUILD_DIRS) $(DIST_DIR))
159153
extension: $(TARGET)
160154
all: $(TARGET)
161155

162-
ifneq ($(PLATFORM),wasm)
163156
# Loadable library
164157
$(TARGET): $(RELEASE_OBJ) $(DEF_FILE) $(CURL_LIB)
165158
$(CC) $(RELEASE_OBJ) $(DEF_FILE) -o $@ $(LDFLAGS)
@@ -169,25 +162,6 @@ ifeq ($(PLATFORM),windows)
169162
endif
170163
# Strip debug symbols
171164
$(STRIP)
172-
else
173-
#WASM build
174-
EMSDK := $(BUILD_WASM)/emsdk
175-
$(EMSDK):
176-
git clone https://github.com/emscripten-core/emsdk.git $(EMSDK)
177-
cd $(EMSDK) && ./emsdk install latest && ./emsdk activate latest
178-
179-
SQLITE_SRC := $(BUILD_WASM)/sqlite
180-
$(SQLITE_SRC): $(EMSDK)
181-
git clone --branch version-$(SQLITE_VERSION) --depth 1 https://github.com/sqlite/sqlite.git $(SQLITE_SRC)
182-
cd $(EMSDK) && . ./emsdk_env.sh && cd ../sqlite && ./configure --enable-all
183-
184-
WASM_FLAGS = emcc.jsflags += -sFETCH
185-
WASM_MAKEFILE = $(SQLITE_SRC)/ext/wasm/GNUmakefile
186-
$(TARGET): $(SQLITE_SRC) $(SRC_FILES)
187-
@grep '$(WASM_FLAGS)' '$(WASM_MAKEFILE)' >/dev/null 2>&1 || echo '$(WASM_FLAGS)' >> '$(WASM_MAKEFILE)'
188-
cd $(SQLITE_SRC)/ext/wasm && $(MAKE) dist sqlite3_wasm_extra_init.c=../../../../../src/wasm.c
189-
mv $(SQLITE_SRC)/ext/wasm/sqlite-wasm-*.zip $(TARGET)
190-
endif
191165

192166
# Test executable
193167
$(TEST_TARGET): $(TEST_OBJ)
@@ -367,14 +341,12 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
367341
xcframework: $(DIST_DIR)/CloudSync.xcframework
368342

369343
# Tools
370-
sqlite_version:
371-
@echo $(SQLITE_VERSION)
372344
version:
373345
@echo $(shell sed -n 's/^#define CLOUDSYNC_VERSION[[:space:]]*"\([^"]*\)".*/\1/p' src/cloudsync.h)
374346

375347
# Clean up generated files
376348
clean:
377-
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src *.sqlite $(BUILD_WASM)
349+
rm -rf $(BUILD_DIRS) $(DIST_DIR)/* $(COV_DIR) *.gcda *.gcno *.gcov $(CURL_DIR)/src *.sqlite
378350

379351
# Help message
380352
help:
@@ -389,12 +361,11 @@ help:
389361
@echo " android (needs ARCH to be set to x86_64 or arm64-v8a and ANDROID_NDK to be set)"
390362
@echo " ios (only on macOS - can be compiled with native network support)"
391363
@echo " ios-sim (only on macOS - can be compiled with native network support)"
392-
@echo " wasm (needs wabt[brew install wabt/sudo apt install wabt])"
393364
@echo ""
394365
@echo "Targets:"
395366
@echo " all - Build the extension (default)"
396367
@echo " clean - Remove built files"
397368
@echo " test [COVERAGE=true] - Test the extension with optional coverage output"
398369
@echo " help - Display this help message"
399370

400-
.PHONY: all clean test extension help xcframework
371+
.PHONY: all clean test extension help version xcframework

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Download the appropriate pre-built binary for your platform from the official [R
118118

119119
### WASM Version
120120

121-
You can download the WebAssembly (WASM) version of SQLite with the SQLite Sync extension enabled from: https://www.npmjs.com/package/@sqliteai/sqlite-sync-wasm
121+
You can download the WebAssembly (WASM) version of SQLite with the SQLite Sync extension enabled from: https://www.npmjs.com/package/@sqliteai/sqlite-wasm
122122

123123
### Loading the Extension
124124

examples/sport-tracker-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ npm install
3939
npm run dev
4040
```
4141

42-
> This app uses the packed WASM version of SQLite with the [SQLite Sync extension enabled](https://www.npmjs.com/package/@sqliteai/sqlite-sync-wasm).
42+
> This app uses the packed WASM version of SQLite with the [SQLite Sync extension enabled](https://www.npmjs.com/package/@sqliteai/sqlite-wasm).
4343
4444
## Demo Use Case: Multi-User Sync Scenario
4545

examples/sport-tracker-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"vite": "^7.0.0"
1414
},
1515
"dependencies": {
16-
"@sqliteai/sqlite-sync-wasm": "^3.49.2-sync-0.8.20",
16+
"@sqliteai/sqlite-wasm": "*",
1717
"@types/react": "^19.1.8",
1818
"@types/react-dom": "^19.1.6",
1919
"@vitejs/plugin-react": "^4.6.0",

examples/sport-tracker-app/src/db/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sqlite3InitModule from "@sqliteai/sqlite-sync-wasm";
1+
import sqlite3InitModule from "@sqliteai/sqlite-wasm";
22
import schemaSQL from "../../sport-tracker-schema.sql?raw";
33
import { getDatabaseOperations as getDatabaseOperations } from "./databaseOperations";
44
import {

examples/sport-tracker-app/vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default defineConfig({
1414
},
1515
optimizeDeps: {
1616
exclude: [
17-
/* '@sqlite.org/sqlite-wasm', */
18-
"@sqliteai/sqlite-sync-wasm",
17+
"@sqliteai/sqlite-wasm",
1918
],
2019
},
2120
});

0 commit comments

Comments
 (0)