chaincss 2.1.39 → 2.3.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.
Files changed (33) hide show
  1. package/dist/compiler/accessibility-engine.d.ts +57 -0
  2. package/dist/compiler/constraint-solver.d.ts +85 -0
  3. package/dist/compiler/css-if-transpiler.d.ts +33 -0
  4. package/dist/compiler/design-orchestrator.d.ts +119 -0
  5. package/dist/compiler/intent-api.d.ts +73 -0
  6. package/dist/compiler/intent-engine.d.ts +19 -1
  7. package/dist/compiler/layout-intelligence.d.ts +71 -0
  8. package/dist/compiler/pass-manager.d.ts +157 -0
  9. package/dist/compiler/pattern-learner.d.ts +112 -0
  10. package/dist/compiler/responsive-inference.d.ts +63 -0
  11. package/dist/compiler/scroll-timeline.d.ts +91 -0
  12. package/dist/compiler/semantic-tokens.d.ts +57 -0
  13. package/dist/compiler/source-optimizer.d.ts +109 -0
  14. package/dist/compiler/style-ir.d.ts +183 -0
  15. package/dist/index.d.ts +23 -0
  16. package/dist/index.js +4126 -2
  17. package/package.json +1 -1
  18. package/src/compiler/accessibility-engine.ts +502 -0
  19. package/src/compiler/constraint-solver.ts +407 -0
  20. package/src/compiler/css-if-transpiler.ts +117 -0
  21. package/src/compiler/design-orchestrator.ts +322 -0
  22. package/src/compiler/intent-api.ts +505 -0
  23. package/src/compiler/intent-engine.ts +291 -1
  24. package/src/compiler/layout-intelligence.ts +697 -0
  25. package/src/compiler/pass-manager.ts +657 -0
  26. package/src/compiler/pattern-learner.ts +398 -0
  27. package/src/compiler/responsive-inference.ts +415 -0
  28. package/src/compiler/scroll-timeline.ts +284 -0
  29. package/src/compiler/semantic-tokens.ts +468 -0
  30. package/src/compiler/source-optimizer.ts +541 -0
  31. package/src/compiler/style-ir.ts +495 -0
  32. package/src/index.ts +209 -0
  33. package/ROADMAP.md +0 -31
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Style Pattern Learner
3
+ *
4
+ * Observes all styles across a codebase and:
5
+ * 1. DETECTS repeated patterns by content-hashing style blocks
6
+ * 2. RANKS by frequency × property count
7
+ * 3. SUGGESTS extraction as chain.recipe() or intent macros
8
+ * 4. REPORTS savings (lines eliminated, bundle size reduction)
9
+ *
10
+ * This is compiler-assisted design system extraction.
11
+ */
12
+ import type { IRRule, IRPass } from './style-ir.js';
13
+ export interface StyleFingerprint {
14
+ /** Content hash of the property set */
15
+ hash: string;
16
+ /** Human-readable signature */
17
+ signature: string;
18
+ /** Properties and their values */
19
+ properties: Record<string, string | number>;
20
+ /** Number of properties */
21
+ propertyCount: number;
22
+ }
23
+ export interface PatternCluster {
24
+ /** The fingerprint that defines this cluster */
25
+ fingerprint: StyleFingerprint;
26
+ /** All rules that match this pattern */
27
+ occurrences: Array<{
28
+ ruleId: string;
29
+ selector: string;
30
+ sourceFile?: string;
31
+ component?: string;
32
+ }>;
33
+ /** How many times it appears */
34
+ frequency: number;
35
+ /** Across how many files */
36
+ fileCount: number;
37
+ /** Importance score (frequency × propertyCount) */
38
+ score: number;
39
+ /** Suggested recipe name */
40
+ suggestedName: string;
41
+ /** Suggested extraction as recipe */
42
+ suggestedRecipe: string;
43
+ /** Estimated savings */
44
+ savings: {
45
+ declarations: number;
46
+ linesEliminated: number;
47
+ bundleReduction: string;
48
+ };
49
+ }
50
+ export interface LearningReport {
51
+ clusters: PatternCluster[];
52
+ totalPatterns: number;
53
+ highValuePatterns: PatternCluster[];
54
+ totalSavings: {
55
+ declarations: number;
56
+ estimatedBytes: number;
57
+ };
58
+ summary: string;
59
+ }
60
+ /**
61
+ * Create a content hash from a set of declarations.
62
+ * Ignores selectors, focuses on the actual style properties.
63
+ */
64
+ declare function fingerprintDeclarations(declarations: Array<{
65
+ property: string;
66
+ value: string | number;
67
+ }>): StyleFingerprint;
68
+ /**
69
+ * Cluster rules by their style fingerprint.
70
+ * Only considers rules with a minimum number of declarations.
71
+ */
72
+ declare function clusterPatterns(rules: IRRule[], options?: {
73
+ minProperties?: number;
74
+ minFrequency?: number;
75
+ }): PatternCluster[];
76
+ /**
77
+ * Generate a full learning report from clustered patterns.
78
+ */
79
+ declare function generateReport(clusters: PatternCluster[]): LearningReport;
80
+ /**
81
+ * Pattern Learning IR pass.
82
+ * Analyzes rules, clusters patterns, and adds diagnostics.
83
+ */
84
+ export declare const patternLearningPass: IRPass;
85
+ /**
86
+ * Learn patterns from a set of style rules.
87
+ */
88
+ export declare function learnPatterns(rules: Array<{
89
+ selector: string;
90
+ declarations: Record<string, string | number>;
91
+ sourceFile?: string;
92
+ }>, options?: {
93
+ minProperties?: number;
94
+ minFrequency?: number;
95
+ }): LearningReport;
96
+ /**
97
+ * Get the top patterns worth extracting.
98
+ */
99
+ export declare function getExtractionCandidates(rules: Array<{
100
+ selector: string;
101
+ declarations: Record<string, string | number>;
102
+ sourceFile?: string;
103
+ }>, minScore?: number): PatternCluster[];
104
+ export declare const patternLearner: {
105
+ learn: typeof learnPatterns;
106
+ extract: typeof getExtractionCandidates;
107
+ fingerprint: typeof fingerprintDeclarations;
108
+ cluster: typeof clusterPatterns;
109
+ report: typeof generateReport;
110
+ pass: IRPass;
111
+ };
112
+ export default patternLearner;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Automatic Responsive Inference Engine
3
+ *
4
+ * Detects layout patterns that will break on mobile and suggests fixes.
5
+ * Positions ChainCSS as a layout advisor, not just a compiler.
6
+ *
7
+ * Detection rules:
8
+ * - Fixed widths > 768px → suggest min(100%, width)
9
+ * - Grid columns > 2 → suggest auto-fit
10
+ * - Large font sizes → suggest clamp()
11
+ * - Fixed height: 100vh → suggest 100dvh
12
+ * - Large padding/gap → suggest responsive reduction
13
+ * - Multiple fixed-width columns → suggest auto-fit grid
14
+ */
15
+ import type { IRPass } from './style-ir.js';
16
+ export interface ResponsiveIssue {
17
+ ruleId: string;
18
+ selector: string;
19
+ property: string;
20
+ currentValue: string;
21
+ severity: 'error' | 'warning' | 'info';
22
+ category: 'overflow' | 'grid' | 'typography' | 'spacing' | 'viewport' | 'columns';
23
+ message: string;
24
+ suggestedFix: string;
25
+ autoFixAvailable: boolean;
26
+ affectedViewports: string[];
27
+ }
28
+ export interface ResponsiveReport {
29
+ issues: ResponsiveIssue[];
30
+ criticalCount: number;
31
+ warningCount: number;
32
+ infoCount: number;
33
+ summary: string;
34
+ }
35
+ /**
36
+ * Responsive Inference IR pass.
37
+ * Detects responsive issues and adds diagnostics with suggested fixes.
38
+ */
39
+ export declare const responsiveInferencePass: IRPass;
40
+ /**
41
+ * Analyze declarations and return responsive issues.
42
+ */
43
+ export declare function analyzeResponsive(selector: string, declarations: Record<string, string | number>): ResponsiveIssue[];
44
+ /**
45
+ * Generate a full responsive report.
46
+ */
47
+ export declare function generateResponsiveReport(issues: ResponsiveIssue[]): ResponsiveReport;
48
+ /**
49
+ * Auto-fix a single responsive issue.
50
+ */
51
+ export declare function autoFixIssue(issue: ResponsiveIssue): string;
52
+ /**
53
+ * Auto-fix all auto-fixable issues.
54
+ */
55
+ export declare function autoFixAll(issues: ResponsiveIssue[]): string[];
56
+ export declare const responsiveInference: {
57
+ analyze: typeof analyzeResponsive;
58
+ report: typeof generateResponsiveReport;
59
+ autoFix: typeof autoFixIssue;
60
+ autoFixAll: typeof autoFixAll;
61
+ pass: IRPass;
62
+ };
63
+ export default responsiveInference;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Scroll-Driven Animations Engine
3
+ *
4
+ * Compiles timeline-based animation descriptions into:
5
+ * 1. Native CSS scroll-timeline / view-timeline (Chromium 115+)
6
+ * 2. @supports fallback with JavaScript polyfill hint
7
+ *
8
+ * API inspiration: GSAP's ScrollTrigger, but compiles to 0kb JS.
9
+ */
10
+ export interface ScrollTimelineConfig {
11
+ /** Name of the timeline */
12
+ name: string;
13
+ /** What drives the timeline */
14
+ source: 'scroll' | 'view';
15
+ /** The scrollable element (default: nearest scrollable ancestor) */
16
+ scroller?: 'nearest' | 'root' | 'self' | string;
17
+ /** Scroll axis */
18
+ axis?: 'block' | 'inline' | 'x' | 'y';
19
+ /** For view timelines: when does the element enter/exit */
20
+ inset?: string | {
21
+ start: string;
22
+ end: string;
23
+ };
24
+ /** Timeline range (for view timelines) */
25
+ range?: 'cover' | 'contain' | 'entry' | 'exit' | 'entry-crossing' | 'exit-crossing' | string;
26
+ }
27
+ export interface KeyframeStep {
28
+ /** Percentage or keyword (e.g., '0%', 'from', 'to') */
29
+ offset: string;
30
+ /** CSS properties at this keyframe */
31
+ properties: Record<string, string | number>;
32
+ /** Easing for this segment */
33
+ easing?: string;
34
+ }
35
+ export interface ScrollAnimation {
36
+ /** Selector to animate */
37
+ selector: string;
38
+ /** Timeline configuration */
39
+ timeline: ScrollTimelineConfig;
40
+ /** Keyframes */
41
+ keyframes: KeyframeStep[];
42
+ /** Animation duration (maps to timeline range) */
43
+ duration?: string;
44
+ /** Fill mode */
45
+ fill?: 'none' | 'forwards' | 'backwards' | 'both';
46
+ /** Iteration count */
47
+ iterations?: number | 'infinite';
48
+ /** Delay before starting */
49
+ delay?: string;
50
+ }
51
+ export interface ScrollTimelineResult {
52
+ /** Native CSS for scroll-driven animation */
53
+ css: string;
54
+ /** The @keyframes name generated */
55
+ animationName: string;
56
+ /** The timeline name generated */
57
+ timelineName: string;
58
+ /** Fallback CSS for browsers without scroll-timeline */
59
+ fallback: string;
60
+ }
61
+ export declare const SCROLL_PRESETS: Record<string, ScrollAnimation>;
62
+ /**
63
+ * Compile a scroll animation into CSS.
64
+ *
65
+ * Output includes:
66
+ * - @keyframes definition
67
+ * - animation-timeline property
68
+ * - animation-range (for view timelines)
69
+ * - @supports fallback for older browsers
70
+ */
71
+ export declare function compileScrollAnimation(animation: ScrollAnimation): ScrollTimelineResult;
72
+ /**
73
+ * Compile multiple scroll animations for a page.
74
+ */
75
+ export declare function compileScrollAnimations(animations: ScrollAnimation[]): string;
76
+ /**
77
+ * Create a scroll animation from a preset.
78
+ */
79
+ export declare function createScrollAnimation(preset: keyof typeof SCROLL_PRESETS, selector: string, overrides?: Partial<ScrollAnimation>): ScrollAnimation;
80
+ /**
81
+ * Get available scroll animation presets.
82
+ */
83
+ export declare function getScrollPresets(): string[];
84
+ export declare const scrollTimeline: {
85
+ compile: typeof compileScrollAnimation;
86
+ compileAll: typeof compileScrollAnimations;
87
+ create: typeof createScrollAnimation;
88
+ presets: Record<string, ScrollAnimation>;
89
+ getPresets: typeof getScrollPresets;
90
+ };
91
+ export default scrollTimeline;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Semantic Token System
3
+ *
4
+ * Intent-based styling that maps semantic concepts to design tokens.
5
+ * Wraps the existing token system — both coexist.
6
+ *
7
+ * @example
8
+ * chain.surface('interactive') // → maps to background, color, border-radius
9
+ * chain.text('primary') // → maps to color, font-weight
10
+ * chain.elevation('floating') // → maps to box-shadow, z-index
11
+ * chain.state('hover') // → maps to hover pseudo-class
12
+ * chain.spacing('comfortable') // → maps to padding
13
+ */
14
+ import type { IRPass } from './style-ir.js';
15
+ export type SurfaceIntent = 'interactive' | 'container' | 'overlay' | 'sheet' | 'tooltip' | 'input';
16
+ export type TextIntent = 'primary' | 'secondary' | 'muted' | 'link' | 'inverse' | 'code';
17
+ export type ElevationIntent = 'flat' | 'raised' | 'floating' | 'sticky' | 'overlay' | 'modal';
18
+ export type StateIntent = 'hover' | 'active' | 'focus' | 'disabled' | 'loading' | 'selected';
19
+ export type SpacingIntent = 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious' | 'generous';
20
+ export interface SemanticMapping {
21
+ properties: Record<string, string | number>;
22
+ pseudoClass?: string;
23
+ description: string;
24
+ }
25
+ export interface ThemeContext {
26
+ mode: 'light' | 'dark' | 'high-contrast';
27
+ brand?: Record<string, string>;
28
+ containerContext?: 'light' | 'dark';
29
+ }
30
+ /**
31
+ * Resolve a semantic intent to concrete CSS properties.
32
+ * Applies theme overrides based on context.
33
+ */
34
+ export declare function resolveSemantic(category: 'surface' | 'text' | 'elevation' | 'state' | 'spacing', intent: string, themeContext?: ThemeContext): SemanticMapping | null;
35
+ /**
36
+ * Get all available intents for a category.
37
+ */
38
+ export declare function getSemanticIntents(category: 'surface' | 'text' | 'elevation' | 'state' | 'spacing'): string[];
39
+ /**
40
+ * Get the description of a semantic intent.
41
+ */
42
+ export declare function getSemanticDescription(category: 'surface' | 'text' | 'elevation' | 'state' | 'spacing', intent: string): string | null;
43
+ /**
44
+ * Semantic Token IR pass.
45
+ * Resolves any _semantic metadata on rules into concrete declarations.
46
+ */
47
+ export declare const semanticTokensPass: IRPass;
48
+ export declare const semanticTokens: {
49
+ resolve: typeof resolveSemantic;
50
+ getIntents: typeof getSemanticIntents;
51
+ getDescription: typeof getSemanticDescription;
52
+ pass: IRPass;
53
+ theme: Record<string, Record<string, SemanticMapping>>;
54
+ darkOverrides: Record<string, Record<string, Partial<Record<string, string | number>>>>;
55
+ highContrastOverrides: Record<string, Record<string, Partial<Record<string, string | number>>>>;
56
+ };
57
+ export default semanticTokens;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Source-Aware Optimization Engine
3
+ *
4
+ * Unifies all analysis modules into an enterprise-grade optimization report.
5
+ * Tracks where every style originates and detects:
6
+ * - Duplicate styles across files
7
+ * - Dead/unreachable rules
8
+ * - Specificity wars
9
+ * - Conflicting animations
10
+ * - Redundant media queries
11
+ * - Unused variants and recipes
12
+ */
13
+ import type { IRRule, IRPass } from './style-ir.js';
14
+ export interface DuplicateGroup {
15
+ /** The shared signature */
16
+ signature: string;
17
+ /** All occurrences with source locations */
18
+ occurrences: Array<{
19
+ selector: string;
20
+ file?: string;
21
+ line?: number;
22
+ component?: string;
23
+ }>;
24
+ /** How many times it appears */
25
+ count: number;
26
+ /** Suggested extraction */
27
+ suggestion: string;
28
+ /** Estimated savings in bytes */
29
+ savingsBytes: number;
30
+ }
31
+ export interface DeadRule {
32
+ ruleId: string;
33
+ selector: string;
34
+ file?: string;
35
+ line?: number;
36
+ reason: string;
37
+ bytesWasted: number;
38
+ }
39
+ export interface SpecificityConflict {
40
+ higher: {
41
+ selector: string;
42
+ specificity: number;
43
+ file?: string;
44
+ line?: number;
45
+ };
46
+ lower: {
47
+ selector: string;
48
+ specificity: number;
49
+ file?: string;
50
+ line?: number;
51
+ };
52
+ property?: string;
53
+ severity: 'warning' | 'info';
54
+ }
55
+ export interface AnimationConflict {
56
+ name: string;
57
+ locations: Array<{
58
+ file?: string;
59
+ line?: number;
60
+ selector: string;
61
+ }>;
62
+ count: number;
63
+ }
64
+ export interface MediaQueryRedundancy {
65
+ query: string;
66
+ count: number;
67
+ files: string[];
68
+ suggestion: string;
69
+ savingsBytes: number;
70
+ }
71
+ export interface OptimizationReport {
72
+ duplicates: DuplicateGroup[];
73
+ deadRules: DeadRule[];
74
+ specificityConflicts: SpecificityConflict[];
75
+ animationConflicts: AnimationConflict[];
76
+ mediaQueryRedundancies: MediaQueryRedundancy[];
77
+ summary: {
78
+ totalIssues: number;
79
+ duplicatesCount: number;
80
+ deadCount: number;
81
+ specificityCount: number;
82
+ animationCount: number;
83
+ mediaQueryCount: number;
84
+ totalSavingsBytes: number;
85
+ totalSavingsKB: string;
86
+ };
87
+ formattedReport: string;
88
+ }
89
+ declare function findDuplicates(rules: IRRule[]): DuplicateGroup[];
90
+ declare function findDeadRules(rules: IRRule[]): DeadRule[];
91
+ declare function findSpecificityConflicts(rules: IRRule[]): SpecificityConflict[];
92
+ declare function findAnimationConflicts(rules: IRRule[]): AnimationConflict[];
93
+ declare function findMediaQueryRedundancies(rules: IRRule[]): MediaQueryRedundancy[];
94
+ declare function formatReport(report: OptimizationReport): string;
95
+ declare function generateOptimizationReport(rules: IRRule[]): OptimizationReport;
96
+ export declare const sourceOptimizerPass: IRPass;
97
+ export declare function optimizeSource(rules: IRRule[]): OptimizationReport;
98
+ export declare const sourceOptimizer: {
99
+ optimize: typeof optimizeSource;
100
+ findDuplicates: typeof findDuplicates;
101
+ findDeadRules: typeof findDeadRules;
102
+ findSpecificityConflicts: typeof findSpecificityConflicts;
103
+ findAnimationConflicts: typeof findAnimationConflicts;
104
+ findMediaQueryRedundancies: typeof findMediaQueryRedundancies;
105
+ report: typeof generateOptimizationReport;
106
+ format: typeof formatReport;
107
+ pass: IRPass;
108
+ };
109
+ export default sourceOptimizer;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * ChainCSS Intermediate Representation (IR)
3
+ *
4
+ * The single source of truth that all compiler passes read from and write to.
5
+ * Replaces direct object mutation with a typed, traceable AST.
6
+ *
7
+ * Architecture:
8
+ * StyleDefinition → parseIR() → StyleIR → [passes] → generateCSS()
9
+ */
10
+ import type { StyleDefinition } from '../core/types.js';
11
+ /** Unique identifier for every IR node */
12
+ export type IRNodeId = string;
13
+ /** Source location for debugging and source maps */
14
+ export interface SourceLocation {
15
+ file?: string;
16
+ line?: number;
17
+ column?: number;
18
+ component?: string;
19
+ }
20
+ /** A single CSS declaration (property: value) */
21
+ export interface IRDeclaration {
22
+ id: IRNodeId;
23
+ property: string;
24
+ value: string | number;
25
+ important?: boolean;
26
+ source?: SourceLocation;
27
+ /** Transform history — who modified this and why */
28
+ history: IRTransformRecord[];
29
+ /** Metadata from passes */
30
+ meta: Record<string, any>;
31
+ }
32
+ /** A CSS rule (selector + declarations + nested rules) */
33
+ export interface IRRule {
34
+ id: IRNodeId;
35
+ selector: string;
36
+ declarations: IRDeclaration[];
37
+ pseudoClasses: IRPseudoClass[];
38
+ atRules: IRAtRule[];
39
+ nestedRules: IRRule[];
40
+ /** Conditional if() expressions */
41
+ conditions: IRCondition[];
42
+ /** Dead code flag — set by optimizer passes */
43
+ isDead: boolean;
44
+ /** Specificity — set by graph pass */
45
+ specificity: number;
46
+ /** Content hash for deduplication */
47
+ hash: string;
48
+ source: SourceLocation;
49
+ history: IRTransformRecord[];
50
+ meta: Record<string, any>;
51
+ }
52
+ /** Pseudo-class block (hover, focus, etc.) */
53
+ export interface IRPseudoClass {
54
+ id: IRNodeId;
55
+ name: string;
56
+ declarations: IRDeclaration[];
57
+ source: SourceLocation;
58
+ history: IRTransformRecord[];
59
+ }
60
+ /** At-rule block (media, keyframes, supports, etc.) */
61
+ export interface IRAtRule {
62
+ id: IRNodeId;
63
+ type: 'media' | 'keyframes' | 'font-face' | 'supports' | 'container' | 'layer';
64
+ query?: string;
65
+ name?: string;
66
+ declarations: IRDeclaration[];
67
+ nestedRules: IRRule[];
68
+ source: SourceLocation;
69
+ history: IRTransformRecord[];
70
+ }
71
+ /** CSS if() conditional */
72
+ export interface IRCondition {
73
+ id: IRNodeId;
74
+ property: string;
75
+ variable: string;
76
+ conditions: Record<string, string | number>;
77
+ defaultValue: string | number;
78
+ source: SourceLocation;
79
+ }
80
+ /** Transform record — who touched this node and why */
81
+ export interface IRTransformRecord {
82
+ pass: string;
83
+ action: string;
84
+ timestamp: number;
85
+ previous?: any;
86
+ reason?: string;
87
+ }
88
+ /** The full IR tree */
89
+ export interface StyleIR {
90
+ id: string;
91
+ rules: IRRule[];
92
+ diagnostics: IRDiagnostic[];
93
+ meta: {
94
+ version: string;
95
+ createdAt: number;
96
+ sourceFiles: string[];
97
+ passCount: number;
98
+ passes: string[];
99
+ };
100
+ }
101
+ /** Diagnostic attached to an IR node */
102
+ export interface IRDiagnostic {
103
+ id: IRNodeId;
104
+ nodeId: IRNodeId;
105
+ severity: 'error' | 'warning' | 'info' | 'hint';
106
+ message: string;
107
+ suggestion?: string;
108
+ pass: string;
109
+ }
110
+ export declare function resetIdCounter(): void;
111
+ export declare function createDeclaration(property: string, value: string | number, source?: SourceLocation, meta?: Record<string, any>): IRDeclaration;
112
+ export declare function createRule(selector: string, source?: SourceLocation): IRRule;
113
+ export declare function createIR(sourceFiles?: string[]): StyleIR;
114
+ /**
115
+ * Parse a StyleDefinition (or Record<string, any>) into the IR.
116
+ * This is the bridge — existing code produces StyleDefinition,
117
+ * this converts it to typed IR for all downstream passes.
118
+ */
119
+ export declare function parseIR(styles: Record<string, StyleDefinition> | Record<string, any>, sourceFile?: string): StyleIR;
120
+ /**
121
+ * Generate a CSS string from the IR.
122
+ * This replaces the ad-hoc CSS generation scattered across modules.
123
+ */
124
+ export declare function generateCSS(ir: StyleIR, options?: {
125
+ minify?: boolean;
126
+ }): string;
127
+ /** Count all nodes in the IR */
128
+ export declare function countNodes(ir: StyleIR): {
129
+ rules: number;
130
+ declarations: number;
131
+ pseudoClasses: number;
132
+ atRules: number;
133
+ conditions: number;
134
+ };
135
+ /** Find a rule by selector */
136
+ export declare function findRule(ir: StyleIR, selector: string): IRRule | undefined;
137
+ /** Clone an IR (deep copy) */
138
+ export declare function cloneIR(ir: StyleIR): StyleIR;
139
+ /** Debug: print IR summary */
140
+ export declare function debugIR(ir: StyleIR): string;
141
+ export type IRPass = (ir: StyleIR) => StyleIR;
142
+ /**
143
+ * Apply a transform pass to the IR.
144
+ * Records the pass in metadata for debugging.
145
+ */
146
+ export declare function applyPass(ir: StyleIR, pass: IRPass, passName: string): StyleIR;
147
+ /**
148
+ * Apply multiple passes in sequence.
149
+ */
150
+ export declare function applyPasses(ir: StyleIR, passes: Array<{
151
+ name: string;
152
+ pass: IRPass;
153
+ }>): StyleIR;
154
+ /**
155
+ * Full pipeline: StyleDefinition → IR → passes → CSS.
156
+ * Drop-in replacement for existing compile() calls.
157
+ */
158
+ export declare function compileViaIR(styles: Record<string, StyleDefinition>, passes?: Array<{
159
+ name: string;
160
+ pass: IRPass;
161
+ }>, options?: {
162
+ minify?: boolean;
163
+ sourceFile?: string;
164
+ }): {
165
+ css: string;
166
+ ir: StyleIR;
167
+ };
168
+ export declare const styleIR: {
169
+ createIR: typeof createIR;
170
+ parseIR: typeof parseIR;
171
+ generateCSS: typeof generateCSS;
172
+ createRule: typeof createRule;
173
+ createDeclaration: typeof createDeclaration;
174
+ countNodes: typeof countNodes;
175
+ findRule: typeof findRule;
176
+ cloneIR: typeof cloneIR;
177
+ debugIR: typeof debugIR;
178
+ applyPass: typeof applyPass;
179
+ applyPasses: typeof applyPasses;
180
+ compileViaIR: typeof compileViaIR;
181
+ resetIdCounter: typeof resetIdCounter;
182
+ };
183
+ export default styleIR;
package/dist/index.d.ts CHANGED
@@ -40,6 +40,29 @@ export type { Chain } from './compiler/Chain.js';
40
40
  export type { AnimationConfig, KeyframeDefinition } from './compiler/animations.js';
