tailwind-styled-v4 5.1.21 → 5.1.23

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 (62) hide show
  1. package/README.md +216 -0
  2. package/dist/atomic.js +34 -4
  3. package/dist/atomic.js.map +1 -1
  4. package/dist/atomic.mjs +31 -2
  5. package/dist/atomic.mjs.map +1 -1
  6. package/dist/cli.d.mts +28 -16
  7. package/dist/cli.d.ts +28 -16
  8. package/dist/cli.js +392 -77
  9. package/dist/cli.js.map +1 -1
  10. package/dist/cli.mjs +388 -75
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/compiler.d.mts +195 -1
  13. package/dist/compiler.d.ts +195 -1
  14. package/dist/compiler.js +356 -12
  15. package/dist/compiler.js.map +1 -1
  16. package/dist/compiler.mjs +340 -10
  17. package/dist/compiler.mjs.map +1 -1
  18. package/dist/engine.js +194 -164
  19. package/dist/engine.js.map +1 -1
  20. package/dist/engine.mjs +184 -155
  21. package/dist/engine.mjs.map +1 -1
  22. package/dist/index.browser.mjs +144 -14
  23. package/dist/index.browser.mjs.map +1 -1
  24. package/dist/index.d.mts +45 -4
  25. package/dist/index.d.ts +45 -4
  26. package/dist/index.js +174 -9
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +185 -21
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/next.js +489 -158
  31. package/dist/next.js.map +1 -1
  32. package/dist/next.mjs +483 -153
  33. package/dist/next.mjs.map +1 -1
  34. package/dist/runtime-css.js +1 -1
  35. package/dist/runtime-css.js.map +1 -1
  36. package/dist/runtime-css.mjs +1 -1
  37. package/dist/runtime-css.mjs.map +1 -1
  38. package/dist/runtime.js +17 -0
  39. package/dist/runtime.js.map +1 -1
  40. package/dist/runtime.mjs +23 -0
  41. package/dist/runtime.mjs.map +1 -1
  42. package/dist/shared.js +91 -61
  43. package/dist/shared.js.map +1 -1
  44. package/dist/shared.mjs +85 -56
  45. package/dist/shared.mjs.map +1 -1
  46. package/dist/turbopackLoader.js +79 -49
  47. package/dist/turbopackLoader.js.map +1 -1
  48. package/dist/turbopackLoader.mjs +76 -47
  49. package/dist/turbopackLoader.mjs.map +1 -1
  50. package/dist/tw.js +390 -77
  51. package/dist/tw.js.map +1 -1
  52. package/dist/tw.mjs +387 -75
  53. package/dist/tw.mjs.map +1 -1
  54. package/dist/vite.js +157 -127
  55. package/dist/vite.js.map +1 -1
  56. package/dist/vite.mjs +150 -121
  57. package/dist/vite.mjs.map +1 -1
  58. package/dist/webpackLoader.js +39 -9
  59. package/dist/webpackLoader.js.map +1 -1
  60. package/dist/webpackLoader.mjs +36 -7
  61. package/dist/webpackLoader.mjs.map +1 -1
  62. package/package.json +1 -1
