@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
@@ -1,15 +1,16 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file One whole-page picture of a page through a Chrome or Chromium,
5
- * driven over the DevTools protocol on a pipe, run as its own process by the
6
- * editor's browser runner.
7
- * @input argv: the browser, the page (.html), the picture (.png), the color
8
- * mode
9
- * @output the whole page, every pixel of its height, at the path given, and
10
- * on stdout the fonts it drew its text in (font-probe.mjs) and the text
11
- * it draws cut short (cut-short.mjs); on failure, the browser's reason
12
- * on stderr and exit code 1
4
+ * @file Whole-page pictures of a batch of pages through one Chrome or
5
+ * Chromium, driven over the DevTools protocol on a pipe, run as its own
6
+ * process by the editor's browser runner.
7
+ * @input argv: the browser, and the batch (JSON: each job's page .html,
8
+ * picture .png and color mode)
9
+ * @output each whole page, every pixel of its height, at its path, and on
10
+ * stdout, each line led by its job's place and a tab: the fonts it drew
11
+ * its text in (font-probe.mjs), the text it draws cut short
12
+ * (cut-short.mjs), and PICTURE_TAKEN once it is whole; on failure, the
13
+ * browser's reason on stderr and exit code 1
13
14
  * @position run by `screenshot` in api/theme-edit/_preview.mjs through
14
15
  * `runBrowser`, which gives it a temp folder of its own (the browser's
15
16
  * profile goes there), its time bound and its stop
@@ -22,10 +23,21 @@ import * as path from 'node:path';
22
23
  import {pathToFileURL} from 'node:url';
23
24
  import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
24
25
  import {NETWORK_URL_PATTERNS, QUIET_BROWSER_ARGS} from './offline.mjs';
25
- import {PICTURE_WINDOW} from './picture-window.mjs';
26
+ import {
27
+ PICTURE_PAGES_AT_ONCE,
28
+ PICTURE_TAKEN,
29
+ PICTURE_WINDOW,
30
+ SETTLE_ANIMATIONS,
31
+ AWAIT_QUIET,
32
+ eachAtOnce,
33
+ } from './picture-window.mjs';
26
34
  import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
27
35
 
28
- const [chrome, html, png, mode] = process.argv.slice(2);
36
+ const [chrome, batch] = process.argv.slice(2);
37
+ /** @type {Array<{html: string, png: string, mode: string}>} */
38
+ const jobs = JSON.parse(batch);
39
+ /** A line for one job of the batch. @param {number} i @param {string} line */
40
+ const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
29
41
 
30
42
  const browser = spawn(
31
43
  chrome,
@@ -140,8 +152,16 @@ function event(method, sessionId) {
140
152
  ]);
141
153
  }
142
154
 
