@astryxdesign/cli 0.7.17 → 0.7.18-canary.gb660bba

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 (215) 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/doctor/_adapter.d.mts +11 -62
  5. package/api/doctor/_adapter.mjs +242 -472
  6. package/api/doctor/doctor.d.mts +1 -1
  7. package/api/doctor/doctor.mjs +1 -1
  8. package/api/doctor/theme-checks.mjs +37 -45
  9. package/api/error.d.mts +21 -0
  10. package/api/error.mjs +89 -0
  11. package/api/hook/list/list.d.mts +1 -1
  12. package/api/icon/icon.doc.mjs +1 -1
  13. package/api/icon/icon.type.mjs +1 -1
  14. package/api/icon/search/search.d.mts +4 -1
  15. package/api/icon/search/search.mjs +41 -4
  16. package/api/render/_adapter.mjs +233 -40
  17. package/api/render/render.type.d.mts +1 -1
  18. package/api/render/render.type.mjs +1 -1
  19. package/api/search/ORDERING.md +2 -2
  20. package/api/search/_candidate-score.mjs +32 -8
  21. package/api/search/_cards.json +1 -1
  22. package/api/search/_compound.d.mts +0 -1
  23. package/api/search/_compound.mjs +93 -2
  24. package/api/search/_lexical.mjs +177 -17
  25. package/api/search/_order.d.mts +3 -1
  26. package/api/search/_order.mjs +16 -5
  27. package/api/search/_result.d.mts +9 -0
  28. package/api/search/_result.mjs +10 -0
  29. package/api/search/_score.mjs +21 -3
  30. package/api/swizzle/_moduleGraph.d.mts +8 -0
  31. package/api/swizzle/_moduleGraph.mjs +61 -3
  32. package/api/template/copy/copy.mjs +5 -3
  33. package/api/theme/_adapter.mjs +48 -12
  34. package/api/theme/build/build.d.mts +4 -0
  35. package/api/theme/build/build.mjs +69 -18
  36. package/api/theme/build/style-keys.mjs +4 -5
  37. package/api/theme/build/theme-object.mjs +5 -0
  38. package/api/theme/palette/generate/color.d.mts +47 -0
  39. package/api/theme/palette/generate/color.mjs +58 -1
  40. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  41. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  42. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  43. package/api/theme/palette/generate/editor-look.mjs +550 -0
  44. package/api/theme/palette/generate/mapping.d.mts +94 -9
  45. package/api/theme/palette/generate/mapping.mjs +94 -22
  46. package/api/theme-edit/_adapter.mjs +10 -1
  47. package/api/theme-edit/_catalog.d.mts +13 -13
  48. package/api/theme-edit/_catalog.mjs +38 -16
  49. package/api/theme-edit/_check.d.mts +82 -6
  50. package/api/theme-edit/_check.mjs +1270 -238
  51. package/api/theme-edit/_color.d.mts +74 -0
  52. package/api/theme-edit/_color.mjs +168 -3
  53. package/api/theme-edit/_compiler.d.mts +3 -5
  54. package/api/theme-edit/_compiler.mjs +122 -23
  55. package/api/theme-edit/_context.d.mts +46 -5
  56. package/api/theme-edit/_context.mjs +97 -49
  57. package/api/theme-edit/_css.d.mts +11 -0
  58. package/api/theme-edit/_css.mjs +40 -0
  59. package/api/theme-edit/_edit.d.mts +13 -0
  60. package/api/theme-edit/_edit.mjs +1450 -128
  61. package/api/theme-edit/_how-commands.d.mts +12 -0
  62. package/api/theme-edit/_how-commands.mjs +96 -14
  63. package/api/theme-edit/_how-question.d.mts +73 -29
  64. package/api/theme-edit/_how-question.mjs +8233 -1207
  65. package/api/theme-edit/_how-sides.d.mts +22 -0
  66. package/api/theme-edit/_how-sides.mjs +173 -0
  67. package/api/theme-edit/_how-steps.d.mts +42 -0
  68. package/api/theme-edit/_how-steps.mjs +208 -0
  69. package/api/theme-edit/_how-values.d.mts +29 -0
  70. package/api/theme-edit/_how-values.mjs +111 -0
  71. package/api/theme-edit/_how-words.d.mts +15 -0
  72. package/api/theme-edit/_how-words.mjs +239 -0
  73. package/api/theme-edit/_how.d.mts +1 -1
  74. package/api/theme-edit/_how.mjs +412 -37
  75. package/api/theme-edit/_missed.d.mts +2 -1
  76. package/api/theme-edit/_missed.mjs +125 -13
  77. package/api/theme-edit/_normal.d.mts +5 -3
  78. package/api/theme-edit/_normal.mjs +54 -14
  79. package/api/theme-edit/_palette.d.mts +204 -4
  80. package/api/theme-edit/_palette.mjs +901 -25
  81. package/api/theme-edit/_part-pieces.d.mts +54 -0
  82. package/api/theme-edit/_part-pieces.mjs +179 -0
  83. package/api/theme-edit/_part-words.mjs +33 -5
  84. package/api/theme-edit/_parts.d.mts +133 -0
  85. package/api/theme-edit/_parts.mjs +599 -10
  86. package/api/theme-edit/_picture-traits.d.mts +259 -0
  87. package/api/theme-edit/_picture-traits.mjs +1030 -0
  88. package/api/theme-edit/_preview.d.mts +84 -4
  89. package/api/theme-edit/_preview.mjs +260 -24
  90. package/api/theme-edit/_project.d.mts +14 -4
  91. package/api/theme-edit/_project.mjs +95 -26
  92. package/api/theme-edit/_set-line.d.mts +29 -0
  93. package/api/theme-edit/_set-line.mjs +100 -0
  94. package/api/theme-edit/_settings.d.mts +625 -28
  95. package/api/theme-edit/_settings.mjs +4587 -880
  96. package/api/theme-edit/_tables.d.mts +25 -1
  97. package/api/theme-edit/_tables.mjs +115 -11
  98. package/api/theme-edit/_text-looks.d.mts +78 -0
  99. package/api/theme-edit/_text-looks.mjs +376 -0
  100. package/api/theme-edit/_vet.d.mts +3 -26
  101. package/api/theme-edit/_vet.mjs +5 -89
  102. package/api/theme-edit/how/how.d.mts +1 -1
  103. package/api/theme-edit/how/how.mjs +1 -1
  104. package/api/theme-edit/theme-edit.type.d.mts +54 -1
  105. package/api/theme-edit/theme-edit.type.mjs +17 -2
  106. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  107. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  108. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  109. package/api/theme-edit/themeEditShow.doc.mjs +4 -0
  110. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  111. package/assets/component-list.generated.json +1 -1
  112. package/assets/docs/author-a-theme.doc.mjs +7 -4
  113. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  114. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  115. package/assets/docs/use-a-theme.doc.mjs +89 -17
  116. package/assets/docs-routes.generated.json +1 -1
  117. package/assets/docs.generated.json +2 -2
  118. package/assets/icons/definitions/article.doc.mjs +9 -0
  119. package/assets/icons/template-icons.json +5 -0
  120. package/assets/search-catalog.generated.json +2 -2
  121. package/assets/self-audit.generated.json +1 -1
  122. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  123. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  124. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  125. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  126. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  127. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  128. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  129. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  130. package/assets/templates/components.generated.json +1 -1
  131. package/assets/templates/pages/ide/page.tsx +5 -10
  132. package/assets/templates/pages/payment-form/page.tsx +16 -60
  133. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  134. package/authoring/debug/parse.d.mts +1 -1
  135. package/authoring/doctypes/_schema.d.mts +13 -13
  136. package/authoring/gap-report/parse.d.mts +1 -1
  137. package/clients/cli/build-id.generated.json +1 -1
  138. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  139. package/clients/cli/commands/experimental/theme.mjs +46 -6
  140. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  141. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  142. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  143. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  144. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  145. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  146. package/clients/cli/commands/hook.mjs +7 -0
  147. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  148. package/clients/cli/index.mjs +6 -2
  149. package/clients/cli/lib/hook-format.mjs +41 -1
  150. package/clients/cli/lib/json-shim.mjs +34 -14
  151. package/clients/cli/lib/other-cli-words.mjs +7 -0
  152. package/clients/cli/lib/unknown-command.mjs +345 -46
  153. package/clients/cli/manifest.generated.json +1 -1
  154. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  155. package/foundation/agent-docs/agent-docs.mjs +51 -8
  156. package/foundation/config/project.d.mts +11 -1
  157. package/foundation/config/project.mjs +11 -2
  158. package/foundation/discovery/component-replacement.d.mts +5 -8
  159. package/foundation/discovery/component-replacement.mjs +12 -14
  160. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  161. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  162. package/foundation/discovery/core-elements.d.mts +6 -0
  163. package/foundation/discovery/core-elements.mjs +10 -2
  164. package/foundation/discovery/core-prop-types.d.mts +5 -0
  165. package/foundation/discovery/core-prop-types.mjs +10 -3
  166. package/foundation/discovery/core-props.d.mts +8 -0
  167. package/foundation/discovery/core-props.mjs +29 -13
  168. package/foundation/discovery/official-list.d.mts +17 -0
  169. package/foundation/discovery/official-list.mjs +77 -0
  170. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  171. package/foundation/discovery/unknown-core-props.mjs +601 -0
  172. package/foundation/discovery/written-prop-values.d.mts +35 -0
  173. package/foundation/discovery/written-prop-values.mjs +258 -0
  174. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  175. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  176. package/foundation/fs/package-name.d.mts +10 -0
  177. package/foundation/fs/package-name.mjs +37 -0
  178. package/foundation/fs/project-source-files.d.mts +27 -0
  179. package/foundation/fs/project-source-files.mjs +115 -0
  180. package/foundation/fs/project-sources.d.mts +25 -0
  181. package/foundation/fs/project-sources.mjs +83 -0
  182. package/foundation/fs/read-record.d.mts +18 -0
  183. package/foundation/fs/read-record.mjs +36 -2
  184. package/foundation/integrations/integration-warnings.d.mts +39 -7
  185. package/foundation/integrations/integration-warnings.mjs +141 -19
  186. package/foundation/integrations/missing-dependency.d.mts +11 -0
  187. package/foundation/integrations/missing-dependency.mjs +20 -5
  188. package/foundation/release/folder-lock.d.mts +5 -2
  189. package/foundation/release/folder-lock.mjs +9 -3
  190. package/foundation/release/notices.mjs +2 -8
  191. package/foundation/render/cut-short.d.mts +8 -2
  192. package/foundation/render/cut-short.mjs +50 -5
  193. package/foundation/render/drawn-contrast.d.mts +38 -0
  194. package/foundation/render/drawn-contrast.mjs +237 -0
  195. package/foundation/render/file-header.mjs +4 -0
  196. package/foundation/render/layers.d.mts +2 -1
  197. package/foundation/render/layers.mjs +22 -1
  198. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  199. package/foundation/render/package-resolve-hooks.mjs +124 -32
  200. package/foundation/render/page-worker.mjs +95 -23
  201. package/foundation/render/part-boxes.d.mts +27 -0
  202. package/foundation/render/part-boxes.mjs +45 -0
  203. package/foundation/render/picture-chrome.mjs +36 -4
  204. package/foundation/render/picture-playwright.mjs +26 -2
  205. package/foundation/render/picture-window.d.mts +29 -2
  206. package/foundation/render/picture-window.mjs +99 -1
  207. package/foundation/render/render-page.d.mts +39 -6
  208. package/foundation/render/render-page.mjs +26 -10
  209. package/foundation/render/ts-paths.mjs +2 -1
  210. package/foundation/response/error-codes.doc.mjs +1 -1
  211. package/foundation/response/error-codes.mjs +1 -1
  212. package/foundation/response/response-types.doc.mjs +1 -1
  213. package/foundation/text/written-string.d.mts +4 -1
  214. package/foundation/text/written-string.mjs +4 -1
  215. package/package.json +8 -7
