weapp-tailwindcss 5.0.0-next.11 → 5.0.0-next.13
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-BRkhpjio.js → bundle-state-Bz8vLnCf.js} +3 -2
- package/dist/{bundle-state-BrtFgX-A.mjs → bundle-state-CP2XS3Uj.mjs} +3 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css.d.ts +4 -0
- package/dist/bundlers/shared/hmr-timing.d.ts +18 -1
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
- package/dist/bundlers/vite/source-candidates.d.ts +11 -0
- package/dist/bundlers/vite/source-scan.d.ts +18 -1
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/cli.js +453 -9
- package/dist/cli.mjs +451 -8
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/generator-C9H44wEF.mjs +32 -0
- package/dist/generator-CRORPkpW.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +49 -13
- package/dist/gulp.mjs +46 -10
- package/dist/{incremental-runtime-class-set-CBMefNHQ.js → incremental-runtime-class-set-DN9KKjSi.js} +512 -103
- package/dist/{incremental-runtime-class-set-DaS2yw5c.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +491 -88
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-BdcRlSpp.js → postcss-Ab7YzAbs.js} +30 -19
- package/dist/{postcss-Bs-RbNzK.js → postcss-CZE8k8oP.js} +59 -53
- package/dist/{postcss-xZDiTRII.mjs → postcss-CtlrNknb.mjs} +19 -8
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-D5eEdqeH.js → precheck-CRX-pMKJ.js} +37 -17
- package/dist/{precheck-DtBGFS-n.mjs → precheck-SG48aLG2.mjs} +29 -9
- package/dist/presets.js +6 -6
- package/dist/presets.mjs +4 -4
- package/dist/source-candidates-C4YgmZ8A.js +274 -0
- package/dist/source-candidates-CyupdLKi.mjs +259 -0
- package/dist/tailwindcss/runtime/cache.d.ts +1 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -0
- package/dist/{tailwindcss-DGM8lHUj.mjs → tailwindcss-BbTVeQkG.mjs} +9 -4
- package/dist/{tailwindcss-B78nj6n7.js → tailwindcss-DZ6jVYb4.js} +21 -16
- package/dist/v3-engine-D61eilBl.mjs +3208 -0
- package/dist/v3-engine-DwV1E6rX.js +3461 -0
- package/dist/{vite-C8S1wfyQ.mjs → vite-Ti_qSctn.mjs} +380 -542
- package/dist/{vite-BEj9JOOA.js → vite-xKS6RvLR.js} +385 -550
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +29 -9
- package/dist/weapp-tw-runtime-classset-loader.js +1 -1
- package/dist/{webpack-ZGIKKpFf.mjs → webpack-DvptFz7B.mjs} +36 -19
- package/dist/{webpack-Dm1IXTIh.js → webpack-wfNutjMm.js} +40 -23
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- package/dist/cache-B_9E7FxF.js +0 -517
- package/dist/cache-DEDxBMIw.mjs +0 -443
- package/dist/generator-CahkD2vq.mjs +0 -1469
- package/dist/generator-Ck1Dd1V0.js +0 -1568
- package/dist/runtime-patch-CqB-A4zA.js +0 -85
- package/dist/runtime-patch-DGKsVkiG.mjs +0 -71
- package/dist/source-scan-CIVTa3Cj.js +0 -297
- package/dist/source-scan-CJ0y0XBj.mjs +0 -258
- /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
- /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
- /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
- /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
- /package/dist/{utils-CGBVVNm6.mjs → utils-CycMvPn_.mjs} +0 -0
- /package/dist/{utils-4ODFyoqD.js → utils-D0MZP_tr.js} +0 -0
|
@@ -0,0 +1,3208 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import fs, { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { logger } from "@weapp-tailwindcss/logger";
|
|
7
|
+
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
8
|
+
import { TailwindcssPatcher, createTailwindV4Engine, loadTailwindV4DesignSystem, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions } from "tailwindcss-patch";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import _createDebug from "debug";
|
|
11
|
+
import { stat } from "node:fs/promises";
|
|
12
|
+
import fg from "fast-glob";
|
|
13
|
+
import micromatch from "micromatch";
|
|
14
|
+
import { loadConfig } from "tailwindcss-config";
|
|
15
|
+
import { createStyleHandler, protectDynamicColorMixAlpha } from "@weapp-tailwindcss/postcss";
|
|
16
|
+
//#region src/context/workspace.ts
|
|
17
|
+
const IGNORED_WORKSPACE_DIRS = new Set([
|
|
18
|
+
"node_modules",
|
|
19
|
+
".git",
|
|
20
|
+
".hg",
|
|
21
|
+
".svn",
|
|
22
|
+
".turbo",
|
|
23
|
+
".output",
|
|
24
|
+
".next",
|
|
25
|
+
"dist",
|
|
26
|
+
"build"
|
|
27
|
+
]);
|
|
28
|
+
function findWorkspaceRoot(startDir) {
|
|
29
|
+
if (!startDir) return;
|
|
30
|
+
let current = path.resolve(startDir);
|
|
31
|
+
while (true) {
|
|
32
|
+
if (existsSync(path.join(current, "pnpm-workspace.yaml"))) return current;
|
|
33
|
+
const parent = path.dirname(current);
|
|
34
|
+
if (parent === current) return;
|
|
35
|
+
current = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function findNearestPackageRoot(startDir) {
|
|
39
|
+
if (!startDir) return;
|
|
40
|
+
let current = path.resolve(startDir);
|
|
41
|
+
while (true) {
|
|
42
|
+
if (existsSync(path.join(current, "package.json"))) return current;
|
|
43
|
+
const parent = path.dirname(current);
|
|
44
|
+
if (parent === current) return;
|
|
45
|
+
current = parent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
49
|
+
const visited = /* @__PURE__ */ new Set();
|
|
50
|
+
const queue = [path.resolve(rootDir)];
|
|
51
|
+
while (queue.length > 0) {
|
|
52
|
+
const current = queue.shift();
|
|
53
|
+
const normalized = path.normalize(current);
|
|
54
|
+
if (visited.has(normalized)) continue;
|
|
55
|
+
visited.add(normalized);
|
|
56
|
+
try {
|
|
57
|
+
const pkgPath = path.join(normalized, "package.json");
|
|
58
|
+
if (existsSync(pkgPath)) {
|
|
59
|
+
if (JSON.parse(readFileSync(pkgPath, "utf8"))?.name === packageName) return normalized;
|
|
60
|
+
}
|
|
61
|
+
} catch {}
|
|
62
|
+
let entries;
|
|
63
|
+
try {
|
|
64
|
+
entries = readdirSync(normalized, { withFileTypes: true });
|
|
65
|
+
} catch {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const entry of entries) {
|
|
69
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
|
|
70
|
+
queue.push(path.join(normalized, entry.name));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/utils/object.ts
|
|
76
|
+
function definedEntries(value) {
|
|
77
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
78
|
+
}
|
|
79
|
+
function omitUndefined(value) {
|
|
80
|
+
return Object.fromEntries(definedEntries(value));
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/tailwindcss/patcher-options.ts
|
|
84
|
+
function resolveTailwindcssOptions(options) {
|
|
85
|
+
return options?.tailwindcss ?? options?.tailwind;
|
|
86
|
+
}
|
|
87
|
+
function normalizeExtendLengthUnits(value) {
|
|
88
|
+
if (value === false) return false;
|
|
89
|
+
if (value === true) return { enabled: true };
|
|
90
|
+
if (value && typeof value === "object") return {
|
|
91
|
+
enabled: true,
|
|
92
|
+
...value
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function normalizeTailwindcssPatcherOptions(options) {
|
|
96
|
+
return options;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/tailwindcss/patcher-resolve.ts
|
|
100
|
+
const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
|
|
101
|
+
const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
|
|
102
|
+
const TAILWIND_CONFIG_FILES = [
|
|
103
|
+
"tailwind.config.js",
|
|
104
|
+
"tailwind.config.cjs",
|
|
105
|
+
"tailwind.config.mjs",
|
|
106
|
+
"tailwind.config.ts",
|
|
107
|
+
"tailwind.config.cts",
|
|
108
|
+
"tailwind.config.mts"
|
|
109
|
+
];
|
|
110
|
+
function isPathSpecifier(specifier) {
|
|
111
|
+
if (!specifier) return false;
|
|
112
|
+
if (specifier.startsWith("file://")) return true;
|
|
113
|
+
if (path.isAbsolute(specifier)) return true;
|
|
114
|
+
return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
|
|
115
|
+
}
|
|
116
|
+
function resolveModuleFromPaths(specifier, paths) {
|
|
117
|
+
if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
|
|
118
|
+
try {
|
|
119
|
+
return createRequire(import.meta.url).resolve(specifier, { paths });
|
|
120
|
+
} catch {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function resolveTailwindConfigFallback(packageName, paths) {
|
|
125
|
+
if (!packageName) return;
|
|
126
|
+
for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
|
|
127
|
+
const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
|
|
128
|
+
if (resolved) return resolved;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function appendNodeModules(paths, dir) {
|
|
132
|
+
if (!dir) return;
|
|
133
|
+
const nodeModulesDir = path.join(dir, "node_modules");
|
|
134
|
+
if (existsSync(nodeModulesDir)) paths.add(nodeModulesDir);
|
|
135
|
+
}
|
|
136
|
+
function findTailwindConfig(searchRoots) {
|
|
137
|
+
for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
|
|
138
|
+
const candidate = path.resolve(root, file);
|
|
139
|
+
if (existsSync(candidate)) return candidate;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function createDefaultResolvePaths(basedir) {
|
|
143
|
+
const paths = /* @__PURE__ */ new Set();
|
|
144
|
+
let fallbackCandidates = [];
|
|
145
|
+
if (basedir) {
|
|
146
|
+
const resolvedBase = path.resolve(basedir);
|
|
147
|
+
appendNodeModules(paths, resolvedBase);
|
|
148
|
+
fallbackCandidates.push(resolvedBase);
|
|
149
|
+
const packageRoot = findNearestPackageRoot(resolvedBase);
|
|
150
|
+
if (packageRoot) {
|
|
151
|
+
appendNodeModules(paths, packageRoot);
|
|
152
|
+
fallbackCandidates.push(packageRoot);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const cwd = process.cwd();
|
|
156
|
+
appendNodeModules(paths, cwd);
|
|
157
|
+
try {
|
|
158
|
+
const modulePath = fileURLToPath(import.meta.url);
|
|
159
|
+
const candidate = existsSync(modulePath) && !path.extname(modulePath) ? modulePath : path.dirname(modulePath);
|
|
160
|
+
paths.add(candidate);
|
|
161
|
+
} catch {
|
|
162
|
+
paths.add(import.meta.url);
|
|
163
|
+
}
|
|
164
|
+
if (paths.size === 0) {
|
|
165
|
+
fallbackCandidates = fallbackCandidates.filter(Boolean);
|
|
166
|
+
if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
|
|
167
|
+
for (const candidate of fallbackCandidates) paths.add(candidate);
|
|
168
|
+
}
|
|
169
|
+
return [...paths];
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/tailwindcss/version.ts
|
|
173
|
+
function normalizeSupportedTailwindcssMajorVersion(version) {
|
|
174
|
+
return version === 3 || version === 4 ? version : void 0;
|
|
175
|
+
}
|
|
176
|
+
function readPackageJson(packageJsonPath) {
|
|
177
|
+
try {
|
|
178
|
+
return JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
179
|
+
} catch {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function findPackageJsonDeclaringPackage(packageName, base) {
|
|
184
|
+
let current = path.resolve(base);
|
|
185
|
+
while (true) {
|
|
186
|
+
const pkgPath = path.join(current, "package.json");
|
|
187
|
+
if (existsSync(pkgPath)) {
|
|
188
|
+
const pkg = readPackageJson(pkgPath);
|
|
189
|
+
if (readDeclaredPackageVersion(packageName, pkg)) return pkgPath;
|
|
190
|
+
if (pkg?.name !== "weapp-tailwindcss") return;
|
|
191
|
+
}
|
|
192
|
+
const parent = path.dirname(current);
|
|
193
|
+
if (parent === current) return;
|
|
194
|
+
current = parent;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function readDeclaredPackageVersion(packageName, pkg) {
|
|
198
|
+
return pkg?.dependencies?.[packageName] ?? pkg?.devDependencies?.[packageName] ?? pkg?.peerDependencies?.[packageName] ?? pkg?.optionalDependencies?.[packageName];
|
|
199
|
+
}
|
|
200
|
+
function readDeclaredPackageMajorVersion(version) {
|
|
201
|
+
const match = version?.match(/(?:^|\D)([34])(?:\.|\b)/);
|
|
202
|
+
return normalizeSupportedTailwindcssMajorVersion(match ? Number(match[1]) : void 0);
|
|
203
|
+
}
|
|
204
|
+
function readInstalledPackageMajorVersion(packageName, base) {
|
|
205
|
+
const packageJsonPath = findPackageJsonDeclaringPackage(packageName, base);
|
|
206
|
+
if (!packageJsonPath) return;
|
|
207
|
+
const declaredVersion = readDeclaredPackageVersion(packageName, readPackageJson(packageJsonPath));
|
|
208
|
+
if (!declaredVersion) return;
|
|
209
|
+
try {
|
|
210
|
+
const pkg = createRequire(packageJsonPath)(`${packageName}/package.json`);
|
|
211
|
+
return normalizeSupportedTailwindcssMajorVersion(Number(pkg.version?.split(".")[0]));
|
|
212
|
+
} catch {
|
|
213
|
+
return readDeclaredPackageMajorVersion(declaredVersion);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/tailwindcss/patcher.ts
|
|
218
|
+
function createFallbackTailwindcssPatcher() {
|
|
219
|
+
return {
|
|
220
|
+
packageInfo: {
|
|
221
|
+
name: "tailwindcss",
|
|
222
|
+
version: void 0,
|
|
223
|
+
rootPath: "",
|
|
224
|
+
packageJsonPath: "",
|
|
225
|
+
packageJson: {}
|
|
226
|
+
},
|
|
227
|
+
majorVersion: 4,
|
|
228
|
+
async getClassSet() {
|
|
229
|
+
return /* @__PURE__ */ new Set();
|
|
230
|
+
},
|
|
231
|
+
async extract(_options) {
|
|
232
|
+
return {
|
|
233
|
+
classList: [],
|
|
234
|
+
classSet: /* @__PURE__ */ new Set()
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
async collectContentTokens() {
|
|
238
|
+
return {
|
|
239
|
+
entries: [],
|
|
240
|
+
filesScanned: 0,
|
|
241
|
+
sources: [],
|
|
242
|
+
skippedFiles: []
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
let hasLoggedMissingTailwind = false;
|
|
248
|
+
const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
|
|
249
|
+
const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
|
|
250
|
+
function isTailwindcssV4PackageName(packageName) {
|
|
251
|
+
return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
|
|
252
|
+
}
|
|
253
|
+
function createTailwindcssPatcher(options) {
|
|
254
|
+
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
255
|
+
const cache = { driver: "memory" };
|
|
256
|
+
const normalizedBasedir = basedir ? path.resolve(basedir) : void 0;
|
|
257
|
+
const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? process.cwd();
|
|
258
|
+
if (cacheDir) if (path.isAbsolute(cacheDir)) cache.dir = cacheDir;
|
|
259
|
+
else if (normalizedBasedir) cache.dir = path.resolve(normalizedBasedir, cacheDir);
|
|
260
|
+
else cache.dir = path.resolve(process.cwd(), cacheDir);
|
|
261
|
+
else cache.dir = path.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
|
|
262
|
+
if (normalizedBasedir) cache.cwd = normalizedBasedir;
|
|
263
|
+
const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? process.cwd());
|
|
264
|
+
const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
|
|
265
|
+
const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
|
|
266
|
+
const baseTailwindOptions = defuOverrideArray(tailwindcss ?? {}, omitUndefined({
|
|
267
|
+
cwd: normalizedBasedir,
|
|
268
|
+
resolve: { paths: resolvePaths }
|
|
269
|
+
}));
|
|
270
|
+
if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
|
|
271
|
+
if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
|
|
272
|
+
if (typeof baseTailwindOptions.postcssPlugin === "string") {
|
|
273
|
+
const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
|
|
274
|
+
if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
275
|
+
}
|
|
276
|
+
const baseOptions = omitUndefined({
|
|
277
|
+
projectRoot: normalizedBasedir,
|
|
278
|
+
cache,
|
|
279
|
+
tailwindcss: baseTailwindOptions,
|
|
280
|
+
apply: omitUndefined({
|
|
281
|
+
exposeContext: true,
|
|
282
|
+
extendLengthUnits
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
const resolvedOptions = defuOverrideArray(normalizedUserOptions ?? {}, baseOptions);
|
|
286
|
+
const resolvedTailwindOptions = resolvedOptions.tailwindcss;
|
|
287
|
+
if (resolvedTailwindOptions) {
|
|
288
|
+
const existingResolve = resolvedTailwindOptions.resolve ?? {};
|
|
289
|
+
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
|
|
290
|
+
resolvedTailwindOptions.resolve = {
|
|
291
|
+
...existingResolve,
|
|
292
|
+
paths: [...new Set(sourcePaths)]
|
|
293
|
+
};
|
|
294
|
+
logger.debug("Tailwind resolve config %O", {
|
|
295
|
+
packageName: resolvedTailwindOptions.packageName,
|
|
296
|
+
version: resolvedTailwindOptions.version,
|
|
297
|
+
resolve: resolvedTailwindOptions.resolve,
|
|
298
|
+
cwd: resolvedTailwindOptions.cwd
|
|
299
|
+
});
|
|
300
|
+
if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
|
|
301
|
+
const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
|
|
302
|
+
if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
303
|
+
}
|
|
304
|
+
const searchRoots = /* @__PURE__ */ new Set();
|
|
305
|
+
if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
|
|
306
|
+
for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
|
|
307
|
+
const parentDir = path.dirname(resolvePath);
|
|
308
|
+
searchRoots.add(parentDir);
|
|
309
|
+
}
|
|
310
|
+
const configPath = findTailwindConfig(searchRoots);
|
|
311
|
+
if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
|
|
312
|
+
else {
|
|
313
|
+
const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
|
|
314
|
+
if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
|
|
315
|
+
}
|
|
316
|
+
if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = path.dirname(configPath);
|
|
317
|
+
resolvedOptions.tailwindcss = resolvedTailwindOptions;
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
return new TailwindcssPatcher(resolvedOptions);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
|
|
323
|
+
if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
|
|
324
|
+
if (!hasLoggedMissingTailwind) {
|
|
325
|
+
logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 运行时能力。若需使用 Tailwind 能力,请安装 tailwindcss。");
|
|
326
|
+
hasLoggedMissingTailwind = true;
|
|
327
|
+
}
|
|
328
|
+
return createFallbackTailwindcssPatcher();
|
|
329
|
+
}
|
|
330
|
+
if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/debug/index.ts
|
|
336
|
+
const _debug = _createDebug("weapp-tw");
|
|
337
|
+
function createDebug(prefix) {
|
|
338
|
+
const debug = ((formatter, ...args) => {
|
|
339
|
+
return _debug((prefix ?? "") + formatter, ...args);
|
|
340
|
+
});
|
|
341
|
+
Object.defineProperty(debug, "enabled", {
|
|
342
|
+
enumerable: false,
|
|
343
|
+
configurable: false,
|
|
344
|
+
get() {
|
|
345
|
+
return _debug.enabled;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
return debug;
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/tailwindcss/source-scan.ts
|
|
352
|
+
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
353
|
+
"html",
|
|
354
|
+
"wxml",
|
|
355
|
+
"axml",
|
|
356
|
+
"jxml",
|
|
357
|
+
"ksml",
|
|
358
|
+
"ttml",
|
|
359
|
+
"qml",
|
|
360
|
+
"tyml",
|
|
361
|
+
"xhsml",
|
|
362
|
+
"swan",
|
|
363
|
+
"vue",
|
|
364
|
+
"mpx",
|
|
365
|
+
"js",
|
|
366
|
+
"jsx",
|
|
367
|
+
"ts",
|
|
368
|
+
"tsx"
|
|
369
|
+
];
|
|
370
|
+
function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
|
|
371
|
+
return `**/*.{${extensions.join(",")}}`;
|
|
372
|
+
}
|
|
373
|
+
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
|
|
374
|
+
function parseConfigParam$1(params) {
|
|
375
|
+
const value = params.trim();
|
|
376
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
377
|
+
}
|
|
378
|
+
function isLegacyContentObject$1(value) {
|
|
379
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
380
|
+
}
|
|
381
|
+
function normalizeGlobPattern(pattern) {
|
|
382
|
+
return pattern.startsWith("./") ? pattern.slice(2) : pattern;
|
|
383
|
+
}
|
|
384
|
+
function hasGlobMagic(value) {
|
|
385
|
+
return /[*?[\]{}()!+@]/.test(value);
|
|
386
|
+
}
|
|
387
|
+
function splitStaticGlobPrefix(pattern) {
|
|
388
|
+
const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
|
|
389
|
+
const prefix = [];
|
|
390
|
+
const rest = [];
|
|
391
|
+
let reachedGlob = false;
|
|
392
|
+
for (const segment of segments) {
|
|
393
|
+
if (!reachedGlob && segment && !hasGlobMagic(segment)) {
|
|
394
|
+
prefix.push(segment);
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
reachedGlob = true;
|
|
398
|
+
rest.push(segment);
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
prefix,
|
|
402
|
+
rest
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function segmentTopLevel(input, separator) {
|
|
406
|
+
const parts = [];
|
|
407
|
+
const stack = [];
|
|
408
|
+
let lastPos = 0;
|
|
409
|
+
let quote;
|
|
410
|
+
for (let index = 0; index < input.length; index++) {
|
|
411
|
+
const char = input[index];
|
|
412
|
+
if (char === "\\") {
|
|
413
|
+
index += 1;
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (quote) {
|
|
417
|
+
if (char === quote) quote = void 0;
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
if (char === "\"" || char === "'") {
|
|
421
|
+
quote = char;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
if (char === "(") {
|
|
425
|
+
stack.push(")");
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (char === "[") {
|
|
429
|
+
stack.push("]");
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
if (char === "{") {
|
|
433
|
+
stack.push("}");
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (stack.length > 0 && char === stack[stack.length - 1]) {
|
|
437
|
+
stack.pop();
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (stack.length === 0 && char === separator) {
|
|
441
|
+
parts.push(input.slice(lastPos, index));
|
|
442
|
+
lastPos = index + 1;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
parts.push(input.slice(lastPos));
|
|
446
|
+
return parts;
|
|
447
|
+
}
|
|
448
|
+
function isSequence(value) {
|
|
449
|
+
return NUMERICAL_RANGE_RE.test(value);
|
|
450
|
+
}
|
|
451
|
+
function expandSequence(value) {
|
|
452
|
+
const match = value.match(NUMERICAL_RANGE_RE);
|
|
453
|
+
if (!match) return [value];
|
|
454
|
+
const [, start, end, stepValue] = match;
|
|
455
|
+
if (start === void 0 || end === void 0) return [value];
|
|
456
|
+
let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
|
|
457
|
+
const startNumber = Number.parseInt(start, 10);
|
|
458
|
+
const endNumber = Number.parseInt(end, 10);
|
|
459
|
+
const increasing = startNumber < endNumber;
|
|
460
|
+
if (step === void 0) step = increasing ? 1 : -1;
|
|
461
|
+
if (step === 0) return [];
|
|
462
|
+
if (increasing && step < 0) step = -step;
|
|
463
|
+
if (!increasing && step > 0) step = -step;
|
|
464
|
+
const result = [];
|
|
465
|
+
for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
|
|
466
|
+
return result;
|
|
467
|
+
}
|
|
468
|
+
function expandInlineSourceCandidatePattern(pattern) {
|
|
469
|
+
const index = pattern.indexOf("{");
|
|
470
|
+
if (index === -1) return [pattern];
|
|
471
|
+
const prefix = pattern.slice(0, index);
|
|
472
|
+
const rest = pattern.slice(index);
|
|
473
|
+
let depth = 0;
|
|
474
|
+
let endIndex = -1;
|
|
475
|
+
for (let index = 0; index < rest.length; index++) {
|
|
476
|
+
const char = rest[index];
|
|
477
|
+
if (char === "{") depth += 1;
|
|
478
|
+
else if (char === "}") {
|
|
479
|
+
depth -= 1;
|
|
480
|
+
if (depth === 0) {
|
|
481
|
+
endIndex = index;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (endIndex === -1) return [pattern];
|
|
487
|
+
const inner = rest.slice(1, endIndex);
|
|
488
|
+
const suffix = rest.slice(endIndex + 1);
|
|
489
|
+
const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",")).flatMap((part) => expandInlineSourceCandidatePattern(part));
|
|
490
|
+
return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
|
|
491
|
+
}
|
|
492
|
+
function parseSourceInlineParam(params) {
|
|
493
|
+
let value = params.trim();
|
|
494
|
+
const negated = value.startsWith("not ");
|
|
495
|
+
if (negated) value = value.slice(4).trim();
|
|
496
|
+
if (!value.startsWith("inline(") || !value.endsWith(")")) return;
|
|
497
|
+
const inlineValue = value.slice(7, -1).trim();
|
|
498
|
+
const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
|
|
499
|
+
if (!match) return;
|
|
500
|
+
const source = match[2];
|
|
501
|
+
if (source === void 0) return;
|
|
502
|
+
return {
|
|
503
|
+
negated,
|
|
504
|
+
source
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function collectCssInlineSourceCandidates(root) {
|
|
508
|
+
const included = /* @__PURE__ */ new Set();
|
|
509
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
510
|
+
root.walkAtRules("source", (rule) => {
|
|
511
|
+
const parsed = parseSourceInlineParam(rule.params);
|
|
512
|
+
if (!parsed) return;
|
|
513
|
+
const target = parsed.negated ? excluded : included;
|
|
514
|
+
for (const source of segmentTopLevel(parsed.source, " ")) {
|
|
515
|
+
const trimmed = source.trim();
|
|
516
|
+
if (!trimmed) continue;
|
|
517
|
+
for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
|
|
518
|
+
const normalized = candidate.trim();
|
|
519
|
+
if (normalized) target.add(normalized);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
for (const candidate of excluded) included.delete(candidate);
|
|
524
|
+
return {
|
|
525
|
+
included,
|
|
526
|
+
excluded
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function normalizeLegacyContentEntries(content, base) {
|
|
530
|
+
if (typeof content === "string") {
|
|
531
|
+
const negated = content.startsWith("!");
|
|
532
|
+
return [{
|
|
533
|
+
base,
|
|
534
|
+
negated,
|
|
535
|
+
pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
|
|
536
|
+
}];
|
|
537
|
+
}
|
|
538
|
+
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
|
|
539
|
+
if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, base);
|
|
540
|
+
return [];
|
|
541
|
+
}
|
|
542
|
+
async function pathExistsAsDirectory(file) {
|
|
543
|
+
try {
|
|
544
|
+
return (await stat(file)).isDirectory();
|
|
545
|
+
} catch {
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
|
|
550
|
+
const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
|
|
551
|
+
if (await pathExistsAsDirectory(absoluteSource)) return {
|
|
552
|
+
base: absoluteSource,
|
|
553
|
+
negated,
|
|
554
|
+
pattern: normalizeGlobPattern(defaultPattern)
|
|
555
|
+
};
|
|
556
|
+
if (path.isAbsolute(sourcePath)) return {
|
|
557
|
+
base: path.dirname(absoluteSource),
|
|
558
|
+
negated,
|
|
559
|
+
pattern: normalizeGlobPattern(path.basename(absoluteSource))
|
|
560
|
+
};
|
|
561
|
+
const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
|
|
562
|
+
if (prefix.length > 0 && rest.length > 0) return {
|
|
563
|
+
base: path.resolve(base, ...prefix),
|
|
564
|
+
negated,
|
|
565
|
+
pattern: normalizeGlobPattern(rest.join("/"))
|
|
566
|
+
};
|
|
567
|
+
return {
|
|
568
|
+
base,
|
|
569
|
+
negated,
|
|
570
|
+
pattern: normalizeGlobPattern(sourcePath)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function parseSourceFileParam$1(params) {
|
|
574
|
+
const value = params.trim();
|
|
575
|
+
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
576
|
+
const negated = value.startsWith("not ");
|
|
577
|
+
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
578
|
+
if (sourceValue.startsWith("inline(")) return;
|
|
579
|
+
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
580
|
+
return match?.[2] ? {
|
|
581
|
+
negated,
|
|
582
|
+
sourcePath: match[2]
|
|
583
|
+
} : void 0;
|
|
584
|
+
}
|
|
585
|
+
async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
|
|
586
|
+
const entries = [];
|
|
587
|
+
const tasks = [];
|
|
588
|
+
root.walkAtRules("source", (rule) => {
|
|
589
|
+
const parsed = parseSourceFileParam$1(rule.params);
|
|
590
|
+
if (!parsed) return;
|
|
591
|
+
tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
|
|
592
|
+
});
|
|
593
|
+
entries.push(...await Promise.all(tasks));
|
|
594
|
+
return entries;
|
|
595
|
+
}
|
|
596
|
+
async function expandTailwindSourceEntries(entries, options = {}) {
|
|
597
|
+
const files = /* @__PURE__ */ new Set();
|
|
598
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
599
|
+
const entriesByBase = /* @__PURE__ */ new Map();
|
|
600
|
+
for (const entry of entries) {
|
|
601
|
+
const base = path.resolve(entry.base);
|
|
602
|
+
const group = entriesByBase.get(base) ?? [];
|
|
603
|
+
group.push({
|
|
604
|
+
...entry,
|
|
605
|
+
base
|
|
606
|
+
});
|
|
607
|
+
entriesByBase.set(base, group);
|
|
608
|
+
}
|
|
609
|
+
await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
|
|
610
|
+
const patterns = group.map((entry) => {
|
|
611
|
+
const pattern = normalizeGlobPattern(entry.pattern);
|
|
612
|
+
return entry.negated ? `!${pattern}` : pattern;
|
|
613
|
+
});
|
|
614
|
+
if (!patterns.some((pattern) => !pattern.startsWith("!"))) return;
|
|
615
|
+
const ignore = options.ignore;
|
|
616
|
+
const matched = await fg(patterns, {
|
|
617
|
+
absolute: true,
|
|
618
|
+
cwd: base,
|
|
619
|
+
...ignore === void 0 ? {} : { ignore },
|
|
620
|
+
onlyFiles: true,
|
|
621
|
+
unique: true
|
|
622
|
+
});
|
|
623
|
+
for (const file of matched) files.add(path.resolve(file));
|
|
624
|
+
}));
|
|
625
|
+
return [...files].filter((file) => !negativeEntries.some((entry) => {
|
|
626
|
+
const relative = path.relative(path.resolve(entry.base), file).split(path.sep).join("/");
|
|
627
|
+
return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizeGlobPattern(entry.pattern));
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
632
|
+
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
|
|
633
|
+
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
634
|
+
return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
|
|
635
|
+
}
|
|
636
|
+
function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
637
|
+
if (!candidates) return;
|
|
638
|
+
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
639
|
+
}
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
642
|
+
/**
|
|
643
|
+
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
644
|
+
*/
|
|
645
|
+
function removeUnsupportedCascadeLayers(root) {
|
|
646
|
+
root.walkAtRules("layer", (atRule) => {
|
|
647
|
+
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
648
|
+
atRule.remove();
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
atRule.replaceWith(...atRule.nodes);
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/tailwindcss/miniprogram.ts
|
|
656
|
+
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
657
|
+
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
658
|
+
const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
|
|
659
|
+
const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
|
|
660
|
+
"*",
|
|
661
|
+
"view",
|
|
662
|
+
"text",
|
|
663
|
+
":before",
|
|
664
|
+
":after",
|
|
665
|
+
"::before",
|
|
666
|
+
"::after"
|
|
667
|
+
]);
|
|
668
|
+
const PREFLIGHT_RESET_PROPS = new Set([
|
|
669
|
+
"box-sizing",
|
|
670
|
+
"border",
|
|
671
|
+
"border-width",
|
|
672
|
+
"border-style",
|
|
673
|
+
"border-color",
|
|
674
|
+
"margin",
|
|
675
|
+
"padding"
|
|
676
|
+
]);
|
|
677
|
+
const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
|
|
678
|
+
function hasClassSelector(selector) {
|
|
679
|
+
return CLASS_SELECTOR_RE.test(selector);
|
|
680
|
+
}
|
|
681
|
+
function normalizeSelector$1(selector) {
|
|
682
|
+
return selector.trim().replace(/\s+/g, "");
|
|
683
|
+
}
|
|
684
|
+
function getRuleSelectors(rule) {
|
|
685
|
+
return rule.selector.split(",").map(normalizeSelector$1).filter(Boolean);
|
|
686
|
+
}
|
|
687
|
+
function isCustomPropertyRule(rule) {
|
|
688
|
+
let hasDeclaration = false;
|
|
689
|
+
let allCustomProperties = true;
|
|
690
|
+
rule.walkDecls((decl) => {
|
|
691
|
+
hasDeclaration = true;
|
|
692
|
+
if (!decl.prop.startsWith("--")) allCustomProperties = false;
|
|
693
|
+
});
|
|
694
|
+
return hasDeclaration && allCustomProperties;
|
|
695
|
+
}
|
|
696
|
+
function isEmptyContentInitDeclaration(decl) {
|
|
697
|
+
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
698
|
+
}
|
|
699
|
+
function removeEmptyContentInitDeclarations(rule) {
|
|
700
|
+
rule.walkDecls((decl) => {
|
|
701
|
+
if (isEmptyContentInitDeclaration(decl)) decl.remove();
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function usesTwContentVariable(root) {
|
|
705
|
+
let used = false;
|
|
706
|
+
root.walkDecls((decl) => {
|
|
707
|
+
if (CONTENT_VAR_RE.test(decl.value)) used = true;
|
|
708
|
+
});
|
|
709
|
+
return used;
|
|
710
|
+
}
|
|
711
|
+
function isPseudoContentInitRule(rule) {
|
|
712
|
+
const selector = rule.selector.replace(/\s+/g, "");
|
|
713
|
+
if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
|
|
714
|
+
let hasDeclaration = false;
|
|
715
|
+
let onlyContentVariable = true;
|
|
716
|
+
rule.walkDecls((decl) => {
|
|
717
|
+
hasDeclaration = true;
|
|
718
|
+
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
719
|
+
});
|
|
720
|
+
return hasDeclaration && onlyContentVariable;
|
|
721
|
+
}
|
|
722
|
+
function isMiniProgramPreflightRule(rule) {
|
|
723
|
+
const selectors = getRuleSelectors(rule);
|
|
724
|
+
if (selectors.length === 0 || !selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) || !selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after")) return false;
|
|
725
|
+
let hasTailwindVariable = false;
|
|
726
|
+
let hasResetProp = false;
|
|
727
|
+
rule.walkDecls((decl) => {
|
|
728
|
+
if (decl.prop.startsWith("--tw-")) hasTailwindVariable = true;
|
|
729
|
+
if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
|
|
730
|
+
});
|
|
731
|
+
return hasTailwindVariable || hasResetProp;
|
|
732
|
+
}
|
|
733
|
+
function isKeyframesRule(rule) {
|
|
734
|
+
let parent = rule.parent;
|
|
735
|
+
while (parent) {
|
|
736
|
+
if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
|
|
737
|
+
parent = parent.parent;
|
|
738
|
+
}
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
|
|
743
|
+
*
|
|
744
|
+
* 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
|
|
745
|
+
* 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
|
|
746
|
+
*/
|
|
747
|
+
function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
748
|
+
const root = postcss.parse(css);
|
|
749
|
+
const shouldPreserveContentInit = options.preservePreflight || usesTwContentVariable(root);
|
|
750
|
+
root.walkComments((comment) => {
|
|
751
|
+
comment.remove();
|
|
752
|
+
});
|
|
753
|
+
removeUnsupportedCascadeLayers(root);
|
|
754
|
+
root.walkAtRules("supports", (atRule) => {
|
|
755
|
+
atRule.remove();
|
|
756
|
+
});
|
|
757
|
+
root.walkRules((rule) => {
|
|
758
|
+
if (isKeyframesRule(rule)) return;
|
|
759
|
+
if (hasClassSelector(rule.selector)) return;
|
|
760
|
+
if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
|
|
761
|
+
if (isPseudoContentInitRule(rule)) {
|
|
762
|
+
if (!shouldPreserveContentInit) rule.remove();
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
766
|
+
if (isCustomPropertyRule(rule)) {
|
|
767
|
+
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
rule.remove();
|
|
771
|
+
});
|
|
772
|
+
root.walkAtRules((atRule) => {
|
|
773
|
+
if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
|
|
774
|
+
});
|
|
775
|
+
return root.toString();
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
779
|
+
const defaultStyleHandler$1 = createStyleHandler({
|
|
780
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
781
|
+
cssRemoveHoverPseudoClass: true,
|
|
782
|
+
isMainChunk: true,
|
|
783
|
+
majorVersion: 4
|
|
784
|
+
});
|
|
785
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
786
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
787
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
788
|
+
try {
|
|
789
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
790
|
+
} catch {
|
|
791
|
+
return match;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
796
|
+
const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(css));
|
|
797
|
+
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
798
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
799
|
+
cssRemoveHoverPseudoClass: true,
|
|
800
|
+
isMainChunk: true,
|
|
801
|
+
majorVersion: 4,
|
|
802
|
+
...options
|
|
803
|
+
});
|
|
804
|
+
return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css));
|
|
805
|
+
}
|
|
806
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
807
|
+
return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
|
|
808
|
+
}
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
811
|
+
const TAILWIND_V3_COLOR_STEPS = [
|
|
812
|
+
"50",
|
|
813
|
+
"100",
|
|
814
|
+
"200",
|
|
815
|
+
"300",
|
|
816
|
+
"400",
|
|
817
|
+
"500",
|
|
818
|
+
"600",
|
|
819
|
+
"700",
|
|
820
|
+
"800",
|
|
821
|
+
"900",
|
|
822
|
+
"950"
|
|
823
|
+
];
|
|
824
|
+
const TAILWIND_V3_COLOR_PALETTE = {
|
|
825
|
+
slate: [
|
|
826
|
+
"#f8fafc",
|
|
827
|
+
"#f1f5f9",
|
|
828
|
+
"#e2e8f0",
|
|
829
|
+
"#cbd5e1",
|
|
830
|
+
"#94a3b8",
|
|
831
|
+
"#64748b",
|
|
832
|
+
"#475569",
|
|
833
|
+
"#334155",
|
|
834
|
+
"#1e293b",
|
|
835
|
+
"#0f172a",
|
|
836
|
+
"#020617"
|
|
837
|
+
],
|
|
838
|
+
gray: [
|
|
839
|
+
"#f9fafb",
|
|
840
|
+
"#f3f4f6",
|
|
841
|
+
"#e5e7eb",
|
|
842
|
+
"#d1d5db",
|
|
843
|
+
"#9ca3af",
|
|
844
|
+
"#6b7280",
|
|
845
|
+
"#4b5563",
|
|
846
|
+
"#374151",
|
|
847
|
+
"#1f2937",
|
|
848
|
+
"#111827",
|
|
849
|
+
"#030712"
|
|
850
|
+
],
|
|
851
|
+
zinc: [
|
|
852
|
+
"#fafafa",
|
|
853
|
+
"#f4f4f5",
|
|
854
|
+
"#e4e4e7",
|
|
855
|
+
"#d4d4d8",
|
|
856
|
+
"#a1a1aa",
|
|
857
|
+
"#71717a",
|
|
858
|
+
"#52525b",
|
|
859
|
+
"#3f3f46",
|
|
860
|
+
"#27272a",
|
|
861
|
+
"#18181b",
|
|
862
|
+
"#09090b"
|
|
863
|
+
],
|
|
864
|
+
neutral: [
|
|
865
|
+
"#fafafa",
|
|
866
|
+
"#f5f5f5",
|
|
867
|
+
"#e5e5e5",
|
|
868
|
+
"#d4d4d4",
|
|
869
|
+
"#a3a3a3",
|
|
870
|
+
"#737373",
|
|
871
|
+
"#525252",
|
|
872
|
+
"#404040",
|
|
873
|
+
"#262626",
|
|
874
|
+
"#171717",
|
|
875
|
+
"#0a0a0a"
|
|
876
|
+
],
|
|
877
|
+
stone: [
|
|
878
|
+
"#fafaf9",
|
|
879
|
+
"#f5f5f4",
|
|
880
|
+
"#e7e5e4",
|
|
881
|
+
"#d6d3d1",
|
|
882
|
+
"#a8a29e",
|
|
883
|
+
"#78716c",
|
|
884
|
+
"#57534e",
|
|
885
|
+
"#44403c",
|
|
886
|
+
"#292524",
|
|
887
|
+
"#1c1917",
|
|
888
|
+
"#0c0a09"
|
|
889
|
+
],
|
|
890
|
+
red: [
|
|
891
|
+
"#fef2f2",
|
|
892
|
+
"#fee2e2",
|
|
893
|
+
"#fecaca",
|
|
894
|
+
"#fca5a5",
|
|
895
|
+
"#f87171",
|
|
896
|
+
"#ef4444",
|
|
897
|
+
"#dc2626",
|
|
898
|
+
"#b91c1c",
|
|
899
|
+
"#991b1b",
|
|
900
|
+
"#7f1d1d",
|
|
901
|
+
"#450a0a"
|
|
902
|
+
],
|
|
903
|
+
orange: [
|
|
904
|
+
"#fff7ed",
|
|
905
|
+
"#ffedd5",
|
|
906
|
+
"#fed7aa",
|
|
907
|
+
"#fdba74",
|
|
908
|
+
"#fb923c",
|
|
909
|
+
"#f97316",
|
|
910
|
+
"#ea580c",
|
|
911
|
+
"#c2410c",
|
|
912
|
+
"#9a3412",
|
|
913
|
+
"#7c2d12",
|
|
914
|
+
"#431407"
|
|
915
|
+
],
|
|
916
|
+
amber: [
|
|
917
|
+
"#fffbeb",
|
|
918
|
+
"#fef3c7",
|
|
919
|
+
"#fde68a",
|
|
920
|
+
"#fcd34d",
|
|
921
|
+
"#fbbf24",
|
|
922
|
+
"#f59e0b",
|
|
923
|
+
"#d97706",
|
|
924
|
+
"#b45309",
|
|
925
|
+
"#92400e",
|
|
926
|
+
"#78350f",
|
|
927
|
+
"#451a03"
|
|
928
|
+
],
|
|
929
|
+
yellow: [
|
|
930
|
+
"#fefce8",
|
|
931
|
+
"#fef9c3",
|
|
932
|
+
"#fef08a",
|
|
933
|
+
"#fde047",
|
|
934
|
+
"#facc15",
|
|
935
|
+
"#eab308",
|
|
936
|
+
"#ca8a04",
|
|
937
|
+
"#a16207",
|
|
938
|
+
"#854d0e",
|
|
939
|
+
"#713f12",
|
|
940
|
+
"#422006"
|
|
941
|
+
],
|
|
942
|
+
lime: [
|
|
943
|
+
"#f7fee7",
|
|
944
|
+
"#ecfccb",
|
|
945
|
+
"#d9f99d",
|
|
946
|
+
"#bef264",
|
|
947
|
+
"#a3e635",
|
|
948
|
+
"#84cc16",
|
|
949
|
+
"#65a30d",
|
|
950
|
+
"#4d7c0f",
|
|
951
|
+
"#3f6212",
|
|
952
|
+
"#365314",
|
|
953
|
+
"#1a2e05"
|
|
954
|
+
],
|
|
955
|
+
green: [
|
|
956
|
+
"#f0fdf4",
|
|
957
|
+
"#dcfce7",
|
|
958
|
+
"#bbf7d0",
|
|
959
|
+
"#86efac",
|
|
960
|
+
"#4ade80",
|
|
961
|
+
"#22c55e",
|
|
962
|
+
"#16a34a",
|
|
963
|
+
"#15803d",
|
|
964
|
+
"#166534",
|
|
965
|
+
"#14532d",
|
|
966
|
+
"#052e16"
|
|
967
|
+
],
|
|
968
|
+
emerald: [
|
|
969
|
+
"#ecfdf5",
|
|
970
|
+
"#d1fae5",
|
|
971
|
+
"#a7f3d0",
|
|
972
|
+
"#6ee7b7",
|
|
973
|
+
"#34d399",
|
|
974
|
+
"#10b981",
|
|
975
|
+
"#059669",
|
|
976
|
+
"#047857",
|
|
977
|
+
"#065f46",
|
|
978
|
+
"#064e3b",
|
|
979
|
+
"#022c22"
|
|
980
|
+
],
|
|
981
|
+
teal: [
|
|
982
|
+
"#f0fdfa",
|
|
983
|
+
"#ccfbf1",
|
|
984
|
+
"#99f6e4",
|
|
985
|
+
"#5eead4",
|
|
986
|
+
"#2dd4bf",
|
|
987
|
+
"#14b8a6",
|
|
988
|
+
"#0d9488",
|
|
989
|
+
"#0f766e",
|
|
990
|
+
"#115e59",
|
|
991
|
+
"#134e4a",
|
|
992
|
+
"#042f2e"
|
|
993
|
+
],
|
|
994
|
+
cyan: [
|
|
995
|
+
"#ecfeff",
|
|
996
|
+
"#cffafe",
|
|
997
|
+
"#a5f3fc",
|
|
998
|
+
"#67e8f9",
|
|
999
|
+
"#22d3ee",
|
|
1000
|
+
"#06b6d4",
|
|
1001
|
+
"#0891b2",
|
|
1002
|
+
"#0e7490",
|
|
1003
|
+
"#155e75",
|
|
1004
|
+
"#164e63",
|
|
1005
|
+
"#083344"
|
|
1006
|
+
],
|
|
1007
|
+
sky: [
|
|
1008
|
+
"#f0f9ff",
|
|
1009
|
+
"#e0f2fe",
|
|
1010
|
+
"#bae6fd",
|
|
1011
|
+
"#7dd3fc",
|
|
1012
|
+
"#38bdf8",
|
|
1013
|
+
"#0ea5e9",
|
|
1014
|
+
"#0284c7",
|
|
1015
|
+
"#0369a1",
|
|
1016
|
+
"#075985",
|
|
1017
|
+
"#0c4a6e",
|
|
1018
|
+
"#082f49"
|
|
1019
|
+
],
|
|
1020
|
+
blue: [
|
|
1021
|
+
"#eff6ff",
|
|
1022
|
+
"#dbeafe",
|
|
1023
|
+
"#bfdbfe",
|
|
1024
|
+
"#93c5fd",
|
|
1025
|
+
"#60a5fa",
|
|
1026
|
+
"#3b82f6",
|
|
1027
|
+
"#2563eb",
|
|
1028
|
+
"#1d4ed8",
|
|
1029
|
+
"#1e40af",
|
|
1030
|
+
"#1e3a8a",
|
|
1031
|
+
"#172554"
|
|
1032
|
+
],
|
|
1033
|
+
indigo: [
|
|
1034
|
+
"#eef2ff",
|
|
1035
|
+
"#e0e7ff",
|
|
1036
|
+
"#c7d2fe",
|
|
1037
|
+
"#a5b4fc",
|
|
1038
|
+
"#818cf8",
|
|
1039
|
+
"#6366f1",
|
|
1040
|
+
"#4f46e5",
|
|
1041
|
+
"#4338ca",
|
|
1042
|
+
"#3730a3",
|
|
1043
|
+
"#312e81",
|
|
1044
|
+
"#1e1b4b"
|
|
1045
|
+
],
|
|
1046
|
+
violet: [
|
|
1047
|
+
"#f5f3ff",
|
|
1048
|
+
"#ede9fe",
|
|
1049
|
+
"#ddd6fe",
|
|
1050
|
+
"#c4b5fd",
|
|
1051
|
+
"#a78bfa",
|
|
1052
|
+
"#8b5cf6",
|
|
1053
|
+
"#7c3aed",
|
|
1054
|
+
"#6d28d9",
|
|
1055
|
+
"#5b21b6",
|
|
1056
|
+
"#4c1d95",
|
|
1057
|
+
"#2e1065"
|
|
1058
|
+
],
|
|
1059
|
+
purple: [
|
|
1060
|
+
"#faf5ff",
|
|
1061
|
+
"#f3e8ff",
|
|
1062
|
+
"#e9d5ff",
|
|
1063
|
+
"#d8b4fe",
|
|
1064
|
+
"#c084fc",
|
|
1065
|
+
"#a855f7",
|
|
1066
|
+
"#9333ea",
|
|
1067
|
+
"#7e22ce",
|
|
1068
|
+
"#6b21a8",
|
|
1069
|
+
"#581c87",
|
|
1070
|
+
"#3b0764"
|
|
1071
|
+
],
|
|
1072
|
+
fuchsia: [
|
|
1073
|
+
"#fdf4ff",
|
|
1074
|
+
"#fae8ff",
|
|
1075
|
+
"#f5d0fe",
|
|
1076
|
+
"#f0abfc",
|
|
1077
|
+
"#e879f9",
|
|
1078
|
+
"#d946ef",
|
|
1079
|
+
"#c026d3",
|
|
1080
|
+
"#a21caf",
|
|
1081
|
+
"#86198f",
|
|
1082
|
+
"#701a75",
|
|
1083
|
+
"#4a044e"
|
|
1084
|
+
],
|
|
1085
|
+
pink: [
|
|
1086
|
+
"#fdf2f8",
|
|
1087
|
+
"#fce7f3",
|
|
1088
|
+
"#fbcfe8",
|
|
1089
|
+
"#f9a8d4",
|
|
1090
|
+
"#f472b6",
|
|
1091
|
+
"#ec4899",
|
|
1092
|
+
"#db2777",
|
|
1093
|
+
"#be185d",
|
|
1094
|
+
"#9d174d",
|
|
1095
|
+
"#831843",
|
|
1096
|
+
"#500724"
|
|
1097
|
+
],
|
|
1098
|
+
rose: [
|
|
1099
|
+
"#fff1f2",
|
|
1100
|
+
"#ffe4e6",
|
|
1101
|
+
"#fecdd3",
|
|
1102
|
+
"#fda4af",
|
|
1103
|
+
"#fb7185",
|
|
1104
|
+
"#f43f5e",
|
|
1105
|
+
"#e11d48",
|
|
1106
|
+
"#be123c",
|
|
1107
|
+
"#9f1239",
|
|
1108
|
+
"#881337",
|
|
1109
|
+
"#4c0519"
|
|
1110
|
+
]
|
|
1111
|
+
};
|
|
1112
|
+
function createTailwindV3DefaultColorThemeCss() {
|
|
1113
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
1114
|
+
for (const [color, values] of Object.entries(TAILWIND_V3_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V3_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V3_COLOR_STEPS[index]}: ${values[index]};`);
|
|
1115
|
+
return [
|
|
1116
|
+
"@theme {",
|
|
1117
|
+
...declarations,
|
|
1118
|
+
"}"
|
|
1119
|
+
].join("\n");
|
|
1120
|
+
}
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region src/tailwindcss/v4-engine/tailwind-v3-compatibility.ts
|
|
1123
|
+
const TAILWIND_V3_COMPATIBILITY_THEME_CSS = [
|
|
1124
|
+
"@theme {",
|
|
1125
|
+
" --default-ring-width: 3px;",
|
|
1126
|
+
" --default-ring-color: var(--color-blue-500, #3b82f6);",
|
|
1127
|
+
" --default-outline-width: 3px;",
|
|
1128
|
+
"",
|
|
1129
|
+
" --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
|
|
1130
|
+
" --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
|
|
1131
|
+
" --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
|
|
1132
|
+
" --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
|
|
1133
|
+
" --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
|
|
1134
|
+
" --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
|
|
1135
|
+
"",
|
|
1136
|
+
" --blur-xs: 4px;",
|
|
1137
|
+
" --blur-sm: 4px;",
|
|
1138
|
+
" --blur: 8px;",
|
|
1139
|
+
" --backdrop-blur-xs: 4px;",
|
|
1140
|
+
" --backdrop-blur-sm: 4px;",
|
|
1141
|
+
" --backdrop-blur: 8px;",
|
|
1142
|
+
"",
|
|
1143
|
+
" --radius-xs: 0.125rem;",
|
|
1144
|
+
" --radius-sm: 0.125rem;",
|
|
1145
|
+
" --radius: 0.25rem;",
|
|
1146
|
+
"}",
|
|
1147
|
+
createTailwindV3DefaultColorThemeCss()
|
|
1148
|
+
].join("\n");
|
|
1149
|
+
const TAILWIND_V3_COMPATIBILITY_BASE_CSS = [
|
|
1150
|
+
"*,",
|
|
1151
|
+
"::after,",
|
|
1152
|
+
"::before,",
|
|
1153
|
+
"::backdrop,",
|
|
1154
|
+
"::file-selector-button {",
|
|
1155
|
+
" border-color: var(--color-gray-200, currentcolor);",
|
|
1156
|
+
"}",
|
|
1157
|
+
"",
|
|
1158
|
+
"input::placeholder,",
|
|
1159
|
+
"textarea::placeholder {",
|
|
1160
|
+
" opacity: 1;",
|
|
1161
|
+
" color: var(--color-gray-400, currentcolor);",
|
|
1162
|
+
"}",
|
|
1163
|
+
"",
|
|
1164
|
+
"button:not(:disabled),",
|
|
1165
|
+
"[role=\"button\"]:not(:disabled) {",
|
|
1166
|
+
" cursor: pointer;",
|
|
1167
|
+
"}",
|
|
1168
|
+
"",
|
|
1169
|
+
"dialog {",
|
|
1170
|
+
" margin: auto;",
|
|
1171
|
+
"}"
|
|
1172
|
+
].join("\n");
|
|
1173
|
+
function applyTailwindV3CompatibilityCss(css) {
|
|
1174
|
+
return `${TAILWIND_V3_COMPATIBILITY_THEME_CSS}\n${css}\n${TAILWIND_V3_COMPATIBILITY_BASE_CSS}`;
|
|
1175
|
+
}
|
|
1176
|
+
//#endregion
|
|
1177
|
+
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
1178
|
+
const TAILWIND_V4_COLOR_STEPS = [
|
|
1179
|
+
"50",
|
|
1180
|
+
"100",
|
|
1181
|
+
"200",
|
|
1182
|
+
"300",
|
|
1183
|
+
"400",
|
|
1184
|
+
"500",
|
|
1185
|
+
"600",
|
|
1186
|
+
"700",
|
|
1187
|
+
"800",
|
|
1188
|
+
"900",
|
|
1189
|
+
"950"
|
|
1190
|
+
];
|
|
1191
|
+
const TAILWIND_V4_COLOR_PALETTE = {
|
|
1192
|
+
slate: [
|
|
1193
|
+
"#f8fafc",
|
|
1194
|
+
"#f1f5f9",
|
|
1195
|
+
"#e2e8f0",
|
|
1196
|
+
"#cad5e2",
|
|
1197
|
+
"#90a1b9",
|
|
1198
|
+
"#62748e",
|
|
1199
|
+
"#45556c",
|
|
1200
|
+
"#314158",
|
|
1201
|
+
"#1d293d",
|
|
1202
|
+
"#0f172b",
|
|
1203
|
+
"#020618"
|
|
1204
|
+
],
|
|
1205
|
+
gray: [
|
|
1206
|
+
"#f9fafb",
|
|
1207
|
+
"#f3f4f6",
|
|
1208
|
+
"#e5e7eb",
|
|
1209
|
+
"#d1d5dc",
|
|
1210
|
+
"#99a1af",
|
|
1211
|
+
"#6a7282",
|
|
1212
|
+
"#4a5565",
|
|
1213
|
+
"#364153",
|
|
1214
|
+
"#1e2939",
|
|
1215
|
+
"#101828",
|
|
1216
|
+
"#030712"
|
|
1217
|
+
],
|
|
1218
|
+
zinc: [
|
|
1219
|
+
"#fafafa",
|
|
1220
|
+
"#f4f4f5",
|
|
1221
|
+
"#e4e4e7",
|
|
1222
|
+
"#d4d4d8",
|
|
1223
|
+
"#9f9fa9",
|
|
1224
|
+
"#71717b",
|
|
1225
|
+
"#52525c",
|
|
1226
|
+
"#3f3f46",
|
|
1227
|
+
"#27272a",
|
|
1228
|
+
"#18181b",
|
|
1229
|
+
"#09090b"
|
|
1230
|
+
],
|
|
1231
|
+
neutral: [
|
|
1232
|
+
"#fafafa",
|
|
1233
|
+
"#f5f5f5",
|
|
1234
|
+
"#e5e5e5",
|
|
1235
|
+
"#d4d4d4",
|
|
1236
|
+
"#a1a1a1",
|
|
1237
|
+
"#737373",
|
|
1238
|
+
"#525252",
|
|
1239
|
+
"#404040",
|
|
1240
|
+
"#262626",
|
|
1241
|
+
"#171717",
|
|
1242
|
+
"#0a0a0a"
|
|
1243
|
+
],
|
|
1244
|
+
stone: [
|
|
1245
|
+
"#fafaf9",
|
|
1246
|
+
"#f5f5f4",
|
|
1247
|
+
"#e7e5e4",
|
|
1248
|
+
"#d6d3d1",
|
|
1249
|
+
"#a6a09b",
|
|
1250
|
+
"#79716b",
|
|
1251
|
+
"#57534d",
|
|
1252
|
+
"#44403b",
|
|
1253
|
+
"#292524",
|
|
1254
|
+
"#1c1917",
|
|
1255
|
+
"#0c0a09"
|
|
1256
|
+
],
|
|
1257
|
+
mauve: [
|
|
1258
|
+
"#fafafa",
|
|
1259
|
+
"#f3f1f3",
|
|
1260
|
+
"#e7e4e7",
|
|
1261
|
+
"#d7d0d7",
|
|
1262
|
+
"#a89ea9",
|
|
1263
|
+
"#79697b",
|
|
1264
|
+
"#594c5b",
|
|
1265
|
+
"#463947",
|
|
1266
|
+
"#2a212c",
|
|
1267
|
+
"#1d161e",
|
|
1268
|
+
"#0c090c"
|
|
1269
|
+
],
|
|
1270
|
+
olive: [
|
|
1271
|
+
"#fbfbf9",
|
|
1272
|
+
"#f4f4f0",
|
|
1273
|
+
"#e8e8e3",
|
|
1274
|
+
"#d8d8d0",
|
|
1275
|
+
"#abab9c",
|
|
1276
|
+
"#7c7c67",
|
|
1277
|
+
"#5b5b4b",
|
|
1278
|
+
"#474739",
|
|
1279
|
+
"#2b2b22",
|
|
1280
|
+
"#1d1d16",
|
|
1281
|
+
"#0c0c09"
|
|
1282
|
+
],
|
|
1283
|
+
mist: [
|
|
1284
|
+
"#f9fbfb",
|
|
1285
|
+
"#f1f3f3",
|
|
1286
|
+
"#e3e7e8",
|
|
1287
|
+
"#d0d6d8",
|
|
1288
|
+
"#9ca8ab",
|
|
1289
|
+
"#67787c",
|
|
1290
|
+
"#4b585b",
|
|
1291
|
+
"#394447",
|
|
1292
|
+
"#22292b",
|
|
1293
|
+
"#161b1d",
|
|
1294
|
+
"#090b0c"
|
|
1295
|
+
],
|
|
1296
|
+
taupe: [
|
|
1297
|
+
"#fbfaf9",
|
|
1298
|
+
"#f3f1f1",
|
|
1299
|
+
"#e8e4e3",
|
|
1300
|
+
"#d8d2d0",
|
|
1301
|
+
"#aba09c",
|
|
1302
|
+
"#7c6d67",
|
|
1303
|
+
"#5b4f4b",
|
|
1304
|
+
"#473c39",
|
|
1305
|
+
"#2b2422",
|
|
1306
|
+
"#1d1816",
|
|
1307
|
+
"#0c0a09"
|
|
1308
|
+
],
|
|
1309
|
+
red: [
|
|
1310
|
+
"#fef2f2",
|
|
1311
|
+
"#ffe2e2",
|
|
1312
|
+
"#ffc9c9",
|
|
1313
|
+
"#ffa2a2",
|
|
1314
|
+
"#ff6467",
|
|
1315
|
+
"#fb2c36",
|
|
1316
|
+
"#e7000b",
|
|
1317
|
+
"#c10007",
|
|
1318
|
+
"#9f0712",
|
|
1319
|
+
"#82181a",
|
|
1320
|
+
"#460809"
|
|
1321
|
+
],
|
|
1322
|
+
orange: [
|
|
1323
|
+
"#fff7ed",
|
|
1324
|
+
"#ffedd4",
|
|
1325
|
+
"#ffd6a7",
|
|
1326
|
+
"#ffb86a",
|
|
1327
|
+
"#ff8904",
|
|
1328
|
+
"#ff6900",
|
|
1329
|
+
"#f54900",
|
|
1330
|
+
"#ca3500",
|
|
1331
|
+
"#9f2d00",
|
|
1332
|
+
"#7e2a0c",
|
|
1333
|
+
"#441306"
|
|
1334
|
+
],
|
|
1335
|
+
amber: [
|
|
1336
|
+
"#fffbeb",
|
|
1337
|
+
"#fef3c6",
|
|
1338
|
+
"#fee685",
|
|
1339
|
+
"#ffd230",
|
|
1340
|
+
"#ffb900",
|
|
1341
|
+
"#fe9a00",
|
|
1342
|
+
"#e17100",
|
|
1343
|
+
"#bb4d00",
|
|
1344
|
+
"#973c00",
|
|
1345
|
+
"#7b3306",
|
|
1346
|
+
"#461901"
|
|
1347
|
+
],
|
|
1348
|
+
yellow: [
|
|
1349
|
+
"#fefce8",
|
|
1350
|
+
"#fef9c2",
|
|
1351
|
+
"#fff085",
|
|
1352
|
+
"#ffdf20",
|
|
1353
|
+
"#fdc700",
|
|
1354
|
+
"#f0b100",
|
|
1355
|
+
"#d08700",
|
|
1356
|
+
"#a65f00",
|
|
1357
|
+
"#894b00",
|
|
1358
|
+
"#733e0a",
|
|
1359
|
+
"#432004"
|
|
1360
|
+
],
|
|
1361
|
+
lime: [
|
|
1362
|
+
"#f7fee7",
|
|
1363
|
+
"#ecfcca",
|
|
1364
|
+
"#d8f999",
|
|
1365
|
+
"#bbf451",
|
|
1366
|
+
"#9ae600",
|
|
1367
|
+
"#7ccf00",
|
|
1368
|
+
"#5ea500",
|
|
1369
|
+
"#497d00",
|
|
1370
|
+
"#3c6300",
|
|
1371
|
+
"#35530e",
|
|
1372
|
+
"#192e03"
|
|
1373
|
+
],
|
|
1374
|
+
green: [
|
|
1375
|
+
"#f0fdf4",
|
|
1376
|
+
"#dcfce7",
|
|
1377
|
+
"#b9f8cf",
|
|
1378
|
+
"#7bf1a8",
|
|
1379
|
+
"#05df72",
|
|
1380
|
+
"#00c950",
|
|
1381
|
+
"#00a63e",
|
|
1382
|
+
"#008236",
|
|
1383
|
+
"#016630",
|
|
1384
|
+
"#0d542b",
|
|
1385
|
+
"#032e15"
|
|
1386
|
+
],
|
|
1387
|
+
emerald: [
|
|
1388
|
+
"#ecfdf5",
|
|
1389
|
+
"#d0fae5",
|
|
1390
|
+
"#a4f4cf",
|
|
1391
|
+
"#5ee9b5",
|
|
1392
|
+
"#00d492",
|
|
1393
|
+
"#00bc7d",
|
|
1394
|
+
"#009966",
|
|
1395
|
+
"#007a55",
|
|
1396
|
+
"#006045",
|
|
1397
|
+
"#004f3b",
|
|
1398
|
+
"#002c22"
|
|
1399
|
+
],
|
|
1400
|
+
teal: [
|
|
1401
|
+
"#f0fdfa",
|
|
1402
|
+
"#cbfbf1",
|
|
1403
|
+
"#96f7e4",
|
|
1404
|
+
"#46ecd5",
|
|
1405
|
+
"#00d5be",
|
|
1406
|
+
"#00bba7",
|
|
1407
|
+
"#009689",
|
|
1408
|
+
"#00786f",
|
|
1409
|
+
"#005f5a",
|
|
1410
|
+
"#0b4f4a",
|
|
1411
|
+
"#022f2e"
|
|
1412
|
+
],
|
|
1413
|
+
cyan: [
|
|
1414
|
+
"#ecfeff",
|
|
1415
|
+
"#cefafe",
|
|
1416
|
+
"#a2f4fd",
|
|
1417
|
+
"#53eafd",
|
|
1418
|
+
"#00d3f2",
|
|
1419
|
+
"#00b8db",
|
|
1420
|
+
"#0092b8",
|
|
1421
|
+
"#007595",
|
|
1422
|
+
"#005f78",
|
|
1423
|
+
"#104e64",
|
|
1424
|
+
"#053345"
|
|
1425
|
+
],
|
|
1426
|
+
sky: [
|
|
1427
|
+
"#f0f9ff",
|
|
1428
|
+
"#dff2fe",
|
|
1429
|
+
"#b8e6fe",
|
|
1430
|
+
"#74d4ff",
|
|
1431
|
+
"#00bcff",
|
|
1432
|
+
"#00a6f4",
|
|
1433
|
+
"#0084d1",
|
|
1434
|
+
"#0069a8",
|
|
1435
|
+
"#00598a",
|
|
1436
|
+
"#024a70",
|
|
1437
|
+
"#052f4a"
|
|
1438
|
+
],
|
|
1439
|
+
blue: [
|
|
1440
|
+
"#eff6ff",
|
|
1441
|
+
"#dbeafe",
|
|
1442
|
+
"#bedbff",
|
|
1443
|
+
"#8ec5ff",
|
|
1444
|
+
"#51a2ff",
|
|
1445
|
+
"#2b7fff",
|
|
1446
|
+
"#155dfc",
|
|
1447
|
+
"#1447e6",
|
|
1448
|
+
"#193cb8",
|
|
1449
|
+
"#1c398e",
|
|
1450
|
+
"#162456"
|
|
1451
|
+
],
|
|
1452
|
+
indigo: [
|
|
1453
|
+
"#eef2ff",
|
|
1454
|
+
"#e0e7ff",
|
|
1455
|
+
"#c6d2ff",
|
|
1456
|
+
"#a3b3ff",
|
|
1457
|
+
"#7c86ff",
|
|
1458
|
+
"#615fff",
|
|
1459
|
+
"#4f39f6",
|
|
1460
|
+
"#432dd7",
|
|
1461
|
+
"#372aac",
|
|
1462
|
+
"#312c85",
|
|
1463
|
+
"#1e1a4d"
|
|
1464
|
+
],
|
|
1465
|
+
violet: [
|
|
1466
|
+
"#f5f3ff",
|
|
1467
|
+
"#ede9fe",
|
|
1468
|
+
"#ddd6ff",
|
|
1469
|
+
"#c4b4ff",
|
|
1470
|
+
"#a684ff",
|
|
1471
|
+
"#8e51ff",
|
|
1472
|
+
"#7f22fe",
|
|
1473
|
+
"#7008e7",
|
|
1474
|
+
"#5d0ec0",
|
|
1475
|
+
"#4d179a",
|
|
1476
|
+
"#2f0d68"
|
|
1477
|
+
],
|
|
1478
|
+
purple: [
|
|
1479
|
+
"#faf5ff",
|
|
1480
|
+
"#f3e8ff",
|
|
1481
|
+
"#e9d4ff",
|
|
1482
|
+
"#dab2ff",
|
|
1483
|
+
"#c27aff",
|
|
1484
|
+
"#ad46ff",
|
|
1485
|
+
"#9810fa",
|
|
1486
|
+
"#8200db",
|
|
1487
|
+
"#6e11b0",
|
|
1488
|
+
"#59168b",
|
|
1489
|
+
"#3c0366"
|
|
1490
|
+
],
|
|
1491
|
+
fuchsia: [
|
|
1492
|
+
"#fdf4ff",
|
|
1493
|
+
"#fae8ff",
|
|
1494
|
+
"#f6cfff",
|
|
1495
|
+
"#f4a8ff",
|
|
1496
|
+
"#ed6aff",
|
|
1497
|
+
"#e12afb",
|
|
1498
|
+
"#c800de",
|
|
1499
|
+
"#a800b7",
|
|
1500
|
+
"#8a0194",
|
|
1501
|
+
"#721378",
|
|
1502
|
+
"#4b004f"
|
|
1503
|
+
],
|
|
1504
|
+
pink: [
|
|
1505
|
+
"#fdf2f8",
|
|
1506
|
+
"#fce7f3",
|
|
1507
|
+
"#fccee8",
|
|
1508
|
+
"#fda5d5",
|
|
1509
|
+
"#fb64b6",
|
|
1510
|
+
"#f6339a",
|
|
1511
|
+
"#e60076",
|
|
1512
|
+
"#c6005c",
|
|
1513
|
+
"#a3004c",
|
|
1514
|
+
"#861043",
|
|
1515
|
+
"#510424"
|
|
1516
|
+
],
|
|
1517
|
+
rose: [
|
|
1518
|
+
"#fff1f2",
|
|
1519
|
+
"#ffe4e6",
|
|
1520
|
+
"#ffccd3",
|
|
1521
|
+
"#ffa1ad",
|
|
1522
|
+
"#ff637e",
|
|
1523
|
+
"#ff2056",
|
|
1524
|
+
"#ec003f",
|
|
1525
|
+
"#c70036",
|
|
1526
|
+
"#a50036",
|
|
1527
|
+
"#8b0836",
|
|
1528
|
+
"#4d0218"
|
|
1529
|
+
]
|
|
1530
|
+
};
|
|
1531
|
+
function createTailwindV4DefaultColorThemeCss() {
|
|
1532
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
1533
|
+
for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
|
|
1534
|
+
return [
|
|
1535
|
+
"@theme {",
|
|
1536
|
+
...declarations,
|
|
1537
|
+
"}"
|
|
1538
|
+
].join("\n");
|
|
1539
|
+
}
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1542
|
+
const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
|
|
1543
|
+
const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
|
|
1544
|
+
function findLeadingImportInsertionIndex(css) {
|
|
1545
|
+
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1546
|
+
let insertionIndex = 0;
|
|
1547
|
+
let match = importPattern.exec(css);
|
|
1548
|
+
while (match !== null) {
|
|
1549
|
+
insertionIndex = match.index + match[0].length;
|
|
1550
|
+
match = importPattern.exec(css);
|
|
1551
|
+
}
|
|
1552
|
+
return insertionIndex;
|
|
1553
|
+
}
|
|
1554
|
+
function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
1555
|
+
const themeCss = createTailwindV4DefaultColorThemeCss();
|
|
1556
|
+
const insertionIndex = findLeadingImportInsertionIndex(css);
|
|
1557
|
+
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
1558
|
+
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
1559
|
+
}
|
|
1560
|
+
function collectCandidates$1(candidates) {
|
|
1561
|
+
return new Set(candidates ?? []);
|
|
1562
|
+
}
|
|
1563
|
+
function createStableJson$1(value) {
|
|
1564
|
+
if (value === void 0) return "undefined";
|
|
1565
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1566
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
|
|
1567
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
1568
|
+
const record = value;
|
|
1569
|
+
return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
|
|
1570
|
+
}).join(",")}}`;
|
|
1571
|
+
}
|
|
1572
|
+
function createDependencyFingerprint$1(files) {
|
|
1573
|
+
return files.map((file) => {
|
|
1574
|
+
try {
|
|
1575
|
+
const stat = fs.statSync(file);
|
|
1576
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
1577
|
+
} catch {
|
|
1578
|
+
return `${file}:missing`;
|
|
1579
|
+
}
|
|
1580
|
+
}).join("|");
|
|
1581
|
+
}
|
|
1582
|
+
function createIncrementalGenerateCacheKey$1(source, target, styleOptions, tailwindcssV3Compatibility) {
|
|
1583
|
+
return [
|
|
1584
|
+
source.projectRoot,
|
|
1585
|
+
source.base,
|
|
1586
|
+
createStableJson$1(source.baseFallbacks),
|
|
1587
|
+
source.css,
|
|
1588
|
+
createDependencyFingerprint$1(source.dependencies),
|
|
1589
|
+
target,
|
|
1590
|
+
createStableJson$1(styleOptions),
|
|
1591
|
+
createStableJson$1(tailwindcssV3Compatibility)
|
|
1592
|
+
].join("\0");
|
|
1593
|
+
}
|
|
1594
|
+
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
1595
|
+
return [
|
|
1596
|
+
cacheKey,
|
|
1597
|
+
scanSources === true ? "scan:1" : "scan:0",
|
|
1598
|
+
[...requestedCandidates].sort().join("\n")
|
|
1599
|
+
].join("\0");
|
|
1600
|
+
}
|
|
1601
|
+
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
1602
|
+
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
1603
|
+
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
1604
|
+
if (cachedTask) return cachedTask;
|
|
1605
|
+
const promise = task();
|
|
1606
|
+
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
1607
|
+
promise.finally(() => {
|
|
1608
|
+
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
1609
|
+
});
|
|
1610
|
+
return promise;
|
|
1611
|
+
}
|
|
1612
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1613
|
+
const promise = loadTailwindV4DesignSystem(source);
|
|
1614
|
+
promise.catch(() => {
|
|
1615
|
+
if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
|
|
1616
|
+
});
|
|
1617
|
+
return promise;
|
|
1618
|
+
}
|
|
1619
|
+
function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
|
|
1620
|
+
const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
|
|
1621
|
+
const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
|
|
1622
|
+
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
1623
|
+
return compatibleSourceCss === source.css ? source : {
|
|
1624
|
+
...source,
|
|
1625
|
+
css: compatibleSourceCss
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
function resolveTargetCandidates(candidates, target) {
|
|
1629
|
+
const collected = collectCandidates$1(candidates);
|
|
1630
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1631
|
+
}
|
|
1632
|
+
function collectSeenCandidates(generated, requestedCandidates) {
|
|
1633
|
+
return new Set([
|
|
1634
|
+
...requestedCandidates,
|
|
1635
|
+
...generated.rawCandidates,
|
|
1636
|
+
...generated.classSet
|
|
1637
|
+
]);
|
|
1638
|
+
}
|
|
1639
|
+
function seedIncrementalGenerateCache(options) {
|
|
1640
|
+
const cacheKey = createIncrementalGenerateCacheKey$1(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1641
|
+
incrementalGenerateCache$1.set(cacheKey, {
|
|
1642
|
+
seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
|
|
1643
|
+
classSet: new Set(options.generated.classSet),
|
|
1644
|
+
css: options.generated.css,
|
|
1645
|
+
rawCss: options.generated.rawCss,
|
|
1646
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1647
|
+
dependencies: options.generated.dependencies,
|
|
1648
|
+
sources: options.generated.sources,
|
|
1649
|
+
root: options.generated.root,
|
|
1650
|
+
target: options.generated.target
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
function parseImportSourceParam$1(params) {
|
|
1654
|
+
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
1655
|
+
if (!match) return;
|
|
1656
|
+
return {
|
|
1657
|
+
none: match[1] === "none",
|
|
1658
|
+
sourcePath: match[3]
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
function isTailwindCssImport$1(params) {
|
|
1662
|
+
return /^\s*(['"])tailwindcss(?:\/[^'"]*)?\1/.test(params);
|
|
1663
|
+
}
|
|
1664
|
+
function parseCssImportSpecifier$1(params) {
|
|
1665
|
+
const value = params.trim();
|
|
1666
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1667
|
+
if (quoted) return quoted[2];
|
|
1668
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1669
|
+
return url?.[2] ?? url?.[3];
|
|
1670
|
+
}
|
|
1671
|
+
function isTailwindCssPreflightImport(params) {
|
|
1672
|
+
const specifier = parseCssImportSpecifier$1(params);
|
|
1673
|
+
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1674
|
+
}
|
|
1675
|
+
function hasImportLayerOption(params) {
|
|
1676
|
+
return /\blayer(?:\s*\(|\s*$)/.test(params);
|
|
1677
|
+
}
|
|
1678
|
+
function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
1679
|
+
if (!css.includes("preflight")) return css;
|
|
1680
|
+
let root;
|
|
1681
|
+
try {
|
|
1682
|
+
root = postcss.parse(css);
|
|
1683
|
+
} catch {
|
|
1684
|
+
return css;
|
|
1685
|
+
}
|
|
1686
|
+
let changed = false;
|
|
1687
|
+
root.walkAtRules("import", (rule) => {
|
|
1688
|
+
if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
|
|
1689
|
+
rule.remove();
|
|
1690
|
+
changed = true;
|
|
1691
|
+
}
|
|
1692
|
+
});
|
|
1693
|
+
return changed ? root.toString() : css;
|
|
1694
|
+
}
|
|
1695
|
+
function parseSourceFileParam(params) {
|
|
1696
|
+
const value = params.trim();
|
|
1697
|
+
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
1698
|
+
const negated = value.startsWith("not ");
|
|
1699
|
+
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
1700
|
+
if (sourceValue.startsWith("inline(")) return;
|
|
1701
|
+
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
1702
|
+
return match?.[2] ? {
|
|
1703
|
+
negated,
|
|
1704
|
+
pattern: match[2]
|
|
1705
|
+
} : void 0;
|
|
1706
|
+
}
|
|
1707
|
+
function resolveSourceBase$1(base, sourcePath) {
|
|
1708
|
+
return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
1709
|
+
}
|
|
1710
|
+
function resolveCssDefinedScanSources(source) {
|
|
1711
|
+
let importSourceBase;
|
|
1712
|
+
let hasSourceNone = false;
|
|
1713
|
+
const sourcePatterns = [];
|
|
1714
|
+
const from = source.dependencies[0];
|
|
1715
|
+
let root;
|
|
1716
|
+
try {
|
|
1717
|
+
root = postcss.parse(source.css, { from });
|
|
1718
|
+
} catch {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
root.walkAtRules((rule) => {
|
|
1722
|
+
if (rule.name === "import") {
|
|
1723
|
+
if (!isTailwindCssImport$1(rule.params)) return;
|
|
1724
|
+
const sourceParam = parseImportSourceParam$1(rule.params);
|
|
1725
|
+
if (sourceParam?.none) hasSourceNone = true;
|
|
1726
|
+
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase$1(source.base, sourceParam.sourcePath);
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
if (rule.name !== "source") return;
|
|
1730
|
+
const sourcePattern = parseSourceFileParam(rule.params);
|
|
1731
|
+
if (!sourcePattern) return;
|
|
1732
|
+
sourcePatterns.push({
|
|
1733
|
+
base: source.base,
|
|
1734
|
+
negated: sourcePattern.negated,
|
|
1735
|
+
pattern: sourcePattern.pattern
|
|
1736
|
+
});
|
|
1737
|
+
});
|
|
1738
|
+
if (!importSourceBase) {
|
|
1739
|
+
if (hasSourceNone) return sourcePatterns.length > 0 ? sourcePatterns : false;
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
return [{
|
|
1743
|
+
base: importSourceBase,
|
|
1744
|
+
negated: false,
|
|
1745
|
+
pattern: "**/*"
|
|
1746
|
+
}, ...sourcePatterns];
|
|
1747
|
+
}
|
|
1748
|
+
function resolveScanSources(source, scanSources) {
|
|
1749
|
+
if (scanSources !== true) return scanSources;
|
|
1750
|
+
return resolveCssDefinedScanSources(source) ?? scanSources;
|
|
1751
|
+
}
|
|
1752
|
+
function hasThemeParent(rule) {
|
|
1753
|
+
let parent = rule.parent;
|
|
1754
|
+
while (parent) {
|
|
1755
|
+
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
1756
|
+
parent = parent.parent;
|
|
1757
|
+
}
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1760
|
+
function isVendorPrefixedKeyframes(rule) {
|
|
1761
|
+
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
1762
|
+
}
|
|
1763
|
+
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
1764
|
+
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1765
|
+
let root;
|
|
1766
|
+
try {
|
|
1767
|
+
root = postcss.parse(css);
|
|
1768
|
+
} catch {
|
|
1769
|
+
return css;
|
|
1770
|
+
}
|
|
1771
|
+
let changed = false;
|
|
1772
|
+
root.walkAtRules((rule) => {
|
|
1773
|
+
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
1774
|
+
rule.remove();
|
|
1775
|
+
changed = true;
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
return changed ? root.toString() : css;
|
|
1779
|
+
}
|
|
1780
|
+
function createTailwindV4Engine$1(source) {
|
|
1781
|
+
async function generateOnce(generateSource, options = {}) {
|
|
1782
|
+
const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
|
|
1783
|
+
const compatibleSource = createCompatibleSource(generateSource, target, tailwindcssV3Compatibility);
|
|
1784
|
+
const candidates = resolveTargetCandidates(patchOptions.candidates, target);
|
|
1785
|
+
const result = await createTailwindV4Engine(compatibleSource).generate(omitUndefined({
|
|
1786
|
+
scanSources: resolveScanSources(compatibleSource, scanSources),
|
|
1787
|
+
...patchOptions,
|
|
1788
|
+
candidates
|
|
1789
|
+
}));
|
|
1790
|
+
const rawCss = result.css;
|
|
1791
|
+
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
1792
|
+
return {
|
|
1793
|
+
...result,
|
|
1794
|
+
css,
|
|
1795
|
+
rawCss,
|
|
1796
|
+
target
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
async function generateWithIncrementalCache(options = {}) {
|
|
1800
|
+
const target = options.target ?? "weapp";
|
|
1801
|
+
const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
|
|
1802
|
+
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1803
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
|
|
1804
|
+
const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, options.styleOptions, options.tailwindcssV3Compatibility);
|
|
1805
|
+
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1806
|
+
const generated = await generateOnce(source, options);
|
|
1807
|
+
seedIncrementalGenerateCache({
|
|
1808
|
+
compatibleSource,
|
|
1809
|
+
generated,
|
|
1810
|
+
requestedCandidates,
|
|
1811
|
+
styleOptions: options.styleOptions,
|
|
1812
|
+
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
|
|
1813
|
+
target
|
|
1814
|
+
});
|
|
1815
|
+
return generated;
|
|
1816
|
+
});
|
|
1817
|
+
const cached = incrementalGenerateCache$1.get(cacheKey);
|
|
1818
|
+
if (cached) {
|
|
1819
|
+
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
1820
|
+
if (missingCandidates.length === 0) return {
|
|
1821
|
+
css: cached.css,
|
|
1822
|
+
rawCss: cached.rawCss,
|
|
1823
|
+
incrementalCss: "",
|
|
1824
|
+
incrementalRawCss: "",
|
|
1825
|
+
classSet: new Set(cached.classSet),
|
|
1826
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
1827
|
+
dependencies: cached.dependencies,
|
|
1828
|
+
sources: cached.sources,
|
|
1829
|
+
root: cached.root,
|
|
1830
|
+
target: cached.target
|
|
1831
|
+
};
|
|
1832
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1833
|
+
const cssByCandidate = (await cached.designSystemPromise).candidatesToCss(missingCandidates);
|
|
1834
|
+
const rawCssParts = [];
|
|
1835
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
1836
|
+
for (let index = 0; index < missingCandidates.length; index += 1) {
|
|
1837
|
+
const candidate = missingCandidates[index];
|
|
1838
|
+
const css = cssByCandidate[index];
|
|
1839
|
+
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
1840
|
+
rawCssParts.push(css);
|
|
1841
|
+
classSet.add(candidate);
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
const rawCss = rawCssParts.join("\n");
|
|
1845
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, options.styleOptions) : "";
|
|
1846
|
+
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
1847
|
+
for (const className of classSet) cached.classSet.add(className);
|
|
1848
|
+
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
1849
|
+
cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
1850
|
+
return {
|
|
1851
|
+
css: cached.css,
|
|
1852
|
+
rawCss: cached.rawCss,
|
|
1853
|
+
incrementalCss,
|
|
1854
|
+
incrementalRawCss: rawCss,
|
|
1855
|
+
classSet: new Set(cached.classSet),
|
|
1856
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
1857
|
+
dependencies: cached.dependencies,
|
|
1858
|
+
sources: cached.sources,
|
|
1859
|
+
root: cached.root,
|
|
1860
|
+
target: cached.target
|
|
1861
|
+
};
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1865
|
+
const generated = await generateOnce(source, options);
|
|
1866
|
+
seedIncrementalGenerateCache({
|
|
1867
|
+
compatibleSource,
|
|
1868
|
+
generated,
|
|
1869
|
+
requestedCandidates,
|
|
1870
|
+
styleOptions: options.styleOptions,
|
|
1871
|
+
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
|
|
1872
|
+
target
|
|
1873
|
+
});
|
|
1874
|
+
return generated;
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
async function generate(options = {}) {
|
|
1878
|
+
return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
|
|
1879
|
+
}
|
|
1880
|
+
return {
|
|
1881
|
+
source,
|
|
1882
|
+
loadDesignSystem: createTailwindV4Engine(source).loadDesignSystem,
|
|
1883
|
+
validateCandidates: createTailwindV4Engine(source).validateCandidates,
|
|
1884
|
+
generate
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
//#endregion
|
|
1888
|
+
//#region src/tailwindcss/v4-engine/source.ts
|
|
1889
|
+
function isPostcssPluginImportTarget(value) {
|
|
1890
|
+
if (!value) return false;
|
|
1891
|
+
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
1892
|
+
}
|
|
1893
|
+
function uniqueDefined(values) {
|
|
1894
|
+
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
|
|
1895
|
+
}
|
|
1896
|
+
function getProjectRoot$1(patcher) {
|
|
1897
|
+
return patcher.options?.projectRoot ?? process.cwd();
|
|
1898
|
+
}
|
|
1899
|
+
function readConfiguredV4Base(tailwindOptions) {
|
|
1900
|
+
const v4 = typeof tailwindOptions === "object" && tailwindOptions !== null ? tailwindOptions : void 0;
|
|
1901
|
+
if (typeof v4 !== "object" || v4 === null) return;
|
|
1902
|
+
return v4.configuredBase;
|
|
1903
|
+
}
|
|
1904
|
+
function isBarePackageSpecifier(specifier) {
|
|
1905
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
1906
|
+
}
|
|
1907
|
+
function parseCssImportSpecifier(params) {
|
|
1908
|
+
const value = params.trim();
|
|
1909
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1910
|
+
if (quoted) {
|
|
1911
|
+
const specifier = quoted[2];
|
|
1912
|
+
if (specifier === void 0) return;
|
|
1913
|
+
return {
|
|
1914
|
+
quote: quoted[1],
|
|
1915
|
+
raw: quoted[0],
|
|
1916
|
+
specifier
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1920
|
+
if (!url) return;
|
|
1921
|
+
const specifier = url[2] ?? url[3];
|
|
1922
|
+
if (specifier === void 0) return;
|
|
1923
|
+
return {
|
|
1924
|
+
quote: url[1],
|
|
1925
|
+
raw: url[0],
|
|
1926
|
+
specifier
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
function quoteCssImportSpecifier(specifier, quote = "\"") {
|
|
1930
|
+
return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
|
|
1931
|
+
}
|
|
1932
|
+
function createTailwindV4CssImportSpecifierSet(packageName) {
|
|
1933
|
+
const specifiers = new Set(["tailwindcss"]);
|
|
1934
|
+
if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
|
|
1935
|
+
return specifiers;
|
|
1936
|
+
}
|
|
1937
|
+
function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
1938
|
+
if (!css.includes("tailwindcss")) return css;
|
|
1939
|
+
let root;
|
|
1940
|
+
try {
|
|
1941
|
+
root = postcss.parse(css);
|
|
1942
|
+
} catch {
|
|
1943
|
+
return css;
|
|
1944
|
+
}
|
|
1945
|
+
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
1946
|
+
let changed = false;
|
|
1947
|
+
root.walkAtRules("import", (rule) => {
|
|
1948
|
+
const parsed = parseCssImportSpecifier(rule.params);
|
|
1949
|
+
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
1950
|
+
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(`${parsed.specifier}/index.css`, parsed.quote));
|
|
1951
|
+
changed = true;
|
|
1952
|
+
});
|
|
1953
|
+
return changed ? root.toString() : css;
|
|
1954
|
+
}
|
|
1955
|
+
function resolveTailwindCssImportTarget(patcher) {
|
|
1956
|
+
const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
|
|
1957
|
+
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
1958
|
+
const packageName = patcher.packageInfo?.name;
|
|
1959
|
+
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
|
|
1960
|
+
return "tailwindcss";
|
|
1961
|
+
}
|
|
1962
|
+
function readTailwindV4Options(patcher) {
|
|
1963
|
+
return resolveTailwindcssOptions(patcher.options)?.v4 ?? patcher.options?.tailwind?.v4;
|
|
1964
|
+
}
|
|
1965
|
+
function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
1966
|
+
const projectRoot = getProjectRoot$1(patcher);
|
|
1967
|
+
const tailwindOptions = resolveTailwindcssOptions(patcher.options);
|
|
1968
|
+
const tailwindV4Options = readTailwindV4Options(patcher);
|
|
1969
|
+
const configDir = tailwindOptions?.config ? path.dirname(tailwindOptions.config) : void 0;
|
|
1970
|
+
const configuredBase = readConfiguredV4Base(tailwindV4Options);
|
|
1971
|
+
const hasCssEntries = Boolean(tailwindV4Options?.cssEntries?.length);
|
|
1972
|
+
return omitUndefined({
|
|
1973
|
+
projectRoot,
|
|
1974
|
+
base: configuredBase ?? (hasCssEntries ? void 0 : tailwindV4Options?.base),
|
|
1975
|
+
baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
|
|
1976
|
+
css: tailwindV4Options?.css,
|
|
1977
|
+
cssSources: tailwindV4Options?.cssSources,
|
|
1978
|
+
cssEntries: tailwindV4Options?.cssEntries,
|
|
1979
|
+
sources: tailwindV4Options?.sources,
|
|
1980
|
+
packageName: resolveTailwindCssImportTarget(patcher)
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
function resolveTailwindV4Source$1(options) {
|
|
1984
|
+
return resolveTailwindV4Source(options?.css === void 0 ? options : {
|
|
1985
|
+
...options,
|
|
1986
|
+
css: normalizeTailwindV4CssPackageImports(options.css, options.packageName)
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
1990
|
+
return resolveTailwindV4Source$1(resolveTailwindV4SourceOptionsFromPatcher(patcher));
|
|
1991
|
+
}
|
|
1992
|
+
//#endregion
|
|
1993
|
+
//#region src/bundlers/vite/static-config-content.ts
|
|
1994
|
+
function skipWhitespaceAndComments(source, start) {
|
|
1995
|
+
let index = start;
|
|
1996
|
+
while (index < source.length) {
|
|
1997
|
+
const char = source[index];
|
|
1998
|
+
if (/\s/.test(char ?? "")) {
|
|
1999
|
+
index += 1;
|
|
2000
|
+
continue;
|
|
2001
|
+
}
|
|
2002
|
+
if (char === "/" && source[index + 1] === "/") {
|
|
2003
|
+
index += 2;
|
|
2004
|
+
while (index < source.length && source[index] !== "\n") index += 1;
|
|
2005
|
+
continue;
|
|
2006
|
+
}
|
|
2007
|
+
if (char === "/" && source[index + 1] === "*") {
|
|
2008
|
+
index += 2;
|
|
2009
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
|
|
2010
|
+
index = Math.min(index + 2, source.length);
|
|
2011
|
+
continue;
|
|
2012
|
+
}
|
|
2013
|
+
break;
|
|
2014
|
+
}
|
|
2015
|
+
return index;
|
|
2016
|
+
}
|
|
2017
|
+
function readQuotedString(source, start) {
|
|
2018
|
+
const quote = source[start];
|
|
2019
|
+
if (quote !== "\"" && quote !== "'") return;
|
|
2020
|
+
let value = "";
|
|
2021
|
+
for (let index = start + 1; index < source.length; index++) {
|
|
2022
|
+
const char = source[index];
|
|
2023
|
+
if (char === "\\") {
|
|
2024
|
+
const next = source[index + 1];
|
|
2025
|
+
if (next === void 0) return;
|
|
2026
|
+
value += next;
|
|
2027
|
+
index += 1;
|
|
2028
|
+
continue;
|
|
2029
|
+
}
|
|
2030
|
+
if (char === quote) return {
|
|
2031
|
+
end: index + 1,
|
|
2032
|
+
value
|
|
2033
|
+
};
|
|
2034
|
+
value += char;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
function readIdentifier(source, start) {
|
|
2038
|
+
return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
|
|
2039
|
+
}
|
|
2040
|
+
function findMatchingBracket(source, start, open, close) {
|
|
2041
|
+
let depth = 0;
|
|
2042
|
+
let quote;
|
|
2043
|
+
for (let index = start; index < source.length; index++) {
|
|
2044
|
+
const char = source[index];
|
|
2045
|
+
if (char === "\\") {
|
|
2046
|
+
index += 1;
|
|
2047
|
+
continue;
|
|
2048
|
+
}
|
|
2049
|
+
if (quote) {
|
|
2050
|
+
if (char === quote) quote = void 0;
|
|
2051
|
+
continue;
|
|
2052
|
+
}
|
|
2053
|
+
if (char === "\"" || char === "'") {
|
|
2054
|
+
quote = char;
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
if (char === "`") return;
|
|
2058
|
+
if (char === open) {
|
|
2059
|
+
depth += 1;
|
|
2060
|
+
continue;
|
|
2061
|
+
}
|
|
2062
|
+
if (char === close) {
|
|
2063
|
+
depth -= 1;
|
|
2064
|
+
if (depth === 0) return index;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
function findContentPropertyValue(source) {
|
|
2069
|
+
let index = 0;
|
|
2070
|
+
while (index < source.length) {
|
|
2071
|
+
const nextIndex = source.indexOf("content", index);
|
|
2072
|
+
if (nextIndex === -1) return;
|
|
2073
|
+
const previous = source[nextIndex - 1];
|
|
2074
|
+
const next = source[nextIndex + 7];
|
|
2075
|
+
if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
|
|
2076
|
+
index = nextIndex + 7;
|
|
2077
|
+
continue;
|
|
2078
|
+
}
|
|
2079
|
+
let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
|
|
2080
|
+
if (source[colonIndex] !== ":") {
|
|
2081
|
+
index = nextIndex + 7;
|
|
2082
|
+
continue;
|
|
2083
|
+
}
|
|
2084
|
+
colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
|
|
2085
|
+
return { start: colonIndex };
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
function parseStaticContentArray(source, start) {
|
|
2089
|
+
if (source[start] !== "[") return;
|
|
2090
|
+
const value = [];
|
|
2091
|
+
let index = skipWhitespaceAndComments(source, start + 1);
|
|
2092
|
+
while (index < source.length) {
|
|
2093
|
+
if (source[index] === "]") return {
|
|
2094
|
+
end: index + 1,
|
|
2095
|
+
value
|
|
2096
|
+
};
|
|
2097
|
+
const parsed = parseStaticContentValue(source, index);
|
|
2098
|
+
if (!parsed) return;
|
|
2099
|
+
value.push(parsed.value);
|
|
2100
|
+
index = skipWhitespaceAndComments(source, parsed.end);
|
|
2101
|
+
if (source[index] === ",") {
|
|
2102
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
2103
|
+
continue;
|
|
2104
|
+
}
|
|
2105
|
+
if (source[index] === "]") continue;
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
function parseStaticContentObject(source, start) {
|
|
2110
|
+
if (source[start] !== "{") return;
|
|
2111
|
+
const end = findMatchingBracket(source, start, "{", "}");
|
|
2112
|
+
if (end === void 0) return;
|
|
2113
|
+
let index = skipWhitespaceAndComments(source, start + 1);
|
|
2114
|
+
let files;
|
|
2115
|
+
while (index < end) {
|
|
2116
|
+
let key;
|
|
2117
|
+
const quotedKey = readQuotedString(source, index);
|
|
2118
|
+
if (quotedKey) {
|
|
2119
|
+
key = quotedKey.value;
|
|
2120
|
+
index = quotedKey.end;
|
|
2121
|
+
} else {
|
|
2122
|
+
key = readIdentifier(source, index);
|
|
2123
|
+
if (!key) return;
|
|
2124
|
+
index += key.length;
|
|
2125
|
+
}
|
|
2126
|
+
index = skipWhitespaceAndComments(source, index);
|
|
2127
|
+
if (source[index] !== ":") return;
|
|
2128
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
2129
|
+
const parsedValue = parseStaticContentValue(source, index);
|
|
2130
|
+
if (!parsedValue) return;
|
|
2131
|
+
if (key === "files") files = parsedValue.value;
|
|
2132
|
+
index = skipWhitespaceAndComments(source, parsedValue.end);
|
|
2133
|
+
if (source[index] === ",") {
|
|
2134
|
+
index = skipWhitespaceAndComments(source, index + 1);
|
|
2135
|
+
continue;
|
|
2136
|
+
}
|
|
2137
|
+
if (index < end) return;
|
|
2138
|
+
}
|
|
2139
|
+
return files === void 0 ? void 0 : {
|
|
2140
|
+
end: end + 1,
|
|
2141
|
+
value: { files }
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
function parseStaticContentValue(source, start) {
|
|
2145
|
+
const index = skipWhitespaceAndComments(source, start);
|
|
2146
|
+
const quoted = readQuotedString(source, index);
|
|
2147
|
+
if (quoted) return quoted;
|
|
2148
|
+
if (source[index] === "[") return parseStaticContentArray(source, index);
|
|
2149
|
+
if (source[index] === "{") return parseStaticContentObject(source, index);
|
|
2150
|
+
}
|
|
2151
|
+
function readStaticConfigContent(configPath) {
|
|
2152
|
+
let source;
|
|
2153
|
+
try {
|
|
2154
|
+
source = readFileSync(configPath, "utf8");
|
|
2155
|
+
} catch {
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
const contentProperty = findContentPropertyValue(source);
|
|
2159
|
+
if (!contentProperty) return;
|
|
2160
|
+
return parseStaticContentValue(source, contentProperty.start)?.value;
|
|
2161
|
+
}
|
|
2162
|
+
//#endregion
|
|
2163
|
+
//#region src/bundlers/vite/source-scan.ts
|
|
2164
|
+
const VITE_SOURCE_CANDIDATE_PATTERN = createSourceScanPattern([
|
|
2165
|
+
"js",
|
|
2166
|
+
"jsx",
|
|
2167
|
+
"mjs",
|
|
2168
|
+
"cjs",
|
|
2169
|
+
"ts",
|
|
2170
|
+
"tsx",
|
|
2171
|
+
"mts",
|
|
2172
|
+
"cts",
|
|
2173
|
+
"vue",
|
|
2174
|
+
"uvue",
|
|
2175
|
+
"nvue",
|
|
2176
|
+
"svelte",
|
|
2177
|
+
"mpx",
|
|
2178
|
+
"html",
|
|
2179
|
+
"wxml",
|
|
2180
|
+
"axml",
|
|
2181
|
+
"jxml",
|
|
2182
|
+
"ksml",
|
|
2183
|
+
"ttml",
|
|
2184
|
+
"qml",
|
|
2185
|
+
"tyml",
|
|
2186
|
+
"xhsml",
|
|
2187
|
+
"swan",
|
|
2188
|
+
"css",
|
|
2189
|
+
"wxss",
|
|
2190
|
+
"acss",
|
|
2191
|
+
"jxss",
|
|
2192
|
+
"ttss",
|
|
2193
|
+
"qss",
|
|
2194
|
+
"tyss",
|
|
2195
|
+
"scss",
|
|
2196
|
+
"sass",
|
|
2197
|
+
"less",
|
|
2198
|
+
"styl",
|
|
2199
|
+
"stylus"
|
|
2200
|
+
]);
|
|
2201
|
+
const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
|
|
2202
|
+
const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
|
|
2203
|
+
function parseImportSourceParam(params) {
|
|
2204
|
+
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
2205
|
+
if (!match) return;
|
|
2206
|
+
return {
|
|
2207
|
+
none: match[1] === "none",
|
|
2208
|
+
sourcePath: match[3]
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
function isTailwindCssImport(params) {
|
|
2212
|
+
return /^\s*(['"])tailwindcss(?:\/[^'"]*)?\1/.test(params);
|
|
2213
|
+
}
|
|
2214
|
+
function resolveSourceBase(base, sourcePath) {
|
|
2215
|
+
return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
2216
|
+
}
|
|
2217
|
+
function resolveConfigPath(base, configPath) {
|
|
2218
|
+
if (path.isAbsolute(configPath)) return path.resolve(configPath);
|
|
2219
|
+
let current = path.resolve(base);
|
|
2220
|
+
while (true) {
|
|
2221
|
+
const candidate = path.resolve(current, configPath);
|
|
2222
|
+
if (existsSync(candidate)) return candidate;
|
|
2223
|
+
const parent = path.dirname(current);
|
|
2224
|
+
if (parent === current) break;
|
|
2225
|
+
current = parent;
|
|
2226
|
+
}
|
|
2227
|
+
return path.resolve(base, configPath);
|
|
2228
|
+
}
|
|
2229
|
+
function createCssEntriesCacheKey(css, base, dependencies) {
|
|
2230
|
+
return JSON.stringify({
|
|
2231
|
+
base: path.resolve(base),
|
|
2232
|
+
css,
|
|
2233
|
+
dependencies
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
function addSourceScanDependency(dependencies, file) {
|
|
2237
|
+
if (typeof file === "string" && file.length > 0) dependencies.add(path.resolve(file));
|
|
2238
|
+
}
|
|
2239
|
+
function addSourceScanDependencies(dependencies, files) {
|
|
2240
|
+
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
|
|
2241
|
+
}
|
|
2242
|
+
function createResolvedViteSourceScan(input, dependencies) {
|
|
2243
|
+
return {
|
|
2244
|
+
...input,
|
|
2245
|
+
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
async function statConfigDependency(file) {
|
|
2249
|
+
try {
|
|
2250
|
+
const stats = await stat(file);
|
|
2251
|
+
return {
|
|
2252
|
+
file,
|
|
2253
|
+
mtimeMs: stats.mtimeMs,
|
|
2254
|
+
size: stats.size
|
|
2255
|
+
};
|
|
2256
|
+
} catch {
|
|
2257
|
+
return {
|
|
2258
|
+
file,
|
|
2259
|
+
mtimeMs: -1,
|
|
2260
|
+
size: -1
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
async function collectConfigDependencySignatures(root, base) {
|
|
2265
|
+
const configPaths = /* @__PURE__ */ new Set();
|
|
2266
|
+
root.walkAtRules("config", (rule) => {
|
|
2267
|
+
const configPath = parseConfigParam$1(rule.params);
|
|
2268
|
+
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
|
|
2269
|
+
});
|
|
2270
|
+
return Promise.all([...configPaths].sort().map(statConfigDependency));
|
|
2271
|
+
}
|
|
2272
|
+
function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
|
|
2273
|
+
const merged = {
|
|
2274
|
+
included: /* @__PURE__ */ new Set(),
|
|
2275
|
+
excluded: /* @__PURE__ */ new Set()
|
|
2276
|
+
};
|
|
2277
|
+
for (const inlineCandidates of allInlineCandidates) {
|
|
2278
|
+
if (!inlineCandidates) continue;
|
|
2279
|
+
for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
|
|
2280
|
+
for (const candidate of inlineCandidates.excluded) {
|
|
2281
|
+
merged.excluded.add(candidate);
|
|
2282
|
+
merged.included.delete(candidate);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
|
|
2286
|
+
}
|
|
2287
|
+
async function resolveConfigContentEntries(root, base) {
|
|
2288
|
+
const configPaths = /* @__PURE__ */ new Set();
|
|
2289
|
+
root.walkAtRules("config", (rule) => {
|
|
2290
|
+
const configPath = parseConfigParam$1(rule.params);
|
|
2291
|
+
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
|
|
2292
|
+
});
|
|
2293
|
+
const entries = [];
|
|
2294
|
+
for (const configPath of configPaths) {
|
|
2295
|
+
const staticContent = readStaticConfigContent(configPath);
|
|
2296
|
+
if (staticContent !== void 0) {
|
|
2297
|
+
entries.push(...normalizeLegacyContentEntries(staticContent, path.dirname(configPath)));
|
|
2298
|
+
continue;
|
|
2299
|
+
}
|
|
2300
|
+
try {
|
|
2301
|
+
const loaded = await loadConfig({
|
|
2302
|
+
config: configPath,
|
|
2303
|
+
cwd: path.dirname(configPath)
|
|
2304
|
+
});
|
|
2305
|
+
entries.push(...normalizeLegacyContentEntries(loaded?.config.content, path.dirname(configPath)));
|
|
2306
|
+
} catch {}
|
|
2307
|
+
}
|
|
2308
|
+
return {
|
|
2309
|
+
dependencies: [...configPaths],
|
|
2310
|
+
entries
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
2314
|
+
let root;
|
|
2315
|
+
try {
|
|
2316
|
+
root = postcss.parse(css);
|
|
2317
|
+
} catch {
|
|
2318
|
+
return;
|
|
2319
|
+
}
|
|
2320
|
+
let importSourceBase;
|
|
2321
|
+
let hasSourceNone = false;
|
|
2322
|
+
const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
|
|
2323
|
+
const entries = [...configEntries.entries, ...sourceEntries];
|
|
2324
|
+
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
2325
|
+
root.walkAtRules("import", (rule) => {
|
|
2326
|
+
if (!isTailwindCssImport(rule.params)) return;
|
|
2327
|
+
const sourceParam = parseImportSourceParam(rule.params);
|
|
2328
|
+
if (sourceParam?.none) hasSourceNone = true;
|
|
2329
|
+
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
|
|
2330
|
+
});
|
|
2331
|
+
if (importSourceBase) return {
|
|
2332
|
+
entries: [{
|
|
2333
|
+
base: importSourceBase,
|
|
2334
|
+
negated: false,
|
|
2335
|
+
pattern: VITE_SOURCE_CANDIDATE_PATTERN
|
|
2336
|
+
}, ...entries],
|
|
2337
|
+
explicit: true,
|
|
2338
|
+
inlineCandidates,
|
|
2339
|
+
dependencies: configEntries.dependencies
|
|
2340
|
+
};
|
|
2341
|
+
if (hasSourceNone) return {
|
|
2342
|
+
entries,
|
|
2343
|
+
explicit: true,
|
|
2344
|
+
inlineCandidates,
|
|
2345
|
+
dependencies: configEntries.dependencies
|
|
2346
|
+
};
|
|
2347
|
+
return entries.length > 0 ? {
|
|
2348
|
+
entries,
|
|
2349
|
+
explicit: true,
|
|
2350
|
+
inlineCandidates,
|
|
2351
|
+
dependencies: configEntries.dependencies
|
|
2352
|
+
} : inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0 ? {
|
|
2353
|
+
entries: [],
|
|
2354
|
+
explicit: true,
|
|
2355
|
+
inlineCandidates,
|
|
2356
|
+
dependencies: configEntries.dependencies
|
|
2357
|
+
} : void 0;
|
|
2358
|
+
}
|
|
2359
|
+
async function resolveViteTailwindV4CssDependencies(css, base) {
|
|
2360
|
+
return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
|
|
2361
|
+
}
|
|
2362
|
+
function collectExistingCssEntries(options) {
|
|
2363
|
+
return [
|
|
2364
|
+
...options.cssEntries ?? [],
|
|
2365
|
+
...options.tailwindcss?.v4?.cssEntries ?? [],
|
|
2366
|
+
...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
2367
|
+
].filter((item) => typeof item === "string" && item.length > 0).map((item) => path.resolve(item)).filter((item) => existsSync(item));
|
|
2368
|
+
}
|
|
2369
|
+
async function pathExistsAsFile(file) {
|
|
2370
|
+
try {
|
|
2371
|
+
return (await stat(file)).isFile();
|
|
2372
|
+
} catch {
|
|
2373
|
+
return false;
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
async function resolveTailwindV4EntriesFromCssCached(css, base) {
|
|
2377
|
+
let root;
|
|
2378
|
+
try {
|
|
2379
|
+
root = postcss.parse(css);
|
|
2380
|
+
} catch {
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
|
|
2384
|
+
const cached = tailwindV4CssEntriesCache.get(cacheKey);
|
|
2385
|
+
if (cached) return cached;
|
|
2386
|
+
const task = resolveTailwindV4EntriesFromCss(css, base);
|
|
2387
|
+
tailwindV4CssEntriesCache.set(cacheKey, task);
|
|
2388
|
+
return task;
|
|
2389
|
+
}
|
|
2390
|
+
async function discoverTailwindV4CssEntries(root, outDir) {
|
|
2391
|
+
const resolvedRoot = path.resolve(root);
|
|
2392
|
+
const ignore = ["**/node_modules/**", "**/.git/**"];
|
|
2393
|
+
const resolvedOutDir = outDir ? path.resolve(resolvedRoot, outDir) : void 0;
|
|
2394
|
+
if (resolvedOutDir) {
|
|
2395
|
+
const relativeOutDir = path.relative(resolvedRoot, resolvedOutDir);
|
|
2396
|
+
if (relativeOutDir && !relativeOutDir.startsWith("..") && !path.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(path.sep).join("/")}/**`);
|
|
2397
|
+
}
|
|
2398
|
+
const candidates = await fg(VITE_TAILWIND_CSS_ENTRY_PATTERN, {
|
|
2399
|
+
absolute: true,
|
|
2400
|
+
cwd: resolvedRoot,
|
|
2401
|
+
ignore,
|
|
2402
|
+
onlyFiles: true,
|
|
2403
|
+
unique: true
|
|
2404
|
+
});
|
|
2405
|
+
const entries = [];
|
|
2406
|
+
for (const file of candidates) {
|
|
2407
|
+
if (!await pathExistsAsFile(file)) continue;
|
|
2408
|
+
try {
|
|
2409
|
+
const css = readFileSync(file, "utf8");
|
|
2410
|
+
if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
|
|
2411
|
+
if (await resolveTailwindV4EntriesFromCssCached(css, path.dirname(file))) entries.push(file);
|
|
2412
|
+
}
|
|
2413
|
+
} catch {}
|
|
2414
|
+
}
|
|
2415
|
+
return entries;
|
|
2416
|
+
}
|
|
2417
|
+
function collectConfiguredCssSources(options) {
|
|
2418
|
+
return [...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? []];
|
|
2419
|
+
}
|
|
2420
|
+
function resolveTailwindV4CssSourceBase(source, fallbackBase) {
|
|
2421
|
+
if (typeof source.base === "string" && source.base.length > 0) return source.base;
|
|
2422
|
+
if (typeof source.file === "string" && source.file.length > 0) return path.dirname(source.file);
|
|
2423
|
+
return fallbackBase;
|
|
2424
|
+
}
|
|
2425
|
+
async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
|
|
2426
|
+
if (patcher.majorVersion === 3) {
|
|
2427
|
+
const source = await resolveTailwindV3SourceFromPatcher(patcher);
|
|
2428
|
+
const contentEntries = normalizeLegacyContentEntries(source.configObject?.content, source.config ? path.dirname(source.config) : source.cwd);
|
|
2429
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
2430
|
+
addSourceScanDependency(dependencies, source.config);
|
|
2431
|
+
return contentEntries.length > 0 ? createResolvedViteSourceScan({ entries: contentEntries }, dependencies) : void 0;
|
|
2432
|
+
}
|
|
2433
|
+
if (patcher.majorVersion === 4) {
|
|
2434
|
+
const sourceOptions = resolveTailwindV4SourceOptionsFromPatcher(patcher);
|
|
2435
|
+
const cssEntries = collectExistingCssEntries(options);
|
|
2436
|
+
if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
|
|
2437
|
+
const scanRoot = scanOptions.root;
|
|
2438
|
+
const sourceProjectRoot = sourceOptions.projectRoot;
|
|
2439
|
+
if (scanRoot && sourceProjectRoot && path.resolve(scanRoot) === path.resolve(sourceProjectRoot)) {
|
|
2440
|
+
const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
|
|
2441
|
+
cssEntries.push(...discoveredCssEntries);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
const entries = [];
|
|
2445
|
+
const cssInlineCandidates = [];
|
|
2446
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
2447
|
+
let explicit = false;
|
|
2448
|
+
for (const cssEntry of cssEntries) {
|
|
2449
|
+
addSourceScanDependency(dependencies, cssEntry);
|
|
2450
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(readFileSync(cssEntry, "utf8"), path.dirname(cssEntry));
|
|
2451
|
+
if (resolved) {
|
|
2452
|
+
entries.push(...resolved.entries);
|
|
2453
|
+
cssInlineCandidates.push(resolved.inlineCandidates);
|
|
2454
|
+
addSourceScanDependencies(dependencies, resolved.dependencies);
|
|
2455
|
+
explicit || (explicit = resolved.explicit);
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2459
|
+
if (entries.length > 0 || inlineCandidates || explicit) return createResolvedViteSourceScan({
|
|
2460
|
+
entries: explicit ? entries : entries.length > 0 ? entries : void 0,
|
|
2461
|
+
explicit,
|
|
2462
|
+
inlineCandidates
|
|
2463
|
+
}, dependencies);
|
|
2464
|
+
if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
|
|
2465
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? process.cwd());
|
|
2466
|
+
return resolved ? createResolvedViteSourceScan({
|
|
2467
|
+
entries: resolved.entries,
|
|
2468
|
+
explicit: resolved.explicit,
|
|
2469
|
+
inlineCandidates: resolved.inlineCandidates
|
|
2470
|
+
}, new Set(resolved.dependencies)) : void 0;
|
|
2471
|
+
}
|
|
2472
|
+
const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? process.cwd();
|
|
2473
|
+
for (const cssSource of [...collectConfiguredCssSources(options), ...sourceOptions.cssSources ?? []]) {
|
|
2474
|
+
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
2475
|
+
addSourceScanDependency(dependencies, cssSource.file);
|
|
2476
|
+
addSourceScanDependencies(dependencies, cssSource.dependencies);
|
|
2477
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
|
|
2478
|
+
if (resolved) {
|
|
2479
|
+
entries.push(...resolved.entries);
|
|
2480
|
+
cssInlineCandidates.push(resolved.inlineCandidates);
|
|
2481
|
+
addSourceScanDependencies(dependencies, resolved.dependencies);
|
|
2482
|
+
explicit || (explicit = resolved.explicit);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2486
|
+
if (entries.length > 0 || cssSourceInlineCandidates || explicit) return createResolvedViteSourceScan({
|
|
2487
|
+
entries: explicit ? entries : entries.length > 0 ? entries : void 0,
|
|
2488
|
+
explicit,
|
|
2489
|
+
inlineCandidates: cssSourceInlineCandidates
|
|
2490
|
+
}, dependencies);
|
|
2491
|
+
const source = await resolveTailwindV4SourceFromPatcher(patcher);
|
|
2492
|
+
addSourceScanDependency(dependencies, source.file);
|
|
2493
|
+
addSourceScanDependencies(dependencies, source.dependencies);
|
|
2494
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
|
|
2495
|
+
return resolved ? createResolvedViteSourceScan({
|
|
2496
|
+
entries: resolved.entries,
|
|
2497
|
+
explicit: resolved.explicit,
|
|
2498
|
+
inlineCandidates: resolved.inlineCandidates
|
|
2499
|
+
}, new Set([...dependencies, ...resolved.dependencies])) : void 0;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
function toPosixPath(value) {
|
|
2503
|
+
return value.split(path.sep).join("/");
|
|
2504
|
+
}
|
|
2505
|
+
function normalizeEntryPattern(entry) {
|
|
2506
|
+
return path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(path.resolve(entry.base), entry.pattern)) : entry.pattern;
|
|
2507
|
+
}
|
|
2508
|
+
function createViteSourceScanMatcher(entries) {
|
|
2509
|
+
if (!entries?.length) return;
|
|
2510
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
2511
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
2512
|
+
if (positiveEntries.length === 0) return () => false;
|
|
2513
|
+
return (file) => {
|
|
2514
|
+
const resolvedFile = path.resolve(file);
|
|
2515
|
+
if (!positiveEntries.some((entry) => {
|
|
2516
|
+
const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
|
|
2517
|
+
return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizeEntryPattern(entry));
|
|
2518
|
+
})) return false;
|
|
2519
|
+
return !negativeEntries.some((entry) => {
|
|
2520
|
+
const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
|
|
2521
|
+
return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizeEntryPattern(entry));
|
|
2522
|
+
});
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
//#endregion
|
|
2526
|
+
//#region src/tailwindcss/runtime/cache.ts
|
|
2527
|
+
const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
2528
|
+
const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
|
|
2529
|
+
const runtimeTrackedSourceFilesCache = /* @__PURE__ */ new Map();
|
|
2530
|
+
let runtimeFileSignatureCacheClearTimer;
|
|
2531
|
+
const runtimeSignaturePatchersSymbol = Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
|
|
2532
|
+
function getCacheEntry(twPatcher) {
|
|
2533
|
+
let entry = runtimeClassSetCache.get(twPatcher);
|
|
2534
|
+
if (!entry) {
|
|
2535
|
+
entry = {};
|
|
2536
|
+
runtimeClassSetCache.set(twPatcher, entry);
|
|
2537
|
+
}
|
|
2538
|
+
return entry;
|
|
2539
|
+
}
|
|
2540
|
+
function scheduleRuntimeConfigSignatureCacheClear() {
|
|
2541
|
+
if (runtimeFileSignatureCacheClearTimer) return;
|
|
2542
|
+
runtimeFileSignatureCacheClearTimer = setTimeout(() => {
|
|
2543
|
+
runtimeFileSignatureCache.clear();
|
|
2544
|
+
runtimeTrackedSourceFilesCache.clear();
|
|
2545
|
+
runtimeFileSignatureCacheClearTimer = void 0;
|
|
2546
|
+
}, 0);
|
|
2547
|
+
runtimeFileSignatureCacheClearTimer.unref?.();
|
|
2548
|
+
}
|
|
2549
|
+
function getFileSignature(filePath) {
|
|
2550
|
+
const cached = runtimeFileSignatureCache.get(filePath);
|
|
2551
|
+
if (cached !== void 0) return cached;
|
|
2552
|
+
let signature;
|
|
2553
|
+
try {
|
|
2554
|
+
const stats = statSync(filePath);
|
|
2555
|
+
signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
|
|
2556
|
+
} catch {
|
|
2557
|
+
signature = `${filePath}:missing`;
|
|
2558
|
+
}
|
|
2559
|
+
runtimeFileSignatureCache.set(filePath, signature);
|
|
2560
|
+
scheduleRuntimeConfigSignatureCacheClear();
|
|
2561
|
+
return signature;
|
|
2562
|
+
}
|
|
2563
|
+
function getTailwindTrackedFiles(twPatcher) {
|
|
2564
|
+
const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
|
|
2565
|
+
const tracked = /* @__PURE__ */ new Set();
|
|
2566
|
+
const configPath = tailwindOptions?.config;
|
|
2567
|
+
if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
|
|
2568
|
+
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
|
|
2569
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
2570
|
+
if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
|
|
2571
|
+
for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
|
|
2572
|
+
}
|
|
2573
|
+
return tracked;
|
|
2574
|
+
}
|
|
2575
|
+
function normalizeTrackedSourceSignature(cssEntries, cssSources) {
|
|
2576
|
+
return normalizeSignatureValue({
|
|
2577
|
+
cssEntries: cssEntries?.map((entry) => {
|
|
2578
|
+
if (!existsSync(entry)) return `${entry}:missing`;
|
|
2579
|
+
return getFileSignature(entry);
|
|
2580
|
+
}),
|
|
2581
|
+
cssSources
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
async function collectTailwindV4TrackedSourceFiles(twPatcher) {
|
|
2585
|
+
const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
|
|
2586
|
+
const signature = normalizeTrackedSourceSignature(tailwindOptions?.v4?.cssEntries, tailwindOptions?.v4?.cssSources);
|
|
2587
|
+
const cached = runtimeTrackedSourceFilesCache.get(signature);
|
|
2588
|
+
if (cached) return cached;
|
|
2589
|
+
const files = /* @__PURE__ */ new Set();
|
|
2590
|
+
for (const cssEntry of tailwindOptions?.v4?.cssEntries ?? []) {
|
|
2591
|
+
if (!existsSync(cssEntry)) continue;
|
|
2592
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(readFileSync(cssEntry, "utf8"), path.dirname(cssEntry));
|
|
2593
|
+
const expanded = resolved?.entries?.length ? await expandTailwindSourceEntries(resolved.entries) : [];
|
|
2594
|
+
for (const file of expanded) files.add(file);
|
|
2595
|
+
}
|
|
2596
|
+
for (const cssSource of tailwindOptions?.v4?.cssSources ?? []) {
|
|
2597
|
+
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
2598
|
+
const base = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.dirname(cssSource.file) : tailwindOptions?.v4?.base ?? tailwindOptions?.cwd ?? twPatcher.options?.projectRoot ?? process.cwd();
|
|
2599
|
+
const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, base);
|
|
2600
|
+
const expanded = resolved?.entries?.length ? await expandTailwindSourceEntries(resolved.entries) : [];
|
|
2601
|
+
for (const file of expanded) files.add(file);
|
|
2602
|
+
}
|
|
2603
|
+
const result = [...files].sort((a, b) => a.localeCompare(b));
|
|
2604
|
+
runtimeTrackedSourceFilesCache.set(signature, result);
|
|
2605
|
+
return result;
|
|
2606
|
+
}
|
|
2607
|
+
function normalizeSignatureValue(value) {
|
|
2608
|
+
if (value == null) return "null";
|
|
2609
|
+
if (typeof value === "string") return value;
|
|
2610
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
2611
|
+
if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
|
|
2612
|
+
if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
|
|
2613
|
+
return String(value);
|
|
2614
|
+
}
|
|
2615
|
+
function readOptionalProperty(value, key) {
|
|
2616
|
+
if (typeof value !== "object" || value === null || !(key in value)) return;
|
|
2617
|
+
return value[key];
|
|
2618
|
+
}
|
|
2619
|
+
function getTailwindOptionsSignature(twPatcher) {
|
|
2620
|
+
const options = twPatcher.options;
|
|
2621
|
+
const tailwindOptions = resolveTailwindcssOptions(options);
|
|
2622
|
+
return normalizeSignatureValue({
|
|
2623
|
+
projectRoot: options?.projectRoot,
|
|
2624
|
+
packageName: tailwindOptions?.packageName,
|
|
2625
|
+
versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
|
|
2626
|
+
cwd: tailwindOptions?.cwd,
|
|
2627
|
+
config: tailwindOptions?.config,
|
|
2628
|
+
v2: tailwindOptions?.v2,
|
|
2629
|
+
v3: tailwindOptions?.v3,
|
|
2630
|
+
v4: {
|
|
2631
|
+
base: tailwindOptions?.v4?.base,
|
|
2632
|
+
configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
|
|
2633
|
+
css: tailwindOptions?.v4?.css,
|
|
2634
|
+
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
2635
|
+
cssSources: tailwindOptions?.v4?.cssSources,
|
|
2636
|
+
hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
|
|
2637
|
+
sources: tailwindOptions?.v4?.sources
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
function getRuntimeTargetSignature(twPatcher) {
|
|
2642
|
+
const packageInfo = twPatcher.packageInfo;
|
|
2643
|
+
return [
|
|
2644
|
+
packageInfo?.name ?? "missing",
|
|
2645
|
+
packageInfo?.rootPath ?? "missing",
|
|
2646
|
+
packageInfo?.version ?? "unknown",
|
|
2647
|
+
twPatcher.majorVersion ?? "unknown",
|
|
2648
|
+
getTailwindOptionsSignature(twPatcher)
|
|
2649
|
+
].join(":");
|
|
2650
|
+
}
|
|
2651
|
+
function getNestedPatchers$1(twPatcher) {
|
|
2652
|
+
const nested = twPatcher[runtimeSignaturePatchersSymbol];
|
|
2653
|
+
return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
|
|
2654
|
+
}
|
|
2655
|
+
function getOwnRuntimeClassSetSignature(twPatcher) {
|
|
2656
|
+
const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
|
|
2657
|
+
return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|runtime:${getRuntimeTargetSignature(twPatcher)}`;
|
|
2658
|
+
}
|
|
2659
|
+
function invalidateRuntimeClassSet(twPatcher) {
|
|
2660
|
+
if (!twPatcher) return;
|
|
2661
|
+
const nestedPatchers = getNestedPatchers$1(twPatcher);
|
|
2662
|
+
if (nestedPatchers) for (const patcher of nestedPatchers) invalidateRuntimeClassSet(patcher);
|
|
2663
|
+
for (const trackedFile of getTailwindTrackedFiles(twPatcher)) runtimeFileSignatureCache.delete(trackedFile);
|
|
2664
|
+
runtimeTrackedSourceFilesCache.clear();
|
|
2665
|
+
runtimeClassSetCache.delete(twPatcher);
|
|
2666
|
+
}
|
|
2667
|
+
function getRuntimeClassSetCacheEntry(twPatcher) {
|
|
2668
|
+
return getCacheEntry(twPatcher);
|
|
2669
|
+
}
|
|
2670
|
+
function getRuntimeClassSetSignature(twPatcher) {
|
|
2671
|
+
const nestedPatchers = getNestedPatchers$1(twPatcher);
|
|
2672
|
+
if (nestedPatchers) return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
|
|
2673
|
+
return getOwnRuntimeClassSetSignature(twPatcher);
|
|
2674
|
+
}
|
|
2675
|
+
async function getRuntimeClassSetSignatureWithSources(twPatcher) {
|
|
2676
|
+
const baseSignature = getRuntimeClassSetSignature(twPatcher);
|
|
2677
|
+
if (twPatcher.majorVersion !== 4) return baseSignature;
|
|
2678
|
+
const trackedSourceFiles = await collectTailwindV4TrackedSourceFiles(twPatcher);
|
|
2679
|
+
if (trackedSourceFiles.length === 0) return baseSignature;
|
|
2680
|
+
return [baseSignature, trackedSourceFiles.map(getFileSignature).join("|")].join("|sources:");
|
|
2681
|
+
}
|
|
2682
|
+
//#endregion
|
|
2683
|
+
//#region src/tailwindcss/runtime-patch.ts
|
|
2684
|
+
const debug = createDebug("[tailwindcss:runtime-patch] ");
|
|
2685
|
+
const require = createRequire(import.meta.url);
|
|
2686
|
+
const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
|
|
2687
|
+
function getNestedPatchers(twPatcher) {
|
|
2688
|
+
const nested = twPatcher[runtimeSignaturePatchersSymbol];
|
|
2689
|
+
return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
|
|
2690
|
+
}
|
|
2691
|
+
function shouldApplyRuntimePatch(twPatcher) {
|
|
2692
|
+
return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
|
|
2693
|
+
}
|
|
2694
|
+
function clearTailwindcssRequireCache(twPatcher) {
|
|
2695
|
+
const rootPath = twPatcher.packageInfo?.rootPath;
|
|
2696
|
+
if (!rootPath) return;
|
|
2697
|
+
const normalizedRoot = path.resolve(rootPath);
|
|
2698
|
+
let count = 0;
|
|
2699
|
+
for (const id of Object.keys(require.cache)) {
|
|
2700
|
+
const normalizedId = path.resolve(id);
|
|
2701
|
+
if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${path.sep}`)) {
|
|
2702
|
+
delete require.cache[id];
|
|
2703
|
+
count += 1;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
if (count > 0) debug("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
|
|
2707
|
+
}
|
|
2708
|
+
async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
|
|
2709
|
+
const nestedPatchers = getNestedPatchers(twPatcher);
|
|
2710
|
+
if (nestedPatchers) {
|
|
2711
|
+
await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
if (!shouldApplyRuntimePatch(twPatcher)) return;
|
|
2715
|
+
const cached = runtimePatchPromiseCache.get(twPatcher);
|
|
2716
|
+
if (cached) {
|
|
2717
|
+
await cached;
|
|
2718
|
+
if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
|
|
2719
|
+
return;
|
|
2720
|
+
}
|
|
2721
|
+
const task = Promise.resolve().then(async () => {
|
|
2722
|
+
debug("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
|
|
2723
|
+
await twPatcher.patch?.();
|
|
2724
|
+
if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
|
|
2725
|
+
}).catch((error) => {
|
|
2726
|
+
runtimePatchPromiseCache.delete(twPatcher);
|
|
2727
|
+
throw error;
|
|
2728
|
+
});
|
|
2729
|
+
runtimePatchPromiseCache.set(twPatcher, task);
|
|
2730
|
+
return task;
|
|
2731
|
+
}
|
|
2732
|
+
//#endregion
|
|
2733
|
+
//#region src/tailwindcss/v3-engine/miniprogram.ts
|
|
2734
|
+
const defaultStyleHandler = createStyleHandler({
|
|
2735
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
2736
|
+
cssRemoveHoverPseudoClass: true,
|
|
2737
|
+
isMainChunk: true,
|
|
2738
|
+
majorVersion: 3
|
|
2739
|
+
});
|
|
2740
|
+
const MINI_PROGRAM_V3_PREFLIGHT_SELECTOR = "view,text,::before,::after";
|
|
2741
|
+
const V3_PREFLIGHT_RESET_PROPS = new Set([
|
|
2742
|
+
"box-sizing",
|
|
2743
|
+
"border",
|
|
2744
|
+
"border-width",
|
|
2745
|
+
"border-style",
|
|
2746
|
+
"border-color",
|
|
2747
|
+
"margin",
|
|
2748
|
+
"padding"
|
|
2749
|
+
]);
|
|
2750
|
+
function normalizeSelector(selector) {
|
|
2751
|
+
return selector.trim().replace(/\s+/g, "");
|
|
2752
|
+
}
|
|
2753
|
+
function isMiniProgramV3PreflightRule(rule) {
|
|
2754
|
+
return normalizeSelector(rule.selector) === MINI_PROGRAM_V3_PREFLIGHT_SELECTOR;
|
|
2755
|
+
}
|
|
2756
|
+
function hasResetDeclaration(rule) {
|
|
2757
|
+
let found = false;
|
|
2758
|
+
rule.walkDecls((decl) => {
|
|
2759
|
+
if (V3_PREFLIGHT_RESET_PROPS.has(decl.prop)) found = true;
|
|
2760
|
+
});
|
|
2761
|
+
return found;
|
|
2762
|
+
}
|
|
2763
|
+
function createPreflightDeclarations(cssPreflight) {
|
|
2764
|
+
if (!cssPreflight || typeof cssPreflight !== "object") return [];
|
|
2765
|
+
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => postcss.decl({
|
|
2766
|
+
prop,
|
|
2767
|
+
value: value.toString()
|
|
2768
|
+
}));
|
|
2769
|
+
}
|
|
2770
|
+
function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
2771
|
+
const declarations = createPreflightDeclarations(cssPreflight);
|
|
2772
|
+
if (declarations.length === 0) return css;
|
|
2773
|
+
try {
|
|
2774
|
+
const root = postcss.parse(css);
|
|
2775
|
+
let targetRule;
|
|
2776
|
+
let hasReset = false;
|
|
2777
|
+
root.walkRules((rule) => {
|
|
2778
|
+
if (!isMiniProgramV3PreflightRule(rule)) return;
|
|
2779
|
+
targetRule ?? (targetRule = rule);
|
|
2780
|
+
if (hasResetDeclaration(rule)) hasReset = true;
|
|
2781
|
+
});
|
|
2782
|
+
if (!targetRule || hasReset) return css;
|
|
2783
|
+
targetRule.append(...declarations.map((decl) => decl.clone()));
|
|
2784
|
+
return root.toString();
|
|
2785
|
+
} catch {
|
|
2786
|
+
return css;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
async function transformTailwindV3CssToWeapp(css, options) {
|
|
2790
|
+
return ensureMiniProgramV3PreflightReset(pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
|
|
2791
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
2792
|
+
cssRemoveHoverPseudoClass: true,
|
|
2793
|
+
isMainChunk: true,
|
|
2794
|
+
majorVersion: 3,
|
|
2795
|
+
...options
|
|
2796
|
+
})).css, { preservePreflight: true }), options?.cssPreflight);
|
|
2797
|
+
}
|
|
2798
|
+
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
2799
|
+
return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
|
|
2800
|
+
}
|
|
2801
|
+
//#endregion
|
|
2802
|
+
//#region src/tailwindcss/v3-engine/generator.ts
|
|
2803
|
+
const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
|
|
2804
|
+
const incrementalGenerateCache = /* @__PURE__ */ new Map();
|
|
2805
|
+
function isLegacyContentObject(value) {
|
|
2806
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
2807
|
+
}
|
|
2808
|
+
function createRawContentEntries(candidates, sources) {
|
|
2809
|
+
const entries = [];
|
|
2810
|
+
const candidateContent = [...candidates].join(" ");
|
|
2811
|
+
if (candidateContent.length > 0) entries.push({
|
|
2812
|
+
raw: candidateContent,
|
|
2813
|
+
extension: "html"
|
|
2814
|
+
});
|
|
2815
|
+
for (const source of sources) entries.push({
|
|
2816
|
+
raw: source.content,
|
|
2817
|
+
extension: source.extension ?? "html"
|
|
2818
|
+
});
|
|
2819
|
+
return entries;
|
|
2820
|
+
}
|
|
2821
|
+
function createChangedContentEntries(candidates, sources) {
|
|
2822
|
+
return createRawContentEntries(candidates, sources).map((entry) => ({
|
|
2823
|
+
content: entry.raw,
|
|
2824
|
+
extension: entry.extension
|
|
2825
|
+
}));
|
|
2826
|
+
}
|
|
2827
|
+
function collectCandidates(candidates) {
|
|
2828
|
+
return new Set(candidates ?? []);
|
|
2829
|
+
}
|
|
2830
|
+
function mergeContent(content, rawEntries) {
|
|
2831
|
+
if (isLegacyContentObject(content)) return {
|
|
2832
|
+
...content,
|
|
2833
|
+
relative: content.relative ?? true,
|
|
2834
|
+
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
2835
|
+
};
|
|
2836
|
+
return {
|
|
2837
|
+
relative: true,
|
|
2838
|
+
files: [...[].concat(content ?? []), ...rawEntries]
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
function normalizeConfigObject(config) {
|
|
2842
|
+
if (!config || typeof config !== "object") return config;
|
|
2843
|
+
const maybeDefault = config.default;
|
|
2844
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
2845
|
+
return config;
|
|
2846
|
+
}
|
|
2847
|
+
function hasExplicitContentInput(options) {
|
|
2848
|
+
return options.candidates !== void 0 || options.sources !== void 0;
|
|
2849
|
+
}
|
|
2850
|
+
function createExplicitContentConfig(rawEntries) {
|
|
2851
|
+
return {
|
|
2852
|
+
relative: true,
|
|
2853
|
+
files: rawEntries
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
function createTailwindConfig(source, options) {
|
|
2857
|
+
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
2858
|
+
const rawEntries = createRawContentEntries(options.candidates ?? [], options.sources ?? []);
|
|
2859
|
+
config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
|
|
2860
|
+
return config;
|
|
2861
|
+
}
|
|
2862
|
+
function loadTailwindV3Internals(source) {
|
|
2863
|
+
const requireFromProject = createRequire(`${source.cwd}/package.json`);
|
|
2864
|
+
const requireFromRuntime = createRequire(import.meta.url);
|
|
2865
|
+
const requireTailwind = (id) => {
|
|
2866
|
+
try {
|
|
2867
|
+
return requireFromProject(id);
|
|
2868
|
+
} catch {
|
|
2869
|
+
return requireFromRuntime(id);
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
const collapseAdjacentRulesModule = requireTailwind(`${source.packageName}/lib/lib/collapseAdjacentRules`);
|
|
2873
|
+
const collapseDuplicateDeclarationsModule = requireTailwind(`${source.packageName}/lib/lib/collapseDuplicateDeclarations`);
|
|
2874
|
+
const generateRulesModule = requireTailwind(`${source.packageName}/lib/lib/generateRules`);
|
|
2875
|
+
const sharedStateModule = requireTailwind(`${source.packageName}/lib/lib/sharedState`);
|
|
2876
|
+
const setupContextUtils = requireTailwind(`${source.packageName}/lib/lib/setupContextUtils`);
|
|
2877
|
+
const processTailwindFeaturesModule = requireTailwind(`${source.packageName}/lib/processTailwindFeatures`);
|
|
2878
|
+
const resolveDefaultsAtRulesModule = requireTailwind(`${source.packageName}/lib/lib/resolveDefaultsAtRules`);
|
|
2879
|
+
const resolveConfigModule = requireTailwind(`${source.packageName}/lib/public/resolve-config`);
|
|
2880
|
+
const validateConfigModule = requireTailwind(`${source.packageName}/lib/util/validateConfig.js`);
|
|
2881
|
+
return {
|
|
2882
|
+
collapseAdjacentRules: collapseAdjacentRulesModule["default"] ?? collapseAdjacentRulesModule,
|
|
2883
|
+
collapseDuplicateDeclarations: collapseDuplicateDeclarationsModule["default"] ?? collapseDuplicateDeclarationsModule,
|
|
2884
|
+
createContext: setupContextUtils["createContext"],
|
|
2885
|
+
generateRules: generateRulesModule["generateRules"],
|
|
2886
|
+
notOnDemandCandidate: String(sharedStateModule["NOT_ON_DEMAND"] ?? "*"),
|
|
2887
|
+
processTailwindFeatures: processTailwindFeaturesModule["default"] ?? processTailwindFeaturesModule,
|
|
2888
|
+
resolveDefaultsAtRules: resolveDefaultsAtRulesModule["default"] ?? resolveDefaultsAtRulesModule,
|
|
2889
|
+
resolveConfig: resolveConfigModule["default"] ?? resolveConfigModule,
|
|
2890
|
+
validateConfig: validateConfigModule["validateConfig"]
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
function createStableJson(value) {
|
|
2894
|
+
if (value === void 0) return "undefined";
|
|
2895
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
2896
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
2897
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
2898
|
+
const record = value;
|
|
2899
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
2900
|
+
}).join(",")}}`;
|
|
2901
|
+
}
|
|
2902
|
+
function createDependencyFingerprint(files) {
|
|
2903
|
+
return files.map((file) => {
|
|
2904
|
+
try {
|
|
2905
|
+
const stat = fs.statSync(file);
|
|
2906
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
2907
|
+
} catch {
|
|
2908
|
+
return `${file}:missing`;
|
|
2909
|
+
}
|
|
2910
|
+
}).join("|");
|
|
2911
|
+
}
|
|
2912
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
2913
|
+
return [
|
|
2914
|
+
source.packageName,
|
|
2915
|
+
source.postcssPlugin,
|
|
2916
|
+
source.cwd,
|
|
2917
|
+
source.config ?? "config:missing",
|
|
2918
|
+
createDependencyFingerprint(source.dependencies),
|
|
2919
|
+
source.css,
|
|
2920
|
+
createStableJson(normalizeConfigObject(source.configObject)?.content),
|
|
2921
|
+
target,
|
|
2922
|
+
createStableJson(styleOptions)
|
|
2923
|
+
].join("\0");
|
|
2924
|
+
}
|
|
2925
|
+
function createRuntimeReadyCacheKey(source, rootPath) {
|
|
2926
|
+
return [
|
|
2927
|
+
source.packageName,
|
|
2928
|
+
source.postcssPlugin,
|
|
2929
|
+
rootPath ?? "missing",
|
|
2930
|
+
source.config ?? "config:missing",
|
|
2931
|
+
source.cwd
|
|
2932
|
+
].join("\0");
|
|
2933
|
+
}
|
|
2934
|
+
function isDirectUtilitiesOnlyCss(css) {
|
|
2935
|
+
return css.replace(/\s+/g, "") === "@tailwindutilities;";
|
|
2936
|
+
}
|
|
2937
|
+
function collectClassSet(context) {
|
|
2938
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
2939
|
+
for (const candidate of context.classCache.keys()) if (String(candidate) !== "*") classSet.add(candidate);
|
|
2940
|
+
return classSet;
|
|
2941
|
+
}
|
|
2942
|
+
function collectDependencyMessages(result) {
|
|
2943
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
2944
|
+
for (const message of result.messages) {
|
|
2945
|
+
const file = message["file"];
|
|
2946
|
+
if (message["type"] === "dependency" && typeof file === "string") dependencies.add(file);
|
|
2947
|
+
}
|
|
2948
|
+
return dependencies;
|
|
2949
|
+
}
|
|
2950
|
+
function sortCandidates(candidates) {
|
|
2951
|
+
return [...candidates].sort((a, z) => {
|
|
2952
|
+
if (a === z) return 0;
|
|
2953
|
+
return a < z ? -1 : 1;
|
|
2954
|
+
});
|
|
2955
|
+
}
|
|
2956
|
+
function appendUtilityRules(root, context, rules) {
|
|
2957
|
+
const sortedRules = context.offsets.sort(rules);
|
|
2958
|
+
for (const [sort, rule] of sortedRules) {
|
|
2959
|
+
const tailwindRaw = rule.raws.tailwind;
|
|
2960
|
+
if (sort.layer === "utilities" || sort.layer === "variants" && tailwindRaw?.parentLayer === "utilities") root.append(rule.clone());
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
function appendDirectUtilityRules(root, context) {
|
|
2964
|
+
appendUtilityRules(root, context, [...context.ruleCache]);
|
|
2965
|
+
}
|
|
2966
|
+
function createRuntimeReadyPromise(source) {
|
|
2967
|
+
const patcher = createTailwindcssPatcher({
|
|
2968
|
+
basedir: source.cwd,
|
|
2969
|
+
supportCustomLengthUnitsPatch: true,
|
|
2970
|
+
tailwindcss: {
|
|
2971
|
+
...source.config === void 0 ? {} : { config: source.config },
|
|
2972
|
+
cwd: source.cwd,
|
|
2973
|
+
packageName: source.packageName,
|
|
2974
|
+
postcssPlugin: source.postcssPlugin,
|
|
2975
|
+
version: 3
|
|
2976
|
+
}
|
|
2977
|
+
});
|
|
2978
|
+
const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
|
|
2979
|
+
const cached = runtimeReadyPromiseCache.get(cacheKey);
|
|
2980
|
+
if (cached) return cached;
|
|
2981
|
+
const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
|
|
2982
|
+
runtimeReadyPromiseCache.delete(cacheKey);
|
|
2983
|
+
throw error;
|
|
2984
|
+
});
|
|
2985
|
+
runtimeReadyPromiseCache.set(cacheKey, task);
|
|
2986
|
+
return task;
|
|
2987
|
+
}
|
|
2988
|
+
function createTailwindV3Engine(source) {
|
|
2989
|
+
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
2990
|
+
let tailwindInternals;
|
|
2991
|
+
async function generateOnce(generateSource, options = {}) {
|
|
2992
|
+
await runtimeReadyPromise;
|
|
2993
|
+
tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
|
|
2994
|
+
const internals = tailwindInternals;
|
|
2995
|
+
const { styleOptions, target = "weapp" } = options;
|
|
2996
|
+
const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, options)));
|
|
2997
|
+
const changedContent = createChangedContentEntries(options.candidates ?? [], options.sources ?? []);
|
|
2998
|
+
const root = postcss.parse(generateSource.css, { from: void 0 });
|
|
2999
|
+
const result = {
|
|
3000
|
+
css: "",
|
|
3001
|
+
messages: []
|
|
3002
|
+
};
|
|
3003
|
+
let context;
|
|
3004
|
+
if (isDirectUtilitiesOnlyCss(generateSource.css)) {
|
|
3005
|
+
context = internals.createContext(tailwindConfig, changedContent, root);
|
|
3006
|
+
internals.generateRules(new Set(sortCandidates([internals.notOnDemandCandidate, ...collectCandidates(options.candidates)])), context);
|
|
3007
|
+
root.removeAll();
|
|
3008
|
+
appendDirectUtilityRules(root, context);
|
|
3009
|
+
internals.resolveDefaultsAtRules(context)(root, result);
|
|
3010
|
+
internals.collapseAdjacentRules(context)(root, result);
|
|
3011
|
+
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3012
|
+
} else {
|
|
3013
|
+
const setupContext = () => {
|
|
3014
|
+
return (currentRoot) => internals.createContext(tailwindConfig, changedContent, currentRoot);
|
|
3015
|
+
};
|
|
3016
|
+
context = await internals.processTailwindFeatures(setupContext)(root, result);
|
|
3017
|
+
}
|
|
3018
|
+
const rawCss = root.toString();
|
|
3019
|
+
const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
|
|
3020
|
+
const dependencies = collectDependencyMessages(result);
|
|
3021
|
+
for (const dependency of generateSource.dependencies) dependencies.add(dependency);
|
|
3022
|
+
const classSet = collectClassSet(context);
|
|
3023
|
+
return {
|
|
3024
|
+
css,
|
|
3025
|
+
rawCss,
|
|
3026
|
+
context,
|
|
3027
|
+
classSet,
|
|
3028
|
+
rawCandidates: collectCandidates(options.candidates),
|
|
3029
|
+
dependencies: [...dependencies],
|
|
3030
|
+
sources: [],
|
|
3031
|
+
root: null,
|
|
3032
|
+
target,
|
|
3033
|
+
version: 3
|
|
3034
|
+
};
|
|
3035
|
+
}
|
|
3036
|
+
async function generateIncrementalMissingUtilities(context, candidates, target, styleOptions) {
|
|
3037
|
+
tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
|
|
3038
|
+
const internals = tailwindInternals;
|
|
3039
|
+
const root = postcss.root();
|
|
3040
|
+
const result = {
|
|
3041
|
+
css: "",
|
|
3042
|
+
messages: []
|
|
3043
|
+
};
|
|
3044
|
+
appendUtilityRules(root, context, internals.generateRules(new Set(sortCandidates(candidates)), context));
|
|
3045
|
+
internals.resolveDefaultsAtRules(context)(root, result);
|
|
3046
|
+
internals.collapseAdjacentRules(context)(root, result);
|
|
3047
|
+
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3048
|
+
const rawCss = root.toString();
|
|
3049
|
+
return {
|
|
3050
|
+
css: await transformTailwindV3CssByTarget(rawCss, target, styleOptions),
|
|
3051
|
+
rawCss,
|
|
3052
|
+
classSet: collectClassSet(context),
|
|
3053
|
+
dependencies: collectDependencyMessages(result)
|
|
3054
|
+
};
|
|
3055
|
+
}
|
|
3056
|
+
async function generateWithIncrementalCache(options = {}) {
|
|
3057
|
+
if ((options.sources?.length ?? 0) > 0) return generateOnce(source, options);
|
|
3058
|
+
const target = options.target ?? "weapp";
|
|
3059
|
+
const requestedCandidates = collectCandidates(options.candidates);
|
|
3060
|
+
if (requestedCandidates.size === 0) return generateOnce(source, options);
|
|
3061
|
+
const cacheKey = createIncrementalGenerateCacheKey(source, target, options.styleOptions);
|
|
3062
|
+
const cached = incrementalGenerateCache.get(cacheKey);
|
|
3063
|
+
if (cached) {
|
|
3064
|
+
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
3065
|
+
if (missingCandidates.length === 0) return {
|
|
3066
|
+
css: cached.css,
|
|
3067
|
+
rawCss: cached.rawCss,
|
|
3068
|
+
incrementalCss: "",
|
|
3069
|
+
incrementalRawCss: "",
|
|
3070
|
+
classSet: new Set(cached.classSet),
|
|
3071
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
3072
|
+
dependencies: cached.dependencies,
|
|
3073
|
+
sources: [],
|
|
3074
|
+
root: null,
|
|
3075
|
+
target: cached.target,
|
|
3076
|
+
version: 3
|
|
3077
|
+
};
|
|
3078
|
+
const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, options.styleOptions);
|
|
3079
|
+
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
3080
|
+
for (const className of generated.classSet) cached.classSet.add(className);
|
|
3081
|
+
cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
|
|
3082
|
+
cached.rawCss = [cached.rawCss, generated.rawCss].filter(Boolean).join("\n");
|
|
3083
|
+
cached.dependencies = [...new Set([...cached.dependencies, ...generated.dependencies])];
|
|
3084
|
+
return {
|
|
3085
|
+
css: cached.css,
|
|
3086
|
+
rawCss: cached.rawCss,
|
|
3087
|
+
incrementalCss: generated.css,
|
|
3088
|
+
incrementalRawCss: generated.rawCss,
|
|
3089
|
+
classSet: new Set(cached.classSet),
|
|
3090
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
3091
|
+
dependencies: cached.dependencies,
|
|
3092
|
+
sources: [],
|
|
3093
|
+
root: null,
|
|
3094
|
+
target: cached.target,
|
|
3095
|
+
version: 3
|
|
3096
|
+
};
|
|
3097
|
+
}
|
|
3098
|
+
const generated = await generateOnce(source, options);
|
|
3099
|
+
incrementalGenerateCache.set(cacheKey, {
|
|
3100
|
+
context: generated.context,
|
|
3101
|
+
seenCandidates: new Set(requestedCandidates),
|
|
3102
|
+
classSet: new Set(generated.classSet),
|
|
3103
|
+
css: generated.css,
|
|
3104
|
+
rawCss: generated.rawCss,
|
|
3105
|
+
dependencies: generated.dependencies,
|
|
3106
|
+
target: generated.target
|
|
3107
|
+
});
|
|
3108
|
+
return generated;
|
|
3109
|
+
}
|
|
3110
|
+
async function generate(options = {}) {
|
|
3111
|
+
return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
|
|
3112
|
+
}
|
|
3113
|
+
return {
|
|
3114
|
+
source,
|
|
3115
|
+
async validateCandidates(candidates) {
|
|
3116
|
+
return (await generate({
|
|
3117
|
+
candidates,
|
|
3118
|
+
incrementalCache: true,
|
|
3119
|
+
target: "tailwind"
|
|
3120
|
+
})).classSet;
|
|
3121
|
+
},
|
|
3122
|
+
generate
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
//#endregion
|
|
3126
|
+
//#region src/tailwindcss/v3-engine/source.ts
|
|
3127
|
+
const DEFAULT_TAILWIND_V3_CSS = [
|
|
3128
|
+
"@tailwind base;",
|
|
3129
|
+
"@tailwind components;",
|
|
3130
|
+
"@tailwind utilities;"
|
|
3131
|
+
].join("\n");
|
|
3132
|
+
function parseConfigParam(params) {
|
|
3133
|
+
const value = params.trim();
|
|
3134
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
3135
|
+
}
|
|
3136
|
+
function resolveOptionalPath(value, base) {
|
|
3137
|
+
if (!value) return;
|
|
3138
|
+
return path.isAbsolute(value) ? value : path.resolve(base, value);
|
|
3139
|
+
}
|
|
3140
|
+
function resolveCssConfig(css, base) {
|
|
3141
|
+
if (!css) return {
|
|
3142
|
+
css,
|
|
3143
|
+
config: void 0
|
|
3144
|
+
};
|
|
3145
|
+
const root = postcss.parse(css);
|
|
3146
|
+
let config;
|
|
3147
|
+
root.walkAtRules("config", (rule) => {
|
|
3148
|
+
const configPath = parseConfigParam(rule.params);
|
|
3149
|
+
if (!configPath) return;
|
|
3150
|
+
if (!config) config = resolveOptionalPath(configPath, base);
|
|
3151
|
+
rule.remove();
|
|
3152
|
+
});
|
|
3153
|
+
return {
|
|
3154
|
+
config,
|
|
3155
|
+
css: root.toString()
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
function getProjectRoot(patcher) {
|
|
3159
|
+
return patcher.options?.projectRoot ?? process.cwd();
|
|
3160
|
+
}
|
|
3161
|
+
function normalizeLoadedConfig(config) {
|
|
3162
|
+
if (!config || typeof config !== "object") return config;
|
|
3163
|
+
const maybeDefault = config.default;
|
|
3164
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
3165
|
+
return config;
|
|
3166
|
+
}
|
|
3167
|
+
function resolveTailwindCssPackageName(patcher) {
|
|
3168
|
+
return resolveTailwindcssOptions(patcher.options)?.packageName ?? patcher.packageInfo?.name ?? "tailwindcss";
|
|
3169
|
+
}
|
|
3170
|
+
async function resolveTailwindV3Source(options = {}) {
|
|
3171
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
3172
|
+
const base = options.base ?? options.cwd ?? projectRoot;
|
|
3173
|
+
const cssConfig = resolveCssConfig(options.css, base);
|
|
3174
|
+
const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
|
|
3175
|
+
const cwd = options.cwd ?? (config ? path.dirname(config) : projectRoot);
|
|
3176
|
+
const loaded = await loadConfig(omitUndefined({
|
|
3177
|
+
config,
|
|
3178
|
+
cwd
|
|
3179
|
+
}));
|
|
3180
|
+
return {
|
|
3181
|
+
version: 3,
|
|
3182
|
+
projectRoot,
|
|
3183
|
+
cwd,
|
|
3184
|
+
base,
|
|
3185
|
+
css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
|
|
3186
|
+
config: loaded?.filepath ?? config,
|
|
3187
|
+
configObject: normalizeLoadedConfig(loaded?.config),
|
|
3188
|
+
dependencies: loaded?.filepath ? [loaded.filepath] : [],
|
|
3189
|
+
packageName: options.packageName ?? "tailwindcss",
|
|
3190
|
+
postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
|
|
3194
|
+
const projectRoot = getProjectRoot(patcher);
|
|
3195
|
+
const tailwindOptions = resolveTailwindcssOptions(patcher.options);
|
|
3196
|
+
return {
|
|
3197
|
+
projectRoot,
|
|
3198
|
+
cwd: tailwindOptions?.v3?.cwd ?? tailwindOptions?.cwd ?? projectRoot,
|
|
3199
|
+
config: tailwindOptions?.v3?.config ?? tailwindOptions?.config,
|
|
3200
|
+
packageName: resolveTailwindCssPackageName(patcher),
|
|
3201
|
+
postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
3205
|
+
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
3206
|
+
}
|
|
3207
|
+
//#endregion
|
|
3208
|
+
export { createSourceScanPattern as A, omitUndefined as B, createTailwindV4Engine$1 as C, filterUnsupportedMiniProgramTailwindV4Candidates as D, removeUnsupportedCascadeLayers as E, createDebug as F, findWorkspacePackageDir as H, createTailwindcssPatcher as I, readInstalledPackageMajorVersion as L, normalizeLegacyContentEntries as M, parseConfigParam$1 as N, loadTailwindV4DesignSystem as O, resolveCssSourceEntries as P, findTailwindConfig as R, resolveTailwindV4SourceOptionsFromPatcher as S, transformTailwindV4CssToWeapp as T, findWorkspaceRoot as U, findNearestPackageRoot as V, resolveViteSourceScanEntries as _, transformTailwindV3CssByTarget as a, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, invalidateRuntimeClassSet as d, runtimeSignaturePatchersSymbol as f, resolveTailwindV4EntriesFromCssCached as g, resolveTailwindV4EntriesFromCss as h, createTailwindV3Engine as i, expandTailwindSourceEntries as j, collectCssInlineSourceCandidates as k, getRuntimeClassSetSignature as l, discoverTailwindV4CssEntries as m, resolveTailwindV3SourceFromPatcher as n, transformTailwindV3CssToWeapp as o, createViteSourceScanMatcher as p, resolveTailwindV3SourceOptionsFromPatcher as r, ensureTailwindcssRuntimePatch as s, resolveTailwindV3Source as t, getRuntimeClassSetSignatureWithSources as u, resolveViteTailwindV4CssDependencies as v, transformTailwindV4CssByTarget as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, resolveTailwindcssOptions as z };
|