@cwcss/crosswind 0.1.6 → 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.
package/README.md CHANGED
@@ -1,390 +1,52 @@
1
- <p align="center"><img src=".github/art/cover.jpg" alt="Social Card of this repo"></p>
1
+ # @cwcss/crosswind
2
2
 
3
- [![npm version][npm-version-src]][npm-version-href]
4
- [![GitHub Actions][github-actions-src]][github-actions-href]
5
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6
- <!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7
- <!-- [![Codecov][codecov-src]][codecov-href] -->
3
+ A performant Utility-First CSS framework, similar to Tailwind or UnoCSS. Built with TypeScript and optimized for Bun.
8
4
 
9
- # crosswind
10
-
11
- A blazingly fast, utility-first CSS framework built with Bun. Crosswind generates only the CSS you need by scanning your files for utility classes, providing Tailwind CSS-compatible utilities with exceptional performance.
12
-
13
- ## Features
14
-
15
- - ⚡️**Blazingly Fast**- Built with Bun for exceptional performance (1000+ utilities in <10ms)
16
- - 🎯**On-Demand Generation**- Only generates CSS for utilities you actually use
17
- - 🎨**Tailwind-Compatible**- Familiar utility classes and syntax
18
- - 💪**Fully Typed**- Complete TypeScript support with type-safe configuration
19
- - 🔧**Highly Configurable**- Customize theme, colors, spacing, variants, and more
20
- - 📦**Zero Runtime Dependencies**- Minimal footprint, maximum performance
21
- - 🔥**Hot Reload**- Watch mode for instant rebuilds during development
22
- - 🎭**Variant Support**- Responsive, state (hover, focus, etc.), dark mode, and custom variants
23
- - ✨**Modern CSS Features**- Grid, Flexbox, animations, transforms, filters, and more
24
- - 🔨**Class Compilation**- Optimize HTML by compiling utility groups into single class names
25
- - 🧪**Thoroughly Tested**- 1300+ tests including comprehensive performance benchmarks
26
- - 🚀**Production Ready**- Minification, preflight CSS, and optimized builds
27
- - ⌨️**CLI & API**- Use via command line or programmatic API
28
-
29
- ## Get Started
30
-
31
- ### Installation
5
+ ## Installation
32
6
 
33
7
  ```bash
34
- bun add crosswind
35
-
36
- # or
37
-
38
- npm install crosswind
39
- ```### Quick Start
40
-
41
- 1.**Initialize Crosswind**:```bash
42
-
43
- # Create a config file
44
-
45
- bunx crosswind init
46
-
47
- ```This creates a`crosswind.config.ts`file:```typescript
48
- import type { CrosswindOptions } from 'crosswind'
49
-
50
- export default {
51
- content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
52
- output: './dist/crosswind.css',
53
- minify: false,
54
- } satisfies CrosswindOptions
55
- ```1.**Add utility classes to your HTML**:```html
56
-
57
- <div class="flex items-center justify-between p-4 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600">
58
- <h1 class="text-2xl font-bold">Hello Crosswind!</h1>
59
- </div>
60
-
61
- ```1.**Build your CSS**:```bash
62
-
63
- # Build once
64
-
65
- bunx crosswind build
66
-
67
- # Build and watch for changes
68
-
69
- bunx crosswind watch
8
+ bun add @cwcss/crosswind
9
+ ```
70
10
 
71
- # Build with options
11
+ ```bash
12
+ npm install @cwcss/crosswind
13
+ ```
72
14
 
