tailwind-styled-v4 4.0.0 → 5.0.1

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 (194) hide show
  1. package/CHANGELOG.md +398 -0
  2. package/LICENSE +21 -0
  3. package/README.md +532 -0
  4. package/dist/analyzer.d.mts +114 -0
  5. package/dist/analyzer.d.ts +114 -0
  6. package/dist/analyzer.js +1555 -0
  7. package/dist/analyzer.js.map +1 -0
  8. package/dist/analyzer.mjs +1544 -0
  9. package/dist/analyzer.mjs.map +1 -0
  10. package/dist/animate.d.mts +46 -0
  11. package/dist/animate.d.ts +41 -112
  12. package/dist/animate.js +792 -235
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +782 -0
  15. package/dist/animate.mjs.map +1 -0
  16. package/dist/atomic.d.mts +18 -0
  17. package/dist/atomic.d.ts +18 -0
  18. package/dist/atomic.js +191 -0
  19. package/dist/atomic.js.map +1 -0
  20. package/dist/atomic.mjs +185 -0
  21. package/dist/atomic.mjs.map +1 -0
  22. package/dist/cli.d.mts +1 -0
  23. package/dist/cli.d.ts +1 -0
  24. package/dist/cli.js +6063 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/cli.mjs +6053 -0
  27. package/dist/cli.mjs.map +1 -0
  28. package/dist/{compiler.d.cts → compiler.d.mts} +503 -210
  29. package/dist/compiler.d.ts +503 -210
  30. package/dist/compiler.js +1549 -566
  31. package/dist/compiler.js.map +1 -1
  32. package/dist/{compiler.cjs → compiler.mjs} +1476 -627
  33. package/dist/compiler.mjs.map +1 -0
  34. package/dist/dashboard.d.mts +272 -0
  35. package/dist/dashboard.d.ts +272 -0
  36. package/dist/dashboard.js +249 -0
  37. package/dist/dashboard.js.map +1 -0
  38. package/dist/dashboard.mjs +239 -0
  39. package/dist/dashboard.mjs.map +1 -0
  40. package/dist/devtools.js +336 -211
  41. package/dist/devtools.js.map +1 -1
  42. package/dist/{devtools.cjs → devtools.mjs} +331 -220
  43. package/dist/devtools.mjs.map +1 -0
  44. package/dist/engine.d.mts +84 -0
  45. package/dist/engine.d.ts +84 -0
  46. package/dist/engine.js +3014 -0
  47. package/dist/engine.js.map +1 -0
  48. package/dist/engine.mjs +3005 -0
  49. package/dist/engine.mjs.map +1 -0
  50. package/dist/{index.d.cts → index.d.mts} +75 -4
  51. package/dist/index.d.ts +75 -4
  52. package/dist/index.js +1341 -149
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +2162 -0
  55. package/dist/index.mjs.map +1 -0
  56. package/dist/liveTokenEngine-DYN3Zale.d.mts +34 -0
  57. package/dist/liveTokenEngine-DYN3Zale.d.ts +34 -0
  58. package/dist/next.d.mts +55 -0
  59. package/dist/next.d.ts +30 -20
  60. package/dist/next.js +6947 -149
  61. package/dist/next.js.map +1 -1
  62. package/dist/next.mjs +7050 -0
  63. package/dist/next.mjs.map +1 -0
  64. package/dist/plugin.d.mts +90 -0
  65. package/dist/plugin.d.ts +90 -0
  66. package/dist/plugin.js +185 -0
  67. package/dist/plugin.js.map +1 -0
  68. package/dist/plugin.mjs +174 -0
  69. package/dist/plugin.mjs.map +1 -0
  70. package/dist/pluginRegistry.d.mts +83 -0
  71. package/dist/pluginRegistry.d.ts +83 -0
  72. package/dist/pluginRegistry.js +303 -0
  73. package/dist/pluginRegistry.js.map +1 -0
  74. package/dist/pluginRegistry.mjs +298 -0
  75. package/dist/pluginRegistry.mjs.map +1 -0
  76. package/dist/{preset.d.cts → preset.d.mts} +29 -2
  77. package/dist/preset.d.ts +29 -2
  78. package/dist/preset.js +318 -21
  79. package/dist/preset.js.map +1 -1
  80. package/dist/preset.mjs +414 -0
  81. package/dist/preset.mjs.map +1 -0
  82. package/dist/rspack.d.mts +33 -0
  83. package/dist/rspack.d.ts +33 -0
  84. package/dist/rspack.js +55 -0
  85. package/dist/rspack.js.map +1 -0
  86. package/dist/rspack.mjs +45 -0
  87. package/dist/rspack.mjs.map +1 -0
  88. package/dist/runtime.d.mts +62 -0
  89. package/dist/runtime.d.ts +62 -0
  90. package/dist/runtime.js +207 -0
  91. package/dist/runtime.js.map +1 -0
  92. package/dist/runtime.mjs +188 -0
  93. package/dist/runtime.mjs.map +1 -0
  94. package/dist/runtimeCss.d.mts +65 -0
  95. package/dist/runtimeCss.d.ts +65 -0
  96. package/dist/runtimeCss.js +188 -0
  97. package/dist/runtimeCss.js.map +1 -0
  98. package/dist/runtimeCss.mjs +173 -0
  99. package/dist/runtimeCss.mjs.map +1 -0
  100. package/dist/scanner.d.mts +25 -0
  101. package/dist/scanner.d.ts +25 -0
  102. package/dist/scanner.js +717 -0
  103. package/dist/scanner.js.map +1 -0
  104. package/dist/scanner.mjs +703 -0
  105. package/dist/scanner.mjs.map +1 -0
  106. package/dist/shared.d.mts +85 -0
  107. package/dist/shared.d.ts +85 -0
  108. package/dist/shared.js +255 -0
  109. package/dist/shared.js.map +1 -0
  110. package/dist/shared.mjs +233 -0
  111. package/dist/shared.mjs.map +1 -0
  112. package/dist/storybookAddon.d.mts +108 -0
  113. package/dist/storybookAddon.d.ts +108 -0
  114. package/dist/storybookAddon.js +95 -0
  115. package/dist/storybookAddon.js.map +1 -0
  116. package/dist/storybookAddon.mjs +88 -0
  117. package/dist/storybookAddon.mjs.map +1 -0
  118. package/dist/svelte.d.mts +114 -0
  119. package/dist/svelte.d.ts +114 -0
  120. package/dist/svelte.js +67 -0
  121. package/dist/svelte.js.map +1 -0
  122. package/dist/svelte.mjs +59 -0
  123. package/dist/svelte.mjs.map +1 -0
  124. package/dist/testing.d.mts +185 -0
  125. package/dist/testing.d.ts +185 -0
  126. package/dist/testing.js +173 -0
  127. package/dist/testing.js.map +1 -0
  128. package/dist/testing.mjs +158 -0
  129. package/dist/testing.mjs.map +1 -0
  130. package/dist/{theme.d.cts → theme.d.mts} +18 -11
  131. package/dist/theme.d.ts +18 -11
  132. package/dist/theme.js +205 -19
  133. package/dist/theme.js.map +1 -1
  134. package/dist/theme.mjs +311 -0
  135. package/dist/theme.mjs.map +1 -0
  136. package/dist/types-DXr2PmGP.d.mts +31 -0
  137. package/dist/types-DXr2PmGP.d.ts +31 -0
  138. package/dist/vite.d.mts +51 -0
  139. package/dist/vite.d.ts +35 -6
  140. package/dist/vite.js +4254 -57
  141. package/dist/vite.js.map +1 -1
  142. package/dist/vite.mjs +4281 -0
  143. package/dist/vite.mjs.map +1 -0
  144. package/dist/vue.d.mts +89 -0
  145. package/dist/vue.d.ts +89 -0
  146. package/dist/vue.js +104 -0
  147. package/dist/vue.js.map +1 -0
  148. package/dist/vue.mjs +96 -0
  149. package/dist/vue.mjs.map +1 -0
  150. package/package.json +173 -67
  151. package/dist/animate.cjs +0 -252
  152. package/dist/animate.cjs.map +0 -1
  153. package/dist/animate.d.cts +0 -117
  154. package/dist/astTransform-ua-eapqs.d.cts +0 -41
  155. package/dist/astTransform-ua-eapqs.d.ts +0 -41
  156. package/dist/compiler.cjs.map +0 -1
  157. package/dist/css.cjs +0 -71
  158. package/dist/css.cjs.map +0 -1
  159. package/dist/css.d.cts +0 -45
  160. package/dist/css.d.ts +0 -45
  161. package/dist/css.js +0 -62
  162. package/dist/css.js.map +0 -1
  163. package/dist/devtools.cjs.map +0 -1
  164. package/dist/index.cjs +0 -1058
  165. package/dist/index.cjs.map +0 -1
  166. package/dist/next.cjs +0 -268
  167. package/dist/next.cjs.map +0 -1
  168. package/dist/next.d.cts +0 -45
  169. package/dist/plugins.cjs +0 -396
  170. package/dist/plugins.cjs.map +0 -1
  171. package/dist/plugins.d.cts +0 -231
  172. package/dist/plugins.d.ts +0 -231
  173. package/dist/plugins.js +0 -381
  174. package/dist/plugins.js.map +0 -1
  175. package/dist/preset.cjs +0 -129
  176. package/dist/preset.cjs.map +0 -1
  177. package/dist/theme.cjs +0 -154
  178. package/dist/theme.cjs.map +0 -1
  179. package/dist/turbopackLoader.cjs +0 -2689
  180. package/dist/turbopackLoader.cjs.map +0 -1
  181. package/dist/turbopackLoader.d.cts +0 -22
  182. package/dist/turbopackLoader.d.ts +0 -22
  183. package/dist/turbopackLoader.js +0 -2681
  184. package/dist/turbopackLoader.js.map +0 -1
  185. package/dist/vite.cjs +0 -105
  186. package/dist/vite.cjs.map +0 -1
  187. package/dist/vite.d.cts +0 -22
  188. package/dist/webpackLoader.cjs +0 -2670
  189. package/dist/webpackLoader.cjs.map +0 -1
  190. package/dist/webpackLoader.d.cts +0 -24
  191. package/dist/webpackLoader.d.ts +0 -24
  192. package/dist/webpackLoader.js +0 -2662
  193. package/dist/webpackLoader.js.map +0 -1
  194. /package/dist/{devtools.d.cts → devtools.d.mts} +0 -0
