]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add ext/wasm/module-symbols.html. Adjacent minor JS touchups.
authorstephan <stephan@noemail.net>
Fri, 28 Oct 2022 11:40:46 +0000 (11:40 +0000)
committerstephan <stephan@noemail.net>
Fri, 28 Oct 2022 11:40:46 +0000 (11:40 +0000)
FossilOrigin-Name: 24f12e681e06e3b71a6ac9c82255fe0270953a74c711405841f7e385eeafe874

ext/wasm/api/sqlite3-api-glue.js
ext/wasm/api/sqlite3-api-prologue.js
ext/wasm/common/SqliteTestUtil.js
ext/wasm/index.html
ext/wasm/module-symbols.html [new file with mode: 0644]
manifest
manifest.uuid

index d096af1c89b98c510f4361bb3d77439e07a4a9f2..16840e79f34d937f2328baa8078bb5f86612d5b8 100644 (file)
@@ -104,6 +104,10 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
         : fI64Disabled(e[0]);
     }
 
+    /* There's no(?) need to expose bindingSignatures to clients,
+       implicitly making it part of the public interface. */
+    delete wasm.bindingSignatures;
+
     if(wasm.exports.sqlite3_wasm_db_error){
       util.sqlite3_wasm_db_error = capi.wasm.xWrap(
         'sqlite3_wasm_db_error', 'int', 'sqlite3*', 'int', 'string'
@@ -115,20 +119,20 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
       };
     }
 
-    /**
-       When registering a VFS and its related components it may be
-       necessary to ensure that JS keeps a reference to them to keep
-       them from getting garbage collected. Simply pass each such value
-       to this function and a reference will be held to it for the life
-       of the app.
-    */
-    capi.sqlite3_vfs_register.addReference = function f(...args){
-      if(!f._) f._ = [];
-      f._.push(...args);
-    };
-
   }/*xWrap() bindings*/;
 
+  /**
+     When registering a VFS and its related components it may be
+     necessary to ensure that JS keeps a reference to them to keep
+     them from getting garbage collected. Simply pass each such value
+     to this function and a reference will be held to it for the life
+     of the app.
+  */
+  capi.sqlite3_vfs_register.addReference = function f(...args){
+    if(!f._) f._ = [];
+    f._.push(...args);
+  };
+
   /**
      Internal helper to assist in validating call argument counts in
      the hand-written sqlite3_xyz() wrappers. We do this only for
index 96b2fa019de0bb07fee4e343225e996efef36281..05305db22a406850d68a77461910dd40b75195be 100644 (file)
@@ -1042,25 +1042,24 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
       //set: wasm.exports.sqlite3_wasm_pstack_restore
     },
     /**
-      Resolves to the total number of bytes available in the pstack,
-      including any space which is currently allocated. This value is
-      a compile-time constant.
+       sqlite3.wasm.pstack.quota to the total number of bytes
+       available in the pstack, including any space which is currently
+       allocated. This value is a compile-time constant.
     */
     quota: {
       configurable: false, iterable: true, writeable: false,
       get: wasm.exports.sqlite3_wasm_pstack_quota
-    }    
+    },
+    /**
+       sqlite3.wasm.pstack.remaining resolves to the amount of space
+       remaining in the pstack.
+    */
+    remaining: {
+      configurable: false, iterable: true, writeable: false,
+      get: wasm.exports.sqlite3_wasm_pstack_remaining
+    }
   })/*wasm.pstack properties*/;
 
-  /**
-     sqlite3.wasm.pstack.remaining resolves to the amount of
-     space remaining in the pstack.
-  */
-  Object.defineProperty(wasm.pstack, 'remaining', {
-    configurable: false, iterable: true, writeable: false,
-    get: wasm.exports.sqlite3_wasm_pstack_remaining
-  });
-
   /**
      An Error subclass specifically for reporting DB-level errors and
      enabling clients to unambiguously identify such exceptions.
index 08688fd487211c0f68ec639be69d458a6fe82f2f..5ed423785bcaa355854dfec00b58200f3e801703 100644 (file)
     ],
     //onRuntimeInitialized: function(){},
     /* Proxy for C-side stdout output. */
-    print: function(){
-      console.log.apply(console, Array.prototype.slice.call(arguments));
-    },
+    print: (...args)=>{console.log(...args)},
     /* Proxy for C-side stderr output. */