@@ -0,0 +1,376 @@
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,32 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /**
5
- * Split a printed command into its arguments, as a POSIX shell reads them:
6
- * single quotes (with `'\''` for a quote inside), double quotes and
7
- * backslashes. `null` when the quotes do not close.
8
- * @param {string} line
9
- * @returns {string[] | null}
10
- */
11
- export function splitCommand(line: string): string[] | null;
12
- /**
13
- * Read a suggested `set <slug> <thing> <value> [flags]` line; `null` when it
14
- * is not one this check can read (another command or theme, a placeholder,
15
- * an unknown flag): such a line is kept as it is.
16
- * @param {string} name
17
- * @param {string} slug
18
- */
19
- export function readSetLine(name: string, slug: string): {
20
- thing: string;
21
- value: string;
22
- flags: {
23
- on?: string;
24
- when?: string;
25
- state?: string;
26
- mode?: string;
27
- only?: boolean;
28
- };
29
- } | null;
30
4
  /**
31
5
  * Drop each `set` suggestion of a refusal that `set` itself would refuse,
32
6
  * checked against the theme as it is now (a copy: nothing is changed). Any
@@ -71,3 +45,6 @@ export function followLine(line: string, check: (line: string) => Promise<Astryx
71
45
  next?: import("../../foundation/response/base").Suggestion[];
72
46
  }>;
73
47
  import { AstryxError } from '../error.mjs';
48
+ import { readSetLine } from './_set-line.mjs';
49
+ import { splitCommand } from './_set-line.mjs';
50
+ export { readSetLine, splitCommand };
@@ -13,95 +13,9 @@ import {AstryxError} from '../error.mjs';
13
13
  import {checkSetting} from './_check.mjs';
14
14
  import {allowedLine} from './_normal.mjs';
15
15
  import {P} from './_tables.mjs';
16
+ import {readSetLine, splitCommand} from './_set-line.mjs';
16
17
 
17
- /**
18
- * Split a printed command into its arguments, as a POSIX shell reads them:
19
- * single quotes (with `'\''` for a quote inside), double quotes and
20
- * backslashes. `null` when the quotes do not close.
21
- * @param {string} line
22
- * @returns {string[] | null}
23
- */
24
- export function splitCommand(line) {
25
- /** @type {string[]} */
26
- const out = [];
27
- let cur = '';
28
- let has = false;
29
- for (let i = 0; i < line.length; i += 1) {
30
- const c = line[i];
31
- if (c === "'") {
32
- const end = line.indexOf("'", i + 1);
33
- if (end < 0) return null;
34
- cur += line.slice(i + 1, end);
35
- has = true;
36
- i = end;
37
- } else if (c === '"') {
38
- let j = i + 1;
39
- for (; j < line.length && line[j] !== '"'; j += 1) {
40
- if (line[j] === '\\' && j + 1 < line.length) j += 1;
41
- cur += line[j];
42
- }
43
- if (j >= line.length) return null;
44
- has = true;
45
- i = j;
46
- } else if (c === '\\' && i + 1 < line.length) {
47
- cur += line[i + 1];
48
- has = true;
49
- i += 1;
50
- } else if (/\s/.test(c)) {
51
- if (has) out.push(cur);
52
- cur = '';
53
- has = false;
54
- } else {
55
- cur += c;
56
- has = true;
57
- }
58
- }
59
- if (has) out.push(cur);
60
- return out;
61
- }
62
-
63
- const VALUE_FLAGS = new Set(['on', 'when', 'state', 'mode']);
64
-
65
- /**
66
- * Read a suggested `set <slug> <thing> <value> [flags]` line; `null` when it
67
- * is not one this check can read (another command or theme, a placeholder,
68
- * an unknown flag): such a line is kept as it is.
69
- * @param {string} name
70
- * @param {string} slug
71
- */
72
- export function readSetLine(name, slug) {
73
- const prefix = `${P} set ${slug} `;
74
- if (!name.startsWith(prefix)) return null;
75
- const rest = name.slice(prefix.length);
76
- // A placeholder (`<a color>`, `…`) is a pattern, not a command to run.
77
- if (/<[^>]*>|…/.test(rest)) return null;
78
- const args = splitCommand(rest);
79
- if (!args || !args.length) return null;
80
- /** @type {string[]} */
81
- const pos = [];
82
- /** @type {{on?: string, when?: string, state?: string, mode?: string, only?: boolean}} */
83
- const flags = {};
84
- for (let i = 0; i < args.length; i += 1) {
85
- const a = args[i];
86
- const m = /^--([a-z]+)(?:=(.*))?$/.exec(a);
87
- // A token (`--color-accent`) is the thing, not a flag.
88
- if (m && (VALUE_FLAGS.has(m[1]) || m[1] === 'only') && pos.length) {
89
- if (m[1] === 'only') {
90
- flags.only = true;
91
- continue;
92
- }
93
- const v = m[2] ?? args[(i += 1)];
94
- if (v == null) return null;
95
- /** @type {any} */ (flags)[m[1]] = v;
96
- } else if (m && pos.length) {
97
- // Some other flag (`--png`): not part of the setting.
98
- if (m[1] === 'png') continue;
99
- return null;
100
- } else pos.push(a);
101
- }
102
- if (pos.length > 2 || !pos.length) return null;
103
- return {thing: pos[0], value: pos[1] ?? '', flags};
104
- }
18
+ export {readSetLine, splitCommand};
105
19
 
