@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.
- package/LICENSE.md +21 -0
- package/README.md +390 -0
- package/dist/build.d.ts +24 -0
- package/dist/config.d.ts +5 -0
- package/dist/generator.d.ts +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +12798 -0
- package/dist/parser.d.ts +42 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/preflight-forms.d.ts +5 -0
- package/dist/preflight.d.ts +2 -0
- package/dist/rules-advanced.d.ts +27 -0
- package/dist/rules-effects.d.ts +25 -0
- package/dist/rules-forms.d.ts +7 -0
- package/dist/rules-grid.d.ts +13 -0
- package/dist/rules-interactivity.d.ts +41 -0
- package/dist/rules-layout.d.ts +26 -0
- package/dist/rules-transforms.d.ts +33 -0
- package/dist/rules-typography.d.ts +41 -0
- package/dist/rules.d.ts +39 -0
- package/dist/scanner.d.ts +18 -0
- package/dist/transformer-compile-class.d.ts +37 -0
- package/{src/types.ts → dist/types.d.ts} +17 -86
- package/package.json +1 -1
- package/PLUGIN.md +0 -235
- package/benchmark/framework-comparison.bench.ts +0 -850
- package/bin/cli.ts +0 -365
- package/bin/crosswind +0 -0
- package/bin/headwind +0 -0
- package/build.ts +0 -8
- package/crosswind.config.ts +0 -9
- package/example/comprehensive.html +0 -70
- package/example/index.html +0 -21
- package/example/output.css +0 -236
- package/examples/plugin/README.md +0 -112
- package/examples/plugin/build.ts +0 -32
- package/examples/plugin/src/index.html +0 -34
- package/examples/plugin/src/index.ts +0 -7
- package/headwind +0 -2
- package/src/build.ts +0 -101
- package/src/config.ts +0 -529
- package/src/generator.ts +0 -2173
- package/src/index.ts +0 -10
- package/src/parser.ts +0 -1471
- package/src/plugin.ts +0 -118
- package/src/preflight-forms.ts +0 -229
- package/src/preflight.ts +0 -388
- package/src/rules-advanced.ts +0 -477
- package/src/rules-effects.ts +0 -461
- package/src/rules-forms.ts +0 -103
- package/src/rules-grid.ts +0 -241
- package/src/rules-interactivity.ts +0 -525
- package/src/rules-layout.ts +0 -385
- package/src/rules-transforms.ts +0 -412
- package/src/rules-typography.ts +0 -486
- package/src/rules.ts +0 -809
- package/src/scanner.ts +0 -84
- package/src/transformer-compile-class.ts +0 -275
- package/test/advanced-features.test.ts +0 -911
- package/test/arbitrary.test.ts +0 -396
- package/test/attributify.test.ts +0 -592
- package/test/bracket-syntax.test.ts +0 -1133
- package/test/build.test.ts +0 -99
- package/test/colors.test.ts +0 -934
- package/test/flexbox.test.ts +0 -669
- package/test/generator.test.ts +0 -597
- package/test/grid.test.ts +0 -584
- package/test/layout.test.ts +0 -404
- package/test/modifiers.test.ts +0 -417
- package/test/parser.test.ts +0 -564
- package/test/performance-regression.test.ts +0 -376
- package/test/performance.test.ts +0 -568
- package/test/plugin.test.ts +0 -160
- package/test/scanner.test.ts +0 -94
- package/test/sizing.test.ts +0 -481
- package/test/spacing.test.ts +0 -394
- package/test/transformer-compile-class.test.ts +0 -287
- package/test/transforms.test.ts +0 -448
- package/test/typography.test.ts +0 -632
- package/test/variants-form-states.test.ts +0 -225
- package/test/variants-group-peer.test.ts +0 -66
- package/test/variants-media.test.ts +0 -213
- package/test/variants-positional.test.ts +0 -58
- package/test/variants-pseudo-elements.test.ts +0 -47
- package/test/variants-state.test.ts +0 -62
- package/tsconfig.json +0 -18
package/test/plugin.test.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { afterAll, beforeAll, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { mkdir, rm, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { plugin } from '../src/plugin'
|
|
5
|
-
|
|
6
|
-
const TEST_DIR = join(import.meta.dir, '.plugin-test')
|
|
7
|
-
const DIST_DIR = join(TEST_DIR, 'dist')
|
|
8
|
-
|
|
9
|
-
describe('bun plugin', () => {
|
|
10
|
-
beforeAll(async () => {
|
|
11
|
-
await mkdir(TEST_DIR, { recursive: true })
|
|
12
|
-
await mkdir(DIST_DIR, { recursive: true })
|
|
13
|
-
|
|
14
|
-
// Create test HTML file
|
|
15
|
-
await writeFile(
|
|
16
|
-
join(TEST_DIR, 'index.html'),
|
|
17
|
-
`<!DOCTYPE html>
|
|
18
|
-
<html lang="en">
|
|
19
|
-
<head>
|
|
20
|
-
<meta charset="UTF-8">
|
|
21
|
-
<title>Test</title>
|
|
22
|
-
</head>
|
|
23
|
-
<body>
|
|
24
|
-
<div class="flex items-center justify-between p-4 bg-blue-500 text-white rounded-lg shadow-md hover:bg-blue-600">
|
|
25
|
-
<h1 class="text-2xl font-bold">Hello Crosswind!</h1>
|
|
26
|
-
</div>
|
|
27
|
-
</body>
|
|
28
|
-
</html>`,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
// Create a TypeScript entrypoint that imports the HTML
|
|
32
|
-
await writeFile(
|
|
33
|
-
join(TEST_DIR, 'index.ts'),
|
|
34
|
-
`import html from './index.html'
|
|
35
|
-
export default html
|
|
36
|
-
`,
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
afterAll(async () => {
|
|
41
|
-
await rm(TEST_DIR, { recursive: true, force: true })
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('should process HTML files and inject CSS', async () => {
|
|
45
|
-
const result = await Bun.build({
|
|
46
|
-
entrypoints: [join(TEST_DIR, 'index.ts')],
|
|
47
|
-
outdir: DIST_DIR,
|
|
48
|
-
plugins: [
|
|
49
|
-
plugin({
|
|
50
|
-
config: {
|
|
51
|
-
minify: false,
|
|
52
|
-
},
|
|
53
|
-
includePreflight: false,
|
|
54
|
-
}),
|
|
55
|
-
],
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
expect(result.success).toBe(true)
|
|
59
|
-
expect(result.outputs.length).toBeGreaterThan(0)
|
|
60
|
-
|
|
61
|
-
// Read the output content
|
|
62
|
-
const output = await result.outputs[0].text()
|
|
63
|
-
|
|
64
|
-
// Check that CSS was injected
|
|
65
|
-
expect(output).toContain('<style>')
|
|
66
|
-
expect(output).toContain('</style>')
|
|
67
|
-
|
|
68
|
-
// Check for utility classes in the CSS
|
|
69
|
-
expect(output).toContain('.flex')
|
|
70
|
-
expect(output).toContain('display: flex')
|
|
71
|
-
expect(output).toContain('.items-center')
|
|
72
|
-
expect(output).toContain('.p-4')
|
|
73
|
-
expect(output).toContain('padding: 1rem')
|
|
74
|
-
expect(output).toContain('.bg-blue-500')
|
|
75
|
-
expect(output).toContain('.text-white')
|
|
76
|
-
expect(output).toContain('.rounded-lg')
|
|
77
|
-
expect(output).toContain('.shadow-md')
|
|
78
|
-
expect(output).toContain('.text-2xl')
|
|
79
|
-
expect(output).toContain('.font-bold')
|
|
80
|
-
|
|
81
|
-
// Check for hover variant (note: double backslash in bundled output)
|
|
82
|
-
expect(output).toContain(':bg-blue-600:hover')
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('should respect minify option', async () => {
|
|
86
|
-
const result = await Bun.build({
|
|
87
|
-
entrypoints: [join(TEST_DIR, 'index.ts')],
|
|
88
|
-
outdir: DIST_DIR,
|
|
89
|
-
plugins: [
|
|
90
|
-
plugin({
|
|
91
|
-
config: {
|
|
92
|
-
minify: true,
|
|
93
|
-
},
|
|
94
|
-
includePreflight: false,
|
|
95
|
-
}),
|
|
96
|
-
],
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
expect(result.success).toBe(true)
|
|
100
|
-
const output = await result.outputs[0].text()
|
|
101
|
-
|
|
102
|
-
// Minified CSS should not contain extra whitespace
|
|
103
|
-
const styleMatch = output.match(/<style>(.*?)<\/style>/s)
|
|
104
|
-
expect(styleMatch).toBeTruthy()
|
|
105
|
-
|
|
106
|
-
if (styleMatch) {
|
|
107
|
-
const css = styleMatch[1]
|
|
108
|
-
// Minified CSS should not have newlines or multiple spaces
|
|
109
|
-
expect(css).not.toContain('\n\n')
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('should work with custom config', async () => {
|
|
114
|
-
const result = await Bun.build({
|
|
115
|
-
entrypoints: [join(TEST_DIR, 'index.ts')],
|
|
116
|
-
outdir: DIST_DIR,
|
|
117
|
-
plugins: [
|
|
118
|
-
plugin({
|
|
119
|
-
config: {
|
|
120
|
-
minify: false,
|
|
121
|
-
theme: {
|
|
122
|
-
colors: {
|
|
123
|
-
custom: '#123456',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
includePreflight: false,
|
|
128
|
-
}),
|
|
129
|
-
],
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
expect(result.success).toBe(true)
|
|
133
|
-
const output = await result.outputs[0].text()
|
|
134
|
-
|
|
135
|
-
// Standard utilities should still work
|
|
136
|
-
expect(output).toContain('.flex')
|
|
137
|
-
expect(output).toContain('.p-4')
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('should include preflight CSS when enabled', async () => {
|
|
141
|
-
const result = await Bun.build({
|
|
142
|
-
entrypoints: [join(TEST_DIR, 'index.ts')],
|
|
143
|
-
outdir: DIST_DIR,
|
|
144
|
-
plugins: [
|
|
145
|
-
plugin({
|
|
146
|
-
config: {
|
|
147
|
-
minify: false,
|
|
148
|
-
},
|
|
149
|
-
includePreflight: true,
|
|
150
|
-
}),
|
|
151
|
-
],
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
expect(result.success).toBe(true)
|
|
155
|
-
const output = await result.outputs[0].text()
|
|
156
|
-
|
|
157
|
-
// Check for preflight CSS (reset styles)
|
|
158
|
-
expect(output).toContain('box-sizing: border-box')
|
|
159
|
-
})
|
|
160
|
-
})
|
package/test/scanner.test.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { afterAll, beforeAll, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { mkdir, rm, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import { Scanner } from '../src/scanner'
|
|
5
|
-
|
|
6
|
-
const TEST_DIR = join(import.meta.dir, '.scanner-test')
|
|
7
|
-
|
|
8
|
-
describe('Scanner', () => {
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
// Create test directory and files
|
|
11
|
-
await mkdir(TEST_DIR, { recursive: true })
|
|
12
|
-
|
|
13
|
-
await writeFile(
|
|
14
|
-
join(TEST_DIR, 'test1.html'),
|
|
15
|
-
'<div class="flex p-4 bg-blue-500"></div>',
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
await writeFile(
|
|
19
|
-
join(TEST_DIR, 'test2.tsx'),
|
|
20
|
-
'export const Button = () => <button className="px-4 py-2 rounded">Click</button>',
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
await writeFile(
|
|
24
|
-
join(TEST_DIR, 'test3.jsx'),
|
|
25
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
26
|
-
'<div className={`text-center ${active ? "font-bold" : ""}`}>Text</div>',
|
|
27
|
-
)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
afterAll(async () => {
|
|
31
|
-
// Clean up test directory
|
|
32
|
-
await rm(TEST_DIR, { recursive: true, force: true })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('scanContent', () => {
|
|
36
|
-
it('should scan content string for classes', () => {
|
|
37
|
-
const scanner = new Scanner([])
|
|
38
|
-
const classes = scanner.scanContent('<div class="flex p-4"></div>')
|
|
39
|
-
expect(classes).toEqual(new Set(['flex', 'p-4']))
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
describe('scanFile', () => {
|
|
44
|
-
it('should scan a single file', async () => {
|
|
45
|
-
const scanner = new Scanner([])
|
|
46
|
-
const classes = await scanner.scanFile(join(TEST_DIR, 'test1.html'))
|
|
47
|
-
expect(classes).toEqual(new Set(['flex', 'p-4', 'bg-blue-500']))
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should return empty set for non-existent file', async () => {
|
|
51
|
-
const scanner = new Scanner([])
|
|
52
|
-
const classes = await scanner.scanFile(join(TEST_DIR, 'non-existent.html'))
|
|
53
|
-
expect(classes.size).toBe(0)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
describe('scan', () => {
|
|
58
|
-
it('should scan all files matching pattern', async () => {
|
|
59
|
-
const scanner = new Scanner([join(TEST_DIR, '*.html')])
|
|
60
|
-
const { classes } = await scanner.scan()
|
|
61
|
-
expect(classes.has('flex')).toBe(true)
|
|
62
|
-
expect(classes.has('p-4')).toBe(true)
|
|
63
|
-
expect(classes.has('bg-blue-500')).toBe(true)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should scan multiple patterns', async () => {
|
|
67
|
-
const scanner = new Scanner([
|
|
68
|
-
join(TEST_DIR, '*.html'),
|
|
69
|
-
join(TEST_DIR, '*.tsx'),
|
|
70
|
-
])
|
|
71
|
-
const { classes } = await scanner.scan()
|
|
72
|
-
expect(classes.has('flex')).toBe(true)
|
|
73
|
-
expect(classes.has('px-4')).toBe(true)
|
|
74
|
-
expect(classes.has('py-2')).toBe(true)
|
|
75
|
-
expect(classes.has('rounded')).toBe(true)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('should handle JSX files', async () => {
|
|
79
|
-
const scanner = new Scanner([join(TEST_DIR, '*.jsx')])
|
|
80
|
-
const { classes } = await scanner.scan()
|
|
81
|
-
expect(classes.has('text-center')).toBe(true)
|
|
82
|
-
expect(classes.has('font-bold')).toBe(true)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('should scan all file types with glob pattern', async () => {
|
|
86
|
-
const scanner = new Scanner([join(TEST_DIR, '*.{html,tsx,jsx}')])
|
|
87
|
-
const { classes } = await scanner.scan()
|
|
88
|
-
expect(classes.size).toBeGreaterThan(5)
|
|
89
|
-
expect(classes.has('flex')).toBe(true)
|
|
90
|
-
expect(classes.has('px-4')).toBe(true)
|
|
91
|
-
expect(classes.has('text-center')).toBe(true)
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
})
|