]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further minor cleanups and docs in the fiddle app and worker. fiddle-local-db
authorstephan <stephan@noemail.net>
Wed, 25 May 2022 04:20:08 +0000 (04:20 +0000)
committerstephan <stephan@noemail.net>
Wed, 25 May 2022 04:20:08 +0000 (04:20 +0000)
FossilOrigin-Name: 199e01799dfa48e3fddafb7f2ae5360604150a44186d5c5a977e158ad8e7e657

ext/fiddle/fiddle-worker.js
ext/fiddle/fiddle.js
ext/fiddle/testing1.html
manifest
manifest.uuid

index 3707e85a844a8d7695d57deb8a4f6b776e46d82a..5c7f7e4fbf4f6fbe08b7f28587580ca6cd30f38e 100644 (file)
         });
     };
 
+    const stdout = function(){wMsg('stdout', Array.prototype.slice.call(arguments));};
+    const stderr = function(){wMsg('stderr', Array.prototype.slice.call(arguments));};
+
     self.onerror = function(/*message, source, lineno, colno, error*/) {
         const err = arguments[4];
         if(err && 'ExitStatus'==err.name){
             /* This is relevant for the sqlite3 shell binding but not the
                lower-level binding. */
-            fiddleModule._isDead = true;
-            fiddleModule.printErr("FATAL ERROR:", err.message);
-            fiddleModule.printErr("Restarting the app requires reloading the page.");
+            fiddleModule.isDead = true;
+            stderr("FATAL ERROR:", err.message);
+            stderr("Restarting the app requires reloading the page.");
             wMsg('error', err);
         }
         fiddleModule.setStatus('Exception thrown, see JavaScript console');
         */
         exec: function f(sql){
             if(!f._) f._ = fiddleModule.cwrap('fiddle_exec', null, ['string']);
-            if(fiddleModule._isDead){
+            if(fiddleModule.isDead){
                 wMsg('stderr', "shell module has exit()ed. Cannot run SQL.");
                 return;
             }
        emscripten module for use with build mode -sMODULARIZE.
     */
     const fiddleModule = {
-        /* ^^^ cannot declare that const because fiddle-module.js
-           (auto-generated) includes a decl for it and runs in this scope. */
-        preRun: [],
-        postRun: [
-            /*function(M) {
-                console.debug("FS=",M.FS);
-                wMsg('fiddle-ready');
-            }*/
-        ],
-        print: function(text){wMsg('stdout', Array.prototype.slice.call(arguments));},
-        printErr: function(text){wMsg('stderr', Array.prototype.slice.call(arguments));},
-        onRuntimeInitialized: function(M) {
-            //console.debug("M=",M);
-            wMsg('fiddle-ready');
-        },
+        print: stdout,
+        printErr: stderr,
         /**
-           Intercepts status updates from the Module object and fires
-           worker events with a type of 'status' and a payload of:
+           Intercepts status updates from the emscripting module init
+           and fires worker events with a type of 'status' and a
+           payload of:
 
            {
            text: string | null, // null at end of load process
                 type:'status',
                 data:{step: ++f.last.step, text: text||null}
             });
-        },
-        totalDependencies: 0,
-        monitorRunDependencies: function(left) {
-            this.totalDependencies = Math.max(this.totalDependencies, left);
-            this.setStatus(left
-                           ? ('Preparing... (' + (this.totalDependencies-left)
-                              + '/' + this.totalDependencies + ')')
-                           : 'All downloads complete.');
         }
     };
 
-
-    importScripts('fiddle-module.js')
-    /* loads the wasm module and installs our module init function,
-       initFiddleModule(). */;
+    importScripts('fiddle-module.js');
     /**
        initFiddleModule() is installed via fiddle-module.js due to
        building with:
 
        emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initFiddleModule
     */
-    initFiddleModule(fiddleModule);
+    initFiddleModule(fiddleModule).then(function(thisModule){
+        wMsg('fiddle-ready');
+    });
 })();
index 95f57c15a7561b390f9dd9f3587af4912f79f0e3..ec2cc4a8ef504cb9a7664c6fbcdcc28853da381b 100644 (file)
@@ -86,6 +86,8 @@
             }
         },
         _msgMap: {},
+        /** Adds a worker message handler for messages of the given
+            type. */
         addMsgHandler: function f(type,callback){
             if(Array.isArray(type)){
                 type.forEach((t)=>this.addMsgHandler(t, callback));
@@ -96,6 +98,7 @@
              : (this._msgMap[type] = [])).push(callback);
             return this;
         },
+        /** Given a worker message, runs all handlers for msg.type. */
         runMsgHandlers: function(msg){
             const list = (this._msgMap.hasOwnProperty(msg.type)
                           ? this._msgMap[msg.type] : false);
             list.forEach((f)=>f(msg));
             return true;
         },
+        /** Removes all message handlers for the given message type. */
         clearMsgHandlers: function(type){
             delete this._msgMap[type];
             return this;
                     SF.echo("Exported (possibly auto-downloaded):",ev.filename);
                     window.URL.revokeObjectURL(a.href);
                     a.remove();
-                },0);
+                },500);
             });
             a.click();
         });
 
