sqlite/ext/wasm
stephan d35a69a8da Fix a non-bare-bones-mode test case broken by the previous checkin.
FossilOrigin-Name: 3be729493b76a8b51c19d81543dea2dcb1fc718f81d4f2d9c6e1381789217687
2024-07-25 16:28:55 +00:00
..
api Strip progress handlers and window functions from the wasm bare-bones (formerly 'minimal') JS bits, noting that we can't yet use OMIT_WINDOWFUNC (for the C parts) without a custom amalgamation. Currently at 604kb. 2024-07-25 16:21:19 +00:00
common Doc updates in JS code. No functional changes. 2024-06-12 12:17:03 +00:00
fiddle Remove an extraneous CSS file and import its CSS into the one HTML file which uses it. 2024-06-18 20:47:05 +00:00
jaccwabyt Minor doc touchup in the JS bits. 2023-12-29 04:29:07 +00:00
sql
SQLTester Update ext/wasm/SQLTester for recent internal-API reorgs. 2024-01-24 19:54:49 +00:00
tests/opfs/concurrency Add several convenience links to the OPFS VFS concurrency tester app for launching it with various combinations of options. 2024-07-13 01:40:36 +00:00
batch-runner-sahpool.html Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups. 2023-11-30 20:34:24 +00:00
batch-runner-sahpool.js Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups. 2023-11-30 20:34:24 +00:00
batch-runner.html
batch-runner.js Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups. 2023-11-30 20:34:24 +00:00
c-pp.c
demo-123-worker.html
demo-123.html
demo-123.js Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups. 2023-11-30 20:34:24 +00:00
demo-jsstorage.html
demo-jsstorage.js
demo-worker1-promiser.c-pp.html Resolve duplicate loading of promiser v2 demo code (a side effect of having done precisely what it was told to do). Consolidate demo-worker1-promiser(-esm).html/(m)js variants into central copies processed with c-pp. 2024-03-07 18:53:27 +00:00
demo-worker1-promiser.c-pp.js Resolve duplicate loading of promiser v2 demo code (a side effect of having done precisely what it was told to do). Consolidate demo-worker1-promiser(-esm).html/(m)js variants into central copies processed with c-pp. 2024-03-07 18:53:27 +00:00
demo-worker1.html
demo-worker1.js
dist.make When running the 'dist' target in ext/wasm for an SEE-capable build, ensure that the resulting zip file and directory name include '-see'. 2024-04-23 05:38:49 +00:00
example_extra_init.c
EXPORTED_FUNCTIONS.fiddle.in
fiddle.make Strip progress handlers and window functions from the wasm bare-bones (formerly 'minimal') JS bits, noting that we can't yet use OMIT_WINDOWFUNC (for the C parts) without a custom amalgamation. Currently at 604kb. 2024-07-25 16:21:19 +00:00
GNUmakefile Strip progress handlers and window functions from the wasm bare-bones (formerly 'minimal') JS bits, noting that we can't yet use OMIT_WINDOWFUNC (for the C parts) without a custom amalgamation. Currently at 604kb. 2024-07-25 16:21:19 +00:00
index-dist.html wasm promiser.v2 is essentially working but the demo code is double-loading the module for as-yet-undetermined reasons. 2024-03-07 17:56:08 +00:00
index.html wasm promiser.v2 is essentially working but the demo code is double-loading the module for as-yet-undetermined reasons. 2024-03-07 17:56:08 +00:00
make-make.sh More work on the minimal-mode wasm build (now 603kb uncompressed). Remove the hard-coded feature-enable flags from sqlite3-wasm.c and rely on the build to provide them. Some wasm build cleanup, but attempts to completely overhaul it have been thwarted by my inability to make script-generated makefile code more legible/maintainable than the current eval spaghetti. 2024-07-25 14:00:26 +00:00
module-symbols.html Add a doc link for the new sqlite3_js_posix_create_file(). 2023-08-11 17:45:23 +00:00
README-dist.txt
README.md
scratchpad-wasmfs.html
scratchpad-wasmfs.mjs
speedtest1-wasmfs.html
speedtest1-wasmfs.mjs
speedtest1-worker.html Add a basic batch-mode SQL runner for the SAH Pool VFS, for use in comparing it against WebSQL. Bring the WebSQL batch runner up to date, noting that it cannot run without addition of an "origin trial" activation key from Google because that's now the only way to enable WebSQL in Chrome (that part is not checked in because that key is private). Minor code-adjacent cleanups. 2023-11-30 20:34:24 +00:00
speedtest1-worker.js Make explicit which JS APIs are for internal use only by moving the JS-bound internal-use-only functions out of client-visible reach and renaming the WASM-exported ones from sqlite3_wasm... to sqlite3__wasm... (with two underscores). These have always been documented as internal-use-only, so this is not a breaking change except for clients which have ignored the docs. 2024-01-08 07:52:47 +00:00
speedtest1.html
split-speedtest1-script.sh
test-opfs-vfs.html
test-opfs-vfs.js Fix an exception misuse in test-opfs-vfs.js. 2023-11-15 11:31:49 +00:00
tester1-worker.html
tester1.c-pp.html
tester1.c-pp.js Fix a non-bare-bones-mode test case broken by the previous checkin. 2024-07-25 16:28:55 +00:00
wasmfs.make Start work on an overhaul of the wasm build process, with an eye towards less over-engineering. 2024-07-25 10:50:45 +00:00

