weapp-tailwindcss 5.3.6 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +4 -4
  3. package/dist/bundlers/shared/framework-postcss.d.ts +3 -0
  4. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -1
  5. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/types.d.ts +3 -1
  7. package/dist/bundlers/shared/source-candidates/snapshot.d.ts +19 -0
  8. package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -0
  9. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -0
  10. package/dist/bundlers/shared/source-candidates/views.d.ts +12 -0
  11. package/dist/bundlers/shared/style-requests.d.ts +1 -0
  12. package/dist/bundlers/vite/bundle-state.d.ts +9 -1
  13. package/dist/bundlers/vite/capability-profile.d.ts +18 -0
  14. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +12 -0
  15. package/dist/bundlers/vite/hot-css-modules.d.ts +2 -2
  16. package/dist/bundlers/vite/shared/configured-css-entry-observer.d.ts +29 -0
  17. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -0
  18. package/dist/bundlers/vite/shared/framework-css-generation-queue.d.ts +1 -0
  19. package/dist/bundlers/vite/shared/framework-hmr-module-version.d.ts +9 -0
  20. package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +5 -0
  21. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +12 -2
  22. package/dist/compiler/compilation-session-pool.d.ts +1 -0
  23. package/dist/compiler/framework-compiler-session.d.ts +21 -0
  24. package/dist/compiler/index.d.ts +1 -0
  25. package/dist/{context-DTLRADfE.cjs → compiler-CDAz4SwJ.cjs} +907 -11
  26. package/dist/{context-4ittVpgt.js → compiler-DWcUgi3A.js} +813 -6
  27. package/dist/context/handlers.d.ts +1 -1
  28. package/dist/core/compiler/compiler.d.ts +2 -0
  29. package/dist/core/compiler/generation-cache.d.ts +30 -0
  30. package/dist/core/compiler/generation-state.d.ts +17 -0
  31. package/dist/core/compiler/index.d.ts +2 -0
  32. package/dist/core/compiler/root-store.d.ts +41 -0
  33. package/dist/core/compiler/snapshot.d.ts +35 -0
  34. package/dist/core/compiler/source-fingerprint.d.ts +3 -0
  35. package/dist/core/compiler/transforms.d.ts +15 -0
  36. package/dist/core/compiler/types.d.ts +75 -0
  37. package/dist/core.cjs +34 -8
  38. package/dist/core.d.ts +4 -1
  39. package/dist/core.js +3 -2
  40. package/dist/framework/index.d.ts +3 -1
  41. package/dist/framework.cjs +6 -1
  42. package/dist/framework.js +6 -1
  43. package/dist/{generator-EnTXLBlK.js → generator-BjK5PRR-.js} +28 -10
  44. package/dist/{generator-DKiYbTFR.cjs → generator-WlhrtNa3.cjs} +26 -8
  45. package/dist/generator.cjs +1 -1
  46. package/dist/generator.js +1 -1
  47. package/dist/{gulp-DwtrU4V1.js → gulp-BbMMp7vY.js} +7 -7
  48. package/dist/{gulp-CUysZjW3.cjs → gulp-CBu_waef.cjs} +14 -16
  49. package/dist/gulp.cjs +1 -1
  50. package/dist/gulp.js +1 -1
  51. package/dist/{hmr-timing-utmOgn6p.js → hmr-timing-B_4sAvsk.js} +369 -291
  52. package/dist/{hmr-timing-Cvh5UgnM.cjs → hmr-timing-CYhNto2U.cjs} +4 -4
  53. package/dist/index.cjs +4 -4
  54. package/dist/index.js +4 -4
  55. package/dist/{pipeline-helpers-CyVXL3h6.cjs → pipeline-helpers-Du8eAtMG.cjs} +6 -6
  56. package/dist/postcss.cjs +1 -1
  57. package/dist/postcss.js +1 -1
  58. package/dist/presets.cjs +2 -3
  59. package/dist/presets.js +1 -1
  60. package/dist/rspack.cjs +2 -2
  61. package/dist/rspack.js +2 -2
  62. package/dist/{source-candidate-scan-signature-BNt7NrrI.cjs → source-candidate-scan-signature-ZOm0O17V.cjs} +5 -5
  63. package/dist/{source-candidate-scan-signature-CDrLxVKu.js → source-candidate-scan-signature-wieibgE7.js} +3 -3
  64. package/dist/{tailwindcss-ChnpCv25.js → tailwindcss-9xmoCkaR.js} +1 -1
  65. package/dist/{tailwindcss-CexDJBhx.cjs → tailwindcss-D3jltF7M.cjs} +763 -5
  66. package/dist/{transform-CL-UZW1U.cjs → transform-C6k9zTQR.cjs} +12 -4
  67. package/dist/{transform-Bfi1_VgN.js → transform-DQhgAarN.js} +12 -4
  68. package/dist/typedoc.export.d.ts +1 -0
  69. package/dist/types/index.d.ts +2 -0
  70. package/dist/uni-app-x/component-local-style.d.ts +2 -0
  71. package/dist/uni-app-x/transform.d.ts +1 -0
  72. package/dist/uni-app-x/vite/asset-task.d.ts +21 -0
  73. package/dist/uni-app-x/vite/plugin-options.d.ts +8 -0
  74. package/dist/uni-app-x/vite/web-local-style.d.ts +2 -1
  75. package/dist/uni-app-x/vite.d.ts +1 -21
  76. package/dist/{v4-generation-core-Dhsu9Deu.cjs → v4-generation-core-BhYkeoZ4.cjs} +378 -300
  77. package/dist/{vite-DMX5zoID.cjs → vite-B0cvyfSY.cjs} +807 -200
  78. package/dist/{vite-DJkhb8n1.js → vite-Fu6GTjIY.js} +774 -165
  79. package/dist/vite.cjs +1 -1
  80. package/dist/vite.js +1 -1
  81. package/dist/weapp-tw-css-generation-loader.cjs +1 -1
  82. package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
  83. package/dist/{webpack-Cpy_yggg.cjs → webpack-Amn5lmnx.cjs} +33 -35
  84. package/dist/{webpack-CzhrD9p3.js → webpack-BKHO-WSM.js} +10 -10
  85. package/dist/webpack.cjs +1 -1
  86. package/dist/webpack.js +1 -1
  87. package/dist/wxml/utils.d.ts +1 -1
  88. package/dist/{wxml-B7OAVpXJ.js → wxml-CvKyV69S.js} +10 -2
  89. package/dist/{wxml-PrK-8ARX.cjs → wxml-o-CUulAM.cjs} +40 -32
  90. package/package.json +12 -11
  91. package/dist/options-BJrtIQbH.cjs +0 -768
  92. package/dist/style-options-DW30H5PV.cjs +0 -82
