@kromatv/sdk 0.1.40-canary.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 (987) hide show
  1. package/README.md +80 -0
  2. package/dist/cli.js +2523 -0
  3. package/package.json +78 -0
  4. package/rust/Cargo.toml +3 -0
  5. package/rust/kroma-db/Cargo.toml +27 -0
  6. package/rust/kroma-db/src/accounts/access_tokens.rs +197 -0
  7. package/rust/kroma-db/src/accounts/credentials.rs +97 -0
  8. package/rust/kroma-db/src/accounts/invites.rs +136 -0
  9. package/rust/kroma-db/src/accounts/preferences.rs +100 -0
  10. package/rust/kroma-db/src/accounts/resets.rs +202 -0
  11. package/rust/kroma-db/src/accounts/sessions.rs +182 -0
  12. package/rust/kroma-db/src/accounts/test_support.rs +14 -0
  13. package/rust/kroma-db/src/accounts/verifications.rs +185 -0
  14. package/rust/kroma-db/src/accounts.rs +244 -0
  15. package/rust/kroma-db/src/admin/metrics.rs +201 -0
  16. package/rust/kroma-db/src/admin/play_history.rs +361 -0
  17. package/rust/kroma-db/src/admin/play_sort.rs +113 -0
  18. package/rust/kroma-db/src/admin/stats.rs +108 -0
  19. package/rust/kroma-db/src/admin/test_support.rs +83 -0
  20. package/rust/kroma-db/src/admin/watch_stats.rs +458 -0
  21. package/rust/kroma-db/src/admin.rs +226 -0
  22. package/rust/kroma-db/src/audio_analysis.rs +253 -0
  23. package/rust/kroma-db/src/backup/module_stores.rs +204 -0
  24. package/rust/kroma-db/src/backup/rows.rs +155 -0
  25. package/rust/kroma-db/src/backup/test_support.rs +61 -0
  26. package/rust/kroma-db/src/backup.rs +306 -0
  27. package/rust/kroma-db/src/catalog_query/find_titles.rs +316 -0
  28. package/rust/kroma-db/src/catalog_query/test_support.rs +88 -0
  29. package/rust/kroma-db/src/catalog_query.rs +198 -0
  30. package/rust/kroma-db/src/chunked.rs +36 -0
  31. package/rust/kroma-db/src/core_tables.rs +99 -0
  32. package/rust/kroma-db/src/curated.rs +192 -0
  33. package/rust/kroma-db/src/downloaded_subs.rs +136 -0
  34. package/rust/kroma-db/src/downloads.rs +219 -0
  35. package/rust/kroma-db/src/grant/escapes/schema.rs +120 -0
  36. package/rust/kroma-db/src/grant/escapes/statements.rs +170 -0
  37. package/rust/kroma-db/src/grant/escapes.rs +141 -0
  38. package/rust/kroma-db/src/grant/tests.rs +255 -0
  39. package/rust/kroma-db/src/grant.rs +203 -0
  40. package/rust/kroma-db/src/home/genre_guard.rs +249 -0
  41. package/rust/kroma-db/src/home/hydration.rs +126 -0
  42. package/rust/kroma-db/src/home/test_support.rs +60 -0
  43. package/rust/kroma-db/src/home.rs +244 -0
  44. package/rust/kroma-db/src/hydrate.rs +296 -0
  45. package/rust/kroma-db/src/ingest/metadata.rs +648 -0
  46. package/rust/kroma-db/src/ingest/probe.rs +171 -0
  47. package/rust/kroma-db/src/ingest/probe_result.rs +178 -0
  48. package/rust/kroma-db/src/ingest/scanned_files.rs +235 -0
  49. package/rust/kroma-db/src/ingest/sync.rs +291 -0
  50. package/rust/kroma-db/src/ingest/test_support.rs +114 -0
  51. package/rust/kroma-db/src/ingest.rs +20 -0
  52. package/rust/kroma-db/src/jobs.rs +269 -0
  53. package/rust/kroma-db/src/lib.rs +97 -0
  54. package/rust/kroma-db/src/library.rs +66 -0
  55. package/rust/kroma-db/src/localize/items.rs +303 -0
  56. package/rust/kroma-db/src/localize/shows.rs +192 -0
  57. package/rust/kroma-db/src/localize/test_support.rs +91 -0
  58. package/rust/kroma-db/src/localize.rs +105 -0
  59. package/rust/kroma-db/src/markers.rs +203 -0
  60. package/rust/kroma-db/src/media/person.rs +213 -0
  61. package/rust/kroma-db/src/media/show_detail.rs +186 -0
  62. package/rust/kroma-db/src/media/shows.rs +202 -0
  63. package/rust/kroma-db/src/media/splash.rs +199 -0
  64. package/rust/kroma-db/src/media/test_support.rs +31 -0
  65. package/rust/kroma-db/src/media.rs +296 -0
  66. package/rust/kroma-db/src/metadata_core.rs +348 -0
  67. package/rust/kroma-db/src/notifications/digest.rs +143 -0
  68. package/rust/kroma-db/src/notifications/preferences.rs +138 -0
  69. package/rust/kroma-db/src/notifications/read_state.rs +167 -0
  70. package/rust/kroma-db/src/notifications/test_support.rs +50 -0
  71. package/rust/kroma-db/src/notifications.rs +232 -0
  72. package/rust/kroma-db/src/passkeys.rs +163 -0
  73. package/rust/kroma-db/src/pipeline/ops/drain.rs +266 -0
  74. package/rust/kroma-db/src/pipeline/ops/reconcile.rs +274 -0
  75. package/rust/kroma-db/src/pipeline/ops/test_support.rs +48 -0
  76. package/rust/kroma-db/src/pipeline/ops.rs +49 -0
  77. package/rust/kroma-db/src/pipeline/query/elements.rs +200 -0
  78. package/rust/kroma-db/src/pipeline/query/test_support.rs +23 -0
  79. package/rust/kroma-db/src/pipeline/query.rs +255 -0
  80. package/rust/kroma-db/src/pipeline/tests.rs +319 -0
  81. package/rust/kroma-db/src/pipeline.rs +26 -0
  82. package/rust/kroma-db/src/playback/continue_watching.rs +289 -0
  83. package/rust/kroma-db/src/playback/on_deck.rs +53 -0
  84. package/rust/kroma-db/src/playback/show_progress.rs +230 -0
  85. package/rust/kroma-db/src/playback/test_support.rs +55 -0
  86. package/rust/kroma-db/src/playback/up_next.rs +208 -0
  87. package/rust/kroma-db/src/playback/watch_state.rs +129 -0
  88. package/rust/kroma-db/src/playback.rs +196 -0
  89. package/rust/kroma-db/src/pool.rs +117 -0
  90. package/rust/kroma-db/src/push_subs.rs +323 -0
  91. package/rust/kroma-db/src/reports.rs +231 -0
  92. package/rust/kroma-db/src/requests/availability.rs +211 -0
  93. package/rust/kroma-db/src/requests/calendar.rs +221 -0
  94. package/rust/kroma-db/src/requests/gaps.rs +213 -0
  95. package/rust/kroma-db/src/requests/search_queue.rs +352 -0
  96. package/rust/kroma-db/src/requests/tests.rs +289 -0
  97. package/rust/kroma-db/src/requests/wanted.rs +351 -0
  98. package/rust/kroma-db/src/requests.rs +245 -0
  99. package/rust/kroma-db/src/rows.rs +190 -0
  100. package/rust/kroma-db/src/schema/ddl.rs +678 -0
  101. package/rust/kroma-db/src/schema/migrations.rs +261 -0
  102. package/rust/kroma-db/src/schema.rs +273 -0
  103. package/rust/kroma-db/src/suggest.rs +129 -0
  104. package/rust/kroma-db/src/taste.rs +77 -0
  105. package/rust/kroma-db/src/testing.rs +63 -0
  106. package/rust/kroma-db/src/tmdb_pin.rs +133 -0
  107. package/rust/kroma-db/src/translations.rs +569 -0
  108. package/rust/kroma-db/src/vectors/recommendations.rs +164 -0
  109. package/rust/kroma-db/src/vectors/search.rs +213 -0
  110. package/rust/kroma-db/src/vectors/test_support.rs +31 -0
  111. package/rust/kroma-db/src/vectors.rs +161 -0
  112. package/rust/kroma-domain/Cargo.toml +17 -0
  113. package/rust/kroma-domain/src/accounts.rs +181 -0
  114. package/rust/kroma-domain/src/admin.rs +197 -0
  115. package/rust/kroma-domain/src/cast.rs +178 -0
  116. package/rust/kroma-domain/src/crash.rs +48 -0
  117. package/rust/kroma-domain/src/jobs.rs +119 -0
  118. package/rust/kroma-domain/src/lib.rs +44 -0
  119. package/rust/kroma-domain/src/library.rs +21 -0
  120. package/rust/kroma-domain/src/matching/mod.rs +293 -0
  121. package/rust/kroma-domain/src/matching/normalize.rs +193 -0
  122. package/rust/kroma-domain/src/media.rs +297 -0
  123. package/rust/kroma-domain/src/metadata.rs +389 -0
  124. package/rust/kroma-domain/src/naming/marker.rs +215 -0
  125. package/rust/kroma-domain/src/naming/mod.rs +283 -0
  126. package/rust/kroma-domain/src/naming/title.rs +349 -0
  127. package/rust/kroma-domain/src/notifications/action.rs +50 -0
  128. package/rust/kroma-domain/src/notifications/event.rs +225 -0
  129. package/rust/kroma-domain/src/notifications/mod.rs +18 -0
  130. package/rust/kroma-domain/src/notifications/param.rs +90 -0
  131. package/rust/kroma-domain/src/notifications/spec.rs +178 -0
  132. package/rust/kroma-domain/src/notifications/view.rs +55 -0
  133. package/rust/kroma-domain/src/people.rs +286 -0
  134. package/rust/kroma-domain/src/pipeline.rs +114 -0
  135. package/rust/kroma-domain/src/playback.rs +39 -0
  136. package/rust/kroma-domain/src/push.rs +163 -0
  137. package/rust/kroma-domain/src/reports.rs +213 -0
  138. package/rust/kroma-domain/src/requests/discover.rs +102 -0
  139. package/rust/kroma-domain/src/requests/ledger.rs +129 -0
  140. package/rust/kroma-domain/src/requests/mod.rs +238 -0
  141. package/rust/kroma-domain/src/section.rs +44 -0
  142. package/rust/kroma-domain/src/slug.rs +165 -0
  143. package/rust/kroma-http/Cargo.toml +20 -0
  144. package/rust/kroma-http/examples/seam-bench.rs +73 -0
  145. package/rust/kroma-http/src/builder.rs +35 -0
  146. package/rust/kroma-http/src/config.rs +50 -0
  147. package/rust/kroma-http/src/curl.rs +131 -0
  148. package/rust/kroma-http/src/fetch.rs +226 -0
  149. package/rust/kroma-http/src/lib.rs +25 -0
  150. package/rust/kroma-http/src/loopback/mod.rs +220 -0
  151. package/rust/kroma-http/src/loopback/tcp.rs +182 -0
  152. package/rust/kroma-http/src/loopback/transport.rs +42 -0
  153. package/rust/kroma-http/src/response.rs +130 -0
  154. package/rust/kroma-module-host/Cargo.toml +36 -0
  155. package/rust/kroma-module-host/src/auth.rs +221 -0
  156. package/rust/kroma-module-host/src/host_ctx.rs +382 -0
  157. package/rust/kroma-module-host/src/host_token.rs +147 -0
  158. package/rust/kroma-module-host/src/lib.rs +141 -0
  159. package/rust/kroma-module-host/src/module.rs +115 -0
  160. package/rust/kroma-module-host/src/port.rs +163 -0
  161. package/rust/kroma-module-host/src/storage.rs +97 -0
  162. package/rust/kroma-module-host/src/test_serve.rs +33 -0
  163. package/rust/kroma-module-host/src/testing/log.rs +145 -0
  164. package/rust/kroma-module-host/src/testing/mod.rs +72 -0
  165. package/rust/kroma-module-host/src/testing/recording.rs +209 -0
  166. package/rust/kroma-module-host/src/testing/stub.rs +592 -0
  167. package/rust/kroma-module-macros/Cargo.toml +12 -0
  168. package/rust/kroma-module-macros/src/lib.rs +148 -0
  169. package/rust/kroma-module-manifest/Cargo.toml +15 -0
  170. package/rust/kroma-module-manifest/src/compat.rs +157 -0
  171. package/rust/kroma-module-manifest/src/embedded.rs +160 -0
  172. package/rust/kroma-module-manifest/src/event.rs +74 -0
  173. package/rust/kroma-module-manifest/src/lib.rs +57 -0
  174. package/rust/kroma-module-manifest/src/manifest.rs +548 -0
  175. package/rust/kroma-module-manifest/src/registry.rs +626 -0
  176. package/rust/kroma-module-runtime/Cargo.toml +33 -0
  177. package/rust/kroma-module-runtime/src/lib.rs +743 -0
  178. package/rust/kroma-module-sdk/Cargo.toml +49 -0
  179. package/rust/kroma-module-sdk/src/lib.rs +70 -0
  180. package/rust/kroma-primitives/Cargo.toml +12 -0
  181. package/rust/kroma-primitives/src/lib.rs +101 -0
  182. package/rust/kroma-testing/Cargo.toml +10 -0
  183. package/rust/kroma-testing/src/lib.rs +72 -0
  184. package/templates/base/README.md +14 -0
  185. package/templates/base/_gitignore +4 -0
  186. package/templates/base/icon.svg +1 -0
  187. package/templates/base/locales/en.json +7 -0
  188. package/templates/base/locales/fr.json +7 -0
  189. package/templates/server/.cargo/config.toml +2 -0
  190. package/templates/server/rust-toolchain.toml +3 -0
  191. package/templates/server/server/Cargo.toml +37 -0
  192. package/templates/server/server/src/bin/module.rs +6 -0
  193. package/templates/server/server/src/lib.rs +43 -0
  194. package/templates/ui/ui/src/__PAGE__.tsx +22 -0
  195. package/templates/ui/ui/src/module.tsx +17 -0
  196. package/templates/ui/ui/src/schemas.ts +6 -0
  197. package/tsconfig.module.json +110 -0
  198. package/types/client/src/api/accounts/client.d.ts +291 -0
  199. package/types/client/src/api/accounts/ids.d.ts +13 -0
  200. package/types/client/src/api/accounts/index.d.ts +6 -0
  201. package/types/client/src/api/accounts/passkeys.d.ts +79 -0
  202. package/types/client/src/api/accounts/quick-connect.d.ts +23 -0
  203. package/types/client/src/api/accounts/remembered.d.ts +66 -0
  204. package/types/client/src/api/accounts/rules.d.ts +9 -0
  205. package/types/client/src/api/accounts/schemas.d.ts +214 -0
  206. package/types/client/src/api/admin/backup.d.ts +22 -0
  207. package/types/client/src/api/admin/client.d.ts +407 -0
  208. package/types/client/src/api/admin/index.d.ts +7 -0
  209. package/types/client/src/api/admin/logs.d.ts +24 -0
  210. package/types/client/src/api/admin/metrics.d.ts +231 -0
  211. package/types/client/src/api/admin/notifications.d.ts +47 -0
  212. package/types/client/src/api/admin/settings.d.ts +50 -0
  213. package/types/client/src/api/admin/stats.d.ts +257 -0
  214. package/types/client/src/api/admin/users.d.ts +98 -0
  215. package/types/client/src/api/cast/client.d.ts +209 -0
  216. package/types/client/src/api/cast/ids.d.ts +4 -0
  217. package/types/client/src/api/cast/index.d.ts +3 -0
  218. package/types/client/src/api/cast/schemas.d.ts +565 -0
  219. package/types/client/src/api/diagnostics/client.d.ts +13 -0
  220. package/types/client/src/api/diagnostics/index.d.ts +2 -0
  221. package/types/client/src/api/diagnostics/schemas.d.ts +29 -0
  222. package/types/client/src/api/discover.d.ts +5 -0
  223. package/types/client/src/api/discover.web.d.ts +5 -0
  224. package/types/client/src/api/discovery/client.d.ts +115 -0
  225. package/types/client/src/api/discovery/index.d.ts +2 -0
  226. package/types/client/src/api/discovery/schemas.d.ts +175 -0
  227. package/types/client/src/api/events/index.d.ts +2 -0
  228. package/types/client/src/api/events/schemas.d.ts +371 -0
  229. package/types/client/src/api/events/socket.d.ts +42 -0
  230. package/types/client/src/api/handoff/client.d.ts +68 -0
  231. package/types/client/src/api/handoff/ids.d.ts +4 -0
  232. package/types/client/src/api/handoff/index.d.ts +3 -0
  233. package/types/client/src/api/handoff/schemas.d.ts +93 -0
  234. package/types/client/src/api/jobs/client.d.ts +96 -0
  235. package/types/client/src/api/jobs/ids.d.ts +5 -0
  236. package/types/client/src/api/jobs/index.d.ts +3 -0
  237. package/types/client/src/api/jobs/schemas.d.ts +168 -0
  238. package/types/client/src/api/library/client.d.ts +45 -0
  239. package/types/client/src/api/library/index.d.ts +2 -0
  240. package/types/client/src/api/library/schemas.d.ts +28 -0
  241. package/types/client/src/api/llm/client.d.ts +37 -0
  242. package/types/client/src/api/llm/ids.d.ts +3 -0
  243. package/types/client/src/api/llm/index.d.ts +3 -0
  244. package/types/client/src/api/llm/schemas.d.ts +74 -0
  245. package/types/client/src/api/media/artwork-scale.d.ts +18 -0
  246. package/types/client/src/api/media/artwork.d.ts +31 -0
  247. package/types/client/src/api/media/client.d.ts +2160 -0
  248. package/types/client/src/api/media/credits.d.ts +46 -0
  249. package/types/client/src/api/media/ids.d.ts +12 -0
  250. package/types/client/src/api/media/index.d.ts +7 -0
  251. package/types/client/src/api/media/rematch.d.ts +31 -0
  252. package/types/client/src/api/media/schemas.d.ts +1607 -0
  253. package/types/client/src/api/media/search.d.ts +1044 -0
  254. package/types/client/src/api/media/tracks.d.ts +152 -0
  255. package/types/client/src/api/modules/client.d.ts +38 -0
  256. package/types/client/src/api/modules/ids.d.ts +3 -0
  257. package/types/client/src/api/modules/index.d.ts +5 -0
  258. package/types/client/src/api/modules/module-api.d.ts +23 -0
  259. package/types/client/src/api/modules/schemas.d.ts +74 -0
  260. package/types/client/src/api/modules/store.d.ts +226 -0
  261. package/types/client/src/api/notifications/capability.d.ts +36 -0
  262. package/types/client/src/api/notifications/client.d.ts +79 -0
  263. package/types/client/src/api/notifications/ids.d.ts +3 -0
  264. package/types/client/src/api/notifications/index.d.ts +4 -0
  265. package/types/client/src/api/notifications/push.d.ts +18 -0
  266. package/types/client/src/api/notifications/schemas.d.ts +235 -0
  267. package/types/client/src/api/pipeline/client.d.ts +126 -0
  268. package/types/client/src/api/pipeline/index.d.ts +2 -0
  269. package/types/client/src/api/pipeline/schemas.d.ts +139 -0
  270. package/types/client/src/api/playback/client.d.ts +681 -0
  271. package/types/client/src/api/playback/ids.d.ts +3 -0
  272. package/types/client/src/api/playback/index.d.ts +3 -0
  273. package/types/client/src/api/playback/schemas.d.ts +38 -0
  274. package/types/client/src/api/reports/client.d.ts +117 -0
  275. package/types/client/src/api/reports/ids.d.ts +3 -0
  276. package/types/client/src/api/reports/index.d.ts +3 -0
  277. package/types/client/src/api/reports/schemas.d.ts +144 -0
  278. package/types/client/src/api/requests/acquisition.d.ts +240 -0
  279. package/types/client/src/api/requests/client.d.ts +301 -0
  280. package/types/client/src/api/requests/ids.d.ts +7 -0
  281. package/types/client/src/api/requests/index.d.ts +4 -0
  282. package/types/client/src/api/requests/schemas.d.ts +162 -0
  283. package/types/client/src/api/subtitles/client.d.ts +48 -0
  284. package/types/client/src/api/subtitles/ids.d.ts +5 -0
  285. package/types/client/src/api/subtitles/index.d.ts +3 -0
  286. package/types/client/src/api/subtitles/schemas.d.ts +78 -0
  287. package/types/client/src/core/client.d.ts +17 -0
  288. package/types/client/src/core/http/api-error.d.ts +36 -0
  289. package/types/client/src/core/http/body.d.ts +1 -0
  290. package/types/client/src/core/http/concurrency.d.ts +8 -0
  291. package/types/client/src/core/http/index.d.ts +6 -0
  292. package/types/client/src/core/http/path.d.ts +10 -0
  293. package/types/client/src/core/http/preconnect.d.ts +2 -0
  294. package/types/client/src/core/http/query.d.ts +9 -0
  295. package/types/client/src/core/http/request-context.d.ts +94 -0
  296. package/types/client/src/core/http/user-agent.d.ts +7 -0
  297. package/types/client/src/core/ids/ids.d.ts +13 -0
  298. package/types/client/src/core/ids/index.d.ts +1 -0
  299. package/types/client/src/core/index.d.ts +4 -0
  300. package/types/client/src/core/session/index.d.ts +3 -0
  301. package/types/client/src/core/session/locale.d.ts +6 -0
  302. package/types/client/src/core/session/storage.d.ts +32 -0
  303. package/types/client/src/core/session/token.d.ts +19 -0
  304. package/types/client/src/index.d.ts +3 -0
  305. package/types/client/src/kroma-client.d.ts +49 -0
  306. package/types/client/src/query/index.d.ts +35 -0
  307. package/types/core/src/airdate.d.ts +21 -0
  308. package/types/core/src/browse.d.ts +45 -0
  309. package/types/core/src/compat.d.ts +9 -0
  310. package/types/core/src/discover.d.ts +31 -0
  311. package/types/core/src/format.d.ts +63 -0
  312. package/types/core/src/genre-art.d.ts +21 -0
  313. package/types/core/src/genre-table.d.ts +117 -0
  314. package/types/core/src/genre.d.ts +42 -0
  315. package/types/core/src/handoff/beacon.d.ts +39 -0
  316. package/types/core/src/handoff/grant.d.ts +20 -0
  317. package/types/core/src/handoff/index.d.ts +8 -0
  318. package/types/core/src/handoff/nearby.d.ts +17 -0
  319. package/types/core/src/handoff/sources.d.ts +110 -0
  320. package/types/core/src/health-probe.d.ts +19 -0
  321. package/types/core/src/hevc/audio-support.d.ts +47 -0
  322. package/types/core/src/hevc/capabilities.d.ts +63 -0
  323. package/types/core/src/hevc/directplay.d.ts +70 -0
  324. package/types/core/src/hevc/engine.d.ts +29 -0
  325. package/types/core/src/hevc.d.ts +4 -0
  326. package/types/core/src/i18n.d.ts +2381 -0
  327. package/types/core/src/index.d.ts +25 -0
  328. package/types/core/src/intl.d.ts +28 -0
  329. package/types/core/src/lang-table.d.ts +11 -0
  330. package/types/core/src/lang.d.ts +59 -0
  331. package/types/core/src/local-ip.d.ts +2 -0
  332. package/types/core/src/locales/catalogs.d.ts +2 -0
  333. package/types/core/src/locales/catalogs.web.d.ts +3 -0
  334. package/types/core/src/locales/default-locale.d.ts +3 -0
  335. package/types/core/src/match.d.ts +14 -0
  336. package/types/core/src/notification-labels.d.ts +47 -0
  337. package/types/core/src/people.d.ts +33 -0
  338. package/types/core/src/permissions.d.ts +10 -0
  339. package/types/core/src/person-facts.d.ts +23 -0
  340. package/types/core/src/platform.d.ts +7 -0
  341. package/types/core/src/playback-buffer.d.ts +64 -0
  342. package/types/core/src/playback-stall.d.ts +86 -0
  343. package/types/core/src/player.d.ts +22 -0
  344. package/types/core/src/push-labels.d.ts +6 -0
  345. package/types/core/src/react/handoff-picker.d.ts +52 -0
  346. package/types/core/src/react/index.d.ts +6 -0
  347. package/types/core/src/react/lang-prefs.d.ts +35 -0
  348. package/types/core/src/react/nearby-tvs.d.ts +31 -0
  349. package/types/core/src/remote.d.ts +26 -0
  350. package/types/core/src/server-origin.d.ts +12 -0
  351. package/types/core/src/slug.d.ts +4 -0
  352. package/types/core/src/subtitles.d.ts +20 -0
  353. package/types/i18n/src/announce.d.ts +15 -0
  354. package/types/i18n/src/catalog-types.d.ts +7 -0
  355. package/types/i18n/src/chain.d.ts +22 -0
  356. package/types/i18n/src/define.d.ts +39 -0
  357. package/types/i18n/src/dev-overrides.d.ts +39 -0
  358. package/types/i18n/src/i18n.d.ts +61 -0
  359. package/types/i18n/src/index.d.ts +11 -0
  360. package/types/i18n/src/interpolate.d.ts +14 -0
  361. package/types/i18n/src/layout.d.ts +18 -0
  362. package/types/i18n/src/locales.d.ts +12 -0
  363. package/types/i18n/src/namespaces.d.ts +37 -0
  364. package/types/i18n/src/nest.d.ts +17 -0
  365. package/types/i18n/src/plural.d.ts +20 -0
  366. package/types/i18n/src/react/context.d.ts +37 -0
  367. package/types/i18n/src/react/index.d.ts +2 -0
  368. package/types/i18n/src/react/provider.d.ts +14 -0
  369. package/types/i18n/src/registry.d.ts +36 -0
  370. package/types/i18n/src/store.d.ts +46 -0
  371. package/types/i18n/src/types.d.ts +30 -0
  372. package/types/module-sdk/src/admin/context.d.ts +20 -0
  373. package/types/module-sdk/src/admin/denied.d.ts +1 -0
  374. package/types/module-sdk/src/admin/engines.d.ts +35 -0
  375. package/types/module-sdk/src/admin/hooks.d.ts +39 -0
  376. package/types/module-sdk/src/admin/page-states.d.ts +27 -0
  377. package/types/module-sdk/src/admin/settings.d.ts +9 -0
  378. package/types/module-sdk/src/bus.d.ts +8 -0
  379. package/types/module-sdk/src/contracts.d.ts +6 -0
  380. package/types/module-sdk/src/define.d.ts +38 -0
  381. package/types/module-sdk/src/events.d.ts +11 -0
  382. package/types/module-sdk/src/host.d.ts +32 -0
  383. package/types/module-sdk/src/icon.d.ts +1 -0
  384. package/types/module-sdk/src/index.d.ts +35 -0
  385. package/types/module-sdk/src/module.d.ts +83 -0
  386. package/types/module-sdk/src/registry.d.ts +63 -0
  387. package/types/module-sdk/src/scope.d.ts +23 -0
  388. package/types/module-sdk/src/shared.d.ts +21 -0
  389. package/types/module-sdk/src/slot.d.ts +34 -0
  390. package/types/module-sdk/src/types.d.ts +39 -0
  391. package/types/module-sdk/src/ui/table.d.ts +88 -0
  392. package/types/module-sdk/src/use-sorted-table.d.ts +56 -0
  393. package/types/registry/src/build.d.ts +16 -0
  394. package/types/registry/src/client.d.ts +23 -0
  395. package/types/registry/src/documents/index.d.ts +6 -0
  396. package/types/registry/src/documents/v1.d.ts +197 -0
  397. package/types/registry/src/index.d.ts +7 -0
  398. package/types/registry/src/manifest/index.d.ts +9 -0
  399. package/types/registry/src/manifest/v2.d.ts +182 -0
  400. package/types/registry/src/semver.d.ts +24 -0
  401. package/types/registry/src/sort.d.ts +2 -0
  402. package/types/registry/src/spec.d.ts +19 -0
  403. package/types/registry/src/text.d.ts +6 -0
  404. package/types/spatial-nav/src/descent.d.ts +9 -0
  405. package/types/spatial-nav/src/directions.d.ts +16 -0
  406. package/types/spatial-nav/src/fallback-focus.d.ts +5 -0
  407. package/types/spatial-nav/src/focus-owner.d.ts +16 -0
  408. package/types/spatial-nav/src/focus-tree.d.ts +63 -0
  409. package/types/spatial-nav/src/index.d.ts +4 -0
  410. package/types/spatial-nav/src/navigator.bench.d.ts +1 -0
  411. package/types/spatial-nav/src/react/configure-remote.d.ts +16 -0
  412. package/types/spatial-nav/src/react/default-focus.d.ts +15 -0
  413. package/types/spatial-nav/src/react/focus-queue.d.ts +16 -0
  414. package/types/spatial-nav/src/react/navigator-context.d.ts +19 -0
  415. package/types/spatial-nav/src/react/navigator-item.d.ts +28 -0
  416. package/types/spatial-nav/src/react/navigator-node.d.ts +27 -0
  417. package/types/spatial-nav/src/react/navigator-root.d.ts +19 -0
  418. package/types/spatial-nav/src/react/navigator-view.d.ts +18 -0
  419. package/types/spatial-nav/src/react/pointer-device.d.ts +14 -0
  420. package/types/spatial-nav/src/react/spatial-node.d.ts +27 -0
  421. package/types/spatial-nav/src/react/use-lock-navigator.d.ts +11 -0
  422. package/types/spatial-nav/src/react.d.ts +17 -0
  423. package/types/spatial-nav/src/resolve-move.d.ts +6 -0
  424. package/types/spatial-nav/src/spatial-navigator.d.ts +23 -0
  425. package/types/ui/src/assets/fonts.d.ts +4 -0
  426. package/types/ui/src/components/atoms/art-scrim/art-scrim.d.ts +21 -0
  427. package/types/ui/src/components/atoms/art-scrim/index.d.ts +1 -0
  428. package/types/ui/src/components/atoms/avatar/avatar.d.ts +43 -0
  429. package/types/ui/src/components/atoms/avatar/index.d.ts +1 -0
  430. package/types/ui/src/components/atoms/badge/badge.d.ts +116 -0
  431. package/types/ui/src/components/atoms/badge/index.d.ts +1 -0
  432. package/types/ui/src/components/atoms/box/box.d.ts +29 -0
  433. package/types/ui/src/components/atoms/box/index.d.ts +1 -0
  434. package/types/ui/src/components/atoms/button/button-variants.d.ts +216 -0
  435. package/types/ui/src/components/atoms/button/button.d.ts +37 -0
  436. package/types/ui/src/components/atoms/button/index.d.ts +1 -0
  437. package/types/ui/src/components/atoms/checkbox/checkbox.d.ts +62 -0
  438. package/types/ui/src/components/atoms/checkbox/index.d.ts +1 -0
  439. package/types/ui/src/components/atoms/chip/chip.d.ts +172 -0
  440. package/types/ui/src/components/atoms/chip/index.d.ts +1 -0
  441. package/types/ui/src/components/atoms/divider/divider.d.ts +13 -0
  442. package/types/ui/src/components/atoms/divider/index.d.ts +1 -0
  443. package/types/ui/src/components/atoms/expandable-text/expandable-text.d.ts +20 -0
  444. package/types/ui/src/components/atoms/expandable-text/index.d.ts +1 -0
  445. package/types/ui/src/components/atoms/focusable/focusable-a11y.d.ts +12 -0
  446. package/types/ui/src/components/atoms/focusable/focusable-delegate.d.ts +21 -0
  447. package/types/ui/src/components/atoms/focusable/focusable-forms.d.ts +62 -0
  448. package/types/ui/src/components/atoms/focusable/focusable-link.d.ts +7 -0
  449. package/types/ui/src/components/atoms/focusable/focusable-paint.d.ts +47 -0
  450. package/types/ui/src/components/atoms/focusable/focusable-types.d.ts +167 -0
  451. package/types/ui/src/components/atoms/focusable/focusable.d.ts +7 -0
  452. package/types/ui/src/components/atoms/focusable/index.d.ts +1 -0
  453. package/types/ui/src/components/atoms/focusable/touch-pressable.d.ts +35 -0
  454. package/types/ui/src/components/atoms/focusable/use-entry-focus.d.ts +9 -0
  455. package/types/ui/src/components/atoms/focusable/use-web-keys.d.ts +7 -0
  456. package/types/ui/src/components/atoms/frost/frost.d.ts +62 -0
  457. package/types/ui/src/components/atoms/frost/index.d.ts +1 -0
  458. package/types/ui/src/components/atoms/grid/grid.d.ts +28 -0
  459. package/types/ui/src/components/atoms/grid/index.d.ts +1 -0
  460. package/types/ui/src/components/atoms/ground/ground.d.ts +19 -0
  461. package/types/ui/src/components/atoms/ground/index.d.ts +1 -0
  462. package/types/ui/src/components/atoms/icon/icon.d.ts +4 -0
  463. package/types/ui/src/components/atoms/icon/index.d.ts +1 -0
  464. package/types/ui/src/components/atoms/icon-button/icon-button.d.ts +165 -0
  465. package/types/ui/src/components/atoms/icon-button/index.d.ts +1 -0
  466. package/types/ui/src/components/atoms/icon-well/icon-well.d.ts +46 -0
  467. package/types/ui/src/components/atoms/icon-well/index.d.ts +1 -0
  468. package/types/ui/src/components/atoms/img/img.d.ts +45 -0
  469. package/types/ui/src/components/atoms/img/index.d.ts +1 -0
  470. package/types/ui/src/components/atoms/img/native-layers.d.ts +28 -0
  471. package/types/ui/src/components/atoms/img/use-cross-fade.d.ts +9 -0
  472. package/types/ui/src/components/atoms/img/web-layers.d.ts +19 -0
  473. package/types/ui/src/components/atoms/index.d.ts +64 -0
  474. package/types/ui/src/components/atoms/kbd/index.d.ts +2 -0
  475. package/types/ui/src/components/atoms/kbd/kbd.d.ts +18 -0
  476. package/types/ui/src/components/atoms/logo/index.d.ts +1 -0
  477. package/types/ui/src/components/atoms/logo/logo.d.ts +11 -0
  478. package/types/ui/src/components/atoms/number-field/index.d.ts +1 -0
  479. package/types/ui/src/components/atoms/number-field/number-field.d.ts +11 -0
  480. package/types/ui/src/components/atoms/progress/index.d.ts +1 -0
  481. package/types/ui/src/components/atoms/progress/progress.d.ts +28 -0
  482. package/types/ui/src/components/atoms/progress-ring/index.d.ts +1 -0
  483. package/types/ui/src/components/atoms/progress-ring/progress-ring.d.ts +7 -0
  484. package/types/ui/src/components/atoms/radio/index.d.ts +1 -0
  485. package/types/ui/src/components/atoms/radio/radio.d.ts +76 -0
  486. package/types/ui/src/components/atoms/skeleton/card-skeleton.d.ts +6 -0
  487. package/types/ui/src/components/atoms/skeleton/index.d.ts +4 -0
  488. package/types/ui/src/components/atoms/skeleton/poster-skeleton.d.ts +7 -0
  489. package/types/ui/src/components/atoms/skeleton/skeleton.d.ts +20 -0
  490. package/types/ui/src/components/atoms/skeleton/table-skeleton.d.ts +6 -0
  491. package/types/ui/src/components/atoms/spinner/index.d.ts +1 -0
  492. package/types/ui/src/components/atoms/spinner/spinner.d.ts +14 -0
  493. package/types/ui/src/components/atoms/status-dot/index.d.ts +1 -0
  494. package/types/ui/src/components/atoms/status-dot/status-dot.d.ts +9 -0
  495. package/types/ui/src/components/atoms/surface/index.d.ts +1 -0
  496. package/types/ui/src/components/atoms/surface/surface.d.ts +56 -0
  497. package/types/ui/src/components/atoms/switch/index.d.ts +1 -0
  498. package/types/ui/src/components/atoms/switch/switch.d.ts +64 -0
  499. package/types/ui/src/components/atoms/text/index.d.ts +1 -0
  500. package/types/ui/src/components/atoms/text/text.d.ts +21 -0
  501. package/types/ui/src/components/atoms/text-area/index.d.ts +1 -0
  502. package/types/ui/src/components/atoms/text-area/text-area.d.ts +31 -0
  503. package/types/ui/src/components/atoms/text-field/index.d.ts +1 -0
  504. package/types/ui/src/components/atoms/text-field/text-field.d.ts +50 -0
  505. package/types/ui/src/components/atoms/watched-badge/index.d.ts +1 -0
  506. package/types/ui/src/components/atoms/watched-badge/watched-badge.d.ts +19 -0
  507. package/types/ui/src/components/atoms/wheel/index.d.ts +1 -0
  508. package/types/ui/src/components/atoms/wheel/wheel.d.ts +9 -0
  509. package/types/ui/src/components/common/if/if.d.ts +9 -0
  510. package/types/ui/src/components/common/if/index.d.ts +1 -0
  511. package/types/ui/src/components/common/index.d.ts +2 -0
  512. package/types/ui/src/components/molecules/add-tile/add-tile.d.ts +65 -0
  513. package/types/ui/src/components/molecules/add-tile/index.d.ts +2 -0
  514. package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-context.d.ts +20 -0
  515. package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-item.d.ts +13 -0
  516. package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail-lens.d.ts +17 -0
  517. package/types/ui/src/components/molecules/alphabet-rail/alphabet-rail.d.ts +46 -0
  518. package/types/ui/src/components/molecules/alphabet-rail/index.d.ts +2 -0
  519. package/types/ui/src/components/molecules/alphabet-rail/use-letter-scrub.d.ts +17 -0
  520. package/types/ui/src/components/molecules/back-button/back-button.d.ts +10 -0
  521. package/types/ui/src/components/molecules/back-button/index.d.ts +1 -0
  522. package/types/ui/src/components/molecules/button-group/button-group.d.ts +37 -0
  523. package/types/ui/src/components/molecules/button-group/index.d.ts +3 -0
  524. package/types/ui/src/components/molecules/callout/callout.d.ts +63 -0
  525. package/types/ui/src/components/molecules/callout/index.d.ts +1 -0
  526. package/types/ui/src/components/molecules/category-tile/category-tile.d.ts +65 -0
  527. package/types/ui/src/components/molecules/category-tile/index.d.ts +1 -0
  528. package/types/ui/src/components/molecules/choice-list/choice-list.d.ts +53 -0
  529. package/types/ui/src/components/molecules/choice-list/index.d.ts +1 -0
  530. package/types/ui/src/components/molecules/copy-button/copy-button.d.ts +19 -0
  531. package/types/ui/src/components/molecules/copy-button/index.d.ts +1 -0
  532. package/types/ui/src/components/molecules/data-field/data-field.d.ts +44 -0
  533. package/types/ui/src/components/molecules/data-field/index.d.ts +1 -0
  534. package/types/ui/src/components/molecules/disclosure/disclosure.d.ts +55 -0
  535. package/types/ui/src/components/molecules/disclosure/index.d.ts +1 -0
  536. package/types/ui/src/components/molecules/dropzone/dropzone-parts.d.ts +46 -0
  537. package/types/ui/src/components/molecules/dropzone/dropzone-sift.d.ts +6 -0
  538. package/types/ui/src/components/molecules/dropzone/dropzone.d.ts +21 -0
  539. package/types/ui/src/components/molecules/dropzone/dropzone.web.d.ts +11 -0
  540. package/types/ui/src/components/molecules/dropzone/index.d.ts +1 -0
  541. package/types/ui/src/components/molecules/empty-state/empty-state.d.ts +60 -0
  542. package/types/ui/src/components/molecules/empty-state/index.d.ts +1 -0
  543. package/types/ui/src/components/molecules/field/field.d.ts +56 -0
  544. package/types/ui/src/components/molecules/field/index.d.ts +1 -0
  545. package/types/ui/src/components/molecules/hint/hint.d.ts +23 -0
  546. package/types/ui/src/components/molecules/hint/index.d.ts +1 -0
  547. package/types/ui/src/components/molecules/index.d.ts +70 -0
  548. package/types/ui/src/components/molecules/input-group/index.d.ts +3 -0
  549. package/types/ui/src/components/molecules/input-group/input-group-context.d.ts +34 -0
  550. package/types/ui/src/components/molecules/input-group/input-group-parts.d.ts +31 -0
  551. package/types/ui/src/components/molecules/input-group/input-group.d.ts +38 -0
  552. package/types/ui/src/components/molecules/keypad/index.d.ts +1 -0
  553. package/types/ui/src/components/molecules/keypad/keypad.d.ts +44 -0
  554. package/types/ui/src/components/molecules/legend/index.d.ts +1 -0
  555. package/types/ui/src/components/molecules/legend/legend.d.ts +32 -0
  556. package/types/ui/src/components/molecules/list/index.d.ts +1 -0
  557. package/types/ui/src/components/molecules/list/list.d.ts +41 -0
  558. package/types/ui/src/components/molecules/list-row/index.d.ts +3 -0
  559. package/types/ui/src/components/molecules/list-row/list-group.d.ts +23 -0
  560. package/types/ui/src/components/molecules/list-row/list-row-context.d.ts +10 -0
  561. package/types/ui/src/components/molecules/list-row/list-row-parts.d.ts +28 -0
  562. package/types/ui/src/components/molecules/list-row/list-row-variants.d.ts +90 -0
  563. package/types/ui/src/components/molecules/list-row/list-row.d.ts +51 -0
  564. package/types/ui/src/components/molecules/media-card/index.d.ts +1 -0
  565. package/types/ui/src/components/molecules/media-card/media-card.d.ts +22 -0
  566. package/types/ui/src/components/molecules/nav-pill/index.d.ts +1 -0
  567. package/types/ui/src/components/molecules/nav-pill/nav-pill-context.d.ts +28 -0
  568. package/types/ui/src/components/molecules/nav-pill/nav-pill-item.d.ts +101 -0
  569. package/types/ui/src/components/molecules/nav-pill/nav-pill-lens.d.ts +8 -0
  570. package/types/ui/src/components/molecules/nav-pill/nav-pill.d.ts +55 -0
  571. package/types/ui/src/components/molecules/otp-field/index.d.ts +1 -0
  572. package/types/ui/src/components/molecules/otp-field/otp-field-context.d.ts +32 -0
  573. package/types/ui/src/components/molecules/otp-field/otp-field-parts.d.ts +18 -0
  574. package/types/ui/src/components/molecules/otp-field/otp-field-variants.d.ts +68 -0
  575. package/types/ui/src/components/molecules/otp-field/otp-field.d.ts +57 -0
  576. package/types/ui/src/components/molecules/page-header/index.d.ts +1 -0
  577. package/types/ui/src/components/molecules/page-header/page-header.d.ts +69 -0
  578. package/types/ui/src/components/molecules/pagination/index.d.ts +3 -0
  579. package/types/ui/src/components/molecules/pagination/pagination.d.ts +102 -0
  580. package/types/ui/src/components/molecules/pagination/paging.d.ts +24 -0
  581. package/types/ui/src/components/molecules/person-card/index.d.ts +1 -0
  582. package/types/ui/src/components/molecules/person-card/person-card.d.ts +58 -0
  583. package/types/ui/src/components/molecules/pin-field/index.d.ts +1 -0
  584. package/types/ui/src/components/molecules/pin-field/pin-field.d.ts +26 -0
  585. package/types/ui/src/components/molecules/poster-card/index.d.ts +1 -0
  586. package/types/ui/src/components/molecules/poster-card/poster-card.d.ts +22 -0
  587. package/types/ui/src/components/molecules/section/index.d.ts +1 -0
  588. package/types/ui/src/components/molecules/section/section.d.ts +54 -0
  589. package/types/ui/src/components/molecules/segment-group/index.d.ts +2 -0
  590. package/types/ui/src/components/molecules/segment-group/segment-group-context.d.ts +17 -0
  591. package/types/ui/src/components/molecules/segment-group/segment-group-item.d.ts +58 -0
  592. package/types/ui/src/components/molecules/segment-group/segment-group.d.ts +29 -0
  593. package/types/ui/src/components/molecules/select/index.d.ts +1 -0
  594. package/types/ui/src/components/molecules/select/select-context.d.ts +54 -0
  595. package/types/ui/src/components/molecules/select/select-item.d.ts +39 -0
  596. package/types/ui/src/components/molecules/select/select-options-dialog.d.ts +3 -0
  597. package/types/ui/src/components/molecules/select/select-options.d.ts +3 -0
  598. package/types/ui/src/components/molecules/select/select-selection.d.ts +24 -0
  599. package/types/ui/src/components/molecules/select/select-surface.d.ts +17 -0
  600. package/types/ui/src/components/molecules/select/select.d.ts +112 -0
  601. package/types/ui/src/components/molecules/stat-card/index.d.ts +1 -0
  602. package/types/ui/src/components/molecules/stat-card/stat-card.d.ts +46 -0
  603. package/types/ui/src/components/molecules/stepper/index.d.ts +1 -0
  604. package/types/ui/src/components/molecules/stepper/stepper-context.d.ts +44 -0
  605. package/types/ui/src/components/molecules/stepper/stepper-item.d.ts +110 -0
  606. package/types/ui/src/components/molecules/stepper/stepper-list.d.ts +12 -0
  607. package/types/ui/src/components/molecules/stepper/stepper.d.ts +97 -0
  608. package/types/ui/src/components/molecules/stepper/use-steps.d.ts +40 -0
  609. package/types/ui/src/components/molecules/theme-switch/index.d.ts +1 -0
  610. package/types/ui/src/components/molecules/theme-switch/theme-switch.d.ts +19 -0
  611. package/types/ui/src/components/molecules/timeline/index.d.ts +1 -0
  612. package/types/ui/src/components/molecules/timeline/timeline.d.ts +55 -0
  613. package/types/ui/src/components/molecules/tooltip/index.d.ts +1 -0
  614. package/types/ui/src/components/molecules/tooltip/tooltip.d.ts +9 -0
  615. package/types/ui/src/components/molecules/tooltip/tooltip.web.d.ts +4 -0
  616. package/types/ui/src/components/organisms/chart/chart-context.d.ts +38 -0
  617. package/types/ui/src/components/organisms/chart/chart-marks.d.ts +32 -0
  618. package/types/ui/src/components/organisms/chart/chart-parts.d.ts +41 -0
  619. package/types/ui/src/components/organisms/chart/chart-path.d.ts +28 -0
  620. package/types/ui/src/components/organisms/chart/chart-scale.d.ts +82 -0
  621. package/types/ui/src/components/organisms/chart/chart.d.ts +63 -0
  622. package/types/ui/src/components/organisms/chart/index.d.ts +5 -0
  623. package/types/ui/src/components/organisms/code-block/code-block.d.ts +23 -0
  624. package/types/ui/src/components/organisms/code-block/code-tokens.d.ts +15 -0
  625. package/types/ui/src/components/organisms/code-block/index.d.ts +1 -0
  626. package/types/ui/src/components/organisms/command/command-context.d.ts +31 -0
  627. package/types/ui/src/components/organisms/command/command-keys-types.d.ts +11 -0
  628. package/types/ui/src/components/organisms/command/command-keys.d.ts +3 -0
  629. package/types/ui/src/components/organisms/command/command-keys.web.d.ts +3 -0
  630. package/types/ui/src/components/organisms/command/command-list.d.ts +46 -0
  631. package/types/ui/src/components/organisms/command/command-parts.d.ts +24 -0
  632. package/types/ui/src/components/organisms/command/command-row.d.ts +15 -0
  633. package/types/ui/src/components/organisms/command/command.d.ts +45 -0
  634. package/types/ui/src/components/organisms/command/index.d.ts +7 -0
  635. package/types/ui/src/components/organisms/dialog/confirm-dialog/confirm-dialog.d.ts +12 -0
  636. package/types/ui/src/components/organisms/dialog/confirm-dialog/confirm.d.ts +16 -0
  637. package/types/ui/src/components/organisms/dialog/confirm-dialog/index.d.ts +2 -0
  638. package/types/ui/src/components/organisms/dialog/dialog-actions.d.ts +29 -0
  639. package/types/ui/src/components/organisms/dialog/dialog-parts.d.ts +20 -0
  640. package/types/ui/src/components/organisms/dialog/dialog.d.ts +55 -0
  641. package/types/ui/src/components/organisms/dialog/index.d.ts +3 -0
  642. package/types/ui/src/components/organisms/drawer/drawer-parts.d.ts +29 -0
  643. package/types/ui/src/components/organisms/drawer/drawer-slide.d.ts +20 -0
  644. package/types/ui/src/components/organisms/drawer/drawer.d.ts +64 -0
  645. package/types/ui/src/components/organisms/drawer/index.d.ts +2 -0
  646. package/types/ui/src/components/organisms/index.d.ts +31 -0
  647. package/types/ui/src/components/organisms/keyboard/index.d.ts +8 -0
  648. package/types/ui/src/components/organisms/keyboard/key.d.ts +57 -0
  649. package/types/ui/src/components/organisms/keyboard/keyboard-layouts.d.ts +27 -0
  650. package/types/ui/src/components/organisms/keyboard/search-keyboard/index.d.ts +1 -0
  651. package/types/ui/src/components/organisms/keyboard/search-keyboard/search-keyboard.d.ts +19 -0
  652. package/types/ui/src/components/organisms/keyboard/url-keyboard/index.d.ts +1 -0
  653. package/types/ui/src/components/organisms/keyboard/url-keyboard/url-keyboard.d.ts +20 -0
  654. package/types/ui/src/components/organisms/keyboard/use-physical-typing.d.ts +2 -0
  655. package/types/ui/src/components/organisms/kroma-intro/animations.d.ts +2 -0
  656. package/types/ui/src/components/organisms/kroma-intro/constants.d.ts +14 -0
  657. package/types/ui/src/components/organisms/kroma-intro/css-intro.d.ts +12 -0
  658. package/types/ui/src/components/organisms/kroma-intro/index.d.ts +3 -0
  659. package/types/ui/src/components/organisms/kroma-intro/intro-scene.d.ts +21 -0
  660. package/types/ui/src/components/organisms/kroma-intro/intro-shell.d.ts +10 -0
  661. package/types/ui/src/components/organisms/kroma-intro/kroma-intro.d.ts +3 -0
  662. package/types/ui/src/components/organisms/kroma-intro/kroma-intro.web.d.ts +33 -0
  663. package/types/ui/src/components/organisms/kroma-intro/use-intro-exit.d.ts +21 -0
  664. package/types/ui/src/components/organisms/kroma-intro/use-intro-keys.d.ts +19 -0
  665. package/types/ui/src/components/organisms/menu/index.d.ts +1 -0
  666. package/types/ui/src/components/organisms/menu/menu-context.d.ts +32 -0
  667. package/types/ui/src/components/organisms/menu/menu-item.d.ts +57 -0
  668. package/types/ui/src/components/organisms/menu/menu-surface-dialog.d.ts +25 -0
  669. package/types/ui/src/components/organisms/menu/menu-surface.d.ts +3 -0
  670. package/types/ui/src/components/organisms/menu/menu.d.ts +49 -0
  671. package/types/ui/src/components/organisms/nearby-tv-list/index.d.ts +2 -0
  672. package/types/ui/src/components/organisms/nearby-tv-list/nearby-tv-list.d.ts +12 -0
  673. package/types/ui/src/components/organisms/perf-hud/index.d.ts +1 -0
  674. package/types/ui/src/components/organisms/perf-hud/perf-chart.d.ts +5 -0
  675. package/types/ui/src/components/organisms/perf-hud/perf-hud.d.ts +4 -0
  676. package/types/ui/src/components/organisms/player/hooks/use-drag-track.d.ts +22 -0
  677. package/types/ui/src/components/organisms/player/hooks/use-grid-focus.d.ts +19 -0
  678. package/types/ui/src/components/organisms/player/hooks/use-idle-cursor.d.ts +7 -0
  679. package/types/ui/src/components/organisms/player/hooks/use-list-focus.d.ts +40 -0
  680. package/types/ui/src/components/organisms/player/hooks/use-player-credits.d.ts +22 -0
  681. package/types/ui/src/components/organisms/player/hooks/use-player-ending.d.ts +37 -0
  682. package/types/ui/src/components/organisms/player/hooks/use-player-keys.d.ts +8 -0
  683. package/types/ui/src/components/organisms/player/hooks/use-player-keys.web.d.ts +5 -0
  684. package/types/ui/src/components/organisms/player/hooks/use-player-nav.d.ts +58 -0
  685. package/types/ui/src/components/organisms/player/hooks/use-player-outro.d.ts +14 -0
  686. package/types/ui/src/components/organisms/player/hooks/use-seek-nudge.d.ts +8 -0
  687. package/types/ui/src/components/organisms/player/index.d.ts +22 -0
  688. package/types/ui/src/components/organisms/player/lib/audio-filter.d.ts +15 -0
  689. package/types/ui/src/components/organisms/player/lib/chapters.d.ts +16 -0
  690. package/types/ui/src/components/organisms/player/lib/chart-geometry.d.ts +46 -0
  691. package/types/ui/src/components/organisms/player/lib/fmt.d.ts +19 -0
  692. package/types/ui/src/components/organisms/player/lib/lean-stats.d.ts +34 -0
  693. package/types/ui/src/components/organisms/player/lib/metrics.d.ts +40 -0
  694. package/types/ui/src/components/organisms/player/lib/nav-keys.d.ts +19 -0
  695. package/types/ui/src/components/organisms/player/lib/nav.d.ts +38 -0
  696. package/types/ui/src/components/organisms/player/lib/panel-header.d.ts +12 -0
  697. package/types/ui/src/components/organisms/player/lib/panel-slide.d.ts +16 -0
  698. package/types/ui/src/components/organisms/player/lib/player-keys.d.ts +44 -0
  699. package/types/ui/src/components/organisms/player/lib/seek-track.d.ts +19 -0
  700. package/types/ui/src/components/organisms/player/lib/stage-card.d.ts +31 -0
  701. package/types/ui/src/components/organisms/player/lib/stage-ratio.d.ts +4 -0
  702. package/types/ui/src/components/organisms/player/lib/stage-ratio.web.d.ts +2 -0
  703. package/types/ui/src/components/organisms/player/lib/style.d.ts +40 -0
  704. package/types/ui/src/components/organisms/player/lib/styles.d.ts +3 -0
  705. package/types/ui/src/components/organisms/player/lib/subtitle-appearance.d.ts +53 -0
  706. package/types/ui/src/components/organisms/player/lib/subtitle-edge.d.ts +3 -0
  707. package/types/ui/src/components/organisms/player/lib/subtitle-edge.web.d.ts +3 -0
  708. package/types/ui/src/components/organisms/player/lib/surface-shrink.d.ts +17 -0
  709. package/types/ui/src/components/organisms/player/lib/virtual-focus.d.ts +2 -0
  710. package/types/ui/src/components/organisms/player/lib/virtual-focus.web.d.ts +3 -0
  711. package/types/ui/src/components/organisms/player/parts/control-cluster/control-cluster.d.ts +32 -0
  712. package/types/ui/src/components/organisms/player/parts/control-cluster/index.d.ts +1 -0
  713. package/types/ui/src/components/organisms/player/parts/credits-card/credits-card.d.ts +25 -0
  714. package/types/ui/src/components/organisms/player/parts/credits-card/index.d.ts +1 -0
  715. package/types/ui/src/components/organisms/player/parts/icons.d.ts +39 -0
  716. package/types/ui/src/components/organisms/player/parts/post-play/index.d.ts +1 -0
  717. package/types/ui/src/components/organisms/player/parts/post-play/post-play.d.ts +41 -0
  718. package/types/ui/src/components/organisms/player/parts/post-play/rise.d.ts +12 -0
  719. package/types/ui/src/components/organisms/player/parts/post-play/rise.web.d.ts +10 -0
  720. package/types/ui/src/components/organisms/player/parts/seek-bar/index.d.ts +1 -0
  721. package/types/ui/src/components/organisms/player/parts/seek-bar/seek-bar.d.ts +22 -0
  722. package/types/ui/src/components/organisms/player/parts/settings-panel/index.d.ts +1 -0
  723. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/audio-filter-panel.d.ts +11 -0
  724. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/audio-panel.d.ts +11 -0
  725. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/entries.d.ts +35 -0
  726. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/gen.d.ts +24 -0
  727. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/generate-wizard.d.ts +18 -0
  728. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/menu-list.d.ts +9 -0
  729. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/menu-row.d.ts +15 -0
  730. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/panel-style.d.ts +99 -0
  731. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/quality-panel.d.ts +16 -0
  732. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/report-panel.d.ts +8 -0
  733. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/select-row.d.ts +21 -0
  734. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/speed-panel.d.ts +10 -0
  735. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/sub-view.d.ts +16 -0
  736. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitle-appearance-panel.d.ts +14 -0
  737. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitle-appearance-parts.d.ts +27 -0
  738. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/subtitles-panel.d.ts +18 -0
  739. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/title-bar.d.ts +9 -0
  740. package/types/ui/src/components/organisms/player/parts/settings-panel/settings/wizard-parts.d.ts +8 -0
  741. package/types/ui/src/components/organisms/player/parts/settings-panel/settings-panel.d.ts +40 -0
  742. package/types/ui/src/components/organisms/player/parts/skip-intro-button/index.d.ts +1 -0
  743. package/types/ui/src/components/organisms/player/parts/skip-intro-button/skip-intro-button.d.ts +22 -0
  744. package/types/ui/src/components/organisms/player/parts/stage/index.d.ts +1 -0
  745. package/types/ui/src/components/organisms/player/parts/stage/stage-overlay.d.ts +13 -0
  746. package/types/ui/src/components/organisms/player/parts/stage/stage.d.ts +30 -0
  747. package/types/ui/src/components/organisms/player/parts/stats-panel/index.d.ts +1 -0
  748. package/types/ui/src/components/organisms/player/parts/stats-panel/stats-chart.d.ts +16 -0
  749. package/types/ui/src/components/organisms/player/parts/stats-panel/stats-panel.d.ts +14 -0
  750. package/types/ui/src/components/organisms/player/parts/storyboard-thumb/index.d.ts +1 -0
  751. package/types/ui/src/components/organisms/player/parts/storyboard-thumb/storyboard-thumb.d.ts +4 -0
  752. package/types/ui/src/components/organisms/player/parts/subtitle-renderer/index.d.ts +1 -0
  753. package/types/ui/src/components/organisms/player/parts/subtitle-renderer/subtitle-renderer.d.ts +32 -0
  754. package/types/ui/src/components/organisms/player/parts/surface-radius.d.ts +9 -0
  755. package/types/ui/src/components/organisms/player/parts/top-bar/index.d.ts +1 -0
  756. package/types/ui/src/components/organisms/player/parts/top-bar/top-bar.d.ts +24 -0
  757. package/types/ui/src/components/organisms/player/parts/transport/index.d.ts +1 -0
  758. package/types/ui/src/components/organisms/player/parts/transport/transport.d.ts +19 -0
  759. package/types/ui/src/components/organisms/player/parts/up-next-card/index.d.ts +1 -0
  760. package/types/ui/src/components/organisms/player/parts/up-next-card/up-next-card.d.ts +37 -0
  761. package/types/ui/src/components/organisms/player/parts/up-next-sheet/index.d.ts +1 -0
  762. package/types/ui/src/components/organisms/player/parts/up-next-sheet/slide.d.ts +5 -0
  763. package/types/ui/src/components/organisms/player/parts/up-next-sheet/slide.web.d.ts +5 -0
  764. package/types/ui/src/components/organisms/player/parts/up-next-sheet/up-next-sheet.d.ts +17 -0
  765. package/types/ui/src/components/organisms/player/player-chrome-state.d.ts +11 -0
  766. package/types/ui/src/components/organisms/player/player-input.d.ts +16 -0
  767. package/types/ui/src/components/organisms/player/player-parts.d.ts +34 -0
  768. package/types/ui/src/components/organisms/player/player.d.ts +63 -0
  769. package/types/ui/src/components/organisms/player/types.d.ts +226 -0
  770. package/types/ui/src/components/organisms/rail/index.d.ts +1 -0
  771. package/types/ui/src/components/organisms/rail/rail-context.d.ts +7 -0
  772. package/types/ui/src/components/organisms/rail/rail-row.d.ts +22 -0
  773. package/types/ui/src/components/organisms/rail/rail.d.ts +63 -0
  774. package/types/ui/src/components/organisms/resizable/index.d.ts +8 -0
  775. package/types/ui/src/components/organisms/resizable/resizable-context.d.ts +39 -0
  776. package/types/ui/src/components/organisms/resizable/resizable-cursor.d.ts +3 -0
  777. package/types/ui/src/components/organisms/resizable/resizable-cursor.web.d.ts +4 -0
  778. package/types/ui/src/components/organisms/resizable/resizable-handle.d.ts +30 -0
  779. package/types/ui/src/components/organisms/resizable/resizable-keys-types.d.ts +11 -0
  780. package/types/ui/src/components/organisms/resizable/resizable-keys.d.ts +3 -0
  781. package/types/ui/src/components/organisms/resizable/resizable-keys.web.d.ts +3 -0
  782. package/types/ui/src/components/organisms/resizable/resizable-layout.d.ts +55 -0
  783. package/types/ui/src/components/organisms/resizable/resizable-panel.d.ts +55 -0
  784. package/types/ui/src/components/organisms/resizable/resizable-store.d.ts +18 -0
  785. package/types/ui/src/components/organisms/resizable/resizable.d.ts +59 -0
  786. package/types/ui/src/components/organisms/splash-backdrop/index.d.ts +2 -0
  787. package/types/ui/src/components/organisms/splash-backdrop/splash-backdrop.d.ts +22 -0
  788. package/types/ui/src/components/organisms/table/index.d.ts +1 -0
  789. package/types/ui/src/components/organisms/table/table-cell.d.ts +9 -0
  790. package/types/ui/src/components/organisms/table/table-columns.d.ts +32 -0
  791. package/types/ui/src/components/organisms/table/table-context.d.ts +17 -0
  792. package/types/ui/src/components/organisms/table/table-frame.d.ts +9 -0
  793. package/types/ui/src/components/organisms/table/table-place.d.ts +8 -0
  794. package/types/ui/src/components/organisms/table/table-row.d.ts +12 -0
  795. package/types/ui/src/components/organisms/table/table-sort-cell.d.ts +14 -0
  796. package/types/ui/src/components/organisms/table/table-sort.d.ts +38 -0
  797. package/types/ui/src/components/organisms/table/table.d.ts +65 -0
  798. package/types/ui/src/components/organisms/toast/index.d.ts +1 -0
  799. package/types/ui/src/components/organisms/toast/toast-card.d.ts +8 -0
  800. package/types/ui/src/components/organisms/toast/toast.d.ts +54 -0
  801. package/types/ui/src/components/organisms/virtual/clip.d.ts +25 -0
  802. package/types/ui/src/components/organisms/virtual/index.d.ts +2 -0
  803. package/types/ui/src/components/organisms/virtual/moving-strip.d.ts +16 -0
  804. package/types/ui/src/components/organisms/virtual/strip-motion.d.ts +4 -0
  805. package/types/ui/src/components/organisms/virtual/virtual-grid/grid-row.d.ts +25 -0
  806. package/types/ui/src/components/organisms/virtual/virtual-grid/grid-rows.d.ts +57 -0
  807. package/types/ui/src/components/organisms/virtual/virtual-grid/index.d.ts +1 -0
  808. package/types/ui/src/components/organisms/virtual/virtual-grid/use-wheel-rows.d.ts +8 -0
  809. package/types/ui/src/components/organisms/virtual/virtual-grid/virtual-grid.d.ts +54 -0
  810. package/types/ui/src/components/organisms/virtual/virtual-rail/edge-scroll.d.ts +38 -0
  811. package/types/ui/src/components/organisms/virtual/virtual-rail/index.d.ts +1 -0
  812. package/types/ui/src/components/organisms/virtual/virtual-rail/rail-edge.d.ts +11 -0
  813. package/types/ui/src/components/organisms/virtual/virtual-rail/use-key-grace.d.ts +6 -0
  814. package/types/ui/src/components/organisms/virtual/virtual-rail/virtual-rail.d.ts +19 -0
  815. package/types/ui/src/components/templates/index.d.ts +2 -0
  816. package/types/ui/src/components/templates/tv-stage/index.d.ts +1 -0
  817. package/types/ui/src/components/templates/tv-stage/tv-stage.d.ts +7 -0
  818. package/types/ui/src/core/atomic/index.d.ts +5 -0
  819. package/types/ui/src/core/atomic/inject.d.ts +3 -0
  820. package/types/ui/src/core/atomic/register.d.ts +13 -0
  821. package/types/ui/src/core/atomic/static-style.d.ts +8 -0
  822. package/types/ui/src/core/breakpoint-cascade.d.ts +45 -0
  823. package/types/ui/src/core/breakpoint.d.ts +21 -0
  824. package/types/ui/src/core/color.d.ts +21 -0
  825. package/types/ui/src/core/index.d.ts +20 -0
  826. package/types/ui/src/core/normalize.d.ts +21 -0
  827. package/types/ui/src/core/recipe.d.ts +21 -0
  828. package/types/ui/src/core/shorthand-resolve.d.ts +54 -0
  829. package/types/ui/src/core/shorthands.d.ts +187 -0
  830. package/types/ui/src/core/stabilise.d.ts +14 -0
  831. package/types/ui/src/core/states.d.ts +16 -0
  832. package/types/ui/src/core/styles.d.ts +59 -0
  833. package/types/ui/src/core/theme-create.d.ts +64 -0
  834. package/types/ui/src/core/theme-mode.d.ts +15 -0
  835. package/types/ui/src/core/theme.d.ts +72 -0
  836. package/types/ui/src/core/tokens/colors.d.ts +109 -0
  837. package/types/ui/src/core/tokens/css-palette.d.ts +19 -0
  838. package/types/ui/src/core/tokens/css-var.d.ts +8 -0
  839. package/types/ui/src/core/tokens/effects.d.ts +103 -0
  840. package/types/ui/src/core/tokens/index.d.ts +10 -0
  841. package/types/ui/src/core/tokens/layout.d.ts +94 -0
  842. package/types/ui/src/core/tokens/mobile.d.ts +91 -0
  843. package/types/ui/src/core/tokens/registry.d.ts +4 -0
  844. package/types/ui/src/core/tokens/typography.d.ts +232 -0
  845. package/types/ui/src/core/types.d.ts +122 -0
  846. package/types/ui/src/core/use-breakpoint.d.ts +16 -0
  847. package/types/ui/src/core/use-theme.d.ts +30 -0
  848. package/types/ui/src/core/web-style.d.ts +91 -0
  849. package/types/ui/src/index.d.ts +20 -0
  850. package/types/ui/src/kit.d.ts +74 -0
  851. package/types/ui/src/lib/a11y-props.d.ts +26 -0
  852. package/types/ui/src/lib/a11y.d.ts +8 -0
  853. package/types/ui/src/lib/anchor.d.ts +32 -0
  854. package/types/ui/src/lib/anchored-keys.d.ts +41 -0
  855. package/types/ui/src/lib/anchored-panel.d.ts +42 -0
  856. package/types/ui/src/lib/anchored-popup.d.ts +17 -0
  857. package/types/ui/src/lib/box-layers.d.ts +10 -0
  858. package/types/ui/src/lib/box-style.d.ts +16 -0
  859. package/types/ui/src/lib/caret.d.ts +8 -0
  860. package/types/ui/src/lib/classed.d.ts +3 -0
  861. package/types/ui/src/lib/cover-rect.d.ts +26 -0
  862. package/types/ui/src/lib/css.d.ts +19 -0
  863. package/types/ui/src/lib/css.web.d.ts +25 -0
  864. package/types/ui/src/lib/cursor.d.ts +17 -0
  865. package/types/ui/src/lib/dismiss-backdrop.d.ts +11 -0
  866. package/types/ui/src/lib/dom.d.ts +12 -0
  867. package/types/ui/src/lib/drag-select.d.ts +1 -0
  868. package/types/ui/src/lib/drag-select.web.d.ts +13 -0
  869. package/types/ui/src/lib/ease.d.ts +13 -0
  870. package/types/ui/src/lib/escape-guard.d.ts +1 -0
  871. package/types/ui/src/lib/expo-image-backend.d.ts +5 -0
  872. package/types/ui/src/lib/field-shell.d.ts +140 -0
  873. package/types/ui/src/lib/focus-entry.d.ts +20 -0
  874. package/types/ui/src/lib/focus-here.d.ts +11 -0
  875. package/types/ui/src/lib/focus-here.web.d.ts +7 -0
  876. package/types/ui/src/lib/focus-lift.d.ts +39 -0
  877. package/types/ui/src/lib/focus-nav.d.ts +3 -0
  878. package/types/ui/src/lib/focus-nav.web.d.ts +2 -0
  879. package/types/ui/src/lib/focus-platform.d.ts +30 -0
  880. package/types/ui/src/lib/focus-presence.d.ts +5 -0
  881. package/types/ui/src/lib/focus-remote.d.ts +39 -0
  882. package/types/ui/src/lib/focus-remote.web.d.ts +16 -0
  883. package/types/ui/src/lib/focus-report.d.ts +18 -0
  884. package/types/ui/src/lib/focus-root.d.ts +22 -0
  885. package/types/ui/src/lib/focus-root.web.d.ts +3 -0
  886. package/types/ui/src/lib/focus-scope.d.ts +59 -0
  887. package/types/ui/src/lib/focus-scroll.d.ts +69 -0
  888. package/types/ui/src/lib/focus-tab.d.ts +12 -0
  889. package/types/ui/src/lib/focus-transition.d.ts +11 -0
  890. package/types/ui/src/lib/focus-transition.web.d.ts +3 -0
  891. package/types/ui/src/lib/focus-types.d.ts +18 -0
  892. package/types/ui/src/lib/focus-visible.d.ts +21 -0
  893. package/types/ui/src/lib/form/index.d.ts +4 -0
  894. package/types/ui/src/lib/form/message.d.ts +10 -0
  895. package/types/ui/src/lib/form/standard-schema.d.ts +27 -0
  896. package/types/ui/src/lib/form/use-form.d.ts +59 -0
  897. package/types/ui/src/lib/fuzzy-search.d.ts +20 -0
  898. package/types/ui/src/lib/genre-icon.d.ts +4 -0
  899. package/types/ui/src/lib/glyph.d.ts +24 -0
  900. package/types/ui/src/lib/group-shape.d.ts +44 -0
  901. package/types/ui/src/lib/hover-passthrough.d.ts +9 -0
  902. package/types/ui/src/lib/icon-catalog.d.ts +19 -0
  903. package/types/ui/src/lib/icon-search.d.ts +18 -0
  904. package/types/ui/src/lib/icons/every-glyph.d.ts +4 -0
  905. package/types/ui/src/lib/icons/every-glyph.web.d.ts +4 -0
  906. package/types/ui/src/lib/icons/glyph-source.d.ts +3 -0
  907. package/types/ui/src/lib/icons/glyphs.d.ts +34 -0
  908. package/types/ui/src/lib/icons/library.d.ts +19 -0
  909. package/types/ui/src/lib/icons/stroke-prop.d.ts +2 -0
  910. package/types/ui/src/lib/icons/stroke-prop.web.d.ts +2 -0
  911. package/types/ui/src/lib/image-backend.d.ts +26 -0
  912. package/types/ui/src/lib/input-gate.d.ts +11 -0
  913. package/types/ui/src/lib/input-source.d.ts +3 -0
  914. package/types/ui/src/lib/landmark.d.ts +4 -0
  915. package/types/ui/src/lib/landmark.web.d.ts +4 -0
  916. package/types/ui/src/lib/lockup-paths.d.ts +10 -0
  917. package/types/ui/src/lib/loop.d.ts +15 -0
  918. package/types/ui/src/lib/loop.web.d.ts +5 -0
  919. package/types/ui/src/lib/modal-portal.d.ts +3 -0
  920. package/types/ui/src/lib/modal-portal.web.d.ts +8 -0
  921. package/types/ui/src/lib/name-of.d.ts +9 -0
  922. package/types/ui/src/lib/nav-style.d.ts +5 -0
  923. package/types/ui/src/lib/overlay-host.d.ts +23 -0
  924. package/types/ui/src/lib/part-context.d.ts +8 -0
  925. package/types/ui/src/lib/perf-memory.d.ts +12 -0
  926. package/types/ui/src/lib/perf-memory.web.d.ts +4 -0
  927. package/types/ui/src/lib/perf.d.ts +35 -0
  928. package/types/ui/src/lib/platform.d.ts +3 -0
  929. package/types/ui/src/lib/platform.web.d.ts +2 -0
  930. package/types/ui/src/lib/portal.d.ts +10 -0
  931. package/types/ui/src/lib/portal.web.d.ts +17 -0
  932. package/types/ui/src/lib/press-dip.d.ts +26 -0
  933. package/types/ui/src/lib/press-guard.d.ts +8 -0
  934. package/types/ui/src/lib/progress-motion.d.ts +11 -0
  935. package/types/ui/src/lib/progress-motion.web.d.ts +11 -0
  936. package/types/ui/src/lib/reduced-motion.d.ts +7 -0
  937. package/types/ui/src/lib/report-categories.d.ts +10 -0
  938. package/types/ui/src/lib/ring-room.d.ts +27 -0
  939. package/types/ui/src/lib/ring-scope.d.ts +6 -0
  940. package/types/ui/src/lib/ring.d.ts +27 -0
  941. package/types/ui/src/lib/sample-art.d.ts +9 -0
  942. package/types/ui/src/lib/scroll-lock.d.ts +1 -0
  943. package/types/ui/src/lib/scroll-lock.web.d.ts +6 -0
  944. package/types/ui/src/lib/shake.d.ts +8 -0
  945. package/types/ui/src/lib/shake.web.d.ts +4 -0
  946. package/types/ui/src/lib/slot.d.ts +36 -0
  947. package/types/ui/src/lib/sort-icon.d.ts +5 -0
  948. package/types/ui/src/lib/splash-motion.d.ts +25 -0
  949. package/types/ui/src/lib/splash-motion.web.d.ts +15 -0
  950. package/types/ui/src/lib/stable-callback.d.ts +9 -0
  951. package/types/ui/src/lib/surface-bands.d.ts +26 -0
  952. package/types/ui/src/lib/surface-presentation.d.ts +17 -0
  953. package/types/ui/src/lib/surface-shell.d.ts +21 -0
  954. package/types/ui/src/lib/svg.d.ts +1 -0
  955. package/types/ui/src/lib/svg.web.d.ts +17 -0
  956. package/types/ui/src/lib/theme-audio.d.ts +7 -0
  957. package/types/ui/src/lib/tv-remote.d.ts +11 -0
  958. package/types/ui/src/lib/use-complete-once.d.ts +12 -0
  959. package/types/ui/src/lib/use-controllable.d.ts +1 -0
  960. package/types/ui/src/lib/use-copy.d.ts +20 -0
  961. package/types/ui/src/lib/use-growing-count.d.ts +12 -0
  962. package/types/ui/src/lib/use-settled-value.d.ts +5 -0
  963. package/types/ui/src/lib/wheel-pan.d.ts +7 -0
  964. package/types/ui/src/lib/wheel-pan.web.d.ts +11 -0
  965. package/types/ui/src/lib/wheel-paths.d.ts +5 -0
  966. package/types/ui/src/services/aiSuggest.d.ts +15 -0
  967. package/types/ui/src/services/auth.d.ts +41 -0
  968. package/types/ui/src/services/cast-context.d.ts +33 -0
  969. package/types/ui/src/services/cast-events.d.ts +23 -0
  970. package/types/ui/src/services/cast-lan.d.ts +21 -0
  971. package/types/ui/src/services/cast-position.d.ts +14 -0
  972. package/types/ui/src/services/cast.d.ts +20 -0
  973. package/types/ui/src/services/format.d.ts +25 -0
  974. package/types/ui/src/services/i18n.d.ts +18 -0
  975. package/types/ui/src/services/locale.d.ts +18 -0
  976. package/types/ui/src/services/playback.d.ts +49 -0
  977. package/types/ui/src/services/storyboard.d.ts +33 -0
  978. package/types/ui/src/services/subtitleGenerations.d.ts +13 -0
  979. package/types/ui/src/services/themeAudio.d.ts +19 -0
  980. package/types/ui/src/services/themeAudio.native.d.ts +8 -0
  981. package/types/ui/src/ssr.d.ts +20 -0
  982. package/types/ui/src/styles/motion.d.ts +2 -0
  983. package/types/ui/src/styles/page.d.ts +2 -0
  984. package/types/ui/src/styles/reset.d.ts +2 -0
  985. package/types/ui/src/styles/sheet.d.ts +18 -0
  986. package/types/ui/src/testing.d.ts +27 -0
  987. package/types/ui/src/workbench-config.d.ts +9 -0
