weapp-tailwindcss 5.0.13 → 5.1.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 (178) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/auto-Ba6hDrse.mjs +13 -0
  4. package/dist/auto-DtU6f3X6.js +18 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
  7. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +21 -9
  8. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  9. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
  11. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
  12. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
  13. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  14. package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
  15. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  16. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  17. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  18. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  19. package/dist/bundlers/vite/css-memory.d.ts +10 -0
  20. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  21. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
  23. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +0 -1
  24. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
  25. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +5 -0
  26. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
  27. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
  28. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
  29. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  30. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
  31. package/dist/bundlers/vite/generate-bundle.d.ts +3 -1
  32. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  33. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  34. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  35. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
  36. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  37. package/dist/bundlers/vite/source-candidates.d.ts +9 -2
  38. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
  39. package/dist/bundlers/vite/source-scan.d.ts +2 -2
  40. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  41. package/dist/bundlers/vite/utils.d.ts +1 -0
  42. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
  43. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
  44. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  45. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
  46. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
  47. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  48. package/dist/cache/index.d.ts +1 -0
  49. package/dist/cli/mount-options.d.ts +2 -2
  50. package/dist/cli.js +124 -437
  51. package/dist/cli.mjs +120 -433
  52. package/dist/context/index.d.ts +3 -3
  53. package/dist/context/style-options.d.ts +4 -1
  54. package/dist/context/tailwindcss.d.ts +1 -1
  55. package/dist/{precheck-B0Z8yW7E.js → context-BHxLe743.js} +391 -153
  56. package/dist/{precheck-CRI90iL1.mjs → context-Mbzkek1q.mjs} +368 -137
  57. package/dist/core.js +15 -12
  58. package/dist/core.mjs +10 -7
  59. package/dist/css-macro.js +1 -1
  60. package/dist/css-macro.mjs +1 -1
  61. package/dist/{defaults-C_J_kBpw.js → defaults-CVcKbXBG.js} +4 -15
  62. package/dist/{defaults-Bqx18S1f.mjs → defaults-ZElj1zKc.mjs} +5 -10
  63. package/dist/defaults.d.ts +1 -7
  64. package/dist/defaults.js +1 -2
  65. package/dist/defaults.mjs +2 -2
  66. package/dist/generator/index.d.ts +6 -7
  67. package/dist/generator/options.d.ts +3 -3
  68. package/dist/generator/types.d.ts +9 -10
  69. package/dist/generator-9rUz4Hcb.js +170 -0
  70. package/dist/generator-Dc4qaPmT.mjs +123 -0
  71. package/dist/generator.js +10 -16
  72. package/dist/generator.mjs +3 -3
  73. package/dist/{gulp-XT8Jc7lH.js → gulp-B_sdP6dx.js} +47 -87
  74. package/dist/{gulp-DfOQERcV.mjs → gulp-uM36oIJs.mjs} +40 -80
  75. package/dist/gulp.js +1 -1
  76. package/dist/gulp.mjs +1 -1
  77. package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-BXMLsF4b.mjs} +1145 -842
  78. package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CogqkFaF.js} +1262 -881
  79. package/dist/index.js +4 -4
  80. package/dist/index.mjs +4 -4
  81. package/dist/js/fast-path/oxc.d.ts +4 -0
  82. package/dist/js/precheck.d.ts +1 -0
  83. package/dist/postcss.js +3 -4
  84. package/dist/postcss.mjs +2 -3
  85. package/dist/presets.js +9 -19
  86. package/dist/presets.mjs +8 -18
  87. package/dist/runtime-branch/create-branch.d.ts +2 -0
  88. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  89. package/dist/runtime-branch/index.d.ts +6 -0
  90. package/dist/runtime-branch/mini-program.d.ts +2 -0
  91. package/dist/runtime-branch/native-app.d.ts +2 -0
  92. package/dist/runtime-branch/platform.d.ts +6 -0
  93. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  94. package/dist/runtime-branch/types.d.ts +37 -0
  95. package/dist/runtime-branch/web.d.ts +2 -0
  96. package/dist/runtime-branch.d.ts +1 -0
  97. package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-2ybpptAK.js} +261 -19
  98. package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
  99. package/dist/tailwindcss/candidates.d.ts +7 -0
  100. package/dist/tailwindcss/index.d.ts +2 -2
  101. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  102. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  103. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  104. package/dist/tailwindcss/runtime-types.d.ts +86 -0
  105. package/dist/tailwindcss/runtime.d.ts +6 -6
  106. package/dist/tailwindcss/source-scan.d.ts +1 -1
  107. package/dist/tailwindcss/targets.d.ts +2 -2
  108. package/dist/tailwindcss/v4/config.d.ts +3 -3
  109. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  110. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  111. package/dist/tailwindcss/v4/index.d.ts +1 -1
  112. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  113. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  114. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  115. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  116. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  117. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  118. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  119. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  120. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  121. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  122. package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
  123. package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
  124. package/dist/tailwindcss/version.d.ts +1 -1
  125. package/dist/tailwindcss-DHIYcqXT.js +1523 -0
  126. package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
  127. package/dist/{transform-YmrmxuF3.js → transform-CQVOgmzM.js} +17 -17
  128. package/dist/{transform-DfcEjsZF.mjs → transform-tExdt40m.mjs} +2 -2
  129. package/dist/typedoc.export.d.ts +1 -1
  130. package/dist/types/index.d.ts +16 -17
  131. package/dist/types/shared.d.ts +1 -1
  132. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  133. package/dist/types/user-defined-options/general.d.ts +5 -3
  134. package/dist/types/user-defined-options/important.d.ts +2 -2
  135. package/dist/uni-app-x/style-asset.d.ts +1 -0
  136. package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
  137. package/dist/v4-engine-D4ubP7N5.js +2778 -0
  138. package/dist/{vite-CXHVsHmX.js → vite-CP0ylSxZ.js} +1081 -542
  139. package/dist/{vite-DjI09vVN.mjs → vite-CPO83EhA.mjs} +916 -376
  140. package/dist/vite.js +1 -1
  141. package/dist/vite.mjs +1 -1
  142. package/dist/weapp-tw-css-import-rewrite-loader.js +5350 -4165
  143. package/dist/weapp-tw-runtime-classset-loader.js +15 -4
  144. package/dist/webpack-Bsek8VhR.js +2094 -0
  145. package/dist/webpack-BzqhJ8yK.mjs +2082 -0
  146. package/dist/webpack.js +1 -1
  147. package/dist/webpack.mjs +1 -1
  148. package/package.json +4 -5
  149. package/dist/auto-CTp6wE5a.js +0 -33
  150. package/dist/auto-Cl8_hsG6.mjs +0 -22
  151. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  152. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  153. package/dist/context/tailwindcss/rax.d.ts +0 -2
  154. package/dist/generator-CzpArpCL.js +0 -92
  155. package/dist/generator-ITLd7PTl.mjs +0 -67
  156. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  157. package/dist/tailwindcss/patcher.d.ts +0 -12
  158. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  159. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  160. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  161. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  162. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  163. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  164. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  165. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  166. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  167. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  168. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  169. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  170. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  171. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  172. package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
  173. package/dist/tailwindcss-DZEwT3C_.js +0 -613
  174. package/dist/v3-engine-2rrgylhn.js +0 -4686
  175. package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
  176. package/dist/webpack-BcPpnT90.mjs +0 -1184
  177. package/dist/webpack-CfkUkMXG.js +0 -1196
  178. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -0,0 +1,2396 @@
