@astryxdesign/cli 0.7.18-canary.gfacee17 → 0.7.18

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 (363) hide show
  1. package/CHANGELOG.md +185 -19
  2. package/README.md +19 -19
  3. package/api/component/_adapter.d.mts +2 -1
  4. package/api/component/_adapter.mjs +2 -1
  5. package/api/docs/_adapter.d.mts +6 -5
  6. package/api/docs/_adapter.mjs +36 -5
  7. package/api/doctor/_adapter.d.mts +6 -3
  8. package/api/doctor/_adapter.mjs +13 -5
  9. package/api/doctor/doctor.mjs +5 -5
  10. package/api/doctor/font-packages.d.mts +36 -0
  11. package/api/doctor/font-packages.mjs +124 -0
  12. package/api/doctor/theme-checks.mjs +110 -49
  13. package/api/experimental.d.mts +0 -2
  14. package/api/experimental.mjs +0 -12
  15. package/api/icon/_adapter.d.mts +2 -2
  16. package/api/icon/_adapter.mjs +6 -2
  17. package/api/icon/_authoring.mjs +22 -13
  18. package/api/icon/_default-look.mjs +15 -15
  19. package/api/icon/add/add.mjs +14 -9
  20. package/api/icon/icon.doc.mjs +7 -7
  21. package/api/icon/icon.type.d.mts +33 -33
  22. package/api/icon/icon.type.mjs +45 -45
  23. package/api/icon/iconAdd.doc.mjs +9 -10
  24. package/api/icon/iconMap.doc.mjs +11 -12
  25. package/api/icon/iconNewDefinition.doc.mjs +8 -8
  26. package/api/icon/iconNewSet.doc.mjs +5 -5
  27. package/api/icon/map/map.mjs +7 -7
  28. package/api/icon/use/use.mjs +4 -4
  29. package/api/init/run/run.mjs +0 -1
  30. package/api/integration/add-helpers.mjs +1 -1
  31. package/api/integration/validate-integration.type.d.mts +6 -6
  32. package/api/integration/validate-integration.type.mjs +6 -6
  33. package/api/render/_adapter.d.mts +5 -3
  34. package/api/render/_adapter.mjs +64 -4
  35. package/api/render/render.doc.mjs +9 -2
  36. package/api/render/render.mjs +5 -2
  37. package/api/render/render.type.d.mts +17 -0
  38. package/api/render/render.type.mjs +10 -0
  39. package/api/search/ORDERING.md +1 -1
  40. package/api/search/_candidate-score.mjs +20 -0
  41. package/api/search/_words.d.mts +8 -0
  42. package/api/search/_words.mjs +15 -0
  43. package/api/template/template.type.d.mts +2 -2
  44. package/api/template/template.type.mjs +2 -2
  45. package/api/theme/_adapter.mjs +19 -11
  46. package/api/theme/build/build.d.mts +19 -51
  47. package/api/theme/build/build.mjs +195 -189
  48. package/api/theme/build/font-warning.d.mts +19 -2
  49. package/api/theme/build/font-warning.mjs +46 -5
  50. package/api/theme/generateTonalPalette.doc.mjs +1 -1
  51. package/api/theme/palette/generate/derive-look.mjs +108 -37
  52. package/api/theme/palette/generate/mapping.mjs +2 -0
  53. package/api/theme/template/template.d.mts +0 -17
  54. package/api/theme/template/template.mjs +1 -42
  55. package/api/theme/theme.type.d.mts +5 -4
  56. package/api/theme/theme.type.mjs +5 -4
  57. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  58. package/api/theme/themeRemove.doc.mjs +1 -1
  59. package/assets/codemods/transforms/v0.7.0/preserve-bottom-sheet-content-padding.mjs +3 -1
  60. package/assets/component-list.generated.json +1 -1
  61. package/assets/discover/official-packages.json +26 -2
  62. package/assets/docs/author-a-theme.doc.mjs +6 -5
  63. package/assets/docs/browser-support.doc.mjs +1 -0
  64. package/assets/docs/icons.doc.mjs +8 -7
  65. package/assets/docs/motion.doc.mjs +46 -0
  66. package/assets/docs/theme.doc.dense.mjs +6 -17
  67. package/assets/docs/theme.doc.mjs +6 -16
  68. package/assets/docs/theme.doc.zh.mjs +6 -16
  69. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  70. package/assets/docs/tree/data-colors-in-renderers.doc.mjs +400 -0
  71. package/assets/docs/tree/font-setup.doc.mjs +30 -0
  72. package/assets/docs/tree/icon-sets.doc.mjs +2 -2
  73. package/assets/docs/tree/share-a-page.doc.mjs +1 -1
  74. package/assets/docs/tree/template-icons.doc.mjs +3 -3
  75. package/assets/docs/tree/tokens-color.doc.mjs +5 -0
  76. package/assets/docs/tree/tokens.doc.mjs +4 -3
  77. package/assets/docs/tree/updates.doc.mjs +1 -1
  78. package/assets/docs/tree/visualization.doc.mjs +30 -0
  79. package/assets/docs-routes.generated.json +1 -1
  80. package/assets/docs.generated.json +2 -2
  81. package/assets/icons/definitions/drag.doc.mjs +1 -0
  82. package/assets/search-catalog.generated.json +2 -2
  83. package/assets/self-audit.generated.json +1 -1
  84. package/assets/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +1 -1
  85. package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +20 -10
  86. package/assets/templates/blocks/components/Card/SelectableCardShowcase.doc.mjs +1 -1
  87. package/assets/templates/blocks/components/Card/SelectableCardShowcase.tsx +36 -16
  88. package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +6 -0
  89. package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +6 -0
  90. package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.doc.mjs +14 -0
  91. package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.tsx +63 -0
  92. package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.doc.mjs +29 -0
  93. package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.tsx +237 -0
  94. package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +10 -72
  95. package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.doc.mjs +1 -1
  96. package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +7 -7
  97. package/assets/templates/blocks/components/Table/TableCustomRowTable.doc.mjs +14 -0
  98. package/assets/templates/blocks/components/Table/TableCustomRowTable.tsx +96 -0
  99. package/assets/templates/components.generated.json +1 -1
  100. package/assets/templates/pages/ai-chat-landing/page.tsx +4 -0
  101. package/assets/templates/pages/dashboard-scorecard/page.tsx +26 -7
  102. package/assets/templates/pages/editor/page.tsx +13 -3
  103. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +2 -2
  104. package/assets/templates/themes/butter/butterTheme.ts +12 -10
  105. package/assets/templates/themes/butter/icons.tsx +2 -0
  106. package/assets/templates/themes/chocolate/chocolateTheme.ts +1 -0
  107. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  108. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
  109. package/assets/templates/themes/gothic/gothicTheme.ts +1 -0
  110. package/assets/templates/themes/gothic/icons.tsx +2 -0
  111. package/assets/templates/themes/matcha/icons.tsx +2 -0
  112. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +2 -2
  113. package/assets/templates/themes/matcha/matchaTheme.ts +1 -0
  114. package/assets/templates/themes/neutral/icons.tsx +2 -0
  115. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +2 -2
  116. package/assets/templates/themes/neutral/neutralTheme.ts +1 -0
  117. package/assets/templates/themes/stone/icons.tsx +2 -0
  118. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +1 -1
  119. package/assets/templates/themes/stone/stoneTheme.ts +1 -0
  120. package/assets/templates/themes/y2k/icons.tsx +2 -0
  121. package/assets/templates/themes/y2k/y2kTheme.ts +1 -0
  122. package/assets/theme.template.ts +9 -5
  123. package/authoring/config/parse.mjs +1 -1
  124. package/authoring/doctypes/base/type.ts +2 -3
  125. package/authoring/doctypes/component/component.doc.mjs +1 -1
  126. package/authoring/doctypes/icon-set/icon-names.mjs +1 -0
  127. package/authoring/integration/integration.doc.mjs +1 -1
  128. package/authoring/integration/type.ts +1 -1
  129. package/clients/cli/build-id.generated.json +1 -1
  130. package/clients/cli/commands/doctor.mjs +2 -2
  131. package/clients/cli/commands/experimental/export.mjs +2 -1
  132. package/clients/cli/commands/experimental/icon.mjs +17 -17
  133. package/clients/cli/commands/experimental/index.mjs +0 -5
  134. package/clients/cli/commands/experimental/render-output.mjs +9 -0
  135. package/clients/cli/commands/experimental-export.doc.mjs +6 -0
  136. package/clients/cli/commands/experimental-icon-add.doc.mjs +8 -8
  137. package/clients/cli/commands/experimental-icon-map.doc.mjs +6 -6
  138. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +6 -6
  139. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +3 -3
  140. package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
  141. package/clients/cli/commands/experimental-icon.doc.mjs +6 -6
  142. package/clients/cli/commands/experimental.doc.mjs +2 -6
  143. package/clients/cli/commands/template.mjs +1 -1
  144. package/clients/cli/commands/theme-build.doc.mjs +8 -1
  145. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -1
  146. package/clients/cli/commands/theme-remove.doc.mjs +1 -1
  147. package/clients/cli/commands/theme.doc.mjs +1 -11
  148. package/clients/cli/commands/theme.mjs +110 -475
  149. package/clients/cli/commands.generated.json +1 -1
  150. package/clients/cli/index.mjs +4 -34
  151. package/clients/cli/lib/base-gate.mjs +2 -3
  152. package/clients/cli/lib/cli-error.mjs +8 -72
  153. package/clients/cli/lib/define-command.mjs +0 -19
  154. package/clients/cli/lib/json-shim.mjs +11 -633
  155. package/clients/cli/lib/manifest.mjs +0 -4
  156. package/clients/cli/lib/stray-option.mjs +1 -2
  157. package/clients/cli/manifest.generated.json +1 -1
  158. package/foundation/agent-docs/agent-docs.mjs +1 -1
  159. package/foundation/color/css-color.mjs +2 -3
  160. package/foundation/discovery/app-layout.d.mts +13 -0
  161. package/foundation/discovery/app-layout.mjs +35 -0
  162. package/foundation/discovery/cli-self-docs.mjs +4 -4
  163. package/foundation/discovery/fixture-refs.d.mts +51 -0
  164. package/foundation/discovery/fixture-refs.mjs +351 -0
  165. package/foundation/discovery/icon-definition-discovery.mjs +7 -7
  166. package/foundation/discovery/icon-ranking.mjs +2 -2
  167. package/foundation/discovery/icon-set-checks.mjs +6 -6
  168. package/foundation/discovery/icon-set-discovery.mjs +2 -2
  169. package/foundation/discovery/icon-set-writer.d.mts +24 -7
  170. package/foundation/discovery/icon-set-writer.mjs +75 -31
  171. package/foundation/discovery/static-descriptor.d.mts +49 -0
  172. package/foundation/discovery/static-descriptor.mjs +548 -0
  173. package/foundation/discovery/template-adapter.d.mts +0 -47
  174. package/foundation/discovery/template-adapter.mjs +1 -333
  175. package/foundation/discovery/theme-discovery.d.mts +6 -47
  176. package/foundation/discovery/theme-discovery.mjs +15 -537
  177. package/foundation/doc-compiler/bundle.mjs +2 -2
  178. package/foundation/doc-compiler/import.mjs +1 -1
  179. package/foundation/env/user-dirs.d.mts +5 -2
  180. package/foundation/env/user-dirs.mjs +12 -5
  181. package/foundation/fonts/next-font.d.mts +26 -0
  182. package/foundation/fonts/next-font.mjs +149 -0
  183. package/foundation/fs/empty-folder.mjs +2 -2
  184. package/foundation/fs/read-record.mjs +11 -4
  185. package/foundation/pictures/pictures.d.mts +152 -0
  186. package/foundation/pictures/pictures.mjs +565 -0
  187. package/foundation/release/folder-lock.mjs +3 -2
  188. package/foundation/render/cut-short.d.mts +2 -2
  189. package/foundation/render/cut-short.mjs +2 -2
  190. package/foundation/render/drawn-contrast.d.mts +2 -2
  191. package/foundation/render/drawn-contrast.mjs +2 -2
  192. package/foundation/render/font-probe.d.mts +2 -2
  193. package/foundation/render/font-probe.mjs +2 -2
  194. package/foundation/render/layers.mjs +1 -2
  195. package/foundation/render/package-resolve-hooks.d.mts +25 -5
  196. package/foundation/render/package-resolve-hooks.mjs +77 -14
  197. package/foundation/render/page-worker.mjs +24 -12
  198. package/foundation/render/part-boxes.d.mts +2 -3
  199. package/foundation/render/part-boxes.mjs +2 -3
  200. package/foundation/render/picture-chrome.mjs +18 -15
  201. package/foundation/render/picture-playwright.mjs +10 -7
  202. package/foundation/render/picture-window.d.mts +13 -0
  203. package/foundation/render/picture-window.mjs +31 -0
  204. package/foundation/render/render-page.d.mts +1 -1
  205. package/foundation/render/render-page.mjs +4 -5
  206. package/foundation/render/single-copy-hooks.d.mts +2 -0
  207. package/foundation/render/single-copy-hooks.mjs +2 -0
  208. package/foundation/response/error-codes.doc.mjs +14 -14
  209. package/foundation/response/error-codes.mjs +13 -13
  210. package/foundation/response/response-types.doc.mjs +8 -69
  211. package/foundation/runtime/css-tree.mjs +2 -2
  212. package/foundation/runtime/word-table.d.mts +1 -1
  213. package/foundation/runtime/word-table.mjs +1 -1
  214. package/foundation/suggest/other-command.d.mts +52 -15
  215. package/foundation/suggest/other-command.mjs +168 -45
  216. package/foundation/text/suggest-order.d.mts +7 -0
  217. package/foundation/text/suggest-order.mjs +1 -1
  218. package/package.json +7 -8
  219. package/api/theme-edit/_adapter.d.mts +0 -228
  220. package/api/theme-edit/_adapter.mjs +0 -2025
  221. package/api/theme-edit/_catalog.d.mts +0 -172
  222. package/api/theme-edit/_catalog.mjs +0 -806
  223. package/api/theme-edit/_check.d.mts +0 -391
  224. package/api/theme-edit/_check.mjs +0 -9370
  225. package/api/theme-edit/_color.d.mts +0 -135
  226. package/api/theme-edit/_color.mjs +0 -480
  227. package/api/theme-edit/_compiler.d.mts +0 -77
  228. package/api/theme-edit/_compiler.mjs +0 -1053
  229. package/api/theme-edit/_context.d.mts +0 -399
  230. package/api/theme-edit/_context.mjs +0 -1778
  231. package/api/theme-edit/_css.d.mts +0 -169
  232. package/api/theme-edit/_css.mjs +0 -1167
  233. package/api/theme-edit/_edit.d.mts +0 -167
  234. package/api/theme-edit/_edit.mjs +0 -11220
  235. package/api/theme-edit/_how-commands.d.mts +0 -315
  236. package/api/theme-edit/_how-commands.mjs +0 -1664
  237. package/api/theme-edit/_how-question.d.mts +0 -341
  238. package/api/theme-edit/_how-question.mjs +0 -33291
  239. package/api/theme-edit/_how-sides.d.mts +0 -22
  240. package/api/theme-edit/_how-sides.mjs +0 -173
  241. package/api/theme-edit/_how-steps.d.mts +0 -42
  242. package/api/theme-edit/_how-steps.mjs +0 -208
  243. package/api/theme-edit/_how-values.d.mts +0 -29
  244. package/api/theme-edit/_how-values.mjs +0 -111
  245. package/api/theme-edit/_how-words.d.mts +0 -15
  246. package/api/theme-edit/_how-words.mjs +0 -239
  247. package/api/theme-edit/_how.d.mts +0 -55
  248. package/api/theme-edit/_how.mjs +0 -2388
  249. package/api/theme-edit/_importers.d.mts +0 -38
  250. package/api/theme-edit/_importers.mjs +0 -188
  251. package/api/theme-edit/_marks.d.mts +0 -39
  252. package/api/theme-edit/_marks.mjs +0 -67
  253. package/api/theme-edit/_missed.d.mts +0 -56
  254. package/api/theme-edit/_missed.mjs +0 -1128
  255. package/api/theme-edit/_name-rule.d.mts +0 -11
  256. package/api/theme-edit/_name-rule.mjs +0 -12
  257. package/api/theme-edit/_normal.d.mts +0 -365
  258. package/api/theme-edit/_normal.mjs +0 -1978
  259. package/api/theme-edit/_overview.d.mts +0 -9
  260. package/api/theme-edit/_overview.mjs +0 -293
  261. package/api/theme-edit/_palette.d.mts +0 -616
  262. package/api/theme-edit/_palette.mjs +0 -2776
  263. package/api/theme-edit/_part-pieces.d.mts +0 -54
  264. package/api/theme-edit/_part-pieces.mjs +0 -179
  265. package/api/theme-edit/_part-words.d.mts +0 -39
  266. package/api/theme-edit/_part-words.mjs +0 -242
  267. package/api/theme-edit/_parts.d.mts +0 -402
  268. package/api/theme-edit/_parts.mjs +0 -2294
  269. package/api/theme-edit/_picture-traits.d.mts +0 -259
  270. package/api/theme-edit/_picture-traits.mjs +0 -1030
  271. package/api/theme-edit/_png.d.mts +0 -94
  272. package/api/theme-edit/_png.mjs +0 -479
  273. package/api/theme-edit/_preview-app.d.mts +0 -172
  274. package/api/theme-edit/_preview-app.mjs +0 -6430
  275. package/api/theme-edit/_preview.d.mts +0 -549
  276. package/api/theme-edit/_preview.mjs +0 -3264
  277. package/api/theme-edit/_project.d.mts +0 -207
  278. package/api/theme-edit/_project.mjs +0 -643
  279. package/api/theme-edit/_resolved.d.mts +0 -46
  280. package/api/theme-edit/_resolved.mjs +0 -800
  281. package/api/theme-edit/_set-line.d.mts +0 -29
  282. package/api/theme-edit/_set-line.mjs +0 -100
  283. package/api/theme-edit/_settings.d.mts +0 -2426
  284. package/api/theme-edit/_settings.mjs +0 -18435
  285. package/api/theme-edit/_tables.d.mts +0 -227
  286. package/api/theme-edit/_tables.mjs +0 -1128
  287. package/api/theme-edit/_text-looks.d.mts +0 -78
  288. package/api/theme-edit/_text-looks.mjs +0 -376
  289. package/api/theme-edit/_vet.d.mts +0 -50
  290. package/api/theme-edit/_vet.mjs +0 -166
  291. package/api/theme-edit/how/how.d.mts +0 -17
  292. package/api/theme-edit/how/how.mjs +0 -28
  293. package/api/theme-edit/new/new.d.mts +0 -11
  294. package/api/theme-edit/new/new.mjs +0 -22
  295. package/api/theme-edit/preview-add/preview-add.d.mts +0 -14
  296. package/api/theme-edit/preview-add/preview-add.mjs +0 -25
  297. package/api/theme-edit/preview-app/preview-app.d.mts +0 -13
  298. package/api/theme-edit/preview-app/preview-app.mjs +0 -24
  299. package/api/theme-edit/preview-list/preview-list.d.mts +0 -10
  300. package/api/theme-edit/preview-list/preview-list.mjs +0 -21
  301. package/api/theme-edit/preview-remove/preview-remove.d.mts +0 -12
  302. package/api/theme-edit/preview-remove/preview-remove.mjs +0 -23
  303. package/api/theme-edit/set/set.d.mts +0 -13
  304. package/api/theme-edit/set/set.mjs +0 -24
  305. package/api/theme-edit/show/show.d.mts +0 -13
  306. package/api/theme-edit/show/show.mjs +0 -24
  307. package/api/theme-edit/theme-edit.d.mts +0 -12
  308. package/api/theme-edit/theme-edit.mjs +0 -36
  309. package/api/theme-edit/theme-edit.type.d.mts +0 -730
  310. package/api/theme-edit/theme-edit.type.mjs +0 -342
  311. package/api/theme-edit/themeEditHow.doc.d.mts +0 -6
  312. package/api/theme-edit/themeEditHow.doc.mjs +0 -105
  313. package/api/theme-edit/themeEditNew.doc.d.mts +0 -5
  314. package/api/theme-edit/themeEditNew.doc.mjs +0 -112
  315. package/api/theme-edit/themeEditPreviewAdd.doc.d.mts +0 -6
  316. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +0 -121
  317. package/api/theme-edit/themeEditPreviewApp.doc.d.mts +0 -6
  318. package/api/theme-edit/themeEditPreviewApp.doc.mjs +0 -87
  319. package/api/theme-edit/themeEditPreviewList.doc.d.mts +0 -6
  320. package/api/theme-edit/themeEditPreviewList.doc.mjs +0 -62
  321. package/api/theme-edit/themeEditPreviewRemove.doc.d.mts +0 -6
  322. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +0 -96
  323. package/api/theme-edit/themeEditSet.doc.d.mts +0 -6
  324. package/api/theme-edit/themeEditSet.doc.mjs +0 -175
  325. package/api/theme-edit/themeEditShow.doc.d.mts +0 -6
  326. package/api/theme-edit/themeEditShow.doc.mjs +0 -118
  327. package/api/theme-edit/themeEditUndo.doc.d.mts +0 -6
  328. package/api/theme-edit/themeEditUndo.doc.mjs +0 -133
  329. package/api/theme-edit/undo/undo.d.mts +0 -13
  330. package/api/theme-edit/undo/undo.mjs +0 -24
  331. package/assets/preview-app/README.md +0 -6
  332. package/assets/preview-app/css.d.ts +0 -5
  333. package/assets/preview-app/gitignore +0 -4
  334. package/assets/preview-app/next.config.mjs +0 -12
  335. package/assets/preview-app/package.json +0 -24
  336. package/assets/preview-app/src/app/globals.css +0 -6
  337. package/assets/preview-app/src/app/layout.tsx +0 -21
  338. package/assets/preview-app/src/app/page.tsx +0 -94
  339. package/assets/preview-app/src/app/providers.tsx +0 -16
  340. package/assets/preview-app/tsconfig.json +0 -27
  341. package/clients/cli/commands/experimental/theme.mjs +0 -2990
  342. package/clients/cli/commands/experimental-theme-add.doc.mjs +0 -80
  343. package/clients/cli/commands/experimental-theme-compile.doc.mjs +0 -98
  344. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +0 -196
  345. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -174
  346. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +0 -139
  347. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +0 -77
  348. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +0 -105
  349. package/clients/cli/commands/experimental-theme-editor.doc.mjs +0 -49
  350. package/clients/cli/commands/experimental-theme-eject.doc.mjs +0 -72
  351. package/clients/cli/commands/experimental-theme-list.doc.mjs +0 -49
  352. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +0 -88
  353. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +0 -61
  354. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +0 -48
  355. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +0 -59
  356. package/clients/cli/commands/experimental-theme-preview.doc.mjs +0 -41
  357. package/clients/cli/commands/experimental-theme-remove.doc.mjs +0 -57
  358. package/clients/cli/commands/experimental-theme-targets.doc.mjs +0 -62
  359. package/clients/cli/commands/experimental-theme-template.doc.mjs +0 -63
  360. package/clients/cli/commands/experimental-theme-use.doc.mjs +0 -57
  361. package/clients/cli/commands/experimental-theme.doc.mjs +0 -60
  362. package/foundation/fonts/fontsource-families.generated.d.mts +0 -5
  363. package/foundation/fonts/fontsource-families.generated.mjs +0 -2110
