@cwcss/crosswind 0.1.5 → 0.1.6

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 (86) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +390 -0
  3. package/dist/build.d.ts +24 -0
  4. package/dist/config.d.ts +5 -0
  5. package/dist/generator.d.ts +31 -0
  6. package/dist/index.d.ts +10 -0
  7. package/dist/index.js +12798 -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/transformer-compile-class.d.ts +37 -0
  23. package/{src/types.ts → dist/types.d.ts} +17 -86
  24. package/package.json +1 -1
  25. package/PLUGIN.md +0 -235
  26. package/benchmark/framework-comparison.bench.ts +0 -850
  27. package/bin/cli.ts +0 -365
  28. package/bin/crosswind +0 -0
  29. package/bin/headwind +0 -0
  30. package/build.ts +0 -8
  31. package/crosswind.config.ts +0 -9
  32. package/example/comprehensive.html +0 -70
  33. package/example/index.html +0 -21
  34. package/example/output.css +0 -236
  35. package/examples/plugin/README.md +0 -112
  36. package/examples/plugin/build.ts +0 -32
  37. package/examples/plugin/src/index.html +0 -34
  38. package/examples/plugin/src/index.ts +0 -7
  39. package/headwind +0 -2
  40. package/src/build.ts +0 -101
  41. package/src/config.ts +0 -529
  42. package/src/generator.ts +0 -2173
  43. package/src/index.ts +0 -10
  44. package/src/parser.ts +0 -1471
  45. package/src/plugin.ts +0 -118
  46. package/src/preflight-forms.ts +0 -229
  47. package/src/preflight.ts +0 -388
  48. package/src/rules-advanced.ts +0 -477
  49. package/src/rules-effects.ts +0 -461
  50. package/src/rules-forms.ts +0 -103
  51. package/src/rules-grid.ts +0 -241
  52. package/src/rules-interactivity.ts +0 -525
  53. package/src/rules-layout.ts +0 -385
  54. package/src/rules-transforms.ts +0 -412
  55. package/src/rules-typography.ts +0 -486
  56. package/src/rules.ts +0 -809
  57. package/src/scanner.ts +0 -84
  58. package/src/transformer-compile-class.ts +0 -275
  59. package/test/advanced-features.test.ts +0 -911
  60. package/test/arbitrary.test.ts +0 -396
  61. package/test/attributify.test.ts +0 -592
  62. package/test/bracket-syntax.test.ts +0 -1133
  63. package/test/build.test.ts +0 -99
  64. package/test/colors.test.ts +0 -934
  65. package/test/flexbox.test.ts +0 -669
  66. package/test/generator.test.ts +0 -597
  67. package/test/grid.test.ts +0 -584
  68. package/test/layout.test.ts +0 -404
  69. package/test/modifiers.test.ts +0 -417
  70. package/test/parser.test.ts +0 -564
  71. package/test/performance-regression.test.ts +0 -376
  72. package/test/performance.test.ts +0 -568
  73. package/test/plugin.test.ts +0 -160
  74. package/test/scanner.test.ts +0 -94
  75. package/test/sizing.test.ts +0 -481
  76. package/test/spacing.test.ts +0 -394
  77. package/test/transformer-compile-class.test.ts +0 -287
  78. package/test/transforms.test.ts +0 -448
  79. package/test/typography.test.ts +0 -632
  80. package/test/variants-form-states.test.ts +0 -225
  81. package/test/variants-group-peer.test.ts +0 -66
  82. package/test/variants-media.test.ts +0 -213
  83. package/test/variants-positional.test.ts +0 -58
  84. package/test/variants-pseudo-elements.test.ts +0 -47
  85. package/test/variants-state.test.ts +0 -62
  86. package/tsconfig.json +0 -18
