]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor internal JS cleanups.
authorstephan <stephan@noemail.net>
Thu, 20 Oct 2022 04:00:05 +0000 (04:00 +0000)
committerstephan <stephan@noemail.net>
Thu, 20 Oct 2022 04:00:05 +0000 (04:00 +0000)
FossilOrigin-Name: 818ef0b5c909e733b643455278f7cc45533178f1cc6617058c00ed64fa44896a

ext/wasm/api/extern-post-js.js
ext/wasm/api/sqlite3-api-prologue.js
ext/wasm/api/sqlite3-worker1.js
manifest
manifest.uuid

index 5f5f72d4b3a86021e0db6532f083471a6271564c..768696508ea2d756f35868428a15bf6b7fab5988 100644 (file)
 
      https://github.com/emscripten-core/emscripten/issues/18071
 
-     The only current workaround is to temporarily stash this state
+     The only(?) current workaround is to temporarily stash this state
      into the global scope and delete it when sqlite3InitModule()
      is called.
   */
   const initModuleState = self.sqlite3InitModuleState = Object.assign(Object.create(null),{
     moduleScript: self?.document?.currentScript,
-    isWorker: (!self.document && self.window !== self),
+    isWorker: ('undefined' !== typeof WorkerGlobalScope),
     location: self.location,
     urlParams: new URL(self.location.href).searchParams
   });
   if(initModuleState.urlParams.has('sqlite3.dir')){
     initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/';
-  };
+  }else if(initModuleState.moduleScript){
+    const li = initModuleState.moduleScript.src.split('/');
+    li.pop();
+    initModuleState.sqlite3Dir = li.join('/') + '/';
+  }
+  //console.warn("initModuleState =",initModuleState);
 
   self.sqlite3InitModule = (...args)=>{
     //console.warn("Using replaced sqlite3InitModule()",self.location);
                    document?.currentScript?.src);
     }
   }
+  /* Replace the various module exports performed by the Emscripten
+     glue... */
+  if (typeof exports === 'object' && typeof module === 'object')
+    module.exports = sqlite3InitModule;
+  else if (typeof exports === 'object')
+    exports["sqlite3InitModule"] = sqlite3InitModule;
+  /* AMD modules get injected in a way we cannot override,
+     so we can't handle those here. */
 })();
index 3980e0ad42a4581ee8d211448b71f9ee9a128a02..f59d86506bd7129f0c1deaf89b13c39c2334dace 100644 (file)
@@ -522,7 +522,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
       isInt32, isSQLableTypedArray, isTypedArray, 
       typedArrayToString,
       isMainWindow: ()=>{
-        return self.window===self && self.document;
+        return 'undefined' === typeof WorkerGlobalScope
       }
     },
     