@@ -17,8 +17,9 @@ export function installedPackageOf(file: string): string | null;
17
17
  */
18
18
  /**
19
19
  * Lookups that one set of hooks keeps: each folder's package.json, read once,
20
- * and the folders of the linked packages bare imports reached.
21
- * @typedef {{manifests: Map<string, FolderManifest>, linked: Set<string>}} PackageLookups
20
+ * the folders of the linked packages bare imports reached, and the answers to
21
+ * package names and `#` imports, by folderKey.
22
+ * @typedef {{manifests: Map<string, FolderManifest>, linked: Set<string>, byFolder: Map<string, object>}} PackageLookups
22
23
  */
23
24
  /** @returns {PackageLookups} */
24
25
  export function packageLookups(): PackageLookups;
@@ -31,6 +32,18 @@ export function packageLookups(): PackageLookups;
31
32
  * @returns {string | null}
32
33
  */
33
34
  export function linkedPackageOf(file: string, lookups: PackageLookups): string | null;
35
+ /**
36
+ * Notes `folder` as the folder of the linked package `name`: a folder
37
+ * outside node_modules whose package.json names `name`, as the real folder
38
+ * of a link `node_modules/<name>` is, or the folder a bare import of `name`
39
+ * reached (see noteLinkedPackage). A folder `skip` refuses is not noted.
40
+ * @param {string} name
41
+ * @param {string} folder
42
+ * @param {PackageLookups} lookups
43
+ * @param {(folder: string) => boolean} skip - takes the folder with a
44
+ * trailing separator
45
+ */
46
+ export function noteLinkedFolder(name: string, folder: string, lookups: PackageLookups, skip: (folder: string) => boolean): void;
34
47
  /**
35
48
  * The URL of the ES module that `specifier` names from `parent`, when both
36
49
  * are files of one installed package and Node would load it as an ES module;
@@ -47,7 +60,10 @@ export function linkedPackageOf(file: string, lookups: PackageLookups): string |
47
60
  export function packageModuleUrl(specifier: string, parent: string | undefined, lookups: PackageLookups): string | null;
48
61
  /**
49
62
  * Module hooks that resolve imports between the files of an installed or a
50
- * linked package by path.
63
+ * linked package by path, and each package name or `#` import that ES
64
+ * modules import once for each folder it is imported from. What the next resolvers answered there
65
+ * (single-copy-hooks.mjs among them, which decides by the name) is the
66
+ * answer kept.
51
67
  * @param {PackageLookups} [lookups]
52
68
  * @param {{skip?: (folder: string) => boolean}} [options] - `skip`: a folder
53
69
  * never taken as a linked package's (the page's own folders)
@@ -57,11 +73,13 @@ export function packageResolveHooks(lookups?: PackageLookups, { skip }?: {
57
73
  }): {
58
74
  /**
59
75
  * @param {string} specifier
60
- * @param {{parentURL?: string}} context
76
+ * @param {{parentURL?: string, conditions?: readonly string[], importAttributes?: object}} context
61
77
  * @param {(specifier: string, context: any) => any} nextResolve
62
78
  */
