@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
|
Binary file
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
export function simpleQuery(sql) {
|
|
3
|
+
const text=Buffer.from(sql+'\0');
|
|
4
|
+
const bytes=Buffer.alloc(text.length+5);
|
|
5
|
+
bytes[0]=81; bytes.writeInt32BE(text.length+4,1);text.copy(bytes,5);
|
|
6
|
+
return bytes;
|
|
7
|
+
}
|
|
8
|
+
export function startup(application_name='attach-B') {
|
|
9
|
+
const text=Buffer.from(`user\0postgres\0database\0postgres\0application_name\0${application_name}\0client_encoding\0UTF8\0\0`);
|
|
10
|
+
const bytes=Buffer.alloc(text.length+8);
|
|
11
|
+
bytes.writeInt32BE(bytes.length,0);bytes.writeInt32BE(196608,4);text.copy(bytes,8);
|
|
12
|
+
return bytes;
|
|
13
|
+
}
|
|
14
|
+
export function parseWire(input) {
|
|
15
|
+
const b=Buffer.from(input),results=[],notices=[],notifications=[];
|
|
16
|
+
let current={fields:[],rows:[]},status=null;
|
|
17
|
+
for(let o=0;o<b.length;) {
|
|
18
|
+
assert(o+5<=b.length,'truncated wire header');
|
|
19
|
+
const type=String.fromCharCode(b[o]),len=b.readInt32BE(o+1),end=o+1+len;
|
|
20
|
+
assert(len>=4 && end<=b.length,'truncated wire body');
|
|
21
|
+
let p=o+5;
|
|
22
|
+
const str=()=>{let q=b.indexOf(0,p);assert(q>=p&&q<end);let s=b.toString('utf8',p,q);p=q+1;return s;};
|
|
23
|
+
if(type==='T') {
|
|
24
|
+
const n=b.readInt16BE(p);p+=2;current={fields:[],rows:[]};
|
|
25
|
+
for(let i=0;i<n;i++){const name=str();p+=6;const oid=b.readInt32BE(p);p+=12;current.fields.push({name,oid});}
|
|
26
|
+
} else if(type==='D') {
|
|
27
|
+
const n=b.readInt16BE(p);p+=2;const row=[];
|
|
28
|
+
for(let i=0;i<n;i++){const size=b.readInt32BE(p);p+=4;row.push(size===-1?null:b.toString('utf8',p,p+size));if(size>=0)p+=size;}current.rows.push(row);
|
|
29
|
+
} else if(type==='C') {current.tag=str();results.push(current);current={fields:[],rows:[]};}
|
|
30
|
+
else if(type==='E'||type==='N') {
|
|
31
|
+
const fields={};while(p<end&&b[p]){const key=String.fromCharCode(b[p++]);fields[key]=str();}
|
|
32
|
+
const err={code:fields.C,message:fields.M};
|
|
33
|
+
if(type==='E') {results.push({error:err});current={fields:[],rows:[]};}else notices.push(err);
|
|
34
|
+
} else if(type==='Z')status=String.fromCharCode(b[p]);
|
|
35
|
+
else if(type==='A'){const pid=b.readInt32BE(p);p+=4;notifications.push({pid,channel:str(),payload:str()});}
|
|
36
|
+
o=end;
|
|
37
|
+
}
|
|
38
|
+
return {results,status,notices,notifications};
|
|
39
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {PGlite} from './pglite/packages/pglite/dist/index.js';
|
|
4
|
+
import {simpleQuery,startup,parseWire} from '../../../wait/wire.mjs';
|
|
5
|
+
|
|
6
|
+
export class BackendStartExit extends Error {
|
|
7
|
+
constructor(status,bytes){super('backend exited during startup');this.status=status;this.bytes=bytes;}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function hasFatalResponse(bytes){
|
|
11
|
+
for(let o=0;o+5<=bytes.length;){
|
|
12
|
+
const n=bytes.readInt32BE(o+1),end=o+1+n;assert(n>=4&&end<=bytes.length,'invalid startup response');
|
|
13
|
+
if(bytes[o]===69){
|
|
14
|
+
const fields={};let p=o+5;
|
|
15
|
+
while(p<end&&bytes[p]){const key=String.fromCharCode(bytes[p++]),q=bytes.indexOf(0,p);assert(q>=p&&q<end);fields[key]=bytes.toString('utf8',p,q);p=q+1;}
|
|
16
|
+
if((fields.V??fields.S)==='FATAL')return true;
|
|
17
|
+
}
|
|
18
|
+
o=end;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// One Wasm instance. Only the OS boundary schedules work. Shared memory and
|
|
24
|
+
// PostgreSQL's own lock queues determine which parked continuations can run.
|
|
25
|
+
export class EngineHost {
|
|
26
|
+
static async create(options={}) {
|
|
27
|
+
assert.equal(typeof WebAssembly.Suspending,'function','JSPI host required');
|
|
28
|
+
const h=new EngineHost();
|
|
29
|
+
h.options=options;h.layout=JSON.parse(fs.readFileSync(new URL('./engine-logs/static-layout.json',import.meta.url)));
|
|
30
|
+
h.spans=h.layout.spans.map((s,i)=>({...s,key:'main:'+i}));h.initial=new Map();
|
|
31
|
+
h.backends=new Map();h.signals=new Map();h.parked=new Map();h.jobs=[];h.log=[];h.waits=[];
|
|
32
|
+
h.busy=false;h.scheduled=false;h.active=null;h.switches=0;h.nextSlot=2;h.freeSlots=[];h.timers=new Map();
|
|
33
|
+
h.parkingObservers=new Map();h.operations=new Map();h.failure=null;h.startups=1;h.syncMailbox=[];h.checkpointTickets=new Map();h.nextCheckpointTicket=1;
|
|
34
|
+
h.failureNotification=new Promise(resolve=>{h.reportFailure=resolve;});
|
|
35
|
+
h.descriptorOwners=new Map();h.asyncEntries=new Set();h.osActivations=new Set();h.synchronousDepth=0;h.quantumDeadline=0;
|
|
36
|
+
h.event=event=>{h.log.push(event);if(process.env.L2_EVENT_LOG)fs.appendFileSync(process.env.L2_EVENT_LOG,JSON.stringify(event)+'\n');};
|
|
37
|
+
const extension={name:'contexts',setup:async(pg,opts)=>({emscriptenOpts:{...opts,postRun:[...(opts.postRun??[]),m=>{
|
|
38
|
+
h.mod=m;
|
|
39
|
+
const files=m.FS,create=files.createStream,close=files.closeStream;
|
|
40
|
+
files.createStream=function(...args){const stream=create.apply(this,args);h.descriptorOwners.set(stream.fd,{pid:h.active??42,stream});return stream;};
|
|
41
|
+
files.closeStream=function(fd){h.descriptorOwners.delete(fd);return close.call(this,fd);};
|
|
42
|
+
for(const stream of files.streams)if(stream)h.descriptorOwners.set(stream.fd,{pid:42,stream});
|
|
43
|
+
m.sessionsOwnFd=(pid,fd)=>{
|
|
44
|
+
const stream=files.streams[fd];assert(stream,'missing transferred descriptor');h.descriptorOwners.set(fd,{pid,stream});
|
|
45
|
+
};
|
|
46
|
+
const original=m.callMain;
|
|
47
|
+
m.callMain=args=>{
|
|
48
|
+
if(!h.pristine){
|
|
49
|
+
h.event({event:'bootstrap-main',mode:args[0]??''});
|
|
50
|
+
if(args[0]==='--single'){
|
|
51
|
+
h.pristine=h.capture();for(const [k,v]of h.pristine)h.initial.set(k,v);
|
|
52
|
+
}
|
|
53
|
+
h.active=42;
|
|
54
|
+
if(!h.backends.has(42))h.backends.set(42,{pid:42,image:h.capture(),sp:m.stackSave(),slot:1});
|
|
55
|
+
assert(!h.operations.has(42),'overlapping bootstrap entry');
|
|
56
|
+
h.busy=true;const bootstrap={bootstrap:true};h.operations.set(42,bootstrap);
|
|
57
|
+
return Promise.resolve().then(()=>original(args)).finally(()=>{
|
|
58
|
+
h.save();h.operations.delete(42);h.busy=false;h.kick();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return original(args);
|
|
62
|
+
};
|
|
63
|
+
m.attachDsoLoaded=(name,start,size)=>{
|
|
64
|
+
if(!size||h.spans.some(s=>s.key==='dso:'+name))return;
|
|
65
|
+
const span={key:'dso:'+name,start,size};h.spans.push(span);h.initial.set(span.key,m.HEAPU8.slice(start,start+size));
|
|
66
|
+
};
|
|
67
|
+
for(const d of m.attachDsos??[])m.attachDsoLoaded(d.name,d.start,d.size);
|
|
68
|
+
m.attachSignal=(pid,sig)=>{
|
|
69
|
+
h.event({event:'signal-send',source:h.active,pid,sig});
|
|
70
|
+
const target=pid===0?h.active:Math.abs(pid);
|
|
71
|
+
if(!h.backends.has(target))return -1;
|
|
72
|
+
if(sig){if(target===h.active)h.deliver(sig);else h.signal(target,sig);}return 0;
|
|
73
|
+
};
|
|
74
|
+
m.sessionsWait=(latch,timeout)=>h.sleep(latch,timeout);
|
|
75
|
+
m.sessionsCanYield=()=>h.canYield();
|
|
76
|
+
m.sessionsYield=()=>h.sleep(0,0,true);
|
|
77
|
+
m.sessionsSPIEnabled=site=>!h.synchronousDepth&&h.asyncEntries.has(h.active)&&
|
|
78
|
+
!h.osActivations.has(h.active)&&h.options.spiBoundaries?.(h.active,site)===true;
|
|
79
|
+
m.sessionsSPIPark=(site,footprint)=>h.sleep(0,-1,true,'spi',{site,footprint});
|
|
80
|
+
m.sessionsTimer=(which,sec,usec)=>h.timer(which,sec,usec);
|
|
81
|
+
m.sessionsSync=(tag,size,type)=>h.syncRequest(tag,size,type);
|
|
82
|
+
m.sessionsNextSync=(tag,size,type)=>h.nextSyncRequest(tag,size,type);
|
|
83
|
+
m.sessionsCheckpointStart=flags=>h.startCheckpoint(flags);
|
|
84
|
+
m.sessionsCheckpointWait=ticket=>h.waitCheckpoint(ticket);
|
|
85
|
+
m.sessionsCheckpointRelease=ticket=>h.releaseCheckpoint(ticket);
|
|
86
|
+
}]}})};
|
|
87
|
+
h.db=await PGlite.create({...options,children:undefined,
|
|
88
|
+
extensions:{...options.extensions,contexts:extension},
|
|
89
|
+
startParams:[...PGlite.defaultStartParams,'-c','shared_memory_type=sysv','-c','dynamic_shared_memory_type=sysv',...(options.extraStartParams??[])],
|
|
90
|
+
onStderr:text=>{h.log.push({event:'stderr',text});options.onStderr?.(text);},
|
|
91
|
+
onStdout:text=>{h.log.push({event:'stdout',text});options.onStdout?.(text);}});
|
|
92
|
+
assert(h.pristine&&h.mod,'initial private image unavailable');
|
|
93
|
+
h.active=42;h.backends.set(42,{pid:42,image:h.capture(),sp:h.mod.stackSave(),slot:1});
|
|
94
|
+
h.log.push({event:'backend-ready',pid:42});
|
|
95
|
+
for(const pid of options.children??[])await h.attach(pid);
|
|
96
|
+
return h;
|
|
97
|
+
}
|
|
98
|
+
capture(){return new Map(this.spans.map(s=>[s.key,this.mod.HEAPU8.slice(s.start,s.start+s.size)]));}
|
|
99
|
+
restore(image){for(const s of this.spans){const b=image.get(s.key)??this.initial.get(s.key);assert(b,'uninitialized DSO image');this.mod.HEAPU8.set(b,s.start);}}
|
|
100
|
+
save(){if(this.active!==null){const b=this.backends.get(this.active);assert(b);b.image=this.capture();b.sp=this.mod.stackSave();}}
|
|
101
|
+
select(pid){
|
|
102
|
+
assert(this.backends.has(pid),'unknown backend');
|
|
103
|
+
if(this.active!==pid){this.save();const b=this.backends.get(pid);this.restore(b.image);this.mod.stackRestore(b.sp);this.active=pid;this.switches++;}
|
|
104
|
+
const signals=this.signals.get(pid);this.signals.delete(pid);
|
|
105
|
+
if(signals)for(const sig of signals)this.deliver(sig);
|
|
106
|
+
}
|
|
107
|
+
deliver(sig){
|
|
108
|
+
this.event({event:'signal-deliver',pid:this.active,sig});this.synchronousDepth++;
|
|
109
|
+
try{if(sig===14)this.mod._pgl_sessions_alarm();else this.mod._pgl_sessions_deliver(sig);}
|
|
110
|
+
finally{this.synchronousDepth--;}
|
|
111
|
+
}
|
|
112
|
+
canYield(){
|
|
113
|
+
if(this.synchronousDepth||!this.asyncEntries.has(this.active))return false;
|
|
114
|
+
const now=Date.now();if(now<this.quantumDeadline)return false;
|
|
115
|
+
this.quantumDeadline=now+4;return true;
|
|
116
|
+
}
|
|
117
|
+
schedule(pid,work,interrupt=false){
|
|
118
|
+
if(this.failure)return Promise.reject(this.failure);
|
|
119
|
+
return new Promise((resolve,reject)=>{this.jobs.push({pid,work,resolve,reject,interrupt});this.kick();});
|
|
120
|
+
}
|
|
121
|
+
kick(){if(!this.scheduled){this.scheduled=true;queueMicrotask(()=>{this.scheduled=false;this.pump();});}}
|
|
122
|
+
pump(){
|
|
123
|
+
if(this.busy||this.failure)return;
|
|
124
|
+
for(const [pid,w]of this.parked){
|
|
125
|
+
if(!w.queued&&(w.kind==='spi'?w.released:w.kind==='service'?(w.notified||w.request.done):(w.timedOut||this.latchSet(w)))){w.queued=true;this.jobs.push({pid,wake:w});}
|
|
126
|
+
}
|
|
127
|
+
const index=this.jobs.findIndex(j=>j.wake||j.interrupt||!this.operations.has(j.pid));
|
|
128
|
+
if(index<0)return;
|
|
129
|
+
const [job]=this.jobs.splice(index,1);
|
|
130
|
+
if(!this.backends.has(job.pid)&&job.interrupt){job.resolve?.();this.kick();return;}
|
|
131
|
+
if(job.wake){
|
|
132
|
+
const w=job.wake;if(this.parked.get(job.pid)!==w){this.kick();return;}
|
|
133
|
+
this.busy=true;this.select(job.pid);this.mod.stackRestore(w.sp);this.parked.delete(job.pid);
|
|
134
|
+
clearTimeout(w.timeoutHandle);w.returned=true;
|
|
135
|
+
if(w.kind==='service'){
|
|
136
|
+
assert.equal(w.request.waiter,w);w.request.waiter=null;
|
|
137
|
+
this.event({event:'service-wake',pid:job.pid,ticket:w.request.ticket,done:w.request.done});
|
|
138
|
+
w.resolve(w.request.done?1:0);
|
|
139
|
+
}else if(w.kind==='spi'){
|
|
140
|
+
this.event({event:'spi-resume',pid:job.pid});
|
|
141
|
+
w.resolve();
|
|
142
|
+
}else{
|
|
143
|
+
w.returnedSet=this.latchSet(w);
|
|
144
|
+
this.event({event:'wake',pid:job.pid,latch:w.latch,latchSet:w.returnedSet,timedOut:!!w.timedOut});
|
|
145
|
+
w.resolve(w.returnedSet?1:0);
|
|
146
|
+
}
|
|
147
|
+
// Ownership remains with the resumed C activation until it sleeps again
|
|
148
|
+
// or its exported entry completes. Never resolve two C stacks together.
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.busy=true;
|
|
152
|
+
if(!job.interrupt)this.operations.set(job.pid,job);
|
|
153
|
+
try{this.select(job.pid);}catch(e){job.reject(e);this.fail(e);return;}
|
|
154
|
+
Promise.resolve().then(job.work).then(job.resolve,job.reject).finally(()=>{
|
|
155
|
+
if(!job.interrupt)this.operations.delete(job.pid);
|
|
156
|
+
if(!this.options.oneSession||this.backends.size>1)this.save();
|
|
157
|
+
this.busy=false;this.kick();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
fail(error){
|
|
161
|
+
if(this.failure)return;
|
|
162
|
+
this.failure=error;for(const j of this.jobs.splice(0))j.reject?.(error);
|
|
163
|
+
for(const timer of this.timers.values())clearTimeout(timer);this.timers.clear();
|
|
164
|
+
for(const parked of this.parked.values())clearTimeout(parked.timeoutHandle);
|
|
165
|
+
// A fatal host error is not a resume permission. Leave C continuations
|
|
166
|
+
// parked and notify the owning runner, which records the failed engine.
|
|
167
|
+
this.reportFailure(error);
|
|
168
|
+
}
|
|
169
|
+
latchSet(w){
|
|
170
|
+
if(!w.latch)return false;
|
|
171
|
+
if(this.active!==w.pid){
|
|
172
|
+
const span=this.spans.find(s=>w.latch>=s.start&&w.latch+4<=s.start+s.size);
|
|
173
|
+
if(span){
|
|
174
|
+
const b=this.backends.get(w.pid).image.get(span.key)??this.initial.get(span.key);
|
|
175
|
+
return new DataView(b.buffer,b.byteOffset+w.latch-span.start,4).getInt32(0,true)!==0;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return new DataView(this.mod.HEAPU8.buffer).getInt32(w.latch,true)!==0;
|
|
179
|
+
}
|
|
180
|
+
sleep(latch,timeout,cooperative=false,kind=cooperative?'yield':latch?'latch':'timer',boundary=null){
|
|
181
|
+
const pid=this.active;assert(this.busy&&this.backends.has(pid));assert(!this.parked.has(pid));
|
|
182
|
+
if(latch&&new DataView(this.mod.HEAPU8.buffer).getInt32(latch,true)!==0)return Promise.resolve(1);
|
|
183
|
+
return new Promise(resolve=>{
|
|
184
|
+
const osService=this.osActivations.has(pid);
|
|
185
|
+
const w={pid,latch,timeout,cooperative,osService,kind,sp:this.mod.stackSave(),resolve,queued:false};
|
|
186
|
+
w.boundary=boundary;this.parked.set(pid,w);if(!cooperative&&!osService)this.waits.push(w);this.save();this.busy=false;
|
|
187
|
+
this.event({event:kind==='spi'?'spi-park':cooperative?'yield':'park',pid,latch,timeout,...boundary});
|
|
188
|
+
if(boundary)this.options.onSPI?.(pid,boundary);
|
|
189
|
+
if(timeout>=0)w.timeoutHandle=setTimeout(()=>{w.timedOut=true;this.kick();},timeout);
|
|
190
|
+
if(!cooperative&&!osService){
|
|
191
|
+
for(const notify of this.parkingObservers.get(pid)??[])notify(w);
|
|
192
|
+
this.parkingObservers.delete(pid);this.onWait?.(w);
|
|
193
|
+
}
|
|
194
|
+
this.kick();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
resumeSPI(pid){
|
|
198
|
+
const waiter=this.parked.get(pid);
|
|
199
|
+
assert(waiter?.kind==='spi'&&!waiter.released,'no resumable SPI boundary');
|
|
200
|
+
waiter.released=true;this.kick();
|
|
201
|
+
}
|
|
202
|
+
waitUntilParked(pid){
|
|
203
|
+
if(this.parked.has(pid)&&!this.parked.get(pid).cooperative&&!this.parked.get(pid).osService)return Promise.resolve(this.parked.get(pid));
|
|
204
|
+
return Promise.race([new Promise(resolve=>{const a=this.parkingObservers.get(pid)??[];a.push(resolve);this.parkingObservers.set(pid,a);}),this.failureNotification.then(e=>{throw e;})]);
|
|
205
|
+
}
|
|
206
|
+
timer(which,sec,usec){
|
|
207
|
+
if(which!==0)return -1;
|
|
208
|
+
const pid=this.active;if(pid===null)return 0;
|
|
209
|
+
clearTimeout(this.timers.get(pid));this.timers.delete(pid);
|
|
210
|
+
const ms=sec*1000+usec/1000;
|
|
211
|
+
this.event({event:'timer-arm',pid,milliseconds:ms});
|
|
212
|
+
if(ms>0){
|
|
213
|
+
const handle=setTimeout(()=>{
|
|
214
|
+
this.timers.delete(pid);
|
|
215
|
+
this.event({event:'timer-fire',pid});
|
|
216
|
+
if(this.backends.has(pid))this.signal(pid,14);
|
|
217
|
+
},Math.max(1,ms));this.timers.set(pid,handle);
|
|
218
|
+
}
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
startCheckpoint(flags){
|
|
222
|
+
const owner=this.active,ticket=this.nextCheckpointTicket++;
|
|
223
|
+
assert(ticket>0&&ticket<0x7fffffff,'checkpoint ticket ceiling');
|
|
224
|
+
assert(owner!==42&&this.backends.has(owner),'checkpoint requester outside backend lifetime');
|
|
225
|
+
const request={ticket,owner,flags,done:false,waiter:null};this.checkpointTickets.set(ticket,request);
|
|
226
|
+
this.event({event:'checkpoint-request',pid:owner,ticket,flags});
|
|
227
|
+
this.schedule(42,()=>this.runCheckpoint(request)).then(()=>{
|
|
228
|
+
request.done=true;this.event({event:'checkpoint-complete',ticket});this.kick();
|
|
229
|
+
},cause=>this.fail(new Error('checkpoint coordinator failed',{cause})));
|
|
230
|
+
return ticket;
|
|
231
|
+
}
|
|
232
|
+
async runCheckpoint(request){
|
|
233
|
+
const m=this.mod,sp=m.stackSave();this.asyncEntries.add(42);this.osActivations.add(42);
|
|
234
|
+
try{assert.equal(await m._pgl_sessions_checkpoint_request(request.flags),1,'checkpoint coordinator did not complete');}
|
|
235
|
+
finally{this.osActivations.delete(42);this.asyncEntries.delete(42);m.stackRestore(sp);}
|
|
236
|
+
}
|
|
237
|
+
waitCheckpoint(ticket){
|
|
238
|
+
const request=this.checkpointTickets.get(ticket),pid=this.active;
|
|
239
|
+
assert(request&&request.owner===pid,'invalid checkpoint waiter');
|
|
240
|
+
assert(this.busy&&!this.parked.has(pid)&&!request.waiter,'overlapping checkpoint waiter');
|
|
241
|
+
if(request.done)return Promise.resolve(1);
|
|
242
|
+
return new Promise(resolve=>{
|
|
243
|
+
const w={kind:'service',pid,request,sp:this.mod.stackSave(),resolve,queued:false,notified:false};
|
|
244
|
+
request.waiter=w;this.parked.set(pid,w);this.save();this.busy=false;
|
|
245
|
+
this.event({event:'service-park',pid,ticket});this.kick();
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
releaseCheckpoint(ticket){
|
|
249
|
+
const request=this.checkpointTickets.get(ticket);
|
|
250
|
+
assert(request&&request.owner===this.active&&!request.waiter,'invalid checkpoint ticket release');
|
|
251
|
+
this.checkpointTickets.delete(ticket);this.event({event:'checkpoint-release',ticket,done:request.done});
|
|
252
|
+
// The scheduled kernel request owns its own reference and continues even
|
|
253
|
+
// when native CHECK_FOR_INTERRUPTS unwinds its abandoned caller.
|
|
254
|
+
}
|
|
255
|
+
nextSyncRequest(tag,size,type){
|
|
256
|
+
assert.equal(this.active,42,'sync mailbox consumed outside coordinator');
|
|
257
|
+
const request=this.syncMailbox[0];if(!request)return 0;
|
|
258
|
+
assert.equal(size,request.bytes.length,'FileTag ABI mismatch');
|
|
259
|
+
this.mod.HEAPU8.set(request.bytes,tag);new DataView(this.mod.HEAPU8.buffer).setInt32(type,request.type,true);
|
|
260
|
+
this.syncMailbox.shift();return 1;
|
|
261
|
+
}
|
|
262
|
+
syncRequest(tag,size,type){
|
|
263
|
+
const caller=this.active;
|
|
264
|
+
assert(this.backends.has(42)&&this.backends.has(caller)&&caller!==42,'sync service outside backend lifetime');
|
|
265
|
+
assert(Number.isInteger(size)&&size>0&&size<=256,'invalid FileTag size');
|
|
266
|
+
this.syncMailbox.push({bytes:this.mod.HEAPU8.slice(tag,tag+size),type});
|
|
267
|
+
// A live coordinator consumes its mailbox only from the native Absorb
|
|
268
|
+
// boundary. Never reenter its suspended checkpoint activation.
|
|
269
|
+
if(this.operations.has(42)||this.parked.has(42))return 1;
|
|
270
|
+
this.synchronousDepth++;
|
|
271
|
+
try{this.select(42);assert.equal(this.mod._pgl_sessions_absorb_sync_service(),1,'sync mailbox registration failed');return 1;}
|
|
272
|
+
catch(cause){const error=new Error('sync coordinator failed',{cause});this.fail(error);throw error;}
|
|
273
|
+
finally{this.select(caller);this.synchronousDepth--;}
|
|
274
|
+
}
|
|
275
|
+
signal(pid,sig){
|
|
276
|
+
if(!this.backends.has(pid))return;
|
|
277
|
+
const signals=this.signals.get(pid)??new Set();signals.add(sig);this.signals.set(pid,signals);
|
|
278
|
+
// Idle and parked backends both receive the real C signal handler with
|
|
279
|
+
// their own private globals selected. It sets the real latch/interrupts.
|
|
280
|
+
this.schedule(pid,()=>this.serviceIdle(pid),true).catch(e=>this.fail(e));
|
|
281
|
+
}
|
|
282
|
+
async serviceIdle(pid){
|
|
283
|
+
const waiter=this.parked.get(pid);
|
|
284
|
+
if(waiter?.kind==='service'){waiter.notified=true;this.kick();return;}
|
|
285
|
+
if(this.operations.has(pid)||waiter)return;
|
|
286
|
+
const m=this.mod,sp=m.stackSave(),io=this.io(Buffer.alloc(0),bytes=>this.onAsyncData?.(pid,bytes));
|
|
287
|
+
const operation={idle:true};this.operations.set(pid,operation);let exit;
|
|
288
|
+
this.asyncEntries.add(pid);
|
|
289
|
+
try{await m._pgl_sessions_idle_interrupt();}
|
|
290
|
+
catch(e){if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;exit=e.status;}
|
|
291
|
+
finally{this.asyncEntries.delete(pid);this.operations.delete(pid);io.finish();m.stackRestore(sp);}
|
|
292
|
+
if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
|
|
293
|
+
}
|
|
294
|
+
io(input,onData){
|
|
295
|
+
const m=this.mod;let offset=0;const output=[];
|
|
296
|
+
const read=m.addFunction((ptr,n)=>{const len=Math.min(n,input.length-offset);m.HEAPU8.set(input.subarray(offset,offset+len),ptr);offset+=len;return len;},'ipi');
|
|
297
|
+
const write=m.addFunction((ptr,n)=>{const b=Buffer.from(m.HEAPU8.slice(ptr,ptr+n));output.push(b);onData?.(b);return n;},'ipi');
|
|
298
|
+
const lookup=name=>{const v=this.layout.inputs.find(x=>x.input.endsWith('.'+name));assert(v,'missing IO shim section');return v.start;};
|
|
299
|
+
const view=new DataView(m.HEAPU8.buffer),readAddr=lookup('pgl_read'),writeAddr=lookup('pgl_write');
|
|
300
|
+
const oldRead=view.getUint32(readAddr,true),oldWrite=view.getUint32(writeAddr,true);
|
|
301
|
+
m._pgl_set_rw_cbs(read,write);
|
|
302
|
+
return {output,get remaining(){return input.length-offset;},finish(){m._pgl_set_rw_cbs(oldRead,oldWrite);m.removeFunction(read);m.removeFunction(write);}};
|
|
303
|
+
}
|
|
304
|
+
async attach(pid,packet=startup('l2-backend')){
|
|
305
|
+
assert(!this.backends.has(pid));
|
|
306
|
+
const slot=this.freeSlots.pop()??this.nextSlot++;
|
|
307
|
+
const path='/tmp/l2-child-'+pid;
|
|
308
|
+
await this.schedule(42,()=>{
|
|
309
|
+
const m=this.mod,sp=m.stackSave(),p=m.stringToUTF8OnStack(path);
|
|
310
|
+
try{assert.equal(m._pgl_sessions_prepare_child(slot,p,pid),0,'child serialization failed');}finally{m.stackRestore(sp);}
|
|
311
|
+
});
|
|
312
|
+
// Create the stack before restoring the clean child-private template. The
|
|
313
|
+
// allocator and virtual filesystem remain shared, as they do in WAIT.
|
|
314
|
+
await this.schedule(42,()=>{
|
|
315
|
+
const stack=this.mod._pgl_sessions_stack();assert(stack>0);const sp=stack+8*1024*1024;
|
|
316
|
+
this.backends.set(pid,{pid,slot,stack,sp,image:new Map(this.pristine)});
|
|
317
|
+
});
|
|
318
|
+
return this.schedule(pid,async()=>{
|
|
319
|
+
const m=this.mod,b=this.backends.get(pid);m._pgl_setPGliteActive(1);m._pgl_sessions_setpid(pid);m.stackRestore(b.sp);
|
|
320
|
+
const io=this.io(packet);let exit;
|
|
321
|
+
try{exit=await m.callMain(['--forkchild=backend',path]);}
|
|
322
|
+
finally{m.stackRestore(b.sp);io.finish();}
|
|
323
|
+
const bytes=Buffer.concat(io.output),response=parseWire(bytes);
|
|
324
|
+
if(exit!==99&&hasFatalResponse(bytes)){
|
|
325
|
+
this.retire(pid);throw new BackendStartExit(exit,bytes);
|
|
326
|
+
}
|
|
327
|
+
assert.equal(exit,99,JSON.stringify(response));assert(!response.results.some(x=>x.error),JSON.stringify(response));
|
|
328
|
+
this.log.push({event:'child-entry',pid,slot,exit,startup:response});return bytes;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
raw(pid,input,onData){
|
|
332
|
+
return this.schedule(pid,async()=>{
|
|
333
|
+
const m=this.mod,sp=m.stackSave(),io=this.io(input,onData);let exit;
|
|
334
|
+
this.asyncEntries.add(pid);
|
|
335
|
+
try {
|
|
336
|
+
while(io.remaining>0||m._pq_buffer_remaining_data()>0){
|
|
337
|
+
try{await m._PostgresMainLoopOnce();}
|
|
338
|
+
catch(e){
|
|
339
|
+
m.stackRestore(sp);
|
|
340
|
+
if(e.status===100){this.synchronousDepth++;try{m._PostgresMainLongJmp();}finally{this.synchronousDepth--;}continue;}
|
|
341
|
+
if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;
|
|
342
|
+
exit=e.status;break;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if(exit===undefined){m._PostgresSendReadyForQueryIfNecessary();m._pgl_pq_flush();}
|
|
346
|
+
} finally {this.asyncEntries.delete(pid);io.finish();m.stackRestore(sp);}
|
|
347
|
+
const bytes=Buffer.concat(io.output);this.onProtocol?.({pid,bytes});
|
|
348
|
+
if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
|
|
349
|
+
return bytes;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async query(pid,sql){const bytes=await this.raw(pid,simpleQuery(sql));return parseWire(bytes);}
|
|
353
|
+
retire(pid){
|
|
354
|
+
const m=this.mod,b=this.backends.get(pid);assert(b&&pid!==42&&this.active===pid,'retirement outside backend');
|
|
355
|
+
clearTimeout(this.timers.get(pid));this.timers.delete(pid);this.signals.delete(pid);this.parkingObservers.delete(pid);this.asyncEntries.delete(pid);
|
|
356
|
+
assert(!this.parked.has(pid),'retiring a suspended backend');
|
|
357
|
+
for(const [ticket,request]of this.checkpointTickets)if(request.owner===pid){assert(!request.waiter,'retiring a live checkpoint waiter');this.checkpointTickets.delete(ticket);this.event({event:'checkpoint-owner-exit',ticket,done:request.done});}
|
|
358
|
+
const releasedAllocations=m._pgl_sessions_cleanup_memory();let closedDescriptors=0;
|
|
359
|
+
for(const [fd,owner]of [...this.descriptorOwners])if(owner.pid===pid){
|
|
360
|
+
if(m.FS.streams[fd]===owner.stream){m.FS.close(owner.stream);closedDescriptors++;}
|
|
361
|
+
else this.descriptorOwners.delete(fd);
|
|
362
|
+
}
|
|
363
|
+
this.log.push({event:'backend-closed',pid,slot:b.slot,releasedAllocations,closedDescriptors});
|
|
364
|
+
this.save();this.active=null;this.backends.delete(pid);
|
|
365
|
+
const release=()=>{
|
|
366
|
+
assert.equal(m._pgl_sessions_release_child(b.slot),0,'backend slot not safely retired');
|
|
367
|
+
m._free(b.stack);this.freeSlots.push(b.slot);
|
|
368
|
+
};
|
|
369
|
+
if(this.operations.has(42)||this.parked.has(42))this.schedule(42,release).catch(e=>this.fail(e));
|
|
370
|
+
else{this.select(42);release();}
|
|
371
|
+
}
|
|
372
|
+
async disconnect(pid){
|
|
373
|
+
if(!this.backends.has(pid)||pid===42)return;
|
|
374
|
+
const waiter=this.parked.get(pid);
|
|
375
|
+
if(waiter)this.signal(pid,2);
|
|
376
|
+
if(waiter?.kind==='spi'&&!waiter.released)this.resumeSPI(pid);
|
|
377
|
+
await this.schedule(pid,async()=>{
|
|
378
|
+
const m=this.mod,b=this.backends.get(pid),sp=m.stackSave(),io=this.io(Buffer.from([88,0,0,0,4]));
|
|
379
|
+
m._pgl_setPGliteActive(0);
|
|
380
|
+
try{await m._PostgresMainLoopOnce();}catch(e){if(e.status!==0)throw e;}
|
|
381
|
+
finally{io.finish();m.stackRestore(sp);m._pgl_setPGliteActive(1);}
|
|
382
|
+
this.retire(pid);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
async close(){
|
|
386
|
+
for(const pid of [...this.backends.keys()].filter(p=>p!==42))await this.disconnect(pid);
|
|
387
|
+
for(const t of this.timers.values())clearTimeout(t);this.timers.clear();
|
|
388
|
+
await this.schedule(42,()=>this.db.close());
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
export const createHost=options=>EngineHost.create(options);
|