@@ -904,8 +904,8 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
   */
   wasm.pstack = Object.assign(Object.create(null),{
     /**
-       Sets the current ppstack position to the given pointer.
-       Results are undefined if the passed-in value did not come from
+       Sets the current pstack position to the given pointer. Results
+       are undefined if the passed-in value did not come from
        this.pointer.
     */
     restore: wasm.exports.sqlite3_wasm_pstack_restore,
@@ -927,7 +927,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
                                "bytes from the pstack.");
     },
     /**
-       Allocates n chunks, each sz bytes, as a single memory block and
+       alloc()'s n chunks, each sz bytes, as a single memory block and
        returns the addresses as an array of n element, each holding
        the address of one chunk.
 
@@ -965,7 +965,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
        will corrupt or read neighboring memory.
 
        However, when all pointers involved point to "small" data, it
-       is safe to pass a falsy value to save to memory.
+       is safe to pass a falsy value to save a tiny bit of memory.
     */
     allocPtr: (n=1,safePtrSize=true)=>{
       return 1===n
index 26c88402c145778855b9b2d1490ca9636f13d8ec..4cff68b08b64c79c788d282ca3f3951c547531f9 100644 (file)
@@ -40,6 +40,7 @@
   if(urlParams.has('sqlite3.dir')){
     theJs = urlParams.get('sqlite3.dir') + '/' + theJs;
   }
+  //console.warn("worker1 theJs =",theJs);
   importScripts(theJs);
   sqlite3InitModule().then((sqlite3)=>{
     sqlite3.capi.sqlite3_wasmfs_opfs_dir();
index a40ab24a57128c1e5a72baa19bf602ad313a372c..72f30663c2a888f6a4a6eeefe515dd25a9c2464e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sthe\sCLI,\snever\suse\sstrcmp()\sor\sstrncmp()\sdirectly.\s\sInstead\suse\nwrapper\sfunctions\scli_strcmp()\sand\scli_strncmp()\sthat\swork\scorrectly\seven\nif\sthe\sinput\sis\sa\sNULL\spointer.\n[forum:/forumpost/142b868da7560d0b|Forum\spost\s142b868da7560d0b].
-D 2022-10-19T18:04:42.228
+C Minor\sinternal\sJS\scleanups.
+D 2022-10-20T04:00:05.192
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -478,7 +478,7 @@ F ext/wasm/README.md 1e5b28158b74ab3ffc9d54fcbc020f0bbeb82c2ff8bbd904214c86c70e8
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 89983a8d122c35a90c65ec667844b95a78bcd04f3198a99c1e0c8368c1a0b03a
 F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
 F ext/wasm/api/README.md 1350088aee90e959ad9a94fab1bb6bcb5e99d4d27f976db389050f54f2640c78
-F ext/wasm/api/extern-post-js.js 4bba34d8301f6058abd8ee24d2778b7360c5c3679217b38f5670e97a5ba7a3ec
+F ext/wasm/api/extern-post-js.js efbed835f290b3741259acc5faf68714a60d38e6834e6cfe172d5354c87566d2
 F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41
 F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1
 F ext/wasm/api/post-js-header.js 2e5c886398013ba2af88028ecbced1e4b22dc96a86467f1ecc5ba9e64ef90a8b
@@ -487,14 +487,14 @@ F ext/wasm/api/sqlite3-api-cleanup.js 4d07a7524dc9b7b050acfde57163e839243ad2383b
 F ext/wasm/api/sqlite3-api-glue.js 05eb701460bb72edbe3bf923bd51262551614612c37802fc597eabb4c6b83232
 F ext/wasm/api/sqlite3-api-oo1.js 9a5f0c00d476c504f16dcd456e1743dbc2826ca3d10645dfa62663a39e3ed0d8
 F ext/wasm/api/sqlite3-api-opfs.js 22d60ba956e873b65e2e0591e239178082bd53a6d563c3c58db7dc03e562e8f7
-F ext/wasm/api/sqlite3-api-prologue.js bdcd1f636e5ef0622f99b753aff0d26cc250bcd3a17923771e335ec73059b073
+F ext/wasm/api/sqlite3-api-prologue.js 73fcbeb788653e305eaae9dbef07825a2f6360812872c0c82185bf5d7447d375
 F ext/wasm/api/sqlite3-api-worker1.js df948de3968abd2361e1ff7a4410a5c5313275e9738a07e6686e8803a4c6070b
 F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 206ce6bbc3c30ad51a37d9c25e3a2712e70b586e0f9a2cf8cb0b9619017c2671
 F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
 F ext/wasm/api/sqlite3-wasm.c 84d410a2b9defdac85e6a421736307ff3a3eed3c1b0ae3b7b140edbc6ad81a8f
 F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52aff253afbf3350431f5773faf0e4b
-F ext/wasm/api/sqlite3-worker1.js ed87487c0813241909dc57813368a02a5ade37bc95e858c8ca256dedda030651
+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
@@ -2036,8 +2036,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 e3648a07f5607dbd4d6ad5b6e5a62a4a1d0b173d3f22aa36c74b768281fc86d8
-R dc5d57d2ab062846ea9bb105dfaf948e
-U drh
-Z 77fd38c4ef78083cfcf69fef5a64b6ae
+P 7450a561f8577c3ee41f84074c6ef39e29e56876cab4fd763e6489c66f603223
+R c184bc0a2cb850b281d68afdc582ec08
+U stephan
+Z 1e0d42d411be9deb413df9188b4a61c9
 # Remove this line to create a well-formed Fossil manifest.
index 2d0cb0c719a275f89e59b11a181f6f94103d84f1..6daf2a2f4cbebb4a1f89b0930cfa4f376be31402 100644 (file)
@@ -1 +1 @@
-7450a561f8577c3ee41f84074c6ef39e29e56876cab4fd763e6489c66f603223
\ No newline at end of file
+818ef0b5c909e733b643455278f7cc45533178f1cc6617058c00ed64fa44896a
\ No newline at end of file