This directory houses the Web Assembly (WASM) parts of the sqlite3 build.

It requires emscripten and that the build environment be set up for emscripten. A mini-HOWTO for setting that up follows...

First, install the Emscripten SDK, as documented here and summarized below for Linux environments:

# Clone the emscripten repository:
$ sudo apt install git
$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk

# Download and install the latest SDK tools:
$ ./emsdk install latest

# Make the "latest" SDK "active" for the current user:
$ ./emsdk activate latest

Those parts only need to be run once, but the SDK can be updated using:

$ git pull
$ ./emsdk install latest
$ ./emsdk activate latest

The following needs to be run for each shell instance which needs the emcc compiler:

# Activate PATH and other environment variables in the current terminal:
$ source ./emsdk_env.sh

$ which emcc
/path/to/emsdk/upstream/emscripten/emcc

Optionally, add that to your login shell's resource file (~/.bashrc or equivalent).

That env script needs to be sourced for building this application from the top of the sqlite3 build tree:

$ make fiddle

Or:

$ cd ext/wasm
$ make

That will generate the a number of files required for a handful of test and demo applications which can be accessed via index.html. WASM content cannot, due to XMLHttpRequest security limitations, be loaded if the containing HTML file is opened directly in the browser (i.e. if it is opened using a file:// URL), so it needs to be served via an HTTP server. For example, using althttpd:

$ cd ext/wasm
$ althttpd --enable-sab --max-age 1 --page index.html

That will open the system's browser and run the index page, from which all of the test and demo applications can be accessed.

Note that when serving this app via althttpd, it must be a version from 2022-09-26 or newer so that it recognizes the --enable-sab flag, which causes althttpd to emit two HTTP response headers which are required to enable JavaScript's SharedArrayBuffer and Atomics APIs. Those APIs are required in order to enable the OPFS-related features in the apps which use them.

Testing on a remote machine that is accessed via SSH

NB: The following are developer notes, last validated on 2023-07-19

  • Remote: Install git, emsdk, and althttpd
  • Remote: Install the SQLite source tree. CD to ext/wasm
  • Remote: "make" to build WASM
  • Remote: althttpd --enable-sab --port 8080 --popup
  • Local: ssh -L 8180:localhost:8080 remote
  • Local: Point your web-browser at http://localhost:8180/index.html

In order to enable SharedArrayBuffer, the web-browser requires that the two extra Cross-Origin lines be present in HTTP reply headers and that the request must come from "localhost" (or over an SSL connection). Since the web-server is on a different machine from the web-broser, the localhost requirement means that the connection must be tunneled using SSH.