@astryxdesign/cli 0.7.17-canary.g49a475f → 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 +14 -9
- package/api/build/_adapter.d.mts +33 -4
- package/api/build/_adapter.mjs +43 -8
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +2 -1
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.type.d.mts +13 -1
- package/api/build/build.type.mjs +6 -3
- package/api/build/kit/kind.d.mts +6 -0
- package/api/build/kit/kind.mjs +1 -1
- package/api/build/kit/kit.mjs +3 -3
- package/api/build/kit/rank.d.mts +9 -3
- package/api/build/kit/rank.mjs +21 -8
- package/api/build/kit/signals.d.mts +7 -1
- package/api/build/kit/signals.mjs +124 -41
- package/api/build/kit/start.d.mts +20 -5
- package/api/build/kit/start.mjs +103 -23
- package/api/build/kit/weights.d.mts +20 -4
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +68 -18
- package/api/build/kit/words.d.mts +44 -2
- package/api/build/kit/words.mjs +159 -4
- package/api/build/tree.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -4
- package/api/component/_adapter.d.mts +51 -20
- package/api/component/_adapter.mjs +198 -29
- package/api/component/component.mjs +18 -5
- package/api/component/component.type.d.mts +4 -0
- package/api/component/component.type.mjs +1 -0
- package/api/component/detail/blocks/blocks.mjs +1 -0
- 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.d.mts +10 -0
- package/api/discover/_adapter.mjs +110 -16
- package/api/discover/detail/item/item.mjs +5 -0
- package/api/discover/discover.mjs +12 -3
- package/api/discover/discover.type.d.mts +16 -3
- package/api/discover/discover.type.mjs +13 -3
- package/api/docs/_adapter.d.mts +74 -30
- package/api/docs/_adapter.mjs +488 -234
- package/api/docs/_entry-names-lazily.d.mts +22 -0
- package/api/docs/_entry-names-lazily.mjs +25 -0
- package/api/docs/_entry-names.d.mts +23 -0
- package/api/docs/_entry-names.mjs +105 -0
- package/api/doctor/_adapter.d.mts +63 -2
- package/api/doctor/_adapter.mjs +141 -5
- package/api/doctor/doctor.d.mts +11 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +81 -30
- package/api/doctor/theme-checks.d.mts +35 -3
- package/api/doctor/theme-checks.mjs +449 -99
- package/api/error.d.mts +4 -3
- package/api/error.mjs +3 -2
- package/api/hook/_adapter.d.mts +14 -7
- package/api/hook/_adapter.mjs +46 -9
- package/api/hook/detail/detail.mjs +5 -2
- package/api/hook/detail/params/params.mjs +10 -3
- 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/integration/add-helpers.mjs +10 -0
- package/api/integration/authoring-checks.mjs +5 -2
- package/api/integration/check/check.mjs +6 -1
- package/api/integration/pack-check.mjs +50 -3
- package/api/integration/validate-integration.d.mts +18 -6
- package/api/integration/validate-integration.mjs +110 -14
- package/api/integration/validate-integration.type.d.mts +13 -0
- package/api/integration/validate-integration.type.mjs +2 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +8 -5
- package/api/search/_adapter.mjs +14 -10
- package/api/search/_candidate-score.d.mts +9 -4
- package/api/search/_candidate-score.mjs +82 -14
- 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/_gather-templates.mjs +1 -0
- package/api/search/_lexical.d.mts +16 -0
- package/api/search/_lexical.mjs +98 -10
- package/api/search/_priority.d.mts +10 -2
- package/api/search/_priority.mjs +37 -7
- package/api/search/_result.d.mts +1 -0
- package/api/search/_result.mjs +1 -0
- 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.doc.mjs +1 -1
- package/api/search/search.mjs +37 -4
- package/api/search/search.type.d.mts +4 -0
- package/api/search/search.type.mjs +1 -0
- package/api/swizzle/_adapter.d.mts +7 -5
- package/api/swizzle/_adapter.mjs +22 -6
- package/api/swizzle/copy/copy.mjs +5 -4
- package/api/template/_adapter.d.mts +16 -0
- package/api/template/_adapter.mjs +39 -2
- package/api/template/cdn/cdn.mjs +37 -8
- package/api/template/copy/copy.d.mts +6 -3
- package/api/template/copy/copy.mjs +83 -8
- package/api/template/show/show.mjs +1 -0
- package/api/template/skeleton/skeleton.mjs +1 -0
- package/api/template/template.doc.mjs +5 -5
- package/api/template/template.mjs +63 -11
- package/api/template/template.type.d.mts +4 -0
- package/api/template/template.type.mjs +5 -1
- package/api/theme/_adapter.d.mts +20 -1
- package/api/theme/_adapter.mjs +149 -12
- package/api/theme/_app-provider.d.mts +31 -0
- package/api/theme/_app-provider.mjs +135 -0
- package/api/theme/add/add.mjs +3 -1
- package/api/theme/build/build.d.mts +127 -11
- package/api/theme/build/build.mjs +2047 -352
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/family.mjs +61 -21
- package/api/theme/build/font-warning.d.mts +99 -5
- package/api/theme/build/font-warning.mjs +379 -61
- package/api/theme/build/icon-imports.mjs +83 -15
- package/api/theme/build/input-fields.d.mts +110 -0
- package/api/theme/build/input-fields.mjs +667 -0
- package/api/theme/build/null-values.d.mts +42 -0
- package/api/theme/build/null-values.mjs +283 -0
- package/api/theme/build/self-contained.d.mts +90 -0
- package/api/theme/build/self-contained.mjs +380 -0
- package/api/theme/build/source-syntax.d.mts +11 -0
- package/api/theme/build/source-syntax.mjs +28 -0
- package/api/theme/build/style-keys.d.mts +72 -0
- package/api/theme/build/style-keys.mjs +589 -0
- package/api/theme/build/typography-values.d.mts +61 -0
- package/api/theme/build/typography-values.mjs +408 -0
- package/api/theme/build/written-values.d.mts +78 -0
- package/api/theme/build/written-values.mjs +482 -0
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/list/list.mjs +17 -1
- package/api/theme/palette/generate/generator.d.mts +14 -2
- package/api/theme/palette/generate/generator.mjs +94 -8
- package/api/theme/remove/remove.d.mts +2 -1
- package/api/theme/remove/remove.mjs +7 -3
- package/api/theme/theme.type.d.mts +89 -5
- package/api/theme/theme.type.mjs +46 -7
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +8 -5
- package/api/theme/themeTemplate.doc.mjs +18 -3
- package/api/theme-edit/_adapter.d.mts +57 -4
- package/api/theme-edit/_adapter.mjs +380 -73
- package/api/theme-edit/_catalog.d.mts +82 -4
- package/api/theme-edit/_catalog.mjs +397 -24
- package/api/theme-edit/_check.d.mts +153 -2
- package/api/theme-edit/_check.mjs +3028 -563
- package/api/theme-edit/_color.d.mts +27 -2
- package/api/theme-edit/_color.mjs +66 -8
- package/api/theme-edit/_compiler.d.mts +7 -2
- package/api/theme-edit/_compiler.mjs +335 -21
- package/api/theme-edit/_context.d.mts +192 -7
- package/api/theme-edit/_context.mjs +750 -70
- package/api/theme-edit/_css.d.mts +32 -0
- package/api/theme-edit/_css.mjs +121 -34
- package/api/theme-edit/_edit.d.mts +68 -5
- package/api/theme-edit/_edit.mjs +5119 -667
- package/api/theme-edit/_how-commands.d.mts +28 -1
- package/api/theme-edit/_how-commands.mjs +621 -17
- package/api/theme-edit/_how-question.d.mts +101 -9
- package/api/theme-edit/_how-question.mjs +13901 -1282
- package/api/theme-edit/_how.d.mts +13 -2
- package/api/theme-edit/_how.mjs +389 -32
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_missed.d.mts +54 -0
- package/api/theme-edit/_missed.mjs +917 -0
- package/api/theme-edit/_normal.d.mts +110 -21
- package/api/theme-edit/_normal.mjs +700 -105
- package/api/theme-edit/_palette.d.mts +77 -0
- package/api/theme-edit/_palette.mjs +364 -73
- package/api/theme-edit/_part-words.d.mts +39 -0
- package/api/theme-edit/_part-words.mjs +191 -0
- package/api/theme-edit/_parts.d.mts +74 -4
- package/api/theme-edit/_parts.mjs +677 -73
- package/api/theme-edit/_preview-app.d.mts +8 -13
- package/api/theme-edit/_preview-app.mjs +1189 -559
- package/api/theme-edit/_preview.d.mts +151 -10
- package/api/theme-edit/_preview.mjs +785 -98
- package/api/theme-edit/_project.d.mts +38 -3
- package/api/theme-edit/_project.mjs +135 -8
- package/api/theme-edit/_settings.d.mts +678 -83
- package/api/theme-edit/_settings.mjs +6037 -1051
- package/api/theme-edit/_tables.d.mts +43 -3
- package/api/theme-edit/_tables.mjs +244 -59
- package/api/theme-edit/_vet.d.mts +14 -1
- package/api/theme-edit/_vet.mjs +86 -12
- package/api/theme-edit/theme-edit.type.d.mts +53 -3
- package/api/theme-edit/theme-edit.type.mjs +23 -5
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/upgrade/_adapter.mjs +13 -2
- package/api/upgrade/upgrade.mjs +16 -1
- package/assets/codemods/integration-runner.mjs +1 -1
- package/assets/codemods/jscodeshift.d.ts +1 -1
- package/assets/codemods/parse.mjs +2 -2
- package/assets/codemods/run-codemod.mjs +71 -18
- package/assets/codemods/runner.mjs +1 -4
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +86 -7
- package/assets/docs/theme.doc.mjs +76 -2
- package/assets/docs/theme.doc.zh.mjs +61 -1
- package/assets/docs/tree/authoring.doc.mjs +1 -0
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/cli.doc.mjs +1 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/fonts-and-assets.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/install-once.doc.mjs +1 -1
- package/assets/docs/tree/problems.doc.mjs +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/docs/tree/share-a-page.doc.mjs +162 -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 +3 -3
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs-routes.generated.json +1 -0
- 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/ChatComposerInput/useChatPasteAsTokenHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatPasteAsTokenHookUsage.tsx +32 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
- 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/ai-chat-landing/page.tsx +31 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +3 -0
- 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-alert-rail/page.tsx +1 -1
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +32 -21
- package/assets/templates/pages/dashboard-comparison/page.tsx +11 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +22 -9
- package/assets/templates/pages/dashboard-progress/page.tsx +28 -16
- package/assets/templates/pages/dashboard-scorecard/page.tsx +9 -0
- package/assets/templates/pages/detail-page/page.tsx +157 -76
- 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 +122 -65
- package/assets/templates/pages/editor/page.tsx +41 -24
- package/assets/templates/pages/file-explorer/page.tsx +44 -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 +55 -6
- package/assets/templates/pages/gallery-hero/page.tsx +2 -1
- package/assets/templates/pages/ide/page.tsx +23 -0
- package/assets/templates/pages/ide/template.doc.mjs +1 -1
- package/assets/templates/pages/incident-console/page.tsx +130 -30
- package/assets/templates/pages/incident-console/template.doc.mjs +2 -2
- package/assets/templates/pages/kanban-board/page.tsx +50 -3
- package/assets/templates/pages/login-card/page.tsx +16 -0
- package/assets/templates/pages/login-split/page.tsx +19 -6
- package/assets/templates/pages/messaging-shell/page.tsx +409 -419
- package/assets/templates/pages/messaging-shell/template.doc.mjs +6 -6
- package/assets/templates/pages/payment-form/page.tsx +107 -43
- package/assets/templates/pages/product-detail/page.tsx +26 -2
- 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 +196 -17
- 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 +27 -4
- 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 +575 -61
- package/assets/templates/pages/table/template.doc.mjs +11 -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 +17 -1
- package/assets/templates/pages/table-grouped/page.tsx +171 -133
- package/assets/templates/pages/table-inbox/page.tsx +60 -1
- package/assets/templates/pages/table-page/page.tsx +23 -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 +134 -80
- 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/assets/theme.template.ts +3 -2
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +28 -14
- 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/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +1 -1
- package/authoring/index.d.ts +6 -1
- package/authoring/integration/integration.doc.mjs +15 -0
- package/authoring/integration/schema.d.mts +30 -1
- package/authoring/integration/schema.mjs +129 -4
- package/authoring/integration/type.ts +48 -0
- package/clients/cli/bin/astryx.mjs +9 -3
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +17 -5
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/component.mjs +107 -42
- package/clients/cli/commands/discover.mjs +70 -3
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +41 -5
- package/clients/cli/commands/doctor.mjs +52 -2
- package/clients/cli/commands/experimental/index.mjs +4 -1
- package/clients/cli/commands/experimental/theme.mjs +1504 -186
- package/clients/cli/commands/experimental-render.doc.mjs +18 -5
- package/clients/cli/commands/experimental-theme-add.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -2
- 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 +4 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +5 -4
- 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 +3 -2
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +6 -4
- 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/init.mjs +14 -6
- package/clients/cli/commands/integration-add.doc.mjs +1 -0
- package/clients/cli/commands/manifest.mjs +10 -3
- package/clients/cli/commands/search.mjs +13 -1
- package/clients/cli/commands/swizzle.doc.mjs +9 -2
- package/clients/cli/commands/swizzle.mjs +13 -6
- package/clients/cli/commands/template.doc.mjs +4 -1
- package/clients/cli/commands/template.mjs +34 -7
- package/clients/cli/commands/theme-add.doc.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +11 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-remove.doc.mjs +15 -6
- 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 +824 -576
- package/clients/cli/commands/upgrade.mjs +7 -3
- package/clients/cli/index.mjs +177 -78
- package/clients/cli/lib/base-gate.mjs +522 -0
- package/clients/cli/lib/cli-error.mjs +21 -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 +679 -40
- package/clients/cli/lib/manifest.d.ts +14 -0
- package/clients/cli/lib/manifest.mjs +78 -22
- package/clients/cli/lib/not-ready.mjs +22 -0
- package/clients/cli/lib/root-args.mjs +79 -0
- package/clients/cli/lib/stray-option.mjs +491 -0
- package/clients/cli/lib/unknown-command.mjs +374 -0
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +39 -3
- package/foundation/agent-docs/agent-docs.mjs +1 -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 +22 -0
- package/foundation/config/project.mjs +94 -30
- package/foundation/config/theme-build-header.d.mts +14 -0
- package/foundation/config/theme-build-header.mjs +14 -0
- package/foundation/config/theme-private-vars.d.mts +26 -2
- package/foundation/config/theme-private-vars.mjs +65 -5
- package/foundation/config/theme-state.d.mts +19 -2
- package/foundation/config/theme-state.mjs +93 -1
- package/foundation/debug/event.d.mts +8 -2
- package/foundation/debug/event.mjs +6 -7
- package/foundation/debug/recorder.d.mts +8 -1
- package/foundation/debug/recorder.mjs +8 -2
- package/foundation/discovery/cli-self-doc-names.d.mts +13 -0
- package/foundation/discovery/cli-self-doc-names.mjs +51 -0
- package/foundation/discovery/cli-self-docs.d.mts +0 -2
- package/foundation/discovery/cli-self-docs.mjs +11 -16
- 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 +12 -6
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/core-theme-facts.d.mts +70 -0
- package/foundation/discovery/core-theme-facts.mjs +384 -0
- package/foundation/discovery/docs-discovery.d.mts +84 -9
- package/foundation/discovery/docs-discovery.mjs +151 -60
- package/foundation/discovery/entry-name-files.d.mts +72 -9
- package/foundation/discovery/entry-name-files.mjs +193 -103
- package/foundation/discovery/hook-discovery.d.mts +16 -6
- package/foundation/discovery/hook-discovery.mjs +82 -43
- package/foundation/discovery/integration-component-views.d.mts +15 -0
- package/foundation/discovery/integration-component-views.mjs +91 -0
- package/foundation/discovery/module-exports.d.mts +26 -1
- package/foundation/discovery/module-exports.mjs +114 -40
- package/foundation/discovery/name-roots.d.mts +38 -0
- package/foundation/discovery/name-roots.mjs +108 -0
- package/foundation/discovery/next-routes.d.mts +48 -0
- package/foundation/discovery/next-routes.mjs +197 -0
- package/foundation/discovery/stored-self-audit.mjs +2 -0
- package/foundation/discovery/template-adapter.d.mts +31 -63
- package/foundation/discovery/template-adapter.mjs +38 -207
- package/foundation/discovery/template-destination.d.mts +28 -0
- package/foundation/discovery/template-destination.mjs +106 -0
- package/foundation/discovery/template-ids.d.mts +69 -0
- package/foundation/discovery/template-ids.mjs +203 -0
- package/foundation/discovery/template-needs.mjs +3 -1
- package/foundation/discovery/theme-discovery.d.mts +12 -0
- package/foundation/discovery/theme-discovery.mjs +34 -2
- package/foundation/discovery/theme-imports.d.mts +10 -0
- package/foundation/discovery/theme-imports.mjs +37 -4
- package/foundation/discovery/theming-targets.d.mts +13 -5
- package/foundation/discovery/theming-targets.mjs +38 -45
- package/foundation/doc-compiler/generated-levels.d.mts +43 -0
- package/foundation/doc-compiler/generated-levels.mjs +72 -0
- package/foundation/doc-compiler/literal-doc.d.mts +12 -0
- package/foundation/doc-compiler/literal-doc.mjs +322 -0
- package/foundation/doc-compiler/stored-docs.d.mts +7 -0
- package/foundation/doc-compiler/stored-docs.mjs +14 -1
- package/foundation/doc-compiler/tree.d.mts +18 -87
- package/foundation/doc-compiler/tree.mjs +57 -64
- package/foundation/env/intl-defaults.d.mts +39 -0
- package/foundation/env/intl-defaults.mjs +150 -0
- package/foundation/env/intl-now.d.mts +21 -0
- package/foundation/env/intl-now.mjs +25 -0
- package/foundation/env/package-manager.d.mts +11 -2
- package/foundation/env/package-manager.mjs +28 -4
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +128 -12
- package/foundation/fs/cache-eviction.d.mts +3 -1
- package/foundation/fs/cache-eviction.mjs +7 -1
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +12 -2
- package/foundation/fs/gather-cache.d.mts +81 -2
- package/foundation/fs/gather-cache.mjs +615 -97
- package/foundation/fs/glob.d.mts +16 -0
- package/foundation/fs/glob.mjs +105 -0
- package/foundation/fs/jiti-cache.mjs +14 -6
- package/foundation/fs/kept-tree.d.mts +39 -15
- package/foundation/fs/kept-tree.mjs +155 -46
- package/foundation/fs/loaded-files.d.mts +30 -0
- package/foundation/fs/loaded-files.mjs +148 -0
- package/foundation/fs/module-loader.d.mts +53 -8
- package/foundation/fs/module-loader.mjs +559 -39
- package/foundation/fs/own-modules.d.mts +29 -0
- package/foundation/fs/own-modules.mjs +57 -0
- package/foundation/fs/path-safety.d.mts +34 -2
- package/foundation/fs/path-safety.mjs +170 -18
- package/foundation/fs/paths.d.mts +41 -2
- package/foundation/fs/paths.mjs +95 -5
- package/foundation/fs/read-record.d.mts +84 -7
- package/foundation/fs/read-record.mjs +333 -56
- package/foundation/fs/regular-file.d.mts +29 -0
- package/foundation/fs/regular-file.mjs +77 -0
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/fs/stylesheet-file.d.mts +37 -0
- package/foundation/fs/stylesheet-file.mjs +48 -0
- package/foundation/fs/theme-module-rejections.d.mts +32 -0
- package/foundation/fs/theme-module-rejections.mjs +82 -0
- package/foundation/integrations/integrations.d.mts +27 -1
- package/foundation/integrations/integrations.mjs +24 -2
- package/foundation/integrations/pack-state.d.mts +85 -0
- package/foundation/integrations/pack-state.mjs +509 -0
- package/foundation/integrations/shipped-imports.d.mts +125 -0
- package/foundation/integrations/shipped-imports.mjs +530 -0
- package/foundation/integrations/validate-contributions.d.mts +0 -17
- package/foundation/integrations/validate-contributions.mjs +81 -290
- package/foundation/release/choose.d.mts +7 -0
- package/foundation/release/choose.mjs +16 -2
- package/foundation/release/handoff.mjs +68 -13
- package/foundation/release/notices.d.mts +46 -9
- package/foundation/release/notices.mjs +78 -20
- package/foundation/release/pnp-runtime.d.mts +66 -0
- package/foundation/release/pnp-runtime.mjs +139 -0
- package/foundation/release/project.d.mts +11 -0
- package/foundation/release/project.mjs +23 -7
- package/foundation/release/run-context.d.mts +7 -2
- package/foundation/release/run-context.mjs +6 -2
- package/foundation/render/assets.mjs +52 -7
- package/foundation/render/charts.d.mts +78 -27
- package/foundation/render/charts.mjs +319 -90
- package/foundation/render/css-cut.d.mts +14 -1
- package/foundation/render/css-cut.mjs +117 -4
- package/foundation/render/cut-short.d.mts +35 -0
- package/foundation/render/cut-short.mjs +124 -0
- package/foundation/render/embedded-imports.d.mts +31 -0
- package/foundation/render/embedded-imports.mjs +169 -39
- package/foundation/render/font-probe.d.mts +27 -0
- package/foundation/render/font-probe.mjs +77 -0
- package/foundation/render/layers.d.mts +49 -0
- package/foundation/render/layers.mjs +347 -0
- package/foundation/render/offline.d.mts +32 -0
- package/foundation/render/offline.mjs +56 -0
- package/foundation/render/page-worker.mjs +374 -15
- package/foundation/render/picture-chrome.mjs +46 -4
- package/foundation/render/picture-playwright.mjs +41 -5
- package/foundation/render/picture-window.d.mts +32 -0
- package/foundation/render/picture-window.mjs +146 -0
- package/foundation/render/render-page.d.mts +46 -4
- package/foundation/render/render-page.mjs +453 -98
- 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 +12 -12
- package/foundation/runtime/css-tree.d.mts +24 -0
- package/foundation/runtime/css-tree.mjs +103 -0
- package/foundation/runtime/lazy-dependencies.d.mts +3 -1
- package/foundation/runtime/lazy-dependencies.mjs +20 -5
- package/foundation/suggest/name-index.d.mts +149 -0
- package/foundation/suggest/name-index.mjs +317 -0
- package/foundation/suggest/other-command.d.mts +146 -0
- package/foundation/suggest/other-command.mjs +783 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/entry-names.d.mts +14 -0
- package/foundation/text/entry-names.mjs +14 -0
- package/foundation/text/string-utils.d.mts +49 -5
- package/foundation/text/string-utils.mjs +124 -26
- package/foundation/text/suggest-order.d.mts +75 -4
- package/foundation/text/suggest-order.mjs +285 -9
- package/foundation/text/written-string.d.mts +17 -0
- package/foundation/text/written-string.mjs +22 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +8 -7
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
FONT_ROLES,
|
|
30
30
|
FONTS,
|
|
31
31
|
OPEN_FONTS,
|
|
32
|
+
appleFaceGeneric,
|
|
32
33
|
isDesktopFamily,
|
|
33
34
|
oneSystemOf,
|
|
34
35
|
P,
|
|
@@ -38,27 +39,53 @@ import {makeCompiler} from './_compiler.mjs';
|
|
|
38
39
|
import {openProject, installLine} from './_project.mjs';
|
|
39
40
|
import {partData} from './_parts.mjs';
|
|
40
41
|
import {writeWhole} from './_palette.mjs';
|
|
42
|
+
import {
|
|
43
|
+
assetRef,
|
|
44
|
+
CSS_URL,
|
|
45
|
+
cssUrlRef,
|
|
46
|
+
} from '../../foundation/render/render-page.mjs';
|
|
47
|
+
import {MAX_ASSET_BYTES} from '../../foundation/render/assets.mjs';
|
|
48
|
+
import {typoNear} from './_normal.mjs';
|
|
41
49
|
import {
|
|
42
50
|
fontOf,
|
|
51
|
+
ownTokenEntries,
|
|
43
52
|
builtFontFamilies,
|
|
53
|
+
builtFontWeights,
|
|
44
54
|
fontPackages,
|
|
45
|
-
|
|
55
|
+
fontsourceSuggestion,
|
|
46
56
|
modesOf,
|
|
47
|
-
nearest,
|
|
48
57
|
refuse,
|
|
49
58
|
editorWrote,
|
|
50
59
|
recordWritten,
|
|
51
60
|
themeFiles,
|
|
52
61
|
refuseThemesNotFolder,
|
|
53
62
|
shown,
|
|
63
|
+
OPEN_SECTION,
|
|
54
64
|
} from './_settings.mjs';
|
|
55
65
|
import {
|
|
56
66
|
SHOWCASE_GROUPS,
|
|
67
|
+
copyFontsCss,
|
|
68
|
+
fontPackageSheets,
|
|
69
|
+
fontPackageWeights,
|
|
70
|
+
shownWeight,
|
|
71
|
+
baseFontsSheet,
|
|
57
72
|
newPictureRun,
|
|
58
73
|
renderPreview,
|
|
74
|
+
renderSheet,
|
|
59
75
|
screenshot,
|
|
76
|
+
pageInTheWay,
|
|
77
|
+
inTheWayPhrase,
|
|
60
78
|
} from './_preview.mjs';
|
|
61
79
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
80
|
+
import {
|
|
81
|
+
customPropertyValues,
|
|
82
|
+
fontKey,
|
|
83
|
+
importedFontFamilies,
|
|
84
|
+
} from '../../foundation/fonts/font-stylesheet.mjs';
|
|
85
|
+
import {
|
|
86
|
+
hasGenericFamily,
|
|
87
|
+
namedFontFamilies,
|
|
88
|
+
} from '../theme/build/font-warning.mjs';
|
|
62
89
|
|
|
63
90
|
const E = ERROR_CODES;
|
|
64
91
|
|
|
@@ -117,7 +144,7 @@ export async function context(cwd) {
|
|
|
117
144
|
unchecked = renderCause(project, /** @type {Error} */ (e).message);
|
|
118
145
|
uncheckedCode = /** @type {any} */ (e).code ?? null;
|
|
119
146
|
parts = {
|
|
120
|
-
|
|
147
|
+
censusKey: '',
|
|
121
148
|
coreKey: project.coreKey,
|
|
122
149
|
map: {},
|
|
123
150
|
pairs: [],
|
|
@@ -132,6 +159,12 @@ export async function context(cwd) {
|
|
|
132
159
|
unchecked,
|
|
133
160
|
uncheckedCode,
|
|
134
161
|
derived: await derivedVars(project.coreDir),
|
|
162
|
+
/**
|
|
163
|
+
* The pictures the running command takes after its build (its --png),
|
|
164
|
+
* so the build names as removed only the ones it does not take again.
|
|
165
|
+
* @type {{sheet: string | null} | null}
|
|
166
|
+
*/
|
|
167
|
+
takesPictures: null,
|
|
135
168
|
};
|
|
136
169
|
}
|
|
137
170
|
|
|
@@ -156,7 +189,8 @@ async function derivedVars(coreDir) {
|
|
|
156
189
|
const isRenderFailure = e =>
|
|
157
190
|
e instanceof AstryxError &&
|
|
158
191
|
(e.code === E.ERR_RENDER_FAILED ||
|
|
159
|
-
e.code === E.ERR_RENDER_MISSING_DEPENDENCY
|
|
192
|
+
e.code === E.ERR_RENDER_MISSING_DEPENDENCY ||
|
|
193
|
+
e.code === E.ERR_RENDER_ASSET_TOO_LARGE);
|
|
160
194
|
|
|
161
195
|
/**
|
|
162
196
|
* The app a folder belongs to: the nearest folder at or above it whose
|
|
@@ -346,6 +380,19 @@ function usesCore(/** @type {any} */ json) {
|
|
|
346
380
|
* @param {string} message
|
|
347
381
|
*/
|
|
348
382
|
export function renderCause(project, message) {
|
|
383
|
+
const two = reactCopies(project);
|
|
384
|
+
return two
|
|
385
|
+
? `${message} The likely cause: two copies of React, the app's (${two.app}) and the one Core resolves (${two.core}). Make Core resolve the app's React.`
|
|
386
|
+
: message;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The two copies of React a render saw, when the app's and the one Core
|
|
391
|
+
* resolves differ; else null.
|
|
392
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
393
|
+
* @returns {{app: string, core: string} | null}
|
|
394
|
+
*/
|
|
395
|
+
export function reactCopies(project) {
|
|
349
396
|
/** @param {(id: string) => string} resolve */
|
|
350
397
|
const reactOf = resolve => {
|
|
351
398
|
try {
|
|
@@ -369,9 +416,7 @@ export function renderCause(project, message) {
|
|
|
369
416
|
} catch {
|
|
370
417
|
// No Core package file: nothing to compare.
|
|
371
418
|
}
|
|
372
|
-
return app && core && app !== core
|
|
373
|
-
? `${message} The likely cause: two copies of React, the app's (${app}) and the one Core resolves (${core}). Make Core resolve the app's React.`
|
|
374
|
-
: message;
|
|
419
|
+
return app && core && app !== core ? {app, core} : null;
|
|
375
420
|
}
|
|
376
421
|
|
|
377
422
|
/**
|
|
@@ -381,16 +426,99 @@ export function renderCause(project, message) {
|
|
|
381
426
|
const notChecked = cause =>
|
|
382
427
|
cause ? {code: E.ERR_THEME_NOT_CHECKED, cause} : null;
|
|
383
428
|
|
|
429
|
+
/** The sample page, as a note about its pictures names it. */
|
|
430
|
+
export const SAMPLE_PAGE_NAME = 'the sample page';
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Text one page's pictures draw cut short in one part, as the browser
|
|
434
|
+
* measured it: the page and its picture, the part (null when the text sits
|
|
435
|
+
* in none), its texts, the one mode it was cut in when only one was, and
|
|
436
|
+
* whether every text is drawn whole once the part keeps its width
|
|
437
|
+
* (`flex-shrink: 0`, applied in the page and measured).
|
|
438
|
+
* @typedef {{page: string, file: string, part: string | null, texts: string[], only: 'light' | 'dark' | null, whole: boolean}} CutShort
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
/** The texts named, the first six and how many more. @param {string[]} texts */
|
|
442
|
+
const someTexts = texts =>
|
|
443
|
+
`${texts
|
|
444
|
+
.slice(0, 6)
|
|
445
|
+
.map(t => JSON.stringify(t))
|
|
446
|
+
.join(', ')}${texts.length > 6 ? `, and ${texts.length - 6} more` : ''}`;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* The note for text a page's pictures draw cut short.
|
|
450
|
+
* @param {CutShort} c
|
|
451
|
+
*/
|
|
452
|
+
export function cutShortNote(c) {
|
|
453
|
+
const n = c.texts.length;
|
|
454
|
+
const what = c.part
|
|
455
|
+
? `${c.part} label${n === 1 ? '' : 's'}`
|
|
456
|
+
: `text${n === 1 ? '' : 's'}`;
|
|
457
|
+
return `${c.page} (${c.file}) draws ${n} ${what} cut short${c.only ? ` in ${c.only} mode only` : ''} (${someTexts(c.texts)}); the text no longer fits ${c.part ? `the ${c.part}` : 'its box'}`;
|
|
458
|
+
}
|
|
459
|
+
|
|
384
460
|
/**
|
|
385
|
-
*
|
|
461
|
+
* The problem for text a page's pictures draw cut short, with the line that
|
|
462
|
+
* keeps it whole: the part keeps its width (`flex-shrink 0` on it), offered
|
|
463
|
+
* only when the browser measured every text whole with it; else no line,
|
|
464
|
+
* and that the line was measured and does not.
|
|
465
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
466
|
+
* @param {string} slug
|
|
467
|
+
* @param {CutShort} c
|
|
468
|
+
* @returns {{problem: string, fix: string | null}}
|
|
469
|
+
*/
|
|
470
|
+
export function cutShortProblem(ctx, slug, c) {
|
|
471
|
+
const label = c.part ? `${c.part} labels` : 'text';
|
|
472
|
+
const problem = `${label} cut short in ${c.page}'s pictures (${c.file}${c.only ? `, ${c.only} mode` : ''}): ${someTexts(c.texts)}`;
|
|
473
|
+
if (c.part && c.whole && ctx.project.target.has(c.part))
|
|
474
|
+
return {problem, fix: `${P} set ${slug} flex-shrink 0 --on ${c.part}`};
|
|
475
|
+
return {
|
|
476
|
+
problem: c.part
|
|
477
|
+
? `${problem}; keeping the ${c.part}'s width (flex-shrink 0) was measured and does not draw them whole there, so no one line fixes it`
|
|
478
|
+
: problem,
|
|
479
|
+
fix: null,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Pictures of HTML files, on request. A shot with a `name` is a page laid
|
|
485
|
+
* out so its text fits in the base theme (the sample page): the text its
|
|
486
|
+
* pictures draw cut short, as the browser measured it, comes back in
|
|
487
|
+
* `cutShort`, one entry for each part on each page ({@link cutShortNote},
|
|
488
|
+
* {@link cutShortProblem}). The sheets (the open
|
|
489
|
+
* states among them) have no name: their cells are narrow, and the full
|
|
490
|
+
* sheet cuts long labels short in every theme.
|
|
386
491
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
387
|
-
* @param {Array<{html: string, png: string}>} shots
|
|
492
|
+
* @param {Array<{html: string, png: string, name?: string}>} shots
|
|
388
493
|
* @param {Array<'light' | 'dark'>} modes
|
|
389
|
-
* @returns {Promise<{files: string[], problem: string | null}>}
|
|
494
|
+
* @returns {Promise<{files: string[], problem: string | null, cutShort: CutShort[]}>}
|
|
390
495
|
*/
|
|
391
496
|
export async function pictures(project, shots, modes) {
|
|
392
497
|
/** @type {string[]} */
|
|
393
498
|
const files = [];
|
|
499
|
+
/**
|
|
500
|
+
* The text drawn cut short, by page, then by part: its texts, the modes
|
|
501
|
+
* it was drawn so in, whether keeping the part's width draws every one
|
|
502
|
+
* whole, and the page's picture.
|
|
503
|
+
* @type {Map<string, {file: string, parts: Map<string, {texts: Set<string>, modes: Set<'light' | 'dark'>, whole: boolean}>}>}
|
|
504
|
+
*/
|
|
505
|
+
const cut = new Map();
|
|
506
|
+
/** One entry for each part on each page, from what was measured. */
|
|
507
|
+
const cutShortNotes = () =>
|
|
508
|
+
[...cut].flatMap(([name, page]) =>
|
|
509
|
+
[...page.parts].map(
|
|
510
|
+
([part, {texts, modes: drawnIn, whole}]) =>
|
|
511
|
+
/** @type {CutShort} */ ({
|
|
512
|
+
page: name,
|
|
513
|
+
file: page.file,
|
|
514
|
+
part: part || null,
|
|
515
|
+
texts: [...texts],
|
|
516
|
+
only:
|
|
517
|
+
modes.length > 1 && drawnIn.size === 1 ? [...drawnIn][0] : null,
|
|
518
|
+
whole,
|
|
519
|
+
}),
|
|
520
|
+
),
|
|
521
|
+
);
|
|
394
522
|
/** What a later browser's success says of an earlier one. @type {string[]} */
|
|
395
523
|
const notes = [];
|
|
396
524
|
/** One run for every picture: a browser that failed is not tried again. */
|
|
@@ -406,27 +534,62 @@ export async function pictures(project, shots, modes) {
|
|
|
406
534
|
? slug
|
|
407
535
|
: null;
|
|
408
536
|
};
|
|
537
|
+
/** A link at a path, whether or not what it points to is there. @param {string} p */
|
|
538
|
+
const isLink = p => {
|
|
539
|
+
try {
|
|
540
|
+
return Boolean(
|
|
541
|
+
fs.lstatSync(p, {throwIfNoEntry: false})?.isSymbolicLink(),
|
|
542
|
+
);
|
|
543
|
+
} catch {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
};
|
|
409
547
|
// A picture is written only over a picture the editor took, unchanged
|
|
410
548
|
// since: a file of the user's by that name (a screenshot of the same
|
|
411
|
-
// size included) blocks every picture, and is named.
|
|
549
|
+
// size included) blocks every picture, and is named. A link at a
|
|
550
|
+
// picture's name (to a file or to nothing) is never written through or
|
|
551
|
+
// replaced: that one picture is skipped and named, the others are taken.
|
|
412
552
|
const blocked = shots
|
|
413
553
|
.flatMap(({png}) => modes.map(m => outOf(png, m)))
|
|
414
554
|
.filter(out => {
|
|
415
555
|
const slug = themeOf(out);
|
|
416
556
|
return (
|
|
417
557
|
Boolean(slug) &&
|
|
558
|
+
!isLink(out) &&
|
|
418
559
|
fs.existsSync(out) &&
|
|
419
560
|
!editorWrote(project.cwd, /** @type {string} */ (slug), out)
|
|
420
561
|
);
|
|
421
562
|
});
|
|
563
|
+
// The record of the editor's pictures is a plain file, or none yet.
|
|
564
|
+
// Something else at its name (a pipe, a folder) is left as it is and
|
|
565
|
+
// named, and no picture is taken: a picture the record cannot hold would
|
|
566
|
+
// read as a file of yours on the next run.
|
|
567
|
+
for (const slug of new Set(shots.map(s => themeOf(s.png)))) {
|
|
568
|
+
if (!slug) continue;
|
|
569
|
+
const record = themeFiles(project.cwd, slug).pictures;
|
|
570
|
+
const st = fs.lstatSync(record, {throwIfNoEntry: false});
|
|
571
|
+
if (st && !st.isFile())
|
|
572
|
+
return {
|
|
573
|
+
files,
|
|
574
|
+
cutShort: [],
|
|
575
|
+
problem: `${inTheWayPhrase(path.relative(project.cwd, record), st.isSymbolicLink() ? 'link' : st.isDirectory() ? 'folder' : 'other', "the record of the editor's pictures")}, so no picture was taken and it is left as it is; move ${st.isSymbolicLink() ? 'the link' : 'it'}, then run the command again`,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
/** Pictures skipped for a link at their name. @type {string[]} */
|
|
579
|
+
const linked = [];
|
|
422
580
|
if (blocked.length)
|
|
423
581
|
return {
|
|
424
582
|
files,
|
|
583
|
+
cutShort: [],
|
|
425
584
|
problem: `${blocked.map(f => path.relative(project.cwd, f)).join(', ')} ${blocked.length === 1 ? 'is a file' : 'are files'} the editor did not write (or changed since it did), so no picture was taken and ${blocked.length === 1 ? 'it is' : 'they are'} left as ${blocked.length === 1 ? 'it is' : 'they are'}`,
|
|
426
585
|
};
|
|
427
|
-
for (const {html, png} of shots) {
|
|
586
|
+
for (const {html, png, name} of shots) {
|
|
428
587
|
for (const m of modes) {
|
|
429
588
|
const out = outOf(png, m);
|
|
589
|
+
if (isLink(out)) {
|
|
590
|
+
linked.push(out);
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
430
593
|
// Taken under a name of its own and moved into place once whole: a
|
|
431
594
|
// run stopped while the browser runs leaves no picture at the real
|
|
432
595
|
// name (one the next run would read as a file of yours). A part left
|
|
@@ -452,6 +615,7 @@ export async function pictures(project, shots, modes) {
|
|
|
452
615
|
if (fs.existsSync(part) && !fs.lstatSync(part).isFile())
|
|
453
616
|
return {
|
|
454
617
|
files,
|
|
618
|
+
cutShort: cutShortNotes(),
|
|
455
619
|
problem: `${path.relative(project.cwd, part)} is a folder, where --png writes a picture before moving it into place, so no picture was taken; move it out of ${path.relative(project.cwd, path.dirname(out))}/`,
|
|
456
620
|
};
|
|
457
621
|
// A folder it cannot write gets no picture: named before the browser
|
|
@@ -461,13 +625,26 @@ export async function pictures(project, shots, modes) {
|
|
|
461
625
|
} catch (e) {
|
|
462
626
|
return {
|
|
463
627
|
files,
|
|
628
|
+
cutShort: cutShortNotes(),
|
|
464
629
|
problem: `${path.relative(project.cwd, path.dirname(out))}/ cannot be written (${/** @type {any} */ (e)?.code ?? 'no access'}), so no picture was taken; fix its permissions, then run the command again`,
|
|
465
630
|
};
|
|
466
631
|
}
|
|
467
632
|
const r = await screenshot(project, html, part, m, run);
|
|
468
633
|
if (!r.ok) {
|
|
469
634
|
fs.rmSync(part, {force: true});
|
|
470
|
-
|
|
635
|
+
// Said for the whole run: the pictures taken before this one stand,
|
|
636
|
+
// and this one and every one after it were not taken.
|
|
637
|
+
const all = shots.flatMap(s => modes.map(mm => outOf(s.png, mm)));
|
|
638
|
+
const missed = all
|
|
639
|
+
.slice(all.indexOf(out))
|
|
640
|
+
.map(f => path.relative(project.cwd, f).split(path.sep).join('/'));
|
|
641
|
+
return {
|
|
642
|
+
files,
|
|
643
|
+
cutShort: cutShortNotes(),
|
|
644
|
+
problem: files.length
|
|
645
|
+
? `${files.join(', ')} ${files.length === 1 ? 'was' : 'were'} taken, but ${missed.join(', ')} ${missed.length === 1 ? 'was' : 'were'} not: ${r.reason}`
|
|
646
|
+
: `No picture was taken: ${r.reason}`,
|
|
647
|
+
};
|
|
471
648
|
}
|
|
472
649
|
try {
|
|
473
650
|
fs.renameSync(part, out);
|
|
@@ -475,6 +652,7 @@ export async function pictures(project, shots, modes) {
|
|
|
475
652
|
fs.rmSync(part, {force: true});
|
|
476
653
|
return {
|
|
477
654
|
files,
|
|
655
|
+
cutShort: cutShortNotes(),
|
|
478
656
|
problem: `the picture could not be moved into ${path.relative(project.cwd, out)} (${/** @type {any} */ (e)?.code ?? e})`,
|
|
479
657
|
};
|
|
480
658
|
}
|
|
@@ -495,16 +673,140 @@ export async function pictures(project, shots, modes) {
|
|
|
495
673
|
}
|
|
496
674
|
recordWritten(project.cwd, slug, [out]);
|
|
497
675
|
}
|
|
498
|
-
|
|
676
|
+
for (const n of r.notes ?? []) if (!notes.includes(n)) notes.push(n);
|
|
677
|
+
// What the browser measured on a page laid out to fit, kept by page
|
|
678
|
+
// and part; nothing when its script measured nothing.
|
|
679
|
+
if (name && r.cutShort?.length) {
|
|
680
|
+
const page = cut.get(name) ?? {file: r.file, parts: new Map()};
|
|
681
|
+
cut.set(name, page);
|
|
682
|
+
for (const {part, text, whole} of r.cutShort) {
|
|
683
|
+
const at = page.parts.get(part ?? '') ?? {
|
|
684
|
+
texts: new Set(),
|
|
685
|
+
modes: new Set(),
|
|
686
|
+
whole: true,
|
|
687
|
+
};
|
|
688
|
+
page.parts.set(part ?? '', at);
|
|
689
|
+
at.texts.add(text);
|
|
690
|
+
at.modes.add(m);
|
|
691
|
+
at.whole &&= whole;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
499
694
|
}
|
|
500
695
|
}
|
|
696
|
+
if (linked.length) {
|
|
697
|
+
const rels = linked.map(f =>
|
|
698
|
+
path.relative(project.cwd, f).split(path.sep).join('/'),
|
|
699
|
+
);
|
|
700
|
+
const target = (/** @type {string} */ f) => {
|
|
701
|
+
try {
|
|
702
|
+
const to = fs.readlinkSync(f);
|
|
703
|
+
return fs.existsSync(f)
|
|
704
|
+
? ` (to ${to})`
|
|
705
|
+
: ` (to ${to}, which does not exist)`;
|
|
706
|
+
} catch {
|
|
707
|
+
return '';
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
notes.unshift(
|
|
711
|
+
`${linked.map((f, i) => `${rels[i]}${target(f)}`).join(', ')} ${linked.length === 1 ? 'is a link' : 'are links'}, and a picture is never written through or over a link, so ${linked.length === 1 ? 'that picture was' : 'those pictures were'} not taken${files.length ? `; ${files.join(', ')} ${files.length === 1 ? 'was' : 'were'} taken` : ''}`,
|
|
712
|
+
);
|
|
713
|
+
}
|
|
501
714
|
return {
|
|
502
715
|
files,
|
|
503
|
-
// Pictures were taken; a note says why an earlier browser did not
|
|
716
|
+
// Pictures were taken; a note says why an earlier browser did not, and
|
|
717
|
+
// which pictures a link at their name kept out.
|
|
504
718
|
problem: notes.join('; ') || null,
|
|
719
|
+
cutShort: cutShortNotes(),
|
|
505
720
|
};
|
|
506
721
|
}
|
|
507
722
|
|
|
723
|
+
/**
|
|
724
|
+
* The families the theme's build writes that no package loads: not a
|
|
725
|
+
* system or desktop font, not loaded by a font stylesheet the app copy
|
|
726
|
+
* imports (the base's fonts included), and none of `packages` (the font
|
|
727
|
+
* packages that load it where the fonts go: the project's, or a new app's).
|
|
728
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
729
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
730
|
+
* @param {Array<{family: string}>} packages
|
|
731
|
+
* @returns {string[]}
|
|
732
|
+
*/
|
|
733
|
+
export function familiesNothingLoads(ctx, data, packages) {
|
|
734
|
+
const built = builtFontFamilies(ctx, data.name);
|
|
735
|
+
/** @type {Set<string>} */
|
|
736
|
+
const loaded = new Set();
|
|
737
|
+
for (const spec of copyFontsCss(ctx, data.name, data))
|
|
738
|
+
for (const f of importedFontFamilies(spec, ctx.project.cwd)) loaded.add(f);
|
|
739
|
+
return [...(built?.values() ?? [])].filter(family => {
|
|
740
|
+
const key = fontKey(family);
|
|
741
|
+
return !(
|
|
742
|
+
loaded.has(key) ||
|
|
743
|
+
packages.some(x => fontKey(x.family) === key) ||
|
|
744
|
+
isDesktopFamily(family) ||
|
|
745
|
+
oneSystemOf(family) ||
|
|
746
|
+
appleFaceGeneric(family)
|
|
747
|
+
);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* What the previews (preview.html, sheet.html and their pictures) cannot
|
|
753
|
+
* show of the images and files the theme's built stylesheet names: a
|
|
754
|
+
* remote file (a page opened from disk loads no network), a file that is
|
|
755
|
+
* not there, one that is not a regular file, and one too large to carry.
|
|
756
|
+
* Read from the built stylesheet with the renderer's own reader, so a
|
|
757
|
+
* preview rendered before says it too.
|
|
758
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
759
|
+
* @param {string} slug
|
|
760
|
+
* @returns {string[]}
|
|
761
|
+
*/
|
|
762
|
+
export function themeImageNotes(ctx, slug) {
|
|
763
|
+
const file = themeFiles(ctx.project.cwd, slug).css;
|
|
764
|
+
/** @type {string} */
|
|
765
|
+
let css;
|
|
766
|
+
try {
|
|
767
|
+
css = fs.readFileSync(file, 'utf8');
|
|
768
|
+
} catch {
|
|
769
|
+
return [];
|
|
770
|
+
}
|
|
771
|
+
const at = {dir: path.dirname(file), root: ctx.project.cwd};
|
|
772
|
+
const where = shown(ctx.project.cwd, at.dir);
|
|
773
|
+
/** @type {Map<string, string>} */
|
|
774
|
+
const notes = new Map();
|
|
775
|
+
for (const m of css.matchAll(new RegExp(CSS_URL.source, 'g'))) {
|
|
776
|
+
const named = assetRef(cssUrlRef(m), at);
|
|
777
|
+
if (!named || notes.has(named.ref)) continue;
|
|
778
|
+
if (named.kind === 'remote')
|
|
779
|
+
notes.set(
|
|
780
|
+
named.ref,
|
|
781
|
+
`${named.ref} is loaded from the network: the app loads it, but the previews (preview.html, sheet.html and their pictures) cannot, and show the theme without it.`,
|
|
782
|
+
);
|
|
783
|
+
else if (named.kind === 'missing')
|
|
784
|
+
notes.set(
|
|
785
|
+
named.ref,
|
|
786
|
+
`${named.ref} was not found beside the theme (${where}/), so neither the previews nor the app show it.`,
|
|
787
|
+
);
|
|
788
|
+
else if (named.kind === 'not-file')
|
|
789
|
+
notes.set(
|
|
790
|
+
named.ref,
|
|
791
|
+
`${named.ref} is not a regular file (a pipe, a device or a folder), so the previews do not read it and show the theme without it.`,
|
|
792
|
+
);
|
|
793
|
+
else if (named.kind === 'unreadable')
|
|
794
|
+
notes.set(
|
|
795
|
+
named.ref,
|
|
796
|
+
`${shown(ctx.project.cwd, named.file)} cannot be read (no permission), so the previews show the theme without it; make it readable (chmod u+r) to show it.`,
|
|
797
|
+
);
|
|
798
|
+
else {
|
|
799
|
+
const bytes = fs.statSync(named.file).size;
|
|
800
|
+
if (bytes > MAX_ASSET_BYTES)
|
|
801
|
+
notes.set(
|
|
802
|
+
named.ref,
|
|
803
|
+
`${shown(ctx.project.cwd, named.file)} is ${(bytes / 1048576).toFixed(1)} MB, more than the ${MAX_ASSET_BYTES / 1048576} MB a preview page carries per file; a smaller copy shows in the previews too.`,
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return [...notes.values()];
|
|
808
|
+
}
|
|
809
|
+
|
|
508
810
|
/**
|
|
509
811
|
* Font notes for the families the theme builds: the import line for an
|
|
510
812
|
* open font, the install line when its package is missing, and a warning
|
|
@@ -517,6 +819,13 @@ export function fontNotes(ctx, data) {
|
|
|
517
819
|
/** @type {string[]} */
|
|
518
820
|
const notes = [];
|
|
519
821
|
const packages = fontPackages(ctx, data);
|
|
822
|
+
// A family nothing loads, with the Fontsource package that would load
|
|
823
|
+
// it, when Fontsource's naming gives one.
|
|
824
|
+
/** @param {string} family */
|
|
825
|
+
const unloadedNote = family => {
|
|
826
|
+
const s = fontsourceSuggestion(family);
|
|
827
|
+
return `"${family}" is not a system font and no package loads it: the app must load it, or it falls back.${s ? ` ${s.known ? '' : 'If Fontsource publishes it, '}${installLine(ctx.project.cwd, [s.pkg])} installs its package, which the previews and the app copy then load.` : ''}`;
|
|
828
|
+
};
|
|
520
829
|
for (const {pkg, family, installed} of packages) {
|
|
521
830
|
const fallbacks =
|
|
522
831
|
Object.values(OPEN_FONTS).find(f => f.pkg === pkg)?.fallbacks ?? '';
|
|
@@ -527,7 +836,13 @@ export function fontNotes(ctx, data) {
|
|
|
527
836
|
: 'system';
|
|
528
837
|
notes.push(
|
|
529
838
|
installed
|
|
530
|
-
? `${family} is installed (${pkg}), so the previews
|
|
839
|
+
? `${family} is installed (${pkg}), so the previews and the app copy load it, a stylesheet for each face the theme's weights show: ${fontPackageSheets(
|
|
840
|
+
ctx,
|
|
841
|
+
data.name,
|
|
842
|
+
pkg,
|
|
843
|
+
)
|
|
844
|
+
.map(x => `import '${x}';`)
|
|
845
|
+
.join(' ')}`
|
|
531
846
|
: `${family} is not installed, so it does not load: the previews and the app show the next font in the stack. Install it: ${installLine(ctx.project.cwd, [pkg])}. Then the preview imports it on the next set or show, and the app imports it once: import '${pkg}'; Until then, the closest font that needs no install is ${near}: ${P} set ${data.name} font ${near}`,
|
|
532
847
|
);
|
|
533
848
|
}
|
|
@@ -568,21 +883,182 @@ export function fontNotes(ctx, data) {
|
|
|
568
883
|
const named = fontOf(s.value).family.replace(/^["']|["']$/g, '');
|
|
569
884
|
const system = oneSystemOf(named);
|
|
570
885
|
const on = s.on ? ` --on ${s.on}` : '';
|
|
886
|
+
const generic = appleFaceGeneric(named);
|
|
887
|
+
if (generic) {
|
|
888
|
+
// Apple systems reach their interface faces only by a generic.
|
|
889
|
+
const {fallbacks} = fontOf(s.value);
|
|
890
|
+
const next = fallbacks.split(',')[0]?.trim() || 'system-ui';
|
|
891
|
+
// The generic once: a stack that already holds it keeps one.
|
|
892
|
+
const value = [
|
|
893
|
+
...new Set(
|
|
894
|
+
[generic, ...fallbacks.split(',')].map(f => f.trim()).filter(Boolean),
|
|
895
|
+
),
|
|
896
|
+
].join(', ');
|
|
897
|
+
notes.push(
|
|
898
|
+
`"${named}" is an Apple interface face, which browsers do not reach by its name, so every system shows the next font in the stack (${next}). Apple systems show it for ${generic}: ${P} set ${data.name} font ${quoteCommandArgument(value)}${on}`,
|
|
899
|
+
);
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
571
902
|
if (system) {
|
|
572
903
|
// A system font, on one system: the others show the next font.
|
|
573
904
|
const next =
|
|
574
905
|
fontOf(s.value).fallbacks.split(',')[0]?.trim() || 'system-ui';
|
|
575
906
|
notes.push(
|
|
576
907
|
/^(-apple-system|blinkmacsystemfont)$/.test(family)
|
|
577
|
-
? `"${named}" names the
|
|
908
|
+
? `"${named}" names the interface font of ${system}, and only there: other systems show the next font in the stack (${next}). The system preset gives each system its own interface font: ${P} set ${data.name} font system${on}`
|
|
578
909
|
: `"${named}" ships only on ${system}: other systems show the next font in the stack (${next}).${near ? ` The closest open font, which loads everywhere, is ${near}: ${P} set ${data.name} font ${near}${on}` : ''}`,
|
|
579
910
|
);
|
|
580
911
|
continue;
|
|
581
912
|
}
|
|
582
913
|
notes.push(
|
|
583
|
-
|
|
914
|
+
`${unloadedNote(named)}${near ? ` The closest open font is ${near}: ${P} set ${data.name} font ${near}${s.on ? ` --on ${s.on}` : ''}` : ''}`,
|
|
584
915
|
);
|
|
585
916
|
}
|
|
917
|
+
// Every other family the build writes that nothing loads (a part's own
|
|
918
|
+
// font, a font token, a family the theme's own source sets) is named
|
|
919
|
+
// once, with the package that would load it: the same built families
|
|
920
|
+
// the app copy and the previews load fonts for.
|
|
921
|
+
const dialFamilies = new Set(
|
|
922
|
+
data.settings
|
|
923
|
+
.filter(s => s.thing === 'font')
|
|
924
|
+
.map(s => fontKey(fontOf(s.value).family)),
|
|
925
|
+
);
|
|
926
|
+
// A base family the app loads from a remote stylesheet (a Google Fonts
|
|
927
|
+
// import in the base's fonts.css) is not in the static previews: a page
|
|
928
|
+
// opened from disk cannot load a remote stylesheet. Unless an installed
|
|
929
|
+
// package loads it, the previews and pictures show the next font.
|
|
930
|
+
const base = baseFontsSheet(ctx, data);
|
|
931
|
+
if (base?.remote.length)
|
|
932
|
+
for (const family of base.families) {
|
|
933
|
+
if (built && !built.has(family.toLowerCase())) continue;
|
|
934
|
+
if (
|
|
935
|
+
packages.some(x => x.installed && fontKey(x.family) === fontKey(family))
|
|
936
|
+
)
|
|
937
|
+
continue;
|
|
938
|
+
const s = fontsourceSuggestion(family);
|
|
939
|
+
notes.push(
|
|
940
|
+
`"${family}" comes from ${base.spec}, which loads it from ${new URL(base.remote[0], 'https://x').host}: the app shows it, but the previews (preview.html, sheet.html and their pictures) cannot load a remote stylesheet and show the next font in the stack.${s ? ` ${installLine(ctx.project.cwd, [s.pkg])} installs a copy the previews load too.` : ''}`,
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
notes.push(...baseWeightNotes(ctx, data));
|
|
944
|
+
for (const family of familiesNothingLoads(ctx, data, packages)) {
|
|
945
|
+
if (dialFamilies.has(fontKey(family))) continue;
|
|
946
|
+
notes.push(unloadedNote(family));
|
|
947
|
+
}
|
|
948
|
+
notes.push(...loneFamilyNotes(ctx, data));
|
|
949
|
+
return notes;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/** What each font role's family token sets, for a note. */
|
|
953
|
+
const ROLE_TEXT = /** @type {Record<string, string>} */ ({
|
|
954
|
+
body: 'body text uses',
|
|
955
|
+
heading: 'headings use',
|
|
956
|
+
code: 'code uses',
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* A note for each font role the theme's build gives one family and no
|
|
961
|
+
* fallback at all (`--font-family-heading: Lora`, as Core builds a heading
|
|
962
|
+
* family given no fallbacks of its own, or an exact token set so): text in
|
|
963
|
+
* it has no font while that one loads, or if it is missing. The way to a
|
|
964
|
+
* list is named where the family came from: the setting, run with a list
|
|
965
|
+
* (the family's own open-font fallbacks, else the font dial's), or the
|
|
966
|
+
* theme's own source.
|
|
967
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
968
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
969
|
+
* @returns {string[]}
|
|
970
|
+
*/
|
|
971
|
+
export function loneFamilyNotes(ctx, data) {
|
|
972
|
+
/** @type {string} */
|
|
973
|
+
let css;
|
|
974
|
+
try {
|
|
975
|
+
css = fs.readFileSync(themeFiles(ctx.project.cwd, data.name).css, 'utf8');
|
|
976
|
+
} catch {
|
|
977
|
+
return [];
|
|
978
|
+
}
|
|
979
|
+
/** @type {string[]} */
|
|
980
|
+
const notes = [];
|
|
981
|
+
const own = customPropertyValues(css);
|
|
982
|
+
for (const role of Object.keys(ROLE_TEXT)) {
|
|
983
|
+
const token = `--font-family-${role}`;
|
|
984
|
+
const value = own.get(token)?.at(-1);
|
|
985
|
+
if (!value || /var\(/i.test(value) || hasGenericFamily(value)) continue;
|
|
986
|
+
const named = namedFontFamilies(value);
|
|
987
|
+
if (named.length !== 1) continue;
|
|
988
|
+
const family = named[0].replace(/^["']|["']$/g, '');
|
|
989
|
+
const fallbacks =
|
|
990
|
+
Object.values(OPEN_FONTS).find(f => fontKey(f.family) === fontKey(family))
|
|
991
|
+
?.fallbacks ?? fontOf(family).fallbacks;
|
|
992
|
+
const list = `${value.trim()}, ${fallbacks}`;
|
|
993
|
+
const setting = data.settings.find(
|
|
994
|
+
s => s.source === 'token' && s.thing === token && !s.on && !s.when,
|
|
995
|
+
);
|
|
996
|
+
const typography = ownTokenEntries(ctx.project.cwd, data.name).some(
|
|
997
|
+
e => e.kind === 'typography' && e.key === `${role}.family`,
|
|
998
|
+
);
|
|
999
|
+
const fix = setting
|
|
1000
|
+
? `give a list: ${P} set ${data.name} ${token} ${quoteCommandArgument(list)}`
|
|
1001
|
+
: typography
|
|
1002
|
+
? `give typography.${role} its fallbacks in themes/${data.name}/${data.name}.theme.ts (such as fallbacks: '${fallbacks}')`
|
|
1003
|
+
: `give ${token} a list in themes/${data.name}/${data.name}.theme.ts (such as '${list}')`;
|
|
1004
|
+
notes.push(
|
|
1005
|
+
`${ROLE_TEXT[role]} only ${family}, with no fallback while it loads or if it is missing; to fall back, ${fix}`,
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
return notes;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* A note for each weight the theme uses that a stylesheet loading one of
|
|
1013
|
+
* its families has no face for (it shows as the face CSS font matching
|
|
1014
|
+
* picks): the base theme's font stylesheet, unless an installed package
|
|
1015
|
+
* loads that family, and each installed font package with a stylesheet per
|
|
1016
|
+
* weight.
|
|
1017
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
1018
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
1019
|
+
* @returns {string[]}
|
|
1020
|
+
*/
|
|
1021
|
+
export function baseWeightNotes(ctx, data) {
|
|
1022
|
+
/** @type {string[]} */
|
|
1023
|
+
const notes = [];
|
|
1024
|
+
const built = builtFontFamilies(ctx, data.name);
|
|
1025
|
+
const packages = fontPackages(ctx, data);
|
|
1026
|
+
/**
|
|
1027
|
+
* @param {string} family @param {string} by what loads it
|
|
1028
|
+
* @param {number[]} faces the weights it loads @param {string} fix
|
|
1029
|
+
*/
|
|
1030
|
+
const gap = (family, by, faces, fix) => {
|
|
1031
|
+
// The weights text in this family uses: those set beside it, and the
|
|
1032
|
+
// ones every text reads (never a weight only another family uses).
|
|
1033
|
+
const used = builtFontWeights(ctx, data.name, family) ?? [];
|
|
1034
|
+
const missing = used.filter(w => !faces.includes(w));
|
|
1035
|
+
if (missing.length)
|
|
1036
|
+
notes.push(
|
|
1037
|
+
`${family} is loaded by ${by} at ${faces.join(', ')} only, so ${missing.map(w => `${w} shows as ${shownWeight(w, faces)}`).join(', ')}${fix}`,
|
|
1038
|
+
);
|
|
1039
|
+
};
|
|
1040
|
+
const base = baseFontsSheet(ctx, data);
|
|
1041
|
+
for (const [family, faces] of base?.weights ?? []) {
|
|
1042
|
+
if (built && !built.has(family.toLowerCase())) continue;
|
|
1043
|
+
if (
|
|
1044
|
+
packages.some(x => x.installed && fontKey(x.family) === fontKey(family))
|
|
1045
|
+
)
|
|
1046
|
+
continue;
|
|
1047
|
+
const s = fontsourceSuggestion(family);
|
|
1048
|
+
gap(
|
|
1049
|
+
family,
|
|
1050
|
+
/** @type {{spec: string}} */ (base).spec,
|
|
1051
|
+
faces,
|
|
1052
|
+
s
|
|
1053
|
+
? `; ${installLine(ctx.project.cwd, [s.pkg])} loads every weight of it`
|
|
1054
|
+
: '',
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
for (const {pkg, family, installed} of packages) {
|
|
1058
|
+
if (!installed || (built && !built.has(family.toLowerCase()))) continue;
|
|
1059
|
+
const faces = fontPackageWeights(ctx, pkg);
|
|
1060
|
+
if (faces) gap(family, pkg, faces, '');
|
|
1061
|
+
}
|
|
586
1062
|
return notes;
|
|
587
1063
|
}
|
|
588
1064
|
|
|
@@ -633,21 +1109,37 @@ export function styledChanges(before, after, base) {
|
|
|
633
1109
|
typeof baseValue !== 'object' &&
|
|
634
1110
|
plain(baseValue) === plain(now);
|
|
635
1111
|
const where = `${target}${key === 'base' ? '' : ` ${key}`}`;
|
|
636
|
-
// A block (a state, `:hover
|
|
1112
|
+
// A block (a state, `:hover`, a mode block, a state inside a mode
|
|
1113
|
+
// block) lists each property it changes, under its path.
|
|
1114
|
+
/**
|
|
1115
|
+
* @param {string} path @param {any} xs @param {any} ys @param {any} shownIn
|
|
1116
|
+
*/
|
|
1117
|
+
const blockLines = (path, xs, ys, shownIn) => {
|
|
1118
|
+
for (const p of new Set([
|
|
1119
|
+
...Object.keys(xs ?? {}),
|
|
1120
|
+
...Object.keys(ys ?? {}),
|
|
1121
|
+
])) {
|
|
1122
|
+
const was = xs?.[p];
|
|
1123
|
+
const now = ys?.[p];
|
|
1124
|
+
if (JSON.stringify(was) === JSON.stringify(now)) continue;
|
|
1125
|
+
if (
|
|
1126
|
+
(now && typeof now === 'object') ||
|
|
1127
|
+
(was && typeof was === 'object')
|
|
1128
|
+
) {
|
|
1129
|
+
blockLines(`${path} ${p}`, was ?? {}, now ?? {}, shownIn?.[p]);
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (repeatsBase(was, now, shownIn?.[p])) continue;
|
|
1133
|
+
out.push(
|
|
1134
|
+
`${where} ${path}: ${cssName(p)} ${now === undefined ? '(removed)' : String(now)}`,
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
637
1138
|
if (
|
|
638
1139
|
(y[prop] && typeof y[prop] === 'object') ||
|
|
639
1140
|
(x[prop] && typeof x[prop] === 'object')
|
|
640
1141
|
) {
|
|
641
|
-
|
|
642
|
-
const ys = y[prop] ?? {};
|
|
643
|
-
for (const p of new Set([...Object.keys(xs), ...Object.keys(ys)]))
|
|
644
|
-
if (
|
|
645
|
-
JSON.stringify(xs[p]) !== JSON.stringify(ys[p]) &&
|
|
646
|
-
!repeatsBase(xs[p], ys[p], shown?.[p])
|
|
647
|
-
)
|
|
648
|
-
out.push(
|
|
649
|
-
`${where} ${prop}: ${cssName(p)} ${ys[p] === undefined ? '(removed)' : String(ys[p])}`,
|
|
650
|
-
);
|
|
1142
|
+
blockLines(prop, x[prop] ?? {}, y[prop] ?? {}, shown);
|
|
651
1143
|
continue;
|
|
652
1144
|
}
|
|
653
1145
|
if (repeatsBase(x[prop], y[prop], shown)) continue;
|
|
@@ -697,7 +1189,156 @@ export function styledChanges(before, after, base) {
|
|
|
697
1189
|
}
|
|
698
1190
|
|
|
699
1191
|
/**
|
|
700
|
-
*
|
|
1192
|
+
* The line that says which pictures to open after a run that took them:
|
|
1193
|
+
* each family of components' first ({@link familyPages}), then the sample
|
|
1194
|
+
* page's and the open states' (every menu, tooltip, popover and list drawn
|
|
1195
|
+
* open), of the mode shown first (light when the theme has both). Null when
|
|
1196
|
+
* this run took none of them.
|
|
1197
|
+
* @param {string[]} files the pictures taken, as shown (`themes/t/preview.png`)
|
|
1198
|
+
* @returns {string | null}
|
|
1199
|
+
*/
|
|
1200
|
+
export function lookAtPictures(files) {
|
|
1201
|
+
/** @param {string} name */
|
|
1202
|
+
const one = name =>
|
|
1203
|
+
files.find(f => path.basename(f) === `${name}.png`) ??
|
|
1204
|
+
files.find(f => path.basename(f) === `${name}-dark.png`);
|
|
1205
|
+
const preview = one('preview');
|
|
1206
|
+
const open = one(`sheet-${OPEN_SECTION}`);
|
|
1207
|
+
const families = FAMILY_SECTIONS.map(g => one(`sheet-${g}`)).filter(
|
|
1208
|
+
f => f != null,
|
|
1209
|
+
);
|
|
1210
|
+
if (!preview && !open && !families.length) return null;
|
|
1211
|
+
const dark =
|
|
1212
|
+
files.some(f => /-dark\.png$/.test(f)) &&
|
|
1213
|
+
files.some(f => /(?<!-dark)\.png$/.test(f));
|
|
1214
|
+
return `open ${[
|
|
1215
|
+
// A family's own picture reads whole; the full sheet does not.
|
|
1216
|
+
...(families.length
|
|
1217
|
+
? [`${families.join(', ')} (one family of components each)`]
|
|
1218
|
+
: []),
|
|
1219
|
+
...(preview
|
|
1220
|
+
? [
|
|
1221
|
+
`${preview} (the sample page, a tooltip, a menu and a list drawn open below it)`,
|
|
1222
|
+
]
|
|
1223
|
+
: []),
|
|
1224
|
+
...(open
|
|
1225
|
+
? [
|
|
1226
|
+
`${open} (each control at rest, hovered, focused and pressed at its top, then every menu, tooltip, popover and list, drawn open)`,
|
|
1227
|
+
]
|
|
1228
|
+
: []),
|
|
1229
|
+
].join(' and ')}${dark ? '; the -dark pictures show the dark mode' : ''}`;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* The page of the theme's open states (every menu, tooltip, popover and
|
|
1234
|
+
* list drawn open: the overlays section of the sheet), made and stamped
|
|
1235
|
+
* with the build it shows, and where its picture goes. The sample page
|
|
1236
|
+
* (preview.png) has no overlay open, and the full sheet is too tall to
|
|
1237
|
+
* read whole, so `--png` takes this picture beside the sample page's.
|
|
1238
|
+
* @param {import('./_settings.mjs').Ctx} ctx
|
|
1239
|
+
* @param {string} slug
|
|
1240
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
1241
|
+
* @returns {Promise<{html: string, png: string} | {problem: string}>} the
|
|
1242
|
+
* page and its picture, or why neither is made: something of yours at the
|
|
1243
|
+
* page's name (a file the editor did not write, a link, a folder) is never
|
|
1244
|
+
* written over, as a picture of yours is not
|
|
1245
|
+
*/
|
|
1246
|
+
export async function openStatesPage(ctx, slug, data) {
|
|
1247
|
+
const f = themeFiles(ctx.project.cwd, slug);
|
|
1248
|
+
const html = path.join(f.dir, `sheet-${OPEN_SECTION}.html`);
|
|
1249
|
+
const png = path.join(f.dir, `sheet-${OPEN_SECTION}.png`);
|
|
1250
|
+
const shownHtml = shown(ctx.project.cwd, html);
|
|
1251
|
+
const skipped = `so ${shown(ctx.project.cwd, png)} (the open states) was not taken`;
|
|
1252
|
+
const inWay = pageInTheWay(html);
|
|
1253
|
+
if (inWay)
|
|
1254
|
+
return {
|
|
1255
|
+
problem: `${inTheWayPhrase(shownHtml, inWay, 'the open states page')}, ${skipped}; move ${inWay === 'link' ? 'the link' : 'it'}, then run ${P} show ${slug} --png`,
|
|
1256
|
+
};
|
|
1257
|
+
await renderSheet(ctx, slug, data, {group: OPEN_SECTION});
|
|
1258
|
+
stampSheet(html, slug, ctx.project.cwd);
|
|
1259
|
+
return {html, png};
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* The family `show --png` pictures when the theme's settings set no part of
|
|
1264
|
+
* its own (a fresh theme, or only theme-wide settings): the buttons, an
|
|
1265
|
+
* overview of the theme's controls beside the sample page.
|
|
1266
|
+
*/
|
|
1267
|
+
export const FAMILY_OVERVIEW = 'actions';
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* The families of components with a picture of their own beside the full
|
|
1271
|
+
* sheet, which is too tall to read whole: each section of the sheet but the
|
|
1272
|
+
* overlays (the open states page shows them) and the pages (the sample page
|
|
1273
|
+
* is preview.png).
|
|
1274
|
+
*/
|
|
1275
|
+
export const FAMILY_SECTIONS = Object.freeze(
|
|
1276
|
+
SHOWCASE_GROUPS.filter(g => g !== OPEN_SECTION && g !== 'pages'),
|
|
1277
|
+
);
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* One page for each family of components ({@link FAMILY_SECTIONS}), cut
|
|
1281
|
+
* from the full sheet just made, so each shows its family as the sheet
|
|
1282
|
+
* does, with no render of its own: the sheet's head and bar, then that
|
|
1283
|
+
* family's section. Each is written where `show --section <family>` writes
|
|
1284
|
+
* that family's sheet, and stamped with the build it shows. Something of
|
|
1285
|
+
* yours at a family page's name is never written over: that page is left
|
|
1286
|
+
* out and named.
|
|
1287
|
+
* @param {string} sheet the full sheet, as written
|
|
1288
|
+
* @param {string} slug
|
|
1289
|
+
* @param {string} cwd
|
|
1290
|
+
* @param {readonly string[]} [only] the families to make; every one by default
|
|
1291
|
+
* @returns {{pages: Array<{html: string, png: string, family: string}>, problems: string[]}}
|
|
1292
|
+
*/
|
|
1293
|
+
export function familyPages(sheet, slug, cwd, only = FAMILY_SECTIONS) {
|
|
1294
|
+
/** @type {Array<{html: string, png: string, family: string}>} */
|
|
1295
|
+
const pages = [];
|
|
1296
|
+
/** @type {string[]} */
|
|
1297
|
+
const problems = [];
|
|
1298
|
+
const text = fs.readFileSync(sheet, 'utf8').replace(SHEET_STAMP, '');
|
|
1299
|
+
// Each section of the sheet starts with its own marker, in order, and
|
|
1300
|
+
// holds no section of its own: one ends where the next starts, and the
|
|
1301
|
+
// last at the last section close.
|
|
1302
|
+
const starts = [
|
|
1303
|
+
...text.matchAll(
|
|
1304
|
+
/<section\b[^>]*\sclass="[^"]*\bcs-family-([a-z-]+)\b[^"]*"[^>]*>/g,
|
|
1305
|
+
),
|
|
1306
|
+
].map(m => ({family: m[1], at: /** @type {number} */ (m.index)}));
|
|
1307
|
+
const close = text.lastIndexOf('</section>');
|
|
1308
|
+
if (!starts.length || close < 0) return {pages, problems};
|
|
1309
|
+
const end = close + '</section>'.length;
|
|
1310
|
+
const before = text.slice(0, starts[0].at);
|
|
1311
|
+
const after = text.slice(end);
|
|
1312
|
+
for (const [i, {family, at}] of starts.entries()) {
|
|
1313
|
+
if (!FAMILY_SECTIONS.includes(family) || !only.includes(family)) continue;
|
|
1314
|
+
const html = path.join(path.dirname(sheet), `sheet-${family}.html`);
|
|
1315
|
+
const png = path.join(path.dirname(sheet), `sheet-${family}.png`);
|
|
1316
|
+
const inWay = pageInTheWay(html);
|
|
1317
|
+
if (inWay) {
|
|
1318
|
+
problems.push(
|
|
1319
|
+
`${inTheWayPhrase(shown(cwd, html), inWay, `the ${family} sheet`)}, so ${shown(cwd, png)} was not taken; move ${inWay === 'link' ? 'the link' : 'it'}, then run ${P} show ${slug} --png`,
|
|
1320
|
+
);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
const head = before
|
|
1324
|
+
.replace('class="cs-page"', `class="cs-page cs-section-${family}"`)
|
|
1325
|
+
.replace(
|
|
1326
|
+
`<strong>${slug}: every component</strong>`,
|
|
1327
|
+
`<strong>${slug}: every component (${family})</strong>`,
|
|
1328
|
+
);
|
|
1329
|
+
writeWhole(
|
|
1330
|
+
html,
|
|
1331
|
+
`${head}${text.slice(at, starts[i + 1]?.at ?? end)}${after}`,
|
|
1332
|
+
);
|
|
1333
|
+
stampSheet(html, slug, cwd);
|
|
1334
|
+
pages.push({html, png, family});
|
|
1335
|
+
}
|
|
1336
|
+
return {pages, problems};
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Previews after a change: the sample page always; on request, pictures of
|
|
1341
|
+
* it and of the open states ({@link openStatesPage}).
|
|
701
1342
|
* @param {import('./_settings.mjs').Ctx} ctx
|
|
702
1343
|
* @param {string} slug
|
|
703
1344
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
@@ -708,23 +1349,53 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
708
1349
|
let preview = null;
|
|
709
1350
|
let cause = ctx.unchecked ?? null;
|
|
710
1351
|
const f0 = themeFiles(ctx.project.cwd, slug);
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
1352
|
+
// Something of yours at preview.html (a file, a link, a pipe) is left as
|
|
1353
|
+
// it is: the sample page is not made, so the change is not rendered,
|
|
1354
|
+
// which the result says. (A folder there is named by the write that
|
|
1355
|
+
// fails, below.)
|
|
1356
|
+
const inWay = pageInTheWay(f0.preview);
|
|
1357
|
+
const previewInWay =
|
|
1358
|
+
inWay === 'file' || inWay === 'link' || inWay === 'other' ? inWay : null;
|
|
1359
|
+
if (previewInWay)
|
|
1360
|
+
cause ??= `${inTheWayPhrase(shown(ctx.project.cwd, f0.preview), previewInWay, 'the sample page')}, so the sample page was not made and the change was not rendered; move ${previewInWay === 'link' ? 'the link' : 'it'}, then run ${P} show ${slug}`;
|
|
1361
|
+
else
|
|
1362
|
+
try {
|
|
1363
|
+
preview = await renderPreview(ctx, slug, data);
|
|
1364
|
+
} catch (e) {
|
|
1365
|
+
// The change is already saved: any failure here leaves it unchecked.
|
|
1366
|
+
const code = /** @type {any} */ (e)?.code;
|
|
1367
|
+
cause ??= isRenderFailure(e)
|
|
1368
|
+
? renderCause(ctx.project, /** @type {Error} */ (e).message)
|
|
1369
|
+
: ['ENOSPC', 'EACCES', 'EPERM', 'EROFS', 'EIO'].includes(code)
|
|
1370
|
+
? `preview.html could not be written (${code === 'ENOSPC' ? 'the disk is full' : code}), so it still shows the theme as it was`
|
|
1371
|
+
: // A folder (or another thing) where preview.html goes: the page
|
|
1372
|
+
// was rendered, and could not be written there.
|
|
1373
|
+
code === ERROR_CODES.ERR_WRITE_FAILED ||
|
|
1374
|
+
(fs.existsSync(f0.preview) && !fs.statSync(f0.preview).isFile())
|
|
1375
|
+
? `preview.html could not be written (${shown(ctx.project.cwd, f0.preview)} is ${fs.existsSync(f0.preview) && fs.statSync(f0.preview).isDirectory() ? 'a folder' : 'in the way'}; move it, then run ${P} show ${slug}), so it still shows the theme as it was`
|
|
1376
|
+
: `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
1377
|
+
}
|
|
727
1378
|
const f = themeFiles(ctx.project.cwd, slug);
|
|
1379
|
+
/**
|
|
1380
|
+
* The pages photographed: the sample page, and with it the open states.
|
|
1381
|
+
* @type {Array<{html: string, png: string, name?: string}>}
|
|
1382
|
+
*/
|
|
1383
|
+
const shotPages = [
|
|
1384
|
+
{html: f.preview, png: f.previewPng, name: SAMPLE_PAGE_NAME},
|
|
1385
|
+
];
|
|
1386
|
+
/** Why the open states were not taken, said with the pictures. @type {string | null} */
|
|
1387
|
+
let openProblem = null;
|
|
1388
|
+
// Made before the sections are judged, so it is current, never marked.
|
|
1389
|
+
if (png && preview) {
|
|
1390
|
+
const open = await openStatesPage(ctx, slug, data).catch(e => {
|
|
1391
|
+
if (/** @type {any} */ (e)?.lockLost) throw e;
|
|
1392
|
+
return {
|
|
1393
|
+
problem: `the open states page could not be made (${e instanceof Error ? e.message.split('\n')[0] : String(e)}), so ${shown(ctx.project.cwd, path.join(f.dir, `sheet-${OPEN_SECTION}.png`))} was not taken`,
|
|
1394
|
+
};
|
|
1395
|
+
});
|
|
1396
|
+
if ('problem' in open) openProblem = open.problem;
|
|
1397
|
+
else shotPages.push(open);
|
|
1398
|
+
}
|
|
728
1399
|
// The sheet of every component is made by show only: after a change it
|
|
729
1400
|
// says, at its top, that it shows the theme as it was.
|
|
730
1401
|
const sheetStale = markSheetStale(f.sheet, slug, ctx.project.cwd);
|
|
@@ -734,26 +1405,20 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
734
1405
|
fs.existsSync(f.dir) ? fs.readdirSync(f.dir) : []
|
|
735
1406
|
).filter(n => {
|
|
736
1407
|
if (!/^sheet-[a-z-]+\.html$/.test(n)) return false;
|
|
737
|
-
|
|
738
|
-
try {
|
|
739
|
-
if (!SHEET_STAMP.test(fs.readFileSync(file, 'utf8'))) return false;
|
|
740
|
-
} catch {
|
|
741
|
-
return false;
|
|
742
|
-
}
|
|
743
|
-
return markSheetStale(file, slug, ctx.project.cwd);
|
|
1408
|
+
return markSheetStale(path.join(f.dir, n), slug, ctx.project.cwd);
|
|
744
1409
|
});
|
|
745
1410
|
const shots =
|
|
746
1411
|
png && preview
|
|
747
|
-
? await pictures(
|
|
748
|
-
|
|
749
|
-
[{html: f.preview, png: f.previewPng}],
|
|
750
|
-
modesOf(data),
|
|
751
|
-
)
|
|
752
|
-
: {files: [], problem: null};
|
|
1412
|
+
? await pictures(ctx.project, shotPages, modesOf(data))
|
|
1413
|
+
: {files: [], problem: null, cutShort: []};
|
|
753
1414
|
return {
|
|
754
1415
|
preview,
|
|
755
1416
|
pictures: shots.files,
|
|
756
|
-
|
|
1417
|
+
// Text the sample page's pictures draw cut short: a note and a problem
|
|
1418
|
+
// of the change.
|
|
1419
|
+
cutShort: shots.cutShort,
|
|
1420
|
+
pictureProblem:
|
|
1421
|
+
[openProblem, shots.problem].filter(Boolean).join('; ') || null,
|
|
757
1422
|
notChecked: notChecked(cause),
|
|
758
1423
|
...(sheetStale && !sectionsStale.length
|
|
759
1424
|
? {
|
|
@@ -834,6 +1499,8 @@ export function stampSheet(file, slug, cwd) {
|
|
|
834
1499
|
* @param {string} cwd
|
|
835
1500
|
*/
|
|
836
1501
|
function markSheetStale(file, slug, cwd) {
|
|
1502
|
+
// Only the editor's own sheet: a file of yours there is never written.
|
|
1503
|
+
if (pageInTheWay(file) != null) return false;
|
|
837
1504
|
let html;
|
|
838
1505
|
try {
|
|
839
1506
|
html = fs.readFileSync(file, 'utf8');
|
|
@@ -880,24 +1547,37 @@ function markSheetStale(file, slug, cwd) {
|
|
|
880
1547
|
* that is not a section.
|
|
881
1548
|
* @param {string | undefined} section
|
|
882
1549
|
* @param {string} [theme] the theme the suggestions name
|
|
1550
|
+
* @param {string} [rest] the command's other options as typed (` --png`):
|
|
1551
|
+
* the offered command keeps them, with only the section fixed
|
|
883
1552
|
* @returns {string | undefined}
|
|
884
1553
|
*/
|
|
885
|
-
export function checkSection(section, theme = 'my') {
|
|
1554
|
+
export function checkSection(section, theme = 'my', rest = '') {
|
|
1555
|
+
// A section is offered only when one is within a typo of what was typed;
|
|
1556
|
+
// otherwise the way on is the whole sheet (show with no --section), with
|
|
1557
|
+
// the sections listed in the message. An option where the section
|
|
1558
|
+
// belongs (`--section --png`) was read as its value: it stays an option.
|
|
1559
|
+
const eaten =
|
|
1560
|
+
typeof section === 'string' && /^--[a-z][a-z-]*$/.test(section.trim())
|
|
1561
|
+
? ` ${section.trim()}`
|
|
1562
|
+
: '';
|
|
1563
|
+
const show = `${P} show ${theme}${rest}${rest.includes(eaten) ? '' : eaten}`;
|
|
886
1564
|
if (section === '')
|
|
887
|
-
refuse(
|
|
888
|
-
|
|
889
|
-
|
|
1565
|
+
refuse(
|
|
1566
|
+
E.ERR_MISSING_ARGUMENT,
|
|
1567
|
+
`--section was given no value; it takes ${SHOWCASE_GROUPS.join(', ')}, and show with no --section makes the whole sheet.`,
|
|
1568
|
+
{run: [show]},
|
|
1569
|
+
);
|
|
890
1570
|
const s = section?.toLowerCase();
|
|
891
|
-
if (s != null && !SHOWCASE_GROUPS.includes(s))
|
|
1571
|
+
if (s != null && !SHOWCASE_GROUPS.includes(s)) {
|
|
1572
|
+
const near = SHOWCASE_GROUPS.filter(g => typoNear(s, g));
|
|
892
1573
|
refuse(
|
|
893
1574
|
E.ERR_INVALID_ARGUMENT,
|
|
894
|
-
`--section takes ${SHOWCASE_GROUPS.join(', ')}, not "${section}".`,
|
|
1575
|
+
`--section takes ${SHOWCASE_GROUPS.join(', ')}, not "${section}"${near.length ? '' : '; show with no --section makes the whole sheet'}.`,
|
|
895
1576
|
{
|
|
896
|
-
didYouMean:
|
|
897
|
-
run: [
|
|
898
|
-
`${P} show ${theme} --section ${nearest(s, SHOWCASE_GROUPS)[0] ?? SHOWCASE_GROUPS[0]}`,
|
|
899
|
-
],
|
|
1577
|
+
didYouMean: near,
|
|
1578
|
+
run: [near.length === 1 ? `${show} --section ${near[0]}` : show],
|
|
900
1579
|
},
|
|
901
1580
|
);
|
|
1581
|
+
}
|
|
902
1582
|
return s;
|
|
903
1583
|
}
|