@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
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 +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- 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 +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -293,6 +293,7 @@ export function tempFor(file) {
|
|
|
293
293
|
* @property {boolean} pass
|
|
294
294
|
* @property {string} [note] - The whole sentence to report, when the check is not a plain stop move.
|
|
295
295
|
* @property {string[]} [dials] - The color dials whose notes report it, when its token belongs to none of them.
|
|
296
|
+
* @property {{thing: string, value: string, mode?: Mode}} [fix] - The nearest setting that passes it, when one does: a darker exact color for a pale fill.
|
|
296
297
|
*/
|
|
297
298
|
|
|
298
299
|
/**
|
|
@@ -511,11 +512,20 @@ export const LIFT_PARTS = OFFICIAL.lifted.map(
|
|
|
511
512
|
/** @type {[string, string, string]} */ ([
|
|
512
513
|
part,
|
|
513
514
|
block,
|
|
514
|
-
part
|
|
515
|
-
? '--color-neutral'
|
|
516
|
-
: '--color-accent-muted',
|
|
515
|
+
liftGround(part, block),
|
|
517
516
|
]),
|
|
518
517
|
);
|
|
518
|
+
/**
|
|
519
|
+
* What a lifted block's secondary text sits on: a card's own fill for a
|
|
520
|
+
* card colour (the card variant rule lifts it there), the translucent
|
|
521
|
+
* neutral track under segmented-control labels, else the accent tint.
|
|
522
|
+
* @param {string} part @param {string} block
|
|
523
|
+
*/
|
|
524
|
+
function liftGround(part, block) {
|
|
525
|
+
if (part === 'segmented-control-item') return '--color-neutral';
|
|
526
|
+
const color = part === 'card' ? /^variant:([\w-]+)$/.exec(block)?.[1] : null;
|
|
527
|
+
return color ? `--color-background-${color}` : '--color-accent-muted';
|
|
528
|
+
}
|
|
519
529
|
/** What each lifted background is, and the parts on it, for notes. */
|
|
520
530
|
const LIFT_GROUNDS =
|
|
521
531
|
/** @type {Record<string, {what: string, parts: string}>} */ ({
|
|
@@ -527,6 +537,12 @@ const LIFT_GROUNDS =
|
|
|
527
537
|
what: 'the neutral track',
|
|
528
538
|
parts: 'segmented-control labels',
|
|
529
539
|
},
|
|
540
|
+
...Object.fromEntries(
|
|
541
|
+
LIFT_PARTS.filter(([part]) => part === 'card').map(([, block, g]) => {
|
|
542
|
+
const color = block.replace(/^variant:/, '');
|
|
543
|
+
return [g, {what: `the ${color} card fill`, parts: `${color} cards`}];
|
|
544
|
+
}),
|
|
545
|
+
),
|
|
530
546
|
});
|
|
531
547
|
const BORDER = /** @type {[number, number]} */ ([80, 65]);
|
|
532
548
|
/**
|
|
@@ -1040,8 +1056,23 @@ function tools(
|
|
|
1040
1056
|
on,
|
|
1041
1057
|
r: contrast(on.color, fill),
|
|
1042
1058
|
}));
|
|
1043
|
-
|
|
1059
|
+
let best = a.r >= TEXT || a.r >= b.r ? a : b;
|
|
1044
1060
|
const other = best === a ? b : a;
|
|
1061
|
+
// Neither reads: the end of the gray ramp on the better side (black
|
|
1062
|
+
// past near-black, white past near-white) when it reads better, so the
|
|
1063
|
+
// text picked is never one a darker or lighter gray would beat.
|
|
1064
|
+
if (best.r < TEXT) {
|
|
1065
|
+
const dark =
|
|
1066
|
+
contrast(best.on.color, PALETTE_WHITE) > contrast(fill, PALETTE_WHITE);
|
|
1067
|
+
/** @type {StopRef} */
|
|
1068
|
+
const end = neutral
|
|
1069
|
+
? {...ref('neutral', m, at(dark ? 0 : 100)), family: 'neutral'}
|
|
1070
|
+
: dark
|
|
1071
|
+
? {stop: 0, color: PALETTE_BLACK, family: 'black'}
|
|
1072
|
+
: {stop: 100, color: PALETTE_WHITE, family: 'white'};
|
|
1073
|
+
const r = contrast(end.color, fill);
|
|
1074
|
+
if (r > best.r) best = {on: end, r};
|
|
1075
|
+
}
|
|
1045
1076
|
return {
|
|
1046
1077
|
on: best.on,
|
|
1047
1078
|
r: best.r,
|
|
@@ -2317,6 +2348,25 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2317
2348
|
);
|
|
2318
2349
|
}) ?? start;
|
|
2319
2350
|
fill[m] = ref(f.id, m, found);
|
|
2351
|
+
// The shade nearest your color that passes, offered as the theme's
|
|
2352
|
+
// own dark fill when it is closer to your color than the one used.
|
|
2353
|
+
const near = [...stops]
|
|
2354
|
+
.filter(s => s > 0 && s < 100)
|
|
2355
|
+
.sort((a, b) => Math.abs(a - S) - Math.abs(b - S) || b - a)
|
|
2356
|
+
.find(s => {
|
|
2357
|
+
const c = ref(f.id, m, s).color;
|
|
2358
|
+
return (
|
|
2359
|
+
t.page(c, m, f.id) >= NON_TEXT && t.onFor(f.id, m, c).r >= TEXT
|
|
2360
|
+
);
|
|
2361
|
+
});
|
|
2362
|
+
const closer =
|
|
2363
|
+
near != null && Math.abs(near - S) < Math.abs(found - S)
|
|
2364
|
+
? (() => {
|
|
2365
|
+
const c = ref(f.id, m, near).color;
|
|
2366
|
+
const o = t.onFor(f.id, m, c);
|
|
2367
|
+
return `; for a fill closer to your color in dark: ${P} set ${slug} ${names.fill} ${quoteCommandArgument(c)} --mode dark (shade ${shade(near)}, the nearest that passes, with ${textName(o.on)} text at ${round(o.r)}:1)`;
|
|
2368
|
+
})()
|
|
2369
|
+
: '';
|
|
2320
2370
|
if (reports(names.fill))
|
|
2321
2371
|
checks.push({
|
|
2322
2372
|
token: names.fill,
|
|
@@ -2327,7 +2377,7 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2327
2377
|
ratio: plain.ratio,
|
|
2328
2378
|
needs: TEXT,
|
|
2329
2379
|
pass: true,
|
|
2330
|
-
note: `in dark, ${names.fill} is shade ${shade(found)}, not your exact color: ${plain.why}${found === start ? '' : `; shade ${shade(start)} does not pass either, so it is the nearest shade that does`}`,
|
|
2380
|
+
note: `in dark, ${names.fill} is shade ${shade(found)}, not your exact color: ${plain.why}${found === start ? '' : `; shade ${shade(start)} does not pass either, so it is the nearest shade that does`}${closer}`,
|
|
2331
2381
|
});
|
|
2332
2382
|
}
|
|
2333
2383
|
put(names.fill, f.id, fill);
|
|
@@ -2372,6 +2422,18 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2372
2422
|
if (modes.includes('light') && has(names.fill)) {
|
|
2373
2423
|
const used = exactFill.light ?? /** @type {StopRef} */ (fill.light).color;
|
|
2374
2424
|
const p = t.page(solid(used, 'light', f.id), 'light', f.id);
|
|
2425
|
+
// The nearest darker color that stands out from the light page.
|
|
2426
|
+
/** @type {string | null} */
|
|
2427
|
+
let darker = null;
|
|
2428
|
+
const from = parseColor(solid(used, 'light', f.id));
|
|
2429
|
+
for (let i = 1; from && i <= 100 && !darker; i++) {
|
|
2430
|
+
const c = hex(
|
|
2431
|
+
/** @type {[number, number, number]} */ (
|
|
2432
|
+
from.map(v => Math.round(v * (1 - i / 100)))
|
|
2433
|
+
),
|
|
2434
|
+
);
|
|
2435
|
+
if (t.page(c, 'light', f.id) >= NON_TEXT) darker = c;
|
|
2436
|
+
}
|
|
2375
2437
|
if (p < NON_TEXT)
|
|
2376
2438
|
checks.push({
|
|
2377
2439
|
token: names.fill,
|
|
@@ -2385,6 +2447,13 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2385
2447
|
note: exactFill.light
|
|
2386
2448
|
? `in light, your exact ${names.fill} (${used}) stands out from the page at only ${round(p)}:1, and a fill needs ${NON_TEXT}:1, so its buttons and badges may not show: give it a darker color`
|
|
2387
2449
|
: `in light, your exact ${f.id} stands out from the page at only ${round(p)}:1, and a fill needs ${NON_TEXT}:1, so ${names.fill} buttons and badges may not show: pick a darker ${f.id}`,
|
|
2450
|
+
...(darker
|
|
2451
|
+
? {
|
|
2452
|
+
fix: exactFill.light
|
|
2453
|
+
? {thing: names.fill, value: darker, mode: 'light'}
|
|
2454
|
+
: {thing: f.id, value: darker},
|
|
2455
|
+
}
|
|
2456
|
+
: {}),
|
|
2388
2457
|
});
|
|
2389
2458
|
}
|
|
2390
2459
|
|
|
@@ -2437,34 +2506,53 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2437
2506
|
// nearest shade that reads, and the result says so.
|
|
2438
2507
|
const text = each(m => {
|
|
2439
2508
|
const grounds = [...surfaces(m, f.id), ...mutedSeen(m)];
|
|
2440
|
-
|
|
2509
|
+
// The fill the theme really shows in this mode: an exact token
|
|
2510
|
+
// setting of it, else the dial's own color at its shade. The text
|
|
2511
|
+
// starts from that color's nearest shade.
|
|
2512
|
+
const shown = exactFill[m] ? solid(exactFill[m], m, f.id) : null;
|
|
2513
|
+
const start = shown
|
|
2514
|
+
? stops.reduce((x, y) =>
|
|
2515
|
+
perceptualDelta(ref(f.id, m, y).color, shown) <
|
|
2516
|
+
perceptualDelta(ref(f.id, m, x).color, shown)
|
|
2517
|
+
? y
|
|
2518
|
+
: x,
|
|
2519
|
+
)
|
|
2520
|
+
: S;
|
|
2521
|
+
const own = shown
|
|
2522
|
+
? {...ref(f.id, m, start), color: shown}
|
|
2523
|
+
: fill[m]?.exact
|
|
2524
|
+
? ref(f.id, m, S)
|
|
2525
|
+
: null;
|
|
2441
2526
|
if (own) {
|
|
2442
2527
|
const r = Math.min(...grounds.map(([, bg]) => contrast(own.color, bg)));
|
|
2443
2528
|
if (r >= TEXT) {
|
|
2444
|
-
if (
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2529
|
+
if (!shown) {
|
|
2530
|
+
if (reports(names.text))
|
|
2531
|
+
checks.push({
|
|
2532
|
+
token: names.text,
|
|
2533
|
+
mode: m,
|
|
2534
|
+
stop: S,
|
|
2535
|
+
preferred: S,
|
|
2536
|
+
against: grounds.map(([n]) => n).join(', '),
|
|
2537
|
+
ratio: round(r),
|
|
2538
|
+
needs: TEXT,
|
|
2539
|
+
pass: true,
|
|
2540
|
+
});
|
|
2541
|
+
return own;
|
|
2542
|
+
}
|
|
2456
2543
|
}
|
|
2457
2544
|
const before = checks.length;
|
|
2458
|
-
const moved = pick(names.text, f.id, m,
|
|
2545
|
+
const moved = pick(names.text, f.id, m, start, grounds, TEXT);
|
|
2546
|
+
if (r >= TEXT) return moved;
|
|
2459
2547
|
const last = checks.length > before ? checks[checks.length - 1] : null;
|
|
2460
|
-
if (last && moved.stop !==
|
|
2548
|
+
if (last && (moved.stop !== start || shown))
|
|
2461
2549
|
last.note = `${names.text} ${m}: your exact color (${own.color}) reads at only ${grounds
|
|
2462
2550
|
.map(([n, bg]) => [n, contrast(own.color, bg)])
|
|
2463
2551
|
.filter(([, x]) => Number(x) < TEXT)
|
|
2464
2552
|
.map(([n, x]) => `${round(Number(x))}:1 on ${n}`)
|
|
2465
2553
|
.join(
|
|
2466
2554
|
', ',
|
|
2467
|
-
)} (text needs ${TEXT}:1), so links and accent text use shade ${shade(moved.stop)} (${moved.color}), the nearest that reads; the fill keeps your color, and an exact ${names.text} keeps any color you give it`;
|
|
2555
|
+
)} (text needs ${TEXT}:1), so ${f.id === 'accent' ? 'links and accent text' : `${f.id} text and icons`} use shade ${shade(moved.stop)} (${moved.color}), the nearest that reads; the fill keeps your color, and an exact ${names.text} keeps any color you give it`;
|
|
2468
2556
|
return moved;
|
|
2469
2557
|
}
|
|
2470
2558
|
return pick(names.text, f.id, m, at(TEXT_STOP[side(m)]), grounds, TEXT);
|
|
@@ -2516,7 +2604,9 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2516
2604
|
// else a gray ramp the generator grows from the base theme's own
|
|
2517
2605
|
// secondary text (written as colors, not shades of the palette). The
|
|
2518
2606
|
// tint stays at its official stop. A mode where the theme sets
|
|
2519
|
-
// secondary text exactly takes that value
|
|
2607
|
+
// secondary text exactly takes that value where it reads there, else the
|
|
2608
|
+
// gray nearest it that does: a secondary text set for the whole theme
|
|
2609
|
+
// never makes those parts less readable.
|
|
2520
2610
|
/** @type {Record<string, Partial<Record<Mode, StopRef>>> | null} */
|
|
2521
2611
|
let lift = null;
|
|
2522
2612
|
{
|
|
@@ -2609,14 +2699,23 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2609
2699
|
const byMode = {};
|
|
2610
2700
|
for (const m of modes) {
|
|
2611
2701
|
const own = rawOf('--color-text-secondary', m);
|
|
2612
|
-
|
|
2613
|
-
byMode[m] = {
|
|
2614
|
-
|
|
2615
|
-
|
|
2702
|
+
const literal = () => {
|
|
2703
|
+
byMode[m] = {
|
|
2704
|
+
stop: 0,
|
|
2705
|
+
color: /** @type {string} */ (own),
|
|
2706
|
+
family: 'literal',
|
|
2707
|
+
};
|
|
2708
|
+
};
|
|
2616
2709
|
const fillColor = valueOf(m, ground);
|
|
2617
2710
|
const g = grays(m);
|
|
2618
2711
|
const text = startText(m);
|
|
2619
|
-
if (!fillColor || !g || !text)
|
|
2712
|
+
if (!fillColor || !g || !text) {
|
|
2713
|
+
if (own) {
|
|
2714
|
+
literal();
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
break;
|
|
2718
|
+
}
|
|
2620
2719
|
const seen = drawn(what, fillColor, surfaces(m, 'neutral'));
|
|
2621
2720
|
const hover = valueOf(m, '--color-overlay-hover');
|
|
2622
2721
|
const on = [
|
|
@@ -2634,7 +2733,20 @@ export function paletteMapping(cwd, slug, data, base, tokenDefaults) {
|
|
|
2634
2733
|
const keys = Object.keys(g.ramp)
|
|
2635
2734
|
.map(Number)
|
|
2636
2735
|
.sort((a, b) => a - b);
|
|
2637
|
-
|
|
2736
|
+
if (
|
|
2737
|
+
own &&
|
|
2738
|
+
parseColor(own) &&
|
|
2739
|
+
Math.min(...on.map(([, bg]) => contrast(own, bg))) >= TEXT
|
|
2740
|
+
) {
|
|
2741
|
+
literal();
|
|
2742
|
+
continue;
|
|
2743
|
+
}
|
|
2744
|
+
const from =
|
|
2745
|
+
(own && parseColor(own)
|
|
2746
|
+
? hex(/** @type {number[]} */ (parseColor(own)))
|
|
2747
|
+
: null) ??
|
|
2748
|
+
baseLift(m) ??
|
|
2749
|
+
text;
|
|
2638
2750
|
const start = keys.reduce((x, y) =>
|
|
2639
2751
|
perceptualDelta(g.ramp[y], from) < perceptualDelta(g.ramp[x], from)
|
|
2640
2752
|
? y
|
|
@@ -2752,10 +2864,19 @@ export function mappingRows(dial) {
|
|
|
2752
2864
|
([t, [[l, la], [d, da]]]) =>
|
|
2753
2865
|
`${t}: light shade ${l} at opacity ${la}, dark shade ${d} at opacity ${da}`,
|
|
2754
2866
|
),
|
|
2755
|
-
...Object.
|
|
2756
|
-
g =>
|
|
2757
|
-
|
|
2758
|
-
|
|
2867
|
+
...Object.entries(LIFT_GROUNDS)
|
|
2868
|
+
.filter(([g]) => !g.startsWith('--color-background-'))
|
|
2869
|
+
.map(
|
|
2870
|
+
([, g]) =>
|
|
2871
|
+
`--color-text-secondary on ${g.parts}: the shade nearest the secondary text's that reads at ${TEXT}:1 on ${g.what} and under a hover, as the official theme lifts it`,
|
|
2872
|
+
),
|
|
2873
|
+
...(Object.keys(LIFT_GROUNDS).some(g =>
|
|
2874
|
+
g.startsWith('--color-background-'),
|
|
2875
|
+
)
|
|
2876
|
+
? [
|
|
2877
|
+
`--color-text-secondary on coloured cards: the shade nearest the secondary text's that reads at ${TEXT}:1 on each card's fill, as the official theme lifts it`,
|
|
2878
|
+
]
|
|
2879
|
+
: []),
|
|
2759
2880
|
];
|
|
2760
2881
|
const word = dial === 'accent' ? null : STATUS_TOKEN[dial];
|
|
2761
2882
|
if (dial !== 'accent' && !word) return [];
|
|
@@ -2840,7 +2961,11 @@ export function paletteFailures(pal, dial, modes = ['light', 'dark']) {
|
|
|
2840
2961
|
if (!pal) return [];
|
|
2841
2962
|
return dialChecks(pal, dial, modes)
|
|
2842
2963
|
.filter(c => !c.pass)
|
|
2843
|
-
.map(c => ({
|
|
2964
|
+
.map(c => ({
|
|
2965
|
+
key: paletteCheckKey(c),
|
|
2966
|
+
text: checkNote(c, dial),
|
|
2967
|
+
...(c.fix ? {fix: c.fix} : {}),
|
|
2968
|
+
}));
|
|
2844
2969
|
}
|
|
2845
2970
|
|
|
2846
2971
|
/**
|
|
@@ -33,7 +33,9 @@ export const OVERRIDES = [
|
|
|
33
33
|
[/\b((modal |dialog )?(overlay|scrim|backdrop))\b/, {on: 'overlay'}],
|
|
34
34
|
[/\bicons?\b/, {on: 'icons'}],
|
|
35
35
|
[
|
|
36
|
-
|
|
36
|
+
// (The header row is the header cells: "table header row gray" is
|
|
37
|
+
// never every row.)
|
|
38
|
+
/\b(table header rows?|header rows?|table headers?|column headers?|table headings?)\b/,
|
|
37
39
|
{on: 'table-header-cell'},
|
|
38
40
|
],
|
|
39
41
|
[
|
|
@@ -123,9 +125,20 @@ export const OVERRIDES = [
|
|
|
123
125
|
/\b(?:toggle|switch)(?:e?s)?(?:'s)?\s+(?:thumbs?|knobs?|handles?)\b/,
|
|
124
126
|
{on: 'switch-thumb'},
|
|
125
127
|
],
|
|
126
|
-
//
|
|
128
|
+
// The buttons or items of a toggle group (its own possessive or not):
|
|
129
|
+
// Core's toggle buttons, never a switch's.
|
|
127
130
|
[
|
|
128
|
-
/\
|
|
131
|
+
/\btoggle[- ]?(?:button[- ]?)?groups?(?:'s|s'|’s)?\s+(?:buttons?|items?|options?)\b/,
|
|
132
|
+
{on: 'toggle-button'},
|
|
133
|
+
],
|
|
134
|
+
// A toggle group: the group of toggle buttons, never a switch.
|
|
135
|
+
[/\btoggle[- ]?(?:button[- ]?)?groups?\b/, {on: 'toggle-button-group'}],
|
|
136
|
+
// A toggle button: Core's toggle button, never a switch.
|
|
137
|
+
[/\btoggle[- ]?buttons?\b/, {on: 'toggle-button'}],
|
|
138
|
+
// "switch off", "switch the buttons to" are the verb, not the part; the
|
|
139
|
+
// switch's "on color" or "on state" (its checked look) is the part.
|
|
140
|
+
[
|
|
141
|
+
/\b(toggles?|switch(?:e?s)?(?! (?:off|on(?\b)|to|the|out|it|them|over|back|from)\b))\b/,
|
|
129
142
|
{on: 'switch'},
|
|
130
143
|
],
|
|
131
144
|
[/\b((table )?cells?)\b/, {on: 'table-cell'}],
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A fingerprint of a module and every file it imports by a relative path,
|
|
6
|
+
* read once: what a cache built by that code is keyed by, so any change to
|
|
7
|
+
* the code builds it again, with no number to bump by hand (the installed
|
|
8
|
+
* Core is the cache folder's own key).
|
|
9
|
+
* @param {string} url the module's own `import.meta.url`
|
|
10
|
+
*/
|
|
11
|
+
export function codeFingerprint(url: string): string;
|
|
4
12
|
/**
|
|
5
13
|
* The props a component renders with: its doc's playground defaults, or,
|
|
6
14
|
* for a doc with none (an older Core), a sample for each required prop.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import * as fs from 'node:fs';
|
|
19
|
+
import * as os from 'node:os';
|
|
19
20
|
import * as path from 'node:path';
|
|
20
21
|
import {createHash} from 'node:crypto';
|
|
21
22
|
import {createRequire} from 'node:module';
|
|
@@ -37,14 +38,19 @@ import {
|
|
|
37
38
|
pageSource,
|
|
38
39
|
} from './_catalog.mjs';
|
|
39
40
|
import {removeOnStop} from '../../foundation/fs/stop-cleanup.mjs';
|
|
41
|
+
import {
|
|
42
|
+
fileStamp,
|
|
43
|
+
recordContentRead,
|
|
44
|
+
} from '../../foundation/fs/read-record.mjs';
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
47
|
+
* A fingerprint of a module and every file it imports by a relative path,
|
|
48
|
+
* read once: what a cache built by that code is keyed by, so any change to
|
|
49
|
+
* the code builds it again, with no number to bump by hand (the installed
|
|
50
|
+
* Core is the cache folder's own key).
|
|
51
|
+
* @param {string} url the module's own `import.meta.url`
|
|
46
52
|
*/
|
|
47
|
-
|
|
53
|
+
export function codeFingerprint(url) {
|
|
48
54
|
const hash = createHash('sha256');
|
|
49
55
|
/** @type {Set<string>} */
|
|
50
56
|
const seen = new Set();
|
|
@@ -65,9 +71,12 @@ const CENSUS_KEY = (() => {
|
|
|
65
71
|
))
|
|
66
72
|
walk(path.resolve(path.dirname(file), m[1]));
|
|
67
73
|
};
|
|
68
|
-
walk(fileURLToPath(
|
|
74
|
+
walk(fileURLToPath(url));
|
|
69
75
|
return hash.digest('hex').slice(0, 16);
|
|
70
|
-
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What the cached part data is built by ({@link codeFingerprint}). */
|
|
79
|
+
const CENSUS_KEY = codeFingerprint(import.meta.url);
|
|
71
80
|
|
|
72
81
|
/**
|
|
73
82
|
* Flags that change what a component does or whether it shows, not how it
|
|
@@ -199,12 +208,16 @@ export function demoProps(project, name) {
|
|
|
199
208
|
)
|
|
200
209
|
return null;
|
|
201
210
|
const props = given ?? {};
|
|
202
|
-
// A
|
|
203
|
-
//
|
|
211
|
+
// A required prop its defaults leave out (a status dot's variant, a
|
|
212
|
+
// command palette's search source) takes its sample, as for a doc with no
|
|
213
|
+
// defaults: without it the part draws nothing (no color, no list).
|
|
204
214
|
if (given)
|
|
205
|
-
for (const [p, d] of Object.entries(info.props ?? {}))
|
|
206
|
-
if (
|
|
207
|
-
|
|
215
|
+
for (const [p, d] of Object.entries(info.props ?? {})) {
|
|
216
|
+
if (p in props || /^on[A-Z]/.test(p) || p === 'children') continue;
|
|
217
|
+
if (!d.required && !/^SearchSource\b/.test(d.type)) continue;
|
|
218
|
+
const v = d.slots?.[0] ?? sampleOf(name, d.type);
|
|
219
|
+
if (v !== undefined) props[p] = v;
|
|
220
|
+
}
|
|
208
221
|
if (!given)
|
|
209
222
|
for (const [p, d] of Object.entries(info.props ?? {})) {
|
|
210
223
|
if (!d.required || /^on[A-Z]/.test(p)) continue;
|
|
@@ -490,10 +503,55 @@ const RUN = `${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
|
490
503
|
export const renderDir = project =>
|
|
491
504
|
path.join(project.cwd, 'themes', `.astryx-render-${RUN}`);
|
|
492
505
|
|
|
506
|
+
/** The file in a render folder that names the process that made it. */
|
|
507
|
+
const RENDER_OWNER = '.astryx-render-owner.json';
|
|
508
|
+
/** The renders of this process running now, which share its render folder. */
|
|
509
|
+
let rendersInFlight = 0;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* The process space this process runs in: its host and, on Linux, its pid
|
|
513
|
+
* namespace, so a process id read from a render folder's owner file is
|
|
514
|
+
* known to be this machine's own (a container that shares the project
|
|
515
|
+
* folder has another).
|
|
516
|
+
*/
|
|
517
|
+
const processSpace = () => {
|
|
518
|
+
let namespace = '';
|
|
519
|
+
try {
|
|
520
|
+
namespace = fs.readlinkSync('/proc/self/ns/pid');
|
|
521
|
+
} catch {
|
|
522
|
+
// No pid namespaces here.
|
|
523
|
+
}
|
|
524
|
+
return `${os.hostname()}\0${namespace}`;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Whether the process that made a render folder is known to be gone: its
|
|
529
|
+
* owner file names this process space, and no process has its id.
|
|
530
|
+
* @param {string} dir
|
|
531
|
+
* @param {number} pid
|
|
532
|
+
*/
|
|
533
|
+
function renderOwnerGone(dir, pid) {
|
|
534
|
+
/** @type {any} */
|
|
535
|
+
let owner;
|
|
536
|
+
try {
|
|
537
|
+
owner = JSON.parse(fs.readFileSync(path.join(dir, RENDER_OWNER), 'utf8'));
|
|
538
|
+
} catch {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
if (owner?.space !== processSpace() || owner?.pid !== pid) return false;
|
|
542
|
+
try {
|
|
543
|
+
process.kill(pid, 0);
|
|
544
|
+
return false;
|
|
545
|
+
} catch (error) {
|
|
546
|
+
return /** @type {any} */ (error)?.code === 'ESRCH';
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
493
550
|
/**
|
|
494
551
|
* Remove render folders a stopped command left (killed, out of memory):
|
|
495
|
-
*
|
|
496
|
-
*
|
|
552
|
+
* `.astryx-render-<pid>-<random>` folders whose maker is known to be gone
|
|
553
|
+
* (its owner file names this process space, and no process has its id),
|
|
554
|
+
* else only those more than ten minutes old. Links are never followed.
|
|
497
555
|
* @param {string} themes
|
|
498
556
|
*/
|
|
499
557
|
function sweepRenders(themes) {
|
|
@@ -507,17 +565,23 @@ function sweepRenders(themes) {
|
|
|
507
565
|
const m = /^\.astryx-render-(\d+)-[a-z0-9]+$/.exec(n);
|
|
508
566
|
if (!m || Number(m[1]) === process.pid) continue;
|
|
509
567
|
const p = path.join(themes, n);
|
|
510
|
-
// A
|
|
511
|
-
//
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
568
|
+
// A folder whose maker is known gone is a leftover at once. A process id
|
|
569
|
+
// from another process space may look gone or alive here, so there age
|
|
570
|
+
// decides: a render takes at most three minutes, and a folder older than
|
|
571
|
+
// ten is a leftover.
|
|
572
|
+
/** @type {import('node:fs').Stats} */
|
|
573
|
+
let stat;
|
|
515
574
|
try {
|
|
516
|
-
|
|
575
|
+
stat = fs.lstatSync(p);
|
|
517
576
|
} catch {
|
|
518
577
|
continue;
|
|
519
578
|
}
|
|
520
|
-
if (
|
|
579
|
+
if (!stat.isDirectory()) continue;
|
|
580
|
+
if (
|
|
581
|
+
!renderOwnerGone(p, Number(m[1])) &&
|
|
582
|
+
Date.now() - stat.mtimeMs < 10 * 60_000
|
|
583
|
+
)
|
|
584
|
+
continue;
|
|
521
585
|
try {
|
|
522
586
|
if (fs.lstatSync(p).isDirectory())
|
|
523
587
|
fs.rmSync(p, {recursive: true, force: true});
|
|
@@ -564,22 +628,36 @@ export async function renderGenerated(
|
|
|
564
628
|
// still goes.
|
|
565
629
|
const untrack = removeOnStop(dir);
|
|
566
630
|
const entry = path.join(dir, file);
|
|
567
|
-
|
|
568
|
-
// which a page opened from disk cannot reach: the inline placeholder
|
|
569
|
-
// takes their place, as when a template is scaffolded.
|
|
570
|
-
const {stripTemplateAssetRefs} =
|
|
571
|
-
await import('../../foundation/discovery/template-adapter.mjs');
|
|
572
|
-
fs.writeFileSync(entry, stripTemplateAssetRefs(source));
|
|
573
|
-
for (const x of extra) {
|
|
574
|
-
fs.mkdirSync(path.dirname(path.join(dir, x.name)), {recursive: true});
|
|
575
|
-
fs.copyFileSync(x.from, path.join(dir, x.name));
|
|
576
|
-
}
|
|
631
|
+
rendersInFlight++;
|
|
577
632
|
try {
|
|
633
|
+
// Who made it, so a later render can tell it is left over once this
|
|
634
|
+
// process is gone (killed outright, which no handler sees).
|
|
635
|
+
fs.writeFileSync(
|
|
636
|
+
path.join(dir, RENDER_OWNER),
|
|
637
|
+
`${JSON.stringify({pid: process.pid, space: processSpace()})}\n`,
|
|
638
|
+
);
|
|
639
|
+
// Demo images point at the docs site's own folder
|
|
640
|
+
// (`/template-assets/…`), which a page opened from disk cannot reach:
|
|
641
|
+
// the inline placeholder takes their place, as when a template is
|
|
642
|
+
// scaffolded.
|
|
643
|
+
const {stripTemplateAssetRefs} =
|
|
644
|
+
await import('../../foundation/discovery/template-adapter.mjs');
|
|
645
|
+
fs.writeFileSync(entry, stripTemplateAssetRefs(source));
|
|
646
|
+
for (const x of extra) {
|
|
647
|
+
fs.mkdirSync(path.dirname(path.join(dir, x.name)), {recursive: true});
|
|
648
|
+
fs.copyFileSync(x.from, path.join(dir, x.name));
|
|
649
|
+
}
|
|
578
650
|
// The editor's pages render every component, and a busy machine slows
|
|
579
651
|
// them down: they get three times the page limit.
|
|
580
652
|
const page = await renderPage(entry, {
|
|
581
653
|
title: file.replace(/\.[^.]+$/, ''),
|
|
582
654
|
timeoutMs: EDITOR_RENDER_MS,
|
|
655
|
+
// The editor shows the markup itself and writes no file, so it needs
|
|
656
|
+
// no script.
|
|
657
|
+
markupOnly: true,
|
|
658
|
+
// A theme's image too large for a page is named by the editor (show's
|
|
659
|
+
// notes); the page goes on without it.
|
|
660
|
+
leaveLargeStyleAssets: true,
|
|
583
661
|
...(opts.openLayers ? {openLayers: true} : {}),
|
|
584
662
|
});
|
|
585
663
|
// The page is the same whichever command rendered it: the folder's
|
|
@@ -631,6 +709,10 @@ export async function renderGenerated(
|
|
|
631
709
|
// it, so a render running beside this one keeps its own.
|
|
632
710
|
for (const f of [entry, ...extra.map(x => path.join(dir, x.name))])
|
|
633
711
|
fs.rmSync(f, {force: true});
|
|
712
|
+
// The owner file goes with this process's last render: then the folder
|
|
713
|
+
// holds nothing of a render still running.
|
|
714
|
+
if (--rendersInFlight === 0)
|
|
715
|
+
fs.rmSync(path.join(dir, RENDER_OWNER), {force: true});
|
|
634
716
|
// Another render may still use it: a folder with a file in it stays.
|
|
635
717
|
removeEmptyFolder(madeThemes ? themes : dir, {deep: true});
|
|
636
718
|
untrack();
|
|
@@ -641,8 +723,8 @@ export async function renderGenerated(
|
|
|
641
723
|
const isRecord = v => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
642
724
|
|
|
643
725
|
/**
|
|
644
|
-
* Part data read from a cache file, by file, with the file's
|
|
645
|
-
*
|
|
726
|
+
* Part data read from a cache file, by file, with the file's stamp
|
|
727
|
+
* (`fileStamp`) when it was read. Shared by every command in the process, so it
|
|
646
728
|
* is frozen.
|
|
647
729
|
* @type {Map<string, {stamp: string, data: PartData}>}
|
|
648
730
|
*/
|
|
@@ -672,8 +754,8 @@ export async function partData(project) {
|
|
|
672
754
|
try {
|
|
673
755
|
// The file is read again only when it changed: every command reads it,
|
|
674
756
|
// and parsing it costs more than the rest of a small command.
|
|
675
|
-
|
|
676
|
-
const stamp =
|
|
757
|
+
recordContentRead(file);
|
|
758
|
+
const stamp = fileStamp(file);
|
|
677
759
|
const kept = readParts.get(file);
|
|
678
760
|
const cached =
|
|
679
761
|
kept?.stamp === stamp
|
|
@@ -688,7 +770,9 @@ export async function partData(project) {
|
|
|
688
770
|
Object.values(cached.map).every(isRecord) &&
|
|
689
771
|
Array.isArray(cached.pairs)
|
|
690
772
|
) {
|
|
691
|
-
|
|
773
|
+
// A file that appeared after its stamp is not kept: the entry would
|
|
774
|
+
// outlive its removal.
|
|
775
|
+
if (stamp !== '-') readParts.set(file, {stamp, data: cached});
|
|
692
776
|
return cached;
|
|
693
777
|
}
|
|
694
778
|
} catch {
|
|
@@ -54,6 +54,30 @@ export function pngTexts(bytes: Buffer): Record<string, string>;
|
|
|
54
54
|
* @returns {Buffer}
|
|
55
55
|
*/
|
|
56
56
|
export function withPngText(bytes: Buffer, keyword: string, text: string): Buffer;
|
|
57
|
+
/**
|
|
58
|
+
* The bytes of a PNG holding a picture's RGBA pixels, 8 bits a channel, each
|
|
59
|
+
* row unfiltered.
|
|
60
|
+
* @param {Picture} pic
|
|
61
|
+
* @returns {Buffer}
|
|
62
|
+
*/
|
|
63
|
+
export function encodePng({ width, height, rgba }: Picture): Buffer;
|
|
64
|
+
/**
|
|
65
|
+
* A tall picture cut into pictures, in order, each cut only at the top of a
|
|
66
|
+
* row of parts: the end of a run of at least `gap` rows of one color (the
|
|
67
|
+
* page between two rows of cells; a cell's dashed edge breaks every run
|
|
68
|
+
* inside it). A piece ends at the lowest row top within `most` pixels; a
|
|
69
|
+
* row taller than that is a piece of its own, never cut through. A last
|
|
70
|
+
* piece shorter than `least` joins the one before it. A picture no taller
|
|
71
|
+
* than `most` is itself alone.
|
|
72
|
+
* @param {Picture} pic
|
|
73
|
+
* @param {number} most
|
|
74
|
+
* @param {{gap?: number, least?: number}} [options]
|
|
75
|
+
* @returns {Picture[]}
|
|
76
|
+
*/
|
|
77
|
+
export function cutTall(pic: Picture, most: number, { gap, least }?: {
|
|
78
|
+
gap?: number;
|
|
79
|
+
least?: number;
|
|
80
|
+
}): Picture[];
|
|
57
81
|
/**
|
|
58
82
|
* The most pixels a picture may have: about a 6K screen. A bigger header is
|
|
59
83
|
* refused before any memory is taken for it.
|