@astryxdesign/cli 0.7.17 → 0.7.18-canary.g57306fd
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.
- package/README.md +1 -1
- package/api/discover/_adapter.d.mts +7 -5
- package/api/discover/_adapter.mjs +12 -11
- package/api/docs/_adapter.d.mts +19 -2
- package/api/docs/_adapter.mjs +66 -5
- package/api/doctor/_adapter.d.mts +11 -62
- package/api/doctor/_adapter.mjs +242 -472
- package/api/doctor/doctor.d.mts +1 -1
- package/api/doctor/doctor.mjs +3 -3
- package/api/doctor/theme-checks.mjs +37 -45
- package/api/error.d.mts +21 -0
- package/api/error.mjs +89 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +8 -0
- package/api/icon/_adapter.mjs +17 -0
- package/api/icon/_authoring.mjs +6 -6
- package/api/icon/_default-look.mjs +16 -16
- package/api/icon/add/add.mjs +3 -3
- package/api/icon/exportIconIndex.doc.mjs +2 -2
- package/api/icon/icon.doc.mjs +2 -2
- package/api/icon/icon.type.d.mts +4 -0
- package/api/icon/icon.type.mjs +2 -1
- package/api/icon/search/icon-index.mjs +16 -3
- package/api/icon/search/search.d.mts +15 -5
- package/api/icon/search/search.mjs +74 -16
- package/api/icon/use/use.mjs +4 -4
- package/api/render/_adapter.mjs +233 -40
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.mjs +4 -0
- package/api/search/_candidate-score.mjs +32 -8
- package/api/search/_cards.json +1 -1
- package/api/search/_compound.d.mts +0 -1
- package/api/search/_compound.mjs +93 -2
- package/api/search/_icons.d.mts +4 -2
- package/api/search/_icons.mjs +4 -2
- package/api/search/_lexical.mjs +177 -17
- package/api/search/_order.d.mts +3 -1
- package/api/search/_order.mjs +16 -5
- package/api/search/_result.d.mts +9 -0
- package/api/search/_result.mjs +10 -0
- package/api/search/_score.mjs +21 -3
- package/api/swizzle/_moduleGraph.d.mts +8 -0
- package/api/swizzle/_moduleGraph.mjs +61 -3
- package/api/template/copy/copy.mjs +5 -3
- package/api/theme/_adapter.mjs +48 -12
- package/api/theme/build/build.d.mts +4 -0
- package/api/theme/build/build.mjs +69 -18
- package/api/theme/build/style-keys.mjs +4 -5
- package/api/theme/build/theme-object.mjs +5 -0
- package/api/theme/palette/generate/color.d.mts +47 -0
- package/api/theme/palette/generate/color.mjs +58 -1
- package/api/theme/palette/generate/derive-look.d.mts +293 -0
- package/api/theme/palette/generate/derive-look.mjs +1362 -0
- package/api/theme/palette/generate/editor-look.d.mts +62 -0
- package/api/theme/palette/generate/editor-look.mjs +550 -0
- package/api/theme/palette/generate/mapping.d.mts +94 -9
- package/api/theme/palette/generate/mapping.mjs +94 -22
- package/api/theme-edit/_adapter.mjs +13 -2
- package/api/theme-edit/_catalog.d.mts +13 -13
- package/api/theme-edit/_catalog.mjs +66 -28
- package/api/theme-edit/_check.d.mts +82 -6
- package/api/theme-edit/_check.mjs +1270 -238
- package/api/theme-edit/_color.d.mts +74 -0
- package/api/theme-edit/_color.mjs +168 -3
- package/api/theme-edit/_compiler.d.mts +3 -5
- package/api/theme-edit/_compiler.mjs +122 -23
- package/api/theme-edit/_context.d.mts +55 -12
- package/api/theme-edit/_context.mjs +114 -60
- package/api/theme-edit/_css.d.mts +11 -0
- package/api/theme-edit/_css.mjs +40 -0
- package/api/theme-edit/_edit.d.mts +15 -2
- package/api/theme-edit/_edit.mjs +1469 -133
- package/api/theme-edit/_how-commands.d.mts +116 -0
- package/api/theme-edit/_how-commands.mjs +227 -115
- package/api/theme-edit/_how-question.d.mts +74 -29
- package/api/theme-edit/_how-question.mjs +8514 -1256
- package/api/theme-edit/_how-sides.d.mts +22 -0
- package/api/theme-edit/_how-sides.mjs +173 -0
- package/api/theme-edit/_how-steps.d.mts +42 -0
- package/api/theme-edit/_how-steps.mjs +208 -0
- package/api/theme-edit/_how-values.d.mts +29 -0
- package/api/theme-edit/_how-values.mjs +111 -0
- package/api/theme-edit/_how-words.d.mts +15 -0
- package/api/theme-edit/_how-words.mjs +239 -0
- package/api/theme-edit/_how.d.mts +1 -1
- package/api/theme-edit/_how.mjs +422 -37
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +125 -13
- package/api/theme-edit/_normal.d.mts +5 -3
- package/api/theme-edit/_normal.mjs +54 -14
- package/api/theme-edit/_palette.d.mts +204 -4
- package/api/theme-edit/_palette.mjs +901 -25
- package/api/theme-edit/_part-pieces.d.mts +54 -0
- package/api/theme-edit/_part-pieces.mjs +179 -0
- package/api/theme-edit/_part-words.mjs +33 -5
- package/api/theme-edit/_parts.d.mts +133 -0
- package/api/theme-edit/_parts.mjs +599 -10
- package/api/theme-edit/_picture-traits.d.mts +259 -0
- package/api/theme-edit/_picture-traits.mjs +1030 -0
- package/api/theme-edit/_preview.d.mts +95 -4
- package/api/theme-edit/_preview.mjs +284 -31
- package/api/theme-edit/_project.d.mts +14 -4
- package/api/theme-edit/_project.mjs +95 -26
- package/api/theme-edit/_resolved.d.mts +46 -0
- package/api/theme-edit/_resolved.mjs +800 -0
- package/api/theme-edit/_set-line.d.mts +29 -0
- package/api/theme-edit/_set-line.mjs +100 -0
- package/api/theme-edit/_settings.d.mts +625 -28
- package/api/theme-edit/_settings.mjs +4867 -888
- package/api/theme-edit/_tables.d.mts +25 -1
- package/api/theme-edit/_tables.mjs +115 -11
- package/api/theme-edit/_text-looks.d.mts +78 -0
- package/api/theme-edit/_text-looks.mjs +376 -0
- package/api/theme-edit/_vet.d.mts +3 -26
- package/api/theme-edit/_vet.mjs +5 -89
- package/api/theme-edit/how/how.d.mts +1 -1
- package/api/theme-edit/how/how.mjs +1 -1
- package/api/theme-edit/show/show.d.mts +4 -3
- package/api/theme-edit/show/show.mjs +3 -2
- package/api/theme-edit/theme-edit.type.d.mts +117 -1
- package/api/theme-edit/theme-edit.type.mjs +46 -3
- package/api/theme-edit/themeEditHow.doc.mjs +3 -3
- package/api/theme-edit/themeEditNew.doc.mjs +4 -0
- package/api/theme-edit/themeEditSet.doc.mjs +6 -2
- package/api/theme-edit/themeEditShow.doc.mjs +22 -3
- package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/theme.doc.dense.mjs +10 -0
- package/assets/docs/theme.doc.mjs +10 -0
- package/assets/docs/theme.doc.zh.mjs +10 -0
- package/assets/docs/tree/export-pages.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +89 -17
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/article.doc.mjs +9 -0
- package/assets/icons/template-icons.json +5 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ide/page.tsx +5 -10
- package/assets/templates/pages/payment-form/page.tsx +16 -60
- package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +13 -13
- package/authoring/gap-report/parse.d.mts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/ensure-core-built.mjs +17 -10
- package/clients/cli/commands/experimental/icon.mjs +7 -7
- package/clients/cli/commands/experimental/theme.mjs +175 -13
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/hook.mjs +7 -0
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/index.mjs +6 -2
- package/clients/cli/lib/hook-format.mjs +41 -1
- package/clients/cli/lib/json-shim.mjs +34 -14
- package/clients/cli/lib/other-cli-words.mjs +7 -0
- package/clients/cli/lib/unknown-command.mjs +345 -46
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +11 -2
- package/foundation/agent-docs/agent-docs.mjs +51 -8
- package/foundation/config/project.d.mts +11 -1
- package/foundation/config/project.mjs +11 -2
- package/foundation/discovery/component-replacement.d.mts +5 -8
- package/foundation/discovery/component-replacement.mjs +12 -14
- package/foundation/discovery/core-augmentation-points.d.mts +35 -0
- package/foundation/discovery/core-augmentation-points.mjs +410 -9
- package/foundation/discovery/core-elements.d.mts +6 -0
- package/foundation/discovery/core-elements.mjs +10 -2
- package/foundation/discovery/core-prop-types.d.mts +5 -0
- package/foundation/discovery/core-prop-types.mjs +10 -3
- package/foundation/discovery/core-props.d.mts +8 -0
- package/foundation/discovery/core-props.mjs +29 -13
- package/foundation/discovery/icon-ranking.d.mts +5 -2
- package/foundation/discovery/icon-ranking.mjs +101 -18
- package/foundation/discovery/icon-set-checks.mjs +1 -1
- package/foundation/discovery/icon-set-writer.mjs +1 -1
- package/foundation/discovery/official-list.d.mts +17 -0
- package/foundation/discovery/official-list.mjs +77 -0
- package/foundation/discovery/unknown-core-props.d.mts +130 -0
- package/foundation/discovery/unknown-core-props.mjs +601 -0
- package/foundation/discovery/written-prop-values.d.mts +35 -0
- package/foundation/discovery/written-prop-values.mjs +258 -0
- package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
- package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
- package/foundation/fs/package-name.d.mts +10 -0
- package/foundation/fs/package-name.mjs +37 -0
- package/foundation/fs/project-source-files.d.mts +27 -0
- package/foundation/fs/project-source-files.mjs +115 -0
- package/foundation/fs/project-sources.d.mts +25 -0
- package/foundation/fs/project-sources.mjs +83 -0
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +36 -2
- package/foundation/integrations/integration-warnings.d.mts +39 -7
- package/foundation/integrations/integration-warnings.mjs +141 -19
- package/foundation/integrations/missing-dependency.d.mts +11 -0
- package/foundation/integrations/missing-dependency.mjs +20 -5
- package/foundation/release/folder-lock.d.mts +5 -2
- package/foundation/release/folder-lock.mjs +9 -3
- package/foundation/release/notices.mjs +2 -8
- package/foundation/render/cut-short.d.mts +8 -2
- package/foundation/render/cut-short.mjs +50 -5
- package/foundation/render/drawn-contrast.d.mts +40 -0
- package/foundation/render/drawn-contrast.mjs +355 -0
- package/foundation/render/file-header.mjs +4 -0
- package/foundation/render/layers.d.mts +2 -1
- package/foundation/render/layers.mjs +22 -1
- package/foundation/render/package-resolve-hooks.d.mts +38 -9
- package/foundation/render/package-resolve-hooks.mjs +124 -32
- package/foundation/render/page-worker.mjs +95 -23
- package/foundation/render/part-boxes.d.mts +27 -0
- package/foundation/render/part-boxes.mjs +45 -0
- package/foundation/render/picture-chrome.mjs +36 -4
- package/foundation/render/picture-playwright.mjs +26 -2
- package/foundation/render/picture-window.d.mts +29 -2
- package/foundation/render/picture-window.mjs +99 -1
- package/foundation/render/render-page.d.mts +39 -6
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.mjs +2 -1
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +9 -5
- package/foundation/text/written-string.d.mts +4 -1
- package/foundation/text/written-string.mjs +4 -1
- package/package.json +8 -7
|
@@ -9,17 +9,33 @@
|
|
|
9
9
|
* @returns {string | null}
|
|
10
10
|
*/
|
|
11
11
|
export function familyOf(project: import("./_project.mjs").ThemeProject, name: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a section's own page draws a component in a cell of its own. On
|
|
14
|
+
* the overlays section's page, a part of an overlay (a dialog's header, a
|
|
15
|
+
* command palette's list) shows inside the overlay it belongs to, never
|
|
16
|
+
* alone beside it, and inside it only while the overlay is open: that page
|
|
17
|
+
* stays one or two screens. The whole sheet draws it alone.
|
|
18
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @param {string | null | undefined} group the section drawn, none for the whole sheet
|
|
21
|
+
*/
|
|
22
|
+
export function shownOnSection(project: import("./_project.mjs").ThemeProject, name: string, group: string | null | undefined): boolean;
|
|
12
23
|
/**
|
|
13
24
|
* The sections of the theme-building page whose parts the theme's settings
|
|
14
25
|
* set on their own (`--on badge`, or a group of parts such as `--on
|
|
15
26
|
* inputs`): the components each part names a class of, each in its section. A setting for the whole theme (a color, the
|
|
16
27
|
* corners) sets no section here: the sample page and the open states show
|
|
17
28
|
* it.
|
|
18
|
-
*
|
|
29
|
+
* A family role (`--on option-rows`) is read from the census, as the
|
|
30
|
+
* change itself reads it, so the pictured set is what the change touched.
|
|
31
|
+
* @param {{project: import('./_project.mjs').ThemeProject, C?: any}} ctx
|
|
19
32
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
20
33
|
* @returns {string[]}
|
|
21
34
|
*/
|
|
22
|
-
export function touchedFamilies(
|
|
35
|
+
export function touchedFamilies(ctx: {
|
|
36
|
+
project: import("./_project.mjs").ThemeProject;
|
|
37
|
+
C?: any;
|
|
38
|
+
}, data: import("./_settings.mjs").ThemeData): string[];
|
|
23
39
|
/**
|
|
24
40
|
* Items of the theme-building page: each component once per variant
|
|
25
41
|
* (overlays open), the sample page, and template pages
|
|
@@ -172,6 +188,17 @@ export function renderSheet(ctx: import("./_settings.mjs").Ctx, slug: string, da
|
|
|
172
188
|
skipped: string[];
|
|
173
189
|
notes: string[];
|
|
174
190
|
}>;
|
|
191
|
+
/**
|
|
192
|
+
* A copy of an element tree in which every controlled part with a value and
|
|
193
|
+
* no onChange gets one that does nothing, so a click on it never throws. A
|
|
194
|
+
* callback the part's doc requires (a toast's onDismiss) that the sample
|
|
195
|
+
* leaves out gets one that does nothing too, so the part never calls a
|
|
196
|
+
* missing function (a toast's timer).
|
|
197
|
+
* @param {unknown} v
|
|
198
|
+
* @param {import('./_project.mjs').ThemeProject} [project]
|
|
199
|
+
* @returns {unknown}
|
|
200
|
+
*/
|
|
201
|
+
export function withHandlers(v: unknown, project?: import("./_project.mjs").ThemeProject): unknown;
|
|
175
202
|
/**
|
|
176
203
|
* The source of the preview's components page: every component grouped,
|
|
177
204
|
* each variant side by side, overlays open. Template pages are pages of
|
|
@@ -276,8 +303,9 @@ export function screenshot(project: import("./_project.mjs").ThemeProject, html:
|
|
|
276
303
|
* took the picture, each with whether its part keeping its width draws it
|
|
277
304
|
* whole; absent when that browser's script measured nothing.
|
|
278
305
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
279
|
-
* @param {Array<{html: string, png: string, mode: 'light' | 'dark'}>} jobs
|
|
280
|
-
* absolute paths
|
|
306
|
+
* @param {Array<{html: string, png: string, mode: 'light' | 'dark', boxes?: string[]}>} jobs
|
|
307
|
+
* absolute paths; `boxes`: parts whose drawn sizes the picture measures
|
|
308
|
+
* (its result's `boxes`)
|
|
281
309
|
* @param {PictureRun} [run] what earlier pictures of the same run learned:
|
|
282
310
|
* a browser that failed or hung there is not tried again
|
|
283
311
|
* @returns {Promise<PictureResult[]>}
|
|
@@ -286,7 +314,61 @@ export function screenshots(project: import("./_project.mjs").ThemeProject, jobs
|
|
|
286
314
|
html: string;
|
|
287
315
|
png: string;
|
|
288
316
|
mode: "light" | "dark";
|
|
317
|
+
boxes?: string[];
|
|
289
318
|
}>, run?: PictureRun): Promise<PictureResult[]>;
|
|
319
|
+
/**
|
|
320
|
+
* How much each part's drawn size changes from one page to another (the
|
|
321
|
+
* sheet before a change and after it): both pictured in one browser run,
|
|
322
|
+
* each part's boxes measured, and the largest growth of a box at the same
|
|
323
|
+
* place in the page taken, in px. A part not drawn on both pages is
|
|
324
|
+
* counted as not drawn. The pictures themselves are not kept.
|
|
325
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
326
|
+
* @param {string} before absolute path of the page before
|
|
327
|
+
* @param {string} after absolute path of the page after
|
|
328
|
+
* @param {string[]} parts
|
|
329
|
+
* @param {'light' | 'dark'} mode
|
|
330
|
+
* @returns {Promise<{changes: Array<{part: string, width: number, height: number, drawn: number}>} | {problem: string}>}
|
|
331
|
+
*/
|
|
332
|
+
export function partSizeChanges(project: import("./_project.mjs").ThemeProject, before: string, after: string, parts: string[], mode: "light" | "dark"): Promise<{
|
|
333
|
+
changes: Array<{
|
|
334
|
+
part: string;
|
|
335
|
+
width: number;
|
|
336
|
+
height: number;
|
|
337
|
+
drawn: number;
|
|
338
|
+
}>;
|
|
339
|
+
} | {
|
|
340
|
+
problem: string;
|
|
341
|
+
}>;
|
|
342
|
+
/**
|
|
343
|
+
* How much each part's drawn boxes grow from one measurement to another:
|
|
344
|
+
* the largest growth in width and in height of a box at the same place in
|
|
345
|
+
* the page, in px, to a hundredth (0 when none grows; a box that shrinks
|
|
346
|
+
* does not count), and how many boxes both measurements draw.
|
|
347
|
+
* @param {string[]} parts
|
|
348
|
+
* @param {Record<string, Array<[number, number]>>} was
|
|
349
|
+
* @param {Record<string, Array<[number, number]>>} now
|
|
350
|
+
* @returns {Array<{part: string, width: number, height: number, drawn: number}>}
|
|
351
|
+
*/
|
|
352
|
+
export function boxChanges(parts: string[], was: Record<string, Array<[number, number]>>, now: Record<string, Array<[number, number]>>): Array<{
|
|
353
|
+
part: string;
|
|
354
|
+
width: number;
|
|
355
|
+
height: number;
|
|
356
|
+
drawn: number;
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* What a change of size says about the parts it measured: how much each
|
|
360
|
+
* part that grows grows, else that they keep their size; null when none
|
|
361
|
+
* of them is drawn.
|
|
362
|
+
* @param {Array<{part: string, width: number, height: number, drawn: number}>} changes
|
|
363
|
+
* @param {string} cause what grew them ("the added border")
|
|
364
|
+
* @returns {string | null}
|
|
365
|
+
*/
|
|
366
|
+
export function sizeChangeNote(changes: Array<{
|
|
367
|
+
part: string;
|
|
368
|
+
width: number;
|
|
369
|
+
height: number;
|
|
370
|
+
drawn: number;
|
|
371
|
+
}>, cause: string): string | null;
|
|
290
372
|
/**
|
|
291
373
|
* What a picture shows in place of a font stack: a role whose stack ends in
|
|
292
374
|
* a generic of a kind (serif, monospace, cursive) and none of whose named
|
|
@@ -444,11 +526,20 @@ export type PictureResult = {
|
|
|
444
526
|
ok: true;
|
|
445
527
|
file: string;
|
|
446
528
|
notes?: string[];
|
|
529
|
+
boxes?: Record<string, Array<[number, number]>>;
|
|
447
530
|
cutShort?: Array<{
|
|
448
531
|
part: string | null;
|
|
449
532
|
text: string;
|
|
450
533
|
whole: boolean;
|
|
451
534
|
broken?: boolean;
|
|
535
|
+
overlaps?: boolean;
|
|
536
|
+
}>;
|
|
537
|
+
lowContrast?: Array<{
|
|
538
|
+
part: string;
|
|
539
|
+
text: string;
|
|
540
|
+
ratio: number;
|
|
541
|
+
fg: string;
|
|
542
|
+
bg: string;
|
|
452
543
|
}>;
|
|
453
544
|
} | {
|
|
454
545
|
ok: false;
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
themeFiles,
|
|
54
54
|
APP_COPY_BUILT,
|
|
55
55
|
appCopyNames,
|
|
56
|
+
groupsOf,
|
|
56
57
|
} from './_settings.mjs';
|
|
57
58
|
import {readRegularFile, writeWhole} from './_palette.mjs';
|
|
58
59
|
import {cliVersion} from '../../foundation/release/run-context.mjs';
|
|
@@ -60,7 +61,6 @@ import {importPathOf, installLine} from './_project.mjs';
|
|
|
60
61
|
import {
|
|
61
62
|
COLOR_PROP_PARTS,
|
|
62
63
|
DIRECT,
|
|
63
|
-
FAMILIES,
|
|
64
64
|
P,
|
|
65
65
|
SHOWCASE_GROUPS,
|
|
66
66
|
wordTable,
|
|
@@ -75,6 +75,8 @@ import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
|
75
75
|
import {PICTURE_TAKEN} from '../../foundation/render/picture-window.mjs';
|
|
76
76
|
import {FONT_PROBE_PREFIX} from '../../foundation/render/font-probe.mjs';
|
|
77
77
|
import {CUT_SHORT_PREFIX} from '../../foundation/render/cut-short.mjs';
|
|
78
|
+
import {LOW_CONTRAST_PREFIX} from '../../foundation/render/drawn-contrast.mjs';
|
|
79
|
+
import {PART_BOXES_PREFIX} from '../../foundation/render/part-boxes.mjs';
|
|
78
80
|
|
|
79
81
|
const TEMPLATES_DIR = path.resolve(
|
|
80
82
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
@@ -176,22 +178,42 @@ export function familyOf(project, name) {
|
|
|
176
178
|
return groupOf(name, info?.category || parent?.category || '');
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Whether a section's own page draws a component in a cell of its own. On
|
|
183
|
+
* the overlays section's page, a part of an overlay (a dialog's header, a
|
|
184
|
+
* command palette's list) shows inside the overlay it belongs to, never
|
|
185
|
+
* alone beside it, and inside it only while the overlay is open: that page
|
|
186
|
+
* stays one or two screens. The whole sheet draws it alone.
|
|
187
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
188
|
+
* @param {string} name
|
|
189
|
+
* @param {string | null | undefined} group the section drawn, none for the whole sheet
|
|
190
|
+
*/
|
|
191
|
+
export function shownOnSection(project, name, group) {
|
|
192
|
+
return !(
|
|
193
|
+
group === 'overlays' &&
|
|
194
|
+
familyOf(project, name) === 'overlays' &&
|
|
195
|
+
project.components[name]?.subComponentOf
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
179
199
|
/**
|
|
180
200
|
* The sections of the theme-building page whose parts the theme's settings
|
|
181
201
|
* set on their own (`--on badge`, or a group of parts such as `--on
|
|
182
202
|
* inputs`): the components each part names a class of, each in its section. A setting for the whole theme (a color, the
|
|
183
203
|
* corners) sets no section here: the sample page and the open states show
|
|
184
204
|
* it.
|
|
185
|
-
*
|
|
205
|
+
* A family role (`--on option-rows`) is read from the census, as the
|
|
206
|
+
* change itself reads it, so the pictured set is what the change touched.
|
|
207
|
+
* @param {{project: import('./_project.mjs').ThemeProject, C?: any}} ctx
|
|
186
208
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
187
209
|
* @returns {string[]}
|
|
188
210
|
*/
|
|
189
|
-
export function touchedFamilies(
|
|
190
|
-
|
|
211
|
+
export function touchedFamilies(ctx, data) {
|
|
212
|
+
const {project} = ctx;
|
|
213
|
+
// A group (`--on inputs`, `--on option-rows`) sets each of its parts.
|
|
214
|
+
const groups = groupsOf(ctx);
|
|
191
215
|
const parts = new Set(
|
|
192
|
-
(data.settings ?? []).flatMap(s =>
|
|
193
|
-
s.on ? (FAMILIES[s.on] ?? [s.on]) : [],
|
|
194
|
-
),
|
|
216
|
+
(data.settings ?? []).flatMap(s => (s.on ? (groups[s.on] ?? [s.on]) : [])),
|
|
195
217
|
);
|
|
196
218
|
/** @type {Set<string>} */
|
|
197
219
|
const out = new Set();
|
|
@@ -204,6 +226,71 @@ export function touchedFamilies(project, data) {
|
|
|
204
226
|
return [...out];
|
|
205
227
|
}
|
|
206
228
|
|
|
229
|
+
/** The Astryx control each plain HTML text control is drawn as. */
|
|
230
|
+
const ASTRYX_CONTROLS = Object.freeze({
|
|
231
|
+
input: 'TextInput',
|
|
232
|
+
textarea: 'TextArea',
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
/** The input types a text input draws. */
|
|
236
|
+
const TEXT_TYPES = new Set([
|
|
237
|
+
'',
|
|
238
|
+
'text',
|
|
239
|
+
'email',
|
|
240
|
+
'search',
|
|
241
|
+
'url',
|
|
242
|
+
'tel',
|
|
243
|
+
'password',
|
|
244
|
+
]);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A value with each plain HTML text control in a doc's sample (a field's
|
|
248
|
+
* `<input>`) drawn as the Astryx control for it, its label hidden, so the
|
|
249
|
+
* sheet shows the theme's own control where an app would use one: a bare
|
|
250
|
+
* browser control shows nothing of the theme. Every other value is the same
|
|
251
|
+
* object.
|
|
252
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
253
|
+
* @param {unknown} v
|
|
254
|
+
* @returns {unknown}
|
|
255
|
+
*/
|
|
256
|
+
function withAstryxControls(project, v) {
|
|
257
|
+
if (Array.isArray(v)) {
|
|
258
|
+
const out = v.map(x => withAstryxControls(project, x));
|
|
259
|
+
return out.every((x, i) => x === v[i]) ? v : out;
|
|
260
|
+
}
|
|
261
|
+
if (!v || typeof v !== 'object') return v;
|
|
262
|
+
if (isElement(v)) {
|
|
263
|
+
const own = /** @type {Record<string, string>} */ (ASTRYX_CONTROLS)[
|
|
264
|
+
v.__element
|
|
265
|
+
];
|
|
266
|
+
const p = /** @type {Record<string, unknown>} */ (v.props ?? {});
|
|
267
|
+
if (
|
|
268
|
+
own &&
|
|
269
|
+
project.components[own] &&
|
|
270
|
+
(v.__element !== 'input' || TEXT_TYPES.has(String(p.type ?? '')))
|
|
271
|
+
)
|
|
272
|
+
return {
|
|
273
|
+
__element: own,
|
|
274
|
+
props: {
|
|
275
|
+
label: String(p['aria-label'] ?? p.placeholder ?? 'Text'),
|
|
276
|
+
isLabelHidden: true,
|
|
277
|
+
...(p.placeholder != null ? {placeholder: p.placeholder} : {}),
|
|
278
|
+
...(p.id != null ? {id: p.id} : {}),
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
const props = withAstryxControls(project, v.props);
|
|
282
|
+
const children = withAstryxControls(project, v.children);
|
|
283
|
+
return props === v.props && children === v.children
|
|
284
|
+
? v
|
|
285
|
+
: {...v, props, children};
|
|
286
|
+
}
|
|
287
|
+
const entries = Object.entries(v);
|
|
288
|
+
const out = entries.map(([k, x]) => [k, withAstryxControls(project, x)]);
|
|
289
|
+
return out.every(([, x], i) => x === entries[i][1])
|
|
290
|
+
? v
|
|
291
|
+
: {...v, ...Object.fromEntries(out)};
|
|
292
|
+
}
|
|
293
|
+
|
|
207
294
|
/**
|
|
208
295
|
* What the cached component items are built by ({@link codeFingerprint}):
|
|
209
296
|
* this file and every file it imports, read the first time it is needed.
|
|
@@ -231,6 +318,7 @@ const itemsByFile = new Map();
|
|
|
231
318
|
*/
|
|
232
319
|
function cachedComponentItems(project, group) {
|
|
233
320
|
itemsKey ??= codeFingerprint(import.meta.url);
|
|
321
|
+
if (!project.cacheDir) return componentItems(project, group);
|
|
234
322
|
const file = path.join(project.cacheDir, 'items.json');
|
|
235
323
|
let kept = itemsByFile.get(file);
|
|
236
324
|
if (!kept) {
|
|
@@ -306,22 +394,13 @@ function componentItems(project, group) {
|
|
|
306
394
|
// so it would draw an empty cell: it gets none.
|
|
307
395
|
if (!importPathOf(project, name)) continue;
|
|
308
396
|
const info = project.components[name];
|
|
309
|
-
|
|
310
|
-
// header, a command palette's list) shows inside the overlay it belongs
|
|
311
|
-
// to, never alone beside it: that page stays one or two screens.
|
|
312
|
-
if (group === 'overlays' && g === 'overlays' && info?.subComponentOf)
|
|
313
|
-
continue;
|
|
397
|
+
if (!shownOnSection(project, name, group)) continue;
|
|
314
398
|
// A deprecated part is not drawn: a theme styles the part that replaces
|
|
315
399
|
// it. An overlay whose playground opens it over the page draws nothing
|
|
316
400
|
// closed (a phone's navigation drawer, slid out of the window): where
|
|
317
|
-
// the open states draw it open
|
|
401
|
+
// the open states draw it open, that is its only cell, on every page.
|
|
318
402
|
if (info?.deprecated) continue;
|
|
319
|
-
if (
|
|
320
|
-
(!group || group === 'overlays') &&
|
|
321
|
-
info?.overlay &&
|
|
322
|
-
OPEN_SCENES.some(s => s.name === name)
|
|
323
|
-
)
|
|
324
|
-
continue;
|
|
403
|
+
if (info?.overlay && OPEN_SCENES.some(s => s.name === name)) continue;
|
|
325
404
|
catalogVariants(project, name, 12, {shown: true}).forEach((v, i) =>
|
|
326
405
|
items.push({
|
|
327
406
|
group: g,
|
|
@@ -332,7 +411,13 @@ function componentItems(project, group) {
|
|
|
332
411
|
// A doc's sample children may name a part by an older name (a
|
|
333
412
|
// stack, a heading): each is drawn by the name Core exports.
|
|
334
413
|
props: /** @type {Record<string, unknown>} */ (
|
|
335
|
-
|
|
414
|
+
withAstryxControls(
|
|
415
|
+
project,
|
|
416
|
+
withCoreAliases(
|
|
417
|
+
project,
|
|
418
|
+
withSampleContent(project, name, v.props),
|
|
419
|
+
),
|
|
420
|
+
)
|
|
336
421
|
),
|
|
337
422
|
}),
|
|
338
423
|
// An overlay shown open is drawn open: Core places a popover,
|
|
@@ -1431,22 +1516,36 @@ const CONTROLLED = new Set([
|
|
|
1431
1516
|
|
|
1432
1517
|
/**
|
|
1433
1518
|
* A copy of an element tree in which every controlled part with a value and
|
|
1434
|
-
* no onChange gets one that does nothing, so a click on it never throws.
|
|
1519
|
+
* no onChange gets one that does nothing, so a click on it never throws. A
|
|
1520
|
+
* callback the part's doc requires (a toast's onDismiss) that the sample
|
|
1521
|
+
* leaves out gets one that does nothing too, so the part never calls a
|
|
1522
|
+
* missing function (a toast's timer).
|
|
1435
1523
|
* @param {unknown} v
|
|
1524
|
+
* @param {import('./_project.mjs').ThemeProject} [project]
|
|
1436
1525
|
* @returns {unknown}
|
|
1437
1526
|
*/
|
|
1438
|
-
function withHandlers(v) {
|
|
1439
|
-
if (Array.isArray(v)) return v.map(withHandlers);
|
|
1527
|
+
export function withHandlers(v, project) {
|
|
1528
|
+
if (Array.isArray(v)) return v.map(x => withHandlers(x, project));
|
|
1440
1529
|
if (isElement(v)) {
|
|
1441
1530
|
const props = Object.fromEntries(
|
|
1442
|
-
Object.entries(v.props ?? {}).map(([k, x]) => [
|
|
1531
|
+
Object.entries(v.props ?? {}).map(([k, x]) => [
|
|
1532
|
+
k,
|
|
1533
|
+
withHandlers(x, project),
|
|
1534
|
+
]),
|
|
1443
1535
|
);
|
|
1444
1536
|
if (CONTROLLED.has(v.__element) && 'value' in props && !props.onChange)
|
|
1445
1537
|
props.onChange = {__code: '() => {}'};
|
|
1538
|
+
// Written without an arrow, so this no-op adds no `>` inside a tag.
|
|
1539
|
+
const docProps = project?.components[v.__element]?.props ?? {};
|
|
1540
|
+
for (const [name, doc] of Object.entries(docProps))
|
|
1541
|
+
if (/^on[A-Z]/.test(name) && doc?.required && !(name in props))
|
|
1542
|
+
props[name] = {__code: 'function () {}'};
|
|
1446
1543
|
return {
|
|
1447
1544
|
...v,
|
|
1448
1545
|
props,
|
|
1449
|
-
...(v.children === undefined
|
|
1546
|
+
...(v.children === undefined
|
|
1547
|
+
? {}
|
|
1548
|
+
: {children: withHandlers(v.children, project)}),
|
|
1450
1549
|
};
|
|
1451
1550
|
}
|
|
1452
1551
|
return v;
|
|
@@ -1584,7 +1683,10 @@ function componentsPage(project, {theme = null, C}) {
|
|
|
1584
1683
|
)
|
|
1585
1684
|
.map(it => ({
|
|
1586
1685
|
...it,
|
|
1587
|
-
tree: withHandlers(
|
|
1686
|
+
tree: withHandlers(
|
|
1687
|
+
withSources(project, withCoreNames(project, it.tree)),
|
|
1688
|
+
project,
|
|
1689
|
+
),
|
|
1588
1690
|
}))
|
|
1589
1691
|
.filter(it => it.tree !== undefined);
|
|
1590
1692
|
/** @type {Map<string, Map<string, import('./_catalog.mjs').CatalogItem[]>>} */
|
|
@@ -1670,7 +1772,7 @@ function overviewPage(project, {theme = null, colors = false}) {
|
|
|
1670
1772
|
const sections = OVERVIEW_SECTIONS.map(x => ({
|
|
1671
1773
|
title: x.title,
|
|
1672
1774
|
tree: /** @type {import('./_catalog.mjs').Tree | undefined} */ (
|
|
1673
|
-
withHandlers(withCoreNames(project, x.tree))
|
|
1775
|
+
withHandlers(withCoreNames(project, x.tree), project)
|
|
1674
1776
|
),
|
|
1675
1777
|
})).filter(x => x.tree !== undefined);
|
|
1676
1778
|
const body = sections
|
|
@@ -2101,7 +2203,7 @@ export async function screenshot(
|
|
|
2101
2203
|
}
|
|
2102
2204
|
|
|
2103
2205
|
/**
|
|
2104
|
-
* @typedef {{ok: true, file: string, notes?: string[], cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>} | {ok: false, reason: string, stopped?: string}} PictureResult
|
|
2206
|
+
* @typedef {{ok: true, file: string, notes?: string[], boxes?: Record<string, Array<[number, number]>>, cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>, lowContrast?: Array<{part: string, text: string, ratio: number, fg: string, bg: string}>} | {ok: false, reason: string, stopped?: string}} PictureResult
|
|
2105
2207
|
*/
|
|
2106
2208
|
|
|
2107
2209
|
/** The time a batch adds to its browser's bound for each page after the first. */
|
|
@@ -2121,8 +2223,9 @@ const PAGE_BOUND_MS = 20_000;
|
|
|
2121
2223
|
* took the picture, each with whether its part keeping its width draws it
|
|
2122
2224
|
* whole; absent when that browser's script measured nothing.
|
|
2123
2225
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
2124
|
-
* @param {Array<{html: string, png: string, mode: 'light' | 'dark'}>} jobs
|
|
2125
|
-
* absolute paths
|
|
2226
|
+
* @param {Array<{html: string, png: string, mode: 'light' | 'dark', boxes?: string[]}>} jobs
|
|
2227
|
+
* absolute paths; `boxes`: parts whose drawn sizes the picture measures
|
|
2228
|
+
* (its result's `boxes`)
|
|
2126
2229
|
* @param {PictureRun} [run] what earlier pictures of the same run learned:
|
|
2127
2230
|
* a browser that failed or hung there is not tried again
|
|
2128
2231
|
* @returns {Promise<PictureResult[]>}
|
|
@@ -2229,6 +2332,8 @@ export async function screenshots(project, jobs, run = newPictureRun()) {
|
|
|
2229
2332
|
...pictureFontNotes(out),
|
|
2230
2333
|
],
|
|
2231
2334
|
...measuredCutShort(out),
|
|
2335
|
+
...measuredLowContrast(out),
|
|
2336
|
+
...measuredBoxes(out),
|
|
2232
2337
|
});
|
|
2233
2338
|
}
|
|
2234
2339
|
if (results.length === jobs.length) return results;
|
|
@@ -2269,6 +2374,92 @@ export async function screenshots(project, jobs, run = newPictureRun()) {
|
|
|
2269
2374
|
return results;
|
|
2270
2375
|
}
|
|
2271
2376
|
|
|
2377
|
+
/**
|
|
2378
|
+
* How much each part's drawn size changes from one page to another (the
|
|
2379
|
+
* sheet before a change and after it): both pictured in one browser run,
|
|
2380
|
+
* each part's boxes measured, and the largest growth of a box at the same
|
|
2381
|
+
* place in the page taken, in px. A part not drawn on both pages is
|
|
2382
|
+
* counted as not drawn. The pictures themselves are not kept.
|
|
2383
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
2384
|
+
* @param {string} before absolute path of the page before
|
|
2385
|
+
* @param {string} after absolute path of the page after
|
|
2386
|
+
* @param {string[]} parts
|
|
2387
|
+
* @param {'light' | 'dark'} mode
|
|
2388
|
+
* @returns {Promise<{changes: Array<{part: string, width: number, height: number, drawn: number}>} | {problem: string}>}
|
|
2389
|
+
*/
|
|
2390
|
+
export async function partSizeChanges(project, before, after, parts, mode) {
|
|
2391
|
+
const pngs = [before, after].map(h => h.replace(/\.html$/, '.png'));
|
|
2392
|
+
/** @type {PictureResult[]} */
|
|
2393
|
+
let shots;
|
|
2394
|
+
try {
|
|
2395
|
+
shots = await screenshots(project, [
|
|
2396
|
+
{html: before, png: pngs[0], mode, boxes: parts},
|
|
2397
|
+
{html: after, png: pngs[1], mode, boxes: parts},
|
|
2398
|
+
]);
|
|
2399
|
+
} finally {
|
|
2400
|
+
for (const p of pngs) fs.rmSync(p, {force: true});
|
|
2401
|
+
}
|
|
2402
|
+
const [a, b] = shots;
|
|
2403
|
+
if (!a?.ok || !b?.ok)
|
|
2404
|
+
return {
|
|
2405
|
+
problem:
|
|
2406
|
+
(a && !a.ok ? a.reason : b && !b.ok ? b.reason : null) ??
|
|
2407
|
+
'no picture was taken',
|
|
2408
|
+
};
|
|
2409
|
+
return {changes: boxChanges(parts, a.boxes ?? {}, b.boxes ?? {})};
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
/**
|
|
2413
|
+
* How much each part's drawn boxes grow from one measurement to another:
|
|
2414
|
+
* the largest growth in width and in height of a box at the same place in
|
|
2415
|
+
* the page, in px, to a hundredth (0 when none grows; a box that shrinks
|
|
2416
|
+
* does not count), and how many boxes both measurements draw.
|
|
2417
|
+
* @param {string[]} parts
|
|
2418
|
+
* @param {Record<string, Array<[number, number]>>} was
|
|
2419
|
+
* @param {Record<string, Array<[number, number]>>} now
|
|
2420
|
+
* @returns {Array<{part: string, width: number, height: number, drawn: number}>}
|
|
2421
|
+
*/
|
|
2422
|
+
export function boxChanges(parts, was, now) {
|
|
2423
|
+
const round = (/** @type {number} */ n) => Math.round(n * 100) / 100;
|
|
2424
|
+
return parts.map(part => {
|
|
2425
|
+
const a = was[part] ?? [];
|
|
2426
|
+
const b = now[part] ?? [];
|
|
2427
|
+
const drawn = Math.min(a.length, b.length);
|
|
2428
|
+
let width = 0;
|
|
2429
|
+
let height = 0;
|
|
2430
|
+
for (let i = 0; i < drawn; i++) {
|
|
2431
|
+
width = Math.max(width, b[i][0] - a[i][0]);
|
|
2432
|
+
height = Math.max(height, b[i][1] - a[i][1]);
|
|
2433
|
+
}
|
|
2434
|
+
return {part, width: round(width), height: round(height), drawn};
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* What a change of size says about the parts it measured: how much each
|
|
2440
|
+
* part that grows grows, else that they keep their size; null when none
|
|
2441
|
+
* of them is drawn.
|
|
2442
|
+
* @param {Array<{part: string, width: number, height: number, drawn: number}>} changes
|
|
2443
|
+
* @param {string} cause what grew them ("the added border")
|
|
2444
|
+
* @returns {string | null}
|
|
2445
|
+
*/
|
|
2446
|
+
export function sizeChangeNote(changes, cause) {
|
|
2447
|
+
const drawn = changes.filter(x => x.drawn);
|
|
2448
|
+
if (!drawn.length) return null;
|
|
2449
|
+
const grows = drawn.filter(x => x.width > 0 || x.height > 0);
|
|
2450
|
+
if (!grows.length)
|
|
2451
|
+
return `${drawn.map(x => x.part).join(', ')} keeps its size with ${cause} (measured on the sheet, at rest and in each state it draws)`;
|
|
2452
|
+
return grows
|
|
2453
|
+
.map(
|
|
2454
|
+
x =>
|
|
2455
|
+
`${x.part} grows by ${[
|
|
2456
|
+
...(x.height > 0 ? [`${x.height}px in height`] : []),
|
|
2457
|
+
...(x.width > 0 ? [`${x.width}px in width`] : []),
|
|
2458
|
+
].join(' and ')} (${cause}; measured on the sheet)`,
|
|
2459
|
+
)
|
|
2460
|
+
.join('; ');
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2272
2463
|
/** The generic families any font of a common kind stands in for. */
|
|
2273
2464
|
const PLAIN_GENERICS = ['sans-serif', 'system-ui', 'ui-sans-serif'];
|
|
2274
2465
|
|
|
@@ -2315,7 +2506,7 @@ export function pictureFontNotes(stdout) {
|
|
|
2315
2506
|
* The text a picture script measured cut short, from the line it prints
|
|
2316
2507
|
* after `CUT_SHORT_PREFIX`; nothing when it printed none that reads.
|
|
2317
2508
|
* @param {string} stdout what the picture script printed
|
|
2318
|
-
* @returns {{cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean}>}}
|
|
2509
|
+
* @returns {{cutShort?: Array<{part: string | null, text: string, whole: boolean, broken?: boolean, overlaps?: boolean}>}}
|
|
2319
2510
|
*/
|
|
2320
2511
|
function measuredCutShort(stdout) {
|
|
2321
2512
|
const line = stdout.split('\n').find(l => l.startsWith(CUT_SHORT_PREFIX));
|
|
@@ -2336,10 +2527,72 @@ function measuredCutShort(stdout) {
|
|
|
2336
2527
|
text: x.text,
|
|
2337
2528
|
whole: x.whole === true,
|
|
2338
2529
|
...(x.broken === true ? {broken: true} : {}),
|
|
2530
|
+
...(x.overlaps === true ? {overlaps: true} : {}),
|
|
2339
2531
|
})),
|
|
2340
2532
|
};
|
|
2341
2533
|
}
|
|
2342
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* The text a picture script measured too faint to read, from the line it
|
|
2537
|
+
* prints after `LOW_CONTRAST_PREFIX`; nothing when it printed none that
|
|
2538
|
+
* reads.
|
|
2539
|
+
* @param {string} stdout what the picture script printed
|
|
2540
|
+
* @returns {{lowContrast?: Array<{part: string, text: string, ratio: number, fg: string, bg: string}>}}
|
|
2541
|
+
*/
|
|
2542
|
+
function measuredLowContrast(stdout) {
|
|
2543
|
+
const line = stdout.split('\n').find(l => l.startsWith(LOW_CONTRAST_PREFIX));
|
|
2544
|
+
if (!line) return {};
|
|
2545
|
+
/** @type {unknown} */
|
|
2546
|
+
let found;
|
|
2547
|
+
try {
|
|
2548
|
+
found = JSON.parse(line.slice(LOW_CONTRAST_PREFIX.length));
|
|
2549
|
+
} catch {
|
|
2550
|
+
return {};
|
|
2551
|
+
}
|
|
2552
|
+
if (!Array.isArray(found)) return {};
|
|
2553
|
+
return {
|
|
2554
|
+
lowContrast: found.filter(
|
|
2555
|
+
x =>
|
|
2556
|
+
x &&
|
|
2557
|
+
typeof x.part === 'string' &&
|
|
2558
|
+
typeof x.text === 'string' &&
|
|
2559
|
+
typeof x.ratio === 'number' &&
|
|
2560
|
+
/^#[0-9a-f]{6}$/.test(String(x.fg)) &&
|
|
2561
|
+
/^#[0-9a-f]{6}$/.test(String(x.bg)),
|
|
2562
|
+
),
|
|
2563
|
+
};
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
/**
|
|
2567
|
+
* The part sizes a picture script measured, from the line it prints after
|
|
2568
|
+
* `PART_BOXES_PREFIX`; nothing when it printed none that reads.
|
|
2569
|
+
* @param {string} stdout what the picture script printed
|
|
2570
|
+
* @returns {{boxes?: Record<string, Array<[number, number]>>}}
|
|
2571
|
+
*/
|
|
2572
|
+
function measuredBoxes(stdout) {
|
|
2573
|
+
const line = stdout.split('\n').find(l => l.startsWith(PART_BOXES_PREFIX));
|
|
2574
|
+
if (!line) return {};
|
|
2575
|
+
/** @type {unknown} */
|
|
2576
|
+
let found;
|
|
2577
|
+
try {
|
|
2578
|
+
found = JSON.parse(line.slice(PART_BOXES_PREFIX.length));
|
|
2579
|
+
} catch {
|
|
2580
|
+
return {};
|
|
2581
|
+
}
|
|
2582
|
+
if (!found || typeof found !== 'object' || Array.isArray(found)) return {};
|
|
2583
|
+
/** @type {Record<string, Array<[number, number]>>} */
|
|
2584
|
+
const boxes = {};
|
|
2585
|
+
for (const [part, list] of Object.entries(found))
|
|
2586
|
+
if (Array.isArray(list))
|
|
2587
|
+
boxes[part] = list.filter(
|
|
2588
|
+
(/** @type {unknown} */ b) =>
|
|
2589
|
+
Array.isArray(b) &&
|
|
2590
|
+
b.length === 2 &&
|
|
2591
|
+
b.every(n => typeof n === 'number'),
|
|
2592
|
+
);
|
|
2593
|
+
return {boxes};
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2343
2596
|
/** A Chrome or Chromium on this machine, at a usual place or on PATH. */
|
|
2344
2597
|
function chromeBinary() {
|
|
2345
2598
|
const names = [
|
|
@@ -6,11 +6,19 @@
|
|
|
6
6
|
* of the node_modules that holds the Core the command reads (the
|
|
7
7
|
* project's own, or a workspace root's). The locks and the part-data cache
|
|
8
8
|
* both live here, so one command never finds two answers. Null without
|
|
9
|
-
* Core
|
|
9
|
+
* Core, and null under Yarn Plug'n'Play: there Core resolves into a
|
|
10
|
+
* read-only package archive, which is no node_modules.
|
|
10
11
|
* @param {string} dir
|
|
11
12
|
* @returns {string | null}
|
|
12
13
|
*/
|
|
13
14
|
export function themeCacheRoot(dir: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Refuse a Yarn Plug'n'Play app: it has no node_modules for the editor to
|
|
17
|
+
* read Core from, or to keep its locks and cache in. Its .pnp.cjs sits at
|
|
18
|
+
* the app or at the workspace root above it.
|
|
19
|
+
* @param {string} dir the app folder, or a folder in it
|
|
20
|
+
*/
|
|
21
|
+
export function refusePlugAndPlay(dir: string): void;
|
|
14
22
|
/**
|
|
15
23
|
* The step that adds packages to the app: the install guidance its
|
|
16
24
|
* integrations give, else {@link packageManagerAddLine}.
|
|
@@ -80,12 +88,13 @@ export function baseThemeFile(project: ThemeProject, like: string): string;
|
|
|
80
88
|
* Resolved tokens of the base theme in both modes.
|
|
81
89
|
* @param {ThemeProject} project
|
|
82
90
|
* @param {string | undefined} like
|
|
83
|
-
* @returns {Promise<{light: Record<string, string>, dark: Record<string, string>, components: Record<string, any>}>}
|
|
91
|
+
* @returns {Promise<{light: Record<string, string>, dark: Record<string, string>, components: Record<string, any>, onDark: Record<string, string>}>}
|
|
84
92
|
*/
|
|
85
93
|
export function baseResolved(project: ThemeProject, like: string | undefined): Promise<{
|
|
86
94
|
light: Record<string, string>;
|
|
87
95
|
dark: Record<string, string>;
|
|
88
96
|
components: Record<string, any>;
|
|
97
|
+
onDark: Record<string, string>;
|
|
89
98
|
}>;
|
|
90
99
|
export function literals(type: string): string[];
|
|
91
100
|
export function baseInstalled(from: ThemeProject | string, like: string): boolean;
|
|
@@ -101,9 +110,10 @@ export type ThemeProject = {
|
|
|
101
110
|
*/
|
|
102
111
|
coreKey: string;
|
|
103
112
|
/**
|
|
104
|
-
* - node_modules/.cache/astryx-theme/<coreKey
|
|
113
|
+
* - node_modules/.cache/astryx-theme/<coreKey>;
|
|
114
|
+
* null under Yarn Plug'n'Play, which has no node_modules to keep it in
|
|
105
115
|
*/
|
|
106
|
-
cacheDir: string;
|
|
116
|
+
cacheDir: string | null;
|
|
107
117
|
/**
|
|
108
118
|
* - Core's theme module.
|
|
109
119
|
*/
|