@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
@@ -1,6 +1,17 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The missing package, the package that needs it and the importing file,
6
+ * when that package declares the missing one: a broken install.
7
+ * @param {string} message
8
+ * @returns {{name: string, requiredBy: string, importer: string} | null}
9
+ */
10
+ export function brokenInstall(message: string): {
11
+ name: string;
12
+ requiredBy: string;
13
+ importer: string;
14
+ } | null;
4
15
  /**
5
16
  * The missing package's name when the package that imports it declares it.
6
17
  * @param {string} message
@@ -14,9 +14,12 @@
14
14
  * design, so a manifest that needs either has a packaging bug, which
15
15
  * reinstalling does not clear. A package listed both as a dependency and
16
16
  * as an optional one is optional, as npm reads it.
17
+ * `brokenInstall(message)`: the same finding with the package that needs
18
+ * it and the importing file.
17
19
  * @position Read by the project (foundation/config/project.mjs) to tell an
18
20
  * install the user can repair from a dependency's own packaging bug, which
19
- * stays out of the project's issues.
21
+ * stays out of the project's issues, and by the API's broken-install
22
+ * refusal (api/error.mjs).
20
23
  */
21
24
 
22
25
  import * as fs from 'node:fs';
@@ -73,11 +76,12 @@ function parse(message) {
73
76
  }
74
77
 
75
78
  /**
76
- * The missing package's name when the package that imports it declares it.
79
+ * The missing package, the package that needs it and the importing file,
80
+ * when that package declares the missing one: a broken install.
77
81
  * @param {string} message
78
- * @returns {string | null}
82
+ * @returns {{name: string, requiredBy: string, importer: string} | null}
79
83
  */