-    printErr: function(){
-      console.error.apply(console, Array.prototype.slice.call(arguments));
-    },
+    printErr: (...args)=>{console.error(...args)},
     /**
        Called by the Emscripten module init bits to report loading
        progress. It gets passed an empty argument when loading is done
index 7df2c601f519ec069b6f32003d74e3dff8b29d74..044cd1360d624e5bf0df93eafaacc1e7ca50afb0 100644 (file)
@@ -82,6 +82,9 @@
         </li>
         <li>The obligatory "misc." category...
           <ul>
+            <li><a href='module-symbols.html'>module-symbols</a> gives
+              a high-level overview of the symbols exposed by the JS
+              module.</li>
             <li><a href='batch-runner.html'>batch-runner</a>: runs batches of SQL exported from speedtest1.</li>
             <!--li><a href='scratchpad-wasmfs-main.html'>scratchpad-wasmfs-main</a>:
               experimenting with WASMFS/OPFS-based persistence. Maintenance
diff --git a/ext/wasm/module-symbols.html b/ext/wasm/module-symbols.html
new file mode 100644 (file)
index 0000000..e77866a
--- /dev/null
@@ -0,0 +1,307 @@
+<!doctype html>
+<html lang="en-us">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
+    <script src="jswasm/sqlite3.js"></script>
+    <title>sqlite3 Module Symbols</title>
+  </head>
+  <body>
+<div class="fossil-doc" data-title="sqlite3 Module Symbols">
+  <style>
+    .pseudolist {
+        column-count: auto;
+        column-width: 20rem;
+        column-gap: 1.5em;
+        width: 95%;
+        margin: auto;
+    }
+    .pseudolist > span {
+        font-family: monospace;
+        margin: 0.25em 0;
+        display: block;
+    }
+    .pseudolist.wrap-anywhere {
+        overflow-wrap: anywhere;
+    }
+    .warning { color: firebrick }
+    .error { color: firebrick; background-color: yellow}
+    .hidden, .initially-hidden {
+        position: absolute !important;
+        opacity: 0 !important;
+        pointer-events: none !important;
+        display: none !important;
+    }
+    h1::before, h2::before, h3::before, h4::before {
+        /* Remove automatic numbering */
+        content: "" !important;
+        background-color: transparent !important;
+        margin: 0 !important;
+        border: 0 !important;
+        padding: 0 !important;
+    }
+    .func-wasm {
+        
+    }
+    .func-wasm::after {
+        content: "*";
+        color: blue;
+    }
+  </style>
+  <p id='module-load-status'><strong>Loading WASM module...</strong>
+    If this takes "a long time" it may have failed and the browser's
+    dev console may contain hints as to why.
+  </p>
+
+  <p>
+    This page lists the SQLite3 APIs exported
+    by <code>sqlite3.wasm</code> and exposed to clients
+    by <code>sqlite3.js</code>. These lists are generated dynamically
+    by loading the JS/WASM module and introspecting it, with the following
+    caveats:
+  </p>
+
+  <ul>
+    <li>Some APIs are explicitly filtered out of these lists because
+      they are strictly for internal use within the JS/WASM APIs and
+      its own test code.
+    </li>
+    <li>This page runs in the main UI thread so cannot see features
+      which are only available in a Worker thread. If this page were
+      to function via a Worker, it would not be able to see
+      functionality only available in the main thread. Starting a
+      Worker here to fetch those symbols requires loading a second
+      copy of the sqlite3 WASM module and JS code.
+    </li>
+  </ul>
+
+  <div class='initially-hidden'>
+
+    <p>This page exposes a global symbol named <code>sqlite3</code>
+      which can be inspected using the browser's dev tools.
+    </p>
+
+    <p>Jump to...</p>
+    <ul>
+      <li><a href='#sqlite3-namespace'><code>sqlite3</code> namespace</a></li>
+      <li><a href='#sqlite3-version'><code>sqlite3.version</code></a></li>
+      <li><a href='#sqlite3-functions'><code>sqlite3_...()</code> functions</a></li>
+      <li><a href='#sqlite3-constants'><code>SQLITE_...</code> functions</a></li>
+      <li><a href='#sqlite3.oo1'><code>sqlite3.oo1</code></a>
+        <!--ul>
+          <li><a href='#sqlite3.oo1.DB'><code>sqlite3.oo1.DB</code></a></li>
+          <li><a href='#sqlite3.oo1.Stmt'><code>sqlite3.oo1.Stmt</code></a></li>
+        </ul-->
+      </li>
+      <li><a href='#sqlite3.capi.wasm'><code>sqlite3.capi.wasm</code></a></li>
+      <li><a href='#sqlite3.capi.wasm.pstack'><code>sqlite3.capi.wasm.pstack</code></a></li>
+      <li><a href='#compile-options'>Compilation options used in this module build.</a></li>
+    </ul>
+
+    <a id="sqlite3-namespace"></a>
+    <h1><code>sqlite3</code> Namespace</h1>
+    <p>
+      The <code>sqlite3</code> namespace object exposes the following...
+    </p>
+    <div id='list-namespace' class='pseudolist'></div>
+
+    <a id="sqlite3-version"></a>
+    <h1><code>sqlite3.version</code></h1>
+    <p>
+      The <code>sqlite3.version</code> object exposes the following...
+    </p>
+    <div id='list-version' class='pseudolist wrap-anywhere'></div>
+    
+    <a id="sqlite3-functions"></a>
+    <h1><code>sqlite3_...()</code> Function List</h1>
+    
+    <p>The <code>sqlite3.capi</code> object exposes the following
+      <a href='https://sqlite.org/c3ref/funclist.html'><code>sqlite3_...()</code>
+        functions</a>...
+    </p>
+    <div id='list-functions' class='pseudolist'></div>
+    <p>
+      <code class='func-wasm'></code> = function is specific to the JS/WASM
+      bindings, not part of the C API.
+    </p>
+
+    <a id="sqlite3-constants"></a>
+    <h1><code>SQLITE_...</code> Constants</h1>
+
+    <p>The <code>sqlite3.capi</code> object exposes the following
+      <a href='https://sqlite.org/c3ref/constlist.html'><code>SQLITE_...</code>
+        constants</a>...
+    </p>
+    <div id='list-constants' class='pseudolist'></div>
+
+    <a id="sqlite3.oo1"></a>
+    <h1><code>sqlite3.oo1</code></h1>
+    <p>
+      The <code>sqlite3.oo1</code> object exposes the following...
+    </p>
+    <div id='list-oo1' class='pseudolist'></div>
+
+    <a id="sqlite3.capi.wasm"></a>
+    <h1><code>sqlite3.capi.wasm</code></h1>
+    <p>
+      The <code>sqlite3.capi.wasm</code> object exposes the
+      following...
+    </p>
+    <div id='list-wasm' class='pseudolist'></div>
+
+    <a id="sqlite3.capi.wasm.pstack"></a>
+    <h1><code>sqlite3.capi.wasm.pstack</code></h1>
+    <p>
+      The <code>sqlite3.capi.wasm.pstack</code> object exposes the
+      following...
+    </p>
+    <div id='list-wasm-pstack' class='pseudolist'></div>
+
+    <a id="compile-options"></a>
+    <h1>Compilation Options</h1>
+    <p>
+      Compilation options used in this build of <code>sqlite3.wasm</code>...
+    </p>
+    <div id='list-compile-options' class='pseudolist'></div>
+
+  </div><!-- .initially-hidden -->
+  <script>(async function(){
+    const eNew = (tag,parent)=>{
+        const e = document.createElement(tag);
+        if(parent) parent.appendChild(e);
+        return e;
+    };
+    const eLi = (label,parent)=>{
+        const e = eNew('span',parent);
+        e.innerText = label;
+        return e;
+    };
+    const E = (sel)=>document.querySelector(sel);
+    const EAll = (sel)=>document.querySelectorAll(sel);
+    const eFuncs = E('#list-functions'),
+          eConst = E('#list-constants');
+    const renderConst = function(name){
+        eLi(name, eConst);
+    };
+    const renderFunc = function(name){
+        let lbl = name+'()';
+        const e = eLi(lbl, eFuncs);;
+        if(name.startsWith('sqlite3_js')
+           || name.startsWith('sqlite3_wasm')){
+            e.classList.add('func-wasm');
+        }
+    };
+    const renderGeneric = function(name,value,eParent){
+        let lbl;
+        if(value instanceof Function) lbl = name+'()';
+        else{
+            switch(typeof value){
+                case 'number': case 'boolean': case 'string':
+                    lbl = name+' = '+JSON.stringify(value);
+                    break;
+                default:
+                    lbl = name + ' ['+(typeof value)+']';
+            }
+        }
+        const e = eLi(lbl, eParent);
+        if(name.startsWith('sqlite3_wasm')){
+            e.classList.add('func-wasm');
+        }
+    };
+    const renderIt = async function(sqlite3){
+        self.sqlite3 = sqlite3;
+        console.warn("sqlite3 installed as global symbol self.sqlite3.");
+        const capi = sqlite3.capi;
+        const cmpIcase = (a,b)=>a.toLowerCase().localeCompare(b.toLowerCase());
+        const renderX = function(tgtElem, container, keys){
+            for(const k of keys.sort(cmpIcase)){
+                renderGeneric(k, container[k], tgtElem);
+            }
+        };
+        
+        const excludeNamespace = ['scriptInfo','StructBinder'];
+        renderX(
+            E('#list-namespace'), sqlite3,
+            Object.keys(sqlite3)
+                .filter((v)=>excludeNamespace.indexOf(v)<0)
+        );
+        renderX(
+            E('#list-version'), sqlite3.version,
+            Object.keys(sqlite3.version)
+        );
+
+        /* sqlite3_...() and SQLITE_... */
+        const lists = {c: [], f: []};
+        for(const [k,v] of Object.entries(capi)){
+            if(k.startsWith('SQLITE_')) lists.c.push(k);
+            else if(k.startsWith('sqlite3_')) lists.f.push(k);
+        }
+        const excludeCapi = [
+            'sqlite3_wasmfs_filename_is_persistent',
+            'sqlite3_wasmfs_opfs_dir'
+        ];
+        lists.c.sort().forEach(renderConst);
+        lists.f
+            .filter((v)=>excludeCapi.indexOf(v)<0)
+            .sort()
+            .forEach(renderFunc);
+        lists.c = lists.f = null;
+
+        renderX(E('#list-oo1'), sqlite3.oo1,
+                Object.keys(sqlite3.oo1) );
+
+        const excludeWasm = ['ctype'];
+        renderX(E('#list-wasm'),
+                capi.wasm,
+                Object.keys(capi.wasm)
+                .filter((v)=>{
+                    return !v.startsWith('sqlite3_wasm_')
+                        && excludeWasm.indexOf(v)<0;
+                }));
+        const psKeys = Object.keys(capi.wasm.pstack);
+        psKeys.push('pointer','quota','remaining');
+        renderX(E('#list-wasm-pstack'), capi.wasm.pstack, psKeys);
+
+        const cou = capi.wasm.compileOptionUsed();
+        renderX(E('#list-compile-options'), cou, Object.keys(cou));
+    };
+
+    /**
+       This is a module object for use with the emscripten-installed
+       sqlite3InitModule() factory function.
+    */
+    const myModule = {
+        print: (...args)=>{console.log(...args)},
+        printErr: (...args)=>{console.error(...args)},
+        /**
+           Called by the Emscripten module init bits to report loading
+           progress. It gets passed an empty argument when loading is done
+           (after onRuntimeInitialized() and any this.postRun callbacks
+           have been run).
+        */
+        setStatus: function f(text){
+            if(!f.last){
+                f.last = { text: '', step: 0 };
+                f.ui = {
+                    status: E('#module-load-status')
+                };
+            }
+            if(text === f.last.text) return;
+            f.last.text = text;
+            ++f.last.step;
+            if(text) {
+                f.ui.status.classList.remove('hidden');
+                f.ui.status.innerText = text;
+            }else{
+                f.ui.status.classList.add('hidden');
+                EAll('.initially-hidden').forEach((e)=>{
+                    e.classList.remove('initially-hidden');
+                });
+            }
+        }
+    }/*myModule*/;
+    self.sqlite3InitModule(myModule).then(renderIt);
+})();</script>
+</div><!-- .fossil-doc -->
+</body></html>
index 91bcc1f863a3116dce90c44dc3b49a27979d3183..d8b26a700f454d80348d7e1562e524e10608ff59 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\ssqlite3.oo1\sAPI\sreorg\sprompted\sby\sdocumenting.
-D 2022-10-28T10:36:18.816
+C Add\sext/wasm/module-symbols.html.\sAdjacent\sminor\sJS\stouchups.
+D 2022-10-28T11:40:46.460
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -499,10 +499,10 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
 F ext/wasm/api/post-js-header.js 2e5c886398013ba2af88028ecbced1e4b22dc96a86467f1ecc5ba9e64ef90a8b
 F ext/wasm/api/pre-js.js 151e0616614a49f3db19ed544fa13b38c87c108959fbcd4029ea8399a562d94f
 F ext/wasm/api/sqlite3-api-cleanup.js 4d07a7524dc9b7b050acfde57163e839243ad2383bd7ee0de0178b1b3e988588
