@xtandard/kit 0.0.0-stage → 0.1.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 (402) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -2
  3. package/bin/xtandard-kit.mjs +3 -0
  4. package/dist/base-path-BJugWLNO.cjs +42 -0
  5. package/dist/base-path-BJugWLNO.cjs.map +1 -0
  6. package/dist/base-path-CDb4In5E.mjs +31 -0
  7. package/dist/base-path-CDb4In5E.mjs.map +1 -0
  8. package/dist/basic-Qtriv0xS.mjs +176 -0
  9. package/dist/basic-Qtriv0xS.mjs.map +1 -0
  10. package/dist/basic-ZaO92-lB.cjs +199 -0
  11. package/dist/basic-ZaO92-lB.cjs.map +1 -0
  12. package/dist/bin.cjs +126 -0
  13. package/dist/bin.cjs.map +1 -0
  14. package/dist/bin.d.cts +20 -0
  15. package/dist/bin.d.mts +20 -0
  16. package/dist/bin.mjs +125 -0
  17. package/dist/bin.mjs.map +1 -0
  18. package/dist/cas-CuPSaXBV.cjs +23 -0
  19. package/dist/cas-CuPSaXBV.cjs.map +1 -0
  20. package/dist/cas-CzA-yECx.mjs +18 -0
  21. package/dist/cas-CzA-yECx.mjs.map +1 -0
  22. package/dist/chunk-DakpK96I.cjs +43 -0
  23. package/dist/contract-B3UPXXLx.d.cts +30 -0
  24. package/dist/contract-B3UPXXLx.d.mts +30 -0
  25. package/dist/contract-BDPNvjtp.d.mts +64 -0
  26. package/dist/contract-BEdfGTPs.mjs +85 -0
  27. package/dist/contract-BEdfGTPs.mjs.map +1 -0
  28. package/dist/contract-BIVzAn4f.d.cts +64 -0
  29. package/dist/contract-BvgtswLX.d.cts +75 -0
  30. package/dist/contract-BvgtswLX.d.mts +75 -0
  31. package/dist/contract-DUj9P3Vt.d.cts +72 -0
  32. package/dist/contract-DUj9P3Vt.d.mts +72 -0
  33. package/dist/contract-wAEMDmYG.cjs +132 -0
  34. package/dist/contract-wAEMDmYG.cjs.map +1 -0
  35. package/dist/drizzle-BElCHWri.d.mts +115 -0
  36. package/dist/drizzle-BXaQXCr0.cjs +232 -0
  37. package/dist/drizzle-BXaQXCr0.cjs.map +1 -0
  38. package/dist/drizzle-CEpahWQB.d.cts +115 -0
  39. package/dist/drizzle-DxnelsPT.mjs +197 -0
  40. package/dist/drizzle-DxnelsPT.mjs.map +1 -0
  41. package/dist/duration-7WpAK-xe.mjs +52 -0
  42. package/dist/duration-7WpAK-xe.mjs.map +1 -0
  43. package/dist/duration-DVA0Fzkx.cjs +63 -0
  44. package/dist/duration-DVA0Fzkx.cjs.map +1 -0
  45. package/dist/duration-FPwbmWIU.d.cts +35 -0
  46. package/dist/duration-FPwbmWIU.d.mts +35 -0
  47. package/dist/entry-adapters-bun.cjs +10 -0
  48. package/dist/entry-adapters-bun.cjs.map +1 -0
  49. package/dist/entry-adapters-bun.d.cts +10 -0
  50. package/dist/entry-adapters-bun.d.mts +10 -0
  51. package/dist/entry-adapters-bun.mjs +9 -0
  52. package/dist/entry-adapters-bun.mjs.map +1 -0
  53. package/dist/entry-adapters-elysia.cjs +54 -0
  54. package/dist/entry-adapters-elysia.cjs.map +1 -0
  55. package/dist/entry-adapters-elysia.d.cts +38 -0
  56. package/dist/entry-adapters-elysia.d.mts +38 -0
  57. package/dist/entry-adapters-elysia.mjs +53 -0
  58. package/dist/entry-adapters-elysia.mjs.map +1 -0
  59. package/dist/entry-adapters-express.cjs +27 -0
  60. package/dist/entry-adapters-express.cjs.map +1 -0
  61. package/dist/entry-adapters-express.d.cts +24 -0
  62. package/dist/entry-adapters-express.d.mts +24 -0
  63. package/dist/entry-adapters-express.mjs +26 -0
  64. package/dist/entry-adapters-express.mjs.map +1 -0
  65. package/dist/entry-adapters-hono.cjs +33 -0
  66. package/dist/entry-adapters-hono.cjs.map +1 -0
  67. package/dist/entry-adapters-hono.d.cts +36 -0
  68. package/dist/entry-adapters-hono.d.mts +36 -0
  69. package/dist/entry-adapters-hono.mjs +30 -0
  70. package/dist/entry-adapters-hono.mjs.map +1 -0
  71. package/dist/entry-adapters-next.cjs +19 -0
  72. package/dist/entry-adapters-next.cjs.map +1 -0
  73. package/dist/entry-adapters-next.d.cts +35 -0
  74. package/dist/entry-adapters-next.d.mts +35 -0
  75. package/dist/entry-adapters-next.mjs +18 -0
  76. package/dist/entry-adapters-next.mjs.map +1 -0
  77. package/dist/entry-adapters-node.cjs +7 -0
  78. package/dist/entry-adapters-node.d.cts +2 -0
  79. package/dist/entry-adapters-node.d.mts +2 -0
  80. package/dist/entry-adapters-node.mjs +2 -0
  81. package/dist/entry-auth-basic.cjs +5 -0
  82. package/dist/entry-auth-basic.d.cts +83 -0
  83. package/dist/entry-auth-basic.d.mts +83 -0
  84. package/dist/entry-auth-basic.mjs +2 -0
  85. package/dist/entry-auth-delegated.cjs +28 -0
  86. package/dist/entry-auth-delegated.cjs.map +1 -0
  87. package/dist/entry-auth-delegated.d.cts +36 -0
  88. package/dist/entry-auth-delegated.d.mts +36 -0
  89. package/dist/entry-auth-delegated.mjs +27 -0
  90. package/dist/entry-auth-delegated.mjs.map +1 -0
  91. package/dist/entry-auth-none.cjs +4 -0
  92. package/dist/entry-auth-none.d.cts +25 -0
  93. package/dist/entry-auth-none.d.mts +25 -0
  94. package/dist/entry-auth-none.mjs +2 -0
  95. package/dist/entry-auth.cjs +0 -0
  96. package/dist/entry-auth.d.cts +2 -0
  97. package/dist/entry-auth.d.mts +2 -0
  98. package/dist/entry-auth.mjs +1 -0
  99. package/dist/entry-authorization-delegated.cjs +27 -0
  100. package/dist/entry-authorization-delegated.cjs.map +1 -0
  101. package/dist/entry-authorization-delegated.d.cts +31 -0
  102. package/dist/entry-authorization-delegated.d.mts +31 -0
  103. package/dist/entry-authorization-delegated.mjs +26 -0
  104. package/dist/entry-authorization-delegated.mjs.map +1 -0
  105. package/dist/entry-authorization-none.cjs +3 -0
  106. package/dist/entry-authorization-none.d.cts +18 -0
  107. package/dist/entry-authorization-none.d.mts +18 -0
  108. package/dist/entry-authorization-none.mjs +2 -0
  109. package/dist/entry-authorization-roles.cjs +3 -0
  110. package/dist/entry-authorization-roles.d.cts +2 -0
  111. package/dist/entry-authorization-roles.d.mts +2 -0
  112. package/dist/entry-authorization-roles.mjs +2 -0
  113. package/dist/entry-authorization.cjs +35 -0
  114. package/dist/entry-authorization.cjs.map +1 -0
  115. package/dist/entry-authorization.d.cts +2 -0
  116. package/dist/entry-authorization.d.mts +2 -0
  117. package/dist/entry-authorization.mjs +34 -0
  118. package/dist/entry-authorization.mjs.map +1 -0
  119. package/dist/entry-build.cjs +481 -0
  120. package/dist/entry-build.cjs.map +1 -0
  121. package/dist/entry-build.d.cts +355 -0
  122. package/dist/entry-build.d.mts +355 -0
  123. package/dist/entry-build.mjs +460 -0
  124. package/dist/entry-build.mjs.map +1 -0
  125. package/dist/entry-cli.cjs +368 -0
  126. package/dist/entry-cli.cjs.map +1 -0
  127. package/dist/entry-cli.d.cts +275 -0
  128. package/dist/entry-cli.d.mts +275 -0
  129. package/dist/entry-cli.mjs +355 -0
  130. package/dist/entry-cli.mjs.map +1 -0
  131. package/dist/entry-drizzle-mysql.cjs +36 -0
  132. package/dist/entry-drizzle-mysql.cjs.map +1 -0
  133. package/dist/entry-drizzle-mysql.d.cts +55 -0
  134. package/dist/entry-drizzle-mysql.d.mts +55 -0
  135. package/dist/entry-drizzle-mysql.mjs +34 -0
  136. package/dist/entry-drizzle-mysql.mjs.map +1 -0
  137. package/dist/entry-drizzle-pg.cjs +38 -0
  138. package/dist/entry-drizzle-pg.cjs.map +1 -0
  139. package/dist/entry-drizzle-pg.d.cts +78 -0
  140. package/dist/entry-drizzle-pg.d.mts +78 -0
  141. package/dist/entry-drizzle-pg.mjs +36 -0
  142. package/dist/entry-drizzle-pg.mjs.map +1 -0
  143. package/dist/entry-drizzle-sqlite.cjs +20 -0
  144. package/dist/entry-drizzle-sqlite.cjs.map +1 -0
  145. package/dist/entry-drizzle-sqlite.d.cts +22 -0
  146. package/dist/entry-drizzle-sqlite.d.mts +22 -0
  147. package/dist/entry-drizzle-sqlite.mjs +19 -0
  148. package/dist/entry-drizzle-sqlite.mjs.map +1 -0
  149. package/dist/entry-hooks-log.cjs +32 -0
  150. package/dist/entry-hooks-log.cjs.map +1 -0
  151. package/dist/entry-hooks-log.d.cts +36 -0
  152. package/dist/entry-hooks-log.d.mts +36 -0
  153. package/dist/entry-hooks-log.mjs +31 -0
  154. package/dist/entry-hooks-log.mjs.map +1 -0
  155. package/dist/entry-hooks.cjs +10 -0
  156. package/dist/entry-hooks.d.cts +2 -0
  157. package/dist/entry-hooks.d.mts +2 -0
  158. package/dist/entry-hooks.mjs +2 -0
  159. package/dist/entry-server-router.cjs +235 -0
  160. package/dist/entry-server-router.cjs.map +1 -0
  161. package/dist/entry-server-router.d.cts +193 -0
  162. package/dist/entry-server-router.d.mts +193 -0
  163. package/dist/entry-server-router.mjs +228 -0
  164. package/dist/entry-server-router.mjs.map +1 -0
  165. package/dist/entry-server.cjs +344 -0
  166. package/dist/entry-server.cjs.map +1 -0
  167. package/dist/entry-server.d.cts +230 -0
  168. package/dist/entry-server.d.mts +230 -0
  169. package/dist/entry-server.mjs +322 -0
  170. package/dist/entry-server.mjs.map +1 -0
  171. package/dist/entry-site.cjs +1083 -0
  172. package/dist/entry-site.cjs.map +1 -0
  173. package/dist/entry-site.d.cts +336 -0
  174. package/dist/entry-site.d.mts +336 -0
  175. package/dist/entry-site.mjs +1060 -0
  176. package/dist/entry-site.mjs.map +1 -0
  177. package/dist/entry-storage-cloudflare-kv.cjs +51 -0
  178. package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
  179. package/dist/entry-storage-cloudflare-kv.d.cts +52 -0
  180. package/dist/entry-storage-cloudflare-kv.d.mts +52 -0
  181. package/dist/entry-storage-cloudflare-kv.mjs +50 -0
  182. package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
  183. package/dist/entry-storage-drizzle-internals.cjs +6 -0
  184. package/dist/entry-storage-drizzle-internals.d.cts +2 -0
  185. package/dist/entry-storage-drizzle-internals.d.mts +2 -0
  186. package/dist/entry-storage-drizzle-internals.mjs +2 -0
  187. package/dist/entry-storage-drizzle.cjs +4 -0
  188. package/dist/entry-storage-drizzle.d.cts +3 -0
  189. package/dist/entry-storage-drizzle.d.mts +3 -0
  190. package/dist/entry-storage-drizzle.mjs +2 -0
  191. package/dist/entry-storage-file.cjs +306 -0
  192. package/dist/entry-storage-file.cjs.map +1 -0
  193. package/dist/entry-storage-file.d.cts +76 -0
  194. package/dist/entry-storage-file.d.mts +76 -0
  195. package/dist/entry-storage-file.mjs +301 -0
  196. package/dist/entry-storage-file.mjs.map +1 -0
  197. package/dist/entry-storage-libsql-internals.cjs +7 -0
  198. package/dist/entry-storage-libsql-internals.d.cts +3 -0
  199. package/dist/entry-storage-libsql-internals.d.mts +3 -0
  200. package/dist/entry-storage-libsql-internals.mjs +3 -0
  201. package/dist/entry-storage-libsql.cjs +3 -0
  202. package/dist/entry-storage-libsql.d.cts +2 -0
  203. package/dist/entry-storage-libsql.d.mts +2 -0
  204. package/dist/entry-storage-libsql.mjs +2 -0
  205. package/dist/entry-storage-memory.cjs +78 -0
  206. package/dist/entry-storage-memory.cjs.map +1 -0
  207. package/dist/entry-storage-memory.d.cts +35 -0
  208. package/dist/entry-storage-memory.d.mts +35 -0
  209. package/dist/entry-storage-memory.mjs +77 -0
  210. package/dist/entry-storage-memory.mjs.map +1 -0
  211. package/dist/entry-storage-mongodb-internals.cjs +5 -0
  212. package/dist/entry-storage-mongodb-internals.d.cts +2 -0
  213. package/dist/entry-storage-mongodb-internals.d.mts +2 -0
  214. package/dist/entry-storage-mongodb-internals.mjs +2 -0
  215. package/dist/entry-storage-mongodb.cjs +3 -0
  216. package/dist/entry-storage-mongodb.d.cts +2 -0
  217. package/dist/entry-storage-mongodb.d.mts +2 -0
  218. package/dist/entry-storage-mongodb.mjs +2 -0
  219. package/dist/entry-storage-postgres-internals.cjs +6 -0
  220. package/dist/entry-storage-postgres-internals.d.cts +2 -0
  221. package/dist/entry-storage-postgres-internals.d.mts +2 -0
  222. package/dist/entry-storage-postgres-internals.mjs +2 -0
  223. package/dist/entry-storage-postgres.cjs +4 -0
  224. package/dist/entry-storage-postgres.d.cts +2 -0
  225. package/dist/entry-storage-postgres.d.mts +2 -0
  226. package/dist/entry-storage-postgres.mjs +2 -0
  227. package/dist/entry-storage-redis-internals.cjs +7 -0
  228. package/dist/entry-storage-redis-internals.d.cts +2 -0
  229. package/dist/entry-storage-redis-internals.d.mts +2 -0
  230. package/dist/entry-storage-redis-internals.mjs +2 -0
  231. package/dist/entry-storage-redis.cjs +4 -0
  232. package/dist/entry-storage-redis.d.cts +2 -0
  233. package/dist/entry-storage-redis.d.mts +2 -0
  234. package/dist/entry-storage-redis.mjs +2 -0
  235. package/dist/entry-storage-sqlite-internals.cjs +7 -0
  236. package/dist/entry-storage-sqlite-internals.d.cts +3 -0
  237. package/dist/entry-storage-sqlite-internals.d.mts +3 -0
  238. package/dist/entry-storage-sqlite-internals.mjs +3 -0
  239. package/dist/entry-storage-sqlite.cjs +3 -0
  240. package/dist/entry-storage-sqlite.d.cts +2 -0
  241. package/dist/entry-storage-sqlite.d.mts +2 -0
  242. package/dist/entry-storage-sqlite.mjs +2 -0
  243. package/dist/entry-storage-testing.cjs +801 -0
  244. package/dist/entry-storage-testing.cjs.map +1 -0
  245. package/dist/entry-storage-testing.d.cts +150 -0
  246. package/dist/entry-storage-testing.d.mts +150 -0
  247. package/dist/entry-storage-testing.mjs +790 -0
  248. package/dist/entry-storage-testing.mjs.map +1 -0
  249. package/dist/entry-storage-unstorage.cjs +78 -0
  250. package/dist/entry-storage-unstorage.cjs.map +1 -0
  251. package/dist/entry-storage-unstorage.d.cts +30 -0
  252. package/dist/entry-storage-unstorage.d.mts +30 -0
  253. package/dist/entry-storage-unstorage.mjs +77 -0
  254. package/dist/entry-storage-unstorage.mjs.map +1 -0
  255. package/dist/entry-storage.cjs +114 -0
  256. package/dist/entry-storage.cjs.map +1 -0
  257. package/dist/entry-storage.d.cts +152 -0
  258. package/dist/entry-storage.d.mts +152 -0
  259. package/dist/entry-storage.mjs +91 -0
  260. package/dist/entry-storage.mjs.map +1 -0
  261. package/dist/entry-testing.cjs +79 -0
  262. package/dist/entry-testing.cjs.map +1 -0
  263. package/dist/entry-testing.d.cts +55 -0
  264. package/dist/entry-testing.d.mts +55 -0
  265. package/dist/entry-testing.mjs +77 -0
  266. package/dist/entry-testing.mjs.map +1 -0
  267. package/dist/entry-tokens.cjs +4 -0
  268. package/dist/entry-tokens.d.cts +85 -0
  269. package/dist/entry-tokens.d.mts +85 -0
  270. package/dist/entry-tokens.mjs +2 -0
  271. package/dist/entry-ui-embed.cjs +131 -0
  272. package/dist/entry-ui-embed.cjs.map +1 -0
  273. package/dist/entry-ui-embed.d.cts +87 -0
  274. package/dist/entry-ui-embed.d.mts +87 -0
  275. package/dist/entry-ui-embed.mjs +127 -0
  276. package/dist/entry-ui-embed.mjs.map +1 -0
  277. package/dist/entry-ui.cjs +795 -0
  278. package/dist/entry-ui.cjs.map +1 -0
  279. package/dist/entry-ui.d.cts +574 -0
  280. package/dist/entry-ui.d.mts +574 -0
  281. package/dist/entry-ui.mjs +731 -0
  282. package/dist/entry-ui.mjs.map +1 -0
  283. package/dist/entry-util.cjs +145 -0
  284. package/dist/entry-util.cjs.map +1 -0
  285. package/dist/entry-util.d.cts +85 -0
  286. package/dist/entry-util.d.mts +85 -0
  287. package/dist/entry-util.mjs +130 -0
  288. package/dist/entry-util.mjs.map +1 -0
  289. package/dist/http-B_rTnLW9.cjs +235 -0
  290. package/dist/http-B_rTnLW9.cjs.map +1 -0
  291. package/dist/http-CxYM7kPT.d.mts +133 -0
  292. package/dist/http-DVdVI6kJ.mjs +164 -0
  293. package/dist/http-DVdVI6kJ.mjs.map +1 -0
  294. package/dist/http-XBVRk8uo.d.cts +133 -0
  295. package/dist/index.cjs +8 -0
  296. package/dist/index.cjs.map +1 -0
  297. package/dist/index.d.cts +6 -0
  298. package/dist/index.d.mts +6 -0
  299. package/dist/index.mjs +7 -0
  300. package/dist/index.mjs.map +1 -0
  301. package/dist/json-CCyzstIm.d.cts +44 -0
  302. package/dist/json-CCyzstIm.d.mts +44 -0
  303. package/dist/json-CM7TwYQ7.cjs +92 -0
  304. package/dist/json-CM7TwYQ7.cjs.map +1 -0
  305. package/dist/json-CmM1M5Kz.mjs +63 -0
  306. package/dist/json-CmM1M5Kz.mjs.map +1 -0
  307. package/dist/keys-Bwubabk0.mjs +73 -0
  308. package/dist/keys-Bwubabk0.mjs.map +1 -0
  309. package/dist/keys-DQrwxDKI.cjs +126 -0
  310. package/dist/keys-DQrwxDKI.cjs.map +1 -0
  311. package/dist/kv-sqlite-B6iTLOx2.d.cts +20 -0
  312. package/dist/kv-sqlite-CHOdIMJ-.cjs +77 -0
  313. package/dist/kv-sqlite-CHOdIMJ-.cjs.map +1 -0
  314. package/dist/kv-sqlite-DIIPfflJ.mjs +66 -0
  315. package/dist/kv-sqlite-DIIPfflJ.mjs.map +1 -0
  316. package/dist/kv-sqlite-Tx4UedJs.d.mts +20 -0
  317. package/dist/libsql-0160BubR.d.mts +65 -0
  318. package/dist/libsql-BZmRZIqt.d.cts +65 -0
  319. package/dist/libsql-CiBfVtbS.cjs +103 -0
  320. package/dist/libsql-CiBfVtbS.cjs.map +1 -0
  321. package/dist/libsql-CkOjQINi.mjs +86 -0
  322. package/dist/libsql-CkOjQINi.mjs.map +1 -0
  323. package/dist/mongodb--Cuj7V_9.cjs +150 -0
  324. package/dist/mongodb--Cuj7V_9.cjs.map +1 -0
  325. package/dist/mongodb-DGtsolQ2.d.cts +61 -0
  326. package/dist/mongodb-JMizy4Wg.mjs +127 -0
  327. package/dist/mongodb-JMizy4Wg.mjs.map +1 -0
  328. package/dist/mongodb-xGEU5Gwz.d.mts +61 -0
  329. package/dist/node-B1Djcwfi.d.cts +57 -0
  330. package/dist/node-B1Djcwfi.d.mts +57 -0
  331. package/dist/node-BYjocCbU.mjs +167 -0
  332. package/dist/node-BYjocCbU.mjs.map +1 -0
  333. package/dist/node-DFFqYRk-.cjs +201 -0
  334. package/dist/node-DFFqYRk-.cjs.map +1 -0
  335. package/dist/none-BEY7Kc_-.mjs +33 -0
  336. package/dist/none-BEY7Kc_-.mjs.map +1 -0
  337. package/dist/none-BoQ6-30P.cjs +33 -0
  338. package/dist/none-BoQ6-30P.cjs.map +1 -0
  339. package/dist/none-CHwVkQL-.cjs +49 -0
  340. package/dist/none-CHwVkQL-.cjs.map +1 -0
  341. package/dist/none-yu3qC47E.mjs +23 -0
  342. package/dist/none-yu3qC47E.mjs.map +1 -0
  343. package/dist/peer-BIjBFzwQ.cjs +56 -0
  344. package/dist/peer-BIjBFzwQ.cjs.map +1 -0
  345. package/dist/peer-CTHMzOdn.mjs +40 -0
  346. package/dist/peer-CTHMzOdn.mjs.map +1 -0
  347. package/dist/portal-container-CJIcau3B.mjs +610 -0
  348. package/dist/portal-container-CJIcau3B.mjs.map +1 -0
  349. package/dist/portal-container-Ca1NxrLE.cjs +774 -0
  350. package/dist/portal-container-Ca1NxrLE.cjs.map +1 -0
  351. package/dist/postgres-BJzxKBk0.d.cts +72 -0
  352. package/dist/postgres-CA8_XcAE.cjs +164 -0
  353. package/dist/postgres-CA8_XcAE.cjs.map +1 -0
  354. package/dist/postgres-RfQMgAsj.d.mts +72 -0
  355. package/dist/postgres-aDiBmNzr.mjs +135 -0
  356. package/dist/postgres-aDiBmNzr.mjs.map +1 -0
  357. package/dist/redis-B2AS4xAQ.cjs +259 -0
  358. package/dist/redis-B2AS4xAQ.cjs.map +1 -0
  359. package/dist/redis-B362ofBw.d.cts +159 -0
  360. package/dist/redis-CahNAVTW.d.mts +159 -0
  361. package/dist/redis-hdoKymfG.mjs +218 -0
  362. package/dist/redis-hdoKymfG.mjs.map +1 -0
  363. package/dist/roles-7JPrQXZa.mjs +46 -0
  364. package/dist/roles-7JPrQXZa.mjs.map +1 -0
  365. package/dist/roles-B_8QqJ3j.cjs +56 -0
  366. package/dist/roles-B_8QqJ3j.cjs.map +1 -0
  367. package/dist/roles-DLISB4T3.d.mts +41 -0
  368. package/dist/roles-DQbbtUPW.d.cts +41 -0
  369. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  370. package/dist/scope-css-BN3jf0ly.cjs +315 -0
  371. package/dist/scope-css-BN3jf0ly.cjs.map +1 -0
  372. package/dist/scope-css-BuJfRCsE.mjs +256 -0
  373. package/dist/scope-css-BuJfRCsE.mjs.map +1 -0
  374. package/dist/scoped-BRoE1W1x.cjs +175 -0
  375. package/dist/scoped-BRoE1W1x.cjs.map +1 -0
  376. package/dist/scoped-cFBbotCh.mjs +164 -0
  377. package/dist/scoped-cFBbotCh.mjs.map +1 -0
  378. package/dist/sqlite-B2g1JJz1.d.cts +47 -0
  379. package/dist/sqlite-BIPIlxfj.d.mts +47 -0
  380. package/dist/sqlite-BntoYaXZ.cjs +79 -0
  381. package/dist/sqlite-BntoYaXZ.cjs.map +1 -0
  382. package/dist/sqlite-DYJDcu7p.mjs +62 -0
  383. package/dist/sqlite-DYJDcu7p.mjs.map +1 -0
  384. package/dist/table-BrioFSra.d.cts +11 -0
  385. package/dist/table-BrioFSra.d.mts +11 -0
  386. package/dist/theme-context-DzZ1otaD.d.cts +270 -0
  387. package/dist/theme-context-J65pythD.d.mts +270 -0
  388. package/dist/ui/styles.css +239 -0
  389. package/dist/util-Dnj5T-yw.mjs +39 -0
  390. package/dist/util-Dnj5T-yw.mjs.map +1 -0
  391. package/dist/util-dAnTK9x-.cjs +74 -0
  392. package/dist/util-dAnTK9x-.cjs.map +1 -0
  393. package/dist/validation-B-atP968.mjs +191 -0
  394. package/dist/validation-B-atP968.mjs.map +1 -0
  395. package/dist/validation-BJifGoB2.d.mts +122 -0
  396. package/dist/validation-DLnzBVJr.cjs +258 -0
  397. package/dist/validation-DLnzBVJr.cjs.map +1 -0
  398. package/dist/validation-tfV2qhbD.d.cts +122 -0
  399. package/package.json +715 -4
  400. package/tsconfig/assets.d.ts +21 -0
  401. package/tsconfig/base.json +21 -0
  402. package/tsconfig/react.json +9 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-server.cjs","names":["normalizeBasePath","stripBasePath","json","durationToMs"],"sources":["../src/server/cors.ts","../src/server/render-index-html.ts","../src/server/static-assets.ts","../src/server/panel.ts"],"sourcesContent":["/**\n * Framework-independent CORS for the mounted panel. When the panel handler is\n * given a `cors` option, it answers `OPTIONS` preflights itself and attaches\n * `Access-Control-*` headers to every response — so a **cross-origin embed**\n * (a widget on `app.example.com`, the panel on `api.example.com`) works even if\n * the host framework's CORS middleware does not wrap the mounted sub-handler.\n *\n * @module\n */\n\n/** CORS configuration for the panel handler. */\nexport interface CorsOptions {\n /**\n * Allowed origin(s): a single origin (`\"https://app.example.com\"`), `\"*\"`, a\n * list, or a predicate `(origin) => boolean`. With `credentials: true`, `\"*\"`\n * is echoed back as the caller's exact origin (the browser forbids `*` +\n * credentials).\n */\n origin: string | string[] | ((origin: string) => boolean);\n /** Send `Access-Control-Allow-Credentials: true` (needed for cookie auth). Default `false`. */\n credentials?: boolean;\n /** Allowed methods advertised in preflight. Default `GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS`. */\n methods?: string[];\n /**\n * Allowed request headers advertised in preflight. Default: reflect the\n * request's `Access-Control-Request-Headers`, falling back to\n * `Content-Type, Authorization`.\n */\n headers?: string[];\n /** `Access-Control-Max-Age` (seconds) for the preflight cache. */\n maxAge?: number;\n}\n\nconst DEFAULT_METHODS = \"GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS\";\n\n/**\n * Resolve the value for `Access-Control-Allow-Origin` for this request, or\n * `null` when the origin is not allowed (no CORS headers → the browser blocks).\n */\nfunction resolveOrigin(cors: CorsOptions, requestOrigin: string | null): string | null {\n const { origin } = cors;\n if (origin === \"*\") {\n // `*` + credentials is invalid; echo the caller's origin instead.\n return cors.credentials ? (requestOrigin ?? null) : \"*\";\n }\n if (requestOrigin === null) return null;\n const allowed =\n typeof origin === \"string\"\n ? origin === requestOrigin\n : Array.isArray(origin)\n ? origin.includes(requestOrigin)\n : origin(requestOrigin);\n return allowed ? requestOrigin : null;\n}\n\n/**\n * `response` itself when its headers can be changed, else a copy that shares\n * its body (`Response.redirect()` and `fetch()` responses have immutable\n * headers).\n */\nfunction mutable(response: Response): Response {\n try {\n response.headers.set(\"x-xtandard-probe\", \"1\");\n response.headers.delete(\"x-xtandard-probe\");\n return response;\n } catch {\n return new Response(response.body, response);\n }\n}\n\n/** Attach `Access-Control-*` headers to `response` for an allowed cross-origin request. */\nexport function applyCorsHeaders(\n request: Request,\n response: Response,\n cors: CorsOptions,\n): Response {\n const requestOrigin = request.headers.get(\"origin\");\n const allowOrigin = resolveOrigin(cors, requestOrigin);\n if (allowOrigin === null) return response;\n response = mutable(response);\n response.headers.set(\"access-control-allow-origin\", allowOrigin);\n if (cors.credentials) response.headers.set(\"access-control-allow-credentials\", \"true\");\n // The response varies by Origin unless we blanket-allow `*` — tell caches.\n if (allowOrigin !== \"*\") response.headers.append(\"vary\", \"Origin\");\n return response;\n}\n\n/** Build the `204` response for a CORS preflight (`OPTIONS`). */\nexport function preflightResponse(request: Request, cors: CorsOptions): Response {\n const response = new Response(null, { status: 204 });\n applyCorsHeaders(request, response, cors);\n response.headers.set(\n \"access-control-allow-methods\",\n (cors.methods ?? []).join(\",\") || DEFAULT_METHODS,\n );\n const requestedHeaders = request.headers.get(\"access-control-request-headers\");\n response.headers.set(\n \"access-control-allow-headers\",\n cors.headers?.join(\",\") || requestedHeaders || \"Content-Type, Authorization\",\n );\n if (cors.maxAge !== undefined) {\n response.headers.set(\"access-control-max-age\", String(cors.maxAge));\n }\n return response;\n}\n","/**\n * Renders the SPA `index.html`: injects a `<base>` tag so relative asset URLs\n * resolve under any mount path, and a bootstrap `window.<globalName>` blob.\n * Falls back to a minimal built-in page when the UI bundle is absent (before\n * `bun run build:ui`, in headless tests, or on Workers without `node:fs`).\n *\n * Everything operator-controlled is escaped: the title (HTML), the `<base\n * href>` (attribute) and the bootstrap JSON (`<`, `>`, U+2028/U+2029, so it\n * can't close the `<script>` or break the line).\n *\n * @module\n */\n\n/** Bootstrap config injected into the page. Products add their own fields. */\nexport interface BootstrapConfig {\n title: string;\n basePath: string;\n [key: string]: unknown;\n}\n\n/** Options for {@link renderIndexHtml}. */\nexport interface RenderIndexHtmlOptions {\n /**\n * The global the SPA reads its bootstrap from, e.g. `\"__WEBHOOKS_CONFIG__\"`.\n * Must be a JavaScript identifier.\n */\n globalName: string;\n /** The bootstrap config (`title` and `basePath` are required). */\n config: BootstrapConfig;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst escapeJson = (value: unknown): string =>\n JSON.stringify(value)\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\")\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n\nconst escapeHtml = (s: string): string => s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n\n/** Build the `<base href>` value (always ends in `/`). */\nfunction baseHref(basePath: string): string {\n return basePath === \"\" ? \"/\" : `${basePath}/`;\n}\n\nfunction headTags(options: RenderIndexHtmlOptions): string {\n return (\n `<base href=\"${escapeHtml(baseHref(options.config.basePath))}\">` +\n `<script>window.${options.globalName}=${escapeJson(options.config)}</script>`\n );\n}\n\nfunction injectInto(html: string, options: RenderIndexHtmlOptions): string {\n const tags = headTags(options);\n if (html.includes(\"<head>\")) return html.replace(\"<head>\", () => `<head>${tags}`);\n return tags + html;\n}\n\n/** Minimal page served when no built UI is present. */\nfunction fallbackHtml(options: RenderIndexHtmlOptions): string {\n const title = escapeHtml(String(options.config.title));\n const code = \"background:#1a1a1a;padding:2px 6px;border-radius:4px\";\n return `<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">${headTags(\n options,\n )}<title>${title}</title></head><body style=\"font-family:system-ui;margin:0;padding:3rem;background:#0a0a0a;color:#e5e5e5\"><h1 style=\"margin:0 0 .5rem\">${title}</h1><p style=\"color:#a3a3a3\">The admin UI bundle is not built. Run <code style=\"${code}\">bun run build:ui</code>. The JSON API at <code style=\"${code}\">api/</code> is fully available (<a style=\"color:#2dd4bf\" href=\"api/openapi.json\">OpenAPI</a>).</p></body></html>`;\n}\n\n/**\n * Read, inject into, and return the SPA index HTML from `uiDir`, or the\n * fallback page when `uiDir` is `undefined` or has no `index.html`.\n *\n * @example\n * ```ts\n * const html = await renderIndexHtml(uiDir, {\n * globalName: \"__WEBHOOKS_CONFIG__\",\n * config: { title, basePath, readonly },\n * });\n * ```\n */\nexport async function renderIndexHtml(\n uiDir: string | undefined,\n options: RenderIndexHtmlOptions,\n): Promise<string> {\n if (!IDENTIFIER.test(options.globalName)) {\n throw new TypeError(\n `renderIndexHtml: globalName must be an identifier, got \"${options.globalName}\"`,\n );\n }\n if (uiDir === undefined) return fallbackHtml(options);\n try {\n const [{ readFile }, { join }] = await Promise.all([\n import(\"node:fs/promises\"),\n import(\"node:path\"),\n ]);\n const html = await readFile(join(uiDir, \"index.html\"), \"utf8\");\n return injectInto(html, options);\n } catch {\n return fallbackHtml(options);\n }\n}\n","/**\n * Serves the bundled SPA's static assets from the UI output directory. Maps file\n * extensions to content types and guards against path traversal.\n *\n * `node:fs` / `node:path` are imported lazily, only when an asset is actually\n * served, so a runtime without them (Cloudflare Workers without\n * `nodejs_compat`) can still import the panel and serve the API — it just\n * passes no `uiDir`.\n *\n * @module\n */\n\nconst CONTENT_TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".ico\": \"image/x-icon\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".map\": \"application/json; charset=utf-8\",\n \".txt\": \"text/plain; charset=utf-8\",\n};\n\nfunction contentType(path: string): string {\n const dot = path.lastIndexOf(\".\");\n const ext = dot >= 0 ? path.slice(dot).toLowerCase() : \"\";\n return CONTENT_TYPES[ext] ?? \"application/octet-stream\";\n}\n\n/** True if the path has a file extension (so a miss should 404 rather than fall through to the SPA). */\nexport function looksLikeAsset(path: string): boolean {\n const last = path.split(\"/\").pop() ?? \"\";\n return last.includes(\".\");\n}\n\n/**\n * Try to serve `path` (base-path-stripped, leading `/`) as a static file from\n * `uiDir`. Returns a `Response`, or `null` if the file does not exist or the\n * path escapes `uiDir`. Files under `assets/` (content-hashed by the bundler)\n * are cached for a year; everything else is `no-cache`.\n */\nexport async function serveStaticAsset(uiDir: string, path: string): Promise<Response | null> {\n const [{ readFile }, { join, normalize, resolve, sep }] = await Promise.all([\n import(\"node:fs/promises\"),\n import(\"node:path\"),\n ]);\n // Resolve within uiDir and refuse anything that escapes it (including sibling\n // directories that merely share the prefix, e.g. `ui-private`).\n const rel = normalize(path).replace(/^(\\.\\.(\\/|\\\\|$))+/, \"\");\n const root = resolve(uiDir);\n const full = resolve(join(root, rel));\n if (full !== root && !full.startsWith(root + sep)) return null;\n try {\n const data = await readFile(full);\n return new Response(new Uint8Array(data), {\n status: 200,\n headers: {\n \"content-type\": contentType(full),\n \"cache-control\": rel.includes(\"/assets/\")\n ? \"public, max-age=31536000, immutable\"\n : \"no-cache\",\n },\n });\n } catch {\n return null;\n }\n}\n\n/**\n * Locate a product's built SPA. Pass the product module's `import.meta.url`:\n * compiled (the npm-consumer case) the bundle is the sibling `./ui` of the\n * module's `dist/` chunk; run from TypeScript source (examples, `file:`\n * links) it is `<repo>/dist/ui`. Falls back to the compiled-layout path so the\n * \"build the UI\" hint still fires when nothing is built yet.\n *\n * Extra `candidates` (relative to `moduleUrl`) are tried first. Returns\n * `undefined` when the module URL is not a `file:` URL or the runtime has no\n * `node:fs` (Workers): the panel then serves the API and a fallback page.\n *\n * @example\n * ```ts\n * const uiDir = options.uiDir ?? resolveUiDir(import.meta.url);\n * ```\n */\nexport function resolveUiDir(\n moduleUrl: string | URL,\n candidates: readonly string[] = [],\n): string | undefined {\n const fs = getBuiltin<{ existsSync(path: string): boolean }>(\"node:fs\");\n const url = getBuiltin<{ fileURLToPath(url: URL): string }>(\"node:url\");\n if (!fs || !url) return undefined;\n try {\n const paths = [...candidates, \"./ui\", \"../../dist/ui\"].map((c) =>\n url.fileURLToPath(new URL(c, moduleUrl)),\n );\n return paths.find((p) => fs.existsSync(p)) ?? paths[candidates.length];\n } catch {\n return undefined;\n }\n}\n\n/** A Node built-in, synchronously, when the runtime has it (Node ≥ 20.16, Bun, Deno). */\nfunction getBuiltin<T>(name: string): T | undefined {\n const proc = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } }).process;\n return proc?.getBuiltinModule?.(name) as T | undefined;\n}\n","/**\n * The panel handler skeleton every product wraps in its `createFetchHandler`:\n * one web-standard `(request) => Promise<Response>` that serves the\n * healthcheck, the product's JSON API, the OpenAPI document, the bundled SPA's\n * static assets and the SPA fallback, under any base path, with optional\n * CORS, plus a uniform `close()` that stops background tasks.\n *\n * Request flow:\n *\n * 1. `OPTIONS` with `cors` set → preflight `204`.\n * 2. `GET|HEAD /healthcheck` → `{ ok: true }`.\n * 3. The product's `api(request, path)`; a non-`null` response wins.\n * 4. `GET|HEAD /api/openapi.json` (and `/openapi.json`) when `openapi` is set.\n * 5. Any other method → `405` (`Allow: GET, HEAD`).\n * 6. A static asset from `uiDir`; a miss on an asset-looking path → `404`.\n * 7. The SPA `index.html` with the bootstrap injected, `cache-control: no-cache`.\n *\n * @module\n */\n\nimport { durationToMs, type Duration } from \"../util/duration.ts\";\nimport { normalizeBasePath, stripBasePath } from \"./base-path.ts\";\nimport { applyCorsHeaders, preflightResponse, type CorsOptions } from \"./cors.ts\";\nimport { json } from \"./http.ts\";\nimport { renderIndexHtml } from \"./render-index-html.ts\";\nimport { looksLikeAsset, serveStaticAsset } from \"./static-assets.ts\";\n\n/** Background work owned by a panel (a dispatcher, a sweep timer…). */\nexport interface PanelTask {\n /** Called once when the panel is created. */\n start?(): void;\n /** Called once by `close()`. */\n stop(): void | Promise<void>;\n}\n\n/** Options for {@link createPanelHandler}. */\nexport interface PanelOptions {\n /** Mount prefix, e.g. `\"/webhooks\"`. Default `\"\"` (root). */\n basePath?: string;\n /** UI title, in the page and the bootstrap. */\n title: string;\n /** Logo image URL shown in the navbar in place of the title wordmark. */\n logoUrl?: string;\n /** Reported to the SPA in the bootstrap. Default `false`. */\n readonly?: boolean;\n /**\n * The built SPA directory (see `resolveUiDir`). `undefined` serves no static\n * files and the fallback page (e.g. on Workers).\n */\n uiDir?: string | undefined;\n /** Answer CORS preflights and decorate every response. */\n cors?: CorsOptions;\n /**\n * The product's API router. Receives the base-path-stripped path; returns a\n * response, or `null` when the path is not an API route.\n */\n api?: (request: Request, path: string) => Promise<Response | null> | Response | null;\n /** Extra bootstrap fields injected into `index.html` (beside `title`, `basePath`, `readonly`, `logoUrl`). */\n bootstrap?: () => Record<string, unknown>;\n /** The global the SPA reads its bootstrap from, e.g. `\"__WEBHOOKS_CONFIG__\"`. */\n globalName: string;\n /** The OpenAPI document, served at `/api/openapi.json` and `/openapi.json` (public). */\n openapi?: () => Record<string, unknown>;\n /** Background tasks: started now, stopped by `close()`. */\n tasks?: readonly PanelTask[];\n /** Healthcheck path, or `false` to leave it to the product. Default `\"/healthcheck\"`. */\n healthcheck?: string | false;\n}\n\n/** What {@link createPanelHandler} returns. */\nexport interface PanelHandler {\n /** Web-standard request handler. */\n fetch(request: Request): Promise<Response>;\n /** The normalized base path. */\n readonly basePath: string;\n /** Stop every task (idempotent). */\n close(): Promise<void>;\n}\n\nconst OPENAPI_PATHS = new Set([\"/api/openapi.json\", \"/openapi.json\"]);\n\n/**\n * Build the panel handler.\n *\n * @example\n * ```ts\n * import { createPanelHandler, resolveUiDir } from \"@xtandard/kit/server\";\n *\n * const panel = createPanelHandler({\n * basePath: options.basePath,\n * title: options.title ?? \"@xtandard/webhooks\",\n * globalName: \"__WEBHOOKS_CONFIG__\",\n * uiDir: options.uiDir ?? resolveUiDir(import.meta.url),\n * api: (request, path) => handleApiRequest(request, path, ctx),\n * openapi: () => buildOpenApiDocument({ basePath, title }),\n * tasks: [dispatcherTask],\n * });\n * Bun.serve({ fetch: panel.fetch });\n * ```\n */\nexport function createPanelHandler(options: PanelOptions): PanelHandler {\n const basePath = normalizeBasePath(options.basePath);\n const { cors, uiDir } = options;\n const healthcheck = options.healthcheck ?? \"/healthcheck\";\n const tasks = [...(options.tasks ?? [])];\n for (const task of tasks) task.start?.();\n let closing: Promise<void> | undefined;\n\n async function fetch(request: Request): Promise<Response> {\n // CORS preflight: answer OPTIONS directly so it works for any path,\n // independent of the host framework wrapping this handler.\n if (cors && request.method === \"OPTIONS\") return preflightResponse(request, cors);\n const response = await respond(request);\n return cors ? applyCorsHeaders(request, response, cors) : response;\n }\n\n async function respond(request: Request): Promise<Response> {\n const path = stripBasePath(new URL(request.url).pathname, basePath);\n const read = request.method === \"GET\" || request.method === \"HEAD\";\n\n if (read && healthcheck !== false && path === healthcheck) return json({ ok: true });\n\n const api = options.api ? await options.api(request, path) : null;\n if (api) return api;\n\n if (read && options.openapi && OPENAPI_PATHS.has(path)) return json(options.openapi());\n\n if (!read) {\n return new Response(\"Method Not Allowed\", { status: 405, headers: { allow: \"GET, HEAD\" } });\n }\n\n if (uiDir !== undefined) {\n const asset = await serveStaticAsset(uiDir, path);\n if (asset) return asset;\n }\n // A path that looks like a file but was not found → 404 (don't mask it with the SPA).\n if (path !== \"/\" && looksLikeAsset(path)) return new Response(\"Not Found\", { status: 404 });\n\n const html = await renderIndexHtml(uiDir, {\n globalName: options.globalName,\n config: {\n title: options.title,\n basePath,\n readonly: options.readonly ?? false,\n ...(options.logoUrl !== undefined ? { logoUrl: options.logoUrl } : {}),\n ...options.bootstrap?.(),\n },\n });\n return new Response(html, {\n status: 200,\n headers: { \"content-type\": \"text/html; charset=utf-8\", \"cache-control\": \"no-cache\" },\n });\n }\n\n return {\n fetch,\n basePath,\n close() {\n closing ??= Promise.all(tasks.map(async (task) => task.stop())).then(() => undefined);\n return closing;\n },\n };\n}\n\n/** Options for {@link intervalTask}. */\nexport interface IntervalTaskOptions {\n /** Reports a rejected run. Default: `console.warn` with `[source]`. */\n onError?: (error: unknown) => void;\n /** Log prefix for the default `onError`. Default `\"@xtandard/kit\"`. */\n source?: string;\n}\n\n/**\n * A {@link PanelTask} that runs `run` every `every` (a `Duration`). The timer\n * is `unref()`ed so it never keeps the process alive; a run that rejects is\n * reported, never thrown. `every <= 0` makes a task that does nothing.\n *\n * @example\n * ```ts\n * tasks: [intervalTask(\"1m\", () => engine.sweep(), { source: \"@xtandard/entitlements\" })]\n * ```\n */\nexport function intervalTask(\n every: Duration,\n run: () => unknown,\n options: IntervalTaskOptions = {},\n): PanelTask {\n const ms = durationToMs(every);\n const onError =\n options.onError ??\n ((error: unknown) =>\n console.warn(`[${options.source ?? \"@xtandard/kit\"}] task failed:`, error));\n let timer: ReturnType<typeof setInterval> | undefined;\n return {\n start() {\n if (ms <= 0 || timer) return;\n timer = setInterval(() => {\n Promise.resolve()\n .then(run)\n .catch((error: unknown) => onError(error));\n }, ms);\n (timer as { unref?: () => void }).unref?.();\n },\n stop() {\n if (timer) clearInterval(timer);\n timer = undefined;\n },\n };\n}\n"],"mappings":";;;;;AAiCA,MAAM,kBAAkB;;;;;AAMxB,SAAS,cAAc,MAAmB,eAA6C;CACrF,MAAM,EAAE,WAAW;CACnB,IAAI,WAAW,KAEb,OAAO,KAAK,cAAe,iBAAiB,OAAQ;CAEtD,IAAI,kBAAkB,MAAM,OAAO;CAOnC,QALE,OAAO,WAAW,WACd,WAAW,gBACX,MAAM,QAAQ,MAAM,IAClB,OA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ErrorMapping, c as JSON_CONTENT_TYPE, d as authorize, f as error, g as match, h as mapError, i as ErrorMap, l as ScopedAuth, m as json, n as Authenticated, o as HttpError, p as intParam, r as AuthorizeOptions, s as IntParamOptions, t as AuthenticateOptions, u as authenticate, v as noContent, y as requireOneOf } from "./http-XBVRk8uo.cjs";