106
20
  /**
107
21
  * Drop each `set` suggestion of a refusal that `set` itself would refuse,
@@ -130,7 +44,9 @@ export function vetSuggestions(e, ctx, slug, data) {
130
44
  structuredClone(data),
131
45
  line.thing,
132
46
  line.value,
133
- line.flags,
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},
134
50
  false,
135
51
  );
136
52
  return null;
@@ -7,7 +7,7 @@
7
7
  * inside it), a family (its members), a setting (a dial's rungs, a token's
8
8
  * type and readers, a CSS property), an aspect (colors, text, corners...: the
9
9
  * whole-theme tokens and dial), a plain-words question (exact commands), a
10
- * PNG picture (its main colors, or the color at points), or with `list` a
10
+ * PNG picture (its main colors and the look's traits measured from it, or the color at points), or with `list` a
11
11
  * list of dials, tokens, parts, families or CSS properties.
12
12
  * @experimental
13
13
  * @param {string} subject a part, family, setting, aspect, question, or PNG file; with `list`, a filter
@@ -16,7 +16,7 @@ import * as adapter from '../_adapter.mjs';
16
16
  * inside it), a family (its members), a setting (a dial's rungs, a token's
17
17
  * type and readers, a CSS property), an aspect (colors, text, corners...: the
18
18
  * whole-theme tokens and dial), a plain-words question (exact commands), a
19
- * PNG picture (its main colors, or the color at points), or with `list` a
19
+ * PNG picture (its main colors and the look's traits measured from it, or the color at points), or with `list` a
20
20
  * list of dials, tokens, parts, families or CSS properties.
21
21
  * @experimental
22
22
  * @param {string} subject a part, family, setting, aspect, question, or PNG file; with `list`, a filter
@@ -189,6 +189,14 @@ export type ThemeEditChangeData = {
189
189
  * - The setting written, or for `undo` the one removed.
190
190
  */
