weapp-tailwindcss 5.2.7 → 5.2.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/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -3
- package/dist/bundlers/vite/module-identity.d.ts +9 -0
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +4 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -1
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -0
- package/dist/cli.js +1 -0
- package/dist/{context-YAvTyPV2.js → context-BMkbwnH8.js} +10 -23
- package/dist/{context-OqD_eBxQ.cjs → context-CByXWyhQ.cjs} +179 -25
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-BE34PYSC.cjs → generator-B0dCFlP1.cjs} +10 -0
- package/dist/{generator-DYeAa2-5.js → generator-BLpOsd5O.js} +10 -0
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-BydhuCbr.js → gulp-BWhCahA2.js} +4 -4
- package/dist/{gulp-Bun9iCRE.cjs → gulp-BdoorWb5.cjs} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Gs9P-QtZ.js → hmr-timing-CJocHeZr.js} +22 -14
- package/dist/{hmr-timing-D607CWrq.cjs → hmr-timing-DiYnyg_W.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-hVsoTfwL.cjs → options-zpZez7qe.cjs} +1 -1
- package/dist/{pipeline-helpers-BLpoT8fX.cjs → pipeline-helpers-CsNLoEX1.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{source-candidate-scan-signature-BGDNJE2r.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-CdjPWQqv.js → source-candidate-scan-signature-of-TmeOs.js} +3 -3
- package/dist/{style-options-B_ppaVIg.cjs → style-options-COpQc8fr.cjs} +2 -2
- package/dist/{tailwindcss-CTpCc_nd.js → tailwindcss-2zdmASlM.js} +1 -1
- package/dist/{tailwindcss-DcpiKvmJ.cjs → tailwindcss-LtnGCxF0.cjs} +2 -2
- package/dist/{transform-BbaPIji9.js → transform-DVGsr8cV.js} +24 -7
- package/dist/{transform-BUEyOCT7.cjs → transform-DzVJW6Dp.cjs} +24 -7
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/vite/author-apply.d.ts +1 -0
- package/dist/uni-app-x/vite/harmony-apply.d.ts +4 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +27 -0
- package/dist/uni-app-x/vite/style-request.d.ts +3 -0
- package/dist/uni-app-x/vite.d.ts +3 -24
- package/dist/{v4-generation-core-BrkM1vCs.cjs → v4-generation-core-BjHT6qGC.cjs} +22 -14
- package/dist/{vite-DM-U-Ins.js → vite-BJJqWc_F.js} +505 -188
- package/dist/{vite-n0mRgEcF.cjs → vite-V86H6PZa.cjs} +508 -191
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{webpack-BlUJf8Ru.js → webpack-CkeFhPY2.js} +6 -6
- package/dist/{webpack-Bf8yJwTO.cjs → webpack-CzQrloDg.cjs} +9 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
4
4
|
const require_object = require("./object-C_Vr6_S5.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
|
|
8
8
|
const require_wxml = require("./wxml-DSMNuUaP.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_context = require("./context-
|
|
11
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
12
|
-
const require_style_options = require("./style-options-
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-DiYnyg_W.cjs");
|
|
10
|
+
const require_context = require("./context-CByXWyhQ.cjs");
|
|
11
|
+
const require_tailwindcss = require("./tailwindcss-LtnGCxF0.cjs");
|
|
12
|
+
const require_style_options = require("./style-options-COpQc8fr.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-D9FXTD9a.cjs");
|
|
14
14
|
require("./logger-TlKT3xmR.cjs");
|
|
15
15
|
const require_css_imports = require("./css-imports-DfNC3e6a.cjs");
|
|
16
16
|
let node_fs = require("node:fs");
|
|
@@ -27,6 +27,7 @@ let micromatch = require("micromatch");
|
|
|
27
27
|
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
28
28
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
29
29
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
30
|
+
let node_url = require("node:url");
|
|
30
31
|
let node_buffer = require("node:buffer");
|
|
31
32
|
let node_async_hooks = require("node:async_hooks");
|
|
32
33
|
let comment_json = require("comment-json");
|
|
@@ -408,6 +409,7 @@ function resolveReferencePaths(styleSource, sourceId) {
|
|
|
408
409
|
return styleSource;
|
|
409
410
|
}
|
|
410
411
|
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
412
|
+
const pathApi = /^[a-z]:[\\/]/i.test(cleanSourceId) ? node_path.default.win32 : node_path.default;
|
|
411
413
|
root.walkAtRules("reference", (rule) => {
|
|
412
414
|
const quote = rule.params[0];
|
|
413
415
|
if (quote !== "\"" && quote !== "'") return;
|
|
@@ -415,7 +417,7 @@ function resolveReferencePaths(styleSource, sourceId) {
|
|
|
415
417
|
if (closingQuoteIndex <= 1) return;
|
|
416
418
|
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
417
419
|
if (!referencePath.startsWith(".")) return;
|
|
418
|
-
rule.params = `${quote}${
|
|
420
|
+
rule.params = `${quote}${pathApi.resolve(pathApi.dirname(cleanSourceId), referencePath).replaceAll("\\", "/")}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
419
421
|
});
|
|
420
422
|
return root.toString();
|
|
421
423
|
}
|
|
@@ -2321,6 +2323,8 @@ const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
|
2321
2323
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2322
2324
|
const SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
2323
2325
|
"*",
|
|
2326
|
+
":after",
|
|
2327
|
+
":before",
|
|
2324
2328
|
"::after",
|
|
2325
2329
|
"::before",
|
|
2326
2330
|
"::backdrop",
|
|
@@ -2332,6 +2336,14 @@ const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
2332
2336
|
"::after",
|
|
2333
2337
|
"::before"
|
|
2334
2338
|
]);
|
|
2339
|
+
const UNI_APP_WEB_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
2340
|
+
"uni-view",
|
|
2341
|
+
"uni-text",
|
|
2342
|
+
":after",
|
|
2343
|
+
":before",
|
|
2344
|
+
"::after",
|
|
2345
|
+
"::before"
|
|
2346
|
+
]);
|
|
2335
2347
|
const MINI_PROGRAM_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
2336
2348
|
"box-sizing",
|
|
2337
2349
|
"margin",
|
|
@@ -2438,14 +2450,24 @@ function isScopedUniversalTailwindPreflightRule(rule) {
|
|
|
2438
2450
|
const declarations = getRuleDeclarations(rule);
|
|
2439
2451
|
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
|
|
2440
2452
|
}
|
|
2453
|
+
function isScopedUniAppWebTailwindPreflightRule(rule) {
|
|
2454
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
2455
|
+
const declarations = getRuleDeclarations(rule);
|
|
2456
|
+
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && UNI_APP_WEB_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
|
|
2457
|
+
}
|
|
2441
2458
|
function isLikelyTailwindGlobalRule(rule) {
|
|
2442
2459
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2443
2460
|
const declarations = getRuleDeclarations(rule);
|
|
2444
|
-
return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
2461
|
+
return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
2445
2462
|
}
|
|
2446
2463
|
function isLikelyTailwindPropertyAtRule(atRule) {
|
|
2447
2464
|
return atRule.name.toLowerCase() === "property" && normalizeCssSignatureValue(atRule.params).startsWith("--tw-");
|
|
2448
2465
|
}
|
|
2466
|
+
function isLikelyTailwindLayerOrderAtRule(atRule) {
|
|
2467
|
+
if (atRule.name.toLowerCase() !== "layer" || atRule.nodes !== void 0) return false;
|
|
2468
|
+
const params = normalizeCssSignatureValue(atRule.params).replace(/\s+/g, "");
|
|
2469
|
+
return params === "properties" || params === "theme" || params === "base" || params === "theme,base,components,utilities";
|
|
2470
|
+
}
|
|
2449
2471
|
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
2450
2472
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2451
2473
|
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
@@ -2464,12 +2486,6 @@ function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
|
2464
2486
|
const declarations = getRuleDeclarations(rule);
|
|
2465
2487
|
return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
|
|
2466
2488
|
}
|
|
2467
|
-
function hasUnscopedMiniProgramTailwindPreflightRule(css) {
|
|
2468
|
-
return /(?:^|[{}])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{/.test(css);
|
|
2469
|
-
}
|
|
2470
|
-
function hasScopedMiniProgramTailwindContentInitRule(css) {
|
|
2471
|
-
return /(?:^|[{}])[^{}]*\.data-v-[\w-][^{}]*\{\s*--tw-content\s*:/.test(css);
|
|
2472
|
-
}
|
|
2473
2489
|
//#endregion
|
|
2474
2490
|
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2475
2491
|
function createDeclarationSignature(rule) {
|
|
@@ -2536,10 +2552,7 @@ function isRuleCoveredByRootCss(rule, coverage) {
|
|
|
2536
2552
|
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
2537
2553
|
if (!hasVueScopedAttr(css)) return css;
|
|
2538
2554
|
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
2539
|
-
const hasUnscopedMiniProgramPreflight = hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2540
|
-
const hasScopedMiniProgramContentInit = hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2541
2555
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2542
|
-
if (coverage.rules.size === 0 && coverage.atRules.size === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2543
2556
|
try {
|
|
2544
2557
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2545
2558
|
let changed = false;
|
|
@@ -2550,13 +2563,13 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
2550
2563
|
}
|
|
2551
2564
|
});
|
|
2552
2565
|
root.walkRules((rule) => {
|
|
2553
|
-
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule)) {
|
|
2566
|
+
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
|
|
2554
2567
|
rule.remove();
|
|
2555
2568
|
changed = true;
|
|
2556
2569
|
}
|
|
2557
2570
|
});
|
|
2558
2571
|
root.walkAtRules((atRule) => {
|
|
2559
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2572
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2560
2573
|
atRule.remove();
|
|
2561
2574
|
changed = true;
|
|
2562
2575
|
return;
|
|
@@ -2590,22 +2603,20 @@ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
|
2590
2603
|
if (css.trim().length === 0) return css;
|
|
2591
2604
|
const hasScopedCss = hasVueScopedAttr(css);
|
|
2592
2605
|
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2593
|
-
|
|
2594
|
-
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2595
|
-
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2606
|
+
if (rootSources.length === 0 && !hasScopedCss) return css;
|
|
2596
2607
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2597
2608
|
let nextCss = css;
|
|
2598
2609
|
try {
|
|
2599
2610
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2600
2611
|
let changed = false;
|
|
2601
2612
|
root.walkRules((rule) => {
|
|
2602
|
-
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule))) {
|
|
2613
|
+
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
|
|
2603
2614
|
rule.remove();
|
|
2604
2615
|
changed = true;
|
|
2605
2616
|
}
|
|
2606
2617
|
});
|
|
2607
2618
|
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2608
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2619
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2609
2620
|
atRule.remove();
|
|
2610
2621
|
changed = true;
|
|
2611
2622
|
return;
|
|
@@ -5089,7 +5100,7 @@ function injectHarmonyCssIntoMainAsset(bundle, cssSources, isMainCssAsset, plan,
|
|
|
5089
5100
|
return true;
|
|
5090
5101
|
}
|
|
5091
5102
|
async function handleUniAppXPostCssTasks(options) {
|
|
5092
|
-
const { bundle, debug,
|
|
5103
|
+
const { bundle, debug, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteProcessedCssAssetResults, isHarmonyAppStyleTarget, isNativeAppStyleTarget, onUpdate, opts, runtimeState, styleHandler, deferStylePlaceholderInjection } = options;
|
|
5093
5104
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
5094
5105
|
if (opts.appType !== "uni-app-x" && !isNativeAppStyleTarget && !isHarmonyAppStyleTarget) return applyStyleSources;
|
|
5095
5106
|
const emissionPlan = new require_v4_generation_core.AssetEmissionPlan();
|
|
@@ -5111,7 +5122,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5111
5122
|
const generated = await require_v4_generation_core.generateTailwindV4Css({
|
|
5112
5123
|
opts,
|
|
5113
5124
|
runtimeState,
|
|
5114
|
-
runtime: /* @__PURE__ */ new Set(
|
|
5125
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
5115
5126
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
5116
5127
|
file: outputFile,
|
|
5117
5128
|
outputFile,
|
|
@@ -5121,6 +5132,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5121
5132
|
isMainChunk: false
|
|
5122
5133
|
},
|
|
5123
5134
|
cssStage: "framework-processed",
|
|
5135
|
+
disableSourceScan: true,
|
|
5124
5136
|
getSourceCandidatesForEntries,
|
|
5125
5137
|
styleHandler,
|
|
5126
5138
|
debug
|
|
@@ -5651,6 +5663,53 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
5651
5663
|
return enabled;
|
|
5652
5664
|
}
|
|
5653
5665
|
//#endregion
|
|
5666
|
+
//#region src/uni-app-x/vite/author-apply.ts
|
|
5667
|
+
function normalizeSelector(selector) {
|
|
5668
|
+
return selector.replace(/\s+/g, " ").trim();
|
|
5669
|
+
}
|
|
5670
|
+
function atRuleKey(name, params) {
|
|
5671
|
+
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
5672
|
+
}
|
|
5673
|
+
/**
|
|
5674
|
+
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
5675
|
+
* utilities 和 property 注册复制进 scoped style 模块。
|
|
5676
|
+
*/
|
|
5677
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
|
|
5678
|
+
try {
|
|
5679
|
+
const authorRoot = _weapp_tailwindcss_postcss.postcss.parse(require_generator.removeTailwindSourceDirectives(authorCss, { importFallback: true }));
|
|
5680
|
+
const authorSelectors = /* @__PURE__ */ new Set();
|
|
5681
|
+
const authorAtRules = /* @__PURE__ */ new Set();
|
|
5682
|
+
authorRoot.walkRules((rule) => {
|
|
5683
|
+
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
|
|
5684
|
+
});
|
|
5685
|
+
authorRoot.walkAtRules((atRule) => {
|
|
5686
|
+
if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
5687
|
+
});
|
|
5688
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(generatedCss);
|
|
5689
|
+
let changed = false;
|
|
5690
|
+
root.walkRules((rule) => {
|
|
5691
|
+
if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
|
|
5692
|
+
rule.remove();
|
|
5693
|
+
changed = true;
|
|
5694
|
+
});
|
|
5695
|
+
root.walkAtRules((atRule) => {
|
|
5696
|
+
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
5697
|
+
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
5698
|
+
atRule.remove();
|
|
5699
|
+
changed = true;
|
|
5700
|
+
});
|
|
5701
|
+
root.walkComments((comment) => {
|
|
5702
|
+
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
5703
|
+
comment.remove();
|
|
5704
|
+
changed = true;
|
|
5705
|
+
}
|
|
5706
|
+
});
|
|
5707
|
+
return changed ? root.toString().trim() : generatedCss;
|
|
5708
|
+
} catch {
|
|
5709
|
+
return generatedCss;
|
|
5710
|
+
}
|
|
5711
|
+
}
|
|
5712
|
+
//#endregion
|
|
5654
5713
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
5655
5714
|
function createStableHash(input) {
|
|
5656
5715
|
let hash = 2166136261;
|
|
@@ -5661,23 +5720,43 @@ function createStableHash(input) {
|
|
|
5661
5720
|
return (hash >>> 0).toString(36);
|
|
5662
5721
|
}
|
|
5663
5722
|
function createUniAppXHarmonyApplyExpander(options) {
|
|
5723
|
+
const referenceBySourceId = /* @__PURE__ */ new Map();
|
|
5664
5724
|
const styleSources = /* @__PURE__ */ new Set();
|
|
5665
5725
|
const utilities = /* @__PURE__ */ new Set();
|
|
5666
|
-
function rememberSource(code, id) {
|
|
5726
|
+
function rememberSource(code, id, authoritative = false) {
|
|
5667
5727
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5728
|
+
const sourceKey = normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
5729
|
+
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
5668
5730
|
for (const source of sources) {
|
|
5669
5731
|
styleSources.add(source);
|
|
5732
|
+
try {
|
|
5733
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("reference", (rule) => {
|
|
5734
|
+
const reference = rule.toString();
|
|
5735
|
+
references.add(reference.endsWith(";") ? reference : `${reference};`);
|
|
5736
|
+
});
|
|
5737
|
+
} catch {}
|
|
5670
5738
|
for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
5671
5739
|
}
|
|
5740
|
+
if (references.size > 0) referenceBySourceId.set(sourceKey, references);
|
|
5741
|
+
else if (authoritative) referenceBySourceId.delete(sourceKey);
|
|
5742
|
+
}
|
|
5743
|
+
function prepareStyles(code, id) {
|
|
5744
|
+
if (!code.includes("@apply") || code.includes("@reference")) return code;
|
|
5745
|
+
const references = referenceBySourceId.get(normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
5746
|
+
if (references?.size !== 1) return code;
|
|
5747
|
+
return `${references.values().next().value}\n${code}`;
|
|
5672
5748
|
}
|
|
5673
5749
|
async function expandStyles(code, id, hookContext) {
|
|
5674
5750
|
if (!options.isHarmonyBuildTarget() || !code.includes("@apply")) return code;
|
|
5675
|
-
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5751
|
+
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(prepareStyles(code, id), id);
|
|
5676
5752
|
const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
|
|
5677
5753
|
if (sources.length === 0 || sourceUtilities.size === 0) return code;
|
|
5678
5754
|
const cssFile = node_path.default.resolve(options.getResolvedConfig()?.root ?? node_process.default.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)))}.css`);
|
|
5679
|
-
const
|
|
5755
|
+
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
5756
|
+
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
5680
5757
|
addWatchFile: hookContext.addWatchFile?.bind(hookContext),
|
|
5758
|
+
disableSourceScan: true,
|
|
5759
|
+
sourceCandidates: [],
|
|
5681
5760
|
transient: true
|
|
5682
5761
|
});
|
|
5683
5762
|
if (typeof generatedCss !== "string" || generatedCss.trim().length === 0) return code;
|
|
@@ -5685,49 +5764,178 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5685
5764
|
}
|
|
5686
5765
|
return {
|
|
5687
5766
|
expandStyles,
|
|
5767
|
+
prepareStyles,
|
|
5688
5768
|
rememberSource,
|
|
5689
5769
|
styleSources,
|
|
5690
5770
|
utilities
|
|
5691
5771
|
};
|
|
5692
5772
|
}
|
|
5693
5773
|
//#endregion
|
|
5774
|
+
//#region src/bundlers/vite/module-identity.ts
|
|
5775
|
+
const WINDOWS_DRIVE_RE = /^\/?[a-z]:[\\/]/i;
|
|
5776
|
+
const WINDOWS_UNC_RE = /^(?:\\\\|\/\/)/;
|
|
5777
|
+
function unique(values) {
|
|
5778
|
+
return [...new Set([...values].filter((value) => typeof value === "string" && value.length > 0))];
|
|
5779
|
+
}
|
|
5780
|
+
function decodeFileId(id) {
|
|
5781
|
+
try {
|
|
5782
|
+
return decodeURIComponent(id);
|
|
5783
|
+
} catch {
|
|
5784
|
+
return id;
|
|
5785
|
+
}
|
|
5786
|
+
}
|
|
5787
|
+
function stripViteFsPrefix(id) {
|
|
5788
|
+
if (!id.startsWith("/@fs/")) return id;
|
|
5789
|
+
const file = id.slice(5);
|
|
5790
|
+
return file.startsWith("/") || WINDOWS_DRIVE_RE.test(file) ? file : `/${file}`;
|
|
5791
|
+
}
|
|
5792
|
+
function stripFileProtocol(id) {
|
|
5793
|
+
if (!id.startsWith("file://")) return id;
|
|
5794
|
+
try {
|
|
5795
|
+
return (0, node_url.fileURLToPath)(id);
|
|
5796
|
+
} catch {
|
|
5797
|
+
return id;
|
|
5798
|
+
}
|
|
5799
|
+
}
|
|
5800
|
+
function isWindowsFile(file) {
|
|
5801
|
+
return WINDOWS_DRIVE_RE.test(file) || WINDOWS_UNC_RE.test(file);
|
|
5802
|
+
}
|
|
5803
|
+
function normalizeWindowsFile(file) {
|
|
5804
|
+
const withoutDriveSlash = /^\/[a-z]:[\\/]/i.test(file) ? file.slice(1) : file;
|
|
5805
|
+
return slash(node_path.default.win32.resolve(withoutDriveSlash));
|
|
5806
|
+
}
|
|
5807
|
+
function normalizeFile(file, root) {
|
|
5808
|
+
if (isWindowsFile(file) || isWindowsFile(root)) return normalizeWindowsFile(isWindowsFile(file) ? file : node_path.default.win32.resolve(root, file.replace(/^\//, "")));
|
|
5809
|
+
if (node_path.default.isAbsolute(file)) {
|
|
5810
|
+
if (file === root || file.startsWith(`${root}${node_path.default.sep}`) || (0, node_fs.existsSync)(file) || (0, node_fs.existsSync)(node_path.default.dirname(file))) return slash(node_path.default.resolve(file));
|
|
5811
|
+
const rootRelativeFile = node_path.default.resolve(root, file.slice(1));
|
|
5812
|
+
return (0, node_fs.existsSync)(rootRelativeFile) || (0, node_fs.existsSync)(node_path.default.dirname(rootRelativeFile)) ? slash(rootRelativeFile) : slash(node_path.default.resolve(file));
|
|
5813
|
+
}
|
|
5814
|
+
return slash(node_path.default.resolve(root, file));
|
|
5815
|
+
}
|
|
5816
|
+
function resolveRealFile(file) {
|
|
5817
|
+
if (node_process.default.platform !== "win32" && isWindowsFile(file)) return file;
|
|
5818
|
+
let current = file;
|
|
5819
|
+
const missingSegments = [];
|
|
5820
|
+
try {
|
|
5821
|
+
while (true) try {
|
|
5822
|
+
const resolvedParent = node_fs.realpathSync.native(current);
|
|
5823
|
+
return slash(node_path.default.join(resolvedParent, ...missingSegments));
|
|
5824
|
+
} catch {
|
|
5825
|
+
const parent = node_path.default.dirname(current);
|
|
5826
|
+
if (parent === current) return file;
|
|
5827
|
+
missingSegments.unshift(node_path.default.basename(current));
|
|
5828
|
+
current = parent;
|
|
5829
|
+
}
|
|
5830
|
+
} catch {
|
|
5831
|
+
return file;
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
function normalizeIdentityKey(file) {
|
|
5835
|
+
return isWindowsFile(file) || node_process.default.platform === "win32" ? file.toLowerCase() : file;
|
|
5836
|
+
}
|
|
5837
|
+
/**
|
|
5838
|
+
* 将 Vite URL、文件路径和 Windows 的等价路径收敛为同一个模块身份。
|
|
5839
|
+
*/
|
|
5840
|
+
function resolveViteModuleIdentity(id, root = node_process.default.cwd()) {
|
|
5841
|
+
const cleanId = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
5842
|
+
const decodedRoot = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(root));
|
|
5843
|
+
const normalizedRoot = isWindowsFile(decodedRoot) ? normalizeWindowsFile(decodedRoot) : slash(node_path.default.resolve(decodedRoot));
|
|
5844
|
+
const unwrappedId = stripFileProtocol(stripViteFsPrefix(cleanId));
|
|
5845
|
+
const file = unwrappedId.startsWith("\0") ? void 0 : normalizeFile(unwrappedId, normalizedRoot);
|
|
5846
|
+
const realFile = file ? resolveRealFile(file) : void 0;
|
|
5847
|
+
const key = realFile ? normalizeIdentityKey(realFile) : cleanId;
|
|
5848
|
+
const pathApi = isWindowsFile(normalizedRoot) ? node_path.default.win32 : node_path.default.posix;
|
|
5849
|
+
const relativeUrl = realFile && normalizeIdentityKey(realFile).startsWith(`${normalizeIdentityKey(normalizedRoot)}/`) ? `/${slash(pathApi.relative(normalizedRoot, realFile))}` : void 0;
|
|
5850
|
+
return {
|
|
5851
|
+
cleanId,
|
|
5852
|
+
file: realFile,
|
|
5853
|
+
key,
|
|
5854
|
+
lookupFiles: unique([file, realFile]),
|
|
5855
|
+
lookupIds: unique([
|
|
5856
|
+
id,
|
|
5857
|
+
cleanId,
|
|
5858
|
+
unwrappedId,
|
|
5859
|
+
file,
|
|
5860
|
+
realFile,
|
|
5861
|
+
realFile ? `/@fs/${realFile}` : void 0,
|
|
5862
|
+
relativeUrl
|
|
5863
|
+
])
|
|
5864
|
+
};
|
|
5865
|
+
}
|
|
5866
|
+
function hasSameViteModuleIdentity(left, right, root = node_process.default.cwd()) {
|
|
5867
|
+
if (!left || !right) return false;
|
|
5868
|
+
return resolveViteModuleIdentity(left, root).key === resolveViteModuleIdentity(right, root).key;
|
|
5869
|
+
}
|
|
5870
|
+
//#endregion
|
|
5694
5871
|
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5695
|
-
function
|
|
5872
|
+
async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
5696
5873
|
const modules = [];
|
|
5697
5874
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5698
5875
|
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
5876
|
+
const seenFileIdentities = /* @__PURE__ */ new Set();
|
|
5877
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5878
|
+
const collectModule = (mod) => {
|
|
5879
|
+
if (mod == null || seenModules.has(mod) || !acceptModule(mod)) return;
|
|
5880
|
+
seenModules.add(mod);
|
|
5881
|
+
modules.push(mod);
|
|
5882
|
+
};
|
|
5883
|
+
for (const id of ids) {
|
|
5884
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
5885
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5886
|
+
for (const moduleId of identity.lookupIds) {
|
|
5887
|
+
if (seenModuleIds.has(moduleId)) continue;
|
|
5888
|
+
seenModuleIds.add(moduleId);
|
|
5889
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(moduleId));
|
|
5890
|
+
if (moduleId.startsWith("/")) collectModule(await ctx.server.moduleGraph.getModuleByUrl?.(moduleId));
|
|
5891
|
+
}
|
|
5892
|
+
if (seenFileIdentities.has(identity.key)) continue;
|
|
5893
|
+
seenFileIdentities.add(identity.key);
|
|
5894
|
+
for (const file of identity.lookupFiles) for (const mod of ctx.server.moduleGraph.getModulesByFile?.(file) ?? []) collectModule(mod);
|
|
5895
|
+
}
|
|
5896
|
+
return modules;
|
|
5897
|
+
}
|
|
5898
|
+
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5699
5899
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5700
|
-
const outDir = ctx.server.config?.build?.outDir ?
|
|
5900
|
+
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
5701
5901
|
const isHotSourceStyleModule = (id) => {
|
|
5702
5902
|
if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
|
|
5703
5903
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5704
5904
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5705
|
-
if (outDir
|
|
5706
|
-
const
|
|
5707
|
-
if (
|
|
5905
|
+
if (outDir) {
|
|
5906
|
+
const identity = resolveViteModuleIdentity(file, root);
|
|
5907
|
+
if (identity.key === outDir.key || identity.key.startsWith(`${outDir.key}/`)) return false;
|
|
5708
5908
|
}
|
|
5709
5909
|
return true;
|
|
5710
5910
|
};
|
|
5711
|
-
const
|
|
5712
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
5911
|
+
const modules = await resolveHotModulesByIds(ctx, tailwindRootCssModuleIds, (mod) => {
|
|
5713
5912
|
const modId = mod.id ?? mod.url;
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
if (moduleId.length === 0 || seenModuleIds.has(moduleId)) continue;
|
|
5723
|
-
seenModuleIds.add(moduleId);
|
|
5724
|
-
const candidates = [ctx.server.moduleGraph.getModuleById(moduleId), ...ctx.server.moduleGraph.getModulesByFile(moduleId) ?? []];
|
|
5725
|
-
for (const mod of candidates) collectModule(mod);
|
|
5913
|
+
return isHotSourceStyleModule(modId);
|
|
5914
|
+
});
|
|
5915
|
+
const seenHotModules = new Set(modules);
|
|
5916
|
+
for (let index = 0; index < modules.length; index++) for (const importer of modules[index]?.importers ?? []) {
|
|
5917
|
+
const importerId = importer.id ?? importer.url;
|
|
5918
|
+
if (!seenHotModules.has(importer) && isHotSourceStyleModule(importerId)) {
|
|
5919
|
+
seenHotModules.add(importer);
|
|
5920
|
+
modules.push(importer);
|
|
5726
5921
|
}
|
|
5727
5922
|
}
|
|
5923
|
+
for (const mod of modules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
5728
5924
|
return modules;
|
|
5729
5925
|
}
|
|
5730
|
-
function
|
|
5926
|
+
async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
5927
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5928
|
+
const sourceIds = new Set(ids);
|
|
5929
|
+
for (const id of ids) {
|
|
5930
|
+
if (typeof id !== "string" || !/\.(?:uvue|nvue)(?:$|[?#])/i.test(id)) continue;
|
|
5931
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5932
|
+
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${(0, _weapp_tailwindcss_shared.cleanUrl)(lookupId)}?import`);
|
|
5933
|
+
}
|
|
5934
|
+
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
5935
|
+
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url);
|
|
5936
|
+
});
|
|
5937
|
+
}
|
|
5938
|
+
async function resolveHotSourceModules(ctx) {
|
|
5731
5939
|
const modules = [];
|
|
5732
5940
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5733
5941
|
const collectModule = (mod) => {
|
|
@@ -5737,10 +5945,27 @@ function resolveHotSourceModules(ctx) {
|
|
|
5737
5945
|
modules.push(mod);
|
|
5738
5946
|
};
|
|
5739
5947
|
for (const mod of ctx.modules) collectModule(mod);
|
|
5740
|
-
for (const mod of
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5948
|
+
for (const mod of await resolveHotSourceModulesByIds(ctx, [ctx.file])) collectModule(mod);
|
|
5949
|
+
return modules;
|
|
5950
|
+
}
|
|
5951
|
+
function mergeHotModulesByIdentity(root, ...groups) {
|
|
5952
|
+
const modules = [];
|
|
5953
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5954
|
+
const seenIdentities = /* @__PURE__ */ new Set();
|
|
5955
|
+
for (const mod of groups.flat()) {
|
|
5956
|
+
if (seenModules.has(mod)) continue;
|
|
5957
|
+
const ids = [
|
|
5958
|
+
mod.id,
|
|
5959
|
+
mod.url,
|
|
5960
|
+
mod.file
|
|
5961
|
+
].filter((id) => typeof id === "string" && id.length > 0);
|
|
5962
|
+
const moduleKind = ids.some(require_v4_generation_core.isSourceStyleRequest) ? "style" : "source";
|
|
5963
|
+
const keys = ids.map((id) => `${moduleKind}:${resolveViteModuleIdentity(id, root).key}`);
|
|
5964
|
+
if (keys.some((key) => seenIdentities.has(key))) continue;
|
|
5965
|
+
seenModules.add(mod);
|
|
5966
|
+
keys.forEach((key) => seenIdentities.add(key));
|
|
5967
|
+
modules.push(mod);
|
|
5968
|
+
}
|
|
5744
5969
|
return modules;
|
|
5745
5970
|
}
|
|
5746
5971
|
function resolveModuleHotUrl(mod) {
|
|
@@ -5759,23 +5984,32 @@ function isRootMiniProgramStyleUrl(file) {
|
|
|
5759
5984
|
}
|
|
5760
5985
|
function resolveCssHotUrl(id, root) {
|
|
5761
5986
|
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5762
|
-
const
|
|
5763
|
-
if (/^\/(
|
|
5764
|
-
if (isRootMiniProgramStyleUrl(
|
|
5765
|
-
return `${
|
|
5987
|
+
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5988
|
+
if (/^\/(?!@fs\/|[A-Z]:)/i.test(cleanId) && !cleanId.startsWith(slash(root))) {
|
|
5989
|
+
if (isRootMiniProgramStyleUrl(cleanId)) return;
|
|
5990
|
+
return `${cleanId}${suffix}`;
|
|
5766
5991
|
}
|
|
5992
|
+
const file = resolveViteModuleIdentity(id, root).file ?? cleanId;
|
|
5767
5993
|
if (!isAbsoluteFilePath(file)) return;
|
|
5768
5994
|
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5769
5995
|
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5770
5996
|
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5771
5997
|
return `/${slash(node_path.default.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5772
5998
|
}
|
|
5773
|
-
function includesHotModule(modules, target) {
|
|
5999
|
+
function includesHotModule(modules, target, root) {
|
|
5774
6000
|
const targetUrl = resolveModuleHotUrl(target);
|
|
5775
6001
|
const targetId = target.id;
|
|
5776
6002
|
return modules.some((mod) => {
|
|
5777
6003
|
if (mod === target) return true;
|
|
5778
|
-
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId
|
|
6004
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId || [
|
|
6005
|
+
target.id,
|
|
6006
|
+
target.url,
|
|
6007
|
+
target.file
|
|
6008
|
+
].some((targetIdentity) => [
|
|
6009
|
+
mod.id,
|
|
6010
|
+
mod.url,
|
|
6011
|
+
mod.file
|
|
6012
|
+
].some((moduleIdentity) => hasSameViteModuleIdentity(targetIdentity, moduleIdentity, root)));
|
|
5779
6013
|
});
|
|
5780
6014
|
}
|
|
5781
6015
|
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
@@ -5793,10 +6027,16 @@ function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
|
5793
6027
|
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5794
6028
|
});
|
|
5795
6029
|
}
|
|
5796
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
6030
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
5797
6031
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
5798
6032
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5799
6033
|
const updates = [];
|
|
6034
|
+
for (const id of fallbackSourceIds) {
|
|
6035
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
6036
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6037
|
+
seenUrls.add(hotUrl);
|
|
6038
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6039
|
+
}
|
|
5800
6040
|
for (const id of fallbackCssIds) {
|
|
5801
6041
|
if (!require_v4_generation_core.isSourceStyleRequest(id)) continue;
|
|
5802
6042
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
@@ -5805,7 +6045,7 @@ function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
|
5805
6045
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5806
6046
|
}
|
|
5807
6047
|
for (const mod of cssModules) {
|
|
5808
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
6048
|
+
if (includesHotModule(ctx.modules, mod, root)) continue;
|
|
5809
6049
|
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5810
6050
|
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5811
6051
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
@@ -5840,12 +6080,25 @@ function createUniAppXNativeHmrReloader(options) {
|
|
|
5840
6080
|
}
|
|
5841
6081
|
async function handleHotUpdate(ctx) {
|
|
5842
6082
|
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5843
|
-
|
|
6083
|
+
await options.syncSourceCandidates?.(ctx);
|
|
5844
6084
|
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5845
|
-
const
|
|
6085
|
+
const hasRuntimeClassChange = previousRuntimeClassSet !== void 0 && (currentRuntimeClassSet.size !== previousRuntimeClassSet.size || [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate)));
|
|
5846
6086
|
remember(currentRuntimeClassSet);
|
|
5847
|
-
|
|
5848
|
-
|
|
6087
|
+
const cssModules = ctx.server?.moduleGraph ? await resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
6088
|
+
const sourceModules = ctx.server?.moduleGraph ? await resolveHotSourceModules(ctx) : ctx.modules ?? [];
|
|
6089
|
+
const localStyleModules = hasRuntimeClassChange && ctx.server?.moduleGraph ? await resolveHotSourceModulesByIds(ctx, options.localStyleModuleIds) : [];
|
|
6090
|
+
for (const mod of /* @__PURE__ */ new Set([...sourceModules, ...localStyleModules])) ctx.server?.moduleGraph?.invalidateModule(mod);
|
|
6091
|
+
const modules = [.../* @__PURE__ */ new Set([
|
|
6092
|
+
...sourceModules,
|
|
6093
|
+
...localStyleModules,
|
|
6094
|
+
...cssModules
|
|
6095
|
+
])];
|
|
6096
|
+
const canAcceptUpdate = hasSelfAcceptingNonStyleHotModule([...sourceModules, ...localStyleModules]) || cssModules.length > 0;
|
|
6097
|
+
if (hasRuntimeClassChange && !canAcceptUpdate) {
|
|
6098
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
6099
|
+
return [];
|
|
6100
|
+
}
|
|
6101
|
+
return modules.length > 0 ? modules : void 0;
|
|
5849
6102
|
}
|
|
5850
6103
|
return {
|
|
5851
6104
|
handleHotUpdate,
|
|
@@ -5865,12 +6118,7 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
5865
6118
|
};
|
|
5866
6119
|
}
|
|
5867
6120
|
//#endregion
|
|
5868
|
-
//#region src/uni-app-x/vite.ts
|
|
5869
|
-
let transformUVuePromise;
|
|
5870
|
-
function loadTransformUVue() {
|
|
5871
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-BUEyOCT7.cjs")).then((mod) => mod.transformUVue));
|
|
5872
|
-
return transformUVuePromise;
|
|
5873
|
-
}
|
|
6121
|
+
//#region src/uni-app-x/vite/style-request.ts
|
|
5874
6122
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
5875
6123
|
"scss",
|
|
5876
6124
|
"sass",
|
|
@@ -5880,8 +6128,7 @@ const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
|
5880
6128
|
]);
|
|
5881
6129
|
const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
5882
6130
|
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
5883
|
-
const
|
|
5884
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6131
|
+
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
5885
6132
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
5886
6133
|
function isPreprocessorRequest(id, lang) {
|
|
5887
6134
|
const normalizedLang = lang?.toLowerCase();
|
|
@@ -5891,25 +6138,37 @@ function isPreprocessorRequest(id, lang) {
|
|
|
5891
6138
|
return PREPROCESSOR_EXT_RE.test(id);
|
|
5892
6139
|
}
|
|
5893
6140
|
function resolveUniAppXCssTarget(id) {
|
|
5894
|
-
return UVUE_NVUE_RE.test((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ? "uvue" : void 0;
|
|
5895
|
-
}
|
|
5896
|
-
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
5897
|
-
return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
|
|
6141
|
+
return UVUE_NVUE_RE$1.test((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ? "uvue" : void 0;
|
|
5898
6142
|
}
|
|
5899
6143
|
function isCssModuleExport(code) {
|
|
5900
6144
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5901
6145
|
}
|
|
6146
|
+
//#endregion
|
|
6147
|
+
//#region src/uni-app-x/vite.ts
|
|
6148
|
+
let transformUVuePromise;
|
|
6149
|
+
function loadTransformUVue() {
|
|
6150
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-DzVJW6Dp.cjs")).then((mod) => mod.transformUVue));
|
|
6151
|
+
return transformUVuePromise;
|
|
6152
|
+
}
|
|
6153
|
+
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
6154
|
+
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6155
|
+
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
6156
|
+
return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
|
|
6157
|
+
}
|
|
5902
6158
|
function createUniAppXPlugins(options) {
|
|
5903
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6159
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5904
6160
|
const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
|
|
5905
6161
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
5906
6162
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5907
6163
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6164
|
+
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
5908
6165
|
let componentLocalStyleEnabled;
|
|
5909
6166
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5910
6167
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5911
6168
|
ensureRuntimeClassSet,
|
|
5912
6169
|
isNativeAppBuildTarget,
|
|
6170
|
+
localStyleModuleIds: nativeLocalStyleModuleIds,
|
|
6171
|
+
syncSourceCandidates: syncSourceCandidatesForHotUpdate,
|
|
5913
6172
|
tailwindRootCssModuleIds,
|
|
5914
6173
|
viteProcessedCssSourceFiles
|
|
5915
6174
|
});
|
|
@@ -5934,13 +6193,15 @@ function createUniAppXPlugins(options) {
|
|
|
5934
6193
|
if (require_generator.resolveUniUtsPlatform().isAppHarmony) return true;
|
|
5935
6194
|
return isUniAppXHarmonyOutDir(getResolvedConfig()?.build?.outDir);
|
|
5936
6195
|
}
|
|
5937
|
-
function getStyleHandlerOptions(id) {
|
|
5938
|
-
const
|
|
6196
|
+
function getStyleHandlerOptions(id, source) {
|
|
6197
|
+
const isMainChunk = source === "tailwind-root" || mainCssChunkMatcher(id, appType);
|
|
6198
|
+
const cacheKey = `${isMainChunk ? "1" : "0"}:${source ?? ""}:${id}`;
|
|
5939
6199
|
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
5940
6200
|
if (!styleHandlerOptions) {
|
|
5941
6201
|
styleHandlerOptions = require_object.omitUndefined({
|
|
5942
|
-
isMainChunk
|
|
6202
|
+
isMainChunk,
|
|
5943
6203
|
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
6204
|
+
uniAppXCssSource: isNativeAppBuildTarget(id) ? source : void 0,
|
|
5944
6205
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5945
6206
|
postcssOptions: { options: {
|
|
5946
6207
|
from: id,
|
|
@@ -5960,16 +6221,24 @@ function createUniAppXPlugins(options) {
|
|
|
5960
6221
|
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
5961
6222
|
}
|
|
5962
6223
|
async function transformStyle(code, id, query, hookContext) {
|
|
5963
|
-
isNativeAppBuildTarget(id);
|
|
6224
|
+
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
5964
6225
|
const parsed = query ?? parseVueRequest(id).query;
|
|
5965
6226
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5966
6227
|
if (isCssModuleExport(code)) return;
|
|
5967
|
-
const
|
|
5968
|
-
|
|
6228
|
+
const hasTailwindRoot = require_generator.hasTailwindRootDirectives(code, { importFallback: true });
|
|
6229
|
+
const hasTailwindApply = require_generator.hasTailwindApplyDirective(code);
|
|
6230
|
+
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
6231
|
+
const isNativeSfcAuthorStyle = isNativeStyle && resolveUniAppXCssTarget(id) === "uvue";
|
|
6232
|
+
if (!shouldGenerateCss && (!isNativeStyle || isNativeSfcAuthorStyle)) return;
|
|
5969
6233
|
harmonyApply.rememberSource(code, id);
|
|
5970
|
-
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code,
|
|
5971
|
-
|
|
5972
|
-
|
|
6234
|
+
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(code, id) : code, {
|
|
6235
|
+
...hookContext,
|
|
6236
|
+
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
6237
|
+
sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
|
|
6238
|
+
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
6239
|
+
}) : void 0;
|
|
6240
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, code) : generatedCss : code;
|
|
6241
|
+
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
5973
6242
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
5974
6243
|
reportStyleWarnings(postcssResult);
|
|
5975
6244
|
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
@@ -5984,7 +6253,7 @@ function createUniAppXPlugins(options) {
|
|
|
5984
6253
|
getResolvedConfig,
|
|
5985
6254
|
isHarmonyBuildTarget,
|
|
5986
6255
|
async transformCss(css, id) {
|
|
5987
|
-
const result = await styleHandler(css, getStyleHandlerOptions(id));
|
|
6256
|
+
const result = await styleHandler(css, getStyleHandlerOptions(id, "author-apply"));
|
|
5988
6257
|
reportStyleWarnings(result);
|
|
5989
6258
|
return result.css;
|
|
5990
6259
|
}
|
|
@@ -6021,40 +6290,46 @@ function createUniAppXPlugins(options) {
|
|
|
6021
6290
|
if (!isEnabled()) return;
|
|
6022
6291
|
await nativeHmrReloader.refreshBaseline();
|
|
6023
6292
|
},
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6293
|
+
transform: {
|
|
6294
|
+
order: "pre",
|
|
6295
|
+
async handler(code, id) {
|
|
6296
|
+
if (!isEnabled()) return;
|
|
6297
|
+
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6298
|
+
if (isNativeAppBuildTarget(id)) {
|
|
6299
|
+
nativeLocalStyleModuleIds.add(id);
|
|
6300
|
+
nativeLocalStyleModuleIds.add((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
6301
|
+
}
|
|
6302
|
+
harmonyApply.rememberSource(code, id, true);
|
|
6303
|
+
const resolvedConfig = getResolvedConfig();
|
|
6304
|
+
const isServeCommand = resolvedConfig?.command === "serve";
|
|
6305
|
+
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
6306
|
+
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
6307
|
+
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6308
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6309
|
+
const transformUVue = await loadTransformUVue();
|
|
6310
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6311
|
+
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
6312
|
+
const result = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle ? transformUVue(code, id, jsHandler, currentRuntimeSet, require_object.omitUndefined({
|
|
6313
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6314
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6315
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6316
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
6317
|
+
})) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6318
|
+
if (result?.code) {
|
|
6319
|
+
harmonyApply.rememberSource(result.code, id);
|
|
6320
|
+
const expandedCode = await harmonyApply.expandStyles(result.code, id, this);
|
|
6321
|
+
if (expandedCode !== result.code) return {
|
|
6322
|
+
code: expandedCode,
|
|
6323
|
+
map: null
|
|
6324
|
+
};
|
|
6325
|
+
}
|
|
6326
|
+
return result;
|
|
6051
6327
|
}
|
|
6052
|
-
return result;
|
|
6053
6328
|
},
|
|
6054
6329
|
async handleHotUpdate(ctx) {
|
|
6055
6330
|
if (!isEnabled()) return;
|
|
6056
6331
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
6057
|
-
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
6332
|
+
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6058
6333
|
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
6059
6334
|
},
|
|
6060
6335
|
async watchChange(id) {
|
|
@@ -6083,7 +6358,12 @@ function createUniAppXPlugins(options) {
|
|
|
6083
6358
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApply.utilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
6084
6359
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
6085
6360
|
const harmonyApplyCssFile = node_path.default.resolve(getResolvedConfig()?.root ?? node_process.default.cwd(), "uni-app-x-harmony-apply.css");
|
|
6086
|
-
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
6361
|
+
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), {
|
|
6362
|
+
addWatchFile: this?.addWatchFile?.bind(this),
|
|
6363
|
+
disableSourceScan: true,
|
|
6364
|
+
sourceCandidates: [],
|
|
6365
|
+
transient: true
|
|
6366
|
+
});
|
|
6087
6367
|
if (typeof generatedCss === "string" && generatedCss.trim().length > 0) cssSources.push(generatedCss);
|
|
6088
6368
|
}
|
|
6089
6369
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
@@ -7800,12 +8080,11 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7800
8080
|
});
|
|
7801
8081
|
};
|
|
7802
8082
|
collectViteProcessedCssAssets();
|
|
7803
|
-
const createHarmonyBundleStyleSources = async (
|
|
8083
|
+
const createHarmonyBundleStyleSources = async () => {
|
|
7804
8084
|
const cssSources = collectViteProcessedCssSources(getViteProcessedCssAssetResults);
|
|
7805
8085
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
7806
8086
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
7807
8087
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
7808
|
-
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
7809
8088
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7810
8089
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
7811
8090
|
file: "uni-app-x-harmony-apply.css"
|
|
@@ -7813,7 +8092,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7813
8092
|
const generated = await require_v4_generation_core.generateTailwindV4Css({
|
|
7814
8093
|
opts,
|
|
7815
8094
|
runtimeState,
|
|
7816
|
-
runtime:
|
|
8095
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
7817
8096
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
7818
8097
|
file: "uni-app-x-harmony-apply.css",
|
|
7819
8098
|
outputFile: "uni-app-x-harmony-apply.css",
|
|
@@ -7823,6 +8102,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7823
8102
|
isMainChunk: false
|
|
7824
8103
|
},
|
|
7825
8104
|
cssStage: "framework-processed",
|
|
8105
|
+
disableSourceScan: true,
|
|
7826
8106
|
getSourceCandidatesForEntries,
|
|
7827
8107
|
generatorPlatform,
|
|
7828
8108
|
styleHandler: opts.styleHandler,
|
|
@@ -7831,9 +8111,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7831
8111
|
if (generated?.css) cssSources.push(annotateCss(generated.css));
|
|
7832
8112
|
return cssSources;
|
|
7833
8113
|
};
|
|
7834
|
-
const injectHarmonyBundleStyles = async (
|
|
8114
|
+
const injectHarmonyBundleStyles = async () => {
|
|
7835
8115
|
if (!isHarmonyAppStyleTarget) return;
|
|
7836
|
-
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources(
|
|
8116
|
+
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources() })) debug("uni-app-x harmony bundle styles inject");
|
|
7837
8117
|
};
|
|
7838
8118
|
const isCssOutputAssetEntry = (entry) => {
|
|
7839
8119
|
const [bundleFile, output] = entry;
|
|
@@ -7970,7 +8250,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7970
8250
|
bundle,
|
|
7971
8251
|
writeTargets
|
|
7972
8252
|
});
|
|
7973
|
-
await injectHarmonyBundleStyles(
|
|
8253
|
+
await injectHarmonyBundleStyles();
|
|
7974
8254
|
collectViteProcessedCssAssets();
|
|
7975
8255
|
injectViteProcessedCssIntoMainCss();
|
|
7976
8256
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
@@ -8533,6 +8813,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
8533
8813
|
async transform(code, id) {
|
|
8534
8814
|
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
8535
8815
|
if (!hasViteCssGenerationDirective(code)) return;
|
|
8816
|
+
if (options.shouldDeferGeneration?.(id, code)) return;
|
|
8536
8817
|
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
8537
8818
|
const generatedCss = await options.generateCss(id, code, {
|
|
8538
8819
|
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
@@ -8689,15 +8970,19 @@ function createViteHmrCandidateState(options) {
|
|
|
8689
8970
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8690
8971
|
...change,
|
|
8691
8972
|
file,
|
|
8692
|
-
runtimeAffecting: changeOptions.runtimeAffecting === true || require_v4_generation_core.isSourceStyleRequest(file) || WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(options.getSourceCandidate(file) ?? "")
|
|
8973
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || require_v4_generation_core.isSourceStyleRequest(file) || WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(options.getSourceCandidate(file) ?? "")
|
|
8693
8974
|
});
|
|
8694
8975
|
const apply = (change) => {
|
|
8695
8976
|
if (require_v4_generation_core.isSourceStyleRequest(change.file)) {
|
|
8696
8977
|
clear();
|
|
8697
8978
|
return change;
|
|
8698
8979
|
}
|
|
8980
|
+
if (change.runtimeAffecting) {
|
|
8981
|
+
queueFullRegeneration();
|
|
8982
|
+
return change;
|
|
8983
|
+
}
|
|
8699
8984
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
8700
|
-
if (preserveDeletedCss
|
|
8985
|
+
if (preserveDeletedCss) {
|
|
8701
8986
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
8702
8987
|
else if (!pendingChange) clear();
|
|
8703
8988
|
return change;
|
|
@@ -8957,6 +9242,11 @@ function sameStringList(first, second) {
|
|
|
8957
9242
|
//#endregion
|
|
8958
9243
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8959
9244
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
9245
|
+
const hasDifferentHotModules = (left, right) => left.length !== right.length || left.some((mod, index) => mod !== right[index]);
|
|
9246
|
+
const hasTemplateHotSourceModule = (modules) => modules.some((mod) => {
|
|
9247
|
+
const request = mod.url ?? mod.id;
|
|
9248
|
+
return typeof request === "string" && /\.(?:uvue|nvue)(?:\?import)?$/i.test(request);
|
|
9249
|
+
});
|
|
8960
9250
|
return {
|
|
8961
9251
|
name: `${require_context.vitePluginName}:source-candidates`,
|
|
8962
9252
|
enforce: "pre",
|
|
@@ -9022,60 +9312,68 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9022
9312
|
await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9023
9313
|
}, { emit: false });
|
|
9024
9314
|
},
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
mod.
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
if (
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9315
|
+
handleHotUpdate: {
|
|
9316
|
+
order: "post",
|
|
9317
|
+
async handler(ctx) {
|
|
9318
|
+
require_v4_generation_core.recordCompilationDependencyChanges(options.runtimeState, require_v4_generation_core.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))]));
|
|
9319
|
+
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9320
|
+
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && require_v4_generation_core.isSourceCandidateRequest(ctx.file);
|
|
9321
|
+
if (isSourceCandidateHotUpdate && require_v4_generation_core.isSourceStyleRequest(ctx.file)) {
|
|
9322
|
+
for (const mod of ctx.modules) for (const id of [
|
|
9323
|
+
mod.id,
|
|
9324
|
+
mod.url,
|
|
9325
|
+
mod.file
|
|
9326
|
+
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
9327
|
+
}
|
|
9328
|
+
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9329
|
+
if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
|
|
9330
|
+
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
9331
|
+
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9332
|
+
}
|
|
9333
|
+
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9334
|
+
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9335
|
+
let canUseHmrCandidateAppend = false;
|
|
9336
|
+
if (isSourceCandidateHotUpdate) {
|
|
9337
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
9338
|
+
const preserveDeletedCssInHmr = options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
9339
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
9340
|
+
if (!canUseHmrCandidateAppend) {
|
|
9341
|
+
if (sourceCandidateChange === void 0) {
|
|
9342
|
+
options.hmrCandidateState.clear();
|
|
9343
|
+
if (!preserveDeletedCssInHmr && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.queueFullRegeneration();
|
|
9344
|
+
}
|
|
9345
|
+
if (isWebLikeHotUpdate) {
|
|
9346
|
+
await options.refreshRuntimeStateForAutoCssSources?.(true);
|
|
9347
|
+
await options.sourceScanSession.sync({ force: true });
|
|
9348
|
+
}
|
|
9056
9349
|
}
|
|
9057
9350
|
}
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9351
|
+
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9352
|
+
const cssModules = await resolveHotTailwindCssModules(ctx, require_v4_generation_core.isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9353
|
+
const hotRoot = ctx.server.config?.root ?? node_process.default.cwd();
|
|
9354
|
+
const sourceModules = isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9355
|
+
const hasHmrCandidateAppend = options.hmrCandidateState.hasPendingCandidateAppend() || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
9356
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && options.isUniViteProject())) {
|
|
9357
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9358
|
+
return [];
|
|
9359
|
+
}
|
|
9360
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.isNuxtPageMacroHotModule(mod.id ?? mod.url))) {
|
|
9361
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9362
|
+
return [];
|
|
9363
|
+
}
|
|
9364
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
9365
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9366
|
+
return [];
|
|
9367
|
+
}
|
|
9368
|
+
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
9369
|
+
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9370
|
+
if (hasHmrCandidateAppend) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
|
|
9371
|
+
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
9372
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
9373
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
9374
|
+
return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, ctx.modules, cssModules) : void 0;
|
|
9375
|
+
}, { emit: false });
|
|
9376
|
+
}
|
|
9079
9377
|
},
|
|
9080
9378
|
async buildStart() {
|
|
9081
9379
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
@@ -9087,6 +9385,11 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9087
9385
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9088
9386
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9089
9387
|
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9388
|
+
async function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx) {
|
|
9389
|
+
const source = typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9390
|
+
await sourceScanSession.syncChangedFile(ctx.file, source);
|
|
9391
|
+
await sourceScanSession.waitForPendingSyncs();
|
|
9392
|
+
}
|
|
9090
9393
|
function createFrameworkSourceScanSession(options) {
|
|
9091
9394
|
const sourceCandidateScanCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9092
9395
|
let sourceScanEntries;
|
|
@@ -9249,12 +9552,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9249
9552
|
function createFrameworkTailwindRootCss(options) {
|
|
9250
9553
|
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
9251
9554
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
9252
|
-
const normalizeSourceFile = (id) =>
|
|
9555
|
+
const normalizeSourceFile = (id) => resolveViteModuleIdentity(id).key;
|
|
9253
9556
|
const rememberModule = (id) => {
|
|
9254
9557
|
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
9255
9558
|
moduleIds.add(id);
|
|
9256
|
-
const
|
|
9257
|
-
if (require_v4_generation_core.isSourceStyleRequest(cleanId)) moduleIds.add(
|
|
9559
|
+
const identity = resolveViteModuleIdentity(id);
|
|
9560
|
+
if (require_v4_generation_core.isSourceStyleRequest(identity.cleanId)) for (const moduleId of identity.lookupIds) moduleIds.add(moduleId);
|
|
9258
9561
|
};
|
|
9259
9562
|
const register = async (id, code) => {
|
|
9260
9563
|
rememberModule(id);
|
|
@@ -9558,7 +9861,8 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9558
9861
|
generatedClassSetByFile,
|
|
9559
9862
|
getCommand: () => resolvedConfig?.command,
|
|
9560
9863
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9561
|
-
getSourceCandidate: (file) => sourceCandidateCollector.source(file)
|
|
9864
|
+
getSourceCandidate: (file) => sourceCandidateCollector.source(file),
|
|
9865
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(file))
|
|
9562
9866
|
});
|
|
9563
9867
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9564
9868
|
cssMemory,
|
|
@@ -9667,7 +9971,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9667
9971
|
const transient = hookContext?.transient === true;
|
|
9668
9972
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9669
9973
|
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
9670
|
-
const runtime = fullRuntime;
|
|
9974
|
+
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9671
9975
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9672
9976
|
css: generatorTransformCode,
|
|
9673
9977
|
cssPipelineContext,
|
|
@@ -9740,8 +10044,8 @@ ${previousTracedCss}`;
|
|
|
9740
10044
|
previousCss: previousGeneratorCss,
|
|
9741
10045
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
9742
10046
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
9743
|
-
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
9744
|
-
disableSourceScan:
|
|
10047
|
+
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
10048
|
+
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
9745
10049
|
cssStage: hookContext?.cssStage,
|
|
9746
10050
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
9747
10051
|
}), {
|
|
@@ -9795,7 +10099,7 @@ ${previousTracedCss}`;
|
|
|
9795
10099
|
source: tracedCss
|
|
9796
10100
|
});
|
|
9797
10101
|
markViteProcessedCssSource(file);
|
|
9798
|
-
rememberTailwindRootCssModule(id);
|
|
10102
|
+
if (require_generator.hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
9799
10103
|
recordGeneratorCandidates(fullRuntime);
|
|
9800
10104
|
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
9801
10105
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
@@ -9808,6 +10112,11 @@ ${previousTracedCss}`;
|
|
|
9808
10112
|
return `${require_v4_generation_core.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
9809
10113
|
${tracedCss}`;
|
|
9810
10114
|
};
|
|
10115
|
+
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
10116
|
+
...createCssPipelineContext(),
|
|
10117
|
+
code,
|
|
10118
|
+
id
|
|
10119
|
+
}) === true;
|
|
9811
10120
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
9812
10121
|
getAppType: () => opts.appType,
|
|
9813
10122
|
generateTailwindCss: generateTailwindCssForVitePipeline,
|
|
@@ -9815,7 +10124,7 @@ ${tracedCss}`;
|
|
|
9815
10124
|
onTailwindRootCss: registerTailwindRootCss,
|
|
9816
10125
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
9817
10126
|
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
9818
|
-
shouldDeferGeneration: (
|
|
10127
|
+
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports && require_generator.hasTailwindRootDirectives(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }) || shouldDeferFrameworkPreTransformGeneration(id, code),
|
|
9819
10128
|
shouldOwnTailwindGeneration,
|
|
9820
10129
|
shouldRewrite: shouldRewriteCssImports,
|
|
9821
10130
|
weappTailwindcssDirPosix
|
|
@@ -9898,6 +10207,7 @@ ${tracedCss}`;
|
|
|
9898
10207
|
getRememberedMainCssSource: cssMemory.getRememberedCssSourceEntry
|
|
9899
10208
|
});
|
|
9900
10209
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10210
|
+
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
9901
10211
|
const prepareTailwindGeneration = async () => {
|
|
9902
10212
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
9903
10213
|
await sourceScanSession.sync();
|
|
@@ -9914,6 +10224,7 @@ ${tracedCss}`;
|
|
|
9914
10224
|
mainCssChunkMatcher,
|
|
9915
10225
|
runtimeState,
|
|
9916
10226
|
styleHandler,
|
|
10227
|
+
syncSourceCandidatesForHotUpdate,
|
|
9917
10228
|
tailwindRootCssModuleIds,
|
|
9918
10229
|
uniAppX,
|
|
9919
10230
|
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
@@ -9983,12 +10294,14 @@ ${tracedCss}`;
|
|
|
9983
10294
|
syncCssEntriesFromAnchor
|
|
9984
10295
|
});
|
|
9985
10296
|
const plugins = [
|
|
10297
|
+
...extraPlugins,
|
|
9986
10298
|
...rewritePlugins,
|
|
9987
10299
|
sourceCandidatesPlugin,
|
|
9988
10300
|
...createViteCssGenerationPlugins({
|
|
9989
10301
|
generateCss: generateTailwindCssForVitePipeline,
|
|
9990
10302
|
getCommand: () => resolvedConfig?.command,
|
|
9991
10303
|
onTailwindRootCss: registerTailwindRootCss,
|
|
10304
|
+
shouldDeferGeneration: shouldDeferFrameworkPreTransformGeneration,
|
|
9992
10305
|
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
9993
10306
|
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
9994
10307
|
}),
|
|
@@ -10011,7 +10324,6 @@ ${tracedCss}`;
|
|
|
10011
10324
|
},
|
|
10012
10325
|
postPlugin
|
|
10013
10326
|
];
|
|
10014
|
-
plugins.push(...extraPlugins);
|
|
10015
10327
|
plugins.push(cssFinalizerOutputPlugin);
|
|
10016
10328
|
plugins.push(...require_source_candidate_scan_signature.createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|
|
10017
10329
|
return plugins;
|
|
@@ -10273,7 +10585,8 @@ function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
|
10273
10585
|
//#endregion
|
|
10274
10586
|
//#region src/bundlers/vite/frameworks/uni-app-x/index.ts
|
|
10275
10587
|
function isUniAppXNativeAppStyleTarget(context) {
|
|
10276
|
-
|
|
10588
|
+
const stylePlatform = context?.resolveStylePlatform?.();
|
|
10589
|
+
return require_generator.resolveUniUtsPlatform().isApp || stylePlatform === "app" || stylePlatform === "app-plus" || stylePlatform?.startsWith("app-") === true || isUniAppXNativeAppOutDir(context?.resolvedConfig?.build?.outDir) || isUniAppXNativeAppOutDir(context?.resolvedConfig?.root);
|
|
10277
10590
|
}
|
|
10278
10591
|
function isUniAppXHarmonyAppStyleTarget(context) {
|
|
10279
10592
|
const uniUtsPlatform = require_generator.resolveUniUtsPlatform();
|
|
@@ -10300,6 +10613,9 @@ const uniAppXCssPipelineStrategy = {
|
|
|
10300
10613
|
if (!context.cssHandlerOptions.isMainChunk && require_generator.hasTailwindApplyDirective(context.generatorCode)) return false;
|
|
10301
10614
|
return true;
|
|
10302
10615
|
},
|
|
10616
|
+
shouldDeferPreTransformTailwindGeneration(context) {
|
|
10617
|
+
return resolveUniAppXCssTarget(context.id) === "uvue" && require_generator.hasTailwindApplyDirective(context.code) && !require_generator.hasTailwindRootDirectives(context.code, { importFallback: true });
|
|
10618
|
+
},
|
|
10303
10619
|
transformGeneratedCss(css, context) {
|
|
10304
10620
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
10305
10621
|
return withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
@@ -10326,6 +10642,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10326
10642
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10327
10643
|
runtimeState: context.runtimeState,
|
|
10328
10644
|
styleHandler: context.styleHandler,
|
|
10645
|
+
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
|
10329
10646
|
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10330
10647
|
uniAppX: context.uniAppX,
|
|
10331
10648
|
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|