+        /**
+           Handle load/import of an external db file.
+        */
         E('#load-db').addEventListener('change',function(){
             const f = this.files[0];
             const r = new FileReader();
             });
             r.addEventListener('error',function(){
                 that.removeAttribute('disabled');
-                SF.echo("Loading",f.name,"failed for unknown reason.");
+                SF.echo("Loading",f.name,"failed for unknown reasons.");
             });
             r.addEventListener('abort',function(){
                 that.removeAttribute('disabled');
         debounce.$defaultDelay = 500 /*arbitrary*/;
 
         const ForceResizeKludge = (function(){
-            /* Workaround for Safari mayhem regarding use of vh CSS units....
-               We cannot use vh units to set the terminal area size because
-               Safari chokes on that, so we calculate that height here. Larger
-               than ~95% is too big for Firefox on Android, causing the input
-               area to move off-screen. */
+            /* Workaround for Safari mayhem regarding use of vh CSS
+               units....  We cannot use vh units to set the main view
+               size because Safari chokes on that, so we calculate
+               that height here. Larger than ~95% is too big for
+               Firefox on Android, causing the input area to move
+               off-screen. */
             const bcl = document.body.classList;
             const appViews = EAll('.app-view');
             const resized = function f(){
                 var ht;
                 var extra = 0;
                 const elemsToCount = [
+                    /* Elements which we need to always count in the
+                       visible body size. */
                     E('body > header'),
                     E('body > footer')
                 ];
index 08a0009c60a3415f92e5093e7916aab162648106..f29fb3ce2ce0c94ad72c31523cd69b1cf60851ae 100644 (file)
@@ -25,8 +25,8 @@
       <progress value="0" max="100" id="module-progress" hidden='1'></progress>  
     </div><!-- /emscripten bits -->
     <div>Everything on this page happens in the dev console.</div>
-    <script src="testing-common.js"></script>
     <script src="SqliteTestUtil.js"></script>
+    <script src="testing-common.js"></script>
     <script src="testing1.js"></script>
     <script src="sqlite3.js"></script>
   </body>
index 1b66446908d811ba411c2fa1b8415fc1a77e59fc..ff64e2086457f4ba610b0c165a805ef6376aa185 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C fiddle:\srefactored\sso\sthat\sit\sno\slonger\sexposes\sany\sglobal\ssymbols.\sDoing\sso\swith\sthe\smain\ssqlite3.api\smodule\swill\sbe\smuch\stricker.
-D 2022-05-25T03:08:22.772
+C Further\sminor\scleanups\sand\sdocs\sin\sthe\sfiddle\sapp\sand\sworker.
+D 2022-05-25T04:20:08.617
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -61,14 +61,14 @@ F ext/fiddle/EXPORTED_RUNTIME_METHODS 4808171d24c601e31d2ea4eb131180e25194d8e78a
 F ext/fiddle/Makefile 2608fe0c56fa8f9cdf17e28d2be6def550a2fe987db5f7fc06d0210bfc868258
 F ext/fiddle/SqliteTestUtil.js e3094833660a6ddd40766b802901b5861b37f0b89c6c577ee0ce4c9d36399e61
 F ext/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
-F ext/fiddle/fiddle-worker.js ecfdf9d842f895046338469b30101f312866ca5dc3d3e002ae88b1256898094c
+F ext/fiddle/fiddle-worker.js 6000da12965319bed53d546f87885a6717a0cd8de0b4832edde7a95e63d1f33e
 F ext/fiddle/fiddle.html 70796dc8a867448b41bc7e2c5fd6b1865ed8010b3abe22ba0678e8915c062e9a
-F ext/fiddle/fiddle.js 931562304cf918b4b88c7095735e8b91896194c918a15afcfba0e5a31e273d63
+F ext/fiddle/fiddle.js 45f96ac7f7d6678503568dded46afaa741d841a2464519035636da0fd77aec50
 F ext/fiddle/index.md d9c1c308d8074341bc3b11d1d39073cd77754cb3ca9aeb949f23fdd8323d81cf
 F ext/fiddle/sqlite3-api.js ce08520b8117e4fbbbeb02d8d047defd4e8507d687e76d20a39f12401bad0219
 F ext/fiddle/testing-common.js a2527fd8dfb500bad9b434ae2645bb91489792115ee1e1b4b53cac4e9198992a
 F ext/fiddle/testing.css 750572dded671d2cf142bbcb27af5542522ac08db128245d0b9fe410aa1d7f2a
-F ext/fiddle/testing1.html c00236d71b7f7523b722ae2f79cb2b734e6ed4ff16102fa69974145f6e2bfc95
+F ext/fiddle/testing1.html 6c9321f68d90f942bdf51bbbfa7497113b203b85e45ef65e31d7cca3ce460366
 F ext/fiddle/testing1.js a2cee7ee12c2e1756e775125b0f9950dc5e5faeeeb4979c6d9894626d90cb5d9
 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
 F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b
@@ -1969,8 +1969,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 7c7fd34c8a05832a3973aaffe696250cb4d2a0b1646c9bfbe83970daf33cd817
-R 51490a036ccbb69f6412426a9f5e3350
+P cd227be805d0cd4b6e3c72ed0992ad3aec3db9c366909d9d82c6d3a29009c6eb
+R 89c5ae72ffcf082aa75015e7b32399c7
 U stephan
-Z 8dfdf2f1ba6221b5fdaef93177c62735
+Z 3072b7cf3dc542f70a2622c2abe8aee2
 # Remove this line to create a well-formed Fossil manifest.
index 4f5e9539defc00d0c59cfc20819232b5f6242928..42e8b351170a2c92d280a73bf2ac3b2582269641 100644 (file)
@@ -1 +1 @@
-cd227be805d0cd4b6e3c72ed0992ad3aec3db9c366909d9d82c6d3a29009c6eb
\ No newline at end of file
+199e01799dfa48e3fddafb7f2ae5360604150a44186d5c5a977e158ad8e7e657
\ No newline at end of file