chaincss 1.13.3 → 2.0.0

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 (101) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/LICENSE +2 -3
  3. package/README.md +238 -105
  4. package/dist/cli/commands/build.d.ts +3 -0
  5. package/dist/cli/commands/build.d.ts.map +1 -0
  6. package/dist/cli/commands/compile.d.ts +3 -0
  7. package/dist/cli/commands/compile.d.ts.map +1 -0
  8. package/dist/cli/commands/init.d.ts +5 -0
  9. package/dist/cli/commands/init.d.ts.map +1 -0
  10. package/dist/cli/commands/timeline.d.ts +2 -0
  11. package/dist/cli/commands/timeline.d.ts.map +1 -0
  12. package/dist/cli/commands/watch.d.ts +6 -0
  13. package/dist/cli/commands/watch.d.ts.map +1 -0
  14. package/dist/cli/index.d.ts +2 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +5960 -0
  17. package/dist/cli/types.d.ts +51 -0
  18. package/dist/cli/types.d.ts.map +1 -0
  19. package/dist/cli/utils/config-loader.d.ts +8 -0
  20. package/dist/cli/utils/config-loader.d.ts.map +1 -0
  21. package/dist/cli/utils/file-utils.d.ts +9 -0
  22. package/dist/cli/utils/file-utils.d.ts.map +1 -0
  23. package/dist/cli/utils/logger.d.ts +17 -0
  24. package/dist/cli/utils/logger.d.ts.map +1 -0
  25. package/dist/compiler/atomic-optimizer.d.ts +76 -0
  26. package/dist/compiler/atomic-optimizer.d.ts.map +1 -0
  27. package/dist/compiler/btt.d.ts +138 -0
  28. package/dist/compiler/btt.d.ts.map +1 -0
  29. package/dist/compiler/cache-manager.d.ts +20 -0
  30. package/dist/compiler/cache-manager.d.ts.map +1 -0
  31. package/dist/compiler/commonProps.d.ts +2 -0
  32. package/dist/compiler/commonProps.d.ts.map +1 -0
  33. package/dist/compiler/index.d.ts +12 -0
  34. package/dist/compiler/index.d.ts.map +1 -0
  35. package/dist/compiler/index.js +5177 -0
  36. package/dist/compiler/prefixer.d.ts +42 -0
  37. package/dist/compiler/prefixer.d.ts.map +1 -0
  38. package/dist/compiler/theme-contract.d.ts +61 -0
  39. package/dist/compiler/theme-contract.d.ts.map +1 -0
  40. package/dist/compiler/tokens.d.ts +52 -0
  41. package/dist/compiler/tokens.d.ts.map +1 -0
  42. package/dist/compiler/types.d.ts +57 -0
  43. package/dist/compiler/types.d.ts.map +1 -0
  44. package/dist/core/compiler.d.ts +32 -0
  45. package/dist/core/compiler.d.ts.map +1 -0
  46. package/dist/core/constants.d.ts +129 -0
  47. package/dist/core/constants.d.ts.map +1 -0
  48. package/dist/core/index.d.ts +4 -0
  49. package/dist/core/index.d.ts.map +1 -0
  50. package/dist/core/types.d.ts +88 -0
  51. package/dist/core/types.d.ts.map +1 -0
  52. package/dist/core/utils.d.ts +37 -0
  53. package/dist/core/utils.d.ts.map +1 -0
  54. package/dist/index.d.ts +13 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +5667 -0
  57. package/dist/plugins/vite.d.ts +11 -0
  58. package/dist/plugins/vite.d.ts.map +1 -0
  59. package/dist/plugins/vite.js +25839 -0
  60. package/dist/plugins/webpack.d.ts +45 -0
  61. package/dist/plugins/webpack.d.ts.map +1 -0
  62. package/dist/plugins/webpack.js +107 -0
  63. package/dist/runtime/hmr.d.ts +3 -0
  64. package/dist/runtime/hmr.d.ts.map +1 -0
  65. package/dist/runtime/index.d.ts +15 -0
  66. package/dist/runtime/index.d.ts.map +1 -0
  67. package/dist/runtime/index.js +552 -0
  68. package/dist/runtime/injector.d.ts +85 -0
  69. package/dist/runtime/injector.d.ts.map +1 -0
  70. package/dist/runtime/react.d.ts +54 -0
  71. package/dist/runtime/react.d.ts.map +1 -0
  72. package/dist/runtime/react.js +270 -0
  73. package/dist/runtime/types.d.ts +45 -0
  74. package/dist/runtime/types.d.ts.map +1 -0
  75. package/dist/runtime/utils.d.ts +62 -0
  76. package/dist/runtime/utils.d.ts.map +1 -0
  77. package/dist/runtime/vue.d.ts +52 -0
  78. package/dist/runtime/vue.d.ts.map +1 -0
  79. package/dist/runtime/vue.js +232 -0
  80. package/package.json +90 -119
  81. package/browser/commonProps.js +0 -14
  82. package/browser/index.js +0 -3
  83. package/browser/react-hooks.js +0 -162
  84. package/browser/rtt.js +0 -400
  85. package/browser/vue-composables.js +0 -200
  86. package/node/atomic-optimizer.js +0 -526
  87. package/node/btt.js +0 -1009
  88. package/node/cache-manager.js +0 -56
  89. package/node/chaincss.js +0 -642
  90. package/node/index.js +0 -2
  91. package/node/loaders/chaincss-loader.js +0 -62
  92. package/node/plugins/next-plugin.js +0 -120
  93. package/node/plugins/vite-plugin.js +0 -383
  94. package/node/plugins/webpack-plugin.js +0 -41
  95. package/node/prefixer.js +0 -237
  96. package/node/strVal.js +0 -92
  97. package/node/theme-validator.js +0 -32
  98. package/shared/theme-contract.js +0 -98
  99. package/shared/tokens.cjs +0 -256
  100. package/shared/tokens.mjs +0 -320
  101. package/types.d.ts +0 -325
