diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e82530..2fe3a2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ on: jobs: test: name: Run tests - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - name: Use Node.js diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..5304d06 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,24 @@ +# An easy way to run tests locally without Nodejs installed: +# +# docker build -t sqliteviz/test -f Dockerfile.test . +# + +FROM node:12 + +RUN set -ex; \ + apt update; \ + apt install -y chromium firefox-esr; \ + npm install -g npm@7 + +WORKDIR /tmp/build + +COPY package.json package-lock.json ./ +COPY lib lib +RUN npm install + +COPY . . + +RUN set -ex; \ + sed -i 's/browsers: \[.*\],/browsers: ['"'FirefoxHeadlessTouch'"'],/' karma.conf.js + +RUN npm run lint -- --no-fix && npm run test diff --git a/lib/sql-js/Dockerfile b/lib/sql-js/Dockerfile index 6de11dc..bf2dc0b 100644 --- a/lib/sql-js/Dockerfile +++ b/lib/sql-js/Dockerfile @@ -1,4 +1,4 @@ -FROM emscripten/emsdk:2.0.24 +FROM emscripten/emsdk:3.0.1 WORKDIR /tmp/build diff --git a/lib/sql-js/README.md b/lib/sql-js/README.md index bc9a023..7841443 100644 --- a/lib/sql-js/README.md +++ b/lib/sql-js/README.md @@ -43,6 +43,8 @@ SQLite [miscellaneous extensions][3] included: SQLite 3rd party extensions included: 1. [pivot_vtab][5] -- a pivot virtual table +2. `pearson` correlation coefficient function extension from [sqlean][21] + (which is part of [squib][20]) To ease the step to have working clone locally, the build is committed into the repository. @@ -99,3 +101,5 @@ described in [this message from SQLite Forum][12]: [17]: https://sqlite.org/contrib/ [18]: https://sqlite.org/contrib//download/extension-functions.c?get=25 [19]: https://github.com/lana-k/sqliteviz/blob/master/tests/lib/database/sqliteExtensions.spec.js +[20]: https://github.com/mrwilson/squib/blob/master/pearson.c +[21]: https://github.com/nalgeon/sqlean/blob/incubator/src/pearson.c diff --git a/lib/sql-js/benchmark/README.md b/lib/sql-js/benchmark/README.md index b36a276..ad51768 100644 --- a/lib/sql-js/benchmark/README.md +++ b/lib/sql-js/benchmark/README.md @@ -1,14 +1,25 @@ # SQLite WebAssembly build micro-benchmark -This directory contains a micro-benchmark for evaluating SQLite -WebAssembly builds performance on typical SQL queries, run from -`make.sh` script. It can also serve as a smoke test. - -The benchmark operates on a set of SQLite WebAssembly builds expected -in `lib/build-$NAME` directories each containing `sql-wasm.js` and -`sql-wasm.wasm`. Then it creates a Docker image for each, and runs -the benchmark in Firefox and Chromium using Karma in the container. - -After successful run, the benchmark result of each build is contained -in `build-$NAME-result.json`. The JSON result files can be analysed -using `result-analysis.ipynb` Jupyter notebook. +This directory contains a micro-benchmark for evaluating SQLite WebAssembly +builds performance on read and write SQL queries, run from `make.sh` script. If +the script has permission to `nice` processes and [Procpath][1] is installed, +e.g. it is run with `sudo -E env PATH=$PATH ./make.sh`, it'll `renice` all +processes running inside the benchmark containers. It can also serve as a smoke +test (e.g. for memory leaks). + +The benchmark operates on a set of SQLite WebAssembly builds expected in +`lib/build-$NAME` directories each containing `sql-wasm.js` and +`sql-wasm.wasm`. Then it creates a Docker image for each, and runs the +benchmark in Firefox and Chromium using Karma in the container. + +After successful run, the benchmark produces the following per each build: + +- `build-$NAME-result.json` +- `build-$NAME.sqlite` (if Procpath is installed) +- `build-$NAME.svg` (if Procpath is installed) + +These files can be analysed using `result-analysis.ipynb` Jupyter notebook. +The SVG is a chart with CPU and RSS usage of each test container (i.e. Chromium +run, then Firefox run per container). + +[1]: https://pypi.org/project/Procpath/ diff --git a/lib/sql-js/benchmark/make.sh b/lib/sql-js/benchmark/make.sh index 3c68f80..55239a2 100755 --- a/lib/sql-js/benchmark/make.sh +++ b/lib/sql-js/benchmark/make.sh @@ -1,7 +1,8 @@ #!/bin/bash -e cleanup () { - rm -rf lib/dist $flag_file + rm -rf lib/dist "$renice_flag_file" + docker rm -f sqljs-benchmark-run 2> /dev/null || true } trap cleanup EXIT @@ -11,34 +12,36 @@ if [ ! -f sample.csv ]; then | gunzip -c > sample.csv fi +PLAYBOOK=procpath/karma_docker.procpath + # for renice to work run like "sudo -E env PATH=$PATH ./make.sh" -test_ni=$(nice -n -1 nice) -if [ $test_ni == -1 ]; then - flag_file=$(mktemp) +test_ni=$(nice -n -5 nice) +if [ $test_ni == -5 ]; then + renice_flag_file=$(mktemp) fi -( - while [ -f $flag_file ]; do - root_pid=$( - docker ps -f status=running -f name='^sqljs-benchmark-' -q \ - | xargs -r -I{} -- docker inspect -f '{{.State.Pid}}' {} - ) - if [ ! -z $root_pid ]; then - procpath query -d $'\n' "$..children[?(@.stat.pid == $root_pid)]..pid" \ - | xargs -I{} -- renice -n -1 -p {} > /dev/null - fi - sleep 1 - done & -) +{ + while [ -f $renice_flag_file ]; do + procpath --logging-level ERROR play -f $PLAYBOOK renice:watch + done +} & shopt -s nullglob for d in lib/build-* ; do rm -rf lib/dist cp -r $d lib/dist + sample_name=$(basename $d) + + docker build -t sqliteviz/sqljs-benchmark . + docker rm sqljs-benchmark-run 2> /dev/null || true + docker run -d -it --cpus 2 --name sqljs-benchmark-run sqliteviz/sqljs-benchmark + { + rm -f ${sample_name}.sqlite + procpath play -f $PLAYBOOK -o database_file=${sample_name}.sqlite track:record + procpath play -f $PLAYBOOK -o database_file=${sample_name}.sqlite \ + -o plot_file=${sample_name}.svg track:plot + } & - name=$(basename $d) - docker build -t sqliteviz/sqljs-benchmark:$name . - docker rm sqljs-benchmark-$name 2> /dev/null || true - docker run -it --cpus 2 --name sqljs-benchmark-$name sqliteviz/sqljs-benchmark:$name - docker cp sqljs-benchmark-$name:/tmp/build/suite-result.json ${name}-result.json - docker rm sqljs-benchmark-$name + docker attach sqljs-benchmark-run + docker cp sqljs-benchmark-run:/tmp/build/suite-result.json ${sample_name}-result.json + docker rm sqljs-benchmark-run done diff --git a/lib/sql-js/benchmark/procpath/karma_docker.procpath b/lib/sql-js/benchmark/procpath/karma_docker.procpath new file mode 100644 index 0000000..93b0c17 --- /dev/null +++ b/lib/sql-js/benchmark/procpath/karma_docker.procpath @@ -0,0 +1,28 @@ +# This command may run when "sqljs-benchmark-run" does not yet exist or run +[renice:watch] +interval: 2 +repeat: 30 +environment: + ROOT_PID=docker inspect -f "{{.State.Pid}}" sqljs-benchmark-run 2> /dev/null || true +query: + PIDS=$..children[?(@.stat.pid in [$ROOT_PID])]..pid +command: + echo $PIDS | tr , '\n' | xargs --no-run-if-empty -I{} -- renice -n -5 -p {} + +# Expected input arguments: database_file +[track:record] +interval: 1 +stop_without_result: 1 +environment: + ROOT_PID=docker inspect -f "{{.State.Pid}}" sqljs-benchmark-run +query: + $..children[?(@.stat.pid == $ROOT_PID)] +pid_list: $ROOT_PID + +# Expected input arguments: database_file, plot_file +[track:plot] +moving_average_window: 5 +title: Chromium vs Firefox (№1 RSS, №2 CPU) +custom_query_file: + procpath/top2_rss.sql + procpath/top2_cpu.sql diff --git a/lib/sql-js/benchmark/procpath/top2_cpu.sql b/lib/sql-js/benchmark/procpath/top2_cpu.sql new file mode 100644 index 0000000..e4d9509 --- /dev/null +++ b/lib/sql-js/benchmark/procpath/top2_cpu.sql @@ -0,0 +1,29 @@ +WITH diff_all AS ( + SELECT + record_id, + ts, + stat_pid, + stat_utime + stat_stime - LAG(stat_utime + stat_stime) OVER ( + PARTITION BY stat_pid + ORDER BY record_id + ) tick_diff, + ts - LAG(ts) OVER ( + PARTITION BY stat_pid + ORDER BY record_id + ) ts_diff + FROM record +), diff AS ( + SELECT * FROM diff_all WHERE tick_diff IS NOT NULL +), one_time_pid_condition AS ( + SELECT stat_pid + FROM record + GROUP BY 1 + ORDER BY SUM(stat_utime + stat_stime) DESC + LIMIT 2 +) +SELECT + ts, + stat_pid pid, + 100.0 * tick_diff / (SELECT value FROM meta WHERE key = 'clock_ticks') / ts_diff value +FROM diff +JOIN one_time_pid_condition USING(stat_pid) diff --git a/lib/sql-js/benchmark/procpath/top2_rss.sql b/lib/sql-js/benchmark/procpath/top2_rss.sql new file mode 100644 index 0000000..2a1f230 --- /dev/null +++ b/lib/sql-js/benchmark/procpath/top2_rss.sql @@ -0,0 +1,13 @@ +WITH one_time_pid_condition AS ( + SELECT stat_pid + FROM record + GROUP BY 1 + ORDER BY SUM(stat_rss) DESC + LIMIT 2 +) +SELECT + ts, + stat_pid pid, + stat_rss / 1024.0 / 1024 * (SELECT value FROM meta WHERE key = 'page_size') value +FROM record +JOIN one_time_pid_condition USING(stat_pid) diff --git a/lib/sql-js/benchmark/result-analysis.ipynb b/lib/sql-js/benchmark/result-analysis.ipynb index 8ab8c1b..6244f70 100644 --- a/lib/sql-js/benchmark/result-analysis.ipynb +++ b/lib/sql-js/benchmark/result-analysis.ipynb @@ -1,207 +1,205 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "2e7d8525", - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "from pathlib import Path\n", - "\n", - "import pandas\n", - "import plotly.express as px" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "0f420fe2", - "metadata": {}, - "outputs": [], - "source": [ - "benchmark_path = Path()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b7d79c6c", - "metadata": {}, - "outputs": [], - "source": [ - "df_dict = {}\n", - "stat_dict = {}\n", - "for p in benchmark_path.glob('build-*-result.json'):\n", - " build_name = p.stem.split('-', 2)[1]\n", - " for browser_data in json.loads(p.read_text()):\n", - " browser_name = f'{browser_data[\"browser\"][\"name\"]} {browser_data[\"browser\"][\"major\"]}'\n", - " browser_name = browser_name.lower().replace('chrome headless', 'chromium')\n", - " for result in (r for i, r in browser_data['result'].items() if i.isdigit()):\n", - " key = build_name, browser_name, result['name']\n", - " df_dict[key] = result['stats']['sample']\n", - " stat_dict[key] = result['stats']\n", - "\n", - "min_sample_size = min(len(v) for v in df_dict.values())\n", - "df_dict = {k: v[:min_sample_size] for k, v in df_dict.items()}\n", - " \n", - "wide_df = pandas.DataFrame(df_dict).reset_index()\n", - "df = pandas.melt(\n", - " wide_df, \n", - " id_vars='index', \n", - " var_name=['build', 'browser', 'test'], \n", - " value_name='duration',\n", - ")\n", - "df.sort_values(['build', 'index'], inplace=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "bc655c11", - "metadata": {}, - "outputs": [ + "cells": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "pr\tfirefox 88\tselect\t0.20 s ± 1.5%\n", - "master\tfirefox 88\tselect\t0.22 s ± 1.3%\n", - "pr\tchromium 90\tselect\t0.18 s ± 1.1%\n", - "master\tchromium 90\tselect\t0.18 s ± 0.5%\n", - "pr\tfirefox 88\timport\t2.37 s ± 4.3%\n", - "master\tfirefox 88\timport\t2.64 s ± 2.6%\n", - "pr\tchromium 90\timport\t1.67 s ± 0.7%\n", - "master\tchromium 90\timport\t1.74 s ± 1.8%\n" - ] - } - ], - "source": [ - "stat_df = pandas.DataFrame(stat_dict)\n", - "stat_df = stat_df.loc[['mean', 'rme']].transpose()\n", - "stat_df.index = stat_df.index.set_names(['build', 'browser', 'test'])\n", - "stat_df = stat_df.reset_index().sort_values(['test', 'browser'], ascending=False)\n", - "for index, row in stat_df.iterrows():\n", - " print('\\t'.join([\n", - " row['build'],\n", - " row['browser'],\n", - " row['test'],\n", - " f'{row[\"mean\"]:.2f} s ± {row[\"rme\"]:.1f}%'\n", - " ]))" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "5a3ab654", - "metadata": {}, - "outputs": [ + "cell_type": "code", + "source": [ + "import json\n", + "from pathlib import Path\n", + "\n", + "import pandas\n", + "from IPython.display import display, IFrame, Markdown\n", + "from plotly import express" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "collapsed": false, + "outputHidden": false, + "inputHidden": true + } + }, { - "data": { - "image/svg+xml": [ - "chromium 90firefox 880.180.20.220.240.261.522.53buildmasterprbrowserdurationdurationtest=selecttest=import" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "fig = px.box(df, x='browser', y='duration', points='all', color='build', facet_row='test')\n", - "fig.update_yaxes(matches=None)\n", - "fig.show('svg')" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "1619018c", - "metadata": {}, - "outputs": [ + "cell_type": "code", + "source": [ + "render_format = 'svg'\n", + "benchmark_path = Path()\n", + "df_dict = {}\n", + "stat_dict = {}\n", + "for p in benchmark_path.glob('build-*-result.json'):\n", + " build_name = p.stem.split('-', 2)[1]\n", + " for browser_data in json.loads(p.read_text()):\n", + " browser_name = f'{browser_data[\"browser\"][\"name\"]} {browser_data[\"browser\"][\"major\"]}'\n", + " browser_name = browser_name.lower().replace('chrome headless', 'chromium')\n", + " for result in (r for i, r in browser_data['result'].items() if i.isdigit()):\n", + " key = build_name, browser_name, result['name']\n", + " df_dict[key] = result['stats']['sample']\n", + " stat_dict[key] = result['stats']\n", + "\n", + "min_sample_size = min(len(v) for v in df_dict.values())\n", + "df_dict = {k: v[:min_sample_size] for k, v in df_dict.items()}\n", + " \n", + "wide_df = pandas.DataFrame(df_dict).reset_index()\n", + "df = pandas.melt(\n", + " wide_df, \n", + " id_vars='index', \n", + " var_name=['build', 'browser', 'test'], \n", + " value_name='duration',\n", + ")\n", + "df = df.rename(columns={'index': 'run'})\n", + "df.sort_values(['build', 'run'], inplace=True)" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "inputHidden": true, + "outputExpanded": false + } + }, { - "data": { - "image/svg+xml": [ - "0102030400.180.20.220102030401.61.822.2buildmasterprindexindexdurationdurationbrowser=chromium 90browser=firefox 88test=selecttest=import" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "fig = px.line(\n", - " df, x='index', y='duration', color='build', facet_col='browser', facet_row='test'\n", - ")\n", - "fig.update_yaxes(matches=None)\n", - "fig.show('svg')" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "397b848c", - "metadata": {}, - "outputs": [ + "cell_type": "markdown", + "source": [ + "# sql.js build comparison\n", + "\n", + "" + ], + "metadata": {} + }, + { + "cell_type": "code", + "source": [ + "stat_df = pandas.DataFrame(stat_dict)\n", + "stat_df = stat_df.loc[['mean', 'rme']].transpose()\n", + "stat_df.index = stat_df.index.set_names(['build', 'browser', 'test'])\n", + "stat_df = stat_df.reset_index().sort_values(['test', 'browser'], ascending=False)\n", + "for index, row in stat_df.iterrows():\n", + " print('\\t'.join([\n", + " row['build'],\n", + " row['browser'],\n", + " row['test'],\n", + " f'{row[\"mean\"]:.2f} s ± {row[\"rme\"]:.1f}%'\n", + " ]))" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "inputHidden": true, + "outputExpanded": false + } + }, + { + "cell_type": "code", + "source": [ + "fig = express.box(df, x='browser', y='duration', points='all', color='build', facet_row='test')\n", + "fig.update_yaxes(matches=None)\n", + "fig.show(render_format)" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "inputHidden": true, + "outputExpanded": false + } + }, + { + "cell_type": "code", + "source": [ + "fig = express.line(\n", + " df, x='run', y='duration', color='build', facet_col='browser', facet_row='test'\n", + ")\n", + "fig.update_yaxes(matches=None)\n", + "fig.show(render_format)" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "inputHidden": true, + "outputExpanded": false + } + }, { - "data": { - "image/svg+xml": [ - "-2.43%-8.26%chromium 90firefox 8800.050.10.150.2-3.88%-10.15%012buildmasterprbrowserdurationdurationtest=selecttest=import" - ] - }, - "metadata": {}, - "output_type": "display_data" + "cell_type": "code", + "source": [ + "plot_df = df.groupby(['browser', 'build', 'test'])['duration'].mean().reset_index()\n", + "plot_df['pct'] = (\n", + " plot_df\n", + " .groupby(['browser', 'test'])['duration']\n", + " .pct_change()\n", + " .fillna('')\n", + " .map(lambda v: '{:.2%}'.format(v) if v else v)\n", + ")\n", + "fig = express.bar(\n", + " plot_df, \n", + " x='browser', \n", + " y='duration', \n", + " color='build', \n", + " text='pct', \n", + " barmode='overlay', \n", + " facet_row='test',\n", + ")\n", + "fig.update_yaxes(matches=None)\n", + "fig.show(render_format)" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "inputHidden": true, + "outputExpanded": false + } + }, + { + "cell_type": "code", + "source": [ + "for p in sorted(benchmark_path.glob('build-*.svg')):\n", + " display(Markdown(p.stem))\n", + " display(IFrame(p, 640, 480))" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "collapsed": false, + "outputHidden": false, + "inputHidden": true, + "outputExpanded": false + } + } + ], + "metadata": { + "kernelspec": { + "name": "stats", + "language": "python", + "display_name": "Stats (Python 3.10)" + }, + "language_info": { + "name": "python", + "version": "3.10.7", + "mimetype": "text/x-python", + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "pygments_lexer": "ipython3", + "nbconvert_exporter": "python", + "file_extension": ".py" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + }, + "kernel_info": { + "name": "stats" + }, + "nteract": { + "version": "0.14.5" } - ], - "source": [ - "plot_df = df.groupby(['browser', 'build', 'test'])['duration'].mean().reset_index()\n", - "plot_df['pct'] = (\n", - " plot_df\n", - " .groupby(['browser', 'test'])['duration']\n", - " .pct_change()\n", - " .fillna('')\n", - " .map(lambda v: '{:.2%}'.format(v) if v else v)\n", - ")\n", - "fig = px.bar(\n", - " plot_df, \n", - " x='browser', \n", - " y='duration', \n", - " color='build', \n", - " text='pct', \n", - " barmode='overlay', \n", - " facet_row='test',\n", - ")\n", - "fig.update_yaxes(matches=None)\n", - "fig.show('svg')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Stats Python 3", - "language": "python", - "name": "stats" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.9" }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file diff --git a/lib/sql-js/build.py b/lib/sql-js/build.py index bdb2b27..13c8313 100644 --- a/lib/sql-js/build.py +++ b/lib/sql-js/build.py @@ -2,9 +2,11 @@ import subprocess from pathlib import Path - +# See the setting descriptions on these pages: +# - https://emscripten.org/docs/optimizing/Optimizing-Code.html +# - https://github.com/emscripten-core/emscripten/blob/main/src/settings.js cflags = ( - '-O2', + # SQLite configuration '-DSQLITE_DEFAULT_CACHE_SIZE=-65536', # 64 MiB '-DSQLITE_DEFAULT_MEMSTATUS=0', '-DSQLITE_DEFAULT_SYNCHRONOUS=0', @@ -13,26 +15,26 @@ '-DSQLITE_ENABLE_FTS3', '-DSQLITE_ENABLE_FTS3_PARENTHESIS', '-DSQLITE_ENABLE_FTS5', - '-DSQLITE_ENABLE_JSON1', '-DSQLITE_ENABLE_NORMALIZE', '-DSQLITE_EXTRA_INIT=extra_init', '-DSQLITE_OMIT_DEPRECATED', '-DSQLITE_OMIT_LOAD_EXTENSION', '-DSQLITE_OMIT_SHARED_CACHE', '-DSQLITE_THREADSAFE=0', + # Compile-time optimisation + '-Os', # reduces the code size about in half comparing to -O2 + '-flto', ) emflags = ( # Base '--memory-init-file', '0', - '-s', 'RESERVED_FUNCTION_POINTERS=64', '-s', 'ALLOW_TABLE_GROWTH=1', - '-s', 'SINGLE_FILE=0', # WASM '-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', - # Optimisation - '-s', 'INLINING_LIMIT=50', - '-O3', + '-s', 'ENVIRONMENT=web,worker', + # Link-time optimisation + '-Os', '-flto', # sql.js '-s', 'EXPORTED_FUNCTIONS=@src/sqljs/exported_functions.json', @@ -50,22 +52,22 @@ def build(src: Path, dst: Path): 'emcc', *cflags, '-c', src / 'sqlite3.c', - '-o', out / 'sqlite3.bc', + '-o', out / 'sqlite3.o', ]) logging.info('Building LLVM bitcode for extension-functions.c') subprocess.check_call([ 'emcc', *cflags, '-c', src / 'extension-functions.c', - '-o', out / 'extension-functions.bc', + '-o', out / 'extension-functions.o', ]) logging.info('Building WASM from bitcode') subprocess.check_call([ 'emcc', *emflags, - out / 'sqlite3.bc', - out / 'extension-functions.bc', + out / 'sqlite3.o', + out / 'extension-functions.o', '-o', out / 'sql-wasm.js', ]) diff --git a/lib/sql-js/configure.py b/lib/sql-js/configure.py index 4839cb1..7d1ed26 100644 --- a/lib/sql-js/configure.py +++ b/lib/sql-js/configure.py @@ -8,7 +8,7 @@ from urllib import request -amalgamation_url = 'https://sqlite.org/2022/sqlite-amalgamation-3390000.zip' +amalgamation_url = 'https://sqlite.org/2023/sqlite-amalgamation-3410000.zip' # Extension-functions # =================== @@ -28,10 +28,11 @@ ('https://sqlite.org/src/raw/09f967dc?at=decimal.c', 'sqlite3_decimal_init'), # Third-party extension # ===================== - ('https://github.com/jakethaw/pivot_vtab/raw/08ab0797/pivot_vtab.c', 'sqlite3_pivotvtab_init'), + ('https://github.com/jakethaw/pivot_vtab/raw/9323ef93/pivot_vtab.c', 'sqlite3_pivotvtab_init'), + ('https://github.com/nalgeon/sqlean/raw/95e8d21a/src/pearson.c', 'sqlite3_pearson_init'), ) -sqljs_url = 'https://github.com/sql-js/sql.js/archive/refs/tags/v1.5.0.zip' +sqljs_url = 'https://github.com/sql-js/sql.js/archive/refs/tags/v1.7.0.zip' def _generate_extra_init_c_function(init_function_names): diff --git a/lib/sql-js/dist/sql-wasm.js b/lib/sql-js/dist/sql-wasm.js index 31a3155..3b48acf 100644 --- a/lib/sql-js/dist/sql-wasm.js +++ b/lib/sql-js/dist/sql-wasm.js @@ -69,7 +69,7 @@ var initSqlJs = function (moduleConfig) { // The emcc-generated code and shell-post.js code goes below, // meaning that all of it runs inside of this promise. If anything throws an exception, our promise will abort -var Module=typeof Module!=="undefined"?Module:{};null;Module["onRuntimeInitialized"]=function onRuntimeInitialized(){var apiTemp=stackAlloc(4);var cwrap=Module["cwrap"];var NULL=0;var SQLITE_OK=0;var SQLITE_ROW=100;var SQLITE_DONE=101;var SQLITE_INTEGER=1;var SQLITE_FLOAT=2;var SQLITE_TEXT=3;var SQLITE_BLOB=4;var SQLITE_UTF8=1;var sqlite3_open=cwrap("sqlite3_open","number",["string","number"]);var sqlite3_close_v2=cwrap("sqlite3_close_v2","number",["number"]);var sqlite3_exec=cwrap("sqlite3_exec","number",["number","string","number","number","number"]);var sqlite3_changes=cwrap("sqlite3_changes","number",["number"]);var sqlite3_prepare_v2=cwrap("sqlite3_prepare_v2","number",["number","string","number","number","number"]);var sqlite3_sql=cwrap("sqlite3_sql","string",["number"]);var sqlite3_normalized_sql=cwrap("sqlite3_normalized_sql","string",["number"]);var sqlite3_prepare_v2_sqlptr=cwrap("sqlite3_prepare_v2","number",["number","number","number","number","number"]);var sqlite3_bind_text=cwrap("sqlite3_bind_text","number",["number","number","number","number","number"]);var sqlite3_bind_blob=cwrap("sqlite3_bind_blob","number",["number","number","number","number","number"]);var sqlite3_bind_double=cwrap("sqlite3_bind_double","number",["number","number","number"]);var sqlite3_bind_int=cwrap("sqlite3_bind_int","number",["number","number","number"]);var sqlite3_bind_parameter_index=cwrap("sqlite3_bind_parameter_index","number",["number","string"]);var sqlite3_step=cwrap("sqlite3_step","number",["number"]);var sqlite3_errmsg=cwrap("sqlite3_errmsg","string",["number"]);var sqlite3_column_count=cwrap("sqlite3_column_count","number",["number"]);var sqlite3_data_count=cwrap("sqlite3_data_count","number",["number"]);var sqlite3_column_double=cwrap("sqlite3_column_double","number",["number","number"]);var sqlite3_column_text=cwrap("sqlite3_column_text","string",["number","number"]);var sqlite3_column_blob=cwrap("sqlite3_column_blob","number",["number","number"]);var sqlite3_column_bytes=cwrap("sqlite3_column_bytes","number",["number","number"]);var sqlite3_column_type=cwrap("sqlite3_column_type","number",["number","number"]);var sqlite3_column_name=cwrap("sqlite3_column_name","string",["number","number"]);var sqlite3_reset=cwrap("sqlite3_reset","number",["number"]);var sqlite3_clear_bindings=cwrap("sqlite3_clear_bindings","number",["number"]);var sqlite3_finalize=cwrap("sqlite3_finalize","number",["number"]);var sqlite3_create_function_v2=cwrap("sqlite3_create_function_v2","number",["number","string","number","number","number","number","number","number","number"]);var sqlite3_value_type=cwrap("sqlite3_value_type","number",["number"]);var sqlite3_value_bytes=cwrap("sqlite3_value_bytes","number",["number"]);var sqlite3_value_text=cwrap("sqlite3_value_text","string",["number"]);var sqlite3_value_blob=cwrap("sqlite3_value_blob","number",["number"]);var sqlite3_value_double=cwrap("sqlite3_value_double","number",["number"]);var sqlite3_result_double=cwrap("sqlite3_result_double","",["number","number"]);var sqlite3_result_null=cwrap("sqlite3_result_null","",["number"]);var sqlite3_result_text=cwrap("sqlite3_result_text","",["number","string","number","number"]);var sqlite3_result_blob=cwrap("sqlite3_result_blob","",["number","number","number","number"]);var sqlite3_result_int=cwrap("sqlite3_result_int","",["number","number"]);var sqlite3_result_error=cwrap("sqlite3_result_error","",["number","string","number"]);var registerExtensionFunctions=cwrap("RegisterExtensionFunctions","number",["number"]);function Statement(stmt1,db){this.stmt=stmt1;this.db=db;this.pos=1;this.allocatedmem=[]}Statement.prototype["bind"]=function bind(values){if(!this.stmt){throw"Statement closed"}this["reset"]();if(Array.isArray(values))return this.bindFromArray(values);if(values!=null&&typeof values==="object"){return this.bindFromObject(values)}return true};Statement.prototype["step"]=function step(){if(!this.stmt){throw"Statement closed"}this.pos=1;var ret=sqlite3_step(this.stmt);switch(ret){case SQLITE_ROW:return true;case SQLITE_DONE:return false;default:throw this.db.handleError(ret)}};Statement.prototype.getNumber=function getNumber(pos){if(pos==null){pos=this.pos;this.pos+=1}return sqlite3_column_double(this.stmt,pos)};Statement.prototype.getString=function getString(pos){if(pos==null){pos=this.pos;this.pos+=1}return sqlite3_column_text(this.stmt,pos)};Statement.prototype.getBlob=function getBlob(pos){if(pos==null){pos=this.pos;this.pos+=1}var size=sqlite3_column_bytes(this.stmt,pos);var ptr=sqlite3_column_blob(this.stmt,pos);var result=new Uint8Array(size);for(var i=0;i>>0);if(data!=null){FS.createDataFile("/",this.filename,data,true,true)}this.handleError(sqlite3_open(this.filename,apiTemp));this.db=getValue(apiTemp,"i32");registerExtensionFunctions(this.db);this.statements={};this.functions={}}Database.prototype["run"]=function run(sql,params){if(!this.db){throw"Database closed"}if(params){var stmt=this["prepare"](sql,params);try{stmt["step"]()}finally{stmt["free"]()}}else{this.handleError(sqlite3_exec(this.db,sql,0,0,apiTemp))}return this};Database.prototype["exec"]=function exec(sql,params){if(!this.db){throw"Database closed"}var stack=stackSave();var stmt=null;try{var nextSqlPtr=allocateUTF8OnStack(sql);var pzTail=stackAlloc(4);var results=[];while(getValue(nextSqlPtr,"i8")!==NULL){setValue(apiTemp,0,"i32");setValue(pzTail,0,"i32");this.handleError(sqlite3_prepare_v2_sqlptr(this.db,nextSqlPtr,-1,apiTemp,pzTail));var pStmt=getValue(apiTemp,"i32");nextSqlPtr=getValue(pzTail,"i32");if(pStmt!==NULL){var curresult=null;stmt=new Statement(pStmt,this);if(params!=null){stmt.bind(params)}while(stmt["step"]()){if(curresult===null){curresult={columns:stmt["getColumnNames"](),values:[]};results.push(curresult)}curresult["values"].push(stmt["get"]())}stmt["free"]()}}return results}catch(errCaught){if(stmt)stmt["free"]();throw errCaught}finally{stackRestore(stack)}};Database.prototype["each"]=function each(sql,params,callback,done){var stmt;if(typeof params==="function"){done=callback;callback=params;params=undefined}stmt=this["prepare"](sql,params);try{while(stmt["step"]()){callback(stmt["getAsObject"]())}}finally{stmt["free"]()}if(typeof done==="function"){return done()}return undefined};Database.prototype["prepare"]=function prepare(sql,params){setValue(apiTemp,0,"i32");this.handleError(sqlite3_prepare_v2(this.db,sql,-1,apiTemp,NULL));var pStmt=getValue(apiTemp,"i32");if(pStmt===NULL){throw"Nothing to prepare"}var stmt=new Statement(pStmt,this);if(params!=null){stmt.bind(params)}this.statements[pStmt]=stmt;return stmt};Database.prototype["iterateStatements"]=function iterateStatements(sql){return new StatementIterator(sql,this)};Database.prototype["export"]=function exportDatabase(){Object.values(this.statements).forEach(function each(stmt){stmt["free"]()});Object.values(this.functions).forEach(removeFunction);this.functions={};this.handleError(sqlite3_close_v2(this.db));var binaryDb=FS.readFile(this.filename,{encoding:"binary"});this.handleError(sqlite3_open(this.filename,apiTemp));this.db=getValue(apiTemp,"i32");return binaryDb};Database.prototype["close"]=function close(){if(this.db===null){return}Object.values(this.statements).forEach(function each(stmt){stmt["free"]()});Object.values(this.functions).forEach(removeFunction);this.functions={};this.handleError(sqlite3_close_v2(this.db));FS.unlink("/"+this.filename);this.db=null};Database.prototype["handleError"]=function handleError(returnCode){var errmsg;if(returnCode===SQLITE_OK){return null}errmsg=sqlite3_errmsg(this.db);throw new Error(errmsg)};Database.prototype["getRowsModified"]=function getRowsModified(){return sqlite3_changes(this.db)};Database.prototype["create_function"]=function create_function(name,func){function wrapped_func(cx,argc,argv){var result;function extract_blob(ptr){var size=sqlite3_value_bytes(ptr);var blob_ptr=sqlite3_value_blob(ptr);var blob_arg=new Uint8Array(size);for(var j=0;j1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){return read(f)}}readBinary=function readBinary(f){var data;if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;return Math.ceil(size/factor)*factor}function convertJsFunctionToWasm(func,sig){if(typeof WebAssembly.Function==="function"){var typeNames={"i":"i32","j":"i64","f":"f32","d":"f64"};var type={parameters:[],results:sig[0]=="v"?[]:[typeNames[sig[0]]]};for(var i=1;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for getValue: "+type)}return null}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(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=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}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}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function allocateUTF8OnStack(str){var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="sql-wasm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["L"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Da"];addOnInit(Module["asm"]["M"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){var result=WebAssembly.instantiate(binary,info);return result}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}function demangle(func){return func}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function jsStackTrace(){var error=new Error;if(!error.stack){try{throw new Error}catch(e){error=e}if(!error.stack){return"(no stack trace available)"}}return error.stack.toString()}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}function _tzset(){if(_tzset.called)return;_tzset.called=true;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);HEAP32[__get_timezone()>>2]=stdTimezoneOffset*60;HEAP32[__get_daylight()>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAP32[__get_tzname()+4>>2]=summerNamePtr}else{HEAP32[__get_tzname()>>2]=summerNamePtr;HEAP32[__get_tzname()+4>>2]=winterNamePtr}}function _localtime_r(time,tmPtr){_tzset();var date=new Date(HEAP32[time>>2]*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 start=new Date(date.getFullYear(),0,1);var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);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 zonePtr=HEAP32[__get_tzname()+(dst?4:0)>>2];HEAP32[tmPtr+40>>2]=zonePtr;return tmPtr}function ___localtime_r(a0,a1){return _localtime_r(a0,a1)}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto==="object"&&typeof crypto["getRandomValues"]==="function"){var randomBuffer=new Uint8Array(1);return function(){crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");return function(){return crypto_module["randomBytes"](1)[0]}}catch(e){}}return function(){abort("randomDevice")}}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:function(from,to){from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function mmapAlloc(size){var alignedSize=alignMemory(size,65536);var ptr=_malloc(alignedSize);while(size=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:function(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:function(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:function(node){FS.hashRemoveNode(node)},isRoot:function(node){return node===node.parent},isMountpoint:function(node){return!!node.mounted},isFile:function(mode){return(mode&61440)===32768},isDir:function(mode){return(mode&61440)===16384},isLink:function(mode){return(mode&61440)===40960},isChrdev:function(mode){return(mode&61440)===8192},isBlkdev:function(mode){return(mode&61440)===24576},isFIFO:function(mode){return(mode&61440)===4096},isSocket:function(mode){return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:function(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:function(dir){var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:function(dir,name){try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:function(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:function(fd){return FS.streams[fd]},createStream:function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=function(){};FS.FSStream.prototype={object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:function(fd){FS.streams[fd]=null},chrdev_stream_ops:{open:function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:function(){throw new FS.ErrnoError(70)}},major:function(dev){return dev>>8},minor:function(dev){return dev&255},makedev:function(ma,mi){return ma<<8|mi},registerDevice:function(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:function(dev){return FS.devices[dev]},getMounts:function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:function(parent,name){return parent.node_ops.lookup(parent,name)},mknod:function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:function(path,mode){var dirs=path.split("/");var d="";for(var i=0;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}};var lazyArray=this;lazyArray.setDataGetter(function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){FS.forceLoadFile(node);var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i>2]=stat.dev;HEAP32[buf+4>>2]=0;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP32[buf+32>>2]=0;tempI64=[stat.size>>>0,(tempDouble=stat.size,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+40>>2]=tempI64[0],HEAP32[buf+44>>2]=tempI64[1];HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP32[buf+56>>2]=stat.atime.getTime()/1e3|0;HEAP32[buf+60>>2]=0;HEAP32[buf+64>>2]=stat.mtime.getTime()/1e3|0;HEAP32[buf+68>>2]=0;HEAP32[buf+72>>2]=stat.ctime.getTime()/1e3|0;HEAP32[buf+76>>2]=0;tempI64=[stat.ino>>>0,(tempDouble=stat.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+80>>2]=tempI64[0],HEAP32[buf+84>>2]=tempI64[1];return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},doMkdir:function(path,mode){path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0},doMknod:function(path,mode,dev){switch(mode&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}FS.mknod(path,mode,dev);return 0},doReadlink:function(path,buf,bufsize){if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len},doAccess:function(path,amode){if(amode&~7){return-28}var node;var lookup=FS.lookupPath(path,{follow:true});node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0},doDup:function(path,flags,suggestFD){var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.open(path,flags,0,suggestFD,suggestFD).fd},doReadv:function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream},get64:function(low,high){return low}};function ___sys_access(path,amode){try{path=SYSCALLS.getStr(path);return SYSCALLS.doAccess(path,amode)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_chmod(path,mode){try{path=SYSCALLS.getStr(path);FS.chmod(path,mode);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_chown32(path,owner,group){try{path=SYSCALLS.getStr(path);FS.chown(path,owner,group);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_fchmod(fd,mode){try{FS.fchmod(fd,mode);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_fchown32(fd,owner,group){try{FS.fchown(fd,owner,group);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.open(stream.path,stream.flags,0,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 12:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 13:case 14:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_ftruncate64(fd,zero,low,high){try{var length=SYSCALLS.get64(low,high);FS.ftruncate(fd,length);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd);if(size>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=2147483648;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,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var _emscripten_get_now;if(ENVIRONMENT_IS_NODE){_emscripten_get_now=function(){var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else if(typeof dateNow!=="undefined"){_emscripten_get_now=dateNow}else _emscripten_get_now=function(){return performance.now()};function _emscripten_thread_sleep(msecs){var start=_emscripten_get_now();while(_emscripten_get_now()-start>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_read(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{var stream=SYSCALLS.getStreamFromFD(fd);var HIGH_OFFSET=4294967296;var offset=offset_high*HIGH_OFFSET+(offset_low>>>0);var DOUBLE_LIMIT=9007199254740992;if(offset<=-DOUBLE_LIMIT||offset>=DOUBLE_LIMIT){return-61}FS.llseek(stream,offset,whence);tempI64=[stream.position>>>0,(tempDouble=stream.position,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[newOffset>>2]=tempI64[0],HEAP32[newOffset+4>>2]=tempI64[1];if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_sync(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);if(stream.stream_ops&&stream.stream_ops.fsync){return-stream.stream_ops.fsync(stream)}return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doWritev(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _gettimeofday(ptr){var now=Date.now();HEAP32[ptr>>2]=now/1e3|0;HEAP32[ptr+4>>2]=now%1e3*1e3|0;return 0}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function setFileTime(path,time){path=UTF8ToString(path);try{FS.utime(path,time,time);return 0}catch(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();setErrNo(e.errno);return-1}}function _utimes(path,times){var time;if(times){var mtime=times+8;time=HEAP32[mtime>>2]*1e3;time+=HEAP32[mtime+4>>2]/1e3}else{time=Date.now()}return setFileTime(path,time)}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"a":___assert_fail,"q":___localtime_r,"H":___sys_access,"u":___sys_chmod,"C":___sys_chown32,"v":___sys_fchmod,"D":___sys_fchown32,"b":___sys_fcntl64,"r":___sys_fstat64,"F":___sys_ftruncate64,"g":___sys_getcwd,"B":___sys_geteuid32,"c":___sys_getpid,"t":___sys_lstat64,"s":___sys_mkdir,"z":___sys_mmap2,"A":___sys_munmap,"x":___sys_open,"E":___sys_readlink,"j":___sys_rmdir,"f":___sys_stat64,"i":___sys_unlink,"w":_emscripten_get_heap_max,"l":_emscripten_memcpy_big,"d":_emscripten_resize_heap,"p":_emscripten_thread_sleep,"n":_environ_get,"o":_environ_sizes_get,"e":_fd_close,"m":_fd_fdstat_get,"G":_fd_read,"k":_fd_seek,"I":_fd_sync,"h":_fd_write,"J":_gettimeofday,"K":_time,"y":_utimes};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["M"]).apply(null,arguments)};var _memset=Module["_memset"]=function(){return(_memset=Module["_memset"]=Module["asm"]["N"]).apply(null,arguments)};var _sqlite3_free=Module["_sqlite3_free"]=function(){return(_sqlite3_free=Module["_sqlite3_free"]=Module["asm"]["O"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["P"]).apply(null,arguments)};var _sqlite3_step=Module["_sqlite3_step"]=function(){return(_sqlite3_step=Module["_sqlite3_step"]=Module["asm"]["Q"]).apply(null,arguments)};var _sqlite3_finalize=Module["_sqlite3_finalize"]=function(){return(_sqlite3_finalize=Module["_sqlite3_finalize"]=Module["asm"]["R"]).apply(null,arguments)};var _sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=function(){return(_sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=Module["asm"]["S"]).apply(null,arguments)};var _sqlite3_reset=Module["_sqlite3_reset"]=function(){return(_sqlite3_reset=Module["_sqlite3_reset"]=Module["asm"]["T"]).apply(null,arguments)};var _sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=function(){return(_sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=Module["asm"]["U"]).apply(null,arguments)};var _sqlite3_value_blob=Module["_sqlite3_value_blob"]=function(){return(_sqlite3_value_blob=Module["_sqlite3_value_blob"]=Module["asm"]["V"]).apply(null,arguments)};var _sqlite3_value_text=Module["_sqlite3_value_text"]=function(){return(_sqlite3_value_text=Module["_sqlite3_value_text"]=Module["asm"]["W"]).apply(null,arguments)};var _sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=function(){return(_sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=Module["asm"]["X"]).apply(null,arguments)};var _sqlite3_value_double=Module["_sqlite3_value_double"]=function(){return(_sqlite3_value_double=Module["_sqlite3_value_double"]=Module["asm"]["Y"]).apply(null,arguments)};var _sqlite3_value_int=Module["_sqlite3_value_int"]=function(){return(_sqlite3_value_int=Module["_sqlite3_value_int"]=Module["asm"]["Z"]).apply(null,arguments)};var _sqlite3_value_type=Module["_sqlite3_value_type"]=function(){return(_sqlite3_value_type=Module["_sqlite3_value_type"]=Module["asm"]["_"]).apply(null,arguments)};var _sqlite3_result_blob=Module["_sqlite3_result_blob"]=function(){return(_sqlite3_result_blob=Module["_sqlite3_result_blob"]=Module["asm"]["$"]).apply(null,arguments)};var _sqlite3_result_double=Module["_sqlite3_result_double"]=function(){return(_sqlite3_result_double=Module["_sqlite3_result_double"]=Module["asm"]["aa"]).apply(null,arguments)};var _sqlite3_result_error=Module["_sqlite3_result_error"]=function(){return(_sqlite3_result_error=Module["_sqlite3_result_error"]=Module["asm"]["ba"]).apply(null,arguments)};var _sqlite3_result_int=Module["_sqlite3_result_int"]=function(){return(_sqlite3_result_int=Module["_sqlite3_result_int"]=Module["asm"]["ca"]).apply(null,arguments)};var _sqlite3_result_int64=Module["_sqlite3_result_int64"]=function(){return(_sqlite3_result_int64=Module["_sqlite3_result_int64"]=Module["asm"]["da"]).apply(null,arguments)};var _sqlite3_result_null=Module["_sqlite3_result_null"]=function(){return(_sqlite3_result_null=Module["_sqlite3_result_null"]=Module["asm"]["ea"]).apply(null,arguments)};var _sqlite3_result_text=Module["_sqlite3_result_text"]=function(){return(_sqlite3_result_text=Module["_sqlite3_result_text"]=Module["asm"]["fa"]).apply(null,arguments)};var _sqlite3_column_count=Module["_sqlite3_column_count"]=function(){return(_sqlite3_column_count=Module["_sqlite3_column_count"]=Module["asm"]["ga"]).apply(null,arguments)};var _sqlite3_data_count=Module["_sqlite3_data_count"]=function(){return(_sqlite3_data_count=Module["_sqlite3_data_count"]=Module["asm"]["ha"]).apply(null,arguments)};var _sqlite3_column_blob=Module["_sqlite3_column_blob"]=function(){return(_sqlite3_column_blob=Module["_sqlite3_column_blob"]=Module["asm"]["ia"]).apply(null,arguments)};var _sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=function(){return(_sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=Module["asm"]["ja"]).apply(null,arguments)};var _sqlite3_column_double=Module["_sqlite3_column_double"]=function(){return(_sqlite3_column_double=Module["_sqlite3_column_double"]=Module["asm"]["ka"]).apply(null,arguments)};var _sqlite3_column_text=Module["_sqlite3_column_text"]=function(){return(_sqlite3_column_text=Module["_sqlite3_column_text"]=Module["asm"]["la"]).apply(null,arguments)};var _sqlite3_column_type=Module["_sqlite3_column_type"]=function(){return(_sqlite3_column_type=Module["_sqlite3_column_type"]=Module["asm"]["ma"]).apply(null,arguments)};var _sqlite3_column_name=Module["_sqlite3_column_name"]=function(){return(_sqlite3_column_name=Module["_sqlite3_column_name"]=Module["asm"]["na"]).apply(null,arguments)};var _sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=function(){return(_sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=Module["asm"]["oa"]).apply(null,arguments)};var _sqlite3_bind_double=Module["_sqlite3_bind_double"]=function(){return(_sqlite3_bind_double=Module["_sqlite3_bind_double"]=Module["asm"]["pa"]).apply(null,arguments)};var _sqlite3_bind_int=Module["_sqlite3_bind_int"]=function(){return(_sqlite3_bind_int=Module["_sqlite3_bind_int"]=Module["asm"]["qa"]).apply(null,arguments)};var _sqlite3_bind_text=Module["_sqlite3_bind_text"]=function(){return(_sqlite3_bind_text=Module["_sqlite3_bind_text"]=Module["asm"]["ra"]).apply(null,arguments)};var _sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=function(){return(_sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=Module["asm"]["sa"]).apply(null,arguments)};var _sqlite3_sql=Module["_sqlite3_sql"]=function(){return(_sqlite3_sql=Module["_sqlite3_sql"]=Module["asm"]["ta"]).apply(null,arguments)};var _sqlite3_normalized_sql=Module["_sqlite3_normalized_sql"]=function(){return(_sqlite3_normalized_sql=Module["_sqlite3_normalized_sql"]=Module["asm"]["ua"]).apply(null,arguments)};var _sqlite3_errmsg=Module["_sqlite3_errmsg"]=function(){return(_sqlite3_errmsg=Module["_sqlite3_errmsg"]=Module["asm"]["va"]).apply(null,arguments)};var _sqlite3_exec=Module["_sqlite3_exec"]=function(){return(_sqlite3_exec=Module["_sqlite3_exec"]=Module["asm"]["wa"]).apply(null,arguments)};var _sqlite3_changes=Module["_sqlite3_changes"]=function(){return(_sqlite3_changes=Module["_sqlite3_changes"]=Module["asm"]["xa"]).apply(null,arguments)};var _sqlite3_close_v2=Module["_sqlite3_close_v2"]=function(){return(_sqlite3_close_v2=Module["_sqlite3_close_v2"]=Module["asm"]["ya"]).apply(null,arguments)};var _sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=function(){return(_sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=Module["asm"]["za"]).apply(null,arguments)};var _sqlite3_open=Module["_sqlite3_open"]=function(){return(_sqlite3_open=Module["_sqlite3_open"]=Module["asm"]["Aa"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["Ba"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["Ca"]).apply(null,arguments)};var _RegisterExtensionFunctions=Module["_RegisterExtensionFunctions"]=function(){return(_RegisterExtensionFunctions=Module["_RegisterExtensionFunctions"]=Module["asm"]["Ea"]).apply(null,arguments)};var __get_tzname=Module["__get_tzname"]=function(){return(__get_tzname=Module["__get_tzname"]=Module["asm"]["Fa"]).apply(null,arguments)};var __get_daylight=Module["__get_daylight"]=function(){return(__get_daylight=Module["__get_daylight"]=Module["asm"]["Ga"]).apply(null,arguments)};var __get_timezone=Module["__get_timezone"]=function(){return(__get_timezone=Module["__get_timezone"]=Module["asm"]["Ha"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["Ia"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["Ja"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["Ka"]).apply(null,arguments)};var _memalign=Module["_memalign"]=function(){return(_memalign=Module["_memalign"]=Module["asm"]["La"]).apply(null,arguments)};Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stackSave"]=stackSave;Module["stackRestore"]=stackRestore;Module["stackAlloc"]=stackAlloc;var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); +var Module=typeof Module!=="undefined"?Module:{};var objAssign=Object.assign;null;Module["onRuntimeInitialized"]=function onRuntimeInitialized(){var apiTemp=stackAlloc(4);var cwrap=Module["cwrap"];var NULL=0;var SQLITE_OK=0;var SQLITE_ROW=100;var SQLITE_DONE=101;var SQLITE_INTEGER=1;var SQLITE_FLOAT=2;var SQLITE_TEXT=3;var SQLITE_BLOB=4;var SQLITE_UTF8=1;var sqlite3_open=cwrap("sqlite3_open","number",["string","number"]);var sqlite3_close_v2=cwrap("sqlite3_close_v2","number",["number"]);var sqlite3_exec=cwrap("sqlite3_exec","number",["number","string","number","number","number"]);var sqlite3_changes=cwrap("sqlite3_changes","number",["number"]);var sqlite3_prepare_v2=cwrap("sqlite3_prepare_v2","number",["number","string","number","number","number"]);var sqlite3_sql=cwrap("sqlite3_sql","string",["number"]);var sqlite3_normalized_sql=cwrap("sqlite3_normalized_sql","string",["number"]);var sqlite3_prepare_v2_sqlptr=cwrap("sqlite3_prepare_v2","number",["number","number","number","number","number"]);var sqlite3_bind_text=cwrap("sqlite3_bind_text","number",["number","number","number","number","number"]);var sqlite3_bind_blob=cwrap("sqlite3_bind_blob","number",["number","number","number","number","number"]);var sqlite3_bind_double=cwrap("sqlite3_bind_double","number",["number","number","number"]);var sqlite3_bind_int=cwrap("sqlite3_bind_int","number",["number","number","number"]);var sqlite3_bind_parameter_index=cwrap("sqlite3_bind_parameter_index","number",["number","string"]);var sqlite3_step=cwrap("sqlite3_step","number",["number"]);var sqlite3_errmsg=cwrap("sqlite3_errmsg","string",["number"]);var sqlite3_column_count=cwrap("sqlite3_column_count","number",["number"]);var sqlite3_data_count=cwrap("sqlite3_data_count","number",["number"]);var sqlite3_column_double=cwrap("sqlite3_column_double","number",["number","number"]);var sqlite3_column_text=cwrap("sqlite3_column_text","string",["number","number"]);var sqlite3_column_blob=cwrap("sqlite3_column_blob","number",["number","number"]);var sqlite3_column_bytes=cwrap("sqlite3_column_bytes","number",["number","number"]);var sqlite3_column_type=cwrap("sqlite3_column_type","number",["number","number"]);var sqlite3_column_name=cwrap("sqlite3_column_name","string",["number","number"]);var sqlite3_reset=cwrap("sqlite3_reset","number",["number"]);var sqlite3_clear_bindings=cwrap("sqlite3_clear_bindings","number",["number"]);var sqlite3_finalize=cwrap("sqlite3_finalize","number",["number"]);var sqlite3_create_function_v2=cwrap("sqlite3_create_function_v2","number",["number","string","number","number","number","number","number","number","number"]);var sqlite3_value_type=cwrap("sqlite3_value_type","number",["number"]);var sqlite3_value_bytes=cwrap("sqlite3_value_bytes","number",["number"]);var sqlite3_value_text=cwrap("sqlite3_value_text","string",["number"]);var sqlite3_value_blob=cwrap("sqlite3_value_blob","number",["number"]);var sqlite3_value_double=cwrap("sqlite3_value_double","number",["number"]);var sqlite3_result_double=cwrap("sqlite3_result_double","",["number","number"]);var sqlite3_result_null=cwrap("sqlite3_result_null","",["number"]);var sqlite3_result_text=cwrap("sqlite3_result_text","",["number","string","number","number"]);var sqlite3_result_blob=cwrap("sqlite3_result_blob","",["number","number","number","number"]);var sqlite3_result_int=cwrap("sqlite3_result_int","",["number","number"]);var sqlite3_result_error=cwrap("sqlite3_result_error","",["number","string","number"]);var registerExtensionFunctions=cwrap("RegisterExtensionFunctions","number",["number"]);function Statement(stmt1,db){this.stmt=stmt1;this.db=db;this.pos=1;this.allocatedmem=[]}Statement.prototype["bind"]=function bind(values){if(!this.stmt){throw"Statement closed"}this["reset"]();if(Array.isArray(values))return this.bindFromArray(values);if(values!=null&&typeof values==="object"){return this.bindFromObject(values)}return true};Statement.prototype["step"]=function step(){if(!this.stmt){throw"Statement closed"}this.pos=1;var ret=sqlite3_step(this.stmt);switch(ret){case SQLITE_ROW:return true;case SQLITE_DONE:return false;default:throw this.db.handleError(ret)}};Statement.prototype.getNumber=function getNumber(pos){if(pos==null){pos=this.pos;this.pos+=1}return sqlite3_column_double(this.stmt,pos)};Statement.prototype.getBigInt=function getBigInt(pos){if(pos==null){pos=this.pos;this.pos+=1}var text=sqlite3_column_text(this.stmt,pos);if(typeof BigInt!=="function"){throw new Error("BigInt is not supported")}return BigInt(text)};Statement.prototype.getString=function getString(pos){if(pos==null){pos=this.pos;this.pos+=1}return sqlite3_column_text(this.stmt,pos)};Statement.prototype.getBlob=function getBlob(pos){if(pos==null){pos=this.pos;this.pos+=1}var size=sqlite3_column_bytes(this.stmt,pos);var ptr=sqlite3_column_blob(this.stmt,pos);var result=new Uint8Array(size);for(var i=0;i>>0);if(data!=null){FS.createDataFile("/",this.filename,data,true,true)}this.handleError(sqlite3_open(this.filename,apiTemp));this.db=getValue(apiTemp,"i32");registerExtensionFunctions(this.db);this.statements={};this.functions={}}Database.prototype["run"]=function run(sql,params){if(!this.db){throw"Database closed"}if(params){var stmt=this["prepare"](sql,params);try{stmt["step"]()}finally{stmt["free"]()}}else{this.handleError(sqlite3_exec(this.db,sql,0,0,apiTemp))}return this};Database.prototype["exec"]=function exec(sql,params,config){if(!this.db){throw"Database closed"}var stack=stackSave();var stmt=null;try{var nextSqlPtr=allocateUTF8OnStack(sql);var pzTail=stackAlloc(4);var results=[];while(getValue(nextSqlPtr,"i8")!==NULL){setValue(apiTemp,0,"i32");setValue(pzTail,0,"i32");this.handleError(sqlite3_prepare_v2_sqlptr(this.db,nextSqlPtr,-1,apiTemp,pzTail));var pStmt=getValue(apiTemp,"i32");nextSqlPtr=getValue(pzTail,"i32");if(pStmt!==NULL){var curresult=null;stmt=new Statement(pStmt,this);if(params!=null){stmt.bind(params)}while(stmt["step"]()){if(curresult===null){curresult={columns:stmt["getColumnNames"](),values:[]};results.push(curresult)}curresult["values"].push(stmt["get"](null,config))}stmt["free"]()}}return results}catch(errCaught){if(stmt)stmt["free"]();throw errCaught}finally{stackRestore(stack)}};Database.prototype["each"]=function each(sql,params,callback,done,config){var stmt;if(typeof params==="function"){done=callback;callback=params;params=undefined}stmt=this["prepare"](sql,params);try{while(stmt["step"]()){callback(stmt["getAsObject"](null,config))}}finally{stmt["free"]()}if(typeof done==="function"){return done()}return undefined};Database.prototype["prepare"]=function prepare(sql,params){setValue(apiTemp,0,"i32");this.handleError(sqlite3_prepare_v2(this.db,sql,-1,apiTemp,NULL));var pStmt=getValue(apiTemp,"i32");if(pStmt===NULL){throw"Nothing to prepare"}var stmt=new Statement(pStmt,this);if(params!=null){stmt.bind(params)}this.statements[pStmt]=stmt;return stmt};Database.prototype["iterateStatements"]=function iterateStatements(sql){return new StatementIterator(sql,this)};Database.prototype["export"]=function exportDatabase(){Object.values(this.statements).forEach(function each(stmt){stmt["free"]()});Object.values(this.functions).forEach(removeFunction);this.functions={};this.handleError(sqlite3_close_v2(this.db));var binaryDb=FS.readFile(this.filename,{encoding:"binary"});this.handleError(sqlite3_open(this.filename,apiTemp));this.db=getValue(apiTemp,"i32");return binaryDb};Database.prototype["close"]=function close(){if(this.db===null){return}Object.values(this.statements).forEach(function each(stmt){stmt["free"]()});Object.values(this.functions).forEach(removeFunction);this.functions={};this.handleError(sqlite3_close_v2(this.db));FS.unlink("/"+this.filename);this.db=null};Database.prototype["handleError"]=function handleError(returnCode){var errmsg;if(returnCode===SQLITE_OK){return null}errmsg=sqlite3_errmsg(this.db);throw new Error(errmsg)};Database.prototype["getRowsModified"]=function getRowsModified(){return sqlite3_changes(this.db)};Database.prototype["create_function"]=function create_function(name,func){function wrapped_func(cx,argc,argv){var result;function extract_blob(ptr){var size=sqlite3_value_bytes(ptr);var blob_ptr=sqlite3_value_blob(ptr);var blob_arg=new Uint8Array(size);for(var j=0;j>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return Number(HEAPF64[ptr>>3]);default:abort("invalid type for getValue: "+type)}return null}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}function getCFunc(ident){var func=Module["_"+ident];return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(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=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}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}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function allocateUTF8OnStack(str){var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){{if(Module["onAbort"]){Module["onAbort"](what)}}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile;wasmBinaryFile="sql-wasm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["K"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Ja"];addOnInit(Module["asm"]["L"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){getWasmTableEntry(func)()}else{getWasmTableEntry(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}function demangle(func){return func}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function getWasmTableEntry(funcPtr){return wasmTable.get(funcPtr)}function jsStackTrace(){var error=new Error;if(!error.stack){try{throw new Error}catch(e){error=e}if(!error.stack){return"(no stack trace available)"}}return error.stack.toString()}function setWasmTableEntry(idx,func){wasmTable.set(idx,func)}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}function _tzset_impl(){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);HEAP32[__get_timezone()>>2]=stdTimezoneOffset*60;HEAP32[__get_daylight()>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAP32[__get_tzname()+4>>2]=summerNamePtr}else{HEAP32[__get_tzname()>>2]=summerNamePtr;HEAP32[__get_tzname()+4>>2]=winterNamePtr}}function _tzset(){if(_tzset.called)return;_tzset.called=true;_tzset_impl()}function _localtime_r(time,tmPtr){_tzset();var date=new Date(HEAP32[time>>2]*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 start=new Date(date.getFullYear(),0,1);var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-(date.getTimezoneOffset()*60);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 zonePtr=HEAP32[__get_tzname()+(dst?4:0)>>2];HEAP32[tmPtr+40>>2]=zonePtr;return tmPtr}function ___localtime_r(a0,a1){return _localtime_r(a0,a1)}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto==="object"&&typeof crypto["getRandomValues"]==="function"){var randomBuffer=new Uint8Array(1);return function(){crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else return function(){abort("randomDevice")}}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:function(from,to){from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function zeroMemory(address,size){HEAPU8.fill(0,address,address+size)}function alignMemory(size,alignment){return Math.ceil(size/alignment)*alignment}function mmapAlloc(size){size=alignMemory(size,65536);var ptr=_memalign(65536,size);if(!ptr)return 0;zeroMemory(ptr,size);return ptr}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:function(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:function(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:function(node){FS.hashRemoveNode(node)},isRoot:function(node){return node===node.parent},isMountpoint:function(node){return!!node.mounted},isFile:function(mode){return(mode&61440)===32768},isDir:function(mode){return(mode&61440)===16384},isLink:function(mode){return(mode&61440)===40960},isChrdev:function(mode){return(mode&61440)===8192},isBlkdev:function(mode){return(mode&61440)===24576},isFIFO:function(mode){return(mode&61440)===4096},isSocket:function(mode){return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:function(node,perms){if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:function(dir){var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:function(dir,name){try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:function(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:function(fd){return FS.streams[fd]},createStream:function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=function(){};FS.FSStream.prototype={object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:function(fd){FS.streams[fd]=null},chrdev_stream_ops:{open:function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:function(){throw new FS.ErrnoError(70)}},major:function(dev){return dev>>8},minor:function(dev){return dev&255},makedev:function(ma,mi){return ma<<8|mi},registerDevice:function(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:function(dev){return FS.devices[dev]},getMounts:function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:function(parent,name){return parent.node_ops.lookup(parent,name)},mknod:function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:function(path,mode){var dirs=path.split("/");var d="";for(var i=0;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}};var lazyArray=this;lazyArray.setDataGetter(function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){FS.forceLoadFile(node);var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i>2]=stat.dev;HEAP32[buf+4>>2]=0;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP32[buf+32>>2]=0;tempI64=[stat.size>>>0,(tempDouble=stat.size,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+40>>2]=tempI64[0],HEAP32[buf+44>>2]=tempI64[1];HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP32[buf+56>>2]=stat.atime.getTime()/1e3|0;HEAP32[buf+60>>2]=0;HEAP32[buf+64>>2]=stat.mtime.getTime()/1e3|0;HEAP32[buf+68>>2]=0;HEAP32[buf+72>>2]=stat.ctime.getTime()/1e3|0;HEAP32[buf+76>>2]=0;tempI64=[stat.ino>>>0,(tempDouble=stat.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+80>>2]=tempI64[0],HEAP32[buf+84>>2]=tempI64[1];return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},doMkdir:function(path,mode){path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0},doMknod:function(path,mode,dev){switch(mode&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}FS.mknod(path,mode,dev);return 0},doReadlink:function(path,buf,bufsize){if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len},doAccess:function(path,amode){if(amode&~7){return-28}var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0},doDup:function(path,flags,suggestFD){var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.open(path,flags,0,suggestFD,suggestFD).fd},doReadv:function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream},get64:function(low,high){return low}};function ___syscall_access(path,amode){try{path=SYSCALLS.getStr(path);return SYSCALLS.doAccess(path,amode)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_chmod(path,mode){try{path=SYSCALLS.getStr(path);FS.chmod(path,mode);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_chown32(path,owner,group){try{path=SYSCALLS.getStr(path);FS.chown(path,owner,group);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fchmod(fd,mode){try{FS.fchmod(fd,mode);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fchown32(fd,owner,group){try{FS.fchown(fd,owner,group);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.open(stream.path,stream.flags,0,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstatat64(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~4352;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_ftruncate64(fd,low,high){try{var length=SYSCALLS.get64(low,high);FS.ftruncate(fd,length);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_getcwd(buf,size){try{if(size===0)return-28;var cwd=FS.cwd();var cwdLengthInBytes=lengthBytesUTF8(cwd);if(size>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=2147483648;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,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator==="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAP32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAP32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_read(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{var stream=SYSCALLS.getStreamFromFD(fd);var HIGH_OFFSET=4294967296;var offset=offset_high*HIGH_OFFSET+(offset_low>>>0);var DOUBLE_LIMIT=9007199254740992;if(offset<=-DOUBLE_LIMIT||offset>=DOUBLE_LIMIT){return-61}FS.llseek(stream,offset,whence);tempI64=[stream.position>>>0,(tempDouble=stream.position,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[newOffset>>2]=tempI64[0],HEAP32[newOffset+4>>2]=tempI64[1];if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_sync(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);if(stream.stream_ops&&stream.stream_ops.fsync){return-stream.stream_ops.fsync(stream)}return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doWritev(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _gettimeofday(ptr){var now=Date.now();HEAP32[ptr>>2]=now/1e3|0;HEAP32[ptr+4>>2]=now%1e3*1e3|0;return 0}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function setFileTime(path,time){path=UTF8ToString(path);try{FS.utime(path,time,time);return 0}catch(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();setErrNo(e.errno);return-1}}function _utimes(path,times){var time;if(times){var mtime=times+8;time=HEAP32[mtime>>2]*1e3;time+=HEAP32[mtime+4>>2]/1e3}else{time=Date.now()}return setFileTime(path,time)}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"a":___assert_fail,"w":___localtime_r,"j":___syscall_access,"h":___syscall_chmod,"f":___syscall_chown32,"i":___syscall_fchmod,"g":___syscall_fchown32,"b":___syscall_fcntl64,"H":___syscall_fstat64,"E":___syscall_fstatat64,"C":___syscall_ftruncate64,"B":___syscall_getcwd,"x":___syscall_geteuid32,"F":___syscall_lstat64,"v":___syscall_mkdir,"u":___syscall_mmap2,"t":___syscall_munmap,"s":___syscall_open,"q":___syscall_readlink,"p":___syscall_rmdir,"G":___syscall_stat64,"o":___syscall_unlink,"e":_emscripten_get_now,"l":_emscripten_memcpy_big,"c":_emscripten_resize_heap,"z":_environ_get,"A":_environ_sizes_get,"d":_fd_close,"n":_fd_fdstat_get,"r":_fd_read,"k":_fd_seek,"D":_fd_sync,"m":_fd_write,"y":_gettimeofday,"I":_time,"J":_utimes};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["L"]).apply(null,arguments)};var _sqlite3_free=Module["_sqlite3_free"]=function(){return(_sqlite3_free=Module["_sqlite3_free"]=Module["asm"]["M"]).apply(null,arguments)};var _sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=function(){return(_sqlite3_prepare_v2=Module["_sqlite3_prepare_v2"]=Module["asm"]["N"]).apply(null,arguments)};var _sqlite3_step=Module["_sqlite3_step"]=function(){return(_sqlite3_step=Module["_sqlite3_step"]=Module["asm"]["O"]).apply(null,arguments)};var _sqlite3_finalize=Module["_sqlite3_finalize"]=function(){return(_sqlite3_finalize=Module["_sqlite3_finalize"]=Module["asm"]["P"]).apply(null,arguments)};var _sqlite3_reset=Module["_sqlite3_reset"]=function(){return(_sqlite3_reset=Module["_sqlite3_reset"]=Module["asm"]["Q"]).apply(null,arguments)};var _sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=function(){return(_sqlite3_clear_bindings=Module["_sqlite3_clear_bindings"]=Module["asm"]["R"]).apply(null,arguments)};var _sqlite3_value_blob=Module["_sqlite3_value_blob"]=function(){return(_sqlite3_value_blob=Module["_sqlite3_value_blob"]=Module["asm"]["S"]).apply(null,arguments)};var _sqlite3_value_text=Module["_sqlite3_value_text"]=function(){return(_sqlite3_value_text=Module["_sqlite3_value_text"]=Module["asm"]["T"]).apply(null,arguments)};var _sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=function(){return(_sqlite3_value_bytes=Module["_sqlite3_value_bytes"]=Module["asm"]["U"]).apply(null,arguments)};var _sqlite3_value_double=Module["_sqlite3_value_double"]=function(){return(_sqlite3_value_double=Module["_sqlite3_value_double"]=Module["asm"]["V"]).apply(null,arguments)};var _sqlite3_value_int=Module["_sqlite3_value_int"]=function(){return(_sqlite3_value_int=Module["_sqlite3_value_int"]=Module["asm"]["W"]).apply(null,arguments)};var _sqlite3_value_type=Module["_sqlite3_value_type"]=function(){return(_sqlite3_value_type=Module["_sqlite3_value_type"]=Module["asm"]["X"]).apply(null,arguments)};var _sqlite3_result_blob=Module["_sqlite3_result_blob"]=function(){return(_sqlite3_result_blob=Module["_sqlite3_result_blob"]=Module["asm"]["Y"]).apply(null,arguments)};var _sqlite3_result_double=Module["_sqlite3_result_double"]=function(){return(_sqlite3_result_double=Module["_sqlite3_result_double"]=Module["asm"]["Z"]).apply(null,arguments)};var _sqlite3_result_error=Module["_sqlite3_result_error"]=function(){return(_sqlite3_result_error=Module["_sqlite3_result_error"]=Module["asm"]["_"]).apply(null,arguments)};var _sqlite3_result_int=Module["_sqlite3_result_int"]=function(){return(_sqlite3_result_int=Module["_sqlite3_result_int"]=Module["asm"]["$"]).apply(null,arguments)};var _sqlite3_result_int64=Module["_sqlite3_result_int64"]=function(){return(_sqlite3_result_int64=Module["_sqlite3_result_int64"]=Module["asm"]["aa"]).apply(null,arguments)};var _sqlite3_result_null=Module["_sqlite3_result_null"]=function(){return(_sqlite3_result_null=Module["_sqlite3_result_null"]=Module["asm"]["ba"]).apply(null,arguments)};var _sqlite3_result_text=Module["_sqlite3_result_text"]=function(){return(_sqlite3_result_text=Module["_sqlite3_result_text"]=Module["asm"]["ca"]).apply(null,arguments)};var _sqlite3_column_count=Module["_sqlite3_column_count"]=function(){return(_sqlite3_column_count=Module["_sqlite3_column_count"]=Module["asm"]["da"]).apply(null,arguments)};var _sqlite3_data_count=Module["_sqlite3_data_count"]=function(){return(_sqlite3_data_count=Module["_sqlite3_data_count"]=Module["asm"]["ea"]).apply(null,arguments)};var _sqlite3_column_blob=Module["_sqlite3_column_blob"]=function(){return(_sqlite3_column_blob=Module["_sqlite3_column_blob"]=Module["asm"]["fa"]).apply(null,arguments)};var _sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=function(){return(_sqlite3_column_bytes=Module["_sqlite3_column_bytes"]=Module["asm"]["ga"]).apply(null,arguments)};var _sqlite3_column_double=Module["_sqlite3_column_double"]=function(){return(_sqlite3_column_double=Module["_sqlite3_column_double"]=Module["asm"]["ha"]).apply(null,arguments)};var _sqlite3_column_text=Module["_sqlite3_column_text"]=function(){return(_sqlite3_column_text=Module["_sqlite3_column_text"]=Module["asm"]["ia"]).apply(null,arguments)};var _sqlite3_column_type=Module["_sqlite3_column_type"]=function(){return(_sqlite3_column_type=Module["_sqlite3_column_type"]=Module["asm"]["ja"]).apply(null,arguments)};var _sqlite3_column_name=Module["_sqlite3_column_name"]=function(){return(_sqlite3_column_name=Module["_sqlite3_column_name"]=Module["asm"]["ka"]).apply(null,arguments)};var _sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=function(){return(_sqlite3_bind_blob=Module["_sqlite3_bind_blob"]=Module["asm"]["la"]).apply(null,arguments)};var _sqlite3_bind_double=Module["_sqlite3_bind_double"]=function(){return(_sqlite3_bind_double=Module["_sqlite3_bind_double"]=Module["asm"]["ma"]).apply(null,arguments)};var _sqlite3_bind_int=Module["_sqlite3_bind_int"]=function(){return(_sqlite3_bind_int=Module["_sqlite3_bind_int"]=Module["asm"]["na"]).apply(null,arguments)};var _sqlite3_bind_text=Module["_sqlite3_bind_text"]=function(){return(_sqlite3_bind_text=Module["_sqlite3_bind_text"]=Module["asm"]["oa"]).apply(null,arguments)};var _sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=function(){return(_sqlite3_bind_parameter_index=Module["_sqlite3_bind_parameter_index"]=Module["asm"]["pa"]).apply(null,arguments)};var _sqlite3_sql=Module["_sqlite3_sql"]=function(){return(_sqlite3_sql=Module["_sqlite3_sql"]=Module["asm"]["qa"]).apply(null,arguments)};var _sqlite3_normalized_sql=Module["_sqlite3_normalized_sql"]=function(){return(_sqlite3_normalized_sql=Module["_sqlite3_normalized_sql"]=Module["asm"]["ra"]).apply(null,arguments)};var _sqlite3_exec=Module["_sqlite3_exec"]=function(){return(_sqlite3_exec=Module["_sqlite3_exec"]=Module["asm"]["sa"]).apply(null,arguments)};var _sqlite3_errmsg=Module["_sqlite3_errmsg"]=function(){return(_sqlite3_errmsg=Module["_sqlite3_errmsg"]=Module["asm"]["ta"]).apply(null,arguments)};var _sqlite3_changes=Module["_sqlite3_changes"]=function(){return(_sqlite3_changes=Module["_sqlite3_changes"]=Module["asm"]["ua"]).apply(null,arguments)};var _sqlite3_close_v2=Module["_sqlite3_close_v2"]=function(){return(_sqlite3_close_v2=Module["_sqlite3_close_v2"]=Module["asm"]["va"]).apply(null,arguments)};var _sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=function(){return(_sqlite3_create_function_v2=Module["_sqlite3_create_function_v2"]=Module["asm"]["wa"]).apply(null,arguments)};var _sqlite3_open=Module["_sqlite3_open"]=function(){return(_sqlite3_open=Module["_sqlite3_open"]=Module["asm"]["xa"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["ya"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["za"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["Aa"]).apply(null,arguments)};var _RegisterExtensionFunctions=Module["_RegisterExtensionFunctions"]=function(){return(_RegisterExtensionFunctions=Module["_RegisterExtensionFunctions"]=Module["asm"]["Ba"]).apply(null,arguments)};var __get_tzname=Module["__get_tzname"]=function(){return(__get_tzname=Module["__get_tzname"]=Module["asm"]["Ca"]).apply(null,arguments)};var __get_daylight=Module["__get_daylight"]=function(){return(__get_daylight=Module["__get_daylight"]=Module["asm"]["Da"]).apply(null,arguments)};var __get_timezone=Module["__get_timezone"]=function(){return(__get_timezone=Module["__get_timezone"]=Module["asm"]["Ea"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["Fa"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["Ga"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["Ha"]).apply(null,arguments)};var _memalign=Module["_memalign"]=function(){return(_memalign=Module["_memalign"]=Module["asm"]["Ia"]).apply(null,arguments)};Module["cwrap"]=cwrap;Module["UTF8ToString"]=UTF8ToString;Module["stackSave"]=stackSave;Module["stackRestore"]=stackRestore;Module["stackAlloc"]=stackAlloc;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); // The shell-pre.js and emcc-generated code goes above diff --git a/lib/sql-js/dist/sql-wasm.wasm b/lib/sql-js/dist/sql-wasm.wasm index d8f9074..1ac2981 100755 Binary files a/lib/sql-js/dist/sql-wasm.wasm and b/lib/sql-js/dist/sql-wasm.wasm differ diff --git a/tests/lib/database/sqliteExtensions.spec.js b/tests/lib/database/sqliteExtensions.spec.js index 2961378..97bab95 100644 --- a/tests/lib/database/sqliteExtensions.spec.js +++ b/tests/lib/database/sqliteExtensions.spec.js @@ -160,39 +160,39 @@ describe('SQLite extensions', function () { it('supports transitive_closure', async function () { const actual = await db.execute(` CREATE TABLE node( - node_id INTEGER NOT NULL PRIMARY KEY, - parent_id INTEGER, - name VARCHAR(127), - FOREIGN KEY (parent_id) REFERENCES node(node_id) - ); - CREATE INDEX node_parent_id_idx ON node(parent_id); - - CREATE VIRTUAL TABLE node_closure USING transitive_closure( - tablename = "node", - idcolumn = "node_id", - parentcolumn = "parent_id" + node_id INTEGER NOT NULL PRIMARY KEY, + parent_id INTEGER, + name VARCHAR(127), + FOREIGN KEY (parent_id) REFERENCES node(node_id) ); + CREATE INDEX node_parent_id_idx ON node(parent_id); - INSERT INTO node VALUES - (1, NULL, 'tests'), - (2, 1, 'lib'), - (3, 2, 'database'), - (4, 2, 'utils'), - (5, 2, 'storedQueries.spec.js'), - (6, 3, '_sql.spec.js'), - (7, 3, '_statements.spec.js'), - (8, 3, 'database.spec.js'), - (9, 3, 'sqliteExtensions.spec.js'), - (10, 4, 'fileIo.spec.js'), - (11, 4, 'time.spec.js'); - - SELECT name - FROM node - WHERE node_id IN ( - SELECT nc.id - FROM node_closure AS nc - WHERE nc.root = 2 AND nc.depth = 2 - ); + CREATE VIRTUAL TABLE node_closure USING transitive_closure( + tablename = "node", + idcolumn = "node_id", + parentcolumn = "parent_id" + ); + + INSERT INTO node VALUES + (1, NULL, 'tests'), + (2, 1, 'lib'), + (3, 2, 'database'), + (4, 2, 'utils'), + (5, 2, 'storedQueries.spec.js'), + (6, 3, '_sql.spec.js'), + (7, 3, '_statements.spec.js'), + (8, 3, 'database.spec.js'), + (9, 3, 'sqliteExtensions.spec.js'), + (10, 4, 'fileIo.spec.js'), + (11, 4, 'time.spec.js'); + + SELECT name + FROM node + WHERE node_id IN ( + SELECT nc.id + FROM node_closure AS nc + WHERE nc.root = 2 AND nc.depth = 2 + ); `) expect(actual.values).to.eql({ name: [ @@ -293,7 +293,7 @@ describe('SQLite extensions', function () { it('supports decimal', async function () { const actual = await db.execute(` - select + SELECT decimal_add(decimal('0.1'), decimal('0.2')) "add", decimal_sub(0.2, 0.1) sub, decimal_mul(power(2, 69), 2) mul, @@ -430,4 +430,29 @@ describe('SQLite extensions', function () { ] }) }) + + it('supports pearson', async function () { + const actual = await db.execute(` + CREATE TABLE dataset(x REAL, y REAL, z REAL); + INSERT INTO dataset VALUES + (5,3,3.2), (5,6,4.3), (5,9,5.4), + (10,3,4), (10,6,3.8), (10,9,3.6), + (15,3,4.8), (15,6,4), (15,9,3.5); + + SELECT + pearson(x, x) xx, + pearson(x, y) xy, + abs(-0.12666 - pearson(x, z)) < 0.00001 xz, + pearson(y, x) yx, + pearson(y, y) yy, + abs(0.10555 - pearson(y, z)) < 0.00001 yz, + abs(-0.12666 - pearson(z, x)) < 0.00001 zx, + abs(0.10555 - pearson(z, y)) < 0.00001 zy, + pearson(z, z) zz + FROM dataset; + `) + expect(actual.values).to.eql({ + xx: [1], xy: [0], xz: [1], yx: [0], yy: [1], yz: [1], zx: [1], zy: [1], zz: [1] + }) + }) })