2
+ import { t as Duration } from "./duration-FPwbmWIU.cjs";
3
+
4
+ //#region src/server/base-path.d.ts
5
+ /**
6
+ * Base-path helpers. The panel can be mounted under any prefix (`/webhooks`,
7
+ * `/admin/webhooks`, ...). These normalize the configured base path and strip it
8
+ * from incoming request paths so routing is prefix-agnostic.
9
+ *
10
+ * @module
11
+ */
12
+ /** Normalize a base path to either `""` (root) or `/segment` with no trailing slash. */
13
+ declare function normalizeBasePath(basePath: string | undefined): string;
14
+ /**
15
+ * Strip the (normalized) base path from a pathname. Returns a path that always
16
+ * starts with `/`. If the pathname does not start with the base path it is
17
+ * returned unchanged (the host framework may already have stripped the mount).
18
+ */
19
+ declare function stripBasePath(pathname: string, basePath: string): string;
20
+ //#endregion
21
+ //#region src/server/cors.d.ts
22
+ /**
23
+ * Framework-independent CORS for the mounted panel. When the panel handler is
24
+ * given a `cors` option, it answers `OPTIONS` preflights itself and attaches
25
+ * `Access-Control-*` headers to every response — so a **cross-origin embed**
26
+ * (a widget on `app.example.com`, the panel on `api.example.com`) works even if
27
+ * the host framework's CORS middleware does not wrap the mounted sub-handler.
28
+ *
29
+ * @module
30
+ */
31
+ /** CORS configuration for the panel handler. */
32
+ interface CorsOptions {
33
+ /**
34
+ * Allowed origin(s): a single origin (`"https://app.example.com"`), `"*"`, a
35
+ * list, or a predicate `(origin) => boolean`. With `credentials: true`, `"*"`
36
+ * is echoed back as the caller's exact origin (the browser forbids `*` +
37
+ * credentials).
38
+ */
39
+ origin: string | string[] | ((origin: string) => boolean);
40
+ /** Send `Access-Control-Allow-Credentials: true` (needed for cookie auth). Default `false`. */
41
+ credentials?: boolean;
42
+ /** Allowed methods advertised in preflight. Default `GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS`. */
43
+ methods?: string[];
44
+ /**
45
+ * Allowed request headers advertised in preflight. Default: reflect the
46
+ * request's `Access-Control-Request-Headers`, falling back to
47
+ * `Content-Type, Authorization`.
48
+ */
49
+ headers?: string[];
50
+ /** `Access-Control-Max-Age` (seconds) for the preflight cache. */
51
+ maxAge?: number;
52
+ }
53
+ /** Attach `Access-Control-*` headers to `response` for an allowed cross-origin request. */
54
+ declare function applyCorsHeaders(request: Request, response: Response, cors: CorsOptions): Response;
55
+ /** Build the `204` response for a CORS preflight (`OPTIONS`). */
56
+ declare function preflightResponse(request: Request, cors: CorsOptions): Response;
57
+ //#endregion
58
+ //#region src/server/panel.d.ts
59
+ /** Background work owned by a panel (a dispatcher, a sweep timer…). */
60
+ interface PanelTask {
61
+ /** Called once when the panel is created. */
62
+ start?(): void;
63
+ /** Called once by `close()`. */
64
+ stop(): void | Promise<void>;
65
+ }
66
+ /** Options for {@link createPanelHandler}. */
67
+ interface PanelOptions {
68
+ /** Mount prefix, e.g. `"/webhooks"`. Default `""` (root). */
69
+ basePath?: string;
70
+ /** UI title, in the page and the bootstrap. */
71
+ title: string;
72
+ /** Logo image URL shown in the navbar in place of the title wordmark. */
73
+ logoUrl?: string;
74
+ /** Reported to the SPA in the bootstrap. Default `false`. */
75
+ readonly?: boolean;
76
+ /**
77
+ * The built SPA directory (see `resolveUiDir`). `undefined` serves no static
78
+ * files and the fallback page (e.g. on Workers).
79
+ */
80
+ uiDir?: string | undefined;
81
+ /** Answer CORS preflights and decorate every response. */
82
+ cors?: CorsOptions;
83
+ /**
84
+ * The product's API router. Receives the base-path-stripped path; returns a
85
+ * response, or `null` when the path is not an API route.
86
+ */
87
+ api?: (request: Request, path: string) => Promise<Response | null> | Response | null;
88
+ /** Extra bootstrap fields injected into `index.html` (beside `title`, `basePath`, `readonly`, `logoUrl`). */
89
+ bootstrap?: () => Record<string, unknown>;
90
+ /** The global the SPA reads its bootstrap from, e.g. `"__WEBHOOKS_CONFIG__"`. */
91
+ globalName: string;
92
+ /** The OpenAPI document, served at `/api/openapi.json` and `/openapi.json` (public). */
93
+ openapi?: () => Record<string, unknown>;
94
+ /** Background tasks: started now, stopped by `close()`. */
95
+ tasks?: readonly PanelTask[];
96
+ /** Healthcheck path, or `false` to leave it to the product. Default `"/healthcheck"`. */
97
+ healthcheck?: string | false;
98
+ }
99
+ /** What {@link createPanelHandler} returns. */
100
+ interface PanelHandler {
101
+ /** Web-standard request handler. */
102
+ fetch(request: Request): Promise<Response>;
103
+ /** The normalized base path. */
104
+ readonly basePath: string;
105
+ /** Stop every task (idempotent). */
106
+ close(): Promise<void>;
107
+ }
108
+ /**
109
+ * Build the panel handler.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { createPanelHandler, resolveUiDir } from "@xtandard/kit/server";
114
+ *
115
+ * const panel = createPanelHandler({
116
+ * basePath: options.basePath,
117
+ * title: options.title ?? "@xtandard/webhooks",
118
+ * globalName: "__WEBHOOKS_CONFIG__",
119
+ * uiDir: options.uiDir ?? resolveUiDir(import.meta.url),
120
+ * api: (request, path) => handleApiRequest(request, path, ctx),
121
+ * openapi: () => buildOpenApiDocument({ basePath, title }),
122
+ * tasks: [dispatcherTask],
123
+ * });
124
+ * Bun.serve({ fetch: panel.fetch });
125
+ * ```
126
+ */
127
+ declare function createPanelHandler(options: PanelOptions): PanelHandler;
128
+ /** Options for {@link intervalTask}. */
129
+ interface IntervalTaskOptions {
130
+ /** Reports a rejected run. Default: `console.warn` with `[source]`. */
131
+ onError?: (error: unknown) => void;
132
+ /** Log prefix for the default `onError`. Default `"@xtandard/kit"`. */
133
+ source?: string;
134
+ }
135
+ /**
136
+ * A {@link PanelTask} that runs `run` every `every` (a `Duration`). The timer
137
+ * is `unref()`ed so it never keeps the process alive; a run that rejects is
138
+ * reported, never thrown. `every <= 0` makes a task that does nothing.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * tasks: [intervalTask("1m", () => engine.sweep(), { source: "@xtandard/entitlements" })]
143
+ * ```
144
+ */
145
+ declare function intervalTask(every: Duration, run: () => unknown, options?: IntervalTaskOptions): PanelTask;
146
+ //#endregion
147
+ //#region src/server/render-index-html.d.ts
148
+ /**
149
+ * Renders the SPA `index.html`: injects a `<base>` tag so relative asset URLs
150
+ * resolve under any mount path, and a bootstrap `window.<globalName>` blob.
151
+ * Falls back to a minimal built-in page when the UI bundle is absent (before
152
+ * `bun run build:ui`, in headless tests, or on Workers without `node:fs`).
153
+ *
154
+ * Everything operator-controlled is escaped: the title (HTML), the `<base
155
+ * href>` (attribute) and the bootstrap JSON (`<`, `>`, U+2028/U+2029, so it
156
+ * can't close the `<script>` or break the line).
157
+ *
158
+ * @module
159
+ */
160
+ /** Bootstrap config injected into the page. Products add their own fields. */
161
+ interface BootstrapConfig {
162
+ title: string;
163
+ basePath: string;
164
+ [key: string]: unknown;
165
+ }
166
+ /** Options for {@link renderIndexHtml}. */
167
+ interface RenderIndexHtmlOptions {
168
+ /**
169
+ * The global the SPA reads its bootstrap from, e.g. `"__WEBHOOKS_CONFIG__"`.
170
+ * Must be a JavaScript identifier.
171
+ */
172
+ globalName: string;
173
+ /** The bootstrap config (`title` and `basePath` are required). */
174
+ config: BootstrapConfig;
175
+ }
176
+ /**
177
+ * Read, inject into, and return the SPA index HTML from `uiDir`, or the
178
+ * fallback page when `uiDir` is `undefined` or has no `index.html`.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const html = await renderIndexHtml(uiDir, {
183
+ * globalName: "__WEBHOOKS_CONFIG__",
184
+ * config: { title, basePath, readonly },
185
+ * });
186
+ * ```
187
+ */
188
+ declare function renderIndexHtml(uiDir: string | undefined, options: RenderIndexHtmlOptions): Promise<string>;
189
+ //#endregion
190
+ //#region src/server/static-assets.d.ts
191
+ /**
192
+ * Serves the bundled SPA's static assets from the UI output directory. Maps file
193
+ * extensions to content types and guards against path traversal.
194
+ *
195
+ * `node:fs` / `node:path` are imported lazily, only when an asset is actually
196
+ * served, so a runtime without them (Cloudflare Workers without
197
+ * `nodejs_compat`) can still import the panel and serve the API — it just
198
+ * passes no `uiDir`.
199
+ *
200
+ * @module
201
+ */
202
+ /** True if the path has a file extension (so a miss should 404 rather than fall through to the SPA). */
203
+ declare function looksLikeAsset(path: string): boolean;
204
+ /**
205
+ * Try to serve `path` (base-path-stripped, leading `/`) as a static file from
206
+ * `uiDir`. Returns a `Response`, or `null` if the file does not exist or the
207
+ * path escapes `uiDir`. Files under `assets/` (content-hashed by the bundler)
208
+ * are cached for a year; everything else is `no-cache`.
209
+ */
210
+ declare function serveStaticAsset(uiDir: string, path: string): Promise<Response | null>;
211
+ /**
212
+ * Locate a product's built SPA. Pass the product module's `import.meta.url`:
213
+ * compiled (the npm-consumer case) the bundle is the sibling `./ui` of the
214
+ * module's `dist/` chunk; run from TypeScript source (examples, `file:`
215
+ * links) it is `<repo>/dist/ui`. Falls back to the compiled-layout path so the
216
+ * "build the UI" hint still fires when nothing is built yet.
217
+ *
218
+ * Extra `candidates` (relative to `moduleUrl`) are tried first. Returns
219
+ * `undefined` when the module URL is not a `file:` URL or the runtime has no
220
+ * `node:fs` (Workers): the panel then serves the API and a fallback page.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * const uiDir = options.uiDir ?? resolveUiDir(import.meta.url);
225
+ * ```
226
+ */
227
+ declare function resolveUiDir(moduleUrl: string | URL, candidates?: readonly string[]): string | undefined;
228
+ //#endregion
229
+ export { type AuthenticateOptions, type Authenticated, type AuthorizeOptions, type BootstrapConfig, type CorsOptions, type ErrorMap, type ErrorMapping, HttpError, type IntParamOptions, type IntervalTaskOptions, JSON_CONTENT_TYPE, type PanelHandler, type PanelOptions, type PanelTask, type RenderIndexHtmlOptions, type ScopedAuth, applyCorsHeaders, authenticate, authorize, createPanelHandler, error, intParam, intervalTask, json, looksLikeAsset, mapError, match, methodNotAllowed, noContent, normalizeBasePath, preflightResponse, renderIndexHtml, requireOneOf, resolveUiDir, serveStaticAsset, stripBasePath };
230
+ //# sourceMappingURL=entry-server.d.cts.map
@@ -0,0 +1,230 @@
1
+ import { _ as methodNotAllowed, a as ErrorMapping, c as JSON_CONTENT_TYPE, d as authorize, f as error, g as match, h as mapError, i as ErrorMap, l as ScopedAuth, m as json, n as Authenticated, o as HttpError, p as intParam, r as AuthorizeOptions, s as IntParamOptions, t as AuthenticateOptions, u as authenticate, v as noContent, y as requireOneOf } from "./http-CxYM7kPT.mjs";
2
+ import { t as Duration } from "./duration-FPwbmWIU.mjs";
3
+
4
+ //#region src/server/base-path.d.ts
5
+ /**
6
+ * Base-path helpers. The panel can be mounted under any prefix (`/webhooks`,
7
+ * `/admin/webhooks`, ...). These normalize the configured base path and strip it
8
+ * from incoming request paths so routing is prefix-agnostic.
9
+ *
10
+ * @module
11
+ */
12
+ /** Normalize a base path to either `""` (root) or `/segment` with no trailing slash. */
13
+ declare function normalizeBasePath(basePath: string | undefined): string;
14
+ /**
15
+ * Strip the (normalized) base path from a pathname. Returns a path that always
16
+ * starts with `/`. If the pathname does not start with the base path it is
17
+ * returned unchanged (the host framework may already have stripped the mount).
18
+ */
19
+ declare function stripBasePath(pathname: string, basePath: string): string;
20
+ //#endregion
21
+ //#region src/server/cors.d.ts
22
+ /**
23
+ * Framework-independent CORS for the mounted panel. When the panel handler is
24
+ * given a `cors` option, it answers `OPTIONS` preflights itself and attaches
25
+ * `Access-Control-*` headers to every response — so a **cross-origin embed**
26
+ * (a widget on `app.example.com`, the panel on `api.example.com`) works even if
27
+ * the host framework's CORS middleware does not wrap the mounted sub-handler.
28
+ *
29
+ * @module
30
+ */
31
+ /** CORS configuration for the panel handler. */
32
+ interface CorsOptions {
33
+ /**
34
+ * Allowed origin(s): a single origin (`"https://app.example.com"`), `"*"`, a
35
+ * list, or a predicate `(origin) => boolean`. With `credentials: true`, `"*"`
36
+ * is echoed back as the caller's exact origin (the browser forbids `*` +
37
+ * credentials).
38
+ */
39
+ origin: string | string[] | ((origin: string) => boolean);
40
+ /** Send `Access-Control-Allow-Credentials: true` (needed for cookie auth). Default `false`. */
41
+ credentials?: boolean;
42
+ /** Allowed methods advertised in preflight. Default `GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS`. */
43
+ methods?: string[];
44
+ /**
45
+ * Allowed request headers advertised in preflight. Default: reflect the
46
+ * request's `Access-Control-Request-Headers`, falling back to
47
+ * `Content-Type, Authorization`.
48
+ */
49
+ headers?: string[];
50
+ /** `Access-Control-Max-Age` (seconds) for the preflight cache. */
51
+ maxAge?: number;
52
+ }
53
+ /** Attach `Access-Control-*` headers to `response` for an allowed cross-origin request. */
54
+ declare function applyCorsHeaders(request: Request, response: Response, cors: CorsOptions): Response;
55
+ /** Build the `204` response for a CORS preflight (`OPTIONS`). */
56
+ declare function preflightResponse(request: Request, cors: CorsOptions): Response;
57
+ //#endregion
58
+ //#region src/server/panel.d.ts
59
+ /** Background work owned by a panel (a dispatcher, a sweep timer…). */
60
+ interface PanelTask {
61
+ /** Called once when the panel is created. */
62
+ start?(): void;
63
+ /** Called once by `close()`. */
64
+ stop(): void | Promise<void>;
65
+ }
66
+ /** Options for {@link createPanelHandler}. */
67
+ interface PanelOptions {
68
+ /** Mount prefix, e.g. `"/webhooks"`. Default `""` (root). */
69
+ basePath?: string;
70
+ /** UI title, in the page and the bootstrap. */
71
+ title: string;
72
+ /** Logo image URL shown in the navbar in place of the title wordmark. */
73
+ logoUrl?: string;
74
+ /** Reported to the SPA in the bootstrap. Default `false`. */
75
+ readonly?: boolean;
76
+ /**
77
+ * The built SPA directory (see `resolveUiDir`). `undefined` serves no static
78
+ * files and the fallback page (e.g. on Workers).
79
+ */
80
+ uiDir?: string | undefined;
81
+ /** Answer CORS preflights and decorate every response. */
82
+ cors?: CorsOptions;
83
+ /**
84
+ * The product's API router. Receives the base-path-stripped path; returns a
85
+ * response, or `null` when the path is not an API route.
86
+ */
87
+ api?: (request: Request, path: string) => Promise<Response | null> | Response | null;
88
+ /** Extra bootstrap fields injected into `index.html` (beside `title`, `basePath`, `readonly`, `logoUrl`). */
89
+ bootstrap?: () => Record<string, unknown>;
90
+ /** The global the SPA reads its bootstrap from, e.g. `"__WEBHOOKS_CONFIG__"`. */
91
+ globalName: string;
92
+ /** The OpenAPI document, served at `/api/openapi.json` and `/openapi.json` (public). */
93
+ openapi?: () => Record<string, unknown>;
94
+ /** Background tasks: started now, stopped by `close()`. */
95
+ tasks?: readonly PanelTask[];
96
+ /** Healthcheck path, or `false` to leave it to the product. Default `"/healthcheck"`. */
97
+ healthcheck?: string | false;
98
+ }
99
+ /** What {@link createPanelHandler} returns. */
100
+ interface PanelHandler {
101
+ /** Web-standard request handler. */
102
+ fetch(request: Request): Promise<Response>;
103
+ /** The normalized base path. */
104
+ readonly basePath: string;
105
+ /** Stop every task (idempotent). */
106
+ close(): Promise<void>;
107
+ }
108
+ /**
109
+ * Build the panel handler.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { createPanelHandler, resolveUiDir } from "@xtandard/kit/server";
114
+ *
115
+ * const panel = createPanelHandler({
116
+ * basePath: options.basePath,
117
+ * title: options.title ?? "@xtandard/webhooks",
118
+ * globalName: "__WEBHOOKS_CONFIG__",
119
+ * uiDir: options.uiDir ?? resolveUiDir(import.meta.url),
120
+ * api: (request, path) => handleApiRequest(request, path, ctx),
121
+ * openapi: () => buildOpenApiDocument({ basePath, title }),
122
+ * tasks: [dispatcherTask],
123
+ * });
124
+ * Bun.serve({ fetch: panel.fetch });
125
+ * ```
126
+ */
127
+ declare function createPanelHandler(options: PanelOptions): PanelHandler;
128
+ /** Options for {@link intervalTask}. */
129
+ interface IntervalTaskOptions {
130
+ /** Reports a rejected run. Default: `console.warn` with `[source]`. */
131
+ onError?: (error: unknown) => void;
132
+ /** Log prefix for the default `onError`. Default `"@xtandard/kit"`. */
133
+ source?: string;
134
+ }
135
+ /**
136
+ * A {@link PanelTask} that runs `run` every `every` (a `Duration`). The timer
137
+ * is `unref()`ed so it never keeps the process alive; a run that rejects is
138
+ * reported, never thrown. `every <= 0` makes a task that does nothing.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * tasks: [intervalTask("1m", () => engine.sweep(), { source: "@xtandard/entitlements" })]
143
+ * ```
144
+ */
145
+ declare function intervalTask(every: Duration, run: () => unknown, options?: IntervalTaskOptions): PanelTask;
146
+ //#endregion
147
+ //#region src/server/render-index-html.d.ts
148
+ /**
149
+ * Renders the SPA `index.html`: injects a `<base>` tag so relative asset URLs
150
+ * resolve under any mount path, and a bootstrap `window.<globalName>` blob.
151
+ * Falls back to a minimal built-in page when the UI bundle is absent (before
152
+ * `bun run build:ui`, in headless tests, or on Workers without `node:fs`).
153
+ *
154
+ * Everything operator-controlled is escaped: the title (HTML), the `<base
155
+ * href>` (attribute) and the bootstrap JSON (`<`, `>`, U+2028/U+2029, so it
156
+ * can't close the `<script>` or break the line).
157
+ *
158
+ * @module
159
+ */
160
+ /** Bootstrap config injected into the page. Products add their own fields. */
161
+ interface BootstrapConfig {
162
+ title: string;
163
+ basePath: string;
164
+ [key: string]: unknown;
165
+ }
166
+ /** Options for {@link renderIndexHtml}. */
167
+ interface RenderIndexHtmlOptions {
168
+ /**
169
+ * The global the SPA reads its bootstrap from, e.g. `"__WEBHOOKS_CONFIG__"`.
170
+ * Must be a JavaScript identifier.
171
+ */
172
+ globalName: string;
173
+ /** The bootstrap config (`title` and `basePath` are required). */
174
+ config: BootstrapConfig;
175
+ }
176
+ /**
177
+ * Read, inject into, and return the SPA index HTML from `uiDir`, or the
178
+ * fallback page when `uiDir` is `undefined` or has no `index.html`.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const html = await renderIndexHtml(uiDir, {
183
+ * globalName: "__WEBHOOKS_CONFIG__",
184
+ * config: { title, basePath, readonly },
185
+ * });
186
+ * ```
187
+ */
188
+ declare function renderIndexHtml(uiDir: string | undefined, options: RenderIndexHtmlOptions): Promise<string>;
189
+ //#endregion
190
+ //#region src/server/static-assets.d.ts
191
+ /**
192
+ * Serves the bundled SPA's static assets from the UI output directory. Maps file
193
+ * extensions to content types and guards against path traversal.
194
+ *
195
+ * `node:fs` / `node:path` are imported lazily, only when an asset is actually
196
+ * served, so a runtime without them (Cloudflare Workers without
197
+ * `nodejs_compat`) can still import the panel and serve the API — it just
198
+ * passes no `uiDir`.
199
+ *
200
+ * @module
201
+ */
202
+ /** True if the path has a file extension (so a miss should 404 rather than fall through to the SPA). */
203
+ declare function looksLikeAsset(path: string): boolean;
204
+ /**
205
+ * Try to serve `path` (base-path-stripped, leading `/`) as a static file from
206
+ * `uiDir`. Returns a `Response`, or `null` if the file does not exist or the
207
+ * path escapes `uiDir`. Files under `assets/` (content-hashed by the bundler)
208
+ * are cached for a year; everything else is `no-cache`.
209
+ */
210
+ declare function serveStaticAsset(uiDir: string, path: string): Promise<Response | null>;
211
+ /**
212
+ * Locate a product's built SPA. Pass the product module's `import.meta.url`:
213
+ * compiled (the npm-consumer case) the bundle is the sibling `./ui` of the
214
+ * module's `dist/` chunk; run from TypeScript source (examples, `file:`
215
+ * links) it is `<repo>/dist/ui`. Falls back to the compiled-layout path so the
216
+ * "build the UI" hint still fires when nothing is built yet.
217
+ *
218
+ * Extra `candidates` (relative to `moduleUrl`) are tried first. Returns
219
+ * `undefined` when the module URL is not a `file:` URL or the runtime has no
220
+ * `node:fs` (Workers): the panel then serves the API and a fallback page.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * const uiDir = options.uiDir ?? resolveUiDir(import.meta.url);
225
+ * ```
226
+ */
227
+ declare function resolveUiDir(moduleUrl: string | URL, candidates?: readonly string[]): string | undefined;
228
+ //#endregion
229
+ export { type AuthenticateOptions, type Authenticated, type AuthorizeOptions, type BootstrapConfig, type CorsOptions, type ErrorMap, type ErrorMapping, HttpError, type IntParamOptions, type IntervalTaskOptions, JSON_CONTENT_TYPE, type PanelHandler, type PanelOptions, type PanelTask, type RenderIndexHtmlOptions, type ScopedAuth, applyCorsHeaders, authenticate, authorize, createPanelHandler, error, intParam, intervalTask, json, looksLikeAsset, mapError, match, methodNotAllowed, noContent, normalizeBasePath, preflightResponse, renderIndexHtml, requireOneOf, resolveUiDir, serveStaticAsset, stripBasePath };
230
+ //# sourceMappingURL=entry-server.d.mts.map