@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.
Files changed (383) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +45 -0
  3. package/README.md +152 -2
  4. package/THIRD_PARTY_NOTICES +6770 -0
  5. package/dist/browser.mjs +2642 -0
  6. package/examples/quickstart.mjs +11 -0
  7. package/licenses/Emscripten.txt +101 -0
  8. package/licenses/ICU.txt +542 -0
  9. package/licenses/OSSP-UUID.txt +24 -0
  10. package/licenses/OpenSSL.txt +177 -0
  11. package/licenses/PGlite.txt +176 -0
  12. package/licenses/PostgreSQL-extra.txt +3592 -0
  13. package/licenses/PostgreSQL.txt +23 -0
  14. package/licenses/README.md +36 -0
  15. package/licenses/Snowball.txt +29 -0
  16. package/licenses/async-mutex.txt +21 -0
  17. package/licenses/base64-js.txt +21 -0
  18. package/licenses/buffer.txt +21 -0
  19. package/licenses/compiler-rt.txt +311 -0
  20. package/licenses/dlmalloc.txt +135 -0
  21. package/licenses/esbuild.txt +21 -0
  22. package/licenses/ieee754.txt +11 -0
  23. package/licenses/libcxx.txt +311 -0
  24. package/licenses/libcxxabi.txt +311 -0
  25. package/licenses/libunwind.txt +311 -0
  26. package/licenses/libxml2-extra.txt +34 -0
  27. package/licenses/libxml2.txt +24 -0
  28. package/licenses/libxslt.txt +53 -0
  29. package/licenses/musl.txt +193 -0
  30. package/licenses/pg-protocol.txt +21 -0
  31. package/licenses/tinytar.txt +21 -0
  32. package/licenses/tslib.txt +28 -0
  33. package/licenses/tsup.txt +21 -0
  34. package/licenses/zlib.txt +22 -0
  35. package/package.json +76 -4
  36. package/runtime/engine/frozen/runtime/engine-host.mjs +377 -0
  37. package/runtime/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
  38. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
  39. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
  40. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
  41. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
  42. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
  43. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
  44. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
  45. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
  46. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
  47. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
  48. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
  49. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
  50. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
  51. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
  52. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
  53. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
  54. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
  55. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
  56. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
  57. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
  58. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
  59. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
  60. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
  61. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
  62. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
  63. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
  64. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
  65. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
  66. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
  67. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
  68. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
  69. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
  70. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
  71. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
  72. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
  73. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
  74. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
  75. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
  76. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
  77. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
  78. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
  79. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
  80. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
  81. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
  82. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
  83. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
  84. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
  85. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
  86. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
  87. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
  88. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
  89. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
  90. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
  91. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
  92. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
  93. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
  94. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
  95. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
  96. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
  97. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
  98. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
  99. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
  100. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
  101. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
  102. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
  103. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
  104. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
  105. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
  106. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
  107. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
  108. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
  109. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
  110. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
  111. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
  112. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
  113. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
  114. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
  115. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
  116. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
  117. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
  118. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
  119. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
  120. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
  121. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
  122. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
  123. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
  124. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
  125. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
  126. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
  127. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
  128. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
  129. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
  130. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
  131. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
  132. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
  133. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
  134. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
  135. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
  136. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
  137. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
  138. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
  139. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
  140. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
  141. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
  142. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
  143. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
  144. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
  145. package/runtime/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
  146. package/runtime/race/pin.mjs +12 -0
  147. package/runtime/runtime-manifest.json +579 -0
  148. package/runtime/wait/initial-image.tgz +0 -0
  149. package/runtime/wait/wire.mjs +39 -0
  150. package/runtime-infn/engine/frozen/runtime/engine-host.mjs +390 -0
  151. package/runtime-infn/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
  152. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
  153. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
  154. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
  155. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
  156. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
  157. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
  158. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
  159. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
  160. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
  161. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
  162. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
  163. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
  164. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
  165. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
  166. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
  167. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
  168. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
  169. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
  170. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
  171. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
  172. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
  173. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
  174. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
  175. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
  176. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
  177. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
  178. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
  179. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
  180. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
  181. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
  182. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
  183. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
  184. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
  185. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
  186. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
  187. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
  188. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
  189. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
  190. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
  191. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
  192. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
  193. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
  194. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
  195. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
  196. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
  197. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
  198. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
  199. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
  200. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
  201. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
  202. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
  203. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
  204. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
  205. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
  206. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
  207. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
  208. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
  209. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
  210. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
  211. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
  212. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
  213. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
  214. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
  215. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
  216. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
  217. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
  218. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
  219. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
  220. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
  221. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
  222. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
  223. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
  224. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
  225. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
  226. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
  227. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
  228. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
  229. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
  230. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
  231. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
  232. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
  233. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
  234. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
  235. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
  236. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
  237. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
  238. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
  239. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
  240. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
  241. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
  242. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
  243. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
  244. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
  245. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
  246. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
  247. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
  248. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
  249. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
  250. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
  251. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
  252. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
  253. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
  254. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
  255. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
  256. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
  257. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
  258. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
  259. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
  260. package/runtime-infn/race/pin.mjs +12 -0
  261. package/runtime-infn/runtime-manifest.json +580 -0
  262. package/runtime-infn/wait/initial-image.tgz +0 -0
  263. package/runtime-infn/wait/wire.mjs +39 -0
  264. package/runtime-infnprod/engine/frozen/runtime/engine-host.mjs +391 -0
  265. package/runtime-infnprod/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
  266. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
  267. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
  268. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
  269. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
  270. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
  271. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
  272. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
  273. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
  274. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
  275. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
  276. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
  277. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
  278. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
  279. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
  280. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
  281. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
  282. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
  283. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
  284. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
  285. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
  286. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
  287. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
  288. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
  289. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
  290. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
  291. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
  292. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
  293. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
  294. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
  295. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
  296. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
  297. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
  298. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
  299. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
  300. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
  301. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
  302. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
  303. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
  304. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
  305. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
  306. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
  307. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
  308. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
  309. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
  310. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
  311. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
  312. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
  313. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
  314. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
  315. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
  316. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
  317. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
  318. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
  319. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
  320. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
  321. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
  322. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
  323. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
  324. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
  325. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
  326. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
  327. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
  328. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
  329. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
  330. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
  331. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
  332. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
  333. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
  334. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
  335. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
  336. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
  337. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
  338. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
  339. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
  340. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
  341. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
  342. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
  343. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
  344. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
  345. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
  346. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
  347. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
  348. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
  349. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
  350. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
  351. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
  352. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
  353. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
  354. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
  355. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
  356. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
  357. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
  358. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
  359. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
  360. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
  361. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
  362. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
  363. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
  364. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
  365. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
  366. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
  367. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
  368. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
  369. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
  370. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
  371. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
  372. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
  373. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
  374. package/runtime-infnprod/race/pin.mjs +12 -0
  375. package/runtime-infnprod/runtime-manifest.json +581 -0
  376. package/runtime-infnprod/wait/initial-image.tgz +0 -0
  377. package/runtime-infnprod/wait/wire.mjs +39 -0
  378. package/src/browser-platform.mjs +12 -0
  379. package/src/browser.d.ts +5 -0
  380. package/src/browser.mjs +43 -0
  381. package/src/index.d.ts +50 -0
  382. package/src/index.mjs +23 -0
  383. package/src/runtime-integrity.mjs +69 -0
