chaincss 2.1.37 → 2.1.39

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.
@@ -1,5 +1,6 @@
1
1
  import type { ChainCSSConfig, CompileResult, StyleDefinition } from './types.js';
2
2
  import { AtomicOptimizer } from '../compiler/atomic-optimizer.js';
3
+ import type { GraphCompileOptions } from '../compiler/style-graph.js';
3
4
  export declare class ChainCSSCompiler {
4
5
  private config;
5
6
  private prefixer;
@@ -18,6 +19,17 @@ export declare class ChainCSSCompiler {
18
19
  private compileQueue;
19
20
  private lruList;
20
21
  constructor(config: ChainCSSConfig);
22
+ /**
23
+ * Compile using the style graph compiler for advanced optimizations.
24
+ *
25
+ * @example
26
+ * const result = compiler.compileWithGraph(styles, {
27
+ * eliminateDead: true,
28
+ * knownSelectors: ['.header', '.footer'],
29
+ * mergeIdentical: true
30
+ * });
31
+ */
32
+ compileWithGraph(styles: Record<string, import('./types.js').StyleDefinition>, options?: GraphCompileOptions): import('./types.js').GraphCompileResult;
21
33
  hasStyles(): boolean;
22
34
  private processStyleObject;
23
35
  private addToCache;
@@ -199,3 +199,148 @@ export declare function isStyleDefinition(value: any): value is StyleDefinition;
199
199
  export declare function isAtRule(value: any): value is AtRule;
200
200
  export declare function isAtomicClass(value: any): value is AtomicClass;
201
201
  export declare function isCompileResult(value: any): value is CompileResult;
202
+ export type CSSUnit = 'px' | 'rem' | 'em' | '%' | 'vw' | 'vh' | 'vmin' | 'vmax' | 'ch' | 'ex' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'deg' | 'rad' | 'turn' | 'grad' | 's' | 'ms' | 'dpi' | 'dpcm' | 'dppx';
203
+ export interface CSSMathValue {
204
+ value: number;
205
+ unit: CSSUnit;
206
+ }
207
+ export interface MathContext {
208
+ rootFontSize?: number;
209
+ viewportWidth?: number;
210
+ viewportHeight?: number;
211
+ parentFontSize?: number;
212
+ dpi?: number;
213
+ elementWidth?: number;
214
+ elementHeight?: number;
215
+ }
216
+ export interface MathResult {
217
+ value: number;
218
+ unit: CSSUnit | 'calc' | 'mixed';
219
+ expression: string;
220
+ resolved: CSSMathValue | null;
221
+ explanations: string[];
222
+ toString(): string;
223
+ toCalc(): string;
224
+ }
225
+ export interface FluidTypeConfig {
226
+ minSize: number;
227
+ maxSize: number;
228
+ minWidth?: number;
229
+ maxWidth?: number;
230
+ unit?: 'px' | 'rem';
231
+ rootFontSize?: number;
232
+ }
233
+ export interface IntentRule {
234
+ input: string | RegExp;
235
+ output: string | ((match: RegExpMatchArray) => string);
236
+ defaults?: Record<string, string | number>;
237
+ confidence: number;
238
+ description: string;
239
+ }
240
+ export interface CorrectionResult {
241
+ original: string;
242
+ property: string;
243
+ corrected: string;
244
+ defaults: Record<string, string | number>;
245
+ confidence: number;
246
+ intent: string;
247
+ explanation: string;
248
+ }
249
+ export interface IntentContext {
250
+ property?: string;
251
+ value?: string;
252
+ selector?: string;
253
+ parentStyles?: Record<string, any>;
254
+ mediaContext?: string;
255
+ themeContext?: string;
256
+ }
257
+ export type HealMode = 'strict' | 'dev' | 'smart';
258
+ export interface HealResult {
259
+ fixed: Record<string, any>;
260
+ corrections: CorrectionResult[];
261
+ warnings: string[];
262
+ mode: HealMode;
263
+ }
264
+ export interface StyleGraphNode {
265
+ id: string;
266
+ selector: string;
267
+ properties: Record<string, string | number>;
268
+ specificity: number;
269
+ dependencies: string[];
270
+ dependents: string[];
271
+ mediaQuery?: string;
272
+ isDead: boolean;
273
+ hash: string;
274
+ sourceComponent?: string;
275
+ }
276
+ export interface StyleGraphEdge {
277
+ from: string;
278
+ to: string;
279
+ type: 'extends' | 'overrides' | 'references';
280
+ }
281
+ export interface StyleGraph {
282
+ nodes: Map<string, StyleGraphNode>;
283
+ edges: StyleGraphEdge[];
284
+ rootNodes: string[];
285
+ leafNodes: string[];
286
+ }
287
+ export interface GraphCompileOptions {
288
+ eliminateDead?: boolean;
289
+ knownSelectors?: string[];
290
+ mergeIdentical?: boolean;
291
+ mergeThreshold?: number;
292
+ sortOutput?: 'specificity' | 'source-order' | 'topological';
293
+ verbose?: boolean;
294
+ }
295
+ export interface GraphCompileResult extends CompileResult {
296
+ graph: StyleGraph;
297
+ eliminatedDead: number;
298
+ mergedRules: number;
299
+ optimizationTime: number;
300
+ preOptimizationSize: number;
301
+ postOptimizationSize: number;
302
+ }
303
+ export type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
304
+ export interface StyleDiagnostic {
305
+ property: string;
306
+ value?: string;
307
+ selector?: string;
308
+ severity: DiagnosticSeverity;
309
+ message: string;
310
+ suggestion?: string;
311
+ code?: string;
312
+ source?: string;
313
+ range?: {
314
+ startLine: number;
315
+ startColumn: number;
316
+ endLine: number;
317
+ endColumn: number;
318
+ };
319
+ }
320
+ export interface StyleAnalysis {
321
+ diagnostics: StyleDiagnostic[];
322
+ conflicts: StyleDiagnostic[];
323
+ breakpoints: BreakpointConfig[];
324
+ unusedSelectors: string[];
325
+ deadStyles: string[];
326
+ duplicationWarnings: StyleDiagnostic[];
327
+ optimizationSuggestions: StyleDiagnostic[];
328
+ stats: {
329
+ totalProperties: number;
330
+ totalSelectors: number;
331
+ shorthandOpportunities: number;
332
+ animationSuggestions: number;
333
+ responsiveIssues: number;
334
+ };
335
+ }
336
+ export interface BreakpointInference {
337
+ selector: string;
338
+ property: string;
339
+ currentValue: string;
340
+ suggestedBreakpoint: string;
341
+ suggestedValue: string;
342
+ reason: string;
343
+ }
344
+ export declare function isMathResult(value: any): value is MathResult;
345
+ export declare function isCorrectionResult(value: any): value is CorrectionResult;
346
+ export declare function isGraphCompileResult(value: any): value is GraphCompileResult;
package/dist/index.d.ts CHANGED
@@ -55,3 +55,11 @@ export type ResponsiveValue<T> = T | {
55
55
  };
56
56
  export type StyleWithTokens<T = any> = T | ((tokens: DesignTokens) => T);
57
57
  import { DesignTokens } from './compiler/tokens.js';
58
+ export { math, add, subtract, multiply, divide, fluidType, convert, toPx, scale } from './compiler/math-engine.js';
59
+ export type { CSSUnit, CSSMathValue, MathContext, MathResult, FluidTypeConfig } from './compiler/math-engine.js';
60
+ export { intent, correct, heal, validate as validateValue, getIntent } from './compiler/intent-engine.js';
61
+ export type { CorrectionResult, HealMode, HealResult, IntentContext } from './compiler/intent-engine.js';
62
+ export { StyleGraphCompiler, compileGraph } from './compiler/style-graph.js';
63
+ export type { StyleGraph, StyleGraphNode, StyleGraphEdge, GraphCompileOptions, GraphCompileResult } from './compiler/style-graph.js';
64
+ export { StyleAnalyzer, analyze as analyzeStyle } from './compiler/analyzer.js';
65
+ export type { StyleDiagnostic, StyleAnalysis, BreakpointInference, DiagnosticSeverity } from './compiler/analyzer.js';