@astryxdesign/cli 0.7.17 → 0.7.18-canary.g32556bb

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 (261) hide show
  1. package/README.md +1 -1
  2. package/api/discover/_adapter.d.mts +7 -5
  3. package/api/discover/_adapter.mjs +12 -11
  4. package/api/docs/_adapter.d.mts +19 -2
  5. package/api/docs/_adapter.mjs +66 -5
  6. package/api/doctor/_adapter.d.mts +11 -62
  7. package/api/doctor/_adapter.mjs +242 -472
  8. package/api/doctor/doctor.d.mts +1 -1
  9. package/api/doctor/doctor.mjs +3 -3
  10. package/api/doctor/theme-checks.mjs +37 -45
  11. package/api/error.d.mts +21 -0
  12. package/api/error.mjs +89 -0
  13. package/api/hook/list/list.d.mts +1 -1
  14. package/api/icon/_adapter.d.mts +8 -0
  15. package/api/icon/_adapter.mjs +17 -0
  16. package/api/icon/_authoring.mjs +6 -6
  17. package/api/icon/_default-look.mjs +16 -16
  18. package/api/icon/add/add.mjs +3 -3
  19. package/api/icon/exportIconIndex.doc.mjs +2 -2
  20. package/api/icon/icon.doc.mjs +2 -2
  21. package/api/icon/icon.type.d.mts +4 -0
  22. package/api/icon/icon.type.mjs +2 -1
  23. package/api/icon/search/icon-index.mjs +16 -3
  24. package/api/icon/search/search.d.mts +15 -5
  25. package/api/icon/search/search.mjs +74 -16
  26. package/api/icon/use/use.mjs +4 -4
  27. package/api/render/_adapter.mjs +233 -40
  28. package/api/render/render.type.d.mts +1 -1
  29. package/api/render/render.type.mjs +1 -1
  30. package/api/search/ORDERING.md +2 -2
  31. package/api/search/_adapter.mjs +4 -0
  32. package/api/search/_candidate-score.mjs +32 -8
  33. package/api/search/_cards.json +1 -1
  34. package/api/search/_compound.d.mts +0 -1
  35. package/api/search/_compound.mjs +93 -2
  36. package/api/search/_icons.d.mts +4 -2
  37. package/api/search/_icons.mjs +4 -2
  38. package/api/search/_lexical.mjs +177 -17
  39. package/api/search/_order.d.mts +3 -1
  40. package/api/search/_order.mjs +16 -5
  41. package/api/search/_result.d.mts +9 -0
  42. package/api/search/_result.mjs +10 -0
  43. package/api/search/_score.mjs +21 -3
  44. package/api/swizzle/_moduleGraph.d.mts +8 -0
  45. package/api/swizzle/_moduleGraph.mjs +61 -3
  46. package/api/template/copy/copy.mjs +5 -3
  47. package/api/template/template.type.d.mts +3 -3
  48. package/api/template/template.type.mjs +3 -3
  49. package/api/theme/_adapter.mjs +48 -12
  50. package/api/theme/build/build.d.mts +4 -0
  51. package/api/theme/build/build.mjs +69 -18
  52. package/api/theme/build/style-keys.mjs +4 -5
  53. package/api/theme/build/theme-object.mjs +5 -0
  54. package/api/theme/palette/generate/color.d.mts +47 -0
  55. package/api/theme/palette/generate/color.mjs +58 -1
  56. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  57. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  58. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  59. package/api/theme/palette/generate/editor-look.mjs +550 -0
  60. package/api/theme/palette/generate/mapping.d.mts +94 -9
  61. package/api/theme/palette/generate/mapping.mjs +94 -22
  62. package/api/theme-edit/_adapter.mjs +13 -2
  63. package/api/theme-edit/_catalog.d.mts +13 -13
  64. package/api/theme-edit/_catalog.mjs +66 -28
  65. package/api/theme-edit/_check.d.mts +82 -6
  66. package/api/theme-edit/_check.mjs +1270 -238
  67. package/api/theme-edit/_color.d.mts +74 -0
  68. package/api/theme-edit/_color.mjs +168 -3
  69. package/api/theme-edit/_compiler.d.mts +3 -5
  70. package/api/theme-edit/_compiler.mjs +122 -23
  71. package/api/theme-edit/_context.d.mts +55 -12
  72. package/api/theme-edit/_context.mjs +114 -60
  73. package/api/theme-edit/_css.d.mts +11 -0
  74. package/api/theme-edit/_css.mjs +40 -0
  75. package/api/theme-edit/_edit.d.mts +15 -2
  76. package/api/theme-edit/_edit.mjs +1469 -133
  77. package/api/theme-edit/_how-commands.d.mts +116 -0
  78. package/api/theme-edit/_how-commands.mjs +227 -115
  79. package/api/theme-edit/_how-question.d.mts +74 -29
  80. package/api/theme-edit/_how-question.mjs +8514 -1256
  81. package/api/theme-edit/_how-sides.d.mts +22 -0
  82. package/api/theme-edit/_how-sides.mjs +173 -0
  83. package/api/theme-edit/_how-steps.d.mts +42 -0
  84. package/api/theme-edit/_how-steps.mjs +208 -0
  85. package/api/theme-edit/_how-values.d.mts +29 -0
  86. package/api/theme-edit/_how-values.mjs +111 -0
  87. package/api/theme-edit/_how-words.d.mts +15 -0
  88. package/api/theme-edit/_how-words.mjs +239 -0
  89. package/api/theme-edit/_how.d.mts +1 -1
  90. package/api/theme-edit/_how.mjs +422 -37
  91. package/api/theme-edit/_missed.d.mts +2 -1
  92. package/api/theme-edit/_missed.mjs +125 -13
  93. package/api/theme-edit/_normal.d.mts +5 -3
  94. package/api/theme-edit/_normal.mjs +54 -14
  95. package/api/theme-edit/_palette.d.mts +204 -4
  96. package/api/theme-edit/_palette.mjs +901 -25
  97. package/api/theme-edit/_part-pieces.d.mts +54 -0
  98. package/api/theme-edit/_part-pieces.mjs +179 -0
  99. package/api/theme-edit/_part-words.mjs +33 -5
  100. package/api/theme-edit/_parts.d.mts +133 -0
  101. package/api/theme-edit/_parts.mjs +599 -10
  102. package/api/theme-edit/_picture-traits.d.mts +259 -0
  103. package/api/theme-edit/_picture-traits.mjs +1030 -0
  104. package/api/theme-edit/_preview.d.mts +95 -4
  105. package/api/theme-edit/_preview.mjs +284 -31
  106. package/api/theme-edit/_project.d.mts +14 -4
  107. package/api/theme-edit/_project.mjs +95 -26
  108. package/api/theme-edit/_resolved.d.mts +46 -0
  109. package/api/theme-edit/_resolved.mjs +800 -0
  110. package/api/theme-edit/_set-line.d.mts +29 -0
  111. package/api/theme-edit/_set-line.mjs +100 -0
  112. package/api/theme-edit/_settings.d.mts +625 -28
  113. package/api/theme-edit/_settings.mjs +4867 -888
  114. package/api/theme-edit/_tables.d.mts +25 -1
  115. package/api/theme-edit/_tables.mjs +115 -11
  116. package/api/theme-edit/_text-looks.d.mts +78 -0
  117. package/api/theme-edit/_text-looks.mjs +376 -0
  118. package/api/theme-edit/_vet.d.mts +3 -26
  119. package/api/theme-edit/_vet.mjs +5 -89
  120. package/api/theme-edit/how/how.d.mts +1 -1
  121. package/api/theme-edit/how/how.mjs +1 -1
  122. package/api/theme-edit/show/show.d.mts +4 -3
  123. package/api/theme-edit/show/show.mjs +3 -2
  124. package/api/theme-edit/theme-edit.type.d.mts +117 -1
  125. package/api/theme-edit/theme-edit.type.mjs +46 -3
  126. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  128. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  129. package/api/theme-edit/themeEditShow.doc.mjs +22 -3
  130. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  131. package/assets/component-list.generated.json +1 -1
  132. package/assets/docs/author-a-theme.doc.mjs +7 -4
  133. package/assets/docs/icons.doc.mjs +7 -6
  134. package/assets/docs/theme.doc.dense.mjs +10 -0
  135. package/assets/docs/theme.doc.mjs +10 -0
  136. package/assets/docs/theme.doc.zh.mjs +10 -0
  137. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  138. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  139. package/assets/docs/use-a-theme.doc.mjs +89 -17
  140. package/assets/docs-routes.generated.json +1 -1
  141. package/assets/docs.generated.json +2 -2
  142. package/assets/icons/definitions/article.doc.mjs +9 -0
  143. package/assets/icons/template-icons.json +5 -0
  144. package/assets/search-catalog.generated.json +2 -2
  145. package/assets/self-audit.generated.json +1 -1
  146. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  147. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  148. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  149. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  150. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  151. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  152. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  153. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  154. package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +9 -1
  155. package/assets/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonShowcase.doc.mjs +9 -2
  156. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.doc.mjs +3 -2
  157. package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -1
  158. package/assets/templates/blocks/components/SideNavItem/SideNavItemShowcase.doc.mjs +3 -2
  159. package/assets/templates/blocks/components/SideNavSection/SideNavSectionShowcase.doc.mjs +2 -1
  160. package/assets/templates/components.generated.json +1 -1
  161. package/assets/templates/pages/ide/page.tsx +5 -10
  162. package/assets/templates/pages/payment-form/page.tsx +16 -60
  163. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  164. package/authoring/config/parse.mjs +1 -1
  165. package/authoring/debug/parse.d.mts +1 -1
  166. package/authoring/doctypes/_schema.d.mts +13 -13
  167. package/authoring/doctypes/icon-definition/parse.mjs +2 -2
  168. package/authoring/doctypes/icon-set/parse.mjs +1 -1
  169. package/authoring/doctypes/template/parse.mjs +1 -4
  170. package/authoring/gap-report/parse.d.mts +1 -1
  171. package/clients/cli/build-id.generated.json +1 -1
  172. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  173. package/clients/cli/commands/experimental/icon.mjs +7 -7
  174. package/clients/cli/commands/experimental/theme.mjs +175 -13
  175. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  176. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  177. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  178. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  179. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  180. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  181. package/clients/cli/commands/hook.mjs +7 -0
  182. package/clients/cli/commands/template.mjs +1 -1
  183. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  184. package/clients/cli/index.mjs +6 -2
  185. package/clients/cli/lib/hook-format.mjs +41 -1
  186. package/clients/cli/lib/json-shim.mjs +34 -14
  187. package/clients/cli/lib/other-cli-words.mjs +7 -0
  188. package/clients/cli/lib/unknown-command.mjs +345 -46
  189. package/clients/cli/manifest.generated.json +1 -1
  190. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  191. package/foundation/agent-docs/agent-docs.mjs +51 -8
  192. package/foundation/config/project.d.mts +11 -1
  193. package/foundation/config/project.mjs +11 -2
  194. package/foundation/discovery/component-replacement.d.mts +5 -8
  195. package/foundation/discovery/component-replacement.mjs +12 -14
  196. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  197. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  198. package/foundation/discovery/core-elements.d.mts +6 -0
  199. package/foundation/discovery/core-elements.mjs +10 -2
  200. package/foundation/discovery/core-prop-types.d.mts +5 -0
  201. package/foundation/discovery/core-prop-types.mjs +10 -3
  202. package/foundation/discovery/core-props.d.mts +8 -0
  203. package/foundation/discovery/core-props.mjs +29 -13
  204. package/foundation/discovery/icon-ranking.d.mts +5 -2
  205. package/foundation/discovery/icon-ranking.mjs +101 -18
  206. package/foundation/discovery/icon-set-checks.mjs +1 -1
  207. package/foundation/discovery/icon-set-writer.mjs +1 -1
  208. package/foundation/discovery/official-list.d.mts +17 -0
  209. package/foundation/discovery/official-list.mjs +77 -0
  210. package/foundation/discovery/template-icon-notes.mjs +3 -3
  211. package/foundation/discovery/template-icons.mjs +2 -2
  212. package/foundation/discovery/template-placeholders.mjs +1 -1
  213. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  214. package/foundation/discovery/unknown-core-props.mjs +601 -0
  215. package/foundation/discovery/written-prop-values.d.mts +35 -0
  216. package/foundation/discovery/written-prop-values.mjs +258 -0
  217. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  218. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  219. package/foundation/fs/package-name.d.mts +10 -0
  220. package/foundation/fs/package-name.mjs +37 -0
  221. package/foundation/fs/project-source-files.d.mts +27 -0
  222. package/foundation/fs/project-source-files.mjs +115 -0
  223. package/foundation/fs/project-sources.d.mts +25 -0
  224. package/foundation/fs/project-sources.mjs +83 -0
  225. package/foundation/fs/read-record.d.mts +18 -0
  226. package/foundation/fs/read-record.mjs +36 -2
  227. package/foundation/integrations/integration-warnings.d.mts +39 -7
  228. package/foundation/integrations/integration-warnings.mjs +141 -19
  229. package/foundation/integrations/missing-dependency.d.mts +11 -0
  230. package/foundation/integrations/missing-dependency.mjs +20 -5
  231. package/foundation/release/folder-lock.d.mts +5 -2
  232. package/foundation/release/folder-lock.mjs +9 -3
  233. package/foundation/release/notices.mjs +2 -8
  234. package/foundation/render/cut-short.d.mts +8 -2
  235. package/foundation/render/cut-short.mjs +50 -5
  236. package/foundation/render/drawn-contrast.d.mts +40 -0
  237. package/foundation/render/drawn-contrast.mjs +355 -0
  238. package/foundation/render/file-header.mjs +4 -0
  239. package/foundation/render/layers.d.mts +2 -1
  240. package/foundation/render/layers.mjs +22 -1
  241. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  242. package/foundation/render/package-resolve-hooks.mjs +124 -32
  243. package/foundation/render/page-worker.mjs +95 -23
  244. package/foundation/render/part-boxes.d.mts +27 -0
  245. package/foundation/render/part-boxes.mjs +45 -0
  246. package/foundation/render/picture-chrome.mjs +36 -4
  247. package/foundation/render/picture-playwright.mjs +26 -2
  248. package/foundation/render/picture-window.d.mts +29 -2
  249. package/foundation/render/picture-window.mjs +99 -1
  250. package/foundation/render/render-page.d.mts +39 -6
  251. package/foundation/render/render-page.mjs +26 -10
  252. package/foundation/render/ts-paths.mjs +2 -1
  253. package/foundation/response/error-codes.doc.mjs +1 -1
  254. package/foundation/response/error-codes.mjs +1 -1
  255. package/foundation/response/response-types.doc.mjs +9 -5
  256. package/foundation/suggest/other-command.mjs +25 -1
  257. package/foundation/text/icon-set-next.d.mts +1 -1
  258. package/foundation/text/icon-set-next.mjs +2 -2
  259. package/foundation/text/written-string.d.mts +4 -1
  260. package/foundation/text/written-string.mjs +4 -1
  261. package/package.json +8 -7
