@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03
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 +26 -2
- package/api/docs/_adapter.mjs +219 -6
- 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 +122 -1
- package/api/theme/build/build.mjs +412 -84
- 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 +23 -3
- package/api/theme/build/font-warning.mjs +54 -5
- package/api/theme/build/icon-imports.mjs +25 -2
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +103 -3
- package/api/theme-edit/_adapter.mjs +961 -82
- package/api/theme-edit/_catalog.mjs +19 -4
- package/api/theme-edit/_check.d.mts +63 -24
- package/api/theme-edit/_check.mjs +2467 -362
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +89 -6
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +165 -54
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +31 -4
- package/api/theme-edit/_edit.mjs +2433 -204
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +759 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6473 -553
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- 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 +292 -0
- package/api/theme-edit/_normal.mjs +1454 -0
- package/api/theme-edit/_palette.mjs +10 -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 +18 -1
- package/api/theme-edit/_parts.mjs +246 -23
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +776 -187
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +582 -139
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +3 -1
- package/api/theme-edit/_settings.d.mts +417 -42
- package/api/theme-edit/_settings.mjs +3262 -424
- package/api/theme-edit/_tables.d.mts +15 -0
- package/api/theme-edit/_tables.mjs +63 -1
- package/api/theme-edit/_vet.d.mts +20 -0
- package/api/theme-edit/_vet.mjs +47 -2
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- 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/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 +358 -63
- 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 +1 -1
- 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 +317 -47
- 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 +92 -21
- 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/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.mjs +3 -2
- 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 +31 -0
- package/foundation/fonts/font-stylesheet.mjs +115 -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 +512 -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/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
|
@@ -156,7 +156,11 @@ function sweepTemps(dir) {
|
|
|
156
156
|
}
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
// A picture taken under its own name (`.<picture>.part-<pid>.png`) by a
|
|
160
|
+
// run stopped while the browser ran.
|
|
161
|
+
const m =
|
|
162
|
+
/^\..+\.astryx-(\d+)-[a-z0-9]+\.tmp$/.exec(n) ??
|
|
163
|
+
/^\.[\w-]+\.part-(\d+)\.png$/.exec(n);
|
|
160
164
|
if (!m) continue;
|
|
161
165
|
const p = path.join(dir, n);
|
|
162
166
|
try {
|
|
@@ -203,12 +207,14 @@ export function removeEmptyFolder(dir, opts = {}) {
|
|
|
203
207
|
|
|
204
208
|
/**
|
|
205
209
|
* Whether a file name is one of the editor's own temp files: a whole-file
|
|
206
|
-
* write's `.<name>.astryx-<pid>-<random>.tmp`,
|
|
207
|
-
* `.<
|
|
210
|
+
* write's `.<name>.astryx-<pid>-<random>.tmp`, a build's `.<name>.tmp-<id>`,
|
|
211
|
+
* or a picture's `.<picture>.part-<pid>.png`. A command stopped part way can
|
|
212
|
+
* leave one behind.
|
|
208
213
|
* @param {string} name
|
|
209
214
|
*/
|
|
210
215
|
export const isEditorTemp = name =>
|
|
211
|
-
/^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name)
|
|
216
|
+
/^\..+\.(astryx-\d+-[a-z0-9]+\.tmp|tmp-[\w-]+)$/.test(name) ||
|
|
217
|
+
/^\.[\w-]+\.part-\d+\.png$/.test(name);
|
|
212
218
|
|
|
213
219
|
/**
|
|
214
220
|
* A temp file beside `file` for a whole write, named so only the editor
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The part or group a plain word names, as how reads it (`checkboxes` is
|
|
6
|
+
* the checks group, `panels` the containers), or null.
|
|
7
|
+
* @param {string} word
|
|
8
|
+
* @returns {string | null}
|
|
9
|
+
*/
|
|
10
|
+
export function partForWord(word: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* @file The plain words for parts that Core's catalog cannot give (groups,
|
|
13
|
+
* variants, font roles, phrases of several words, and words two components
|
|
14
|
+
* share), and the part or group one plain word names.
|
|
15
|
+
* @position api/theme-edit — a leaf with no imports, read by _how-question.mjs
|
|
16
|
+
* and _check.mjs
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Phrases for parts that Core's catalog cannot give: groups, variants,
|
|
20
|
+
* font roles, phrases of several words, and words two components share.
|
|
21
|
+
* They are read before the catalog's names and doc keywords
|
|
22
|
+
* (partLexicon), longest phrase first.
|
|
23
|
+
* @type {Array<[RegExp, {on: string, when?: string, role?: string, level?: string, missing?: string}]>}
|
|
24
|
+
*/
|
|
25
|
+
export const OVERRIDES: Array<[RegExp, {
|
|
26
|
+
on: string;
|
|
27
|
+
when?: string;
|
|
28
|
+
role?: string;
|
|
29
|
+
level?: string;
|
|
30
|
+
missing?: string;
|
|
31
|
+
}]>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The plain words for parts that Core's catalog cannot give (groups,
|
|
5
|
+
* variants, font roles, phrases of several words, and words two components
|
|
6
|
+
* share), and the part or group one plain word names.
|
|
7
|
+
* @position api/theme-edit — a leaf with no imports, read by _how-question.mjs
|
|
8
|
+
* and _check.mjs
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Phrases for parts that Core's catalog cannot give: groups, variants,
|
|
13
|
+
* font roles, phrases of several words, and words two components share.
|
|
14
|
+
* They are read before the catalog's names and doc keywords
|
|
15
|
+
* (partLexicon), longest phrase first.
|
|
16
|
+
* @type {Array<[RegExp, {on: string, when?: string, role?: string, level?: string, missing?: string}]>}
|
|
17
|
+
*/
|
|
18
|
+
export const OVERRIDES = [
|
|
19
|
+
[/\bdividers?\b/, {on: 'divider'}],
|
|
20
|
+
[
|
|
21
|
+
/\baccordions? (headers?|triggers?|titles?|headings?)\b/,
|
|
22
|
+
{on: 'collapsible-trigger'},
|
|
23
|
+
],
|
|
24
|
+
[/\baccordions?\b/, {on: 'collapsible'}],
|
|
25
|
+
[/\bcombo ?box(es)?\b/, {on: 'complex-selector'}],
|
|
26
|
+
[/\bnotifications?\b/, {on: 'toast'}],
|
|
27
|
+
[/\b(focus (ring|outline)s?)\b/, {on: 'focus-ring'}],
|
|
28
|
+
[/\b((modal |dialog )?(overlay|scrim|backdrop))\b/, {on: 'overlay'}],
|
|
29
|
+
[/\bicons?\b/, {on: 'icons'}],
|
|
30
|
+
[
|
|
31
|
+
/\b(table header|column headers?|table headings?)\b/,
|
|
32
|
+
{on: 'table-header-cell'},
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
/\b(tabs? (underline|indicator)s?|underline (of|on|under) (the )?tabs?)\b/,
|
|
36
|
+
{on: 'tab-indicator'},
|
|
37
|
+
],
|
|
38
|
+
[/\b(status dots?)\b/, {on: 'status-dot'}],
|
|
39
|
+
[/\b(progress( bar)?( fill)?|loading bar)\b/, {on: 'progress-bar-fill'}],
|
|
40
|
+
[
|
|
41
|
+
/\b((side ?nav|sidebar)( nav(igation)?)? (links?|items?))\b/,
|
|
42
|
+
{on: 'side-nav-item'},
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
/\b((dropdown |context )?menu (items?|options?|entries)|dropdown items?)\b/,
|
|
46
|
+
{on: 'dropdown-menu-item'},
|
|
47
|
+
],
|
|
48
|
+
[/\b(nav(igation)? (links?|items?))\b/, {on: 'top-nav-item'}],
|
|
49
|
+
// A context menu is its own part in Core (its items are the dropdown
|
|
50
|
+
// menu's items, which it reuses).
|
|
51
|
+
[/\b(context ?menus?|right[- ]click menus?)\b/, {on: 'context-menu'}],
|
|
52
|
+
[/\b((dropdown )?menus?)\b/, {on: 'dropdown-menu'}],
|
|
53
|
+
// A part's own header or footer ("dialog header", "card footer") is that
|
|
54
|
+
// part's, never the app's top bar or footer.
|
|
55
|
+
[
|
|
56
|
+
/(?<!\b(?:dialog|modal|card|drawer|sheet|popover|panel|section|table|menu)s? )\bfooters?\b/,
|
|
57
|
+
{on: 'layout-footer'},
|
|
58
|
+
],
|
|
59
|
+
[/\b(side ?nav|sidebar|side ?panel)\b/, {on: 'side-nav'}],
|
|
60
|
+
[
|
|
61
|
+
/\b(app (name|title)|logo|site title|product name)\b/,
|
|
62
|
+
{on: 'top-nav-heading'},
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
/(?<!\b(?:dialog|modal|card|drawer|sheet|popover|panel|section|table|menu)s? )\b(header|top ?bar|title ?bar|nav ?bar|app ?bar|masthead)\b/,
|
|
66
|
+
{on: 'app-shell-header'},
|
|
67
|
+
],
|
|
68
|
+
[/\b(page|app background|whole background|body background)\b/, {on: 'page'}],
|
|
69
|
+
[/\b(radio( buttons?)?|radios)\b/, {on: 'radio-indicator'}],
|
|
70
|
+
[/\b(primary|main) buttons?\b/, {on: 'button', when: 'variant:primary'}],
|
|
71
|
+
[/\bsecondary buttons?\b/, {on: 'button', when: 'variant:secondary'}],
|
|
72
|
+
[/\bghost buttons?\b/, {on: 'button', when: 'variant:ghost'}],
|
|
73
|
+
[
|
|
74
|
+
/\b(danger|destructive|delete) (buttons?|ones?|variant)\b/,
|
|
75
|
+
{on: 'button', when: 'variant:destructive'},
|
|
76
|
+
],
|
|
77
|
+
[/\b(panels?|windows?|boxes|tiles?|containers?)\b/, {on: 'containers'}],
|
|
78
|
+
[/\b(banners?|alerts?|notices?|announcements?)\b/, {on: 'banner'}],
|
|
79
|
+
[/\b(text ?areas?|multi-?line (inputs?|fields?))\b/, {on: 'text-area'}],
|
|
80
|
+
[
|
|
81
|
+
/\b(select (dropdowns?|menus?|box(es)?|inputs?)|selects|dropdowns?|pickers?|select(?! (the|a|an|all|any|one|which|what|it|them)\b))\b/,
|
|
82
|
+
{on: 'selector'},
|
|
83
|
+
],
|
|
84
|
+
[/\b(skeletons?( loaders?)?|loading placeholders?)\b/, {on: 'skeleton'}],
|
|
85
|
+
[
|
|
86
|
+
/\b(inputs?|text ?box(es)?|text ?fields?|form fields?|fields?)\b/,
|
|
87
|
+
{on: 'inputs'},
|
|
88
|
+
],
|
|
89
|
+
[/\b(checkbox(es)?|check ?marks?)\b/, {on: 'checks'}],
|
|
90
|
+
// "switch off", "switch the buttons to" are the verb, not the part.
|
|
91
|
+
[
|
|
92
|
+
/\b(toggles?|switch(?:e?s)?(?! (off|on|to|the|out|it|them|over|back|from)\b))\b/,
|
|
93
|
+
{on: 'switch'},
|
|
94
|
+
],
|
|
95
|
+
[/\b((table )?cells?)\b/, {on: 'table-cell'}],
|
|
96
|
+
[/\b(table rows?|rows?|tables?)\b/, {on: 'table-row'}],
|
|
97
|
+
[/\b(badges?|chips?|tags?)\b/, {on: 'badge'}],
|
|
98
|
+
[/\bh([1-6])\b/, {on: 'heading'}],
|
|
99
|
+
[/\b(headings?|titles?)\b/, {on: 'heading'}],
|
|
100
|
+
[/\b(modals?|popups?)\b/, {on: 'dialog'}],
|
|
101
|
+
[/\bcode\b/, {on: 'code', role: 'code'}],
|
|
102
|
+
// Small, secondary and supporting text, captions and fine print: the
|
|
103
|
+
// supporting text style, not the base size.
|
|
104
|
+
[
|
|
105
|
+
/\b((?:small|secondary|supporting|helper|hint|caption|muted) (?:text|copy)|fine print|captions?)\b/,
|
|
106
|
+
{on: 'body', role: 'supporting'},
|
|
107
|
+
],
|
|
108
|
+
[/\bbody( text)?\b/, {on: 'body', role: 'body'}],
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The part or group a plain word names, as how reads it (`checkboxes` is
|
|
113
|
+
* the checks group, `panels` the containers), or null.
|
|
114
|
+
* @param {string} word
|
|
115
|
+
* @returns {string | null}
|
|
116
|
+
*/
|
|
117
|
+
export function partForWord(word) {
|
|
118
|
+
const w = String(word ?? '')
|
|
119
|
+
.trim()
|
|
120
|
+
.toLowerCase();
|
|
121
|
+
if (!w) return null;
|
|
122
|
+
for (const [re, hit] of OVERRIDES)
|
|
123
|
+
if (/** @type {RegExp} */ (re).test(w))
|
|
124
|
+
return /** @type {{on: string}} */ (hit).on;
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
@@ -31,7 +31,8 @@ export function isItemOf(project: import("./_project.mjs").ThemeProject, name: s
|
|
|
31
31
|
* A component's catalog entries, all from its doc: its demo props
|
|
32
32
|
* ({@link demoProps}), then once per value of each visual prop with a
|
|
33
33
|
* closed set of values (`variant`, `status`, `color`, and a number union
|
|
34
|
-
* such as a heading's level),
|
|
34
|
+
* such as a heading's level), its checked and disabled states, and each look
|
|
35
|
+
* flag (`isStriped`) turned on. An
|
|
35
36
|
* overlay the playground shows in place renders open; on a page people
|
|
36
37
|
* see, once, as some of its variants size the window, not the card.
|
|
37
38
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -142,6 +143,10 @@ export type PartRecord = {
|
|
|
142
143
|
tokens: Record<string, string[]>;
|
|
143
144
|
values: string[];
|
|
144
145
|
}>;
|
|
146
|
+
/**
|
|
147
|
+
* - property -> the value under each condition, private variables resolved
|
|
148
|
+
*/
|
|
149
|
+
at?: Record<string, Record<string, string>> | undefined;
|
|
145
150
|
/**
|
|
146
151
|
* - tokens read by unnamed elements inside the part -> properties
|
|
147
152
|
*/
|
|
@@ -154,6 +159,18 @@ export type PartRecord = {
|
|
|
154
159
|
* - parts rendered inside it
|
|
155
160
|
*/
|
|
156
161
|
contains: string[];
|
|
162
|
+
/**
|
|
163
|
+
* - the elements it is rendered as (`tr` for a table row)
|
|
164
|
+
*/
|
|
165
|
+
tags?: string[] | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* - the radius tokens of the corners Core draws by place on the parts directly inside it (a button group's end buttons)
|
|
168
|
+
*/
|
|
169
|
+
innerCorners?: string[] | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* - state ('' for always) -> property -> the token Core paints it with as an inline style, which no theme rule can replace
|
|
172
|
+
*/
|
|
173
|
+
inline?: Record<string, Record<string, string>> | undefined;
|
|
157
174
|
};
|
|
158
175
|
export type PaintSide = {
|
|
159
176
|
target: string | null;
|
|
@@ -29,16 +29,33 @@ import {
|
|
|
29
29
|
RenderError,
|
|
30
30
|
} from '../../foundation/render/render-page.mjs';
|
|
31
31
|
import {SAMPLE_PAGE, elementNames, pageSource} from './_catalog.mjs';
|
|
32
|
+
import {removeOnStop} from '../../foundation/fs/stop-cleanup.mjs';
|
|
32
33
|
|
|
33
34
|
/** Bump when the shape of the cached part data changes. */
|
|
34
|
-
const PART_DATA_VERSION =
|
|
35
|
+
const PART_DATA_VERSION = 11;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Flags that change what a component does or whether it shows, not how it
|
|
39
|
+
* looks: the catalog never turns them on (disabled has its own entry).
|
|
40
|
+
*/
|
|
41
|
+
const LIFECYCLE_FLAGS = new Set([
|
|
42
|
+
'isDisabled',
|
|
43
|
+
'isOpen',
|
|
44
|
+
'isDefaultOpen',
|
|
45
|
+
'hasAutoFocus',
|
|
46
|
+
'isHidden',
|
|
47
|
+
]);
|
|
35
48
|
|
|
36
49
|
/**
|
|
37
50
|
* @typedef {object} PartRecord
|
|
38
51
|
* @property {Record<string, {tokens: Record<string, string[]>, values: string[]}>} own - property -> tokens (with conditions) and raw values
|
|
52
|
+
* @property {Record<string, Record<string, string>>} [at] - property -> the value under each condition, private variables resolved
|
|
39
53
|
* @property {Record<string, string[]>} inside - tokens read by unnamed elements inside the part -> properties
|
|
40
54
|
* @property {Record<string, string[]>} attrs - data attributes seen on the part
|
|
41
55
|
* @property {string[]} contains - parts rendered inside it
|
|
56
|
+
* @property {string[]} [tags] - the elements it is rendered as (`tr` for a table row)
|
|
57
|
+
* @property {string[]} [innerCorners] - the radius tokens of the corners Core draws by place on the parts directly inside it (a button group's end buttons)
|
|
58
|
+
* @property {Record<string, Record<string, string>>} [inline] - state ('' for always) -> property -> the token Core paints it with as an inline style, which no theme rule can replace
|
|
42
59
|
*/
|
|
43
60
|
|
|
44
61
|
/**
|
|
@@ -177,7 +194,8 @@ export function isItemOf(project, name) {
|
|
|
177
194
|
* A component's catalog entries, all from its doc: its demo props
|
|
178
195
|
* ({@link demoProps}), then once per value of each visual prop with a
|
|
179
196
|
* closed set of values (`variant`, `status`, `color`, and a number union
|
|
180
|
-
* such as a heading's level),
|
|
197
|
+
* such as a heading's level), its checked and disabled states, and each look
|
|
198
|
+
* flag (`isStriped`) turned on. An
|
|
181
199
|
* overlay the playground shows in place renders open; on a page people
|
|
182
200
|
* see, once, as some of its variants size the window, not the card.
|
|
183
201
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -223,6 +241,12 @@ export function catalogVariants(project, name, cap, opts = {}) {
|
|
|
223
241
|
// The states the doc names that a prop sets: checked (a boolean value)
|
|
224
242
|
// and disabled. The label says the state shown.
|
|
225
243
|
const states = new Set(info.targets.flatMap(t => t.states ?? []));
|
|
244
|
+
// A value the doc lists beside true and false (a checkbox's
|
|
245
|
+
// 'indeterminate'): rendered too, so the look Core gives it is read.
|
|
246
|
+
if (states.has('checked'))
|
|
247
|
+
for (const word of literals(info.props?.value?.type ?? ''))
|
|
248
|
+
if (word !== 'true' && word !== 'false')
|
|
249
|
+
variants.push({label: word, props: {...base, value: word}});
|
|
226
250
|
if (states.has('checked') && info.props?.value?.type.startsWith('boolean')) {
|
|
227
251
|
const on = base.value !== true;
|
|
228
252
|
variants.push({
|
|
@@ -243,6 +267,17 @@ export function catalogVariants(project, name, cap, opts = {}) {
|
|
|
243
267
|
if (n !== base[p])
|
|
244
268
|
variants.push({label: `${p} ${n}`, props: {...base, [p]: n}});
|
|
245
269
|
}
|
|
270
|
+
// Each look flag the doc names (`isStriped`, `hasHover`), turned on, so
|
|
271
|
+
// the styles Core gives only under it are read too: a table row's hover
|
|
272
|
+
// and stripes come from its table's flags.
|
|
273
|
+
for (const [p, doc] of Object.entries(info.props ?? {}))
|
|
274
|
+
if (
|
|
275
|
+
/^(is|has)[A-Z]/.test(p) &&
|
|
276
|
+
!LIFECYCLE_FLAGS.has(p) &&
|
|
277
|
+
String(/** @type {any} */ (doc)?.type ?? '').trim() === 'boolean' &&
|
|
278
|
+
base[p] !== true
|
|
279
|
+
)
|
|
280
|
+
variants.push({label: p, props: {...base, [p]: true}});
|
|
246
281
|
return variants.slice(0, cap);
|
|
247
282
|
}
|
|
248
283
|
|
|
@@ -367,14 +402,9 @@ export async function renderGenerated(project, file, source, extra = []) {
|
|
|
367
402
|
);
|
|
368
403
|
})();
|
|
369
404
|
fs.mkdirSync(dir, {recursive: true});
|
|
370
|
-
// Stopped by a signal, the render folder
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
cleanup();
|
|
374
|
-
process.kill(process.pid, sig);
|
|
375
|
-
};
|
|
376
|
-
process.once('SIGINT', onSignal);
|
|
377
|
-
process.once('SIGTERM', onSignal);
|
|
405
|
+
// Stopped by a signal (the terminal closing too), the render folder
|
|
406
|
+
// still goes.
|
|
407
|
+
const untrack = removeOnStop(dir);
|
|
378
408
|
const entry = path.join(dir, file);
|
|
379
409
|
// Demo images point at the docs site's own folder (`/template-assets/…`),
|
|
380
410
|
// which a page opened from disk cannot reach: the inline placeholder
|
|
@@ -430,8 +460,7 @@ export async function renderGenerated(project, file, source, extra = []) {
|
|
|
430
460
|
fs.rmSync(f, {force: true});
|
|
431
461
|
// Another render may still use it: a folder with a file in it stays.
|
|
432
462
|
removeEmptyFolder(madeThemes ? themes : dir, {deep: true});
|
|
433
|
-
|
|
434
|
-
process.removeListener('SIGTERM', onSignal);
|
|
463
|
+
untrack();
|
|
435
464
|
}
|
|
436
465
|
}
|
|
437
466
|
|
|
@@ -473,6 +502,141 @@ export async function partData(project) {
|
|
|
473
502
|
return data;
|
|
474
503
|
}
|
|
475
504
|
|
|
505
|
+
/** The tokens Core's indicator focus ring is drawn from, per property. */
|
|
506
|
+
const RING_TOKENS = {
|
|
507
|
+
'outline-width': '--focus-outline-width',
|
|
508
|
+
'outline-style': '--focus-outline-style',
|
|
509
|
+
'outline-color': '--focus-outline-color',
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Add the focus ring a control draws on its indicator at focus time (Core's
|
|
514
|
+
* `useIndicatorFocusRing`, used by a control whose input is visually
|
|
515
|
+
* hidden): an inline style the server render never shows, read from the
|
|
516
|
+
* focus outline tokens. The tokens are read by the indicator always (it
|
|
517
|
+
* never takes focus itself, so no state reaches the ring), and the outline
|
|
518
|
+
* properties are painted inline, which no theme rule can replace. The
|
|
519
|
+
* indicator is the control's own `-indicator` target, or for a part of
|
|
520
|
+
* another component (a radio list's item), that component's.
|
|
521
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
522
|
+
* @param {Record<string, PartRecord>} map
|
|
523
|
+
*/
|
|
524
|
+
function addIndicatorRings(project, map) {
|
|
525
|
+
for (const [name, info] of Object.entries(project.components)) {
|
|
526
|
+
const at = info.importPath?.split('/').pop();
|
|
527
|
+
let source;
|
|
528
|
+
try {
|
|
529
|
+
source = at
|
|
530
|
+
? fs.readFileSync(
|
|
531
|
+
path.join(project.coreDir, 'dist', at, `${name}.js`),
|
|
532
|
+
'utf8',
|
|
533
|
+
)
|
|
534
|
+
: '';
|
|
535
|
+
} catch {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (!source.includes('useIndicatorFocusRing')) continue;
|
|
539
|
+
/** @param {import('./_project.mjs').ComponentInfo | undefined} c */
|
|
540
|
+
const indicators = c =>
|
|
541
|
+
(c?.targets ?? [])
|
|
542
|
+
.map(t => t.className.replace(/^astryx-/, ''))
|
|
543
|
+
.filter(k => k.endsWith('-indicator'));
|
|
544
|
+
const own = indicators(info);
|
|
545
|
+
const keys = own.length
|
|
546
|
+
? own
|
|
547
|
+
: indicators(
|
|
548
|
+
info.subComponentOf
|
|
549
|
+
? project.components[info.subComponentOf]
|
|
550
|
+
: undefined,
|
|
551
|
+
);
|
|
552
|
+
for (const key of keys) {
|
|
553
|
+
const rec = (map[key] ??= {
|
|
554
|
+
own: {},
|
|
555
|
+
inside: {},
|
|
556
|
+
attrs: {},
|
|
557
|
+
contains: [],
|
|
558
|
+
});
|
|
559
|
+
for (const [prop, token] of Object.entries(RING_TOKENS)) {
|
|
560
|
+
rec.inside[token] = [...new Set([...(rec.inside[token] ?? []), prop])];
|
|
561
|
+
(rec.inline ??= {})[''] = {...rec.inline?.[''], [prop]: token};
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Add the paint Core writes as an inline style when it sets a theme state
|
|
569
|
+
* at run time (a table row's selection wash, set by the selection plugin
|
|
570
|
+
* beside the row's `selected` state): something the server render never
|
|
571
|
+
* shows. A built module under a component's folder that writes a state's
|
|
572
|
+
* attribute (`themeDataAttributes({selected: 'selected'})`) and an inline
|
|
573
|
+
* property from a color token (`el.style.backgroundColor = …` with
|
|
574
|
+
* `colorVars['--color-accent-muted']`) paints that state with it, on each
|
|
575
|
+
* of the component's targets that lists the state.
|
|
576
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
577
|
+
* @param {Record<string, PartRecord>} map
|
|
578
|
+
*/
|
|
579
|
+
function addInlineStatePaint(project, map) {
|
|
580
|
+
const dist = path.join(project.coreDir, 'dist');
|
|
581
|
+
/** @param {string} dir @returns {string[]} */
|
|
582
|
+
const modules = dir => {
|
|
583
|
+
let entries;
|
|
584
|
+
try {
|
|
585
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
586
|
+
} catch {
|
|
587
|
+
return [];
|
|
588
|
+
}
|
|
589
|
+
return entries.flatMap(e =>
|
|
590
|
+
e.isDirectory()
|
|
591
|
+
? modules(path.join(dir, e.name))
|
|
592
|
+
: e.name.endsWith('.js')
|
|
593
|
+
? [path.join(dir, e.name)]
|
|
594
|
+
: [],
|
|
595
|
+
);
|
|
596
|
+
};
|
|
597
|
+
for (const [name, info] of Object.entries(project.components)) {
|
|
598
|
+
const folder = info.importPath?.split('/').pop();
|
|
599
|
+
if (!folder || folder !== name) continue;
|
|
600
|
+
const withStates = info.targets.filter(t => t.states.length);
|
|
601
|
+
if (!withStates.length) continue;
|
|
602
|
+
for (const file of modules(path.join(dist, folder))) {
|
|
603
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
604
|
+
const states = [
|
|
605
|
+
...source.matchAll(
|
|
606
|
+
/themeDataAttributes\(\{\s*([\w-]+):\s*'\1'\s*\}\)/g,
|
|
607
|
+
),
|
|
608
|
+
].map(m => m[1]);
|
|
609
|
+
if (!states.length) continue;
|
|
610
|
+
const props = [
|
|
611
|
+
...source.matchAll(/\.style\.([a-z][A-Za-z]*)\s*=(?!=)/g),
|
|
612
|
+
].map(m => m[1].replace(/[A-Z]/g, c => `-${c.toLowerCase()}`));
|
|
613
|
+
const colorTokens = [
|
|
614
|
+
...source.matchAll(/colorVars\[['"](--color-[\w-]+)['"]\]/g),
|
|
615
|
+
].map(m => m[1]);
|
|
616
|
+
if (!props.length || colorTokens.length !== 1) continue;
|
|
617
|
+
for (const t of withStates) {
|
|
618
|
+
const key = t.className.replace(/^astryx-/, '');
|
|
619
|
+
const rec = map[key];
|
|
620
|
+
if (!rec) continue;
|
|
621
|
+
for (const state of states.filter(st => t.states.includes(st)))
|
|
622
|
+
for (const prop of props) {
|
|
623
|
+
(rec.inline ??= {})[state] = {
|
|
624
|
+
...rec.inline?.[state],
|
|
625
|
+
[prop]: colorTokens[0],
|
|
626
|
+
};
|
|
627
|
+
const own = (rec.own[prop] ??= {tokens: {}, values: []});
|
|
628
|
+
own.tokens[colorTokens[0]] = [
|
|
629
|
+
...new Set([
|
|
630
|
+
...(own.tokens[colorTokens[0]] ?? []),
|
|
631
|
+
`${state}=${state}`,
|
|
632
|
+
]),
|
|
633
|
+
];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
476
640
|
/**
|
|
477
641
|
* Build the part data: render the catalog, then walk its markup.
|
|
478
642
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -497,6 +661,8 @@ async function buildPartData(project) {
|
|
|
497
661
|
}
|
|
498
662
|
const tokens = new Set(Object.keys(project.core.tokenDefaults ?? {}));
|
|
499
663
|
const result = walkMarkup(markup, declarations(css), tokens);
|
|
664
|
+
addInlineStatePaint(project, result.map);
|
|
665
|
+
addIndicatorRings(project, result.map);
|
|
500
666
|
return {
|
|
501
667
|
version: PART_DATA_VERSION,
|
|
502
668
|
coreKey: project.coreKey,
|
|
@@ -666,6 +832,24 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
666
832
|
return out;
|
|
667
833
|
}
|
|
668
834
|
|
|
835
|
+
/**
|
|
836
|
+
* A value with the private variables set on the element or its ancestors
|
|
837
|
+
* put in (a variable with no fallback only), so it reads public tokens and
|
|
838
|
+
* literal values alone where it can.
|
|
839
|
+
* @param {string} v
|
|
840
|
+
* @param {Record<string, string>} env
|
|
841
|
+
* @param {Set<string>} tokens
|
|
842
|
+
* @param {number} [depth]
|
|
843
|
+
* @returns {string}
|
|
844
|
+
*/
|
|
845
|
+
function resolvePrivate(v, env, tokens, depth = 0) {
|
|
846
|
+
if (depth > 8) return v;
|
|
847
|
+
const out = v.replace(/var\((--[a-zA-Z0-9_-]+)\)/g, (m, name) =>
|
|
848
|
+
!tokens.has(name) && env[name] != null ? env[name] : m,
|
|
849
|
+
);
|
|
850
|
+
return out === v ? v : resolvePrivate(out, env, tokens, depth + 1);
|
|
851
|
+
}
|
|
852
|
+
|
|
669
853
|
/**
|
|
670
854
|
* Walk server-rendered markup: for each element, its classes' declarations
|
|
671
855
|
* become what its part reads; text records the color pair it sits on.
|
|
@@ -675,7 +859,7 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
675
859
|
* @returns {{map: Record<string, PartRecord>, pairs: TextPair[]}}
|
|
676
860
|
*/
|
|
677
861
|
export function walkMarkup(html, decls, tokens) {
|
|
678
|
-
/** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>}>} */
|
|
862
|
+
/** @type {Record<string, {own: Record<string, {tokens: Record<string, Set<string>>, values: Set<string>}>, at: Record<string, Record<string, string>>, inside: Record<string, Set<string>>, attrs: Record<string, Set<string>>, contains: Set<string>, tags: Set<string>, innerCorners: Set<string>}>} */
|
|
679
863
|
const map = {};
|
|
680
864
|
/** @type {Array<{env: Record<string, string>, target: string | null, fg: PaintSide | null, bg: PaintSide | null}>} */
|
|
681
865
|
const stack = [{env: {}, target: null, fg: null, bg: null}];
|
|
@@ -709,10 +893,21 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
709
893
|
const dataAttrs = Object.fromEntries(
|
|
710
894
|
[
|
|
711
895
|
...attrs.matchAll(
|
|
712
|
-
/data-(variant|status|size|selected|state|elevation|tone|color|level|weight)="([^"]*)"/g,
|
|
896
|
+
/data-(variant|status|size|selected|state|elevation|tone|color|level|weight|checked)="([^"]*)"/g,
|
|
713
897
|
),
|
|
714
898
|
].map(x => [x[1], x[2]]),
|
|
715
899
|
);
|
|
900
|
+
// The place another component puts a part in (the current page's
|
|
901
|
+
// button in a pagination, a pressed toggle) is a condition of what that
|
|
902
|
+
// component styles it with there, never the part's look at rest. A part
|
|
903
|
+
// that marks the place with a theme state of its own (a selected tab)
|
|
904
|
+
// is conditioned by that state already.
|
|
905
|
+
const ownState = ['selected', 'checked', 'state'].some(k => k in dataAttrs);
|
|
906
|
+
const context = ownState
|
|
907
|
+
? []
|
|
908
|
+
: [...attrs.matchAll(/\baria-(current|pressed)="([^"]*)"/g)]
|
|
909
|
+
.filter(x => x[2] !== 'false')
|
|
910
|
+
.map(x => `${x[1]}=${x[2]}`);
|
|
716
911
|
const parent = stack[stack.length - 1];
|
|
717
912
|
const env = {...parent.env};
|
|
718
913
|
const own = cls.flatMap(c => decls.get(c) ?? []);
|
|
@@ -723,25 +918,39 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
723
918
|
);
|
|
724
919
|
const target = named[0]?.slice(7) ?? parent.target;
|
|
725
920
|
const ownsTarget = named.length > 0;
|
|
726
|
-
|
|
727
|
-
|
|
921
|
+
// An element can carry several targets (a shell's side nav region is a
|
|
922
|
+
// layout panel too): its declarations are each one's own.
|
|
923
|
+
for (const t of ownsTarget ? named.map(c => c.slice(7)) : [target]) {
|
|
924
|
+
if (!t) continue;
|
|
925
|
+
const T = (map[t] ??= {
|
|
728
926
|
own: {},
|
|
927
|
+
at: {},
|
|
729
928
|
inside: {},
|
|
730
929
|
attrs: {},
|
|
731
930
|
contains: new Set(),
|
|
931
|
+
tags: new Set(),
|
|
932
|
+
innerCorners: new Set(),
|
|
732
933
|
});
|
|
733
934
|
if (ownsTarget)
|
|
734
935
|
for (const [k, v] of Object.entries(dataAttrs))
|
|
735
936
|
(T.attrs[k] ??= new Set()).add(v);
|
|
736
|
-
const cond0 =
|
|
737
|
-
.map(([k, v]) => `${k}=${v}`)
|
|
738
|
-
|
|
937
|
+
const cond0 = [
|
|
938
|
+
...Object.entries(dataAttrs).map(([k, v]) => `${k}=${v}`),
|
|
939
|
+
...context,
|
|
940
|
+
].join(',');
|
|
739
941
|
for (const d of own) {
|
|
740
942
|
if (d.prop.startsWith('--')) continue;
|
|
943
|
+
// (An inherited background paints nothing of its own: it reads no
|
|
944
|
+
// token, and what shows is its parent's.)
|
|
741
945
|
const toks = expand(d.value, env, tokens);
|
|
742
946
|
const cond = [cond0, d.cond].filter(Boolean).join(' ');
|
|
743
947
|
if (ownsTarget) {
|
|
744
948
|
const P = (T.own[d.prop] ??= {tokens: {}, values: new Set()});
|
|
949
|
+
(T.at[d.prop] ??= {})[cond || 'always'] ??= resolvePrivate(
|
|
950
|
+
d.value,
|
|
951
|
+
env,
|
|
952
|
+
tokens,
|
|
953
|
+
);
|
|
745
954
|
P.values.add(
|
|
746
955
|
d.value.length > 80 ? `${d.value.slice(0, 80)}...` : d.value,
|
|
747
956
|
);
|
|
@@ -763,14 +972,25 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
763
972
|
}
|
|
764
973
|
if (d.prop === 'background-color') {
|
|
765
974
|
const t = [...expand(d.value, env, tokens)];
|
|
766
|
-
if (t.length || !/transparent
|
|
975
|
+
if (t.length || !/transparent|^\s*inherit\s*$/i.test(d.value))
|
|
767
976
|
bg = {target, tokens: t, raw: t.length ? null : d.value};
|
|
768
977
|
}
|
|
769
978
|
}
|
|
770
|
-
|
|
979
|
+
for (const t of ownsTarget ? named.map(c => c.slice(7)) : [])
|
|
771
980
|
for (const anc of stack)
|
|
772
|
-
if (anc.target && anc.target !== target)
|
|
773
|
-
|
|
981
|
+
if (anc.target && anc.target !== t) map[anc.target].contains.add(t);
|
|
982
|
+
if (ownsTarget) {
|
|
983
|
+
for (const t of named) map[t.slice(7)].tags.add(tag.toLowerCase());
|
|
984
|
+
// Corners Core draws on a part by its place among its siblings (a
|
|
985
|
+
// button group's first and last buttons): the radius token they read
|
|
986
|
+
// is the enclosing part's corners.
|
|
987
|
+
if (parent.target && !named.includes(`astryx-${parent.target}`))
|
|
988
|
+
for (const d of own)
|
|
989
|
+
if (/^border-(start|end)-(start|end)-radius$/.test(d.prop))
|
|
990
|
+
for (const tok of expand(d.value, env, tokens))
|
|
991
|
+
if (/^--radius-/.test(tok))
|
|
992
|
+
map[parent.target].innerCorners.add(tok);
|
|
993
|
+
}
|
|
774
994
|
if (!selfClose && !VOID.has(tag.toLowerCase()))
|
|
775
995
|
stack.push({env, target, fg, bg});
|
|
776
996
|
}
|
|
@@ -792,6 +1012,7 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
792
1012
|
},
|
|
793
1013
|
]),
|
|
794
1014
|
),
|
|
1015
|
+
at: v.at,
|
|
795
1016
|
inside: Object.fromEntries(
|
|
796
1017
|
Object.entries(v.inside).map(([k, s]) => [k, [...s]]),
|
|
797
1018
|
),
|
|
@@ -799,6 +1020,8 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
799
1020
|
Object.entries(v.attrs).map(([k, s]) => [k, [...s]]),
|
|
800
1021
|
),
|
|
801
1022
|
contains: [...v.contains],
|
|
1023
|
+
tags: [...v.tags],
|
|
1024
|
+
innerCorners: [...v.innerCorners],
|
|
802
1025
|
};
|
|
803
1026
|
}
|
|
804
1027
|
return {map: out, pairs: [...pairs.values()]};
|
|
@@ -68,12 +68,18 @@ export function refreshPreviewRoute(cwd: string, slug: string): Promise<{
|
|
|
68
68
|
* @param {'colors' | 'components' | 'overview'} focus
|
|
69
69
|
* @param {{code: string, cause: string} | null} [notChecked] why the change
|
|
70
70
|
* could not be rendered
|
|
71
|
+
* @param {{pictureProblem?: string | null, stale?: string[]}} [extra] this
|
|
72
|
+
* result's picture problem (what kept --png from taking pictures) and its
|
|
73
|
+
* previewStale entries (an in-app preview changed by hand)
|
|
71
74
|
* @returns {string}
|
|
72
75
|
*/
|
|
73
76
|
export function seeLine(cwd: string, slug: string, focus: "colors" | "components" | "overview", notChecked?: {
|
|
74
77
|
code: string;
|
|
75
78
|
cause: string;
|
|
76
|
-
} | null
|
|
79
|
+
} | null, extra?: {
|
|
80
|
+
pictureProblem?: string | null;
|
|
81
|
+
stale?: string[];
|
|
82
|
+
}): string;
|
|
77
83
|
/**
|
|
78
84
|
* Add pages to the in-app theme preview, and write the preview route the
|
|
79
85
|
* first time. With a description, the build ranking picks the template
|