@@ -1,768 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
- const require_generator = require("./generator-DKiYbTFR.cjs");
3
- let node_fs = require("node:fs");
4
- let node_path = require("node:path");
5
- node_path = require_rolldown_runtime.__toESM(node_path, 1);
6
- let node_process = require("node:process");
7
- node_process = require_rolldown_runtime.__toESM(node_process, 1);
8
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
9
- let node_fs_promises = require("node:fs/promises");
10
- let fast_glob = require("fast-glob");
11
- fast_glob = require_rolldown_runtime.__toESM(fast_glob, 1);
12
- let tailwindcss_config = require("tailwindcss-config");
13
- //#region src/tailwindcss/source-scan/inline-source.ts
14
- const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
15
- function segmentTopLevel(input, separator, options = {}) {
16
- const parts = [];
17
- const stack = [];
18
- let lastPos = 0;
19
- let quote;
20
- for (let index = 0; index < input.length; index++) {
21
- const char = input[index];
22
- if (char === "\\") {
23
- index += 1;
24
- continue;
25
- }
26
- if (quote) {
27
- if (char === quote) quote = void 0;
28
- continue;
29
- }
30
- if (char === "\"" || char === "'") {
31
- quote = char;
32
- continue;
33
- }
34
- if (char === "(") {
35
- stack.push(")");
36
- continue;
37
- }
38
- if (char === "[") {
39
- stack.push("]");
40
- continue;
41
- }
42
- if (char === "{") {
43
- stack.push("}");
44
- continue;
45
- }
46
- if (stack.length > 0 && char === stack[stack.length - 1]) {
47
- stack.pop();
48
- continue;
49
- }
50
- if (stack.length === 0 && char === separator) {
51
- const part = input.slice(lastPos, index);
52
- if (part || options.keepEmpty) parts.push(part);
53
- lastPos = index + 1;
54
- }
55
- }
56
- const part = input.slice(lastPos);
57
- if (part || options.keepEmpty) parts.push(part);
58
- return parts;
59
- }
60
- function isSequence(value) {
61
- return NUMERICAL_RANGE_RE.test(value);
62
- }
63
- function expandSequence(value) {
64
- const match = value.match(NUMERICAL_RANGE_RE);
65
- if (!match) return [value];
66
- const [, start, end, stepValue] = match;
67
- if (start === void 0 || end === void 0) return [value];
68
- let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
69
- const startNumber = Number.parseInt(start, 10);
70
- const endNumber = Number.parseInt(end, 10);
71
- const increasing = startNumber < endNumber;
72
- if (step === void 0) step = increasing ? 1 : -1;
73
- if (step === 0) return [];
74
- if (increasing && step < 0) step = -step;
75
- if (!increasing && step > 0) step = -step;
76
- const result = [];
77
- for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
78
- return result;
79
- }
80
- function expandInlineSourceCandidatePattern(pattern) {
81
- const index = pattern.indexOf("{");
82
- if (index === -1) return [pattern];
83
- const prefix = pattern.slice(0, index);
84
- const rest = pattern.slice(index);
85
- let depth = 0;
86
- let endIndex = -1;
87
- for (let index = 0; index < rest.length; index++) {
88
- const char = rest[index];
89
- if (char === "{") depth += 1;
90
- else if (char === "}") {
91
- depth -= 1;
92
- if (depth === 0) {
93
- endIndex = index;
94
- break;
95
- }
96
- }
97
- }
98
- if (endIndex === -1) return [pattern];
99
- const inner = rest.slice(1, endIndex);
100
- const suffix = rest.slice(endIndex + 1);
101
- const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
102
- return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
103
- }
104
- function parseSourceInlineParam(params) {
105
- let value = params.trim();
106
- const negated = value.startsWith("not ");
107
- if (negated) value = value.slice(4).trim();
108
- if (!value.startsWith("inline(") || !value.endsWith(")")) return;
109
- const inlineValue = value.slice(7, -1).trim();
110
- const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
111
- if (!match) return;
112
- const source = match[2];
113
- if (source === void 0) return;
114
- return {
115
- negated,
116
- source
117
- };
118
- }
119
- function collectCssInlineSourceCandidates(root) {
120
- const included = /* @__PURE__ */ new Set();
121
- const excluded = /* @__PURE__ */ new Set();
122
- root.walkAtRules("source", (rule) => {
123
- const parsed = parseSourceInlineParam(rule.params);
124
- if (!parsed) return;
125
- const target = parsed.negated ? excluded : included;
126
- for (const source of segmentTopLevel(parsed.source, " ")) {
127
- const trimmed = source.trim();
128
- if (!trimmed) continue;
129
- for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
130
- const normalized = candidate.trim();
131
- if (normalized) target.add(normalized);
132
- }
133
- }
134
- });
135
- for (const candidate of excluded) included.delete(candidate);
136
- return {
137
- included,
138
- excluded
139
- };
140
- }
141
- //#endregion
142
- //#region src/tailwindcss/v4/preflight.ts
143
- function parseCssImportSpecifier(params) {
144
- const value = params.trim();
145
- const quoted = /^(['"])(.*?)\1/.exec(value);
146
- if (quoted) return quoted[2];
147
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
148
- return url?.[2] ?? url?.[3];
149
- }
150
- function normalizeTailwindImportSpecifier(params) {
151
- return parseCssImportSpecifier(params)?.replaceAll("\\", "/");
152
- }
153
- function isTailwindV4CssImportParam(params) {
154
- const specifier = normalizeTailwindImportSpecifier(params);
155
- return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier?.startsWith("tailwindcss/") === true || specifier?.startsWith("tailwindcss4/") === true || specifier?.endsWith("/tailwindcss/index.css") === true;
156
- }
157
- function isTailwindV4PreflightImportParam(params) {
158
- const specifier = normalizeTailwindImportSpecifier(params);
159
- return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier === "tailwindcss/preflight" || specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss4/preflight" || specifier === "tailwindcss4/preflight.css" || specifier?.endsWith("/tailwindcss/index.css") === true || specifier?.endsWith("/tailwindcss/preflight.css") === true;
160
- }
161
- function includesTailwindV4PreflightDirective(css) {
162
- try {
163
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
164
- let includesPreflight = false;
165
- root.walkAtRules("import", (rule) => {
166
- includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
167
- });
168
- root.walkAtRules("tailwind", (rule) => {
169
- includesPreflight || (includesPreflight = rule.params.trim() === "base");
170
- });
171
- return includesPreflight;
172
- } catch {
173
- return /@import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/(?:preflight(?:\.css)?|index\.css))?["')\s;]/.test(css) || /@tailwind\s+base\b/.test(css);
174
- }
175
- }
176
- //#endregion
177
- //#region src/bundlers/shared/static-config-content.ts
178
- function skipWhitespaceAndComments(source, start) {
179
- let index = start;
180
- while (index < source.length) {
181
- const char = source[index];
182
- if (/\s/.test(char ?? "")) {
183
- index += 1;
184
- continue;
185
- }
186
- if (char === "/" && source[index + 1] === "/") {
187
- index += 2;
188
- while (index < source.length && source[index] !== "\n") index += 1;
189
- continue;
190
- }
191
- if (char === "/" && source[index + 1] === "*") {
192
- index += 2;
193
- while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
194
- index = Math.min(index + 2, source.length);
195
- continue;
196
- }
197
- break;
198
- }
199
- return index;
200
- }
201
- function readQuotedString(source, start) {
202
- const quote = source[start];
203
- if (quote !== "\"" && quote !== "'") return;
204
- let value = "";
205
- for (let index = start + 1; index < source.length; index++) {
206
- const char = source[index];
207
- if (char === "\\") {
208
- const next = source[index + 1];
209
- if (next === void 0) return;
210
- value += next;
211
- index += 1;
212
- continue;
213
- }
214
- if (char === quote) return {
215
- end: index + 1,
216
- value
217
- };
218
- value += char;
219
- }
220
- }
221
- function readIdentifier(source, start) {
222
- return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
223
- }
224
- function findMatchingBracket(source, start, open, close) {
225
- let depth = 0;
226
- let quote;
227
- for (let index = start; index < source.length; index++) {
228
- const char = source[index];
229
- if (char === "\\") {
230
- index += 1;
231
- continue;
232
- }
233
- if (quote) {
234
- if (char === quote) quote = void 0;
235
- continue;
236
- }
237
- if (char === "\"" || char === "'") {
238
- quote = char;
239
- continue;
240
- }
241
- if (char === "`") return;
242
- if (char === open) {
243
- depth += 1;
244
- continue;
245
- }
246
- if (char === close) {
247
- depth -= 1;
248
- if (depth === 0) return index;
249
- }
250
- }
251
- }
252
- function findContentPropertyValue(source) {
253
- let index = 0;
254
- while (index < source.length) {
255
- const nextIndex = source.indexOf("content", index);
256
- if (nextIndex === -1) return;
257
- const previous = source[nextIndex - 1];
258
- const next = source[nextIndex + 7];
259
- if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
260
- index = nextIndex + 7;
261
- continue;
262
- }
263
- let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
264
- if (source[colonIndex] !== ":") {
265
- index = nextIndex + 7;
266
- continue;
267
- }
268
- colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
269
- return { start: colonIndex };
270
- }
271
- }
272
- function parseStaticContentArray(source, start) {
273
- if (source[start] !== "[") return;
274
- const value = [];
275
- let index = skipWhitespaceAndComments(source, start + 1);
276
- while (index < source.length) {
277
- if (source[index] === "]") return {
278
- end: index + 1,
279
- value
280
- };
281
- const parsed = parseStaticContentValue(source, index);
282
- if (!parsed) return;
283
- value.push(parsed.value);
284
- index = skipWhitespaceAndComments(source, parsed.end);
285
- if (source[index] === ",") {
286
- index = skipWhitespaceAndComments(source, index + 1);
287
- continue;
288
- }
289
- if (source[index] === "]") continue;
290
- return;
291
- }
292
- }
293
- function parseStaticContentObject(source, start) {
294
- if (source[start] !== "{") return;
295
- const end = findMatchingBracket(source, start, "{", "}");
296
- if (end === void 0) return;
297
- let index = skipWhitespaceAndComments(source, start + 1);
298
- let files;
299
- while (index < end) {
300
- let key;
301
- const quotedKey = readQuotedString(source, index);
302
- if (quotedKey) {
303
- key = quotedKey.value;
304
- index = quotedKey.end;
305
- } else {
306
- key = readIdentifier(source, index);
307
- if (!key) return;
308
- index += key.length;
309
- }
310
- index = skipWhitespaceAndComments(source, index);
311
- if (source[index] !== ":") return;
312
- index = skipWhitespaceAndComments(source, index + 1);
313
- const parsedValue = parseStaticContentValue(source, index);
314
- if (!parsedValue) return;
315
- if (key === "files") files = parsedValue.value;
316
- index = skipWhitespaceAndComments(source, parsedValue.end);
317
- if (source[index] === ",") {
318
- index = skipWhitespaceAndComments(source, index + 1);
319
- continue;
320
- }
321
- if (index < end) return;
322
- }
323
- return files === void 0 ? void 0 : {
324
- end: end + 1,
325
- value: { files }
326
- };
327
- }
328
- function parseStaticContentValue(source, start) {
329
- const index = skipWhitespaceAndComments(source, start);
330
- const quoted = readQuotedString(source, index);
331
- if (quoted) return quoted;
332
- if (source[index] === "[") return parseStaticContentArray(source, index);
333
- if (source[index] === "{") return parseStaticContentObject(source, index);
334
- }
335
- function readStaticConfigContent(configPath) {
336
- let source;
337
- try {
338
- source = (0, node_fs.readFileSync)(configPath, "utf8");
339
- } catch {
340
- return;
341
- }
342
- const contentProperty = findContentPropertyValue(source);
343
- if (!contentProperty) return;
344
- return parseStaticContentValue(source, contentProperty.start)?.value;
345
- }
346
- //#endregion
347
- //#region src/bundlers/shared/source-scan/css-entries.ts
348
- const SOURCE_CANDIDATE_PATTERN = require_generator.FULL_SOURCE_SCAN_PATTERN;
349
- const TAILWIND_CSS_ENTRY_PATTERN = "**/*.css";
350
- const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
351
- function parseImportSourceParam(params) {
352
- const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
353
- if (!match) return;
354
- return {
355
- none: match[1] === "none",
356
- sourcePath: match[3]
357
- };
358
- }
359
- function resolveSourceBase(base, sourcePath) {
360
- return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
361
- }
362
- function resolveConfigPath(base, configPath) {
363
- if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
364
- return node_path.default.resolve(base, configPath);
365
- }
366
- function createCssEntriesCacheKey(css, base, dependencies) {
367
- return JSON.stringify({
368
- base: node_path.default.resolve(base),
369
- css,
370
- dependencies
371
- });
372
- }
373
- async function statConfigDependency(file) {
374
- try {
375
- const stats = await (0, node_fs_promises.stat)(file);
376
- return {
377
- file,
378
- mtimeMs: stats.mtimeMs,
379
- size: stats.size
380
- };
381
- } catch {
382
- return {
383
- file,
384
- mtimeMs: -1,
385
- size: -1
386
- };
387
- }
388
- }
389
- async function collectConfigDependencySignatures(root, base) {
390
- const configPaths = /* @__PURE__ */ new Set();
391
- root.walkAtRules("config", (rule) => {
392
- const configPath = require_generator.parseConfigParam(rule.params);
393
- if (configPath) configPaths.add(resolveConfigPath(base, configPath));
394
- });
395
- return Promise.all([...configPaths].sort().map(statConfigDependency));
396
- }
397
- function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
398
- const merged = {
399
- included: /* @__PURE__ */ new Set(),
400
- excluded: /* @__PURE__ */ new Set()
401
- };
402
- for (const inlineCandidates of allInlineCandidates) {
403
- if (!inlineCandidates) continue;
404
- for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
405
- for (const candidate of inlineCandidates.excluded) {
406
- merged.excluded.add(candidate);
407
- merged.included.delete(candidate);
408
- }
409
- }
410
- return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
411
- }
412
- async function resolveConfigContentEntries(root, base) {
413
- const configPaths = /* @__PURE__ */ new Set();
414
- root.walkAtRules("config", (rule) => {
415
- const configPath = require_generator.parseConfigParam(rule.params);
416
- if (configPath) configPaths.add(resolveConfigPath(base, configPath));
417
- });
418
- const entries = [];
419
- for (const configPath of configPaths) {
420
- const staticContent = readStaticConfigContent(configPath);
421
- if (staticContent !== void 0) {
422
- entries.push(...require_generator.normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
423
- continue;
424
- }
425
- try {
426
- const loaded = await (0, tailwindcss_config.loadConfig)({
427
- config: configPath,
428
- cwd: node_path.default.dirname(configPath)
429
- });
430
- entries.push(...require_generator.normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
431
- } catch {}
432
- }
433
- return {
434
- dependencies: [...configPaths],
435
- entries
436
- };
437
- }
438
- async function resolveTailwindV4EntriesFromCss(css, base) {
439
- let root;
440
- try {
441
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
442
- } catch {
443
- return;
444
- }
445
- let importSourceBase;
446
- let hasSourceNone = false;
447
- let hasTailwindCssImport = false;
448
- let includesPreflight = false;
449
- const [sourceEntries, configEntries] = await Promise.all([require_generator.resolveCssSourceEntries(root, base, SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
450
- const entries = [...configEntries.entries, ...sourceEntries];
451
- const hasPositiveEntries = entries.some((entry) => !entry.negated);
452
- const inlineCandidates = collectCssInlineSourceCandidates(root);
453
- root.walkAtRules("import", (rule) => {
454
- if (!isTailwindV4CssImportParam(rule.params)) return;
455
- hasTailwindCssImport = true;
456
- includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
457
- const sourceParam = parseImportSourceParam(rule.params);
458
- if (sourceParam?.none) hasSourceNone = true;
459
- if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
460
- });
461
- root.walkAtRules("tailwind", (rule) => {
462
- includesPreflight || (includesPreflight = rule.params.trim() === "base");
463
- });
464
- if (importSourceBase) return {
465
- entries: [{
466
- base: importSourceBase,
467
- negated: false,
468
- pattern: SOURCE_CANDIDATE_PATTERN
469
- }, ...entries],
470
- explicit: true,
471
- includesPreflight,
472
- inlineCandidates,
473
- dependencies: configEntries.dependencies
474
- };
475
- if (hasSourceNone) return {
476
- entries,
477
- explicit: true,
478
- includesPreflight,
479
- inlineCandidates,
480
- dependencies: configEntries.dependencies
481
- };
482
- if (hasPositiveEntries) return {
483
- entries,
484
- explicit: true,
485
- includesPreflight,
486
- inlineCandidates,
487
- dependencies: configEntries.dependencies
488
- };
489
- if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
490
- entries: [],
491
- explicit: true,
492
- includesPreflight,
493
- inlineCandidates,
494
- dependencies: configEntries.dependencies
495
- };
496
- return hasTailwindCssImport ? {
497
- entries,
498
- explicit: false,
499
- includesPreflight,
500
- inlineCandidates,
501
- dependencies: configEntries.dependencies
502
- } : void 0;
503
- }
504
- async function resolveTailwindV4CssDependencies(css, base) {
505
- return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
506
- }
507
- function collectExistingCssEntries(options) {
508
- return [
509
- ...options.cssEntries ?? [],
510
- ...options.tailwindcss?.v4?.cssEntries ?? [],
511
- ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
512
- ].filter((item) => typeof item === "string" && item.length > 0).filter(require_generator.isTailwindV4CssEntry).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
513
- }
514
- async function pathExistsAsFile(file) {
515
- try {
516
- return (await (0, node_fs_promises.stat)(file)).isFile();
517
- } catch {
518
- return false;
519
- }
520
- }
521
- async function resolveTailwindV4EntriesFromCssCached(css, base) {
522
- let root;
523
- try {
524
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
525
- } catch {
526
- return;
527
- }
528
- const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
529
- const cached = tailwindV4CssEntriesCache.get(cacheKey);
530
- if (cached) return cached;
531
- const task = resolveTailwindV4EntriesFromCss(css, base).catch((error) => {
532
- tailwindV4CssEntriesCache.delete(cacheKey);
533
- throw error;
534
- });
535
- tailwindV4CssEntriesCache.set(cacheKey, task);
536
- return task;
537
- }
538
- async function discoverTailwindV4CssEntries(root, outDir) {
539
- const resolvedRoot = node_path.default.resolve(root);
540
- const ignore = ["**/node_modules/**", "**/.git/**"];
541
- const resolvedOutDir = outDir ? node_path.default.resolve(resolvedRoot, outDir) : void 0;
542
- if (resolvedOutDir) {
543
- const relativeOutDir = node_path.default.relative(resolvedRoot, resolvedOutDir);
544
- if (relativeOutDir && !relativeOutDir.startsWith("..") && !node_path.default.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(node_path.default.sep).join("/")}/**`);
545
- }
546
- const candidates = await (0, fast_glob.default)(TAILWIND_CSS_ENTRY_PATTERN, {
547
- absolute: true,
548
- cwd: resolvedRoot,
549
- ignore,
550
- onlyFiles: true,
551
- unique: true
552
- });
553
- const entries = [];
554
- for (const file of candidates) {
555
- if (!await pathExistsAsFile(file)) continue;
556
- try {
557
- const css = (0, node_fs.readFileSync)(file, "utf8");
558
- if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
559
- if (await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(file))) entries.push(file);
560
- }
561
- } catch {}
562
- }
563
- return entries;
564
- }
565
- function collectConfiguredCssSources(options) {
566
- return require_generator.filterTailwindV4CssSourceRoots([...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? []]) ?? [];
567
- }
568
- //#endregion
569
- //#region src/bundlers/shared/source-scan/dependencies.ts
570
- function addSourceScanDependency(dependencies, file) {
571
- if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
572
- }
573
- function addSourceScanDependencies(dependencies, files) {
574
- for (const file of files ?? []) addSourceScanDependency(dependencies, file);
575
- }
576
- //#endregion
577
- //#region src/bundlers/shared/source-scan.ts
578
- function createResolvedSourceScan(input, dependencies) {
579
- return {
580
- ...input,
581
- ...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
582
- };
583
- }
584
- function createMergedCssEntrySourceScanEntries(entries, options) {
585
- if (options.sourceCount <= 1) return entries;
586
- const positiveEntries = entries.filter((entry) => !entry.negated);
587
- return positiveEntries.length > 0 ? positiveEntries : entries;
588
- }
589
- function resolveExplicitSourceScanEntries(entries, explicit) {
590
- if (!explicit) return entries.length > 0 ? entries : void 0;
591
- return entries.some((entry) => !entry.negated) ? entries : [];
592
- }
593
- function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
594
- return {
595
- entries: resolveExplicitSourceScanEntries(entries, explicit),
596
- explicit,
597
- inlineCandidates
598
- };
599
- }
600
- async function resolveSourceScanEntries(options, runtime, scanOptions = {}) {
601
- const sourceOptions = require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtime);
602
- const configuredSourceEntries = sourceOptions.sources ?? [];
603
- const cssEntries = collectExistingCssEntries(options);
604
- if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
605
- const scanRoot = scanOptions.root;
606
- const sourceProjectRoot = sourceOptions.projectRoot;
607
- if (scanRoot && sourceProjectRoot && node_path.default.resolve(scanRoot) === node_path.default.resolve(sourceProjectRoot)) {
608
- const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
609
- cssEntries.push(...discoveredCssEntries);
610
- }
611
- }
612
- const entries = [];
613
- const cssInlineCandidates = [];
614
- const dependencies = /* @__PURE__ */ new Set();
615
- let explicit = configuredSourceEntries.length > 0;
616
- let readableCssEntryCount = 0;
617
- for (const cssEntry of cssEntries) {
618
- addSourceScanDependency(dependencies, cssEntry);
619
- let css;
620
- try {
621
- css = (0, node_fs.readFileSync)(cssEntry, "utf8");
622
- } catch {
623
- continue;
624
- }
625
- readableCssEntryCount++;
626
- const resolved = await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
627
- if (resolved) {
628
- entries.push(...resolved.entries);
629
- cssInlineCandidates.push(resolved.inlineCandidates);
630
- addSourceScanDependencies(dependencies, resolved.dependencies);
631
- explicit || (explicit = resolved.explicit);
632
- }
633
- }
634
- const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
635
- const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
636
- if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedSourceScan({
637
- entries: resolveExplicitSourceScanEntries([...configuredSourceEntries, ...scanEntries], explicit),
638
- explicit,
639
- inlineCandidates
640
- }, dependencies);
641
- if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
642
- const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
643
- return resolved ? createResolvedSourceScan(createResolvedV4CssScanInput([...configuredSourceEntries, ...resolved.entries], resolved.inlineCandidates, explicit || resolved.explicit), new Set(resolved.dependencies)) : void 0;
644
- }
645
- const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
646
- const configuredCssSources = collectConfiguredCssSources(options);
647
- for (const cssSource of [...configuredCssSources, ...sourceOptions.cssSources ?? []]) {
648
- if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
649
- addSourceScanDependency(dependencies, cssSource.file);
650
- addSourceScanDependencies(dependencies, cssSource.dependencies);
651
- const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
652
- if (resolved) {
653
- entries.push(...resolved.entries);
654
- cssInlineCandidates.push(resolved.inlineCandidates);
655
- addSourceScanDependencies(dependencies, resolved.dependencies);
656
- explicit || (explicit = resolved.explicit);
657
- }
658
- }
659
- const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
660
- const cssSourceCount = (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length;
661
- const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: cssSourceCount });
662
- if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit) return createResolvedSourceScan({
663
- entries: resolveExplicitSourceScanEntries([...configuredSourceEntries, ...cssSourceScanEntries], explicit),
664
- explicit,
665
- inlineCandidates: cssSourceInlineCandidates
666
- }, dependencies);
667
- if (cssSourceCount > 0) return;
668
- const source = await require_generator.resolveTailwindV4SourceFromRuntime(runtime);
669
- addSourceScanDependency(dependencies, source.file);
670
- addSourceScanDependencies(dependencies, source.dependencies);
671
- const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
672
- return resolved ? createResolvedSourceScan(createResolvedV4CssScanInput(resolved.entries.length > 0 ? [...configuredSourceEntries, ...resolved.entries] : configuredSourceEntries, resolved.inlineCandidates, explicit || (resolved.entries.length > 0 ? resolved.explicit : false)), /* @__PURE__ */ new Set([...dependencies, ...resolved.dependencies])) : void 0;
673
- }
674
- //#endregion
675
- //#region src/uni-app-x/options.ts
676
- const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
677
- enabled: true,
678
- onlyWhenStyleIsolationVersion2: true
679
- };
680
- const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
681
- enabled: false,
682
- onlyWhenStyleIsolationVersion2: true
683
- };
684
- function isBooleanUniAppXShortcut(option) {
685
- return option === true || option === false || option === void 0;
686
- }
687
- function resolveComponentLocalStyles(option) {
688
- if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
689
- const componentLocalStyles = option.componentLocalStyles;
690
- if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
691
- if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
692
- return {
693
- ...componentLocalStyles.componentMatcher ? { componentMatcher: componentLocalStyles.componentMatcher } : {},
694
- enabled: componentLocalStyles.enabled !== false,
695
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false,
696
- ...componentLocalStyles.pageMatcher ? { pageMatcher: componentLocalStyles.pageMatcher } : {}
697
- };
698
- }
699
- function resolveUniAppXOptions(option) {
700
- if (typeof option === "object" && option) return {
701
- enabled: option.enabled !== false,
702
- componentLocalStyles: resolveComponentLocalStyles(option),
703
- uvueUnsupported: option.uvueUnsupported ?? "warn"
704
- };
705
- return {
706
- enabled: Boolean(option),
707
- componentLocalStyles: resolveComponentLocalStyles(option),
708
- uvueUnsupported: "warn"
709
- };
710
- }
711
- function isUniAppXEnabled(option) {
712
- return resolveUniAppXOptions(option).enabled;
713
- }
714
- //#endregion
715
- Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
716
- enumerable: true,
717
- get: function() {
718
- return collectCssInlineSourceCandidates;
719
- }
720
- });
721
- Object.defineProperty(exports, "discoverTailwindV4CssEntries", {
722
- enumerable: true,
723
- get: function() {
724
- return discoverTailwindV4CssEntries;
725
- }
726
- });
727
- Object.defineProperty(exports, "includesTailwindV4PreflightDirective", {
728
- enumerable: true,
729
- get: function() {
730
- return includesTailwindV4PreflightDirective;
731
- }
732
- });
733
- Object.defineProperty(exports, "isUniAppXEnabled", {
734
- enumerable: true,
735
- get: function() {
736
- return isUniAppXEnabled;
737
- }
738
- });
739
- Object.defineProperty(exports, "resolveSourceScanEntries", {
740
- enumerable: true,
741
- get: function() {
742
- return resolveSourceScanEntries;
743
- }
744
- });
745
- Object.defineProperty(exports, "resolveTailwindV4CssDependencies", {
746
- enumerable: true,
747
- get: function() {
748
- return resolveTailwindV4CssDependencies;
749
- }
750
- });
751
- Object.defineProperty(exports, "resolveTailwindV4EntriesFromCss", {
752
- enumerable: true,
753
- get: function() {
754
- return resolveTailwindV4EntriesFromCss;
755
- }
756
- });
757
- Object.defineProperty(exports, "resolveTailwindV4EntriesFromCssCached", {
758
- enumerable: true,
759
- get: function() {
760
- return resolveTailwindV4EntriesFromCssCached;
761
- }
762
- });
763
- Object.defineProperty(exports, "resolveUniAppXOptions", {
764
- enumerable: true,
765
- get: function() {
766
- return resolveUniAppXOptions;
767
- }
768
- });