@cwcss/crosswind 0.1.5 → 0.2.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 (87) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +52 -0
  3. package/dist/bin/cli.js +14615 -0
  4. package/dist/build.d.ts +24 -0
  5. package/dist/config.d.ts +5 -0
  6. package/dist/generator.d.ts +31 -0
  7. package/dist/index.d.ts +10 -0
  8. package/dist/parser.d.ts +42 -0
  9. package/dist/plugin.d.ts +22 -0
  10. package/dist/preflight-forms.d.ts +5 -0
  11. package/dist/preflight.d.ts +2 -0
  12. package/dist/rules-advanced.d.ts +27 -0
  13. package/dist/rules-effects.d.ts +25 -0
  14. package/dist/rules-forms.d.ts +7 -0
  15. package/dist/rules-grid.d.ts +13 -0
  16. package/dist/rules-interactivity.d.ts +41 -0
  17. package/dist/rules-layout.d.ts +26 -0
  18. package/dist/rules-transforms.d.ts +33 -0
  19. package/dist/rules-typography.d.ts +41 -0
  20. package/dist/rules.d.ts +39 -0
  21. package/dist/scanner.d.ts +18 -0
  22. package/dist/src/index.js +12848 -0
  23. package/dist/transformer-compile-class.d.ts +37 -0
  24. package/{src/types.ts → dist/types.d.ts} +17 -86
  25. package/package.json +2 -16
  26. package/PLUGIN.md +0 -235
  27. package/benchmark/framework-comparison.bench.ts +0 -850
  28. package/bin/cli.ts +0 -365
  29. package/bin/crosswind +0 -0
  30. package/bin/headwind +0 -0
  31. package/build.ts +0 -8
  32. package/crosswind.config.ts +0 -9
  33. package/example/comprehensive.html +0 -70
  34. package/example/index.html +0 -21
  35. package/example/output.css +0 -236
  36. package/examples/plugin/README.md +0 -112
  37. package/examples/plugin/build.ts +0 -32
  38. package/examples/plugin/src/index.html +0 -34
  39. package/examples/plugin/src/index.ts +0 -7
  40. package/headwind +0 -2
  41. package/src/build.ts +0 -101
  42. package/src/config.ts +0 -529
  43. package/src/generator.ts +0 -2173
  44. package/src/index.ts +0 -10
  45. package/src/parser.ts +0 -1471
  46. package/src/plugin.ts +0 -118
  47. package/src/preflight-forms.ts +0 -229
  48. package/src/preflight.ts +0 -388
  49. package/src/rules-advanced.ts +0 -477
  50. package/src/rules-effects.ts +0 -461
  51. package/src/rules-forms.ts +0 -103
  52. package/src/rules-grid.ts +0 -241
  53. package/src/rules-interactivity.ts +0 -525
  54. package/src/rules-layout.ts +0 -385
  55. package/src/rules-transforms.ts +0 -412
  56. package/src/rules-typography.ts +0 -486
  57. package/src/rules.ts +0 -809
  58. package/src/scanner.ts +0 -84
  59. package/src/transformer-compile-class.ts +0 -275
  60. package/test/advanced-features.test.ts +0 -911
  61. package/test/arbitrary.test.ts +0 -396
  62. package/test/attributify.test.ts +0 -592
  63. package/test/bracket-syntax.test.ts +0 -1133
  64. package/test/build.test.ts +0 -99
  65. package/test/colors.test.ts +0 -934
  66. package/test/flexbox.test.ts +0 -669
  67. package/test/generator.test.ts +0 -597
  68. package/test/grid.test.ts +0 -584
  69. package/test/layout.test.ts +0 -404
  70. package/test/modifiers.test.ts +0 -417
  71. package/test/parser.test.ts +0 -564
  72. package/test/performance-regression.test.ts +0 -376
  73. package/test/performance.test.ts +0 -568
  74. package/test/plugin.test.ts +0 -160
  75. package/test/scanner.test.ts +0 -94
  76. package/test/sizing.test.ts +0 -481
  77. package/test/spacing.test.ts +0 -394
  78. package/test/transformer-compile-class.test.ts +0 -287
  79. package/test/transforms.test.ts +0 -448
  80. package/test/typography.test.ts +0 -632
  81. package/test/variants-form-states.test.ts +0 -225
  82. package/test/variants-group-peer.test.ts +0 -66
  83. package/test/variants-media.test.ts +0 -213
  84. package/test/variants-positional.test.ts +0 -58
  85. package/test/variants-pseudo-elements.test.ts +0 -47
  86. package/test/variants-state.test.ts +0 -62
  87. package/tsconfig.json +0 -18
