@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
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 +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
package/api/theme-edit/_edit.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
coversTyped,
|
|
34
34
|
readsTyped,
|
|
35
35
|
withoutCopyDebris,
|
|
36
|
+
withoutDebris,
|
|
36
37
|
baseWord,
|
|
37
38
|
typoNear,
|
|
38
39
|
stateSpelling,
|
|
@@ -79,6 +80,7 @@ import {
|
|
|
79
80
|
closestOf,
|
|
80
81
|
partsOf,
|
|
81
82
|
undoArgs,
|
|
83
|
+
isCheckNote,
|
|
82
84
|
withoutBadValues,
|
|
83
85
|
NAME_RULE,
|
|
84
86
|
HISTORY_STEPS,
|
|
@@ -116,6 +118,7 @@ import {
|
|
|
116
118
|
ownSourceTokens,
|
|
117
119
|
ownSourceTokenValues,
|
|
118
120
|
ownTokenEntries,
|
|
121
|
+
fontOf,
|
|
119
122
|
ownThemeInput,
|
|
120
123
|
describeValue,
|
|
121
124
|
settingsThemeName,
|
|
@@ -146,6 +149,7 @@ import {
|
|
|
146
149
|
skips,
|
|
147
150
|
OPEN_SECTION,
|
|
148
151
|
FOLLOWS,
|
|
152
|
+
baseRedraws,
|
|
149
153
|
} from './_settings.mjs';
|
|
150
154
|
import {
|
|
151
155
|
checkSetting,
|
|
@@ -173,6 +177,7 @@ import {
|
|
|
173
177
|
roleWeightTokens,
|
|
174
178
|
typographyValueProblem,
|
|
175
179
|
} from '../theme/build/typography-values.mjs';
|
|
180
|
+
import {radiusInputProblems} from '../theme/build/radius-values.mjs';
|
|
176
181
|
import {
|
|
177
182
|
derivedPrivateCopies,
|
|
178
183
|
spreadPrivateVarMessage,
|
|
@@ -182,8 +187,10 @@ import {
|
|
|
182
187
|
CUSTOM_PROPERTY,
|
|
183
188
|
customPropertyCycle,
|
|
184
189
|
cycleProblem,
|
|
190
|
+
writtenPrimitive,
|
|
185
191
|
} from '../theme/build/written-values.mjs';
|
|
186
192
|
import {colorProblem, hex, parseColor} from './_color.mjs';
|
|
193
|
+
import {hexToOklch, oklchClampedHex} from '../theme/palette/generate/color.mjs';
|
|
187
194
|
import {
|
|
188
195
|
PALETTE_DIALS,
|
|
189
196
|
VIBRANCY_DEFAULT,
|
|
@@ -244,7 +251,9 @@ import {
|
|
|
244
251
|
stampSheet,
|
|
245
252
|
lookAtPictures,
|
|
246
253
|
familyPages,
|
|
254
|
+
FAMILY_PICTURE_HEIGHT,
|
|
247
255
|
FAMILY_SECTIONS,
|
|
256
|
+
UNWRITABLE,
|
|
248
257
|
FAMILY_OVERVIEW,
|
|
249
258
|
} from './_context.mjs';
|
|
250
259
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
@@ -943,6 +952,19 @@ async function newTheme(
|
|
|
943
952
|
const fixed =
|
|
944
953
|
present ?? readings[0] ?? slugFor(path_ ? typedThemeName(typed) : typed);
|
|
945
954
|
const exists = Boolean(present);
|
|
955
|
+
// A token's name typed where the theme's name goes, with or without
|
|
956
|
+
// its dashes (`--color-accent`, `Color-Accent`), is no theme to make:
|
|
957
|
+
// the editor reads a token by either spelling, so a free name is
|
|
958
|
+
// offered instead, as for a dial's name.
|
|
959
|
+
const asToken = await (async () => {
|
|
960
|
+
if (exists || !/^[a-z][a-z0-9-]*$/i.test(typed)) return false;
|
|
961
|
+
try {
|
|
962
|
+
const {C} = await context(cwd);
|
|
963
|
+
return Boolean(C.isToken(`--${typed.toLowerCase()}`));
|
|
964
|
+
} catch {
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
})();
|
|
946
968
|
// Dial settings typed where the name goes (`'accent: red'`, `{"accent":
|
|
947
969
|
// "red"}`): a free name, with those settings as their options, checked
|
|
948
970
|
// as every new line is.
|
|
@@ -972,7 +994,7 @@ async function newTheme(
|
|
|
972
994
|
againLines(
|
|
973
995
|
usableNewName(
|
|
974
996
|
cwd,
|
|
975
|
-
namesSettingAsTyped(typed) ? 'my-theme' : fixed,
|
|
997
|
+
namesSettingAsTyped(typed) || asToken ? 'my-theme' : fixed,
|
|
976
998
|
),
|
|
977
999
|
),
|
|
978
1000
|
},
|
|
@@ -1092,7 +1114,14 @@ async function newTheme(
|
|
|
1092
1114
|
reason: likeFixed ? 'do this instead' : 'build on no theme',
|
|
1093
1115
|
},
|
|
1094
1116
|
]),
|
|
1095
|
-
|
|
1117
|
+
// A spelling is a did-you-mean; the same word with copy debris on
|
|
1118
|
+
// it (`neutral'`, `neutral,`) is no other word, so none is said.
|
|
1119
|
+
...(likeFixed &&
|
|
1120
|
+
baseWord(
|
|
1121
|
+
withoutDebris(withoutCopyDebris(String(options.like ?? ''))),
|
|
1122
|
+
) !== likeFixed
|
|
1123
|
+
? [{name: likeFixed, reason: 'did you mean'}]
|
|
1124
|
+
: []),
|
|
1096
1125
|
],
|
|
1097
1126
|
E.ERR_THEME_BAD_VALUE,
|
|
1098
1127
|
);
|
|
@@ -1274,7 +1303,38 @@ async function newTheme(
|
|
|
1274
1303
|
...data.settings.map(describe),
|
|
1275
1304
|
],
|
|
1276
1305
|
notes,
|
|
1277
|
-
|
|
1306
|
+
// Text it made unreadable, then the contrast checks its color dials
|
|
1307
|
+
// fail (a pale accent that does not stand out from the page), as a
|
|
1308
|
+
// change of that dial says them.
|
|
1309
|
+
problems: [
|
|
1310
|
+
...r.problems,
|
|
1311
|
+
...(await (async () => {
|
|
1312
|
+
const dials = [
|
|
1313
|
+
...new Set(
|
|
1314
|
+
data.settings
|
|
1315
|
+
.filter(s => PALETTE_DIALS.includes(s.thing))
|
|
1316
|
+
.map(s => s.thing),
|
|
1317
|
+
),
|
|
1318
|
+
];
|
|
1319
|
+
if (!dials.length) return [];
|
|
1320
|
+
const pal = paletteMapping(
|
|
1321
|
+
cwd,
|
|
1322
|
+
name,
|
|
1323
|
+
data,
|
|
1324
|
+
await baseResolved(ctx.project, data.like),
|
|
1325
|
+
ctx.project.core.tokenDefaults,
|
|
1326
|
+
);
|
|
1327
|
+
const seen = new Set();
|
|
1328
|
+
return dials.flatMap(d =>
|
|
1329
|
+
paletteFailures(pal, d, modesOf(data))
|
|
1330
|
+
.filter(x => !seen.has(x.key) && seen.add(x.key))
|
|
1331
|
+
.map(x => x.text),
|
|
1332
|
+
);
|
|
1333
|
+
})()),
|
|
1334
|
+
],
|
|
1335
|
+
// What the colors and dials it started with did not reach, as a
|
|
1336
|
+
// change reports it.
|
|
1337
|
+
...(await missedSummary(ctx, name, data, r.res)),
|
|
1278
1338
|
...p,
|
|
1279
1339
|
// How to use the theme in this app: theme add <theme> for its app copy.
|
|
1280
1340
|
wiring: appWiring(ctx, name, data),
|
|
@@ -1983,7 +2043,7 @@ function modeWiringNotes(cwd, slug, before, after) {
|
|
|
1983
2043
|
: []),
|
|
1984
2044
|
...(now && !was
|
|
1985
2045
|
? [
|
|
1986
|
-
`the app shows ${slug} in ${now} mode when its <Theme> is given mode="${now}" (
|
|
2046
|
+
`the app shows ${slug} in ${now} mode when its <Theme> is given mode="${now}": \`${P.replace(' experimental theme editor', '')} theme add ${slug}\` records the theme and its mode, and the wiring it prints passes it (mode={themeModes[defaultThemeSlug] ?? 'system'}), so nothing else is needed; give it yourself only where the app renders <Theme> on its own. The theme keeps both halves of its colors, so a toast or a lightbox Core draws in the other mode stays readable`,
|
|
1987
2047
|
]
|
|
1988
2048
|
: []),
|
|
1989
2049
|
];
|
|
@@ -2942,6 +3002,16 @@ export async function editorStoredRefusal(root, slug) {
|
|
|
2942
3002
|
}
|
|
2943
3003
|
}
|
|
2944
3004
|
|
|
3005
|
+
/**
|
|
3006
|
+
* A value as the build writes it (written-values' `writtenPrimitive`): a
|
|
3007
|
+
* BigInt as its digits, a boxed primitive (`new String('red')`) as its
|
|
3008
|
+
* primitive, each half of a pair too; any other value as it is.
|
|
3009
|
+
* @param {unknown} value
|
|
3010
|
+
* @returns {unknown}
|
|
3011
|
+
*/
|
|
3012
|
+
const asPrimitive = value =>
|
|
3013
|
+
Array.isArray(value) ? value.map(writtenPrimitive) : writtenPrimitive(value);
|
|
3014
|
+
|
|
2945
3015
|
/** @type {WeakMap<object, Record<string, Record<string, unknown>>>} */
|
|
2946
3016
|
const coreSurfaces = new WeakMap();
|
|
2947
3017
|
/**
|
|
@@ -3177,6 +3247,9 @@ async function ownTokenProblems(ctx, slug, data) {
|
|
|
3177
3247
|
// A null token leaves it unset: the build writes it as it is and warns
|
|
3178
3248
|
// at its line.
|
|
3179
3249
|
if (value === null) return null;
|
|
3250
|
+
// A boxed primitive (`new String('red')`) is written as its primitive,
|
|
3251
|
+
// so it is judged as that.
|
|
3252
|
+
value = asPrimitive(value);
|
|
3180
3253
|
const custom = !(token in known);
|
|
3181
3254
|
if (Array.isArray(value)) {
|
|
3182
3255
|
if (value.length !== 2 || value.some(h => typeof h !== 'string'))
|
|
@@ -3229,6 +3302,7 @@ async function ownTokenProblems(ctx, slug, data) {
|
|
|
3229
3302
|
* @returns {string | null}
|
|
3230
3303
|
*/
|
|
3231
3304
|
const judgeProperty = (prop, value, file, reads, component) => {
|
|
3305
|
+
value = asPrimitive(value);
|
|
3232
3306
|
// A family list is read as set reads one for that part (a comma
|
|
3233
3307
|
// missing before a generic family, a quoted generic, a dial word):
|
|
3234
3308
|
// font-family's value, and the families a `font` shorthand names last.
|
|
@@ -4031,6 +4105,17 @@ async function ownTokenProblems(ctx, slug, data) {
|
|
|
4031
4105
|
...(e ? atOf(e) : {line: null, file: null}),
|
|
4032
4106
|
});
|
|
4033
4107
|
}
|
|
4108
|
+
// The radius scale: a field missing builds every scaled corner as NaNpx.
|
|
4109
|
+
{
|
|
4110
|
+
const e = entries.find(x => x.kind === 'field' && x.key === 'radius');
|
|
4111
|
+
for (const r of radiusInputProblems(input.radius))
|
|
4112
|
+
out.push({
|
|
4113
|
+
token: r.path.join('.'),
|
|
4114
|
+
value: typeof r.value === 'string' ? r.value : '',
|
|
4115
|
+
why: r.why,
|
|
4116
|
+
...(e ? atOf(e) : {line: null, file: null}),
|
|
4117
|
+
});
|
|
4118
|
+
}
|
|
4034
4119
|
const tokens = loaded?.theme?.tokens;
|
|
4035
4120
|
if (input.typography && tokens && typeof tokens === 'object') {
|
|
4036
4121
|
/** @param {string} role */
|
|
@@ -4339,6 +4424,10 @@ function carryTyped(e, sub, slug, thing, typed, data, cwd = process.cwd()) {
|
|
|
4339
4424
|
typedThing: String(thing),
|
|
4340
4425
|
saved,
|
|
4341
4426
|
mode: / --mode (light|dark)\b/.exec(x.name)?.[1] ?? '',
|
|
4427
|
+
scope: {
|
|
4428
|
+
on: / --on '?([a-z][a-z0-9-]*)/.exec(x.name)?.[1],
|
|
4429
|
+
state: / --state '?([a-z][a-z0-9-]*)/.exec(x.name)?.[1],
|
|
4430
|
+
},
|
|
4342
4431
|
});
|
|
4343
4432
|
});
|
|
4344
4433
|
const covered = coversTyped(reads, typedText, String(thing));
|
|
@@ -5927,9 +6016,21 @@ async function changeOnce(
|
|
|
5927
6016
|
}
|
|
5928
6017
|
})()
|
|
5929
6018
|
: new Set();
|
|
5930
|
-
/**
|
|
6019
|
+
/**
|
|
6020
|
+
* The checks a change made fail, each with the line that passes it when
|
|
6021
|
+
* one does (a darker exact color for a pale fill).
|
|
6022
|
+
* @param {Array<{key: string, text: string, fix?: {thing: string, value: string, mode?: string}}>} found
|
|
6023
|
+
* @returns {Array<{problem: string, fix: string | null}>}
|
|
6024
|
+
*/
|
|
5931
6025
|
const newFailures = found =>
|
|
5932
|
-
found
|
|
6026
|
+
found
|
|
6027
|
+
.filter(x => !paletteFailedBefore.has(x.key))
|
|
6028
|
+
.map(x => ({
|
|
6029
|
+
problem: x.text,
|
|
6030
|
+
fix: x.fix
|
|
6031
|
+
? `${P} set ${slug} ${x.fix.thing} ${quoteCommandArgument(x.fix.value)}${x.fix.mode && modesOf(data).length > 1 ? ` --mode ${x.fix.mode}` : ''}`
|
|
6032
|
+
: null,
|
|
6033
|
+
}));
|
|
5933
6034
|
if (sub === 'set' && (s.thing === 'base' || s.thing === 'mode')) {
|
|
5934
6035
|
const before = s.thing === 'base' ? (data.like ?? 'none') : data.mode;
|
|
5935
6036
|
if (s.thing === 'base') {
|
|
@@ -5958,13 +6059,16 @@ async function changeOnce(
|
|
|
5958
6059
|
parts: [],
|
|
5959
6060
|
group: null,
|
|
5960
6061
|
changedTokens: r.changed,
|
|
6062
|
+
changedPartTokens: r.changedParts ?? [],
|
|
5961
6063
|
styled: styledChanges(compiledBefore, compileTheme(ctx, data, after)),
|
|
5962
6064
|
kept: [],
|
|
5963
6065
|
lifted: r.lifted,
|
|
5964
6066
|
leftOut: [],
|
|
5965
6067
|
notes: [
|
|
5966
6068
|
...(r.unchanged
|
|
5967
|
-
? [
|
|
6069
|
+
? [
|
|
6070
|
+
`no change: ${s.thing} is already ${s.value}, so nothing was built and no undo step was added`,
|
|
6071
|
+
]
|
|
5968
6072
|
: []),
|
|
5969
6073
|
...fieldNotes,
|
|
5970
6074
|
...r.notes,
|
|
@@ -6004,7 +6108,7 @@ async function changeOnce(
|
|
|
6004
6108
|
!appListsTheme(cwd, slug) &&
|
|
6005
6109
|
(data.mode === 'light-only' || data.mode === 'dark-only')
|
|
6006
6110
|
? [
|
|
6007
|
-
`the app shows ${slug} in ${data.mode === 'light-only' ? 'light' : 'dark'} mode when its <Theme> is given mode="${data.mode === 'light-only' ? 'light' : 'dark'}" (
|
|
6111
|
+
`the app shows ${slug} in ${data.mode === 'light-only' ? 'light' : 'dark'} mode when its <Theme> is given mode="${data.mode === 'light-only' ? 'light' : 'dark'}": \`${P.replace(' experimental theme editor', '')} theme add ${slug}\` records the theme and its mode, and the wiring it prints passes it (mode={themeModes[defaultThemeSlug] ?? 'system'}), so nothing else is needed; give it yourself only where the app renders <Theme> on its own. The theme keeps both halves of its colors, so a toast or a lightbox Core draws in the other mode stays readable`,
|
|
6008
6112
|
]
|
|
6009
6113
|
: []),
|
|
6010
6114
|
// The colors are made again for the new base or mode: their
|
|
@@ -6044,15 +6148,29 @@ async function changeOnce(
|
|
|
6044
6148
|
// never a line that removes one of them.
|
|
6045
6149
|
if (value != null && value !== '' && namesSaved(value))
|
|
6046
6150
|
undoList(`${thing} ${value}`, E.ERR_THEME_NOT_SET);
|
|
6047
|
-
// A
|
|
6048
|
-
//
|
|
6151
|
+
// A property set in another form of the same family on the same
|
|
6152
|
+
// part is a near one too: a padding side for the shorthand (or the
|
|
6153
|
+
// other way), and a shorthand for the longhand it writes
|
|
6154
|
+
// (`background` for `background-color`, as CSS reads them).
|
|
6049
6155
|
const PAD = /^padding(?:-(?:inline|block|top|right|bottom|left))?$/;
|
|
6156
|
+
/** The shorthand a property belongs to. @param {string} t */
|
|
6157
|
+
const family = t =>
|
|
6158
|
+
PAD.test(t)
|
|
6159
|
+
? 'padding'
|
|
6160
|
+
: /^(?:background|border|font|margin|outline|transition|flex|grid|list-style|overflow|place|gap|inset)(?:-|$)/.test(
|
|
6161
|
+
t,
|
|
6162
|
+
)
|
|
6163
|
+
? /^[a-z]+/.exec(t)?.[0]
|
|
6164
|
+
: null;
|
|
6165
|
+
const sameFamily = family(s.thing);
|
|
6050
6166
|
const nearOnes = data.settings.filter(
|
|
6051
6167
|
x =>
|
|
6052
6168
|
x.thing === s.thing ||
|
|
6053
|
-
(
|
|
6054
|
-
|
|
6055
|
-
(x.on ?? null) === (s.on ?? null)
|
|
6169
|
+
(sameFamily != null &&
|
|
6170
|
+
family(x.thing) === sameFamily &&
|
|
6171
|
+
(x.on ?? null) === (s.on ?? null) &&
|
|
6172
|
+
(x.when ?? null) === (s.when ?? null) &&
|
|
6173
|
+
(x.state ?? null) === (s.state ?? null)),
|
|
6056
6174
|
);
|
|
6057
6175
|
const near = nearOnes.map(describe);
|
|
6058
6176
|
// A token the theme's own source sets: that file is where it is
|
|
@@ -6233,6 +6351,7 @@ async function changeOnce(
|
|
|
6233
6351
|
)
|
|
6234
6352
|
: [];
|
|
6235
6353
|
const r = await commitTheme(ctx, slug, data, {history: true});
|
|
6354
|
+
await sayNextStepClears(ctx, slug, s, r);
|
|
6236
6355
|
const compiledAfter = compileTheme(ctx, data, base);
|
|
6237
6356
|
// What the spacing dial said of the sizes it could not keep apart.
|
|
6238
6357
|
// What the build said of settings it could not write as they are.
|
|
@@ -6809,7 +6928,7 @@ async function changeOnce(
|
|
|
6809
6928
|
notes.push(
|
|
6810
6929
|
`${slug}.theme.ts sets ${ownWins.slice(0, 4).join(', ')}${ownWins.length > 4 ? ` and ${ownWins.length - 4} more` : ''} itself, and your own source wins over the settings, so ${ownWins.length > 1 ? 'those do' : 'that does'} not change; ${ownTakeOut(slug, s.thing, ownWins, data)}`,
|
|
6811
6930
|
);
|
|
6812
|
-
/** The contrast checks the colors this change made fail. @type {string
|
|
6931
|
+
/** The contrast checks the colors this change made fail. @type {Array<{problem: string, fix: string | null}>} */
|
|
6813
6932
|
const colorFails = [];
|
|
6814
6933
|
const dialPal =
|
|
6815
6934
|
PALETTE_DIALS.includes(s.thing) && sub === 'set'
|
|
@@ -6881,6 +7000,34 @@ async function changeOnce(
|
|
|
6881
7000
|
]
|
|
6882
7001
|
: []),
|
|
6883
7002
|
);
|
|
7003
|
+
// A whole-theme token the base theme draws past on some parts (its own
|
|
7004
|
+
// rule for the part sets the property the token feeds in Core): the
|
|
7005
|
+
// token never reaches those, and the result says so, with the command
|
|
7006
|
+
// that does.
|
|
7007
|
+
if (
|
|
7008
|
+
sub === 'set' &&
|
|
7009
|
+
s.source === 'token' &&
|
|
7010
|
+
!s.on &&
|
|
7011
|
+
!s.when &&
|
|
7012
|
+
!s.state &&
|
|
7013
|
+
ctx.C?.MAP
|
|
7014
|
+
)
|
|
7015
|
+
for (const r of baseRedraws(ctx.C, base, s.thing)) {
|
|
7016
|
+
// (Unless the theme already sets it there itself.)
|
|
7017
|
+
if (
|
|
7018
|
+
data.settings.some(
|
|
7019
|
+
x =>
|
|
7020
|
+
x.source === 'property' &&
|
|
7021
|
+
x.thing === r.prop &&
|
|
7022
|
+
(x.when ?? null) === (r.when ? r.when : null) &&
|
|
7023
|
+
partsOf(ctx, x).includes(r.part),
|
|
7024
|
+
)
|
|
7025
|
+
)
|
|
7026
|
+
continue;
|
|
7027
|
+
notes.push(
|
|
7028
|
+
`${r.part}${r.when ? ` (${r.when.replace(':', ' ')})` : ''} does not use ${s.thing}: the ${data.like ?? 'base'} theme draws its ${r.prop} from ${r.value} there; to change it: ${P} set ${slug} ${r.prop} ${quoteCommandArgument(String(s.value))} --on ${r.part}${r.when ? ` --when ${r.when}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`,
|
|
7029
|
+
);
|
|
7030
|
+
}
|
|
6884
7031
|
// A token another one follows (the surface's fills, the emphasized
|
|
6885
7032
|
// border) says what moved with it.
|
|
6886
7033
|
if (sub === 'set' && s.source === 'token' && !s.on && !s.when && !s.state) {
|
|
@@ -6922,6 +7069,25 @@ async function changeOnce(
|
|
|
6922
7069
|
if (s.thing === 'neutral' && sub === 'set') {
|
|
6923
7070
|
// Only the theme's own modes; a dark theme gets no white-page offer.
|
|
6924
7071
|
const modes = modesOf(data);
|
|
7072
|
+
// A gray whose shades are the base theme's own grays (black or white,
|
|
7073
|
+
// which every gray ramp ends with, or the base's own gray): the page,
|
|
7074
|
+
// surfaces, text and borders keep their colors. A gray sets the tint of
|
|
7075
|
+
// the grays, never how light or dark the surfaces are.
|
|
7076
|
+
const GRAYS_SHOWN = [
|
|
7077
|
+
'--color-background-body',
|
|
7078
|
+
'--color-background-surface',
|
|
7079
|
+
'--color-background-card',
|
|
7080
|
+
'--color-text-primary',
|
|
7081
|
+
'--color-text-secondary',
|
|
7082
|
+
'--color-border-emphasized',
|
|
7083
|
+
];
|
|
7084
|
+
const moved = /** @type {unknown[]} */ (r.changed ?? []).map(
|
|
7085
|
+
c => String(c).split(/[\s:]/)[0],
|
|
7086
|
+
);
|
|
7087
|
+
if (!GRAYS_SHOWN.some(k => moved.includes(k)))
|
|
7088
|
+
notes.push(
|
|
7089
|
+
`neutral ${s.value} grows the same grays the ${data.like ?? 'base'} theme already shows, so its page, surfaces, text and borders keep their colors${moved.length ? ` (only ${[...new Set(moved)].join(', ')} changed)` : ''}: a gray sets the tint of the grays, not how light or dark the surfaces are. For dark surfaces: ${P} set ${slug} mode dark-only, or set --color-background-surface and --color-background-body to the colors you want`,
|
|
7090
|
+
);
|
|
6925
7091
|
const pinned = data.settings.some(
|
|
6926
7092
|
x =>
|
|
6927
7093
|
x.source === 'token' &&
|
|
@@ -6938,6 +7104,9 @@ async function changeOnce(
|
|
|
6938
7104
|
}`,
|
|
6939
7105
|
);
|
|
6940
7106
|
}
|
|
7107
|
+
if (s.thing === 'accent' && sub === 'set') {
|
|
7108
|
+
notes.push(...infoClashNotes(data, base, slug, String(s.value)));
|
|
7109
|
+
}
|
|
6941
7110
|
if (s.thing === 'vibrancy') {
|
|
6942
7111
|
notes.push(
|
|
6943
7112
|
sub === 'set'
|
|
@@ -6954,7 +7123,10 @@ async function changeOnce(
|
|
|
6954
7123
|
/^--font-family-/.test(s.thing)) &&
|
|
6955
7124
|
sub === 'set'
|
|
6956
7125
|
)
|
|
6957
|
-
notes.unshift(
|
|
7126
|
+
notes.unshift(
|
|
7127
|
+
...ownFamilyNotes(ctx, slug, s),
|
|
7128
|
+
...fontNotes(ctx, {...data, settings: [s]}),
|
|
7129
|
+
);
|
|
6958
7130
|
if (s.thing === 'type' || s.thing === 'headings')
|
|
6959
7131
|
for (const [m, why] of maskedSettings(data, ctx))
|
|
6960
7132
|
notes.push(`${describe(m)}: ${why}`);
|
|
@@ -7038,6 +7210,7 @@ async function changeOnce(
|
|
|
7038
7210
|
}
|
|
7039
7211
|
: null,
|
|
7040
7212
|
changedTokens: r.changed,
|
|
7213
|
+
changedPartTokens: r.changedParts ?? [],
|
|
7041
7214
|
styled,
|
|
7042
7215
|
kept,
|
|
7043
7216
|
lifted: r.lifted,
|
|
@@ -7047,41 +7220,62 @@ async function changeOnce(
|
|
|
7047
7220
|
// contrast checks the colors it made fail.
|
|
7048
7221
|
newProblems: [
|
|
7049
7222
|
...problemLines(r.newProblems),
|
|
7050
|
-
...colorFails
|
|
7223
|
+
...colorFails,
|
|
7051
7224
|
// Text the sample page's pictures draw cut short, with the line
|
|
7052
7225
|
// the browser measured as keeping it whole.
|
|
7053
7226
|
...cutShort.map(c => cutShortProblem(ctx, slug, c)),
|
|
7054
7227
|
],
|
|
7055
|
-
|
|
7056
|
-
// the line that reaches it), and on how many parts (a part can miss
|
|
7057
|
-
// two ways: its border and its shadow).
|
|
7058
|
-
// (Left out when none is missed.)
|
|
7059
|
-
...(await (async () => {
|
|
7060
|
-
const list = await missedParts(
|
|
7061
|
-
ctx,
|
|
7062
|
-
slug,
|
|
7063
|
-
data,
|
|
7064
|
-
// The theme's tokens as they are now: a change that changed
|
|
7065
|
-
// nothing comes back with none of its own.
|
|
7066
|
-
Object.keys(r.res?.light ?? {}).length
|
|
7067
|
-
? r.res
|
|
7068
|
-
: await resolvedTokens(ctx, slug),
|
|
7069
|
-
await baseResolved(ctx.project, data.like),
|
|
7070
|
-
{count: true},
|
|
7071
|
-
).catch(() => []);
|
|
7072
|
-
return list.length
|
|
7073
|
-
? {
|
|
7074
|
-
missed: list.length,
|
|
7075
|
-
missedParts: new Set(list.map(m => m.part)).size,
|
|
7076
|
-
}
|
|
7077
|
-
: {};
|
|
7078
|
-
})()),
|
|
7228
|
+
...(await missedSummary(ctx, slug, data, r.res)),
|
|
7079
7229
|
warnings: r.warnings,
|
|
7080
7230
|
...p,
|
|
7081
7231
|
},
|
|
7082
7232
|
};
|
|
7083
7233
|
}
|
|
7084
7234
|
|
|
7235
|
+
/**
|
|
7236
|
+
* When the theme sets a colored accent and leaves info unset, and the base
|
|
7237
|
+
* theme's info is a strong color whose hue is far from the accent's (and
|
|
7238
|
+
* from a colored neutral's): info's banners and badges keep that hue in a
|
|
7239
|
+
* palette that has none of it (a bright blue info in a pink theme). Says
|
|
7240
|
+
* so, with an info between the two hues at info's own lightness and a
|
|
7241
|
+
* little less strength, so it sits with the palette and stays apart from
|
|
7242
|
+
* the accent.
|
|
7243
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
7244
|
+
* @param {{light: Record<string, string>, dark: Record<string, string>}} base
|
|
7245
|
+
* @param {string} slug
|
|
7246
|
+
* @param {string} accent the accent color set
|
|
7247
|
+
* @returns {string[]}
|
|
7248
|
+
*/
|
|
7249
|
+
function infoClashNotes(data, base, slug, accent) {
|
|
7250
|
+
if (data.settings.some(x => x.source === 'dial' && x.thing === 'info'))
|
|
7251
|
+
return [];
|
|
7252
|
+
const info = parseColor(String(base.light['--color-info'] ?? ''));
|
|
7253
|
+
const now = parseColor(accent);
|
|
7254
|
+
if (!info || !now) return [];
|
|
7255
|
+
const i = hexToOklch(hex(info));
|
|
7256
|
+
const n = hexToOklch(hex(now));
|
|
7257
|
+
/** @param {number} a @param {number} b */
|
|
7258
|
+
const apart = (a, b) => Math.abs(((a - b + 540) % 360) - 180);
|
|
7259
|
+
if (i.C < 0.08 || n.C < 0.05 || apart(i.H, n.H) <= 60) return [];
|
|
7260
|
+
const neutral = [...data.settings]
|
|
7261
|
+
.reverse()
|
|
7262
|
+
.find(x => x.source === 'dial' && x.thing === 'neutral' && !x.on);
|
|
7263
|
+
const gray = neutral && parseColor(String(neutral.value));
|
|
7264
|
+
if (gray) {
|
|
7265
|
+
const g = hexToOklch(hex(gray));
|
|
7266
|
+
if (g.C >= 0.02 && apart(i.H, g.H) <= 60) return [];
|
|
7267
|
+
}
|
|
7268
|
+
const turn = ((n.H - i.H + 540) % 360) - 180;
|
|
7269
|
+
const between = oklchClampedHex(
|
|
7270
|
+
i.L,
|
|
7271
|
+
i.C * 0.85,
|
|
7272
|
+
(i.H + turn / 2 + 360) % 360,
|
|
7273
|
+
);
|
|
7274
|
+
return [
|
|
7275
|
+
`info (banners, info badges) keeps the base theme's ${hex(info)}, a hue your accent ${accent} does not share; for an info that sits with your palette and stays apart from the accent: ${P} set ${slug} info ${quoteCommandArgument(between)}`,
|
|
7276
|
+
];
|
|
7277
|
+
}
|
|
7278
|
+
|
|
7085
7279
|
/**
|
|
7086
7280
|
* Which status colors the theme does not set, so they keep the base theme's
|
|
7087
7281
|
* values whatever the vibrancy, with the commands that bring them in: each
|
|
@@ -7375,7 +7569,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
7375
7569
|
const ownMasked = ownOverNotes.map(n => n.slice(0, n.indexOf(': ')));
|
|
7376
7570
|
const checked = await contrastProblems(ctx, data, res);
|
|
7377
7571
|
// What cannot be measured is a note, not a problem.
|
|
7378
|
-
const shownChecks = checked.filter(x => !x
|
|
7572
|
+
const shownChecks = checked.filter(x => !isCheckNote(x));
|
|
7379
7573
|
const problems = shownChecks.map(x => x.text);
|
|
7380
7574
|
const pal = paletteMapping(
|
|
7381
7575
|
cwd,
|
|
@@ -7502,12 +7696,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
7502
7696
|
} catch (e) {
|
|
7503
7697
|
// A theme folder it cannot write is the pictures' problem: the
|
|
7504
7698
|
// picture run names the folder, and show stands.
|
|
7505
|
-
if (
|
|
7506
|
-
['EACCES', 'EPERM', 'EROFS', 'ENOSPC'].includes(
|
|
7507
|
-
/** @type {any} */ (e)?.code,
|
|
7508
|
-
)
|
|
7509
|
-
)
|
|
7510
|
-
return null;
|
|
7699
|
+
if (UNWRITABLE.includes(/** @type {any} */ (e)?.code)) return null;
|
|
7511
7700
|
throw e;
|
|
7512
7701
|
}
|
|
7513
7702
|
})
|
|
@@ -7520,15 +7709,24 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
7520
7709
|
[
|
|
7521
7710
|
{html: f.preview, png: f.previewPng, name: SAMPLE_PAGE_NAME},
|
|
7522
7711
|
...(open && !('problem' in open) ? [open] : []),
|
|
7523
|
-
|
|
7524
|
-
//
|
|
7525
|
-
|
|
7526
|
-
|
|
7712
|
+
// A family taller than a reader takes in whole is cut into
|
|
7713
|
+
// pictures of a readable height.
|
|
7714
|
+
...families.pages.map(({html, png: out}) => ({
|
|
7715
|
+
html,
|
|
7716
|
+
png: out,
|
|
7717
|
+
most: FAMILY_PICTURE_HEIGHT,
|
|
7718
|
+
})),
|
|
7719
|
+
// A section is photographed from its own sheet, a family cut
|
|
7720
|
+
// as above. The full sheet, every component, is too tall to
|
|
7721
|
+
// read whole and slow to take: it is not photographed.
|
|
7527
7722
|
...(section
|
|
7528
7723
|
? [
|
|
7529
7724
|
{
|
|
7530
7725
|
html: path.join(f.dir, `sheet-${section}.html`),
|
|
7531
7726
|
png: path.join(f.dir, `sheet-${section}.png`),
|
|
7727
|
+
...(FAMILY_SECTIONS.includes(section)
|
|
7728
|
+
? {most: FAMILY_PICTURE_HEIGHT}
|
|
7729
|
+
: {}),
|
|
7532
7730
|
},
|
|
7533
7731
|
]
|
|
7534
7732
|
: []),
|
|
@@ -7636,12 +7834,12 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
7636
7834
|
// A setting the theme file wins over is not live: no contrast
|
|
7637
7835
|
// caveat for it (its own note says it does not show).
|
|
7638
7836
|
...checked
|
|
7639
|
-
.map(x => x.text)
|
|
7640
7837
|
.filter(
|
|
7641
7838
|
x =>
|
|
7642
|
-
x
|
|
7643
|
-
!ownMasked.some(d => x.includes(` for ${d},`)),
|
|
7644
|
-
)
|
|
7839
|
+
isCheckNote(x) &&
|
|
7840
|
+
!ownMasked.some(d => x.text.includes(` for ${d},`)),
|
|
7841
|
+
)
|
|
7842
|
+
.map(x => x.text),
|
|
7645
7843
|
...fontNotes(ctx, data),
|
|
7646
7844
|
// Images and files of the theme the previews cannot show.
|
|
7647
7845
|
...themeImageNotes(ctx, theme),
|
|
@@ -7689,7 +7887,7 @@ export async function themeEditShow(theme, options = {}) {
|
|
|
7689
7887
|
// contrast, each with the command that fixes it when one does.
|
|
7690
7888
|
openProblems: [
|
|
7691
7889
|
...problemLines(shownChecks),
|
|
7692
|
-
...colorProblems
|
|
7890
|
+
...colorProblems,
|
|
7693
7891
|
// Text the sample page's pictures draw cut short, with the line
|
|
7694
7892
|
// the browser measured as keeping it whole.
|
|
7695
7893
|
...shots.cutShort.map(c => cutShortProblem(ctx, theme, c)),
|
|
@@ -7829,6 +8027,23 @@ function nowAppliesIn(ctx, data, removed, base) {
|
|
|
7829
8027
|
);
|
|
7830
8028
|
if (exact) return describe(exact);
|
|
7831
8029
|
}
|
|
8030
|
+
// Another setting of the same thing that still applies where this one
|
|
8031
|
+
// did (a whole-theme color removed over one saved for this mode): that
|
|
8032
|
+
// setting, not the base theme's value.
|
|
8033
|
+
if (!removed.on) {
|
|
8034
|
+
const still = [...data.settings]
|
|
8035
|
+
.reverse()
|
|
8036
|
+
.find(
|
|
8037
|
+
x =>
|
|
8038
|
+
x !== removed &&
|
|
8039
|
+
!x.on &&
|
|
8040
|
+
!x.when &&
|
|
8041
|
+
!x.state &&
|
|
8042
|
+
x.thing === removed.thing &&
|
|
8043
|
+
(removed.mode ? !x.mode || x.mode === removed.mode : Boolean(x.mode)),
|
|
8044
|
+
);
|
|
8045
|
+
if (still) return describe(still);
|
|
8046
|
+
}
|
|
7832
8047
|
// A token a dial still writes (an accent color feeds --color-accent):
|
|
7833
8048
|
// name that dial.
|
|
7834
8049
|
if (removed.source === 'token' && !removed.on) {
|
|
@@ -8284,6 +8499,82 @@ function unreachedParts(ctx, data, res, base) {
|
|
|
8284
8499
|
.map(x => x.part);
|
|
8285
8500
|
}
|
|
8286
8501
|
|
|
8502
|
+
/**
|
|
8503
|
+
* A problem a change made that the next step of a line the editor offered
|
|
8504
|
+
* clears: the change was the first step of a several-step missed line (a
|
|
8505
|
+
* tooltip's surface, then its text), and the problem sits on that line's
|
|
8506
|
+
* part. Its text says so, with that step, so a person running one step at
|
|
8507
|
+
* a time sees it is expected. Nothing is hidden: the problem stays listed.
|
|
8508
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
8509
|
+
* @param {string} slug
|
|
8510
|
+
* @param {import('./_settings.mjs').Setting} s the setting the change wrote
|
|
8511
|
+
* @param {{newProblems: Array<{text: string, key: string, fix: string | null}>, before?: import('./_settings.mjs').ThemeData | null, resBefore?: {light: Record<string, string>, dark: Record<string, string>} | null}} r
|
|
8512
|
+
*/
|
|
8513
|
+
async function sayNextStepClears(ctx, slug, s, r) {
|
|
8514
|
+
if (!r.newProblems.length || !r.before || !r.resBefore) return;
|
|
8515
|
+
const same = (/** @type {unknown} */ a, /** @type {unknown} */ b) =>
|
|
8516
|
+
String(a ?? '')
|
|
8517
|
+
.trim()
|
|
8518
|
+
.toLowerCase() ===
|
|
8519
|
+
String(b ?? '')
|
|
8520
|
+
.trim()
|
|
8521
|
+
.toLowerCase();
|
|
8522
|
+
const missed = missedSteps(
|
|
8523
|
+
ctx,
|
|
8524
|
+
r.before,
|
|
8525
|
+
r.resBefore,
|
|
8526
|
+
await baseResolved(ctx.project, r.before.like),
|
|
8527
|
+
);
|
|
8528
|
+
for (const m of missed) {
|
|
8529
|
+
const [first, next] = m.steps;
|
|
8530
|
+
if (
|
|
8531
|
+
!next ||
|
|
8532
|
+
!same(first.thing, s.thing) ||
|
|
8533
|
+
!same(first.value, s.value) ||
|
|
8534
|
+
!same(first.on, s.on) ||
|
|
8535
|
+
!same(first.mode, s.mode) ||
|
|
8536
|
+
!same(first.when, s.when) ||
|
|
8537
|
+
!same(first.state, s.state)
|
|
8538
|
+
)
|
|
8539
|
+
continue;
|
|
8540
|
+
const line = `${P} set ${slug} ${next.thing} ${quoteCommandArgument(next.value)}${next.on ? ` --on ${next.on}` : ''}${next.when ? ` --when ${next.when}` : ''}${next.state ? ` --state ${next.state}` : ''}${next.mode ? ` --mode ${next.mode}` : ''}`;
|
|
8541
|
+
for (const x of r.newProblems)
|
|
8542
|
+
if (new RegExp(`^text in ${m.part}\\b`).test(x.text))
|
|
8543
|
+
x.text += `; this was the first step of the line offered for ${m.part}, and its next step clears it: ${line}`;
|
|
8544
|
+
}
|
|
8545
|
+
}
|
|
8546
|
+
|
|
8547
|
+
/**
|
|
8548
|
+
* How many misses the theme's own changes left (show lists each with the
|
|
8549
|
+
* line that reaches it), on how many parts (a part can miss two ways: its
|
|
8550
|
+
* border and its shadow), and which: what a change or a new theme reports.
|
|
8551
|
+
* Left out when none is missed.
|
|
8552
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
8553
|
+
* @param {string} slug
|
|
8554
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
8555
|
+
* @param {{light: Record<string, string>, dark: Record<string, string>} | undefined} res
|
|
8556
|
+
* the theme's tokens as the change built them (a change that changed
|
|
8557
|
+
* nothing comes back with none: they are read again)
|
|
8558
|
+
* @returns {Promise<{missed?: number, missedParts?: number, missedOn?: string[]}>}
|
|
8559
|
+
*/
|
|
8560
|
+
async function missedSummary(ctx, slug, data, res) {
|
|
8561
|
+
if (!data.settings.length) return {};
|
|
8562
|
+
const list = await missedParts(
|
|
8563
|
+
ctx,
|
|
8564
|
+
slug,
|
|
8565
|
+
data,
|
|
8566
|
+
Object.keys(res?.light ?? {}).length
|
|
8567
|
+
? /** @type {any} */ (res)
|
|
8568
|
+
: await resolvedTokens(ctx, slug),
|
|
8569
|
+
await baseResolved(ctx.project, data.like),
|
|
8570
|
+
{count: true},
|
|
8571
|
+
).catch(() => []);
|
|
8572
|
+
const on = [...new Set(list.map(m => m.part))];
|
|
8573
|
+
return list.length
|
|
8574
|
+
? {missed: list.length, missedParts: on.length, missedOn: on}
|
|
8575
|
+
: {};
|
|
8576
|
+
}
|
|
8577
|
+
|
|
8287
8578
|
/**
|
|
8288
8579
|
* The parts the theme's own changes should have reached and did not, most
|
|
8289
8580
|
* flagged first, each with why and the line that reaches it, its steps
|
|
@@ -8442,7 +8733,7 @@ function partValues(ctx, data, res, mode) {
|
|
|
8442
8733
|
* shade with no exact setting, the theme's own source changed it
|
|
8443
8734
|
* @param {string} [slug]
|
|
8444
8735
|
* @param {Record<string, string>} [own] the tokens the theme's own source sets
|
|
8445
|
-
* @returns {{vibrancy: number | null, colors: import('./theme-edit.type.mjs').ThemeEditColor[], colorNotes: string[], colorProblems: string
|
|
8736
|
+
* @returns {{vibrancy: number | null, colors: import('./theme-edit.type.mjs').ThemeEditColor[], colorNotes: string[], colorProblems: Array<{problem: string, fix: string | null}>}}
|
|
8446
8737
|
* `colorProblems`: the color notes of pairings that fail their contrast
|
|
8447
8738
|
*/
|
|
8448
8739
|
function colorsReport(pal, data, built, slug = '', own = {}) {
|
|
@@ -8545,7 +8836,15 @@ function colorsReport(pal, data, built, slug = '', own = {}) {
|
|
|
8545
8836
|
new RegExp(`${k.replace(/[-]/g, '\\-')}(?![\\w-])`).test(n),
|
|
8546
8837
|
),
|
|
8547
8838
|
),
|
|
8548
|
-
|
|
8839
|
+
// Each with the line that passes it, when one does.
|
|
8840
|
+
colorProblems: pairings
|
|
8841
|
+
.filter(c => !c.pass)
|
|
8842
|
+
.map(c => ({
|
|
8843
|
+
problem: pairingNote(c),
|
|
8844
|
+
fix: c.fix
|
|
8845
|
+
? `${P} set ${slug} ${c.fix.thing} ${quoteCommandArgument(c.fix.value)}${c.fix.mode && modesOf(data).length > 1 ? ` --mode ${c.fix.mode}` : ''}`
|
|
8846
|
+
: null,
|
|
8847
|
+
})),
|
|
8549
8848
|
};
|
|
8550
8849
|
}
|
|
8551
8850
|
|
|
@@ -9267,6 +9566,7 @@ async function undoTheme(theme, options) {
|
|
|
9267
9566
|
stepsLeft: stepsLeft,
|
|
9268
9567
|
// What the step back changed, as a change reports it.
|
|
9269
9568
|
changedTokens: committed.changed,
|
|
9569
|
+
changedPartTokens: committed.changedParts ?? [],
|
|
9270
9570
|
problems: committed.problems,
|
|
9271
9571
|
newProblems: [
|
|
9272
9572
|
...problemLines(committed.newProblems),
|
|
@@ -9302,3 +9602,71 @@ function buildNotes(ctx) {
|
|
|
9302
9602
|
const notes = /** @type {{compileNotes?: unknown}} */ (ctx)?.compileNotes;
|
|
9303
9603
|
return Array.isArray(notes) ? notes.map(String) : [];
|
|
9304
9604
|
}
|
|
9605
|
+
|
|
9606
|
+
/**
|
|
9607
|
+
* The roles a page-wide font setting does not reach because the theme's
|
|
9608
|
+
* own source gives their family itself (a `typography` family or a
|
|
9609
|
+
* `--font-family-*` token): the source wins over its settings, so those
|
|
9610
|
+
* roles keep the source's family. Read from the build the set just made.
|
|
9611
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
9612
|
+
* @param {string} slug
|
|
9613
|
+
* @param {import('./_settings.mjs').Setting} s
|
|
9614
|
+
* @returns {string[]}
|
|
9615
|
+
*/
|
|
9616
|
+
function ownFamilyNotes(ctx, slug, s) {
|
|
9617
|
+
if (s.on || s.when || s.state) return [];
|
|
9618
|
+
const roles =
|
|
9619
|
+
s.thing === 'font'
|
|
9620
|
+
? ['body', 'heading']
|
|
9621
|
+
: /^--font-family-[a-z]+$/.test(s.thing)
|
|
9622
|
+
? [s.thing.slice('--font-family-'.length)]
|
|
9623
|
+
: [];
|
|
9624
|
+
if (!roles.length) return [];
|
|
9625
|
+
const cwd = ctx.project.cwd;
|
|
9626
|
+
const own = ownTokenEntries(cwd, slug).filter(
|
|
9627
|
+
e =>
|
|
9628
|
+
!e.overridden &&
|
|
9629
|
+
!e.block &&
|
|
9630
|
+
((e.kind === 'typography' && /^[^.]+\.family$/.test(e.key)) ||
|
|
9631
|
+
(e.token != null && /^--font-family-/.test(e.token))),
|
|
9632
|
+
);
|
|
9633
|
+
if (!own.length) return [];
|
|
9634
|
+
/** @type {string} */
|
|
9635
|
+
let css;
|
|
9636
|
+
try {
|
|
9637
|
+
css = fs.readFileSync(themeFiles(cwd, slug).css, 'utf8');
|
|
9638
|
+
} catch {
|
|
9639
|
+
return [];
|
|
9640
|
+
}
|
|
9641
|
+
const unquote = (/** @type {string} */ f) => f.replace(/["']/g, '').trim();
|
|
9642
|
+
const asked = unquote(
|
|
9643
|
+
s.thing === 'font'
|
|
9644
|
+
? fontOf(String(s.value)).family
|
|
9645
|
+
: (String(s.value).split(',')[0] ?? ''),
|
|
9646
|
+
);
|
|
9647
|
+
/** @type {Array<[string, string]>} */
|
|
9648
|
+
const kept = [];
|
|
9649
|
+
for (const role of roles) {
|
|
9650
|
+
const m = new RegExp(`--font-family-${role}:\\s*([^;}]+)`).exec(css);
|
|
9651
|
+
const first = m ? unquote(m[1].split(',')[0] ?? '') : '';
|
|
9652
|
+
if (first && first.toLowerCase() !== asked.toLowerCase())
|
|
9653
|
+
kept.push([role, first]);
|
|
9654
|
+
}
|
|
9655
|
+
if (!kept.length) return [];
|
|
9656
|
+
const fileOf = (/** @type {{file?: string}} */ e) =>
|
|
9657
|
+
e.file ? path.relative(cwd, e.file) : `themes/${slug}/${slug}.theme.ts`;
|
|
9658
|
+
const file = fileOf(own[0]);
|
|
9659
|
+
const where = own
|
|
9660
|
+
.map(
|
|
9661
|
+
e =>
|
|
9662
|
+
`${e.token ?? `typography.${e.key}`}${e.line ? ` (line ${e.line})` : ''}${fileOf(e) === file ? '' : ` in ${fileOf(e)}`}`,
|
|
9663
|
+
)
|
|
9664
|
+
.join(', ');
|
|
9665
|
+
const roleWords = (/** @type {string} */ role) =>
|
|
9666
|
+
role === 'body' ? 'body text' : role === 'heading' ? 'headings' : role;
|
|
9667
|
+
const families = [...new Set(kept.map(([, f]) => f))];
|
|
9668
|
+
const what = `${kept.map(([role]) => roleWords(role)).join(' and ')} keep${kept.length === 1 && kept[0][0] !== 'heading' ? 's' : ''} ${families.join(' and ')}`;
|
|
9669
|
+
return [
|
|
9670
|
+
`${describe(s)} does not show${kept.length < roles.length ? ` in ${kept.map(([role]) => roleWords(role)).join(' and ')}` : ''}: ${what}, because ${file} sets ${where} itself, and the theme's own source wins over its settings. To use ${asked} there, change the family in ${file}, or take it out of that file.`,
|
|
9671
|
+
];
|
|
9672
|
+
}
|