weapp-tailwindcss 5.2.7 → 5.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -3
- package/dist/bundlers/vite/module-identity.d.ts +9 -0
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +4 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -1
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -0
- package/dist/cli.js +1 -0
- package/dist/{context-YAvTyPV2.js → context-BMkbwnH8.js} +10 -23
- package/dist/{context-OqD_eBxQ.cjs → context-CByXWyhQ.cjs} +179 -25
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-BE34PYSC.cjs → generator-B0dCFlP1.cjs} +10 -0
- package/dist/{generator-DYeAa2-5.js → generator-BLpOsd5O.js} +10 -0
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-BydhuCbr.js → gulp-BWhCahA2.js} +4 -4
- package/dist/{gulp-Bun9iCRE.cjs → gulp-BdoorWb5.cjs} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Gs9P-QtZ.js → hmr-timing-CJocHeZr.js} +22 -14
- package/dist/{hmr-timing-D607CWrq.cjs → hmr-timing-DiYnyg_W.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-hVsoTfwL.cjs → options-zpZez7qe.cjs} +1 -1
- package/dist/{pipeline-helpers-BLpoT8fX.cjs → pipeline-helpers-CsNLoEX1.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{source-candidate-scan-signature-BGDNJE2r.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-CdjPWQqv.js → source-candidate-scan-signature-of-TmeOs.js} +3 -3
- package/dist/{style-options-B_ppaVIg.cjs → style-options-COpQc8fr.cjs} +2 -2
- package/dist/{tailwindcss-CTpCc_nd.js → tailwindcss-2zdmASlM.js} +1 -1
- package/dist/{tailwindcss-DcpiKvmJ.cjs → tailwindcss-LtnGCxF0.cjs} +2 -2
- package/dist/{transform-BbaPIji9.js → transform-DVGsr8cV.js} +24 -7
- package/dist/{transform-BUEyOCT7.cjs → transform-DzVJW6Dp.cjs} +24 -7
- package/dist/uni-app-x/component-local-style.d.ts +1 -0
- package/dist/uni-app-x/vite/author-apply.d.ts +1 -0
- package/dist/uni-app-x/vite/harmony-apply.d.ts +4 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +27 -0
- package/dist/uni-app-x/vite/style-request.d.ts +3 -0
- package/dist/uni-app-x/vite.d.ts +3 -24
- package/dist/{v4-generation-core-BrkM1vCs.cjs → v4-generation-core-BjHT6qGC.cjs} +22 -14
- package/dist/{vite-DM-U-Ins.js → vite-BJJqWc_F.js} +505 -188
- package/dist/{vite-n0mRgEcF.cjs → vite-V86H6PZa.cjs} +508 -191
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{webpack-BlUJf8Ru.js → webpack-CkeFhPY2.js} +6 -6
- package/dist/{webpack-Bf8yJwTO.cjs → webpack-CzQrloDg.cjs} +9 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
2
|
-
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-
|
|
2
|
+
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, K as hasUserCssLayerBlocks, L as hasMiniProgramCssSpecificityPlaceholders, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, S as findNearestPackageRoot, U as normalizeEmptyTailwindCustomVariants, X as hasTailwindApplyDirective, Y as hasLocalCssImport, Z as hasTailwindNonRootGenerationDirectives, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, kt as resolveTailwindV4CssSourceBase, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, mt as stripGeneratorPlaceholderMarkers, nt as normalizeTailwindSourceForGenerator, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, ut as hasTailwindGeneratedCssMarkers, wt as isFileMatchedByTailwindSourceEntries, x as normalizeCssEntries } from "./generator-BLpOsd5O.js";
|
|
3
3
|
import { t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
4
|
-
import { _ as resolveTailwindV4EntriesFromCssCached, a as findTailwindConfig, f as createSourceScanMatcher, h as resolveTailwindV4CssDependencies, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
4
|
+
import { _ as resolveTailwindV4EntriesFromCssCached, a as findTailwindConfig, f as createSourceScanMatcher, h as resolveTailwindV4CssDependencies, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-2zdmASlM.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { A as createCssSourceTraceCacheSignature, B as finalizeCompilerShadowRun, C as createBundlerGeneratedCssMarker, D as finalizeMiniProgramCssStructure, E as stripBundlerGeneratedCssMarkers, J as disposeCompilerOwner, K as updateRuntimeCompilationBuildState, L as isPureLocalCssImportWrapper, N as processCachedTask, O as hasEmptyAtRuleBlockCandidate, P as createRuntimeClassSetManager, S as stripRequestQuery, T as parseBundlerGeneratedCssMarkerBlocks, U as createRuntimeCompilationBuildState, V as buildRuntimeCompilationSnapshot, Y as beginCompilerShadowRun, Z as AssetEmissionPlan, a as extractMarkedUserLayerComponentsCss, at as extractCandidatesFromSource, d as normalizeMiniProgramGeneratorCssSource, et as recordCompilationDependencyChanges, f as normalizeMiniProgramImportShell, h as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, it as isSourceCandidateRequest, j as createCssTokenSourceMap, k as annotateCssSourceTrace, nt as createSourceCandidateCollector, o as mergeMarkedUserLayerComponentsCss, p as scoreTailwindV4CssSourceFileMatch, q as createRuntimeAffectingSourceSignature, r as generateTailwindV4Css, t as createHmrTimingRecorder, tt as createCompilationDependencyChanges, u as runWithConcurrency, w as hasBundlerGeneratedCssMarker, x as isSourceStyleRequest } from "./hmr-timing-
|
|
6
|
+
import { A as createCssSourceTraceCacheSignature, B as finalizeCompilerShadowRun, C as createBundlerGeneratedCssMarker, D as finalizeMiniProgramCssStructure, E as stripBundlerGeneratedCssMarkers, J as disposeCompilerOwner, K as updateRuntimeCompilationBuildState, L as isPureLocalCssImportWrapper, N as processCachedTask, O as hasEmptyAtRuleBlockCandidate, P as createRuntimeClassSetManager, S as stripRequestQuery, T as parseBundlerGeneratedCssMarkerBlocks, U as createRuntimeCompilationBuildState, V as buildRuntimeCompilationSnapshot, Y as beginCompilerShadowRun, Z as AssetEmissionPlan, a as extractMarkedUserLayerComponentsCss, at as extractCandidatesFromSource, d as normalizeMiniProgramGeneratorCssSource, et as recordCompilationDependencyChanges, f as normalizeMiniProgramImportShell, h as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, it as isSourceCandidateRequest, j as createCssTokenSourceMap, k as annotateCssSourceTrace, nt as createSourceCandidateCollector, o as mergeMarkedUserLayerComponentsCss, p as scoreTailwindV4CssSourceFileMatch, q as createRuntimeAffectingSourceSignature, r as generateTailwindV4Css, t as createHmrTimingRecorder, tt as createCompilationDependencyChanges, u as runWithConcurrency, w as hasBundlerGeneratedCssMarker, x as isSourceStyleRequest } from "./hmr-timing-CJocHeZr.js";
|
|
7
7
|
import { h as createDebug, m as replaceWxml } from "./wxml-IBzZSaQC.js";
|
|
8
|
-
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-
|
|
8
|
+
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-BMkbwnH8.js";
|
|
9
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-of-TmeOs.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
11
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
@@ -18,6 +18,7 @@ import { readFile } from "node:fs/promises";
|
|
|
18
18
|
import micromatch from "micromatch";
|
|
19
19
|
import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
20
20
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
21
22
|
import { Buffer } from "node:buffer";
|
|
22
23
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
24
|
import { parse } from "comment-json";
|
|
@@ -399,6 +400,7 @@ function resolveReferencePaths(styleSource, sourceId) {
|
|
|
399
400
|
return styleSource;
|
|
400
401
|
}
|
|
401
402
|
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
403
|
+
const pathApi = /^[a-z]:[\\/]/i.test(cleanSourceId) ? path.win32 : path;
|
|
402
404
|
root.walkAtRules("reference", (rule) => {
|
|
403
405
|
const quote = rule.params[0];
|
|
404
406
|
if (quote !== "\"" && quote !== "'") return;
|
|
@@ -406,7 +408,7 @@ function resolveReferencePaths(styleSource, sourceId) {
|
|
|
406
408
|
if (closingQuoteIndex <= 1) return;
|
|
407
409
|
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
408
410
|
if (!referencePath.startsWith(".")) return;
|
|
409
|
-
rule.params = `${quote}${
|
|
411
|
+
rule.params = `${quote}${pathApi.resolve(pathApi.dirname(cleanSourceId), referencePath).replaceAll("\\", "/")}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
410
412
|
});
|
|
411
413
|
return root.toString();
|
|
412
414
|
}
|
|
@@ -2312,6 +2314,8 @@ const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
|
2312
2314
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2313
2315
|
const SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
2314
2316
|
"*",
|
|
2317
|
+
":after",
|
|
2318
|
+
":before",
|
|
2315
2319
|
"::after",
|
|
2316
2320
|
"::before",
|
|
2317
2321
|
"::backdrop",
|
|
@@ -2323,6 +2327,14 @@ const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
2323
2327
|
"::after",
|
|
2324
2328
|
"::before"
|
|
2325
2329
|
]);
|
|
2330
|
+
const UNI_APP_WEB_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
2331
|
+
"uni-view",
|
|
2332
|
+
"uni-text",
|
|
2333
|
+
":after",
|
|
2334
|
+
":before",
|
|
2335
|
+
"::after",
|
|
2336
|
+
"::before"
|
|
2337
|
+
]);
|
|
2326
2338
|
const MINI_PROGRAM_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
2327
2339
|
"box-sizing",
|
|
2328
2340
|
"margin",
|
|
@@ -2429,14 +2441,24 @@ function isScopedUniversalTailwindPreflightRule(rule) {
|
|
|
2429
2441
|
const declarations = getRuleDeclarations(rule);
|
|
2430
2442
|
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));
|
|
2431
2443
|
}
|
|
2444
|
+
function isScopedUniAppWebTailwindPreflightRule(rule) {
|
|
2445
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
2446
|
+
const declarations = getRuleDeclarations(rule);
|
|
2447
|
+
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));
|
|
2448
|
+
}
|
|
2432
2449
|
function isLikelyTailwindGlobalRule(rule) {
|
|
2433
2450
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2434
2451
|
const declarations = getRuleDeclarations(rule);
|
|
2435
|
-
return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
2452
|
+
return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
2436
2453
|
}
|
|
2437
2454
|
function isLikelyTailwindPropertyAtRule(atRule) {
|
|
2438
2455
|
return atRule.name.toLowerCase() === "property" && normalizeCssSignatureValue(atRule.params).startsWith("--tw-");
|
|
2439
2456
|
}
|
|
2457
|
+
function isLikelyTailwindLayerOrderAtRule(atRule) {
|
|
2458
|
+
if (atRule.name.toLowerCase() !== "layer" || atRule.nodes !== void 0) return false;
|
|
2459
|
+
const params = normalizeCssSignatureValue(atRule.params).replace(/\s+/g, "");
|
|
2460
|
+
return params === "properties" || params === "theme" || params === "base" || params === "theme,base,components,utilities";
|
|
2461
|
+
}
|
|
2440
2462
|
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
2441
2463
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2442
2464
|
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
@@ -2455,12 +2477,6 @@ function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
|
2455
2477
|
const declarations = getRuleDeclarations(rule);
|
|
2456
2478
|
return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
|
|
2457
2479
|
}
|
|
2458
|
-
function hasUnscopedMiniProgramTailwindPreflightRule(css) {
|
|
2459
|
-
return /(?:^|[{}])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{/.test(css);
|
|
2460
|
-
}
|
|
2461
|
-
function hasScopedMiniProgramTailwindContentInitRule(css) {
|
|
2462
|
-
return /(?:^|[{}])[^{}]*\.data-v-[\w-][^{}]*\{\s*--tw-content\s*:/.test(css);
|
|
2463
|
-
}
|
|
2464
2480
|
//#endregion
|
|
2465
2481
|
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2466
2482
|
function createDeclarationSignature(rule) {
|
|
@@ -2527,10 +2543,7 @@ function isRuleCoveredByRootCss(rule, coverage) {
|
|
|
2527
2543
|
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
2528
2544
|
if (!hasVueScopedAttr(css)) return css;
|
|
2529
2545
|
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
2530
|
-
const hasUnscopedMiniProgramPreflight = hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2531
|
-
const hasScopedMiniProgramContentInit = hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2532
2546
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2533
|
-
if (coverage.rules.size === 0 && coverage.atRules.size === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2534
2547
|
try {
|
|
2535
2548
|
const root = postcss.parse(css);
|
|
2536
2549
|
let changed = false;
|
|
@@ -2541,13 +2554,13 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
2541
2554
|
}
|
|
2542
2555
|
});
|
|
2543
2556
|
root.walkRules((rule) => {
|
|
2544
|
-
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule)) {
|
|
2557
|
+
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
|
|
2545
2558
|
rule.remove();
|
|
2546
2559
|
changed = true;
|
|
2547
2560
|
}
|
|
2548
2561
|
});
|
|
2549
2562
|
root.walkAtRules((atRule) => {
|
|
2550
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2563
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2551
2564
|
atRule.remove();
|
|
2552
2565
|
changed = true;
|
|
2553
2566
|
return;
|
|
@@ -2581,22 +2594,20 @@ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
|
2581
2594
|
if (css.trim().length === 0) return css;
|
|
2582
2595
|
const hasScopedCss = hasVueScopedAttr(css);
|
|
2583
2596
|
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2584
|
-
|
|
2585
|
-
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2586
|
-
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2597
|
+
if (rootSources.length === 0 && !hasScopedCss) return css;
|
|
2587
2598
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2588
2599
|
let nextCss = css;
|
|
2589
2600
|
try {
|
|
2590
2601
|
const root = postcss.parse(css);
|
|
2591
2602
|
let changed = false;
|
|
2592
2603
|
root.walkRules((rule) => {
|
|
2593
|
-
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule))) {
|
|
2604
|
+
if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
|
|
2594
2605
|
rule.remove();
|
|
2595
2606
|
changed = true;
|
|
2596
2607
|
}
|
|
2597
2608
|
});
|
|
2598
2609
|
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2599
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2610
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2600
2611
|
atRule.remove();
|
|
2601
2612
|
changed = true;
|
|
2602
2613
|
return;
|
|
@@ -5080,7 +5091,7 @@ function injectHarmonyCssIntoMainAsset(bundle, cssSources, isMainCssAsset, plan,
|
|
|
5080
5091
|
return true;
|
|
5081
5092
|
}
|
|
5082
5093
|
async function handleUniAppXPostCssTasks(options) {
|
|
5083
|
-
const { bundle, debug,
|
|
5094
|
+
const { bundle, debug, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteProcessedCssAssetResults, isHarmonyAppStyleTarget, isNativeAppStyleTarget, onUpdate, opts, runtimeState, styleHandler, deferStylePlaceholderInjection } = options;
|
|
5084
5095
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
5085
5096
|
if (opts.appType !== "uni-app-x" && !isNativeAppStyleTarget && !isHarmonyAppStyleTarget) return applyStyleSources;
|
|
5086
5097
|
const emissionPlan = new AssetEmissionPlan();
|
|
@@ -5102,7 +5113,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5102
5113
|
const generated = await generateTailwindV4Css({
|
|
5103
5114
|
opts,
|
|
5104
5115
|
runtimeState,
|
|
5105
|
-
runtime: /* @__PURE__ */ new Set(
|
|
5116
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
5106
5117
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
5107
5118
|
file: outputFile,
|
|
5108
5119
|
outputFile,
|
|
@@ -5112,6 +5123,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5112
5123
|
isMainChunk: false
|
|
5113
5124
|
},
|
|
5114
5125
|
cssStage: "framework-processed",
|
|
5126
|
+
disableSourceScan: true,
|
|
5115
5127
|
getSourceCandidatesForEntries,
|
|
5116
5128
|
styleHandler,
|
|
5117
5129
|
debug
|
|
@@ -5642,6 +5654,53 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
5642
5654
|
return enabled;
|
|
5643
5655
|
}
|
|
5644
5656
|
//#endregion
|
|
5657
|
+
//#region src/uni-app-x/vite/author-apply.ts
|
|
5658
|
+
function normalizeSelector(selector) {
|
|
5659
|
+
return selector.replace(/\s+/g, " ").trim();
|
|
5660
|
+
}
|
|
5661
|
+
function atRuleKey(name, params) {
|
|
5662
|
+
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
5663
|
+
}
|
|
5664
|
+
/**
|
|
5665
|
+
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
5666
|
+
* utilities 和 property 注册复制进 scoped style 模块。
|
|
5667
|
+
*/
|
|
5668
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
|
|
5669
|
+
try {
|
|
5670
|
+
const authorRoot = postcss.parse(removeTailwindSourceDirectives(authorCss, { importFallback: true }));
|
|
5671
|
+
const authorSelectors = /* @__PURE__ */ new Set();
|
|
5672
|
+
const authorAtRules = /* @__PURE__ */ new Set();
|
|
5673
|
+
authorRoot.walkRules((rule) => {
|
|
5674
|
+
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
|
|
5675
|
+
});
|
|
5676
|
+
authorRoot.walkAtRules((atRule) => {
|
|
5677
|
+
if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
5678
|
+
});
|
|
5679
|
+
const root = postcss.parse(generatedCss);
|
|
5680
|
+
let changed = false;
|
|
5681
|
+
root.walkRules((rule) => {
|
|
5682
|
+
if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
|
|
5683
|
+
rule.remove();
|
|
5684
|
+
changed = true;
|
|
5685
|
+
});
|
|
5686
|
+
root.walkAtRules((atRule) => {
|
|
5687
|
+
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
5688
|
+
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
5689
|
+
atRule.remove();
|
|
5690
|
+
changed = true;
|
|
5691
|
+
});
|
|
5692
|
+
root.walkComments((comment) => {
|
|
5693
|
+
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
5694
|
+
comment.remove();
|
|
5695
|
+
changed = true;
|
|
5696
|
+
}
|
|
5697
|
+
});
|
|
5698
|
+
return changed ? root.toString().trim() : generatedCss;
|
|
5699
|
+
} catch {
|
|
5700
|
+
return generatedCss;
|
|
5701
|
+
}
|
|
5702
|
+
}
|
|
5703
|
+
//#endregion
|
|
5645
5704
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
5646
5705
|
function createStableHash(input) {
|
|
5647
5706
|
let hash = 2166136261;
|
|
@@ -5652,23 +5711,43 @@ function createStableHash(input) {
|
|
|
5652
5711
|
return (hash >>> 0).toString(36);
|
|
5653
5712
|
}
|
|
5654
5713
|
function createUniAppXHarmonyApplyExpander(options) {
|
|
5714
|
+
const referenceBySourceId = /* @__PURE__ */ new Map();
|
|
5655
5715
|
const styleSources = /* @__PURE__ */ new Set();
|
|
5656
5716
|
const utilities = /* @__PURE__ */ new Set();
|
|
5657
|
-
function rememberSource(code, id) {
|
|
5717
|
+
function rememberSource(code, id, authoritative = false) {
|
|
5658
5718
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5719
|
+
const sourceKey = normalizePath(cleanUrl(id));
|
|
5720
|
+
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
5659
5721
|
for (const source of sources) {
|
|
5660
5722
|
styleSources.add(source);
|
|
5723
|
+
try {
|
|
5724
|
+
postcss.parse(source).walkAtRules("reference", (rule) => {
|
|
5725
|
+
const reference = rule.toString();
|
|
5726
|
+
references.add(reference.endsWith(";") ? reference : `${reference};`);
|
|
5727
|
+
});
|
|
5728
|
+
} catch {}
|
|
5661
5729
|
for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
5662
5730
|
}
|
|
5731
|
+
if (references.size > 0) referenceBySourceId.set(sourceKey, references);
|
|
5732
|
+
else if (authoritative) referenceBySourceId.delete(sourceKey);
|
|
5733
|
+
}
|
|
5734
|
+
function prepareStyles(code, id) {
|
|
5735
|
+
if (!code.includes("@apply") || code.includes("@reference")) return code;
|
|
5736
|
+
const references = referenceBySourceId.get(normalizePath(cleanUrl(id)));
|
|
5737
|
+
if (references?.size !== 1) return code;
|
|
5738
|
+
return `${references.values().next().value}\n${code}`;
|
|
5663
5739
|
}
|
|
5664
5740
|
async function expandStyles(code, id, hookContext) {
|
|
5665
5741
|
if (!options.isHarmonyBuildTarget() || !code.includes("@apply")) return code;
|
|
5666
|
-
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5742
|
+
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(prepareStyles(code, id), id);
|
|
5667
5743
|
const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
|
|
5668
5744
|
if (sources.length === 0 || sourceUtilities.size === 0) return code;
|
|
5669
5745
|
const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process$1.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl(id)))}.css`);
|
|
5670
|
-
const
|
|
5746
|
+
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
5747
|
+
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
5671
5748
|
addWatchFile: hookContext.addWatchFile?.bind(hookContext),
|
|
5749
|
+
disableSourceScan: true,
|
|
5750
|
+
sourceCandidates: [],
|
|
5672
5751
|
transient: true
|
|
5673
5752
|
});
|
|
5674
5753
|
if (typeof generatedCss !== "string" || generatedCss.trim().length === 0) return code;
|
|
@@ -5676,49 +5755,178 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5676
5755
|
}
|
|
5677
5756
|
return {
|
|
5678
5757
|
expandStyles,
|
|
5758
|
+
prepareStyles,
|
|
5679
5759
|
rememberSource,
|
|
5680
5760
|
styleSources,
|
|
5681
5761
|
utilities
|
|
5682
5762
|
};
|
|
5683
5763
|
}
|
|
5684
5764
|
//#endregion
|
|
5765
|
+
//#region src/bundlers/vite/module-identity.ts
|
|
5766
|
+
const WINDOWS_DRIVE_RE = /^\/?[a-z]:[\\/]/i;
|
|
5767
|
+
const WINDOWS_UNC_RE = /^(?:\\\\|\/\/)/;
|
|
5768
|
+
function unique(values) {
|
|
5769
|
+
return [...new Set([...values].filter((value) => typeof value === "string" && value.length > 0))];
|
|
5770
|
+
}
|
|
5771
|
+
function decodeFileId(id) {
|
|
5772
|
+
try {
|
|
5773
|
+
return decodeURIComponent(id);
|
|
5774
|
+
} catch {
|
|
5775
|
+
return id;
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
function stripViteFsPrefix(id) {
|
|
5779
|
+
if (!id.startsWith("/@fs/")) return id;
|
|
5780
|
+
const file = id.slice(5);
|
|
5781
|
+
return file.startsWith("/") || WINDOWS_DRIVE_RE.test(file) ? file : `/${file}`;
|
|
5782
|
+
}
|
|
5783
|
+
function stripFileProtocol(id) {
|
|
5784
|
+
if (!id.startsWith("file://")) return id;
|
|
5785
|
+
try {
|
|
5786
|
+
return fileURLToPath(id);
|
|
5787
|
+
} catch {
|
|
5788
|
+
return id;
|
|
5789
|
+
}
|
|
5790
|
+
}
|
|
5791
|
+
function isWindowsFile(file) {
|
|
5792
|
+
return WINDOWS_DRIVE_RE.test(file) || WINDOWS_UNC_RE.test(file);
|
|
5793
|
+
}
|
|
5794
|
+
function normalizeWindowsFile(file) {
|
|
5795
|
+
const withoutDriveSlash = /^\/[a-z]:[\\/]/i.test(file) ? file.slice(1) : file;
|
|
5796
|
+
return slash(path.win32.resolve(withoutDriveSlash));
|
|
5797
|
+
}
|
|
5798
|
+
function normalizeFile(file, root) {
|
|
5799
|
+
if (isWindowsFile(file) || isWindowsFile(root)) return normalizeWindowsFile(isWindowsFile(file) ? file : path.win32.resolve(root, file.replace(/^\//, "")));
|
|
5800
|
+
if (path.isAbsolute(file)) {
|
|
5801
|
+
if (file === root || file.startsWith(`${root}${path.sep}`) || existsSync(file) || existsSync(path.dirname(file))) return slash(path.resolve(file));
|
|
5802
|
+
const rootRelativeFile = path.resolve(root, file.slice(1));
|
|
5803
|
+
return existsSync(rootRelativeFile) || existsSync(path.dirname(rootRelativeFile)) ? slash(rootRelativeFile) : slash(path.resolve(file));
|
|
5804
|
+
}
|
|
5805
|
+
return slash(path.resolve(root, file));
|
|
5806
|
+
}
|
|
5807
|
+
function resolveRealFile(file) {
|
|
5808
|
+
if (process$1.platform !== "win32" && isWindowsFile(file)) return file;
|
|
5809
|
+
let current = file;
|
|
5810
|
+
const missingSegments = [];
|
|
5811
|
+
try {
|
|
5812
|
+
while (true) try {
|
|
5813
|
+
const resolvedParent = realpathSync.native(current);
|
|
5814
|
+
return slash(path.join(resolvedParent, ...missingSegments));
|
|
5815
|
+
} catch {
|
|
5816
|
+
const parent = path.dirname(current);
|
|
5817
|
+
if (parent === current) return file;
|
|
5818
|
+
missingSegments.unshift(path.basename(current));
|
|
5819
|
+
current = parent;
|
|
5820
|
+
}
|
|
5821
|
+
} catch {
|
|
5822
|
+
return file;
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
5825
|
+
function normalizeIdentityKey(file) {
|
|
5826
|
+
return isWindowsFile(file) || process$1.platform === "win32" ? file.toLowerCase() : file;
|
|
5827
|
+
}
|
|
5828
|
+
/**
|
|
5829
|
+
* 将 Vite URL、文件路径和 Windows 的等价路径收敛为同一个模块身份。
|
|
5830
|
+
*/
|
|
5831
|
+
function resolveViteModuleIdentity(id, root = process$1.cwd()) {
|
|
5832
|
+
const cleanId = decodeFileId(cleanUrl(id));
|
|
5833
|
+
const decodedRoot = decodeFileId(cleanUrl(root));
|
|
5834
|
+
const normalizedRoot = isWindowsFile(decodedRoot) ? normalizeWindowsFile(decodedRoot) : slash(path.resolve(decodedRoot));
|
|
5835
|
+
const unwrappedId = stripFileProtocol(stripViteFsPrefix(cleanId));
|
|
5836
|
+
const file = unwrappedId.startsWith("\0") ? void 0 : normalizeFile(unwrappedId, normalizedRoot);
|
|
5837
|
+
const realFile = file ? resolveRealFile(file) : void 0;
|
|
5838
|
+
const key = realFile ? normalizeIdentityKey(realFile) : cleanId;
|
|
5839
|
+
const pathApi = isWindowsFile(normalizedRoot) ? path.win32 : path.posix;
|
|
5840
|
+
const relativeUrl = realFile && normalizeIdentityKey(realFile).startsWith(`${normalizeIdentityKey(normalizedRoot)}/`) ? `/${slash(pathApi.relative(normalizedRoot, realFile))}` : void 0;
|
|
5841
|
+
return {
|
|
5842
|
+
cleanId,
|
|
5843
|
+
file: realFile,
|
|
5844
|
+
key,
|
|
5845
|
+
lookupFiles: unique([file, realFile]),
|
|
5846
|
+
lookupIds: unique([
|
|
5847
|
+
id,
|
|
5848
|
+
cleanId,
|
|
5849
|
+
unwrappedId,
|
|
5850
|
+
file,
|
|
5851
|
+
realFile,
|
|
5852
|
+
realFile ? `/@fs/${realFile}` : void 0,
|
|
5853
|
+
relativeUrl
|
|
5854
|
+
])
|
|
5855
|
+
};
|
|
5856
|
+
}
|
|
5857
|
+
function hasSameViteModuleIdentity(left, right, root = process$1.cwd()) {
|
|
5858
|
+
if (!left || !right) return false;
|
|
5859
|
+
return resolveViteModuleIdentity(left, root).key === resolveViteModuleIdentity(right, root).key;
|
|
5860
|
+
}
|
|
5861
|
+
//#endregion
|
|
5685
5862
|
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5686
|
-
function
|
|
5863
|
+
async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
5687
5864
|
const modules = [];
|
|
5688
5865
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5689
5866
|
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
5867
|
+
const seenFileIdentities = /* @__PURE__ */ new Set();
|
|
5868
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5869
|
+
const collectModule = (mod) => {
|
|
5870
|
+
if (mod == null || seenModules.has(mod) || !acceptModule(mod)) return;
|
|
5871
|
+
seenModules.add(mod);
|
|
5872
|
+
modules.push(mod);
|
|
5873
|
+
};
|
|
5874
|
+
for (const id of ids) {
|
|
5875
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
5876
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5877
|
+
for (const moduleId of identity.lookupIds) {
|
|
5878
|
+
if (seenModuleIds.has(moduleId)) continue;
|
|
5879
|
+
seenModuleIds.add(moduleId);
|
|
5880
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(moduleId));
|
|
5881
|
+
if (moduleId.startsWith("/")) collectModule(await ctx.server.moduleGraph.getModuleByUrl?.(moduleId));
|
|
5882
|
+
}
|
|
5883
|
+
if (seenFileIdentities.has(identity.key)) continue;
|
|
5884
|
+
seenFileIdentities.add(identity.key);
|
|
5885
|
+
for (const file of identity.lookupFiles) for (const mod of ctx.server.moduleGraph.getModulesByFile?.(file) ?? []) collectModule(mod);
|
|
5886
|
+
}
|
|
5887
|
+
return modules;
|
|
5888
|
+
}
|
|
5889
|
+
async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5690
5890
|
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5691
|
-
const outDir = ctx.server.config?.build?.outDir ?
|
|
5891
|
+
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
5692
5892
|
const isHotSourceStyleModule = (id) => {
|
|
5693
5893
|
if (!isSourceStyleRequest(id)) return false;
|
|
5694
5894
|
const file = cleanUrl(id);
|
|
5695
5895
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5696
|
-
if (outDir
|
|
5697
|
-
const
|
|
5698
|
-
if (
|
|
5896
|
+
if (outDir) {
|
|
5897
|
+
const identity = resolveViteModuleIdentity(file, root);
|
|
5898
|
+
if (identity.key === outDir.key || identity.key.startsWith(`${outDir.key}/`)) return false;
|
|
5699
5899
|
}
|
|
5700
5900
|
return true;
|
|
5701
5901
|
};
|
|
5702
|
-
const
|
|
5703
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
5902
|
+
const modules = await resolveHotModulesByIds(ctx, tailwindRootCssModuleIds, (mod) => {
|
|
5704
5903
|
const modId = mod.id ?? mod.url;
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
if (moduleId.length === 0 || seenModuleIds.has(moduleId)) continue;
|
|
5714
|
-
seenModuleIds.add(moduleId);
|
|
5715
|
-
const candidates = [ctx.server.moduleGraph.getModuleById(moduleId), ...ctx.server.moduleGraph.getModulesByFile(moduleId) ?? []];
|
|
5716
|
-
for (const mod of candidates) collectModule(mod);
|
|
5904
|
+
return isHotSourceStyleModule(modId);
|
|
5905
|
+
});
|
|
5906
|
+
const seenHotModules = new Set(modules);
|
|
5907
|
+
for (let index = 0; index < modules.length; index++) for (const importer of modules[index]?.importers ?? []) {
|
|
5908
|
+
const importerId = importer.id ?? importer.url;
|
|
5909
|
+
if (!seenHotModules.has(importer) && isHotSourceStyleModule(importerId)) {
|
|
5910
|
+
seenHotModules.add(importer);
|
|
5911
|
+
modules.push(importer);
|
|
5717
5912
|
}
|
|
5718
5913
|
}
|
|
5914
|
+
for (const mod of modules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
5719
5915
|
return modules;
|
|
5720
5916
|
}
|
|
5721
|
-
function
|
|
5917
|
+
async function resolveHotSourceModulesByIds(ctx, ids) {
|
|
5918
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5919
|
+
const sourceIds = new Set(ids);
|
|
5920
|
+
for (const id of ids) {
|
|
5921
|
+
if (typeof id !== "string" || !/\.(?:uvue|nvue)(?:$|[?#])/i.test(id)) continue;
|
|
5922
|
+
const identity = resolveViteModuleIdentity(id, root);
|
|
5923
|
+
for (const lookupId of identity.lookupIds) if (!/[?&]import(?:[=&]|$)/.test(lookupId)) sourceIds.add(`${cleanUrl(lookupId)}?import`);
|
|
5924
|
+
}
|
|
5925
|
+
return resolveHotModulesByIds(ctx, sourceIds, (mod) => {
|
|
5926
|
+
return !isSourceStyleRequest(mod.id ?? mod.url);
|
|
5927
|
+
});
|
|
5928
|
+
}
|
|
5929
|
+
async function resolveHotSourceModules(ctx) {
|
|
5722
5930
|
const modules = [];
|
|
5723
5931
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5724
5932
|
const collectModule = (mod) => {
|
|
@@ -5728,10 +5936,27 @@ function resolveHotSourceModules(ctx) {
|
|
|
5728
5936
|
modules.push(mod);
|
|
5729
5937
|
};
|
|
5730
5938
|
for (const mod of ctx.modules) collectModule(mod);
|
|
5731
|
-
for (const mod of
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5939
|
+
for (const mod of await resolveHotSourceModulesByIds(ctx, [ctx.file])) collectModule(mod);
|
|
5940
|
+
return modules;
|
|
5941
|
+
}
|
|
5942
|
+
function mergeHotModulesByIdentity(root, ...groups) {
|
|
5943
|
+
const modules = [];
|
|
5944
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5945
|
+
const seenIdentities = /* @__PURE__ */ new Set();
|
|
5946
|
+
for (const mod of groups.flat()) {
|
|
5947
|
+
if (seenModules.has(mod)) continue;
|
|
5948
|
+
const ids = [
|
|
5949
|
+
mod.id,
|
|
5950
|
+
mod.url,
|
|
5951
|
+
mod.file
|
|
5952
|
+
].filter((id) => typeof id === "string" && id.length > 0);
|
|
5953
|
+
const moduleKind = ids.some(isSourceStyleRequest) ? "style" : "source";
|
|
5954
|
+
const keys = ids.map((id) => `${moduleKind}:${resolveViteModuleIdentity(id, root).key}`);
|
|
5955
|
+
if (keys.some((key) => seenIdentities.has(key))) continue;
|
|
5956
|
+
seenModules.add(mod);
|
|
5957
|
+
keys.forEach((key) => seenIdentities.add(key));
|
|
5958
|
+
modules.push(mod);
|
|
5959
|
+
}
|
|
5735
5960
|
return modules;
|
|
5736
5961
|
}
|
|
5737
5962
|
function resolveModuleHotUrl(mod) {
|
|
@@ -5750,23 +5975,32 @@ function isRootMiniProgramStyleUrl(file) {
|
|
|
5750
5975
|
}
|
|
5751
5976
|
function resolveCssHotUrl(id, root) {
|
|
5752
5977
|
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5753
|
-
const
|
|
5754
|
-
if (/^\/(
|
|
5755
|
-
if (isRootMiniProgramStyleUrl(
|
|
5756
|
-
return `${
|
|
5978
|
+
const cleanId = cleanUrl(id);
|
|
5979
|
+
if (/^\/(?!@fs\/|[A-Z]:)/i.test(cleanId) && !cleanId.startsWith(slash(root))) {
|
|
5980
|
+
if (isRootMiniProgramStyleUrl(cleanId)) return;
|
|
5981
|
+
return `${cleanId}${suffix}`;
|
|
5757
5982
|
}
|
|
5983
|
+
const file = resolveViteModuleIdentity(id, root).file ?? cleanId;
|
|
5758
5984
|
if (!isAbsoluteFilePath(file)) return;
|
|
5759
5985
|
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5760
5986
|
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5761
5987
|
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5762
5988
|
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5763
5989
|
}
|
|
5764
|
-
function includesHotModule(modules, target) {
|
|
5990
|
+
function includesHotModule(modules, target, root) {
|
|
5765
5991
|
const targetUrl = resolveModuleHotUrl(target);
|
|
5766
5992
|
const targetId = target.id;
|
|
5767
5993
|
return modules.some((mod) => {
|
|
5768
5994
|
if (mod === target) return true;
|
|
5769
|
-
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId
|
|
5995
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId || [
|
|
5996
|
+
target.id,
|
|
5997
|
+
target.url,
|
|
5998
|
+
target.file
|
|
5999
|
+
].some((targetIdentity) => [
|
|
6000
|
+
mod.id,
|
|
6001
|
+
mod.url,
|
|
6002
|
+
mod.file
|
|
6003
|
+
].some((moduleIdentity) => hasSameViteModuleIdentity(targetIdentity, moduleIdentity, root)));
|
|
5770
6004
|
});
|
|
5771
6005
|
}
|
|
5772
6006
|
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
@@ -5784,10 +6018,16 @@ function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
|
5784
6018
|
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5785
6019
|
});
|
|
5786
6020
|
}
|
|
5787
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
6021
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
5788
6022
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
5789
6023
|
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5790
6024
|
const updates = [];
|
|
6025
|
+
for (const id of fallbackSourceIds) {
|
|
6026
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
6027
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
6028
|
+
seenUrls.add(hotUrl);
|
|
6029
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
6030
|
+
}
|
|
5791
6031
|
for (const id of fallbackCssIds) {
|
|
5792
6032
|
if (!isSourceStyleRequest(id)) continue;
|
|
5793
6033
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
@@ -5796,7 +6036,7 @@ function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
|
5796
6036
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5797
6037
|
}
|
|
5798
6038
|
for (const mod of cssModules) {
|
|
5799
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
6039
|
+
if (includesHotModule(ctx.modules, mod, root)) continue;
|
|
5800
6040
|
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5801
6041
|
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5802
6042
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
@@ -5831,12 +6071,25 @@ function createUniAppXNativeHmrReloader(options) {
|
|
|
5831
6071
|
}
|
|
5832
6072
|
async function handleHotUpdate(ctx) {
|
|
5833
6073
|
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5834
|
-
|
|
6074
|
+
await options.syncSourceCandidates?.(ctx);
|
|
5835
6075
|
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5836
|
-
const
|
|
6076
|
+
const hasRuntimeClassChange = previousRuntimeClassSet !== void 0 && (currentRuntimeClassSet.size !== previousRuntimeClassSet.size || [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate)));
|
|
5837
6077
|
remember(currentRuntimeClassSet);
|
|
5838
|
-
|
|
5839
|
-
|
|
6078
|
+
const cssModules = ctx.server?.moduleGraph ? await resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
6079
|
+
const sourceModules = ctx.server?.moduleGraph ? await resolveHotSourceModules(ctx) : ctx.modules ?? [];
|
|
6080
|
+
const localStyleModules = hasRuntimeClassChange && ctx.server?.moduleGraph ? await resolveHotSourceModulesByIds(ctx, options.localStyleModuleIds) : [];
|
|
6081
|
+
for (const mod of /* @__PURE__ */ new Set([...sourceModules, ...localStyleModules])) ctx.server?.moduleGraph?.invalidateModule(mod);
|
|
6082
|
+
const modules = [.../* @__PURE__ */ new Set([
|
|
6083
|
+
...sourceModules,
|
|
6084
|
+
...localStyleModules,
|
|
6085
|
+
...cssModules
|
|
6086
|
+
])];
|
|
6087
|
+
const canAcceptUpdate = hasSelfAcceptingNonStyleHotModule([...sourceModules, ...localStyleModules]) || cssModules.length > 0;
|
|
6088
|
+
if (hasRuntimeClassChange && !canAcceptUpdate) {
|
|
6089
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
6090
|
+
return [];
|
|
6091
|
+
}
|
|
6092
|
+
return modules.length > 0 ? modules : void 0;
|
|
5840
6093
|
}
|
|
5841
6094
|
return {
|
|
5842
6095
|
handleHotUpdate,
|
|
@@ -5856,12 +6109,7 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
5856
6109
|
};
|
|
5857
6110
|
}
|
|
5858
6111
|
//#endregion
|
|
5859
|
-
//#region src/uni-app-x/vite.ts
|
|
5860
|
-
let transformUVuePromise;
|
|
5861
|
-
function loadTransformUVue() {
|
|
5862
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-BbaPIji9.js").then((mod) => mod.transformUVue));
|
|
5863
|
-
return transformUVuePromise;
|
|
5864
|
-
}
|
|
6112
|
+
//#region src/uni-app-x/vite/style-request.ts
|
|
5865
6113
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
5866
6114
|
"scss",
|
|
5867
6115
|
"sass",
|
|
@@ -5871,8 +6119,7 @@ const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
|
5871
6119
|
]);
|
|
5872
6120
|
const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
5873
6121
|
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
5874
|
-
const
|
|
5875
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6122
|
+
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
5876
6123
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
5877
6124
|
function isPreprocessorRequest(id, lang) {
|
|
5878
6125
|
const normalizedLang = lang?.toLowerCase();
|
|
@@ -5882,25 +6129,37 @@ function isPreprocessorRequest(id, lang) {
|
|
|
5882
6129
|
return PREPROCESSOR_EXT_RE.test(id);
|
|
5883
6130
|
}
|
|
5884
6131
|
function resolveUniAppXCssTarget(id) {
|
|
5885
|
-
return UVUE_NVUE_RE.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
5886
|
-
}
|
|
5887
|
-
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
5888
|
-
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
6132
|
+
return UVUE_NVUE_RE$1.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
5889
6133
|
}
|
|
5890
6134
|
function isCssModuleExport(code) {
|
|
5891
6135
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5892
6136
|
}
|
|
6137
|
+
//#endregion
|
|
6138
|
+
//#region src/uni-app-x/vite.ts
|
|
6139
|
+
let transformUVuePromise;
|
|
6140
|
+
function loadTransformUVue() {
|
|
6141
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-DVGsr8cV.js").then((mod) => mod.transformUVue));
|
|
6142
|
+
return transformUVuePromise;
|
|
6143
|
+
}
|
|
6144
|
+
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
6145
|
+
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6146
|
+
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
6147
|
+
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
6148
|
+
}
|
|
5893
6149
|
function createUniAppXPlugins(options) {
|
|
5894
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6150
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5895
6151
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
5896
6152
|
const utsPlatform = resolveUniUtsPlatform();
|
|
5897
6153
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5898
6154
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6155
|
+
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
5899
6156
|
let componentLocalStyleEnabled;
|
|
5900
6157
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5901
6158
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5902
6159
|
ensureRuntimeClassSet,
|
|
5903
6160
|
isNativeAppBuildTarget,
|
|
6161
|
+
localStyleModuleIds: nativeLocalStyleModuleIds,
|
|
6162
|
+
syncSourceCandidates: syncSourceCandidatesForHotUpdate,
|
|
5904
6163
|
tailwindRootCssModuleIds,
|
|
5905
6164
|
viteProcessedCssSourceFiles
|
|
5906
6165
|
});
|
|
@@ -5925,13 +6184,15 @@ function createUniAppXPlugins(options) {
|
|
|
5925
6184
|
if (resolveUniUtsPlatform().isAppHarmony) return true;
|
|
5926
6185
|
return isUniAppXHarmonyOutDir(getResolvedConfig()?.build?.outDir);
|
|
5927
6186
|
}
|
|
5928
|
-
function getStyleHandlerOptions(id) {
|
|
5929
|
-
const
|
|
6187
|
+
function getStyleHandlerOptions(id, source) {
|
|
6188
|
+
const isMainChunk = source === "tailwind-root" || mainCssChunkMatcher(id, appType);
|
|
6189
|
+
const cacheKey = `${isMainChunk ? "1" : "0"}:${source ?? ""}:${id}`;
|
|
5930
6190
|
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
5931
6191
|
if (!styleHandlerOptions) {
|
|
5932
6192
|
styleHandlerOptions = omitUndefined({
|
|
5933
|
-
isMainChunk
|
|
6193
|
+
isMainChunk,
|
|
5934
6194
|
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
6195
|
+
uniAppXCssSource: isNativeAppBuildTarget(id) ? source : void 0,
|
|
5935
6196
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5936
6197
|
postcssOptions: { options: {
|
|
5937
6198
|
from: id,
|
|
@@ -5951,16 +6212,24 @@ function createUniAppXPlugins(options) {
|
|
|
5951
6212
|
for (const warning of warnings) logger$1.warn(warning.toString());
|
|
5952
6213
|
}
|
|
5953
6214
|
async function transformStyle(code, id, query, hookContext) {
|
|
5954
|
-
isNativeAppBuildTarget(id);
|
|
6215
|
+
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
5955
6216
|
const parsed = query ?? parseVueRequest(id).query;
|
|
5956
6217
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5957
6218
|
if (isCssModuleExport(code)) return;
|
|
5958
|
-
const
|
|
5959
|
-
|
|
6219
|
+
const hasTailwindRoot = hasTailwindRootDirectives(code, { importFallback: true });
|
|
6220
|
+
const hasTailwindApply = hasTailwindApplyDirective(code);
|
|
6221
|
+
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
6222
|
+
const isNativeSfcAuthorStyle = isNativeStyle && resolveUniAppXCssTarget(id) === "uvue";
|
|
6223
|
+
if (!shouldGenerateCss && (!isNativeStyle || isNativeSfcAuthorStyle)) return;
|
|
5960
6224
|
harmonyApply.rememberSource(code, id);
|
|
5961
|
-
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code,
|
|
5962
|
-
|
|
5963
|
-
|
|
6225
|
+
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(code, id) : code, {
|
|
6226
|
+
...hookContext,
|
|
6227
|
+
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
6228
|
+
sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
|
|
6229
|
+
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
6230
|
+
}) : void 0;
|
|
6231
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, code) : generatedCss : code;
|
|
6232
|
+
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
5964
6233
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
5965
6234
|
reportStyleWarnings(postcssResult);
|
|
5966
6235
|
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath(cleanUrl(id)));
|
|
@@ -5975,7 +6244,7 @@ function createUniAppXPlugins(options) {
|
|
|
5975
6244
|
getResolvedConfig,
|
|
5976
6245
|
isHarmonyBuildTarget,
|
|
5977
6246
|
async transformCss(css, id) {
|
|
5978
|
-
const result = await styleHandler(css, getStyleHandlerOptions(id));
|
|
6247
|
+
const result = await styleHandler(css, getStyleHandlerOptions(id, "author-apply"));
|
|
5979
6248
|
reportStyleWarnings(result);
|
|
5980
6249
|
return result.css;
|
|
5981
6250
|
}
|
|
@@ -6012,40 +6281,46 @@ function createUniAppXPlugins(options) {
|
|
|
6012
6281
|
if (!isEnabled()) return;
|
|
6013
6282
|
await nativeHmrReloader.refreshBaseline();
|
|
6014
6283
|
},
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6284
|
+
transform: {
|
|
6285
|
+
order: "pre",
|
|
6286
|
+
async handler(code, id) {
|
|
6287
|
+
if (!isEnabled()) return;
|
|
6288
|
+
if (!UVUE_NVUE_QUERY_RE.test(id)) return;
|
|
6289
|
+
if (isNativeAppBuildTarget(id)) {
|
|
6290
|
+
nativeLocalStyleModuleIds.add(id);
|
|
6291
|
+
nativeLocalStyleModuleIds.add(cleanUrl(id));
|
|
6292
|
+
}
|
|
6293
|
+
harmonyApply.rememberSource(code, id, true);
|
|
6294
|
+
const resolvedConfig = getResolvedConfig();
|
|
6295
|
+
const isServeCommand = resolvedConfig?.command === "serve";
|
|
6296
|
+
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
6297
|
+
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
6298
|
+
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6299
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6300
|
+
const transformUVue = await loadTransformUVue();
|
|
6301
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6302
|
+
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
6303
|
+
const result = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler || enableComponentLocalStyle || enablePageLocalStyle ? transformUVue(code, id, jsHandler, currentRuntimeSet, omitUndefined({
|
|
6304
|
+
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6305
|
+
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6306
|
+
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6307
|
+
...enablePageLocalStyle ? { enablePageLocalStyle } : {}
|
|
6308
|
+
})) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
6309
|
+
if (result?.code) {
|
|
6310
|
+
harmonyApply.rememberSource(result.code, id);
|
|
6311
|
+
const expandedCode = await harmonyApply.expandStyles(result.code, id, this);
|
|
6312
|
+
if (expandedCode !== result.code) return {
|
|
6313
|
+
code: expandedCode,
|
|
6314
|
+
map: null
|
|
6315
|
+
};
|
|
6316
|
+
}
|
|
6317
|
+
return result;
|
|
6042
6318
|
}
|
|
6043
|
-
return result;
|
|
6044
6319
|
},
|
|
6045
6320
|
async handleHotUpdate(ctx) {
|
|
6046
6321
|
if (!isEnabled()) return;
|
|
6047
6322
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
6048
|
-
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
6323
|
+
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6049
6324
|
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
6050
6325
|
},
|
|
6051
6326
|
async watchChange(id) {
|
|
@@ -6074,7 +6349,12 @@ function createUniAppXPlugins(options) {
|
|
|
6074
6349
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApply.utilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
6075
6350
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
6076
6351
|
const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process$1.cwd(), "uni-app-x-harmony-apply.css");
|
|
6077
|
-
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
6352
|
+
const generatedCss = await generateCss?.(harmonyApplyCssFile, createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities), {
|
|
6353
|
+
addWatchFile: this?.addWatchFile?.bind(this),
|
|
6354
|
+
disableSourceScan: true,
|
|
6355
|
+
sourceCandidates: [],
|
|
6356
|
+
transient: true
|
|
6357
|
+
});
|
|
6078
6358
|
if (typeof generatedCss === "string" && generatedCss.trim().length > 0) cssSources.push(generatedCss);
|
|
6079
6359
|
}
|
|
6080
6360
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
@@ -7791,12 +8071,11 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7791
8071
|
});
|
|
7792
8072
|
};
|
|
7793
8073
|
collectViteProcessedCssAssets();
|
|
7794
|
-
const createHarmonyBundleStyleSources = async (
|
|
8074
|
+
const createHarmonyBundleStyleSources = async () => {
|
|
7795
8075
|
const cssSources = collectViteProcessedCssSources(getViteProcessedCssAssetResults);
|
|
7796
8076
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
7797
8077
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
7798
8078
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
7799
|
-
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
7800
8079
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7801
8080
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
7802
8081
|
file: "uni-app-x-harmony-apply.css"
|
|
@@ -7804,7 +8083,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7804
8083
|
const generated = await generateTailwindV4Css({
|
|
7805
8084
|
opts,
|
|
7806
8085
|
runtimeState,
|
|
7807
|
-
runtime:
|
|
8086
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
7808
8087
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
7809
8088
|
file: "uni-app-x-harmony-apply.css",
|
|
7810
8089
|
outputFile: "uni-app-x-harmony-apply.css",
|
|
@@ -7814,6 +8093,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7814
8093
|
isMainChunk: false
|
|
7815
8094
|
},
|
|
7816
8095
|
cssStage: "framework-processed",
|
|
8096
|
+
disableSourceScan: true,
|
|
7817
8097
|
getSourceCandidatesForEntries,
|
|
7818
8098
|
generatorPlatform,
|
|
7819
8099
|
styleHandler: opts.styleHandler,
|
|
@@ -7822,9 +8102,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7822
8102
|
if (generated?.css) cssSources.push(annotateCss(generated.css));
|
|
7823
8103
|
return cssSources;
|
|
7824
8104
|
};
|
|
7825
|
-
const injectHarmonyBundleStyles = async (
|
|
8105
|
+
const injectHarmonyBundleStyles = async () => {
|
|
7826
8106
|
if (!isHarmonyAppStyleTarget) return;
|
|
7827
|
-
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources(
|
|
8107
|
+
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources() })) debug("uni-app-x harmony bundle styles inject");
|
|
7828
8108
|
};
|
|
7829
8109
|
const isCssOutputAssetEntry = (entry) => {
|
|
7830
8110
|
const [bundleFile, output] = entry;
|
|
@@ -7961,7 +8241,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7961
8241
|
bundle,
|
|
7962
8242
|
writeTargets
|
|
7963
8243
|
});
|
|
7964
|
-
await injectHarmonyBundleStyles(
|
|
8244
|
+
await injectHarmonyBundleStyles();
|
|
7965
8245
|
collectViteProcessedCssAssets();
|
|
7966
8246
|
injectViteProcessedCssIntoMainCss();
|
|
7967
8247
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
@@ -8552,6 +8832,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
8552
8832
|
async transform(code, id) {
|
|
8553
8833
|
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
8554
8834
|
if (!hasViteCssGenerationDirective(code)) return;
|
|
8835
|
+
if (options.shouldDeferGeneration?.(id, code)) return;
|
|
8555
8836
|
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
8556
8837
|
const generatedCss = await options.generateCss(id, code, {
|
|
8557
8838
|
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
@@ -8708,15 +8989,19 @@ function createViteHmrCandidateState(options) {
|
|
|
8708
8989
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8709
8990
|
...change,
|
|
8710
8991
|
file,
|
|
8711
|
-
runtimeAffecting: changeOptions.runtimeAffecting === true || isSourceStyleRequest(file) || WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(options.getSourceCandidate(file) ?? "")
|
|
8992
|
+
runtimeAffecting: changeOptions.runtimeAffecting === true || options.isRuntimeAffectingSource?.(file) === true || isSourceStyleRequest(file) || WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE.test(options.getSourceCandidate(file) ?? "")
|
|
8712
8993
|
});
|
|
8713
8994
|
const apply = (change) => {
|
|
8714
8995
|
if (isSourceStyleRequest(change.file)) {
|
|
8715
8996
|
clear();
|
|
8716
8997
|
return change;
|
|
8717
8998
|
}
|
|
8999
|
+
if (change.runtimeAffecting) {
|
|
9000
|
+
queueFullRegeneration();
|
|
9001
|
+
return change;
|
|
9002
|
+
}
|
|
8718
9003
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
8719
|
-
if (preserveDeletedCss
|
|
9004
|
+
if (preserveDeletedCss) {
|
|
8720
9005
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
8721
9006
|
else if (!pendingChange) clear();
|
|
8722
9007
|
return change;
|
|
@@ -8976,6 +9261,11 @@ function sameStringList(first, second) {
|
|
|
8976
9261
|
//#endregion
|
|
8977
9262
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8978
9263
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
9264
|
+
const hasDifferentHotModules = (left, right) => left.length !== right.length || left.some((mod, index) => mod !== right[index]);
|
|
9265
|
+
const hasTemplateHotSourceModule = (modules) => modules.some((mod) => {
|
|
9266
|
+
const request = mod.url ?? mod.id;
|
|
9267
|
+
return typeof request === "string" && /\.(?:uvue|nvue)(?:\?import)?$/i.test(request);
|
|
9268
|
+
});
|
|
8979
9269
|
return {
|
|
8980
9270
|
name: `${vitePluginName}:source-candidates`,
|
|
8981
9271
|
enforce: "pre",
|
|
@@ -9041,60 +9331,68 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9041
9331
|
await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9042
9332
|
}, { emit: false });
|
|
9043
9333
|
},
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
mod.
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
if (
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9334
|
+
handleHotUpdate: {
|
|
9335
|
+
order: "post",
|
|
9336
|
+
async handler(ctx) {
|
|
9337
|
+
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl(ctx.file))]));
|
|
9338
|
+
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9339
|
+
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(ctx.file);
|
|
9340
|
+
if (isSourceCandidateHotUpdate && isSourceStyleRequest(ctx.file)) {
|
|
9341
|
+
for (const mod of ctx.modules) for (const id of [
|
|
9342
|
+
mod.id,
|
|
9343
|
+
mod.url,
|
|
9344
|
+
mod.file
|
|
9345
|
+
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
9346
|
+
}
|
|
9347
|
+
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9348
|
+
if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
|
|
9349
|
+
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
9350
|
+
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9351
|
+
}
|
|
9352
|
+
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9353
|
+
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9354
|
+
let canUseHmrCandidateAppend = false;
|
|
9355
|
+
if (isSourceCandidateHotUpdate) {
|
|
9356
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
9357
|
+
const preserveDeletedCssInHmr = options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
9358
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
9359
|
+
if (!canUseHmrCandidateAppend) {
|
|
9360
|
+
if (sourceCandidateChange === void 0) {
|
|
9361
|
+
options.hmrCandidateState.clear();
|
|
9362
|
+
if (!preserveDeletedCssInHmr && !isSourceStyleRequest(ctx.file)) options.hmrCandidateState.queueFullRegeneration();
|
|
9363
|
+
}
|
|
9364
|
+
if (isWebLikeHotUpdate) {
|
|
9365
|
+
await options.refreshRuntimeStateForAutoCssSources?.(true);
|
|
9366
|
+
await options.sourceScanSession.sync({ force: true });
|
|
9367
|
+
}
|
|
9075
9368
|
}
|
|
9076
9369
|
}
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9370
|
+
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
9371
|
+
const cssModules = await resolveHotTailwindCssModules(ctx, isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds);
|
|
9372
|
+
const hotRoot = ctx.server.config?.root ?? process$1.cwd();
|
|
9373
|
+
const sourceModules = isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) ? await resolveHotSourceModules(ctx) : ctx.modules;
|
|
9374
|
+
const hasHmrCandidateAppend = options.hmrCandidateState.hasPendingCandidateAppend() || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
9375
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && options.isUniViteProject())) {
|
|
9376
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9377
|
+
return [];
|
|
9378
|
+
}
|
|
9379
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.isNuxtPageMacroHotModule(mod.id ?? mod.url))) {
|
|
9380
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9381
|
+
return [];
|
|
9382
|
+
}
|
|
9383
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test(cleanUrl(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
9384
|
+
sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
9385
|
+
return [];
|
|
9386
|
+
}
|
|
9387
|
+
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
9388
|
+
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
9389
|
+
if (hasHmrCandidateAppend) options.hmrCandidateState.armTargets(cssModules, supplementalCssFallbackIds);
|
|
9390
|
+
if (shouldSendSupplementalCssHotUpdates) sendSupplementalCssHotUpdates(ctx, cssModules, supplementalCssFallbackIds);
|
|
9391
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
9392
|
+
if (isSourceCandidateHotUpdate && !isSourceStyleRequest(ctx.file) && cssModules.length > 0) return mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
9393
|
+
return cssModules.length > 0 ? mergeHotModulesByIdentity(hotRoot, ctx.modules, cssModules) : void 0;
|
|
9394
|
+
}, { emit: false });
|
|
9395
|
+
}
|
|
9098
9396
|
},
|
|
9099
9397
|
async buildStart() {
|
|
9100
9398
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
@@ -9106,6 +9404,11 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9106
9404
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9107
9405
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9108
9406
|
const sourceCandidateScanSnapshotCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9407
|
+
async function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx) {
|
|
9408
|
+
const source = typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9409
|
+
await sourceScanSession.syncChangedFile(ctx.file, source);
|
|
9410
|
+
await sourceScanSession.waitForPendingSyncs();
|
|
9411
|
+
}
|
|
9109
9412
|
function createFrameworkSourceScanSession(options) {
|
|
9110
9413
|
const sourceCandidateScanCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9111
9414
|
let sourceScanEntries;
|
|
@@ -9268,12 +9571,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9268
9571
|
function createFrameworkTailwindRootCss(options) {
|
|
9269
9572
|
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
9270
9573
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
9271
|
-
const normalizeSourceFile = (id) =>
|
|
9574
|
+
const normalizeSourceFile = (id) => resolveViteModuleIdentity(id).key;
|
|
9272
9575
|
const rememberModule = (id) => {
|
|
9273
9576
|
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
9274
9577
|
moduleIds.add(id);
|
|
9275
|
-
const
|
|
9276
|
-
if (isSourceStyleRequest(cleanId)) moduleIds.add(
|
|
9578
|
+
const identity = resolveViteModuleIdentity(id);
|
|
9579
|
+
if (isSourceStyleRequest(identity.cleanId)) for (const moduleId of identity.lookupIds) moduleIds.add(moduleId);
|
|
9277
9580
|
};
|
|
9278
9581
|
const register = async (id, code) => {
|
|
9279
9582
|
rememberModule(id);
|
|
@@ -9577,7 +9880,8 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9577
9880
|
generatedClassSetByFile,
|
|
9578
9881
|
getCommand: () => resolvedConfig?.command,
|
|
9579
9882
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9580
|
-
getSourceCandidate: (file) => sourceCandidateCollector.source(file)
|
|
9883
|
+
getSourceCandidate: (file) => sourceCandidateCollector.source(file),
|
|
9884
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
|
|
9581
9885
|
});
|
|
9582
9886
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9583
9887
|
cssMemory,
|
|
@@ -9686,7 +9990,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9686
9990
|
const transient = hookContext?.transient === true;
|
|
9687
9991
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9688
9992
|
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
9689
|
-
const runtime = fullRuntime;
|
|
9993
|
+
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9690
9994
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9691
9995
|
css: generatorTransformCode,
|
|
9692
9996
|
cssPipelineContext,
|
|
@@ -9759,8 +10063,8 @@ ${previousTracedCss}`;
|
|
|
9759
10063
|
previousCss: previousGeneratorCss,
|
|
9760
10064
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
9761
10065
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
9762
|
-
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
9763
|
-
disableSourceScan:
|
|
10066
|
+
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
10067
|
+
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
9764
10068
|
cssStage: hookContext?.cssStage,
|
|
9765
10069
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
9766
10070
|
}), {
|
|
@@ -9814,7 +10118,7 @@ ${previousTracedCss}`;
|
|
|
9814
10118
|
source: tracedCss
|
|
9815
10119
|
});
|
|
9816
10120
|
markViteProcessedCssSource(file);
|
|
9817
|
-
rememberTailwindRootCssModule(id);
|
|
10121
|
+
if (hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
9818
10122
|
recordGeneratorCandidates(fullRuntime);
|
|
9819
10123
|
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
9820
10124
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
@@ -9827,6 +10131,11 @@ ${previousTracedCss}`;
|
|
|
9827
10131
|
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
9828
10132
|
${tracedCss}`;
|
|
9829
10133
|
};
|
|
10134
|
+
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
10135
|
+
...createCssPipelineContext(),
|
|
10136
|
+
code,
|
|
10137
|
+
id
|
|
10138
|
+
}) === true;
|
|
9830
10139
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
9831
10140
|
getAppType: () => opts.appType,
|
|
9832
10141
|
generateTailwindCss: generateTailwindCssForVitePipeline,
|
|
@@ -9834,7 +10143,7 @@ ${tracedCss}`;
|
|
|
9834
10143
|
onTailwindRootCss: registerTailwindRootCss,
|
|
9835
10144
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
9836
10145
|
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
9837
|
-
shouldDeferGeneration: (
|
|
10146
|
+
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports && hasTailwindRootDirectives(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }) || shouldDeferFrameworkPreTransformGeneration(id, code),
|
|
9838
10147
|
shouldOwnTailwindGeneration,
|
|
9839
10148
|
shouldRewrite: shouldRewriteCssImports,
|
|
9840
10149
|
weappTailwindcssDirPosix
|
|
@@ -9917,6 +10226,7 @@ ${tracedCss}`;
|
|
|
9917
10226
|
getRememberedMainCssSource: cssMemory.getRememberedCssSourceEntry
|
|
9918
10227
|
});
|
|
9919
10228
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10229
|
+
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
9920
10230
|
const prepareTailwindGeneration = async () => {
|
|
9921
10231
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
9922
10232
|
await sourceScanSession.sync();
|
|
@@ -9933,6 +10243,7 @@ ${tracedCss}`;
|
|
|
9933
10243
|
mainCssChunkMatcher,
|
|
9934
10244
|
runtimeState,
|
|
9935
10245
|
styleHandler,
|
|
10246
|
+
syncSourceCandidatesForHotUpdate,
|
|
9936
10247
|
tailwindRootCssModuleIds,
|
|
9937
10248
|
uniAppX,
|
|
9938
10249
|
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
@@ -10002,12 +10313,14 @@ ${tracedCss}`;
|
|
|
10002
10313
|
syncCssEntriesFromAnchor
|
|
10003
10314
|
});
|
|
10004
10315
|
const plugins = [
|
|
10316
|
+
...extraPlugins,
|
|
10005
10317
|
...rewritePlugins,
|
|
10006
10318
|
sourceCandidatesPlugin,
|
|
10007
10319
|
...createViteCssGenerationPlugins({
|
|
10008
10320
|
generateCss: generateTailwindCssForVitePipeline,
|
|
10009
10321
|
getCommand: () => resolvedConfig?.command,
|
|
10010
10322
|
onTailwindRootCss: registerTailwindRootCss,
|
|
10323
|
+
shouldDeferGeneration: shouldDeferFrameworkPreTransformGeneration,
|
|
10011
10324
|
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
10012
10325
|
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
10013
10326
|
}),
|
|
@@ -10030,7 +10343,6 @@ ${tracedCss}`;
|
|
|
10030
10343
|
},
|
|
10031
10344
|
postPlugin
|
|
10032
10345
|
];
|
|
10033
|
-
plugins.push(...extraPlugins);
|
|
10034
10346
|
plugins.push(cssFinalizerOutputPlugin);
|
|
10035
10347
|
plugins.push(...createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|
|
10036
10348
|
return plugins;
|
|
@@ -10292,7 +10604,8 @@ function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
|
10292
10604
|
//#endregion
|
|
10293
10605
|
//#region src/bundlers/vite/frameworks/uni-app-x/index.ts
|
|
10294
10606
|
function isUniAppXNativeAppStyleTarget(context) {
|
|
10295
|
-
|
|
10607
|
+
const stylePlatform = context?.resolveStylePlatform?.();
|
|
10608
|
+
return resolveUniUtsPlatform().isApp || stylePlatform === "app" || stylePlatform === "app-plus" || stylePlatform?.startsWith("app-") === true || isUniAppXNativeAppOutDir(context?.resolvedConfig?.build?.outDir) || isUniAppXNativeAppOutDir(context?.resolvedConfig?.root);
|
|
10296
10609
|
}
|
|
10297
10610
|
function isUniAppXHarmonyAppStyleTarget(context) {
|
|
10298
10611
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
@@ -10319,6 +10632,9 @@ const uniAppXCssPipelineStrategy = {
|
|
|
10319
10632
|
if (!context.cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(context.generatorCode)) return false;
|
|
10320
10633
|
return true;
|
|
10321
10634
|
},
|
|
10635
|
+
shouldDeferPreTransformTailwindGeneration(context) {
|
|
10636
|
+
return resolveUniAppXCssTarget(context.id) === "uvue" && hasTailwindApplyDirective(context.code) && !hasTailwindRootDirectives(context.code, { importFallback: true });
|
|
10637
|
+
},
|
|
10322
10638
|
transformGeneratedCss(css, context) {
|
|
10323
10639
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
10324
10640
|
return withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
@@ -10345,6 +10661,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10345
10661
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10346
10662
|
runtimeState: context.runtimeState,
|
|
10347
10663
|
styleHandler: context.styleHandler,
|
|
10664
|
+
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
|
10348
10665
|
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10349
10666
|
uniAppX: context.uniAppX,
|
|
10350
10667
|
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|