node-sqlite3-wasm
Advanced tools
@@ -1,1 +0,1 @@ | ||
| var Module=typeof Module!="undefined"?Module:{};var ENVIRONMENT_IS_NODE=true;const INT32_MIN=-2147483648;const INT32_MAX=2147483647;const NULL=0;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;let temp;const sqlite3={};Module.onRuntimeInitialized=()=>{temp=stackAlloc(4);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_blob64:[n,n5],bind_null:[n,n2],bind_parameter_index:[n,[n,s]],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],last_insert_rowid:[n,n1],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_blob64:[v,n4],result_int:[v,n2],result_int64:[v,n2],result_error:[v,n3],column_table_name:[s,n2],get_autocommit:[n,n1]};for(const[name,sig]of Object.entries(signatures)){sqlite3[name]=cwrap(`sqlite3_${name}`,sig[0],sig[1])}};class SQLite3Error extends Error{constructor(message){super(message);this.name="SQLite3Error"}}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(bigInt){if(bigInt>=Number.MIN_SAFE_INTEGER&&bigInt<=Number.MAX_SAFE_INTEGER){return Number(bigInt)}return bigInt}function parseFunctionArguments(argc,argv){const args=[];for(let i=0;i<argc;i++){const ptr=getValue(argv+4*i,"i32");const type=sqlite3.value_type(ptr);let arg;switch(type){case SQLITE_INTEGER:arg=toNumberOrNot(sqlite3.value_int64(ptr));break;case SQLITE_FLOAT:arg=sqlite3.value_double(ptr);break;case SQLITE_TEXT:arg=sqlite3.value_text(ptr);break;case SQLITE_BLOB:const p=sqlite3.value_blob(ptr);if(p!=NULL){arg=HEAPU8.slice(p,p+sqlite3.value_bytes(ptr))}else{arg=new Uint8Array}break;case SQLITE_NULL:arg=null;break}args.push(arg)}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 tempPtr=stringToHeap(result);sqlite3.result_text(cx,tempPtr,-1,SQLITE_TRANSIENT);_free(tempPtr);break;case"object":if(result===null){sqlite3.result_null(cx)}else if(result instanceof Uint8Array){const tempPtr=arrayToHeap(result);if(result.byteLength<=INT32_MAX){sqlite3.result_blob(cx,tempPtr,result.byteLength,SQLITE_TRANSIENT)}else{sqlite3.result_blob64(cx,tempPtr,BigInt(result.byteLength),SQLITE_TRANSIENT)}_free(tempPtr)}else{throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`)}break;default:throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`)}}class Database{constructor(filename,{fileMustExist=false,readOnly=false}={}){let flags;if(readOnly){flags=SQLITE_OPEN_READONLY}else{flags=SQLITE_OPEN_READWRITE;if(!fileMustExist)flags|=SQLITE_OPEN_CREATE}const rc=sqlite3.open_v2(filename,temp,flags,NULL);this._ptr=getValue(temp,"i32");if(rc!==SQLITE_OK){if(this._ptr!==NULL)sqlite3.close_v2(this._ptr);throw new SQLite3Error(`Could not open the database "${filename}"`)}this._functions=new Map}get isOpen(){return this._ptr!==null}get inTransaction(){this._assertOpen();return sqlite3.get_autocommit(this._ptr)===0}close(){this._assertOpen();for(const func of this._functions.values())removeFunction(func);this._functions.clear();this._handleError(sqlite3.close_v2(this._ptr));this._ptr=null}function(name,func,{deterministic=false}={}){this._assertOpen();function wrappedFunc(cx,argc,argv){const args=parseFunctionArguments(argc,argv);let result;try{result=func.apply(null,args)}catch(err){const tempPtr=stringToHeap(err.toString());sqlite3.result_error(cx,tempPtr,-1);_free(tempPtr);return}setFunctionResult(cx,result)}if(this._functions.has(name)){removeFunction(this._functions.get(name));this._functions.delete(name)}const funcPtr=addFunction(wrappedFunc,"viii");this._functions.set(name,funcPtr);let eTextRep=SQLITE_UTF8;if(deterministic)eTextRep|=SQLITE_DETERMINISTIC;this._handleError(sqlite3.create_function_v2(this._ptr,name,func.length,eTextRep,NULL,funcPtr,NULL,NULL,NULL));return this}exec(sql){this._assertOpen();const tempPtr=stringToHeap(sql);try{this._handleError(sqlite3.exec(this._ptr,tempPtr,NULL,NULL,NULL))}finally{_free(tempPtr)}}prepare(sql){this._assertOpen();return new Statement(this,sql)}run(sql,values){const stmt=this.prepare(sql);try{return stmt.run(values)}finally{stmt.finalize()}}all(sql,values,{expand=false}={}){return this._query(sql,values,false,expand)}get(sql,values,{expand=false}={}){return this._query(sql,values,true,expand)}_query(sql,values,single,expand){const stmt=this.prepare(sql);try{if(single){return stmt.get(values,{expand})}else{return stmt.all(values,{expand})}}finally{stmt.finalize()}}_assertOpen(){if(!this.isOpen)throw new SQLite3Error("Database already closed")}_handleError(returnCode){if(returnCode!==SQLITE_OK)throw new SQLite3Error(sqlite3.errmsg(this._ptr))}}class Statement{constructor(db,sql){const tempPtr=stringToHeap(sql);try{db._handleError(sqlite3.prepare_v2(db._ptr,tempPtr,-1,temp,NULL))}finally{_free(tempPtr)}this._ptr=getValue(temp,"i32");if(this._ptr===NULL)throw new SQLite3Error("Nothing to prepare");this._db=db}get database(){return this._db}get isFinalized(){return this._ptr===null}run(values){this._assertReady();this._bind(values);this._step();return{changes:sqlite3.changes(this._db._ptr),lastInsertRowid:toNumberOrNot(sqlite3.last_insert_rowid(this._db._ptr))}}iterate(values,{expand=false}={}){return this._queryRows(values,expand)}all(values,{expand=false}={}){return Array.from(this.iterate(values,{expand}))}get(values,{expand=false}={}){const result=this._queryRows(values,expand).next();return result.done?null:result.value}finalize(){if(this.isFinalized)throw new SQLite3Error("Statement already finalized");try{this._db._handleError(sqlite3.finalize(this._ptr))}finally{this._ptr=null}}_reset(){return sqlite3.clear_bindings(this._ptr)===SQLITE_OK&&sqlite3.reset(this._ptr)===SQLITE_OK}*_queryRows(values,expand){this._assertReady();this._bind(values);const columns=this._getColumnNames();while(this._step())yield this._getRow(columns,expand)}_bind(values){if(!this._reset()){throw new SQLite3Error("Could not reset statement prior to binding new values")}if(Array.isArray(values)){this._bindArray(values)}else if(values!=null&&typeof values==="object"){this._bindObject(values)}else if(typeof values!=="undefined"){this._bindValue(values,1)}}_step(){const ret=sqlite3.step(this._ptr);switch(ret){case SQLITE_ROW:return true;case SQLITE_DONE:return false;default:this._db._handleError(ret)}}_getRow(columns,expand){const row={};for(let i=0;i<columns.length;i++){let v;const colType=sqlite3.column_type(this._ptr,i);switch(colType){case SQLITE_INTEGER:v=toNumberOrNot(sqlite3.column_int64(this._ptr,i));break;case SQLITE_FLOAT:v=sqlite3.column_double(this._ptr,i);break;case SQLITE_TEXT:v=sqlite3.column_text(this._ptr,i);break;case SQLITE_BLOB:const p=sqlite3.column_blob(this._ptr,i);if(p!=NULL){v=HEAPU8.slice(p,p+sqlite3.column_bytes(this._ptr,i))}else{v=new Uint8Array}break;case SQLITE_NULL:v=null;break}const column=columns[i];if(expand){let table=sqlite3.column_table_name(this._ptr,i);table=table===""?"$":table;if(Object.hasOwn(row,table)){row[table][column]=v}else{row[table]={[column]:v}}}else{row[column]=v}}return row}_getColumnNames(){const names=[];const columns=sqlite3.column_count(this._ptr);for(let i=0;i<columns;i++)names.push(sqlite3.column_name(this._ptr,i));return names}_bindArray(values){for(let i=0;i<values.length;i++)this._bindValue(values[i],i+1)}_bindObject(values){for(const[param,value]of Object.entries(values)){const i=sqlite3.bind_parameter_index(this._ptr,param);if(i===0)throw new SQLite3Error(`Unknown binding parameter: "${param}"`);this._bindValue(value,i)}}_bindValue(value,position){let ret;switch(typeof value){case"string":const tempPtr=stringToHeap(value);ret=sqlite3.bind_text(this._ptr,position,tempPtr,-1,SQLITE_TRANSIENT);_free(tempPtr);break;case"number":if(Number.isSafeInteger(value)){if(value>=INT32_MIN&&value<=INT32_MAX){ret=sqlite3.bind_int(this._ptr,position,value)}else{ret=sqlite3.bind_int64(this._ptr,position,BigInt(value))}}else{ret=sqlite3.bind_double(this._ptr,position,value)}break;case"bigint":ret=sqlite3.bind_int64(this._ptr,position,value);break;case"boolean":ret=sqlite3.bind_int(this._ptr,position,value?1:0);break;case"object":if(value===null){ret=sqlite3.bind_null(this._ptr,position)}else if(value instanceof Uint8Array){const tempPtr=arrayToHeap(value);if(value.byteLength<=INT32_MAX){ret=sqlite3.bind_blob(this._ptr,position,tempPtr,value.byteLength,SQLITE_TRANSIENT)}else{ret=sqlite3.bind_blob64(this._ptr,position,tempPtr,BigInt(value.byteLength),SQLITE_TRANSIENT)}_free(tempPtr)}else{throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`)}break;default:throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`)}if(ret!==SQLITE_OK)this._db._handleError(ret)}_assertReady(){if(this.isFinalized)throw new SQLite3Error("Statement already finalized");if(!this._db.isOpen)throw new SQLite3Error("Database is closed")}}Module.Database=Database;Module.SQLite3Error=SQLite3Error;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("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["z"]()}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("node-sqlite3-wasm.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{func();maybeExit()}catch(e){handleException(e)}};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 _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_finalize,_sqlite3_reset,_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_blob64,_sqlite3_result_double,_sqlite3_result_error,_sqlite3_result_int,_sqlite3_result_int64,_sqlite3_result_null,_sqlite3_result_text,_sqlite3_step,_sqlite3_column_count,_sqlite3_column_blob,_sqlite3_column_bytes,_sqlite3_column_double,_sqlite3_column_int64,_sqlite3_column_text,_sqlite3_column_type,_sqlite3_column_name,_sqlite3_column_table_name,_sqlite3_bind_blob,_sqlite3_bind_blob64,_sqlite3_bind_double,_sqlite3_bind_int,_sqlite3_bind_int64,_sqlite3_bind_null,_sqlite3_bind_text,_sqlite3_bind_parameter_index,_sqlite3_exec,_sqlite3_prepare_v2,_sqlite3_errmsg,_sqlite3_last_insert_rowid,_sqlite3_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_finalize=Module["_sqlite3_finalize"]=wasmExports["A"];_sqlite3_reset=Module["_sqlite3_reset"]=wasmExports["B"];_sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=wasmExports["C"];_sqlite3_value_blob=Module["_sqlite3_value_blob"]=wasmExports["D"];_sqlite3_value_text=Module["_sqlite3_value_text"]=wasmExports["E"];_sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=wasmExports["F"];_sqlite3_value_double=Module["_sqlite3_value_double"]=wasmExports["G"];_sqlite3_value_int64=Module["_sqlite3_value_int64"]=wasmExports["H"];_sqlite3_value_type=Module["_sqlite3_value_type"]=wasmExports["I"];_sqlite3_result_blob=Module["_sqlite3_result_blob"]=wasmExports["J"];_sqlite3_result_blob64=Module["_sqlite3_result_blob64"]=wasmExports["K"];_sqlite3_result_double=Module["_sqlite3_result_double"]=wasmExports["L"];_sqlite3_result_error=Module["_sqlite3_result_error"]=wasmExports["M"];_sqlite3_result_int=Module["_sqlite3_result_int"]=wasmExports["N"];_sqlite3_result_int64=Module["_sqlite3_result_int64"]=wasmExports["O"];_sqlite3_result_null=Module["_sqlite3_result_null"]=wasmExports["P"];_sqlite3_result_text=Module["_sqlite3_result_text"]=wasmExports["Q"];_sqlite3_step=Module["_sqlite3_step"]=wasmExports["R"];_sqlite3_column_count=Module["_sqlite3_column_count"]=wasmExports["S"];_sqlite3_column_blob=Module["_sqlite3_column_blob"]=wasmExports["T"];_sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=wasmExports["U"];_sqlite3_column_double=Module["_sqlite3_column_double"]=wasmExports["V"];_sqlite3_column_int64=Module["_sqlite3_column_int64"]=wasmExports["W"];_sqlite3_column_text=Module["_sqlite3_column_text"]=wasmExports["X"];_sqlite3_column_type=Module["_sqlite3_column_type"]=wasmExports["Y"];_sqlite3_column_name=Module["_sqlite3_column_name"]=wasmExports["Z"];_sqlite3_column_table_name=Module["_sqlite3_column_table_name"]=wasmExports["_"];_sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=wasmExports["$"];_sqlite3_bind_blob64=Module["_sqlite3_bind_blob64"]=wasmExports["aa"];_sqlite3_bind_double=Module["_sqlite3_bind_double"]=wasmExports["ba"];_sqlite3_bind_int=Module["_sqlite3_bind_int"]=wasmExports["ca"];_sqlite3_bind_int64=Module["_sqlite3_bind_int64"]=wasmExports["da"];_sqlite3_bind_null=Module["_sqlite3_bind_null"]=wasmExports["ea"];_sqlite3_bind_text=Module["_sqlite3_bind_text"]=wasmExports["fa"];_sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=wasmExports["ga"];_sqlite3_exec=Module["_sqlite3_exec"]=wasmExports["ha"];_sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=wasmExports["ia"];_sqlite3_errmsg=Module["_sqlite3_errmsg"]=wasmExports["ja"];_sqlite3_last_insert_rowid=Module["_sqlite3_last_insert_rowid"]=wasmExports["ka"];_sqlite3_changes=Module["_sqlite3_changes"]=wasmExports["la"];_sqlite3_close_v2=Module["_sqlite3_close_v2"]=wasmExports["ma"];_sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=wasmExports["na"];_sqlite3_open_v2=Module["_sqlite3_open_v2"]=wasmExports["oa"];_sqlite3_get_autocommit=Module["_sqlite3_get_autocommit"]=wasmExports["pa"];_malloc=Module["_malloc"]=wasmExports["qa"];_free=Module["_free"]=wasmExports["ra"];__emscripten_timeout=wasmExports["ta"];__emscripten_stack_restore=wasmExports["ua"];__emscripten_stack_alloc=wasmExports["va"];_emscripten_stack_get_current=wasmExports["wa"];memory=wasmMemory=wasmExports["y"];__indirect_function_table=wasmTable=wasmExports["sa"]}var wasmImports={k:__abort_js,j:__emscripten_runtime_keepalive_clear,o:__localtime_js,l:__setitimer_js,p:__tzset_js,q:_emscripten_date_now,a:_emscripten_get_now,n:_emscripten_resize_heap,w:_nodejsAccess,s:_nodejsCheckReservedLock,f:_nodejsClose,x:_nodejsDelete,v:_nodejsFileSize,m:_nodejsFullPathname,u:_nodejsLock,h:_nodejsRandomness,e:_nodejsRead,b:_nodejsSync,c:_nodejsTruncate,t:_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(); | ||
| var Module=typeof Module!="undefined"?Module:{};var ENVIRONMENT_IS_NODE=true;const INT32_MIN=-2147483648;const INT32_MAX=2147483647;const NULL=0;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;let temp;const sqlite3={};Module.onRuntimeInitialized=()=>{temp=stackAlloc(4);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_blob64:[n,n5],bind_null:[n,n2],bind_parameter_index:[n,[n,s]],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],last_insert_rowid:[n,n1],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_blob64:[v,n4],result_int:[v,n2],result_int64:[v,n2],result_error:[v,n3],column_table_name:[s,n2],get_autocommit:[n,n1]};for(const[name,sig]of Object.entries(signatures)){sqlite3[name]=cwrap(`sqlite3_${name}`,sig[0],sig[1])}};class SQLite3Error extends Error{constructor(message){super(message);this.name="SQLite3Error"}}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(bigInt){if(bigInt>=Number.MIN_SAFE_INTEGER&&bigInt<=Number.MAX_SAFE_INTEGER){return Number(bigInt)}return bigInt}function parseFunctionArguments(argc,argv){const args=[];for(let i=0;i<argc;i++){const ptr=getValue(argv+4*i,"i32");const type=sqlite3.value_type(ptr);let arg;switch(type){case SQLITE_INTEGER:arg=toNumberOrNot(sqlite3.value_int64(ptr));break;case SQLITE_FLOAT:arg=sqlite3.value_double(ptr);break;case SQLITE_TEXT:arg=sqlite3.value_text(ptr);break;case SQLITE_BLOB:const p=sqlite3.value_blob(ptr);if(p!=NULL){arg=HEAPU8.slice(p,p+sqlite3.value_bytes(ptr))}else{arg=new Uint8Array}break;case SQLITE_NULL:arg=null;break}args.push(arg)}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 tempPtr=stringToHeap(result);sqlite3.result_text(cx,tempPtr,-1,SQLITE_TRANSIENT);_free(tempPtr);break;case"object":if(result===null){sqlite3.result_null(cx)}else if(result instanceof Uint8Array){const tempPtr=arrayToHeap(result);if(result.byteLength<=INT32_MAX){sqlite3.result_blob(cx,tempPtr,result.byteLength,SQLITE_TRANSIENT)}else{sqlite3.result_blob64(cx,tempPtr,BigInt(result.byteLength),SQLITE_TRANSIENT)}_free(tempPtr)}else{throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`)}break;default:throw new SQLite3Error(`Unsupported type for function result: "${typeof result}"`)}}class Database{constructor(filename,{fileMustExist=false,readOnly=false}={}){let flags;if(readOnly){flags=SQLITE_OPEN_READONLY}else{flags=SQLITE_OPEN_READWRITE;if(!fileMustExist)flags|=SQLITE_OPEN_CREATE}const rc=sqlite3.open_v2(filename,temp,flags,NULL);this._ptr=getValue(temp,"i32");if(rc!==SQLITE_OK){if(this._ptr!==NULL)sqlite3.close_v2(this._ptr);throw new SQLite3Error(`Could not open the database "${filename}"`)}this._functions=new Map}get isOpen(){return this._ptr!==null}get inTransaction(){this._assertOpen();return sqlite3.get_autocommit(this._ptr)===0}close(){this._assertOpen();for(const func of this._functions.values())removeFunction(func);this._functions.clear();this._handleError(sqlite3.close_v2(this._ptr));this._ptr=null}function(name,func,{deterministic=false}={}){this._assertOpen();function wrappedFunc(cx,argc,argv){const args=parseFunctionArguments(argc,argv);let result;try{result=func.apply(null,args)}catch(err){const tempPtr=stringToHeap(err.toString());sqlite3.result_error(cx,tempPtr,-1);_free(tempPtr);return}setFunctionResult(cx,result)}if(this._functions.has(name)){removeFunction(this._functions.get(name));this._functions.delete(name)}const funcPtr=addFunction(wrappedFunc,"viii");this._functions.set(name,funcPtr);let eTextRep=SQLITE_UTF8;if(deterministic)eTextRep|=SQLITE_DETERMINISTIC;this._handleError(sqlite3.create_function_v2(this._ptr,name,func.length,eTextRep,NULL,funcPtr,NULL,NULL,NULL));return this}exec(sql){this._assertOpen();const tempPtr=stringToHeap(sql);try{this._handleError(sqlite3.exec(this._ptr,tempPtr,NULL,NULL,NULL))}finally{_free(tempPtr)}}prepare(sql){this._assertOpen();return new Statement(this,sql)}run(sql,values){const stmt=this.prepare(sql);try{return stmt.run(values)}finally{stmt.finalize()}}all(sql,values,{expand=false}={}){return this._query(sql,values,false,expand)}get(sql,values,{expand=false}={}){return this._query(sql,values,true,expand)}_query(sql,values,single,expand){const stmt=this.prepare(sql);try{if(single){return stmt.get(values,{expand})}else{return stmt.all(values,{expand})}}finally{stmt.finalize()}}_assertOpen(){if(!this.isOpen)throw new SQLite3Error("Database already closed")}_handleError(returnCode){if(returnCode!==SQLITE_OK)throw new SQLite3Error(sqlite3.errmsg(this._ptr))}}class Statement{constructor(db,sql){const tempPtr=stringToHeap(sql);try{db._handleError(sqlite3.prepare_v2(db._ptr,tempPtr,-1,temp,NULL))}finally{_free(tempPtr)}this._ptr=getValue(temp,"i32");if(this._ptr===NULL)throw new SQLite3Error("Nothing to prepare");this._db=db}get database(){return this._db}get isFinalized(){return this._ptr===null}run(values){this._assertReady();this._bind(values);this._step();return{changes:sqlite3.changes(this._db._ptr),lastInsertRowid:toNumberOrNot(sqlite3.last_insert_rowid(this._db._ptr))}}iterate(values,{expand=false}={}){return this._queryRows(values,expand)}all(values,{expand=false}={}){return Array.from(this.iterate(values,{expand}))}get(values,{expand=false}={}){const result=this._queryRows(values,expand).next();return result.done?null:result.value}finalize(){if(this.isFinalized)throw new SQLite3Error("Statement already finalized");try{this._db._handleError(sqlite3.finalize(this._ptr))}finally{this._ptr=null}}_reset(){return sqlite3.clear_bindings(this._ptr)===SQLITE_OK&&sqlite3.reset(this._ptr)===SQLITE_OK}*_queryRows(values,expand){this._assertReady();this._bind(values);const columns=this._getColumnNames();while(this._step())yield this._getRow(columns,expand)}_bind(values){if(!this._reset()){throw new SQLite3Error("Could not reset statement prior to binding new values")}if(Array.isArray(values)){this._bindArray(values)}else if(values!=null&&typeof values==="object"){this._bindObject(values)}else if(typeof values!=="undefined"){this._bindValue(values,1)}}_step(){const ret=sqlite3.step(this._ptr);switch(ret){case SQLITE_ROW:return true;case SQLITE_DONE:return false;default:this._db._handleError(ret)}}_getRow(columns,expand){const row={};for(let i=0;i<columns.length;i++){let v;const colType=sqlite3.column_type(this._ptr,i);switch(colType){case SQLITE_INTEGER:v=toNumberOrNot(sqlite3.column_int64(this._ptr,i));break;case SQLITE_FLOAT:v=sqlite3.column_double(this._ptr,i);break;case SQLITE_TEXT:v=sqlite3.column_text(this._ptr,i);break;case SQLITE_BLOB:const p=sqlite3.column_blob(this._ptr,i);if(p!=NULL){v=HEAPU8.slice(p,p+sqlite3.column_bytes(this._ptr,i))}else{v=new Uint8Array}break;case SQLITE_NULL:v=null;break}const column=columns[i];if(expand){let table=sqlite3.column_table_name(this._ptr,i);table=table===""?"$":table;if(Object.hasOwn(row,table)){row[table][column]=v}else{row[table]={[column]:v}}}else{row[column]=v}}return row}_getColumnNames(){const names=[];const columns=sqlite3.column_count(this._ptr);for(let i=0;i<columns;i++)names.push(sqlite3.column_name(this._ptr,i));return names}_bindArray(values){for(let i=0;i<values.length;i++)this._bindValue(values[i],i+1)}_bindObject(values){for(const[param,value]of Object.entries(values)){const i=sqlite3.bind_parameter_index(this._ptr,param);if(i===0)throw new SQLite3Error(`Unknown binding parameter: "${param}"`);this._bindValue(value,i)}}_bindValue(value,position){let ret;switch(typeof value){case"string":const tempPtr=stringToHeap(value);ret=sqlite3.bind_text(this._ptr,position,tempPtr,-1,SQLITE_TRANSIENT);_free(tempPtr);break;case"number":if(Number.isSafeInteger(value)){if(value>=INT32_MIN&&value<=INT32_MAX){ret=sqlite3.bind_int(this._ptr,position,value)}else{ret=sqlite3.bind_int64(this._ptr,position,BigInt(value))}}else{ret=sqlite3.bind_double(this._ptr,position,value)}break;case"bigint":ret=sqlite3.bind_int64(this._ptr,position,value);break;case"boolean":ret=sqlite3.bind_int(this._ptr,position,value?1:0);break;case"object":if(value===null){ret=sqlite3.bind_null(this._ptr,position)}else if(value instanceof Uint8Array){const tempPtr=arrayToHeap(value);if(value.byteLength<=INT32_MAX){ret=sqlite3.bind_blob(this._ptr,position,tempPtr,value.byteLength,SQLITE_TRANSIENT)}else{ret=sqlite3.bind_blob64(this._ptr,position,tempPtr,BigInt(value.byteLength),SQLITE_TRANSIENT)}_free(tempPtr)}else{throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`)}break;default:throw new SQLite3Error(`Unsupported type for binding: "${typeof value}"`)}if(ret!==SQLITE_OK)this._db._handleError(ret)}_assertReady(){if(this.isFinalized)throw new SQLite3Error("Statement already finalized");if(!this._db.isOpen)throw new SQLite3Error("Database is closed")}}Module.Database=Database;Module.SQLite3Error=SQLite3Error;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["z"]()}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("node-sqlite3-wasm.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 _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_finalize,_sqlite3_reset,_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_blob64,_sqlite3_result_double,_sqlite3_result_error,_sqlite3_result_int,_sqlite3_result_int64,_sqlite3_result_null,_sqlite3_result_text,_sqlite3_step,_sqlite3_column_count,_sqlite3_column_blob,_sqlite3_column_bytes,_sqlite3_column_double,_sqlite3_column_int64,_sqlite3_column_text,_sqlite3_column_type,_sqlite3_column_name,_sqlite3_column_table_name,_sqlite3_bind_blob,_sqlite3_bind_blob64,_sqlite3_bind_double,_sqlite3_bind_int,_sqlite3_bind_int64,_sqlite3_bind_null,_sqlite3_bind_text,_sqlite3_bind_parameter_index,_sqlite3_exec,_sqlite3_prepare_v2,_sqlite3_errmsg,_sqlite3_last_insert_rowid,_sqlite3_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_finalize=Module["_sqlite3_finalize"]=wasmExports["A"];_sqlite3_reset=Module["_sqlite3_reset"]=wasmExports["B"];_sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=wasmExports["C"];_sqlite3_value_blob=Module["_sqlite3_value_blob"]=wasmExports["D"];_sqlite3_value_text=Module["_sqlite3_value_text"]=wasmExports["E"];_sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=wasmExports["F"];_sqlite3_value_double=Module["_sqlite3_value_double"]=wasmExports["G"];_sqlite3_value_int64=Module["_sqlite3_value_int64"]=wasmExports["H"];_sqlite3_value_type=Module["_sqlite3_value_type"]=wasmExports["I"];_sqlite3_result_blob=Module["_sqlite3_result_blob"]=wasmExports["J"];_sqlite3_result_blob64=Module["_sqlite3_result_blob64"]=wasmExports["K"];_sqlite3_result_double=Module["_sqlite3_result_double"]=wasmExports["L"];_sqlite3_result_error=Module["_sqlite3_result_error"]=wasmExports["M"];_sqlite3_result_int=Module["_sqlite3_result_int"]=wasmExports["N"];_sqlite3_result_int64=Module["_sqlite3_result_int64"]=wasmExports["O"];_sqlite3_result_null=Module["_sqlite3_result_null"]=wasmExports["P"];_sqlite3_result_text=Module["_sqlite3_result_text"]=wasmExports["Q"];_sqlite3_step=Module["_sqlite3_step"]=wasmExports["R"];_sqlite3_column_count=Module["_sqlite3_column_count"]=wasmExports["S"];_sqlite3_column_blob=Module["_sqlite3_column_blob"]=wasmExports["T"];_sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=wasmExports["U"];_sqlite3_column_double=Module["_sqlite3_column_double"]=wasmExports["V"];_sqlite3_column_int64=Module["_sqlite3_column_int64"]=wasmExports["W"];_sqlite3_column_text=Module["_sqlite3_column_text"]=wasmExports["X"];_sqlite3_column_type=Module["_sqlite3_column_type"]=wasmExports["Y"];_sqlite3_column_name=Module["_sqlite3_column_name"]=wasmExports["Z"];_sqlite3_column_table_name=Module["_sqlite3_column_table_name"]=wasmExports["_"];_sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=wasmExports["$"];_sqlite3_bind_blob64=Module["_sqlite3_bind_blob64"]=wasmExports["aa"];_sqlite3_bind_double=Module["_sqlite3_bind_double"]=wasmExports["ba"];_sqlite3_bind_int=Module["_sqlite3_bind_int"]=wasmExports["ca"];_sqlite3_bind_int64=Module["_sqlite3_bind_int64"]=wasmExports["da"];_sqlite3_bind_null=Module["_sqlite3_bind_null"]=wasmExports["ea"];_sqlite3_bind_text=Module["_sqlite3_bind_text"]=wasmExports["fa"];_sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=wasmExports["ga"];_sqlite3_exec=Module["_sqlite3_exec"]=wasmExports["ha"];_sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=wasmExports["ia"];_sqlite3_errmsg=Module["_sqlite3_errmsg"]=wasmExports["ja"];_sqlite3_last_insert_rowid=Module["_sqlite3_last_insert_rowid"]=wasmExports["ka"];_sqlite3_changes=Module["_sqlite3_changes"]=wasmExports["la"];_sqlite3_close_v2=Module["_sqlite3_close_v2"]=wasmExports["ma"];_sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=wasmExports["na"];_sqlite3_open_v2=Module["_sqlite3_open_v2"]=wasmExports["oa"];_sqlite3_get_autocommit=Module["_sqlite3_get_autocommit"]=wasmExports["pa"];_malloc=Module["_malloc"]=wasmExports["qa"];_free=Module["_free"]=wasmExports["ra"];__emscripten_timeout=wasmExports["ta"];__emscripten_stack_restore=wasmExports["ua"];__emscripten_stack_alloc=wasmExports["va"];_emscripten_stack_get_current=wasmExports["wa"];memory=wasmMemory=wasmExports["y"];__indirect_function_table=wasmTable=wasmExports["sa"]}var wasmImports={k:__abort_js,j:__emscripten_runtime_keepalive_clear,o:__localtime_js,l:__setitimer_js,p:__tzset_js,q:_emscripten_date_now,a:_emscripten_get_now,n:_emscripten_resize_heap,w:_nodejsAccess,s:_nodejsCheckReservedLock,f:_nodejsClose,x:_nodejsDelete,v:_nodejsFileSize,m:_nodejsFullPathname,u:_nodejsLock,h:_nodejsRandomness,e:_nodejsRead,b:_nodejsSync,c:_nodejsTruncate,t:_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(); |
+6
-2
| { | ||
| "name": "node-sqlite3-wasm", | ||
| "version": "0.8.53", | ||
| "version": "0.8.54", | ||
| "description": "WebAssembly port of SQLite3 for Node.js with file system access", | ||
@@ -8,2 +8,6 @@ "homepage": "https://github.com/tndrle/node-sqlite3-wasm", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/tndrle/node-sqlite3-wasm" | ||
| }, | ||
| "keywords": [ | ||
@@ -29,3 +33,3 @@ "nodejs", | ||
| "scripts": { | ||
| "_docker": "docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u):$(id -g) emscripten/emsdk:4.0.23", | ||
| "_docker": "docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u):$(id -g) emscripten/emsdk:5.0.2", | ||
| "test": "mocha --timeout 10000", | ||
@@ -32,0 +36,0 @@ "test:coverage": "c8 -r html mocha --timeout 10000", |
+2
-2
| **_node-sqlite3-wasm_** | ||
| [](https://www.npmjs.com/package/node-sqlite3-wasm) | ||
| [](https://www.sqlite.org/index.html) | ||
| [](https://www.sqlite.org/index.html) | ||
@@ -29,3 +29,3 @@ # WebAssembly build of SQLite3 for Node.js | ||
| _node-sqlite3-wasm_ is currently based on SQLite 3.51.2. | ||
| _node-sqlite3-wasm_ is currently based on SQLite 3.52.0. | ||
@@ -32,0 +32,0 @@ ## Getting Started |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
1325721
1.07%1
-50%1
Infinity%