@viberaven/sessions 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +45 -0
- package/README.md +152 -2
- package/THIRD_PARTY_NOTICES +6770 -0
- package/dist/browser.mjs +2642 -0
- package/examples/quickstart.mjs +11 -0
- package/licenses/Emscripten.txt +101 -0
- package/licenses/ICU.txt +542 -0
- package/licenses/OSSP-UUID.txt +24 -0
- package/licenses/OpenSSL.txt +177 -0
- package/licenses/PGlite.txt +176 -0
- package/licenses/PostgreSQL-extra.txt +3592 -0
- package/licenses/PostgreSQL.txt +23 -0
- package/licenses/README.md +36 -0
- package/licenses/Snowball.txt +29 -0
- package/licenses/async-mutex.txt +21 -0
- package/licenses/base64-js.txt +21 -0
- package/licenses/buffer.txt +21 -0
- package/licenses/compiler-rt.txt +311 -0
- package/licenses/dlmalloc.txt +135 -0
- package/licenses/esbuild.txt +21 -0
- package/licenses/ieee754.txt +11 -0
- package/licenses/libcxx.txt +311 -0
- package/licenses/libcxxabi.txt +311 -0
- package/licenses/libunwind.txt +311 -0
- package/licenses/libxml2-extra.txt +34 -0
- package/licenses/libxml2.txt +24 -0
- package/licenses/libxslt.txt +53 -0
- package/licenses/musl.txt +193 -0
- package/licenses/pg-protocol.txt +21 -0
- package/licenses/tinytar.txt +21 -0
- package/licenses/tslib.txt +28 -0
- package/licenses/tsup.txt +21 -0
- package/licenses/zlib.txt +22 -0
- package/package.json +76 -4
- package/runtime/engine/frozen/runtime/engine-host.mjs +377 -0
- package/runtime/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
- package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
- package/runtime/race/pin.mjs +12 -0
- package/runtime/runtime-manifest.json +579 -0
- package/runtime/wait/initial-image.tgz +0 -0
- package/runtime/wait/wire.mjs +39 -0
- package/runtime-infn/engine/frozen/runtime/engine-host.mjs +390 -0
- package/runtime-infn/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
- package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
- package/runtime-infn/race/pin.mjs +12 -0
- package/runtime-infn/runtime-manifest.json +580 -0
- package/runtime-infn/wait/initial-image.tgz +0 -0
- package/runtime-infn/wait/wire.mjs +39 -0
- package/runtime-infnprod/engine/frozen/runtime/engine-host.mjs +391 -0
- package/runtime-infnprod/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
- package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
- package/runtime-infnprod/race/pin.mjs +12 -0
- package/runtime-infnprod/runtime-manifest.json +581 -0
- package/runtime-infnprod/wait/initial-image.tgz +0 -0
- package/runtime-infnprod/wait/wire.mjs +39 -0
- package/src/browser-platform.mjs +12 -0
- package/src/browser.d.ts +5 -0
- package/src/browser.mjs +43 -0
- package/src/index.d.ts +50 -0
- package/src/index.mjs +23 -0
- package/src/runtime-integrity.mjs +69 -0
package/dist/browser.mjs
ADDED
|
@@ -0,0 +1,2642 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// node_modules/base64-js/index.js
|
|
31
|
+
var require_base64_js = __commonJS({
|
|
32
|
+
"node_modules/base64-js/index.js"(exports) {
|
|
33
|
+
"use strict";
|
|
34
|
+
init_browser_buffer();
|
|
35
|
+
exports.byteLength = byteLength;
|
|
36
|
+
exports.toByteArray = toByteArray;
|
|
37
|
+
exports.fromByteArray = fromByteArray;
|
|
38
|
+
var lookup = [];
|
|
39
|
+
var revLookup = [];
|
|
40
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
41
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
42
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
43
|
+
lookup[i] = code[i];
|
|
44
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
45
|
+
}
|
|
46
|
+
var i;
|
|
47
|
+
var len;
|
|
48
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
49
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
50
|
+
function getLens(b64) {
|
|
51
|
+
var len2 = b64.length;
|
|
52
|
+
if (len2 % 4 > 0) {
|
|
53
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
54
|
+
}
|
|
55
|
+
var validLen = b64.indexOf("=");
|
|
56
|
+
if (validLen === -1) validLen = len2;
|
|
57
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
58
|
+
return [validLen, placeHoldersLen];
|
|
59
|
+
}
|
|
60
|
+
function byteLength(b64) {
|
|
61
|
+
var lens = getLens(b64);
|
|
62
|
+
var validLen = lens[0];
|
|
63
|
+
var placeHoldersLen = lens[1];
|
|
64
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
65
|
+
}
|
|
66
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
67
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
68
|
+
}
|
|
69
|
+
function toByteArray(b64) {
|
|
70
|
+
var tmp;
|
|
71
|
+
var lens = getLens(b64);
|
|
72
|
+
var validLen = lens[0];
|
|
73
|
+
var placeHoldersLen = lens[1];
|
|
74
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
75
|
+
var curByte = 0;
|
|
76
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
77
|
+
var i2;
|
|
78
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
79
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
80
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
81
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
82
|
+
arr[curByte++] = tmp & 255;
|
|
83
|
+
}
|
|
84
|
+
if (placeHoldersLen === 2) {
|
|
85
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
86
|
+
arr[curByte++] = tmp & 255;
|
|
87
|
+
}
|
|
88
|
+
if (placeHoldersLen === 1) {
|
|
89
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
90
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
91
|
+
arr[curByte++] = tmp & 255;
|
|
92
|
+
}
|
|
93
|
+
return arr;
|
|
94
|
+
}
|
|
95
|
+
function tripletToBase64(num) {
|
|
96
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
97
|
+
}
|
|
98
|
+
function encodeChunk(uint8, start, end) {
|
|
99
|
+
var tmp;
|
|
100
|
+
var output = [];
|
|
101
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
102
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
103
|
+
output.push(tripletToBase64(tmp));
|
|
104
|
+
}
|
|
105
|
+
return output.join("");
|
|
106
|
+
}
|
|
107
|
+
function fromByteArray(uint8) {
|
|
108
|
+
var tmp;
|
|
109
|
+
var len2 = uint8.length;
|
|
110
|
+
var extraBytes = len2 % 3;
|
|
111
|
+
var parts = [];
|
|
112
|
+
var maxChunkLength = 16383;
|
|
113
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
114
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
115
|
+
}
|
|
116
|
+
if (extraBytes === 1) {
|
|
117
|
+
tmp = uint8[len2 - 1];
|
|
118
|
+
parts.push(
|
|
119
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
120
|
+
);
|
|
121
|
+
} else if (extraBytes === 2) {
|
|
122
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
123
|
+
parts.push(
|
|
124
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return parts.join("");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// node_modules/ieee754/index.js
|
|
133
|
+
var require_ieee754 = __commonJS({
|
|
134
|
+
"node_modules/ieee754/index.js"(exports) {
|
|
135
|
+
init_browser_buffer();
|
|
136
|
+
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
137
|
+
var e, m;
|
|
138
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
139
|
+
var eMax = (1 << eLen) - 1;
|
|
140
|
+
var eBias = eMax >> 1;
|
|
141
|
+
var nBits = -7;
|
|
142
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
143
|
+
var d = isLE ? -1 : 1;
|
|
144
|
+
var s = buffer[offset + i];
|
|
145
|
+
i += d;
|
|
146
|
+
e = s & (1 << -nBits) - 1;
|
|
147
|
+
s >>= -nBits;
|
|
148
|
+
nBits += eLen;
|
|
149
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
150
|
+
}
|
|
151
|
+
m = e & (1 << -nBits) - 1;
|
|
152
|
+
e >>= -nBits;
|
|
153
|
+
nBits += mLen;
|
|
154
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
155
|
+
}
|
|
156
|
+
if (e === 0) {
|
|
157
|
+
e = 1 - eBias;
|
|
158
|
+
} else if (e === eMax) {
|
|
159
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
160
|
+
} else {
|
|
161
|
+
m = m + Math.pow(2, mLen);
|
|
162
|
+
e = e - eBias;
|
|
163
|
+
}
|
|
164
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
165
|
+
};
|
|
166
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
167
|
+
var e, m, c;
|
|
168
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
169
|
+
var eMax = (1 << eLen) - 1;
|
|
170
|
+
var eBias = eMax >> 1;
|
|
171
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
172
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
173
|
+
var d = isLE ? 1 : -1;
|
|
174
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
175
|
+
value = Math.abs(value);
|
|
176
|
+
if (isNaN(value) || value === Infinity) {
|
|
177
|
+
m = isNaN(value) ? 1 : 0;
|
|
178
|
+
e = eMax;
|
|
179
|
+
} else {
|
|
180
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
181
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
182
|
+
e--;
|
|
183
|
+
c *= 2;
|
|
184
|
+
}
|
|
185
|
+
if (e + eBias >= 1) {
|
|
186
|
+
value += rt / c;
|
|
187
|
+
} else {
|
|
188
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
189
|
+
}
|
|
190
|
+
if (value * c >= 2) {
|
|
191
|
+
e++;
|
|
192
|
+
c /= 2;
|
|
193
|
+
}
|
|
194
|
+
if (e + eBias >= eMax) {
|
|
195
|
+
m = 0;
|
|
196
|
+
e = eMax;
|
|
197
|
+
} else if (e + eBias >= 1) {
|
|
198
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
199
|
+
e = e + eBias;
|
|
200
|
+
} else {
|
|
201
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
202
|
+
e = 0;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
206
|
+
}
|
|
207
|
+
e = e << mLen | m;
|
|
208
|
+
eLen += mLen;
|
|
209
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
210
|
+
}
|
|
211
|
+
buffer[offset + i - d] |= s * 128;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// node_modules/buffer/index.js
|
|
217
|
+
var require_buffer = __commonJS({
|
|
218
|
+
"node_modules/buffer/index.js"(exports) {
|
|
219
|
+
"use strict";
|
|
220
|
+
init_browser_buffer();
|
|
221
|
+
var base64 = require_base64_js();
|
|
222
|
+
var ieee754 = require_ieee754();
|
|
223
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
224
|
+
exports.Buffer = Buffer3;
|
|
225
|
+
exports.SlowBuffer = SlowBuffer;
|
|
226
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
227
|
+
var K_MAX_LENGTH = 2147483647;
|
|
228
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
229
|
+
Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
230
|
+
if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
231
|
+
console.error(
|
|
232
|
+
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function typedArraySupport() {
|
|
236
|
+
try {
|
|
237
|
+
const arr = new Uint8Array(1);
|
|
238
|
+
const proto = { foo: function() {
|
|
239
|
+
return 42;
|
|
240
|
+
} };
|
|
241
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
242
|
+
Object.setPrototypeOf(arr, proto);
|
|
243
|
+
return arr.foo() === 42;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Object.defineProperty(Buffer3.prototype, "parent", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function() {
|
|
251
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
252
|
+
return this.buffer;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(Buffer3.prototype, "offset", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get: function() {
|
|
258
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
259
|
+
return this.byteOffset;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
function createBuffer(length) {
|
|
263
|
+
if (length > K_MAX_LENGTH) {
|
|
264
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
265
|
+
}
|
|
266
|
+
const buf = new Uint8Array(length);
|
|
267
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
268
|
+
return buf;
|
|
269
|
+
}
|
|
270
|
+
function Buffer3(arg, encodingOrOffset, length) {
|
|
271
|
+
if (typeof arg === "number") {
|
|
272
|
+
if (typeof encodingOrOffset === "string") {
|
|
273
|
+
throw new TypeError(
|
|
274
|
+
'The "string" argument must be of type string. Received type number'
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return allocUnsafe(arg);
|
|
278
|
+
}
|
|
279
|
+
return from(arg, encodingOrOffset, length);
|
|
280
|
+
}
|
|
281
|
+
Buffer3.poolSize = 8192;
|
|
282
|
+
function from(value, encodingOrOffset, length) {
|
|
283
|
+
if (typeof value === "string") {
|
|
284
|
+
return fromString(value, encodingOrOffset);
|
|
285
|
+
}
|
|
286
|
+
if (ArrayBuffer.isView(value)) {
|
|
287
|
+
return fromArrayView(value);
|
|
288
|
+
}
|
|
289
|
+
if (value == null) {
|
|
290
|
+
throw new TypeError(
|
|
291
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
295
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
296
|
+
}
|
|
297
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
298
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === "number") {
|
|
301
|
+
throw new TypeError(
|
|
302
|
+
'The "value" argument must not be of type number. Received type number'
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
306
|
+
if (valueOf != null && valueOf !== value) {
|
|
307
|
+
return Buffer3.from(valueOf, encodingOrOffset, length);
|
|
308
|
+
}
|
|
309
|
+
const b = fromObject(value);
|
|
310
|
+
if (b) return b;
|
|
311
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
312
|
+
return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
313
|
+
}
|
|
314
|
+
throw new TypeError(
|
|
315
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
Buffer3.from = function(value, encodingOrOffset, length) {
|
|
319
|
+
return from(value, encodingOrOffset, length);
|
|
320
|
+
};
|
|
321
|
+
Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
|
|
322
|
+
Object.setPrototypeOf(Buffer3, Uint8Array);
|
|
323
|
+
function assertSize(size) {
|
|
324
|
+
if (typeof size !== "number") {
|
|
325
|
+
throw new TypeError('"size" argument must be of type number');
|
|
326
|
+
} else if (size < 0) {
|
|
327
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function alloc(size, fill, encoding) {
|
|
331
|
+
assertSize(size);
|
|
332
|
+
if (size <= 0) {
|
|
333
|
+
return createBuffer(size);
|
|
334
|
+
}
|
|
335
|
+
if (fill !== void 0) {
|
|
336
|
+
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
|
337
|
+
}
|
|
338
|
+
return createBuffer(size);
|
|
339
|
+
}
|
|
340
|
+
Buffer3.alloc = function(size, fill, encoding) {
|
|
341
|
+
return alloc(size, fill, encoding);
|
|
342
|
+
};
|
|
343
|
+
function allocUnsafe(size) {
|
|
344
|
+
assertSize(size);
|
|
345
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
346
|
+
}
|
|
347
|
+
Buffer3.allocUnsafe = function(size) {
|
|
348
|
+
return allocUnsafe(size);
|
|
349
|
+
};
|
|
350
|
+
Buffer3.allocUnsafeSlow = function(size) {
|
|
351
|
+
return allocUnsafe(size);
|
|
352
|
+
};
|
|
353
|
+
function fromString(string, encoding) {
|
|
354
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
355
|
+
encoding = "utf8";
|
|
356
|
+
}
|
|
357
|
+
if (!Buffer3.isEncoding(encoding)) {
|
|
358
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
359
|
+
}
|
|
360
|
+
const length = byteLength(string, encoding) | 0;
|
|
361
|
+
let buf = createBuffer(length);
|
|
362
|
+
const actual = buf.write(string, encoding);
|
|
363
|
+
if (actual !== length) {
|
|
364
|
+
buf = buf.slice(0, actual);
|
|
365
|
+
}
|
|
366
|
+
return buf;
|
|
367
|
+
}
|
|
368
|
+
function fromArrayLike(array) {
|
|
369
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
370
|
+
const buf = createBuffer(length);
|
|
371
|
+
for (let i = 0; i < length; i += 1) {
|
|
372
|
+
buf[i] = array[i] & 255;
|
|
373
|
+
}
|
|
374
|
+
return buf;
|
|
375
|
+
}
|
|
376
|
+
function fromArrayView(arrayView) {
|
|
377
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
378
|
+
const copy = new Uint8Array(arrayView);
|
|
379
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
380
|
+
}
|
|
381
|
+
return fromArrayLike(arrayView);
|
|
382
|
+
}
|
|
383
|
+
function fromArrayBuffer(array, byteOffset, length) {
|
|
384
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
385
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
386
|
+
}
|
|
387
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
388
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
389
|
+
}
|
|
390
|
+
let buf;
|
|
391
|
+
if (byteOffset === void 0 && length === void 0) {
|
|
392
|
+
buf = new Uint8Array(array);
|
|
393
|
+
} else if (length === void 0) {
|
|
394
|
+
buf = new Uint8Array(array, byteOffset);
|
|
395
|
+
} else {
|
|
396
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
397
|
+
}
|
|
398
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
399
|
+
return buf;
|
|
400
|
+
}
|
|
401
|
+
function fromObject(obj) {
|
|
402
|
+
if (Buffer3.isBuffer(obj)) {
|
|
403
|
+
const len = checked(obj.length) | 0;
|
|
404
|
+
const buf = createBuffer(len);
|
|
405
|
+
if (buf.length === 0) {
|
|
406
|
+
return buf;
|
|
407
|
+
}
|
|
408
|
+
obj.copy(buf, 0, 0, len);
|
|
409
|
+
return buf;
|
|
410
|
+
}
|
|
411
|
+
if (obj.length !== void 0) {
|
|
412
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
413
|
+
return createBuffer(0);
|
|
414
|
+
}
|
|
415
|
+
return fromArrayLike(obj);
|
|
416
|
+
}
|
|
417
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
418
|
+
return fromArrayLike(obj.data);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function checked(length) {
|
|
422
|
+
if (length >= K_MAX_LENGTH) {
|
|
423
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
424
|
+
}
|
|
425
|
+
return length | 0;
|
|
426
|
+
}
|
|
427
|
+
function SlowBuffer(length) {
|
|
428
|
+
if (+length != length) {
|
|
429
|
+
length = 0;
|
|
430
|
+
}
|
|
431
|
+
return Buffer3.alloc(+length);
|
|
432
|
+
}
|
|
433
|
+
Buffer3.isBuffer = function isBuffer(b) {
|
|
434
|
+
return b != null && b._isBuffer === true && b !== Buffer3.prototype;
|
|
435
|
+
};
|
|
436
|
+
Buffer3.compare = function compare(a, b) {
|
|
437
|
+
if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
|
|
438
|
+
if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
|
|
439
|
+
if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
|
|
440
|
+
throw new TypeError(
|
|
441
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
if (a === b) return 0;
|
|
445
|
+
let x = a.length;
|
|
446
|
+
let y = b.length;
|
|
447
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
448
|
+
if (a[i] !== b[i]) {
|
|
449
|
+
x = a[i];
|
|
450
|
+
y = b[i];
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (x < y) return -1;
|
|
455
|
+
if (y < x) return 1;
|
|
456
|
+
return 0;
|
|
457
|
+
};
|
|
458
|
+
Buffer3.isEncoding = function isEncoding(encoding) {
|
|
459
|
+
switch (String(encoding).toLowerCase()) {
|
|
460
|
+
case "hex":
|
|
461
|
+
case "utf8":
|
|
462
|
+
case "utf-8":
|
|
463
|
+
case "ascii":
|
|
464
|
+
case "latin1":
|
|
465
|
+
case "binary":
|
|
466
|
+
case "base64":
|
|
467
|
+
case "ucs2":
|
|
468
|
+
case "ucs-2":
|
|
469
|
+
case "utf16le":
|
|
470
|
+
case "utf-16le":
|
|
471
|
+
return true;
|
|
472
|
+
default:
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
Buffer3.concat = function concat(list, length) {
|
|
477
|
+
if (!Array.isArray(list)) {
|
|
478
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
479
|
+
}
|
|
480
|
+
if (list.length === 0) {
|
|
481
|
+
return Buffer3.alloc(0);
|
|
482
|
+
}
|
|
483
|
+
let i;
|
|
484
|
+
if (length === void 0) {
|
|
485
|
+
length = 0;
|
|
486
|
+
for (i = 0; i < list.length; ++i) {
|
|
487
|
+
length += list[i].length;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const buffer = Buffer3.allocUnsafe(length);
|
|
491
|
+
let pos = 0;
|
|
492
|
+
for (i = 0; i < list.length; ++i) {
|
|
493
|
+
let buf = list[i];
|
|
494
|
+
if (isInstance(buf, Uint8Array)) {
|
|
495
|
+
if (pos + buf.length > buffer.length) {
|
|
496
|
+
if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
|
|
497
|
+
buf.copy(buffer, pos);
|
|
498
|
+
} else {
|
|
499
|
+
Uint8Array.prototype.set.call(
|
|
500
|
+
buffer,
|
|
501
|
+
buf,
|
|
502
|
+
pos
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
} else if (!Buffer3.isBuffer(buf)) {
|
|
506
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
507
|
+
} else {
|
|
508
|
+
buf.copy(buffer, pos);
|
|
509
|
+
}
|
|
510
|
+
pos += buf.length;
|
|
511
|
+
}
|
|
512
|
+
return buffer;
|
|
513
|
+
};
|
|
514
|
+
function byteLength(string, encoding) {
|
|
515
|
+
if (Buffer3.isBuffer(string)) {
|
|
516
|
+
return string.length;
|
|
517
|
+
}
|
|
518
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
519
|
+
return string.byteLength;
|
|
520
|
+
}
|
|
521
|
+
if (typeof string !== "string") {
|
|
522
|
+
throw new TypeError(
|
|
523
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
const len = string.length;
|
|
527
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
528
|
+
if (!mustMatch && len === 0) return 0;
|
|
529
|
+
let loweredCase = false;
|
|
530
|
+
for (; ; ) {
|
|
531
|
+
switch (encoding) {
|
|
532
|
+
case "ascii":
|
|
533
|
+
case "latin1":
|
|
534
|
+
case "binary":
|
|
535
|
+
return len;
|
|
536
|
+
case "utf8":
|
|
537
|
+
case "utf-8":
|
|
538
|
+
return utf8ToBytes(string).length;
|
|
539
|
+
case "ucs2":
|
|
540
|
+
case "ucs-2":
|
|
541
|
+
case "utf16le":
|
|
542
|
+
case "utf-16le":
|
|
543
|
+
return len * 2;
|
|
544
|
+
case "hex":
|
|
545
|
+
return len >>> 1;
|
|
546
|
+
case "base64":
|
|
547
|
+
return base64ToBytes(string).length;
|
|
548
|
+
default:
|
|
549
|
+
if (loweredCase) {
|
|
550
|
+
return mustMatch ? -1 : utf8ToBytes(string).length;
|
|
551
|
+
}
|
|
552
|
+
encoding = ("" + encoding).toLowerCase();
|
|
553
|
+
loweredCase = true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
Buffer3.byteLength = byteLength;
|
|
558
|
+
function slowToString(encoding, start, end) {
|
|
559
|
+
let loweredCase = false;
|
|
560
|
+
if (start === void 0 || start < 0) {
|
|
561
|
+
start = 0;
|
|
562
|
+
}
|
|
563
|
+
if (start > this.length) {
|
|
564
|
+
return "";
|
|
565
|
+
}
|
|
566
|
+
if (end === void 0 || end > this.length) {
|
|
567
|
+
end = this.length;
|
|
568
|
+
}
|
|
569
|
+
if (end <= 0) {
|
|
570
|
+
return "";
|
|
571
|
+
}
|
|
572
|
+
end >>>= 0;
|
|
573
|
+
start >>>= 0;
|
|
574
|
+
if (end <= start) {
|
|
575
|
+
return "";
|
|
576
|
+
}
|
|
577
|
+
if (!encoding) encoding = "utf8";
|
|
578
|
+
while (true) {
|
|
579
|
+
switch (encoding) {
|
|
580
|
+
case "hex":
|
|
581
|
+
return hexSlice(this, start, end);
|
|
582
|
+
case "utf8":
|
|
583
|
+
case "utf-8":
|
|
584
|
+
return utf8Slice(this, start, end);
|
|
585
|
+
case "ascii":
|
|
586
|
+
return asciiSlice(this, start, end);
|
|
587
|
+
case "latin1":
|
|
588
|
+
case "binary":
|
|
589
|
+
return latin1Slice(this, start, end);
|
|
590
|
+
case "base64":
|
|
591
|
+
return base64Slice(this, start, end);
|
|
592
|
+
case "ucs2":
|
|
593
|
+
case "ucs-2":
|
|
594
|
+
case "utf16le":
|
|
595
|
+
case "utf-16le":
|
|
596
|
+
return utf16leSlice(this, start, end);
|
|
597
|
+
default:
|
|
598
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
599
|
+
encoding = (encoding + "").toLowerCase();
|
|
600
|
+
loweredCase = true;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
Buffer3.prototype._isBuffer = true;
|
|
605
|
+
function swap(b, n, m) {
|
|
606
|
+
const i = b[n];
|
|
607
|
+
b[n] = b[m];
|
|
608
|
+
b[m] = i;
|
|
609
|
+
}
|
|
610
|
+
Buffer3.prototype.swap16 = function swap16() {
|
|
611
|
+
const len = this.length;
|
|
612
|
+
if (len % 2 !== 0) {
|
|
613
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
614
|
+
}
|
|
615
|
+
for (let i = 0; i < len; i += 2) {
|
|
616
|
+
swap(this, i, i + 1);
|
|
617
|
+
}
|
|
618
|
+
return this;
|
|
619
|
+
};
|
|
620
|
+
Buffer3.prototype.swap32 = function swap32() {
|
|
621
|
+
const len = this.length;
|
|
622
|
+
if (len % 4 !== 0) {
|
|
623
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
624
|
+
}
|
|
625
|
+
for (let i = 0; i < len; i += 4) {
|
|
626
|
+
swap(this, i, i + 3);
|
|
627
|
+
swap(this, i + 1, i + 2);
|
|
628
|
+
}
|
|
629
|
+
return this;
|
|
630
|
+
};
|
|
631
|
+
Buffer3.prototype.swap64 = function swap64() {
|
|
632
|
+
const len = this.length;
|
|
633
|
+
if (len % 8 !== 0) {
|
|
634
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
635
|
+
}
|
|
636
|
+
for (let i = 0; i < len; i += 8) {
|
|
637
|
+
swap(this, i, i + 7);
|
|
638
|
+
swap(this, i + 1, i + 6);
|
|
639
|
+
swap(this, i + 2, i + 5);
|
|
640
|
+
swap(this, i + 3, i + 4);
|
|
641
|
+
}
|
|
642
|
+
return this;
|
|
643
|
+
};
|
|
644
|
+
Buffer3.prototype.toString = function toString() {
|
|
645
|
+
const length = this.length;
|
|
646
|
+
if (length === 0) return "";
|
|
647
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
648
|
+
return slowToString.apply(this, arguments);
|
|
649
|
+
};
|
|
650
|
+
Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
|
|
651
|
+
Buffer3.prototype.equals = function equals(b) {
|
|
652
|
+
if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
653
|
+
if (this === b) return true;
|
|
654
|
+
return Buffer3.compare(this, b) === 0;
|
|
655
|
+
};
|
|
656
|
+
Buffer3.prototype.inspect = function inspect() {
|
|
657
|
+
let str = "";
|
|
658
|
+
const max = exports.INSPECT_MAX_BYTES;
|
|
659
|
+
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
660
|
+
if (this.length > max) str += " ... ";
|
|
661
|
+
return "<Buffer " + str + ">";
|
|
662
|
+
};
|
|
663
|
+
if (customInspectSymbol) {
|
|
664
|
+
Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
|
|
665
|
+
}
|
|
666
|
+
Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
667
|
+
if (isInstance(target, Uint8Array)) {
|
|
668
|
+
target = Buffer3.from(target, target.offset, target.byteLength);
|
|
669
|
+
}
|
|
670
|
+
if (!Buffer3.isBuffer(target)) {
|
|
671
|
+
throw new TypeError(
|
|
672
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (start === void 0) {
|
|
676
|
+
start = 0;
|
|
677
|
+
}
|
|
678
|
+
if (end === void 0) {
|
|
679
|
+
end = target ? target.length : 0;
|
|
680
|
+
}
|
|
681
|
+
if (thisStart === void 0) {
|
|
682
|
+
thisStart = 0;
|
|
683
|
+
}
|
|
684
|
+
if (thisEnd === void 0) {
|
|
685
|
+
thisEnd = this.length;
|
|
686
|
+
}
|
|
687
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
688
|
+
throw new RangeError("out of range index");
|
|
689
|
+
}
|
|
690
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
691
|
+
return 0;
|
|
692
|
+
}
|
|
693
|
+
if (thisStart >= thisEnd) {
|
|
694
|
+
return -1;
|
|
695
|
+
}
|
|
696
|
+
if (start >= end) {
|
|
697
|
+
return 1;
|
|
698
|
+
}
|
|
699
|
+
start >>>= 0;
|
|
700
|
+
end >>>= 0;
|
|
701
|
+
thisStart >>>= 0;
|
|
702
|
+
thisEnd >>>= 0;
|
|
703
|
+
if (this === target) return 0;
|
|
704
|
+
let x = thisEnd - thisStart;
|
|
705
|
+
let y = end - start;
|
|
706
|
+
const len = Math.min(x, y);
|
|
707
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
708
|
+
const targetCopy = target.slice(start, end);
|
|
709
|
+
for (let i = 0; i < len; ++i) {
|
|
710
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
711
|
+
x = thisCopy[i];
|
|
712
|
+
y = targetCopy[i];
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (x < y) return -1;
|
|
717
|
+
if (y < x) return 1;
|
|
718
|
+
return 0;
|
|
719
|
+
};
|
|
720
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
721
|
+
if (buffer.length === 0) return -1;
|
|
722
|
+
if (typeof byteOffset === "string") {
|
|
723
|
+
encoding = byteOffset;
|
|
724
|
+
byteOffset = 0;
|
|
725
|
+
} else if (byteOffset > 2147483647) {
|
|
726
|
+
byteOffset = 2147483647;
|
|
727
|
+
} else if (byteOffset < -2147483648) {
|
|
728
|
+
byteOffset = -2147483648;
|
|
729
|
+
}
|
|
730
|
+
byteOffset = +byteOffset;
|
|
731
|
+
if (numberIsNaN(byteOffset)) {
|
|
732
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
733
|
+
}
|
|
734
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
735
|
+
if (byteOffset >= buffer.length) {
|
|
736
|
+
if (dir) return -1;
|
|
737
|
+
else byteOffset = buffer.length - 1;
|
|
738
|
+
} else if (byteOffset < 0) {
|
|
739
|
+
if (dir) byteOffset = 0;
|
|
740
|
+
else return -1;
|
|
741
|
+
}
|
|
742
|
+
if (typeof val === "string") {
|
|
743
|
+
val = Buffer3.from(val, encoding);
|
|
744
|
+
}
|
|
745
|
+
if (Buffer3.isBuffer(val)) {
|
|
746
|
+
if (val.length === 0) {
|
|
747
|
+
return -1;
|
|
748
|
+
}
|
|
749
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
750
|
+
} else if (typeof val === "number") {
|
|
751
|
+
val = val & 255;
|
|
752
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
753
|
+
if (dir) {
|
|
754
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
755
|
+
} else {
|
|
756
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
760
|
+
}
|
|
761
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
762
|
+
}
|
|
763
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
764
|
+
let indexSize = 1;
|
|
765
|
+
let arrLength = arr.length;
|
|
766
|
+
let valLength = val.length;
|
|
767
|
+
if (encoding !== void 0) {
|
|
768
|
+
encoding = String(encoding).toLowerCase();
|
|
769
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
770
|
+
if (arr.length < 2 || val.length < 2) {
|
|
771
|
+
return -1;
|
|
772
|
+
}
|
|
773
|
+
indexSize = 2;
|
|
774
|
+
arrLength /= 2;
|
|
775
|
+
valLength /= 2;
|
|
776
|
+
byteOffset /= 2;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
function read(buf, i2) {
|
|
780
|
+
if (indexSize === 1) {
|
|
781
|
+
return buf[i2];
|
|
782
|
+
} else {
|
|
783
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
let i;
|
|
787
|
+
if (dir) {
|
|
788
|
+
let foundIndex = -1;
|
|
789
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
790
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
791
|
+
if (foundIndex === -1) foundIndex = i;
|
|
792
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
793
|
+
} else {
|
|
794
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
795
|
+
foundIndex = -1;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
800
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
801
|
+
let found = true;
|
|
802
|
+
for (let j = 0; j < valLength; j++) {
|
|
803
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
804
|
+
found = false;
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (found) return i;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return -1;
|
|
812
|
+
}
|
|
813
|
+
Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
814
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
815
|
+
};
|
|
816
|
+
Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
817
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
818
|
+
};
|
|
819
|
+
Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
820
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
821
|
+
};
|
|
822
|
+
function hexWrite(buf, string, offset, length) {
|
|
823
|
+
offset = Number(offset) || 0;
|
|
824
|
+
const remaining = buf.length - offset;
|
|
825
|
+
if (!length) {
|
|
826
|
+
length = remaining;
|
|
827
|
+
} else {
|
|
828
|
+
length = Number(length);
|
|
829
|
+
if (length > remaining) {
|
|
830
|
+
length = remaining;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
const strLen = string.length;
|
|
834
|
+
if (length > strLen / 2) {
|
|
835
|
+
length = strLen / 2;
|
|
836
|
+
}
|
|
837
|
+
let i;
|
|
838
|
+
for (i = 0; i < length; ++i) {
|
|
839
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
840
|
+
if (numberIsNaN(parsed)) return i;
|
|
841
|
+
buf[offset + i] = parsed;
|
|
842
|
+
}
|
|
843
|
+
return i;
|
|
844
|
+
}
|
|
845
|
+
function utf8Write(buf, string, offset, length) {
|
|
846
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
847
|
+
}
|
|
848
|
+
function asciiWrite(buf, string, offset, length) {
|
|
849
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
850
|
+
}
|
|
851
|
+
function base64Write(buf, string, offset, length) {
|
|
852
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
853
|
+
}
|
|
854
|
+
function ucs2Write(buf, string, offset, length) {
|
|
855
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
856
|
+
}
|
|
857
|
+
Buffer3.prototype.write = function write(string, offset, length, encoding) {
|
|
858
|
+
if (offset === void 0) {
|
|
859
|
+
encoding = "utf8";
|
|
860
|
+
length = this.length;
|
|
861
|
+
offset = 0;
|
|
862
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
863
|
+
encoding = offset;
|
|
864
|
+
length = this.length;
|
|
865
|
+
offset = 0;
|
|
866
|
+
} else if (isFinite(offset)) {
|
|
867
|
+
offset = offset >>> 0;
|
|
868
|
+
if (isFinite(length)) {
|
|
869
|
+
length = length >>> 0;
|
|
870
|
+
if (encoding === void 0) encoding = "utf8";
|
|
871
|
+
} else {
|
|
872
|
+
encoding = length;
|
|
873
|
+
length = void 0;
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
throw new Error(
|
|
877
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
const remaining = this.length - offset;
|
|
881
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
882
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
883
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
884
|
+
}
|
|
885
|
+
if (!encoding) encoding = "utf8";
|
|
886
|
+
let loweredCase = false;
|
|
887
|
+
for (; ; ) {
|
|
888
|
+
switch (encoding) {
|
|
889
|
+
case "hex":
|
|
890
|
+
return hexWrite(this, string, offset, length);
|
|
891
|
+
case "utf8":
|
|
892
|
+
case "utf-8":
|
|
893
|
+
return utf8Write(this, string, offset, length);
|
|
894
|
+
case "ascii":
|
|
895
|
+
case "latin1":
|
|
896
|
+
case "binary":
|
|
897
|
+
return asciiWrite(this, string, offset, length);
|
|
898
|
+
case "base64":
|
|
899
|
+
return base64Write(this, string, offset, length);
|
|
900
|
+
case "ucs2":
|
|
901
|
+
case "ucs-2":
|
|
902
|
+
case "utf16le":
|
|
903
|
+
case "utf-16le":
|
|
904
|
+
return ucs2Write(this, string, offset, length);
|
|
905
|
+
default:
|
|
906
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
907
|
+
encoding = ("" + encoding).toLowerCase();
|
|
908
|
+
loweredCase = true;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
Buffer3.prototype.toJSON = function toJSON() {
|
|
913
|
+
return {
|
|
914
|
+
type: "Buffer",
|
|
915
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
function base64Slice(buf, start, end) {
|
|
919
|
+
if (start === 0 && end === buf.length) {
|
|
920
|
+
return base64.fromByteArray(buf);
|
|
921
|
+
} else {
|
|
922
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function utf8Slice(buf, start, end) {
|
|
926
|
+
end = Math.min(buf.length, end);
|
|
927
|
+
const res = [];
|
|
928
|
+
let i = start;
|
|
929
|
+
while (i < end) {
|
|
930
|
+
const firstByte = buf[i];
|
|
931
|
+
let codePoint = null;
|
|
932
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
933
|
+
if (i + bytesPerSequence <= end) {
|
|
934
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
935
|
+
switch (bytesPerSequence) {
|
|
936
|
+
case 1:
|
|
937
|
+
if (firstByte < 128) {
|
|
938
|
+
codePoint = firstByte;
|
|
939
|
+
}
|
|
940
|
+
break;
|
|
941
|
+
case 2:
|
|
942
|
+
secondByte = buf[i + 1];
|
|
943
|
+
if ((secondByte & 192) === 128) {
|
|
944
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
945
|
+
if (tempCodePoint > 127) {
|
|
946
|
+
codePoint = tempCodePoint;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
break;
|
|
950
|
+
case 3:
|
|
951
|
+
secondByte = buf[i + 1];
|
|
952
|
+
thirdByte = buf[i + 2];
|
|
953
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
954
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
955
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
956
|
+
codePoint = tempCodePoint;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
break;
|
|
960
|
+
case 4:
|
|
961
|
+
secondByte = buf[i + 1];
|
|
962
|
+
thirdByte = buf[i + 2];
|
|
963
|
+
fourthByte = buf[i + 3];
|
|
964
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
965
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
966
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
967
|
+
codePoint = tempCodePoint;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (codePoint === null) {
|
|
973
|
+
codePoint = 65533;
|
|
974
|
+
bytesPerSequence = 1;
|
|
975
|
+
} else if (codePoint > 65535) {
|
|
976
|
+
codePoint -= 65536;
|
|
977
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
978
|
+
codePoint = 56320 | codePoint & 1023;
|
|
979
|
+
}
|
|
980
|
+
res.push(codePoint);
|
|
981
|
+
i += bytesPerSequence;
|
|
982
|
+
}
|
|
983
|
+
return decodeCodePointsArray(res);
|
|
984
|
+
}
|
|
985
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
986
|
+
function decodeCodePointsArray(codePoints) {
|
|
987
|
+
const len = codePoints.length;
|
|
988
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
989
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
990
|
+
}
|
|
991
|
+
let res = "";
|
|
992
|
+
let i = 0;
|
|
993
|
+
while (i < len) {
|
|
994
|
+
res += String.fromCharCode.apply(
|
|
995
|
+
String,
|
|
996
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
return res;
|
|
1000
|
+
}
|
|
1001
|
+
function asciiSlice(buf, start, end) {
|
|
1002
|
+
let ret = "";
|
|
1003
|
+
end = Math.min(buf.length, end);
|
|
1004
|
+
for (let i = start; i < end; ++i) {
|
|
1005
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
1006
|
+
}
|
|
1007
|
+
return ret;
|
|
1008
|
+
}
|
|
1009
|
+
function latin1Slice(buf, start, end) {
|
|
1010
|
+
let ret = "";
|
|
1011
|
+
end = Math.min(buf.length, end);
|
|
1012
|
+
for (let i = start; i < end; ++i) {
|
|
1013
|
+
ret += String.fromCharCode(buf[i]);
|
|
1014
|
+
}
|
|
1015
|
+
return ret;
|
|
1016
|
+
}
|
|
1017
|
+
function hexSlice(buf, start, end) {
|
|
1018
|
+
const len = buf.length;
|
|
1019
|
+
if (!start || start < 0) start = 0;
|
|
1020
|
+
if (!end || end < 0 || end > len) end = len;
|
|
1021
|
+
let out = "";
|
|
1022
|
+
for (let i = start; i < end; ++i) {
|
|
1023
|
+
out += hexSliceLookupTable[buf[i]];
|
|
1024
|
+
}
|
|
1025
|
+
return out;
|
|
1026
|
+
}
|
|
1027
|
+
function utf16leSlice(buf, start, end) {
|
|
1028
|
+
const bytes = buf.slice(start, end);
|
|
1029
|
+
let res = "";
|
|
1030
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
1031
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
1032
|
+
}
|
|
1033
|
+
return res;
|
|
1034
|
+
}
|
|
1035
|
+
Buffer3.prototype.slice = function slice(start, end) {
|
|
1036
|
+
const len = this.length;
|
|
1037
|
+
start = ~~start;
|
|
1038
|
+
end = end === void 0 ? len : ~~end;
|
|
1039
|
+
if (start < 0) {
|
|
1040
|
+
start += len;
|
|
1041
|
+
if (start < 0) start = 0;
|
|
1042
|
+
} else if (start > len) {
|
|
1043
|
+
start = len;
|
|
1044
|
+
}
|
|
1045
|
+
if (end < 0) {
|
|
1046
|
+
end += len;
|
|
1047
|
+
if (end < 0) end = 0;
|
|
1048
|
+
} else if (end > len) {
|
|
1049
|
+
end = len;
|
|
1050
|
+
}
|
|
1051
|
+
if (end < start) end = start;
|
|
1052
|
+
const newBuf = this.subarray(start, end);
|
|
1053
|
+
Object.setPrototypeOf(newBuf, Buffer3.prototype);
|
|
1054
|
+
return newBuf;
|
|
1055
|
+
};
|
|
1056
|
+
function checkOffset(offset, ext, length) {
|
|
1057
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1058
|
+
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1059
|
+
}
|
|
1060
|
+
Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1061
|
+
offset = offset >>> 0;
|
|
1062
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1063
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1064
|
+
let val = this[offset];
|
|
1065
|
+
let mul = 1;
|
|
1066
|
+
let i = 0;
|
|
1067
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1068
|
+
val += this[offset + i] * mul;
|
|
1069
|
+
}
|
|
1070
|
+
return val;
|
|
1071
|
+
};
|
|
1072
|
+
Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1073
|
+
offset = offset >>> 0;
|
|
1074
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1075
|
+
if (!noAssert) {
|
|
1076
|
+
checkOffset(offset, byteLength2, this.length);
|
|
1077
|
+
}
|
|
1078
|
+
let val = this[offset + --byteLength2];
|
|
1079
|
+
let mul = 1;
|
|
1080
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1081
|
+
val += this[offset + --byteLength2] * mul;
|
|
1082
|
+
}
|
|
1083
|
+
return val;
|
|
1084
|
+
};
|
|
1085
|
+
Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1086
|
+
offset = offset >>> 0;
|
|
1087
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1088
|
+
return this[offset];
|
|
1089
|
+
};
|
|
1090
|
+
Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1091
|
+
offset = offset >>> 0;
|
|
1092
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1093
|
+
return this[offset] | this[offset + 1] << 8;
|
|
1094
|
+
};
|
|
1095
|
+
Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1096
|
+
offset = offset >>> 0;
|
|
1097
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1098
|
+
return this[offset] << 8 | this[offset + 1];
|
|
1099
|
+
};
|
|
1100
|
+
Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1101
|
+
offset = offset >>> 0;
|
|
1102
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1103
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1104
|
+
};
|
|
1105
|
+
Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1106
|
+
offset = offset >>> 0;
|
|
1107
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1108
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1109
|
+
};
|
|
1110
|
+
Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1111
|
+
offset = offset >>> 0;
|
|
1112
|
+
validateNumber(offset, "offset");
|
|
1113
|
+
const first = this[offset];
|
|
1114
|
+
const last = this[offset + 7];
|
|
1115
|
+
if (first === void 0 || last === void 0) {
|
|
1116
|
+
boundsError(offset, this.length - 8);
|
|
1117
|
+
}
|
|
1118
|
+
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
|
1119
|
+
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1120
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1121
|
+
});
|
|
1122
|
+
Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1123
|
+
offset = offset >>> 0;
|
|
1124
|
+
validateNumber(offset, "offset");
|
|
1125
|
+
const first = this[offset];
|
|
1126
|
+
const last = this[offset + 7];
|
|
1127
|
+
if (first === void 0 || last === void 0) {
|
|
1128
|
+
boundsError(offset, this.length - 8);
|
|
1129
|
+
}
|
|
1130
|
+
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1131
|
+
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1132
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1133
|
+
});
|
|
1134
|
+
Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1135
|
+
offset = offset >>> 0;
|
|
1136
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1137
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1138
|
+
let val = this[offset];
|
|
1139
|
+
let mul = 1;
|
|
1140
|
+
let i = 0;
|
|
1141
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1142
|
+
val += this[offset + i] * mul;
|
|
1143
|
+
}
|
|
1144
|
+
mul *= 128;
|
|
1145
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1146
|
+
return val;
|
|
1147
|
+
};
|
|
1148
|
+
Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1149
|
+
offset = offset >>> 0;
|
|
1150
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1151
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1152
|
+
let i = byteLength2;
|
|
1153
|
+
let mul = 1;
|
|
1154
|
+
let val = this[offset + --i];
|
|
1155
|
+
while (i > 0 && (mul *= 256)) {
|
|
1156
|
+
val += this[offset + --i] * mul;
|
|
1157
|
+
}
|
|
1158
|
+
mul *= 128;
|
|
1159
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1160
|
+
return val;
|
|
1161
|
+
};
|
|
1162
|
+
Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1163
|
+
offset = offset >>> 0;
|
|
1164
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1165
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
1166
|
+
return (255 - this[offset] + 1) * -1;
|
|
1167
|
+
};
|
|
1168
|
+
Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1169
|
+
offset = offset >>> 0;
|
|
1170
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1171
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
1172
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1173
|
+
};
|
|
1174
|
+
Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1175
|
+
offset = offset >>> 0;
|
|
1176
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1177
|
+
const val = this[offset + 1] | this[offset] << 8;
|
|
1178
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1179
|
+
};
|
|
1180
|
+
Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1181
|
+
offset = offset >>> 0;
|
|
1182
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1183
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1184
|
+
};
|
|
1185
|
+
Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1186
|
+
offset = offset >>> 0;
|
|
1187
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1188
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1189
|
+
};
|
|
1190
|
+
Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1191
|
+
offset = offset >>> 0;
|
|
1192
|
+
validateNumber(offset, "offset");
|
|
1193
|
+
const first = this[offset];
|
|
1194
|
+
const last = this[offset + 7];
|
|
1195
|
+
if (first === void 0 || last === void 0) {
|
|
1196
|
+
boundsError(offset, this.length - 8);
|
|
1197
|
+
}
|
|
1198
|
+
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1199
|
+
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1200
|
+
});
|
|
1201
|
+
Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1202
|
+
offset = offset >>> 0;
|
|
1203
|
+
validateNumber(offset, "offset");
|
|
1204
|
+
const first = this[offset];
|
|
1205
|
+
const last = this[offset + 7];
|
|
1206
|
+
if (first === void 0 || last === void 0) {
|
|
1207
|
+
boundsError(offset, this.length - 8);
|
|
1208
|
+
}
|
|
1209
|
+
const val = (first << 24) + // Overflow
|
|
1210
|
+
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1211
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
1212
|
+
});
|
|
1213
|
+
Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1214
|
+
offset = offset >>> 0;
|
|
1215
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1216
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
1217
|
+
};
|
|
1218
|
+
Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1219
|
+
offset = offset >>> 0;
|
|
1220
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1221
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
1222
|
+
};
|
|
1223
|
+
Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1224
|
+
offset = offset >>> 0;
|
|
1225
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1226
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
1227
|
+
};
|
|
1228
|
+
Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1229
|
+
offset = offset >>> 0;
|
|
1230
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1231
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
1232
|
+
};
|
|
1233
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
1234
|
+
if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1235
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1236
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1237
|
+
}
|
|
1238
|
+
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1239
|
+
value = +value;
|
|
1240
|
+
offset = offset >>> 0;
|
|
1241
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1242
|
+
if (!noAssert) {
|
|
1243
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1244
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1245
|
+
}
|
|
1246
|
+
let mul = 1;
|
|
1247
|
+
let i = 0;
|
|
1248
|
+
this[offset] = value & 255;
|
|
1249
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1250
|
+
this[offset + i] = value / mul & 255;
|
|
1251
|
+
}
|
|
1252
|
+
return offset + byteLength2;
|
|
1253
|
+
};
|
|
1254
|
+
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1255
|
+
value = +value;
|
|
1256
|
+
offset = offset >>> 0;
|
|
1257
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1258
|
+
if (!noAssert) {
|
|
1259
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1260
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1261
|
+
}
|
|
1262
|
+
let i = byteLength2 - 1;
|
|
1263
|
+
let mul = 1;
|
|
1264
|
+
this[offset + i] = value & 255;
|
|
1265
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1266
|
+
this[offset + i] = value / mul & 255;
|
|
1267
|
+
}
|
|
1268
|
+
return offset + byteLength2;
|
|
1269
|
+
};
|
|
1270
|
+
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1271
|
+
value = +value;
|
|
1272
|
+
offset = offset >>> 0;
|
|
1273
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1274
|
+
this[offset] = value & 255;
|
|
1275
|
+
return offset + 1;
|
|
1276
|
+
};
|
|
1277
|
+
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1278
|
+
value = +value;
|
|
1279
|
+
offset = offset >>> 0;
|
|
1280
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1281
|
+
this[offset] = value & 255;
|
|
1282
|
+
this[offset + 1] = value >>> 8;
|
|
1283
|
+
return offset + 2;
|
|
1284
|
+
};
|
|
1285
|
+
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1286
|
+
value = +value;
|
|
1287
|
+
offset = offset >>> 0;
|
|
1288
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1289
|
+
this[offset] = value >>> 8;
|
|
1290
|
+
this[offset + 1] = value & 255;
|
|
1291
|
+
return offset + 2;
|
|
1292
|
+
};
|
|
1293
|
+
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1294
|
+
value = +value;
|
|
1295
|
+
offset = offset >>> 0;
|
|
1296
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1297
|
+
this[offset + 3] = value >>> 24;
|
|
1298
|
+
this[offset + 2] = value >>> 16;
|
|
1299
|
+
this[offset + 1] = value >>> 8;
|
|
1300
|
+
this[offset] = value & 255;
|
|
1301
|
+
return offset + 4;
|
|
1302
|
+
};
|
|
1303
|
+
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1304
|
+
value = +value;
|
|
1305
|
+
offset = offset >>> 0;
|
|
1306
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1307
|
+
this[offset] = value >>> 24;
|
|
1308
|
+
this[offset + 1] = value >>> 16;
|
|
1309
|
+
this[offset + 2] = value >>> 8;
|
|
1310
|
+
this[offset + 3] = value & 255;
|
|
1311
|
+
return offset + 4;
|
|
1312
|
+
};
|
|
1313
|
+
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1314
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1315
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1316
|
+
buf[offset++] = lo;
|
|
1317
|
+
lo = lo >> 8;
|
|
1318
|
+
buf[offset++] = lo;
|
|
1319
|
+
lo = lo >> 8;
|
|
1320
|
+
buf[offset++] = lo;
|
|
1321
|
+
lo = lo >> 8;
|
|
1322
|
+
buf[offset++] = lo;
|
|
1323
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1324
|
+
buf[offset++] = hi;
|
|
1325
|
+
hi = hi >> 8;
|
|
1326
|
+
buf[offset++] = hi;
|
|
1327
|
+
hi = hi >> 8;
|
|
1328
|
+
buf[offset++] = hi;
|
|
1329
|
+
hi = hi >> 8;
|
|
1330
|
+
buf[offset++] = hi;
|
|
1331
|
+
return offset;
|
|
1332
|
+
}
|
|
1333
|
+
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1334
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1335
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1336
|
+
buf[offset + 7] = lo;
|
|
1337
|
+
lo = lo >> 8;
|
|
1338
|
+
buf[offset + 6] = lo;
|
|
1339
|
+
lo = lo >> 8;
|
|
1340
|
+
buf[offset + 5] = lo;
|
|
1341
|
+
lo = lo >> 8;
|
|
1342
|
+
buf[offset + 4] = lo;
|
|
1343
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1344
|
+
buf[offset + 3] = hi;
|
|
1345
|
+
hi = hi >> 8;
|
|
1346
|
+
buf[offset + 2] = hi;
|
|
1347
|
+
hi = hi >> 8;
|
|
1348
|
+
buf[offset + 1] = hi;
|
|
1349
|
+
hi = hi >> 8;
|
|
1350
|
+
buf[offset] = hi;
|
|
1351
|
+
return offset + 8;
|
|
1352
|
+
}
|
|
1353
|
+
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1354
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1355
|
+
});
|
|
1356
|
+
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1357
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1358
|
+
});
|
|
1359
|
+
Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1360
|
+
value = +value;
|
|
1361
|
+
offset = offset >>> 0;
|
|
1362
|
+
if (!noAssert) {
|
|
1363
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1364
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1365
|
+
}
|
|
1366
|
+
let i = 0;
|
|
1367
|
+
let mul = 1;
|
|
1368
|
+
let sub = 0;
|
|
1369
|
+
this[offset] = value & 255;
|
|
1370
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1371
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1372
|
+
sub = 1;
|
|
1373
|
+
}
|
|
1374
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1375
|
+
}
|
|
1376
|
+
return offset + byteLength2;
|
|
1377
|
+
};
|
|
1378
|
+
Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1379
|
+
value = +value;
|
|
1380
|
+
offset = offset >>> 0;
|
|
1381
|
+
if (!noAssert) {
|
|
1382
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1383
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1384
|
+
}
|
|
1385
|
+
let i = byteLength2 - 1;
|
|
1386
|
+
let mul = 1;
|
|
1387
|
+
let sub = 0;
|
|
1388
|
+
this[offset + i] = value & 255;
|
|
1389
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1390
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1391
|
+
sub = 1;
|
|
1392
|
+
}
|
|
1393
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1394
|
+
}
|
|
1395
|
+
return offset + byteLength2;
|
|
1396
|
+
};
|
|
1397
|
+
Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1398
|
+
value = +value;
|
|
1399
|
+
offset = offset >>> 0;
|
|
1400
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1401
|
+
if (value < 0) value = 255 + value + 1;
|
|
1402
|
+
this[offset] = value & 255;
|
|
1403
|
+
return offset + 1;
|
|
1404
|
+
};
|
|
1405
|
+
Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1406
|
+
value = +value;
|
|
1407
|
+
offset = offset >>> 0;
|
|
1408
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1409
|
+
this[offset] = value & 255;
|
|
1410
|
+
this[offset + 1] = value >>> 8;
|
|
1411
|
+
return offset + 2;
|
|
1412
|
+
};
|
|
1413
|
+
Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1414
|
+
value = +value;
|
|
1415
|
+
offset = offset >>> 0;
|
|
1416
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1417
|
+
this[offset] = value >>> 8;
|
|
1418
|
+
this[offset + 1] = value & 255;
|
|
1419
|
+
return offset + 2;
|
|
1420
|
+
};
|
|
1421
|
+
Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1422
|
+
value = +value;
|
|
1423
|
+
offset = offset >>> 0;
|
|
1424
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1425
|
+
this[offset] = value & 255;
|
|
1426
|
+
this[offset + 1] = value >>> 8;
|
|
1427
|
+
this[offset + 2] = value >>> 16;
|
|
1428
|
+
this[offset + 3] = value >>> 24;
|
|
1429
|
+
return offset + 4;
|
|
1430
|
+
};
|
|
1431
|
+
Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1432
|
+
value = +value;
|
|
1433
|
+
offset = offset >>> 0;
|
|
1434
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1435
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1436
|
+
this[offset] = value >>> 24;
|
|
1437
|
+
this[offset + 1] = value >>> 16;
|
|
1438
|
+
this[offset + 2] = value >>> 8;
|
|
1439
|
+
this[offset + 3] = value & 255;
|
|
1440
|
+
return offset + 4;
|
|
1441
|
+
};
|
|
1442
|
+
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1443
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1444
|
+
});
|
|
1445
|
+
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1446
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1447
|
+
});
|
|
1448
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1449
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1450
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
1451
|
+
}
|
|
1452
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1453
|
+
value = +value;
|
|
1454
|
+
offset = offset >>> 0;
|
|
1455
|
+
if (!noAssert) {
|
|
1456
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
1457
|
+
}
|
|
1458
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1459
|
+
return offset + 4;
|
|
1460
|
+
}
|
|
1461
|
+
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1462
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1463
|
+
};
|
|
1464
|
+
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1465
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1466
|
+
};
|
|
1467
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1468
|
+
value = +value;
|
|
1469
|
+
offset = offset >>> 0;
|
|
1470
|
+
if (!noAssert) {
|
|
1471
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
1472
|
+
}
|
|
1473
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1474
|
+
return offset + 8;
|
|
1475
|
+
}
|
|
1476
|
+
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1477
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1478
|
+
};
|
|
1479
|
+
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1480
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1481
|
+
};
|
|
1482
|
+
Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1483
|
+
if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1484
|
+
if (!start) start = 0;
|
|
1485
|
+
if (!end && end !== 0) end = this.length;
|
|
1486
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
1487
|
+
if (!targetStart) targetStart = 0;
|
|
1488
|
+
if (end > 0 && end < start) end = start;
|
|
1489
|
+
if (end === start) return 0;
|
|
1490
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
1491
|
+
if (targetStart < 0) {
|
|
1492
|
+
throw new RangeError("targetStart out of bounds");
|
|
1493
|
+
}
|
|
1494
|
+
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1495
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1496
|
+
if (end > this.length) end = this.length;
|
|
1497
|
+
if (target.length - targetStart < end - start) {
|
|
1498
|
+
end = target.length - targetStart + start;
|
|
1499
|
+
}
|
|
1500
|
+
const len = end - start;
|
|
1501
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
1502
|
+
this.copyWithin(targetStart, start, end);
|
|
1503
|
+
} else {
|
|
1504
|
+
Uint8Array.prototype.set.call(
|
|
1505
|
+
target,
|
|
1506
|
+
this.subarray(start, end),
|
|
1507
|
+
targetStart
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
return len;
|
|
1511
|
+
};
|
|
1512
|
+
Buffer3.prototype.fill = function fill(val, start, end, encoding) {
|
|
1513
|
+
if (typeof val === "string") {
|
|
1514
|
+
if (typeof start === "string") {
|
|
1515
|
+
encoding = start;
|
|
1516
|
+
start = 0;
|
|
1517
|
+
end = this.length;
|
|
1518
|
+
} else if (typeof end === "string") {
|
|
1519
|
+
encoding = end;
|
|
1520
|
+
end = this.length;
|
|
1521
|
+
}
|
|
1522
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1523
|
+
throw new TypeError("encoding must be a string");
|
|
1524
|
+
}
|
|
1525
|
+
if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
|
|
1526
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
1527
|
+
}
|
|
1528
|
+
if (val.length === 1) {
|
|
1529
|
+
const code = val.charCodeAt(0);
|
|
1530
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
1531
|
+
val = code;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
} else if (typeof val === "number") {
|
|
1535
|
+
val = val & 255;
|
|
1536
|
+
} else if (typeof val === "boolean") {
|
|
1537
|
+
val = Number(val);
|
|
1538
|
+
}
|
|
1539
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
1540
|
+
throw new RangeError("Out of range index");
|
|
1541
|
+
}
|
|
1542
|
+
if (end <= start) {
|
|
1543
|
+
return this;
|
|
1544
|
+
}
|
|
1545
|
+
start = start >>> 0;
|
|
1546
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
1547
|
+
if (!val) val = 0;
|
|
1548
|
+
let i;
|
|
1549
|
+
if (typeof val === "number") {
|
|
1550
|
+
for (i = start; i < end; ++i) {
|
|
1551
|
+
this[i] = val;
|
|
1552
|
+
}
|
|
1553
|
+
} else {
|
|
1554
|
+
const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
|
|
1555
|
+
const len = bytes.length;
|
|
1556
|
+
if (len === 0) {
|
|
1557
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1558
|
+
}
|
|
1559
|
+
for (i = 0; i < end - start; ++i) {
|
|
1560
|
+
this[i + start] = bytes[i % len];
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return this;
|
|
1564
|
+
};
|
|
1565
|
+
var errors = {};
|
|
1566
|
+
function E(sym, getMessage, Base) {
|
|
1567
|
+
errors[sym] = class NodeError extends Base {
|
|
1568
|
+
constructor() {
|
|
1569
|
+
super();
|
|
1570
|
+
Object.defineProperty(this, "message", {
|
|
1571
|
+
value: getMessage.apply(this, arguments),
|
|
1572
|
+
writable: true,
|
|
1573
|
+
configurable: true
|
|
1574
|
+
});
|
|
1575
|
+
this.name = `${this.name} [${sym}]`;
|
|
1576
|
+
this.stack;
|
|
1577
|
+
delete this.name;
|
|
1578
|
+
}
|
|
1579
|
+
get code() {
|
|
1580
|
+
return sym;
|
|
1581
|
+
}
|
|
1582
|
+
set code(value) {
|
|
1583
|
+
Object.defineProperty(this, "code", {
|
|
1584
|
+
configurable: true,
|
|
1585
|
+
enumerable: true,
|
|
1586
|
+
value,
|
|
1587
|
+
writable: true
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
toString() {
|
|
1591
|
+
return `${this.name} [${sym}]: ${this.message}`;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
E(
|
|
1596
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1597
|
+
function(name) {
|
|
1598
|
+
if (name) {
|
|
1599
|
+
return `${name} is outside of buffer bounds`;
|
|
1600
|
+
}
|
|
1601
|
+
return "Attempt to access memory outside buffer bounds";
|
|
1602
|
+
},
|
|
1603
|
+
RangeError
|
|
1604
|
+
);
|
|
1605
|
+
E(
|
|
1606
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1607
|
+
function(name, actual) {
|
|
1608
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1609
|
+
},
|
|
1610
|
+
TypeError
|
|
1611
|
+
);
|
|
1612
|
+
E(
|
|
1613
|
+
"ERR_OUT_OF_RANGE",
|
|
1614
|
+
function(str, range, input) {
|
|
1615
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
1616
|
+
let received = input;
|
|
1617
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1618
|
+
received = addNumericalSeparator(String(input));
|
|
1619
|
+
} else if (typeof input === "bigint") {
|
|
1620
|
+
received = String(input);
|
|
1621
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1622
|
+
received = addNumericalSeparator(received);
|
|
1623
|
+
}
|
|
1624
|
+
received += "n";
|
|
1625
|
+
}
|
|
1626
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
1627
|
+
return msg;
|
|
1628
|
+
},
|
|
1629
|
+
RangeError
|
|
1630
|
+
);
|
|
1631
|
+
function addNumericalSeparator(val) {
|
|
1632
|
+
let res = "";
|
|
1633
|
+
let i = val.length;
|
|
1634
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
1635
|
+
for (; i >= start + 4; i -= 3) {
|
|
1636
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1637
|
+
}
|
|
1638
|
+
return `${val.slice(0, i)}${res}`;
|
|
1639
|
+
}
|
|
1640
|
+
function checkBounds(buf, offset, byteLength2) {
|
|
1641
|
+
validateNumber(offset, "offset");
|
|
1642
|
+
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
|
|
1643
|
+
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
function checkIntBI(value, min, max, buf, offset, byteLength2) {
|
|
1647
|
+
if (value > max || value < min) {
|
|
1648
|
+
const n = typeof min === "bigint" ? "n" : "";
|
|
1649
|
+
let range;
|
|
1650
|
+
if (byteLength2 > 3) {
|
|
1651
|
+
if (min === 0 || min === BigInt(0)) {
|
|
1652
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
|
|
1653
|
+
} else {
|
|
1654
|
+
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
|
|
1655
|
+
}
|
|
1656
|
+
} else {
|
|
1657
|
+
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
1658
|
+
}
|
|
1659
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1660
|
+
}
|
|
1661
|
+
checkBounds(buf, offset, byteLength2);
|
|
1662
|
+
}
|
|
1663
|
+
function validateNumber(value, name) {
|
|
1664
|
+
if (typeof value !== "number") {
|
|
1665
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
function boundsError(value, length, type) {
|
|
1669
|
+
if (Math.floor(value) !== value) {
|
|
1670
|
+
validateNumber(value, type);
|
|
1671
|
+
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
|
|
1672
|
+
}
|
|
1673
|
+
if (length < 0) {
|
|
1674
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1675
|
+
}
|
|
1676
|
+
throw new errors.ERR_OUT_OF_RANGE(
|
|
1677
|
+
type || "offset",
|
|
1678
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
1679
|
+
value
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1683
|
+
function base64clean(str) {
|
|
1684
|
+
str = str.split("=")[0];
|
|
1685
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1686
|
+
if (str.length < 2) return "";
|
|
1687
|
+
while (str.length % 4 !== 0) {
|
|
1688
|
+
str = str + "=";
|
|
1689
|
+
}
|
|
1690
|
+
return str;
|
|
1691
|
+
}
|
|
1692
|
+
function utf8ToBytes(string, units) {
|
|
1693
|
+
units = units || Infinity;
|
|
1694
|
+
let codePoint;
|
|
1695
|
+
const length = string.length;
|
|
1696
|
+
let leadSurrogate = null;
|
|
1697
|
+
const bytes = [];
|
|
1698
|
+
for (let i = 0; i < length; ++i) {
|
|
1699
|
+
codePoint = string.charCodeAt(i);
|
|
1700
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
1701
|
+
if (!leadSurrogate) {
|
|
1702
|
+
if (codePoint > 56319) {
|
|
1703
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1704
|
+
continue;
|
|
1705
|
+
} else if (i + 1 === length) {
|
|
1706
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1707
|
+
continue;
|
|
1708
|
+
}
|
|
1709
|
+
leadSurrogate = codePoint;
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (codePoint < 56320) {
|
|
1713
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1714
|
+
leadSurrogate = codePoint;
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1718
|
+
} else if (leadSurrogate) {
|
|
1719
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1720
|
+
}
|
|
1721
|
+
leadSurrogate = null;
|
|
1722
|
+
if (codePoint < 128) {
|
|
1723
|
+
if ((units -= 1) < 0) break;
|
|
1724
|
+
bytes.push(codePoint);
|
|
1725
|
+
} else if (codePoint < 2048) {
|
|
1726
|
+
if ((units -= 2) < 0) break;
|
|
1727
|
+
bytes.push(
|
|
1728
|
+
codePoint >> 6 | 192,
|
|
1729
|
+
codePoint & 63 | 128
|
|
1730
|
+
);
|
|
1731
|
+
} else if (codePoint < 65536) {
|
|
1732
|
+
if ((units -= 3) < 0) break;
|
|
1733
|
+
bytes.push(
|
|
1734
|
+
codePoint >> 12 | 224,
|
|
1735
|
+
codePoint >> 6 & 63 | 128,
|
|
1736
|
+
codePoint & 63 | 128
|
|
1737
|
+
);
|
|
1738
|
+
} else if (codePoint < 1114112) {
|
|
1739
|
+
if ((units -= 4) < 0) break;
|
|
1740
|
+
bytes.push(
|
|
1741
|
+
codePoint >> 18 | 240,
|
|
1742
|
+
codePoint >> 12 & 63 | 128,
|
|
1743
|
+
codePoint >> 6 & 63 | 128,
|
|
1744
|
+
codePoint & 63 | 128
|
|
1745
|
+
);
|
|
1746
|
+
} else {
|
|
1747
|
+
throw new Error("Invalid code point");
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return bytes;
|
|
1751
|
+
}
|
|
1752
|
+
function asciiToBytes(str) {
|
|
1753
|
+
const byteArray = [];
|
|
1754
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1755
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1756
|
+
}
|
|
1757
|
+
return byteArray;
|
|
1758
|
+
}
|
|
1759
|
+
function utf16leToBytes(str, units) {
|
|
1760
|
+
let c, hi, lo;
|
|
1761
|
+
const byteArray = [];
|
|
1762
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1763
|
+
if ((units -= 2) < 0) break;
|
|
1764
|
+
c = str.charCodeAt(i);
|
|
1765
|
+
hi = c >> 8;
|
|
1766
|
+
lo = c % 256;
|
|
1767
|
+
byteArray.push(lo);
|
|
1768
|
+
byteArray.push(hi);
|
|
1769
|
+
}
|
|
1770
|
+
return byteArray;
|
|
1771
|
+
}
|
|
1772
|
+
function base64ToBytes(str) {
|
|
1773
|
+
return base64.toByteArray(base64clean(str));
|
|
1774
|
+
}
|
|
1775
|
+
function blitBuffer(src, dst, offset, length) {
|
|
1776
|
+
let i;
|
|
1777
|
+
for (i = 0; i < length; ++i) {
|
|
1778
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
1779
|
+
dst[i + offset] = src[i];
|
|
1780
|
+
}
|
|
1781
|
+
return i;
|
|
1782
|
+
}
|
|
1783
|
+
function isInstance(obj, type) {
|
|
1784
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1785
|
+
}
|
|
1786
|
+
function numberIsNaN(obj) {
|
|
1787
|
+
return obj !== obj;
|
|
1788
|
+
}
|
|
1789
|
+
var hexSliceLookupTable = (function() {
|
|
1790
|
+
const alphabet = "0123456789abcdef";
|
|
1791
|
+
const table = new Array(256);
|
|
1792
|
+
for (let i = 0; i < 16; ++i) {
|
|
1793
|
+
const i16 = i * 16;
|
|
1794
|
+
for (let j = 0; j < 16; ++j) {
|
|
1795
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return table;
|
|
1799
|
+
})();
|
|
1800
|
+
function defineBigIntMethod(fn) {
|
|
1801
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1802
|
+
}
|
|
1803
|
+
function BufferBigIntNotDefined() {
|
|
1804
|
+
throw new Error("BigInt not supported");
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
|
|
1809
|
+
// scripts/browser-buffer.mjs
|
|
1810
|
+
var import_buffer;
|
|
1811
|
+
var init_browser_buffer = __esm({
|
|
1812
|
+
"scripts/browser-buffer.mjs"() {
|
|
1813
|
+
"use strict";
|
|
1814
|
+
import_buffer = __toESM(require_buffer(), 1);
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// src/browser.mjs
|
|
1819
|
+
init_browser_buffer();
|
|
1820
|
+
|
|
1821
|
+
// runtime/engine/frozen/runtime/engine-host.mjs
|
|
1822
|
+
init_browser_buffer();
|
|
1823
|
+
|
|
1824
|
+
// sessions-platform:fs
|
|
1825
|
+
init_browser_buffer();
|
|
1826
|
+
|
|
1827
|
+
// src/browser-platform.mjs
|
|
1828
|
+
init_browser_buffer();
|
|
1829
|
+
var layout;
|
|
1830
|
+
function setLayout(text) {
|
|
1831
|
+
layout = text;
|
|
1832
|
+
}
|
|
1833
|
+
var filesystem = {
|
|
1834
|
+
readFileSync(url) {
|
|
1835
|
+
if (!String(url).endsWith("/engine-logs/static-layout.json") || layout === void 0) throw new Error("Browser runtime attempted unsupported filesystem access");
|
|
1836
|
+
return layout;
|
|
1837
|
+
},
|
|
1838
|
+
appendFileSync() {
|
|
1839
|
+
throw new Error("Filesystem logging is unavailable in Chrome");
|
|
1840
|
+
}
|
|
1841
|
+
};
|
|
1842
|
+
function assertion(value, message = "Engine assertion failed") {
|
|
1843
|
+
if (!value) throw new Error(message);
|
|
1844
|
+
}
|
|
1845
|
+
assertion.equal = (actual, expected, message) => assertion(actual === expected, message ?? `Engine assertion failed: ${String(actual)} !== ${String(expected)}`);
|
|
1846
|
+
assertion.notEqual = (actual, expected, message) => assertion(actual !== expected, message ?? "Engine assertion failed: values must differ");
|
|
1847
|
+
|
|
1848
|
+
// sessions-platform:assert
|
|
1849
|
+
init_browser_buffer();
|
|
1850
|
+
|
|
1851
|
+
// runtime/engine/frozen/runtime/engine-host.mjs
|
|
1852
|
+
import { PGlite } from "../runtime/engine/frozen/runtime/pglite/packages/pglite/dist/index.js";
|
|
1853
|
+
|
|
1854
|
+
// runtime/wait/wire.mjs
|
|
1855
|
+
init_browser_buffer();
|
|
1856
|
+
function simpleQuery(sql) {
|
|
1857
|
+
const text = import_buffer.Buffer.from(sql + "\0");
|
|
1858
|
+
const bytes = import_buffer.Buffer.alloc(text.length + 5);
|
|
1859
|
+
bytes[0] = 81;
|
|
1860
|
+
bytes.writeInt32BE(text.length + 4, 1);
|
|
1861
|
+
text.copy(bytes, 5);
|
|
1862
|
+
return bytes;
|
|
1863
|
+
}
|
|
1864
|
+
function startup(application_name = "attach-B") {
|
|
1865
|
+
const text = import_buffer.Buffer.from(`user\0postgres\0database\0postgres\0application_name\0${application_name}\0client_encoding\0UTF8\0\0`);
|
|
1866
|
+
const bytes = import_buffer.Buffer.alloc(text.length + 8);
|
|
1867
|
+
bytes.writeInt32BE(bytes.length, 0);
|
|
1868
|
+
bytes.writeInt32BE(196608, 4);
|
|
1869
|
+
text.copy(bytes, 8);
|
|
1870
|
+
return bytes;
|
|
1871
|
+
}
|
|
1872
|
+
function parseWire(input) {
|
|
1873
|
+
const b = import_buffer.Buffer.from(input), results = [], notices = [], notifications = [];
|
|
1874
|
+
let current = { fields: [], rows: [] }, status = null;
|
|
1875
|
+
for (let o = 0; o < b.length; ) {
|
|
1876
|
+
assertion(o + 5 <= b.length, "truncated wire header");
|
|
1877
|
+
const type = String.fromCharCode(b[o]), len = b.readInt32BE(o + 1), end = o + 1 + len;
|
|
1878
|
+
assertion(len >= 4 && end <= b.length, "truncated wire body");
|
|
1879
|
+
let p = o + 5;
|
|
1880
|
+
const str = () => {
|
|
1881
|
+
let q = b.indexOf(0, p);
|
|
1882
|
+
assertion(q >= p && q < end);
|
|
1883
|
+
let s = b.toString("utf8", p, q);
|
|
1884
|
+
p = q + 1;
|
|
1885
|
+
return s;
|
|
1886
|
+
};
|
|
1887
|
+
if (type === "T") {
|
|
1888
|
+
const n = b.readInt16BE(p);
|
|
1889
|
+
p += 2;
|
|
1890
|
+
current = { fields: [], rows: [] };
|
|
1891
|
+
for (let i = 0; i < n; i++) {
|
|
1892
|
+
const name = str();
|
|
1893
|
+
p += 6;
|
|
1894
|
+
const oid = b.readInt32BE(p);
|
|
1895
|
+
p += 12;
|
|
1896
|
+
current.fields.push({ name, oid });
|
|
1897
|
+
}
|
|
1898
|
+
} else if (type === "D") {
|
|
1899
|
+
const n = b.readInt16BE(p);
|
|
1900
|
+
p += 2;
|
|
1901
|
+
const row = [];
|
|
1902
|
+
for (let i = 0; i < n; i++) {
|
|
1903
|
+
const size = b.readInt32BE(p);
|
|
1904
|
+
p += 4;
|
|
1905
|
+
row.push(size === -1 ? null : b.toString("utf8", p, p + size));
|
|
1906
|
+
if (size >= 0) p += size;
|
|
1907
|
+
}
|
|
1908
|
+
current.rows.push(row);
|
|
1909
|
+
} else if (type === "C") {
|
|
1910
|
+
current.tag = str();
|
|
1911
|
+
results.push(current);
|
|
1912
|
+
current = { fields: [], rows: [] };
|
|
1913
|
+
} else if (type === "E" || type === "N") {
|
|
1914
|
+
const fields = {};
|
|
1915
|
+
while (p < end && b[p]) {
|
|
1916
|
+
const key = String.fromCharCode(b[p++]);
|
|
1917
|
+
fields[key] = str();
|
|
1918
|
+
}
|
|
1919
|
+
const err = { code: fields.C, message: fields.M };
|
|
1920
|
+
if (type === "E") {
|
|
1921
|
+
results.push({ error: err });
|
|
1922
|
+
current = { fields: [], rows: [] };
|
|
1923
|
+
} else notices.push(err);
|
|
1924
|
+
} else if (type === "Z") status = String.fromCharCode(b[p]);
|
|
1925
|
+
else if (type === "A") {
|
|
1926
|
+
const pid = b.readInt32BE(p);
|
|
1927
|
+
p += 4;
|
|
1928
|
+
notifications.push({ pid, channel: str(), payload: str() });
|
|
1929
|
+
}
|
|
1930
|
+
o = end;
|
|
1931
|
+
}
|
|
1932
|
+
return { results, status, notices, notifications };
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
// runtime/engine/frozen/runtime/engine-host.mjs
|
|
1936
|
+
var BackendStartExit = class extends Error {
|
|
1937
|
+
constructor(status, bytes) {
|
|
1938
|
+
super("backend exited during startup");
|
|
1939
|
+
this.status = status;
|
|
1940
|
+
this.bytes = bytes;
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
function hasFatalResponse(bytes) {
|
|
1944
|
+
for (let o = 0; o + 5 <= bytes.length; ) {
|
|
1945
|
+
const n = bytes.readInt32BE(o + 1), end = o + 1 + n;
|
|
1946
|
+
assertion(n >= 4 && end <= bytes.length, "invalid startup response");
|
|
1947
|
+
if (bytes[o] === 69) {
|
|
1948
|
+
const fields = {};
|
|
1949
|
+
let p = o + 5;
|
|
1950
|
+
while (p < end && bytes[p]) {
|
|
1951
|
+
const key = String.fromCharCode(bytes[p++]), q = bytes.indexOf(0, p);
|
|
1952
|
+
assertion(q >= p && q < end);
|
|
1953
|
+
fields[key] = bytes.toString("utf8", p, q);
|
|
1954
|
+
p = q + 1;
|
|
1955
|
+
}
|
|
1956
|
+
if ((fields.V ?? fields.S) === "FATAL") return true;
|
|
1957
|
+
}
|
|
1958
|
+
o = end;
|
|
1959
|
+
}
|
|
1960
|
+
return false;
|
|
1961
|
+
}
|
|
1962
|
+
var EngineHost = class _EngineHost {
|
|
1963
|
+
static async create(options = {}) {
|
|
1964
|
+
assertion.equal(typeof WebAssembly.Suspending, "function", "JSPI host required");
|
|
1965
|
+
const h = new _EngineHost();
|
|
1966
|
+
h.options = options;
|
|
1967
|
+
h.layout = JSON.parse(filesystem.readFileSync(new URL("./engine-logs/static-layout.json", import.meta.url)));
|
|
1968
|
+
h.spans = h.layout.spans.map((s, i) => ({ ...s, key: "main:" + i }));
|
|
1969
|
+
h.initial = /* @__PURE__ */ new Map();
|
|
1970
|
+
h.backends = /* @__PURE__ */ new Map();
|
|
1971
|
+
h.signals = /* @__PURE__ */ new Map();
|
|
1972
|
+
h.parked = /* @__PURE__ */ new Map();
|
|
1973
|
+
h.jobs = [];
|
|
1974
|
+
h.log = [];
|
|
1975
|
+
h.waits = [];
|
|
1976
|
+
h.busy = false;
|
|
1977
|
+
h.scheduled = false;
|
|
1978
|
+
h.active = null;
|
|
1979
|
+
h.switches = 0;
|
|
1980
|
+
h.nextSlot = 2;
|
|
1981
|
+
h.freeSlots = [];
|
|
1982
|
+
h.timers = /* @__PURE__ */ new Map();
|
|
1983
|
+
h.parkingObservers = /* @__PURE__ */ new Map();
|
|
1984
|
+
h.operations = /* @__PURE__ */ new Map();
|
|
1985
|
+
h.failure = null;
|
|
1986
|
+
h.startups = 1;
|
|
1987
|
+
h.syncMailbox = [];
|
|
1988
|
+
h.checkpointTickets = /* @__PURE__ */ new Map();
|
|
1989
|
+
h.nextCheckpointTicket = 1;
|
|
1990
|
+
h.failureNotification = new Promise((resolve) => {
|
|
1991
|
+
h.reportFailure = resolve;
|
|
1992
|
+
});
|
|
1993
|
+
h.descriptorOwners = /* @__PURE__ */ new Map();
|
|
1994
|
+
h.asyncEntries = /* @__PURE__ */ new Set();
|
|
1995
|
+
h.osActivations = /* @__PURE__ */ new Set();
|
|
1996
|
+
h.synchronousDepth = 0;
|
|
1997
|
+
h.quantumDeadline = 0;
|
|
1998
|
+
h.event = (event) => {
|
|
1999
|
+
h.log.push(event);
|
|
2000
|
+
if (void 0) filesystem.appendFileSync(void 0, JSON.stringify(event) + "\n");
|
|
2001
|
+
};
|
|
2002
|
+
const extension = { name: "contexts", setup: async (pg, opts) => ({ emscriptenOpts: { ...opts, postRun: [...opts.postRun ?? [], (m) => {
|
|
2003
|
+
h.mod = m;
|
|
2004
|
+
const files = m.FS, create = files.createStream, close = files.closeStream;
|
|
2005
|
+
files.createStream = function(...args) {
|
|
2006
|
+
const stream = create.apply(this, args);
|
|
2007
|
+
h.descriptorOwners.set(stream.fd, { pid: h.active ?? 42, stream });
|
|
2008
|
+
return stream;
|
|
2009
|
+
};
|
|
2010
|
+
files.closeStream = function(fd) {
|
|
2011
|
+
h.descriptorOwners.delete(fd);
|
|
2012
|
+
return close.call(this, fd);
|
|
2013
|
+
};
|
|
2014
|
+
for (const stream of files.streams) if (stream) h.descriptorOwners.set(stream.fd, { pid: 42, stream });
|
|
2015
|
+
m.sessionsOwnFd = (pid, fd) => {
|
|
2016
|
+
const stream = files.streams[fd];
|
|
2017
|
+
assertion(stream, "missing transferred descriptor");
|
|
2018
|
+
h.descriptorOwners.set(fd, { pid, stream });
|
|
2019
|
+
};
|
|
2020
|
+
const original = m.callMain;
|
|
2021
|
+
m.callMain = (args) => {
|
|
2022
|
+
if (!h.pristine) {
|
|
2023
|
+
h.event({ event: "bootstrap-main", mode: args[0] ?? "" });
|
|
2024
|
+
if (args[0] === "--single") {
|
|
2025
|
+
h.pristine = h.capture();
|
|
2026
|
+
for (const [k, v] of h.pristine) h.initial.set(k, v);
|
|
2027
|
+
}
|
|
2028
|
+
h.active = 42;
|
|
2029
|
+
if (!h.backends.has(42)) h.backends.set(42, { pid: 42, image: h.capture(), sp: m.stackSave(), slot: 1 });
|
|
2030
|
+
assertion(!h.operations.has(42), "overlapping bootstrap entry");
|
|
2031
|
+
h.busy = true;
|
|
2032
|
+
const bootstrap = { bootstrap: true };
|
|
2033
|
+
h.operations.set(42, bootstrap);
|
|
2034
|
+
return Promise.resolve().then(() => original(args)).finally(() => {
|
|
2035
|
+
h.save();
|
|
2036
|
+
h.operations.delete(42);
|
|
2037
|
+
h.busy = false;
|
|
2038
|
+
h.kick();
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
return original(args);
|
|
2042
|
+
};
|
|
2043
|
+
m.attachDsoLoaded = (name, start, size) => {
|
|
2044
|
+
if (!size || h.spans.some((s) => s.key === "dso:" + name)) return;
|
|
2045
|
+
const span = { key: "dso:" + name, start, size };
|
|
2046
|
+
h.spans.push(span);
|
|
2047
|
+
h.initial.set(span.key, m.HEAPU8.slice(start, start + size));
|
|
2048
|
+
};
|
|
2049
|
+
for (const d of m.attachDsos ?? []) m.attachDsoLoaded(d.name, d.start, d.size);
|
|
2050
|
+
m.attachSignal = (pid, sig) => {
|
|
2051
|
+
h.event({ event: "signal-send", source: h.active, pid, sig });
|
|
2052
|
+
const target = pid === 0 ? h.active : Math.abs(pid);
|
|
2053
|
+
if (!h.backends.has(target)) return -1;
|
|
2054
|
+
if (sig) {
|
|
2055
|
+
if (target === h.active) h.deliver(sig);
|
|
2056
|
+
else h.signal(target, sig);
|
|
2057
|
+
}
|
|
2058
|
+
return 0;
|
|
2059
|
+
};
|
|
2060
|
+
m.sessionsWait = (latch, timeout) => h.sleep(latch, timeout);
|
|
2061
|
+
m.sessionsCanYield = () => h.canYield();
|
|
2062
|
+
m.sessionsYield = () => h.sleep(0, 0, true);
|
|
2063
|
+
m.sessionsTimer = (which, sec, usec) => h.timer(which, sec, usec);
|
|
2064
|
+
m.sessionsSync = (tag, size, type) => h.syncRequest(tag, size, type);
|
|
2065
|
+
m.sessionsNextSync = (tag, size, type) => h.nextSyncRequest(tag, size, type);
|
|
2066
|
+
m.sessionsCheckpointStart = (flags) => h.startCheckpoint(flags);
|
|
2067
|
+
m.sessionsCheckpointWait = (ticket) => h.waitCheckpoint(ticket);
|
|
2068
|
+
m.sessionsCheckpointRelease = (ticket) => h.releaseCheckpoint(ticket);
|
|
2069
|
+
}] } }) };
|
|
2070
|
+
h.db = await PGlite.create({
|
|
2071
|
+
...options,
|
|
2072
|
+
children: void 0,
|
|
2073
|
+
extensions: { ...options.extensions, contexts: extension },
|
|
2074
|
+
startParams: [...PGlite.defaultStartParams, "-c", "shared_memory_type=sysv", "-c", "dynamic_shared_memory_type=sysv", ...options.extraStartParams ?? []],
|
|
2075
|
+
onStderr: (text) => {
|
|
2076
|
+
h.log.push({ event: "stderr", text });
|
|
2077
|
+
options.onStderr?.(text);
|
|
2078
|
+
},
|
|
2079
|
+
onStdout: (text) => {
|
|
2080
|
+
h.log.push({ event: "stdout", text });
|
|
2081
|
+
options.onStdout?.(text);
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
assertion(h.pristine && h.mod, "initial private image unavailable");
|
|
2085
|
+
h.active = 42;
|
|
2086
|
+
h.backends.set(42, { pid: 42, image: h.capture(), sp: h.mod.stackSave(), slot: 1 });
|
|
2087
|
+
h.log.push({ event: "backend-ready", pid: 42 });
|
|
2088
|
+
for (const pid of options.children ?? []) await h.attach(pid);
|
|
2089
|
+
return h;
|
|
2090
|
+
}
|
|
2091
|
+
capture() {
|
|
2092
|
+
return new Map(this.spans.map((s) => [s.key, this.mod.HEAPU8.slice(s.start, s.start + s.size)]));
|
|
2093
|
+
}
|
|
2094
|
+
restore(image) {
|
|
2095
|
+
for (const s of this.spans) {
|
|
2096
|
+
const b = image.get(s.key) ?? this.initial.get(s.key);
|
|
2097
|
+
assertion(b, "uninitialized DSO image");
|
|
2098
|
+
this.mod.HEAPU8.set(b, s.start);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
save() {
|
|
2102
|
+
if (this.active !== null) {
|
|
2103
|
+
const b = this.backends.get(this.active);
|
|
2104
|
+
assertion(b);
|
|
2105
|
+
b.image = this.capture();
|
|
2106
|
+
b.sp = this.mod.stackSave();
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
select(pid) {
|
|
2110
|
+
assertion(this.backends.has(pid), "unknown backend");
|
|
2111
|
+
if (this.active !== pid) {
|
|
2112
|
+
this.save();
|
|
2113
|
+
const b = this.backends.get(pid);
|
|
2114
|
+
this.restore(b.image);
|
|
2115
|
+
this.mod.stackRestore(b.sp);
|
|
2116
|
+
this.active = pid;
|
|
2117
|
+
this.switches++;
|
|
2118
|
+
}
|
|
2119
|
+
const signals = this.signals.get(pid);
|
|
2120
|
+
this.signals.delete(pid);
|
|
2121
|
+
if (signals) for (const sig of signals) this.deliver(sig);
|
|
2122
|
+
}
|
|
2123
|
+
deliver(sig) {
|
|
2124
|
+
this.event({ event: "signal-deliver", pid: this.active, sig });
|
|
2125
|
+
this.synchronousDepth++;
|
|
2126
|
+
try {
|
|
2127
|
+
if (sig === 14) this.mod._pgl_sessions_alarm();
|
|
2128
|
+
else this.mod._pgl_sessions_deliver(sig);
|
|
2129
|
+
} finally {
|
|
2130
|
+
this.synchronousDepth--;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
canYield() {
|
|
2134
|
+
if (this.synchronousDepth || !this.asyncEntries.has(this.active)) return false;
|
|
2135
|
+
const now = Date.now();
|
|
2136
|
+
if (now < this.quantumDeadline) return false;
|
|
2137
|
+
this.quantumDeadline = now + 4;
|
|
2138
|
+
return true;
|
|
2139
|
+
}
|
|
2140
|
+
schedule(pid, work, interrupt = false) {
|
|
2141
|
+
if (this.failure) return Promise.reject(this.failure);
|
|
2142
|
+
return new Promise((resolve, reject) => {
|
|
2143
|
+
this.jobs.push({ pid, work, resolve, reject, interrupt });
|
|
2144
|
+
this.kick();
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
kick() {
|
|
2148
|
+
if (!this.scheduled) {
|
|
2149
|
+
this.scheduled = true;
|
|
2150
|
+
queueMicrotask(() => {
|
|
2151
|
+
this.scheduled = false;
|
|
2152
|
+
this.pump();
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
pump() {
|
|
2157
|
+
if (this.busy || this.failure) return;
|
|
2158
|
+
for (const [pid, w] of this.parked) {
|
|
2159
|
+
if (!w.queued && (w.kind === "service" ? w.notified || w.request.done : w.timedOut || this.latchSet(w))) {
|
|
2160
|
+
w.queued = true;
|
|
2161
|
+
this.jobs.push({ pid, wake: w });
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
const index = this.jobs.findIndex((j) => j.wake || j.interrupt || !this.operations.has(j.pid));
|
|
2165
|
+
if (index < 0) return;
|
|
2166
|
+
const [job] = this.jobs.splice(index, 1);
|
|
2167
|
+
if (!this.backends.has(job.pid) && job.interrupt) {
|
|
2168
|
+
job.resolve?.();
|
|
2169
|
+
this.kick();
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
if (job.wake) {
|
|
2173
|
+
const w = job.wake;
|
|
2174
|
+
if (this.parked.get(job.pid) !== w) {
|
|
2175
|
+
this.kick();
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
this.busy = true;
|
|
2179
|
+
this.select(job.pid);
|
|
2180
|
+
this.mod.stackRestore(w.sp);
|
|
2181
|
+
this.parked.delete(job.pid);
|
|
2182
|
+
clearTimeout(w.timeoutHandle);
|
|
2183
|
+
w.returned = true;
|
|
2184
|
+
if (w.kind === "service") {
|
|
2185
|
+
assertion.equal(w.request.waiter, w);
|
|
2186
|
+
w.request.waiter = null;
|
|
2187
|
+
this.event({ event: "service-wake", pid: job.pid, ticket: w.request.ticket, done: w.request.done });
|
|
2188
|
+
w.resolve(w.request.done ? 1 : 0);
|
|
2189
|
+
} else {
|
|
2190
|
+
w.returnedSet = this.latchSet(w);
|
|
2191
|
+
this.event({ event: "wake", pid: job.pid, latch: w.latch, latchSet: w.returnedSet, timedOut: !!w.timedOut });
|
|
2192
|
+
w.resolve(w.returnedSet ? 1 : 0);
|
|
2193
|
+
}
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
this.busy = true;
|
|
2197
|
+
if (!job.interrupt) this.operations.set(job.pid, job);
|
|
2198
|
+
try {
|
|
2199
|
+
this.select(job.pid);
|
|
2200
|
+
} catch (e) {
|
|
2201
|
+
job.reject(e);
|
|
2202
|
+
this.fail(e);
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
Promise.resolve().then(job.work).then(job.resolve, job.reject).finally(() => {
|
|
2206
|
+
if (!job.interrupt) this.operations.delete(job.pid);
|
|
2207
|
+
if (!this.options.oneSession || this.backends.size > 1) this.save();
|
|
2208
|
+
this.busy = false;
|
|
2209
|
+
this.kick();
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
fail(error) {
|
|
2213
|
+
if (this.failure) return;
|
|
2214
|
+
this.failure = error;
|
|
2215
|
+
for (const j of this.jobs.splice(0)) j.reject?.(error);
|
|
2216
|
+
for (const timer of this.timers.values()) clearTimeout(timer);
|
|
2217
|
+
this.timers.clear();
|
|
2218
|
+
for (const parked of this.parked.values()) clearTimeout(parked.timeoutHandle);
|
|
2219
|
+
this.reportFailure(error);
|
|
2220
|
+
}
|
|
2221
|
+
latchSet(w) {
|
|
2222
|
+
if (!w.latch) return false;
|
|
2223
|
+
if (this.active !== w.pid) {
|
|
2224
|
+
const span = this.spans.find((s) => w.latch >= s.start && w.latch + 4 <= s.start + s.size);
|
|
2225
|
+
if (span) {
|
|
2226
|
+
const b = this.backends.get(w.pid).image.get(span.key) ?? this.initial.get(span.key);
|
|
2227
|
+
return new DataView(b.buffer, b.byteOffset + w.latch - span.start, 4).getInt32(0, true) !== 0;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
return new DataView(this.mod.HEAPU8.buffer).getInt32(w.latch, true) !== 0;
|
|
2231
|
+
}
|
|
2232
|
+
sleep(latch, timeout, cooperative = false) {
|
|
2233
|
+
const pid = this.active;
|
|
2234
|
+
assertion(this.busy && this.backends.has(pid));
|
|
2235
|
+
assertion(!this.parked.has(pid));
|
|
2236
|
+
if (latch && new DataView(this.mod.HEAPU8.buffer).getInt32(latch, true) !== 0) return Promise.resolve(1);
|
|
2237
|
+
return new Promise((resolve) => {
|
|
2238
|
+
const osService = this.osActivations.has(pid);
|
|
2239
|
+
const w = { pid, latch, timeout, cooperative, osService, kind: cooperative ? "yield" : latch ? "latch" : "timer", sp: this.mod.stackSave(), resolve, queued: false };
|
|
2240
|
+
this.parked.set(pid, w);
|
|
2241
|
+
if (!cooperative && !osService) this.waits.push(w);
|
|
2242
|
+
this.save();
|
|
2243
|
+
this.busy = false;
|
|
2244
|
+
this.event({ event: cooperative ? "yield" : "park", pid, latch, timeout });
|
|
2245
|
+
if (timeout >= 0) w.timeoutHandle = setTimeout(() => {
|
|
2246
|
+
w.timedOut = true;
|
|
2247
|
+
this.kick();
|
|
2248
|
+
}, timeout);
|
|
2249
|
+
if (!cooperative && !osService) {
|
|
2250
|
+
for (const notify of this.parkingObservers.get(pid) ?? []) notify(w);
|
|
2251
|
+
this.parkingObservers.delete(pid);
|
|
2252
|
+
this.onWait?.(w);
|
|
2253
|
+
}
|
|
2254
|
+
this.kick();
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
waitUntilParked(pid) {
|
|
2258
|
+
if (this.parked.has(pid) && !this.parked.get(pid).cooperative && !this.parked.get(pid).osService) return Promise.resolve(this.parked.get(pid));
|
|
2259
|
+
return Promise.race([new Promise((resolve) => {
|
|
2260
|
+
const a = this.parkingObservers.get(pid) ?? [];
|
|
2261
|
+
a.push(resolve);
|
|
2262
|
+
this.parkingObservers.set(pid, a);
|
|
2263
|
+
}), this.failureNotification.then((e) => {
|
|
2264
|
+
throw e;
|
|
2265
|
+
})]);
|
|
2266
|
+
}
|
|
2267
|
+
timer(which, sec, usec) {
|
|
2268
|
+
if (which !== 0) return -1;
|
|
2269
|
+
const pid = this.active;
|
|
2270
|
+
if (pid === null) return 0;
|
|
2271
|
+
clearTimeout(this.timers.get(pid));
|
|
2272
|
+
this.timers.delete(pid);
|
|
2273
|
+
const ms = sec * 1e3 + usec / 1e3;
|
|
2274
|
+
this.event({ event: "timer-arm", pid, milliseconds: ms });
|
|
2275
|
+
if (ms > 0) {
|
|
2276
|
+
const handle = setTimeout(() => {
|
|
2277
|
+
this.timers.delete(pid);
|
|
2278
|
+
this.event({ event: "timer-fire", pid });
|
|
2279
|
+
if (this.backends.has(pid)) this.signal(pid, 14);
|
|
2280
|
+
}, Math.max(1, ms));
|
|
2281
|
+
this.timers.set(pid, handle);
|
|
2282
|
+
}
|
|
2283
|
+
return 0;
|
|
2284
|
+
}
|
|
2285
|
+
startCheckpoint(flags) {
|
|
2286
|
+
const owner = this.active, ticket = this.nextCheckpointTicket++;
|
|
2287
|
+
assertion(ticket > 0 && ticket < 2147483647, "checkpoint ticket ceiling");
|
|
2288
|
+
assertion(owner !== 42 && this.backends.has(owner), "checkpoint requester outside backend lifetime");
|
|
2289
|
+
const request = { ticket, owner, flags, done: false, waiter: null };
|
|
2290
|
+
this.checkpointTickets.set(ticket, request);
|
|
2291
|
+
this.event({ event: "checkpoint-request", pid: owner, ticket, flags });
|
|
2292
|
+
this.schedule(42, () => this.runCheckpoint(request)).then(() => {
|
|
2293
|
+
request.done = true;
|
|
2294
|
+
this.event({ event: "checkpoint-complete", ticket });
|
|
2295
|
+
this.kick();
|
|
2296
|
+
}, (cause) => this.fail(new Error("checkpoint coordinator failed", { cause })));
|
|
2297
|
+
return ticket;
|
|
2298
|
+
}
|
|
2299
|
+
async runCheckpoint(request) {
|
|
2300
|
+
const m = this.mod, sp = m.stackSave();
|
|
2301
|
+
this.asyncEntries.add(42);
|
|
2302
|
+
this.osActivations.add(42);
|
|
2303
|
+
try {
|
|
2304
|
+
assertion.equal(await m._pgl_sessions_checkpoint_request(request.flags), 1, "checkpoint coordinator did not complete");
|
|
2305
|
+
} finally {
|
|
2306
|
+
this.osActivations.delete(42);
|
|
2307
|
+
this.asyncEntries.delete(42);
|
|
2308
|
+
m.stackRestore(sp);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
waitCheckpoint(ticket) {
|
|
2312
|
+
const request = this.checkpointTickets.get(ticket), pid = this.active;
|
|
2313
|
+
assertion(request && request.owner === pid, "invalid checkpoint waiter");
|
|
2314
|
+
assertion(this.busy && !this.parked.has(pid) && !request.waiter, "overlapping checkpoint waiter");
|
|
2315
|
+
if (request.done) return Promise.resolve(1);
|
|
2316
|
+
return new Promise((resolve) => {
|
|
2317
|
+
const w = { kind: "service", pid, request, sp: this.mod.stackSave(), resolve, queued: false, notified: false };
|
|
2318
|
+
request.waiter = w;
|
|
2319
|
+
this.parked.set(pid, w);
|
|
2320
|
+
this.save();
|
|
2321
|
+
this.busy = false;
|
|
2322
|
+
this.event({ event: "service-park", pid, ticket });
|
|
2323
|
+
this.kick();
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
releaseCheckpoint(ticket) {
|
|
2327
|
+
const request = this.checkpointTickets.get(ticket);
|
|
2328
|
+
assertion(request && request.owner === this.active && !request.waiter, "invalid checkpoint ticket release");
|
|
2329
|
+
this.checkpointTickets.delete(ticket);
|
|
2330
|
+
this.event({ event: "checkpoint-release", ticket, done: request.done });
|
|
2331
|
+
}
|
|
2332
|
+
nextSyncRequest(tag, size, type) {
|
|
2333
|
+
assertion.equal(this.active, 42, "sync mailbox consumed outside coordinator");
|
|
2334
|
+
const request = this.syncMailbox[0];
|
|
2335
|
+
if (!request) return 0;
|
|
2336
|
+
assertion.equal(size, request.bytes.length, "FileTag ABI mismatch");
|
|
2337
|
+
this.mod.HEAPU8.set(request.bytes, tag);
|
|
2338
|
+
new DataView(this.mod.HEAPU8.buffer).setInt32(type, request.type, true);
|
|
2339
|
+
this.syncMailbox.shift();
|
|
2340
|
+
return 1;
|
|
2341
|
+
}
|
|
2342
|
+
syncRequest(tag, size, type) {
|
|
2343
|
+
const caller = this.active;
|
|
2344
|
+
assertion(this.backends.has(42) && this.backends.has(caller) && caller !== 42, "sync service outside backend lifetime");
|
|
2345
|
+
assertion(Number.isInteger(size) && size > 0 && size <= 256, "invalid FileTag size");
|
|
2346
|
+
this.syncMailbox.push({ bytes: this.mod.HEAPU8.slice(tag, tag + size), type });
|
|
2347
|
+
if (this.operations.has(42) || this.parked.has(42)) return 1;
|
|
2348
|
+
this.synchronousDepth++;
|
|
2349
|
+
try {
|
|
2350
|
+
this.select(42);
|
|
2351
|
+
assertion.equal(this.mod._pgl_sessions_absorb_sync_service(), 1, "sync mailbox registration failed");
|
|
2352
|
+
return 1;
|
|
2353
|
+
} catch (cause) {
|
|
2354
|
+
const error = new Error("sync coordinator failed", { cause });
|
|
2355
|
+
this.fail(error);
|
|
2356
|
+
throw error;
|
|
2357
|
+
} finally {
|
|
2358
|
+
this.select(caller);
|
|
2359
|
+
this.synchronousDepth--;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
signal(pid, sig) {
|
|
2363
|
+
if (!this.backends.has(pid)) return;
|
|
2364
|
+
const signals = this.signals.get(pid) ?? /* @__PURE__ */ new Set();
|
|
2365
|
+
signals.add(sig);
|
|
2366
|
+
this.signals.set(pid, signals);
|
|
2367
|
+
this.schedule(pid, () => this.serviceIdle(pid), true).catch((e) => this.fail(e));
|
|
2368
|
+
}
|
|
2369
|
+
async serviceIdle(pid) {
|
|
2370
|
+
const waiter = this.parked.get(pid);
|
|
2371
|
+
if (waiter?.kind === "service") {
|
|
2372
|
+
waiter.notified = true;
|
|
2373
|
+
this.kick();
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
if (this.operations.has(pid) || waiter) return;
|
|
2377
|
+
const m = this.mod, sp = m.stackSave(), io = this.io(import_buffer.Buffer.alloc(0), (bytes) => this.onAsyncData?.(pid, bytes));
|
|
2378
|
+
const operation = { idle: true };
|
|
2379
|
+
this.operations.set(pid, operation);
|
|
2380
|
+
let exit;
|
|
2381
|
+
this.asyncEntries.add(pid);
|
|
2382
|
+
try {
|
|
2383
|
+
await m._pgl_sessions_idle_interrupt();
|
|
2384
|
+
} catch (e) {
|
|
2385
|
+
if (e.status === void 0 || !hasFatalResponse(import_buffer.Buffer.concat(io.output))) throw e;
|
|
2386
|
+
exit = e.status;
|
|
2387
|
+
} finally {
|
|
2388
|
+
this.asyncEntries.delete(pid);
|
|
2389
|
+
this.operations.delete(pid);
|
|
2390
|
+
io.finish();
|
|
2391
|
+
m.stackRestore(sp);
|
|
2392
|
+
}
|
|
2393
|
+
if (exit !== void 0) {
|
|
2394
|
+
this.retire(pid);
|
|
2395
|
+
this.onBackendExit?.({ pid, status: exit });
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
io(input, onData) {
|
|
2399
|
+
const m = this.mod;
|
|
2400
|
+
let offset = 0;
|
|
2401
|
+
const output = [];
|
|
2402
|
+
const read = m.addFunction((ptr, n) => {
|
|
2403
|
+
const len = Math.min(n, input.length - offset);
|
|
2404
|
+
m.HEAPU8.set(input.subarray(offset, offset + len), ptr);
|
|
2405
|
+
offset += len;
|
|
2406
|
+
return len;
|
|
2407
|
+
}, "ipi");
|
|
2408
|
+
const write = m.addFunction((ptr, n) => {
|
|
2409
|
+
const b = import_buffer.Buffer.from(m.HEAPU8.slice(ptr, ptr + n));
|
|
2410
|
+
output.push(b);
|
|
2411
|
+
onData?.(b);
|
|
2412
|
+
return n;
|
|
2413
|
+
}, "ipi");
|
|
2414
|
+
const lookup = (name) => {
|
|
2415
|
+
const v = this.layout.inputs.find((x) => x.input.endsWith("." + name));
|
|
2416
|
+
assertion(v, "missing IO shim section");
|
|
2417
|
+
return v.start;
|
|
2418
|
+
};
|
|
2419
|
+
const view = new DataView(m.HEAPU8.buffer), readAddr = lookup("pgl_read"), writeAddr = lookup("pgl_write");
|
|
2420
|
+
const oldRead = view.getUint32(readAddr, true), oldWrite = view.getUint32(writeAddr, true);
|
|
2421
|
+
m._pgl_set_rw_cbs(read, write);
|
|
2422
|
+
return { output, get remaining() {
|
|
2423
|
+
return input.length - offset;
|
|
2424
|
+
}, finish() {
|
|
2425
|
+
m._pgl_set_rw_cbs(oldRead, oldWrite);
|
|
2426
|
+
m.removeFunction(read);
|
|
2427
|
+
m.removeFunction(write);
|
|
2428
|
+
} };
|
|
2429
|
+
}
|
|
2430
|
+
async attach(pid, packet = startup("l2-backend")) {
|
|
2431
|
+
assertion(!this.backends.has(pid));
|
|
2432
|
+
const slot = this.freeSlots.pop() ?? this.nextSlot++;
|
|
2433
|
+
const path = "/tmp/l2-child-" + pid;
|
|
2434
|
+
await this.schedule(42, () => {
|
|
2435
|
+
const m = this.mod, sp = m.stackSave(), p = m.stringToUTF8OnStack(path);
|
|
2436
|
+
try {
|
|
2437
|
+
assertion.equal(m._pgl_sessions_prepare_child(slot, p, pid), 0, "child serialization failed");
|
|
2438
|
+
} finally {
|
|
2439
|
+
m.stackRestore(sp);
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
await this.schedule(42, () => {
|
|
2443
|
+
const stack = this.mod._pgl_sessions_stack();
|
|
2444
|
+
assertion(stack > 0);
|
|
2445
|
+
const sp = stack + 8 * 1024 * 1024;
|
|
2446
|
+
this.backends.set(pid, { pid, slot, stack, sp, image: new Map(this.pristine) });
|
|
2447
|
+
});
|
|
2448
|
+
return this.schedule(pid, async () => {
|
|
2449
|
+
const m = this.mod, b = this.backends.get(pid);
|
|
2450
|
+
m._pgl_setPGliteActive(1);
|
|
2451
|
+
m._pgl_sessions_setpid(pid);
|
|
2452
|
+
m.stackRestore(b.sp);
|
|
2453
|
+
const io = this.io(packet);
|
|
2454
|
+
let exit;
|
|
2455
|
+
try {
|
|
2456
|
+
exit = await m.callMain(["--forkchild=backend", path]);
|
|
2457
|
+
} finally {
|
|
2458
|
+
m.stackRestore(b.sp);
|
|
2459
|
+
io.finish();
|
|
2460
|
+
}
|
|
2461
|
+
const bytes = import_buffer.Buffer.concat(io.output), response = parseWire(bytes);
|
|
2462
|
+
if (exit !== 99 && hasFatalResponse(bytes)) {
|
|
2463
|
+
this.retire(pid);
|
|
2464
|
+
throw new BackendStartExit(exit, bytes);
|
|
2465
|
+
}
|
|
2466
|
+
assertion.equal(exit, 99, JSON.stringify(response));
|
|
2467
|
+
assertion(!response.results.some((x) => x.error), JSON.stringify(response));
|
|
2468
|
+
this.log.push({ event: "child-entry", pid, slot, exit, startup: response });
|
|
2469
|
+
return bytes;
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
raw(pid, input, onData) {
|
|
2473
|
+
return this.schedule(pid, async () => {
|
|
2474
|
+
const m = this.mod, sp = m.stackSave(), io = this.io(input, onData);
|
|
2475
|
+
let exit;
|
|
2476
|
+
this.asyncEntries.add(pid);
|
|
2477
|
+
try {
|
|
2478
|
+
while (io.remaining > 0 || m._pq_buffer_remaining_data() > 0) {
|
|
2479
|
+
try {
|
|
2480
|
+
await m._PostgresMainLoopOnce();
|
|
2481
|
+
} catch (e) {
|
|
2482
|
+
m.stackRestore(sp);
|
|
2483
|
+
if (e.status === 100) {
|
|
2484
|
+
this.synchronousDepth++;
|
|
2485
|
+
try {
|
|
2486
|
+
m._PostgresMainLongJmp();
|
|
2487
|
+
} finally {
|
|
2488
|
+
this.synchronousDepth--;
|
|
2489
|
+
}
|
|
2490
|
+
continue;
|
|
2491
|
+
}
|
|
2492
|
+
if (e.status === void 0 || !hasFatalResponse(import_buffer.Buffer.concat(io.output))) throw e;
|
|
2493
|
+
exit = e.status;
|
|
2494
|
+
break;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
if (exit === void 0) {
|
|
2498
|
+
m._PostgresSendReadyForQueryIfNecessary();
|
|
2499
|
+
m._pgl_pq_flush();
|
|
2500
|
+
}
|
|
2501
|
+
} finally {
|
|
2502
|
+
this.asyncEntries.delete(pid);
|
|
2503
|
+
io.finish();
|
|
2504
|
+
m.stackRestore(sp);
|
|
2505
|
+
}
|
|
2506
|
+
const bytes = import_buffer.Buffer.concat(io.output);
|
|
2507
|
+
this.onProtocol?.({ pid, bytes });
|
|
2508
|
+
if (exit !== void 0) {
|
|
2509
|
+
this.retire(pid);
|
|
2510
|
+
this.onBackendExit?.({ pid, status: exit });
|
|
2511
|
+
}
|
|
2512
|
+
return bytes;
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
async query(pid, sql) {
|
|
2516
|
+
const bytes = await this.raw(pid, simpleQuery(sql));
|
|
2517
|
+
return parseWire(bytes);
|
|
2518
|
+
}
|
|
2519
|
+
retire(pid) {
|
|
2520
|
+
const m = this.mod, b = this.backends.get(pid);
|
|
2521
|
+
assertion(b && pid !== 42 && this.active === pid, "retirement outside backend");
|
|
2522
|
+
clearTimeout(this.timers.get(pid));
|
|
2523
|
+
this.timers.delete(pid);
|
|
2524
|
+
this.signals.delete(pid);
|
|
2525
|
+
this.parkingObservers.delete(pid);
|
|
2526
|
+
this.asyncEntries.delete(pid);
|
|
2527
|
+
assertion(!this.parked.has(pid), "retiring a suspended backend");
|
|
2528
|
+
for (const [ticket, request] of this.checkpointTickets) if (request.owner === pid) {
|
|
2529
|
+
assertion(!request.waiter, "retiring a live checkpoint waiter");
|
|
2530
|
+
this.checkpointTickets.delete(ticket);
|
|
2531
|
+
this.event({ event: "checkpoint-owner-exit", ticket, done: request.done });
|
|
2532
|
+
}
|
|
2533
|
+
const releasedAllocations = m._pgl_sessions_cleanup_memory();
|
|
2534
|
+
let closedDescriptors = 0;
|
|
2535
|
+
for (const [fd, owner] of [...this.descriptorOwners]) if (owner.pid === pid) {
|
|
2536
|
+
if (m.FS.streams[fd] === owner.stream) {
|
|
2537
|
+
m.FS.close(owner.stream);
|
|
2538
|
+
closedDescriptors++;
|
|
2539
|
+
} else this.descriptorOwners.delete(fd);
|
|
2540
|
+
}
|
|
2541
|
+
this.log.push({ event: "backend-closed", pid, slot: b.slot, releasedAllocations, closedDescriptors });
|
|
2542
|
+
this.save();
|
|
2543
|
+
this.active = null;
|
|
2544
|
+
this.backends.delete(pid);
|
|
2545
|
+
const release = () => {
|
|
2546
|
+
assertion.equal(m._pgl_sessions_release_child(b.slot), 0, "backend slot not safely retired");
|
|
2547
|
+
m._free(b.stack);
|
|
2548
|
+
this.freeSlots.push(b.slot);
|
|
2549
|
+
};
|
|
2550
|
+
if (this.operations.has(42) || this.parked.has(42)) this.schedule(42, release).catch((e) => this.fail(e));
|
|
2551
|
+
else {
|
|
2552
|
+
this.select(42);
|
|
2553
|
+
release();
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
async disconnect(pid) {
|
|
2557
|
+
if (!this.backends.has(pid) || pid === 42) return;
|
|
2558
|
+
if (this.parked.has(pid)) this.signal(pid, 2);
|
|
2559
|
+
await this.schedule(pid, async () => {
|
|
2560
|
+
const m = this.mod, b = this.backends.get(pid), sp = m.stackSave(), io = this.io(import_buffer.Buffer.from([88, 0, 0, 0, 4]));
|
|
2561
|
+
m._pgl_setPGliteActive(0);
|
|
2562
|
+
try {
|
|
2563
|
+
await m._PostgresMainLoopOnce();
|
|
2564
|
+
} catch (e) {
|
|
2565
|
+
if (e.status !== 0) throw e;
|
|
2566
|
+
} finally {
|
|
2567
|
+
io.finish();
|
|
2568
|
+
m.stackRestore(sp);
|
|
2569
|
+
m._pgl_setPGliteActive(1);
|
|
2570
|
+
}
|
|
2571
|
+
this.retire(pid);
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
async close() {
|
|
2575
|
+
for (const pid of [...this.backends.keys()].filter((p) => p !== 42)) await this.disconnect(pid);
|
|
2576
|
+
for (const t of this.timers.values()) clearTimeout(t);
|
|
2577
|
+
this.timers.clear();
|
|
2578
|
+
await this.schedule(42, () => this.db.close());
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
var createHost = (options) => EngineHost.create(options);
|
|
2582
|
+
|
|
2583
|
+
// src/browser.mjs
|
|
2584
|
+
var root = new URL("../runtime/", import.meta.url);
|
|
2585
|
+
var digest = async (bytes) => [...new Uint8Array(await crypto.subtle.digest("SHA-256", bytes))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2586
|
+
async function get(name) {
|
|
2587
|
+
const response = await fetch(new URL(name, root));
|
|
2588
|
+
if (!response.ok) throw new Error(`Cannot load Sessions runtime asset (${response.status}): ${name}`);
|
|
2589
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
2590
|
+
}
|
|
2591
|
+
async function verifyRuntime() {
|
|
2592
|
+
const manifest = JSON.parse(new TextDecoder().decode(await get("runtime-manifest.json")));
|
|
2593
|
+
if (manifest.format !== 1 || manifest.engineVersion !== "18.6" || !Array.isArray(manifest.files) || manifest.files.length === 0 || !/^[a-f0-9]{64}$/.test(manifest.upstreamRuntimeSha256)) throw new Error("Unsupported runtime manifest");
|
|
2594
|
+
const paths = /* @__PURE__ */ new Set();
|
|
2595
|
+
for (const file of manifest.files) {
|
|
2596
|
+
if (!file.path || file.path.includes("\\") || file.path.startsWith("/") || file.path.split("/").some((p) => !p || p === "." || p === "..") || paths.has(file.path)) throw new Error("Invalid runtime path");
|
|
2597
|
+
if (!/^[a-f0-9]{64}$/.test(file.sha256) || !Number.isSafeInteger(file.bytes) || file.bytes < 0) throw new Error("Invalid runtime file manifest");
|
|
2598
|
+
paths.add(file.path);
|
|
2599
|
+
const bytes = await get(file.path);
|
|
2600
|
+
if (bytes.byteLength !== file.bytes || await digest(bytes) !== file.sha256) throw new Error(`Runtime hash mismatch: ${file.path}`);
|
|
2601
|
+
}
|
|
2602
|
+
for (const key of ["entry", "image", "wire", "pin", "layout"]) if (!paths.has(manifest[key])) throw new Error(`Runtime missing ${key}`);
|
|
2603
|
+
if (await digest(new TextEncoder().encode(manifest.files.map((f) => `${f.path}:${f.sha256}`).join("\n"))) !== manifest.runtimeSha256) throw new Error("Runtime identity mismatch");
|
|
2604
|
+
return manifest;
|
|
2605
|
+
}
|
|
2606
|
+
async function createHost2(options = {}) {
|
|
2607
|
+
if (typeof WorkerGlobalScope === "undefined" || !(self instanceof WorkerGlobalScope) || !/Chrome\//.test(navigator.userAgent) || /Edg\//.test(navigator.userAgent) || typeof WebAssembly.Suspending !== "function") throw new Error("VibeRaven Sessions browser preview requires a Chrome Worker with JSPI enabled. Node users need Node 24+ and --experimental-wasm-jspi.");
|
|
2608
|
+
const manifest = await verifyRuntime();
|
|
2609
|
+
setLayout(new TextDecoder().decode(await get(manifest.layout)));
|
|
2610
|
+
return createHost({ ...options, loadDataDir: options.loadDataDir ?? new Blob([await get(manifest.image)]) });
|
|
2611
|
+
}
|
|
2612
|
+
async function loadExtensions(names = []) {
|
|
2613
|
+
const manifest = await verifyRuntime(), extensions = {};
|
|
2614
|
+
for (const name of names) {
|
|
2615
|
+
if (!/^[a-z_]+$/.test(name)) throw new Error("Invalid extension name");
|
|
2616
|
+
const extension = await import(new URL(manifest.dist + "/contrib/" + name + ".js", root).href);
|
|
2617
|
+
if (!extension[name]) throw new Error("No bundled extension: " + name);
|
|
2618
|
+
extensions[name] = extension[name];
|
|
2619
|
+
}
|
|
2620
|
+
return extensions;
|
|
2621
|
+
}
|
|
2622
|
+
export {
|
|
2623
|
+
createHost2 as createHost,
|
|
2624
|
+
loadExtensions,
|
|
2625
|
+
parseWire,
|
|
2626
|
+
simpleQuery,
|
|
2627
|
+
startup,
|
|
2628
|
+
verifyRuntime
|
|
2629
|
+
};
|
|
2630
|
+
/*! Bundled license information:
|
|
2631
|
+
|
|
2632
|
+
ieee754/index.js:
|
|
2633
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
2634
|
+
|
|
2635
|
+
buffer/index.js:
|
|
2636
|
+
(*!
|
|
2637
|
+
* The buffer module from node.js, for the browser.
|
|
2638
|
+
*
|
|
2639
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
2640
|
+
* @license MIT
|
|
2641
|
+
*)
|
|
2642
|
+
*/
|