@@ -0,0 +1,45 @@
1
+ export interface ChainCSSLoaderOptions {
2
+ /**
3
+ * Mode: 'build' for production (zero-runtime), 'runtime' for development
4
+ * @default process.env.NODE_ENV === 'production' ? 'build' : 'runtime'
5
+ */
6
+ mode?: 'build' | 'runtime';
7
+ /**
8
+ * Enable atomic CSS optimization
9
+ * @default false
10
+ */
11
+ atomic?: boolean;
12
+ /**
13
+ * Enable CSS minification
14
+ * @default process.env.NODE_ENV === 'production'
15
+ */
16
+ minify?: boolean;
17
+ /**
18
+ * Enable source maps
19
+ * @default false
20
+ */
21
+ sourceMap?: boolean;
22
+ /**
23
+ * Output directory for compiled CSS
24
+ * @default '.chaincss-cache'
25
+ */
26
+ outputDir?: string;
27
+ /**
28
+ * Verbose logging
29
+ * @default false
30
+ */
31
+ verbose?: boolean;
32
+ }
33
+ interface LoaderContext {
34
+ async: () => (err: Error | null, code?: string) => void;
35
+ getOptions: () => ChainCSSLoaderOptions;
36
+ resourcePath: string;
37
+ context: string;
38
+ }
39
+ /**
40
+ * Webpack loader for ChainCSS
41
+ * Converts .chain.js / .chain.ts files to static CSS at build time
42
+ */
43
+ export default function chaincssLoader(this: LoaderContext, source: string): void;
44
+ export {};
45
+ //# sourceMappingURL=webpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/plugins/webpack.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,UAAU,EAAE,MAAM,qBAAqB,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAqHhF"}
@@ -0,0 +1,107 @@
1
+ // src/plugins/webpack.ts
2
+ import path from "path";
3
+ import { execSync } from "child_process";
4
+ import fs from "fs";
5
+ import { fileURLToPath } from "url";
6
+ var __filename = fileURLToPath(import.meta.url);
7
+ 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}`);
15
+ }
16
+ const styleNames = extractStyleNames(source);
17
+ const code = `
18
+ import { $, compile } from 'chaincss/runtime';
19
+ const styles = (() => {
20
+ ${source}
21
+ return { ${styleNames} };
22
+ })();
23
+ export default styles;
24
+ `;
25
+ callback(null, code);
26
+ return;
27
+ }
28
+ 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 });
36
+ }
37
+ fs.writeFileSync(tempFile, source, "utf8");
38
+ if (!fs.existsSync(outputDir)) {
39
+ fs.mkdirSync(outputDir, { recursive: true });
40
+ }
41
+ const chaincssCli = path.join(__dirname, "../cli/index.js");
42
+ let cmd = `node ${chaincssCli} compile "${tempFile}" "${outputDir}"`;
43
+ if (options.atomic) {
44
+ cmd += " --atomic";
45
+ }
46
+ if (options.minify) {
47
+ cmd += " --minify";
48
+ }
49
+ if (options.sourceMap) {
50
+ cmd += " --source-map";
51
+ }
52
+ if (options.verbose) {
53
+ console.log(`[chaincss-loader] Executing: ${cmd}`);
54
+ }
55
+ execSync(cmd, { stdio: options.verbose ? "inherit" : "pipe" });
56
+ const baseName = path.basename(this.resourcePath, path.extname(this.resourcePath));
57
+ const cssPath = path.join(outputDir, `${baseName}.css`);
58
+ const jsPath = path.join(outputDir, `${baseName}.js`);
59
+ let css = "";
60
+ if (fs.existsSync(cssPath)) {
61
+ css = fs.readFileSync(cssPath, "utf8");
62
+ }
63
+ let classExports = "";
64
+ if (fs.existsSync(jsPath)) {
65
+ classExports = fs.readFileSync(jsPath, "utf8");
66
+ }
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;
85
+ }
86
+
87
+ export default { ${extractStyleNames(source)} };
88
+ `;
89
+ callback(null, code);
90
+ } catch (err) {
91
+ console.error(`[chaincss-loader] Error compiling ${this.resourcePath}:`, err.message);
92
+ 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(", ");
104
+ }
105
+ export {
106
+ chaincssLoader as default
107
+ };
@@ -0,0 +1,3 @@
1
+ export declare function setupHMR(): void;
2
+ export declare function registerForHMR(moduleId: string, styles: Record<string, any>): void;
3
+ //# sourceMappingURL=hmr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../../src/runtime/hmr.ts"],"names":[],"mappings":"AASA,wBAAgB,QAAQ,SAUvB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAS3E"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * ChainCSS Runtime Module
3
+ *
4
+ * WARNING: Importing from this module adds ~3.2KB to your bundle.
5
+ * For production, use build-time compilation with chaincss/plugin/vite instead.
6
+ */
7
+ export { chainRuntime as $, compileRuntime as compile, runRuntime as run, styleInjector } from './injector.js';
8
+ export { useChainStyles, useDynamicChainStyles, useThemeChainStyles, ChainCSSGlobal, cx, withChainStyles, enableChainCSSDebug, disableChainCSSDebug, isDebugEnabled, createStyledComponent, useComputedStyles } from './react.js';
9
+ export { useAtomicClasses, ChainCSSGlobal as ChainCSSGlobalVue, createStyledComponent as createStyledVueComponent, // This is fine - it renames
10
+ createStyledComponents as createStyledVueComponents, useComputedStyles as useComputedStylesVue, // This renames useComputedStyles
11
+ provideStyleContext, injectStyleContext } from './vue.js';
12
+ export { setupHMR, registerForHMR } from './hmr.js';
13
+ export { generateStyleId, hashString, kebabCase, isBrowser, isDevelopment, isProduction, debounce, memoize, cn as cnUtils, devWarn, devLog, logError, createDebugger } from './utils.js';
14
+ export type { RuntimeStyleDefinition, UseChainStylesOptions, RuntimeCompiledResult, StyleInjector, UseAtomicClassesReturn, HMRPayload, ChainCSSDebugger } from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,IAAI,CAAC,EAAE,cAAc,IAAI,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG/G,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,EAAE,EACF,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,cAAc,IAAI,iBAAiB,EACnC,qBAAqB,IAAI,wBAAwB,EAAG,4BAA4B;AAChF,sBAAsB,IAAI,yBAAyB,EACnD,iBAAiB,IAAI,oBAAoB,EAAG,iCAAiC;AAC7E,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,EAAE,IAAI,OAAO,EACb,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC"}