80
- export function missingDeclaredDependency(message) {
84
+ export function brokenInstall(message) {
81
85
  const found = parse(message);
82
86
  if (!found) return null;
83
87
  let dir = path.dirname(found.importer);
@@ -87,7 +91,9 @@ export function missingDeclaredDependency(message) {
87
91
  try {
88
92
  const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
89
93
  if (typeof pkg?.name === 'string') {
90
- return requires(pkg, found.name) ? found.name : null;
94
+ return requires(pkg, found.name)
95
+ ? {name: found.name, requiredBy: pkg.name, importer: found.importer}
96
+ : null;
91
97
  }
92
98
  } catch {
93
99
  return null;
@@ -98,3 +104,12 @@ export function missingDeclaredDependency(message) {
98
104
  dir = parent;
99
105
  }
100
106
  }
107
+
108
+ /**
109
+ * The missing package's name when the package that imports it declares it.
110
+ * @param {string} message
111
+ * @returns {string | null}
112
+ */
113
+ export function missingDeclaredDependency(message) {
114
+ return brokenInstall(message)?.name ?? null;
115
+ }
@@ -16,11 +16,14 @@ export function stillHolds(): void;
16
16
  * @template T
17
17
  * @param {string} lockDir
18
18
  * @param {() => Promise<T>} fn
19
- * @param {{waitMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
19
+ * @param {{waitMs?: number, silentMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
20
+ * `silentMs`: how long a record may stand unrenewed before a holder that
21
+ * does not run here is taken over ({@link SILENT_MS})
20
22
  * @returns {Promise<T>}
21
23
  */
22
- export function withFolderLock<T>(lockDir: string, fn: () => Promise<T>, { waitMs, onBusy }: {
24
+ export function withFolderLock<T>(lockDir: string, fn: () => Promise<T>, { waitMs, silentMs, onBusy }: {
23
25
  waitMs?: number;
26
+ silentMs?: number;
24
27
  onBusy: (owner: any, heldSeconds: number | null) => never;
25
28
  }): Promise<T>;
26
29
  /** How long a held lock's record may stand unrenewed before it is taken over. */
@@ -111,10 +111,16 @@ const readOwner = file => {
111
111
  * @template T
112
112
  * @param {string} lockDir
113
113
  * @param {() => Promise<T>} fn
114
- * @param {{waitMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
114
+ * @param {{waitMs?: number, silentMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
115
+ * `silentMs`: how long a record may stand unrenewed before a holder that
116
+ * does not run here is taken over ({@link SILENT_MS})
115
117
  * @returns {Promise<T>}
116
118
  */
117
- export async function withFolderLock(lockDir, fn, {waitMs = 30_000, onBusy}) {
119
+ export async function withFolderLock(
120
+ lockDir,
121
+ fn,
122
+ {waitMs = 30_000, silentMs = SILENT_MS, onBusy},
123
+ ) {
118
124
  const ownerFile = path.join(lockDir, 'owner.json');
119
125
  /** @returns {number | null} seconds since the holder took the lock */
120
126
  const held = () => {
@@ -141,7 +147,7 @@ export async function withFolderLock(lockDir, fn, {waitMs = 30_000, onBusy}) {
141
147
  const judged = lockIdentity(lockDir);
142
148
  if (
143
149
  judged &&
144
- foreignLockIsSilent(lockDir, Date.now(), SILENT_MS) &&
150
+ foreignLockIsSilent(lockDir, Date.now(), silentMs) &&
145
151
  !aliveHere(readOwner(ownerFile))
146
152
  ) {
147
153
  takeOver(lockDir, judged);
@@ -75,6 +75,7 @@ import {
75
75
  readReleaseFacts,
76
76
  } from './project.mjs';
77
77
  import {samePath} from '../fs/path-compare.mjs';
78
+ import {readOfficialList} from '../discovery/official-list.mjs';
78
79
  import {updateNoticesOff} from './update-notice-env.mjs';
79
80
  import {binStartedRun} from './run-context.mjs';
80
81
  import {installGuidanceFor} from '../env/cli-command.mjs';
@@ -527,14 +528,7 @@ function officialPackages() {
527
528
  /** @type {any} */
528
529
  let list;
529
530
  try {
530
- // Built here, not at load: paths.mjs and this module load each other.
531
- const file = path.join(
532
- CLI_ROOT,
533
- 'assets',
534
- 'discover',
535
- 'official-packages.json',
536
- );
537
- list = JSON.parse(fs.readFileSync(file, 'utf8'));
531
+ list = readOfficialList();
538
532
  } catch {
539
533
  return [];
540
534
  }
@@ -15,21 +15,27 @@
15
15
  * narrower than the word) comes back too, the word as its `text`, with
16
16
  * `broken`; a word broken where it may break (at a hyphen, a slash, a soft
17
17
  * hyphen) is not counted.
18
+ * A text that runs past the side of its own box onto the text of a box
19
+ * beside it (weekday names wider than their calendar column) comes back
20
+ * too, with `overlaps`. Boxes placed out of the flow (absolute or fixed)
21
+ * are left out: they overlap on purpose.
18
22
  * Runs in the page: it uses nothing from outside its own body.
19
- * @returns {Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>}
23
+ * @returns {Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>}
20
24
  */
21
25
  export function cutShortText(): Array<{
22
26
  part: string | null;
23
27
  text: string;
24
28
  whole: boolean;
25
29
  broken?: boolean;
30
+ overlaps?: boolean;
26
31
  }>;
27
32
  /**
28
33
  * @file The text a picture's page draws cut short, measured in the page.
29
34
  * @input None: `cutShortText` runs in the page the picture is taken of.
30
35
  * @output `cutShortText`: each text the browser draws cut short (an ellipsis
31
36
  * or a line clamp, or text drawn past the side of a box that clips it),
32
- * and each word it breaks across two lines inside the word (`broken`),
37
+ * each word it breaks across two lines inside the word (`broken`), and
38
+ * each text drawn over its neighbor's text (`overlaps`),
33
39
  * with the part it sits in and whether keeping that part's width
34
40
  * (`flex-shrink: 0` on it, the line the editor offers) draws it whole;
35
41
  * `CUT_SHORT_PREFIX`, the line prefix a picture script prints it after.
@@ -5,7 +5,8 @@
5
5
  * @input None: `cutShortText` runs in the page the picture is taken of.
6
6
  * @output `cutShortText`: each text the browser draws cut short (an ellipsis
7
7
  * or a line clamp, or text drawn past the side of a box that clips it),
8
- * and each word it breaks across two lines inside the word (`broken`),
8
+ * each word it breaks across two lines inside the word (`broken`), and
9
+ * each text drawn over its neighbor's text (`overlaps`),
9
10
  * with the part it sits in and whether keeping that part's width
10
11
  * (`flex-shrink: 0` on it, the line the editor offers) draws it whole;
11
12
  * `CUT_SHORT_PREFIX`, the line prefix a picture script prints it after.
@@ -33,8 +34,12 @@ export const CUT_SHORT_PREFIX = 'astryx-cut-short:';
33
34
  * narrower than the word) comes back too, the word as its `text`, with
34
35
  * `broken`; a word broken where it may break (at a hyphen, a slash, a soft
35
36
  * hyphen) is not counted.
37
+ * A text that runs past the side of its own box onto the text of a box
38
+ * beside it (weekday names wider than their calendar column) comes back
39
+ * too, with `overlaps`. Boxes placed out of the flow (absolute or fixed)
40
+ * are left out: they overlap on purpose.
36
41
  * Runs in the page: it uses nothing from outside its own body.
37
- * @returns {Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>}
42
+ * @returns {Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>}
38
43
  */
39
44
  export function cutShortText() {
40
45
  /** @param {Element} el */
@@ -124,13 +129,48 @@ export function cutShortText() {
124
129
  }
125
130
  return out;
126
131
  };
127
- /** @type {Array<{el: HTMLElement, part: string | null, text: string, broken?: boolean}>} */
132
+ /** Whether a box sits in the flow (not absolute or fixed). @param {Element} el */
133
+ const inFlow = el =>
134
+ !/^(?:absolute|fixed)$/.test(getComputedStyle(el).position);
135
+ /** The boxes of a node's text, one for each line. @param {Node} node */
136
+ const textBoxes = node => {
137
+ const range = document.createRange();
138
+ range.selectNodeContents(node);
139
+ return [...range.getClientRects()].filter(r => r.width > 0 && r.height > 0);
140
+ };
141
+ /**
142
+ * Own text drawn past the side of its own box and over the text of a box
143
+ * beside it (a sibling in the flow).
144
+ * @param {HTMLElement} el
145
+ */
146
+ const overlapping = el => {
147
+ if (!ownText(el) || !inFlow(el) || !el.parentElement) return false;
148
+ const box = el.getBoundingClientRect();
149
+ const own = textBoxes(el);
150
+ // Any reach past the box counts: letters a fraction of a pixel into the
151
+ // next box already touch its text.
152
+ if (!own.some(t => t.left < box.left - 0.1 || t.right > box.right + 0.1))
153
+ return false;
154
+ for (const sib of el.parentElement.children) {
155
+ if (sib === el || !inFlow(sib) || !drawn(sib)) continue;
156
+ for (const s of textBoxes(sib))
157
+ for (const t of own) {
158
+ const w = Math.min(t.right, s.right) - Math.max(t.left, s.left);
159
+ const h = Math.min(t.bottom, s.bottom) - Math.max(t.top, s.top);
160
+ if (w > 0.1 && h > 1) return true;
161
+ }
162
+ }
163
+ return false;
164
+ };
165
+ /** @type {Array<{el: HTMLElement, part: string | null, text: string, broken?: boolean, overlaps?: boolean}>} */
128
166
  const found = [];
129
167
  for (const el of document.body.querySelectorAll('*')) {
130
168
  if (!(el instanceof HTMLElement)) continue;
131
169
  const text = (el.textContent ?? '').replace(/\s+/g, ' ').trim();
132
170
  if (!text || !drawn(el)) continue;
133
171
  if (cutShort(el)) found.push({el, part: partOf(el), text});
172
+ else if (overlapping(el))
173
+ found.push({el, part: partOf(el), text, overlaps: true});
134
174
  else
135
175
  for (const word of brokenWords(el))
136
176
  found.push({el, part: partOf(el), text: word, broken: true});
@@ -150,15 +190,20 @@ export function cutShortText() {
150
190
  found
151
191
  .filter(f => f.part === part)
152
192
  .every(f =>
153
- f.broken ? !brokenWords(f.el).includes(f.text) : !cutShort(f.el),
193
+ f.broken
194
+ ? !brokenWords(f.el).includes(f.text)
195
+ : f.overlaps
196
+ ? !overlapping(f.el)
197
+ : !cutShort(f.el),
154
198
  ),
155
199
  );
156
200
  keep.remove();
157
201
  }
158
- return found.map(({part, text, broken}) => ({
202
+ return found.map(({part, text, broken, overlaps}) => ({
159
203
  part,
160
204
  text,
161
205
  whole: whole.get(part) ?? false,
162
206
  ...(broken ? {broken: true} : {}),
207
+ ...(overlaps ? {overlaps: true} : {}),
163
208
  }));
164
209
  }
@@ -0,0 +1,40 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Each text the page draws too faint to read: its own color, composited
6
+ * over what is drawn behind it (the fills of the boxes around it, from the
7
+ * page up), under 4.5:1, or 3:1 for large text (24px, or 18.66px bold).
8
+ * Text that is not drawn (no box, hidden), text in a disabled control or
9
+ * under a box drawn see-through (a disabled look), text in the theme's
10
+ * disabled or placeholder color (which needs no 4.5:1), and text over an
11
+ * image, a picture, a gradient between colors or a layer that covers only
12
+ * part of its box (no one color behind it) are left out. A flat tint over
13
+ * the whole box (a pressed state's one-color gradient) is a fill. `part` is
14
+ * the nearest Astryx part the text sits in (its `astryx-<part>` class); text in
15
+ * no part (a sheet's own labels) is left out. One entry for each part,
16
+ * text and pair of colors.
17
+ * Runs in the page: it uses nothing from outside its own body.
18
+ * @returns {Array<{part: string, text: string, ratio: number, fg: string, bg: string}>}
19
+ */
20
+ export function lowContrastText(): Array<{
21
+ part: string;
22
+ text: string;
23
+ ratio: number;
24
+ fg: string;
25
+ bg: string;
26
+ }>;
27
+ /**
28
+ * @file The text a picture's page draws too faint to read, measured in the
29
+ * page.
30
+ * @input None: `lowContrastText` runs in the page the picture is taken of.
31
+ * @output `lowContrastText`: each text the browser draws under the contrast
32
+ * text needs (4.5:1, or 3:1 when large), with the part it sits in and the
33
+ * two colors as drawn; `LOW_CONTRAST_PREFIX`, the line prefix a picture
34
+ * script prints it after.
35
+ * @position run by picture-chrome.mjs and picture-playwright.mjs once the
36
+ * page is drawn as the picture shows it; read back by `screenshot` in
37
+ * api/theme-edit/_preview.mjs from the script's stdout
38
+ */
39
+ /** The line prefix a picture script prints the measurement after. */
40
+ export const LOW_CONTRAST_PREFIX: "astryx-low-contrast:";
@@ -0,0 +1,355 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The text a picture's page draws too faint to read, measured in the
5
+ * page.
6
+ * @input None: `lowContrastText` runs in the page the picture is taken of.
7
+ * @output `lowContrastText`: each text the browser draws under the contrast
8
+ * text needs (4.5:1, or 3:1 when large), with the part it sits in and the
9
+ * two colors as drawn; `LOW_CONTRAST_PREFIX`, the line prefix a picture
10
+ * script prints it after.
11
+ * @position run by picture-chrome.mjs and picture-playwright.mjs once the
12
+ * page is drawn as the picture shows it; read back by `screenshot` in
13
+ * api/theme-edit/_preview.mjs from the script's stdout
14
+ */
15
+
16
+ /* global document, getComputedStyle -- lowContrastText runs in the page */
17
+
18
+ /** The line prefix a picture script prints the measurement after. */
19
+ export const LOW_CONTRAST_PREFIX = 'astryx-low-contrast:';
20
+
21
+ /**
22
+ * Each text the page draws too faint to read: its own color, composited
23
+ * over what is drawn behind it (the fills of the boxes around it, from the
24
+ * page up), under 4.5:1, or 3:1 for large text (24px, or 18.66px bold).
25
+ * Text that is not drawn (no box, hidden), text in a disabled control or
26
+ * under a box drawn see-through (a disabled look), text in the theme's
27
+ * disabled or placeholder color (which needs no 4.5:1), and text over an
28
+ * image, a picture, a gradient between colors or a layer that covers only
29
+ * part of its box (no one color behind it) are left out. A flat tint over
30
+ * the whole box (a pressed state's one-color gradient) is a fill. `part` is
31
+ * the nearest Astryx part the text sits in (its `astryx-<part>` class); text in
32
+ * no part (a sheet's own labels) is left out. One entry for each part,
33
+ * text and pair of colors.
34
+ * Runs in the page: it uses nothing from outside its own body.
35
+ * @returns {Array<{part: string, text: string, ratio: number, fg: string, bg: string}>}
36
+ */
37
+ export function lowContrastText() {
38
+ /** @param {string} v @returns {[number, number, number, number] | null} */
39
+ const rgba = v => {
40
+ const m =
41
+ /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(
42
+ v.trim(),
43
+ );
44
+ const c =
45
+ /^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+%?))?\s*\)$/.exec(
46
+ v.trim(),
47
+ );
48
+ /** @param {string | undefined} a */
49
+ const alpha = a =>
50
+ a == null
51
+ ? 1
52
+ : a.endsWith('%')
53
+ ? Number(a.slice(0, -1)) / 100
54
+ : Number(a);
55
+ if (m) return [Number(m[1]), Number(m[2]), Number(m[3]), alpha(m[4])];
56
+ if (c)
57
+ return [
58
+ Number(c[1]) * 255,
59
+ Number(c[2]) * 255,
60
+ Number(c[3]) * 255,
61
+ alpha(c[4]),
62
+ ];
63
+ return null;
64
+ };
65
+ /** @param {number[]} top @param {number[]} under */
66
+ const over = (top, under) =>
67
+ [0, 1, 2].map(i => top[i] * top[3] + under[i] * (1 - top[3]));
68
+ /** @param {number[]} c */
69
+ const lum = c => {
70
+ const [r, g, b] = c.map(v => {
71
+ const s = v / 255;
72
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
73
+ });
74
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
75
+ };
76
+ /** @param {number[]} a @param {number[]} b */
77
+ const ratio = (a, b) => {
78
+ const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p);
79
+ return (x + 0.05) / (y + 0.05);
80
+ };
81
+ /** @param {number[]} c */
82
+ const hex = c =>
83
+ `#${c.map(v => Math.round(v).toString(16).padStart(2, '0')).join('')}`;
84
+ /** @param {Element} el */
85
+ const partOf = el => {
86
+ for (let a = /** @type {Element | null} */ (el); a; a = a.parentElement) {
87
+ const named = [...a.classList].find(
88
+ c => c.startsWith('astryx-') && !c.startsWith('astryx-theme'),
89
+ );
90
+ if (named) return named.slice('astryx-'.length);
91
+ }
92
+ return null;
93
+ };
94
+ /** Whether two rectangles overlap. @param {DOMRect} p @param {DOMRect} q */
95
+ const meet = (p, q) =>
96
+ p.left < q.right &&
97
+ q.left < p.right &&
98
+ p.top < q.bottom &&
99
+ q.top < p.bottom;
100
+ /**
101
+ * What is drawn behind an element's text, as one color, or null: a box
102
+ * around it see-through or hidden, disabled, or drawn with an image that
103
+ * is not one flat color over the whole box, before an opaque fill.
104
+ * @param {Element} el
105
+ */
106
+ const behind = el => {
107
+ /** @type {Array<[number, number, number, number]>} */
108
+ const fills = [];
109
+ for (let a = /** @type {Element | null} */ (el); a; a = a.parentElement) {
110
+ const cs = getComputedStyle(a);
111
+ if (
112
+ Number(cs.opacity) < 1 ||
113
+ a.matches(':disabled, [aria-disabled="true"], [inert]')
114
+ )
115
+ return null;
116
+ if (cs.display === 'contents') continue;
117
+ if (a !== document.documentElement) {
118
+ const r = a.getBoundingClientRect();
119
+ if (r.width < 2 || r.height < 2 || cs.visibility !== 'visible')
120
+ return null;
121
+ }
122
+ // (A flat tint drawn as an image, a hover or pressed state's
123
+ // one-color gradient, is a fill like any other, drawn over the
124
+ // box's color; any other image leaves no one color behind.)
125
+ const tints = flatLayers(cs, a.getBoundingClientRect());
126
+ if (!tints) return null;
127
+ const f = rgba(cs.backgroundColor);
128
+ // (Drawn bottom first: the box's color, then its layers, the last
129
+ // listed lowest; fills are gathered top first.)
130
+ const own = [...(f && f[3] > 0 ? [f] : []), ...[...tints].reverse()];
131
+ fills.push(...own.reverse());
132
+ if (own.some(x => x[3] >= 1)) break;
133
+ }
134
+ let under = [255, 255, 255];
135
+ for (const f of fills.reverse()) under = over(f, under);
136
+ return under;
137
+ };
138
+ /**
139
+ * A box's image layers when each is one flat color (a gradient whose
140
+ * stops are all the same color) that covers the whole box, top layer
141
+ * first; [] for none. A layer that draws nothing (a size of 0) is left
142
+ * out. null for any other image: a picture, a gradient between colors, or
143
+ * a flat layer that covers only part of the box (an underline).
144
+ * @param {CSSStyleDeclaration} cs the box's computed style
145
+ * @param {DOMRect} box the box
146
+ * @returns {Array<[number, number, number, number]> | null}
147
+ */
148
+ const flatLayers = (cs, box) => {
149
+ const bgi = cs.backgroundImage;
150
+ if (!bgi || bgi === 'none') return [];
151
+ /** @type {string[]} */
152
+ const layers = [];
153
+ let depth = 0;
154
+ let start = 0;
155
+ for (let i = 0; i < bgi.length; i++) {
156
+ if (bgi[i] === '(') depth++;
157
+ else if (bgi[i] === ')') depth--;
158
+ else if (bgi[i] === ',' && depth === 0) {
159
+ layers.push(bgi.slice(start, i));
160
+ start = i + 1;
161
+ }
162
+ }
163
+ layers.push(bgi.slice(start));
164
+ /** @type {Array<[number, number, number, number]>} */
165
+ const out = [];
166
+ for (const [n, layer] of layers.entries()) {
167
+ if (!/^\s*(?:linear|radial)-gradient\(/.test(layer)) return null;
168
+ const covers = coverage(cs, n, box);
169
+ if (covers === 'none') continue;
170
+ if (covers === 'part') return null;
171
+ const colors = (
172
+ layer.match(
173
+ /(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)/g,
174
+ ) ?? []
175
+ ).map(rgba);
176
+ if (!colors.length || colors.some(c => c == null)) return null;
177
+ const [first] = /** @type {Array<[number, number, number, number]>} */ (
178
+ colors
179
+ );
180
+ if (
181
+ colors.some(c =>
182
+ /** @type {number[]} */ (c).some(
183
+ (v, i) => Math.abs(v - first[i]) > 0.5 / (i === 3 ? 255 : 1),
184
+ ),
185
+ )
186
+ )
187
+ return null;
188
+ out.push(first);
189
+ }
190
+ return out;
191
+ };
192
+ /**
193
+ * How much of a box one of its image layers covers: 'all', 'part' or
194
+ * 'none'. A gradient has no size of its own: it fills its size (the whole
195
+ * box by default) once, or tiles it where it repeats.
196
+ * @param {CSSStyleDeclaration} cs @param {number} n the layer, top first
197
+ * @param {DOMRect} box
198
+ * @returns {'all' | 'part' | 'none'}
199
+ */
200
+ const coverage = (cs, n, box) => {
201
+ /** @param {string} list */
202
+ const nth = list => {
203
+ const items = list.split(',').map(x => x.trim());
204
+ return items[n % items.length] ?? '';
205
+ };
206
+ const size = nth(cs.backgroundSize).split(/\s+/);
207
+ const rep = nth(cs.backgroundRepeat).split(/\s+/);
208
+ const repeats =
209
+ rep[0] === 'repeat-x'
210
+ ? [true, false]
211
+ : rep[0] === 'repeat-y'
212
+ ? [false, true]
213
+ : [rep[0], rep[1] ?? rep[0]].map(
214
+ r => r === 'repeat' || r === 'round',
215
+ );
216
+ const pos = [nth(cs.backgroundPositionX), nth(cs.backgroundPositionY)];
217
+ // (Only a plain length or percentage is read: a size or a place the
218
+ // browser keeps as calc(), or an edge keyword with an offset, is taken
219
+ // as covering part of the box.)
220
+ const plain = /^-?[\d.]+(px|%)?$/;
221
+ let part = false;
222
+ for (const [i, whole] of [box.width, box.height].entries()) {
223
+ const s =
224
+ size[0] === 'cover' || size[0] === 'contain'
225
+ ? 'auto'
226
+ : (size[i] ?? 'auto');
227
+ if (s !== 'auto' && !plain.test(s)) return 'part';
228
+ const len =
229
+ s === 'auto'
230
+ ? whole
231
+ : s.endsWith('%')
232
+ ? (parseFloat(s) / 100) * whole
233
+ : parseFloat(s);
234
+ if (!(len > 0)) return 'none';
235
+ if (repeats[i]) continue;
236
+ const at = pos[i] || '0%';
237
+ if (!plain.test(at)) return 'part';
238
+ const offset = at.endsWith('%')
239
+ ? (parseFloat(at) / 100) * (whole - len)
240
+ : parseFloat(at) || 0;
241
+ // (It covers the box when it holds it whole, wherever it is placed.)
242
+ if (offset > 0.5 || offset + len < whole - 0.5) part = true;
243
+ }
244
+ return part ? 'part' : 'all';
245
+ };
246
+ /**
247
+ * The page's images, pictures and boxes with a background image (a
248
+ * gradient or a tint), with their boxes, read once when first asked: a
249
+ * page has many texts and few of them fail.
250
+ * @type {Array<[Element, DOMRect]> | null}
251
+ */
252
+ let media = null;
253
+ /**
254
+ * Whether an image, a picture, a gradient or a tint is drawn over or under
255
+ * an element's text from a box beside it (media under an overlay's
256
+ * scrim): then no one color is behind the text.
257
+ * @param {Element} el
258
+ */
259
+ const overImage = el => {
260
+ media ??= [...document.querySelectorAll('body *')]
261
+ .filter(m => {
262
+ if (m.matches('img, picture, video, canvas, svg image')) return true;
263
+ // (A box beside the text draws over or under it whatever its
264
+ // image, a flat tint too: no one color is known behind the text.)
265
+ return getComputedStyle(m).backgroundImage !== 'none';
266
+ })
267
+ .map(
268
+ m => /** @type {[Element, DOMRect]} */ ([m, m.getBoundingClientRect()]),
269
+ );
270
+ const box = el.getBoundingClientRect();
271
+ return media.some(
272
+ ([m, r]) => !m.contains(el) && !el.contains(m) && meet(r, box),
273
+ );
274
+ };
275
+ /**
276
+ * Whether a color is the theme's disabled or placeholder text color where
277
+ * an element sits (read from a probe there, as the page resolves it).
278
+ * @param {Element} el @param {number[]} c
279
+ */
280
+ const exempt = (el, c) => {
281
+ // (One probe for each theme scope and color: the tokens are the
282
+ // scope's.)
283
+ const scope = el.closest('[data-astryx-theme], [data-theme]');
284
+ const key = hex(c);
285
+ const known = exemptSeen.get(scope)?.get(key);
286
+ if (known != null) return known;
287
+ const said = exemptAt(el, c);
288
+ if (!exemptSeen.has(scope)) exemptSeen.set(scope, new Map());
289
+ /** @type {Map<string, boolean>} */ (exemptSeen.get(scope)).set(key, said);
290
+ return said;
291
+ };
292
+ /** @type {Map<Element | null, Map<string, boolean>>} */
293
+ const exemptSeen = new Map();
294
+ /** @param {Element} el @param {number[]} c */
295
+ const exemptAt = (el, c) => {
296
+ const probe = document.createElement('span');
297
+ el.appendChild(probe);
298
+ try {
299
+ return [
300
+ '--color-text-disabled',
301
+ '--color-icon-disabled',
302
+ '--color-text-placeholder',
303
+ ].some(t => {
304
+ // (A token the page does not set gives the fallback, never the
305
+ // color the probe would inherit.)
306
+ probe.style.color = `var(${t}, rgb(1, 2, 3))`;
307
+ const v = rgba(getComputedStyle(probe).color);
308
+ return (
309
+ v != null &&
310
+ !(v[0] === 1 && v[1] === 2 && v[2] === 3) &&
311
+ v.slice(0, 3).every((x, i) => Math.abs(x - c[i]) < 1)
312
+ );
313
+ });
314
+ } finally {
315
+ probe.remove();
316
+ }
317
+ };
318
+ /** @type {Map<string, {part: string, text: string, ratio: number, fg: string, bg: string}>} */
319
+ const found = new Map();
320
+ for (const el of document.querySelectorAll('body *')) {
321
+ const text = [...el.childNodes]
322
+ .filter(n => n.nodeType === 3)
323
+ .map(n => (n.textContent ?? '').trim())
324
+ .join(' ')
325
+ .trim();
326
+ if (!text) continue;
327
+ const part = partOf(el);
328
+ if (!part) continue;
329
+ const cs = getComputedStyle(el);
330
+ const fg = rgba(cs.color);
331
+ if (!fg || fg[3] === 0) continue;
332
+ const bg = behind(el);
333
+ if (!bg) continue;
334
+ const shown = over(fg, bg);
335
+ const r = ratio(shown, bg);
336
+ const size = parseFloat(cs.fontSize);
337
+ const large = size >= 24 || (size >= 18.66 && Number(cs.fontWeight) >= 700);
338
+ if (r >= (large ? 3 : 4.5)) continue;
339
+ // (The same text in the same colors is reported once. A copy left out,
340
+ // one over a picture or in a disabled color, says nothing of a later
341
+ // copy drawn faint on a plain ground: only a reported one is skipped.)
342
+ const key = `${part}\u0000${text}\u0000${hex(shown)}\u0000${hex(bg)}`;
343
+ if (found.has(key)) continue;
344
+ if (exempt(el, fg) || overImage(el)) continue;
345
+ found.set(key, {
346
+ part,
347
+ text: text.slice(0, 40),
348
+ ratio: Math.floor(r * 100) / 100,
349
+ fg: hex(shown),
350
+ bg: hex(bg),
351
+ });
352
+ if (found.size >= 60) break;
353
+ }
354
+ return [...found.values()];
355
+ }
@@ -91,6 +91,10 @@ export function headerNote(facts) {
91
91
  ' command with the folder it wrote:',
92
92
  ` ${run} experimental export ${shellArg(facts.restored)} --out ${file}${title}`,
93
93
  ...(facts.title !== undefined && !quotable ? [' The page was rendered with --title; step 1 prints the command with it.'] : []),
94
+ `To work offline later, install the CLI for your computer while online (${run} docs global/install-once):`,
95
+ ` npm install --global @astryxdesign/cli@${facts.cli ?? 'latest'}`,
96
+ ' Then, still online, run steps 1 and 3 once as astryx, so it keeps the Core a render needs.',
97
+ ' Offline, run the same commands as astryx: npx cannot fetch the CLI without a network.',
94
98
  `If you have the project, edit ${facts.page} there instead, and render it in the same way.`,
95
99
  "Inside a project, the project's own CLI answers these commands. A project CLI older than",
96
100
  `${facts.cli ?? 'the one that rendered this file'} writes the page without this note; to keep the note, update that CLI first:`,