chaincss 2.1.21 → 2.1.23

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/index.js CHANGED
@@ -3353,16 +3353,8 @@ var compileRuntime = (s, moduleId) => styleInjector.injectMultiple(s, moduleId);
3353
3353
  // src/runtime/index.ts
3354
3354
  function injectChainStyles(styles) {
3355
3355
  let css = "";
3356
- let staticCount = 0, dynamicCount = 0, hybridCount = 0;
3357
3356
  for (const [key, obj] of Object.entries(styles)) {
3358
3357
  if (!obj || !obj.selectors) continue;
3359
- if (obj.__isHybrid) {
3360
- hybridCount++;
3361
- } else if (obj.__runtimeClasses && Object.keys(obj.__runtimeClasses).length > 0) {
3362
- dynamicCount++;
3363
- } else {
3364
- staticCount++;
3365
- }
3366
3358
  const sel = "." + obj.selectors[0];
3367
3359
  css += sel + "{";
3368
3360
  for (const [k, v] of Object.entries(obj)) {
@@ -3387,7 +3379,7 @@ function injectChainStyles(styles) {
3387
3379
  el.setAttribute("data-chaincss", "runtime");
3388
3380
  el.textContent = css;
3389
3381
  document.head.appendChild(el);
3390
- console.log("\u26D3\uFE0F ChainCSS Split: \u{1F4E6} Static=" + staticCount + " \u26A1 Dynamic=" + dynamicCount + " \u{1F500} Hybrid=" + hybridCount + " | CSS: " + css.length + " bytes");
3382
+ console.log("\u26D3\uFE0F ChainCSS \u2014 " + Object.keys(styles).length + " styles injected | CSS: " + css.length + " bytes | smartChain auto-detect active");
3391
3383
  return el;
3392
3384
  }
3393
3385
 
@@ -3435,6 +3435,23 @@ const setManifest = (manifest) => {
3435
3435
  }
3436
3436
  console.log(` \u2514\u2500 Found ${total} chain calls (${chainMatches?.length || 0} static, ${smartMatches?.length || 0} hybrid)`);
3437
3437
  }
3438
+ if (id.endsWith(".chain.ts") || id.endsWith(".chain.js")) {
3439
+ try {
3440
+ const results = await compiler.compileFile(id);
3441
+ let css2 = "";
3442
+ for (const r of Object.values(results)) {
3443
+ if (r.css) css2 += r.css + "\n";
3444
+ }
3445
+ if (css2.trim()) {
3446
+ generatedCSS += css2;
3447
+ totalCSSBytes += css2.length;
3448
+ if (options.verbose) {
3449
+ console.log(` \u2514\u2500 Extracted ${css2.length} bytes of CSS`);
3450
+ }
3451
+ }
3452
+ } catch (e) {
3453
+ }
3454
+ }
3438
3455
  await compiler.compileSource(source, id);
3439
3456
  const css = compiler.getCombinedCSS();
3440
3457
  if (css && css.trim()) {
@@ -3506,7 +3523,13 @@ ${source}`,
3506
3523
  hybridCount = 0;
3507
3524
  totalCSSBytes = 0;
3508
3525
  },
3509
- buildEnd() {
3526
+ async buildEnd() {
3527
+ if (generatedCSS.trim() && options.cssOutput) {
3528
+ const fs8 = await import("fs");
3529
+ const outputPath = path6.resolve(process.cwd(), options.cssOutput);
3530
+ fs8.writeFileSync(outputPath, generatedCSS, "utf8");
3531
+ console.log(` \u{1F4C1} CSS written to ${options.cssOutput} (${generatedCSS.length} bytes)`);
3532
+ }
3510
3533
  const finalCSS = updateCSS();
3511
3534
  const stats = compiler.getStats();
3512
3535
  console.log("");
@@ -3909,16 +3909,8 @@ var injectStyleContextSvelte = (...args) => getSvelteExports().injectStyleContex
3909
3909
  var chainStyles2 = (...args) => getSvelteExports().chainStyles?.(...args);
3910
3910
  function injectChainStyles(styles3) {
3911
3911
  let css = "";
3912
- let staticCount = 0, dynamicCount = 0, hybridCount = 0;
3913
3912
  for (const [key, obj] of Object.entries(styles3)) {
3914
3913
  if (!obj || !obj.selectors) continue;
3915
- if (obj.__isHybrid) {
3916
- hybridCount++;
3917
- } else if (obj.__runtimeClasses && Object.keys(obj.__runtimeClasses).length > 0) {
3918
- dynamicCount++;
3919
- } else {
3920
- staticCount++;
3921
- }
3922
3914
  const sel = "." + obj.selectors[0];
3923
3915
  css += sel + "{";
3924
3916
  for (const [k, v] of Object.entries(obj)) {
@@ -3943,7 +3935,7 @@ function injectChainStyles(styles3) {
3943
3935
  el.setAttribute("data-chaincss", "runtime");
3944
3936
  el.textContent = css;
3945
3937
  document.head.appendChild(el);
3946
- console.log("\u26D3\uFE0F ChainCSS Split: \u{1F4E6} Static=" + staticCount + " \u26A1 Dynamic=" + dynamicCount + " \u{1F500} Hybrid=" + hybridCount + " | CSS: " + css.length + " bytes");
3938
+ console.log("\u26D3\uFE0F ChainCSS \u2014 " + Object.keys(styles3).length + " styles injected | CSS: " + css.length + " bytes | smartChain auto-detect active");
3947
3939
  return el;
3948
3940
  }
3949
3941
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaincss",
3
- "version": "2.1.21",
3
+ "version": "2.1.23",
4
4
  "description": "ChainCSS - 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",
@@ -317,7 +317,27 @@ const setManifest = (manifest) => {
317
317
  console.log(` └─ Found ${total} chain calls (${chainMatches?.length || 0} static, ${smartMatches?.length || 0} hybrid)`);
318
318
  }
319
319
 
320
- // Compile the source
320
+ // Compile .chain.ts files to CSS
321
+ if (id.endsWith('.chain.ts') || id.endsWith('.chain.js')) {
322
+ try {
323
+ const results = await compiler.compileFile(id);
324
+ let css = '';
325
+ for (const r of Object.values(results)) {
326
+ if (r.css) css += r.css + '\n';
327
+ }
328
+ if (css.trim()) {
329
+ generatedCSS += css;
330
+ totalCSSBytes += css.length;
331
+ if (options.verbose) {
332
+ console.log(` └─ Extracted ${css.length} bytes of CSS`);
333
+ }
334
+ }
335
+ } catch (e) {
336
+ // Not a compilable chain file
337
+ }
338
+ }
339
+
340
+ // Also detect chain() calls in JSX/TSX for stats
321
341
  await compiler.compileSource(source, id);
322
342
 
323
343
  // Show what was found
@@ -416,7 +436,15 @@ const setManifest = (manifest) => {
416
436
  totalCSSBytes = 0;
417
437
  },
418
438
 
419
- buildEnd() {
439
+ async buildEnd() {
440
+ // Write CSS to file if we have any
441
+ if (generatedCSS.trim() && options.cssOutput) {
442
+ const fs = await import('fs');
443
+ const outputPath = path.resolve(process.cwd(), options.cssOutput);
444
+ fs.writeFileSync(outputPath, generatedCSS, 'utf8');
445
+ console.log(` 📁 CSS written to ${options.cssOutput} (${generatedCSS.length} bytes)`);
446
+ }
447
+
420
448
  const finalCSS = updateCSS();
421
449
  const stats = compiler.getStats();
422
450
 
@@ -92,20 +92,10 @@ export type {
92
92
  // Auto-inject styles into DOM
93
93
  export function injectChainStyles(styles: Record<string, any>) {
94
94
  let css = '';
95
- let staticCount = 0, dynamicCount = 0, hybridCount = 0;
96
-
95
+
97
96
  for (const [key, obj] of Object.entries(styles)) {
98
97
  if (!obj || !obj.selectors) continue;
99
98
 
100
- // Use smartChain's built-in detection
101
- if (obj.__isHybrid) {
102
- hybridCount++;
103
- } else if (obj.__runtimeClasses && Object.keys(obj.__runtimeClasses).length > 0) {
104
- dynamicCount++;
105
- } else {
106
- staticCount++;
107
- }
108
-
109
99
  const sel = '.' + obj.selectors[0];
110
100
  css += sel + '{';
111
101
  for (const [k, v] of Object.entries(obj)) {
@@ -132,7 +122,7 @@ export function injectChainStyles(styles: Record<string, any>) {
132
122
  document.head.appendChild(el);
133
123
 
134
124
  // Show split stats in console
135
- console.log('⛓️ ChainCSS Split: 📦 Static=' + staticCount + ' Dynamic=' + dynamicCount + ' 🔀 Hybrid=' + hybridCount + ' | CSS: ' + css.length + ' bytes');
125
+ console.log('⛓️ ChainCSS ' + Object.keys(styles).length + ' styles injected | CSS: ' + css.length + ' bytes | smartChain auto-detect active');
136
126
 
137
127
  return el;
138
128
  }