basalt-ui 3.0.0 → 3.1.0
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/AGENTS.md +1 -0
- package/CHANGELOG.md +72 -39
- package/MIGRATING.md +44 -2
- package/README.md +39 -12
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/rules/basalt-ui.md +3 -3
- package/agent/skills/basalt-app/references/live.md +4 -4
- package/agent/skills/basalt-app/references/migrate.md +2 -2
- package/agent/skills/basalt-app/references/setup.md +17 -8
- package/agent/skills/basalt-app/references/testing.md +8 -6
- package/agent/skills/basalt-design/SKILL.md +2 -1
- package/agent/skills/basalt-design/references/controls.md +1 -0
- package/agent/skills/basalt-design/references/parts.md +5 -1
- package/agent/templates/AGENTS-block.md.tpl +6 -23
- package/agent/templates/AGENTS-block.site.md.tpl +5 -18
- package/agent/templates/AGENTS-block.tokens.md.tpl +3 -7
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/agent/templates/_app-error.i18n.tpl +8 -32
- package/agent/templates/_app-error.tpl +8 -32
- package/agent/templates/_app-pending.i18n.tpl +5 -3
- package/agent/templates/_app-pending.tpl +5 -4
- package/agent/templates/main.i18n.tpl +8 -3
- package/agent/templates/main.tpl +8 -3
- package/agent/templates/router.start.tpl +8 -3
- package/agent/templates/seed-messages.json +0 -30
- package/configs/oxlint-app.json +9 -1
- package/configs/oxlint-bridge.json +3 -1
- package/configs/oxlint-parts.json +9 -1
- package/configs/oxlint-site.json +3 -1
- package/dist/astro/shiki.d.ts +3 -2
- package/dist/astro/shiki.d.ts.map +1 -1
- package/dist/cards/bar-list.d.ts.map +1 -1
- package/dist/cards/bar-list.js +2 -1
- package/dist/cards/chain-view.d.ts +37 -8
- package/dist/cards/chain-view.d.ts.map +1 -1
- package/dist/cards/chain-view.js +105 -38
- package/dist/cards/contract.d.ts +8 -1
- package/dist/cards/contract.d.ts.map +1 -1
- package/dist/cards/data-panel.d.ts.map +1 -1
- package/dist/cards/data-panel.js +1 -0
- package/dist/cards/event-list.d.ts.map +1 -1
- package/dist/cards/event-list.js +3 -2
- package/dist/cards/index.d.ts +1 -1
- package/dist/cards/index.d.ts.map +1 -1
- package/dist/cards/row-list.d.ts.map +1 -1
- package/dist/cards/row-list.js +2 -1
- package/dist/cards/stat-card-parts.d.ts +3 -3
- package/dist/cards/stat-card-parts.d.ts.map +1 -1
- package/dist/cards/stat-card-parts.js +8 -2
- package/dist/cards/stat-card.d.ts.map +1 -1
- package/dist/cards/stat-card.js +34 -9
- package/dist/charts/core/compile.d.ts +2 -0
- package/dist/charts/core/compile.d.ts.map +1 -1
- package/dist/charts/core/compile.js +16 -8
- package/dist/charts/core/cursor.d.ts +2 -1
- package/dist/charts/core/cursor.d.ts.map +1 -1
- package/dist/charts/core/cursor.js +8 -1
- package/dist/charts/core/tooltip-said.d.ts +16 -0
- package/dist/charts/core/tooltip-said.d.ts.map +1 -0
- package/dist/charts/core/tooltip-said.js +39 -0
- package/dist/charts/focus.d.ts.map +1 -1
- package/dist/charts/focus.js +1 -1
- package/dist/charts/parts/chart-card.d.ts.map +1 -1
- package/dist/charts/parts/chart-card.js +1 -0
- package/dist/cli/agent-note.d.ts +3 -3
- package/dist/cli/agent-note.d.ts.map +1 -1
- package/dist/cli/agent-note.js +5 -5
- package/dist/cli/budget/index.d.ts +7 -0
- package/dist/cli/budget/index.d.ts.map +1 -1
- package/dist/cli/budget/index.js +11 -5
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/doctor/app.d.ts.map +1 -1
- package/dist/cli/doctor/app.js +53 -24
- package/dist/cli/doctor/eject.d.ts.map +1 -1
- package/dist/cli/doctor/eject.js +16 -9
- package/dist/cli/doctor/guards.d.ts.map +1 -1
- package/dist/cli/doctor/guards.js +11 -8
- package/dist/cli/doctor/hook.js +1 -1
- package/dist/cli/doctor/install.d.ts.map +1 -1
- package/dist/cli/doctor/install.js +46 -22
- package/dist/cli/doctor/translations.d.ts.map +1 -1
- package/dist/cli/doctor/translations.js +11 -4
- package/dist/cli/doctor/types.d.ts +2 -2
- package/dist/cli/doctor/types.d.ts.map +1 -1
- package/dist/cli/doctor/types.js +1 -1
- package/dist/cli/doctor/wiring.d.ts.map +1 -1
- package/dist/cli/doctor/wiring.js +26 -15
- package/dist/cli/eject/dropped-slots.d.ts +6 -0
- package/dist/cli/eject/dropped-slots.d.ts.map +1 -0
- package/dist/cli/eject/dropped-slots.js +9 -0
- package/dist/cli/eject/index.d.ts.map +1 -1
- package/dist/cli/eject/index.js +9 -8
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +7 -2
- package/dist/cli/index.d.ts +6 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +38 -7
- package/dist/cli/init/index.d.ts +10 -0
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/index.js +61 -10
- package/dist/cli/init/locales.d.ts +7 -0
- package/dist/cli/init/locales.d.ts.map +1 -1
- package/dist/cli/init/locales.js +21 -6
- package/dist/cli/init/router-seeds.d.ts.map +1 -1
- package/dist/cli/init/router-seeds.js +16 -3
- package/dist/cli/init/steps.d.ts +36 -3
- package/dist/cli/init/steps.d.ts.map +1 -1
- package/dist/cli/init/steps.js +201 -34
- package/dist/cli/lint/baseline.d.ts +27 -0
- package/dist/cli/lint/baseline.d.ts.map +1 -0
- package/dist/cli/lint/baseline.js +96 -0
- package/dist/cli/lint/engine.d.ts +2 -0
- package/dist/cli/lint/engine.d.ts.map +1 -1
- package/dist/cli/lint/engine.js +18 -8
- package/dist/cli/lint/hook.d.ts.map +1 -1
- package/dist/cli/lint/hook.js +8 -3
- package/dist/cli/lint/index.d.ts +3 -0
- package/dist/cli/lint/index.d.ts.map +1 -1
- package/dist/cli/lint/index.js +67 -8
- package/dist/cli/manifest.d.ts +46 -3
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +71 -1
- package/dist/cli/migrate/census.d.ts +6 -0
- package/dist/cli/migrate/census.d.ts.map +1 -1
- package/dist/cli/migrate/census.js +22 -1
- package/dist/cli/migrate/index.d.ts +5 -0
- package/dist/cli/migrate/index.d.ts.map +1 -1
- package/dist/cli/migrate/index.js +36 -3
- package/dist/cli/migrate/lost-classes.d.ts +20 -0
- package/dist/cli/migrate/lost-classes.d.ts.map +1 -0
- package/dist/cli/migrate/lost-classes.js +145 -0
- package/dist/cli/migrate/rows.d.ts +10 -0
- package/dist/cli/migrate/rows.d.ts.map +1 -1
- package/dist/cli/migrate/rows.js +15 -0
- package/dist/cli/package-manager.d.ts.map +1 -1
- package/dist/cli/package-manager.js +2 -1
- package/dist/cli/peers.d.ts +2 -0
- package/dist/cli/peers.d.ts.map +1 -1
- package/dist/cli/peers.js +7 -0
- package/dist/cli/presets.d.ts.map +1 -1
- package/dist/cli/presets.js +27 -11
- package/dist/cli/resolver.d.ts +13 -4
- package/dist/cli/resolver.d.ts.map +1 -1
- package/dist/cli/resolver.js +39 -5
- package/dist/cli/router-wiring.d.ts +1 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +1 -1
- package/dist/cli/sync/engine.d.ts +8 -1
- package/dist/cli/sync/engine.d.ts.map +1 -1
- package/dist/cli/sync/engine.js +25 -14
- package/dist/cli/sync/index.d.ts.map +1 -1
- package/dist/cli/sync/index.js +7 -4
- package/dist/cli/sync/render.d.ts.map +1 -1
- package/dist/cli/sync/render.js +21 -28
- package/dist/cli/tokens-css.d.ts +2 -0
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +28 -6
- package/dist/controls/contract.d.ts +2 -1
- package/dist/controls/contract.d.ts.map +1 -1
- package/dist/controls/control-home.d.ts +4 -1
- package/dist/controls/control-home.d.ts.map +1 -1
- package/dist/controls/control-home.js +5 -3
- package/dist/controls/local-control.d.ts +28 -1
- package/dist/controls/local-control.d.ts.map +1 -1
- package/dist/controls/local-control.js +14 -2
- package/dist/core/cn.d.ts.map +1 -1
- package/dist/core/cn.js +6 -5
- package/dist/core/frame-figure.d.ts +2 -0
- package/dist/core/frame-figure.d.ts.map +1 -1
- package/dist/core/frame-figure.js +5 -2
- package/dist/core/frame-head.d.ts +3 -1
- package/dist/core/frame-head.d.ts.map +1 -1
- package/dist/core/frame-head.js +28 -7
- package/dist/core/frame-regions.d.ts +1 -1
- package/dist/core/frame-regions.d.ts.map +1 -1
- package/dist/core/frame-regions.js +18 -8
- package/dist/core/info-hint.d.ts +5 -0
- package/dist/core/info-hint.d.ts.map +1 -1
- package/dist/core/info-hint.js +22 -1
- package/dist/core/mark-tone.d.ts +6 -2
- package/dist/core/mark-tone.d.ts.map +1 -1
- package/dist/core/mark-tone.js +1 -1
- package/dist/core/mark-types.d.ts +4 -2
- package/dist/core/mark-types.d.ts.map +1 -1
- package/dist/core/messages/chain.d.ts +2 -1
- package/dist/core/messages/chain.d.ts.map +1 -1
- package/dist/core/messages/chain.js +1 -0
- package/dist/core/messages/index.d.ts +2 -1
- package/dist/core/messages/index.d.ts.map +1 -1
- package/dist/core/messages/index.js +2 -0
- package/dist/core/messages/runs.d.ts +20 -0
- package/dist/core/messages/runs.d.ts.map +1 -0
- package/dist/core/messages/runs.js +18 -0
- package/dist/core/phase.d.ts +25 -2
- package/dist/core/phase.d.ts.map +1 -1
- package/dist/core/ports.d.ts +4 -1
- package/dist/core/ports.d.ts.map +1 -1
- package/dist/core/provider.d.ts +3 -1
- package/dist/core/provider.d.ts.map +1 -1
- package/dist/core/provider.js +5 -3
- package/dist/core/scheme.d.ts +2 -1
- package/dist/core/scheme.d.ts.map +1 -1
- package/dist/core/scheme.js +1 -0
- package/dist/core/spark/mini-bars.d.ts +6 -4
- package/dist/core/spark/mini-bars.d.ts.map +1 -1
- package/dist/core/spark/mini-bars.js +36 -11
- package/dist/core/spark/sparkline.d.ts +2 -2
- package/dist/core/spark/sparkline.d.ts.map +1 -1
- package/dist/core/spark/sparkline.js +21 -2
- package/dist/css/bridge.css +63 -0
- package/dist/css/generate.d.ts +2 -2
- package/dist/css/generate.d.ts.map +1 -1
- package/dist/css/generate.js +25 -0
- package/dist/data/live/live-query.d.ts +2 -2
- package/dist/data/live/live-query.d.ts.map +1 -1
- package/dist/data/live/live-query.js +2 -1
- package/dist/lint/preset.d.ts +12 -3
- package/dist/lint/preset.d.ts.map +1 -1
- package/dist/lint/preset.js +30 -10
- package/dist/lint/rules/class/table.d.ts.map +1 -1
- package/dist/lint/rules/class/table.js +3 -1
- package/dist/lint/rules/structure/control-home.js +1 -1
- package/dist/lint/rules/structure/import-boundary.d.ts.map +1 -1
- package/dist/lint/rules/structure/import-boundary.js +2 -0
- package/dist/lint/rules/structure/label-literal.d.ts.map +1 -1
- package/dist/lint/rules/structure/label-literal.js +1 -1
- package/dist/lint/shadcn.d.ts +562 -0
- package/dist/lint/shadcn.d.ts.map +1 -0
- package/dist/lint/shadcn.js +52 -0
- package/dist/lint/stylelint/render.d.ts +3 -1
- package/dist/lint/stylelint/render.d.ts.map +1 -1
- package/dist/lint/stylelint/render.js +23 -2
- package/dist/lint/stylelint/rules.d.ts +3 -2
- package/dist/lint/stylelint/rules.d.ts.map +1 -1
- package/dist/lint/stylelint/rules.js +11 -6
- package/dist/lint/weakened.d.ts +8 -0
- package/dist/lint/weakened.d.ts.map +1 -1
- package/dist/lint/weakened.js +44 -1
- package/dist/messages/de.d.ts.map +1 -1
- package/dist/messages/de.js +15 -0
- package/dist/messages/es.d.ts.map +1 -1
- package/dist/messages/es.js +15 -0
- package/dist/messages/fr.d.ts.map +1 -1
- package/dist/messages/fr.js +15 -0
- package/dist/messages/zh-hans.d.ts.map +1 -1
- package/dist/messages/zh-hans.js +15 -0
- package/dist/page/bar-title.d.ts +25 -0
- package/dist/page/bar-title.d.ts.map +1 -0
- package/dist/page/bar-title.js +10 -0
- package/dist/page/contract.d.ts +11 -1
- package/dist/page/contract.d.ts.map +1 -1
- package/dist/page/empty-state.d.ts +5 -2
- package/dist/page/empty-state.d.ts.map +1 -1
- package/dist/page/empty-state.js +14 -3
- package/dist/page/facts.d.ts +19 -2
- package/dist/page/facts.d.ts.map +1 -1
- package/dist/page/facts.js +26 -5
- package/dist/page/index.d.ts +8 -0
- package/dist/page/index.d.ts.map +1 -1
- package/dist/page/index.js +9 -0
- package/dist/page/page-bar.d.ts.map +1 -1
- package/dist/page/page-bar.js +2 -7
- package/dist/page/page-summary.d.ts +2 -1
- package/dist/page/page-summary.d.ts.map +1 -1
- package/dist/page/page-summary.js +1 -1
- package/dist/page/run-button.d.ts +26 -0
- package/dist/page/run-button.d.ts.map +1 -0
- package/dist/page/run-button.js +31 -0
- package/dist/page/run-list.d.ts +28 -0
- package/dist/page/run-list.d.ts.map +1 -0
- package/dist/page/run-list.js +88 -0
- package/dist/page/run-queue.d.ts +78 -0
- package/dist/page/run-queue.d.ts.map +1 -0
- package/dist/page/run-queue.js +93 -0
- package/dist/page/section.d.ts +6 -1
- package/dist/page/section.d.ts.map +1 -1
- package/dist/page/section.js +34 -16
- package/dist/shell/commands/command-palette.d.ts.map +1 -1
- package/dist/shell/commands/command-palette.js +5 -1
- package/dist/shell/parts/header.js +1 -1
- package/dist/surfaces.d.ts +15 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +19 -2
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3 -0
- package/dist/testing/pseudo-locale.d.ts +41 -0
- package/dist/testing/pseudo-locale.d.ts.map +1 -0
- package/dist/testing/pseudo-locale.js +74 -0
- package/dist/testing/quality.d.ts +6 -0
- package/dist/testing/quality.d.ts.map +1 -1
- package/dist/testing/quality.js +139 -1
- package/dist/tokens/bridge-sheet.d.ts +21 -0
- package/dist/tokens/bridge-sheet.d.ts.map +1 -0
- package/dist/tokens/bridge-sheet.js +68 -0
- package/dist/tokens/emit.d.ts +6 -1
- package/dist/tokens/emit.d.ts.map +1 -1
- package/dist/tokens/emit.js +26 -1
- package/dist/ui/accordion.js +1 -1
- package/dist/ui/card.d.ts +32 -4
- package/dist/ui/card.d.ts.map +1 -1
- package/dist/ui/card.js +26 -3
- package/dist/ui/collapsible.d.ts +4 -2
- package/dist/ui/collapsible.d.ts.map +1 -1
- package/dist/ui/collapsible.js +1 -1
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/meter.d.ts +34 -3
- package/dist/ui/meter.d.ts.map +1 -1
- package/dist/ui/meter.guard.d.ts +2 -0
- package/dist/ui/meter.guard.d.ts.map +1 -1
- package/dist/ui/meter.guard.js +20 -0
- package/dist/ui/meter.js +23 -7
- package/dist/ui/primitive.contract.d.ts.map +1 -1
- package/dist/ui/primitive.contract.js +7 -0
- package/dist/ui/remote-pad.d.ts +62 -0
- package/dist/ui/remote-pad.d.ts.map +1 -0
- package/dist/ui/remote-pad.guard.d.ts +21 -0
- package/dist/ui/remote-pad.guard.d.ts.map +1 -0
- package/dist/ui/remote-pad.guard.js +6 -0
- package/dist/ui/remote-pad.js +148 -0
- package/dist/ui/segmented.d.ts.map +1 -1
- package/dist/ui/segmented.js +4 -0
- package/dist/ui/skeleton.d.ts +9 -4
- package/dist/ui/skeleton.d.ts.map +1 -1
- package/dist/ui/skeleton.guard.d.ts +6 -2
- package/dist/ui/skeleton.guard.d.ts.map +1 -1
- package/dist/ui/skeleton.guard.js +4 -0
- package/dist/ui/skeleton.js +2 -1
- package/dist/ui/slots.d.ts +2 -1
- package/dist/ui/slots.d.ts.map +1 -1
- package/dist/ui/slots.js +2 -1
- package/dist/vite/allotment.d.ts +1 -1
- package/dist/vite/allotment.d.ts.map +1 -1
- package/dist/vite/allotment.js +15 -1
- package/dist/vite/doc.d.ts +1 -1
- package/dist/vite/doc.d.ts.map +1 -1
- package/dist/vite/doc.js +12 -2
- package/dist/vite/head.d.ts +4 -3
- package/dist/vite/head.d.ts.map +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +4 -1
- package/dist/vite/shell-worker.d.ts +6 -0
- package/dist/vite/shell-worker.d.ts.map +1 -0
- package/dist/vite/shell-worker.js +92 -0
- package/docs/astro.md +19 -4
- package/docs/bar-list.md +3 -2
- package/docs/bar-title.md +33 -0
- package/docs/basalt-provider.md +2 -1
- package/docs/card.md +24 -4
- package/docs/chain-view.md +12 -7
- package/docs/chart-card.md +3 -2
- package/docs/collapsible.md +4 -2
- package/docs/control-home.md +4 -2
- package/docs/create-run-queue.md +40 -0
- package/docs/data-panel.md +3 -2
- package/docs/de.md +1 -1
- package/docs/empty-state.md +3 -1
- package/docs/es.md +1 -1
- package/docs/event-list.md +3 -2
- package/docs/fact.md +6 -1
- package/docs/facts.md +5 -1
- package/docs/fr.md +1 -1
- package/docs/live-query.md +1 -1
- package/docs/meter.md +17 -13
- package/docs/mini-bars.md +7 -5
- package/docs/pseudo-basalt-messages.md +30 -0
- package/docs/pseudo-messages.md +27 -0
- package/docs/quality.md +2 -1
- package/docs/recipes/localise-app.md +2 -2
- package/docs/remote-pad.md +40 -0
- package/docs/row-list.md +3 -2
- package/docs/run-button.md +45 -0
- package/docs/run-list.md +71 -0
- package/docs/section.md +7 -1
- package/docs/set-scheme.md +2 -2
- package/docs/skeleton.md +4 -3
- package/docs/slots.md +1 -1
- package/docs/sparkline.md +5 -2
- package/docs/stat-card.md +6 -4
- package/docs/testing.md +64 -0
- package/docs/use-local-control.md +8 -1
- package/docs/use-runs.md +32 -0
- package/docs/vite.md +12 -2
- package/docs/zh-hans.md +1 -1
- package/llms.txt +88 -21
- package/migrations/areas/shadcn.json +338 -0
- package/package.json +9 -2
- package/src/astro/shiki.ts +3 -1
- package/src/cards/bar-list.tsx +2 -1
- package/src/cards/chain-view.tsx +167 -55
- package/src/cards/contract.ts +8 -1
- package/src/cards/data-panel.tsx +1 -0
- package/src/cards/event-list.tsx +2 -1
- package/src/cards/index.ts +1 -0
- package/src/cards/row-list.tsx +2 -1
- package/src/cards/stat-card-parts.tsx +9 -7
- package/src/cards/stat-card.tsx +39 -12
- package/src/charts/core/compile.ts +31 -19
- package/src/charts/core/cursor.ts +11 -3
- package/src/charts/core/tooltip-said.ts +55 -0
- package/src/charts/focus.tsx +4 -1
- package/src/charts/parts/chart-card.tsx +1 -0
- package/src/cli/agent-note.ts +12 -5
- package/src/cli/budget/index.ts +22 -5
- package/src/cli/config.ts +1 -1
- package/src/cli/doctor/app.ts +75 -23
- package/src/cli/doctor/eject.ts +30 -10
- package/src/cli/doctor/guards.ts +11 -8
- package/src/cli/doctor/hook.ts +1 -1
- package/src/cli/doctor/install.ts +61 -24
- package/src/cli/doctor/translations.ts +13 -4
- package/src/cli/doctor/types.ts +2 -3
- package/src/cli/doctor/wiring.ts +30 -16
- package/src/cli/eject/dropped-slots.ts +11 -0
- package/src/cli/eject/index.ts +13 -9
- package/src/cli/help.ts +34 -10
- package/src/cli/index.ts +56 -14
- package/src/cli/init/index.ts +64 -5
- package/src/cli/init/locales.ts +41 -8
- package/src/cli/init/router-seeds.ts +17 -3
- package/src/cli/init/steps.ts +308 -41
- package/src/cli/lint/baseline.ts +141 -0
- package/src/cli/lint/engine.ts +33 -10
- package/src/cli/lint/hook.ts +11 -3
- package/src/cli/lint/index.ts +77 -12
- package/src/cli/manifest.ts +132 -4
- package/src/cli/migrate/census.ts +35 -1
- package/src/cli/migrate/index.ts +46 -3
- package/src/cli/migrate/lost-classes.ts +203 -0
- package/src/cli/migrate/rows.ts +21 -0
- package/src/cli/package-manager.ts +4 -1
- package/src/cli/peers.ts +11 -0
- package/src/cli/presets.ts +32 -11
- package/src/cli/resolver.ts +58 -10
- package/src/cli/router-wiring.ts +3 -1
- package/src/cli/sync/engine.ts +30 -14
- package/src/cli/sync/index.ts +7 -4
- package/src/cli/sync/render.ts +29 -37
- package/src/cli/tokens-css.ts +42 -5
- package/src/controls/contract.ts +2 -0
- package/src/controls/control-home.tsx +15 -4
- package/src/controls/local-control.ts +49 -3
- package/src/core/cn.ts +9 -5
- package/src/core/frame-figure.tsx +7 -1
- package/src/core/frame-head.tsx +32 -6
- package/src/core/frame-regions.tsx +18 -8
- package/src/core/info-hint.tsx +26 -0
- package/src/core/mark-tone.ts +10 -3
- package/src/core/mark-types.ts +4 -2
- package/src/core/messages/chain.ts +2 -1
- package/src/core/messages/index.ts +4 -0
- package/src/core/messages/runs.ts +40 -0
- package/src/core/phase.ts +22 -2
- package/src/core/ports.ts +13 -1
- package/src/core/provider.tsx +7 -3
- package/src/core/scheme.ts +6 -2
- package/src/core/spark/mini-bars.tsx +59 -15
- package/src/core/spark/sparkline.tsx +26 -4
- package/src/css/bridge.css +63 -0
- package/src/css/generate.ts +40 -3
- package/src/data/live/live-query.ts +4 -3
- package/src/lint/preset.ts +52 -13
- package/src/lint/rules/class/table.ts +3 -1
- package/src/lint/rules/structure/control-home.ts +1 -1
- package/src/lint/rules/structure/import-boundary.ts +2 -0
- package/src/lint/rules/structure/label-literal.ts +3 -1
- package/src/lint/shadcn.ts +91 -0
- package/src/lint/stylelint/render.ts +31 -1
- package/src/lint/stylelint/rules.ts +19 -7
- package/src/lint/weakened.ts +59 -1
- package/src/messages/de.ts +20 -0
- package/src/messages/es.ts +20 -0
- package/src/messages/fr.ts +20 -0
- package/src/messages/zh-hans.ts +20 -0
- package/src/page/bar-title.tsx +35 -0
- package/src/page/contract.ts +11 -1
- package/src/page/empty-state.tsx +18 -8
- package/src/page/facts.tsx +43 -5
- package/src/page/index.ts +8 -0
- package/src/page/page-bar.tsx +2 -9
- package/src/page/page-summary.tsx +4 -3
- package/src/page/run-button.tsx +52 -0
- package/src/page/run-list.tsx +151 -0
- package/src/page/run-queue.ts +185 -0
- package/src/page/section.tsx +30 -5
- package/src/shell/commands/command-palette.tsx +10 -1
- package/src/shell/parts/header.tsx +1 -1
- package/src/surfaces.ts +18 -1
- package/src/testing/index.ts +1 -0
- package/src/testing/pseudo-locale.ts +149 -0
- package/src/testing/quality.ts +188 -0
- package/src/tokens/bridge-sheet.ts +80 -0
- package/src/tokens/emit.ts +45 -6
- package/src/ui/accordion.tsx +1 -1
- package/src/ui/card.tsx +56 -6
- package/src/ui/collapsible.tsx +5 -3
- package/src/ui/combobox.tsx +1 -1
- package/src/ui/meter.guard.ts +23 -0
- package/src/ui/meter.tsx +76 -27
- package/src/ui/no-restyle.generated.json +8 -0
- package/src/ui/primitive.contract.ts +7 -0
- package/src/ui/remote-pad.guard.ts +24 -0
- package/src/ui/remote-pad.tsx +249 -0
- package/src/ui/segmented.tsx +6 -0
- package/src/ui/skeleton.guard.ts +7 -2
- package/src/ui/skeleton.tsx +10 -4
- package/src/ui/slots.ts +2 -1
- package/src/vite/allotment.ts +15 -1
- package/src/vite/doc.ts +12 -2
- package/src/vite/head.ts +4 -3
- package/src/vite/index.ts +4 -1
- package/src/vite/shell-worker.ts +115 -0
package/src/cli/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* basalt-ui CLI — the dispatcher plus the plumbing `init`, `sync`, `lint` and `doctor` (each
|
|
3
3
|
* in its own file) share. Runs under Node 22.18 or newer (it loads the `.ts` series file through
|
|
4
|
-
* Node's type stripping) and under Bun: `
|
|
5
|
-
*
|
|
4
|
+
* Node's type stripping) and under Bun: no `Bun` global and no `bun`-module import on any path.
|
|
5
|
+
* Its one package import is `yaml`, for pnpm-workspace.yaml.
|
|
6
6
|
*/
|
|
7
7
|
import { createHash } from 'node:crypto'
|
|
8
8
|
import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
9
9
|
import { dirname, isAbsolute, relative, resolve } from 'node:path'
|
|
10
10
|
import { fileURLToPath } from 'node:url'
|
|
11
|
+
import { parse as parseYaml } from 'yaml'
|
|
11
12
|
|
|
12
13
|
import { RULE_NAMES, SKILL_NAMES } from '../surfaces'
|
|
13
14
|
import { docs, parts } from './docs'
|
|
@@ -18,6 +19,7 @@ import { eject } from './eject'
|
|
|
18
19
|
import { EJECT_HELP } from './eject/help'
|
|
19
20
|
import { COMMAND_OPTIONS, USAGE, unknownFlag } from './help'
|
|
20
21
|
import { init } from './init/index'
|
|
22
|
+
import { readManifest } from './manifest'
|
|
21
23
|
import { isHookCall, lint } from './lint'
|
|
22
24
|
import { migrate } from './migrate'
|
|
23
25
|
import { shot } from './shot'
|
|
@@ -187,11 +189,21 @@ const appRelative = (root: string, dir: string): string =>
|
|
|
187
189
|
export const hasViteEntry = (dir: string): boolean =>
|
|
188
190
|
existsSync(resolve(dir, 'src/main.tsx')) || existsSync(resolve(dir, 'index.html'))
|
|
189
191
|
|
|
192
|
+
/** The manifest's roots above `site`, or none where there is no readable manifest. */
|
|
193
|
+
function declaredAppRoots(root: string): string[] {
|
|
194
|
+
const read = readManifest(root)
|
|
195
|
+
if (read === null || 'error' in read) return []
|
|
196
|
+
return Object.entries(read.manifest.roots)
|
|
197
|
+
.filter(([, profile]) => profile !== 'tokens' && profile !== 'site')
|
|
198
|
+
.map(([dir]) => dir.replace(/^(?:\.\/)+/, '').replace(/\/+$/, ''))
|
|
199
|
+
}
|
|
200
|
+
|
|
190
201
|
/**
|
|
191
202
|
* Where the Vite app lives relative to the install root `root` (manifest, `.claude/`, AGENTS block).
|
|
192
203
|
* ONE resolution for `doctor`, `sync` and `init`, in order: `basalt.app` in the root package.json;
|
|
193
204
|
* else the single workspace package that depends on basalt-ui AND has a Vite entry; else `root`
|
|
194
|
-
* itself (a single-package app).
|
|
205
|
+
* itself (a single-package app). Among two such packages the one the manifest declares an app root in
|
|
206
|
+
* is it; else the choice is not inferable, an error. A
|
|
195
207
|
* package declaring `basalt.sibling` is a declared second install and never a candidate.
|
|
196
208
|
*/
|
|
197
209
|
export function resolveAppDir(root: string): AppResolution {
|
|
@@ -215,8 +227,14 @@ export function resolveAppDir(root: string): AppResolution {
|
|
|
215
227
|
readBasaltConfig(pkg.dir).sibling !== true,
|
|
216
228
|
)
|
|
217
229
|
if (candidates.length === 0) return self
|
|
218
|
-
|
|
219
|
-
|
|
230
|
+
// A `tokens` or `site` root is no Vite app, so it never makes the choice ambiguous.
|
|
231
|
+
const appRoots = declaredAppRoots(root)
|
|
232
|
+
const declared = candidates.filter((pkg) => {
|
|
233
|
+
const rel = appRelative(root, pkg.dir)
|
|
234
|
+
return appRoots.some((r) => r === rel || r.startsWith(`${rel}/`))
|
|
235
|
+
})
|
|
236
|
+
const [only] = declared.length === 1 ? declared : candidates
|
|
237
|
+
if ((declared.length === 1 || candidates.length === 1) && only !== undefined) {
|
|
220
238
|
return { dir: only.dir, rel: appRelative(root, only.dir) }
|
|
221
239
|
}
|
|
222
240
|
const names = candidates.map((pkg) => appRelative(root, pkg.dir)).join(', ')
|
|
@@ -252,7 +270,7 @@ export function packageRoot(): string {
|
|
|
252
270
|
|
|
253
271
|
export type WorkspacePackage = { readonly name: string; readonly dir: string }
|
|
254
272
|
|
|
255
|
-
/** {@link collectWorkspacePackages}'s return: the packages plus whether a
|
|
273
|
+
/** {@link collectWorkspacePackages}'s return: the packages plus whether a workspace list existed. */
|
|
256
274
|
export type WorkspaceWalk = {
|
|
257
275
|
readonly packages: readonly WorkspacePackage[]
|
|
258
276
|
readonly hasWorkspacesField: boolean
|
|
@@ -320,7 +338,7 @@ function expandWorkspaceGlobs(cwd: string, patterns: readonly string[]): string[
|
|
|
320
338
|
const expand = (pattern: string): string[] =>
|
|
321
339
|
expandPatternSegments(
|
|
322
340
|
cwd,
|
|
323
|
-
pattern.split('/').filter((s) => s.length > 0),
|
|
341
|
+
pattern.split('/').filter((s) => s.length > 0 && s !== '.'),
|
|
324
342
|
)
|
|
325
343
|
|
|
326
344
|
const excluded = new Set(
|
|
@@ -337,27 +355,42 @@ function expandWorkspaceGlobs(cwd: string, patterns: readonly string[]): string[
|
|
|
337
355
|
if (existsSync(resolve(abs, 'package.json'))) dirs.push(abs)
|
|
338
356
|
}
|
|
339
357
|
}
|
|
340
|
-
|
|
358
|
+
// package.json and pnpm-workspace.yaml may both name a glob: one app, listed once.
|
|
359
|
+
return [...new Set(dirs)]
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** The `packages` globs of `cwd`'s pnpm-workspace.yaml; `[]` when the file or key is absent or does not parse. */
|
|
363
|
+
function pnpmWorkspacePatterns(cwd: string): string[] {
|
|
364
|
+
const text = readIfExists(resolve(cwd, 'pnpm-workspace.yaml'))
|
|
365
|
+
if (text === null) return []
|
|
366
|
+
try {
|
|
367
|
+
const packages = (parseYaml(text) as { packages?: unknown } | null)?.packages
|
|
368
|
+
return isStringArray(packages) ? packages : []
|
|
369
|
+
} catch {
|
|
370
|
+
return []
|
|
371
|
+
}
|
|
341
372
|
}
|
|
342
373
|
|
|
343
374
|
/**
|
|
344
|
-
* Every workspace package declared by `cwd`'s root `package.json` (array or `{ packages }` form)
|
|
345
|
-
* PLUS the root manifest itself, labelled `"{name} (root)"` (it commonly carries a hoisted `ai`
|
|
375
|
+
* Every workspace package declared by `cwd`'s root `package.json` (array or `{ packages }` form)
|
|
376
|
+
* or its `pnpm-workspace.yaml`, PLUS the root manifest itself, labelled `"{name} (root)"` (it commonly carries a hoisted `ai`
|
|
346
377
|
* dev dependency that can skew against a package's major). `hasWorkspacesField` is `false` when
|
|
347
|
-
* there is no `package.json`,
|
|
378
|
+
* there is no `package.json`, or neither file holds a list this recognizes; never throws.
|
|
348
379
|
*/
|
|
349
380
|
export function collectWorkspacePackages(cwd: string): WorkspaceWalk {
|
|
350
381
|
const parsed = readPackageJson<{ workspaces?: unknown; name?: string }>(cwd)
|
|
351
382
|
if (parsed === null) return { packages: [], hasWorkspacesField: false }
|
|
352
383
|
|
|
353
|
-
const
|
|
384
|
+
const declared = isStringArray(parsed.workspaces)
|
|
354
385
|
? parsed.workspaces
|
|
355
386
|
: parsed.workspaces !== null &&
|
|
356
387
|
typeof parsed.workspaces === 'object' &&
|
|
357
388
|
isStringArray((parsed.workspaces as { packages?: unknown }).packages)
|
|
358
389
|
? (parsed.workspaces as { packages: string[] }).packages
|
|
359
390
|
: null
|
|
360
|
-
|
|
391
|
+
const pnpm = pnpmWorkspacePatterns(cwd)
|
|
392
|
+
if (declared === null && pnpm.length === 0) return { packages: [], hasWorkspacesField: false }
|
|
393
|
+
const patterns = [...(declared ?? []), ...pnpm]
|
|
361
394
|
|
|
362
395
|
const rootName = parsed.name && parsed.name.length > 0 ? `${parsed.name} (root)` : '(root)'
|
|
363
396
|
const workspacePackages = expandWorkspaceGlobs(cwd, patterns).map((dir) => ({
|
|
@@ -396,7 +429,16 @@ export function run(argv: string[], cwd: string = process.cwd()): number | Promi
|
|
|
396
429
|
flags.includes('-h')
|
|
397
430
|
) {
|
|
398
431
|
// A command with its own help text prints it; the rest print the one usage.
|
|
399
|
-
|
|
432
|
+
// `init`'s help is its own block of the one usage, from its line to the next command's.
|
|
433
|
+
// The blank line is the anchor: the synopsis at the top names every command too.
|
|
434
|
+
const start = USAGE.indexOf('\n\ninit --profile')
|
|
435
|
+
const initHelp = USAGE.slice(start, USAGE.indexOf('\n\nsync [--check]', start)).trim()
|
|
436
|
+
const own: Partial<Record<string, string>> = {
|
|
437
|
+
add: ADD_HELP,
|
|
438
|
+
eject: EJECT_HELP,
|
|
439
|
+
init: initHelp,
|
|
440
|
+
}
|
|
441
|
+
console.log(own[cmd ?? ''] ?? USAGE)
|
|
400
442
|
return 0
|
|
401
443
|
}
|
|
402
444
|
// Before dispatch, like --help: it answers "which basalt-ui is running" as one bare line.
|
package/src/cli/init/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `init --profile tokens|site|bridge|parts|app [--root <path>]... [--tokens-out <css>]
|
|
3
|
-
* [--tokens-json-out <json>] [--extra <file>] [--accent --neutral --vibrancy --selector] [--locales en,de]
|
|
3
|
+
* [--tokens-json-out <json>] [--extra <file>] [--accent --neutral --vibrancy --selector] [--locales en,de]
|
|
4
|
+
* [--agents <path.md>] [--design <path.md>]
|
|
5
|
+
* [--catalogs <pattern>]...`: the one
|
|
4
6
|
* door into an install (docs/v3/concepts/skills-agent-layer.md 4.1). The profile is declared,
|
|
5
7
|
* never inferred. It declares the manifest, generates the token outputs, installs the profile's
|
|
6
8
|
* peers within their declared ranges (saved exactly), places the managed files through `sync`, seeds the budget and DESIGN.md,
|
|
@@ -22,8 +24,17 @@ import { generateRouteTree } from '../route-tree'
|
|
|
22
24
|
import { parseLegacyLedger } from '../legacy-2x'
|
|
23
25
|
import { HARNESSES, isHarness } from '../harness'
|
|
24
26
|
import type { Harness } from '../harness'
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
+
import {
|
|
28
|
+
AGENTS_FILE,
|
|
29
|
+
isCatalogPattern,
|
|
30
|
+
isLocaleTag,
|
|
31
|
+
isMarkdownFile,
|
|
32
|
+
MANIFEST_PATH,
|
|
33
|
+
PROFILES,
|
|
34
|
+
readManifest,
|
|
35
|
+
} from '../manifest'
|
|
36
|
+
import { VITE_CONFIGS } from '../router-wiring'
|
|
37
|
+
import { isSiblingApp, undeclaredInstall } from '../resolver'
|
|
27
38
|
import { readIfExists } from '../source-text'
|
|
28
39
|
import { retireLegacy } from './upgrade'
|
|
29
40
|
import type { Manifest, Profile } from '../manifest'
|
|
@@ -31,6 +42,7 @@ import {
|
|
|
31
42
|
declareManifest,
|
|
32
43
|
generateTokens,
|
|
33
44
|
installPeers,
|
|
45
|
+
belowRootRefusal,
|
|
34
46
|
installRoot,
|
|
35
47
|
defaultExtra,
|
|
36
48
|
skipPlacements,
|
|
@@ -88,6 +100,9 @@ export const FLAGS = {
|
|
|
88
100
|
start: { type: 'boolean' },
|
|
89
101
|
harness: { type: 'string' },
|
|
90
102
|
locales: { type: 'string' },
|
|
103
|
+
agents: { type: 'string' },
|
|
104
|
+
design: { type: 'string' },
|
|
105
|
+
catalogs: { type: 'string', multiple: true },
|
|
91
106
|
} as const
|
|
92
107
|
|
|
93
108
|
/** A path inside the repo: relative, no `..`, no line breaks. */
|
|
@@ -99,6 +114,14 @@ const isInside = (path: string): boolean =>
|
|
|
99
114
|
|
|
100
115
|
const clean = (path: string): string => path.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '') || '.'
|
|
101
116
|
|
|
117
|
+
/** A root holding a Vite config or index.html is the app, not its source. Doctor checks the root's parent for the Vite config, and the root and its parent for index.html, so such a root sends it to the wrong directory. */
|
|
118
|
+
const appDirRoot = (base: string, roots: readonly string[]): string | undefined =>
|
|
119
|
+
roots.find(
|
|
120
|
+
(root) =>
|
|
121
|
+
root !== '.' &&
|
|
122
|
+
['index.html', ...VITE_CONFIGS].some((file) => existsSync(resolve(base, root, file))),
|
|
123
|
+
)
|
|
124
|
+
|
|
102
125
|
/** The flags as `Args`, or the first reason they are not a legal call. */
|
|
103
126
|
export function parseInit(argv: readonly string[]): { args: Args } | { error: string } {
|
|
104
127
|
let values: ReturnType<typeof parseArgs<{ options: typeof FLAGS }>>['values']
|
|
@@ -139,6 +162,13 @@ export function parseInit(argv: readonly string[]): { args: Args } | { error: st
|
|
|
139
162
|
error: `--locales takes a comma list of language tags, the source one first, like en,de (got '${badTag ?? ''}')`,
|
|
140
163
|
}
|
|
141
164
|
}
|
|
165
|
+
const catalogs = values.catalogs?.map(clean)
|
|
166
|
+
const badCatalog = catalogs?.find((p) => !isCatalogPattern(p) || !isInside(p))
|
|
167
|
+
if (badCatalog !== undefined) {
|
|
168
|
+
return {
|
|
169
|
+
error: `--catalogs takes a path pattern with {locale}, relative to the repo root, like 'packages/i18n/locales/*/{locale}.po' (got '${badCatalog}')`,
|
|
170
|
+
}
|
|
171
|
+
}
|
|
142
172
|
const roots = [...new Set((values.root ?? ['.']).map(clean))]
|
|
143
173
|
const tokensOut = clean(
|
|
144
174
|
values['tokens-out'] ?? `${roots[0] === '.' ? '' : `${roots[0]}/`}tokens.css`,
|
|
@@ -146,6 +176,18 @@ export function parseInit(argv: readonly string[]): { args: Args } | { error: st
|
|
|
146
176
|
const tokensJsonOut =
|
|
147
177
|
values['tokens-json-out'] === undefined ? undefined : clean(values['tokens-json-out'])
|
|
148
178
|
const extra = values.extra === undefined ? undefined : clean(values.extra)
|
|
179
|
+
const agents = values.agents === undefined ? undefined : clean(values.agents)
|
|
180
|
+
const design = values.design === undefined ? undefined : clean(values.design)
|
|
181
|
+
for (const [flag, value] of [
|
|
182
|
+
['--agents', agents],
|
|
183
|
+
['--design', design],
|
|
184
|
+
] as const) {
|
|
185
|
+
if (value !== undefined && !(isInside(value) && isMarkdownFile(value))) {
|
|
186
|
+
return {
|
|
187
|
+
error: `${flag} takes a .md path relative to the repo root, without '..' (got '${value}')`,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
149
191
|
const paths = [
|
|
150
192
|
...roots,
|
|
151
193
|
tokensOut,
|
|
@@ -174,6 +216,9 @@ export function parseInit(argv: readonly string[]): { args: Args } | { error: st
|
|
|
174
216
|
start: values.start === true,
|
|
175
217
|
...(harnesses === undefined ? {} : { harnesses: [...new Set(harnesses)] as Harness[] }),
|
|
176
218
|
...(locales === undefined ? {} : { locales: [...new Set(locales)] }),
|
|
219
|
+
...(agents === undefined ? {} : { agents }),
|
|
220
|
+
...(design === undefined ? {} : { design }),
|
|
221
|
+
...(catalogs === undefined ? {} : { catalogs: [...new Set(catalogs)] }),
|
|
177
222
|
},
|
|
178
223
|
}
|
|
179
224
|
}
|
|
@@ -211,6 +256,8 @@ export async function init(
|
|
|
211
256
|
let parsed = parseInit(argv)
|
|
212
257
|
if ('error' in parsed) return fail(parsed.error)
|
|
213
258
|
const root = installRoot(cwd)
|
|
259
|
+
const refusal = belowRootRefusal(cwd, root)
|
|
260
|
+
if (refusal !== null) return fail(refusal)
|
|
214
261
|
const recorded = readManifest(root)
|
|
215
262
|
const text = readIfExists(resolve(root, MANIFEST_PATH))
|
|
216
263
|
const ledger = text === null ? null : parseLegacyLedger(text)
|
|
@@ -230,6 +277,12 @@ export async function init(
|
|
|
230
277
|
if ('error' in parsed) return fail(parsed.error)
|
|
231
278
|
}
|
|
232
279
|
}
|
|
280
|
+
const app = appDirRoot(root, parsed.args.roots)
|
|
281
|
+
if (app !== undefined) {
|
|
282
|
+
return fail(
|
|
283
|
+
`${app} holds a Vite config or index.html, so it is the app, not its source: use ${app}/src`,
|
|
284
|
+
)
|
|
285
|
+
}
|
|
233
286
|
// No --extra: the file the manifest already records, else the profile's conventional one.
|
|
234
287
|
const args: Args = {
|
|
235
288
|
...parsed.args,
|
|
@@ -243,7 +296,12 @@ export async function init(
|
|
|
243
296
|
run: args.noInstall ? undefined : (deps.run ?? spawnRun),
|
|
244
297
|
problems: [],
|
|
245
298
|
todo: [],
|
|
299
|
+
previousRoots: current?.roots ?? {},
|
|
246
300
|
}
|
|
301
|
+
// Refused before the first write: a run that stops halfway leaves a tree no step finishes.
|
|
302
|
+
const declaring = Object.fromEntries(args.roots.map((r) => [r, args.profile]))
|
|
303
|
+
const blocked = undeclaredInstall(root, { roots: { ...current?.roots, ...declaring } })
|
|
304
|
+
if (blocked !== null) return fail(`${blocked} Nothing was written.`)
|
|
247
305
|
forgetWritten()
|
|
248
306
|
seedSeries(ctx)
|
|
249
307
|
|
|
@@ -251,7 +309,8 @@ export async function init(
|
|
|
251
309
|
// A sibling install registers no hook at the repo root: its `check-v3` holds the line.
|
|
252
310
|
const sibling = isSiblingApp(root)
|
|
253
311
|
const bases = sibling ? [root, findRepoRoot(root)] : [root]
|
|
254
|
-
const
|
|
312
|
+
const agentsAt = [AGENTS_FILE, ...[args.agents, current?.agents].filter((a) => a !== undefined)]
|
|
313
|
+
const before = agentFiles(bases, agentsAt)
|
|
255
314
|
// Before the manifest is written over the 2.x ledger it reads.
|
|
256
315
|
try {
|
|
257
316
|
retireLegacy(ctx, ledger, current?.managed ?? {})
|
|
@@ -315,7 +374,7 @@ export async function init(
|
|
|
315
374
|
? 'next: the agent continues with the basalt-site skill: fix each line doctor printed, then run doctor again until it passes.'
|
|
316
375
|
: 'next: the agent continues with the basalt-app skill (references/setup.md): fix each line doctor printed, then run doctor again until it passes.',
|
|
317
376
|
)
|
|
318
|
-
const note = sessionNote(before, bases)
|
|
377
|
+
const note = sessionNote(before, bases, agentsAt)
|
|
319
378
|
if (note !== null) console.log(`\n${note}`)
|
|
320
379
|
if (ctx.problems.length === 0) return 0
|
|
321
380
|
for (const problem of ctx.problems) console.error(`✖ basalt-ui init: ${problem}`)
|
package/src/cli/init/locales.ts
CHANGED
|
@@ -42,6 +42,40 @@ export const translatedInstall = (
|
|
|
42
42
|
manifest: Pick<Manifest, 'locales'> | null,
|
|
43
43
|
): boolean => isTranslated({ locales: argLocales ?? manifest?.locales ?? [] })
|
|
44
44
|
|
|
45
|
+
/** The path of the catalogues `init` writes, under the app directory `appRel` (`''` is the install root). */
|
|
46
|
+
export const scaffoldCatalog = (appRel: string): string =>
|
|
47
|
+
`${appRel === '' ? '' : `${appRel}/`}src/locales/{locale}.po`
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The manifest's `catalogs` when none of them is the scaffold's own: the app keeps its catalogue
|
|
51
|
+
* elsewhere, so `init` writes no catalogue, no wiring of one and no seed that would read it.
|
|
52
|
+
*/
|
|
53
|
+
export function keptCatalogs(
|
|
54
|
+
catalogs: readonly string[] | undefined,
|
|
55
|
+
appRel: string,
|
|
56
|
+
): readonly string[] | undefined {
|
|
57
|
+
const own = scaffoldCatalog(appRel)
|
|
58
|
+
// `*` stands for one directory or file name, as doctor reads the patterns.
|
|
59
|
+
const covers = (pattern: string): boolean => {
|
|
60
|
+
const shape = pattern
|
|
61
|
+
.replace(/^(?:\.\/)+/, '')
|
|
62
|
+
.split('*')
|
|
63
|
+
.map(escapeRegex)
|
|
64
|
+
return new RegExp(`^${shape.join('[^/]*')}$`).test(own)
|
|
65
|
+
}
|
|
66
|
+
return catalogs?.some(covers) === false ? catalogs : undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const escapeRegex = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
70
|
+
|
|
71
|
+
/** The language a tag reads words in: its base language, and `zh-hans` for Chinese in the simplified script (`zh`, `zh-CN`, not `zh-TW`). */
|
|
72
|
+
const languageOf = (locale: string): string => {
|
|
73
|
+
const language = locale.toLowerCase().split('-')[0] ?? locale
|
|
74
|
+
return language === 'zh' && new Intl.Locale(locale).maximize().script === 'Hans'
|
|
75
|
+
? 'zh-hans'
|
|
76
|
+
: language
|
|
77
|
+
}
|
|
78
|
+
|
|
45
79
|
/** A declared language tag as the package's own message pack names it, for the languages it ships. */
|
|
46
80
|
const PACKS: Readonly<Record<string, { specifier: string; key: string }>> = {
|
|
47
81
|
de: { specifier: 'basalt-ui/messages/de', key: 'de' },
|
|
@@ -50,9 +84,8 @@ const PACKS: Readonly<Record<string, { specifier: string; key: string }>> = {
|
|
|
50
84
|
'zh-hans': { specifier: 'basalt-ui/messages/zh-hans', key: 'zhHans' },
|
|
51
85
|
}
|
|
52
86
|
|
|
53
|
-
/** The pack for the tag, else for its
|
|
54
|
-
const packOf = (locale: string) =>
|
|
55
|
-
PACKS[locale.toLowerCase()] ?? PACKS[locale.toLowerCase().split('-')[0] ?? '']
|
|
87
|
+
/** The pack for the tag, else for its language (`de-AT` reads the German pack), as `renderCatalogue` reads the words. */
|
|
88
|
+
const packOf = (locale: string) => PACKS[locale.toLowerCase()] ?? PACKS[languageOf(locale)]
|
|
56
89
|
|
|
57
90
|
/** The seeds' messages by their English text, then each shipped language's translation (`agent/templates/seed-messages.json`). */
|
|
58
91
|
export type SeedMessages = Readonly<Record<string, Readonly<Record<string, string>>>>
|
|
@@ -76,7 +109,7 @@ const quoted = (text: string): string => JSON.stringify(text)
|
|
|
76
109
|
* The source language with no shipped translation keeps the English text, so its catalogue is whole.
|
|
77
110
|
*/
|
|
78
111
|
export function renderCatalogue(locale: string, source: string, messages: SeedMessages): string {
|
|
79
|
-
const language = locale
|
|
112
|
+
const language = languageOf(locale)
|
|
80
113
|
const english = language === 'en'
|
|
81
114
|
const entries = Object.keys(messages)
|
|
82
115
|
.toSorted((a, b) => a.localeCompare(b))
|
|
@@ -101,10 +134,10 @@ export function renderCatalogue(locale: string, source: string, messages: SeedMe
|
|
|
101
134
|
|
|
102
135
|
/** The languages `init` wrote no translation for: the catalogue holds the messages empty. */
|
|
103
136
|
export const untranslated = (locales: readonly string[]): string[] =>
|
|
104
|
-
locales.filter(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
137
|
+
locales.filter(
|
|
138
|
+
(locale) =>
|
|
139
|
+
languageOf(locale) !== 'en' && packOf(locale) === undefined && locale !== locales[0],
|
|
140
|
+
)
|
|
108
141
|
|
|
109
142
|
const tuple = (items: readonly string[]): string => `[${items.map((i) => `'${i}'`).join(', ')}]`
|
|
110
143
|
|
|
@@ -25,9 +25,15 @@ import type { RouterSeedSkip } from '../router-wiring'
|
|
|
25
25
|
import { routePatterns } from '../route-tree'
|
|
26
26
|
import { hasDependency, readIfExists } from '../source-text'
|
|
27
27
|
import type { Ctx } from './steps'
|
|
28
|
-
import { appName, CSS_ENTRIES, say, translatedApp, writeText } from './steps'
|
|
28
|
+
import { appCatalogs, appName, CSS_ENTRIES, say, translatedApp, writeText } from './steps'
|
|
29
29
|
import { isStock } from './stock'
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
localeVars,
|
|
32
|
+
readSeedMessages,
|
|
33
|
+
renderCatalogue,
|
|
34
|
+
scaffoldCatalog,
|
|
35
|
+
untranslated,
|
|
36
|
+
} from './locales'
|
|
31
37
|
import { readManifest, writeManifest } from '../manifest'
|
|
32
38
|
|
|
33
39
|
/**
|
|
@@ -181,7 +187,7 @@ function placeLocaleScaffold(ctx: Ctx, app: { rel: string }): void {
|
|
|
181
187
|
say(`wrote ${dest}`)
|
|
182
188
|
}
|
|
183
189
|
if (manifest !== null && app.rel !== '' && manifest.catalogs === undefined) {
|
|
184
|
-
writeManifest(ctx.root, { ...manifest, catalogs: [
|
|
190
|
+
writeManifest(ctx.root, { ...manifest, catalogs: [scaffoldCatalog(app.rel)] })
|
|
185
191
|
}
|
|
186
192
|
const missing = untranslated(locales)
|
|
187
193
|
if (missing.length > 0) {
|
|
@@ -213,6 +219,14 @@ export function placeRouterSeeds(ctx: Ctx): void {
|
|
|
213
219
|
ctx.routerPlugin = !start && (skip === null || skip === 'shell-less')
|
|
214
220
|
if (start) startTodos(ctx, app)
|
|
215
221
|
const translated = translatedApp(ctx)
|
|
222
|
+
const kept = translated ? appCatalogs(ctx) : undefined
|
|
223
|
+
if (kept !== undefined) {
|
|
224
|
+
// Without a root route there are no routes yet, and the router plugin would find none.
|
|
225
|
+
ctx.routerPlugin &&= readIfExists(resolve(ctx.root, routerSeedDest(app.rel, 'root'))) !== null
|
|
226
|
+
return say(
|
|
227
|
+
`no catalogue and no router seeds written: the app keeps its catalogue (${kept.join(', ')}), and the seeds would read the scaffold's (basalt-ui docs localise-app)`,
|
|
228
|
+
)
|
|
229
|
+
}
|
|
216
230
|
if (skip !== null || (translated && start)) {
|
|
217
231
|
if (translated) ctx.todo.push(LOCALE_NOTE)
|
|
218
232
|
if (skip !== null) return say(`skipped the router seeds: ${SKIP_NOTES[skip]}`)
|