@decantr/essence-spec 1.0.0-beta.1 → 1.0.0-beta.10

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/dist/index.d.ts CHANGED
@@ -11,9 +11,8 @@ type ThemeStyle = 'auradecantism' | 'clean' | 'glassmorphism' | 'retro' | 'biolu
11
11
  type ThemeMode = 'light' | 'dark' | 'auto';
12
12
  type ThemeShape = 'sharp' | 'rounded' | 'pill';
13
13
  interface Theme {
14
- style: ThemeStyle | string;
14
+ id: string;
15
15
  mode: ThemeMode;
16
- recipe: string;
17
16
  shape?: ThemeShape;
18
17
  }
19
18
  type PlatformType = 'spa' | 'ssr' | 'static';
@@ -50,10 +49,18 @@ interface Density {
50
49
  level: DensityLevel;
51
50
  content_gap: string;
52
51
  }
52
+ interface SpatialTokens {
53
+ '--d-section-py': string;
54
+ '--d-interactive-py': string;
55
+ '--d-interactive-px': string;
56
+ '--d-surface-p': string;
57
+ '--d-data-py': string;
58
+ '--d-control-py': string;
59
+ '--d-content-gap': string;
60
+ }
53
61
  type GuardMode = 'creative' | 'guided' | 'strict';
54
62
  interface Guard {
55
63
  enforce_style?: boolean;
56
- enforce_recipe?: boolean;
57
64
  mode: GuardMode;
58
65
  }
