tailwind-styled-v4 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to `tailwind-styled-v4` will be documented here.
4
+
5
+ ## [1.0.0] — Initial Release
6
+
7
+ ### Added
8
+
9
+ #### Core Engine
10
+ - `tw` proxy — template literal & object config syntax
11
+ - `tw.tag\`classes\`` — template literal API
12
+ - `tw.tag({ base, variants, compoundVariants, defaultVariants })` — object config API
13
+ - `tw(Component)\`classes\`` — wrap any existing component
14
+ - `Component.extend\`extra-classes\`` — chain extra classes
15
+ - `Component.withVariants(config)` — merge new variants
16
+
17
+ #### Runtime Engines
18
+ - **propEngine** — 80+ props (padding, margin, sizing, colors, flex, grid, layout, effects, animation, interaction)
19
+ - **responsiveEngine** — `{ base, sm, md, lg, xl, 2xl }` responsive objects
20
+ - **variantEngine** — CVA-style variants with `defaultVariants` support
21
+ - **compoundVariant** — multi-condition compound variants
22
+ - **classResolver** — central resolver combining all engines via `tailwind-merge`
23
+
24
+ #### Standalone APIs
25
+ - `cv()` — standalone class variants function (shadcn/ui & Radix compatible)
26
+ - `withTw(Component, base?)` — HOC untuk wrap third-party components
27
+ - `cls\`...\`` — tagged template for static class strings
28
+ - `cx(...inputs)` — lightweight class joiner (~100b, zero-dep)
29
+ - `cxm(...inputs)` — cx + tailwind-merge deduplication
30
+
31
+ #### Plugin System
32
+ - `registerPlugin({ name, props })` — custom prop resolver plugins
33
+ - `loadBuiltinPlugins()` — 6 built-in plugins: animation, grid, backdrop, gradient, scroll, print
34
+ - `listPlugins()` / `getPlugin(name)` — plugin introspection
35
+
36
+ #### Theme System
37
+ - `setTheme(tokens)` — deep-merge semantic tokens
38
+ - `replaceTheme(tokens)` — replace entire theme
39
+ - `getTheme()` / `getThemeNamespace(key)` — read current theme
40
+ - `onThemeChange(listener)` — subscription API
41
+ - `loadDefaultTheme()` — semantic token preset (primary, surface, muted, etc.)
42
+ - `loadDarkTheme()` — fintech/crypto/Web3 dark preset
43
+
44
+ #### Zero-Runtime Compiler
45
+ - `withTailwindStyled(opts)(nextConfig)` — Next.js HOC wrapper
46
+ - `tailwindStyledPlugin(opts)` — Vite plugin
47
+ - Webpack loader (`tailwind-styled-v4/webpack-loader`)
48
+ - Static transform: `tw.div\`p-4\`` → `styled.div.attrs(()=>({className:"p-4"}))\`\``
49
+ - Dynamic guard: skips interpolated templates (`${}`) safely
50
+ - `data-tw="tw-xxxxx"` attribute injection for DevTools (dev mode)
51
+
52
+ #### Build Tools
53
+ - `generateTailwindTypes.ts` — generates **58.055** Tailwind class type unions
54
+ - `generateSafelist.ts` — scans src/ and outputs `tailwind.safelist.json`
55
+ - `extractAllClasses(source)` — extract classes from any source string
56
+
57
+ #### IntelliSense
58
+ - **58.055 class definitions** in `tailwind.generated.ts`
59
+ - Coverage: all colors (21 palettes × 11 shades), spacing, sizing, flexbox, grid, effects, transitions, animations, responsive prefixes (sm/md/lg/xl/2xl), state prefixes (hover/focus/active/disabled/dark/group-hover/peer-hover/focus-visible/focus-within)
60
+
61
+ #### Developer Experience
62
+ - `shouldForwardProp` — tw props tidak bocor ke DOM attributes
63
+ - `blockProp(name)` / `allowProp(name)` — fine-grained forwarding control
64
+ - `hashClass(input)` → `"tw-xxxxx"` — stable component hash
65
+ - `componentName(tag, classes)` — display name generator for React DevTools
66
+ - Source maps enabled in all builds
67
+
68
+ #### Stack Compatibility
69
+ - Next.js 15/16 (App Router + Pages Router)
70
+ - React 18/19
71
+ - Tailwind CSS v3/v4
72
+ - styled-components v5/v6
73
+ - TypeScript 4.9/5.x
74
+ - shadcn/ui, Radix UI, Headless UI
75
+ - Vite 4/5, Webpack 4/5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 tailwind-styled-v4
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,330 @@
1
+ # tailwind-styled-v4
2
+
3
+ **PRO Engine** — styled-components + Tailwind CSS v4, zero-runtime compile option, variant system, responsive props, plugin ecosystem.
4
+
5
+ > Melampaui `twin.macro` dengan tetap kompatibel penuh terhadap Next.js 16 · React 19 · Tailwind CSS v4 · styled-components v6 · TypeScript 5 · shadcn/ui.
6
+
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install tailwind-styled-v4
13
+ # peerDependencies
14
+ npm install styled-components tailwind-merge clsx
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Quick Start
20
+
21
+ ### Template Literal (sederhana)
22
+
23
+ ```tsx
24
+ import { tw } from "tailwind-styled-v4"
25
+
26
+ const Card = tw.div`
27
+ p-6
28
+ bg-zinc-900
29
+ rounded-2xl
30
+ border border-zinc-800
31
+ `
32
+
33
+ // Responsive props inline
34
+ <Card p={{ base: 4, md: 6, lg: 8 }} />
35
+ // → p-4 md:p-6 lg:p-8
36
+ ```
37
+
38
+ ### Object Config (full power)
39
+
40
+ ```tsx
41
+ const Button = tw.button({
42
+ base: "inline-flex items-center justify-center rounded-lg font-medium transition",
43
+ variants: {
44
+ variant: {
45
+ primary: "bg-blue-600 text-white hover:bg-blue-700",
46
+ ghost: "bg-transparent border border-zinc-700 hover:bg-zinc-800",
47
+ danger: "bg-red-600 text-white hover:bg-red-700",
48
+ },
49
+ size: {
50
+ sm: "h-8 px-3 text-sm",
51
+ md: "h-10 px-4 text-sm",
52
+ lg: "h-12 px-6 text-base",
53
+ },
54
+ },
55
+ compoundVariants: [
56
+ { variant: "primary", size: "lg", class: "shadow-lg shadow-blue-600/30" },
57
+ ],
58
+ defaultVariants: { variant: "primary", size: "md" },
59
+ })
60
+
61
+ // Usage
62
+ <Button variant="primary" size="lg">Click me</Button>
63
+ <Button variant="ghost" size="sm">Cancel</Button>
64
+ ```
65
+
66
+ ### Extend existing component
67
+
68
+ ```tsx
69
+ const HeroCard = Card.extend`shadow-2xl ring-1 ring-zinc-700/50`
70
+ ```
71
+
72
+ ### Wrap any component (shadcn/ui, Radix, dll)
73
+
74
+ ```tsx
75
+ import { withTw, tw } from "tailwind-styled-v4"
76
+ import { Button } from "@/components/ui/button" // shadcn
77
+ import Link from "next/link"
78
+
79
+ const TwButton = withTw(Button, "px-4 py-2")
80
+ const NavLink = tw(Link)`text-zinc-400 hover:text-zinc-100 transition-colors`
81
+ ```
82
+
83
+ ### Standalone class variants (headless/shadcn compatible)
84
+
85
+ ```tsx
86
+ import { cv } from "tailwind-styled-v4"
87
+
88
+ const badgeCv = cv({
89
+ base: "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",
90
+ variants: {
91
+ color: {
92
+ blue: "bg-blue-100 text-blue-800",
93
+ green: "bg-green-100 text-green-800",
94
+ red: "bg-red-100 text-red-800",
95
+ }
96
+ },
97
+ defaultVariants: { color: "blue" }
98
+ })
99
+
100
+ // Use anywhere
101
+ <span className={badgeCv({ color: "green" })}>Active</span>
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Responsive Props
107
+
108
+ Semua props mendukung responsive object:
109
+
110
+ ```tsx
111
+ <Box
112
+ p={{ base: 2, sm: 4, md: 6, lg: 8 }}
113
+ cols={{ base: 1, sm: 2, lg: 3 }}
114
+ gap={{ base: 3, md: 4 }}
115
+ display="grid"
116
+ />
117
+ // → p-2 sm:p-4 md:p-6 lg:p-8 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 md:gap-4
118
+ ```
119
+
120
+ ### Available Props
121
+
122
+ | Category | Props |
123
+ |----------|-------|
124
+ | **Padding** | `p` `px` `py` `pt` `pb` `pl` `pr` |
125
+ | **Margin** | `m` `mx` `my` `mt` `mb` `ml` `mr` |
126
+ | **Gap** | `gap` `gapX` `gapY` `spaceX` `spaceY` |
127
+ | **Sizing** | `w` `h` `size` `minW` `maxW` `minH` `maxH` |
128
+ | **Colors** | `bg` `text` `border` `ring` `fill` `stroke` |
129
+ | **Typography** | `font` `fontSize` `leading` `tracking` `align` `truncate` `lineClamp` |
130
+ | **Flexbox** | `flex` `flexDir` `items` `justify` `wrap` `grow` `shrink` `basis` `self` |
131
+ | **Grid** | `cols` `rows` `colSpan` `rowSpan` `colStart` `colEnd` |
132
+ | **Layout** | `display` `overflow` `pos` `z` `top` `right` `bottom` `left` `inset` |
133
+ | **Border** | `rounded` `roundedT` `roundedB` `borderStyle` `outline` |
134
+ | **Effects** | `opacity` `shadow` `blur` `brightness` `contrast` `grayscale` `backdrop` |
135
+ | **Motion** | `transition` `duration` `ease` `delay` `animate` |
136
+ | **Interaction** | `cursor` `select` `pointer` `touch` |
137
+
138
+ ---
139
+
140
+ ## Zero-Runtime (Next.js)
141
+
142
+ Di production build, semua `tw.tag\`...\`` dikompilasi menjadi static string — zero JS runtime overhead.
143
+
144
+ ```ts
145
+ // next.config.ts
146
+ import { withTailwindStyled } from "tailwind-styled-v4/compiler"
147
+
148
+ export default withTailwindStyled({
149
+ mode: "zero-runtime", // "runtime" di dev, "zero-runtime" di production
150
+ addDataAttr: true, // data-tw="tw-3f2a1" untuk DevTools
151
+ generateSafelist: true, // auto-generate tailwind.safelist.json
152
+ })(/** nextConfig */ {})
153
+ ```
154
+
155
+ **Before (source):**
156
+ ```tsx
157
+ const Box = tw.div`p-4 bg-zinc-900 rounded-xl`
158
+ ```
159
+
160
+ **After (compiled output):**
161
+ ```tsx
162
+ const Box = styled.div.attrs(() => ({ className: "p-4 bg-zinc-900 rounded-xl" }))``
163
+ ```
164
+
165
+ Runtime cost: **0 bytes** untuk class resolution.
166
+
167
+ ---
168
+
169
+ ## Zero-Runtime (Vite)
170
+
171
+ ```ts
172
+ // vite.config.ts
173
+ import { tailwindStyledPlugin } from "tailwind-styled-v4/compiler"
174
+
175
+ export default defineConfig({
176
+ plugins: [react(), tailwindStyledPlugin({ mode: "zero-runtime" })],
177
+ })
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Plugin System
183
+
184
+ ```tsx
185
+ import { registerPlugin } from "tailwind-styled-v4"
186
+
187
+ // Custom plugin
188
+ registerPlugin({
189
+ name: "glass",
190
+ props: {
191
+ glass: v => v === true ? "bg-white/10 backdrop-blur-xl border border-white/10" : "",
192
+ frosted: v => v === true ? "bg-white/5 backdrop-blur-md saturate-150" : "",
193
+ }
194
+ })
195
+
196
+ // Usage
197
+ <Box glass /> // → bg-white/10 backdrop-blur-xl border border-white/10
198
+ <Box frosted /> // → bg-white/5 backdrop-blur-md saturate-150
199
+ ```
200
+
201
+ ### Built-in Plugins
202
+
203
+ ```tsx
204
+ import { loadBuiltinPlugins } from "tailwind-styled-v4"
205
+ loadBuiltinPlugins() // animation, grid, backdrop, gradient, scroll, print
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Theme System
211
+
212
+ ```tsx
213
+ import { setTheme, loadDefaultTheme, loadDarkTheme } from "tailwind-styled-v4"
214
+
215
+ // Preset themes
216
+ loadDefaultTheme() // semantic tokens: primary, surface, muted, dll
217
+ loadDarkTheme() // fintech/crypto/Web3 dark preset
218
+
219
+ // Custom tokens
220
+ setTheme({
221
+ colors: {
222
+ brand: "blue-600",
223
+ "brand-hover": "blue-700",
224
+ surface: "zinc-900",
225
+ },
226
+ radius: {
227
+ card: "2xl",
228
+ button: "lg",
229
+ },
230
+ })
231
+
232
+ // Now works everywhere
233
+ <Box bg="brand" rounded="card" />
234
+ // → bg-blue-600 rounded-2xl
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Safelist Generation
240
+
241
+ ```bash
242
+ npm run build:safelist
243
+ ```
244
+
245
+ Menghasilkan `tailwind.safelist.json` yang bisa direferensikan di `tailwind.config.ts`:
246
+
247
+ ```ts
248
+ // tailwind.config.ts
249
+ import safelist from "./tailwind.safelist.json"
250
+
251
+ export default {
252
+ safelist: safelist.safelist,
253
+ // ...
254
+ }
255
+ ```
256
+
257
+ ---
258
+
259
+ ## IntelliSense (VSCode)
260
+
261
+ Library ini menyertakan **58.055 class definitions** di `src/types/tailwind.generated.ts` untuk autocomplete penuh di VSCode termasuk semua modifier:
262
+
263
+ ```
264
+ bg-blue-500 ← base class
265
+ hover:bg-blue-500 ← hover state
266
+ md:bg-blue-500 ← responsive
267
+ dark:bg-blue-500 ← dark mode
268
+ dark:hover:bg-blue-500 ← combined
269
+ ```
270
+
271
+ Tambahkan ke `.vscode/settings.json`:
272
+ ```json
273
+ {
274
+ "tailwindCSS.experimental.classRegex": [
275
+ ["tw\\.\\w+`([^`]*)`", "([^`]*)"],
276
+ ["tw\\.\\w+\\(([^)]*)\\)", "\"([^\"]*)\""],
277
+ ["cv\\(([^)]*)\\)", "\"([^\"]*)\""]
278
+ ]
279
+ }
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Scripts
285
+
286
+ ```bash
287
+ npm run build # build library
288
+ npm run build:types # regenerate 58k class types
289
+ npm run build:safelist # scan src/ dan generate safelist
290
+ npm run dev # watch mode
291
+ npm run test # run all tests
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Comparison
297
+
298
+ | Feature | tailwind-styled-v4 | twin.macro | CVA | Stitches |
299
+ |---------|--------------------|------------|-----|----------|
300
+ | Template literal | ✅ | ✅ | ❌ | ❌ |
301
+ | Object config + variants | ✅ | ❌ | ✅ | ✅ |
302
+ | Compound variants | ✅ | ❌ | ✅ | ✅ |
303
+ | Responsive props | ✅ | ❌ | ❌ | ❌ |
304
+ | Zero-runtime | ✅ | ✅ | ❌ | ✅ |
305
+ | Plugin system | ✅ | ❌ | ❌ | ❌ |
306
+ | styled-components compat | ✅ | ✅ | ❌ | ❌ |
307
+ | shadcn/ui compat | ✅ | ❌ | ✅ | ❌ |
308
+ | Theme/token system | ✅ | ❌ | ❌ | ✅ |
309
+ | IntelliSense 58k classes | ✅ | ✅ | ❌ | ❌ |
310
+ | Wrap any component | ✅ | ❌ | ❌ | ❌ |
311
+
312
+ ---
313
+
314
+ ## Stack Compatibility
315
+
316
+ - **Next.js** 15 / 16 (App Router + Pages Router)
317
+ - **React** 18 / 19 (Server Components compatible)
318
+ - **Tailwind CSS** v3 / v4
319
+ - **styled-components** v5 / v6
320
+ - **TypeScript** 4.9 / 5.x
321
+ - **shadcn/ui** (semua komponen)
322
+ - **Radix UI** (via `withTw()`)
323
+ - **Vite** 4 / 5
324
+ - **Webpack** 4 / 5
325
+
326
+ ---
327
+
328
+ ## License
329
+
330
+ MIT
@@ -0,0 +1,214 @@
1
+ /**
2
+ * tailwind-styled-v4 — AST Transform Core
3
+ *
4
+ * Pure-string AST-like transformer yang menganalisis source code dan
5
+ * mengubah semua tw.tag`...` / tw.tag({...}) calls menjadi static
6
+ * className strings (zero-runtime output).
7
+ *
8
+ * Dipakai oleh:
9
+ * - swcPlugin.ts → SWC/Next.js transform
10
+ * - vitePlugin.ts → Vite/Rollup transform
11
+ * - nextPlugin.ts → Next.js webpack loader
12
+ * - postcssPlugin.ts → PostCSS safelist generation
13
+ *
14
+ * Zero-runtime berarti output akhirnya adalah:
15
+ * BEFORE: const Box = tw.div`p-4 bg-zinc-900`
16
+ * AFTER: const Box = styled.div``.attrs(()=>({className:"p-4 bg-zinc-900"}))``)
17
+ *
18
+ * Untuk kasus yang pure static (tidak ada dynamic expr),
19
+ * output bisa di-inline langsung sebagai string literal:
20
+ * AFTER: const Box = styled.div.attrs(()=>({className:"p-4 bg-zinc-900"}))``)
21
+ */
22
+ interface TransformOptions {
23
+ /**
24
+ * "runtime" → keep tw.tag, resolve at runtime (default dev mode)
25
+ * "zero-runtime"→ transform to styled.tag with static className
26
+ * "extract-only"→ do not transform, only extract class names
27
+ */
28
+ mode?: "runtime" | "zero-runtime" | "extract-only";
29
+ /** Add data-tw attribute for debugging in dev tools */
30
+ addDataAttr?: boolean;
31
+ /** Generate unique stable hash per component for CSS layer naming */
32
+ generateHash?: boolean;
33
+ /** Tailwind prefix (if configured in tailwind.config.ts) */
34
+ prefix?: string;
35
+ /** Filename being transformed — used for source maps */
36
+ filename?: string;
37
+ }
38
+ interface TransformResult {
39
+ code: string;
40
+ classes: string[];
41
+ map?: string;
42
+ changed: boolean;
43
+ }
44
+ declare function transformSource(source: string, opts?: TransformOptions): TransformResult;
45
+ declare function extractAllClasses(source: string): string[];
46
+ declare function transformBatch(files: Array<{
47
+ path: string;
48
+ source: string;
49
+ }>, opts?: TransformOptions): {
50
+ results: Array<TransformResult & {
51
+ path: string;
52
+ }>;
53
+ allClasses: string[];
54
+ };
55
+
56
+ /**
57
+ * tailwind-styled-v4 — transformTw
58
+ *
59
+ * Low-level transform used by all build plugins.
60
+ * Wraps astTransform with file-type filtering and source-map passthrough.
61
+ */
62
+
63
+ /**
64
+ * Transform a single file's source code.
65
+ * Returns unchanged code for non-JS/TS files.
66
+ */
67
+ declare function transformTw(source: string, opts?: TransformOptions & {
68
+ filepath?: string;
69
+ }): TransformResult;
70
+ /**
71
+ * Extract all Tailwind classes from source without transforming.
72
+ * Used for safelist generation.
73
+ */
74
+ declare function extractTwClasses(source: string): string[];
75
+ /**
76
+ * Check whether a file should be processed by the transform.
77
+ */
78
+ declare function shouldProcess(filepath: string): boolean;
79
+
80
+ /**
81
+ * tailwind-styled-v4 — SWC Plugin / Next.js Transform
82
+ *
83
+ * Integrates with Next.js compiler (SWC-based) via next.config.ts.
84
+ * Supports both Webpack and Turbopack (Next.js 15.3+).
85
+ *
86
+ * Usage in next.config.ts:
87
+ * ─────────────────────────────────────────────────────────────
88
+ * import { withTailwindStyled } from "tailwind-styled-v4/compiler"
89
+ *
90
+ * const nextConfig = withTailwindStyled({
91
+ * mode: "zero-runtime",
92
+ * addDataAttr: true,
93
+ * generateHash: true,
94
+ * })({
95
+ * // ...your Next.js config
96
+ * })
97
+ *
98
+ * export default nextConfig
99
+ * ─────────────────────────────────────────────────────────────
100
+ *
101
+ * What it does at build time:
102
+ * BEFORE: const Box = tw.div`p-4 bg-zinc-900 rounded-xl`
103
+ * AFTER: const Box = styled.div.attrs(()=>({className:"p-4 bg-zinc-900 rounded-xl"}))`
104
+ *
105
+ * Turbopack support (Next.js 15.3+):
106
+ * ─────────────────────────────────────────────────────────────
107
+ * Turbopack does not support webpack loaders. Instead it uses
108
+ * experimental.turbopack.rules. withTailwindStyled automatically
109
+ * detects and configures both bundlers.
110
+ */
111
+
112
+ interface SwcPluginOptions extends TransformOptions {
113
+ /**
114
+ * Directories to scan for class extraction (safelist generation).
115
+ * Defaults to ["src", "app", "pages", "components"]
116
+ */
117
+ scanDirs?: string[];
118
+ /**
119
+ * Output path for generated safelist JSON.
120
+ * Defaults to "tailwind.safelist.json"
121
+ */
122
+ safelistOutput?: string;
123
+ /**
124
+ * Whether to generate the safelist file on each build.
125
+ * Defaults to true
126
+ */
127
+ generateSafelist?: boolean;
128
+ }
129
+ declare function turbopackTransform(source: string, resourcePath: string, opts?: TransformOptions): {
130
+ code: string;
131
+ };
132
+ declare function withTailwindStyled(pluginOpts?: SwcPluginOptions): (nextConfig?: Record<string, any>) => Record<string, any>;
133
+ declare function swcTransformFile(source: string, filepath: string, opts?: TransformOptions): string;
134
+ interface SafelistOptions {
135
+ scanDirs: string[];
136
+ outputPath: string;
137
+ cwd: string;
138
+ }
139
+ declare function runSafelistGeneration(opts: SafelistOptions): void;
140
+ declare function swcPlugin(source: string, opts?: TransformOptions): string;
141
+
142
+ /**
143
+ * tailwind-styled-v4 — Vite Plugin
144
+ *
145
+ * Usage in vite.config.ts:
146
+ * ─────────────────────────────────────────────────────────────
147
+ * import { tailwindStyledPlugin } from "tailwind-styled-v4/compiler"
148
+ *
149
+ * export default defineConfig({
150
+ * plugins: [
151
+ * react(),
152
+ * tailwindStyledPlugin({
153
+ * mode: "zero-runtime",
154
+ * addDataAttr: true,
155
+ * }),
156
+ * ],
157
+ * })
158
+ * ─────────────────────────────────────────────────────────────
159
+ *
160
+ * Compatible with: Vite 4+, Remix, SvelteKit (JS files only)
161
+ */
162
+
163
+ interface VitePluginOptions extends TransformOptions {
164
+ /** Include patterns. Default: all .tsx/.ts/.jsx/.js */
165
+ include?: RegExp;
166
+ /** Exclude patterns. Default: node_modules */
167
+ exclude?: RegExp;
168
+ /** Directories to scan for safelist generation */
169
+ scanDirs?: string[];
170
+ /** Output path for safelist JSON */
171
+ safelistOutput?: string;
172
+ /** Generate safelist on build end */
173
+ generateSafelist?: boolean;
174
+ }
175
+ declare function tailwindStyledPlugin(opts?: VitePluginOptions): any;
176
+
177
+ /**
178
+ * tailwind-styled-v4 — Safelist Generator
179
+ *
180
+ * Scans your entire src/ directory and extracts every Tailwind class
181
+ * used via tw.tag`...`, className="...", cn(), etc.
182
+ *
183
+ * The output JSON can be referenced in your tailwind.config.ts:
184
+ *
185
+ * ─────────────────────────────────────────────────────────────
186
+ * // tailwind.config.ts
187
+ * import safelist from "./tailwind.safelist.json"
188
+ *
189
+ * export default {
190
+ * safelist: safelist.safelist,
191
+ * // ...
192
+ * }
193
+ * ─────────────────────────────────────────────────────────────
194
+ *
195
+ * Run manually: npx ts-node src/build/generateSafelist.ts
196
+ * Or via script: npm run build:safelist
197
+ */
198
+ interface SafelistConfig {
199
+ /** Root directory of your project */
200
+ cwd: string;
201
+ /** Directories to scan (relative to cwd) */
202
+ scanDirs: string[];
203
+ /** File extensions to scan */
204
+ extensions: RegExp;
205
+ /** Directories to skip */
206
+ excludeDirs: string[];
207
+ /** Output file path (relative to cwd) */
208
+ outputPath: string;
209
+ /** Include Tailwind pattern annotations in output */
210
+ verbose: boolean;
211
+ }
212
+ declare function generateSafelist(userConfig?: Partial<SafelistConfig>): void;
213
+
214
+ export { type SwcPluginOptions, type TransformOptions, type TransformResult, type VitePluginOptions, extractAllClasses, extractTwClasses, generateSafelist, runSafelistGeneration, shouldProcess, swcPlugin, swcTransformFile, tailwindStyledPlugin, transformBatch, transformSource, transformTw, turbopackTransform, withTailwindStyled };