@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
@@ -1,78 +0,0 @@
1
- // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
- // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
-
4
- /**
5
- * A font weight written in a clause: a number from 100 to 900, or a weight
6
- * word ("semibold").
7
- * @param {{text: string}} c
8
- */
9
- export function weightIn(c: {
10
- text: string;
11
- }): string | null;
12
- /**
13
- * A draft for a run of looks read whole ("bold 13px #3b5998 text") writes
14
- * one of its looks, and the run's color is its color ask's, so a typed
15
- * color of that run is no word the draft failed to read; any other typed
16
- * color still is.
17
- * @param {{text: string, parts: Array<{on: string}>}} c the clause
18
- * @param {Array<{thing: string}>} steps this draft's steps
19
- * @param {string[]} hues the hue words a question can say
20
- * @param {string[]} literals the typed colors the draft would report
21
- */
22
- export function colorInOtherDraft(c: {
23
- text: string;
24
- parts: Array<{
25
- on: string;
26
- }>;
27
- }, steps: Array<{
28
- thing: string;
29
- }>, hues: string[], literals: string[]): boolean;
30
- /**
31
- * A run of looks said for a part's text or the top bar's links asks for
32
- * each of its looks: its color ("tabs: bold 13px #3b5998 text") and a size
33
- * said for links ("white bold 11px links"), each an ask of its own beside
34
- * the weight and size the clause reader already gives, when every ask the
35
- * clause makes is a look of that text.
36
- * @param {Array<{text: string, aspects: string[], parts: Array<{on: string}>, container?: string, placeStrict?: unknown, state?: string | null}>} clauses
37
- * @param {string[]} hues the hue words a question can say
38
- */
39
- export function addRunLooks(clauses: Array<{
40
- text: string;
41
- aspects: string[];
42
- parts: Array<{
43
- on: string;
44
- }>;
45
- container?: string;
46
- placeStrict?: unknown;
47
- state?: string | null;
48
- }>, hues: string[]): void;
49
- /**
50
- * Links said with the top bar are its nav items, never every link in the
51
- * app: in the clause after the bar's, joined by "with" ("top bar #3b5998
52
- * with white links"), or in a clause that holds the bar only as the place
53
- * of its links and asks only for the links' text ("top bar with white bold
54
- * links"), more links said after them with "and" for a mode or a state,
55
- * and a look said for them again ("and underline them on hover"). A
56
- * clause that also asks for a look of the bar, never says links, or places
57
- * its links elsewhere ("links on cards") keeps its reading.
58
- * @param {Array<{joint?: string, text: string, aspects: string[], parts: Array<{on: string}>, container?: string, within?: unknown, placeStrict?: unknown}>} clauses
59
- * @param {(text: string) => boolean} namesBar whether words name the bar,
60
- * by the part words
61
- * @param {(clause: object) => void} release drops the notes that a
62
- * clause's links could not be kept to the bar
63
- */
64
- export function barLinksAreNavItems(clauses: Array<{
65
- joint?: string;
66
- text: string;
67
- aspects: string[];
68
- parts: Array<{
69
- on: string;
70
- }>;
71
- container?: string;
72
- within?: unknown;
73
- placeStrict?: unknown;
74
- }>, namesBar: (text: string) => boolean, release: (clause: object) => void): void;
75
- /** The looks of a part's text said together, each an ask of its own. */
76
- export const TEXT_LOOKS: string[];
77
- /** The parts that are the top bar. */
78
- export const BAR_PARTS: Set<string>;
@@ -1,376 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file How a question says a text's looks: its weight, a run of looks
5
- * said together for a part's text or the top bar's links, and links said
6
- * with the top bar.
7
- * @input the question's clauses, a draft's steps, and the hue words
8
- * @output weights, the top bar's links read as its nav items, and the
9
- * text color and link size a run of looks asks for
10
- * @position api/theme-edit — read by _how-question.mjs; reads only the
11
- * weight table
12
- */
13
-
14
- import {HEADING_WEIGHTS} from './_tables.mjs';
15
-
16
- /**
17
- * A font weight written in a clause: a number from 100 to 900, or a weight
18
- * word ("semibold").
19
- * @param {{text: string}} c
20
- */
21
- export function weightIn(c) {
22
- const n = /\b([1-9]00)\b(?!\s*(px|ms|%))/.exec(c.text)?.[1];
23
- if (n) return n;
24
- // "weight 450": any weight from 1 to 1000 written beside the word.
25
- const typed =
26
- /\bweight\s*:?\s*(\d{1,4})\b(?!\s*(?:px|ms|%|rem|em))/.exec(c.text)?.[1] ??
27
- /\b(\d{1,4})\s+(?:font\s+)?weight\b/.exec(c.text)?.[1];
28
- if (typed && Number(typed) >= 1 && Number(typed) <= 1000) return typed;
29
- const w = /\b(semi-?bold|medium|regular|normal)\b/.exec(c.text)?.[1];
30
- return w
31
- ? HEADING_WEIGHTS[
32
- /** @type {keyof typeof HEADING_WEIGHTS} */ (
33
- w === 'normal' ? 'regular' : w.replace('-', '')
34
- )
35
- ]
36
- : null;
37
- }
38
-
39
- /** @type {Map<string, RegExp>} */
40
- const lookRuns = new Map();
41
-
42
- /**
43
- * Looks said together right before the text or links they style, at
44
- * least one a weight or a size, with the noun phrase ending there: "white
45
- * bold 11px links", "bold 13px #3b5998 text" (which the question reader
46
- * writes "bold 13px text #3b5998"), "#3b5998 bold 13px text". A noun after
47
- * it ("a 2px black text stroke") makes no run. A run the question reader
48
- * splits ("13px #3b5998 bold text", "italic 13px #3b5998 text") is found
49
- * in no one clause, so it reads as before. Group 1 is the noun.
50
- * @param {string[]} hues the hue words a question can say
51
- */
52
- function lookRun(hues) {
53
- const kept = lookRuns.get(hues.join('|'));
54
- if (kept) return kept;
55
- const color = `#[0-9a-f]{3,8}|white|black|gr[ae]y|${hues.join('|')}`;
56
- const ws = String.raw`bold|semi-?bold|\d+(?:\.\d+)?(?:px|rem|pt)`;
57
- const look = `(?:${color}|${ws}|uppercase|italic)`;
58
- const end = String.raw`(?=\s*(?:$|[,;.:)]|(?:and|but|then|in|on|of|for|with|to|at|inside|across|that|which|when|while)\b))`;
59
- const run = new RegExp(
60
- String.raw`(?:^|\s)(?:${look}\s+)*(?:${ws})\s+(?:${look}\s+)*(text|links?)(?:\s+#[0-9a-f]{3,8})?\b${end}`,
61
- );
62
- lookRuns.set(hues.join('|'), run);
63
- return run;
64
- }
65
-
66
- /** Parts whose text is the page's, never their own. */
67
- const PAGE_PARTS = new Set(['page', 'app-shell', 'layout-content', 'body']);
68
-
69
- /**
70
- * The run of looks a clause says for its own part's text, or for the top
71
- * bar's links: never for the page, every link, or links said with another
72
- * part, which read as before.
73
- * @param {{text: string, parts: Array<{on: string}>, container?: string, within?: unknown}} c
74
- * @param {string[]} hues
75
- */
76
- function ownRun(c, hues) {
77
- const m = lookRun(hues).exec(String(c.text ?? ''));
78
- // (A run said for one part's text but placed in another, "tabs with bold
79
- // 13px #3b5998 text on cards", reads as before.)
80
- if (!m || c.container || c.within || new Set(c.parts.map(p => p.on)).size > 1)
81
- return null;
82
- const owns = /^links?$/.test(m[1])
83
- ? c.parts.length > 0 && c.parts.every(p => p.on === 'top-nav-item')
84
- : c.parts.length > 0 &&
85
- c.parts.every(p => p.on !== 'link' && !PAGE_PARTS.has(p.on));
86
- return owns ? m[0] : null;
87
- }
88
-
89
- /**
90
- * A draft for a run of looks read whole ("bold 13px #3b5998 text") writes
91
- * one of its looks, and the run's color is its color ask's, so a typed
92
- * color of that run is no word the draft failed to read; any other typed
93
- * color still is.
94
- * @param {{text: string, parts: Array<{on: string}>}} c the clause
95
- * @param {Array<{thing: string}>} steps this draft's steps
96
- * @param {string[]} hues the hue words a question can say
97
- * @param {string[]} literals the typed colors the draft would report
98
- */
99
- export function colorInOtherDraft(c, steps, hues, literals) {
100
- const run = (ownRun(c, hues) ?? '').toLowerCase();
101
- return (
102
- RUN_READ.has(c) &&
103
- /#[0-9a-f]{3,8}\b/.test(run) &&
104
- literals.every(l => run.includes(l.toLowerCase())) &&
105
- steps.length > 0
106
- );
107
- }
108
-
109
- /** The asks of a clause whose run of looks is read whole. */
110
- const RUN_READ = new WeakSet();
111
-
112
- /** The looks of a part's text said together, each an ask of its own. */
113
- export const TEXT_LOOKS = ['case', 'weight', 'italic', 'tracking', 'fontsize'];
114
-
115
- /** The asks a run of looks can make: those looks and its color. */
116
- const RUN_ASKS = new Set(['text', ...TEXT_LOOKS]);
117
-
118
- /**
119
- * A run of looks said for a part's text or the top bar's links asks for
120
- * each of its looks: its color ("tabs: bold 13px #3b5998 text") and a size
121
- * said for links ("white bold 11px links"), each an ask of its own beside
122
- * the weight and size the clause reader already gives, when every ask the
123
- * clause makes is a look of that text.
124
- * @param {Array<{text: string, aspects: string[], parts: Array<{on: string}>, container?: string, placeStrict?: unknown, state?: string | null}>} clauses
125
- * @param {string[]} hues the hue words a question can say
126
- */
127
- export function addRunLooks(clauses, hues) {
128
- const color = new RegExp(
129
- `#[0-9a-f]{3,8}|\\b(?:white|black|gr[ae]y|${hues.join('|')})\\b`,
130
- );
131
- // (A clause is keyed by its words, its parts and its state: two parts
132
- // said with the same words, "cards with bold 13px #3b5998 text, buttons
133
- // with bold 13px #3b5998 text", are two runs. Asks the reader split from
134
- // one clause sit side by side with its words.)
135
- const id = (/** @type {(typeof clauses)[number]} */ x) =>
136
- `${x.text}\u0000${x.parts.map(p => p.on).join(',')}\u0000${x.state ?? ''}`;
137
- // (A clause the reader gives another clause's words and part says no
138
- // run of its own.)
139
- /** @type {Map<string, number>} */
140
- const first = new Map();
141
- clauses.forEach((x, k) => first.has(id(x)) || first.set(id(x), k));
142
- for (let i = clauses.length - 1; i >= 0; i--) {
143
- const c = clauses[i];
144
- // (Asks split from one clause share its words and part: read them
145
- // once.)
146
- if (
147
- clauses[i - 1]?.text === c.text ||
148
- (first.get(id(c)) ?? i) < i ||
149
- // (A run said for a state, "selected tabs with …", reads as before:
150
- // the reader can give it another clause's words.)
151
- c.state
152
- )
153
- continue;
154
- let end = i;
155
- while (clauses[end + 1]?.text === c.text) end++;
156
- const group = clauses.slice(i, end + 1);
157
- const asks = group.flatMap(x => x.aspects);
158
- // ("cards, tabs and buttons with bold 13px #3b5998 text": the reader
159
- // gives the run's color to only some parts of a list. Unless every
160
- // part said with the run's other looks has the color too, the list
161
- // reads as before.)
162
- if (/#[0-9a-f]{3,8}\b/i.test(c.text)) {
163
- const own = new Set(String(c.text).toLowerCase().split(/\s+/));
164
- const looks = (/** @type {string} */ t) =>
165
- t
166
- .toLowerCase()
167
- .split(/\s+/)
168
- .filter(w => w && !/^\d+(?:\.\d+)?(?:px|rem|pt)$/.test(w));
169
- const sameState = (/** @type {(typeof clauses)[number]} */ x) =>
170
- (x.state ?? null) === (c.state ?? null);
171
- /** @type {Set<string>} */
172
- const withLooks = new Set();
173
- /** @type {Set<string>} */
174
- const withColor = new Set();
175
- for (const x of clauses) {
176
- if (!x.text || !sameState(x)) continue;
177
- const ws = looks(String(x.text));
178
- if (!ws.every(w => own.has(w))) continue;
179
- const into = /#[0-9a-f]{3,8}\b/i.test(x.text) ? withColor : withLooks;
180
- for (const p of x.parts) into.add(p.on);
181
- }
182
- if ([...withLooks].some(on => !withColor.has(on))) continue;
183
- }
184
- const run = ownRun(c, hues);
185
- // ("top bar #3b5998 with 11px white links": the links' color stays the
186
- // bar's link color, and their size is the nav items'.)
187
- const said = lookRun(hues).exec(String(c.text ?? ''))?.[0] ?? '';
188
- if (
189
- !run &&
190
- /\blinks?\b/.test(said) &&
191
- /\d(?:px|rem|pt)\b/.test(said) &&
192
- BAR_KEPT.has(c) &&
193
- !asks.includes('fontsize') &&
194
- asks.every(a => RUN_ASKS.has(a))
195
- ) {
196
- const size = {...c, parts: [{on: 'top-nav-item'}], aspects: ['fontsize']};
197
- delete size.container;
198
- delete size.placeStrict;
199
- for (const x of [...group, size]) RUN_READ.add(x);
200
- clauses.splice(end + 1, 0, size);
201
- continue;
202
- }
203
- // (Only when every ask of the clause is a look of the run's own part's
204
- // text: otherwise the clause reads as before.)
205
- if (
206
- !run ||
207
- !group.every(x => ownRun(x, hues)) ||
208
- !asks.every(a => RUN_ASKS.has(a))
209
- )
210
- continue;
211
- /** @type {string[]} */
212
- const add = [];
213
- if (color.test(run) && !asks.includes('text')) add.push('text');
214
- if (/\blinks?\b/.test(run) && /\d(?:px|rem|pt)\b/.test(run)) {
215
- if (!asks.includes('fontsize')) add.push('fontsize');
216
- }
217
- // (The color of the bar's links is the bar's link color, placed as the
218
- // question reader places it.)
219
- const inBar = IN_BAR.get(c);
220
- const copies = add.map(a =>
221
- a === 'text' && inBar
222
- ? {...c, ...inBar, parts: [{on: 'link'}], aspects: [a]}
223
- : {...c, parts: c.parts.map(p => ({...p})), aspects: [a]},
224
- );
225
- for (const x of [...group, ...copies]) RUN_READ.add(x);
226
- clauses.splice(end + 1, 0, ...copies);
227
- }
228
- }
229
-
230
- /**
231
- * Where the question reader placed the bar's links, kept for the color
232
- * ask a run of their looks adds.
233
- * @type {WeakMap<object, {container: string, placeStrict: unknown}>}
234
- */
235
- const IN_BAR = new WeakMap();
236
-
237
- /** The bar's links whose color the question reader keeps to the bar. */
238
- const BAR_KEPT = new WeakSet();
239
-
240
- /** The parts that are the top bar. */
241
- export const BAR_PARTS = new Set(['app-shell-header', 'top-nav']);
242
-
243
- /**
244
- * Links said with the top bar are its nav items, never every link in the
245
- * app: in the clause after the bar's, joined by "with" ("top bar #3b5998
246
- * with white links"), or in a clause that holds the bar only as the place
247
- * of its links and asks only for the links' text ("top bar with white bold
248
- * links"), more links said after them with "and" for a mode or a state,
249
- * and a look said for them again ("and underline them on hover"). A
250
- * clause that also asks for a look of the bar, never says links, or places
251
- * its links elsewhere ("links on cards") keeps its reading.
252
- * @param {Array<{joint?: string, text: string, aspects: string[], parts: Array<{on: string}>, container?: string, within?: unknown, placeStrict?: unknown}>} clauses
253
- * @param {(text: string) => boolean} namesBar whether words name the bar,
254
- * by the part words
255
- * @param {(clause: object) => void} release drops the notes that a
256
- * clause's links could not be kept to the bar
257
- */
258
- export function barLinksAreNavItems(clauses, namesBar, release) {
259
- const bar = (/** @type {{on: string}} */ p) => BAR_PARTS.has(p.on);
260
- const link = (/** @type {{on: string}} */ p) => p.on === 'link';
261
- /** @type {string | null} the bar whose links were last its nav items */
262
- let held = null;
263
- // (Whether the clause before is the bar's links.)
264
- let lastBar = false;
265
- for (let k = 0; k < clauses.length;) {
266
- // (Asks split from one clause share its words and its joint: they are
267
- // read as one, and the bar is in the clause before them all.)
268
- const c = clauses[k];
269
- let end = k;
270
- while (clauses[end + 1]?.text === c.text) end++;
271
- const group = clauses.slice(k, end + 1);
272
- const before = clauses[k - 1];
273
- k = end + 1;
274
- // (Links the ask places elsewhere, "the links on cards", stay there;
275
- // links said with the bar are its nav items, and "the links in the
276
- // header" read as before.)
277
- const placed = group.find(x => x.container || x.within);
278
- const barPlaced = Boolean(
279
- placed && BAR_PARTS.has(String(placed.container)),
280
- );
281
- if (placed && !barPlaced) {
282
- lastBar = false;
283
- continue;
284
- }
285
- const inBar = barPlaced && /^[\s;]*with\s*$/.test(c.joint ?? '');
286
- const unplace = (/** @type {(typeof clauses)[number]} */ x) => {
287
- if (x.container && BAR_PARTS.has(x.container)) {
288
- delete x.container;
289
- delete x.placeStrict;
290
- release(x);
291
- }
292
- };
293
- const says = /\blinks?\b/.test(c.text);
294
- const and = /^[\s,]*and\s*$/.test(c.joint ?? '');
295
- const navBefore = lastBar;
296
- const barOf = (/** @type {typeof clauses} */ xs) =>
297
- xs.flatMap(x => x.parts).find(bar)?.on ?? null;
298
- // ("top bar navy with blue buttons": only links said with the bar are
299
- // its nav items.)
300
- const joined =
301
- says &&
302
- (inBar ||
303
- (/^[\s;]*with\s*$/.test(c.joint ?? '') &&
304
- Boolean(before && barOf([before]))));
305
- // ("… with white links in light mode and gray links in dark mode": more
306
- // links said in the bar's list for a mode or a state of their own are
307
- // its nav items too.)
308
- const more =
309
- says &&
310
- and &&
311
- navBefore &&
312
- /\b(?:(?:light|dark) mode|hover(?:ed|ing)?|selected|active|focus(?:ed)?|pressed|visited)\b/.test(
313
- c.text,
314
- ) &&
315
- group.every(x => x.parts.length && x.parts.every(p => link(p) || bar(p)));
316
- const holder =
317
- says &&
318
- Boolean(barOf(group)) &&
319
- group.some(x => x.parts.some(link)) &&
320
- !namesBar(c.text) &&
321
- group.every(x => x.aspects.every(a => RUN_ASKS.has(a)));
322
- // ("… with white links, and underline them on hover": a look said for
323
- // those links again, by "them", is the nav items' too.)
324
- const again =
325
- !says &&
326
- and &&
327
- navBefore &&
328
- /\b(?:them|they|their)\b/.test(c.text) &&
329
- group.every(x => x.parts.length && x.parts.every(p => link(p) || bar(p)));
330
- if (joined || holder || more || again) {
331
- if (!again)
332
- held =
333
- (inBar ? String(placed?.container) : null) ??
334
- (joined && before ? barOf([before]) : barOf(group)) ??
335
- held;
336
- for (const x of group) {
337
- // (The links' color said in the bar is the bar's link color, as
338
- // the question reader places it.)
339
- if (x.aspects.includes('text') && BAR_PARTS.has(String(x.container))) {
340
- BAR_KEPT.add(x);
341
- continue;
342
- }
343
- if (x.container && BAR_PARTS.has(x.container))
344
- IN_BAR.set(x, {container: x.container, placeStrict: x.placeStrict});
345
- unplace(x);
346
- if (holder || more || again) x.parts = x.parts.filter(p => !bar(p));
347
- for (const p of x.parts) if (link(p)) p.on = 'top-nav-item';
348
- }
349
- lastBar = true;
350
- continue;
351
- }
352
- lastBar = false;
353
- if (
354
- // ("top bar with white links and white text": a look said after the
355
- // links for text, or one the bar draws, is the bar's own.)
356
- !says &&
357
- and &&
358
- navBefore &&
359
- held &&
360
- // (Only a look said for text, or one the bar draws itself; "underline
361
- // them on hover" is still the links'.)
362
- !/\b(?:them|their|they|it|its)\b/.test(c.text) &&
363
- (/\btext\b/.test(c.text) ||
364
- group.every(x =>
365
- x.aspects.every(a =>
366
- ['background', 'border', 'shadow', 'corners'].includes(a),
367
- ),
368
- )) &&
369
- group.every(x => x.parts.length && x.parts.every(p => link(p) || bar(p)))
370
- )
371
- for (const x of group) {
372
- unplace(x);
373
- x.parts = [{on: held}];
374
- }
375
- }
376
- }
@@ -1,50 +0,0 @@
1
- // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
- // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
-
4
- /**
5
- * Drop each `set` suggestion of a refusal that `set` itself would refuse,
6
- * checked against the theme as it is now (a copy: nothing is changed). Any
7
- * other suggestion is kept. When every suggestion goes, the refusal points
8
- * at `set --help`.
9
- * @template T
10
- * @param {T} e the error thrown
11
- * @param {import('./_settings.mjs').Ctx | null | undefined} ctx
12
- * @param {string} slug
13
- * @param {import('./_settings.mjs').ThemeData | null | undefined} data
14
- * @returns {T}
15
- */
16
- export function vetSuggestions<T>(e: T, ctx: import("./_settings.mjs").Ctx | null | undefined, slug: string, data: import("./_settings.mjs").ThemeData | null | undefined): T;
17
- /**
18
- * Whether a line a refusal offers is a repair of the line refused, by the
19
- * one input gate: the same command and theme, no scope that was not typed
20
- * (never a stock part), and a value in place of the one typed only as an
21
- * exact reading of it.
22
- * @param {'set' | 'undo'} sub
23
- * @param {string} slug
24
- * @param {string} line the line refused
25
- * @param {string} name the line offered
26
- */
27
- export function repairGate(sub: "set" | "undo", slug: string, line: string, name: string): boolean;
28
- /**
29
- * Follow a suggested command before it is offered: `check` runs the line as
30
- * its command would (in memory, nothing written) and gives null when it
31
- * runs, else the refusal. The refusal's own repair (its first suggestion
32
- * `isRepair` takes that was not tried) replaces the line, until the line
33
- * runs or no repair is offered; `why` then names what is still refused.
34
- * Every refusal-suggested `set`, `undo`, `new` and `compile` that is a
35
- * repair of a typed command goes through here.
36
- * @param {string} line
37
- * @param {(line: string) => Promise<AstryxError | null> | AstryxError | null} check
38
- * @param {(name: string) => boolean} isRepair
39
- * @returns {Promise<{line: string, why: string | null, next?: import("../../foundation/response/base").Suggestion[]}>}
40
- * `next`: the commands the last refusal offers (an install before the line, a look at the theme)
41
- */
42
- export function followLine(line: string, check: (line: string) => Promise<AstryxError | null> | AstryxError | null, isRepair: (name: string) => boolean): Promise<{
43
- line: string;
44
- why: string | null;
45
- next?: import("../../foundation/response/base").Suggestion[];
46
- }>;
47
- import { AstryxError } from '../error.mjs';
48
- import { readSetLine } from './_set-line.mjs';
49
- import { splitCommand } from './_set-line.mjs';
50
- export { readSetLine, splitCommand };
@@ -1,166 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file The one place every `set` command a refusal suggests is checked
5
- * before it is shown: each runs through the same check `set` uses (in
6
- * memory, nothing written, nothing built), and one `set` would refuse is
7
- * dropped, so a "do this instead" never leads to a second refusal.
8
- *
9
- * @position api/theme-edit — imported by _edit.mjs
10
- */
11
-
12
- import {AstryxError} from '../error.mjs';
13
- import {checkSetting} from './_check.mjs';
14
- import {allowedLine} from './_normal.mjs';
15
- import {P} from './_tables.mjs';
16
- import {readSetLine, splitCommand} from './_set-line.mjs';
17
-
18
- export {readSetLine, splitCommand};
19
-
20
- /**
21
- * Drop each `set` suggestion of a refusal that `set` itself would refuse,
22
- * checked against the theme as it is now (a copy: nothing is changed). Any
23
- * other suggestion is kept. When every suggestion goes, the refusal points
24
- * at `set --help`.
25
- * @template T
26
- * @param {T} e the error thrown
27
- * @param {import('./_settings.mjs').Ctx | null | undefined} ctx
28
- * @param {string} slug
29
- * @param {import('./_settings.mjs').ThemeData | null | undefined} data
30
- * @returns {T}
31
- */
32
- export function vetSuggestions(e, ctx, slug, data) {
33
- if (!(e instanceof AstryxError) || !ctx || !data) return e;
34
- const list = e.suggestions ?? [];
35
- if (!list.length) return e;
36
- /** The refusal set gives a line, or null when it takes it. @param {string} name */
37
- const refusal = name => {
38
- const line = readSetLine(name, slug);
39
- if (!line) return null;
40
- try {
41
- checkSetting(
42
- ctx,
43
- slug,
44
- structuredClone(data),
45
- line.thing,
46
- line.value,
47
- // `set` reads a typed box shorthand as its sides, so the line is
48
- // checked the way it runs.
49
- {...line.flags, sides: true},
50
- false,
51
- );
52
- return null;
53
- } catch (err) {
54
- if (err instanceof AstryxError) return err;
55
- throw err;
56
- }
57
- };
58
- // A refused line is followed through each repair its refusal offers that
59
- // passes the one gate (every case fix of one line in one pass: a part
60
- // and its variant), and offered as the line that works; a line its own
61
- // refusal offers again after a step (an install) works once that step
62
- // is done.
63
- /** @type {typeof list} */
64
- const kept = [];
65
- for (const s of list) {
66
- if (!readSetLine(s.name, slug)) {
67
- kept.push(s);
68
- continue;
69
- }
70
- const tried = new Set([s.name]);
71
- let now = s.name;
72
- for (;;) {
73
- const err = refusal(now);
74
- if (!err) {
75
- if (!kept.some(k => k.name === now)) kept.push({...s, name: now});
76
- break;
77
- }
78
- if ((err.suggestions ?? []).some(x => x.name === now)) {
79
- kept.push({...s, name: now});
80
- break;
81
- }
82
- const next = (err.suggestions ?? []).find(
83
- x => !tried.has(x.name) && repairGate('set', slug, s.name, x.name),
84
- );
85
- if (!next) break;
86
- now = next.name;
87
- tried.add(now);
88
- }
89
- }
90
- if (
91
- kept.length === list.length &&
92
- kept.every((k, i) => k.name === list[i].name)
93
- )
94
- return e;
95
- e.suggestions = kept.length
96
- ? kept
97
- : [{name: `${P} set --help`, reason: 'see what set takes'}];
98
- return e;
99
- }
100
-
101
- /**
102
- * Whether a line a refusal offers is a repair of the line refused, by the
103
- * one input gate: the same command and theme, no scope that was not typed
104
- * (never a stock part), and a value in place of the one typed only as an
105
- * exact reading of it.
106
- * @param {'set' | 'undo'} sub
107
- * @param {string} slug
108
- * @param {string} line the line refused
109
- * @param {string} name the line offered
110
- */
111
- export function repairGate(sub, slug, line, name) {
112
- if (!name.startsWith(`${P} ${sub} ${slug} `)) return false;
113
- const toSet = (/** @type {string} */ l) =>
114
- sub === 'undo' ? l.replace(`${P} undo `, `${P} set `) : l;
115
- const was = readSetLine(toSet(line), slug);
116
- const next = readSetLine(toSet(name), slug);
117
- if (!was || !next) return true;
118
- const scopes = /** @type {const} */ (['on', 'when', 'state', 'mode']);
119
- if (scopes.some(k => next.flags[k] != null && was.flags[k] == null))
120
- return false;
121
- return (
122
- sub === 'undo' ||
123
- next.value === was.value ||
124
- allowedLine({offered: next.value, typed: was.value, thing: next.thing})
125
- );
126
- }
127
-
128
- /**
129
- * Follow a suggested command before it is offered: `check` runs the line as
130
- * its command would (in memory, nothing written) and gives null when it
131
- * runs, else the refusal. The refusal's own repair (its first suggestion
132
- * `isRepair` takes that was not tried) replaces the line, until the line
133
- * runs or no repair is offered; `why` then names what is still refused.
134
- * Every refusal-suggested `set`, `undo`, `new` and `compile` that is a
135
- * repair of a typed command goes through here.
136
- * @param {string} line
137
- * @param {(line: string) => Promise<AstryxError | null> | AstryxError | null} check
138
- * @param {(name: string) => boolean} isRepair
139
- * @returns {Promise<{line: string, why: string | null, next?: import("../../foundation/response/base").Suggestion[]}>}
140
- * `next`: the commands the last refusal offers (an install before the line, a look at the theme)
141
- */
142
- export async function followLine(line, check, isRepair) {
143
- const tried = new Set([line]);
144
- let now = line;
145
- for (;;) {
146
- const refused = await check(now);
147
- if (!refused) return {line: now, why: null};
148
- // A refusal that offers the line itself after another step (an
149
- // install) says the line works once that is done: no other line is
150
- // followed in its place.
151
- const again = (refused.suggestions ?? []).some(x => x.name === now);
152
- const next = again
153
- ? undefined
154
- : (refused.suggestions ?? []).find(
155
- x => isRepair(x.name) && !tried.has(x.name),
156
- );
157
- if (!next)
158
- return {
159
- line: now,
160
- why: refused.message.replace(/\s*Nothing was changed\.$/, ''),
161
- next: refused.suggestions ?? [],
162
- };
163
- now = next.name;
164
- tried.add(now);
165
- }
166
- }