Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/wasm/api/sqlite3-worker1.c-pp.js # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / wasm / api / sqlite3-worker1.c-pp.js` 61 lines ยท 2205 bytes Raw Blame History 1 //#if not omit-oo1 2 /* 3 2022-05-23 4 5 The author disclaims copyright to this source code. In place of a 6 legal notice, here is a blessing: 7 8 * May you do good and not evil. 9 * May you find forgiveness for yourself and forgive others. 10 * May you share freely, never taking more than you give. 11 12 *********************************************************************** 13 14 This is a JS Worker file for the main sqlite3 api. It loads 15 sqlite3.js, initializes the module, and postMessage()'s a message 16 after the module is initialized: 17 18 {type: 'sqlite3-api', result: 'worker1-ready'} 19 20 This seemingly superfluous level of indirection is necessary when 21 loading sqlite3.js via a Worker. Instantiating a worker with new 22 Worker("sqlite.js") will not (cannot) call sqlite3InitModule() to 23 initialize the module due to a timing/order-of-operations conflict 24 (and that symbol is not exported in a way that a Worker loading it 25 that way can see it). Thus JS code wanting to load the sqlite3 26 Worker-specific API needs to pass _this_ file (or equivalent) to the 27 Worker constructor and then listen for an event in the form shown 28 above in order to know when the module has completed initialization. 29 30 This file accepts a URL arguments to adjust how it loads sqlite3.js: 31 32 - `sqlite3.dir`, if set, treats the given directory name as the 33 directory from which `sqlite3.js` will be loaded. 34 */ 35 //#if target:es6-bundler-friendly 36 import sqlite3InitModule from './sqlite3-bundler-friendly.mjs'; 37 //#elif target:es6-module 38 import sqlite3InitModule from './sqlite3.mjs'; 39 //#else 40 "use strict"; 41 { 42 const urlParams = globalThis.location 43 ? new URL(globalThis.location.href).searchParams 44 : new URLSearchParams(); 45 let theJs = 'sqlite3.js'; 46 if(urlParams.has('sqlite3.dir')){ 47 const s = urlParams.get('sqlite3.dir'); 48 if( s && s.indexOf(':')<0 && s.indexOf('//')<0 ){ 49 theJs = s + '/' + theJs; 50 }else{ 51 console.warn("Invalid sqlite3.dir value:",s); 52 } 53 } 54 //console.warn("worker1 theJs =",theJs); 55 importScripts(theJs); 56 } 57 //#/if 58 sqlite3InitModule().then(sqlite3 => sqlite3.initWorker1API()); 59 //#else 60 /* Built with the omit-oo1 flag. */ 61 //#/if if not omit-oo1