-F ext/wasm/api/sqlite3-api-glue.js f024dc2f41418ad203edf1228d7cf7934249c11ffcbb65d21f9bb69333d63d55
+F ext/wasm/api/sqlite3-api-glue.js c47e86a1b91917cf37de8386e4a94669612565df7f35a5ad7e04028330e5db54
 F ext/wasm/api/sqlite3-api-oo1.js 9ae79193d05712f9883a3e1a1a54f0620354aeb85fef5850fad5e4a9437a5b4d
 F ext/wasm/api/sqlite3-api-opfs.js a4316c04b2eb6ae69fc9a8b33f1d0ff22a0398665d98e6504ee13221cbf5cc5b
-F ext/wasm/api/sqlite3-api-prologue.js 7f7c2f516d3ed39b3761ad8a6de86dc703b6c2678de6d078defcdc52df48cc27
+F ext/wasm/api/sqlite3-api-prologue.js 968c7204ff7357b4565e166c7f39600132b08e4050094fa4d8c014a12a5bdd3e
 F ext/wasm/api/sqlite3-api-worker1.js b2d650514ccc75f80dff666fd3ee68dc8fb4137bcd01caac2c62ff93a7ebf638
 F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
 F ext/wasm/api/sqlite3-opfs-async-proxy.js f04cb1eb483c92bc61fe02749f7afcf17ec803968171aedd7d96faf428c26bcb
