chaincss 2.0.7 → 2.1.1

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 (159) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/CODE_OF_CONDUCT.md +21 -0
  3. package/CONTRIBUTING.md +28 -0
  4. package/README.md +455 -226
  5. package/demo/demo/node_modules/caniuse-db/fulldata-json/data-2.0.json +1 -0
  6. package/demo/index.html +16 -0
  7. package/demo/package.json +20 -0
  8. package/demo/src/App.tsx +117 -0
  9. package/demo/src/chaincss-barrel.ts +9 -0
  10. package/demo/src/main.tsx +8 -0
  11. package/demo/src/styles.chain.ts +300 -0
  12. package/demo/vite.config.ts +46 -0
  13. package/dist/cli/commands/build.d.ts +0 -1
  14. package/dist/cli/commands/cache.d.ts +1 -0
  15. package/dist/cli/commands/init.d.ts +6 -3
  16. package/dist/cli/commands/timeline.d.ts +0 -1
  17. package/dist/cli/commands/watch.d.ts +0 -1
  18. package/dist/cli/index.d.ts +0 -1
  19. package/dist/cli/index.js +3213 -5296
  20. package/dist/cli/types.d.ts +51 -20
  21. package/dist/cli/utils/config-loader.d.ts +0 -1
  22. package/dist/cli/utils/file-utils.d.ts +27 -3
  23. package/dist/cli/utils/logger.d.ts +0 -1
  24. package/dist/compiler/Chain.d.ts +215 -0
  25. package/dist/compiler/animations.d.ts +76 -0
  26. package/dist/compiler/atomic-optimizer.d.ts +47 -12
  27. package/dist/compiler/breakpoints.d.ts +46 -0
  28. package/dist/compiler/btt.d.ts +36 -60
  29. package/dist/compiler/cache-manager.d.ts +58 -4
  30. package/dist/compiler/commonProps.d.ts +0 -1
  31. package/dist/compiler/content-addressable-cache.d.ts +78 -0
  32. package/dist/compiler/helpers.d.ts +54 -0
  33. package/dist/compiler/index.d.ts +16 -9
  34. package/dist/compiler/index.js +4450 -4316
  35. package/dist/compiler/prefixer.d.ts +17 -1
  36. package/dist/compiler/shorthands.d.ts +28 -0
  37. package/dist/compiler/suggestions.d.ts +43 -0
  38. package/dist/compiler/theme-contract.d.ts +16 -27
  39. package/dist/compiler/token-resolver.d.ts +69 -0
  40. package/dist/compiler/tokens.d.ts +33 -8
  41. package/dist/core/auto-detector.d.ts +34 -0
  42. package/dist/core/common-utils.d.ts +97 -0
  43. package/dist/core/compiler.d.ts +63 -23
  44. package/dist/core/constants.d.ts +137 -36
  45. package/dist/core/smart-chain.d.ts +3 -0
  46. package/dist/core/types.d.ts +122 -15
  47. package/dist/core/utils.d.ts +134 -17
  48. package/dist/index.d.ts +52 -8
  49. package/dist/index.js +7090 -5578
  50. package/dist/plugins/vite.d.ts +7 -5
  51. package/dist/plugins/vite.js +2964 -25641
  52. package/dist/plugins/webpack.d.ts +24 -1
  53. package/dist/plugins/webpack.js +209 -72
  54. package/dist/runtime/Chain.d.ts +32 -0
  55. package/dist/runtime/auto-hooks.d.ts +11 -0
  56. package/dist/runtime/hmr.d.ts +22 -2
  57. package/dist/runtime/index.d.ts +3 -2
  58. package/dist/runtime/index.js +3648 -301
  59. package/dist/runtime/injector.d.ts +39 -72
  60. package/dist/runtime/react.d.ts +17 -12
  61. package/dist/runtime/svelte.d.ts +15 -0
  62. package/dist/runtime/types.d.ts +126 -4
  63. package/dist/runtime/utils.d.ts +0 -1
  64. package/dist/runtime/vue.d.ts +34 -14
  65. package/package.json +59 -66
  66. package/src/cli/commands/build.ts +133 -0
  67. package/src/cli/commands/cache.ts +371 -0
  68. package/src/cli/commands/init.ts +230 -0
  69. package/src/cli/commands/timeline.ts +435 -0
  70. package/src/cli/commands/watch.ts +211 -0
  71. package/src/cli/index.ts +226 -0
  72. package/src/cli/types.ts +100 -0
  73. package/src/cli/utils/config-loader.ts +174 -0
  74. package/src/cli/utils/file-utils.ts +139 -0
  75. package/src/cli/utils/logger.ts +74 -0
  76. package/src/compiler/Chain.ts +831 -0
  77. package/src/compiler/animations.ts +517 -0
  78. package/src/compiler/atomic-optimizer.ts +786 -0
  79. package/src/compiler/breakpoints.ts +347 -0
  80. package/src/compiler/btt.ts +1147 -0
  81. package/src/compiler/cache-manager.ts +446 -0
  82. package/src/compiler/commonProps.ts +18 -0
  83. package/src/compiler/content-addressable-cache.ts +478 -0
  84. package/src/compiler/helpers.ts +407 -0
  85. package/src/compiler/index.ts +72 -0
  86. package/src/compiler/prefixer.ts +720 -0
  87. package/src/compiler/shorthands.ts +558 -0
  88. package/src/compiler/suggestions.ts +436 -0
  89. package/src/compiler/theme-contract.ts +197 -0
  90. package/src/compiler/token-resolver.ts +241 -0
  91. package/src/compiler/tokens.ts +612 -0
  92. package/src/core/auto-detector.ts +187 -0
  93. package/src/core/common-utils.ts +423 -0
  94. package/src/core/compiler.ts +835 -0
  95. package/src/core/constants.ts +424 -0
  96. package/src/core/index.ts +107 -0
  97. package/src/core/smart-chain.ts +163 -0
  98. package/src/core/types.ts +257 -0
  99. package/src/core/utils.ts +598 -0
  100. package/src/index.ts +208 -0
  101. package/src/plugins/vite.d.ts +316 -0
  102. package/src/plugins/vite.ts +424 -0
  103. package/src/plugins/webpack.d.ts +289 -0
  104. package/src/plugins/webpack.ts +416 -0
  105. package/src/runtime/Chain.ts +242 -0
  106. package/src/runtime/auto-hooks.tsx +127 -0
  107. package/src/runtime/auto-vue.ts +72 -0
  108. package/src/runtime/hmr.ts +212 -0
  109. package/src/runtime/index.ts +82 -0
  110. package/src/runtime/injector.ts +273 -0
  111. package/src/runtime/react.tsx +269 -0
  112. package/src/runtime/svelte.ts +15 -0
  113. package/src/runtime/types.ts +256 -0
  114. package/src/runtime/utils.ts +128 -0
  115. package/src/runtime/vite-env.d.ts +120 -0
  116. package/src/runtime/vue.ts +231 -0
  117. package/tsconfig.build.json +41 -0
  118. package/tsconfig.json +25 -0
  119. package/tsconfig.runtimes.json +18 -0
  120. package/dist/cli/cli.cjs +0 -7
  121. package/dist/cli/commands/build.d.ts.map +0 -1
  122. package/dist/cli/commands/compile.d.ts +0 -3
  123. package/dist/cli/commands/compile.d.ts.map +0 -1
  124. package/dist/cli/commands/init.d.ts.map +0 -1
  125. package/dist/cli/commands/timeline.d.ts.map +0 -1
  126. package/dist/cli/commands/watch.d.ts.map +0 -1
  127. package/dist/cli/index.d.ts.map +0 -1
  128. package/dist/cli/types.d.ts.map +0 -1
  129. package/dist/cli/utils/config-loader.d.ts.map +0 -1
  130. package/dist/cli/utils/file-utils.d.ts.map +0 -1
  131. package/dist/cli/utils/logger.d.ts.map +0 -1
  132. package/dist/compiler/atomic-optimizer.d.ts.map +0 -1
  133. package/dist/compiler/btt.d.ts.map +0 -1
  134. package/dist/compiler/cache-manager.d.ts.map +0 -1
  135. package/dist/compiler/commonProps.d.ts.map +0 -1
  136. package/dist/compiler/index.d.ts.map +0 -1
  137. package/dist/compiler/prefixer.d.ts.map +0 -1
  138. package/dist/compiler/theme-contract.d.ts.map +0 -1
  139. package/dist/compiler/tokens.d.ts.map +0 -1
  140. package/dist/compiler/types.d.ts +0 -57
  141. package/dist/compiler/types.d.ts.map +0 -1
  142. package/dist/core/compiler.d.ts.map +0 -1
  143. package/dist/core/constants.d.ts.map +0 -1
  144. package/dist/core/index.d.ts +0 -4
  145. package/dist/core/index.d.ts.map +0 -1
  146. package/dist/core/types.d.ts.map +0 -1
  147. package/dist/core/utils.d.ts.map +0 -1
  148. package/dist/index.d.ts.map +0 -1
  149. package/dist/plugins/vite.d.ts.map +0 -1
  150. package/dist/plugins/webpack.d.ts.map +0 -1
  151. package/dist/runtime/hmr.d.ts.map +0 -1
  152. package/dist/runtime/index.d.ts.map +0 -1
  153. package/dist/runtime/injector.d.ts.map +0 -1
  154. package/dist/runtime/react.d.ts.map +0 -1
  155. package/dist/runtime/react.js +0 -324
  156. package/dist/runtime/types.d.ts.map +0 -1
  157. package/dist/runtime/utils.d.ts.map +0 -1
  158. package/dist/runtime/vue.d.ts.map +0 -1
  159. package/dist/runtime/vue.js +0 -286