package/dist/cli.js ADDED
@@ -0,0 +1,2523 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var __defProp = Object.defineProperty;
4
+ var __returnValue = (v) => v;
5
+ function __exportSetter(name, newValue) {
6
+ this[name] = __returnValue.bind(null, newValue);
7
+ }
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true,
13
+ configurable: true,
14
+ set: __exportSetter.bind(all, name)
15
+ });
16
+ };
17
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
+
19
+ // ../registry/src/documents/v1.ts
20
+ import { z } from "zod";
21
+ var Integrity, PointDef, Contribution, PointReq, RegistryArtifact, DependencyMap, RegistryVersion, ModuleMeta, RegistryEntry, RegistryIndex, ModuleRecord, RegistryDescriptor;
22
+ var init_v1 = __esm(() => {
23
+ Integrity = z.string().regex(/^sha256-[A-Za-z0-9+/]{43}=$/, "not an sha256 SRI");
24
+ PointDef = z.object({
25
+ name: z.string(),
26
+ version: z.number().int().positive().nullish(),
27
+ methods: z.array(z.string()).nullish()
28
+ }).catchall(z.json());
29
+ Contribution = z.object({
30
+ point: z.string(),
31
+ version: z.number().int().positive().nullish(),
32
+ id: z.string().nullish()
33
+ }).catchall(z.json());
34
+ PointReq = z.object({
35
+ point: z.string(),
36
+ version: z.string().nullish(),
37
+ id: z.string().nullish(),
38
+ optional: z.boolean().nullish()
39
+ }).catchall(z.json());
40
+ RegistryArtifact = z.object({
41
+ target: z.string().nullish(),
42
+ url: z.string(),
43
+ size: z.number().int().nonnegative(),
44
+ integrity: Integrity,
45
+ contentHash: Integrity.nullish()
46
+ });
47
+ DependencyMap = z.record(z.string(), z.string());
48
+ RegistryVersion = z.object({
49
+ schemaVersion: z.number().int().nullish(),
50
+ engines: z.record(z.string(), z.string()).nullish(),
51
+ library: z.boolean().nullish(),
52
+ dependencies: DependencyMap.nullish(),
53
+ optionalDependencies: DependencyMap.nullish(),
54
+ definesPoints: z.array(PointDef).nullish(),
55
+ contributes: z.array(Contribution).nullish(),
56
+ consumes: z.array(PointReq).nullish(),
57
+ artifacts: z.array(RegistryArtifact)
58
+ });
59
+ ModuleMeta = z.object({
60
+ id: z.string(),
61
+ name: z.string(),
62
+ description: z.string().nullish(),
63
+ author: z.string().nullish(),
64
+ homepage: z.string().nullish(),
65
+ license: z.string().nullish(),
66
+ keywords: z.array(z.string()).nullish(),
67
+ tags: z.array(z.string()).nullish(),
68
+ icon: z.string().nullish()
69
+ });
70
+ RegistryEntry = ModuleMeta.extend(RegistryVersion.shape).extend({
71
+ version: z.string()
72
+ });
73
+ RegistryIndex = z.array(RegistryEntry);
74
+ ModuleRecord = ModuleMeta.extend({
75
+ apiVersion: z.number().int().min(1),
76
+ latest: z.string(),
77
+ distTags: z.record(z.string(), z.string()).default({}),
78
+ versions: z.record(z.string(), RegistryVersion)
79
+ });
80
+ RegistryDescriptor = z.object({
81
+ apiVersion: z.number().int().min(1),
82
+ name: z.string(),
83
+ url: z.string(),
84
+ modules: z.array(z.string())
85
+ });
86
+ });
87
+
88
+ // ../registry/src/documents/index.ts
89
+ var REGISTRY_API_VERSION = 1, DOCUMENT_SCHEMAS;
90
+ var init_documents = __esm(() => {
91
+ init_v1();
92
+ init_v1();
93
+ DOCUMENT_SCHEMAS = {
94
+ 1: { registry: RegistryDescriptor, index: RegistryIndex, module: ModuleRecord }
95
+ };
96
+ });
97
+
98
+ // ../registry/src/manifest/v2.ts
99
+ import { z as z2 } from "zod";
100
+ function speaksCurrentSchema(manifest) {
101
+ return manifest.schemaVersion === SCHEMA_VERSION;
102
+ }
103
+ function dependenciesOf(manifest) {
104
+ return mapOf(manifest.dependencies);
105
+ }
106
+ function optionalDependenciesOf(manifest) {
107
+ return mapOf(manifest.optionalDependencies);
108
+ }
109
+ var DependencyMap2, ConfigField, SCHEMA_VERSION = 2, REVERSE_DNS_ID, TableOrColumn, CoreScope, Storage, Manifest, mapOf = (raw) => raw ?? {}, ArtifactRef, DescribedModule;
110
+ var init_v2 = __esm(() => {
111
+ init_v1();
112
+ DependencyMap2 = z2.record(z2.string(), z2.string()).nullish();
113
+ ConfigField = z2.object({
114
+ key: z2.string(),
115
+ label: z2.string(),
116
+ type: z2.enum(["string", "bool", "number", "select"]),
117
+ default: z2.string().nullish(),
118
+ options: z2.array(z2.string()).nullish(),
119
+ placeholder: z2.string().nullish(),
120
+ secret: z2.boolean().nullish(),
121
+ required: z2.boolean().nullish()
122
+ });
123
+ REVERSE_DNS_ID = /^[a-z0-9]+(?:\.[a-z0-9-]+)+$/;
124
+ TableOrColumn = z2.string().regex(/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)?$/);
125
+ CoreScope = z2.object({
126
+ read: z2.array(TableOrColumn).nullish().describe('Tables and columns this module may SELECT, as "table" or "table.column". A column named in a WHERE is reached as much as one that is projected.'),
127
+ write: z2.array(TableOrColumn).nullish().describe("Tables this module may INSERT / UPDATE / DELETE. A write grant is not a read grant, and a foreign key drags its other table in: writing a child reads the parent, and a cascading delete writes the child.")
128
+ });
129
+ Storage = z2.object({
130
+ core: CoreScope.nullish().describe("The slice of the shared core database this module may reach. Enforced per connection by SQLite's authorizer at prepare time, so it cannot be worked around by building the SQL as a string. Absent means none of it."),
131
+ adopt: z2.array(z2.string().regex(/^[A-Za-z_]\w*$/)).nullish().describe("Tables this module used to keep in the core database and now owns. The core moves each one - schema, indexes and rows - into the module's own file before the module is spawned, then drops the core copy, so it happens exactly once.")
132
+ });
133
+ Manifest = z2.object({
134
+ $schema: z2.string().optional().describe("The schema this manifest is written against, so an editor can offer completion and inline docs. Ignored everywhere else."),
135
+ schemaVersion: z2.number().int().nullish().describe("The manifest schema this module is built against. A server that speaks a different one refuses the bundle rather than reading it on a best-effort basis, because the fields that moved between versions parse as absent, not as errors."),
136
+ id: z2.string().describe("Reverse-DNS identifier, e.g. tv.kroma.torrents. The runtime join key."),
137
+ name: z2.string().describe("Display name, shown in the Store and the admin."),
138
+ version: z2.string().describe("The module's own semver version. Bump it whenever the bundle changes: CI content-hashes each bundle and refuses a run whose bytes moved while this stood still."),
139
+ description: z2.string().nullish().describe("One line, shown on the Store card."),
140
+ engines: z2.record(z2.string(), z2.string()).nullish().describe('What this module needs from its host, by engine name and semver range, e.g. { "server": ">=0.1.4" }. A bare version means "at least that". An engine the host cannot check is refused, not ignored.'),
141
+ library: z2.boolean().nullish().describe("A library module: its .kmod ships no native binary (its code is co-linked into the processes that need it), so the supervisor registers it but spawns no process."),
142
+ dependencies: DependencyMap2.describe('Hard dependencies as a map of module id to semver range; a bare "*" means any version. Enforced on the backend.'),
143
+ optionalDependencies: DependencyMap2.describe("Soft dependencies, same shape: version-checked and ordered first when present, but not required."),
144
+ definesPoints: z2.array(PointDef).nullish().describe("Points this module INVENTS, for other modules to plug into. `name` is local; the full name is `<this module's id>/<name>`, so ownership reads off the name and two authors cannot collide."),
145
+ contributes: z2.array(Contribution).nullish().describe("Points this module answers, its own included. One declaration where there used to be three: `provides` described a capability for the admin picker and `ports` described the RPC name resolution matched on, and an engine advertised the same fact under both."),
146
+ consumes: z2.array(PointReq).nullish().describe('Points this module CALLS. Unlike a module id in `dependencies`, this says "something has to answer this", which is what a store can resolve without naming a peer.'),
147
+ config: z2.array(ConfigField).nullish().describe("Admin-configurable settings this module exposes, rendered as a form."),
148
+ storage: Storage.nullish().describe("This module's databases, and the capability itself: without a storage object the module gets no database and its binary does not link SQLite. Its presence alone grants it its own file at <data>/modules/<id>/module.sqlite, where its migrations run and which it owns outright."),
149
+ feRemote: z2.object({ module: z2.string() }).nullish().describe("Frontend Module Federation remote (runtime-loaded modules). The entry URL is derived by the server as /modules/<id>/remoteEntry.js."),
150
+ author: z2.string().nullish().describe("Who published it, shown on the Store page."),
151
+ homepage: z2.string().nullish().describe("Where to read more about it."),
152
+ license: z2.string().nullish().describe("SPDX identifier, e.g. GPL-2.0-or-later."),
153
+ keywords: z2.array(z2.string()).nullish().describe("Free-form search terms, matched by the Store's search."),
154
+ tags: z2.array(z2.string()).nullish().describe("Words a store filters by. Defaults to the local half of each point this module answers, so it rarely needs writing by hand.")
155
+ });
156
+ ArtifactRef = z2.object({
157
+ target: z2.string().nullish(),
158
+ url: z2.string(),
159
+ size: z2.number().int().nonnegative(),
160
+ sha256: z2.string().nullish(),
161
+ contentHash: z2.string().nullish()
162
+ });
163
+ DescribedModule = Manifest.extend({
164
+ icon: z2.string().nullish(),
165
+ artifacts: z2.array(ArtifactRef)
166
+ });
167
+ });
168
+
169
+ // ../registry/src/manifest/index.ts
170
+ var MODULE_SCHEMA_VERSION = 2, MANIFEST_SCHEMAS;
171
+ var init_manifest = __esm(() => {
172
+ init_v2();
173
+ init_v2();
174
+ MANIFEST_SCHEMAS = { 2: Manifest };
175
+ });
176
+
177
+ // ../registry/src/semver.ts
178
+ function parse(raw) {
179
+ const m = SEMVER.exec(raw.trim());
180
+ if (!m)
181
+ return null;
182
+ const [, major, minor, patch, pre] = m;
183
+ return {
184
+ major: Number(major),
185
+ minor: Number(minor),
186
+ patch: Number(patch),
187
+ prerelease: pre ? pre.split(".").map((p) => /^\d+$/.test(p) ? Number(p) : p) : []
188
+ };
189
+ }
190
+ function sign(a, b) {
191
+ if (a < b)
192
+ return -1;
193
+ return a > b ? 1 : 0;
194
+ }
195
+ function comparePart(a, b) {
196
+ const aNum = typeof a === "number";
197
+ const bNum = typeof b === "number";
198
+ if (aNum && bNum)
199
+ return sign(a, b);
200
+ if (aNum !== bNum)
201
+ return aNum ? -1 : 1;
202
+ return sign(String(a), String(b));
203
+ }
204
+ function comparePrerelease(a, b) {
205
+ if (a.length === 0 || b.length === 0) {
206
+ if (a.length === b.length)
207
+ return 0;
208
+ return a.length === 0 ? 1 : -1;
209
+ }
210
+ const len = Math.max(a.length, b.length);
211
+ for (let i = 0;i < len; i++) {
212
+ const x = a[i];
213
+ const y = b[i];
214
+ if (x === undefined)
215
+ return -1;
216
+ if (y === undefined)
217
+ return 1;
218
+ const c = comparePart(x, y);
219
+ if (c !== 0)
220
+ return c;
221
+ }
222
+ return 0;
223
+ }
224
+ function compare(a, b) {
225
+ for (const k of ["major", "minor", "patch"]) {
226
+ if (a[k] !== b[k])
227
+ return a[k] < b[k] ? -1 : 1;
228
+ }
229
+ return comparePrerelease(a.prerelease, b.prerelease);
230
+ }
231
+ function compareRaw(a, b) {
232
+ const [x, y] = [parse(a), parse(b)];
233
+ if (!x || !y) {
234
+ if (x)
235
+ return 1;
236
+ if (y)
237
+ return -1;
238
+ return 0;
239
+ }
240
+ return compare(x, y);
241
+ }
242
+ function channelOf(version) {
243
+ const parsed = parse(version);
244
+ if (!parsed)
245
+ return null;
246
+ const [first] = parsed.prerelease;
247
+ if (first === undefined)
248
+ return "latest";
249
+ return typeof first === "string" ? first : null;
250
+ }
251
+ var SEMVER;
252
+ var init_semver = __esm(() => {
253
+ SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
254
+ });
255
+
256
+ // ../registry/src/sort.ts
257
+ function byCodeUnit(a, b) {
258
+ if (a < b)
259
+ return -1;
260
+ return a > b ? 1 : 0;
261
+ }
262
+
263
+ // ../registry/src/text.ts
264
+ function base64(bytes) {
265
+ return btoa(String.fromCodePoint(...bytes));
266
+ }
267
+
268
+ // ../registry/src/build.ts
269
+ function sriFromHex(hexSha256) {
270
+ if (!hexSha256 || !HEX_SHA256.test(hexSha256))
271
+ return null;
272
+ const bytes = hexSha256.match(/../g)?.map((byte) => Number.parseInt(byte, 16)) ?? [];
273
+ return `sha256-${base64(Uint8Array.from(bytes))}`;
274
+ }
275
+ function tagsOf(entry) {
276
+ const explicit = some(entry.tags);
277
+ if (explicit)
278
+ return explicit;
279
+ const points = (entry.contributes ?? []).map((c) => c && typeof c === "object" ? c.point : undefined).filter((p) => typeof p === "string").map((p) => p.split("/").pop());
280
+ return some([...new Set(points)]);
281
+ }
282
+ function metaOf(entry) {
283
+ return {
284
+ id: entry.id,
285
+ name: entry.name,
286
+ description: entry.description,
287
+ author: entry.author,
288
+ homepage: entry.homepage,
289
+ license: entry.license,
290
+ keywords: some(entry.keywords),
291
+ tags: tagsOf(entry),
292
+ icon: entry.icon
293
+ };
294
+ }
295
+ function versionOf(entry) {
296
+ return {
297
+ schemaVersion: entry.schemaVersion,
298
+ engines: entry.engines,
299
+ library: entry.library,
300
+ dependencies: someMap(dependenciesOf(entry)),
301
+ optionalDependencies: someMap(optionalDependenciesOf(entry)),
302
+ definesPoints: some(entry.definesPoints),
303
+ contributes: some(entry.contributes),
304
+ consumes: some(entry.consumes),
305
+ artifacts: entry.artifacts.flatMap((a) => {
306
+ const integrity = sriFromHex(a.sha256);
307
+ if (!integrity)
308
+ return [];
309
+ return [
310
+ {
311
+ target: a.target,
312
+ url: a.url,
313
+ size: a.size,
314
+ integrity,
315
+ contentHash: sriFromHex(a.contentHash)
316
+ }
317
+ ];
318
+ })
319
+ };
320
+ }
321
+ function buildModuleRecord(entry, known) {
322
+ const versions = { ...known?.versions, [entry.version]: versionOf(entry) };
323
+ const channel = channelOf(entry.version);
324
+ const distTags = { ...known?.distTags, ...channel ? { [channel]: entry.version } : {} };
325
+ return {
326
+ apiVersion: REGISTRY_API_VERSION,
327
+ ...metaOf(entry),
328
+ latest: distTags.latest ?? entry.version,
329
+ distTags,
330
+ versions
331
+ };
332
+ }
333
+ function buildIndex(entries) {
334
+ return entries.map((entry) => ({ ...metaOf(entry), version: entry.version, ...versionOf(entry) })).sort((a, b) => byCodeUnit(a.id, b.id));
335
+ }
336
+ function buildDescriptor(name, url, entries) {
337
+ return {
338
+ apiVersion: REGISTRY_API_VERSION,
339
+ name,
340
+ url,
341
+ modules: entries.map((e) => e.id).sort(byCodeUnit)
342
+ };
343
+ }
344
+ var HEX_SHA256, some = (list) => list && list.length > 0 ? list : undefined, someMap = (map) => Object.keys(map).length > 0 ? map : undefined;
345
+ var init_build = __esm(() => {
346
+ init_documents();
347
+ init_manifest();
348
+ init_semver();
349
+ HEX_SHA256 = /^[0-9a-f]{64}$/i;
350
+ });
351
+
352
+ // ../registry/src/client.ts
353
+ var init_client = __esm(() => {
354
+ init_documents();
355
+ init_semver();
356
+ });
357
+
358
+ // ../registry/src/spec.ts
359
+ import { z as z3 } from "zod";
360
+ function openWorld(node) {
361
+ if (Array.isArray(node))
362
+ return node.map(openWorld);
363
+ if (!node || typeof node !== "object")
364
+ return node;
365
+ const out = {};
366
+ for (const [key, value] of Object.entries(node)) {
367
+ if (key === "additionalProperties" && value === false)
368
+ continue;
369
+ out[key] = openWorld(value);
370
+ }
371
+ return out;
372
+ }
373
+ function schemaFor(name, version) {
374
+ if (name === "manifest")
375
+ return MANIFEST_SCHEMAS[version];
376
+ return DOCUMENT_SCHEMAS[version]?.[name];
377
+ }
378
+ function jsonSchema(name, version = schemaVersionOf(name), origin = "https://modules.kroma.tv") {
379
+ const schema = schemaFor(name, version);
380
+ if (!schema)
381
+ return null;
382
+ const emitted = openWorld(z3.toJSONSchema(schema, { io: "output" }));
383
+ return { ...emitted, $id: `${origin}${schemaPath(name, version)}` };
384
+ }
385
+ var SCHEMA_NAMES, schemaVersionOf = (name) => name === "manifest" ? MODULE_SCHEMA_VERSION : REGISTRY_API_VERSION, schemaPath = (name, version = schemaVersionOf(name)) => `/schemas/${version}/${name}.json`;
386
+ var init_spec = __esm(() => {
387
+ init_documents();
388
+ init_manifest();
389
+ SCHEMA_NAMES = ["manifest", "registry", "index", "module"];
390
+ });
391
+
392
+ // ../registry/src/index.ts
393
+ var init_src = __esm(() => {
394
+ init_build();
395
+ init_client();
396
+ init_documents();
397
+ init_manifest();
398
+ init_semver();
399
+ init_spec();
400
+ });
401
+
402
+ // ../module-sdk/src/shared.ts
403
+ function sharedKey(specifier) {
404
+ if (specifier === PUBLIC_NAME)
405
+ return "@kroma/module-sdk";
406
+ if (SHARED_MODULES.includes(specifier))
407
+ return specifier;
408
+ if (CLIENT_DOMAIN.test(specifier))
409
+ return specifier;
410
+ if (KIT_DEEP.test(specifier))
411
+ return "@kroma/ui/kit";
412
+ return null;
413
+ }
414
+ var SHARED_MODULES, CLIENT_DOMAIN, KIT_DEEP, PUBLIC_NAME = "@kromatv/sdk", SHARED_GLOBAL = "__KROMA_SHARED__", REMOTE_ENTRY = "remoteEntry.js", REMOTE_STYLES = "style.css";
415
+ var init_shared = __esm(() => {
416
+ SHARED_MODULES = [
417
+ "react",
418
+ "react/jsx-runtime",
419
+ "react/jsx-dev-runtime",
420
+ "react-dom",
421
+ "react-native",
422
+ "@kroma/module-sdk",
423
+ "@kroma/ui",
424
+ "@kroma/ui/kit",
425
+ "@kroma/ui/tokens",
426
+ "@kroma/core",
427
+ "@kroma/core/react",
428
+ "@kroma/client",
429
+ "@kroma/client/query",
430
+ "@kroma/i18n",
431
+ "@kroma/i18n/react",
432
+ "@tanstack/react-query",
433
+ "@tanstack/react-router",
434
+ "react-call"
435
+ ];
436
+ CLIENT_DOMAIN = /^@kroma\/client\/[a-z][a-z0-9-]*$/;
437
+ KIT_DEEP = /^@kroma\/ui\/kit\/.+/;
438
+ });
439
+
440
+ // src/scaffold/plan.ts
441
+ import { existsSync, readFileSync } from "fs";
442
+ import { dirname, join } from "path";
443
+ import { z as z4 } from "zod";
444
+ function packageRoot(from) {
445
+ let dir = from;
446
+ for (;; ) {
447
+ const manifest = join(dir, "package.json");
448
+ if (existsSync(manifest) && OWN_NAMES.has(JSON.parse(readFileSync(manifest, "utf8")).name)) {
449
+ return dir;
450
+ }
451
+ const parent = dirname(dir);
452
+ if (parent === dir)
453
+ throw new Error("kroma: cannot find my own package.json");
454
+ dir = parent;
455
+ }
456
+ }
457
+ function slugOf(id) {
458
+ return id.split(".").pop() ?? id;
459
+ }
460
+ function pascal(slug) {
461
+ return slug.split(/[^a-z0-9]+/i).filter(Boolean).map((w) => w[0]?.toUpperCase() + w.slice(1)).join("");
462
+ }
463
+ function snake(slug) {
464
+ return slug.replace(/[^a-z0-9]+/gi, "_").toLowerCase();
465
+ }
466
+ function versions(cwd) {
467
+ const own = PackageJson.parse(JSON.parse(readFileSync(join(CLI_ROOT, "package.json"), "utf8")));
468
+ const repo = repoRoot(cwd);
469
+ const server = repo ? serverVersion(repo) : null;
470
+ const sdk = own.version !== "0.0.0" ? own.version : server ?? "0.0.0";
471
+ const channel = repo ? rustChannel(repo) : null;
472
+ return {
473
+ sdk,
474
+ server: server ?? sdk,
475
+ rustChannel: channel ?? "1.98.0",
476
+ reactNative: own.kroma.reactNative
477
+ };
478
+ }
479
+ function repoRoot(cwd) {
480
+ let dir = cwd;
481
+ for (;; ) {
482
+ if (existsSync(join(dir, "server", "Cargo.toml")) && existsSync(join(dir, "modules")))
483
+ return dir;
484
+ const parent = dirname(dir);
485
+ if (parent === dir)
486
+ return null;
487
+ dir = parent;
488
+ }
489
+ }
490
+ function serverVersion(repo) {
491
+ const toml = readFileSync(join(repo, "server", "Cargo.toml"), "utf8");
492
+ return /^version\s*=\s*"([^"]+)"/m.exec(toml)?.[1] ?? null;
493
+ }
494
+ function rustChannel(repo) {
495
+ const path = join(repo, "rust-toolchain.toml");
496
+ if (!existsSync(path))
497
+ return null;
498
+ return /^channel\s*=\s*"([^"]+)"/m.exec(readFileSync(path, "utf8"))?.[1] ?? null;
499
+ }
500
+ function serverRange(version) {
501
+ return version === "0.0.0" ? "*" : `>=${version}`;
502
+ }
503
+ function sdkSpec(v, inRepo) {
504
+ if (inRepo)
505
+ return "workspace:*";
506
+ return v.sdk === "0.0.0" ? "*" : `^${v.sdk}`;
507
+ }
508
+ function treesFor(kind) {
509
+ const trees = ["base"];
510
+ if (kind !== "server")
511
+ trees.push("ui");
512
+ if (kind !== "ui")
513
+ trees.push("server");
514
+ return trees.map((t) => join(CLI_ROOT, "templates", t));
515
+ }
516
+ function skipInRepo(rel) {
517
+ return rel === "rust-toolchain.toml" || rel === ".cargo/config.toml" || rel === ".gitignore";
518
+ }
519
+ function templateVars(a, v) {
520
+ const slug = slugOf(a.id);
521
+ const crate = `kroma-module-${slug}`;
522
+ const migrations = a.storage ? `
523
+ fn migrations(&self) -> &'static str {
524
+ "CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, body TEXT NOT NULL);"
525
+ }
526
+ ` : "";
527
+ return {
528
+ ID: a.id,
529
+ SDK: a.inRepo ? "@kroma/module-sdk" : PUBLIC_NAME,
530
+ SLUG: slug,
531
+ NAME: a.name,
532
+ DESCRIPTION: a.description,
533
+ VERSION: "0.1.0",
534
+ PAGE: `${pascal(slug)}Page`,
535
+ STRUCT: `${pascal(slug)}Module`,
536
+ CRATE: crate,
537
+ CRATE_IDENT: snake(crate),
538
+ SDK_CRATES: a.inRepo ? "../../../server/crates" : `../node_modules/${PUBLIC_NAME}/rust`,
539
+ SDK_FEATURES: a.storage ? ', features = ["storage"]' : "",
540
+ RUNTIME_FEATURES: a.storage ? ', features = ["storage"]' : "",
541
+ MIGRATIONS: migrations,
542
+ RUST_CHANNEL: v.rustChannel
543
+ };
544
+ }
545
+ function manifestFor(a, v) {
546
+ const manifest = {
547
+ $schema: `https://modules.kroma.tv/schemas/${MODULE_SCHEMA_VERSION}/manifest.json`,
548
+ schemaVersion: MODULE_SCHEMA_VERSION,
549
+ id: a.id,
550
+ name: a.name,
551
+ version: "0.1.0",
552
+ description: a.description,
553
+ engines: { server: serverRange(v.server) }
554
+ };
555
+ if (a.kind !== "server")
556
+ manifest.feRemote = { module: "./remoteEntry.js" };
557
+ if (a.storage)
558
+ manifest.storage = { core: {} };
559
+ return manifest;
560
+ }
561
+ function packageJsonFor(a, v) {
562
+ if (a.kind === "server")
563
+ return null;
564
+ const dep = sdkSpec(v, a.inRepo);
565
+ const slug = slugOf(a.id);
566
+ return {
567
+ name: a.inRepo ? `@kroma/module-${slug}` : a.id,
568
+ version: "0.0.0",
569
+ private: true,
570
+ type: "module",
571
+ description: a.description,
572
+ ...a.inRepo ? { exports: { ".": "./ui/src/module.tsx", "./schemas": "./ui/src/schemas.ts" } } : {},
573
+ scripts: a.inRepo ? { typecheck: "tsc --noEmit" } : { dev: "kroma dev", build: "kroma build", check: "kroma check", typecheck: "tsc --noEmit" },
574
+ dependencies: {
575
+ ...a.inRepo ? { "@kroma/module-sdk": "workspace:*", "@kroma/ui": "workspace:*" } : { [PUBLIC_NAME]: dep },
576
+ zod: "^4.5.4"
577
+ },
578
+ peerDependencies: { react: "^19.2.8" },
579
+ devDependencies: {
580
+ ...a.inRepo ? {} : { react: "^19.2.8", "react-native": v.reactNative },
581
+ "@types/react": "^19.2.18",
582
+ typescript: "^7.0.2"
583
+ },
584
+ ...a.inRepo ? {} : { overrides: { "react-native": v.reactNative } }
585
+ };
586
+ }
587
+ function tsconfigFor(a, depth) {
588
+ if (a.kind === "server")
589
+ return null;
590
+ const base = a.inRepo ? `${"../".repeat(depth)}tsconfig.base.json` : `${PUBLIC_NAME}/tsconfig`;
591
+ return {
592
+ extends: base,
593
+ ...a.inRepo ? { compilerOptions: { noEmit: true, types: ["react"] } } : {},
594
+ include: ["ui/src"]
595
+ };
596
+ }
597
+ var OWN_NAMES, CLI_ROOT, PackageJson;
598
+ var init_plan = __esm(() => {
599
+ init_shared();
600
+ init_src();
601
+ OWN_NAMES = new Set(["@kroma/cli", PUBLIC_NAME]);
602
+ CLI_ROOT = packageRoot(import.meta.dir);
603
+ PackageJson = z4.object({
604
+ version: z4.string(),
605
+ kroma: z4.object({ reactNative: z4.string() })
606
+ });
607
+ });
608
+
609
+ // src/scaffold/render.ts
610
+ import { mkdirSync, readdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
611
+ import { dirname as dirname2, join as join2, relative } from "path";
612
+ function render(text, vars) {
613
+ return text.replace(/__([A-Z_]+)__/g, (all, key) => vars[key] ?? all);
614
+ }
615
+ function outputName(name) {
616
+ return name.startsWith("_") ? `.${name.slice(1)}` : name;
617
+ }
618
+ function files(dir) {
619
+ return readdirSync(dir, { withFileTypes: true, recursive: true }).filter((e) => e.isFile()).map((e) => join2(e.parentPath, e.name));
620
+ }
621
+ function renderTree(templateDir, target, vars) {
622
+ const written = [];
623
+ for (const file of files(templateDir)) {
624
+ const rel = relative(templateDir, file).split("/").map((part) => outputName(render(part, vars))).join("/");
625
+ const out = join2(target, rel);
626
+ mkdirSync(dirname2(out), { recursive: true });
627
+ writeFileSync(out, render(readFileSync2(file, "utf8"), vars));
628
+ written.push(rel);
629
+ }
630
+ return written;
631
+ }
632
+ var init_render = () => {};
633
+
634
+ // src/style.ts
635
+ var CSI = "\x1B[", enabled, wrap = (code) => (text) => enabled ? `${CSI}${code}m${text}${CSI}0m` : text, style;
636
+ var init_style = __esm(() => {
637
+ enabled = process.stdout.isTTY === true && !process.env.NO_COLOR;
638
+ style = {
639
+ bold: wrap("1"),
640
+ dim: wrap("2"),
641
+ red: wrap("31"),
642
+ green: wrap("32"),
643
+ yellow: wrap("33"),
644
+ cyan: wrap("36")
645
+ };
646
+ });
647
+
648
+ // src/commands/create.ts
649
+ var exports_create = {};
650
+ __export(exports_create, {
651
+ createCommand: () => createCommand
652
+ });
653
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
654
+ import { join as join3, relative as relative2, resolve } from "path";
655
+ import * as p from "@clack/prompts";
656
+ var {$ } = globalThis.Bun;
657
+ function isKind(v) {
658
+ return v === "full" || v === "server" || v === "ui";
659
+ }
660
+ function isBareId(dir) {
661
+ return !dir.includes("/") && REVERSE_DNS_ID.test(dir);
662
+ }
663
+ function idIssue(id) {
664
+ return REVERSE_DNS_ID.test(id) ? undefined : "a reverse-DNS id, lowercase: tv.acme.notes";
665
+ }
666
+ function titleOf(id) {
667
+ const slug = slugOf(id);
668
+ return slug.charAt(0).toUpperCase() + slug.slice(1).replace(/-/g, " ");
669
+ }
670
+ async function answer(value) {
671
+ if (p.isCancel(value))
672
+ throw new Error("cancelled");
673
+ return value;
674
+ }
675
+ async function ask(options, cwd) {
676
+ const inRepo = options.inRepo ?? repoRoot(cwd) !== null;
677
+ const given = options.id ?? (options.dir && isBareId(options.dir) ? options.dir : undefined);
678
+ if (options.yes) {
679
+ if (!given)
680
+ throw new Error("--yes needs an id: kroma create tv.acme.notes --yes");
681
+ return {
682
+ id: given,
683
+ name: options.name ?? titleOf(given),
684
+ description: options.description ?? "",
685
+ kind: isKind(options.kind) ? options.kind : "full",
686
+ storage: options.storage ?? false,
687
+ inRepo
688
+ };
689
+ }
690
+ p.intro(`${style.bold("KROMA")} module`);
691
+ const id = given && !idIssue(given) ? given : await answer(await p.text({
692
+ message: "Module id",
693
+ placeholder: "tv.acme.notes",
694
+ initialValue: given,
695
+ validate: (v) => idIssue(v ?? "")
696
+ }));
697
+ const name = options.name ?? await answer(await p.text({ message: "Display name", initialValue: titleOf(id) }));
698
+ const description = options.description ?? await answer(await p.text({ message: "One line about it", defaultValue: "" }));
699
+ const kind = isKind(options.kind) ? options.kind : await answer(await p.select({ message: "What is it?", options: KINDS }));
700
+ const storage = kind === "ui" ? false : options.storage ?? await answer(await p.confirm({
701
+ message: "Does the sidecar keep its own database?",
702
+ initialValue: false
703
+ }));
704
+ return { id, name, description, kind, storage, inRepo };
705
+ }
706
+ function write(target, rel, value) {
707
+ writeFileSync2(join3(target, rel), `${JSON.stringify(value, null, 2)}
708
+ `);
709
+ }
710
+ async function createCommand(options) {
711
+ const cwd = options.cwd ?? process.cwd();
712
+ const a = await ask(options, cwd);
713
+ const repo = a.inRepo ? repoRoot(cwd) : null;
714
+ const explicit = options.dir && !isBareId(options.dir) ? resolve(cwd, options.dir) : null;
715
+ const target = explicit ?? (repo ? join3(repo, "modules", a.id) : join3(cwd, a.id));
716
+ if (existsSync2(target) && readdirSync2(target).length > 0) {
717
+ throw new Error(`${target} exists and is not empty`);
718
+ }
719
+ mkdirSync2(target, { recursive: true });
720
+ const v = versions(cwd);
721
+ const vars = templateVars(a, v);
722
+ const written = [];
723
+ for (const tree of treesFor(a.kind)) {
724
+ for (const rel of renderTree(tree, target, vars)) {
725
+ if (a.inRepo && skipInRepo(rel)) {
726
+ await $`rm -f ${join3(target, rel)}`.quiet();
727
+ continue;
728
+ }
729
+ written.push(rel);
730
+ }
731
+ }
732
+ write(target, "module.json", manifestFor(a, v));
733
+ written.push("module.json");
734
+ const pkg = packageJsonFor(a, v);
735
+ if (pkg) {
736
+ write(target, "package.json", pkg);
737
+ write(target, "tsconfig.json", tsconfigFor(a, repo ? relative2(repo, target).split("/").length : 0));
738
+ written.push("package.json", "tsconfig.json");
739
+ }
740
+ const where = relative2(cwd, target) || ".";
741
+ if (options.yes) {
742
+ console.log(`created ${a.id} in ${where} (${written.length} files)`);
743
+ } else {
744
+ p.log.success(`${a.id} in ${where}`);
745
+ }
746
+ const install = options.install !== false && pkg !== null;
747
+ if (install) {
748
+ const s = options.yes ? null : p.spinner();
749
+ s?.start(a.inRepo ? "bun install (workspace links)" : "bun install");
750
+ const result = await $`bun install`.cwd(repo ?? target).quiet().nothrow();
751
+ if (result.exitCode !== 0) {
752
+ s?.stop("bun install failed");
753
+ console.error(result.stderr.toString());
754
+ return 1;
755
+ }
756
+ s?.stop("installed");
757
+ }
758
+ const next = [
759
+ ...where === "." ? [] : [`cd ${where}`],
760
+ ...a.inRepo ? [] : ["bunx kroma login http://localhost:4040"],
761
+ a.inRepo ? "bunx kroma dev" : "bunx kroma dev"
762
+ ];
763
+ if (options.yes) {
764
+ console.log(next.join(`
765
+ `));
766
+ } else {
767
+ p.note(next.join(`
768
+ `), "next");
769
+ p.outro("done");
770
+ }
771
+ return 0;
772
+ }
773
+ var KINDS;
774
+ var init_create = __esm(() => {
775
+ init_src();
776
+ init_plan();
777
+ init_render();
778
+ init_style();
779
+ KINDS = [
780
+ {
781
+ value: "full",
782
+ label: "A page and a sidecar",
783
+ hint: "a React page in the admin, a Rust process behind it"
784
+ },
785
+ { value: "server", label: "A sidecar only", hint: "a Rust process, no page" },
786
+ { value: "ui", label: "A page only", hint: "a React page over the core API" }
787
+ ];
788
+ });
789
+
790
+ // src/sort.ts
791
+ function byCodeUnit2(a, b) {
792
+ if (a < b)
793
+ return -1;
794
+ return a > b ? 1 : 0;
795
+ }
796
+
797
+ // src/bundle/tar.ts
798
+ import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync } from "fs";
799
+ import { join as join4 } from "path";
800
+ function octal(value, width) {
801
+ return `${value.toString(8).padStart(width - 1, "0")}\x00`;
802
+ }
803
+ function header(name, size, mode, dir) {
804
+ if (name.length > 100) {
805
+ throw new Error(`tar entry name too long for a ustar header: ${name}`);
806
+ }
807
+ const buf = new Uint8Array(BLOCK);
808
+ const put = (s, off) => buf.set(new TextEncoder().encode(s), off);
809
+ put(name, 0);
810
+ put(octal(mode, 8), 100);
811
+ put(octal(0, 8), 108);
812
+ put(octal(0, 8), 116);
813
+ put(octal(dir ? 0 : size, 12), 124);
814
+ put(octal(0, 12), 136);
815
+ put(" ", 148);
816
+ put(dir ? "5" : "0", 156);
817
+ put("ustar\x00", 257);
818
+ put("00", 263);
819
+ let sum = 0;
820
+ for (const b of buf)
821
+ sum += b;
822
+ put(`${sum.toString(8).padStart(6, "0")}\x00 `, 148);
823
+ return buf;
824
+ }
825
+ function entryList(staging, entries) {
826
+ const out = [];
827
+ const walk = (rel) => {
828
+ if (statSync(join4(staging, rel)).isDirectory()) {
829
+ out.push({ name: `${rel}/`, dir: true, mode: 493 });
830
+ for (const child of readdirSync3(join4(staging, rel)).sort(byCodeUnit2)) {
831
+ walk(`${rel}/${child}`);
832
+ }
833
+ } else {
834
+ out.push({ name: rel, dir: false, mode: rel === "module" ? 493 : 420 });
835
+ }
836
+ };
837
+ for (const entry of [...entries].sort(byCodeUnit2))
838
+ walk(entry);
839
+ return out;
840
+ }
841
+ function deterministicTar(staging, entries) {
842
+ const parts = [];
843
+ for (const e of entryList(staging, entries)) {
844
+ if (e.dir) {
845
+ parts.push(header(e.name, 0, e.mode, true));
846
+ continue;
847
+ }
848
+ const data = readFileSync3(join4(staging, e.name));
849
+ parts.push(header(e.name, data.length, e.mode, false), data);
850
+ const pad = data.length % BLOCK;
851
+ if (pad)
852
+ parts.push(new Uint8Array(BLOCK - pad));
853
+ }
854
+ parts.push(new Uint8Array(BLOCK * 2));
855
+ const buf = new Uint8Array(parts.reduce((n, p2) => n + p2.length, 0));
856
+ let off = 0;
857
+ for (const p2 of parts) {
858
+ buf.set(p2, off);
859
+ off += p2.length;
860
+ }
861
+ return buf;
862
+ }
863
+ function tarRead(tar, wanted) {
864
+ const field = (start, len) => new TextDecoder().decode(tar.subarray(start, start + len)).split("\x00")[0] ?? "";
865
+ let off = 0;
866
+ while (off + BLOCK <= tar.length) {
867
+ const name = field(off, 100);
868
+ if (!name)
869
+ break;
870
+ const size = Number.parseInt(field(off + 124, 12).trim() || "0", 8);
871
+ if (name === wanted || name === `./${wanted}`) {
872
+ return tar.subarray(off + BLOCK, off + BLOCK + size);
873
+ }
874
+ off += BLOCK + Math.ceil(size / BLOCK) * BLOCK;
875
+ }
876
+ return null;
877
+ }
878
+ function toTar(buf) {
879
+ if (buf[0] === 40 && buf[1] === 181 && buf[2] === 47 && buf[3] === 253) {
880
+ return Bun.zstdDecompressSync(buf);
881
+ }
882
+ if (buf[0] === 31 && buf[1] === 139) {
883
+ return Bun.gunzipSync(buf);
884
+ }
885
+ return buf;
886
+ }
887
+ var BLOCK = 512;
888
+ var init_tar = () => {};
889
+
890
+ // src/bundle/pack.ts
891
+ import {
892
+ copyFileSync,
893
+ cpSync,
894
+ existsSync as existsSync3,
895
+ mkdirSync as mkdirSync3,
896
+ readFileSync as readFileSync4,
897
+ rmSync,
898
+ writeFileSync as writeFileSync3
899
+ } from "fs";
900
+ import { join as join5 } from "path";
901
+ function bundleName(id, hasBinary, target) {
902
+ return `${id}${hasBinary && target ? `-${target}` : ""}.kmod`;
903
+ }
904
+ function stage(input) {
905
+ const { project, binPath, feDir } = input;
906
+ const staging = join5(project.dir, ".bundle");
907
+ rmSync(staging, { recursive: true, force: true });
908
+ mkdirSync3(staging, { recursive: true });
909
+ const entries = ["module.json"];
910
+ copyFileSync(join5(project.dir, "module.json"), join5(staging, "module.json"));
911
+ if (binPath) {
912
+ copyFileSync(binPath, join5(staging, "module"));
913
+ entries.push("module");
914
+ }
915
+ for (const icon of ["icon.svg", "icon.png"]) {
916
+ if (existsSync3(join5(project.dir, icon))) {
917
+ copyFileSync(join5(project.dir, icon), join5(staging, icon));
918
+ entries.push(icon);
919
+ }
920
+ }
921
+ if (feDir && existsSync3(feDir)) {
922
+ cpSync(feDir, join5(staging, "fe"), { recursive: true });
923
+ entries.push("fe");
924
+ }
925
+ return { staging, entries };
926
+ }
927
+ function packBundle(input) {
928
+ const { project, outDir, target, binPath } = input;
929
+ const { staging, entries } = stage(input);
930
+ mkdirSync3(outDir, { recursive: true });
931
+ const file = bundleName(project.manifest.id, binPath !== null, target);
932
+ const kmod = join5(outDir, file);
933
+ const tar = deterministicTar(staging, entries);
934
+ rmSync(staging, { recursive: true, force: true });
935
+ const stamp = `${kmod}.tarsha`;
936
+ const tarSha = Bun.SHA256.hash(tar, "hex");
937
+ if (existsSync3(kmod) && existsSync3(stamp) && readFileSync4(stamp, "utf8").trim() === tarSha) {
938
+ return { path: kmod, file, changed: false };
939
+ }
940
+ const bytes = Bun.zstdCompressSync(tar, { level: 19 });
941
+ writeFileSync3(kmod, bytes);
942
+ writeFileSync3(stamp, `${tarSha}
943
+ `);
944
+ writeFileSync3(`${kmod}.sha256`, `${Bun.SHA256.hash(bytes, "hex")} ${file}
945
+ `);
946
+ return { path: kmod, file, changed: true };
947
+ }
948
+ function packForDev(input) {
949
+ const { project, outDir, target, binPath } = input;
950
+ const { staging, entries } = stage(input);
951
+ mkdirSync3(outDir, { recursive: true });
952
+ const file = bundleName(project.manifest.id, binPath !== null, target);
953
+ const kmod = join5(outDir, file);
954
+ const tar = deterministicTar(staging, entries);
955
+ rmSync(staging, { recursive: true, force: true });
956
+ writeFileSync3(kmod, Bun.zstdCompressSync(tar, { level: 1 }));
957
+ return { path: kmod, file, changed: true };
958
+ }
959
+ var init_pack = __esm(() => {
960
+ init_tar();
961
+ });
962
+
963
+ // src/cargo.ts
964
+ import { existsSync as existsSync4 } from "fs";
965
+ import { join as join6 } from "path";
966
+ var {$: $2 } = globalThis.Bun;
967
+ function targetDir(cwd, projects) {
968
+ const env = process.env.KMOD_TARGET_DIR?.trim();
969
+ if (env)
970
+ return env;
971
+ const only = projects[0];
972
+ if (projects.length === 1 && only?.dir === cwd)
973
+ return join6(only.dir, "server/target");
974
+ return join6(cwd, "target/kmod");
975
+ }
976
+ function cargoBuild(bin, features, target, profile, dir) {
977
+ const args = ["build", "--bin", bin];
978
+ if (profile === "release-kmod")
979
+ args.push("--profile", "release-kmod");
980
+ if (features.length)
981
+ args.push("--features", features.join(","));
982
+ if (target)
983
+ args.push("--target", target);
984
+ const outDir = profile === "release-kmod" ? "release-kmod" : "debug";
985
+ const binPath = target ? join6(dir, target, outDir, bin) : join6(dir, outDir, bin);
986
+ return { args, binPath };
987
+ }
988
+ async function cargo(cwd, args, dir, quiet = false) {
989
+ const run = $2`cargo ${args}`.cwd(cwd).env({ ...process.env, CARGO_TARGET_DIR: dir }).nothrow();
990
+ const result = quiet ? await run.quiet() : await run;
991
+ return result.exitCode;
992
+ }
993
+ async function buildSidecar(project, dir, options) {
994
+ const server = project.server;
995
+ if (!server?.bin)
996
+ return null;
997
+ const { args, binPath } = cargoBuild(server.bin, server.features, options.target, options.profile, dir);
998
+ if (!options.skipBuild) {
999
+ const code = await cargo(server.dir, args, dir);
1000
+ if (code !== 0)
1001
+ throw new Error(`${project.manifest.id}: cargo build failed`);
1002
+ }
1003
+ if (!existsSync4(binPath)) {
1004
+ throw new Error(options.skipBuild ? `KMOD_SKIP_BUILD is set but there is no prebuilt binary at ${binPath}` : `${project.manifest.id}: cargo built no binary at ${binPath}`);
1005
+ }
1006
+ return binPath;
1007
+ }
1008
+ var init_cargo = () => {};
1009
+
1010
+ // src/fe/remote-plugin.ts
1011
+ import { dirname as dirname3, relative as relative3 } from "path";
1012
+ import { init, parse as parse2 } from "es-module-lexer";
1013
+ import MagicString from "magic-string";
1014
+ function posix(path) {
1015
+ return path.split("\\").join("/");
1016
+ }
1017
+ function relativeImport(from, to) {
1018
+ const rel = posix(relative3(dirname3(from), to));
1019
+ return rel.startsWith(".") ? rel : `./${rel}`;
1020
+ }
1021
+ function clean(id) {
1022
+ return id.split("?", 1)[0] ?? id;
1023
+ }
1024
+ function pattern(braces) {
1025
+ const fields = braces.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean).map((s) => {
1026
+ const [name, alias] = s.split(/\s+as\s+/);
1027
+ return alias ? `${name}: ${alias}` : String(name);
1028
+ });
1029
+ return `{ ${fields.join(", ")} }`;
1030
+ }
1031
+ function rewriteImport(statement, key, tmp) {
1032
+ const take = `const ${tmp} = ${HELPER_FN}(${JSON.stringify(key)});`;
1033
+ if (/^import\s*['"]/.test(statement))
1034
+ return `${HELPER_FN}(${JSON.stringify(key)});`;
1035
+ const clause = /^import\s+([\s\S]*?)\s*from\s*['"]/.exec(statement)?.[1];
1036
+ if (clause === undefined)
1037
+ throw new Error(`cannot rewrite: ${statement}`);
1038
+ const lines = [take];
1039
+ let rest = clause.trim();
1040
+ const braces = /\{[^}]*\}/.exec(rest)?.[0];
1041
+ if (braces) {
1042
+ lines.push(`const ${pattern(braces)} = ${tmp};`);
1043
+ rest = rest.replace(braces, "");
1044
+ }
1045
+ const ns = /\*\s+as\s+(\w+)/.exec(rest)?.[1];
1046
+ if (ns) {
1047
+ lines.push(`const ${ns} = ${tmp};`);
1048
+ rest = rest.replace(/\*\s+as\s+\w+/, "");
1049
+ }
1050
+ const def = rest.replace(/,/g, "").trim();
1051
+ if (def)
1052
+ lines.push(`const ${def} = ${tmp}.default;`);
1053
+ return lines.join(" ");
1054
+ }
1055
+ function rewriteReexport(statement, key, tmp) {
1056
+ const take = `const ${tmp} = ${HELPER_FN}(${JSON.stringify(key)});`;
1057
+ const braces = /\{[^}]*\}/.exec(statement)?.[0];
1058
+ if (!braces) {
1059
+ throw new Error(`\`export * from '${key}'\` is not supported for a package the host provides`);
1060
+ }
1061
+ const fields = braces.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean).map((s) => {
1062
+ const [name, alias] = s.split(/\s+as\s+/);
1063
+ return `export const ${alias ?? name} = ${tmp}.${name};`;
1064
+ });
1065
+ return [take, ...fields].join(" ");
1066
+ }
1067
+ function kromaRemote(options) {
1068
+ const entry = posix(options.entry);
1069
+ const manifestImport = relativeImport(options.entry, options.manifestPath);
1070
+ const localesGlob = `${relativeImport(options.entry, options.localesDir)}/*.json`;
1071
+ const manifest = {
1072
+ name: "kroma-remote:manifest",
1073
+ enforce: "pre",
1074
+ transform(code, id) {
1075
+ if (posix(clean(id)) !== entry || !OPTIONS_ONLY_CALL.test(code))
1076
+ return null;
1077
+ const injected = `import __kromaManifest from '${manifestImport}';
1078
+ ${code}`.replace(OPTIONS_ONLY_CALL, `defineModule({ manifest: __kromaManifest, locales: import.meta.glob('${localesGlob}', { eager: true, import: 'default' }),`);
1079
+ return { code: injected, map: null };
1080
+ }
1081
+ };
1082
+ const shared = {
1083
+ name: "kroma-remote:shared",
1084
+ enforce: "post",
1085
+ resolveId(id, importer) {
1086
+ if (id === HELPER)
1087
+ return RESOLVED_HELPER;
1088
+ const key = sharedKey(id);
1089
+ if (key)
1090
+ return { id: `${HELPER}:${key}`, external: true };
1091
+ if (id.startsWith("@kroma/")) {
1092
+ this.error(`${importer ?? "a module file"} imports '${id}', which the host does not provide. The SDK packages carry types only; a page may import ${SHARED_MODULES.join(", ")} and any @kroma/client/<domain>.`);
1093
+ }
1094
+ return null;
1095
+ },
1096
+ load(id) {
1097
+ if (id !== RESOLVED_HELPER)
1098
+ return null;
1099
+ return [
1100
+ `export function ${HELPER_FN}(key) {`,
1101
+ ` const shared = globalThis[${JSON.stringify(SHARED_GLOBAL)}];`,
1102
+ " const mod = shared && shared[key];",
1103
+ ' if (!mod) throw new Error("kroma module: the host provides no " + JSON.stringify(key) + "; this bundle only runs inside a KROMA client");',
1104
+ " return mod;",
1105
+ "}"
1106
+ ].join(`
1107
+ `);
1108
+ },
1109
+ async transform(code, id) {
1110
+ const file = clean(id);
1111
+ if (id.startsWith("\x00") || !SCRIPT.test(file))
1112
+ return null;
1113
+ if (!code.includes("import") && !code.includes("export"))
1114
+ return null;
1115
+ await init;
1116
+ const [imports, exports] = parse2(code, file);
1117
+ if (posix(file) === entry && !exports.some((e) => e.n === "default")) {
1118
+ this.error(`${file}: the module entry must \`export default defineModule({ ... })\``);
1119
+ }
1120
+ const s = new MagicString(code);
1121
+ let count = 0;
1122
+ for (const imp of imports) {
1123
+ if (!imp.n)
1124
+ continue;
1125
+ const key = sharedKey(imp.n);
1126
+ if (!key)
1127
+ continue;
1128
+ const tmp = `__ks${count++}`;
1129
+ if (imp.d >= 0) {
1130
+ s.overwrite(imp.ss, imp.se, `Promise.resolve(${HELPER_FN}(${JSON.stringify(key)}))`);
1131
+ continue;
1132
+ }
1133
+ const statement = code.slice(imp.ss, imp.se);
1134
+ const rewritten = statement.startsWith("export") ? rewriteReexport(statement, key, tmp) : rewriteImport(statement, key, tmp);
1135
+ s.overwrite(imp.ss, imp.se, rewritten);
1136
+ }
1137
+ if (count === 0)
1138
+ return null;
1139
+ s.prepend(`import { ${HELPER_FN} } from ${JSON.stringify(HELPER)};
1140
+ `);
1141
+ return { code: s.toString(), map: s.generateMap({ hires: true }) };
1142
+ },
1143
+ generateBundle(_options, bundle) {
1144
+ if (!(REMOTE_STYLES in bundle))
1145
+ return;
1146
+ const entry2 = bundle[REMOTE_ENTRY];
1147
+ if (entry2?.type !== "chunk")
1148
+ return;
1149
+ entry2.code = `${LINK_STYLES}
1150
+ ${entry2.code}`;
1151
+ }
1152
+ };
1153
+ return [manifest, shared];
1154
+ }
1155
+ var HELPER = "virtual:kroma-shared", RESOLVED_HELPER, HELPER_FN = "__kroma_shared", OPTIONS_ONLY_CALL, LINK_STYLES, SCRIPT;
1156
+ var init_remote_plugin = __esm(() => {
1157
+ init_shared();
1158
+ RESOLVED_HELPER = `\x00${HELPER}`;
1159
+ OPTIONS_ONLY_CALL = /\bdefineModule\s*\(\s*\{/;
1160
+ LINK_STYLES = [
1161
+ "(function () {",
1162
+ ` var href = new URL(${JSON.stringify(`./${REMOTE_STYLES}`)}, import.meta.url).href;`,
1163
+ ` if (document.querySelector('link[href="' + href + '"]')) return;`,
1164
+ " var link = document.createElement('link');",
1165
+ " link.rel = 'stylesheet';",
1166
+ " link.href = href;",
1167
+ " document.head.appendChild(link);",
1168
+ "})();"
1169
+ ].join(`
1170
+ `);
1171
+ SCRIPT = /\.[cm]?[jt]sx?$/;
1172
+ });
1173
+
1174
+ // src/fe/build.ts
1175
+ import { join as join7 } from "path";
1176
+ import { build } from "vite";
1177
+ async function buildFrontend(project, outDir, mode) {
1178
+ const ui = project.ui;
1179
+ if (!ui)
1180
+ return false;
1181
+ await build({
1182
+ configFile: false,
1183
+ envDir: false,
1184
+ root: ui.dir,
1185
+ mode,
1186
+ logLevel: "warn",
1187
+ clearScreen: false,
1188
+ define: { "process.env.NODE_ENV": JSON.stringify(mode) },
1189
+ plugins: kromaRemote({
1190
+ entry: ui.entry,
1191
+ manifestPath: join7(project.dir, "module.json"),
1192
+ localesDir: join7(project.dir, "locales")
1193
+ }),
1194
+ build: {
1195
+ outDir,
1196
+ emptyOutDir: true,
1197
+ target: "es2022",
1198
+ minify: mode === "production",
1199
+ sourcemap: mode === "development",
1200
+ cssCodeSplit: false,
1201
+ lib: {
1202
+ entry: ui.entry,
1203
+ formats: ["es"],
1204
+ fileName: () => REMOTE_ENTRY,
1205
+ cssFileName: REMOTE_STYLES.replace(/\.css$/, "")
1206
+ },
1207
+ rolldownOptions: {
1208
+ output: {
1209
+ chunkFileNames: "[name]-[hash].js",
1210
+ assetFileNames: "[name]-[hash][extname]"
1211
+ }
1212
+ }
1213
+ }
1214
+ });
1215
+ return true;
1216
+ }
1217
+ var init_build2 = __esm(() => {
1218
+ init_shared();
1219
+ init_remote_plugin();
1220
+ });
1221
+
1222
+ // src/project.ts
1223
+ import { existsSync as existsSync5, readdirSync as readdirSync4, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1224
+ import { isAbsolute, join as join8, resolve as resolve2 } from "path";
1225
+ import { z as z5 } from "zod";
1226
+ function readServer(dir) {
1227
+ const serverDir = join8(dir, "server");
1228
+ const cargoPath = join8(serverDir, "Cargo.toml");
1229
+ if (!existsSync5(cargoPath))
1230
+ return null;
1231
+ const cargo2 = CargoManifest.parse(Bun.TOML.parse(readFileSync5(cargoPath, "utf8")));
1232
+ return {
1233
+ dir: serverDir,
1234
+ crate: cargo2.package.name,
1235
+ bin: cargo2.bin[0]?.name ?? null,
1236
+ features: cargo2.package.metadata?.kmod?.features ?? []
1237
+ };
1238
+ }
1239
+ function readFrontend(dir) {
1240
+ const entry = UI_ENTRIES.map((rel) => join8(dir, rel)).find((p2) => existsSync5(p2));
1241
+ return entry ? { dir: join8(dir, "ui"), entry } : null;
1242
+ }
1243
+ function issues(error) {
1244
+ return error.issues.map((i) => ` ${i.path.length ? `${i.path.join(".")}: ` : ""}${i.message}`).join(`
1245
+ `);
1246
+ }
1247
+ function openProject(dir) {
1248
+ const path = join8(dir, "module.json");
1249
+ if (!existsSync5(path)) {
1250
+ throw new Error(`${dir} is not a module: no module.json there`);
1251
+ }
1252
+ let raw;
1253
+ try {
1254
+ raw = JSON.parse(readFileSync5(path, "utf8"));
1255
+ } catch (e) {
1256
+ throw new Error(`${path}: invalid JSON (${e.message})`);
1257
+ }
1258
+ const read = AuthoredManifest.safeParse(raw);
1259
+ if (!read.success) {
1260
+ throw new Error(`${path} is not a valid manifest:
1261
+ ${issues(read.error)}`);
1262
+ }
1263
+ return { dir, manifest: read.data, server: readServer(dir), ui: readFrontend(dir) };
1264
+ }
1265
+ function absolute(path, cwd) {
1266
+ return isAbsolute(path) ? path : resolve2(cwd, path);
1267
+ }
1268
+ function moduleDirs(root) {
1269
+ if (!existsSync5(root))
1270
+ return [];
1271
+ return readdirSync4(root, { withFileTypes: true }).filter((e) => e.isDirectory() && existsSync5(join8(root, e.name, "module.json"))).map((e) => join8(root, e.name)).sort(byCodeUnit2);
1272
+ }
1273
+ function findProjects(dirs, cwd = process.cwd()) {
1274
+ if (dirs.length > 0)
1275
+ return dirs.map((d) => openProject(absolute(d, cwd)));
1276
+ if (existsSync5(join8(cwd, "module.json")))
1277
+ return [openProject(cwd)];
1278
+ const found = moduleDirs(join8(cwd, "modules"));
1279
+ if (found.length === 0) {
1280
+ throw new Error(`no module here: ${cwd} has no module.json and no modules/ directory`);
1281
+ }
1282
+ return found.map(openProject);
1283
+ }
1284
+ var AuthoredManifest, CargoManifest, UI_ENTRIES;
1285
+ var init_project = __esm(() => {
1286
+ init_src();
1287
+ AuthoredManifest = Manifest.strict().refine((m) => m.schemaVersion === MODULE_SCHEMA_VERSION, {
1288
+ message: `schemaVersion must be ${MODULE_SCHEMA_VERSION}`
1289
+ }).refine((m) => REVERSE_DNS_ID.test(m.id), { message: "id must be reverse-DNS, lowercase" });
1290
+ CargoManifest = z5.object({
1291
+ package: z5.object({
1292
+ name: z5.string(),
1293
+ metadata: z5.object({ kmod: z5.object({ features: z5.array(z5.string()).default([]) }).optional() }).optional()
1294
+ }),
1295
+ bin: z5.array(z5.object({ name: z5.string() })).default([])
1296
+ });
1297
+ UI_ENTRIES = ["ui/src/module.tsx", "ui/src/module.ts", "ui/src/index.tsx", "ui/src/index.ts"];
1298
+ });
1299
+
1300
+ // src/config.ts
1301
+ import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
1302
+ import { homedir } from "os";
1303
+ import { dirname as dirname4, join as join9 } from "path";
1304
+ import { z as z6 } from "zod";
1305
+ function configPath() {
1306
+ const env = process.env.KROMA_CLI_CONFIG?.trim();
1307
+ if (env)
1308
+ return env;
1309
+ const base = process.env.XDG_CONFIG_HOME?.trim() || join9(homedir(), ".config");
1310
+ return join9(base, "kroma", "cli.json");
1311
+ }
1312
+ function readConfig(path = configPath()) {
1313
+ if (!existsSync6(path))
1314
+ return { servers: {} };
1315
+ try {
1316
+ return Config.parse(JSON.parse(readFileSync6(path, "utf8")));
1317
+ } catch {
1318
+ return { servers: {} };
1319
+ }
1320
+ }
1321
+ function writeConfig(config, path = configPath()) {
1322
+ mkdirSync4(dirname4(path), { recursive: true });
1323
+ writeFileSync4(path, `${JSON.stringify(config, null, 2)}
1324
+ `, { mode: 384 });
1325
+ }
1326
+ function normalizeServer(url) {
1327
+ const withScheme = /^https?:\/\//.test(url) ? url : `http://${url}`;
1328
+ return withScheme.replace(/\/+$/, "");
1329
+ }
1330
+ var Config;
1331
+ var init_config = __esm(() => {
1332
+ Config = z6.object({
1333
+ defaultServer: z6.string().optional(),
1334
+ servers: z6.record(z6.string(), z6.object({ token: z6.string(), user: z6.string().optional() })).default({})
1335
+ });
1336
+ });
1337
+
1338
+ // src/server.ts
1339
+ import { readFileSync as readFileSync7 } from "fs";
1340
+ import { z as z7 } from "zod";
1341
+ function resolveServer(options) {
1342
+ const config = readConfig();
1343
+ const url = normalizeServer(options.server ?? process.env.KROMA_SERVER ?? config.defaultServer ?? DEFAULT_SERVER);
1344
+ const token = options.token ?? process.env.KROMA_TOKEN ?? config.servers[url]?.token;
1345
+ if (!token) {
1346
+ throw new Error(`no token for ${url}: run \`kroma login ${url}\`, or pass --token / set KROMA_TOKEN (an account with settings.manage)`);
1347
+ }
1348
+ return { url, token };
1349
+ }
1350
+ function hostTriplePart(arch = process.arch, platform = process.platform) {
1351
+ const cpu = arch === "arm64" ? "aarch64" : "x86_64";
1352
+ const os = platform === "darwin" ? "apple-darwin" : "linux";
1353
+ return `${cpu}-${os === "linux" ? "unknown-linux" : os}`;
1354
+ }
1355
+ function bundleFor(files2, id, triple = hostTriplePart()) {
1356
+ const mine = files2.filter((f) => f === `${id}.kmod` || f.startsWith(`${id}-`));
1357
+ if (mine.length === 0)
1358
+ return;
1359
+ return mine.find((f) => f === `${id}.kmod`) ?? mine.find((f) => f.includes(triple)) ?? mine[0];
1360
+ }
1361
+ async function serverPlatform(server) {
1362
+ const res = await fetch(`${server.url}/api/admin/store/platform`, {
1363
+ headers: { authorization: `Bearer ${server.token}` }
1364
+ });
1365
+ if (res.status === 404)
1366
+ return null;
1367
+ if (!res.ok)
1368
+ throw new Error(`${server.url}: GET /api/admin/store/platform failed (${res.status})`);
1369
+ return Platform.parse(await res.json());
1370
+ }
1371
+ function bundleRunsOn(file, platform) {
1372
+ if (!platform)
1373
+ return true;
1374
+ const stem = file.replace(/\.kmod$/, "");
1375
+ const dash = stem.indexOf("-");
1376
+ if (dash < 0)
1377
+ return true;
1378
+ return stem.slice(dash + 1) === platform.target;
1379
+ }
1380
+ async function uploadBundle(server, path) {
1381
+ const bytes = readFileSync7(path);
1382
+ const res = await fetch(`${server.url}/api/admin/store/install`, {
1383
+ method: "POST",
1384
+ headers: {
1385
+ authorization: `Bearer ${server.token}`,
1386
+ "content-type": "application/octet-stream"
1387
+ },
1388
+ body: new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength)
1389
+ });
1390
+ const body = await res.text();
1391
+ if (!res.ok)
1392
+ throw new Error(`install failed (${res.status}): ${body}`);
1393
+ return body;
1394
+ }
1395
+ var DEFAULT_SERVER = "http://localhost:4040", Platform;
1396
+ var init_server = __esm(() => {
1397
+ init_config();
1398
+ Platform = z7.object({ target: z7.string(), serverVersion: z7.string() });
1399
+ });
1400
+
1401
+ // src/commands/build.ts
1402
+ var exports_build = {};
1403
+ __export(exports_build, {
1404
+ buildCommand: () => buildCommand,
1405
+ feOutDir: () => feOutDir
1406
+ });
1407
+ import { join as join10 } from "path";
1408
+ function feOutDir(project) {
1409
+ return join10(project.dir, "dist", "fe");
1410
+ }
1411
+ function describe(project) {
1412
+ const server = project.server;
1413
+ if (!server?.bin)
1414
+ return "library, no binary";
1415
+ const extras = server.features.length ? ` [+${server.features.join(",")}]` : "";
1416
+ return `bin ${server.bin}${extras}`;
1417
+ }
1418
+ async function buildCommand(options) {
1419
+ const cwd = options.cwd ?? process.cwd();
1420
+ const projects = findProjects(options.dirs, cwd);
1421
+ const dir = targetDir(cwd, projects);
1422
+ const outDir = options.out ?? join10(cwd, "dist", "modules");
1423
+ const target = options.target?.trim() || process.env.KMOD_TARGET?.trim() || null;
1424
+ const profile = options.profile ?? "release-kmod";
1425
+ const skipBuild = options.skipBuild ?? process.env.KMOD_SKIP_BUILD === "1";
1426
+ const built = [];
1427
+ for (const project of projects) {
1428
+ console.log(`
1429
+ ${style.bold(project.manifest.id)} (${describe(project)})`);
1430
+ built.push({
1431
+ project,
1432
+ binPath: await buildSidecar(project, dir, { target, profile, skipBuild })
1433
+ });
1434
+ }
1435
+ const packed = await Promise.all(built.map(async ({ project, binPath }) => {
1436
+ const fe = feOutDir(project);
1437
+ const hasFe = await buildFrontend(project, fe, "production");
1438
+ const result = packBundle({ project, binPath, feDir: hasFe ? fe : null, outDir, target });
1439
+ console.log(` ${result.changed ? "packed" : "unchanged"}: ${result.path}`);
1440
+ return result;
1441
+ }));
1442
+ console.log(`
1443
+ ${packed.length} bundle(s) in ${outDir}`);
1444
+ return 0;
1445
+ }
1446
+ var init_build3 = __esm(() => {
1447
+ init_pack();
1448
+ init_cargo();
1449
+ init_build2();
1450
+ init_project();
1451
+ init_style();
1452
+ });
1453
+
1454
+ // src/commands/dev.ts
1455
+ var exports_dev = {};
1456
+ __export(exports_dev, {
1457
+ devCommand: () => devCommand
1458
+ });
1459
+ import { existsSync as existsSync7, watch } from "fs";
1460
+ import { join as join11, relative as relative4 } from "path";
1461
+ function partOf(project, file) {
1462
+ const rel = relative4(project.dir, file);
1463
+ if (rel.startsWith("..") || rel.startsWith("dist") || rel.startsWith(".bundle"))
1464
+ return null;
1465
+ if (rel.startsWith("server/"))
1466
+ return rel.endsWith(".rs") || rel.endsWith("Cargo.toml") ? "server" : null;
1467
+ if (rel.startsWith("ui/"))
1468
+ return rel.includes("/dist/") || rel.includes("node_modules") ? null : "ui";
1469
+ if (rel.startsWith("locales/") || rel === "module.json")
1470
+ return "ui";
1471
+ if (rel.startsWith("icon."))
1472
+ return "bundle";
1473
+ return null;
1474
+ }
1475
+
1476
+ class Loop {
1477
+ project;
1478
+ server;
1479
+ dir;
1480
+ target;
1481
+ binPath = null;
1482
+ hasFe = false;
1483
+ running = null;
1484
+ pending = new Set;
1485
+ constructor(project, server, dir, target) {
1486
+ this.project = project;
1487
+ this.server = server;
1488
+ this.dir = dir;
1489
+ this.target = target;
1490
+ }
1491
+ request(parts) {
1492
+ for (const p2 of parts)
1493
+ this.pending.add(p2);
1494
+ if (this.running)
1495
+ return;
1496
+ this.running = this.drain().finally(() => {
1497
+ this.running = null;
1498
+ if (this.pending.size > 0)
1499
+ this.request([]);
1500
+ });
1501
+ }
1502
+ async drain() {
1503
+ const parts = new Set(this.pending);
1504
+ this.pending.clear();
1505
+ const started = Date.now();
1506
+ try {
1507
+ if (parts.has("server")) {
1508
+ this.binPath = await buildSidecar(this.project, this.dir, {
1509
+ target: this.target,
1510
+ profile: "dev"
1511
+ });
1512
+ }
1513
+ if (parts.has("ui")) {
1514
+ this.hasFe = await buildFrontend(this.project, feOutDir(this.project), "development");
1515
+ }
1516
+ const packed = packForDev({
1517
+ project: this.project,
1518
+ binPath: this.binPath,
1519
+ feDir: this.hasFe ? feOutDir(this.project) : null,
1520
+ outDir: join11(this.project.dir, "dist", "dev"),
1521
+ target: this.target
1522
+ });
1523
+ await uploadBundle(this.server, packed.path);
1524
+ console.log(` ${style.green("installed")} ${packed.file} in ${Date.now() - started}ms`);
1525
+ } catch (e) {
1526
+ console.error(` ${style.red("failed")}: ${e instanceof Error ? e.message : String(e)}`);
1527
+ console.error(" the running module is left as it was");
1528
+ }
1529
+ }
1530
+ }
1531
+ async function devCommand(options) {
1532
+ const cwd = options.cwd ?? process.cwd();
1533
+ const project = openProject(options.dir ? join11(cwd, options.dir) : cwd);
1534
+ const server = resolveServer(options);
1535
+ const platform = await serverPlatform(server);
1536
+ const target = options.target?.trim() || null;
1537
+ const host = hostTriplePart();
1538
+ if (platform && !target && !platform.target.startsWith(host)) {
1539
+ throw new Error(`${server.url} runs ${platform.target} and this machine builds ${host}; pass --target ${platform.target}`);
1540
+ }
1541
+ if (platform && target && !bundleRunsOn(`x-${target}.kmod`, platform)) {
1542
+ throw new Error(`${server.url} runs ${platform.target}, not ${target}`);
1543
+ }
1544
+ const dir = targetDir(cwd, [project]);
1545
+ const loop = new Loop(project, server, dir, target);
1546
+ console.log(`${style.bold(project.manifest.id)} -> ${server.url}`);
1547
+ loop.request(["server", "ui"]);
1548
+ const timers = new Map;
1549
+ const roots = [
1550
+ "server/src",
1551
+ "server/Cargo.toml",
1552
+ "ui/src",
1553
+ "locales",
1554
+ "module.json",
1555
+ "icon.svg",
1556
+ "icon.png"
1557
+ ].map((r) => join11(project.dir, r)).filter((r) => existsSync7(r));
1558
+ for (const root of roots) {
1559
+ watch(root, { recursive: true }, (_event, file) => {
1560
+ const part = partOf(project, join11(root, file ?? ""));
1561
+ if (!part)
1562
+ return;
1563
+ clearTimeout(timers.get(part));
1564
+ timers.set(part, setTimeout(() => {
1565
+ console.log(`
1566
+ ${relative4(project.dir, join11(root, file ?? ""))} changed`);
1567
+ loop.request([part]);
1568
+ }, DEBOUNCE_MS));
1569
+ });
1570
+ }
1571
+ console.log(`watching ${roots.map((r) => relative4(project.dir, r)).join(", ")}
1572
+ `);
1573
+ await new Promise(() => {});
1574
+ return 0;
1575
+ }
1576
+ var DEBOUNCE_MS = 120;
1577
+ var init_dev = __esm(() => {
1578
+ init_pack();
1579
+ init_cargo();
1580
+ init_build2();
1581
+ init_project();
1582
+ init_server();
1583
+ init_style();
1584
+ init_build3();
1585
+ });
1586
+
1587
+ // src/commands/check.ts
1588
+ var exports_check = {};
1589
+ __export(exports_check, {
1590
+ checkCommand: () => checkCommand,
1591
+ importProblems: () => importProblems
1592
+ });
1593
+ import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
1594
+ import { dirname as dirname5, join as join12, relative as relative5 } from "path";
1595
+ var {$: $3 } = globalThis.Bun;
1596
+ function sources(dir) {
1597
+ if (!existsSync8(dir))
1598
+ return [];
1599
+ return readdirSync5(dir, { withFileTypes: true, recursive: true }).filter((e) => e.isFile() && /\.(ts|tsx)$/.test(e.name) && !/\.test\.tsx?$/.test(e.name)).map((e) => join12(e.parentPath, e.name));
1600
+ }
1601
+ function importProblems(file, code, projectDir) {
1602
+ const out = [];
1603
+ const label = relative5(projectDir, file);
1604
+ for (const m of code.matchAll(IMPORT)) {
1605
+ const spec = m[1] ?? m[2] ?? "";
1606
+ if (spec.startsWith("#ui/")) {
1607
+ out.push(`${label}: '${spec}' is the kit's private alias; import from '@kroma/ui/kit'`);
1608
+ } else if (spec.startsWith(".")) {
1609
+ const target = join12(dirname5(file), spec);
1610
+ if (relative5(projectDir, target).startsWith("..")) {
1611
+ out.push(`${label}: '${spec}' reaches outside the module`);
1612
+ }
1613
+ }
1614
+ }
1615
+ return out;
1616
+ }
1617
+ async function checkTs(project) {
1618
+ if (!project.ui)
1619
+ return [];
1620
+ const tsconfigDir = [project.dir, project.ui.dir].find((d) => existsSync8(join12(d, "tsconfig.json")));
1621
+ const problems = sources(join12(project.ui.dir, "src")).flatMap((f) => importProblems(f, readFileSync8(f, "utf8"), project.dir));
1622
+ if (!tsconfigDir)
1623
+ return [...problems, `${project.manifest.id}: no tsconfig.json beside the frontend`];
1624
+ const tsc = await $3`bun x tsc --noEmit -p ${tsconfigDir}`.cwd(tsconfigDir).nothrow();
1625
+ if (tsc.exitCode !== 0)
1626
+ problems.push(`${project.manifest.id}: tsc failed`);
1627
+ return problems;
1628
+ }
1629
+ async function checkCommand(options) {
1630
+ const cwd = options.cwd ?? process.cwd();
1631
+ const projects = findProjects(options.dirs, cwd);
1632
+ const dir = targetDir(cwd, projects);
1633
+ const problems = [];
1634
+ const seen = new Map;
1635
+ for (const p2 of projects) {
1636
+ const first = seen.get(p2.manifest.id);
1637
+ if (first)
1638
+ problems.push(`duplicate module id "${p2.manifest.id}" in ${first} and ${p2.dir}`);
1639
+ seen.set(p2.manifest.id, p2.dir);
1640
+ }
1641
+ for (const project of projects) {
1642
+ console.log(`
1643
+ ${style.bold(project.manifest.id)}`);
1644
+ if (options.ts !== false)
1645
+ problems.push(...await checkTs(project));
1646
+ if (options.rust !== false && project.server) {
1647
+ const code = await cargo(project.server.dir, ["clippy", "--all-targets", "--", "-D", "warnings"], dir);
1648
+ if (code !== 0)
1649
+ problems.push(`${project.manifest.id}: clippy failed`);
1650
+ }
1651
+ }
1652
+ if (problems.length > 0) {
1653
+ console.error(`
1654
+ ${style.red(`${problems.length} problem(s)`)}`);
1655
+ for (const p2 of problems)
1656
+ console.error(` - ${p2}`);
1657
+ return 1;
1658
+ }
1659
+ console.log(`
1660
+ ${style.green("every check passed")} (${projects.length} module(s))`);
1661
+ return 0;
1662
+ }
1663
+ var IMPORT;
1664
+ var init_check = __esm(() => {
1665
+ init_cargo();
1666
+ init_project();
1667
+ init_style();
1668
+ IMPORT = /^\s*(?:import|export)\b[^'"]*?from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]/gm;
1669
+ });
1670
+
1671
+ // src/commands/install.ts
1672
+ var exports_install = {};
1673
+ __export(exports_install, {
1674
+ installCommand: () => installCommand
1675
+ });
1676
+ import { existsSync as existsSync9, readdirSync as readdirSync6 } from "fs";
1677
+ import { basename, join as join13 } from "path";
1678
+ function pickBundle(options, cwd, triple) {
1679
+ if (options.file)
1680
+ return options.file;
1681
+ const id = options.id ?? (existsSync9(join13(cwd, "module.json")) ? openProject(cwd).manifest.id : undefined);
1682
+ if (!id)
1683
+ throw new Error("usage: kroma install [module-id] [--file x.kmod] [--server URL] [--token T]");
1684
+ const dir = options.from ?? join13(cwd, "dist", "modules");
1685
+ const file = existsSync9(dir) ? bundleFor(readdirSync6(dir), id, triple) : undefined;
1686
+ if (!file)
1687
+ throw new Error(`no packed bundle for '${id}' in ${dir}; run \`kroma build\` first`);
1688
+ return join13(dir, file);
1689
+ }
1690
+ async function installCommand(options) {
1691
+ const cwd = options.cwd ?? process.cwd();
1692
+ const server = resolveServer(options);
1693
+ const platform = await serverPlatform(server);
1694
+ const path = pickBundle(options, cwd, platform?.target ?? hostTriplePart());
1695
+ if (!bundleRunsOn(basename(path), platform)) {
1696
+ throw new Error(`${basename(path)} was built for another platform; the server at ${server.url} runs ${platform?.target}. Build with --target ${platform?.target}.`);
1697
+ }
1698
+ const body = await uploadBundle(server, path);
1699
+ console.log(`installed ${basename(path)} -> ${server.url}`);
1700
+ if (body.trim())
1701
+ console.log(` ${body.trim()}`);
1702
+ return 0;
1703
+ }
1704
+ var init_install = __esm(() => {
1705
+ init_project();
1706
+ init_server();
1707
+ });
1708
+
1709
+ // src/commands/login.ts
1710
+ var exports_login = {};
1711
+ __export(exports_login, {
1712
+ loginCommand: () => loginCommand
1713
+ });
1714
+ import * as p2 from "@clack/prompts";
1715
+ import { z as z8 } from "zod";
1716
+ async function ask2(label, given, secret) {
1717
+ if (given)
1718
+ return given;
1719
+ const answer2 = secret ? await p2.password({ message: label }) : await p2.text({ message: label, validate: (v) => v ? undefined : "required" });
1720
+ if (p2.isCancel(answer2))
1721
+ throw new Error("cancelled");
1722
+ return answer2;
1723
+ }
1724
+ async function loginCommand(options) {
1725
+ const url = normalizeServer(options.server ?? process.env.KROMA_SERVER ?? DEFAULT_SERVER);
1726
+ p2.intro(`sign in to ${url}`);
1727
+ const email = await ask2("email or username", options.email ?? process.env.KROMA_EMAIL, false);
1728
+ const password2 = await ask2("password", options.password ?? process.env.KROMA_PASSWORD, true);
1729
+ const res = await fetch(`${url}/api/auth/login`, {
1730
+ method: "POST",
1731
+ headers: { "content-type": "application/json" },
1732
+ body: JSON.stringify({ email, password: password2 })
1733
+ });
1734
+ if (!res.ok)
1735
+ throw new Error(`login failed (${res.status}): ${(await res.text()).trim()}`);
1736
+ const { token, user } = Login.parse(await res.json());
1737
+ const config = readConfig();
1738
+ config.servers[url] = { token, user: user?.email ?? user?.name ?? email };
1739
+ config.defaultServer = url;
1740
+ writeConfig(config);
1741
+ p2.outro(`signed in; token kept in ${configPath()}`);
1742
+ return 0;
1743
+ }
1744
+ var Login;
1745
+ var init_login = __esm(() => {
1746
+ init_config();
1747
+ init_server();
1748
+ Login = z8.object({
1749
+ token: z8.string(),
1750
+ user: z8.object({ email: z8.string().optional(), name: z8.string().optional() }).loose().optional()
1751
+ });
1752
+ });
1753
+
1754
+ // src/commands/plan.ts
1755
+ var exports_plan = {};
1756
+ __export(exports_plan, {
1757
+ planCommand: () => planCommand
1758
+ });
1759
+ import { relative as relative6 } from "path";
1760
+ function planCommand(dirs, target, cwd = process.cwd()) {
1761
+ const projects = findProjects(dirs, cwd);
1762
+ const dir = targetDir(cwd, projects);
1763
+ const triple = target?.trim() || process.env.KMOD_TARGET?.trim() || null;
1764
+ const lines = [`export CARGO_TARGET_DIR="$PWD/${relative6(cwd, dir)}"`];
1765
+ for (const project of projects) {
1766
+ const server = project.server;
1767
+ if (!server?.bin)
1768
+ continue;
1769
+ const { args } = cargoBuild(server.bin, server.features, triple, "release-kmod", dir);
1770
+ const manifest = relative6(cwd, `${server.dir}/Cargo.toml`);
1771
+ lines.push(`cargo ${args.join(" ")} --manifest-path ${manifest}`);
1772
+ }
1773
+ process.stdout.write(`${lines.join(`
1774
+ `)}
1775
+ `);
1776
+ return 0;
1777
+ }
1778
+ var init_plan2 = __esm(() => {
1779
+ init_cargo();
1780
+ init_project();
1781
+ });
1782
+
1783
+ // src/commands/cargo.ts
1784
+ var exports_cargo = {};
1785
+ __export(exports_cargo, {
1786
+ cargoCommand: () => cargoCommand
1787
+ });
1788
+ import { existsSync as existsSync10 } from "fs";
1789
+ import { join as join14 } from "path";
1790
+ async function cargoCommand(args, cwd = process.cwd()) {
1791
+ if (args.length === 0)
1792
+ throw new Error("usage: kroma cargo <cargo-subcommand> [args...]");
1793
+ const projects = findProjects([], cwd);
1794
+ const dir = targetDir(cwd, projects);
1795
+ const workspaces = projects.flatMap((p3) => p3.server ? [[p3.manifest.id, p3.server.dir]] : []);
1796
+ const lib = join14(cwd, "modules", "lib");
1797
+ if (existsSync10(join14(lib, "Cargo.toml")))
1798
+ workspaces.push(["lib", lib]);
1799
+ const failed = [];
1800
+ for (const [id, crateDir] of workspaces) {
1801
+ console.log(`
1802
+ === ${id}: cargo ${args.join(" ")}`);
1803
+ if (await cargo(crateDir, args, dir) !== 0)
1804
+ failed.push(id);
1805
+ }
1806
+ if (failed.length > 0) {
1807
+ console.error(`
1808
+ cargo ${args[0]} failed in ${failed.length} module(s): ${failed.join(", ")}`);
1809
+ return 1;
1810
+ }
1811
+ console.log(`
1812
+ cargo ${args[0]}: every module passed`);
1813
+ return 0;
1814
+ }
1815
+ var init_cargo2 = __esm(() => {
1816
+ init_cargo();
1817
+ init_project();
1818
+ });
1819
+
1820
+ // src/bundle/read.ts
1821
+ import { createHash } from "crypto";
1822
+ import { existsSync as existsSync11, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
1823
+ import { join as join15 } from "path";
1824
+ function iconDataUri(tar) {
1825
+ const svg = tarRead(tar, "icon.svg");
1826
+ if (svg && svg.length <= ICON_MAX) {
1827
+ return `data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`;
1828
+ }
1829
+ const png = tarRead(tar, "icon.png");
1830
+ if (png && png.length <= ICON_MAX) {
1831
+ return `data:image/png;base64,${Buffer.from(png).toString("base64")}`;
1832
+ }
1833
+ return;
1834
+ }
1835
+ function readBundle(path) {
1836
+ const file = path.split("/").pop() ?? path;
1837
+ const bytes = readFileSync9(path);
1838
+ const tar = toTar(new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength));
1839
+ const manifestBytes = tarRead(tar, "module.json");
1840
+ if (!manifestBytes) {
1841
+ console.warn(` ! ${file}: no module.json inside, skipped`);
1842
+ return null;
1843
+ }
1844
+ const read = Manifest.safeParse(JSON.parse(new TextDecoder().decode(manifestBytes)));
1845
+ if (!read.success) {
1846
+ console.warn(` ! ${file}: module.json is not a manifest, skipped (${read.error.message})`);
1847
+ return null;
1848
+ }
1849
+ const manifest = read.data;
1850
+ if (!speaksCurrentSchema(manifest)) {
1851
+ console.warn(` ! ${file}: built for manifest schema v${manifest.schemaVersion ?? 0}, and this SDK speaks v${MODULE_SCHEMA_VERSION}; skipped`);
1852
+ return null;
1853
+ }
1854
+ const stem = file.slice(0, -".kmod".length);
1855
+ const target = stem === manifest.id ? null : stem.slice(manifest.id.length).replace(/^-/, "") || null;
1856
+ return {
1857
+ manifest,
1858
+ target,
1859
+ file,
1860
+ path,
1861
+ size: bytes.length,
1862
+ sha256: createHash("sha256").update(bytes).digest("hex"),
1863
+ contentHash: createHash("sha256").update(tar).digest("hex"),
1864
+ icon: iconDataUri(tar)
1865
+ };
1866
+ }
1867
+ function readBundles(dir) {
1868
+ if (!existsSync11(dir)) {
1869
+ throw new Error(`no packed modules at ${dir}; run \`kroma build\` first`);
1870
+ }
1871
+ return readdirSync7(dir).filter((f) => f.endsWith(".kmod")).sort(byCodeUnit2).flatMap((f) => readBundle(join15(dir, f)) ?? []);
1872
+ }
1873
+ function toEntries(bundles, baseFor) {
1874
+ const entries = new Map;
1875
+ for (const b of bundles) {
1876
+ const base = baseFor(b).replace(/\/$/, "");
1877
+ const artifact = {
1878
+ target: b.target,
1879
+ file: b.file,
1880
+ url: base ? `${base}/${b.file}` : b.file,
1881
+ size: b.size,
1882
+ sha256: b.sha256,
1883
+ contentHash: b.contentHash
1884
+ };
1885
+ const existing = entries.get(b.manifest.id);
1886
+ if (existing) {
1887
+ existing.artifacts.push(artifact);
1888
+ existing.icon ??= b.icon;
1889
+ continue;
1890
+ }
1891
+ entries.set(b.manifest.id, {
1892
+ ...b.manifest,
1893
+ icon: b.icon,
1894
+ artifacts: [artifact],
1895
+ file: artifact.file,
1896
+ url: artifact.url,
1897
+ size: artifact.size,
1898
+ sha256: artifact.sha256
1899
+ });
1900
+ }
1901
+ const out = [...entries.values()].sort((a, b) => byCodeUnit2(a.id, b.id));
1902
+ for (const m of out) {
1903
+ m.artifacts.sort((a, b) => byCodeUnit2(a.target ?? "", b.target ?? ""));
1904
+ const first = m.artifacts[0];
1905
+ if (first) {
1906
+ m.file = first.file;
1907
+ m.url = first.url;
1908
+ m.size = first.size;
1909
+ m.sha256 = first.sha256;
1910
+ }
1911
+ }
1912
+ return out;
1913
+ }
1914
+ var ICON_MAX;
1915
+ var init_read = __esm(() => {
1916
+ init_src();
1917
+ init_tar();
1918
+ ICON_MAX = 64 * 1024;
1919
+ });
1920
+
1921
+ // src/commands/registry.ts
1922
+ var exports_registry = {};
1923
+ __export(exports_registry, {
1924
+ registryCommand: () => registryCommand,
1925
+ resolveDir: () => resolveDir
1926
+ });
1927
+ import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
1928
+ import { isAbsolute as isAbsolute2, join as join16 } from "path";
1929
+ function resolveDir(value, fallback, cwd) {
1930
+ if (!value)
1931
+ return join16(cwd, fallback);
1932
+ return isAbsolute2(value) ? value : join16(cwd, value);
1933
+ }
1934
+ function registryCommand(options) {
1935
+ const cwd = options.cwd ?? process.cwd();
1936
+ const modulesDir = resolveDir(options.from, "dist/modules", cwd);
1937
+ const outDir = resolveDir(options.out, "dist/registry", cwd);
1938
+ const baseUrl = (options.base ?? "").replace(/\/$/, "");
1939
+ const bundles = readBundles(modulesDir);
1940
+ mkdirSync5(outDir, { recursive: true });
1941
+ for (const b of bundles)
1942
+ copyFileSync2(b.path, join16(outDir, b.file));
1943
+ const modules = toEntries(bundles, () => baseUrl);
1944
+ const write2 = (rel, value) => {
1945
+ const path = join16(outDir, rel);
1946
+ mkdirSync5(join16(path, ".."), { recursive: true });
1947
+ writeFileSync5(path, `${JSON.stringify(value, null, 2)}
1948
+ `);
1949
+ };
1950
+ write2("catalog.json", { schema: 2, generatedAt: new Date().toISOString(), modules });
1951
+ write2("registry.json", buildDescriptor("KROMA modules", baseUrl, modules));
1952
+ write2("index.json", buildIndex(modules));
1953
+ for (const entry of modules)
1954
+ write2(`m/${entry.id}.json`, buildModuleRecord(entry));
1955
+ for (const name of SCHEMA_NAMES) {
1956
+ const schema = jsonSchema(name);
1957
+ write2(schemaPath(name).replace(/^\//, ""), schema);
1958
+ write2(`schemas/${name}.json`, schema);
1959
+ }
1960
+ console.log(`registry: ${modules.length} module(s) -> ${outDir}`);
1961
+ for (const m of modules) {
1962
+ const targets = m.artifacts.map((a) => a.target ?? "universal").join(", ");
1963
+ console.log(` ${m.id} v${m.version} [${targets}]`);
1964
+ }
1965
+ return 0;
1966
+ }
1967
+ var init_registry = __esm(() => {
1968
+ init_src();
1969
+ init_read();
1970
+ });
1971
+
1972
+ // src/commands/serve.ts
1973
+ var exports_serve = {};
1974
+ __export(exports_serve, {
1975
+ registryApp: () => registryApp,
1976
+ serveCommand: () => serveCommand
1977
+ });
1978
+ import { existsSync as existsSync12, readFileSync as readFileSync10 } from "fs";
1979
+ import { join as join17 } from "path";
1980
+ import { Hono } from "hono";
1981
+ function registryApp(dir) {
1982
+ const app = new Hono;
1983
+ const entries = (url) => toEntries(readBundles(dir), () => origin(url));
1984
+ app.get("/registry.json", (c) => json(buildDescriptor(REGISTRY_NAME, origin(c.req.url), entries(c.req.url))));
1985
+ app.get("/index.json", (c) => json(buildIndex(entries(c.req.url))));
1986
+ app.get("/m/:id{[^/]+[.]json}", (c) => {
1987
+ const id = decodeURIComponent(c.req.param("id").replace(/\.json$/, ""));
1988
+ const found = entries(c.req.url).find((m) => m.id === id);
1989
+ return found ? json(buildModuleRecord(found)) : c.json({ error: "no such module" }, 404);
1990
+ });
1991
+ app.get("/schemas/:version{[0-9]+}/:name{[^/]+[.]json}", (c) => {
1992
+ const name = schemaNamed(c.req.param("name"));
1993
+ if (!name)
1994
+ return c.json({ error: "no such schema" }, 404);
1995
+ return json(jsonSchema(name, Number(c.req.param("version"))));
1996
+ });
1997
+ app.get("/schemas/:name{[^/]+[.]json}", (c) => {
1998
+ const name = schemaNamed(c.req.param("name"));
1999
+ return name ? json(jsonSchema(name)) : c.json({ error: "no such schema" }, 404);
2000
+ });
2001
+ app.get("/:file{[^/]+[.]kmod}", (c) => {
2002
+ const file = c.req.param("file");
2003
+ const named = readBundles(dir).some((b) => b.file === file);
2004
+ const path = join17(dir, file);
2005
+ if (!named || !existsSync12(path))
2006
+ return c.json({ error: "no such bundle" }, 404);
2007
+ const bytes = readFileSync10(path);
2008
+ return new Response(new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength), {
2009
+ headers: { "content-type": "application/octet-stream" }
2010
+ });
2011
+ });
2012
+ return app;
2013
+ }
2014
+ async function serveCommand(options) {
2015
+ const cwd = options.cwd ?? process.cwd();
2016
+ const dir = resolveDir(options.from, "dist/modules", cwd);
2017
+ const port = options.port ?? 4173;
2018
+ Bun.serve({ port, fetch: registryApp(dir).fetch });
2019
+ const found = readBundles(dir);
2020
+ console.log(`serving ${found.length} bundle(s) from ${dir}
2021
+ `);
2022
+ for (const b of found)
2023
+ console.log(` ${b.manifest.id} v${b.manifest.version}`);
2024
+ console.log(`
2025
+ http://localhost:${port}/registry.json`);
2026
+ console.log(`
2027
+ Add http://localhost:${port} under Admin -> Modules -> Registries to browse it.`);
2028
+ await new Promise(() => {});
2029
+ return 0;
2030
+ }
2031
+ var REGISTRY_NAME = "KROMA modules (local)", origin = (url) => new URL(url).origin, json = (value) => new Response(`${JSON.stringify(value, null, 2)}
2032
+ `, {
2033
+ headers: { "content-type": "application/json", "access-control-allow-origin": "*" }
2034
+ }), schemaNamed = (name) => SCHEMA_NAMES.find((candidate) => candidate === name.replace(/\.json$/, ""));
2035
+ var init_serve = __esm(() => {
2036
+ init_src();
2037
+ init_read();
2038
+ init_registry();
2039
+ });
2040
+
2041
+ // src/bundle/catalog.ts
2042
+ import { z as z9 } from "zod";
2043
+ var Artifact, Entry, Catalog;
2044
+ var init_catalog = __esm(() => {
2045
+ init_src();
2046
+ Artifact = ArtifactRef.extend({
2047
+ target: z9.string().nullable(),
2048
+ file: z9.string(),
2049
+ size: z9.number().int().nonnegative(),
2050
+ sha256: z9.string(),
2051
+ contentHash: z9.string()
2052
+ });
2053
+ Entry = DescribedModule.extend({
2054
+ icon: z9.string().optional(),
2055
+ artifacts: z9.array(Artifact),
2056
+ file: z9.string(),
2057
+ url: z9.string(),
2058
+ size: z9.number().int().nonnegative(),
2059
+ sha256: z9.string()
2060
+ });
2061
+ Catalog = z9.object({
2062
+ schema: z9.number(),
2063
+ generatedAt: z9.string().nullish(),
2064
+ modules: z9.array(Entry).default([])
2065
+ });
2066
+ });
2067
+
2068
+ // src/commands/release.ts
2069
+ var exports_release = {};
2070
+ __export(exports_release, {
2071
+ decide: () => decide,
2072
+ releaseCommand: () => releaseCommand,
2073
+ tagFor: () => tagFor,
2074
+ verdictFor: () => verdictFor
2075
+ });
2076
+ import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
2077
+ import { join as join18 } from "path";
2078
+ function tagFor(id, version) {
2079
+ return `${id}@${version}`;
2080
+ }
2081
+ function verdictFor(local, live) {
2082
+ if (!live)
2083
+ return { kind: "new" };
2084
+ const order = compareRaw(local.version, live.version);
2085
+ if (order < 0)
2086
+ return { kind: "backwards", published: live.version };
2087
+ if (order > 0)
2088
+ return { kind: "publish", from: live.version };
2089
+ const liveHashes = new Map(live.artifacts.map((a) => [a.target ?? "", a.contentHash]));
2090
+ const stale = local.artifacts.filter((a) => {
2091
+ const published = liveHashes.get(a.target ?? "");
2092
+ return published !== undefined && published !== a.contentHash;
2093
+ }).map((a) => a.target ?? "universal");
2094
+ stale.sort(byCodeUnit2);
2095
+ if (stale.length > 0) {
2096
+ return { kind: "stale", published: live.version, targets: stale };
2097
+ }
2098
+ return { kind: "unchanged" };
2099
+ }
2100
+ async function loadPublished(source) {
2101
+ if (!/^https?:\/\//.test(source)) {
2102
+ if (!existsSync13(source))
2103
+ throw new Error(`--published ${source} does not exist`);
2104
+ return Catalog.parse(JSON.parse(readFileSync11(source, "utf8")));
2105
+ }
2106
+ const res = await fetch(source, { headers: { "user-agent": "kroma-cli" } });
2107
+ if (res.status === 404) {
2108
+ console.warn(` ! ${source} is 404: treating every module as a first release`);
2109
+ return { schema: 2, modules: [] };
2110
+ }
2111
+ if (!res.ok)
2112
+ throw new Error(`${source}: HTTP ${res.status}`);
2113
+ return Catalog.parse(await res.json());
2114
+ }
2115
+ function decide(bundles, published, repo, now) {
2116
+ const live = new Map((published.modules ?? []).map((m) => [m.id, m]));
2117
+ const local = toEntries(bundles, (b) => `https://github.com/${repo}/releases/download/${tagFor(b.manifest.id, b.manifest.version)}`);
2118
+ const plan = { publish: [], unchanged: [], carried: [] };
2119
+ const stale = [];
2120
+ const errors = [];
2121
+ const entries = [];
2122
+ for (const entry of local) {
2123
+ if (!parse(entry.version)) {
2124
+ errors.push(`${entry.id}: version ${JSON.stringify(entry.version)} is not semver, so it cannot be ordered against what is published`);
2125
+ continue;
2126
+ }
2127
+ const verdict = verdictFor(entry, live.get(entry.id));
2128
+ switch (verdict.kind) {
2129
+ case "new":
2130
+ case "publish":
2131
+ plan.publish.push({
2132
+ id: entry.id,
2133
+ version: entry.version,
2134
+ tag: tagFor(entry.id, entry.version),
2135
+ files: entry.artifacts.flatMap((a) => [a.file, `${a.file}.sha256`]),
2136
+ reason: verdict.kind
2137
+ });
2138
+ entries.push(entry);
2139
+ break;
2140
+ case "unchanged":
2141
+ plan.unchanged.push(entry.id);
2142
+ entries.push(live.get(entry.id));
2143
+ break;
2144
+ case "stale":
2145
+ stale.push([
2146
+ `${entry.id}: the bundle changed but the version did not.`,
2147
+ ` module.json says ${entry.version}, which is already published`,
2148
+ ` differing target(s): ${verdict.targets.join(", ")}`,
2149
+ ` Bump the module's version past ${verdict.published} and re-push.`
2150
+ ].join(`
2151
+ `));
2152
+ entries.push(live.get(entry.id));
2153
+ break;
2154
+ case "backwards":
2155
+ errors.push(`${entry.id}: version ${entry.version} is OLDER than the published ${verdict.published}; a release cannot go backwards`);
2156
+ entries.push(live.get(entry.id));
2157
+ break;
2158
+ }
2159
+ }
2160
+ const packed = new Set(local.map((m) => m.id));
2161
+ for (const [id, entry] of live) {
2162
+ if (!packed.has(id)) {
2163
+ plan.carried.push(id);
2164
+ entries.push(entry);
2165
+ }
2166
+ }
2167
+ entries.sort((a, b) => byCodeUnit2(a.id, b.id));
2168
+ return { plan, catalog: { schema: 2, generatedAt: now, modules: entries }, stale, errors };
2169
+ }
2170
+ function report(plan, stale, errors, strict) {
2171
+ for (const r of plan.publish) {
2172
+ const label = r.reason === "new" ? "new" : "update";
2173
+ console.log(` publish ${r.tag} (${label}, ${r.files.length / 2} artifact(s))`);
2174
+ }
2175
+ for (const id of plan.unchanged)
2176
+ console.log(` unchanged ${id}`);
2177
+ for (const id of plan.carried)
2178
+ console.log(` carried ${id} (not built in this run)`);
2179
+ if (stale.length > 0) {
2180
+ console.warn(`
2181
+ ${stale.length} module(s) changed without a version bump, NOT published:
2182
+ `);
2183
+ for (const s of stale)
2184
+ console.warn(` ! ${s}
2185
+ `);
2186
+ console.warn(strict ? " --strict: treating unbumped modules as a failure." : " The ready modules above still ship. Bump these and re-push to release them.");
2187
+ }
2188
+ if (errors.length > 0) {
2189
+ console.error(`
2190
+ ${errors.length} module(s) cannot be released:
2191
+ `);
2192
+ for (const e of errors)
2193
+ console.error(` x ${e}
2194
+ `);
2195
+ }
2196
+ }
2197
+ async function releaseCommand(options) {
2198
+ const repo = options.repo ?? process.env.GITHUB_REPOSITORY;
2199
+ if (!repo)
2200
+ throw new Error("--repo owner/name is required (or set GITHUB_REPOSITORY)");
2201
+ const cwd = options.cwd ?? process.cwd();
2202
+ const modulesDir = resolveDir(options.from, "dist/modules", cwd);
2203
+ const outDir = resolveDir(options.out, "dist/registry", cwd);
2204
+ const bundles = readBundles(modulesDir);
2205
+ const published = await loadPublished(options.published ?? DEFAULT_REGISTRY);
2206
+ const { plan, catalog, stale, errors } = decide(bundles, published, repo, new Date().toISOString());
2207
+ report(plan, stale, errors, options.strict === true);
2208
+ if (errors.length > 0)
2209
+ return 1;
2210
+ if (options.strict && stale.length > 0)
2211
+ return 1;
2212
+ if (options.dryRun) {
2213
+ console.log(`
2214
+ --dry-run: wrote nothing`);
2215
+ return 0;
2216
+ }
2217
+ mkdirSync6(outDir, { recursive: true });
2218
+ writeFileSync6(join18(outDir, "modules.json"), `${JSON.stringify(catalog, null, 2)}
2219
+ `);
2220
+ writeFileSync6(join18(outDir, "plan.json"), `${JSON.stringify(plan, null, 2)}
2221
+ `);
2222
+ console.log(`
2223
+ ${plan.publish.length} release(s) to cut; catalog describes ${catalog.modules.length} module(s) -> ${outDir}`);
2224
+ return 0;
2225
+ }
2226
+ var DEFAULT_REGISTRY = "https://modules.kroma.tv/modules.json";
2227
+ var init_release = __esm(() => {
2228
+ init_src();
2229
+ init_catalog();
2230
+ init_read();
2231
+ init_registry();
2232
+ });
2233
+
2234
+ // src/cli.ts
2235
+ import { defineCommand, runMain } from "citty";
2236
+
2237
+ // src/exit-after.ts
2238
+ async function exitAfter(work) {
2239
+ try {
2240
+ return process.exit(await work);
2241
+ } catch (error) {
2242
+ console.error(error instanceof Error ? error.message : String(error));
2243
+ return process.exit(1);
2244
+ }
2245
+ }
2246
+
2247
+ // src/cli.ts
2248
+ var dirsArg = {
2249
+ type: "positional",
2250
+ required: false,
2251
+ description: "Module directories; default: this module, or every one under modules/"
2252
+ };
2253
+ var serverArgs = {
2254
+ server: { type: "string", valueHint: "url", description: "The KROMA server (KROMA_SERVER)" },
2255
+ token: { type: "string", valueHint: "token", description: "A session token (KROMA_TOKEN)" }
2256
+ };
2257
+ var text3 = (v) => typeof v === "string" && v !== "" ? v : undefined;
2258
+ var list = (v) => {
2259
+ if (Array.isArray(v))
2260
+ return v.map(String);
2261
+ return typeof v === "string" && v !== "" ? [v] : [];
2262
+ };
2263
+ var create = defineCommand({
2264
+ meta: {
2265
+ name: "create",
2266
+ description: "Scaffold a module: a few questions, then a project ready for `kroma dev`."
2267
+ },
2268
+ args: {
2269
+ dir: {
2270
+ type: "positional",
2271
+ required: false,
2272
+ description: "Where to put it (defaults to the module id)"
2273
+ },
2274
+ id: { type: "string", valueHint: "tv.acme.notes", description: "The module id" },
2275
+ name: { type: "string", description: "Display name" },
2276
+ description: { type: "string", description: "One line about the module" },
2277
+ kind: {
2278
+ type: "string",
2279
+ valueHint: "full|server|ui",
2280
+ description: "A page and a sidecar, a sidecar, or a page"
2281
+ },
2282
+ storage: { type: "boolean", description: "The sidecar keeps its own database" },
2283
+ "in-repo": {
2284
+ type: "boolean",
2285
+ description: "Path deps into this checkout (the default inside it)"
2286
+ },
2287
+ install: {
2288
+ type: "boolean",
2289
+ default: true,
2290
+ description: "Run bun install afterwards",
2291
+ negativeDescription: "Skip bun install"
2292
+ },
2293
+ yes: { type: "boolean", default: false, description: "Take every default, ask nothing" }
2294
+ },
2295
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_create(), exports_create)).then((m) => m.createCommand({
2296
+ dir: text3(args.dir),
2297
+ id: text3(args.id),
2298
+ name: text3(args.name),
2299
+ description: text3(args.description),
2300
+ kind: text3(args.kind),
2301
+ storage: typeof args.storage === "boolean" ? args.storage : undefined,
2302
+ inRepo: typeof args["in-repo"] === "boolean" ? args["in-repo"] : undefined,
2303
+ install: args.install !== false,
2304
+ yes: args.yes === true
2305
+ })))
2306
+ });
2307
+ var dev = defineCommand({
2308
+ meta: {
2309
+ name: "dev",
2310
+ description: "Build the module, install it on a server, and again on every save."
2311
+ },
2312
+ args: {
2313
+ dir: {
2314
+ type: "positional",
2315
+ required: false,
2316
+ description: "The module directory (default: here)"
2317
+ },
2318
+ target: {
2319
+ type: "string",
2320
+ valueHint: "triple",
2321
+ description: "Cross-compile the sidecar for the server"
2322
+ },
2323
+ ...serverArgs
2324
+ },
2325
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_dev(), exports_dev)).then((m) => m.devCommand({
2326
+ dir: text3(args.dir),
2327
+ target: text3(args.target),
2328
+ server: text3(args.server),
2329
+ token: text3(args.token)
2330
+ })))
2331
+ });
2332
+ var build2 = defineCommand({
2333
+ meta: {
2334
+ name: "build",
2335
+ description: "Pack the installable .kmod: the sidecar, the frontend, the manifest."
2336
+ },
2337
+ args: {
2338
+ dirs: dirsArg,
2339
+ out: {
2340
+ type: "string",
2341
+ valueHint: "dir",
2342
+ description: "Output directory (default: dist/modules)"
2343
+ },
2344
+ target: {
2345
+ type: "string",
2346
+ valueHint: "triple",
2347
+ description: "Cross-compile for this Rust target (KMOD_TARGET)"
2348
+ },
2349
+ debug: { type: "boolean", default: false, description: "A dev-profile sidecar" },
2350
+ "skip-build": {
2351
+ type: "boolean",
2352
+ default: false,
2353
+ description: "Pack a binary built out of band (KMOD_SKIP_BUILD)"
2354
+ }
2355
+ },
2356
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_build3(), exports_build)).then((m) => m.buildCommand({
2357
+ dirs: list(args._),
2358
+ out: text3(args.out),
2359
+ target: text3(args.target),
2360
+ profile: args.debug ? "dev" : "release-kmod",
2361
+ skipBuild: args["skip-build"] || undefined
2362
+ })))
2363
+ });
2364
+ var check = defineCommand({
2365
+ meta: {
2366
+ name: "check",
2367
+ description: "Validate the manifest, type-check the frontend, clippy the sidecar."
2368
+ },
2369
+ args: {
2370
+ dirs: dirsArg,
2371
+ rust: {
2372
+ type: "boolean",
2373
+ default: true,
2374
+ description: "Run clippy",
2375
+ negativeDescription: "Skip clippy"
2376
+ },
2377
+ ts: { type: "boolean", default: true, description: "Run tsc", negativeDescription: "Skip tsc" }
2378
+ },
2379
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_check(), exports_check)).then((m) => m.checkCommand({ dirs: list(args._), rust: args.rust !== false, ts: args.ts !== false })))
2380
+ });
2381
+ var install = defineCommand({
2382
+ meta: { name: "install", description: "Upload a packed .kmod to a running server." },
2383
+ args: {
2384
+ id: {
2385
+ type: "positional",
2386
+ required: false,
2387
+ description: "The module id (default: this module)"
2388
+ },
2389
+ file: { type: "string", valueHint: "path", description: "A .kmod to upload instead" },
2390
+ from: {
2391
+ type: "string",
2392
+ valueHint: "dir",
2393
+ description: "Where the bundles are (default: dist/modules)"
2394
+ },
2395
+ ...serverArgs
2396
+ },
2397
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_install(), exports_install)).then((m) => m.installCommand({
2398
+ id: text3(args.id),
2399
+ file: text3(args.file),
2400
+ from: text3(args.from),
2401
+ server: text3(args.server),
2402
+ token: text3(args.token)
2403
+ })))
2404
+ });
2405
+ var login = defineCommand({
2406
+ meta: { name: "login", description: "Sign in to a server once; dev and install use the token." },
2407
+ args: {
2408
+ server: {
2409
+ type: "positional",
2410
+ required: false,
2411
+ description: "The server URL (default: http://localhost:4040)"
2412
+ },
2413
+ email: { type: "string", description: "Email or username (KROMA_EMAIL)" },
2414
+ password: { type: "string", description: "Password (KROMA_PASSWORD)" }
2415
+ },
2416
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_login(), exports_login)).then((m) => m.loginCommand({
2417
+ server: text3(args.server),
2418
+ email: text3(args.email),
2419
+ password: text3(args.password)
2420
+ })))
2421
+ });
2422
+ var plan = defineCommand({
2423
+ meta: {
2424
+ name: "plan",
2425
+ description: "Print the cargo build lines CI runs in its cross-compile container."
2426
+ },
2427
+ args: {
2428
+ dirs: dirsArg,
2429
+ target: { type: "string", valueHint: "triple", description: "The Rust target (KMOD_TARGET)" }
2430
+ },
2431
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_plan2(), exports_plan)).then((m) => m.planCommand(list(args._), text3(args.target))))
2432
+ });
2433
+ var cargo2 = defineCommand({
2434
+ meta: { name: "cargo", description: "Run one cargo subcommand in every module workspace." },
2435
+ args: {
2436
+ args: {
2437
+ type: "positional",
2438
+ required: true,
2439
+ description: "The cargo subcommand and its arguments"
2440
+ }
2441
+ },
2442
+ run: ({ rawArgs }) => exitAfter(Promise.resolve().then(() => (init_cargo2(), exports_cargo)).then((m) => m.cargoCommand(rawArgs.filter((a) => a !== "--"))))
2443
+ });
2444
+ var registry = defineCommand({
2445
+ meta: {
2446
+ name: "registry",
2447
+ description: "Write the packed bundles as a static registry for any host."
2448
+ },
2449
+ args: {
2450
+ from: {
2451
+ type: "string",
2452
+ valueHint: "dir",
2453
+ description: "Where the bundles are (default: dist/modules)"
2454
+ },
2455
+ out: {
2456
+ type: "string",
2457
+ valueHint: "dir",
2458
+ description: "Output directory (default: dist/registry)"
2459
+ },
2460
+ base: {
2461
+ type: "string",
2462
+ valueHint: "url",
2463
+ description: "The URL the registry will be served at"
2464
+ }
2465
+ },
2466
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_registry(), exports_registry)).then((m) => m.registryCommand({ from: text3(args.from), out: text3(args.out), base: text3(args.base) })))
2467
+ });
2468
+ var serve = defineCommand({
2469
+ meta: { name: "serve", description: "Serve the packed bundles as a live registry to browse." },
2470
+ args: {
2471
+ from: {
2472
+ type: "string",
2473
+ valueHint: "dir",
2474
+ description: "Where the bundles are (default: dist/modules)"
2475
+ },
2476
+ port: { type: "string", valueHint: "port", description: "Port (default: 4173)" }
2477
+ },
2478
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_serve(), exports_serve)).then((m) => m.serveCommand({ from: text3(args.from), port: args.port ? Number(args.port) : undefined })))
2479
+ });
2480
+ var release = defineCommand({
2481
+ meta: { name: "release", description: "Decide which packed modules publish on their own tags." },
2482
+ args: {
2483
+ repo: {
2484
+ type: "string",
2485
+ valueHint: "owner/name",
2486
+ description: "The GitHub repository (GITHUB_REPOSITORY)"
2487
+ },
2488
+ published: {
2489
+ type: "string",
2490
+ valueHint: "url|file",
2491
+ description: "The live catalog to compare against"
2492
+ },
2493
+ from: {
2494
+ type: "string",
2495
+ valueHint: "dir",
2496
+ description: "Where the bundles are (default: dist/modules)"
2497
+ },
2498
+ out: {
2499
+ type: "string",
2500
+ valueHint: "dir",
2501
+ description: "Output directory (default: dist/registry)"
2502
+ },
2503
+ "dry-run": { type: "boolean", default: false, description: "Decide and print, write nothing" },
2504
+ strict: {
2505
+ type: "boolean",
2506
+ default: false,
2507
+ description: "An unbumped changed module fails the run"
2508
+ }
2509
+ },
2510
+ run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_release(), exports_release)).then((m) => m.releaseCommand({
2511
+ repo: text3(args.repo),
2512
+ published: text3(args.published),
2513
+ from: text3(args.from),
2514
+ out: text3(args.out),
2515
+ dryRun: args["dry-run"] === true,
2516
+ strict: args.strict === true
2517
+ })))
2518
+ });
2519
+ var main = defineCommand({
2520
+ meta: { name: "kroma", description: "Build KROMA modules." },
2521
+ subCommands: { create, dev, build: build2, check, install, login, plan, cargo: cargo2, registry, serve, release }
2522
+ });
2523
+ runMain(main);