41
41
  export type { BreakpointsMap, ResponsiveStyle } from './compiler/breakpoints.js';
42
42
  export declare const VERSION = "3.0.0";
43
+ export { orchestrator, contrastRatio, checkContrast, auditContrast, createContextualToken, resolveContextual, generateContextualCSS, validateTokenRelationships, } from './compiler/design-orchestrator.js';
44
+ export type { ContrastResult, ContrastReport, ContextualToken, TokenContext } from './compiler/design-orchestrator.js';
45
+ export { scrollTimeline, compileScrollAnimation, compileScrollAnimations, createScrollAnimation, getScrollPresets, SCROLL_PRESETS, } from './compiler/scroll-timeline.js';
46
+ export type { ScrollTimelineConfig, ScrollAnimation, ScrollTimelineResult, KeyframeStep } from './compiler/scroll-timeline.js';
47
+ export { styleIR, createIR, parseIR, generateCSS, createRule, createDeclaration, applyPass, applyPasses, compileViaIR, countNodes, debugIR, resetIdCounter, } from './compiler/style-ir.js';
48
+ export type { StyleIR, IRRule, IRDeclaration, IRPseudoClass, IRAtRule, IRCondition, IRTransformRecord, IRDiagnostic, IRNodeId, SourceLocation, IRPass, } from './compiler/style-ir.js';
49
+ export { PassManager, runDefaultPipeline, DEFAULT_PIPELINE, intentRecoveryPass, unitResolutionPass, validationPass, specificitySortPass, deadEliminationPass, atomicExtractionPass, mediaQueryPackingPass, cssIfTranspilePass, cssCompressionPass, diagnosticsExportPass, } from './compiler/pass-manager.js';
50
+ export type { PassName, PassPriority, PassDefinition, PassResult, PipelineResult } from './compiler/pass-manager.js';
51
+ export { constraintSolver, resolveConstraint, resolveStickyUntil, resolveContainerQuery, parseConstraint, constraintSolverPass, } from './compiler/constraint-solver.js';
52
+ export type { Constraint, ConstraintOperator, ConstraintTarget, ResolvedConstraint } from './compiler/constraint-solver.js';
53
+ export { layoutIntelligence, recognizeLayout, suggestMacro, getLayoutPatterns, layoutIntelligencePass, } from './compiler/layout-intelligence.js';
54
+ export type { LayoutPattern, PatternMatch, PatternReport } from './compiler/layout-intelligence.js';
55
+ export { responsiveInference, analyzeResponsive, generateResponsiveReport, autoFixIssue, autoFixAll, responsiveInferencePass, } from './compiler/responsive-inference.js';
56
+ export type { ResponsiveIssue, ResponsiveReport } from './compiler/responsive-inference.js';
57
+ export { patternLearner, learnPatterns, getExtractionCandidates, patternLearningPass, } from './compiler/pattern-learner.js';
58
+ export type { StyleFingerprint, PatternCluster, LearningReport } from './compiler/pattern-learner.js';
59
+ export { sourceOptimizer, optimizeSource, sourceOptimizerPass, } from './compiler/source-optimizer.js';
60
+ export type { OptimizationReport, DuplicateGroup, DeadRule, SpecificityConflict, AnimationConflict, MediaQueryRedundancy } from './compiler/source-optimizer.js';
61
+ export { semanticTokens, resolveSemantic, getSemanticIntents, getSemanticDescription, semanticTokensPass, } from './compiler/semantic-tokens.js';
62
+ export type { SurfaceIntent, TextIntent, ElevationIntent, StateIntent, SpacingIntent, SemanticMapping, ThemeContext } from './compiler/semantic-tokens.js';
63
+ export { accessibilityEngine, auditAccessibility, checkRule, accessibilityPass, } from './compiler/accessibility-engine.js';
64
+ export type { AccessibilityIssue, AccessibilityReport } from './compiler/accessibility-engine.js';
65
+ export { intentAPI, resolveIntent, getAvailableIntents, getIntentsByCategory, getIntentDescription, intentAPIPass, } from './compiler/intent-api.js';
43
66
  import { chain } from './compiler/Chain.js';
44
67
  export default chain;
45
68
  export type { Properties as CSSProperties } from 'csstype';