@@ -1,109 +1,84 @@
1
- export { T as TransformOptions, a as TransformResult, t as transformSource } from './astTransform-ua-eapqs.cjs';
2
-
3
1
  declare function hasTwUsage(source: string): boolean;
4
2
  declare function isDynamic(content: string): boolean;
5
3
  declare function isServerComponent(source: string): boolean;
6
4
  declare function hasInteractiveFeatures(content: string): boolean;
7
5
 
8
- /**
9
- * tailwind-styled-v4 Atomic CSS Mode (Optional)
10
- *
11
- * Mode opsional yang mengubah Tailwind classes menjadi atomic CSS rules.
12
- * Mirip konsep StyleX dari Meta — setiap class menghasilkan satu CSS rule.
13
- *
14
- * Keuntungan:
15
- * - CSS global deduplicated (p-4 hanya satu rule di seluruh app)
16
- * - Bundle CSS lebih kecil untuk app besar
17
- * - Zero duplicate styles
18
- *
19
- * Mode ini TIDAK mengganti Tailwind — tetap pakai Tailwind utilities,
20
- * hanya menambahkan layer extraction untuk SSR streaming.
21
- *
22
- * Usage:
23
- * withTailwindStyled({ atomic: true })(nextConfig)
24
- */
25
- interface AtomicRule {
26
- /** Original Tailwind class */
27
- twClass: string;
28
- /** Generated atomic class name */
29
- atomicName: string;
30
- /** CSS property */
31
- property: string;
32
- /** CSS value */
33
- value: string;
34
- /** Modifier (hover:, md:, etc.) */
35
- modifier?: string;
6
+ interface TransformOptions {
7
+ /** @deprecated Mode is always "zero-runtime" in v5. This option will be removed in v6. */
8
+ mode?: "zero-runtime";
9
+ autoClientBoundary?: boolean;
10
+ addDataAttr?: boolean;
11
+ hoist?: boolean;
12
+ filename?: string;
13
+ /** Keep all imports from tailwind-styled-v4 intact only transform tw.* usages */
14
+ preserveImports?: boolean;
15
+ /** Enable Dead Style Elimination - removes unused CSS after transformation (default: false) */
16
+ deadStyleElimination?: boolean;
36
17
  }
37
- declare function parseAtomicClass(twClass: string): AtomicRule | null;
38
- declare function generateAtomicCss(rules: AtomicRule[]): string;
39
- declare function toAtomicClasses(twClasses: string): {
40
- atomicClasses: string;
41
- rules: AtomicRule[];
42
- unknownClasses: string[];
43
- };
44
- declare function getAtomicRegistry(): Map<string, AtomicRule>;
45
- declare function clearAtomicRegistry(): void;
46
-
47
- declare function extractAllClasses(source: string): string[];
18
+ interface TransformResult {
19
+ code: string;
20
+ classes: string[];
21
+ rsc?: {
22
+ isServer: boolean;
23
+ needsClientDirective: boolean;
24
+ clientReasons: string[];
25
+ };
26
+ changed: boolean;
27
+ }
28
+ declare function transformSource(source: string, opts?: TransformOptions): TransformResult;
48
29
 
49
30
  /**
50
- * tailwind-styled-v4 — classMerger
31
+ * tailwind-styled-v4 — CSS Compiler (Rust-backed LightningCSS-style)
51
32
  *
52
- * FIX #05: Ganti custom UTILITY_GROUPS resolver dengan twMerge.
33
+ * v5 CHANGE: Now requires native binding. Previously fell back to JS implementation.
53
34
  *
54
- * WHY: Custom regex resolver memiliki banyak edge case yang salah
55
- * (ring-, text- grouping, dll). tailwind-merge sudah jadi dependency,
56
- * lebih akurat, dan di-maintain oleh komunitas Tailwind.
57
- *
58
- * RESULT: Output compile-time dan runtime kini identik — tidak ada
59
- * behavior perbedaan antara dev mode dan production build.
35
+ * Compiles Tailwind class lists to atomic CSS using Rust native engine.
60
36
  */
37
+ interface CssCompileResult$1 {
38
+ /** Generated atomic CSS */
39
+ css: string;
40
+ /** Classes successfully resolved to native CSS */
41
+ resolvedClasses: string[];
42
+ /** Classes with no native mapping (get @apply fallback) */
43
+ unknownClasses: string[];
44
+ /** Byte size of generated CSS */
45
+ sizeBytes: number;
46
+ /** Which engine produced this output */
47
+ engine: "rust" | "fallback";
48
+ }
61
49
  /**
62
- * Merge Tailwind classes statically at compile time.
63
- * Menggunakan tailwind-merge untuk conflict resolution yang akurat.
50
+ * Compile a list of Tailwind classes into atomic CSS.
64
51
  *
65
- * FIX #05: Sebelumnya pakai custom UTILITY_GROUPS regex yang tidak
66
- * kompatibel dengan tailwind-merge runtime. Sekarang keduanya identik.
52
+ * v5 CHANGE: Now THROWS if native binding is unavailable.
53
+ * Previously fell back to JS implementation.
54
+ *
55
+ * Uses Rust LightningCSS-style engine when native binary is available.
67
56
  *
68
57
  * @example
69
- * mergeClassesStatic("p-4 p-2 bg-red-500 bg-blue-500")
70
- * → "p-2 bg-blue-500"
58
+ * const { css } = compileCssFromClasses(['flex', 'items-center', 'hover:bg-blue-600'])
59
+ * // → ".flex { display: flex } .items-center { align-items: center } ..."
71
60
  *
72
- * mergeClassesStatic("ring-2 ring-4")
73
- * → "ring-4" ✓ (custom resolver dulu return "ring-2 ring-4" — salah!)
61
+ * @throws Error if native binding is not available
74
62
  */
75
- declare function mergeClassesStatic(classes: string): string;
63
+ declare function compileCssFromClasses(classes: string[], options?: {
64
+ prefix?: string;
65
+ }): CssCompileResult$1;
76
66
  /**
77
- * Normalize raw class string trim, dedupe whitespace, join lines.
67
+ * Compile CSS for a set of classes and inject as a <style> block (SSR helper).
78
68
  */
79
- declare function normalizeClasses(raw: string): string;
69
+ declare function buildStyleTag(classes: string[]): string;
80
70
 
81
71
  /**
82
- * tailwind-styled-v4 Component Hoister
83
- *
84
- * Problem: Component yang didefinisikan di dalam fungsi lain
85
- * akan direcreate setiap render — sangat buruk untuk performa.
86
- *
87
- * BEFORE (buruk):
88
- * export default function Page() {
89
- * const Box = tw.div`p-4` ← dibuat ulang tiap render!
90
- * return <Box/>
91
- * }
72
+ * Extract all Tailwind classes from source code.
92
73
  *
93
- * AFTER (benar):
94
- * const Box = tw.div`p-4` ← module scope, dibuat sekali
95
- * export default function Page() {
96
- * return <Box/>
97
- * }
74
+ * v5 CHANGE: Now THROWS if native binding is unavailable.
75
+ * Previously fell back to JS implementation.
98
76
  *
99
- * Hoister mendeteksi pola ini dan memindahkan deklarasi ke module scope.
77
+ * @param source - Source code to extract classes from
78
+ * @returns Array of unique class names (sorted)
79
+ * @throws Error if native binding is not available
100
80
  */
101
- interface HoistResult {
102
- code: string;
103
- hoisted: string[];
104
- warnings: string[];
105
- }
106
- declare function hoistComponents(source: string): HoistResult;
81
+ declare function extractAllClasses(source: string): string[];
107
82
 
108
83
  /**
109
84
  * tailwind-styled-v4 — Dead Style Eliminator
@@ -169,6 +144,26 @@ interface RegisteredComponent {
169
144
  name: string;
170
145
  variants: Record<string, Record<string, string>>;
171
146
  }
147
+ /**
148
+ * Find unused variant values by comparing registered components with actual usage.
149
+ */
150
+ declare function findDeadVariants(registered: RegisteredComponent[], projectUsage: Record<string, Record<string, Set<string>>>): EliminationReport;
151
+ /**
152
+ * Filter a CSS string to remove selectors for unused classes.
153
+ *
154
+ * @param css - Full CSS string
155
+ * @param deadClasses - Set of class names to remove
156
+ */
157
+ declare function eliminateDeadCss(css: string, deadClasses: Set<string>): string;
158
+ /**
159
+ * Merge duplicate CSS rules and deduplicate media queries.
160
+ * Reduces final CSS size for atomic outputs.
161
+ *
162
+ * @example
163
+ * optimizeCss(".tw-a1{padding:16px} .tw-b1{padding:16px}")
164
+ * → ".tw-a1,.tw-b1{padding:16px}"
165
+ */
166
+ declare function optimizeCss(css: string): string;
172
167
  interface EliminationOptions {
173
168
  dirs?: string[];
174
169
  cwd?: string;
@@ -314,112 +309,6 @@ declare function parseClassesToNodes(classes: string[]): StyleNode[];
314
309
  declare function getIncrementalEngine(opts?: IncrementalEngineOptions): IncrementalEngine;
315
310
  declare function resetIncrementalEngine(): void;
316
311
 
317
- /**
318
- * tailwind-styled-v4 — Tailwind Config Loader
319
- *
320
- * Auto-load tailwind config dari project.
321
- * Jika tidak ada → fallback ke defaultPreset (zero-config mode).
322
- *
323
- * Priority:
324
- * 1. tailwind.config.ts (TypeScript)
325
- * 2. tailwind.config.js (JavaScript)
326
- * 3. tailwind.config.mjs (ESM)
327
- * 4. defaultPreset (fallback — zero-config)
328
- */
329
- type TailwindConfig = Record<string, any>;
330
- /**
331
- * Load tailwind config. Cached per process.
332
- * Returns defaultPreset if no config found (zero-config mode).
333
- */
334
- declare function loadTailwindConfig(cwd?: string): TailwindConfig;
335
- /**
336
- * Get content paths dari config (atau default paths)
337
- */
338
- declare function getContentPaths(config: TailwindConfig, cwd?: string): string[];
339
- /**
340
- * Invalidate config cache (useful for watch mode)
341
- */
342
- declare function invalidateConfigCache(): void;
343
- /**
344
- * Check if project has zero-config setup (no user tailwind config)
345
- */
346
- declare function isZeroConfig(cwd?: string): boolean;
347
- /**
348
- * Auto-generate tailwind.config.ts dan globals.css jika tidak ada
349
- * (dipanggil oleh CLI dan withTailwindStyled pada first run)
350
- */
351
- declare function bootstrapZeroConfig(cwd?: string): {
352
- generatedConfig: boolean;
353
- generatedCss: boolean;
354
- };
355
-
356
- /**
357
- * tailwind-styled-v4 — Route CSS Collector
358
- *
359
- * Mengumpulkan Tailwind classes per-route sehingga setiap halaman
360
- * hanya memuat CSS yang benar-benar dipakai.
361
- *
362
- * Tailwind default: ~300kb global CSS
363
- * Route CSS: ~2–10kb per halaman
364
- *
365
- * Cara kerja:
366
- * 1. Setiap file yang di-transform oleh compiler melaporkan classnya
367
- * 2. Collector memetakan file → route
368
- * 3. Di akhir build, CSS di-generate per route
369
- *
370
- * File structure output:
371
- * .next/static/css/
372
- * _global.css ← base + reset (sekali load)
373
- * app/page.css ← hanya class yang dipakai di /
374
- * app/about/page.css ← hanya class untuk /about
375
- * app/dashboard/...
376
- */
377
- interface RouteClassMap {
378
- /** filepath → array of tw classes */
379
- files: Map<string, Set<string>>;
380
- /** route → Set of files yang dipakai */
381
- routes: Map<string, Set<string>>;
382
- /** Global classes (di-load semua route) */
383
- global: Set<string>;
384
- }
385
- /**
386
- * Register classes dari sebuah file setelah compiler transform.
387
- * Dipanggil oleh turbopackLoader/webpackLoader setelah setiap file di-transform.
388
- */
389
- declare function registerFileClasses(filepath: string, classes: string[]): void;
390
- /**
391
- * Register global classes (base styles, layout, dsb.)
392
- * Global classes dimuat di semua route.
393
- */
394
- declare function registerGlobalClasses(classes: string[]): void;
395
- /**
396
- * Get all classes for a specific route (termasuk global)
397
- */
398
- declare function getRouteClasses(route: string): Set<string>;
399
- /**
400
- * Get all routes yang sudah ter-register
401
- */
402
- declare function getAllRoutes(): string[];
403
- /**
404
- * Get complete map (untuk build-time generation)
405
- */
406
- declare function getCollector(): RouteClassMap;
407
- /**
408
- * Reset collector (start of each build)
409
- */
410
- declare function resetCollector(): void;
411
- /**
412
- * Konversi filepath ke Next.js App Router route.
413
- *
414
- * /src/app/page.tsx → /
415
- * /src/app/about/page.tsx → /about
416
- * /src/app/dashboard/page.tsx → /dashboard
417
- * /src/components/Button.tsx → null (shared component, goes to global)
418
- * /src/app/layout.tsx → __layout (global)
419
- */
420
- declare function fileToRoute(filepath: string): string | null;
421
- declare function getCollectorSummary(): string;
422
-
423
312
  /**
424
313
  * tailwind-styled-v4 — RSC Analyzer
425
314
  *
@@ -476,22 +365,6 @@ declare function resolveServerVariant(base: string, table: Record<string, Record
476
365
  declare function injectClientDirective(code: string): string;
477
366
  declare function injectServerOnlyComment(code: string): string;
478
367
 
479
- /**
480
- * tailwind-styled-v4 — safelistGenerator
481
- *
482
- * Scan semua source files dan extract Tailwind classes untuk safelist.
483
- * Output: .tailwind-styled-safelist.json
484
- *
485
- * Developer tidak perlu manual safelist.
486
- */
487
- declare function generateSafelist(scanDirs: string[], outputPath?: string, cwd?: string): string[];
488
- declare function loadSafelist(safelistPath: string): string[];
489
- /**
490
- * Tailwind v4 variant — output CSS dengan @source inline() bukan JSON.
491
- * Tailwind v4 tidak punya 'safelist' di config — pakai @source inline() di CSS.
492
- */
493
- declare function generateSafelistCss(scanDirs: string[], outputPath?: string, cwd?: string): string[];
494
-
495
368
  /**
496
369
  * tailwind-styled-v4 — Style Bucket System
497
370
  *
@@ -627,6 +500,429 @@ declare function detectConflicts(nodes: StyleNode[]): ConflictWarning[];
627
500
  declare function getBucketEngine(): BucketEngine;
628
501
  declare function resetBucketEngine(): void;
629
502
 
503
+ /**
504
+ * @deprecated in v5 — Use @tailwind-styled/atomic package instead
505
+ * This module will be removed in v6
506
+ *
507
+ * tailwind-styled-v4 — Atomic CSS Mode (Optional)
508
+ *
509
+ * Mode opsional yang mengubah Tailwind classes menjadi atomic CSS rules.
510
+ * Mirip konsep StyleX dari Meta — setiap class menghasilkan satu CSS rule.
511
+ *
512
+ * Keuntungan:
513
+ * - CSS global deduplicated (p-4 hanya satu rule di seluruh app)
514
+ * - Bundle CSS lebih kecil untuk app besar
515
+ * - Zero duplicate styles
516
+ *
517
+ * Mode ini TIDAK mengganti Tailwind — tetap pakai Tailwind utilities,
518
+ * hanya menambahkan layer extraction untuk SSR streaming.
519
+ *
520
+ * Usage:
521
+ * withTailwindStyled({ atomic: true })(nextConfig)
522
+ */
523
+ interface AtomicRule {
524
+ /** Original Tailwind class */
525
+ twClass: string;
526
+ /** Generated atomic class name */
527
+ atomicName: string;
528
+ /** CSS property */
529
+ property: string;
530
+ /** CSS value */
531
+ value: string;
532
+ /** Modifier (hover:, md:, etc.) */
533
+ modifier?: string;
534
+ }
535
+ declare function parseAtomicClass(twClass: string): AtomicRule | null;
536
+ declare function generateAtomicCss(rules: AtomicRule[]): string;
537
+ declare function toAtomicClasses(twClasses: string): {
538
+ atomicClasses: string;
539
+ rules: AtomicRule[];
540
+ unknownClasses: string[];
541
+ };
542
+ declare function getAtomicRegistry(): Map<string, AtomicRule>;
543
+ declare function clearAtomicRegistry(): void;
544
+
545
+ /**
546
+ * tailwind-styled-v4 — classMerger
547
+ *
548
+ * FIX #05: Ganti custom UTILITY_GROUPS resolver dengan twMerge.
549
+ *
550
+ * WHY: Custom regex resolver memiliki banyak edge case yang salah
551
+ * (ring-, text- grouping, dll). tailwind-merge sudah jadi dependency,
552
+ * lebih akurat, dan di-maintain oleh komunitas Tailwind.
553
+ *
554
+ * RESULT: Output compile-time dan runtime kini identik — tidak ada
555
+ * behavior perbedaan antara dev mode dan production build.
556
+ */
557
+ /**
558
+ * Merge Tailwind classes statically at compile time.
559
+ * Menggunakan tailwind-merge untuk conflict resolution yang akurat.
560
+ *
561
+ * FIX #05: Sebelumnya pakai custom UTILITY_GROUPS regex yang tidak
562
+ * kompatibel dengan tailwind-merge runtime. Sekarang keduanya identik.
563
+ *
564
+ * @example
565
+ * mergeClassesStatic("p-4 p-2 bg-red-500 bg-blue-500")
566
+ * → "p-2 bg-blue-500"
567
+ *
568
+ * mergeClassesStatic("ring-2 ring-4")
569
+ * → "ring-4" ✓ (custom resolver dulu return "ring-2 ring-4" — salah!)
570
+ */
571
+ declare function mergeClassesStatic(classes: string): string;
572
+ /**
573
+ * Normalize raw class string — trim, dedupe whitespace, join lines.
574
+ */
575
+ declare function normalizeClasses(raw: string): string;
576
+
577
+ /**
578
+ * tailwind-styled-v4 — Component Hoister
579
+ *
580
+ * Problem: Component yang didefinisikan di dalam fungsi lain
581
+ * akan direcreate setiap render — sangat buruk untuk performa.
582
+ *
583
+ * BEFORE (buruk):
584
+ * export default function Page() {
585
+ * const Box = tw.div`p-4` ← dibuat ulang tiap render!
586
+ * return <Box/>
587
+ * }
588
+ *
589
+ * AFTER (benar):
590
+ * const Box = tw.div`p-4` ← module scope, dibuat sekali
591
+ * export default function Page() {
592
+ * return <Box/>
593
+ * }
594
+ *
595
+ * Hoister mendeteksi pola ini dan memindahkan deklarasi ke module scope.
596
+ */
597
+ interface HoistResult {
598
+ code: string;
599
+ hoisted: string[];
600
+ warnings: string[];
601
+ }
602
+ declare function hoistComponents(source: string): HoistResult;
603
+
604
+ type CompileEngine = "none" | "native" | "js";
605
+ interface CompileInput {
606
+ filepath: string;
607
+ source: string;
608
+ options: TransformOptions;
609
+ }
610
+ declare class CompileContext {
611
+ filepath: string;
612
+ source: string;
613
+ options: TransformOptions;
614
+ result: TransformResult | null;
615
+ done: boolean;
616
+ engine: CompileEngine;
617
+ constructor(input: CompileInput);
618
+ }
619
+
620
+ /**
621
+ * tailwind-styled-v4 — NativeBridge
622
+ *
623
+ * Loads the native Rust engine (.node binding via index.mjs) and exposes
624
+ * its functions to the JS compiler pipeline.
625
+ *
626
+ * The bridge is loaded lazily and cached. If the .node binary is not
627
+ * present (e.g. the user hasn't built the Rust crate yet), every function
628
+ * returns null and the pipeline falls through to the JS implementation.
629
+ *
630
+ * Environment flags:
631
+ * TWS_NO_NATIVE=1 — disable native bridge entirely
632
+ * TWS_NO_RUST=1 — alias for TWS_NO_NATIVE
633
+ */
634
+
635
+ /** Raw shape returned by Rust transform_source — napi auto-converts snake_case → camelCase */
636
+ interface NativeTransformResult {
637
+ code: string;
638
+ classes: string[];
639
+ changed: boolean;
640
+ /** JSON string: { isServer: boolean, needsClientDirective: boolean } */
641
+ rscJson?: string | null;
642
+ /** JSON string: ComponentMetadata[] */
643
+ metadataJson?: string | null;
644
+ }
645
+ /** Metadata for one compound component, produced by Rust and consumed by @tailwind-styled/runtime */
646
+ interface ComponentMetadata {
647
+ component: string;
648
+ tag: string;
649
+ baseClass: string;
650
+ subComponents: Record<string, {
651
+ tag: string;
652
+ class: string;
653
+ }>;
654
+ }
655
+ /** Full bridge interface — all members optional so feature detection is easy */
656
+ interface NativeBridge {
657
+ /** Parse individual class tokens. Throws if binding is unavailable. */
658
+ parseClassesNative?: (input: string) => Array<{
659
+ raw: string;
660
+ base: string;
661
+ variants: string[];
662
+ modifierType?: string | null;
663
+ modifierValue?: string | null;
664
+ }>;
665
+ /** Fast pre-check — returns null if binding unavailable. */
666
+ hasTwUsageNative?: (source: string) => boolean | null;
667
+ /** Idempotency guard — returns null if binding unavailable. */
668
+ isAlreadyTransformedNative?: (source: string) => boolean | null;
669
+ /** RSC analysis — returns null if binding unavailable. */
670
+ analyzeRscNative?: (source: string, filename?: string) => {
671
+ isServer: boolean;
672
+ needsClientDirective: boolean;
673
+ clientReasons: string[];
674
+ } | null;
675
+ /** Full transform — returns null if binding unavailable (JS pipeline takes over). */
676
+ transformSourceNative?: (source: string, opts: Record<string, unknown>) => NativeTransformResult | null;
677
+ /** AST-based class extraction (Oxc+regex hybrid) */
678
+ astExtractClassesNative?: (source: string, filename?: string) => {
679
+ classes: string[];
680
+ engine: string;
681
+ } | null;
682
+ /** Rust-based class extraction via regex */
683
+ extractClassesFromSourceNative?: (source: string) => string[] | null;
684
+ /** Analyze class frequency - used for DSE */
685
+ analyzeClassesNative?: (filesJson: string, root: string, topN: number) => {
686
+ root: string;
687
+ totalFiles: number;
688
+ uniqueClassCount: number;
689
+ totalClassOccurrences: number;
690
+ topClasses: Array<{
691
+ name: string;
692
+ count: number;
693
+ }>;
694
+ duplicateCandidates: Array<{
695
+ name: string;
696
+ count: number;
697
+ }>;
698
+ safelist: string[];
699
+ } | null;
700
+ }
701
+ /**
702
+ * Get the native bridge - THROWS if unavailable.
703
+ *
704
+ * v5 CHANGE: Previously returned null and fell back to JS pipeline.
705
+ * Now throws an error to ensure native binding is always used.
706
+ *
707
+ * @throws Error if native binding is not available
708
+ */
709
+ declare function getNativeBridge(): NativeBridge;
710
+ declare function resetNativeBridgeCache(): void;
711
+ declare function adaptNativeResult(raw: NativeTransformResult): TransformResult & {
712
+ metadata?: ComponentMetadata[];
713
+ };
714
+
715
+ interface CoreCompileOptions extends TransformOptions {
716
+ }
717
+ interface CoreCompileResult {
718
+ result: TransformResult;
719
+ engine: CompileEngine;
720
+ cacheHit: boolean;
721
+ /** Compound component metadata produced by Rust — undefined when the JS pipeline ran */
722
+ metadata?: ComponentMetadata[];
723
+ /** CSS output after DSE (when deadStyleElimination option is enabled) */
724
+ css?: string;
725
+ }
726
+ declare function compileWithCore(input: CompileInput): CoreCompileResult;
727
+ declare function resetCompileCache(): void;
728
+
729
+ /**
730
+ * tailwind-styled-v5 - loaderCore
731
+ *
732
+ * Unified loader path:
733
+ * incremental precheck -> core compiler (native/js pipeline) -> finalize
734
+ */
735
+
736
+ interface LoaderOptions extends TransformOptions {
737
+ routeCss?: boolean;
738
+ incremental?: boolean;
739
+ verbose?: boolean;
740
+ autoClientBoundary?: boolean;
741
+ }
742
+ interface LoaderContext {
743
+ filepath: string;
744
+ source: string;
745
+ options: LoaderOptions;
746
+ isDev?: boolean;
747
+ }
748
+ interface LoaderOutput {
749
+ code: string;
750
+ changed: boolean;
751
+ classes: string[];
752
+ rsc?: TransformResult["rsc"];
753
+ engine?: "native" | "js" | "none";
754
+ cacheHit?: boolean;
755
+ /** Compound component metadata — only present when Rust engine ran */
756
+ metadata?: ComponentMetadata[];
757
+ }
758
+ declare function shouldSkipFile(filepath: string): boolean;
759
+ declare function runLoaderTransform(ctx: LoaderContext): LoaderOutput;
760
+
761
+ /**
762
+ * tailwind-styled-v4 — Tailwind Config Loader
763
+ *
764
+ * Auto-load tailwind config dari project.
765
+ * Jika tidak ada → fallback ke defaultPreset (zero-config mode).
766
+ *
767
+ * Priority:
768
+ * 1. tailwind.config.ts (TypeScript)
769
+ * 2. tailwind.config.js (JavaScript)
770
+ * 3. tailwind.config.mjs (ESM)
771
+ * 4. defaultPreset (fallback — zero-config)
772
+ */
773
+ type TailwindConfig = Record<string, any>;
774
+ /**
775
+ * Load tailwind config. Cached per process.
776
+ * Returns defaultPreset if no config found (zero-config mode).
777
+ */
778
+ declare function loadTailwindConfig(cwd?: string): TailwindConfig;
779
+ /**
780
+ * Get content paths dari config (atau default paths)
781
+ */
782
+ declare function getContentPaths(config: TailwindConfig, cwd?: string): string[];
783
+ /**
784
+ * Invalidate config cache (useful for watch mode)
785
+ */
786
+ declare function invalidateConfigCache(): void;
787
+ /**
788
+ * Check if project has zero-config setup (no user tailwind config)
789
+ */
790
+ declare function isZeroConfig(cwd?: string): boolean;
791
+ /**
792
+ * Auto-generate tailwind.config.ts dan globals.css jika tidak ada
793
+ * (dipanggil oleh CLI dan withTailwindStyled pada first run)
794
+ */
795
+ declare function bootstrapZeroConfig(cwd?: string): {
796
+ generatedConfig: boolean;
797
+ generatedCss: boolean;
798
+ };
799
+
800
+ type PipelineStep<T> = (ctx: T) => void;
801
+ declare class Pipeline<T extends {
802
+ done?: boolean;
803
+ }> {
804
+ private steps;
805
+ use(step: PipelineStep<T>): this;
806
+ run(ctx: T): T;
807
+ }
808
+
809
+ /**
810
+ * tailwind-styled-v4 — Route CSS Collector
811
+ *
812
+ * Mengumpulkan Tailwind classes per-route sehingga setiap halaman
813
+ * hanya memuat CSS yang benar-benar dipakai.
814
+ *
815
+ * Tailwind default: ~300kb global CSS
816
+ * Route CSS: ~2–10kb per halaman
817
+ *
818
+ * Cara kerja:
819
+ * 1. Setiap file yang di-transform oleh compiler melaporkan classnya
820
+ * 2. Collector memetakan file → route
821
+ * 3. Di akhir build, CSS di-generate per route
822
+ *
823
+ * File structure output:
824
+ * .next/static/css/
825
+ * _global.css ← base + reset (sekali load)
826
+ * app/page.css ← hanya class yang dipakai di /
827
+ * app/about/page.css ← hanya class untuk /about
828
+ * app/dashboard/...
829
+ */
830
+ interface RouteClassMap {
831
+ /** filepath → array of tw classes */
832
+ files: Map<string, Set<string>>;
833
+ /** route → Set of files yang dipakai */
834
+ routes: Map<string, Set<string>>;
835
+ /** Global classes (di-load semua route) */
836
+ global: Set<string>;
837
+ }
838
+ /**
839
+ * Register classes dari sebuah file setelah compiler transform.
840
+ * Dipanggil oleh turbopackLoader/webpackLoader setelah setiap file di-transform.
841
+ */
842
+ declare function registerFileClasses(filepath: string, classes: string[]): void;
843
+ /**
844
+ * Register global classes (base styles, layout, dsb.)
845
+ * Global classes dimuat di semua route.
846
+ */
847
+ declare function registerGlobalClasses(classes: string[]): void;
848
+ /**
849
+ * Get all classes for a specific route (termasuk global)
850
+ */
851
+ declare function getRouteClasses(route: string): Set<string>;
852
+ /**
853
+ * Get all routes yang sudah ter-register
854
+ */
855
+ declare function getAllRoutes(): string[];
856
+ /**
857
+ * Get complete map (untuk build-time generation)
858
+ */
859
+ declare function getCollector(): RouteClassMap;
860
+ /**
861
+ * Reset collector (start of each build)
862
+ */
863
+ declare function resetCollector(): void;
864
+ /**
865
+ * Konversi filepath ke Next.js App Router route.
866
+ *
867
+ * /src/app/page.tsx → /
868
+ * /src/app/about/page.tsx → /about
869
+ * /src/app/dashboard/page.tsx → /dashboard
870
+ * /src/components/Button.tsx → null (shared component, goes to global)
871
+ * /src/app/layout.tsx → __layout (global)
872
+ */
873
+ declare function fileToRoute(filepath: string): string | null;
874
+ declare function getCollectorSummary(): string;
875
+
876
+ interface CssCompileResult {
877
+ css: string;
878
+ resolvedClasses: string[];
879
+ unknownClasses: string[];
880
+ sizeBytes: number;
881
+ engine: "rust" | "fallback";
882
+ }
883
+ interface AstExtractResult {
884
+ classes: string[];
885
+ componentNames: string[];
886
+ hasTwUsage: boolean;
887
+ hasUseClient: boolean;
888
+ imports: string[];
889
+ engine: "rust" | "fallback";
890
+ }
891
+ /**
892
+ * Compile Tailwind class list → atomic CSS via Rust LightningCSS-style compiler.
893
+ *
894
+ * v5 CHANGE: Now THROWS if native binding is unavailable.
895
+ * Previously fell back to JS implementation.
896
+ *
897
+ * @throws Error if native binding is not available
898
+ */
899
+ declare function compileCssNative(classes: string[], prefix?: string | null): CssCompileResult;
900
+ /**
901
+ * Extract Tailwind classes from source via Rust AST-style extractor.
902
+ *
903
+ * v5 CHANGE: Now THROWS if native binding is unavailable.
904
+ * Previously fell back to JS implementation.
905
+ *
906
+ * @throws Error if native binding is not available
907
+ */
908
+ declare function astExtractClassesNative(source: string, filename: string): AstExtractResult;
909
+
910
+ /**
911
+ * tailwind-styled-v4 — safelistGenerator
912
+ *
913
+ * Scan semua source files dan extract Tailwind classes untuk safelist.
914
+ * Output: .tailwind-styled-safelist.json
915
+ *
916
+ * Developer tidak perlu manual safelist.
917
+ */
918
+ declare function generateSafelist(scanDirs: string[], outputPath?: string, cwd?: string): string[];
919
+ declare function loadSafelist(safelistPath: string): string[];
920
+ /**
921
+ * Tailwind v4 variant — output CSS dengan @source inline() bukan JSON.
922
+ * Tailwind v4 tidak punya 'safelist' di config — pakai @source inline() di CSS.
923
+ */
924
+ declare function generateSafelistCss(scanDirs: string[], outputPath?: string, cwd?: string): string[];
925
+
630
926
  /**
631
927
  * tailwind-styled-v4 — Embedded Tailwind Engine
632
928
  *
@@ -642,10 +938,7 @@ declare function resetBucketEngine(): void;
642
938
  * Tailwind normal: ~300kb global
643
939
  * Route CSS: ~2–10kb per route
644
940
  *
645
- * Mode operasi:
646
- * "jit" → generate CSS saat file berubah (dev mode)
647
- * "build" → generate semua CSS di akhir build (production)
648
- * "manual" → tidak generate, hanya extract (default untuk kompatibilitas)
941
+ * NOTE: v5 only supports Tailwind v4. v3 support has been removed.
649
942
  */
650
943
  type TailwindEngineMode = "jit" | "build" | "manual";
651
944
  interface TailwindEngineOptions {
@@ -665,7 +958,7 @@ interface CssGenerateResult {
665
958
  * Try to use Tailwind's internal API for CSS generation.
666
959
  * Fallback ke manual CSS generation jika Tailwind API tidak tersedia.
667
960
  *
668
- * NOTE: Tailwind v4 mengubah API internal kita support keduanya.
961
+ * NOTE: v5 only supports Tailwind v4. v3 support has been removed.
669
962
  */
670
963
  declare function generateCssForClasses(classes: string[], config?: Record<string, any>, cwd?: string): Promise<string>;
671
964
  declare function generateAllRouteCss(opts?: TailwindEngineOptions): Promise<CssGenerateResult[]>;
@@ -713,4 +1006,4 @@ declare function compileVariants(base: string, variants: Record<string, Record<s
713
1006
  [key: string]: any;
714
1007
  }>, defaults?: Record<string, string>): CompiledVariants;
715
1008
 
716
- export { type AtomicRule, BucketEngine, type BucketStats, type ComponentEnv, type ConflictWarning, type CssDiff, type CssGenerateResult, type EliminationReport, type FileDependencyGraph, type HoistResult, IncrementalEngine, type IncrementalEngineOptions, type IncrementalStats, type ProcessResult, type RouteClassMap, type RscAnalysis, type StaticVariantUsage, type StyleBucket, type StyleNode, type TailwindEngineOptions, type VariantUsage, analyzeFile, analyzeVariantUsage, bootstrapZeroConfig, bucketSort, classifyNode, clearAtomicRegistry, compileVariants, detectConflicts, extractAllClasses, extractComponentUsage, fileToRoute, generateAllRouteCss, generateAtomicCss, generateCssForClasses, generateSafelist, generateSafelistCss, getAllRoutes, getAtomicRegistry, getBucketEngine, getCollector, getCollectorSummary, getContentPaths, getIncrementalEngine, getRouteClasses, hasInteractiveFeatures, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, invalidateConfigCache, isDynamic, isServerComponent, isZeroConfig, loadSafelist, loadTailwindConfig, mergeClassesStatic, normalizeClasses, parseAtomicClass, parseClassesToNodes, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetCollector, resetIncrementalEngine, resolveServerVariant, runElimination, scanProjectUsage, hasTwUsage as shouldProcess, toAtomicClasses };
1009
+ export { type AstExtractResult, type AtomicRule, BucketEngine, type BucketStats, CompileContext, type CompileEngine, type CompileInput, type ComponentEnv, type ComponentMetadata, type ConflictWarning, type CoreCompileOptions, type CoreCompileResult, type CssCompileResult$1 as CssCompileResult, type CssDiff, type CssGenerateResult, type EliminationReport, type FileDependencyGraph, type HoistResult, IncrementalEngine, type IncrementalEngineOptions, type IncrementalStats, type LoaderContext, type LoaderOptions, type LoaderOutput, type NativeBridge, type NativeTransformResult, Pipeline, type ProcessResult, type RouteClassMap, type RscAnalysis, type StaticVariantUsage, type StyleBucket, type StyleNode, type TailwindEngineOptions, type TransformOptions, type TransformResult, type VariantUsage, adaptNativeResult, analyzeFile, analyzeVariantUsage, astExtractClassesNative, bootstrapZeroConfig, bucketSort, buildStyleTag, classifyNode, clearAtomicRegistry, compileCssFromClasses, compileCssNative, compileVariants, compileWithCore, detectConflicts, eliminateDeadCss, extractAllClasses, extractComponentUsage, fileToRoute, findDeadVariants, generateAllRouteCss, generateAtomicCss, generateCssForClasses, generateSafelist, generateSafelistCss, getAllRoutes, getAtomicRegistry, getBucketEngine, getCollector, getCollectorSummary, getContentPaths, getIncrementalEngine, getNativeBridge, getRouteClasses, hasInteractiveFeatures, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, invalidateConfigCache, isDynamic, isServerComponent, isZeroConfig, loadSafelist, loadTailwindConfig, mergeClassesStatic, normalizeClasses, optimizeCss, parseAtomicClass, parseClassesToNodes, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetCollector, resetCompileCache, resetIncrementalEngine, resetNativeBridgeCache, resolveServerVariant, runElimination, runLoaderTransform, scanProjectUsage, hasTwUsage as shouldProcess, shouldSkipFile, toAtomicClasses, transformSource };