@@ -1,396 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { defaultConfig } from '../src/config'
3
- import { CSSGenerator } from '../src/generator'
4
- import { parseClass } from '../src/parser'
5
-
6
- describe('Arbitrary Values and Properties', () => {
7
- describe('Arbitrary values', () => {
8
- it('should support arbitrary width', () => {
9
- const gen = new CSSGenerator(defaultConfig)
10
- gen.generate('w-[100px]')
11
- expect(gen.toCSS(false)).toContain('width: 100px;')
12
- })
13
-
14
- it('should support arbitrary color', () => {
15
- const gen = new CSSGenerator(defaultConfig)
16
- gen.generate('bg-[#ff0000]')
17
- expect(gen.toCSS(false)).toContain('background-color: #ff0000;')
18
- })
19
-
20
- it('should support arbitrary padding', () => {
21
- const gen = new CSSGenerator(defaultConfig)
22
- gen.generate('p-[2.5rem]')
23
- expect(gen.toCSS(false)).toContain('padding: 2.5rem;')
24
- })
25
-
26
- it('should work with negative arbitrary values', () => {
27
- const gen = new CSSGenerator(defaultConfig)
28
- gen.generate('-m-[100px]')
29
- const css = gen.toCSS(false)
30
- expect(css).toBeDefined()
31
- })
32
- })
33
-
34
- describe('Arbitrary properties', () => {
35
- it('should parse arbitrary property', () => {
36
- const result = parseClass('[color:red]')
37
- expect(result).toEqual({
38
- raw: '[color:red]',
39
- variants: [],
40
- utility: 'color',
41
- value: 'red',
42
- important: false,
43
- arbitrary: true,
44
- })
45
- })
46
-
47
- it('should parse arbitrary property with dashes', () => {
48
- const result = parseClass('[mask-type:luminance]')
49
- expect(result).toEqual({
50
- raw: '[mask-type:luminance]',
51
- variants: [],
52
- utility: 'mask-type',
53
- value: 'luminance',
54
- important: false,
55
- arbitrary: true,
56
- })
57
- })
58
-
59
- it('should generate arbitrary property CSS', () => {
60
- const gen = new CSSGenerator(defaultConfig)
61
- gen.generate('[display:grid]')
62
- expect(gen.toCSS(false)).toContain('display: grid;')
63
- })
64
-
65
- it('should generate arbitrary property with dashes', () => {
66
- const gen = new CSSGenerator(defaultConfig)
67
- gen.generate('[mask-type:alpha]')
68
- expect(gen.toCSS(false)).toContain('mask-type: alpha;')
69
- })
70
-
71
- it('should handle arbitrary property with spaces', () => {
72
- const gen = new CSSGenerator(defaultConfig)
73
- gen.generate('[grid-template-areas:auto]')
74
- expect(gen.toCSS(false)).toContain('grid-template-areas: auto;')
75
- })
76
-
77
- it('should handle arbitrary property with CSS functions', () => {
78
- const gen = new CSSGenerator(defaultConfig)
79
- gen.generate('[background:linear-gradient(red,blue)]')
80
- expect(gen.toCSS(false)).toContain('background: linear-gradient(red,blue);')
81
- })
82
-
83
- it('should handle arbitrary property with important', () => {
84
- const gen = new CSSGenerator(defaultConfig)
85
- gen.generate('![z-index:9999]')
86
- expect(gen.toCSS(false)).toContain('z-index: 9999 !important;')
87
- })
88
- })
89
-
90
- describe('Edge Cases', () => {
91
- describe('Complex arbitrary values', () => {
92
- it('should handle calc() in arbitrary values', () => {
93
- const gen = new CSSGenerator(defaultConfig)
94
- gen.generate('w-[calc(100%-2rem)]')
95
- expect(gen.toCSS(false)).toContain('width: calc(100%-2rem);')
96
- })
97
-
98
- it('should handle clamp() in arbitrary values', () => {
99
- const gen = new CSSGenerator(defaultConfig)
100
- gen.generate('text-[clamp(1rem,2.5vw,3rem)]')
101
- expect(gen.toCSS(false)).toContain('font-size: clamp(1rem,2.5vw,3rem);')
102
- })
103
-
104
- it('should handle min() in arbitrary values', () => {
105
- const gen = new CSSGenerator(defaultConfig)
106
- gen.generate('w-[min(100%,500px)]')
107
- expect(gen.toCSS(false)).toContain('width: min(100%,500px);')
108
- })
109
-
110
- it('should handle max() in arbitrary values', () => {
111
- const gen = new CSSGenerator(defaultConfig)
112
- gen.generate('h-[max(50vh,300px)]')
113
- expect(gen.toCSS(false)).toContain('height: max(50vh,300px);')
114
- })
115
-
116
- it('should handle CSS variables', () => {
117
- const gen = new CSSGenerator(defaultConfig)
118
- gen.generate('text-[var(--font-size)]')
119
- expect(gen.toCSS(false)).toContain('font-size: var(--font-size);')
120
- })
121
-
122
- it('should handle multiple CSS variables', () => {
123
- const gen = new CSSGenerator(defaultConfig)
124
- gen.generate('[color:var(--primary,#000)]')
125
- expect(gen.toCSS(false)).toContain('color: var(--primary,#000);')
126
- })
127
- })
128
-
129
- describe('Type hints in arbitrary values', () => {
130
- it('should handle color type hint with CSS variable', () => {
131
- const gen = new CSSGenerator(defaultConfig)
132
- gen.generate('text-[color:var(--muted)]')
133
- expect(gen.toCSS(false)).toContain('color: var(--muted);')
134
- })
135
-
136
- it('should handle length type hint', () => {
137
- const gen = new CSSGenerator(defaultConfig)
138
- gen.generate('text-[length:1.5rem]')
139
- expect(gen.toCSS(false)).toContain('font-size: 1.5rem;')
140
- })
141
-
142
- it('should handle border color type hint', () => {
143
- const gen = new CSSGenerator(defaultConfig)
144
- gen.generate('border-[color:var(--border)]')
145
- expect(gen.toCSS(false)).toContain('border-color: var(--border);')
146
- })
147
-
148
- it('should handle bg color type hint', () => {
149
- const gen = new CSSGenerator(defaultConfig)
150
- gen.generate('bg-[color:var(--background)]')
151
- expect(gen.toCSS(false)).toContain('background-color: var(--background);')
152
- })
153
-
154
- it('should parse type hint correctly', () => {
155
- const result = parseClass('text-[color:var(--muted)]')
156
- expect(result.utility).toBe('text')
157
- expect(result.value).toBe('var(--muted)')
158
- expect(result.typeHint).toBe('color')
159
- expect(result.arbitrary).toBe(true)
160
- })
161
-
162
- it('should parse length type hint correctly', () => {
163
- const result = parseClass('w-[length:100px]')
164
- expect(result.utility).toBe('w')
165
- expect(result.value).toBe('100px')
166
- expect(result.typeHint).toBe('length')
167
- expect(result.arbitrary).toBe(true)
168
- })
169
-
170
- it('should not confuse CSS var() with type hint', () => {
171
- const result = parseClass('text-[var(--size)]')
172
- expect(result.utility).toBe('text')
173
- expect(result.value).toBe('var(--size)')
174
- expect(result.typeHint).toBeUndefined()
175
- })
176
-
177
- it('should handle type hint with variant', () => {
178
- const gen = new CSSGenerator(defaultConfig)
179
- gen.generate('hover:text-[color:var(--muted)]')
180
- const css = gen.toCSS(false)
181
- expect(css).toContain(':hover')
182
- expect(css).toContain('color: var(--muted);')
183
- })
184
- })
185
-
186
- describe('Modern CSS units', () => {
187
- it('should handle dvh units', () => {
188
- const gen = new CSSGenerator(defaultConfig)
189
- gen.generate('h-[100dvh]')
190
- expect(gen.toCSS(false)).toContain('height: 100dvh;')
191
- })
192
-
193
- it('should handle svh units', () => {
194
- const gen = new CSSGenerator(defaultConfig)
195
- gen.generate('h-[100svh]')
196
- expect(gen.toCSS(false)).toContain('height: 100svh;')
197
- })
198
-
199
- it('should handle lvh units', () => {
200
- const gen = new CSSGenerator(defaultConfig)
201
- gen.generate('h-[100lvh]')
202
- expect(gen.toCSS(false)).toContain('height: 100lvh;')
203
- })
204
-
205
- it('should handle cqw units', () => {
206
- const gen = new CSSGenerator(defaultConfig)
207
- gen.generate('w-[50cqw]')
208
- expect(gen.toCSS(false)).toContain('width: 50cqw;')
209
- })
210
-
211
- it('should handle cqh units', () => {
212
- const gen = new CSSGenerator(defaultConfig)
213
- gen.generate('h-[50cqh]')
214
- expect(gen.toCSS(false)).toContain('height: 50cqh;')
215
- })
216
-
217
- it('should handle ch units', () => {
218
- const gen = new CSSGenerator(defaultConfig)
219
- gen.generate('w-[60ch]')
220
- expect(gen.toCSS(false)).toContain('width: 60ch;')
221
- })
222
-
223
- it('should handle ex units', () => {
224
- const gen = new CSSGenerator(defaultConfig)
225
- gen.generate('h-[10ex]')
226
- expect(gen.toCSS(false)).toContain('height: 10ex;')
227
- })
228
- })
229
-
230
- describe('Complex arbitrary properties', () => {
231
- it('should handle grid-template-columns with complex value', () => {
232
- const gen = new CSSGenerator(defaultConfig)
233
- gen.generate('[grid-template-columns:repeat(auto-fit,minmax(200px,1fr))]')
234
- expect(gen.toCSS(false)).toContain('grid-template-columns: repeat(auto-fit,minmax(200px,1fr));')
235
- })
236
-
237
- it('should handle background with gradients', () => {
238
- const gen = new CSSGenerator(defaultConfig)
239
- gen.generate('[background:linear-gradient(45deg,red,blue)]')
240
- expect(gen.toCSS(false)).toContain('background: linear-gradient(45deg,red,blue);')
241
- })
242
-
243
- it('should handle filter with blur', () => {
244
- const gen = new CSSGenerator(defaultConfig)
245
- gen.generate('[filter:blur(10px)]')
246
- expect(gen.toCSS(false)).toContain('filter: blur(10px);')
247
- })
248
-
249
- it('should handle transform property', () => {
250
- const gen = new CSSGenerator(defaultConfig)
251
- gen.generate('[transform:translateX(10px)]')
252
- expect(gen.toCSS(false)).toContain('transform: translateX(10px);')
253
- })
254
-
255
- it('should handle box-shadow', () => {
256
- const gen = new CSSGenerator(defaultConfig)
257
- gen.generate('[box-shadow:inset_0_2px_4px_0_#0f172a]')
258
- const css = gen.toCSS(false)
259
- expect(css).toContain('box-shadow:')
260
- })
261
- })
262
-
263
- describe('Arbitrary values with variants', () => {
264
- it('should handle arbitrary value with responsive variant', () => {
265
- const gen = new CSSGenerator(defaultConfig)
266
- gen.generate('md:w-[450px]')
267
- const css = gen.toCSS(false)
268
- expect(css).toContain('@media (min-width: 768px)')
269
- expect(css).toContain('width: 450px;')
270
- })
271
-
272
- it('should handle arbitrary value with hover variant', () => {
273
- const gen = new CSSGenerator(defaultConfig)
274
- gen.generate('hover:bg-[#ff6600]')
275
- const css = gen.toCSS(false)
276
- expect(css).toContain(':hover')
277
- expect(css).toContain('background-color: #ff6600;')
278
- })
279
-
280
- it('should handle arbitrary value with multiple variants', () => {
281
- const gen = new CSSGenerator(defaultConfig)
282
- gen.generate('md:hover:w-[500px]')
283
- const css = gen.toCSS(false)
284
- expect(css).toContain('@media')
285
- expect(css).toContain(':hover')
286
- })
287
- })
288
-
289
- describe('Edge values', () => {
290
- it('should handle zero arbitrary value', () => {
291
- const gen = new CSSGenerator(defaultConfig)
292
- gen.generate('w-[0]')
293
- expect(gen.toCSS(false)).toContain('width: 0;')
294
- })
295
-
296
- it('should handle very large arbitrary value', () => {
297
- const gen = new CSSGenerator(defaultConfig)
298
- gen.generate('w-[9999px]')
299
- expect(gen.toCSS(false)).toContain('width: 9999px;')
300
- })
301
-
302
- it('should handle decimal arbitrary value', () => {
303
- const gen = new CSSGenerator(defaultConfig)
304
- gen.generate('opacity-[0.37]')
305
- expect(gen.toCSS(false)).toContain('opacity: 0.37;')
306
- })
307
-
308
- it('should handle fractional values', () => {
309
- const gen = new CSSGenerator(defaultConfig)
310
- gen.generate('w-[75.5%]')
311
- expect(gen.toCSS(false)).toContain('width: 75.5%;')
312
- })
313
- })
314
-
315
- describe('URL and image arbitrary values', () => {
316
- it('should handle url() in background-image', () => {
317
- const gen = new CSSGenerator(defaultConfig)
318
- gen.generate('[background-image:url(/images/bg.jpg)]')
319
- expect(gen.toCSS(false)).toContain('background-image: url(/images/bg.jpg);')
320
- })
321
-
322
- it('should handle data URL', () => {
323
- const gen = new CSSGenerator(defaultConfig)
324
- gen.generate('[background:url(data:image/svg+xml;base64,ABC)]')
325
- expect(gen.toCSS(false)).toContain('background: url(data:image/svg+xml;base64,ABC);')
326
- })
327
- })
328
-
329
- describe('Special characters in arbitrary values', () => {
330
- it('should handle parentheses in arbitrary values', () => {
331
- const gen = new CSSGenerator(defaultConfig)
332
- gen.generate('[clip-path:circle(50%)]')
333
- expect(gen.toCSS(false)).toContain('clip-path: circle(50%);')
334
- })
335
-
336
- it('should handle complex values', () => {
337
- const gen = new CSSGenerator(defaultConfig)
338
- gen.generate('[animation:spin_1s_linear_infinite]')
339
- const css = gen.toCSS(false)
340
- expect(css).toContain('animation:')
341
- })
342
- })
343
-
344
- describe('Color formats in arbitrary', () => {
345
- it('should handle hex colors', () => {
346
- const gen = new CSSGenerator(defaultConfig)
347
- gen.generate('bg-[#123456]')
348
- expect(gen.toCSS(false)).toContain('background-color: #123456;')
349
- })
350
-
351
- it('should handle rgb colors', () => {
352
- const gen = new CSSGenerator(defaultConfig)
353
- gen.generate('bg-[rgb(255,0,0)]')
354
- expect(gen.toCSS(false)).toContain('background-color: rgb(255,0,0);')
355
- })
356
-
357
- it('should handle rgba colors', () => {
358
- const gen = new CSSGenerator(defaultConfig)
359
- gen.generate('bg-[rgba(0,0,0,0.5)]')
360
- expect(gen.toCSS(false)).toContain('background-color: rgba(0,0,0,0.5);')
361
- })
362
-
363
- it('should handle hsl colors', () => {
364
- const gen = new CSSGenerator(defaultConfig)
365
- gen.generate('bg-[hsl(200,100%,50%)]')
366
- expect(gen.toCSS(false)).toContain('background-color: hsl(200,100%,50%);')
367
- })
368
-
369
- it('should handle hsla colors', () => {
370
- const gen = new CSSGenerator(defaultConfig)
371
- gen.generate('bg-[hsla(120,50%,50%,0.8)]')
372
- expect(gen.toCSS(false)).toContain('background-color: hsla(120,50%,50%,0.8);')
373
- })
374
- })
375
-
376
- describe('Angle units', () => {
377
- it('should handle deg units', () => {
378
- const gen = new CSSGenerator(defaultConfig)
379
- gen.generate('rotate-[17deg]')
380
- expect(gen.toCSS(false)).toContain('transform: rotate(17deg);')
381
- })
382
-
383
- it('should handle rad units', () => {
384
- const gen = new CSSGenerator(defaultConfig)
385
- gen.generate('rotate-[1.5rad]')
386
- expect(gen.toCSS(false)).toContain('transform: rotate(1.5rad);')
387
- })
388
-
389
- it('should handle turn units', () => {
390
- const gen = new CSSGenerator(defaultConfig)
391
- gen.generate('rotate-[0.25turn]')
392
- expect(gen.toCSS(false)).toContain('transform: rotate(0.25turn);')
393
- })
394
- })
395
- })
396
- })