@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,481 +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('Sizing Utilities', () => {
7
- describe('Width', () => {
8
- it('should generate w-full', () => {
9
- const gen = new CSSGenerator(defaultConfig)
10
- gen.generate('w-full')
11
- expect(gen.toCSS(false)).toContain('width: 100%;')
12
- })
13
-
14
- it('should generate w-screen', () => {
15
- const gen = new CSSGenerator(defaultConfig)
16
- gen.generate('w-screen')
17
- expect(gen.toCSS(false)).toContain('width: 100vw;')
18
- })
19
-
20
- it('should generate w-auto', () => {
21
- const gen = new CSSGenerator(defaultConfig)
22
- gen.generate('w-auto')
23
- expect(gen.toCSS(false)).toContain('width: auto;')
24
- })
25
-
26
- it('should generate w-min', () => {
27
- const gen = new CSSGenerator(defaultConfig)
28
- gen.generate('w-min')
29
- expect(gen.toCSS(false)).toContain('width: min-content;')
30
- })
31
-
32
- it('should generate w-max', () => {
33
- const gen = new CSSGenerator(defaultConfig)
34
- gen.generate('w-max')
35
- expect(gen.toCSS(false)).toContain('width: max-content;')
36
- })
37
-
38
- it('should generate w-fit', () => {
39
- const gen = new CSSGenerator(defaultConfig)
40
- gen.generate('w-fit')
41
- expect(gen.toCSS(false)).toContain('width: fit-content;')
42
- })
43
-
44
- it('should support arbitrary width', () => {
45
- const gen = new CSSGenerator(defaultConfig)
46
- gen.generate('w-[100px]')
47
- expect(gen.toCSS(false)).toContain('width: 100px;')
48
- })
49
- })
50
-
51
- describe('Height', () => {
52
- it('should generate h-full', () => {
53
- const gen = new CSSGenerator(defaultConfig)
54
- gen.generate('h-full')
55
- expect(gen.toCSS(false)).toContain('height: 100%;')
56
- })
57
-
58
- it('should generate h-screen', () => {
59
- const gen = new CSSGenerator(defaultConfig)
60
- gen.generate('h-screen')
61
- expect(gen.toCSS(false)).toContain('height: 100vh;')
62
- })
63
-
64
- it('should generate h-auto', () => {
65
- const gen = new CSSGenerator(defaultConfig)
66
- gen.generate('h-auto')
67
- expect(gen.toCSS(false)).toContain('height: auto;')
68
- })
69
- })
70
-
71
- describe('Fractional values', () => {
72
- it('should parse fractional width', () => {
73
- const result = parseClass('w-1/2')
74
- expect(result).toEqual({
75
- raw: 'w-1/2',
76
- variants: [],
77
- utility: 'w',
78
- value: '1/2',
79
- important: false,
80
- arbitrary: false,
81
- })
82
- })
83
-
84
- it('should generate 50% width for w-1/2', () => {
85
- const gen = new CSSGenerator(defaultConfig)
86
- gen.generate('w-1/2')
87
- expect(gen.toCSS(false)).toContain('width: 50%;')
88
- })
89
-
90
- it('should generate 33.333% width for w-1/3', () => {
91
- const gen = new CSSGenerator(defaultConfig)
92
- gen.generate('w-1/3')
93
- expect(gen.toCSS(false)).toContain('width: 33.33333333333333%;')
94
- })
95
-
96
- it('should generate 66.666% width for w-2/3', () => {
97
- const gen = new CSSGenerator(defaultConfig)
98
- gen.generate('w-2/3')
99
- expect(gen.toCSS(false)).toContain('width: 66.66666666666666%;')
100
- })
101
-
102
- it('should generate 75% height for h-3/4', () => {
103
- const gen = new CSSGenerator(defaultConfig)
104
- gen.generate('h-3/4')
105
- expect(gen.toCSS(false)).toContain('height: 75%;')
106
- })
107
-
108
- it('should handle improper fractions', () => {
109
- const gen = new CSSGenerator(defaultConfig)
110
- gen.generate('w-5/3')
111
- expect(gen.toCSS(false)).toMatch(/width: 166\.666/)
112
- })
113
-
114
- it('should handle very large fraction denominator', () => {
115
- const gen = new CSSGenerator(defaultConfig)
116
- gen.generate('w-1/10000')
117
- expect(gen.toCSS(false)).toContain('width: 0.01%;')
118
- })
119
- })
120
-
121
- describe('Min-width', () => {
122
- it('should generate min-w-0', () => {
123
- const gen = new CSSGenerator(defaultConfig)
124
- gen.generate('min-w-0')
125
- expect(gen.toCSS(false)).toContain('min-width: 0;')
126
- })
127
-
128
- it('should generate min-w-full', () => {
129
- const gen = new CSSGenerator(defaultConfig)
130
- gen.generate('min-w-full')
131
- expect(gen.toCSS(false)).toContain('min-width: 100%;')
132
- })
133
-
134
- it('should generate min-w-min', () => {
135
- const gen = new CSSGenerator(defaultConfig)
136
- gen.generate('min-w-min')
137
- expect(gen.toCSS(false)).toContain('min-width: min-content;')
138
- })
139
-
140
- it('should generate min-w-max', () => {
141
- const gen = new CSSGenerator(defaultConfig)
142
- gen.generate('min-w-max')
143
- expect(gen.toCSS(false)).toContain('min-width: max-content;')
144
- })
145
-
146
- it('should generate min-w-fit', () => {
147
- const gen = new CSSGenerator(defaultConfig)
148
- gen.generate('min-w-fit')
149
- expect(gen.toCSS(false)).toContain('min-width: fit-content;')
150
- })
151
- })
152
-
153
- describe('Max-width', () => {
154
- it('should generate max-w-xl', () => {
155
- const gen = new CSSGenerator(defaultConfig)
156
- gen.generate('max-w-xl')
157
- expect(gen.toCSS(false)).toContain('max-width: 36rem;')
158
- })
159
-
160
- it('should generate max-w-screen', () => {
161
- const gen = new CSSGenerator(defaultConfig)
162
- gen.generate('max-w-screen')
163
- expect(gen.toCSS(false)).toContain('max-width: 100vw;')
164
- })
165
-
166
- it('should generate max-w-none', () => {
167
- const gen = new CSSGenerator(defaultConfig)
168
- gen.generate('max-w-none')
169
- expect(gen.toCSS(false)).toContain('max-width: none;')
170
- })
171
-
172
- it('should generate max-w-full', () => {
173
- const gen = new CSSGenerator(defaultConfig)
174
- gen.generate('max-w-full')
175
- expect(gen.toCSS(false)).toContain('max-width: 100%;')
176
- })
177
-
178
- it('should handle max-w with arbitrary value', () => {
179
- const gen = new CSSGenerator(defaultConfig)
180
- gen.generate('max-w-[1920px]')
181
- expect(gen.toCSS(false)).toContain('max-width: 1920px;')
182
- })
183
- })
184
-
185
- describe('Min-height', () => {
186
- it('should generate min-h-screen', () => {
187
- const gen = new CSSGenerator(defaultConfig)
188
- gen.generate('min-h-screen')
189
- expect(gen.toCSS(false)).toContain('min-height: 100vh;')
190
- })
191
-
192
- it('should generate min-h-full', () => {
193
- const gen = new CSSGenerator(defaultConfig)
194
- gen.generate('min-h-full')
195
- expect(gen.toCSS(false)).toContain('min-height: 100%;')
196
- })
197
-
198
- it('should handle min-h-screen on mobile', () => {
199
- const gen = new CSSGenerator(defaultConfig)
200
- gen.generate('min-h-[100dvh]')
201
- expect(gen.toCSS(false)).toContain('min-height: 100dvh;')
202
- })
203
- })
204
-
205
- describe('Max-height', () => {
206
- it('should generate max-h-full', () => {
207
- const gen = new CSSGenerator(defaultConfig)
208
- gen.generate('max-h-full')
209
- expect(gen.toCSS(false)).toContain('max-height: 100%;')
210
- })
211
-
212
- it('should generate max-h-screen', () => {
213
- const gen = new CSSGenerator(defaultConfig)
214
- gen.generate('max-h-screen')
215
- expect(gen.toCSS(false)).toContain('max-height: 100vh;')
216
- })
217
- })
218
- })
219
-
220
- describe('Edge Cases', () => {
221
- describe('Width edge cases', () => {
222
- it('should handle w-0', () => {
223
- const gen = new CSSGenerator(defaultConfig)
224
- gen.generate('w-0')
225
- expect(gen.toCSS(false)).toContain('width: 0;')
226
- })
227
-
228
- it('should handle w-px (1px)', () => {
229
- const gen = new CSSGenerator(defaultConfig)
230
- gen.generate('w-px')
231
- expect(gen.toCSS(false)).toContain('width: 1px;')
232
- })
233
-
234
- it('should handle width with calc()', () => {
235
- const gen = new CSSGenerator(defaultConfig)
236
- gen.generate('w-[calc(100vw-2rem)]')
237
- expect(gen.toCSS(false)).toContain('width: calc(100vw-2rem);')
238
- })
239
-
240
- it('should handle width with CSS variables', () => {
241
- const gen = new CSSGenerator(defaultConfig)
242
- gen.generate('w-[var(--custom-width)]')
243
- expect(gen.toCSS(false)).toContain('width: var(--custom-width);')
244
- })
245
-
246
- it('should handle width with clamp()', () => {
247
- const gen = new CSSGenerator(defaultConfig)
248
- gen.generate('w-[clamp(200px,50vw,600px)]')
249
- expect(gen.toCSS(false)).toContain('width: clamp(200px,50vw,600px);')
250
- })
251
-
252
- it('should handle width with min()', () => {
253
- const gen = new CSSGenerator(defaultConfig)
254
- gen.generate('w-[min(100%,500px)]')
255
- expect(gen.toCSS(false)).toContain('width: min(100%,500px);')
256
- })
257
-
258
- it('should handle width with max()', () => {
259
- const gen = new CSSGenerator(defaultConfig)
260
- gen.generate('w-[max(300px,50%)]')
261
- expect(gen.toCSS(false)).toContain('width: max(300px,50%);')
262
- })
263
-
264
- it('should handle width 100dvw', () => {
265
- const gen = new CSSGenerator(defaultConfig)
266
- gen.generate('w-[100dvw]')
267
- expect(gen.toCSS(false)).toContain('width: 100dvw;')
268
- })
269
-
270
- it('should handle width with ch units', () => {
271
- const gen = new CSSGenerator(defaultConfig)
272
- gen.generate('w-[80ch]')
273
- expect(gen.toCSS(false)).toContain('width: 80ch;')
274
- })
275
- })
276
-
277
- describe('Height edge cases', () => {
278
- it('should handle h-0', () => {
279
- const gen = new CSSGenerator(defaultConfig)
280
- gen.generate('h-0')
281
- expect(gen.toCSS(false)).toContain('height: 0;')
282
- })
283
-
284
- it('should handle h-px', () => {
285
- const gen = new CSSGenerator(defaultConfig)
286
- gen.generate('h-px')
287
- expect(gen.toCSS(false)).toContain('height: 1px;')
288
- })
289
-
290
- it('should handle height with svh units', () => {
291
- const gen = new CSSGenerator(defaultConfig)
292
- gen.generate('h-[100svh]')
293
- expect(gen.toCSS(false)).toContain('height: 100svh;')
294
- })
295
-
296
- it('should handle height with dvh units', () => {
297
- const gen = new CSSGenerator(defaultConfig)
298
- gen.generate('h-[100dvh]')
299
- expect(gen.toCSS(false)).toContain('height: 100dvh;')
300
- })
301
-
302
- it('should handle height with lvh units', () => {
303
- const gen = new CSSGenerator(defaultConfig)
304
- gen.generate('h-[100lvh]')
305
- expect(gen.toCSS(false)).toContain('height: 100lvh;')
306
- })
307
-
308
- it('should handle height with calc()', () => {
309
- const gen = new CSSGenerator(defaultConfig)
310
- gen.generate('h-[calc(100vh-80px)]')
311
- expect(gen.toCSS(false)).toContain('height: calc(100vh-80px);')
312
- })
313
- })
314
-
315
- describe('Fractional edge cases', () => {
316
- it('should handle w-1/12', () => {
317
- const gen = new CSSGenerator(defaultConfig)
318
- gen.generate('w-1/12')
319
- expect(gen.toCSS(false)).toMatch(/width: 8\.333/)
320
- })
321
-
322
- it('should handle w-11/12', () => {
323
- const gen = new CSSGenerator(defaultConfig)
324
- gen.generate('w-11/12')
325
- expect(gen.toCSS(false)).toMatch(/width: 91\.666/)
326
- })
327
-
328
- it('should handle w-full (100%)', () => {
329
- const gen = new CSSGenerator(defaultConfig)
330
- gen.generate('w-full')
331
- expect(gen.toCSS(false)).toContain('width: 100%;')
332
- })
333
-
334
- it('should handle fraction with result > 100%', () => {
335
- const gen = new CSSGenerator(defaultConfig)
336
- gen.generate('w-[5/4]')
337
- expect(gen.toCSS(false)).toContain('width: 125%;')
338
- })
339
-
340
- it('should handle very precise fraction', () => {
341
- const gen = new CSSGenerator(defaultConfig)
342
- gen.generate('w-[1/7]')
343
- expect(gen.toCSS(false)).toMatch(/width: 14\.285/)
344
- })
345
- })
346
-
347
- describe('Min/Max edge cases', () => {
348
- it('should handle min-w-0', () => {
349
- const gen = new CSSGenerator(defaultConfig)
350
- gen.generate('min-w-0')
351
- expect(gen.toCSS(false)).toContain('min-width: 0;')
352
- })
353
-
354
- it('should handle max-w-none', () => {
355
- const gen = new CSSGenerator(defaultConfig)
356
- gen.generate('max-w-none')
357
- expect(gen.toCSS(false)).toContain('max-width: none;')
358
- })
359
-
360
- it('should handle min-h-0', () => {
361
- const gen = new CSSGenerator(defaultConfig)
362
- gen.generate('min-h-0')
363
- expect(gen.toCSS(false)).toContain('min-height: 0;')
364
- })
365
-
366
- it('should handle max-h-none', () => {
367
- const gen = new CSSGenerator(defaultConfig)
368
- gen.generate('max-h-none')
369
- expect(gen.toCSS(false)).toContain('max-height: none;')
370
- })
371
-
372
- it('should handle min-w with calc()', () => {
373
- const gen = new CSSGenerator(defaultConfig)
374
- gen.generate('min-w-[calc(100%-40px)]')
375
- expect(gen.toCSS(false)).toContain('min-width: calc(100%-40px);')
376
- })
377
-
378
- it('should handle max-w with vw', () => {
379
- const gen = new CSSGenerator(defaultConfig)
380
- gen.generate('max-w-[90vw]')
381
- expect(gen.toCSS(false)).toContain('max-width: 90vw;')
382
- })
383
-
384
- it('should handle min-h-screen', () => {
385
- const gen = new CSSGenerator(defaultConfig)
386
- gen.generate('min-h-screen')
387
- expect(gen.toCSS(false)).toContain('min-height: 100vh;')
388
- })
389
-
390
- it('should handle max-h-screen', () => {
391
- const gen = new CSSGenerator(defaultConfig)
392
- gen.generate('max-h-screen')
393
- expect(gen.toCSS(false)).toContain('max-height: 100vh;')
394
- })
395
- })
396
-
397
- describe('Size with variants', () => {
398
- it('should handle sizing with important', () => {
399
- const gen = new CSSGenerator(defaultConfig)
400
- gen.generate('!w-full')
401
- expect(gen.toCSS(false)).toContain('width: 100% !important;')
402
- })
403
-
404
- it('should handle sizing with hover', () => {
405
- const gen = new CSSGenerator(defaultConfig)
406
- gen.generate('hover:w-auto')
407
- const css = gen.toCSS(false)
408
- expect(css).toContain(':hover')
409
- expect(css).toContain('width: auto;')
410
- })
411
-
412
- it('should handle sizing with responsive', () => {
413
- const gen = new CSSGenerator(defaultConfig)
414
- gen.generate('lg:w-1/2')
415
- const css = gen.toCSS(false)
416
- expect(css).toContain('@media (min-width: 1024px)')
417
- expect(css).toContain('width: 50%;')
418
- })
419
- })
420
-
421
- describe('Container query units', () => {
422
- it('should handle width with cqw', () => {
423
- const gen = new CSSGenerator(defaultConfig)
424
- gen.generate('w-[50cqw]')
425
- expect(gen.toCSS(false)).toContain('width: 50cqw;')
426
- })
427
-
428
- it('should handle height with cqh', () => {
429
- const gen = new CSSGenerator(defaultConfig)
430
- gen.generate('h-[80cqh]')
431
- expect(gen.toCSS(false)).toContain('height: 80cqh;')
432
- })
433
- })
434
-
435
- describe('Edge cases', () => {
436
- it('should handle fractional sizing', () => {
437
- const gen = new CSSGenerator(defaultConfig)
438
- gen.generate('w-1/2')
439
- gen.generate('w-1/3')
440
- gen.generate('w-2/3')
441
- gen.generate('w-1/4')
442
- gen.generate('w-3/4')
443
- gen.generate('w-1/5')
444
- const css = gen.toCSS(false)
445
- expect(css).toContain('width')
446
- })
447
-
448
- it('should handle full width/height', () => {
449
- const gen = new CSSGenerator(defaultConfig)
450
- gen.generate('w-full')
451
- gen.generate('h-full')
452
- const css = gen.toCSS(false)
453
- expect(css).toContain('100%')
454
- })
455
-
456
- it('should handle screen width/height', () => {
457
- const gen = new CSSGenerator(defaultConfig)
458
- gen.generate('w-screen')
459
- gen.generate('h-screen')
460
- const css = gen.toCSS(false)
461
- expect(css).toContain('100v')
462
- })
463
-
464
- it('should handle min/max content sizing', () => {
465
- const gen = new CSSGenerator(defaultConfig)
466
- gen.generate('w-min')
467
- gen.generate('w-max')
468
- gen.generate('w-fit')
469
- const css = gen.toCSS(false)
470
- expect(css).toContain('content')
471
- })
472
-
473
- it('should handle auto sizing', () => {
474
- const gen = new CSSGenerator(defaultConfig)
475
- gen.generate('w-auto')
476
- gen.generate('h-auto')
477
- const css = gen.toCSS(false)
478
- expect(css).toContain('auto')
479
- })
480
- })
481
- })