package/README.md CHANGED
@@ -498,6 +498,151 @@ export default defineConfig({
498
498
  // rspack.config.js
499
499
  import { tailwindStyled } from "tailwind-styled-v4/rspack"
500
500
 
501
+ ---
502
+
503
+ ## Theme Management
504
+
505
+ Tailwind-styled-v4 automatic mengelola CSS custom properties via `@theme inline` directive. Compiler Rust pre-generate semua CSS state rules di build time — zero runtime overhead.
506
+
507
+ ### Setup Tema
508
+
509
+ **globals.css — Define CSS Variables:**
510
+ ```css
511
+ @import "tailwindcss";
512
+
513
+ :root {
514
+ --background: #f5f7fb;
515
+ --foreground: #111827;
516
+ --surface: #ffffff;
517
+ --accent: #2563eb;
518
+ }
519
+
520
+ [data-theme="dark"] {
521
+ --background: #070b16;
522
+ --foreground: #e5e7eb;
523
+ --surface: #0f172a;
524
+ --accent: #60a5fa;
525
+ }
526
+
527
+ /* Bridge to Tailwind */
528
+ @theme inline {
529
+ --color-background: var(--background);
530
+ --color-foreground: var(--foreground);
531
+ --color-surface: var(--surface);
532
+ --color-accent: var(--accent);
533
+ }
534
+ ```
535
+
536
+ **ThemeProvider.tsx — Runtime Toggle:**
537
+ ```tsx
538
+ "use client";
539
+
540
+ import { ReactNode, useEffect, useState, createContext, useContext } from "react";
541
+
542
+ const STORAGE_KEY = "app-theme";
543
+
544
+ function applyTheme(theme: "light" | "dark") {
545
+ document.documentElement.setAttribute("data-theme", theme);
546
+ }
547
+
548
+ const ThemeContext = createContext<{
549
+ theme: "light" | "dark";
550
+ setTheme: (theme: "light" | "dark") => void;
551
+ } | null>(null);
552
+
553
+ export function ThemeProvider({ children }: { children: ReactNode }) {
554
+ const [theme, setThemeState] = useState<"light" | "dark">("light");
555
+ const [mounted, setMounted] = useState(false);
556
+
557
+ useEffect(() => {
558
+ const stored = localStorage.getItem(STORAGE_KEY) || "light";
559
+ setThemeState(stored as "light" | "dark");
560
+ applyTheme(stored as "light" | "dark");
561
+ setMounted(true);
562
+ }, []);
563
+
564
+ const setTheme = (newTheme: "light" | "dark") => {
565
+ localStorage.setItem(STORAGE_KEY, newTheme);
566
+ setThemeState(newTheme);
567
+ applyTheme(newTheme);
568
+ };
569
+
570
+ return (
571
+ <ThemeContext.Provider value={{ theme, setTheme }}>
572
+ {mounted ? children : null}
573
+ </ThemeContext.Provider>
574
+ );
575
+ }
576
+
577
+ export function useTheme() {
578
+ const context = useContext(ThemeContext);
579
+ if (!context) throw new Error("useTheme must be inside ThemeProvider");
580
+ return context;
581
+ }
582
+ ```
583
+
584
+ **layout.tsx — Wrap App:**
585
+ ```tsx
586
+ import { ThemeProvider } from "@/components/ThemeProvider";
587
+
588
+ export default function RootLayout({ children }) {
589
+ return (
590
+ <html lang="id">
591
+ <body>
592
+ <ThemeProvider>{children}</ThemeProvider>
593
+ </body>
594
+ </html>
595
+ );
596
+ }
597
+ ```
598
+
599
+ ### Gunakan di Komponen
600
+
601
+ ```tsx
602
+ import { useTheme } from "@/components/ThemeProvider";
603
+ import { tw } from "tailwind-styled-v4";
604
+
605
+ const ThemeButton = tw.button`
606
+ px-4 py-2 rounded-lg
607
+ bg-[var(--accent)] text-white
608
+ hover:opacity-80 transition
609
+ `;
610
+
611
+ export function ThemeToggle() {
612
+ const { theme, setTheme } = useTheme();
613
+
614
+ return (
615
+ <ThemeButton onClick={() => setTheme(theme === "light" ? "dark" : "light")}>
616
+ {theme === "light" ? "🌙 Dark" : "☀️ Light"}
617
+ </ThemeButton>
618
+ );
619
+ }
620
+ ```
621
+
622
+ ### Mengapa Ini Berbeda
623
+
624
+ Tailwind-styled-v4 tidak butuh library theme khusus — compiler Rust handle CSS optimization:
625
+
626
+ 1. **Build-time state extraction**: Compiler scan 81 file, extract 182 komponen, generate 20 state rules
627
+ 2. **CSS custom properties**: Tailwind bridge variabel ke design system via `@theme inline`
628
+ 3. **Zero runtime**: Theme toggle hanya set `data-theme` attribute — CSS change instant
629
+ 4. **localStorage + system preference**: ThemeProvider handle persistence dan auto-sync
630
+
631
+ **Hasil di `.next/tw-classes/_tw-state-static.css` (auto-generated):**
632
+ ```css
633
+ /* Button component state rules — pre-generated di build time */
634
+ .tw-s-b35937[data-disabled="true"] { opacity: 50%; cursor: not-allowed; }
635
+ .tw-s-b35937[data-loading="true"] { opacity: 60%; cursor: wait; }
636
+
637
+ /* State selectors menggunakan CSS variables */
638
+ .tw-s-93c530[data-copied="true"] {
639
+ background-color: var(--color-emerald-500);
640
+ color: var(--color-white);
641
+ }
642
+ ```
643
+
644
+ Semua state rules di-generate Rust saat build — tidak ada string comparison atau kondisional di runtime! 🚀
645
+
501
646
  export default {
502
647
  plugins: [tailwindStyled()],
503
648
  }
@@ -650,6 +795,33 @@ tailwind-styled-v4/
650
795
 
651
796
  ---
652
797
 
798
+ ## 🪄 Build-Time Magic: Pelajari Lebih Lanjut
799
+
800
+ Tailwind-styled-v4 melakukan serangkaian operasi sophisticated di build time. Baca dokumentasi untuk understand:
801
+
802
+ - **[.next-MAGIC-EXPLAINED.md](.next-MAGIC-EXPLAINED.md)** — Complete breakdown dari semua yang terjadi di `.next/tw-classes/`
803
+ - Phase 1-5 workflow
804
+ - Rust engine scanning (425× lebih cepat)
805
+ - State rule pre-generation
806
+ - Route attribution & CSS splitting
807
+ - Component hash determinism
808
+
809
+ - **[BUILD_TIME_FLOW_DIAGRAM.md](BUILD_TIME_FLOW_DIAGRAM.md)** — Visual flowchart & architecture
810
+ - Complete flow dari `npm run dev` hingga browser
811
+ - File dependency graph
812
+ - Key decision points & tradeoffs
813
+ - Performance comparison
814
+
815
+ - **[BUILD_ARTIFACTS_BREAKDOWN.md](BUILD_ARTIFACTS_BREAKDOWN.md)** — Apa yang actually di-generate
816
+ - `_initial-scan.css` (3500 lines)
817
+ - `_tw-state-static.css` (20 pre-generated rules)
818
+ - `css-manifest.json` (route attribution)
819
+ - Statistics & examples
820
+
821
+ **Highlight**: Engine melakukan ~370ms work di build time → runtime zero overhead ✨
822
+
823
+ ---
824
+
653
825
  ## Development
654
826
 
655
827
  ```bash
@@ -679,6 +851,50 @@ npm run bench
679
851
 
680
852
  ---
681
853
 
854
+ ## Build-Time Magic Documentation
855
+
856
+ Tailwind-styled-v4 performs 18+ layers of build-time optimization yang menghasilkan zero runtime overhead. Dokumentasi lengkap tersedia:
857
+
858
+ - **Quick Overview** (5 min): `MAGIC_QUICK_REFERENCE.md`
859
+ - **Architecture Flow** (15 min): `BUILD_TIME_FLOW_DIAGRAM.md`
860
+ - **Technical Deep Dive** (30 min): `.next-MAGIC-EXPLAINED.md`
861
+ - **Entire .next/ Folder** (30 min): `COMPLETE_NEXT_FOLDER_MAGIC.md`
862
+ - **Real Files Breakdown** (20 min): `BUILD_ARTIFACTS_BREAKDOWN.md`
863
+ - **All 18 Layers Explained** (45 min): `COMPLETE_MAGIC_LAYERS_NEXTJS_APP.md` ⭐
864
+
865
+ **Steering File** (for future agents): `.kiro/steering/build-time-magic.md`
866
+
867
+ Untuk development workflows dan advanced patterns, lihat:
868
+ - `PROPER_THEME_ARCHITECTURE.md` — Theme setup guide
869
+ - `ARIA_VS_VARIANTS_CLARIFICATION.md` — Accessibility patterns
870
+ - `FINAL_THEME_SOLUTION.md` — Complete theme solution
871
+ - `docs/WAVE5_INTEGRATION_GUIDE.md` — Wave 5 integration
872
+
873
+ ---
874
+
875
+ ## Build-Time Magic Documentation
876
+
877
+ Tailwind-styled-v4 performs 18+ layers of build-time optimization yang menghasilkan zero runtime overhead. Dokumentasi lengkap tersedia di `docs/` folder:
878
+
879
+ ### 📚 Quick Navigation
880
+
881
+ **Main Documentation Folder**:
882
+ - **`docs/README_BUILD_TIME_MAGIC.md`** - Main entry point
883
+ - **`docs/DOCUMENTATION_INDEX.md`** - Complete navigation guide
884
+ - **`docs/build-time-magic/`** - 18 layers documentation (6 files)
885
+ - **`docs/theme-architecture/`** - Theme setup patterns
886
+ - **`docs/accessibility/`** - ARIA & semantic components
887
+
888
+ ### 🚀 Start Reading
889
+
890
+ 1. **5-Minute Overview**: `docs/build-time-magic/01-QUICK_REFERENCE.md`
891
+ 2. **15-Minute Architecture**: `docs/build-time-magic/02-FLOW_DIAGRAM.md`
892
+ 3. **45-Minute Complete**: `docs/build-time-magic/06-ALL_18_LAYERS.md` ⭐
893
+
894
+ **All in**: `docs/build-time-magic/` folder with 6 comprehensive files.
895
+
896
+ ---
897
+
682
898
  ## Contributing
683
899
 
684
900
  PR dan issue sangat welcome. Prioritas saat ini:
package/dist/atomic.js CHANGED
@@ -186,7 +186,7 @@ var init_nativeBridge = __esm({
186
186
  "use strict";
187
187
  init_cjs_shims();
188
188
  init_src();
189
- _loadNative = (path5) => require(path5);
189
+ _loadNative = (path6) => require(path6);
190
190
  log = (...args) => {
191
191
  if (process.env.DEBUG?.includes("compiler:native")) {
192
192
  console.log("[compiler:native]", ...args);
@@ -339,14 +339,41 @@ var init_routeGraph = __esm({
339
339
  }
340
340
  });
341
341
 
342
+ // packages/domain/compiler/src/semanticComponentAnalyzer.ts
343
+ var init_semanticComponentAnalyzer = __esm({
344
+ "packages/domain/compiler/src/semanticComponentAnalyzer.ts"() {
345
+ "use strict";
346
+ init_cjs_shims();
347
+ }
348
+ });
349
+
350
+ // packages/domain/compiler/src/typeGeneratorFromMetadata.ts
351
+ var init_typeGeneratorFromMetadata = __esm({
352
+ "packages/domain/compiler/src/typeGeneratorFromMetadata.ts"() {
353
+ "use strict";
354
+ init_cjs_shims();
355
+ }
356
+ });
357
+
358
+ // packages/domain/compiler/src/typeGenerationPlugin.ts
359
+ var import_node_fs3, import_node_path3;
360
+ var init_typeGenerationPlugin = __esm({
361
+ "packages/domain/compiler/src/typeGenerationPlugin.ts"() {
362
+ "use strict";
363
+ init_cjs_shims();
364
+ import_node_fs3 = __toESM(require("fs"), 1);
365
+ import_node_path3 = __toESM(require("path"), 1);
366
+ }
367
+ });
368
+
342
369
  // packages/domain/compiler/src/index.ts
343
- var import_node_fs3, import_node_path3, import_node_module3, _require3;
370
+ var import_node_fs4, import_node_path4, import_node_module3, _require3;
344
371
  var init_src2 = __esm({
345
372
  "packages/domain/compiler/src/index.ts"() {
346
373
  "use strict";
347
374
  init_cjs_shims();
348
- import_node_fs3 = __toESM(require("fs"), 1);
349
- import_node_path3 = __toESM(require("path"), 1);
375
+ import_node_fs4 = __toESM(require("fs"), 1);
376
+ import_node_path4 = __toESM(require("path"), 1);
350
377
  import_node_module3 = require("module");
351
378
  init_nativeBridge();
352
379
  init_compiler();
@@ -356,6 +383,9 @@ var init_src2 = __esm({
356
383
  init_redis();
357
384
  init_watch();
358
385
  init_routeGraph();
386
+ init_semanticComponentAnalyzer();
387
+ init_typeGeneratorFromMetadata();
388
+ init_typeGenerationPlugin();
359
389
  _require3 = (0, import_node_module3.createRequire)(
360
390
  typeof require !== "undefined" ? typeof __filename !== "undefined" ? `file://${__filename}` : "file://unknown" : importMetaUrl
361
391
  );