Skip to content

Commit ba66572

Browse files
committed
Merge branch 'master' into reconcile-rhashimoto-wa-sqlite
2 parents 3d95bee + a3b1324 commit ba66572

Some content is hidden

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

41 files changed

+2334
-677
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: " Do not post anything other than a bug report"
3+
about: Issues are only for possible bugs in project code.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: [ "master" ]
1111

1212
env:
13-
EM_VERSION: 3.1.47
13+
EM_VERSION: 3.1.61
1414
EM_CACHE_FOLDER: 'emsdk-cache'
1515

1616
jobs:
@@ -33,7 +33,7 @@ jobs:
3333
- uses: browser-actions/setup-chrome@v1
3434
id: setup-chrome
3535
with:
36-
chrome-version: 121
36+
chrome-version: 129
3737
- run: |
3838
${{ steps.setup-chrome.outputs.chrome-path }} --version
3939
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
path: ${{env.EM_CACHE_FOLDER}}
6262
key: ${{env.EM_VERSION}}-${{ runner.os }}
63-
- uses: mymindstorm/setup-emsdk@v12
63+
- uses: mymindstorm/setup-emsdk@v14
6464
with:
6565
version: ${{env.EM_VERSION}}
6666
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# dependencies
2-
SQLITE_VERSION = version-3.45.0
3-
SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=${SQLITE_VERSION}
2+
SQLITE_VERSION = version-3.50.1
3+
SQLITE_TARBALL_URL = https://www.sqlite.org/src/tarball/$(SQLITE_VERSION)/sqlite.tar.gz
44

55
EXTENSION_FUNCTIONS = extension-functions.c
66
EXTENSION_FUNCTIONS_URL = https://www.sqlite.org/contrib/download/extension-functions.c?get=25
@@ -18,13 +18,15 @@ CFILES = \
1818
main.c \
1919
libauthorizer.c \
2020
libfunction.c \
21+
libhook.c \
2122
libprogress.c \
2223
libvfs.c \
2324
$(CFILES_EXTRA)
2425

2526
JSFILES = \
2627
src/libauthorizer.js \
2728
src/libfunction.js \
29+
src/libhook.js \
2830
src/libprogress.js \
2931
src/libvfs.js
3032

@@ -38,7 +40,7 @@ vpath %.c $(dir.crsql)
3840
EXPORTED_FUNCTIONS = src/exported_functions.json
3941
EXPORTED_RUNTIME_METHODS = src/extra_exported_runtime_methods.json
4042
ASYNCIFY_IMPORTS = src/asyncify_imports.json
41-
ASYNCIFY_EXPORTS = src/asyncify_exports.json
43+
JSPI_EXPORTS = src/jspi_exports.json
4244

4345
# intermediate files
4446
RS_LIB = crsql_bundle
@@ -72,6 +74,7 @@ EMFLAGS_COMMON = \
7274
-s INVOKE_RUN \
7375
-s ENVIRONMENT="web,worker" \
7476
-s STACK_SIZE=512KB \
77+
-s WASM_BIGINT=0 \
7578
$(EMFLAGS_EXTRA)
7679

7780
EMFLAGS_DEBUG = \
@@ -92,6 +95,7 @@ EMFLAGS_LIBRARIES = \
9295
--js-library src/libadapters.js \
9396
--post-js src/libauthorizer.js \
9497
--post-js src/libfunction.js \
98+
--post-js src/libhook.js \
9599
--post-js src/libprogress.js \
96100
--post-js src/libvfs.js
97101

@@ -108,9 +112,9 @@ EMFLAGS_ASYNCIFY_DIST = \
108112
-s ASYNCIFY_STACK_SIZE=16384
109113

110114
EMFLAGS_JSPI = \
111-
-s ASYNCIFY=2 \
115+
-s JSPI \
112116
-s ASYNCIFY_IMPORTS=@src/asyncify_imports.json \
113-
-s ASYNCIFY_EXPORTS=@src/asyncify_exports.json
117+
-s JSPI_EXPORTS=@src/jspi_exports.json
114118

115119
# NOTE: The tests expect the default page size to be 8192 (not 4096 like the sqlite3 default)
116120
WASQLITE_EXTRA_DEFINES = \

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg?branch=breaking-changes)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml?branch=breaking-changes)
1+
[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml)
22

33
# wa-sqlite
44
This is a WebAssembly build of SQLite with support for writing SQLite virtual filesystems completely in Javascript. This allows alternative browser storage options such as IndexedDB and Origin Private File System. Applications can opt to use either a synchronous or asynchronous (using Asyncify or JSPI) SQLite library build (an asynchronous build is required for asynchronous extensions).
55

