weapp-tailwindcss 5.0.6 → 5.0.7
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/dist/{bundle-state-CFgzVHFP.js → bundle-state-BzwPS-UI.js} +2 -1
- package/dist/{bundle-state-CdNXQl-o.mjs → bundle-state-ChcOKb9w.mjs} +2 -1
- package/dist/bundlers/gulp/index.d.ts +3 -4
- package/dist/bundlers/gulp/module-graph.d.ts +2 -0
- package/dist/bundlers/gulp/runtime-snapshot.d.ts +5 -0
- package/dist/bundlers/gulp/vinyl-transform.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/css-source-trace.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +56 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +27 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +26 -0
- package/dist/bundlers/shared/generator-css/validate.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +4 -32
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +14 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +11 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/style-matching.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +68 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -62
- package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +4 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +2 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +13 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +17 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/scan-root.d.ts +10 -0
- package/dist/bundlers/vite/source-candidates/script.d.ts +7 -0
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +1 -0
- package/dist/bundlers/vite/source-candidates.d.ts +8 -3
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +20 -0
- package/dist/bundlers/vite/source-scan/dependencies.d.ts +2 -0
- package/dist/bundlers/vite/source-scan.d.ts +2 -12
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -20
- package/dist/cli.js +69 -69
- package/dist/cli.mjs +69 -69
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{defaults-BPUuNYcD.js → defaults-Boc26eel.js} +1 -0
- package/dist/{defaults-8xrgzxFY.mjs → defaults-DH0ZQRhy.mjs} +1 -0
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-C56PJYxA.js → generator-6yF8wjxR.js} +1 -1
- package/dist/{generator-Bgn4m8An.mjs → generator-BON6M1bL.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp-_7p1Z2vc.js +473 -0
- package/dist/gulp-oE-Byqk6.mjs +463 -0
- package/dist/gulp.js +4 -414
- package/dist/gulp.mjs +1 -406
- package/dist/{incremental-runtime-class-set-Bmzdjlk0.js → hmr-timing-BKQNRxHr.js} +1205 -449
- package/dist/{incremental-runtime-class-set-BEYHQkZc.mjs → hmr-timing-BVTGf5ch.mjs} +1169 -467
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{postcss-B7QNe78h.js → postcss-BTIunhWl.js} +7 -7
- package/dist/{postcss-BgINK7Nm.mjs → postcss-BtmrrZ31.mjs} +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-Copn2SqE.mjs → precheck-CZjr87m_.mjs} +19 -5
- package/dist/{precheck-CyPbGn38.js → precheck-fhIkzCSU.js} +19 -5
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/tailwindcss/source-scan/inline-source.d.ts +7 -0
- package/dist/tailwindcss/source-scan.d.ts +2 -7
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +3 -0
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +10 -0
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +6 -0
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/{tailwindcss-C0Zgo3Es.mjs → tailwindcss-bbQUg25J.mjs} +2 -2
- package/dist/{tailwindcss-Tw6CSVHL.js → tailwindcss-vswd1gc3.js} +2 -2
- package/dist/{transform-95ivJthq.js → transform-CReJxxh_.js} +11 -2
- package/dist/{transform-DgCFGtQR.mjs → transform-DEsFlG9k.mjs} +11 -2
- package/dist/types/typedoc-tailwindcss-patch.d.ts +4 -2
- package/dist/types/user-defined-options/general.d.ts +5 -0
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/harmony.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +16 -0
- package/dist/uni-app-x/style-asset.d.ts +20 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite.d.ts +1 -0
- package/dist/{v3-engine-6FVAcrZl.js → v3-engine-CEMXFegG.js} +758 -708
- package/dist/{v3-engine-Ji6AXPh2.mjs → v3-engine-CdIwmHuc.mjs} +756 -706
- package/dist/{vite-Bw6LOXvf.js → vite-0jFbh9hx.js} +1797 -386
- package/dist/{vite-ChZ2cbn4.mjs → vite-C7BGAlCE.mjs} +1779 -369
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +1104 -980
- package/dist/{webpack-CMJ7iqN7.mjs → webpack-Dx6_eg5k.mjs} +96 -36
- package/dist/{webpack-nn3P8_S_.js → webpack-aEuDoYfQ.js} +105 -44
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +7 -6
- package/dist/source-candidates-BODCmzz5.mjs +0 -355
- package/dist/source-candidates-Caf2GDvx.js +0 -374
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
2
|
const require_auto = require("./auto-Cvy0zWpS.js");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
5
3
|
let node_module = require("node:module");
|
|
6
4
|
let postcss = require("postcss");
|
|
7
5
|
postcss = require_chunk.__toESM(postcss);
|
|
8
6
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
9
7
|
let node_process = require("node:process");
|
|
10
8
|
node_process = require_chunk.__toESM(node_process);
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
11
11
|
let node_path = require("node:path");
|
|
12
12
|
node_path = require_chunk.__toESM(node_path);
|
|
13
13
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
@@ -16,12 +16,175 @@ let node_url = require("node:url");
|
|
|
16
16
|
let debug = require("debug");
|
|
17
17
|
debug = require_chunk.__toESM(debug);
|
|
18
18
|
let node_fs_promises = require("node:fs/promises");
|
|
19
|
-
let fast_glob = require("fast-glob");
|
|
20
|
-
fast_glob = require_chunk.__toESM(fast_glob);
|
|
21
|
-
let tailwindcss_config = require("tailwindcss-config");
|
|
22
19
|
let micromatch = require("micromatch");
|
|
23
20
|
micromatch = require_chunk.__toESM(micromatch);
|
|
24
21
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
22
|
+
let fast_glob = require("fast-glob");
|
|
23
|
+
fast_glob = require_chunk.__toESM(fast_glob);
|
|
24
|
+
let tailwindcss_config = require("tailwindcss-config");
|
|
25
|
+
//#region src/utils/object.ts
|
|
26
|
+
function definedEntries(value) {
|
|
27
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
28
|
+
}
|
|
29
|
+
function omitUndefined(value) {
|
|
30
|
+
return Object.fromEntries(definedEntries(value));
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/tailwindcss/v3-engine/generator/content.ts
|
|
34
|
+
function isLegacyContentObject$1(value) {
|
|
35
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
36
|
+
}
|
|
37
|
+
function createRawContentEntries(candidates, sources) {
|
|
38
|
+
const entries = [];
|
|
39
|
+
const candidateContent = [...candidates].join(" ");
|
|
40
|
+
if (candidateContent.length > 0) entries.push({
|
|
41
|
+
raw: candidateContent,
|
|
42
|
+
extension: "html"
|
|
43
|
+
});
|
|
44
|
+
for (const source of sources) entries.push({
|
|
45
|
+
raw: source.content,
|
|
46
|
+
extension: source.extension ?? "html"
|
|
47
|
+
});
|
|
48
|
+
return entries;
|
|
49
|
+
}
|
|
50
|
+
function createChangedContentEntries(candidates, sources) {
|
|
51
|
+
return createRawContentEntries(candidates, sources).map((entry) => ({
|
|
52
|
+
content: entry.raw,
|
|
53
|
+
extension: entry.extension
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
function collectCandidates$1(candidates) {
|
|
57
|
+
return new Set(candidates ?? []);
|
|
58
|
+
}
|
|
59
|
+
function collectApplyCandidatesFromCss(css) {
|
|
60
|
+
if (!css.includes("@apply")) return [];
|
|
61
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
62
|
+
try {
|
|
63
|
+
postcss.default.parse(css).walkAtRules("apply", (rule) => {
|
|
64
|
+
for (const candidate of rule.params.split(/\s+/)) {
|
|
65
|
+
const normalized = candidate.replace(/!important$/, "").trim();
|
|
66
|
+
if (normalized) candidates.add(normalized);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
} catch {}
|
|
70
|
+
return [...candidates];
|
|
71
|
+
}
|
|
72
|
+
function isTailwindCandidateLayer(params) {
|
|
73
|
+
return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
|
|
74
|
+
}
|
|
75
|
+
function extractClassCandidatesFromSelector(selector, candidates) {
|
|
76
|
+
for (let index = 0; index < selector.length; index++) {
|
|
77
|
+
if (selector[index] !== ".") continue;
|
|
78
|
+
let candidate = "";
|
|
79
|
+
let escaped = false;
|
|
80
|
+
for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
|
|
81
|
+
const char = selector[tokenIndex];
|
|
82
|
+
if (escaped) {
|
|
83
|
+
candidate += char;
|
|
84
|
+
escaped = false;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (char === "\\") {
|
|
88
|
+
escaped = true;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (char && /[\w-]/.test(char)) {
|
|
92
|
+
candidate += char;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
if (candidate) candidates.add(candidate);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function collectLayerCandidatesFromCss(css) {
|
|
101
|
+
if (!css.includes("@layer")) return [];
|
|
102
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
103
|
+
try {
|
|
104
|
+
postcss.default.parse(css).walkAtRules("layer", (layer) => {
|
|
105
|
+
if (!isTailwindCandidateLayer(layer.params)) return;
|
|
106
|
+
layer.walkRules((rule) => {
|
|
107
|
+
extractClassCandidatesFromSelector(rule.selector, candidates);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
} catch {}
|
|
111
|
+
return [...candidates];
|
|
112
|
+
}
|
|
113
|
+
function mergeGenerateCandidates(source, options) {
|
|
114
|
+
return collectCandidates$1([
|
|
115
|
+
...collectLayerCandidatesFromCss(source.css),
|
|
116
|
+
...collectApplyCandidatesFromCss(source.css),
|
|
117
|
+
...collectCandidates$1(options.candidates)
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
function mergeContent(content, rawEntries) {
|
|
121
|
+
if (isLegacyContentObject$1(content)) return {
|
|
122
|
+
...content,
|
|
123
|
+
relative: content.relative ?? true,
|
|
124
|
+
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
relative: true,
|
|
128
|
+
files: [...[].concat(content ?? []), ...rawEntries]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function normalizeConfigObject(config) {
|
|
132
|
+
if (!config || typeof config !== "object") return config;
|
|
133
|
+
const maybeDefault = config.default;
|
|
134
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
135
|
+
return config;
|
|
136
|
+
}
|
|
137
|
+
function hasExplicitContentInput(options) {
|
|
138
|
+
return options.candidates !== void 0 || options.sources !== void 0;
|
|
139
|
+
}
|
|
140
|
+
function createExplicitContentConfig(rawEntries) {
|
|
141
|
+
return {
|
|
142
|
+
relative: true,
|
|
143
|
+
files: rawEntries
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function createTailwindConfig(source, options) {
|
|
147
|
+
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
148
|
+
const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
|
|
149
|
+
config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
|
|
150
|
+
return config;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/tailwindcss/v3-engine/generator/cache-key.ts
|
|
154
|
+
function createStableJson$1(value) {
|
|
155
|
+
if (value === void 0) return "undefined";
|
|
156
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
157
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
|
|
158
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
159
|
+
const record = value;
|
|
160
|
+
return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
|
|
161
|
+
}).join(",")}}`;
|
|
162
|
+
}
|
|
163
|
+
function createDependencyFingerprint$1(files) {
|
|
164
|
+
return files.map((file) => {
|
|
165
|
+
try {
|
|
166
|
+
const stat = node_fs.default.statSync(file);
|
|
167
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
168
|
+
} catch {
|
|
169
|
+
return `${file}:missing`;
|
|
170
|
+
}
|
|
171
|
+
}).join("|");
|
|
172
|
+
}
|
|
173
|
+
function createIncrementalGenerateCacheKey$1(source, target, styleOptions, bareArbitraryValues) {
|
|
174
|
+
return [
|
|
175
|
+
source.packageName,
|
|
176
|
+
source.postcssPlugin,
|
|
177
|
+
source.cwd,
|
|
178
|
+
source.config ?? "config:missing",
|
|
179
|
+
createDependencyFingerprint$1(source.dependencies),
|
|
180
|
+
source.css,
|
|
181
|
+
createStableJson$1(normalizeConfigObject(source.configObject)?.content),
|
|
182
|
+
target,
|
|
183
|
+
createStableJson$1(styleOptions),
|
|
184
|
+
createStableJson$1(bareArbitraryValues)
|
|
185
|
+
].join("\0");
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
25
188
|
//#region src/context/workspace.ts
|
|
26
189
|
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
27
190
|
"node_modules",
|
|
@@ -81,14 +244,6 @@ function findWorkspacePackageDir(rootDir, packageName) {
|
|
|
81
244
|
}
|
|
82
245
|
}
|
|
83
246
|
//#endregion
|
|
84
|
-
//#region src/utils/object.ts
|
|
85
|
-
function definedEntries(value) {
|
|
86
|
-
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
87
|
-
}
|
|
88
|
-
function omitUndefined(value) {
|
|
89
|
-
return Object.fromEntries(definedEntries(value));
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
247
|
//#region src/utils/options.ts
|
|
93
248
|
function resolveBooleanObjectOption(value, enabledValue) {
|
|
94
249
|
if (!value) return false;
|
|
@@ -311,7 +466,7 @@ function createTailwindcssPatcher(options) {
|
|
|
311
466
|
const resolvedTailwindOptions = resolvedOptions.tailwindcss;
|
|
312
467
|
if (resolvedTailwindOptions) {
|
|
313
468
|
const existingResolve = resolvedTailwindOptions.resolve ?? {};
|
|
314
|
-
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths, ...resolvePaths] : resolvePaths;
|
|
469
|
+
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths ?? [], ...resolvePaths] : resolvePaths;
|
|
315
470
|
resolvedTailwindOptions.resolve = {
|
|
316
471
|
...existingResolve,
|
|
317
472
|
paths: [...new Set(sourcePaths)]
|
|
@@ -373,140 +528,8 @@ function createDebug(prefix) {
|
|
|
373
528
|
return debug$2;
|
|
374
529
|
}
|
|
375
530
|
//#endregion
|
|
376
|
-
//#region src/tailwindcss/source-scan.ts
|
|
377
|
-
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
378
|
-
"html",
|
|
379
|
-
"wxml",
|
|
380
|
-
"axml",
|
|
381
|
-
"jxml",
|
|
382
|
-
"ksml",
|
|
383
|
-
"ttml",
|
|
384
|
-
"qml",
|
|
385
|
-
"tyml",
|
|
386
|
-
"xhsml",
|
|
387
|
-
"swan",
|
|
388
|
-
"vue",
|
|
389
|
-
"mpx",
|
|
390
|
-
"js",
|
|
391
|
-
"jsx",
|
|
392
|
-
"ts",
|
|
393
|
-
"tsx"
|
|
394
|
-
];
|
|
395
|
-
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
396
|
-
"js",
|
|
397
|
-
"jsx",
|
|
398
|
-
"mjs",
|
|
399
|
-
"cjs",
|
|
400
|
-
"ts",
|
|
401
|
-
"tsx",
|
|
402
|
-
"mts",
|
|
403
|
-
"cts",
|
|
404
|
-
"vue",
|
|
405
|
-
"uvue",
|
|
406
|
-
"nvue",
|
|
407
|
-
"svelte",
|
|
408
|
-
"mpx",
|
|
409
|
-
"html",
|
|
410
|
-
"wxml",
|
|
411
|
-
"axml",
|
|
412
|
-
"jxml",
|
|
413
|
-
"ksml",
|
|
414
|
-
"ttml",
|
|
415
|
-
"qml",
|
|
416
|
-
"tyml",
|
|
417
|
-
"xhsml",
|
|
418
|
-
"swan",
|
|
419
|
-
"css",
|
|
420
|
-
"wxss",
|
|
421
|
-
"acss",
|
|
422
|
-
"jxss",
|
|
423
|
-
"ttss",
|
|
424
|
-
"qss",
|
|
425
|
-
"tyss",
|
|
426
|
-
"scss",
|
|
427
|
-
"sass",
|
|
428
|
-
"less",
|
|
429
|
-
"styl",
|
|
430
|
-
"stylus"
|
|
431
|
-
];
|
|
432
|
-
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
433
|
-
return `**/*.{${extensions.join(",")}}`;
|
|
434
|
-
}
|
|
435
|
-
const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
436
|
-
const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
437
|
-
function toPosixPath(value) {
|
|
438
|
-
return value.split(node_path.default.sep).join("/");
|
|
439
|
-
}
|
|
440
|
-
function resolveSourceScanPath(value) {
|
|
441
|
-
const resolved = node_path.default.resolve(value);
|
|
442
|
-
try {
|
|
443
|
-
return node_fs.realpathSync.native(resolved);
|
|
444
|
-
} catch {
|
|
445
|
-
return resolved;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
function normalizeEntryPattern(entry) {
|
|
449
|
-
return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
|
|
450
|
-
}
|
|
451
|
-
function isFileMatchedByTailwindSourceEntry(file, entry) {
|
|
452
|
-
const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
|
|
453
|
-
return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
|
|
454
|
-
}
|
|
455
|
-
function isFileExcludedByTailwindSourceEntries(file, entries) {
|
|
456
|
-
if (!entries?.length) return false;
|
|
457
|
-
const resolvedFile = resolveSourceScanPath(file);
|
|
458
|
-
return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
459
|
-
}
|
|
460
|
-
function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
461
|
-
if (!entries?.length) return true;
|
|
462
|
-
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
463
|
-
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
464
|
-
const resolvedFile = resolveSourceScanPath(file);
|
|
465
|
-
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
466
|
-
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
467
|
-
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
468
|
-
}
|
|
469
|
-
function createTailwindSourceEntryMatcher(entries) {
|
|
470
|
-
if (!entries?.length) return;
|
|
471
|
-
return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
|
|
472
|
-
}
|
|
473
|
-
function resolveTailwindV4CssSourceBase(source, fallbackBase) {
|
|
474
|
-
if (typeof source.base === "string" && source.base.length > 0) return source.base;
|
|
475
|
-
if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
|
|
476
|
-
return fallbackBase;
|
|
477
|
-
}
|
|
531
|
+
//#region src/tailwindcss/source-scan/inline-source.ts
|
|
478
532
|
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
479
|
-
function parseConfigParam$1(params) {
|
|
480
|
-
const value = params.trim();
|
|
481
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
482
|
-
}
|
|
483
|
-
function isLegacyContentObject$1(value) {
|
|
484
|
-
return typeof value === "object" && value !== null && "files" in value;
|
|
485
|
-
}
|
|
486
|
-
function normalizeGlobPattern(pattern) {
|
|
487
|
-
return pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
488
|
-
}
|
|
489
|
-
function hasGlobMagic(value) {
|
|
490
|
-
return /[*?[\]{}()!+@]/.test(value);
|
|
491
|
-
}
|
|
492
|
-
function splitStaticGlobPrefix(pattern) {
|
|
493
|
-
const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
|
|
494
|
-
const prefix = [];
|
|
495
|
-
const rest = [];
|
|
496
|
-
let reachedGlob = false;
|
|
497
|
-
for (const segment of segments) {
|
|
498
|
-
if (!reachedGlob && segment && !hasGlobMagic(segment)) {
|
|
499
|
-
prefix.push(segment);
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
reachedGlob = true;
|
|
503
|
-
rest.push(segment);
|
|
504
|
-
}
|
|
505
|
-
return {
|
|
506
|
-
prefix,
|
|
507
|
-
rest
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
533
|
function segmentTopLevel(input, separator, options = {}) {
|
|
511
534
|
const parts = [];
|
|
512
535
|
const stack = [];
|
|
@@ -633,6 +656,140 @@ function collectCssInlineSourceCandidates(root) {
|
|
|
633
656
|
excluded
|
|
634
657
|
};
|
|
635
658
|
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/tailwindcss/source-scan.ts
|
|
661
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
662
|
+
"html",
|
|
663
|
+
"wxml",
|
|
664
|
+
"axml",
|
|
665
|
+
"jxml",
|
|
666
|
+
"ksml",
|
|
667
|
+
"ttml",
|
|
668
|
+
"qml",
|
|
669
|
+
"tyml",
|
|
670
|
+
"xhsml",
|
|
671
|
+
"swan",
|
|
672
|
+
"vue",
|
|
673
|
+
"mpx",
|
|
674
|
+
"js",
|
|
675
|
+
"jsx",
|
|
676
|
+
"ts",
|
|
677
|
+
"tsx"
|
|
678
|
+
];
|
|
679
|
+
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
680
|
+
"js",
|
|
681
|
+
"jsx",
|
|
682
|
+
"mjs",
|
|
683
|
+
"cjs",
|
|
684
|
+
"ts",
|
|
685
|
+
"tsx",
|
|
686
|
+
"mts",
|
|
687
|
+
"cts",
|
|
688
|
+
"vue",
|
|
689
|
+
"uvue",
|
|
690
|
+
"nvue",
|
|
691
|
+
"svelte",
|
|
692
|
+
"mpx",
|
|
693
|
+
"html",
|
|
694
|
+
"wxml",
|
|
695
|
+
"axml",
|
|
696
|
+
"jxml",
|
|
697
|
+
"ksml",
|
|
698
|
+
"ttml",
|
|
699
|
+
"qml",
|
|
700
|
+
"tyml",
|
|
701
|
+
"xhsml",
|
|
702
|
+
"swan",
|
|
703
|
+
"css",
|
|
704
|
+
"wxss",
|
|
705
|
+
"acss",
|
|
706
|
+
"jxss",
|
|
707
|
+
"ttss",
|
|
708
|
+
"qss",
|
|
709
|
+
"tyss",
|
|
710
|
+
"scss",
|
|
711
|
+
"sass",
|
|
712
|
+
"less",
|
|
713
|
+
"styl",
|
|
714
|
+
"stylus"
|
|
715
|
+
];
|
|
716
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
717
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
718
|
+
}
|
|
719
|
+
const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
720
|
+
const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
721
|
+
function toPosixPath(value) {
|
|
722
|
+
return value.split(node_path.default.sep).join("/");
|
|
723
|
+
}
|
|
724
|
+
function resolveSourceScanPath(value) {
|
|
725
|
+
const resolved = node_path.default.resolve(value);
|
|
726
|
+
try {
|
|
727
|
+
return node_fs.realpathSync.native(resolved);
|
|
728
|
+
} catch {
|
|
729
|
+
return resolved;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function normalizeEntryPattern(entry) {
|
|
733
|
+
return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
|
|
734
|
+
}
|
|
735
|
+
function isFileMatchedByTailwindSourceEntry(file, entry) {
|
|
736
|
+
const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
|
|
737
|
+
return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
|
|
738
|
+
}
|
|
739
|
+
function isFileExcludedByTailwindSourceEntries(file, entries) {
|
|
740
|
+
if (!entries?.length) return false;
|
|
741
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
742
|
+
return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
743
|
+
}
|
|
744
|
+
function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
745
|
+
if (!entries?.length) return true;
|
|
746
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
747
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
748
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
749
|
+
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
750
|
+
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
751
|
+
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
752
|
+
}
|
|
753
|
+
function createTailwindSourceEntryMatcher(entries) {
|
|
754
|
+
if (!entries?.length) return;
|
|
755
|
+
return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
|
|
756
|
+
}
|
|
757
|
+
function resolveTailwindV4CssSourceBase(source, fallbackBase) {
|
|
758
|
+
if (typeof source.base === "string" && source.base.length > 0) return source.base;
|
|
759
|
+
if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
|
|
760
|
+
return fallbackBase;
|
|
761
|
+
}
|
|
762
|
+
function parseConfigParam$1(params) {
|
|
763
|
+
const value = params.trim();
|
|
764
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
765
|
+
}
|
|
766
|
+
function isLegacyContentObject(value) {
|
|
767
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
768
|
+
}
|
|
769
|
+
function normalizeGlobPattern(pattern) {
|
|
770
|
+
return pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
771
|
+
}
|
|
772
|
+
function hasGlobMagic(value) {
|
|
773
|
+
return /[*?[\]{}()!+@]/.test(value);
|
|
774
|
+
}
|
|
775
|
+
function splitStaticGlobPrefix(pattern) {
|
|
776
|
+
const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
|
|
777
|
+
const prefix = [];
|
|
778
|
+
const rest = [];
|
|
779
|
+
let reachedGlob = false;
|
|
780
|
+
for (const segment of segments) {
|
|
781
|
+
if (!reachedGlob && segment && !hasGlobMagic(segment)) {
|
|
782
|
+
prefix.push(segment);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
reachedGlob = true;
|
|
786
|
+
rest.push(segment);
|
|
787
|
+
}
|
|
788
|
+
return {
|
|
789
|
+
prefix,
|
|
790
|
+
rest
|
|
791
|
+
};
|
|
792
|
+
}
|
|
636
793
|
function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
637
794
|
if (typeof content === "string") {
|
|
638
795
|
const negated = content.startsWith("!");
|
|
@@ -643,7 +800,7 @@ function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
|
643
800
|
}];
|
|
644
801
|
}
|
|
645
802
|
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
|
|
646
|
-
if (isLegacyContentObject
|
|
803
|
+
if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
|
|
647
804
|
return [];
|
|
648
805
|
}
|
|
649
806
|
async function pathExistsAsDirectory(file) {
|
|
@@ -739,40 +896,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
739
896
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
740
897
|
}
|
|
741
898
|
//#endregion
|
|
742
|
-
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
743
|
-
const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
744
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
745
|
-
cssRemoveHoverPseudoClass: true,
|
|
746
|
-
isMainChunk: true,
|
|
747
|
-
majorVersion: 4
|
|
748
|
-
});
|
|
749
|
-
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
750
|
-
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
751
|
-
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
752
|
-
try {
|
|
753
|
-
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
754
|
-
} catch {
|
|
755
|
-
return match;
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
async function transformTailwindV4CssToWeapp(css, options) {
|
|
760
|
-
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(require_auto.hasCssMacroStyleOptions(options) ? await require_auto.transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
761
|
-
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
762
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
763
|
-
cssRemoveHoverPseudoClass: true,
|
|
764
|
-
isMainChunk: true,
|
|
765
|
-
majorVersion: 4,
|
|
766
|
-
...options
|
|
767
|
-
});
|
|
768
|
-
const pruneOptions = { preserveConditionalComments: require_auto.hasCssMacroStyleOptions(options) };
|
|
769
|
-
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
770
|
-
}
|
|
771
|
-
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
772
|
-
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
773
|
-
return require_auto.hasCssMacroStyleOptions(options) ? require_auto.transformCssMacroCss(css, options) : css;
|
|
774
|
-
}
|
|
775
|
-
//#endregion
|
|
776
899
|
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
777
900
|
const TAILWIND_V3_COLOR_STEPS = [
|
|
778
901
|
"50",
|
|
@@ -1504,40 +1627,7 @@ function createTailwindV4DefaultColorThemeCss() {
|
|
|
1504
1627
|
].join("\n");
|
|
1505
1628
|
}
|
|
1506
1629
|
//#endregion
|
|
1507
|
-
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1508
|
-
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1509
|
-
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1510
|
-
const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
|
|
1511
|
-
const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
|
|
1512
|
-
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
1513
|
-
"**/.git/**",
|
|
1514
|
-
"**/.hg/**",
|
|
1515
|
-
"**/.jj/**",
|
|
1516
|
-
"**/.next/**",
|
|
1517
|
-
"**/.parcel-cache/**",
|
|
1518
|
-
"**/.pnpm-store/**",
|
|
1519
|
-
"**/.svelte-kit/**",
|
|
1520
|
-
"**/.svn/**",
|
|
1521
|
-
"**/.turbo/**",
|
|
1522
|
-
"**/.venv/**",
|
|
1523
|
-
"**/.vercel/**",
|
|
1524
|
-
"**/.yarn/**",
|
|
1525
|
-
"**/__pycache__/**",
|
|
1526
|
-
"**/node_modules/**",
|
|
1527
|
-
"**/venv/**",
|
|
1528
|
-
"**/*.less",
|
|
1529
|
-
"**/*.lock",
|
|
1530
|
-
"**/*.sass",
|
|
1531
|
-
"**/*.scss",
|
|
1532
|
-
"**/*.styl",
|
|
1533
|
-
"**/*.log",
|
|
1534
|
-
"**/package-lock.json",
|
|
1535
|
-
"**/pnpm-lock.yaml",
|
|
1536
|
-
"**/bun.lockb",
|
|
1537
|
-
"**/.gitignore",
|
|
1538
|
-
"**/.env",
|
|
1539
|
-
"**/.env.*"
|
|
1540
|
-
];
|
|
1630
|
+
//#region src/tailwindcss/v4-engine/generator/css-compat.ts
|
|
1541
1631
|
function findLeadingImportInsertionIndex(css) {
|
|
1542
1632
|
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1543
1633
|
let insertionIndex = 0;
|
|
@@ -1554,13 +1644,78 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
|
1554
1644
|
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
1555
1645
|
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
1556
1646
|
}
|
|
1557
|
-
function
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1647
|
+
function parseCssImportSpecifier$3(params) {
|
|
1648
|
+
const value = params.trim();
|
|
1649
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1650
|
+
if (quoted) return quoted[2];
|
|
1651
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1652
|
+
return url?.[2] ?? url?.[3];
|
|
1653
|
+
}
|
|
1654
|
+
function isTailwindCssPreflightImport(params) {
|
|
1655
|
+
const specifier = parseCssImportSpecifier$3(params);
|
|
1656
|
+
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1657
|
+
}
|
|
1658
|
+
function hasImportLayerOption(params) {
|
|
1659
|
+
return /\blayer(?:\s*\(|\s*$)/.test(params);
|
|
1660
|
+
}
|
|
1661
|
+
function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
1662
|
+
if (!css.includes("preflight")) return css;
|
|
1663
|
+
let root;
|
|
1664
|
+
try {
|
|
1665
|
+
root = postcss.default.parse(css);
|
|
1666
|
+
} catch {
|
|
1667
|
+
return css;
|
|
1668
|
+
}
|
|
1669
|
+
let changed = false;
|
|
1670
|
+
root.walkAtRules("import", (rule) => {
|
|
1671
|
+
if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
|
|
1672
|
+
rule.remove();
|
|
1673
|
+
changed = true;
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
return changed ? root.toString() : css;
|
|
1677
|
+
}
|
|
1678
|
+
function hasThemeParent(rule) {
|
|
1679
|
+
let parent = rule.parent;
|
|
1680
|
+
while (parent) {
|
|
1681
|
+
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
1682
|
+
parent = parent.parent;
|
|
1683
|
+
}
|
|
1562
1684
|
return false;
|
|
1563
1685
|
}
|
|
1686
|
+
function isVendorPrefixedKeyframes(rule) {
|
|
1687
|
+
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
1688
|
+
}
|
|
1689
|
+
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
1690
|
+
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1691
|
+
let root;
|
|
1692
|
+
try {
|
|
1693
|
+
root = postcss.default.parse(css);
|
|
1694
|
+
} catch {
|
|
1695
|
+
return css;
|
|
1696
|
+
}
|
|
1697
|
+
let changed = false;
|
|
1698
|
+
root.walkAtRules((rule) => {
|
|
1699
|
+
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
1700
|
+
rule.remove();
|
|
1701
|
+
changed = true;
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
return changed ? root.toString() : css;
|
|
1705
|
+
}
|
|
1706
|
+
function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
|
|
1707
|
+
const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
|
|
1708
|
+
const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
|
|
1709
|
+
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
1710
|
+
return compatibleSourceCss === source.css ? source : {
|
|
1711
|
+
...source,
|
|
1712
|
+
css: compatibleSourceCss
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
//#endregion
|
|
1716
|
+
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
1717
|
+
const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
|
|
1718
|
+
const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
|
|
1564
1719
|
function normalizeRpxTextCandidate(candidate) {
|
|
1565
1720
|
return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
|
|
1566
1721
|
}
|
|
@@ -1593,16 +1748,162 @@ function restoreRpxTextCssSelectors(css, restoreCandidates) {
|
|
|
1593
1748
|
return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
|
|
1594
1749
|
});
|
|
1595
1750
|
}
|
|
1596
|
-
|
|
1751
|
+
//#endregion
|
|
1752
|
+
//#region src/tailwindcss/v4-engine/generator/scan-sources.ts
|
|
1753
|
+
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
1754
|
+
"**/.git/**",
|
|
1755
|
+
"**/.hg/**",
|
|
1756
|
+
"**/.jj/**",
|
|
1757
|
+
"**/.next/**",
|
|
1758
|
+
"**/.parcel-cache/**",
|
|
1759
|
+
"**/.pnpm-store/**",
|
|
1760
|
+
"**/.svelte-kit/**",
|
|
1761
|
+
"**/.svn/**",
|
|
1762
|
+
"**/.turbo/**",
|
|
1763
|
+
"**/.venv/**",
|
|
1764
|
+
"**/.vercel/**",
|
|
1765
|
+
"**/.yarn/**",
|
|
1766
|
+
"**/__pycache__/**",
|
|
1767
|
+
"**/node_modules/**",
|
|
1768
|
+
"**/venv/**",
|
|
1769
|
+
"**/*.less",
|
|
1770
|
+
"**/*.lock",
|
|
1771
|
+
"**/*.sass",
|
|
1772
|
+
"**/*.scss",
|
|
1773
|
+
"**/*.styl",
|
|
1774
|
+
"**/*.log",
|
|
1775
|
+
"**/package-lock.json",
|
|
1776
|
+
"**/pnpm-lock.yaml",
|
|
1777
|
+
"**/bun.lockb",
|
|
1778
|
+
"**/.gitignore",
|
|
1779
|
+
"**/.env",
|
|
1780
|
+
"**/.env.*"
|
|
1781
|
+
];
|
|
1782
|
+
function parseImportSourceParam$1(params) {
|
|
1783
|
+
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
1784
|
+
if (!match) return;
|
|
1785
|
+
return {
|
|
1786
|
+
none: match[1] === "none",
|
|
1787
|
+
sourcePath: match[3]
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
function parseCssImportSpecifier$2(params) {
|
|
1791
|
+
const value = params.trim();
|
|
1792
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1793
|
+
if (quoted) return quoted[2];
|
|
1794
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1795
|
+
return url?.[2] ?? url?.[3];
|
|
1796
|
+
}
|
|
1797
|
+
function isTailwindCssImport$1(params) {
|
|
1798
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
1799
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1800
|
+
}
|
|
1801
|
+
function resolveSourceBase$1(base, sourcePath) {
|
|
1802
|
+
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
1803
|
+
}
|
|
1804
|
+
function createDefaultIgnoredScanSources(base) {
|
|
1805
|
+
return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
|
|
1806
|
+
base,
|
|
1807
|
+
pattern,
|
|
1808
|
+
negated: true
|
|
1809
|
+
}));
|
|
1810
|
+
}
|
|
1811
|
+
function normalizeCssDefinedScanSources(base, entries) {
|
|
1812
|
+
return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
|
|
1813
|
+
base,
|
|
1814
|
+
pattern: "**/*",
|
|
1815
|
+
negated: false
|
|
1816
|
+
}, ...entries] : entries;
|
|
1817
|
+
}
|
|
1818
|
+
async function resolveCssDefinedScanSources(source) {
|
|
1819
|
+
let importSourceBase;
|
|
1820
|
+
let hasSourceNone = false;
|
|
1821
|
+
const from = source.dependencies[0];
|
|
1822
|
+
let root;
|
|
1823
|
+
try {
|
|
1824
|
+
root = postcss.default.parse(source.css, { from });
|
|
1825
|
+
} catch {
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
root.walkAtRules((rule) => {
|
|
1829
|
+
if (rule.name === "import") {
|
|
1830
|
+
if (!isTailwindCssImport$1(rule.params)) return;
|
|
1831
|
+
const sourceParam = parseImportSourceParam$1(rule.params);
|
|
1832
|
+
if (sourceParam?.none) hasSourceNone = true;
|
|
1833
|
+
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase$1(source.base, sourceParam.sourcePath);
|
|
1834
|
+
}
|
|
1835
|
+
});
|
|
1836
|
+
const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
|
|
1837
|
+
if (!importSourceBase) {
|
|
1838
|
+
if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
|
|
1839
|
+
if (hasSourceNone) return false;
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
return [
|
|
1843
|
+
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1844
|
+
...sourcePatterns,
|
|
1845
|
+
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1846
|
+
];
|
|
1847
|
+
}
|
|
1848
|
+
async function resolveScanSources(source, scanSources) {
|
|
1849
|
+
if (scanSources !== true) return scanSources;
|
|
1850
|
+
return await resolveCssDefinedScanSources(source) ?? false;
|
|
1851
|
+
}
|
|
1852
|
+
//#endregion
|
|
1853
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
1854
|
+
const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
1855
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1856
|
+
cssRemoveHoverPseudoClass: true,
|
|
1857
|
+
isMainChunk: true,
|
|
1858
|
+
majorVersion: 4
|
|
1859
|
+
});
|
|
1860
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
1861
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
1862
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
1863
|
+
try {
|
|
1864
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
1865
|
+
} catch {
|
|
1866
|
+
return match;
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
1871
|
+
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(require_auto.hasCssMacroStyleOptions(options) ? await require_auto.transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
1872
|
+
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
1873
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1874
|
+
cssRemoveHoverPseudoClass: true,
|
|
1875
|
+
isMainChunk: true,
|
|
1876
|
+
majorVersion: 4,
|
|
1877
|
+
...options
|
|
1878
|
+
});
|
|
1879
|
+
const pruneOptions = { preserveConditionalComments: require_auto.hasCssMacroStyleOptions(options) };
|
|
1880
|
+
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
1881
|
+
}
|
|
1882
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
1883
|
+
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
1884
|
+
return require_auto.hasCssMacroStyleOptions(options) ? require_auto.transformCssMacroCss(css, options) : css;
|
|
1885
|
+
}
|
|
1886
|
+
//#endregion
|
|
1887
|
+
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1888
|
+
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1889
|
+
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1890
|
+
function collectCandidates(candidates) {
|
|
1891
|
+
return new Set(candidates ?? []);
|
|
1892
|
+
}
|
|
1893
|
+
function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
|
|
1894
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
1895
|
+
return false;
|
|
1896
|
+
}
|
|
1897
|
+
function createStableJson(value) {
|
|
1597
1898
|
if (value === void 0) return "undefined";
|
|
1598
1899
|
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1599
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson
|
|
1900
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
1600
1901
|
return `{${Object.keys(value).sort().map((key) => {
|
|
1601
1902
|
const record = value;
|
|
1602
|
-
return `${JSON.stringify(key)}:${createStableJson
|
|
1903
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
1603
1904
|
}).join(",")}}`;
|
|
1604
1905
|
}
|
|
1605
|
-
function createDependencyFingerprint
|
|
1906
|
+
function createDependencyFingerprint(files) {
|
|
1606
1907
|
return files.map((file) => {
|
|
1607
1908
|
try {
|
|
1608
1909
|
const stat = node_fs.default.statSync(file);
|
|
@@ -1612,16 +1913,16 @@ function createDependencyFingerprint$1(files) {
|
|
|
1612
1913
|
}
|
|
1613
1914
|
}).join("|");
|
|
1614
1915
|
}
|
|
1615
|
-
function createIncrementalGenerateCacheKey
|
|
1916
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions, tailwindcssV3Compatibility) {
|
|
1616
1917
|
return [
|
|
1617
1918
|
source.projectRoot,
|
|
1618
1919
|
source.base,
|
|
1619
|
-
createStableJson
|
|
1920
|
+
createStableJson(source.baseFallbacks),
|
|
1620
1921
|
source.css,
|
|
1621
|
-
createDependencyFingerprint
|
|
1922
|
+
createDependencyFingerprint(source.dependencies),
|
|
1622
1923
|
target,
|
|
1623
|
-
createStableJson
|
|
1624
|
-
createStableJson
|
|
1924
|
+
createStableJson(styleOptions),
|
|
1925
|
+
createStableJson(tailwindcssV3Compatibility)
|
|
1625
1926
|
].join("\0");
|
|
1626
1927
|
}
|
|
1627
1928
|
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
@@ -1642,192 +1943,61 @@ function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources,
|
|
|
1642
1943
|
});
|
|
1643
1944
|
return promise;
|
|
1644
1945
|
}
|
|
1645
|
-
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1646
|
-
const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
|
|
1647
|
-
promise.catch(() => {
|
|
1648
|
-
if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
|
|
1649
|
-
});
|
|
1650
|
-
return promise;
|
|
1651
|
-
}
|
|
1652
|
-
function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
|
|
1653
|
-
const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
|
|
1654
|
-
const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
|
|
1655
|
-
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
1656
|
-
return compatibleSourceCss === source.css ? source : {
|
|
1657
|
-
...source,
|
|
1658
|
-
css: compatibleSourceCss
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1661
|
-
function resolveTargetCandidates(candidates, target) {
|
|
1662
|
-
const collected = collectCandidates$1(candidates);
|
|
1663
|
-
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1664
|
-
}
|
|
1665
|
-
function collectSeenCandidates(generated, requestedCandidates) {
|
|
1666
|
-
return new Set([
|
|
1667
|
-
...requestedCandidates,
|
|
1668
|
-
...generated.rawCandidates,
|
|
1669
|
-
...generated.classSet
|
|
1670
|
-
]);
|
|
1671
|
-
}
|
|
1672
|
-
function createIncrementalStyleOptions(styleOptions) {
|
|
1673
|
-
return {
|
|
1674
|
-
...styleOptions,
|
|
1675
|
-
isMainChunk: false
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
function resolveStyleOptions$1(source, options) {
|
|
1679
|
-
return require_auto.hasCssMacroTailwindV4Directive(source.css) ? require_auto.withCssMacroStyleOptions(options) : options;
|
|
1680
|
-
}
|
|
1681
|
-
function collectCustomPropertyValues(css) {
|
|
1682
|
-
const values = /* @__PURE__ */ new Map();
|
|
1683
|
-
try {
|
|
1684
|
-
postcss.default.parse(css).walkDecls((decl) => {
|
|
1685
|
-
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1686
|
-
});
|
|
1687
|
-
} catch {}
|
|
1688
|
-
return values;
|
|
1689
|
-
}
|
|
1690
|
-
function mergeCustomPropertyValues(target, css) {
|
|
1691
|
-
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1692
|
-
}
|
|
1693
|
-
function seedIncrementalGenerateCache(options) {
|
|
1694
|
-
const cacheKey = createIncrementalGenerateCacheKey$1(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1695
|
-
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1696
|
-
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1697
|
-
incrementalGenerateCache$1.set(cacheKey, {
|
|
1698
|
-
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1699
|
-
classSet: new Set(options.generated.classSet),
|
|
1700
|
-
css: options.generated.css,
|
|
1701
|
-
rawCss: options.generated.rawCss,
|
|
1702
|
-
customPropertyValues,
|
|
1703
|
-
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1704
|
-
dependencies: options.generated.dependencies,
|
|
1705
|
-
sources: options.generated.sources,
|
|
1706
|
-
root: options.generated.root,
|
|
1707
|
-
target: options.generated.target
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
function parseImportSourceParam$1(params) {
|
|
1711
|
-
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
1712
|
-
if (!match) return;
|
|
1713
|
-
return {
|
|
1714
|
-
none: match[1] === "none",
|
|
1715
|
-
sourcePath: match[3]
|
|
1716
|
-
};
|
|
1717
|
-
}
|
|
1718
|
-
function isTailwindCssImport$1(params) {
|
|
1719
|
-
const specifier = parseCssImportSpecifier$2(params);
|
|
1720
|
-
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1721
|
-
}
|
|
1722
|
-
function parseCssImportSpecifier$2(params) {
|
|
1723
|
-
const value = params.trim();
|
|
1724
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1725
|
-
if (quoted) return quoted[2];
|
|
1726
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1727
|
-
return url?.[2] ?? url?.[3];
|
|
1728
|
-
}
|
|
1729
|
-
function isTailwindCssPreflightImport(params) {
|
|
1730
|
-
const specifier = parseCssImportSpecifier$2(params);
|
|
1731
|
-
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1732
|
-
}
|
|
1733
|
-
function hasImportLayerOption(params) {
|
|
1734
|
-
return /\blayer(?:\s*\(|\s*$)/.test(params);
|
|
1735
|
-
}
|
|
1736
|
-
function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
1737
|
-
if (!css.includes("preflight")) return css;
|
|
1738
|
-
let root;
|
|
1739
|
-
try {
|
|
1740
|
-
root = postcss.default.parse(css);
|
|
1741
|
-
} catch {
|
|
1742
|
-
return css;
|
|
1743
|
-
}
|
|
1744
|
-
let changed = false;
|
|
1745
|
-
root.walkAtRules("import", (rule) => {
|
|
1746
|
-
if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
|
|
1747
|
-
rule.remove();
|
|
1748
|
-
changed = true;
|
|
1749
|
-
}
|
|
1750
|
-
});
|
|
1751
|
-
return changed ? root.toString() : css;
|
|
1752
|
-
}
|
|
1753
|
-
function resolveSourceBase$1(base, sourcePath) {
|
|
1754
|
-
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
1755
|
-
}
|
|
1756
|
-
function createDefaultIgnoredScanSources(base) {
|
|
1757
|
-
return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
|
|
1758
|
-
base,
|
|
1759
|
-
pattern,
|
|
1760
|
-
negated: true
|
|
1761
|
-
}));
|
|
1762
|
-
}
|
|
1763
|
-
function normalizeCssDefinedScanSources(base, entries) {
|
|
1764
|
-
return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
|
|
1765
|
-
base,
|
|
1766
|
-
pattern: "**/*",
|
|
1767
|
-
negated: false
|
|
1768
|
-
}, ...entries] : entries;
|
|
1769
|
-
}
|
|
1770
|
-
async function resolveCssDefinedScanSources(source) {
|
|
1771
|
-
let importSourceBase;
|
|
1772
|
-
let hasSourceNone = false;
|
|
1773
|
-
const from = source.dependencies[0];
|
|
1774
|
-
let root;
|
|
1775
|
-
try {
|
|
1776
|
-
root = postcss.default.parse(source.css, { from });
|
|
1777
|
-
} catch {
|
|
1778
|
-
return;
|
|
1779
|
-
}
|
|
1780
|
-
root.walkAtRules((rule) => {
|
|
1781
|
-
if (rule.name === "import") {
|
|
1782
|
-
if (!isTailwindCssImport$1(rule.params)) return;
|
|
1783
|
-
const sourceParam = parseImportSourceParam$1(rule.params);
|
|
1784
|
-
if (sourceParam?.none) hasSourceNone = true;
|
|
1785
|
-
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase$1(source.base, sourceParam.sourcePath);
|
|
1786
|
-
}
|
|
1946
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1947
|
+
const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
|
|
1948
|
+
promise.catch(() => {
|
|
1949
|
+
if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
|
|
1787
1950
|
});
|
|
1788
|
-
|
|
1789
|
-
if (!importSourceBase) {
|
|
1790
|
-
if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
|
|
1791
|
-
if (hasSourceNone) return false;
|
|
1792
|
-
return;
|
|
1793
|
-
}
|
|
1794
|
-
return [
|
|
1795
|
-
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1796
|
-
...sourcePatterns,
|
|
1797
|
-
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1798
|
-
];
|
|
1951
|
+
return promise;
|
|
1799
1952
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
return
|
|
1953
|
+
function resolveTargetCandidates(candidates, target) {
|
|
1954
|
+
const collected = collectCandidates(candidates);
|
|
1955
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1803
1956
|
}
|
|
1804
|
-
function
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
return false;
|
|
1957
|
+
function collectSeenCandidates(generated, requestedCandidates) {
|
|
1958
|
+
return new Set([
|
|
1959
|
+
...requestedCandidates,
|
|
1960
|
+
...generated.rawCandidates,
|
|
1961
|
+
...generated.classSet
|
|
1962
|
+
]);
|
|
1811
1963
|
}
|
|
1812
|
-
function
|
|
1813
|
-
return
|
|
1964
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
1965
|
+
return {
|
|
1966
|
+
...styleOptions,
|
|
1967
|
+
isMainChunk: false
|
|
1968
|
+
};
|
|
1814
1969
|
}
|
|
1815
|
-
function
|
|
1816
|
-
|
|
1817
|
-
|
|
1970
|
+
function resolveStyleOptions$1(source, options) {
|
|
1971
|
+
return require_auto.hasCssMacroTailwindV4Directive(source.css) ? require_auto.withCssMacroStyleOptions(options) : options;
|
|
1972
|
+
}
|
|
1973
|
+
function collectCustomPropertyValues(css) {
|
|
1974
|
+
const values = /* @__PURE__ */ new Map();
|
|
1818
1975
|
try {
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1976
|
+
postcss.default.parse(css).walkDecls((decl) => {
|
|
1977
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1978
|
+
});
|
|
1979
|
+
} catch {}
|
|
1980
|
+
return values;
|
|
1981
|
+
}
|
|
1982
|
+
function mergeCustomPropertyValues(target, css) {
|
|
1983
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1984
|
+
}
|
|
1985
|
+
function seedIncrementalGenerateCache(options) {
|
|
1986
|
+
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1987
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1988
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1989
|
+
incrementalGenerateCache$1.set(cacheKey, {
|
|
1990
|
+
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1991
|
+
classSet: new Set(options.generated.classSet),
|
|
1992
|
+
css: options.generated.css,
|
|
1993
|
+
rawCss: options.generated.rawCss,
|
|
1994
|
+
customPropertyValues,
|
|
1995
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1996
|
+
dependencies: options.generated.dependencies,
|
|
1997
|
+
sources: options.generated.sources,
|
|
1998
|
+
root: options.generated.root,
|
|
1999
|
+
target: options.generated.target
|
|
1829
2000
|
});
|
|
1830
|
-
return changed ? root.toString() : css;
|
|
1831
2001
|
}
|
|
1832
2002
|
function createTailwindV4Engine(source) {
|
|
1833
2003
|
async function generateOnce(generateSource, options = {}) {
|
|
@@ -1835,8 +2005,8 @@ function createTailwindV4Engine(source) {
|
|
|
1835
2005
|
const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
|
|
1836
2006
|
const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
|
|
1837
2007
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1838
|
-
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { bareArbitraryValues: patchOptions.bareArbitraryValues })) : void 0;
|
|
1839
|
-
const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates
|
|
2008
|
+
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
2009
|
+
const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
|
|
1840
2010
|
const result = await engine.generate(omitUndefined({
|
|
1841
2011
|
scanSources: false,
|
|
1842
2012
|
...patchOptions,
|
|
@@ -1859,7 +2029,7 @@ function createTailwindV4Engine(source) {
|
|
|
1859
2029
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1860
2030
|
const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
|
|
1861
2031
|
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
|
|
1862
|
-
const cacheKey = createIncrementalGenerateCacheKey
|
|
2032
|
+
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
|
|
1863
2033
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1864
2034
|
const generated = await generateOnce(source, options);
|
|
1865
2035
|
seedIncrementalGenerateCache({
|
|
@@ -2048,109 +2218,48 @@ function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
|
2048
2218
|
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2049
2219
|
}
|
|
2050
2220
|
//#endregion
|
|
2051
|
-
//#region src/bundlers/shared/generator-css/directives.ts
|
|
2052
|
-
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
2053
|
-
"config",
|
|
2054
|
-
"custom-variant",
|
|
2055
|
-
"layer",
|
|
2056
|
-
"plugin",
|
|
2057
|
-
"reference",
|
|
2058
|
-
"source",
|
|
2059
|
-
"tailwind",
|
|
2060
|
-
"theme",
|
|
2061
|
-
"utility",
|
|
2062
|
-
"variant"
|
|
2063
|
-
]);
|
|
2064
|
-
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
2065
|
-
"config",
|
|
2066
|
-
"custom-variant",
|
|
2067
|
-
"plugin",
|
|
2068
|
-
"source",
|
|
2069
|
-
"tailwind",
|
|
2070
|
-
"theme",
|
|
2071
|
-
"utility",
|
|
2072
|
-
"variant"
|
|
2073
|
-
]);
|
|
2074
|
-
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
2221
|
+
//#region src/bundlers/shared/generator-css/directives/fallback.ts
|
|
2075
2222
|
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
2076
2223
|
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
2077
2224
|
const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
|
|
2078
|
-
|
|
2079
|
-
["tailwindcss/base", "base"],
|
|
2080
|
-
["tailwindcss/components", "components"],
|
|
2081
|
-
["tailwindcss/utilities", "utilities"]
|
|
2082
|
-
]);
|
|
2083
|
-
function parseImportRequest(params) {
|
|
2225
|
+
function parseImportRequest$1(params) {
|
|
2084
2226
|
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2085
2227
|
}
|
|
2086
|
-
function
|
|
2087
|
-
let found = false;
|
|
2088
|
-
try {
|
|
2089
|
-
postcss.default.parse(rawSource).walkAtRules("import", (rule) => {
|
|
2090
|
-
const request = parseImportRequest(rule.params);
|
|
2091
|
-
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
2092
|
-
found = true;
|
|
2093
|
-
return false;
|
|
2094
|
-
}
|
|
2095
|
-
});
|
|
2096
|
-
} catch {}
|
|
2097
|
-
return found;
|
|
2098
|
-
}
|
|
2099
|
-
function parseConfigRequest(params) {
|
|
2228
|
+
function parseConfigRequest$1(params) {
|
|
2100
2229
|
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2101
2230
|
}
|
|
2102
|
-
function isPackageJsonImportRequest(request) {
|
|
2231
|
+
function isPackageJsonImportRequest$1(request) {
|
|
2103
2232
|
return typeof request === "string" && request.startsWith("#");
|
|
2104
2233
|
}
|
|
2105
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
2234
|
+
function isWeappTailwindcssImportRequest$1(request) {
|
|
2106
2235
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2107
2236
|
}
|
|
2108
|
-
function
|
|
2109
|
-
|
|
2237
|
+
function isTailwindImportRequest$1(request) {
|
|
2238
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
2239
|
+
}
|
|
2240
|
+
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
2241
|
+
if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2110
2242
|
return request;
|
|
2111
2243
|
}
|
|
2112
|
-
function replaceImportRequest(params, request, replacement) {
|
|
2244
|
+
function replaceImportRequest$1(params, request, replacement) {
|
|
2113
2245
|
const index = params.indexOf(request);
|
|
2114
2246
|
if (index === -1) return params;
|
|
2115
2247
|
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2116
2248
|
}
|
|
2117
|
-
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
2118
|
-
if (!options.importFallback) return false;
|
|
2119
|
-
let changed = false;
|
|
2120
|
-
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
2121
|
-
root.walkAtRules("import", (node) => {
|
|
2122
|
-
const request = parseImportRequest(node.params);
|
|
2123
|
-
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2124
|
-
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
2125
|
-
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
2126
|
-
const normalizedKey = normalizedParams.trim();
|
|
2127
|
-
if (seenCanonicalImports.has(normalizedKey)) {
|
|
2128
|
-
node.remove();
|
|
2129
|
-
changed = true;
|
|
2130
|
-
return;
|
|
2131
|
-
}
|
|
2132
|
-
seenCanonicalImports.add(normalizedKey);
|
|
2133
|
-
if (normalizedParams !== node.params) {
|
|
2134
|
-
node.params = normalizedParams;
|
|
2135
|
-
changed = true;
|
|
2136
|
-
}
|
|
2137
|
-
});
|
|
2138
|
-
return changed;
|
|
2139
|
-
}
|
|
2140
2249
|
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
2141
2250
|
const trimmed = line.trimStart();
|
|
2142
2251
|
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
2143
|
-
const request = parseImportRequest(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
2144
|
-
if (isTailwindImportRequest(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
2145
|
-
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2146
|
-
return replaceImportRequest(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
2252
|
+
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
2253
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
|
|
2254
|
+
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
2255
|
+
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
2147
2256
|
}
|
|
2148
2257
|
return line;
|
|
2149
2258
|
}
|
|
2150
2259
|
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
2151
|
-
const request = parseImportRequest(trimmed.replace(/^@import\b/, ""));
|
|
2152
|
-
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
2153
|
-
return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
2260
|
+
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
2261
|
+
if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
|
|
2262
|
+
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
2154
2263
|
}
|
|
2155
2264
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
2156
2265
|
const directives = [];
|
|
@@ -2164,10 +2273,10 @@ function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
|
2164
2273
|
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
2165
2274
|
const normalizedTrimmed = normalized.trim();
|
|
2166
2275
|
if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
|
|
2167
|
-
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
2168
|
-
if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest(request)) continue;
|
|
2276
|
+
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
2277
|
+
if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
|
|
2169
2278
|
if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
|
|
2170
|
-
if (request && isTailwindImportRequest(request)) {
|
|
2279
|
+
if (request && isTailwindImportRequest$1(request)) {
|
|
2171
2280
|
const key = normalizedTrimmed;
|
|
2172
2281
|
if (seenImports.has(key)) continue;
|
|
2173
2282
|
seenImports.add(key);
|
|
@@ -2263,10 +2372,97 @@ function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
|
2263
2372
|
function extractConfigRequestFromSource(rawSource) {
|
|
2264
2373
|
for (const line of rawSource.split(/\r?\n/)) {
|
|
2265
2374
|
const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
|
|
2266
|
-
const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
|
|
2375
|
+
const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
|
|
2267
2376
|
if (request) return request;
|
|
2268
2377
|
}
|
|
2269
2378
|
}
|
|
2379
|
+
//#endregion
|
|
2380
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
2381
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
2382
|
+
"config",
|
|
2383
|
+
"custom-variant",
|
|
2384
|
+
"layer",
|
|
2385
|
+
"plugin",
|
|
2386
|
+
"reference",
|
|
2387
|
+
"source",
|
|
2388
|
+
"tailwind",
|
|
2389
|
+
"theme",
|
|
2390
|
+
"utility",
|
|
2391
|
+
"variant"
|
|
2392
|
+
]);
|
|
2393
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
2394
|
+
"config",
|
|
2395
|
+
"custom-variant",
|
|
2396
|
+
"plugin",
|
|
2397
|
+
"source",
|
|
2398
|
+
"tailwind",
|
|
2399
|
+
"theme",
|
|
2400
|
+
"utility",
|
|
2401
|
+
"variant"
|
|
2402
|
+
]);
|
|
2403
|
+
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
2404
|
+
const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
|
|
2405
|
+
["tailwindcss/base", "base"],
|
|
2406
|
+
["tailwindcss/components", "components"],
|
|
2407
|
+
["tailwindcss/utilities", "utilities"]
|
|
2408
|
+
]);
|
|
2409
|
+
function parseImportRequest(params) {
|
|
2410
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2411
|
+
}
|
|
2412
|
+
function hasLocalCssImport(rawSource) {
|
|
2413
|
+
let found = false;
|
|
2414
|
+
try {
|
|
2415
|
+
postcss.default.parse(rawSource).walkAtRules("import", (rule) => {
|
|
2416
|
+
const request = parseImportRequest(rule.params);
|
|
2417
|
+
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
2418
|
+
found = true;
|
|
2419
|
+
return false;
|
|
2420
|
+
}
|
|
2421
|
+
});
|
|
2422
|
+
} catch {}
|
|
2423
|
+
return found;
|
|
2424
|
+
}
|
|
2425
|
+
function parseConfigRequest(params) {
|
|
2426
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2427
|
+
}
|
|
2428
|
+
function isPackageJsonImportRequest(request) {
|
|
2429
|
+
return typeof request === "string" && request.startsWith("#");
|
|
2430
|
+
}
|
|
2431
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
2432
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2433
|
+
}
|
|
2434
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
2435
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2436
|
+
return request;
|
|
2437
|
+
}
|
|
2438
|
+
function replaceImportRequest(params, request, replacement) {
|
|
2439
|
+
const index = params.indexOf(request);
|
|
2440
|
+
if (index === -1) return params;
|
|
2441
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2442
|
+
}
|
|
2443
|
+
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
2444
|
+
if (!options.importFallback) return false;
|
|
2445
|
+
let changed = false;
|
|
2446
|
+
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
2447
|
+
root.walkAtRules("import", (node) => {
|
|
2448
|
+
const request = parseImportRequest(node.params);
|
|
2449
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2450
|
+
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
2451
|
+
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
2452
|
+
const normalizedKey = normalizedParams.trim();
|
|
2453
|
+
if (seenCanonicalImports.has(normalizedKey)) {
|
|
2454
|
+
node.remove();
|
|
2455
|
+
changed = true;
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
seenCanonicalImports.add(normalizedKey);
|
|
2459
|
+
if (normalizedParams !== node.params) {
|
|
2460
|
+
node.params = normalizedParams;
|
|
2461
|
+
changed = true;
|
|
2462
|
+
}
|
|
2463
|
+
});
|
|
2464
|
+
return changed;
|
|
2465
|
+
}
|
|
2270
2466
|
function resolveConfigPath$1(base, configPath) {
|
|
2271
2467
|
if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
|
|
2272
2468
|
return node_path.default.resolve(base, configPath);
|
|
@@ -2846,7 +3042,15 @@ function readStaticConfigContent(configPath) {
|
|
|
2846
3042
|
return parseStaticContentValue(source, contentProperty.start)?.value;
|
|
2847
3043
|
}
|
|
2848
3044
|
//#endregion
|
|
2849
|
-
//#region src/bundlers/vite/source-scan.ts
|
|
3045
|
+
//#region src/bundlers/vite/source-scan/dependencies.ts
|
|
3046
|
+
function addSourceScanDependency(dependencies, file) {
|
|
3047
|
+
if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
|
|
3048
|
+
}
|
|
3049
|
+
function addSourceScanDependencies(dependencies, files) {
|
|
3050
|
+
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
|
|
3051
|
+
}
|
|
3052
|
+
//#endregion
|
|
3053
|
+
//#region src/bundlers/vite/source-scan/css-entries.ts
|
|
2850
3054
|
const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
|
|
2851
3055
|
const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
|
|
2852
3056
|
const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
|
|
@@ -2883,23 +3087,6 @@ function createCssEntriesCacheKey(css, base, dependencies) {
|
|
|
2883
3087
|
dependencies
|
|
2884
3088
|
});
|
|
2885
3089
|
}
|
|
2886
|
-
function addSourceScanDependency(dependencies, file) {
|
|
2887
|
-
if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
|
|
2888
|
-
}
|
|
2889
|
-
function addSourceScanDependencies(dependencies, files) {
|
|
2890
|
-
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
|
|
2891
|
-
}
|
|
2892
|
-
function createResolvedViteSourceScan(input, dependencies) {
|
|
2893
|
-
return {
|
|
2894
|
-
...input,
|
|
2895
|
-
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
2896
|
-
};
|
|
2897
|
-
}
|
|
2898
|
-
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
2899
|
-
if (options.sourceCount <= 1) return entries;
|
|
2900
|
-
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
2901
|
-
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
2902
|
-
}
|
|
2903
3090
|
async function statConfigDependency(file) {
|
|
2904
3091
|
try {
|
|
2905
3092
|
const stats = await (0, node_fs_promises.stat)(file);
|
|
@@ -3113,6 +3300,26 @@ async function discoverTailwindV4CssEntries(root, outDir) {
|
|
|
3113
3300
|
function collectConfiguredCssSources(options) {
|
|
3114
3301
|
return [...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? []];
|
|
3115
3302
|
}
|
|
3303
|
+
//#endregion
|
|
3304
|
+
//#region src/bundlers/vite/source-scan.ts
|
|
3305
|
+
function createResolvedViteSourceScan(input, dependencies) {
|
|
3306
|
+
return {
|
|
3307
|
+
...input,
|
|
3308
|
+
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
3312
|
+
if (options.sourceCount <= 1) return entries;
|
|
3313
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
3314
|
+
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
3315
|
+
}
|
|
3316
|
+
function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
|
|
3317
|
+
return {
|
|
3318
|
+
entries: explicit ? entries : entries.length > 0 ? entries : void 0,
|
|
3319
|
+
explicit,
|
|
3320
|
+
inlineCandidates
|
|
3321
|
+
};
|
|
3322
|
+
}
|
|
3116
3323
|
async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
|
|
3117
3324
|
if (patcher.majorVersion === 3) {
|
|
3118
3325
|
const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
|
|
@@ -3164,11 +3371,7 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
3164
3371
|
}, dependencies);
|
|
3165
3372
|
if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
|
|
3166
3373
|
const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
3167
|
-
return resolved ? createResolvedViteSourceScan(
|
|
3168
|
-
entries: resolved.explicit ? resolved.entries : resolved.entries.length > 0 ? resolved.entries : void 0,
|
|
3169
|
-
explicit: resolved.explicit,
|
|
3170
|
-
inlineCandidates: resolved.inlineCandidates
|
|
3171
|
-
}, new Set(resolved.dependencies)) : void 0;
|
|
3374
|
+
return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set(resolved.dependencies)) : void 0;
|
|
3172
3375
|
}
|
|
3173
3376
|
const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
|
|
3174
3377
|
const configuredCssSources = collectConfiguredCssSources(options);
|
|
@@ -3195,11 +3398,7 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
3195
3398
|
addSourceScanDependency(dependencies, source.file);
|
|
3196
3399
|
addSourceScanDependencies(dependencies, source.dependencies);
|
|
3197
3400
|
const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
|
|
3198
|
-
return resolved ? createResolvedViteSourceScan(
|
|
3199
|
-
entries: resolved.explicit ? resolved.entries : resolved.entries.length > 0 ? resolved.entries : void 0,
|
|
3200
|
-
explicit: resolved.explicit,
|
|
3201
|
-
inlineCandidates: resolved.inlineCandidates
|
|
3202
|
-
}, new Set([...dependencies, ...resolved.dependencies])) : void 0;
|
|
3401
|
+
return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set([...dependencies, ...resolved.dependencies])) : void 0;
|
|
3203
3402
|
}
|
|
3204
3403
|
}
|
|
3205
3404
|
function createViteSourceScanMatcher(entries) {
|
|
@@ -3413,6 +3612,40 @@ async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
|
|
|
3413
3612
|
return task;
|
|
3414
3613
|
}
|
|
3415
3614
|
//#endregion
|
|
3615
|
+
//#region src/tailwindcss/v3-engine/generator/runtime-ready.ts
|
|
3616
|
+
const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
|
|
3617
|
+
function createRuntimeReadyCacheKey(source, rootPath) {
|
|
3618
|
+
return [
|
|
3619
|
+
source.packageName,
|
|
3620
|
+
source.postcssPlugin,
|
|
3621
|
+
rootPath ?? "missing",
|
|
3622
|
+
source.config ?? "config:missing",
|
|
3623
|
+
source.cwd
|
|
3624
|
+
].join("\0");
|
|
3625
|
+
}
|
|
3626
|
+
function createRuntimeReadyPromise(source) {
|
|
3627
|
+
const patcher = createTailwindcssPatcher({
|
|
3628
|
+
basedir: source.cwd,
|
|
3629
|
+
supportCustomLengthUnitsPatch: true,
|
|
3630
|
+
tailwindcss: {
|
|
3631
|
+
...source.config === void 0 ? {} : { config: source.config },
|
|
3632
|
+
cwd: source.cwd,
|
|
3633
|
+
packageName: source.packageName,
|
|
3634
|
+
postcssPlugin: source.postcssPlugin,
|
|
3635
|
+
version: 3
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
|
|
3639
|
+
const cached = runtimeReadyPromiseCache.get(cacheKey);
|
|
3640
|
+
if (cached) return cached;
|
|
3641
|
+
const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
|
|
3642
|
+
runtimeReadyPromiseCache.delete(cacheKey);
|
|
3643
|
+
throw error;
|
|
3644
|
+
});
|
|
3645
|
+
runtimeReadyPromiseCache.set(cacheKey, task);
|
|
3646
|
+
return task;
|
|
3647
|
+
}
|
|
3648
|
+
//#endregion
|
|
3416
3649
|
//#region src/tailwindcss/v3-engine/miniprogram.ts
|
|
3417
3650
|
const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
3418
3651
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
@@ -3494,33 +3727,7 @@ async function transformTailwindV3CssByTarget(css, target, options) {
|
|
|
3494
3727
|
}
|
|
3495
3728
|
//#endregion
|
|
3496
3729
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
3497
|
-
const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
|
|
3498
3730
|
const incrementalGenerateCache = /* @__PURE__ */ new Map();
|
|
3499
|
-
function isLegacyContentObject(value) {
|
|
3500
|
-
return typeof value === "object" && value !== null && "files" in value;
|
|
3501
|
-
}
|
|
3502
|
-
function createRawContentEntries(candidates, sources) {
|
|
3503
|
-
const entries = [];
|
|
3504
|
-
const candidateContent = [...candidates].join(" ");
|
|
3505
|
-
if (candidateContent.length > 0) entries.push({
|
|
3506
|
-
raw: candidateContent,
|
|
3507
|
-
extension: "html"
|
|
3508
|
-
});
|
|
3509
|
-
for (const source of sources) entries.push({
|
|
3510
|
-
raw: source.content,
|
|
3511
|
-
extension: source.extension ?? "html"
|
|
3512
|
-
});
|
|
3513
|
-
return entries;
|
|
3514
|
-
}
|
|
3515
|
-
function createChangedContentEntries(candidates, sources) {
|
|
3516
|
-
return createRawContentEntries(candidates, sources).map((entry) => ({
|
|
3517
|
-
content: entry.raw,
|
|
3518
|
-
extension: entry.extension
|
|
3519
|
-
}));
|
|
3520
|
-
}
|
|
3521
|
-
function collectCandidates(candidates) {
|
|
3522
|
-
return new Set(candidates ?? []);
|
|
3523
|
-
}
|
|
3524
3731
|
function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
|
|
3525
3732
|
return (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
|
|
3526
3733
|
}
|
|
@@ -3540,7 +3747,7 @@ function normalizeBareArbitraryValueCandidates(candidates, bareArbitraryValues)
|
|
|
3540
3747
|
async function collectSourceBareArbitraryValueCandidates(sources, bareArbitraryValues) {
|
|
3541
3748
|
if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return [];
|
|
3542
3749
|
const candidates = /* @__PURE__ */ new Set();
|
|
3543
|
-
for (const source of sources ?? []) for (const candidate of await (0, tailwindcss_patch.extractSourceCandidates)(source.content, source.extension ?? "html", { bareArbitraryValues })) if ((0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)) candidates.add(candidate);
|
|
3750
|
+
for (const source of sources ?? []) for (const candidate of await (0, tailwindcss_patch.extractSourceCandidates)(source.content, source.extension ?? "html", omitUndefined({ bareArbitraryValues }))) if ((0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)) candidates.add(candidate);
|
|
3544
3751
|
return [...candidates];
|
|
3545
3752
|
}
|
|
3546
3753
|
function escapeCssClassSelector(className) {
|
|
@@ -3576,99 +3783,6 @@ function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
|
3576
3783
|
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
3577
3784
|
return false;
|
|
3578
3785
|
}
|
|
3579
|
-
function collectApplyCandidatesFromCss(css) {
|
|
3580
|
-
if (!css.includes("@apply")) return [];
|
|
3581
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
3582
|
-
try {
|
|
3583
|
-
postcss.default.parse(css).walkAtRules("apply", (rule) => {
|
|
3584
|
-
for (const candidate of rule.params.split(/\s+/)) {
|
|
3585
|
-
const normalized = candidate.replace(/!important$/, "").trim();
|
|
3586
|
-
if (normalized) candidates.add(normalized);
|
|
3587
|
-
}
|
|
3588
|
-
});
|
|
3589
|
-
} catch {}
|
|
3590
|
-
return [...candidates];
|
|
3591
|
-
}
|
|
3592
|
-
function isTailwindCandidateLayer(params) {
|
|
3593
|
-
return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
|
|
3594
|
-
}
|
|
3595
|
-
function extractClassCandidatesFromSelector(selector, candidates) {
|
|
3596
|
-
for (let index = 0; index < selector.length; index++) {
|
|
3597
|
-
if (selector[index] !== ".") continue;
|
|
3598
|
-
let candidate = "";
|
|
3599
|
-
let escaped = false;
|
|
3600
|
-
for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
|
|
3601
|
-
const char = selector[tokenIndex];
|
|
3602
|
-
if (escaped) {
|
|
3603
|
-
candidate += char;
|
|
3604
|
-
escaped = false;
|
|
3605
|
-
continue;
|
|
3606
|
-
}
|
|
3607
|
-
if (char === "\\") {
|
|
3608
|
-
escaped = true;
|
|
3609
|
-
continue;
|
|
3610
|
-
}
|
|
3611
|
-
if (char && /[\w-]/.test(char)) {
|
|
3612
|
-
candidate += char;
|
|
3613
|
-
continue;
|
|
3614
|
-
}
|
|
3615
|
-
break;
|
|
3616
|
-
}
|
|
3617
|
-
if (candidate) candidates.add(candidate);
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
function collectLayerCandidatesFromCss(css) {
|
|
3621
|
-
if (!css.includes("@layer")) return [];
|
|
3622
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
3623
|
-
try {
|
|
3624
|
-
postcss.default.parse(css).walkAtRules("layer", (layer) => {
|
|
3625
|
-
if (!isTailwindCandidateLayer(layer.params)) return;
|
|
3626
|
-
layer.walkRules((rule) => {
|
|
3627
|
-
extractClassCandidatesFromSelector(rule.selector, candidates);
|
|
3628
|
-
});
|
|
3629
|
-
});
|
|
3630
|
-
} catch {}
|
|
3631
|
-
return [...candidates];
|
|
3632
|
-
}
|
|
3633
|
-
function mergeGenerateCandidates(source, options) {
|
|
3634
|
-
return collectCandidates([
|
|
3635
|
-
...collectLayerCandidatesFromCss(source.css),
|
|
3636
|
-
...collectApplyCandidatesFromCss(source.css),
|
|
3637
|
-
...collectCandidates(options.candidates)
|
|
3638
|
-
]);
|
|
3639
|
-
}
|
|
3640
|
-
function mergeContent(content, rawEntries) {
|
|
3641
|
-
if (isLegacyContentObject(content)) return {
|
|
3642
|
-
...content,
|
|
3643
|
-
relative: content.relative ?? true,
|
|
3644
|
-
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
3645
|
-
};
|
|
3646
|
-
return {
|
|
3647
|
-
relative: true,
|
|
3648
|
-
files: [...[].concat(content ?? []), ...rawEntries]
|
|
3649
|
-
};
|
|
3650
|
-
}
|
|
3651
|
-
function normalizeConfigObject(config) {
|
|
3652
|
-
if (!config || typeof config !== "object") return config;
|
|
3653
|
-
const maybeDefault = config.default;
|
|
3654
|
-
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
3655
|
-
return config;
|
|
3656
|
-
}
|
|
3657
|
-
function hasExplicitContentInput(options) {
|
|
3658
|
-
return options.candidates !== void 0 || options.sources !== void 0;
|
|
3659
|
-
}
|
|
3660
|
-
function createExplicitContentConfig(rawEntries) {
|
|
3661
|
-
return {
|
|
3662
|
-
relative: true,
|
|
3663
|
-
files: rawEntries
|
|
3664
|
-
};
|
|
3665
|
-
}
|
|
3666
|
-
function createTailwindConfig(source, options) {
|
|
3667
|
-
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
3668
|
-
const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
|
|
3669
|
-
config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
|
|
3670
|
-
return config;
|
|
3671
|
-
}
|
|
3672
3786
|
function shouldAutoEnableCssMacro(source) {
|
|
3673
3787
|
return require_auto.hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
|
|
3674
3788
|
}
|
|
@@ -3708,48 +3822,6 @@ function loadTailwindV3Internals(source) {
|
|
|
3708
3822
|
validateConfig: validateConfigModule["validateConfig"]
|
|
3709
3823
|
};
|
|
3710
3824
|
}
|
|
3711
|
-
function createStableJson(value) {
|
|
3712
|
-
if (value === void 0) return "undefined";
|
|
3713
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
3714
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
3715
|
-
return `{${Object.keys(value).sort().map((key) => {
|
|
3716
|
-
const record = value;
|
|
3717
|
-
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
3718
|
-
}).join(",")}}`;
|
|
3719
|
-
}
|
|
3720
|
-
function createDependencyFingerprint(files) {
|
|
3721
|
-
return files.map((file) => {
|
|
3722
|
-
try {
|
|
3723
|
-
const stat = node_fs.default.statSync(file);
|
|
3724
|
-
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
3725
|
-
} catch {
|
|
3726
|
-
return `${file}:missing`;
|
|
3727
|
-
}
|
|
3728
|
-
}).join("|");
|
|
3729
|
-
}
|
|
3730
|
-
function createIncrementalGenerateCacheKey(source, target, styleOptions, bareArbitraryValues) {
|
|
3731
|
-
return [
|
|
3732
|
-
source.packageName,
|
|
3733
|
-
source.postcssPlugin,
|
|
3734
|
-
source.cwd,
|
|
3735
|
-
source.config ?? "config:missing",
|
|
3736
|
-
createDependencyFingerprint(source.dependencies),
|
|
3737
|
-
source.css,
|
|
3738
|
-
createStableJson(normalizeConfigObject(source.configObject)?.content),
|
|
3739
|
-
target,
|
|
3740
|
-
createStableJson(styleOptions),
|
|
3741
|
-
createStableJson(bareArbitraryValues)
|
|
3742
|
-
].join("\0");
|
|
3743
|
-
}
|
|
3744
|
-
function createRuntimeReadyCacheKey(source, rootPath) {
|
|
3745
|
-
return [
|
|
3746
|
-
source.packageName,
|
|
3747
|
-
source.postcssPlugin,
|
|
3748
|
-
rootPath ?? "missing",
|
|
3749
|
-
source.config ?? "config:missing",
|
|
3750
|
-
source.cwd
|
|
3751
|
-
].join("\0");
|
|
3752
|
-
}
|
|
3753
3825
|
function isDirectUtilitiesOnlyCss(css) {
|
|
3754
3826
|
return css.replace(/\s+/g, "") === "@tailwindutilities;";
|
|
3755
3827
|
}
|
|
@@ -3782,28 +3854,6 @@ function appendUtilityRules(root, context, rules) {
|
|
|
3782
3854
|
function appendDirectUtilityRules(root, context) {
|
|
3783
3855
|
appendUtilityRules(root, context, [...context.ruleCache]);
|
|
3784
3856
|
}
|
|
3785
|
-
function createRuntimeReadyPromise(source) {
|
|
3786
|
-
const patcher = createTailwindcssPatcher({
|
|
3787
|
-
basedir: source.cwd,
|
|
3788
|
-
supportCustomLengthUnitsPatch: true,
|
|
3789
|
-
tailwindcss: {
|
|
3790
|
-
...source.config === void 0 ? {} : { config: source.config },
|
|
3791
|
-
cwd: source.cwd,
|
|
3792
|
-
packageName: source.packageName,
|
|
3793
|
-
postcssPlugin: source.postcssPlugin,
|
|
3794
|
-
version: 3
|
|
3795
|
-
}
|
|
3796
|
-
});
|
|
3797
|
-
const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
|
|
3798
|
-
const cached = runtimeReadyPromiseCache.get(cacheKey);
|
|
3799
|
-
if (cached) return cached;
|
|
3800
|
-
const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
|
|
3801
|
-
runtimeReadyPromiseCache.delete(cacheKey);
|
|
3802
|
-
throw error;
|
|
3803
|
-
});
|
|
3804
|
-
runtimeReadyPromiseCache.set(cacheKey, task);
|
|
3805
|
-
return task;
|
|
3806
|
-
}
|
|
3807
3857
|
function createTailwindV3Engine(source) {
|
|
3808
3858
|
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
3809
3859
|
let tailwindInternals;
|
|
@@ -3889,7 +3939,7 @@ function createTailwindV3Engine(source) {
|
|
|
3889
3939
|
const requestedCandidates = mergeGenerateCandidates(source, options);
|
|
3890
3940
|
if (requestedCandidates.size === 0) return generateOnce(source, options);
|
|
3891
3941
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
3892
|
-
const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions, options.bareArbitraryValues);
|
|
3942
|
+
const cacheKey = createIncrementalGenerateCacheKey$1(source, target, styleOptions, options.bareArbitraryValues);
|
|
3893
3943
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
3894
3944
|
if (cached) {
|
|
3895
3945
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
|