chaincss 2.0.6 → 2.1.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 (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 +454 -231
  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 +3649 -301
  59. package/dist/runtime/injector.d.ts +39 -71
  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 +724 -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 -270
  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 -232
@@ -0,0 +1,139 @@
1
+ // src/cli/utils/file-utils.ts
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { glob } from 'glob';
6
+
7
+ export interface FindOptions {
8
+ ignore?: string[];
9
+ absolute?: boolean;
10
+ }
11
+
12
+ export function findInputFiles(patterns: string[], options: FindOptions = {}): string[] {
13
+ const files: string[] = [];
14
+ const ignorePatterns = options.ignore || ['**/node_modules/**', '**/dist/**', '**/.chaincss-cache/**'];
15
+
16
+ for (const pattern of patterns) {
17
+ try {
18
+ const matches = glob.sync(pattern, {
19
+ ignore: ignorePatterns,
20
+ absolute: options.absolute || false
21
+ });
22
+ files.push(...matches);
23
+ } catch (error) {
24
+ console.warn(`[file-utils] Failed to glob pattern "${pattern}":`, (error as Error).message);
25
+ }
26
+ }
27
+
28
+ return [...new Set(files)]; // Remove duplicates
29
+ }
30
+
31
+ export function ensureDirectory(dir: string): void {
32
+ if (!fs.existsSync(dir)) {
33
+ try {
34
+ fs.mkdirSync(dir, { recursive: true });
35
+ } catch (error) {
36
+ throw new Error(`Failed to create directory "${dir}": ${(error as Error).message}`);
37
+ }
38
+ }
39
+ }
40
+
41
+ export function getRelativePath(filePath: string, baseDir: string): string {
42
+ return path.relative(baseDir, filePath);
43
+ }
44
+
45
+ export function getOutputPath(inputFile: string, outputDir: string, extension: string = ''): string {
46
+ const baseName = path.basename(inputFile, path.extname(inputFile));
47
+ const outExt = extension || path.extname(inputFile);
48
+ return path.join(outputDir, `${baseName}${outExt}`);
49
+ }
50
+
51
+ export function fileExists(filePath: string): boolean {
52
+ try {
53
+ return fs.existsSync(filePath);
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ export function readFile(filePath: string): string {
60
+ try {
61
+ return fs.readFileSync(filePath, 'utf8');
62
+ } catch (error) {
63
+ throw new Error(`Failed to read file "${filePath}": ${(error as Error).message}`);
64
+ }
65
+ }
66
+
67
+ export function writeFile(filePath: string, content: string): void {
68
+ try {
69
+ ensureDirectory(path.dirname(filePath));
70
+ fs.writeFileSync(filePath, content, 'utf8');
71
+ } catch (error) {
72
+ throw new Error(`Failed to write file "${filePath}": ${(error as Error).message}`);
73
+ }
74
+ }
75
+
76
+ export function deleteFile(filePath: string): void {
77
+ try {
78
+ if (fs.existsSync(filePath)) {
79
+ fs.unlinkSync(filePath);
80
+ }
81
+ } catch (error) {
82
+ console.warn(`[file-utils] Failed to delete file "${filePath}":`, (error as Error).message);
83
+ }
84
+ }
85
+
86
+ export function copyFile(source: string, destination: string): void {
87
+ try {
88
+ ensureDirectory(path.dirname(destination));
89
+ fs.copyFileSync(source, destination);
90
+ } catch (error) {
91
+ throw new Error(`Failed to copy file from "${source}" to "${destination}": ${(error as Error).message}`);
92
+ }
93
+ }
94
+
95
+ export function getFileSize(filePath: string): number {
96
+ try {
97
+ const stats = fs.statSync(filePath);
98
+ return stats.size;
99
+ } catch {
100
+ return 0;
101
+ }
102
+ }
103
+
104
+ export function getFileHash(filePath: string): string {
105
+ const crypto = require('crypto');
106
+ const content = readFile(filePath);
107
+ return crypto.createHash('md5').update(content).digest('hex').slice(0, 8);
108
+ }
109
+
110
+ export function isDirectory(dirPath: string): boolean {
111
+ try {
112
+ return fs.statSync(dirPath).isDirectory();
113
+ } catch {
114
+ return false;
115
+ }
116
+ }
117
+
118
+ export function ensureCleanDir(dir: string): void {
119
+ if (fs.existsSync(dir)) {
120
+ fs.rmSync(dir, { recursive: true, force: true });
121
+ }
122
+ ensureDirectory(dir);
123
+ }
124
+
125
+ export default {
126
+ findInputFiles,
127
+ ensureDirectory,
128
+ getRelativePath,
129
+ getOutputPath,
130
+ fileExists,
131
+ readFile,
132
+ writeFile,
133
+ deleteFile,
134
+ copyFile,
135
+ getFileSize,
136
+ getFileHash,
137
+ isDirectory,
138
+ ensureCleanDir
139
+ };
@@ -0,0 +1,74 @@
1
+ // chaincss/src/cli/utils/logger.ts
2
+
3
+ import chalk from 'chalk';
4
+
5
+ export type LogLevel = 'info' | 'success' | 'warn' | 'error' | 'debug';
6
+
7
+ export class Logger {
8
+ private verbose: boolean;
9
+
10
+ constructor(verbose: boolean = false) {
11
+ this.verbose = verbose;
12
+ }
13
+
14
+ info(message: string, ...args: any[]): void {
15
+ console.log(chalk.blue('ℹ'), message, ...args);
16
+ }
17
+
18
+ success(message: string, ...args: any[]): void {
19
+ console.log(chalk.green('✓'), message, ...args);
20
+ }
21
+
22
+ warn(message: string, ...args: any[]): void {
23
+ console.log(chalk.yellow('⚠'), message, ...args);
24
+ }
25
+
26
+ error(message: string, ...args: any[]): void {
27
+ console.log(chalk.red('✗'), message, ...args);
28
+ }
29
+
30
+ debug(message: string, ...args: any[]): void {
31
+ if (this.verbose) {
32
+ console.log(chalk.gray('🔍'), message, ...args);
33
+ }
34
+ }
35
+
36
+ step(message: string, ...args: any[]): void {
37
+ console.log(chalk.cyan('→'), message, ...args);
38
+ }
39
+
40
+ header(message: string): void {
41
+ console.log();
42
+ console.log(chalk.bold.cyan(message));
43
+ console.log(chalk.gray('─'.repeat(message.length)));
44
+ }
45
+
46
+ divider(): void {
47
+ console.log(chalk.gray('─'.repeat(50)));
48
+ }
49
+
50
+ table(data: Record<string, any>): void {
51
+ const maxKeyLength = Math.max(...Object.keys(data).map(k => k.length));
52
+
53
+ for (const [key, value] of Object.entries(data)) {
54
+ const paddedKey = key.padEnd(maxKeyLength);
55
+ console.log(` ${chalk.cyan(paddedKey)}: ${value}`);
56
+ }
57
+ }
58
+
59
+ progress(current: number, total: number, message: string): void {
60
+ const percent = Math.round((current / total) * 100);
61
+ const barLength = 30;
62
+ const filledLength = Math.round((barLength * current) / total);
63
+ const bar = '█'.repeat(filledLength) + '░'.repeat(barLength - filledLength);
64
+
65
+ process.stdout.write(`\r ${bar} ${percent}% ${message}`);
66
+ if (current === total) {
67
+ process.stdout.write('\n');
68
+ }
69
+ }
70
+ }
71
+
72
+ export function createLogger(verbose: boolean = false): Logger {
73
+ return new Logger(verbose);
74
+ }