@@ -0,0 +1,22 @@
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
+ * The sides of one part's border said in a list joined as one ask: "a
6
+ * border on top and sides", "the left and right edges", "a #ddd border on
7
+ * top, left and right" (`top & left & right`), so no list or clause split
8
+ * takes a side away. Only in a clause that names a border, an edge or an
9
+ * outline: a list of padding sides is the spacing reader's.
10
+ * @param {string} q
11
+ * @returns {string}
12
+ */
13
+ export function joinSideLists(q: string): string;
14
+ /**
15
+ * A border color written one per side, as CSS writes it (`#eee #eee #ddd`,
16
+ * `rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25)`): two to four written
17
+ * colors (hex or a color function) with nothing but spaces between them,
18
+ * as typed; null for a clause without one, or with more than four.
19
+ * @param {string} text a clause, as typed
20
+ * @returns {string[] | null}
21
+ */
22
+ export function sideColorsIn(text: string): string[] | null;
@@ -0,0 +1,173 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A border's sides said in a list ("a border on top and sides") and a
5
+ * border color written one per side (`#eee #eee #ddd`), as the how reader
6
+ * reads them.
7
+ * @position api/theme-edit — a leaf read by _how-question.mjs
8
+ */
9
+
10
+ import {parseColor} from './_color.mjs';
11
+
12
+ /**
13
+ * The sides of one part's border said in a list joined as one ask: "a
14
+ * border on top and sides", "the left and right edges", "a #ddd border on
15
+ * top, left and right" (`top & left & right`), so no list or clause split
16
+ * takes a side away. Only in a clause that names a border, an edge or an
17
+ * outline: a list of padding sides is the spacing reader's.
18
+ * @param {string} q
19
+ * @returns {string}
20
+ */
21
+ export function joinSideLists(q) {
22
+ // ("above and below" are the top and the bottom.)
23
+ const SIDE = String.raw`(?:top|bottom|left|right|sides|above|below)`;
24
+ return q.replace(
25
+ new RegExp(
26
+ // (Each side may take its own "on" and "the": "the top and the
27
+ // bottom", "on the left and on the right".)
28
+ String.raw`\b${SIDE}(?:(?:\s*,\s*and\s+|\s*,\s*|\s+and\s+)(?:on\s+)?(?:the\s+)?${SIDE}\b)+`,
29
+ 'gi',
30
+ ),
31
+ (m, at, all) => {
32
+ // (The list's own clause: from the comma, semicolon or full stop
33
+ // before it to the one after it.)
34
+ const text = String(all);
35
+ const from =
36
+ Math.max(
37
+ text.lastIndexOf(',', at - 1),
38
+ text.lastIndexOf(';', at - 1),
39
+ text.lastIndexOf('.', at - 1),
40
+ ) + 1;
41
+ const after = text.slice(at + m.length).search(/[,;]|\.(?:\s|$)/);
42
+ const clause = text.slice(
43
+ from,
44
+ after < 0 ? undefined : at + m.length + after,
45
+ );
46
+ // (The list is the border's when the look it follows is a border,
47
+ // "a border on top and sides", or a border follows it, "top and
48
+ // bottom borders"; "a border and padding top and bottom 6px" lists
49
+ // the padding's sides.)
50
+ const before = clause
51
+ .slice(0, at - from)
52
+ .match(
53
+ /\b(?:borders?|bordered|edges?|outlines?|lines?|padding|margins?|spacing|gaps?|radius|corners?|space)\b/gi,
54
+ );
55
+ const owner = before?.at(-1) ?? '';
56
+ // (A look said right after the list is its own: "a border and top
57
+ // and bottom padding 6px" lists the padding's sides, and the clause
58
+ // keeps both.)
59
+ const next = text.slice(at + m.length).match(/^\s*([a-z]+)/i)?.[1] ?? '';
60
+ const nextLook =
61
+ /^(?:borders?|edges?|outlines?|lines?|padding|margins?|spacing|gaps?|radius|corners?|space)$/i.test(
62
+ next,
63
+ );
64
+ // (Only a border's or a padding's sides are listed: "corners on top
65
+ // and bottom" are every corner, read by the corner reader.)
66
+ const sided =
67
+ /^(?:borders?|bordered|edges?|outlines?|lines?|padding|margins?|spacing|space)$/i;
68
+ // (A comma or an "and" before the last side, with a look after it
69
+ // and another before the list, ends the first item there: "a border
70
+ // on top and bottom padding 8px" is the border's top and the
71
+ // padding's bottom. The sides before that comma are the earlier look's.)
72
+ const lastComma =
73
+ /(?:\s*,\s*(?:and\s+)?|\s+and\s+)(?:on\s+)?(?:the\s+)?[a-z]+$/i.exec(m);
74
+ // (Only a list said as where the earlier look goes, "on top", "along
75
+ // the top", "on its top", or right after it, "border top": "a border and top and bottom padding 6px"
76
+ // lists the padding's sides.)
77
+ const placed =
78
+ /\b(?:on|at|along|across|around|over|down|by)(?:\s+(?:the|its|their))?\s*$/i.test(
79
+ text.slice(0, at),
80
+ ) ||
81
+ /\b(?:borders?|bordered|edges?|outlines?|lines?|padding|margins?|spacing|space|shadows?|glows?|gradients?|underlines?|corners?|text|bold|uppercase)\s*$/i.test(
82
+ text.slice(0, at),
83
+ );
84
+ // (Whatever look came before, a shadow or a glow too: only a border's
85
+ // or a spacing's sides are joined.)
86
+ // (Corners said on a side, "rounded corners on the left", are the
87
+ // corner reader's: the list stays as said.)
88
+ if (/^(?:corners?|radius)$/i.test(owner)) return m;
89
+ // (A width, style or color between the look and the side, "border
90
+ // 1px top, bottom padding 8px", is read as it always was: the list
91
+ // stays as said.)
92
+ if (
93
+ /\b(?:borders?|edges?|outlines?|lines?|padding|margins?)(?:\s+(?!(?:top|bottom|left|right|sides|above|below|and|or|on|at|along|across|around|over|down|by|the|its|their|with|of|to)\b)[#\w.%()-]+)+\s*$/i.test(
94
+ text.slice(0, at),
95
+ )
96
+ )
97
+ return m;
98
+ if (nextLook && placed && lastComma) {
99
+ const head = m.slice(0, lastComma.index);
100
+ const joinedHead = sided.test(owner)
101
+ ? head.replace(
102
+ /\s*,\s*(?:and\s+)?(?:on\s+)?(?:the\s+)?|\s+and\s+(?:on\s+)?(?:the\s+)?/gi,
103
+ ' & ',
104
+ )
105
+ : head;
106
+ return joinedHead + m.slice(lastComma.index);
107
+ }
108
+ // (Any look's list is kept whole, "top and bottom padding 6px", so
109
+ // each side said takes the look: the border reader and the padding
110
+ // reader each read the sides.)
111
+ const look = nextLook ? sided.test(next) : sided.test(owner);
112
+ return look
113
+ ? m.replace(
114
+ /\s*,\s*(?:and\s+)?(?:on\s+)?(?:the\s+)?|\s+and\s+(?:on\s+)?(?:the\s+)?/gi,
115
+ ' & ',
116
+ )
117
+ : m;
118
+ },
119
+ );
120
+ }
121
+
122
+ /**
123
+ * A border color written one per side, as CSS writes it (`#eee #eee #ddd`,
124
+ * `rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25)`): two to four written
125
+ * colors (hex or a color function) with nothing but spaces between them,
126
+ * as typed; null for a clause without one, or with more than four.
127
+ * @param {string} text a clause, as typed
128
+ * @returns {string[] | null}
129
+ */
130
+ export function sideColorsIn(text) {
131
+ const lower = text.toLowerCase();
132
+ // (A CSS keyword color in the run, "#ddd #ddd transparent", "white", is
133
+ // one of its sides, as typed; a run needs one written color, a hex or a
134
+ // color function, so a list of color words is never read as sides.)
135
+ const written = [
136
+ ...lower.matchAll(
137
+ /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)|\b[a-z]+\b/g,
138
+ ),
139
+ ]
140
+ .map(m => /** @type {[number, string]} */ ([m.index ?? 0, m[0]]))
141
+ .filter(
142
+ ([, v]) =>
143
+ /^[#a-z]/.test(v) &&
144
+ (v === 'transparent' || v === 'currentcolor' || parseColor(v) != null),
145
+ );
146
+ for (let i = 0; i < written.length;) {
147
+ let j = i;
148
+ while (
149
+ j + 1 < written.length &&
150
+ /^\s+$/.test(
151
+ lower.slice(written[j][0] + written[j][1].length, written[j + 1][0]),
152
+ )
153
+ )
154
+ j++;
155
+ const run = written.slice(i, j + 1);
156
+ // (A color word that names the next look, "#dddddd white background",
157
+ // is that look's color, never a side of the run.)
158
+ while (
159
+ run.length &&
160
+ /^[a-z]+$/.test(run[run.length - 1][1]) &&
161
+ /^\s+(?:backgrounds?|bg|fills?|text|fonts?|colou?rs?|links?|headings?|titles?|labels?|icons?|accents?)\b/.test(
162
+ lower.slice(run[run.length - 1][0] + run[run.length - 1][1].length),
163
+ )
164
+ )
165
+ run.pop();
166
+ if (run.length >= 2 && run.some(([, v]) => /^#|\(/.test(v)))
167
+ return run.length > 4
168
+ ? null
169
+ : run.map(([at, v]) => text.slice(at, at + v.length));
170
+ i = j + 1;
171
+ }
172
+ return null;
173
+ }
@@ -0,0 +1,42 @@
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
+ * Make a color lighter or darker by mixing in white or black.
6
+ * @param {string} color @param {number} amount -1 (darker) to 1 (lighter)
7
+ */
8
+ export function shift(color: string, amount: number): string | null;
9
+ /**
10
+ * A box-shadow with each layer's blur scaled (the third length); offsets,
11
+ * spread, inset and color stay. Null when no layer has a blur to scale.
12
+ * @param {string} shadow @param {number} f
13
+ */
14
+ export function blurScaled(shadow: string, f: number): string | null;
15
+ /**
16
+ * {@link shift} that keeps a see-through color see-through: its alpha
17
+ * stays, only its hue moves. A see-through ink paints over the page, so
18
+ * whether more of it is lighter is read against that page's color.
19
+ * @param {string} color @param {number} amount
20
+ * @param {string | null} [page] the page color it paints over (white when
21
+ * not given)
22
+ */
23
+ export function shiftKeepAlpha(color: string, amount: number, page?: string | null): string | null;
24
+ /** Scale a CSS length. @param {string} v @param {number} f */
25
+ export function scaled(v: string, f: number): string | null;
26
+ /**
27
+ * A color written with a new alpha, in the form it was written: a hex color
28
+ * as 8-digit hex, a `/ alpha` or rgba()/hsla() alpha replaced, an opaque
29
+ * color function given one.
30
+ * @param {string} color
31
+ * @param {number} a 0 to 1
32
+ */
33
+ export function withAlpha(color: string, a: number): string;
34
+ /**
35
+ * A shadow with the alpha of each of its colors scaled (clamped to 0–1),
36
+ * layers, offsets and blur kept; with a mode, only that half of each
37
+ * light-dark() color.
38
+ * @param {string} value
39
+ * @param {number} k
40
+ * @param {'light' | 'dark' | null} [mode]
41
+ */
42
+ export function shadowAlphaScaled(value: string, k: number, mode?: "light" | "dark" | null): string;
@@ -0,0 +1,208 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The value a step moves to: a color made lighter or darker (keeping
5
+ * a see-through color see-through), a color given a new alpha, a length
6
+ * scaled, and a shadow's blur or alpha scaled.
7
+ * @position api/theme-edit — a leaf read by _how-question.mjs and _missed.mjs
8
+ */
9
+
10
+ import {COLOR_IN_VALUE, alphaOf, hex, parseColor} from './_color.mjs';
11
+
12
+ /**
13
+ * Make a color lighter or darker by mixing in white or black.
14
+ * @param {string} color @param {number} amount -1 (darker) to 1 (lighter)
15
+ */
16
+ export function shift(color, amount) {
17
+ const rgb = parseColor(color);
18
+ if (!rgb) return null;
19
+ const to = amount > 0 ? 255 : 0;
20
+ const a = Math.abs(amount);
21
+ return hex(rgb.map(c => c + (to - c) * a));
22
+ }
23
+
24
+ /**
25
+ * A box-shadow with each layer's blur scaled (the third length); offsets,
26
+ * spread, inset and color stay. Null when no layer has a blur to scale.
27
+ * @param {string} shadow @param {number} f
28
+ */
29
+ export function blurScaled(shadow, f) {
30
+ const layers = String(shadow).split(/,(?![^(]*\))/);
31
+ let changed = false;
32
+ const out = layers.map(layer => {
33
+ // The lengths outside any function (a color's numbers are not
34
+ // lengths): the third is the blur.
35
+ let depth = 0;
36
+ let count = 0;
37
+ let res = '';
38
+ const re = /[()]|-?\d*\.?\d+(?:px|rem|em)?(?![\w.%])/g;
39
+ let last = 0;
40
+ for (let m = re.exec(layer); m; m = re.exec(layer)) {
41
+ const tok = m[0];
42
+ if (tok === '(') depth++;
43
+ else if (tok === ')') depth--;
44
+ else if (
45
+ (depth === 0 && /^-?\d/.test(tok)) ||
46
+ (depth === 0 && /^-?\./.test(tok))
47
+ ) {
48
+ const before = layer[m.index - 1];
49
+ if (m.index === 0 || /\s/.test(before ?? ' ')) {
50
+ count++;
51
+ if (count === 3) {
52
+ const n = /^(-?\d*\.?\d+)(px|rem|em)?$/.exec(tok);
53
+ if (n) {
54
+ const unit = n[2] ?? 'px';
55
+ const v = Number(n[1]) * f;
56
+ res +=
57
+ layer.slice(last, m.index) +
58
+ `${Number(v.toFixed(unit === 'px' ? 2 : 3))}${unit}`;
59
+ last = m.index + tok.length;
60
+ changed = true;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ return res + layer.slice(last);
67
+ });
68
+ return changed ? out.join(',') : null;
69
+ }
70
+
71
+ /**
72
+ * {@link shift} that keeps a see-through color see-through: its alpha
73
+ * stays, only its hue moves. A see-through ink paints over the page, so
74
+ * whether more of it is lighter is read against that page's color.
75
+ * @param {string} color @param {number} amount
76
+ * @param {string | null} [page] the page color it paints over (white when
77
+ * not given)
78
+ */
79
+ export function shiftKeepAlpha(color, amount, page = null) {
80
+ // rgb()/rgba()/hsl()/hwb()/lab()/oklch() with an alpha: the same color as
81
+ // #rrggbbaa, so its alpha stays too.
82
+ const fn =
83
+ /^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\((.*)\)$/i.exec(
84
+ String(color).trim(),
85
+ )?.[1] ?? null;
86
+ if (fn) {
87
+ const alphaText =
88
+ /\/\s*([\d.]+%?)\s*$/.exec(fn)?.[1] ??
89
+ (/^\s*rgba|^\s*hsla/i.test(String(color).trim())
90
+ ? /,\s*([\d.]+%?)\s*$/.exec(fn)?.[1]
91
+ : undefined);
92
+ const rgb = parseColor(color);
93
+ if (alphaText && rgb) {
94
+ const a = alphaText.endsWith('%')
95
+ ? Number.parseFloat(alphaText) / 100
96
+ : Number(alphaText);
97
+ if (a >= 0 && a < 1) {
98
+ const byte = Math.max(0, Math.min(255, Math.round(a * 255)));
99
+ return shiftKeepAlpha(
100
+ `${hex(rgb.slice(0, 3))}${byte.toString(16).padStart(2, '0')}`,
101
+ amount,
102
+ page,
103
+ );
104
+ }
105
+ }
106
+ }
107
+ const m = /^#([0-9a-f]{6})([0-9a-f]{2})$/i.exec(String(color).trim());
108
+ if (!m) return shift(color, amount);
109
+ // A see-through ink: lighter means less of an ink darker than the page
110
+ // (fainter) or more of one lighter than it (stronger); its hue stays.
111
+ const rgb = parseColor(`#${m[1]}`) ?? [0, 0, 0];
112
+ const under = (page ? parseColor(page) : null) ?? [255, 255, 255];
113
+ const sum = (/** @type {number[]} */ v) => v[0] + v[1] + v[2];
114
+ const darkInk =
115
+ sum(rgb) < sum(under) || (sum(rgb) === sum(under) && sum(rgb) < 382);
116
+ const k = Math.min(0.9, Math.abs(amount) * 2.5);
117
+ const f = amount > 0 === darkInk ? 1 - k : 1 + k;
118
+ const a = Math.max(1, Math.min(255, Math.round(parseInt(m[2], 16) * f)));
119
+ return `#${m[1]}${a.toString(16).padStart(2, '0')}`;
120
+ }
121
+
122
+ /** Scale a CSS length. @param {string} v @param {number} f */
123
+ export function scaled(v, f) {
124
+ const m = /^(\d*\.?\d+)(px|rem|em)$/.exec(String(v ?? '').trim());
125
+ if (!m) return null;
126
+ const n = Number(m[1]) * f;
127
+ // A fraction of a pixel is a real length (hi-dpi screens draw it): kept
128
+ // to 0.01px, never rounded away to the same value or to 0.
129
+ return `${m[2] === 'px' ? Number(n.toFixed(2)) : Number(n.toFixed(3))}${m[2]}`;
130
+ }
131
+
132
+ /**
133
+ * A color written with a new alpha, in the form it was written: a hex color
134
+ * as 8-digit hex, a `/ alpha` or rgba()/hsla() alpha replaced, an opaque
135
+ * color function given one.
136
+ * @param {string} color
137
+ * @param {number} a 0 to 1
138
+ */
139
+ export function withAlpha(color, a) {
140
+ const c = color.trim();
141
+ const round = (/** @type {number} */ n) => Math.round(n * 1000) / 1000;
142
+ if (c.startsWith('#')) {
143
+ const rgb = parseColor(c);
144
+ if (!rgb) return color;
145
+ return `${hex(rgb.slice(0, 3))}${Math.round(a * 255)
146
+ .toString(16)
147
+ .padStart(2, '0')}`;
148
+ }
149
+ const slash = /\/\s*[\d.]+(%?)\s*\)$/.exec(c);
150
+ if (slash)
151
+ return c.replace(
152
+ /\/\s*[\d.]+%?\s*\)$/,
153
+ slash[1] ? `/ ${Math.round(a * 1000) / 10}%)` : `/ ${round(a)})`,
154
+ );
155
+ const legacy =
156
+ /^(rgba?|hsla?)\(([^,()]*),([^,()]*),([^,()]*)(?:,[^,()]*)?\)$/i.exec(c);
157
+ if (legacy)
158
+ return `${legacy[1].replace(/a$/i, '')}a(${legacy[2].trim()}, ${legacy[3].trim()}, ${legacy[4].trim()}, ${round(a)})`;
159
+ return c.replace(/\)$/, ` / ${round(a)})`);
160
+ }
161
+
162
+ /**
163
+ * A shadow with the alpha of each of its colors scaled (clamped to 0–1),
164
+ * layers, offsets and blur kept; with a mode, only that half of each
165
+ * light-dark() color.
166
+ * @param {string} value
167
+ * @param {number} k
168
+ * @param {'light' | 'dark' | null} [mode]
169
+ */
170
+ export function shadowAlphaScaled(value, k, mode = null) {
171
+ /** @param {string} part */
172
+ const scale = part =>
173
+ part
174
+ // A color mixed with transparent (a ring at 30%) scales its share.
175
+ .replace(
176
+ /color-mix\(\s*in\s+srgb\s*,\s*((?:[^(),]|\([^()]*\))+?)\s+(\d*\.?\d+)%\s*,\s*transparent\s*\)/gi,
177
+ (_m, color, share) =>
178
+ `color-mix(in srgb, ${color.trim()} ${Math.round(Math.max(0, Math.min(100, Number(share) * k)) * 10) / 10}%, transparent)`,
179
+ )
180
+ .replace(COLOR_IN_VALUE, c =>
181
+ /^color-mix\(/i.test(c)
182
+ ? c
183
+ : withAlpha(c, Math.max(0, Math.min(1, alphaOf(c) * k))),
184
+ );
185
+ if (!mode) return scale(value);
186
+ // A named mode: that half of each light-dark() color; a color written as
187
+ // one value becomes a light-dark() pair with only that mode's half scaled.
188
+ const PAIR =
189
+ /light-dark\(((?:[^(),]|\([^()]*\))*),\s*((?:[^(),]|\([^()]*\))*)\)/g;
190
+ return value
191
+ .split(/(light-dark\((?:[^(),]|\([^()]*\))*,\s*(?:[^(),]|\([^()]*\))*\))/g)
192
+ .map(piece =>
193
+ /^light-dark\(/.test(piece)
194
+ ? piece.replace(
195
+ PAIR,
196
+ (_m, a, b) =>
197
+ `light-dark(${mode === 'light' ? scale(a) : a}, ${mode === 'dark' ? scale(b) : b})`,
198
+ )
199
+ : piece.replace(COLOR_IN_VALUE, c => {
200
+ const scaled = scale(c);
201
+ if (scaled === c) return c;
202
+ return mode === 'dark'
203
+ ? `light-dark(${c}, ${scaled})`
204
+ : `light-dark(${scaled}, ${c})`;
205
+ }),
206
+ )
207
+ .join('');
208
+ }
@@ -0,0 +1,29 @@
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
+ * @file A typed value no page could show (a line height under 0.8, a padding
6
+ * wider than any screen), and the property a question asks the value of
7
+ * ("how much padding …").
8
+ * @position api/theme-edit — a leaf read by _how-question.mjs and _how.mjs
9
+ */
10
+ /**
11
+ * A typed value no page could show, for the properties whose range is
12
+ * plain: a line height that draws lines over each other (under 0.8) or
13
+ * far apart (over 4), a padding, margin or gap wider than any screen
14
+ * (over 512px), a font size under 6px or over 256px, a border over 64px.
15
+ * The reason, or null for a value in range (and for any other property).
16
+ * @param {{thing: string, value?: unknown}} st
17
+ * @returns {string | null}
18
+ */
19
+ export function outOfBounds(st: {
20
+ thing: string;
21
+ value?: unknown;
22
+ }): string | null;
23
+ /**
24
+ * The property a question asks the value of ("how much padding …", "how
25
+ * rounded are …", "what color is …"), or null when it is not one.
26
+ * @param {string} q
27
+ * @returns {string | null}
28
+ */
29
+ export function valueAsked(q: string): string | null;
@@ -0,0 +1,111 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A typed value no page could show (a line height under 0.8, a padding
5
+ * wider than any screen), and the property a question asks the value of
6
+ * ("how much padding …").
7
+ * @position api/theme-edit — a leaf read by _how-question.mjs and _how.mjs
8
+ */
9
+
10
+ /**
11
+ * A typed value no page could show, for the properties whose range is
12
+ * plain: a line height that draws lines over each other (under 0.8) or
13
+ * far apart (over 4), a padding, margin or gap wider than any screen
14
+ * (over 512px), a font size under 6px or over 256px, a border over 64px.
15
+ * The reason, or null for a value in range (and for any other property).
16
+ * @param {{thing: string, value?: unknown}} st
17
+ * @returns {string | null}
18
+ */
19
+ export function outOfBounds(st) {
20
+ const v = String(st.value ?? '').trim();
21
+ const m = /^(-?\d*\.?\d+)(px|rem|em|%)?$/.exec(v);
22
+ if (!m) return null;
23
+ const n = Number(m[1]);
24
+ const unit = m[2] ?? '';
25
+ const px =
26
+ unit === 'rem' || unit === 'em' ? n * 16 : unit === 'px' ? n : null;
27
+ const thing = st.thing;
28
+ if (/^line-height$|^--text-[a-z0-9-]+-leading$/.test(thing)) {
29
+ const ratio = unit === '' ? n : unit === '%' ? n / 100 : null;
30
+ if (ratio != null && (ratio < 0.5 || ratio > 4))
31
+ return `a line height of ${v} ${ratio < 0.5 ? 'draws each line over the one before it' : 'leaves lines far apart'}; a line height reads between 0.5 and 4`;
32
+ return null;
33
+ }
34
+ if (
35
+ /^(?:padding|margin|gap|row-gap|column-gap)(?:-[a-z-]+)?$|^--spacing-/.test(
36
+ thing,
37
+ )
38
+ ) {
39
+ const each = v.split(/\s+/);
40
+ if (px != null && Math.abs(px) > 512)
41
+ return `${thing} ${v} is wider than any screen; a ${thing.replace(/^--/, '')} reads up to 512px`;
42
+ void each;
43
+ return null;
44
+ }
45
+ if (
46
+ /^font-size$|^--text-[a-z0-9-]+-size$/.test(thing) &&
47
+ px != null &&
48
+ (px < 6 || px > 256)
49
+ )
50
+ return `a font size of ${v} ${px < 6 ? 'cannot be read' : 'is wider than the screen for a word'}; a font size reads between 6px and 256px`;
51
+ if (
52
+ /^border(?:-[a-z]+)?-width$|^--border-width$/.test(thing) &&
53
+ px != null &&
54
+ px > 64
55
+ )
56
+ return `a border of ${v} covers the part; a border reads up to 64px`;
57
+ return null;
58
+ }
59
+
60
+ /**
61
+ * The property a question asks the value of ("how much padding …", "how
62
+ * rounded are …", "what color is …"), or null when it is not one.
63
+ * @param {string} q
64
+ * @returns {string | null}
65
+ */
66
+ export function valueAsked(q) {
67
+ // Only the question part ("how rounded are cards? make them 12px").
68
+ const t = q.toLowerCase().trim().split('?')[0];
69
+ if (
70
+ !/^(?:how (?:much|many|big|round(?:ed)?|thick|wide|tall|bold|dark|light|transparent|opaque|dense|roomy|spacious|compact|tight|airy|crowded|cramped|strong|faint|soft|blurry)|what(?:(?:'s| is| are)(?: the| my)?(?: [a-z-]+){0,2}?|(?: the)?) (?:colou?r|size|padding|gap|spacing|density|radius|corner radius|font|weight|font size|shadow|border|opacity|font family|typeface|background|fill|focus ring|focus outline|ring|outline|height|width)s?|which (?:colou?r|font))\b/.test(
71
+ t,
72
+ )
73
+ )
74
+ return null;
75
+ // "what is the focus ring of inputs": the ring the part draws when
76
+ // focused (a box-shadow or an outline, as Core draws it there).
77
+ if (/\b(?:focus (?:ring|outline)|rings?|outlines?)\b/.test(t))
78
+ return 'focus-ring';
79
+ if (/\b(round|rounded|radius|corners?)\b/.test(t)) return 'border-radius';
80
+ if (/\b(opacity|transparent|opaque)\b/.test(t)) return 'opacity';
81
+ if (
82
+ /\b(font family|typeface)\b|\bwhat(?:'s| is)?(?: the| my)?(?: [a-z-]+)? font\b(?! size| weight)|\bwhich font\b/.test(
83
+ t,
84
+ )
85
+ )
86
+ return 'font-family';
87
+ if (/\bgap\b/.test(t)) return 'gap';
88
+ // "how tall are the buttons", "what is the height of buttons".
89
+ if (/\b(height|tall)\b/.test(t)) return 'height';
90
+ if (
91
+ /\b(padding|spacing|space|room|density|dense|roomy|spacious|compact|tight|airy|crowded|cramped)\b/.test(
92
+ t,
93
+ )
94
+ )
95
+ return 'padding';
96
+ if (/\bshadows?\b/.test(t)) return 'box-shadow';
97
+ if (/\b(background|fill|bg)\b/.test(t)) return 'background-color';
98
+ // (How strong or faint a border is, its color; how thick, its width.)
99
+ if (/\bborders?\b/.test(t))
100
+ return /\b(colou?r|strong|faint|dark|light|visible)\b/.test(t)
101
+ ? 'border-color'
102
+ : 'border-width';
103
+ if (/\bfont size|text size|how big\b/.test(t)) return 'font-size';
104
+ if (/\b(bold|weight)\b/.test(t)) return 'font-weight';
105
+ // "what color is the primary button": the color; which one (its fill or
106
+ // its text) the part decides (draftAnswer reads the part facts).
107
+ if (/\b(colou?r|dark|light)\b/.test(t)) return 'color';
108
+ // "how thick are dividers": a line's thickness is its border width.
109
+ if (/\bhow (?:thick|thin)\b|\bthickness\b/.test(t)) return 'border-width';
110
+ return null;
111
+ }
@@ -0,0 +1,15 @@
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
+ * Words of other languages the docs ship, and the English word each means.
6
+ * Matched as whole words, or anywhere for scripts without spaces.
7
+ * @type {Array<[RegExp, string]>}
8
+ */
9
+ export const TRANSLATE: Array<[RegExp, string]>;
10
+ /** Design words a near miss is corrected to, beside the one-word part names. */
11
+ export const DESIGN_WORDS: string[];
12
+ /** Hues people name, as fills a part can take. */
13
+ export const HUES: Record<string, string>;
14
+ /** States a word names. */
15
+ export const STATE_WORDS: Array<[RegExp, string]>;