weapp-tailwindcss 5.3.6 → 5.4.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.
- package/README.md +3 -3
- package/README.zh-CN.md +4 -4
- package/dist/bundlers/shared/framework-postcss.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +3 -1
- package/dist/bundlers/shared/source-candidates/snapshot.d.ts +19 -0
- package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/views.d.ts +12 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +9 -1
- package/dist/bundlers/vite/capability-profile.d.ts +18 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +12 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +2 -2
- package/dist/bundlers/vite/shared/configured-css-entry-observer.d.ts +29 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -0
- package/dist/bundlers/vite/shared/framework-css-generation-queue.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-hmr-module-version.d.ts +9 -0
- package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +5 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +12 -2
- package/dist/compiler/compilation-session-pool.d.ts +1 -0
- package/dist/compiler/framework-compiler-session.d.ts +21 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/{context-DTLRADfE.cjs → compiler-C93NfxSe.cjs} +859 -11
- package/dist/{context-4ittVpgt.js → compiler-qDa3phIv.js} +764 -5
- package/dist/context/handlers.d.ts +1 -1
- package/dist/core/compiler/compiler.d.ts +2 -0
- package/dist/core/compiler/generation-cache.d.ts +30 -0
- package/dist/core/compiler/generation-state.d.ts +17 -0
- package/dist/core/compiler/index.d.ts +2 -0
- package/dist/core/compiler/root-store.d.ts +38 -0
- package/dist/core/compiler/snapshot.d.ts +35 -0
- package/dist/core/compiler/source-fingerprint.d.ts +3 -0
- package/dist/core/compiler/transforms.d.ts +15 -0
- package/dist/core/compiler/types.d.ts +69 -0
- package/dist/core.cjs +9 -8
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -2
- package/dist/framework/index.d.ts +3 -1
- package/dist/framework.cjs +6 -1
- package/dist/framework.js +6 -1
- package/dist/{generator-EnTXLBlK.js → generator-C0m2S4WI.js} +3 -2
- package/dist/{generator-DKiYbTFR.cjs → generator-CKJ6sj1f.cjs} +3 -2
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-CUysZjW3.cjs → gulp-CW6JGqVn.cjs} +14 -16
- package/dist/{gulp-DwtrU4V1.js → gulp-e2iWsmEK.js} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-utmOgn6p.js → hmr-timing-DgMgwSce.js} +367 -289
- package/dist/{hmr-timing-Cvh5UgnM.cjs → hmr-timing-n7QQKFp7.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CyVXL3h6.cjs → pipeline-helpers-DoLQy44Q.cjs} +6 -6
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -3
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{source-candidate-scan-signature-CDrLxVKu.js → source-candidate-scan-signature-B0lOMiwB.js} +3 -3
- package/dist/{source-candidate-scan-signature-BNt7NrrI.cjs → source-candidate-scan-signature-Chb-Zrwt.cjs} +5 -5
- package/dist/{tailwindcss-CexDJBhx.cjs → tailwindcss-BGlJ1m1l.cjs} +763 -5
- package/dist/{tailwindcss-ChnpCv25.js → tailwindcss-BSKl0FTD.js} +1 -1
- package/dist/{transform-CL-UZW1U.cjs → transform-C6k9zTQR.cjs} +12 -4
- package/dist/{transform-Bfi1_VgN.js → transform-DQhgAarN.js} +12 -4
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/uni-app-x/component-local-style.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite/asset-task.d.ts +21 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +8 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +2 -1
- package/dist/uni-app-x/vite.d.ts +1 -21
- package/dist/{v4-generation-core-Dhsu9Deu.cjs → v4-generation-core-B2sUkkgq.cjs} +378 -300
- package/dist/{vite-DMX5zoID.cjs → vite-B0IPgrvM.cjs} +807 -200
- package/dist/{vite-DJkhb8n1.js → vite-CcEb2SOl.js} +774 -165
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
- package/dist/{webpack-Cpy_yggg.cjs → webpack-B5vc13U_.cjs} +33 -35
- package/dist/{webpack-CzhrD9p3.js → webpack-BPA5I79o.js} +7 -7
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/wxml/utils.d.ts +1 -1
- package/dist/{wxml-B7OAVpXJ.js → wxml-CvKyV69S.js} +10 -2
- package/dist/{wxml-PrK-8ARX.cjs → wxml-o-CUulAM.cjs} +40 -32
- package/package.json +12 -11
- package/dist/options-BJrtIQbH.cjs +0 -768
- package/dist/style-options-DW30H5PV.cjs +0 -82
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-CKJ6sj1f.cjs");
|
|
3
3
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
4
|
-
const require_options = require("./options-BJrtIQbH.cjs");
|
|
5
4
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
5
|
let node_fs = require("node:fs");
|
|
7
6
|
let node_path = require("node:path");
|
|
@@ -11,9 +10,675 @@ node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
|
11
10
|
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
12
11
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
12
|
let node_module = require("node:module");
|
|
13
|
+
let node_fs_promises = require("node:fs/promises");
|
|
14
14
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
15
|
+
let fast_glob = require("fast-glob");
|
|
16
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob, 1);
|
|
17
|
+
let tailwindcss_config = require("tailwindcss-config");
|
|
15
18
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
16
19
|
let node_url = require("node:url");
|
|
20
|
+
//#region src/tailwindcss/source-scan/inline-source.ts
|
|
21
|
+
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
22
|
+
function segmentTopLevel(input, separator, options = {}) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
const stack = [];
|
|
25
|
+
let lastPos = 0;
|
|
26
|
+
let quote;
|
|
27
|
+
for (let index = 0; index < input.length; index++) {
|
|
28
|
+
const char = input[index];
|
|
29
|
+
if (char === "\\") {
|
|
30
|
+
index += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (quote) {
|
|
34
|
+
if (char === quote) quote = void 0;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (char === "\"" || char === "'") {
|
|
38
|
+
quote = char;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (char === "(") {
|
|
42
|
+
stack.push(")");
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (char === "[") {
|
|
46
|
+
stack.push("]");
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (char === "{") {
|
|
50
|
+
stack.push("}");
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (stack.length > 0 && char === stack[stack.length - 1]) {
|
|
54
|
+
stack.pop();
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (stack.length === 0 && char === separator) {
|
|
58
|
+
const part = input.slice(lastPos, index);
|
|
59
|
+
if (part || options.keepEmpty) parts.push(part);
|
|
60
|
+
lastPos = index + 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const part = input.slice(lastPos);
|
|
64
|
+
if (part || options.keepEmpty) parts.push(part);
|
|
65
|
+
return parts;
|
|
66
|
+
}
|
|
67
|
+
function isSequence(value) {
|
|
68
|
+
return NUMERICAL_RANGE_RE.test(value);
|
|
69
|
+
}
|
|
70
|
+
function expandSequence(value) {
|
|
71
|
+
const match = value.match(NUMERICAL_RANGE_RE);
|
|
72
|
+
if (!match) return [value];
|
|
73
|
+
const [, start, end, stepValue] = match;
|
|
74
|
+
if (start === void 0 || end === void 0) return [value];
|
|
75
|
+
let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
|
|
76
|
+
const startNumber = Number.parseInt(start, 10);
|
|
77
|
+
const endNumber = Number.parseInt(end, 10);
|
|
78
|
+
const increasing = startNumber < endNumber;
|
|
79
|
+
if (step === void 0) step = increasing ? 1 : -1;
|
|
80
|
+
if (step === 0) return [];
|
|
81
|
+
if (increasing && step < 0) step = -step;
|
|
82
|
+
if (!increasing && step > 0) step = -step;
|
|
83
|
+
const result = [];
|
|
84
|
+
for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function expandInlineSourceCandidatePattern(pattern) {
|
|
88
|
+
const index = pattern.indexOf("{");
|
|
89
|
+
if (index === -1) return [pattern];
|
|
90
|
+
const prefix = pattern.slice(0, index);
|
|
91
|
+
const rest = pattern.slice(index);
|
|
92
|
+
let depth = 0;
|
|
93
|
+
let endIndex = -1;
|
|
94
|
+
for (let index = 0; index < rest.length; index++) {
|
|
95
|
+
const char = rest[index];
|
|
96
|
+
if (char === "{") depth += 1;
|
|
97
|
+
else if (char === "}") {
|
|
98
|
+
depth -= 1;
|
|
99
|
+
if (depth === 0) {
|
|
100
|
+
endIndex = index;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (endIndex === -1) return [pattern];
|
|
106
|
+
const inner = rest.slice(1, endIndex);
|
|
107
|
+
const suffix = rest.slice(endIndex + 1);
|
|
108
|
+
const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
|
|
109
|
+
return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
|
|
110
|
+
}
|
|
111
|
+
function parseSourceInlineParam(params) {
|
|
112
|
+
let value = params.trim();
|
|
113
|
+
const negated = value.startsWith("not ");
|
|
114
|
+
if (negated) value = value.slice(4).trim();
|
|
115
|
+
if (!value.startsWith("inline(") || !value.endsWith(")")) return;
|
|
116
|
+
const inlineValue = value.slice(7, -1).trim();
|
|
117
|
+
const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
|
|
118
|
+
if (!match) return;
|
|
119
|
+
const source = match[2];
|
|
120
|
+
if (source === void 0) return;
|
|
121
|
+
return {
|
|
122
|
+
negated,
|
|
123
|
+
source
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function collectCssInlineSourceCandidates(root) {
|
|
127
|
+
const included = /* @__PURE__ */ new Set();
|
|
128
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
129
|
+
root.walkAtRules("source", (rule) => {
|
|
130
|
+
const parsed = parseSourceInlineParam(rule.params);
|
|
131
|
+
if (!parsed) return;
|
|
132
|
+
const target = parsed.negated ? excluded : included;
|
|
133
|
+
for (const source of segmentTopLevel(parsed.source, " ")) {
|
|
134
|
+
const trimmed = source.trim();
|
|
135
|
+
if (!trimmed) continue;
|
|
136
|
+
for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
|
|
137
|
+
const normalized = candidate.trim();
|
|
138
|
+
if (normalized) target.add(normalized);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
for (const candidate of excluded) included.delete(candidate);
|
|
143
|
+
return {
|
|
144
|
+
included,
|
|
145
|
+
excluded
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/tailwindcss/v4/preflight.ts
|
|
150
|
+
function parseCssImportSpecifier(params) {
|
|
151
|
+
const value = params.trim();
|
|
152
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
153
|
+
if (quoted) return quoted[2];
|
|
154
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
155
|
+
return url?.[2] ?? url?.[3];
|
|
156
|
+
}
|
|
157
|
+
function normalizeTailwindImportSpecifier(params) {
|
|
158
|
+
return parseCssImportSpecifier(params)?.replaceAll("\\", "/");
|
|
159
|
+
}
|
|
160
|
+
function isTailwindV4CssImportParam(params) {
|
|
161
|
+
const specifier = normalizeTailwindImportSpecifier(params);
|
|
162
|
+
return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier?.startsWith("tailwindcss/") === true || specifier?.startsWith("tailwindcss4/") === true || specifier?.endsWith("/tailwindcss/index.css") === true;
|
|
163
|
+
}
|
|
164
|
+
function isTailwindV4PreflightImportParam(params) {
|
|
165
|
+
const specifier = normalizeTailwindImportSpecifier(params);
|
|
166
|
+
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;
|
|
167
|
+
}
|
|
168
|
+
function includesTailwindV4PreflightDirective(css) {
|
|
169
|
+
try {
|
|
170
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
171
|
+
let includesPreflight = false;
|
|
172
|
+
root.walkAtRules("import", (rule) => {
|
|
173
|
+
includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
|
|
174
|
+
});
|
|
175
|
+
root.walkAtRules("tailwind", (rule) => {
|
|
176
|
+
includesPreflight || (includesPreflight = rule.params.trim() === "base");
|
|
177
|
+
});
|
|
178
|
+
return includesPreflight;
|
|
179
|
+
} catch {
|
|
180
|
+
return /@import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/(?:preflight(?:\.css)?|index\.css))?["')\s;]/.test(css) || /@tailwind\s+base\b/.test(css);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/bundlers/shared/static-config-content.ts
|
|
185
|
+
function skipWhitespaceAndComments(source, start) {
|
|
186
|
+
let index = start;
|
|
187
|
+
while (index < source.length) {
|
|
188
|
+
const char = source[index];
|
|
189
|
+
if (/\s/.test(char ?? "")) {
|
|
190
|
+
index += 1;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
194
|
+
index += 2;
|
|
195
|
+
while (index < source.length && source[index] !== "\n") index += 1;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
199
|
+
index += 2;
|
|
200
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
|
|
201
|
+
index = Math.min(index + 2, source.length);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
return index;
|
|
207
|
+
}
|
|
208
|
+
function readQuotedString(source, start) {
|
|
209
|
+
const quote = source[start];
|
|
210
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
211
|
+
let value = "";
|
|
212
|
+
for (let index = start + 1; index < source.length; index++) {
|
|
213
|
+
const char = source[index];
|
|
214
|
+
if (char === "\\") {
|
|
215
|
+
const next = source[index + 1];
|
|
216
|
+
if (next === void 0) return;
|
|
217
|
+
value += next;
|
|
218
|
+
index += 1;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (char === quote) return {
|
|
222
|
+
end: index + 1,
|
|
223
|
+
value
|
|
224
|
+
};
|
|
225
|
+
value += char;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function readIdentifier(source, start) {
|
|
229
|
+
return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
|
|
230
|
+
}
|
|
231
|
+
function findMatchingBracket(source, start, open, close) {
|
|
232
|
+
let depth = 0;
|
|
233
|
+
let quote;
|
|
234
|
+
for (let index = start; index < source.length; index++) {
|
|
235
|
+
const char = source[index];
|
|
236
|
+
if (char === "\\") {
|
|
237
|
+
index += 1;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (quote) {
|
|
241
|
+
if (char === quote) quote = void 0;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (char === "\"" || char === "'") {
|
|
245
|
+
quote = char;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (char === "`") return;
|
|
249
|
+
if (char === open) {
|
|
250
|
+
depth += 1;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (char === close) {
|
|
254
|
+
depth -= 1;
|
|
255
|
+
if (depth === 0) return index;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function findContentPropertyValue(source) {
|
|
260
|
+
let index = 0;
|
|
261
|
+
while (index < source.length) {
|
|
262
|
+
const nextIndex = source.indexOf("content", index);
|
|
263
|
+
if (nextIndex === -1) return;
|
|
264
|
+
const previous = source[nextIndex - 1];
|
|
265
|
+
const next = source[nextIndex + 7];
|
|
266
|
+
if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
|
|
267
|
+
index = nextIndex + 7;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
|
|
271
|
+
if (source[colonIndex] !== ":") {
|
|
272
|
+
index = nextIndex + 7;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
|
|
276
|
+
return { start: colonIndex };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function parseStaticContentArray(source, start) {
|
|
280
|
+
if (source[start] !== "[") return;
|
|
281
|
+
const value = [];
|
|
282
|
+
let index = skipWhitespaceAndComments(source, start + 1);
|
|
283
|
+
while (index < source.length) {
|
|
284
|
+
if (source[index] === "]") return {
|
|
285
|
+
end: index + 1,
|
|
286
|
+
value
|
|
287
|
+
};
|
|
288
|
+
const parsed = parseStaticContentValue(source, index);
|
|
289
|
+
if (!parsed) return;
|
|
290
|
+
value.push(parsed.value);
|
|
291
|
+
index = skipWhitespaceAndComments(source, parsed.end);
|
|
292
|
+
if (source[index] === ",") {
|
|
293
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (source[index] === "]") continue;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function parseStaticContentObject(source, start) {
|
|
301
|
+
if (source[start] !== "{") return;
|
|
302
|
+
const end = findMatchingBracket(source, start, "{", "}");
|
|
303
|
+
if (end === void 0) return;
|
|
304
|
+
let index = skipWhitespaceAndComments(source, start + 1);
|
|
305
|
+
let files;
|
|
306
|
+
while (index < end) {
|
|
307
|
+
let key;
|
|
308
|
+
const quotedKey = readQuotedString(source, index);
|
|
309
|
+
if (quotedKey) {
|
|
310
|
+
key = quotedKey.value;
|
|
311
|
+
index = quotedKey.end;
|
|
312
|
+
} else {
|
|
313
|
+
key = readIdentifier(source, index);
|
|
314
|
+
if (!key) return;
|
|
315
|
+
index += key.length;
|
|
316
|
+
}
|
|
317
|
+
index = skipWhitespaceAndComments(source, index);
|
|
318
|
+
if (source[index] !== ":") return;
|
|
319
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
320
|
+
const parsedValue = parseStaticContentValue(source, index);
|
|
321
|
+
if (!parsedValue) return;
|
|
322
|
+
if (key === "files") files = parsedValue.value;
|
|
323
|
+
index = skipWhitespaceAndComments(source, parsedValue.end);
|
|
324
|
+
if (source[index] === ",") {
|
|
325
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (index < end) return;
|
|
329
|
+
}
|
|
330
|
+
return files === void 0 ? void 0 : {
|
|
331
|
+
end: end + 1,
|
|
332
|
+
value: { files }
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function parseStaticContentValue(source, start) {
|
|
336
|
+
const index = skipWhitespaceAndComments(source, start);
|
|
337
|
+
const quoted = readQuotedString(source, index);
|
|
338
|
+
if (quoted) return quoted;
|
|
339
|
+
if (source[index] === "[") return parseStaticContentArray(source, index);
|
|
340
|
+
if (source[index] === "{") return parseStaticContentObject(source, index);
|
|
341
|
+
}
|
|
342
|
+
function readStaticConfigContent(configPath) {
|
|
343
|
+
let source;
|
|
344
|
+
try {
|
|
345
|
+
source = (0, node_fs.readFileSync)(configPath, "utf8");
|
|
346
|
+
} catch {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const contentProperty = findContentPropertyValue(source);
|
|
350
|
+
if (!contentProperty) return;
|
|
351
|
+
return parseStaticContentValue(source, contentProperty.start)?.value;
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/bundlers/shared/source-scan/css-entries.ts
|
|
355
|
+
const SOURCE_CANDIDATE_PATTERN = require_generator.FULL_SOURCE_SCAN_PATTERN;
|
|
356
|
+
const TAILWIND_CSS_ENTRY_PATTERN = "**/*.css";
|
|
357
|
+
const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
|
|
358
|
+
function parseImportSourceParam(params) {
|
|
359
|
+
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
360
|
+
if (!match) return;
|
|
361
|
+
return {
|
|
362
|
+
none: match[1] === "none",
|
|
363
|
+
sourcePath: match[3]
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function resolveSourceBase(base, sourcePath) {
|
|
367
|
+
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
368
|
+
}
|
|
369
|
+
function resolveConfigPath(base, configPath) {
|
|
370
|
+
if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
|
|
371
|
+
return node_path.default.resolve(base, configPath);
|
|
372
|
+
}
|
|
373
|
+
function createCssEntriesCacheKey(css, base, dependencies) {
|
|
374
|
+
return JSON.stringify({
|
|
375
|
+
base: node_path.default.resolve(base),
|
|
376
|
+
css,
|
|
377
|
+
dependencies
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
async function statConfigDependency(file) {
|
|
381
|
+
try {
|
|
382
|
+
const stats = await (0, node_fs_promises.stat)(file);
|
|
383
|
+
return {
|
|
384
|
+
file,
|
|
385
|
+
mtimeMs: stats.mtimeMs,
|
|
386
|
+
size: stats.size
|
|
387
|
+
};
|
|
388
|
+
} catch {
|
|
389
|
+
return {
|
|
390
|
+
file,
|
|
391
|
+
mtimeMs: -1,
|
|
392
|
+
size: -1
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async function collectConfigDependencySignatures(root, base) {
|
|
397
|
+
const configPaths = /* @__PURE__ */ new Set();
|
|
398
|
+
root.walkAtRules("config", (rule) => {
|
|
399
|
+
const configPath = require_generator.parseConfigParam(rule.params);
|
|
400
|
+
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
|
|
401
|
+
});
|
|
402
|
+
return Promise.all([...configPaths].sort().map(statConfigDependency));
|
|
403
|
+
}
|
|
404
|
+
function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
|
|
405
|
+
const merged = {
|
|
406
|
+
included: /* @__PURE__ */ new Set(),
|
|
407
|
+
excluded: /* @__PURE__ */ new Set()
|
|
408
|
+
};
|
|
409
|
+
for (const inlineCandidates of allInlineCandidates) {
|
|
410
|
+
if (!inlineCandidates) continue;
|
|
411
|
+
for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
|
|
412
|
+
for (const candidate of inlineCandidates.excluded) {
|
|
413
|
+
merged.excluded.add(candidate);
|
|
414
|
+
merged.included.delete(candidate);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
|
|
418
|
+
}
|
|
419
|
+
async function resolveConfigContentEntries(root, base) {
|
|
420
|
+
const configPaths = /* @__PURE__ */ new Set();
|
|
421
|
+
root.walkAtRules("config", (rule) => {
|
|
422
|
+
const configPath = require_generator.parseConfigParam(rule.params);
|
|
423
|
+
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
|
|
424
|
+
});
|
|
425
|
+
const entries = [];
|
|
426
|
+
for (const configPath of configPaths) {
|
|
427
|
+
const staticContent = readStaticConfigContent(configPath);
|
|
428
|
+
if (staticContent !== void 0) {
|
|
429
|
+
entries.push(...require_generator.normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const loaded = await (0, tailwindcss_config.loadConfig)({
|
|
434
|
+
config: configPath,
|
|
435
|
+
cwd: node_path.default.dirname(configPath)
|
|
436
|
+
});
|
|
437
|
+
entries.push(...require_generator.normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
|
|
438
|
+
} catch {}
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
dependencies: [...configPaths],
|
|
442
|
+
entries
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
446
|
+
let root;
|
|
447
|
+
try {
|
|
448
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
449
|
+
} catch {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
let importSourceBase;
|
|
453
|
+
let hasSourceNone = false;
|
|
454
|
+
let hasTailwindCssImport = false;
|
|
455
|
+
let includesPreflight = false;
|
|
456
|
+
const [sourceEntries, configEntries] = await Promise.all([require_generator.resolveCssSourceEntries(root, base, SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
457
|
+
const entries = [...configEntries.entries, ...sourceEntries];
|
|
458
|
+
const hasPositiveEntries = entries.some((entry) => !entry.negated);
|
|
459
|
+
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
460
|
+
root.walkAtRules("import", (rule) => {
|
|
461
|
+
if (!isTailwindV4CssImportParam(rule.params)) return;
|
|
462
|
+
hasTailwindCssImport = true;
|
|
463
|
+
includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
|
|
464
|
+
const sourceParam = parseImportSourceParam(rule.params);
|
|
465
|
+
if (sourceParam?.none) hasSourceNone = true;
|
|
466
|
+
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
|
|
467
|
+
});
|
|
468
|
+
root.walkAtRules("tailwind", (rule) => {
|
|
469
|
+
includesPreflight || (includesPreflight = rule.params.trim() === "base");
|
|
470
|
+
});
|
|
471
|
+
if (importSourceBase) return {
|
|
472
|
+
entries: [{
|
|
473
|
+
base: importSourceBase,
|
|
474
|
+
negated: false,
|
|
475
|
+
pattern: SOURCE_CANDIDATE_PATTERN
|
|
476
|
+
}, ...entries],
|
|
477
|
+
explicit: true,
|
|
478
|
+
includesPreflight,
|
|
479
|
+
inlineCandidates,
|
|
480
|
+
dependencies: configEntries.dependencies
|
|
481
|
+
};
|
|
482
|
+
if (hasSourceNone) return {
|
|
483
|
+
entries,
|
|
484
|
+
explicit: true,
|
|
485
|
+
includesPreflight,
|
|
486
|
+
inlineCandidates,
|
|
487
|
+
dependencies: configEntries.dependencies
|
|
488
|
+
};
|
|
489
|
+
if (hasPositiveEntries) return {
|
|
490
|
+
entries,
|
|
491
|
+
explicit: true,
|
|
492
|
+
includesPreflight,
|
|
493
|
+
inlineCandidates,
|
|
494
|
+
dependencies: configEntries.dependencies
|
|
495
|
+
};
|
|
496
|
+
if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
|
|
497
|
+
entries: [],
|
|
498
|
+
explicit: true,
|
|
499
|
+
includesPreflight,
|
|
500
|
+
inlineCandidates,
|
|
501
|
+
dependencies: configEntries.dependencies
|
|
502
|
+
};
|
|
503
|
+
return hasTailwindCssImport ? {
|
|
504
|
+
entries,
|
|
505
|
+
explicit: false,
|
|
506
|
+
includesPreflight,
|
|
507
|
+
inlineCandidates,
|
|
508
|
+
dependencies: configEntries.dependencies
|
|
509
|
+
} : void 0;
|
|
510
|
+
}
|
|
511
|
+
async function resolveTailwindV4CssDependencies(css, base) {
|
|
512
|
+
return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
|
|
513
|
+
}
|
|
514
|
+
function collectExistingCssEntries(options) {
|
|
515
|
+
return [
|
|
516
|
+
...options.cssEntries ?? [],
|
|
517
|
+
...options.tailwindcss?.v4?.cssEntries ?? [],
|
|
518
|
+
...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
519
|
+
].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));
|
|
520
|
+
}
|
|
521
|
+
async function pathExistsAsFile(file) {
|
|
522
|
+
try {
|
|
523
|
+
return (await (0, node_fs_promises.stat)(file)).isFile();
|
|
524
|
+
} catch {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
async function resolveTailwindV4EntriesFromCssCached(css, base) {
|
|
529
|
+
let root;
|
|
530
|
+
try {
|
|
531
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
532
|
+
} catch {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
|
|
536
|
+
const cached = tailwindV4CssEntriesCache.get(cacheKey);
|
|
537
|
+
if (cached) return cached;
|
|
538
|
+
const task = resolveTailwindV4EntriesFromCss(css, base).catch((error) => {
|
|
539
|
+
tailwindV4CssEntriesCache.delete(cacheKey);
|
|
540
|
+
throw error;
|
|
541
|
+
});
|
|
542
|
+
tailwindV4CssEntriesCache.set(cacheKey, task);
|
|
543
|
+
return task;
|
|
544
|
+
}
|
|
545
|
+
async function discoverTailwindV4CssEntries(root, outDir) {
|
|
546
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
547
|
+
const ignore = ["**/node_modules/**", "**/.git/**"];
|
|
548
|
+
const resolvedOutDir = outDir ? node_path.default.resolve(resolvedRoot, outDir) : void 0;
|
|
549
|
+
if (resolvedOutDir) {
|
|
550
|
+
const relativeOutDir = node_path.default.relative(resolvedRoot, resolvedOutDir);
|
|
551
|
+
if (relativeOutDir && !relativeOutDir.startsWith("..") && !node_path.default.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(node_path.default.sep).join("/")}/**`);
|
|
552
|
+
}
|
|
553
|
+
const candidates = await (0, fast_glob.default)(TAILWIND_CSS_ENTRY_PATTERN, {
|
|
554
|
+
absolute: true,
|
|
555
|
+
cwd: resolvedRoot,
|
|
556
|
+
ignore,
|
|
557
|
+
onlyFiles: true,
|
|
558
|
+
unique: true
|
|
559
|
+
});
|
|
560
|
+
const entries = [];
|
|
561
|
+
for (const file of candidates) {
|
|
562
|
+
if (!await pathExistsAsFile(file)) continue;
|
|
563
|
+
try {
|
|
564
|
+
const css = (0, node_fs.readFileSync)(file, "utf8");
|
|
565
|
+
if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
|
|
566
|
+
if (await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(file))) entries.push(file);
|
|
567
|
+
}
|
|
568
|
+
} catch {}
|
|
569
|
+
}
|
|
570
|
+
return entries;
|
|
571
|
+
}
|
|
572
|
+
function collectConfiguredCssSources(options) {
|
|
573
|
+
return require_generator.filterTailwindV4CssSourceRoots([...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? []]) ?? [];
|
|
574
|
+
}
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/bundlers/shared/source-scan/dependencies.ts
|
|
577
|
+
function addSourceScanDependency(dependencies, file) {
|
|
578
|
+
if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
|
|
579
|
+
}
|
|
580
|
+
function addSourceScanDependencies(dependencies, files) {
|
|
581
|
+
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
|
|
582
|
+
}
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/bundlers/shared/source-scan.ts
|
|
585
|
+
function createResolvedSourceScan(input, dependencies) {
|
|
586
|
+
return {
|
|
587
|
+
...input,
|
|
588
|
+
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
592
|
+
if (options.sourceCount <= 1) return entries;
|
|
593
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
594
|
+
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
595
|
+
}
|
|
596
|
+
function resolveExplicitSourceScanEntries(entries, explicit) {
|
|
597
|
+
if (!explicit) return entries.length > 0 ? entries : void 0;
|
|
598
|
+
return entries.some((entry) => !entry.negated) ? entries : [];
|
|
599
|
+
}
|
|
600
|
+
function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
|
|
601
|
+
return {
|
|
602
|
+
entries: resolveExplicitSourceScanEntries(entries, explicit),
|
|
603
|
+
explicit,
|
|
604
|
+
inlineCandidates
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
async function resolveSourceScanEntries(options, runtime, scanOptions = {}) {
|
|
608
|
+
const sourceOptions = require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtime);
|
|
609
|
+
const configuredSourceEntries = sourceOptions.sources ?? [];
|
|
610
|
+
const cssEntries = collectExistingCssEntries(options);
|
|
611
|
+
if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
|
|
612
|
+
const scanRoot = scanOptions.root;
|
|
613
|
+
const sourceProjectRoot = sourceOptions.projectRoot;
|
|
614
|
+
if (scanRoot && sourceProjectRoot && node_path.default.resolve(scanRoot) === node_path.default.resolve(sourceProjectRoot)) {
|
|
615
|
+
const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
|
|
616
|
+
cssEntries.push(...discoveredCssEntries);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const entries = [];
|
|
620
|
+
const cssInlineCandidates = [];
|
|
621
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
622
|
+
let explicit = configuredSourceEntries.length > 0;
|
|
623
|
+
let readableCssEntryCount = 0;
|
|
624
|
+
for (const cssEntry of cssEntries) {
|
|
625
|
+
addSourceScanDependency(dependencies, cssEntry);
|
|
626
|
+
let css;
|
|
627
|
+
try {
|
|
628
|
+
css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
629
|
+
} catch {
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
readableCssEntryCount++;
|
|
633
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
|
|
634
|
+
if (resolved) {
|
|
635
|
+
entries.push(...resolved.entries);
|
|
636
|
+
cssInlineCandidates.push(resolved.inlineCandidates);
|
|
637
|
+
addSourceScanDependencies(dependencies, resolved.dependencies);
|
|
638
|
+
explicit || (explicit = resolved.explicit);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
642
|
+
const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
|
|
643
|
+
if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedSourceScan({
|
|
644
|
+
entries: resolveExplicitSourceScanEntries([...configuredSourceEntries, ...scanEntries], explicit),
|
|
645
|
+
explicit,
|
|
646
|
+
inlineCandidates
|
|
647
|
+
}, dependencies);
|
|
648
|
+
if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
|
|
649
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
650
|
+
return resolved ? createResolvedSourceScan(createResolvedV4CssScanInput([...configuredSourceEntries, ...resolved.entries], resolved.inlineCandidates, explicit || resolved.explicit), new Set(resolved.dependencies)) : void 0;
|
|
651
|
+
}
|
|
652
|
+
const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
|
|
653
|
+
const configuredCssSources = collectConfiguredCssSources(options);
|
|
654
|
+
for (const cssSource of [...configuredCssSources, ...sourceOptions.cssSources ?? []]) {
|
|
655
|
+
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
656
|
+
addSourceScanDependency(dependencies, cssSource.file);
|
|
657
|
+
addSourceScanDependencies(dependencies, cssSource.dependencies);
|
|
658
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
|
|
659
|
+
if (resolved) {
|
|
660
|
+
entries.push(...resolved.entries);
|
|
661
|
+
cssInlineCandidates.push(resolved.inlineCandidates);
|
|
662
|
+
addSourceScanDependencies(dependencies, resolved.dependencies);
|
|
663
|
+
explicit || (explicit = resolved.explicit);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
667
|
+
const cssSourceCount = (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length;
|
|
668
|
+
const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: cssSourceCount });
|
|
669
|
+
if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit) return createResolvedSourceScan({
|
|
670
|
+
entries: resolveExplicitSourceScanEntries([...configuredSourceEntries, ...cssSourceScanEntries], explicit),
|
|
671
|
+
explicit,
|
|
672
|
+
inlineCandidates: cssSourceInlineCandidates
|
|
673
|
+
}, dependencies);
|
|
674
|
+
if (cssSourceCount > 0) return;
|
|
675
|
+
const source = await require_generator.resolveTailwindV4SourceFromRuntime(runtime);
|
|
676
|
+
addSourceScanDependency(dependencies, source.file);
|
|
677
|
+
addSourceScanDependencies(dependencies, source.dependencies);
|
|
678
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
|
|
679
|
+
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;
|
|
680
|
+
}
|
|
681
|
+
//#endregion
|
|
17
682
|
//#region src/tailwindcss/runtime/cache.ts
|
|
18
683
|
const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
19
684
|
const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
|
|
@@ -80,15 +745,14 @@ async function collectTailwindV4TrackedSourceFiles(tailwindRuntime) {
|
|
|
80
745
|
const files = /* @__PURE__ */ new Set();
|
|
81
746
|
for (const cssEntry of tailwindOptions?.v4?.cssEntries ?? []) {
|
|
82
747
|
if (!(0, node_fs.existsSync)(cssEntry)) continue;
|
|
83
|
-
const
|
|
84
|
-
const resolved = await require_options.resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
|
|
748
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached((0, node_fs.readFileSync)(cssEntry, "utf8"), node_path.default.dirname(cssEntry));
|
|
85
749
|
const expanded = resolved?.entries?.length ? await require_generator.expandTailwindSourceEntries(resolved.entries) : [];
|
|
86
750
|
for (const file of expanded) files.add(file);
|
|
87
751
|
}
|
|
88
752
|
for (const cssSource of tailwindOptions?.v4?.cssSources ?? []) {
|
|
89
753
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
90
754
|
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();
|
|
91
|
-
const resolved = await
|
|
755
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, base);
|
|
92
756
|
const expanded = resolved?.entries?.length ? await require_generator.expandTailwindSourceEntries(resolved.entries) : [];
|
|
93
757
|
for (const file of expanded) files.add(file);
|
|
94
758
|
}
|
|
@@ -762,6 +1426,46 @@ function tryCreateMultiTailwindcssRuntime(groups, options) {
|
|
|
762
1426
|
return createMultiTailwindcssRuntime(runtimes);
|
|
763
1427
|
}
|
|
764
1428
|
//#endregion
|
|
1429
|
+
//#region src/uni-app-x/options.ts
|
|
1430
|
+
const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
|
|
1431
|
+
enabled: true,
|
|
1432
|
+
onlyWhenStyleIsolationVersion2: true
|
|
1433
|
+
};
|
|
1434
|
+
const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
|
|
1435
|
+
enabled: false,
|
|
1436
|
+
onlyWhenStyleIsolationVersion2: true
|
|
1437
|
+
};
|
|
1438
|
+
function isBooleanUniAppXShortcut(option) {
|
|
1439
|
+
return option === true || option === false || option === void 0;
|
|
1440
|
+
}
|
|
1441
|
+
function resolveComponentLocalStyles(option) {
|
|
1442
|
+
if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
|
|
1443
|
+
const componentLocalStyles = option.componentLocalStyles;
|
|
1444
|
+
if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
|
|
1445
|
+
if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
|
|
1446
|
+
return {
|
|
1447
|
+
...componentLocalStyles.componentMatcher ? { componentMatcher: componentLocalStyles.componentMatcher } : {},
|
|
1448
|
+
enabled: componentLocalStyles.enabled !== false,
|
|
1449
|
+
onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false,
|
|
1450
|
+
...componentLocalStyles.pageMatcher ? { pageMatcher: componentLocalStyles.pageMatcher } : {}
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
function resolveUniAppXOptions(option) {
|
|
1454
|
+
if (typeof option === "object" && option) return {
|
|
1455
|
+
enabled: option.enabled !== false,
|
|
1456
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
1457
|
+
uvueUnsupported: option.uvueUnsupported ?? "warn"
|
|
1458
|
+
};
|
|
1459
|
+
return {
|
|
1460
|
+
enabled: Boolean(option),
|
|
1461
|
+
componentLocalStyles: resolveComponentLocalStyles(option),
|
|
1462
|
+
uvueUnsupported: "warn"
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function isUniAppXEnabled(option) {
|
|
1466
|
+
return resolveUniAppXOptions(option).enabled;
|
|
1467
|
+
}
|
|
1468
|
+
//#endregion
|
|
765
1469
|
//#region src/context/tailwindcss/basedir.ts
|
|
766
1470
|
const ENV_BASEDIR_KEYS = [
|
|
767
1471
|
"WEAPP_TAILWINDCSS_BASEDIR",
|
|
@@ -913,12 +1617,24 @@ Object.defineProperty(exports, "applyV4CssCalcDefaults", {
|
|
|
913
1617
|
return applyV4CssCalcDefaults;
|
|
914
1618
|
}
|
|
915
1619
|
});
|
|
1620
|
+
Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
|
|
1621
|
+
enumerable: true,
|
|
1622
|
+
get: function() {
|
|
1623
|
+
return collectCssInlineSourceCandidates;
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
916
1626
|
Object.defineProperty(exports, "createTailwindcssRuntimeFromContext", {
|
|
917
1627
|
enumerable: true,
|
|
918
1628
|
get: function() {
|
|
919
1629
|
return createTailwindcssRuntimeFromContext;
|
|
920
1630
|
}
|
|
921
1631
|
});
|
|
1632
|
+
Object.defineProperty(exports, "discoverTailwindV4CssEntries", {
|
|
1633
|
+
enumerable: true,
|
|
1634
|
+
get: function() {
|
|
1635
|
+
return discoverTailwindV4CssEntries;
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
922
1638
|
Object.defineProperty(exports, "findTailwindConfig", {
|
|
923
1639
|
enumerable: true,
|
|
924
1640
|
get: function() {
|
|
@@ -943,18 +1659,60 @@ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
|
|
|
943
1659
|
return getRuntimeClassSetSignatureWithSources;
|
|
944
1660
|
}
|
|
945
1661
|
});
|
|
1662
|
+
Object.defineProperty(exports, "includesTailwindV4PreflightDirective", {
|
|
1663
|
+
enumerable: true,
|
|
1664
|
+
get: function() {
|
|
1665
|
+
return includesTailwindV4PreflightDirective;
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
946
1668
|
Object.defineProperty(exports, "invalidateRuntimeClassSet", {
|
|
947
1669
|
enumerable: true,
|
|
948
1670
|
get: function() {
|
|
949
1671
|
return invalidateRuntimeClassSet;
|
|
950
1672
|
}
|
|
951
1673
|
});
|
|
1674
|
+
Object.defineProperty(exports, "isUniAppXEnabled", {
|
|
1675
|
+
enumerable: true,
|
|
1676
|
+
get: function() {
|
|
1677
|
+
return isUniAppXEnabled;
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
Object.defineProperty(exports, "resolveSourceScanEntries", {
|
|
1681
|
+
enumerable: true,
|
|
1682
|
+
get: function() {
|
|
1683
|
+
return resolveSourceScanEntries;
|
|
1684
|
+
}
|
|
1685
|
+
});
|
|
1686
|
+
Object.defineProperty(exports, "resolveTailwindV4CssDependencies", {
|
|
1687
|
+
enumerable: true,
|
|
1688
|
+
get: function() {
|
|
1689
|
+
return resolveTailwindV4CssDependencies;
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
Object.defineProperty(exports, "resolveTailwindV4EntriesFromCss", {
|
|
1693
|
+
enumerable: true,
|
|
1694
|
+
get: function() {
|
|
1695
|
+
return resolveTailwindV4EntriesFromCss;
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
Object.defineProperty(exports, "resolveTailwindV4EntriesFromCssCached", {
|
|
1699
|
+
enumerable: true,
|
|
1700
|
+
get: function() {
|
|
1701
|
+
return resolveTailwindV4EntriesFromCssCached;
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
952
1704
|
Object.defineProperty(exports, "resolveTailwindcssBasedir", {
|
|
953
1705
|
enumerable: true,
|
|
954
1706
|
get: function() {
|
|
955
1707
|
return resolveTailwindcssBasedir;
|
|
956
1708
|
}
|
|
957
1709
|
});
|
|
1710
|
+
Object.defineProperty(exports, "resolveUniAppXOptions", {
|
|
1711
|
+
enumerable: true,
|
|
1712
|
+
get: function() {
|
|
1713
|
+
return resolveUniAppXOptions;
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
958
1716
|
Object.defineProperty(exports, "warnMissingCssEntries", {
|
|
959
1717
|
enumerable: true,
|
|
960
1718
|
get: function() {
|