aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-opfs.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-10-19 04:44:58 +0000
committerstephan <stephan@noemail.net>2022-10-19 04:44:58 +0000
commitcd0df83c156d12c89bcbe41420af51d83444855d (patch)
treef6e70858e5441d36916c58d053a44643a138bc86 /ext/wasm/api/sqlite3-api-opfs.js
parent71de8e02416aa9a4ad90ac6958ff3fa025a33d2d (diff)
downloadsqlite-cd0df83c156d12c89bcbe41420af51d83444855d.tar.gz
sqlite-cd0df83c156d12c89bcbe41420af51d83444855d.zip
Apply considerable acrobatics to get the JS/WASM deliverables building to and loadable from a directory other than the one which contains the app-level code. Requires an only-slightly-leaky abstraction of passing a URL argument when loading sqlite3.js but provides much greater flexibility in where the JS/WASM files are located.
FossilOrigin-Name: 6d468dab9eb84d4548f68014959f02fe4f66455472ff24fe729382bb2972e3d1
Diffstat (limited to 'ext/wasm/api/sqlite3-api-opfs.js')
-rw-r--r--ext/wasm/api/sqlite3-api-opfs.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/wasm/api/sqlite3-api-opfs.js b/ext/wasm/api/sqlite3-api-opfs.js
index 98defe4fb..9f5302454 100644
--- a/ext/wasm/api/sqlite3-api-opfs.js
+++ b/ext/wasm/api/sqlite3-api-opfs.js
@@ -98,6 +98,9 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
options.proxyUri = callee.defaultProxyUri;
}
+ if('function' === typeof options.proxyUri){
+ options.proxyUri = options.proxyUri();
+ }
const thePromise = new Promise(function(promiseResolve, promiseReject_){
const loggers = {
0:console.error.bind(console),
@@ -1092,9 +1095,18 @@ installOpfsVfs.defaultProxyUri =
"sqlite3-opfs-async-proxy.js";
//console.warn("sqlite3.installOpfsVfs.defaultProxyUri =",sqlite3.installOpfsVfs.defaultProxyUri);
self.sqlite3ApiBootstrap.initializersAsync.push(async (sqlite3)=>{
+ if(sqlite3.scriptInfo && !sqlite3.scriptInfo.isWorker){
+ return;
+ }
try{
+ let proxyJs = installOpfsVfs.defaultProxyUri;
+ if(sqlite3.scriptInfo.sqlite3Dir){
+ installOpfsVfs.defaultProxyUri =
+ sqlite3.scriptInfo.sqlite3Dir + proxyJs;
+ //console.warn("installOpfsVfs.defaultProxyUri =",installOpfsVfs.defaultProxyUri);
+ }
return installOpfsVfs().catch((e)=>{
- console.warn("Ignoring inability to install OPFS sqlite3_vfs:",e);
+ console.warn("Ignoring inability to install OPFS sqlite3_vfs:",e.message);
});
}catch(e){
console.error("installOpfsVfs() exception:",e);