@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69

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 (426) hide show
  1. package/README.md +64 -63
  2. package/api/build/_adapter.d.mts +51 -0
  3. package/api/build/_adapter.mjs +122 -6
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.mjs +23 -14
  6. package/api/build/build.type.d.mts +1 -1
  7. package/api/build/build.type.mjs +3 -3
  8. package/api/build/help/help.d.mts +15 -14
  9. package/api/build/help/help.mjs +62 -3
  10. package/api/build/kit/answer.mjs +2 -3
  11. package/api/build/kit/signals.d.mts +10 -0
  12. package/api/build/kit/signals.mjs +15 -2
  13. package/api/component/detail/blocks/blocks.mjs +2 -1
  14. package/api/discover/_adapter.d.mts +57 -6
  15. package/api/discover/_adapter.mjs +278 -49
  16. package/api/discover/_catalog-view.d.mts +7 -0
  17. package/api/discover/_catalog-view.mjs +10 -1
  18. package/api/discover/detail/detail.d.mts +3 -2
  19. package/api/discover/detail/detail.mjs +3 -2
  20. package/api/discover/detail/doc/doc.mjs +1 -1
  21. package/api/discover/discover.d.mts +24 -0
  22. package/api/discover/discover.doc.mjs +1 -1
  23. package/api/discover/discover.mjs +146 -25
  24. package/api/discover/discover.type.d.mts +6 -4
  25. package/api/discover/discover.type.mjs +6 -4
  26. package/api/discover/search/search.d.mts +22 -0
  27. package/api/discover/search/search.mjs +290 -70
  28. package/api/docs/_entry-names.mjs +4 -3
  29. package/api/doctor/_adapter.d.mts +43 -3
  30. package/api/doctor/_adapter.mjs +142 -18
  31. package/api/doctor/built-checks.d.mts +30 -3
  32. package/api/doctor/built-checks.mjs +132 -5
  33. package/api/doctor/doctor.d.mts +93 -6
  34. package/api/doctor/doctor.doc.mjs +2 -2
  35. package/api/doctor/doctor.mjs +524 -33
  36. package/api/doctor/doctor.type.d.mts +2 -1
  37. package/api/doctor/doctor.type.mjs +2 -1
  38. package/api/doctor/theme-checks.d.mts +19 -0
  39. package/api/doctor/theme-checks.mjs +74 -6
  40. package/api/hook/hook.type.d.mts +1 -1
  41. package/api/hook/hook.type.mjs +1 -1
  42. package/api/hook/list/list.mjs +11 -7
  43. package/api/icon/_adapter.d.mts +2 -1
  44. package/api/icon/_adapter.mjs +10 -15
  45. package/api/icon/_records.d.mts +3 -1
  46. package/api/icon/_records.mjs +30 -3
  47. package/api/icon/exportIconIndex.doc.mjs +1 -1
  48. package/api/icon/icon.doc.mjs +3 -3
  49. package/api/icon/icon.type.d.mts +32 -1
  50. package/api/icon/icon.type.mjs +19 -3
  51. package/api/icon/list/list.mjs +4 -1
  52. package/api/icon/rankIconIndex.doc.mjs +1 -1
  53. package/api/icon/search/icon-index.mjs +18 -8
  54. package/api/icon/search/search.d.mts +26 -3
  55. package/api/icon/search/search.mjs +155 -9
  56. package/api/init/_adapter.d.mts +14 -0
  57. package/api/init/_adapter.mjs +26 -4
  58. package/api/init/init.d.mts +1 -1
  59. package/api/init/init.doc.mjs +2 -2
  60. package/api/init/init.mjs +1 -1
  61. package/api/init/init.type.d.mts +29 -1
  62. package/api/init/init.type.mjs +14 -1
  63. package/api/init/run/run.d.mts +11 -1
  64. package/api/init/run/run.mjs +84 -5
  65. package/api/integration/_adapter.d.mts +5 -4
  66. package/api/integration/_adapter.mjs +7 -5
  67. package/api/integration/integrationCheck.doc.mjs +1 -1
  68. package/api/integration/pack-check.mjs +8 -9
  69. package/api/integration/validate-integration.d.mts +1 -1
  70. package/api/integration/validate-integration.mjs +26 -24
  71. package/api/integration/validate-integration.type.d.mts +5 -2
  72. package/api/integration/validate-integration.type.mjs +5 -2
  73. package/api/integration/validateIntegration.doc.mjs +1 -1
  74. package/api/render/_adapter.d.mts +4 -2
  75. package/api/render/_adapter.mjs +62 -21
  76. package/api/render/render.doc.mjs +8 -5
  77. package/api/render/render.mjs +1 -1
  78. package/api/render/render.type.d.mts +2 -0
  79. package/api/render/render.type.mjs +2 -0
  80. package/api/search/ORDERING.md +2 -2
  81. package/api/search/_candidate-score.d.mts +3 -0
  82. package/api/search/_candidate-score.mjs +36 -3
  83. package/api/search/_gather-docs.mjs +29 -2
  84. package/api/search/_gather-templates.mjs +2 -1
  85. package/api/search/_main-searcher.mjs +13 -0
  86. package/api/search/_named-keywords.d.mts +2 -1
  87. package/api/search/_named-keywords.mjs +48 -6
  88. package/api/search/_order.d.mts +36 -1
  89. package/api/search/_order.mjs +141 -3
  90. package/api/swizzle/list/list.mjs +8 -1
  91. package/api/swizzle/swizzle.type.d.mts +1 -1
  92. package/api/swizzle/swizzle.type.mjs +1 -1
  93. package/api/template/copy/copy.mjs +3 -4
  94. package/api/template/list/list.mjs +2 -1
  95. package/api/template/show/show.mjs +2 -1
  96. package/api/template/skeleton/skeleton.mjs +2 -1
  97. package/api/template/template.doc.mjs +1 -1
  98. package/api/template/template.mjs +19 -1
  99. package/api/template/template.type.d.mts +1 -0
  100. package/api/template/template.type.mjs +2 -1
  101. package/api/theme/_adapter.d.mts +1 -0
  102. package/api/theme/_adapter.mjs +3 -5
  103. package/api/theme/_app-provider.d.mts +42 -0
  104. package/api/theme/_app-provider.mjs +61 -27
  105. package/api/theme/build/build.d.mts +4 -10
  106. package/api/theme/build/build.mjs +165 -116
  107. package/api/theme/build/input-fields.d.mts +9 -0
  108. package/api/theme/build/input-fields.mjs +155 -16
  109. package/api/theme/build/radius-values.d.mts +18 -0
  110. package/api/theme/build/radius-values.mjs +76 -0
  111. package/api/theme/build/typography-values.mjs +7 -23
  112. package/api/theme/build/written-values.d.mts +18 -0
  113. package/api/theme/build/written-values.mjs +107 -31
  114. package/api/theme/eject/eject.mjs +6 -1
  115. package/api/theme/palette/generate/generator.mjs +24 -0
  116. package/api/theme/theme.type.d.mts +4 -2
  117. package/api/theme/theme.type.mjs +3 -2
  118. package/api/theme/themeBuild.doc.mjs +2 -2
  119. package/api/theme/themeEject.doc.mjs +1 -1
  120. package/api/theme-edit/_catalog.d.mts +40 -0
  121. package/api/theme-edit/_catalog.mjs +100 -22
  122. package/api/theme-edit/_check.mjs +213 -43
  123. package/api/theme-edit/_color.d.mts +14 -0
  124. package/api/theme-edit/_color.mjs +22 -0
  125. package/api/theme-edit/_compiler.mjs +52 -0
  126. package/api/theme-edit/_context.d.mts +20 -2
  127. package/api/theme-edit/_context.mjs +157 -29
  128. package/api/theme-edit/_edit.mjs +426 -58
  129. package/api/theme-edit/_how-question.d.mts +14 -0
  130. package/api/theme-edit/_how-question.mjs +1541 -127
  131. package/api/theme-edit/_how.mjs +43 -0
  132. package/api/theme-edit/_missed.mjs +107 -27
  133. package/api/theme-edit/_normal.d.mts +18 -4
  134. package/api/theme-edit/_normal.mjs +84 -3
  135. package/api/theme-edit/_palette.d.mts +9 -0
  136. package/api/theme-edit/_palette.mjs +158 -33
  137. package/api/theme-edit/_part-words.mjs +16 -3
  138. package/api/theme-edit/_parts.d.mts +8 -0
  139. package/api/theme-edit/_parts.mjs +120 -36
  140. package/api/theme-edit/_png.d.mts +24 -0
  141. package/api/theme-edit/_png.mjs +99 -0
  142. package/api/theme-edit/_preview-app.d.mts +16 -0
  143. package/api/theme-edit/_preview-app.mjs +52 -18
  144. package/api/theme-edit/_preview.d.mts +44 -26
  145. package/api/theme-edit/_preview.mjs +255 -67
  146. package/api/theme-edit/_project.d.mts +12 -1
  147. package/api/theme-edit/_project.mjs +16 -1
  148. package/api/theme-edit/_settings.d.mts +116 -0
  149. package/api/theme-edit/_settings.mjs +1197 -58
  150. package/api/theme-edit/_tables.d.mts +16 -0
  151. package/api/theme-edit/_tables.mjs +34 -4
  152. package/api/theme-edit/theme-edit.type.d.mts +15 -2
  153. package/api/theme-edit/theme-edit.type.mjs +8 -6
  154. package/api/upgrade/_adapter.d.mts +46 -7
  155. package/api/upgrade/_adapter.mjs +110 -15
  156. package/api/upgrade/registry/registry.d.mts +6 -3
  157. package/api/upgrade/registry/registry.mjs +21 -6
  158. package/api/upgrade/run/run.mjs +23 -11
  159. package/api/upgrade/upgrade.doc.mjs +4 -3
  160. package/assets/component-list.generated.json +1 -1
  161. package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
  162. package/assets/docs/tree/checks.doc.mjs +2 -2
  163. package/assets/docs/tree/host-entry.doc.mjs +4 -0
  164. package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
  165. package/assets/docs/tree/icon-sets.doc.mjs +6 -6
  166. package/assets/docs/tree/problems.doc.mjs +3 -3
  167. package/assets/docs/tree/render-pages.doc.mjs +17 -3
  168. package/assets/docs/tree/share-a-page.doc.mjs +5 -5
  169. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  170. package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
  171. package/assets/docs/tree/updates.doc.mjs +1 -1
  172. package/assets/docs/tree/versioning.doc.mjs +1 -1
  173. package/assets/docs/working-with-ai.doc.mjs +40 -5
  174. package/assets/docs-routes.generated.json +1 -1
  175. package/assets/docs.generated.json +2 -2
  176. package/assets/icons/installed-icon-set.doc.mjs +30 -0
  177. package/assets/search-catalog.generated.json +2 -2
  178. package/assets/self-audit.generated.json +1 -1
  179. package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
  180. package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
  181. package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
  182. package/assets/templates/components.generated.json +1 -1
  183. package/assets/templates/pages/ai-chat/page.tsx +6 -2
  184. package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
  185. package/assets/templates/pages/blank/page.tsx +4 -2
  186. package/assets/templates/pages/canvas-editor/page.tsx +3 -1
  187. package/assets/templates/pages/centered-hero/page.tsx +1 -1
  188. package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
  189. package/assets/templates/pages/classic-gallery/page.tsx +1 -1
  190. package/assets/templates/pages/contact-form/page.tsx +2 -2
  191. package/assets/templates/pages/course-detail/page.tsx +1 -1
  192. package/assets/templates/pages/dashboard/page.tsx +24 -8
  193. package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
  194. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
  195. package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
  196. package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
  197. package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
  198. package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
  199. package/assets/templates/pages/detail-page/page.tsx +22 -5
  200. package/assets/templates/pages/documentation/page.tsx +4 -2
  201. package/assets/templates/pages/documentation-design/page.tsx +5 -2
  202. package/assets/templates/pages/documentation-technical/page.tsx +4 -2
  203. package/assets/templates/pages/editor/page.tsx +28 -9
  204. package/assets/templates/pages/file-explorer/page.tsx +3 -1
  205. package/assets/templates/pages/form-two-column/page.tsx +1 -1
  206. package/assets/templates/pages/form-wizard/page.tsx +1 -1
  207. package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
  208. package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
  209. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  210. package/assets/templates/pages/gallery-hero/page.tsx +1 -1
  211. package/assets/templates/pages/ide/page.tsx +7 -2
  212. package/assets/templates/pages/kanban-board/page.tsx +10 -4
  213. package/assets/templates/pages/library/page.tsx +31 -61
  214. package/assets/templates/pages/login/page.tsx +4 -2
  215. package/assets/templates/pages/login-card/page.tsx +4 -2
  216. package/assets/templates/pages/login-split/page.tsx +3 -2
  217. package/assets/templates/pages/login-sso/page.tsx +4 -4
  218. package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
  219. package/assets/templates/pages/payment-form/page.tsx +1 -1
  220. package/assets/templates/pages/product-detail/page.tsx +16 -4
  221. package/assets/templates/pages/product-gallery/page.tsx +1 -1
  222. package/assets/templates/pages/settings/page.tsx +10 -4
  223. package/assets/templates/pages/settings-dialog/page.tsx +5 -6
  224. package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
  225. package/assets/templates/pages/side-gallery/page.tsx +1 -1
  226. package/assets/templates/pages/table/page.tsx +2 -2
  227. package/assets/templates/pages/table-filter/page.tsx +21 -6
  228. package/assets/templates/pages/table-grouped/page.tsx +23 -2
  229. package/assets/templates/pages/table-inbox/page.tsx +82 -32
  230. package/assets/templates/pages/theme-showcase/page.tsx +3 -2
  231. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
  232. package/assets/templates/themes/butter/butterTheme.ts +197 -4
  233. package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
  234. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
  235. package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
  236. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
  237. package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
  238. package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
  239. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
  240. package/assets/templates/themes/stone/stoneTheme.ts +69 -0
  241. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
  242. package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
  243. package/authoring/codemod/parse.d.mts +0 -36
  244. package/authoring/codemod/parse.mjs +62 -41
  245. package/authoring/config/config.doc.mjs +1 -1
  246. package/authoring/config/parse.d.mts +0 -47
  247. package/authoring/config/parse.mjs +128 -103
  248. package/authoring/config/type.ts +4 -3
  249. package/authoring/debug/parse.d.mts +2 -2
  250. package/authoring/discover/parse.d.mts +2 -2
  251. package/authoring/discover/parse.mjs +52 -38
  252. package/authoring/discover/type.ts +2 -1
  253. package/authoring/doctypes/_schema.d.mts +834 -950
  254. package/authoring/doctypes/_schema.mjs +863 -825
  255. package/authoring/doctypes/command/parse.mjs +2 -2
  256. package/authoring/doctypes/component/parse.mjs +2 -2
  257. package/authoring/doctypes/enum/parse.mjs +2 -2
  258. package/authoring/doctypes/hook/parse.mjs +2 -2
  259. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
  260. package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
  261. package/authoring/doctypes/icon-definition/parse.mjs +59 -43
  262. package/authoring/doctypes/icon-set/parse.d.mts +0 -75
  263. package/authoring/doctypes/icon-set/parse.mjs +239 -210
  264. package/authoring/doctypes/legacy.mjs +3 -3
  265. package/authoring/doctypes/namespace/parse.mjs +2 -2
  266. package/authoring/doctypes/reference/parse.mjs +2 -2
  267. package/authoring/doctypes/schema/parse.mjs +2 -2
  268. package/authoring/doctypes/template/parse.d.mts +0 -101
  269. package/authoring/doctypes/template/parse.mjs +131 -106
  270. package/authoring/doctypes/theme/parse.d.mts +0 -23
  271. package/authoring/doctypes/theme/parse.mjs +52 -36
  272. package/authoring/gap-report/parse.d.mts +1 -1
  273. package/authoring/integration/integration.doc.mjs +8 -0
  274. package/authoring/integration/schema.d.mts +14 -3
  275. package/authoring/integration/schema.mjs +20 -2
  276. package/authoring/integration/type.ts +14 -0
  277. package/clients/cli/build-id.generated.json +1 -1
  278. package/clients/cli/commands/build.mjs +27 -13
  279. package/clients/cli/commands/component.mjs +14 -3
  280. package/clients/cli/commands/discover.doc.mjs +2 -2
  281. package/clients/cli/commands/discover.mjs +20 -3
  282. package/clients/cli/commands/docs.doc.mjs +11 -9
  283. package/clients/cli/commands/docs.mjs +50 -21
  284. package/clients/cli/commands/experimental/icon.mjs +330 -227
  285. package/clients/cli/commands/experimental/render.mjs +16 -1
  286. package/clients/cli/commands/experimental/theme.mjs +42 -17
  287. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  288. package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
  289. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
  290. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
  291. package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
  292. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  293. package/clients/cli/commands/experimental-render.doc.mjs +3 -3
  294. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  295. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  296. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  297. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  298. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  299. package/clients/cli/commands/init.doc.mjs +36 -24
  300. package/clients/cli/commands/integration-check.doc.mjs +1 -1
  301. package/clients/cli/commands/mcp.doc.mjs +53 -0
  302. package/clients/cli/commands/mcp.mjs +51 -0
  303. package/clients/cli/commands/search.mjs +46 -9
  304. package/clients/cli/commands/template.mjs +3 -2
  305. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  306. package/clients/cli/commands/theme.mjs +12 -2
  307. package/clients/cli/commands/upgrade.doc.mjs +3 -2
  308. package/clients/cli/commands.generated.json +1 -1
  309. package/clients/cli/formatters/index.mjs +52 -6
  310. package/clients/cli/index.mjs +23 -17
  311. package/clients/cli/lib/base-gate.mjs +37 -5
  312. package/clients/cli/lib/define-command.mjs +82 -4
  313. package/clients/cli/lib/json-shim.mjs +61 -4
  314. package/clients/cli/lib/manifest.mjs +9 -1
  315. package/clients/cli/lib/mcp-server.mjs +286 -0
  316. package/clients/cli/lib/mcp-tools.mjs +405 -0
  317. package/clients/cli/lib/other-cli-words.mjs +99 -0
  318. package/clients/cli/lib/stray-option.mjs +27 -1
  319. package/clients/cli/lib/unknown-command.mjs +326 -11
  320. package/clients/cli/manifest.generated.json +1 -1
  321. package/clients/cli/run.mjs +1 -1
  322. package/foundation/agent-docs/agent-docs.d.mts +49 -1
  323. package/foundation/agent-docs/agent-docs.mjs +108 -7
  324. package/foundation/agent-docs/computer-agent-text.mjs +1 -1
  325. package/foundation/bases/core.d.mts +1 -1
  326. package/foundation/bases/core.mjs +3 -3
  327. package/foundation/bases/resolve.d.mts +4 -8
  328. package/foundation/bases/resolve.mjs +15 -21
  329. package/foundation/bases/state.d.mts +15 -9
  330. package/foundation/bases/state.mjs +33 -6
  331. package/foundation/config/project.d.mts +5 -4
  332. package/foundation/config/project.mjs +33 -17
  333. package/foundation/discovery/component-discovery.mjs +15 -28
  334. package/foundation/discovery/icon-imports.d.mts +66 -0
  335. package/foundation/discovery/icon-imports.mjs +225 -0
  336. package/foundation/discovery/icon-ranking.d.mts +12 -2
  337. package/foundation/discovery/icon-ranking.mjs +197 -10
  338. package/foundation/discovery/icon-set-checks.mjs +2 -1
  339. package/foundation/discovery/icon-set-discovery.d.mts +28 -0
  340. package/foundation/discovery/icon-set-discovery.mjs +42 -0
  341. package/foundation/discovery/icon-set-writer.d.mts +2 -11
  342. package/foundation/discovery/icon-set-writer.mjs +3 -29
  343. package/foundation/discovery/module-exports.d.mts +1 -1
  344. package/foundation/discovery/module-exports.mjs +136 -33
  345. package/foundation/discovery/name-roots.d.mts +5 -0
  346. package/foundation/discovery/name-roots.mjs +11 -0
  347. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  348. package/foundation/discovery/runner-allowlist.mjs +2 -0
  349. package/foundation/discovery/runner-commands.mjs +1 -0
  350. package/foundation/discovery/template-adapter.d.mts +1 -1
  351. package/foundation/discovery/template-destination.d.mts +14 -6
  352. package/foundation/discovery/template-destination.mjs +42 -8
  353. package/foundation/discovery/template-icons.d.mts +45 -2
  354. package/foundation/discovery/template-icons.mjs +26 -54
  355. package/foundation/discovery/template-needs.d.mts +28 -2
  356. package/foundation/discovery/template-needs.mjs +92 -11
  357. package/foundation/discovery/theme-discovery.d.mts +8 -0
  358. package/foundation/discovery/theme-discovery.mjs +23 -6
  359. package/foundation/discovery/theme-imports.mjs +2 -4
  360. package/foundation/doc-compiler/parse-readable.mjs +4 -3
  361. package/foundation/doc-compiler/stored-docs.d.mts +13 -0
  362. package/foundation/doc-compiler/stored-docs.mjs +74 -3
  363. package/foundation/env/cli-command.d.mts +68 -10
  364. package/foundation/env/cli-command.mjs +116 -22
  365. package/foundation/env/project-scope.d.mts +9 -0
  366. package/foundation/env/project-scope.mjs +28 -2
  367. package/foundation/fs/gather-cache.d.mts +23 -0
  368. package/foundation/fs/gather-cache.mjs +94 -2
  369. package/foundation/fs/module-loader.d.mts +3 -1
  370. package/foundation/fs/module-loader.mjs +85 -5
  371. package/foundation/fs/read-record.mjs +9 -5
  372. package/foundation/identity/package-names.d.mts +18 -0
  373. package/foundation/identity/package-names.mjs +19 -0
  374. package/foundation/identity/providers.mjs +3 -2
  375. package/foundation/integrations/icon-features.d.mts +63 -0
  376. package/foundation/integrations/icon-features.mjs +54 -0
  377. package/foundation/integrations/integrations.d.mts +13 -1
  378. package/foundation/integrations/integrations.mjs +47 -6
  379. package/foundation/integrations/pack-state.d.mts +21 -0
  380. package/foundation/integrations/pack-state.mjs +42 -19
  381. package/foundation/integrations/validate-contributions.d.mts +11 -3
  382. package/foundation/integrations/validate-contributions.mjs +51 -13
  383. package/foundation/release/cache.d.mts +13 -1
  384. package/foundation/release/cache.mjs +94 -14
  385. package/foundation/release/notices.d.mts +15 -0
  386. package/foundation/release/notices.mjs +111 -7
  387. package/foundation/release/project.d.mts +3 -4
  388. package/foundation/release/project.mjs +5 -6
  389. package/foundation/render/client-bundle.d.mts +126 -0
  390. package/foundation/render/client-bundle.mjs +565 -0
  391. package/foundation/render/cut-short.d.mts +7 -1
  392. package/foundation/render/cut-short.mjs +46 -6
  393. package/foundation/render/embedded-imports.d.mts +4 -3
  394. package/foundation/render/embedded-imports.mjs +13 -8
  395. package/foundation/render/esbuild-dependency.d.mts +14 -0
  396. package/foundation/render/esbuild-dependency.mjs +41 -0
  397. package/foundation/render/file-header.mjs +5 -4
  398. package/foundation/render/page-worker.mjs +562 -86
  399. package/foundation/render/picture-chrome.mjs +54 -29
  400. package/foundation/render/picture-playwright.mjs +78 -42
  401. package/foundation/render/picture-window.d.mts +33 -0
  402. package/foundation/render/picture-window.mjs +78 -0
  403. package/foundation/render/render-page.d.mts +55 -4
  404. package/foundation/render/render-page.mjs +199 -28
  405. package/foundation/render/restore-folder.d.mts +13 -0
  406. package/foundation/render/restore-folder.mjs +30 -0
  407. package/foundation/render/served-packages.d.mts +2 -1
  408. package/foundation/render/served-packages.mjs +5 -3
  409. package/foundation/render/ts-paths.d.mts +11 -0
  410. package/foundation/render/ts-paths.mjs +27 -2
  411. package/foundation/render/value-uses.d.mts +43 -0
  412. package/foundation/render/value-uses.mjs +110 -0
  413. package/foundation/response/error-codes.d.mts +2 -1
  414. package/foundation/response/error-codes.doc.mjs +7 -1
  415. package/foundation/response/error-codes.mjs +10 -2
  416. package/foundation/response/response-types.doc.mjs +12 -12
  417. package/foundation/runtime/package-root.d.mts +8 -0
  418. package/foundation/runtime/package-root.mjs +20 -0
  419. package/foundation/suggest/other-command.d.mts +11 -0
  420. package/foundation/suggest/other-command.mjs +1 -1
  421. package/foundation/text/icon-id.d.mts +20 -0
  422. package/foundation/text/icon-id.mjs +40 -0
  423. package/foundation/text/icon-set-next.d.mts +25 -0
  424. package/foundation/text/icon-set-next.mjs +29 -0
  425. package/foundation/xle/browser.d.mts +2 -2
  426. package/package.json +7 -6
