aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-prologue.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-07-13 18:35:48 +0000
committerstephan <stephan@noemail.net>2023-07-13 18:35:48 +0000
commitf4449dc0ba9e0188ed466e42878a52fb7576efe3 (patch)
tree73f8e4a70ce96f9eba10d11816d9272b6286e655 /ext/wasm/api/sqlite3-api-prologue.js
parentbc6d949aa3640f0e7f0ff750486f500e02aded76 (diff)
parentd655290c99e787ec73ce7516a0e5dfae74065ebc (diff)
downloadsqlite-f4449dc0ba9e0188ed466e42878a52fb7576efe3.tar.gz
sqlite-f4449dc0ba9e0188ed466e42878a52fb7576efe3.zip
Reintroduce WASMFS+OPFS support, albeit as a separate (less portable) WASM build.
FossilOrigin-Name: 7e4c594e9591101f6b727212c99f561498444e86d3d059e5864a717c614f903a
Diffstat (limited to 'ext/wasm/api/sqlite3-api-prologue.js')
-rw-r--r--ext/wasm/api/sqlite3-api-prologue.js44
1 files changed, 15 insertions, 29 deletions
diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js
index 77739db57..f3d0a7c40 100644
--- a/ext/wasm/api/sqlite3-api-prologue.js
+++ b/ext/wasm/api/sqlite3-api-prologue.js
@@ -92,8 +92,8 @@
currently work due to incompatible Emscripten-side changes made
in the WASMFS+OPFS combination. This option is currently ignored.
- [^1] = This property may optionally be a function, in which case this
- function re-assigns calls that function to fetch the value,
+ [^1] = This property may optionally be a function, in which case
+ this function calls that function to fetch the value,
enabling delayed evaluation.
The returned object is the top-level sqlite3 namespace object.
@@ -149,11 +149,6 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
config[k] = config[k]();
}
});
- config.wasmOpfsDir =
- /* 2022-12-17: WASMFS+OPFS can no longer be activated from the
- main thread (aborts via a failed assert() if it's attempted),
- which eliminates any(?) benefit to supporting it. */ false;
-
/**
The main sqlite3 binding API gets installed into this object,
mimicking the C API as closely as we can. The numerous members
@@ -1177,31 +1172,31 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
/** State for sqlite3_wasmfs_opfs_dir(). */
let __wasmfsOpfsDir = undefined;
/**
- 2022-12-17: incompatible WASMFS changes have made WASMFS+OPFS
- unavailable from the main thread, which eliminates the most
- significant benefit of supporting WASMFS. This function is now a
- no-op which always returns a falsy value. Before that change,
- this function behaved as documented below (and how it will again
- if we can find a compelling reason to support it).
-
If the wasm environment has a WASMFS/OPFS-backed persistent
storage directory, its path is returned by this function. If it
does not then it returns "" (noting that "" is a falsy value).
The first time this is called, this function inspects the current
environment to determine whether persistence support is available
- and, if it is, enables it (if needed).
+ and, if it is, enables it (if needed). After the first call it
+ always returns the cached result.
+
+ If the returned string is not empty, any files stored under the
+ given path (recursively) are housed in OPFS storage. If the
+ returned string is empty, this particular persistent storage
+ option is not available on the client.
+
+ Though the mount point name returned by this function is intended
+ to remain stable, clients should not hard-coded it anywhere. Always call this function to get the path.
- This function currently only recognizes the WASMFS/OPFS storage
- combination and its path refers to storage rooted in the
- Emscripten-managed virtual filesystem.
+ Note that this function is a no-op in must builds of this
+ library, as the WASMFS capability requires a custom
+ build.
*/
capi.sqlite3_wasmfs_opfs_dir = function(){
if(undefined !== __wasmfsOpfsDir) return __wasmfsOpfsDir;
// If we have no OPFS, there is no persistent dir
const pdir = config.wasmfsOpfsDir;
- console.error("sqlite3_wasmfs_opfs_dir() can no longer work due "+
- "to incompatible WASMFS changes. It will be removed.");
if(!pdir
|| !globalThis.FileSystemHandle
|| !globalThis.FileSystemDirectoryHandle
@@ -1223,8 +1218,6 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
};
/**
- Experimental and subject to change or removal.
-
Returns true if sqlite3.capi.sqlite3_wasmfs_opfs_dir() is a
non-empty string and the given name starts with (that string +
'/'), else returns false.
@@ -1234,13 +1227,6 @@ globalThis.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
return (p && name) ? name.startsWith(p+'/') : false;
};
- // This bit is highly arguable and is incompatible with the fiddle shell.
- if(false && 0===wasm.exports.sqlite3_vfs_find(0)){
- /* Assume that sqlite3_initialize() has not yet been called.
- This will be the case in an SQLITE_OS_KV build. */
- wasm.exports.sqlite3_initialize();
- }
-
/**
Given an `sqlite3*`, an sqlite3_vfs name, and an optional db name
(defaulting to "main"), returns a truthy value (see below) if