@nikkory/vibe-engine 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -1168
- package/bin/vibe.js +1 -1
- package/dist/cli/logo.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,1032 +9,100 @@ Zero-token UI/UX code generation with 24-factor design system support.
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## Features
|
|
12
|
+
## ✨ Features
|
|
13
13
|
|
|
14
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
|
|
15
|
+
- 🎯 **24-Factor Configuration**: Comprehensive design control across color, size, variant, shape, animation, accessibility, and more
|
|
16
16
|
- 📦 **169 Components**: Button, Input, Card, Modal, Tabs, and 45+ more component types
|
|
17
|
-
- 🔧 **Framework-Agnostic**:
|
|
17
|
+
- 🔧 **Framework-Agnostic**: Works with React, Vue, Svelte, or any framework
|
|
18
18
|
- 🏛️ **3-Tier Quality**: Basic (30-50 LOC), Standard (50-150 LOC), Enterprise (150-300 LOC)
|
|
19
19
|
- 📊 **Component Registry**: Search, filter, browse 169 pre-configured components
|
|
20
|
-
- 🎭 **Style Generation**: Runtime style generation with design tokens
|
|
21
20
|
- 🛡️ **Type-Safe**: Full TypeScript support with strict mode
|
|
22
21
|
|
|
23
22
|
---
|
|
24
23
|
|
|
25
|
-
## Installation
|
|
24
|
+
## 📦 Installation
|
|
26
25
|
|
|
27
26
|
```bash
|
|
28
|
-
#
|
|
29
|
-
npm install @nikkory/vibe-engine
|
|
30
|
-
|
|
31
|
-
# pnpm
|
|
32
|
-
pnpm add @nikkory/vibe-engine
|
|
27
|
+
# Global CLI (Recommended)
|
|
28
|
+
npm install -g @nikkory/vibe-engine
|
|
33
29
|
|
|
34
|
-
#
|
|
35
|
-
|
|
30
|
+
# Local library
|
|
31
|
+
npm install @nikkory/vibe-engine
|
|
36
32
|
```
|
|
37
33
|
|
|
38
34
|
---
|
|
39
35
|
|
|
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';
|
|
36
|
+
## 🚀 Quick Start
|
|
71
37
|
|
|
72
|
-
|
|
73
|
-
console.log(ALL_COMPONENTS.length); // 169
|
|
38
|
+
### CLI Usage
|
|
74
39
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
40
|
+
```bash
|
|
41
|
+
# Generate enterprise button with Material Design
|
|
42
|
+
vibe generate button material-design enterprise
|
|
78
43
|
|
|
79
|
-
|
|
80
|
-
|
|
44
|
+
# Generate with custom factor overrides
|
|
45
|
+
vibe generate button material-design enterprise --factor-4=full
|
|
81
46
|
|
|
82
|
-
|
|
83
|
-
|
|
47
|
+
# Batch generate all components for Material Design
|
|
48
|
+
vibe batch -o ./generated --ds material-design
|
|
84
49
|
```
|
|
85
50
|
|
|
86
51
|
### Design Systems
|
|
87
52
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
53
|
+
| Design System | Description |
|
|
54
|
+
| ----------------- | -------------------------------- |
|
|
55
|
+
| material-design | Google Material Design 3 |
|
|
56
|
+
| ios-hig | Apple Human Interface Guidelines |
|
|
57
|
+
| glassmorphism | Frosted glass effect |
|
|
58
|
+
| neumorphism | Soft UI with shadows |
|
|
59
|
+
| brutalism | Bold, raw aesthetic |
|
|
60
|
+
| minimalism | Clean, simple design |
|
|
61
|
+
| cyberpunk | Neon futuristic style |
|
|
62
|
+
| flat-design | Microsoft Metro style |
|
|
63
|
+
| retro-vintage | Classic nostalgic look |
|
|
64
|
+
| fluent-design | Microsoft Fluent UI |
|
|
65
|
+
| carbon-design | IBM Carbon Design |
|
|
66
|
+
| ant-design | Ant Design System |
|
|
99
67
|
|
|
100
68
|
### Quality Tiers
|
|
101
69
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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';
|
|
70
|
+
| Tier | LOC | Features |
|
|
71
|
+
| ---------- | ------- | --------------------------------------- |
|
|
72
|
+
| Basic | 30-50 | Core props, basic styling |
|
|
73
|
+
| Standard | 50-150 | + forwardRef, displayName, variants |
|
|
74
|
+
| Enterprise | 150-300 | + memo, useCallback, analytics, ARIA |
|
|
75
|
+
|
|
76
|
+
### Example Output (Enterprise Tier)
|
|
77
|
+
|
|
78
|
+
Generated Material Design Button with full production-ready features:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import React, { memo, forwardRef, useCallback } from 'react';
|
|
82
|
+
|
|
83
|
+
export const MaterialDesignButtonEnterprise = memo(
|
|
84
|
+
forwardRef<HTMLButtonElement, MaterialDesignButtonEnterpriseProps>(
|
|
85
|
+
({ children, analyticsEvent, onClick, ...props }, ref) => {
|
|
86
|
+
const handleClick = useCallback(
|
|
87
|
+
(e: React.MouseEvent<HTMLButtonElement>): void => {
|
|
88
|
+
if (analyticsEvent && typeof window !== 'undefined') {
|
|
89
|
+
(window as unknown as { dataLayer?: unknown[] }).dataLayer?.push({
|
|
90
|
+
event: analyticsEvent,
|
|
91
|
+
category: 'component',
|
|
92
|
+
action: 'click',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
onClick?.(e);
|
|
96
|
+
},
|
|
97
|
+
[analyticsEvent, onClick]
|
|
98
|
+
);
|
|
1030
99
|
|
|
1031
|
-
export const ButtonMaterialDesignEnterprise = memo(
|
|
1032
|
-
forwardRef<HTMLButtonElement, ButtonMaterialDesignEnterpriseProps>(
|
|
1033
|
-
({ children, className, ...props }, ref) => {
|
|
1034
100
|
return (
|
|
1035
101
|
<button
|
|
1036
102
|
ref={ref}
|
|
1037
|
-
|
|
103
|
+
onClick={handleClick}
|
|
104
|
+
className="bg-blue-500 hover:bg-blue-600 rounded-full px-6 py-3"
|
|
105
|
+
aria-label={props['aria-label']}
|
|
1038
106
|
{...props}
|
|
1039
107
|
>
|
|
1040
108
|
{children}
|
|
@@ -1044,179 +112,56 @@ export const ButtonMaterialDesignEnterprise = memo(
|
|
|
1044
112
|
)
|
|
1045
113
|
);
|
|
1046
114
|
|
|
1047
|
-
|
|
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
|
|
115
|
+
MaterialDesignButtonEnterprise.displayName = 'MaterialDesignButtonEnterprise';
|
|
1085
116
|
```
|
|
1086
117
|
|
|
1087
|
-
**
|
|
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
|
-
```
|
|
118
|
+
**Generated in <0.1s** with full TypeScript types and tests included.
|
|
1101
119
|
|
|
1102
120
|
---
|
|
1103
121
|
|
|
1104
|
-
##
|
|
122
|
+
## 🎯 24-Factor System
|
|
1105
123
|
|
|
1106
|
-
|
|
124
|
+
The engine supports 24 configurable design factors:
|
|
1107
125
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
isValidColorScheme,
|
|
1111
|
-
isValidSize,
|
|
1112
|
-
isValidAnimation,
|
|
1113
|
-
validateFactor24Completeness,
|
|
1114
|
-
} from '@nikkory/vibe-engine';
|
|
126
|
+
**Basic Factors (1-6)**
|
|
127
|
+
- Color, Size, Variant, Shape, Position, Icon Position
|
|
1115
128
|
|
|
1116
|
-
|
|
1117
|
-
|
|
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';
|
|
129
|
+
**Standard Factors (7-11)**
|
|
130
|
+
- State, Animation, Elevation, Accessibility, Alignment
|
|
1132
131
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
try {
|
|
1136
|
-
const code = '...';
|
|
1137
|
-
return Result.ok(code);
|
|
1138
|
-
} catch (error) {
|
|
1139
|
-
return Result.fail(new Error('Generation failed'));
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
132
|
+
**Standard Extended (12-16)**
|
|
133
|
+
- Orientation, Density, Loading State, Responsive, Theme
|
|
1142
134
|
|
|
1143
|
-
|
|
1144
|
-
|
|
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
|
-
```
|
|
135
|
+
**Enterprise Factors (17-24)**
|
|
136
|
+
- Spacing, Typography, Border, Opacity, Overflow, Cursor, Z-Index, Transition
|
|
1177
137
|
|
|
1178
138
|
---
|
|
1179
139
|
|
|
1180
|
-
##
|
|
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,
|
|
140
|
+
## 📖 Documentation
|
|
1196
141
|
|
|
1197
|
-
|
|
1198
|
-
RegistryComponentDefinition,
|
|
1199
|
-
ComponentCategory,
|
|
1200
|
-
ComponentStatus,
|
|
142
|
+
For detailed API documentation, examples, and guides:
|
|
1201
143
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
} from '@nikkory/vibe-engine';
|
|
1206
|
-
```
|
|
144
|
+
- **Website**: https://nikkory.com
|
|
145
|
+
- **Full Documentation**: https://docs.nikkory.com
|
|
146
|
+
- **GitHub**: https://github.com/kemonra/nikkory-vibe
|
|
1207
147
|
|
|
1208
148
|
---
|
|
1209
149
|
|
|
1210
|
-
##
|
|
150
|
+
## 📊 Component Registry
|
|
1211
151
|
|
|
1212
|
-
-
|
|
1213
|
-
|
|
1214
|
-
-
|
|
1215
|
-
-
|
|
152
|
+
169 pre-configured components across 12 categories:
|
|
153
|
+
|
|
154
|
+
- **Basic**: Button, Input, Textarea, Checkbox, Radio, Switch, Select, Slider
|
|
155
|
+
- **Feedback**: Alert, Badge, Chip, Progress, Spinner, Skeleton, Tooltip
|
|
156
|
+
- **Navigation**: Tabs, Menu, Breadcrumb, Pagination, Stepper
|
|
157
|
+
- **Data Display**: Card, Table, List, Accordion, Avatar
|
|
158
|
+
- **Overlay**: Modal, Drawer, Popover
|
|
159
|
+
- **Date/Time**: Date Picker, Calendar
|
|
160
|
+
- **Media**: Audio, Video, Image, File
|
|
1216
161
|
|
|
1217
162
|
---
|
|
1218
163
|
|
|
1219
|
-
## Related Packages
|
|
164
|
+
## 🔧 Related Packages
|
|
1220
165
|
|
|
1221
166
|
- **[@nikkory/vibe-react](https://npmjs.com/package/@nikkory/vibe-react)** - React component library
|
|
1222
167
|
- **[@nikkory/vibe-patterns](https://npmjs.com/package/@nikkory/vibe-patterns)** - 634 pre-built patterns
|
|
@@ -1224,42 +169,32 @@ import type {
|
|
|
1224
169
|
|
|
1225
170
|
---
|
|
1226
171
|
|
|
1227
|
-
##
|
|
1228
|
-
|
|
1229
|
-
See [Migration Guide](../../docs/MIGRATION-v3-to-v4.md) for detailed instructions.
|
|
172
|
+
## 🌐 Browser Support
|
|
1230
173
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
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
|
-
```
|
|
174
|
+
- Chrome/Edge: Latest 2 versions
|
|
175
|
+
- Firefox: Latest 2 versions
|
|
176
|
+
- Safari: Latest 2 versions
|
|
177
|
+
- Node.js: ≥18.0.0
|
|
1242
178
|
|
|
1243
179
|
---
|
|
1244
180
|
|
|
1245
|
-
##
|
|
181
|
+
## 📄 License
|
|
1246
182
|
|
|
1247
|
-
|
|
183
|
+
MIT © Nikkory
|
|
1248
184
|
|
|
1249
|
-
|
|
185
|
+
**Copyright © 2024-2026 Nikkory. All rights reserved.**
|
|
1250
186
|
|
|
1251
|
-
|
|
187
|
+
This software and its source code are proprietary to Nikkory and protected by copyright law. Unauthorized copying, distribution, modification, or use of this software, via any medium, is strictly prohibited without express written permission from Nikkory.
|
|
1252
188
|
|
|
1253
|
-
|
|
189
|
+
For licensing inquiries, please contact: dev@nikkory.com
|
|
1254
190
|
|
|
1255
191
|
---
|
|
1256
192
|
|
|
1257
|
-
## Support
|
|
193
|
+
## 💬 Support
|
|
1258
194
|
|
|
1259
|
-
- **Documentation**: https://docs.nikkory.com
|
|
1260
195
|
- **GitHub Issues**: https://github.com/kemonra/nikkory-vibe/issues
|
|
1261
|
-
- **Discord**: https://discord.gg/nikkory
|
|
1262
196
|
- **Email**: dev@nikkory.com
|
|
197
|
+
- **Website**: https://nikkory.com
|
|
1263
198
|
|
|
1264
199
|
---
|
|
1265
200
|
|