@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,315 @@
1
+ const require_peer = require("./peer-BIjBFzwQ.cjs");
2
+ let node_fs_promises = require("node:fs/promises");
3
+ let node_fs = require("node:fs");
4
+ let node_path = require("node:path");
5
+ let node_url = require("node:url");
6
+ //#region src/build/api-surface.ts
7
+ /**
8
+ * API-surface snapshots (ADR 0003). For every `exports` subpath of a built package,
9
+ * {@link apiSurface} records the runtime export names (by importing the ESM entry) and the exported
10
+ * declaration names (from its `.d.mts`, through the TypeScript compiler API). {@link diffApiSurface}
11
+ * compares two snapshots; a migration PR, or a kit patch, must show no removals.
12
+ *
13
+ * Needs the optional peer `typescript` for the declaration names.
14
+ *
15
+ * @module
16
+ */
17
+ function pick(value, keys) {
18
+ if (value === void 0 || value === null) return void 0;
19
+ if (typeof value === "string") return value;
20
+ if (Array.isArray(value)) {
21
+ for (const v of value) {
22
+ const hit = pick(v, keys);
23
+ if (hit) return hit;
24
+ }
25
+ return;
26
+ }
27
+ for (const key of keys) {
28
+ const hit = pick(value[key], keys);
29
+ if (hit) return hit;
30
+ }
31
+ }
32
+ /**
33
+ * Resolve an `exports` value to its ESM runtime file and declaration file (paths as written in
34
+ * `package.json`). `.d.mts` is derived from an `.mjs` target when no `types` condition is given.
35
+ */
36
+ function exportTarget(value) {
37
+ const importSide = value && typeof value === "object" && !Array.isArray(value) && "import" in value ? value.import : value;
38
+ const runtime = pick(importSide ?? null, ["node", "default"]);
39
+ const conditionTypes = (v) => v && typeof v === "object" && !Array.isArray(v) ? pick(v.types ?? null, ["default"]) : void 0;
40
+ let types = conditionTypes(importSide) ?? conditionTypes(value);
41
+ if (!types && runtime) types = runtime.replace(/\.m?js$/, (ext) => ext === ".mjs" ? ".d.mts" : ".d.ts");
42
+ const isCode = (p) => p && /\.[cm]?[jt]s$/.test(p) ? p : void 0;
43
+ return {
44
+ runtime: isCode(runtime),
45
+ types: types && /\.d\.[cm]?ts$/.test(types) ? types : void 0
46
+ };
47
+ }
48
+ /** Locate the package root: `dir` itself, or its parent when `dir` is the `dist/` folder. */
49
+ function packageRoot(dir) {
50
+ const abs = (0, node_path.resolve)(dir);
51
+ if ((0, node_fs.existsSync)((0, node_path.join)(abs, "package.json"))) return abs;
52
+ if ((0, node_fs.existsSync)((0, node_path.join)((0, node_path.dirname)(abs), "package.json"))) return (0, node_path.dirname)(abs);
53
+ throw new Error(`api-surface: no package.json in ${abs} or its parent`);
54
+ }
55
+ async function declarationNames(files) {
56
+ const out = /* @__PURE__ */ new Map();
57
+ if (files.length === 0) return out;
58
+ const ts = await require_peer.importPeer("typescript", "@xtandard/kit/build", async () => {
59
+ const mod = await import("typescript");
60
+ return mod.default ?? mod;
61
+ });
62
+ const program = ts.createProgram(files, {
63
+ noEmit: true,
64
+ skipLibCheck: true,
65
+ allowJs: false,
66
+ types: [],
67
+ module: ts.ModuleKind.ESNext,
68
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
69
+ target: ts.ScriptTarget.ESNext
70
+ });
71
+ const checker = program.getTypeChecker();
72
+ for (const file of files) {
73
+ const source = program.getSourceFile(file);
74
+ const symbol = source && checker.getSymbolAtLocation(source);
75
+ out.set(file, symbol ? checker.getExportsOfModule(symbol).map((s) => s.getName()).sort() : []);
76
+ }
77
+ return out;
78
+ }
79
+ /**
80
+ * Snapshot the API surface of the built package at `dir` (the package root, or its `dist/`).
81
+ * Wildcard, CSS, JSON and `./package.json` exports are skipped.
82
+ */
83
+ async function apiSurface(dir) {
84
+ const root = packageRoot(dir);
85
+ const pkg = JSON.parse(await (0, node_fs_promises.readFile)((0, node_path.join)(root, "package.json"), "utf8"));
86
+ const exportsField = pkg.exports && typeof pkg.exports === "object" && !Array.isArray(pkg.exports) ? Object.keys(pkg.exports).every((k) => k.startsWith(".")) ? pkg.exports : { ".": pkg.exports } : pkg.exports ? { ".": pkg.exports } : {};
87
+ const targets = [];
88
+ for (const [subpath, value] of Object.entries(exportsField)) {
89
+ if (subpath.includes("*") || subpath === "./package.json") continue;
90
+ const target = exportTarget(value);
91
+ if (target.runtime || target.types) targets.push([subpath, target]);
92
+ }
93
+ const names = await declarationNames(targets.map(([, t]) => t.types && (0, node_path.join)(root, t.types)).filter((f) => Boolean(f && (0, node_fs.existsSync)(f))));
94
+ const subpaths = {};
95
+ for (const [subpath, target] of targets) {
96
+ const surface = {
97
+ runtime: [],
98
+ types: []
99
+ };
100
+ const errors = [];
101
+ if (target.runtime) try {
102
+ const mod = await import(`${(0, node_url.pathToFileURL)((0, node_path.join)(root, target.runtime)).href}?surface=${Date.now()}`);
103
+ surface.runtime = Object.keys(mod).sort();
104
+ } catch (error) {
105
+ errors.push(`import ${target.runtime}: ${error.message}`);
106
+ }
107
+ if (target.types) {
108
+ const file = (0, node_path.join)(root, target.types);
109
+ if (names.has(file)) surface.types = names.get(file);
110
+ else errors.push(`missing ${target.types}`);
111
+ }
112
+ if (errors.length) surface.error = errors.join("; ");
113
+ subpaths[subpath] = surface;
114
+ }
115
+ return {
116
+ package: pkg.name ?? (0, node_path.basename)(root),
117
+ version: pkg.version ?? "0.0.0",
118
+ subpaths
119
+ };
120
+ }
121
+ /** Compare two snapshots. Anything in `before` but not in `after` is a removal. */
122
+ function diffApiSurface(before, after) {
123
+ const removed = [];
124
+ const added = [];
125
+ const keys = new Set([...Object.keys(before.subpaths), ...Object.keys(after.subpaths)]);
126
+ for (const subpath of keys) {
127
+ const a = before.subpaths[subpath];
128
+ const b = after.subpaths[subpath];
129
+ if (!b) {
130
+ removed.push(`${subpath}: subpath`);
131
+ continue;
132
+ }
133
+ if (!a) {
134
+ added.push(`${subpath}: subpath`);
135
+ continue;
136
+ }
137
+ for (const kind of ["runtime", "types"]) {
138
+ const was = new Set(a[kind]);
139
+ const now = new Set(b[kind]);
140
+ for (const name of was) if (!now.has(name)) removed.push(`${subpath}: ${kind} ${name}`);
141
+ for (const name of now) if (!was.has(name)) added.push(`${subpath}: ${kind} ${name}`);
142
+ }
143
+ if (b.error && !a.error) removed.push(`${subpath}: now fails (${b.error})`);
144
+ }
145
+ return {
146
+ removed,
147
+ added
148
+ };
149
+ }
150
+ //#endregion
151
+ //#region src/build/fix-elysia2-types.ts
152
+ /**
153
+ * Post-build step for a product's `/elysia2` declarations.
154
+ *
155
+ * `tsc -p tsconfig.elysia2.build.json` type-checks against the `elysia-v2` devDep alias (the repos
156
+ * develop on Elysia 1), and where tsc has to name an inferred type it may spell the alias:
157
+ * `import("elysia-v2/types")`. Consumers install Elysia 2 as plain `elysia`, so the specifier is
158
+ * rewritten.
159
+ *
160
+ * @module
161
+ */
162
+ /** Rewrite `"<from>"` / `"<from>/…"` module specifiers to `<to>` in a string. */
163
+ function rewriteSpecifiers(source, from = "elysia-v2", to = "elysia") {
164
+ const name = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
165
+ return source.replace(new RegExp(`(["'])${name}(\\/[^"']*)?\\1`, "g"), `$1${to}$2$1`);
166
+ }
167
+ /**
168
+ * Rewrite the alias in every `.d.ts`/`.d.mts`/`.d.cts` under `dir` (recursively). Resolves to the
169
+ * number of files changed.
170
+ */
171
+ async function fixElysia2Types(options = {}) {
172
+ const dir = options.dir ?? "dist/types-elysia2";
173
+ let rewritten = 0;
174
+ for (const rel of await (0, node_fs_promises.readdir)(dir, { recursive: true })) {
175
+ if (!/\.d\.[mc]?ts$/.test(rel)) continue;
176
+ const path = (0, node_path.join)(dir, rel);
177
+ const src = await (0, node_fs_promises.readFile)(path, "utf8");
178
+ const out = rewriteSpecifiers(src, options.from, options.to);
179
+ if (out !== src) {
180
+ await (0, node_fs_promises.writeFile)(path, out);
181
+ rewritten++;
182
+ }
183
+ }
184
+ return rewritten;
185
+ }
186
+ //#endregion
187
+ //#region src/build/scope-css.ts
188
+ /**
189
+ * Scoping for a product's React-embed stylesheet.
190
+ *
191
+ * The embed build emits `dist/react.css` as a full, unscoped Tailwind build: global preflight
192
+ * resets (`*`, `button`, `h1`, `a`, …) plus generic utilities (`.flex`, `.border`, …). A host app
193
+ * importing it (`@xtandard/<product>/react/styles.css`) would get its whole page restyled.
194
+ *
195
+ * {@link scopeCss} prefixes every rule with the embed's wrapper class. The design-token
196
+ * `:root`/`html` blocks (including `:root[data-theme="dark"]` and `:root.dark`) and the `body`
197
+ * surface rule are re-homed onto the wrapper itself, and keyframe steps are left alone. The
198
+ * standalone SPA build (`dist/ui`) is not processed: it legitimately owns the whole document.
199
+ *
200
+ * Needs the optional peers `postcss` and `postcss-prefix-selector`.
201
+ *
202
+ * @module
203
+ */
204
+ const SUBPATH = "@xtandard/kit/build";
205
+ /** `".xtandard-flags"` → `".xtandard-flags"`; a bare `"xtandard-flags"` gets its dot. */
206
+ function normalizeScope(scope) {
207
+ const s = scope.trim();
208
+ const withDot = s.startsWith(".") ? s : `.${s}`;
209
+ if (!/^\.[A-Za-z_-][\w-]*$/.test(withDot)) throw new Error(`scope must be a single class name such as ".xtandard-flags", got "${scope}"`);
210
+ return withDot;
211
+ }
212
+ /**
213
+ * Prefix every rule in `css` with `scope` (a class, e.g. `".xtandard-flags"`), re-homing
214
+ * `:root`/`html`/`:host`/`body` onto the wrapper and leaving keyframe steps alone. Pure.
215
+ */
216
+ async function scopeCss(css, scope) {
217
+ const prefix = normalizeScope(scope);
218
+ const [{ default: postcss }, { default: prefixSelector }] = await Promise.all([require_peer.importPeer("postcss", SUBPATH, () => import("postcss")), require_peer.importPeer("postcss-prefix-selector", SUBPATH, () => import("postcss-prefix-selector"))]);
219
+ return (await postcss([prefixSelector({
220
+ prefix,
221
+ transform(prefix, selector, prefixedSelector) {
222
+ const s = selector.trim();
223
+ if (/^(\d+(\.\d+)?%|from|to)$/.test(s)) return selector;
224
+ if (/^(:root|html|:host|body)$/.test(s)) return prefix;
225
+ const compound = /^(?::root|html)([[:.].*)$/.exec(s);
226
+ if (compound) return `${prefix}${compound[1]}`;
227
+ return prefixedSelector;
228
+ }
229
+ })]).process(css, { from: void 0 })).css;
230
+ }
231
+ /**
232
+ * Rules that would restyle the host document if they escaped the scope: preflight resets, the
233
+ * universal custom-property rule, and token blocks left on `:root`/`html`/`body`. Returns the
234
+ * offending rule fragments (empty when fully scoped).
235
+ */
236
+ function findUnscopedLeaks(css, scope) {
237
+ const prefix = normalizeScope(scope);
238
+ const scoped = new RegExp(`${prefix.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")}(?![\\w-])`);
239
+ return css.split("}").filter((rule) => /text-size-adjust|^\s*\*[,{]|^\s*(button|a|h1|table)[,{]|^\s*(:root|html|body)[[,{:.\s]/.test(rule)).filter((rule) => !scoped.test(rule));
240
+ }
241
+ /**
242
+ * Scope a stylesheet on disk in place (`xtandard-kit scope-embed-css --scope … --css …`), then
243
+ * check it for leaks.
244
+ */
245
+ async function scopeCssFile(path, scope) {
246
+ const scoped = await scopeCss(await (0, node_fs_promises.readFile)(path, "utf8"), scope);
247
+ await (0, node_fs_promises.writeFile)(path, scoped);
248
+ return {
249
+ path,
250
+ leaks: findUnscopedLeaks(scoped, scope)
251
+ };
252
+ }
253
+ //#endregion
254
+ Object.defineProperty(exports, "apiSurface", {
255
+ enumerable: true,
256
+ get: function() {
257
+ return apiSurface;
258
+ }
259
+ });
260
+ Object.defineProperty(exports, "diffApiSurface", {
261
+ enumerable: true,
262
+ get: function() {
263
+ return diffApiSurface;
264
+ }
265
+ });
266
+ Object.defineProperty(exports, "exportTarget", {
267
+ enumerable: true,
268
+ get: function() {
269
+ return exportTarget;
270
+ }
271
+ });
272
+ Object.defineProperty(exports, "findUnscopedLeaks", {
273
+ enumerable: true,
274
+ get: function() {
275
+ return findUnscopedLeaks;
276
+ }
277
+ });
278
+ Object.defineProperty(exports, "fixElysia2Types", {
279
+ enumerable: true,
280
+ get: function() {
281
+ return fixElysia2Types;
282
+ }
283
+ });
284
+ Object.defineProperty(exports, "normalizeScope", {
285
+ enumerable: true,
286
+ get: function() {
287
+ return normalizeScope;
288
+ }
289
+ });
290
+ Object.defineProperty(exports, "packageRoot", {
291
+ enumerable: true,
292
+ get: function() {
293
+ return packageRoot;
294
+ }
295
+ });
296
+ Object.defineProperty(exports, "rewriteSpecifiers", {
297
+ enumerable: true,
298
+ get: function() {
299
+ return rewriteSpecifiers;
300
+ }
301
+ });
302
+ Object.defineProperty(exports, "scopeCss", {
303
+ enumerable: true,
304
+ get: function() {
305
+ return scopeCss;
306
+ }
307
+ });
308
+ Object.defineProperty(exports, "scopeCssFile", {
309
+ enumerable: true,
310
+ get: function() {
311
+ return scopeCssFile;
312
+ }
313
+ });
314
+
315
+ //# sourceMappingURL=scope-css-BN3jf0ly.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-css-BN3jf0ly.cjs","names":["importPeer","importPeer"],"sources":["../src/build/api-surface.ts","../src/build/fix-elysia2-types.ts","../src/build/scope-css.ts"],"sourcesContent":["/**\n * API-surface snapshots (ADR 0003). For every `exports` subpath of a built package,\n * {@link apiSurface} records the runtime export names (by importing the ESM entry) and the exported\n * declaration names (from its `.d.mts`, through the TypeScript compiler API). {@link diffApiSurface}\n * compares two snapshots; a migration PR, or a kit patch, must show no removals.\n *\n * Needs the optional peer `typescript` for the declaration names.\n *\n * @module\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { importPeer } from \"../internal/peer.ts\";\n\n/** The surface of one subpath. */\nexport interface SubpathSurface {\n /** Runtime export names (sorted), from importing the ESM entry. */\n runtime: string[];\n /** Every exported name in the `.d.mts` (types and values, sorted). */\n types: string[];\n /** Why the entry could not be imported or read, when it couldn't. */\n error?: string;\n}\n\n/** A package's API surface, as written by `xtandard-kit api-surface`. */\nexport interface ApiSurface {\n package: string;\n version: string;\n /** Keyed by subpath (`\".\"`, `\"./storage/redis\"`…), in `exports` order. */\n subpaths: Record<string, SubpathSurface>;\n}\n\n/** The ESM runtime file and declaration file an `exports` entry points at. */\nexport interface ExportTarget {\n runtime?: string;\n types?: string;\n}\n\ntype Conditions = string | null | { [condition: string]: Conditions } | Conditions[];\n\nfunction pick(value: Conditions | undefined, keys: readonly string[]): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n for (const v of value) {\n const hit = pick(v, keys);\n if (hit) return hit;\n }\n return undefined;\n }\n for (const key of keys) {\n const hit = pick(value[key], keys);\n if (hit) return hit;\n }\n return undefined;\n}\n\n/**\n * Resolve an `exports` value to its ESM runtime file and declaration file (paths as written in\n * `package.json`). `.d.mts` is derived from an `.mjs` target when no `types` condition is given.\n */\nexport function exportTarget(value: Conditions): ExportTarget {\n const importSide =\n value && typeof value === \"object\" && !Array.isArray(value) && \"import\" in value\n ? value.import\n : value;\n const runtime = pick(importSide ?? null, [\"node\", \"default\"]);\n // `types` only ever comes from a condition; a bare string target is the runtime file.\n const conditionTypes = (v: Conditions | undefined) =>\n v && typeof v === \"object\" && !Array.isArray(v)\n ? pick(v.types ?? null, [\"default\"])\n : undefined;\n let types = conditionTypes(importSide) ?? conditionTypes(value);\n if (!types && runtime)\n types = runtime.replace(/\\.m?js$/, (ext) => (ext === \".mjs\" ? \".d.mts\" : \".d.ts\"));\n const isCode = (p?: string) => (p && /\\.[cm]?[jt]s$/.test(p) ? p : undefined);\n return {\n runtime: isCode(runtime),\n types: types && /\\.d\\.[cm]?ts$/.test(types) ? types : undefined,\n };\n}\n\n/** Locate the package root: `dir` itself, or its parent when `dir` is the `dist/` folder. */\nexport function packageRoot(dir: string): string {\n const abs = resolve(dir);\n if (existsSync(join(abs, \"package.json\"))) return abs;\n if (existsSync(join(dirname(abs), \"package.json\"))) return dirname(abs);\n throw new Error(`api-surface: no package.json in ${abs} or its parent`);\n}\n\nasync function declarationNames(files: string[]): Promise<Map<string, string[]>> {\n const out = new Map<string, string[]>();\n if (files.length === 0) return out;\n // `typescript` is CommonJS: its API is the default export under Node ESM.\n const ts = await importPeer(\"typescript\", \"@xtandard/kit/build\", async () => {\n const mod = await import(\"typescript\");\n return mod.default ?? mod;\n });\n const program = ts.createProgram(files, {\n noEmit: true,\n skipLibCheck: true,\n allowJs: false,\n types: [],\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n target: ts.ScriptTarget.ESNext,\n });\n const checker = program.getTypeChecker();\n for (const file of files) {\n const source = program.getSourceFile(file);\n const symbol = source && checker.getSymbolAtLocation(source);\n out.set(\n file,\n symbol\n ? checker\n .getExportsOfModule(symbol)\n .map((s) => s.getName())\n .sort()\n : [],\n );\n }\n return out;\n}\n\n/**\n * Snapshot the API surface of the built package at `dir` (the package root, or its `dist/`).\n * Wildcard, CSS, JSON and `./package.json` exports are skipped.\n */\nexport async function apiSurface(dir: string): Promise<ApiSurface> {\n const root = packageRoot(dir);\n const pkg = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\")) as {\n name?: string;\n version?: string;\n exports?: Record<string, Conditions> | Conditions;\n };\n const exportsField: Record<string, Conditions> =\n pkg.exports && typeof pkg.exports === \"object\" && !Array.isArray(pkg.exports)\n ? Object.keys(pkg.exports).every((k) => k.startsWith(\".\"))\n ? (pkg.exports as Record<string, Conditions>)\n : { \".\": pkg.exports as Conditions }\n : pkg.exports\n ? { \".\": pkg.exports as Conditions }\n : {};\n\n const targets: [string, ExportTarget][] = [];\n for (const [subpath, value] of Object.entries(exportsField)) {\n if (subpath.includes(\"*\") || subpath === \"./package.json\") continue;\n const target = exportTarget(value);\n if (target.runtime || target.types) targets.push([subpath, target]);\n }\n\n const typeFiles = targets\n .map(([, t]) => t.types && join(root, t.types))\n .filter((f): f is string => Boolean(f && existsSync(f)));\n const names = await declarationNames(typeFiles);\n\n const subpaths: Record<string, SubpathSurface> = {};\n for (const [subpath, target] of targets) {\n const surface: SubpathSurface = { runtime: [], types: [] };\n const errors: string[] = [];\n if (target.runtime) {\n try {\n // A fresh module instance per snapshot: Node caches ESM by URL, so a second snapshot\n // in the same process (before/after a rebuild) would otherwise see the old exports.\n const url = `${pathToFileURL(join(root, target.runtime)).href}?surface=${Date.now()}`;\n const mod = (await import(url)) as object;\n surface.runtime = Object.keys(mod).sort();\n } catch (error) {\n errors.push(`import ${target.runtime}: ${(error as Error).message}`);\n }\n }\n if (target.types) {\n const file = join(root, target.types);\n if (names.has(file)) surface.types = names.get(file)!;\n else errors.push(`missing ${target.types}`);\n }\n if (errors.length) surface.error = errors.join(\"; \");\n subpaths[subpath] = surface;\n }\n return { package: pkg.name ?? basename(root), version: pkg.version ?? \"0.0.0\", subpaths };\n}\n\n/** The result of {@link diffApiSurface}: one line per change, e.g. `\"./storage: runtime foo\"`. */\nexport interface ApiSurfaceDiff {\n removed: string[];\n added: string[];\n}\n\n/** Compare two snapshots. Anything in `before` but not in `after` is a removal. */\nexport function diffApiSurface(before: ApiSurface, after: ApiSurface): ApiSurfaceDiff {\n const removed: string[] = [];\n const added: string[] = [];\n const keys = new Set([...Object.keys(before.subpaths), ...Object.keys(after.subpaths)]);\n for (const subpath of keys) {\n const a = before.subpaths[subpath];\n const b = after.subpaths[subpath];\n if (!b) {\n removed.push(`${subpath}: subpath`);\n continue;\n }\n if (!a) {\n added.push(`${subpath}: subpath`);\n continue;\n }\n for (const kind of [\"runtime\", \"types\"] as const) {\n const was = new Set(a[kind]);\n const now = new Set(b[kind]);\n for (const name of was) if (!now.has(name)) removed.push(`${subpath}: ${kind} ${name}`);\n for (const name of now) if (!was.has(name)) added.push(`${subpath}: ${kind} ${name}`);\n }\n if (b.error && !a.error) removed.push(`${subpath}: now fails (${b.error})`);\n }\n return { removed, added };\n}\n","/**\n * Post-build step for a product's `/elysia2` declarations.\n *\n * `tsc -p tsconfig.elysia2.build.json` type-checks against the `elysia-v2` devDep alias (the repos\n * develop on Elysia 1), and where tsc has to name an inferred type it may spell the alias:\n * `import(\"elysia-v2/types\")`. Consumers install Elysia 2 as plain `elysia`, so the specifier is\n * rewritten.\n *\n * @module\n */\n\nimport { readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/** Options for {@link fixElysia2Types}. */\nexport interface FixElysia2TypesOptions {\n /** The declarations directory; `\"dist/types-elysia2\"` by default. */\n dir?: string;\n /** The alias to rewrite; `\"elysia-v2\"` by default. */\n from?: string;\n /** What it becomes; `\"elysia\"` by default. */\n to?: string;\n}\n\n/** Rewrite `\"<from>\"` / `\"<from>/…\"` module specifiers to `<to>` in a string. */\nexport function rewriteSpecifiers(source: string, from = \"elysia-v2\", to = \"elysia\"): string {\n const name = from.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return source.replace(new RegExp(`([\"'])${name}(\\\\/[^\"']*)?\\\\1`, \"g\"), `$1${to}$2$1`);\n}\n\n/**\n * Rewrite the alias in every `.d.ts`/`.d.mts`/`.d.cts` under `dir` (recursively). Resolves to the\n * number of files changed.\n */\nexport async function fixElysia2Types(options: FixElysia2TypesOptions = {}): Promise<number> {\n const dir = options.dir ?? \"dist/types-elysia2\";\n let rewritten = 0;\n for (const rel of await readdir(dir, { recursive: true })) {\n if (!/\\.d\\.[mc]?ts$/.test(rel)) continue;\n const path = join(dir, rel);\n const src = await readFile(path, \"utf8\");\n const out = rewriteSpecifiers(src, options.from, options.to);\n if (out !== src) {\n await writeFile(path, out);\n rewritten++;\n }\n }\n return rewritten;\n}\n","/**\n * Scoping for a product's React-embed stylesheet.\n *\n * The embed build emits `dist/react.css` as a full, unscoped Tailwind build: global preflight\n * resets (`*`, `button`, `h1`, `a`, …) plus generic utilities (`.flex`, `.border`, …). A host app\n * importing it (`@xtandard/<product>/react/styles.css`) would get its whole page restyled.\n *\n * {@link scopeCss} prefixes every rule with the embed's wrapper class. The design-token\n * `:root`/`html` blocks (including `:root[data-theme=\"dark\"]` and `:root.dark`) and the `body`\n * surface rule are re-homed onto the wrapper itself, and keyframe steps are left alone. The\n * standalone SPA build (`dist/ui`) is not processed: it legitimately owns the whole document.\n *\n * Needs the optional peers `postcss` and `postcss-prefix-selector`.\n *\n * @module\n */\n\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { importPeer } from \"../internal/peer.ts\";\n\nconst SUBPATH = \"@xtandard/kit/build\";\n\n/** `\".xtandard-flags\"` → `\".xtandard-flags\"`; a bare `\"xtandard-flags\"` gets its dot. */\nexport function normalizeScope(scope: string): string {\n const s = scope.trim();\n const withDot = s.startsWith(\".\") ? s : `.${s}`;\n if (!/^\\.[A-Za-z_-][\\w-]*$/.test(withDot)) {\n throw new Error(`scope must be a single class name such as \".xtandard-flags\", got \"${scope}\"`);\n }\n return withDot;\n}\n\n/**\n * Prefix every rule in `css` with `scope` (a class, e.g. `\".xtandard-flags\"`), re-homing\n * `:root`/`html`/`:host`/`body` onto the wrapper and leaving keyframe steps alone. Pure.\n */\nexport async function scopeCss(css: string, scope: string): Promise<string> {\n const prefix = normalizeScope(scope);\n const [{ default: postcss }, { default: prefixSelector }] = await Promise.all([\n importPeer(\"postcss\", SUBPATH, () => import(\"postcss\")),\n importPeer(\"postcss-prefix-selector\", SUBPATH, () => import(\"postcss-prefix-selector\")),\n ]);\n const result = await postcss([\n prefixSelector({\n prefix,\n transform(prefix: string, selector: string, prefixedSelector: string): string {\n const s = selector.trim();\n // Keyframe steps (`from`, `to`, `47%`, `0%,50%`) are not element selectors.\n if (/^(\\d+(\\.\\d+)?%|from|to)$/.test(s)) return selector;\n // Design tokens live on :root/html — re-home them onto the wrapper so the embed's own\n // scope carries them (the host <html> is untouched). `body` carries the page surface\n // (background, text colour, font): the wrapper is the embed's \"page\", so it gets them too,\n // otherwise its text inherits the host's colour over the dashboard's own surfaces.\n if (/^(:root|html|:host|body)$/.test(s)) return prefix;\n // Compound root selectors — the dark tokens on `:root[data-theme=\"dark\"]`, `:root.dark`,\n // `:root:not(…)` — become the wrapper with the same qualifier\n // (`.xtandard-flags[data-theme=\"dark\"]`), matching the `data-theme` the embed sets on its\n // own wrapper.\n const compound = /^(?::root|html)([[:.].*)$/.exec(s);\n if (compound) return `${prefix}${compound[1]}`;\n return prefixedSelector;\n },\n }),\n ]).process(css, { from: undefined });\n return result.css;\n}\n\n/**\n * Rules that would restyle the host document if they escaped the scope: preflight resets, the\n * universal custom-property rule, and token blocks left on `:root`/`html`/`body`. Returns the\n * offending rule fragments (empty when fully scoped).\n */\nexport function findUnscopedLeaks(css: string, scope: string): string[] {\n const prefix = normalizeScope(scope);\n // A fragment is scoped when the class appears as a whole class token (not `.x-flags-other`).\n const scoped = new RegExp(`${prefix.replace(/[.*+?^${}()|[\\]\\\\-]/g, \"\\\\$&\")}(?![\\\\w-])`);\n return css\n .split(\"}\")\n .filter((rule) =>\n /text-size-adjust|^\\s*\\*[,{]|^\\s*(button|a|h1|table)[,{]|^\\s*(:root|html|body)[[,{:.\\s]/.test(\n rule,\n ),\n )\n .filter((rule) => !scoped.test(rule));\n}\n\n/** What {@link scopeCssFile} did. */\nexport interface ScopeCssFileResult {\n /** The file that was rewritten. */\n path: string;\n /** Unscoped fragments left after scoping (the command fails when non-empty). */\n leaks: string[];\n}\n\n/**\n * Scope a stylesheet on disk in place (`xtandard-kit scope-embed-css --scope … --css …`), then\n * check it for leaks.\n */\nexport async function scopeCssFile(path: string, scope: string): Promise<ScopeCssFileResult> {\n const scoped = await scopeCss(await readFile(path, \"utf8\"), scope);\n await writeFile(path, scoped);\n return { path, leaks: findUnscopedLeaks(scoped, scope) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2CA,SAAS,KAAK,OAA+B,MAA6C;CACxF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,KAAK,MAAM,KAAK,OAAO;GACrB,MAAM,MAAM,KAAK,GAAG,IAAI;GACxB,IAAI,KAAK,OAAO;EAClB;EACA;CACF;CACA,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,MAAM,KAAK,MAAM,MAAM,IAAI;EACjC,IAAI,KAAK,OAAO;CAClB;AAEF;;;;;AAMA,SAAgB,aAAa,OAAiC;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M,SAAS,MAAM,SAAS,OAAA,GAAA,iBAAA,UAAe,MAAM,MAAM,GAAG,KAAK;CACjE,OAAA,GAAA,iBAAA,WAAgB,MAAM,MAAM;CAC5B,OAAO;EAAE;EAAM,OAAO,kBAAkB,QAAQ,KAAK;CAAE;AACzD"}
@@ -0,0 +1,256 @@
1
+ import { t as importPeer } from "./peer-CTHMzOdn.mjs";
2
+ import { readFile, readdir, writeFile } from "node:fs/promises";
3
+ import { existsSync } from "node:fs";
4
+ import { basename, dirname, join, resolve } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/build/api-surface.ts
7
+ /**
8
+ * API-surface snapshots (ADR 0003). For every `exports` subpath of a built package,
9
+ * {@link apiSurface} records the runtime export names (by importing the ESM entry) and the exported
10
+ * declaration names (from its `.d.mts`, through the TypeScript compiler API). {@link diffApiSurface}
11
+ * compares two snapshots; a migration PR, or a kit patch, must show no removals.
12
+ *
13
+ * Needs the optional peer `typescript` for the declaration names.
14
+ *
15
+ * @module
16
+ */
17
+ function pick(value, keys) {
18
+ if (value === void 0 || value === null) return void 0;
19
+ if (typeof value === "string") return value;
20
+ if (Array.isArray(value)) {
21
+ for (const v of value) {
22
+ const hit = pick(v, keys);
23
+ if (hit) return hit;
24
+ }
25
+ return;
26
+ }
27
+ for (const key of keys) {
28
+ const hit = pick(value[key], keys);
29
+ if (hit) return hit;
30
+ }
31
+ }
32
+ /**
33
+ * Resolve an `exports` value to its ESM runtime file and declaration file (paths as written in
34
+ * `package.json`). `.d.mts` is derived from an `.mjs` target when no `types` condition is given.
35
+ */
36
+ function exportTarget(value) {
37
+ const importSide = value && typeof value === "object" && !Array.isArray(value) && "import" in value ? value.import : value;
38
+ const runtime = pick(importSide ?? null, ["node", "default"]);
39
+ const conditionTypes = (v) => v && typeof v === "object" && !Array.isArray(v) ? pick(v.types ?? null, ["default"]) : void 0;
40
+ let types = conditionTypes(importSide) ?? conditionTypes(value);
41
+ if (!types && runtime) types = runtime.replace(/\.m?js$/, (ext) => ext === ".mjs" ? ".d.mts" : ".d.ts");
42
+ const isCode = (p) => p && /\.[cm]?[jt]s$/.test(p) ? p : void 0;
43
+ return {
44
+ runtime: isCode(runtime),
45
+ types: types && /\.d\.[cm]?ts$/.test(types) ? types : void 0
46
+ };
47
+ }
48
+ /** Locate the package root: `dir` itself, or its parent when `dir` is the `dist/` folder. */
49
+ function packageRoot(dir) {
50
+ const abs = resolve(dir);
51
+ if (existsSync(join(abs, "package.json"))) return abs;
52
+ if (existsSync(join(dirname(abs), "package.json"))) return dirname(abs);
53
+ throw new Error(`api-surface: no package.json in ${abs} or its parent`);
54
+ }
55
+ async function declarationNames(files) {
56
+ const out = /* @__PURE__ */ new Map();
57
+ if (files.length === 0) return out;
58
+ const ts = await importPeer("typescript", "@xtandard/kit/build", async () => {
59
+ const mod = await import("typescript");
60
+ return mod.default ?? mod;
61
+ });
62
+ const program = ts.createProgram(files, {
63
+ noEmit: true,
64
+ skipLibCheck: true,
65
+ allowJs: false,
66
+ types: [],
67
+ module: ts.ModuleKind.ESNext,
68
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
69
+ target: ts.ScriptTarget.ESNext
70
+ });
71
+ const checker = program.getTypeChecker();
72
+ for (const file of files) {
73
+ const source = program.getSourceFile(file);
74
+ const symbol = source && checker.getSymbolAtLocation(source);
75
+ out.set(file, symbol ? checker.getExportsOfModule(symbol).map((s) => s.getName()).sort() : []);
76
+ }
77
+ return out;
78
+ }
79
+ /**
80
+ * Snapshot the API surface of the built package at `dir` (the package root, or its `dist/`).
81
+ * Wildcard, CSS, JSON and `./package.json` exports are skipped.
82
+ */
83
+ async function apiSurface(dir) {
84
+ const root = packageRoot(dir);
85
+ const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
86
+ const exportsField = pkg.exports && typeof pkg.exports === "object" && !Array.isArray(pkg.exports) ? Object.keys(pkg.exports).every((k) => k.startsWith(".")) ? pkg.exports : { ".": pkg.exports } : pkg.exports ? { ".": pkg.exports } : {};
87
+ const targets = [];
88
+ for (const [subpath, value] of Object.entries(exportsField)) {
89
+ if (subpath.includes("*") || subpath === "./package.json") continue;
90
+ const target = exportTarget(value);
91
+ if (target.runtime || target.types) targets.push([subpath, target]);
92
+ }
93
+ const names = await declarationNames(targets.map(([, t]) => t.types && join(root, t.types)).filter((f) => Boolean(f && existsSync(f))));
94
+ const subpaths = {};
95
+ for (const [subpath, target] of targets) {
96
+ const surface = {
97
+ runtime: [],
98
+ types: []
99
+ };
100
+ const errors = [];
101
+ if (target.runtime) try {
102
+ const mod = await import(`${pathToFileURL(join(root, target.runtime)).href}?surface=${Date.now()}`);
103
+ surface.runtime = Object.keys(mod).sort();
104
+ } catch (error) {
105
+ errors.push(`import ${target.runtime}: ${error.message}`);
106
+ }
107
+ if (target.types) {
108
+ const file = join(root, target.types);
109
+ if (names.has(file)) surface.types = names.get(file);
110
+ else errors.push(`missing ${target.types}`);
111
+ }
112
+ if (errors.length) surface.error = errors.join("; ");
113
+ subpaths[subpath] = surface;
114
+ }
115
+ return {
116
+ package: pkg.name ?? basename(root),
117
+ version: pkg.version ?? "0.0.0",
118
+ subpaths
119
+ };
120
+ }
121
+ /** Compare two snapshots. Anything in `before` but not in `after` is a removal. */
122
+ function diffApiSurface(before, after) {
123
+ const removed = [];
124
+ const added = [];
125
+ const keys = new Set([...Object.keys(before.subpaths), ...Object.keys(after.subpaths)]);
126
+ for (const subpath of keys) {
127
+ const a = before.subpaths[subpath];
128
+ const b = after.subpaths[subpath];
129
+ if (!b) {
130
+ removed.push(`${subpath}: subpath`);
131
+ continue;
132
+ }
133
+ if (!a) {
134
+ added.push(`${subpath}: subpath`);
135
+ continue;
136
+ }
137
+ for (const kind of ["runtime", "types"]) {
138
+ const was = new Set(a[kind]);
139
+ const now = new Set(b[kind]);
140
+ for (const name of was) if (!now.has(name)) removed.push(`${subpath}: ${kind} ${name}`);
141
+ for (const name of now) if (!was.has(name)) added.push(`${subpath}: ${kind} ${name}`);
142
+ }
143
+ if (b.error && !a.error) removed.push(`${subpath}: now fails (${b.error})`);
144
+ }
145
+ return {
146
+ removed,
147
+ added
148
+ };
149
+ }
150
+ //#endregion
151
+ //#region src/build/fix-elysia2-types.ts
152
+ /**
153
+ * Post-build step for a product's `/elysia2` declarations.
154
+ *
155
+ * `tsc -p tsconfig.elysia2.build.json` type-checks against the `elysia-v2` devDep alias (the repos
156
+ * develop on Elysia 1), and where tsc has to name an inferred type it may spell the alias:
157
+ * `import("elysia-v2/types")`. Consumers install Elysia 2 as plain `elysia`, so the specifier is
158
+ * rewritten.
159
+ *
160
+ * @module
161
+ */
162
+ /** Rewrite `"<from>"` / `"<from>/…"` module specifiers to `<to>` in a string. */
163
+ function rewriteSpecifiers(source, from = "elysia-v2", to = "elysia") {
164
+ const name = from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
165
+ return source.replace(new RegExp(`(["'])${name}(\\/[^"']*)?\\1`, "g"), `$1${to}$2$1`);
166
+ }
167
+ /**
168
+ * Rewrite the alias in every `.d.ts`/`.d.mts`/`.d.cts` under `dir` (recursively). Resolves to the
169
+ * number of files changed.
170
+ */
171
+ async function fixElysia2Types(options = {}) {
172
+ const dir = options.dir ?? "dist/types-elysia2";
173
+ let rewritten = 0;
174
+ for (const rel of await readdir(dir, { recursive: true })) {
175
+ if (!/\.d\.[mc]?ts$/.test(rel)) continue;
176
+ const path = join(dir, rel);
177
+ const src = await readFile(path, "utf8");
178
+ const out = rewriteSpecifiers(src, options.from, options.to);
179
+ if (out !== src) {
180
+ await writeFile(path, out);
181
+ rewritten++;
182
+ }
183
+ }
184
+ return rewritten;
185
+ }
186
+ //#endregion
187
+ //#region src/build/scope-css.ts
188
+ /**
189
+ * Scoping for a product's React-embed stylesheet.
190
+ *
191
+ * The embed build emits `dist/react.css` as a full, unscoped Tailwind build: global preflight
192
+ * resets (`*`, `button`, `h1`, `a`, …) plus generic utilities (`.flex`, `.border`, …). A host app
193
+ * importing it (`@xtandard/<product>/react/styles.css`) would get its whole page restyled.
194
+ *
195
+ * {@link scopeCss} prefixes every rule with the embed's wrapper class. The design-token
196
+ * `:root`/`html` blocks (including `:root[data-theme="dark"]` and `:root.dark`) and the `body`
197
+ * surface rule are re-homed onto the wrapper itself, and keyframe steps are left alone. The
198
+ * standalone SPA build (`dist/ui`) is not processed: it legitimately owns the whole document.
199
+ *
200
+ * Needs the optional peers `postcss` and `postcss-prefix-selector`.
201
+ *
202
+ * @module
203
+ */
204
+ const SUBPATH = "@xtandard/kit/build";
205
+ /** `".xtandard-flags"` → `".xtandard-flags"`; a bare `"xtandard-flags"` gets its dot. */
206
+ function normalizeScope(scope) {
207
+ const s = scope.trim();
208
+ const withDot = s.startsWith(".") ? s : `.${s}`;
209
+ if (!/^\.[A-Za-z_-][\w-]*$/.test(withDot)) throw new Error(`scope must be a single class name such as ".xtandard-flags", got "${scope}"`);
210
+ return withDot;
211
+ }
212
+ /**
213
+ * Prefix every rule in `css` with `scope` (a class, e.g. `".xtandard-flags"`), re-homing
214
+ * `:root`/`html`/`:host`/`body` onto the wrapper and leaving keyframe steps alone. Pure.
215
+ */
216
+ async function scopeCss(css, scope) {
217
+ const prefix = normalizeScope(scope);
218
+ const [{ default: postcss }, { default: prefixSelector }] = await Promise.all([importPeer("postcss", SUBPATH, () => import("postcss")), importPeer("postcss-prefix-selector", SUBPATH, () => import("postcss-prefix-selector"))]);
219
+ return (await postcss([prefixSelector({
220
+ prefix,
221
+ transform(prefix, selector, prefixedSelector) {
222
+ const s = selector.trim();
223
+ if (/^(\d+(\.\d+)?%|from|to)$/.test(s)) return selector;
224
+ if (/^(:root|html|:host|body)$/.test(s)) return prefix;
225
+ const compound = /^(?::root|html)([[:.].*)$/.exec(s);
226
+ if (compound) return `${prefix}${compound[1]}`;
227
+ return prefixedSelector;
228
+ }
229
+ })]).process(css, { from: void 0 })).css;
230
+ }
231
+ /**
232
+ * Rules that would restyle the host document if they escaped the scope: preflight resets, the
233
+ * universal custom-property rule, and token blocks left on `:root`/`html`/`body`. Returns the
234
+ * offending rule fragments (empty when fully scoped).
235
+ */
236
+ function findUnscopedLeaks(css, scope) {
237
+ const prefix = normalizeScope(scope);
238
+ const scoped = new RegExp(`${prefix.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")}(?![\\w-])`);
239
+ return css.split("}").filter((rule) => /text-size-adjust|^\s*\*[,{]|^\s*(button|a|h1|table)[,{]|^\s*(:root|html|body)[[,{:.\s]/.test(rule)).filter((rule) => !scoped.test(rule));
240
+ }
241
+ /**
242
+ * Scope a stylesheet on disk in place (`xtandard-kit scope-embed-css --scope … --css …`), then
243
+ * check it for leaks.
244
+ */
245
+ async function scopeCssFile(path, scope) {
246
+ const scoped = await scopeCss(await readFile(path, "utf8"), scope);
247
+ await writeFile(path, scoped);
248
+ return {
249
+ path,
250
+ leaks: findUnscopedLeaks(scoped, scope)
251
+ };
252
+ }
253
+ //#endregion
254
+ export { fixElysia2Types as a, diffApiSurface as c, scopeCssFile as i, exportTarget as l, normalizeScope as n, rewriteSpecifiers as o, scopeCss as r, apiSurface as s, findUnscopedLeaks as t, packageRoot as u };
255
+
256
+ //# sourceMappingURL=scope-css-BuJfRCsE.mjs.map