@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f
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 +75 -0
- package/api/theme/build/build.mjs +243 -58
- package/api/theme/build/font-warning.d.mts +7 -0
- package/api/theme/build/font-warning.mjs +17 -0
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +63 -2
- package/api/theme-edit/_adapter.mjs +771 -57
- package/api/theme-edit/_check.d.mts +40 -22
- package/api/theme-edit/_check.mjs +2029 -336
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +49 -1
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.d.mts +3 -3
- package/api/theme-edit/_context.mjs +111 -48
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +18 -4
- package/api/theme-edit/_edit.mjs +1685 -155
- package/api/theme-edit/_how-commands.d.mts +65 -0
- package/api/theme-edit/_how-commands.mjs +633 -1
- package/api/theme-edit/_how-question.d.mts +84 -0
- package/api/theme-edit/_how-question.mjs +5124 -281
- package/api/theme-edit/_how.mjs +140 -29
- 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 +257 -0
- package/api/theme-edit/_normal.mjs +1252 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +10 -1
- package/api/theme-edit/_parts.mjs +179 -3
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +515 -148
- package/api/theme-edit/_preview.d.mts +100 -14
- package/api/theme-edit/_preview.mjs +549 -137
- package/api/theme-edit/_settings.d.mts +347 -30
- package/api/theme-edit/_settings.mjs +2971 -327
- package/api/theme-edit/_tables.d.mts +6 -0
- package/api/theme-edit/_tables.mjs +44 -1
- package/api/theme-edit/_vet.d.mts +18 -0
- package/api/theme-edit/_vet.mjs +32 -0
- 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 +2 -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 +163 -28
- 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 +209 -8
- 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 +77 -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 +52 -0
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +3 -2
- 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/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +164 -55
- 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/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 +316 -42
- 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
|
|
@@ -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,10 @@ export type PartRecord = {
|
|
|
154
159
|
* - parts rendered inside it
|
|
155
160
|
*/
|
|
156
161
|
contains: string[];
|
|
162
|
+
/**
|
|
163
|
+
* - state -> property -> the token Core paints it with as an inline style in that state, which outranks any theme rule
|
|
164
|
+
*/
|
|
165
|
+
inline?: Record<string, Record<string, string>> | undefined;
|
|
157
166
|
};
|
|
158
167
|
export type PaintSide = {
|
|
159
168
|
target: string | null;
|
|
@@ -31,14 +31,28 @@ import {
|
|
|
31
31
|
import {SAMPLE_PAGE, elementNames, pageSource} from './_catalog.mjs';
|
|
32
32
|
|
|
33
33
|
/** Bump when the shape of the cached part data changes. */
|
|
34
|
-
const PART_DATA_VERSION =
|
|
34
|
+
const PART_DATA_VERSION = 7;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Flags that change what a component does or whether it shows, not how it
|
|
38
|
+
* looks: the catalog never turns them on (disabled has its own entry).
|
|
39
|
+
*/
|
|
40
|
+
const LIFECYCLE_FLAGS = new Set([
|
|
41
|
+
'isDisabled',
|
|
42
|
+
'isOpen',
|
|
43
|
+
'isDefaultOpen',
|
|
44
|
+
'hasAutoFocus',
|
|
45
|
+
'isHidden',
|
|
46
|
+
]);
|
|
35
47
|
|
|
36
48
|
/**
|
|
37
49
|
* @typedef {object} PartRecord
|
|
38
50
|
* @property {Record<string, {tokens: Record<string, string[]>, values: string[]}>} own - property -> tokens (with conditions) and raw values
|
|
51
|
+
* @property {Record<string, Record<string, string>>} [at] - property -> the value under each condition, private variables resolved
|
|
39
52
|
* @property {Record<string, string[]>} inside - tokens read by unnamed elements inside the part -> properties
|
|
40
53
|
* @property {Record<string, string[]>} attrs - data attributes seen on the part
|
|
41
54
|
* @property {string[]} contains - parts rendered inside it
|
|
55
|
+
* @property {Record<string, Record<string, string>>} [inline] - state -> property -> the token Core paints it with as an inline style in that state, which outranks any theme rule
|
|
42
56
|
*/
|
|
43
57
|
|
|
44
58
|
/**
|
|
@@ -177,7 +191,8 @@ export function isItemOf(project, name) {
|
|
|
177
191
|
* A component's catalog entries, all from its doc: its demo props
|
|
178
192
|
* ({@link demoProps}), then once per value of each visual prop with a
|
|
179
193
|
* closed set of values (`variant`, `status`, `color`, and a number union
|
|
180
|
-
* such as a heading's level),
|
|
194
|
+
* such as a heading's level), its checked and disabled states, and each look
|
|
195
|
+
* flag (`isStriped`) turned on. An
|
|
181
196
|
* overlay the playground shows in place renders open; on a page people
|
|
182
197
|
* see, once, as some of its variants size the window, not the card.
|
|
183
198
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -243,6 +258,17 @@ export function catalogVariants(project, name, cap, opts = {}) {
|
|
|
243
258
|
if (n !== base[p])
|
|
244
259
|
variants.push({label: `${p} ${n}`, props: {...base, [p]: n}});
|
|
245
260
|
}
|
|
261
|
+
// Each look flag the doc names (`isStriped`, `hasHover`), turned on, so
|
|
262
|
+
// the styles Core gives only under it are read too: a table row's hover
|
|
263
|
+
// and stripes come from its table's flags.
|
|
264
|
+
for (const [p, doc] of Object.entries(info.props ?? {}))
|
|
265
|
+
if (
|
|
266
|
+
/^(is|has)[A-Z]/.test(p) &&
|
|
267
|
+
!LIFECYCLE_FLAGS.has(p) &&
|
|
268
|
+
String(/** @type {any} */ (doc)?.type ?? '').trim() === 'boolean' &&
|
|
269
|
+
base[p] !== true
|
|
270
|
+
)
|
|
271
|
+
variants.push({label: p, props: {...base, [p]: true}});
|
|
246
272
|
return variants.slice(0, cap);
|
|
247
273
|
}
|
|
248
274
|
|
|
@@ -473,6 +499,129 @@ export async function partData(project) {
|
|
|
473
499
|
return data;
|
|
474
500
|
}
|
|
475
501
|
|
|
502
|
+
/** The tokens Core's indicator focus ring is drawn from, per property. */
|
|
503
|
+
const RING_TOKENS = {
|
|
504
|
+
'outline-width': '--focus-outline-width',
|
|
505
|
+
'outline-style': '--focus-outline-style',
|
|
506
|
+
'outline-color': '--focus-outline-color',
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Add the focus ring a control draws on its indicator at focus time (Core's
|
|
511
|
+
* `useIndicatorFocusRing`, used by a control whose input is visually
|
|
512
|
+
* hidden): an inline style the server render never shows, read from the
|
|
513
|
+
* focus outline tokens on the control's own `-indicator` part.
|
|
514
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
515
|
+
* @param {Record<string, PartRecord>} map
|
|
516
|
+
*/
|
|
517
|
+
function addIndicatorRings(project, map) {
|
|
518
|
+
for (const [name, info] of Object.entries(project.components)) {
|
|
519
|
+
const at = info.importPath?.split('/').pop();
|
|
520
|
+
let source;
|
|
521
|
+
try {
|
|
522
|
+
source = at
|
|
523
|
+
? fs.readFileSync(
|
|
524
|
+
path.join(project.coreDir, 'dist', at, `${name}.js`),
|
|
525
|
+
'utf8',
|
|
526
|
+
)
|
|
527
|
+
: '';
|
|
528
|
+
} catch {
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
if (!source.includes('useIndicatorFocusRing')) continue;
|
|
532
|
+
for (const t of info.targets) {
|
|
533
|
+
const key = t.className.replace(/^astryx-/, '');
|
|
534
|
+
if (!key.endsWith('-indicator')) continue;
|
|
535
|
+
const rec = (map[key] ??= {
|
|
536
|
+
own: {},
|
|
537
|
+
inside: {},
|
|
538
|
+
attrs: {},
|
|
539
|
+
contains: [],
|
|
540
|
+
});
|
|
541
|
+
for (const [prop, token] of Object.entries(RING_TOKENS)) {
|
|
542
|
+
const p = (rec.own[prop] ??= {tokens: {}, values: []});
|
|
543
|
+
p.tokens[token] = [
|
|
544
|
+
...new Set([...(p.tokens[token] ?? []), ':focus-visible']),
|
|
545
|
+
];
|
|
546
|
+
if (!p.values.includes(`var(${token})`)) p.values.push(`var(${token})`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Add the paint Core writes as an inline style when it sets a theme state
|
|
554
|
+
* at run time (a table row's selection wash, set by the selection plugin
|
|
555
|
+
* beside the row's `selected` state): something the server render never
|
|
556
|
+
* shows. A built module under a component's folder that writes a state's
|
|
557
|
+
* attribute (`themeDataAttributes({selected: 'selected'})`) and an inline
|
|
558
|
+
* property from a color token (`el.style.backgroundColor = …` with
|
|
559
|
+
* `colorVars['--color-accent-muted']`) paints that state with it, on each
|
|
560
|
+
* of the component's targets that lists the state.
|
|
561
|
+
* @param {import('./_project.mjs').ThemeProject} project
|
|
562
|
+
* @param {Record<string, PartRecord>} map
|
|
563
|
+
*/
|
|
564
|
+
function addInlineStatePaint(project, map) {
|
|
565
|
+
const dist = path.join(project.coreDir, 'dist');
|
|
566
|
+
/** @param {string} dir @returns {string[]} */
|
|
567
|
+
const modules = dir => {
|
|
568
|
+
let entries;
|
|
569
|
+
try {
|
|
570
|
+
entries = fs.readdirSync(dir, {withFileTypes: true});
|
|
571
|
+
} catch {
|
|
572
|
+
return [];
|
|
573
|
+
}
|
|
574
|
+
return entries.flatMap(e =>
|
|
575
|
+
e.isDirectory()
|
|
576
|
+
? modules(path.join(dir, e.name))
|
|
577
|
+
: e.name.endsWith('.js')
|
|
578
|
+
? [path.join(dir, e.name)]
|
|
579
|
+
: [],
|
|
580
|
+
);
|
|
581
|
+
};
|
|
582
|
+
for (const [name, info] of Object.entries(project.components)) {
|
|
583
|
+
const folder = info.importPath?.split('/').pop();
|
|
584
|
+
if (!folder || folder !== name) continue;
|
|
585
|
+
const withStates = info.targets.filter(t => t.states.length);
|
|
586
|
+
if (!withStates.length) continue;
|
|
587
|
+
for (const file of modules(path.join(dist, folder))) {
|
|
588
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
589
|
+
const states = [
|
|
590
|
+
...source.matchAll(
|
|
591
|
+
/themeDataAttributes\(\{\s*([\w-]+):\s*'\1'\s*\}\)/g,
|
|
592
|
+
),
|
|
593
|
+
].map(m => m[1]);
|
|
594
|
+
if (!states.length) continue;
|
|
595
|
+
const props = [
|
|
596
|
+
...source.matchAll(/\.style\.([a-z][A-Za-z]*)\s*=(?!=)/g),
|
|
597
|
+
].map(m => m[1].replace(/[A-Z]/g, c => `-${c.toLowerCase()}`));
|
|
598
|
+
const colorTokens = [
|
|
599
|
+
...source.matchAll(/colorVars\[['"](--color-[\w-]+)['"]\]/g),
|
|
600
|
+
].map(m => m[1]);
|
|
601
|
+
if (!props.length || colorTokens.length !== 1) continue;
|
|
602
|
+
for (const t of withStates) {
|
|
603
|
+
const key = t.className.replace(/^astryx-/, '');
|
|
604
|
+
const rec = map[key];
|
|
605
|
+
if (!rec) continue;
|
|
606
|
+
for (const state of states.filter(st => t.states.includes(st)))
|
|
607
|
+
for (const prop of props) {
|
|
608
|
+
(rec.inline ??= {})[state] = {
|
|
609
|
+
...rec.inline?.[state],
|
|
610
|
+
[prop]: colorTokens[0],
|
|
611
|
+
};
|
|
612
|
+
const own = (rec.own[prop] ??= {tokens: {}, values: []});
|
|
613
|
+
own.tokens[colorTokens[0]] = [
|
|
614
|
+
...new Set([
|
|
615
|
+
...(own.tokens[colorTokens[0]] ?? []),
|
|
616
|
+
`${state}=${state}`,
|
|
617
|
+
]),
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
476
625
|
/**
|
|
477
626
|
* Build the part data: render the catalog, then walk its markup.
|
|
478
627
|
* @param {import('./_project.mjs').ThemeProject} project
|
|
@@ -497,6 +646,8 @@ async function buildPartData(project) {
|
|
|
497
646
|
}
|
|
498
647
|
const tokens = new Set(Object.keys(project.core.tokenDefaults ?? {}));
|
|
499
648
|
const result = walkMarkup(markup, declarations(css), tokens);
|
|
649
|
+
addInlineStatePaint(project, result.map);
|
|
650
|
+
addIndicatorRings(project, result.map);
|
|
500
651
|
return {
|
|
501
652
|
version: PART_DATA_VERSION,
|
|
502
653
|
coreKey: project.coreKey,
|
|
@@ -666,6 +817,24 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
666
817
|
return out;
|
|
667
818
|
}
|
|
668
819
|
|
|
820
|
+
/**
|
|
821
|
+
* A value with the private variables set on the element or its ancestors
|
|
822
|
+
* put in (a variable with no fallback only), so it reads public tokens and
|
|
823
|
+
* literal values alone where it can.
|
|
824
|
+
* @param {string} v
|
|
825
|
+
* @param {Record<string, string>} env
|
|
826
|
+
* @param {Set<string>} tokens
|
|
827
|
+
* @param {number} [depth]
|
|
828
|
+
* @returns {string}
|
|
829
|
+
*/
|
|
830
|
+
function resolvePrivate(v, env, tokens, depth = 0) {
|
|
831
|
+
if (depth > 8) return v;
|
|
832
|
+
const out = v.replace(/var\((--[a-zA-Z0-9_-]+)\)/g, (m, name) =>
|
|
833
|
+
!tokens.has(name) && env[name] != null ? env[name] : m,
|
|
834
|
+
);
|
|
835
|
+
return out === v ? v : resolvePrivate(out, env, tokens, depth + 1);
|
|
836
|
+
}
|
|
837
|
+
|
|
669
838
|
/**
|
|
670
839
|
* Walk server-rendered markup: for each element, its classes' declarations
|
|
671
840
|
* become what its part reads; text records the color pair it sits on.
|
|
@@ -675,7 +844,7 @@ function expand(v, env, tokens, seen = new Set(), depth = 0) {
|
|
|
675
844
|
* @returns {{map: Record<string, PartRecord>, pairs: TextPair[]}}
|
|
676
845
|
*/
|
|
677
846
|
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>}>} */
|
|
847
|
+
/** @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>}>} */
|
|
679
848
|
const map = {};
|
|
680
849
|
/** @type {Array<{env: Record<string, string>, target: string | null, fg: PaintSide | null, bg: PaintSide | null}>} */
|
|
681
850
|
const stack = [{env: {}, target: null, fg: null, bg: null}];
|
|
@@ -726,6 +895,7 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
726
895
|
if (target) {
|
|
727
896
|
const T = (map[target] ??= {
|
|
728
897
|
own: {},
|
|
898
|
+
at: {},
|
|
729
899
|
inside: {},
|
|
730
900
|
attrs: {},
|
|
731
901
|
contains: new Set(),
|
|
@@ -742,6 +912,11 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
742
912
|
const cond = [cond0, d.cond].filter(Boolean).join(' ');
|
|
743
913
|
if (ownsTarget) {
|
|
744
914
|
const P = (T.own[d.prop] ??= {tokens: {}, values: new Set()});
|
|
915
|
+
(T.at[d.prop] ??= {})[cond || 'always'] ??= resolvePrivate(
|
|
916
|
+
d.value,
|
|
917
|
+
env,
|
|
918
|
+
tokens,
|
|
919
|
+
);
|
|
745
920
|
P.values.add(
|
|
746
921
|
d.value.length > 80 ? `${d.value.slice(0, 80)}...` : d.value,
|
|
747
922
|
);
|
|
@@ -792,6 +967,7 @@ export function walkMarkup(html, decls, tokens) {
|
|
|
792
967
|
},
|
|
793
968
|
]),
|
|
794
969
|
),
|
|
970
|
+
at: v.at,
|
|
795
971
|
inside: Object.fromEntries(
|
|
796
972
|
Object.entries(v.inside).map(([k, s]) => [k, [...s]]),
|
|
797
973
|
),
|
|
@@ -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
|