1
+ import { a as withCssMacroStyleOptions, i as transformCssMacroCss, n as hasCssMacroTailwindV4Directive, t as hasCssMacroStyleOptions } from "./auto-Ba6hDrse.mjs";
2
+ import { createRequire } from "node:module";
3
+ import fs, { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+ import { createTailwindV4Engine, extractRawCandidates, loadTailwindV4DesignSystem, resolveProjectSourceFiles, resolveTailwindV4Source } from "@tailwindcss-mangle/engine";
7
+ import { createStyleHandler, normalizeTailwindcssWebRpxDeclarations, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
8
+ import { LRUCache } from "lru-cache";
9
+ import { stat } from "node:fs/promises";
10
+ import micromatch from "micromatch";
11
+ //#region src/runtime-branch/generator-target-env.ts
12
+ const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
13
+ const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
14
+ const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
15
+ function getEnvValue(key) {
16
+ return typeof process === "undefined" ? void 0 : process.env[key];
17
+ }
18
+ function normalizeGeneratorTargetValue(value) {
19
+ return value === "weapp" || value === "web" ? value : void 0;
20
+ }
21
+ function isUniWebPlatform(value) {
22
+ const normalized = value?.trim().toLowerCase();
23
+ return normalized === "h5" || normalized?.startsWith("web") === true;
24
+ }
25
+ function isUniAppWebViewPlatform(value) {
26
+ const normalized = value?.trim().toLowerCase();
27
+ return normalized === "app" || normalized === "app-plus";
28
+ }
29
+ function isUniNativeAppPlatform(value) {
30
+ return (value?.trim().toLowerCase())?.startsWith("app-") === true;
31
+ }
32
+ function isMpxWebPlatform(value) {
33
+ return value?.trim().toLowerCase() === "web";
34
+ }
35
+ function inferGeneratorTargetFromExplicitEnv() {
36
+ for (const key of explicitGeneratorTargetEnvKeys) {
37
+ const target = normalizeGeneratorTargetValue(getEnvValue(key));
38
+ if (target !== void 0) return target;
39
+ }
40
+ }
41
+ function shouldUseWebGeneratorTargetFromEnv() {
42
+ return uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5";
43
+ }
44
+ function inferGeneratorTargetFromEnv() {
45
+ return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
46
+ }
47
+ //#endregion
48
+ //#region src/utils/object.ts
49
+ function definedEntries(value) {
50
+ return Object.entries(value).filter(([, item]) => item !== void 0);
51
+ }
52
+ function omitUndefined(value) {
53
+ return Object.fromEntries(definedEntries(value));
54
+ }
55
+ //#endregion
56
+ //#region src/tailwindcss/v4-engine/candidates.ts
57
+ const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
58
+ function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
59
+ return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
60
+ }
61
+ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
62
+ if (!candidates) return;
63
+ return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
64
+ }
65
+ //#endregion
66
+ //#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
67
+ const TAILWIND_V4_COLOR_STEPS = [
68
+ "50",
69
+ "100",
70
+ "200",
71
+ "300",
72
+ "400",
73
+ "500",
74
+ "600",
75
+ "700",
76
+ "800",
77
+ "900",
78
+ "950"
79
+ ];
80
+ const TAILWIND_V4_COLOR_PALETTE = {
81
+ slate: [
82
+ "#f8fafc",
83
+ "#f1f5f9",
84
+ "#e2e8f0",
85
+ "#cad5e2",
86
+ "#90a1b9",
87
+ "#62748e",
88
+ "#45556c",
89
+ "#314158",
90
+ "#1d293d",
91
+ "#0f172b",
92
+ "#020618"
93
+ ],
94
+ gray: [
95
+ "#f9fafb",
96
+ "#f3f4f6",
97
+ "#e5e7eb",
98
+ "#d1d5dc",
99
+ "#99a1af",
100
+ "#6a7282",
101
+ "#4a5565",
102
+ "#364153",
103
+ "#1e2939",
104
+ "#101828",
105
+ "#030712"
106
+ ],
107
+ zinc: [
108
+ "#fafafa",
109
+ "#f4f4f5",
110
+ "#e4e4e7",
111
+ "#d4d4d8",
112
+ "#9f9fa9",
113
+ "#71717b",
114
+ "#52525c",
115
+ "#3f3f46",
116
+ "#27272a",
117
+ "#18181b",
118
+ "#09090b"
119
+ ],
120
+ neutral: [
121
+ "#fafafa",
122
+ "#f5f5f5",
123
+ "#e5e5e5",
124
+ "#d4d4d4",
125
+ "#a1a1a1",
126
+ "#737373",
127
+ "#525252",
128
+ "#404040",
129
+ "#262626",
130
+ "#171717",
131
+ "#0a0a0a"
132
+ ],
133
+ stone: [
134
+ "#fafaf9",
135
+ "#f5f5f4",
136
+ "#e7e5e4",
137
+ "#d6d3d1",
138
+ "#a6a09b",
139
+ "#79716b",
140
+ "#57534d",
141
+ "#44403b",
142
+ "#292524",
143
+ "#1c1917",
144
+ "#0c0a09"
145
+ ],
146
+ mauve: [
147
+ "#fafafa",
148
+ "#f3f1f3",
149
+ "#e7e4e7",
150
+ "#d7d0d7",
151
+ "#a89ea9",
152
+ "#79697b",
153
+ "#594c5b",
154
+ "#463947",
155
+ "#2a212c",
156
+ "#1d161e",
157
+ "#0c090c"
158
+ ],
159
+ olive: [
160
+ "#fbfbf9",
161
+ "#f4f4f0",
162
+ "#e8e8e3",
163
+ "#d8d8d0",
164
+ "#abab9c",
165
+ "#7c7c67",
166
+ "#5b5b4b",
167
+ "#474739",
168
+ "#2b2b22",
169
+ "#1d1d16",
170
+ "#0c0c09"
171
+ ],
172
+ mist: [
173
+ "#f9fbfb",
174
+ "#f1f3f3",
175
+ "#e3e7e8",
176
+ "#d0d6d8",
177
+ "#9ca8ab",
178
+ "#67787c",
179
+ "#4b585b",
180
+ "#394447",
181
+ "#22292b",
182
+ "#161b1d",
183
+ "#090b0c"
184
+ ],
185
+ taupe: [
186
+ "#fbfaf9",
187
+ "#f3f1f1",
188
+ "#e8e4e3",
189
+ "#d8d2d0",
190
+ "#aba09c",
191
+ "#7c6d67",
192
+ "#5b4f4b",
193
+ "#473c39",
194
+ "#2b2422",
195
+ "#1d1816",
196
+ "#0c0a09"
197
+ ],
198
+ red: [
199
+ "#fef2f2",
200
+ "#ffe2e2",
201
+ "#ffc9c9",
202
+ "#ffa2a2",
203
+ "#ff6467",
204
+ "#fb2c36",
205
+ "#e7000b",
206
+ "#c10007",
207
+ "#9f0712",
208
+ "#82181a",
209
+ "#460809"
210
+ ],
211
+ orange: [
212
+ "#fff7ed",
213
+ "#ffedd4",
214
+ "#ffd6a7",
215
+ "#ffb86a",
216
+ "#ff8904",
217
+ "#ff6900",
218
+ "#f54900",
219
+ "#ca3500",
220
+ "#9f2d00",
221
+ "#7e2a0c",
222
+ "#441306"
223
+ ],
224
+ amber: [
225
+ "#fffbeb",
226
+ "#fef3c6",
227
+ "#fee685",
228
+ "#ffd230",
229
+ "#ffb900",
230
+ "#fe9a00",
231
+ "#e17100",
232
+ "#bb4d00",
233
+ "#973c00",
234
+ "#7b3306",
235
+ "#461901"
236
+ ],
237
+ yellow: [
238
+ "#fefce8",
239
+ "#fef9c2",
240
+ "#fff085",
241
+ "#ffdf20",
242
+ "#fdc700",
243
+ "#f0b100",
244
+ "#d08700",
245
+ "#a65f00",
246
+ "#894b00",
247
+ "#733e0a",
248
+ "#432004"
249
+ ],
250
+ lime: [
251
+ "#f7fee7",
252
+ "#ecfcca",
253
+ "#d8f999",
254
+ "#bbf451",
255
+ "#9ae600",
256
+ "#7ccf00",
257
+ "#5ea500",
258
+ "#497d00",
259
+ "#3c6300",
260
+ "#35530e",
261
+ "#192e03"
262
+ ],
263
+ green: [
264
+ "#f0fdf4",
265
+ "#dcfce7",
266
+ "#b9f8cf",
267
+ "#7bf1a8",
268
+ "#05df72",
269
+ "#00c950",
270
+ "#00a63e",
271
+ "#008236",
272
+ "#016630",
273
+ "#0d542b",
274
+ "#032e15"
275
+ ],
276
+ emerald: [
277
+ "#ecfdf5",
278
+ "#d0fae5",
279
+ "#a4f4cf",
280
+ "#5ee9b5",
281
+ "#00d492",
282
+ "#00bc7d",
283
+ "#009966",
284
+ "#007a55",
285
+ "#006045",
286
+ "#004f3b",
287
+ "#002c22"
288
+ ],
289
+ teal: [
290
+ "#f0fdfa",
291
+ "#cbfbf1",
292
+ "#96f7e4",
293
+ "#46ecd5",
294
+ "#00d5be",
295
+ "#00bba7",
296
+ "#009689",
297
+ "#00786f",
298
+ "#005f5a",
299
+ "#0b4f4a",
300
+ "#022f2e"
301
+ ],
302
+ cyan: [
303
+ "#ecfeff",
304
+ "#cefafe",
305
+ "#a2f4fd",
306
+ "#53eafd",
307
+ "#00d3f2",
308
+ "#00b8db",
309
+ "#0092b8",
310
+ "#007595",
311
+ "#005f78",
312
+ "#104e64",
313
+ "#053345"
314
+ ],
315
+ sky: [
316
+ "#f0f9ff",
317
+ "#dff2fe",
318
+ "#b8e6fe",
319
+ "#74d4ff",
320
+ "#00bcff",
321
+ "#00a6f4",
322
+ "#0084d1",
323
+ "#0069a8",
324
+ "#00598a",
325
+ "#024a70",
326
+ "#052f4a"
327
+ ],
328
+ blue: [
329
+ "#eff6ff",
330
+ "#dbeafe",
331
+ "#bedbff",
332
+ "#8ec5ff",
333
+ "#51a2ff",
334
+ "#2b7fff",
335
+ "#155dfc",
336
+ "#1447e6",
337
+ "#193cb8",
338
+ "#1c398e",
339
+ "#162456"
340
+ ],
341
+ indigo: [
342
+ "#eef2ff",
343
+ "#e0e7ff",
344
+ "#c6d2ff",
345
+ "#a3b3ff",
346
+ "#7c86ff",
347
+ "#615fff",
348
+ "#4f39f6",
349
+ "#432dd7",
350
+ "#372aac",
351
+ "#312c85",
352
+ "#1e1a4d"
353
+ ],
354
+ violet: [
355
+ "#f5f3ff",
356
+ "#ede9fe",
357
+ "#ddd6ff",
358
+ "#c4b4ff",
359
+ "#a684ff",
360
+ "#8e51ff",
361
+ "#7f22fe",
362
+ "#7008e7",
363
+ "#5d0ec0",
364
+ "#4d179a",
365
+ "#2f0d68"
366
+ ],
367
+ purple: [
368
+ "#faf5ff",
369
+ "#f3e8ff",
370
+ "#e9d4ff",
371
+ "#dab2ff",
372
+ "#c27aff",
373
+ "#ad46ff",
374
+ "#9810fa",
375
+ "#8200db",
376
+ "#6e11b0",
377
+ "#59168b",
378
+ "#3c0366"
379
+ ],
380
+ fuchsia: [
381
+ "#fdf4ff",
382
+ "#fae8ff",
383
+ "#f6cfff",
384
+ "#f4a8ff",
385
+ "#ed6aff",
386
+ "#e12afb",
387
+ "#c800de",
388
+ "#a800b7",
389
+ "#8a0194",
390
+ "#721378",
391
+ "#4b004f"
392
+ ],
393
+ pink: [
394
+ "#fdf2f8",
395
+ "#fce7f3",
396
+ "#fccee8",
397
+ "#fda5d5",
398
+ "#fb64b6",
399
+ "#f6339a",
400
+ "#e60076",
401
+ "#c6005c",
402
+ "#a3004c",
403
+ "#861043",
404
+ "#510424"
405
+ ],
406
+ rose: [
407
+ "#fff1f2",
408
+ "#ffe4e6",
409
+ "#ffccd3",
410
+ "#ffa1ad",
411
+ "#ff637e",
412
+ "#ff2056",
413
+ "#ec003f",
414
+ "#c70036",
415
+ "#a50036",
416
+ "#8b0836",
417
+ "#4d0218"
418
+ ]
419
+ };
420
+ function createTailwindV4DefaultColorThemeCss() {
421
+ const declarations = [" --color-black: #000;", " --color-white: #fff;"];
422
+ for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
423
+ return [
424
+ "@theme {",
425
+ ...declarations,
426
+ "}"
427
+ ].join("\n");
428
+ }
429
+ //#endregion
430
+ //#region src/tailwindcss/v4-engine/generator/css-compat.ts
431
+ function findLeadingImportInsertionIndex(css) {
432
+ const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
433
+ let insertionIndex = 0;
434
+ let match = importPattern.exec(css);
435
+ while (match !== null) {
436
+ insertionIndex = match.index + match[0].length;
437
+ match = importPattern.exec(css);
438
+ }
439
+ return insertionIndex;
440
+ }
441
+ function applyMiniProgramTailwindV4DefaultColorCss(css) {
442
+ const themeCss = createTailwindV4DefaultColorThemeCss();
443
+ const insertionIndex = findLeadingImportInsertionIndex(css);
444
+ if (insertionIndex === 0) return `${themeCss}\n${css}`;
445
+ return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
446
+ }
447
+ function parseCssImportSpecifier$2(params) {
448
+ const value = params.trim();
449
+ const quoted = /^(['"])(.*?)\1/.exec(value);
450
+ if (quoted) return quoted[2];
451
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
452
+ return url?.[2] ?? url?.[3];
453
+ }
454
+ function isTailwindCssPreflightImport(params) {
455
+ const specifier = parseCssImportSpecifier$2(params);
456
+ return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
457
+ }
458
+ function removeTailwindV4PreflightImports(css) {
459
+ if (!css.includes("preflight")) return css;
460
+ let root;
461
+ try {
462
+ root = postcss.parse(css);
463
+ } catch {
464
+ return css;
465
+ }
466
+ let changed = false;
467
+ root.walkAtRules("import", (rule) => {
468
+ if (isTailwindCssPreflightImport(rule.params)) {
469
+ rule.remove();
470
+ changed = true;
471
+ }
472
+ });
473
+ return changed ? root.toString() : css;
474
+ }
475
+ function hasThemeParent(rule) {
476
+ let parent = rule.parent;
477
+ while (parent) {
478
+ if (parent.type === "atrule" && parent.name === "theme") return true;
479
+ parent = parent.parent;
480
+ }
481
+ return false;
482
+ }
483
+ function isVendorPrefixedKeyframes(rule) {
484
+ return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
485
+ }
486
+ function removeUnsupportedThemeVendorKeyframes(css) {
487
+ if (!css.includes("@theme") || !css.includes("@-")) return css;
488
+ let root;
489
+ try {
490
+ root = postcss.parse(css);
491
+ } catch {
492
+ return css;
493
+ }
494
+ let changed = false;
495
+ root.walkAtRules((rule) => {
496
+ if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
497
+ rule.remove();
498
+ changed = true;
499
+ }
500
+ });
501
+ return changed ? root.toString() : css;
502
+ }
503
+ function createCompatibleSource(source, target) {
504
+ const filteredSourceCss = target === "weapp" ? removeTailwindV4PreflightImports(source.css) : source.css;
505
+ const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
506
+ return compatibleSourceCss === source.css ? source : {
507
+ ...source,
508
+ css: compatibleSourceCss
509
+ };
510
+ }
511
+ //#endregion
512
+ //#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
513
+ const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
514
+ const BARE_RPX_LENGTH_CANDIDATE_RE = new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
515
+ const BARE_RPX_LENGTH_HINT_CANDIDATE_RE = new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
516
+ const RPX_LENGTH_SELECTOR_RE = new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
517
+ function normalizeRpxLengthCandidate(candidate) {
518
+ return candidate.replace(BARE_RPX_LENGTH_CANDIDATE_RE, (_match, prefix, important, utility, value, suffix) => {
519
+ return `${prefix}${important}${utility}-[length:${value}]${suffix}`;
520
+ });
521
+ }
522
+ function normalizeRpxLengthCandidates(candidates) {
523
+ const normalized = /* @__PURE__ */ new Set();
524
+ const restoreCandidates = /* @__PURE__ */ new Map();
525
+ for (const candidate of candidates) {
526
+ const normalizedCandidate = normalizeRpxLengthCandidate(candidate);
527
+ normalized.add(normalizedCandidate);
528
+ if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
529
+ }
530
+ return {
531
+ candidates: normalized,
532
+ restoreCandidates
533
+ };
534
+ }
535
+ function restoreRpxLengthCandidates(candidates, restoreCandidates) {
536
+ if (restoreCandidates.size === 0) return new Set(candidates);
537
+ return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
538
+ }
539
+ function normalizeCssEscapedRpxSelectorValue(value) {
540
+ return value.replace(/\\([.+-])/g, "$1");
541
+ }
542
+ function restoreRpxLengthCssSelectors(css, restoreCandidates) {
543
+ if (restoreCandidates.size === 0 || !css.includes("\\[length\\:")) return css;
544
+ const restoredUtilities = new Set([...restoreCandidates.keys()].map((candidate) => {
545
+ const match = BARE_RPX_LENGTH_HINT_CANDIDATE_RE.exec(candidate);
546
+ return match ? `${match[1]}:${match[2]}` : void 0;
547
+ }).filter((value) => Boolean(value)));
548
+ return css.replace(RPX_LENGTH_SELECTOR_RE, (match, utility, value) => {
549
+ return restoredUtilities.has(`${utility}:${normalizeCssEscapedRpxSelectorValue(value)}`) ? `${utility}-\\[${value}\\]` : match;
550
+ });
551
+ }
552
+ //#endregion
553
+ //#region src/tailwindcss/source-scan/inline-source.ts
554
+ const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
555
+ function segmentTopLevel(input, separator, options = {}) {
556
+ const parts = [];
557
+ const stack = [];
558
+ let lastPos = 0;
559
+ let quote;
560
+ for (let index = 0; index < input.length; index++) {
561
+ const char = input[index];
562
+ if (char === "\\") {
563
+ index += 1;
564
+ continue;
565
+ }
566
+ if (quote) {
567
+ if (char === quote) quote = void 0;
568
+ continue;
569
+ }
570
+ if (char === "\"" || char === "'") {
571
+ quote = char;
572
+ continue;
573
+ }
574
+ if (char === "(") {
575
+ stack.push(")");
576
+ continue;
577
+ }
578
+ if (char === "[") {
579
+ stack.push("]");
580
+ continue;
581
+ }
582
+ if (char === "{") {
583
+ stack.push("}");
584
+ continue;
585
+ }
586
+ if (stack.length > 0 && char === stack[stack.length - 1]) {
587
+ stack.pop();
588
+ continue;
589
+ }
590
+ if (stack.length === 0 && char === separator) {
591
+ const part = input.slice(lastPos, index);
592
+ if (part || options.keepEmpty) parts.push(part);
593
+ lastPos = index + 1;
594
+ }
595
+ }
596
+ const part = input.slice(lastPos);
597
+ if (part || options.keepEmpty) parts.push(part);
598
+ return parts;
599
+ }
600
+ function isSequence(value) {
601
+ return NUMERICAL_RANGE_RE.test(value);
602
+ }
603
+ function expandSequence(value) {
604
+ const match = value.match(NUMERICAL_RANGE_RE);
605
+ if (!match) return [value];
606
+ const [, start, end, stepValue] = match;
607
+ if (start === void 0 || end === void 0) return [value];
608
+ let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
609
+ const startNumber = Number.parseInt(start, 10);
610
+ const endNumber = Number.parseInt(end, 10);
611
+ const increasing = startNumber < endNumber;
612
+ if (step === void 0) step = increasing ? 1 : -1;
613
+ if (step === 0) return [];
614
+ if (increasing && step < 0) step = -step;
615
+ if (!increasing && step > 0) step = -step;
616
+ const result = [];
617
+ for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
618
+ return result;
619
+ }
620
+ function expandInlineSourceCandidatePattern(pattern) {
621
+ const index = pattern.indexOf("{");
622
+ if (index === -1) return [pattern];
623
+ const prefix = pattern.slice(0, index);
624
+ const rest = pattern.slice(index);
625
+ let depth = 0;
626
+ let endIndex = -1;
627
+ for (let index = 0; index < rest.length; index++) {
628
+ const char = rest[index];
629
+ if (char === "{") depth += 1;
630
+ else if (char === "}") {
631
+ depth -= 1;
632
+ if (depth === 0) {
633
+ endIndex = index;
634
+ break;
635
+ }
636
+ }
637
+ }
638
+ if (endIndex === -1) return [pattern];
639
+ const inner = rest.slice(1, endIndex);
640
+ const suffix = rest.slice(endIndex + 1);
641
+ const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
642
+ return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
643
+ }
644
+ function parseSourceInlineParam(params) {
645
+ let value = params.trim();
646
+ const negated = value.startsWith("not ");
647
+ if (negated) value = value.slice(4).trim();
648
+ if (!value.startsWith("inline(") || !value.endsWith(")")) return;
649
+ const inlineValue = value.slice(7, -1).trim();
650
+ const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
651
+ if (!match) return;
652
+ const source = match[2];
653
+ if (source === void 0) return;
654
+ return {
655
+ negated,
656
+ source
657
+ };
658
+ }
659
+ function collectCssInlineSourceCandidates(root) {
660
+ const included = /* @__PURE__ */ new Set();
661
+ const excluded = /* @__PURE__ */ new Set();
662
+ root.walkAtRules("source", (rule) => {
663
+ const parsed = parseSourceInlineParam(rule.params);
664
+ if (!parsed) return;
665
+ const target = parsed.negated ? excluded : included;
666
+ for (const source of segmentTopLevel(parsed.source, " ")) {
667
+ const trimmed = source.trim();
668
+ if (!trimmed) continue;
669
+ for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
670
+ const normalized = candidate.trim();
671
+ if (normalized) target.add(normalized);
672
+ }
673
+ }
674
+ });
675
+ for (const candidate of excluded) included.delete(candidate);
676
+ return {
677
+ included,
678
+ excluded
679
+ };
680
+ }
681
+ //#endregion
682
+ //#region src/tailwindcss/source-scan.ts
683
+ const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
684
+ "html",
685
+ "wxml",
686
+ "axml",
687
+ "jxml",
688
+ "ksml",
689
+ "ttml",
690
+ "qml",
691
+ "tyml",
692
+ "xhsml",
693
+ "swan",
694
+ "vue",
695
+ "mpx",
696
+ "js",
697
+ "jsx",
698
+ "ts",
699
+ "tsx"
700
+ ];
701
+ const FULL_SOURCE_SCAN_EXTENSIONS = [
702
+ "js",
703
+ "jsx",
704
+ "mjs",
705
+ "cjs",
706
+ "ts",
707
+ "tsx",
708
+ "mts",
709
+ "cts",
710
+ "vue",
711
+ "uvue",
712
+ "nvue",
713
+ "svelte",
714
+ "mpx",
715
+ "html",
716
+ "wxml",
717
+ "axml",
718
+ "jxml",
719
+ "ksml",
720
+ "ttml",
721
+ "qml",
722
+ "tyml",
723
+ "xhsml",
724
+ "swan",
725
+ "css",
726
+ "wxss",
727
+ "acss",
728
+ "jxss",
729
+ "ttss",
730
+ "qss",
731
+ "tyss",
732
+ "scss",
733
+ "sass",
734
+ "less",
735
+ "styl",
736
+ "stylus"
737
+ ];
738
+ function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
739
+ return `**/*.{${extensions.join(",")}}`;
740
+ }
741
+ const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
742
+ const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
743
+ function toPosixPath(value) {
744
+ return value.split(path.sep).join("/");
745
+ }
746
+ function resolveSourceScanPath(value) {
747
+ const resolved = path.resolve(value);
748
+ try {
749
+ return realpathSync.native(resolved);
750
+ } catch {
751
+ return resolved;
752
+ }
753
+ }
754
+ function normalizeEntryPattern(entry) {
755
+ return path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
756
+ }
757
+ function isFileMatchedByTailwindSourceEntry(file, entry) {
758
+ const relative = toPosixPath(path.relative(resolveSourceScanPath(entry.base), file));
759
+ return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizeEntryPattern(entry));
760
+ }
761
+ function isFileExcludedByTailwindSourceEntries(file, entries) {
762
+ if (!entries?.length) return false;
763
+ const resolvedFile = resolveSourceScanPath(file);
764
+ return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
765
+ }
766
+ function isFileMatchedByTailwindSourceEntries(file, entries) {
767
+ if (!entries?.length) return true;
768
+ const positiveEntries = entries.filter((entry) => !entry.negated);
769
+ const negativeEntries = entries.filter((entry) => entry.negated);
770
+ const resolvedFile = resolveSourceScanPath(file);
771
+ if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
772
+ if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
773
+ return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
774
+ }
775
+ function createTailwindSourceEntryMatcher(entries) {
776
+ if (!entries?.length) return;
777
+ return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
778
+ }
779
+ function resolveTailwindV4CssSourceBase(source, fallbackBase) {
780
+ if (typeof source.base === "string" && source.base.length > 0) return source.base;
781
+ if (typeof source.file === "string" && source.file.length > 0) return path.dirname(source.file);
782
+ return fallbackBase;
783
+ }
784
+ function parseConfigParam(params) {
785
+ const value = params.trim();
786
+ return /^(['"])(.+)\1$/.exec(value)?.[2];
787
+ }
788
+ function isLegacyContentObject(value) {
789
+ return typeof value === "object" && value !== null && "files" in value;
790
+ }
791
+ function normalizeGlobPattern(pattern) {
792
+ return pattern.startsWith("./") ? pattern.slice(2) : pattern;
793
+ }
794
+ function hasGlobMagic(value) {
795
+ return /[*?[\]{}()!+@]/.test(value);
796
+ }
797
+ function splitStaticGlobPrefix(pattern) {
798
+ const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
799
+ const prefix = [];
800
+ const rest = [];
801
+ let reachedGlob = false;
802
+ for (const segment of segments) {
803
+ if (!reachedGlob && segment && !hasGlobMagic(segment)) {
804
+ prefix.push(segment);
805
+ continue;
806
+ }
807
+ reachedGlob = true;
808
+ rest.push(segment);
809
+ }
810
+ return {
811
+ prefix,
812
+ rest
813
+ };
814
+ }
815
+ function normalizeLegacyContentEntries(content, base, options = {}) {
816
+ if (typeof content === "string") {
817
+ const negated = content.startsWith("!");
818
+ return [{
819
+ base,
820
+ negated,
821
+ pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
822
+ }];
823
+ }
824
+ if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
825
+ if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
826
+ return [];
827
+ }
828
+ async function pathExistsAsDirectory(file) {
829
+ try {
830
+ return (await stat(file)).isDirectory();
831
+ } catch {
832
+ return false;
833
+ }
834
+ }
835
+ async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
836
+ const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
837
+ if (await pathExistsAsDirectory(absoluteSource)) return {
838
+ base: absoluteSource,
839
+ negated,
840
+ pattern: normalizeGlobPattern(defaultPattern)
841
+ };
842
+ if (path.isAbsolute(sourcePath) && hasGlobMagic(sourcePath)) {
843
+ const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
844
+ const root = path.parse(sourcePath).root;
845
+ const normalizedPrefix = prefix[0] === "" ? prefix.slice(1) : prefix;
846
+ if (rest.length > 0) return {
847
+ base: path.resolve(root, ...normalizedPrefix),
848
+ negated,
849
+ pattern: normalizeGlobPattern(rest.join("/"))
850
+ };
851
+ }
852
+ if (path.isAbsolute(sourcePath)) return {
853
+ base: path.dirname(absoluteSource),
854
+ negated,
855
+ pattern: normalizeGlobPattern(path.basename(absoluteSource))
856
+ };
857
+ const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
858
+ if (prefix.length > 0 && rest.length > 0) return {
859
+ base: path.resolve(base, ...prefix),
860
+ negated,
861
+ pattern: normalizeGlobPattern(rest.join("/"))
862
+ };
863
+ return {
864
+ base,
865
+ negated,
866
+ pattern: normalizeGlobPattern(sourcePath)
867
+ };
868
+ }
869
+ function parseSourceFileParam(params) {
870
+ const value = params.trim();
871
+ if (!value || value === "none" || value.startsWith("inline(")) return;
872
+ const negated = value.startsWith("not ");
873
+ const sourceValue = negated ? value.slice(4).trim() : value;
874
+ if (sourceValue.startsWith("inline(")) return;
875
+ const match = /^(['"])(.+)\1$/.exec(sourceValue);
876
+ return match?.[2] ? {
877
+ negated,
878
+ sourcePath: match[2]
879
+ } : void 0;
880
+ }
881
+ async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
882
+ const entries = [];
883
+ const tasks = [];
884
+ root.walkAtRules("source", (rule) => {
885
+ const parsed = parseSourceFileParam(rule.params);
886
+ if (!parsed) return;
887
+ tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
888
+ });
889
+ entries.push(...await Promise.all(tasks));
890
+ return entries;
891
+ }
892
+ async function expandTailwindSourceEntries(entries, options = {}) {
893
+ if (entries.length === 0) return [];
894
+ const files = /* @__PURE__ */ new Set();
895
+ const entriesByBase = /* @__PURE__ */ new Map();
896
+ for (const entry of entries) {
897
+ const base = path.resolve(entry.base);
898
+ const group = entriesByBase.get(base) ?? [];
899
+ group.push({
900
+ ...entry,
901
+ base
902
+ });
903
+ entriesByBase.set(base, group);
904
+ }
905
+ await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
906
+ const ignoredSources = options.ignore?.map((pattern) => ({
907
+ base,
908
+ pattern: normalizeGlobPattern(pattern),
909
+ negated: true
910
+ }));
911
+ const matched = await resolveProjectSourceFiles({
912
+ cwd: base,
913
+ sources: group,
914
+ ...ignoredSources === void 0 ? {} : { ignoredSources }
915
+ });
916
+ for (const file of matched) files.add(path.resolve(file));
917
+ }));
918
+ return [...files].filter((file) => !isFileExcludedByTailwindSourceEntries(file, entries));
919
+ }
920
+ //#endregion
921
+ //#region src/tailwindcss/v4-engine/generator/scan-sources.ts
922
+ const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
923
+ "**/.git/**",
924
+ "**/.hg/**",
925
+ "**/.jj/**",
926
+ "**/.next/**",
927
+ "**/.parcel-cache/**",
928
+ "**/.pnpm-store/**",
929
+ "**/.svelte-kit/**",
930
+ "**/.svn/**",
931
+ "**/.turbo/**",
932
+ "**/.venv/**",
933
+ "**/.vercel/**",
934
+ "**/.yarn/**",
935
+ "**/__pycache__/**",
936
+ "**/node_modules/**",
937
+ "**/venv/**",
938
+ "**/*.less",
939
+ "**/*.lock",
940
+ "**/*.sass",
941
+ "**/*.scss",
942
+ "**/*.styl",
943
+ "**/*.log",
944
+ "**/package-lock.json",
945
+ "**/pnpm-lock.yaml",
946
+ "**/bun.lockb",
947
+ "**/.gitignore",
948
+ "**/.env",
949
+ "**/.env.*"
950
+ ];
951
+ function parseImportSourceParam(params) {
952
+ const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
953
+ if (!match) return;
954
+ return {
955
+ none: match[1] === "none",
956
+ sourcePath: match[3]
957
+ };
958
+ }
959
+ function parseCssImportSpecifier$1(params) {
960
+ const value = params.trim();
961
+ const quoted = /^(['"])(.*?)\1/.exec(value);
962
+ if (quoted) return quoted[2];
963
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
964
+ return url?.[2] ?? url?.[3];
965
+ }
966
+ function isTailwindCssImport(params) {
967
+ const specifier = parseCssImportSpecifier$1(params);
968
+ return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
969
+ }
970
+ function resolveSourceBase(base, sourcePath) {
971
+ return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
972
+ }
973
+ function createDefaultIgnoredScanSources(base) {
974
+ return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
975
+ base,
976
+ pattern,
977
+ negated: true
978
+ }));
979
+ }
980
+ function normalizeCssDefinedScanSources(base, entries) {
981
+ return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
982
+ base,
983
+ pattern: "**/*",
984
+ negated: false
985
+ }, ...entries] : entries;
986
+ }
987
+ function resolveDefaultSourceBase(source) {
988
+ return source.projectRoot ?? source.cwd ?? source.base;
989
+ }
990
+ async function resolveCssDefinedScanSources(source) {
991
+ let importSourceBase;
992
+ let hasSourceNone = false;
993
+ let hasTailwindImport = false;
994
+ const from = source.dependencies[0];
995
+ let root;
996
+ try {
997
+ root = postcss.parse(source.css, { from });
998
+ } catch {
999
+ return;
1000
+ }
1001
+ root.walkAtRules((rule) => {
1002
+ if (rule.name === "import") {
1003
+ if (!isTailwindCssImport(rule.params)) return;
1004
+ hasTailwindImport = true;
1005
+ const sourceParam = parseImportSourceParam(rule.params);
1006
+ if (sourceParam?.none) hasSourceNone = true;
1007
+ if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(source.base, sourceParam.sourcePath);
1008
+ }
1009
+ });
1010
+ const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
1011
+ if (!importSourceBase) {
1012
+ if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
1013
+ if (hasSourceNone) return false;
1014
+ if (hasTailwindImport) {
1015
+ const defaultBase = resolveDefaultSourceBase(source);
1016
+ return [await resolveTailwindSourceEntry(".", defaultBase, false, "**/*"), ...createDefaultIgnoredScanSources(defaultBase)];
1017
+ }
1018
+ return;
1019
+ }
1020
+ return [
1021
+ await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
1022
+ ...sourcePatterns,
1023
+ ...createDefaultIgnoredScanSources(importSourceBase)
1024
+ ];
1025
+ }
1026
+ async function resolveScanSources(source, scanSources) {
1027
+ if (scanSources !== true) return scanSources;
1028
+ return await resolveCssDefinedScanSources(source) ?? false;
1029
+ }
1030
+ //#endregion
1031
+ //#region src/tailwindcss/v4-engine/miniprogram.ts
1032
+ const defaultStyleHandler = createStyleHandler({
1033
+ cssChildCombinatorReplaceValue: ["view", "text"],
1034
+ cssRemoveHoverPseudoClass: true,
1035
+ isMainChunk: true,
1036
+ majorVersion: 4
1037
+ });
1038
+ const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
1039
+ function normalizeTailwindV4GeneratedUrlValues(css) {
1040
+ return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
1041
+ try {
1042
+ return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
1043
+ } catch {
1044
+ return match;
1045
+ }
1046
+ });
1047
+ }
1048
+ async function transformTailwindV4CssToWeapp(css, options) {
1049
+ const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
1050
+ const result = await defaultStyleHandler(protectedCss.css, {
1051
+ cssChildCombinatorReplaceValue: ["view", "text"],
1052
+ cssRemoveHoverPseudoClass: true,
1053
+ isMainChunk: true,
1054
+ majorVersion: 4,
1055
+ ...options
1056
+ });
1057
+ const pruneOptions = {
1058
+ preservePreflight: true,
1059
+ preserveConditionalComments: hasCssMacroStyleOptions(options)
1060
+ };
1061
+ return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css), pruneOptions);
1062
+ }
1063
+ function transformTailwindV4WebRpxCss(css) {
1064
+ if (!css.includes("rpx")) return css;
1065
+ try {
1066
+ const root = postcss.parse(css);
1067
+ return normalizeTailwindcssWebRpxDeclarations(root, { majorVersion: 4 }) ? root.toString() : css;
1068
+ } catch {
1069
+ return css;
1070
+ }
1071
+ }
1072
+ function shouldTransformWebRpxCss(options) {
1073
+ return options?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
1074
+ }
1075
+ async function transformTailwindV4CssByTarget(css, target, options) {
1076
+ if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
1077
+ const resolvedWebCss = await (hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css);
1078
+ return shouldTransformWebRpxCss(options) ? transformTailwindV4WebRpxCss(resolvedWebCss) : resolvedWebCss;
1079
+ }
1080
+ //#endregion
1081
+ //#region src/tailwindcss/v4-engine/generator.ts
1082
+ const INCREMENTAL_GENERATE_CACHE_MAX = 8;
1083
+ const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
1084
+ const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 128;
1085
+ const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 256 * 1024;
1086
+ const incrementalGenerateCache = new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
1087
+ const incrementalGenerateTaskCache = new LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
1088
+ function collectCandidates(candidates) {
1089
+ return new Set(candidates ?? []);
1090
+ }
1091
+ function hasRemovedCandidates(previousCandidates, nextCandidates) {
1092
+ for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
1093
+ return false;
1094
+ }
1095
+ function createStableJson(value) {
1096
+ if (value === void 0) return "undefined";
1097
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
1098
+ if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
1099
+ return `{${Object.keys(value).sort().map((key) => {
1100
+ const record = value;
1101
+ return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
1102
+ }).join(",")}}`;
1103
+ }
1104
+ function createDependencyFingerprint(files) {
1105
+ return files.map((file) => {
1106
+ try {
1107
+ const stat = fs.statSync(file);
1108
+ return `${file}:${stat.size}:${stat.mtimeMs}`;
1109
+ } catch {
1110
+ return `${file}:missing`;
1111
+ }
1112
+ }).join("|");
1113
+ }
1114
+ function createIncrementalGenerateCacheKey(source, target, styleOptions) {
1115
+ return [
1116
+ source.projectRoot,
1117
+ source.base,
1118
+ createStableJson(source.baseFallbacks),
1119
+ source.css,
1120
+ createDependencyFingerprint(source.dependencies),
1121
+ target,
1122
+ createStableJson(styleOptions)
1123
+ ].join("\0");
1124
+ }
1125
+ function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
1126
+ return [
1127
+ cacheKey,
1128
+ scanSources === true ? "scan:1" : "scan:0",
1129
+ [...requestedCandidates].sort().join("\n")
1130
+ ].join("\0");
1131
+ }
1132
+ function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
1133
+ const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
1134
+ const cachedTask = incrementalGenerateTaskCache.get(taskKey);
1135
+ if (cachedTask) return cachedTask;
1136
+ const promise = task();
1137
+ incrementalGenerateTaskCache.set(taskKey, promise);
1138
+ promise.finally(() => {
1139
+ if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
1140
+ });
1141
+ return promise;
1142
+ }
1143
+ function createIncrementalDesignSystemPromise(source, cacheKey) {
1144
+ const promise = loadTailwindV4DesignSystem(source);
1145
+ promise.catch(() => {
1146
+ if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
1147
+ });
1148
+ return promise;
1149
+ }
1150
+ function resolveTargetCandidates(candidates, target) {
1151
+ const collected = collectCandidates(candidates);
1152
+ return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
1153
+ }
1154
+ function collectSeenCandidates(generated, requestedCandidates) {
1155
+ return new Set([
1156
+ ...requestedCandidates,
1157
+ ...generated.rawCandidates,
1158
+ ...generated.classSet
1159
+ ]);
1160
+ }
1161
+ function shouldDelegateWebSourceScanToTailwind(target, scanSources) {
1162
+ return target === "web" && scanSources !== false;
1163
+ }
1164
+ function createIncrementalStyleOptions(styleOptions) {
1165
+ return {
1166
+ ...styleOptions,
1167
+ isMainChunk: false
1168
+ };
1169
+ }
1170
+ function resolveStyleOptions(source, options) {
1171
+ return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
1172
+ }
1173
+ function collectCustomPropertyValues(css) {
1174
+ const values = /* @__PURE__ */ new Map();
1175
+ try {
1176
+ postcss.parse(css).walkDecls((decl) => {
1177
+ if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
1178
+ });
1179
+ } catch {}
1180
+ return values;
1181
+ }
1182
+ function mergeCustomPropertyValues(target, css) {
1183
+ for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
1184
+ }
1185
+ function createStableTextSignature(input) {
1186
+ let hash = 2166136261;
1187
+ for (let i = 0; i < input.length; i++) {
1188
+ hash ^= input.charCodeAt(i);
1189
+ hash = Math.imul(hash, 16777619);
1190
+ }
1191
+ return (hash >>> 0).toString(36);
1192
+ }
1193
+ function summarizeIncrementalCacheKey(key) {
1194
+ return {
1195
+ keyHash: createStableTextSignature(key),
1196
+ keyBytes: key.length
1197
+ };
1198
+ }
1199
+ function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
1200
+ return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX;
1201
+ }
1202
+ function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
1203
+ return requestedCandidates.size <= INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX && generated.css.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX && generated.rawCss.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX;
1204
+ }
1205
+ function seedIncrementalGenerateCache(options) {
1206
+ if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
1207
+ const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
1208
+ const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
1209
+ mergeCustomPropertyValues(customPropertyValues, options.generated.css);
1210
+ incrementalGenerateCache.set(cacheKey, {
1211
+ seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
1212
+ classSet: new Set(options.generated.classSet),
1213
+ css: options.generated.css,
1214
+ rawCss: options.generated.rawCss,
1215
+ customPropertyValues,
1216
+ designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
1217
+ dependencies: options.generated.dependencies,
1218
+ sources: options.generated.sources,
1219
+ root: options.generated.root,
1220
+ target: options.generated.target
1221
+ });
1222
+ return true;
1223
+ }
1224
+ function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
1225
+ if (target !== "web") return true;
1226
+ return styleOptions?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
1227
+ }
1228
+ function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
1229
+ return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? normalizeRpxLengthCandidates(candidates) : {
1230
+ candidates: new Set(candidates),
1231
+ restoreCandidates: /* @__PURE__ */ new Map()
1232
+ };
1233
+ }
1234
+ function createTailwindV4Engine$1(source) {
1235
+ async function generateOnce(generateSource, options = {}) {
1236
+ const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
1237
+ const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
1238
+ const engine = createTailwindV4Engine(createCompatibleSource(generateSource, target));
1239
+ const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1240
+ const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
1241
+ const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
1242
+ const normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target), target, resolvedStyleOptions);
1243
+ const result = await engine.generate(omitUndefined({
1244
+ scanSources: delegateSourceScan ? resolvedScanSources : false,
1245
+ ...patchOptions,
1246
+ candidates: normalizedCandidates.candidates
1247
+ }));
1248
+ const rawCss = restoreRpxLengthCssSelectors(result.css, normalizedCandidates.restoreCandidates);
1249
+ const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
1250
+ return {
1251
+ ...result,
1252
+ classSet: restoreRpxLengthCandidates(result.classSet, normalizedCandidates.restoreCandidates),
1253
+ rawCandidates: restoreRpxLengthCandidates(result.rawCandidates, normalizedCandidates.restoreCandidates),
1254
+ css,
1255
+ rawCss,
1256
+ target
1257
+ };
1258
+ }
1259
+ async function generateWithIncrementalCache(options = {}) {
1260
+ const target = options.target ?? "weapp";
1261
+ const compatibleSource = createCompatibleSource(source, target);
1262
+ const requestedCandidates = resolveTargetCandidates(options.candidates, target);
1263
+ const styleOptions = resolveStyleOptions(source, options.styleOptions);
1264
+ if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
1265
+ const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
1266
+ if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1267
+ const generated = await generateOnce(source, options);
1268
+ if (!seedIncrementalGenerateCache({
1269
+ compatibleSource,
1270
+ generated,
1271
+ requestedCandidates,
1272
+ styleOptions: options.styleOptions,
1273
+ target
1274
+ })) incrementalGenerateCache.delete(cacheKey);
1275
+ return generated;
1276
+ });
1277
+ const cached = incrementalGenerateCache.get(cacheKey);
1278
+ if (cached) {
1279
+ if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1280
+ const generated = await generateOnce(source, options);
1281
+ if (!seedIncrementalGenerateCache({
1282
+ compatibleSource,
1283
+ generated,
1284
+ requestedCandidates,
1285
+ styleOptions,
1286
+ target
1287
+ })) incrementalGenerateCache.delete(cacheKey);
1288
+ return generated;
1289
+ });
1290
+ const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
1291
+ if (missingCandidates.length === 0) return {
1292
+ css: cached.css,
1293
+ rawCss: cached.rawCss,
1294
+ incrementalCss: "",
1295
+ incrementalRawCss: "",
1296
+ classSet: new Set(cached.classSet),
1297
+ rawCandidates: new Set(cached.seenCandidates),
1298
+ dependencies: cached.dependencies,
1299
+ sources: cached.sources,
1300
+ root: cached.root,
1301
+ target: cached.target
1302
+ };
1303
+ if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1304
+ const generated = await generateOnce(source, options);
1305
+ if (!seedIncrementalGenerateCache({
1306
+ compatibleSource,
1307
+ generated,
1308
+ requestedCandidates,
1309
+ styleOptions,
1310
+ target
1311
+ })) incrementalGenerateCache.delete(cacheKey);
1312
+ return generated;
1313
+ });
1314
+ return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1315
+ const designSystem = await cached.designSystemPromise;
1316
+ const normalizedMissing = normalizeTargetRpxLengthCandidates(missingCandidates, target, styleOptions);
1317
+ const normalizedMissingCandidates = [...normalizedMissing.candidates];
1318
+ const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
1319
+ const rawCssParts = [];
1320
+ const classSet = /* @__PURE__ */ new Set();
1321
+ for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
1322
+ const candidate = normalizedMissingCandidates[index];
1323
+ const css = cssByCandidate[index];
1324
+ if (candidate && typeof css === "string" && css.trim().length > 0) {
1325
+ rawCssParts.push(restoreRpxLengthCssSelectors(css, normalizedMissing.restoreCandidates));
1326
+ classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
1327
+ }
1328
+ }
1329
+ const rawCss = rawCssParts.join("\n");
1330
+ const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
1331
+ ...createIncrementalStyleOptions(styleOptions),
1332
+ customPropertyValues: cached.customPropertyValues
1333
+ }) : "";
1334
+ for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
1335
+ for (const className of classSet) cached.classSet.add(className);
1336
+ cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
1337
+ cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
1338
+ mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
1339
+ return {
1340
+ css: cached.css,
1341
+ rawCss: cached.rawCss,
1342
+ incrementalCss,
1343
+ incrementalRawCss: rawCss,
1344
+ classSet: new Set(cached.classSet),
1345
+ rawCandidates: new Set(cached.seenCandidates),
1346
+ dependencies: cached.dependencies,
1347
+ sources: cached.sources,
1348
+ root: cached.root,
1349
+ target: cached.target
1350
+ };
1351
+ });
1352
+ }
1353
+ return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1354
+ const generated = await generateOnce(source, options);
1355
+ seedIncrementalGenerateCache({
1356
+ compatibleSource,
1357
+ generated,
1358
+ requestedCandidates,
1359
+ styleOptions,
1360
+ target
1361
+ });
1362
+ return generated;
1363
+ });
1364
+ }
1365
+ async function generate(options = {}) {
1366
+ return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
1367
+ }
1368
+ return {
1369
+ source,
1370
+ loadDesignSystem: createTailwindV4Engine(source).loadDesignSystem,
1371
+ validateCandidates: createTailwindV4Engine(source).validateCandidates,
1372
+ generate
1373
+ };
1374
+ }
1375
+ function getTailwindV4IncrementalGenerateCacheStats() {
1376
+ return {
1377
+ max: INCREMENTAL_GENERATE_CACHE_MAX,
1378
+ entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
1379
+ entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
1380
+ size: incrementalGenerateCache.size,
1381
+ taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
1382
+ taskSize: incrementalGenerateTaskCache.size,
1383
+ entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
1384
+ ...summarizeIncrementalCacheKey(key),
1385
+ candidates: entry.seenCandidates.size,
1386
+ classSet: entry.classSet.size,
1387
+ cssBytes: entry.css.length,
1388
+ rawCssBytes: entry.rawCss.length
1389
+ })),
1390
+ keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
1391
+ taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
1392
+ };
1393
+ }
1394
+ //#endregion
1395
+ //#region src/bundlers/shared/generator-css/config-directive.ts
1396
+ function quoteCssString(value) {
1397
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
1398
+ }
1399
+ function toCssPath(value) {
1400
+ return value.replaceAll("\\", "/");
1401
+ }
1402
+ function prependConfigDirective(css, config) {
1403
+ if (!config || /@config\s+/.test(css)) return css;
1404
+ return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
1405
+ }
1406
+ function normalizeConfigDirective(css, config) {
1407
+ if (!config || !/@config\s+/.test(css)) return css;
1408
+ return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
1409
+ }
1410
+ //#endregion
1411
+ //#region src/bundlers/shared/generator-css/markers.ts
1412
+ const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
1413
+ const TAILWIND_ESCAPED_UTILITY_MARKER_RE = /\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
1414
+ const TAILWIND_ROOT_THEME_MARKER_RE = /(?::host|page|\.tw-root|wx-root-portal-content)[^{]{0,256}\{[^}]{0,4096}--(?:color|spacing|text|font-weight|radius)-/;
1415
+ const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
1416
+ const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
1417
+ const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
1418
+ const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
1419
+ const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
1420
+ const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
1421
+ function createCssAppend(base, extra) {
1422
+ if (!base) return extra;
1423
+ if (!extra) return base;
1424
+ return `${base}\n${extra}`;
1425
+ }
1426
+ function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
1427
+ const trimmedRaw = rawSource.trim();
1428
+ const trimmedTailwind = rawTailwindCss.trim();
1429
+ if (trimmedRaw === trimmedTailwind) return {
1430
+ before: "",
1431
+ after: ""
1432
+ };
1433
+ if (trimmedTailwind.startsWith(trimmedRaw)) return {
1434
+ before: "",
1435
+ after: ""
1436
+ };
1437
+ const start = rawSource.indexOf(rawTailwindCss);
1438
+ if (start === -1) return;
1439
+ return {
1440
+ before: rawSource.slice(0, start),
1441
+ after: rawSource.slice(start + rawTailwindCss.length)
1442
+ };
1443
+ }
1444
+ function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
1445
+ const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
1446
+ if (!match || match.index === void 0) return;
1447
+ let afterStart = match.index + match[0].length;
1448
+ while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
1449
+ if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
1450
+ afterStart += rawTailwindCss.length;
1451
+ while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
1452
+ }
1453
+ return {
1454
+ before: rawSource.slice(0, match.index),
1455
+ after: rawSource.slice(afterStart)
1456
+ };
1457
+ }
1458
+ function splitTailwindGeneratedCssByBanner(rawSource, start) {
1459
+ const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
1460
+ if (!match || match.index === void 0) return;
1461
+ return {
1462
+ before: rawSource.slice(0, match.index),
1463
+ after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
1464
+ };
1465
+ }
1466
+ function stripTailwindBanner(css) {
1467
+ return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
1468
+ }
1469
+ function stripTailwindBanners(css) {
1470
+ return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
1471
+ }
1472
+ function stripGeneratorPlaceholderMarkers(css) {
1473
+ return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
1474
+ }
1475
+ function hasTailwindGeneratedCss(rawSource) {
1476
+ return TAILWIND_V4_BANNER_RE.test(rawSource);
1477
+ }
1478
+ function hasTailwindGeneratedCssMarkers(rawSource) {
1479
+ if (rawSource.includes("--tw-") || rawSource.includes("tailwindcss v") || rawSource.includes(":not(#\\#)") || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1480
+ if (!rawSource.includes("\\:") && !rawSource.includes("\\[") && !rawSource.includes("\\#") && !rawSource.includes("--color-") && !rawSource.includes("--spacing-") && !rawSource.includes("--text-") && !rawSource.includes("--font-weight-") && !rawSource.includes("--radius-")) return false;
1481
+ return TAILWIND_ESCAPED_UTILITY_MARKER_RE.test(rawSource) || TAILWIND_ROOT_THEME_MARKER_RE.test(rawSource);
1482
+ }
1483
+ //#endregion
1484
+ //#region src/bundlers/shared/generator-css/directives/fallback.ts
1485
+ const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
1486
+ const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
1487
+ const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
1488
+ function parseImportRequest$1(params) {
1489
+ return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
1490
+ }
1491
+ function parseConfigRequest$1(params) {
1492
+ return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
1493
+ }
1494
+ function isPackageJsonImportRequest$1(request) {
1495
+ return typeof request === "string" && request.startsWith("#");
1496
+ }
1497
+ function isWeappTailwindcssImportRequest$1(request) {
1498
+ return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
1499
+ }
1500
+ function isTailwindImportRequest$1(request) {
1501
+ return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
1502
+ }
1503
+ function normalizeTailwindImportRequest$1(request, options = {}) {
1504
+ if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
1505
+ return request;
1506
+ }
1507
+ function replaceImportRequest$1(params, request, replacement) {
1508
+ const index = params.indexOf(request);
1509
+ if (index === -1) return params;
1510
+ return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
1511
+ }
1512
+ function normalizeTailwindDirectiveLine(line, options = {}) {
1513
+ const trimmed = line.trimStart();
1514
+ if (/^@(?:use|forward)\b/.test(trimmed)) {
1515
+ const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
1516
+ if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
1517
+ const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
1518
+ return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
1519
+ }
1520
+ return line;
1521
+ }
1522
+ if (!options.importFallback || !trimmed.startsWith("@import")) return line;
1523
+ const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
1524
+ if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
1525
+ return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
1526
+ }
1527
+ function extractTailwindDirectiveLines(rawSource, options = {}) {
1528
+ const directives = [];
1529
+ const seenImports = /* @__PURE__ */ new Set();
1530
+ for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
1531
+ const trimmed = line.trim();
1532
+ if (!trimmed || trimmed.startsWith("//")) continue;
1533
+ const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
1534
+ if (!directive) continue;
1535
+ if (TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(directive)) continue;
1536
+ const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
1537
+ const normalizedTrimmed = normalized.trim();
1538
+ if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
1539
+ const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
1540
+ if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
1541
+ if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
1542
+ if (request && isTailwindImportRequest$1(request)) {
1543
+ const key = normalizedTrimmed;
1544
+ if (seenImports.has(key)) continue;
1545
+ seenImports.add(key);
1546
+ }
1547
+ directives.push(normalized);
1548
+ }
1549
+ return directives;
1550
+ }
1551
+ function stripPreprocessorLineComment(line) {
1552
+ let quote;
1553
+ let escaped = false;
1554
+ for (let index = 0; index < line.length; index++) {
1555
+ const char = line[index];
1556
+ if (escaped) {
1557
+ escaped = false;
1558
+ continue;
1559
+ }
1560
+ if (char === "\\") {
1561
+ escaped = true;
1562
+ continue;
1563
+ }
1564
+ if (quote) {
1565
+ if (char === quote) quote = void 0;
1566
+ continue;
1567
+ }
1568
+ if (char === "\"" || char === "'") {
1569
+ quote = char;
1570
+ continue;
1571
+ }
1572
+ if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
1573
+ }
1574
+ return line;
1575
+ }
1576
+ function countBlockBraceDelta(line) {
1577
+ let quote;
1578
+ let escaped = false;
1579
+ let delta = 0;
1580
+ for (let index = 0; index < line.length; index++) {
1581
+ const char = line[index];
1582
+ if (escaped) {
1583
+ escaped = false;
1584
+ continue;
1585
+ }
1586
+ if (char === "\\") {
1587
+ escaped = true;
1588
+ continue;
1589
+ }
1590
+ if (quote) {
1591
+ if (char === quote) quote = void 0;
1592
+ continue;
1593
+ }
1594
+ if (char === "\"" || char === "'") {
1595
+ quote = char;
1596
+ continue;
1597
+ }
1598
+ if (char === "{") delta++;
1599
+ else if (char === "}") delta--;
1600
+ }
1601
+ return delta;
1602
+ }
1603
+ function extractTailwindFallbackBlocks(rawSource) {
1604
+ const blocks = [];
1605
+ let current;
1606
+ let depth = 0;
1607
+ for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
1608
+ const line = stripPreprocessorLineComment(rawLine);
1609
+ if (!line.trim()) continue;
1610
+ if (!current) {
1611
+ if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
1612
+ current = [line];
1613
+ depth = countBlockBraceDelta(line);
1614
+ if (depth <= 0) {
1615
+ blocks.push(current.join("\n"));
1616
+ current = void 0;
1617
+ depth = 0;
1618
+ }
1619
+ continue;
1620
+ }
1621
+ current.push(line);
1622
+ depth += countBlockBraceDelta(line);
1623
+ if (depth <= 0) {
1624
+ blocks.push(current.join("\n"));
1625
+ current = void 0;
1626
+ depth = 0;
1627
+ }
1628
+ }
1629
+ return blocks;
1630
+ }
1631
+ function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
1632
+ const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
1633
+ return directives.length > 0 ? directives.join("\n") : void 0;
1634
+ }
1635
+ function extractConfigRequestFromSource(rawSource) {
1636
+ for (const line of rawSource.split(/\r?\n/)) {
1637
+ const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
1638
+ const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
1639
+ if (request) return request;
1640
+ }
1641
+ }
1642
+ //#endregion
1643
+ //#region src/bundlers/shared/generator-css/directives.ts
1644
+ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
1645
+ "config",
1646
+ "custom-variant",
1647
+ "layer",
1648
+ "plugin",
1649
+ "reference",
1650
+ "source",
1651
+ "tailwind",
1652
+ "theme",
1653
+ "utility",
1654
+ "variant"
1655
+ ]);
1656
+ const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
1657
+ "config",
1658
+ "custom-variant",
1659
+ "plugin",
1660
+ "source",
1661
+ "tailwind",
1662
+ "theme",
1663
+ "utility",
1664
+ "variant"
1665
+ ]);
1666
+ const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
1667
+ function parseImportRequest(params) {
1668
+ return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
1669
+ }
1670
+ function hasLocalCssImport(rawSource) {
1671
+ let found = false;
1672
+ try {
1673
+ postcss.parse(rawSource).walkAtRules("import", (rule) => {
1674
+ const request = parseImportRequest(rule.params);
1675
+ if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
1676
+ found = true;
1677
+ return false;
1678
+ }
1679
+ });
1680
+ } catch {}
1681
+ return found;
1682
+ }
1683
+ function parseConfigRequest(params) {
1684
+ return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
1685
+ }
1686
+ function isPackageJsonImportRequest(request) {
1687
+ return typeof request === "string" && request.startsWith("#");
1688
+ }
1689
+ function isWeappTailwindcssImportRequest(request) {
1690
+ return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
1691
+ }
1692
+ function normalizeTailwindImportRequest(request, options = {}) {
1693
+ if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
1694
+ return request;
1695
+ }
1696
+ function replaceImportRequest(params, request, replacement) {
1697
+ const index = params.indexOf(request);
1698
+ if (index === -1) return params;
1699
+ return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
1700
+ }
1701
+ function normalizeTailwindImportAtRules(root, options = {}) {
1702
+ if (!options.importFallback) return false;
1703
+ let changed = false;
1704
+ const seenCanonicalImports = /* @__PURE__ */ new Set();
1705
+ root.walkAtRules("import", (node) => {
1706
+ const request = parseImportRequest(node.params);
1707
+ const normalizedRequest = normalizeTailwindImportRequest(request, options);
1708
+ if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
1709
+ const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
1710
+ const normalizedKey = normalizedParams.trim();
1711
+ if (seenCanonicalImports.has(normalizedKey)) {
1712
+ node.remove();
1713
+ changed = true;
1714
+ return;
1715
+ }
1716
+ seenCanonicalImports.add(normalizedKey);
1717
+ if (normalizedParams !== node.params) {
1718
+ node.params = normalizedParams;
1719
+ changed = true;
1720
+ }
1721
+ });
1722
+ return changed;
1723
+ }
1724
+ function resolveConfigPath(base, configPath) {
1725
+ if (path.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return path.isAbsolute(configPath) ? configPath : void 0;
1726
+ return path.resolve(base, configPath);
1727
+ }
1728
+ function normalizeTailwindConfigDirectives(rawSource, base) {
1729
+ return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
1730
+ if (path.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
1731
+ return `@config ${quote}${path.resolve(base, request).replace(/\\/g, "/")}${quote};`;
1732
+ });
1733
+ }
1734
+ function hasPreprocessorOnlySyntax(rawSource) {
1735
+ return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
1736
+ }
1737
+ function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
1738
+ return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
1739
+ }
1740
+ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
1741
+ if (!options.importFallback) return rawSource;
1742
+ try {
1743
+ const root = postcss.parse(rawSource);
1744
+ return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
1745
+ } catch {
1746
+ return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
1747
+ }
1748
+ }
1749
+ function isTailwindImportRequest(request) {
1750
+ return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
1751
+ }
1752
+ function isTailwindImportAtRule(node, options = {}) {
1753
+ if (node.name === "tailwind") return true;
1754
+ if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
1755
+ return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
1756
+ }
1757
+ function isTailwindSourceDirective(node, options = {}) {
1758
+ if (node.type !== "atrule") return false;
1759
+ const atRule = node;
1760
+ if (isTailwindImportAtRule(atRule, options)) return true;
1761
+ if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
1762
+ if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
1763
+ return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
1764
+ }
1765
+ function hasGeneratedCssArtifacts(rawSource) {
1766
+ return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
1767
+ }
1768
+ function isTailwindGenerationDirective(node, options = {}) {
1769
+ if (node.type !== "atrule") return false;
1770
+ const atRule = node;
1771
+ const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
1772
+ return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
1773
+ }
1774
+ function removeTailwindSourceDirectives(rawSource, options = {}) {
1775
+ try {
1776
+ const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
1777
+ if (!source) return "";
1778
+ const root = postcss.parse(source);
1779
+ let removed = false;
1780
+ root.walk((node) => {
1781
+ if (isTailwindSourceDirective(node, options)) {
1782
+ node.remove();
1783
+ removed = true;
1784
+ }
1785
+ });
1786
+ return removed ? root.toString() : source;
1787
+ } catch {
1788
+ return stripGeneratorPlaceholderMarkers(rawSource);
1789
+ }
1790
+ }
1791
+ function hasTailwindSourceDirectives(rawSource, options = {}) {
1792
+ try {
1793
+ if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1794
+ const root = postcss.parse(rawSource);
1795
+ let found = false;
1796
+ const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
1797
+ root.walk((node) => {
1798
+ if (isTailwindGenerationDirective(node, {
1799
+ ...options,
1800
+ ignoreLayer
1801
+ })) {
1802
+ found = true;
1803
+ return false;
1804
+ }
1805
+ });
1806
+ return found;
1807
+ } catch {
1808
+ return extractTailwindDirectiveLines(rawSource, options).length > 0;
1809
+ }
1810
+ }
1811
+ function hasTailwindNonRootGenerationDirectives(rawSource, options = {}) {
1812
+ try {
1813
+ if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
1814
+ const root = postcss.parse(rawSource);
1815
+ let found = false;
1816
+ const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
1817
+ root.walk((node) => {
1818
+ if (isTailwindGenerationDirective(node, {
1819
+ ...options,
1820
+ ignoreLayer
1821
+ }) && !(node.type === "atrule" && isTailwindImportAtRule(node, options))) {
1822
+ found = true;
1823
+ return false;
1824
+ }
1825
+ });
1826
+ return found;
1827
+ } catch {
1828
+ return GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource) || /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
1829
+ }
1830
+ }
1831
+ function hasTailwindRootImportDirectives(rawSource, options = {}) {
1832
+ if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
1833
+ try {
1834
+ const root = postcss.parse(rawSource);
1835
+ let found = false;
1836
+ root.walkAtRules((node) => {
1837
+ if (isTailwindImportAtRule(node, options)) {
1838
+ found = true;
1839
+ return false;
1840
+ }
1841
+ });
1842
+ return found;
1843
+ } catch {
1844
+ return extractTailwindDirectiveLines(rawSource, options).some((line) => /@(?:import|use|forward)\b/.test(line));
1845
+ }
1846
+ }
1847
+ function hasTailwindRootDirectives(rawSource, options = {}) {
1848
+ if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
1849
+ try {
1850
+ const root = postcss.parse(rawSource);
1851
+ let found = false;
1852
+ root.walkAtRules((node) => {
1853
+ const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
1854
+ if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
1855
+ found = true;
1856
+ return false;
1857
+ }
1858
+ });
1859
+ return found;
1860
+ } catch {
1861
+ return extractTailwindDirectiveLines(rawSource, options).length > 0;
1862
+ }
1863
+ }
1864
+ function hasTailwindApplyDirective(rawSource) {
1865
+ if (!rawSource.includes("@apply")) return false;
1866
+ try {
1867
+ const root = postcss.parse(rawSource);
1868
+ let found = false;
1869
+ root.walkAtRules("apply", () => {
1870
+ found = true;
1871
+ return false;
1872
+ });
1873
+ return found;
1874
+ } catch {
1875
+ const fallback = extractTailwindSourceForPostcssFallback(rawSource);
1876
+ return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
1877
+ }
1878
+ }
1879
+ function resolveCssEntrySource(rawSource, base, options = {}) {
1880
+ try {
1881
+ const root = postcss.parse(rawSource);
1882
+ const normalizedImports = normalizeTailwindImportAtRules(root, options);
1883
+ let found = false;
1884
+ let config;
1885
+ let configRequest;
1886
+ let removedConfig = false;
1887
+ const removeConfig = options.removeConfig ?? true;
1888
+ const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
1889
+ root.walk((node) => {
1890
+ if (isTailwindGenerationDirective(node, {
1891
+ ...options,
1892
+ ignoreLayer
1893
+ })) found = true;
1894
+ if (node.type === "atrule" && node.name === "config") {
1895
+ const configPath = parseConfigRequest(node.params);
1896
+ if (configPath && !config) {
1897
+ configRequest = configPath;
1898
+ config = resolveConfigPath(base, configPath);
1899
+ }
1900
+ if (removeConfig) {
1901
+ node.remove();
1902
+ removedConfig = true;
1903
+ }
1904
+ }
1905
+ });
1906
+ if (!found) return;
1907
+ if (hasPreprocessorOnlySyntax(rawSource)) {
1908
+ const css = extractTailwindSourceForPostcssFallback(rawSource, {
1909
+ ...options,
1910
+ removeConfig
1911
+ });
1912
+ if (css) return {
1913
+ css,
1914
+ config,
1915
+ configRequest,
1916
+ base
1917
+ };
1918
+ }
1919
+ return {
1920
+ css: removedConfig || normalizedImports ? root.toString() : rawSource,
1921
+ config,
1922
+ configRequest,
1923
+ base
1924
+ };
1925
+ } catch {
1926
+ const css = extractTailwindSourceForPostcssFallback(rawSource, options);
1927
+ const configRequest = extractConfigRequestFromSource(rawSource);
1928
+ const config = configRequest ? resolveConfigPath(base, configRequest) : void 0;
1929
+ return css ? {
1930
+ css,
1931
+ config,
1932
+ configRequest,
1933
+ base
1934
+ } : void 0;
1935
+ }
1936
+ }
1937
+ //#endregion
1938
+ //#region src/utils/options.ts
1939
+ function resolveBooleanObjectOption(value, enabledValue) {
1940
+ if (!value) return false;
1941
+ if (value === true) return enabledValue;
1942
+ return value;
1943
+ }
1944
+ function normalizeStringListOption(value) {
1945
+ if (!value) return;
1946
+ const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
1947
+ if (!values) return;
1948
+ const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
1949
+ return normalized.length > 0 ? normalized : void 0;
1950
+ }
1951
+ //#endregion
1952
+ //#region src/tailwindcss/runtime-options.ts
1953
+ function resolveTailwindcssOptions(options) {
1954
+ return options?.tailwindcss ?? options?.tailwind;
1955
+ }
1956
+ function normalizeExtendLengthUnits(value) {
1957
+ if (value === void 0) return;
1958
+ const resolved = resolveBooleanObjectOption(value, { enabled: true });
1959
+ return resolved && typeof resolved === "object" ? {
1960
+ enabled: true,
1961
+ ...resolved
1962
+ } : resolved;
1963
+ }
1964
+ function normalizeTailwindcssRuntimeOptions(options) {
1965
+ return options;
1966
+ }
1967
+ //#endregion
1968
+ //#region src/context/workspace.ts
1969
+ const IGNORED_WORKSPACE_DIRS = new Set([
1970
+ "node_modules",
1971
+ ".git",
1972
+ ".hg",
1973
+ ".svn",
1974
+ ".turbo",
1975
+ ".output",
1976
+ ".next",
1977
+ "dist",
1978
+ "build"
1979
+ ]);
1980
+ function findWorkspaceRoot(startDir) {
1981
+ if (!startDir) return;
1982
+ let current = path.resolve(startDir);
1983
+ while (true) {
1984
+ if (existsSync(path.join(current, "pnpm-workspace.yaml"))) return current;
1985
+ const parent = path.dirname(current);
1986
+ if (parent === current) return;
1987
+ current = parent;
1988
+ }
1989
+ }
1990
+ function findNearestPackageRoot(startDir) {
1991
+ if (!startDir) return;
1992
+ let current = path.resolve(startDir);
1993
+ while (true) {
1994
+ if (existsSync(path.join(current, "package.json"))) return current;
1995
+ const parent = path.dirname(current);
1996
+ if (parent === current) return;
1997
+ current = parent;
1998
+ }
1999
+ }
2000
+ function findWorkspacePackageDir(rootDir, packageName) {
2001
+ const visited = /* @__PURE__ */ new Set();
2002
+ const queue = [path.resolve(rootDir)];
2003
+ while (queue.length > 0) {
2004
+ const current = queue.shift();
2005
+ const normalized = path.normalize(current);
2006
+ if (visited.has(normalized)) continue;
2007
+ visited.add(normalized);
2008
+ try {
2009
+ const pkgPath = path.join(normalized, "package.json");
2010
+ if (existsSync(pkgPath)) {
2011
+ if (JSON.parse(readFileSync(pkgPath, "utf8"))?.name === packageName) return normalized;
2012
+ }
2013
+ } catch {}
2014
+ let entries;
2015
+ try {
2016
+ entries = readdirSync(normalized, { withFileTypes: true });
2017
+ } catch {
2018
+ continue;
2019
+ }
2020
+ for (const entry of entries) {
2021
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
2022
+ queue.push(path.join(normalized, entry.name));
2023
+ }
2024
+ }
2025
+ }
2026
+ //#endregion
2027
+ //#region src/tailwindcss/v4/css-entries.ts
2028
+ const TAILWIND_V4_CSS_ENTRY_RE = /\.css(?:[?#].*)?$/i;
2029
+ function isTailwindV4CssEntry(entry) {
2030
+ return typeof entry === "string" && TAILWIND_V4_CSS_ENTRY_RE.test(entry.trim());
2031
+ }
2032
+ function guessBasedirFromEntries(entries) {
2033
+ if (!entries) return;
2034
+ for (const entry of entries) {
2035
+ if (typeof entry !== "string") continue;
2036
+ const trimmed = entry.trim();
2037
+ if (!trimmed || !path.isAbsolute(trimmed)) continue;
2038
+ if (!isTailwindV4CssEntry(trimmed)) continue;
2039
+ const entryDir = path.dirname(trimmed);
2040
+ const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
2041
+ if (resolved) return resolved;
2042
+ }
2043
+ }
2044
+ function normalizeCssEntries(entries, anchor) {
2045
+ if (!entries || entries.length === 0) return;
2046
+ const normalized = /* @__PURE__ */ new Set();
2047
+ for (const entry of entries) {
2048
+ if (typeof entry !== "string") continue;
2049
+ const trimmed = entry.trim();
2050
+ if (trimmed.length === 0) continue;
2051
+ if (!isTailwindV4CssEntry(trimmed)) continue;
2052
+ const resolved = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.normalize(path.resolve(anchor, trimmed));
2053
+ normalized.add(resolved);
2054
+ }
2055
+ return normalized.size > 0 ? [...normalized] : void 0;
2056
+ }
2057
+ function isSubPath(parent, child) {
2058
+ if (!parent || !child) return false;
2059
+ const relative = path.relative(parent, child);
2060
+ return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
2061
+ }
2062
+ function resolveCssEntryBase(entryDir, options) {
2063
+ const normalizedDir = path.normalize(entryDir);
2064
+ const { preferredBaseDir, workspaceRoot } = options;
2065
+ if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
2066
+ if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
2067
+ const packageRoot = findNearestPackageRoot(normalizedDir);
2068
+ if (packageRoot) return path.normalize(packageRoot);
2069
+ return normalizedDir;
2070
+ }
2071
+ function groupCssEntriesByBase(entries, options = {}) {
2072
+ const normalizedOptions = {
2073
+ preferredBaseDir: options.preferredBaseDir ? path.normalize(options.preferredBaseDir) : void 0,
2074
+ workspaceRoot: options.workspaceRoot ? path.normalize(options.workspaceRoot) : void 0
2075
+ };
2076
+ const groups = /* @__PURE__ */ new Map();
2077
+ for (const entry of entries) {
2078
+ const baseDir = resolveCssEntryBase(path.dirname(entry), normalizedOptions);
2079
+ const bucket = groups.get(baseDir);
2080
+ if (bucket) bucket.push(entry);
2081
+ else groups.set(baseDir, [entry]);
2082
+ }
2083
+ return groups;
2084
+ }
2085
+ //#endregion
2086
+ //#region src/tailwindcss/v4/css-sources.ts
2087
+ function hasCssEntriesValue(value) {
2088
+ if (typeof value === "string") return isTailwindV4CssEntry(value);
2089
+ return Array.isArray(value) && value.some(isTailwindV4CssEntry);
2090
+ }
2091
+ function hasCssSourcesValue(value) {
2092
+ return Array.isArray(value) && value.some((source) => {
2093
+ const file = source?.file;
2094
+ return typeof source === "object" && source !== null && typeof file === "string" && isTailwindV4CssEntry(file) && typeof source.css === "string" && source.css.trim().length > 0;
2095
+ });
2096
+ }
2097
+ function isTailwindV4CssSourceRoot(source) {
2098
+ return typeof source === "object" && source !== null && typeof source.file === "string" && isTailwindV4CssEntry(source.file);
2099
+ }
2100
+ function filterTailwindV4CssSourceRoots(sources) {
2101
+ const filtered = sources?.filter(isTailwindV4CssSourceRoot);
2102
+ return filtered && filtered.length > 0 ? filtered : void 0;
2103
+ }
2104
+ function hasConfiguredTailwindV4CssRoots(options) {
2105
+ return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources);
2106
+ }
2107
+ function normalizeCssSourceFile(file) {
2108
+ if (!file) return;
2109
+ return path.isAbsolute(file) ? path.normalize(file) : file;
2110
+ }
2111
+ function normalizeCssSourceBase(base) {
2112
+ if (!base) return;
2113
+ return path.resolve(base);
2114
+ }
2115
+ function normalizeDependencies(dependencies) {
2116
+ return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
2117
+ }
2118
+ function isSameCssSource(a, b) {
2119
+ return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
2120
+ }
2121
+ function upsertTailwindV4CssSource(opts, source) {
2122
+ if (!isTailwindV4CssEntry(source.file)) return false;
2123
+ const normalizedSource = omitUndefined({
2124
+ ...source,
2125
+ ...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
2126
+ ...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
2127
+ ...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
2128
+ });
2129
+ const tailwindcss = opts.tailwindcss ?? {};
2130
+ const v4 = tailwindcss.v4 ?? {};
2131
+ const cssSources = [...v4.cssSources ?? []];
2132
+ const sourceFile = normalizeCssSourceFile(normalizedSource.file);
2133
+ const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
2134
+ if (existingIndex >= 0) {
2135
+ const existing = cssSources[existingIndex];
2136
+ if (!existing) {
2137
+ cssSources[existingIndex] = normalizedSource;
2138
+ return true;
2139
+ }
2140
+ const nextSource = {
2141
+ ...existing,
2142
+ ...normalizedSource
2143
+ };
2144
+ if (isSameCssSource(existing, nextSource)) return false;
2145
+ cssSources[existingIndex] = nextSource;
2146
+ } else cssSources.push(normalizedSource);
2147
+ opts.tailwindcss = {
2148
+ ...tailwindcss,
2149
+ v4: {
2150
+ ...v4,
2151
+ cssSources
2152
+ }
2153
+ };
2154
+ return true;
2155
+ }
2156
+ //#endregion
2157
+ //#region src/tailwindcss/v4-engine/source.ts
2158
+ const require = createRequire(import.meta.url);
2159
+ function isCssEntryPoint(file) {
2160
+ return typeof file === "string" && path.basename(file) === "index.css" && existsSync(file);
2161
+ }
2162
+ function resolvePackageCssEntryPoint(specifier) {
2163
+ try {
2164
+ const resolved = require.resolve(specifier);
2165
+ if (isCssEntryPoint(resolved)) return resolved;
2166
+ } catch {}
2167
+ const packageName = specifier.replace(/\/index\.css$/, "");
2168
+ if (packageName !== "tailwindcss") return;
2169
+ try {
2170
+ const packageJson = require.resolve(`${packageName}/package.json`);
2171
+ const cssEntry = path.resolve(path.dirname(packageJson), "index.css");
2172
+ if (isCssEntryPoint(cssEntry)) return cssEntry;
2173
+ } catch {}
2174
+ try {
2175
+ let current = path.dirname(require.resolve("@tailwindcss-mangle/engine"));
2176
+ while (true) {
2177
+ const cssEntry = path.resolve(current, "..", "tailwindcss", "index.css");
2178
+ if (isCssEntryPoint(cssEntry)) return cssEntry;
2179
+ const parent = path.dirname(current);
2180
+ if (parent === current) break;
2181
+ current = parent;
2182
+ }
2183
+ } catch {}
2184
+ }
2185
+ function isPostcssPluginImportTarget(value) {
2186
+ if (!value) return false;
2187
+ return value === "@tailwindcss/postcss" || value.includes("/postcss");
2188
+ }
2189
+ function uniqueDefined(values) {
2190
+ return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
2191
+ }
2192
+ function getProjectRoot(runtime) {
2193
+ return runtime.options?.projectRoot ?? process.cwd();
2194
+ }
2195
+ function resolveBase(value, fallback) {
2196
+ return value === void 0 ? fallback : path.isAbsolute(value) ? path.resolve(value) : path.resolve(fallback, value);
2197
+ }
2198
+ function resolveConfigDir(config, projectRoot) {
2199
+ if (!config) return;
2200
+ const configPath = path.isAbsolute(config) ? config : path.resolve(projectRoot, config);
2201
+ return path.dirname(configPath);
2202
+ }
2203
+ function isBarePackageSpecifier(specifier) {
2204
+ return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
2205
+ }
2206
+ function isPackageJsonImportSpecifier(specifier) {
2207
+ return typeof specifier === "string" && specifier.startsWith("#");
2208
+ }
2209
+ function parseCssImportSpecifier(params) {
2210
+ const value = params.trim();
2211
+ const quoted = /^(['"])(.*?)\1/.exec(value);
2212
+ if (quoted) {
2213
+ const specifier = quoted[2];
2214
+ if (specifier === void 0) return;
2215
+ return {
2216
+ quote: quoted[1],
2217
+ raw: quoted[0],
2218
+ specifier
2219
+ };
2220
+ }
2221
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
2222
+ if (!url) return;
2223
+ const specifier = url[2] ?? url[3];
2224
+ if (specifier === void 0) return;
2225
+ return {
2226
+ quote: url[1],
2227
+ raw: url[0],
2228
+ specifier
2229
+ };
2230
+ }
2231
+ function quoteCssImportSpecifier(specifier, quote = "\"") {
2232
+ return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
2233
+ }
2234
+ function createTailwindV4CssImportSpecifierSet(packageName) {
2235
+ const specifiers = new Set(["tailwindcss"]);
2236
+ if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
2237
+ return specifiers;
2238
+ }
2239
+ function normalizeTailwindV4CssPackageImports(css, packageName) {
2240
+ if (!css.includes("tailwindcss")) return css;
2241
+ let root;
2242
+ try {
2243
+ root = postcss.parse(css);
2244
+ } catch {
2245
+ return css;
2246
+ }
2247
+ const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
2248
+ let changed = false;
2249
+ root.walkAtRules((rule) => {
2250
+ if (rule.name !== "import" && rule.name !== "reference") return;
2251
+ const parsed = parseCssImportSpecifier(rule.params);
2252
+ if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
2253
+ const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
2254
+ if (!cssEntryPoint) return;
2255
+ rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
2256
+ changed = true;
2257
+ });
2258
+ return changed ? root.toString() : css;
2259
+ }
2260
+ function normalizeTailwindV4CssSources(cssSources, packageName, projectRoot) {
2261
+ if (!cssSources?.length) return cssSources;
2262
+ let changed = false;
2263
+ const normalizedCssSources = cssSources.map((cssSource) => {
2264
+ const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.isAbsolute(cssSource.file) ? path.resolve(cssSource.file) : path.resolve(projectRoot ?? process.cwd(), cssSource.file) : void 0;
2265
+ const base = typeof cssSource.base === "string" && cssSource.base.length > 0 ? path.isAbsolute(cssSource.base) ? path.resolve(cssSource.base) : path.resolve(projectRoot ?? process.cwd(), cssSource.base) : file ? path.dirname(file) : void 0;
2266
+ if (typeof cssSource.css !== "string") {
2267
+ if (file === cssSource.file && base === cssSource.base) return cssSource;
2268
+ changed = true;
2269
+ return {
2270
+ ...cssSource,
2271
+ ...base === void 0 ? {} : { base },
2272
+ ...file === void 0 ? {} : { file }
2273
+ };
2274
+ }
2275
+ const configBase = base ?? projectRoot ?? process.cwd();
2276
+ const css = normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(cssSource.css, configBase), packageName);
2277
+ if (css === cssSource.css && file === cssSource.file && base === cssSource.base) return cssSource;
2278
+ changed = true;
2279
+ return {
2280
+ ...cssSource,
2281
+ css,
2282
+ ...base === void 0 ? {} : { base },
2283
+ ...file === void 0 ? {} : { file }
2284
+ };
2285
+ });
2286
+ return changed ? normalizedCssSources : cssSources;
2287
+ }
2288
+ function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
2289
+ if (!cssEntries?.length) return;
2290
+ const remainingCssEntries = [];
2291
+ const cssSources = [];
2292
+ for (const cssEntry of cssEntries) {
2293
+ const file = path.resolve(cssEntry);
2294
+ if (!existsSync(file)) {
2295
+ remainingCssEntries.push(cssEntry);
2296
+ continue;
2297
+ }
2298
+ const base = path.dirname(file);
2299
+ const rawCss = readFileSync(file, "utf8");
2300
+ const entrySource = resolveCssEntrySource(rawCss, base, { removeConfig: false });
2301
+ const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, entrySource?.config && existsSync(entrySource.config) ? entrySource.config : entrySource?.configRequest && !path.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? path.resolve(base, entrySource.configRequest) : entrySource?.config), packageName);
2302
+ cssSources.push({
2303
+ file,
2304
+ base,
2305
+ css,
2306
+ dependencies: [file]
2307
+ });
2308
+ }
2309
+ return {
2310
+ cssEntries: remainingCssEntries,
2311
+ cssSources
2312
+ };
2313
+ }
2314
+ function normalizeTailwindV4SourceOptions(options) {
2315
+ if (!options) return options;
2316
+ const cssBase = resolveBase(options.base, options.projectRoot ?? options.cwd ?? process.cwd());
2317
+ const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(normalizeTailwindConfigDirectives(options.css, cssBase), options.packageName);
2318
+ const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
2319
+ const configuredCssSources = filterTailwindV4CssSourceRoots(options.cssSources);
2320
+ const cssSources = normalizeTailwindV4CssSources(configuredCssSources || entrySources?.cssSources ? [...configuredCssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName, options.projectRoot);
2321
+ const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
2322
+ if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
2323
+ return {
2324
+ ...options,
2325
+ css,
2326
+ ...cssEntries === void 0 ? {} : { cssEntries },
2327
+ cssSources
2328
+ };
2329
+ }
2330
+ function resolveTailwindCssImportTarget(runtime) {
2331
+ const configuredPackageName = resolveTailwindcssOptions(runtime.options)?.packageName;
2332
+ if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
2333
+ const packageName = runtime.packageInfo?.name;
2334
+ if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
2335
+ return "tailwindcss";
2336
+ }
2337
+ function readTailwindV4Options(runtime) {
2338
+ return resolveTailwindcssOptions(runtime.options)?.v4 ?? runtime.options?.tailwind?.v4;
2339
+ }
2340
+ function isRawTailwindcssPatchOptions(options) {
2341
+ return Boolean(options && "tailwindcss" in options);
2342
+ }
2343
+ function resolveEngineTailwindV4SourceOptions(runtime) {
2344
+ if (runtime.options) {
2345
+ const projectRoot = getProjectRoot(runtime);
2346
+ const tailwindOptions = resolveTailwindcssOptions(runtime.options);
2347
+ const tailwindV4Options = readTailwindV4Options(runtime);
2348
+ const cwd = resolveBase(tailwindOptions?.cwd, projectRoot);
2349
+ const configuredBase = tailwindV4Options?.configuredBase ?? (isRawTailwindcssPatchOptions(runtime.options) ? tailwindV4Options?.base : void 0);
2350
+ const baseFallbacks = uniqueDefined([
2351
+ configuredBase,
2352
+ cwd,
2353
+ projectRoot,
2354
+ resolveConfigDir(tailwindOptions?.config, projectRoot)
2355
+ ]);
2356
+ return {
2357
+ projectRoot,
2358
+ cwd,
2359
+ ...configuredBase === void 0 ? {} : { base: configuredBase },
2360
+ baseFallbacks,
2361
+ ...tailwindV4Options?.cssSources === void 0 ? {} : { cssSources: tailwindV4Options.cssSources },
2362
+ ...tailwindV4Options?.cssEntries === void 0 ? {} : { cssEntries: tailwindV4Options.cssEntries },
2363
+ packageName: resolveTailwindCssImportTarget(runtime)
2364
+ };
2365
+ }
2366
+ return {
2367
+ projectRoot: getProjectRoot(runtime),
2368
+ packageName: resolveTailwindCssImportTarget(runtime)
2369
+ };
2370
+ }
2371
+ function resolveTailwindV4SourceOptionsFromRuntime(runtime) {
2372
+ const tailwindV4Options = readTailwindV4Options(runtime);
2373
+ return normalizeTailwindV4SourceOptions(omitUndefined({
2374
+ ...resolveEngineTailwindV4SourceOptions(runtime),
2375
+ sources: tailwindV4Options?.sources
2376
+ }));
2377
+ }
2378
+ function resolveTailwindV4Source$1(options) {
2379
+ return resolveTailwindV4Source(normalizeTailwindV4SourceOptions(options));
2380
+ }
2381
+ function resolveTailwindV4SourceFromRuntimeOptions(options) {
2382
+ const projectRoot = options?.projectRoot ?? process.cwd();
2383
+ const tailwindOptions = options?.tailwindcss;
2384
+ const v4Options = tailwindOptions?.v4;
2385
+ return resolveTailwindV4Source$1({
2386
+ projectRoot,
2387
+ cwd: resolveBase(tailwindOptions?.cwd, projectRoot),
2388
+ packageName: tailwindOptions?.packageName ?? "tailwindcss",
2389
+ ...v4Options ?? {}
2390
+ });
2391
+ }
2392
+ async function resolveTailwindV4SourceFromRuntime(runtime) {
2393
+ return resolveTailwindV4Source$1(resolveTailwindV4SourceOptionsFromRuntime(runtime));
2394
+ }
2395
+ //#endregion
2396
+ export { isFileMatchedByTailwindSourceEntries as $, removeTailwindSourceDirectives as A, stripGeneratorPlaceholderMarkers as B, hasTailwindRootDirectives as C, normalizeTailwindSourceDirectives as D, normalizeTailwindConfigDirectives as E, hasTailwindGeneratedCss as F, createTailwindV4Engine$1 as G, stripTailwindBanners as H, hasTailwindGeneratedCssMarkers as I, transformTailwindV4CssToWeapp as J, getTailwindV4IncrementalGenerateCacheStats as K, splitGeneratorPlaceholderCssBySourceOrder as L, GENERATOR_PLACEHOLDER_MARKER_RE as M, VITE_MARKER_RE as N, normalizeTailwindSourceForGenerator as O, createCssAppend as P, expandTailwindSourceEntries as Q, splitTailwindGeneratedCssByBanner as R, hasTailwindNonRootGenerationDirectives as S, hasTailwindSourceDirectives as T, normalizeConfigDirective as U, stripTailwindBanner as V, prependConfigDirective as W, FULL_SOURCE_SCAN_PATTERN as X, FULL_SOURCE_SCAN_EXTENSION_RE as Y, createTailwindSourceEntryMatcher as Z, resolveTailwindcssOptions as _, filterTailwindV4CssSourceRoots as a, toPosixPath as at, hasLocalCssImport as b, groupCssEntriesByBase as c, omitUndefined as ct, normalizeCssEntries as d, normalizeLegacyContentEntries as et, findNearestPackageRoot as f, normalizeTailwindcssRuntimeOptions as g, normalizeExtendLengthUnits as h, resolveTailwindV4SourceOptionsFromRuntime as i, resolveTailwindV4CssSourceBase as it, resolveCssEntrySource as j, parseImportRequest as k, guessBasedirFromEntries as l, inferGeneratorTargetFromEnv as lt, findWorkspaceRoot as m, resolveTailwindV4SourceFromRuntime as n, resolveCssSourceEntries as nt, hasConfiguredTailwindV4CssRoots as o, collectCssInlineSourceCandidates as ot, findWorkspacePackageDir as p, transformTailwindV4CssByTarget as q, resolveTailwindV4SourceFromRuntimeOptions as r, resolveSourceScanPath as rt, upsertTailwindV4CssSource as s, filterUnsupportedMiniProgramTailwindV4Candidates as st, resolveTailwindV4Source$1 as t, parseConfigParam as tt, isTailwindV4CssEntry as u, loadTailwindV4DesignSystem as ut, normalizeStringListOption as v, hasTailwindRootImportDirectives as w, hasTailwindApplyDirective as x, resolveBooleanObjectOption as y, splitTailwindV4GeneratedCssBySourceOrder as z };