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
@@ -29,12 +29,36 @@ export interface ChainCSSLoaderOptions {
29
29
  * @default false
30
30
  */
31
31
  verbose?: boolean;
32
+ /**
33
+ * Enable CSS extraction to separate file
34
+ * @default false
35
+ */
36
+ extractCSS?: boolean;
37
+ /**
38
+ * Enable Hot Module Replacement
39
+ * @default true in development
40
+ */
41
+ hmr?: boolean;
42
+ /**
43
+ * Custom cache key for compilation
44
+ */
45
+ cacheKey?: string;
46
+ /**
47
+ * Framework to generate components for
48
+ * @default 'auto'
49
+ */
50
+ framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'auto';
32
51
  }
33
52
  interface LoaderContext {
34
53
  async: () => (err: Error | null, code?: string) => void;
35
54
  getOptions: () => ChainCSSLoaderOptions;
36
55
  resourcePath: string;
37
56
  context: string;
57
+ cacheable: (flag: boolean) => void;
58
+ addDependency: (file: string) => void;
59
+ emitFile: (name: string, content: string, sourceMap?: any) => void;
60
+ emitWarning: (warning: Error) => void;
61
+ emitError: (error: Error) => void;
38
62
  }
39
63
  /**
40
64
  * Webpack loader for ChainCSS
@@ -42,4 +66,3 @@ interface LoaderContext {
42
66
  */
43
67
  export default function chaincssLoader(this: LoaderContext, source: string): void;
44
68
  export {};
45
- //# sourceMappingURL=webpack.d.ts.map
@@ -1,106 +1,243 @@
1
1
  // src/plugins/webpack.ts
2
2
  import path from "path";
3
- import { execSync } from "child_process";
3
+ import { spawn } from "child_process";
4
4
  import fs from "fs";
5
5
  import { fileURLToPath } from "url";
6
+ import crypto from "crypto";
6
7
  var __filename = fileURLToPath(import.meta.url);
7
8
  var __dirname = path.dirname(__filename);