191
191
  setting: ThemeEditSetting;
192
+ /**
193
+ * - On `set` of a box shorthand a part takes one length of (a menu's `padding '5px 0'`): the value typed and the sides written for it in this change, `setting` being the first.
194
+ */
195
+ asSides?: {
196
+ thing: string;
197
+ value: string;
198
+ sides: ThemeEditSetting[];
199
+ } | undefined;
192
200
  /**
193
201
  * - On `undo`: what applies instead of the setting removed: a dial that still writes the token (such as the generated accent color), a whole-theme setting of the same thing, or the base theme's value.
194
202
  */
@@ -222,7 +230,7 @@ export type ThemeEditChangeData = {
222
230
  onlyHint: boolean;
223
231
  } | null;
224
232
  /**
225
- * - Resolved token changes, `name (mode): before -> after`.
233
+ * - Resolved token changes, `name (mode): before -> after`. The category colors (badges, tokens, card tints) and chart colors that moved with the look are counted in one line each.
226
234
  */
227
235
  changedTokens: string[];
228
236
  /**
@@ -252,6 +260,13 @@ export type ThemeEditChangeData = {
252
260
  note: string;
253
261
  run: string[];
254
262
  }>;
263
+ /**
264
+ * - The open fonts this set names whose package is not installed, each with the command that installs it; the previews and the app draw the next font in the stack until then. Left out when every one loads. The text output prints it right under the status line.
265
+ */
266
+ fontNotLoaded?: {
267
+ family: string;
268
+ run: string[];
269
+ }[] | undefined;
255
270
  /**
256
271
  * - Text this theme made unreadable (below 4.5:1, and not that low in the base theme).
257
272
  */