59
66
  interface Impression {
@@ -64,6 +71,12 @@ interface Impression {
64
71
  novel_elements: string[];
65
72
  }
66
73
  type GeneratorTarget = 'decantr' | 'react' | 'vue' | 'svelte' | string;
74
+ type WcagLevel = 'none' | 'A' | 'AA' | 'AAA';
75
+ type CvdPreference = 'none' | 'auto' | 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia';
76
+ interface Accessibility {
77
+ wcag_level?: WcagLevel;
78
+ cvd_preference?: CvdPreference;
79
+ }
67
80
  interface Essence {
68
81
  $schema?: string;
69
82
  version: string;
@@ -76,6 +89,7 @@ interface Essence {
76
89
  density: Density;
77
90
  guard: Guard;
78
91
  target: GeneratorTarget;
92
+ accessibility?: Accessibility;
79
93
  _impression?: Impression;
80
94
  }
81
95
  interface EssenceSection {
@@ -96,9 +110,130 @@ interface SectionedEssence {
96
110
  density: Density;
97
111
  guard: Guard;
98
112
  target: GeneratorTarget;
113
+ accessibility?: Accessibility;
99
114
  _impression?: Impression;
100
115
  }
101
- type EssenceFile = Essence | SectionedEssence;
116
+ interface EssenceDNA {
117
+ theme: Theme;
118
+ spacing: {
119
+ base_unit: number;
120
+ scale: string;
121
+ density: DensityLevel;
122
+ content_gap: string;
123
+ };
124
+ typography: {
125
+ scale: string;
126
+ heading_weight: number;
127
+ body_weight: number;
128
+ };
129
+ color: {
130
+ palette: string;
131
+ accent_count: number;
132
+ cvd_preference: CvdPreference | string;
133
+ };
134
+ radius: {
135
+ philosophy: ThemeShape | string;
136
+ base: number;
137
+ };
138
+ elevation: {
139
+ system: string;
140
+ max_levels: number;
141
+ };
142
+ motion: {
143
+ preference: string;
144
+ duration_scale: number;
145
+ reduce_motion: boolean;
146
+ timing?: string;
147
+ durations?: Record<string, string>;
148
+ };
149
+ accessibility: {
150
+ wcag_level: WcagLevel;
151
+ focus_visible: boolean;
152
+ skip_nav: boolean;
153
+ };
154
+ personality: string[];
155
+ constraints?: {
156
+ mode?: string;
157
+ typography?: string;
158
+ borders?: string;
159
+ corners?: string;
160
+ shadows?: string;
161
+ effects?: Record<string, string>;
162
+ };
163
+ }
164
+ /** Only density and mode may be overridden per-page. DNA axioms like wcag_level and theme.id are never overrideable. */
165
+ interface DNAOverrides {
166
+ density?: DensityLevel;
167
+ mode?: ThemeMode;
168
+ }
169
+ interface BlueprintPage {
170
+ id: string;
171
+ route?: string;
172
+ shell_override?: ShellType | null;
173
+ layout: LayoutItem[];
174
+ patterns?: PatternRef[];
175
+ dna_overrides?: DNAOverrides;
176
+ surface?: string;
177
+ }
178
+ type ArchetypeRole = 'primary' | 'gateway' | 'public' | 'auxiliary';
179
+ interface EssenceV31Section {
180
+ id: string;
181
+ role: ArchetypeRole;
182
+ shell: ShellType | string;
183
+ features: string[];
184
+ description: string;
185
+ pages: BlueprintPage[];
186
+ dna_overrides?: DNAOverrides;
187
+ }
188
+ interface RouteEntry {
189
+ section: string;
190
+ page: string;
191
+ }
192
+ interface EssenceBlueprint {
193
+ shell?: ShellType | string;
194
+ sections?: EssenceV31Section[];
195
+ pages?: BlueprintPage[];
196
+ features: string[];
197
+ routes?: Record<string, RouteEntry>;
198
+ icon_style?: string;
199
+ avatar_style?: string;
200
+ }
201
+ interface EssenceV3Guard {
202
+ mode: GuardMode;
203
+ dna_enforcement: 'error' | 'warn' | 'off';
204
+ blueprint_enforcement: 'warn' | 'off';
205
+ }
206
+ interface EssenceMeta {
207
+ archetype: string;
208
+ target: GeneratorTarget;
209
+ platform: Platform;
210
+ guard: EssenceV3Guard;
211
+ seo?: {
212
+ schema_org?: string[];
213
+ meta_priorities?: string[];
214
+ };
215
+ navigation?: {
216
+ hotkeys?: Array<{
217
+ key: string;
218
+ route?: string;
219
+ action?: string;
220
+ label: string;
221
+ }>;
222
+ command_palette?: boolean;
223
+ };
224
+ }
225
+ interface EssenceV3 {
226
+ $schema?: string;
227
+ version: '3.0.0' | '3.1.0';
228
+ dna: EssenceDNA;
229
+ blueprint: EssenceBlueprint;
230
+ meta: EssenceMeta;
231
+ _impression?: Impression;
232
+ }
233
+ type EssenceFile = Essence | SectionedEssence | EssenceV3;
234
+ declare function isV3(essence: EssenceFile): essence is EssenceV3;
235
+ /** Flatten sections into a flat page list (for guards and backward compat). */
236
+ declare function flattenPages(blueprint: EssenceBlueprint): BlueprintPage[];
102
237
  declare function isSectioned(essence: EssenceFile): essence is SectionedEssence;
103
238
  declare function isSimple(essence: EssenceFile): essence is Essence;
104
239
 
@@ -108,26 +243,55 @@ interface ValidationResult {
108
243
  }
109
244
  declare function validateEssence(data: unknown): ValidationResult;
110
245
 
111
- interface RecipeSpatialHints {
246
+ interface SpatialHints {
112
247
  density_bias?: number;
113
248
  content_gap_shift?: number;
114
249
  }
115
- declare function computeDensity(personality: string[], recipeSpatial?: RecipeSpatialHints): Density;
250
+ declare function computeDensity(personality: string[], spatialHints?: SpatialHints): Density;
251
+ interface SpatialTokenHints {
252
+ section_padding?: string | null;
253
+ density_bias?: number;
254
+ content_gap_shift?: number;
255
+ }
256
+ declare function computeSpatialTokens(density: DensityLevel, spatialHints?: SpatialTokenHints): SpatialTokens;
116
257
 
258
+ interface AutoFix {
259
+ type: 'add_page' | 'update_layout' | 'update_blueprint';
260
+ patch: Record<string, unknown>;
261
+ }
117
262
  interface GuardViolation {
118
- rule: 'style' | 'structure' | 'layout' | 'recipe' | 'density';
263
+ rule: 'style' | 'structure' | 'layout' | 'density' | 'theme-mode' | 'pattern-exists' | 'accessibility';
119
264
  severity: 'error' | 'warning';
120
265
  message: string;
266
+ suggestion?: string;
267
+ layer?: 'dna' | 'blueprint';
268
+ autoFixable?: boolean;
269
+ autoFix?: AutoFix;
121
270
  }
122
271
  interface GuardContext {
123
272
  pageId?: string;
124
273
  style?: string;
125
- recipe?: string;
126
274
  layout?: string[];
127
275
  density_gap?: string;
276
+ themeRegistry?: Map<string, {
277
+ modes: string[];
278
+ }>;
279
+ patternRegistry?: Map<string, unknown>;
280
+ a11y_issues?: string[];
128
281
  }
129
- declare function evaluateGuard(essence: EssenceFile, context: GuardContext): GuardViolation[];
282
+ declare function evaluateGuard(essence: EssenceFile, context?: GuardContext): GuardViolation[];
130
283
 
131
284
  declare function normalizeEssence(input: Record<string, unknown>): EssenceFile;
132
285
 
133
- export { type ColumnLayout, type Density, type DensityLevel, type Essence, type EssenceFile, type EssenceSection, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type PatternRef, type Platform, type PlatformType, type RoutingStrategy, type SectionedEssence, type ShellType, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, computeDensity, evaluateGuard, isSectioned, isSimple, normalizeEssence, validateEssence };
286
+ /**
287
+ * Migrate a v2 EssenceFile to v3 format (DNA/Blueprint/Meta split).
288
+ * If already v3, returns unchanged. SectionedEssence uses first section's theme.
289
+ */
290
+ declare function migrateV2ToV3(essence: EssenceFile): EssenceV3;
291
+ /**
292
+ * Migrate a v3.0 flat-page EssenceV3 to v3.1 sectioned format.
293
+ * If already v3.1 or has blueprint.sections, returns unchanged.
294
+ */
295
+ declare function migrateV30ToV31(essence: EssenceV3): EssenceV3;
296
+
297
+ export { type Accessibility, type ArchetypeRole, type AutoFix, type BlueprintPage, type ColumnLayout, type CvdPreference, type DNAOverrides, type Density, type DensityLevel, type Essence, type EssenceBlueprint, type EssenceDNA, type EssenceFile, type EssenceMeta, type EssenceSection, type EssenceV3, type EssenceV31Section, type EssenceV3Guard, type GeneratorTarget, type Guard, type GuardContext, type GuardMode, type GuardViolation, type Impression, type LayoutItem, type PatternRef, type Platform, type PlatformType, type RouteEntry, type RoutingStrategy, type SectionedEssence, type ShellType, type SpatialTokens, type StructurePage, type Theme, type ThemeMode, type ThemeShape, type ThemeStyle, type ValidationResult, type WcagLevel, computeDensity, computeSpatialTokens, evaluateGuard, flattenPages, isSectioned, isSimple, isV3, migrateV2ToV3, migrateV30ToV31, normalizeEssence, validateEssence };