@duckdb/duckdb-wasm-shell
Version:
<img src="https://raw.githubusercontent.com/duckdb/duckdb-wasm/main/misc/duckdb_wasm.svg" height="64">
4 lines • 83.8 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/index.ts", "../package.json", "../src/version.ts", "../src/shell.ts", "../crate/pkg/shell.js", "../src/utils/history_store.ts", "../src/utils/files.ts", "../src/platform.ts"],
"sourcesContent": ["export * from './version';\nexport * from './shell';\nexport { getJsDelivrModule } from './platform';\n", "{\n \"name\": \"@duckdb/duckdb-wasm-shell\",\n \"version\": \"1.29.1-dev132.0\",\n \"description\": \"\",\n \"author\": \"Andre Kohn <kohn.a@outlook.com>\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/duckdb/duckdb-wasm.git\"\n },\n \"keywords\": [\n \"sql\",\n \"duckdb\",\n \"relational\",\n \"database\",\n \"data\",\n \"query\",\n \"wasm\",\n \"analytics\",\n \"olap\",\n \"arrow\",\n \"parquet\",\n \"json\",\n \"csv\"\n ],\n \"dependencies\": {\n \"@duckdb/duckdb-wasm\": \"^1.29.1-dev132.0\",\n \"xterm\": \"^5.3.0\",\n \"xterm-addon-fit\": \"^0.8.0\",\n \"xterm-addon-web-links\": \"^0.9.0\",\n \"xterm-addon-webgl\": \"^0.16.0\"\n },\n \"devDependencies\": {\n \"esbuild\": \"^0.20.2\",\n \"eslint\": \"^8.57.0\",\n \"eslint-plugin-jasmine\": \"^4.1.3\",\n \"eslint-plugin-react\": \"^7.34.0\",\n \"jasmine\": \"^5.1.0\",\n \"jasmine-core\": \"^5.1.2\",\n \"jasmine-spec-reporter\": \"^7.0.0\",\n \"make-dir\": \"^4.0.0\",\n \"prettier\": \"^3.2.5\",\n \"rimraf\": \"^5.0.5\",\n \"wasm-pack\": \"^0.12.1\"\n },\n \"scripts\": {\n \"install:wasmpack\": \"node ../../node_modules/wasm-pack/install.js\",\n \"build:debug\": \"node bundle.mjs debug && tsc --emitDeclarationOnly\",\n \"build:release\": \"node bundle.mjs release && tsc --emitDeclarationOnly\",\n \"lint\": \"eslint src\"\n },\n \"files\": [\n \"dist\",\n \"!dist/types/test\"\n ],\n \"main\": \"dist/shell.cjs\",\n \"module\": \"dist/shell.mjs\",\n \"types\": \"dist/shell.d.ts\",\n \"jsdelivr\": \"dist/shell.cjs\",\n \"unpkg\": \"dist/shell.mjs\",\n \"sideEffects\": false,\n \"exports\": {\n \"./dist/shell_bg.wasm\": \"./dist/shell_bg.wasm\",\n \"./dist/shell.js\": \"./dist/shell.js\",\n \"./dist/shell.cjs\": \"./dist/shell.cjs\",\n \"./dist/shell.mjs\": \"./dist/shell.mjs\",\n \"./dist/shell\": \"./dist/shell.mjs\",\n \".\": {\n \"types\": \"./dist/shell.d.ts\",\n \"import\": \"./dist/shell.mjs\",\n \"require\": \"./dist/shell.cjs\"\n }\n }\n}\n", "import config from '../package.json';\n\nexport const PACKAGE_NAME = config.name;\nexport const PACKAGE_VERSION = config.version;\n\nconst VERSION_PARTS = config.version.split('.');\nexport const PACKAGE_VERSION_MAJOR = VERSION_PARTS[0];\nexport const PACKAGE_VERSION_MINOR = VERSION_PARTS[1];\nexport const PACKAGE_VERSION_PATCH = VERSION_PARTS[2];\n", "import * as duckdb from '@duckdb/duckdb-wasm';\nimport * as shell from '../crate/pkg';\nimport { HistoryStore } from './utils/history_store';\nimport { pickFiles } from './utils/files';\nimport { InstantiationProgress } from '@duckdb/duckdb-wasm/dist/types/src/bindings';\n\nconst hasWebGL = (): boolean => {\n if (duckdb.isSafari()) {\n return false;\n }\n const canvas = document.createElement('canvas') as any;\n const supports = 'probablySupportsContext' in canvas ? 'probablySupportsContext' : 'supportsContext';\n if (supports in canvas) {\n return canvas[supports]('webgl2');\n }\n return 'WebGL2RenderingContext' in window;\n};\n\nclass ShellRuntime {\n database: duckdb.AsyncDuckDB | null;\n history: HistoryStore;\n resizeHandler: (_event: UIEvent) => void;\n hash: string;\n\n constructor(protected container: HTMLDivElement) {\n this.database = null;\n this.history = new HistoryStore();\n this.resizeHandler = (_event: UIEvent) => {\n const rect = container.getBoundingClientRect();\n shell.resize(rect.width, rect.height);\n };\n this.hash = \"\";\n }\n\n public async pickFiles(this: ShellRuntime): Promise<number> {\n if (this.database == null) {\n console.warn('database is not initialized');\n return 0;\n }\n return await pickFiles(this.database!);\n }\n public async downloadFile(this: ShellRuntime, name: string, buffer: Uint8Array): Promise<void> {\n const blob = new Blob([buffer]);\n const link = document.createElement('a');\n link.href = URL.createObjectURL(blob);\n link.download = name;\n link.click();\n }\n public async readClipboardText(this: ShellRuntime): Promise<string> {\n return await navigator.clipboard.readText();\n }\n public async writeClipboardText(this: ShellRuntime, value: string) {\n return await navigator.clipboard.writeText(value);\n }\n public async pushInputToHistory(this: ShellRuntime, value: string) {\n\tconst encode = encodeURIComponent(extraswaps(value));\n\tif (this.hash === \"\")\n\t\tthis.hash = \"queries=v0\";\n\tthis.hash += \",\";\n\tthis.hash += encode;\n\tif (window.location.hash.startsWith(\"#savequeries\"))\n\t\twindow.location.hash = \"savequeries&\" + this.hash;\n const a = document.getElementById(\"hashencoded\");\n\tif (a && a instanceof HTMLAnchorElement)\n\t\ta.href= \"/#\" + this.hash;\n this.history.push(value);\n }\n}\n\ninterface ShellProps {\n shellModule: RequestInfo | URL | Response | BufferSource | WebAssembly.Module;\n container: HTMLDivElement;\n resolveDatabase: (p: duckdb.InstantiationProgressHandler) => Promise<duckdb.AsyncDuckDB>;\n backgroundColor?: string;\n fontFamily?: string;\n}\n\nfunction formatBytes(value: number): string {\n const [multiple, k, suffix] = [1000, 'k', 'B'];\n const exp = (Math.log(value) / Math.log(multiple)) | 0;\n const size = Number((value / Math.pow(multiple, exp)).toFixed(2));\n return `${size} ${exp ? `${k}MGTPEZY`[exp - 1] + suffix : `byte${size !== 1 ? 's' : ''}`}`;\n}\n\nfunction extraswaps(input: string): string {\n // As long as this function is symmetrical, all good\n let res : string = \"\";\n for (let i=0; i<input.length; i++) {\n\tif (input[i] == ' ')\n\t\tres += '-';\n\telse if (input[i] == '-')\n\t\tres += ' ';\n\telse if (input[i] == ';')\n\t\tres += '~';\n\telse if (input[i] == '~')\n\t\tres += ';';\n\telse\n\t\tres += input[i];\n\t}\n\treturn res;\n}\n\nexport async function embed(props: ShellProps) {\n // Initialize the shell\n await shell.default(props.shellModule);\n\n // Embed into container\n const runtime = new ShellRuntime(props.container);\n shell.embed(props.container!, runtime, {\n fontFamily: props.fontFamily ?? 'monospace',\n backgroundColor: props.backgroundColor ?? '#333',\n withWebGL: hasWebGL(),\n });\n props.container.onresize = runtime.resizeHandler;\n\n const TERM_BOLD = '\\x1b[1m';\n const TERM_NORMAL = '\\x1b[m';\n const TERM_CLEAR = '\\x1b[2K\\r';\n\n // Progress handler\n const progressHandler = (progress: InstantiationProgress) => {\n if (progress.bytesTotal > 0) {\n const blocks = Math.max(Math.min(Math.floor((progress.bytesLoaded / progress.bytesTotal) * 10.0), 10.0), 0.0);\n const bar = `${'#'.repeat(blocks)}${'-'.repeat(10 - blocks)}`;\n shell.write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${bar}`);\n } else {\n shell.write(`${TERM_CLEAR}${TERM_BOLD}[ RUN ]${TERM_NORMAL} Loading ${formatBytes(progress.bytesLoaded)}`);\n }\n };\n\n // Attach to the database\n shell.writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} Instantiating DuckDB`);\n runtime.database = await props.resolveDatabase(progressHandler);\n shell.writeln(`${TERM_CLEAR}${TERM_BOLD}[ OK ]${TERM_NORMAL} Instantiating DuckDB`);\n\n // Additional steps\n const step = async (label: string, work: () => Promise<void>) => {\n shell.writeln(`${TERM_BOLD}[ RUN ]${TERM_NORMAL} ${label}`);\n await work();\n shell.writeln(`${TERM_BOLD}[ OK ]${TERM_NORMAL} ${label}`);\n };\n await step('Loading Shell History', async () => {\n await runtime.history.open();\n const [hist, histCursor] = await runtime.history.load();\n shell.loadHistory(hist, histCursor);\n });\n await step('Attaching Shell', async () => {\n shell.configureDatabase(runtime.database);\n });\n\tconst hash = window.location.hash;\n\tconst splits = hash.split(',');\n\tconst sqls : Array<string> = [];\n\tfor (let i=1; i< splits.length; i++) {\n\t\tsqls.push(extraswaps(decodeURIComponent(splits[i])));\n\t\t}\n await step('Rewinding history!', async () => {\n shell.passInitQueries(sqls);\n });\n}\n", "import { getPlatformFeatures, PACKAGE_NAME, PACKAGE_VERSION } from '@duckdb/duckdb-wasm';\nimport { Terminal } from 'xterm';\nimport { FitAddon } from 'xterm-addon-fit';\nimport { WebLinksAddon } from 'xterm-addon-web-links';\nimport { WebglAddon } from 'xterm-addon-webgl';\n\nlet wasm;\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_export_4.set(idx, obj);\n return idx;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nlet cachedUint32ArrayMemory0 = null;\n\nfunction getUint32ArrayMemory0() {\n if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {\n cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);\n }\n return cachedUint32ArrayMemory0;\n}\n\nfunction passArray32ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 4, 4) >>> 0;\n getUint32ArrayMemory0().set(arg, ptr / 4);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nconst CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(state => {\n wasm.__wbindgen_export_6.get(state.dtor)(state.a, state.b)\n});\n\nfunction makeMutClosure(arg0, arg1, dtor, f) {\n const state = { a: arg0, b: arg1, cnt: 1, dtor };\n const real = (...args) => {\n // First up with a closure we increment the internal reference\n // count. This ensures that the Rust closure environment won't\n // be deallocated while we're invoking it.\n state.cnt++;\n const a = state.a;\n state.a = 0;\n try {\n return f(a, state.b, ...args);\n } finally {\n if (--state.cnt === 0) {\n wasm.__wbindgen_export_6.get(state.dtor)(a, state.b);\n CLOSURE_DTORS.unregister(state);\n } else {\n state.a = a;\n }\n }\n };\n real.original = state;\n CLOSURE_DTORS.register(real, state, state);\n return real;\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches && builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nexport function main() {\n wasm.main();\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_export_4.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n/**\n * @param {HTMLElement} elem\n * @param {any} runtime\n * @param {any} options\n */\nexport function embed(elem, runtime, options) {\n const ret = wasm.embed(elem, runtime, options);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n}\n\n/**\n * @param {string} text\n */\nexport function write(text) {\n const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.write(ptr0, len0);\n}\n\n/**\n * @param {string} text\n */\nexport function writeln(text) {\n const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.writeln(ptr0, len0);\n}\n\n/**\n * @param {string} name\n */\nexport function registerOPFSFileName(name) {\n const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.registerOPFSFileName(ptr0, len0);\n}\n\n/**\n * @param {string} name\n * @param {boolean} enable\n */\nexport function collectFileStatistics(name, enable) {\n const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.collectFileStatistics(ptr0, len0, enable);\n}\n\n/**\n * @param {number} _width\n * @param {number} _height\n */\nexport function resize(_width, _height) {\n wasm.resize(_width, _height);\n}\n\n/**\n * @param {Array<any>} history\n * @param {number} cursor\n */\nexport function loadHistory(history, cursor) {\n wasm.loadHistory(history, cursor);\n}\n\n/**\n * @param {Array<any>} queries\n * @returns {Promise<void>}\n */\nexport function passInitQueries(queries) {\n const ret = wasm.passInitQueries(queries);\n return ret;\n}\n\n/**\n * @param {any} db\n * @returns {Promise<void>}\n */\nexport function configureDatabase(db) {\n const ret = wasm.configureDatabase(db);\n return ret;\n}\n\n/**\n * @param {ShellInputContext} ctx\n * @returns {Promise<void>}\n */\nexport function resumeAfterInput(ctx) {\n const ret = wasm.resumeAfterInput(ctx);\n return ret;\n}\n\nfunction __wbg_adapter_26(arg0, arg1, arg2) {\n const ret = wasm.closure81_externref_shim(arg0, arg1, arg2);\n return ret !== 0;\n}\n\nfunction __wbg_adapter_29(arg0, arg1, arg2) {\n wasm.closure184_externref_shim(arg0, arg1, arg2);\n}\n\nfunction __wbg_adapter_221(arg0, arg1, arg2, arg3) {\n wasm.closure1177_externref_shim(arg0, arg1, arg2, arg3);\n}\n\n/**\n * A shell input context\n * @enum {0}\n */\nexport const ShellInputContext = Object.freeze({\n FileInput: 0, \"0\": \"FileInput\",\n});\n/**\n * @enum {0 | 1 | 2}\n */\nexport const WcWidth = Object.freeze({\n Width0: 0, \"0\": \"Width0\",\n Width1: 1, \"1\": \"Width1\",\n Width2: 2, \"2\": \"Width2\",\n});\n\nconst DuckDBConfigFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_duckdbconfig_free(ptr >>> 0, 1));\n\nexport class DuckDBConfig {\n\n static __wrap(ptr) {\n ptr = ptr >>> 0;\n const obj = Object.create(DuckDBConfig.prototype);\n obj.__wbg_ptr = ptr;\n DuckDBConfigFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n DuckDBConfigFinalization.unregister(this);\n return ptr;\n }\n\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_duckdbconfig_free(ptr, 0);\n }\n /**\n * @returns {string | undefined}\n */\n get path() {\n const ret = wasm.duckdbconfig_path(this.__wbg_ptr);\n let v1;\n if (ret[0] !== 0) {\n v1 = getStringFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v1;\n }\n /**\n * @param {string | null} [path]\n */\n set path(path) {\n var ptr0 = isLikeNone(path) ? 0 : passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.duckdbconfig_set_path(this.__wbg_ptr, ptr0, len0);\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbg_attachCustomKeyEventHandler_5c309ad8c2d6ff9c = function(arg0, arg1) {\n arg0.attachCustomKeyEventHandler(arg1);\n };\n imports.wbg.__wbg_backgroundColor_51cf19ee7d4b277a = function(arg0, arg1) {\n const ret = arg1.backgroundColor;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_bigInt64Array_c64b3751e74d5277 = function(arg0) {\n const ret = arg0.bigInt64Array;\n return ret;\n };\n imports.wbg.__wbg_blockSize_cd30a6366d631ae8 = function(arg0) {\n const ret = arg0.blockSize;\n return ret;\n };\n imports.wbg.__wbg_blockStats_7e6019968a50af3b = function(arg0) {\n const ret = arg0.blockStats;\n return ret;\n };\n imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {\n const ret = arg0.buffer;\n return ret;\n };\n imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments) };\n imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments) };\n imports.wbg.__wbg_collectFileStatistics_d40af29ff6fc8c95 = function() { return handleError(function (arg0, arg1, arg2, arg3) {\n const ret = arg0.collectFileStatistics(getStringFromWasm0(arg1, arg2), arg3 !== 0);\n return ret;\n }, arguments) };\n imports.wbg.__wbg_cols_77a8050235d63c90 = function(arg0) {\n const ret = arg0.cols;\n return ret;\n };\n imports.wbg.__wbg_connectInternal_818454f7281c00df = function() { return handleError(function (arg0) {\n const ret = arg0.connectInternal();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_construct_036a353ca42f67b4 = function(arg0) {\n const ret = new Terminal(arg0);\n return ret;\n };\n imports.wbg.__wbg_copyFileToBuffer_83cb2af8941ca82a = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.copyFileToBuffer(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_crossOriginIsolated_0118e2417ec095ee = function(arg0) {\n const ret = arg0.crossOriginIsolated;\n return ret;\n };\n imports.wbg.__wbg_ctrlKey_1e826e468105ac11 = function(arg0) {\n const ret = arg0.ctrlKey;\n return ret;\n };\n imports.wbg.__wbg_disconnect_92d81f4ec3f107ec = function() { return handleError(function (arg0, arg1) {\n const ret = arg0.disconnect(arg1 >>> 0);\n return ret;\n }, arguments) };\n imports.wbg.__wbg_downloadFile_d0dec3d05b3a9f19 = function() { return handleError(function (arg0, arg1, arg2, arg3) {\n const ret = arg0.downloadFile(getStringFromWasm0(arg1, arg2), arg3);\n return ret;\n }, arguments) };\n imports.wbg.__wbg_dropFile_6eb68222192e72fc = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.dropFile(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_dropFiles_8bf37b450b4de5ee = function() { return handleError(function (arg0) {\n const ret = arg0.dropFiles();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n };\n imports.wbg.__wbg_error_ebb9ec1bc5af2f31 = function(arg0, arg1) {\n console.error(getStringFromWasm0(arg0, arg1));\n };\n imports.wbg.__wbg_exportFileStatistics_d52b61d6c201da1c = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.exportFileStatistics(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_fit_0db5c78a2a85f563 = function(arg0) {\n arg0.fit();\n };\n imports.wbg.__wbg_focus_dd92db4314c4db81 = function(arg0) {\n arg0.focus();\n };\n imports.wbg.__wbg_fontFamily_cac93414dbe897cf = function(arg0, arg1) {\n const ret = arg1.fontFamily;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_getFeatureFlags_14afaddbcef26858 = function() { return handleError(function (arg0) {\n const ret = arg0.getFeatureFlags();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_getPlatformFeatures_40454c7f78791eb6 = function() { return handleError(function () {\n const ret = getPlatformFeatures();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_getVersion_32486a199e795762 = function() { return handleError(function (arg0) {\n const ret = arg0.getVersion();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {\n const ret = arg0[arg1 >>> 0];\n return ret;\n };\n imports.wbg.__wbg_globFiles_542704d623854358 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.globFiles(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_instanceof_WebLinksAddon_3750ea42996e2252 = function(arg0) {\n let result;\n try {\n result = arg0 instanceof WebLinksAddon;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_instanceof_WebglAddon_d96a60a43cae1674 = function(arg0) {\n let result;\n try {\n result = arg0 instanceof WebglAddon;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_instanceof_Window_def73ea0955fc569 = function(arg0) {\n let result;\n try {\n result = arg0 instanceof Window;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n };\n imports.wbg.__wbg_key_7b5c6cb539be8e13 = function(arg0, arg1) {\n const ret = arg1.key;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {\n const ret = arg0.length;\n return ret;\n };\n imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {\n const ret = arg0.length;\n return ret;\n };\n imports.wbg.__wbg_loadAddon_143d540bb5725490 = function(arg0, arg1) {\n arg0.loadAddon(arg1);\n };\n imports.wbg.__wbg_log_33ef14fd0c9ec1a3 = function(arg0, arg1) {\n console.log(getStringFromWasm0(arg0, arg1));\n };\n imports.wbg.__wbg_message_97a2af9b89d693a3 = function(arg0) {\n const ret = arg0.message;\n return ret;\n };\n imports.wbg.__wbg_metaKey_e1dd47d709a80ce5 = function(arg0) {\n const ret = arg0.metaKey;\n return ret;\n };\n imports.wbg.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {\n try {\n var state0 = {a: arg0, b: arg1};\n var cb0 = (arg0, arg1) => {\n const a = state0.a;\n state0.a = 0;\n try {\n return __wbg_adapter_221(a, state0.b, arg0, arg1);\n } finally {\n state0.a = a;\n }\n };\n const ret = new Promise(cb0);\n return ret;\n } finally {\n state0.a = state0.b = 0;\n }\n };\n imports.wbg.__wbg_new_405e22f390576ce2 = function() {\n const ret = new Object();\n return ret;\n };\n imports.wbg.__wbg_new_7890702e2f921af0 = function(arg0) {\n const ret = new WebglAddon(arg0 === 0xFFFFFF ? undefined : arg0 !== 0);\n return ret;\n };\n imports.wbg.__wbg_new_7c075f00f439f1e0 = function() {\n const ret = new FitAddon();\n return ret;\n };\n imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {\n const ret = new Error();\n return ret;\n };\n imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {\n const ret = new Uint8Array(arg0);\n return ret;\n };\n imports.wbg.__wbg_new_c2ccb7a35264c397 = function(arg0, arg1, arg2) {\n const ret = new WebLinksAddon(arg0, arg1, arg2 === 0xFFFFFF ? undefined : arg2 !== 0);\n return ret;\n };\n imports.wbg.__wbg_new_c68d7209be747379 = function(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return ret;\n };\n imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return ret;\n };\n imports.wbg.__wbg_now_d18023d54d4e5500 = function(arg0) {\n const ret = arg0.now();\n return ret;\n };\n imports.wbg.__wbg_offsets_9a0c43647dfe8174 = function(arg0, arg1) {\n const ret = arg1.offsets;\n const ptr1 = passArray32ToWasm0(ret, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_open_89ca330653f2b749 = function() { return handleError(function (arg0, arg1) {\n const ret = arg0.open(DuckDBConfig.__wrap(arg1));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_open_ea472ea5209b0983 = function(arg0, arg1) {\n arg0.open(arg1);\n };\n imports.wbg.__wbg_performance_c185c0cdc2766575 = function(arg0) {\n const ret = arg0.performance;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n };\n imports.wbg.__wbg_pickFiles_c443e685aed27e4f = function() { return handleError(function (arg0) {\n const ret = arg0.pickFiles();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_pushInputToHistory_1549e9c17621ffd1 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.pushInputToHistory(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(arg0) {\n queueMicrotask(arg0);\n };\n imports.wbg.__wbg_queueMicrotask_d3219def82552485 = function(arg0) {\n const ret = arg0.queueMicrotask;\n return ret;\n };\n imports.wbg.__wbg_readClipboardText_731ab326db907631 = function() { return handleError(function (arg0) {\n const ret = arg0.readClipboardText();\n return ret;\n }, arguments) };\n imports.wbg.__wbg_registerOPFSFileName_1ac109036d40476f = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.registerOPFSFileName(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_resolve_4851785c9c5f573d = function(arg0) {\n const ret = Promise.resolve(arg0);\n return ret;\n };\n imports.wbg.__wbg_runQuery_dd923bfcee4eae4d = function() { return handleError(function (arg0, arg1, arg2, arg3) {\n const ret = arg0.runQuery(arg1 >>> 0, getStringFromWasm0(arg2, arg3));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {\n arg0.set(arg1, arg2 >>> 0);\n };\n imports.wbg.__wbg_setallowProposedApi_1e56ae3768e93420 = function(arg0, arg1) {\n arg0.allowProposedApi = arg1 !== 0;\n };\n imports.wbg.__wbg_setbackground_94f13d2866b2e31b = function(arg0, arg1, arg2) {\n arg0.background = getStringFromWasm0(arg1, arg2);\n };\n imports.wbg.__wbg_setbrightYellow_5858b72099992f03 = function(arg0, arg1, arg2) {\n arg0.brightYellow = getStringFromWasm0(arg1, arg2);\n };\n imports.wbg.__wbg_setcursorBlink_850e871d6bcda748 = function(arg0, arg1) {\n arg0.cursorBlink = arg1 !== 0;\n };\n imports.wbg.__wbg_setcursorWidth_7899d7d19308befe = function(arg0, arg1) {\n arg0.cursorWidth = arg1 >>> 0;\n };\n imports.wbg.__wbg_setdrawBoldTextInBrightColors_c3276731d7662d87 = function(arg0, arg1) {\n arg0.drawBoldTextInBrightColors = arg1 !== 0;\n };\n imports.wbg.__wbg_setfontFamily_f2837e56dcf1e5a4 = function(arg0, arg1, arg2) {\n arg0.fontFamily = getStringFromWasm0(arg1, arg2);\n };\n imports.wbg.__wbg_setfontSize_7d8e3357cbc2a6ac = function(arg0, arg1) {\n arg0.fontSize = arg1 >>> 0;\n };\n imports.wbg.__wbg_setforeground_bbda7a714f8f4254 = function(arg0, arg1, arg2) {\n arg0.foreground = getStringFromWasm0(arg1, arg2);\n };\n imports.wbg.__wbg_setrightClickSelectsWord_e15e0a6c7e12c2f4 = function(arg0, arg1) {\n arg0.rightClickSelectsWord = arg1 !== 0;\n };\n imports.wbg.__wbg_setrows_395bb2f6a40be664 = function(arg0, arg1) {\n arg0.rows = arg1 >>> 0;\n };\n imports.wbg.__wbg_settheme_1b783323a8d2b858 = function(arg0, arg1) {\n arg0.theme = arg1;\n };\n imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n };\n imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n };\n imports.wbg.__wbg_static_accessor_PACKAGE_NAME_0af717684e189e55 = function(arg0) {\n const ret = PACKAGE_NAME;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_static_accessor_PACKAGE_VERSION_549ba11794cf5003 = function(arg0) {\n const ret = PACKAGE_VERSION;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n };\n imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n };\n imports.wbg.__wbg_then_44b73946d2fb3e7d = function(arg0, arg1) {\n const ret = arg0.then(arg1);\n return ret;\n };\n imports.wbg.__wbg_then_48b406749878a531 = function(arg0, arg1, arg2) {\n const ret = arg0.then(arg1, arg2);\n return ret;\n };\n imports.wbg.__wbg_toString_c813bbd34d063839 = function(arg0) {\n const ret = arg0.toString();\n return ret;\n };\n imports.wbg.__wbg_tokenize_8a1699f08f37e193 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.tokenize(getStringFromWasm0(arg1, arg2));\n return ret;\n }, arguments) };\n imports.wbg.__wbg_totalFileReadsAhead_a8f3246739715872 = function(arg0) {\n const ret = arg0.totalFileReadsAhead;\n return ret;\n };\n imports.wbg.__wbg_totalFileReadsCached_a9d725246d8113de = function(arg0) {\n const ret = arg0.totalFileReadsCached;\n return ret;\n };\n imports.wbg.__wbg_totalFileReadsCold_969fc4fdc92ba928 = function(arg0) {\n const ret = arg0.totalFileReadsCold;\n return ret;\n };\n imports.wbg.__wbg_totalFileWrites_a1979d03072ca561 = function(arg0) {\n const ret = arg0.totalFileWrites;\n return ret;\n };\n imports.wbg.__wbg_totalPageAccesses_d1e0755e7c873650 = function(arg0) {\n const ret = arg0.totalPageAccesses;\n return ret;\n };\n imports.wbg.__wbg_totalPageLoads_055280bed199c515 = function(arg0) {\n const ret = arg0.totalPageLoads;\n return ret;\n };\n imports.wbg.__wbg_type_16f2b8031796512f = function(arg0, arg1) {\n const ret = arg1.type;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_types_10068f549973c623 = function(arg0, arg1) {\n const ret = arg1.types;\n const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbg_warn_45a3a6612d9f19fe = function(arg0, arg1) {\n console.warn(getStringFromWasm0(arg0, arg1));\n };\n imports.wbg.__wbg_wasmBulkMemory_551502ede47fbf09 = function(arg0) {\n const ret = arg0.wasmBulkMemory;\n return ret;\n };\n imports.wbg.__wbg_wasmExceptions_4f3d6bc9c38eccd4 = function(arg0) {\n const ret = arg0.wasmExceptions;\n return ret;\n };\n imports.wbg.__wbg_wasmSIMD_6e524010ac1b3712 = function(arg0) {\n const ret = arg0.wasmSIMD;\n return ret;\n };\n imports.wbg.__wbg_wasmThreads_bb92f1f17739f197 = function(arg0) {\n const ret = arg0.wasmThreads;\n return ret;\n };\n imports.wbg.__wbg_withWebGL_e7b2f98241b8125a = function(arg0) {\n const ret = arg0.withWebGL;\n return ret;\n };\n imports.wbg.__wbg_write_c3295e1c4c88047e = function(arg0, arg1, arg2) {\n arg0.write(getStringFromWasm0(arg1, arg2));\n };\n imports.wbg.__wbindgen_cb_drop = function(arg0) {\n const obj = arg0.original;\n if (obj.cnt-- == 1) {\n obj.a = 0;\n return true;\n }\n const ret = false;\n return ret;\n };\n imports.wbg.__wbindgen_closure_wrapper285 = function(arg0, arg1, arg2) {\n const ret = makeMutClosure(arg0, arg1, 82, __wbg_adapter_26);\n return ret;\n };\n imports.wbg.__wbindgen_closure_wrapper901 = function(arg0, arg1, arg2) {\n const ret = makeMutClosure(arg0, arg1, 185, __wbg_adapter_29);\n return ret;\n };\n imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {\n const ret = debugString(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbindgen_init_externref_table = function() {\n const table = wasm.__wbindgen_export_4;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n ;\n };\n imports.wbg.__wbindgen_is_function = function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n };\n imports.wbg.__wbindgen_is_undefined = function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n };\n imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {\n const obj = arg1;\n const ret = JSON.stringify(obj === undefined ? null : obj);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbindgen_memory = function() {\n const ret = wasm.memory;\n return ret;\n };\n imports.wbg.__wbindgen_number_get = function(arg0, arg1) {\n const obj = arg1;\n const ret = typeof(obj) === 'number' ? obj : undefined;\n getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);\n };\n imports.wbg.__wbindgen_string_get = function(arg0, arg1) {\n const obj = arg1;\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n };\n imports.wbg.__wbindgen_throw = function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n };\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedDataViewMemory0 = null;\n cachedUint32ArrayMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n\n\n wasm.__wbindgen_start();\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('shell_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\n", "const DB_VERSION = 4;\nconst DB_NAME = 'DUCKDB_WASM_SHELL_HISTORY';\nconst TABLE_LOG_INFO = 'LOG_INFO';\nconst TABLE_LOG_ENTRIES = 'LOG_ENTRIES';\nconst HISTORY_SIZE_SHIFT = 10; // 1 << 10 = 1024 elements\n\ninterface LogEntry {\n key: number;\n when: Date;\n input: string;\n}\n\ninterface LogInfo {\n key: number;\n nextEntryKey: number;\n entryCount: number;\n}\n\nexport class HistoryStore {\n protected _idbFactory: IDBFactory;\n protected _idb: IDBDatabase | null;\n protected _nextEntryKey: number;\n protected _entryCount: number;\n\n public constructor() {\n this._idbFactory = window.indexedDB;\n this._idb = null;\n this._nextEntryKey = 0;\n this._entryCount = 0;\n }\n\n /// Load entire history\n public async load(): Promise<[string[], number]> {\n if (this._entryCount == 0) return [[], 0];\n\n // Update in indexeddb\n const tx = this._idb!.transaction([TABLE_LOG_ENTRIES, TABLE_LOG_INFO], 'readwrite');\n const logs = tx.objectStore(TABLE_LOG_ENTRIES);\n const cursor = logs.openCursor();\n\n // Collect all history entries\n return await new Promise((resolve, reject) => {\n const results: string[] = [];\n cursor.onsuccess = event => {\n const req = event.target as IDBRequest<IDBCursorWithValue | null>;\n if (req.result != null) {\n results.push((req.result.value as LogEntry).input);\n req.result.continue();\n } else {\n resolve([results, Math.min(this._nextEntryKey, 1 << HISTORY_SIZE_SHIFT)]);\n }\n };\n cursor.onerror = reject;\n });\n }\n\n /// Open the indexeddb database\n public async open(): Promise<void> {\n // Create the database\n await new Promise((resolve, reject) => {\n const req = this._idbFactory.open(DB_NAME, DB_VERSION);\n req.onupgradeneeded = ev => {\n const openReq = ev.target as IDBOpenDBRequest;\n const idb = openReq.result;\n const tx = openReq.transaction!;\n this.createSchema(idb);\n tx.oncomplete = () => resolve(idb);\n tx.onerror = err => reject(err);\n };\n req.onsuccess = (_: any) => {\n this._idb = req.result;\n resolve(null);\n };\n req.onerror = err => reject(err);\n }).catch(e => console.warn(\"Unable to initialize indexedDB, no history persistence\"));\n\n // Load the metadata\n await this.loadMetadata();\n }\n\n /// Load the log metadata (if persisted)\n protected async loadMetadata(): Promise<void> {\n if (!this._idb)\n return;\n const entry: LogInfo | null = await new Promise((resolve, _reject) => {\n const tx = this._idb!.transaction([TABLE_LOG_INFO]);\n const logInfo = tx.objectStore(TABLE_LOG_INFO);\n const req = logInfo.get(0);\n req.onsuccess = (e: Event) => resolve((e.target as IDBRequest<LogInfo>).result || null);\n req.onerror = (e: Event) => {\n console.warn(e);\n resolve(null);\n };\n });\n this._nextEntryKey = entry?.nextEntryKey || 0;\n this._entryCount = entry?.entryCount || 0;\n }\n\n /// Create the store schema\n protected createSchema(idb: IDBDatabase): void {\n if (idb.objectStoreNames.contains(TABLE_LOG_INFO)) {\n idb.deleteObjectStore(TABLE_LOG_INFO);\n }\n if (idb.objectStoreNames.contains(TABLE_LOG_ENTRIES)) {\n