@@ -293,6 +293,7 @@ export function tempFor(file) {
293
293
  * @property {boolean} pass
294
294
  * @property {string} [note] - The whole sentence to report, when the check is not a plain stop move.
295
295
  * @property {string[]} [dials] - The color dials whose notes report it, when its token belongs to none of them.
296
+ * @property {{thing: string, value: string, mode?: Mode}} [fix] - The nearest setting that passes it, when one does: a darker exact color for a pale fill.
296
297
  */
297
298
 
298
299
  /**
@@ -511,11 +512,20 @@ export const LIFT_PARTS = OFFICIAL.lifted.map(
511
512
  /** @type {[string, string, string]} */ ([
512
513
  part,
513
514
  block,
514
- part === 'segmented-control-item'
515
- ? '--color-neutral'
516
- : '--color-accent-muted',
515
+ liftGround(part, block),
517
516
  ]),
518
517
  );
518
+ /**
519
+ * What a lifted block's secondary text sits on: a card's own fill for a
520
+ * card colour (the card variant rule lifts it there), the translucent
521
+ * neutral track under segmented-control labels, else the accent tint.
522
+ * @param {string} part @param {string} block
523
+ */
524
+ function liftGround(part, block) {
525
+ if (part === 'segmented-control-item') return '--color-neutral';
526
+ const color = part === 'card' ? /^variant:([\w-]+)$/.exec(block)?.[1] : null;
527
+ return color ? `--color-background-${color}` : '--color-accent-muted';
528
+ }
519
529
  /** What each lifted background is, and the parts on it, for notes. */
