@tempots/beatui 0.22.0 → 0.24.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.
Files changed (150) hide show
  1. package/README.md +9 -0
  2. package/dist/{2019-DsAbc1I5.cjs → 2019-7ojCcWUJ.cjs} +1 -1
  3. package/dist/{2019-BD_R8GCb.js → 2019-JwkYbae8.js} +2 -2
  4. package/dist/{2020-j6NLRYni.cjs → 2020-BLYgDBO4.cjs} +1 -1
  5. package/dist/{2020-DZOE7XZH.js → 2020-kK0rQWn9.js} +2 -2
  6. package/dist/{ar-CYAprS9_.cjs → ar-BAb4yHZS.cjs} +1 -1
  7. package/dist/{ar-DuYtkwHz.js → ar-BgrUqaxG.js} +1 -1
  8. package/dist/auth/index.cjs.js +1 -1
  9. package/dist/auth/index.es.js +3 -3
  10. package/dist/beatui.css +610 -394
  11. package/dist/beatui.tailwind.css +606 -394
  12. package/dist/{colors-B8HoRLA_.cjs → colors-Qc1mmmfr.cjs} +1 -1
  13. package/dist/{colors-5Nwx_gSj.js → colors-WfmhQ5e1.js} +63 -67
  14. package/dist/{de-BSxDfb1B.js → de-D_sdCcAw.js} +1 -1
  15. package/dist/{de-rQvC-Ydh.cjs → de-Dn2CdXgD.cjs} +1 -1
  16. package/dist/{es-BvmzhRc0.cjs → es-CEPxKSog.cjs} +1 -1
  17. package/dist/{es-CAIPTBfa.js → es-DczvLqEV.js} +1 -1
  18. package/dist/{fa-COTldXuh.js → fa-DhPP5Tgo.js} +1 -1
  19. package/dist/{fa-B3IJgHCh.cjs → fa-NvkKjIQ6.cjs} +1 -1
  20. package/dist/{fr-Djxzcm-x.js → fr-D3WwoeQg.js} +1 -1
  21. package/dist/{fr-C9hsLGOb.cjs → fr-cR59lx1A.cjs} +1 -1
  22. package/dist/{he-C_CvtpO2.js → he-CFhi-6Rs.js} +1 -1
  23. package/dist/{he-CHrcixO3.cjs → he-CxSHPJMg.cjs} +1 -1
  24. package/dist/{hi-C47vc5OG.js → hi-Cqy8JcS7.js} +1 -1
  25. package/dist/{hi-CpbCblie.cjs → hi-DLnz3lCX.cjs} +1 -1
  26. package/dist/{index-CeyxEbJL.cjs → index-0nXL1jt0.cjs} +1 -1
  27. package/dist/{index-C0yFCSoy.cjs → index-4MNPHZD0.cjs} +1 -1
  28. package/dist/{index-YbpU8b-b.cjs → index-4pbqdHdu.cjs} +1 -1
  29. package/dist/{index-m-1yJOxv.js → index-5kvan4pZ.js} +3 -3
  30. package/dist/{index--c2sxg96.js → index-8xL7lFvb.js} +2 -2
  31. package/dist/{index-KlPMACee.js → index-B8jOeOOB.js} +2 -2
  32. package/dist/{index-CW3QYddJ.js → index-BCaOVY88.js} +2 -2
  33. package/dist/{index-CsPpB1Kw.js → index-BICIDfB6.js} +1 -1
  34. package/dist/{index-BNQL8moK.js → index-BKHqr1z2.js} +2 -2
  35. package/dist/{index-BiHxJSI9.js → index-BSaEXg56.js} +3 -3
  36. package/dist/{index-B8EM1O9d.cjs → index-BSfK-Qwf.cjs} +1 -1
  37. package/dist/{index-SP-G4Erl.cjs → index-Bc-5l3Cz.cjs} +1 -1
  38. package/dist/{index-CjQ-nqcq.js → index-BeoVum6H.js} +1 -1
  39. package/dist/{index-BJZGXsLQ.cjs → index-Bk0BtvLD.cjs} +1 -1
  40. package/dist/{index-BUE3WeDh.cjs → index-BvXl7BJD.cjs} +1 -1
  41. package/dist/{index-DS0bdfOa.cjs → index-BzaR8uM1.cjs} +1 -1
  42. package/dist/{index-BIBYSE0O.js → index-C5uZbosj.js} +3 -3
  43. package/dist/{index-CcB11LV-.cjs → index-C7L2gKXf.cjs} +1 -1
  44. package/dist/{index-BtAze4TI.js → index-C7NeFFtL.js} +3 -3
  45. package/dist/{index-DtpMK8Ak.js → index-CEvEqrWz.js} +2 -2
  46. package/dist/{index-o4bA2Ymm.cjs → index-CGAE3ijj.cjs} +1 -1
  47. package/dist/{index-2J0cohRF.js → index-CJIznGSs.js} +2 -2
  48. package/dist/{index-h82qauh2.js → index-CKRtOTlW.js} +4 -4
  49. package/dist/{index-OUX19p46.js → index-CN4vYjXL.js} +2 -2
  50. package/dist/{index-CtlfDEiP.cjs → index-CPUSDEhf.cjs} +1 -1
  51. package/dist/{index-DPHERztz.cjs → index-CTiwmXQv.cjs} +1 -1
  52. package/dist/{index-c5HMVa4V.cjs → index-CflXJ8xJ.cjs} +1 -1
  53. package/dist/{index-BK8EFVAw.cjs → index-CgH6d8ie.cjs} +1 -1
  54. package/dist/{index-C4wKda5M.js → index-CiwYKSUt.js} +2 -2
  55. package/dist/{index-jLIz3LSI.js → index-Cwsc5H7D.js} +2 -2
  56. package/dist/{index-BLjWV-YV.cjs → index-D1rYqvi5.cjs} +2 -2
  57. package/dist/{index-BXHmDsV_.js → index-D6aavhaa.js} +2 -2
  58. package/dist/{index-C_T9Gzw8.js → index-DAdi5JJz.js} +2 -2
  59. package/dist/{index-CSK499Fw.cjs → index-DKyf2VGu.cjs} +1 -1
  60. package/dist/{index-CBlls5Ux.cjs → index-DXB8LND-.cjs} +1 -1
  61. package/dist/{index-D7a7hidA.js → index-DYmfX0jE.js} +100 -100
  62. package/dist/{index-_0aF8UPX.js → index-DZRUtuQ1.js} +2 -2
  63. package/dist/{index-CQcRWw-d.js → index-DqP1O6vK.js} +2 -2
  64. package/dist/{index-D3y-KMW-.js → index-Dr0vUVGJ.js} +4 -4
  65. package/dist/{index-CngY8bhO.cjs → index-DrNo6z9a.cjs} +1 -1
  66. package/dist/{index-C-UADaTN.cjs → index-Dsgj-jNd.cjs} +1 -1
  67. package/dist/index-Dvc6ZVJ3.cjs +1 -0
  68. package/dist/index-OrV7N-wE.js +680 -0
  69. package/dist/{index-Du_-zpYu.js → index-SPJ46EtH.js} +4 -4
  70. package/dist/{index-zcRhAq4N.cjs → index-ZuS9yWom.cjs} +1 -1
  71. package/dist/{index-BHOzetMx.cjs → index-ljok1ep6.cjs} +1 -1
  72. package/dist/{index-BIbSEVsf.cjs → index-uOI0LXHI.cjs} +1 -1
  73. package/dist/{index-jr-7RW3y.cjs → index-zvVNcjMi.cjs} +1 -1
  74. package/dist/index.cjs.js +4 -4
  75. package/dist/index.es.js +1731 -1731
  76. package/dist/{it-iA1CUA-2.cjs → it-C7Kv6j-_.cjs} +1 -1
  77. package/dist/{it-l8u4xqsP.js → it-CtMArqSp.js} +1 -1
  78. package/dist/{ja-CRKtLvpo.cjs → ja-BPL80aw5.cjs} +1 -1
  79. package/dist/{ja-Dr2Azv8X.js → ja-UFqZT78C.js} +1 -1
  80. package/dist/json-schema/index.cjs.js +1 -1
  81. package/dist/json-schema/index.es.js +1 -1
  82. package/dist/{ko-C97MbNN9.js → ko-B5LB1_X_.js} +1 -1
  83. package/dist/{ko-DAqjjbor.cjs → ko-Cmt_34Xp.cjs} +1 -1
  84. package/dist/markdown/index.cjs.js +1 -1
  85. package/dist/markdown/index.es.js +1 -1
  86. package/dist/markdown.css +52 -3
  87. package/dist/milkdown/index.cjs.js +1 -1
  88. package/dist/milkdown/index.es.js +1 -1
  89. package/dist/{milkdown-input-Dp-upGqQ.js → milkdown-input-BI5TwGax.js} +26 -26
  90. package/dist/{milkdown-input-EMBZNdma.cjs → milkdown-input-CdJ7N_YZ.cjs} +2 -2
  91. package/dist/{milkdown-url-DgMTahqt.js → milkdown-url-D99P-nA-.js} +1 -1
  92. package/dist/{milkdown-url-DjKYrEOH.cjs → milkdown-url-DqoUZH3u.cjs} +1 -1
  93. package/dist/milkdown.css +4 -4
  94. package/dist/{modal-at2TcO_O.js → modal-C2Aa-aVN.js} +1 -1
  95. package/dist/{modal-hr4K3edu.cjs → modal-UsqvSvHy.cjs} +1 -1
  96. package/dist/{nl-CCa2fPh7.cjs → nl-B-WL9SX2.cjs} +1 -1
  97. package/dist/{nl-BnDPAHZz.js → nl-DCfHVqzQ.js} +1 -1
  98. package/dist/notice-C7I6EmRh.cjs +1 -0
  99. package/dist/{notice-DhynzVip.js → notice-c9Vbv45l.js} +836 -821
  100. package/dist/{pl-BVuQd0i3.cjs → pl-TGqkSi2w.cjs} +1 -1
  101. package/dist/{pl-DYEVmpx5.js → pl-UcTv39q1.js} +1 -1
  102. package/dist/{pt-C-cIHGoh.js → pt-CXsgmVtb.js} +1 -1
  103. package/dist/{pt-BFGThC8F.cjs → pt-Ua_e-1JE.cjs} +1 -1
  104. package/dist/{ru-M4WO0h1a.cjs → ru-9YWCN6fR.cjs} +1 -1
  105. package/dist/{ru-n2tT3Gv-.js → ru-C0MvZW2g.js} +1 -1
  106. package/dist/styles-url-B3p8AqBy.cjs +1 -0
  107. package/dist/styles-url-COuz9fVH.js +4 -0
  108. package/dist/tailwind/index.cjs.js +1 -1
  109. package/dist/tailwind/index.es.js +2 -2
  110. package/dist/tailwind/preset.cjs.js +1 -1
  111. package/dist/tailwind/preset.es.js +3 -3
  112. package/dist/tailwind/vite-plugin.cjs.js +13 -6
  113. package/dist/tailwind/vite-plugin.es.js +478 -161
  114. package/dist/{tr-CFUAqbmS.js → tr-CIIkc1uL.js} +1 -1
  115. package/dist/{tr-KxY4CbD3.cjs → tr-D70Oy8aN.cjs} +1 -1
  116. package/dist/{translations-DGCYRUSw.js → translations-CB6iJ1Rn.js} +1 -1
  117. package/dist/translations-DpZ-btu9.cjs +2 -0
  118. package/dist/{translations-924E7r4Q.js → translations-GO9sIajX.js} +235 -203
  119. package/dist/{translations-Do79R-x4.cjs → translations-NYxsXjMT.cjs} +1 -1
  120. package/dist/types/components/button/button.d.ts +1 -1
  121. package/dist/types/components/form/input/checkbox-input.d.ts +8 -1
  122. package/dist/types/components/form/input/switch.d.ts +3 -1
  123. package/dist/types/components/misc/notice.d.ts +1 -1
  124. package/dist/types/components/navigation/link/link.d.ts +1 -1
  125. package/dist/types/components/theme/types.d.ts +1 -1
  126. package/dist/types/components/typography/label.d.ts +1 -1
  127. package/dist/types/tailwind/google-fonts.d.ts +45 -0
  128. package/dist/types/tailwind/preset.d.ts +34 -0
  129. package/dist/types/tailwind/vite-plugin.d.ts +4 -0
  130. package/dist/types/tokens/colors.d.ts +6 -6
  131. package/dist/types/tokens/index.d.ts +19 -1
  132. package/dist/types/tokens/motion.d.ts +25 -0
  133. package/dist/types/tokens/radius.d.ts +5 -0
  134. package/dist/types/tokens/shadows.d.ts +5 -0
  135. package/dist/types/tokens/spacing.d.ts +5 -0
  136. package/dist/types/tokens/text-shadows.d.ts +5 -0
  137. package/dist/types/tokens/typography.d.ts +9 -1
  138. package/dist/{ur-B7kT0PwV.js → ur-Cpx9oyTV.js} +1 -1
  139. package/dist/{ur-GeXcd9eA.cjs → ur-DmxXuJ9O.cjs} +1 -1
  140. package/dist/{vi-DYvrvqim.cjs → vi-Cboo_ueb.cjs} +1 -1
  141. package/dist/{vi-CA85io1z.js → vi-D24AUQ01.js} +1 -1
  142. package/dist/{zh-cLh5uTFh.js → zh-25YFRjoV.js} +1 -1
  143. package/dist/{zh-EIWIyzbZ.cjs → zh-BXivX7rD.cjs} +1 -1
  144. package/package.json +1 -1
  145. package/dist/index-Br70wXYb.cjs +0 -1
  146. package/dist/index-DVdM4Oz7.js +0 -420
  147. package/dist/notice-CplKL-zm.cjs +0 -1
  148. package/dist/styles-url-CIhMtnm4.js +0 -4
  149. package/dist/styles-url-SkuBc_7K.cjs +0 -1
  150. package/dist/translations-BtAHDMLA.cjs +0 -2