63
79
  resolve(specifier: string, context: {
64
80
  parentURL?: string;
81
+ conditions?: readonly string[];
82
+ importAttributes?: object;
65
83
  }, nextResolve: (specifier: string, context: any) => any): any;
66
84
  };
67
85
  /**
@@ -75,9 +93,11 @@ export type FolderManifest = {
75
93
  } | null | undefined;
76
94
  /**
77
95
  * Lookups that one set of hooks keeps: each folder's package.json, read once,
78
- * and the folders of the linked packages bare imports reached.
96
+ * the folders of the linked packages bare imports reached, and the answers to
97
+ * package names and `#` imports, by folderKey.
79
98
  */
80
99
  export type PackageLookups = {
81
100
  manifests: Map<string, FolderManifest>;
82
101
  linked: Set<string>;
102
+ byFolder: Map<string, object>;
83
103
  };
@@ -8,13 +8,18 @@
8
8
  * @output Module hooks whose resolve step answers a relative, fully
9
9
  * specified ES module import between two files of one installed package,
10
10
  * or of one linked package (one a bare import reached outside
11
- * node_modules), with the file's URL; every other import goes on to the
12
- * next resolver, and its answer is returned as it is.
11
+ * node_modules), with the file's URL, and a package name or a `#` import
12
+ * that an ES module imports from a folder it was already resolved from,
13
+ * with the answer it got there; every other import goes on to the next
14
+ * resolver, and its answer is returned as it is.
13
15
  * @position foundation/render. Node reads the nearest package.json of each