520
530
  const LIFT_GROUNDS =
521
531
  /** @type {Record<string, {what: string, parts: string}>} */ ({
@@ -527,6 +537,12 @@ const LIFT_GROUNDS =
527
537
  what: 'the neutral track',
528
538
  parts: 'segmented-control labels',
529
539
  },
540
+ ...Object.fromEntries(
541
+ LIFT_PARTS.filter(([part]) => part === 'card').map(([, block, g]) => {
542
+ const color = block.replace(/^variant:/, '');
543
+ return [g, {what: `the ${color} card fill`, parts: `${color} cards`}];
544
+ }),
545
+ ),
530
546
  });
531
547
  const BORDER = /** @type {[number, number]} */ ([80, 65]);
532
548
  /**
@@ -1040,8 +1056,23 @@ function tools(
1040
1056
  on,
1041
1057
  r: contrast(on.color, fill),
1042
1058
  }));
1043
- const best = a.r >= TEXT || a.r >= b.r ? a : b;
1059
+ let best = a.r >= TEXT || a.r >= b.r ? a : b;
1044
1060
  const other = best === a ? b : a;
1061
+ // Neither reads: the end of the gray ramp on the better side (black
1062
+ // past near-black, white past near-white) when it reads better, so the
1063
+ // text picked is never one a darker or lighter gray would beat.
1064
+ if (best.r < TEXT) {
1065
+ const dark =
1066
+ contrast(best.on.color, PALETTE_WHITE) > contrast(fill, PALETTE_WHITE);
1067
+ /** @type {StopRef} */
1068
+ const end = neutral
1069
+ ? {...ref('neutral', m, at(dark ? 0 : 100)), family: 'neutral'}
1070
+ : dark
1071
+ ? {stop: 0, color: PALETTE_BLACK, family: 'black'}
1072
+ : {stop: 100, color: PALETTE_WHITE, family: 'white'};
1073
+ const r = contrast(end.color, fill);
1074
+ if (r > best.r) best = {on: end, r};
1075
+ }
1045
1076
  return {
1046
1077
  on: best.on,
1047
1078
  r: best.r,
@@ -2317,6 +2348,25 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2317
2348
  );
