weapp-tailwindcss 5.0.6 → 5.0.8
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-CdNXQl-o.mjs → bundle-state-5FtFktJr.mjs} +2 -1
- package/dist/{bundle-state-CFgzVHFP.js → bundle-state-cHwTyrOS.js} +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 +71 -69
- package/dist/cli.mjs +71 -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-C--TrAod.js} +1 -1
- package/dist/{generator-Bgn4m8An.mjs → generator-DnwUQOXB.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp-5Tan5bHG.js +473 -0
- package/dist/gulp-B22YSGU_.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-CscCNKb9.js} +1205 -449
- package/dist/{incremental-runtime-class-set-BEYHQkZc.mjs → hmr-timing-DK-mine6.mjs} +1169 -467
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{postcss-BgINK7Nm.mjs → postcss-CjWuDZwL.mjs} +4 -4
- package/dist/{postcss-B7QNe78h.js → postcss-R5pDVHUy.js} +7 -7
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-CyPbGn38.js → precheck-B8y6tDvG.js} +19 -5
- package/dist/{precheck-Copn2SqE.mjs → precheck-CcxTR7E_.mjs} +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-0DaftXcU.mjs} +2 -2
- package/dist/{tailwindcss-Tw6CSVHL.js → tailwindcss-DbZ4o4m_.js} +2 -2
- package/dist/{transform-DgCFGtQR.mjs → transform-DRyWUN5X.mjs} +11 -2
- package/dist/{transform-95ivJthq.js → transform-DiW_u3eD.js} +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-Ji6AXPh2.mjs → v3-engine-ArQVHEau.mjs} +786 -699
- package/dist/{v3-engine-6FVAcrZl.js → v3-engine-DdlvXpID.js} +788 -701
- package/dist/{vite-Bw6LOXvf.js → vite-C_IUnDBy.js} +1797 -386
- package/dist/{vite-ChZ2cbn4.mjs → vite-_iUhzc4t.mjs} +1779 -369
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +1148 -987
- package/dist/{webpack-CMJ7iqN7.mjs → webpack-CqnI4Ymw.mjs} +104 -37
- package/dist/{webpack-nn3P8_S_.js → webpack-KLoTb5Dr.js} +113 -45
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -5
- package/dist/source-candidates-BODCmzz5.mjs +0 -355
- package/dist/source-candidates-Caf2GDvx.js +0 -374
|
@@ -1,13 +1,14 @@
|
|
|
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");
|
|
7
|
+
tailwindcss_patch = require_chunk.__toESM(tailwindcss_patch);
|
|
9
8
|
let node_process = require("node:process");
|
|
10
9
|
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let node_fs = require("node:fs");
|
|
11
|
+
node_fs = require_chunk.__toESM(node_fs);
|
|
11
12
|
let node_path = require("node:path");
|
|
12
13
|
node_path = require_chunk.__toESM(node_path);
|
|
13
14
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
@@ -16,12 +17,175 @@ let node_url = require("node:url");
|
|
|
16
17
|
let debug = require("debug");
|
|
17
18
|
debug = require_chunk.__toESM(debug);
|
|
18
19
|
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
20
|
let micromatch = require("micromatch");
|
|
23
21
|
micromatch = require_chunk.__toESM(micromatch);
|
|
24
22
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
23
|
+
let fast_glob = require("fast-glob");
|
|
24
|
+
fast_glob = require_chunk.__toESM(fast_glob);
|
|
25
|
+
let tailwindcss_config = require("tailwindcss-config");
|
|
26
|
+
//#region src/utils/object.ts
|
|
27
|
+
function definedEntries(value) {
|
|
28
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
29
|
+
}
|
|
30
|
+
function omitUndefined(value) {
|
|
31
|
+
return Object.fromEntries(definedEntries(value));
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/tailwindcss/v3-engine/generator/content.ts
|
|
35
|
+
function isLegacyContentObject$1(value) {
|
|
36
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
37
|
+
}
|
|
38
|
+
function createRawContentEntries(candidates, sources) {
|
|
39
|
+
const entries = [];
|
|
40
|
+
const candidateContent = [...candidates].join(" ");
|
|
41
|
+
if (candidateContent.length > 0) entries.push({
|
|
42
|
+
raw: candidateContent,
|
|
43
|
+
extension: "html"
|
|
44
|
+
});
|
|
45
|
+
for (const source of sources) entries.push({
|
|
46
|
+
raw: source.content,
|
|
47
|
+
extension: source.extension ?? "html"
|
|
48
|
+
});
|
|
49
|
+
return entries;
|
|
50
|
+
}
|
|
51
|
+
function createChangedContentEntries(candidates, sources) {
|
|
52
|
+
return createRawContentEntries(candidates, sources).map((entry) => ({
|
|
53
|
+
content: entry.raw,
|
|
54
|
+
extension: entry.extension
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
function collectCandidates$1(candidates) {
|
|
58
|
+
return new Set(candidates ?? []);
|
|
59
|
+
}
|
|
60
|
+
function collectApplyCandidatesFromCss(css) {
|
|
61
|
+
if (!css.includes("@apply")) return [];
|
|
62
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
63
|
+
try {
|
|
64
|
+
postcss.default.parse(css).walkAtRules("apply", (rule) => {
|
|
65
|
+
for (const candidate of rule.params.split(/\s+/)) {
|
|
66
|
+
const normalized = candidate.replace(/!important$/, "").trim();
|
|
67
|
+
if (normalized) candidates.add(normalized);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} catch {}
|
|
71
|
+
return [...candidates];
|
|
72
|
+
}
|
|
73
|
+
function isTailwindCandidateLayer(params) {
|
|
74
|
+
return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
|
|
75
|
+
}
|
|
76
|
+
function extractClassCandidatesFromSelector(selector, candidates) {
|
|
77
|
+
for (let index = 0; index < selector.length; index++) {
|
|
78
|
+
if (selector[index] !== ".") continue;
|
|
79
|
+
let candidate = "";
|
|
80
|
+
let escaped = false;
|
|
81
|
+
for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
|
|
82
|
+
const char = selector[tokenIndex];
|
|
83
|
+
if (escaped) {
|
|
84
|
+
candidate += char;
|
|
85
|
+
escaped = false;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (char === "\\") {
|
|
89
|
+
escaped = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (char && /[\w-]/.test(char)) {
|
|
93
|
+
candidate += char;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (candidate) candidates.add(candidate);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function collectLayerCandidatesFromCss(css) {
|
|
102
|
+
if (!css.includes("@layer")) return [];
|
|
103
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
104
|
+
try {
|
|
105
|
+
postcss.default.parse(css).walkAtRules("layer", (layer) => {
|
|
106
|
+
if (!isTailwindCandidateLayer(layer.params)) return;
|
|
107
|
+
layer.walkRules((rule) => {
|
|
108
|
+
extractClassCandidatesFromSelector(rule.selector, candidates);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
} catch {}
|
|
112
|
+
return [...candidates];
|
|
113
|
+
}
|
|
114
|
+
function mergeGenerateCandidates(source, options) {
|
|
115
|
+
return collectCandidates$1([
|
|
116
|
+
...collectLayerCandidatesFromCss(source.css),
|
|
117
|
+
...collectApplyCandidatesFromCss(source.css),
|
|
118
|
+
...collectCandidates$1(options.candidates)
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
function mergeContent(content, rawEntries) {
|
|
122
|
+
if (isLegacyContentObject$1(content)) return {
|
|
123
|
+
...content,
|
|
124
|
+
relative: content.relative ?? true,
|
|
125
|
+
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
relative: true,
|
|
129
|
+
files: [...[].concat(content ?? []), ...rawEntries]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function normalizeConfigObject(config) {
|
|
133
|
+
if (!config || typeof config !== "object") return config;
|
|
134
|
+
const maybeDefault = config.default;
|
|
135
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
136
|
+
return config;
|
|
137
|
+
}
|
|
138
|
+
function hasExplicitContentInput(options) {
|
|
139
|
+
return options.candidates !== void 0 || options.sources !== void 0;
|
|
140
|
+
}
|
|
141
|
+
function createExplicitContentConfig(rawEntries) {
|
|
142
|
+
return {
|
|
143
|
+
relative: true,
|
|
144
|
+
files: rawEntries
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function createTailwindConfig(source, options) {
|
|
148
|
+
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
149
|
+
const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
|
|
150
|
+
config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
|
|
151
|
+
return config;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/tailwindcss/v3-engine/generator/cache-key.ts
|
|
155
|
+
function createStableJson$1(value) {
|
|
156
|
+
if (value === void 0) return "undefined";
|
|
157
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
158
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
|
|
159
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
160
|
+
const record = value;
|
|
161
|
+
return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
|
|
162
|
+
}).join(",")}}`;
|
|
163
|
+
}
|
|
164
|
+
function createDependencyFingerprint$1(files) {
|
|
165
|
+
return files.map((file) => {
|
|
166
|
+
try {
|
|
167
|
+
const stat = node_fs.default.statSync(file);
|
|
168
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
169
|
+
} catch {
|
|
170
|
+
return `${file}:missing`;
|
|
171
|
+
}
|
|
172
|
+
}).join("|");
|
|
173
|
+
}
|
|
174
|
+
function createIncrementalGenerateCacheKey$1(source, target, styleOptions, bareArbitraryValues) {
|
|
175
|
+
return [
|
|
176
|
+
source.packageName,
|
|
177
|
+
source.postcssPlugin,
|
|
178
|
+
source.cwd,
|
|
179
|
+
source.config ?? "config:missing",
|
|
180
|
+
createDependencyFingerprint$1(source.dependencies),
|
|
181
|
+
source.css,
|
|
182
|
+
createStableJson$1(normalizeConfigObject(source.configObject)?.content),
|
|
183
|
+
target,
|
|
184
|
+
createStableJson$1(styleOptions),
|
|
185
|
+
createStableJson$1(bareArbitraryValues)
|
|
186
|
+
].join("\0");
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
25
189
|
//#region src/context/workspace.ts
|
|
26
190
|
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
27
191
|
"node_modules",
|
|
@@ -81,14 +245,6 @@ function findWorkspacePackageDir(rootDir, packageName) {
|
|
|
81
245
|
}
|
|
82
246
|
}
|
|
83
247
|
//#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
248
|
//#region src/utils/options.ts
|
|
93
249
|
function resolveBooleanObjectOption(value, enabledValue) {
|
|
94
250
|
if (!value) return false;
|
|
@@ -311,7 +467,7 @@ function createTailwindcssPatcher(options) {
|
|
|
311
467
|
const resolvedTailwindOptions = resolvedOptions.tailwindcss;
|
|
312
468
|
if (resolvedTailwindOptions) {
|
|
313
469
|
const existingResolve = resolvedTailwindOptions.resolve ?? {};
|
|
314
|
-
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths, ...resolvePaths] : resolvePaths;
|
|
470
|
+
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths ?? [], ...resolvePaths] : resolvePaths;
|
|
315
471
|
resolvedTailwindOptions.resolve = {
|
|
316
472
|
...existingResolve,
|
|
317
473
|
paths: [...new Set(sourcePaths)]
|
|
@@ -373,140 +529,8 @@ function createDebug(prefix) {
|
|
|
373
529
|
return debug$2;
|
|
374
530
|
}
|
|
375
531
|
//#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
|
-
}
|
|
532
|
+
//#region src/tailwindcss/source-scan/inline-source.ts
|
|
478
533
|
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
534
|
function segmentTopLevel(input, separator, options = {}) {
|
|
511
535
|
const parts = [];
|
|
512
536
|
const stack = [];
|
|
@@ -633,6 +657,140 @@ function collectCssInlineSourceCandidates(root) {
|
|
|
633
657
|
excluded
|
|
634
658
|
};
|
|
635
659
|
}
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/tailwindcss/source-scan.ts
|
|
662
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
663
|
+
"html",
|
|
664
|
+
"wxml",
|
|
665
|
+
"axml",
|
|
666
|
+
"jxml",
|
|
667
|
+
"ksml",
|
|
668
|
+
"ttml",
|
|
669
|
+
"qml",
|
|
670
|
+
"tyml",
|
|
671
|
+
"xhsml",
|
|
672
|
+
"swan",
|
|
673
|
+
"vue",
|
|
674
|
+
"mpx",
|
|
675
|
+
"js",
|
|
676
|
+
"jsx",
|
|
677
|
+
"ts",
|
|
678
|
+
"tsx"
|
|
679
|
+
];
|
|
680
|
+
const FULL_SOURCE_SCAN_EXTENSIONS = [
|
|
681
|
+
"js",
|
|
682
|
+
"jsx",
|
|
683
|
+
"mjs",
|
|
684
|
+
"cjs",
|
|
685
|
+
"ts",
|
|
686
|
+
"tsx",
|
|
687
|
+
"mts",
|
|
688
|
+
"cts",
|
|
689
|
+
"vue",
|
|
690
|
+
"uvue",
|
|
691
|
+
"nvue",
|
|
692
|
+
"svelte",
|
|
693
|
+
"mpx",
|
|
694
|
+
"html",
|
|
695
|
+
"wxml",
|
|
696
|
+
"axml",
|
|
697
|
+
"jxml",
|
|
698
|
+
"ksml",
|
|
699
|
+
"ttml",
|
|
700
|
+
"qml",
|
|
701
|
+
"tyml",
|
|
702
|
+
"xhsml",
|
|
703
|
+
"swan",
|
|
704
|
+
"css",
|
|
705
|
+
"wxss",
|
|
706
|
+
"acss",
|
|
707
|
+
"jxss",
|
|
708
|
+
"ttss",
|
|
709
|
+
"qss",
|
|
710
|
+
"tyss",
|
|
711
|
+
"scss",
|
|
712
|
+
"sass",
|
|
713
|
+
"less",
|
|
714
|
+
"styl",
|
|
715
|
+
"stylus"
|
|
716
|
+
];
|
|
717
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
718
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
719
|
+
}
|
|
720
|
+
const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
|
|
721
|
+
const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
|
|
722
|
+
function toPosixPath(value) {
|
|
723
|
+
return value.split(node_path.default.sep).join("/");
|
|
724
|
+
}
|
|
725
|
+
function resolveSourceScanPath(value) {
|
|
726
|
+
const resolved = node_path.default.resolve(value);
|
|
727
|
+
try {
|
|
728
|
+
return node_fs.realpathSync.native(resolved);
|
|
729
|
+
} catch {
|
|
730
|
+
return resolved;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
function normalizeEntryPattern(entry) {
|
|
734
|
+
return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
|
|
735
|
+
}
|
|
736
|
+
function isFileMatchedByTailwindSourceEntry(file, entry) {
|
|
737
|
+
const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
|
|
738
|
+
return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
|
|
739
|
+
}
|
|
740
|
+
function isFileExcludedByTailwindSourceEntries(file, entries) {
|
|
741
|
+
if (!entries?.length) return false;
|
|
742
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
743
|
+
return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
744
|
+
}
|
|
745
|
+
function isFileMatchedByTailwindSourceEntries(file, entries) {
|
|
746
|
+
if (!entries?.length) return true;
|
|
747
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
748
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
749
|
+
const resolvedFile = resolveSourceScanPath(file);
|
|
750
|
+
if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
751
|
+
if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
|
|
752
|
+
return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
|
|
753
|
+
}
|
|
754
|
+
function createTailwindSourceEntryMatcher(entries) {
|
|
755
|
+
if (!entries?.length) return;
|
|
756
|
+
return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
|
|
757
|
+
}
|
|
758
|
+
function resolveTailwindV4CssSourceBase(source, fallbackBase) {
|
|
759
|
+
if (typeof source.base === "string" && source.base.length > 0) return source.base;
|
|
760
|
+
if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
|
|
761
|
+
return fallbackBase;
|
|
762
|
+
}
|
|
763
|
+
function parseConfigParam$1(params) {
|
|
764
|
+
const value = params.trim();
|
|
765
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
766
|
+
}
|
|
767
|
+
function isLegacyContentObject(value) {
|
|
768
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
769
|
+
}
|
|
770
|
+
function normalizeGlobPattern(pattern) {
|
|
771
|
+
return pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
772
|
+
}
|
|
773
|
+
function hasGlobMagic(value) {
|
|
774
|
+
return /[*?[\]{}()!+@]/.test(value);
|
|
775
|
+
}
|
|
776
|
+
function splitStaticGlobPrefix(pattern) {
|
|
777
|
+
const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
|
|
778
|
+
const prefix = [];
|
|
779
|
+
const rest = [];
|
|
780
|
+
let reachedGlob = false;
|
|
781
|
+
for (const segment of segments) {
|
|
782
|
+
if (!reachedGlob && segment && !hasGlobMagic(segment)) {
|
|
783
|
+
prefix.push(segment);
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
reachedGlob = true;
|
|
787
|
+
rest.push(segment);
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
prefix,
|
|
791
|
+
rest
|
|
792
|
+
};
|
|
793
|
+
}
|
|
636
794
|
function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
637
795
|
if (typeof content === "string") {
|
|
638
796
|
const negated = content.startsWith("!");
|
|
@@ -643,7 +801,7 @@ function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
|
643
801
|
}];
|
|
644
802
|
}
|
|
645
803
|
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
|
|
646
|
-
if (isLegacyContentObject
|
|
804
|
+
if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
|
|
647
805
|
return [];
|
|
648
806
|
}
|
|
649
807
|
async function pathExistsAsDirectory(file) {
|
|
@@ -739,40 +897,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
739
897
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
740
898
|
}
|
|
741
899
|
//#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
900
|
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
777
901
|
const TAILWIND_V3_COLOR_STEPS = [
|
|
778
902
|
"50",
|
|
@@ -1504,40 +1628,7 @@ function createTailwindV4DefaultColorThemeCss() {
|
|
|
1504
1628
|
].join("\n");
|
|
1505
1629
|
}
|
|
1506
1630
|
//#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
|
-
];
|
|
1631
|
+
//#region src/tailwindcss/v4-engine/generator/css-compat.ts
|
|
1541
1632
|
function findLeadingImportInsertionIndex(css) {
|
|
1542
1633
|
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1543
1634
|
let insertionIndex = 0;
|
|
@@ -1554,13 +1645,78 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
|
1554
1645
|
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
1555
1646
|
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
1556
1647
|
}
|
|
1557
|
-
function
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1648
|
+
function parseCssImportSpecifier$3(params) {
|
|
1649
|
+
const value = params.trim();
|
|
1650
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1651
|
+
if (quoted) return quoted[2];
|
|
1652
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1653
|
+
return url?.[2] ?? url?.[3];
|
|
1654
|
+
}
|
|
1655
|
+
function isTailwindCssPreflightImport(params) {
|
|
1656
|
+
const specifier = parseCssImportSpecifier$3(params);
|
|
1657
|
+
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1658
|
+
}
|
|
1659
|
+
function hasImportLayerOption(params) {
|
|
1660
|
+
return /\blayer(?:\s*\(|\s*$)/.test(params);
|
|
1661
|
+
}
|
|
1662
|
+
function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
1663
|
+
if (!css.includes("preflight")) return css;
|
|
1664
|
+
let root;
|
|
1665
|
+
try {
|
|
1666
|
+
root = postcss.default.parse(css);
|
|
1667
|
+
} catch {
|
|
1668
|
+
return css;
|
|
1669
|
+
}
|
|
1670
|
+
let changed = false;
|
|
1671
|
+
root.walkAtRules("import", (rule) => {
|
|
1672
|
+
if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
|
|
1673
|
+
rule.remove();
|
|
1674
|
+
changed = true;
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
return changed ? root.toString() : css;
|
|
1678
|
+
}
|
|
1679
|
+
function hasThemeParent(rule) {
|
|
1680
|
+
let parent = rule.parent;
|
|
1681
|
+
while (parent) {
|
|
1682
|
+
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
1683
|
+
parent = parent.parent;
|
|
1684
|
+
}
|
|
1562
1685
|
return false;
|
|
1563
1686
|
}
|
|
1687
|
+
function isVendorPrefixedKeyframes(rule) {
|
|
1688
|
+
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
1689
|
+
}
|
|
1690
|
+
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
1691
|
+
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1692
|
+
let root;
|
|
1693
|
+
try {
|
|
1694
|
+
root = postcss.default.parse(css);
|
|
1695
|
+
} catch {
|
|
1696
|
+
return css;
|
|
1697
|
+
}
|
|
1698
|
+
let changed = false;
|
|
1699
|
+
root.walkAtRules((rule) => {
|
|
1700
|
+
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
1701
|
+
rule.remove();
|
|
1702
|
+
changed = true;
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
return changed ? root.toString() : css;
|
|
1706
|
+
}
|
|
1707
|
+
function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
|
|
1708
|
+
const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
|
|
1709
|
+
const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
|
|
1710
|
+
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
1711
|
+
return compatibleSourceCss === source.css ? source : {
|
|
1712
|
+
...source,
|
|
1713
|
+
css: compatibleSourceCss
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
//#endregion
|
|
1717
|
+
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
1718
|
+
const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
|
|
1719
|
+
const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
|
|
1564
1720
|
function normalizeRpxTextCandidate(candidate) {
|
|
1565
1721
|
return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
|
|
1566
1722
|
}
|
|
@@ -1593,120 +1749,37 @@ function restoreRpxTextCssSelectors(css, restoreCandidates) {
|
|
|
1593
1749
|
return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
|
|
1594
1750
|
});
|
|
1595
1751
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
1628
|
-
return [
|
|
1629
|
-
cacheKey,
|
|
1630
|
-
scanSources === true ? "scan:1" : "scan:0",
|
|
1631
|
-
[...requestedCandidates].sort().join("\n")
|
|
1632
|
-
].join("\0");
|
|
1633
|
-
}
|
|
1634
|
-
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
1635
|
-
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
1636
|
-
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
1637
|
-
if (cachedTask) return cachedTask;
|
|
1638
|
-
const promise = task();
|
|
1639
|
-
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
1640
|
-
promise.finally(() => {
|
|
1641
|
-
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
1642
|
-
});
|
|
1643
|
-
return promise;
|
|
1644
|
-
}
|
|
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
|
-
}
|
|
1752
|
+
//#endregion
|
|
1753
|
+
//#region src/tailwindcss/v4-engine/generator/scan-sources.ts
|
|
1754
|
+
const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
|
|
1755
|
+
"**/.git/**",
|
|
1756
|
+
"**/.hg/**",
|
|
1757
|
+
"**/.jj/**",
|
|
1758
|
+
"**/.next/**",
|
|
1759
|
+
"**/.parcel-cache/**",
|
|
1760
|
+
"**/.pnpm-store/**",
|
|
1761
|
+
"**/.svelte-kit/**",
|
|
1762
|
+
"**/.svn/**",
|
|
1763
|
+
"**/.turbo/**",
|
|
1764
|
+
"**/.venv/**",
|
|
1765
|
+
"**/.vercel/**",
|
|
1766
|
+
"**/.yarn/**",
|
|
1767
|
+
"**/__pycache__/**",
|
|
1768
|
+
"**/node_modules/**",
|
|
1769
|
+
"**/venv/**",
|
|
1770
|
+
"**/*.less",
|
|
1771
|
+
"**/*.lock",
|
|
1772
|
+
"**/*.sass",
|
|
1773
|
+
"**/*.scss",
|
|
1774
|
+
"**/*.styl",
|
|
1775
|
+
"**/*.log",
|
|
1776
|
+
"**/package-lock.json",
|
|
1777
|
+
"**/pnpm-lock.yaml",
|
|
1778
|
+
"**/bun.lockb",
|
|
1779
|
+
"**/.gitignore",
|
|
1780
|
+
"**/.env",
|
|
1781
|
+
"**/.env.*"
|
|
1782
|
+
];
|
|
1710
1783
|
function parseImportSourceParam$1(params) {
|
|
1711
1784
|
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
1712
1785
|
if (!match) return;
|
|
@@ -1715,10 +1788,6 @@ function parseImportSourceParam$1(params) {
|
|
|
1715
1788
|
sourcePath: match[3]
|
|
1716
1789
|
};
|
|
1717
1790
|
}
|
|
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
1791
|
function parseCssImportSpecifier$2(params) {
|
|
1723
1792
|
const value = params.trim();
|
|
1724
1793
|
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
@@ -1726,29 +1795,9 @@ function parseCssImportSpecifier$2(params) {
|
|
|
1726
1795
|
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1727
1796
|
return url?.[2] ?? url?.[3];
|
|
1728
1797
|
}
|
|
1729
|
-
function
|
|
1798
|
+
function isTailwindCssImport$1(params) {
|
|
1730
1799
|
const specifier = parseCssImportSpecifier$2(params);
|
|
1731
|
-
return specifier === "tailwindcss
|
|
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;
|
|
1800
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1752
1801
|
}
|
|
1753
1802
|
function resolveSourceBase$1(base, sourcePath) {
|
|
1754
1803
|
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
@@ -1792,42 +1841,164 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1792
1841
|
return;
|
|
1793
1842
|
}
|
|
1794
1843
|
return [
|
|
1795
|
-
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1796
|
-
...sourcePatterns,
|
|
1797
|
-
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1798
|
-
];
|
|
1844
|
+
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1845
|
+
...sourcePatterns,
|
|
1846
|
+
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1847
|
+
];
|
|
1848
|
+
}
|
|
1849
|
+
async function resolveScanSources(source, scanSources) {
|
|
1850
|
+
if (scanSources !== true) return scanSources;
|
|
1851
|
+
return await resolveCssDefinedScanSources(source) ?? false;
|
|
1852
|
+
}
|
|
1853
|
+
//#endregion
|
|
1854
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
1855
|
+
const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
1856
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1857
|
+
cssRemoveHoverPseudoClass: true,
|
|
1858
|
+
isMainChunk: true,
|
|
1859
|
+
majorVersion: 4
|
|
1860
|
+
});
|
|
1861
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
1862
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
1863
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
1864
|
+
try {
|
|
1865
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
1866
|
+
} catch {
|
|
1867
|
+
return match;
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
1872
|
+
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 });
|
|
1873
|
+
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
1874
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1875
|
+
cssRemoveHoverPseudoClass: true,
|
|
1876
|
+
isMainChunk: true,
|
|
1877
|
+
majorVersion: 4,
|
|
1878
|
+
...options
|
|
1879
|
+
});
|
|
1880
|
+
const pruneOptions = { preserveConditionalComments: require_auto.hasCssMacroStyleOptions(options) };
|
|
1881
|
+
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
1882
|
+
}
|
|
1883
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
1884
|
+
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
1885
|
+
return require_auto.hasCssMacroStyleOptions(options) ? require_auto.transformCssMacroCss(css, options) : css;
|
|
1886
|
+
}
|
|
1887
|
+
//#endregion
|
|
1888
|
+
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1889
|
+
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1890
|
+
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1891
|
+
function collectCandidates(candidates) {
|
|
1892
|
+
return new Set(candidates ?? []);
|
|
1893
|
+
}
|
|
1894
|
+
function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
|
|
1895
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
1896
|
+
return false;
|
|
1897
|
+
}
|
|
1898
|
+
function createStableJson(value) {
|
|
1899
|
+
if (value === void 0) return "undefined";
|
|
1900
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1901
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
1902
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
1903
|
+
const record = value;
|
|
1904
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
1905
|
+
}).join(",")}}`;
|
|
1906
|
+
}
|
|
1907
|
+
function createDependencyFingerprint(files) {
|
|
1908
|
+
return files.map((file) => {
|
|
1909
|
+
try {
|
|
1910
|
+
const stat = node_fs.default.statSync(file);
|
|
1911
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
1912
|
+
} catch {
|
|
1913
|
+
return `${file}:missing`;
|
|
1914
|
+
}
|
|
1915
|
+
}).join("|");
|
|
1916
|
+
}
|
|
1917
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions, tailwindcssV3Compatibility) {
|
|
1918
|
+
return [
|
|
1919
|
+
source.projectRoot,
|
|
1920
|
+
source.base,
|
|
1921
|
+
createStableJson(source.baseFallbacks),
|
|
1922
|
+
source.css,
|
|
1923
|
+
createDependencyFingerprint(source.dependencies),
|
|
1924
|
+
target,
|
|
1925
|
+
createStableJson(styleOptions),
|
|
1926
|
+
createStableJson(tailwindcssV3Compatibility)
|
|
1927
|
+
].join("\0");
|
|
1928
|
+
}
|
|
1929
|
+
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
1930
|
+
return [
|
|
1931
|
+
cacheKey,
|
|
1932
|
+
scanSources === true ? "scan:1" : "scan:0",
|
|
1933
|
+
[...requestedCandidates].sort().join("\n")
|
|
1934
|
+
].join("\0");
|
|
1799
1935
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1936
|
+
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
1937
|
+
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
1938
|
+
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
1939
|
+
if (cachedTask) return cachedTask;
|
|
1940
|
+
const promise = task();
|
|
1941
|
+
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
1942
|
+
promise.finally(() => {
|
|
1943
|
+
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
1944
|
+
});
|
|
1945
|
+
return promise;
|
|
1803
1946
|
}
|
|
1804
|
-
function
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
if (
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
return false;
|
|
1947
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1948
|
+
const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
|
|
1949
|
+
promise.catch(() => {
|
|
1950
|
+
if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
|
|
1951
|
+
});
|
|
1952
|
+
return promise;
|
|
1811
1953
|
}
|
|
1812
|
-
function
|
|
1813
|
-
|
|
1954
|
+
function resolveTargetCandidates(candidates, target) {
|
|
1955
|
+
const collected = collectCandidates(candidates);
|
|
1956
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1814
1957
|
}
|
|
1815
|
-
function
|
|
1816
|
-
|
|
1817
|
-
|
|
1958
|
+
function collectSeenCandidates(generated, requestedCandidates) {
|
|
1959
|
+
return new Set([
|
|
1960
|
+
...requestedCandidates,
|
|
1961
|
+
...generated.rawCandidates,
|
|
1962
|
+
...generated.classSet
|
|
1963
|
+
]);
|
|
1964
|
+
}
|
|
1965
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
1966
|
+
return {
|
|
1967
|
+
...styleOptions,
|
|
1968
|
+
isMainChunk: false
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
function resolveStyleOptions$1(source, options) {
|
|
1972
|
+
return require_auto.hasCssMacroTailwindV4Directive(source.css) ? require_auto.withCssMacroStyleOptions(options) : options;
|
|
1973
|
+
}
|
|
1974
|
+
function collectCustomPropertyValues(css) {
|
|
1975
|
+
const values = /* @__PURE__ */ new Map();
|
|
1818
1976
|
try {
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1977
|
+
postcss.default.parse(css).walkDecls((decl) => {
|
|
1978
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1979
|
+
});
|
|
1980
|
+
} catch {}
|
|
1981
|
+
return values;
|
|
1982
|
+
}
|
|
1983
|
+
function mergeCustomPropertyValues(target, css) {
|
|
1984
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1985
|
+
}
|
|
1986
|
+
function seedIncrementalGenerateCache(options) {
|
|
1987
|
+
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1988
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1989
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1990
|
+
incrementalGenerateCache$1.set(cacheKey, {
|
|
1991
|
+
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1992
|
+
classSet: new Set(options.generated.classSet),
|
|
1993
|
+
css: options.generated.css,
|
|
1994
|
+
rawCss: options.generated.rawCss,
|
|
1995
|
+
customPropertyValues,
|
|
1996
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1997
|
+
dependencies: options.generated.dependencies,
|
|
1998
|
+
sources: options.generated.sources,
|
|
1999
|
+
root: options.generated.root,
|
|
2000
|
+
target: options.generated.target
|
|
1829
2001
|
});
|
|
1830
|
-
return changed ? root.toString() : css;
|
|
1831
2002
|
}
|
|
1832
2003
|
function createTailwindV4Engine(source) {
|
|
1833
2004
|
async function generateOnce(generateSource, options = {}) {
|
|
@@ -1835,8 +2006,8 @@ function createTailwindV4Engine(source) {
|
|
|
1835
2006
|
const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
|
|
1836
2007
|
const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
|
|
1837
2008
|
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
|
|
2009
|
+
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
2010
|
+
const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
|
|
1840
2011
|
const result = await engine.generate(omitUndefined({
|
|
1841
2012
|
scanSources: false,
|
|
1842
2013
|
...patchOptions,
|
|
@@ -1859,7 +2030,7 @@ function createTailwindV4Engine(source) {
|
|
|
1859
2030
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1860
2031
|
const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
|
|
1861
2032
|
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
|
|
1862
|
-
const cacheKey = createIncrementalGenerateCacheKey
|
|
2033
|
+
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
|
|
1863
2034
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1864
2035
|
const generated = await generateOnce(source, options);
|
|
1865
2036
|
seedIncrementalGenerateCache({
|
|
@@ -2048,109 +2219,48 @@ function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
|
2048
2219
|
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2049
2220
|
}
|
|
2050
2221
|
//#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/;
|
|
2222
|
+
//#region src/bundlers/shared/generator-css/directives/fallback.ts
|
|
2075
2223
|
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
2076
2224
|
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
2077
2225
|
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) {
|
|
2226
|
+
function parseImportRequest$1(params) {
|
|
2084
2227
|
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2085
2228
|
}
|
|
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) {
|
|
2229
|
+
function parseConfigRequest$1(params) {
|
|
2100
2230
|
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2101
2231
|
}
|
|
2102
|
-
function isPackageJsonImportRequest(request) {
|
|
2232
|
+
function isPackageJsonImportRequest$1(request) {
|
|
2103
2233
|
return typeof request === "string" && request.startsWith("#");
|
|
2104
2234
|
}
|
|
2105
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
2235
|
+
function isWeappTailwindcssImportRequest$1(request) {
|
|
2106
2236
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2107
2237
|
}
|
|
2108
|
-
function
|
|
2109
|
-
|
|
2238
|
+
function isTailwindImportRequest$1(request) {
|
|
2239
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
2240
|
+
}
|
|
2241
|
+
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
2242
|
+
if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2110
2243
|
return request;
|
|
2111
2244
|
}
|
|
2112
|
-
function replaceImportRequest(params, request, replacement) {
|
|
2245
|
+
function replaceImportRequest$1(params, request, replacement) {
|
|
2113
2246
|
const index = params.indexOf(request);
|
|
2114
2247
|
if (index === -1) return params;
|
|
2115
2248
|
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2116
2249
|
}
|
|
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
2250
|
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
2141
2251
|
const trimmed = line.trimStart();
|
|
2142
2252
|
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);
|
|
2253
|
+
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
2254
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
|
|
2255
|
+
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
2256
|
+
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
2147
2257
|
}
|
|
2148
2258
|
return line;
|
|
2149
2259
|
}
|
|
2150
2260
|
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"));
|
|
2261
|
+
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
2262
|
+
if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
|
|
2263
|
+
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
2154
2264
|
}
|
|
2155
2265
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
2156
2266
|
const directives = [];
|
|
@@ -2164,10 +2274,10 @@ function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
|
2164
2274
|
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
2165
2275
|
const normalizedTrimmed = normalized.trim();
|
|
2166
2276
|
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;
|
|
2277
|
+
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
2278
|
+
if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
|
|
2169
2279
|
if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
|
|
2170
|
-
if (request && isTailwindImportRequest(request)) {
|
|
2280
|
+
if (request && isTailwindImportRequest$1(request)) {
|
|
2171
2281
|
const key = normalizedTrimmed;
|
|
2172
2282
|
if (seenImports.has(key)) continue;
|
|
2173
2283
|
seenImports.add(key);
|
|
@@ -2263,10 +2373,97 @@ function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
|
2263
2373
|
function extractConfigRequestFromSource(rawSource) {
|
|
2264
2374
|
for (const line of rawSource.split(/\r?\n/)) {
|
|
2265
2375
|
const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
|
|
2266
|
-
const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
|
|
2376
|
+
const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
|
|
2267
2377
|
if (request) return request;
|
|
2268
2378
|
}
|
|
2269
2379
|
}
|
|
2380
|
+
//#endregion
|
|
2381
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
2382
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
2383
|
+
"config",
|
|
2384
|
+
"custom-variant",
|
|
2385
|
+
"layer",
|
|
2386
|
+
"plugin",
|
|
2387
|
+
"reference",
|
|
2388
|
+
"source",
|
|
2389
|
+
"tailwind",
|
|
2390
|
+
"theme",
|
|
2391
|
+
"utility",
|
|
2392
|
+
"variant"
|
|
2393
|
+
]);
|
|
2394
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
2395
|
+
"config",
|
|
2396
|
+
"custom-variant",
|
|
2397
|
+
"plugin",
|
|
2398
|
+
"source",
|
|
2399
|
+
"tailwind",
|
|
2400
|
+
"theme",
|
|
2401
|
+
"utility",
|
|
2402
|
+
"variant"
|
|
2403
|
+
]);
|
|
2404
|
+
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/;
|
|
2405
|
+
const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
|
|
2406
|
+
["tailwindcss/base", "base"],
|
|
2407
|
+
["tailwindcss/components", "components"],
|
|
2408
|
+
["tailwindcss/utilities", "utilities"]
|
|
2409
|
+
]);
|
|
2410
|
+
function parseImportRequest(params) {
|
|
2411
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2412
|
+
}
|
|
2413
|
+
function hasLocalCssImport(rawSource) {
|
|
2414
|
+
let found = false;
|
|
2415
|
+
try {
|
|
2416
|
+
postcss.default.parse(rawSource).walkAtRules("import", (rule) => {
|
|
2417
|
+
const request = parseImportRequest(rule.params);
|
|
2418
|
+
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
2419
|
+
found = true;
|
|
2420
|
+
return false;
|
|
2421
|
+
}
|
|
2422
|
+
});
|
|
2423
|
+
} catch {}
|
|
2424
|
+
return found;
|
|
2425
|
+
}
|
|
2426
|
+
function parseConfigRequest(params) {
|
|
2427
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2428
|
+
}
|
|
2429
|
+
function isPackageJsonImportRequest(request) {
|
|
2430
|
+
return typeof request === "string" && request.startsWith("#");
|
|
2431
|
+
}
|
|
2432
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
2433
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2434
|
+
}
|
|
2435
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
2436
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2437
|
+
return request;
|
|
2438
|
+
}
|
|
2439
|
+
function replaceImportRequest(params, request, replacement) {
|
|
2440
|
+
const index = params.indexOf(request);
|
|
2441
|
+
if (index === -1) return params;
|
|
2442
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2443
|
+
}
|
|
2444
|
+
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
2445
|
+
if (!options.importFallback) return false;
|
|
2446
|
+
let changed = false;
|
|
2447
|
+
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
2448
|
+
root.walkAtRules("import", (node) => {
|
|
2449
|
+
const request = parseImportRequest(node.params);
|
|
2450
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2451
|
+
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
2452
|
+
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
2453
|
+
const normalizedKey = normalizedParams.trim();
|
|
2454
|
+
if (seenCanonicalImports.has(normalizedKey)) {
|
|
2455
|
+
node.remove();
|
|
2456
|
+
changed = true;
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
seenCanonicalImports.add(normalizedKey);
|
|
2460
|
+
if (normalizedParams !== node.params) {
|
|
2461
|
+
node.params = normalizedParams;
|
|
2462
|
+
changed = true;
|
|
2463
|
+
}
|
|
2464
|
+
});
|
|
2465
|
+
return changed;
|
|
2466
|
+
}
|
|
2270
2467
|
function resolveConfigPath$1(base, configPath) {
|
|
2271
2468
|
if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
|
|
2272
2469
|
return node_path.default.resolve(base, configPath);
|
|
@@ -2846,7 +3043,15 @@ function readStaticConfigContent(configPath) {
|
|
|
2846
3043
|
return parseStaticContentValue(source, contentProperty.start)?.value;
|
|
2847
3044
|
}
|
|
2848
3045
|
//#endregion
|
|
2849
|
-
//#region src/bundlers/vite/source-scan.ts
|
|
3046
|
+
//#region src/bundlers/vite/source-scan/dependencies.ts
|
|
3047
|
+
function addSourceScanDependency(dependencies, file) {
|
|
3048
|
+
if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
|
|
3049
|
+
}
|
|
3050
|
+
function addSourceScanDependencies(dependencies, files) {
|
|
3051
|
+
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
|
|
3052
|
+
}
|
|
3053
|
+
//#endregion
|
|
3054
|
+
//#region src/bundlers/vite/source-scan/css-entries.ts
|
|
2850
3055
|
const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
|
|
2851
3056
|
const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
|
|
2852
3057
|
const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
|
|
@@ -2883,23 +3088,6 @@ function createCssEntriesCacheKey(css, base, dependencies) {
|
|
|
2883
3088
|
dependencies
|
|
2884
3089
|
});
|
|
2885
3090
|
}
|
|
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
3091
|
async function statConfigDependency(file) {
|
|
2904
3092
|
try {
|
|
2905
3093
|
const stats = await (0, node_fs_promises.stat)(file);
|
|
@@ -3113,6 +3301,26 @@ async function discoverTailwindV4CssEntries(root, outDir) {
|
|
|
3113
3301
|
function collectConfiguredCssSources(options) {
|
|
3114
3302
|
return [...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? []];
|
|
3115
3303
|
}
|
|
3304
|
+
//#endregion
|
|
3305
|
+
//#region src/bundlers/vite/source-scan.ts
|
|
3306
|
+
function createResolvedViteSourceScan(input, dependencies) {
|
|
3307
|
+
return {
|
|
3308
|
+
...input,
|
|
3309
|
+
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
3313
|
+
if (options.sourceCount <= 1) return entries;
|
|
3314
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
3315
|
+
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
3316
|
+
}
|
|
3317
|
+
function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
|
|
3318
|
+
return {
|
|
3319
|
+
entries: explicit ? entries : entries.length > 0 ? entries : void 0,
|
|
3320
|
+
explicit,
|
|
3321
|
+
inlineCandidates
|
|
3322
|
+
};
|
|
3323
|
+
}
|
|
3116
3324
|
async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
|
|
3117
3325
|
if (patcher.majorVersion === 3) {
|
|
3118
3326
|
const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
|
|
@@ -3164,11 +3372,7 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
3164
3372
|
}, dependencies);
|
|
3165
3373
|
if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
|
|
3166
3374
|
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;
|
|
3375
|
+
return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set(resolved.dependencies)) : void 0;
|
|
3172
3376
|
}
|
|
3173
3377
|
const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
|
|
3174
3378
|
const configuredCssSources = collectConfiguredCssSources(options);
|
|
@@ -3195,11 +3399,7 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
3195
3399
|
addSourceScanDependency(dependencies, source.file);
|
|
3196
3400
|
addSourceScanDependencies(dependencies, source.dependencies);
|
|
3197
3401
|
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;
|
|
3402
|
+
return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set([...dependencies, ...resolved.dependencies])) : void 0;
|
|
3203
3403
|
}
|
|
3204
3404
|
}
|
|
3205
3405
|
function createViteSourceScanMatcher(entries) {
|
|
@@ -3413,6 +3613,40 @@ async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
|
|
|
3413
3613
|
return task;
|
|
3414
3614
|
}
|
|
3415
3615
|
//#endregion
|
|
3616
|
+
//#region src/tailwindcss/v3-engine/generator/runtime-ready.ts
|
|
3617
|
+
const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
|
|
3618
|
+
function createRuntimeReadyCacheKey(source, rootPath) {
|
|
3619
|
+
return [
|
|
3620
|
+
source.packageName,
|
|
3621
|
+
source.postcssPlugin,
|
|
3622
|
+
rootPath ?? "missing",
|
|
3623
|
+
source.config ?? "config:missing",
|
|
3624
|
+
source.cwd
|
|
3625
|
+
].join("\0");
|
|
3626
|
+
}
|
|
3627
|
+
function createRuntimeReadyPromise(source) {
|
|
3628
|
+
const patcher = createTailwindcssPatcher({
|
|
3629
|
+
basedir: source.cwd,
|
|
3630
|
+
supportCustomLengthUnitsPatch: true,
|
|
3631
|
+
tailwindcss: {
|
|
3632
|
+
...source.config === void 0 ? {} : { config: source.config },
|
|
3633
|
+
cwd: source.cwd,
|
|
3634
|
+
packageName: source.packageName,
|
|
3635
|
+
postcssPlugin: source.postcssPlugin,
|
|
3636
|
+
version: 3
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
|
|
3640
|
+
const cached = runtimeReadyPromiseCache.get(cacheKey);
|
|
3641
|
+
if (cached) return cached;
|
|
3642
|
+
const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
|
|
3643
|
+
runtimeReadyPromiseCache.delete(cacheKey);
|
|
3644
|
+
throw error;
|
|
3645
|
+
});
|
|
3646
|
+
runtimeReadyPromiseCache.set(cacheKey, task);
|
|
3647
|
+
return task;
|
|
3648
|
+
}
|
|
3649
|
+
//#endregion
|
|
3416
3650
|
//#region src/tailwindcss/v3-engine/miniprogram.ts
|
|
3417
3651
|
const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
3418
3652
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
@@ -3494,32 +3728,13 @@ async function transformTailwindV3CssByTarget(css, target, options) {
|
|
|
3494
3728
|
}
|
|
3495
3729
|
//#endregion
|
|
3496
3730
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
3497
|
-
const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
|
|
3498
3731
|
const incrementalGenerateCache = /* @__PURE__ */ new Map();
|
|
3499
|
-
function
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
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 ?? []);
|
|
3732
|
+
const patchRawStyleGenerator = typeof tailwindcss_patch.generateTailwindV3RawStyle === "function" ? tailwindcss_patch.generateTailwindV3RawStyle : void 0;
|
|
3733
|
+
function isTailwindV3PatchResolutionError(error, packageName) {
|
|
3734
|
+
if (!error || typeof error !== "object") return false;
|
|
3735
|
+
const code = error.code;
|
|
3736
|
+
if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
|
|
3737
|
+
return String(error.message ?? "").includes(`${packageName}/lib/`);
|
|
3523
3738
|
}
|
|
3524
3739
|
function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
|
|
3525
3740
|
return (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
|
|
@@ -3540,7 +3755,7 @@ function normalizeBareArbitraryValueCandidates(candidates, bareArbitraryValues)
|
|
|
3540
3755
|
async function collectSourceBareArbitraryValueCandidates(sources, bareArbitraryValues) {
|
|
3541
3756
|
if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return [];
|
|
3542
3757
|
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);
|
|
3758
|
+
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
3759
|
return [...candidates];
|
|
3545
3760
|
}
|
|
3546
3761
|
function escapeCssClassSelector(className) {
|
|
@@ -3576,99 +3791,6 @@ function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
|
3576
3791
|
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
3577
3792
|
return false;
|
|
3578
3793
|
}
|
|
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
3794
|
function shouldAutoEnableCssMacro(source) {
|
|
3673
3795
|
return require_auto.hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
|
|
3674
3796
|
}
|
|
@@ -3708,48 +3830,6 @@ function loadTailwindV3Internals(source) {
|
|
|
3708
3830
|
validateConfig: validateConfigModule["validateConfig"]
|
|
3709
3831
|
};
|
|
3710
3832
|
}
|
|
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
3833
|
function isDirectUtilitiesOnlyCss(css) {
|
|
3754
3834
|
return css.replace(/\s+/g, "") === "@tailwindutilities;";
|
|
3755
3835
|
}
|
|
@@ -3782,27 +3862,25 @@ function appendUtilityRules(root, context, rules) {
|
|
|
3782
3862
|
function appendDirectUtilityRules(root, context) {
|
|
3783
3863
|
appendUtilityRules(root, context, [...context.ruleCache]);
|
|
3784
3864
|
}
|
|
3785
|
-
function
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3865
|
+
async function generateRawStyleWithPatch(generateSource, candidates, sources) {
|
|
3866
|
+
if (!patchRawStyleGenerator) return;
|
|
3867
|
+
try {
|
|
3868
|
+
return await patchRawStyleGenerator({
|
|
3869
|
+
cwd: generateSource.cwd,
|
|
3870
|
+
packageName: generateSource.packageName,
|
|
3871
|
+
css: generateSource.css,
|
|
3872
|
+
candidates,
|
|
3873
|
+
sources,
|
|
3874
|
+
config: createTailwindConfig(generateSource, {
|
|
3875
|
+
candidates,
|
|
3876
|
+
sources
|
|
3877
|
+
}),
|
|
3878
|
+
directUtilitiesOnly: "auto"
|
|
3879
|
+
});
|
|
3880
|
+
} catch (error) {
|
|
3881
|
+
if (isTailwindV3PatchResolutionError(error, generateSource.packageName)) return;
|
|
3802
3882
|
throw error;
|
|
3803
|
-
}
|
|
3804
|
-
runtimeReadyPromiseCache.set(cacheKey, task);
|
|
3805
|
-
return task;
|
|
3883
|
+
}
|
|
3806
3884
|
}
|
|
3807
3885
|
function createTailwindV3Engine(source) {
|
|
3808
3886
|
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
@@ -3829,23 +3907,32 @@ function createTailwindV3Engine(source) {
|
|
|
3829
3907
|
messages: []
|
|
3830
3908
|
};
|
|
3831
3909
|
let context;
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3910
|
+
let rawCss;
|
|
3911
|
+
let dependencies;
|
|
3912
|
+
const patchGenerated = await generateRawStyleWithPatch(generateSource, candidates, options.sources ?? []);
|
|
3913
|
+
if (patchGenerated) {
|
|
3914
|
+
context = patchGenerated.context;
|
|
3915
|
+
rawCss = restoreBareArbitraryValueCssSelectors(patchGenerated.css, requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3916
|
+
dependencies = new Set(patchGenerated.dependencies);
|
|
3840
3917
|
} else {
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3918
|
+
if (isDirectUtilitiesOnlyCss(generateSource.css)) {
|
|
3919
|
+
context = internals.createContext(tailwindConfig, changedContent, root);
|
|
3920
|
+
internals.generateRules(new Set(sortCandidates([internals.notOnDemandCandidate, ...candidates])), context);
|
|
3921
|
+
root.removeAll();
|
|
3922
|
+
appendDirectUtilityRules(root, context);
|
|
3923
|
+
internals.resolveDefaultsAtRules(context)(root, result);
|
|
3924
|
+
internals.collapseAdjacentRules(context)(root, result);
|
|
3925
|
+
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3926
|
+
} else {
|
|
3927
|
+
const setupContext = () => {
|
|
3928
|
+
return (currentRoot) => internals.createContext(tailwindConfig, changedContent, currentRoot);
|
|
3929
|
+
};
|
|
3930
|
+
context = await internals.processTailwindFeatures(setupContext)(root, result);
|
|
3931
|
+
}
|
|
3932
|
+
rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3933
|
+
dependencies = collectDependencyMessages(result);
|
|
3845
3934
|
}
|
|
3846
|
-
const rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3847
3935
|
const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
3848
|
-
const dependencies = collectDependencyMessages(result);
|
|
3849
3936
|
for (const dependency of generateSource.dependencies) dependencies.add(dependency);
|
|
3850
3937
|
const classSet = restoreBareArbitraryValueClassSet(collectClassSet(context), requestedCandidates, options.bareArbitraryValues);
|
|
3851
3938
|
return {
|
|
@@ -3889,7 +3976,7 @@ function createTailwindV3Engine(source) {
|
|
|
3889
3976
|
const requestedCandidates = mergeGenerateCandidates(source, options);
|
|
3890
3977
|
if (requestedCandidates.size === 0) return generateOnce(source, options);
|
|
3891
3978
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
3892
|
-
const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions, options.bareArbitraryValues);
|
|
3979
|
+
const cacheKey = createIncrementalGenerateCacheKey$1(source, target, styleOptions, options.bareArbitraryValues);
|
|
3893
3980
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
3894
3981
|
if (cached) {
|
|
3895
3982
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
|