@@ -0,0 +1,256 @@
1
+ // @ts-nocheck — optional peer dependency
2
+ // src/runtime/types.ts
3
+
4
+ /**
5
+ * Runtime ChainCSS Type Definitions
6
+ * Only needed if using runtime mode
7
+ */
8
+
9
+ // ============================================================================
10
+ // Core Runtime Types
11
+ // ============================================================================
12
+
13
+ export interface RuntimeStyleDefinition {
14
+ selectors?: string[];
15
+ hover?: Record<string, string | number>;
16
+ _classes?: string[];
17
+ _name?: string;
18
+ [cssProperty: string]: any;
19
+ }
20
+
21
+ export interface UseChainStylesOptions {
22
+ /** Cache compiled styles */
23
+ cache?: boolean;
24
+ /** CSS class namespace prefix */
25
+ namespace?: string;
26
+ /** Watch for changes (development only) */
27
+ watch?: boolean;
28
+ /** Debug mode */
29
+ debug?: boolean;
30
+ /** Server-side rendering mode */
31
+ ssr?: boolean;
32
+ }
33
+
34
+ export interface RuntimeCompiledResult {
35
+ [key: string]: string;
36
+ }
37
+
38
+ // ============================================================================
39
+ // Style Injector Types
40
+ // ============================================================================
41
+
42
+ export interface StyleInjector {
43
+ inject(styleId: string, style: RuntimeStyleDefinition): string;
44
+ injectMultiple(styles: Record<string, RuntimeStyleDefinition>, moduleId?: string): Record<string, string>;
45
+ update(styleId: string, style: RuntimeStyleDefinition): string;
46
+ remove(styleId: string): void;
47
+ removeModule(moduleId: string): void;
48
+ clear(): void;
49
+ setTokens(tokens: TokenStore): void;
50
+ getStyleElement(): HTMLStyleElement | null;
51
+ getStats(): { injectedStyles: number; modules: number };
52
+ }
53
+
54
+ // ============================================================================
55
+ // Token Types
56
+ // ============================================================================
57
+
58
+ export interface TokenStore {
59
+ colors?: Record<string, string>;
60
+ spacing?: Record<string, string>;
61
+ typography?: {
62
+ fontFamily?: Record<string, string>;
63
+ fontSize?: Record<string, string>;
64
+ fontWeight?: Record<string, string>;
65
+ lineHeight?: Record<string, string>;
66
+ letterSpacing?: Record<string, string>;
67
+ };
68
+ breakpoints?: Record<string, string>;
69
+ zIndex?: Record<string, string>;
70
+ shadows?: Record<string, string>;
71
+ borderRadius?: Record<string, string>;
72
+ animations?: Record<string, any>;
73
+ [key: string]: any;
74
+ }
75
+
76
+ // ============================================================================
77
+ // Manifest Types
78
+ // ============================================================================
79
+
80
+ export interface ChainCSSManifest {
81
+ atomicMap: Record<string, string>;
82
+ version: string;
83
+ timestamp?: number;
84
+ stats?: {
85
+ totalStyles: number;
86
+ atomicStyles: number;
87
+ uniqueProperties: number;
88
+ savings: string;
89
+ };
90
+ }
91
+
92
+ // ============================================================================
93
+ // Framework-Specific Types (optional imports)
94
+ // ============================================================================
95
+
96
+ // React-specific types
97
+ export interface UseAtomicClassesReturn {
98
+ classes: Record<string, string>;
99
+ cx: (name: string) => string;
100
+ cn: (...names: string[]) => string;
101
+ inject?: (styles: Record<string, any>) => void;
102
+ }
103
+
104
+ export interface UseDynamicChainStylesReturn extends UseAtomicClassesReturn {
105
+ updateStyles: (newStyles: Record<string, any>) => void;
106
+ }
107
+
108
+ export interface UseThemeChainStylesReturn extends UseAtomicClassesReturn {
109
+ theme: any;
110
+ setTheme: (theme: any) => void;
111
+ }
112
+
113
+ // Vue-specific types
114
+ export interface UseAtomicClassesReturnVue {
115
+ classes: import('vue').Ref<Record<string, string>>;
116
+ cx: (name: string) => string;
117
+ cn: (...names: string[]) => string;
118
+ inject: (styles: Record<string, any>) => void;
119
+ }
120
+
121
+ export interface UseComputedStylesReturnVue {
122
+ classes: import('vue').Ref<Record<string, string>>;
123
+ rootClass: import('vue').ComputedRef<string>;
124
+ }
125
+
126
+ // Svelte-specific types
127
+ export interface UseAtomicClassesReturnSvelte {
128
+ subscribe: (callback: (value: Record<string, string>) => void) => () => void;
129
+ get: () => Record<string, string>;
130
+ cx: (name: string) => string;
131
+ cn: (...names: string[]) => string;
132
+ }
133
+
134
+ export interface UseComputedStylesReturnSvelte {
135
+ classes: UseAtomicClassesReturnSvelte;
136
+ rootClass: import('svelte/store').Readable<string>;
137
+ }
138
+
139
+ // Solid-specific types (using type alias to avoid direct import error)
140
+ // These will work if solid-js is installed, otherwise they default to any
141
+ type SolidAccessor<T> = T extends any ? (() => T) : never;
142
+
143
+ export interface UseAtomicClassesReturnSolid {
144
+ classes: SolidAccessor<Record<string, string>>;
145
+ cx: (...names: string[]) => string;
146
+ inject: (styles: Record<string, any>) => void;
147
+ }
148
+
149
+ export interface UseComputedStylesReturnSolid {
150
+ classes: SolidAccessor<Record<string, string>>;
151
+ rootClass: SolidAccessor<string>;
152
+ }
153
+
154
+ // ============================================================================
155
+ // HMR Types
156
+ // ============================================================================
157
+
158
+ export interface HMRPayload {
159
+ file: string;
160
+ css?: string;
161
+ map?: Record<string, string>;
162
+ styles?: Record<string, any>;
163
+ timestamp: number;
164
+ moduleId?: string;
165
+ }
166
+
167
+ export interface HMRUpdateEvent {
168
+ type: 'chaincss:update';
169
+ data: HMRPayload;
170
+ }
171
+
172
+ // ============================================================================
173
+ // Debug Types
174
+ // ============================================================================
175
+
176
+ export interface ChainCSSDebugger {
177
+ enabled: boolean;
178
+ log: (...args: any[]) => void;
179
+ warn: (...args: any[]) => void;
180
+ error: (...args: any[]) => void;
181
+ group: (label: string) => void;
182
+ groupEnd: () => void;
183
+ time: (label: string) => void;
184
+ timeEnd: (label: string) => void;
185
+ }
186
+
187
+ export interface DebugOptions {
188
+ enabled?: boolean;
189
+ verbose?: boolean;
190
+ prefix?: string;
191
+ }
192
+
193
+ // ============================================================================
194
+ // Utility Types
195
+ // ============================================================================
196
+
197
+ export type CSSValue = string | number | undefined;
198
+ export type CSSProperties = Record<string, CSSValue>;
199
+
200
+ export type ResponsiveValue<T> = T | {
201
+ base?: T;
202
+ sm?: T;
203
+ md?: T;
204
+ lg?: T;
205
+ xl?: T;
206
+ '2xl'?: T;
207
+ [key: string]: T | undefined;
208
+ };
209
+
210
+ export type TokenValue<T = string> = T | `$${string}`;
211
+
212
+ // ============================================================================
213
+ // Global Augmentations
214
+ // ============================================================================
215
+
216
+ declare global {
217
+ interface Window {
218
+ __CHAINCSS_V2_TOKENS__?: TokenStore;
219
+ __CHAINCSS_MANIFEST__?: ChainCSSManifest;
220
+ __CHAINCSS_DEBUG__?: boolean;
221
+ __CHAINCSS_VUE_DEBUG__?: boolean;
222
+ __CHAINCSS_SVELTE_DEBUG__?: boolean;
223
+ __CHAINCSS_SOLID_DEBUG__?: boolean;
224
+ __CHAINCSS_REACT_DEBUG__?: boolean;
225
+ }
226
+ }
227
+
228
+ // ============================================================================
229
+ // Type Guards
230
+ // ============================================================================
231
+
232
+ export function isRuntimeStyleDefinition(obj: any): obj is RuntimeStyleDefinition {
233
+ return obj && typeof obj === 'object' && (obj.selectors === undefined || Array.isArray(obj.selectors));
234
+ }
235
+
236
+ export function isStyleInjector(obj: any): obj is StyleInjector {
237
+ return obj && typeof obj === 'object' &&
238
+ typeof obj.injectMultiple === 'function' &&
239
+ typeof obj.removeModule === 'function';
240
+ }
241
+
242
+ export function isChainCSSManifest(obj: any): obj is ChainCSSManifest {
243
+ return obj && typeof obj === 'object' &&
244
+ 'atomicMap' in obj &&
245
+ 'version' in obj;
246
+ }
247
+
248
+ export function isTokenStore(obj: any): obj is TokenStore {
249
+ return obj && typeof obj === 'object';
250
+ }
251
+
252
+ export function isHMRPayload(obj: any): obj is HMRPayload {
253
+ return obj && typeof obj === 'object' &&
254
+ 'file' in obj &&
255
+ 'timestamp' in obj;
256
+ }
@@ -0,0 +1,128 @@
1
+ // src/runtime/utils.ts - Add missing exports
2
+
3
+ /**
4
+ * Runtime utility functions for ChainCSS
5
+ */
6
+
7
+ /**
8
+ * Generate a unique ID for style injection
9
+ */
10
+ export function generateStyleId(prefix: string = 'chain'): string {
11
+ const random = Math.random().toString(36).substring(2, 10);
12
+ const timestamp = Date.now().toString(36);
13
+ return `${prefix}-${timestamp}-${random}`;
14
+ }
15
+
16
+ /**
17
+ * Simple hash function for class name generation
18
+ */
19
+ export function hashString(str: string): string {
20
+ let hash = 0;
21
+ for (let i = 0; i < str.length; i++) {
22
+ hash = ((hash << 5) - hash) + str.charCodeAt(i);
23
+ hash |= 0;
24
+ }
25
+ return Math.abs(hash).toString(36);
26
+ }
27
+
28
+ /**
29
+ * Convert camelCase to kebab-case
30
+ */
31
+ export function kebabCase(str: string): string {
32
+ return str.replace(/([A-Z])/g, '-$1').toLowerCase();
33
+ }
34
+
35
+ /**
36
+ * Check if code is running in browser
37
+ */
38
+ export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
39
+
40
+ /**
41
+ * Check if code is running in development mode
42
+ */
43
+ export const isDevelopment = process.env.NODE_ENV === 'development';
44
+
45
+ /**
46
+ * Check if code is running in production mode
47
+ */
48
+ export const isProduction = process.env.NODE_ENV === 'production';
49
+
50
+ /**
51
+ * Debounce function for HMR updates
52
+ */
53
+ export function debounce<T extends (...args: any[]) => any>(
54
+ fn: T,
55
+ delay: number
56
+ ): (...args: Parameters<T>) => void {
57
+ let timeoutId: ReturnType<typeof setTimeout>;
58
+
59
+ return (...args: Parameters<T>) => {
60
+ clearTimeout(timeoutId);
61
+ timeoutId = setTimeout(() => fn(...args), delay);
62
+ };
63
+ }
64
+
65
+ /**
66
+ * Memoize function results
67
+ */
68
+ export function memoize<T extends (...args: any[]) => any>(
69
+ fn: T
70
+ ): T & { cache: Map<string, ReturnType<T>> } {
71
+ const cache = new Map<string, ReturnType<T>>();
72
+
73
+ const memoized = ((...args: Parameters<T>) => {
74
+ const key = JSON.stringify(args);
75
+ if (cache.has(key)) {
76
+ return cache.get(key);
77
+ }
78
+ const result = fn(...args);
79
+ cache.set(key, result);
80
+ return result;
81
+ }) as T & { cache: Map<string, ReturnType<T>> };
82
+
83
+ memoized.cache = cache;
84
+ return memoized;
85
+ }
86
+
87
+ /**
88
+ * Safe class name joiner (like clsx)
89
+ */
90
+ export function cn(...classes: (string | undefined | null | false)[]): string {
91
+ return classes.filter(Boolean).join(' ');
92
+ }
93
+
94
+ /**
95
+ * Warn in development only
96
+ */
97
+ export function devWarn(message: string, ...args: any[]): void {
98
+ if (isDevelopment) {
99
+ console.warn(`[ChainCSS] ${message}`, ...args);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Log in development only
105
+ */
106
+ export function devLog(message: string, ...args: any[]): void {
107
+ if (isDevelopment) {
108
+ console.log(`[ChainCSS] ${message}`, ...args);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Error logging (always)
114
+ */
115
+ export function logError(message: string, error?: Error): void {
116
+ console.error(`[ChainCSS] ${message}`, error || '');
117
+ }
118
+
119
+ /**
120
+ * Create a debug logger
121
+ */
122
+ export function createDebugger(module: string) {
123
+ return {
124
+ log: (...args: any[]) => devLog(`[${module}]`, ...args),
125
+ warn: (...args: any[]) => devWarn(`[${module}]`, ...args),
126
+ error: (...args: any[]) => logError(`[${module}]`, ...args)
127
+ };
128
+ }
@@ -0,0 +1,120 @@
1
+ // src/runtime/vite-env.d.ts (enhanced version)
2
+
3
+ /// <reference types="vite/client" />
4
+
5
+ /**
6
+ * Vite HMR API Type Extensions
7
+ * Provides full type support for import.meta.hot
8
+ */
9
+
10
+ interface ImportMeta {
11
+ readonly hot?: {
12
+ /**
13
+ * Accept updates for this module
14
+ */
15
+ accept(cb?: (mod: any) => void): void;
16
+
17
+ /**
18
+ * Accept updates for specific dependencies
19
+ */
20
+ accept(deps: string[], cb: (modules: any[]) => void): void;
21
+
22
+ /**
23
+ * Handle disposal of this module
24
+ */
25
+ dispose(cb: (data: any) => void): void;
26
+
27
+ /**
28
+ * Listen to custom HMR events
29
+ */
30
+ on(event: string, cb: (data: any) => void): void;
31
+
32
+ /**
33
+ * Send custom HMR events
34
+ */
35
+ send(event: string, data: any): void;
36
+
37
+ /**
38
+ * Decline updates for this module
39
+ */
40
+ decline(): void;
41
+
42
+ /**
43
+ * Invalidate this module (force reload)
44
+ */
45
+ invalidate(): void;
46
+
47
+ /**
48
+ * Check if HMR is available
49
+ */
50
+ hot: boolean;
51
+
52
+ /**
53
+ * Current module data
54
+ */
55
+ data: any;
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Webpack HMR API Type Extensions
61
+ * For Webpack compatibility
62
+ */
63
+ declare module 'webpack' {
64
+ interface HotModule {
65
+ accept(callback?: (modules?: any[]) => void): void;
66
+ accept(dependencies: string[], callback?: (updatedDependencies: string[]) => void): void;
67
+ decline(): void;
68
+ dispose(callback: (data: any) => void): void;
69
+ addStatusHandler(callback: (status: string) => void): void;
70
+ removeStatusHandler(callback: (status: string) => void): void;
71
+ data: any;
72
+ status: () => string;
73
+ }
74
+
75
+ interface NodeModule {
76
+ hot?: HotModule;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Global HMR utilities for ChainCSS
82
+ */
83
+ declare namespace ChainCSSHMR {
84
+ interface HMREventMap {
85
+ 'chaincss:update': {
86
+ file: string;
87
+ css?: string;
88
+ map?: Record<string, string>;
89
+ styles?: Record<string, any>;
90
+ timestamp?: number;
91
+ };
92
+ 'vite:beforeUpdate': void;
93
+ 'vite:afterUpdate': void;
94
+ }
95
+
96
+ interface HMRUtils {
97
+ /**
98
+ * Setup HMR for the current environment
99
+ */
100
+ setupHMR(): void;
101
+
102
+ /**
103
+ * Register a module for HMR updates
104
+ */
105
+ registerForHMR(moduleId: string, styles?: Record<string, any>, callback?: (newStyles: Record<string, any>) => void): void;
106
+
107
+ /**
108
+ * Check if HMR is supported
109
+ */
110
+ isHMRSupported(): boolean;
111
+
112
+ /**
113
+ * Get the current HMR environment type
114
+ */
115
+ getHMRType(): 'vite' | 'webpack' | 'none';
116
+ }
117
+ }
118
+
119
+ // Export types for use in other files
120
+ export type { ChainCSSHMR };