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,1523 @@
1
+ const require_chunk = require("./chunk-emK7D4bc.js");
2
+ const require_v4_engine = require("./v4-engine-D4ubP7N5.js");
3
+ require("./utils-BCa37Wqj.js");
4
+ let node_fs = require("node:fs");
5
+ let node_path = require("node:path");
6
+ node_path = require_chunk.__toESM(node_path);
7
+ let node_process = require("node:process");
8
+ node_process = require_chunk.__toESM(node_process);
9
+ let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
10
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
11
+ let node_fs_promises = require("node:fs/promises");
12
+ let node_module = require("node:module");
13
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
14
+ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
15
+ let fast_glob = require("fast-glob");
16
+ fast_glob = require_chunk.__toESM(fast_glob);
17
+ let tailwindcss_config = require("tailwindcss-config");
18
+ let node_url = require("node:url");
19
+ //#region src/bundlers/vite/static-config-content.ts
20
+ function skipWhitespaceAndComments(source, start) {
21
+ let index = start;
22
+ while (index < source.length) {
23
+ const char = source[index];
24
+ if (/\s/.test(char ?? "")) {
25
+ index += 1;
26
+ continue;
27
+ }
28
+ if (char === "/" && source[index + 1] === "/") {
29
+ index += 2;
30
+ while (index < source.length && source[index] !== "\n") index += 1;
31
+ continue;
32
+ }
33
+ if (char === "/" && source[index + 1] === "*") {
34
+ index += 2;
35
+ while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
36
+ index = Math.min(index + 2, source.length);
37
+ continue;
38
+ }
39
+ break;
40
+ }
41
+ return index;
42
+ }
43
+ function readQuotedString(source, start) {
44
+ const quote = source[start];
45
+ if (quote !== "\"" && quote !== "'") return;
46
+ let value = "";
47
+ for (let index = start + 1; index < source.length; index++) {
48
+ const char = source[index];
49
+ if (char === "\\") {
50
+ const next = source[index + 1];
51
+ if (next === void 0) return;
52
+ value += next;
53
+ index += 1;
54
+ continue;
55
+ }
56
+ if (char === quote) return {
57
+ end: index + 1,
58
+ value
59
+ };
60
+ value += char;
61
+ }
62
+ }
63
+ function readIdentifier(source, start) {
64
+ return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
65
+ }
66
+ function findMatchingBracket(source, start, open, close) {
67
+ let depth = 0;
68
+ let quote;
69
+ for (let index = start; index < source.length; index++) {
70
+ const char = source[index];
71
+ if (char === "\\") {
72
+ index += 1;
73
+ continue;
74
+ }
75
+ if (quote) {
76
+ if (char === quote) quote = void 0;
77
+ continue;
78
+ }
79
+ if (char === "\"" || char === "'") {
80
+ quote = char;
81
+ continue;
82
+ }
83
+ if (char === "`") return;
84
+ if (char === open) {
85
+ depth += 1;
86
+ continue;
87
+ }
88
+ if (char === close) {
89
+ depth -= 1;
90
+ if (depth === 0) return index;
91
+ }
92
+ }
93
+ }
94
+ function findContentPropertyValue(source) {
95
+ let index = 0;
96
+ while (index < source.length) {
97
+ const nextIndex = source.indexOf("content", index);
98
+ if (nextIndex === -1) return;
99
+ const previous = source[nextIndex - 1];
100
+ const next = source[nextIndex + 7];
101
+ if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
102
+ index = nextIndex + 7;
103
+ continue;
104
+ }
105
+ let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
106
+ if (source[colonIndex] !== ":") {
107
+ index = nextIndex + 7;
108
+ continue;
109
+ }
110
+ colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
111
+ return { start: colonIndex };
112
+ }
113
+ }
114
+ function parseStaticContentArray(source, start) {
115
+ if (source[start] !== "[") return;
116
+ const value = [];
117
+ let index = skipWhitespaceAndComments(source, start + 1);
118
+ while (index < source.length) {
119
+ if (source[index] === "]") return {
120
+ end: index + 1,
121
+ value
122
+ };
123
+ const parsed = parseStaticContentValue(source, index);
124
+ if (!parsed) return;
125
+ value.push(parsed.value);
126
+ index = skipWhitespaceAndComments(source, parsed.end);
127
+ if (source[index] === ",") {
128
+ index = skipWhitespaceAndComments(source, index + 1);
129
+ continue;
130
+ }
131
+ if (source[index] === "]") continue;
132
+ return;
133
+ }
134
+ }
135
+ function parseStaticContentObject(source, start) {
136
+ if (source[start] !== "{") return;
137
+ const end = findMatchingBracket(source, start, "{", "}");
138
+ if (end === void 0) return;
139
+ let index = skipWhitespaceAndComments(source, start + 1);
140
+ let files;
141
+ while (index < end) {
142
+ let key;
143
+ const quotedKey = readQuotedString(source, index);
144
+ if (quotedKey) {
145
+ key = quotedKey.value;
146
+ index = quotedKey.end;
147
+ } else {
148
+ key = readIdentifier(source, index);
149
+ if (!key) return;
150
+ index += key.length;
151
+ }
152
+ index = skipWhitespaceAndComments(source, index);
153
+ if (source[index] !== ":") return;
154
+ index = skipWhitespaceAndComments(source, index + 1);
155
+ const parsedValue = parseStaticContentValue(source, index);
156
+ if (!parsedValue) return;
157
+ if (key === "files") files = parsedValue.value;
158
+ index = skipWhitespaceAndComments(source, parsedValue.end);
159
+ if (source[index] === ",") {
160
+ index = skipWhitespaceAndComments(source, index + 1);
161
+ continue;
162
+ }
163
+ if (index < end) return;
164
+ }
165
+ return files === void 0 ? void 0 : {
166
+ end: end + 1,
167
+ value: { files }
168
+ };
169
+ }
170
+ function parseStaticContentValue(source, start) {
171
+ const index = skipWhitespaceAndComments(source, start);
172
+ const quoted = readQuotedString(source, index);
173
+ if (quoted) return quoted;
174
+ if (source[index] === "[") return parseStaticContentArray(source, index);
175
+ if (source[index] === "{") return parseStaticContentObject(source, index);
176
+ }
177
+ function readStaticConfigContent(configPath) {
178
+ let source;
179
+ try {
180
+ source = (0, node_fs.readFileSync)(configPath, "utf8");
181
+ } catch {
182
+ return;
183
+ }
184
+ const contentProperty = findContentPropertyValue(source);
185
+ if (!contentProperty) return;
186
+ return parseStaticContentValue(source, contentProperty.start)?.value;
187
+ }
188
+ //#endregion
189
+ //#region src/bundlers/vite/source-scan/css-entries.ts
190
+ const VITE_SOURCE_CANDIDATE_PATTERN = require_v4_engine.FULL_SOURCE_SCAN_PATTERN;
191
+ const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.css";
192
+ const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
193
+ function parseImportSourceParam(params) {
194
+ const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
195
+ if (!match) return;
196
+ return {
197
+ none: match[1] === "none",
198
+ sourcePath: match[3]
199
+ };
200
+ }
201
+ function parseCssImportSpecifier(params) {
202
+ const value = params.trim();
203
+ const quoted = /^(['"])(.*?)\1/.exec(value);
204
+ if (quoted) return quoted[2];
205
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
206
+ return url?.[2] ?? url?.[3];
207
+ }
208
+ function isTailwindCssImport(params) {
209
+ const specifier = parseCssImportSpecifier(params);
210
+ return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
211
+ }
212
+ function resolveSourceBase(base, sourcePath) {
213
+ return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
214
+ }
215
+ function resolveConfigPath(base, configPath) {
216
+ if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
217
+ return node_path.default.resolve(base, configPath);
218
+ }
219
+ function createCssEntriesCacheKey(css, base, dependencies) {
220
+ return JSON.stringify({
221
+ base: node_path.default.resolve(base),
222
+ css,
223
+ dependencies
224
+ });
225
+ }
226
+ async function statConfigDependency(file) {
227
+ try {
228
+ const stats = await (0, node_fs_promises.stat)(file);
229
+ return {
230
+ file,
231
+ mtimeMs: stats.mtimeMs,
232
+ size: stats.size
233
+ };
234
+ } catch {
235
+ return {
236
+ file,
237
+ mtimeMs: -1,
238
+ size: -1
239
+ };
240
+ }
241
+ }
242
+ async function collectConfigDependencySignatures(root, base) {
243
+ const configPaths = /* @__PURE__ */ new Set();
244
+ root.walkAtRules("config", (rule) => {
245
+ const configPath = require_v4_engine.parseConfigParam(rule.params);
246
+ if (configPath) configPaths.add(resolveConfigPath(base, configPath));
247
+ });
248
+ return Promise.all([...configPaths].sort().map(statConfigDependency));
249
+ }
250
+ function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
251
+ const merged = {
252
+ included: /* @__PURE__ */ new Set(),
253
+ excluded: /* @__PURE__ */ new Set()
254
+ };
255
+ for (const inlineCandidates of allInlineCandidates) {
256
+ if (!inlineCandidates) continue;
257
+ for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
258
+ for (const candidate of inlineCandidates.excluded) {
259
+ merged.excluded.add(candidate);
260
+ merged.included.delete(candidate);
261
+ }
262
+ }
263
+ return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
264
+ }
265
+ async function resolveConfigContentEntries(root, base) {
266
+ const configPaths = /* @__PURE__ */ new Set();
267
+ root.walkAtRules("config", (rule) => {
268
+ const configPath = require_v4_engine.parseConfigParam(rule.params);
269
+ if (configPath) configPaths.add(resolveConfigPath(base, configPath));
270
+ });
271
+ const entries = [];
272
+ for (const configPath of configPaths) {
273
+ const staticContent = readStaticConfigContent(configPath);
274
+ if (staticContent !== void 0) {
275
+ entries.push(...require_v4_engine.normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
276
+ continue;
277
+ }
278
+ try {
279
+ const loaded = await (0, tailwindcss_config.loadConfig)({
280
+ config: configPath,
281
+ cwd: node_path.default.dirname(configPath)
282
+ });
283
+ entries.push(...require_v4_engine.normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
284
+ } catch {}
285
+ }
286
+ return {
287
+ dependencies: [...configPaths],
288
+ entries
289
+ };
290
+ }
291
+ async function resolveTailwindV4EntriesFromCss(css, base) {
292
+ let root;
293
+ try {
294
+ root = _weapp_tailwindcss_postcss.postcss.parse(css);
295
+ } catch {
296
+ return;
297
+ }
298
+ let importSourceBase;
299
+ let hasSourceNone = false;
300
+ let hasTailwindCssImport = false;
301
+ const [sourceEntries, configEntries] = await Promise.all([require_v4_engine.resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
302
+ const entries = [...configEntries.entries, ...sourceEntries];
303
+ const hasPositiveEntries = entries.some((entry) => !entry.negated);
304
+ const inlineCandidates = require_v4_engine.collectCssInlineSourceCandidates(root);
305
+ root.walkAtRules("import", (rule) => {
306
+ if (!isTailwindCssImport(rule.params)) return;
307
+ hasTailwindCssImport = true;
308
+ const sourceParam = parseImportSourceParam(rule.params);
309
+ if (sourceParam?.none) hasSourceNone = true;
310
+ if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
311
+ });
312
+ if (importSourceBase) return {
313
+ entries: [{
314
+ base: importSourceBase,
315
+ negated: false,
316
+ pattern: VITE_SOURCE_CANDIDATE_PATTERN
317
+ }, ...entries],
318
+ explicit: true,
319
+ inlineCandidates,
320
+ dependencies: configEntries.dependencies
321
+ };
322
+ if (hasSourceNone) return {
323
+ entries,
324
+ explicit: true,
325
+ inlineCandidates,
326
+ dependencies: configEntries.dependencies
327
+ };
328
+ if (hasPositiveEntries) return {
329
+ entries,
330
+ explicit: true,
331
+ inlineCandidates,
332
+ dependencies: configEntries.dependencies
333
+ };
334
+ if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
335
+ entries: [],
336
+ explicit: true,
337
+ inlineCandidates,
338
+ dependencies: configEntries.dependencies
339
+ };
340
+ return hasTailwindCssImport ? {
341
+ entries,
342
+ explicit: false,
343
+ inlineCandidates,
344
+ dependencies: configEntries.dependencies
345
+ } : void 0;
346
+ }
347
+ async function resolveViteTailwindV4CssDependencies(css, base) {
348
+ return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
349
+ }
350
+ function collectExistingCssEntries(options) {
351
+ return [
352
+ ...options.cssEntries ?? [],
353
+ ...options.tailwindcss?.v4?.cssEntries ?? [],
354
+ ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
355
+ ].filter((item) => typeof item === "string" && item.length > 0).filter(require_v4_engine.isTailwindV4CssEntry).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
356
+ }
357
+ async function pathExistsAsFile(file) {
358
+ try {
359
+ return (await (0, node_fs_promises.stat)(file)).isFile();
360
+ } catch {
361
+ return false;
362
+ }
363
+ }
364
+ async function resolveTailwindV4EntriesFromCssCached(css, base) {
365
+ let root;
366
+ try {
367
+ root = _weapp_tailwindcss_postcss.postcss.parse(css);
368
+ } catch {
369
+ return;
370
+ }
371
+ const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
372
+ const cached = tailwindV4CssEntriesCache.get(cacheKey);
373
+ if (cached) return cached;
374
+ const task = resolveTailwindV4EntriesFromCss(css, base).catch((error) => {
375
+ tailwindV4CssEntriesCache.delete(cacheKey);
376
+ throw error;
377
+ });
378
+ tailwindV4CssEntriesCache.set(cacheKey, task);
379
+ return task;
380
+ }
381
+ async function discoverTailwindV4CssEntries(root, outDir) {
382
+ const resolvedRoot = node_path.default.resolve(root);
383
+ const ignore = ["**/node_modules/**", "**/.git/**"];
384
+ const resolvedOutDir = outDir ? node_path.default.resolve(resolvedRoot, outDir) : void 0;
385
+ if (resolvedOutDir) {
386
+ const relativeOutDir = node_path.default.relative(resolvedRoot, resolvedOutDir);
387
+ if (relativeOutDir && !relativeOutDir.startsWith("..") && !node_path.default.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(node_path.default.sep).join("/")}/**`);
388
+ }
389
+ const candidates = await (0, fast_glob.default)(VITE_TAILWIND_CSS_ENTRY_PATTERN, {
390
+ absolute: true,
391
+ cwd: resolvedRoot,
392
+ ignore,
393
+ onlyFiles: true,
394
+ unique: true
395
+ });
396
+ const entries = [];
397
+ for (const file of candidates) {
398
+ if (!await pathExistsAsFile(file)) continue;
399
+ try {
400
+ const css = (0, node_fs.readFileSync)(file, "utf8");
401
+ if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
402
+ if (await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(file))) entries.push(file);
403
+ }
404
+ } catch {}
405
+ }
406
+ return entries;
407
+ }
408
+ function collectConfiguredCssSources(options) {
409
+ return require_v4_engine.filterTailwindV4CssSourceRoots([...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? []]) ?? [];
410
+ }
411
+ //#endregion
412
+ //#region src/bundlers/vite/source-scan/dependencies.ts
413
+ function addSourceScanDependency(dependencies, file) {
414
+ if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
415
+ }
416
+ function addSourceScanDependencies(dependencies, files) {
417
+ for (const file of files ?? []) addSourceScanDependency(dependencies, file);
418
+ }
419
+ //#endregion
420
+ //#region src/bundlers/vite/source-scan.ts
421
+ function createResolvedViteSourceScan(input, dependencies) {
422
+ return {
423
+ ...input,
424
+ ...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
425
+ };
426
+ }
427
+ function createMergedCssEntrySourceScanEntries(entries, options) {
428
+ if (options.sourceCount <= 1) return entries;
429
+ const positiveEntries = entries.filter((entry) => !entry.negated);
430
+ return positiveEntries.length > 0 ? positiveEntries : entries;
431
+ }
432
+ function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
433
+ return {
434
+ entries: explicit ? entries : entries.length > 0 ? entries : void 0,
435
+ explicit,
436
+ inlineCandidates
437
+ };
438
+ }
439
+ async function resolveViteSourceScanEntries(options, runtime, scanOptions = {}) {
440
+ const sourceOptions = require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtime);
441
+ const cssEntries = collectExistingCssEntries(options);
442
+ if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
443
+ const scanRoot = scanOptions.root;
444
+ const sourceProjectRoot = sourceOptions.projectRoot;
445
+ if (scanRoot && sourceProjectRoot && node_path.default.resolve(scanRoot) === node_path.default.resolve(sourceProjectRoot)) {
446
+ const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
447
+ cssEntries.push(...discoveredCssEntries);
448
+ }
449
+ }
450
+ const entries = [];
451
+ const cssInlineCandidates = [];
452
+ const dependencies = /* @__PURE__ */ new Set();
453
+ let explicit = false;
454
+ let readableCssEntryCount = 0;
455
+ for (const cssEntry of cssEntries) {
456
+ addSourceScanDependency(dependencies, cssEntry);
457
+ let css;
458
+ try {
459
+ css = (0, node_fs.readFileSync)(cssEntry, "utf8");
460
+ } catch {
461
+ continue;
462
+ }
463
+ readableCssEntryCount++;
464
+ const resolved = await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
465
+ if (resolved) {
466
+ entries.push(...resolved.entries);
467
+ cssInlineCandidates.push(resolved.inlineCandidates);
468
+ addSourceScanDependencies(dependencies, resolved.dependencies);
469
+ explicit || (explicit = resolved.explicit);
470
+ }
471
+ }
472
+ const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
473
+ const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
474
+ if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
475
+ entries: explicit ? scanEntries : scanEntries.length > 0 ? scanEntries : void 0,
476
+ explicit,
477
+ inlineCandidates
478
+ }, dependencies);
479
+ if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
480
+ const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
481
+ return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set(resolved.dependencies)) : void 0;
482
+ }
483
+ const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
484
+ const configuredCssSources = collectConfiguredCssSources(options);
485
+ for (const cssSource of [...configuredCssSources, ...sourceOptions.cssSources ?? []]) {
486
+ if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
487
+ addSourceScanDependency(dependencies, cssSource.file);
488
+ addSourceScanDependencies(dependencies, cssSource.dependencies);
489
+ const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
490
+ if (resolved) {
491
+ entries.push(...resolved.entries);
492
+ cssInlineCandidates.push(resolved.inlineCandidates);
493
+ addSourceScanDependencies(dependencies, resolved.dependencies);
494
+ explicit || (explicit = resolved.explicit);
495
+ }
496
+ }
497
+ const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
498
+ const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length });
499
+ if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
500
+ entries: explicit ? cssSourceScanEntries : cssSourceScanEntries.length > 0 ? cssSourceScanEntries : void 0,
501
+ explicit,
502
+ inlineCandidates: cssSourceInlineCandidates
503
+ }, dependencies);
504
+ const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
505
+ addSourceScanDependency(dependencies, source.file);
506
+ addSourceScanDependencies(dependencies, source.dependencies);
507
+ const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
508
+ return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries.length > 0 ? resolved.entries : [], resolved.inlineCandidates, resolved.entries.length > 0 ? resolved.explicit : false), new Set([...dependencies, ...resolved.dependencies])) : void 0;
509
+ }
510
+ function createViteSourceScanMatcher(entries) {
511
+ if (entries?.length === 0) return;
512
+ return require_v4_engine.createTailwindSourceEntryMatcher(entries);
513
+ }
514
+ //#endregion
515
+ //#region src/tailwindcss/runtime/cache.ts
516
+ const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
517
+ const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
518
+ const runtimeTrackedSourceFilesCache = /* @__PURE__ */ new Map();
519
+ let runtimeFileSignatureCacheClearTimer;
520
+ const runtimeSignatureRuntimesSymbol = Symbol.for("weapp-tailwindcss.runtimeSignatureRuntimes");
521
+ function getCacheEntry(tailwindRuntime) {
522
+ let entry = runtimeClassSetCache.get(tailwindRuntime);
523
+ if (!entry) {
524
+ entry = {};
525
+ runtimeClassSetCache.set(tailwindRuntime, entry);
526
+ }
527
+ return entry;
528
+ }
529
+ function scheduleRuntimeConfigSignatureCacheClear() {
530
+ if (runtimeFileSignatureCacheClearTimer) return;
531
+ runtimeFileSignatureCacheClearTimer = setTimeout(() => {
532
+ runtimeFileSignatureCache.clear();
533
+ runtimeTrackedSourceFilesCache.clear();
534
+ runtimeFileSignatureCacheClearTimer = void 0;
535
+ }, 0);
536
+ runtimeFileSignatureCacheClearTimer.unref?.();
537
+ }
538
+ function getFileSignature(filePath) {
539
+ const cached = runtimeFileSignatureCache.get(filePath);
540
+ if (cached !== void 0) return cached;
541
+ let signature;
542
+ try {
543
+ const stats = (0, node_fs.statSync)(filePath);
544
+ signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
545
+ } catch {
546
+ signature = `${filePath}:missing`;
547
+ }
548
+ runtimeFileSignatureCache.set(filePath, signature);
549
+ scheduleRuntimeConfigSignatureCacheClear();
550
+ return signature;
551
+ }
552
+ function getTailwindTrackedFiles(tailwindRuntime) {
553
+ const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(tailwindRuntime.options);
554
+ const tracked = /* @__PURE__ */ new Set();
555
+ const configPath = tailwindOptions?.config;
556
+ if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
557
+ for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
558
+ for (const source of tailwindOptions?.v4?.cssSources ?? []) {
559
+ if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
560
+ for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
561
+ }
562
+ return tracked;
563
+ }
564
+ function normalizeTrackedSourceSignature(cssEntries, cssSources) {
565
+ return normalizeSignatureValue({
566
+ cssEntries: cssEntries?.map((entry) => {
567
+ if (!(0, node_fs.existsSync)(entry)) return `${entry}:missing`;
568
+ return getFileSignature(entry);
569
+ }),
570
+ cssSources
571
+ });
572
+ }
573
+ async function collectTailwindV4TrackedSourceFiles(tailwindRuntime) {
574
+ const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(tailwindRuntime.options);
575
+ const signature = normalizeTrackedSourceSignature(tailwindOptions?.v4?.cssEntries, tailwindOptions?.v4?.cssSources);
576
+ const cached = runtimeTrackedSourceFilesCache.get(signature);
577
+ if (cached) return cached;
578
+ const files = /* @__PURE__ */ new Set();
579
+ for (const cssEntry of tailwindOptions?.v4?.cssEntries ?? []) {
580
+ if (!(0, node_fs.existsSync)(cssEntry)) continue;
581
+ const resolved = await resolveTailwindV4EntriesFromCssCached((0, node_fs.readFileSync)(cssEntry, "utf8"), node_path.default.dirname(cssEntry));
582
+ const expanded = resolved?.entries?.length ? await require_v4_engine.expandTailwindSourceEntries(resolved.entries) : [];
583
+ for (const file of expanded) files.add(file);
584
+ }
585
+ for (const cssSource of tailwindOptions?.v4?.cssSources ?? []) {
586
+ if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
587
+ const base = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.dirname(cssSource.file) : tailwindOptions?.v4?.base ?? tailwindOptions?.cwd ?? tailwindRuntime.options?.projectRoot ?? node_process.default.cwd();
588
+ const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, base);
589
+ const expanded = resolved?.entries?.length ? await require_v4_engine.expandTailwindSourceEntries(resolved.entries) : [];
590
+ for (const file of expanded) files.add(file);
591
+ }
592
+ const result = [...files].sort((a, b) => a.localeCompare(b));
593
+ runtimeTrackedSourceFilesCache.set(signature, result);
594
+ return result;
595
+ }
596
+ function normalizeSignatureValue(value) {
597
+ if (value == null) return "null";
598
+ if (typeof value === "string") return value;
599
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
600
+ if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
601
+ if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
602
+ return String(value);
603
+ }
604
+ function readOptionalProperty(value, key) {
605
+ if (typeof value !== "object" || value === null || !(key in value)) return;
606
+ return value[key];
607
+ }
608
+ function getTailwindOptionsSignature(tailwindRuntime) {
609
+ const options = tailwindRuntime.options;
610
+ const tailwindOptions = require_v4_engine.resolveTailwindcssOptions(options);
611
+ return normalizeSignatureValue({
612
+ projectRoot: options?.projectRoot,
613
+ packageName: tailwindOptions?.packageName,
614
+ versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
615
+ cwd: tailwindOptions?.cwd,
616
+ config: tailwindOptions?.config,
617
+ v4: {
618
+ base: tailwindOptions?.v4?.base,
619
+ configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
620
+ css: tailwindOptions?.v4?.css,
621
+ cssEntries: tailwindOptions?.v4?.cssEntries,
622
+ cssSources: tailwindOptions?.v4?.cssSources,
623
+ hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
624
+ sources: tailwindOptions?.v4?.sources
625
+ }
626
+ });
627
+ }
628
+ function getRuntimeTargetSignature(tailwindRuntime) {
629
+ const packageInfo = tailwindRuntime.packageInfo;
630
+ return [
631
+ packageInfo?.name ?? "missing",
632
+ packageInfo?.rootPath ?? "missing",
633
+ packageInfo?.version ?? "unknown",
634
+ tailwindRuntime.majorVersion ?? "unknown",
635
+ getTailwindOptionsSignature(tailwindRuntime)
636
+ ].join(":");
637
+ }
638
+ function getNestedRuntimes(tailwindRuntime) {
639
+ const nested = tailwindRuntime[runtimeSignatureRuntimesSymbol];
640
+ return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
641
+ }
642
+ function getOwnRuntimeClassSetSignature(tailwindRuntime) {
643
+ const trackedFiles = [...getTailwindTrackedFiles(tailwindRuntime)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
644
+ return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|runtime:${getRuntimeTargetSignature(tailwindRuntime)}`;
645
+ }
646
+ function invalidateRuntimeClassSet(tailwindRuntime) {
647
+ if (!tailwindRuntime) return;
648
+ const nestedRuntimes = getNestedRuntimes(tailwindRuntime);
649
+ if (nestedRuntimes) for (const runtime of nestedRuntimes) invalidateRuntimeClassSet(runtime);
650
+ for (const trackedFile of getTailwindTrackedFiles(tailwindRuntime)) runtimeFileSignatureCache.delete(trackedFile);
651
+ runtimeTrackedSourceFilesCache.clear();
652
+ runtimeClassSetCache.delete(tailwindRuntime);
653
+ }
654
+ function getRuntimeClassSetCacheEntry(tailwindRuntime) {
655
+ return getCacheEntry(tailwindRuntime);
656
+ }
657
+ function getRuntimeClassSetSignature(tailwindRuntime) {
658
+ const nestedRuntimes = getNestedRuntimes(tailwindRuntime);
659
+ if (nestedRuntimes) return nestedRuntimes.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
660
+ return getOwnRuntimeClassSetSignature(tailwindRuntime);
661
+ }
662
+ async function getRuntimeClassSetSignatureWithSources(tailwindRuntime) {
663
+ const baseSignature = getRuntimeClassSetSignature(tailwindRuntime);
664
+ const trackedSourceFiles = await collectTailwindV4TrackedSourceFiles(tailwindRuntime);
665
+ if (trackedSourceFiles.length === 0) return baseSignature;
666
+ return [baseSignature, trackedSourceFiles.map(getFileSignature).join("|")].join("|sources:");
667
+ }
668
+ //#endregion
669
+ //#region src/tailwindcss/v4/config.ts
670
+ const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
671
+ function includesToken(list, token) {
672
+ return list.some((candidate) => {
673
+ if (typeof token === "string") {
674
+ if (typeof candidate === "string") return candidate === token;
675
+ candidate.lastIndex = 0;
676
+ return candidate.test(token);
677
+ }
678
+ if (typeof candidate === "string") {
679
+ token.lastIndex = 0;
680
+ return token.test(candidate);
681
+ }
682
+ return candidate.source === token.source && candidate.flags === token.flags;
683
+ });
684
+ }
685
+ function ensureDefaultsIncluded(value) {
686
+ if (value === true) return { includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES] };
687
+ if (Array.isArray(value)) {
688
+ if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
689
+ const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
690
+ return missing.length > 0 ? [...value, ...missing] : value;
691
+ }
692
+ if (value && typeof value === "object") {
693
+ const include = value.includeCustomProperties;
694
+ if (!Array.isArray(include)) return {
695
+ ...value,
696
+ includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
697
+ };
698
+ if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
699
+ const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
700
+ return missing.length > 0 ? {
701
+ ...value,
702
+ includeCustomProperties: [...include, ...missing]
703
+ } : value;
704
+ }
705
+ return value;
706
+ }
707
+ function normalizeCssEntriesConfig(entries) {
708
+ const normalized = require_v4_engine.normalizeStringListOption(entries)?.filter(require_v4_engine.isTailwindV4CssEntry);
709
+ return normalized && normalized.length > 0 ? normalized : void 0;
710
+ }
711
+ function hasConfiguredCssEntries(ctx) {
712
+ if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
713
+ if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) return true;
714
+ const runtimeOptions = ctx.tailwindcssRuntimeOptions;
715
+ if (runtimeOptions) {
716
+ if (normalizeCssEntriesConfig(runtimeOptions.tailwindcss?.v4?.cssEntries)) return true;
717
+ }
718
+ return false;
719
+ }
720
+ let hasWarnedMissingCssEntries = false;
721
+ function warnMissingCssEntries(ctx, tailwindRuntime) {
722
+ if (hasWarnedMissingCssEntries) return;
723
+ if (!tailwindRuntime) return;
724
+ if (hasConfiguredCssEntries(ctx) || require_v4_engine.hasConfiguredTailwindV4CssRoots(ctx)) return;
725
+ hasWarnedMissingCssEntries = true;
726
+ _weapp_tailwindcss_logger.logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
727
+ }
728
+ function applyV4CssCalcDefaults(cssCalc, tailwindRuntime) {
729
+ const cssCalcOptions = cssCalc ?? true;
730
+ if (tailwindRuntime && cssCalcOptions) return ensureDefaultsIncluded(cssCalcOptions);
731
+ return cssCalcOptions;
732
+ }
733
+ //#endregion
734
+ //#region src/tailwindcss/runtime-resolve.ts
735
+ const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
736
+ const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
737
+ const TAILWIND_CONFIG_FILES = [
738
+ "tailwind.config.js",
739
+ "tailwind.config.cjs",
740
+ "tailwind.config.mjs",
741
+ "tailwind.config.ts",
742
+ "tailwind.config.cts",
743
+ "tailwind.config.mts"
744
+ ];
745
+ function isPathSpecifier(specifier) {
746
+ if (!specifier) return false;
747
+ if (specifier.startsWith("file://")) return true;
748
+ if (node_path.default.isAbsolute(specifier)) return true;
749
+ return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
750
+ }
751
+ function resolveModuleFromPaths(specifier, paths) {
752
+ if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
753
+ try {
754
+ return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve(specifier, { paths });
755
+ } catch {
756
+ return;
757
+ }
758
+ }
759
+ function resolveTailwindConfigFallback(packageName, paths) {
760
+ if (!packageName) return;
761
+ for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
762
+ const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
763
+ if (resolved) return resolved;
764
+ }
765
+ }
766
+ function appendNodeModules(paths, dir) {
767
+ if (!dir) return;
768
+ const nodeModulesDir = node_path.default.join(dir, "node_modules");
769
+ if ((0, node_fs.existsSync)(nodeModulesDir)) paths.add(nodeModulesDir);
770
+ }
771
+ function findTailwindConfig(searchRoots) {
772
+ for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
773
+ const candidate = node_path.default.resolve(root, file);
774
+ if ((0, node_fs.existsSync)(candidate)) return candidate;
775
+ }
776
+ }
777
+ function createDefaultResolvePaths(basedir) {
778
+ const paths = /* @__PURE__ */ new Set();
779
+ let fallbackCandidates = [];
780
+ if (basedir) {
781
+ const resolvedBase = node_path.default.resolve(basedir);
782
+ appendNodeModules(paths, resolvedBase);
783
+ fallbackCandidates.push(resolvedBase);
784
+ const packageRoot = require_v4_engine.findNearestPackageRoot(resolvedBase);
785
+ if (packageRoot) {
786
+ appendNodeModules(paths, packageRoot);
787
+ fallbackCandidates.push(packageRoot);
788
+ }
789
+ const workspaceRoot = require_v4_engine.findWorkspaceRoot(resolvedBase);
790
+ if (workspaceRoot) {
791
+ appendNodeModules(paths, workspaceRoot);
792
+ fallbackCandidates.push(workspaceRoot);
793
+ }
794
+ }
795
+ const cwd = node_process.default.cwd();
796
+ appendNodeModules(paths, cwd);
797
+ try {
798
+ const modulePath = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
799
+ const candidate = (0, node_fs.existsSync)(modulePath) && !node_path.default.extname(modulePath) ? modulePath : node_path.default.dirname(modulePath);
800
+ paths.add(candidate);
801
+ } catch {
802
+ paths.add(require("url").pathToFileURL(__filename).href);
803
+ }
804
+ if (paths.size === 0) {
805
+ fallbackCandidates = fallbackCandidates.filter(Boolean);
806
+ if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
807
+ for (const candidate of fallbackCandidates) paths.add(candidate);
808
+ }
809
+ return [...paths];
810
+ }
811
+ //#endregion
812
+ //#region src/tailwindcss/version.ts
813
+ function normalizeSupportedTailwindcssMajorVersion(version) {
814
+ return version === 4 ? version : void 0;
815
+ }
816
+ function readPackageJson(packageJsonPath) {
817
+ try {
818
+ return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
819
+ } catch {
820
+ return;
821
+ }
822
+ }
823
+ function findPackageJsonDeclaringPackage(packageName, base) {
824
+ let current = node_path.default.resolve(base);
825
+ while (true) {
826
+ const pkgPath = node_path.default.join(current, "package.json");
827
+ if ((0, node_fs.existsSync)(pkgPath)) {
828
+ const pkg = readPackageJson(pkgPath);
829
+ if (readDeclaredPackageVersion(packageName, pkg)) return pkgPath;
830
+ if (pkg?.name !== "weapp-tailwindcss") return;
831
+ }
832
+ const parent = node_path.default.dirname(current);
833
+ if (parent === current) return;
834
+ current = parent;
835
+ }
836
+ }
837
+ function readDeclaredPackageVersion(packageName, pkg) {
838
+ return pkg?.dependencies?.[packageName] ?? pkg?.devDependencies?.[packageName] ?? pkg?.peerDependencies?.[packageName] ?? pkg?.optionalDependencies?.[packageName];
839
+ }
840
+ function readDeclaredPackageMajorVersion(version) {
841
+ const match = version?.match(/(?:^|\D)(4)(?:\.|\b)/);
842
+ return normalizeSupportedTailwindcssMajorVersion(match ? Number(match[1]) : void 0);
843
+ }
844
+ function readInstalledPackageMajorVersion(packageName, base) {
845
+ const packageJsonPath = findPackageJsonDeclaringPackage(packageName, base);
846
+ if (!packageJsonPath) return;
847
+ const declaredVersion = readDeclaredPackageVersion(packageName, readPackageJson(packageJsonPath));
848
+ if (!declaredVersion) return;
849
+ try {
850
+ const pkg = (0, node_module.createRequire)(packageJsonPath)(`${packageName}/package.json`);
851
+ return normalizeSupportedTailwindcssMajorVersion(Number(pkg.version?.split(".")[0]));
852
+ } catch {
853
+ return readDeclaredPackageMajorVersion(declaredVersion);
854
+ }
855
+ }
856
+ //#endregion
857
+ //#region src/tailwindcss/runtime-factory.ts
858
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
859
+ function createPackageInfo(tailwindOptions) {
860
+ const packageName = tailwindOptions?.packageName ?? "tailwindcss";
861
+ const resolvePaths = tailwindOptions?.resolve?.paths;
862
+ let rootPath;
863
+ const cwdPackageJsonPath = tailwindOptions?.cwd ? node_path.default.join(tailwindOptions.cwd, "package.json") : void 0;
864
+ if (cwdPackageJsonPath) try {
865
+ if (require$1(cwdPackageJsonPath).name === packageName) rootPath = cwdPackageJsonPath;
866
+ } catch {}
867
+ rootPath ?? (rootPath = resolveModuleFromPaths(`${packageName}/package.json`, resolvePaths ?? []));
868
+ if (!rootPath) for (const resolvePath of [tailwindOptions?.cwd, ...resolvePaths ?? []]) {
869
+ if (!resolvePath) continue;
870
+ try {
871
+ rootPath = (0, node_module.createRequire)(node_path.default.join(resolvePath, "package.json")).resolve(`${packageName}/package.json`);
872
+ break;
873
+ } catch {}
874
+ }
875
+ if (rootPath) {
876
+ const packageJsonPath = rootPath;
877
+ const packageRoot = node_path.default.dirname(packageJsonPath);
878
+ try {
879
+ const packageJson = require$1(packageJsonPath);
880
+ return {
881
+ name: packageName,
882
+ version: packageJson.version,
883
+ rootPath: packageRoot,
884
+ packageJsonPath,
885
+ packageJson
886
+ };
887
+ } catch {
888
+ return {
889
+ name: packageName,
890
+ version: void 0,
891
+ rootPath: packageRoot,
892
+ packageJsonPath,
893
+ packageJson: {}
894
+ };
895
+ }
896
+ }
897
+ return {
898
+ name: packageName,
899
+ version: void 0,
900
+ rootPath: "",
901
+ packageJsonPath: "",
902
+ packageJson: {}
903
+ };
904
+ }
905
+ function resolveMajorVersion(tailwindOptions, packageInfo) {
906
+ if (tailwindOptions?.version === 4) return tailwindOptions.version;
907
+ if (packageInfo.version?.startsWith("4.")) return 4;
908
+ return 4;
909
+ }
910
+ function createFallbackTailwindcssRuntime(options) {
911
+ const packageInfo = createPackageInfo(options?.tailwindcss);
912
+ return {
913
+ packageInfo,
914
+ majorVersion: resolveMajorVersion(options?.tailwindcss, packageInfo),
915
+ options,
916
+ async getClassSet() {
917
+ return /* @__PURE__ */ new Set();
918
+ },
919
+ async extract(_options) {
920
+ return {
921
+ classList: [],
922
+ classSet: /* @__PURE__ */ new Set()
923
+ };
924
+ },
925
+ async collectContentTokens() {
926
+ return {
927
+ entries: [],
928
+ filesScanned: 0,
929
+ sources: [],
930
+ skippedFiles: []
931
+ };
932
+ }
933
+ };
934
+ }
935
+ function createEngineTailwindcssRuntime(options) {
936
+ const tailwindOptions = options.tailwindcss;
937
+ const packageInfo = createPackageInfo(tailwindOptions);
938
+ const majorVersion = resolveMajorVersion(tailwindOptions, packageInfo);
939
+ let classSetCache;
940
+ let runtime;
941
+ function applyClassSetFilter(classSet) {
942
+ if (typeof options.filter !== "function") return classSet;
943
+ return new Set([...classSet].filter((className) => options.filter?.(className) !== false));
944
+ }
945
+ async function collectClassSet() {
946
+ const report = await collectContentTokens();
947
+ const candidates = new Set(report.entries.map((entry) => {
948
+ return typeof entry === "string" ? entry : entry.rawCandidate;
949
+ }).filter((entry) => typeof entry === "string" && entry.length > 0));
950
+ await collectTailwindV4CssCandidates(candidates);
951
+ return applyClassSetFilter(candidates);
952
+ }
953
+ async function collectTailwindV4CssCandidates(candidates) {
954
+ const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
955
+ const cssList = [source.css, ...(source.cssSources ?? []).map((cssSource) => cssSource.css).filter((css) => typeof css === "string")];
956
+ for (const css of cssList) {
957
+ if (!css.includes("@apply")) continue;
958
+ try {
959
+ _weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("apply", (rule) => {
960
+ for (const candidate of rule.params.split(/\s+/)) {
961
+ const normalized = candidate.replace(/!important$/, "").trim();
962
+ if (normalized) candidates.add(normalized);
963
+ }
964
+ });
965
+ } catch {}
966
+ }
967
+ }
968
+ async function collectContentTokens() {
969
+ const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
970
+ const report = await (0, _tailwindcss_mangle_engine.extractProjectCandidatesWithPositions)({
971
+ base: source.base,
972
+ baseFallbacks: source.baseFallbacks,
973
+ css: source.css,
974
+ cwd: source.projectRoot,
975
+ sources: source.sources
976
+ });
977
+ return {
978
+ entries: report.entries,
979
+ filesScanned: report.filesScanned,
980
+ sources: source.sources,
981
+ skippedFiles: report.skippedFiles
982
+ };
983
+ }
984
+ async function extract(options) {
985
+ let classSet = await collectClassSet();
986
+ const filter = options?.removeUniversalSelector === true ? (className) => className !== "*" : void 0;
987
+ if (filter) classSet = new Set([...classSet].filter(filter));
988
+ if (typeof options?.write === "boolean") {}
989
+ classSetCache = classSet;
990
+ return {
991
+ classList: [...classSet],
992
+ classSet
993
+ };
994
+ }
995
+ runtime = {
996
+ packageInfo,
997
+ majorVersion,
998
+ options,
999
+ async getClassSet() {
1000
+ return (await extract({ write: false })).classSet;
1001
+ },
1002
+ getClassSetSync() {
1003
+ return classSetCache ?? /* @__PURE__ */ new Set();
1004
+ },
1005
+ extract,
1006
+ collectContentTokens
1007
+ };
1008
+ return runtime;
1009
+ }
1010
+ let hasLoggedMissingTailwind = false;
1011
+ const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
1012
+ const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
1013
+ function createTailwindcssRuntime(options) {
1014
+ const { basedir, cacheDir, supportCustomLengthUnits, tailwindcss, tailwindcssRuntimeOptions } = options || {};
1015
+ const cache = {
1016
+ enabled: true,
1017
+ driver: "memory"
1018
+ };
1019
+ const normalizedBasedir = basedir ? node_path.default.resolve(basedir) : void 0;
1020
+ const cacheRoot = require_v4_engine.findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? node_process.default.cwd();
1021
+ if (cacheDir) if (node_path.default.isAbsolute(cacheDir)) cache.dir = cacheDir;
1022
+ else if (normalizedBasedir) cache.dir = node_path.default.resolve(normalizedBasedir, cacheDir);
1023
+ else cache.dir = node_path.default.resolve(node_process.default.cwd(), cacheDir);
1024
+ else cache.dir = node_path.default.join(cacheRoot, "node_modules", ".cache", "@tailwindcss-mangle", "engine");
1025
+ if (normalizedBasedir) cache.cwd = normalizedBasedir;
1026
+ const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? node_process.default.cwd());
1027
+ const normalizedUserOptions = require_v4_engine.normalizeTailwindcssRuntimeOptions(tailwindcssRuntimeOptions);
1028
+ const extendLengthUnits = require_v4_engine.normalizeExtendLengthUnits(supportCustomLengthUnits ?? true);
1029
+ const baseTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, require_v4_engine.omitUndefined({
1030
+ cwd: normalizedBasedir,
1031
+ resolve: { paths: resolvePaths }
1032
+ }));
1033
+ baseTailwindOptions.packageName = tailwindcss?.packageName ?? normalizedUserOptions?.tailwindcss?.packageName ?? baseTailwindOptions.packageName ?? "tailwindcss";
1034
+ if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = "tailwindcss";
1035
+ if (typeof baseTailwindOptions.postcssPlugin === "string") {
1036
+ const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
1037
+ if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
1038
+ }
1039
+ const baseOptions = require_v4_engine.omitUndefined({
1040
+ projectRoot: normalizedBasedir,
1041
+ cache,
1042
+ tailwindcss: baseTailwindOptions,
1043
+ apply: require_v4_engine.omitUndefined({
1044
+ exposeContext: true,
1045
+ extendLengthUnits
1046
+ })
1047
+ });
1048
+ const resolvedOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(normalizedUserOptions ?? {}, baseOptions);
1049
+ const resolvedTailwindOptions = resolvedOptions.tailwindcss;
1050
+ if (resolvedTailwindOptions) {
1051
+ const existingResolve = resolvedTailwindOptions.resolve ?? {};
1052
+ const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths ?? [], ...resolvePaths] : resolvePaths;
1053
+ resolvedTailwindOptions.resolve = {
1054
+ ...existingResolve,
1055
+ paths: [...new Set(sourcePaths)]
1056
+ };
1057
+ _weapp_tailwindcss_logger.logger.debug("Tailwind resolve config %O", {
1058
+ packageName: resolvedTailwindOptions.packageName,
1059
+ version: resolvedTailwindOptions.version,
1060
+ resolve: resolvedTailwindOptions.resolve,
1061
+ cwd: resolvedTailwindOptions.cwd
1062
+ });
1063
+ if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
1064
+ const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
1065
+ if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
1066
+ }
1067
+ const searchRoots = /* @__PURE__ */ new Set();
1068
+ if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
1069
+ for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
1070
+ const parentDir = node_path.default.dirname(resolvePath);
1071
+ searchRoots.add(parentDir);
1072
+ }
1073
+ const configPath = findTailwindConfig(searchRoots);
1074
+ if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
1075
+ else {
1076
+ const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
1077
+ if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
1078
+ }
1079
+ if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = node_path.default.dirname(configPath);
1080
+ resolvedOptions.tailwindcss = resolvedTailwindOptions;
1081
+ }
1082
+ try {
1083
+ return createEngineTailwindcssRuntime(resolvedOptions);
1084
+ } catch (error) {
1085
+ const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
1086
+ if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
1087
+ if (!hasLoggedMissingTailwind) {
1088
+ _weapp_tailwindcss_logger.logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 运行时能力。若需使用 Tailwind 能力,请安装 tailwindcss。");
1089
+ hasLoggedMissingTailwind = true;
1090
+ }
1091
+ return createFallbackTailwindcssRuntime(resolvedOptions);
1092
+ }
1093
+ if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) _weapp_tailwindcss_logger.logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
1094
+ throw error;
1095
+ }
1096
+ }
1097
+ //#endregion
1098
+ //#region src/tailwindcss/v4/multi-runtime.ts
1099
+ function createMultiTailwindcssRuntime(runtimes) {
1100
+ if (runtimes.length <= 1) {
1101
+ const [runtime] = runtimes;
1102
+ if (!runtime) throw new Error("createMultiTailwindcssRuntime requires at least one runtime.");
1103
+ return runtime;
1104
+ }
1105
+ const first = runtimes[0];
1106
+ const multiRuntime = {
1107
+ ...first,
1108
+ packageInfo: first?.packageInfo,
1109
+ majorVersion: first?.majorVersion,
1110
+ options: first?.options,
1111
+ async getClassSet() {
1112
+ const aggregated = /* @__PURE__ */ new Set();
1113
+ for (const runtime of runtimes) {
1114
+ const current = await runtime.getClassSet();
1115
+ for (const className of current) aggregated.add(className);
1116
+ }
1117
+ return aggregated;
1118
+ },
1119
+ async extract(options) {
1120
+ const aggregatedSet = /* @__PURE__ */ new Set();
1121
+ const aggregatedList = [];
1122
+ let filename;
1123
+ for (const runtime of runtimes) {
1124
+ const result = await runtime.extract(options);
1125
+ if (!result) continue;
1126
+ if (filename === void 0 && result.filename) filename = result.filename;
1127
+ if (result.classList) for (const className of result.classList) {
1128
+ if (!aggregatedSet.has(className)) aggregatedList.push(className);
1129
+ aggregatedSet.add(className);
1130
+ }
1131
+ if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
1132
+ }
1133
+ return require_v4_engine.omitUndefined({
1134
+ classList: aggregatedList,
1135
+ classSet: aggregatedSet,
1136
+ filename
1137
+ });
1138
+ }
1139
+ };
1140
+ if (runtimes.every((runtime) => typeof runtime.getClassSetSync === "function")) multiRuntime.getClassSetSync = () => {
1141
+ const aggregated = /* @__PURE__ */ new Set();
1142
+ for (const runtime of runtimes) {
1143
+ const current = runtime.getClassSetSync?.();
1144
+ if (!current) continue;
1145
+ for (const className of current) aggregated.add(className);
1146
+ }
1147
+ return aggregated;
1148
+ };
1149
+ Object.defineProperty(multiRuntime, runtimeSignatureRuntimesSymbol, {
1150
+ value: [...runtimes],
1151
+ configurable: true
1152
+ });
1153
+ return multiRuntime;
1154
+ }
1155
+ //#endregion
1156
+ //#region src/tailwindcss/v4/runtime-options.ts
1157
+ function overrideTailwindcssRuntimeOptionsForBase(options, baseDir, cssEntries) {
1158
+ const hasCssEntries = cssEntries.length > 0;
1159
+ if (!options) return options;
1160
+ const modernTailwind = options.tailwindcss;
1161
+ if (!modernTailwind) return options;
1162
+ return {
1163
+ ...options,
1164
+ tailwindcss: {
1165
+ ...modernTailwind,
1166
+ v4: {
1167
+ ...modernTailwind.v4 ?? {},
1168
+ ...hasCssEntries ? {} : { base: modernTailwind.v4?.base ?? baseDir },
1169
+ cssEntries: hasCssEntries ? cssEntries : modernTailwind.v4?.cssEntries ?? cssEntries
1170
+ }
1171
+ }
1172
+ };
1173
+ }
1174
+ //#endregion
1175
+ //#region src/tailwindcss/v4/runtime-factory.ts
1176
+ function isTailwindcss4Package(packageName) {
1177
+ return Boolean(packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")));
1178
+ }
1179
+ function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
1180
+ if (typeof configuredVersion === "number") return configuredVersion;
1181
+ if (isTailwindcss4Package(configuredPackageName)) return 4;
1182
+ }
1183
+ function readPackageNameFromBaseDir(baseDir) {
1184
+ try {
1185
+ if (!(0, node_fs.existsSync)(node_path.default.join(baseDir, "index.css"))) return;
1186
+ const name = JSON.parse((0, node_fs.readFileSync)(node_path.default.join(baseDir, "package.json"), "utf8")).name;
1187
+ return typeof name === "string" && (name === "tailwindcss" || name.includes("tailwindcss4")) ? name : void 0;
1188
+ } catch {
1189
+ return;
1190
+ }
1191
+ }
1192
+ function createTailwindcssRuntimeForBase(baseDir, cssEntries, options) {
1193
+ const { tailwindcss, tailwindcssRuntimeOptions, supportCustomLengthUnits, bareArbitraryValues } = options;
1194
+ const hasCssEntries = Boolean(cssEntries?.length);
1195
+ const defaultTailwindcssConfig = {
1196
+ cwd: baseDir,
1197
+ v4: hasCssEntries ? require_v4_engine.omitUndefined({ cssEntries }) : require_v4_engine.omitUndefined({
1198
+ base: baseDir,
1199
+ cssEntries
1200
+ })
1201
+ };
1202
+ const mergedTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, defaultTailwindcssConfig);
1203
+ if (!mergedTailwindOptions.v4 || typeof mergedTailwindOptions.v4 !== "object") mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
1204
+ base: baseDir,
1205
+ cssEntries: cssEntries ?? []
1206
+ };
1207
+ else if (hasCssEntries) {
1208
+ if (cssEntries?.length) mergedTailwindOptions.v4.cssEntries = cssEntries;
1209
+ else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = [];
1210
+ } else if (!mergedTailwindOptions.v4.cssEntries) {
1211
+ if (!mergedTailwindOptions.v4.base) mergedTailwindOptions.v4.base = baseDir;
1212
+ mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
1213
+ }
1214
+ if (bareArbitraryValues !== void 0 && bareArbitraryValues !== false) mergedTailwindOptions.v4.bareArbitraryValues = bareArbitraryValues;
1215
+ const patchedOptions = overrideTailwindcssRuntimeOptionsForBase(tailwindcssRuntimeOptions, baseDir, cssEntries ?? []);
1216
+ const configuredPackageName = tailwindcss?.packageName || tailwindcssRuntimeOptions?.tailwindcss?.packageName;
1217
+ const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssRuntimeOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
1218
+ const resolvedTailwindVersion = readInstalledPackageMajorVersion(configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss", baseDir) ?? explicitTailwindVersion;
1219
+ const supportedResolvedTailwindVersion = resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
1220
+ const tailwindOptionsForPackage = {
1221
+ ...mergedTailwindOptions,
1222
+ packageName: configuredPackageName ?? mergedTailwindOptions.packageName ?? readPackageNameFromBaseDir(baseDir) ?? "tailwindcss"
1223
+ };
1224
+ if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
1225
+ return createTailwindcssRuntime(require_v4_engine.omitUndefined({
1226
+ basedir: baseDir,
1227
+ supportCustomLengthUnits: supportCustomLengthUnits ?? true,
1228
+ tailwindcss: tailwindOptionsForPackage,
1229
+ tailwindcssRuntimeOptions: patchedOptions
1230
+ }));
1231
+ }
1232
+ function tryCreateMultiTailwindcssRuntime(groups, options) {
1233
+ if (groups.size <= 1) return;
1234
+ _weapp_tailwindcss_logger.logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
1235
+ const runtimes = [];
1236
+ for (const [baseDir, entries] of groups) {
1237
+ const runtime = createTailwindcssRuntimeForBase(baseDir, entries, options);
1238
+ if (runtime) runtimes.push(runtime);
1239
+ }
1240
+ return createMultiTailwindcssRuntime(runtimes);
1241
+ }
1242
+ //#endregion
1243
+ //#region src/uni-app-x/options.ts
1244
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
1245
+ enabled: true,
1246
+ onlyWhenStyleIsolationVersion2: true
1247
+ };
1248
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
1249
+ enabled: false,
1250
+ onlyWhenStyleIsolationVersion2: true
1251
+ };
1252
+ function isBooleanUniAppXShortcut(option) {
1253
+ return option === true || option === false || option === void 0;
1254
+ }
1255
+ function resolveComponentLocalStyles(option) {
1256
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
1257
+ const componentLocalStyles = option.componentLocalStyles;
1258
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
1259
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
1260
+ return {
1261
+ enabled: componentLocalStyles.enabled !== false,
1262
+ onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
1263
+ };
1264
+ }
1265
+ function resolveUniAppXOptions(option) {
1266
+ if (typeof option === "object" && option) return {
1267
+ enabled: option.enabled !== false,
1268
+ componentLocalStyles: resolveComponentLocalStyles(option),
1269
+ uvueUnsupported: option.uvueUnsupported ?? "warn"
1270
+ };
1271
+ return {
1272
+ enabled: Boolean(option),
1273
+ componentLocalStyles: resolveComponentLocalStyles(option),
1274
+ uvueUnsupported: "warn"
1275
+ };
1276
+ }
1277
+ function isUniAppXEnabled(option) {
1278
+ return resolveUniAppXOptions(option).enabled;
1279
+ }
1280
+ //#endregion
1281
+ //#region src/context/tailwindcss/basedir.ts
1282
+ const ENV_BASEDIR_KEYS = [
1283
+ "WEAPP_TAILWINDCSS_BASEDIR",
1284
+ "WEAPP_TAILWINDCSS_BASE_DIR",
1285
+ "TAILWINDCSS_BASEDIR",
1286
+ "TAILWINDCSS_BASE_DIR",
1287
+ "UNI_INPUT_DIR",
1288
+ "UNI_INPUT_ROOT",
1289
+ "UNI_CLI_ROOT",
1290
+ "UNI_APP_INPUT_DIR",
1291
+ "INIT_CWD",
1292
+ "PWD"
1293
+ ];
1294
+ const GENERIC_ENV_BASEDIR_KEYS = new Set(["INIT_CWD", "PWD"]);
1295
+ function pickEnvBasedir() {
1296
+ for (const key of ENV_BASEDIR_KEYS) {
1297
+ const value = node_process.default.env[key];
1298
+ if (value && node_path.default.isAbsolute(value)) return {
1299
+ key,
1300
+ value
1301
+ };
1302
+ }
1303
+ }
1304
+ function pickPackageEnvBasedir() {
1305
+ const packageJsonPath = node_process.default.env["npm_package_json"];
1306
+ if (packageJsonPath) {
1307
+ const packageDir = node_path.default.dirname(packageJsonPath);
1308
+ if (packageDir && node_path.default.isAbsolute(packageDir)) return packageDir;
1309
+ }
1310
+ const localPrefix = node_process.default.env["npm_config_local_prefix"];
1311
+ if (localPrefix && node_path.default.isAbsolute(localPrefix)) return localPrefix;
1312
+ }
1313
+ const STACK_PAREN_RE = /\(([^)]+)\)/u;
1314
+ const STACK_AT_RE = /at\s+(\S.*)$/u;
1315
+ function detectCallerBasedir() {
1316
+ const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
1317
+ if (!stack) return;
1318
+ if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("caller stack: %s", stack);
1319
+ const lines = stack.split("\n");
1320
+ for (const line of lines) {
1321
+ const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
1322
+ if (!location) continue;
1323
+ let filePath = location;
1324
+ if (filePath.startsWith("file://")) try {
1325
+ filePath = (0, node_url.fileURLToPath)(filePath);
1326
+ } catch {
1327
+ continue;
1328
+ }
1329
+ const [candidate = ""] = filePath.split(":");
1330
+ const resolvedPath = node_path.default.isAbsolute(filePath) ? filePath : candidate;
1331
+ if (!node_path.default.isAbsolute(resolvedPath)) continue;
1332
+ if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
1333
+ try {
1334
+ return node_path.default.dirname(resolvedPath);
1335
+ } catch {
1336
+ continue;
1337
+ }
1338
+ }
1339
+ }
1340
+ function resolveTailwindcssBasedir(basedir, fallback) {
1341
+ const envBasedirResult = pickEnvBasedir();
1342
+ const envBasedir = envBasedirResult?.value;
1343
+ const envBasedirKey = envBasedirResult?.key;
1344
+ const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
1345
+ const packageEnvBasedir = pickPackageEnvBasedir();
1346
+ const callerBasedir = !envBasedir || envBasedirIsGeneric ? detectCallerBasedir() : void 0;
1347
+ const cwd = node_process.default.cwd();
1348
+ const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
1349
+ const resolveRelative = (value) => node_path.default.isAbsolute(value) ? node_path.default.normalize(value) : node_path.default.normalize(node_path.default.resolve(anchor, value));
1350
+ if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("resolveTailwindcssBasedir anchor %O", {
1351
+ basedir,
1352
+ envBasedir,
1353
+ envBasedirKey,
1354
+ envBasedirIsGeneric,
1355
+ packageEnvBasedir,
1356
+ fallback,
1357
+ callerBasedir,
1358
+ npm_package_json: node_process.default.env["npm_package_json"],
1359
+ cwd,
1360
+ anchor
1361
+ });
1362
+ if (basedir && basedir.trim().length > 0) return resolveRelative(basedir);
1363
+ if (envBasedir && !envBasedirIsGeneric) return node_path.default.normalize(envBasedir);
1364
+ if (fallback && fallback.trim().length > 0) return resolveRelative(fallback);
1365
+ if (packageEnvBasedir) return node_path.default.normalize(packageEnvBasedir);
1366
+ if (callerBasedir) {
1367
+ const normalizedCaller = node_path.default.normalize(callerBasedir);
1368
+ const librarySegment = `${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}`;
1369
+ if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
1370
+ }
1371
+ const packageName = node_process.default.env["PNPM_PACKAGE_NAME"];
1372
+ if (packageName) try {
1373
+ const packageJsonPath = (0, node_module.createRequire)(node_path.default.join(anchor, "__resolve_tailwindcss_basedir__.cjs")).resolve(`${packageName}/package.json`);
1374
+ if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
1375
+ return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
1376
+ } catch {
1377
+ if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("failed to resolve package json for %s", packageName);
1378
+ const workspaceRoot = require_v4_engine.findWorkspaceRoot(anchor);
1379
+ if (workspaceRoot) {
1380
+ const packageDir = require_v4_engine.findWorkspacePackageDir(workspaceRoot, packageName);
1381
+ if (packageDir) return packageDir;
1382
+ }
1383
+ }
1384
+ if (envBasedir) return node_path.default.normalize(envBasedir);
1385
+ return node_path.default.normalize(cwd);
1386
+ }
1387
+ //#endregion
1388
+ //#region src/context/tailwindcss.ts
1389
+ function createTailwindcssRuntimeFromContext(ctx) {
1390
+ const { tailwindcssBasedir, supportCustomLengthUnits, tailwindcss, tailwindcssRuntimeOptions, cssEntries: rawCssEntries, appType, arbitraryValues } = ctx;
1391
+ const effectiveSupportCustomLengthUnits = ctx.generator?.target === "web" ? false : supportCustomLengthUnits;
1392
+ const absoluteCssEntryBasedir = require_v4_engine.guessBasedirFromEntries(rawCssEntries);
1393
+ const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
1394
+ ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
1395
+ _weapp_tailwindcss_logger.logger.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
1396
+ const normalizedCssEntries = require_v4_engine.normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
1397
+ if (normalizedCssEntries) ctx.cssEntries = normalizedCssEntries;
1398
+ const runtimeOptions = {
1399
+ tailwindcss,
1400
+ tailwindcssRuntimeOptions,
1401
+ supportCustomLengthUnits: effectiveSupportCustomLengthUnits,
1402
+ appType,
1403
+ bareArbitraryValues: arbitraryValues?.bareArbitraryValues
1404
+ };
1405
+ const workspaceRoot = require_v4_engine.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_v4_engine.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
1406
+ const groupedCssEntries = normalizedCssEntries ? require_v4_engine.groupCssEntriesByBase(normalizedCssEntries, require_v4_engine.omitUndefined({
1407
+ preferredBaseDir: resolvedTailwindcssBasedir,
1408
+ workspaceRoot
1409
+ })) : void 0;
1410
+ const multiRuntime = groupedCssEntries ? tryCreateMultiTailwindcssRuntime(groupedCssEntries, runtimeOptions) : void 0;
1411
+ if (multiRuntime) return multiRuntime;
1412
+ if (groupedCssEntries?.size === 1) {
1413
+ const firstGroup = groupedCssEntries.entries().next().value;
1414
+ if (firstGroup) {
1415
+ const [baseDir, entries] = firstGroup;
1416
+ return createTailwindcssRuntimeForBase(baseDir, entries, runtimeOptions);
1417
+ }
1418
+ }
1419
+ return createTailwindcssRuntimeForBase(resolvedTailwindcssBasedir, normalizedCssEntries ?? rawCssEntries, runtimeOptions);
1420
+ }
1421
+ //#endregion
1422
+ Object.defineProperty(exports, "applyV4CssCalcDefaults", {
1423
+ enumerable: true,
1424
+ get: function() {
1425
+ return applyV4CssCalcDefaults;
1426
+ }
1427
+ });
1428
+ Object.defineProperty(exports, "createTailwindcssRuntimeFromContext", {
1429
+ enumerable: true,
1430
+ get: function() {
1431
+ return createTailwindcssRuntimeFromContext;
1432
+ }
1433
+ });
1434
+ Object.defineProperty(exports, "createViteSourceScanMatcher", {
1435
+ enumerable: true,
1436
+ get: function() {
1437
+ return createViteSourceScanMatcher;
1438
+ }
1439
+ });
1440
+ Object.defineProperty(exports, "discoverTailwindV4CssEntries", {
1441
+ enumerable: true,
1442
+ get: function() {
1443
+ return discoverTailwindV4CssEntries;
1444
+ }
1445
+ });
1446
+ Object.defineProperty(exports, "findTailwindConfig", {
1447
+ enumerable: true,
1448
+ get: function() {
1449
+ return findTailwindConfig;
1450
+ }
1451
+ });
1452
+ Object.defineProperty(exports, "getRuntimeClassSetCacheEntry", {
1453
+ enumerable: true,
1454
+ get: function() {
1455
+ return getRuntimeClassSetCacheEntry;
1456
+ }
1457
+ });
1458
+ Object.defineProperty(exports, "getRuntimeClassSetSignature", {
1459
+ enumerable: true,
1460
+ get: function() {
1461
+ return getRuntimeClassSetSignature;
1462
+ }
1463
+ });
1464
+ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
1465
+ enumerable: true,
1466
+ get: function() {
1467
+ return getRuntimeClassSetSignatureWithSources;
1468
+ }
1469
+ });
1470
+ Object.defineProperty(exports, "invalidateRuntimeClassSet", {
1471
+ enumerable: true,
1472
+ get: function() {
1473
+ return invalidateRuntimeClassSet;
1474
+ }
1475
+ });
1476
+ Object.defineProperty(exports, "isUniAppXEnabled", {
1477
+ enumerable: true,
1478
+ get: function() {
1479
+ return isUniAppXEnabled;
1480
+ }
1481
+ });
1482
+ Object.defineProperty(exports, "resolveTailwindV4EntriesFromCss", {
1483
+ enumerable: true,
1484
+ get: function() {
1485
+ return resolveTailwindV4EntriesFromCss;
1486
+ }
1487
+ });
1488
+ Object.defineProperty(exports, "resolveTailwindV4EntriesFromCssCached", {
1489
+ enumerable: true,
1490
+ get: function() {
1491
+ return resolveTailwindV4EntriesFromCssCached;
1492
+ }
1493
+ });
1494
+ Object.defineProperty(exports, "resolveTailwindcssBasedir", {
1495
+ enumerable: true,
1496
+ get: function() {
1497
+ return resolveTailwindcssBasedir;
1498
+ }
1499
+ });
1500
+ Object.defineProperty(exports, "resolveUniAppXOptions", {
1501
+ enumerable: true,
1502
+ get: function() {
1503
+ return resolveUniAppXOptions;
1504
+ }
1505
+ });
1506
+ Object.defineProperty(exports, "resolveViteSourceScanEntries", {
1507
+ enumerable: true,
1508
+ get: function() {
1509
+ return resolveViteSourceScanEntries;
1510
+ }
1511
+ });
1512
+ Object.defineProperty(exports, "resolveViteTailwindV4CssDependencies", {
1513
+ enumerable: true,
1514
+ get: function() {
1515
+ return resolveViteTailwindV4CssDependencies;
1516
+ }
1517
+ });
1518
+ Object.defineProperty(exports, "warnMissingCssEntries", {
1519
+ enumerable: true,
1520
+ get: function() {
1521
+ return warnMissingCssEntries;
1522
+ }
1523
+ });