73
- bunx crosswind build --output ./dist/styles.css --minify
74
- ```### Programmatic API
15
+ ## Usage
75
16
 
76
- You can also use Crosswind programmatically:```typescript
77
- import { build } from 'crosswind'
17
+ ```typescript
18
+ import { build, scan, generate } from '@cwcss/crosswind'
78
19
 
20
+ // Build CSS from your content files
79
21
  const result = await build({
80
- content: ['./src/**/*.html'],
22
+ content: ['./src/**/*.html', './src/**/*.tsx'],
81
23
  output: './dist/styles.css',
82
24
  minify: true,
83
25
  })
84
-
85
- console.log(`Generated ${result.classes.size} classes in ${result.duration}ms`)
86
-
87
- ```## CLI Commands
88
-
89
- Crosswind provides a comprehensive CLI:```bash
90
- crosswind build # Build CSS once
91
- crosswind watch # Build and watch for changes
92
- crosswind init # Create config file
93
- crosswind analyze # Analyze utility class usage
94
- crosswind clean # Remove output CSS file
95
- crosswind preflight # Generate preflight CSS only
96
- crosswind --version # Show version
97
- crosswind --help # Show help
98
- ```## Configuration
99
-
100
- Crosswind supports extensive configuration options:```typescript
101
- import type { CrosswindOptions } from 'crosswind'
102
-
103
- export default {
104
- // Content sources to scan for utility classes
105
- content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
106
-
107
- // Output CSS file path
108
- output: './dist/styles.css',
109
-
110
- // Minify output CSS
111
- minify: false,
112
-
113
- // Enable watch mode
114
- watch: false,
115
-
116
- // Enable verbose logging
117
- verbose: false,
118
-
119
- // Theme customization
120
- theme: {
121
- colors: {
122
- primary: '#3b82f6',
123
- secondary: '#10b981',
124
- // ... extend or override default colors
125
- },
126
- spacing: {
127
- // ... customize spacing scale
128
- },
129
- fontSize: {
130
- // ... customize font sizes
131
- },
132
- // ... and more
133
- },
134
-
135
- // Shortcuts (utility aliases)
136
- shortcuts: {
137
- btn: 'px-4 py-2 rounded bg-blue-500 text-white hover:bg-blue-600',
138
- card: 'p-6 bg-white rounded-lg shadow-md',
139
- },
140
-
141
- // Custom variants
142
- variants: {
143
- // ... configure breakpoints, states, etc.
144
- },
145
-
146
- // Safelist (always include these classes)
147
- safelist: ['bg-red-500', 'text-green-500'],
148
-
149
- // Blocklist (never include these classes)
150
- blocklist: ['debug-*'],
151
-
152
- // Custom rules
153
- rules: [],
154
-
155
- // Preflight CSS (normalize/reset styles)
156
- preflights: [],
157
-
158
- // Presets
159
- presets: [],
160
- } satisfies CrosswindOptions
161
-
162
- ```For more configuration options, see the [Configuration Guide](https://crosswind.stacksjs.org/config).
163
-
164
- ## Available Utilities
165
-
166
- Crosswind provides a comprehensive set of utility classes compatible with Tailwind CSS:
167
-
168
- -**Layout**: display, position, overflow, z-index, etc.
169
- -**Flexbox & Grid**: flex, grid, gap, align, justify, etc.
170
- -**Spacing**: margin, padding with full scale support
171
- -**Sizing**: width, height, min/max sizes
172
- -**Typography**: font family, size, weight, line height, text alignment, etc.
173
- -**Backgrounds**: colors, gradients, images, position, size
174
- -**Borders**: width, color, radius, style
175
- -**Effects**: shadow, opacity, blend modes, filters
176
- -**Transforms**: translate, rotate, scale, skew
177
- -**Transitions & Animations**: duration, timing, delay
178
- -**Interactivity**: cursor, pointer events, user select, scroll behavior
179
- -**Advanced**: mask utilities, backdrop filters, ring utilities
180
-
181
- ### Variants
182
-
183
- -**Responsive**:`sm:`, `md:`, `lg:`, `xl:`, `2xl:`-**State**:`hover:`, `focus:`, `active:`, `disabled:`, `visited:`, `checked:`-**Pseudo-elements**:`before:`, `after:`, `placeholder:`, `selection:`-**Group/Peer**:`group-hover:`, `peer-focus:`-**Dark mode**:`dark:`-**Positional**:`first:`, `last:`, `odd:`, `even:`-**Important**:`!`prefix (e.g.,`!text-red-500`)
184
-
185
- ### Arbitrary Values
186
-
187
- Crosswind supports arbitrary values for maximum flexibility:
188
-
189
- ```html
190
-
191
- <div class="w-[500px] h-[calc(100vh-4rem)] bg-[#1da1f2] text-[clamp(1rem,5vw,3rem)]">
192
- Custom values!
193
- </div>
194
-
195
- ```### Compile Class (HTML Optimization)
196
-
197
- Optimize your HTML by compiling utility groups into single class names:```html
198
- <!-- Before -->
199
- <div class=":hw: flex items-center justify-between px-4 py-2 bg-white rounded-lg shadow-md">
200
- Content
201
- </div>
202
-
203
- <!-- After build -->
204
- <div class="hw-2k9d3a">
205
- Content
206
- </div>
207
- ```This reduces HTML file size by up to 60%. Learn more in the [Compile Class documentation](https://crosswind.stacksjs.org/features/compile-class).
208
-
209
- ## Testing
210
-
211
- Crosswind includes a comprehensive test suite with 1300+ tests:```bash
212
-
213
- # Run all tests
214
-
215
- bun test
216
-
217
- # Run specific test files
218
-
219
- bun test test/performance.test.ts
220
-
221
- # Run tests in watch mode
222
-
223
- bun test --watch
224
-
225
- ```### Test Coverage
226
-
227
- -**Core Functionality**: Parser, generator, scanner, builder
228
- -**Utilities**: Layout, typography, colors, spacing, grid, flexbox
229
- -**Variants**: Responsive, state, pseudo-elements, combinations
230
- -**Advanced Features**: Shortcuts, custom rules, arbitrary values
231
- -**Performance**: Benchmarks for generation speed and memory efficiency
232
- -**Edge Cases**: Invalid inputs, complex nesting, duplicate handling
233
-
234
- ## Performance
235
-
236
- Crosswind is designed for speed. We've benchmarked against other popular utility-first CSS frameworks to demonstrate our performance advantages.
237
-
238
- ### Benchmark Results
239
-
240
- Our comprehensive benchmark suite (20 tests) compares Crosswind with UnoCSS, Tailwind CSS v3, and Tailwind CSS v4.
241
-
242
- | Scenario | Crosswind | UnoCSS | Tailwind v3 | Tailwind v4 | Winner |
243
- |----------|----------|--------|-------------|-------------|--------|
244
- |**Simple Utilities**(10 classes) |**2.75µs**| 31.58µs | 14.32ms | 46.47ms | Crosswind ⚡ |
245
- |**Complex Utilities**(11 classes) |**8.61µs**| 43.77µs | 14.25ms | 39.26ms | Crosswind ⚡ |
246
- |**Arbitrary Values**(10 classes) |**41.71µs**| 64.44µs | 15.52ms | - | Crosswind ⚡ |
247
- |**Real-world Components**(~60 classes) |**25.26µs**| 97.71µs | 16.12ms | 45.07ms | Crosswind ⚡ |
248
- |**Large Scale**(500 classes) |**94.89µs**| 201.30µs | 14.51ms | 40.06ms | Crosswind ⚡ |
249
- |**CSS Output**(1000 values) |**1.50ms**| 115.59ms | 16.03ms | - | Crosswind ⚡ |
250
- |**Color Utilities**(330 classes) |**100.85µs**| 526.82µs | 12.89ms | 37.27ms | Crosswind ⚡ |
251
- |**Responsive**(500 classes) |**100.16µs**| 211.39µs | 12.86ms | 41.07ms | Crosswind ⚡ |
252
- |**Interactive States**(440 classes) |**260.75µs**| 1.16ms | 13.84ms | 38.06ms | Crosswind ⚡ |
253
- |**Duplicate Handling**(6000 items) |**43.19µs**| 1.81ms | 18.47ms | 48.11ms | Crosswind ⚡ |
254
- |**Typography**(50 classes) |**16.06µs**| 94.37µs | 14.37ms | 39.33ms | Crosswind ⚡ |
255
- |**Flexbox**(50 classes) |**13.77µs**| 88.62µs | 13.04ms | 42.38ms | Crosswind ⚡ |
256
- |**Grid**(55 classes) |**59.89µs**| 118.31µs | 15.10ms | 39.00ms | Crosswind ⚡ |
257
- |**Stacked Variants**(40 classes) |**73.43µs**| 148.79µs | 15.65ms | 41.11ms | Crosswind ⚡ |
258
- |**Transforms**(55 classes) |**78.39µs**| 100.85µs | 13.76ms | 44.34ms | Crosswind ⚡ |
259
- |**Transitions**(30 classes) |**12.96µs**| 66.47µs | 14.38ms | 36.46ms | Crosswind ⚡ |
260
- |**Border & Ring**(45 classes) |**12.55µs**| 90.45µs | 10.52ms | 40.58ms | Crosswind ⚡ |
261
- |**Shadow & Effects**(35 classes) |**6.92µs**| 62.12µs | 10.89ms | 36.62ms | Crosswind ⚡ |
262
- |**Incremental Generation**(200 classes) |**73.91µs**| 196.35µs | 14.07ms | 35.58ms | Crosswind ⚡ |
263
- |**Full Project**(~800 classes) |**649.87µs**| 1.38ms | 14.41ms | - | Crosswind ⚡ |
264
-
265
- ### Highlights
266
-
267
- -**Crosswind wins 20/20 benchmarks**vs all competitors
268
- -**Simple utilities**: 11x faster than UnoCSS, 5,200x faster than Tailwind v3
269
- -**Typography**: 6x faster than UnoCSS
270
- -**Flexbox**: 6.4x faster than UnoCSS
271
- -**Shadow & Effects**: 9x faster than UnoCSS
272
- -**Border & Ring**: 7x faster than UnoCSS
273
- -**Color utilities**: 5x faster than UnoCSS
274
- -**Interactive states**: 4.5x faster than UnoCSS
275
- -**Duplicate handling**: 42x faster than UnoCSS
276
- -**CSS output generation**: 77x faster than UnoCSS
277
- -**Full project simulation**: 2.1x faster than UnoCSS, 22x faster than Tailwind v3
278
-
279
- ### Running Benchmarks
280
-
281
- You can run the benchmarks yourself to see the performance on your hardware:```bash
282
-
283
- # Run the comprehensive benchmark suite
284
-
285
- bun run benchmark
286
-
287
- # Or run from the packages/crosswind directory
288
-
289
- cd packages/crosswind
290
- bun run benchmark
291
- ```All benchmarks use [Mitata](https://github.com/evanwashere/mitata) for accurate measurements and run on Bun runtime. Results may vary based on your hardware.
292
-
293
- ## Development
294
-
295
- To contribute to Crosswind development:```bash
296
-
297
- # Clone the repository
298
-
299
- git clone <https://github.com/cwcss/crosswind.git>
300
- cd crosswind
301
-
302
- # Install dependencies
303
-
304
- bun install
305
-
306
- # Run tests
307
-
308
- bun test
309
-
310
- # Run tests in watch mode
311
-
312
- bun test --watch
313
-
314
- # Run performance benchmarks
315
-
316
- bun test test/performance.test.ts
317
-
318
- # Type check
319
-
320
- bun run typecheck
321
-
322
- # Build the package
323
-
324
- bun run build
325
-
326
26
  ```
327
27
 
328
- ## Documentation
329
-
330
- For comprehensive documentation, visit [crosswind.stacksjs.org](https://crosswind.stacksjs.org)
331
-
332
- - [Installation Guide](https://crosswind.stacksjs.org/install)
333
- - [Usage Guide](https://crosswind.stacksjs.org/usage)
334
- - [Configuration](https://crosswind.stacksjs.org/config)
335
- - [CLI Reference](https://crosswind.stacksjs.org/features/cli)
336
- - [API Reference](https://crosswind.stacksjs.org/api-reference)
337
-
338
- ## Changelog
339
-
340
- Please see our [releases](https://github.com/cwcss/crosswind/releases) page for more information on what has changed recently.
341
-
342
- ## Contributing
343
-
344
- Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
345
-
346
- We welcome contributions! Whether it's:
347
-
348
- - 🐛 Bug reports and fixes
349
- - ✨ New utility classes or features
350
- - 📝 Documentation improvements
351
- - ⚡️ Performance optimizations
352
- - 🧪 Additional test coverage
28
+ ### CLI
353
29
 
354
- ## Community
355
-
356
- For help, discussion about best practices, or any other conversation that would benefit from being searchable:
357
-
358
- [Discussions on GitHub](https://github.com/cwcss/crosswind/discussions)
359
-
360
- For casual chit-chat with others using this package:
361
-
362
- [Join the Stacks Discord Server](https://discord.gg/stacksjs)
363
-
364
- ## Postcardware
365
-
366
- “Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
367
-
368
- Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
369
-
370
- ## Sponsors
30
+ ```bash
31
+ # Run the crosswind CLI
32
+ crosswind build
33
+ crosswind build --watch
34
+ crosswind build --minify
35
+ ```
371
36
 
372
- We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
37
+ ## Features
373
38
 
374
- - [JetBrains](https://www.jetbrains.com/)
375
- - [The Solana Foundation](https://solana.com/)
39
+ - On-demand utility CSS generation
40
+ - Tailwind-compatible utility classes
41
+ - Built-in CSS minification
42
+ - File watching for development
43
+ - Configurable theme (colors, spacing, typography, etc.)
44
+ - Variant support (hover, focus, dark mode, responsive, and more)
45
+ - Custom rules and shortcuts
46
+ - Preset system for extensibility
47
+ - Bun plugin support
48
+ - Cross-platform CLI binaries (Linux, macOS, Windows)
376
49
 
377
50
  ## License
378
51
 
379
- The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
380
-
381
- Made with 💙
382
-
383
- <!-- Badges -->
384
- [npm-version-src]: <https://img.shields.io/npm/v/crosswind?style=flat-square>
385
- [npm-version-href]: <https://npmjs.com/package/crosswind>
386
- [github-actions-src]: <https://img.shields.io/github/actions/workflow/status/cwcss/crosswind/ci.yml?style=flat-square&branch=main>
387
- [github-actions-href]: <https://github.com/cwcss/crosswind/actions?query=workflow%3Aci>
388
-
389
- <!-- [codecov-src]: <https://img.shields.io/codecov/c/gh/cwcss/crosswind/main?style=flat-square>
390
- [codecov-href]: <https://codecov.io/gh/cwcss/crosswind> -->
52
+ MIT