8
- function chaincssLoader(source) {
9
- const callback = this.async();
10
- const options = this.getOptions() || {};
11
- const mode = options.mode || (process.env.NODE_ENV === "production" ? "build" : "runtime");
12
- if (mode === "runtime") {
13
- if (options.verbose) {
14
- console.log(`[chaincss-loader] Runtime mode for ${this.resourcePath}`);
9
+ function generateHash(content) {
10
+ return crypto.createHash("md5").update(content).digest("hex").slice(0, 8);
11
+ }
12
+ function extractStyleExports(source) {
13
+ const exports = [];
14
+ const constRegex = /const\s+(\w+)\s*=\s*(?:chain|\$)\(\s*\)\s*(?:\.\w+\([^)]*\)\s*)*\.\$el\(['"`]([^'"`]+)['"`]\)/g;
15
+ let match;
16
+ while ((match = constRegex.exec(source)) !== null) {
17
+ exports.push({
18
+ name: match[1],
19
+ className: match[2]
20
+ });
21
+ }
22
+ const exportRegex = /export\s+const\s+(\w+)\s*=\s*(?:chain|\$)\(\s*\)\s*(?:\.\w+\([^)]*\)\s*)*\.\$el\(['"`]([^'"`]+)['"`]\)/g;
23
+ while ((match = exportRegex.exec(source)) !== null) {
24
+ exports.push({
25
+ name: match[1],
26
+ className: match[2]
27
+ });
28
+ }
29
+ return exports;
30
+ }
31
+ function generateRuntimeCode(source, styleExports, resourcePath, options) {
32
+ const styleNames = styleExports.map((e) => e.name).join(", ");
33
+ const hmrEnabled = options.hmr !== false && process.env.NODE_ENV !== "production";
34
+ const classMapping = styleExports.map((exp) => ` ${exp.name}: '${exp.className}'`).join(",\n");
35
+ return `
36
+ // Generated by ChainCSS Webpack Loader (Runtime Mode)
37
+ // Source: ${path.basename(resourcePath)}
38
+
39
+ import { chain, enableDebug } from 'chaincss/runtime';
40
+
41
+ ${hmrEnabled ? `// Enable debug in development
42
+ if (process.env.NODE_ENV !== 'production') {
43
+ enableDebug(${options.verbose || false});
44
+ }` : ""}
45
+
46
+ // Original source for reference
47
+ ${source}
48
+
49
+ // Compiled style exports
50
+ export const styles = {
51
+ ${classMapping}
52
+ };
53
+
54
+ export default styles;
55
+
56
+ ${hmrEnabled ? `
57
+ // HMR Support
58
+ if (module.hot) {
59
+ module.hot.accept();
60
+ module.hot.dispose(() => {
61
+ // Cleanup on reload
62
+ const styleId = 'chaincss-${generateHash(resourcePath)}';
63
+ const style = document.getElementById(styleId);
64
+ if (style) style.remove();
65
+ });
15
66
  }
16
- const styleNames = extractStyleNames(source);
17
- const code = `
18
- import { $, compile } from 'chaincss/runtime';
19
- const styles = (() => {
20
- ${source}
21
- return { ${styleNames} };
22
- })();
67
+ ` : ""}
68
+ `;
69
+ }
70
+ function generateProductionCode(css, styleExports, resourcePath, options) {
71
+ const styleNames = styleExports.map((e) => e.name).join(", ");
72
+ const classMapping = styleExports.map((exp) => ` ${exp.name}: '${exp.className}'`).join(",\n");
73
+ const escapedCSS = css.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
74
+ if (options.extractCSS) {
75
+ return `
76
+ // Generated by ChainCSS Webpack Loader (Build Mode - Extracted)
77
+ // Source: ${path.basename(resourcePath)}
78
+
79
+ export const styles = {
80
+ ${classMapping}
81
+ };
82
+
83
+ export default styles;
84
+ `;
85
+ } else {
86
+ return `
87
+ // Generated by ChainCSS Webpack Loader (Build Mode - Injected)
88
+ // Source: ${path.basename(resourcePath)}
89
+
90
+ export const styles = {
91
+ ${classMapping}
92
+ };
93
+
94
+ // Inject CSS
95
+ const css = \`${escapedCSS}\`;
96
+ if (typeof document !== 'undefined' && css && css.trim()) {
97
+ const styleId = 'chaincss-${generateHash(resourcePath)}';
98
+ let style = document.getElementById(styleId);
99
+ if (!style) {
100
+ style = document.createElement('style');
101
+ style.id = styleId;
102
+ style.setAttribute('data-chaincss', 'true');
103
+ style.setAttribute('data-source', ${JSON.stringify(path.basename(resourcePath))});
104
+ document.head.appendChild(style);
105
+ }
106
+ style.textContent = css;
107
+ }
108
+
23
109
  export default styles;
24
110
  `;
25
- callback(null, code);
26
- return;
27
111
  }
112
+ }
113
+ async function compileChainCSS(source, filePath, options, context) {
114
+ const tempFile = path.join(context.context, `.temp.${generateHash(source)}.chain.js`);
115
+ const outputDir = options.outputDir || path.join(process.cwd(), ".chaincss-cache");
116
+ const baseName = path.basename(filePath, path.extname(filePath));
28
117
  try {
29
- if (options.verbose) {
30
- console.log(`[chaincss-loader] Build mode for ${this.resourcePath}`);
31
- }
32
- const tempFile = path.join(this.context, `.temp.${Date.now()}.chain.js`);
33
- const outputDir = options.outputDir || path.join(process.cwd(), ".chaincss-cache");
34
- if (!fs.existsSync(path.dirname(tempFile))) {
35
- fs.mkdirSync(path.dirname(tempFile), { recursive: true });
118
+ const tempDir = path.dirname(tempFile);
119
+ if (!fs.existsSync(tempDir)) {
120
+ fs.mkdirSync(tempDir, { recursive: true });
36
121
  }
37
122
  fs.writeFileSync(tempFile, source, "utf8");
123
+ context.addDependency(tempFile);
38
124
  if (!fs.existsSync(outputDir)) {
39
125
  fs.mkdirSync(outputDir, { recursive: true });
40
126
  }
41
127
  const chaincssCli = path.join(__dirname, "../cli/index.js");
42
- let cmd = `node ${chaincssCli} compile "${tempFile}" "${outputDir}"`;
43
- if (options.atomic) {
44
- cmd += " --atomic";
128
+ if (!fs.existsSync(chaincssCli)) {
129
+ throw new Error(`ChainCSS CLI not found at ${chaincssCli}. Please ensure chaincss is built.`);
45
130
  }
46
- if (options.minify) {
47
- cmd += " --minify";
131
+ const args = [
132
+ chaincssCli,
133
+ "compile",
134
+ tempFile,
135
+ outputDir,
136
+ "--framework",
137
+ options.framework || "auto"
138
+ ];
139
+ if (options.atomic) args.push("--atomic");
140
+ if (options.minify) args.push("--minify");
141
+ if (options.sourceMap) args.push("--source-map");
142
+ if (options.verbose) args.push("--verbose");
143
+ if (options.verbose) {
144
+ console.log(`[chaincss-loader] Executing: node ${args.join(" ")}`);
48
145
  }
49
- if (options.sourceMap) {
50
- cmd += " --source-map";
146
+ const result = await new Promise((resolve, reject) => {
147
+ const proc = spawn("node", args, {
148
+ cwd: process.cwd(),
149
+ timeout: 3e4
150
+ });
151
+ let stdout = "";
152
+ let stderr = "";
153
+ proc.stdout.on("data", (data) => {
154
+ stdout += data.toString();
155
+ });
156
+ proc.stderr.on("data", (data) => {
157
+ stderr += data.toString();
158
+ });
159
+ proc.on("close", (code) => {
160
+ if (code === 0) {
161
+ resolve({ stdout, stderr });
162
+ } else {
163
+ reject(new Error(`Compilation failed with code ${code}: ${stderr}`));
164
+ }
165
+ });
166
+ proc.on("error", reject);
167
+ });
168
+ if (options.verbose && result.stdout) {
169
+ console.log(result.stdout);
51
170
  }
52
- if (options.verbose) {
53
- console.log(`[chaincss-loader] Executing: ${cmd}`);
171
+ if (result.stderr) {
172
+ context.emitWarning(new Error(result.stderr));
54
173
  }
55
- execSync(cmd, { stdio: options.verbose ? "inherit" : "pipe" });
56
- const baseName = path.basename(this.resourcePath, path.extname(this.resourcePath));
57
174
  const cssPath = path.join(outputDir, `${baseName}.css`);
58
- const jsPath = path.join(outputDir, `${baseName}.js`);
59
175
  let css = "";
60
176
  if (fs.existsSync(cssPath)) {
61
177
  css = fs.readFileSync(cssPath, "utf8");
178
+ if (options.verbose) {
179
+ console.log(`[chaincss-loader] Read CSS: ${css.length} bytes from ${cssPath}`);
180
+ }
62
181
  }
63
- let classExports = "";
64
- if (fs.existsSync(jsPath)) {
65
- classExports = fs.readFileSync(jsPath, "utf8");
182
+ const classMapPath = path.join(outputDir, `${baseName}.class.js`);
183
+ let classMap = {};
184
+ if (fs.existsSync(classMapPath)) {
185
+ const classMapContent = fs.readFileSync(classMapPath, "utf8");
186
+ const exportMatch = classMapContent.match(/export const (\w+) = '([^']+)'/g);
187
+ if (exportMatch) {
188
+ exportMatch.forEach((line) => {
189
+ const match = line.match(/export const (\w+) = '([^']+)'/);
190
+ if (match) {
191
+ classMap[match[1]] = match[2];
192
+ }
193
+ });
194
+ }
66
195
  }
67
- fs.unlinkSync(tempFile);
68
- const code = `
69
- // Generated by ChainCSS Webpack Loader (Build Mode)
70
- // Zero-runtime CSS injection
71
-
72
- ${classExports}
73
-
74
- const css = ${JSON.stringify(css)};
75
- if (typeof document !== 'undefined') {
76
- const styleId = 'chaincss-${baseName}';
77
- let style = document.getElementById(styleId);
78
- if (!style) {
79
- style = document.createElement('style');
80
- style.id = styleId;
81
- style.setAttribute('data-chaincss', ${JSON.stringify(this.resourcePath)});
82
- document.head.appendChild(style);
83
- }
84
- style.textContent = css;
196
+ return { css, classMap };
197
+ } finally {
198
+ try {
199
+ if (fs.existsSync(tempFile)) {
200
+ fs.unlinkSync(tempFile);
85
201
  }
86
-
87
- export default { ${extractStyleNames(source)} };
88
- `;
202
+ } catch (e) {
203
+ }
204
+ }
205
+ }
206
+ function chaincssLoader(source) {
207
+ const callback = this.async();
208
+ const options = this.getOptions() || {};
209
+ this.cacheable(true);
210
+ const mode = options.mode || (process.env.NODE_ENV === "production" ? "build" : "runtime");
211
+ const styleExports = extractStyleExports(source);
212
+ if (options.verbose) {
213
+ console.log(`[chaincss-loader] Processing ${path.basename(this.resourcePath)} in ${mode} mode`);
214
+ console.log(`[chaincss-loader] Found exports: ${styleExports.map((e) => e.name).join(", ")}`);
215
+ }
216
+ if (mode === "runtime") {
217
+ const code = generateRuntimeCode(source, styleExports, this.resourcePath, options);
218
+ callback(null, code);
219
+ return;
220
+ }
221
+ compileChainCSS(source, this.resourcePath, options, this).then(({ css, classMap }) => {
222
+ if (options.extractCSS && css) {
223
+ const cssFileName = `${path.basename(this.resourcePath, path.extname(this.resourcePath))}.css`;
224
+ this.emitFile(cssFileName, css);
225
+ if (options.verbose) {
226
+ console.log(`[chaincss-loader] Emitted CSS: ${cssFileName} (${css.length} bytes)`);
227
+ }
228
+ }
229
+ const code = generateProductionCode(css, styleExports, this.resourcePath, options);
230
+ if (options.verbose) {
231
+ console.log(`[chaincss-loader] \u2713 Compiled ${path.basename(this.resourcePath)}`);
232
+ console.log(`[chaincss-loader] CSS size: ${css.length} bytes`);
233
+ console.log(`[chaincss-loader] Exports: ${styleExports.length}`);
234
+ }
89
235
  callback(null, code);
90
- } catch (err) {
236
+ }).catch((err) => {
91
237
  console.error(`[chaincss-loader] Error compiling ${this.resourcePath}:`, err.message);
238
+ this.emitError(err);
92
239
  callback(err);
93
- }
94
- }
95
- function extractStyleNames(source) {
96
- const matches = source.match(/const\s+(\w+)\s*=\s*\$\(/g);
97
- if (!matches)
98
- return "";
99
- const names = matches.map((m) => {
100
- const match = m.match(/const\s+(\w+)/);
101
- return match ? match[1] : "";
102
- }).filter(Boolean);
103
- return names.join(", ");
240
+ });
104
241
  }
105
242
  export {
106
243
  chaincssLoader as default
@@ -0,0 +1,32 @@
1
+ export declare function enableDebug(enabled?: boolean): void;
2
+ export declare const setManifest: (manifest: any) => void;
3
+ export declare const setTokens: (tokens: any) => void;
4
+ export declare class RuntimeChain {
5
+ private useTokens;
6
+ private catcher;
7
+ private componentName;
8
+ proxy: any;
9
+ constructor(useTokens?: boolean);
10
+ use(plugin: any): any;
11
+ hover(): any;
12
+ /**
13
+ * Set the component name for class generation
14
+ */
15
+ $name(name: string): this;
16
+ /**
17
+ * Finalizes the chain. Returns the style object and resets the catcher.
18
+ */
19
+ $el(name?: string): Record<string, any>;
20
+ end(name?: string): Record<string, any>;
21
+ /**
22
+ * Get the current catcher (for debugging)
23
+ */
24
+ getCatcher(): Record<string, any>;
25
+ }
26
+ /**
27
+ * --- EXPORTS ---
28
+ */
29
+ export declare const $: () => any;
30
+ export declare const $t: () => any;
31
+ export declare const chain: (useTokens?: boolean) => any;
32
+ export default chain;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ export interface UseSmartStylesOptions {
3
+ debug?: boolean;
4
+ ssr?: boolean;
5
+ moduleId?: string;
6
+ }
7
+ export declare function useSmartStyles<T extends Record<string, any>>(styleBuilder: (chain: any) => any, deps?: any[], options?: UseSmartStylesOptions): Record<string, string>;
8
+ export declare function createSmartComponent<P extends Record<string, any>>(Component: React.ComponentType<P>, baseStyles?: (chain: any) => any): React.FC<P & {
9
+ className?: string;
10
+ }>;
11
+ export declare function withSmartStyles<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, styles: (chain: any) => any): React.FC<P>;
@@ -1,3 +1,23 @@
1
1
  export declare function setupHMR(): void;
2
- export declare function registerForHMR(moduleId: string, styles: Record<string, any>): void;
3
- //# sourceMappingURL=hmr.d.ts.map
2
+ /**
3
+ * Register a module for HMR updates
4
+ * @param moduleId - Unique identifier for the module
5
+ * @param styles - Current styles object (optional)
6
+ * @param callback - Callback when module updates (optional)
7
+ */
8
+ export declare function registerForHMR(moduleId: string, styles?: Record<string, any>, callback?: (newStyles: Record<string, any>) => void): void;
9
+ /**
10
+ * Get HMR status
11
+ */
12
+ export declare function isHMRSupported(): boolean;
13
+ /**
14
+ * Get current HMR environment
15
+ */
16
+ export declare function getHMRType(): string;
17
+ declare const _default: {
18
+ setupHMR: typeof setupHMR;
19
+ registerForHMR: typeof registerForHMR;
20
+ isHMRSupported: typeof isHMRSupported;
21
+ getHMRType: typeof getHMRType;
22
+ };
23
+ export default _default;
@@ -4,12 +4,13 @@
4
4
  * WARNING: Importing from this module adds ~3.2KB to your bundle.
5
5
  * For production, use build-time compilation with chaincss/plugin/vite instead.
6
6
  */
7
- export { $, compileRuntime as compile, runRuntime as run, styleInjector } from './injector.js';
7
+ export { compileRuntime as compile, runRuntime as run, styleInjector } from './injector.js';
8
+ export { $, $t, chain, setManifest } from './Chain.js';
8
9
  export { useChainStyles, useDynamicChainStyles, useThemeChainStyles, ChainCSSGlobal, cx, withChainStyles, enableChainCSSDebug, disableChainCSSDebug, isDebugEnabled, createStyledComponent, useComputedStyles } from './react.js';
9
10
  export { useAtomicClasses, ChainCSSGlobal as ChainCSSGlobalVue, createStyledComponent as createStyledVueComponent, // This is fine - it renames
10
11
  createStyledComponents as createStyledVueComponents, useComputedStyles as useComputedStylesVue, // This renames useComputedStyles
11
12
  provideStyleContext, injectStyleContext } from './vue.js';
13
+ export { useAtomicClasses as useAtomicClassesSvelte, cx as cxSvelte, ChainCSSGlobal as ChainCSSGlobalSvelte, createStyledComponent as createStyledSvelteComponent, createStyledComponents as createStyledSvelteComponents, useComputedStyles as useComputedStylesSvelte, provideStyleContext as provideStyleContextSvelte, injectStyleContext as injectStyleContextSvelte, chainStyles } from './svelte.js';
12
14
  export { setupHMR, registerForHMR } from './hmr.js';
13
15
  export { generateStyleId, hashString, kebabCase, isBrowser, isDevelopment, isProduction, debounce, memoize, cn as cnUtils, devWarn, devLog, logError, createDebugger } from './utils.js';
14
16
  export type { RuntimeStyleDefinition, UseChainStylesOptions, RuntimeCompiledResult, StyleInjector, UseAtomicClassesReturn, HMRPayload, ChainCSSDebugger } from './types.js';
15
- //# sourceMappingURL=index.d.ts.map