chaincss 1.13.2 → 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 +239 -114
  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 -109
  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 -370
  85. package/node/atomic-optimizer.js +0 -391
  86. package/node/btt.js +0 -962
  87. package/node/cache-manager.js +0 -56
  88. package/node/chaincss.js +0 -489
  89. package/node/css-properties.json +0 -633
  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 -106
  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 -277
package/browser/rtt.js DELETED
@@ -1,370 +0,0 @@
1
- import { tokens, createTokens, responsive } from '../shared/tokens.mjs';
2
-
3
- let cachedProperties = null;
4
-
5
- const loadCSSProperties = async () => {
6
- // Return cached if already loaded
7
- if (cachedProperties !== null) {
8
- return cachedProperties;
9
- }
10
- // Try CDN first (only once)
11
- try {
12
- const controller = new AbortController();
13
- const timeoutId = setTimeout(() => controller.abort(), 3000); // 3 second timeout
14
-
15
- const response = await fetch('https://raw.githubusercontent.com/mdn/data/main/css/properties.json', {
16
- signal: controller.signal
17
- });
18
- clearTimeout(timeoutId);
19
-
20
- if (response.ok) {
21
- const data = await response.json();
22
- const allProperties = Object.keys(data);
23
- const baseProperties = new Set();
24
-
25
- allProperties.forEach(prop => {
26
- const baseProp = prop.replace(/^-(webkit|moz|ms|o)-/, '');
27
- baseProperties.add(baseProp);
28
- });
29
-
30
- cachedProperties = Array.from(baseProperties).sort();
31
- console.log(`✅ Loaded ${cachedProperties.length} CSS properties from CDN`);
32
- return cachedProperties;
33
- }
34
- } catch (error) {
35
- console.log('CDN failed, using fallback CSS property list');
36
- // Use hardcoded fallback (always works)
37
- const { COMMON_CSS_PROPERTIES } = await import('./commonProps.js');
38
- cachedProperties = COMMON_CSS_PROPERTIES;
39
- return cachedProperties;
40
- }
41
- };
42
-
43
- const chain = {
44
- cssOutput: undefined,
45
- catcher: {},
46
- cachedValidProperties: [],
47
- async initializeProperties() {
48
- if (this.cachedValidProperties.length > 0) {
49
- return;
50
- }
51
-
52
- const properties = await loadCSSProperties();
53
- this.cachedValidProperties = properties;
54
- },
55
- getCachedProperties() {
56
- return this.cachedValidProperties;
57
- }
58
- };
59
-
60
- // Start initialization (non-blocking)
61
- chain.initializeProperties().catch(err => {
62
- console.error('Failed to load CSS properties:', err.message);
63
- });
64
-
65
- const resolveToken = (value, useTokens) => {
66
- if (!useTokens || typeof value !== 'string' || !value.startsWith('$')) {
67
- return value;
68
- }
69
- const tokenPath = value.slice(1);
70
- const tokenValue = tokens.get(tokenPath);
71
- if (!tokenValue) {
72
- return value;
73
- }
74
- return tokenValue;
75
- };
76
-
77
- function $(useTokens = true) {
78
- const catcher = {};
79
- const validProperties = chain.cachedValidProperties;
80
-
81
- const handler = {
82
- get: (target, prop) => {
83
- if (prop === 'block') {
84
- return function(...args) {
85
- if (args.length === 0) {
86
- const result = { ...catcher };
87
- Object.keys(catcher).forEach(key => delete catcher[key]);
88
- return result;
89
- }
90
- const result = {
91
- selectors: args,
92
- ...catcher
93
- };
94
- Object.keys(catcher).forEach(key => delete catcher[key]);
95
- return result;
96
- };
97
- }
98
-
99
- if (prop === 'hover') {
100
- return () => {
101
- const hoverCatcher = {};
102
- const hoverHandler = {
103
- get: (hoverTarget, hoverProp) => {
104
- if (hoverProp === 'end') {
105
- return () => {
106
- catcher.hover = { ...hoverCatcher };
107
- Object.keys(hoverCatcher).forEach(key => delete hoverCatcher[key]);
108
- return proxy;
109
- };
110
- }
111
- const cssProperty = hoverProp.replace(/([A-Z])/g, '-$1').toLowerCase();
112
- if (validProperties && validProperties.length > 0 && !validProperties.includes(cssProperty)) {
113
- console.warn(`Warning: '${cssProperty}' may not be a valid CSS property`);
114
- }
115
- return (value) => {
116
- hoverCatcher[hoverProp] = resolveToken(value, useTokens);
117
- return hoverProxy;
118
- };
119
- }
120
- };
121
- const hoverProxy = new Proxy({}, hoverHandler);
122
- return hoverProxy;
123
- };
124
- }
125
-
126
- if (prop === 'end') {
127
- return () => {
128
- return proxy;
129
- };
130
- }
131
-
132
- if (prop === 'select') {
133
- return function(selector) {
134
- const props = {};
135
- const selectorProxy = new Proxy({}, {
136
- get: (target, methodProp) => {
137
- if (methodProp === 'block') {
138
- return function() {
139
- return {
140
- selectors: [selector],
141
- ...props
142
- };
143
- };
144
- }
145
- return function(value) {
146
- props[methodProp] = resolveToken(value, useTokens);
147
- return selectorProxy;
148
- };
149
- }
150
- });
151
- return selectorProxy;
152
- };
153
- }
154
-
155
- // At-Rules
156
- if (prop === 'media') {
157
- return function(query, callback) {
158
- const subChain = $(useTokens);
159
- const result = callback(subChain);
160
- if (!catcher.atRules) catcher.atRules = [];
161
- catcher.atRules.push({
162
- type: 'media',
163
- query: query,
164
- styles: result
165
- });
166
- return proxy;
167
- };
168
- }
169
-
170
- if (prop === 'keyframes') {
171
- return function(name, callback) {
172
- const keyframeContext = { _keyframeSteps: {} };
173
- const keyframeProxy = new Proxy(keyframeContext, {
174
- get: (target, stepProp) => {
175
- if (stepProp === 'from' || stepProp === 'to') {
176
- return function(stepCallback) {
177
- const subChain = $(useTokens);
178
- const properties = stepCallback(subChain).block();
179
- target._keyframeSteps[stepProp] = properties;
180
- return keyframeProxy;
181
- };
182
- }
183
- if (stepProp === 'percent') {
184
- return function(value, stepCallback) {
185
- const subChain = $(useTokens);
186
- const properties = stepCallback(subChain).block();
187
- target._keyframeSteps[`${value}%`] = properties;
188
- return keyframeProxy;
189
- };
190
- }
191
- return undefined;
192
- }
193
- });
194
- callback(keyframeProxy);
195
- if (!catcher.atRules) catcher.atRules = [];
196
- catcher.atRules.push({
197
- type: 'keyframes',
198
- name: name,
199
- steps: keyframeContext._keyframeSteps
200
- });
201
- return proxy;
202
- };
203
- }
204
-
205
- if (prop === 'fontFace') {
206
- return function(callback) {
207
- const subChain = $(useTokens);
208
- const fontProps = callback(subChain).block();
209
- if (!catcher.atRules) catcher.atRules = [];
210
- catcher.atRules.push({
211
- type: 'font-face',
212
- properties: fontProps
213
- });
214
- return proxy;
215
- };
216
- }
217
-
218
- if (prop === 'supports') {
219
- return function(condition, callback) {
220
- const subChain = $(useTokens);
221
- const styles = callback(subChain);
222
- if (!catcher.atRules) catcher.atRules = [];
223
- catcher.atRules.push({
224
- type: 'supports',
225
- condition: condition,
226
- styles: styles
227
- });
228
- return proxy;
229
- };
230
- }
231
-
232
- if (prop === 'container') {
233
- return function(condition, callback) {
234
- const subChain = $(useTokens);
235
- const styles = callback(subChain);
236
- if (!catcher.atRules) catcher.atRules = [];
237
- catcher.atRules.push({
238
- type: 'container',
239
- condition: condition,
240
- styles: styles
241
- });
242
- return proxy;
243
- };
244
- }
245
-
246
- if (prop === 'layer') {
247
- return function(name, callback) {
248
- const subChain = $(useTokens);
249
- const styles = callback(subChain);
250
- if (!catcher.atRules) catcher.atRules = [];
251
- catcher.atRules.push({
252
- type: 'layer',
253
- name: name,
254
- styles: styles
255
- });
256
- return proxy;
257
- };
258
- }
259
-
260
- if (prop === 'counterStyle') {
261
- return function(name, callback) {
262
- const subChain = $(useTokens);
263
- const properties = callback(subChain).block();
264
- if (!catcher.atRules) catcher.atRules = [];
265
- catcher.atRules.push({
266
- type: 'counter-style',
267
- name: name,
268
- properties: properties
269
- });
270
- return proxy;
271
- };
272
- }
273
-
274
- if (prop === 'property') {
275
- return function(name, callback) {
276
- const subChain = $(useTokens);
277
- const descriptors = callback(subChain).block();
278
- if (!catcher.atRules) catcher.atRules = [];
279
- catcher.atRules.push({
280
- type: 'property',
281
- name: name,
282
- descriptors: descriptors
283
- });
284
- return proxy;
285
- };
286
- }
287
-
288
- const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
289
- if (validProperties && validProperties.length > 0 && !validProperties.includes(cssProperty)) {
290
- console.warn(`Warning: '${cssProperty}' may not be a valid CSS property`);
291
- }
292
-
293
- return function(value) {
294
- catcher[prop] = resolveToken(value, useTokens);
295
- return proxy;
296
- };
297
- }
298
- };
299
-
300
- const proxy = new Proxy({}, handler);
301
- return proxy;
302
- }
303
-
304
- const run = (...args) => {
305
- let cssOutput = '';
306
- args.forEach((value) => {
307
- if (value && value.selectors) {
308
- let rule = `${value.selectors.join(', ')} {\n`;
309
- for (let key in value) {
310
- if (key !== 'selectors' && value.hasOwnProperty(key)) {
311
- const kebabKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
312
- rule += ` ${kebabKey}: ${value[key]};\n`;
313
- }
314
- }
315
- rule += `}\n\n`;
316
- cssOutput += rule;
317
- }
318
- });
319
- chain.cssOutput = cssOutput.trim();
320
- return cssOutput.trim();
321
- };
322
-
323
- const compile = (obj) => {
324
- let cssString = '';
325
- for (const key in obj) {
326
- if (obj.hasOwnProperty(key)) {
327
- const element = obj[key];
328
- let selectors = element.selectors || [];
329
-
330
- // Generate normal styles
331
- let normalCSS = '';
332
- for (let prop in element) {
333
- if (element.hasOwnProperty(prop) && prop !== 'selectors' && prop !== 'hover') {
334
- const kebabKey = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
335
- normalCSS += ` ${kebabKey}: ${element[prop]};\n`;
336
- }
337
- }
338
- if (normalCSS) {
339
- cssString += `${selectors.join(', ')} {\n${normalCSS}}\n`;
340
- }
341
-
342
- // Generate hover styles
343
- if (element.hover && typeof element.hover === 'object') {
344
- let hoverCSS = '';
345
- for (let prop in element.hover) {
346
- if (element.hover.hasOwnProperty(prop) && prop !== 'selectors') {
347
- const kebabKey = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
348
- hoverCSS += ` ${kebabKey}: ${element.hover[prop]};\n`;
349
- }
350
- }
351
- if (hoverCSS) {
352
- const hoverSelectors = selectors.map(s => `${s}:hover`);
353
- cssString += `${hoverSelectors.join(', ')} {\n${hoverCSS}}\n`;
354
- }
355
- }
356
- }
357
- }
358
- chain.cssOutput = cssString.trim();
359
- return cssString.trim();
360
- };
361
-
362
- export {
363
- chain,
364
- $,
365
- run,
366
- compile,
367
- tokens,
368
- createTokens,
369
- responsive
370
- };