package/PLUGIN.md DELETED
@@ -1,235 +0,0 @@
1
- # Crosswind Bun Plugin
2
-
3
- A Bun plugin that automatically generates and injects Crosswind CSS into your HTML files during the build process.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- bun add @cwcss/crosswind
9
- ```
10
-
11
- ## Quick Start
12
-
13
- **1. Create your HTML file** (`src/template.html`):
14
-
15
- ```html
16
- <!DOCTYPE html>
17
- <html>
18
- <head>
19
- <title>My App</title>
20
- </head>
21
- <body>
22
- <div class="flex items-center p-4 bg-blue-500 text-white rounded-lg">
23
- <h1 class="text-2xl font-bold">Hello Crosswind!</h1>
24
- </div>
25
- </body>
26
- </html>
27
- ```
28
-
29
- **2. Import it in your TypeScript** (`src/index.ts`):
30
-
31
- ```typescript
32
- import template from './template.html'
33
-
34
- // The HTML now has Crosswind CSS injected
35
- document.body.innerHTML = template
36
- ```
37
-
38
- **3. Build with the plugin**:
39
-
40
- ```typescript
41
- import { plugin } from '@cwcss/crosswind'
42
-
43
- await Bun.build({
44
- entrypoints: ['./src/index.ts'],
45
- outdir: './dist',
46
- plugins: [plugin()],
47
- })
48
- ```
49
-
50
- The plugin will automatically:
51
-
52
- - Scan the HTML for utility classes
53
- - Generate CSS for those classes
54
- - Inject the CSS into the `<head>` section
55
-
56
- ## Configuration
57
-
58
- ### Basic Configuration
59
-
60
- ```typescript
61
- import { plugin } from '@cwcss/crosswind'
62
-
63
- await Bun.build({
64
- entrypoints: ['./src/index.ts'],
65
- outdir: './dist',
66
- plugins: [
67
- plugin({
68
- includePreflight: true, // Include CSS reset (default: true)
69
- }),
70
- ],
71
- })
72
- ```
73
-
74
- ### Custom Theme
75
-
76
- ```typescript
77
- import { plugin } from '@cwcss/crosswind'
78
-
79
- await Bun.build({
80
- entrypoints: ['./src/index.ts'],
81
- outdir: './dist',
82
- plugins: [
83
- plugin({
84
- config: {
85
- minify: true,
86
- theme: {
87
- colors: {
88
- primary: '#3b82f6',
89
- secondary: '#10b981',
90
- danger: '#ef4444',
91
- },
92
- spacing: {
93
- 18: '4.5rem',
94
- 88: '22rem',
95
- },
96
- },
97
- shortcuts: {
98
- btn: 'px-4 py-2 rounded bg-primary text-white hover:bg-blue-600',
99
- card: 'p-6 bg-white rounded-lg shadow-md',
100
- },
101
- },
102
- }),
103
- ],
104
- })
105
- ```
106
-
107
- ### Advanced Configuration
108
-
109
- ```typescript
110
- import { plugin } from '@cwcss/crosswind'
111
-
112
- await Bun.build({
113
- entrypoints: ['./src/index.ts'],
114
- outdir: './dist',
115
- plugins: [
116
- plugin({
117
- config: {
118
- minify: true,
119
- safelist: ['bg-red-500', 'text-green-500'], // Always include these
120
- blocklist: ['debug-*'], // Never include these
121
- theme: {
122
- colors: {
123
- brand: {
124
- 50: '#f0f9ff',
125
- 100: '#e0f2fe',
126
- 500: '#0ea5e9',
127
- 900: '#0c4a6e',
128
- },
129
- },
130
- },
131
- shortcuts: {
132
- 'btn-primary': 'px-4 py-2 rounded bg-brand-500 text-white hover:bg-brand-600',
133
- },
134
- },
135
- includePreflight: true,
136
- }),
137
- ],
138
- })
139
- ```
140
-
141
- ## API Reference
142
-
143
- ### `plugin(options?)`
144
-
145
- Creates a Crosswind Bun plugin instance.
146
-
147
- #### Options
148
-
149
- - **`config`** (`Partial<CrosswindConfig>`) - Custom Crosswind configuration
150
- - `minify` - Minify the generated CSS
151
- - `theme` - Custom theme (colors, spacing, fonts, etc.)
152
- - `shortcuts` - Utility class shortcuts
153
- - `safelist` - Classes to always include
154
- - `blocklist` - Classes to never include
155
- - `variants` - Enable/disable variants
156
- - And more...
157
-
158
- - **`includePreflight`** (`boolean`) - Include preflight CSS (default: `true`)
159
-
160
- ## How It Works
161
-
162
- 1. The plugin registers an `onLoad` handler for `.html` files
163
- 2. When Bun encounters an HTML import, the plugin intercepts it
164
- 3. It extracts all utility classes from the HTML using Crosswind's parser
165
- 4. It generates CSS for those classes using Crosswind's generator
166
- 5. The CSS is injected into the `<head>` section
167
- 6. The processed HTML is returned to the bundle
168
-
169
- ## Use Cases
170
-
171
- - **SPAs**: Import HTML templates with automatic CSS generation
172
- - **Web Components**: Load component templates with scoped styles
173
- - **Static Sites**: Process HTML pages during build
174
- - **Email Templates**: Generate inline CSS for email HTML
175
-
176
- ## Examples
177
-
178
- See the [examples/plugin](./examples/plugin) directory for a complete working example.
179
-
180
- ## Comparison with CLI
181
-
182
- | Feature | Plugin | CLI |
183
- |---------|--------|-----|
184
- | Automatic CSS generation | ✅ | ✅ |
185
- | Watches files | ✅ (via Bun) | ✅ |
186
- | Injects CSS | ✅ | ❌ |
187
- | Separate CSS file | ❌ | ✅ |
188
- | Build integration | ✅ | ❌ |
189
- | Standalone usage | ❌ | ✅ |
190
-
191
- ## Performance
192
-
193
- The plugin is highly performant:
194
-
195
- - Processes 1000 utilities in ~7ms
196
- - Minimal overhead in build process
197
- - Lazy loading - only processes imported HTML files
198
-
199
- ## TypeScript Support
200
-
201
- The plugin is fully typed. Import the types:
202
-
203
- ```typescript
204
- import type { CrosswindPluginOptions } from '@cwcss/crosswind'
205
-
206
- const options: CrosswindPluginOptions = {
207
- config: {
208
- minify: true,
209
- },
210
- }
211
- ```
212
-
213
- ## Configuration File
214
-
215
- The plugin also respects `crosswind.config.ts` in your project root:
216
-
217
- ```typescript
218
- // crosswind.config.ts
219
- import type { CrosswindOptions } from '@cwcss/crosswind'
220
-
221
- export default {
222
- minify: true,
223
- theme: {
224
- colors: {
225
- primary: '#3b82f6',
226
- },
227
- },
228
- } satisfies CrosswindOptions
229
- ```
230
-
231
- The plugin will merge this config with any options passed to it.
232
-
233
- ## License
234
-
235
- MIT