@@ -260,6 +275,10 @@ export type ThemeEditChangeData = {
260
275
  * - What this change made unreadable or unseen, each with the command that fixes it: text and borders that read well before it, and the contrast checks the colors it made fail; with `png`, text the sample page's pictures draw cut short, with `flex-shrink 0` on its part when the browser measured that drawing it whole. The text output leads with them, under the status line.
261
276
  */
262
277
  newProblems: ThemeEditProblem[];
278
+ /**
279
+ * - Problems the theme had that this change moved but left failing (a fill made darker, still not dark enough), each with what it was and the command that fixes it; left out when none. The text output says them under the new problems.
280
+ */
281
+ leftProblems?: ThemeEditProblem[] | undefined;
263
282
  /**
264
283
  * - How many misses the theme's own changes left (show --json lists each, with the line that reaches it); the text output counts them near its top.
265
284
  */
@@ -276,6 +295,10 @@ export type ThemeEditChangeData = {
276
295
  * - Where each of those parts keeps the base theme's look: the part, the variant its miss is in when it is one (`type:error`), then the state, or `at rest`; the text output names them.
277
296
  */
278
297
  missedWhere?: string[] | undefined;
298
+ /**
299
+ * - How many of those misses this change brought (not there before it); the text output says the missed line only when it brought one.
300
+ */
301
+ missedNew?: number | undefined;
279
302
  /**
280
303
  * - Warnings from the theme build.
281
304
  */
@@ -601,6 +624,35 @@ export type ThemeEditHowOptions = {
601
624
  */
602
625
  words?: string[] | undefined;
603
626
  };
627
+ /**
628
+ * One result of a plain-words question (`data.results`, `kind: 'question'`).
629
+ */
630
+ export type ThemeEditHowResult = {
631
+ /**
632
+ * - What the result does, or why it does nothing.
633
+ */
634
+ text: string;
635
+ /**
636
+ * - The commands, each checked as `set` checks it.
637
+ */
638
+ commands: string[];
639
+ /**
640
+ * - Run every command in order.
641
+ */
642
+ sequence?: boolean | undefined;
643
+ /**
644
+ * - Commands left out, with the reason.
645
+ */
646
+ refused?: {
647
+ command: string;
648
+ why: string;
649
+ run?: string[];
650
+ }[] | undefined;
651
+ /**
652
+ * - More than the ask (a colored variant changed too): never first, never the answer itself.
653
+ */
654
+ offer?: boolean | undefined;
655
+ };
604
656
  /**
605
657
  * `astryx --json experimental theme editor how <subject>`. `kind` says which answer it is.
606
658
  */
@@ -609,6 +661,7 @@ export type ThemeEditHowResponse = {
609
661
  data: {
610
662
  kind: "part" | "group" | "setting" | "aspect" | "question" | "picture" | "list";
611
663
  subject: string;
664
+ results?: ThemeEditHowResult[];
612
665
  [key: string]: any;
613
666
  };
614
667
  };