2318
2349
  }) ?? start;
2319
2350
  fill[m] = ref(f.id, m, found);
2351
+ // The shade nearest your color that passes, offered as the theme's
2352
+ // own dark fill when it is closer to your color than the one used.
2353
+ const near = [...stops]
2354
+ .filter(s => s > 0 && s < 100)
2355
+ .sort((a, b) => Math.abs(a - S) - Math.abs(b - S) || b - a)
2356
+ .find(s => {
2357
+ const c = ref(f.id, m, s).color;
2358
+ return (
2359
+ t.page(c, m, f.id) >= NON_TEXT && t.onFor(f.id, m, c).r >= TEXT
2360
+ );
2361
+ });
2362
+ const closer =
2363
+ near != null && Math.abs(near - S) < Math.abs(found - S)
2364
+ ? (() => {
2365
+ const c = ref(f.id, m, near).color;
2366
+ const o = t.onFor(f.id, m, c);
2367
+ return `; for a fill closer to your color in dark: ${P} set ${slug} ${names.fill} ${quoteCommandArgument(c)} --mode dark (shade ${shade(near)}, the nearest that passes, with ${textName(o.on)} text at ${round(o.r)}:1)`;
2368
+ })()
2369
+ : '';
2320
2370
  if (reports(names.fill))