143
- try {
144
- const {targetId} = await send('Target.createTarget', {url: 'about:blank'});
155
+ /**
156
+ * One page of the batch in a tab of its own: drawn, pictured whole, and
157
+ * measured.
158
+ * @param {{html: string, png: string, mode: string}} job
159
+ * @param {number} i
160
+ */
161
+ async function picture({html, png, mode}, i) {
162
+ // Each page in a window of its own: a page in a background tab runs
163
+ // no animation frames, so a chart drawn over frames never finishes.
164
+ const {targetId} = await send('Target.createTarget', {url: 'about:blank', newWindow: true});
145
165
  const {sessionId} = await send('Target.attachToTarget', {
146
166
  targetId,
147
167
  flatten: true,
@@ -171,20 +191,20 @@ try {
171
191
  const loaded = event('Page.loadEventFired', sessionId);
172
192
  await send('Page.navigate', {url: pathToFileURL(html).href}, sessionId);
173
193
  await loaded;
194
+ // The page draws, at the window's size, until it is quiet (a chart's
195
+ // drawing over frames ends).
196
+ await send('Runtime.evaluate', {expression: AWAIT_QUIET, awaitPromise: true}, sessionId);
174
197
  // An overlay drawn open plays its opening animation (a fade-in) as the
175
- // page loads: each animation that ends is run to its end before the
176
- // picture, so the picture shows the overlay as it looks open, as
177
- // Playwright's animations: 'disabled' does. A looping one (a spinner)
178
- // stays as it is.
179
- await send(
180
- 'Runtime.evaluate',
181
- {
182
- expression: `for (const a of document.getAnimations()) { if (a.effect?.getComputedTiming().iterations !== Infinity) a.finish(); }`,
183
- },
184
- sessionId,
185
- );
198
+ // page loads: it is run to its end, and a looping one held at a frame a
199
+ // person sees (SETTLE_ANIMATIONS), before the picture.
200
+ await send('Runtime.evaluate', {expression: SETTLE_ANIMATIONS}, sessionId);
186
201
  const metrics = await send('Page.getLayoutMetrics', {}, sessionId);
187
202
  const size = metrics.cssContentSize ?? metrics.contentSize;
203
+ // A picture beyond the window makes the page see a resize; a part that
204
+ // redraws on it (a responsive chart) would start over and be pictured
205
+ // empty. The page's script is held while the picture is taken; the page
206
+ // stays laid out for the window (its vh, fixed parts and media queries).
207
+ await send('Emulation.setScriptExecutionDisabled', {value: true}, sessionId);
188
208
  const {data} = await send(
189
209
  'Page.captureScreenshot',
190
210
  {
@@ -201,12 +221,12 @@ try {
201
221
  sessionId,
202
222
  );
203
223
  fs.writeFileSync(png, Buffer.from(data, 'base64'));
224
+ await send('Emulation.setScriptExecutionDisabled', {value: false}, sessionId);
204
225
  // The fonts the picture drew its text in, for the editor's note.
205
226
  const fonts = await probeFonts((method, params) =>
206
227
  send(method, params, sessionId),
207
228
  ).catch(() => null);
208
- if (fonts)
209
- process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
229
+ if (fonts) say(i, `${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}`);
210
230
  // The text the picture draws cut short, measured on the page as the
211
231
  // picture shows it. A measurement that does not run says nothing, and
212
232
  // the picture stands.
@@ -216,9 +236,14 @@ try {
216
236
  sessionId,
217
237
  ).catch(() => null);
218
238
  if (Array.isArray(measured?.result?.value) && !measured.exceptionDetails)
219
- process.stdout.write(
220
- `${CUT_SHORT_PREFIX}${JSON.stringify(measured.result.value)}\n`,
221
- );
239
+ say(i, `${CUT_SHORT_PREFIX}${JSON.stringify(measured.result.value)}`);
240
+ await send('Target.closeTarget', {targetId}).catch(() => {});
241
+ say(i, PICTURE_TAKEN);
242
+ }
243
+
244
+ try {
245
+ // One browser for every page of the batch, a few tabs at a time.
246
+ await eachAtOnce(jobs, PICTURE_PAGES_AT_ONCE, picture);
222
247
  await send('Browser.close').catch(() => {});
223
248
  } catch (e) {
224
249
  process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
@@ -1,14 +1,16 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file One picture of a page through the project's Playwright, run as its
5
- * own process by the editor's browser runner.
6
- * @input argv: the Playwright entry file, the page (.html), the picture
7
- * (.png), the color mode, and a browser to use instead of Playwright's own
8
- * @output the picture at the path given, and on stdout the fonts it drew
9
- * its text in (font-probe.mjs) and the text it draws cut short
10
- * (cut-short.mjs); on failure, Playwright's error on stderr and exit
11
- * code 1
4
+ * @file The pictures of a batch of pages through the project's Playwright,
5
+ * one browser for all, run as its own process by the editor's browser
6
+ * runner.
7
+ * @input argv: the Playwright entry file, the batch (JSON: each job's page
8
+ * .html, picture .png and color mode), and a browser to use instead of
9
+ * Playwright's own
10
+ * @output each picture at its path, and on stdout, each line led by its
11
+ * job's place and a tab: the fonts it drew its text in (font-probe.mjs),
12
+ * the text it draws cut short (cut-short.mjs), and PICTURE_TAKEN once it
13
+ * is whole; on failure, Playwright's error on stderr and exit code 1
12
14
  * @position run by `screenshot` in api/theme-edit/_preview.mjs through
13
15
  * `runBrowser`, which gives it a temp folder of its own, its time bound and its stop
14
16
  */
@@ -16,51 +18,85 @@
16
18
  import {pathToFileURL} from 'node:url';
17
19
  import {CUT_SHORT_PREFIX, cutShortText} from './cut-short.mjs';
18
20
  import {LOCAL_URL, QUIET_BROWSER_ARGS} from './offline.mjs';
19
- import {PICTURE_WINDOW} from './picture-window.mjs';
21
+ import {
22
+ PICTURE_PAGES_AT_ONCE,
23
+ PICTURE_TAKEN,
24
+ PICTURE_WINDOW,
25
+ SETTLE_ANIMATIONS,
26
+ AWAIT_QUIET,
27
+ eachAtOnce,
28
+ } from './picture-window.mjs';
20
29
  import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
21
30
 
22
- const [entry, html, png, mode, executablePath] = process.argv.slice(2);
31
+ const [entry, batch, executablePath] = process.argv.slice(2);
32
+ /** @type {Array<{html: string, png: string, mode: string}>} */
33
+ const jobs = JSON.parse(batch);
34
+ /** A line for one job of the batch. @param {number} i @param {string} line */
35
+ const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
23
36
  try {
24
37
  const pw = await import(pathToFileURL(entry).href);
25
38
  const chromium = pw.chromium ?? pw.default?.chromium;
26
- // The browser's own network off, as for the Chrome picture script.
39
+ // One browser for every picture of the batch, its own network off, as
40
+ // for the Chrome picture script.
27
41
  const browser = await chromium.launch({
28
42
  args: [...QUIET_BROWSER_ARGS],
29
43
  ...(executablePath ? {executablePath} : {}),
30
44
  });
31
45
  try {
32
- const page = await browser.newPage({
33
- viewport: {...PICTURE_WINDOW},
34
- colorScheme: mode === 'dark' ? 'dark' : 'light',
35
- });
36
- // The page loads its own files only: a remote stylesheet, font or image
37
- // fails at once instead of holding the load on a network.
38
- await page.route(
39
- (/** @type {URL} */ url) => !LOCAL_URL.test(url.href),
40
- (/** @type {{abort: (why: string) => Promise<void>}} */ route) =>
41
- route.abort('blockedbyclient'),
46
+ await eachAtOnce(
47
+ jobs,
48
+ PICTURE_PAGES_AT_ONCE,
49
+ async ({html, png, mode}, i) => {
50
+ const page = await browser.newPage({
51
+ viewport: {...PICTURE_WINDOW},
52
+ colorScheme: mode === 'dark' ? 'dark' : 'light',
53
+ });
54
+ // The page loads its own files only: a remote stylesheet, font or
55
+ // image fails at once instead of holding the load on a network.
56
+ await page.route(
57
+ (/** @type {URL} */ url) => !LOCAL_URL.test(url.href),
58
+ (/** @type {{abort: (why: string) => Promise<void>}} */ route) =>
59
+ route.abort('blockedbyclient'),
60
+ );
61
+ await page.goto(pathToFileURL(html).href, {waitUntil: 'load'});
62
+ // The page draws until it is quiet (a chart's drawing over frames
63
+ // ends).
64
+ await page.evaluate(AWAIT_QUIET);
65
+ // An overlay drawn open plays its opening animation (a fade-in) as
66
+ // the page loads: it is run to its end, and a looping one held at a
67
+ // frame a person sees (SETTLE_ANIMATIONS), before the picture.
68
+ // Playwright's own animations: 'disabled' would put a looping one
69
+ // back at its first frame, where a skeleton is faint.
70
+ await page.evaluate(SETTLE_ANIMATIONS);
71
+ // A whole-page picture makes the page see a resize; a part that
72
+ // redraws on it (a responsive chart) would start over and be
73
+ // pictured empty. The page's script is held while it is taken.
74
+ const held = await (async () => {
75
+ const cdp = await page.context().newCDPSession(page);
76
+ await cdp.send('Emulation.setScriptExecutionDisabled', {value: true});
77
+ return cdp;
78
+ })().catch(() => null);
79
+ await page.screenshot({path: png, fullPage: true, animations: 'allow'});
80
+ await held?.send('Emulation.setScriptExecutionDisabled', {value: false}).catch(() => {});
81
+ // The fonts the picture drew its text in, for the editor's note.
82
+ const fonts = await (async () => {
83
+ const cdp = await page.context().newCDPSession(page);
84
+ return probeFonts((method, params) => cdp.send(method, params));
85
+ })().catch(() => null);
86
+ if (fonts) say(i, `${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}`);
87
+ // The text the picture draws cut short, measured on the page as the
88
+ // picture shows it. A page that runs no script measures nothing, and
89
+ // the picture stands: nothing is said.
90
+ try {
91
+ const cut = await page.evaluate(cutShortText);
92
+ say(i, `${CUT_SHORT_PREFIX}${JSON.stringify(cut)}`);
93
+ } catch {
94
+ // Not measured.
95
+ }
96
+ await page.close?.().catch(() => {});
97
+ say(i, PICTURE_TAKEN);
98
+ },
42
99
  );
43
- await page.goto(pathToFileURL(html).href, {waitUntil: 'load'});
44
- // An overlay drawn open plays its opening animation (a fade-in) as the
45
- // page loads: the picture is taken with each animation that ends run
46
- // to its end, so it shows the overlay as it looks open.
47
- await page.screenshot({path: png, fullPage: true, animations: 'disabled'});
48
- // The fonts the picture drew its text in, for the editor's note.
49
- const fonts = await (async () => {
50
- const cdp = await page.context().newCDPSession(page);
51
- return probeFonts((method, params) => cdp.send(method, params));
52
- })().catch(() => null);
53
- if (fonts)
54
- process.stdout.write(`${FONT_PROBE_PREFIX}${JSON.stringify(fonts)}\n`);
55
- // The text the picture draws cut short, measured on the page as the
56
- // picture shows it. A page that runs no script measures nothing, and
57
- // the picture stands: nothing is said.
58
- try {
59
- const cut = await page.evaluate(cutShortText);
60
- process.stdout.write(`${CUT_SHORT_PREFIX}${JSON.stringify(cut)}\n`);
61
- } catch {
62
- // Not measured.
63
- }
64
100
  } finally {
65
101
  await browser.close();
66
102
  }
@@ -1,6 +1,16 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * Run each job of a list in order, a few at a time. Once one fails, no
6
+ * other starts; the ones running finish, then the first failure is thrown,
7
+ * so every job before it has had its turn.
8
+ * @template T
9
+ * @param {T[]} jobs
10
+ * @param {number} atOnce
11
+ * @param {(job: T, i: number) => Promise<void>} run
12
+ */
13
+ export function eachAtOnce<T>(jobs: T[], atOnce: number, run: (job: T, i: number) => Promise<void>): Promise<void>;
4
14
  /**
5
15
  * Whether a media query matches in the window a picture is taken in
6
16
  * (PICTURE_WINDOW, a desktop's, with a mouse): each comma-separated query
@@ -26,6 +36,29 @@ export function desktopMatches(query: string, { sure }?: {
26
36
  * the stylesheet cut (css-cut.mjs), so a part drawn open or in a state
27
37
  * lays out as the picture shows it.
28
38
  */
39
+ /**
40
+ * The script run on a page before its picture: each animation that ends (an
41
+ * overlay's fade-in) is run to its end, so the picture shows the part as it
42
+ * looks once it has played; each that loops (a skeleton's shimmer, a pulsing
43
+ * dot, a spinner) is held at the middle of its first round, a frame a person
44
+ * sees as it plays, never its first frame, where a part can be faint or gone.
45
+ */
46
+ export const SETTLE_ANIMATIONS: "for (const a of document.getAnimations()) {\n const t = a.effect?.getComputedTiming();\n if (!t) continue;\n if (t.iterations !== Infinity) { a.finish(); continue; }\n a.pause();\n a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;\n}";
47
+ /**
48
+ * The script run before the picture: it waits until the page stops
49
+ * changing, so a part drawn over animation frames (a responsive chart's
50
+ * lines) is drawn whole. Quiet means no change to the document for
51
+ * QUIET_MS; it waits QUIET_MOST_MS at most.
52
+ */
53
+ export const AWAIT_QUIET: "new Promise(resolve => {\n const QUIET_MS = 300;\n const QUIET_MOST_MS = 4000;\n let timer = setTimeout(done, QUIET_MS);\n const most = setTimeout(done, QUIET_MOST_MS);\n const watch = new MutationObserver(() => {\n clearTimeout(timer);\n timer = setTimeout(done, QUIET_MS);\n });\n watch.observe(document, {subtree: true, childList: true, attributes: true, characterData: true});\n function done() {\n watch.disconnect();\n clearTimeout(timer);\n clearTimeout(most);\n resolve(true);\n }\n})";
54
+ /**
55
+ * How a picture script hands back a batch: each line it prints for a job
56
+ * starts with the job's place in the batch and a tab; a job's picture is
57
+ * whole once it prints this word.
58
+ */
59
+ export const PICTURE_TAKEN: "taken";
60
+ /** How many pages of a batch a picture script draws at once. */
61
+ export const PICTURE_PAGES_AT_ONCE: 3;
29
62
  export const PICTURE_WINDOW: Readonly<{
30
63
  width: 1280;
31
64
  height: 900;
@@ -12,6 +12,84 @@
12
12
  * lays out as the picture shows it.
13
13
  */
14
14
 
15
+ /**
16
+ * The script run on a page before its picture: each animation that ends (an
17
+ * overlay's fade-in) is run to its end, so the picture shows the part as it
18
+ * looks once it has played; each that loops (a skeleton's shimmer, a pulsing
19
+ * dot, a spinner) is held at the middle of its first round, a frame a person
20
+ * sees as it plays, never its first frame, where a part can be faint or gone.
21
+ */
22
+ export const SETTLE_ANIMATIONS = `for (const a of document.getAnimations()) {
23
+ const t = a.effect?.getComputedTiming();
24
+ if (!t) continue;
25
+ if (t.iterations !== Infinity) { a.finish(); continue; }
26
+ a.pause();
27
+ a.currentTime = (Number(a.effect.getTiming().delay) || 0) + (typeof t.duration === 'number' ? t.duration : 0) / 2;
28
+ }`;
29
+
30
+ /**
31
+ * The script run before the picture: it waits until the page stops
32
+ * changing, so a part drawn over animation frames (a responsive chart's
33
+ * lines) is drawn whole. Quiet means no change to the document for
34
+ * QUIET_MS; it waits QUIET_MOST_MS at most.
35
+ */
36
+ export const AWAIT_QUIET = `new Promise(resolve => {
37
+ const QUIET_MS = 300;
38
+ const QUIET_MOST_MS = 4000;
39
+ let timer = setTimeout(done, QUIET_MS);
40
+ const most = setTimeout(done, QUIET_MOST_MS);
41
+ const watch = new MutationObserver(() => {
42
+ clearTimeout(timer);
43
+ timer = setTimeout(done, QUIET_MS);
44
+ });
45
+ watch.observe(document, {subtree: true, childList: true, attributes: true, characterData: true});
46
+ function done() {
47
+ watch.disconnect();
48
+ clearTimeout(timer);
49
+ clearTimeout(most);
50
+ resolve(true);
51
+ }
52
+ })`;
53
+
54
+ /**
55
+ * How a picture script hands back a batch: each line it prints for a job
56
+ * starts with the job's place in the batch and a tab; a job's picture is
57
+ * whole once it prints this word.
58
+ */
59
+ export const PICTURE_TAKEN = 'taken';
60
+
61
+ /** How many pages of a batch a picture script draws at once. */
62
+ export const PICTURE_PAGES_AT_ONCE = 3;
63
+
64
+ /**
65
+ * Run each job of a list in order, a few at a time. Once one fails, no
66
+ * other starts; the ones running finish, then the first failure is thrown,
67
+ * so every job before it has had its turn.
68
+ * @template T
69
+ * @param {T[]} jobs
70
+ * @param {number} atOnce
71
+ * @param {(job: T, i: number) => Promise<void>} run
72
+ */
73
+ export async function eachAtOnce(jobs, atOnce, run) {
74
+ let next = 0;
75
+ /** @type {{error: unknown} | null} */
76
+ let failed = null;
77
+ await Promise.all(
78
+ Array.from({length: Math.min(atOnce, jobs.length)}, async () => {
79
+ while (!failed && next < jobs.length) {
80
+ const i = next++;
81
+ try {
82
+ await run(jobs[i], i);
83
+ } catch (error) {
84
+ failed ??= {error};
85
+ }
86
+ }
87
+ }),
88
+ );
89
+ const first = /** @type {{error: unknown} | null} */ (failed);
90
+ if (first) throw first.error;
91
+ }
92
+
15
93
  export const PICTURE_WINDOW = Object.freeze({width: 1280, height: 900});
16
94
 
17
95
  /** The pointer of the window a picture is taken in. */
@@ -25,6 +25,34 @@ export function awaitHost(host: import("node:child_process").ChildProcess, { tim
25
25
  withoutSegmenter: boolean;
26
26
  stateFile?: string;
27
27
  }): Promise<any>;
28
+ /**
29
+ * The markup with each link out of the file opening in a new tab, as the
30
+ * file's script opens it once it runs (client-bundle.mjs): a viewer's frame
31
+ * cannot follow a link out. A link that names its own target keeps it.
32
+ * @param {string} markup the page's server markup
33
+ * @returns {string}
34
+ */
35
+ export function linksOpenNewTabs(markup: string): string;
36
+ /**
37
+ * The page's script with each string the markup's rewrite replaced (an
38
+ * image's `src`, `poster` or `srcset`, as the page wrote it) written as the
39
+ * same carried data, so the page the script draws shows what the first paint
40
+ * showed. Only a quoted string that is exactly that value changes, never a
41
+ * longer string that holds it.
42
+ * @param {string} script
43
+ * @param {Map<string, string>} rewrites
44
+ * @returns {string}
45
+ */
46
+ export function withCarriedPaths(script: string, rewrites: Map<string, string>): string;
47
+ /**
48
+ * The script with each image the embedded source does not carry written in
49
+ * as its data: URI (`uriOf` gives it), so the image still shows once the
50
+ * script draws the page.
51
+ * @param {string} script
52
+ * @param {Set<string>} carried the SHA-256 of each file the source carries
53
+ * @param {(sha256: string, prefix: string) => string | null} uriOf
54
+ */
55
+ export function withUncarriedImages(script: string, carried: Set<string>, uriOf: (sha256: string, prefix: string) => string | null): string;
28
56
  /**
29
57
  * The warning for a page rendered without Intl.Segmenter.
30
58
  * @returns {RenderWarning}
@@ -67,16 +95,26 @@ export function assetRef(ref: string, at: {
67
95
  /**
68
96
  * Render a page module to one self-contained HTML file.
69
97
  * @param {string} entry absolute path of the page module
70
- * @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean}} [options]
98
+ * @param {{title?: string, timeoutMs?: number, version?: string, served?: ServedSet | null, output?: string, cwd?: string, openLayers?: boolean, leaveLargeStyleAssets?: boolean, markupOnly?: boolean, esbuildFrom?: string}} [options]
71
99
  * `served`: the Core of the package set the CLI runs from, for the packages
72
100
  * the page's folder has no copy of; `output`: the file the HTML goes to;
73
101
  * `cwd`: the current folder, whose files are the page's own outside a
74
102
  * project; `openLayers`: the overlays the page shows or opens are drawn
75
- * and added after its markup (layers.mjs), for reading what they paint.
76
- * With `output`, the file describes itself: notes at its top and end name
103
+ * and added after its markup (layers.mjs), for reading what they paint;
104
+ * `leaveLargeStyleAssets`: a stylesheet's file too large to inline is
105
+ * left out and named in the warnings, not refused (for a caller that
106
+ * names such files itself). With `output`, the file describes itself: notes at its top and end name
77
107
  * what made it and the commands that give the page back and render it
78
108
  * again, and its embedded source records the CLI version, the packages
79
- * the page rendered with, and the markup as rendered.
109
+ * the page rendered with, and the markup as rendered. The file also
110
+ * carries the page's script (client-bundle.mjs): it draws the page over
111
+ * its markup in the browser, so the page's controls work. The markup sits
112
+ * in one element the script draws into, and the stylesheet keeps the rules
113
+ * any of the page's modules can use, not only the markup's. esbuild, a
114
+ * dependency of the CLI, builds the script (`esbuildFrom`: the folder it
115
+ * resolves from); a page whose script cannot be built fails the render.
116
+ * `markupOnly` renders the markup and its styles without the script, for a
117
+ * caller that shows the markup itself (the theme editor); it writes no file.
80
118
  * @returns {Promise<RenderedPage>}
81
119
  */
82
120
  export function renderPage(entry: string, options?: {
@@ -87,6 +125,9 @@ export function renderPage(entry: string, options?: {
87
125
  output?: string;
88
126
  cwd?: string;
89
127
  openLayers?: boolean;
128
+ leaveLargeStyleAssets?: boolean;
129
+ markupOnly?: boolean;
130
+ esbuildFrom?: string;
90
131
  }): Promise<RenderedPage>;
91
132
  /** How long one page may take to render before it is stopped. */
92
133
  export const RENDER_TIMEOUT_MS: 60000;
@@ -106,6 +147,8 @@ export const RENDER_TIMEOUT_MS: 60000;
106
147
  * @property {number} images - Local files inlined as data: URIs.
107
148
  * @property {RenderWarning[]} warnings
108
149
  * @property {{name: string, dir: string}[]} fromSet - Packages that came from the package set the CLI runs from, not the page's folder.
150
+ * @property {number} [scriptBytes] - Bytes of the page's script; none in a markup-only render.
151
+ * @property {number} [scriptModules] - The modules the page's script holds; none in a markup-only render.
109
152
  */
110
153
  /** An error carrying a render error code. */
111
154
  export class RenderError extends Error {
@@ -171,6 +214,14 @@ export type RenderedPage = {
171
214
  name: string;
172
215
  dir: string;
173
216
  }[];
217
+ /**
218
+ * - Bytes of the page's script; none in a markup-only render.
219
+ */
220
+ scriptBytes?: number | undefined;
221
+ /**
222
+ * - The modules the page's script holds; none in a markup-only render.
223
+ */
224
+ scriptModules?: number | undefined;
174
225
  };
175
226
  export type ServedSet = {
176
227
  dir: string;