aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/wasm/GNUmakefile109
-rw-r--r--ext/wasm/README-dist.txt34
-rw-r--r--ext/wasm/api/extern-post-js.c-pp.js13
-rw-r--r--ext/wasm/api/pre-js.c-pp.js13
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js5
-rw-r--r--ext/wasm/api/sqlite3-vfs-opfs.c-pp.js4
-rw-r--r--ext/wasm/api/sqlite3-worker1-promiser.js4
-rw-r--r--ext/wasm/api/sqlite3-worker1.js4
-rw-r--r--ext/wasm/c-pp.c39
-rw-r--r--ext/wasm/dist.make2
-rw-r--r--ext/wasm/tester1-worker.html8
-rw-r--r--ext/wasm/tester1.c-pp.html8
-rw-r--r--ext/wasm/tester1.c-pp.js8
-rw-r--r--manifest39
-rw-r--r--manifest.uuid2
15 files changed, 204 insertions, 88 deletions
diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile
index eef6902d6..78e34eb19 100644
--- a/ext/wasm/GNUmakefile
+++ b/ext/wasm/GNUmakefile
@@ -37,6 +37,15 @@
# - wasm-strip for release builds: https://github.com/WebAssembly/wabt
# - InfoZip for 'dist' zip file
########################################################################
+#
+# Significant TODOs for this build include, but are not necessarily
+# limited to:
+#
+# 1) Consolidate the code generation for sqlite3*.*js into a script
+# which generates the makefile code, rather than using $(call) and
+# $(eval), or at least centralize the setup of the numerous vars
+# related to each build variant (vanilla, esm, bundler-friendly).
+#
SHELL := $(shell which bash 2>/dev/null)
MAKEFILE := $(lastword $(MAKEFILE_LIST))
CLEAN_FILES :=
@@ -57,6 +66,13 @@ ifeq (,$(emcc.version))
else
$(info using emcc version [$(emcc.version)])
endif
+emcc.version := $(shell "$(emcc.bin)" --version | sed -n 1p \
+ | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;')
+ifeq (,$(emcc.version))
+ $(warning Cannot determine emcc version. This might unduly impact build flags.)
+else
+ $(info using emcc version [$(emcc.version)])
+endif
wasm-strip ?= $(shell which wasm-strip 2>/dev/null)
ifeq (,$(filter clean,$(MAKECMDGOALS)))
@@ -233,8 +249,17 @@ $(2): $(1) $$(MAKEFILE) $$(bin.c-pp)
$$(bin.c-pp) -f $(1) -o $$@ $(3)
CLEAN_FILES += $(2)
endef
-c-pp.D.vanilla ?=
-c-pp.D.esm ?= -Dtarget=es6-module
+c-pp.D.vanilla :=
+c-pp.D.esm := -Dtarget=es6-module
+c-pp.D.bundler-friendly := $(c-pp.D.esm) -Dtarget=es6-bundler-friendly
+# The various -D... values used by the sources include:
+#
+# -Dtarget=es6-module: intended for plain ESM module build.
+#
+# -Dtarget=es6-module -Dtarget=es6-bundler-friendly: intended for
+# "bundler-friendly" ESM module build. These have some restrictions
+# on how URL() objects are constructed in some contexts.
+#
# /end C-PP.FILTER
########################################################################
@@ -362,9 +387,11 @@ $(sqlite3-api.js.in): $(sqlite3-api.jses) $(MAKEFILE)
# for real-life clients.
sqlite3-api.js := $(dir.dout)/sqlite3-api.js
sqlite3-api.mjs := $(dir.dout)/sqlite3-api.mjs
+sqlite3-api-bundler-friendly.mjs := $(dir.dout)/sqlite3-api-bundler-friendly.mjs
$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api.js)))
$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api.mjs), $(c-pp.D.esm)))
-all: $(sqlite3-api.js) $(sqlite3-api.mjs)
+$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api-bundler-friendly.mjs), $(c-pp.D.bundler-friendly)))
+all: $(sqlite3-api.js) $(sqlite3-api.mjs) $(sqlite3-api-bundler-friendly.mjs)
$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
@echo "Making $@..."
@@ -381,7 +408,7 @@ $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js)
cat $(sqlite3-license-version-header.js); \
echo '/*'; \
echo '** This code was built from sqlite3 version...'; \
- echo "** "; \
+ echo "**"; \
awk -e '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' \
-e '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
echo '*/'; \
@@ -392,13 +419,16 @@ $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js)
# the generated emscripten module file. The following rules generate
# various versions of those files for the vanilla and ESM builds.
pre-js.js.in := $(dir.api)/pre-js.c-pp.js
-pre-js.js.esm := $(dir.tmp)/pre-js.esm.js
pre-js.js.vanilla := $(dir.tmp)/pre-js.vanilla.js
+pre-js.js.esm := $(dir.tmp)/pre-js.esm.js
+pre-js.js.bundler-friendly := $(dir.tmp)/pre-js.bundler-friendly.js
$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.vanilla),$(c-pp.D.vanilla)))
$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.esm),$(c-pp.D.esm)))
+$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
post-js.js.in := $(dir.tmp)/post-js.c-pp.js
post-js.js.vanilla := $(dir.tmp)/post-js.vanilla.js
post-js.js.esm := $(dir.tmp)/post-js.esm.js
+post-js.js.bundler-friendly := $(dir.tmp)/post-js.bundler-friendly.js
post-jses.js := \
$(dir.api)/post-js-header.js \
$(sqlite3-api.js.in) \
@@ -412,6 +442,7 @@ $(post-js.js.in): $(post-jses.js) $(MAKEFILE)
done > $@
$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.vanilla),$(c-pp.D.vanilla)))
$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.esm),$(c-pp.D.esm)))
+$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
# extern-post-js* and extern-pre-js* are files for use with
# Emscripten's --extern-pre-js and --extern-post-js flags. These
@@ -419,8 +450,10 @@ $(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.esm),$(c-pp.D.esm)))
extern-post-js.js.in := $(dir.api)/extern-post-js.c-pp.js
extern-post-js.js.vanilla := $(dir.tmp)/extern-post-js.vanilla.js
extern-post-js.js.esm := $(dir.tmp)/extern-post-js.esm.js
+extern-post-js.js.bundler-friendly := $(dir.tmp)/extern-post-js.bundler-friendly.js
$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.vanilla),$(c-pp.D.vanilla)))
$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.esm),$(c-pp.D.esm)))
+$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
extern-pre-js.js := $(dir.api)/extern-pre-js.js
# Emscripten flags for --[extern-][pre|post]-js=... for the
@@ -435,6 +468,10 @@ pre-post-common.flags.esm := \
$(pre-post-common.flags) \
--post-js=$(post-js.js.esm) \
--extern-post-js=$(extern-post-js.js.esm)
+pre-post-common.flags.bundler-friendly := \
+ $(pre-post-common.flags) \
+ --post-js=$(post-js.js.bundler-friendly) \
+ --extern-post-js=$(extern-post-js.js.bundler-friendly)
# pre-post-jses.deps.* = a list of dependencies for the
# --[extern-][pre/post]-js files.
@@ -443,14 +480,16 @@ pre-post-jses.deps.vanilla := $(pre-post-jses.deps.common) \
$(post-js.js.vanilla) $(extern-post-js.js.vanilla)
pre-post-jses.deps.esm := $(pre-post-jses.deps.common) \
$(post-js.js.esm) $(extern-post-js.js.esm)
+pre-post-jses.deps.bundler-friendly := $(pre-post-jses.deps.common) \
+ $(post-js.js.bundler-friendly) $(extern-post-js.js.bundler-friendly)
########################################################################
# call-make-pre-js is a $(call)able which creates rules for
# pre-js-$(1).js. $1 = the base name of the JS file on whose behalf
-# this pre-js is for. $2 is the build mode: one of (vanilla, esm).
-# This sets up --[extern-][pre/post]-js flags in
-# $(pre-post-$(1).flags.$(2)) and dependencies in
-# $(pre-post-$(1).deps.$(2)).
+# this pre-js is for (one of: sqlite3, sqlite3-wasm). $2 is the build
+# mode: one of (vanilla, esm, bundler-friendly). This sets up
+# --[extern-][pre/post]-js flags in $(pre-post-$(1).flags.$(2)) and
+# dependencies in $(pre-post-$(1).deps.$(2)).
define call-make-pre-js
pre-post-$(1).flags.$(2) ?=
$$(dir.tmp)/pre-js-$(1)-$(2).js: $$(pre-js.js.$(2)) $$(MAKEFILE)
@@ -607,6 +646,7 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED
sqlite3.js := $(dir.dout)/sqlite3.js
sqlite3.mjs := $(dir.dout)/sqlite3.mjs
+sqlite3-bundler-friendly.mjs := $(dir.dout)/sqlite3-bundler-friendly.mjs
# Undocumented Emscripten feature: if the target file extension is
# "mjs", it defaults to ES6 module builds:
# https://github.com/emscripten-core/emscripten/issues/14383
@@ -619,13 +659,16 @@ sqlite3-wasm.c := $(dir.api)/sqlite3-wasm.c
# instead of building a shared copy of sqlite3-wasm.o.
$(eval $(call call-make-pre-js,sqlite3,vanilla))
$(eval $(call call-make-pre-js,sqlite3,esm))
-$(sqlite3.js) $(sqlite3.mjs): $(MAKEFILE) $(sqlite3-wasm.c) \
- $(EXPORTED_FUNCTIONS.api)
+$(eval $(call call-make-pre-js,sqlite3,bundler-friendly))
+$(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs): \
+ $(MAKEFILE) $(sqlite3-wasm.c) $(EXPORTED_FUNCTIONS.api)
$(sqlite3.js): $(pre-post-sqlite3.deps.vanilla)
$(sqlite3.mjs): $(pre-post-sqlite3.deps.esm)
+$(sqlite3-bundler-friendly.mjs): $(pre-post-sqlite3.deps.bundler-friendly)
########################################################################
# SQLITE3.xJS.RECIPE = the $(call)able recipe body for $(sqlite3.js)
-# and $(sqlite3.mjs). $1 = one of (vanilla, esm).
+# and $(sqlite3.mjs). $1 = one of (vanilla, esm). $2 must be 1 for
+# ES6-style builds, 0 for other builds.
#
# Reminder for ESM builds: even if we use -sEXPORT_ES6=0, emcc _still_
# adds:
@@ -634,17 +677,18 @@ $(sqlite3.mjs): $(pre-post-sqlite3.deps.esm)
#
# when building *.mjs, which is bad because we need to export an
# overwritten version of that function and cannot "export default"
-# twice. Because of this, we have to sed $(sqlite3.mjs) to remove the
-# _first_ instance (only) of /^export default/.
+# twice. Because of this, we have to sed *.mjs to remove the _first_
+# instance (only) of /^export default/.
#
# Upstream RFE:
# https://github.com/emscripten-core/emscripten/issues/18237
########################################################################
# SQLITE3.xJS.EXPORT-DEFAULT is part of SQLITE3[-WASMFS].xJS.RECIPE,
-# factored into a separate piece to avoid code duplication. $1 is
-# the build mode: one of (vanilla, esm).
+# factored into a separate piece to avoid code duplication. $1 is 1 if
+# the build mode needs this workaround (esm, bundler-friendly) and 0
+# if not (vanilla).
define SQLITE3.xJS.ESM-EXPORT-DEFAULT
-if [ esm = $(1) ]; then \
+if [ x1 = x$(1) ]; then \
echo "Fragile workaround for an Emscripten annoyance. See SQLITE3.xJS.RECIPE."; \
sed -i -e '0,/^export default/{/^export default/d;}' $@ || exit $$?; \
if ! grep -q '^export default' $@; then \
@@ -659,30 +703,43 @@ define SQLITE3.xJS.RECIPE
$(emcc.jsflags) \
$(pre-post-sqlite3.flags.$(1)) $(emcc.flags.sqlite3.$(1)) \
$(cflags.common) $(SQLITE_OPT) $(sqlite3-wasm.c)
- @$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,$(1))
+ @$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,$(2))
+ @if [ bundler-friendly = $(1) ]; then \
+ echo "Patching sqlite3-bundler-friendly.js for sqlite3.wasm..."; \
+ rm -f $(dir.dout)/sqlite3-bundler-friendly.wasm; \
+ sed -i -e 's/sqlite3-bundler-friendly.wasm/sqlite3.wasm/g' $@ || exit $$?; \
+ fi
chmod -x $(sqlite3.wasm)
$(maybe-wasm-strip) $(sqlite3.wasm)
@ls -la $@ $(sqlite3.wasm)
endef
emcc.flags.sqlite3.vanilla :=
emcc.flags.sqlite3.esm := -sEXPORT_ES6 -sUSE_ES6_IMPORT_META
+emcc.flags.sqlite3.bundler-friendly := $(emcc.flags.sqlite3.esm)
$(sqlite3.js):
- $(call SQLITE3.xJS.RECIPE,vanilla)
+ $(call SQLITE3.xJS.RECIPE,vanilla,0)
$(sqlite3.mjs):
- $(call SQLITE3.xJS.RECIPE,esm)
+ $(call SQLITE3.xJS.RECIPE,esm,1)
+$(sqlite3-bundler-friendly.mjs):
+ $(call SQLITE3.xJS.RECIPE,bundler-friendly,1)
########################################################################
# We have to ensure that we do not build both $(sqlite3.js) and
# $(sqlite3.mjs) in parallel because both result in the creation of
# $(sqlite3.wasm). We have no(?) way to build just the .mjs file
# without also building the .wasm file. i.e. we're building
-# $(sqlite3.wasm) twice, but that's apparently unavoidable (and
-# harmless, just a waste of build time).
+# $(sqlite3.wasm) multiple times, but that's apparently unavoidable
+# (and harmless, just a waste of build time).
$(sqlite3.wasm): $(sqlite3.js)
$(sqlite3.mjs): $(sqlite3.js)
-CLEAN_FILES += $(sqlite3.js) $(sqlite3.mjs) $(sqlite3.wasm)
-all: $(sqlite3.js) $(sqlite3.mjs)
+$(sqlite3-bundler-friendly.mjs): $(sqlite3.mjs)
+# maintenance reminder: the deps on ^^^ must all be such that they are
+# never built in parallel.
+CLEAN_FILES += $(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs) \
+ $(sqlite3.wasm)
+all: $(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs)
quick: $(sqlite3.js)
quick: $(sqlite3.mjs) # for the sake of the snapshot build
+quick: $(sqlite3-bundler-friendly.mjs) # for the sake of the snapshot build
# End main $(sqlite3.js) build
########################################################################
@@ -792,7 +849,7 @@ CLEAN_FILES += $(speedtest1.js) $(speedtest1.wasm)
# 4) Load sqlite3 as an ESM worker. (Not all browsers support this.)
#
# To that end, we require two separate builds of tester1.js:
-#
+#
# tester1.js: cases 1 and 2
# tester1.mjs: cases 3 and 4
#
@@ -802,6 +859,8 @@ $(eval $(call C-PP.FILTER,tester1.c-pp.js,tester1.mjs,$(c-pp.D.esm)))
$(eval $(call C-PP.FILTER,tester1.c-pp.html,tester1.html))
$(eval $(call C-PP.FILTER,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.esm)))
tester1: tester1.js tester1.mjs tester1.html tester1-esm.html
+# Note that we do not include $(sqlite3-bundler-friendly.mjs) in this
+# because bundlers are client-specific.
all quick: tester1
########################################################################
diff --git a/ext/wasm/README-dist.txt b/ext/wasm/README-dist.txt
index 909a5ebbe..db0862628 100644
--- a/ext/wasm/README-dist.txt
+++ b/ext/wasm/README-dist.txt
@@ -4,19 +4,39 @@ Main project page: https://sqlite.org
Documentation: https://sqlite.org/wasm
-This archive contains the sqlite3.js, sqlite3.mjs, and sqlite3.wasm
-files which make up the sqlite3 WASM/JS build.
+This archive contains the following deliverables for the WASM/JS
+build:
-The jswasm directory contains the core sqlite3 deliverables and the
-top-level directory contains demonstration and test applications.
+- jswasm/sqlite3.js is the canonical "vanilla JS" version.
-Browsers will not serve WASM files from file:// URLs, so the demo/test
-apps require a web server and that server must include the following
-headers in its response when serving the files:
+- jswasm/sqlite3.mjs is the same but in ES6 module form
+
+- jswasm/sqlite3-bundler-friendly.mjs is the same as the ES6 module
+ with small tweaks to make it compatible with "bundler" tools
+ commonly seen in node.js-based projects.
+
+- jswasm/sqlite3.wasm is the binary WASM file imported by all of the
+ above-listed JS files.
+
+- The jswasm directory additionally contains a number of supplemental
+ JS files which cannot be bundled directly with the main JS files
+ but are necessary for certain usages.
+
+- The top-level directory contains various demonstration and test
+ applications for sqlite3.js and sqlite3.mjs.
+ sqlite3-bundler-friendly.mjs requires client-side build tools to make
+ use of and is not demonstrated here.
+
+Browsers will not serve WASM files from file:// URLs, so the test and
+demonstration apps require a web server and that server must include
+the following headers in its response when serving the files:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
+The core library will function without those headers but certain
+features, most notably OPFS storage, will not be available.
+
One simple way to get the demo apps up and running on Unix-style
systems is to install althttpd (https://sqlite.org/althttpd) and run:
diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js
index 225869794..a577a63e1 100644
--- a/ext/wasm/api/extern-post-js.c-pp.js
+++ b/ext/wasm/api/extern-post-js.c-pp.js
@@ -9,7 +9,7 @@
Emscripten-generated module init scope, in the current
global scope. */
//#if target=es6-module
-const toExportForES6 =
+const toExportForESM =
//#endif
(function(){
/**
@@ -45,10 +45,10 @@ const toExportForES6 =
moduleScript: self?.document?.currentScript,
isWorker: ('undefined' !== typeof WorkerGlobalScope),
location: self.location,
- urlParams: new URL(self.location.href).searchParams
+ urlParams: new URL(self.location.href).searchParams
});
initModuleState.debugModule =
- (new URL(self.location.href).searchParams).has('sqlite3.debugModule')
+ initModuleState.urlParams.has('sqlite3.debugModule')
? (...args)=>console.warn('sqlite3.debugModule:',...args)
: ()=>{};
@@ -105,6 +105,10 @@ const toExportForES6 =
document?.currentScript?.src);
}
}
+//#ifnot target=es6-module
+// Emscripten does not inject these module-loader bits in ES6 module
+// builds and including them here breaks JS bundlers, so elide them
+// from ESM builds.
/* Replace the various module exports performed by the Emscripten
glue... */
if (typeof exports === 'object' && typeof module === 'object'){
@@ -114,8 +118,9 @@ const toExportForES6 =
}
/* AMD modules get injected in a way we cannot override,
so we can't handle those here. */
+//#endif // !target=es6-module
return self.sqlite3InitModule /* required for ESM */;
})();
//#if target=es6-module
-export default toExportForES6;
+export default toExportForESM;
//#endif
diff --git a/ext/wasm/api/pre-js.c-pp.js b/ext/wasm/api/pre-js.c-pp.js
index 5d8e58864..a25c7ce77 100644
--- a/ext/wasm/api/pre-js.c-pp.js
+++ b/ext/wasm/api/pre-js.c-pp.js
@@ -6,12 +6,14 @@
*/
// See notes in extern-post-js.js
-const sqlite3InitModuleState = self.sqlite3InitModuleState || Object.assign(Object.create(null),{
- debugModule: ()=>{}
-});
+const sqlite3InitModuleState = self.sqlite3InitModuleState
+ || Object.assign(Object.create(null),{
+ debugModule: ()=>{}
+ });
delete self.sqlite3InitModuleState;
sqlite3InitModuleState.debugModule('self.location =',self.location);
+//#ifnot target=es6-bundler-friendly
/**
This custom locateFile() tries to figure out where to load `path`
from. The intent is to provide a way for foo/bar/X.js loaded from a
@@ -53,8 +55,9 @@ Module['locateFile'] = function(path, prefix) {
"result =", theFile
);
return theFile;
-//#endif /* SQLITE_JS_EMS */
+//#endif target=es6-module
}.bind(sqlite3InitModuleState);
+//#endif ifnot target=es6-bundler-friendly
/**
Bug warning: a custom Module.instantiateWasm() does not work
@@ -64,7 +67,7 @@ Module['locateFile'] = function(path, prefix) {
In such builds we must disable this.
*/
-const xNameOfInstantiateWasm = true
+const xNameOfInstantiateWasm = false
? 'instantiateWasm'
: 'emscripten-bug-17951';
Module[xNameOfInstantiateWasm] = function callee(imports,onSuccess){
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index ba210e7f9..fddd7b38e 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -183,7 +183,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
checkSqlite3Rc(
pDb, capi.sqlite3_exec(pDb, postInitSql, 0, 0, 0)
);
- }
+ }
}catch(e){
this.close();
throw e;
@@ -791,6 +791,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
- `callback` and `resultRows`: permit an array entries with
semantics similar to those described for `bind` above.
+ - If passed neither a callback nor returnValue but is passed a
+ rowMode, default to returning the result set.
+
*/
exec: function(/*(sql [,obj]) || (obj)*/){
affirmDbOpen(this);
diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js
index 2ded905ad..451f0019c 100644
--- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js
+++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js
@@ -198,7 +198,9 @@ const installOpfsVfs = function callee(options){
return promiseReject_(err);
};
const W =
-//#if target=es6-module
+//#if target=es6-bundler-friendly
+ new Worker(new URL("sqlite3-opfs-async-proxy.js", import.meta.url));
+//#elif target=es6-module
new Worker(new URL(options.proxyUri, import.meta.url));
//#else
new Worker(options.proxyUri);
diff --git a/ext/wasm/api/sqlite3-worker1-promiser.js b/ext/wasm/api/sqlite3-worker1-promiser.js
index 7360512d4..1689d3480 100644
--- a/ext/wasm/api/sqlite3-worker1-promiser.js
+++ b/ext/wasm/api/sqlite3-worker1-promiser.js
@@ -238,6 +238,9 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){
}/*sqlite3Worker1Promiser()*/;
self.sqlite3Worker1Promiser.defaultConfig = {
worker: function(){
+//#if target=es6-bundler-friendly
+ return new Worker("sqlite3-worker1.js");
+//#else
let theJs = "sqlite3-worker1.js";
if(this.currentScript){
const src = this.currentScript.src.split('/');
@@ -252,6 +255,7 @@ self.sqlite3Worker1Promiser.defaultConfig = {
}
}
return new Worker(theJs + self.location.search);
+//#endif
}.bind({
currentScript: self?.document?.currentScript
}),
diff --git a/ext/wasm/api/sqlite3-worker1.js b/ext/wasm/api/sqlite3-worker1.js
index 4ff19b888..9e9c3ac42 100644
--- a/ext/wasm/api/sqlite3-worker1.js
+++ b/ext/wasm/api/sqlite3-worker1.js
@@ -33,6 +33,9 @@
*/
"use strict";
(()=>{
+//#if target=es6-bundler-friendly
+ importScripts('sqlite3.js');
+//#else
const urlParams = new URL(self.location.href).searchParams;
let theJs = 'sqlite3.js';
if(urlParams.has('sqlite3.dir')){
@@ -40,6 +43,7 @@
}
//console.warn("worker1 theJs =",theJs);
importScripts(theJs);
+//#endif
sqlite3InitModule().then((sqlite3)=>{
sqlite3.initWorker1API();
});
diff --git a/ext/wasm/c-pp.c b/ext/wasm/c-pp.c
index 881c009ac..c439a0d09 100644
--- a/ext/wasm/c-pp.c
+++ b/ext/wasm/c-pp.c
@@ -51,10 +51,10 @@
**
** Design note: this code makes use of sqlite3. Though not _strictly_
** needed in order to implement it, this tool was specifically created
-** for potential use with the sqlite3 project's own JavaScript code,
-** so there's no reason not to make use of it to do some of the heavy
-** lifting. It does not require any cutting-edge sqlite3 features and
-** should be usable with any version which supports `WITHOUT ROWID`.
+** for use with the sqlite3 project's own JavaScript code, so there's
+** no reason not to make use of it to do some of the heavy lifting. It
+** does not require any cutting-edge sqlite3 features and should be
+** usable with any version which supports `WITHOUT ROWID`.
**
** Author(s):
**
@@ -603,18 +603,9 @@ void g_stderr(char const *zFmt, ...){
va_end(va);
}
-#if 0
-void cmpp_t_outf(CmppTokenizer * t, char const *zFmt, ...){
- if(!CT_skip(t)){
- va_list va;
- va_start(va, zFmt);
- vfprintf(g.out.pFile, zFmt, va);
- va_end(va);
- }
-}
-#endif
-
void cmpp_t_out(CmppTokenizer * t, void const *z, unsigned int n){
+ g_debug(3,("CT_skipLevel() ?= %d\n",CT_skipLevel(t)));
+ g_debug(3,("CT_skip() ?= %d\n",CT_skip(t)));
if(!CT_skip(t)){
if(1!=fwrite(z, n, 1, g.out.pFile)){
int const err = errno;
@@ -631,18 +622,28 @@ void CmppLevel_push(CmppTokenizer * const t){
g.zDelim, CmppLevel_Max);
}
pPrev = &CT_level(t);
+ g_debug(3,("push from tokenizer level=%u flags=%04x\n", t->level.ndx, pPrev->flags));
p = &t->level.stack[++t->level.ndx];
*p = CmppLevel_empty;
p->token = t->token;
p->flags = (CmppLevel_F_INHERIT_MASK & pPrev->flags);
if(CLvl_skip(pPrev)) p->flags |= CmppLevel_F_ELIDE;
+ g_debug(3,("push to tokenizer level=%u flags=%04x\n", t->level.ndx, p->flags));
}
void CmppLevel_pop(CmppTokenizer * const t){
if(!t->level.ndx){
fatal("Internal error: CmppLevel_pop() at the top of the stack");
}
+ g_debug(3,("pop from tokenizer level=%u, flags=%04x skipLevel?=%d\n", t->level.ndx,
+ t->level.stack[t->level.ndx].flags, CT_skipLevel(t)));
+ g_debug(3,("CT_skipLevel() ?= %d\n",CT_skipLevel(t)));
+ g_debug(3,("CT_skip() ?= %d\n",CT_skip(t)));
t->level.stack[t->level.ndx--] = CmppLevel_empty;
+ g_debug(3,("pop to tokenizer level=%u, flags=%04x\n", t->level.ndx,
+ t->level.stack[t->level.ndx].flags));
+ g_debug(3,("CT_skipLevel() ?= %d\n",CT_skipLevel(t)));
+ g_debug(3,("CT_skip() ?= %d\n",CT_skip(t)));
}
CmppLevel * CmppLevel_get(CmppTokenizer * const t){
@@ -776,7 +777,7 @@ int db_define_has(const char * zName){
assert(SQLITE_DONE==rc);
rc = 0;
}
- g_debug(1,("define has [%s] = %d\n",zName, rc));
+ g_debug(1,("defined [%s] ?= %d\n",zName, rc));
sqlite3_clear_bindings(g.stmt.defHas);
sqlite3_reset(g.stmt.defHas);
return rc;
@@ -1220,10 +1221,11 @@ static void cmpp_kwd_if(CmppKeyword const * pKw, CmppTokenizer *t){
if(TT_IfNot==pKw->ttype || TT_ElifNot==pKw->ttype) buul = !buul;
if(buul){
CT_pstate(t) = tmpState = TS_IfPassed;
- CT_skipLevel(t) = 0;
+ CT_skipLevel(t) = 0;
}else{
CT_pstate(t) = TS_If /* also for TT_IfNot, TT_Elif, TT_ElifNot */;
CT_skipLevel(t) = 1;
+ g_debug(3,("setting CT_skipLevel = 1 @ level %d\n", t->level.ndx));
}
if(TT_If==pKw->ttype || TT_IfNot==pKw->ttype){
unsigned const lvlIf = t->level.ndx;
@@ -1234,10 +1236,13 @@ static void cmpp_kwd_if(CmppKeyword const * pKw, CmppTokenizer *t){
assert(TT_EndIf == t->token.ttype);
break;
}
+#if 0
if(TS_IfPassed==tmpState){
tmpState = TS_Start;
t->level.stack[lvlIf].flags |= CmppLevel_F_ELIDE;
+ g_debug(1,("Setting ELIDE for TS_IfPassed @ lv %d (lvlIf=%d)\n", t->level.ndx, lvlIf));
}
+#endif
}
if(lvlIf <= t->level.ndx){
cmpp_kwd__err_prefix(pKw, t, NULL);
diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make
index 8b1a2d4f1..ffc261370 100644
--- a/ext/wasm/dist.make
+++ b/ext/wasm/dist.make
@@ -84,6 +84,8 @@ dist: \
> $(dist-dir.jswasm)/$(notdir $(sqlite3.js))
@$(bin.stripccomments) -k -k < $(sqlite3.mjs) \
> $(dist-dir.jswasm)/$(notdir $(sqlite3.mjs))
+ @$(bin.stripccomments) -k -k < $(sqlite3-bundler-friendly.mjs) \
+ > $(dist-dir.jswasm)/$(notdir $(sqlite3-bundler-friendly.mjs))
@cp -p $(dist.common.extras) $(dist-dir.common)
@set -e; \
vnum=$$($(bin.version-info) --download-version); \
diff --git a/ext/wasm/tester1-worker.html b/ext/wasm/tester1-worker.html
index a9c12d72c..03e1f02b0 100644
--- a/ext/wasm/tester1-worker.html
+++ b/ext/wasm/tester1-worker.html
@@ -11,8 +11,12 @@
</head>
<body>
<h1 id='color-target'>sqlite3 tester #1: Worker thread</h1>
- <div>See <a href='tester1.html' target='tester1.html'>tester1.html</a>
- for the UI-thread variant.</div>
+ <div>Variants:
+ <a href='tester1.html' target='tester1.html'>conventional UI thread</a>,
+ <a href='tester1-worker.html' target='tester1-worker.html'>conventional worker</a>,
+ <a href='tester1-esm.html' target='tester1-esm.html'>ESM in UI thread</a>,
+ <a href='tester1-worker.html?esm' target='tester1-worker.html?esm'>ESM worker</a>
+ </div>
<div class='input-wrapper'>
<input type='checkbox' id='cb-log-reverse'>
<label for='cb-log-reverse'>Reverse log order?</label>
diff --git a/ext/wasm/tester1.c-pp.html b/ext/wasm/tester1.c-pp.html
index 535e58962..bbdd8b223 100644
--- a/ext/wasm/tester1.c-pp.html
+++ b/ext/wasm/tester1.c-pp.html
@@ -16,8 +16,12 @@ UI thread
<style></style>
</head>
<body><h1 id='color-target'></h1>
- <div>See <a href='tester1-worker.html' target='tester1-worker.html'>tester1-worker.html</a>
- for the Worker-thread variant.</div>
+ <div>Variants:
+ <a href='tester1.html' target='tester1.html'>conventional UI thread</a>,
+ <a href='tester1-worker.html' target='tester1-worker.html'>conventional worker</a>,
+ <a href='tester1-esm.html' target='tester1-esm.html'>ESM in UI thread</a>,
+ <a href='tester1-worker.html?esm' target='tester1-worker.html?esm'>ESM worker</a>
+ </div>
<div class='input-wrapper'>
<input type='checkbox' id='cb-log-reverse'>
<label for='cb-log-reverse'>Reverse log order?</label>
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js
index 7f5de5166..dca533137 100644
--- a/ext/wasm/tester1.c-pp.js
+++ b/ext/wasm/tester1.c-pp.js
@@ -1192,13 +1192,13 @@ self.sqlite3InitModule = sqlite3InitModule;
rc = capi.sqlite3_db_status(this.db, capi.SQLITE_DBSTATUS_LOOKASIDE_USED,
pCur, pHi, 0);
T.assert(0===rc);
- if(wasm.peek32(pCur)){
- warn("Cannot test db_config(SQLITE_DBCONFIG_LOOKASIDE)",
- "while lookaside memory is in use.");
- }else{
+ if(!wasm.peek32(pCur)){
rc = capi.sqlite3_db_config(this.db, capi.SQLITE_DBCONFIG_LOOKASIDE,
0, 4096, 12);
T.assert(0 === rc);
+ }else{
+ console.debug("Cannot test db_config(SQLITE_DBCONFIG_LOOKASIDE)",
+ "while lookaside memory is in use.");
}
wasm.poke32([pCur, pHi], 0);
let [vCur, vHi] = wasm.peek32(pCur, pHi);
diff --git a/manifest b/manifest
index 4b7e12a3a..5c62a39f7 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\scompiler\swarning\sin\sbase85.c.
-D 2023-01-27T23:10:10.479
+C Add\sJS\sbundler-friendly\sJS\sbuild.\sMinor\stest\scode\scleanups.
+D 2023-01-28T04:20:46.205
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -466,33 +466,33 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb
F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
-F ext/wasm/GNUmakefile 217dcb2e3058d7554c46a6e8c89fdb28006c2278206e3e9572ce52030736a5a6
-F ext/wasm/README-dist.txt dab111337028af58ec11cb35c2e1a82398217c399c7499fefab0509a0499a5d7
+F ext/wasm/GNUmakefile 8d82b51a23f9c84c770abd72f18d95a95044a03a216e0246ebd1b3668619c77e
+F ext/wasm/README-dist.txt 4a1db3677d0341a12434d1fd6c97aae2f96785d734641407a201b719f5d94f44
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 77a2f1f2fc60a35def7455dffc8d3f2c56385d6ac5c6cecc60fa938252ea2c54
-F ext/wasm/api/extern-post-js.c-pp.js 8923f76c3d2213159e12d641dc750523ead5c848185dc4996fae5cc12397f88d
+F ext/wasm/api/extern-post-js.c-pp.js 44a3a169f55a8dba42cf688954b2625b9b9e6174f2ff02d4918a2ca8c3beab7f
F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41
F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
-F ext/wasm/api/pre-js.c-pp.js f060b108d0960798c0aa0688392a3c1a58a2e3c942f3560de1c4a7a1aa7af433
+F ext/wasm/api/pre-js.c-pp.js 9ece5de1bb0509f0a8a360712fcc9c1291b9516c0be5bd66acedd6edbcec37a1
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
F ext/wasm/api/sqlite3-api-glue.js 0a93e58aabf52b32ddccbb107a1fd4552f2505e103ab63396c4d0a0743704785
-F ext/wasm/api/sqlite3-api-oo1.js e9fba119e9b1716b3f731838ed1ab18741401bcf4c51d2a4a6e9d1d23cf9d771
+F ext/wasm/api/sqlite3-api-oo1.js a3892fd79070d8c947205d8b90d8218cdb12e7fd5027dced5805dd387b590a36
F ext/wasm/api/sqlite3-api-prologue.js 69a74f2777aaafafc07ad2c922674fe3197ef63c921a3262b4772f937e7eb14a
F ext/wasm/api/sqlite3-api-worker1.js c462199c40358f00f93e326206bddc756c52b93f2cb60ffb63f54fe4f9a9e977
F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
F ext/wasm/api/sqlite3-opfs-async-proxy.js 7795b84b66a7a8dedc791340709b310bb497c3c72a80bef364fa2a58e2ddae3f
F ext/wasm/api/sqlite3-v-helper.js 6f6c3e390a72e08b0a5b16a0d567d7af3c04d172831853a29d72a6f1dd40ff24
-F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 50e4f6103dc65556e3e040f9e80eb8f14bfc6f979fa018952859f7755e201b27
+F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js a10bdc9695dcf453e120970a5de8a3e61db4e4047d0a7cc5a6d63dfe7ae87f4e
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
F ext/wasm/api/sqlite3-wasm.c 76625a70937a8522d014ef686c32db5b53a3ee61850323f5c601d2ac39fe52fe
-F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52aff253afbf3350431f5773faf0e4b
-F ext/wasm/api/sqlite3-worker1.js 9d3d3dfc70bff8998c1d8ff6d881cf1c3d52468d635417f02796151fe6b31cd7
+F ext/wasm/api/sqlite3-worker1-promiser.js f10c3ecd9df06f6320073c2ce230a7ed7c56034d8b88c1e57095f2a97faf423a
+F ext/wasm/api/sqlite3-worker1.js 77b3835192469e9da23926ec8f78fb0b114a51d048dc54388709ac22b5c5f0a0
F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d0cef96fbbe4c8
F ext/wasm/batch-runner.js 0dad6a02ad796f1003d3b7048947d275c4d6277f63767b8e685c27df8fdac93e
-F ext/wasm/c-pp.c 92285f7bce67ed7b7020b40fde8ed0982c442b63dc33df9dfd4b658d4a6c0779
+F ext/wasm/c-pp.c 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25b4
F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
F ext/wasm/common/testing.css 0ff15602a3ab2bad8aef2c3bd120c7ee3fd1c2054ad2ace7e214187ae68d926f
@@ -506,7 +506,7 @@ F ext/wasm/demo-worker1-promiser.html 1de7c248c7c2cfd4a5783d2aa154bce62d74c6de98
F ext/wasm/demo-worker1-promiser.js b99c550763fa792c204e9a7cceadd976004036d9fc3e22fab7051712e30d207d
F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d
F ext/wasm/demo-worker1.js a619adffc98b75b66c633b00f747b856449a134a9a0357909287d80a182d70fa
-F ext/wasm/dist.make 5523b02e824db5ab8176e3eedc2e709fe1204d8f4d6e52e8321cdf6830114b72
+F ext/wasm/dist.make b50668a4f79d4464a59c3378b6b53968bb0652a06737b1e0b07544458de28f3d
F ext/wasm/fiddle.make d5308b5c35f691758ef20badd25f91f3780b20415760daf0d98afbe4f24921b9
F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
F ext/wasm/fiddle/fiddle-worker.js b4a0c8ab6c0983218543ca771c45f6075449f63a1dcf290ae5a681b2cba8800d
@@ -528,9 +528,9 @@ F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d826
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555e685bce3da8c3f
F ext/wasm/test-opfs-vfs.js f09266873e1a34d9bdb6d3981ec8c9e382f31f215c9fd2f9016d2394b8ae9b7b
-F ext/wasm/tester1-worker.html d43f3c131d88f10d00aff3e328fed13c858d674ea2ff1ff90225506137f85aa9
-F ext/wasm/tester1.c-pp.html d34bef3d48e5cbc1c7c06882ad240fec49bf88f5f65696cc2c72c416933aa406
-F ext/wasm/tester1.c-pp.js 7786fa3bdf074be8935e3a77b1ca135fd36ef6f87823c0695deaca585b133d06
+F ext/wasm/tester1-worker.html 258d08f1ba9cc2d455958751e26be833893cf9ff7853e9436e593e1f778a386b
+F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
+F ext/wasm/tester1.c-pp.js f199ef496aec40a7ddedcc84f996117c911eac36d377913993d3f0261f9427ac
F ext/wasm/tests/opfs/concurrency/index.html 86d8ac435074d1e7007b91105f4897f368c165e8cecb6a9aa3d81f5cf5dcbe70
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
@@ -2044,8 +2044,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P e446c8b4aa2ffe075f9c289c771d62a414661c3ffe6abae5649c50af8e32fab6
-R d679b1424ddaeb09fc6eeb6c565e2751
-U drh
-Z 0e1eac878e4ebdd2f0ed91103111d8aa
+P bd9613fd63193bd6b33798d83f0ef21987ba468b53d13a25a31cb9e9e5f20562 6a5c4f6b19aa0704efe7f789102f757a1ed05d6542f37c7aa37a4439783944a3
+R 7e285c57f9c962c0e3cd104712b20885
+T +closed 6a5c4f6b19aa0704efe7f789102f757a1ed05d6542f37c7aa37a4439783944a3 Closed\sby\sintegrate-merge.
+U stephan
+Z 04a00083266e19e010eadc8bb14898d9
# Remove this line to create a well-formed Fossil manifest.
diff --git a/manifest.uuid b/manifest.uuid
index fea530843..9b1cb2f61 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-bd9613fd63193bd6b33798d83f0ef21987ba468b53d13a25a31cb9e9e5f20562 \ No newline at end of file
+24d3a53dea5e596230558e233cbbd9d0288b4c394cd5ea7b650fd99bff4cde2e \ No newline at end of file