2321
2371
  checks.push({
2322
2372
  token: names.fill,
@@ -2327,7 +2377,7 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2327
2377
  ratio: plain.ratio,
2328
2378
  needs: TEXT,
2329
2379
  pass: true,
2330
- note: `in dark, ${names.fill} is shade ${shade(found)}, not your exact color: ${plain.why}${found === start ? '' : `; shade ${shade(start)} does not pass either, so it is the nearest shade that does`}`,
2380
+ note: `in dark, ${names.fill} is shade ${shade(found)}, not your exact color: ${plain.why}${found === start ? '' : `; shade ${shade(start)} does not pass either, so it is the nearest shade that does`}${closer}`,
2331
2381
  });
2332
2382
  }
2333
2383
  put(names.fill, f.id, fill);
@@ -2372,6 +2422,18 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2372
2422
  if (modes.includes('light') && has(names.fill)) {
2373
2423
  const used = exactFill.light ?? /** @type {StopRef} */ (fill.light).color;
2374
2424
  const p = t.page(solid(used, 'light', f.id), 'light', f.id);
2425
+ // The nearest darker color that stands out from the light page.
2426
+ /** @type {string | null} */
2427
+ let darker = null;
2428
+ const from = parseColor(solid(used, 'light', f.id));
2429
+ for (let i = 1; from && i <= 100 && !darker; i++) {
2430
+ const c = hex(
2431
+ /** @type {[number, number, number]} */ (
2432
+ from.map(v => Math.round(v * (1 - i / 100)))
2433
+ ),
2434
+ );
2435
+ if (t.page(c, 'light', f.id) >= NON_TEXT) darker = c;
2436
+ }
2375
2437
  if (p < NON_TEXT)
2376
2438
  checks.push({
2377
2439
  token: names.fill,
@@ -2385,6 +2447,13 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2385
2447
  note: exactFill.light
2386
2448
  ? `in light, your exact ${names.fill} (${used}) stands out from the page at only ${round(p)}:1, and a fill needs ${NON_TEXT}:1, so its buttons and badges may not show: give it a darker color`
2387
2449
  : `in light, your exact ${f.id} stands out from the page at only ${round(p)}:1, and a fill needs ${NON_TEXT}:1, so ${names.fill} buttons and badges may not show: pick a darker ${f.id}`,
2450
+ ...(darker
2451
+ ? {
2452
+ fix: exactFill.light
2453
+ ? {thing: names.fill, value: darker, mode: 'light'}
2454
+ : {thing: f.id, value: darker},
2455
+ }
2456
+ : {}),
2388
2457
  });
2389
2458
  }
2390
2459
 
@@ -2437,34 +2506,53 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2437
2506
  // nearest shade that reads, and the result says so.
