mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Add/apply various kvvfs-specific utility APIs to the JS layer to assist in testing and analysis. Correct a backwards default arg check for sqlite3ApiBootstrap(). Add exports for sqlite3_db_handle(), sqlite3_file_control(), and the SQLITE_FCNTL_xxx enum.
FossilOrigin-Name: 0d78961870ee9f22f1ba16d423377d28dcc36e04b1e31ffd57f3e2fd51f8f0f2
This commit is contained in:
@ -20,11 +20,17 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build
|
||||
/**
|
||||
Install a suitable default configuration for sqlite3ApiBootstrap().
|
||||
*/
|
||||
const SABC = self.sqlite3ApiBootstrap.defaultConfig;
|
||||
SABC.Module = Module /* ==> Currently needs to be exposed here for test code. NOT part
|
||||
of the public API. */;
|
||||
SABC.exports = Module['asm'];
|
||||
SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */;
|
||||
const SABC = self.sqlite3ApiConfig || Object.create(null);
|
||||
if(undefined===SABC.Module){
|
||||
SABC.Module = Module /* ==> Currently needs to be exposed here for
|
||||
test code. NOT part of the public API. */;
|
||||
}
|
||||
if(undefined===SABC.exports){
|
||||
SABC.exports = Module['asm'];
|
||||
}
|
||||
if(undefined===SABC.memory){
|
||||
SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */;
|
||||
}
|
||||
|
||||
/**
|
||||
For current (2022-08-22) purposes, automatically call
|
||||
@ -35,8 +41,15 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build
|
||||
configuration used by a no-args call to sqlite3ApiBootstrap().
|
||||
*/
|
||||
//console.warn("self.sqlite3ApiConfig = ",self.sqlite3ApiConfig);
|
||||
const sqlite3 = self.sqlite3ApiBootstrap();
|
||||
delete self.sqlite3ApiBootstrap;
|
||||
const rmApiConfig = (SABC !== self.sqlite3ApiConfig);
|
||||
self.sqlite3ApiConfig = SABC;
|
||||
let sqlite3;
|
||||
try{
|
||||
sqlite3 = self.sqlite3ApiBootstrap();
|
||||
}finally{
|
||||
delete self.sqlite3ApiBootstrap;
|
||||
if(rmApiConfig) delete self.sqlite3ApiConfig;
|
||||
}
|
||||
|
||||
if(self.location && +self.location.port > 1024){
|
||||
console.warn("Installing sqlite3 bits as global S for local dev/test purposes.");
|
||||
|
Reference in New Issue
Block a user