bedrock-sqlite 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ declare module "bedrock-sqlite" {
2
+ interface RunResult {
3
+ changes: number;
4
+ lastInsertRowid: number | bigint;
5
+ }
6
+
7
+ interface ColumnDefinition {
8
+ name: string;
9
+ column: string | null;
10
+ table: string | null;
11
+ database: string | null;
12
+ type: string | null;
13
+ }
14
+
15
+ interface DatabaseOptions {
16
+ readonly?: boolean;
17
+ fileMustExist?: boolean;
18
+ }
19
+
20
+ interface FunctionOptions {
21
+ deterministic?: boolean;
22
+ directOnly?: boolean;
23
+ varargs?: boolean;
24
+ }
25
+
26
+ interface AggregateOptions {
27
+ step: (accumulator: any, ...args: any[]) => any;
28
+ result?: (accumulator: any) => any;
29
+ start?: any;
30
+ inverse?: (accumulator: any, ...args: any[]) => any;
31
+ deterministic?: boolean;
32
+ directOnly?: boolean;
33
+ varargs?: boolean;
34
+ }
35
+
36
+ interface Statement {
37
+ readonly source: string;
38
+ readonly reader: boolean;
39
+ readonly readonly: boolean;
40
+ run(...params: any[]): RunResult;
41
+ get(...params: any[]): any;
42
+ all(...params: any[]): any[];
43
+ iterate(...params: any[]): IterableIterator<any>;
44
+ pluck(toggle?: boolean): this;
45
+ expand(toggle?: boolean): this;
46
+ raw(toggle?: boolean): this;
47
+ columns(): ColumnDefinition[];
48
+ bind(...params: any[]): this;
49
+ }
50
+
51
+ interface Database {
52
+ readonly open: boolean;
53
+ readonly readonly: boolean;
54
+ readonly name: string;
55
+ readonly inTransaction: boolean;
56
+ prepare(source: string): Statement;
57
+ exec(sql: string): this;
58
+ transaction<F extends (...args: any[]) => any>(
59
+ fn: F
60
+ ): F & {
61
+ deferred: F;
62
+ immediate: F;
63
+ exclusive: F;
64
+ database: Database;
65
+ };
66
+ pragma(source: string, options?: { simple?: boolean }): any;
67
+ function(
68
+ name: string,
69
+ fn: (...args: any[]) => any,
70
+ options?: FunctionOptions
71
+ ): this;
72
+ aggregate(name: string, options: AggregateOptions): this;
73
+ close(): void;
74
+ }
75
+
76
+ interface DatabaseConstructor {
77
+ new (filename: string, options?: DatabaseOptions): Database;
78
+ }
79
+
80
+ class SqliteError extends Error {
81
+ code: string;
82
+ constructor(message: string, code?: string);
83
+ }
84
+
85
+ const Database: DatabaseConstructor;
86
+
87
+ export { Database, SqliteError };
88
+ export type {
89
+ RunResult,
90
+ ColumnDefinition,
91
+ DatabaseOptions,
92
+ FunctionOptions,
93
+ AggregateOptions,
94
+ Statement,
95
+ DatabaseConstructor,
96
+ };
97
+ }
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1 @@
1
+ var Module=typeof Module!="undefined"?Module:{};var ENVIRONMENT_IS_NODE=true;const SQLITE_OK=0;const SQLITE_ROW=100;const SQLITE_DONE=101;const SQLITE_INTEGER=1;const SQLITE_FLOAT=2;const SQLITE_TEXT=3;const SQLITE_BLOB=4;const SQLITE_NULL=5;const SQLITE_UTF8=1;const SQLITE_TRANSIENT=-1;const SQLITE_DETERMINISTIC=2048;const SQLITE_DIRECTONLY=524288;const INT32_MIN=-2147483648;const INT32_MAX=2147483647;const NULL=0;let temp;const sqlite3={};Module.onRuntimeInitialized=()=>{temp=stackAlloc(8);const v=null;const n="number";const s="string";const n1=[n];const n2=[n,...n1];const n3=[n,...n2];const n4=[n,...n3];const n5=[n,...n4];const signatures={open_v2:[n,[s,n,n,s]],exec:[n,n5],errmsg:[s,n1],prepare_v2:[n,n5],close_v2:[n,n1],finalize:[n,n1],reset:[n,n1],clear_bindings:[n,n1],bind_int:[n,n3],bind_int64:[n,n3],bind_double:[n,n3],bind_text:[n,n5],bind_blob:[n,n5],bind_null:[n,n2],bind_parameter_index:[n,[n,s]],bind_parameter_count:[n,n1],bind_parameter_name:[s,n2],step:[n,n1],column_int64:[n,n2],column_double:[n,n2],column_text:[s,n2],column_blob:[n,n2],column_type:[n,n2],column_name:[s,n2],column_count:[n,n1],column_bytes:[n,n2],column_table_name:[s,n2],column_origin_name:[s,n2],column_database_name:[s,n2],data_count:[n,n1],sql:[s,n1],stmt_readonly:[n,n1],last_insert_rowid:[n,n1],changes:[n,n1],total_changes:[n,n1],create_function_v2:[n,[n,s,n,n,n,n,n,n,n]],value_type:[n,n1],value_text:[s,n1],value_blob:[n,n1],value_int64:[n,n1],value_double:[n,n1],value_bytes:[n,n1],result_double:[v,n2],result_null:[v,n1],result_text:[v,n4],result_blob:[v,n4],result_int:[v,n2],result_int64:[v,n2],result_error:[v,n3],get_autocommit:[n,n1]};for(const[name,sig]of Object.entries(signatures)){sqlite3[name]=cwrap(`sqlite3_${name}`,sig[0],sig[1])}function arrayToHeap(array){const ptr=_malloc(array.byteLength);HEAPU8.set(array,ptr);return ptr}function stringToHeap(str){const size=lengthBytesUTF8(str)+1;const ptr=_malloc(size);stringToUTF8(str,ptr,size);return ptr}function toNumberOrNot(val){if(typeof val==="bigint"){if(val>=Number.MIN_SAFE_INTEGER&&val<=Number.MAX_SAFE_INTEGER){return Number(val)}return val}return val}class SqliteError extends Error{constructor(message,code){super(message);this.name="SqliteError";this.code=code||"SQLITE_ERROR"}}function resolveBindParams(args){if(args.length===0)return null;if(args.length===1){const arg=args[0];if(arg===undefined||arg===null)return null;if(Array.isArray(arg))return arg;if(typeof arg==="object"&&!(arg instanceof Uint8Array)&&!(arg instanceof Buffer))return arg;return[arg]}return Array.from(args)}function parseFunctionArgs(argc,argv){const args=[];for(let i=0;i<argc;i++){const ptr=getValue(argv+4*i,"i32");const type=sqlite3.value_type(ptr);switch(type){case SQLITE_INTEGER:args.push(toNumberOrNot(sqlite3.value_int64(ptr)));break;case SQLITE_FLOAT:args.push(sqlite3.value_double(ptr));break;case SQLITE_TEXT:args.push(sqlite3.value_text(ptr));break;case SQLITE_BLOB:{const p=sqlite3.value_blob(ptr);args.push(p!==NULL?Buffer.from(HEAPU8.slice(p,p+sqlite3.value_bytes(ptr))):Buffer.alloc(0));break}case SQLITE_NULL:args.push(null);break}}return args}function setFunctionResult(cx,result){switch(typeof result){case"boolean":sqlite3.result_int(cx,result?1:0);break;case"number":if(Number.isSafeInteger(result)){if(result>=INT32_MIN&&result<=INT32_MAX){sqlite3.result_int(cx,result)}else{sqlite3.result_int64(cx,BigInt(result))}}else{sqlite3.result_double(cx,result)}break;case"bigint":sqlite3.result_int64(cx,result);break;case"string":{const tp=stringToHeap(result);sqlite3.result_text(cx,tp,-1,SQLITE_TRANSIENT);_free(tp);break}case"object":if(result===null){sqlite3.result_null(cx)}else if(result instanceof Uint8Array||Buffer.isBuffer(result)){const tp=arrayToHeap(result);sqlite3.result_blob(cx,tp,result.byteLength,SQLITE_TRANSIENT);_free(tp)}else{sqlite3.result_error(cx,stringToHeap("unsupported return type"),-1)}break;default:sqlite3.result_null(cx);break}}class Database{constructor(filename,options={}){if(typeof filename!=="string"&&!Buffer.isBuffer(filename)){throw new TypeError("Expected first argument to be a string")}filename=String(filename);const readonly=!!options.readonly;const fileMustExist=!!options.fileMustExist;let flags;if(readonly){flags=1}else{flags=2;if(!fileMustExist)flags|=4}const rc=sqlite3.open_v2(filename,temp,flags,NULL);this._ptr=getValue(temp,"i32");if(rc!==SQLITE_OK){const msg=this._ptr!==NULL?sqlite3.errmsg(this._ptr):"unable to open database";if(this._ptr!==NULL)sqlite3.close_v2(this._ptr);this._ptr=null;throw new SqliteError(msg)}this._open=true;this._readonly=readonly;this._name=filename;this._statements=new Set;this._functions=new Map;this.exec("PRAGMA busy_timeout = 5000")}get open(){return this._open}get readonly(){return this._readonly}get name(){return this._name}get inTransaction(){return this._open&&sqlite3.get_autocommit(this._ptr)===0}prepare(source){this._assertOpen();if(typeof source!=="string"){throw new TypeError("Expected first argument to be a string")}const stmt=new Statement(this,source);this._statements.add(stmt);return stmt}exec(sql){this._assertOpen();for(const stmt of this._statements){if(!stmt._finalized)sqlite3.reset(stmt._ptr)}const tp=stringToHeap(sql);try{const rc=sqlite3.exec(this._ptr,tp,NULL,NULL,NULL);if(rc!==SQLITE_OK){throw new SqliteError(sqlite3.errmsg(this._ptr))}}finally{_free(tp)}return this}transaction(fn){if(typeof fn!=="function"){throw new TypeError("Expected first argument to be a function")}const db=this;const wrapTxn=begin=>{const beginStmt=db.prepare(begin);const commitStmt=db.prepare("COMMIT");const rollbackStmt=db.prepare("ROLLBACK");const runner=function(...args){let result;if(db.inTransaction){return fn.apply(this,args)}beginStmt.run();try{result=fn.apply(this,args);commitStmt.run()}catch(err){if(db.inTransaction){rollbackStmt.run()}throw err}return result};return runner};const result=wrapTxn("BEGIN");result.deferred=wrapTxn("BEGIN DEFERRED");result.immediate=wrapTxn("BEGIN IMMEDIATE");result.exclusive=wrapTxn("BEGIN EXCLUSIVE");result.database=db;return result}pragma(source,options){if(typeof source!=="string"){throw new TypeError("Expected first argument to be a string")}const simple=options&&options.simple;const sql=`PRAGMA ${source}`;const stmt=this.prepare(sql);try{if(stmt.reader){return simple?stmt.pluck().get():stmt.all()}else{return stmt.run()}}finally{sqlite3.finalize(stmt._ptr);stmt._finalized=true;this._statements.delete(stmt)}}function(name,fn,options={}){this._assertOpen();if(typeof name!=="string")throw new TypeError("Expected first argument to be a string");if(typeof fn!=="function")throw new TypeError("Expected second argument to be a function");const deterministic=!!options.deterministic;const directOnly=!!options.directOnly;const varargs=options.varargs||false;if(this._functions.has(name)){removeFunction(this._functions.get(name));this._functions.delete(name)}const wrappedFunc=(cx,argc,argv)=>{const args=parseFunctionArgs(argc,argv);try{const result=fn(...args);setFunctionResult(cx,result)}catch(err){const tp=stringToHeap(err.toString());sqlite3.result_error(cx,tp,-1);_free(tp)}};const funcPtr=addFunction(wrappedFunc,"viii");this._functions.set(name,funcPtr);let eTextRep=SQLITE_UTF8;if(deterministic)eTextRep|=SQLITE_DETERMINISTIC;if(directOnly)eTextRep|=SQLITE_DIRECTONLY;const rc=sqlite3.create_function_v2(this._ptr,name,varargs?-1:fn.length,eTextRep,NULL,funcPtr,NULL,NULL,NULL);if(rc!==SQLITE_OK)throw new SqliteError(sqlite3.errmsg(this._ptr));return this}aggregate(name,options){this._assertOpen();if(typeof name!=="string")throw new TypeError("Expected first argument to be a string");if(!options||typeof options!=="object")throw new TypeError("Expected second argument to be an options object");const step=options.step;const result=options.result||(acc=>acc);const start=options.start;const inverse=options.inverse;const deterministic=!!options.deterministic;const directOnly=!!options.directOnly;const varargs=!!options.varargs;if(typeof step!=="function")throw new TypeError("Expected options.step to be a function");let accumulator;const stepWrapper=(cx,argc,argv)=>{const args=parseFunctionArgs(argc,argv);try{accumulator=step(accumulator,...args)}catch(err){const tp=stringToHeap(err.toString());sqlite3.result_error(cx,tp,-1);_free(tp)}};const finalWrapper=cx=>{try{const val=result(accumulator);setFunctionResult(cx,val)}catch(err){const tp=stringToHeap(err.toString());sqlite3.result_error(cx,tp,-1);_free(tp)}accumulator=typeof start==="function"?start():start};accumulator=typeof start==="function"?start():start;if(this._functions.has(name+"_step")){removeFunction(this._functions.get(name+"_step"));this._functions.delete(name+"_step")}if(this._functions.has(name+"_final")){removeFunction(this._functions.get(name+"_final"));this._functions.delete(name+"_final")}const stepPtr=addFunction(stepWrapper,"viii");const finalPtr=addFunction(finalWrapper,"vi");this._functions.set(name+"_step",stepPtr);this._functions.set(name+"_final",finalPtr);let eTextRep=SQLITE_UTF8;if(deterministic)eTextRep|=SQLITE_DETERMINISTIC;if(directOnly)eTextRep|=SQLITE_DIRECTONLY;const argCount=varargs?-1:step.length-1;const rc=sqlite3.create_function_v2(this._ptr,name,argCount,eTextRep,NULL,NULL,stepPtr,finalPtr,NULL);if(rc!==SQLITE_OK)throw new SqliteError(sqlite3.errmsg(this._ptr));return this}close(){if(!this._open)return;for(const stmt of this._statements){if(!stmt._finalized){sqlite3.finalize(stmt._ptr);stmt._finalized=true}}this._statements.clear();for(const func of this._functions.values()){removeFunction(func)}this._functions.clear();const rc=sqlite3.close_v2(this._ptr);if(rc!==SQLITE_OK){throw new SqliteError(sqlite3.errmsg(this._ptr))}this._ptr=null;this._open=false}_assertOpen(){if(!this._open)throw new SqliteError("The database connection is not open")}_handleError(rc){if(rc!==SQLITE_OK){throw new SqliteError(sqlite3.errmsg(this._ptr))}}}class Statement{constructor(db,source){this._db=db;this._source=source;this._finalized=false;this._pluck=false;this._expand=false;this._raw=false;this._bound=false;const tp=stringToHeap(source);try{const rc=sqlite3.prepare_v2(db._ptr,tp,-1,temp,NULL);if(rc!==SQLITE_OK){throw new SqliteError(sqlite3.errmsg(db._ptr))}}finally{_free(tp)}this._ptr=getValue(temp,"i32");if(this._ptr===NULL){throw new SqliteError("Nothing to prepare")}this._columnCount=sqlite3.column_count(this._ptr);this._reader=this._columnCount>0;this._readonly=!!sqlite3.stmt_readonly(this._ptr)}get source(){return this._source}get reader(){return this._reader}get readonly(){return this._readonly}run(...args){this._assertReady();const params=resolveBindParams(args);this._reset();if(params)this._bind(params);this._step();return{changes:sqlite3.changes(this._db._ptr),lastInsertRowid:toNumberOrNot(sqlite3.last_insert_rowid(this._db._ptr))}}get(...args){this._assertReady();const params=resolveBindParams(args);this._reset();if(params)this._bind(params);if(!this._step())return undefined;return this._getRow()}all(...args){this._assertReady();const params=resolveBindParams(args);this._reset();if(params)this._bind(params);const rows=[];while(this._step()){rows.push(this._getRow())}return rows}*iterate(...args){this._assertReady();const params=resolveBindParams(args);this._reset();if(params)this._bind(params);while(this._step()){yield this._getRow()}}pluck(toggle=true){this._pluck=toggle;this._raw=false;this._expand=false;return this}expand(toggle=true){this._expand=toggle;this._pluck=false;this._raw=false;return this}raw(toggle=true){this._raw=toggle;this._pluck=false;this._expand=false;return this}columns(){this._assertReady();const cols=[];for(let i=0;i<this._columnCount;i++){cols.push({name:sqlite3.column_name(this._ptr,i),column:sqlite3.column_origin_name(this._ptr,i),table:sqlite3.column_table_name(this._ptr,i),database:sqlite3.column_database_name(this._ptr,i),type:null})}return cols}bind(...args){this._assertReady();const params=resolveBindParams(args);this._reset();if(params)this._bind(params);this._bound=true;return this}_reset(){sqlite3.clear_bindings(this._ptr);sqlite3.reset(this._ptr)}_step(){const rc=sqlite3.step(this._ptr);if(rc===SQLITE_ROW)return true;if(rc===SQLITE_DONE)return false;throw new SqliteError(sqlite3.errmsg(this._db._ptr))}_getRow(){if(this._pluck){return this._getColumnValue(0)}if(this._raw){const row=[];for(let i=0;i<this._columnCount;i++){row.push(this._getColumnValue(i))}return row}if(this._expand){const row={};for(let i=0;i<this._columnCount;i++){let table=sqlite3.column_table_name(this._ptr,i);table=table===""||table===null?"$":table;const name=sqlite3.column_name(this._ptr,i);if(!row[table])row[table]={};row[table][name]=this._getColumnValue(i)}return row}const row={};for(let i=0;i<this._columnCount;i++){row[sqlite3.column_name(this._ptr,i)]=this._getColumnValue(i)}return row}_getColumnValue(i){const type=sqlite3.column_type(this._ptr,i);switch(type){case SQLITE_INTEGER:return toNumberOrNot(sqlite3.column_int64(this._ptr,i));case SQLITE_FLOAT:return sqlite3.column_double(this._ptr,i);case SQLITE_TEXT:return sqlite3.column_text(this._ptr,i);case SQLITE_BLOB:{const p=sqlite3.column_blob(this._ptr,i);if(p!==NULL){return Buffer.from(HEAPU8.slice(p,p+sqlite3.column_bytes(this._ptr,i)))}return Buffer.alloc(0)}case SQLITE_NULL:return null;default:return null}}_bind(params){if(Array.isArray(params)){for(let i=0;i<params.length;i++){this._bindValue(params[i],i+1)}}else if(typeof params==="object"){const count=sqlite3.bind_parameter_count(this._ptr);for(let i=1;i<=count;i++){const pname=sqlite3.bind_parameter_name(this._ptr,i);if(!pname)continue;const stripped=pname.slice(1);const value=pname in params?params[pname]:stripped in params?params[stripped]:undefined;if(value!==undefined){this._bindValue(value,i)}}}}_bindValue(value,position){let rc;switch(typeof value){case"string":{const tp=stringToHeap(value);rc=sqlite3.bind_text(this._ptr,position,tp,-1,SQLITE_TRANSIENT);_free(tp);break}case"number":if(Number.isSafeInteger(value)){if(value>=INT32_MIN&&value<=INT32_MAX){rc=sqlite3.bind_int(this._ptr,position,value)}else{rc=sqlite3.bind_int64(this._ptr,position,BigInt(value))}}else{rc=sqlite3.bind_double(this._ptr,position,value)}break;case"bigint":rc=sqlite3.bind_int64(this._ptr,position,value);break;case"boolean":rc=sqlite3.bind_int(this._ptr,position,value?1:0);break;case"object":if(value===null){rc=sqlite3.bind_null(this._ptr,position)}else if(value instanceof Uint8Array||Buffer.isBuffer(value)){const tp=arrayToHeap(value);rc=sqlite3.bind_blob(this._ptr,position,tp,value.byteLength,SQLITE_TRANSIENT);_free(tp)}else{throw new SqliteError(`Unsupported binding type at position ${position}`)}break;default:if(value===undefined){rc=sqlite3.bind_null(this._ptr,position)}else{throw new SqliteError(`Unsupported binding type: ${typeof value}`)}}if(rc!==SQLITE_OK){throw new SqliteError(sqlite3.errmsg(this._db._ptr))}}_assertReady(){if(this._finalized)throw new SqliteError("This statement has been finalized");if(!this._db._open)throw new SqliteError("The database connection is not open")}}Module.Database=Database;Module.SqliteError=SqliteError};const path=require("node:path");const crypto=require("node:crypto");const SQLITE_CANTOPEN=14;const SQLITE_IOERR_READ=266;const SQLITE_IOERR_SHORT_READ=522;const SQLITE_IOERR_FSYNC=1034;const SQLITE_IOERR_WRITE=778;const SQLITE_IOERR_DELETE=2570;const SQLITE_IOERR_CLOSE=4106;const SQLITE_IOERR_TRUNCATE=1546;const SQLITE_IOERR_FSTAT=1802;const SQLITE_IOERR_LOCK=3850;const SQLITE_IOERR_UNLOCK=2058;const SQLITE_OPEN_READONLY=1;const SQLITE_OPEN_READWRITE=2;const SQLITE_OPEN_CREATE=4;const SQLITE_OPEN_EXCLUSIVE=16;const SQLITE_ACCESS_READWRITE=1;const SQLITE_ACCESS_READ=2;const SQLITE_LOCK_NONE=0;const SQLITE_BUSY=5;function _fd(fileInfo){return getValue(fileInfo+4,"i32")}function _isLocked(fileInfo){return getValue(fileInfo+8,"i32")!=0}function _setLocked(fileInfo,locked){setValue(fileInfo+8,locked?1:0,"i32")}function _path(fileInfo){return UTF8ToString(getValue(fileInfo+12,"i32"))}function _safeInt(bigInt){if(bigInt<Number.MIN_SAFE_INTEGER||bigInt>Number.MAX_SAFE_INTEGER)throw 0;return Number(bigInt)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName;if(typeof __filename!="undefined"){_scriptName=__filename}else{}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");scriptDirectory=__dirname+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);if(typeof module!="undefined"){module["exports"]=Module}quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["D"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("sqlite3.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)'}function instantiateSync(file,info){var module;var binary=getBinarySync(file);module=new WebAssembly.Module(binary);var instance=new WebAssembly.Instance(module,info);return[instance,module]}function getWasmImports(){var imports={a:wasmImports};return imports}function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=instantiateSync(wasmBinaryFile,info);return receiveInstance(result[0])}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP64[ptr>>3];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":HEAP64[ptr>>3]=BigInt(value);break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var __abort_js=()=>abort("");var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var isLeapYear=year=>year%4===0&&(year%100!==0||year%400===0);var MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335];var MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334];var ydayFromDate=date=>{var leap=isLeapYear(date.getFullYear());var monthDaysCumulative=leap?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE;var yday=monthDaysCumulative[date.getMonth()]+date.getDate()-1;return yday};var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);function __localtime_js(time,tmPtr){time=bigintToI53Checked(time);var date=new Date(time*1e3);HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst}var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var _emscripten_date_now=()=>Date.now();var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";function _nodejsAccess(vfs,filePath,flags,outResult){let aflags=fs.constants.F_OK;if(flags==SQLITE_ACCESS_READWRITE)aflags=fs.constants.R_OK|fs.constants.W_OK;if(flags==SQLITE_ACCESS_READ)aflags=fs.constants.R_OK;try{fs.accessSync(UTF8ToString(filePath),aflags);setValue(outResult,1,"i32")}catch{setValue(outResult,0,"i32")}return SQLITE_OK}function _nodejsCheckReservedLock(fi,outResult){try{fs.accessSync(`${_path(fi)}.lock`,fs.constants.F_OK);setValue(outResult,1,"i32")}catch{setValue(outResult,0,"i32")}return SQLITE_OK}function _nodejsClose(fi){_nodejsUnlock(fi,SQLITE_LOCK_NONE);try{fs.closeSync(_fd(fi))}catch{return SQLITE_IOERR_CLOSE}return SQLITE_OK}function _nodejsDelete(vfs,filePath,dirSync){const pathStr=UTF8ToString(filePath);try{fs.unlinkSync(pathStr)}catch(err){if(err.code!="ENOENT")return SQLITE_IOERR_DELETE}if(dirSync){let fd=-1;try{fd=fs.openSync(path.dirname(pathStr),"r");fs.fsyncSync(fd)}catch{return SQLITE_IOERR_FSYNC}finally{try{fs.closeSync(fd)}catch{return SQLITE_IOERR_FSYNC}}}return SQLITE_OK}function _nodejsFileSize(fi,outSize){try{setValue(outSize,fs.fstatSync(_fd(fi)).size,"i64")}catch{return SQLITE_IOERR_FSTAT}return SQLITE_OK}function _nodejsFullPathname(vfs,relPath,sizeFullPath,outFullPath){const full=path.resolve(UTF8ToString(relPath));stringToUTF8(full,outFullPath,sizeFullPath);return full.length<sizeFullPath?SQLITE_OK:SQLITE_CANTOPEN}function _nodejsLock(fi,level){if(!_isLocked(fi)){try{fs.mkdirSync(`${_path(fi)}.lock`)}catch(err){return err.code=="EEXIST"?SQLITE_BUSY:SQLITE_IOERR_LOCK}_setLocked(fi,true)}return SQLITE_OK}function _nodejsRandomness(vfs,bytes,outBuffer){const buf=HEAPU8.subarray(outBuffer,outBuffer+bytes);crypto.randomFillSync(buf);return bytes}function _nodejsRead(fi,outBuffer,bytes,offset){const buf=HEAPU8.subarray(outBuffer,outBuffer+bytes);let bytesRead;try{bytesRead=fs.readSync(_fd(fi),buf,0,bytes,offset)}catch{return SQLITE_IOERR_READ}if(bytesRead==bytes){return SQLITE_OK}else if(bytesRead>=0){if(bytesRead<bytes){try{buf.fill(0,bytesRead)}catch{return SQLITE_IOERR_READ}}return SQLITE_IOERR_SHORT_READ}return SQLITE_IOERR_READ}function _nodejsShmBarrier(fi){}function _nodejsShmLock(fi,offset,n,flags){return SQLITE_OK}var _shmRegistry={};function _nodejsShmMap(fi,pgno,pgsz,isWrite,ppOut){const filePath=_path(fi);if(!_shmRegistry[filePath])_shmRegistry[filePath]={};const regions=_shmRegistry[filePath];if(!(pgno in regions)){if(!isWrite){setValue(ppOut,0,"*");return SQLITE_OK}const buf=_malloc(pgsz);HEAPU8.fill(0,buf,buf+pgsz);regions[pgno]=buf}setValue(ppOut,regions[pgno],"*");return SQLITE_OK}function _nodejsShmUnmap(fi,deleteFlag){if(deleteFlag){const filePath=_path(fi);const regions=_shmRegistry[filePath];if(regions){for(const pgno in regions)_free(regions[pgno]);delete _shmRegistry[filePath]}}return SQLITE_OK}function _nodejsSync(fi,flags){try{fs.fsyncSync(_fd(fi))}catch{return SQLITE_IOERR_FSYNC}return SQLITE_OK}function _nodejsTruncate(fi,size){try{fs.ftruncateSync(_fd(fi),_safeInt(size))}catch{return SQLITE_IOERR_TRUNCATE}return SQLITE_OK}function _nodejsUnlock(fi,level){if(level==SQLITE_LOCK_NONE&&_isLocked(fi)){try{fs.rmdirSync(`${_path(fi)}.lock`)}catch(err){if(err.code!="ENOENT")return SQLITE_IOERR_UNLOCK}_setLocked(fi,false)}return SQLITE_OK}function _nodejsWrite(fi,buffer,bytes,offset){try{const bytesWritten=fs.writeSync(_fd(fi),HEAPU8.subarray(buffer,buffer+bytes),0,bytes,_safeInt(offset));return bytesWritten!=bytes?SQLITE_IOERR_WRITE:SQLITE_OK}catch{return SQLITE_IOERR_WRITE}}function _nodejs_max_path_length(){return process.platform=="win32"?260:4096}function _nodejs_open(filePath,flags,mode){let oflags=0;if(flags&SQLITE_OPEN_EXCLUSIVE)oflags|=fs.constants.O_EXCL;if(flags&SQLITE_OPEN_CREATE)oflags|=fs.constants.O_CREAT;if(flags&SQLITE_OPEN_READONLY)oflags|=fs.constants.O_RDONLY;if(flags&SQLITE_OPEN_READWRITE)oflags|=fs.constants.O_RDWR;try{return fs.openSync(UTF8ToString(filePath),oflags,mode)}catch{return-1}}var getCFunc=ident=>{var func=Module["_"+ident];return func};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var ccall=(ident,returnType,argTypes,args,opts)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str)}return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func(...cArgs);function onDone(ret){if(stack!==0)stackRestore(stack);return convertReturnValue(ret)}ret=onDone(ret);return ret};var cwrap=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return(...args)=>ccall(ident,returnType,argTypes,args,opts)};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var updateTableMap=(offset,count)=>{if(functionsInTableMap){for(var i=offset;i<offset+count;i++){var item=getWasmTableEntry(i);if(item){functionsInTableMap.set(item,i)}}}};var functionsInTableMap;var getFunctionAddress=func=>{if(!functionsInTableMap){functionsInTableMap=new WeakMap;updateTableMap(0,wasmTable.length)}return functionsInTableMap.get(func)||0};var freeTableIndexes=[];var getEmptyTableSlot=()=>{if(freeTableIndexes.length){return freeTableIndexes.pop()}return wasmTable["grow"](1)};var setWasmTableEntry=(idx,func)=>{wasmTable.set(idx,func);wasmTableMirror[idx]=wasmTable.get(idx)};var uleb128EncodeWithLen=arr=>{const n=arr.length;return[n%128|128,n>>7,...arr]};var wasmTypeCodes={i:127,p:127,j:126,f:125,d:124,e:111};var generateTypePack=types=>uleb128EncodeWithLen(Array.from(types,type=>{var code=wasmTypeCodes[type];return code}));var convertJsFunctionToWasm=(func,sig)=>{var bytes=Uint8Array.of(0,97,115,109,1,0,0,0,1,...uleb128EncodeWithLen([1,96,...generateTypePack(sig.slice(1)),...generateTypePack(sig[0]==="v"?"":sig[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(bytes);var instance=new WebAssembly.Instance(module,{e:{f:func}});var wrappedFunc=instance.exports["f"];return wrappedFunc};var addFunction=(func,sig)=>{var rtn=getFunctionAddress(func);if(rtn){return rtn}var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func)}catch(err){if(!(err instanceof TypeError)){throw err}var wrapped=convertJsFunctionToWasm(func,sig);setWasmTableEntry(ret,wrapped)}functionsInTableMap.set(func,ret);return ret};var removeFunction=index=>{functionsInTableMap.delete(getWasmTableEntry(index));setWasmTableEntry(index,null);freeTableIndexes.push(index)};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}Module["cwrap"]=cwrap;Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var _sqlite3_prepare_v2,_sqlite3_step,_sqlite3_column_int64,_sqlite3_reset,_sqlite3_exec,_sqlite3_finalize,_sqlite3_clear_bindings,_sqlite3_value_blob,_sqlite3_value_text,_sqlite3_value_bytes,_sqlite3_value_double,_sqlite3_value_int64,_sqlite3_value_type,_sqlite3_result_blob,_sqlite3_result_double,_sqlite3_result_error,_sqlite3_result_int,_sqlite3_result_int64,_sqlite3_result_null,_sqlite3_result_text,_sqlite3_column_count,_sqlite3_data_count,_sqlite3_column_blob,_sqlite3_column_bytes,_sqlite3_column_double,_sqlite3_column_text,_sqlite3_column_type,_sqlite3_column_name,_sqlite3_column_database_name,_sqlite3_column_table_name,_sqlite3_column_origin_name,_sqlite3_bind_blob,_sqlite3_bind_double,_sqlite3_bind_int,_sqlite3_bind_int64,_sqlite3_bind_null,_sqlite3_bind_text,_sqlite3_bind_parameter_count,_sqlite3_bind_parameter_name,_sqlite3_bind_parameter_index,_sqlite3_stmt_readonly,_sqlite3_sql,_sqlite3_errmsg,_sqlite3_last_insert_rowid,_sqlite3_changes,_sqlite3_total_changes,_sqlite3_close_v2,_sqlite3_create_function_v2,_sqlite3_open_v2,_sqlite3_get_autocommit,_malloc,_free,__emscripten_timeout,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){_sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=wasmExports["E"];_sqlite3_step=Module["_sqlite3_step"]=wasmExports["F"];_sqlite3_column_int64=Module["_sqlite3_column_int64"]=wasmExports["G"];_sqlite3_reset=Module["_sqlite3_reset"]=wasmExports["H"];_sqlite3_exec=Module["_sqlite3_exec"]=wasmExports["I"];_sqlite3_finalize=Module["_sqlite3_finalize"]=wasmExports["J"];_sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=wasmExports["K"];_sqlite3_value_blob=Module["_sqlite3_value_blob"]=wasmExports["L"];_sqlite3_value_text=Module["_sqlite3_value_text"]=wasmExports["M"];_sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=wasmExports["N"];_sqlite3_value_double=Module["_sqlite3_value_double"]=wasmExports["O"];_sqlite3_value_int64=Module["_sqlite3_value_int64"]=wasmExports["P"];_sqlite3_value_type=Module["_sqlite3_value_type"]=wasmExports["Q"];_sqlite3_result_blob=Module["_sqlite3_result_blob"]=wasmExports["R"];_sqlite3_result_double=Module["_sqlite3_result_double"]=wasmExports["S"];_sqlite3_result_error=Module["_sqlite3_result_error"]=wasmExports["T"];_sqlite3_result_int=Module["_sqlite3_result_int"]=wasmExports["U"];_sqlite3_result_int64=Module["_sqlite3_result_int64"]=wasmExports["V"];_sqlite3_result_null=Module["_sqlite3_result_null"]=wasmExports["W"];_sqlite3_result_text=Module["_sqlite3_result_text"]=wasmExports["X"];_sqlite3_column_count=Module["_sqlite3_column_count"]=wasmExports["Y"];_sqlite3_data_count=Module["_sqlite3_data_count"]=wasmExports["Z"];_sqlite3_column_blob=Module["_sqlite3_column_blob"]=wasmExports["_"];_sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=wasmExports["$"];_sqlite3_column_double=Module["_sqlite3_column_double"]=wasmExports["aa"];_sqlite3_column_text=Module["_sqlite3_column_text"]=wasmExports["ba"];_sqlite3_column_type=Module["_sqlite3_column_type"]=wasmExports["ca"];_sqlite3_column_name=Module["_sqlite3_column_name"]=wasmExports["da"];_sqlite3_column_database_name=Module["_sqlite3_column_database_name"]=wasmExports["ea"];_sqlite3_column_table_name=Module["_sqlite3_column_table_name"]=wasmExports["fa"];_sqlite3_column_origin_name=Module["_sqlite3_column_origin_name"]=wasmExports["ga"];_sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=wasmExports["ha"];_sqlite3_bind_double=Module["_sqlite3_bind_double"]=wasmExports["ia"];_sqlite3_bind_int=Module["_sqlite3_bind_int"]=wasmExports["ja"];_sqlite3_bind_int64=Module["_sqlite3_bind_int64"]=wasmExports["ka"];_sqlite3_bind_null=Module["_sqlite3_bind_null"]=wasmExports["la"];_sqlite3_bind_text=Module["_sqlite3_bind_text"]=wasmExports["ma"];_sqlite3_bind_parameter_count=Module["_sqlite3_bind_parameter_count"]=wasmExports["na"];_sqlite3_bind_parameter_name=Module["_sqlite3_bind_parameter_name"]=wasmExports["oa"];_sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=wasmExports["pa"];_sqlite3_stmt_readonly=Module["_sqlite3_stmt_readonly"]=wasmExports["qa"];_sqlite3_sql=Module["_sqlite3_sql"]=wasmExports["ra"];_sqlite3_errmsg=Module["_sqlite3_errmsg"]=wasmExports["sa"];_sqlite3_last_insert_rowid=Module["_sqlite3_last_insert_rowid"]=wasmExports["ta"];_sqlite3_changes=Module["_sqlite3_changes"]=wasmExports["ua"];_sqlite3_total_changes=Module["_sqlite3_total_changes"]=wasmExports["va"];_sqlite3_close_v2=Module["_sqlite3_close_v2"]=wasmExports["wa"];_sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=wasmExports["xa"];_sqlite3_open_v2=Module["_sqlite3_open_v2"]=wasmExports["ya"];_sqlite3_get_autocommit=Module["_sqlite3_get_autocommit"]=wasmExports["za"];_malloc=Module["_malloc"]=wasmExports["Aa"];_free=Module["_free"]=wasmExports["Ba"];__emscripten_timeout=wasmExports["Da"];__emscripten_stack_restore=wasmExports["Ea"];__emscripten_stack_alloc=wasmExports["Fa"];_emscripten_stack_get_current=wasmExports["Ga"];memory=wasmMemory=wasmExports["C"];__indirect_function_table=wasmTable=wasmExports["Ca"]}var wasmImports={q:__abort_js,j:__emscripten_runtime_keepalive_clear,m:__localtime_js,k:__setitimer_js,n:__tzset_js,o:_emscripten_date_now,a:_emscripten_get_now,l:_emscripten_resize_heap,A:_nodejsAccess,w:_nodejsCheckReservedLock,f:_nodejsClose,B:_nodejsDelete,z:_nodejsFileSize,p:_nodejsFullPathname,y:_nodejsLock,h:_nodejsRandomness,e:_nodejsRead,t:_nodejsShmBarrier,u:_nodejsShmLock,v:_nodejsShmMap,s:_nodejsShmUnmap,b:_nodejsSync,c:_nodejsTruncate,x:_nodejsUnlock,d:_nodejsWrite,g:_nodejs_max_path_length,r:_nodejs_open,i:_proc_exit};function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=createWasm();run();
Binary file
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "bedrock-sqlite",
3
+ "version": "0.0.1",
4
+ "description": "WASM build of SQLite (bedrock branch) with better-sqlite3 compatible API. Supports BEGIN CONCURRENT and WAL2.",
5
+ "license": "MIT",
6
+ "main": "dist/sqlite3.js",
7
+ "types": "bedrock-sqlite.d.ts",
8
+ "files": [
9
+ "dist/sqlite3.js",
10
+ "dist/sqlite3.wasm",
11
+ "dist/package.json",
12
+ "bedrock-sqlite.d.ts"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/natew/orez",
17
+ "directory": "sqlite-wasm"
18
+ },
19
+ "keywords": [
20
+ "sqlite",
21
+ "sqlite3",
22
+ "wasm",
23
+ "webassembly",
24
+ "better-sqlite3",
25
+ "database",
26
+ "wal2",
27
+ "begin-concurrent",
28
+ "bedrock"
29
+ ],
30
+ "scripts": {
31
+ "build:wasm": "docker run --rm -v $(pwd)/..:/workspace -w /workspace/sqlite-wasm -u $(id -u):$(id -g) emscripten/emsdk:5.0.0 make all",
32
+ "clean": "make clean",
33
+ "test": "vitest run",
34
+ "prepublishOnly": "test -f dist/sqlite3.wasm || (echo 'Run build:wasm first' && exit 1)"
35
+ },
36
+ "devDependencies": {
37
+ "vitest": "^3.0.0",
38
+ "typescript": "^5.7.0"
39
+ }
40
+ }