@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8
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 +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +28 -2
- package/api/docs/_adapter.mjs +249 -10
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +132 -1
- package/api/theme/build/build.mjs +482 -157
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +44 -5
- package/api/theme/build/font-warning.mjs +118 -10
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +115 -4
- package/api/theme-edit/_adapter.mjs +997 -83
- package/api/theme-edit/_catalog.d.mts +20 -2
- package/api/theme-edit/_catalog.mjs +50 -10
- package/api/theme-edit/_check.d.mts +75 -24
- package/api/theme-edit/_check.mjs +2672 -422
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +54 -1
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +133 -15
- package/api/theme-edit/_context.d.mts +14 -3
- package/api/theme-edit/_context.mjs +225 -65
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +54 -4
- package/api/theme-edit/_edit.mjs +2966 -286
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +770 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6983 -701
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +303 -0
- package/api/theme-edit/_normal.mjs +1517 -0
- package/api/theme-edit/_palette.d.mts +12 -0
- package/api/theme-edit/_palette.mjs +37 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +28 -2
- package/api/theme-edit/_parts.mjs +267 -31
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +814 -406
- package/api/theme-edit/_preview.d.mts +116 -16
- package/api/theme-edit/_preview.mjs +649 -152
- package/api/theme-edit/_project.d.mts +22 -1
- package/api/theme-edit/_project.mjs +83 -3
- package/api/theme-edit/_settings.d.mts +467 -42
- package/api/theme-edit/_settings.mjs +3527 -468
- package/api/theme-edit/_tables.d.mts +21 -0
- package/api/theme-edit/_tables.mjs +97 -3
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +16 -2
- package/api/theme-edit/theme-edit.type.mjs +6 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +573 -119
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +718 -438
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +132 -24
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.d.mts +6 -5
- package/foundation/discovery/theming-targets.mjs +31 -47
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +141 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +517 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
|
@@ -38,20 +38,33 @@ import {makeCompiler} from './_compiler.mjs';
|
|
|
38
38
|
import {openProject, installLine} from './_project.mjs';
|
|
39
39
|
import {partData} from './_parts.mjs';
|
|
40
40
|
import {writeWhole} from './_palette.mjs';
|
|
41
|
+
import {typoNear} from './_normal.mjs';
|
|
41
42
|
import {
|
|
42
43
|
fontOf,
|
|
44
|
+
builtFontFamilies,
|
|
43
45
|
fontPackages,
|
|
46
|
+
fontsourcePackageOf,
|
|
44
47
|
modesOf,
|
|
45
|
-
nearest,
|
|
46
48
|
refuse,
|
|
47
|
-
adoptOlderPicture,
|
|
48
49
|
editorWrote,
|
|
49
50
|
recordWritten,
|
|
50
51
|
themeFiles,
|
|
51
52
|
refuseThemesNotFolder,
|
|
53
|
+
shown,
|
|
52
54
|
} from './_settings.mjs';
|
|
53
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
SHOWCASE_GROUPS,
|
|
57
|
+
copyFontsCss,
|
|
58
|
+
baseFontsSheet,
|
|
59
|
+
newPictureRun,
|
|
60
|
+
renderPreview,
|
|
61
|
+
screenshot,
|
|
62
|
+
} from './_preview.mjs';
|
|
54
63
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
64
|
+
import {
|
|
65
|
+
fontKey,
|
|
66
|
+
importedFontFamilies,
|
|
67
|
+
} from '../../foundation/fonts/font-stylesheet.mjs';
|
|
55
68
|
|
|
56
69
|
const E = ERROR_CODES;
|
|
57
70
|
|
|
@@ -339,6 +352,19 @@ function usesCore(/** @type {any} */ json) {
|
|
|
339
352
|
* @param {string} message
|
|
340
353
|
*/
|
|
341
354
|
export function renderCause(project, message) {
|
|
355
|
+
const two = reactCopies(project);
|
|
356
|
+
return two
|
|
357
|
+
? `${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.`
|
|
358
|
+
: message;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The two copies of React a render saw, when the app's and the one Core
|
|
363
|
+
* resolves differ; else null.
|
|
364
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
365
|
+
* @returns {{app: string, core: string} | null}
|
|
366
|
+
*/
|
|
367
|
+
export function reactCopies(project) {
|
|
342
368
|
/** @param {(id: string) => string} resolve */
|
|
343
369
|
const reactOf = resolve => {
|
|
344
370
|
try {
|
|
@@ -362,9 +388,7 @@ export function renderCause(project, message) {
|
|
|
362
388
|
} catch {
|
|
363
389
|
// No Core package file: nothing to compare.
|
|
364
390
|
}
|
|
365
|
-
return app && core && app !== core
|
|
366
|
-
? `${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.`
|
|
367
|
-
: message;
|
|
391
|
+
return app && core && app !== core ? {app, core} : null;
|
|
368
392
|
}
|
|
369
393
|
|
|
370
394
|
/**
|
|
@@ -384,8 +408,10 @@ const notChecked = cause =>
|
|
|
384
408
|
export async function pictures(project, shots, modes) {
|
|
385
409
|
/** @type {string[]} */
|
|
386
410
|
const files = [];
|
|
387
|
-
/** @type {string[]} */
|
|
388
|
-
const
|
|
411
|
+
/** What a later browser's success says of an earlier one. @type {string[]} */
|
|
412
|
+
const notes = [];
|
|
413
|
+
/** One run for every picture: a browser that failed is not tried again. */
|
|
414
|
+
const run = newPictureRun();
|
|
389
415
|
/** @param {string} png @param {'light' | 'dark'} m */
|
|
390
416
|
const outOf = (png, m) =>
|
|
391
417
|
modes.length > 1 && m === 'dark' ? png.replace(/\.png$/, '-dark.png') : png;
|
|
@@ -398,21 +424,17 @@ export async function pictures(project, shots, modes) {
|
|
|
398
424
|
: null;
|
|
399
425
|
};
|
|
400
426
|
// A picture is written only over a picture the editor took, unchanged
|
|
401
|
-
// since: a file of the user's by that name
|
|
402
|
-
// named.
|
|
403
|
-
/** Pictures an older editor took, now recorded. @type {string[]} */
|
|
404
|
-
const adopted = [];
|
|
427
|
+
// since: a file of the user's by that name (a screenshot of the same
|
|
428
|
+
// size included) blocks every picture, and is named.
|
|
405
429
|
const blocked = shots
|
|
406
430
|
.flatMap(({png}) => modes.map(m => outOf(png, m)))
|
|
407
431
|
.filter(out => {
|
|
408
432
|
const slug = themeOf(out);
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
return true;
|
|
433
|
+
return (
|
|
434
|
+
Boolean(slug) &&
|
|
435
|
+
fs.existsSync(out) &&
|
|
436
|
+
!editorWrote(project.cwd, /** @type {string} */ (slug), out)
|
|
437
|
+
);
|
|
416
438
|
});
|
|
417
439
|
if (blocked.length)
|
|
418
440
|
return {
|
|
@@ -422,8 +444,69 @@ export async function pictures(project, shots, modes) {
|
|
|
422
444
|
for (const {html, png} of shots) {
|
|
423
445
|
for (const m of modes) {
|
|
424
446
|
const out = outOf(png, m);
|
|
425
|
-
|
|
426
|
-
|
|
447
|
+
// Taken under a name of its own and moved into place once whole: a
|
|
448
|
+
// run stopped while the browser runs leaves no picture at the real
|
|
449
|
+
// name (one the next run would read as a file of yours). A part left
|
|
450
|
+
// by a run stopped before is cleared.
|
|
451
|
+
const part = path.join(
|
|
452
|
+
path.dirname(out),
|
|
453
|
+
`.${path.basename(out, '.png')}.part-${process.pid}.png`,
|
|
454
|
+
);
|
|
455
|
+
for (const n of fs.existsSync(path.dirname(out))
|
|
456
|
+
? fs.readdirSync(path.dirname(out))
|
|
457
|
+
: [])
|
|
458
|
+
if (n.startsWith(`.${path.basename(out, '.png')}.part-`)) {
|
|
459
|
+
// Only a file is a part: a folder by that name is left alone.
|
|
460
|
+
const p = path.join(path.dirname(out), n);
|
|
461
|
+
try {
|
|
462
|
+
if (fs.lstatSync(p).isFile()) fs.rmSync(p, {force: true});
|
|
463
|
+
} catch {
|
|
464
|
+
// Gone already.
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// A folder (or anything else) where this run's part goes: no
|
|
468
|
+
// picture, the path named, never a crash after a saved change.
|
|
469
|
+
if (fs.existsSync(part) && !fs.lstatSync(part).isFile())
|
|
470
|
+
return {
|
|
471
|
+
files,
|
|
472
|
+
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))}/`,
|
|
473
|
+
};
|
|
474
|
+
// A folder it cannot write gets no picture: named before the browser
|
|
475
|
+
// starts, never read as a browser that failed.
|
|
476
|
+
try {
|
|
477
|
+
fs.accessSync(path.dirname(out), fs.constants.W_OK);
|
|
478
|
+
} catch (e) {
|
|
479
|
+
return {
|
|
480
|
+
files,
|
|
481
|
+
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`,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const r = await screenshot(project, html, part, m, run);
|
|
485
|
+
if (!r.ok) {
|
|
486
|
+
fs.rmSync(part, {force: true});
|
|
487
|
+
// Said for the whole run: the pictures taken before this one stand,
|
|
488
|
+
// and this one and every one after it were not taken.
|
|
489
|
+
const all = shots.flatMap(s => modes.map(mm => outOf(s.png, mm)));
|
|
490
|
+
const missed = all
|
|
491
|
+
.slice(all.indexOf(out))
|
|
492
|
+
.map(f => path.relative(project.cwd, f).split(path.sep).join('/'));
|
|
493
|
+
return {
|
|
494
|
+
files,
|
|
495
|
+
problem: files.length
|
|
496
|
+
? `${files.join(', ')} ${files.length === 1 ? 'was' : 'were'} taken, but ${missed.join(', ')} ${missed.length === 1 ? 'was' : 'were'} not: ${r.reason}`
|
|
497
|
+
: `No picture was taken: ${r.reason}`,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
fs.renameSync(part, out);
|
|
502
|
+
} catch (e) {
|
|
503
|
+
fs.rmSync(part, {force: true});
|
|
504
|
+
return {
|
|
505
|
+
files,
|
|
506
|
+
problem: `the picture could not be moved into ${path.relative(project.cwd, out)} (${/** @type {any} */ (e)?.code ?? e})`,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
r.file = path.relative(project.cwd, out).split(path.sep).join('/');
|
|
427
510
|
files.push(r.file);
|
|
428
511
|
// A picture in a theme folder is recorded as the editor's, so a later
|
|
429
512
|
// change removes it and never a picture of the user's.
|
|
@@ -440,31 +523,20 @@ export async function pictures(project, shots, modes) {
|
|
|
440
523
|
}
|
|
441
524
|
recordWritten(project.cwd, slug, [out]);
|
|
442
525
|
}
|
|
443
|
-
if (r.
|
|
526
|
+
if (r.note && !notes.includes(r.note)) notes.push(r.note);
|
|
444
527
|
}
|
|
445
528
|
}
|
|
446
|
-
const adoptedNote = adopted.length
|
|
447
|
-
? `${adopted.join(', ')} ${adopted.length === 1 ? 'was' : 'were'} taken by an earlier version of the editor and ${adopted.length === 1 ? 'is' : 'are'} now recorded as its own`
|
|
448
|
-
: null;
|
|
449
529
|
return {
|
|
450
530
|
files,
|
|
451
|
-
//
|
|
452
|
-
problem:
|
|
453
|
-
[
|
|
454
|
-
adoptedNote,
|
|
455
|
-
cut.length
|
|
456
|
-
? `${cut.join(', ')} show${cut.length === 1 ? 's' : ''} the top 2400 pixels of the page only (Chrome takes the window, not the whole page); open the .html beside ${cut.length === 1 ? 'it' : 'them'} to see all of it, or install Playwright (${installLine(project.cwd, ['playwright'])}) for whole-page pictures`
|
|
457
|
-
: null,
|
|
458
|
-
]
|
|
459
|
-
.filter(Boolean)
|
|
460
|
-
.join('; ') || null,
|
|
531
|
+
// Pictures were taken; a note says why an earlier browser did not.
|
|
532
|
+
problem: notes.join('; ') || null,
|
|
461
533
|
};
|
|
462
534
|
}
|
|
463
535
|
|
|
464
536
|
/**
|
|
465
|
-
* Font notes for the
|
|
466
|
-
* install line when its package is missing, and a warning
|
|
467
|
-
* package loads, naming the closest open font.
|
|
537
|
+
* Font notes for the families the theme builds: the import line for an
|
|
538
|
+
* open font, the install line when its package is missing, and a warning
|
|
539
|
+
* for a family no package loads, naming the closest open font.
|
|
468
540
|
* @param {import('./_settings.mjs').Ctx} ctx
|
|
469
541
|
* @param {import('./_settings.mjs').ThemeData} data
|
|
470
542
|
* @returns {string[]}
|
|
@@ -499,9 +571,16 @@ export function fontNotes(ctx, data) {
|
|
|
499
571
|
first.replace(/["']/g, '').trim().toLowerCase() === f,
|
|
500
572
|
);
|
|
501
573
|
};
|
|
574
|
+
// A font setting whose family the build no longer uses (the theme's own
|
|
575
|
+
// source sets every place it went) gets no note: nothing shows it.
|
|
576
|
+
const built = builtFontFamilies(ctx, data.name);
|
|
502
577
|
for (const s of data.settings) {
|
|
503
578
|
if (
|
|
504
579
|
s.thing !== 'font' ||
|
|
580
|
+
(built &&
|
|
581
|
+
!built.has(
|
|
582
|
+
fontOf(s.value).family.replace(/["']/g, '').trim().toLowerCase(),
|
|
583
|
+
)) ||
|
|
505
584
|
SYSTEM_FONTS.includes(s.value) ||
|
|
506
585
|
isDesktopFamily(fontOf(s.value).family.replace(/["']/g, '')) ||
|
|
507
586
|
OPEN_FONTS[s.value] ||
|
|
@@ -529,7 +608,51 @@ export function fontNotes(ctx, data) {
|
|
|
529
608
|
continue;
|
|
530
609
|
}
|
|
531
610
|
notes.push(
|
|
532
|
-
`"${
|
|
611
|
+
`"${named}" is not a system font and no package loads it: the app must load it, or it falls back. If Fontsource publishes it, ${installLine(ctx.project.cwd, [fontsourcePackageOf(named)])} installs its package, which the previews and the app copy then load.${near ? ` The closest open font is ${near}: ${P} set ${data.name} font ${near}${s.on ? ` --on ${s.on}` : ''}` : ''}`,
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
// Every other family the build writes that nothing loads (a part's own
|
|
615
|
+
// font, a font token, a family the theme's own source sets) is named
|
|
616
|
+
// once, with the package that would load it: the same built families
|
|
617
|
+
// the app copy and the previews load fonts for.
|
|
618
|
+
/** @type {Set<string>} */
|
|
619
|
+
const loaded = new Set();
|
|
620
|
+
for (const spec of copyFontsCss(ctx, data.name, data))
|
|
621
|
+
for (const f of importedFontFamilies(spec, ctx.project.cwd)) loaded.add(f);
|
|
622
|
+
const dialFamilies = new Set(
|
|
623
|
+
data.settings
|
|
624
|
+
.filter(s => s.thing === 'font')
|
|
625
|
+
.map(s => fontKey(fontOf(s.value).family)),
|
|
626
|
+
);
|
|
627
|
+
// A base family the app loads from a remote stylesheet (a Google Fonts
|
|
628
|
+
// import in the base's fonts.css) is not in the static previews: a page
|
|
629
|
+
// opened from disk cannot load a remote stylesheet. Unless an installed
|
|
630
|
+
// package loads it, the previews and pictures show the next font.
|
|
631
|
+
const base = baseFontsSheet(ctx, data);
|
|
632
|
+
if (base?.remote.length)
|
|
633
|
+
for (const family of base.families) {
|
|
634
|
+
if (built && !built.has(family.toLowerCase())) continue;
|
|
635
|
+
if (
|
|
636
|
+
packages.some(x => x.installed && fontKey(x.family) === fontKey(family))
|
|
637
|
+
)
|
|
638
|
+
continue;
|
|
639
|
+
const pkg = fontsourcePackageOf(family);
|
|
640
|
+
notes.push(
|
|
641
|
+
`"${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. ${installLine(ctx.project.cwd, [pkg])} installs a copy the previews load too.`,
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
for (const family of built?.values() ?? []) {
|
|
645
|
+
const key = fontKey(family);
|
|
646
|
+
if (
|
|
647
|
+
loaded.has(key) ||
|
|
648
|
+
dialFamilies.has(key) ||
|
|
649
|
+
packages.some(x => fontKey(x.family) === key) ||
|
|
650
|
+
isDesktopFamily(family) ||
|
|
651
|
+
oneSystemOf(family)
|
|
652
|
+
)
|
|
653
|
+
continue;
|
|
654
|
+
notes.push(
|
|
655
|
+
`"${family}" is not a system font and no package loads it: the app must load it, or it falls back. If Fontsource publishes it, ${installLine(ctx.project.cwd, [fontsourcePackageOf(family)])} installs its package, which the previews and the app copy then load.`,
|
|
533
656
|
);
|
|
534
657
|
}
|
|
535
658
|
return notes;
|
|
@@ -570,30 +693,52 @@ export function styledChanges(before, after, base) {
|
|
|
570
693
|
: p.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
|
|
571
694
|
for (const prop of new Set([...Object.keys(x), ...Object.keys(y)])) {
|
|
572
695
|
if (JSON.stringify(x[prop]) === JSON.stringify(y[prop])) continue;
|
|
573
|
-
// Writing what the base theme already shows there changes nothing.
|
|
574
696
|
const shown = base?.components?.[target]?.[key]?.[prop];
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
697
|
+
/**
|
|
698
|
+
* Whether a write only repeats what the base theme already shows
|
|
699
|
+
* there, which changes nothing.
|
|
700
|
+
* @param {any} was @param {any} now @param {any} baseValue
|
|
701
|
+
*/
|
|
702
|
+
const repeatsBase = (was, now, baseValue) =>
|
|
703
|
+
was === undefined &&
|
|
704
|
+
baseValue !== undefined &&
|
|
705
|
+
typeof baseValue !== 'object' &&
|
|
706
|
+
plain(baseValue) === plain(now);
|
|
581
707
|
const where = `${target}${key === 'base' ? '' : ` ${key}`}`;
|
|
582
|
-
// A
|
|
708
|
+
// A block (a state, `:hover`, a mode block, a state inside a mode
|
|
709
|
+
// block) lists each property it changes, under its path.
|
|
710
|
+
/**
|
|
711
|
+
* @param {string} path @param {any} xs @param {any} ys @param {any} shownIn
|
|
712
|
+
*/
|
|
713
|
+
const blockLines = (path, xs, ys, shownIn) => {
|
|
714
|
+
for (const p of new Set([
|
|
715
|
+
...Object.keys(xs ?? {}),
|
|
716
|
+
...Object.keys(ys ?? {}),
|
|
717
|
+
])) {
|
|
718
|
+
const was = xs?.[p];
|
|
719
|
+
const now = ys?.[p];
|
|
720
|
+
if (JSON.stringify(was) === JSON.stringify(now)) continue;
|
|
721
|
+
if (
|
|
722
|
+
(now && typeof now === 'object') ||
|
|
723
|
+
(was && typeof was === 'object')
|
|
724
|
+
) {
|
|
725
|
+
blockLines(`${path} ${p}`, was ?? {}, now ?? {}, shownIn?.[p]);
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
if (repeatsBase(was, now, shownIn?.[p])) continue;
|
|
729
|
+
out.push(
|
|
730
|
+
`${where} ${path}: ${cssName(p)} ${now === undefined ? '(removed)' : String(now)}`,
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
583
734
|
if (
|
|
584
|
-
prop
|
|
585
|
-
(
|
|
586
|
-
(x[prop] && typeof x[prop] === 'object'))
|
|
735
|
+
(y[prop] && typeof y[prop] === 'object') ||
|
|
736
|
+
(x[prop] && typeof x[prop] === 'object')
|
|
587
737
|
) {
|
|
588
|
-
|
|
589
|
-
const ys = y[prop] ?? {};
|
|
590
|
-
for (const p of new Set([...Object.keys(xs), ...Object.keys(ys)]))
|
|
591
|
-
if (JSON.stringify(xs[p]) !== JSON.stringify(ys[p]))
|
|
592
|
-
out.push(
|
|
593
|
-
`${where} ${prop}: ${cssName(p)} ${ys[p] === undefined ? '(removed)' : String(ys[p])}`,
|
|
594
|
-
);
|
|
738
|
+
blockLines(prop, x[prop] ?? {}, y[prop] ?? {}, shown);
|
|
595
739
|
continue;
|
|
596
740
|
}
|
|
741
|
+
if (repeatsBase(x[prop], y[prop], shown)) continue;
|
|
597
742
|
out.push(
|
|
598
743
|
`${where}: ${cssName(prop)} ${y[prop] === undefined ? '(removed)' : typeof y[prop] === 'string' ? y[prop] : JSON.stringify(y[prop])}`,
|
|
599
744
|
);
|
|
@@ -650,6 +795,7 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
650
795
|
/** @type {string | null} */
|
|
651
796
|
let preview = null;
|
|
652
797
|
let cause = ctx.unchecked ?? null;
|
|
798
|
+
const f0 = themeFiles(ctx.project.cwd, slug);
|
|
653
799
|
try {
|
|
654
800
|
preview = await renderPreview(ctx, slug, data);
|
|
655
801
|
} catch (e) {
|
|
@@ -659,7 +805,12 @@ export async function previewAfter(ctx, slug, data, png) {
|
|
|
659
805
|
? renderCause(ctx.project, /** @type {Error} */ (e).message)
|
|
660
806
|
: ['ENOSPC', 'EACCES', 'EPERM', 'EROFS', 'EIO'].includes(code)
|
|
661
807
|
? `preview.html could not be written (${code === 'ENOSPC' ? 'the disk is full' : code}), so it still shows the theme as it was`
|
|
662
|
-
:
|
|
808
|
+
: // A folder (or another thing) where preview.html goes: the page
|
|
809
|
+
// was rendered, and could not be written there.
|
|
810
|
+
code === ERROR_CODES.ERR_WRITE_FAILED ||
|
|
811
|
+
(fs.existsSync(f0.preview) && !fs.statSync(f0.preview).isFile())
|
|
812
|
+
? `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`
|
|
813
|
+
: `checking it failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
663
814
|
}
|
|
664
815
|
const f = themeFiles(ctx.project.cwd, slug);
|
|
665
816
|
// The sheet of every component is made by show only: after a change it
|
|
@@ -820,21 +971,30 @@ function markSheetStale(file, slug, cwd) {
|
|
|
820
971
|
* @returns {string | undefined}
|
|
821
972
|
*/
|
|
822
973
|
export function checkSection(section, theme = 'my') {
|
|
974
|
+
// A section is offered only when one is within a typo of what was typed;
|
|
975
|
+
// otherwise the way on is the whole sheet (show with no --section), with
|
|
976
|
+
// the sections listed in the message.
|
|
823
977
|
if (section === '')
|
|
824
|
-
refuse(
|
|
825
|
-
|
|
826
|
-
|
|
978
|
+
refuse(
|
|
979
|
+
E.ERR_MISSING_ARGUMENT,
|
|
980
|
+
`--section was given no value; it takes ${SHOWCASE_GROUPS.join(', ')}, and show with no --section makes the whole sheet.`,
|
|
981
|
+
{run: [`${P} show ${theme}`]},
|
|
982
|
+
);
|
|
827
983
|
const s = section?.toLowerCase();
|
|
828
|
-
if (s != null && !SHOWCASE_GROUPS.includes(s))
|
|
984
|
+
if (s != null && !SHOWCASE_GROUPS.includes(s)) {
|
|
985
|
+
const near = SHOWCASE_GROUPS.filter(g => typoNear(s, g));
|
|
829
986
|
refuse(
|
|
830
987
|
E.ERR_INVALID_ARGUMENT,
|
|
831
|
-
`--section takes ${SHOWCASE_GROUPS.join(', ')}, not "${section}".`,
|
|
988
|
+
`--section takes ${SHOWCASE_GROUPS.join(', ')}, not "${section}"${near.length ? '' : '; show with no --section makes the whole sheet'}.`,
|
|
832
989
|
{
|
|
833
|
-
didYouMean:
|
|
990
|
+
didYouMean: near,
|
|
834
991
|
run: [
|
|
835
|
-
|
|
992
|
+
near.length === 1
|
|
993
|
+
? `${P} show ${theme} --section ${near[0]}`
|
|
994
|
+
: `${P} show ${theme}`,
|
|
836
995
|
],
|
|
837
996
|
},
|
|
838
997
|
);
|
|
998
|
+
}
|
|
839
999
|
return s;
|
|
840
1000
|
}
|
|
@@ -107,6 +107,20 @@ export function cssNumber(value: string): {
|
|
|
107
107
|
* @returns {string[]}
|
|
108
108
|
*/
|
|
109
109
|
export function splitTop(v: string, sep: "," | " " | "/"): string[];
|
|
110
|
+
/**
|
|
111
|
+
* Several values of one kind (`-4px -8px`, `1.5 2`, `var(--a) var(--b)`):
|
|
112
|
+
* the items, split as CSS splits them, and their kind (a number's unit, ''
|
|
113
|
+
* for a bare number, `var` for a var()), when every item is of the first
|
|
114
|
+
* one's kind; null otherwise (`all 200`). The one reading of "several
|
|
115
|
+
* values of one kind" that a repair offers the first of and the repair
|
|
116
|
+
* gate allows.
|
|
117
|
+
* @param {string} v
|
|
118
|
+
* @returns {{items: string[], kind: string} | null}
|
|
119
|
+
*/
|
|
120
|
+
export function sameKindValues(v: string): {
|
|
121
|
+
items: string[];
|
|
122
|
+
kind: string;
|
|
123
|
+
} | null;
|
|
110
124
|
/**
|
|
111
125
|
* The parts of a CSS `font` value, by the longhand each sets, as written:
|
|
112
126
|
* `italic small-caps 700 1rem/1 Arial` gives font-style, font-variant-caps,
|
package/api/theme-edit/_css.mjs
CHANGED
|
@@ -235,6 +235,17 @@ export function matchType(type, value) {
|
|
|
235
235
|
*/
|
|
236
236
|
function matchWith(value, match) {
|
|
237
237
|
const {lexer, parse} = csstree();
|
|
238
|
+
// A color function holding a variable (color-mix(…, var(--x))) is a
|
|
239
|
+
// color whatever the variable holds: it is matched as one, so a value
|
|
240
|
+
// with many of them is read like the same value with plain colors.
|
|
241
|
+
for (let i = 0; i < 4; i++) {
|
|
242
|
+
const next = value.replace(
|
|
243
|
+
/\b(?:color-mix|light-dark|rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\)/gi,
|
|
244
|
+
m => (/\bvar\(/i.test(m) ? 'red' : m),
|
|
245
|
+
);
|
|
246
|
+
if (next === value) break;
|
|
247
|
+
value = next;
|
|
248
|
+
}
|
|
238
249
|
const vars =
|
|
239
250
|
value.match(/(?:var|env)\([^()]*(?:\([^()]*\)[^()]*)*\)/gi) ?? [];
|
|
240
251
|
/** @param {string} v */
|
|
@@ -263,7 +274,16 @@ function matchWith(value, match) {
|
|
|
263
274
|
return null;
|
|
264
275
|
}
|
|
265
276
|
}
|
|
266
|
-
|
|
277
|
+
// Many variables: each stands for the same kind of value at once.
|
|
278
|
+
if (vars.length > 3) {
|
|
279
|
+
for (const stand of VAR_STANDS_FOR) {
|
|
280
|
+
let v = value;
|
|
281
|
+
for (const x of vars) v = v.replace(x, stand);
|
|
282
|
+
const ast = tryOne(v);
|
|
283
|
+
if (ast) return ast;
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
267
287
|
/** @param {string} v @param {number} i @returns {any | null} */
|
|
268
288
|
const fill = (v, i) => {
|
|
269
289
|
if (i === vars.length) return tryOne(v);
|
|
@@ -788,6 +808,31 @@ export function splitTop(v, sep) {
|
|
|
788
808
|
return out.filter(x => sep === ',' || x.trim());
|
|
789
809
|
}
|
|
790
810
|
|
|
811
|
+
/**
|
|
812
|
+
* Several values of one kind (`-4px -8px`, `1.5 2`, `var(--a) var(--b)`):
|
|
813
|
+
* the items, split as CSS splits them, and their kind (a number's unit, ''
|
|
814
|
+
* for a bare number, `var` for a var()), when every item is of the first
|
|
815
|
+
* one's kind; null otherwise (`all 200`). The one reading of "several
|
|
816
|
+
* values of one kind" that a repair offers the first of and the repair
|
|
817
|
+
* gate allows.
|
|
818
|
+
* @param {string} v
|
|
819
|
+
* @returns {{items: string[], kind: string} | null}
|
|
820
|
+
*/
|
|
821
|
+
export function sameKindValues(v) {
|
|
822
|
+
const items = splitTop(String(v).trim(), ' ');
|
|
823
|
+
/** @param {string} x */
|
|
824
|
+
const kind = x =>
|
|
825
|
+
/^var\(/i.test(x)
|
|
826
|
+
? 'var'
|
|
827
|
+
: (/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?([a-z%]*)$/i
|
|
828
|
+
.exec(x)?.[1]
|
|
829
|
+
?.toLowerCase() ?? null);
|
|
830
|
+
const first = kind(items[0] ?? '');
|
|
831
|
+
if (items.length < 2 || first === null || items.some(x => kind(x) !== first))
|
|
832
|
+
return null;
|
|
833
|
+
return {items, kind: first};
|
|
834
|
+
}
|
|
835
|
+
|
|
791
836
|
/** The longhand each type of the `font` grammar sets, where css-tree names a type, not a property. */
|
|
792
837
|
const FONT_TYPE_LONGHAND = wordTable(
|
|
793
838
|
/** @type {Record<string, string>} */ ({
|
|
@@ -20,6 +20,20 @@ export function themeEditNew(name: string, options?: import("./theme-edit.type.m
|
|
|
20
20
|
* @returns {string[]}
|
|
21
21
|
*/
|
|
22
22
|
export function newFlagList(like: string | null | undefined, settings: Record<string, string | string[] | undefined>, png?: boolean): string[];
|
|
23
|
+
/**
|
|
24
|
+
* A signal handler for the checks and pictures after a change is saved: it
|
|
25
|
+
* says what is saved (in the words of the command that ran) and how to run
|
|
26
|
+
* what did not, with the project's own CLI invocation, then lets the
|
|
27
|
+
* signal end the process (the render's own handler re-raises it; with none,
|
|
28
|
+
* this one does).
|
|
29
|
+
* @param {string} slug
|
|
30
|
+
* @param {'set' | 'undo' | 'new'} [kind] the command that saved
|
|
31
|
+
* @param {string} [cwd] the project, for the CLI invocation
|
|
32
|
+
* @param {boolean} [png] pictures were asked for: the command named takes
|
|
33
|
+
* them too
|
|
34
|
+
* @returns {(sig: NodeJS.Signals) => void}
|
|
35
|
+
*/
|
|
36
|
+
export function stoppedAfterSave(slug: string, kind?: "set" | "undo" | "new", cwd?: string, png?: boolean): (sig: NodeJS.Signals) => void;
|
|
23
37
|
/**
|
|
24
38
|
* Change one thing in a theme: checked, built, previewed.
|
|
25
39
|
* @experimental
|
|
@@ -30,6 +44,28 @@ export function newFlagList(like: string | null | undefined, settings: Record<st
|
|
|
30
44
|
* @returns {Promise<import('./theme-edit.type.mjs').ThemeEditChangeResponse>}
|
|
31
45
|
*/
|
|
32
46
|
export function themeEditSet(theme: string, thing: string, value: string, options?: ChangeOptions): Promise<import("./theme-edit.type.mjs").ThemeEditChangeResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* The lines that carry out a `new` the CLI builds (words of a value read
|
|
49
|
+
* back into it): the line when new takes it, else what new's own refusal
|
|
50
|
+
* of it offers, vetted as every offered new line is. new's checks only:
|
|
51
|
+
* nothing is written.
|
|
52
|
+
* @param {string} line the whole command, `astryx experimental theme editor new <theme> …`
|
|
53
|
+
* @param {string} name
|
|
54
|
+
* @param {import('./theme-edit.type.mjs').ThemeEditNewOptions} options
|
|
55
|
+
* @returns {Promise<import('../../foundation/response/base').Suggestion[]>}
|
|
56
|
+
*/
|
|
57
|
+
export function checkedNewLines(line: string, name: string, options: import("./theme-edit.type.mjs").ThemeEditNewOptions): Promise<import("../../foundation/response/base").Suggestion[]>;
|
|
58
|
+
/**
|
|
59
|
+
* A `set` or `undo` command line as set or undo takes it (a repair either
|
|
60
|
+
* offers folded in, see followChangeLine), or null when it is refused with
|
|
61
|
+
* no repair: the check every offered line passes, for lines the CLI builds
|
|
62
|
+
* (a flag written with a value).
|
|
63
|
+
* @param {'set' | 'undo'} sub
|
|
64
|
+
* @param {string} line the whole command, `astryx experimental theme editor set <theme> …`
|
|
65
|
+
* @param {string} cwd
|
|
66
|
+
* @returns {Promise<string | null>}
|
|
67
|
+
*/
|
|
68
|
+
export function checkedChangeLine(sub: "set" | "undo", line: string, cwd: string): Promise<string | null>;
|
|
33
69
|
/**
|
|
34
70
|
* For `compile`: the refusal `show` gives for saved settings the editor no
|
|
35
71
|
* longer accepts (naming the undo that removes each), or null.
|
|
@@ -39,13 +75,13 @@ export function themeEditSet(theme: string, thing: string, value: string, option
|
|
|
39
75
|
*/
|
|
40
76
|
export function editorStoredRefusal(root: string, slug: string): Promise<import("../error.mjs").AstryxError | null>;
|
|
41
77
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
78
|
+
* The refusal `compile` gives an editor theme whose own source gives a
|
|
79
|
+
* token a value `set` refuses, or null.
|
|
44
80
|
* @param {string} root
|
|
45
81
|
* @param {string} slug
|
|
46
|
-
* @returns {Promise<
|
|
82
|
+
* @returns {Promise<AstryxError | null>}
|
|
47
83
|
*/
|
|
48
|
-
export function
|
|
84
|
+
export function editorOwnTokenRefusal(root: string, slug: string): Promise<AstryxError | null>;
|
|
49
85
|
/**
|
|
50
86
|
* Every setting of a theme, key resolved values, problems it caused, the
|
|
51
87
|
* sample page and the theme-building page with every component.
|
|
@@ -55,6 +91,19 @@ export function editorPairRefusal(root: string, slug: string): Promise<import(".
|
|
|
55
91
|
* @returns {Promise<import('./theme-edit.type.mjs').ThemeEditShowResponse>}
|
|
56
92
|
*/
|
|
57
93
|
export function themeEditShow(theme: string, options?: import("./theme-edit.type.mjs").ThemeEditShowOptions): Promise<import("./theme-edit.type.mjs").ThemeEditShowResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* The family and weight tokens the theme's own source sets as plain tokens
|
|
96
|
+
* that phones do not show: on top of a base theme, its rule for those
|
|
97
|
+
* screens sets its type again (a rule wins over plain tokens, by Core's
|
|
98
|
+
* contract), unless an exact setting is repeated after it. The note names
|
|
99
|
+
* the fix within that contract: the theme's typography, or a same-screens
|
|
100
|
+
* rule.
|
|
101
|
+
* @param {string} cwd
|
|
102
|
+
* @param {string} slug
|
|
103
|
+
* @param {import('./_settings.mjs').ThemeData} data
|
|
104
|
+
* @returns {string[]}
|
|
105
|
+
*/
|
|
106
|
+
export function ownPhoneNotes(cwd: string, slug: string, data: import("./_settings.mjs").ThemeData): string[];
|
|
58
107
|
/**
|
|
59
108
|
* Put the theme back as it was before its last change. With `thing`, remove
|
|
60
109
|
* that one setting instead, wherever it is in the settings: it goes back to
|
|
@@ -75,3 +124,4 @@ export function themeEditUndo(theme: string, options?: import("./theme-edit.type
|
|
|
75
124
|
*/
|
|
76
125
|
export function editorStale(cwd: string, slug: string): Promise<string | null>;
|
|
77
126
|
export type ChangeOptions = import("./theme-edit.type.mjs").ThemeEditChangeOptions;
|
|
127
|
+
import { AstryxError } from '../error.mjs';
|