@cloudflare/kumo 1.0.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/CHANGELOG.md +510 -0
- package/LICENSE +21 -0
- package/README.md +521 -0
- package/ai/component-registry.json +3754 -0
- package/ai/component-registry.md +4022 -0
- package/ai/schemas.ts +594 -0
- package/dist/badge-Dc99vsfo.js +51 -0
- package/dist/badge-Dc99vsfo.js.map +1 -0
- package/dist/banner-4fkH6Sbt.js +51 -0
- package/dist/banner-4fkH6Sbt.js.map +1 -0
- package/dist/breadcrumbs-B5SY2CWj.js +132 -0
- package/dist/breadcrumbs-B5SY2CWj.js.map +1 -0
- package/dist/button-E2-hZMZE.js +191 -0
- package/dist/button-E2-hZMZE.js.map +1 -0
- package/dist/catalog.js +229 -0
- package/dist/catalog.js.map +1 -0
- package/dist/checkbox-BexIU_lZ.js +224 -0
- package/dist/checkbox-BexIU_lZ.js.map +1 -0
- package/dist/clipboard-text-BFHWMjmr.js +108 -0
- package/dist/clipboard-text-BFHWMjmr.js.map +1 -0
- package/dist/cn-Bhsu1vx2.js +26 -0
- package/dist/cn-Bhsu1vx2.js.map +1 -0
- package/dist/code-T2wPDiM0.js +60 -0
- package/dist/code-T2wPDiM0.js.map +1 -0
- package/dist/collapsible-OBNkTO48.js +56 -0
- package/dist/collapsible-OBNkTO48.js.map +1 -0
- package/dist/combobox-Dld0kS0U.js +228 -0
- package/dist/combobox-Dld0kS0U.js.map +1 -0
- package/dist/command-line/cli.js +764 -0
- package/dist/command-line/commands/add.js +220 -0
- package/dist/command-line/commands/blocks.js +61 -0
- package/dist/command-line/commands/doc.js +167 -0
- package/dist/command-line/commands/init.js +95 -0
- package/dist/command-line/commands/ls.js +53 -0
- package/dist/command-palette-BgQ680BG.js +393 -0
- package/dist/command-palette-BgQ680BG.js.map +1 -0
- package/dist/components/badge.js +7 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/banner.js +7 -0
- package/dist/components/banner.js.map +1 -0
- package/dist/components/breadcrumbs.js +9 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/button.js +9 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox.js +8 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/clipboard-text.js +6 -0
- package/dist/components/clipboard-text.js.map +1 -0
- package/dist/components/code.js +7 -0
- package/dist/components/code.js.map +1 -0
- package/dist/components/collapsible.js +6 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/combobox.js +6 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command-palette.js +8 -0
- package/dist/components/command-palette.js.map +1 -0
- package/dist/components/date-range-picker.js +6 -0
- package/dist/components/date-range-picker.js.map +1 -0
- package/dist/components/dialog.js +11 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown.js +6 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/empty.js +9 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.js +9 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/grid.js +11 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/input.js +11 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.js +10 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/layer-card.js +6 -0
- package/dist/components/layer-card.js.map +1 -0
- package/dist/components/link.js +9 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/loader.js +8 -0
- package/dist/components/loader.js.map +1 -0
- package/dist/components/menubar.js +7 -0
- package/dist/components/menubar.js.map +1 -0
- package/dist/components/meter.js +6 -0
- package/dist/components/meter.js.map +1 -0
- package/dist/components/pagination.js +6 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +14 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/radio.js +10 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/select.js +6 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/sensitive-input.js +8 -0
- package/dist/components/sensitive-input.js.map +1 -0
- package/dist/components/surface.js +6 -0
- package/dist/components/surface.js.map +1 -0
- package/dist/components/switch.js +8 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +8 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +6 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/text.js +6 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/toast.js +8 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.js +7 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/date-range-picker-CbKEQ9pi.js +408 -0
- package/dist/date-range-picker-CbKEQ9pi.js.map +1 -0
- package/dist/dialog-B1TaN0oR.js +77 -0
- package/dist/dialog-B1TaN0oR.js.map +1 -0
- package/dist/dropdown-D0rhYKeG.js +263 -0
- package/dist/dropdown-D0rhYKeG.js.map +1 -0
- package/dist/empty-DzCqjea-.js +93 -0
- package/dist/empty-DzCqjea-.js.map +1 -0
- package/dist/field-V3J0Ql_V.js +71 -0
- package/dist/field-V3J0Ql_V.js.map +1 -0
- package/dist/grid-DKajRHh8.js +127 -0
- package/dist/grid-DKajRHh8.js.map +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/input-Dqvc2AB_.js +109 -0
- package/dist/input-Dqvc2AB_.js.map +1 -0
- package/dist/input-area-B9qajxvZ.js +57 -0
- package/dist/input-area-B9qajxvZ.js.map +1 -0
- package/dist/input-group-Bl6tgD5-.js +111 -0
- package/dist/input-group-Bl6tgD5-.js.map +1 -0
- package/dist/label-87HQArUG.js +50 -0
- package/dist/label-87HQArUG.js.map +1 -0
- package/dist/layer-card-C8j5Hkkj.js +44 -0
- package/dist/layer-card-C8j5Hkkj.js.map +1 -0
- package/dist/link-6TIZ4JIw.js +73 -0
- package/dist/link-6TIZ4JIw.js.map +1 -0
- package/dist/link-provider-DPBGo-0n.js +22 -0
- package/dist/link-provider-DPBGo-0n.js.map +1 -0
- package/dist/loader-DHGMYlC6.js +105 -0
- package/dist/loader-DHGMYlC6.js.map +1 -0
- package/dist/menubar-DLwLRFB1.js +92 -0
- package/dist/menubar-DLwLRFB1.js.map +1 -0
- package/dist/meter-DKUuvXxS.js +51 -0
- package/dist/meter-DKUuvXxS.js.map +1 -0
- package/dist/pagination-C4HQqodz.js +99 -0
- package/dist/pagination-C4HQqodz.js.map +1 -0
- package/dist/popover-DhdIqrP7.js +178 -0
- package/dist/popover-DhdIqrP7.js.map +1 -0
- package/dist/primitives/accordion.js +6 -0
- package/dist/primitives/accordion.js.map +1 -0
- package/dist/primitives/alert-dialog.js +6 -0
- package/dist/primitives/alert-dialog.js.map +1 -0
- package/dist/primitives/autocomplete.js +6 -0
- package/dist/primitives/autocomplete.js.map +1 -0
- package/dist/primitives/avatar.js +6 -0
- package/dist/primitives/avatar.js.map +1 -0
- package/dist/primitives/button.js +6 -0
- package/dist/primitives/button.js.map +1 -0
- package/dist/primitives/checkbox-group.js +6 -0
- package/dist/primitives/checkbox-group.js.map +1 -0
- package/dist/primitives/checkbox.js +6 -0
- package/dist/primitives/checkbox.js.map +1 -0
- package/dist/primitives/collapsible.js +6 -0
- package/dist/primitives/collapsible.js.map +1 -0
- package/dist/primitives/combobox.js +6 -0
- package/dist/primitives/combobox.js.map +1 -0
- package/dist/primitives/context-menu.js +6 -0
- package/dist/primitives/context-menu.js.map +1 -0
- package/dist/primitives/dialog.js +6 -0
- package/dist/primitives/dialog.js.map +1 -0
- package/dist/primitives/direction-provider.js +7 -0
- package/dist/primitives/direction-provider.js.map +1 -0
- package/dist/primitives/field.js +6 -0
- package/dist/primitives/field.js.map +1 -0
- package/dist/primitives/fieldset.js +6 -0
- package/dist/primitives/fieldset.js.map +1 -0
- package/dist/primitives/form.js +6 -0
- package/dist/primitives/form.js.map +1 -0
- package/dist/primitives/input.js +6 -0
- package/dist/primitives/input.js.map +1 -0
- package/dist/primitives/menu.js +6 -0
- package/dist/primitives/menu.js.map +1 -0
- package/dist/primitives/menubar.js +6 -0
- package/dist/primitives/menubar.js.map +1 -0
- package/dist/primitives/meter.js +6 -0
- package/dist/primitives/meter.js.map +1 -0
- package/dist/primitives/navigation-menu.js +6 -0
- package/dist/primitives/navigation-menu.js.map +1 -0
- package/dist/primitives/number-field.js +6 -0
- package/dist/primitives/number-field.js.map +1 -0
- package/dist/primitives/popover.js +6 -0
- package/dist/primitives/popover.js.map +1 -0
- package/dist/primitives/preview-card.js +6 -0
- package/dist/primitives/preview-card.js.map +1 -0
- package/dist/primitives/progress.js +6 -0
- package/dist/primitives/progress.js.map +1 -0
- package/dist/primitives/radio-group.js +6 -0
- package/dist/primitives/radio-group.js.map +1 -0
- package/dist/primitives/radio.js +6 -0
- package/dist/primitives/radio.js.map +1 -0
- package/dist/primitives/scroll-area.js +6 -0
- package/dist/primitives/scroll-area.js.map +1 -0
- package/dist/primitives/select.js +6 -0
- package/dist/primitives/select.js.map +1 -0
- package/dist/primitives/separator.js +6 -0
- package/dist/primitives/separator.js.map +1 -0
- package/dist/primitives/slider.js +6 -0
- package/dist/primitives/slider.js.map +1 -0
- package/dist/primitives/switch.js +6 -0
- package/dist/primitives/switch.js.map +1 -0
- package/dist/primitives/tabs.js +6 -0
- package/dist/primitives/tabs.js.map +1 -0
- package/dist/primitives/toast.js +6 -0
- package/dist/primitives/toast.js.map +1 -0
- package/dist/primitives/toggle-group.js +6 -0
- package/dist/primitives/toggle-group.js.map +1 -0
- package/dist/primitives/toggle.js +6 -0
- package/dist/primitives/toggle.js.map +1 -0
- package/dist/primitives/toolbar.js +6 -0
- package/dist/primitives/toolbar.js.map +1 -0
- package/dist/primitives/tooltip.js +6 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/primitives.js +43 -0
- package/dist/primitives.js.map +1 -0
- package/dist/radio-BVAG7hNp.js +125 -0
- package/dist/radio-BVAG7hNp.js.map +1 -0
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -0
- package/dist/schemas-BSdA0fz-.js +3210 -0
- package/dist/schemas-BSdA0fz-.js.map +1 -0
- package/dist/select-B5Vb3zou.js +122 -0
- package/dist/select-B5Vb3zou.js.map +1 -0
- package/dist/sensitive-input-D5HCV04N.js +258 -0
- package/dist/sensitive-input-D5HCV04N.js.map +1 -0
- package/dist/skeleton-line-CtpS1u1J.js +28 -0
- package/dist/skeleton-line-CtpS1u1J.js.map +1 -0
- package/dist/src/blocks/page-header/index.d.ts +2 -0
- package/dist/src/blocks/page-header/index.d.ts.map +1 -0
- package/dist/src/blocks/page-header/page-header.d.ts +38 -0
- package/dist/src/blocks/page-header/page-header.d.ts.map +1 -0
- package/dist/src/blocks/resource-list/index.d.ts +2 -0
- package/dist/src/blocks/resource-list/index.d.ts.map +1 -0
- package/dist/src/blocks/resource-list/resource-list.d.ts +18 -0
- package/dist/src/blocks/resource-list/resource-list.d.ts.map +1 -0
- package/dist/src/catalog/catalog.d.ts +75 -0
- package/dist/src/catalog/catalog.d.ts.map +1 -0
- package/dist/src/catalog/data.d.ts +44 -0
- package/dist/src/catalog/data.d.ts.map +1 -0
- package/dist/src/catalog/index.d.ts +39 -0
- package/dist/src/catalog/index.d.ts.map +1 -0
- package/dist/src/catalog/types.d.ts +226 -0
- package/dist/src/catalog/types.d.ts.map +1 -0
- package/dist/src/catalog/visibility.d.ts +37 -0
- package/dist/src/catalog/visibility.d.ts.map +1 -0
- package/dist/src/command-line/build-cli.d.ts +7 -0
- package/dist/src/command-line/build-cli.d.ts.map +1 -0
- package/dist/src/command-line/cli.d.ts +13 -0
- package/dist/src/command-line/cli.d.ts.map +1 -0
- package/dist/src/command-line/commands/add.d.ts +10 -0
- package/dist/src/command-line/commands/add.d.ts.map +1 -0
- package/dist/src/command-line/commands/blocks.d.ts +10 -0
- package/dist/src/command-line/commands/blocks.d.ts.map +1 -0
- package/dist/src/command-line/commands/doc.d.ts +14 -0
- package/dist/src/command-line/commands/doc.d.ts.map +1 -0
- package/dist/src/command-line/commands/init.d.ts +18 -0
- package/dist/src/command-line/commands/init.d.ts.map +1 -0
- package/dist/src/command-line/commands/ls.d.ts +10 -0
- package/dist/src/command-line/commands/ls.d.ts.map +1 -0
- package/dist/src/command-line/commands/migrate.d.ts +10 -0
- package/dist/src/command-line/commands/migrate.d.ts.map +1 -0
- package/dist/src/command-line/utils/config.d.ts +42 -0
- package/dist/src/command-line/utils/config.d.ts.map +1 -0
- package/dist/src/command-line/utils/transformer.d.ts +17 -0
- package/dist/src/command-line/utils/transformer.d.ts.map +1 -0
- package/dist/src/components/badge/badge.d.ts +46 -0
- package/dist/src/components/badge/badge.d.ts.map +1 -0
- package/dist/src/components/badge/index.d.ts +2 -0
- package/dist/src/components/badge/index.d.ts.map +1 -0
- package/dist/src/components/banner/banner.d.ts +45 -0
- package/dist/src/components/banner/banner.d.ts.map +1 -0
- package/dist/src/components/banner/index.d.ts +2 -0
- package/dist/src/components/banner/index.d.ts.map +1 -0
- package/dist/src/components/breadcrumbs/breadcrumbs.d.ts +43 -0
- package/dist/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/src/components/breadcrumbs/index.d.ts +2 -0
- package/dist/src/components/breadcrumbs/index.d.ts.map +1 -0
- package/dist/src/components/button/button.d.ts +118 -0
- package/dist/src/components/button/button.d.ts.map +1 -0
- package/dist/src/components/button/index.d.ts +2 -0
- package/dist/src/components/button/index.d.ts.map +1 -0
- package/dist/src/components/checkbox/checkbox.d.ts +167 -0
- package/dist/src/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/src/components/checkbox/index.d.ts +2 -0
- package/dist/src/components/checkbox/index.d.ts.map +1 -0
- package/dist/src/components/clipboard-text/clipboard-text.d.ts +38 -0
- package/dist/src/components/clipboard-text/clipboard-text.d.ts.map +1 -0
- package/dist/src/components/clipboard-text/index.d.ts +2 -0
- package/dist/src/components/clipboard-text/index.d.ts.map +1 -0
- package/dist/src/components/code/code.d.ts +138 -0
- package/dist/src/components/code/code.d.ts.map +1 -0
- package/dist/src/components/code/index.d.ts +4 -0
- package/dist/src/components/code/index.d.ts.map +1 -0
- package/dist/src/components/collapsible/collapsible.d.ts +62 -0
- package/dist/src/components/collapsible/collapsible.d.ts.map +1 -0
- package/dist/src/components/collapsible/index.d.ts +2 -0
- package/dist/src/components/collapsible/index.d.ts.map +1 -0
- package/dist/src/components/combobox/combobox.d.ts +124 -0
- package/dist/src/components/combobox/combobox.d.ts.map +1 -0
- package/dist/src/components/combobox/index.d.ts +2 -0
- package/dist/src/components/combobox/index.d.ts.map +1 -0
- package/dist/src/components/command-palette/command-palette.d.ts +225 -0
- package/dist/src/components/command-palette/command-palette.d.ts.map +1 -0
- package/dist/src/components/command-palette/index.d.ts +3 -0
- package/dist/src/components/command-palette/index.d.ts.map +1 -0
- package/dist/src/components/command-palette/types.d.ts +149 -0
- package/dist/src/components/command-palette/types.d.ts.map +1 -0
- package/dist/src/components/date-range-picker/date-range-picker.d.ts +65 -0
- package/dist/src/components/date-range-picker/date-range-picker.d.ts.map +1 -0
- package/dist/src/components/date-range-picker/index.d.ts +2 -0
- package/dist/src/components/date-range-picker/index.d.ts.map +1 -0
- package/dist/src/components/dialog/dialog.d.ts +121 -0
- package/dist/src/components/dialog/dialog.d.ts.map +1 -0
- package/dist/src/components/dialog/index.d.ts +2 -0
- package/dist/src/components/dialog/index.d.ts.map +1 -0
- package/dist/src/components/dropdown/dropdown.d.ts +58 -0
- package/dist/src/components/dropdown/dropdown.d.ts.map +1 -0
- package/dist/src/components/dropdown/index.d.ts +2 -0
- package/dist/src/components/dropdown/index.d.ts.map +1 -0
- package/dist/src/components/empty/empty.d.ts +34 -0
- package/dist/src/components/empty/empty.d.ts.map +1 -0
- package/dist/src/components/empty/index.d.ts +2 -0
- package/dist/src/components/empty/index.d.ts.map +1 -0
- package/dist/src/components/field/field.d.ts +38 -0
- package/dist/src/components/field/field.d.ts.map +1 -0
- package/dist/src/components/field/index.d.ts +2 -0
- package/dist/src/components/field/index.d.ts.map +1 -0
- package/dist/src/components/grid/grid.d.ts +107 -0
- package/dist/src/components/grid/grid.d.ts.map +1 -0
- package/dist/src/components/grid/index.d.ts +2 -0
- package/dist/src/components/grid/index.d.ts.map +1 -0
- package/dist/src/components/input/index.d.ts +4 -0
- package/dist/src/components/input/index.d.ts.map +1 -0
- package/dist/src/components/input/input-area.d.ts +46 -0
- package/dist/src/components/input/input-area.d.ts.map +1 -0
- package/dist/src/components/input/input-group.d.ts +39 -0
- package/dist/src/components/input/input-group.d.ts.map +1 -0
- package/dist/src/components/input/input.d.ts +157 -0
- package/dist/src/components/input/input.d.ts.map +1 -0
- package/dist/src/components/label/index.d.ts +2 -0
- package/dist/src/components/label/index.d.ts.map +1 -0
- package/dist/src/components/label/label.d.ts +54 -0
- package/dist/src/components/label/label.d.ts.map +1 -0
- package/dist/src/components/layer-card/index.d.ts +2 -0
- package/dist/src/components/layer-card/index.d.ts.map +1 -0
- package/dist/src/components/layer-card/layer-card.d.ts +16 -0
- package/dist/src/components/layer-card/layer-card.d.ts.map +1 -0
- package/dist/src/components/link/index.d.ts +2 -0
- package/dist/src/components/link/index.d.ts.map +1 -0
- package/dist/src/components/link/link.d.ts +35 -0
- package/dist/src/components/link/link.d.ts.map +1 -0
- package/dist/src/components/loader/index.d.ts +3 -0
- package/dist/src/components/loader/index.d.ts.map +1 -0
- package/dist/src/components/loader/loader.d.ts +30 -0
- package/dist/src/components/loader/loader.d.ts.map +1 -0
- package/dist/src/components/loader/skeleton-line.d.ts +10 -0
- package/dist/src/components/loader/skeleton-line.d.ts.map +1 -0
- package/dist/src/components/menubar/index.d.ts +3 -0
- package/dist/src/components/menubar/index.d.ts.map +1 -0
- package/dist/src/components/menubar/menubar.d.ts +22 -0
- package/dist/src/components/menubar/menubar.d.ts.map +1 -0
- package/dist/src/components/menubar/use-menu-navigation.d.ts +8 -0
- package/dist/src/components/menubar/use-menu-navigation.d.ts.map +1 -0
- package/dist/src/components/meter/index.d.ts +2 -0
- package/dist/src/components/meter/index.d.ts.map +1 -0
- package/dist/src/components/meter/meter.d.ts +18 -0
- package/dist/src/components/meter/meter.d.ts.map +1 -0
- package/dist/src/components/pagination/index.d.ts +2 -0
- package/dist/src/components/pagination/index.d.ts.map +1 -0
- package/dist/src/components/pagination/pagination.d.ts +28 -0
- package/dist/src/components/pagination/pagination.d.ts.map +1 -0
- package/dist/src/components/popover/index.d.ts +3 -0
- package/dist/src/components/popover/index.d.ts.map +1 -0
- package/dist/src/components/popover/popover.d.ts +110 -0
- package/dist/src/components/popover/popover.d.ts.map +1 -0
- package/dist/src/components/radio/index.d.ts +2 -0
- package/dist/src/components/radio/index.d.ts.map +1 -0
- package/dist/src/components/radio/radio.d.ts +141 -0
- package/dist/src/components/radio/radio.d.ts.map +1 -0
- package/dist/src/components/select/index.d.ts +2 -0
- package/dist/src/components/select/index.d.ts.map +1 -0
- package/dist/src/components/select/select.d.ts +128 -0
- package/dist/src/components/select/select.d.ts.map +1 -0
- package/dist/src/components/sensitive-input/index.d.ts +2 -0
- package/dist/src/components/sensitive-input/index.d.ts.map +1 -0
- package/dist/src/components/sensitive-input/sensitive-input.d.ts +70 -0
- package/dist/src/components/sensitive-input/sensitive-input.d.ts.map +1 -0
- package/dist/src/components/surface/index.d.ts +2 -0
- package/dist/src/components/surface/index.d.ts.map +1 -0
- package/dist/src/components/surface/surface.d.ts +48 -0
- package/dist/src/components/surface/surface.d.ts.map +1 -0
- package/dist/src/components/switch/index.d.ts +2 -0
- package/dist/src/components/switch/index.d.ts.map +1 -0
- package/dist/src/components/switch/switch.d.ts +155 -0
- package/dist/src/components/switch/switch.d.ts.map +1 -0
- package/dist/src/components/table/index.d.ts +2 -0
- package/dist/src/components/table/index.d.ts.map +1 -0
- package/dist/src/components/table/table.d.ts +54 -0
- package/dist/src/components/table/table.d.ts.map +1 -0
- package/dist/src/components/tabs/index.d.ts +3 -0
- package/dist/src/components/tabs/index.d.ts.map +1 -0
- package/dist/src/components/tabs/tabs.d.ts +64 -0
- package/dist/src/components/tabs/tabs.d.ts.map +1 -0
- package/dist/src/components/text/index.d.ts +2 -0
- package/dist/src/components/text/index.d.ts.map +1 -0
- package/dist/src/components/text/text.d.ts +153 -0
- package/dist/src/components/text/text.d.ts.map +1 -0
- package/dist/src/components/toast/index.d.ts +3 -0
- package/dist/src/components/toast/index.d.ts.map +1 -0
- package/dist/src/components/toast/toast.d.ts +66 -0
- package/dist/src/components/toast/toast.d.ts.map +1 -0
- package/dist/src/components/tooltip/index.d.ts +2 -0
- package/dist/src/components/tooltip/index.d.ts.map +1 -0
- package/dist/src/components/tooltip/tooltip.d.ts +43 -0
- package/dist/src/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/primitives/accordion.d.ts +13 -0
- package/dist/src/primitives/accordion.d.ts.map +1 -0
- package/dist/src/primitives/alert-dialog.d.ts +13 -0
- package/dist/src/primitives/alert-dialog.d.ts.map +1 -0
- package/dist/src/primitives/autocomplete.d.ts +13 -0
- package/dist/src/primitives/autocomplete.d.ts.map +1 -0
- package/dist/src/primitives/avatar.d.ts +13 -0
- package/dist/src/primitives/avatar.d.ts.map +1 -0
- package/dist/src/primitives/button.d.ts +13 -0
- package/dist/src/primitives/button.d.ts.map +1 -0
- package/dist/src/primitives/checkbox-group.d.ts +13 -0
- package/dist/src/primitives/checkbox-group.d.ts.map +1 -0
- package/dist/src/primitives/checkbox.d.ts +13 -0
- package/dist/src/primitives/checkbox.d.ts.map +1 -0
- package/dist/src/primitives/collapsible.d.ts +13 -0
- package/dist/src/primitives/collapsible.d.ts.map +1 -0
- package/dist/src/primitives/combobox.d.ts +13 -0
- package/dist/src/primitives/combobox.d.ts.map +1 -0
- package/dist/src/primitives/context-menu.d.ts +13 -0
- package/dist/src/primitives/context-menu.d.ts.map +1 -0
- package/dist/src/primitives/dialog.d.ts +13 -0
- package/dist/src/primitives/dialog.d.ts.map +1 -0
- package/dist/src/primitives/direction-provider.d.ts +13 -0
- package/dist/src/primitives/direction-provider.d.ts.map +1 -0
- package/dist/src/primitives/field.d.ts +13 -0
- package/dist/src/primitives/field.d.ts.map +1 -0
- package/dist/src/primitives/fieldset.d.ts +13 -0
- package/dist/src/primitives/fieldset.d.ts.map +1 -0
- package/dist/src/primitives/form.d.ts +13 -0
- package/dist/src/primitives/form.d.ts.map +1 -0
- package/dist/src/primitives/index.d.ts +52 -0
- package/dist/src/primitives/index.d.ts.map +1 -0
- package/dist/src/primitives/input.d.ts +13 -0
- package/dist/src/primitives/input.d.ts.map +1 -0
- package/dist/src/primitives/menu.d.ts +13 -0
- package/dist/src/primitives/menu.d.ts.map +1 -0
- package/dist/src/primitives/menubar.d.ts +13 -0
- package/dist/src/primitives/menubar.d.ts.map +1 -0
- package/dist/src/primitives/meter.d.ts +13 -0
- package/dist/src/primitives/meter.d.ts.map +1 -0
- package/dist/src/primitives/navigation-menu.d.ts +13 -0
- package/dist/src/primitives/navigation-menu.d.ts.map +1 -0
- package/dist/src/primitives/number-field.d.ts +13 -0
- package/dist/src/primitives/number-field.d.ts.map +1 -0
- package/dist/src/primitives/popover.d.ts +13 -0
- package/dist/src/primitives/popover.d.ts.map +1 -0
- package/dist/src/primitives/preview-card.d.ts +13 -0
- package/dist/src/primitives/preview-card.d.ts.map +1 -0
- package/dist/src/primitives/progress.d.ts +13 -0
- package/dist/src/primitives/progress.d.ts.map +1 -0
- package/dist/src/primitives/radio-group.d.ts +13 -0
- package/dist/src/primitives/radio-group.d.ts.map +1 -0
- package/dist/src/primitives/radio.d.ts +13 -0
- package/dist/src/primitives/radio.d.ts.map +1 -0
- package/dist/src/primitives/scroll-area.d.ts +13 -0
- package/dist/src/primitives/scroll-area.d.ts.map +1 -0
- package/dist/src/primitives/select.d.ts +13 -0
- package/dist/src/primitives/select.d.ts.map +1 -0
- package/dist/src/primitives/separator.d.ts +13 -0
- package/dist/src/primitives/separator.d.ts.map +1 -0
- package/dist/src/primitives/slider.d.ts +13 -0
- package/dist/src/primitives/slider.d.ts.map +1 -0
- package/dist/src/primitives/switch.d.ts +13 -0
- package/dist/src/primitives/switch.d.ts.map +1 -0
- package/dist/src/primitives/tabs.d.ts +13 -0
- package/dist/src/primitives/tabs.d.ts.map +1 -0
- package/dist/src/primitives/toast.d.ts +13 -0
- package/dist/src/primitives/toast.d.ts.map +1 -0
- package/dist/src/primitives/toggle-group.d.ts +13 -0
- package/dist/src/primitives/toggle-group.d.ts.map +1 -0
- package/dist/src/primitives/toggle.d.ts +13 -0
- package/dist/src/primitives/toggle.d.ts.map +1 -0
- package/dist/src/primitives/toolbar.d.ts +13 -0
- package/dist/src/primitives/toolbar.d.ts.map +1 -0
- package/dist/src/primitives/tooltip.d.ts +13 -0
- package/dist/src/primitives/tooltip.d.ts.map +1 -0
- package/dist/src/registry/index.d.ts +8 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/types.d.ts +191 -0
- package/dist/src/registry/types.d.ts.map +1 -0
- package/dist/src/utils/cn.d.ts +4 -0
- package/dist/src/utils/cn.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/link-provider.d.ts +12 -0
- package/dist/src/utils/link-provider.d.ts.map +1 -0
- package/dist/src/utils/prop-examples.d.ts +36 -0
- package/dist/src/utils/prop-examples.d.ts.map +1 -0
- package/dist/styles/kumo-binding.css +190 -0
- package/dist/styles/kumo-standalone.css +2 -0
- package/dist/styles/kumo.css +55 -0
- package/dist/styles/theme-fedramp.css +20 -0
- package/dist/styles/theme-kumo.css +186 -0
- package/dist/surface-BIC6CXiz.js +21 -0
- package/dist/surface-BIC6CXiz.js.map +1 -0
- package/dist/switch-D4duMhJ0.js +257 -0
- package/dist/switch-D4duMhJ0.js.map +1 -0
- package/dist/table-KuvHGpL8.js +153 -0
- package/dist/table-KuvHGpL8.js.map +1 -0
- package/dist/tabs-lQup-IbT.js +85 -0
- package/dist/tabs-lQup-IbT.js.map +1 -0
- package/dist/text-BEhqwMfe.js +97 -0
- package/dist/text-BEhqwMfe.js.map +1 -0
- package/dist/toast-8YyyQuqZ.js +69 -0
- package/dist/toast-8YyyQuqZ.js.map +1 -0
- package/dist/tooltip-DJWsDTWJ.js +85 -0
- package/dist/tooltip-DJWsDTWJ.js.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/dist/vendor-base-ui-DWIDNgE1.js +20446 -0
- package/dist/vendor-base-ui-DWIDNgE1.js.map +1 -0
- package/dist/vendor-floating-ui-BgbEw62H.js +1286 -0
- package/dist/vendor-floating-ui-BgbEw62H.js.map +1 -0
- package/dist/vendor-styling-BQbxAbdS.js +2775 -0
- package/dist/vendor-styling-BQbxAbdS.js.map +1 -0
- package/dist/vendor-utils-DD8jNJwD.js +741 -0
- package/dist/vendor-utils-DD8jNJwD.js.map +1 -0
- package/package.json +444 -0
- package/scripts/component-registry/cache.ts +123 -0
- package/scripts/component-registry/discovery.ts +469 -0
- package/scripts/component-registry/example-cleanup.ts +168 -0
- package/scripts/component-registry/index.test.ts +680 -0
- package/scripts/component-registry/index.ts +874 -0
- package/scripts/component-registry/markdown-generator.ts +222 -0
- package/scripts/component-registry/metadata.ts +643 -0
- package/scripts/component-registry/props-filter.ts +310 -0
- package/scripts/component-registry/schema-generator.ts +326 -0
- package/scripts/component-registry/sub-components.ts +349 -0
- package/scripts/component-registry/types.ts +156 -0
- package/scripts/component-registry/utils.ts +280 -0
- package/scripts/component-registry/variant-parser.ts +261 -0
- package/scripts/css-build.ts +55 -0
- package/scripts/generate-primitives.ts +178 -0
- package/scripts/theme-generator/config.ts +392 -0
- package/scripts/theme-generator/generate-css.ts +250 -0
- package/scripts/theme-generator/index.ts +159 -0
- package/scripts/theme-generator/migrate.ts +560 -0
- package/scripts/theme-generator/types.ts +86 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Metadata Generator for AI/Agent Consumption
|
|
3
|
+
*
|
|
4
|
+
* This script auto-discovers components from the filesystem and uses
|
|
5
|
+
* ts-json-schema-generator to derive props directly from TypeScript types,
|
|
6
|
+
* then enriches with variant descriptions from KUMO_*_VARIANTS.
|
|
7
|
+
*
|
|
8
|
+
* Components are auto-discovered from src/components/ subdirectories.
|
|
9
|
+
* Each component must export KUMO_<NAME>_VARIANTS and KUMO_<NAME>_DEFAULT_VARIANTS
|
|
10
|
+
*
|
|
11
|
+
* Run: pnpm codegen:registry
|
|
12
|
+
* Output: ai/component-registry.json (committed to git)
|
|
13
|
+
*
|
|
14
|
+
* Performance optimizations:
|
|
15
|
+
* - Hash-based caching: Skip regeneration for unchanged components
|
|
16
|
+
* - Parallel processing: Process components concurrently (8 at a time)
|
|
17
|
+
* - Skip inherited props by default: Opt-in with --inherited-props flag
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { writeFileSync, mkdirSync, readFileSync } from "node:fs";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import * as tsj from "ts-json-schema-generator";
|
|
24
|
+
import type { Definition } from "ts-json-schema-generator";
|
|
25
|
+
|
|
26
|
+
// Internal module imports
|
|
27
|
+
import type {
|
|
28
|
+
CLIFlags,
|
|
29
|
+
CacheFile,
|
|
30
|
+
ComponentConfig,
|
|
31
|
+
ComponentSchema,
|
|
32
|
+
PropSchema,
|
|
33
|
+
SubComponentSchema,
|
|
34
|
+
ProcessComponentResult,
|
|
35
|
+
GenerateRegistryResult,
|
|
36
|
+
} from "./types.js";
|
|
37
|
+
import type { BlockSchema } from "../../src/registry/types.js";
|
|
38
|
+
import {
|
|
39
|
+
CACHE_VERSION,
|
|
40
|
+
loadCache,
|
|
41
|
+
saveCache,
|
|
42
|
+
getCachedComponent,
|
|
43
|
+
hashFileContent,
|
|
44
|
+
createCacheEntry,
|
|
45
|
+
} from "./cache.js";
|
|
46
|
+
import {
|
|
47
|
+
toScreamingSnakeCase,
|
|
48
|
+
extractSemanticColors,
|
|
49
|
+
extractBlockDependencies,
|
|
50
|
+
getBlockFiles,
|
|
51
|
+
} from "./utils.js";
|
|
52
|
+
import { discoverComponents, discoverBlocks } from "./discovery.js";
|
|
53
|
+
import { shouldSkipProp } from "./props-filter.js";
|
|
54
|
+
import {
|
|
55
|
+
detectSubComponents,
|
|
56
|
+
extractSubComponentProps,
|
|
57
|
+
} from "./sub-components.js";
|
|
58
|
+
import { generateAIContext } from "./markdown-generator.js";
|
|
59
|
+
import { generateSchemasFile } from "./schema-generator.js";
|
|
60
|
+
import {
|
|
61
|
+
PASSTHROUGH_COMPONENT_DOCS,
|
|
62
|
+
ADDITIONAL_COMPONENT_PROPS,
|
|
63
|
+
PROP_TYPE_OVERRIDES,
|
|
64
|
+
COMPONENT_STYLING_METADATA,
|
|
65
|
+
} from "./metadata.js";
|
|
66
|
+
|
|
67
|
+
// External imports - demo examples from kumo-docs-astro
|
|
68
|
+
import { existsSync } from "node:fs";
|
|
69
|
+
|
|
70
|
+
// Type for demo metadata (matches kumo-docs-astro output)
|
|
71
|
+
interface DemoMetadata {
|
|
72
|
+
generatedAt: string;
|
|
73
|
+
version: string;
|
|
74
|
+
components: Record<
|
|
75
|
+
string,
|
|
76
|
+
{
|
|
77
|
+
componentName: string;
|
|
78
|
+
sourceFile: string;
|
|
79
|
+
demos: Array<{
|
|
80
|
+
name: string;
|
|
81
|
+
code: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Load demo examples from kumo-docs-astro's generated metadata file.
|
|
90
|
+
* Returns a map compatible with the existing storyExamples interface.
|
|
91
|
+
*/
|
|
92
|
+
function loadDemoExamples(): Map<string, { aiExamples: string[] }> {
|
|
93
|
+
const demoMetadataPath = join(
|
|
94
|
+
__dirname,
|
|
95
|
+
"../../../kumo-docs-astro/dist/demo-metadata.json",
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (!existsSync(demoMetadataPath)) {
|
|
99
|
+
console.warn(
|
|
100
|
+
`Warning: demo-metadata.json not found at ${demoMetadataPath}`,
|
|
101
|
+
);
|
|
102
|
+
console.warn(
|
|
103
|
+
"Run 'pnpm --filter @cloudflare/kumo-docs-astro codegen:demos' first",
|
|
104
|
+
);
|
|
105
|
+
return new Map();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const metadata: DemoMetadata = JSON.parse(
|
|
109
|
+
readFileSync(demoMetadataPath, "utf-8"),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const examples = new Map<string, { aiExamples: string[] }>();
|
|
113
|
+
|
|
114
|
+
for (const [componentName, data] of Object.entries(metadata.components)) {
|
|
115
|
+
examples.set(componentName, {
|
|
116
|
+
aiExamples: data.demos.map((demo) => demo.code),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return examples;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
124
|
+
const componentsDir = join(__dirname, "../../src/components");
|
|
125
|
+
const blocksDir = join(__dirname, "../../src/blocks");
|
|
126
|
+
const rootDir = join(__dirname, "../..");
|
|
127
|
+
const cacheDir = join(__dirname, "../../.cache");
|
|
128
|
+
const cachePath = join(cacheDir, "component-registry-cache.json");
|
|
129
|
+
|
|
130
|
+
// =============================================================================
|
|
131
|
+
// CLI Flags
|
|
132
|
+
// =============================================================================
|
|
133
|
+
|
|
134
|
+
function parseCLIFlags(): CLIFlags {
|
|
135
|
+
const args = process.argv.slice(2);
|
|
136
|
+
return {
|
|
137
|
+
includeInheritedProps: args.includes("--inherited-props"),
|
|
138
|
+
noCache: args.includes("--no-cache"),
|
|
139
|
+
verbose: args.includes("--verbose"),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const CLI_FLAGS = parseCLIFlags();
|
|
144
|
+
|
|
145
|
+
// =============================================================================
|
|
146
|
+
// JSON Schema Type Conversion
|
|
147
|
+
// =============================================================================
|
|
148
|
+
|
|
149
|
+
function jsonSchemaTypeToString(def: Definition): string {
|
|
150
|
+
if (def.$ref) {
|
|
151
|
+
// Extract type name from $ref like "#/definitions/ReactNode"
|
|
152
|
+
const refName = decodeURIComponent(def.$ref.split("/").pop() || "unknown");
|
|
153
|
+
// Simplify common React types
|
|
154
|
+
if (refName.includes("ReactNode") || refName.includes("ReactElement")) {
|
|
155
|
+
return "ReactNode";
|
|
156
|
+
}
|
|
157
|
+
return refName;
|
|
158
|
+
}
|
|
159
|
+
if (def.enum) {
|
|
160
|
+
return "enum";
|
|
161
|
+
}
|
|
162
|
+
if (def.type === "array") {
|
|
163
|
+
const itemType = def.items
|
|
164
|
+
? jsonSchemaTypeToString(def.items as Definition)
|
|
165
|
+
: "unknown";
|
|
166
|
+
return `${itemType}[]`;
|
|
167
|
+
}
|
|
168
|
+
if (def.anyOf || def.oneOf) {
|
|
169
|
+
const types = (def.anyOf || def.oneOf) as Definition[];
|
|
170
|
+
const typeStrings = types
|
|
171
|
+
.map((t) => jsonSchemaTypeToString(t))
|
|
172
|
+
.filter((t) => t !== "undefined" && t !== "null");
|
|
173
|
+
// Simplify if it includes ReactNode variants
|
|
174
|
+
if (typeStrings.some((t) => t.includes("React"))) {
|
|
175
|
+
return "ReactNode";
|
|
176
|
+
}
|
|
177
|
+
return typeStrings.join(" | ");
|
|
178
|
+
}
|
|
179
|
+
if (def.type) {
|
|
180
|
+
return Array.isArray(def.type) ? def.type.join(" | ") : def.type;
|
|
181
|
+
}
|
|
182
|
+
return "unknown";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Resolve a $ref to its actual definition.
|
|
187
|
+
* Returns the resolved definition or the original if no $ref.
|
|
188
|
+
*/
|
|
189
|
+
function resolveRef(
|
|
190
|
+
def: Definition,
|
|
191
|
+
allDefinitions?: Record<string, Definition>,
|
|
192
|
+
): Definition {
|
|
193
|
+
if (!def.$ref || !allDefinitions) {
|
|
194
|
+
return def;
|
|
195
|
+
}
|
|
196
|
+
const refName = decodeURIComponent(def.$ref.split("/").pop() || "");
|
|
197
|
+
const resolved = allDefinitions[refName];
|
|
198
|
+
return resolved || def;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function convertToPropSchema(
|
|
202
|
+
propName: string,
|
|
203
|
+
def: Definition,
|
|
204
|
+
required: boolean,
|
|
205
|
+
// biome-ignore lint/suspicious/noExplicitAny: Variants have varying shapes
|
|
206
|
+
variants?: Record<string, Record<string, any>>,
|
|
207
|
+
defaults?: Record<string, string>,
|
|
208
|
+
allDefinitions?: Record<string, Definition>,
|
|
209
|
+
): PropSchema {
|
|
210
|
+
// Resolve $ref to get the actual definition (for enum detection)
|
|
211
|
+
const resolvedDef = resolveRef(def, allDefinitions);
|
|
212
|
+
|
|
213
|
+
const prop: PropSchema = {
|
|
214
|
+
type: jsonSchemaTypeToString(def),
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
if (required) {
|
|
218
|
+
prop.required = true;
|
|
219
|
+
} else {
|
|
220
|
+
prop.optional = true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (def.description) {
|
|
224
|
+
prop.description = def.description;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Handle enums - check both original def and resolved def (for $ref cases)
|
|
228
|
+
if (def.enum) {
|
|
229
|
+
prop.values = def.enum as string[];
|
|
230
|
+
prop.type = "enum";
|
|
231
|
+
} else if (resolvedDef.enum) {
|
|
232
|
+
// Enum found via $ref resolution (e.g., KumoCodeLang)
|
|
233
|
+
prop.values = resolvedDef.enum as string[];
|
|
234
|
+
prop.type = "enum";
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Enrich with variant descriptions and classes if this prop is a variant
|
|
238
|
+
if (variants && propName in variants) {
|
|
239
|
+
const variantDef = variants[propName];
|
|
240
|
+
prop.values = Object.keys(variantDef);
|
|
241
|
+
prop.type = "enum";
|
|
242
|
+
|
|
243
|
+
const descriptions: Record<string, string> = {};
|
|
244
|
+
const classes: Record<string, string> = {};
|
|
245
|
+
const stateClassesMap: Record<string, Record<string, string>> = {};
|
|
246
|
+
|
|
247
|
+
for (const [key, val] of Object.entries(variantDef)) {
|
|
248
|
+
if (val.description) {
|
|
249
|
+
descriptions[key] = val.description;
|
|
250
|
+
}
|
|
251
|
+
if (val.classes) {
|
|
252
|
+
classes[key] = val.classes;
|
|
253
|
+
}
|
|
254
|
+
if (val.stateClasses) {
|
|
255
|
+
stateClassesMap[key] = val.stateClasses;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (Object.keys(descriptions).length > 0) {
|
|
260
|
+
prop.descriptions = descriptions;
|
|
261
|
+
}
|
|
262
|
+
if (Object.keys(classes).length > 0) {
|
|
263
|
+
prop.classes = classes;
|
|
264
|
+
}
|
|
265
|
+
if (Object.keys(stateClassesMap).length > 0) {
|
|
266
|
+
prop.stateClasses = stateClassesMap;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Add default value from variants defaults
|
|
271
|
+
if (defaults && propName in defaults) {
|
|
272
|
+
prop.default = defaults[propName];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return prop;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// =============================================================================
|
|
279
|
+
// Props Generation from TypeScript Types
|
|
280
|
+
// =============================================================================
|
|
281
|
+
|
|
282
|
+
/** Derive propsType from component name */
|
|
283
|
+
function getPropsType(config: ComponentConfig): string {
|
|
284
|
+
return config.propsType ?? `${config.name}Props`;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Derive sourceFile from component config */
|
|
288
|
+
function getSourceFile(config: ComponentConfig): string {
|
|
289
|
+
return config.sourceFile;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function generatePropsFromType(
|
|
293
|
+
config: ComponentConfig,
|
|
294
|
+
): Record<string, PropSchema> {
|
|
295
|
+
const sourceFile = getSourceFile(config);
|
|
296
|
+
const propsType = getPropsType(config);
|
|
297
|
+
const sourcePath = join(config.sourceDir, sourceFile);
|
|
298
|
+
|
|
299
|
+
try {
|
|
300
|
+
const tsjConfig: tsj.Config = {
|
|
301
|
+
path: sourcePath,
|
|
302
|
+
tsconfig: join(rootDir, "tsconfig.json"),
|
|
303
|
+
type: propsType,
|
|
304
|
+
skipTypeCheck: true,
|
|
305
|
+
expose: "all",
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const schema = tsj.createGenerator(tsjConfig).createSchema(propsType);
|
|
309
|
+
const props: Record<string, PropSchema> = {};
|
|
310
|
+
|
|
311
|
+
// Get the main type definition, following $ref if needed
|
|
312
|
+
let mainDef = schema.definitions?.[propsType] as Definition;
|
|
313
|
+
if (!mainDef) {
|
|
314
|
+
console.warn(`Warning: Could not find type ${propsType}`);
|
|
315
|
+
return {};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Follow $ref chain to get the actual definition
|
|
319
|
+
// This handles cases like: ExpandableProps -> React.PropsWithChildren<...>
|
|
320
|
+
while (mainDef.$ref && !mainDef.properties && !mainDef.allOf) {
|
|
321
|
+
const refName = decodeURIComponent(mainDef.$ref.split("/").pop()!);
|
|
322
|
+
const refDef = schema.definitions?.[refName] as Definition;
|
|
323
|
+
if (!refDef) break;
|
|
324
|
+
mainDef = refDef;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Handle intersection types (allOf) - merge all properties
|
|
328
|
+
// biome-ignore lint/suspicious/noExplicitAny: JSON Schema types are complex
|
|
329
|
+
let allProperties: Record<string, any> = {};
|
|
330
|
+
let allRequired: string[] = [];
|
|
331
|
+
|
|
332
|
+
if (mainDef.allOf) {
|
|
333
|
+
for (const part of mainDef.allOf as Definition[]) {
|
|
334
|
+
if (part.$ref) {
|
|
335
|
+
const refName = part.$ref.split("/").pop()!;
|
|
336
|
+
const refDef = schema.definitions?.[refName] as Definition;
|
|
337
|
+
if (refDef?.properties) {
|
|
338
|
+
allProperties = { ...allProperties, ...refDef.properties };
|
|
339
|
+
}
|
|
340
|
+
if (refDef?.required) {
|
|
341
|
+
allRequired = [...allRequired, ...(refDef.required as string[])];
|
|
342
|
+
}
|
|
343
|
+
} else if (part.properties) {
|
|
344
|
+
allProperties = { ...allProperties, ...part.properties };
|
|
345
|
+
if (part.required) {
|
|
346
|
+
allRequired = [...allRequired, ...(part.required as string[])];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
} else if (mainDef.properties) {
|
|
351
|
+
allProperties = mainDef.properties;
|
|
352
|
+
allRequired = (mainDef.required as string[]) || [];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Convert each property
|
|
356
|
+
for (const [propName, propDef] of Object.entries(allProperties)) {
|
|
357
|
+
// Skip internal React props and inherited DOM props we don't want to expose
|
|
358
|
+
if (shouldSkipProp(propName, CLI_FLAGS)) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
props[propName] = convertToPropSchema(
|
|
363
|
+
propName,
|
|
364
|
+
propDef as Definition,
|
|
365
|
+
allRequired.includes(propName),
|
|
366
|
+
config.variants,
|
|
367
|
+
config.defaults,
|
|
368
|
+
schema.definitions as Record<string, Definition>,
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return props;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.warn(
|
|
375
|
+
`Warning: Could not generate schema for ${getPropsType(config)}:`,
|
|
376
|
+
error,
|
|
377
|
+
);
|
|
378
|
+
// Fallback: generate props from variants only
|
|
379
|
+
return generatePropsFromVariantsOnly(config);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Fallback props generation when ts-json-schema-generator fails.
|
|
385
|
+
* Extracts props from the KUMO_*_VARIANTS object only.
|
|
386
|
+
* This is useful for components with complex generic types.
|
|
387
|
+
*/
|
|
388
|
+
function generatePropsFromVariantsOnly(
|
|
389
|
+
config: ComponentConfig,
|
|
390
|
+
): Record<string, PropSchema> {
|
|
391
|
+
const props: Record<string, PropSchema> = {};
|
|
392
|
+
|
|
393
|
+
// Add variant props from the config
|
|
394
|
+
for (const [propName, variantDef] of Object.entries(config.variants)) {
|
|
395
|
+
const values = Object.keys(variantDef);
|
|
396
|
+
const descriptions: Record<string, string> = {};
|
|
397
|
+
|
|
398
|
+
for (const [key, val] of Object.entries(variantDef)) {
|
|
399
|
+
if (val.description) {
|
|
400
|
+
descriptions[key] = val.description;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
props[propName] = {
|
|
405
|
+
type: "enum",
|
|
406
|
+
values,
|
|
407
|
+
...(config.defaults[propName] && { default: config.defaults[propName] }),
|
|
408
|
+
...(Object.keys(descriptions).length > 0 && { descriptions }),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Add common props that most components have
|
|
413
|
+
props.className = { type: "string", description: "Additional CSS classes" };
|
|
414
|
+
props.children = { type: "ReactNode", description: "Child elements" };
|
|
415
|
+
|
|
416
|
+
console.log(
|
|
417
|
+
` → Fallback: generated ${Object.keys(props).length} props from variants`,
|
|
418
|
+
);
|
|
419
|
+
return props;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// =============================================================================
|
|
423
|
+
// Process Individual Component
|
|
424
|
+
// =============================================================================
|
|
425
|
+
|
|
426
|
+
interface ProcessComponentInput {
|
|
427
|
+
config: ComponentConfig;
|
|
428
|
+
variantConstants: Map<string, string[]>;
|
|
429
|
+
storyExamples: Map<string, { aiExamples: string[] }>;
|
|
430
|
+
cache: CacheFile;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
async function processComponent(
|
|
434
|
+
input: ProcessComponentInput,
|
|
435
|
+
): Promise<ProcessComponentResult> {
|
|
436
|
+
const { config, cache } = input;
|
|
437
|
+
const sourcePath = join(config.sourceDir, getSourceFile(config));
|
|
438
|
+
const storyPath = join(
|
|
439
|
+
config.sourceDir,
|
|
440
|
+
config.dirName,
|
|
441
|
+
`${config.dirName}.stories.tsx`,
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
// Compute hashes for cache checking
|
|
445
|
+
const sourceHash = hashFileContent(sourcePath);
|
|
446
|
+
const storyHash = hashFileContent(storyPath);
|
|
447
|
+
|
|
448
|
+
// Check cache
|
|
449
|
+
const cachedMetadata = getCachedComponent(
|
|
450
|
+
config.name,
|
|
451
|
+
sourceHash,
|
|
452
|
+
storyHash,
|
|
453
|
+
cache,
|
|
454
|
+
CLI_FLAGS,
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
if (cachedMetadata) {
|
|
458
|
+
if (CLI_FLAGS.verbose) {
|
|
459
|
+
console.log(` ✓ ${config.name} (cached)`);
|
|
460
|
+
} else {
|
|
461
|
+
console.log(`✓ ${config.name} (cached)`);
|
|
462
|
+
}
|
|
463
|
+
const colors = extractSemanticColors(sourcePath);
|
|
464
|
+
return {
|
|
465
|
+
name: config.name,
|
|
466
|
+
category: config.category,
|
|
467
|
+
schema: cachedMetadata,
|
|
468
|
+
colors,
|
|
469
|
+
cached: true,
|
|
470
|
+
cacheEntry: {
|
|
471
|
+
componentName: config.name,
|
|
472
|
+
sourceHash,
|
|
473
|
+
storyHash,
|
|
474
|
+
cacheVersion: CACHE_VERSION,
|
|
475
|
+
generatedAt: cache.entries[config.name]?.generatedAt || Date.now(),
|
|
476
|
+
metadata: cachedMetadata,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Not cached, regenerate
|
|
482
|
+
if (CLI_FLAGS.verbose) {
|
|
483
|
+
console.log(` → ${config.name} (regenerating)`);
|
|
484
|
+
} else {
|
|
485
|
+
console.log(`→ ${config.name} (regenerating)`);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const props = generatePropsFromType(config);
|
|
489
|
+
|
|
490
|
+
// Inject additional props for components with important inherited props
|
|
491
|
+
const additionalProps = ADDITIONAL_COMPONENT_PROPS[config.name];
|
|
492
|
+
if (additionalProps) {
|
|
493
|
+
for (const [propName, propSchema] of Object.entries(additionalProps)) {
|
|
494
|
+
if (!props[propName]) {
|
|
495
|
+
props[propName] = propSchema;
|
|
496
|
+
} else {
|
|
497
|
+
if (propSchema.type) {
|
|
498
|
+
props[propName].type = propSchema.type;
|
|
499
|
+
}
|
|
500
|
+
if (propSchema.description) {
|
|
501
|
+
props[propName].description = propSchema.description;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Apply type overrides
|
|
508
|
+
const typeOverrides = PROP_TYPE_OVERRIDES[config.name];
|
|
509
|
+
if (typeOverrides) {
|
|
510
|
+
for (const [propName, newType] of Object.entries(typeOverrides)) {
|
|
511
|
+
if (props[propName]) {
|
|
512
|
+
props[propName].type = newType;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const colors = extractSemanticColors(sourcePath);
|
|
518
|
+
|
|
519
|
+
// Determine examples
|
|
520
|
+
let examples: readonly string[];
|
|
521
|
+
if (config.examples !== undefined) {
|
|
522
|
+
examples = config.examples;
|
|
523
|
+
} else {
|
|
524
|
+
const extracted = input.storyExamples.get(config.name);
|
|
525
|
+
examples = extracted?.aiExamples ?? [];
|
|
526
|
+
if (examples.length > 0 && CLI_FLAGS.verbose) {
|
|
527
|
+
console.log(
|
|
528
|
+
` → Auto-extracted ${examples.length} examples from stories`,
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Detect and process sub-components
|
|
534
|
+
const detectedSubComponents = detectSubComponents(sourcePath);
|
|
535
|
+
let subComponentSchemas: Record<string, SubComponentSchema> | undefined;
|
|
536
|
+
|
|
537
|
+
if (detectedSubComponents.length > 0) {
|
|
538
|
+
subComponentSchemas = {};
|
|
539
|
+
|
|
540
|
+
for (const subComp of detectedSubComponents) {
|
|
541
|
+
let subProps = extractSubComponentProps(sourcePath, subComp, CLI_FLAGS);
|
|
542
|
+
let description = subComp.description;
|
|
543
|
+
let usageExamples: string[] | undefined;
|
|
544
|
+
let renderElement: string | undefined;
|
|
545
|
+
|
|
546
|
+
if (subComp.isPassThrough && subComp.baseComponent) {
|
|
547
|
+
const passthroughDoc =
|
|
548
|
+
PASSTHROUGH_COMPONENT_DOCS[subComp.baseComponent];
|
|
549
|
+
if (passthroughDoc) {
|
|
550
|
+
description = passthroughDoc.description;
|
|
551
|
+
subProps = passthroughDoc.props;
|
|
552
|
+
usageExamples = passthroughDoc.usageExamples;
|
|
553
|
+
renderElement = passthroughDoc.renderElement;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
subComponentSchemas[subComp.name] = {
|
|
558
|
+
name: subComp.name,
|
|
559
|
+
description,
|
|
560
|
+
props: subProps,
|
|
561
|
+
...(subComp.isPassThrough && { isPassThrough: true }),
|
|
562
|
+
...(subComp.baseComponent && { baseComponent: subComp.baseComponent }),
|
|
563
|
+
...(usageExamples && { usageExamples }),
|
|
564
|
+
...(renderElement && { renderElement }),
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (CLI_FLAGS.verbose && Object.keys(subComponentSchemas).length > 0) {
|
|
569
|
+
console.log(
|
|
570
|
+
` → Processed ${Object.keys(subComponentSchemas).length} sub-components`,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Get styling metadata - prefer extracted from component file, fallback to hardcoded metadata
|
|
576
|
+
const stylingMetadata =
|
|
577
|
+
config.styling ?? COMPONENT_STYLING_METADATA[config.name];
|
|
578
|
+
|
|
579
|
+
const schema: ComponentSchema = {
|
|
580
|
+
name: config.name,
|
|
581
|
+
type: config.type,
|
|
582
|
+
description: config.description,
|
|
583
|
+
importPath: "@cloudflare/kumo",
|
|
584
|
+
category: config.category,
|
|
585
|
+
props,
|
|
586
|
+
examples,
|
|
587
|
+
colors,
|
|
588
|
+
...(config.baseStyles && { baseStyles: config.baseStyles }),
|
|
589
|
+
...(subComponentSchemas && { subComponents: subComponentSchemas }),
|
|
590
|
+
...(stylingMetadata && { styling: stylingMetadata }),
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
return {
|
|
594
|
+
name: config.name,
|
|
595
|
+
category: config.category,
|
|
596
|
+
schema,
|
|
597
|
+
colors,
|
|
598
|
+
cached: false,
|
|
599
|
+
cacheEntry: createCacheEntry(config.name, sourceHash, storyHash, schema),
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// =============================================================================
|
|
604
|
+
// Parallel Processing
|
|
605
|
+
// =============================================================================
|
|
606
|
+
|
|
607
|
+
async function processComponentsInParallel(
|
|
608
|
+
configs: ComponentConfig[],
|
|
609
|
+
variantConstants: Map<string, string[]>,
|
|
610
|
+
storyExamples: Map<string, { aiExamples: string[] }>,
|
|
611
|
+
cache: CacheFile,
|
|
612
|
+
): Promise<ProcessComponentResult[]> {
|
|
613
|
+
const BATCH_SIZE = 8; // Process 8 components concurrently
|
|
614
|
+
const results: ProcessComponentResult[] = [];
|
|
615
|
+
|
|
616
|
+
for (let i = 0; i < configs.length; i += BATCH_SIZE) {
|
|
617
|
+
const batch = configs.slice(i, i + BATCH_SIZE);
|
|
618
|
+
const batchResults = await Promise.all(
|
|
619
|
+
batch.map((config) =>
|
|
620
|
+
processComponent({ config, variantConstants, storyExamples, cache }),
|
|
621
|
+
),
|
|
622
|
+
);
|
|
623
|
+
results.push(...batchResults);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return results;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// =============================================================================
|
|
630
|
+
// Generate Registry
|
|
631
|
+
// =============================================================================
|
|
632
|
+
|
|
633
|
+
async function generateRegistry(): Promise<GenerateRegistryResult> {
|
|
634
|
+
const startTime = Date.now();
|
|
635
|
+
|
|
636
|
+
// Auto-discover components and blocks from filesystem
|
|
637
|
+
const COMPONENTS = await discoverComponents(componentsDir);
|
|
638
|
+
console.log(`\nDiscovered ${COMPONENTS.length} components`);
|
|
639
|
+
|
|
640
|
+
const BLOCKS = await discoverBlocks(blocksDir);
|
|
641
|
+
console.log(`Discovered ${BLOCKS.length} blocks`);
|
|
642
|
+
|
|
643
|
+
// Load cache
|
|
644
|
+
const cache = loadCache(cachePath);
|
|
645
|
+
if (!CLI_FLAGS.noCache) {
|
|
646
|
+
const cachedCount = Object.keys(cache.entries).length;
|
|
647
|
+
console.log(`Loaded cache with ${cachedCount} entries`);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// Build variant constants map for propTester parsing (components + blocks)
|
|
651
|
+
const variantConstants = new Map<string, string[]>();
|
|
652
|
+
for (const config of [...COMPONENTS, ...BLOCKS]) {
|
|
653
|
+
const constName = `KUMO_${toScreamingSnakeCase(config.name)}_VARIANTS`;
|
|
654
|
+
for (const [propName, propVariants] of Object.entries(config.variants)) {
|
|
655
|
+
if (typeof propVariants === "object" && propVariants !== null) {
|
|
656
|
+
variantConstants.set(
|
|
657
|
+
`${constName}.${propName}`,
|
|
658
|
+
Object.keys(propVariants),
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// Load examples from demo files (kumo-docs-astro)
|
|
665
|
+
console.log("\nLoading examples from demo files...");
|
|
666
|
+
const storyExamples = loadDemoExamples();
|
|
667
|
+
|
|
668
|
+
// Process components in parallel
|
|
669
|
+
console.log("\nProcessing components...");
|
|
670
|
+
const componentResults = await processComponentsInParallel(
|
|
671
|
+
COMPONENTS,
|
|
672
|
+
variantConstants,
|
|
673
|
+
storyExamples,
|
|
674
|
+
cache,
|
|
675
|
+
);
|
|
676
|
+
|
|
677
|
+
// Process blocks in parallel
|
|
678
|
+
console.log("\nProcessing blocks...");
|
|
679
|
+
const blockResults = await processComponentsInParallel(
|
|
680
|
+
BLOCKS,
|
|
681
|
+
variantConstants,
|
|
682
|
+
storyExamples,
|
|
683
|
+
cache,
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
// Combine and sort results by name for deterministic output
|
|
687
|
+
const allResults = [...componentResults, ...blockResults];
|
|
688
|
+
allResults.sort((a, b) => a.name.localeCompare(b.name));
|
|
689
|
+
|
|
690
|
+
// Build registry from results
|
|
691
|
+
const components: Record<string, ComponentSchema> = {};
|
|
692
|
+
const blocks: Record<string, BlockSchema> = {};
|
|
693
|
+
const byCategory: Record<string, string[]> = {};
|
|
694
|
+
const byType: Record<string, string[]> = { component: [], block: [] };
|
|
695
|
+
const componentColors = new Map<string, string[]>();
|
|
696
|
+
const newCache: CacheFile = {
|
|
697
|
+
version: CACHE_VERSION,
|
|
698
|
+
entries: {},
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
for (const result of componentResults) {
|
|
702
|
+
components[result.name] = result.schema;
|
|
703
|
+
componentColors.set(result.name, result.colors);
|
|
704
|
+
byType.component.push(result.name);
|
|
705
|
+
|
|
706
|
+
if (!byCategory[result.category]) {
|
|
707
|
+
byCategory[result.category] = [];
|
|
708
|
+
}
|
|
709
|
+
byCategory[result.category].push(result.name);
|
|
710
|
+
|
|
711
|
+
// Store in new cache
|
|
712
|
+
newCache.entries[result.name] = result.cacheEntry;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// Process block results and build BlockSchema with files and dependencies
|
|
716
|
+
for (const result of blockResults) {
|
|
717
|
+
const blockConfig = BLOCKS.find((b) => b.name === result.name)!;
|
|
718
|
+
const mainFilePath = join(blockConfig.sourceDir, blockConfig.sourceFile);
|
|
719
|
+
|
|
720
|
+
// Extract dependencies and files
|
|
721
|
+
const dependencies = extractBlockDependencies(mainFilePath);
|
|
722
|
+
const files = getBlockFiles(blockConfig.sourceDir, blockConfig.dirName);
|
|
723
|
+
|
|
724
|
+
blocks[result.name] = {
|
|
725
|
+
...result.schema,
|
|
726
|
+
type: "block",
|
|
727
|
+
files,
|
|
728
|
+
dependencies,
|
|
729
|
+
};
|
|
730
|
+
componentColors.set(result.name, result.colors);
|
|
731
|
+
byType.block.push(result.name);
|
|
732
|
+
|
|
733
|
+
if (!byCategory[result.category]) {
|
|
734
|
+
byCategory[result.category] = [];
|
|
735
|
+
}
|
|
736
|
+
byCategory[result.category].push(result.name);
|
|
737
|
+
|
|
738
|
+
// Store in new cache
|
|
739
|
+
newCache.entries[result.name] = result.cacheEntry;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// Save updated cache
|
|
743
|
+
saveCache(newCache, cachePath, cacheDir);
|
|
744
|
+
|
|
745
|
+
// Add InputArea as a synthetic component (uses Input's variants but has its own dimensions)
|
|
746
|
+
// InputArea doesn't exist as a separate component file but needs registry metadata for Figma plugin
|
|
747
|
+
if (COMPONENT_STYLING_METADATA.InputArea) {
|
|
748
|
+
components.InputArea = {
|
|
749
|
+
name: "InputArea",
|
|
750
|
+
type: "component",
|
|
751
|
+
description:
|
|
752
|
+
"Multi-line textarea input with Input variants and InputArea-specific dimensions",
|
|
753
|
+
importPath: "@cloudflare/kumo (synthetic - uses Input component)",
|
|
754
|
+
category: "Input",
|
|
755
|
+
props: {}, // Uses Input's props
|
|
756
|
+
styling: COMPONENT_STYLING_METADATA.InputArea,
|
|
757
|
+
examples: [],
|
|
758
|
+
colors: [],
|
|
759
|
+
};
|
|
760
|
+
// Add to Input category
|
|
761
|
+
if (!byCategory.Input) {
|
|
762
|
+
byCategory.Input = [];
|
|
763
|
+
}
|
|
764
|
+
// Don't add to byName search (it's a synthetic entry for Figma plugin only)
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
768
|
+
const cached = allResults.filter((r) => r.cached).length;
|
|
769
|
+
const regenerated = allResults.length - cached;
|
|
770
|
+
|
|
771
|
+
console.log(
|
|
772
|
+
`\n✓ Completed in ${elapsed}s (${cached} cached, ${regenerated} regenerated)`,
|
|
773
|
+
);
|
|
774
|
+
|
|
775
|
+
return {
|
|
776
|
+
registry: {
|
|
777
|
+
version: "1.0.0",
|
|
778
|
+
components,
|
|
779
|
+
blocks,
|
|
780
|
+
search: {
|
|
781
|
+
byCategory,
|
|
782
|
+
byName: allResults.map((r) => r.name),
|
|
783
|
+
byType,
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
componentColors,
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// =============================================================================
|
|
791
|
+
// Main
|
|
792
|
+
// =============================================================================
|
|
793
|
+
|
|
794
|
+
function printHelp() {
|
|
795
|
+
console.log(`
|
|
796
|
+
Kumo Component Registry Generator
|
|
797
|
+
|
|
798
|
+
Usage:
|
|
799
|
+
pnpm build:ai-metadata [options]
|
|
800
|
+
|
|
801
|
+
Options:
|
|
802
|
+
--inherited-props Include inherited HTML props (SLOW: adds ~15s)
|
|
803
|
+
Default: false (uses minimal static skip list)
|
|
804
|
+
--no-cache Force full regeneration, ignore cache
|
|
805
|
+
Default: false (uses hash-based cache)
|
|
806
|
+
--verbose Show detailed timing and processing info
|
|
807
|
+
Default: false
|
|
808
|
+
--help Show this help message
|
|
809
|
+
|
|
810
|
+
Examples:
|
|
811
|
+
pnpm build:ai-metadata # Fast build with cache
|
|
812
|
+
pnpm build:ai-metadata --no-cache # Full rebuild
|
|
813
|
+
pnpm build:ai-metadata --inherited-props # Include all HTML props
|
|
814
|
+
pnpm build:ai-metadata --verbose # Show detailed logs
|
|
815
|
+
|
|
816
|
+
Performance:
|
|
817
|
+
- Hash-based caching: Skips unchanged components (~1s incremental)
|
|
818
|
+
- Parallel processing: Processes 8 components concurrently
|
|
819
|
+
- Skip inherited props: Saves ~15s (47% of total time)
|
|
820
|
+
|
|
821
|
+
Target: <10s cold build, <1s incremental build
|
|
822
|
+
`);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
async function main() {
|
|
826
|
+
// Handle --help flag
|
|
827
|
+
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
828
|
+
printHelp();
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
console.log("Kumo Component Registry Generator");
|
|
833
|
+
console.log("==================================");
|
|
834
|
+
console.log(
|
|
835
|
+
`Flags: ${CLI_FLAGS.includeInheritedProps ? "inherited-props" : "skip-inherited"} | ${CLI_FLAGS.noCache ? "no-cache" : "cache"} | ${CLI_FLAGS.verbose ? "verbose" : "quiet"}`,
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
const { registry, componentColors } = await generateRegistry();
|
|
839
|
+
const aiContext = generateAIContext(registry, componentColors);
|
|
840
|
+
const schemasContent = generateSchemasFile(registry);
|
|
841
|
+
|
|
842
|
+
// Ensure output directory exists
|
|
843
|
+
const outputDir = join(__dirname, "../../ai");
|
|
844
|
+
mkdirSync(outputDir, { recursive: true });
|
|
845
|
+
|
|
846
|
+
// Write JSON registry
|
|
847
|
+
const jsonPath = join(outputDir, "component-registry.json");
|
|
848
|
+
writeFileSync(jsonPath, JSON.stringify(registry, null, 2));
|
|
849
|
+
console.log(`\n✓ Generated ${jsonPath}`);
|
|
850
|
+
|
|
851
|
+
// Write markdown context for LLMs
|
|
852
|
+
const mdPath = join(outputDir, "component-registry.md");
|
|
853
|
+
writeFileSync(mdPath, aiContext);
|
|
854
|
+
console.log(`✓ Generated ${mdPath}`);
|
|
855
|
+
|
|
856
|
+
// Write Zod schemas for runtime validation
|
|
857
|
+
const schemasPath = join(outputDir, "schemas.ts");
|
|
858
|
+
writeFileSync(schemasPath, schemasContent);
|
|
859
|
+
console.log(`✓ Generated ${schemasPath}`);
|
|
860
|
+
|
|
861
|
+
// Also output to stdout for piping
|
|
862
|
+
console.log("\n--- Registry Summary ---");
|
|
863
|
+
console.log(`Components: ${registry.search.byType.component.length}`);
|
|
864
|
+
console.log(`Blocks: ${registry.search.byType.block.length}`);
|
|
865
|
+
console.log(`Total: ${registry.search.byName.length}`);
|
|
866
|
+
console.log(
|
|
867
|
+
`Categories: ${Object.keys(registry.search.byCategory).length} (${Object.keys(registry.search.byCategory).join(", ")})`,
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// Re-export types for external consumers
|
|
872
|
+
export type { ComponentType } from "./types.js";
|
|
873
|
+
|
|
874
|
+
main().catch(console.error);
|