2438
2507
  const text = each(m => {
2439
2508
  const grounds = [...surfaces(m, f.id), ...mutedSeen(m)];
2440
- const own = fill[m]?.exact ? ref(f.id, m, S) : null;
2509
+ // The fill the theme really shows in this mode: an exact token
2510
+ // setting of it, else the dial's own color at its shade. The text
2511
+ // starts from that color's nearest shade.
2512
+ const shown = exactFill[m] ? solid(exactFill[m], m, f.id) : null;
2513
+ const start = shown
2514
+ ? stops.reduce((x, y) =>
2515
+ perceptualDelta(ref(f.id, m, y).color, shown) <
2516
+ perceptualDelta(ref(f.id, m, x).color, shown)
2517
+ ? y
2518
+ : x,
2519
+ )
2520
+ : S;
2521
+ const own = shown
2522
+ ? {...ref(f.id, m, start), color: shown}
2523
+ : fill[m]?.exact
2524
+ ? ref(f.id, m, S)
2525
+ : null;
2441
2526
  if (own) {
2442
2527
  const r = Math.min(...grounds.map(([, bg]) => contrast(own.color, bg)));
2443
2528
  if (r >= TEXT) {
2444
- if (reports(names.text))
2445
- checks.push({
2446
- token: names.text,
2447
- mode: m,
2448
- stop: S,
2449
- preferred: S,
2450
- against: grounds.map(([n]) => n).join(', '),
2451
- ratio: round(r),
2452
- needs: TEXT,
2453
- pass: true,
2454
- });
2455
- return own;
2529
+ if (!shown) {
2530
+ if (reports(names.text))
2531
+ checks.push({
2532
+ token: names.text,
2533
+ mode: m,
2534
+ stop: S,
2535
+ preferred: S,
2536
+ against: grounds.map(([n]) => n).join(', '),
2537
+ ratio: round(r),
2538
+ needs: TEXT,
2539
+ pass: true,
2540
+ });
2541
+ return own;
2542
+ }
2456
2543
  }
2457
2544
  const before = checks.length;
2458
- const moved = pick(names.text, f.id, m, S, grounds, TEXT);
2545
+ const moved = pick(names.text, f.id, m, start, grounds, TEXT);
2546
+ if (r >= TEXT) return moved;
2459
2547
  const last = checks.length > before ? checks[checks.length - 1] : null;
2460
- if (last && moved.stop !== S)
2548
+ if (last && (moved.stop !== start || shown))
2461
2549
  last.note = `${names.text} ${m}: your exact color (${own.color}) reads at only ${grounds
2462
2550
  .map(([n, bg]) => [n, contrast(own.color, bg)])
2463
2551
  .filter(([, x]) => Number(x) < TEXT)
2464
2552
  .map(([n, x]) => `${round(Number(x))}:1 on ${n}`)
2465
2553
  .join(
2466
2554
  ', ',
2467
- )} (text needs ${TEXT}:1), so links and accent text use shade ${shade(moved.stop)} (${moved.color}), the nearest that reads; the fill keeps your color, and an exact ${names.text} keeps any color you give it`;
2555
+ )} (text needs ${TEXT}:1), so ${f.id === 'accent' ? 'links and accent text' : `${f.id} text and icons`} use shade ${shade(moved.stop)} (${moved.color}), the nearest that reads; the fill keeps your color, and an exact ${names.text} keeps any color you give it`;
2468
2556
  return moved;
2469
2557
  }
2470
2558
  return pick(names.text, f.id, m, at(TEXT_STOP[side(m)]), grounds, TEXT);
@@ -2516,7 +2604,9 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2516
2604
  // else a gray ramp the generator grows from the base theme's own
2517
2605
  // secondary text (written as colors, not shades of the palette). The
2518
2606
  // tint stays at its official stop. A mode where the theme sets
2519
- // secondary text exactly takes that value instead, as written.
2607
+ // secondary text exactly takes that value where it reads there, else the
2608
+ // gray nearest it that does: a secondary text set for the whole theme
2609
+ // never makes those parts less readable.
2520
2610
  /** @type {Record<string, Partial<Record<Mode, StopRef>>> | null} */
2521
2611
  let lift = null;
2522
2612
  {
@@ -2609,14 +2699,23 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2609
2699
  const byMode = {};
2610
2700
  for (const m of modes) {
2611
2701
  const own = rawOf('--color-text-secondary', m);
2612
- if (own) {
2613
- byMode[m] = {stop: 0, color: own, family: 'literal'};
2614
- continue;
2615
- }
2702
+ const literal = () => {
2703
+ byMode[m] = {
2704
+ stop: 0,
2705
+ color: /** @type {string} */ (own),
2706
+ family: 'literal',
2707
+ };
2708
+ };
2616
2709
  const fillColor = valueOf(m, ground);
2617
2710
  const g = grays(m);
2618
2711
  const text = startText(m);
2619
- if (!fillColor || !g || !text) break;
2712
+ if (!fillColor || !g || !text) {
2713
+ if (own) {
2714
+ literal();
2715
+ continue;
2716
+ }
2717
+ break;
2718
+ }
2620
2719
  const seen = drawn(what, fillColor, surfaces(m, 'neutral'));
2621
2720
  const hover = valueOf(m, '--color-overlay-hover');
2622
2721
  const on = [
@@ -2634,7 +2733,20 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
2634
2733
  const keys = Object.keys(g.ramp)
2635
2734
  .map(Number)
2636
2735
  .sort((a, b) => a - b);
2637
- const from = baseLift(m) ?? text;
2736
+ if (
2737
+ own &&
2738
+ parseColor(own) &&
2739
+ Math.min(...on.map(([, bg]) => contrast(own, bg))) >= TEXT
2740
+ ) {
2741
+ literal();
2742
+ continue;
2743
+ }
2744
+ const from =
2745
+ (own && parseColor(own)
2746
+ ? hex(/** @type {number[]} */ (parseColor(own)))
2747
+ : null) ??
2748
+ baseLift(m) ??
2749
+ text;
2638
2750
  const start = keys.reduce((x, y) =>
2639
2751
  perceptualDelta(g.ramp[y], from) < perceptualDelta(g.ramp[x], from)
2640
2752
  ? y
@@ -2752,10 +2864,19 @@ export function mappingRows(dial) {
2752
2864
  ([t, [[l, la], [d, da]]]) =>
2753
2865
  `${t}: light shade ${l} at opacity ${la}, dark shade ${d} at opacity ${da}`,
2754
2866
  ),
2755
- ...Object.values(LIFT_GROUNDS).map(
2756
- g =>
2757
- `--color-text-secondary on ${g.parts}: the shade nearest the secondary text's that reads at ${TEXT}:1 on ${g.what} and under a hover, as the official theme lifts it`,
2758
- ),
2867
+ ...Object.entries(LIFT_GROUNDS)
2868
+ .filter(([g]) => !g.startsWith('--color-background-'))
2869
+ .map(
2870
+ ([, g]) =>
2871
+ `--color-text-secondary on ${g.parts}: the shade nearest the secondary text's that reads at ${TEXT}:1 on ${g.what} and under a hover, as the official theme lifts it`,
2872
+ ),
2873
+ ...(Object.keys(LIFT_GROUNDS).some(g =>
2874
+ g.startsWith('--color-background-'),
2875
+ )
2876
+ ? [
2877
+ `--color-text-secondary on coloured cards: the shade nearest the secondary text's that reads at ${TEXT}:1 on each card's fill, as the official theme lifts it`,
2878
+ ]
2879
+ : []),
2759
2880
  ];
2760
2881
  const word = dial === 'accent' ? null : STATUS_TOKEN[dial];
2761
2882
  if (dial !== 'accent' && !word) return [];
@@ -2840,7 +2961,11 @@ export function paletteFailures(pal, dial, modes = ['light', 'dark']) {
2840
2961
  if (!pal) return [];
2841
2962
  return dialChecks(pal, dial, modes)
2842
2963
  .filter(c => !c.pass)
2843
- .map(c => ({key: paletteCheckKey(c), text: checkNote(c, dial)}));
2964
+ .map(c => ({
2965
+ key: paletteCheckKey(c),
2966
+ text: checkNote(c, dial),
2967
+ ...(c.fix ? {fix: c.fix} : {}),
2968
+ }));
2844
2969
  }
2845
2970
 
