Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More work on creating a separate sqlite3.js build which is hopefully friendly to JS bundlers. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | js-bundler-friendly |
Files: | files | file ages | folders |
SHA3-256: |
b7b896fb448a7f46eb88eadadb135925 |
User & Date: | stephan 2023-01-27 03:18:16 |
Context
2023-01-27
| ||
05:14 | Work around upstream emscripten 3.1.31 ticket #18609. (check-in: fa784101 user: stephan tags: js-bundler-friendly) | |
03:18 | More work on creating a separate sqlite3.js build which is hopefully friendly to JS bundlers. (check-in: b7b896fb user: stephan tags: js-bundler-friendly) | |
02:21 | Resolve a nested if-block bug in ext/wasm/c-pp.c which caused output after a nested block to be unduly elided. Remove a kludge, added in the previous check-in, which worked around that bug. (check-in: 7a026a4b user: stephan tags: js-bundler-friendly) | |
Changes
Changes to ext/wasm/GNUmakefile.
︙ | ︙ | |||
700 701 702 703 704 705 706 | # $(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) multiple times, but that's apparently unavoidable # (and harmless, just a waste of build time). $(sqlite3.wasm): $(sqlite3.js) $(sqlite3.mjs): $(sqlite3.js) | | > > | 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | # $(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) multiple times, but that's apparently unavoidable # (and harmless, just a waste of build time). $(sqlite3.wasm): $(sqlite3.js) $(sqlite3.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) 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 |
︙ | ︙ |
Changes to ext/wasm/api/extern-post-js.c-pp.js.
︙ | ︙ | |||
41 42 43 44 45 46 47 | into the global scope and delete it when sqlite3InitModule() is called. */ const initModuleState = self.sqlite3InitModuleState = Object.assign(Object.create(null),{ moduleScript: self?.document?.currentScript, isWorker: ('undefined' !== typeof WorkerGlobalScope), location: self.location, | > > > > | > > > > | > | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | into the global scope and delete it when sqlite3InitModule() is called. */ const initModuleState = self.sqlite3InitModuleState = Object.assign(Object.create(null),{ moduleScript: self?.document?.currentScript, isWorker: ('undefined' !== typeof WorkerGlobalScope), location: self.location, urlParams: //#if target=es6-bundler-friendly undefined //#else new URL(self.location.href).searchParams //#endif }); initModuleState.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 && initModuleState.urlParams.has('sqlite3.dir')){ initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/'; }else if(initModuleState.moduleScript){ const li = initModuleState.moduleScript.src.split('/'); li.pop(); initModuleState.sqlite3Dir = li.join('/') + '/'; } |
︙ | ︙ |
Changes to ext/wasm/api/pre-js.c-pp.js.
1 2 3 4 5 6 7 8 | /** BEGIN FILE: api/pre-js.js This file is intended to be prepended to the sqlite3.js build using Emscripten's --pre-js=THIS_FILE flag (or equivalent). */ // See notes in extern-post-js.js | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** BEGIN FILE: api/pre-js.js This file is intended to be prepended to the sqlite3.js build using Emscripten's --pre-js=THIS_FILE flag (or equivalent). */ // See notes in extern-post-js.js 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 |
︙ | ︙ |
Changes to ext/wasm/api/sqlite3-vfs-opfs.c-pp.js.
︙ | ︙ | |||
96 97 98 99 100 101 102 | return Promise.reject( new Error("Missing required OPFS APIs.") ); } if(!options || 'object'!==typeof options){ options = Object.create(null); } | > > > > | > > | | | | | | > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | return Promise.reject( new Error("Missing required OPFS APIs.") ); } if(!options || 'object'!==typeof options){ options = Object.create(null); } 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; } //console.warn("OPFS options =",options,self.location); |
︙ | ︙ |
Changes to ext/wasm/api/sqlite3-worker1-promiser.js.
︙ | ︙ | |||
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | }); if(rowCallbackId) p = p.finally(()=>delete handlerMap[rowCallbackId]); return p; }; }/*sqlite3Worker1Promiser()*/; self.sqlite3Worker1Promiser.defaultConfig = { worker: function(){ let theJs = "sqlite3-worker1.js"; if(this.currentScript){ const src = this.currentScript.src.split('/'); src.pop(); theJs = src.join('/')+'/' + theJs; //console.warn("promiser currentScript, theJs =",this.currentScript,theJs); }else{ //console.warn("promiser self.location =",self.location); const urlParams = new URL(self.location.href).searchParams; if(urlParams.has('sqlite3.dir')){ theJs = urlParams.get('sqlite3.dir') + '/' + theJs; } } return new Worker(theJs + self.location.search); }.bind({ currentScript: self?.document?.currentScript }), onerror: (...args)=>console.error('worker1 promiser error',...args) }; | > > > > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | }); if(rowCallbackId) p = p.finally(()=>delete handlerMap[rowCallbackId]); return p; }; }/*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('/'); src.pop(); theJs = src.join('/')+'/' + theJs; //console.warn("promiser currentScript, theJs =",this.currentScript,theJs); }else{ //console.warn("promiser self.location =",self.location); const urlParams = new URL(self.location.href).searchParams; if(urlParams.has('sqlite3.dir')){ theJs = urlParams.get('sqlite3.dir') + '/' + theJs; } } return new Worker(theJs + self.location.search); //#endif }.bind({ currentScript: self?.document?.currentScript }), onerror: (...args)=>console.error('worker1 promiser error',...args) }; |
Changes to ext/wasm/api/sqlite3-worker1.js.
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | This file accepts a URL arguments to adjust how it loads sqlite3.js: - `sqlite3.dir`, if set, treats the given directory name as the directory from which `sqlite3.js` will be loaded. */ "use strict"; (()=>{ const urlParams = new URL(self.location.href).searchParams; let theJs = 'sqlite3.js'; if(urlParams.has('sqlite3.dir')){ theJs = urlParams.get('sqlite3.dir') + '/' + theJs; } //console.warn("worker1 theJs =",theJs); importScripts(theJs); sqlite3InitModule().then((sqlite3)=>{ sqlite3.initWorker1API(); }); })(); | > > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | This file accepts a URL arguments to adjust how it loads sqlite3.js: - `sqlite3.dir`, if set, treats the given directory name as the directory from which `sqlite3.js` will be loaded. */ "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')){ theJs = urlParams.get('sqlite3.dir') + '/' + theJs; } //console.warn("worker1 theJs =",theJs); importScripts(theJs); //#endif sqlite3InitModule().then((sqlite3)=>{ sqlite3.initWorker1API(); }); })(); |