More work on creating a separate sqlite3.js build which is hopefully friendly to JS bundlers.

FossilOrigin-Name: b7b896fb448a7f46eb88eadadb1359255aec637a384cabcdd526276a02f4f0b4
This commit is contained in:
stephan 2023-01-27 03:18:16 +00:00
parent 67bfea4ea6
commit a0013fbe87
8 changed files with 53 additions and 24 deletions

View File

@ -704,7 +704,9 @@ $(sqlite3-bundler-friendly.mjs):
# (and harmless, just a waste of build time).
$(sqlite3.wasm): $(sqlite3.js)
$(sqlite3.mjs): $(sqlite3.js)
$(sqlite3-bundler-friendly.mjs): $(sqlite3.js)
$(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)

View File

@ -45,14 +45,23 @@ const toExportForES6 =
moduleScript: self?.document?.currentScript,
isWorker: ('undefined' !== typeof WorkerGlobalScope),
location: self.location,
urlParams: new URL(self.location.href).searchParams
urlParams:
//#if target=es6-bundler-friendly
undefined
//#else
new URL(self.location.href).searchParams
//#endif
});
initModuleState.debugModule =
(new URL(self.location.href).searchParams).has('sqlite3.debugModule')
//#if target=es6-bundler-friendly
()=>{}
//#else
(new URL(self.location.href).searchParams).has('sqlite3.debugModule')
? (...args)=>console.warn('sqlite3.debugModule:',...args)
: ()=>{};
//#endif
if(initModuleState.urlParams.has('sqlite3.dir')){
if(initModuleState.urlParams && initModuleState.urlParams.has('sqlite3.dir')){
initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/';
}else if(initModuleState.moduleScript){
const li = initModuleState.moduleScript.src.split('/');

View File

@ -6,7 +6,10 @@
*/
// See notes in extern-post-js.js
const sqlite3InitModuleState = self.sqlite3InitModuleState || Object.create(null);
const sqlite3InitModuleState = self.sqlite3InitModuleState
|| Object.assign(Object.create(null),{
debugModule: ()=>{}
});
delete self.sqlite3InitModuleState;
sqlite3InitModuleState.debugModule('self.location =',self.location);

View File

@ -100,13 +100,20 @@ const installOpfsVfs = function callee(options){
if(!options || 'object'!==typeof options){
options = Object.create(null);
}
const urlParams = new URL(self.location.href).searchParams;
if(undefined===options.verbose){
options.verbose = urlParams.has('opfs-verbose')
? (+urlParams.get('opfs-verbose') || 2) : 1;
}
if(undefined===options.sanityChecks){
options.sanityChecks = urlParams.has('opfs-sanity-check');
const urlParams =
//#if target=es6-bundler-friendly
undefined;
//#else
new URL(self.location.href).searchParams;
//#endif
if(urlParams){
if(undefined===options.verbose){
options.verbose = urlParams.has('opfs-verbose')
? (+urlParams.get('opfs-verbose') || 2) : 1;
}
if(undefined===options.sanityChecks){
options.sanityChecks = urlParams.has('opfs-sanity-check');
}
}
if(undefined===options.proxyUri){
options.proxyUri = callee.defaultProxyUri;

View File

@ -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
}),

View File

@ -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();
});

View File

@ -1,5 +1,5 @@
C Resolve\sa\snested\sif-block\sbug\sin\sext/wasm/c-pp.c\swhich\scaused\soutput\safter\sa\snested\sblock\sto\sbe\sunduly\selided.\sRemove\sa\skludge,\sadded\sin\sthe\sprevious\scheck-in,\swhich\sworked\saround\sthat\sbug.
D 2023-01-27T02:21:16.305
C More\swork\son\screating\sa\sseparate\ssqlite3.js\sbuild\swhich\sis\shopefully\sfriendly\sto\sJS\sbundlers.
D 2023-01-27T03:18:16.304
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -466,17 +466,17 @@ 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 9685958e3c5942c50f16fadbb0c2377252689c52e022a8c1897ad5c4cf751298
F ext/wasm/GNUmakefile e1bd4abe13929dbc4fd9da06d189c61d28fc7a539b2cab942f6300172539d8a5
F ext/wasm/README-dist.txt dab111337028af58ec11cb35c2e1a82398217c399c7499fefab0509a0499a5d7
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 9c1f67c368660cb14b6ddee0ed7c87c70594a41c2a0adc7005016feda6c0cbdb
F ext/wasm/api/extern-post-js.c-pp.js ea549ffcdd3f116de5b4cc08a428e0a91052c341b51b37f158747285f9ef2fe8
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 109d3afcdf6203a39fe79a2d7e0e1e5f93ea672ae00578fd4ec4f6fe19b484cc
F ext/wasm/api/pre-js.c-pp.js 86b2909e07690792ecf14892e6ee4d2ea0b2d6bf8567ad3d549a8cc2e30828a0
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
@ -485,11 +485,11 @@ F ext/wasm/api/sqlite3-api-worker1.js c9ef8865f072e61251260b218aa4ed614a21a25e9e
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 a10bdc9695dcf453e120970a5de8a3e61db4e4047d0a7cc5a6d63dfe7ae87f4e
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js bae9c4c40991a550450bb89dc34e6e1e1e875ae230ccdce3dbb99515517d3361
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 6d80d8569d85713effe8b0818a3cf51dc779e3f0bf8dc88771b8998552ee25b4
@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 4271bf5f41df091696f1dcfc4ffe7a60d24066fc75c896941e0b56de95fe5f89
R 94f2cf8a092efa28759f003587a957ce
P 7a026a4b24d57c1b0970923b972dd42c3f1bb5b282f908079075468b2e1bf601
R 102faa857a2d0d2c23a0f1e8d23a4eac
U stephan
Z 16fc9ca50b1409b7eeea4546395ed5b7
Z 7417462f84e9f6b455bd391f77e8f338
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
7a026a4b24d57c1b0970923b972dd42c3f1bb5b282f908079075468b2e1bf601
b7b896fb448a7f46eb88eadadb1359255aec637a384cabcdd526276a02f4f0b4