weapp-tailwindcss 5.1.13 → 5.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-2dg_uhEJ.mjs +13 -0
- package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
- package/dist/bundlers/gulp/index.d.ts +2 -0
- package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +2 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -0
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/uni-app/index.d.ts +2 -0
- package/dist/bundlers/vite/frameworks/uni-app-x/index.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +18 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +7 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +3 -2
- package/dist/bundlers/vite/serve-root-import-shell.d.ts +8 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/source-candidates.d.ts +3 -0
- package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
- package/dist/{context-xSJE588m.mjs → context-BgGWVAmN.mjs} +5 -3
- package/dist/{context-DRRgW7i2.js → context-VeFq_8vW.js} +5 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{generator-CS10c9g1.js → generator-CEnUsjed.js} +17 -3
- package/dist/{generator-BvPcmqxU.mjs → generator-CEo920So.mjs} +18 -4
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/{gulp-DNZZvUMq.js → gulp-3m1dAiig.js} +92 -54
- package/dist/{gulp-BEOzXrbp.mjs → gulp-DP71z1jG.mjs} +92 -54
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-hRhRAjYV.mjs → hmr-timing-1aS6--U7.mjs} +272 -56
- package/dist/{hmr-timing-DW1g3zjl.js → hmr-timing-B8p4f0ca.js} +323 -53
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/shared/mpx.d.ts +4 -1
- package/dist/{source-candidate-scan-signature-CMgu5bJk.js → source-candidate-scan-signature-BAahhiwb.js} +20 -139
- package/dist/{source-candidate-scan-signature-t4XKAQ04.mjs → source-candidate-scan-signature-Cf7259PR.mjs} +21 -104
- package/dist/tailwindcss/candidates.d.ts +4 -0
- package/dist/{tailwindcss-z9JMF-qU.js → tailwindcss-KBYPJ2DW.js} +1 -1
- package/dist/{tailwindcss-DZT_pWrd.mjs → tailwindcss-xs704TRw.mjs} +1 -1
- package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
- package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
- package/dist/{vite-DnkObu2L.js → vite-DUVjMduj.js} +807 -320
- package/dist/{vite-Tpgi77vE.mjs → vite-nXZEiwG0.mjs} +757 -270
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-generation-loader.js +12 -0
- package/dist/weapp-tw-css-import-rewrite-loader-DNk0IxAt.js +10198 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +6 -8209
- package/dist/{webpack-CTYm19zA.mjs → webpack-C_UUFRgj.mjs} +228 -58
- package/dist/{webpack-CzXjfvYS.js → webpack-nppysF4B.js} +240 -70
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +11 -3
- package/dist/auto-CrJJc5rK.mjs +0 -13
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { $ as normalizeTailwindSourceDirectives, A as filterApplyOnlyGeneratedCss, At as resolveTailwindV4CssSourceBase, B as stripUnmatchedTailwindSourceMediaCloseFragments, F as removeTailwindV4GeneratedUserCssArtifacts, G as removeUnsupportedMiniProgramAtRules, H as finalizeMiniProgramCss, I as removeTailwindV4GeneratorAtRules, J as hasTailwindApplyDirective, L as shouldFilterApplyOnlyGeneratedCss, M as isCommentOnlyCss, N as normalizeEmptyTailwindCustomVariants, Nt as filterUnsupportedMiniProgramTailwindV4Candidates, Pt as loadTailwindV4DesignSystem, R as splitUserCssLayerBlocks, Tt as isFileMatchedByTailwindSourceEntries, V as transformGeneratorUserCss, X as hasTailwindRootDirectives, Z as hasTailwindSourceDirectives, a as resolveGeneratorRuntimeBranch, at as VITE_MARKER_RE, ct as hasTailwindGeneratedCssMarkers, d as resolveTailwindV4SourceFromRuntime, dt as splitTailwindV4GeneratedCssBySourceOrder, ft as stripGeneratorPlaceholderMarkers, gt as prependConfigDirective, ht as normalizeConfigDirective, i as normalizeWeappTailwindcssGeneratorOptions, it as GENERATOR_PLACEHOLDER_MARKER_RE, j as hasUserCssLayerBlocks, jt as toPosixPath$1, k as extractGeneratedCssForUserLayerSelectors, kt as resolveSourceScanPath, lt as splitGeneratorPlaceholderCssBySourceOrder, mt as stripTailwindBanners, nt as removeTailwindSourceDirectives, ot as createCssAppend, p as resolveTailwindV4SourceOptionsFromRuntime, pt as stripTailwindBanner, rt as resolveCssEntrySource, s as shouldUseMiniProgramCssBranch, st as hasTailwindGeneratedCss, t as createWeappTailwindcssGenerator, tt as parseImportRequest, u as resolveTailwindV4Source$1, ut as splitTailwindGeneratedCssByBanner, xt as FULL_SOURCE_SCAN_EXTENSION_RE, z as stripTailwindSourceMediaFragments } from "./generator-
|
|
1
|
+
import { $ as normalizeTailwindSourceDirectives, A as filterApplyOnlyGeneratedCss, At as resolveTailwindV4CssSourceBase, B as stripUnmatchedTailwindSourceMediaCloseFragments, F as removeTailwindV4GeneratedUserCssArtifacts, G as removeUnsupportedMiniProgramAtRules, H as finalizeMiniProgramCss, I as removeTailwindV4GeneratorAtRules, J as hasTailwindApplyDirective, L as shouldFilterApplyOnlyGeneratedCss, M as isCommentOnlyCss, N as normalizeEmptyTailwindCustomVariants, Nt as filterUnsupportedMiniProgramTailwindV4Candidates, Pt as loadTailwindV4DesignSystem, R as splitUserCssLayerBlocks, Tt as isFileMatchedByTailwindSourceEntries, V as transformGeneratorUserCss, X as hasTailwindRootDirectives, Z as hasTailwindSourceDirectives, a as resolveGeneratorRuntimeBranch, at as VITE_MARKER_RE, ct as hasTailwindGeneratedCssMarkers, d as resolveTailwindV4SourceFromRuntime, dt as splitTailwindV4GeneratedCssBySourceOrder, ft as stripGeneratorPlaceholderMarkers, gt as prependConfigDirective, ht as normalizeConfigDirective, i as normalizeWeappTailwindcssGeneratorOptions, it as GENERATOR_PLACEHOLDER_MARKER_RE, j as hasUserCssLayerBlocks, jt as toPosixPath$1, k as extractGeneratedCssForUserLayerSelectors, kt as resolveSourceScanPath, lt as splitGeneratorPlaceholderCssBySourceOrder, mt as stripTailwindBanners, nt as removeTailwindSourceDirectives, ot as createCssAppend, p as resolveTailwindV4SourceOptionsFromRuntime, pt as stripTailwindBanner, rt as resolveCssEntrySource, s as shouldUseMiniProgramCssBranch, st as hasTailwindGeneratedCss, t as createWeappTailwindcssGenerator, tt as parseImportRequest, u as resolveTailwindV4Source$1, ut as splitTailwindGeneratedCssByBanner, xt as FULL_SOURCE_SCAN_EXTENSION_RE, z as stripTailwindSourceMediaFragments } from "./generator-CEo920So.mjs";
|
|
2
|
+
import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.mjs";
|
|
2
3
|
import { t as omitUndefined } from "./object-BJSWl-E5.mjs";
|
|
3
|
-
import { h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective } from "./tailwindcss-
|
|
4
|
-
import { _ as babelParse, b as md5Hash, g as replaceWxml, v as traverse, y as createDebug } from "./wxml-DdGdeqaH.mjs";
|
|
5
|
-
import { r as resolveStyleOptionsFromContext } from "./context-
|
|
4
|
+
import { h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective } from "./tailwindcss-xs704TRw.mjs";
|
|
5
|
+
import { _ as babelParse, b as md5Hash, g as replaceWxml, i as createAttributeMatcher, n as Parser, v as traverse, y as createDebug } from "./wxml-DdGdeqaH.mjs";
|
|
6
|
+
import { r as resolveStyleOptionsFromContext } from "./context-BgGWVAmN.mjs";
|
|
6
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
8
|
import path from "node:path";
|
|
8
9
|
import process from "node:process";
|
|
9
10
|
import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
10
|
-
import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, filterExistingCssRules, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, postcss, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
|
|
11
|
+
import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, filterExistingCssRules, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, normalizeMiniProgramGeneratedCssForPostcss, postcss, removeMatchingLocalCssImports, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
|
|
11
12
|
import { LRUCache } from "lru-cache";
|
|
12
13
|
import { readFile } from "node:fs/promises";
|
|
13
14
|
import { MappingChars2String, unescape } from "@weapp-core/escape";
|
|
@@ -129,6 +130,39 @@ function annotateCssSourceTrace(css, options) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
133
|
+
//#region src/bundlers/shared/generated-css-marker.ts
|
|
134
|
+
const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
|
|
135
|
+
const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
|
|
136
|
+
const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!?\s*weapp-tailwindcss (gulp|vite|webpack)-generated-css(?:\s*:\s*([^\s*]+))?\s*\*\/\s*/gi;
|
|
137
|
+
const VITE_INTERNAL_CSS_MARKER_GLOBAL_RE = /\/\*\$vite\$:\d+\*\/\s*/g;
|
|
138
|
+
function createBundlerGeneratedCssMarker(bundler, file) {
|
|
139
|
+
return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
|
|
140
|
+
}
|
|
141
|
+
function hasBundlerGeneratedCssMarker(source) {
|
|
142
|
+
return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
|
|
143
|
+
}
|
|
144
|
+
function stripBundlerGeneratedCssMarkers(source) {
|
|
145
|
+
return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "").replace(VITE_INTERNAL_CSS_MARKER_GLOBAL_RE, "");
|
|
146
|
+
}
|
|
147
|
+
function parseBundlerGeneratedCssMarkerBlocks(source) {
|
|
148
|
+
const blocks = [];
|
|
149
|
+
BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex = 0;
|
|
150
|
+
let match = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
|
|
151
|
+
while (match !== null) {
|
|
152
|
+
const cssStart = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.lastIndex;
|
|
153
|
+
const nextMatch = BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE.exec(source);
|
|
154
|
+
const cssEnd = nextMatch?.index ?? source.length;
|
|
155
|
+
const file = match[2] ? decodeURIComponent(match[2]) : void 0;
|
|
156
|
+
blocks.push({
|
|
157
|
+
bundler: match[1],
|
|
158
|
+
file,
|
|
159
|
+
css: source.slice(cssStart, cssEnd)
|
|
160
|
+
});
|
|
161
|
+
match = nextMatch;
|
|
162
|
+
}
|
|
163
|
+
return blocks;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
132
166
|
//#region src/bundlers/shared/generator-css/class-selectors.ts
|
|
133
167
|
function normalizeCssClassSelector(value) {
|
|
134
168
|
return value.replace(/\\([^\da-f\r\n])/gi, "$1").replace(/\\([\da-f]{1,6})\s?/gi, (_, code) => String.fromCodePoint(Number.parseInt(code, 16)));
|
|
@@ -153,11 +187,47 @@ function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
|
|
|
153
187
|
return matched;
|
|
154
188
|
}
|
|
155
189
|
//#endregion
|
|
190
|
+
//#region src/bundlers/shared/style-requests.ts
|
|
191
|
+
const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
|
|
192
|
+
const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
|
|
193
|
+
const VUE_STYLE_QUERY_RE = /(?:^|&)type=style(?:&|$)/;
|
|
194
|
+
const STYLE_LANG_QUERY_RE = /(?:^|&)lang(?:[.=](?:css|scss|sass|less|styl|stylus|pcss|postcss))?(?:&|$)/;
|
|
195
|
+
function stripHash(request) {
|
|
196
|
+
const hashIndex = request.indexOf("#");
|
|
197
|
+
return hashIndex === -1 ? request : request.slice(0, hashIndex);
|
|
198
|
+
}
|
|
199
|
+
function stripRequestQuery(request) {
|
|
200
|
+
const normalized = stripHash(request);
|
|
201
|
+
const queryIndex = normalized.indexOf("?");
|
|
202
|
+
return queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
|
|
203
|
+
}
|
|
204
|
+
function isSourceStyleRequest(request) {
|
|
205
|
+
if (typeof request !== "string" || request.length === 0) return false;
|
|
206
|
+
const normalized = stripHash(request);
|
|
207
|
+
const queryIndex = normalized.indexOf("?");
|
|
208
|
+
const pathname = queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
|
|
209
|
+
if (SOURCE_STYLE_EXT_RE.test(pathname)) return true;
|
|
210
|
+
if (queryIndex === -1) return false;
|
|
211
|
+
const query = normalized.slice(queryIndex + 1);
|
|
212
|
+
return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
|
|
213
|
+
}
|
|
214
|
+
function isVueScopedStyleRequest(request) {
|
|
215
|
+
if (typeof request !== "string" || request.length === 0) return false;
|
|
216
|
+
const normalized = stripHash(request);
|
|
217
|
+
const queryIndex = normalized.indexOf("?");
|
|
218
|
+
if (queryIndex === -1) return false;
|
|
219
|
+
const query = normalized.slice(queryIndex + 1);
|
|
220
|
+
return VUE_STYLE_QUERY_RE.test(query) && /(?:^|&)scoped(?:=[^&]*)?(?:&|$)/.test(query);
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
156
223
|
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
157
224
|
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
158
225
|
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
159
226
|
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
160
227
|
}
|
|
228
|
+
function resolvePostcssRequestOption(cssHandlerOptions) {
|
|
229
|
+
return resolveCssHandlerSourceOptions(cssHandlerOptions)?.requestFile ?? resolvePostcssFromOption(cssHandlerOptions);
|
|
230
|
+
}
|
|
161
231
|
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
162
232
|
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
163
233
|
if (!from || !path.isAbsolute(from)) return;
|
|
@@ -172,13 +242,6 @@ function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
|
172
242
|
}
|
|
173
243
|
//#endregion
|
|
174
244
|
//#region src/bundlers/shared/generator-css/generation-helpers.ts
|
|
175
|
-
function isVueScopedStyleSource(from) {
|
|
176
|
-
if (typeof from !== "string" || from.length === 0) return false;
|
|
177
|
-
const queryIndex = from.indexOf("?");
|
|
178
|
-
if (queryIndex === -1) return false;
|
|
179
|
-
const query = from.slice(queryIndex + 1);
|
|
180
|
-
return /(?:^|&)type=style(?:&|$)/.test(query) && /(?:^|&)scoped(?:=[^&]*)?(?:&|$)/.test(query);
|
|
181
|
-
}
|
|
182
245
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
183
246
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
184
247
|
}
|
|
@@ -187,7 +250,7 @@ function isMiniProgramGeneratorTarget(target) {
|
|
|
187
250
|
}
|
|
188
251
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
189
252
|
if (!isMiniProgramGeneratorTarget(target)) return css;
|
|
190
|
-
if (
|
|
253
|
+
if (options.styleOptions && isVueScopedStyleRequest(resolvePostcssRequestOption(options.styleOptions))) return finalizeMiniProgramCss(css, {
|
|
191
254
|
cssPreflight: false,
|
|
192
255
|
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
193
256
|
isTailwindcssV4: true,
|
|
@@ -204,7 +267,7 @@ function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPrefligh
|
|
|
204
267
|
});
|
|
205
268
|
}
|
|
206
269
|
function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
|
|
207
|
-
if (
|
|
270
|
+
if (isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions))) return {
|
|
208
271
|
inject: false,
|
|
209
272
|
preserve: false
|
|
210
273
|
};
|
|
@@ -274,7 +337,7 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
274
337
|
}
|
|
275
338
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
276
339
|
const resolvedStyleOptions = resolveStyleOptionsFromContext(opts);
|
|
277
|
-
const scopedVueStyleSource =
|
|
340
|
+
const scopedVueStyleSource = isVueScopedStyleRequest(resolvePostcssRequestOption(cssHandlerOptions));
|
|
278
341
|
const preflightStyleOptions = {
|
|
279
342
|
cssPreflight: scopedVueStyleSource ? false : resolvedStyleOptions.cssPreflight,
|
|
280
343
|
cssPreflightRange: scopedVueStyleSource ? void 0 : resolvedStyleOptions.cssPreflightRange
|
|
@@ -1472,7 +1535,8 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
1472
1535
|
index: 0,
|
|
1473
1536
|
matched: true
|
|
1474
1537
|
}) : void 0;
|
|
1475
|
-
const
|
|
1538
|
+
const canResolveCombinedConfiguredCssSources = (normalizedSourceOptions?.cssSources?.length ?? 0) <= 1 || hasTailwindGeneratedCss(rawSource);
|
|
1539
|
+
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? (canResolveCombinedConfiguredCssSources ? await resolveTailwindV4Source$1(normalizedSourceOptions) : void 0) : void 0;
|
|
1476
1540
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1477
1541
|
...configuredCssSource,
|
|
1478
1542
|
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
@@ -2314,10 +2378,14 @@ async function generateCssByGenerator(options) {
|
|
|
2314
2378
|
const configuredContainerCompat = hasConfiguredContainerCompatSources(generatorSources);
|
|
2315
2379
|
const sourceConcurrency = resolveGeneratorSourceConcurrency();
|
|
2316
2380
|
const generated = mergeGeneratorResults((await runWithConcurrency(generatorSources.map((source) => async () => {
|
|
2381
|
+
const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
|
|
2317
2382
|
const generator = createWeappTailwindcssGenerator(options.disableSourceScan === true ? {
|
|
2318
2383
|
...source,
|
|
2319
|
-
css: removeTailwindSourceDirectives(
|
|
2320
|
-
} : source
|
|
2384
|
+
css: removeTailwindSourceDirectives(sourceCss, { importFallback: generatorOptions.importFallback })
|
|
2385
|
+
} : sourceCss === source.css ? source : {
|
|
2386
|
+
...source,
|
|
2387
|
+
css: sourceCss
|
|
2388
|
+
});
|
|
2321
2389
|
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
2322
2390
|
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2323
2391
|
const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
|
|
@@ -2350,6 +2418,91 @@ async function generateCssByGenerator(options) {
|
|
|
2350
2418
|
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
2351
2419
|
if (!generated) return;
|
|
2352
2420
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
2421
|
+
const hasMatchedCssSourceFile = generatorSources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2422
|
+
const hasExplicitCssSource = generatorSources.some((source) => {
|
|
2423
|
+
const metadata = source.__weappTailwindcssMeta;
|
|
2424
|
+
return metadata?.candidateMatchedCssSource !== true && (metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0);
|
|
2425
|
+
});
|
|
2426
|
+
const hasPreflightCssSource = generatorSources.some((source) => {
|
|
2427
|
+
const metadata = source.__weappTailwindcssMeta;
|
|
2428
|
+
const appEntryMatchedByCandidates = metadata?.candidateMatchedCssSource === true && metadata.cssEntryIndex === 0 && metadata.cssSourceIndex === void 0;
|
|
2429
|
+
return metadata?.includesPreflight === true && !appEntryMatchedByCandidates;
|
|
2430
|
+
});
|
|
2431
|
+
const hasPreflightRawSource = includesTailwindV4PreflightDirective(generatorRawSource);
|
|
2432
|
+
const hasOnlyPrimaryCssSource = generatorSources.length > 0 && generatorSources.every((source) => {
|
|
2433
|
+
const metadata = source.__weappTailwindcssMeta;
|
|
2434
|
+
return metadata?.candidateMatchedCssSource !== true && metadata?.primaryCssSource === true;
|
|
2435
|
+
});
|
|
2436
|
+
const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2437
|
+
hasGeneratedCss,
|
|
2438
|
+
hasGeneratedMarkers
|
|
2439
|
+
});
|
|
2440
|
+
const filterGeneratedApplyOnlyCss = (css) => {
|
|
2441
|
+
if (!shouldFilterApplyOnlyCss) return css;
|
|
2442
|
+
return filterApplyOnlyGeneratedCss(css, generatorRawSource, { preserveVariables: generated.target !== "web" });
|
|
2443
|
+
};
|
|
2444
|
+
const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
|
|
2445
|
+
cssHandlerOptions,
|
|
2446
|
+
isolateCurrentCssCandidates,
|
|
2447
|
+
localImports,
|
|
2448
|
+
explicitCssSource: hasExplicitCssSource,
|
|
2449
|
+
primaryCssSource: hasOnlyPrimaryCssSource || hasPreflightCssSource || hasPreflightRawSource
|
|
2450
|
+
});
|
|
2451
|
+
if (options.deferCssAdaptation) {
|
|
2452
|
+
const normalizeDeferredGeneratedCss = async (css) => {
|
|
2453
|
+
const rawCss = stripTailwindBanner(css);
|
|
2454
|
+
const generationCss = generated.target === "weapp" && (hasCssMacroStyleOptions(generatorStyleOptions) || hasCssMacroTailwindV4InternalAtRules(rawCss)) ? await transformCssMacroCss(rawCss, generatorStyleOptions) : rawCss;
|
|
2455
|
+
const normalizedCss = generated.target === "weapp" ? await normalizeMiniProgramGeneratedCssForPostcss(generationCss, {
|
|
2456
|
+
preservePreflight: true,
|
|
2457
|
+
preserveRawClassRules: true
|
|
2458
|
+
}) : generationCss;
|
|
2459
|
+
return filterGeneratedApplyOnlyCss(normalizedCss);
|
|
2460
|
+
};
|
|
2461
|
+
const restoreDeferredUserCss = async (css) => {
|
|
2462
|
+
if (generated.target !== "weapp" || generatedUserCssRawSource.trim().length === 0) return css;
|
|
2463
|
+
const userCssOptions = {
|
|
2464
|
+
generatorTarget: generated.target,
|
|
2465
|
+
generatorStyleOptions,
|
|
2466
|
+
cssUserHandlerOptions,
|
|
2467
|
+
styleHandler,
|
|
2468
|
+
importFallback: generatorOptions.importFallback,
|
|
2469
|
+
processed: userRawSourceProcessed
|
|
2470
|
+
};
|
|
2471
|
+
const transformDeferredUserCss = async (source) => {
|
|
2472
|
+
const parts = splitUserCssLayerBlocks(source);
|
|
2473
|
+
const layerCss = await transformGeneratorUserCss(parts.layer, userCssOptions);
|
|
2474
|
+
const restCss = await transformGeneratorUserCss(parts.rest, userCssOptions);
|
|
2475
|
+
return createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss), restCss);
|
|
2476
|
+
};
|
|
2477
|
+
const orderedUserCss = splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
2478
|
+
if (orderedUserCss) {
|
|
2479
|
+
const beforeUserCss = await transformDeferredUserCss(orderedUserCss.before);
|
|
2480
|
+
const afterUserCss = await transformDeferredUserCss(orderedUserCss.after);
|
|
2481
|
+
const cssWithBeforeUserCss = createCssSourceOrderAppend$1(filterExistingCssRules(css, beforeUserCss), css);
|
|
2482
|
+
return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend$1(cssWithBeforeUserCss, filterExistingCssRules(cssWithBeforeUserCss, afterUserCss)));
|
|
2483
|
+
}
|
|
2484
|
+
return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend$1(css, filterExistingCssRules(css, await transformDeferredUserCss(generatedUserCssRawSource))));
|
|
2485
|
+
};
|
|
2486
|
+
const canAppendIncrementalCss = generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource);
|
|
2487
|
+
const incrementalRawCss = generated.incrementalRawCss ?? generated.incrementalCss;
|
|
2488
|
+
const shouldAppendIncrementalCss = canAppendIncrementalCss && typeof options.previousCss === "string" && typeof incrementalRawCss === "string";
|
|
2489
|
+
const normalizedCss = shouldAppendIncrementalCss ? incrementalRawCss.trim().length > 0 ? createCssAppend(options.previousCss, await normalizeDeferredGeneratedCss(incrementalRawCss)) : options.previousCss : await normalizeDeferredGeneratedCss(generated.rawCss ?? generated.css);
|
|
2490
|
+
const css = restoreLocalCssImports(shouldAppendIncrementalCss ? normalizedCss : await restoreDeferredUserCss(normalizedCss), localImports, { outputFile: file });
|
|
2491
|
+
return {
|
|
2492
|
+
css,
|
|
2493
|
+
classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, css, opts.escapeMap, options.previousClassSet),
|
|
2494
|
+
target: generated.target,
|
|
2495
|
+
source: "generator",
|
|
2496
|
+
dependencies: generated.dependencies,
|
|
2497
|
+
incremental: shouldAppendIncrementalCss,
|
|
2498
|
+
metadata: {
|
|
2499
|
+
file,
|
|
2500
|
+
majorVersion,
|
|
2501
|
+
preflightMode,
|
|
2502
|
+
rawCss: generated.rawCss
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2353
2506
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2354
2507
|
const incrementalCss = stripTailwindBanner(generated.incrementalCss);
|
|
2355
2508
|
const css = incrementalCss.trim().length > 0 ? finalizeIncrementalGeneratorCss(options.previousCss, incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
@@ -2371,33 +2524,7 @@ async function generateCssByGenerator(options) {
|
|
|
2371
2524
|
}
|
|
2372
2525
|
};
|
|
2373
2526
|
}
|
|
2374
|
-
const
|
|
2375
|
-
hasGeneratedCss,
|
|
2376
|
-
hasGeneratedMarkers
|
|
2377
|
-
});
|
|
2378
|
-
const generatedCssSource = generated.target === "web" ? generated.css : stripTailwindBanner(generated.css);
|
|
2379
|
-
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
|
|
2380
|
-
const hasMatchedCssSourceFile = generatorSources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2381
|
-
const hasExplicitCssSource = generatorSources.some((source) => {
|
|
2382
|
-
const metadata = source.__weappTailwindcssMeta;
|
|
2383
|
-
return metadata?.candidateMatchedCssSource !== true && (metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0);
|
|
2384
|
-
});
|
|
2385
|
-
const hasPreflightCssSource = generatorSources.some((source) => {
|
|
2386
|
-
const metadata = source.__weappTailwindcssMeta;
|
|
2387
|
-
const appEntryMatchedByCandidates = metadata?.candidateMatchedCssSource === true && metadata.cssEntryIndex === 0 && metadata.cssSourceIndex === void 0;
|
|
2388
|
-
return metadata?.includesPreflight === true && !appEntryMatchedByCandidates;
|
|
2389
|
-
});
|
|
2390
|
-
const hasPreflightRawSource = includesTailwindV4PreflightDirective(generatorRawSource);
|
|
2391
|
-
const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
|
|
2392
|
-
cssHandlerOptions,
|
|
2393
|
-
isolateCurrentCssCandidates,
|
|
2394
|
-
localImports,
|
|
2395
|
-
explicitCssSource: hasExplicitCssSource,
|
|
2396
|
-
primaryCssSource: generatorSources.length > 0 && generatorSources.every((source) => {
|
|
2397
|
-
const metadata = source.__weappTailwindcssMeta;
|
|
2398
|
-
return metadata?.candidateMatchedCssSource !== true && metadata?.primaryCssSource === true;
|
|
2399
|
-
}) || hasPreflightCssSource || hasPreflightRawSource
|
|
2400
|
-
});
|
|
2527
|
+
const generatedCss = filterGeneratedApplyOnlyCss(generated.target === "web" ? generated.css : stripTailwindBanner(generated.css));
|
|
2401
2528
|
const orderedExtraCss = splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
2402
2529
|
const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
|
|
2403
2530
|
if (orderedExtraCss) {
|
|
@@ -2464,6 +2591,8 @@ async function generateCssByGenerator(options) {
|
|
|
2464
2591
|
}
|
|
2465
2592
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
2466
2593
|
let css = generatedCss;
|
|
2594
|
+
const distinctUserLayerParts = hasDistinctUserRawSource && hasUserCssLayerBlocks(generatedUserCssRawSource) ? splitUserCssLayerBlocks(generatedUserCssRawSource) : void 0;
|
|
2595
|
+
let restoredDistinctUserLayerCss = false;
|
|
2467
2596
|
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2468
2597
|
generatorTarget: generated.target,
|
|
2469
2598
|
generatorStyleOptions,
|
|
@@ -2493,10 +2622,26 @@ async function generateCssByGenerator(options) {
|
|
|
2493
2622
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2494
2623
|
}
|
|
2495
2624
|
}
|
|
2625
|
+
if (hasDistinctUserRawSource && distinctUserLayerParts) {
|
|
2626
|
+
const layerUserCss = await transformGeneratorUserCss(distinctUserLayerParts.layer, {
|
|
2627
|
+
generatorTarget: generated.target,
|
|
2628
|
+
generatorStyleOptions,
|
|
2629
|
+
cssUserHandlerOptions,
|
|
2630
|
+
styleHandler,
|
|
2631
|
+
importFallback: generatorOptions.importFallback,
|
|
2632
|
+
processed: userRawSourceProcessed
|
|
2633
|
+
});
|
|
2634
|
+
if (filterExistingCssRules(css, layerUserCss).trim().length > 0) {
|
|
2635
|
+
css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerUserCss), css);
|
|
2636
|
+
restoredDistinctUserLayerCss = true;
|
|
2637
|
+
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2496
2640
|
}
|
|
2497
2641
|
if (hasMatchedCssSourceFile || generated.target === "web") {
|
|
2498
2642
|
if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2499
|
-
const
|
|
2643
|
+
const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
|
|
2644
|
+
const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
|
|
2500
2645
|
generatorTarget: generated.target,
|
|
2501
2646
|
generatorStyleOptions,
|
|
2502
2647
|
cssUserHandlerOptions,
|
|
@@ -2504,10 +2649,11 @@ async function generateCssByGenerator(options) {
|
|
|
2504
2649
|
importFallback: generatorOptions.importFallback,
|
|
2505
2650
|
processed: userRawSourceProcessed
|
|
2506
2651
|
});
|
|
2507
|
-
const missingUserCss = isCssAlreadyRepresentedByMarkers(css,
|
|
2652
|
+
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, distinctUserCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
|
|
2508
2653
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2509
2654
|
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
|
|
2510
|
-
const
|
|
2655
|
+
const cleanedUserCssRawSource = removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource);
|
|
2656
|
+
const userCss = await transformGeneratorUserCss(restoredDistinctUserLayerCss && hasUserCssLayerBlocks(cleanedUserCssRawSource) ? splitUserCssLayerBlocks(cleanedUserCssRawSource).rest : cleanedUserCssRawSource, {
|
|
2511
2657
|
generatorTarget: generated.target,
|
|
2512
2658
|
generatorStyleOptions,
|
|
2513
2659
|
cssUserHandlerOptions,
|
|
@@ -2572,7 +2718,8 @@ async function generateCssByGenerator(options) {
|
|
|
2572
2718
|
css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2573
2719
|
}
|
|
2574
2720
|
if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2575
|
-
const
|
|
2721
|
+
const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
|
|
2722
|
+
const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
|
|
2576
2723
|
generatorTarget: generated.target,
|
|
2577
2724
|
generatorStyleOptions,
|
|
2578
2725
|
cssUserHandlerOptions,
|
|
@@ -2580,7 +2727,7 @@ async function generateCssByGenerator(options) {
|
|
|
2580
2727
|
importFallback: generatorOptions.importFallback,
|
|
2581
2728
|
processed: userRawSourceProcessed
|
|
2582
2729
|
});
|
|
2583
|
-
const missingUserCss = isCssAlreadyRepresentedByMarkers(css,
|
|
2730
|
+
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, distinctUserCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
|
|
2584
2731
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2585
2732
|
}
|
|
2586
2733
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
@@ -2889,10 +3036,66 @@ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
2889
3036
|
"mts",
|
|
2890
3037
|
"cts"
|
|
2891
3038
|
]);
|
|
3039
|
+
const TEMPLATE_SOURCE_CANDIDATE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3040
|
+
"html",
|
|
3041
|
+
"wxml",
|
|
3042
|
+
"axml",
|
|
3043
|
+
"jxml",
|
|
3044
|
+
"ksml",
|
|
3045
|
+
"ttml",
|
|
3046
|
+
"qml",
|
|
3047
|
+
"tyml",
|
|
3048
|
+
"xhsml",
|
|
3049
|
+
"swan",
|
|
3050
|
+
"vue",
|
|
3051
|
+
"uvue",
|
|
3052
|
+
"nvue",
|
|
3053
|
+
"mpx"
|
|
3054
|
+
]);
|
|
2892
3055
|
async function extractCandidatesFromSource(source, extension, options = {}) {
|
|
2893
3056
|
const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await extractSourceCandidates(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
|
|
2894
3057
|
const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
|
|
2895
3058
|
for (const candidate of scriptCandidates) candidates.add(candidate);
|
|
3059
|
+
const templateAttributeCandidates = await extractTemplateAttributeCandidates(source, extension, options);
|
|
3060
|
+
for (const candidate of templateAttributeCandidates) candidates.add(candidate);
|
|
3061
|
+
return candidates;
|
|
3062
|
+
}
|
|
3063
|
+
function isDefaultTemplateAttribute(name) {
|
|
3064
|
+
if (name === "class" || name === "hover-class" || name === "virtualhostclass") return true;
|
|
3065
|
+
const lowerName = name.toLowerCase();
|
|
3066
|
+
return lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass";
|
|
3067
|
+
}
|
|
3068
|
+
async function extractCandidateTokensFromTemplateAttributeValue(value, options) {
|
|
3069
|
+
return options.extractor ? await options.extractor(value, "html") : await extractSourceCandidates(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
3070
|
+
}
|
|
3071
|
+
async function extractTemplateAttributeCandidates(source, extension, options) {
|
|
3072
|
+
if (!TEMPLATE_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
3073
|
+
if (!options.customAttributesEntities?.length) return [];
|
|
3074
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
3075
|
+
const matchCustomAttribute = createAttributeMatcher(options.customAttributesEntities);
|
|
3076
|
+
const defaultTemplateHandlerEnabled = !options.disabledDefaultTemplateHandler;
|
|
3077
|
+
let tag = "";
|
|
3078
|
+
const tasks = [];
|
|
3079
|
+
const parser = new Parser({
|
|
3080
|
+
onopentagname(name) {
|
|
3081
|
+
tag = name;
|
|
3082
|
+
},
|
|
3083
|
+
onattribute(name, value) {
|
|
3084
|
+
if (!value) return;
|
|
3085
|
+
const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
|
|
3086
|
+
const shouldHandleCustom = matchCustomAttribute?.(tag, name) ?? false;
|
|
3087
|
+
if (!shouldHandleDefault && !shouldHandleCustom) return;
|
|
3088
|
+
tasks.push((async () => {
|
|
3089
|
+
for (const candidate of await extractCandidateTokensFromTemplateAttributeValue(value, options)) candidates.add(candidate);
|
|
3090
|
+
})());
|
|
3091
|
+
},
|
|
3092
|
+
onclosetag() {
|
|
3093
|
+
tag = "";
|
|
3094
|
+
}
|
|
3095
|
+
}, { xmlMode: true });
|
|
3096
|
+
parser.write(source);
|
|
3097
|
+
parser.end();
|
|
3098
|
+
await Promise.all(tasks);
|
|
2896
3099
|
return candidates;
|
|
2897
3100
|
}
|
|
2898
3101
|
async function extractScriptStringCandidates(source, extension, options) {
|
|
@@ -3042,8 +3245,21 @@ function resolveSourceCandidateExtension(id) {
|
|
|
3042
3245
|
const normalized = cleanUrl(id);
|
|
3043
3246
|
return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
|
|
3044
3247
|
}
|
|
3045
|
-
function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues, extractor) {
|
|
3046
|
-
return
|
|
3248
|
+
function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues, customAttributesEntities, disabledDefaultTemplateHandler, extractor) {
|
|
3249
|
+
return [
|
|
3250
|
+
extension,
|
|
3251
|
+
JSON.stringify(bareArbitraryValues ?? false),
|
|
3252
|
+
createCustomAttributesCacheSignature(customAttributesEntities),
|
|
3253
|
+
disabledDefaultTemplateHandler === true ? "default-template:off" : "default-template:on",
|
|
3254
|
+
extractor ? "custom" : "default",
|
|
3255
|
+
md5Hash(source)
|
|
3256
|
+
].join("\0");
|
|
3257
|
+
}
|
|
3258
|
+
function createCustomAttributesCacheSignature(customAttributesEntities) {
|
|
3259
|
+
return JSON.stringify((customAttributesEntities ?? []).map(([selector, props]) => [stringifyCustomAttributeToken(selector), Array.isArray(props) ? props.map(stringifyCustomAttributeToken) : stringifyCustomAttributeToken(props)]));
|
|
3260
|
+
}
|
|
3261
|
+
function stringifyCustomAttributeToken(token) {
|
|
3262
|
+
return typeof token === "string" ? `s:${token}` : `r:${token.source}/${token.flags}`;
|
|
3047
3263
|
}
|
|
3048
3264
|
async function extractCandidates(source, extension, options) {
|
|
3049
3265
|
return extractCandidatesFromSource(source, extension, options);
|
|
@@ -3090,7 +3306,7 @@ function createSourceCandidateStore(options = {}) {
|
|
|
3090
3306
|
const normalizedId = cleanUrl(id);
|
|
3091
3307
|
scanSourceById.set(normalizedId, source);
|
|
3092
3308
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
3093
|
-
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
3309
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.customAttributesEntities, options.disabledDefaultTemplateHandler, options.extractor);
|
|
3094
3310
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
3095
3311
|
if (cachedCandidates) {
|
|
3096
3312
|
replaceScanLayer(normalizedId, new Set(cachedCandidates));
|
|
@@ -3103,7 +3319,7 @@ function createSourceCandidateStore(options = {}) {
|
|
|
3103
3319
|
async function syncCss(id, source) {
|
|
3104
3320
|
const normalizedId = cleanUrl(id);
|
|
3105
3321
|
cssSourceById.set(normalizedId, source);
|
|
3106
|
-
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
3322
|
+
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.customAttributesEntities, options.disabledDefaultTemplateHandler, options.extractor);
|
|
3107
3323
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
3108
3324
|
if (cachedCandidates) {
|
|
3109
3325
|
replaceCssLayer(normalizedId, new Set(cachedCandidates));
|
|
@@ -3117,7 +3333,7 @@ function createSourceCandidateStore(options = {}) {
|
|
|
3117
3333
|
const normalizedId = cleanUrl(id);
|
|
3118
3334
|
transformSourceById.set(normalizedId, source);
|
|
3119
3335
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
3120
|
-
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
3336
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.customAttributesEntities, options.disabledDefaultTemplateHandler, options.extractor);
|
|
3121
3337
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
3122
3338
|
const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : await extractCandidates(source, extension, options);
|
|
3123
3339
|
if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
|
|
@@ -3452,4 +3668,4 @@ function createHmrTimingRecorder(bundler) {
|
|
|
3452
3668
|
};
|
|
3453
3669
|
}
|
|
3454
3670
|
//#endregion
|
|
3455
|
-
export {
|
|
3671
|
+
export { collectRawSourceClassSelectors as A, scoreTailwindV4CssSourceFileMatch as C, hasMiniProgramTailwindV4PreflightReset as D, finalizeMiniProgramGeneratorCss as E, annotateCssSourceTrace as F, createCssSourceTraceCacheSignature as I, createCssTokenSourceMap as L, hasBundlerGeneratedCssMarker as M, parseBundlerGeneratedCssMarkerBlocks as N, isSourceStyleRequest as O, stripBundlerGeneratedCssMarkers as P, isCssSourceTraceEnabled as R, splitLocalCssImports as S, createCssSourceOrderAppend$1 as T, mergeMarkedUserLayerComponentsCss as _, isSourceCandidateRequest as a, isPureLocalCssImportWrapper as b, createBundleRuntimeClassSetManager as c, generateCssByGenerator as d, validateCandidatesByGenerator as f, extractMarkedUserLayerComponentsCss as g, runWithConcurrency as h, createSourceCandidateStore as i, createBundlerGeneratedCssMarker as j, stripRequestQuery as k, collectStrictEscapedRuntimeCandidates as l, resolveTaskConcurrency as m, emitHmrTiming as n, resolveSourceCandidateScanFiles as o, pushConcurrentTaskFactories as p, createSourceCandidateCollector as r, extractCandidatesFromSource as s, createHmrTimingRecorder as t, createEscapeFragments as u, normalizeMiniProgramGeneratorCssSource as v, removeGeneratedSelectorCompatCss as w, rewriteLocalCssImportRequestsForOutput as x, normalizeMiniProgramImportShell as y, processCachedTask as z };
|