2846
2971
  /**
@@ -33,7 +33,9 @@ export const OVERRIDES = [
33
33
  [/\b((modal |dialog )?(overlay|scrim|backdrop))\b/, {on: 'overlay'}],
34
34
  [/\bicons?\b/, {on: 'icons'}],
35
35
  [
36
- /\b(table headers?|column headers?|table headings?)\b/,
36
+ // (The header row is the header cells: "table header row gray" is
37
+ // never every row.)
38
+ /\b(table header rows?|header rows?|table headers?|column headers?|table headings?)\b/,
37
39
  {on: 'table-header-cell'},
38
40
  ],
39
41
  [
@@ -123,9 +125,20 @@ export const OVERRIDES = [
123
125
  /\b(?:toggle|switch)(?:e?s)?(?:'s)?\s+(?:thumbs?|knobs?|handles?)\b/,
124
126
  {on: 'switch-thumb'},
125
127
  ],
126
- // "switch off", "switch the buttons to" are the verb, not the part.
128
+ // The buttons or items of a toggle group (its own possessive or not):
129
+ // Core's toggle buttons, never a switch's.
127
130
  [
128
- /\b(toggles?|switch(?:e?s)?(?! (off|on|to|the|out|it|them|over|back|from)\b))\b/,
131
+ /\btoggle[- ]?(?:button[- ]?)?groups?(?:'s|s'|’s)?\s+(?:buttons?|items?|options?)\b/,
132
+ {on: 'toggle-button'},
133
+ ],
134
+ // A toggle group: the group of toggle buttons, never a switch.
135
+ [/\btoggle[- ]?(?:button[- ]?)?groups?\b/, {on: 'toggle-button-group'}],
136
+ // A toggle button: Core's toggle button, never a switch.
137
+ [/\btoggle[- ]?buttons?\b/, {on: 'toggle-button'}],
138
+ // "switch off", "switch the buttons to" are the verb, not the part; the
139
+ // switch's "on color" or "on state" (its checked look) is the part.
140
+ [
141
+ /\b(toggles?|switch(?:e?s)?(?! (?:off|on(?![- ](?:colou?r|state|look)\b)|to|the|out|it|them|over|back|from)\b))\b/,
129
142
  {on: 'switch'},
130
143
  ],
131
144
  [/\b((table )?cells?)\b/, {on: 'table-cell'}],
@@ -1,6 +1,14 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * A fingerprint of a module and every file it imports by a relative path,
6
+ * read once: what a cache built by that code is keyed by, so any change to
7
+ * the code builds it again, with no number to bump by hand (the installed
8
+ * Core is the cache folder's own key).
9
+ * @param {string} url the module's own `import.meta.url`
10
+ */
11
+ export function codeFingerprint(url: string): string;
4
12
  /**
5
13
  * The props a component renders with: its doc's playground defaults, or,
6
14
  * for a doc with none (an older Core), a sample for each required prop.
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import * as fs from 'node:fs';
19
+ import * as os from 'node:os';
19
20
  import * as path from 'node:path';
20
21
  import {createHash} from 'node:crypto';
21
22
  import {createRequire} from 'node:module';
@@ -37,14 +38,19 @@ import {
37
38
  pageSource,
38
39
  } from './_catalog.mjs';
39
40
  import {removeOnStop} from '../../foundation/fs/stop-cleanup.mjs';
41
+ import {
42
+ fileStamp,
43
+ recordContentRead,
44
+ } from '../../foundation/fs/read-record.mjs';
40
45
 
41
46
  /**
42
- * What the cached part data is built by: a fingerprint of this file and
43
- * every file it imports by a relative path, read once. Any change to the
44
- * code that draws and reads the census builds it again, with no number to
45
- * bump by hand (the installed Core is the cache folder's own key).
47
+ * A fingerprint of a module and every file it imports by a relative path,
48
+ * read once: what a cache built by that code is keyed by, so any change to
49
+ * the code builds it again, with no number to bump by hand (the installed
50
+ * Core is the cache folder's own key).
51
+ * @param {string} url the module's own `import.meta.url`
46
52
  */
47
- const CENSUS_KEY = (() => {
53
+ export function codeFingerprint(url) {
48
54
  const hash = createHash('sha256');
49
55
  /** @type {Set<string>} */
50
56
  const seen = new Set();
@@ -65,9 +71,12 @@ const CENSUS_KEY = (() => {
65
71
  ))
66
72
  walk(path.resolve(path.dirname(file), m[1]));
67
73
  };
68
- walk(fileURLToPath(import.meta.url));
74
+ walk(fileURLToPath(url));
69
75
  return hash.digest('hex').slice(0, 16);
70
- })();
76
+ }
77
+
78
+ /** What the cached part data is built by ({@link codeFingerprint}). */
79
+ const CENSUS_KEY = codeFingerprint(import.meta.url);
71
80
 
72
81
  /**
73
82
  * Flags that change what a component does or whether it shows, not how it
@@ -199,12 +208,16 @@ export function demoProps(project, name) {
199
208
  )
200
209
  return null;
201
210
  const props = given ?? {};
202
- // A search source its defaults leave out (a command palette's) is the
203
- // page's sample one: without it the part lists nothing.
211
+ // A required prop its defaults leave out (a status dot's variant, a
212
+ // command palette's search source) takes its sample, as for a doc with no
213
+ // defaults: without it the part draws nothing (no color, no list).
204
214
  if (given)
205
- for (const [p, d] of Object.entries(info.props ?? {}))
206
- if (!(p in props) && /^SearchSource\b/.test(d.type))
207
- props[p] = SAMPLE_SOURCE;
215
+ for (const [p, d] of Object.entries(info.props ?? {})) {
216
+ if (p in props || /^on[A-Z]/.test(p) || p === 'children') continue;
217
+ if (!d.required && !/^SearchSource\b/.test(d.type)) continue;
218
+ const v = d.slots?.[0] ?? sampleOf(name, d.type);
219
+ if (v !== undefined) props[p] = v;
220
+ }
208
221
  if (!given)
209
222
  for (const [p, d] of Object.entries(info.props ?? {})) {
210
223
  if (!d.required || /^on[A-Z]/.test(p)) continue;
@@ -490,10 +503,55 @@ const RUN = `${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
490
503
  export const renderDir = project =>
491
504
  path.join(project.cwd, 'themes', `.astryx-render-${RUN}`);
492
505
 
506
+ /** The file in a render folder that names the process that made it. */
507
+ const RENDER_OWNER = '.astryx-render-owner.json';
508
+ /** The renders of this process running now, which share its render folder. */
509
+ let rendersInFlight = 0;
510
+
511
+ /**
512
+ * The process space this process runs in: its host and, on Linux, its pid
513
+ * namespace, so a process id read from a render folder's owner file is
514
+ * known to be this machine's own (a container that shares the project
515
+ * folder has another).
516
+ */
517
+ const processSpace = () => {
518
+ let namespace = '';
519
+ try {
520
+ namespace = fs.readlinkSync('/proc/self/ns/pid');
521
+ } catch {
522
+ // No pid namespaces here.
523
+ }
524
+ return `${os.hostname()}\0${namespace}`;
525
+ };
526
+
527
+ /**
528
+ * Whether the process that made a render folder is known to be gone: its
529
+ * owner file names this process space, and no process has its id.
530
+ * @param {string} dir
531
+ * @param {number} pid
532
+ */
533
+ function renderOwnerGone(dir, pid) {
534
+ /** @type {any} */
535
+ let owner;
536
+ try {
537
+ owner = JSON.parse(fs.readFileSync(path.join(dir, RENDER_OWNER), 'utf8'));
538
+ } catch {
539
+ return false;
540
+ }
541
+ if (owner?.space !== processSpace() || owner?.pid !== pid) return false;
542
+ try {
543
+ process.kill(pid, 0);
544
+ return false;
545
+ } catch (error) {
546
+ return /** @type {any} */ (error)?.code === 'ESRCH';
547
+ }
548
+ }
549
+
493
550
  /**
494
551
  * Remove render folders a stopped command left (killed, out of memory):
495
- * only `.astryx-render-<pid>-<random>` folders more than ten minutes old.
496
- * Links are never followed.
552
+ * `.astryx-render-<pid>-<random>` folders whose maker is known to be gone
553
+ * (its owner file names this process space, and no process has its id),
554
+ * else only those more than ten minutes old. Links are never followed.
497
555
  * @param {string} themes
498
556
  */