@@ -512,7 +512,7 @@ F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52af
 F ext/wasm/api/sqlite3-worker1.js dbe54b69c1520a2d25eae148cd2750ded2dd7f219ea4ee46f83e0a851dca5974
 F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d0cef96fbbe4c8
 F ext/wasm/batch-runner.js 5bae81684728b6be157d1f92b39824153f0fd019345b39f2ab8930f7ee2a57d8
-F ext/wasm/common/SqliteTestUtil.js 647bf014bd30bdd870a7e9001e251d12fc1c9ec9ce176a1004b838a4b33c5c05
+F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
 F ext/wasm/common/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
 F ext/wasm/common/testing.css 739b58c44511f642f16f57b701c84dc9ee412d8bc47b3d8a99d947babfa69d9d
 F ext/wasm/common/whwasmutil.js 77930367c2a65cf6fd6f99ad3644ede33e4d20466f5e506eb87b8d101a0a7655
@@ -532,9 +532,10 @@ F ext/wasm/fiddle/fiddle-worker.js 41b9796d689fabbef1ad9447496d14645eeb4101b534e
 F ext/wasm/fiddle/fiddle.js 974b995119ac443685d7d94d3b3c58c6a36540e9eb3fed7069d5653284071715
 F ext/wasm/fiddle/index.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2
 F ext/wasm/index-dist.html cb0da16cba0f21cda2c25724c5869102d48eb0af04446acd3cd0ca031f80ed19