@@ -1,37 +1,222 @@
1
1
  import y from "node:fs";
2
- import n from "node:path";
3
- import { createRequire as L } from "node:module";
4
- import { pathToFileURL as A } from "node:url";
5
- import { c as x } from "../index-DVdM4Oz7.js";
6
- function E(t) {
7
- const e = typeof t == "string" ? new URL(t) : t;
8
- if (e.protocol !== "file:")
9
- throw new TypeError(`Expected file URL, received: ${e.href}`);
10
- const s = e.hostname, i = s === "" || s === "localhost", a = decodeURIComponent(e.pathname);
2
+ import c from "node:path";
3
+ import { createRequire as Z } from "node:module";
4
+ import { pathToFileURL as q } from "node:url";
5
+ import { g as ee, a as te, c as se } from "../index-OrV7N-wE.js";
6
+ import { mkdir as ne, writeFile as V, readFile as ae } from "node:fs/promises";
7
+ import { createHash as oe } from "node:crypto";
8
+ const re = "https://fonts.googleapis.com/css2", B = "normal", ie = 400, J = "Mozilla/5.0 (compatible; BeatUI Tailwind Plugin; +https://tempots.com)";
9
+ async function le(e) {
10
+ const { projectRoot: t, requests: s, logger: n } = e;
11
+ if (!s || s.length === 0)
12
+ return null;
13
+ const o = e.cacheDir ? c.resolve(e.cacheDir) : c.join(t, "node_modules", ".beatui", "google-fonts"), a = [], u = /* @__PURE__ */ new Map();
14
+ await ne(o, { recursive: !0 }).catch((m) => {
15
+ n?.(`Unable to create BeatUI Google Fonts cache directory: ${m}`);
16
+ });
17
+ for (const m of s)
18
+ try {
19
+ const d = Q(m), h = await ce({
20
+ request: m,
21
+ cssUrl: d,
22
+ cacheRoot: o,
23
+ logger: n
24
+ });
25
+ if (!h)
26
+ continue;
27
+ const T = await ge({
28
+ cssText: h,
29
+ cacheRoot: o,
30
+ assetMap: u,
31
+ logger: n
32
+ });
33
+ a.push(T);
34
+ } catch (d) {
35
+ n?.(
36
+ `Unexpected error while downloading Google Font "${m.family}": ${String(d)}`
37
+ );
38
+ }
39
+ return a.length === 0 || u.size === 0 ? null : {
40
+ cssText: a.join(`
41
+ `),
42
+ assets: Array.from(u.values())
43
+ };
44
+ }
45
+ async function ce({
46
+ request: e,
47
+ cssUrl: t,
48
+ cacheRoot: s,
49
+ logger: n
50
+ }) {
51
+ const o = c.join(s, ue(e, t));
52
+ try {
53
+ const a = await fetch(t, {
54
+ headers: {
55
+ "User-Agent": J
56
+ }
57
+ });
58
+ if (!a.ok)
59
+ throw new Error(
60
+ `Failed to download Google Font CSS: ${a.status} ${a.statusText}`
61
+ );
62
+ const u = await a.text();
63
+ return await V(o, u), u;
64
+ } catch (a) {
65
+ if (y.existsSync(o))
66
+ try {
67
+ const u = await ae(o, "utf8");
68
+ return n?.(
69
+ `Using cached Google Font CSS for ${e.family} because download failed.`
70
+ ), u;
71
+ } catch (u) {
72
+ n?.(
73
+ `Failed to read cached Google Font CSS for ${e.family}: ${u}`
74
+ );
75
+ }
76
+ return n?.(
77
+ `Unable to download Google Font CSS for ${e.family}: ${a}`
78
+ ), null;
79
+ }
80
+ }
81
+ function ue(e, t) {
82
+ const s = oe("sha1").update(t).digest("hex").slice(0, 10);
83
+ return `${e.family.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-") || "font"}-${s}.css`;
84
+ }
85
+ function Q(e) {
86
+ const { family: t } = e, s = t.trim().replace(/\s+/g, " "), n = de(e.weights), o = fe(e.styles), a = new URLSearchParams();
87
+ return a.append("family", me(s, n, o)), e.display && a.append("display", e.display), e.subsets && e.subsets.length > 0 && a.append("subset", e.subsets.join(",")), e.text && a.append("text", e.text), `${re}?${a.toString()}`;
88
+ }
89
+ function de(e) {
90
+ return !e || e.length === 0 ? [] : Array.from(new Set(e)).sort((t, s) => t - s);
91
+ }
92
+ function fe(e) {
93
+ if (!e || e.length === 0)
94
+ return [B];
95
+ const t = Array.from(new Set(e)), s = t.includes("italic"), n = t.includes("normal");
96
+ return !s && !n && t.push(B), t.sort((o, a) => o === a ? 0 : o === "normal" ? -1 : 1);
97
+ }
98
+ function me(e, t, s) {
99
+ if (t.length === 0 && s.every((d) => d === "normal"))
100
+ return e;
101
+ const n = s.includes("italic"), o = s.includes("normal"), a = t.length > 0 ? t : [ie];
102
+ if (!n)
103
+ return `${e}:wght@${a.join(";")}`;
104
+ const u = /* @__PURE__ */ new Set();
105
+ o && a.forEach((d) => {
106
+ u.add(`0,${d}`);
107
+ }), a.forEach((d) => {
108
+ u.add(`1,${d}`);
109
+ });
110
+ const m = Array.from(u).sort((d, h) => {
111
+ const [T, E] = d.split(",").map(Number), [R, U] = h.split(",").map(Number);
112
+ return T - R || E - U;
113
+ });
114
+ return `${e}:ital,wght@${m.join(";")}`;
115
+ }
116
+ const he = /url\(([^)]+)\)/g;
117
+ async function ge({
118
+ cssText: e,
119
+ cacheRoot: t,
120
+ assetMap: s,
121
+ logger: n
122
+ }) {
123
+ let o = e;
124
+ const a = /* @__PURE__ */ new Set();
125
+ let u;
126
+ for (; (u = he.exec(e)) !== null; ) {
127
+ const d = u[1].trim().replace(/^['"]|['"]$/g, "");
128
+ d.startsWith("http") && a.add(d);
129
+ }
130
+ for (const m of a) {
131
+ const d = await pe(m, t, s, n);
132
+ if (!d)
133
+ continue;
134
+ const h = m.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), T = new RegExp(`url\\((['"])${h}\\1\\)`, "g"), E = new RegExp(`url\\(${h}\\)`, "g");
135
+ o = o.replace(T, `url(${d.placeholder})`), o = o.replace(E, `url(${d.placeholder})`);
136
+ }
137
+ return o;
138
+ }
139
+ async function pe(e, t, s, n) {
140
+ const o = s.get(e);
141
+ if (o)
142
+ return o;
143
+ let a;
144
+ try {
145
+ const h = new URL(e);
146
+ a = c.basename(h.pathname);
147
+ } catch (h) {
148
+ return n?.(`Invalid Google Font URL skipped: ${e} (${h})`), null;
149
+ }
150
+ if (!a)
151
+ return n?.(`Unable to derive file name for Google Font URL: ${e}`), null;
152
+ const u = c.join(t, a), m = `__BEATUI_GOOGLE_FONT_${s.size}__`;
153
+ if (!y.existsSync(u))
154
+ try {
155
+ const h = await fetch(e, {
156
+ headers: {
157
+ "User-Agent": J
158
+ }
159
+ });
160
+ if (!h.ok)
161
+ return n?.(
162
+ `Failed to download Google Font asset ${a}: ${h.status} ${h.statusText}`
163
+ ), null;
164
+ const T = Buffer.from(await h.arrayBuffer());
165
+ await V(u, T);
166
+ } catch (h) {
167
+ return n?.(
168
+ `Unexpected error while downloading Google Font asset ${a}: ${String(h)}`
169
+ ), null;
170
+ }
171
+ const d = {
172
+ url: e,
173
+ fileName: a,
174
+ localPath: u,
175
+ placeholder: m
176
+ };
177
+ return s.set(e, d), d;
178
+ }
179
+ function X(e) {
180
+ const t = typeof e == "string" ? new URL(e) : e;
181
+ if (t.protocol !== "file:")
182
+ throw new TypeError(`Expected file URL, received: ${t.href}`);
183
+ const s = t.hostname, n = s === "" || s === "localhost", o = decodeURIComponent(t.pathname);
11
184
  if (process.platform === "win32") {
12
- let m = a.replace(/\//g, "\\");
13
- return !i && s ? `\\\\${s}${m}` : (m.startsWith("\\") && (m = m.slice(1)), m);
185
+ let a = o.replace(/\//g, "\\");
186
+ return !n && s ? `\\\\${s}${a}` : (a.startsWith("\\") && (a = a.slice(1)), a);
14
187
  }
15
- return !i && s ? `//${s}${a}` : a;
188
+ return !n && s ? `//${s}${o}` : o;
16
189
  }
17
- function B(t) {
18
- return typeof t == "object" && t !== null;
190
+ function we(e) {
191
+ return typeof e == "object" && e !== null;
19
192
  }
20
- function D(t) {
21
- if (typeof t == "string")
22
- return t;
23
- if (typeof t == "function")
24
- return t.name;
25
- if (B(t)) {
26
- const e = t.name;
27
- if (typeof e == "string")
28
- return e;
29
- const s = t.postcssPlugin;
193
+ function ye(e) {
194
+ if (typeof e == "string")
195
+ return e;
196
+ if (typeof e == "function")
197
+ return e.name;
198
+ if (we(e)) {
199
+ const t = e.name;
200
+ if (typeof t == "string")
201
+ return t;
202
+ const s = e.postcssPlugin;
30
203
  if (typeof s == "string")
31
204
  return s;
32
205
  }
33
206
  }
34
- const j = "@tempots/beatui/tailwind.css", f = "beatui.tailwind.css", d = n.dirname(E(import.meta.url)), v = N(d) ?? d, I = [
207
+ const D = "@tempots/beatui/tailwind.css", $ = "beatui.tailwind.css", b = c.dirname(X(import.meta.url)), L = Se(b) ?? b;
208
+ function M(e) {
209
+ if (Object.keys(e).length === 0)
210
+ return "";
211
+ let t = `:root {
212
+ `;
213
+ for (const [s, n] of Object.entries(e))
214
+ t += ` ${s}: ${n};
215
+ `;
216
+ return t += `}
217
+ `, t;
218
+ }
219
+ const W = [
35
220
  "tailwind.config.ts",
36
221
  "tailwind.config.js",
37
222
  "tailwind.config.mjs",
@@ -39,234 +224,366 @@ const j = "@tempots/beatui/tailwind.css", f = "beatui.tailwind.css", d = n.dirna
39
224
  "tailwind.config.mts",
40
225
  "tailwind.config.cts"
41
226
  ];
42
- function N(t) {
43
- let e = t;
44
- const s = n.parse(e).root;
45
- for (; e && e !== s; ) {
46
- const i = n.join(e, "package.json");
47
- if (y.existsSync(i))
227
+ function Se(e) {
228
+ let t = e;
229
+ const s = c.parse(t).root;
230
+ for (; t && t !== s; ) {
231
+ const n = c.join(t, "package.json");
232
+ if (y.existsSync(n))
48
233
  try {
49
- if (JSON.parse(y.readFileSync(i, "utf8"))?.name === "@tempots/beatui")
50
- return e;
234
+ if (JSON.parse(y.readFileSync(n, "utf8"))?.name === "@tempots/beatui")
235
+ return t;
51
236
  } catch {
52
237
  }
53
- e = n.dirname(e);
238
+ t = c.dirname(t);
54
239
  }
55
240
  return null;
56
241
  }
57
- const $ = /* @__PURE__ */ new Map();
58
- function O(t) {
59
- const e = n.resolve(t), s = $.get(e);
242
+ const z = /* @__PURE__ */ new Map();
243
+ function Fe(e) {
244
+ const t = c.resolve(e), s = z.get(t);
60
245
  if (s) return s;
61
- const i = n.join(e, "package.json"), a = L(
62
- y.existsSync(i) ? i : e
246
+ const n = c.join(t, "package.json"), o = Z(
247
+ y.existsSync(n) ? n : t
63
248
  );
64
- return $.set(e, a), a;
249
+ return z.set(t, o), o;
65
250
  }
66
- async function k(t, e) {
67
- const i = O(e).resolve(t);
68
- return await import(A(i).href);
251
+ async function H(e, t) {
252
+ const n = Fe(t).resolve(e);
253
+ return await import(q(n).href);
69
254
  }
70
- function T(t, e) {
71
- const s = e ? [e, ...I] : I;
72
- for (const i of s) {
73
- const a = n.resolve(t, i);
74
- if (y.existsSync(a))
75
- return a;
255
+ function _(e, t) {
256
+ const s = t ? [t, ...W] : W;
257
+ for (const n of s) {
258
+ const o = c.resolve(e, n);
259
+ if (y.existsSync(o))
260
+ return o;
76
261
  }
77
262
  return null;
78
263
  }
79
- function _(t) {
80
- if (t == null)
264
+ function be(e) {
265
+ if (e == null)
81
266
  return null;
82
- const e = typeof t == "string" ? t : t.id;
83
- if (!e)
267
+ const t = typeof e == "string" ? e : e.id;
268
+ if (!t)
84
269
  return null;
85
- const [s] = e.split("?");
86
- return s.startsWith("virtual:") || s.startsWith("\0") ? null : s.startsWith("/@fs/") ? decodeURIComponent(s.slice(4)) : s.startsWith("file://") ? E(s) : n.isAbsolute(s) ? s : null;
270
+ const [s] = t.split("?");
271
+ return s.startsWith("virtual:") || s.startsWith("\0") ? null : s.startsWith("/@fs/") ? decodeURIComponent(s.slice(4)) : s.startsWith("file://") ? X(s) : c.isAbsolute(s) ? s : null;
87
272
  }
88
- function W(t) {
89
- const e = /* @__PURE__ */ new Set([
90
- n.resolve(d, f),
91
- n.resolve(d, "../", f),
92
- n.resolve(d, "../../", f),
93
- n.resolve(d, "tailwind.css"),
94
- n.resolve(d, "../tailwind.css"),
95
- n.resolve(d, "../../tailwind.css"),
96
- n.resolve(d, "../styles/tailwind.css"),
97
- n.resolve(d, "../../styles/tailwind.css"),
98
- n.resolve(v, "dist", f),
99
- n.resolve(v, f),
100
- n.resolve(v, "tailwind.css"),
101
- n.resolve(v, "src/styles/tailwind.css"),
102
- n.resolve(t, "node_modules/@tempots/beatui/tailwind.css")
273
+ function $e(e) {
274
+ const t = /* @__PURE__ */ new Set([
275
+ c.resolve(b, $),
276
+ c.resolve(b, "../", $),
277
+ c.resolve(b, "../../", $),
278
+ c.resolve(b, "tailwind.css"),
279
+ c.resolve(b, "../tailwind.css"),
280
+ c.resolve(b, "../../tailwind.css"),
281
+ c.resolve(b, "../styles/tailwind.css"),
282
+ c.resolve(b, "../../styles/tailwind.css"),
283
+ c.resolve(L, "dist", $),
284
+ c.resolve(L, $),
285
+ c.resolve(L, "tailwind.css"),
286
+ c.resolve(L, "src/styles/tailwind.css"),
287
+ c.resolve(e, "node_modules/@tempots/beatui/tailwind.css")
103
288
  ]);
104
- for (const s of e)
289
+ for (const s of t)
105
290
  if (y.existsSync(s))
106
291
  return s;
107
292
  return null;
108
293
  }
109
- async function M(t, e) {
110
- const s = t.resolve;
294
+ function Te(e) {
295
+ return e ? Array.isArray(e) ? e : [e] : [];
296
+ }
297
+ function Ce(e, t) {
298
+ let s = e;
299
+ for (const [n, o] of t)
300
+ s = s.split(n).join(o);
301
+ return s;
302
+ }
303
+ async function ve(e, t) {
304
+ const s = e.resolve;
111
305
  if (!s)
112
306
  return null;
113
307
  try {
114
- return await s.call(t, e, void 0, { skipSelf: !0 });
308
+ return await s.call(e, t, void 0, { skipSelf: !0 });
115
309
  } catch {
116
310
  return null;
117
311
  }
118
312
  }
119
- function Q(t = {}) {
120
- let e = process.cwd(), s = T(e, t.tailwindConfigPath) ?? null;
121
- const i = t.injectCss !== !1, a = t.darkClass ?? "dark", m = t.rtlAttribute ?? "dir", R = t.rtlValue ?? "rtl";
122
- let b = "/";
123
- const F = {
124
- semanticColors: t.semanticColors,
125
- includeCoreTokens: t.includeCoreTokens,
126
- includeSemanticTokens: t.includeSemanticTokens,
127
- extendTheme: t.extendTheme
313
+ function Le(e = {}) {
314
+ let t = process.cwd(), s = _(t, e.tailwindConfigPath) ?? null;
315
+ const n = e.injectCss !== !1, o = e.darkClass ?? "dark", a = e.rtlAttribute ?? "dir", u = e.rtlValue ?? "rtl";
316
+ let m = "/";
317
+ const d = {
318
+ semanticColors: e.semanticColors,
319
+ semanticFonts: e.semanticFonts,
320
+ semanticRadii: e.semanticRadii,
321
+ semanticShadows: e.semanticShadows,
322
+ semanticMotion: e.semanticMotion,
323
+ semanticSpacing: e.semanticSpacing,
324
+ semanticTextShadows: e.semanticTextShadows,
325
+ fontFamilies: e.fontFamilies,
326
+ includeCoreTokens: e.includeCoreTokens,
327
+ includeSemanticTokens: e.includeSemanticTokens,
328
+ extendTheme: e.extendTheme
329
+ }, T = e.semanticColors != null || e.semanticFonts != null || e.semanticRadii != null || e.semanticShadows != null || e.semanticMotion != null || e.semanticSpacing != null || e.semanticTextShadows != null ? M(
330
+ ee({
331
+ colors: e.semanticColors,
332
+ fonts: e.semanticFonts,
333
+ radii: e.semanticRadii,
334
+ shadows: e.semanticShadows,
335
+ motion: e.semanticMotion,
336
+ spacing: e.semanticSpacing,
337
+ textShadows: e.semanticTextShadows
338
+ })
339
+ ) : "", E = e.fontFamilies ? M(
340
+ te(e.fontFamilies)
341
+ ) : "", R = Te(e.googleFonts);
342
+ let U = "", j = [];
343
+ const N = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), K = "/@beatui/google-fonts", I = [];
344
+ let k = null, P = null, O = !1;
345
+ const G = (f) => {
346
+ const i = [T, E];
347
+ return U && (f === "dev" ? i.push(
348
+ Ce(U, N)
349
+ ) : i.push(U)), i.filter((l) => l && l.length > 0).join(`
350
+ `);
128
351
  };
129
- let h = null;
130
352
  return {
131
353
  name: "beatui-tailwind",
132
354
  enforce: "pre",
133
- async configResolved(r) {
134
- if (e = r.root, s = T(e, t.tailwindConfigPath) ?? s, b = r.base && r.base !== "/" ? r.base.endsWith("/") ? r.base : `${r.base}/` : "/", i) {
135
- const o = await M(
355
+ async configResolved(f) {
356
+ if (t = f.root, O = f.command === "build", s = _(t, e.tailwindConfigPath) ?? s, m = f.base && f.base !== "/" ? f.base.endsWith("/") ? f.base : `${f.base}/` : "/", n) {
357
+ const i = await ve(
136
358
  this,
137
- j
359
+ D
138
360
  );
139
- h = _(o) ?? W(e);
361
+ P = be(i) ?? $e(t);
140
362
  }
363
+ if (R.length > 0) {
364
+ const i = Array.from(
365
+ new Set(R.map(Q))
366
+ ), l = await le({
367
+ projectRoot: t,
368
+ requests: R,
369
+ logger: (r) => this.warn(`[BeatUI] ${r}`)
370
+ });
371
+ if (U = l?.cssText ?? "", j = l?.assets ?? [], N.clear(), x.clear(), A.clear(), I.length = 0, j.length > 0)
372
+ for (const r of j) {
373
+ const g = `${K}/${r.fileName}`;
374
+ N.set(r.placeholder, g), A.set(g, r.localPath);
375
+ }
376
+ else
377
+ I.push(...i);
378
+ } else
379
+ I.length = 0;
141
380
  s || this.warn(
142
381
  "[BeatUI] Tailwind config file not found. BeatUI preset will not be auto-registered. Specify tailwindConfigPath if your config lives elsewhere."
143
- ), i && !h && this.warn(
382
+ ), n && !P && this.warn(
144
383
  "[BeatUI] Unable to resolve @tempots/beatui/tailwind.css. CSS will not be auto-injected."
145
384
  );
146
385
  },
147
- configureServer(r) {
148
- !i || h == null || r.middlewares.use((o, l, g) => {
149
- const P = o.method ?? "GET";
150
- if (!["GET", "HEAD"].includes(P)) {
151
- g();
386
+ configureServer(f) {
387
+ !n || P == null || (f.middlewares.use((i, l, r) => {
388
+ const g = i.method ?? "GET";
389
+ if (!["GET", "HEAD"].includes(g)) {
390
+ r();
152
391
  return;
153
392
  }
154
- const S = (o.url ?? "").split("?")[0];
393
+ const w = (i.url ?? "").split("?")[0];
155
394
  if (!new Set(
156
395
  [
157
- `/${f}`,
158
- b === "/" ? null : `${b}${f}`
159
- ].filter((c) => !!c)
160
- ).has(S)) {
161
- g();
396
+ `/${$}`,
397
+ m === "/" ? null : `${m}${$}`
398
+ ].filter((p) => !!p)
399
+ ).has(w)) {
400
+ r();
162
401
  return;
163
402
  }
164
403
  l.setHeader("Content-Type", "text/css");
165
- const w = y.createReadStream(h);
166
- w.on("error", (c) => {
167
- r.config.logger.error(
168
- `[BeatUI] Failed to stream ${j}: ${String(c)}`
404
+ try {
405
+ let p = y.readFileSync(P, "utf8");
406
+ const C = G("dev");
407
+ C && (p += `
408
+ ${C}`), l.end(p);
409
+ } catch (p) {
410
+ f.config.logger.error(
411
+ `[BeatUI] Failed to stream ${D}: ${String(p)}`
169
412
  ), l.statusCode = 500, l.end();
170
- }), w.pipe(l);
171
- });
413
+ }
414
+ }), A.size > 0 && f.middlewares.use((i, l, r) => {
415
+ const g = i.method ?? "GET";
416
+ if (!["GET", "HEAD"].includes(g)) {
417
+ r();
418
+ return;
419
+ }
420
+ const w = (i.url ?? "").split("?")[0], S = w ? A.get(w) : void 0;
421
+ if (!S) {
422
+ r();
423
+ return;
424
+ }
425
+ l.setHeader("Content-Type", "font/woff2"), y.createReadStream(S).on("error", () => {
426
+ l.statusCode = 500, l.end();
427
+ }).pipe(l);
428
+ }));
172
429
  },
173
430
  buildStart() {
174
- if (!i || h == null) return;
175
- const r = h, o = y.readFileSync(r, "utf8");
176
- this.emitFile({
431
+ if (!O || !n || P == null) return;
432
+ x.clear(), k = null;
433
+ const f = P;
434
+ let i = y.readFileSync(f, "utf8");
435
+ const l = G("raw");
436
+ if (l && (i += `
437
+ ${l}`), k = this.emitFile({
177
438
  type: "asset",
178
- fileName: f,
179
- source: o
180
- });
439
+ fileName: $,
440
+ source: i
441
+ }), j.length > 0)
442
+ for (const r of j)
443
+ try {
444
+ const g = y.readFileSync(r.localPath), w = this.emitFile({
445
+ type: "asset",
446
+ name: `assets/${r.fileName}`,
447
+ source: g
448
+ });
449
+ x.set(r.placeholder, w);
450
+ } catch (g) {
451
+ this.warn(
452
+ `[BeatUI] Failed to include Google Font asset ${r.fileName}: ${String(
453
+ g
454
+ )}`
455
+ );
456
+ }
181
457
  },
182
- async config(r) {
183
- const o = x(F), l = r.css, g = {};
184
- typeof l == "object" && l !== null && Object.assign(g, l);
185
- const P = g.postcss;
186
- let S = {};
187
- typeof P == "object" && P !== null && (S = { ...P });
188
- const C = S.plugins;
189
- let w = [];
190
- Array.isArray(C) ? w = [...C] : C && (w = [C]), s || (s = T(e, t.tailwindConfigPath) ?? null);
191
- let c;
458
+ async config(f) {
459
+ const i = se(d), l = f.css, r = {};
460
+ typeof l == "object" && l !== null && Object.assign(r, l);
461
+ const g = r.postcss;
462
+ let w = {};
463
+ typeof g == "object" && g !== null && (w = { ...g });
464
+ const S = w.plugins;
465
+ let p = [];
466
+ Array.isArray(S) ? p = [...S] : S && (p = [S]), s || (s = _(t, e.tailwindConfigPath) ?? null);
467
+ let C;
192
468
  try {
193
- const u = await k(
469
+ const F = await H(
194
470
  "@tailwindcss/postcss",
195
- e
471
+ t
196
472
  );
197
- c = u.default ?? u;
473
+ C = F.default ?? F;
198
474
  } catch {
199
475
  }
200
- if (typeof c != "function")
476
+ if (typeof C != "function")
201
477
  try {
202
- const u = await k(
478
+ const F = await H(
203
479
  "tailwindcss",
204
- e
480
+ t
205
481
  );
206
- c = u.default ?? u;
207
- } catch (u) {
208
- const p = u instanceof Error && u.message ? ` (${u.message})` : "";
482
+ C = F.default ?? F;
483
+ } catch (F) {
484
+ const v = F instanceof Error && F.message ? ` (${F.message})` : "";
209
485
  this.warn(
210
- `[BeatUI] Unable to load Tailwind CSS automatically. Install \`@tailwindcss/postcss\` (Tailwind v4) or \`tailwindcss\` (legacy) in your project.${p}`
486
+ `[BeatUI] Unable to load Tailwind CSS automatically. Install \`@tailwindcss/postcss\` (Tailwind v4) or \`tailwindcss\` (legacy) in your project.${v}`
211
487
  );
212
488
  }
213
- if (typeof c == "function") {
214
- if (!w.some(
215
- (p) => D(p) === "tailwindcss"
489
+ if (typeof C == "function") {
490
+ if (!p.some(
491
+ (v) => ye(v) === "tailwindcss"
216
492
  ))
217
493
  try {
218
- const p = c({
494
+ const v = C({
219
495
  config: s ?? {
220
- presets: [o]
496
+ presets: [i]
221
497
  }
222
498
  });
223
- w.push(p);
224
- } catch (p) {
225
- const U = p instanceof Error && p.message ? ` (${p.message})` : "";
499
+ p.push(v);
500
+ } catch (v) {
501
+ const Y = v instanceof Error && v.message ? ` (${v.message})` : "";
226
502
  this.warn(
227
- `[BeatUI] Failed to initialize Tailwind automatically. Install \`@tailwindcss/postcss\` (Tailwind v4) or register Tailwind manually.${U}`
503
+ `[BeatUI] Failed to initialize Tailwind automatically. Install \`@tailwindcss/postcss\` (Tailwind v4) or register Tailwind manually.${Y}`
228
504
  );
229
505
  }
230
- } else c != null && this.warn(
506
+ } else C != null && this.warn(
231
507
  "[BeatUI] Unable to load Tailwind CSS automatically. Received unexpected module shape."
232
508
  );
233
509
  return {
234
510
  define: {
235
- "import.meta.env.BEATUI_TAILWIND_PRESET": JSON.stringify(o)
511
+ "import.meta.env.BEATUI_TAILWIND_PRESET": JSON.stringify(i)
236
512
  },
237
513
  css: {
238
- ...g,
514
+ ...r,
239
515
  postcss: {
240
- ...S,
241
- plugins: w
516
+ ...w,
517
+ plugins: p
242
518
  }
243
519
  }
244
520
  };
245
521
  },
246
- transformIndexHtml(r) {
247
- const o = [];
248
- if (i && h) {
249
- const g = b === "/" ? `/${f}` : `${b}${f}`;
250
- o.push({
522
+ generateBundle(f, i) {
523
+ if (!O || !k)
524
+ return;
525
+ const l = this.getFileName(k), r = i[l];
526
+ if (!r || r.type !== "asset" || typeof r.source != "string")
527
+ return;
528
+ let g = r.source;
529
+ for (const [w, S] of x) {
530
+ const p = this.getFileName(S);
531
+ g = g.split(w).join(p);
532
+ }
533
+ r.source = g;
534
+ },
535
+ transformIndexHtml(f) {
536
+ const i = [];
537
+ if (n && P) {
538
+ const r = m === "/" ? `/${$}` : `${m}${$}`;
539
+ i.push({
251
540
  tag: "link",
252
541
  attrs: {
253
542
  rel: "stylesheet",
254
- href: g
543
+ href: r
255
544
  },
256
545
  injectTo: "head-prepend"
257
546
  });
258
547
  }
548
+ I.length > 0 && i.push(
549
+ {
550
+ tag: "link",
551
+ attrs: {
552
+ rel: "preconnect",
553
+ href: "https://fonts.googleapis.com"
554
+ },
555
+ injectTo: "head"
556
+ },
557
+ {
558
+ tag: "link",
559
+ attrs: {
560
+ rel: "preconnect",
561
+ href: "https://fonts.gstatic.com",
562
+ crossorigin: ""
563
+ },
564
+ injectTo: "head"
565
+ },
566
+ ...I.map((r) => ({
567
+ tag: "link",
568
+ attrs: {
569
+ rel: "stylesheet",
570
+ href: r,
571
+ "data-beatui-google-font": ""
572
+ },
573
+ injectTo: "head"
574
+ }))
575
+ );
259
576
  const l = `
260
577
  (() => {
261
578
  const apply = () => {
262
579
  const root = document.documentElement
263
580
  const target = document.body
264
581
  if (!target) return
265
- const hasDark = root.classList.contains('${a.replace(/'/g, "\\'")}')
582
+ const hasDark = root.classList.contains('${o.replace(/'/g, "\\'")}')
266
583
  target.classList.toggle('b-dark', hasDark)
267
584
  target.classList.toggle('b-light', !hasDark)
268
- const dirValue = root.getAttribute('${m.replace(/'/g, "\\'")}')
269
- const isRtl = dirValue === '${R.replace(/'/g, "\\'")}'
585
+ const dirValue = root.getAttribute('${a.replace(/'/g, "\\'")}')
586
+ const isRtl = dirValue === '${u.replace(/'/g, "\\'")}'
270
587
  target.classList.toggle('b-rtl', isRtl)
271
588
  target.classList.toggle('b-ltr', !isRtl)
272
589
  }
@@ -278,20 +595,20 @@ function Q(t = {}) {
278
595
  const observer = new MutationObserver(apply)
279
596
  observer.observe(document.documentElement, {
280
597
  attributes: true,
281
- attributeFilter: ['class', '${m.replace(/'/g, "\\'")}'],
598
+ attributeFilter: ['class', '${a.replace(/'/g, "\\'")}'],
282
599
  })
283
600
  })();
284
601
  `;
285
- return o.push({
602
+ return i.push({
286
603
  tag: "script",
287
604
  attrs: { type: "module" },
288
605
  children: l,
289
606
  injectTo: "body"
290
- }), { html: r, tags: o };
607
+ }), { html: f, tags: i };
291
608
  }
292
609
  };
293
610
  }
294
611
  export {
295
- Q as beatuiTailwindPlugin,
296
- Q as default
612
+ Le as beatuiTailwindPlugin,
613
+ Le as default
297
614
  };