@nikkory/vibe-engine 4.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/PUBLISH-GUIDE.md +250 -0
- package/README.md +1267 -0
- package/bin/vibe.js +22 -0
- package/dist/adapters/index.d.ts +19 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.js +15083 -0
- package/dist/browser.mjs +15000 -0
- package/dist/cli/batch-command.d.ts +142 -0
- package/dist/cli/generate-command.d.ts +119 -0
- package/dist/cli/index.d.ts +34 -0
- package/dist/constants/ComponentTypes.d.ts +65 -0
- package/dist/constants/DesignSystems.d.ts +64 -0
- package/dist/constants/Frameworks.d.ts +71 -0
- package/dist/constants/Tiers.d.ts +72 -0
- package/dist/constants/index.d.ts +10 -0
- package/dist/converters/index.d.ts +12 -0
- package/dist/converters/section-converter.d.ts +176 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +19819 -0
- package/dist/index.mjs +19496 -0
- package/dist/resolution/basic/groups-basic.d.ts +80 -0
- package/dist/resolution/basic/index.d.ts +21 -0
- package/dist/resolution/basic/intents-basic.d.ts +195 -0
- package/dist/resolution/basic/presets-basic.d.ts +96 -0
- package/dist/resolution/basic/resolver-basic.d.ts +127 -0
- package/dist/resolution/basic/shorthands-basic.d.ts +88 -0
- package/dist/resolution/core/groups-core.d.ts +160 -0
- package/dist/resolution/core/index.d.ts +21 -0
- package/dist/resolution/core/intents-core.d.ts +355 -0
- package/dist/resolution/core/presets-core.d.ts +160 -0
- package/dist/resolution/core/resolver-core.d.ts +207 -0
- package/dist/resolution/core/shorthands-core.d.ts +144 -0
- package/dist/resolution/core/types-core.d.ts +167 -0
- package/dist/resolution/debugger.d.ts +183 -0
- package/dist/resolution/demo.d.ts +57 -0
- package/dist/resolution/enterprise/index.d.ts +22 -0
- package/dist/resolution/enterprise/metrics.d.ts +152 -0
- package/dist/resolution/enterprise/resolver-enterprise.d.ts +108 -0
- package/dist/resolution/examples.d.ts +486 -0
- package/dist/resolution/groups/experience-group.d.ts +197 -0
- package/dist/resolution/groups/index.d.ts +196 -0
- package/dist/resolution/groups/layout-group.d.ts +192 -0
- package/dist/resolution/groups/motion-group.d.ts +127 -0
- package/dist/resolution/groups/visual-group.d.ts +146 -0
- package/dist/resolution/index.d.ts +41 -0
- package/dist/resolution/intents/button-intents.d.ts +231 -0
- package/dist/resolution/intents/card-intents.d.ts +177 -0
- package/dist/resolution/intents/feedback-intents.d.ts +222 -0
- package/dist/resolution/intents/index.d.ts +189 -0
- package/dist/resolution/intents/input-intents.d.ts +231 -0
- package/dist/resolution/intents/mood-modifiers.d.ts +154 -0
- package/dist/resolution/performance.d.ts +264 -0
- package/dist/resolution/presets/button-presets.d.ts +243 -0
- package/dist/resolution/presets/card-presets.d.ts +216 -0
- package/dist/resolution/presets/data-display-presets.d.ts +290 -0
- package/dist/resolution/presets/feedback-presets.d.ts +335 -0
- package/dist/resolution/presets/form-presets.d.ts +308 -0
- package/dist/resolution/presets/index.d.ts +22 -0
- package/dist/resolution/presets/input-presets.d.ts +207 -0
- package/dist/resolution/presets/nav-presets.d.ts +235 -0
- package/dist/resolution/presets/overlay-presets.d.ts +216 -0
- package/dist/resolution/presets/preset-registry.d.ts +212 -0
- package/dist/resolution/resolveProps.d.ts +235 -0
- package/dist/resolution/shorthand/feel-mappings.d.ts +140 -0
- package/dist/resolution/shorthand/index.d.ts +172 -0
- package/dist/resolution/shorthand/look-mappings.d.ts +107 -0
- package/dist/resolution/shorthand/spacing-mappings.d.ts +164 -0
- package/dist/resolution/shorthand/surface-mappings.d.ts +139 -0
- package/dist/resolution/standard/groups-standard.d.ts +98 -0
- package/dist/resolution/standard/index.d.ts +28 -0
- package/dist/resolution/standard/intents-standard.d.ts +232 -0
- package/dist/resolution/standard/presets-standard.d.ts +123 -0
- package/dist/resolution/standard/resolver-standard.d.ts +204 -0
- package/dist/resolution/standard/shorthands-standard.d.ts +98 -0
- package/dist/resolution/standard/validators.d.ts +141 -0
- package/dist/resolution/types.d.ts +461 -0
- package/dist/resolution/validators/factor24-validator.d.ts +418 -0
- package/dist/resolution/validators/index.d.ts +14 -0
- package/dist/scripts/generate-react-library.d.ts +15 -0
- package/dist/scripts/write-react-library.d.ts +18 -0
- package/dist/storage/cloud-sync.d.ts +182 -0
- package/dist/storage/index.d.ts +69 -0
- package/dist/storage/local-storage.d.ts +131 -0
- package/dist/storage/section-storage.d.ts +191 -0
- package/dist/styling/StyleGenerator.d.ts +76 -0
- package/dist/styling/TokenStyleResolver.d.ts +163 -0
- package/dist/styling/factor-migration.d.ts +192 -0
- package/dist/styling/factor-validators.d.ts +327 -0
- package/dist/styling/factors-1-6.d.ts +674 -0
- package/dist/styling/factors-12-16.d.ts +700 -0
- package/dist/styling/factors-17-24.d.ts +668 -0
- package/dist/styling/factors-all.d.ts +348 -0
- package/dist/styling/factors.d.ts +291 -0
- package/dist/styling/index.d.ts +31 -0
- package/dist/styling/types.d.ts +400 -0
- package/dist/tokens/schema.d.ts +486 -0
- package/dist/types/Option.d.ts +178 -0
- package/dist/types/Result.d.ts +148 -0
- package/dist/types/algorithm-engine.types.d.ts +298 -0
- package/dist/types/granularity/base.types.d.ts +268 -0
- package/dist/types/granularity/config.types.d.ts +177 -0
- package/dist/types/granularity/factors.types.d.ts +194 -0
- package/dist/types/granularity/index.d.ts +57 -0
- package/dist/types/granularity/slot.types.d.ts +128 -0
- package/dist/types/granularity/template.types.d.ts +179 -0
- package/dist/types/granularity-levels/atom.config.d.ts +151 -0
- package/dist/types/granularity-levels/component.config.d.ts +175 -0
- package/dist/types/granularity-levels/index.d.ts +47 -0
- package/dist/types/granularity-levels/layout.config.d.ts +278 -0
- package/dist/types/granularity-levels/page.config.d.ts +210 -0
- package/dist/types/granularity-levels/section.config.d.ts +188 -0
- package/dist/types/granularity-levels/template.config.d.ts +340 -0
- package/dist/types/index.d.ts +152 -0
- package/dist/types/section-slot.types.d.ts +169 -0
- package/dist/types/section-storage.types.d.ts +298 -0
- package/dist/types/section-template.types.d.ts +170 -0
- package/dist/types/section.types.d.ts +326 -0
- package/dist/ui-studio/ComponentGenerator.d.ts +219 -0
- package/dist/ui-studio/composition/FactorPropagator.d.ts +268 -0
- package/dist/ui-studio/composition/PageGenerator.d.ts +176 -0
- package/dist/ui-studio/composition/SectionGenerator.d.ts +312 -0
- package/dist/ui-studio/composition/SlotResolver.d.ts +295 -0
- package/dist/ui-studio/composition/section-orchestrator.d.ts +306 -0
- package/dist/ui-studio/granularity/FactorCascade.d.ts +328 -0
- package/dist/ui-studio/granularity/GranularityGenerator.d.ts +266 -0
- package/dist/ui-studio/granularity/RecursiveGenerator.d.ts +328 -0
- package/dist/ui-studio/index.d.ts +94 -0
- package/dist/ui-studio/matrix/ClassMapper.d.ts +128 -0
- package/dist/ui-studio/matrix/MatrixResolver.d.ts +203 -0
- package/dist/ui-studio/matrix/types.d.ts +96 -0
- package/dist/ui-studio/presets/IndustryDetector.d.ts +183 -0
- package/dist/ui-studio/presets/component-registry.d.ts +213 -0
- package/dist/ui-studio/presets/factor-registry.d.ts +364 -0
- package/dist/ui-studio/presets/granularity-registry.d.ts +252 -0
- package/dist/ui-studio/presets/index.d.ts +32 -0
- package/dist/ui-studio/presets/industries.d.ts +143 -0
- package/dist/ui-studio/presets/layout-registry.d.ts +21 -0
- package/dist/ui-studio/presets/matrix-groups.d.ts +195 -0
- package/dist/ui-studio/presets/page-registry.d.ts +24 -0
- package/dist/ui-studio/presets/registry.constants.d.ts +69 -0
- package/dist/ui-studio/presets/registry.types.d.ts +166 -0
- package/dist/ui-studio/presets/section-defaults.d.ts +175 -0
- package/dist/ui-studio/presets/section-registry.d.ts +83 -0
- package/dist/ui-studio/presets/section-registry.defaults.d.ts +106 -0
- package/dist/ui-studio/presets/section-registry.helpers.d.ts +112 -0
- package/dist/ui-studio/presets/section-registry.types.d.ts +181 -0
- package/dist/ui-studio/presets/template-registry.d.ts +23 -0
- package/dist/ui-studio/presets/variants.d.ts +1038 -0
- package/dist/ui-studio/registries/components-registry.d.ts +193 -0
- package/dist/ui-studio/registries/design-systems-registry.d.ts +153 -0
- package/dist/ui-studio/registries/factors-registry.d.ts +145 -0
- package/dist/ui-studio/registries/tiers-registry.d.ts +150 -0
- package/dist/ui-studio/resolution/FactorResolver.d.ts +201 -0
- package/dist/ui-studio/templates/TestGenerator.d.ts +55 -0
- package/dist/ui-studio/templates/TierGenerator.d.ts +153 -0
- package/dist/ui-studio/templates/TypesGenerator.d.ts +51 -0
- package/dist/ui-studio/types/granularity/base.types.d.ts +268 -0
- package/dist/ui-studio/types/granularity/config.types.d.ts +177 -0
- package/dist/ui-studio/types/granularity/factors.types.d.ts +194 -0
- package/dist/ui-studio/types/granularity/index.d.ts +57 -0
- package/dist/ui-studio/types/granularity/slot.types.d.ts +128 -0
- package/dist/ui-studio/types/granularity/template.types.d.ts +179 -0
- package/dist/ui-studio/types/granularity-levels/atom.config.d.ts +151 -0
- package/dist/ui-studio/types/granularity-levels/component.config.d.ts +175 -0
- package/dist/ui-studio/types/granularity-levels/index.d.ts +47 -0
- package/dist/ui-studio/types/granularity-levels/layout.config.d.ts +278 -0
- package/dist/ui-studio/types/granularity-levels/page.config.d.ts +210 -0
- package/dist/ui-studio/types/granularity-levels/section.config.d.ts +188 -0
- package/dist/ui-studio/types/granularity-levels/template.config.d.ts +340 -0
- package/dist/ui-studio/types.d.ts +323 -0
- package/dist/utils/CodeUtils.d.ts +103 -0
- package/dist/utils/GenerateComponentValidator.d.ts +35 -0
- package/dist/utils/Logger.d.ts +101 -0
- package/dist/utils/StringUtils.d.ts +120 -0
- package/dist/utils/ValidationUtils.d.ts +71 -0
- package/dist/utils/errors/BaseError.d.ts +23 -0
- package/dist/utils/errors/GenerationError.d.ts +14 -0
- package/dist/utils/errors/TemplateNotFoundError.d.ts +13 -0
- package/dist/utils/errors/ValidationError.d.ts +13 -0
- package/dist/utils/errors/index.d.ts +12 -0
- package/dist/utils/factor-resolver.d.ts +294 -0
- package/dist/utils/granularity-helpers.d.ts +359 -0
- package/dist/utils/index.d.ts +20 -0
- package/dist/utils/performance.d.ts +26 -0
- package/dist/utils/stringify.d.ts +28 -0
- package/dist/validators/component-validator.d.ts +86 -0
- package/dist/validators/design-system-validator.d.ts +95 -0
- package/dist/validators/factor-validator.d.ts +101 -0
- package/dist/validators/index.d.ts +263 -0
- package/dist/validators/section-validator.d.ts +120 -0
- package/dist/validators/slot-validator.d.ts +161 -0
- package/dist/validators/tier-validator.d.ts +102 -0
- package/package.json +67 -0
- package/tests/16-factor-integration.test.d.ts +14 -0
- package/tests/16-factor-visual.test.d.ts +14 -0
- package/tests/5-level-integration.test.d.ts +14 -0
- package/tests/CodeUtils.test.d.ts +7 -0
- package/tests/DesignSystems.test.d.ts +7 -0
- package/tests/GenerateComponentValidator.test.d.ts +7 -0
- package/tests/Logger.test.d.ts +7 -0
- package/tests/StringUtils.test.d.ts +7 -0
- package/tests/StyleGenerator.test.d.ts +13 -0
- package/tests/Tiers.test.d.ts +7 -0
- package/tests/TokenRegistry.test.d.ts +14 -0
- package/tests/TokenStyleResolver.test.d.ts +13 -0
- package/tests/ValidationUtils.test.d.ts +7 -0
- package/tests/_pending_fix/Accordion.test.d.ts +13 -0
- package/tests/_pending_fix/Alert.test.d.ts +13 -0
- package/tests/_pending_fix/AlertDialog.test.d.ts +13 -0
- package/tests/_pending_fix/AspectRatio.test.d.ts +13 -0
- package/tests/_pending_fix/Autocomplete.test.d.ts +13 -0
- package/tests/_pending_fix/Avatar.test.d.ts +13 -0
- package/tests/_pending_fix/Badge.test.d.ts +13 -0
- package/tests/_pending_fix/Banner.test.d.ts +13 -0
- package/tests/_pending_fix/Box.test.d.ts +13 -0
- package/tests/_pending_fix/Breadcrumb.test.d.ts +13 -0
- package/tests/_pending_fix/Callout.test.d.ts +13 -0
- package/tests/_pending_fix/Card.test.d.ts +13 -0
- package/tests/_pending_fix/Center.test.d.ts +13 -0
- package/tests/_pending_fix/Checkbox.test.d.ts +13 -0
- package/tests/_pending_fix/Chip.test.d.ts +13 -0
- package/tests/_pending_fix/ColorPicker.test.d.ts +13 -0
- package/tests/_pending_fix/Combobox.test.d.ts +13 -0
- package/tests/_pending_fix/CommandPalette.test.d.ts +13 -0
- package/tests/_pending_fix/ConfirmationModal.test.d.ts +13 -0
- package/tests/_pending_fix/Container.test.d.ts +13 -0
- package/tests/_pending_fix/DataTable.test.d.ts +13 -0
- package/tests/_pending_fix/DatePicker.test.d.ts +13 -0
- package/tests/_pending_fix/DateRangePicker.test.d.ts +13 -0
- package/tests/_pending_fix/DateTimePicker.test.d.ts +13 -0
- package/tests/_pending_fix/Divider.test.d.ts +13 -0
- package/tests/_pending_fix/Drawer.test.d.ts +13 -0
- package/tests/_pending_fix/Dropdown.test.d.ts +13 -0
- package/tests/_pending_fix/EmptyState.test.d.ts +13 -0
- package/tests/_pending_fix/ErrorState.test.d.ts +13 -0
- package/tests/_pending_fix/FileDropzone.test.d.ts +13 -0
- package/tests/_pending_fix/FileUpload.test.d.ts +13 -0
- package/tests/_pending_fix/Flex.test.d.ts +13 -0
- package/tests/_pending_fix/Grid.test.d.ts +13 -0
- package/tests/_pending_fix/GridItem.test.d.ts +13 -0
- package/tests/_pending_fix/HStack.test.d.ts +13 -0
- package/tests/_pending_fix/Input.test.d.ts +13 -0
- package/tests/_pending_fix/InputCurrency.test.d.ts +13 -0
- package/tests/_pending_fix/InputGroup.test.d.ts +13 -0
- package/tests/_pending_fix/InputOTP.test.d.ts +13 -0
- package/tests/_pending_fix/InputPassword.test.d.ts +13 -0
- package/tests/_pending_fix/InputPhone.test.d.ts +13 -0
- package/tests/_pending_fix/InputSearch.test.d.ts +13 -0
- package/tests/_pending_fix/Link.test.d.ts +13 -0
- package/tests/_pending_fix/List.test.d.ts +13 -0
- package/tests/_pending_fix/LoadingOverlay.test.d.ts +13 -0
- package/tests/_pending_fix/Menu.test.d.ts +13 -0
- package/tests/_pending_fix/Modal.test.d.ts +13 -0
- package/tests/_pending_fix/MultiSelect.test.d.ts +13 -0
- package/tests/_pending_fix/NavGroup.test.d.ts +13 -0
- package/tests/_pending_fix/NavItem.test.d.ts +13 -0
- package/tests/_pending_fix/NavLink.test.d.ts +13 -0
- package/tests/_pending_fix/Navbar.test.d.ts +13 -0
- package/tests/_pending_fix/Notification.test.d.ts +13 -0
- package/tests/_pending_fix/NotificationBadge.test.d.ts +13 -0
- package/tests/_pending_fix/NumberInput.test.d.ts +13 -0
- package/tests/_pending_fix/Pagination.test.d.ts +13 -0
- package/tests/_pending_fix/Popover.test.d.ts +13 -0
- package/tests/_pending_fix/Progress.test.d.ts +13 -0
- package/tests/_pending_fix/ProgressCircle.test.d.ts +13 -0
- package/tests/_pending_fix/ProgressSteps.test.d.ts +13 -0
- package/tests/_pending_fix/Radio.test.d.ts +13 -0
- package/tests/_pending_fix/RangeSlider.test.d.ts +13 -0
- package/tests/_pending_fix/ResizablePanel.test.d.ts +13 -0
- package/tests/_pending_fix/ResultState.test.d.ts +13 -0
- package/tests/_pending_fix/ScrollArea.test.d.ts +13 -0
- package/tests/_pending_fix/Select.test.d.ts +14 -0
- package/tests/_pending_fix/Sheet.test.d.ts +13 -0
- package/tests/_pending_fix/Sidebar.test.d.ts +13 -0
- package/tests/_pending_fix/SimpleGrid.test.d.ts +13 -0
- package/tests/_pending_fix/Skeleton.test.d.ts +13 -0
- package/tests/_pending_fix/Slider.test.d.ts +13 -0
- package/tests/_pending_fix/Spacer.test.d.ts +13 -0
- package/tests/_pending_fix/Spinner.test.d.ts +13 -0
- package/tests/_pending_fix/Stack.test.d.ts +13 -0
- package/tests/_pending_fix/Stat.test.d.ts +13 -0
- package/tests/_pending_fix/Stepper.test.d.ts +14 -0
- package/tests/_pending_fix/Switch.test.d.ts +13 -0
- package/tests/_pending_fix/Table.test.d.ts +13 -0
- package/tests/_pending_fix/Tabs.test.d.ts +13 -0
- package/tests/_pending_fix/Textarea.test.d.ts +13 -0
- package/tests/_pending_fix/Timeline.test.d.ts +13 -0
- package/tests/_pending_fix/Toast.test.d.ts +14 -0
- package/tests/_pending_fix/Tooltip.test.d.ts +14 -0
- package/tests/_pending_fix/VStack.test.d.ts +13 -0
- package/tests/alert.test.d.ts +13 -0
- package/tests/badge.test.d.ts +13 -0
- package/tests/benchmarks/factor-resolution.bench.d.ts +41 -0
- package/tests/button.test.d.ts +16 -0
- package/tests/card.test.d.ts +19 -0
- package/tests/checkbox.test.d.ts +13 -0
- package/tests/component-16-factor-types.test.d.ts +13 -0
- package/tests/component-5level-integration.test.d.ts +14 -0
- package/tests/component-registry-ui.test.d.ts +13 -0
- package/tests/e2e/16-factor-visual.test.d.ts +14 -0
- package/tests/edge-cases.test.d.ts +14 -0
- package/tests/factor-17-24-integration.test.d.ts +14 -0
- package/tests/factor-17-24-performance.test.d.ts +14 -0
- package/tests/factor-validators.test.d.ts +13 -0
- package/tests/factors-1-6.test.d.ts +13 -0
- package/tests/factors-12-16.test.d.ts +13 -0
- package/tests/factors-17-24.test.d.ts +21 -0
- package/tests/factors-all.test.d.ts +13 -0
- package/tests/factors-registry.test.d.ts +11 -0
- package/tests/factors.test.d.ts +13 -0
- package/tests/granularity-types.test.d.ts +18 -0
- package/tests/groups.test.d.ts +14 -0
- package/tests/input.test.d.ts +16 -0
- package/tests/intents.test.d.ts +14 -0
- package/tests/memory-leak.test.d.ts +14 -0
- package/tests/modal.test.d.ts +19 -0
- package/tests/presets.test.d.ts +14 -0
- package/tests/radio.test.d.ts +13 -0
- package/tests/resolution-intents.test.d.ts +13 -0
- package/tests/resolution-presets.test.d.ts +13 -0
- package/tests/resolveProps.test.d.ts +14 -0
- package/tests/section-integration.test.d.ts +16 -0
- package/tests/section-types.test.d.ts +11 -0
- package/tests/setup.d.ts +13 -0
- package/tests/shorthands.test.d.ts +14 -0
- package/tests/switch.test.d.ts +13 -0
- package/tests/tabs.test.d.ts +13 -0
- package/tests/tiers-registry.test.d.ts +11 -0
- package/tests/useComponentStyles.test.d.ts +11 -0
- package/tests/useFactors.test.d.ts +13 -0
- package/tests/validators-invalid-input.test.d.ts +13 -0
- package/tsup.config.d.ts +11 -0
- package/vitest.config.d.ts +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,1267 @@
|
|
|
1
|
+
# @nikkory/vibe-engine
|
|
2
|
+
|
|
3
|
+
**Framework-Agnostic Code Generation Engine for Nikkory Vibe**
|
|
4
|
+
|
|
5
|
+
Zero-token UI/UX code generation with 24-factor design system support.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@nikkory/vibe-engine)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- 🎨 **12 Design Systems**: Material Design, iOS HIG, Glassmorphism, Neumorphism, Brutalism, Minimalism, Cyberpunk, Flat Design, Retro Vintage, Fluent Design, Carbon Design, Ant Design
|
|
15
|
+
- 🎯 **24-Factor System**: Comprehensive design configuration (Color, Size, Variant, Shape, Position, State, Animation, Elevation, A11y, Alignment, Orientation, Density, Loading, Responsive, Theme, Spacing, Typography, Border, Opacity, Overflow, Cursor, Z-Index, Transition)
|
|
16
|
+
- 📦 **169 Components**: Button, Input, Card, Modal, Tabs, and 45+ more component types
|
|
17
|
+
- 🔧 **Framework-Agnostic**: Use with React, Vue, Svelte, or any framework
|
|
18
|
+
- 🏛️ **3-Tier Quality**: Basic (30-50 LOC), Standard (50-150 LOC), Enterprise (150-300 LOC)
|
|
19
|
+
- 📊 **Component Registry**: Search, filter, browse 169 pre-configured components
|
|
20
|
+
- 🎭 **Style Generation**: Runtime style generation with design tokens
|
|
21
|
+
- 🛡️ **Type-Safe**: Full TypeScript support with strict mode
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# npm
|
|
29
|
+
npm install @nikkory/vibe-engine
|
|
30
|
+
|
|
31
|
+
# pnpm
|
|
32
|
+
pnpm add @nikkory/vibe-engine
|
|
33
|
+
|
|
34
|
+
# yarn
|
|
35
|
+
yarn add @nikkory/vibe-engine
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Style Generation
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { generateStyles, cn } from '@nikkory/vibe-engine';
|
|
46
|
+
|
|
47
|
+
// Generate component styles
|
|
48
|
+
const styles = generateStyles({
|
|
49
|
+
componentType: 'button',
|
|
50
|
+
variant: 'filled',
|
|
51
|
+
size: 'md',
|
|
52
|
+
color: 'primary',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Merge class names
|
|
56
|
+
const className = cn('base-class', 'additional-class', {
|
|
57
|
+
'conditional-class': true,
|
|
58
|
+
'hidden-class': false,
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Component Registry
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import {
|
|
66
|
+
ALL_COMPONENTS,
|
|
67
|
+
getComponent,
|
|
68
|
+
searchComponents,
|
|
69
|
+
getStableComponents,
|
|
70
|
+
} from '@nikkory/vibe-engine';
|
|
71
|
+
|
|
72
|
+
// Get all 169 components
|
|
73
|
+
console.log(ALL_COMPONENTS.length); // 169
|
|
74
|
+
|
|
75
|
+
// Get a specific component
|
|
76
|
+
const button = getComponent('button');
|
|
77
|
+
console.log(button.name); // "Button"
|
|
78
|
+
|
|
79
|
+
// Search components
|
|
80
|
+
const buttons = searchComponents('button'); // 10 results
|
|
81
|
+
|
|
82
|
+
// Get stable components only
|
|
83
|
+
const stable = getStableComponents(); // 169 components
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Design Systems
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { CURRENT_DESIGN_SYSTEMS, DESIGN_SYSTEM_INFO } from '@nikkory/vibe-engine';
|
|
90
|
+
|
|
91
|
+
// Available design systems (12 total)
|
|
92
|
+
console.log(CURRENT_DESIGN_SYSTEMS);
|
|
93
|
+
// ['material-design', 'ios-hig', 'glassmorphism', ...]
|
|
94
|
+
|
|
95
|
+
// Get design system info
|
|
96
|
+
const materialInfo = DESIGN_SYSTEM_INFO['material-design'];
|
|
97
|
+
console.log(materialInfo.name); // "Material Design 3"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Quality Tiers
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { TIERS, TIER_INFO } from '@nikkory/vibe-engine';
|
|
104
|
+
|
|
105
|
+
// Available tiers
|
|
106
|
+
console.log(TIERS); // ['basic', 'standard', 'enterprise']
|
|
107
|
+
|
|
108
|
+
// Get tier details
|
|
109
|
+
const enterprise = TIER_INFO.enterprise;
|
|
110
|
+
console.log(enterprise.features);
|
|
111
|
+
// ['memo', 'useCallback', 'analytics', 'ARIA', 'error boundaries']
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 24-Factor Configuration
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import {
|
|
118
|
+
// Basic factors (1-6)
|
|
119
|
+
COLORS,
|
|
120
|
+
SIZES,
|
|
121
|
+
VARIANTS,
|
|
122
|
+
SHAPES,
|
|
123
|
+
POSITIONS,
|
|
124
|
+
ICON_POSITIONS,
|
|
125
|
+
|
|
126
|
+
// Standard factors (7-11)
|
|
127
|
+
STATES,
|
|
128
|
+
ANIMATIONS,
|
|
129
|
+
ELEVATIONS,
|
|
130
|
+
A11Y_LEVELS,
|
|
131
|
+
ALIGNMENTS,
|
|
132
|
+
|
|
133
|
+
// Enterprise factors (12-24)
|
|
134
|
+
ORIENTATIONS,
|
|
135
|
+
DENSITIES,
|
|
136
|
+
LOADING_STATES,
|
|
137
|
+
RESPONSIVE_BREAKPOINTS,
|
|
138
|
+
THEMES,
|
|
139
|
+
SPACINGS,
|
|
140
|
+
TYPOGRAPHIES,
|
|
141
|
+
BORDERS,
|
|
142
|
+
OPACITIES,
|
|
143
|
+
OVERFLOWS,
|
|
144
|
+
CURSORS,
|
|
145
|
+
Z_INDICES,
|
|
146
|
+
TRANSITIONS,
|
|
147
|
+
} from '@nikkory/vibe-engine';
|
|
148
|
+
|
|
149
|
+
// Use factors in configuration
|
|
150
|
+
const config = {
|
|
151
|
+
color: COLORS[0], // 'primary'
|
|
152
|
+
size: SIZES[1], // 'md'
|
|
153
|
+
variant: VARIANTS[0], // 'filled'
|
|
154
|
+
animation: ANIMATIONS[0], // 'fadeIn'
|
|
155
|
+
elevation: ELEVATIONS[1], // 'medium'
|
|
156
|
+
a11yLevel: A11Y_LEVELS[1], // 'enhanced'
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## API Reference
|
|
163
|
+
|
|
164
|
+
### Style Generation
|
|
165
|
+
|
|
166
|
+
#### `generateStyles(config: StyleConfig): GeneratedStyles`
|
|
167
|
+
|
|
168
|
+
Generate component styles from configuration.
|
|
169
|
+
|
|
170
|
+
**Parameters**:
|
|
171
|
+
|
|
172
|
+
- `config.componentType`: Component type (`'button'`, `'input'`, etc.)
|
|
173
|
+
- `config.variant`: Style variant (`'filled'`, `'outlined'`, etc.)
|
|
174
|
+
- `config.size`: Component size (`'sm'`, `'md'`, `'lg'`)
|
|
175
|
+
- `config.color`: Color scheme (`'primary'`, `'secondary'`, etc.)
|
|
176
|
+
|
|
177
|
+
**Returns**: `{ className: string, styles: object }`
|
|
178
|
+
|
|
179
|
+
#### `cn(...inputs: ClassValue[]): string`
|
|
180
|
+
|
|
181
|
+
Merge class names with conditional support.
|
|
182
|
+
|
|
183
|
+
**Parameters**:
|
|
184
|
+
|
|
185
|
+
- `inputs`: Class names, objects, or arrays
|
|
186
|
+
|
|
187
|
+
**Returns**: Merged class name string
|
|
188
|
+
|
|
189
|
+
### Component Registry
|
|
190
|
+
|
|
191
|
+
#### `ALL_COMPONENTS: RegistryComponentDefinition[]`
|
|
192
|
+
|
|
193
|
+
Array of all 169 registered components.
|
|
194
|
+
|
|
195
|
+
#### `getComponent(id: string): RegistryComponentDefinition | undefined`
|
|
196
|
+
|
|
197
|
+
Get a component by ID.
|
|
198
|
+
|
|
199
|
+
#### `searchComponents(query: string): RegistryComponentDefinition[]`
|
|
200
|
+
|
|
201
|
+
Search components by name, tags, or category.
|
|
202
|
+
|
|
203
|
+
#### `getStableComponents(): RegistryComponentDefinition[]`
|
|
204
|
+
|
|
205
|
+
Get all components with `status: 'stable'`.
|
|
206
|
+
|
|
207
|
+
#### `getPopularComponents(): RegistryComponentDefinition[]`
|
|
208
|
+
|
|
209
|
+
Get all components marked as popular (15 components).
|
|
210
|
+
|
|
211
|
+
#### `getNewComponents(): RegistryComponentDefinition[]`
|
|
212
|
+
|
|
213
|
+
Get all components marked as new (7 components).
|
|
214
|
+
|
|
215
|
+
### Constants
|
|
216
|
+
|
|
217
|
+
#### `CURRENT_DESIGN_SYSTEMS: DesignSystem[]`
|
|
218
|
+
|
|
219
|
+
Available design systems (12 total).
|
|
220
|
+
|
|
221
|
+
#### `TIERS: Tier[]`
|
|
222
|
+
|
|
223
|
+
Available quality tiers: `['basic', 'standard', 'enterprise']`.
|
|
224
|
+
|
|
225
|
+
#### `CURRENT_COMPONENT_TYPES: ComponentType[]`
|
|
226
|
+
|
|
227
|
+
Available component types (50 total).
|
|
228
|
+
|
|
229
|
+
### Types
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import type {
|
|
233
|
+
// Core types
|
|
234
|
+
DesignSystem,
|
|
235
|
+
Tier,
|
|
236
|
+
ComponentType,
|
|
237
|
+
Factor24Config,
|
|
238
|
+
StyleConfig,
|
|
239
|
+
GeneratedStyles,
|
|
240
|
+
|
|
241
|
+
// Section Architecture types
|
|
242
|
+
SectionConfig,
|
|
243
|
+
SectionTemplate,
|
|
244
|
+
SectionFactors,
|
|
245
|
+
SectionCategory,
|
|
246
|
+
SlotConfig,
|
|
247
|
+
StoredComponentInSlot,
|
|
248
|
+
TemplateVisibility,
|
|
249
|
+
TemplateMetadata,
|
|
250
|
+
|
|
251
|
+
// Unified Granularity Architecture types
|
|
252
|
+
GranularityLevel,
|
|
253
|
+
GranularityConfig,
|
|
254
|
+
GranularityTemplate,
|
|
255
|
+
GranularitySlotConfig,
|
|
256
|
+
GranularitySlotPosition,
|
|
257
|
+
GranularityFactorDefinition,
|
|
258
|
+
GranularityFactorCategory,
|
|
259
|
+
GranularityFactorValues,
|
|
260
|
+
GranularityLayoutConfig,
|
|
261
|
+
ChildReference,
|
|
262
|
+
// Level-specific aliases
|
|
263
|
+
AtomConfig,
|
|
264
|
+
ComponentConfig,
|
|
265
|
+
PageConfig,
|
|
266
|
+
TemplateConfig,
|
|
267
|
+
} from '@nikkory/vibe-engine';
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 24-Factor Design System
|
|
273
|
+
|
|
274
|
+
### Factors 1-6 (Basic Tier)
|
|
275
|
+
|
|
276
|
+
| Factor | Values | Description |
|
|
277
|
+
| ---------------- | ------------------------------------------------- | --------------- |
|
|
278
|
+
| 1. Color | primary, secondary, success, error, warning, info | Color schemes |
|
|
279
|
+
| 2. Size | xs, sm, md, lg, xl, 2xl | Component sizes |
|
|
280
|
+
| 3. Variant | filled, outlined, text, ghost | Style variants |
|
|
281
|
+
| 4. Shape | rectangle, rounded, pill, circle | Corner radius |
|
|
282
|
+
| 5. Position | top, right, bottom, left, center | Positioning |
|
|
283
|
+
| 6. Icon Position | left, right, top, bottom | Icon placement |
|
|
284
|
+
|
|
285
|
+
### Factors 7-11 (Standard Tier)
|
|
286
|
+
|
|
287
|
+
| Factor | Values | Description |
|
|
288
|
+
| ------------- | --------------------------------------- | ------------------- |
|
|
289
|
+
| 7. State | default, hover, active, focus, disabled | Interaction states |
|
|
290
|
+
| 8. Animation | none, fadeIn, slideIn, bounce, pulse | Entry animations |
|
|
291
|
+
| 9. Elevation | none, low, medium, high, highest | Shadow depth |
|
|
292
|
+
| 10. A11y | basic, enhanced, full | Accessibility level |
|
|
293
|
+
| 11. Alignment | left, center, right, justify | Text alignment |
|
|
294
|
+
|
|
295
|
+
### Factors 12-16 (Standard Extended)
|
|
296
|
+
|
|
297
|
+
| Factor | Values | Description |
|
|
298
|
+
| ----------------- | ----------------------------- | ---------------- |
|
|
299
|
+
| 12. Orientation | horizontal, vertical | Layout direction |
|
|
300
|
+
| 13. Density | compact, normal, comfortable | Spacing density |
|
|
301
|
+
| 14. Loading State | idle, loading, success, error | Async state |
|
|
302
|
+
| 15. Responsive | xs, sm, md, lg, xl | Breakpoints |
|
|
303
|
+
| 16. Theme | light, dark, auto | Color theme |
|
|
304
|
+
|
|
305
|
+
### Factors 17-24 (Enterprise Tier)
|
|
306
|
+
|
|
307
|
+
| Factor | Values | Description |
|
|
308
|
+
| -------------- | ----------------------------- | ----------------- |
|
|
309
|
+
| 17. Spacing | none, xs, sm, md, lg, xl | Margins/padding |
|
|
310
|
+
| 18. Typography | xs, sm, base, lg, xl, 2xl | Font sizes |
|
|
311
|
+
| 19. Border | none, thin, medium, thick | Border width |
|
|
312
|
+
| 20. Opacity | 0, 25, 50, 75, 100 | Transparency |
|
|
313
|
+
| 21. Overflow | visible, hidden, scroll, auto | Overflow behavior |
|
|
314
|
+
| 22. Cursor | default, pointer, wait, text | Cursor style |
|
|
315
|
+
| 23. Z-Index | 0, 10, 20, 30, 40, 50 | Stacking order |
|
|
316
|
+
| 24. Transition | none, fast, normal, slow | Animation speed |
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Algorithm Engine Registries
|
|
321
|
+
|
|
322
|
+
**New in v4.0.0**: Registry-based architecture for the 24-Factor × 3-Tier × 12-Design-Systems generation engine.
|
|
323
|
+
|
|
324
|
+
### Registry Overview
|
|
325
|
+
|
|
326
|
+
| Registry | Purpose | Total Entries |
|
|
327
|
+
| ----------------------- | --------------------------------------------- | ------------- |
|
|
328
|
+
| Tiers Registry | Maps tiers to factor ranges and code features | 3 |
|
|
329
|
+
| Factors Registry | 24 Factor definitions with metadata | 24 |
|
|
330
|
+
| Components Registry | 34 Components with factor applicability | 34 |
|
|
331
|
+
| Design Systems Registry | 12 Design systems with factor values | 12 |
|
|
332
|
+
|
|
333
|
+
### Components Registry Usage
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
import {
|
|
337
|
+
COMPONENT_REGISTRY,
|
|
338
|
+
getComponentEntry,
|
|
339
|
+
getAllComponentTypes,
|
|
340
|
+
getApplicableFactors,
|
|
341
|
+
getSkippedFactors,
|
|
342
|
+
getFactorApplicability,
|
|
343
|
+
componentSupportsDesignSystem,
|
|
344
|
+
searchComponents,
|
|
345
|
+
} from '@nikkory/vibe-engine';
|
|
346
|
+
|
|
347
|
+
// Get all 34 component types
|
|
348
|
+
const types = getAllComponentTypes();
|
|
349
|
+
console.log(types); // ['button', 'input', 'card', ...]
|
|
350
|
+
|
|
351
|
+
// Get component entry with factor applicability
|
|
352
|
+
const button = getComponentEntry('button');
|
|
353
|
+
console.log(button.category); // 'basic'
|
|
354
|
+
console.log(button.elementType); // 'button'
|
|
355
|
+
|
|
356
|
+
// Get applicable factors for a component
|
|
357
|
+
const factors = getApplicableFactors('button');
|
|
358
|
+
console.log(factors); // [1, 2, 3, 4, 6, 7, 8, ...] (applicable factor IDs)
|
|
359
|
+
|
|
360
|
+
// Get skipped factors (null applicability)
|
|
361
|
+
const skipped = getSkippedFactors('button');
|
|
362
|
+
console.log(skipped); // [5, 11, 12, ...] (Position, Alignment, Orientation)
|
|
363
|
+
|
|
364
|
+
// Check factor applicability with overrides
|
|
365
|
+
const applicability = getFactorApplicability('avatar', 4);
|
|
366
|
+
console.log(applicability); // 'circle' (override value for Shape)
|
|
367
|
+
|
|
368
|
+
// Search components
|
|
369
|
+
const results = searchComponents('modal');
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Design Systems Registry Usage
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
import {
|
|
376
|
+
DESIGN_SYSTEM_REGISTRY,
|
|
377
|
+
getDesignSystemEntry,
|
|
378
|
+
getAllDesignSystems,
|
|
379
|
+
getFactorValue,
|
|
380
|
+
getFactorTailwindClasses,
|
|
381
|
+
getDesignSystemCssVariables,
|
|
382
|
+
generateThemeCss,
|
|
383
|
+
mergeFactorValues,
|
|
384
|
+
} from '@nikkory/vibe-engine';
|
|
385
|
+
|
|
386
|
+
// Get all 12 design systems
|
|
387
|
+
const systems = getAllDesignSystems();
|
|
388
|
+
console.log(systems); // ['material-design', 'ios-hig', ...]
|
|
389
|
+
|
|
390
|
+
// Get design system entry
|
|
391
|
+
const md = getDesignSystemEntry('material-design');
|
|
392
|
+
console.log(md.name); // 'Material Design'
|
|
393
|
+
console.log(md.description); // 'Google Material Design 3...'
|
|
394
|
+
|
|
395
|
+
// Get factor value for a design system
|
|
396
|
+
const colorValue = getFactorValue('material-design', 1);
|
|
397
|
+
console.log(colorValue?.tailwindClasses); // 'bg-blue-500 text-white hover:bg-blue-600'
|
|
398
|
+
console.log(colorValue?.cssVariables); // { '--md-color-primary': '#2196f3' }
|
|
399
|
+
|
|
400
|
+
// Get Tailwind classes directly
|
|
401
|
+
const classes = getFactorTailwindClasses('brutalism', 4);
|
|
402
|
+
console.log(classes); // 'rounded-none'
|
|
403
|
+
|
|
404
|
+
// Get CSS variables for Tailwind v4 @theme
|
|
405
|
+
const vars = getDesignSystemCssVariables('glassmorphism');
|
|
406
|
+
console.log(vars['--glass-blur']); // '16px'
|
|
407
|
+
|
|
408
|
+
// Generate @theme CSS block for Tailwind v4
|
|
409
|
+
const themeCss = generateThemeCss('material-design');
|
|
410
|
+
console.log(themeCss);
|
|
411
|
+
// @theme {
|
|
412
|
+
// --md-color-primary: #2196f3;
|
|
413
|
+
// --md-color-secondary: #9c27b0;
|
|
414
|
+
// ...
|
|
415
|
+
// }
|
|
416
|
+
|
|
417
|
+
// Merge design system values with custom overrides
|
|
418
|
+
const merged = mergeFactorValues('material-design', {
|
|
419
|
+
1: { factorId: 1, value: 'custom', tailwindClasses: 'bg-red-500' },
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Factor Applicability Pattern
|
|
424
|
+
|
|
425
|
+
Each component defines which of the 24 factors apply:
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
type FactorApplicability = null | true | string;
|
|
429
|
+
|
|
430
|
+
// null = factor not applicable (skip)
|
|
431
|
+
// true = factor applicable with design system default
|
|
432
|
+
// string = factor applicable with specific override value
|
|
433
|
+
|
|
434
|
+
// Example: Avatar component
|
|
435
|
+
{
|
|
436
|
+
factorApplicability: {
|
|
437
|
+
1: true, // Color - use default
|
|
438
|
+
4: 'circle', // Shape - override to circular
|
|
439
|
+
21: 'hidden', // Overflow - clip to shape
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### Tailwind v4 Integration
|
|
445
|
+
|
|
446
|
+
Design systems provide CSS variables for Tailwind v4 `@theme` integration:
|
|
447
|
+
|
|
448
|
+
```css
|
|
449
|
+
/* Generated by generateThemeCss('material-design') */
|
|
450
|
+
@theme {
|
|
451
|
+
--md-color-primary: #2196f3;
|
|
452
|
+
--md-color-secondary: #9c27b0;
|
|
453
|
+
--md-shape-corner-small: 4px;
|
|
454
|
+
--md-shape-corner-medium: 8px;
|
|
455
|
+
--md-motion-duration-short: 100ms;
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## Section Architecture
|
|
462
|
+
|
|
463
|
+
**New in v4.0.0**: Complete Section Architecture for building pages from configurable sections.
|
|
464
|
+
|
|
465
|
+
### SectionConfig (14 Fields)
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
import type {
|
|
469
|
+
SectionConfig,
|
|
470
|
+
SectionTemplate,
|
|
471
|
+
SectionFactors,
|
|
472
|
+
SectionCategory,
|
|
473
|
+
SlotConfig,
|
|
474
|
+
StoredComponentInSlot,
|
|
475
|
+
} from '@nikkory/vibe-engine';
|
|
476
|
+
|
|
477
|
+
// Create a section configuration
|
|
478
|
+
const heroSection: SectionConfig = {
|
|
479
|
+
// Section-Level Fields (6)
|
|
480
|
+
sectionId: 'hero-1',
|
|
481
|
+
sectionType: 'hero',
|
|
482
|
+
title: 'Welcome to Our Platform',
|
|
483
|
+
subtitle: 'Build amazing experiences',
|
|
484
|
+
designSystem: 'material-design',
|
|
485
|
+
tier: 'enterprise',
|
|
486
|
+
|
|
487
|
+
// Layout Fields (3)
|
|
488
|
+
layout: 'flex',
|
|
489
|
+
columns: 2,
|
|
490
|
+
spacing: 'lg',
|
|
491
|
+
|
|
492
|
+
// Generation Fields (2)
|
|
493
|
+
slots: [],
|
|
494
|
+
itemCount: 1,
|
|
495
|
+
|
|
496
|
+
// Component-Specific Fields (3)
|
|
497
|
+
showCta: true,
|
|
498
|
+
showMedia: true,
|
|
499
|
+
styleOverrides: { className: 'hero-custom' },
|
|
500
|
+
};
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Section Categories (10 Types)
|
|
504
|
+
|
|
505
|
+
| Category | Description | Typical Layout |
|
|
506
|
+
| ------------ | --------------------- | -------------- |
|
|
507
|
+
| hero | Landing page hero | flex, 1-2 cols |
|
|
508
|
+
| features | Feature grid/list | grid, 3-4 cols |
|
|
509
|
+
| testimonials | Customer testimonials | carousel |
|
|
510
|
+
| pricing | Pricing plans | grid, 3 cols |
|
|
511
|
+
| cta | Call-to-action | flex, 1 col |
|
|
512
|
+
| faq | Frequently asked | accordion |
|
|
513
|
+
| team | Team members grid | grid, 3-4 cols |
|
|
514
|
+
| contact | Contact form | flex, 2 cols |
|
|
515
|
+
| gallery | Image gallery | masonry |
|
|
516
|
+
| stats | Statistics/metrics | grid, 4 cols |
|
|
517
|
+
|
|
518
|
+
### SectionTemplate (22 Fields = 14 Config + 8 Metadata)
|
|
519
|
+
|
|
520
|
+
```typescript
|
|
521
|
+
const heroTemplate: SectionTemplate = {
|
|
522
|
+
// SectionConfig (14 fields)
|
|
523
|
+
...heroSection,
|
|
524
|
+
|
|
525
|
+
// TemplateMetadata (8 fields)
|
|
526
|
+
templateId: 'hero-material-001',
|
|
527
|
+
templateName: 'Material Hero',
|
|
528
|
+
description: 'Material Design 3 hero section with gradient',
|
|
529
|
+
author: 'nikkory-team',
|
|
530
|
+
version: '1.0.0',
|
|
531
|
+
tags: ['hero', 'material', 'enterprise', 'landing'],
|
|
532
|
+
visibility: 'public', // 'private' | 'team' | 'public'
|
|
533
|
+
thumbnail: 'https://cdn.nikkory.com/templates/hero-material.png',
|
|
534
|
+
};
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### SectionFactors (13 Factors)
|
|
538
|
+
|
|
539
|
+
Factors that propagate from Section to Components:
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
const factors: SectionFactors = {
|
|
543
|
+
// Visual Factors (6)
|
|
544
|
+
colorPrimary: '#2196f3',
|
|
545
|
+
colorText: '#1a1a1a',
|
|
546
|
+
colorBackground: '#ffffff',
|
|
547
|
+
typography: 'default', // 'compact' | 'default' | 'relaxed' | 'spacious'
|
|
548
|
+
borderRadius: 'md', // 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'
|
|
549
|
+
elevation: 'sm', // 'none' | 'sm' | 'md' | 'lg' | 'xl'
|
|
550
|
+
|
|
551
|
+
// Layout Factors (4)
|
|
552
|
+
padding: 'lg',
|
|
553
|
+
gap: 'md',
|
|
554
|
+
alignment: 'center', // 'start' | 'center' | 'end' | 'stretch' | 'between'
|
|
555
|
+
maxWidth: 'xl', // 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'
|
|
556
|
+
|
|
557
|
+
// Behavior Factors (3)
|
|
558
|
+
animation: 'smooth', // 'none' | 'subtle' | 'smooth' | 'dynamic' | 'playful'
|
|
559
|
+
responsive: { mobile: 'stack', tablet: 'grid', desktop: 'grid' },
|
|
560
|
+
a11yLevel: 'enhanced', // 'standard' | 'enhanced' | 'maximum'
|
|
561
|
+
};
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### Slot System
|
|
565
|
+
|
|
566
|
+
Place components in section slots:
|
|
567
|
+
|
|
568
|
+
```typescript
|
|
569
|
+
const slotConfig: SlotConfig = {
|
|
570
|
+
slotId: 'hero-cta-slot',
|
|
571
|
+
position: 'content', // 'header' | 'content' | 'footer' | 'sidebar' | 'overlay'
|
|
572
|
+
allowedComponents: ['button', 'input', 'chip'],
|
|
573
|
+
maxComponents: 3,
|
|
574
|
+
defaultComponent: 'button',
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const componentInSlot: StoredComponentInSlot = {
|
|
578
|
+
componentRef: 'button',
|
|
579
|
+
instanceId: 'hero-cta-button-1',
|
|
580
|
+
propOverrides: {
|
|
581
|
+
variant: 'filled',
|
|
582
|
+
size: 'lg',
|
|
583
|
+
label: 'Get Started',
|
|
584
|
+
},
|
|
585
|
+
order: 0,
|
|
586
|
+
visible: true,
|
|
587
|
+
};
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### Hybrid Storage (Visibility-Based)
|
|
591
|
+
|
|
592
|
+
- `private`: JSON file only (local machine)
|
|
593
|
+
- `team`: JSON + Cloud sync to team workspace
|
|
594
|
+
- `public`: JSON + Cloud sync + Marketplace listing
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
import type { LocalStorageConfig, CloudSyncConfig } from '@nikkory/vibe-engine';
|
|
598
|
+
|
|
599
|
+
const localConfig: LocalStorageConfig = {
|
|
600
|
+
basePath: './.nikkory/templates',
|
|
601
|
+
fileExtension: '.section.json',
|
|
602
|
+
prettyPrint: true,
|
|
603
|
+
createBackups: true,
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
const cloudConfig: CloudSyncConfig = {
|
|
607
|
+
apiEndpoint: 'https://api.nikkory.com/templates',
|
|
608
|
+
syncInterval: 60000, // 1 minute
|
|
609
|
+
conflictResolution: 'newest-wins',
|
|
610
|
+
enableOfflineQueue: true,
|
|
611
|
+
};
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## Unified Granularity Architecture
|
|
617
|
+
|
|
618
|
+
**New in v4.0.0**: Generic type system for all 6 granularity levels with dynamic factor cascade.
|
|
619
|
+
|
|
620
|
+
### GranularityConfig<G> - Generic Interface
|
|
621
|
+
|
|
622
|
+
Replace duplicate Section/Page/Layout/Template patterns with ONE generic interface:
|
|
623
|
+
|
|
624
|
+
```typescript
|
|
625
|
+
import type {
|
|
626
|
+
GranularityLevel,
|
|
627
|
+
GranularityConfig,
|
|
628
|
+
GranularityTemplate,
|
|
629
|
+
GranularitySlotConfig,
|
|
630
|
+
GranularityFactorDefinition,
|
|
631
|
+
} from '@nikkory/vibe-engine';
|
|
632
|
+
|
|
633
|
+
// 6 Granularity Levels
|
|
634
|
+
type GranularityLevel = 'atom' | 'component' | 'section' | 'page' | 'layout' | 'template';
|
|
635
|
+
|
|
636
|
+
// Generic config for ANY granularity level
|
|
637
|
+
const sectionConfig: GranularityConfig<'section'> = {
|
|
638
|
+
id: 'hero-section-1',
|
|
639
|
+
granularity: 'section',
|
|
640
|
+
designSystem: 'material-design',
|
|
641
|
+
tier: 'enterprise',
|
|
642
|
+
title: 'Hero Section',
|
|
643
|
+
layout: { type: 'flex', alignment: 'center' },
|
|
644
|
+
factors: { spacing: 'lg', colorPrimary: '#3B82F6' },
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const pageConfig: GranularityConfig<'page'> = {
|
|
648
|
+
id: 'landing-page-1',
|
|
649
|
+
granularity: 'page',
|
|
650
|
+
designSystem: 'material-design',
|
|
651
|
+
tier: 'enterprise',
|
|
652
|
+
title: 'Landing Page',
|
|
653
|
+
children: [
|
|
654
|
+
{ childGranularity: 'section', ref: 'hero-section-1', slot: 'main' },
|
|
655
|
+
{ childGranularity: 'section', ref: 'features-section-1', slot: 'main' },
|
|
656
|
+
],
|
|
657
|
+
};
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
### Granularity Hierarchy
|
|
661
|
+
|
|
662
|
+
Factors cascade DOWN from higher levels to lower levels:
|
|
663
|
+
|
|
664
|
+
```
|
|
665
|
+
template (Level 6) - Highest
|
|
666
|
+
↓
|
|
667
|
+
layout (Level 5)
|
|
668
|
+
↓
|
|
669
|
+
page (Level 4)
|
|
670
|
+
↓
|
|
671
|
+
section (Level 3)
|
|
672
|
+
↓
|
|
673
|
+
component (Level 2)
|
|
674
|
+
↓
|
|
675
|
+
atom (Level 1) - Lowest
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
```typescript
|
|
679
|
+
import { GRANULARITY_HIERARCHY, getGranularityRank } from '@nikkory/vibe-engine';
|
|
680
|
+
|
|
681
|
+
// Check hierarchy
|
|
682
|
+
console.log(GRANULARITY_HIERARCHY);
|
|
683
|
+
// ['template', 'layout', 'page', 'section', 'component', 'atom']
|
|
684
|
+
|
|
685
|
+
// Compare levels
|
|
686
|
+
console.log(getGranularityRank('template')); // 6
|
|
687
|
+
console.log(getGranularityRank('page')); // 4
|
|
688
|
+
console.log(getGranularityRank('atom')); // 1
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
### GranularityTemplate<G> - With Metadata
|
|
692
|
+
|
|
693
|
+
Templates extend configs with 8 metadata fields for sharing and versioning:
|
|
694
|
+
|
|
695
|
+
```typescript
|
|
696
|
+
const heroTemplate: GranularityTemplate<'section'> = {
|
|
697
|
+
// Config fields
|
|
698
|
+
id: 'hero-instance-1',
|
|
699
|
+
granularity: 'section',
|
|
700
|
+
designSystem: 'material-design',
|
|
701
|
+
tier: 'enterprise',
|
|
702
|
+
title: 'Hero Section',
|
|
703
|
+
|
|
704
|
+
// 8 Metadata fields
|
|
705
|
+
templateId: 'hero-section-v1',
|
|
706
|
+
templateName: 'Hero Section Template',
|
|
707
|
+
description: 'Full-width hero with headline and CTA',
|
|
708
|
+
author: 'Nikkory Team',
|
|
709
|
+
version: '1.0.0',
|
|
710
|
+
tags: ['hero', 'landing', 'cta'],
|
|
711
|
+
visibility: 'public', // 'private' | 'team' | 'public'
|
|
712
|
+
thumbnail: 'https://nikkory.com/templates/hero.png',
|
|
713
|
+
};
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Factor Cascade System
|
|
717
|
+
|
|
718
|
+
Factors are defined with `level` and `cascadeDown` - no more hardcoded arrays:
|
|
719
|
+
|
|
720
|
+
```typescript
|
|
721
|
+
import type { GranularityFactorDefinition } from '@nikkory/vibe-engine';
|
|
722
|
+
|
|
723
|
+
const spacingFactor: GranularityFactorDefinition = {
|
|
724
|
+
id: 'spacing',
|
|
725
|
+
name: 'Spacing',
|
|
726
|
+
category: 'layout',
|
|
727
|
+
level: 'template', // Minimum level where this factor applies
|
|
728
|
+
cascadeDown: true, // Cascade to page → section → component → atom
|
|
729
|
+
defaults: {
|
|
730
|
+
'material-design': 'md',
|
|
731
|
+
'ios-hig': 'sm',
|
|
732
|
+
},
|
|
733
|
+
options: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
734
|
+
description: 'Controls spacing between elements',
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
// Dynamic factor resolution (replaces hardcoded 8/13/24 arrays)
|
|
738
|
+
// getFactorsForLevel('page') → Returns all factors for page level
|
|
739
|
+
// getFactorsForLevel('section') → Returns all factors for section level
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
### Level-Specific Slot Positions
|
|
743
|
+
|
|
744
|
+
Slots vary by granularity level:
|
|
745
|
+
|
|
746
|
+
```typescript
|
|
747
|
+
import type { GranularitySlotPosition } from '@nikkory/vibe-engine';
|
|
748
|
+
|
|
749
|
+
// Page slots (6 positions)
|
|
750
|
+
type PageSlots = GranularitySlotPosition<'page'>;
|
|
751
|
+
// = 'header' | 'main' | 'sidebar' | 'footer' | 'overlay' | 'floating'
|
|
752
|
+
|
|
753
|
+
// Section slots (5 positions)
|
|
754
|
+
type SectionSlots = GranularitySlotPosition<'section'>;
|
|
755
|
+
// = 'header' | 'content' | 'footer' | 'sidebar' | 'overlay'
|
|
756
|
+
|
|
757
|
+
// Layout slots (4 positions)
|
|
758
|
+
type LayoutSlots = GranularitySlotPosition<'layout'>;
|
|
759
|
+
// = 'header' | 'main' | 'sidebar' | 'footer'
|
|
760
|
+
|
|
761
|
+
// Template slots (3 positions)
|
|
762
|
+
type TemplateSlots = GranularitySlotPosition<'template'>;
|
|
763
|
+
// = 'pages' | 'shared' | 'assets'
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### Level-Specific Type Aliases
|
|
767
|
+
|
|
768
|
+
Convenience type aliases for each level:
|
|
769
|
+
|
|
770
|
+
```typescript
|
|
771
|
+
import type {
|
|
772
|
+
AtomConfig,
|
|
773
|
+
ComponentConfig,
|
|
774
|
+
SectionGranularityConfig,
|
|
775
|
+
PageConfig,
|
|
776
|
+
LayoutGranularityConfig,
|
|
777
|
+
TemplateConfig,
|
|
778
|
+
// Template types
|
|
779
|
+
AtomTemplate,
|
|
780
|
+
ComponentTemplate,
|
|
781
|
+
SectionGranularityTemplate,
|
|
782
|
+
PageTemplate,
|
|
783
|
+
LayoutTemplate,
|
|
784
|
+
TemplateGranularityTemplate,
|
|
785
|
+
} from '@nikkory/vibe-engine';
|
|
786
|
+
|
|
787
|
+
// These are aliases for GranularityConfig<Level>
|
|
788
|
+
const atom: AtomConfig = { id: '1', granularity: 'atom', ... };
|
|
789
|
+
const component: ComponentConfig = { id: '2', granularity: 'component', ... };
|
|
790
|
+
const section: SectionGranularityConfig = { id: '3', granularity: 'section', ... };
|
|
791
|
+
const page: PageConfig = { id: '4', granularity: 'page', ... };
|
|
792
|
+
const layout: LayoutGranularityConfig = { id: '5', granularity: 'layout', ... };
|
|
793
|
+
const template: TemplateConfig = { id: '6', granularity: 'template', ... };
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
### Factor Resolution Types
|
|
797
|
+
|
|
798
|
+
```typescript
|
|
799
|
+
import type {
|
|
800
|
+
GranularityFactorResolutionResult,
|
|
801
|
+
GranularityFactorOverride,
|
|
802
|
+
GranularityFactorQueryOptions,
|
|
803
|
+
GranularityFactorCascadeConfig,
|
|
804
|
+
} from '@nikkory/vibe-engine';
|
|
805
|
+
import { FACTOR_PRIORITY } from '@nikkory/vibe-engine';
|
|
806
|
+
|
|
807
|
+
// Factor priority (higher wins)
|
|
808
|
+
console.log(FACTOR_PRIORITY.DEFAULT); // 0
|
|
809
|
+
console.log(FACTOR_PRIORITY.CASCADE); // 25
|
|
810
|
+
console.log(FACTOR_PRIORITY.CONFIG); // 50
|
|
811
|
+
console.log(FACTOR_PRIORITY.USER); // 100 (always wins)
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
## Composition Generator
|
|
817
|
+
|
|
818
|
+
**New in v4.0.0**: Generate higher-level compositions (pages from sections, layouts from pages, templates from pages).
|
|
819
|
+
|
|
820
|
+
### Usage
|
|
821
|
+
|
|
822
|
+
```typescript
|
|
823
|
+
import { CompositionGenerator } from '@nikkory/vibe-engine';
|
|
824
|
+
import type { CompositionConfig } from '@nikkory/vibe-engine';
|
|
825
|
+
|
|
826
|
+
const generator = new CompositionGenerator();
|
|
827
|
+
|
|
828
|
+
// Generate a landing page from sections
|
|
829
|
+
const result = generator.generateComposition({
|
|
830
|
+
parent: LANDING_PAGE_DEFINITION,
|
|
831
|
+
children: [HERO_SECTION, FEATURES_SECTION, CTA_SECTION],
|
|
832
|
+
strategy: 'slots',
|
|
833
|
+
designSystem: 'material-design',
|
|
834
|
+
tier: 'enterprise',
|
|
835
|
+
outputDir: './src/pages',
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
console.log(result.componentPath); // './src/pages/MaterialDesignLandingPageEnterprise.tsx'
|
|
839
|
+
console.log(result.linesOfCode); // 150-300 for enterprise tier
|
|
840
|
+
console.log(result.displayName); // 'MaterialDesignLandingPageEnterprise'
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### Composition Strategies
|
|
844
|
+
|
|
845
|
+
**1. Slot Composition** - Pages compose sections via named slots:
|
|
846
|
+
|
|
847
|
+
```typescript
|
|
848
|
+
strategy: 'slots';
|
|
849
|
+
// Parent: Page definition
|
|
850
|
+
// Children: Section definitions
|
|
851
|
+
// Result: Page component with section slots
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
**2. Children Composition** - Layouts compose pages via children prop:
|
|
855
|
+
|
|
856
|
+
```typescript
|
|
857
|
+
strategy: 'children';
|
|
858
|
+
// Parent: Layout definition
|
|
859
|
+
// Children: Page definitions
|
|
860
|
+
// Result: Layout component with page children
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
**3. Template Composition** - Templates compose multiple pages:
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
strategy: 'template';
|
|
867
|
+
// Parent: Template definition
|
|
868
|
+
// Children: Page definitions
|
|
869
|
+
// Result: Template with all pages
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### Generation Result
|
|
873
|
+
|
|
874
|
+
```typescript
|
|
875
|
+
interface GenerationResult {
|
|
876
|
+
success: boolean;
|
|
877
|
+
componentPath: string; // Generated file path
|
|
878
|
+
linesOfCode: number; // Total LOC (varies by tier)
|
|
879
|
+
displayName: string; // Component display name
|
|
880
|
+
error?: string; // Error message if failed
|
|
881
|
+
}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
### Tier Features
|
|
885
|
+
|
|
886
|
+
The generator respects tier-specific features:
|
|
887
|
+
|
|
888
|
+
| Tier | LOC | Features |
|
|
889
|
+
| -------------- | ------- | ------------------------------------ |
|
|
890
|
+
| **Basic** | 30-50 | Core composition, basic imports |
|
|
891
|
+
| **Standard** | 50-150 | + forwardRef, displayName, variants |
|
|
892
|
+
| **Enterprise** | 150-300 | + memo, useCallback, analytics, ARIA |
|
|
893
|
+
|
|
894
|
+
---
|
|
895
|
+
|
|
896
|
+
## Matrix Multiplication Code Generation
|
|
897
|
+
|
|
898
|
+
**New in v4.0.0**: Dynamic code generation using matrix multiplication algorithm.
|
|
899
|
+
|
|
900
|
+
### Overview
|
|
901
|
+
|
|
902
|
+
The Matrix Multiplication System replaces hardcoded component generation with a dynamic algorithm that multiplies 4 matrices to produce component configurations:
|
|
903
|
+
|
|
904
|
+
```
|
|
905
|
+
Component = Matrix1 × Matrix2 × Matrix3 × Matrix4 + Override
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
### The 4 Matrices
|
|
909
|
+
|
|
910
|
+
| Matrix | Input | Output | Source |
|
|
911
|
+
| ------------ | ------------------------- | ------------------ | -------------------------------------- |
|
|
912
|
+
| **Matrix 1** | Component ID | HTML Element Type | COMPONENT_REGISTRY |
|
|
913
|
+
| **Matrix 2** | Factor ID + Design System | Factor Values | FACTOR_REGISTRY + user overrides |
|
|
914
|
+
| **Matrix 3** | Tier | React Patterns | Tier definitions |
|
|
915
|
+
| **Matrix 4** | Component × Factor | Applicable Factors | COMPONENT_REGISTRY.factorApplicability |
|
|
916
|
+
|
|
917
|
+
### Usage
|
|
918
|
+
|
|
919
|
+
```typescript
|
|
920
|
+
import { MatrixResolver, TemplateEngine } from '@nikkory/vibe-engine/matrix';
|
|
921
|
+
|
|
922
|
+
// Initialize resolver
|
|
923
|
+
const resolver = new MatrixResolver();
|
|
924
|
+
const templateEngine = new TemplateEngine();
|
|
925
|
+
|
|
926
|
+
// Resolve component configuration
|
|
927
|
+
const config = resolver.resolve({
|
|
928
|
+
componentId: 'button',
|
|
929
|
+
designSystem: 'material-design',
|
|
930
|
+
tier: 'enterprise',
|
|
931
|
+
factor24Config: {
|
|
932
|
+
4: 'md', // borderRadius = md (rounded corners)
|
|
933
|
+
5: 'md', // shadowStyle = md (elevation)
|
|
934
|
+
17: 'md', // spacing = md
|
|
935
|
+
},
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
// Generate React component code
|
|
939
|
+
const code = templateEngine.generate(config);
|
|
940
|
+
console.log(config.classNames);
|
|
941
|
+
// → ['rounded-md', 'shadow-md', 'px-4 py-2']
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
### ResolvedComponentConfig
|
|
945
|
+
|
|
946
|
+
The `resolve()` method returns a complete configuration:
|
|
947
|
+
|
|
948
|
+
```typescript
|
|
949
|
+
interface ResolvedComponentConfig {
|
|
950
|
+
componentName: string; // 'ButtonMaterialDesignEnterprise'
|
|
951
|
+
elementType: string; // 'button' (from COMPONENT_REGISTRY)
|
|
952
|
+
tier: Tier; // 'enterprise'
|
|
953
|
+
designSystem: DesignSystem; // 'material-design'
|
|
954
|
+
classNames: readonly string[]; // ['rounded-md', 'shadow-md', ...]
|
|
955
|
+
imports: readonly string[]; // React imports for tier
|
|
956
|
+
wrappers: readonly string[]; // ['memo', 'forwardRef']
|
|
957
|
+
features: readonly string[]; // ['displayName', 'analytics']
|
|
958
|
+
}
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
### Matrix 2: Factor Override System
|
|
962
|
+
|
|
963
|
+
User overrides take precedence over design system defaults:
|
|
964
|
+
|
|
965
|
+
```typescript
|
|
966
|
+
const config = resolver.resolve({
|
|
967
|
+
componentId: 'button',
|
|
968
|
+
designSystem: 'material-design', // Default: borderRadius = 'md'
|
|
969
|
+
tier: 'enterprise',
|
|
970
|
+
factor24Config: {
|
|
971
|
+
4: 'xl', // Override: borderRadius = 'xl' (more rounded)
|
|
972
|
+
},
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
console.log(config.classNames);
|
|
976
|
+
// → ['rounded-xl', 'shadow-md', 'px-4 py-2']
|
|
977
|
+
// ^^^^^^^^^^^ User override applied!
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
### Design System Differentiation
|
|
981
|
+
|
|
982
|
+
Different design systems produce different code:
|
|
983
|
+
|
|
984
|
+
```typescript
|
|
985
|
+
// Material Design: Rounded corners + shadows
|
|
986
|
+
const material = resolver.resolve({
|
|
987
|
+
componentId: 'button',
|
|
988
|
+
designSystem: 'material-design',
|
|
989
|
+
tier: 'enterprise',
|
|
990
|
+
factor24Config: { 4: 'md', 5: 'md', 17: 'md' },
|
|
991
|
+
});
|
|
992
|
+
console.log(material.classNames);
|
|
993
|
+
// → ['rounded-md', 'shadow-md', 'px-4 py-2']
|
|
994
|
+
|
|
995
|
+
// Brutalism: Sharp corners + no shadows
|
|
996
|
+
const brutalism = resolver.resolve({
|
|
997
|
+
componentId: 'button',
|
|
998
|
+
designSystem: 'brutalism',
|
|
999
|
+
tier: 'enterprise',
|
|
1000
|
+
factor24Config: { 4: 'none', 5: 'none', 17: 'md' },
|
|
1001
|
+
});
|
|
1002
|
+
console.log(brutalism.classNames);
|
|
1003
|
+
// → ['rounded-none', 'shadow-none', 'px-4 py-2']
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
### Tier Patterns (Matrix 3)
|
|
1007
|
+
|
|
1008
|
+
Each tier generates different React patterns:
|
|
1009
|
+
|
|
1010
|
+
| Tier | Imports | Wrappers | Features | LOC |
|
|
1011
|
+
| -------------- | -------------------------------------------- | -------------------- | -------------------------- | ------- |
|
|
1012
|
+
| **Basic** | `React` | `React.FC` | None | 30-50 |
|
|
1013
|
+
| **Standard** | `React`, `forwardRef` | `forwardRef` | `displayName` | 50-150 |
|
|
1014
|
+
| **Enterprise** | `React`, `forwardRef`, `memo`, `useCallback` | `memo`, `forwardRef` | `displayName`, `analytics` | 150-300 |
|
|
1015
|
+
|
|
1016
|
+
### Generated Code Example
|
|
1017
|
+
|
|
1018
|
+
**Enterprise Tier with Material Design:**
|
|
1019
|
+
|
|
1020
|
+
```typescript
|
|
1021
|
+
/**
|
|
1022
|
+
* ButtonMaterialDesignEnterprise Component
|
|
1023
|
+
*
|
|
1024
|
+
* Generated by Nikkory Vibe Matrix Generator
|
|
1025
|
+
* Powered by Nikkory
|
|
1026
|
+
*/
|
|
1027
|
+
|
|
1028
|
+
import * as React from 'react';
|
|
1029
|
+
import { forwardRef, memo, useCallback } from 'react';
|
|
1030
|
+
|
|
1031
|
+
export const ButtonMaterialDesignEnterprise = memo(
|
|
1032
|
+
forwardRef<HTMLButtonElement, ButtonMaterialDesignEnterpriseProps>(
|
|
1033
|
+
({ children, className, ...props }, ref) => {
|
|
1034
|
+
return (
|
|
1035
|
+
<button
|
|
1036
|
+
ref={ref}
|
|
1037
|
+
className={`rounded-md shadow-md px-4 py-2 ${className ?? ''}`}
|
|
1038
|
+
{...props}
|
|
1039
|
+
>
|
|
1040
|
+
{children}
|
|
1041
|
+
</button>
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
1045
|
+
);
|
|
1046
|
+
|
|
1047
|
+
ButtonMaterialDesignEnterprise.displayName = 'ButtonMaterialDesignEnterprise';
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
### ComponentGenerator Integration
|
|
1051
|
+
|
|
1052
|
+
**As of v4.0.0**, the `ComponentGenerator` class internally uses the Matrix Multiplication system for all code generation:
|
|
1053
|
+
|
|
1054
|
+
```typescript
|
|
1055
|
+
import { ComponentGenerator } from '@nikkory/vibe-engine';
|
|
1056
|
+
|
|
1057
|
+
const generator = new ComponentGenerator();
|
|
1058
|
+
|
|
1059
|
+
// ComponentGenerator now uses MatrixResolver + TemplateEngine internally
|
|
1060
|
+
const result = generator.generate({
|
|
1061
|
+
componentType: 'button',
|
|
1062
|
+
designSystem: 'material-design',
|
|
1063
|
+
tier: 'enterprise',
|
|
1064
|
+
factorOverrides: { 2: 'lg' }, // Size override
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
console.log(result.code.componentCode); // Clean, performant code (39-44 LOC)
|
|
1068
|
+
console.log(result.style.tailwindClasses); // Resolved classes
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
**Benefits**:
|
|
1072
|
+
|
|
1073
|
+
- ✅ **Performance**: 0.05ms average generation time (100x faster than target)
|
|
1074
|
+
- ✅ **Memory**: 1.47MB usage (3x under target)
|
|
1075
|
+
- ✅ **Output Quality**: 39-44 lines (under 100-line target)
|
|
1076
|
+
- ✅ **Backward Compatible**: Public API unchanged
|
|
1077
|
+
|
|
1078
|
+
### Testing
|
|
1079
|
+
|
|
1080
|
+
Test the matrix system with the included test script:
|
|
1081
|
+
|
|
1082
|
+
```bash
|
|
1083
|
+
# Run matrix tests
|
|
1084
|
+
npx tsx packages/engine/src/matrix/test-matrix.ts
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
**Test Output:**
|
|
1088
|
+
|
|
1089
|
+
```
|
|
1090
|
+
✅ Material Design Button Test Complete
|
|
1091
|
+
Component Name: ButtonMaterialDesignEnterprise
|
|
1092
|
+
Class Names: rounded-md, px-4 py-2
|
|
1093
|
+
|
|
1094
|
+
✅ Brutalism Button Test Complete
|
|
1095
|
+
Component Name: ButtonBrutalismEnterprise
|
|
1096
|
+
Class Names: rounded-none, px-4 py-2
|
|
1097
|
+
|
|
1098
|
+
🎯 Result: ✅ DIFFERENT (PASS)
|
|
1099
|
+
✅ Design systems generate DIFFERENT code (Target State met!)
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
---
|
|
1103
|
+
|
|
1104
|
+
## Advanced Usage
|
|
1105
|
+
|
|
1106
|
+
### Validators
|
|
1107
|
+
|
|
1108
|
+
```typescript
|
|
1109
|
+
import {
|
|
1110
|
+
isValidColorScheme,
|
|
1111
|
+
isValidSize,
|
|
1112
|
+
isValidAnimation,
|
|
1113
|
+
validateFactor24Completeness,
|
|
1114
|
+
} from '@nikkory/vibe-engine';
|
|
1115
|
+
|
|
1116
|
+
// Validate individual factors
|
|
1117
|
+
if (isValidColorScheme('primary')) {
|
|
1118
|
+
console.log('Valid color');
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// Validate complete configuration
|
|
1122
|
+
const result = validateFactor24Completeness(config);
|
|
1123
|
+
if (!result.isComplete) {
|
|
1124
|
+
console.log('Missing factors:', result.missing);
|
|
1125
|
+
}
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
### Result/Option Types
|
|
1129
|
+
|
|
1130
|
+
```typescript
|
|
1131
|
+
import { Result, Option } from '@nikkory/vibe-engine';
|
|
1132
|
+
|
|
1133
|
+
// Result type for error handling
|
|
1134
|
+
function generateCode(): Result<string, Error> {
|
|
1135
|
+
try {
|
|
1136
|
+
const code = '...';
|
|
1137
|
+
return Result.ok(code);
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
return Result.fail(new Error('Generation failed'));
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
const result = generateCode();
|
|
1144
|
+
if (result.isSuccess()) {
|
|
1145
|
+
console.log(result.getValue());
|
|
1146
|
+
} else {
|
|
1147
|
+
console.error(result.getError());
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// Option type for nullable values
|
|
1151
|
+
const maybeComponent = Option.fromNullable(getComponent('button'));
|
|
1152
|
+
if (maybeComponent.isSome()) {
|
|
1153
|
+
console.log(maybeComponent.unwrap().name);
|
|
1154
|
+
}
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
---
|
|
1158
|
+
|
|
1159
|
+
## Package Structure
|
|
1160
|
+
|
|
1161
|
+
```
|
|
1162
|
+
@nikkory/vibe-engine/
|
|
1163
|
+
├── dist/
|
|
1164
|
+
│ ├── index.js # CommonJS
|
|
1165
|
+
│ ├── index.mjs # ES Module
|
|
1166
|
+
│ ├── index.d.ts # TypeScript types
|
|
1167
|
+
│ ├── browser.js # Browser build
|
|
1168
|
+
│ └── browser.mjs
|
|
1169
|
+
├── src/
|
|
1170
|
+
│ ├── generator/ # Style generation
|
|
1171
|
+
│ ├── presets/ # Component registry
|
|
1172
|
+
│ ├── constants/ # Design systems, tiers
|
|
1173
|
+
│ ├── types/ # TypeScript definitions
|
|
1174
|
+
│ └── utils/ # Utility functions
|
|
1175
|
+
└── package.json
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
---
|
|
1179
|
+
|
|
1180
|
+
## TypeScript Support
|
|
1181
|
+
|
|
1182
|
+
Full TypeScript support with strict mode enabled:
|
|
1183
|
+
|
|
1184
|
+
```typescript
|
|
1185
|
+
import type {
|
|
1186
|
+
// Core types
|
|
1187
|
+
DesignSystem,
|
|
1188
|
+
Tier,
|
|
1189
|
+
ComponentType,
|
|
1190
|
+
Framework,
|
|
1191
|
+
|
|
1192
|
+
// Configuration types
|
|
1193
|
+
Factor24Config,
|
|
1194
|
+
StyleConfig,
|
|
1195
|
+
GenerationConfig,
|
|
1196
|
+
|
|
1197
|
+
// Registry types
|
|
1198
|
+
RegistryComponentDefinition,
|
|
1199
|
+
ComponentCategory,
|
|
1200
|
+
ComponentStatus,
|
|
1201
|
+
|
|
1202
|
+
// Utility types
|
|
1203
|
+
Result,
|
|
1204
|
+
Option,
|
|
1205
|
+
} from '@nikkory/vibe-engine';
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
---
|
|
1209
|
+
|
|
1210
|
+
## Browser Support
|
|
1211
|
+
|
|
1212
|
+
- Chrome/Edge: Latest 2 versions
|
|
1213
|
+
- Firefox: Latest 2 versions
|
|
1214
|
+
- Safari: Latest 2 versions
|
|
1215
|
+
- Node.js: ≥18.0.0
|
|
1216
|
+
|
|
1217
|
+
---
|
|
1218
|
+
|
|
1219
|
+
## Related Packages
|
|
1220
|
+
|
|
1221
|
+
- **[@nikkory/vibe-react](https://npmjs.com/package/@nikkory/vibe-react)** - React component library
|
|
1222
|
+
- **[@nikkory/vibe-patterns](https://npmjs.com/package/@nikkory/vibe-patterns)** - 634 pre-built patterns
|
|
1223
|
+
- **[@nikkory/vibe-types](https://npmjs.com/package/@nikkory/vibe-types)** - Shared TypeScript types
|
|
1224
|
+
|
|
1225
|
+
---
|
|
1226
|
+
|
|
1227
|
+
## Migration from v3.x
|
|
1228
|
+
|
|
1229
|
+
See [Migration Guide](../../docs/MIGRATION-v3-to-v4.md) for detailed instructions.
|
|
1230
|
+
|
|
1231
|
+
**Quick migration**:
|
|
1232
|
+
|
|
1233
|
+
```bash
|
|
1234
|
+
# Replace old package
|
|
1235
|
+
npm uninstall @nikkory/vibe-core @nikkory/vibe-shared
|
|
1236
|
+
npm install @nikkory/vibe-engine
|
|
1237
|
+
|
|
1238
|
+
# Update imports
|
|
1239
|
+
# Old: import { ... } from '@nikkory/vibe-core'
|
|
1240
|
+
# New: import { ... } from '@nikkory/vibe-engine'
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
---
|
|
1244
|
+
|
|
1245
|
+
## Contributing
|
|
1246
|
+
|
|
1247
|
+
We welcome contributions! See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
|
|
1248
|
+
|
|
1249
|
+
---
|
|
1250
|
+
|
|
1251
|
+
## License
|
|
1252
|
+
|
|
1253
|
+
MIT © Nikkory
|
|
1254
|
+
|
|
1255
|
+
---
|
|
1256
|
+
|
|
1257
|
+
## Support
|
|
1258
|
+
|
|
1259
|
+
- **Documentation**: https://docs.nikkory.com
|
|
1260
|
+
- **GitHub Issues**: https://github.com/kemonra/nikkory-vibe/issues
|
|
1261
|
+
- **Discord**: https://discord.gg/nikkory
|
|
1262
|
+
- **Email**: dev@nikkory.com
|
|
1263
|
+
|
|
1264
|
+
---
|
|
1265
|
+
|
|
1266
|
+
**Powered by Nikkory**
|
|
1267
|
+
*https://nikkory.com*
|