@@ -0,0 +1,28 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+
16
+
17
+ Copyright (c) Microsoft Corporation.
18
+
19
+ Permission to use, copy, modify, and/or distribute this software for any
20
+ purpose with or without fee is hereby granted.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 EGOIST
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright notice:
2
+
3
+ (C) 1995-2026 Jean-loup Gailly and Mark Adler
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+
21
+ Jean-loup Gailly Mark Adler
22
+ jloup@gzip.org madler@alumni.caltech.edu
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@viberaven/sessions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Several real PostgreSQL 18.6 sessions in one PGlite WebAssembly instance for concurrency tests and replay. Part of VibeRaven.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "VibeRaven",
8
+ "homepage": "https://github.com/ohad6k/VibeRaven#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ohad6k/VibeRaven.git"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "tag": "next"
16
+ },
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "browser": {
23
+ "types": "./src/browser.d.ts",
24
+ "default": "./dist/browser.mjs"
25
+ },
26
+ "types": "./src/index.d.ts",
27
+ "default": "./src/index.mjs"
28
+ },
29
+ "./browser": {
30
+ "types": "./src/browser.d.ts",
31
+ "default": "./dist/browser.mjs"
32
+ },
33
+ "./pin": "./runtime/race/pin.mjs",
34
+ "./runtime-manifest.json": "./runtime/runtime-manifest.json",
35
+ "./contrib/*": "./runtime/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/*.js"
36
+ },
37
+ "files": [
38
+ "src",
39
+ "runtime",
40
+ "runtime-infn",
41
+ "runtime-infnprod",
42
+ "dist/browser.mjs",
43
+ "LICENSE",
44
+ "NOTICE",
45
+ "licenses",
46
+ "README.md",
47
+ "examples",
48
+ "THIRD_PARTY_NOTICES"
49
+ ],
50
+ "scripts": {
51
+ "test": "node --test test/*.test.mjs",
52
+ "build": "node scripts/build-browser.mjs",
53
+ "verify:runtime": "node src/runtime-integrity.mjs",
54
+ "prepack": "npm run verify:runtime && npm run build"
55
+ },
56
+ "devDependencies": {
57
+ "buffer": "6.0.3",
58
+ "esbuild": "0.25.12"
59
+ },
60
+ "keywords": [
61
+ "postgres",
62
+ "postgresql",
63
+ "pglite",
64
+ "wasm",
65
+ "webassembly",
66
+ "concurrency",
67
+ "race-condition",
68
+ "transactions",
69
+ "deterministic-testing",
70
+ "replay",
71
+ "testing",
72
+ "database",
73
+ "supabase"
74
+ ],
75
+ "bugs": {
76
+ "url": "https://github.com/ohad6k/VibeRaven/issues"
77
+ }
78
+ }
@@ -0,0 +1,377 @@
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.sessionsTimer=(which,sec,usec)=>h.timer(which,sec,usec);
78
+ m.sessionsSync=(tag,size,type)=>h.syncRequest(tag,size,type);
79
+ m.sessionsNextSync=(tag,size,type)=>h.nextSyncRequest(tag,size,type);
80
+ m.sessionsCheckpointStart=flags=>h.startCheckpoint(flags);
81
+ m.sessionsCheckpointWait=ticket=>h.waitCheckpoint(ticket);
82
+ m.sessionsCheckpointRelease=ticket=>h.releaseCheckpoint(ticket);
83
+ }]}})};
84
+ h.db=await PGlite.create({...options,children:undefined,
85
+ extensions:{...options.extensions,contexts:extension},
86
+ startParams:[...PGlite.defaultStartParams,'-c','shared_memory_type=sysv','-c','dynamic_shared_memory_type=sysv',...(options.extraStartParams??[])],
87
+ onStderr:text=>{h.log.push({event:'stderr',text});options.onStderr?.(text);},
88
+ onStdout:text=>{h.log.push({event:'stdout',text});options.onStdout?.(text);}});
89
+ assert(h.pristine&&h.mod,'initial private image unavailable');
90
+ h.active=42;h.backends.set(42,{pid:42,image:h.capture(),sp:h.mod.stackSave(),slot:1});
91
+ h.log.push({event:'backend-ready',pid:42});
92
+ for(const pid of options.children??[])await h.attach(pid);
93
+ return h;
94
+ }
95
+ capture(){return new Map(this.spans.map(s=>[s.key,this.mod.HEAPU8.slice(s.start,s.start+s.size)]));}
96
+ 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);}}
97
+ save(){if(this.active!==null){const b=this.backends.get(this.active);assert(b);b.image=this.capture();b.sp=this.mod.stackSave();}}
98
+ select(pid){
99
+ assert(this.backends.has(pid),'unknown backend');
100
+ 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++;}
101
+ const signals=this.signals.get(pid);this.signals.delete(pid);
102
+ if(signals)for(const sig of signals)this.deliver(sig);
103
+ }
104
+ deliver(sig){
105
+ this.event({event:'signal-deliver',pid:this.active,sig});this.synchronousDepth++;
106
+ try{if(sig===14)this.mod._pgl_sessions_alarm();else this.mod._pgl_sessions_deliver(sig);}
107
+ finally{this.synchronousDepth--;}
108
+ }
109
+ canYield(){
110
+ if(this.synchronousDepth||!this.asyncEntries.has(this.active))return false;
111
+ const now=Date.now();if(now<this.quantumDeadline)return false;
112
+ this.quantumDeadline=now+4;return true;
113
+ }
114
+ schedule(pid,work,interrupt=false){
115
+ if(this.failure)return Promise.reject(this.failure);
116
+ return new Promise((resolve,reject)=>{this.jobs.push({pid,work,resolve,reject,interrupt});this.kick();});
117
+ }
118
+ kick(){if(!this.scheduled){this.scheduled=true;queueMicrotask(()=>{this.scheduled=false;this.pump();});}}
119
+ pump(){
120
+ if(this.busy||this.failure)return;
121
+ for(const [pid,w]of this.parked){
122
+ if(!w.queued&&(w.kind==='service'?(w.notified||w.request.done):(w.timedOut||this.latchSet(w)))){w.queued=true;this.jobs.push({pid,wake:w});}
123
+ }
124
+ const index=this.jobs.findIndex(j=>j.wake||j.interrupt||!this.operations.has(j.pid));
125
+ if(index<0)return;
126
+ const [job]=this.jobs.splice(index,1);
127
+ if(!this.backends.has(job.pid)&&job.interrupt){job.resolve?.();this.kick();return;}
128
+ if(job.wake){
129
+ const w=job.wake;if(this.parked.get(job.pid)!==w){this.kick();return;}
130
+ this.busy=true;this.select(job.pid);this.mod.stackRestore(w.sp);this.parked.delete(job.pid);
131
+ clearTimeout(w.timeoutHandle);w.returned=true;
132
+ if(w.kind==='service'){
133
+ assert.equal(w.request.waiter,w);w.request.waiter=null;
134
+ this.event({event:'service-wake',pid:job.pid,ticket:w.request.ticket,done:w.request.done});
135
+ w.resolve(w.request.done?1:0);
136
+ }else{
137
+ w.returnedSet=this.latchSet(w);
138
+ this.event({event:'wake',pid:job.pid,latch:w.latch,latchSet:w.returnedSet,timedOut:!!w.timedOut});
139
+ w.resolve(w.returnedSet?1:0);
140
+ }
141
+ // Ownership remains with the resumed C activation until it sleeps again
142
+ // or its exported entry completes. Never resolve two C stacks together.
143
+ return;
144
+ }
145
+ this.busy=true;
146
+ if(!job.interrupt)this.operations.set(job.pid,job);
147
+ try{this.select(job.pid);}catch(e){job.reject(e);this.fail(e);return;}
148
+ Promise.resolve().then(job.work).then(job.resolve,job.reject).finally(()=>{
149
+ if(!job.interrupt)this.operations.delete(job.pid);
150
+ if(!this.options.oneSession||this.backends.size>1)this.save();
151
+ this.busy=false;this.kick();
152
+ });
153
+ }
154
+ fail(error){
155
+ if(this.failure)return;
156
+ this.failure=error;for(const j of this.jobs.splice(0))j.reject?.(error);
157
+ for(const timer of this.timers.values())clearTimeout(timer);this.timers.clear();
158
+ for(const parked of this.parked.values())clearTimeout(parked.timeoutHandle);
159
+ // A fatal host error is not a resume permission. Leave C continuations
160
+ // parked and notify the owning runner, which records the failed engine.
161
+ this.reportFailure(error);
162
+ }
163
+ latchSet(w){
164
+ if(!w.latch)return false;
165
+ if(this.active!==w.pid){
166
+ const span=this.spans.find(s=>w.latch>=s.start&&w.latch+4<=s.start+s.size);
167
+ if(span){
168
+ const b=this.backends.get(w.pid).image.get(span.key)??this.initial.get(span.key);
169
+ return new DataView(b.buffer,b.byteOffset+w.latch-span.start,4).getInt32(0,true)!==0;
170
+ }
171
+ }
172
+ return new DataView(this.mod.HEAPU8.buffer).getInt32(w.latch,true)!==0;
173
+ }
174
+ sleep(latch,timeout,cooperative=false){
175
+ const pid=this.active;assert(this.busy&&this.backends.has(pid));assert(!this.parked.has(pid));
176
+ if(latch&&new DataView(this.mod.HEAPU8.buffer).getInt32(latch,true)!==0)return Promise.resolve(1);
177
+ return new Promise(resolve=>{
178
+ const osService=this.osActivations.has(pid);
179
+ const w={pid,latch,timeout,cooperative,osService,kind:cooperative?'yield':latch?'latch':'timer',sp:this.mod.stackSave(),resolve,queued:false};
180
+ this.parked.set(pid,w);if(!cooperative&&!osService)this.waits.push(w);this.save();this.busy=false;
181
+ this.event({event:cooperative?'yield':'park',pid,latch,timeout});
182
+ if(timeout>=0)w.timeoutHandle=setTimeout(()=>{w.timedOut=true;this.kick();},timeout);
183
+ if(!cooperative&&!osService){
184
+ for(const notify of this.parkingObservers.get(pid)??[])notify(w);
185
+ this.parkingObservers.delete(pid);this.onWait?.(w);
186
+ }
187
+ this.kick();
188
+ });
189
+ }
190
+ waitUntilParked(pid){
191
+ if(this.parked.has(pid)&&!this.parked.get(pid).cooperative&&!this.parked.get(pid).osService)return Promise.resolve(this.parked.get(pid));
192
+ 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;})]);
193
+ }
194
+ timer(which,sec,usec){
195
+ if(which!==0)return -1;
196
+ const pid=this.active;if(pid===null)return 0;
197
+ clearTimeout(this.timers.get(pid));this.timers.delete(pid);
198
+ const ms=sec*1000+usec/1000;
199
+ this.event({event:'timer-arm',pid,milliseconds:ms});
200
+ if(ms>0){
201
+ const handle=setTimeout(()=>{
202
+ this.timers.delete(pid);
203
+ this.event({event:'timer-fire',pid});
204
+ if(this.backends.has(pid))this.signal(pid,14);
205
+ },Math.max(1,ms));this.timers.set(pid,handle);
206
+ }
207
+ return 0;
208
+ }
209
+ startCheckpoint(flags){
210
+ const owner=this.active,ticket=this.nextCheckpointTicket++;
211
+ assert(ticket>0&&ticket<0x7fffffff,'checkpoint ticket ceiling');
212
+ assert(owner!==42&&this.backends.has(owner),'checkpoint requester outside backend lifetime');
213
+ const request={ticket,owner,flags,done:false,waiter:null};this.checkpointTickets.set(ticket,request);
214
+ this.event({event:'checkpoint-request',pid:owner,ticket,flags});
215
+ this.schedule(42,()=>this.runCheckpoint(request)).then(()=>{
216
+ request.done=true;this.event({event:'checkpoint-complete',ticket});this.kick();
217
+ },cause=>this.fail(new Error('checkpoint coordinator failed',{cause})));
218
+ return ticket;
219
+ }
220
+ async runCheckpoint(request){
221
+ const m=this.mod,sp=m.stackSave();this.asyncEntries.add(42);this.osActivations.add(42);
222
+ try{assert.equal(await m._pgl_sessions_checkpoint_request(request.flags),1,'checkpoint coordinator did not complete');}
223
+ finally{this.osActivations.delete(42);this.asyncEntries.delete(42);m.stackRestore(sp);}
224
+ }
225
+ waitCheckpoint(ticket){
226
+ const request=this.checkpointTickets.get(ticket),pid=this.active;
227
+ assert(request&&request.owner===pid,'invalid checkpoint waiter');
228
+ assert(this.busy&&!this.parked.has(pid)&&!request.waiter,'overlapping checkpoint waiter');
229
+ if(request.done)return Promise.resolve(1);
230
+ return new Promise(resolve=>{
231
+ const w={kind:'service',pid,request,sp:this.mod.stackSave(),resolve,queued:false,notified:false};
232
+ request.waiter=w;this.parked.set(pid,w);this.save();this.busy=false;
233
+ this.event({event:'service-park',pid,ticket});this.kick();
234
+ });
235
+ }
236
+ releaseCheckpoint(ticket){
237
+ const request=this.checkpointTickets.get(ticket);
238
+ assert(request&&request.owner===this.active&&!request.waiter,'invalid checkpoint ticket release');
239
+ this.checkpointTickets.delete(ticket);this.event({event:'checkpoint-release',ticket,done:request.done});
240
+ // The scheduled kernel request owns its own reference and continues even
241
+ // when native CHECK_FOR_INTERRUPTS unwinds its abandoned caller.
242
+ }
243
+ nextSyncRequest(tag,size,type){
244
+ assert.equal(this.active,42,'sync mailbox consumed outside coordinator');
245
+ const request=this.syncMailbox[0];if(!request)return 0;
246
+ assert.equal(size,request.bytes.length,'FileTag ABI mismatch');
247
+ this.mod.HEAPU8.set(request.bytes,tag);new DataView(this.mod.HEAPU8.buffer).setInt32(type,request.type,true);
248
+ this.syncMailbox.shift();return 1;
249
+ }
250
+ syncRequest(tag,size,type){
251
+ const caller=this.active;
252
+ assert(this.backends.has(42)&&this.backends.has(caller)&&caller!==42,'sync service outside backend lifetime');
253
+ assert(Number.isInteger(size)&&size>0&&size<=256,'invalid FileTag size');
254
+ this.syncMailbox.push({bytes:this.mod.HEAPU8.slice(tag,tag+size),type});
255
+ // A live coordinator consumes its mailbox only from the native Absorb
256
+ // boundary. Never reenter its suspended checkpoint activation.
257
+ if(this.operations.has(42)||this.parked.has(42))return 1;
258
+ this.synchronousDepth++;
259
+ try{this.select(42);assert.equal(this.mod._pgl_sessions_absorb_sync_service(),1,'sync mailbox registration failed');return 1;}
260
+ catch(cause){const error=new Error('sync coordinator failed',{cause});this.fail(error);throw error;}
261
+ finally{this.select(caller);this.synchronousDepth--;}
262
+ }
263
+ signal(pid,sig){
264
+ if(!this.backends.has(pid))return;
265
+ const signals=this.signals.get(pid)??new Set();signals.add(sig);this.signals.set(pid,signals);
266
+ // Idle and parked backends both receive the real C signal handler with
267
+ // their own private globals selected. It sets the real latch/interrupts.
268
+ this.schedule(pid,()=>this.serviceIdle(pid),true).catch(e=>this.fail(e));
269
+ }
270
+ async serviceIdle(pid){
271
+ const waiter=this.parked.get(pid);
272
+ if(waiter?.kind==='service'){waiter.notified=true;this.kick();return;}
273
+ if(this.operations.has(pid)||waiter)return;
274
+ const m=this.mod,sp=m.stackSave(),io=this.io(Buffer.alloc(0),bytes=>this.onAsyncData?.(pid,bytes));
275
+ const operation={idle:true};this.operations.set(pid,operation);let exit;
276
+ this.asyncEntries.add(pid);
277
+ try{await m._pgl_sessions_idle_interrupt();}
278
+ catch(e){if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;exit=e.status;}
279
+ finally{this.asyncEntries.delete(pid);this.operations.delete(pid);io.finish();m.stackRestore(sp);}
280
+ if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
281
+ }
282
+ io(input,onData){
283
+ const m=this.mod;let offset=0;const output=[];
284
+ 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');
285
+ const write=m.addFunction((ptr,n)=>{const b=Buffer.from(m.HEAPU8.slice(ptr,ptr+n));output.push(b);onData?.(b);return n;},'ipi');
286
+ const lookup=name=>{const v=this.layout.inputs.find(x=>x.input.endsWith('.'+name));assert(v,'missing IO shim section');return v.start;};
287
+ const view=new DataView(m.HEAPU8.buffer),readAddr=lookup('pgl_read'),writeAddr=lookup('pgl_write');
288
+ const oldRead=view.getUint32(readAddr,true),oldWrite=view.getUint32(writeAddr,true);
289
+ m._pgl_set_rw_cbs(read,write);
290
+ return {output,get remaining(){return input.length-offset;},finish(){m._pgl_set_rw_cbs(oldRead,oldWrite);m.removeFunction(read);m.removeFunction(write);}};
291
+ }
292
+ async attach(pid,packet=startup('l2-backend')){
293
+ assert(!this.backends.has(pid));
294
+ const slot=this.freeSlots.pop()??this.nextSlot++;
295
+ const path='/tmp/l2-child-'+pid;
296
+ await this.schedule(42,()=>{
297
+ const m=this.mod,sp=m.stackSave(),p=m.stringToUTF8OnStack(path);
298
+ try{assert.equal(m._pgl_sessions_prepare_child(slot,p,pid),0,'child serialization failed');}finally{m.stackRestore(sp);}
299
+ });
300
+ // Create the stack before restoring the clean child-private template. The
301
+ // allocator and virtual filesystem remain shared, as they do in WAIT.
302
+ await this.schedule(42,()=>{
303
+ const stack=this.mod._pgl_sessions_stack();assert(stack>0);const sp=stack+8*1024*1024;
304
+ this.backends.set(pid,{pid,slot,stack,sp,image:new Map(this.pristine)});
305
+ });
306
+ return this.schedule(pid,async()=>{
307
+ const m=this.mod,b=this.backends.get(pid);m._pgl_setPGliteActive(1);m._pgl_sessions_setpid(pid);m.stackRestore(b.sp);
308
+ const io=this.io(packet);let exit;
309
+ try{exit=await m.callMain(['--forkchild=backend',path]);}
310
+ finally{m.stackRestore(b.sp);io.finish();}
311
+ const bytes=Buffer.concat(io.output),response=parseWire(bytes);
312
+ if(exit!==99&&hasFatalResponse(bytes)){
313
+ this.retire(pid);throw new BackendStartExit(exit,bytes);
314
+ }
315
+ assert.equal(exit,99,JSON.stringify(response));assert(!response.results.some(x=>x.error),JSON.stringify(response));
316
+ this.log.push({event:'child-entry',pid,slot,exit,startup:response});return bytes;
317
+ });
318
+ }
319
+ raw(pid,input,onData){
320
+ return this.schedule(pid,async()=>{
321
+ const m=this.mod,sp=m.stackSave(),io=this.io(input,onData);let exit;
322
+ this.asyncEntries.add(pid);
323
+ try {
324
+ while(io.remaining>0||m._pq_buffer_remaining_data()>0){
325
+ try{await m._PostgresMainLoopOnce();}
326
+ catch(e){
327
+ m.stackRestore(sp);
328
+ if(e.status===100){this.synchronousDepth++;try{m._PostgresMainLongJmp();}finally{this.synchronousDepth--;}continue;}
329
+ if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;
330
+ exit=e.status;break;
331
+ }
332
+ }
333
+ if(exit===undefined){m._PostgresSendReadyForQueryIfNecessary();m._pgl_pq_flush();}
334
+ } finally {this.asyncEntries.delete(pid);io.finish();m.stackRestore(sp);}
335
+ const bytes=Buffer.concat(io.output);this.onProtocol?.({pid,bytes});
336
+ if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
337
+ return bytes;
338
+ });
339
+ }
340
+ async query(pid,sql){const bytes=await this.raw(pid,simpleQuery(sql));return parseWire(bytes);}
341
+ retire(pid){
342
+ const m=this.mod,b=this.backends.get(pid);assert(b&&pid!==42&&this.active===pid,'retirement outside backend');
343
+ clearTimeout(this.timers.get(pid));this.timers.delete(pid);this.signals.delete(pid);this.parkingObservers.delete(pid);this.asyncEntries.delete(pid);
344
+ assert(!this.parked.has(pid),'retiring a suspended backend');
345
+ 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});}
346
+ const releasedAllocations=m._pgl_sessions_cleanup_memory();let closedDescriptors=0;
347
+ for(const [fd,owner]of [...this.descriptorOwners])if(owner.pid===pid){
348
+ if(m.FS.streams[fd]===owner.stream){m.FS.close(owner.stream);closedDescriptors++;}
349
+ else this.descriptorOwners.delete(fd);
350
+ }
351
+ this.log.push({event:'backend-closed',pid,slot:b.slot,releasedAllocations,closedDescriptors});
352
+ this.save();this.active=null;this.backends.delete(pid);
353
+ const release=()=>{
354
+ assert.equal(m._pgl_sessions_release_child(b.slot),0,'backend slot not safely retired');
355
+ m._free(b.stack);this.freeSlots.push(b.slot);
356
+ };
357
+ if(this.operations.has(42)||this.parked.has(42))this.schedule(42,release).catch(e=>this.fail(e));
358
+ else{this.select(42);release();}
359
+ }
360
+ async disconnect(pid){
361
+ if(!this.backends.has(pid)||pid===42)return;
362
+ if(this.parked.has(pid))this.signal(pid,2);
363
+ await this.schedule(pid,async()=>{
364
+ const m=this.mod,b=this.backends.get(pid),sp=m.stackSave(),io=this.io(Buffer.from([88,0,0,0,4]));
365
+ m._pgl_setPGliteActive(0);
366
+ try{await m._PostgresMainLoopOnce();}catch(e){if(e.status!==0)throw e;}
367
+ finally{io.finish();m.stackRestore(sp);m._pgl_setPGliteActive(1);}
368
+ this.retire(pid);
369
+ });
370
+ }
371
+ async close(){
372
+ for(const pid of [...this.backends.keys()].filter(p=>p!==42))await this.disconnect(pid);
373
+ for(const t of this.timers.values())clearTimeout(t);this.timers.clear();
374
+ await this.schedule(42,()=>this.db.close());
375
+ }
376
+ }
377
+ export const createHost=options=>EngineHost.create(options);