@astryxdesign/cli 0.7.17-canary.g4ea41ce → 0.7.17-canary.g5a3fd39
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 +7 -2
- package/api/build/_adapter.d.mts +7 -6
- package/api/build/_adapter.mjs +18 -11
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kind.d.mts +6 -0
- package/api/build/kit/kind.mjs +1 -1
- package/api/build/kit/rank.d.mts +7 -1
- package/api/build/kit/rank.mjs +15 -5
- package/api/build/kit/signals.mjs +58 -57
- package/api/build/kit/start.d.mts +2 -1
- package/api/build/kit/start.mjs +62 -9
- package/api/build/kit/words.d.mts +6 -2
- package/api/build/kit/words.mjs +7 -3
- package/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/component/_adapter.d.mts +30 -24
- package/api/component/_adapter.mjs +72 -31
- package/api/component/component.mjs +4 -4
- package/api/component/detail/detail.d.mts +2 -2
- package/api/component/detail/detail.mjs +1 -1
- package/api/component/list/list.d.mts +2 -2
- package/api/component/list/list.mjs +4 -4
- package/api/discover/_adapter.mjs +15 -15
- package/api/docs/_adapter.d.mts +13 -5
- package/api/docs/_adapter.mjs +37 -10
- package/api/doctor/_adapter.d.mts +32 -0
- package/api/doctor/_adapter.mjs +56 -1
- package/api/doctor/doctor.mjs +28 -5
- package/api/doctor/theme-checks.mjs +165 -83
- package/api/error.d.mts +4 -3
- package/api/error.mjs +3 -2
- package/api/hook/_adapter.d.mts +5 -4
- package/api/hook/_adapter.mjs +6 -5
- package/api/icon/_options.d.mts +17 -0
- package/api/icon/_options.mjs +54 -0
- package/api/icon/exportIconIndex.doc.d.mts +10 -0
- package/api/icon/exportIconIndex.doc.mjs +59 -0
- package/api/icon/icon.mjs +11 -34
- package/api/icon/icon.type.d.mts +49 -0
- package/api/icon/icon.type.mjs +24 -0
- package/api/icon/rankIconIndex.doc.d.mts +10 -0
- package/api/icon/rankIconIndex.doc.mjs +79 -0
- package/api/icon/search/icon-index.d.mts +41 -0
- package/api/icon/search/icon-index.mjs +139 -0
- package/api/icon/search/search.d.mts +18 -0
- package/api/icon/search/search.mjs +13 -0
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/search/_adapter.d.mts +8 -5
- package/api/search/_adapter.mjs +14 -10
- package/api/search/_gather-components.d.mts +4 -4
- package/api/search/_gather-components.mjs +4 -3
- package/api/search/_gather-hooks.d.mts +2 -2
- package/api/search/_gather-hooks.mjs +1 -1
- package/api/search/_lexical.mjs +12 -2
- package/api/search/_priority.d.mts +10 -2
- package/api/search/_priority.mjs +37 -7
- package/api/search/_score.d.mts +12 -3
- package/api/search/_score.mjs +6 -3
- package/api/search/_words.mjs +12 -3
- package/api/search/search.d.mts +7 -1
- package/api/search/search.mjs +37 -4
- package/api/swizzle/_adapter.d.mts +7 -5
- package/api/swizzle/_adapter.mjs +7 -3
- package/api/swizzle/copy/copy.mjs +5 -4
- package/api/theme/build/build.d.mts +5 -0
- package/api/theme/build/build.mjs +400 -21
- package/api/theme/build/family.mjs +18 -7
- package/api/theme/build/font-warning.mjs +5 -4
- package/api/theme/build/input-fields.d.mts +21 -6
- package/api/theme/build/input-fields.mjs +104 -13
- package/api/theme/build/typography-values.d.mts +22 -0
- package/api/theme/build/typography-values.mjs +172 -22
- package/api/theme/build/written-values.d.mts +7 -0
- package/api/theme/build/written-values.mjs +57 -8
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/palette/generate/generator.d.mts +14 -2
- package/api/theme/palette/generate/generator.mjs +94 -8
- package/api/theme/theme.type.d.mts +21 -4
- package/api/theme/theme.type.mjs +14 -5
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +18 -3
- package/api/theme-edit/_adapter.d.mts +1 -1
- package/api/theme-edit/_adapter.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +10 -4
- package/api/theme-edit/_catalog.mjs +81 -22
- package/api/theme-edit/_check.mjs +402 -88
- package/api/theme-edit/_color.d.mts +11 -2
- package/api/theme-edit/_color.mjs +23 -7
- package/api/theme-edit/_compiler.mjs +11 -3
- package/api/theme-edit/_context.d.mts +87 -6
- package/api/theme-edit/_context.mjs +224 -17
- package/api/theme-edit/_css.mjs +4 -0
- package/api/theme-edit/_edit.mjs +331 -58
- package/api/theme-edit/_how-question.d.mts +11 -0
- package/api/theme-edit/_how-question.mjs +2514 -234
- package/api/theme-edit/_how.mjs +79 -14
- package/api/theme-edit/_missed.mjs +294 -32
- package/api/theme-edit/_normal.d.mts +3 -1
- package/api/theme-edit/_normal.mjs +4 -1
- package/api/theme-edit/_palette.mjs +36 -5
- package/api/theme-edit/_part-words.mjs +20 -2
- package/api/theme-edit/_parts.d.mts +12 -1
- package/api/theme-edit/_parts.mjs +116 -11
- package/api/theme-edit/_preview-app.mjs +40 -2
- package/api/theme-edit/_preview.d.mts +45 -5
- package/api/theme-edit/_preview.mjs +173 -21
- package/api/theme-edit/_settings.d.mts +20 -0
- package/api/theme-edit/_settings.mjs +1033 -94
- package/api/theme-edit/_tables.mjs +2 -2
- package/api/theme-edit/theme-edit.type.d.mts +6 -5
- package/api/theme-edit/theme-edit.type.mjs +8 -8
- package/api/upgrade/_adapter.mjs +13 -2
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/authoring.doc.mjs +1 -0
- package/assets/docs/tree/cli.doc.mjs +1 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
- package/assets/docs/tree/global.doc.mjs +1 -0
- package/assets/docs/tree/single-component.doc.mjs +40 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/who-answers.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Blockquote/BlockquoteShowcase.tsx +1 -1
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +4 -4
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx +1 -0
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsSupportingVariant.tsx +2 -2
- package/assets/templates/blocks/components/Card/CardElevations.tsx +1 -1
- package/assets/templates/blocks/components/Card/CardWithInnerLayout.tsx +19 -3
- package/assets/templates/blocks/components/Card/ClickableCardWithNestedButton.tsx +11 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardMulti.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterInsideACard.tsx +1 -1
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx +8 -0
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.tsx +8 -2
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutPanelChat.tsx +1 -0
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleCustomContent.tsx +9 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleMetadata.tsx +12 -2
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.tsx +28 -7
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.tsx +35 -7
- package/assets/templates/blocks/components/Collapsible/CollapsibleShowcase.tsx +1 -1
- package/assets/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.tsx +20 -4
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +15 -3
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +29 -6
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBasic.tsx +2 -2
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/ContextMenu/ContextMenuShowcase.tsx +2 -2
- package/assets/templates/blocks/components/Divider/DividerFullBleed.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerVariants.tsx +1 -1
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +23 -4
- package/assets/templates/blocks/components/EmptyState/EmptyStateActions.tsx +18 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.tsx +20 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.tsx +16 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.tsx +11 -1
- package/assets/templates/blocks/components/Heading/HeadingTruncation.tsx +12 -2
- package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentBasic.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentShowcase.tsx +1 -1
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterActions.tsx +17 -3
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterShowcase.tsx +17 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderShowcase.tsx +15 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.tsx +9 -2
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.tsx +1 -1
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelShowcase.tsx +1 -1
- package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/MultiSelector/MultiSelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Outline/OutlineDensity.tsx +2 -0
- package/assets/templates/blocks/components/OverflowList/OverflowListShowcase.tsx +6 -1
- package/assets/templates/blocks/components/Pagination/PaginationVariants.tsx +4 -0
- package/assets/templates/blocks/components/Popover/PopoverHookUsage.tsx +17 -2
- package/assets/templates/blocks/components/SegmentedControl/SegmentedControlFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +8 -1
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +2 -2
- package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -0
- package/assets/templates/blocks/components/Switch/SwitchWithStatus.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsWithActions.tsx +12 -1
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +11 -1
- package/assets/templates/blocks/components/Table/TableInCard.tsx +2 -2
- package/assets/templates/blocks/components/Text/TextTruncation.tsx +1 -1
- package/assets/templates/blocks/components/Text/TextWordBreak.tsx +12 -2
- package/assets/templates/blocks/components/Text/TextWrap.tsx +19 -4
- package/assets/templates/blocks/components/TextArea/TextAreaCharacterCount.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaShowcase.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaStates.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaValidation.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.tsx +1 -1
- package/assets/templates/blocks/components/TextInput/TextInputStatusVariant.tsx +2 -2
- package/assets/templates/blocks/components/Timestamp/TimestampAutoFormat.tsx +15 -1
- package/assets/templates/blocks/components/Timestamp/TimestampRelativeFormat.tsx +15 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +8 -0
- package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +12 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +18 -3
- package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.tsx +6 -0
- package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.tsx +7 -1
- package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.tsx +2 -2
- package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +9 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +102 -6
- package/assets/templates/pages/canvas-editor/page.tsx +73 -2
- package/assets/templates/pages/centered-hero/page.tsx +10 -4
- package/assets/templates/pages/course-detail/page.tsx +46 -2
- package/assets/templates/pages/dashboard/page.tsx +45 -16
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +31 -20
- package/assets/templates/pages/dashboard-comparison/page.tsx +9 -0
- package/assets/templates/pages/dashboard-composition/page.tsx +22 -9
- package/assets/templates/pages/dashboard-progress/page.tsx +27 -15
- package/assets/templates/pages/dashboard-scorecard/page.tsx +9 -0
- package/assets/templates/pages/detail-page/page.tsx +105 -77
- package/assets/templates/pages/documentation/page.tsx +15 -2
- package/assets/templates/pages/documentation-design/page.tsx +7 -34
- package/assets/templates/pages/documentation-technical/page.tsx +76 -12
- package/assets/templates/pages/editor/page.tsx +26 -21
- package/assets/templates/pages/file-explorer/page.tsx +35 -1
- package/assets/templates/pages/form-two-column/page.tsx +2 -3
- package/assets/templates/pages/form-wizard/page.tsx +31 -3
- package/assets/templates/pages/form-wizard-vertical/page.tsx +32 -3
- package/assets/templates/pages/gallery-hero/page.tsx +2 -1
- package/assets/templates/pages/ide/page.tsx +15 -1
- package/assets/templates/pages/incident-console/page.tsx +2 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +1 -1
- package/assets/templates/pages/kanban-board/page.tsx +39 -2
- package/assets/templates/pages/payment-form/page.tsx +77 -39
- package/assets/templates/pages/product-gallery/page.tsx +16 -14
- package/assets/templates/pages/settings/page.tsx +35 -3
- package/assets/templates/pages/settings-dialog/page.tsx +34 -5
- package/assets/templates/pages/settings-sidebar/page.tsx +23 -3
- package/assets/templates/pages/shell-nav/page.tsx +28 -12
- package/assets/templates/pages/shell-side-nav/page.tsx +16 -1
- package/assets/templates/pages/shell-top-nav/page.tsx +27 -1
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -1
- package/assets/templates/pages/table/template.doc.mjs +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/page.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +9 -2
- package/assets/templates/pages/table-grouped/page.tsx +16 -6
- package/assets/templates/pages/table-inbox/page.tsx +60 -1
- package/assets/templates/pages/table-page/page.tsx +10 -2
- package/assets/templates/pages/table-tree/page.tsx +95 -13
- package/assets/templates/pages/theme-showcase/page.tsx +107 -11
- package/assets/templates/pages/work-item-detail/page.tsx +88 -74
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -1
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +5 -0
- package/assets/templates/themes/neutral/neutralTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +22 -8
- package/authoring/doctypes/_schema.mjs +31 -0
- package/authoring/doctypes/command/command.doc.mjs +24 -0
- package/authoring/doctypes/command/type.ts +31 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -5
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -0
- package/authoring/doctypes/namespace/type.ts +4 -0
- package/authoring/doctypes/template/type.ts +0 -7
- package/authoring/index.d.ts +6 -1
- package/authoring/integration/integration.doc.mjs +7 -0
- package/authoring/integration/schema.d.mts +6 -0
- package/authoring/integration/schema.mjs +3 -0
- package/authoring/integration/type.ts +34 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/component.mjs +5 -1
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/experimental/index.mjs +4 -1
- package/clients/cli/commands/experimental/theme.mjs +139 -64
- package/clients/cli/commands/experimental-render.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-add.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-template.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-use.doc.mjs +2 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -0
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +1 -1
- package/clients/cli/commands/integration-add.doc.mjs +1 -0
- package/clients/cli/commands/manifest.mjs +10 -3
- package/clients/cli/commands/swizzle.doc.mjs +8 -1
- package/clients/cli/commands/swizzle.mjs +13 -6
- package/clients/cli/commands/template.doc.mjs +3 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +2 -1
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-remove.doc.mjs +2 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +2 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +21 -5
- package/clients/cli/index.mjs +167 -59
- package/clients/cli/lib/base-gate.mjs +522 -0
- package/clients/cli/lib/command-path.mjs +26 -0
- package/clients/cli/lib/define-command.mjs +161 -12
- package/clients/cli/lib/json-shim.mjs +34 -31
- package/clients/cli/lib/manifest.d.ts +14 -0
- package/clients/cli/lib/manifest.mjs +78 -22
- package/clients/cli/lib/root-args.mjs +79 -0
- package/clients/cli/lib/stray-option.mjs +21 -8
- package/clients/cli/lib/unknown-command.mjs +27 -6
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +13 -1
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core-docs.d.mts +10 -0
- package/foundation/bases/core-docs.mjs +42 -0
- package/foundation/bases/core.d.mts +11 -0
- package/foundation/bases/core.mjs +32 -0
- package/foundation/bases/requirements.d.mts +128 -0
- package/foundation/bases/requirements.mjs +193 -0
- package/foundation/bases/resolve.d.mts +134 -0
- package/foundation/bases/resolve.mjs +295 -0
- package/foundation/bases/state.d.mts +24 -0
- package/foundation/bases/state.mjs +46 -0
- package/foundation/bases/steps.d.mts +49 -0
- package/foundation/bases/steps.mjs +88 -0
- package/foundation/config/project.d.mts +14 -0
- package/foundation/config/project.mjs +68 -1
- package/foundation/discovery/cli-self-docs.mjs +9 -1
- package/foundation/discovery/command-pointers.d.mts +28 -0
- package/foundation/discovery/command-pointers.mjs +31 -0
- package/foundation/discovery/component-discovery.d.mts +9 -8
- package/foundation/discovery/component-discovery.mjs +9 -4
- package/foundation/discovery/docs-discovery.d.mts +13 -5
- package/foundation/discovery/docs-discovery.mjs +25 -6
- package/foundation/discovery/hook-discovery.d.mts +6 -6
- package/foundation/discovery/hook-discovery.mjs +6 -4
- package/foundation/discovery/template-adapter.mjs +5 -0
- package/foundation/discovery/template-ids.d.mts +1 -1
- package/foundation/discovery/template-ids.mjs +5 -1
- package/foundation/discovery/theme-discovery.mjs +3 -0
- package/foundation/discovery/theme-imports.mjs +19 -1
- package/foundation/doc-compiler/tree.d.mts +4 -2
- package/foundation/doc-compiler/tree.mjs +46 -1
- package/foundation/env/package-manager.d.mts +7 -0
- package/foundation/env/package-manager.mjs +21 -0
- package/foundation/fonts/font-stylesheet.d.mts +8 -0
- package/foundation/fonts/font-stylesheet.mjs +26 -2
- package/foundation/fs/gather-cache.mjs +44 -13
- package/foundation/fs/own-modules.d.mts +29 -0
- package/foundation/fs/own-modules.mjs +57 -0
- package/foundation/fs/paths.d.mts +30 -2
- package/foundation/fs/paths.mjs +49 -2
- package/foundation/integrations/integrations.d.mts +4 -0
- package/foundation/integrations/integrations.mjs +6 -1
- package/foundation/release/choose.d.mts +7 -0
- package/foundation/release/choose.mjs +16 -2
- package/foundation/release/notices.d.mts +26 -0
- package/foundation/release/notices.mjs +48 -19
- package/foundation/release/project.d.mts +3 -2
- package/foundation/release/project.mjs +4 -5
- package/foundation/release/run-context.d.mts +7 -2
- package/foundation/release/run-context.mjs +6 -2
- package/foundation/render/css-cut.mjs +86 -6
- package/foundation/render/cut-short.d.mts +35 -0
- package/foundation/render/cut-short.mjs +124 -0
- package/foundation/render/font-probe.d.mts +27 -0
- package/foundation/render/font-probe.mjs +77 -0
- package/foundation/render/layers.d.mts +1 -9
- package/foundation/render/layers.mjs +2 -111
- package/foundation/render/page-worker.mjs +83 -6
- package/foundation/render/picture-chrome.mjs +24 -2
- package/foundation/render/picture-playwright.mjs +22 -2
- package/foundation/render/picture-window.d.mts +20 -4
- package/foundation/render/picture-window.mjs +137 -4
- package/foundation/response/base.d.ts +25 -0
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.d.ts +4 -1
- package/foundation/response/error-codes.doc.mjs +17 -0
- package/foundation/response/error-codes.mjs +21 -0
- package/foundation/response/json.d.mts +3 -1
- package/foundation/response/json.mjs +7 -2
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/suggest/name-index.d.mts +2 -1
- package/foundation/suggest/name-index.mjs +1 -1
- package/foundation/suggest/other-command.d.mts +4 -1
- package/foundation/suggest/other-command.mjs +23 -6
- package/foundation/text/string-utils.d.mts +7 -2
- package/foundation/text/string-utils.mjs +24 -10
- package/package.json +6 -6
- package/assets/templates/pages/access-denied/page.tsx +0 -101
- package/assets/templates/pages/access-denied/template.doc.mjs +0 -24
- package/assets/templates/pages/error-page/page.tsx +0 -130
- package/assets/templates/pages/error-page/template.doc.mjs +0 -22
- package/assets/templates/pages/not-found/page.tsx +0 -124
- package/assets/templates/pages/not-found/template.doc.mjs +0 -30
- package/assets/templates/pages/review-workspace/page.tsx +0 -551
- package/assets/templates/pages/review-workspace/template.doc.mjs +0 -31
- package/assets/templates/pages/run-console/page.tsx +0 -945
- package/assets/templates/pages/run-console/template.doc.mjs +0 -27
- package/assets/templates/pages/welcome-portal/page.tsx +0 -538
- package/assets/templates/pages/welcome-portal/template.doc.mjs +0 -38
|
@@ -34,6 +34,7 @@ import {cssUnescape} from '../../foundation/text/css-escape.mjs';
|
|
|
34
34
|
import {levenshteinDistance} from '../../foundation/text/levenshtein.mjs';
|
|
35
35
|
import {coreVarValues} from './_parts.mjs';
|
|
36
36
|
import {
|
|
37
|
+
hexToOklch,
|
|
37
38
|
oklabCoordinates,
|
|
38
39
|
oklabCoordinatesToHex,
|
|
39
40
|
} from '../theme/palette/generate/color.mjs';
|
|
@@ -565,6 +566,19 @@ export function namesSetting(word) {
|
|
|
565
566
|
);
|
|
566
567
|
}
|
|
567
568
|
|
|
569
|
+
/**
|
|
570
|
+
* Whether a word names a CSS property, which `set` writes only on a part
|
|
571
|
+
* (`--on`): a theme a `new` makes takes no value for it, so its line comes
|
|
572
|
+
* after the theme is made, with a part named.
|
|
573
|
+
* @param {string} word
|
|
574
|
+
*/
|
|
575
|
+
export function needsPart(word) {
|
|
576
|
+
const w = String(word).trim().toLowerCase();
|
|
577
|
+
return (
|
|
578
|
+
!Object.hasOwn(DIALS, w) && !w.startsWith('--') && cssProperties().has(w)
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
|
|
568
582
|
/**
|
|
569
583
|
* Whether text typed where a theme goes names settings, in any form set
|
|
570
584
|
* reads them: a setting's name (`corners`, `--color-accent`), with its value
|
|
@@ -1644,7 +1658,7 @@ export function settingsProblem(
|
|
|
1644
1658
|
if (removes(skip) && skips(s, skip) && entryDamage(s)) continue;
|
|
1645
1659
|
if (!['dial', 'token', 'property'].includes(s.source))
|
|
1646
1660
|
return s.source == null || s.source === ''
|
|
1647
|
-
? `${s.thing} has no source (dial, token or property)`
|
|
1661
|
+
? `${s.thing} has no source (dial, token or property)${unreadFieldsText(s)}`
|
|
1648
1662
|
: `${s.thing} has source ${JSON.stringify(s.source)}, not dial, token or property`;
|
|
1649
1663
|
if (s.mode != null && s.mode !== 'light' && s.mode !== 'dark')
|
|
1650
1664
|
return `${s.thing} has mode ${JSON.stringify(s.mode)}, not light or dark`;
|
|
@@ -1801,6 +1815,20 @@ function twinInLetters(s, read, data) {
|
|
|
1801
1815
|
);
|
|
1802
1816
|
}
|
|
1803
1817
|
|
|
1818
|
+
/**
|
|
1819
|
+
* The fields of a saved entry the editor does not read, said after what is
|
|
1820
|
+
* wrong with it (`; it has "part", a field the editor does not read: a
|
|
1821
|
+
* part is "on"`), or nothing.
|
|
1822
|
+
* @param {any} s
|
|
1823
|
+
*/
|
|
1824
|
+
function unreadFieldsText(s) {
|
|
1825
|
+
const unread = Object.keys(s).filter(
|
|
1826
|
+
k => !ENTRY_FIELDS.includes(k) && !['parts', 'masked', 'note'].includes(k),
|
|
1827
|
+
);
|
|
1828
|
+
if (!unread.length) return '';
|
|
1829
|
+
return `; it has ${unread.map(k => JSON.stringify(k)).join(', ')}, ${unread.length === 1 ? 'a field' : 'fields'} the editor does not read (the part a setting styles is "on")`;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1804
1832
|
/**
|
|
1805
1833
|
* The keys of an entry grouped by the field each writes, in the order
|
|
1806
1834
|
* written; `setting` (the thing as the editor prints it) is the thing.
|
|
@@ -2370,9 +2398,12 @@ function damagedEntry(data, problem) {
|
|
|
2370
2398
|
(Array.isArray(data?.settings) ? data.settings : []).find(
|
|
2371
2399
|
(/** @type {any} */ s) =>
|
|
2372
2400
|
(entryDamage(s) === 'source' &&
|
|
2373
|
-
typeof s.source === 'string' &&
|
|
2374
|
-
|
|
2375
|
-
|
|
2401
|
+
((typeof s.source === 'string' &&
|
|
2402
|
+
s.source !== '' &&
|
|
2403
|
+
problem.startsWith(`${s.thing} has source `)) ||
|
|
2404
|
+
// An entry saved with no source its undo still names.
|
|
2405
|
+
((s.source == null || s.source === '') &&
|
|
2406
|
+
problem.startsWith(`${s.thing} has no source `)))) ||
|
|
2376
2407
|
(entryDamage(s) === 'mode' &&
|
|
2377
2408
|
problem.startsWith(`${s.thing} has mode `)) ||
|
|
2378
2409
|
(PLACE_SCOPES.some(k => entryDamage(s) === k) &&
|
|
@@ -4173,7 +4204,8 @@ function scopeProblem(s) {
|
|
|
4173
4204
|
// (Several states at once are joined by +: `checked+disabled`.)
|
|
4174
4205
|
if (s.state != null && !STATE_NAME.test(s.state))
|
|
4175
4206
|
return `${s.thing} has state "${s.state}", which is not a state name`;
|
|
4176
|
-
|
|
4207
|
+
// (Several, one per prop, are joined by +: `variant:ghost+size:sm`.)
|
|
4208
|
+
if (s.when != null && !/^[\w-]+:[\w.-]+(?:\+[\w-]+:[\w.-]+)*$/.test(s.when))
|
|
4177
4209
|
return `${s.thing} has --when "${s.when}", which is not prop:value`;
|
|
4178
4210
|
if ((s.when != null || s.state != null) && s.on == null)
|
|
4179
4211
|
return `${s.thing} has a variant or state but no part`;
|
|
@@ -4197,12 +4229,17 @@ export const keyOf = s =>
|
|
|
4197
4229
|
|
|
4198
4230
|
/** One line for a setting. @param {Setting} s */
|
|
4199
4231
|
export function describe(s) {
|
|
4232
|
+
// A setting for one mode on no part reaches the whole theme in that mode:
|
|
4233
|
+
// said in one phrase, never "(whole theme) [light only]", which reads as
|
|
4234
|
+
// two scopes at odds.
|
|
4200
4235
|
const where = s.on
|
|
4201
4236
|
? ` on ${s.on}${s.only ? ' only' : ''}${s.when ? ` when ${s.when}` : ''}${s.state ? ` :${s.state}` : ''}`
|
|
4202
|
-
:
|
|
4237
|
+
: s.mode
|
|
4238
|
+
? ` (whole theme, ${s.mode} mode only)`
|
|
4239
|
+
: ' (whole theme)';
|
|
4203
4240
|
// An entry saved with no value says so, never "undefined".
|
|
4204
4241
|
const value = s.value === undefined ? '(no value)' : s.value;
|
|
4205
|
-
return `${s.thing} = ${value}${where}${s.mode ? ` [${s.mode} only]` : ''}`;
|
|
4242
|
+
return `${s.thing} = ${value}${where}${s.mode && s.on ? ` [${s.mode} only]` : ''}`;
|
|
4206
4243
|
}
|
|
4207
4244
|
|
|
4208
4245
|
/**
|
|
@@ -4216,12 +4253,15 @@ export function partsOf(ctx, s) {
|
|
|
4216
4253
|
if (!s.on) return [];
|
|
4217
4254
|
if (s.thing === 'font') return [];
|
|
4218
4255
|
const has = (/** @type {string} */ t) => ctx.project.target.has(t);
|
|
4219
|
-
// A border set on a group lands where each member draws its
|
|
4220
|
-
// and time field's two boxes, never the
|
|
4256
|
+
// A border or a fill set on a group lands where each member draws its
|
|
4257
|
+
// edges or paints its box (a date and time field's two boxes, never the
|
|
4258
|
+
// row around them, which paints nothing).
|
|
4221
4259
|
const spread = (/** @type {string[]} */ members) =>
|
|
4222
4260
|
/^border(?!.*radius)(-|$)/.test(s.thing)
|
|
4223
4261
|
? [...new Set(members.flatMap(t => borderParts(ctx, t)))]
|
|
4224
|
-
:
|
|
4262
|
+
: /^background(-color)?$/.test(s.thing)
|
|
4263
|
+
? [...new Set(members.flatMap(t => fillParts(ctx, t)))]
|
|
4264
|
+
: members;
|
|
4225
4265
|
if (FAMILIES[s.on]) return spread(FAMILIES[s.on].filter(has));
|
|
4226
4266
|
const fam = familyOf(s.on);
|
|
4227
4267
|
if (fam && AUTO_SPREAD.includes(fam) && !s.only)
|
|
@@ -4276,6 +4316,25 @@ export function borderParts(ctx, part) {
|
|
|
4276
4316
|
return inner.length ? inner : [part];
|
|
4277
4317
|
}
|
|
4278
4318
|
|
|
4319
|
+
/**
|
|
4320
|
+
* The parts that paint a part's box (a text input itself; a date and time
|
|
4321
|
+
* field's two boxes, where the row around them paints none).
|
|
4322
|
+
* @param {Ctx} ctx
|
|
4323
|
+
* @param {string} part
|
|
4324
|
+
* @returns {string[]}
|
|
4325
|
+
*/
|
|
4326
|
+
export function fillParts(ctx, part) {
|
|
4327
|
+
const own = ctx.C.MAP[part]?.own ?? {};
|
|
4328
|
+
if (own['background-color'] || own.background) return [part];
|
|
4329
|
+
const inner = cornerParts(ctx, part).filter(
|
|
4330
|
+
t =>
|
|
4331
|
+
t !== part &&
|
|
4332
|
+
(ctx.C.MAP[t]?.own?.['background-color'] ||
|
|
4333
|
+
ctx.C.MAP[t]?.own?.background),
|
|
4334
|
+
);
|
|
4335
|
+
return inner.length ? inner : [part];
|
|
4336
|
+
}
|
|
4337
|
+
|
|
4279
4338
|
export {modesOf};
|
|
4280
4339
|
|
|
4281
4340
|
/**
|
|
@@ -5645,8 +5704,16 @@ export function compileTheme(ctx, data, base) {
|
|
|
5645
5704
|
tg?.stateValues,
|
|
5646
5705
|
);
|
|
5647
5706
|
if (s.state && slot.key !== (s.when ?? 'base')) return null;
|
|
5648
|
-
const
|
|
5649
|
-
|
|
5707
|
+
const attrs = s.when
|
|
5708
|
+
? String(s.when)
|
|
5709
|
+
.split('+')
|
|
5710
|
+
.map(w => {
|
|
5711
|
+
const [k, v] = w.split(':');
|
|
5712
|
+
return `[data-${k}="${v}"]`;
|
|
5713
|
+
})
|
|
5714
|
+
.join('')
|
|
5715
|
+
: '';
|
|
5716
|
+
return `.astryx-${target}${attrs}${slot.pseudo ?? ''}`;
|
|
5650
5717
|
};
|
|
5651
5718
|
|
|
5652
5719
|
/**
|
|
@@ -6328,8 +6395,37 @@ export function compileTheme(ctx, data, base) {
|
|
|
6328
6395
|
: f.fallbacks,
|
|
6329
6396
|
};
|
|
6330
6397
|
} else if (s.thing === 'surfaces') {
|
|
6331
|
-
for (const t of SURFACE_PARTS.filter(x => ctx.project.target.has(x)))
|
|
6332
|
-
|
|
6398
|
+
for (const t of SURFACE_PARTS.filter(x => ctx.project.target.has(x))) {
|
|
6399
|
+
const look = SURFACES[s.value];
|
|
6400
|
+
// A frame that paints nothing (the banner's): its line and shadow
|
|
6401
|
+
// go on the part inside it that paints the rounded fill, so they
|
|
6402
|
+
// follow its corners; a square ring around them otherwise.
|
|
6403
|
+
const paintsNone =
|
|
6404
|
+
!ctx.C.MAP[t]?.at?.['background-color'] &&
|
|
6405
|
+
!ctx.C.MAP[t]?.at?.['border-radius'];
|
|
6406
|
+
const fill = paintsNone
|
|
6407
|
+
? (ctx.C.MAP[t]?.contains ?? []).find(
|
|
6408
|
+
k =>
|
|
6409
|
+
ctx.C.MAP[k]?.at?.['background-color'] &&
|
|
6410
|
+
ctx.C.MAP[k]?.at?.['border-radius'],
|
|
6411
|
+
)
|
|
6412
|
+
: undefined;
|
|
6413
|
+
if (!fill) {
|
|
6414
|
+
Object.assign(block({...s, mode: undefined}, t), look);
|
|
6415
|
+
continue;
|
|
6416
|
+
}
|
|
6417
|
+
const edge = Object.fromEntries(
|
|
6418
|
+
Object.entries(look).filter(([k]) => /^(border|boxShadow)/.test(k)),
|
|
6419
|
+
);
|
|
6420
|
+
const rest = Object.fromEntries(
|
|
6421
|
+
Object.entries(look).filter(
|
|
6422
|
+
([k]) => !/^(border|boxShadow)/.test(k),
|
|
6423
|
+
),
|
|
6424
|
+
);
|
|
6425
|
+
Object.assign(block({...s, mode: undefined}, fill), edge);
|
|
6426
|
+
if (Object.keys(rest).length)
|
|
6427
|
+
Object.assign(block({...s, mode: undefined}, t), rest);
|
|
6428
|
+
}
|
|
6333
6429
|
} else if (s.thing === 'buttons') {
|
|
6334
6430
|
const primary = block(
|
|
6335
6431
|
{...s, mode: undefined, when: 'variant:primary'},
|
|
@@ -6568,7 +6664,19 @@ export function compileTheme(ctx, data, base) {
|
|
|
6568
6664
|
// The see-through main area and the fixed attachment go with the
|
|
6569
6665
|
// page background: in its mode's block for a one-mode one, so the
|
|
6570
6666
|
// other mode keeps the content panel Core paints.
|
|
6571
|
-
|
|
6667
|
+
// (A main area a setting gives a background of its own, in this
|
|
6668
|
+
// mode or in every mode, keeps it: the see-through rule is not
|
|
6669
|
+
// written over it, in whichever order the two were set.)
|
|
6670
|
+
const panelOwn = data.settings.some(
|
|
6671
|
+
x =>
|
|
6672
|
+
x.source === 'property' &&
|
|
6673
|
+
/^background(-color|-image)?$/.test(kebab(x.thing)) &&
|
|
6674
|
+
!x.when &&
|
|
6675
|
+
!x.state &&
|
|
6676
|
+
(!x.mode || x.mode === s.mode) &&
|
|
6677
|
+
partsOf(ctx, x).includes('layout-content'),
|
|
6678
|
+
);
|
|
6679
|
+
if (ctx.project.target.has('layout-content') && !panelOwn) {
|
|
6572
6680
|
const lc = ((theme.components['layout-content'] ??= {}).base ??= {});
|
|
6573
6681
|
const scope = s.mode ? (lc[`@${s.mode}`] ??= {}) : lc;
|
|
6574
6682
|
const main = (scope[':where(.astryx-app-shell [role="main"])'] ??=
|
|
@@ -6878,26 +6986,157 @@ export function compileTheme(ctx, data, base) {
|
|
|
6878
6986
|
? written('--color-background-surface', m)
|
|
6879
6987
|
: null;
|
|
6880
6988
|
const baseSurface = baseColor('--color-background-surface', m);
|
|
6989
|
+
// A fill the base theme keeps between its page and its surface (a dark
|
|
6990
|
+
// card the page's own shade) stays between the page and the surface the
|
|
6991
|
+
// theme shows: its step never carries it past the page.
|
|
6992
|
+
const basePage = baseColor('--color-background-body', m);
|
|
6993
|
+
const page =
|
|
6994
|
+
written('--color-background-body', m) ?? basePage ?? baseSurface;
|
|
6881
6995
|
if (surface && baseSurface)
|
|
6882
6996
|
for (const k of SURFACE_FAMILY) {
|
|
6883
6997
|
if (!(k in TOKENS || base[m]?.[k] != null) || pinned(k, m)) continue;
|
|
6884
6998
|
const from = baseColor(k, m);
|
|
6885
6999
|
if (!from) continue;
|
|
6886
7000
|
const [sl, sa, sb] = oklabCoordinates(surface);
|
|
6887
|
-
const
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
7001
|
+
const [fromL] = oklabCoordinates(from);
|
|
7002
|
+
const [baseSurfaceL] = oklabCoordinates(baseSurface);
|
|
7003
|
+
const l = Math.max(0, Math.min(1, sl + fromL - baseSurfaceL));
|
|
7004
|
+
let color = oklabCoordinatesToHex([l, sa, sb]);
|
|
7005
|
+
if (basePage && page) {
|
|
7006
|
+
const [basePageL] = oklabCoordinates(basePage);
|
|
7007
|
+
const [pageL] = oklabCoordinates(page);
|
|
7008
|
+
const inside = (
|
|
7009
|
+
/** @type {number} */ x,
|
|
7010
|
+
/** @type {number} */ a,
|
|
7011
|
+
/** @type {number} */ b,
|
|
7012
|
+
) => x >= Math.min(a, b) && x <= Math.max(a, b);
|
|
7013
|
+
// Measured on the color written, so rounding never carries it
|
|
7014
|
+
// past the page: at or past a bound, it is that bound's color.
|
|
7015
|
+
if (
|
|
7016
|
+
inside(fromL, basePageL, baseSurfaceL) &&
|
|
7017
|
+
!inside(oklabCoordinates(color)[0], pageL, sl)
|
|
7018
|
+
)
|
|
7019
|
+
color = Math.abs(l - pageL) <= Math.abs(l - sl) ? page : surface;
|
|
7020
|
+
}
|
|
7021
|
+
putTok(k, color, m);
|
|
6894
7022
|
}
|
|
7023
|
+
// The emphasized border (input and selector frames) is never fainter
|
|
7024
|
+
// than the border: an opaque border stronger than it on the surface
|
|
7025
|
+
// carries it; a fainter one leaves it as it is.
|
|
6895
7026
|
const border = pinned('--color-border', m)
|
|
6896
7027
|
? written('--color-border', m)
|
|
6897
7028
|
: null;
|
|
6898
|
-
|
|
7029
|
+
const emphasized =
|
|
7030
|
+
written('--color-border-emphasized', m) ??
|
|
7031
|
+
baseColor('--color-border-emphasized', m);
|
|
7032
|
+
const ground =
|
|
7033
|
+
written('--color-background-surface', m) ??
|
|
7034
|
+
baseColor('--color-background-surface', m);
|
|
7035
|
+
if (
|
|
7036
|
+
border &&
|
|
7037
|
+
!pinned('--color-border-emphasized', m) &&
|
|
7038
|
+
(!emphasized ||
|
|
7039
|
+
!ground ||
|
|
7040
|
+
ratio(
|
|
7041
|
+
/** @type {[number, number, number]} */ (parseColor(border)),
|
|
7042
|
+
/** @type {[number, number, number]} */ (parseColor(ground)),
|
|
7043
|
+
) >
|
|
7044
|
+
ratio(
|
|
7045
|
+
/** @type {[number, number, number]} */ (parseColor(emphasized)),
|
|
7046
|
+
/** @type {[number, number, number]} */ (parseColor(ground)),
|
|
7047
|
+
))
|
|
7048
|
+
)
|
|
6899
7049
|
putTok('--color-border-emphasized', border, m);
|
|
6900
7050
|
}
|
|
7051
|
+
// A flat panel is tinted with the muted fill. The pieces inside it drawn
|
|
7052
|
+
// in that same color (a neutral badge, a track, whatever token the base
|
|
7053
|
+
// theme draws them from) would vanish into the tint, so inside the panel
|
|
7054
|
+
// each fill that shows as the tint is the panel's own surface instead (as
|
|
7055
|
+
// on a raised card, the other way round), and the emphasized border is
|
|
7056
|
+
// stepped where it stands out less from the tint than from that surface.
|
|
7057
|
+
// The tint is written as the colors it shows, since the panel then points
|
|
7058
|
+
// the muted fill elsewhere.
|
|
7059
|
+
/** The color a token shows in a mode, as hex, or null. @param {string} k @param {'light' | 'dark'} m */
|
|
7060
|
+
const shown = (k, m) => {
|
|
7061
|
+
let v = String(tok[k]?.[m] ?? base[m]?.[k] ?? '');
|
|
7062
|
+
for (let i = 0; i < 4; i++) {
|
|
7063
|
+
const ref = /^var\((--[\w-]+)\)$/.exec(v.trim())?.[1];
|
|
7064
|
+
if (!ref) break;
|
|
7065
|
+
v = String(tok[ref]?.[m] ?? base[m]?.[ref] ?? '');
|
|
7066
|
+
}
|
|
7067
|
+
const rgb = parseColor(v.trim());
|
|
7068
|
+
return rgb && alphaOf(v) >= 1 ? hex(rgb) : null;
|
|
7069
|
+
};
|
|
7070
|
+
for (const t of SURFACE_PARTS) {
|
|
7071
|
+
const own = /^var\((--[\w-]+)\)$/.exec(
|
|
7072
|
+
String(ctx.C.MAP[t]?.own?.['background-color']?.values?.[0] ?? ''),
|
|
7073
|
+
)?.[1];
|
|
7074
|
+
for (const b of Object.values(
|
|
7075
|
+
/** @type {Record<string, Record<string, unknown>>} */ (
|
|
7076
|
+
theme.components[t] ?? {}
|
|
7077
|
+
),
|
|
7078
|
+
)) {
|
|
7079
|
+
if (b?.backgroundColor !== 'var(--color-background-muted)' || !own)
|
|
7080
|
+
continue;
|
|
7081
|
+
/** @type {Partial<Record<'light' | 'dark', string>>} */
|
|
7082
|
+
const tint = {};
|
|
7083
|
+
/** @type {Partial<Record<'light' | 'dark', string>>} */
|
|
7084
|
+
const edge = {};
|
|
7085
|
+
for (const m of /** @type {const} */ (['light', 'dark'])) {
|
|
7086
|
+
const fill = shown('--color-background-muted', m);
|
|
7087
|
+
const surface = shown(own, m);
|
|
7088
|
+
const line = shown('--color-border-emphasized', m);
|
|
7089
|
+
if (!fill) continue;
|
|
7090
|
+
tint[m] = fill;
|
|
7091
|
+
if (!surface || !line) continue;
|
|
7092
|
+
const rgb = (/** @type {string} */ x) =>
|
|
7093
|
+
/** @type {[number, number, number]} */ (parseColor(x));
|
|
7094
|
+
const need = ratio(rgb(line), rgb(surface));
|
|
7095
|
+
let [l, a, bb] = oklabCoordinates(line);
|
|
7096
|
+
const away = oklabCoordinates(fill)[0] > 0.5 ? -1 : 1;
|
|
7097
|
+
let stepped = line;
|
|
7098
|
+
for (let i = 0; i < 40 && ratio(rgb(stepped), rgb(fill)) < need; i++) {
|
|
7099
|
+
l = Math.max(0, Math.min(1, l + away * 0.02));
|
|
7100
|
+
stepped = oklabCoordinatesToHex([l, a, bb]);
|
|
7101
|
+
}
|
|
7102
|
+
if (stepped !== line) edge[m] = stepped;
|
|
7103
|
+
}
|
|
7104
|
+
if (!tint.light && !tint.dark) continue;
|
|
7105
|
+
b.backgroundColor =
|
|
7106
|
+
tint.light && tint.dark && tint.light !== tint.dark
|
|
7107
|
+
? `light-dark(${tint.light}, ${tint.dark})`
|
|
7108
|
+
: (tint.light ?? tint.dark);
|
|
7109
|
+
for (const k of Object.keys(TOKENS).filter(isPieceFill)) {
|
|
7110
|
+
if (k === own) continue;
|
|
7111
|
+
/** @type {Partial<Record<'light' | 'dark', boolean>>} */
|
|
7112
|
+
const blends = {};
|
|
7113
|
+
for (const m of /** @type {const} */ (['light', 'dark'])) {
|
|
7114
|
+
const v = shown(k, m);
|
|
7115
|
+
const f = tint[m];
|
|
7116
|
+
// A gray piece reads as the tint when it is near its lightness; a
|
|
7117
|
+
// colored one (a status or category fill) keeps its hue.
|
|
7118
|
+
blends[m] =
|
|
7119
|
+
k === '--color-background-muted' ||
|
|
7120
|
+
Boolean(
|
|
7121
|
+
v &&
|
|
7122
|
+
f &&
|
|
7123
|
+
hexToOklch(v).C < GRAY_PIECE &&
|
|
7124
|
+
ratio(
|
|
7125
|
+
/** @type {[number, number, number]} */ (parseColor(v)),
|
|
7126
|
+
/** @type {[number, number, number]} */ (parseColor(f)),
|
|
7127
|
+
) < BLENDS,
|
|
7128
|
+
);
|
|
7129
|
+
}
|
|
7130
|
+
if (blends.light && blends.dark) b[k] = `var(${own})`;
|
|
7131
|
+
else if (blends.light || blends.dark)
|
|
7132
|
+
b[k] =
|
|
7133
|
+
`light-dark(${blends.light ? `var(${own})` : shown(k, 'light')}, ${blends.dark ? `var(${own})` : shown(k, 'dark')})`;
|
|
7134
|
+
}
|
|
7135
|
+
if (edge.light || edge.dark)
|
|
7136
|
+
b['--color-border-emphasized'] =
|
|
7137
|
+
`light-dark(${edge.light ?? shown('--color-border-emphasized', 'light')}, ${edge.dark ?? shown('--color-border-emphasized', 'dark')})`;
|
|
7138
|
+
}
|
|
7139
|
+
}
|
|
6901
7140
|
for (const [k, {light, dark}] of Object.entries(tok)) {
|
|
6902
7141
|
const l = light ?? shownHalf(k, 'light');
|
|
6903
7142
|
const d = dark ?? shownHalf(k, 'dark');
|
|
@@ -7074,6 +7313,36 @@ const SURFACE_FAMILY = [
|
|
|
7074
7313
|
'--color-skeleton',
|
|
7075
7314
|
];
|
|
7076
7315
|
|
|
7316
|
+
/**
|
|
7317
|
+
* The fills the pieces inside a panel are drawn from (a badge, a track, a
|
|
7318
|
+
* placeholder): Core's background tokens other than the page's and the
|
|
7319
|
+
* panels' own, and the skeleton.
|
|
7320
|
+
*/
|
|
7321
|
+
/** @param {string} k */
|
|
7322
|
+
const isPieceFill = k =>
|
|
7323
|
+
(/^--color-background-/.test(k) &&
|
|
7324
|
+
!/^--color-background-(body|surface|card|popover|inverted)$/.test(k)) ||
|
|
7325
|
+
k === '--color-skeleton';
|
|
7326
|
+
|
|
7327
|
+
/** Below this contrast a gray piece reads as the tint it sits on. */
|
|
7328
|
+
const BLENDS = 1.25;
|
|
7329
|
+
|
|
7330
|
+
/** Below this OKLCH chroma a piece's fill reads as a gray. */
|
|
7331
|
+
const GRAY_PIECE = 0.02;
|
|
7332
|
+
|
|
7333
|
+
/**
|
|
7334
|
+
* The tokens that follow another one the theme sets exactly (where it
|
|
7335
|
+
* does not set them itself): each with the token it follows.
|
|
7336
|
+
*/
|
|
7337
|
+
export const FOLLOWS = Object.freeze(
|
|
7338
|
+
/** @type {Record<string, string>} */ ({
|
|
7339
|
+
...Object.fromEntries(
|
|
7340
|
+
SURFACE_FAMILY.map(k => [k, '--color-background-surface']),
|
|
7341
|
+
),
|
|
7342
|
+
'--color-border-emphasized': '--color-border',
|
|
7343
|
+
}),
|
|
7344
|
+
);
|
|
7345
|
+
|
|
7077
7346
|
/**
|
|
7078
7347
|
* A block's longhands that follow a shorthand covering them, where the base
|
|
7079
7348
|
* theme's block holds the same key, rewritten as that longhand's own sides
|
|
@@ -9131,11 +9400,21 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9131
9400
|
);
|
|
9132
9401
|
const one =
|
|
9133
9402
|
conds.size === 1 ? /^([\w-]+)=([\w-]+)$/.exec([...conds][0]) : null;
|
|
9134
|
-
|
|
9403
|
+
// (A state, a selected item's, is not a variant `--when` names: the
|
|
9404
|
+
// pair is drawn in that state, which pairState says.)
|
|
9405
|
+
const states = ctx.project.target.get(t)?.states ?? [];
|
|
9406
|
+
if (one && !states.includes(one[1])) return `${one[1]}:${one[2]}`;
|
|
9135
9407
|
}
|
|
9408
|
+
// (Only variants the part is drawn in: a rule shared with its group
|
|
9409
|
+
// can name a variant the part does not take, which `--when` refuses.)
|
|
9410
|
+
const takes = new Set(
|
|
9411
|
+
/** @type {string[]} */ ([...(ctx.C.MAP[t]?.attrs?.variant ?? [])]),
|
|
9412
|
+
);
|
|
9136
9413
|
/** @param {string[]} when */
|
|
9137
9414
|
const atRest = when =>
|
|
9138
|
-
when
|
|
9415
|
+
when
|
|
9416
|
+
.map(w => /^variant=([\w-]+)$/.exec(w)?.[1])
|
|
9417
|
+
.filter(v => v != null && takes.has(v));
|
|
9139
9418
|
const reading = new Set(
|
|
9140
9419
|
ctx.C.partReads(t, 'text')
|
|
9141
9420
|
.filter(r => r.token === token)
|
|
@@ -9168,6 +9447,21 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9168
9447
|
*/
|
|
9169
9448
|
const textTokens = (p, m, read) => {
|
|
9170
9449
|
const t = p.fg.target;
|
|
9450
|
+
// Text on a surface that keeps one side (a caption on a lightbox's
|
|
9451
|
+
// dark island) reads the on-color for that side, in both modes.
|
|
9452
|
+
const g = p.bg.target;
|
|
9453
|
+
const sides = /** @type {string[]} */ (
|
|
9454
|
+
/** @type {any} */ (g ? ctx.C.MAP[g] : null)?.mediaSides ?? []
|
|
9455
|
+
);
|
|
9456
|
+
if (
|
|
9457
|
+
g &&
|
|
9458
|
+
g !== t &&
|
|
9459
|
+
ctx.C.MAP[g]?.media &&
|
|
9460
|
+
!autoMediaPart(ctx, g) &&
|
|
9461
|
+
sides.length === 1 &&
|
|
9462
|
+
/^--color-text-(primary|secondary)$/.test(String(p.fg.tokens[0]))
|
|
9463
|
+
)
|
|
9464
|
+
return [`--color-on-${sides[0]}`];
|
|
9171
9465
|
if (!t || !ctx.C.MAP[t]?.media || ctx.C.MAP[t]?.own?.color)
|
|
9172
9466
|
return p.fg.tokens;
|
|
9173
9467
|
// A surface that follows what is painted behind it (a toast's) takes
|
|
@@ -9203,13 +9497,17 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9203
9497
|
*/
|
|
9204
9498
|
const drawnBy = (p, m) => {
|
|
9205
9499
|
const when = pairVariant(p);
|
|
9500
|
+
// (A pair drawn in a state, a selected item's: a setting for that
|
|
9501
|
+
// state draws it too, and wins over one at rest.)
|
|
9502
|
+
const inState = pairState(p);
|
|
9206
9503
|
/** @param {(x: Setting) => boolean} test @param {string | null} [w] the variant a setting must name, if any */
|
|
9207
9504
|
const latest = (test, w = when) =>
|
|
9208
9505
|
[...data.settings]
|
|
9209
9506
|
.reverse()
|
|
9507
|
+
.sort((a, b) => Number(!!b.state) - Number(!!a.state))
|
|
9210
9508
|
.find(
|
|
9211
9509
|
x =>
|
|
9212
|
-
!x.state &&
|
|
9510
|
+
(!x.state || (inState != null && x.state === inState)) &&
|
|
9213
9511
|
(!x.when || x.when === w) &&
|
|
9214
9512
|
(!x.mode || x.mode === m) &&
|
|
9215
9513
|
test(x),
|
|
@@ -9232,10 +9530,21 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9232
9530
|
if (ofBase(p, 'fg', m) != null) return null;
|
|
9233
9531
|
// (On the part around it, a setting for that part's variant the text
|
|
9234
9532
|
// sits on counts.)
|
|
9235
|
-
|
|
9533
|
+
const viaGround = latest(
|
|
9236
9534
|
x => x.source === 'token' && tokens.includes(x.thing) && on(x, around),
|
|
9237
9535
|
/** @type {any} */ (p).groundWhen ?? when,
|
|
9238
9536
|
);
|
|
9537
|
+
if (viaGround) return viaGround;
|
|
9538
|
+
// A token set on the region the text and its ground sit in (a top
|
|
9539
|
+
// bar's text color) reaches it the same way, as CSS inherits it.
|
|
9540
|
+
const region = /** @type {any} */ (p).over?.target ?? null;
|
|
9541
|
+
return region && region !== around && region !== own
|
|
9542
|
+
? latest(
|
|
9543
|
+
x =>
|
|
9544
|
+
x.source === 'token' && tokens.includes(x.thing) && on(x, region),
|
|
9545
|
+
null,
|
|
9546
|
+
)
|
|
9547
|
+
: null;
|
|
9239
9548
|
};
|
|
9240
9549
|
/**
|
|
9241
9550
|
* The mode a side of a pair is drawn in: the scheme of Core's media
|
|
@@ -9250,6 +9559,39 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9250
9559
|
if (!drawnIn) return m;
|
|
9251
9560
|
return side === 'fg' || p.bg !== /** @type {any} */ (p).over ? drawnIn : m;
|
|
9252
9561
|
};
|
|
9562
|
+
/**
|
|
9563
|
+
* A fill the theme paints on a part between the text and the ground the
|
|
9564
|
+
* census measured it on (a side nav pane painted blue, between its items
|
|
9565
|
+
* and the app shell): the text sits on that fill now. The setting's
|
|
9566
|
+
* value, or null when the theme paints none there.
|
|
9567
|
+
* @param {TextPair} p @param {string} m
|
|
9568
|
+
*/
|
|
9569
|
+
const nearerFill = (p, m) => {
|
|
9570
|
+
const t = p.fg.target;
|
|
9571
|
+
const g = p.bg.target;
|
|
9572
|
+
if (!t || !g || g === t || /** @type {any} */ (p).over) return null;
|
|
9573
|
+
const holds = (/** @type {string} */ a, /** @type {string} */ b) =>
|
|
9574
|
+
/** @type {any} */ (ctx.C.MAP[a]?.contains ?? []).includes(b);
|
|
9575
|
+
const fill = [...data.settings].reverse().find(
|
|
9576
|
+
x =>
|
|
9577
|
+
x.source === 'property' &&
|
|
9578
|
+
/^background(-color)?$/.test(x.thing) &&
|
|
9579
|
+
!x.when &&
|
|
9580
|
+
!x.state &&
|
|
9581
|
+
(!x.mode || x.mode === m) &&
|
|
9582
|
+
x.on &&
|
|
9583
|
+
partsOf(ctx, x).some(
|
|
9584
|
+
q =>
|
|
9585
|
+
q !== t &&
|
|
9586
|
+
q !== g &&
|
|
9587
|
+
// (The census drew the text inside that part, and that part
|
|
9588
|
+
// inside the ground: a side nav's item in the side nav.)
|
|
9589
|
+
(p.within ?? []).includes(q) &&
|
|
9590
|
+
holds(g, q),
|
|
9591
|
+
),
|
|
9592
|
+
);
|
|
9593
|
+
return fill ? String(fill.value) : null;
|
|
9594
|
+
};
|
|
9253
9595
|
/** @type {(p: TextPair, side: 'fg' | 'bg', m: string) => string | null} */
|
|
9254
9596
|
const value = (p, side, m0) => {
|
|
9255
9597
|
const m = inScheme(p, side, m0);
|
|
@@ -9259,17 +9601,20 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9259
9601
|
inMode(
|
|
9260
9602
|
side === 'fg'
|
|
9261
9603
|
? drawnBy(p, m)?.value
|
|
9262
|
-
:
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
/** @type {any} */ (p).
|
|
9271
|
-
|
|
9272
|
-
|
|
9604
|
+
: (nearerFill(p, m) ??
|
|
9605
|
+
override(
|
|
9606
|
+
s,
|
|
9607
|
+
side,
|
|
9608
|
+
m,
|
|
9609
|
+
// The ground's own variant; else the variant the text is
|
|
9610
|
+
// drawn in, when the ground is the text's own part (a
|
|
9611
|
+
// secondary button's label on its secondary fill).
|
|
9612
|
+
/** @type {any} */ (p).groundWhen ??
|
|
9613
|
+
/** @type {any} */ (p).when ??
|
|
9614
|
+
(s.target && s.target === p.fg.target
|
|
9615
|
+
? pairVariant(p)
|
|
9616
|
+
: null),
|
|
9617
|
+
)),
|
|
9273
9618
|
m,
|
|
9274
9619
|
) ??
|
|
9275
9620
|
// The base theme's own part style (neutral's destructive button),
|
|
@@ -9479,6 +9824,34 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9479
9824
|
// where it is light, so the part's text is measured with the one its side
|
|
9480
9825
|
// gives, on the part's own fill.
|
|
9481
9826
|
/** @type {TextPair[]} */
|
|
9827
|
+
/**
|
|
9828
|
+
* A pair of a part drawn with its default props, named by the variant Core
|
|
9829
|
+
* draws it as (a Button is `secondary` unless told otherwise): the one
|
|
9830
|
+
* variant whose fill reads the pair's ground token and whose text reads
|
|
9831
|
+
* its text token. Its fix then reaches that variant, as a setting scoped
|
|
9832
|
+
* to it reaches the button the pair stands for. Any other pair as it is.
|
|
9833
|
+
* @param {TextPair} q
|
|
9834
|
+
* @returns {TextPair}
|
|
9835
|
+
*/
|
|
9836
|
+
const defaultVariant = q => {
|
|
9837
|
+
const t = q.fg.target;
|
|
9838
|
+
if (!t || /** @type {any} */ (q).when || q.bg.target !== t) return q;
|
|
9839
|
+
const bgReads = ctx.C.partReads(t, 'background') ?? [];
|
|
9840
|
+
const fgReads = ctx.C.partReads(t, 'text') ?? [];
|
|
9841
|
+
/** @param {Array<{token: string, when: string[]}>} reads @param {string} v */
|
|
9842
|
+
const reads = (reads, v) =>
|
|
9843
|
+
reads.find(r => r.when.includes(`variant=${v}`))?.token;
|
|
9844
|
+
const variants = /** @type {string[]} */ ([
|
|
9845
|
+
...(ctx.C.MAP[t]?.attrs?.variant ?? []),
|
|
9846
|
+
]).filter(
|
|
9847
|
+
v =>
|
|
9848
|
+
reads(bgReads, v) === q.bg.tokens[0] &&
|
|
9849
|
+
(reads(fgReads, v) ?? q.fg.tokens[0]) === q.fg.tokens[0],
|
|
9850
|
+
);
|
|
9851
|
+
return variants.length === 1
|
|
9852
|
+
? /** @type {any} */ ({...q, when: `variant:${variants[0]}`})
|
|
9853
|
+
: q;
|
|
9854
|
+
};
|
|
9482
9855
|
const mediaPairs = [];
|
|
9483
9856
|
const TEXT_ROLES = ['--color-text-primary', '--color-text-secondary'];
|
|
9484
9857
|
// (One pair for each text and side, on the first surface that holds it:
|
|
@@ -9494,7 +9867,8 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9494
9867
|
// shows that, not the page.
|
|
9495
9868
|
const reads = ctx.C.partReads(m, 'background') ?? [];
|
|
9496
9869
|
const ground = (reads.find(r => r.when.includes('')) ?? reads[0])?.token;
|
|
9497
|
-
for (const
|
|
9870
|
+
for (const q0 of [...variantPairs, ...census.pairs]) {
|
|
9871
|
+
const q = defaultVariant(q0);
|
|
9498
9872
|
const t = q.fg.target;
|
|
9499
9873
|
if (
|
|
9500
9874
|
!t ||
|
|
@@ -9505,7 +9879,8 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9505
9879
|
)
|
|
9506
9880
|
continue;
|
|
9507
9881
|
for (const side of sides) {
|
|
9508
|
-
|
|
9882
|
+
// (A part's default variant is one with that variant's own pair.)
|
|
9883
|
+
const k = `${t}|${/** @type {any} */ (q).when ?? q.text}|${side}`;
|
|
9509
9884
|
if (mediaSeen.has(k)) continue;
|
|
9510
9885
|
mediaSeen.add(k);
|
|
9511
9886
|
mediaPairs.push(
|
|
@@ -9557,6 +9932,7 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9557
9932
|
modesOf(data).length > 1 ? ` --mode ${m}` : '';
|
|
9558
9933
|
/** @type {(text: string) => ThemeProblem} */
|
|
9559
9934
|
const plain = text => ({text, fix: null, key: text});
|
|
9935
|
+
const scoped = scopedTextProblems(ctx, data, res);
|
|
9560
9936
|
return [
|
|
9561
9937
|
...problems.map(x => ({
|
|
9562
9938
|
// What the problem is, whatever its ratio: the text, the token or
|
|
@@ -9566,14 +9942,64 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9566
9942
|
// The fix sets what draws the text: the setting that wins in CSS,
|
|
9567
9943
|
// where one does, else the text token where the text sits.
|
|
9568
9944
|
fix: (() => {
|
|
9569
|
-
const color = `'${plainOn(x.ground)}'`;
|
|
9570
9945
|
const pair = /** @type {TextPair} */ (x.pair);
|
|
9946
|
+
// (A pair drawn in a state, a selected item's: its line is for that
|
|
9947
|
+
// state.)
|
|
9948
|
+
const pairIn = pairState(pair);
|
|
9949
|
+
const stateFlag = pairIn ? ` --state ${pairIn}` : '';
|
|
9950
|
+
// Secondary text (a placeholder, a caption) stays secondary: its
|
|
9951
|
+
// own color moved toward black or white just far enough to read at
|
|
9952
|
+
// 4.5:1, not the plain black or white of primary text.
|
|
9953
|
+
// (It reads on every ground that text sits on there: a token set on
|
|
9954
|
+
// a part reaches its text on each of the part's grounds.)
|
|
9955
|
+
const fgNow = parseColor(String(value(pair, 'fg', x.mode) ?? ''));
|
|
9956
|
+
const secondary =
|
|
9957
|
+
fgNow &&
|
|
9958
|
+
/^--color-text-(secondary|placeholder)/.test(
|
|
9959
|
+
String(pair.fg.tokens?.[0]),
|
|
9960
|
+
);
|
|
9961
|
+
const page = parseColor(
|
|
9962
|
+
String(
|
|
9963
|
+
res[/** @type {'light' | 'dark'} */ (x.mode)][
|
|
9964
|
+
'--color-background-body'
|
|
9965
|
+
],
|
|
9966
|
+
),
|
|
9967
|
+
);
|
|
9968
|
+
const groundsThere = secondary
|
|
9969
|
+
? [
|
|
9970
|
+
x.ground,
|
|
9971
|
+
.../** @type {TextPair[]} */ (
|
|
9972
|
+
/** @type {any} */ (ctx).parts.pairs
|
|
9973
|
+
)
|
|
9974
|
+
.filter(
|
|
9975
|
+
q =>
|
|
9976
|
+
(q.bg.target === x.bgPart || q.fg.target === x.textPart) &&
|
|
9977
|
+
q.fg.tokens[0] === pair.fg.tokens[0],
|
|
9978
|
+
)
|
|
9979
|
+
.map(q => {
|
|
9980
|
+
const v = String(value(q, 'bg', x.mode) ?? '');
|
|
9981
|
+
const c = parseColor(v);
|
|
9982
|
+
const a = alphaOf(v);
|
|
9983
|
+
return c && a < 1 && page ? compositeOver(c, a, page) : c;
|
|
9984
|
+
})
|
|
9985
|
+
.filter(g => g != null && plainOn(g) === plainOn(x.ground)),
|
|
9986
|
+
]
|
|
9987
|
+
: [];
|
|
9988
|
+
const color = `'${
|
|
9989
|
+
secondary
|
|
9990
|
+
? nearestReading(
|
|
9991
|
+
/** @type {[number, number, number]} */ (fgNow),
|
|
9992
|
+
/** @type {Array<[number, number, number]>} */ (groundsThere),
|
|
9993
|
+
4.5,
|
|
9994
|
+
)
|
|
9995
|
+
: plainOn(x.ground)
|
|
9996
|
+
}'`;
|
|
9571
9997
|
// Text in the top bar sits over each of the bar's grounds (its
|
|
9572
9998
|
// variants): when they need opposite text, one color set on the
|
|
9573
9999
|
// text's part turns it the wrong way on the others, so no line
|
|
9574
10000
|
// fixes this alone.
|
|
9575
10001
|
const over = /** @type {any} */ (pair).over;
|
|
9576
|
-
if (over) {
|
|
10002
|
+
if (over && !(/** @type {any} */ (pair).mediaOf)) {
|
|
9577
10003
|
const own = value(pair, 'bg', x.mode);
|
|
9578
10004
|
const sides = new Set(
|
|
9579
10005
|
grounds.map(g => {
|
|
@@ -9603,26 +10029,17 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9603
10029
|
part && data.settings.some(s => s.on === part && s.only)
|
|
9604
10030
|
? ' --only'
|
|
9605
10031
|
: '';
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
//
|
|
9612
|
-
//
|
|
9613
|
-
//
|
|
9614
|
-
//
|
|
9615
|
-
// (Text on a toast's own surface takes a color on the toast: a
|
|
9616
|
-
// text token there never reaches it.)
|
|
10032
|
+
// Text inside Core's media surface (a button on a lightbox's dark
|
|
10033
|
+
// island) is drawn in the surface's scheme whatever the page's
|
|
10034
|
+
// mode: a color on its part (its variant) for that mode reaches it
|
|
10035
|
+
// there, and the page's parts in that mode, which sit on a ground of
|
|
10036
|
+
// the same kind. When the part's own fill lets the surface's ground
|
|
10037
|
+
// through (a transparent button) and the same text on the page in
|
|
10038
|
+
// that mode needs the other color, the two grounds disagree: the
|
|
10039
|
+
// surface's own on-color for its side reaches only the text inside
|
|
10040
|
+
// it (unless a color the theme set on the part draws the text).
|
|
9617
10041
|
const onMedia = /** @type {any} */ (pair).mediaOf;
|
|
9618
|
-
// (On a media surface the part is drawn in the surface's scheme: a
|
|
9619
|
-
// color for that mode reaches it there, and the page's parts in
|
|
9620
|
-
// that mode, which sit on a ground of the same kind.)
|
|
9621
10042
|
const drawnIn = /** @type {any} */ (pair).drawnIn;
|
|
9622
|
-
// (When the part's own fill lets the surface's ground through (a
|
|
9623
|
-
// transparent button) and the same text on the page in that mode
|
|
9624
|
-
// needs the other color, the two grounds disagree, and no color on
|
|
9625
|
-
// the part fixes both: no line.)
|
|
9626
10043
|
if (onMedia && drawnIn) {
|
|
9627
10044
|
const q = /** @type {TextPair} */ (/** @type {any} */ (pair).pageOf);
|
|
9628
10045
|
const v = q ? value(q, 'bg', drawnIn) : null;
|
|
@@ -9642,10 +10059,119 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9642
10059
|
: c && page
|
|
9643
10060
|
? compositeOver(c, a, page)
|
|
9644
10061
|
: page;
|
|
9645
|
-
|
|
10062
|
+
const theirs = drawnBy(pair, drawnIn);
|
|
10063
|
+
if (ground && plainOn(ground) !== plainOn(x.ground)) {
|
|
10064
|
+
if (theirs?.thing === 'color') return null;
|
|
10065
|
+
// (Text the surface draws on its own on-color grounds, a
|
|
10066
|
+
// caption bar, would need that on-color the other way: then the
|
|
10067
|
+
// surface's own ground (its overlay) is what turned, and the
|
|
10068
|
+
// base theme's value for it is the line.)
|
|
10069
|
+
const want = plainOn(x.ground);
|
|
10070
|
+
const bars = census.pairs.some((/** @type {TextPair} */ q) => {
|
|
10071
|
+
if (
|
|
10072
|
+
q.bg.target !== onMedia ||
|
|
10073
|
+
!/^--color-on-/.test(String(q.bg.tokens[0]))
|
|
10074
|
+
)
|
|
10075
|
+
return false;
|
|
10076
|
+
const g = parseColor(String(value(q, 'bg', drawnIn) ?? ''));
|
|
10077
|
+
return g != null && plainOn(g) !== want;
|
|
10078
|
+
});
|
|
10079
|
+
if (!bars)
|
|
10080
|
+
return `${P} set ${slug} --color-on-${drawnIn} ${color} --on ${onMedia}`;
|
|
10081
|
+
const tok = /** @type {any} */ (pair).over?.tokens?.[0];
|
|
10082
|
+
const was = tok ? /** @type {any} */ (base)?.[x.mode]?.[tok] : null;
|
|
10083
|
+
return tok &&
|
|
10084
|
+
was &&
|
|
10085
|
+
was !== res[/** @type {'light' | 'dark'} */ (x.mode)][tok]
|
|
10086
|
+
? `${P} set ${slug} ${tok} '${was}'${stateFlag}${modeFlag(x.mode)}`
|
|
10087
|
+
: null;
|
|
10088
|
+
}
|
|
10089
|
+
if (x.textPart)
|
|
10090
|
+
return `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(theirs?.when ?? variant)}${modeFlag(drawnIn)}`;
|
|
10091
|
+
}
|
|
10092
|
+
// Text whose part's own color reads on a pane the theme painted for
|
|
10093
|
+
// it (a side nav's dark fill), shown here on another part that
|
|
10094
|
+
// holds it unpainted (the mobile nav drawer): that part takes the
|
|
10095
|
+
// same fill, which keeps the color where it reads. Recoloring the
|
|
10096
|
+
// text would turn it the wrong way on the painted pane.
|
|
10097
|
+
if (
|
|
10098
|
+
drawn?.thing === 'color' &&
|
|
10099
|
+
x.textPart &&
|
|
10100
|
+
x.bgPart &&
|
|
10101
|
+
x.bgPart !== x.textPart &&
|
|
10102
|
+
drawn.on &&
|
|
10103
|
+
partsOf(ctx, drawn).includes(x.textPart)
|
|
10104
|
+
) {
|
|
10105
|
+
const holds = (/** @type {string} */ a, /** @type {string} */ b) =>
|
|
10106
|
+
/** @type {any} */ (ctx.C.MAP[a]?.contains ?? []).includes(b);
|
|
10107
|
+
const fg = parseColor(String(value(pair, 'fg', x.mode) ?? ''));
|
|
10108
|
+
const pane = [...data.settings]
|
|
10109
|
+
.reverse()
|
|
10110
|
+
.find(
|
|
10111
|
+
y =>
|
|
10112
|
+
y.source === 'property' &&
|
|
10113
|
+
/^background(-color)?$/.test(y.thing) &&
|
|
10114
|
+
!y.when &&
|
|
10115
|
+
!y.state &&
|
|
10116
|
+
(!y.mode || y.mode === x.mode) &&
|
|
10117
|
+
y.on &&
|
|
10118
|
+
y.on !== x.bgPart &&
|
|
10119
|
+
partsOf(ctx, y).some(q => holds(q, String(x.textPart))),
|
|
10120
|
+
);
|
|
10121
|
+
const paneColor = pane ? parseColor(String(pane.value)) : null;
|
|
10122
|
+
if (
|
|
10123
|
+
pane &&
|
|
10124
|
+
fg &&
|
|
10125
|
+
paneColor &&
|
|
10126
|
+
holds(x.bgPart, x.textPart) &&
|
|
10127
|
+
ratio(fg, paneColor) >= 4.5
|
|
10128
|
+
)
|
|
10129
|
+
return `${P} set ${slug} background-color '${String(pane.value)}' --on ${x.bgPart}${only(x.bgPart)}${stateFlag}${modeFlag(x.mode)}`;
|
|
10130
|
+
}
|
|
10131
|
+
if (drawn) {
|
|
10132
|
+
const onText =
|
|
10133
|
+
drawn.on && partsOf(ctx, drawn).includes(String(x.textPart));
|
|
10134
|
+
// A setting that reaches the text's part through its group (a
|
|
10135
|
+
// color on date-input, which every input takes) cannot name a
|
|
10136
|
+
// variant only the text's part has: that variant is scoped on
|
|
10137
|
+
// the text's own part instead.
|
|
10138
|
+
const v = drawn.when ?? (onText ? variant : null);
|
|
10139
|
+
const name = /^variant:([\w-]+)$/.exec(String(v ?? ''))?.[1];
|
|
10140
|
+
if (
|
|
10141
|
+
name &&
|
|
10142
|
+
!drawn.when &&
|
|
10143
|
+
drawn.on &&
|
|
10144
|
+
x.textPart &&
|
|
10145
|
+
drawn.on !== x.textPart &&
|
|
10146
|
+
![
|
|
10147
|
+
.../** @type {string[]} */ (
|
|
10148
|
+
/** @type {any} */ (ctx.C.MAP[drawn.on])?.attrs?.variant ?? []
|
|
10149
|
+
),
|
|
10150
|
+
].includes(name)
|
|
10151
|
+
)
|
|
10152
|
+
return `${P} set ${slug} ${drawn.thing} ${color} --on ${x.textPart}${only(x.textPart)}${when(v)}${stateFlag}${modeFlag(x.mode)}`;
|
|
10153
|
+
return `${P} set ${slug} ${drawn.thing} ${color}${drawn.on ? ` --on ${drawn.on}${drawn.only ? ' --only' : ''}` : ''}${when(v)}${stateFlag}${modeFlag(x.mode)}`;
|
|
10154
|
+
}
|
|
10155
|
+
// (Text on a toast's own surface takes a color on the toast: a
|
|
10156
|
+
// text token there never reaches it.)
|
|
10157
|
+
if (x.textPart && autoMediaPart(ctx, x.textPart))
|
|
10158
|
+
return `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${stateFlag}${modeFlag(x.mode)}`;
|
|
10159
|
+
// Text on a surface's own ground drawn from its on-color (a
|
|
10160
|
+
// lightbox's caption bar): the ground is what changed, and that
|
|
10161
|
+
// on-color on the surface is the line that reaches it, set to the
|
|
10162
|
+
// color the text reads on.
|
|
10163
|
+
const groundToken = String(pair.bg.tokens?.[0] ?? '');
|
|
10164
|
+
if (
|
|
10165
|
+
x.bgPart &&
|
|
10166
|
+
ctx.C.MAP[x.bgPart]?.media &&
|
|
10167
|
+
!autoMediaPart(ctx, x.bgPart) &&
|
|
10168
|
+
/^--color-on-(dark|light)$/.test(groundToken)
|
|
10169
|
+
) {
|
|
10170
|
+
const fg = parseColor(String(value(pair, 'fg', x.mode) ?? ''));
|
|
10171
|
+
return fg
|
|
10172
|
+
? `${P} set ${slug} ${groundToken} '${plainOn(fg)}' --on ${x.bgPart}${only(x.bgPart)}`
|
|
10173
|
+
: null;
|
|
9646
10174
|
}
|
|
9647
|
-
if (x.textPart && (onMedia || autoMediaPart(ctx, x.textPart)))
|
|
9648
|
-
return `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${modeFlag(drawnIn ?? x.mode)}`;
|
|
9649
10175
|
// The base theme colors the text on its own part: only a color
|
|
9650
10176
|
// there changes what is drawn.
|
|
9651
10177
|
// (Text on a ground part's variants that need opposite text: a color
|
|
@@ -9664,7 +10190,7 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9664
10190
|
if (x.textPart && ofBase(pair, 'fg', x.mode) != null)
|
|
9665
10191
|
return sidesOver > 1
|
|
9666
10192
|
? null
|
|
9667
|
-
: `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${modeFlag(x.mode)}`;
|
|
10193
|
+
: `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${stateFlag}${modeFlag(x.mode)}`;
|
|
9668
10194
|
const token = x.fgToken ? textTokens(pair, x.mode, value)[0] : null;
|
|
9669
10195
|
// A ground part that draws several grounds the theme cannot tell
|
|
9670
10196
|
// apart (variants set cannot name): a token set on it would turn
|
|
@@ -9685,6 +10211,11 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9685
10211
|
return g ? plainOn(g) : '';
|
|
9686
10212
|
}),
|
|
9687
10213
|
).size;
|
|
10214
|
+
// Text over a region's ground (a button in the top bar): a token on
|
|
10215
|
+
// the region reaches its text there, and nowhere else.
|
|
10216
|
+
const region = /** @type {any} */ (pair).over?.target;
|
|
10217
|
+
if (token && region && !onMedia)
|
|
10218
|
+
return `${P} set ${slug} ${token} ${color} --on ${region}${only(region)}${stateFlag}${modeFlag(x.mode)}`;
|
|
9688
10219
|
const mixed =
|
|
9689
10220
|
token &&
|
|
9690
10221
|
x.bgPart &&
|
|
@@ -9697,39 +10228,39 @@ export async function contrastProblems(ctx, data, res) {
|
|
|
9697
10228
|
groundsOf(
|
|
9698
10229
|
(/** @type {TextPair} */ q) => q.fg.target === x.textPart,
|
|
9699
10230
|
) === 1
|
|
9700
|
-
? `${P} set ${slug} ${token} ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${modeFlag(x.mode)}`
|
|
10231
|
+
? `${P} set ${slug} ${token} ${color} --on ${x.textPart}${only(x.textPart)}${when(variant)}${stateFlag}${modeFlag(x.mode)}`
|
|
9701
10232
|
: null;
|
|
9702
10233
|
if (token)
|
|
9703
10234
|
return x.bgPart && x.bgPart !== x.textPart
|
|
9704
|
-
? `${P} set ${slug} ${token} ${color} --on ${x.bgPart}${only(x.bgPart)}${when(/** @type {any} */ (pair).groundWhen ?? x.when)}${modeFlag(x.mode)}`
|
|
9705
|
-
: `${P} set ${slug} ${token} ${color}${x.textPart ? ` --on ${x.textPart}${only(x.textPart)}` : ''}${when(variant)}${modeFlag(x.mode)}`;
|
|
10235
|
+
? `${P} set ${slug} ${token} ${color} --on ${x.bgPart}${only(x.bgPart)}${when(/** @type {any} */ (pair).groundWhen ?? x.when)}${stateFlag}${modeFlag(x.mode)}`
|
|
10236
|
+
: `${P} set ${slug} ${token} ${color}${x.textPart ? ` --on ${x.textPart}${only(x.textPart)}` : ''}${when(variant)}${stateFlag}${modeFlag(x.mode)}`;
|
|
9706
10237
|
return x.textPart
|
|
9707
|
-
? `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(x.when)}${modeFlag(x.mode)}`
|
|
10238
|
+
? `${P} set ${slug} color ${color} --on ${x.textPart}${only(x.textPart)}${when(x.when)}${stateFlag}${modeFlag(x.mode)}`
|
|
9708
10239
|
: null;
|
|
9709
10240
|
})(),
|
|
9710
10241
|
})),
|
|
9711
10242
|
...borderContrastProblems(ctx, data, res, base),
|
|
9712
|
-
|
|
10243
|
+
...scoped.problems,
|
|
10244
|
+
...leakedButtonProblems(ctx, data, res),
|
|
10245
|
+
// Pairs styled for one state or condition whose colors cannot be read
|
|
10246
|
+
// as one color, and the button styles, are not measured yet.
|
|
9713
10247
|
...(() => {
|
|
9714
|
-
const
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
// A variant's own colors are measured with the variant pairs.
|
|
9718
|
-
(x.state || (x.when && !/^variant:/.test(x.when))) &&
|
|
9719
|
-
(/^(color|background|background-color)$/.test(x.thing) ||
|
|
9720
|
-
/^--color-/.test(x.thing))) ||
|
|
10248
|
+
const scopedLeft = [
|
|
10249
|
+
...new Set(scoped.unmeasured),
|
|
10250
|
+
...data.settings.filter(
|
|
9721
10251
|
// The button style recolors the primary button only.
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
10252
|
+
x => x.thing === 'buttons' && ['soft', 'outline'].includes(x.value),
|
|
10253
|
+
),
|
|
10254
|
+
];
|
|
10255
|
+
return scopedLeft.length
|
|
9725
10256
|
? [
|
|
9726
10257
|
plain(
|
|
9727
|
-
`not checked: text contrast for ${
|
|
10258
|
+
`not checked: text contrast for ${scopedLeft
|
|
9728
10259
|
.slice(0, 3)
|
|
9729
10260
|
.map(describe)
|
|
9730
10261
|
.join(
|
|
9731
10262
|
'; ',
|
|
9732
|
-
)}${
|
|
10263
|
+
)}${scopedLeft.length > 3 ? ` and ${scopedLeft.length - 3} more` : ''}, set for one variant or state`,
|
|
9733
10264
|
),
|
|
9734
10265
|
]
|
|
9735
10266
|
: [];
|
|
@@ -9763,13 +10294,47 @@ function plainOn(rgb) {
|
|
|
9763
10294
|
: '#ffffff';
|
|
9764
10295
|
}
|
|
9765
10296
|
|
|
10297
|
+
/**
|
|
10298
|
+
* The contrast under which a border no longer differs from the page at all
|
|
10299
|
+
* (the page's own color, within rounding). Where the base's own border is a
|
|
10300
|
+
* hairline under 3:1, the theme's hairline is a choice of how faint, a
|
|
10301
|
+
* clone's #ebebeb as much as the base's; only a border that draws nothing
|
|
10302
|
+
* is a problem there.
|
|
10303
|
+
*/
|
|
10304
|
+
const HAIRLINE_SHOWS = 1.02;
|
|
10305
|
+
|
|
10306
|
+
/**
|
|
10307
|
+
* A color moved toward black or white (whichever stands out on the
|
|
10308
|
+
* grounds) just far enough to reach a contrast on each: the nearest color
|
|
10309
|
+
* that reads, so a muted gray stays a gray.
|
|
10310
|
+
* @param {[number, number, number]} from
|
|
10311
|
+
* @param {Array<[number, number, number]>} grounds the first decides black or white
|
|
10312
|
+
* @param {number} need
|
|
10313
|
+
* @returns {string}
|
|
10314
|
+
*/
|
|
10315
|
+
function nearestReading(from, grounds, need) {
|
|
10316
|
+
const to = plainOn(grounds[0]);
|
|
10317
|
+
const end = /** @type {[number, number, number]} */ (parseColor(to));
|
|
10318
|
+
for (let i = 0; i <= 100; i++) {
|
|
10319
|
+
const c = /** @type {[number, number, number]} */ (
|
|
10320
|
+
from.map((v, k) => Math.round(v + ((end[k] - v) * i) / 100))
|
|
10321
|
+
);
|
|
10322
|
+
if (grounds.every(g => ratio(c, g) >= need)) return hex(c);
|
|
10323
|
+
}
|
|
10324
|
+
return to;
|
|
10325
|
+
}
|
|
10326
|
+
|
|
9766
10327
|
/**
|
|
9767
10328
|
* Border contrast problems this theme caused: a border color it sets (a
|
|
9768
10329
|
* border token for the whole theme, or a part's own border) below 3:1
|
|
9769
10330
|
* against what the border sits on (the part's background, else the page)
|
|
9770
10331
|
* in a mode, where the base theme's border there was not as low. A border
|
|
9771
10332
|
* below 3:1 does not show as an edge (a control's edge needs 3:1, WCAG
|
|
9772
|
-
* 1.4.11)
|
|
10333
|
+
* 1.4.11): a part's own border counts on controls only (a card's or a
|
|
10334
|
+
* divider's is decoration). The border token for the whole theme, where
|
|
10335
|
+
* the base's own is a hairline under 3:1 (its edge comes from elsewhere, a
|
|
10336
|
+
* fill), is a problem only when it draws nothing at all
|
|
10337
|
+
* ({@link HAIRLINE_SHOWS}). The fix is the nearest color that reaches 3:1.
|
|
9773
10338
|
* @param {Ctx} ctx
|
|
9774
10339
|
* @param {ThemeData} data
|
|
9775
10340
|
* @param {{light: Record<string, string>, dark: Record<string, string>}} res
|
|
@@ -9779,12 +10344,43 @@ function plainOn(rgb) {
|
|
|
9779
10344
|
function borderContrastProblems(ctx, data, res, base) {
|
|
9780
10345
|
const modeFlag = (/** @type {string} */ m) =>
|
|
9781
10346
|
modesOf(data).length > 1 ? ` --mode ${m}` : '';
|
|
9782
|
-
/**
|
|
9783
|
-
|
|
10347
|
+
/**
|
|
10348
|
+
* The fix color for a border on a ground, or null: the border's own color
|
|
10349
|
+
* moved toward black or white (whichever stands out on the ground) just
|
|
10350
|
+
* far enough to reach 3:1, so a faint gray edge becomes the nearest gray
|
|
10351
|
+
* that shows, not black.
|
|
10352
|
+
* @param {string} ground @param {string} page @param {string} [border]
|
|
10353
|
+
*/
|
|
10354
|
+
const fixOn = (ground, page, border) => {
|
|
9784
10355
|
const p = parseColor(page);
|
|
9785
10356
|
const g0 = parseColor(ground);
|
|
9786
10357
|
if (!p || !g0) return null;
|
|
9787
|
-
|
|
10358
|
+
const g = compositeOver(g0, alphaOf(ground), p);
|
|
10359
|
+
const b0 = border ? parseColor(border) : null;
|
|
10360
|
+
if (!b0) return plainOn(g);
|
|
10361
|
+
return nearestReading(
|
|
10362
|
+
compositeOver(b0, alphaOf(String(border)), g),
|
|
10363
|
+
[g],
|
|
10364
|
+
3,
|
|
10365
|
+
);
|
|
10366
|
+
};
|
|
10367
|
+
/**
|
|
10368
|
+
* Whether a part is a control (it takes input: Core draws it disabled,
|
|
10369
|
+
* or as a button): its edge is how it is found, and needs 3:1 (WCAG
|
|
10370
|
+
* 1.4.11). A container's border (a card's hairline) is decoration, and a
|
|
10371
|
+
* faint one is a choice.
|
|
10372
|
+
* @param {string} t
|
|
10373
|
+
*/
|
|
10374
|
+
const control = t => {
|
|
10375
|
+
const rec = /** @type {any} */ (ctx.C.MAP[t]);
|
|
10376
|
+
return Boolean(
|
|
10377
|
+
rec &&
|
|
10378
|
+
('disabled' in (rec.attrs ?? {}) ||
|
|
10379
|
+
[...(rec.tags ?? [])].some(
|
|
10380
|
+
(/** @type {string} */ g) =>
|
|
10381
|
+
g === 'button' || g === 'input' || g === 'select',
|
|
10382
|
+
)),
|
|
10383
|
+
);
|
|
9788
10384
|
};
|
|
9789
10385
|
/** A value as one color in a mode: its half of light-dark(), a token read. @param {string} v @param {'light' | 'dark'} m @param {Record<string, string>} tokens */
|
|
9790
10386
|
const inMode = (v, m, tokens) => {
|
|
@@ -9865,8 +10461,16 @@ function borderContrastProblems(ctx, data, res, base) {
|
|
|
9865
10461
|
basePage,
|
|
9866
10462
|
basePage,
|
|
9867
10463
|
);
|
|
9868
|
-
if (
|
|
9869
|
-
|
|
10464
|
+
if (
|
|
10465
|
+
now != null &&
|
|
10466
|
+
now < 3 &&
|
|
10467
|
+
(was == null || (was >= 3 ? was > now : now < HAIRLINE_SHOWS))
|
|
10468
|
+
) {
|
|
10469
|
+
const color = fixOn(
|
|
10470
|
+
page,
|
|
10471
|
+
page,
|
|
10472
|
+
inMode(res[mode][x.thing], mode, res[mode]),
|
|
10473
|
+
);
|
|
9870
10474
|
add(
|
|
9871
10475
|
`border|${x.thing}|${mode}`,
|
|
9872
10476
|
`the border ${x.thing} (${inMode(res[mode][x.thing], mode, res[mode])}) is ${now.toFixed(2)}:1 on the page in ${mode} (${page}); a border needs 3:1 to show as an edge`,
|
|
@@ -9889,7 +10493,7 @@ function borderContrastProblems(ctx, data, res, base) {
|
|
|
9889
10493
|
: colorOfBorder(String(x.value));
|
|
9890
10494
|
if (!color) continue;
|
|
9891
10495
|
const border = inMode(color, mode, res[mode]);
|
|
9892
|
-
for (const t of partsOf(ctx, x)) {
|
|
10496
|
+
for (const t of partsOf(ctx, x).filter(control)) {
|
|
9893
10497
|
const own = [...data.settings]
|
|
9894
10498
|
.reverse()
|
|
9895
10499
|
.find(
|
|
@@ -9925,7 +10529,7 @@ function borderContrastProblems(ctx, data, res, base) {
|
|
|
9925
10529
|
basePage,
|
|
9926
10530
|
);
|
|
9927
10531
|
if (now != null && now < 3 && (was == null || was > now)) {
|
|
9928
|
-
const color = fixOn(ground || page, page);
|
|
10532
|
+
const color = fixOn(ground || page, page, border);
|
|
9929
10533
|
add(
|
|
9930
10534
|
`border|${x.thing}|${t}|${mode}`,
|
|
9931
10535
|
`the border on ${t} (${border}) is ${now.toFixed(2)}:1 on its ${ground && ground !== page ? `background ${ground}` : `page ${page}`} in ${mode}; a border needs 3:1 to show as an edge`,
|
|
@@ -9941,6 +10545,319 @@ function borderContrastProblems(ctx, data, res, base) {
|
|
|
9941
10545
|
return [...out.values()];
|
|
9942
10546
|
}
|
|
9943
10547
|
|
|
10548
|
+
/**
|
|
10549
|
+
* A button color the theme sets that also paints the buttons Core draws
|
|
10550
|
+
* inside a toast (its close button, an icon in a ghost button): measured on
|
|
10551
|
+
* the toast's own fill in each type and mode, where an icon needs 3:1. No
|
|
10552
|
+
* setting reaches the toast's buttons apart from the rest, so the problem
|
|
10553
|
+
* says so; its line is the nearest button color that reads both there and
|
|
10554
|
+
* on the page and surface (4.5:1), or none when no one color does.
|
|
10555
|
+
* @param {Ctx} ctx
|
|
10556
|
+
* @param {ThemeData} data
|
|
10557
|
+
* @param {{light: Record<string, string>, dark: Record<string, string>}} res
|
|
10558
|
+
* @returns {ThemeProblem[]}
|
|
10559
|
+
*/
|
|
10560
|
+
function leakedButtonProblems(ctx, data, res) {
|
|
10561
|
+
const modes = modesOf(data);
|
|
10562
|
+
/** A value as one color in a mode. @param {unknown} v @param {'light' | 'dark'} m */
|
|
10563
|
+
const inMode = (v, m) => {
|
|
10564
|
+
let x = String(v ?? '').trim();
|
|
10565
|
+
for (let i = 0; i < 4; i++) {
|
|
10566
|
+
const pair = /^light-dark\((.*)\)$/is.exec(x);
|
|
10567
|
+
if (pair) {
|
|
10568
|
+
const halves = splitTop(pair[1], ',');
|
|
10569
|
+
if (halves.length === 2) x = halves[m === 'light' ? 0 : 1].trim();
|
|
10570
|
+
}
|
|
10571
|
+
const ref = /^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(x);
|
|
10572
|
+
if (!ref) break;
|
|
10573
|
+
x = String(res[m][ref[1]] ?? '');
|
|
10574
|
+
}
|
|
10575
|
+
return x;
|
|
10576
|
+
};
|
|
10577
|
+
/** @param {string} v @param {[number, number, number]} under */
|
|
10578
|
+
const solid = (v, under) => {
|
|
10579
|
+
const c = parseColor(v);
|
|
10580
|
+
return c ? compositeOver(c, alphaOf(v), under) : null;
|
|
10581
|
+
};
|
|
10582
|
+
/** @type {Map<string, ThemeProblem>} */
|
|
10583
|
+
const out = new Map();
|
|
10584
|
+
for (const m of Object.keys(ctx.C.MAP).filter(t => autoMediaPart(ctx, t))) {
|
|
10585
|
+
const held = /** @type {string[]} */ (
|
|
10586
|
+
/** @type {any} */ (ctx.C.MAP[m])?.holdsVariants?.button ?? []
|
|
10587
|
+
);
|
|
10588
|
+
if (!held.length) continue;
|
|
10589
|
+
const reads = ctx.C.partReads(m, 'background') ?? [];
|
|
10590
|
+
const types = /** @type {string[]} */ ([
|
|
10591
|
+
...(ctx.C.MAP[m]?.attrs?.type ?? []),
|
|
10592
|
+
]);
|
|
10593
|
+
// The toast's fill in each type and page mode, with the scheme its
|
|
10594
|
+
// media surface draws what it holds in there: a setting for one mode
|
|
10595
|
+
// reaches the toast's buttons only where the surface draws that mode
|
|
10596
|
+
// (or takes no side, 'off', where the page's mode applies).
|
|
10597
|
+
/** @type {Array<{type: string, mode: 'light' | 'dark', scheme: 'light' | 'dark', value: string, rgb: [number, number, number]}>} */
|
|
10598
|
+
const fills = [];
|
|
10599
|
+
for (const m0 of modes) {
|
|
10600
|
+
const mode = /** @type {'light' | 'dark'} */ (m0);
|
|
10601
|
+
const page = parseColor(String(res[mode]['--color-background-body']));
|
|
10602
|
+
if (!page) continue;
|
|
10603
|
+
for (const type of ['', ...types]) {
|
|
10604
|
+
const cond = type ? `type=${type}` : '';
|
|
10605
|
+
const fillSet = [...data.settings]
|
|
10606
|
+
.reverse()
|
|
10607
|
+
.find(
|
|
10608
|
+
y =>
|
|
10609
|
+
y.source === 'property' &&
|
|
10610
|
+
/^background(-color)?$/.test(y.thing) &&
|
|
10611
|
+
!y.state &&
|
|
10612
|
+
(!y.mode || y.mode === mode) &&
|
|
10613
|
+
(!y.when || y.when === `type:${type}`) &&
|
|
10614
|
+
y.on &&
|
|
10615
|
+
partsOf(ctx, y).includes(m),
|
|
10616
|
+
);
|
|
10617
|
+
const read =
|
|
10618
|
+
reads.find(r => cond && r.when.includes(cond)) ??
|
|
10619
|
+
reads.find(r => r.when.includes(''));
|
|
10620
|
+
const value = fillSet
|
|
10621
|
+
? inMode(fillSet.value, mode)
|
|
10622
|
+
: read
|
|
10623
|
+
? inMode(`var(${read.token})`, mode)
|
|
10624
|
+
: '';
|
|
10625
|
+
if (/gradient\(|url\(/.test(value)) continue;
|
|
10626
|
+
const rgb = solid(value, page);
|
|
10627
|
+
if (!rgb) continue;
|
|
10628
|
+
const side = autoMediaSide(value, res[mode], {
|
|
10629
|
+
mode,
|
|
10630
|
+
error: type === 'error',
|
|
10631
|
+
});
|
|
10632
|
+
fills.push({
|
|
10633
|
+
type,
|
|
10634
|
+
mode,
|
|
10635
|
+
scheme: side === 'off' ? mode : side,
|
|
10636
|
+
value,
|
|
10637
|
+
rgb,
|
|
10638
|
+
});
|
|
10639
|
+
}
|
|
10640
|
+
}
|
|
10641
|
+
for (const scheme of /** @type {Array<'light' | 'dark'>} */ ([
|
|
10642
|
+
'light',
|
|
10643
|
+
'dark',
|
|
10644
|
+
])) {
|
|
10645
|
+
const here = fills.filter(f => f.scheme === scheme);
|
|
10646
|
+
if (!here.length) continue;
|
|
10647
|
+
const x = [...data.settings]
|
|
10648
|
+
.reverse()
|
|
10649
|
+
.find(
|
|
10650
|
+
y =>
|
|
10651
|
+
y.source === 'property' &&
|
|
10652
|
+
y.thing === 'color' &&
|
|
10653
|
+
!y.state &&
|
|
10654
|
+
(!y.mode || y.mode === scheme) &&
|
|
10655
|
+
y.on &&
|
|
10656
|
+
partsOf(ctx, y).includes('button') &&
|
|
10657
|
+
(!y.when || held.some(v => y.when === `variant:${v}`)),
|
|
10658
|
+
);
|
|
10659
|
+
if (!x) continue;
|
|
10660
|
+
const page = parseColor(
|
|
10661
|
+
String(res[scheme]['--color-background-body'] ?? ''),
|
|
10662
|
+
);
|
|
10663
|
+
if (!page) continue;
|
|
10664
|
+
const color = solid(inMode(x.value, scheme), page);
|
|
10665
|
+
if (!color) continue;
|
|
10666
|
+
const failing = here.filter(f => ratio(color, f.rgb) < 3);
|
|
10667
|
+
if (!failing.length) continue;
|
|
10668
|
+
// The nearest color that reads on every one of those fills (3:1) and,
|
|
10669
|
+
// where the theme draws that mode, as text on its page and surface
|
|
10670
|
+
// (4.5:1), toward black or white; none when no one color does.
|
|
10671
|
+
const surface = solid(
|
|
10672
|
+
String(res[scheme]['--color-background-surface'] ?? ''),
|
|
10673
|
+
page,
|
|
10674
|
+
);
|
|
10675
|
+
const grounds = /** @type {Array<[number, number, number]>} */ (
|
|
10676
|
+
modes.includes(scheme) ? [page, surface].filter(Boolean) : []
|
|
10677
|
+
);
|
|
10678
|
+
/** @type {string | null} */
|
|
10679
|
+
let best = null;
|
|
10680
|
+
let steps = Infinity;
|
|
10681
|
+
for (const end of /** @type {Array<[number, number, number]>} */ ([
|
|
10682
|
+
[0, 0, 0],
|
|
10683
|
+
[255, 255, 255],
|
|
10684
|
+
]))
|
|
10685
|
+
for (let i = 0; i <= 100 && i < steps; i++) {
|
|
10686
|
+
const c = /** @type {[number, number, number]} */ (
|
|
10687
|
+
color.map((v, k) => Math.round(v + ((end[k] - v) * i) / 100))
|
|
10688
|
+
);
|
|
10689
|
+
if (
|
|
10690
|
+
here.every(f => ratio(c, f.rgb) >= 3) &&
|
|
10691
|
+
grounds.every(g => ratio(c, g) >= 4.5)
|
|
10692
|
+
) {
|
|
10693
|
+
best = hex(c);
|
|
10694
|
+
steps = i;
|
|
10695
|
+
break;
|
|
10696
|
+
}
|
|
10697
|
+
}
|
|
10698
|
+
for (const f of failing) {
|
|
10699
|
+
const where = `${m}${f.type ? ` (type ${f.type})` : ''}`;
|
|
10700
|
+
const key = `leak|button|${m}|${f.type}|${f.mode}`;
|
|
10701
|
+
if (out.has(key)) continue;
|
|
10702
|
+
out.set(key, {
|
|
10703
|
+
key,
|
|
10704
|
+
text: `your button color (${describe(x)}) also paints the close button in ${where}: it is ${ratio(color, f.rgb).toFixed(2)}:1 on the ${m}'s fill (${f.value}) in ${f.mode}, and an icon needs 3:1; no setting keeps the ${m}'s buttons apart${best ? '' : `, and no one button color reads on every ${m} and on the page`}`,
|
|
10705
|
+
fix: best
|
|
10706
|
+
? `${P} set ${data.name} color '${best}' --on ${x.on}${x.only ? ' --only' : ''}${x.when ? ` --when ${x.when}` : ''}${x.mode || modes.length > 1 ? ` --mode ${scheme}` : ''}`
|
|
10707
|
+
: null,
|
|
10708
|
+
});
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
}
|
|
10712
|
+
return [...out.values()];
|
|
10713
|
+
}
|
|
10714
|
+
|
|
10715
|
+
/**
|
|
10716
|
+
* Text contrast for a part in one state or condition the theme styles on
|
|
10717
|
+
* its own (a selected row's fill, an info banner's fill, a selected nav
|
|
10718
|
+
* item's text color), which the census drew at rest: the part's text
|
|
10719
|
+
* measured on its fill in that state or condition, in each mode. The fill
|
|
10720
|
+
* is a fill the theme sets for it there, else the token its part data reads
|
|
10721
|
+
* there (as the theme sets it on the part there, or resolves it), else its
|
|
10722
|
+
* resting fill, else the page; the text likewise, else the theme's primary
|
|
10723
|
+
* text. Below 4.5:1 is a problem, fixed with the nearest color that reads
|
|
10724
|
+
* there, set on what draws the text, in that state or condition. Settings
|
|
10725
|
+
* whose text or fill cannot be read as one color come back unmeasured.
|
|
10726
|
+
* @param {Ctx} ctx
|
|
10727
|
+
* @param {ThemeData} data
|
|
10728
|
+
* @param {{light: Record<string, string>, dark: Record<string, string>}} res
|
|
10729
|
+
* @returns {{problems: ThemeProblem[], unmeasured: Setting[]}}
|
|
10730
|
+
*/
|
|
10731
|
+
function scopedTextProblems(ctx, data, res) {
|
|
10732
|
+
const modes = modesOf(data);
|
|
10733
|
+
const modeFlag = (/** @type {string} */ m) =>
|
|
10734
|
+
modes.length > 1 ? ` --mode ${m}` : '';
|
|
10735
|
+
/** A value as one color in a mode. @param {unknown} v @param {'light' | 'dark'} m */
|
|
10736
|
+
const inMode = (v, m) => {
|
|
10737
|
+
let x = String(v ?? '').trim();
|
|
10738
|
+
for (let i = 0; i < 4; i++) {
|
|
10739
|
+
const pair = /^light-dark\((.*)\)$/is.exec(x);
|
|
10740
|
+
if (pair) {
|
|
10741
|
+
const halves = splitTop(pair[1], ',');
|
|
10742
|
+
if (halves.length === 2) x = halves[m === 'light' ? 0 : 1].trim();
|
|
10743
|
+
}
|
|
10744
|
+
const ref = /^var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)$/.exec(x);
|
|
10745
|
+
if (!ref) break;
|
|
10746
|
+
x = String(res[m][ref[1]] ?? '');
|
|
10747
|
+
}
|
|
10748
|
+
return x;
|
|
10749
|
+
};
|
|
10750
|
+
const FILL = /^background(-color)?$/;
|
|
10751
|
+
/** @param {Setting} x */
|
|
10752
|
+
const scopedColor = x =>
|
|
10753
|
+
Boolean(
|
|
10754
|
+
x.on &&
|
|
10755
|
+
(x.state || (x.when && !/^variant:/.test(x.when))) &&
|
|
10756
|
+
(/^(color|background|background-color)$/.test(x.thing) ||
|
|
10757
|
+
/^--color-/.test(x.thing)),
|
|
10758
|
+
);
|
|
10759
|
+
/** @type {Map<string, ThemeProblem>} */
|
|
10760
|
+
const out = new Map();
|
|
10761
|
+
/** @type {Setting[]} */
|
|
10762
|
+
const unmeasured = [];
|
|
10763
|
+
/** @type {Set<string>} */
|
|
10764
|
+
const done = new Set();
|
|
10765
|
+
for (const x of data.settings.filter(scopedColor)) {
|
|
10766
|
+
const st = x.state ? String(x.state) : null;
|
|
10767
|
+
const when = st ? null : String(x.when);
|
|
10768
|
+
for (const t of partsOf(ctx, x)) {
|
|
10769
|
+
const scopeKey = `${t}|${st ?? ''}|${when ?? ''}`;
|
|
10770
|
+
if (done.has(scopeKey)) continue;
|
|
10771
|
+
done.add(scopeKey);
|
|
10772
|
+
/** A part-data condition is this scope. @param {string} w */
|
|
10773
|
+
const inScope = w => {
|
|
10774
|
+
const terms = w.split(' ')[0].split(',');
|
|
10775
|
+
return st
|
|
10776
|
+
? new RegExp(`(^|[\\s,])${st}=`).test(w)
|
|
10777
|
+
: terms.includes(String(when).replace(':', '='));
|
|
10778
|
+
};
|
|
10779
|
+
/** A setting is on this part in this scope (or at rest), in a mode. @param {Setting} y @param {string} m @param {boolean} scoped */
|
|
10780
|
+
const here = (y, m, scoped) =>
|
|
10781
|
+
Boolean(y.on) &&
|
|
10782
|
+
(!y.mode || y.mode === m) &&
|
|
10783
|
+
(scoped
|
|
10784
|
+
? (y.state ?? null) === st && (st ? true : y.when === when)
|
|
10785
|
+
: !y.state && !y.when) &&
|
|
10786
|
+
partsOf(ctx, y).includes(t);
|
|
10787
|
+
/** The latest setting matching, scoped first, then at rest. @param {(y: Setting) => boolean} test @param {string} m */
|
|
10788
|
+
const latest = (test, m) =>
|
|
10789
|
+
[...data.settings].reverse().find(y => test(y) && here(y, m, true)) ??
|
|
10790
|
+
[...data.settings].reverse().find(y => test(y) && here(y, m, false)) ??
|
|
10791
|
+
null;
|
|
10792
|
+
/** The value of a token on this part in this scope, in a mode. @param {string} tok @param {'light' | 'dark'} m */
|
|
10793
|
+
const tokenValue = (tok, m) => {
|
|
10794
|
+
const set = latest(y => y.source === 'token' && y.thing === tok, m);
|
|
10795
|
+
return set ? inMode(set.value, m) : inMode(`var(${tok})`, m);
|
|
10796
|
+
};
|
|
10797
|
+
/** The part-data read for a group in this scope, else at rest. @param {string} group */
|
|
10798
|
+
const readOf = group => {
|
|
10799
|
+
const reads = ctx.C.partReads(t, group) ?? [];
|
|
10800
|
+
return (
|
|
10801
|
+
reads.find(r => r.when.some(inScope)) ??
|
|
10802
|
+
reads.find(r => r.when.includes('')) ??
|
|
10803
|
+
null
|
|
10804
|
+
);
|
|
10805
|
+
};
|
|
10806
|
+
for (const m0 of modes) {
|
|
10807
|
+
const m = /** @type {'light' | 'dark'} */ (m0);
|
|
10808
|
+
const page = parseColor(String(res[m]['--color-background-body']));
|
|
10809
|
+
if (!page) continue;
|
|
10810
|
+
const fillSet = latest(
|
|
10811
|
+
y => y.source === 'property' && FILL.test(y.thing),
|
|
10812
|
+
m,
|
|
10813
|
+
);
|
|
10814
|
+
const fillRead = readOf('background');
|
|
10815
|
+
const groundValue = fillSet
|
|
10816
|
+
? inMode(fillSet.value, m)
|
|
10817
|
+
: fillRead
|
|
10818
|
+
? tokenValue(fillRead.token, m)
|
|
10819
|
+
: String(res[m]['--color-background-body']);
|
|
10820
|
+
const colorSet = latest(
|
|
10821
|
+
y => y.source === 'property' && y.thing === 'color',
|
|
10822
|
+
m,
|
|
10823
|
+
);
|
|
10824
|
+
const textRead = readOf('text');
|
|
10825
|
+
const textToken = textRead?.token ?? '--color-text-primary';
|
|
10826
|
+
const textValue = colorSet
|
|
10827
|
+
? inMode(colorSet.value, m)
|
|
10828
|
+
: tokenValue(textToken, m);
|
|
10829
|
+
if (/gradient\(|url\(/.test(`${groundValue}${textValue}`)) {
|
|
10830
|
+
unmeasured.push(x);
|
|
10831
|
+
continue;
|
|
10832
|
+
}
|
|
10833
|
+
const g0 = parseColor(groundValue);
|
|
10834
|
+
const fg0 = parseColor(textValue);
|
|
10835
|
+
if (!g0 || !fg0) {
|
|
10836
|
+
unmeasured.push(x);
|
|
10837
|
+
continue;
|
|
10838
|
+
}
|
|
10839
|
+
const ground = compositeOver(g0, alphaOf(groundValue), page);
|
|
10840
|
+
const fg = compositeOver(fg0, alphaOf(textValue), ground);
|
|
10841
|
+
const r = ratio(fg, ground);
|
|
10842
|
+
if (r >= 4.5) continue;
|
|
10843
|
+
const scope = st ? `--state ${st}` : `--when ${when}`;
|
|
10844
|
+
const label = st ? st : String(when).replace(':', ' ');
|
|
10845
|
+
const fix = nearestReading(fg, [ground], 4.5);
|
|
10846
|
+
// What draws the text: a color set there, else the token the text
|
|
10847
|
+
// reads, set on the part in that state or condition.
|
|
10848
|
+
const thing = colorSet || !textRead ? 'color' : textToken;
|
|
10849
|
+
const key = `scoped-text|${t}|${st ?? ''}|${when ?? ''}|${m}`;
|
|
10850
|
+
out.set(key, {
|
|
10851
|
+
key,
|
|
10852
|
+
text: `text in ${t} (${label}) is ${r.toFixed(2)}:1 in ${m} (${textValue} on ${t}'s ${fillSet ? groundValue : fillRead ? fillRead.token : 'page'} there); text needs 4.5:1`,
|
|
10853
|
+
fix: `${P} set ${data.name} ${thing} '${fix}' --on ${t} ${scope}${modeFlag(m)}`,
|
|
10854
|
+
});
|
|
10855
|
+
}
|
|
10856
|
+
}
|
|
10857
|
+
}
|
|
10858
|
+
return {problems: [...out.values()], unmeasured};
|
|
10859
|
+
}
|
|
10860
|
+
|
|
9944
10861
|
/**
|
|
9945
10862
|
* Settings file text as data, or null when there is none or it is damaged.
|
|
9946
10863
|
* @param {string | null} text
|
|
@@ -10161,7 +11078,7 @@ function stepText(text, cwd, radii) {
|
|
|
10161
11078
|
}
|
|
10162
11079
|
|
|
10163
11080
|
/** The file's own top-level fields. */
|
|
10164
|
-
const TOP_FIELDS = ['name', 'mode', 'like', 'settings', 'lifted'];
|
|
11081
|
+
const TOP_FIELDS = ['name', 'mode', 'like', 'settings', 'lifted', 'palette'];
|
|
10165
11082
|
/** The top-level field a word the editor uses for it names (`base` is the like field: `set t base`). */
|
|
10166
11083
|
const TOP_FIELD_WORDS = /** @type {Record<string, string>} */ ({base: 'like'});
|
|
10167
11084
|
|
|
@@ -10227,6 +11144,15 @@ function topFieldNames(data) {
|
|
|
10227
11144
|
: `the settings file writes "${k}" in other letters, read as ${field}`,
|
|
10228
11145
|
);
|
|
10229
11146
|
}
|
|
11147
|
+
// A field the editor does not read (`theme`, `modes`) is not used, and
|
|
11148
|
+
// said, with the field it is a typo of.
|
|
11149
|
+
for (const k of Object.keys(data)) {
|
|
11150
|
+
if (TOP_FIELDS.includes(k)) continue;
|
|
11151
|
+
const near = TOP_FIELDS.filter(f => typoNear(k.trim().toLowerCase(), f));
|
|
11152
|
+
notes.push(
|
|
11153
|
+
`the settings file has "${k}", a field the editor does not read${near.length === 1 ? ` (it reads "${near[0]}")` : ''}, so it is not used`,
|
|
11154
|
+
);
|
|
11155
|
+
}
|
|
10230
11156
|
return notes;
|
|
10231
11157
|
}
|
|
10232
11158
|
|
|
@@ -10791,13 +11717,20 @@ export function innerTextTokens(C, part, deep = false) {
|
|
|
10791
11717
|
for (const inner of rec?.contains ?? []) {
|
|
10792
11718
|
const r = C.MAP[inner];
|
|
10793
11719
|
add(r?.inside);
|
|
10794
|
-
// A part's own color counts where it reads the token always,
|
|
10795
|
-
//
|
|
11720
|
+
// A part's own color counts where it reads the token always, or for
|
|
11721
|
+
// a look of its own (a heading or a text's color role, `color=primary`
|
|
11722
|
+
// beside its level), never only in a state.
|
|
10796
11723
|
for (const [tok, conds] of Object.entries(r?.own?.color?.tokens ?? {}))
|
|
10797
11724
|
if (
|
|
10798
11725
|
TEXT_ROLES.includes(tok) &&
|
|
10799
11726
|
/** @type {string[]} */ (conds).some(
|
|
10800
|
-
w =>
|
|
11727
|
+
w =>
|
|
11728
|
+
!w.trim() ||
|
|
11729
|
+
w.trim() === 'always' ||
|
|
11730
|
+
(!/\s/.test(w.trim()) &&
|
|
11731
|
+
!/(?:^|,)(?:disabled|selected|checked|readonly|aria-[\w-]+|status)=/.test(
|
|
11732
|
+
w,
|
|
11733
|
+
)),
|
|
10801
11734
|
)
|
|
10802
11735
|
)
|
|
10803
11736
|
out.add(tok);
|
|
@@ -11229,8 +12162,14 @@ export function refuseLinks(cwd, slug) {
|
|
|
11229
12162
|
// replaced: that one picture is skipped and named (`pictures`), so it
|
|
11230
12163
|
// refuses nothing here.
|
|
11231
12164
|
const recorded = readWrittenRecord(cwd, slug);
|
|
12165
|
+
// A link at a page's name (preview.html, the sheets) or at the record of
|
|
12166
|
+
// pictures is left alone the same way: that page or picture is not made,
|
|
12167
|
+
// and the result names it.
|
|
11232
12168
|
const own = (/** @type {string} */ n) =>
|
|
11233
|
-
(isEditorFile(slug, n, recorded) &&
|
|
12169
|
+
(isEditorFile(slug, n, recorded) &&
|
|
12170
|
+
!n.endsWith('.png') &&
|
|
12171
|
+
!isEditorPage(n, recorded) &&
|
|
12172
|
+
n !== `${slug}.pictures.json`) ||
|
|
11234
12173
|
n === `${slug}.theme.ts` ||
|
|
11235
12174
|
n === 'tokens';
|
|
11236
12175
|
/** @type {string[]} */
|