weapp-tailwindcss 5.1.14 → 5.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-2dg_uhEJ.mjs +13 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
- package/dist/bundlers/gulp/index.d.ts +2 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +43 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +4 -2
- package/dist/bundlers/shared/framework-postcss.d.ts +14 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +18 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +25 -0
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +33 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +3 -6
- package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
- package/dist/bundlers/shared/generator-css.d.ts +1 -2
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +3 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
- package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle-runtime.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +12 -0
- package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
- package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +4 -2
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +5 -4
- package/dist/bundlers/vite/source-candidates/collector.d.ts +8 -0
- package/dist/bundlers/vite/source-candidates/store.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/types-and-cache.d.ts +69 -0
- package/dist/bundlers/vite/source-candidates.d.ts +4 -68
- package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -217
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +6 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
- package/dist/cli.js +14 -18
- package/dist/cli.mjs +14 -18
- package/dist/{context-VeFq_8vW.js → context-BtLIID4m.js} +3 -3
- package/dist/{context-BL8Gy71H.mjs → context-JzwzSX36.mjs} +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{generator-CEnUsjed.js → generator-B91GhUJQ.js} +636 -505
- package/dist/{generator-B59OA64h.mjs → generator-Bv7myuhY.mjs} +557 -432
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/{gulp-DUYWxmZC.mjs → gulp-CKSklPlH.mjs} +218 -153
- package/dist/{gulp-C1Q3LRzg.js → gulp-Q1wITegn.js} +218 -153
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-C3ed5vCx.mjs → hmr-timing-BXg7nI8N.mjs} +3406 -3145
- package/dist/{hmr-timing-BZ5sWIqO.js → hmr-timing-CMPaWn9P.js} +3474 -3147
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/shared/mpx-plugin-owner.d.ts +2 -0
- package/dist/shared/mpx.d.ts +4 -1
- package/dist/{source-candidate-scan-signature-R3dzamcm.js → source-candidate-scan-signature-BKZZk_e6.js} +144 -96
- package/dist/{source-candidate-scan-signature-D7RWjWsY.mjs → source-candidate-scan-signature-CtK-mB_C.mjs} +127 -60
- package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
- package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +52 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
- package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-B4phC0kB.js} +2 -2
- package/dist/{tailwindcss-DPcKMLxL.mjs → tailwindcss-BTcXX8Ka.mjs} +2 -2
- package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
- package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
- package/dist/{vite-CBU5NXTX.mjs → vite-BwQWl9ft.mjs} +1269 -878
- package/dist/{vite-BNlPdsGM.js → vite-DhVnXvAQ.js} +1314 -923
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-generation-loader.js +12 -0
- package/dist/weapp-tw-css-import-rewrite-loader-B0tVkJLH.js +10524 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +6 -10255
- package/dist/weapp-tw-runtime-classset-loader.js +10 -4
- package/dist/{webpack-CZ38fMGC.mjs → webpack-Bo1QrFPf.mjs} +1518 -1079
- package/dist/{webpack-Jpe048pQ.js → webpack-kh78iMSS.js} +1519 -1080
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +17 -7
- package/dist/auto-CrJJc5rK.mjs +0 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveUniUtsPlatform as resolveUniUtsPlatform$1 } from "./framework.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { c as withCssMacroStyleOptions, i as hasCssMacroTailwindV4Source, o as transformCssMacroCss, s as transformCssMacroTailwindV4Source, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.mjs";
|
|
3
3
|
import { t as omitUndefined } from "./object-BJSWl-E5.mjs";
|
|
4
4
|
import "./utils-MVwpU07P.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
@@ -61,6 +61,217 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
61
61
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
|
+
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
65
|
+
const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
|
|
66
|
+
const BARE_RPX_LENGTH_CANDIDATE_RE = new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
|
|
67
|
+
const BARE_RPX_LENGTH_HINT_CANDIDATE_RE = new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
|
|
68
|
+
const RPX_LENGTH_SELECTOR_RE = new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
|
|
69
|
+
function normalizeRpxLengthCandidate(candidate) {
|
|
70
|
+
return candidate.replace(BARE_RPX_LENGTH_CANDIDATE_RE, (_match, prefix, important, utility, value, suffix) => {
|
|
71
|
+
return `${prefix}${important}${utility}-[length:${value}]${suffix}`;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function normalizeRpxLengthCandidates(candidates) {
|
|
75
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
76
|
+
const restoreCandidates = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const candidate of candidates) {
|
|
78
|
+
const normalizedCandidate = normalizeRpxLengthCandidate(candidate);
|
|
79
|
+
normalized.add(normalizedCandidate);
|
|
80
|
+
if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
candidates: normalized,
|
|
84
|
+
restoreCandidates
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function restoreRpxLengthCandidates(candidates, restoreCandidates) {
|
|
88
|
+
if (restoreCandidates.size === 0) return new Set(candidates);
|
|
89
|
+
return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
|
|
90
|
+
}
|
|
91
|
+
function normalizeCssEscapedRpxSelectorValue(value) {
|
|
92
|
+
return value.replace(/\\([.+-])/g, "$1");
|
|
93
|
+
}
|
|
94
|
+
function restoreRpxLengthCssSelectors(css, restoreCandidates) {
|
|
95
|
+
if (restoreCandidates.size === 0 || !css.includes("\\[length\\:")) return css;
|
|
96
|
+
const restoredUtilities = new Set([...restoreCandidates.keys()].map((candidate) => {
|
|
97
|
+
const match = BARE_RPX_LENGTH_HINT_CANDIDATE_RE.exec(candidate);
|
|
98
|
+
return match ? `${match[1]}:${match[2]}` : void 0;
|
|
99
|
+
}).filter((value) => Boolean(value)));
|
|
100
|
+
return css.replace(RPX_LENGTH_SELECTOR_RE, (match, utility, value) => {
|
|
101
|
+
return restoredUtilities.has(`${utility}:${normalizeCssEscapedRpxSelectorValue(value)}`) ? `${utility}-\\[${value}\\]` : match;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 12e3;
|
|
105
|
+
const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 2 * 1024 * 1024;
|
|
106
|
+
const incrementalGenerateCache = new LRUCache({ max: 8 });
|
|
107
|
+
const incrementalGenerateTaskCache = new LRUCache({ max: 32 });
|
|
108
|
+
function collectCandidates(candidates) {
|
|
109
|
+
return new Set(candidates ?? []);
|
|
110
|
+
}
|
|
111
|
+
function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
112
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
function createStableJson(value) {
|
|
116
|
+
if (value === void 0) return "undefined";
|
|
117
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
118
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
119
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
120
|
+
const record = value;
|
|
121
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
122
|
+
}).join(",")}}`;
|
|
123
|
+
}
|
|
124
|
+
function createDependencyFingerprint(files) {
|
|
125
|
+
return files.map((file) => {
|
|
126
|
+
try {
|
|
127
|
+
const stat = fs.statSync(file);
|
|
128
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
129
|
+
} catch {
|
|
130
|
+
return `${file}:missing`;
|
|
131
|
+
}
|
|
132
|
+
}).join("|");
|
|
133
|
+
}
|
|
134
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
135
|
+
return [
|
|
136
|
+
source.projectRoot,
|
|
137
|
+
source.base,
|
|
138
|
+
createStableJson(source.baseFallbacks),
|
|
139
|
+
source.css,
|
|
140
|
+
createDependencyFingerprint(source.dependencies),
|
|
141
|
+
target,
|
|
142
|
+
createStableJson(styleOptions)
|
|
143
|
+
].join("\0");
|
|
144
|
+
}
|
|
145
|
+
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
146
|
+
return [
|
|
147
|
+
cacheKey,
|
|
148
|
+
scanSources === true ? "scan:1" : "scan:0",
|
|
149
|
+
[...requestedCandidates].sort().join("\n")
|
|
150
|
+
].join("\0");
|
|
151
|
+
}
|
|
152
|
+
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
153
|
+
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
154
|
+
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
155
|
+
if (cachedTask) return cachedTask;
|
|
156
|
+
const promise = task();
|
|
157
|
+
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
158
|
+
promise.finally(() => {
|
|
159
|
+
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
160
|
+
});
|
|
161
|
+
return promise;
|
|
162
|
+
}
|
|
163
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
164
|
+
const promise = loadTailwindV4DesignSystem(source);
|
|
165
|
+
promise.catch(() => {
|
|
166
|
+
if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
|
|
167
|
+
});
|
|
168
|
+
return promise;
|
|
169
|
+
}
|
|
170
|
+
function resolveTargetCandidates(candidates, target) {
|
|
171
|
+
const collected = collectCandidates(candidates);
|
|
172
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
173
|
+
}
|
|
174
|
+
function collectSeenCandidates(generated) {
|
|
175
|
+
return new Set(generated.classSet);
|
|
176
|
+
}
|
|
177
|
+
function shouldDelegateWebSourceScanToTailwind(target, scanSources) {
|
|
178
|
+
return target === "web" && scanSources !== false;
|
|
179
|
+
}
|
|
180
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
181
|
+
return {
|
|
182
|
+
...styleOptions,
|
|
183
|
+
isMainChunk: false
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function resolveStyleOptions(source, options) {
|
|
187
|
+
return hasCssMacroTailwindV4Source(source.css) ? withCssMacroStyleOptions(options) : options;
|
|
188
|
+
}
|
|
189
|
+
function collectCustomPropertyValues(css) {
|
|
190
|
+
const values = /* @__PURE__ */ new Map();
|
|
191
|
+
try {
|
|
192
|
+
postcss.parse(css).walkDecls((decl) => {
|
|
193
|
+
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
194
|
+
});
|
|
195
|
+
} catch {}
|
|
196
|
+
return values;
|
|
197
|
+
}
|
|
198
|
+
function mergeCustomPropertyValues(target, css) {
|
|
199
|
+
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
200
|
+
}
|
|
201
|
+
function createStableTextSignature(input) {
|
|
202
|
+
let hash = 2166136261;
|
|
203
|
+
for (let i = 0; i < input.length; i++) {
|
|
204
|
+
hash ^= input.charCodeAt(i);
|
|
205
|
+
hash = Math.imul(hash, 16777619);
|
|
206
|
+
}
|
|
207
|
+
return (hash >>> 0).toString(36);
|
|
208
|
+
}
|
|
209
|
+
function summarizeIncrementalCacheKey(key) {
|
|
210
|
+
return {
|
|
211
|
+
keyHash: createStableTextSignature(key),
|
|
212
|
+
keyBytes: key.length
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
|
|
216
|
+
return cached.seenCandidates.size + missingCandidates.length > 12e3 || cached.css.length > 2097152 || cached.rawCss.length > 2097152 || requestedCandidates.size > 12e3;
|
|
217
|
+
}
|
|
218
|
+
function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
|
|
219
|
+
return requestedCandidates.size <= 12e3 && generated.css.length <= 2097152 && generated.rawCss.length <= 2097152;
|
|
220
|
+
}
|
|
221
|
+
function seedIncrementalGenerateCache(options) {
|
|
222
|
+
if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
|
|
223
|
+
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
|
|
224
|
+
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
225
|
+
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
226
|
+
incrementalGenerateCache.set(cacheKey, {
|
|
227
|
+
seenCandidates: collectSeenCandidates(options.generated),
|
|
228
|
+
classSet: new Set(options.generated.classSet),
|
|
229
|
+
css: options.generated.css,
|
|
230
|
+
rawCss: options.generated.rawCss,
|
|
231
|
+
customPropertyValues,
|
|
232
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
233
|
+
dependencies: options.generated.dependencies,
|
|
234
|
+
sources: options.generated.sources,
|
|
235
|
+
root: options.generated.root,
|
|
236
|
+
target: options.generated.target
|
|
237
|
+
});
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
|
|
241
|
+
if (target !== "web") return true;
|
|
242
|
+
return styleOptions?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
243
|
+
}
|
|
244
|
+
function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
|
|
245
|
+
return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? normalizeRpxLengthCandidates(candidates) : {
|
|
246
|
+
candidates: new Set(candidates),
|
|
247
|
+
restoreCandidates: /* @__PURE__ */ new Map()
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function resolveGeneratedSourcePatterns(generatedSources, scanSources) {
|
|
251
|
+
return Array.isArray(scanSources) ? scanSources : generatedSources;
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/tailwindcss/v4-engine/generator/cache-stats.ts
|
|
255
|
+
function getTailwindV4IncrementalGenerateCacheStats() {
|
|
256
|
+
return {
|
|
257
|
+
max: 8,
|
|
258
|
+
entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
|
|
259
|
+
entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
|
|
260
|
+
size: incrementalGenerateCache.size,
|
|
261
|
+
taskMax: 32,
|
|
262
|
+
taskSize: incrementalGenerateTaskCache.size,
|
|
263
|
+
entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
|
|
264
|
+
...summarizeIncrementalCacheKey(key),
|
|
265
|
+
candidates: entry.seenCandidates.size,
|
|
266
|
+
classSet: entry.classSet.size,
|
|
267
|
+
cssBytes: entry.css.length,
|
|
268
|
+
rawCssBytes: entry.rawCss.length
|
|
269
|
+
})),
|
|
270
|
+
keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
|
|
271
|
+
taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
64
275
|
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
65
276
|
function resolveCssMacroTailwindV4Source(source) {
|
|
66
277
|
const css = transformCssMacroTailwindV4Source(source.css);
|
|
@@ -70,6 +281,56 @@ function resolveCssMacroTailwindV4Source(source) {
|
|
|
70
281
|
};
|
|
71
282
|
}
|
|
72
283
|
//#endregion
|
|
284
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
285
|
+
const defaultStyleHandler = createStyleHandler({
|
|
286
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
287
|
+
cssRemoveHoverPseudoClass: true,
|
|
288
|
+
isMainChunk: true,
|
|
289
|
+
majorVersion: 4
|
|
290
|
+
});
|
|
291
|
+
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
292
|
+
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
293
|
+
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
294
|
+
try {
|
|
295
|
+
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
296
|
+
} catch {
|
|
297
|
+
return match;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
302
|
+
const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
303
|
+
const result = await defaultStyleHandler(protectedCss.css, {
|
|
304
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
305
|
+
cssRemoveHoverPseudoClass: true,
|
|
306
|
+
isMainChunk: true,
|
|
307
|
+
majorVersion: 4,
|
|
308
|
+
...options
|
|
309
|
+
});
|
|
310
|
+
const pruneOptions = {
|
|
311
|
+
preservePreflight: true,
|
|
312
|
+
preserveConditionalComments: hasCssMacroStyleOptions(options)
|
|
313
|
+
};
|
|
314
|
+
return pruneMiniProgramGeneratedCss$1(protectedCss.restore(result.css), pruneOptions);
|
|
315
|
+
}
|
|
316
|
+
function transformTailwindV4WebRpxCss(css) {
|
|
317
|
+
if (!css.includes("rpx")) return css;
|
|
318
|
+
try {
|
|
319
|
+
const root = postcss.parse(css);
|
|
320
|
+
return normalizeTailwindcssWebRpxDeclarations(root, { majorVersion: 4 }) ? root.toString() : css;
|
|
321
|
+
} catch {
|
|
322
|
+
return css;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function shouldTransformWebRpxCss(options) {
|
|
326
|
+
return options?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
327
|
+
}
|
|
328
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
329
|
+
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
330
|
+
const resolvedWebCss = await (hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css);
|
|
331
|
+
return shouldTransformWebRpxCss(options) ? transformTailwindV4WebRpxCss(resolvedWebCss) : resolvedWebCss;
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
73
334
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
74
335
|
const TAILWIND_V4_COLOR_STEPS = [
|
|
75
336
|
"50",
|
|
@@ -556,47 +817,6 @@ function createCompatibleSource(source, target) {
|
|
|
556
817
|
};
|
|
557
818
|
}
|
|
558
819
|
//#endregion
|
|
559
|
-
//#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
|
|
560
|
-
const RPX_LENGTH_UTILITY_PATTERN = String.raw`text|border(?:-[trblxyse])?|bg|outline|ring`;
|
|
561
|
-
const BARE_RPX_LENGTH_CANDIDATE_RE = new RegExp(String.raw`(^|:)(!?)(${RPX_LENGTH_UTILITY_PATTERN})-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$`, "u");
|
|
562
|
-
const BARE_RPX_LENGTH_HINT_CANDIDATE_RE = new RegExp(String.raw`(?:^|:)!?(${RPX_LENGTH_UTILITY_PATTERN})-\[length:([-+]?(?:\d+|\d*\.\d+)rpx)\].*$`, "u");
|
|
563
|
-
const RPX_LENGTH_SELECTOR_RE = new RegExp(String.raw`(${RPX_LENGTH_UTILITY_PATTERN})-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]`, "g");
|
|
564
|
-
function normalizeRpxLengthCandidate(candidate) {
|
|
565
|
-
return candidate.replace(BARE_RPX_LENGTH_CANDIDATE_RE, (_match, prefix, important, utility, value, suffix) => {
|
|
566
|
-
return `${prefix}${important}${utility}-[length:${value}]${suffix}`;
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
function normalizeRpxLengthCandidates(candidates) {
|
|
570
|
-
const normalized = /* @__PURE__ */ new Set();
|
|
571
|
-
const restoreCandidates = /* @__PURE__ */ new Map();
|
|
572
|
-
for (const candidate of candidates) {
|
|
573
|
-
const normalizedCandidate = normalizeRpxLengthCandidate(candidate);
|
|
574
|
-
normalized.add(normalizedCandidate);
|
|
575
|
-
if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
|
|
576
|
-
}
|
|
577
|
-
return {
|
|
578
|
-
candidates: normalized,
|
|
579
|
-
restoreCandidates
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
function restoreRpxLengthCandidates(candidates, restoreCandidates) {
|
|
583
|
-
if (restoreCandidates.size === 0) return new Set(candidates);
|
|
584
|
-
return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
|
|
585
|
-
}
|
|
586
|
-
function normalizeCssEscapedRpxSelectorValue(value) {
|
|
587
|
-
return value.replace(/\\([.+-])/g, "$1");
|
|
588
|
-
}
|
|
589
|
-
function restoreRpxLengthCssSelectors(css, restoreCandidates) {
|
|
590
|
-
if (restoreCandidates.size === 0 || !css.includes("\\[length\\:")) return css;
|
|
591
|
-
const restoredUtilities = new Set([...restoreCandidates.keys()].map((candidate) => {
|
|
592
|
-
const match = BARE_RPX_LENGTH_HINT_CANDIDATE_RE.exec(candidate);
|
|
593
|
-
return match ? `${match[1]}:${match[2]}` : void 0;
|
|
594
|
-
}).filter((value) => Boolean(value)));
|
|
595
|
-
return css.replace(RPX_LENGTH_SELECTOR_RE, (match, utility, value) => {
|
|
596
|
-
return restoredUtilities.has(`${utility}:${normalizeCssEscapedRpxSelectorValue(value)}`) ? `${utility}-\\[${value}\\]` : match;
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
//#endregion
|
|
600
820
|
//#region src/tailwindcss/source-scan.ts
|
|
601
821
|
const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
|
|
602
822
|
"html",
|
|
@@ -958,208 +1178,7 @@ async function resolveScanSources(source, scanSources) {
|
|
|
958
1178
|
return await resolveCssDefinedScanSources(source) ?? false;
|
|
959
1179
|
}
|
|
960
1180
|
//#endregion
|
|
961
|
-
//#region src/tailwindcss/v4-engine/
|
|
962
|
-
const defaultStyleHandler = createStyleHandler({
|
|
963
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
964
|
-
cssRemoveHoverPseudoClass: true,
|
|
965
|
-
isMainChunk: true,
|
|
966
|
-
majorVersion: 4
|
|
967
|
-
});
|
|
968
|
-
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
969
|
-
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
970
|
-
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
971
|
-
try {
|
|
972
|
-
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
973
|
-
} catch {
|
|
974
|
-
return match;
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
async function transformTailwindV4CssToWeapp(css, options) {
|
|
979
|
-
const protectedCss = protectDynamicColorMixAlpha(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
980
|
-
const result = await defaultStyleHandler(protectedCss.css, {
|
|
981
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
982
|
-
cssRemoveHoverPseudoClass: true,
|
|
983
|
-
isMainChunk: true,
|
|
984
|
-
majorVersion: 4,
|
|
985
|
-
...options
|
|
986
|
-
});
|
|
987
|
-
const pruneOptions = {
|
|
988
|
-
preservePreflight: true,
|
|
989
|
-
preserveConditionalComments: hasCssMacroStyleOptions(options)
|
|
990
|
-
};
|
|
991
|
-
return pruneMiniProgramGeneratedCss$1(protectedCss.restore(result.css), pruneOptions);
|
|
992
|
-
}
|
|
993
|
-
function transformTailwindV4WebRpxCss(css) {
|
|
994
|
-
if (!css.includes("rpx")) return css;
|
|
995
|
-
try {
|
|
996
|
-
const root = postcss.parse(css);
|
|
997
|
-
return normalizeTailwindcssWebRpxDeclarations(root, { majorVersion: 4 }) ? root.toString() : css;
|
|
998
|
-
} catch {
|
|
999
|
-
return css;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
function shouldTransformWebRpxCss(options) {
|
|
1003
|
-
return options?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
1004
|
-
}
|
|
1005
|
-
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
1006
|
-
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
1007
|
-
const resolvedWebCss = await (hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css);
|
|
1008
|
-
return shouldTransformWebRpxCss(options) ? transformTailwindV4WebRpxCss(resolvedWebCss) : resolvedWebCss;
|
|
1009
|
-
}
|
|
1010
|
-
//#endregion
|
|
1011
|
-
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1012
|
-
const INCREMENTAL_GENERATE_CACHE_MAX = 8;
|
|
1013
|
-
const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
|
|
1014
|
-
const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 12e3;
|
|
1015
|
-
const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 2 * 1024 * 1024;
|
|
1016
|
-
const incrementalGenerateCache = new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
|
|
1017
|
-
const incrementalGenerateTaskCache = new LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
|
|
1018
|
-
function collectCandidates(candidates) {
|
|
1019
|
-
return new Set(candidates ?? []);
|
|
1020
|
-
}
|
|
1021
|
-
function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
1022
|
-
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
1023
|
-
return false;
|
|
1024
|
-
}
|
|
1025
|
-
function createStableJson(value) {
|
|
1026
|
-
if (value === void 0) return "undefined";
|
|
1027
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1028
|
-
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
1029
|
-
return `{${Object.keys(value).sort().map((key) => {
|
|
1030
|
-
const record = value;
|
|
1031
|
-
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
1032
|
-
}).join(",")}}`;
|
|
1033
|
-
}
|
|
1034
|
-
function createDependencyFingerprint(files) {
|
|
1035
|
-
return files.map((file) => {
|
|
1036
|
-
try {
|
|
1037
|
-
const stat = fs.statSync(file);
|
|
1038
|
-
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
1039
|
-
} catch {
|
|
1040
|
-
return `${file}:missing`;
|
|
1041
|
-
}
|
|
1042
|
-
}).join("|");
|
|
1043
|
-
}
|
|
1044
|
-
function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
1045
|
-
return [
|
|
1046
|
-
source.projectRoot,
|
|
1047
|
-
source.base,
|
|
1048
|
-
createStableJson(source.baseFallbacks),
|
|
1049
|
-
source.css,
|
|
1050
|
-
createDependencyFingerprint(source.dependencies),
|
|
1051
|
-
target,
|
|
1052
|
-
createStableJson(styleOptions)
|
|
1053
|
-
].join("\0");
|
|
1054
|
-
}
|
|
1055
|
-
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
1056
|
-
return [
|
|
1057
|
-
cacheKey,
|
|
1058
|
-
scanSources === true ? "scan:1" : "scan:0",
|
|
1059
|
-
[...requestedCandidates].sort().join("\n")
|
|
1060
|
-
].join("\0");
|
|
1061
|
-
}
|
|
1062
|
-
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
1063
|
-
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
1064
|
-
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
1065
|
-
if (cachedTask) return cachedTask;
|
|
1066
|
-
const promise = task();
|
|
1067
|
-
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
1068
|
-
promise.finally(() => {
|
|
1069
|
-
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
1070
|
-
});
|
|
1071
|
-
return promise;
|
|
1072
|
-
}
|
|
1073
|
-
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
1074
|
-
const promise = loadTailwindV4DesignSystem(source);
|
|
1075
|
-
promise.catch(() => {
|
|
1076
|
-
if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
|
|
1077
|
-
});
|
|
1078
|
-
return promise;
|
|
1079
|
-
}
|
|
1080
|
-
function resolveTargetCandidates(candidates, target) {
|
|
1081
|
-
const collected = collectCandidates(candidates);
|
|
1082
|
-
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
1083
|
-
}
|
|
1084
|
-
function collectSeenCandidates(generated) {
|
|
1085
|
-
return new Set(generated.classSet);
|
|
1086
|
-
}
|
|
1087
|
-
function shouldDelegateWebSourceScanToTailwind(target, scanSources) {
|
|
1088
|
-
return target === "web" && scanSources !== false;
|
|
1089
|
-
}
|
|
1090
|
-
function createIncrementalStyleOptions(styleOptions) {
|
|
1091
|
-
return {
|
|
1092
|
-
...styleOptions,
|
|
1093
|
-
isMainChunk: false
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
function resolveStyleOptions(source, options) {
|
|
1097
|
-
return hasCssMacroTailwindV4Source(source.css) ? withCssMacroStyleOptions(options) : options;
|
|
1098
|
-
}
|
|
1099
|
-
function collectCustomPropertyValues(css) {
|
|
1100
|
-
const values = /* @__PURE__ */ new Map();
|
|
1101
|
-
try {
|
|
1102
|
-
postcss.parse(css).walkDecls((decl) => {
|
|
1103
|
-
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1104
|
-
});
|
|
1105
|
-
} catch {}
|
|
1106
|
-
return values;
|
|
1107
|
-
}
|
|
1108
|
-
function mergeCustomPropertyValues(target, css) {
|
|
1109
|
-
for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
|
|
1110
|
-
}
|
|
1111
|
-
function createStableTextSignature(input) {
|
|
1112
|
-
let hash = 2166136261;
|
|
1113
|
-
for (let i = 0; i < input.length; i++) {
|
|
1114
|
-
hash ^= input.charCodeAt(i);
|
|
1115
|
-
hash = Math.imul(hash, 16777619);
|
|
1116
|
-
}
|
|
1117
|
-
return (hash >>> 0).toString(36);
|
|
1118
|
-
}
|
|
1119
|
-
function summarizeIncrementalCacheKey(key) {
|
|
1120
|
-
return {
|
|
1121
|
-
keyHash: createStableTextSignature(key),
|
|
1122
|
-
keyBytes: key.length
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
|
|
1126
|
-
return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX;
|
|
1127
|
-
}
|
|
1128
|
-
function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
|
|
1129
|
-
return requestedCandidates.size <= INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX && generated.css.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX && generated.rawCss.length <= INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX;
|
|
1130
|
-
}
|
|
1131
|
-
function seedIncrementalGenerateCache(options) {
|
|
1132
|
-
if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
|
|
1133
|
-
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
|
|
1134
|
-
const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
|
|
1135
|
-
mergeCustomPropertyValues(customPropertyValues, options.generated.css);
|
|
1136
|
-
incrementalGenerateCache.set(cacheKey, {
|
|
1137
|
-
seenCandidates: collectSeenCandidates(options.generated),
|
|
1138
|
-
classSet: new Set(options.generated.classSet),
|
|
1139
|
-
css: options.generated.css,
|
|
1140
|
-
rawCss: options.generated.rawCss,
|
|
1141
|
-
customPropertyValues,
|
|
1142
|
-
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
1143
|
-
dependencies: options.generated.dependencies,
|
|
1144
|
-
sources: options.generated.sources,
|
|
1145
|
-
root: options.generated.root,
|
|
1146
|
-
target: options.generated.target
|
|
1147
|
-
});
|
|
1148
|
-
return true;
|
|
1149
|
-
}
|
|
1150
|
-
function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
|
|
1151
|
-
if (target !== "web") return true;
|
|
1152
|
-
return styleOptions?.appType === "uni-app-vite" || shouldUseWebGeneratorTargetFromEnv();
|
|
1153
|
-
}
|
|
1154
|
-
function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
|
|
1155
|
-
return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? normalizeRpxLengthCandidates(candidates) : {
|
|
1156
|
-
candidates: new Set(candidates),
|
|
1157
|
-
restoreCandidates: /* @__PURE__ */ new Map()
|
|
1158
|
-
};
|
|
1159
|
-
}
|
|
1160
|
-
function resolveGeneratedSourcePatterns(generatedSources, scanSources) {
|
|
1161
|
-
return Array.isArray(scanSources) ? scanSources : generatedSources;
|
|
1162
|
-
}
|
|
1181
|
+
//#region src/tailwindcss/v4-engine/generator/engine.ts
|
|
1163
1182
|
function createTailwindV4Engine$1(source) {
|
|
1164
1183
|
async function generateOnce(generateSource, options = {}) {
|
|
1165
1184
|
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
@@ -1304,25 +1323,6 @@ function createTailwindV4Engine$1(source) {
|
|
|
1304
1323
|
generate
|
|
1305
1324
|
};
|
|
1306
1325
|
}
|
|
1307
|
-
function getTailwindV4IncrementalGenerateCacheStats() {
|
|
1308
|
-
return {
|
|
1309
|
-
max: INCREMENTAL_GENERATE_CACHE_MAX,
|
|
1310
|
-
entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
|
|
1311
|
-
entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
|
|
1312
|
-
size: incrementalGenerateCache.size,
|
|
1313
|
-
taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
|
|
1314
|
-
taskSize: incrementalGenerateTaskCache.size,
|
|
1315
|
-
entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
|
|
1316
|
-
...summarizeIncrementalCacheKey(key),
|
|
1317
|
-
candidates: entry.seenCandidates.size,
|
|
1318
|
-
classSet: entry.classSet.size,
|
|
1319
|
-
cssBytes: entry.css.length,
|
|
1320
|
-
rawCssBytes: entry.rawCss.length
|
|
1321
|
-
})),
|
|
1322
|
-
keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
|
|
1323
|
-
taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
|
|
1324
|
-
};
|
|
1325
|
-
}
|
|
1326
1326
|
//#endregion
|
|
1327
1327
|
//#region src/bundlers/shared/generator-css/config-directive.ts
|
|
1328
1328
|
function quoteCssString(value) {
|
|
@@ -1781,12 +1781,293 @@ function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
1783
|
//#endregion
|
|
1784
|
-
//#region src/bundlers/shared/generator-css/
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1787
|
-
"
|
|
1788
|
-
|
|
1789
|
-
|
|
1784
|
+
//#region src/bundlers/shared/generator-css/scoped-rules.ts
|
|
1785
|
+
const VUE_SCOPED_SELECTOR_RE = /\.data-v-[\w-]+|\[data-v-[^\]]+\]/g;
|
|
1786
|
+
function normalizeGeneratedSelector$1(selector) {
|
|
1787
|
+
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1788
|
+
}
|
|
1789
|
+
function normalizeVueScopedSelector(selector) {
|
|
1790
|
+
let scoped = false;
|
|
1791
|
+
return {
|
|
1792
|
+
normalized: normalizeGeneratedSelector$1(selector).replace(VUE_SCOPED_SELECTOR_RE, () => {
|
|
1793
|
+
scoped = true;
|
|
1794
|
+
return "";
|
|
1795
|
+
}).trim(),
|
|
1796
|
+
scoped
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
function normalizeCssComparableValue(value) {
|
|
1800
|
+
const normalizeUnquotedSegment = (segment) => segment.replace(/(^|[^\w.-])(-?)0+\.(\d+)/g, "$1$2.$3");
|
|
1801
|
+
let result = "";
|
|
1802
|
+
let segmentStart = 0;
|
|
1803
|
+
let index = 0;
|
|
1804
|
+
while (index < value.length) {
|
|
1805
|
+
const quote = value[index];
|
|
1806
|
+
if (quote !== "\"" && quote !== "'") {
|
|
1807
|
+
index++;
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
result += normalizeUnquotedSegment(value.slice(segmentStart, index));
|
|
1811
|
+
const stringStart = index;
|
|
1812
|
+
index++;
|
|
1813
|
+
while (index < value.length) {
|
|
1814
|
+
if (value[index] === "\\") {
|
|
1815
|
+
index += 2;
|
|
1816
|
+
continue;
|
|
1817
|
+
}
|
|
1818
|
+
if (value[index] === quote) {
|
|
1819
|
+
index++;
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
index++;
|
|
1823
|
+
}
|
|
1824
|
+
result += value.slice(stringStart, index);
|
|
1825
|
+
segmentStart = index;
|
|
1826
|
+
}
|
|
1827
|
+
return result + normalizeUnquotedSegment(value.slice(segmentStart));
|
|
1828
|
+
}
|
|
1829
|
+
function createCssNodeSignature(node) {
|
|
1830
|
+
if (node.type === "decl") return JSON.stringify([
|
|
1831
|
+
"decl",
|
|
1832
|
+
node.prop,
|
|
1833
|
+
normalizeCssComparableValue(node.value),
|
|
1834
|
+
node.important
|
|
1835
|
+
]);
|
|
1836
|
+
if (node.type === "atrule") return JSON.stringify([
|
|
1837
|
+
"atrule",
|
|
1838
|
+
node.name,
|
|
1839
|
+
normalizeCssComparableValue(node.params),
|
|
1840
|
+
node.nodes?.map(createCssNodeSignature) ?? null
|
|
1841
|
+
]);
|
|
1842
|
+
if (node.type === "rule") return JSON.stringify([
|
|
1843
|
+
"rule",
|
|
1844
|
+
node.selector,
|
|
1845
|
+
node.nodes?.map(createCssNodeSignature) ?? null
|
|
1846
|
+
]);
|
|
1847
|
+
if (node.type === "comment") return JSON.stringify(["comment", node.text]);
|
|
1848
|
+
return node.toString();
|
|
1849
|
+
}
|
|
1850
|
+
function createRuleBodySignature(rule) {
|
|
1851
|
+
return JSON.stringify(rule.nodes?.map(createCssNodeSignature) ?? []);
|
|
1852
|
+
}
|
|
1853
|
+
function createRuleAtRuleContextSignature(rule) {
|
|
1854
|
+
const context = [];
|
|
1855
|
+
let parent = rule.parent;
|
|
1856
|
+
while (parent && parent.type !== "root" && parent.type !== "document") {
|
|
1857
|
+
if (parent.type === "atrule") context.unshift(JSON.stringify([parent.name, parent.params]));
|
|
1858
|
+
parent = parent.parent;
|
|
1859
|
+
}
|
|
1860
|
+
return JSON.stringify(context);
|
|
1861
|
+
}
|
|
1862
|
+
function createScopedRuleCoverageKey(rule, selector) {
|
|
1863
|
+
return JSON.stringify([
|
|
1864
|
+
createRuleAtRuleContextSignature(rule),
|
|
1865
|
+
createRuleBodySignature(rule),
|
|
1866
|
+
selector
|
|
1867
|
+
]);
|
|
1868
|
+
}
|
|
1869
|
+
function removeUnscopedRulesCoveredByScopedRules(root) {
|
|
1870
|
+
const scopedCoverage = /* @__PURE__ */ new Set();
|
|
1871
|
+
root.walkRules((rule) => {
|
|
1872
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1873
|
+
const normalized = normalizeVueScopedSelector(selector);
|
|
1874
|
+
if (normalized.scoped && normalized.normalized) scopedCoverage.add(createScopedRuleCoverageKey(rule, normalized.normalized));
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
if (scopedCoverage.size === 0) return;
|
|
1878
|
+
root.walkRules((rule) => {
|
|
1879
|
+
const normalizedSelectors = (rule.selectors ?? [rule.selector]).map(normalizeVueScopedSelector);
|
|
1880
|
+
if (normalizedSelectors.some((selector) => selector.scoped || !selector.normalized) || !normalizedSelectors.every((selector) => scopedCoverage.has(createScopedRuleCoverageKey(rule, selector.normalized)))) return;
|
|
1881
|
+
rule.remove();
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
function preferScopedGeneratedCssRules(css) {
|
|
1885
|
+
if (!css.includes("data-v-")) return css;
|
|
1886
|
+
try {
|
|
1887
|
+
const root = postcss.parse(css);
|
|
1888
|
+
removeUnscopedRulesCoveredByScopedRules(root);
|
|
1889
|
+
root.walkAtRules((rule) => {
|
|
1890
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1891
|
+
});
|
|
1892
|
+
return root.toString();
|
|
1893
|
+
} catch {
|
|
1894
|
+
return css;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
//#endregion
|
|
1898
|
+
//#region src/bundlers/shared/generator-css/user-css/user-layers.ts
|
|
1899
|
+
function splitUserCssLayerBlocks(source) {
|
|
1900
|
+
if (!source.includes("@layer")) return {
|
|
1901
|
+
layer: "",
|
|
1902
|
+
rest: source
|
|
1903
|
+
};
|
|
1904
|
+
try {
|
|
1905
|
+
const root = postcss.parse(source);
|
|
1906
|
+
const layerRoot = postcss.root();
|
|
1907
|
+
const restRoot = postcss.root();
|
|
1908
|
+
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1909
|
+
return {
|
|
1910
|
+
layer: layerRoot.toString(),
|
|
1911
|
+
rest: restRoot.toString()
|
|
1912
|
+
};
|
|
1913
|
+
} catch {
|
|
1914
|
+
return {
|
|
1915
|
+
layer: source,
|
|
1916
|
+
rest: ""
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
function hasUserCssLayerBlocks(source) {
|
|
1921
|
+
if (!source.includes("@layer")) return false;
|
|
1922
|
+
try {
|
|
1923
|
+
let hasLayerBlock = false;
|
|
1924
|
+
postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1925
|
+
if (node.nodes?.length) hasLayerBlock = true;
|
|
1926
|
+
});
|
|
1927
|
+
return hasLayerBlock;
|
|
1928
|
+
} catch {
|
|
1929
|
+
return true;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
function collectUserLayerSelectors(source) {
|
|
1933
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1934
|
+
try {
|
|
1935
|
+
postcss.parse(source).walkRules((rule) => {
|
|
1936
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1937
|
+
const normalized = selector.trim();
|
|
1938
|
+
if (normalized) selectors.add(normalized);
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
} catch {}
|
|
1942
|
+
return selectors;
|
|
1943
|
+
}
|
|
1944
|
+
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1945
|
+
if (selector === userLayerSelector) return true;
|
|
1946
|
+
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1947
|
+
const next = selector[userLayerSelector.length];
|
|
1948
|
+
return next === ":" || next === "[";
|
|
1949
|
+
}
|
|
1950
|
+
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1951
|
+
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1952
|
+
if (selectors.size === 0) return {
|
|
1953
|
+
layer: "",
|
|
1954
|
+
rest: css
|
|
1955
|
+
};
|
|
1956
|
+
try {
|
|
1957
|
+
const root = postcss.parse(css);
|
|
1958
|
+
const layerRoot = postcss.root();
|
|
1959
|
+
const selectorList = [...selectors];
|
|
1960
|
+
root.walkRules((rule) => {
|
|
1961
|
+
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1962
|
+
layerRoot.append(rule.clone());
|
|
1963
|
+
rule.remove();
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
return {
|
|
1967
|
+
layer: layerRoot.toString(),
|
|
1968
|
+
rest: root.toString()
|
|
1969
|
+
};
|
|
1970
|
+
} catch {
|
|
1971
|
+
return {
|
|
1972
|
+
layer: "",
|
|
1973
|
+
rest: css
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
function normalizeGeneratedSelector(selector) {
|
|
1978
|
+
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1979
|
+
}
|
|
1980
|
+
function collectApplyOnlySourceSelectors(source) {
|
|
1981
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1982
|
+
try {
|
|
1983
|
+
postcss.parse(source).walkRules((rule) => {
|
|
1984
|
+
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1985
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1986
|
+
const normalized = normalizeGeneratedSelector(selector);
|
|
1987
|
+
if (normalized) selectors.add(normalized);
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
} catch {}
|
|
1991
|
+
return selectors;
|
|
1992
|
+
}
|
|
1993
|
+
function hasOnlyApplyBackedSourceRules(source) {
|
|
1994
|
+
let hasApplyRule = false;
|
|
1995
|
+
let hasNonApplyRule = false;
|
|
1996
|
+
try {
|
|
1997
|
+
postcss.parse(source).walkRules((rule) => {
|
|
1998
|
+
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1999
|
+
else hasNonApplyRule = true;
|
|
2000
|
+
});
|
|
2001
|
+
} catch {
|
|
2002
|
+
return false;
|
|
2003
|
+
}
|
|
2004
|
+
return hasApplyRule && !hasNonApplyRule;
|
|
2005
|
+
}
|
|
2006
|
+
function removeCssComments(css) {
|
|
2007
|
+
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
2008
|
+
}
|
|
2009
|
+
function isEmptyCustomVariantBlock(rule) {
|
|
2010
|
+
if (rule.name !== "custom-variant") return false;
|
|
2011
|
+
if (!/^[\w-]+$/.test(rule.params.trim())) return false;
|
|
2012
|
+
if (rule.nodes === void 0) return true;
|
|
2013
|
+
return rule.nodes.every((node) => node.type === "comment");
|
|
2014
|
+
}
|
|
2015
|
+
//#endregion
|
|
2016
|
+
//#region src/bundlers/shared/generator-css/user-css/apply-only.ts
|
|
2017
|
+
function normalizeEmptyTailwindCustomVariants(css) {
|
|
2018
|
+
if (!css.includes("@custom-variant")) return css;
|
|
2019
|
+
try {
|
|
2020
|
+
const root = postcss.parse(css);
|
|
2021
|
+
let changed = false;
|
|
2022
|
+
root.walkAtRules("custom-variant", (rule) => {
|
|
2023
|
+
if (!isEmptyCustomVariantBlock(rule)) return;
|
|
2024
|
+
rule.remove();
|
|
2025
|
+
changed = true;
|
|
2026
|
+
});
|
|
2027
|
+
return changed ? root.toString() : css;
|
|
2028
|
+
} catch {
|
|
2029
|
+
return css;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
function filterApplyOnlyGeneratedCss(css, source, options = {}) {
|
|
2033
|
+
const selectors = collectApplyOnlySourceSelectors(source);
|
|
2034
|
+
if (selectors.size === 0) return css;
|
|
2035
|
+
const selectorList = [...selectors];
|
|
2036
|
+
const preserveVariables = options.preserveVariables !== false;
|
|
2037
|
+
try {
|
|
2038
|
+
const root = postcss.parse(css);
|
|
2039
|
+
root.walkRules((rule) => {
|
|
2040
|
+
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
2041
|
+
const normalized = normalizeGeneratedSelector(selector);
|
|
2042
|
+
return selectorList.some((sourceSelector) => {
|
|
2043
|
+
if (normalized === sourceSelector) return true;
|
|
2044
|
+
if (!normalized.startsWith(sourceSelector)) return false;
|
|
2045
|
+
const next = normalized[sourceSelector.length];
|
|
2046
|
+
return next === ":" || next === "[" || next === ".";
|
|
2047
|
+
});
|
|
2048
|
+
});
|
|
2049
|
+
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
2050
|
+
if (!isApplySelector && (!preserveVariables || !isVariableRule)) rule.remove();
|
|
2051
|
+
});
|
|
2052
|
+
root.walkAtRules((rule) => {
|
|
2053
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
2054
|
+
});
|
|
2055
|
+
const filteredCss = root.toString();
|
|
2056
|
+
return removeCssComments(options.preferScopedRules ? preferScopedGeneratedCssRules(filteredCss) : filteredCss).trim();
|
|
2057
|
+
} catch {
|
|
2058
|
+
return css;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
2062
|
+
return (target === "weapp" || target === "web") && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
2063
|
+
}
|
|
2064
|
+
//#endregion
|
|
2065
|
+
//#region src/bundlers/shared/generator-css/user-css/generated-cleanup.ts
|
|
2066
|
+
const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
|
|
2067
|
+
"config",
|
|
2068
|
+
"custom-variant",
|
|
2069
|
+
"plugin",
|
|
2070
|
+
"source",
|
|
1790
2071
|
"theme",
|
|
1791
2072
|
"utility",
|
|
1792
2073
|
"variant"
|
|
@@ -1885,6 +2166,8 @@ function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
|
1885
2166
|
return source;
|
|
1886
2167
|
}
|
|
1887
2168
|
}
|
|
2169
|
+
//#endregion
|
|
2170
|
+
//#region src/bundlers/shared/generator-css/user-css/at-rules.ts
|
|
1888
2171
|
function removeTailwindSourceMediaBlocks(source) {
|
|
1889
2172
|
let next = source;
|
|
1890
2173
|
let changed = false;
|
|
@@ -2041,6 +2324,8 @@ function removeTailwindApplyAtRules(source) {
|
|
|
2041
2324
|
return source;
|
|
2042
2325
|
}
|
|
2043
2326
|
}
|
|
2327
|
+
//#endregion
|
|
2328
|
+
//#region src/bundlers/shared/generator-css/user-css/source-fragments.ts
|
|
2044
2329
|
function removeTailwindV4GeneratorAtRules(source) {
|
|
2045
2330
|
try {
|
|
2046
2331
|
const root = postcss.parse(source);
|
|
@@ -2162,168 +2447,8 @@ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
|
2162
2447
|
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
2163
2448
|
}
|
|
2164
2449
|
}
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
layer: "",
|
|
2168
|
-
rest: source
|
|
2169
|
-
};
|
|
2170
|
-
try {
|
|
2171
|
-
const root = postcss.parse(source);
|
|
2172
|
-
const layerRoot = postcss.root();
|
|
2173
|
-
const restRoot = postcss.root();
|
|
2174
|
-
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
2175
|
-
return {
|
|
2176
|
-
layer: layerRoot.toString(),
|
|
2177
|
-
rest: restRoot.toString()
|
|
2178
|
-
};
|
|
2179
|
-
} catch {
|
|
2180
|
-
return {
|
|
2181
|
-
layer: source,
|
|
2182
|
-
rest: ""
|
|
2183
|
-
};
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
function hasUserCssLayerBlocks(source) {
|
|
2187
|
-
if (!source.includes("@layer")) return false;
|
|
2188
|
-
try {
|
|
2189
|
-
let hasLayerBlock = false;
|
|
2190
|
-
postcss.parse(source).walkAtRules("layer", (node) => {
|
|
2191
|
-
if (node.nodes?.length) hasLayerBlock = true;
|
|
2192
|
-
});
|
|
2193
|
-
return hasLayerBlock;
|
|
2194
|
-
} catch {
|
|
2195
|
-
return true;
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
function collectUserLayerSelectors(source) {
|
|
2199
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
2200
|
-
try {
|
|
2201
|
-
postcss.parse(source).walkRules((rule) => {
|
|
2202
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
2203
|
-
const normalized = selector.trim();
|
|
2204
|
-
if (normalized) selectors.add(normalized);
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
} catch {}
|
|
2208
|
-
return selectors;
|
|
2209
|
-
}
|
|
2210
|
-
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
2211
|
-
if (selector === userLayerSelector) return true;
|
|
2212
|
-
if (!selector.startsWith(userLayerSelector)) return false;
|
|
2213
|
-
const next = selector[userLayerSelector.length];
|
|
2214
|
-
return next === ":" || next === "[";
|
|
2215
|
-
}
|
|
2216
|
-
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
2217
|
-
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
2218
|
-
if (selectors.size === 0) return {
|
|
2219
|
-
layer: "",
|
|
2220
|
-
rest: css
|
|
2221
|
-
};
|
|
2222
|
-
try {
|
|
2223
|
-
const root = postcss.parse(css);
|
|
2224
|
-
const layerRoot = postcss.root();
|
|
2225
|
-
const selectorList = [...selectors];
|
|
2226
|
-
root.walkRules((rule) => {
|
|
2227
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
2228
|
-
layerRoot.append(rule.clone());
|
|
2229
|
-
rule.remove();
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
return {
|
|
2233
|
-
layer: layerRoot.toString(),
|
|
2234
|
-
rest: root.toString()
|
|
2235
|
-
};
|
|
2236
|
-
} catch {
|
|
2237
|
-
return {
|
|
2238
|
-
layer: "",
|
|
2239
|
-
rest: css
|
|
2240
|
-
};
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
function normalizeGeneratedSelector(selector) {
|
|
2244
|
-
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
2245
|
-
}
|
|
2246
|
-
function collectApplyOnlySourceSelectors(source) {
|
|
2247
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
2248
|
-
try {
|
|
2249
|
-
postcss.parse(source).walkRules((rule) => {
|
|
2250
|
-
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
2251
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
2252
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
2253
|
-
if (normalized) selectors.add(normalized);
|
|
2254
|
-
}
|
|
2255
|
-
});
|
|
2256
|
-
} catch {}
|
|
2257
|
-
return selectors;
|
|
2258
|
-
}
|
|
2259
|
-
function hasOnlyApplyBackedSourceRules(source) {
|
|
2260
|
-
let hasApplyRule = false;
|
|
2261
|
-
let hasNonApplyRule = false;
|
|
2262
|
-
try {
|
|
2263
|
-
postcss.parse(source).walkRules((rule) => {
|
|
2264
|
-
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
2265
|
-
else hasNonApplyRule = true;
|
|
2266
|
-
});
|
|
2267
|
-
} catch {
|
|
2268
|
-
return false;
|
|
2269
|
-
}
|
|
2270
|
-
return hasApplyRule && !hasNonApplyRule;
|
|
2271
|
-
}
|
|
2272
|
-
function removeCssComments(css) {
|
|
2273
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
2274
|
-
}
|
|
2275
|
-
function isEmptyCustomVariantBlock(rule) {
|
|
2276
|
-
if (rule.name !== "custom-variant") return false;
|
|
2277
|
-
if (!/^[\w-]+$/.test(rule.params.trim())) return false;
|
|
2278
|
-
if (rule.nodes === void 0) return true;
|
|
2279
|
-
return rule.nodes.every((node) => node.type === "comment");
|
|
2280
|
-
}
|
|
2281
|
-
function normalizeEmptyTailwindCustomVariants(css) {
|
|
2282
|
-
if (!css.includes("@custom-variant")) return css;
|
|
2283
|
-
try {
|
|
2284
|
-
const root = postcss.parse(css);
|
|
2285
|
-
let changed = false;
|
|
2286
|
-
root.walkAtRules("custom-variant", (rule) => {
|
|
2287
|
-
if (!isEmptyCustomVariantBlock(rule)) return;
|
|
2288
|
-
rule.remove();
|
|
2289
|
-
changed = true;
|
|
2290
|
-
});
|
|
2291
|
-
return changed ? root.toString() : css;
|
|
2292
|
-
} catch {
|
|
2293
|
-
return css;
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
function filterApplyOnlyGeneratedCss(css, source, options = {}) {
|
|
2297
|
-
const selectors = collectApplyOnlySourceSelectors(source);
|
|
2298
|
-
if (selectors.size === 0) return css;
|
|
2299
|
-
const selectorList = [...selectors];
|
|
2300
|
-
const preserveVariables = options.preserveVariables !== false;
|
|
2301
|
-
try {
|
|
2302
|
-
const root = postcss.parse(css);
|
|
2303
|
-
root.walkRules((rule) => {
|
|
2304
|
-
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
2305
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
2306
|
-
return selectorList.some((sourceSelector) => {
|
|
2307
|
-
if (normalized === sourceSelector) return true;
|
|
2308
|
-
if (!normalized.startsWith(sourceSelector)) return false;
|
|
2309
|
-
const next = normalized[sourceSelector.length];
|
|
2310
|
-
return next === ":" || next === "[" || next === ".";
|
|
2311
|
-
});
|
|
2312
|
-
});
|
|
2313
|
-
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
2314
|
-
if (!isApplySelector && (!preserveVariables || !isVariableRule)) rule.remove();
|
|
2315
|
-
});
|
|
2316
|
-
root.walkAtRules((rule) => {
|
|
2317
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
2318
|
-
});
|
|
2319
|
-
return removeCssComments(root.toString()).trim();
|
|
2320
|
-
} catch {
|
|
2321
|
-
return css;
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
2325
|
-
return (target === "weapp" || target === "web") && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
2326
|
-
}
|
|
2450
|
+
//#endregion
|
|
2451
|
+
//#region src/bundlers/shared/generator-css/user-css/transform.ts
|
|
2327
2452
|
async function transformGeneratorUserCss(source, options) {
|
|
2328
2453
|
if (source.trim().length === 0) return "";
|
|
2329
2454
|
if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(unwrapMiniProgramCascadeLayers(removeProcessedMiniProgramUnsupportedCss(source, {
|
|
@@ -2939,4 +3064,4 @@ async function createWeappTailwindcssGeneratorFromRuntime(tailwindRuntime) {
|
|
|
2939
3064
|
return createWeappTailwindcssGenerator(await resolveTailwindSourceFromRuntime(tailwindRuntime));
|
|
2940
3065
|
}
|
|
2941
3066
|
//#endregion
|
|
2942
|
-
export {
|
|
3067
|
+
export { normalizeTailwindConfigDirectives as $, isCommentOnlyCss as A, transformTailwindV4CssByTarget as At, removeTailwindV4GeneratedUserCssArtifacts as B, findWorkspaceRoot as C, isFileMatchedByTailwindSourceEntries as Ct, normalizeStringListOption as D, resolveSourceScanPath as Dt, resolveTailwindcssOptions as E, resolveCssSourceEntries as Et, finalizeMiniProgramCss as F, loadTailwindV4DesignSystem as Ft, hasUserCssLayerBlocks as G, normalizeEmptyTailwindCustomVariants as H, hasMiniProgramCssSpecificityPlaceholders as I, resolveValidTailwindV4Candidates$1 as It, hasLocalCssImport as J, splitUserCssLayerBlocks as K, pruneMiniProgramGeneratedCss as L, removeTailwindV4GeneratorAtRules as M, resolveCssMacroTailwindV4Source as Mt, stripTailwindSourceMediaFragments as N, getTailwindV4IncrementalGenerateCacheStats as Nt, resolveBooleanObjectOption as O, resolveTailwindV4CssSourceBase as Ot, stripUnmatchedTailwindSourceMediaCloseFragments as P, filterUnsupportedMiniProgramTailwindV4Candidates as Pt, hasTailwindSourceDirectives as Q, removeUnsupportedMiniProgramAtRules as R, findWorkspacePackageDir as S, expandTailwindSourceEntries as St, normalizeTailwindcssRuntimeOptions as T, parseConfigParam as Tt, shouldFilterApplyOnlyGeneratedCss as U, filterApplyOnlyGeneratedCss as V, extractGeneratedCssForUserLayerSelectors as W, hasTailwindNonRootGenerationDirectives as X, hasTailwindApplyDirective as Y, hasTailwindRootDirectives as Z, groupCssEntriesByBase as _, prependConfigDirective as _t, resolveGeneratorRuntimeBranch as a, GENERATOR_PLACEHOLDER_MARKER_RE as at, normalizeCssEntries as b, FULL_SOURCE_SCAN_PATTERN as bt, shouldUseNativeAppCssBranch as c, hasTailwindGeneratedCss as ct, resolveTailwindV4SourceFromRuntime as d, splitTailwindGeneratedCssByBanner as dt, normalizeTailwindSourceDirectives as et, resolveTailwindV4SourceFromRuntimeOptions as f, splitTailwindV4GeneratedCssBySourceOrder as ft, upsertTailwindV4CssSource as g, normalizeConfigDirective as gt, hasConfiguredTailwindV4CssRoots as h, stripTailwindBanners as ht, normalizeWeappTailwindcssGeneratorOptions as i, resolveCssEntrySource as it, removeMiniProgramHoverSelectors as j, transformTailwindV4CssToWeapp as jt, transformGeneratorUserCss as k, toPosixPath as kt, resolveUniUtsPlatform as l, hasTailwindGeneratedCssMarkers as lt, filterTailwindV4CssSourceRoots as m, stripTailwindBanner as mt, createWeappTailwindcssGeneratorFromRuntime as n, parseImportRequest as nt, resolveRuntimeBranch as o, VITE_MARKER_RE as ot, resolveTailwindV4SourceOptionsFromRuntime as p, stripGeneratorPlaceholderMarkers as pt, preferScopedGeneratedCssRules as q, resolveTailwindSourceFromRuntime as r, removeTailwindSourceDirectives as rt, shouldUseMiniProgramCssBranch as s, createCssAppend as st, createWeappTailwindcssGenerator as t, normalizeTailwindSourceForGenerator as tt, resolveTailwindV4Source$1 as u, splitGeneratorPlaceholderCssBySourceOrder as ut, guessBasedirFromEntries as v, createTailwindV4Engine$1 as vt, normalizeExtendLengthUnits as w, normalizeLegacyContentEntries as wt, findNearestPackageRoot as x, createTailwindSourceEntryMatcher as xt, isTailwindV4CssEntry as y, FULL_SOURCE_SCAN_EXTENSION_RE as yt, stripMiniProgramCssSpecificityPlaceholders as z };
|