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