499
557
  function sweepRenders(themes) {
@@ -507,17 +565,23 @@ function sweepRenders(themes) {
507
565
  const m = /^\.astryx-render-(\d+)-[a-z0-9]+$/.exec(n);
508
566
  if (!m || Number(m[1]) === process.pid) continue;
509
567
  const p = path.join(themes, n);
510
- // A process id from another process space may look gone or alive here,
511
- // so age decides: a render takes at most three minutes, and a folder
512
- // older than ten is a leftover.
513
- /** @type {number} */
514
- let age;
568
+ // A folder whose maker is known gone is a leftover at once. A process id
569
+ // from another process space may look gone or alive here, so there age
570
+ // decides: a render takes at most three minutes, and a folder older than
571
+ // ten is a leftover.
572
+ /** @type {import('node:fs').Stats} */
573
+ let stat;
515
574
  try {
516
- age = Date.now() - fs.lstatSync(p).mtimeMs;
575
+ stat = fs.lstatSync(p);
517
576
  } catch {
518
577
  continue;
519
578
  }
520
- if (age < 10 * 60_000) continue;
579
+ if (!stat.isDirectory()) continue;
580
+ if (
581
+ !renderOwnerGone(p, Number(m[1])) &&
582
+ Date.now() - stat.mtimeMs < 10 * 60_000
583
+ )
584
+ continue;
521
585
  try {
522
586
  if (fs.lstatSync(p).isDirectory())
523
587
  fs.rmSync(p, {recursive: true, force: true});
@@ -564,22 +628,36 @@ export async function renderGenerated(
564
628
  // still goes.
565
629
  const untrack = removeOnStop(dir);
566
630
  const entry = path.join(dir, file);
567
- // Demo images point at the docs site's own folder (`/template-assets/…`),
568
- // which a page opened from disk cannot reach: the inline placeholder
569
- // takes their place, as when a template is scaffolded.
570
- const {stripTemplateAssetRefs} =
571
- await import('../../foundation/discovery/template-adapter.mjs');
572
- fs.writeFileSync(entry, stripTemplateAssetRefs(source));
573
- for (const x of extra) {
574
- fs.mkdirSync(path.dirname(path.join(dir, x.name)), {recursive: true});
575
- fs.copyFileSync(x.from, path.join(dir, x.name));
576
- }
631
+ rendersInFlight++;
577
632
  try {
633
+ // Who made it, so a later render can tell it is left over once this
634
+ // process is gone (killed outright, which no handler sees).
635
+ fs.writeFileSync(
636
+ path.join(dir, RENDER_OWNER),
637
+ `${JSON.stringify({pid: process.pid, space: processSpace()})}\n`,
638
+ );
639
+ // Demo images point at the docs site's own folder
640
+ // (`/template-assets/…`), which a page opened from disk cannot reach:
641
+ // the inline placeholder takes their place, as when a template is
642
+ // scaffolded.
643
+ const {stripTemplateAssetRefs} =
644
+ await import('../../foundation/discovery/template-adapter.mjs');
645
+ fs.writeFileSync(entry, stripTemplateAssetRefs(source));
646
+ for (const x of extra) {
647
+ fs.mkdirSync(path.dirname(path.join(dir, x.name)), {recursive: true});
648
+ fs.copyFileSync(x.from, path.join(dir, x.name));
649
+ }
578
650
  // The editor's pages render every component, and a busy machine slows
579
651
  // them down: they get three times the page limit.
580
652
  const page = await renderPage(entry, {
581
653
  title: file.replace(/\.[^.]+$/, ''),
582
654
  timeoutMs: EDITOR_RENDER_MS,
655
+ // The editor shows the markup itself and writes no file, so it needs
656
+ // no script.
657
+ markupOnly: true,
658
+ // A theme's image too large for a page is named by the editor (show's
659
+ // notes); the page goes on without it.
660
+ leaveLargeStyleAssets: true,
583
661
  ...(opts.openLayers ? {openLayers: true} : {}),
584
662
  });
585
663
  // The page is the same whichever command rendered it: the folder's
@@ -631,6 +709,10 @@ export async function renderGenerated(
631
709
  // it, so a render running beside this one keeps its own.
632
710
  for (const f of [entry, ...extra.map(x => path.join(dir, x.name))])
633
711
  fs.rmSync(f, {force: true});
712
+ // The owner file goes with this process's last render: then the folder
713
+ // holds nothing of a render still running.
714
+ if (--rendersInFlight === 0)
715
+ fs.rmSync(path.join(dir, RENDER_OWNER), {force: true});
634
716
  // Another render may still use it: a folder with a file in it stays.
635
717
  removeEmptyFolder(madeThemes ? themes : dir, {deep: true});
636
718
  untrack();
@@ -641,8 +723,8 @@ export async function renderGenerated(
641
723
  const isRecord = v => typeof v === 'object' && v !== null && !Array.isArray(v);
642
724
 
643
725
  /**
644
- * Part data read from a cache file, by file, with the file's identity, size
645
- * and time when it was read. Shared by every command in the process, so it
726
+ * Part data read from a cache file, by file, with the file's stamp
727
+ * (`fileStamp`) when it was read. Shared by every command in the process, so it
646
728
  * is frozen.
647
729
  * @type {Map<string, {stamp: string, data: PartData}>}
648
730
  */
@@ -672,8 +754,8 @@ export async function partData(project) {
672
754
  try {
673
755
  // The file is read again only when it changed: every command reads it,
674
756
  // and parsing it costs more than the rest of a small command.
675
- const st = fs.statSync(file);
676
- const stamp = `${st.ino}:${st.size}:${st.mtimeMs}`;
757
+ recordContentRead(file);
758
+ const stamp = fileStamp(file);
677
759
  const kept = readParts.get(file);
678
760
  const cached =
679
761
  kept?.stamp === stamp
@@ -688,7 +770,9 @@ export async function partData(project) {
688
770
  Object.values(cached.map).every(isRecord) &&
689
771
  Array.isArray(cached.pairs)
690
772
  ) {
691
- readParts.set(file, {stamp, data: cached});
773
+ // A file that appeared after its stamp is not kept: the entry would
774
+ // outlive its removal.
775
+ if (stamp !== '-') readParts.set(file, {stamp, data: cached});
692
776
  return cached;
693
777
  }
694
778
  } catch {
@@ -54,6 +54,30 @@ export function pngTexts(bytes: Buffer): Record<string, string>;
54
54
  * @returns {Buffer}
55
55
  */
56
56
  export function withPngText(bytes: Buffer, keyword: string, text: string): Buffer;
57
+ /**
58
+ * The bytes of a PNG holding a picture's RGBA pixels, 8 bits a channel, each
59
+ * row unfiltered.
60
+ * @param {Picture} pic
61
+ * @returns {Buffer}
62
+ */
63
+ export function encodePng({ width, height, rgba }: Picture): Buffer;
64
+ /**
65
+ * A tall picture cut into pictures, in order, each cut only at the top of a
66
+ * row of parts: the end of a run of at least `gap` rows of one color (the
67
+ * page between two rows of cells; a cell's dashed edge breaks every run
68
+ * inside it). A piece ends at the lowest row top within `most` pixels; a
69
+ * row taller than that is a piece of its own, never cut through. A last
70
+ * piece shorter than `least` joins the one before it. A picture no taller
71
+ * than `most` is itself alone.
72
+ * @param {Picture} pic
73
+ * @param {number} most
74
+ * @param {{gap?: number, least?: number}} [options]
75
+ * @returns {Picture[]}
76
+ */
77
+ export function cutTall(pic: Picture, most: number, { gap, least }?: {
78
+ gap?: number;
79
+ least?: number;
80
+ }): Picture[];
57
81
  /**
58
82
  * The most pixels a picture may have: about a 6K screen. A bigger header is
59
83
  * refused before any memory is taken for it.