From 618a375e9f12e78ea0c2449bcf5ed7a769fc6796 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 19 May 2022 10:24:50 +0000 Subject: [PATCH] #if'd out the '.log' command in WASM builds. Cleaned up the user-visible parts of the WASM module initialization. FossilOrigin-Name: b5fa12f824690c1022e4d69b0f5c3949324b311557a7412810741731db7e2cce --- ext/fiddle/fiddle.in.html | 48 ++++++++++++++++++++++++++++----------- ext/fiddle/module-post.js | 40 ++++++++++++++++++++------------ ext/fiddle/module-pre.js | 9 ++++---- manifest | 18 +++++++-------- manifest.uuid | 2 +- src/shell.c.in | 4 ++++ 6 files changed, 79 insertions(+), 42 deletions(-) diff --git a/ext/fiddle/fiddle.in.html b/ext/fiddle/fiddle.in.html index a9c2a57321..b78019565a 100644 --- a/ext/fiddle/fiddle.in.html +++ b/ext/fiddle/fiddle.in.html @@ -5,13 +5,14 @@ sqlite3 fiddle
sqlite3 fiddle
-
emscripten
+
+
+
Initializing app...
+
+ On a slow internet connection this may take a moment. If this + message displays for "a long time", intialization may have + failed and the JavaScript console may contain clues as to why. +
+
Downloading...
-
+
Options
@@ -120,7 +142,7 @@
-
+
- - - + + +
- +
-
+
Notes and Caveats diff --git a/ext/fiddle/module-post.js b/ext/fiddle/module-post.js index bc6f3b2b9f..41dfa35769 100644 --- a/ext/fiddle/module-post.js +++ b/ext/fiddle/module-post.js @@ -14,11 +14,23 @@ window.Module.onRuntimeInitialized = function(){ 'use strict'; const Module = window.Module /* wasm module as set up by emscripten */; delete Module.onRuntimeInitialized; - const taInput = document.querySelector('#input'); - const btnClearIn = document.querySelector('#btn-clear'); - document.querySelectorAll('button').forEach(function(e){ - e.removeAttribute('disabled'); - }); + + /* querySelectorAll() proxy */ + const EAll = function(/*[element=document,] cssSelector*/){ + return (arguments.length>1 ? arguments[0] : document) + .querySelectorAll(arguments[arguments.length-1]); + }; + /* querySelector() proxy */ + const E = function(/*[element=document,] cssSelector*/){ + return (arguments.length>1 ? arguments[0] : document) + .querySelector(arguments[arguments.length-1]); + }; + + // Unhide all elements which start out hidden + EAll('.initially-hidden').forEach((e)=>e.classList.remove('initially-hidden')); + + const taInput = E('#input'); + const btnClearIn = E('#btn-clear'); btnClearIn.addEventListener('click',function(){ taInput.value = ''; },false); @@ -30,8 +42,8 @@ window.Module.onRuntimeInitialized = function(){ btnRun.click(); } }, false); - const taOutput = document.querySelector('#output'); - const btnClearOut = document.querySelector('#btn-clear-output'); + const taOutput = E('#output'); + const btnClearOut = E('#btn-clear-output'); btnClearOut.addEventListener('click',function(){ taOutput.value = ''; },false); @@ -47,7 +59,7 @@ window.Module.onRuntimeInitialized = function(){ if(Module.config.autoClearOutput) taOutput.value=''; f._(sql); }; - const btnRun = document.querySelector('#btn-run'); + const btnRun = E('#btn-run'); btnRun.addEventListener('click',function(){ const sql = taInput.value.trim(); if(sql){ @@ -55,20 +67,20 @@ window.Module.onRuntimeInitialized = function(){ } },false); - document.querySelector('#opt-cb-sbs') + E('#opt-cb-sbs') .addEventListener('change', function(){ - document.querySelector('#main-wrapper').classList[ + E('#main-wrapper').classList[ this.checked ? 'add' : 'remove' ]('side-by-side'); }, false); - document.querySelector('#btn-notes-caveats') + E('#btn-notes-caveats') .addEventListener('click', function(){ - document.querySelector('#notes-caveats').remove(); + E('#notes-caveats').remove(); }, false); /* For each checkbox with data-config=X, set up a binding to Module.config[X]. */ - document.querySelectorAll('input[type=checkbox][data-config]') + EAll('input[type=checkbox][data-config]') .forEach(function(e){ e.checked = !!Module.config[e.dataset.config]; e.addEventListener('change', function(){ @@ -79,7 +91,7 @@ window.Module.onRuntimeInitialized = function(){ /* For each button with data-cmd=X, map a click handler which calls doExec(X). */ const cmdClick = function(){doExec(this.dataset.cmd);}; - document.querySelectorAll('button[data-cmd]').forEach( + EAll('button[data-cmd]').forEach( e => e.addEventListener('click', cmdClick, false) ); diff --git a/ext/fiddle/module-pre.js b/ext/fiddle/module-pre.js index 23cb7983c6..67c6f5a9a0 100644 --- a/ext/fiddle/module-pre.js +++ b/ext/fiddle/module-pre.js @@ -64,12 +64,11 @@ progressElement.hidden = false; spinnerElement.hidden = false; } else { - progressElement.value = null; - progressElement.max = null; - progressElement.hidden = true; - if(!text) spinnerElement.hidden = true; + progressElement.remove(); + if(!text) spinnerElement.remove(); } - statusElement.innerHTML = text; + if(text) statusElement.innerText = text; + else statusElement.remove(); }, totalDependencies: 0, monitorRunDependencies: function(left) { diff --git a/manifest b/manifest index 33c3e8de43..eb4115d318 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Split\sthe\sfiddle\sJS\scode\sinto\sseparate\spre-/post-init\sfiles\sto\ssimplify\sediting.\semcc\swill\scombine\sthese\sinto\sthe\sfinal\sfiddle.js,\sso\sthe\snumber\sof\soutput\sdeliverables\sdoes\snot\schange. -D 2022-05-19T09:55:14.804 +C #if'd\sout\sthe\s'.log'\scommand\sin\sWASM\sbuilds.\sCleaned\sup\sthe\suser-visible\sparts\sof\sthe\sWASM\smodule\sinitialization. +D 2022-05-19T10:24:50.097 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -56,10 +56,10 @@ F ext/expert/sqlite3expert.c 6ca30d73b9ed75bd56d6e0d7f2c962d2affaa72c505458619d0 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/fiddle/Makefile ea647919e6ac4b50edde1490f60ee87e8ccd75141e4aa650718c6f28eb323bbc -F ext/fiddle/fiddle.in.html 69f8eeb8dc22cbaca2c890ed689d65dd8ad00e896b1a29caae8a22893fc51d8e +F ext/fiddle/fiddle.in.html fc5bb8e6c13cac9880dfb41eceed3ff031d51d2a73bf66da51e5cc171e1ee28c F ext/fiddle/index.md d9c1c308d8074341bc3b11d1d39073cd77754cb3ca9aeb949f23fdd8323d81cf -F ext/fiddle/module-post.js 8d62f2199cb367267b7799f259c43673f43578f788f30e106a17b2eccbc8a918 -F ext/fiddle/module-pre.js 31661050c461fa05fbaa564e5369795eed8957458ea81fd2038157d852ff93c8 +F ext/fiddle/module-post.js 5d0eafba848a3e129c46ab1e1af99dcc7e8b7fc207f86ad05c5f45079cca9b6d +F ext/fiddle/module-pre.js 7c093908bd7768c96fb812e5fc1f15073ab129527fa2124a6f3e5076455761ed F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b F ext/fts1/ft_hash.h 06df7bba40dadd19597aa400a875dbc2fed705ea @@ -559,7 +559,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c F src/resolve.c a4eb3c617027fd049b07432f3b942ea7151fa793a332a11a7d0f58c9539e104f F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c 74060a09f66c0c056f3c61627e22cb484af0bbfa29d7d14dcf17c684742c15de -F src/shell.c.in ce99ca3e14211ca8d3eb82ba012504422ef42a59e4abd38c9a08a9638aee8694 +F src/shell.c.in cc3e19b2d2eefbadc4139b016c097d6478eae01d14eca993368ee5cff8820fff F src/sqlite.h.in d15c307939039086adca159dd340a94b79b69827e74c6d661f343eeeaefba896 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d @@ -1959,8 +1959,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 1a1e4e7fdbd0ec61218c3a311164086316d825181f3fc1c1ec235b63488746ef -R 845cc95de5a1a485fbec7d915e3ef826 +P d3d8ea011868bcfa11bb3fe2db78eea6e77ac1005534d9c091f9a81e03f0a7e6 +R d7744af6398d083bf2a1bc37b40874d9 U stephan -Z 439fa3de2a51242095eb61aca5099555 +Z 4e1f89c6494ab0a52794383c827e3145 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 565d54b618..e83553ea74 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d3d8ea011868bcfa11bb3fe2db78eea6e77ac1005534d9c091f9a81e03f0a7e6 \ No newline at end of file +b5fa12f824690c1022e4d69b0f5c3949324b311557a7412810741731db7e2cce \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index c892a25bef..9a0859293b 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4353,7 +4353,9 @@ static const char *(azHelp[]) = { #if !defined(SQLITE_OMIT_LOAD_EXTENSION) && !defined(SQLITE_SHELL_WASM_MODE) ".load FILE ?ENTRY? Load an extension library", #endif +#ifndef SQLITE_SHELL_WASM_MODE ".log FILE|off Turn logging on or off. FILE can be stderr/stdout", +#endif ".mode MODE ?OPTIONS? Set output mode", " MODE is one of:", " ascii Columns/rows delimited by 0x1F and 0x1E", @@ -9386,6 +9388,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else #endif +#ifndef SQLITE_SHELL_WASM_MODE if( c=='l' && strncmp(azArg[0], "log", n)==0 ){ failIfSafeMode(p, "cannot run .log in safe mode"); if( nArg!=2 ){ @@ -9397,6 +9400,7 @@ static int do_meta_command(char *zLine, ShellState *p){ p->pLog = output_file_open(zFile, 0); } }else +#endif if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){ const char *zMode = 0; -- 2.47.2