chaincss 2.1.12 → 2.1.14

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/cli/index.js CHANGED
@@ -2834,61 +2834,8 @@ var init_compiler = __esm({
2834
2834
  if (!this.atomicOptimizer || id.includes("\0")) return;
2835
2835
  try {
2836
2836
  let processedCount = 0;
2837
- let searchFrom = 0;
2838
- while (true) {
2839
- const startIdx = source.indexOf("useChainStyles({", searchFrom);
2840
- if (startIdx === -1) break;
2841
- const braceStart = source.indexOf("{", startIdx);
2842
- if (braceStart === -1) break;
2843
- let braceCount = 0;
2844
- let endIdx = -1;
2845
- for (let i = braceStart; i < source.length; i++) {
2846
- if (source[i] === "{") braceCount++;
2847
- if (source[i] === "}") braceCount--;
2848
- if (braceCount === 0) {
2849
- endIdx = i;
2850
- break;
2851
- }
2852
- }
2853
- if (endIdx === -1) break;
2854
- const stylesBlock = source.substring(braceStart + 1, endIdx);
2855
- try {
2856
- const componentRegex = /(\w+):\s*\{/g;
2857
- let componentMatch;
2858
- while ((componentMatch = componentRegex.exec(stylesBlock)) !== null) {
2859
- const componentKey = componentMatch[1];
2860
- const componentStart = componentMatch.index + componentMatch[0].length;
2861
- let compBraceCount = 0;
2862
- let compEndIdx = -1;
2863
- for (let i = componentStart - 1; i < stylesBlock.length; i++) {
2864
- if (stylesBlock[i] === "{") compBraceCount++;
2865
- if (stylesBlock[i] === "}") compBraceCount--;
2866
- if (compBraceCount === 0) {
2867
- compEndIdx = i;
2868
- break;
2869
- }
2870
- }
2871
- if (compEndIdx === -1) continue;
2872
- const componentStyles = stylesBlock.substring(componentStart, compEndIdx);
2873
- const rawObj = this.safeParseStyleObject(`{${componentStyles}}`);
2874
- if (Object.keys(rawObj).length === 0) continue;
2875
- const expandedObj = {};
2876
- for (const [k, v] of Object.entries(rawObj)) {
2877
- const realKey = shorthandMap[k] || k;
2878
- expandedObj[realKey] = v;
2879
- }
2880
- await this.processStyleObject(expandedObj, componentKey);
2881
- processedCount++;
2882
- }
2883
- } catch (parseError) {
2884
- if (this.config.verbose) {
2885
- console.warn(chalk3.yellow(` \u26A0\uFE0F Failed to parse styles in ${id}: ${parseError}`));
2886
- }
2887
- }
2888
- searchFrom = endIdx + 1;
2889
- }
2890
2837
  if (this.config.verbose && processedCount > 0) {
2891
- console.log(chalk3.gray(` \u{1F4DD} Processed ${processedCount} styles from ${id}`));
2838
+ console.log(` \u2514\u2500 Processed ${processedCount} chain() styles from ${id.split("/").pop()}`);
2892
2839
  }
2893
2840
  } catch (error) {
2894
2841
  console.error(chalk3.red(` \u274C Error compiling source ${id}: ${error}`));
package/dist/index.js CHANGED
@@ -6352,61 +6352,8 @@ var ChainCSSCompiler = class {
6352
6352
  if (!this.atomicOptimizer || id.includes("\0")) return;
6353
6353
  try {
6354
6354
  let processedCount = 0;
6355
- let searchFrom = 0;
6356
- while (true) {
6357
- const startIdx = source.indexOf("useChainStyles({", searchFrom);
6358
- if (startIdx === -1) break;
6359
- const braceStart = source.indexOf("{", startIdx);
6360
- if (braceStart === -1) break;
6361
- let braceCount = 0;
6362
- let endIdx = -1;
6363
- for (let i = braceStart; i < source.length; i++) {
6364
- if (source[i] === "{") braceCount++;
6365
- if (source[i] === "}") braceCount--;
6366
- if (braceCount === 0) {
6367
- endIdx = i;
6368
- break;
6369
- }
6370
- }
6371
- if (endIdx === -1) break;
6372
- const stylesBlock = source.substring(braceStart + 1, endIdx);
6373
- try {
6374
- const componentRegex = /(\w+):\s*\{/g;
6375
- let componentMatch;
6376
- while ((componentMatch = componentRegex.exec(stylesBlock)) !== null) {
6377
- const componentKey = componentMatch[1];
6378
- const componentStart = componentMatch.index + componentMatch[0].length;
6379
- let compBraceCount = 0;
6380
- let compEndIdx = -1;
6381
- for (let i = componentStart - 1; i < stylesBlock.length; i++) {
6382
- if (stylesBlock[i] === "{") compBraceCount++;
6383
- if (stylesBlock[i] === "}") compBraceCount--;
6384
- if (compBraceCount === 0) {
6385
- compEndIdx = i;
6386
- break;
6387
- }
6388
- }
6389
- if (compEndIdx === -1) continue;
6390
- const componentStyles = stylesBlock.substring(componentStart, compEndIdx);
6391
- const rawObj = this.safeParseStyleObject(`{${componentStyles}}`);
6392
- if (Object.keys(rawObj).length === 0) continue;
6393
- const expandedObj = {};
6394
- for (const [k, v] of Object.entries(rawObj)) {
6395
- const realKey = shorthandMap[k] || k;
6396
- expandedObj[realKey] = v;
6397
- }
6398
- await this.processStyleObject(expandedObj, componentKey);
6399
- processedCount++;
6400
- }
6401
- } catch (parseError) {
6402
- if (this.config.verbose) {
6403
- console.warn(chalk3.yellow(` \u26A0\uFE0F Failed to parse styles in ${id}: ${parseError}`));
6404
- }
6405
- }
6406
- searchFrom = endIdx + 1;
6407
- }
6408
6355
  if (this.config.verbose && processedCount > 0) {
6409
- console.log(chalk3.gray(` \u{1F4DD} Processed ${processedCount} styles from ${id}`));
6356
+ console.log(` \u2514\u2500 Processed ${processedCount} chain() styles from ${id.split("/").pop()}`);
6410
6357
  }
6411
6358
  } catch (error) {
6412
6359
  console.error(chalk3.red(` \u274C Error compiling source ${id}: ${error}`));
@@ -2739,61 +2739,8 @@ var ChainCSSCompiler = class {
2739
2739
  if (!this.atomicOptimizer || id.includes("\0")) return;
2740
2740
  try {
2741
2741
  let processedCount = 0;
2742
- let searchFrom = 0;
2743
- while (true) {
2744
- const startIdx = source.indexOf("useChainStyles({", searchFrom);
2745
- if (startIdx === -1) break;
2746
- const braceStart = source.indexOf("{", startIdx);
2747
- if (braceStart === -1) break;
2748
- let braceCount = 0;
2749
- let endIdx = -1;
2750
- for (let i = braceStart; i < source.length; i++) {
2751
- if (source[i] === "{") braceCount++;
2752
- if (source[i] === "}") braceCount--;
2753
- if (braceCount === 0) {
2754
- endIdx = i;
2755
- break;
2756
- }
2757
- }
2758
- if (endIdx === -1) break;
2759
- const stylesBlock = source.substring(braceStart + 1, endIdx);
2760
- try {
2761
- const componentRegex = /(\w+):\s*\{/g;
2762
- let componentMatch;
2763
- while ((componentMatch = componentRegex.exec(stylesBlock)) !== null) {
2764
- const componentKey = componentMatch[1];
2765
- const componentStart = componentMatch.index + componentMatch[0].length;
2766
- let compBraceCount = 0;
2767
- let compEndIdx = -1;
2768
- for (let i = componentStart - 1; i < stylesBlock.length; i++) {
2769
- if (stylesBlock[i] === "{") compBraceCount++;
2770
- if (stylesBlock[i] === "}") compBraceCount--;
2771
- if (compBraceCount === 0) {
2772
- compEndIdx = i;
2773
- break;
2774
- }
2775
- }
2776
- if (compEndIdx === -1) continue;
2777
- const componentStyles = stylesBlock.substring(componentStart, compEndIdx);
2778
- const rawObj = this.safeParseStyleObject(`{${componentStyles}}`);
2779
- if (Object.keys(rawObj).length === 0) continue;
2780
- const expandedObj = {};
2781
- for (const [k, v] of Object.entries(rawObj)) {
2782
- const realKey = shorthandMap[k] || k;
2783
- expandedObj[realKey] = v;
2784
- }
2785
- await this.processStyleObject(expandedObj, componentKey);
2786
- processedCount++;
2787
- }
2788
- } catch (parseError) {
2789
- if (this.config.verbose) {
2790
- console.warn(chalk2.yellow(` \u26A0\uFE0F Failed to parse styles in ${id}: ${parseError}`));
2791
- }
2792
- }
2793
- searchFrom = endIdx + 1;
2794
- }
2795
2742
  if (this.config.verbose && processedCount > 0) {
2796
- console.log(chalk2.gray(` \u{1F4DD} Processed ${processedCount} styles from ${id}`));
2743
+ console.log(` \u2514\u2500 Processed ${processedCount} chain() styles from ${id.split("/").pop()}`);
2797
2744
  }
2798
2745
  } catch (error) {
2799
2746
  console.error(chalk2.red(` \u274C Error compiling source ${id}: ${error}`));
@@ -3471,6 +3418,11 @@ const setManifest = (manifest) => {
3471
3418
  log(`Processing: ${fileName}`);
3472
3419
  processedFiles.add(id);
3473
3420
  await compiler.compileSource(source, id);
3421
+ const css = compiler.getCombinedCSS();
3422
+ if (css && css.trim()) {
3423
+ const ruleCount = (css.match(/\{/g) || []).length;
3424
+ console.log(` \u2514\u2500 Extracted ${ruleCount} CSS rules from ${fileName}`);
3425
+ }
3474
3426
  updateCSS();
3475
3427
  updateManifest();
3476
3428
  if (server && options.hmr !== false) {
@@ -3526,6 +3478,14 @@ ${source}`,
3526
3478
  },
3527
3479
  buildEnd() {
3528
3480
  const finalCSS = updateCSS();
3481
+ const stats = compiler.getStats();
3482
+ console.log("");
3483
+ console.log("[ChainCSS] \u2705 Build complete");
3484
+ console.log(` \u{1F4E6} Static CSS: ${finalCSS.length} bytes`);
3485
+ console.log(` \u26A1 Runtime JS: minimal (dynamic properties only)`);
3486
+ console.log(` \u{1F9E9} Total styles: ${stats.totalStyles || 0} processed`);
3487
+ console.log(` \u{1F4BE} Atomic savings: ${stats.savings || "0%"}`);
3488
+ console.log("");
3529
3489
  log(`Build complete - Final CSS: ${finalCSS.length} bytes`);
3530
3490
  if (options.cssOutput) {
3531
3491
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaincss",
3
- "version": "2.1.12",
3
+ "version": "2.1.14",
4
4
  "description": "ChainCSS v3.0 - The first CSS-in-JS library with true auto-detection mixed mode. Zero runtime by default, dynamic when you need it.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -196,80 +196,9 @@ export class ChainCSSCompiler {
196
196
 
197
197
  try {
198
198
  let processedCount = 0;
199
- let searchFrom = 0;
200
-
201
- while (true) {
202
- const startIdx = source.indexOf('useChainStyles({', searchFrom);
203
- if (startIdx === -1) break;
204
-
205
- // Find the matching closing brace using brace counting
206
- const braceStart = source.indexOf('{', startIdx);
207
- if (braceStart === -1) break;
208
-
209
- let braceCount = 0;
210
- let endIdx = -1;
211
- for (let i = braceStart; i < source.length; i++) {
212
- if (source[i] === '{') braceCount++;
213
- if (source[i] === '}') braceCount--;
214
- if (braceCount === 0) {
215
- endIdx = i;
216
- break;
217
- }
218
- }
219
-
220
- if (endIdx === -1) break;
221
-
222
- const stylesBlock = source.substring(braceStart + 1, endIdx);
223
-
224
- try {
225
- // Extract component definitions from the block
226
- const componentRegex = /(\w+):\s*\{/g;
227
- let componentMatch;
228
-
229
- while ((componentMatch = componentRegex.exec(stylesBlock)) !== null) {
230
- const componentKey = componentMatch[1];
231
- const componentStart = componentMatch.index + componentMatch[0].length;
232
-
233
- // Find matching closing brace for this component
234
- let compBraceCount = 0;
235
- let compEndIdx = -1;
236
- for (let i = componentStart - 1; i < stylesBlock.length; i++) {
237
- if (stylesBlock[i] === '{') compBraceCount++;
238
- if (stylesBlock[i] === '}') compBraceCount--;
239
- if (compBraceCount === 0) {
240
- compEndIdx = i;
241
- break;
242
- }
243
- }
244
-
245
- if (compEndIdx === -1) continue;
246
-
247
- const componentStyles = stylesBlock.substring(componentStart, compEndIdx);
248
- const rawObj = this.safeParseStyleObject(`{${componentStyles}}`);
249
-
250
- if (Object.keys(rawObj).length === 0) continue;
251
-
252
- // Expand shorthands
253
- const expandedObj: Record<string, any> = {};
254
- for (const [k, v] of Object.entries(rawObj)) {
255
- const realKey = shorthandMap[k] || k;
256
- expandedObj[realKey] = v;
257
- }
258
-
259
- await this.processStyleObject(expandedObj, componentKey);
260
- processedCount++;
261
- }
262
- } catch (parseError) {
263
- if (this.config.verbose) {
264
- console.warn(chalk.yellow(` ⚠️ Failed to parse styles in ${id}: ${parseError}`));
265
- }
266
- }
267
-
268
- searchFrom = endIdx + 1;
269
- }
270
199
 
271
200
  if (this.config.verbose && processedCount > 0) {
272
- console.log(chalk.gray(` 📝 Processed ${processedCount} styles from ${id}`));
201
+ console.log(` └─ Processed ${processedCount} chain() styles from ${id.split('/').pop()}`);
273
202
  }
274
203
  } catch (error) {
275
204
  console.error(chalk.red(` ❌ Error compiling source ${id}: ${error}`));
@@ -295,6 +295,13 @@ const setManifest = (manifest) => {
295
295
  // Compile the source
296
296
  await compiler.compileSource(source, id);
297
297
 
298
+ // Show what was found
299
+ const css = compiler.getCombinedCSS();
300
+ if (css && css.trim()) {
301
+ const ruleCount = (css.match(/\{/g) || []).length;
302
+ console.log(` └─ Extracted ${ruleCount} CSS rules from ${fileName}`);
303
+ }
304
+
298
305
  // Update stored data
299
306
  updateCSS();
300
307
  updateManifest();
@@ -372,6 +379,15 @@ const setManifest = (manifest) => {
372
379
 
373
380
  buildEnd() {
374
381
  const finalCSS = updateCSS();
382
+ const stats = compiler.getStats();
383
+
384
+ console.log('');
385
+ console.log('[ChainCSS] ✅ Build complete');
386
+ console.log(` 📦 Static CSS: ${finalCSS.length} bytes`);
387
+ console.log(` ⚡ Runtime JS: minimal (dynamic properties only)`);
388
+ console.log(` 🧩 Total styles: ${stats.totalStyles || 0} processed`);
389
+ console.log(` 💾 Atomic savings: ${stats.savings || '0%'}`);
390
+ console.log('');
375
391
  log(`Build complete - Final CSS: ${finalCSS.length} bytes`);
376
392
 
377
393
  // Write CSS to file if output specified