weapp-tailwindcss 5.2.7 → 5.2.9
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/generate-bundle/finalize/root-import-shell.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/types.d.ts +6 -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 +4 -1
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +4 -2
- package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +4 -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-DhDe9eSf.js} +131 -15
- package/dist/{transform-BUEyOCT7.cjs → transform-GzbxfNGA.cjs} +130 -14
- package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
- package/dist/uni-app-x/component-local-style.d.ts +2 -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 +29 -0
- package/dist/uni-app-x/vite/style-request.d.ts +15 -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-8l9_S4Qi.js} +680 -230
- package/dist/{vite-n0mRgEcF.cjs → vite-Dcx59GRQ.cjs} +683 -233
- 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
|
|
@@ -5261,7 +5273,7 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
5261
5273
|
//#endregion
|
|
5262
5274
|
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
5263
5275
|
async function finalizeGenerateBundle(options) {
|
|
5264
|
-
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
5276
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pendingRememberedCssReplayUpdates, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
|
|
5265
5277
|
const tasksStart = performance.now();
|
|
5266
5278
|
if (cssTaskFactories.length > 0) {
|
|
5267
5279
|
const cssTask = require_v4_generation_core.runWithConcurrency(cssTaskFactories, resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion)).then(() => void 0);
|
|
@@ -5307,7 +5319,7 @@ async function finalizeGenerateBundle(options) {
|
|
|
5307
5319
|
});
|
|
5308
5320
|
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
5309
5321
|
const injectStartedAt = performance.now();
|
|
5310
|
-
|
|
5322
|
+
let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5311
5323
|
opts,
|
|
5312
5324
|
cssPipelineStrategy,
|
|
5313
5325
|
createCssPipelineContext,
|
|
@@ -5324,6 +5336,26 @@ async function finalizeGenerateBundle(options) {
|
|
|
5324
5336
|
onUpdate,
|
|
5325
5337
|
recordTimingDetail
|
|
5326
5338
|
});
|
|
5339
|
+
if (pendingRememberedCssReplayUpdates.length > 0) {
|
|
5340
|
+
for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
5341
|
+
injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
5342
|
+
opts,
|
|
5343
|
+
cssPipelineStrategy,
|
|
5344
|
+
createCssPipelineContext,
|
|
5345
|
+
getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
|
|
5346
|
+
css: update.css,
|
|
5347
|
+
injectIntoMain: update.injectIntoMain,
|
|
5348
|
+
outputFile: update.outputFile
|
|
5349
|
+
}]),
|
|
5350
|
+
markCssAssetProcessed,
|
|
5351
|
+
recordCssAssetResult,
|
|
5352
|
+
transformCss: transformWebTargetCss,
|
|
5353
|
+
debug,
|
|
5354
|
+
onUpdate,
|
|
5355
|
+
recordTimingDetail
|
|
5356
|
+
});
|
|
5357
|
+
debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
|
|
5358
|
+
}
|
|
5327
5359
|
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
5328
5360
|
return injected;
|
|
5329
5361
|
};
|
|
@@ -5651,6 +5683,53 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
5651
5683
|
return enabled;
|
|
5652
5684
|
}
|
|
5653
5685
|
//#endregion
|
|
5686
|
+
//#region src/uni-app-x/vite/author-apply.ts
|
|
5687
|
+
function normalizeSelector(selector) {
|
|
5688
|
+
return selector.replace(/\s+/g, " ").trim();
|
|
5689
|
+
}
|
|
5690
|
+
function atRuleKey(name, params) {
|
|
5691
|
+
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
5692
|
+
}
|
|
5693
|
+
/**
|
|
5694
|
+
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
5695
|
+
* utilities 和 property 注册复制进 scoped style 模块。
|
|
5696
|
+
*/
|
|
5697
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
|
|
5698
|
+
try {
|
|
5699
|
+
const authorRoot = _weapp_tailwindcss_postcss.postcss.parse(require_generator.removeTailwindSourceDirectives(authorCss, { importFallback: true }));
|
|
5700
|
+
const authorSelectors = /* @__PURE__ */ new Set();
|
|
5701
|
+
const authorAtRules = /* @__PURE__ */ new Set();
|
|
5702
|
+
authorRoot.walkRules((rule) => {
|
|
5703
|
+
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
|
|
5704
|
+
});
|
|
5705
|
+
authorRoot.walkAtRules((atRule) => {
|
|
5706
|
+
if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
5707
|
+
});
|
|
5708
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(generatedCss);
|
|
5709
|
+
let changed = false;
|
|
5710
|
+
root.walkRules((rule) => {
|
|
5711
|
+
if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
|
|
5712
|
+
rule.remove();
|
|
5713
|
+
changed = true;
|
|
5714
|
+
});
|
|
5715
|
+
root.walkAtRules((atRule) => {
|
|
5716
|
+
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
5717
|
+
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
5718
|
+
atRule.remove();
|
|
5719
|
+
changed = true;
|
|
5720
|
+
});
|
|
5721
|
+
root.walkComments((comment) => {
|
|
5722
|
+
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
5723
|
+
comment.remove();
|
|
5724
|
+
changed = true;
|
|
5725
|
+
}
|
|
5726
|
+
});
|
|
5727
|
+
return changed ? root.toString().trim() : generatedCss;
|
|
5728
|
+
} catch {
|
|
5729
|
+
return generatedCss;
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
//#endregion
|
|
5654
5733
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
5655
5734
|
function createStableHash(input) {
|
|
5656
5735
|
let hash = 2166136261;
|
|
@@ -5661,23 +5740,43 @@ function createStableHash(input) {
|
|
|
5661
5740
|
return (hash >>> 0).toString(36);
|
|
5662
5741
|
}
|
|
5663
5742
|
function createUniAppXHarmonyApplyExpander(options) {
|
|
5743
|
+
const referenceBySourceId = /* @__PURE__ */ new Map();
|
|
5664
5744
|
const styleSources = /* @__PURE__ */ new Set();
|
|
5665
5745
|
const utilities = /* @__PURE__ */ new Set();
|
|
5666
|
-
function rememberSource(code, id) {
|
|
5746
|
+
function rememberSource(code, id, authoritative = false) {
|
|
5667
5747
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5748
|
+
const sourceKey = normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
5749
|
+
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
5668
5750
|
for (const source of sources) {
|
|
5669
5751
|
styleSources.add(source);
|
|
5752
|
+
try {
|
|
5753
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("reference", (rule) => {
|
|
5754
|
+
const reference = rule.toString();
|
|
5755
|
+
references.add(reference.endsWith(";") ? reference : `${reference};`);
|
|
5756
|
+
});
|
|
5757
|
+
} catch {}
|
|
5670
5758
|
for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
5671
5759
|
}
|
|
5760
|
+
if (references.size > 0) referenceBySourceId.set(sourceKey, references);
|
|
5761
|
+
else if (authoritative) referenceBySourceId.delete(sourceKey);
|
|
5762
|
+
}
|
|
5763
|
+
function prepareStyles(code, id) {
|
|
5764
|
+
if (!code.includes("@apply") || code.includes("@reference")) return code;
|
|
5765
|
+
const references = referenceBySourceId.get(normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
5766
|
+
if (references?.size !== 1) return code;
|
|
5767
|
+
return `${references.values().next().value}\n${code}`;
|
|
5672
5768
|
}
|
|
5673
5769
|
async function expandStyles(code, id, hookContext) {
|
|
5674
5770
|
if (!options.isHarmonyBuildTarget() || !code.includes("@apply")) return code;
|
|
5675
|
-
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5771
|
+
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(prepareStyles(code, id), id);
|
|
5676
5772
|
const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
|
|
5677
5773
|
if (sources.length === 0 || sourceUtilities.size === 0) return code;
|
|
5678
5774
|
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
|
|
5775
|
+
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
5776
|
+
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
5680
5777
|
addWatchFile: hookContext.addWatchFile?.bind(hookContext),
|
|
5778
|
+
disableSourceScan: true,
|
|
5779
|
+
sourceCandidates: [],
|
|
5681
5780
|
transient: true
|
|
5682
5781
|
});
|
|
5683
5782
|
if (typeof generatedCss !== "string" || generatedCss.trim().length === 0) return code;
|
|
@@ -5685,49 +5784,178 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5685
5784
|
}
|
|
5686
5785
|
return {
|
|
5687
5786
|
expandStyles,
|
|
5787
|
+
prepareStyles,
|
|
5688
5788
|
rememberSource,
|
|
5689
5789
|
styleSources,
|
|
5690
5790
|
utilities
|
|
5691
5791
|
};
|
|
5692
5792
|
}
|
|
5693
5793
|
//#endregion
|
|
5794
|
+
//#region src/bundlers/vite/module-identity.ts
|
|
5795
|
+
const WINDOWS_DRIVE_RE = /^\/?[a-z]:[\\/]/i;
|
|
5796
|
+
const WINDOWS_UNC_RE = /^(?:\\\\|\/\/)/;
|
|
5797
|
+
function unique(values) {
|
|
5798
|
+
return [...new Set([...values].filter((value) => typeof value === "string" && value.length > 0))];
|
|
5799
|
+
}
|
|
5800
|
+
function decodeFileId(id) {
|
|
5801
|
+
try {
|
|
5802
|
+
return decodeURIComponent(id);
|
|
5803
|
+
} catch {
|
|
5804
|
+
return id;
|
|
5805
|
+
}
|
|
5806
|
+
}
|
|
5807
|
+
function stripViteFsPrefix(id) {
|
|
5808
|
+
if (!id.startsWith("/@fs/")) return id;
|
|
5809
|
+
const file = id.slice(5);
|
|
5810
|
+
return file.startsWith("/") || WINDOWS_DRIVE_RE.test(file) ? file : `/${file}`;
|
|
5811
|
+
}
|
|
5812
|
+
function stripFileProtocol(id) {
|
|
5813
|
+
if (!id.startsWith("file://")) return id;
|
|
5814
|
+
try {
|
|
5815
|
+
return (0, node_url.fileURLToPath)(id);
|
|
5816
|
+
} catch {
|
|
5817
|
+
return id;
|
|
5818
|
+
}
|
|
5819
|
+
}
|
|
5820
|
+
function isWindowsFile(file) {
|
|
5821
|
+
return WINDOWS_DRIVE_RE.test(file) || WINDOWS_UNC_RE.test(file);
|
|
5822
|
+
}
|
|
5823
|
+
function normalizeWindowsFile(file) {
|
|
5824
|
+
const withoutDriveSlash = /^\/[a-z]:[\\/]/i.test(file) ? file.slice(1) : file;
|
|
5825
|
+
return slash(node_path.default.win32.resolve(withoutDriveSlash));
|
|
5826
|
+
}
|
|
5827
|
+
function normalizeFile(file, root) {
|
|
5828
|
+
if (isWindowsFile(file) || isWindowsFile(root)) return normalizeWindowsFile(isWindowsFile(file) ? file : node_path.default.win32.resolve(root, file.replace(/^\//, "")));
|
|
5829
|
+
if (node_path.default.isAbsolute(file)) {
|
|
5830
|
+
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));
|
|
5831
|
+
const rootRelativeFile = node_path.default.resolve(root, file.slice(1));
|
|
5832
|
+
return (0, node_fs.existsSync)(rootRelativeFile) || (0, node_fs.existsSync)(node_path.default.dirname(rootRelativeFile)) ? slash(rootRelativeFile) : slash(node_path.default.resolve(file));
|
|
5833
|
+
}
|
|
5834
|
+
return slash(node_path.default.resolve(root, file));
|
|
5835
|
+
}
|
|
5836
|
+
function resolveRealFile(file) {
|
|
5837
|
+
if (node_process.default.platform !== "win32" && isWindowsFile(file)) return file;
|
|
5838
|
+
let current = file;
|
|
5839
|
+
const missingSegments = [];
|
|
5840
|
+
try {
|
|
5841
|
+
while (true) try {
|
|
5842
|
+
const resolvedParent = node_fs.realpathSync.native(current);
|
|
5843
|
+
return slash(node_path.default.join(resolvedParent, ...missingSegments));
|
|
5844
|
+
} catch {
|
|
5845
|
+
const parent = node_path.default.dirname(current);
|
|
5846
|
+
if (parent === current) return file;
|
|
5847
|
+
missingSegments.unshift(node_path.default.basename(current));
|
|
5848
|
+
current = parent;
|
|
5849
|
+
}
|
|
5850
|
+
} catch {
|
|
5851
|
+
return file;
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
function normalizeIdentityKey(file) {
|
|
5855
|
+
return isWindowsFile(file) || node_process.default.platform === "win32" ? file.toLowerCase() : file;
|
|
5856
|
+
}
|
|
5857
|
+
/**
|
|
5858
|
+
* 将 Vite URL、文件路径和 Windows 的等价路径收敛为同一个模块身份。
|
|
5859
|
+
*/
|
|
5860
|
+
function resolveViteModuleIdentity(id, root = node_process.default.cwd()) {
|
|
5861
|
+
const cleanId = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
5862
|
+
const decodedRoot = decodeFileId((0, _weapp_tailwindcss_shared.cleanUrl)(root));
|
|
5863
|
+
const normalizedRoot = isWindowsFile(decodedRoot) ? normalizeWindowsFile(decodedRoot) : slash(node_path.default.resolve(decodedRoot));
|
|
5864
|
+
const unwrappedId = stripFileProtocol(stripViteFsPrefix(cleanId));
|
|
5865
|
+
const file = unwrappedId.startsWith("\0") ? void 0 : normalizeFile(unwrappedId, normalizedRoot);
|
|
5866
|
+
const realFile = file ? resolveRealFile(file) : void 0;
|
|
5867
|
+
const key = realFile ? normalizeIdentityKey(realFile) : cleanId;
|
|
5868
|
+
const pathApi = isWindowsFile(normalizedRoot) ? node_path.default.win32 : node_path.default.posix;
|
|
5869
|
+
const relativeUrl = realFile && normalizeIdentityKey(realFile).startsWith(`${normalizeIdentityKey(normalizedRoot)}/`) ? `/${slash(pathApi.relative(normalizedRoot, realFile))}` : void 0;
|
|
5870
|
+
return {
|
|
5871
|
+
cleanId,
|
|
5872
|
+
file: realFile,
|
|
5873
|
+
key,
|
|
5874
|
+
lookupFiles: unique([file, realFile]),
|
|
5875
|
+
lookupIds: unique([
|
|
5876
|
+
id,
|
|
5877
|
+
cleanId,
|
|
5878
|
+
unwrappedId,
|
|
5879
|
+
file,
|
|
5880
|
+
realFile,
|
|
5881
|
+
realFile ? `/@fs/${realFile}` : void 0,
|
|
5882
|
+
relativeUrl
|
|
5883
|
+
])
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
function hasSameViteModuleIdentity(left, right, root = node_process.default.cwd()) {
|
|
5887
|
+
if (!left || !right) return false;
|
|
5888
|
+
return resolveViteModuleIdentity(left, root).key === resolveViteModuleIdentity(right, root).key;
|
|
5889
|
+
}
|
|
5890
|
+
//#endregion
|
|
5694
5891
|
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5695
|
-
function
|
|
5892
|
+
async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
5696
5893
|
const modules = [];
|
|
5697
5894
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5698
5895
|
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
5896
|
+
const seenFileIdentities = /* @__PURE__ */ new Set();
|
|
5897
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5898
|
+
const collectModule = (mod) => {
|
|
5899
|
+
if (mod == null || seenModules.has(mod) || !acceptModule(mod)) return;
|
|
5900
|
+
seenModules.add(mod);
|
|
5901
|
+
modules.push(mod);
|
|
5902
|
+
};
|
|
5903
|
+
for (const id of ids) {
|
|
5904
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
5905
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5906
|
+
for (const moduleId of identity.lookupIds) {
|
|
5907
|
+
if (seenModuleIds.has(moduleId)) continue;
|
|
5908
|
+
seenModuleIds.add(moduleId);
|
|
5909
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(moduleId));
|
|
5910
|
+
if (moduleId.startsWith("/")) collectModule(await ctx.server.moduleGraph.getModuleByUrl?.(moduleId));
|
|
5911
|
+
}
|
|
5912
|
+
if (seenFileIdentities.has(identity.key)) continue;
|
|
5913
|
+
seenFileIdentities.add(identity.key);
|
|
5914
|
+
for (const file of identity.lookupFiles) for (const mod of ctx.server.moduleGraph.getModulesByFile?.(file) ?? []) collectModule(mod);
|
|
5915
|
+
}
|
|
5916
|
+
return modules;
|
|
5917
|
+
}
|
|
5918
|
+
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5699
5919
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5700
|
-
const outDir = ctx.server.config?.build?.outDir ?
|
|
5920
|
+
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
5701
5921
|
const isHotSourceStyleModule = (id) => {
|
|
5702
5922
|
if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
|
|
5703
5923
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5704
5924
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5705
|
-
if (outDir
|
|
5706
|
-
const
|
|
5707
|
-
if (
|
|
5925
|
+
if (outDir) {
|
|
5926
|
+
const identity = resolveViteModuleIdentity(file, root);
|
|
5927
|
+
if (identity.key === outDir.key || identity.key.startsWith(`${outDir.key}/`)) return false;
|
|
5708
5928
|
}
|
|
5709
5929
|
return true;
|
|
5710
5930
|
};
|
|
5711
|
-
const
|
|
5712
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
5931
|
+
const modules = await resolveHotModulesByIds(ctx, tailwindRootCssModuleIds, (mod) => {
|
|
5713
5932
|
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);
|
|
5933
|
+
return isHotSourceStyleModule(modId);
|
|
5934
|
+
});
|
|
5935
|
+
const seenHotModules = new Set(modules);
|
|
5936
|
+
for (let index = 0; index < modules.length; index++) for (const importer of modules[index]?.importers ?? []) {
|
|
5937
|
+
const importerId = importer.id ?? importer.url;
|
|
5938
|
+
if (!seenHotModules.has(importer) && isHotSourceStyleModule(importerId)) {
|
|
5939
|
+
seenHotModules.add(importer);
|
|
5940
|
+
modules.push(importer);
|
|
5726
5941
|
}
|
|
5727
5942
|
}
|
|
5943
|
+
for (const mod of modules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
5728
5944
|
return modules;
|
|
5729
5945
|
}
|
|
5730
|
-
function
|
|
5946
|
+
async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
5947
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5948
|
+
const sourceIds = new Set(ids);
|
|
5949
|
+
for (const id of ids) {
|
|
5950
|
+
if (typeof id !== "string" || !/\.(?:uvue|nvue)(?:$|[?#])/i.test(id)) continue;
|
|
5951
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5952
|
+
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${(0, _weapp_tailwindcss_shared.cleanUrl)(lookupId)}?import`);
|
|
5953
|
+
}
|
|
5954
|
+
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
5955
|
+
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url);
|
|
5956
|
+
});
|
|
5957
|
+
}
|
|
5958
|
+
async function resolveHotSourceModules(ctx) {
|
|
5731
5959
|
const modules = [];
|
|
5732
5960
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5733
5961
|
const collectModule = (mod) => {
|
|
@@ -5737,10 +5965,27 @@ function resolveHotSourceModules(ctx) {
|
|
|
5737
5965
|
modules.push(mod);
|
|
5738
5966
|
};
|
|
5739
5967
|
for (const mod of ctx.modules) collectModule(mod);
|
|
5740
|
-
for (const mod of
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5968
|
+
for (const mod of await resolveHotSourceModulesByIds(ctx, [ctx.file])) collectModule(mod);
|
|
5969
|
+
return modules;
|
|
5970
|
+
}
|
|
5971
|
+
function mergeHotModulesByIdentity(root, ...groups) {
|
|
5972
|
+
const modules = [];
|
|
5973
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5974
|
+
const seenIdentities = /* @__PURE__ */ new Set();
|
|
5975
|
+
for (const mod of groups.flat()) {
|
|
5976
|
+
if (seenModules.has(mod)) continue;
|
|
5977
|
+
const ids = [
|
|
5978
|
+
mod.id,
|
|
5979
|
+
mod.url,
|
|
5980
|
+
mod.file
|
|
5981
|
+
].filter((id) => typeof id === "string" && id.length > 0);
|
|
5982
|
+
const moduleKind = ids.some(require_v4_generation_core.isSourceStyleRequest) ? "style" : "source";
|
|
5983
|
+
const keys = ids.map((id) => `${moduleKind}:${resolveViteModuleIdentity(id, root).key}`);
|
|
5984
|
+
if (keys.some((key) => seenIdentities.has(key))) continue;
|
|
5985
|
+
seenModules.add(mod);
|
|
5986
|
+
keys.forEach((key) => seenIdentities.add(key));
|
|
5987
|
+
modules.push(mod);
|
|
5988
|
+
}
|
|
5744
5989
|
return modules;
|
|
5745
5990
|
}
|
|
5746
5991
|
function resolveModuleHotUrl(mod) {
|
|
@@ -5759,23 +6004,32 @@ function isRootMiniProgramStyleUrl(file) {
|
|
|
5759
6004
|
}
|
|
5760
6005
|
function resolveCssHotUrl(id, root) {
|
|
5761
6006
|
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5762
|
-
const
|
|
5763
|
-
if (/^\/(
|
|
5764
|
-
if (isRootMiniProgramStyleUrl(
|
|
5765
|
-
return `${
|
|
6007
|
+
const cleanId = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
6008
|
+
if (/^\/(?!@fs\/|[A-Z]:)/i.test(cleanId) && !cleanId.startsWith(slash(root))) {
|
|
6009
|
+
if (isRootMiniProgramStyleUrl(cleanId)) return;
|
|
6010
|
+
return `${cleanId}${suffix}`;
|
|
5766
6011
|
}
|
|
6012
|
+
const file = resolveViteModuleIdentity(id, root).file ?? cleanId;
|
|
5767
6013
|
if (!isAbsoluteFilePath(file)) return;
|
|
5768
6014
|
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5769
6015
|
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5770
6016
|
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5771
6017
|
return `/${slash(node_path.default.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5772
6018
|
}
|
|
5773
|
-
function includesHotModule(modules, target) {
|
|
6019
|
+
function includesHotModule(modules, target, root) {
|
|
5774
6020
|
const targetUrl = resolveModuleHotUrl(target);
|
|
5775
6021
|
const targetId = target.id;
|
|
5776
6022
|
return modules.some((mod) => {
|
|
5777
6023
|
if (mod === target) return true;
|
|
5778
|
-
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId
|
|
6024
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId || [
|
|
6025
|
+
target.id,
|
|
6026
|
+
target.url,
|
|
6027
|
+
target.file
|
|
6028
|
+
].some((targetIdentity) => [
|
|
6029
|
+
mod.id,
|
|
6030
|
+
mod.url,
|
|
6031
|
+
mod.file
|
|
6032
|
+
].some((moduleIdentity) => hasSameViteModuleIdentity(targetIdentity, moduleIdentity, root)));
|
|
5779
6033
|
});
|
|
5780
6034
|
}
|
|
5781
6035
|
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
@@ -5793,10 +6047,16 @@ function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
|
5793
6047
|
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5794
6048
|
});
|
|
5795
6049
|
}
|
|
5796
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
6050
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
5797
6051
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
5798
6052
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5799
6053
|
const updates = [];
|
|
6054
|
+
for (const id of fallbackSourceIds) {
|
|
6055
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
6056
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6057
|
+
seenUrls.add(hotUrl);
|
|
6058
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6059
|
+
}
|
|
5800
6060
|
for (const id of fallbackCssIds) {
|
|
5801
6061
|
if (!require_v4_generation_core.isSourceStyleRequest(id)) continue;
|
|
5802
6062
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
@@ -5805,7 +6065,7 @@ function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
|
5805
6065
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5806
6066
|
}
|
|
5807
6067
|
for (const mod of cssModules) {
|
|
5808
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
6068
|
+
if (includesHotModule(ctx.modules, mod, root)) continue;
|
|
5809
6069
|
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5810
6070
|
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5811
6071
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
@@ -5840,12 +6100,25 @@ function createUniAppXNativeHmrReloader(options) {
|
|
|
5840
6100
|
}
|
|
5841
6101
|
async function handleHotUpdate(ctx) {
|
|
5842
6102
|
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5843
|
-
|
|
6103
|
+
await options.syncSourceCandidates?.(ctx);
|
|
5844
6104
|
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5845
|
-
const
|
|
6105
|
+
const hasRuntimeClassChange = previousRuntimeClassSet !== void 0 && (currentRuntimeClassSet.size !== previousRuntimeClassSet.size || [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate)));
|
|
5846
6106
|
remember(currentRuntimeClassSet);
|
|
5847
|
-
|
|
5848
|
-
|
|
6107
|
+
const cssModules = ctx.server?.moduleGraph ? await resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
6108
|
+
const sourceModules = ctx.server?.moduleGraph ? await resolveHotSourceModules(ctx) : ctx.modules ?? [];
|
|
6109
|
+
const localStyleModules = hasRuntimeClassChange && ctx.server?.moduleGraph ? await resolveHotSourceModulesByIds(ctx, options.localStyleModuleIds) : [];
|
|
6110
|
+
for (const mod of /* @__PURE__ */ new Set([...sourceModules, ...localStyleModules])) ctx.server?.moduleGraph?.invalidateModule(mod);
|
|
6111
|
+
const modules = [.../* @__PURE__ */ new Set([
|
|
6112
|
+
...sourceModules,
|
|
6113
|
+
...localStyleModules,
|
|
6114
|
+
...cssModules
|
|
6115
|
+
])];
|
|
6116
|
+
const canAcceptUpdate = hasSelfAcceptingNonStyleHotModule([...sourceModules, ...localStyleModules]) || cssModules.length > 0;
|
|
6117
|
+
if (hasRuntimeClassChange && !canAcceptUpdate) {
|
|
6118
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
6119
|
+
return [];
|
|
6120
|
+
}
|
|
6121
|
+
return modules.length > 0 ? modules : void 0;
|
|
5849
6122
|
}
|
|
5850
6123
|
return {
|
|
5851
6124
|
handleHotUpdate,
|
|
@@ -5865,12 +6138,7 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
5865
6138
|
};
|
|
5866
6139
|
}
|
|
5867
6140
|
//#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
|
-
}
|
|
6141
|
+
//#region src/uni-app-x/vite/style-request.ts
|
|
5874
6142
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
5875
6143
|
"scss",
|
|
5876
6144
|
"sass",
|
|
@@ -5880,8 +6148,7 @@ const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
|
5880
6148
|
]);
|
|
5881
6149
|
const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
5882
6150
|
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
5883
|
-
const
|
|
5884
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6151
|
+
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
5885
6152
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
5886
6153
|
function isPreprocessorRequest(id, lang) {
|
|
5887
6154
|
const normalizedLang = lang?.toLowerCase();
|
|
@@ -5891,25 +6158,48 @@ function isPreprocessorRequest(id, lang) {
|
|
|
5891
6158
|
return PREPROCESSOR_EXT_RE.test(id);
|
|
5892
6159
|
}
|
|
5893
6160
|
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);
|
|
6161
|
+
return UVUE_NVUE_RE$1.test((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ? "uvue" : void 0;
|
|
5898
6162
|
}
|
|
5899
6163
|
function isCssModuleExport(code) {
|
|
5900
6164
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5901
6165
|
}
|
|
6166
|
+
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
6167
|
+
if (!isPreprocessorRequest(id, lang)) return;
|
|
6168
|
+
if (options.isIosPlatform) {
|
|
6169
|
+
const normalizedCode = (0, _weapp_tailwindcss_postcss.normalizeTailwindcssV4InfinityCalcCss)(code);
|
|
6170
|
+
return { result: normalizedCode === code ? void 0 : {
|
|
6171
|
+
code: normalizedCode,
|
|
6172
|
+
map: null
|
|
6173
|
+
} };
|
|
6174
|
+
}
|
|
6175
|
+
if (options.isWebGeneratorTarget && !options.isNativeAppStyleTarget) return { result: void 0 };
|
|
6176
|
+
}
|
|
6177
|
+
//#endregion
|
|
6178
|
+
//#region src/uni-app-x/vite.ts
|
|
6179
|
+
let transformUVuePromise;
|
|
6180
|
+
function loadTransformUVue() {
|
|
6181
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-GzbxfNGA.cjs")).then((mod) => mod.transformUVue));
|
|
6182
|
+
return transformUVuePromise;
|
|
6183
|
+
}
|
|
6184
|
+
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
6185
|
+
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6186
|
+
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
6187
|
+
return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
|
|
6188
|
+
}
|
|
5902
6189
|
function createUniAppXPlugins(options) {
|
|
5903
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6190
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5904
6191
|
const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
|
|
5905
6192
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
5906
6193
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5907
6194
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6195
|
+
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
5908
6196
|
let componentLocalStyleEnabled;
|
|
5909
6197
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5910
6198
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5911
6199
|
ensureRuntimeClassSet,
|
|
5912
6200
|
isNativeAppBuildTarget,
|
|
6201
|
+
localStyleModuleIds: nativeLocalStyleModuleIds,
|
|
6202
|
+
syncSourceCandidates: syncSourceCandidatesForHotUpdate,
|
|
5913
6203
|
tailwindRootCssModuleIds,
|
|
5914
6204
|
viteProcessedCssSourceFiles
|
|
5915
6205
|
});
|
|
@@ -5934,13 +6224,15 @@ function createUniAppXPlugins(options) {
|
|
|
5934
6224
|
if (require_generator.resolveUniUtsPlatform().isAppHarmony) return true;
|
|
5935
6225
|
return isUniAppXHarmonyOutDir(getResolvedConfig()?.build?.outDir);
|
|
5936
6226
|
}
|
|
5937
|
-
function getStyleHandlerOptions(id) {
|
|
5938
|
-
const
|
|
6227
|
+
function getStyleHandlerOptions(id, source) {
|
|
6228
|
+
const isMainChunk = source === "tailwind-root" || mainCssChunkMatcher(id, appType);
|
|
6229
|
+
const cacheKey = `${isMainChunk ? "1" : "0"}:${source ?? ""}:${id}`;
|
|
5939
6230
|
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
5940
6231
|
if (!styleHandlerOptions) {
|
|
5941
6232
|
styleHandlerOptions = require_object.omitUndefined({
|
|
5942
|
-
isMainChunk
|
|
6233
|
+
isMainChunk,
|
|
5943
6234
|
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
6235
|
+
uniAppXCssSource: isNativeAppBuildTarget(id) ? source : void 0,
|
|
5944
6236
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5945
6237
|
postcssOptions: { options: {
|
|
5946
6238
|
from: id,
|
|
@@ -5960,16 +6252,24 @@ function createUniAppXPlugins(options) {
|
|
|
5960
6252
|
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
5961
6253
|
}
|
|
5962
6254
|
async function transformStyle(code, id, query, hookContext) {
|
|
5963
|
-
isNativeAppBuildTarget(id);
|
|
6255
|
+
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
5964
6256
|
const parsed = query ?? parseVueRequest(id).query;
|
|
5965
6257
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5966
6258
|
if (isCssModuleExport(code)) return;
|
|
5967
|
-
const
|
|
5968
|
-
|
|
6259
|
+
const hasTailwindRoot = require_generator.hasTailwindRootDirectives(code, { importFallback: true });
|
|
6260
|
+
const hasTailwindApply = require_generator.hasTailwindApplyDirective(code);
|
|
6261
|
+
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
6262
|
+
const isNativeSfcAuthorStyle = isNativeStyle && resolveUniAppXCssTarget(id) === "uvue";
|
|
6263
|
+
if (!shouldGenerateCss && (!isNativeStyle || isNativeSfcAuthorStyle)) return;
|
|
5969
6264
|
harmonyApply.rememberSource(code, id);
|
|
5970
|
-
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code,
|
|
5971
|
-
|
|
5972
|
-
|
|
6265
|
+
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(code, id) : code, {
|
|
6266
|
+
...hookContext,
|
|
6267
|
+
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
6268
|
+
sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
|
|
6269
|
+
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
6270
|
+
}) : void 0;
|
|
6271
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, code) : generatedCss : code;
|
|
6272
|
+
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
5973
6273
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
5974
6274
|
reportStyleWarnings(postcssResult);
|
|
5975
6275
|
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
@@ -5984,7 +6284,7 @@ function createUniAppXPlugins(options) {
|
|
|
5984
6284
|
getResolvedConfig,
|
|
5985
6285
|
isHarmonyBuildTarget,
|
|
5986
6286
|
async transformCss(css, id) {
|
|
5987
|
-
const result = await styleHandler(css, getStyleHandlerOptions(id));
|
|
6287
|
+
const result = await styleHandler(css, getStyleHandlerOptions(id, "author-apply"));
|
|
5988
6288
|
reportStyleWarnings(result);
|
|
5989
6289
|
return result.css;
|
|
5990
6290
|
}
|
|
@@ -6003,14 +6303,12 @@ function createUniAppXPlugins(options) {
|
|
|
6003
6303
|
if (!isEnabled()) return;
|
|
6004
6304
|
await runtimeState.readyPromise;
|
|
6005
6305
|
const { query } = parseVueRequest(id);
|
|
6006
|
-
const
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
};
|
|
6013
|
-
}
|
|
6306
|
+
const preprocessor = resolvePreprocessorTransform(code, id, query.lang, {
|
|
6307
|
+
isIosPlatform,
|
|
6308
|
+
isNativeAppStyleTarget: isNativeAppStyleTarget(),
|
|
6309
|
+
isWebGeneratorTarget: isWebGeneratorTarget()
|
|
6310
|
+
});
|
|
6311
|
+
if (preprocessor) return preprocessor.result;
|
|
6014
6312
|
return transformStyle(code, id, query, this);
|
|
6015
6313
|
}
|
|
6016
6314
|
}];
|
|
@@ -6021,40 +6319,46 @@ function createUniAppXPlugins(options) {
|
|
|
6021
6319
|
if (!isEnabled()) return;
|
|
6022
6320
|
await nativeHmrReloader.refreshBaseline();
|
|
6023
6321
|
},
|
|
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
|
-
|
|
6322
|
+
transform: {
|
|
6323
|
+
order: "pre",
|
|
6324
|
+
async handler(code, id) {
|
|
6325
|
+
if (!isEnabled()) return;
|
|
6326
|
+
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6327
|
+
if (isNativeAppBuildTarget(id)) {
|
|
6328
|
+
nativeLocalStyleModuleIds.add(id);
|
|
6329
|
+
nativeLocalStyleModuleIds.add((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
6330
|
+
}
|
|
6331
|
+
harmonyApply.rememberSource(code, id, true);
|
|
6332
|
+
const resolvedConfig = getResolvedConfig();
|
|
6333
|
+
const isServeCommand = resolvedConfig?.command === "serve";
|
|
6334
|
+
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
6335
|
+
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
6336
|
+
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6337
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6338
|
+
const transformUVue = await loadTransformUVue();
|
|
6339
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6340
|
+
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
6341
|
+
const result = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle ? transformUVue(code, id, jsHandler, currentRuntimeSet, require_object.omitUndefined({
|
|
6342
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6343
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6344
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6345
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
6346
|
+
})) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6347
|
+
if (result?.code) {
|
|
6348
|
+
harmonyApply.rememberSource(result.code, id);
|
|
6349
|
+
const expandedCode = await harmonyApply.expandStyles(result.code, id, this);
|
|
6350
|
+
if (expandedCode !== result.code) return {
|
|
6351
|
+
code: expandedCode,
|
|
6352
|
+
map: null
|
|
6353
|
+
};
|
|
6354
|
+
}
|
|
6355
|
+
return result;
|
|
6051
6356
|
}
|
|
6052
|
-
return result;
|
|
6053
6357
|
},
|
|
6054
6358
|
async handleHotUpdate(ctx) {
|
|
6055
6359
|
if (!isEnabled()) return;
|
|
6056
6360
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
6057
|
-
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
6361
|
+
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6058
6362
|
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
6059
6363
|
},
|
|
6060
6364
|
async watchChange(id) {
|
|
@@ -6083,7 +6387,12 @@ function createUniAppXPlugins(options) {
|
|
|
6083
6387
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApply.utilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
6084
6388
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
6085
6389
|
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),
|
|
6390
|
+
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), {
|
|
6391
|
+
addWatchFile: this?.addWatchFile?.bind(this),
|
|
6392
|
+
disableSourceScan: true,
|
|
6393
|
+
sourceCandidates: [],
|
|
6394
|
+
transient: true
|
|
6395
|
+
});
|
|
6087
6396
|
if (typeof generatedCss === "string" && generatedCss.trim().length > 0) cssSources.push(generatedCss);
|
|
6088
6397
|
}
|
|
6089
6398
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
@@ -6284,10 +6593,33 @@ function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
|
6284
6593
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
6285
6594
|
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
6286
6595
|
}
|
|
6596
|
+
function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
|
|
6597
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
6598
|
+
for (const [shellFile, targetFile] of targetByFile ?? []) if (require_source_candidate_scan_signature.normalizeOutputPathKey(shellFile) === outputKey) return targetFile;
|
|
6599
|
+
return outputFile;
|
|
6600
|
+
}
|
|
6601
|
+
function createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain) {
|
|
6602
|
+
const updates = [{
|
|
6603
|
+
css,
|
|
6604
|
+
file: sourceFile,
|
|
6605
|
+
injectIntoMain,
|
|
6606
|
+
outputFile
|
|
6607
|
+
}];
|
|
6608
|
+
if (outputFile !== sourceFile) updates.push({
|
|
6609
|
+
css,
|
|
6610
|
+
file: outputFile,
|
|
6611
|
+
injectIntoMain,
|
|
6612
|
+
outputFile
|
|
6613
|
+
});
|
|
6614
|
+
return updates;
|
|
6615
|
+
}
|
|
6287
6616
|
async function processRememberedCssReplay(options) {
|
|
6288
|
-
const { addWatchFile, activeViteCssCacheFiles, bundle, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
6617
|
+
const { addWatchFile, activeViteCssCacheFiles, bundle, bundleFiles, cache, changedCssFiles = /* @__PURE__ */ new Set(), createScopedGeneratorRuntime, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, cssPipelineContext, cssPipelineStrategy, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, generatorRuntime, generatorPlatform, getCssHandlerOptions, getCssUserHandlerOptions, getRememberedCssSignature, getRememberedCssSources, frameworkRootImportShellTargetByFile, isNativeAppStyleTarget, isWebGeneratorTarget, lastCssRawSourceHashByFile = /* @__PURE__ */ new Map(), lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, metrics, normalizeViteCssCacheKey, onUpdate, opts, pendingRememberedCssReplayUpdates, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, runtimeState, setRememberedCssSignature, shouldInjectCssIntoMainFromOutput, shouldPreserveAppCssExtension, sourceRoot, styleHandler, timeTask, useIncrementalMode } = options;
|
|
6289
6618
|
const rememberedReplayGroups = collectRememberedCssReplayGroups(getRememberedCssSources?.(), opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles);
|
|
6290
|
-
|
|
6619
|
+
const normalizedBundleFiles = new Set(bundleFiles.map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
6620
|
+
for (const [rememberedOutputFile, rememberedGroup] of rememberedReplayGroups) {
|
|
6621
|
+
const outputFile = resolveRememberedCssReplayOutputFile(rememberedOutputFile, frameworkRootImportShellTargetByFile);
|
|
6622
|
+
if (outputFile !== rememberedOutputFile) debug("css replay use framework root import shell target: %s -> %s", rememberedOutputFile, outputFile);
|
|
6291
6623
|
if (isHTMLRequest(outputFile) || options.opts.htmlMatcher(outputFile)) continue;
|
|
6292
6624
|
const replayableRememberedGroup = rememberedGroup.filter(({ remembered }) => {
|
|
6293
6625
|
const shouldSkip = shouldSkipRawRememberedCssSource(remembered.rawSource, remembered.sourceFile);
|
|
@@ -6301,7 +6633,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6301
6633
|
const generatorRawSource = isWebGeneratorTarget ? rawSource : require_v4_generation_core.normalizeMiniProgramGeneratorCssSource(rawSource, outputFile);
|
|
6302
6634
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
6303
6635
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
6304
|
-
const outputCssHandlerOptions = getCssHandlerOptions(
|
|
6636
|
+
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
6305
6637
|
const cssHandlerOptions = {
|
|
6306
6638
|
...getCssHandlerOptions(sourceFile),
|
|
6307
6639
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
@@ -6320,7 +6652,19 @@ async function processRememberedCssReplay(options) {
|
|
|
6320
6652
|
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
6321
6653
|
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
6322
6654
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
6323
|
-
if (bundleFiles.includes(
|
|
6655
|
+
if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
6656
|
+
const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
6657
|
+
if (allRememberedSignaturesFresh) if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
6658
|
+
else {
|
|
6659
|
+
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
6660
|
+
if (cachedCss != null) {
|
|
6661
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
6662
|
+
metrics.css.cacheHits++;
|
|
6663
|
+
debug("css replay cached result into framework root target: %s", outputFile);
|
|
6664
|
+
continue;
|
|
6665
|
+
}
|
|
6666
|
+
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
6667
|
+
}
|
|
6324
6668
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await require_source_candidate_scan_signature.createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
6325
6669
|
const sourceTraceTokenSources = sourceTraceSources ? require_v4_generation_core.createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
6326
6670
|
const annotateCss = (css) => require_v4_generation_core.annotateCssSourceTrace(css, {
|
|
@@ -6328,7 +6672,7 @@ async function processRememberedCssReplay(options) {
|
|
|
6328
6672
|
tokenSources: sourceTraceTokenSources
|
|
6329
6673
|
});
|
|
6330
6674
|
const shouldRecordRememberedReplayCss = useIncrementalMode || isNativeAppStyleTarget;
|
|
6331
|
-
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss;
|
|
6675
|
+
const shouldEmitRememberedReplayCssAsset = shouldRecordRememberedReplayCss && !shouldMergeReplayIntoFrameworkRootTarget;
|
|
6332
6676
|
if (!shouldRecordRememberedReplayCss) continue;
|
|
6333
6677
|
const shouldPreserveLocalImportWrapper = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
6334
6678
|
css: rawSource,
|
|
@@ -6396,14 +6740,10 @@ async function processRememberedCssReplay(options) {
|
|
|
6396
6740
|
registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
|
|
6397
6741
|
recordCssAssetResult?.(outputFile, css);
|
|
6398
6742
|
const shouldInjectReplayCssIntoMain = shouldInjectCssIntoMainFromOutput(outputFile, sourceFile, outputCssHandlerOptions);
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
if (outputFile !== sourceFile) recordViteProcessedCssAssetResult?.(outputFile, css, {
|
|
6404
|
-
injectIntoMain: outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain,
|
|
6405
|
-
outputFile
|
|
6406
|
-
});
|
|
6743
|
+
const injectIntoMain = shouldMergeReplayIntoFrameworkRootTarget ? true : outputCssHandlerOptions.isMainChunk ? false : shouldInjectReplayCssIntoMain;
|
|
6744
|
+
const replayUpdates = createRememberedCssReplayUpdates(css, sourceFile, outputFile, injectIntoMain);
|
|
6745
|
+
if (shouldMergeReplayIntoFrameworkRootTarget) pendingRememberedCssReplayUpdates.push(...replayUpdates);
|
|
6746
|
+
else for (const update of replayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
6407
6747
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
6408
6748
|
}
|
|
6409
6749
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
@@ -7295,6 +7635,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7295
7635
|
const tasks = [];
|
|
7296
7636
|
const cssTaskFactories = [];
|
|
7297
7637
|
const jsTaskFactories = [];
|
|
7638
|
+
const pendingRememberedCssReplayUpdates = [];
|
|
7298
7639
|
const entryPlanningStartedAt = performance.now();
|
|
7299
7640
|
for (const entry of snapshot.entries) {
|
|
7300
7641
|
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
@@ -7520,6 +7861,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7520
7861
|
debug,
|
|
7521
7862
|
defaultStyleOutputExtension,
|
|
7522
7863
|
emitOrReplayCssAsset,
|
|
7864
|
+
frameworkRootImportShellTargetByFile,
|
|
7523
7865
|
generatorPlatform,
|
|
7524
7866
|
generatorRuntime,
|
|
7525
7867
|
getCssHandlerOptions,
|
|
@@ -7536,6 +7878,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7536
7878
|
normalizeViteCssCacheKey,
|
|
7537
7879
|
onUpdate,
|
|
7538
7880
|
opts,
|
|
7881
|
+
pendingRememberedCssReplayUpdates,
|
|
7539
7882
|
recordCssAssetResult,
|
|
7540
7883
|
recordViteProcessedCssAssetResult,
|
|
7541
7884
|
rootDir,
|
|
@@ -7587,6 +7930,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
7587
7930
|
opts,
|
|
7588
7931
|
outDir,
|
|
7589
7932
|
pendingLinkedUpdates,
|
|
7933
|
+
pendingRememberedCssReplayUpdates,
|
|
7590
7934
|
pruneViteCssCaches,
|
|
7591
7935
|
recordCssAssetResult,
|
|
7592
7936
|
recordTimingDetail,
|
|
@@ -7800,12 +8144,11 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7800
8144
|
});
|
|
7801
8145
|
};
|
|
7802
8146
|
collectViteProcessedCssAssets();
|
|
7803
|
-
const createHarmonyBundleStyleSources = async (
|
|
8147
|
+
const createHarmonyBundleStyleSources = async () => {
|
|
7804
8148
|
const cssSources = collectViteProcessedCssSources(getViteProcessedCssAssetResults);
|
|
7805
8149
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
7806
8150
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
7807
8151
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
7808
|
-
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
7809
8152
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7810
8153
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
7811
8154
|
file: "uni-app-x-harmony-apply.css"
|
|
@@ -7813,7 +8156,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7813
8156
|
const generated = await require_v4_generation_core.generateTailwindV4Css({
|
|
7814
8157
|
opts,
|
|
7815
8158
|
runtimeState,
|
|
7816
|
-
runtime:
|
|
8159
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
7817
8160
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
7818
8161
|
file: "uni-app-x-harmony-apply.css",
|
|
7819
8162
|
outputFile: "uni-app-x-harmony-apply.css",
|
|
@@ -7823,6 +8166,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7823
8166
|
isMainChunk: false
|
|
7824
8167
|
},
|
|
7825
8168
|
cssStage: "framework-processed",
|
|
8169
|
+
disableSourceScan: true,
|
|
7826
8170
|
getSourceCandidatesForEntries,
|
|
7827
8171
|
generatorPlatform,
|
|
7828
8172
|
styleHandler: opts.styleHandler,
|
|
@@ -7831,9 +8175,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7831
8175
|
if (generated?.css) cssSources.push(annotateCss(generated.css));
|
|
7832
8176
|
return cssSources;
|
|
7833
8177
|
};
|
|
7834
|
-
const injectHarmonyBundleStyles = async (
|
|
8178
|
+
const injectHarmonyBundleStyles = async () => {
|
|
7835
8179
|
if (!isHarmonyAppStyleTarget) return;
|
|
7836
|
-
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources(
|
|
8180
|
+
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources() })) debug("uni-app-x harmony bundle styles inject");
|
|
7837
8181
|
};
|
|
7838
8182
|
const isCssOutputAssetEntry = (entry) => {
|
|
7839
8183
|
const [bundleFile, output] = entry;
|
|
@@ -7970,7 +8314,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7970
8314
|
bundle,
|
|
7971
8315
|
writeTargets
|
|
7972
8316
|
});
|
|
7973
|
-
await injectHarmonyBundleStyles(
|
|
8317
|
+
await injectHarmonyBundleStyles();
|
|
7974
8318
|
collectViteProcessedCssAssets();
|
|
7975
8319
|
injectViteProcessedCssIntoMainCss();
|
|
7976
8320
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
@@ -8533,6 +8877,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
8533
8877
|
async transform(code, id) {
|
|
8534
8878
|
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
8535
8879
|
if (!hasViteCssGenerationDirective(code)) return;
|
|
8880
|
+
if (options.shouldDeferGeneration?.(id, code)) return;
|
|
8536
8881
|
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
8537
8882
|
const generatedCss = await options.generateCss(id, code, {
|
|
8538
8883
|
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
@@ -8650,24 +8995,27 @@ function wrapViteCssPostTransform(config, transformCss) {
|
|
|
8650
8995
|
}
|
|
8651
8996
|
//#endregion
|
|
8652
8997
|
//#region src/bundlers/vite/shared/framework-hmr-candidate-state.ts
|
|
8653
|
-
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
8654
8998
|
function createViteHmrCandidateState(options) {
|
|
8655
8999
|
let pendingChange;
|
|
8656
9000
|
let pendingCssTargetFiles;
|
|
9001
|
+
let pendingTargetsArmed = false;
|
|
8657
9002
|
let pendingFullRegeneration = false;
|
|
8658
9003
|
const normalizeCssTargetFile = (file) => normalizeVitePersistentCacheKey((0, _weapp_tailwindcss_shared.cleanUrl)(file));
|
|
8659
9004
|
const clear = () => {
|
|
8660
9005
|
pendingChange = void 0;
|
|
8661
9006
|
pendingCssTargetFiles = void 0;
|
|
9007
|
+
pendingTargetsArmed = false;
|
|
8662
9008
|
pendingFullRegeneration = false;
|
|
8663
9009
|
};
|
|
8664
9010
|
const queueFullRegeneration = () => {
|
|
8665
9011
|
pendingChange = void 0;
|
|
8666
9012
|
pendingCssTargetFiles = void 0;
|
|
9013
|
+
pendingTargetsArmed = false;
|
|
8667
9014
|
pendingFullRegeneration = true;
|
|
8668
9015
|
};
|
|
8669
9016
|
const queueChange = (change) => {
|
|
8670
9017
|
var _pendingChange;
|
|
9018
|
+
if (pendingFullRegeneration) return;
|
|
8671
9019
|
pendingFullRegeneration = false;
|
|
8672
9020
|
if (!pendingChange) {
|
|
8673
9021
|
pendingChange = {
|
|
@@ -8689,17 +9037,21 @@ function createViteHmrCandidateState(options) {
|
|
|
8689
9037
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8690
9038
|
...change,
|
|
8691
9039
|
file,
|
|
8692
|
-
runtimeAffecting: changeOptions.runtimeAffecting === true ||
|
|
9040
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || require_v4_generation_core.isSourceStyleRequest(file)
|
|
8693
9041
|
});
|
|
8694
9042
|
const apply = (change) => {
|
|
8695
9043
|
if (require_v4_generation_core.isSourceStyleRequest(change.file)) {
|
|
8696
9044
|
clear();
|
|
8697
9045
|
return change;
|
|
8698
9046
|
}
|
|
9047
|
+
if (change.runtimeAffecting) {
|
|
9048
|
+
queueFullRegeneration();
|
|
9049
|
+
return change;
|
|
9050
|
+
}
|
|
8699
9051
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
8700
|
-
if (preserveDeletedCss
|
|
9052
|
+
if (preserveDeletedCss) {
|
|
8701
9053
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
8702
|
-
else if (!pendingChange) clear();
|
|
9054
|
+
else if (!pendingChange && !pendingFullRegeneration) clear();
|
|
8703
9055
|
return change;
|
|
8704
9056
|
}
|
|
8705
9057
|
clear();
|
|
@@ -8708,28 +9060,26 @@ function createViteHmrCandidateState(options) {
|
|
|
8708
9060
|
};
|
|
8709
9061
|
const resolve = (generatorCode, file) => {
|
|
8710
9062
|
const fileKey = normalizeCssTargetFile(file);
|
|
8711
|
-
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && require_generator.hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) ||
|
|
9063
|
+
if (options.getCommand() !== "serve" || !pendingChange || pendingChange.runtimeAffecting || pendingChange.addedCandidates.size === 0 || options.getGeneratorOptions().target === "weapp" && require_generator.hasUserCssLayerBlocks(generatorCode) || !options.cleanGeneratedCssByFile.has(fileKey) || !options.generatedClassSetByFile.has(fileKey) || pendingTargetsArmed && !pendingCssTargetFiles?.has(fileKey)) return;
|
|
8712
9064
|
return pendingChange;
|
|
8713
9065
|
};
|
|
8714
9066
|
const finishTarget = (file) => {
|
|
8715
|
-
if (!pendingChange) return;
|
|
8716
|
-
if (!pendingCssTargetFiles)
|
|
8717
|
-
clear();
|
|
8718
|
-
return;
|
|
8719
|
-
}
|
|
9067
|
+
if (!pendingChange && !pendingFullRegeneration) return;
|
|
9068
|
+
if (!pendingTargetsArmed || !pendingCssTargetFiles) return;
|
|
8720
9069
|
pendingCssTargetFiles.delete(normalizeCssTargetFile(file));
|
|
8721
9070
|
if (pendingCssTargetFiles.size === 0) clear();
|
|
8722
9071
|
};
|
|
8723
9072
|
const armTargets = (cssModules, fallbackCssIds) => {
|
|
8724
|
-
if (!pendingChange) {
|
|
9073
|
+
if (!pendingChange && !pendingFullRegeneration) {
|
|
8725
9074
|
pendingCssTargetFiles = void 0;
|
|
9075
|
+
pendingTargetsArmed = false;
|
|
8726
9076
|
return;
|
|
8727
9077
|
}
|
|
8728
9078
|
const targets = /* @__PURE__ */ new Set();
|
|
8729
9079
|
const addTarget = (file) => {
|
|
8730
9080
|
if (!file) return;
|
|
8731
9081
|
const key = normalizeCssTargetFile(file);
|
|
8732
|
-
if (options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
9082
|
+
if (pendingFullRegeneration || options.cleanGeneratedCssByFile.has(key)) targets.add(key);
|
|
8733
9083
|
};
|
|
8734
9084
|
for (const module of cssModules) {
|
|
8735
9085
|
addTarget(module.id);
|
|
@@ -8737,7 +9087,28 @@ function createViteHmrCandidateState(options) {
|
|
|
8737
9087
|
addTarget(module.url);
|
|
8738
9088
|
}
|
|
8739
9089
|
for (const id of fallbackCssIds) addTarget(id);
|
|
8740
|
-
pendingCssTargetFiles = targets
|
|
9090
|
+
pendingCssTargetFiles = targets;
|
|
9091
|
+
pendingTargetsArmed = true;
|
|
9092
|
+
};
|
|
9093
|
+
const reconcileRuntimeCandidates = (file, candidates, rootCssIds) => {
|
|
9094
|
+
if (options.getCommand() !== "serve" || pendingFullRegeneration) return;
|
|
9095
|
+
const generatedClassSets = [];
|
|
9096
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
9097
|
+
for (const id of rootCssIds) {
|
|
9098
|
+
const fileKey = normalizeCssTargetFile(id);
|
|
9099
|
+
if (seenFiles.has(fileKey)) continue;
|
|
9100
|
+
seenFiles.add(fileKey);
|
|
9101
|
+
const classSet = options.generatedClassSetByFile.get(fileKey);
|
|
9102
|
+
if (classSet) generatedClassSets.push(classSet);
|
|
9103
|
+
}
|
|
9104
|
+
if (generatedClassSets.length === 0) return;
|
|
9105
|
+
const addedCandidates = /* @__PURE__ */ new Set();
|
|
9106
|
+
for (const candidate of candidates) if (generatedClassSets.some((classSet) => !classSet.has(candidate))) addedCandidates.add(candidate);
|
|
9107
|
+
if (addedCandidates.size === 0) return;
|
|
9108
|
+
apply(createChange(file, {
|
|
9109
|
+
addedCandidates,
|
|
9110
|
+
removedCandidates: /* @__PURE__ */ new Set()
|
|
9111
|
+
}));
|
|
8741
9112
|
};
|
|
8742
9113
|
return {
|
|
8743
9114
|
apply,
|
|
@@ -8746,13 +9117,19 @@ function createViteHmrCandidateState(options) {
|
|
|
8746
9117
|
createChange,
|
|
8747
9118
|
finishTarget,
|
|
8748
9119
|
hasPendingCandidateAppend: () => pendingChange != null && !pendingChange.runtimeAffecting && pendingChange.addedCandidates.size > 0,
|
|
8749
|
-
hasPendingChange: () => pendingChange != null,
|
|
9120
|
+
hasPendingChange: () => pendingChange != null || pendingFullRegeneration,
|
|
8750
9121
|
queueFullRegeneration,
|
|
9122
|
+
reconcileRuntimeCandidates,
|
|
8751
9123
|
resolve,
|
|
8752
|
-
shouldForceFullRegeneration: (resolved) =>
|
|
9124
|
+
shouldForceFullRegeneration: (file, resolved) => {
|
|
9125
|
+
if (options.getCommand() !== "serve") return false;
|
|
9126
|
+
if (pendingFullRegeneration) return pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9127
|
+
return pendingChange != null && !resolved && pendingTargetsArmed && pendingCssTargetFiles?.has(normalizeCssTargetFile(file)) === true;
|
|
9128
|
+
},
|
|
8753
9129
|
snapshotDebugState: () => ({
|
|
8754
9130
|
pendingAddedCandidates: pendingChange?.addedCandidates.size ?? 0,
|
|
8755
|
-
pendingCssTargets: pendingCssTargetFiles?.size ?? 0
|
|
9131
|
+
pendingCssTargets: pendingCssTargetFiles?.size ?? 0,
|
|
9132
|
+
pendingFullRegeneration
|
|
8756
9133
|
})
|
|
8757
9134
|
};
|
|
8758
9135
|
}
|
|
@@ -8957,6 +9334,11 @@ function sameStringList(first, second) {
|
|
|
8957
9334
|
//#endregion
|
|
8958
9335
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8959
9336
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
9337
|
+
const hasDifferentHotModules = (left, right) => left.length !== right.length || left.some((mod, index) => mod !== right[index]);
|
|
9338
|
+
const hasTemplateHotSourceModule = (modules) => modules.some((mod) => {
|
|
9339
|
+
const request = mod.url ?? mod.id;
|
|
9340
|
+
return typeof request === "string" && /\.(?:uvue|nvue)(?:\?import)?$/i.test(request);
|
|
9341
|
+
});
|
|
8960
9342
|
return {
|
|
8961
9343
|
name: `${require_context.vitePluginName}:source-candidates`,
|
|
8962
9344
|
enforce: "pre",
|
|
@@ -9022,60 +9404,70 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9022
9404
|
await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9023
9405
|
}, { emit: false });
|
|
9024
9406
|
},
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
mod.
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
options.
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9407
|
+
handleHotUpdate: {
|
|
9408
|
+
order: "post",
|
|
9409
|
+
async handler(ctx) {
|
|
9410
|
+
require_v4_generation_core.recordCompilationDependencyChanges(options.runtimeState, require_v4_generation_core.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))]));
|
|
9411
|
+
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9412
|
+
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && require_v4_generation_core.isSourceCandidateRequest(ctx.file);
|
|
9413
|
+
if (isSourceCandidateHotUpdate && require_v4_generation_core.isSourceStyleRequest(ctx.file)) {
|
|
9414
|
+
for (const mod of ctx.modules) for (const id of [
|
|
9415
|
+
mod.id,
|
|
9416
|
+
mod.url,
|
|
9417
|
+
mod.file
|
|
9418
|
+
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
9419
|
+
}
|
|
9420
|
+
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9421
|
+
if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
|
|
9422
|
+
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
9423
|
+
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9424
|
+
}
|
|
9425
|
+
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9426
|
+
options.sourceScanSession.consumeHotUpdateChange(ctx.file);
|
|
9427
|
+
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9428
|
+
let canUseHmrCandidateAppend = false;
|
|
9429
|
+
if (isSourceCandidateHotUpdate) {
|
|
9430
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
9431
|
+
const preserveDeletedCssInHmr = options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
9432
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
9433
|
+
if (!canUseHmrCandidateAppend) {
|
|
9434
|
+
if (sourceCandidateChange === void 0) {
|
|
9435
|
+
options.hmrCandidateState.clear();
|
|
9436
|
+
if (!preserveDeletedCssInHmr && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.queueFullRegeneration();
|
|
9437
|
+
}
|
|
9438
|
+
if (isWebLikeHotUpdate) {
|
|
9439
|
+
await options.refreshRuntimeStateForAutoCssSources?.(true);
|
|
9440
|
+
await options.sourceScanSession.sync({ force: true });
|
|
9441
|
+
}
|
|
9056
9442
|
}
|
|
9057
9443
|
}
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9444
|
+
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9445
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
|
|
9446
|
+
const cssModules = await resolveHotTailwindCssModules(ctx, require_v4_generation_core.isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9447
|
+
const hotRoot = ctx.server.config?.root ?? node_process.default.cwd();
|
|
9448
|
+
const sourceModules = isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9449
|
+
const hasHmrCandidateAppend = options.hmrCandidateState.hasPendingCandidateAppend() || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
9450
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && options.isUniViteProject())) {
|
|
9451
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9452
|
+
return [];
|
|
9453
|
+
}
|
|
9454
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.isNuxtPageMacroHotModule(mod.id ?? mod.url))) {
|
|
9455
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9456
|
+
return [];
|
|
9457
|
+
}
|
|
9458
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
9459
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9460
|
+
return [];
|
|
9461
|
+
}
|
|
9462
|
+
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);
|
|
9463
|
+
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9464
|
+
if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
|
|
9465
|
+
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
9466
|
+
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;
|
|
9467
|
+
if (isSourceCandidateHotUpdate && !require_v4_generation_core.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
9468
|
+
return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, ctx.modules, cssModules) : void 0;
|
|
9469
|
+
}, { emit: false });
|
|
9470
|
+
}
|
|
9079
9471
|
},
|
|
9080
9472
|
async buildStart() {
|
|
9081
9473
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
@@ -9084,9 +9476,24 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9084
9476
|
};
|
|
9085
9477
|
}
|
|
9086
9478
|
//#endregion
|
|
9479
|
+
//#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
|
|
9480
|
+
const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
|
|
9481
|
+
function createFrameworkHmrRuntimeSignature(file, source) {
|
|
9482
|
+
if (!source || !WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(source)) return "";
|
|
9483
|
+
return (isSfcStyleSourceFile((0, _weapp_tailwindcss_shared.cleanUrl)(file)) ? extractSfcStyleSources(source).filter((styleSource) => WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(styleSource)) : [source]).map((styleSource) => require_v4_generation_core.createRuntimeAffectingSourceSignature(styleSource, "css")).join("\0");
|
|
9484
|
+
}
|
|
9485
|
+
function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
|
|
9486
|
+
return createFrameworkHmrRuntimeSignature(file, previousSource) !== createFrameworkHmrRuntimeSignature(file, nextSource);
|
|
9487
|
+
}
|
|
9488
|
+
//#endregion
|
|
9087
9489
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9088
9490
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9089
9491
|
const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9492
|
+
async function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx) {
|
|
9493
|
+
const source = typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9494
|
+
await sourceScanSession.syncChangedFile(ctx.file, source);
|
|
9495
|
+
await sourceScanSession.waitForPendingSyncs();
|
|
9496
|
+
}
|
|
9090
9497
|
function createFrameworkSourceScanSession(options) {
|
|
9091
9498
|
const sourceCandidateScanCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9092
9499
|
let sourceScanEntries;
|
|
@@ -9097,6 +9504,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9097
9504
|
let sourceCandidateScanInvalidated = true;
|
|
9098
9505
|
const pendingSourceCandidateSyncs = /* @__PURE__ */ new Set();
|
|
9099
9506
|
const pendingSourceCandidateSyncByFile = /* @__PURE__ */ new Map();
|
|
9507
|
+
const pendingHotUpdateChangeByFile = /* @__PURE__ */ new Map();
|
|
9100
9508
|
const normalizeDependency = (file) => node_path.default.normalize(node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(file)));
|
|
9101
9509
|
const isDependency = (file) => sourceScanDependencies.has(normalizeDependency(file));
|
|
9102
9510
|
const invalidate = () => {
|
|
@@ -9198,6 +9606,26 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9198
9606
|
const waitForPendingSyncs = async () => {
|
|
9199
9607
|
while (pendingSourceCandidateSyncs.size > 0) await Promise.all(pendingSourceCandidateSyncs);
|
|
9200
9608
|
};
|
|
9609
|
+
const rememberHotUpdateChange = (change) => {
|
|
9610
|
+
if (!change) return;
|
|
9611
|
+
const previous = pendingHotUpdateChangeByFile.get(change.file);
|
|
9612
|
+
if (!previous) {
|
|
9613
|
+
const remembered = {
|
|
9614
|
+
...change,
|
|
9615
|
+
addedCandidates: new Set(change.addedCandidates),
|
|
9616
|
+
removedCandidates: new Set(change.removedCandidates)
|
|
9617
|
+
};
|
|
9618
|
+
pendingHotUpdateChangeByFile.set(change.file, remembered);
|
|
9619
|
+
return remembered;
|
|
9620
|
+
}
|
|
9621
|
+
for (const candidate of change.addedCandidates) {
|
|
9622
|
+
previous.addedCandidates.add(candidate);
|
|
9623
|
+
previous.removedCandidates.delete(candidate);
|
|
9624
|
+
}
|
|
9625
|
+
for (const candidate of change.removedCandidates) if (!previous.addedCandidates.delete(candidate)) previous.removedCandidates.add(candidate);
|
|
9626
|
+
previous.runtimeAffecting || (previous.runtimeAffecting = change.runtimeAffecting);
|
|
9627
|
+
return previous;
|
|
9628
|
+
};
|
|
9201
9629
|
const syncChangedFile = (id, sourceOverride) => {
|
|
9202
9630
|
if (!options.shouldOwnTailwindGeneration || !options.isCandidateRequest(id)) return Promise.resolve(void 0);
|
|
9203
9631
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
@@ -9208,15 +9636,18 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9208
9636
|
cacheCurrent();
|
|
9209
9637
|
return (require_v4_generation_core.isSourceStyleRequest(file) ? (0, node_fs_promises.readFile)(file, "utf8").then((source) => options.cssMemory.refreshRememberedCssSourceBySourceFile(file, source)).catch((error) => {
|
|
9210
9638
|
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) !== "ENOENT") options.debug("remembered css source watch refresh failed: %s %O", file, error);
|
|
9211
|
-
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true })));
|
|
9639
|
+
}) : Promise.resolve()).then(() => options.cssMemory.refreshRememberedCssSourceByCurrentFile(file)).then(() => rememberHotUpdateChange(options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: true }))));
|
|
9212
9640
|
}
|
|
9213
9641
|
const existingTask = pendingSourceCandidateSyncByFile.get(file);
|
|
9214
9642
|
if (existingTask) return existingTask.then(() => syncChangedFile(id, sourceOverride));
|
|
9643
|
+
const previousSource = options.sourceCandidateCollector.source(file);
|
|
9215
9644
|
const task = (sourceOverride === void 0 ? options.sourceCandidateCollector.syncCurrentFile(id) : options.sourceCandidateCollector.syncCurrentSource(id, sourceOverride)).catch((error) => {
|
|
9216
9645
|
options.debug("source candidate watch sync failed: %s %O", id, error);
|
|
9217
9646
|
}).then((change) => {
|
|
9218
9647
|
cacheCurrent();
|
|
9219
|
-
|
|
9648
|
+
const runtimeAffectingBySource = hasFrameworkHmrRuntimeSourceChange(file, previousSource, options.sourceCandidateCollector.source(file));
|
|
9649
|
+
const appliedChange = change ? options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, change, { runtimeAffecting: runtimeAffectingByDependency || runtimeAffectingBySource })) : void 0;
|
|
9650
|
+
return rememberHotUpdateChange(appliedChange) ?? pendingHotUpdateChangeByFile.get(file);
|
|
9220
9651
|
}).finally(() => {
|
|
9221
9652
|
pendingSourceCandidateSyncs.delete(task);
|
|
9222
9653
|
pendingSourceCandidateSyncByFile.delete(file);
|
|
@@ -9230,9 +9661,11 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9230
9661
|
};
|
|
9231
9662
|
return {
|
|
9232
9663
|
cacheCurrent,
|
|
9664
|
+
consumeHotUpdateChange: (id) => pendingHotUpdateChangeByFile.delete((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
9233
9665
|
getStats: () => ({
|
|
9234
9666
|
pendingSourceCandidateSyncByFile: pendingSourceCandidateSyncByFile.size,
|
|
9235
9667
|
pendingSourceCandidateSyncs: pendingSourceCandidateSyncs.size,
|
|
9668
|
+
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
9236
9669
|
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
9237
9670
|
}),
|
|
9238
9671
|
invalidate,
|
|
@@ -9249,12 +9682,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9249
9682
|
function createFrameworkTailwindRootCss(options) {
|
|
9250
9683
|
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
9251
9684
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
9252
|
-
const normalizeSourceFile = (id) =>
|
|
9685
|
+
const normalizeSourceFile = (id) => resolveViteModuleIdentity(id).key;
|
|
9253
9686
|
const rememberModule = (id) => {
|
|
9254
9687
|
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
9255
9688
|
moduleIds.add(id);
|
|
9256
|
-
const
|
|
9257
|
-
if (require_v4_generation_core.isSourceStyleRequest(cleanId)) moduleIds.add(
|
|
9689
|
+
const identity = resolveViteModuleIdentity(id);
|
|
9690
|
+
if (require_v4_generation_core.isSourceStyleRequest(identity.cleanId)) for (const moduleId of identity.lookupIds) moduleIds.add(moduleId);
|
|
9258
9691
|
};
|
|
9259
9692
|
const register = async (id, code) => {
|
|
9260
9693
|
rememberModule(id);
|
|
@@ -9558,7 +9991,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9558
9991
|
generatedClassSetByFile,
|
|
9559
9992
|
getCommand: () => resolvedConfig?.command,
|
|
9560
9993
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9561
|
-
|
|
9994
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && !resolveCurrentGeneratorBranch().isWeb && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(file))
|
|
9562
9995
|
});
|
|
9563
9996
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9564
9997
|
cssMemory,
|
|
@@ -9666,8 +10099,8 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9666
10099
|
const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
|
|
9667
10100
|
const transient = hookContext?.transient === true;
|
|
9668
10101
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9669
|
-
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
9670
|
-
const runtime = fullRuntime;
|
|
10102
|
+
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(file, pendingHmrChange !== void 0);
|
|
10103
|
+
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9671
10104
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9672
10105
|
css: generatorTransformCode,
|
|
9673
10106
|
cssPipelineContext,
|
|
@@ -9686,7 +10119,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9686
10119
|
markViteProcessedCssSource(file);
|
|
9687
10120
|
rememberTailwindRootCssModule(id);
|
|
9688
10121
|
recordGeneratorCandidates(fullRuntime);
|
|
9689
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10122
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
9690
10123
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
9691
10124
|
cssMemory.rememberCssSource({
|
|
9692
10125
|
outputFile,
|
|
@@ -9740,8 +10173,8 @@ ${previousTracedCss}`;
|
|
|
9740
10173
|
previousCss: previousGeneratorCss,
|
|
9741
10174
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
9742
10175
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
9743
|
-
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
9744
|
-
disableSourceScan:
|
|
10176
|
+
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
10177
|
+
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
9745
10178
|
cssStage: hookContext?.cssStage,
|
|
9746
10179
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
9747
10180
|
}), {
|
|
@@ -9795,9 +10228,9 @@ ${previousTracedCss}`;
|
|
|
9795
10228
|
source: tracedCss
|
|
9796
10229
|
});
|
|
9797
10230
|
markViteProcessedCssSource(file);
|
|
9798
|
-
rememberTailwindRootCssModule(id);
|
|
10231
|
+
if (require_generator.hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
9799
10232
|
recordGeneratorCandidates(fullRuntime);
|
|
9800
|
-
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
10233
|
+
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
9801
10234
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
9802
10235
|
cssMemory.rememberCssSource({
|
|
9803
10236
|
outputFile,
|
|
@@ -9808,6 +10241,11 @@ ${previousTracedCss}`;
|
|
|
9808
10241
|
return `${require_v4_generation_core.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
9809
10242
|
${tracedCss}`;
|
|
9810
10243
|
};
|
|
10244
|
+
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
10245
|
+
...createCssPipelineContext(),
|
|
10246
|
+
code,
|
|
10247
|
+
id
|
|
10248
|
+
}) === true;
|
|
9811
10249
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
9812
10250
|
getAppType: () => opts.appType,
|
|
9813
10251
|
generateTailwindCss: generateTailwindCssForVitePipeline,
|
|
@@ -9815,7 +10253,7 @@ ${tracedCss}`;
|
|
|
9815
10253
|
onTailwindRootCss: registerTailwindRootCss,
|
|
9816
10254
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
9817
10255
|
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
9818
|
-
shouldDeferGeneration: (
|
|
10256
|
+
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports && require_generator.hasTailwindRootDirectives(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }) || shouldDeferFrameworkPreTransformGeneration(id, code),
|
|
9819
10257
|
shouldOwnTailwindGeneration,
|
|
9820
10258
|
shouldRewrite: shouldRewriteCssImports,
|
|
9821
10259
|
weappTailwindcssDirPosix
|
|
@@ -9898,6 +10336,7 @@ ${tracedCss}`;
|
|
|
9898
10336
|
getRememberedMainCssSource: cssMemory.getRememberedCssSourceEntry
|
|
9899
10337
|
});
|
|
9900
10338
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10339
|
+
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
9901
10340
|
const prepareTailwindGeneration = async () => {
|
|
9902
10341
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
9903
10342
|
await sourceScanSession.sync();
|
|
@@ -9910,10 +10349,13 @@ ${tracedCss}`;
|
|
|
9910
10349
|
getResolvedConfig,
|
|
9911
10350
|
isEnabled: shouldEnableFrameworkExtraPlugins,
|
|
9912
10351
|
isIosPlatform: extraPluginPlatform.isIosPlatform === true,
|
|
10352
|
+
isNativeAppStyleTarget: () => frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(createCssPipelineContext()) === true,
|
|
10353
|
+
isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
9913
10354
|
jsHandler,
|
|
9914
10355
|
mainCssChunkMatcher,
|
|
9915
10356
|
runtimeState,
|
|
9916
10357
|
styleHandler,
|
|
10358
|
+
syncSourceCandidatesForHotUpdate,
|
|
9917
10359
|
tailwindRootCssModuleIds,
|
|
9918
10360
|
uniAppX,
|
|
9919
10361
|
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
@@ -9983,12 +10425,14 @@ ${tracedCss}`;
|
|
|
9983
10425
|
syncCssEntriesFromAnchor
|
|
9984
10426
|
});
|
|
9985
10427
|
const plugins = [
|
|
10428
|
+
...extraPlugins,
|
|
9986
10429
|
...rewritePlugins,
|
|
9987
10430
|
sourceCandidatesPlugin,
|
|
9988
10431
|
...createViteCssGenerationPlugins({
|
|
9989
10432
|
generateCss: generateTailwindCssForVitePipeline,
|
|
9990
10433
|
getCommand: () => resolvedConfig?.command,
|
|
9991
10434
|
onTailwindRootCss: registerTailwindRootCss,
|
|
10435
|
+
shouldDeferGeneration: shouldDeferFrameworkPreTransformGeneration,
|
|
9992
10436
|
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
9993
10437
|
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
9994
10438
|
}),
|
|
@@ -10011,7 +10455,6 @@ ${tracedCss}`;
|
|
|
10011
10455
|
},
|
|
10012
10456
|
postPlugin
|
|
10013
10457
|
];
|
|
10014
|
-
plugins.push(...extraPlugins);
|
|
10015
10458
|
plugins.push(cssFinalizerOutputPlugin);
|
|
10016
10459
|
plugins.push(...require_source_candidate_scan_signature.createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|
|
10017
10460
|
return plugins;
|
|
@@ -10273,7 +10716,8 @@ function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
|
10273
10716
|
//#endregion
|
|
10274
10717
|
//#region src/bundlers/vite/frameworks/uni-app-x/index.ts
|
|
10275
10718
|
function isUniAppXNativeAppStyleTarget(context) {
|
|
10276
|
-
|
|
10719
|
+
const stylePlatform = context?.resolveStylePlatform?.();
|
|
10720
|
+
return require_generator.resolveUniUtsPlatform().isApp || stylePlatform === "app" || stylePlatform === "app-plus" || stylePlatform?.startsWith("app-") === true || isUniAppXNativeAppOutDir(context?.resolvedConfig?.build?.outDir) || isUniAppXNativeAppOutDir(context?.resolvedConfig?.root);
|
|
10277
10721
|
}
|
|
10278
10722
|
function isUniAppXHarmonyAppStyleTarget(context) {
|
|
10279
10723
|
const uniUtsPlatform = require_generator.resolveUniUtsPlatform();
|
|
@@ -10300,6 +10744,9 @@ const uniAppXCssPipelineStrategy = {
|
|
|
10300
10744
|
if (!context.cssHandlerOptions.isMainChunk && require_generator.hasTailwindApplyDirective(context.generatorCode)) return false;
|
|
10301
10745
|
return true;
|
|
10302
10746
|
},
|
|
10747
|
+
shouldDeferPreTransformTailwindGeneration(context) {
|
|
10748
|
+
return resolveUniAppXCssTarget(context.id) === "uvue" && require_generator.hasTailwindApplyDirective(context.code) && !require_generator.hasTailwindRootDirectives(context.code, { importFallback: true });
|
|
10749
|
+
},
|
|
10303
10750
|
transformGeneratedCss(css, context) {
|
|
10304
10751
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
10305
10752
|
return withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
@@ -10322,10 +10769,13 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10322
10769
|
getResolvedConfig: context.getResolvedConfig,
|
|
10323
10770
|
isEnabled: context.isEnabled,
|
|
10324
10771
|
isIosPlatform: context.isIosPlatform,
|
|
10772
|
+
isNativeAppStyleTarget: context.isNativeAppStyleTarget,
|
|
10773
|
+
isWebGeneratorTarget: context.isWebGeneratorTarget,
|
|
10325
10774
|
jsHandler: context.jsHandler,
|
|
10326
10775
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10327
10776
|
runtimeState: context.runtimeState,
|
|
10328
10777
|
styleHandler: context.styleHandler,
|
|
10778
|
+
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
|
10329
10779
|
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10330
10780
|
uniAppX: context.uniAppX,
|
|
10331
10781
|
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|