66
IndexedDB and several Origin Private File System virtual file systems are among the examples provided as proof of concept. A table comparing the different VFS classes is [here](https://github.com/rhashimoto/wa-sqlite/tree/master/src/examples#vfs-comparison).
77

8-
[Try the demo](https://rhashimoto.github.io/wa-sqlite/demo/?build=asyncify&config=IDBBatchAtomicVFS&reset) or run [benchmarks](https://rhashimoto.github.io/wa-sqlite/demo/benchmarks/?config=asyncify,IDBBatchAtomicVFS;default,AccessHandlePoolVFS;default,OPFSCoopSyncVFS;asyncify,OPFSAdaptiveVFS;asyncify,OPFSPermutedVFS) with a modern desktop web browser. More information is available in the [FAQ](https://github.com/rhashimoto/wa-sqlite/issues?q=is%3Aissue+label%3Afaq+), [discussion forums](https://github.com/rhashimoto/wa-sqlite/discussions), and [API reference](https://rhashimoto.github.io/wa-sqlite/docs/).
8+
[Try the demo](https://rhashimoto.github.io/wa-sqlite/demo/?build=asyncify&config=IDBBatchAtomicVFS&reset) or run [benchmarks](https://rhashimoto.github.io/wa-sqlite/demo/benchmarks/?config=asyncify,IDBBatchAtomicVFS;asyncify,IDBMirrorVFS;default,AccessHandlePoolVFS;default,OPFSCoopSyncVFS;asyncify,OPFSAdaptiveVFS;asyncify,OPFSPermutedVFS) with a modern desktop web browser. More information is available in the [FAQ](https://github.com/rhashimoto/wa-sqlite/issues?q=is%3Aissue+label%3Afaq+), [discussion forums](https://github.com/rhashimoto/wa-sqlite/discussions), and [API reference](https://rhashimoto.github.io/wa-sqlite/docs/).
99

1010
## Build
1111
The primary motivation for this project is to enable additions to SQLite with only Javascript. Most developers should be able to use the pre-built artifacts in
@@ -19,7 +19,7 @@ If you do want to build yourself, here are the prerequisites:
1919

2020
* Building on Debian Linux is known to work, compatibility with other platforms is unknown.
2121
* `yarn` - If you use a different package manager (e.g. `npm`) then file paths in the demo will need adjustment.
22-
* [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) 3.1.47+.
22+
* [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) 3.1.61+.
2323
* `curl`, `make`, `openssl`, `sed`, `tclsh`, `unzip`
2424

2525
Here are the build steps:
@@ -64,10 +64,10 @@ To serve the demo directly from the source tree:
6464

6565
The demo page provides access to databases on multiple VFS implementations. Query parameters on the demo page URL can be used to specify the configuration and initial state:
6666

67-
| *Parameter* | *Purpose* | *Values* | *Default* |
67+
| Parameter | Purpose | Values | Default |
6868
|----|----|----|----|
6969
| build | Emscripten build type | default, asyncify, jspi | default |
70-
| config | select VFS | MemoryVFS, MemoryAsyncVFS, IDBBatchAtomicVFS, AccessHandlePoolVFS, OPFSAdaptiveVFS, OPFSCoopSyncVFS, OPFSPermutedVFS | uses SQLite internal memory |
70+
| config | select VFS | MemoryVFS, MemoryAsyncVFS, IDBBatchAtomicVFS, IDBMirrorVFS, AccessHandlePoolVFS, OPFSAdaptiveVFS, OPFSAnyContextVFS, OPFSCoopSyncVFS, OPFSPermutedVFS | uses SQLite internal memory |
7171
| reset | clear persistent storage | | |
7272

7373
For convenience, if any text region is selected in the editor, only that region will be executed. In addition, the editor contents are restored across page reloads using browser localStorage.

demo/contention/contention-worker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const BUILDS = new Map([
3737
vfsModule: '../../src/examples/IDBBatchAtomicVFS.js',
3838
vfsOptions: { lockPolicy: 'shared+hint' }
3939
},
40+
{
41+
name: 'IDBMirrorVFS',
42+
vfsModule: '../../src/examples/IDBMirrorVFS.js',
43+
},
4044
{
4145
name: 'OPFSAdaptiveVFS',
4246
vfsModule: '../../src/examples/OPFSAdaptiveVFS.js',

demo/demo-worker.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const BUILDS = new Map([
1313
* @property {string} name
1414
* @property {string} vfsModule path of the VFS module
1515
* @property {string} [vfsClassName] name of the VFS class
16+
* @property {string} [vfsName] name of the VFS instance
1617
* @property {object} [vfsOptions] VFS constructor arguments
1718
*/
1819

@@ -34,6 +35,11 @@ const BUILDS = new Map([
3435
vfsModule: '../src/examples/IDBBatchAtomicVFS.js',
3536
vfsOptions: { lockPolicy: 'shared+hint' }
3637
},
38+
{
39+
name: 'IDBMirrorVFS',
40+
vfsModule: '../src/examples/IDBMirrorVFS.js',
41+
vfsName: 'demo-mirror'
42+
},
3743
{
3844
name: 'OPFSAdaptiveVFS',
3945
vfsModule: '../src/examples/OPFSAdaptiveVFS.js',
@@ -70,7 +76,7 @@ maybeReset().then(async () => {
7076
const config = VFS_CONFIGS.get(configName);
7177

7278
const dbName = searchParams.get('dbName') ?? 'hello';
73-
const vfsName = searchParams.get('vfsName') ?? 'demo';
79+
const vfsName = searchParams.get('vfsName') ?? config.vfsName ?? 'demo';
7480

7581
// Instantiate SQLite.
7682
const { default: moduleFactory } = await import(BUILDS.get(buildName));

demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ window.addEventListener('DOMContentLoaded', async function() {
7777
let time = performance.now();
7878
worker.postMessage(queries);
7979
worker.addEventListener('message', async function(event) {
80+
timestamp.textContent += ` ${(performance.now() - time).toFixed(1)} milliseconds`;
8081
if (event.data.results) {
8182
// Format the results as tables.
8283
event.data.results
@@ -85,7 +86,6 @@ window.addEventListener('DOMContentLoaded', async function() {
8586
} else {
8687
output.innerHTML = `<pre>${event.data.error.message}</pre>`;
8788
}
88-
timestamp.textContent += ` ${Math.trunc(performance.now() - time) / 1000} seconds`;
8989
button.disabled = false;
9090
}, { once: true });
9191
});

demo/file/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as VFS from "../../src/VFS.js";
2-
import { IDBBatchAtomicVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
2+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
3+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
34

45
const SEARCH_PARAMS = new URLSearchParams(location.search);
56
const IDB_NAME = SEARCH_PARAMS.get('idb') ?? 'sqlite-vfs';
@@ -43,7 +44,7 @@ document.getElementById('file-fetch').addEventListener('click', async () => {
4344
let vfs;
4445
try {
4546
log(`Importing to IndexedDB ${IDB_NAME}, path ${DB_NAME}`);
46-
vfs = await IDBBatchAtomicVFS.create(IDB_NAME, null);
47+
vfs = await MyVFS.create(IDB_NAME, null);
4748

4849
// @ts-ignore
4950
const importURL = document.getElementById('file-url').value;
@@ -69,7 +70,7 @@ document.getElementById('file-import').addEventListener('change', async event =>
6970
let vfs;
7071
try {
7172
log(`Importing to IndexedDB ${IDB_NAME}, path ${DB_NAME}`);
72-
vfs = await IDBBatchAtomicVFS.create(IDB_NAME, null);
73+
vfs = await MyVFS.create(IDB_NAME, null);
7374
// @ts-ignore
7475
await importDatabase(vfs, DB_NAME, event.target.files[0].stream());
7576
log('Import complete');
@@ -87,7 +88,7 @@ document.getElementById('file-import').addEventListener('change', async event =>
8788
});
8889

8990
/**
90-
* @param {IDBBatchAtomicVFS} vfs
91+
* @param {MyVFS} vfs
9192
* @param {string} path
9293
* @param {ReadableStream} stream
9394
*/

demo/file/service-worker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as VFS from "../../src/VFS.js";
2-
import { IDBBatchAtomicVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
2+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
3+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
34

45
// Install the service worker as soon as possible.
56
globalThis.addEventListener('install', (/** @type {ExtendableEvent} */ event) => {
@@ -26,7 +27,7 @@ globalThis.addEventListener('fetch', async (/** @type {FetchEvent} */ event) =>
2627

2728
return event.respondWith((async () => {
2829
// Create the VFS and streaming source using the request parameters.
29-
const vfs = await IDBBatchAtomicVFS.create(url.searchParams.get('idb'), null);
30+
const vfs = await MyVFS.create(url.searchParams.get('idb'), null);
3031
const path = url.searchParams.get('db');
3132
const source = new DatabaseSource(vfs, path);
3233

demo/file/verifier.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SQLiteESMFactory from '../../dist/wa-sqlite-async.mjs';
22
import * as SQLite from '../../src/sqlite-api.js';
3-
import { IDBBatchAtomicVFS } from '../../src/examples/IDBBatchAtomicVFS.js';
3+
import { IDBBatchAtomicVFS as MyVFS } from "../../src/examples/IDBBatchAtomicVFS.js";
4+
// import { IDBMirrorVFS as MyVFS } from "../../src/examples/IDBMirrorVFS.js";
45

56
const SEARCH_PARAMS = new URLSearchParams(location.search);
67
const IDB_NAME = SEARCH_PARAMS.get('idb') ?? 'sqlite-vfs';
@@ -10,7 +11,7 @@ const DB_NAME = SEARCH_PARAMS.get('db') ?? 'sqlite.db';
1011
const module = await SQLiteESMFactory();
1112
const sqlite3 = SQLite.Factory(module);
1213

13-
const vfs = await IDBBatchAtomicVFS.create(IDB_NAME, module);
14+
const vfs = await MyVFS.create(IDB_NAME, module);
1415
// @ts-ignore
1516
sqlite3.vfs_register(vfs, true);
1617

0 commit comments

Comments
 (0)