diff options
author | stephan <stephan@noemail.net> | 2022-08-22 21:37:17 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-08-22 21:37:17 +0000 |
commit | ae708b2b018ac558b2f5c7626269415c86e85382 (patch) | |
tree | a1fafc97f0ae6b2c64349ddef9a09da0790d2adb /ext/wasm/common/SqliteTestUtil.js | |
parent | 7a8a0fceeca3ae88595c539bc2394ea8c74cf793 (diff) | |
download | sqlite-ae708b2b018ac558b2f5c7626269415c86e85382.tar.gz sqlite-ae708b2b018ac558b2f5c7626269415c86e85382.zip |
More experimentation with how client-side config state can be passed on to initialize the JS-side sqlite3 API.
FossilOrigin-Name: ea2acc454c012a62556f6d0623d6eff60736d24aa214a64462b423623ef44d47
Diffstat (limited to 'ext/wasm/common/SqliteTestUtil.js')
-rw-r--r-- | ext/wasm/common/SqliteTestUtil.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/wasm/common/SqliteTestUtil.js b/ext/wasm/common/SqliteTestUtil.js index c7c99240e..4b4cefbf0 100644 --- a/ext/wasm/common/SqliteTestUtil.js +++ b/ext/wasm/common/SqliteTestUtil.js @@ -168,6 +168,33 @@ } f.ui.status.classList.add('hidden'); } + }, + /** + Config options used by the Emscripten-dependent initialization + which happens via this.initSqlite3(). This object gets + (indirectly) passed to sqlite3ApiBootstrap() to configure the + sqlite3 API. + */ + sqlite3ApiConfig: { + persistentDirName: "/persistent" + }, + /** + Intended to be called by apps which need to call the + Emscripten-installed sqlite3InitModule() routine. This function + temporarily installs this.sqlite3ApiConfig into the self + object, calls it sqlite3InitModule(), and removes + self.sqlite3ApiConfig after initialization is done. Returns the + promise from sqlite3InitModule(), and the next then() handler + will get the Emscripten module object as its argument. That + module has the sqlite3's main namespace object installed as its + `sqlite3` property. + */ + initSqlite3: function(){ + self.sqlite3ApiConfig = this.sqlite3ApiConfig; + return self.sqlite3InitModule(this).then(function(M){ + delete self.sqlite3ApiConfig; + return M; + }); } }; })(self/*window or worker*/); |