/* Clean up temporary references to our APIs... */
delete sqlite3.capi.util /* arguable, but these are (currently) internal-use APIs */;
- Module.sqlite3 = sqlite3 /* Currently needed by test code and sqlite3-worker1.js */;
- //console.warn("Module.sqlite3 =",Module.sqlite3);
+ Module.sqlite3 = sqlite3 /* Needed for customized sqlite3InitModule() to be able to
+ pass the sqlite3 object off to the client. */;
}else{
console.warn("This is not running in an Emscripten module context, so",
"self.sqlite3ApiBootstrap() is _not_ being called due to lack",
The config object properties include:
- - `Module`[^1]: Emscripten-style module object. Currently only required
- by certain test code and is _not_ part of the public interface.
- (TODO: rename this to EmscriptenModule to be more explicit.)
-
- `exports`[^1]: the "exports" object for the current WASM
environment. In an Emscripten build, this should be set to
`Module['asm']`.
const config = Object.create(null);
{
const configDefaults = {
- Module: undefined/*needed for some test code, not part of the public API*/,
exports: undefined,
memory: undefined,
bigIntEnabled: (()=>{
if('undefined'!==typeof Module){
- /* Emscripten module will contain HEAPU64 when build with
+ /* Emscripten module will contain HEAPU64 when built with
-sWASM_BIGINT=1, else it will not. */
return !!Module.HEAPU64;
}
[
// If any of these config options are functions, replace them with
// the result of calling that function...
- 'Module', 'exports', 'memory', 'wasmfsOpfsDir'
+ 'exports', 'memory', 'wasmfsOpfsDir'
].forEach((k)=>{
if('function' === typeof config[k]){
config[k] = config[k]();
-sMODULARIZE \
-sDYNAMIC_EXECUTION=0 \
-sWASM_BIGINT=$(emcc_enable_bigint) \
- -sEXPORT_NAME=initFiddleModule \
+ -sEXPORT_NAME=$(sqlite3.js.init-func) \
+ $(sqlite3.js.flags.--post-js) \
-sEXPORTED_RUNTIME_METHODS=@$(dir.wasm)/EXPORTED_RUNTIME_METHODS.fiddle \
-sEXPORTED_FUNCTIONS=@$(dir.wasm)/EXPORTED_FUNCTIONS.fiddle \
--post-js=$(post-js.js) \
$(fiddle-module.js): $(MAKEFILE) $(MAKEFILE.fiddle) \
EXPORTED_FUNCTIONS.fiddle EXPORTED_RUNTIME_METHODS.fiddle \
- $(fiddle.cs) $(post-js.js) $(dir.fiddle)/$(SOAP.js)
+ $(fiddle.cs) $(post-jses.deps) $(dir.fiddle)/$(SOAP.js)
$(emcc.bin) -o $@ $(fiddle.emcc-flags) $(fiddle.cs)
$(maybe-wasm-strip) $(fiddle-module.wasm)
gzip < $@ > $@.gz
rm -f $(fiddle-module.js) $(fiddle-module.js).gz \
$(fiddle-module.wasm) $(fiddle-module.wasm).gz \
$(dir.fiddle)/$(SOAP.js) \
+ $(dir.fiddle)/fiddle-module.worker.js \
EXPORTED_FUNCTIONS.fiddle
.PHONY: fiddle
fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz
that any argv strings passed to its main() are valid until
the wasm environment shuts down. */
];
- const S = fiddleModule.sqlite3;
+ const capi = sqlite3.capi;
/* We need to call sqlite3_shutdown() in order to avoid numerous
legitimate warnings from the shell about it being initialized
after sqlite3_initialize() has been called. This means,
to be re-done (e.g. re-registration of dynamically-loaded
VFSes). We need a more generic approach to running such
init-level code. */
- S.capi.sqlite3_shutdown();
- f.argv.pArgv = S.capi.wasm.allocMainArgv(f.argv);
- f.argv.rc = S.capi.wasm.exports.fiddle_main(
+ capi.sqlite3_shutdown();
+ f.argv.pArgv = capi.wasm.allocMainArgv(f.argv);
+ f.argv.rc = capi.wasm.exports.fiddle_main(
f.argv.length, f.argv.pArgv
);
if(f.argv.rc){
fiddleModule.isDead = true;
return false;
}
- stdout("SQLite version", S.capi.sqlite3_libversion(),
- S.capi.sqlite3_sourceid().substr(0,19));
+ stdout("SQLite version", capi.sqlite3_libversion(),
+ capi.sqlite3_sourceid().substr(0,19));
stdout('Welcome to the "fiddle" shell.');
if(S.opfs){
stdout("\nOPFS is available. To open a persistent db, use:\n\n",
exec: function f(sql){
if(!f._){
if(!this.runMain()) return;
- f._ = fiddleModule.cwrap('fiddle_exec', null, ['string']);
+ f._ = sqlite3.capi.wasm.xWrap('fiddle_exec', null, ['string']);
}
if(fiddleModule.isDead){
stderr("shell module has exit()ed. Cannot run SQL.");
if(f._running){
stderr('Cannot run multiple commands concurrently.');
}else if(sql){
+ if(Array.isArray(sql)) sql = sql.join('');
f._running = true;
f._(sql);
}
stderr("TODO: cannot currently reset an OPFS-hosted db.");
return;
}
- if(!f._) f._ = fiddleModule.cwrap('fiddle_reset_db', null);
+ if(!f._) f._ = sqlite3.capi.wasm.xWrap('fiddle_reset_db', null);
stdout("Resetting database.",fixmeOPFS);
f._();
stdout("Reset",this.dbFilename());
/* Interrupt can't work: this Worker is tied up working, so won't get the
interrupt event which would be needed to perform the interrupt. */
interrupt: function f(){
- if(!f._) f._ = fiddleModule.cwrap('fiddle_interrupt', null);
+ if(!f._) f._ = sqlite3.capi.wasm.xWrap('fiddle_interrupt', null);
stdout("Requesting interrupt.");
f._();
}
the bug is apparently in (or via) this code.
*/
const brokenExportDbFileToBlob = function(){
- const S = fiddleModule.sqlite3, capi = S.capi, wasm = capi.wasm;
+ const capi = sqlite3.capi, wasm = capi.wasm;
const pDb = Sqlite3Shell.dbHandle();
if(!pDb) toss("No db is opened.");
const scope = wasm.scopedAllocPush();
}finally{
wasm.scopedAllocPop(scope);
}
- }/*exportDbFileToBlob()*/;
+ }/*brokenExportDbFileToBlob()*/;
const exportDbFileToBlob = function f(){
if(!f._){
emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initFiddleModule
*/
- initFiddleModule(fiddleModule).then(function(thisModule){
- sqlite3 = thisModule.sqlite3;
- const atEnd = ()=>{
- thisModule.fsUnlink = (fn)=>{
- stderr("unlink:",fixmeOPFS);
- return sqlite3.capi.wasm.sqlite3_wasm_vfs_unlink(fn);
- };
- wMsg('fiddle-ready');
+ sqlite3InitModule(fiddleModule).then((_sqlite3)=>{
+ sqlite3 = _sqlite3;
+ fiddleModule.fsUnlink = (fn)=>{
+ stderr("unlink:",fixmeOPFS);
+ return sqlite3.capi.wasm.sqlite3_wasm_vfs_unlink(fn);
};
- if(sqlite3.installOpfsVfs) sqlite3.installOpfsVfs().finally(atEnd);
- else atEnd();
+ wMsg('fiddle-ready');
})/*then()*/;
})();
.querySelector(arguments[arguments.length-1]);
};
- /** Handles status updates from the Module object. */
+ /** Handles status updates from the Emscripten Module object. */
SF.addMsgHandler('module', function f(ev){
ev = ev.data;
if('status'!==ev.type){
(function(){
const xElem = E('#select-examples');
const examples = [
- {name: "Help", sql:
-`-- ================================================
--- Use ctrl-enter or shift-enter to execute sqlite3
--- shell commands and SQL.
--- If a subset of the text is currently selected,
--- only that part is executed.
--- ================================================
-.help`},
+ {name: "Help", sql: [
+ "-- ================================================\n",
+ "-- Use ctrl-enter or shift-enter to execute sqlite3\n",
+ "-- shell commands and SQL.\n",
+ "-- If a subset of the text is currently selected,\n",
+ "-- only that part is executed.\n",
+ "-- ================================================\n",
+ ".help\n"
+ ]},
//{name: "Timer on", sql: ".timer on"},
// ^^^ re-enable if emscripten re-enables getrusage()
- {name: "Setup table T", sql:`.nullvalue NULL
-CREATE TABLE t(a,b);
-INSERT INTO t(a,b) VALUES('abc',123),('def',456),(NULL,789),('ghi',012);
-SELECT * FROM t;`},
- {name: "Table list", sql: ".tables"},
- {name: "Box Mode", sql: ".mode box"},
- {name: "JSON Mode", sql: ".mode json"},
- {name: "Mandlebrot", sql: `WITH RECURSIVE
- xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),
- yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),
- m(iter, cx, cy, x, y) AS (
- SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
- UNION ALL
- SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m
- WHERE (x*x + y*y) < 4.0 AND iter<28
- ),
- m2(iter, cx, cy) AS (
- SELECT max(iter), cx, cy FROM m GROUP BY cx, cy
- ),
- a(t) AS (
- SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '')
- FROM m2 GROUP BY cy
- )
-SELECT group_concat(rtrim(t),x'0a') as Mandelbrot FROM a;`}
+ {name: "Setup table T", sql:[
+ ".nullvalue NULL\n",
+ "CREATE TABLE t(a,b);\n",
+ "INSERT INTO t(a,b) VALUES('abc',123),('def',456),(NULL,789),('ghi',012);\n",
+ "SELECT * FROM t;\n"
+ ]},
+ {name: "Table list", sql: ".tables"},
+ {name: "Box Mode", sql: ".mode box"},
+ {name: "JSON Mode", sql: ".mode json"},
+ {name: "Mandlebrot", sql:[
+ "WITH RECURSIVE",
+ " xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),\n",
+ " yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),\n",
+ " m(iter, cx, cy, x, y) AS (\n",
+ " SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis\n",
+ " UNION ALL\n",
+ " SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m \n",
+ " WHERE (x*x + y*y) < 4.0 AND iter<28\n",
+ " ),\n",
+ " m2(iter, cx, cy) AS (\n",
+ " SELECT max(iter), cx, cy FROM m GROUP BY cx, cy\n",
+ " ),\n",
+ " a(t) AS (\n",
+ " SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') \n",
+ " FROM m2 GROUP BY cy\n",
+ " )\n",
+ "SELECT group_concat(rtrim(t),x'0a') as Mandelbrot FROM a;\n",
+ ]}
];
const newOpt = function(lbl,val){
const o = document.createElement('option');
+ if(Array.isArray(val)) val = val.join('');
o.value = val;
if(!val) o.setAttribute('disabled',true);
o.appendChild(document.createTextNode(lbl));
-C Rework\sthe\sEmscripten-emitted\smodule\sloader/init\sfunction\ssuch\sthat\sit\spasses\son\sthe\ssqlite3\smodule,\sinstead\sof\sthe\sEmscripten\smodule,\sto\sthe\sfirst\sthen()\sof\ssqlite3InitModule()'s\sreturned\sPromise.\sThis\seliminates\sany\sneed\sto\smention\sthe\sEmscripten\smodule\sobject\sin\sclient-side\scode\sunless\sthey\swant\sto\sconfigure\sit\sin\sadvance\sfor\sloading-status\sreports.
-D 2022-09-29T13:17:50.536
+C Finish\seliminating\sexplicit\sEmscripten\smodule\sdependencies\sin\stest\scode\sand\sfiddle.\sThe\sonly\sremnant\sin\spublic\scode\sis\sthe\sEmscripten-generated\smodule\sload/init\sinterface.
+D 2022-09-29T16:54:23.260
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/api/extern-post-js.js d29d5f615c887b356ff80a77a09a346339644c66d4fea79230d8378e2e2f4914
F ext/wasm/api/post-js-footer.js b64319261d920211b8700004d08b956a6c285f3b0bba81456260a713ed04900c
F ext/wasm/api/post-js-header.js 2e5c886398013ba2af88028ecbced1e4b22dc96a86467f1ecc5ba9e64ef90a8b
-F ext/wasm/api/sqlite3-api-cleanup.js 4bd28e61216690b12d6f77bfce71b011995c29496397cfa77e08198eb8d19aeb
+F ext/wasm/api/sqlite3-api-cleanup.js 98905936119a555659b5cf43844211809ab9f436c52a569004e5585d2842b5c2
F ext/wasm/api/sqlite3-api-glue.js 3b164f0ef690a838da8613a2aaec4fc49d29ad5e8fe39c8cdc0f5281f08f9d0b
F ext/wasm/api/sqlite3-api-oo1.js 97a786b366fcac442e1557c3eedef3afa96877411bd6239094d4db5fd5b3c353
F ext/wasm/api/sqlite3-api-opfs.js af65e056b9f5bc6182499f7e7767e3d01abc3772a62c8abbcc04e4c7bb0affc6
-F ext/wasm/api/sqlite3-api-prologue.js 47245a1bb279f54c7c1d6b32f13222536ce0196ced9c2bda2d12a0b4ef8c136d
+F ext/wasm/api/sqlite3-api-prologue.js 97b6073ec313ec4bcbf5d9aeac3ede548485642e56b3e1573beef198f38cc565
F ext/wasm/api/sqlite3-api-worker1.js d5d5b7fac4c4731c38c7e03f4f404b2a95c388a2a1d8bcf361caada572f107e0
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
F ext/wasm/api/sqlite3-wasm.c b756b9c1fee9d0598f715e6df6bf089b750da24aa91bb7ef9277a037d81e7612
F ext/wasm/demo-123.js 35de7c544b9190759fcbf4ca125a674d3f6db03614b9a2175efaa1fbf363ef6f
F ext/wasm/demo-kvvfs1.html 7d4f28873de67f51ac18c584b7d920825139866a96049a49c424d6f5a0ea5e7f
F ext/wasm/demo-kvvfs1.js d1126c3b08099dc1279f353b298ee90f6d374ab6ca2b4cf412031fc992e51d35
-F ext/wasm/fiddle.make fd56fa21bada6ecbf860686a9a789ebda7cc3d9b60835927000fcb00246ea50f
+F ext/wasm/fiddle.make 1595178ee6e6bb645d2be5b6c349cb3604182106ca3fd6bf3336be51432cfb19
F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
-F ext/wasm/fiddle/fiddle-worker.js 425b75b1debe1108c10f1373fdd75994a18adbdc0a593e7ff0ecd91cc6498e89
+F ext/wasm/fiddle/fiddle-worker.js 2a7107b06e5be3b9b063c340ec952f687e37ba6e0aa736b58c280dfb5e16625a
F ext/wasm/fiddle/fiddle.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2
-F ext/wasm/fiddle/fiddle.js aa44051be6e48c53fd23c829177d43f557dcc6f0998ccfcbae7c473ff405f0c6
+F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715
F ext/wasm/index.html 63b370619e4f849ac76f1baed435c05edc29dbb6795bc7c1c935561ff667dd27
F ext/wasm/jaccwabyt/jaccwabyt.js 0d7f32817456a0f3937fcfd934afeb32154ca33580ab264dab6c285e6dbbd215
F ext/wasm/jaccwabyt/jaccwabyt.md 9aa6951b529a8b29f578ec8f0355713c39584c92cf1708f63ba0cf917cb5b68e
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 2e2821f782511b9d2274a89a5a922582aba18c7e9dc7ce01080e713942a56d7d
-R 4702b024c44aa8b0e10da8a3cb6edeca
+P 0dbaa0e2b5abf5c23e2039ec90a3055ebb3c063aaf4e556c42546defe6fbb86d
+R 5ed3f961358b68dff72339b628086e3f
U stephan
-Z 43dbf13bcecc8e2f4da632a6ad6ef70c
+Z 127c84518f22055431ece9a85dc4b451
# Remove this line to create a well-formed Fossil manifest.
-0dbaa0e2b5abf5c23e2039ec90a3055ebb3c063aaf4e556c42546defe6fbb86d
\ No newline at end of file
+7be78dd4efc410f13ff1ceda1fad82b309cc24de2d5106c8bd6b2adeaa13b106
\ No newline at end of file