-F ext/wasm/index.html 6ac073d45d7602e1d8a5b493ce4204dc4a6c5594fdeeb12dec38c4e36ce473ad
+F ext/wasm/index.html ce6a68a75532b47e3c0adb83381a06d15de8c0ac0331fb7bf31d33f8e7c77dc4
 F ext/wasm/jaccwabyt/jaccwabyt.js 0d7f32817456a0f3937fcfd934afeb32154ca33580ab264dab6c285e6dbbd215
 F ext/wasm/jaccwabyt/jaccwabyt.md 9aa6951b529a8b29f578ec8f0355713c39584c92cf1708f63ba0cf917cb5b68e
+F ext/wasm/module-symbols.html e521cf07f8d136748e60d91e49b7b956e8bd56c58fc52acbe5ad58eaeaacf719
 F ext/wasm/scratchpad-wasmfs-main.html 20cf6f1a8f368e70d01e8c17200e3eaa90f1c8e1029186d836d14b83845fbe06
 F ext/wasm/scratchpad-wasmfs-main.js 1841c124a58e3f9e7ee580a0868d6e1834c5a01dbb47c8fdd565eda5db362437
 F ext/wasm/speedtest1-wasmfs.html bc28eb29b69a73864b8d7aae428448f8b7e1de81d8bfb9bba99541322054dbd0
@@ -2052,8 +2053,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 58c2e49279c8f77f006b0c2ce351776bc711633f9c1a39c7a37969838d49ec0b
-R dab7258db99e87600cc7587ad7416655
+P 55237924ca363c5a3e0f8c82620eb6626a98311615866197375a86876b9da3a1
+R d51316afe79c3d740526e1647073065f
 U stephan
-Z 4f2c2ebef52736f5acf8b48e5d4ac065
+Z 0ba750ccdbd0f150e9be1a1ecd5962f2
 # Remove this line to create a well-formed Fossil manifest.
index 3eabfb83cab29d35f55ca14e99b513c19b8e6812..c490bd1e4c1c90579d5d0464ea932a19b81c2f6a 100644 (file)
@@ -1 +1 @@
-55237924ca363c5a3e0f8c82620eb6626a98311615866197375a86876b9da3a1
\ No newline at end of file
+24f12e681e06e3b71a6ac9c82255fe0270953a74c711405841f7e385eeafe874
\ No newline at end of file