14
16
  * module it resolves and loads, and it reads a package's whole manifest
15
17
  * again for each module, so a package of hundreds of modules (Core) reads
16
18
  * its exports map hundreds of times. The hook reads the package.json of
17
- * each folder at most once. Page files never reach it.
19
+ * each folder at most once. Node also resolves a package name again for
20
+ * each module that imports it (each Core module imports React and
21
+ * StyleX); the hook resolves it once for each folder. Page files never
22
+ * reach it.
18
23
  */
19
24
 
20
25
  import * as fs from 'node:fs';
@@ -52,13 +57,14 @@ export function installedPackageOf(file) {
52
57
 
53
58
  /**
54
59
  * Lookups that one set of hooks keeps: each folder's package.json, read once,
55
- * and the folders of the linked packages bare imports reached.
56
- * @typedef {{manifests: Map<string, FolderManifest>, linked: Set<string>}} PackageLookups
60
+ * the folders of the linked packages bare imports reached, and the answers to
61
+ * package names and `#` imports, by folderKey.
62
+ * @typedef {{manifests: Map<string, FolderManifest>, linked: Set<string>, byFolder: Map<string, object>}} PackageLookups
57
63
  */
58
64
 
59
65
  /** @returns {PackageLookups} */
60
66
  export function packageLookups() {
61
- return {manifests: new Map(), linked: new Set()};
67
+ return {manifests: new Map(), linked: new Set(), byFolder: new Map()};
62
68
  }
63
69
 
64
70
  /**
@@ -137,18 +143,67 @@ function noteLinkedPackage(specifier, url, lookups, skip) {
137
143
  const file = fileURLToPath(url);
138
144
  if (file.includes(NODE_MODULES)) return;
139
145
  const found = nearestManifest(path.dirname(file), lookups);
140
- if (
141
- found &&
142
- found.name === packageOf(specifier) &&
143
- !skip(found.dir + path.sep)
144
- )
145
- lookups.linked.add(found.dir);
146
+ if (found) noteLinkedFolder(packageOf(specifier), found.dir, lookups, skip);
147
+ }
148
+
149
+ /**
150
+ * Notes `folder` as the folder of the linked package `name`: a folder
151
+ * outside node_modules whose package.json names `name`, as the real folder
152
+ * of a link `node_modules/<name>` is, or the folder a bare import of `name`
153
+ * reached (see noteLinkedPackage). A folder `skip` refuses is not noted.
154
+ * @param {string} name
155
+ * @param {string} folder
156
+ * @param {PackageLookups} lookups
157
+ * @param {(folder: string) => boolean} skip - takes the folder with a
158
+ * trailing separator
159
+ */
160
+ export function noteLinkedFolder(name, folder, lookups, skip) {
161
+ if ((folder + path.sep).includes(NODE_MODULES)) return;
162
+ if (manifestAt(folder, lookups)?.name === name && !skip(folder + path.sep))
163
+ lookups.linked.add(folder);
146
164
  }
147
165
 
148
166
  /** Whether a specifier names a package (not a path, a URL or an import map entry). @param {string} specifier */
149
167
  const isBare = specifier =>
150
168
  !/^[./#]/.test(specifier) && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);
151
169
 
170
+ /**
171
+ * The key of an import whose answer is the same from every file of one
172
+ * folder: a package name or a `#` import that an ES module imports from a
173
+ * file. Node finds a package name in the node_modules folders above the
174
+ * importing file's folder, a self-reference by the package scope of that
175
+ * folder, and a `#` import in that scope's `imports`; the folder fixes all
176
+ * three, so its conditions, in order, and its import attributes are all else
177
+ * that decides the answer. Import attributes with the same entries in
178
+ * another order give another key: that costs a second resolution, never a
179
+ * wrong answer. Null for any other import, and for every CommonJS
180
+ * resolution: `require.resolve` with its `paths` option reaches the hook
181
+ * without them, so the folder does not fix its answer.
182
+ * @param {string} specifier
183
+ * @param {{parentURL?: string, conditions?: readonly string[], importAttributes?: object}} context
184
+ * @returns {string | null}
185
+ */
186
+ function folderKey(specifier, context) {
187
+ const parent = context.parentURL;
188
+ if (parent === undefined || !parent.startsWith('file:')) return null;
189
+ if (!isBare(specifier) && !specifier.startsWith('#')) return null;
190
+ if (context.conditions?.includes('require')) return null;
191
+ return JSON.stringify([
192
+ path.dirname(fileURLToPath(parent)),
193
+ specifier,
194
+ context.conditions ?? [],
195
+ context.importAttributes ?? {},
196
+ ]);
197
+ }
198
+
199
+ /**
200
+ * Whether an answer is kept for its folder: one that names a file or a
201
+ * built-in module. A resolution that throws is never kept.
202
+ * @param {any} resolved
203
+ */
204
+ const keptForFolder = resolved =>
205
+ typeof resolved?.url === 'string' && /^(?:file|node):/.test(resolved.url);
206
+
152
207
  /**
153
208
  * The `type` of the package.json nearest `dir`, searched up to `root`
154
209
  * included: a string, null when the folders hold none, or undefined when one
@@ -209,7 +264,10 @@ export function packageModuleUrl(specifier, parent, lookups) {
209
264
 
210
265
  /**
211
266
  * Module hooks that resolve imports between the files of an installed or a
212
- * linked package by path.
267
+ * linked package by path, and each package name or `#` import that ES
268
+ * modules import once for each folder it is imported from. What the next resolvers answered there
269
+ * (single-copy-hooks.mjs among them, which decides by the name) is the
270
+ * answer kept.
213
271
  * @param {PackageLookups} [lookups]
214
272
  * @param {{skip?: (folder: string) => boolean}} [options] - `skip`: a folder
215
273
  * never taken as a linked package's (the page's own folders)
@@ -221,15 +279,20 @@ export function packageResolveHooks(
221
279
  return {
222
280
  /**
223
281
  * @param {string} specifier
224
- * @param {{parentURL?: string}} context
282
+ * @param {{parentURL?: string, conditions?: readonly string[], importAttributes?: object}} context
225
283
  * @param {(specifier: string, context: any) => any} nextResolve
226
284
  */
227
285
  resolve(specifier, context, nextResolve) {
228
286
  const url = packageModuleUrl(specifier, context.parentURL, lookups);
229
287
  if (url !== null) return {url, format: 'module', shortCircuit: true};
288
+ const key = folderKey(specifier, context);
289
+ const kept = key === null ? undefined : lookups.byFolder.get(key);
290
+ if (kept !== undefined) return {...kept, shortCircuit: true};
230
291
  const resolved = nextResolve(specifier, context);
231
292
  if (isBare(specifier))
232
293
  noteLinkedPackage(specifier, resolved?.url, lookups, skip);
294
+ if (key !== null && keptForFolder(resolved))
295
+ lookups.byFolder.set(key, {...resolved});
233
296
  return resolved;
234
297
  },
235
298
  };
@@ -49,7 +49,7 @@ import {assetDataUri, isAssetPath} from './assets.mjs';
49
49
  import {NOT_AN_IMAGE, showsImage} from './image-attributes.mjs';
50
50
  import {parseSrcset} from './srcset.mjs';
51
51
  import {SINGLE_COPY, isServedPackage, packageOf, resolveServed, servedImportTarget} from './served-packages.mjs';
52
- import {packageResolveHooks} from './package-resolve-hooks.mjs';
52
+ import {noteLinkedFolder, packageLookups, packageResolveHooks} from './package-resolve-hooks.mjs';
53
53
  import {findNodeModulesPackage} from '../fs/paths.mjs';
54
54
  import {importSpecifiers, moduleImports} from './embedded-imports.mjs';
55
55
  import {sha256} from './source-block.mjs';
@@ -323,6 +323,20 @@ const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
323
323
  const isLocal = file =>
324
324
  !file.includes(NODE_MODULES) && (file === entry || file.startsWith(SCOPE_PREFIX));
325
325
 
326
+ /**
327
+ * A folder the page's own modules live in, or one that holds the page: never
328
+ * the folder of another package. @param {string} folder with a trailing separator
329
+ */
330
+ const pageFolder = folder => isLocal(folder) || entry.startsWith(folder);
331
+
332
+ /**
333
+ * What the package resolve hook keeps (see package-resolve-hooks.mjs). The
334
+ * linked packages are noted as linkedPackageRoots reads the links, so imports
335
+ * inside a linked package resolve by path even when its first file is
336
+ * imported by its path, not by the package's name.
337
+ */
338
+ const PACKAGE_LOOKUPS = packageLookups();
339
+
326
340
  /**
327
341
  * The real folders of the packages that a `node_modules` folder links to
328
342
  * inside the folder whose modules the page carries (`npm link`, a `file:`
@@ -344,8 +358,8 @@ function linkedPackageRoots() {
344
358
  const scanned = new Set();
345
359
  /** @type {string[]} */
346
360
  const found = [];
347
- /** @param {string} link */
348
- const addIfLinkedIn = link => {
361
+ /** @param {string} link @param {string} name the package the link is named for */
362
+ const addIfLinkedIn = (link, name) => {
349
363
  let real;
350
364
  try {
351
365
  if (!fs.lstatSync(link).isSymbolicLink()) return;
@@ -353,6 +367,7 @@ function linkedPackageRoots() {
353
367
  } catch {
354
368
  return;
355
369
  }
370
+ noteLinkedFolder(name, real, PACKAGE_LOOKUPS, pageFolder);
356
371
  const folder = real + path.sep;
357
372
  if (isLocal(folder) && !entry.startsWith(folder) && !roots.has(folder)) {
358
373
  roots.add(folder);
@@ -375,11 +390,11 @@ function linkedPackageRoots() {
375
390
  for (const name of names) {
376
391
  const link = path.join(modules, name);
377
392
  if (!name.startsWith('@')) {
378
- addIfLinkedIn(link);
393
+ addIfLinkedIn(link, name);
379
394
  continue;
380
395
  }
381
396
  try {
382
- for (const scoped of fs.readdirSync(link)) addIfLinkedIn(path.join(link, scoped));
397
+ for (const scoped of fs.readdirSync(link)) addIfLinkedIn(path.join(link, scoped), `${name}/${scoped}`);
383
398
  } catch {
384
399
  // A scope that cannot be read holds no package that Node can load.
385
400
  }
@@ -1646,17 +1661,14 @@ if (servedParent && Object.keys(SINGLE_COPY_ALIASES).length > 0) {
1646
1661
  }
1647
1662
  // Imports between the files of an installed or a linked package resolve by
1648
1663
  // path (a Node without in-thread hooks resolves them itself). The hook
1649
- // answers only relative imports inside a package, and single-copy-hooks.mjs
1650
- // answers only package names, so neither changes what the other resolves.
1664
+ // answers relative imports inside a package, and a package name only with
1665
+ // the answer the next resolvers, single-copy-hooks.mjs among them, gave from
1666
+ // the same folder, so it never changes what single-copy-hooks.mjs resolves.
1651
1667
  // The page's own folders, and a folder that holds the page, are never a
1652
1668
  // linked package's: the page's modules compile as its own.
1653
1669
  const registerHooks = /** @type {any} */ (Module).registerHooks;
1654
1670
  if (typeof registerHooks === 'function')
1655
- registerHooks(
1656
- packageResolveHooks(undefined, {
1657
- skip: folder => isLocal(folder) || entry.startsWith(folder),
1658
- }),
1659
- );
1671
+ registerHooks(packageResolveHooks(PACKAGE_LOOKUPS, {skip: pageFolder}));
1660
1672
 
1661
1673
  /** What the StyleX compiler reads as a theme or constants file, by name. */
1662
1674
  const STYLEX_THEME_FILE = /\.(?:stylex(?:\.const)?|transformed)(?:\.(?:js|ts|tsx|jsx|mjs|cjs))?$/;
@@ -19,9 +19,8 @@ export function partBoxes(parts: string[]): Record<string, Array<[number, number
19
19
  * `PART_BOXES_PREFIX`, the line prefix a picture script prints it after.
20
20
  * @position run by picture-chrome.mjs and picture-playwright.mjs for a job
21
21
  * that names parts to measure, once the page is drawn as the picture shows
22
- * it; read back by `screenshots` in api/theme-edit/_preview.mjs from the
23
- * script's stdout. The theme editor compares two pictures' boxes to name
24
- * what a change of size moves on the page.
22
+ * it; read back by `takePictures` in foundation/pictures/pictures.mjs from
23
+ * the script's stdout.
25
24
  */
26
25
  /** The line prefix a picture script prints the measurement after. */
27
26
  export const PART_BOXES_PREFIX: "astryx-part-boxes:";
@@ -9,9 +9,8 @@
9
9
  * `PART_BOXES_PREFIX`, the line prefix a picture script prints it after.
10
10
  * @position run by picture-chrome.mjs and picture-playwright.mjs for a job
11
11
  * that names parts to measure, once the page is drawn as the picture shows
12
- * it; read back by `screenshots` in api/theme-edit/_preview.mjs from the
13
- * script's stdout. The theme editor compares two pictures' boxes to name
14
- * what a change of size moves on the page.
12
+ * it; read back by `takePictures` in foundation/pictures/pictures.mjs from
13
+ * the script's stdout.
15
14
  */
16
15
 
17
16
  /* global document, getComputedStyle -- partBoxes runs in the page */
@@ -5,15 +5,15 @@
5
5
  * Chromium, driven over the DevTools protocol on a pipe, run as its own
6
6
  * process by the editor's browser runner.
7
7
  * @input argv: the browser, and the batch (JSON: each job's page .html,
8
- * picture .png and color mode)
8
+ * picture .png, color mode and, optionally, its window: a phone's)
9
9
  * @output each whole page, every pixel of its height, at its path, and on
10
10
  * stdout, each line led by its job's place and a tab: the fonts it drew
11
11
  * its text in (font-probe.mjs), the text it draws cut short
12
12
  * (cut-short.mjs), and PICTURE_TAKEN once it is whole; on failure, the
13
13
  * browser's reason on stderr and exit code 1
14
- * @position run by `screenshot` in api/theme-edit/_preview.mjs through
15
- * `runBrowser`, which gives it a temp folder of its own (the browser's
16
- * profile goes there), its time bound and its stop
14
+ * @position run by `takePictures` in foundation/pictures/pictures.mjs
15
+ * through `runBrowser`, which gives it a temp folder of its own (the
16
+ * browser's profile goes there), its time bound and its stop
17
17
  */
18
18
 
19
19
  import {spawn} from 'node:child_process';
@@ -31,6 +31,7 @@ import {
31
31
  PICTURE_PAGES_AT_ONCE,
32
32
  PICTURE_TAKEN,
33
33
  PICTURE_WINDOW,
34
+ windowCommands,
34
35
  SETTLE_ANIMATIONS,
35
36
  AWAIT_QUIET,
36
37
  eachAtOnce,
@@ -38,7 +39,7 @@ import {
38
39
  import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
39
40
 
40
41
  const [chrome, batch] = process.argv.slice(2);
41
- /** @type {Array<{html: string, png: string, mode: string, boxes?: string[]}>} */
42
+ /** @type {Array<{html: string, png: string, mode: string, boxes?: string[], window?: {width: number, height: number, mobile?: boolean}}>} */
42
43
  const jobs = JSON.parse(batch);
43
44
  /** A line for one job of the batch. @param {number} i @param {string} line */
44
45
  const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
@@ -51,6 +52,11 @@ const browser = spawn(
51
52
  '--no-sandbox',
52
53
  '--hide-scrollbars',
53
54
  '--remote-debugging-pipe',
55
+ // The throwaway profile stores no secret. Without these flags, each
56
+ // browser start asks the system keychain (macOS) or password store
57
+ // (Linux) for access, and the person sees a dialog.
58
+ '--use-mock-keychain',
59
+ '--password-store=basic',
54
60
  // The browser's own network off: a picture asks the network for nothing.
55
61
  ...QUIET_BROWSER_ARGS,
56
62
  `--user-data-dir=${path.join(os.tmpdir(), 'profile')}`,
@@ -158,11 +164,11 @@ function event(method, sessionId) {
158
164
 
159
165
  /**
160
166
  * One page of the batch in a tab of its own: drawn, pictured whole, and
161
- * measured.
162
- * @param {{html: string, png: string, mode: string, boxes?: string[]}} job
167
+ * measured. A job's `window` (a phone's) replaces the editor's window.
168
+ * @param {{html: string, png: string, mode: string, boxes?: string[], window?: {width: number, height: number, mobile?: boolean}}} job
163
169
  * @param {number} i
164
170
  */
165
- async function picture({html, png, mode, boxes}, i) {
171
+ async function picture({html, png, mode, boxes, window: view}, i) {
166
172
  // Each page in a window of its own: a page in a background tab runs
167
173
  // no animation frames, so a chart drawn over frames never finishes.
168
174
  const {targetId} = await send('Target.createTarget', {url: 'about:blank', newWindow: true});
@@ -175,11 +181,7 @@ async function picture({html, png, mode, boxes}, i) {
175
181
  // fails at once instead of holding the load on a network.
176
182
  await send('Network.enable', {}, sessionId);
177
183
  await send('Network.setBlockedURLs', {urls: NETWORK_URL_PATTERNS}, sessionId);
178
- await send(
179
- 'Emulation.setDeviceMetricsOverride',
180
- {...PICTURE_WINDOW, deviceScaleFactor: 1, mobile: false},
181
- sessionId,
182
- );
184
+ for (const [method, params] of windowCommands(view)) await send(method, params, sessionId);
183
185
  await send(
184
186
  'Emulation.setEmulatedMedia',
185
187
  {
@@ -222,8 +224,9 @@ async function picture({html, png, mode, boxes}, i) {
222
224
  x: 0,
223
225
  y: 0,
224
226
  // The whole page: a part wider than the window (the page lays it out
225
- // past the window's edge) is pictured whole, never cut at it.
226
- width: Math.max(PICTURE_WINDOW.width, Math.ceil(size.width)),
227
+ // past the window's edge) is pictured whole, never cut at it; a job's
228
+ // own window (a phone's) is the narrowest it is.
229
+ width: Math.max((view ?? PICTURE_WINDOW).width, Math.ceil(size.width)),
227
230
  height: Math.max(1, Math.ceil(size.height)),
228
231
  scale: 1,
229
232
  },
@@ -5,14 +5,15 @@
5
5
  * one browser for all, run as its own process by the editor's browser
6
6
  * runner.
7
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
8
+ * .html, picture .png, color mode and, optionally, its window: a
9
+ * phone's), and a browser to use instead of Playwright's own
10
10
  * @output each picture at its path, and on stdout, each line led by its
11
11
  * job's place and a tab: the fonts it drew its text in (font-probe.mjs),
12
12
  * the text it draws cut short (cut-short.mjs), and PICTURE_TAKEN once it
13
13
  * is whole; on failure, Playwright's error on stderr and exit code 1
14
- * @position run by `screenshot` in api/theme-edit/_preview.mjs through
15
- * `runBrowser`, which gives it a temp folder of its own, its time bound and its stop
14
+ * @position run by `takePictures` in foundation/pictures/pictures.mjs
15
+ * through `runBrowser`, which gives it a temp folder of its own, its time
16
+ * bound and its stop
16
17
  */
17
18
 
18
19
  import {pathToFileURL} from 'node:url';
@@ -33,7 +34,7 @@ import {
33
34
  import {FONT_PROBE_PREFIX, probeFonts} from './font-probe.mjs';
34
35
 
35
36
  const [entry, batch, executablePath] = process.argv.slice(2);
36
- /** @type {Array<{html: string, png: string, mode: string, boxes?: string[]}>} */
37
+ /** @type {Array<{html: string, png: string, mode: string, boxes?: string[], window?: {width: number, height: number, mobile?: boolean}}>} */
37
38
  const jobs = JSON.parse(batch);
38
39
  /** A line for one job of the batch. @param {number} i @param {string} line */
39
40
  const say = (i, line) => process.stdout.write(`${i}\t${line}\n`);
@@ -50,9 +51,11 @@ try {
50
51
  await eachAtOnce(
51
52
  jobs,
52
53
  PICTURE_PAGES_AT_ONCE,
53
- async ({html, png, mode, boxes}, i) => {
54
+ async ({html, png, mode, boxes, window: view}, i) => {
55
+ // A job's `window` (a phone's) replaces the editor's window.
54
56
  const page = await browser.newPage({
55
- viewport: {...PICTURE_WINDOW},
57
+ viewport: {width: (view ?? PICTURE_WINDOW).width, height: (view ?? PICTURE_WINDOW).height},
58
+ ...(view?.mobile ? {isMobile: true, hasTouch: true} : {}),
56
59
  colorScheme: mode === 'dark' ? 'dark' : 'light',
57
60
  });
58
61
  // The page loads its own files only: a remote stylesheet, font or
@@ -11,6 +11,19 @@
11
11
  * @param {(job: T, i: number) => Promise<void>} run
12
12
  */
13
13
  export function eachAtOnce<T>(jobs: T[], atOnce: number, run: (job: T, i: number) => Promise<void>): Promise<void>;
14
+ /**
15
+ * The DevTools commands that size a Chrome page for a picture: the editor's
16
+ * window, or a job's own window. A phone's window also gets touch, as
17
+ * Playwright's phone does, so a page laid out for touch (`pointer: coarse`)
18
+ * is pictured as a phone shows it.
19
+ * @param {{width: number, height: number, mobile?: boolean}} [view]
20
+ * @returns {Array<[string, Record<string, unknown>]>}
21
+ */
22
+ export function windowCommands(view?: {
23
+ width: number;
24
+ height: number;
25
+ mobile?: boolean;
26
+ }): Array<[string, Record<string, unknown>]>;
14
27
  /**
15
28
  * Whether a media query matches in the window a picture is taken in
16
29
  * (PICTURE_WINDOW, a desktop's, with a mouse): one query of the list must
@@ -190,6 +190,37 @@ export const PLACE_LAYERS = `(() => {
190
190
 
191
191
  export const PICTURE_WINDOW = Object.freeze({width: 1280, height: 900});
192
192
 
193
+ /**
194
+ * The DevTools commands that size a Chrome page for a picture: the editor's
195
+ * window, or a job's own window. A phone's window also gets touch, as
196
+ * Playwright's phone does, so a page laid out for touch (`pointer: coarse`)
197
+ * is pictured as a phone shows it.
198
+ * @param {{width: number, height: number, mobile?: boolean}} [view]
199
+ * @returns {Array<[string, Record<string, unknown>]>}
200
+ */
201
+ export function windowCommands(view) {
202
+ const frame = view ?? PICTURE_WINDOW;
203
+ return [
204
+ [
205
+ 'Emulation.setDeviceMetricsOverride',
206
+ {
207
+ width: frame.width,
208
+ height: frame.height,
209
+ deviceScaleFactor: 1,
210
+ mobile: Boolean(view?.mobile),
211
+ },
212
+ ],
213
+ ...(view?.mobile
214
+ ? [
215
+ /** @type {[string, Record<string, unknown>]} */ ([
216
+ 'Emulation.setTouchEmulationEnabled',
217
+ {enabled: true, maxTouchPoints: 5},
218
+ ]),
219
+ ]
220
+ : []),
221
+ ];
222
+ }
223
+
193
224
  /** The pointer of the window a picture is taken in. */
194
225
  const DESKTOP_POINTER = Object.freeze({
195
226
  pointer: 'fine',
@@ -216,7 +216,7 @@ export function oneColorModeOf(markup: string, declared: "light" | "dark" | "bot
216
216
  * `keepClassNames` keeps every class of the first paint as written,
217
217
  * for a caller that styles the markup with its own copy of the styles.
218
218
  * `markupOnly` renders the markup and its styles without the script, for a
219
- * caller that shows the markup itself (the theme editor); it writes no file
219
+ * caller that shows the markup itself; it writes no file
220
220
  * and reaches no network. The render fetches each https image the page
221
221
  * names, once, so the file carries it (remote-images.mjs; `remoteImages`:
222
222
  * the fetch and its time limits, for tests).
@@ -1321,8 +1321,7 @@ function inlineAssets(text, kind, ctx) {
1321
1321
  }
1322
1322
  const found = named.file;
1323
1323
  // A stylesheet's file too large to carry, where the caller names such
1324
- // files itself (the theme editor's own pages): left as it is, as a
1325
- // missing one is.
1324
+ // files itself: left as it is, as a missing one is.
1326
1325
  if (
1327
1326
  kind === 'css' &&
1328
1327
  ctx.leaveLargeStyleAssets &&
@@ -2012,7 +2011,7 @@ function schemeCssFor(mode) {
2012
2011
  * `keepClassNames` keeps every class of the first paint as written,
2013
2012
  * for a caller that styles the markup with its own copy of the styles.
2014
2013
  * `markupOnly` renders the markup and its styles without the script, for a
2015
- * caller that shows the markup itself (the theme editor); it writes no file
2014
+ * caller that shows the markup itself; it writes no file
2016
2015
  * and reaches no network. The render fetches each https image the page
2017
2016
  * names, once, so the file carries it (remote-images.mjs; `remoteImages`:
2018
2017
  * the fetch and its time limits, for tests).
@@ -2760,8 +2759,8 @@ export async function renderPage(entry, options = {}) {
2760
2759
  : path.basename(entry).replace(/\.[^.]+$/, ''));
2761
2760
  const generator = `<meta name="generator" content="Astryx${options.version ? ` ${escapeHtml(options.version)}` : ''}">`;
2762
2761
  const importedSheets = /** @type {{file: string, css: string}[]} */ (message.importedCss ?? []);
2763
- // The theme editor shows each mode itself, so its markup-only pages keep
2764
- // both schemes; a written file shows the theme's one mode.
2762
+ // A caller that shows each mode itself gets markup-only pages with both
2763
+ // schemes; a written file shows the theme's one mode.
2765
2764
  // The theme's stylesheet may come through the page's own CSS, by an
2766
2765
  // `@import` that the file inlines.
2767
2766
  const modeSheets = options.markupOnly
@@ -9,6 +9,8 @@ export function initialize(data: {
9
9
  names: string[];
10
10
  }): void;
11
11
  /**
12
+ * The answer depends only on the name and the importing file's folder, never
13
+ * on the file itself: package-resolve-hooks.mjs keeps it for the folder.
12
14
  * @param {string} specifier
13
15
  * @param {{parentURL?: string}} context
14
16
  * @param {(specifier: string, context?: object) => Promise<unknown>} nextResolve
@@ -27,6 +27,8 @@ export function initialize(data) {
27
27
  }
28
28
 
29
29
  /**
30
+ * The answer depends only on the name and the importing file's folder, never
31
+ * on the file itself: package-resolve-hooks.mjs keeps it for the folder.
30
32
  * @param {string} specifier
31
33
  * @param {{parentURL?: string}} context
32
34
  * @param {(specifier: string, context?: object) => Promise<unknown>} nextResolve