weapp-tailwindcss 5.0.6 → 5.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-state-CdNXQl-o.mjs → bundle-state-5FtFktJr.mjs} +2 -1
- package/dist/{bundle-state-CFgzVHFP.js → bundle-state-cHwTyrOS.js} +2 -1
- package/dist/bundlers/gulp/index.d.ts +3 -4
- package/dist/bundlers/gulp/module-graph.d.ts +2 -0
- package/dist/bundlers/gulp/runtime-snapshot.d.ts +5 -0
- package/dist/bundlers/gulp/vinyl-transform.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/css-source-trace.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +56 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +27 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +26 -0
- package/dist/bundlers/shared/generator-css/validate.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +4 -32
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +14 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +11 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/style-matching.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +68 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -62
- package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +4 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +2 -0
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +13 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +17 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +2 -0
- package/dist/bundlers/vite/source-candidates/scan-root.d.ts +10 -0
- package/dist/bundlers/vite/source-candidates/script.d.ts +7 -0
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +1 -0
- package/dist/bundlers/vite/source-candidates.d.ts +8 -3
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +20 -0
- package/dist/bundlers/vite/source-scan/dependencies.d.ts +2 -0
- package/dist/bundlers/vite/source-scan.d.ts +2 -12
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -20
- package/dist/cli.js +71 -69
- package/dist/cli.mjs +71 -69
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{defaults-BPUuNYcD.js → defaults-Boc26eel.js} +1 -0
- package/dist/{defaults-8xrgzxFY.mjs → defaults-DH0ZQRhy.mjs} +1 -0
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-C56PJYxA.js → generator-C--TrAod.js} +1 -1
- package/dist/{generator-Bgn4m8An.mjs → generator-DnwUQOXB.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp-5Tan5bHG.js +473 -0
- package/dist/gulp-B22YSGU_.mjs +463 -0
- package/dist/gulp.js +4 -414
- package/dist/gulp.mjs +1 -406
- package/dist/{incremental-runtime-class-set-Bmzdjlk0.js → hmr-timing-CscCNKb9.js} +1205 -449
- package/dist/{incremental-runtime-class-set-BEYHQkZc.mjs → hmr-timing-DK-mine6.mjs} +1169 -467
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{postcss-BgINK7Nm.mjs → postcss-CjWuDZwL.mjs} +4 -4
- package/dist/{postcss-B7QNe78h.js → postcss-R5pDVHUy.js} +7 -7
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-CyPbGn38.js → precheck-B8y6tDvG.js} +19 -5
- package/dist/{precheck-Copn2SqE.mjs → precheck-CcxTR7E_.mjs} +19 -5
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/tailwindcss/source-scan/inline-source.d.ts +7 -0
- package/dist/tailwindcss/source-scan.d.ts +2 -7
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +3 -0
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +10 -0
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +6 -0
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
- package/dist/{tailwindcss-C0Zgo3Es.mjs → tailwindcss-0DaftXcU.mjs} +2 -2
- package/dist/{tailwindcss-Tw6CSVHL.js → tailwindcss-DbZ4o4m_.js} +2 -2
- package/dist/{transform-DgCFGtQR.mjs → transform-DRyWUN5X.mjs} +11 -2
- package/dist/{transform-95ivJthq.js → transform-DiW_u3eD.js} +11 -2
- package/dist/types/typedoc-tailwindcss-patch.d.ts +4 -2
- package/dist/types/user-defined-options/general.d.ts +5 -0
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/harmony.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +16 -0
- package/dist/uni-app-x/style-asset.d.ts +20 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite.d.ts +1 -0
- package/dist/{v3-engine-Ji6AXPh2.mjs → v3-engine-ArQVHEau.mjs} +786 -699
- package/dist/{v3-engine-6FVAcrZl.js → v3-engine-DdlvXpID.js} +788 -701
- package/dist/{vite-Bw6LOXvf.js → vite-C_IUnDBy.js} +1797 -386
- package/dist/{vite-ChZ2cbn4.mjs → vite-_iUhzc4t.mjs} +1779 -369
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +1148 -987
- package/dist/{webpack-CMJ7iqN7.mjs → webpack-CqnI4Ymw.mjs} +104 -37
- package/dist/{webpack-nn3P8_S_.js → webpack-KLoTb5Dr.js} +113 -45
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -5
- package/dist/source-candidates-BODCmzz5.mjs +0 -355
- package/dist/source-candidates-Caf2GDvx.js +0 -374
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
6
|
-
let
|
|
2
|
+
const require_v3_engine = require("./v3-engine-DdlvXpID.js");
|
|
3
|
+
const require_generator = require("./generator-C--TrAod.js");
|
|
4
|
+
const require_precheck = require("./precheck-B8y6tDvG.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-DbZ4o4m_.js");
|
|
6
|
+
let node_module = require("node:module");
|
|
7
7
|
let postcss = require("postcss");
|
|
8
8
|
postcss = require_chunk.__toESM(postcss);
|
|
9
9
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
10
10
|
let node_process = require("node:process");
|
|
11
11
|
node_process = require_chunk.__toESM(node_process);
|
|
12
|
+
let node_fs = require("node:fs");
|
|
12
13
|
let node_path = require("node:path");
|
|
13
14
|
node_path = require_chunk.__toESM(node_path);
|
|
15
|
+
let node_fs_promises = require("node:fs/promises");
|
|
14
16
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
17
|
+
let _weapp_core_escape = require("@weapp-core/escape");
|
|
15
18
|
//#region src/bundlers/shared/cache.ts
|
|
16
19
|
async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSource, hash, readCache, applyResult, transform, onCacheHit }) {
|
|
17
20
|
let cacheHit = false;
|
|
@@ -31,6 +34,199 @@ async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSourc
|
|
|
31
34
|
if (!cacheHit) await applyResult(result, { cacheHit: false });
|
|
32
35
|
}
|
|
33
36
|
//#endregion
|
|
37
|
+
//#region src/bundlers/shared/css-source-trace.ts
|
|
38
|
+
const CSS_SOURCE_TRACE_COMMENT_RE = /^\s*tokens:\s/;
|
|
39
|
+
const TAILWIND_GENERATED_CONTAINER_TRACE_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
|
|
40
|
+
function normalizeSelectorTokenCandidate(candidate) {
|
|
41
|
+
return candidate.replace(/(?<!\\)\\:/g, ":").replace(/(?<!\\)\\\//g, "/");
|
|
42
|
+
}
|
|
43
|
+
function normalizeSourcePath(source, root) {
|
|
44
|
+
const resolvedRoot = node_path.default.resolve(root);
|
|
45
|
+
const resolvedSource = node_path.default.resolve(source);
|
|
46
|
+
const relative = node_path.default.relative(resolvedRoot, resolvedSource);
|
|
47
|
+
if (relative && !relative.startsWith("..") && !node_path.default.isAbsolute(relative)) return relative.split(node_path.default.sep).join("/");
|
|
48
|
+
return source.split(node_path.default.sep).join("/");
|
|
49
|
+
}
|
|
50
|
+
function getSourceTraceRoot(opts) {
|
|
51
|
+
const configured = opts.cssSourceTrace;
|
|
52
|
+
if (configured && typeof configured === "object" && configured.root) return configured.root;
|
|
53
|
+
return opts.tailwindcssBasedir ?? node_process.default.cwd();
|
|
54
|
+
}
|
|
55
|
+
function isCssSourceTraceEnabled(opts) {
|
|
56
|
+
return opts.cssSourceTrace === true || typeof opts.cssSourceTrace === "object" && opts.cssSourceTrace !== null;
|
|
57
|
+
}
|
|
58
|
+
function createCssTokenSourceMap(sourcesByToken, opts) {
|
|
59
|
+
const root = getSourceTraceRoot(opts);
|
|
60
|
+
const tokenSources = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const [token, sources] of [...sourcesByToken.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
62
|
+
const source = {
|
|
63
|
+
token,
|
|
64
|
+
sources: [...sources].map((file) => normalizeSourcePath(file, root)).sort()
|
|
65
|
+
};
|
|
66
|
+
tokenSources.set(token, source);
|
|
67
|
+
const escaped = require_precheck.replaceWxml(token, { escapeMap: opts.escapeMap });
|
|
68
|
+
tokenSources.set(escaped, source);
|
|
69
|
+
tokenSources.set(escaped.replaceAll("\\", ""), source);
|
|
70
|
+
}
|
|
71
|
+
return tokenSources;
|
|
72
|
+
}
|
|
73
|
+
function createCssSourceTraceCacheSignature(tokenSources, opts) {
|
|
74
|
+
if (!isCssSourceTraceEnabled(opts)) return "css-source-trace:0";
|
|
75
|
+
if (!tokenSources?.size) return "css-source-trace:1:empty";
|
|
76
|
+
return `css-source-trace:1:${[...tokenSources.values()].map(({ token, sources }) => `${token}<=${sources.join(",")}`).sort().join("|")}`;
|
|
77
|
+
}
|
|
78
|
+
function getTokenSource(tokenSources, token) {
|
|
79
|
+
return tokenSources.get(token);
|
|
80
|
+
}
|
|
81
|
+
function collectRuleSourceTokens(rule, tokenSources) {
|
|
82
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
83
|
+
for (const selector of rule.selectors) {
|
|
84
|
+
const classMatches = selector.matchAll(/\.((?:\\.|[^\s.#:[{>,])*)/g);
|
|
85
|
+
for (const match of classMatches) {
|
|
86
|
+
const rawCandidate = match[1];
|
|
87
|
+
if (!rawCandidate) continue;
|
|
88
|
+
const candidates = [normalizeSelectorTokenCandidate(rawCandidate), rawCandidate];
|
|
89
|
+
for (const candidate of candidates) {
|
|
90
|
+
const source = getTokenSource(tokenSources, candidate);
|
|
91
|
+
if (!source) continue;
|
|
92
|
+
tokens.set(source.token, source);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return tokens;
|
|
98
|
+
}
|
|
99
|
+
function removeTracedTailwindGeneratedContainerRules(root) {
|
|
100
|
+
root.walkRules((rule) => {
|
|
101
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return;
|
|
102
|
+
const previous = rule.prev();
|
|
103
|
+
if (previous?.type !== "comment" || !TAILWIND_GENERATED_CONTAINER_TRACE_COMMENT_RE.test(previous.text)) return;
|
|
104
|
+
previous.remove();
|
|
105
|
+
rule.remove();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function annotateCssSourceTrace(css, options) {
|
|
109
|
+
if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
|
|
110
|
+
try {
|
|
111
|
+
const root = postcss.default.parse(css);
|
|
112
|
+
root.walkComments((comment) => {
|
|
113
|
+
if (CSS_SOURCE_TRACE_COMMENT_RE.test(comment.text)) comment.remove();
|
|
114
|
+
});
|
|
115
|
+
root.walkRules((rule) => {
|
|
116
|
+
const tokens = collectRuleSourceTokens(rule, options.tokenSources);
|
|
117
|
+
if (tokens.size === 0 || !rule.parent) return;
|
|
118
|
+
const lines = [...tokens.values()].map(({ token, sources }) => {
|
|
119
|
+
return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
|
|
120
|
+
});
|
|
121
|
+
const comment = postcss.default.comment({ text: `tokens: ${lines.join(" | ")}` });
|
|
122
|
+
if (rule.raws.before !== void 0) comment.raws.before = rule.raws.before;
|
|
123
|
+
rule.raws.before = "\n";
|
|
124
|
+
rule.parent.insertBefore(rule, comment);
|
|
125
|
+
});
|
|
126
|
+
removeTracedTailwindGeneratedContainerRules(root);
|
|
127
|
+
return root.toString();
|
|
128
|
+
} catch {
|
|
129
|
+
return css;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/bundlers/shared/generator-css/generation-helpers.ts
|
|
134
|
+
function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
|
|
135
|
+
if (target !== "weapp") return css;
|
|
136
|
+
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
137
|
+
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
138
|
+
isTailwindcssV4: majorVersion === 4,
|
|
139
|
+
preservePseudoContentInit: majorVersion === 3
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
143
|
+
if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return false;
|
|
144
|
+
if (!options.isolateCurrentCssCandidates) return true;
|
|
145
|
+
return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
146
|
+
}
|
|
147
|
+
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
148
|
+
if (options.isolateCssSource && options.currentCssCandidates?.length) return new Set([...scopedRuntime, ...options.currentCssCandidates]);
|
|
149
|
+
if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk || options.matchedCssSourceFile || options.isolateCssSource && scopedRuntime.size === 0) return scopedRuntime;
|
|
150
|
+
return new Set([...scopedRuntime, ...runtime]);
|
|
151
|
+
}
|
|
152
|
+
function shouldIsolateScopedCssSource(source, sourceEntries) {
|
|
153
|
+
return Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile) || sourceEntries !== void 0 && sourceEntries.length > 0;
|
|
154
|
+
}
|
|
155
|
+
function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
|
|
156
|
+
return majorVersion === 4 && !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(options.rawSource) && !require_v3_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
157
|
+
}
|
|
158
|
+
function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
|
|
159
|
+
if (majorVersion !== 4) return false;
|
|
160
|
+
if (target === "web") return true;
|
|
161
|
+
if (isolateCssSource) return false;
|
|
162
|
+
return generatorRuntime.size === 0;
|
|
163
|
+
}
|
|
164
|
+
function shouldAppendWebBundleCssFallback(target, options) {
|
|
165
|
+
return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
|
|
166
|
+
}
|
|
167
|
+
function isEmptyCssSourceOrderParts(parts) {
|
|
168
|
+
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
169
|
+
}
|
|
170
|
+
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
171
|
+
const preflightStyleOptions = {
|
|
172
|
+
cssPreflight: opts.cssPreflight,
|
|
173
|
+
cssPreflightRange: opts.cssPreflightRange
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
...require_precheck.resolveStyleOptionsFromContext(opts),
|
|
177
|
+
atRules: opts.atRules,
|
|
178
|
+
uniAppXCssTarget: opts.uniAppXCssTarget,
|
|
179
|
+
uniAppXUnsupported: opts.uniAppXUnsupported,
|
|
180
|
+
...cssHandlerOptions,
|
|
181
|
+
...preflightStyleOptions,
|
|
182
|
+
...generatorStyleOptions
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function createCssSourceOrderAppend$1(base, extra) {
|
|
186
|
+
if (!base) return extra;
|
|
187
|
+
if (!extra) return base;
|
|
188
|
+
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
189
|
+
return `${base}\n${extra}`;
|
|
190
|
+
}
|
|
191
|
+
function shouldFinalizeMarkedUserLayerComponentsCss(file) {
|
|
192
|
+
return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
|
|
193
|
+
}
|
|
194
|
+
function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
195
|
+
const placeholderParts = require_v3_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
|
|
196
|
+
if (placeholderParts) return placeholderParts;
|
|
197
|
+
const exactParts = require_v3_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
|
|
198
|
+
if (exactParts) return exactParts;
|
|
199
|
+
return require_v3_engine.splitTailwindGeneratedCssByBanner(rawSource);
|
|
200
|
+
}
|
|
201
|
+
function shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, options) {
|
|
202
|
+
const hasApplyDirectives = require_v3_engine.hasTailwindApplyDirective(options.rawSource);
|
|
203
|
+
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || majorVersion === 4 && hasApplyDirectives || cssHandlerOptions.isMainChunk;
|
|
204
|
+
}
|
|
205
|
+
function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
|
|
206
|
+
return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
|
|
207
|
+
}
|
|
208
|
+
function mergeGeneratorResults(generatedResults) {
|
|
209
|
+
const firstGenerated = generatedResults[0];
|
|
210
|
+
if (!firstGenerated) return;
|
|
211
|
+
if (generatedResults.length === 1) return firstGenerated;
|
|
212
|
+
const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
|
|
213
|
+
const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
|
|
214
|
+
return {
|
|
215
|
+
...firstGenerated,
|
|
216
|
+
css: generatedResults.map((item) => item.css).join("\n"),
|
|
217
|
+
rawCss: generatedResults.map((item) => item.rawCss).join("\n"),
|
|
218
|
+
incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
|
|
219
|
+
incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
|
|
220
|
+
classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
|
|
221
|
+
dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
|
|
222
|
+
sources: generatedResults.flatMap((item) => item.sources)
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const SUPPORTED_GENERATOR_MAJOR_VERSIONS$1 = new Set([3, 4]);
|
|
226
|
+
function isSupportedGeneratorMajorVersion(majorVersion) {
|
|
227
|
+
return SUPPORTED_GENERATOR_MAJOR_VERSIONS$1.has(majorVersion ?? 0);
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
34
230
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
35
231
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
36
232
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -267,13 +463,6 @@ function isPathWithinRoot$1(file, root) {
|
|
|
267
463
|
const relative = node_path.default.relative(root, file);
|
|
268
464
|
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
269
465
|
}
|
|
270
|
-
function countCommonSuffixSegments(a, b) {
|
|
271
|
-
const aSegments = a.split("/").filter(Boolean);
|
|
272
|
-
const bSegments = b.split("/").filter(Boolean);
|
|
273
|
-
let count = 0;
|
|
274
|
-
while (count < aSegments.length && count < bSegments.length && aSegments[aSegments.length - 1 - count] === bSegments[bSegments.length - 1 - count]) count++;
|
|
275
|
-
return count;
|
|
276
|
-
}
|
|
277
466
|
function collectOutputMatchBases(file, sourceOptions) {
|
|
278
467
|
const normalizedFile = file.replace(/[?#].*$/, "");
|
|
279
468
|
const roots = [
|
|
@@ -308,7 +497,7 @@ function isMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
|
|
|
308
497
|
const normalizedRoot = node_path.default.resolve(root);
|
|
309
498
|
if (isPathWithinRoot$1(normalizedSourceFile, normalizedRoot)) addSourceBase(node_path.default.relative(normalizedRoot, normalizedSourceFile));
|
|
310
499
|
}
|
|
311
|
-
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)
|
|
500
|
+
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
|
|
312
501
|
return false;
|
|
313
502
|
}
|
|
314
503
|
function scoreMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
|
|
@@ -326,13 +515,9 @@ function scoreMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
|
|
|
326
515
|
if (isPathWithinRoot$1(normalizedSourceFile, normalizedRoot)) addSourceBase(node_path.default.relative(normalizedRoot, normalizedSourceFile));
|
|
327
516
|
}
|
|
328
517
|
let bestScore = 0;
|
|
329
|
-
for (const outputBase of outputBases) for (const sourceBase of sourceBases)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
333
|
-
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
334
|
-
else if (commonSuffixSegments >= 2) bestScore = Math.max(bestScore, 100 + commonSuffixSegments);
|
|
335
|
-
}
|
|
518
|
+
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
|
|
519
|
+
else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
520
|
+
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
336
521
|
return bestScore;
|
|
337
522
|
}
|
|
338
523
|
function collectMatchedConfiguredSourceFiles(file, sourceOptions) {
|
|
@@ -491,7 +676,7 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
|
491
676
|
return true;
|
|
492
677
|
}
|
|
493
678
|
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
494
|
-
return rawSource.includes("@apply") || require_v3_engine.hasTailwindGeneratedCss(rawSource) || require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
679
|
+
return rawSource.includes("@apply") || require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindGeneratedCss(rawSource) || require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
495
680
|
}
|
|
496
681
|
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
497
682
|
return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
@@ -536,17 +721,6 @@ function collectCssSourceMatchBases(file, roots) {
|
|
|
536
721
|
} else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
|
|
537
722
|
return bases;
|
|
538
723
|
}
|
|
539
|
-
function hasMatchingCssSourceBase(outputBases, sourceBases) {
|
|
540
|
-
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
function isMatchingTailwindV4CssSourceFile(file, cssSourceFile, sourceOptions) {
|
|
544
|
-
return hasMatchingCssSourceBase(collectCssSourceMatchBases(file, [
|
|
545
|
-
sourceOptions.outputRoot,
|
|
546
|
-
sourceOptions.projectRoot,
|
|
547
|
-
sourceOptions.cwd
|
|
548
|
-
]), collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]));
|
|
549
|
-
}
|
|
550
724
|
function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
|
|
551
725
|
const outputBases = collectCssSourceMatchBases(file, [
|
|
552
726
|
sourceOptions.outputRoot,
|
|
@@ -633,12 +807,29 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
633
807
|
if (!cssSources?.length) return;
|
|
634
808
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
635
809
|
const sourceFile = resolvePostcssSourceFile(cssHandlerOptions);
|
|
636
|
-
const
|
|
637
|
-
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return
|
|
638
|
-
if (sourceFile && typeof cssSource.file === "string" && node_path.default.resolve(sourceFile) === node_path.default.resolve(cssSource.file)) return
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
810
|
+
const matches = cssSources.map((cssSource, index) => {
|
|
811
|
+
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
|
|
812
|
+
if (sourceFile && typeof cssSource.file === "string" && node_path.default.resolve(sourceFile) === node_path.default.resolve(cssSource.file)) return {
|
|
813
|
+
cssSource,
|
|
814
|
+
index,
|
|
815
|
+
score: 1e6
|
|
816
|
+
};
|
|
817
|
+
if (typeof cssSource.file === "string") {
|
|
818
|
+
const pathScore = scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions);
|
|
819
|
+
if (pathScore > 0) return {
|
|
820
|
+
cssSource,
|
|
821
|
+
index,
|
|
822
|
+
score: pathScore
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
if (normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource) return {
|
|
826
|
+
cssSource,
|
|
827
|
+
index,
|
|
828
|
+
score: 1
|
|
829
|
+
};
|
|
830
|
+
}).filter((match) => Boolean(match)).sort((a, b) => b.score - a.score || a.index - b.index);
|
|
831
|
+
const bestScore = matches[0]?.score;
|
|
832
|
+
const matchingSource = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssSource : void 0;
|
|
642
833
|
if (!matchingSource) return;
|
|
643
834
|
return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, { matched: true });
|
|
644
835
|
}
|
|
@@ -710,7 +901,10 @@ function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
|
710
901
|
async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
|
|
711
902
|
if (!resolvedEntrySource) return;
|
|
712
903
|
const resolvedSourceOptions = require_v3_engine.omitUndefined(sourceOptions);
|
|
713
|
-
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file,
|
|
904
|
+
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
|
|
905
|
+
...resolvedSourceOptions,
|
|
906
|
+
sourceFile: resolvedEntrySource.file
|
|
907
|
+
});
|
|
714
908
|
const css = createTailwindV4ApplyReferenceSource(require_v3_engine.normalizeConfigDirective(require_v3_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
715
909
|
return withMatchedSourceSideMetadata(await require_v3_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
716
910
|
base: resolvedEntrySource.base,
|
|
@@ -741,7 +935,25 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
|
741
935
|
}
|
|
742
936
|
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
743
937
|
if (!require_v3_engine.hasTailwindApplyDirective(css) || require_v3_engine.hasTailwindRootDirectives(css)) return css;
|
|
744
|
-
|
|
938
|
+
const utilities = collectTailwindApplyUtilities(css);
|
|
939
|
+
return [
|
|
940
|
+
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
941
|
+
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
942
|
+
css
|
|
943
|
+
].filter(Boolean).join("\n");
|
|
944
|
+
}
|
|
945
|
+
function collectTailwindApplyUtilities(css) {
|
|
946
|
+
let root;
|
|
947
|
+
try {
|
|
948
|
+
root = postcss.default.parse(css);
|
|
949
|
+
} catch {
|
|
950
|
+
return [];
|
|
951
|
+
}
|
|
952
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
953
|
+
root.walkAtRules("apply", (rule) => {
|
|
954
|
+
for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
955
|
+
});
|
|
956
|
+
return [...utilities].sort();
|
|
745
957
|
}
|
|
746
958
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
747
959
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
@@ -854,11 +1066,15 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
854
1066
|
return resolved ? [resolved] : [];
|
|
855
1067
|
}
|
|
856
1068
|
const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
|
|
1069
|
+
if (matchedCssEntrySource) return [generatorOptions?.config ? {
|
|
1070
|
+
...matchedCssEntrySource,
|
|
1071
|
+
css: require_v3_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
|
|
1072
|
+
} : matchedCssEntrySource];
|
|
1073
|
+
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource((shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions.cssEntries?.length ?? 0) <= 1) && canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1074
|
+
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
857
1075
|
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
858
1076
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
859
|
-
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource((shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions.cssEntries?.length ?? 0) <= 1) && canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
860
1077
|
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
|
|
861
|
-
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
862
1078
|
if (preferredCssEntrySource) return [generatorOptions?.config ? {
|
|
863
1079
|
...preferredCssEntrySource,
|
|
864
1080
|
css: require_v3_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -1036,6 +1252,27 @@ function resolveLegacyCompatCssSource(rawSource) {
|
|
|
1036
1252
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1037
1253
|
return resolved;
|
|
1038
1254
|
}
|
|
1255
|
+
function removeMiniProgramContainerCompatCss(css) {
|
|
1256
|
+
try {
|
|
1257
|
+
const root = postcss.default.parse(css);
|
|
1258
|
+
let removed = false;
|
|
1259
|
+
root.walkRules((rule) => {
|
|
1260
|
+
if (rule.selectors?.length === 1 && rule.selectors[0] === ".container") {
|
|
1261
|
+
rule.remove();
|
|
1262
|
+
removed = true;
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
root.walkAtRules((atRule) => {
|
|
1266
|
+
if (atRule.nodes && atRule.nodes.length === 0) {
|
|
1267
|
+
atRule.remove();
|
|
1268
|
+
removed = true;
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
return removed ? root.toString() : css;
|
|
1272
|
+
} catch {
|
|
1273
|
+
return css;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1039
1276
|
function hasContainerConfigToken(rawSource) {
|
|
1040
1277
|
return rawSource.includes("@config") && /\bcontainer\b/.test(rawSource);
|
|
1041
1278
|
}
|
|
@@ -1064,7 +1301,8 @@ function hasConfiguredContainerCompatSources(sources) {
|
|
|
1064
1301
|
return sources.some((source) => hasConfiguredContainerCompatSource(source));
|
|
1065
1302
|
}
|
|
1066
1303
|
async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
|
|
1067
|
-
const
|
|
1304
|
+
const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
|
|
1305
|
+
const compatSource = removeGeneratedSelectorCompatCss(generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource, css);
|
|
1068
1306
|
if (compatSource.trim().length === 0) return css;
|
|
1069
1307
|
if (generatorTarget !== "weapp") return require_v3_engine.createCssAppend(css, compatSource);
|
|
1070
1308
|
const styleOptions = {
|
|
@@ -1082,6 +1320,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
1082
1320
|
return require_v3_engine.createCssAppend(css, cleanedCompatCss);
|
|
1083
1321
|
}
|
|
1084
1322
|
async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
|
|
1323
|
+
if (generatorTarget === "weapp") return css;
|
|
1085
1324
|
const compatSource = resolveLegacyCompatCssSource(rawSource);
|
|
1086
1325
|
const shouldAppendContainer = runtime.has("container") || hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) || configuredContainerCompat || collectGeneratedSelectors(compatSource).has(".container");
|
|
1087
1326
|
if (generatorTarget !== "weapp" || !shouldAppendContainer || collectGeneratedSelectors(css).has(".container")) return css;
|
|
@@ -1144,128 +1383,97 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
1144
1383
|
}
|
|
1145
1384
|
}
|
|
1146
1385
|
//#endregion
|
|
1147
|
-
//#region src/bundlers/shared/generator-css/
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
const UTILITY_LAYER_INSERTION_RES = [
|
|
1151
|
-
/(^|\n)\.(?:fixed|absolute|relative|sticky|static)\s*\{/,
|
|
1152
|
-
/(^|\n)\.(?:block|inline-block|inline|flex|inline-flex|grid|hidden)\s*\{/,
|
|
1153
|
-
/(^|\n)\.(?:m|mx|my|mt|mr|mb|ml|p|px|py|pt|pr|pb|pl)-/,
|
|
1154
|
-
/(^|\n)\.(?:w|h|min-w|min-h|max-w|max-h)-/,
|
|
1155
|
-
/(^|\n)\.(?:bg|text|border|rounded|shadow|opacity|transition|transform|translate|scale|rotate|gap|items|justify|content)-/
|
|
1156
|
-
];
|
|
1157
|
-
function appendCss(base, extra) {
|
|
1386
|
+
//#region src/bundlers/shared/generator-css/local-imports.ts
|
|
1387
|
+
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
1388
|
+
function createCssSourceOrderAppend(base, extra) {
|
|
1158
1389
|
if (!base) return extra;
|
|
1159
1390
|
if (!extra) return base;
|
|
1160
1391
|
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
1161
1392
|
return `${base}\n${extra}`;
|
|
1162
1393
|
}
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1165
|
-
if (!trimmed) return css;
|
|
1166
|
-
const index = css.indexOf(trimmed);
|
|
1167
|
-
if (index === -1) return css;
|
|
1168
|
-
return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
|
|
1394
|
+
function isLocalImportRequest(request) {
|
|
1395
|
+
return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
|
|
1169
1396
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1397
|
+
function isPureLocalCssImportWrapper(css) {
|
|
1398
|
+
let hasImport = false;
|
|
1172
1399
|
try {
|
|
1173
|
-
postcss.default.parse(css)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1400
|
+
const root = postcss.default.parse(css);
|
|
1401
|
+
for (const node of root.nodes) {
|
|
1402
|
+
if (node.type === "comment") continue;
|
|
1403
|
+
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
1404
|
+
const request = require_v3_engine.parseImportRequest(node.params);
|
|
1405
|
+
if (!request || !isLocalImportRequest(request)) return false;
|
|
1406
|
+
hasImport = true;
|
|
1407
|
+
}
|
|
1408
|
+
} catch {
|
|
1409
|
+
return false;
|
|
1410
|
+
}
|
|
1411
|
+
return hasImport;
|
|
1181
1412
|
}
|
|
1182
|
-
function
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1413
|
+
function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
1414
|
+
let hasLocalImport = false;
|
|
1415
|
+
let hasTailwindDirective = false;
|
|
1416
|
+
try {
|
|
1417
|
+
const root = postcss.default.parse(css);
|
|
1418
|
+
for (const node of root.nodes) {
|
|
1419
|
+
if (node.type === "comment") continue;
|
|
1420
|
+
if (node.type === "atrule" && node.name === "import") {
|
|
1421
|
+
const request = require_v3_engine.parseImportRequest(node.params);
|
|
1422
|
+
if (!request || !isLocalImportRequest(request)) return;
|
|
1423
|
+
hasLocalImport = true;
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
if (node.type === "atrule" && node.name === "source") {
|
|
1427
|
+
hasTailwindDirective = true;
|
|
1428
|
+
continue;
|
|
1429
|
+
}
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
} catch {
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(require_v3_engine.removeTailwindSourceDirectives(css)) : void 0;
|
|
1187
1436
|
}
|
|
1188
|
-
function
|
|
1189
|
-
const selectors = [...collectSelectorsFromCss(layerCss)];
|
|
1190
|
-
if (selectors.length === 0) return css;
|
|
1437
|
+
function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
1191
1438
|
try {
|
|
1192
1439
|
const root = postcss.default.parse(css);
|
|
1193
|
-
root.
|
|
1194
|
-
|
|
1440
|
+
root.walkAtRules("import", (atRule) => {
|
|
1441
|
+
const request = require_v3_engine.parseImportRequest(atRule.params);
|
|
1442
|
+
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
1195
1443
|
});
|
|
1196
1444
|
return root.toString();
|
|
1197
1445
|
} catch {
|
|
1198
|
-
return
|
|
1446
|
+
return css;
|
|
1199
1447
|
}
|
|
1200
1448
|
}
|
|
1201
|
-
function
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1449
|
+
function splitLocalCssImports(source) {
|
|
1450
|
+
try {
|
|
1451
|
+
const root = postcss.default.parse(source);
|
|
1452
|
+
const importRoot = postcss.default.root();
|
|
1453
|
+
let changed = false;
|
|
1454
|
+
for (const node of [...root.nodes]) {
|
|
1455
|
+
if (node.type !== "atrule" || node.name !== "import") continue;
|
|
1456
|
+
const request = require_v3_engine.parseImportRequest(node.params);
|
|
1457
|
+
if (!request || !isLocalImportRequest(request)) continue;
|
|
1458
|
+
importRoot.append(node.clone());
|
|
1459
|
+
node.remove();
|
|
1460
|
+
changed = true;
|
|
1213
1461
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
const layerCss = css.slice(contentStart, endIndex).trim();
|
|
1222
|
-
if (layerCss) layers.push(layerCss);
|
|
1223
|
-
cursor = endIndex + 45;
|
|
1224
|
-
}
|
|
1225
|
-
return {
|
|
1226
|
-
layers,
|
|
1227
|
-
rest
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
function findUtilityLayerInsertionIndex(css) {
|
|
1231
|
-
let index = -1;
|
|
1232
|
-
for (const pattern of UTILITY_LAYER_INSERTION_RES) {
|
|
1233
|
-
const match = pattern.exec(css);
|
|
1234
|
-
if (!match) continue;
|
|
1235
|
-
const nextIndex = match.index + (match[1]?.length ?? 0);
|
|
1236
|
-
index = index === -1 ? nextIndex : Math.min(index, nextIndex);
|
|
1462
|
+
const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
|
|
1463
|
+
return changed ? {
|
|
1464
|
+
imports,
|
|
1465
|
+
source: root.toString()
|
|
1466
|
+
} : void 0;
|
|
1467
|
+
} catch {
|
|
1468
|
+
return;
|
|
1237
1469
|
}
|
|
1238
|
-
return index;
|
|
1239
|
-
}
|
|
1240
|
-
function reorderMarkedUserLayerComponentsCss(css) {
|
|
1241
|
-
if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
|
|
1242
|
-
const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
|
|
1243
|
-
if (layers.length === 0) return rest;
|
|
1244
|
-
const layerCss = layers.join("\n");
|
|
1245
|
-
const insertionIndex = findUtilityLayerInsertionIndex(rest);
|
|
1246
|
-
if (insertionIndex === -1) return appendCss(rest, layerCss);
|
|
1247
|
-
return appendCss(appendCss(rest.slice(0, insertionIndex), layerCss), rest.slice(insertionIndex));
|
|
1248
1470
|
}
|
|
1249
|
-
function
|
|
1250
|
-
if (!
|
|
1251
|
-
|
|
1252
|
-
merged: false
|
|
1253
|
-
};
|
|
1254
|
-
const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
|
|
1255
|
-
if (layers.length === 0) return {
|
|
1256
|
-
css: baseCss,
|
|
1257
|
-
merged: false
|
|
1258
|
-
};
|
|
1259
|
-
const layerCss = layers.join("\n");
|
|
1260
|
-
return {
|
|
1261
|
-
css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
|
|
1262
|
-
merged: true
|
|
1263
|
-
};
|
|
1471
|
+
function restoreLocalCssImports(css, imports) {
|
|
1472
|
+
if (!imports?.trim()) return css;
|
|
1473
|
+
return createCssSourceOrderAppend(imports, css);
|
|
1264
1474
|
}
|
|
1265
1475
|
//#endregion
|
|
1266
|
-
//#region src/bundlers/shared/generator-css.ts
|
|
1267
|
-
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1268
|
-
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
1476
|
+
//#region src/bundlers/shared/generator-css/user-css.ts
|
|
1269
1477
|
const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
|
|
1270
1478
|
"config",
|
|
1271
1479
|
"custom-variant",
|
|
@@ -1275,30 +1483,6 @@ const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
|
|
|
1275
1483
|
"utility",
|
|
1276
1484
|
"variant"
|
|
1277
1485
|
]);
|
|
1278
|
-
function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
|
|
1279
|
-
if (target !== "weapp") return css;
|
|
1280
|
-
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
1281
|
-
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
1282
|
-
isTailwindcssV4: majorVersion === 4,
|
|
1283
|
-
preservePseudoContentInit: majorVersion === 3
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
1287
|
-
if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return false;
|
|
1288
|
-
if (!options.isolateCurrentCssCandidates) return true;
|
|
1289
|
-
return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
1290
|
-
}
|
|
1291
|
-
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
1292
|
-
if (options.isolateCssSource && options.currentCssCandidates?.length) return new Set([...scopedRuntime, ...options.currentCssCandidates]);
|
|
1293
|
-
if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk || options.matchedCssSourceFile || options.isolateCssSource && scopedRuntime.size === 0) return scopedRuntime;
|
|
1294
|
-
return new Set([...scopedRuntime, ...runtime]);
|
|
1295
|
-
}
|
|
1296
|
-
function shouldIsolateScopedCssSource(source, sourceEntries) {
|
|
1297
|
-
return Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile) || sourceEntries !== void 0 && sourceEntries.length > 0;
|
|
1298
|
-
}
|
|
1299
|
-
function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
|
|
1300
|
-
return majorVersion === 4 && !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(options.rawSource) && !require_v3_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
1301
|
-
}
|
|
1302
1486
|
function removeTailwindApplyAtRules(source) {
|
|
1303
1487
|
if (!source.includes("@apply")) return source;
|
|
1304
1488
|
try {
|
|
@@ -1336,34 +1520,6 @@ function removeTailwindV4GeneratorAtRules(source) {
|
|
|
1336
1520
|
return source;
|
|
1337
1521
|
}
|
|
1338
1522
|
}
|
|
1339
|
-
function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
|
|
1340
|
-
if (majorVersion !== 4 || isolateCssSource) return false;
|
|
1341
|
-
return target === "web" || generatorRuntime.size === 0;
|
|
1342
|
-
}
|
|
1343
|
-
function shouldAppendWebBundleCssFallback(target, options) {
|
|
1344
|
-
return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
|
|
1345
|
-
}
|
|
1346
|
-
function isEmptyCssSourceOrderParts(parts) {
|
|
1347
|
-
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
1348
|
-
}
|
|
1349
|
-
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
1350
|
-
const preflightStyleOptions = {
|
|
1351
|
-
cssPreflight: opts.cssPreflight,
|
|
1352
|
-
cssPreflightRange: opts.cssPreflightRange
|
|
1353
|
-
};
|
|
1354
|
-
return {
|
|
1355
|
-
...require_precheck.resolveStyleOptionsFromContext(opts),
|
|
1356
|
-
atRules: opts.atRules,
|
|
1357
|
-
uniAppXCssTarget: opts.uniAppXCssTarget,
|
|
1358
|
-
uniAppXUnsupported: opts.uniAppXUnsupported,
|
|
1359
|
-
...cssHandlerOptions,
|
|
1360
|
-
...preflightStyleOptions,
|
|
1361
|
-
...generatorStyleOptions
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
function isLocalImportRequest(request) {
|
|
1365
|
-
return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
|
|
1366
|
-
}
|
|
1367
1523
|
function isCommentOnlyCss(source) {
|
|
1368
1524
|
try {
|
|
1369
1525
|
const root = postcss.default.parse(source);
|
|
@@ -1398,22 +1554,6 @@ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
|
1398
1554
|
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1399
1555
|
}
|
|
1400
1556
|
}
|
|
1401
|
-
function createCssSourceOrderAppend(base, extra) {
|
|
1402
|
-
if (!base) return extra;
|
|
1403
|
-
if (!extra) return base;
|
|
1404
|
-
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
1405
|
-
return `${base}\n${extra}`;
|
|
1406
|
-
}
|
|
1407
|
-
function shouldFinalizeMarkedUserLayerComponentsCss(file) {
|
|
1408
|
-
return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
|
|
1409
|
-
}
|
|
1410
|
-
function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
1411
|
-
const placeholderParts = require_v3_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1412
|
-
if (placeholderParts) return placeholderParts;
|
|
1413
|
-
const exactParts = require_v3_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1414
|
-
if (exactParts) return exactParts;
|
|
1415
|
-
return require_v3_engine.splitTailwindGeneratedCssByBanner(rawSource);
|
|
1416
|
-
}
|
|
1417
1557
|
function splitUserCssLayerBlocks(source) {
|
|
1418
1558
|
if (!source.includes("@layer")) return {
|
|
1419
1559
|
layer: "",
|
|
@@ -1565,84 +1705,157 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1565
1705
|
});
|
|
1566
1706
|
return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
|
|
1567
1707
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
return
|
|
1708
|
+
//#endregion
|
|
1709
|
+
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
1710
|
+
const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
|
|
1711
|
+
const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
|
|
1712
|
+
const UTILITY_LAYER_INSERTION_RES = [
|
|
1713
|
+
/(^|\n)\.(?:fixed|absolute|relative|sticky|static)\s*\{/,
|
|
1714
|
+
/(^|\n)\.(?:block|inline-block|inline|flex|inline-flex|grid|hidden)\s*\{/,
|
|
1715
|
+
/(^|\n)\.(?:m|mx|my|mt|mr|mb|ml|p|px|py|pt|pr|pb|pl)-/,
|
|
1716
|
+
/(^|\n)\.(?:w|h|min-w|min-h|max-w|max-h)-/,
|
|
1717
|
+
/(^|\n)\.(?:bg|text|border|rounded|shadow|opacity|transition|transform|translate|scale|rotate|gap|items|justify|content)-/
|
|
1718
|
+
];
|
|
1719
|
+
function appendCss(base, extra) {
|
|
1720
|
+
if (!base) return extra;
|
|
1721
|
+
if (!extra) return base;
|
|
1722
|
+
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
1723
|
+
return `${base}\n${extra}`;
|
|
1583
1724
|
}
|
|
1584
|
-
function
|
|
1585
|
-
|
|
1586
|
-
|
|
1725
|
+
function removeFirstCssOccurrence(css, chunk) {
|
|
1726
|
+
const trimmed = chunk.trim();
|
|
1727
|
+
if (!trimmed) return css;
|
|
1728
|
+
const index = css.indexOf(trimmed);
|
|
1729
|
+
if (index === -1) return css;
|
|
1730
|
+
return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
|
|
1731
|
+
}
|
|
1732
|
+
function collectSelectorsFromCss(css) {
|
|
1733
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1587
1734
|
try {
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
const request = require_v3_engine.parseImportRequest(node.params);
|
|
1593
|
-
if (!request || !isLocalImportRequest(request)) return;
|
|
1594
|
-
hasLocalImport = true;
|
|
1595
|
-
continue;
|
|
1596
|
-
}
|
|
1597
|
-
if (node.type === "atrule" && node.name === "source") {
|
|
1598
|
-
hasTailwindDirective = true;
|
|
1599
|
-
continue;
|
|
1735
|
+
postcss.default.parse(css).walkRules((rule) => {
|
|
1736
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1737
|
+
const normalized = selector.trim();
|
|
1738
|
+
if (normalized) selectors.add(normalized);
|
|
1600
1739
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
return;
|
|
1605
|
-
}
|
|
1606
|
-
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(require_v3_engine.removeTailwindSourceDirectives(css)) : void 0;
|
|
1740
|
+
});
|
|
1741
|
+
} catch {}
|
|
1742
|
+
return selectors;
|
|
1607
1743
|
}
|
|
1608
|
-
function
|
|
1744
|
+
function matchesLayerSelector(selector, layerSelector) {
|
|
1745
|
+
if (selector === layerSelector) return true;
|
|
1746
|
+
if (!selector.startsWith(layerSelector)) return false;
|
|
1747
|
+
const next = selector[layerSelector.length];
|
|
1748
|
+
return next === ":" || next === "[";
|
|
1749
|
+
}
|
|
1750
|
+
function removeCssRulesForSelectors(css, layerCss) {
|
|
1751
|
+
const selectors = [...collectSelectorsFromCss(layerCss)];
|
|
1752
|
+
if (selectors.length === 0) return css;
|
|
1609
1753
|
try {
|
|
1610
1754
|
const root = postcss.default.parse(css);
|
|
1611
|
-
root.
|
|
1612
|
-
|
|
1613
|
-
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
1755
|
+
root.walkRules((rule) => {
|
|
1756
|
+
if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
|
|
1614
1757
|
});
|
|
1615
1758
|
return root.toString();
|
|
1616
1759
|
} catch {
|
|
1617
|
-
return css;
|
|
1760
|
+
return removeFirstCssOccurrence(css, layerCss);
|
|
1618
1761
|
}
|
|
1619
1762
|
}
|
|
1620
|
-
function
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1763
|
+
function wrapUserLayerComponentsCss(css) {
|
|
1764
|
+
return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
|
|
1765
|
+
}
|
|
1766
|
+
function extractMarkedUserLayerComponentsCss(css) {
|
|
1767
|
+
const layers = [];
|
|
1768
|
+
let rest = "";
|
|
1769
|
+
let cursor = 0;
|
|
1770
|
+
while (cursor < css.length) {
|
|
1771
|
+
const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
|
|
1772
|
+
if (startIndex === -1) {
|
|
1773
|
+
rest += css.slice(cursor);
|
|
1774
|
+
break;
|
|
1632
1775
|
}
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1776
|
+
rest += css.slice(cursor, startIndex);
|
|
1777
|
+
const contentStart = startIndex + 47;
|
|
1778
|
+
const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
|
|
1779
|
+
if (endIndex === -1) {
|
|
1780
|
+
rest += css.slice(startIndex);
|
|
1781
|
+
break;
|
|
1782
|
+
}
|
|
1783
|
+
const layerCss = css.slice(contentStart, endIndex).trim();
|
|
1784
|
+
if (layerCss) layers.push(layerCss);
|
|
1785
|
+
cursor = endIndex + 45;
|
|
1640
1786
|
}
|
|
1787
|
+
return {
|
|
1788
|
+
layers,
|
|
1789
|
+
rest
|
|
1790
|
+
};
|
|
1641
1791
|
}
|
|
1642
|
-
function
|
|
1643
|
-
|
|
1644
|
-
|
|
1792
|
+
function findUtilityLayerInsertionIndex(css) {
|
|
1793
|
+
let index = -1;
|
|
1794
|
+
for (const pattern of UTILITY_LAYER_INSERTION_RES) {
|
|
1795
|
+
const match = pattern.exec(css);
|
|
1796
|
+
if (!match) continue;
|
|
1797
|
+
const nextIndex = match.index + (match[1]?.length ?? 0);
|
|
1798
|
+
index = index === -1 ? nextIndex : Math.min(index, nextIndex);
|
|
1799
|
+
}
|
|
1800
|
+
return index;
|
|
1645
1801
|
}
|
|
1802
|
+
function reorderMarkedUserLayerComponentsCss(css) {
|
|
1803
|
+
if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
|
|
1804
|
+
const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
|
|
1805
|
+
if (layers.length === 0) return rest;
|
|
1806
|
+
const layerCss = layers.join("\n");
|
|
1807
|
+
const insertionIndex = findUtilityLayerInsertionIndex(rest);
|
|
1808
|
+
if (insertionIndex === -1) return appendCss(rest, layerCss);
|
|
1809
|
+
return appendCss(appendCss(rest.slice(0, insertionIndex), layerCss), rest.slice(insertionIndex));
|
|
1810
|
+
}
|
|
1811
|
+
function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
|
|
1812
|
+
if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
|
|
1813
|
+
css: baseCss,
|
|
1814
|
+
merged: false
|
|
1815
|
+
};
|
|
1816
|
+
const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
|
|
1817
|
+
if (layers.length === 0) return {
|
|
1818
|
+
css: baseCss,
|
|
1819
|
+
merged: false
|
|
1820
|
+
};
|
|
1821
|
+
const layerCss = layers.join("\n");
|
|
1822
|
+
return {
|
|
1823
|
+
css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
|
|
1824
|
+
merged: true
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region src/bundlers/shared/generator-css/validate.ts
|
|
1829
|
+
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1830
|
+
async function validateCandidatesByGenerator(options) {
|
|
1831
|
+
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
1832
|
+
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1833
|
+
if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
1834
|
+
const generatorOptions = {
|
|
1835
|
+
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
|
|
1836
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
|
|
1837
|
+
};
|
|
1838
|
+
const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1839
|
+
cssEntries: opts.cssEntries,
|
|
1840
|
+
runtime: candidates
|
|
1841
|
+
});
|
|
1842
|
+
const classSets = await Promise.all(sources.map(async (source) => {
|
|
1843
|
+
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1844
|
+
if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
|
|
1845
|
+
if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
|
|
1846
|
+
}
|
|
1847
|
+
return (await generator.generate({
|
|
1848
|
+
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
1849
|
+
candidates,
|
|
1850
|
+
target: "tailwind"
|
|
1851
|
+
})).classSet;
|
|
1852
|
+
}));
|
|
1853
|
+
const classSet = new Set(classSets.flatMap((item) => [...item]));
|
|
1854
|
+
debug("tailwind generator validated candidates: %s candidates=%d classSet=%d", file, candidates.size, classSet.size);
|
|
1855
|
+
return classSet;
|
|
1856
|
+
}
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region src/bundlers/shared/generator-css.ts
|
|
1646
1859
|
async function generateCssByGenerator(options) {
|
|
1647
1860
|
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
|
|
1648
1861
|
const generatorOptions = {
|
|
@@ -1665,8 +1878,13 @@ async function generateCssByGenerator(options) {
|
|
|
1665
1878
|
const hasGeneratedCss = require_v3_engine.hasTailwindGeneratedCss(generatorRawSource);
|
|
1666
1879
|
const hasSourceDirectives = require_v3_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
1667
1880
|
const hasGeneratedMarkers = require_v3_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
1668
|
-
const shouldGenerateCurrentCss =
|
|
1669
|
-
|
|
1881
|
+
const shouldGenerateCurrentCss = shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
1882
|
+
hasGeneratedCss,
|
|
1883
|
+
hasGeneratedMarkers,
|
|
1884
|
+
hasSourceDirectives,
|
|
1885
|
+
rawSource: generatorRawSource
|
|
1886
|
+
});
|
|
1887
|
+
if (!isSupportedGeneratorMajorVersion(majorVersion) || !shouldGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) return;
|
|
1670
1888
|
try {
|
|
1671
1889
|
await runtimeState.readyPromise;
|
|
1672
1890
|
const currentCssCandidates = majorVersion === 4 ? await (0, tailwindcss_patch.extractSourceCandidates)(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } }) : [];
|
|
@@ -1675,7 +1893,7 @@ async function generateCssByGenerator(options) {
|
|
|
1675
1893
|
hasGeneratedMarkers,
|
|
1676
1894
|
rawSource: generatorRawSource
|
|
1677
1895
|
});
|
|
1678
|
-
const runtimeWithCurrentCss =
|
|
1896
|
+
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
1679
1897
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1680
1898
|
cssEntries: opts.cssEntries,
|
|
1681
1899
|
getSourceCandidatesForEntries,
|
|
@@ -1683,12 +1901,13 @@ async function generateCssByGenerator(options) {
|
|
|
1683
1901
|
});
|
|
1684
1902
|
const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
|
|
1685
1903
|
const configuredContainerCompat = hasConfiguredContainerCompatSources(sources);
|
|
1686
|
-
const
|
|
1904
|
+
const generated = mergeGeneratorResults((await Promise.all(sources.map(async (source) => {
|
|
1687
1905
|
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1688
1906
|
const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
1689
1907
|
const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1690
1908
|
const isolateCssSource = shouldIsolateScopedCssSource(source, sourceEntries);
|
|
1691
|
-
const
|
|
1909
|
+
const sourceMetadata = source.__weappTailwindcssMeta;
|
|
1910
|
+
const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
|
|
1692
1911
|
if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
|
|
1693
1912
|
debug("defer empty scoped css source generation: %s", file);
|
|
1694
1913
|
return;
|
|
@@ -1710,21 +1929,8 @@ async function generateCssByGenerator(options) {
|
|
|
1710
1929
|
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
1711
1930
|
target: generatorOptions.target
|
|
1712
1931
|
});
|
|
1713
|
-
}))).filter((item) => Boolean(item));
|
|
1714
|
-
|
|
1715
|
-
if (!firstGenerated) return;
|
|
1716
|
-
const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
|
|
1717
|
-
const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
|
|
1718
|
-
const generated = generatedResults.length === 1 ? firstGenerated : {
|
|
1719
|
-
...firstGenerated,
|
|
1720
|
-
css: generatedResults.map((item) => item.css).join("\n"),
|
|
1721
|
-
rawCss: generatedResults.map((item) => item.rawCss).join("\n"),
|
|
1722
|
-
incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
|
|
1723
|
-
incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
|
|
1724
|
-
classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
|
|
1725
|
-
dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
|
|
1726
|
-
sources: generatedResults.flatMap((item) => item.sources)
|
|
1727
|
-
};
|
|
1932
|
+
}))).filter((item) => Boolean(item)));
|
|
1933
|
+
if (!generated) return;
|
|
1728
1934
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
1729
1935
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
1730
1936
|
const incrementalCss = require_v3_engine.stripTailwindBanner(generated.incrementalCss);
|
|
@@ -1761,13 +1967,13 @@ async function generateCssByGenerator(options) {
|
|
|
1761
1967
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
1762
1968
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
1763
1969
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
1764
|
-
css = createCssSourceOrderAppend(createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
|
|
1970
|
+
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
|
|
1765
1971
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
1766
1972
|
hasSourceDirectives,
|
|
1767
1973
|
hasMatchedCssSourceFile
|
|
1768
1974
|
})) {
|
|
1769
1975
|
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
1770
|
-
css = createCssSourceOrderAppend(css, userCss);
|
|
1976
|
+
css = createCssSourceOrderAppend$1(css, userCss);
|
|
1771
1977
|
}
|
|
1772
1978
|
if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
|
|
1773
1979
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
@@ -1805,7 +2011,7 @@ async function generateCssByGenerator(options) {
|
|
|
1805
2011
|
rest: css
|
|
1806
2012
|
} : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
1807
2013
|
if (layerCss.layer.trim().length > 0) {
|
|
1808
|
-
css = createCssSourceOrderAppend(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
|
|
2014
|
+
css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
|
|
1809
2015
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
1810
2016
|
}
|
|
1811
2017
|
}
|
|
@@ -1819,7 +2025,7 @@ async function generateCssByGenerator(options) {
|
|
|
1819
2025
|
styleHandler,
|
|
1820
2026
|
importFallback: generatorOptions.importFallback
|
|
1821
2027
|
});
|
|
1822
|
-
css = createCssSourceOrderAppend(css, userCss);
|
|
2028
|
+
css = createCssSourceOrderAppend$1(css, userCss);
|
|
1823
2029
|
}
|
|
1824
2030
|
if (hasMatchedCssSourceFile && generated.target === "weapp") {
|
|
1825
2031
|
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
@@ -1835,7 +2041,7 @@ async function generateCssByGenerator(options) {
|
|
|
1835
2041
|
styleHandler,
|
|
1836
2042
|
importFallback: generatorOptions.importFallback
|
|
1837
2043
|
});
|
|
1838
|
-
css = createCssSourceOrderAppend(css, userCss);
|
|
2044
|
+
css = createCssSourceOrderAppend$1(css, userCss);
|
|
1839
2045
|
}
|
|
1840
2046
|
return {
|
|
1841
2047
|
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
@@ -1864,117 +2070,11 @@ async function generateCssByGenerator(options) {
|
|
|
1864
2070
|
};
|
|
1865
2071
|
} catch (error) {
|
|
1866
2072
|
debug("tailwind direct css generation failed: %s %O", file, error);
|
|
1867
|
-
throw error;
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
async function validateCandidatesByGenerator(options) {
|
|
1871
|
-
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
1872
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1873
|
-
if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
1874
|
-
const generatorOptions = {
|
|
1875
|
-
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
|
|
1876
|
-
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
|
|
1877
|
-
};
|
|
1878
|
-
const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1879
|
-
cssEntries: opts.cssEntries,
|
|
1880
|
-
runtime: candidates
|
|
1881
|
-
});
|
|
1882
|
-
const classSets = await Promise.all(sources.map(async (source) => {
|
|
1883
|
-
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1884
|
-
if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
|
|
1885
|
-
if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
|
|
1886
|
-
}
|
|
1887
|
-
return (await generator.generate({
|
|
1888
|
-
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
1889
|
-
candidates,
|
|
1890
|
-
target: "tailwind"
|
|
1891
|
-
})).classSet;
|
|
1892
|
-
}));
|
|
1893
|
-
const classSet = new Set(classSets.flatMap((item) => [...item]));
|
|
1894
|
-
debug("tailwind generator validated candidates: %s candidates=%d classSet=%d", file, candidates.size, classSet.size);
|
|
1895
|
-
return classSet;
|
|
1896
|
-
}
|
|
1897
|
-
//#endregion
|
|
1898
|
-
//#region src/bundlers/shared/hmr-timing.ts
|
|
1899
|
-
function shouldEmitHmrTiming() {
|
|
1900
|
-
return node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
1901
|
-
}
|
|
1902
|
-
function shouldEmitHumanReadableTiming() {
|
|
1903
|
-
return node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1" && node_process.default.env["WEAPP_TW_HMR_TIMING_LOG"] !== "0";
|
|
1904
|
-
}
|
|
1905
|
-
function emitHmrTiming(bundler, phase, durationMs, details = {}) {
|
|
1906
|
-
if (!shouldEmitHmrTiming()) return;
|
|
1907
|
-
const serializableDetails = { ...details };
|
|
1908
|
-
delete serializableDetails.emit;
|
|
1909
|
-
const payload = {
|
|
1910
|
-
bundler,
|
|
1911
|
-
phase,
|
|
1912
|
-
durationMs: Math.max(0, Math.round(durationMs)),
|
|
1913
|
-
...serializableDetails,
|
|
1914
|
-
...typeof details.wallMs === "number" ? { wallMs: Math.max(0, Math.round(details.wallMs)) } : {}
|
|
1915
|
-
};
|
|
1916
|
-
node_process.default.stdout.write(`[weapp-tailwindcss:hmr] ${JSON.stringify(payload)}\n`);
|
|
1917
|
-
if (shouldEmitHumanReadableTiming()) {
|
|
1918
|
-
const fileSuffix = details.file ? ` file=${details.file}` : "";
|
|
1919
|
-
if (details.metric === "total") {
|
|
1920
|
-
const hooks = details.hooks ? Object.entries(details.hooks).map(([hook, summary]) => `${hook}=${Math.max(0, Math.round(summary.durationMs))}ms/${summary.count}`).join(", ") : "";
|
|
1921
|
-
const hookSuffix = hooks ? ` (${hooks})` : "";
|
|
1922
|
-
const wallSuffix = typeof payload.wallMs === "number" ? ` wall=${payload.wallMs}ms` : "";
|
|
1923
|
-
node_process.default.stdout.write(`[weapp-tailwindcss] ${bundler}:weapp-tailwindcss 总耗时 ${payload.durationMs}ms${wallSuffix}${hookSuffix}\n`);
|
|
1924
|
-
return;
|
|
1925
|
-
}
|
|
1926
|
-
node_process.default.stdout.write(`[weapp-tailwindcss] ${bundler}:${phase} 耗时 ${payload.durationMs}ms${fileSuffix}\n`);
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
function createHmrTimingRecorder(bundler) {
|
|
1930
|
-
const session = {
|
|
1931
|
-
hooks: {},
|
|
1932
|
-
totalMs: 0
|
|
1933
|
-
};
|
|
1934
|
-
const record = (phase, durationMs, details = {}) => {
|
|
1935
|
-
const roundedDuration = Math.max(0, Math.round(durationMs));
|
|
1936
|
-
if (session.startedAt === void 0) session.startedAt = performance.now() - Math.max(0, durationMs);
|
|
1937
|
-
session.totalMs += Math.max(0, durationMs);
|
|
1938
|
-
const current = session.hooks[phase] ?? {
|
|
1939
|
-
count: 0,
|
|
1940
|
-
durationMs: 0,
|
|
1941
|
-
maxMs: 0
|
|
1942
|
-
};
|
|
1943
|
-
current.count += 1;
|
|
1944
|
-
current.durationMs += roundedDuration;
|
|
1945
|
-
current.maxMs = Math.max(current.maxMs, roundedDuration);
|
|
1946
|
-
session.hooks[phase] = current;
|
|
1947
|
-
if (details.emit !== false) emitHmrTiming(bundler, phase, durationMs, details);
|
|
1948
|
-
};
|
|
1949
|
-
const measure = async (phase, task, details = {}) => {
|
|
1950
|
-
const startedAt = performance.now();
|
|
1951
|
-
try {
|
|
1952
|
-
return await task();
|
|
1953
|
-
} finally {
|
|
1954
|
-
record(phase, performance.now() - startedAt, details);
|
|
1955
|
-
}
|
|
1956
|
-
};
|
|
1957
|
-
const emitTotal = (phase = "total") => {
|
|
1958
|
-
if (session.totalMs <= 0) return;
|
|
1959
|
-
const wallMs = session.startedAt === void 0 ? session.totalMs : performance.now() - session.startedAt;
|
|
1960
|
-
emitHmrTiming(bundler, phase, session.totalMs, {
|
|
1961
|
-
hooks: session.hooks,
|
|
1962
|
-
metric: "total",
|
|
1963
|
-
wallMs
|
|
1964
|
-
});
|
|
1965
|
-
session.hooks = {};
|
|
1966
|
-
delete session.startedAt;
|
|
1967
|
-
session.totalMs = 0;
|
|
1968
|
-
};
|
|
1969
|
-
return {
|
|
1970
|
-
emitTotal,
|
|
1971
|
-
measure,
|
|
1972
|
-
record
|
|
1973
|
-
};
|
|
2073
|
+
throw error;
|
|
2074
|
+
}
|
|
1974
2075
|
}
|
|
1975
2076
|
//#endregion
|
|
1976
|
-
//#region src/bundlers/vite/incremental-runtime-class-set.ts
|
|
1977
|
-
const debug = require_v3_engine.createDebug("[vite:runtime-set] ");
|
|
2077
|
+
//#region src/bundlers/vite/incremental-runtime-class-set/entries.ts
|
|
1978
2078
|
const EXTENSION_DOT_PREFIX_RE = /^\./;
|
|
1979
2079
|
const VENDOR_CHUNK_BASENAME_RE = /^(?:vendor|vendors|chunk-vendors|common_vendor)(?:[.-]|$)/i;
|
|
1980
2080
|
const COMMON_VENDOR_CHUNK_RE = /^(?:common|static|assets|chunks?)\/(?:vendor|vendors|chunk-vendors|common_vendor|runtime)(?:[.-]|$)/i;
|
|
@@ -2009,17 +2109,6 @@ function isRuntimeCandidateEntry(entry) {
|
|
|
2009
2109
|
if (entry.output.facadeModuleId && !isDependencyModuleId(entry.output.facadeModuleId)) return true;
|
|
2010
2110
|
return collectChunkModuleIds(entry).some((id) => !isDependencyModuleId(id));
|
|
2011
2111
|
}
|
|
2012
|
-
function createExtractOptions(context, source, bareArbitraryValues) {
|
|
2013
|
-
return {
|
|
2014
|
-
cwd: context.projectRoot,
|
|
2015
|
-
base: context.base,
|
|
2016
|
-
baseFallbacks: context.baseFallbacks,
|
|
2017
|
-
css: context.css,
|
|
2018
|
-
content: source,
|
|
2019
|
-
extension: "html",
|
|
2020
|
-
bareArbitraryValues
|
|
2021
|
-
};
|
|
2022
|
-
}
|
|
2023
2112
|
function createRuntimeEntries(snapshot) {
|
|
2024
2113
|
return snapshot.entries.filter(isRuntimeCandidateEntry);
|
|
2025
2114
|
}
|
|
@@ -2032,37 +2121,54 @@ function resolveEntryExtension(entry) {
|
|
|
2032
2121
|
if (ext.length > 0) return ext;
|
|
2033
2122
|
return "js";
|
|
2034
2123
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2124
|
+
//#endregion
|
|
2125
|
+
//#region src/bundlers/vite/incremental-runtime-class-set/escaped-candidates.ts
|
|
2126
|
+
const ESCAPED_CLASS_TOKEN_RE = /[\w-]+_[A-Z][\w-]*/gi;
|
|
2127
|
+
const TAILWIND_RESTORED_CANDIDATE_SIGNAL_RE = /[[\]:/#!.]/;
|
|
2128
|
+
const MAX_RESTORED_CANDIDATE_VARIANTS = 512;
|
|
2129
|
+
function createEscapeFragments(escapeMap) {
|
|
2130
|
+
return [...new Set(Object.values(escapeMap).filter(Boolean))].sort((a, b) => b.length - a.length);
|
|
2131
|
+
}
|
|
2132
|
+
function hasEscapeFragment(token, escapeFragments) {
|
|
2133
|
+
return escapeFragments.some((fragment) => token.includes(fragment));
|
|
2134
|
+
}
|
|
2135
|
+
function createAmbiguousRestoredRuntimeCandidates(token, escapeMap, escapeFragments) {
|
|
2136
|
+
if (!hasEscapeFragment(token, escapeFragments)) return [];
|
|
2137
|
+
const unescapedByFragment = new Map(Object.entries(escapeMap).map(([char, fragment]) => [fragment, char]));
|
|
2138
|
+
let variants = [""];
|
|
2139
|
+
let index = 0;
|
|
2140
|
+
while (index < token.length) {
|
|
2141
|
+
const fragment = escapeFragments.find((item) => token.startsWith(item, index));
|
|
2142
|
+
if (!fragment) {
|
|
2143
|
+
variants = variants.map((item) => item + token[index]);
|
|
2144
|
+
index += 1;
|
|
2044
2145
|
continue;
|
|
2045
2146
|
}
|
|
2046
|
-
|
|
2147
|
+
const nextVariants = [];
|
|
2148
|
+
const unescaped = unescapedByFragment.get(fragment);
|
|
2149
|
+
for (const variant of variants) {
|
|
2150
|
+
nextVariants.push(variant + fragment);
|
|
2151
|
+
if (unescaped) nextVariants.push(variant + unescaped);
|
|
2152
|
+
if (nextVariants.length >= MAX_RESTORED_CANDIDATE_VARIANTS) break;
|
|
2153
|
+
}
|
|
2154
|
+
variants = nextVariants;
|
|
2155
|
+
index += fragment.length;
|
|
2047
2156
|
}
|
|
2157
|
+
variants.push((0, _weapp_core_escape.unescape)(token, { map: escapeMap }));
|
|
2158
|
+
return [...new Set(variants)].filter((restored) => restored !== token && TAILWIND_RESTORED_CANDIDATE_SIGNAL_RE.test(restored) && !/\s/.test(restored));
|
|
2048
2159
|
}
|
|
2049
|
-
function
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2160
|
+
function collectEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
|
|
2161
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
2162
|
+
ESCAPED_CLASS_TOKEN_RE.lastIndex = 0;
|
|
2163
|
+
let match = ESCAPED_CLASS_TOKEN_RE.exec(source);
|
|
2164
|
+
while (match) {
|
|
2165
|
+
for (const restored of createAmbiguousRestoredRuntimeCandidates(match[0], escapeMap, escapeFragments)) candidates.add(restored);
|
|
2166
|
+
match = ESCAPED_CLASS_TOKEN_RE.exec(source);
|
|
2053
2167
|
}
|
|
2168
|
+
return candidates;
|
|
2054
2169
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
}
|
|
2058
|
-
function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
|
|
2059
|
-
const nextBaseClassSet = new Set(baseClassSet);
|
|
2060
|
-
for (const candidate of candidateCountByClass.keys()) nextBaseClassSet.delete(candidate);
|
|
2061
|
-
return nextBaseClassSet;
|
|
2062
|
-
}
|
|
2063
|
-
function isUrlLikeCandidate(candidate) {
|
|
2064
|
-
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
2065
|
-
}
|
|
2170
|
+
//#endregion
|
|
2171
|
+
//#region src/bundlers/vite/incremental-runtime-class-set/v3-candidates.ts
|
|
2066
2172
|
const TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES = new Set([
|
|
2067
2173
|
"accent",
|
|
2068
2174
|
"animate",
|
|
@@ -2141,6 +2247,9 @@ const TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES = new Set([
|
|
|
2141
2247
|
"w",
|
|
2142
2248
|
"z"
|
|
2143
2249
|
]);
|
|
2250
|
+
function isUrlLikeCandidate(candidate) {
|
|
2251
|
+
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
2252
|
+
}
|
|
2144
2253
|
function getBaseUtilityCandidate(candidate) {
|
|
2145
2254
|
let bracketDepth = 0;
|
|
2146
2255
|
let lastVariantSeparator = -1;
|
|
@@ -2235,10 +2344,54 @@ function isRawCandidateInRanges(start, ranges) {
|
|
|
2235
2344
|
function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
|
|
2236
2345
|
return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
|
|
2237
2346
|
}
|
|
2347
|
+
//#endregion
|
|
2348
|
+
//#region src/bundlers/vite/incremental-runtime-class-set.ts
|
|
2349
|
+
const debug = require_v3_engine.createDebug("[vite:runtime-set] ");
|
|
2350
|
+
function createExtractOptions(context, source, bareArbitraryValues) {
|
|
2351
|
+
return {
|
|
2352
|
+
cwd: context.projectRoot,
|
|
2353
|
+
base: context.base,
|
|
2354
|
+
baseFallbacks: context.baseFallbacks,
|
|
2355
|
+
css: context.css,
|
|
2356
|
+
content: source,
|
|
2357
|
+
extension: "html",
|
|
2358
|
+
...bareArbitraryValues === void 0 ? {} : { bareArbitraryValues }
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
function createCandidateValidationSource(candidates) {
|
|
2362
|
+
return [...new Set(candidates)].sort().join("\n");
|
|
2363
|
+
}
|
|
2364
|
+
function removeCandidateSet$1(candidateCountByClass, candidates) {
|
|
2365
|
+
for (const className of candidates) {
|
|
2366
|
+
const count = candidateCountByClass.get(className);
|
|
2367
|
+
if (count == null) continue;
|
|
2368
|
+
if (count <= 1) {
|
|
2369
|
+
candidateCountByClass.delete(className);
|
|
2370
|
+
continue;
|
|
2371
|
+
}
|
|
2372
|
+
candidateCountByClass.set(className, count - 1);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
function addCandidateSet$1(candidateCountByClass, candidates) {
|
|
2376
|
+
for (const className of candidates) {
|
|
2377
|
+
const nextCount = (candidateCountByClass.get(className) ?? 0) + 1;
|
|
2378
|
+
candidateCountByClass.set(className, nextCount);
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
function createRuntimeClassSet(baseClassSet, candidateCountByClass) {
|
|
2382
|
+
return new Set([...baseClassSet, ...candidateCountByClass.keys()]);
|
|
2383
|
+
}
|
|
2384
|
+
function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
|
|
2385
|
+
const nextBaseClassSet = new Set(baseClassSet);
|
|
2386
|
+
for (const candidate of candidateCountByClass.keys()) nextBaseClassSet.delete(candidate);
|
|
2387
|
+
return nextBaseClassSet;
|
|
2388
|
+
}
|
|
2238
2389
|
function createBundleRuntimeClassSetManager(options = {}) {
|
|
2239
2390
|
const customExtractCandidates = options.extractCandidates;
|
|
2240
2391
|
const extractCandidates = customExtractCandidates ?? tailwindcss_patch.extractValidCandidates;
|
|
2241
2392
|
const extractRawCandidates = options.extractRawCandidates ?? tailwindcss_patch.extractRawCandidatesWithPositions;
|
|
2393
|
+
const escapeMap = options.escapeMap ?? _weapp_core_escape.MappingChars2String;
|
|
2394
|
+
const escapeFragments = createEscapeFragments(escapeMap);
|
|
2242
2395
|
let baseClassSet = /* @__PURE__ */ new Set();
|
|
2243
2396
|
const candidateCountByClass = /* @__PURE__ */ new Map();
|
|
2244
2397
|
const candidatesByFile = /* @__PURE__ */ new Map();
|
|
@@ -2264,7 +2417,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2264
2417
|
return designSystemPromise;
|
|
2265
2418
|
}
|
|
2266
2419
|
function populateCandidateValidityCacheFromDesignSystem(designSystem, unknownCandidates) {
|
|
2267
|
-
const validCandidates = (0, tailwindcss_patch.resolveValidTailwindV4Candidates)(designSystem, unknownCandidates, { bareArbitraryValues: options.bareArbitraryValues });
|
|
2420
|
+
const validCandidates = (0, tailwindcss_patch.resolveValidTailwindV4Candidates)(designSystem, unknownCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
2268
2421
|
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
2269
2422
|
}
|
|
2270
2423
|
async function validateUnknownCandidates(patcher, unknownCandidates) {
|
|
@@ -2298,6 +2451,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2298
2451
|
candidates.add(candidate);
|
|
2299
2452
|
}
|
|
2300
2453
|
}
|
|
2454
|
+
if (patcher.majorVersion === 4) for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
|
|
2301
2455
|
return candidates;
|
|
2302
2456
|
}
|
|
2303
2457
|
async function sync(patcher, snapshot, options = {}) {
|
|
@@ -2316,7 +2470,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2316
2470
|
const canUseBaseWithoutInitialFullScan = Boolean(fullRebuild && !hadTrackedRuntimeFiles && options.skipInitialFullScanWithBase === true && nextBaseClassSet && nextBaseClassSet.size > 0);
|
|
2317
2471
|
for (const [file, previousCandidates] of candidatesByFile) {
|
|
2318
2472
|
if (currentRuntimeFiles.has(file) || snapshot.hasOmittedKnownFiles) continue;
|
|
2319
|
-
removeCandidateSet(candidateCountByClass, previousCandidates);
|
|
2473
|
+
removeCandidateSet$1(candidateCountByClass, previousCandidates);
|
|
2320
2474
|
candidatesByFile.delete(file);
|
|
2321
2475
|
}
|
|
2322
2476
|
const changedRuntimeFiles = canUseBaseWithoutInitialFullScan ? [...collectChangedRuntimeFiles(snapshot)] : fullRebuild ? [...runtimeEntriesByFile.keys()] : [...collectChangedRuntimeFiles(snapshot)];
|
|
@@ -2338,7 +2492,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2338
2492
|
for (const file of changedRuntimeFiles) {
|
|
2339
2493
|
const nextRawCandidates = rawCandidatesByFile.get(file);
|
|
2340
2494
|
const previousCandidates = candidatesByFile.get(file);
|
|
2341
|
-
if (previousCandidates) removeCandidateSet(candidateCountByClass, previousCandidates);
|
|
2495
|
+
if (previousCandidates) removeCandidateSet$1(candidateCountByClass, previousCandidates);
|
|
2342
2496
|
if (!nextRawCandidates || nextRawCandidates.size === 0) {
|
|
2343
2497
|
candidatesByFile.delete(file);
|
|
2344
2498
|
continue;
|
|
@@ -2349,7 +2503,7 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2349
2503
|
candidatesByFile.delete(file);
|
|
2350
2504
|
continue;
|
|
2351
2505
|
}
|
|
2352
|
-
addCandidateSet(candidateCountByClass, nextCandidates);
|
|
2506
|
+
addCandidateSet$1(candidateCountByClass, nextCandidates);
|
|
2353
2507
|
candidatesByFile.set(file, nextCandidates);
|
|
2354
2508
|
}
|
|
2355
2509
|
if (nextBaseClassSet) baseClassSet = canUseBaseWithoutInitialFullScan ? new Set(nextBaseClassSet) : createNonSourceBaseClassSet(nextBaseClassSet, candidateCountByClass);
|
|
@@ -2363,30 +2517,632 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2363
2517
|
};
|
|
2364
2518
|
}
|
|
2365
2519
|
//#endregion
|
|
2520
|
+
//#region src/bundlers/vite/source-candidates/scan-root.ts
|
|
2521
|
+
const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
|
|
2522
|
+
".git",
|
|
2523
|
+
".hg",
|
|
2524
|
+
".jj",
|
|
2525
|
+
".next",
|
|
2526
|
+
".parcel-cache",
|
|
2527
|
+
".pnpm-store",
|
|
2528
|
+
".svelte-kit",
|
|
2529
|
+
".svn",
|
|
2530
|
+
".turbo",
|
|
2531
|
+
".venv",
|
|
2532
|
+
".vercel",
|
|
2533
|
+
".yarn",
|
|
2534
|
+
"__pycache__",
|
|
2535
|
+
"node_modules",
|
|
2536
|
+
"venv"
|
|
2537
|
+
];
|
|
2538
|
+
const TAILWIND_V4_IGNORED_EXTENSIONS = [
|
|
2539
|
+
"css",
|
|
2540
|
+
"less",
|
|
2541
|
+
"postcss",
|
|
2542
|
+
"pcss",
|
|
2543
|
+
"lock",
|
|
2544
|
+
"sass",
|
|
2545
|
+
"scss",
|
|
2546
|
+
"styl",
|
|
2547
|
+
"stylus",
|
|
2548
|
+
"log",
|
|
2549
|
+
"wxss",
|
|
2550
|
+
"acss",
|
|
2551
|
+
"jxss",
|
|
2552
|
+
"ttss",
|
|
2553
|
+
"qss",
|
|
2554
|
+
"tyss"
|
|
2555
|
+
];
|
|
2556
|
+
const TAILWIND_V4_IGNORED_FILES = [
|
|
2557
|
+
"package-lock.json",
|
|
2558
|
+
"pnpm-lock.yaml",
|
|
2559
|
+
"bun.lockb",
|
|
2560
|
+
".gitignore",
|
|
2561
|
+
".env",
|
|
2562
|
+
".env.*"
|
|
2563
|
+
];
|
|
2564
|
+
function resolveOutDirIgnorePattern(root, outDir) {
|
|
2565
|
+
if (!outDir) return;
|
|
2566
|
+
const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
|
|
2567
|
+
if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
|
|
2568
|
+
return `${require_v3_engine.toPosixPath(relative)}/**`;
|
|
2569
|
+
}
|
|
2570
|
+
function normalizeScanEntries(root, entries, outDirIgnore) {
|
|
2571
|
+
const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
|
|
2572
|
+
const scanEntries = entries?.length ? hasPositiveEntry ? entries : [{
|
|
2573
|
+
base: root,
|
|
2574
|
+
pattern: "**/*",
|
|
2575
|
+
negated: false
|
|
2576
|
+
}, ...entries] : void 0;
|
|
2577
|
+
if (!outDirIgnore) return scanEntries;
|
|
2578
|
+
return [...scanEntries ?? [{
|
|
2579
|
+
base: root,
|
|
2580
|
+
pattern: "**/*",
|
|
2581
|
+
negated: false
|
|
2582
|
+
}], {
|
|
2583
|
+
base: root,
|
|
2584
|
+
pattern: outDirIgnore,
|
|
2585
|
+
negated: true
|
|
2586
|
+
}];
|
|
2587
|
+
}
|
|
2588
|
+
function shouldApplyDefaultIgnoredSources(entries) {
|
|
2589
|
+
return entries?.length === void 0 ? false : entries.length > 0 && entries.every((entry) => entry.negated);
|
|
2590
|
+
}
|
|
2591
|
+
function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
|
|
2592
|
+
return [...!explicit || shouldApplyDefaultIgnoredSources(entries) ? [
|
|
2593
|
+
...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
|
|
2594
|
+
base: root,
|
|
2595
|
+
pattern: `**/${pattern}/**`,
|
|
2596
|
+
negated: true
|
|
2597
|
+
})),
|
|
2598
|
+
...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
|
|
2599
|
+
base: root,
|
|
2600
|
+
pattern: `**/*.${extension}`,
|
|
2601
|
+
negated: true
|
|
2602
|
+
})),
|
|
2603
|
+
...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
|
|
2604
|
+
base: root,
|
|
2605
|
+
pattern: `**/${pattern}`,
|
|
2606
|
+
negated: true
|
|
2607
|
+
}))
|
|
2608
|
+
] : [], ...outDirIgnore ? [{
|
|
2609
|
+
base: root,
|
|
2610
|
+
pattern: outDirIgnore,
|
|
2611
|
+
negated: true
|
|
2612
|
+
}] : []];
|
|
2613
|
+
}
|
|
2614
|
+
function resolveSourceCandidateScanFiles(options) {
|
|
2615
|
+
const resolvedRoot = node_path.default.resolve(options.root);
|
|
2616
|
+
const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, options.outDir);
|
|
2617
|
+
const scanEntries = normalizeScanEntries(resolvedRoot, options.entries, outDirIgnore);
|
|
2618
|
+
const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, options.entries, options.explicit);
|
|
2619
|
+
return (0, tailwindcss_patch.resolveProjectSourceFiles)({
|
|
2620
|
+
cwd: resolvedRoot,
|
|
2621
|
+
...scanEntries === void 0 ? {} : { sources: scanEntries },
|
|
2622
|
+
...ignoredSources.length > 0 ? { ignoredSources } : {},
|
|
2623
|
+
filter: options.filter
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
//#endregion
|
|
2627
|
+
//#region src/bundlers/vite/source-candidates/script.ts
|
|
2628
|
+
const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
2629
|
+
"js",
|
|
2630
|
+
"jsx",
|
|
2631
|
+
"mjs",
|
|
2632
|
+
"cjs",
|
|
2633
|
+
"ts",
|
|
2634
|
+
"tsx",
|
|
2635
|
+
"mts",
|
|
2636
|
+
"cts"
|
|
2637
|
+
]);
|
|
2638
|
+
const CLASS_LIKE_NAME_RE = /class/i;
|
|
2639
|
+
function getPropertyName(node) {
|
|
2640
|
+
if (!node) return;
|
|
2641
|
+
if (node.type === "Identifier") return node.name;
|
|
2642
|
+
if (node.type === "StringLiteral") return node.value;
|
|
2643
|
+
}
|
|
2644
|
+
function isClassLikeStringPath(path) {
|
|
2645
|
+
const parent = path.parentPath;
|
|
2646
|
+
if (!parent) return false;
|
|
2647
|
+
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2648
|
+
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2649
|
+
if (parent.isAssignmentExpression?.()) {
|
|
2650
|
+
const left = parent.node.left;
|
|
2651
|
+
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2652
|
+
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2653
|
+
}
|
|
2654
|
+
if (parent.isJSXAttribute?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.name) ?? "");
|
|
2655
|
+
return false;
|
|
2656
|
+
}
|
|
2657
|
+
function isTemplateElementInClassLikePath(path) {
|
|
2658
|
+
const templateLiteralPath = path.parentPath;
|
|
2659
|
+
if (!templateLiteralPath?.isTemplateLiteral?.()) return false;
|
|
2660
|
+
const parent = templateLiteralPath.parentPath;
|
|
2661
|
+
if (!parent) return false;
|
|
2662
|
+
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2663
|
+
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2664
|
+
if (parent.isAssignmentExpression?.()) {
|
|
2665
|
+
const left = parent.node.left;
|
|
2666
|
+
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2667
|
+
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2668
|
+
}
|
|
2669
|
+
return false;
|
|
2670
|
+
}
|
|
2671
|
+
async function extractScriptStringCandidates(source, extension, options) {
|
|
2672
|
+
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2673
|
+
const values = /* @__PURE__ */ new Set();
|
|
2674
|
+
try {
|
|
2675
|
+
require_precheck.traverse(require_precheck.babelParse(source, {
|
|
2676
|
+
cache: true,
|
|
2677
|
+
cacheKey: `vite-source-candidates:${extension}`,
|
|
2678
|
+
plugins: ["jsx", "typescript"],
|
|
2679
|
+
sourceType: "unambiguous"
|
|
2680
|
+
}), {
|
|
2681
|
+
noScope: true,
|
|
2682
|
+
StringLiteral(path) {
|
|
2683
|
+
if (isClassLikeStringPath(path)) values.add(path.node.value);
|
|
2684
|
+
},
|
|
2685
|
+
TemplateElement(path) {
|
|
2686
|
+
if (isTemplateElementInClassLikePath(path)) values.add(path.node.value.raw);
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
} catch {
|
|
2690
|
+
return [];
|
|
2691
|
+
}
|
|
2692
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
2693
|
+
for (const value of values) {
|
|
2694
|
+
const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await (0, tailwindcss_patch.extractSourceCandidates)(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
2695
|
+
for (const candidate of extractedCandidates) candidates.add(candidate);
|
|
2696
|
+
}
|
|
2697
|
+
return candidates;
|
|
2698
|
+
}
|
|
2699
|
+
//#endregion
|
|
2700
|
+
//#region src/bundlers/vite/source-candidates/tailwind-v3-default-extractor.ts
|
|
2701
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
2702
|
+
const TAILWIND_V3_HTML_TOKEN_CANDIDATES = new Set([
|
|
2703
|
+
"/block",
|
|
2704
|
+
"/div",
|
|
2705
|
+
"/span",
|
|
2706
|
+
"/template",
|
|
2707
|
+
"/text",
|
|
2708
|
+
"/view",
|
|
2709
|
+
"class",
|
|
2710
|
+
"className",
|
|
2711
|
+
"div",
|
|
2712
|
+
"hover-class",
|
|
2713
|
+
"span",
|
|
2714
|
+
"template",
|
|
2715
|
+
"text",
|
|
2716
|
+
"view"
|
|
2717
|
+
]);
|
|
2718
|
+
function createTailwindV3DefaultExtractor() {
|
|
2719
|
+
try {
|
|
2720
|
+
const defaultExtractorModule = require$1("tailwindcss/lib/lib/defaultExtractor");
|
|
2721
|
+
const resolveConfigModule = require$1("tailwindcss/resolveConfig");
|
|
2722
|
+
const resolveConfig = resolveConfigModule.default ?? resolveConfigModule;
|
|
2723
|
+
const extractor = (defaultExtractorModule.defaultExtractor ?? defaultExtractorModule.default ?? defaultExtractorModule)({ tailwindConfig: resolveConfig({ content: [] }) });
|
|
2724
|
+
return (source) => new Set(extractor(source).filter((candidate) => !TAILWIND_V3_HTML_TOKEN_CANDIDATES.has(candidate)));
|
|
2725
|
+
} catch {
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
//#endregion
|
|
2730
|
+
//#region src/bundlers/vite/source-candidates.ts
|
|
2731
|
+
const CLEAN_URL_RE = /[?#].*$/;
|
|
2732
|
+
const sourceCandidateContentCache = /* @__PURE__ */ new Map();
|
|
2733
|
+
function cleanUrl(id) {
|
|
2734
|
+
return require_v3_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
|
|
2735
|
+
}
|
|
2736
|
+
function resolveSourceCandidateExtension(id) {
|
|
2737
|
+
const normalized = cleanUrl(id);
|
|
2738
|
+
return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
|
|
2739
|
+
}
|
|
2740
|
+
function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues, extractor) {
|
|
2741
|
+
return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${source}`;
|
|
2742
|
+
}
|
|
2743
|
+
async function extractCandidates(source, extension, options) {
|
|
2744
|
+
const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
|
|
2745
|
+
const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
|
|
2746
|
+
for (const candidate of scriptCandidates) candidates.add(candidate);
|
|
2747
|
+
return candidates;
|
|
2748
|
+
}
|
|
2749
|
+
function isSourceCandidateRequest(id) {
|
|
2750
|
+
return require_v3_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
|
|
2751
|
+
}
|
|
2752
|
+
function removeCandidateSet(candidateCount, candidates) {
|
|
2753
|
+
for (const candidate of candidates) {
|
|
2754
|
+
const count = candidateCount.get(candidate);
|
|
2755
|
+
if (count == null) continue;
|
|
2756
|
+
if (count <= 1) {
|
|
2757
|
+
candidateCount.delete(candidate);
|
|
2758
|
+
continue;
|
|
2759
|
+
}
|
|
2760
|
+
candidateCount.set(candidate, count - 1);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
function addCandidateSet(candidateCount, candidates) {
|
|
2764
|
+
for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
|
|
2765
|
+
}
|
|
2766
|
+
function createSourceCandidateCollector(options = {}) {
|
|
2767
|
+
const candidatesById = /* @__PURE__ */ new Map();
|
|
2768
|
+
const scanCandidatesById = /* @__PURE__ */ new Map();
|
|
2769
|
+
const transformCandidatesById = /* @__PURE__ */ new Map();
|
|
2770
|
+
const cssCandidatesById = /* @__PURE__ */ new Map();
|
|
2771
|
+
const sourceById = /* @__PURE__ */ new Map();
|
|
2772
|
+
const candidateCount = /* @__PURE__ */ new Map();
|
|
2773
|
+
let inlineIncludedCandidates = /* @__PURE__ */ new Set();
|
|
2774
|
+
let inlineExcludedCandidates = /* @__PURE__ */ new Set();
|
|
2775
|
+
async function sync(id, source) {
|
|
2776
|
+
const normalizedId = cleanUrl(id);
|
|
2777
|
+
sourceById.set(normalizedId, source);
|
|
2778
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2779
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2780
|
+
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2781
|
+
if (cachedCandidates) {
|
|
2782
|
+
replaceScanLayer(normalizedId, new Set(cachedCandidates));
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
const nextCandidates = await extractCandidates(source, extension, options);
|
|
2786
|
+
sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
|
|
2787
|
+
replaceScanLayer(normalizedId, nextCandidates);
|
|
2788
|
+
}
|
|
2789
|
+
async function syncCss(id, source) {
|
|
2790
|
+
const normalizedId = cleanUrl(id);
|
|
2791
|
+
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
2792
|
+
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2793
|
+
if (cachedCandidates) {
|
|
2794
|
+
replaceCssLayer(normalizedId, new Set(cachedCandidates));
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2797
|
+
const nextCandidates = await extractCandidates(source, "css", options);
|
|
2798
|
+
sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
|
|
2799
|
+
replaceCssLayer(normalizedId, nextCandidates);
|
|
2800
|
+
}
|
|
2801
|
+
async function merge(id, source) {
|
|
2802
|
+
const normalizedId = cleanUrl(id);
|
|
2803
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2804
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2805
|
+
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2806
|
+
const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : await extractCandidates(source, extension, options);
|
|
2807
|
+
if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
|
|
2808
|
+
replaceTransformLayer(normalizedId, extractedCandidates);
|
|
2809
|
+
}
|
|
2810
|
+
async function syncFile(id) {
|
|
2811
|
+
const normalizedId = cleanUrl(id);
|
|
2812
|
+
await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
|
|
2813
|
+
}
|
|
2814
|
+
async function syncCurrentFile(id) {
|
|
2815
|
+
const normalizedId = cleanUrl(id);
|
|
2816
|
+
transformCandidatesById.delete(normalizedId);
|
|
2817
|
+
await syncFile(normalizedId);
|
|
2818
|
+
}
|
|
2819
|
+
async function scanRoot({ entries, explicit, root, outDir }) {
|
|
2820
|
+
const files = await resolveSourceCandidateScanFiles({
|
|
2821
|
+
entries,
|
|
2822
|
+
explicit,
|
|
2823
|
+
filter: isSourceCandidateRequest,
|
|
2824
|
+
outDir,
|
|
2825
|
+
root
|
|
2826
|
+
});
|
|
2827
|
+
await Promise.all(files.map((file) => syncFile(require_v3_engine.resolveSourceScanPath(file))));
|
|
2828
|
+
}
|
|
2829
|
+
function replaceFinal(id, nextCandidates) {
|
|
2830
|
+
const normalizedId = cleanUrl(id);
|
|
2831
|
+
const previousCandidates = candidatesById.get(normalizedId);
|
|
2832
|
+
if (previousCandidates) {
|
|
2833
|
+
removeCandidateSet(candidateCount, previousCandidates);
|
|
2834
|
+
candidatesById.delete(normalizedId);
|
|
2835
|
+
}
|
|
2836
|
+
if (nextCandidates.size === 0) return;
|
|
2837
|
+
candidatesById.set(normalizedId, nextCandidates);
|
|
2838
|
+
addCandidateSet(candidateCount, nextCandidates);
|
|
2839
|
+
}
|
|
2840
|
+
function replaceScanLayer(id, nextCandidates) {
|
|
2841
|
+
const normalizedId = cleanUrl(id);
|
|
2842
|
+
if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
|
|
2843
|
+
else scanCandidatesById.set(normalizedId, nextCandidates);
|
|
2844
|
+
recompute(normalizedId);
|
|
2845
|
+
}
|
|
2846
|
+
function replaceTransformLayer(id, nextCandidates) {
|
|
2847
|
+
const normalizedId = cleanUrl(id);
|
|
2848
|
+
if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
|
|
2849
|
+
else transformCandidatesById.set(normalizedId, nextCandidates);
|
|
2850
|
+
recompute(normalizedId);
|
|
2851
|
+
}
|
|
2852
|
+
function replaceCssLayer(id, nextCandidates) {
|
|
2853
|
+
const normalizedId = cleanUrl(id);
|
|
2854
|
+
if (nextCandidates.size === 0) cssCandidatesById.delete(normalizedId);
|
|
2855
|
+
else cssCandidatesById.set(normalizedId, nextCandidates);
|
|
2856
|
+
recompute(normalizedId);
|
|
2857
|
+
}
|
|
2858
|
+
function recompute(id) {
|
|
2859
|
+
const normalizedId = cleanUrl(id);
|
|
2860
|
+
replaceFinal(normalizedId, new Set([
|
|
2861
|
+
...scanCandidatesById.get(normalizedId) ?? [],
|
|
2862
|
+
...transformCandidatesById.get(normalizedId) ?? [],
|
|
2863
|
+
...cssCandidatesById.get(normalizedId) ?? []
|
|
2864
|
+
]));
|
|
2865
|
+
}
|
|
2866
|
+
function syncInline(inlineCandidates) {
|
|
2867
|
+
inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
|
|
2868
|
+
inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
|
|
2869
|
+
}
|
|
2870
|
+
function remove(id) {
|
|
2871
|
+
const normalizedId = cleanUrl(id);
|
|
2872
|
+
scanCandidatesById.delete(normalizedId);
|
|
2873
|
+
transformCandidatesById.delete(normalizedId);
|
|
2874
|
+
cssCandidatesById.delete(normalizedId);
|
|
2875
|
+
sourceById.delete(normalizedId);
|
|
2876
|
+
const previousCandidates = candidatesById.get(normalizedId);
|
|
2877
|
+
if (!previousCandidates) return;
|
|
2878
|
+
removeCandidateSet(candidateCount, previousCandidates);
|
|
2879
|
+
candidatesById.delete(normalizedId);
|
|
2880
|
+
}
|
|
2881
|
+
function source(id) {
|
|
2882
|
+
return sourceById.get(cleanUrl(id));
|
|
2883
|
+
}
|
|
2884
|
+
function values() {
|
|
2885
|
+
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
2886
|
+
for (const candidate of inlineExcludedCandidates) values.delete(candidate);
|
|
2887
|
+
return values;
|
|
2888
|
+
}
|
|
2889
|
+
function valuesForEntries(entries, options = {}) {
|
|
2890
|
+
if (entries === void 0) {
|
|
2891
|
+
if (!options.excludeEntries?.length) return values();
|
|
2892
|
+
}
|
|
2893
|
+
const filtered = /* @__PURE__ */ new Set();
|
|
2894
|
+
for (const [id, candidates] of candidatesById) {
|
|
2895
|
+
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
2896
|
+
if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
2897
|
+
for (const candidate of candidates) filtered.add(candidate);
|
|
2898
|
+
}
|
|
2899
|
+
for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
|
|
2900
|
+
for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
|
|
2901
|
+
return filtered;
|
|
2902
|
+
}
|
|
2903
|
+
function sourcesForEntries(entries, options = {}) {
|
|
2904
|
+
const sources = /* @__PURE__ */ new Map();
|
|
2905
|
+
const addCandidateSource = (candidate, id) => {
|
|
2906
|
+
let candidateSources = sources.get(candidate);
|
|
2907
|
+
if (!candidateSources) {
|
|
2908
|
+
candidateSources = /* @__PURE__ */ new Set();
|
|
2909
|
+
sources.set(candidate, candidateSources);
|
|
2910
|
+
}
|
|
2911
|
+
if (id) candidateSources.add(id);
|
|
2912
|
+
};
|
|
2913
|
+
for (const [id, candidates] of candidatesById) {
|
|
2914
|
+
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
2915
|
+
if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
2916
|
+
for (const candidate of candidates) addCandidateSource(candidate, id);
|
|
2917
|
+
}
|
|
2918
|
+
for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
|
|
2919
|
+
for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
|
|
2920
|
+
return sources;
|
|
2921
|
+
}
|
|
2922
|
+
function clear() {
|
|
2923
|
+
candidatesById.clear();
|
|
2924
|
+
scanCandidatesById.clear();
|
|
2925
|
+
transformCandidatesById.clear();
|
|
2926
|
+
cssCandidatesById.clear();
|
|
2927
|
+
sourceById.clear();
|
|
2928
|
+
candidateCount.clear();
|
|
2929
|
+
inlineIncludedCandidates.clear();
|
|
2930
|
+
inlineExcludedCandidates.clear();
|
|
2931
|
+
}
|
|
2932
|
+
function snapshot() {
|
|
2933
|
+
return {
|
|
2934
|
+
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
2935
|
+
cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
2936
|
+
scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
2937
|
+
sourceById: [...sourceById.entries()],
|
|
2938
|
+
transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
2939
|
+
inlineExcludedCandidates: [...inlineExcludedCandidates],
|
|
2940
|
+
inlineIncludedCandidates: [...inlineIncludedCandidates]
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
function restore(snapshot) {
|
|
2944
|
+
clear();
|
|
2945
|
+
inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
|
|
2946
|
+
inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
|
|
2947
|
+
const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
|
|
2948
|
+
for (const [id, candidates] of scanEntries) {
|
|
2949
|
+
const candidateSet = new Set(candidates);
|
|
2950
|
+
if (candidateSet.size === 0) continue;
|
|
2951
|
+
scanCandidatesById.set(id, candidateSet);
|
|
2952
|
+
}
|
|
2953
|
+
for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
|
|
2954
|
+
const candidateSet = new Set(candidates);
|
|
2955
|
+
if (candidateSet.size === 0) continue;
|
|
2956
|
+
transformCandidatesById.set(id, candidateSet);
|
|
2957
|
+
}
|
|
2958
|
+
for (const [id, candidates] of snapshot.cssCandidatesById ?? []) {
|
|
2959
|
+
const candidateSet = new Set(candidates);
|
|
2960
|
+
if (candidateSet.size === 0) continue;
|
|
2961
|
+
cssCandidatesById.set(id, candidateSet);
|
|
2962
|
+
}
|
|
2963
|
+
for (const [id, candidates] of snapshot.candidatesById) {
|
|
2964
|
+
const candidateSet = new Set(candidates);
|
|
2965
|
+
if (candidateSet.size === 0) continue;
|
|
2966
|
+
candidatesById.set(id, candidateSet);
|
|
2967
|
+
addCandidateSet(candidateCount, candidateSet);
|
|
2968
|
+
}
|
|
2969
|
+
for (const [id, source] of snapshot.sourceById ?? []) sourceById.set(id, source);
|
|
2970
|
+
}
|
|
2971
|
+
return {
|
|
2972
|
+
sync,
|
|
2973
|
+
syncCss,
|
|
2974
|
+
merge,
|
|
2975
|
+
syncFile,
|
|
2976
|
+
syncCurrentFile,
|
|
2977
|
+
scanRoot,
|
|
2978
|
+
syncInline,
|
|
2979
|
+
remove,
|
|
2980
|
+
source,
|
|
2981
|
+
values,
|
|
2982
|
+
valuesForEntries,
|
|
2983
|
+
sourcesForEntries,
|
|
2984
|
+
snapshot,
|
|
2985
|
+
restore,
|
|
2986
|
+
clear
|
|
2987
|
+
};
|
|
2988
|
+
}
|
|
2989
|
+
//#endregion
|
|
2990
|
+
//#region src/bundlers/shared/hmr-timing.ts
|
|
2991
|
+
function shouldEmitHmrTiming() {
|
|
2992
|
+
return node_process.default.env["WEAPP_TW_WATCH_REGRESSION"] === "1" || node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1";
|
|
2993
|
+
}
|
|
2994
|
+
function shouldEmitHumanReadableTiming() {
|
|
2995
|
+
return node_process.default.env["WEAPP_TW_HMR_TIMING"] === "1" && node_process.default.env["WEAPP_TW_HMR_TIMING_LOG"] !== "0";
|
|
2996
|
+
}
|
|
2997
|
+
function emitHmrTiming(bundler, phase, durationMs, details = {}) {
|
|
2998
|
+
if (!shouldEmitHmrTiming()) return;
|
|
2999
|
+
const serializableDetails = { ...details };
|
|
3000
|
+
delete serializableDetails.emit;
|
|
3001
|
+
const payload = {
|
|
3002
|
+
bundler,
|
|
3003
|
+
phase,
|
|
3004
|
+
durationMs: Math.max(0, Math.round(durationMs)),
|
|
3005
|
+
...serializableDetails,
|
|
3006
|
+
...typeof details.wallMs === "number" ? { wallMs: Math.max(0, Math.round(details.wallMs)) } : {}
|
|
3007
|
+
};
|
|
3008
|
+
node_process.default.stdout.write(`[weapp-tailwindcss:hmr] ${JSON.stringify(payload)}\n`);
|
|
3009
|
+
if (shouldEmitHumanReadableTiming()) {
|
|
3010
|
+
const fileSuffix = details.file ? ` file=${details.file}` : "";
|
|
3011
|
+
if (details.metric === "total") {
|
|
3012
|
+
const hooks = details.hooks ? Object.entries(details.hooks).map(([hook, summary]) => `${hook}=${Math.max(0, Math.round(summary.durationMs))}ms/${summary.count}`).join(", ") : "";
|
|
3013
|
+
const hookSuffix = hooks ? ` (${hooks})` : "";
|
|
3014
|
+
const wallSuffix = typeof payload.wallMs === "number" ? ` wall=${payload.wallMs}ms` : "";
|
|
3015
|
+
node_process.default.stdout.write(`[weapp-tailwindcss] ${bundler}:weapp-tailwindcss 总耗时 ${payload.durationMs}ms${wallSuffix}${hookSuffix}\n`);
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
node_process.default.stdout.write(`[weapp-tailwindcss] ${bundler}:${phase} 耗时 ${payload.durationMs}ms${fileSuffix}\n`);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
function createHmrTimingRecorder(bundler) {
|
|
3022
|
+
const session = {
|
|
3023
|
+
hooks: {},
|
|
3024
|
+
totalMs: 0
|
|
3025
|
+
};
|
|
3026
|
+
const record = (phase, durationMs, details = {}) => {
|
|
3027
|
+
const roundedDuration = Math.max(0, Math.round(durationMs));
|
|
3028
|
+
if (session.startedAt === void 0) session.startedAt = performance.now() - Math.max(0, durationMs);
|
|
3029
|
+
session.totalMs += Math.max(0, durationMs);
|
|
3030
|
+
const current = session.hooks[phase] ?? {
|
|
3031
|
+
count: 0,
|
|
3032
|
+
durationMs: 0,
|
|
3033
|
+
maxMs: 0
|
|
3034
|
+
};
|
|
3035
|
+
current.count += 1;
|
|
3036
|
+
current.durationMs += roundedDuration;
|
|
3037
|
+
current.maxMs = Math.max(current.maxMs, roundedDuration);
|
|
3038
|
+
session.hooks[phase] = current;
|
|
3039
|
+
if (details.emit !== false) emitHmrTiming(bundler, phase, durationMs, details);
|
|
3040
|
+
};
|
|
3041
|
+
const measure = async (phase, task, details = {}) => {
|
|
3042
|
+
const startedAt = performance.now();
|
|
3043
|
+
try {
|
|
3044
|
+
return await task();
|
|
3045
|
+
} finally {
|
|
3046
|
+
record(phase, performance.now() - startedAt, details);
|
|
3047
|
+
}
|
|
3048
|
+
};
|
|
3049
|
+
const emitTotal = (phase = "total") => {
|
|
3050
|
+
if (session.totalMs <= 0) return;
|
|
3051
|
+
const wallMs = session.startedAt === void 0 ? session.totalMs : performance.now() - session.startedAt;
|
|
3052
|
+
emitHmrTiming(bundler, phase, session.totalMs, {
|
|
3053
|
+
hooks: session.hooks,
|
|
3054
|
+
metric: "total",
|
|
3055
|
+
wallMs
|
|
3056
|
+
});
|
|
3057
|
+
session.hooks = {};
|
|
3058
|
+
delete session.startedAt;
|
|
3059
|
+
session.totalMs = 0;
|
|
3060
|
+
};
|
|
3061
|
+
return {
|
|
3062
|
+
emitTotal,
|
|
3063
|
+
measure,
|
|
3064
|
+
record
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
//#endregion
|
|
3068
|
+
Object.defineProperty(exports, "annotateCssSourceTrace", {
|
|
3069
|
+
enumerable: true,
|
|
3070
|
+
get: function() {
|
|
3071
|
+
return annotateCssSourceTrace;
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
2366
3074
|
Object.defineProperty(exports, "createBundleRuntimeClassSetManager", {
|
|
2367
3075
|
enumerable: true,
|
|
2368
3076
|
get: function() {
|
|
2369
3077
|
return createBundleRuntimeClassSetManager;
|
|
2370
3078
|
}
|
|
2371
3079
|
});
|
|
3080
|
+
Object.defineProperty(exports, "createCssSourceTraceCacheSignature", {
|
|
3081
|
+
enumerable: true,
|
|
3082
|
+
get: function() {
|
|
3083
|
+
return createCssSourceTraceCacheSignature;
|
|
3084
|
+
}
|
|
3085
|
+
});
|
|
3086
|
+
Object.defineProperty(exports, "createCssTokenSourceMap", {
|
|
3087
|
+
enumerable: true,
|
|
3088
|
+
get: function() {
|
|
3089
|
+
return createCssTokenSourceMap;
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
2372
3092
|
Object.defineProperty(exports, "createHmrTimingRecorder", {
|
|
2373
3093
|
enumerable: true,
|
|
2374
3094
|
get: function() {
|
|
2375
3095
|
return createHmrTimingRecorder;
|
|
2376
3096
|
}
|
|
2377
3097
|
});
|
|
3098
|
+
Object.defineProperty(exports, "createSourceCandidateCollector", {
|
|
3099
|
+
enumerable: true,
|
|
3100
|
+
get: function() {
|
|
3101
|
+
return createSourceCandidateCollector;
|
|
3102
|
+
}
|
|
3103
|
+
});
|
|
3104
|
+
Object.defineProperty(exports, "createTailwindV3DefaultExtractor", {
|
|
3105
|
+
enumerable: true,
|
|
3106
|
+
get: function() {
|
|
3107
|
+
return createTailwindV3DefaultExtractor;
|
|
3108
|
+
}
|
|
3109
|
+
});
|
|
2378
3110
|
Object.defineProperty(exports, "emitHmrTiming", {
|
|
2379
3111
|
enumerable: true,
|
|
2380
3112
|
get: function() {
|
|
2381
3113
|
return emitHmrTiming;
|
|
2382
3114
|
}
|
|
2383
3115
|
});
|
|
3116
|
+
Object.defineProperty(exports, "extractMarkedUserLayerComponentsCss", {
|
|
3117
|
+
enumerable: true,
|
|
3118
|
+
get: function() {
|
|
3119
|
+
return extractMarkedUserLayerComponentsCss;
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
2384
3122
|
Object.defineProperty(exports, "generateCssByGenerator", {
|
|
2385
3123
|
enumerable: true,
|
|
2386
3124
|
get: function() {
|
|
2387
3125
|
return generateCssByGenerator;
|
|
2388
3126
|
}
|
|
2389
3127
|
});
|
|
3128
|
+
Object.defineProperty(exports, "isCssSourceTraceEnabled", {
|
|
3129
|
+
enumerable: true,
|
|
3130
|
+
get: function() {
|
|
3131
|
+
return isCssSourceTraceEnabled;
|
|
3132
|
+
}
|
|
3133
|
+
});
|
|
3134
|
+
Object.defineProperty(exports, "isPureLocalCssImportWrapper", {
|
|
3135
|
+
enumerable: true,
|
|
3136
|
+
get: function() {
|
|
3137
|
+
return isPureLocalCssImportWrapper;
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
Object.defineProperty(exports, "isSourceCandidateRequest", {
|
|
3141
|
+
enumerable: true,
|
|
3142
|
+
get: function() {
|
|
3143
|
+
return isSourceCandidateRequest;
|
|
3144
|
+
}
|
|
3145
|
+
});
|
|
2390
3146
|
Object.defineProperty(exports, "mergeMarkedUserLayerComponentsCss", {
|
|
2391
3147
|
enumerable: true,
|
|
2392
3148
|
get: function() {
|