weapp-tailwindcss 5.2.6 → 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/final-css-cleanup.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +8 -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/cleanup.d.ts +0 -1
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -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-DCItlfoq.js → gulp-BWhCahA2.js} +7 -7
- package/dist/{gulp-CPIE1yPk.cjs → gulp-BdoorWb5.cjs} +10 -10
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-BevXxu6p.js → hmr-timing-CJocHeZr.js} +122 -16
- package/dist/{hmr-timing-Chyd_Yfw.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-Cwv-X4Rj.cjs → pipeline-helpers-CsNLoEX1.cjs} +4 -4
- 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-DG5mQZ8o.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-DLFqYads.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-Dtmu8Yax.cjs → v4-generation-core-BjHT6qGC.cjs} +132 -14
- package/dist/{vite-Bk1YU9L0.js → vite-BJJqWc_F.js} +567 -292
- package/dist/{vite-DmN_Y8Uk.cjs → vite-V86H6PZa.cjs} +570 -295
- 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-DtkSnYyR.js → webpack-CkeFhPY2.js} +7 -7
- package/dist/{webpack-DvmrFist.cjs → webpack-CzQrloDg.cjs} +9 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
- package/dist/bundlers/vite/processed-css-assets/empty-at-rule.d.ts +0 -1
|
@@ -1,23 +1,24 @@
|
|
|
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 {
|
|
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";
|
|
13
13
|
import process$1 from "node:process";
|
|
14
14
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
15
|
-
import { collectCssImportRequestsRoot, compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, parseTailwindCssDirectiveRequest, postcss,
|
|
15
|
+
import { collectCssImportRequestsRoot, compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, parseTailwindCssDirectiveRequest, postcss, removeTailwindPostcssPlugins, removeTailwindSourceDirectivesRoot, removeUnsupportedMiniProgramCssImportsRoot, resolvePostcssConfig, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
|
|
16
16
|
import { LRUCache } from "lru-cache";
|
|
17
17
|
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
|
}
|
|
@@ -1331,86 +1333,6 @@ const mix = (del = delimiter) => {
|
|
|
1331
1333
|
const posix = /* @__PURE__ */ mix(":");
|
|
1332
1334
|
const win32 = /* @__PURE__ */ mix(";");
|
|
1333
1335
|
//#endregion
|
|
1334
|
-
//#region src/bundlers/vite/processed-css-assets/empty-at-rule.ts
|
|
1335
|
-
function isAtRuleNameCharacter(code) {
|
|
1336
|
-
return code === 45 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
1337
|
-
}
|
|
1338
|
-
function isCssWhitespace(code) {
|
|
1339
|
-
return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
|
|
1340
|
-
}
|
|
1341
|
-
function findAtRuleBlockStart(css, start) {
|
|
1342
|
-
let parenthesisDepth = 0;
|
|
1343
|
-
let quote = 0;
|
|
1344
|
-
let squareBracketDepth = 0;
|
|
1345
|
-
for (let index = start; index < css.length; index++) {
|
|
1346
|
-
const code = css.charCodeAt(index);
|
|
1347
|
-
if (quote !== 0) {
|
|
1348
|
-
if (code === 92) index++;
|
|
1349
|
-
else if (code === quote) quote = 0;
|
|
1350
|
-
continue;
|
|
1351
|
-
}
|
|
1352
|
-
if (code === 34 || code === 39) {
|
|
1353
|
-
quote = code;
|
|
1354
|
-
continue;
|
|
1355
|
-
}
|
|
1356
|
-
if (code === 92) {
|
|
1357
|
-
index++;
|
|
1358
|
-
continue;
|
|
1359
|
-
}
|
|
1360
|
-
if (code === 47 && css.charCodeAt(index + 1) === 42) {
|
|
1361
|
-
const commentEnd = css.indexOf("*/", index + 2);
|
|
1362
|
-
if (commentEnd < 0) return -1;
|
|
1363
|
-
index = commentEnd + 1;
|
|
1364
|
-
continue;
|
|
1365
|
-
}
|
|
1366
|
-
if (code === 40) {
|
|
1367
|
-
parenthesisDepth++;
|
|
1368
|
-
continue;
|
|
1369
|
-
}
|
|
1370
|
-
if (code === 41 && parenthesisDepth > 0) {
|
|
1371
|
-
parenthesisDepth--;
|
|
1372
|
-
continue;
|
|
1373
|
-
}
|
|
1374
|
-
if (code === 91) {
|
|
1375
|
-
squareBracketDepth++;
|
|
1376
|
-
continue;
|
|
1377
|
-
}
|
|
1378
|
-
if (code === 93 && squareBracketDepth > 0) {
|
|
1379
|
-
squareBracketDepth--;
|
|
1380
|
-
continue;
|
|
1381
|
-
}
|
|
1382
|
-
if (code === 123 && parenthesisDepth === 0 && squareBracketDepth === 0) return index;
|
|
1383
|
-
if ((code === 59 || code === 125) && parenthesisDepth === 0 && squareBracketDepth === 0) return -1;
|
|
1384
|
-
}
|
|
1385
|
-
return -1;
|
|
1386
|
-
}
|
|
1387
|
-
function isEmptyAtRuleBody(css, blockStart) {
|
|
1388
|
-
for (let index = blockStart + 1; index < css.length; index++) {
|
|
1389
|
-
const code = css.charCodeAt(index);
|
|
1390
|
-
if (isCssWhitespace(code)) continue;
|
|
1391
|
-
if (code === 47 && css.charCodeAt(index + 1) === 42) {
|
|
1392
|
-
const commentEnd = css.indexOf("*/", index + 2);
|
|
1393
|
-
if (commentEnd < 0) return false;
|
|
1394
|
-
index = commentEnd + 1;
|
|
1395
|
-
continue;
|
|
1396
|
-
}
|
|
1397
|
-
return code === 125;
|
|
1398
|
-
}
|
|
1399
|
-
return false;
|
|
1400
|
-
}
|
|
1401
|
-
function hasEmptyAtRuleBlockCandidate(css) {
|
|
1402
|
-
let searchFrom = 0;
|
|
1403
|
-
while (searchFrom < css.length) {
|
|
1404
|
-
const atRuleStart = css.indexOf("@", searchFrom);
|
|
1405
|
-
if (atRuleStart < 0) return false;
|
|
1406
|
-
searchFrom = atRuleStart + 1;
|
|
1407
|
-
if (!isAtRuleNameCharacter(css.charCodeAt(searchFrom))) continue;
|
|
1408
|
-
const blockStart = findAtRuleBlockStart(css, searchFrom + 1);
|
|
1409
|
-
if (blockStart >= 0 && isEmptyAtRuleBody(css, blockStart)) return true;
|
|
1410
|
-
}
|
|
1411
|
-
return false;
|
|
1412
|
-
}
|
|
1413
|
-
//#endregion
|
|
1414
1336
|
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
1415
1337
|
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
1416
1338
|
function isCssOutputFile(file) {
|
|
@@ -1701,21 +1623,6 @@ function removeCommentOnlyAtRules(css) {
|
|
|
1701
1623
|
return css;
|
|
1702
1624
|
}
|
|
1703
1625
|
}
|
|
1704
|
-
function removeEmptyCssAtRules(css) {
|
|
1705
|
-
if (!hasEmptyAtRuleBlockCandidate(css)) return css;
|
|
1706
|
-
try {
|
|
1707
|
-
const root = postcss.parse(css);
|
|
1708
|
-
let removed = 0;
|
|
1709
|
-
let passRemoved = 0;
|
|
1710
|
-
do {
|
|
1711
|
-
passRemoved = removeEmptyAtRules(root);
|
|
1712
|
-
removed += passRemoved;
|
|
1713
|
-
} while (passRemoved > 0);
|
|
1714
|
-
return removed > 0 ? root.toString() : css;
|
|
1715
|
-
} catch {
|
|
1716
|
-
return css;
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
1626
|
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
1720
1627
|
if (importedStyleFiles.size === 0) return [];
|
|
1721
1628
|
const importedFileNames = new Set([...importedStyleFiles].map((file) => posix.posix.basename(file)));
|
|
@@ -2407,6 +2314,8 @@ const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
|
2407
2314
|
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
2408
2315
|
const SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
2409
2316
|
"*",
|
|
2317
|
+
":after",
|
|
2318
|
+
":before",
|
|
2410
2319
|
"::after",
|
|
2411
2320
|
"::before",
|
|
2412
2321
|
"::backdrop",
|
|
@@ -2418,6 +2327,14 @@ const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
2418
2327
|
"::after",
|
|
2419
2328
|
"::before"
|
|
2420
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
|
+
]);
|
|
2421
2338
|
const MINI_PROGRAM_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
2422
2339
|
"box-sizing",
|
|
2423
2340
|
"margin",
|
|
@@ -2524,14 +2441,24 @@ function isScopedUniversalTailwindPreflightRule(rule) {
|
|
|
2524
2441
|
const declarations = getRuleDeclarations(rule);
|
|
2525
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));
|
|
2526
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
|
+
}
|
|
2527
2449
|
function isLikelyTailwindGlobalRule(rule) {
|
|
2528
2450
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2529
2451
|
const declarations = getRuleDeclarations(rule);
|
|
2530
|
-
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);
|
|
2531
2453
|
}
|
|
2532
2454
|
function isLikelyTailwindPropertyAtRule(atRule) {
|
|
2533
2455
|
return atRule.name.toLowerCase() === "property" && normalizeCssSignatureValue(atRule.params).startsWith("--tw-");
|
|
2534
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
|
+
}
|
|
2535
2462
|
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
2536
2463
|
const selectors = rule.selectors ?? [rule.selector];
|
|
2537
2464
|
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
@@ -2550,12 +2477,6 @@ function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
|
2550
2477
|
const declarations = getRuleDeclarations(rule);
|
|
2551
2478
|
return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
|
|
2552
2479
|
}
|
|
2553
|
-
function hasUnscopedMiniProgramTailwindPreflightRule(css) {
|
|
2554
|
-
return /(?:^|[{}])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{/.test(css);
|
|
2555
|
-
}
|
|
2556
|
-
function hasScopedMiniProgramTailwindContentInitRule(css) {
|
|
2557
|
-
return /(?:^|[{}])[^{}]*\.data-v-[\w-][^{}]*\{\s*--tw-content\s*:/.test(css);
|
|
2558
|
-
}
|
|
2559
2480
|
//#endregion
|
|
2560
2481
|
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
2561
2482
|
function createDeclarationSignature(rule) {
|
|
@@ -2622,10 +2543,7 @@ function isRuleCoveredByRootCss(rule, coverage) {
|
|
|
2622
2543
|
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
2623
2544
|
if (!hasVueScopedAttr(css)) return css;
|
|
2624
2545
|
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
2625
|
-
const hasUnscopedMiniProgramPreflight = hasUnscopedMiniProgramTailwindPreflightRule(css);
|
|
2626
|
-
const hasScopedMiniProgramContentInit = hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2627
2546
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2628
|
-
if (coverage.rules.size === 0 && coverage.atRules.size === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2629
2547
|
try {
|
|
2630
2548
|
const root = postcss.parse(css);
|
|
2631
2549
|
let changed = false;
|
|
@@ -2636,13 +2554,13 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
|
2636
2554
|
}
|
|
2637
2555
|
});
|
|
2638
2556
|
root.walkRules((rule) => {
|
|
2639
|
-
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)) {
|
|
2640
2558
|
rule.remove();
|
|
2641
2559
|
changed = true;
|
|
2642
2560
|
}
|
|
2643
2561
|
});
|
|
2644
2562
|
root.walkAtRules((atRule) => {
|
|
2645
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2563
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2646
2564
|
atRule.remove();
|
|
2647
2565
|
changed = true;
|
|
2648
2566
|
return;
|
|
@@ -2676,22 +2594,20 @@ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
|
2676
2594
|
if (css.trim().length === 0) return css;
|
|
2677
2595
|
const hasScopedCss = hasVueScopedAttr(css);
|
|
2678
2596
|
const hasScopedTailwindGeneratedCss = hasScopedCss && /tailwindcss v\d/i.test(css);
|
|
2679
|
-
|
|
2680
|
-
const hasScopedMiniProgramContentInit = hasScopedCss && hasScopedMiniProgramTailwindContentInitRule(css);
|
|
2681
|
-
if (rootSources.length === 0 && !hasScopedTailwindGeneratedCss && !hasUnscopedMiniProgramPreflight && !hasScopedMiniProgramContentInit) return css;
|
|
2597
|
+
if (rootSources.length === 0 && !hasScopedCss) return css;
|
|
2682
2598
|
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
2683
2599
|
let nextCss = css;
|
|
2684
2600
|
try {
|
|
2685
2601
|
const root = postcss.parse(css);
|
|
2686
2602
|
let changed = false;
|
|
2687
2603
|
root.walkRules((rule) => {
|
|
2688
|
-
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))) {
|
|
2689
2605
|
rule.remove();
|
|
2690
2606
|
changed = true;
|
|
2691
2607
|
}
|
|
2692
2608
|
});
|
|
2693
2609
|
if (hasScopedCss) root.walkAtRules((atRule) => {
|
|
2694
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) ||
|
|
2610
|
+
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
2695
2611
|
atRule.remove();
|
|
2696
2612
|
changed = true;
|
|
2697
2613
|
return;
|
|
@@ -3036,7 +2952,10 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
3036
2952
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
3037
2953
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
3038
2954
|
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
3039
|
-
if (nextCss !== rawSource)
|
|
2955
|
+
if (nextCss !== rawSource) {
|
|
2956
|
+
output.source = nextCss;
|
|
2957
|
+
options.onAssetWrite?.(file);
|
|
2958
|
+
}
|
|
3040
2959
|
options.markCssAssetProcessed?.(output, file);
|
|
3041
2960
|
options.recordCssAssetResult?.(file, nextCss);
|
|
3042
2961
|
const resolvedOutputFile = resolveViteGeneratedCssMarkerOutputFile(file, singleMarkerFile, existingAssetFiles, options.resolveViteProcessedCssOutputFile);
|
|
@@ -3049,6 +2968,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
3049
2968
|
const targetNextCss = appendCss$1(targetRawSource, filterExistingCssRules(targetRawSource, nextCss).trim());
|
|
3050
2969
|
if (targetNextCss !== targetRawSource) {
|
|
3051
2970
|
targetAsset.source = targetNextCss;
|
|
2971
|
+
options.onAssetWrite?.(resolvedOutputFile);
|
|
3052
2972
|
options.markCssAssetProcessed?.(targetAsset, resolvedOutputFile);
|
|
3053
2973
|
options.recordCssAssetResult?.(resolvedOutputFile, targetNextCss);
|
|
3054
2974
|
}
|
|
@@ -4823,9 +4743,10 @@ function resolveViteCssTransformCachePlan(options) {
|
|
|
4823
4743
|
const cssRuntimeSignature = createCssRuntimeSignature(options.runtimeSignature, options.scopedGeneratorCandidateSignature);
|
|
4824
4744
|
const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, options.cssRuntimeAffectingHash);
|
|
4825
4745
|
const tailwindcssMajorVersion = options.tailwindcssMajorVersion ?? "unknown";
|
|
4746
|
+
const cssCacheKey = `${options.outputFile}:css:${cssRuntimeSignature}:${tailwindcssMajorVersion}`;
|
|
4826
4747
|
return {
|
|
4827
|
-
cssCacheKey
|
|
4828
|
-
cssHashKey:
|
|
4748
|
+
cssCacheKey,
|
|
4749
|
+
cssHashKey: cssCacheKey,
|
|
4829
4750
|
cssRuntimeSignature,
|
|
4830
4751
|
cssSharedCacheKey: [
|
|
4831
4752
|
options.cssShareScope,
|
|
@@ -4962,6 +4883,31 @@ function readAssetSource$1(output) {
|
|
|
4962
4883
|
function shouldFinalizeMiniProgramCssAsset(source) {
|
|
4963
4884
|
return source.includes(":hover") || source.includes("does-not-exist") || hasMiniProgramCssSpecificityPlaceholders(source);
|
|
4964
4885
|
}
|
|
4886
|
+
function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
4887
|
+
if (options.isWebGeneratorTarget) return 0;
|
|
4888
|
+
const plan = new AssetEmissionPlan();
|
|
4889
|
+
const writeTargets = /* @__PURE__ */ new Map();
|
|
4890
|
+
let updated = 0;
|
|
4891
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
4892
|
+
if (output.type !== "asset") continue;
|
|
4893
|
+
const file = output.fileName || bundleFile;
|
|
4894
|
+
if (!options.cssMatcher(file) || options.files && !options.files.has(file)) continue;
|
|
4895
|
+
const rawSource = readAssetSource$1(output);
|
|
4896
|
+
const outputCss = finalizeMiniProgramCssStructure(rawSource);
|
|
4897
|
+
if (outputCss === rawSource) continue;
|
|
4898
|
+
plan.write(file, outputCss);
|
|
4899
|
+
writeTargets.set(file, output);
|
|
4900
|
+
options.recordCssAssetResult?.(file, outputCss);
|
|
4901
|
+
options.onUpdate(file, rawSource, outputCss);
|
|
4902
|
+
options.debug?.("remove final empty mini-program css at-rules: %s bytes=%d", file, outputCss.length);
|
|
4903
|
+
updated++;
|
|
4904
|
+
}
|
|
4905
|
+
applyViteAssetEmissionPlan(plan, {
|
|
4906
|
+
bundle,
|
|
4907
|
+
writeTargets
|
|
4908
|
+
});
|
|
4909
|
+
return updated;
|
|
4910
|
+
}
|
|
4965
4911
|
async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
4966
4912
|
if (options.isWebGeneratorTarget) return 0;
|
|
4967
4913
|
const plan = new AssetEmissionPlan();
|
|
@@ -4974,7 +4920,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
4974
4920
|
const rawSource = readAssetSource$1(output);
|
|
4975
4921
|
if (rawSource.trim().length === 0) continue;
|
|
4976
4922
|
if (options.lastCssResultByFile?.has(file)) {
|
|
4977
|
-
const outputCss = stripMiniProgramCssSpecificityPlaceholders(
|
|
4923
|
+
const outputCss = stripMiniProgramCssSpecificityPlaceholders(finalizeMiniProgramCssStructure(rawSource));
|
|
4978
4924
|
if (outputCss !== rawSource) {
|
|
4979
4925
|
plan.write(file, outputCss);
|
|
4980
4926
|
writeTargets.set(file, output);
|
|
@@ -4986,7 +4932,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
4986
4932
|
continue;
|
|
4987
4933
|
}
|
|
4988
4934
|
if (!shouldFinalizeMiniProgramCssAsset(rawSource)) {
|
|
4989
|
-
const structurallyCleanSource =
|
|
4935
|
+
const structurallyCleanSource = finalizeMiniProgramCssStructure(rawSource);
|
|
4990
4936
|
if (structurallyCleanSource !== rawSource) {
|
|
4991
4937
|
plan.write(file, structurallyCleanSource);
|
|
4992
4938
|
writeTargets.set(file, output);
|
|
@@ -5008,7 +4954,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
5008
4954
|
},
|
|
5009
4955
|
cssPresetEnv: {}
|
|
5010
4956
|
});
|
|
5011
|
-
const outputCss = stripMiniProgramCssSpecificityPlaceholders(
|
|
4957
|
+
const outputCss = stripMiniProgramCssSpecificityPlaceholders(finalizeMiniProgramCssStructure(css));
|
|
5012
4958
|
if (outputCss === rawSource) continue;
|
|
5013
4959
|
plan.write(file, outputCss);
|
|
5014
4960
|
writeTargets.set(file, output);
|
|
@@ -5145,7 +5091,7 @@ function injectHarmonyCssIntoMainAsset(bundle, cssSources, isMainCssAsset, plan,
|
|
|
5145
5091
|
return true;
|
|
5146
5092
|
}
|
|
5147
5093
|
async function handleUniAppXPostCssTasks(options) {
|
|
5148
|
-
const { bundle, debug,
|
|
5094
|
+
const { bundle, debug, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteProcessedCssAssetResults, isHarmonyAppStyleTarget, isNativeAppStyleTarget, onUpdate, opts, runtimeState, styleHandler, deferStylePlaceholderInjection } = options;
|
|
5149
5095
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
5150
5096
|
if (opts.appType !== "uni-app-x" && !isNativeAppStyleTarget && !isHarmonyAppStyleTarget) return applyStyleSources;
|
|
5151
5097
|
const emissionPlan = new AssetEmissionPlan();
|
|
@@ -5167,7 +5113,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5167
5113
|
const generated = await generateTailwindV4Css({
|
|
5168
5114
|
opts,
|
|
5169
5115
|
runtimeState,
|
|
5170
|
-
runtime: /* @__PURE__ */ new Set(
|
|
5116
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
5171
5117
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
5172
5118
|
file: outputFile,
|
|
5173
5119
|
outputFile,
|
|
@@ -5177,6 +5123,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
5177
5123
|
isMainChunk: false
|
|
5178
5124
|
},
|
|
5179
5125
|
cssStage: "framework-processed",
|
|
5126
|
+
disableSourceScan: true,
|
|
5180
5127
|
getSourceCandidatesForEntries,
|
|
5181
5128
|
styleHandler,
|
|
5182
5129
|
debug
|
|
@@ -5707,6 +5654,53 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
5707
5654
|
return enabled;
|
|
5708
5655
|
}
|
|
5709
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
|
|
5710
5704
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
5711
5705
|
function createStableHash(input) {
|
|
5712
5706
|
let hash = 2166136261;
|
|
@@ -5717,23 +5711,43 @@ function createStableHash(input) {
|
|
|
5717
5711
|
return (hash >>> 0).toString(36);
|
|
5718
5712
|
}
|
|
5719
5713
|
function createUniAppXHarmonyApplyExpander(options) {
|
|
5714
|
+
const referenceBySourceId = /* @__PURE__ */ new Map();
|
|
5720
5715
|
const styleSources = /* @__PURE__ */ new Set();
|
|
5721
5716
|
const utilities = /* @__PURE__ */ new Set();
|
|
5722
|
-
function rememberSource(code, id) {
|
|
5717
|
+
function rememberSource(code, id, authoritative = false) {
|
|
5723
5718
|
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5719
|
+
const sourceKey = normalizePath(cleanUrl(id));
|
|
5720
|
+
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
5724
5721
|
for (const source of sources) {
|
|
5725
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 {}
|
|
5726
5729
|
for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
5727
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}`;
|
|
5728
5739
|
}
|
|
5729
5740
|
async function expandStyles(code, id, hookContext) {
|
|
5730
5741
|
if (!options.isHarmonyBuildTarget() || !code.includes("@apply")) return code;
|
|
5731
|
-
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(code, id);
|
|
5742
|
+
const sources = collectUniAppXHarmonyApplyStyleSourcesFromSource(prepareStyles(code, id), id);
|
|
5732
5743
|
const sourceUtilities = collectUniAppXHarmonyApplyUtilitiesFromSources(sources);
|
|
5733
5744
|
if (sources.length === 0 || sourceUtilities.size === 0) return code;
|
|
5734
5745
|
const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process$1.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl(id)))}.css`);
|
|
5735
|
-
const
|
|
5746
|
+
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
5747
|
+
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
5736
5748
|
addWatchFile: hookContext.addWatchFile?.bind(hookContext),
|
|
5749
|
+
disableSourceScan: true,
|
|
5750
|
+
sourceCandidates: [],
|
|
5737
5751
|
transient: true
|
|
5738
5752
|
});
|
|
5739
5753
|
if (typeof generatedCss !== "string" || generatedCss.trim().length === 0) return code;
|
|
@@ -5741,49 +5755,178 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5741
5755
|
}
|
|
5742
5756
|
return {
|
|
5743
5757
|
expandStyles,
|
|
5758
|
+
prepareStyles,
|
|
5744
5759
|
rememberSource,
|
|
5745
5760
|
styleSources,
|
|
5746
5761
|
utilities
|
|
5747
5762
|
};
|
|
5748
5763
|
}
|
|
5749
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
|
|
5750
5862
|
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5751
|
-
function
|
|
5863
|
+
async function resolveHotModulesByIds(ctx, ids, acceptModule) {
|
|
5752
5864
|
const modules = [];
|
|
5753
5865
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5754
5866
|
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
5867
|
+
const seenFileIdentities = /* @__PURE__ */ new Set();
|
|
5755
5868
|
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5756
|
-
const
|
|
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) {
|
|
5890
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5891
|
+
const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
|
|
5757
5892
|
const isHotSourceStyleModule = (id) => {
|
|
5758
5893
|
if (!isSourceStyleRequest(id)) return false;
|
|
5759
5894
|
const file = cleanUrl(id);
|
|
5760
5895
|
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5761
|
-
if (outDir
|
|
5762
|
-
const
|
|
5763
|
-
if (
|
|
5896
|
+
if (outDir) {
|
|
5897
|
+
const identity = resolveViteModuleIdentity(file, root);
|
|
5898
|
+
if (identity.key === outDir.key || identity.key.startsWith(`${outDir.key}/`)) return false;
|
|
5764
5899
|
}
|
|
5765
5900
|
return true;
|
|
5766
5901
|
};
|
|
5767
|
-
const
|
|
5768
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
5902
|
+
const modules = await resolveHotModulesByIds(ctx, tailwindRootCssModuleIds, (mod) => {
|
|
5769
5903
|
const modId = mod.id ?? mod.url;
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
if (moduleId.length === 0 || seenModuleIds.has(moduleId)) continue;
|
|
5779
|
-
seenModuleIds.add(moduleId);
|
|
5780
|
-
const candidates = [ctx.server.moduleGraph.getModuleById(moduleId), ...ctx.server.moduleGraph.getModulesByFile(moduleId) ?? []];
|
|
5781
|
-
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);
|
|
5782
5912
|
}
|
|
5783
5913
|
}
|
|
5914
|
+
for (const mod of modules) ctx.server.moduleGraph.invalidateModule(mod);
|
|
5784
5915
|
return modules;
|
|
5785
5916
|
}
|
|
5786
|
-
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) {
|
|
5787
5930
|
const modules = [];
|
|
5788
5931
|
const seenModules = /* @__PURE__ */ new Set();
|
|
5789
5932
|
const collectModule = (mod) => {
|
|
@@ -5793,10 +5936,27 @@ function resolveHotSourceModules(ctx) {
|
|
|
5793
5936
|
modules.push(mod);
|
|
5794
5937
|
};
|
|
5795
5938
|
for (const mod of ctx.modules) collectModule(mod);
|
|
5796
|
-
for (const mod of
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
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
|
+
}
|
|
5800
5960
|
return modules;
|
|
5801
5961
|
}
|
|
5802
5962
|
function resolveModuleHotUrl(mod) {
|
|
@@ -5815,23 +5975,32 @@ function isRootMiniProgramStyleUrl(file) {
|
|
|
5815
5975
|
}
|
|
5816
5976
|
function resolveCssHotUrl(id, root) {
|
|
5817
5977
|
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5818
|
-
const
|
|
5819
|
-
if (/^\/(
|
|
5820
|
-
if (isRootMiniProgramStyleUrl(
|
|
5821
|
-
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}`;
|
|
5822
5982
|
}
|
|
5983
|
+
const file = resolveViteModuleIdentity(id, root).file ?? cleanId;
|
|
5823
5984
|
if (!isAbsoluteFilePath(file)) return;
|
|
5824
5985
|
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5825
5986
|
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5826
5987
|
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5827
5988
|
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5828
5989
|
}
|
|
5829
|
-
function includesHotModule(modules, target) {
|
|
5990
|
+
function includesHotModule(modules, target, root) {
|
|
5830
5991
|
const targetUrl = resolveModuleHotUrl(target);
|
|
5831
5992
|
const targetId = target.id;
|
|
5832
5993
|
return modules.some((mod) => {
|
|
5833
5994
|
if (mod === target) return true;
|
|
5834
|
-
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)));
|
|
5835
6004
|
});
|
|
5836
6005
|
}
|
|
5837
6006
|
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
@@ -5849,10 +6018,16 @@ function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
|
5849
6018
|
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5850
6019
|
});
|
|
5851
6020
|
}
|
|
5852
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
6021
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = [], fallbackSourceIds = []) {
|
|
5853
6022
|
const seenUrls = /* @__PURE__ */ new Set();
|
|
5854
6023
|
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5855
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
|
+
}
|
|
5856
6031
|
for (const id of fallbackCssIds) {
|
|
5857
6032
|
if (!isSourceStyleRequest(id)) continue;
|
|
5858
6033
|
const hotUrl = resolveCssHotUrl(id, root);
|
|
@@ -5861,7 +6036,7 @@ function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
|
5861
6036
|
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5862
6037
|
}
|
|
5863
6038
|
for (const mod of cssModules) {
|
|
5864
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
6039
|
+
if (includesHotModule(ctx.modules, mod, root)) continue;
|
|
5865
6040
|
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5866
6041
|
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5867
6042
|
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
@@ -5896,12 +6071,25 @@ function createUniAppXNativeHmrReloader(options) {
|
|
|
5896
6071
|
}
|
|
5897
6072
|
async function handleHotUpdate(ctx) {
|
|
5898
6073
|
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5899
|
-
|
|
6074
|
+
await options.syncSourceCandidates?.(ctx);
|
|
5900
6075
|
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5901
|
-
const
|
|
6076
|
+
const hasRuntimeClassChange = previousRuntimeClassSet !== void 0 && (currentRuntimeClassSet.size !== previousRuntimeClassSet.size || [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate)));
|
|
5902
6077
|
remember(currentRuntimeClassSet);
|
|
5903
|
-
|
|
5904
|
-
|
|
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;
|
|
5905
6093
|
}
|
|
5906
6094
|
return {
|
|
5907
6095
|
handleHotUpdate,
|
|
@@ -5921,12 +6109,7 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
5921
6109
|
};
|
|
5922
6110
|
}
|
|
5923
6111
|
//#endregion
|
|
5924
|
-
//#region src/uni-app-x/vite.ts
|
|
5925
|
-
let transformUVuePromise;
|
|
5926
|
-
function loadTransformUVue() {
|
|
5927
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-BbaPIji9.js").then((mod) => mod.transformUVue));
|
|
5928
|
-
return transformUVuePromise;
|
|
5929
|
-
}
|
|
6112
|
+
//#region src/uni-app-x/vite/style-request.ts
|
|
5930
6113
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
5931
6114
|
"scss",
|
|
5932
6115
|
"sass",
|
|
@@ -5936,8 +6119,7 @@ const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
|
5936
6119
|
]);
|
|
5937
6120
|
const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
5938
6121
|
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
5939
|
-
const
|
|
5940
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
6122
|
+
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
5941
6123
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
5942
6124
|
function isPreprocessorRequest(id, lang) {
|
|
5943
6125
|
const normalizedLang = lang?.toLowerCase();
|
|
@@ -5947,25 +6129,37 @@ function isPreprocessorRequest(id, lang) {
|
|
|
5947
6129
|
return PREPROCESSOR_EXT_RE.test(id);
|
|
5948
6130
|
}
|
|
5949
6131
|
function resolveUniAppXCssTarget(id) {
|
|
5950
|
-
return UVUE_NVUE_RE.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
5951
|
-
}
|
|
5952
|
-
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
5953
|
-
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
6132
|
+
return UVUE_NVUE_RE$1.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
5954
6133
|
}
|
|
5955
6134
|
function isCssModuleExport(code) {
|
|
5956
6135
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5957
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
|
+
}
|
|
5958
6149
|
function createUniAppXPlugins(options) {
|
|
5959
|
-
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;
|
|
5960
6151
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
5961
6152
|
const utsPlatform = resolveUniUtsPlatform();
|
|
5962
6153
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5963
6154
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
6155
|
+
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
5964
6156
|
let componentLocalStyleEnabled;
|
|
5965
6157
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5966
6158
|
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5967
6159
|
ensureRuntimeClassSet,
|
|
5968
6160
|
isNativeAppBuildTarget,
|
|
6161
|
+
localStyleModuleIds: nativeLocalStyleModuleIds,
|
|
6162
|
+
syncSourceCandidates: syncSourceCandidatesForHotUpdate,
|
|
5969
6163
|
tailwindRootCssModuleIds,
|
|
5970
6164
|
viteProcessedCssSourceFiles
|
|
5971
6165
|
});
|
|
@@ -5990,13 +6184,15 @@ function createUniAppXPlugins(options) {
|
|
|
5990
6184
|
if (resolveUniUtsPlatform().isAppHarmony) return true;
|
|
5991
6185
|
return isUniAppXHarmonyOutDir(getResolvedConfig()?.build?.outDir);
|
|
5992
6186
|
}
|
|
5993
|
-
function getStyleHandlerOptions(id) {
|
|
5994
|
-
const
|
|
6187
|
+
function getStyleHandlerOptions(id, source) {
|
|
6188
|
+
const isMainChunk = source === "tailwind-root" || mainCssChunkMatcher(id, appType);
|
|
6189
|
+
const cacheKey = `${isMainChunk ? "1" : "0"}:${source ?? ""}:${id}`;
|
|
5995
6190
|
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
5996
6191
|
if (!styleHandlerOptions) {
|
|
5997
6192
|
styleHandlerOptions = omitUndefined({
|
|
5998
|
-
isMainChunk
|
|
6193
|
+
isMainChunk,
|
|
5999
6194
|
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
6195
|
+
uniAppXCssSource: isNativeAppBuildTarget(id) ? source : void 0,
|
|
6000
6196
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
6001
6197
|
postcssOptions: { options: {
|
|
6002
6198
|
from: id,
|
|
@@ -6016,16 +6212,24 @@ function createUniAppXPlugins(options) {
|
|
|
6016
6212
|
for (const warning of warnings) logger$1.warn(warning.toString());
|
|
6017
6213
|
}
|
|
6018
6214
|
async function transformStyle(code, id, query, hookContext) {
|
|
6019
|
-
isNativeAppBuildTarget(id);
|
|
6215
|
+
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
6020
6216
|
const parsed = query ?? parseVueRequest(id).query;
|
|
6021
6217
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
6022
6218
|
if (isCssModuleExport(code)) return;
|
|
6023
|
-
const
|
|
6024
|
-
|
|
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;
|
|
6025
6224
|
harmonyApply.rememberSource(code, id);
|
|
6026
|
-
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code,
|
|
6027
|
-
|
|
6028
|
-
|
|
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);
|
|
6029
6233
|
const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
|
|
6030
6234
|
reportStyleWarnings(postcssResult);
|
|
6031
6235
|
const postcssMap = await formatPostcssSourceMap(postcssResult.map.toJSON(), normalizePath(cleanUrl(id)));
|
|
@@ -6040,7 +6244,7 @@ function createUniAppXPlugins(options) {
|
|
|
6040
6244
|
getResolvedConfig,
|
|
6041
6245
|
isHarmonyBuildTarget,
|
|
6042
6246
|
async transformCss(css, id) {
|
|
6043
|
-
const result = await styleHandler(css, getStyleHandlerOptions(id));
|
|
6247
|
+
const result = await styleHandler(css, getStyleHandlerOptions(id, "author-apply"));
|
|
6044
6248
|
reportStyleWarnings(result);
|
|
6045
6249
|
return result.css;
|
|
6046
6250
|
}
|
|
@@ -6077,40 +6281,46 @@ function createUniAppXPlugins(options) {
|
|
|
6077
6281
|
if (!isEnabled()) return;
|
|
6078
6282
|
await nativeHmrReloader.refreshBaseline();
|
|
6079
6283
|
},
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
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;
|
|
6107
6318
|
}
|
|
6108
|
-
return result;
|
|
6109
6319
|
},
|
|
6110
6320
|
async handleHotUpdate(ctx) {
|
|
6111
6321
|
if (!isEnabled()) return;
|
|
6112
6322
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
6113
|
-
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
6323
|
+
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
6114
6324
|
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
6115
6325
|
},
|
|
6116
6326
|
async watchChange(id) {
|
|
@@ -6139,7 +6349,12 @@ function createUniAppXPlugins(options) {
|
|
|
6139
6349
|
const applyUtilities = /* @__PURE__ */ new Set([...harmonyApply.utilities, ...collectUniAppXHarmonyApplyUtilities(bundle)]);
|
|
6140
6350
|
if (applyStyleSources.length > 0 && applyUtilities.size > 0) {
|
|
6141
6351
|
const harmonyApplyCssFile = path.resolve(getResolvedConfig()?.root ?? process$1.cwd(), "uni-app-x-harmony-apply.css");
|
|
6142
|
-
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
|
+
});
|
|
6143
6358
|
if (typeof generatedCss === "string" && generatedCss.trim().length > 0) cssSources.push(generatedCss);
|
|
6144
6359
|
}
|
|
6145
6360
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
@@ -7798,11 +8013,16 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7798
8013
|
const rootDir = resolvedConfig?.root ? path.resolve(resolvedConfig.root) : process$1.cwd();
|
|
7799
8014
|
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
7800
8015
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType) ?? resolveSourceRootFromBundleGraph(resolvedConfig, bundle);
|
|
8016
|
+
const finalCssAssetFiles = /* @__PURE__ */ new Set();
|
|
8017
|
+
const trackFinalCssAssetUpdate = (file, original, generated) => {
|
|
8018
|
+
finalCssAssetFiles.add(file);
|
|
8019
|
+
opts.onUpdate(file, original, generated);
|
|
8020
|
+
};
|
|
7801
8021
|
restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
|
|
7802
8022
|
debug,
|
|
7803
8023
|
isWebGeneratorTarget,
|
|
7804
8024
|
matchesCss: opts.cssMatcher,
|
|
7805
|
-
onUpdate:
|
|
8025
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
7806
8026
|
recordCssAssetResult,
|
|
7807
8027
|
shouldKeep: (file, css) => cssPipelineStrategy?.shouldKeepRootMiniProgramStyleAsImportShell?.({
|
|
7808
8028
|
...createCssPipelineContext(file),
|
|
@@ -7825,6 +8045,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7825
8045
|
markCssAssetProcessed,
|
|
7826
8046
|
recordCssAssetResult,
|
|
7827
8047
|
recordViteProcessedCssAssetResult,
|
|
8048
|
+
onAssetWrite: (file) => finalCssAssetFiles.add(file),
|
|
7828
8049
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
7829
8050
|
transformCss: (css, file) => finalizeWebCss(css, {
|
|
7830
8051
|
...createCssPipelineContext(file),
|
|
@@ -7846,16 +8067,15 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7846
8067
|
file
|
|
7847
8068
|
}, cssPipelineStrategy),
|
|
7848
8069
|
debug,
|
|
7849
|
-
onUpdate:
|
|
8070
|
+
onUpdate: trackFinalCssAssetUpdate
|
|
7850
8071
|
});
|
|
7851
8072
|
};
|
|
7852
8073
|
collectViteProcessedCssAssets();
|
|
7853
|
-
const createHarmonyBundleStyleSources = async (
|
|
8074
|
+
const createHarmonyBundleStyleSources = async () => {
|
|
7854
8075
|
const cssSources = collectViteProcessedCssSources(getViteProcessedCssAssetResults);
|
|
7855
8076
|
const applyUtilities = collectUniAppXHarmonyApplyUtilities(bundle);
|
|
7856
8077
|
const applyStyleSources = collectUniAppXHarmonyApplyStyleSources(bundle);
|
|
7857
8078
|
if (applyUtilities.size === 0 || applyStyleSources.length === 0) return cssSources;
|
|
7858
|
-
const harmonyRuntime = /* @__PURE__ */ new Set([...runtime, ...applyUtilities]);
|
|
7859
8079
|
const harmonyCssHandlerOptions = createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, "uni-app-x-harmony-apply.css", outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7860
8080
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
7861
8081
|
file: "uni-app-x-harmony-apply.css"
|
|
@@ -7863,7 +8083,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7863
8083
|
const generated = await generateTailwindV4Css({
|
|
7864
8084
|
opts,
|
|
7865
8085
|
runtimeState,
|
|
7866
|
-
runtime:
|
|
8086
|
+
runtime: /* @__PURE__ */ new Set(),
|
|
7867
8087
|
rawSource: createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, applyUtilities),
|
|
7868
8088
|
file: "uni-app-x-harmony-apply.css",
|
|
7869
8089
|
outputFile: "uni-app-x-harmony-apply.css",
|
|
@@ -7873,6 +8093,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7873
8093
|
isMainChunk: false
|
|
7874
8094
|
},
|
|
7875
8095
|
cssStage: "framework-processed",
|
|
8096
|
+
disableSourceScan: true,
|
|
7876
8097
|
getSourceCandidatesForEntries,
|
|
7877
8098
|
generatorPlatform,
|
|
7878
8099
|
styleHandler: opts.styleHandler,
|
|
@@ -7881,9 +8102,9 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7881
8102
|
if (generated?.css) cssSources.push(annotateCss(generated.css));
|
|
7882
8103
|
return cssSources;
|
|
7883
8104
|
};
|
|
7884
|
-
const injectHarmonyBundleStyles = async (
|
|
8105
|
+
const injectHarmonyBundleStyles = async () => {
|
|
7885
8106
|
if (!isHarmonyAppStyleTarget) return;
|
|
7886
|
-
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources(
|
|
8107
|
+
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: await createHarmonyBundleStyleSources() })) debug("uni-app-x harmony bundle styles inject");
|
|
7887
8108
|
};
|
|
7888
8109
|
const isCssOutputAssetEntry = (entry) => {
|
|
7889
8110
|
const [bundleFile, output] = entry;
|
|
@@ -7899,6 +8120,14 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7899
8120
|
cssMatcher: opts.cssMatcher,
|
|
7900
8121
|
debug,
|
|
7901
8122
|
enabled: cssPipelineStrategy?.shouldNormalizeRootMiniProgramImportShell?.(createCssPipelineContext("")) === true,
|
|
8123
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
8124
|
+
recordCssAssetResult
|
|
8125
|
+
});
|
|
8126
|
+
finalizeMiniProgramCssAssetStructures(bundle, {
|
|
8127
|
+
cssMatcher: opts.cssMatcher,
|
|
8128
|
+
debug,
|
|
8129
|
+
files: finalCssAssetFiles,
|
|
8130
|
+
isWebGeneratorTarget,
|
|
7902
8131
|
onUpdate: opts.onUpdate,
|
|
7903
8132
|
recordCssAssetResult
|
|
7904
8133
|
});
|
|
@@ -7914,6 +8143,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7914
8143
|
const writeTargets = /* @__PURE__ */ new Map();
|
|
7915
8144
|
const writeCssAsset = (file, output, source) => {
|
|
7916
8145
|
emissionPlan.write(file, source);
|
|
8146
|
+
finalCssAssetFiles.add(file);
|
|
7917
8147
|
writeTargets.set(file, output);
|
|
7918
8148
|
};
|
|
7919
8149
|
await Promise.all(entries.map(async ([bundleFile, output]) => {
|
|
@@ -8011,13 +8241,21 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
8011
8241
|
bundle,
|
|
8012
8242
|
writeTargets
|
|
8013
8243
|
});
|
|
8014
|
-
await injectHarmonyBundleStyles(
|
|
8244
|
+
await injectHarmonyBundleStyles();
|
|
8015
8245
|
collectViteProcessedCssAssets();
|
|
8016
8246
|
injectViteProcessedCssIntoMainCss();
|
|
8017
8247
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
8018
8248
|
cssMatcher: opts.cssMatcher,
|
|
8019
8249
|
debug,
|
|
8020
8250
|
enabled: cssPipelineStrategy?.shouldNormalizeRootMiniProgramImportShell?.(createCssPipelineContext("")) === true,
|
|
8251
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
8252
|
+
recordCssAssetResult
|
|
8253
|
+
});
|
|
8254
|
+
finalizeMiniProgramCssAssetStructures(bundle, {
|
|
8255
|
+
cssMatcher: opts.cssMatcher,
|
|
8256
|
+
debug,
|
|
8257
|
+
files: finalCssAssetFiles,
|
|
8258
|
+
isWebGeneratorTarget,
|
|
8021
8259
|
onUpdate: opts.onUpdate,
|
|
8022
8260
|
recordCssAssetResult
|
|
8023
8261
|
});
|
|
@@ -8594,6 +8832,7 @@ function createViteCssGenerationPlugins(options) {
|
|
|
8594
8832
|
async transform(code, id) {
|
|
8595
8833
|
if (!options.shouldGenerate() || options.shouldGenerateBuild?.() === false || !isViteBuildStyleRequest(id, options.getCommand())) return;
|
|
8596
8834
|
if (!hasViteCssGenerationDirective(code)) return;
|
|
8835
|
+
if (options.shouldDeferGeneration?.(id, code)) return;
|
|
8597
8836
|
if (hasViteServeCssRootDirective(code)) await options.onTailwindRootCss?.(id, code);
|
|
8598
8837
|
const generatedCss = await options.generateCss(id, code, {
|
|
8599
8838
|
...this.addWatchFile ? { addWatchFile: this.addWatchFile.bind(this) } : {},
|
|
@@ -8750,15 +8989,19 @@ function createViteHmrCandidateState(options) {
|
|
|
8750
8989
|
const createChange = (file, change, changeOptions = {}) => ({
|
|
8751
8990
|
...change,
|
|
8752
8991
|
file,
|
|
8753
|
-
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) ?? "")
|
|
8754
8993
|
});
|
|
8755
8994
|
const apply = (change) => {
|
|
8756
8995
|
if (isSourceStyleRequest(change.file)) {
|
|
8757
8996
|
clear();
|
|
8758
8997
|
return change;
|
|
8759
8998
|
}
|
|
8999
|
+
if (change.runtimeAffecting) {
|
|
9000
|
+
queueFullRegeneration();
|
|
9001
|
+
return change;
|
|
9002
|
+
}
|
|
8760
9003
|
const preserveDeletedCss = options.getGeneratorOptions().hmr.preserveDeletedCss;
|
|
8761
|
-
if (preserveDeletedCss
|
|
9004
|
+
if (preserveDeletedCss) {
|
|
8762
9005
|
if (change.addedCandidates.size > 0) queueChange(change);
|
|
8763
9006
|
else if (!pendingChange) clear();
|
|
8764
9007
|
return change;
|
|
@@ -9018,6 +9261,11 @@ function sameStringList(first, second) {
|
|
|
9018
9261
|
//#endregion
|
|
9019
9262
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
9020
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
|
+
});
|
|
9021
9269
|
return {
|
|
9022
9270
|
name: `${vitePluginName}:source-candidates`,
|
|
9023
9271
|
enforce: "pre",
|
|
@@ -9083,60 +9331,68 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9083
9331
|
await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9084
9332
|
}, { emit: false });
|
|
9085
9333
|
},
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
mod.
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
if (
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
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
|
+
}
|
|
9117
9368
|
}
|
|
9118
9369
|
}
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
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
|
+
}
|
|
9140
9396
|
},
|
|
9141
9397
|
async buildStart() {
|
|
9142
9398
|
await options.hmrTimingRecorder.measure("sourceCandidates.buildStart", options.prepareTailwindGeneration, { emit: false });
|
|
@@ -9148,6 +9404,11 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9148
9404
|
//#region src/bundlers/vite/shared/framework-source-scan-session.ts
|
|
9149
9405
|
const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
|
|
9150
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
|
+
}
|
|
9151
9412
|
function createFrameworkSourceScanSession(options) {
|
|
9152
9413
|
const sourceCandidateScanCache = new LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
|
|
9153
9414
|
let sourceScanEntries;
|
|
@@ -9310,12 +9571,12 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9310
9571
|
function createFrameworkTailwindRootCss(options) {
|
|
9311
9572
|
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
9312
9573
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
9313
|
-
const normalizeSourceFile = (id) =>
|
|
9574
|
+
const normalizeSourceFile = (id) => resolveViteModuleIdentity(id).key;
|
|
9314
9575
|
const rememberModule = (id) => {
|
|
9315
9576
|
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
9316
9577
|
moduleIds.add(id);
|
|
9317
|
-
const
|
|
9318
|
-
if (isSourceStyleRequest(cleanId)) moduleIds.add(
|
|
9578
|
+
const identity = resolveViteModuleIdentity(id);
|
|
9579
|
+
if (isSourceStyleRequest(identity.cleanId)) for (const moduleId of identity.lookupIds) moduleIds.add(moduleId);
|
|
9319
9580
|
};
|
|
9320
9581
|
const register = async (id, code) => {
|
|
9321
9582
|
rememberModule(id);
|
|
@@ -9619,7 +9880,8 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9619
9880
|
generatedClassSetByFile,
|
|
9620
9881
|
getCommand: () => resolvedConfig?.command,
|
|
9621
9882
|
getGeneratorOptions: resolveCurrentGeneratorOptions,
|
|
9622
|
-
getSourceCandidate: (file) => sourceCandidateCollector.source(file)
|
|
9883
|
+
getSourceCandidate: (file) => sourceCandidateCollector.source(file),
|
|
9884
|
+
isRuntimeAffectingSource: (file) => uniAppXEnabled && /\.(?:uvue|nvue)$/i.test(cleanUrl(file))
|
|
9623
9885
|
});
|
|
9624
9886
|
const sourceScanSession = createFrameworkSourceScanSession({
|
|
9625
9887
|
cssMemory,
|
|
@@ -9728,7 +9990,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9728
9990
|
const transient = hookContext?.transient === true;
|
|
9729
9991
|
const pendingHmrChange = transient ? void 0 : hmrCandidateState.resolve(generatorCode, file);
|
|
9730
9992
|
const forceFullHmrCssRegeneration = hmrCandidateState.shouldForceFullRegeneration(pendingHmrChange !== void 0);
|
|
9731
|
-
const runtime = fullRuntime;
|
|
9993
|
+
const runtime = hookContext?.sourceCandidates === void 0 ? fullRuntime : new Set(hookContext.sourceCandidates);
|
|
9732
9994
|
const importShellCss = resolveViteServeRootMiniProgramImportShell({
|
|
9733
9995
|
css: generatorTransformCode,
|
|
9734
9996
|
cssPipelineContext,
|
|
@@ -9801,8 +10063,8 @@ ${previousTracedCss}`;
|
|
|
9801
10063
|
previousCss: previousGeneratorCss,
|
|
9802
10064
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
9803
10065
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
9804
|
-
deferCssAdaptation: !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
9805
|
-
disableSourceScan:
|
|
10066
|
+
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
10067
|
+
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
9806
10068
|
cssStage: hookContext?.cssStage,
|
|
9807
10069
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
9808
10070
|
}), {
|
|
@@ -9856,7 +10118,7 @@ ${previousTracedCss}`;
|
|
|
9856
10118
|
source: tracedCss
|
|
9857
10119
|
});
|
|
9858
10120
|
markViteProcessedCssSource(file);
|
|
9859
|
-
rememberTailwindRootCssModule(id);
|
|
10121
|
+
if (hasTailwindRootDirectives(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
9860
10122
|
recordGeneratorCandidates(fullRuntime);
|
|
9861
10123
|
if (pendingHmrChange) hmrCandidateState.finishTarget(file);
|
|
9862
10124
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
@@ -9869,6 +10131,11 @@ ${previousTracedCss}`;
|
|
|
9869
10131
|
return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
|
|
9870
10132
|
${tracedCss}`;
|
|
9871
10133
|
};
|
|
10134
|
+
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
10135
|
+
...createCssPipelineContext(),
|
|
10136
|
+
code,
|
|
10137
|
+
id
|
|
10138
|
+
}) === true;
|
|
9872
10139
|
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
9873
10140
|
getAppType: () => opts.appType,
|
|
9874
10141
|
generateTailwindCss: generateTailwindCssForVitePipeline,
|
|
@@ -9876,7 +10143,7 @@ ${tracedCss}`;
|
|
|
9876
10143
|
onTailwindRootCss: registerTailwindRootCss,
|
|
9877
10144
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
9878
10145
|
shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
|
|
9879
|
-
shouldDeferGeneration: (
|
|
10146
|
+
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports && hasTailwindRootDirectives(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }) || shouldDeferFrameworkPreTransformGeneration(id, code),
|
|
9880
10147
|
shouldOwnTailwindGeneration,
|
|
9881
10148
|
shouldRewrite: shouldRewriteCssImports,
|
|
9882
10149
|
weappTailwindcssDirPosix
|
|
@@ -9959,6 +10226,7 @@ ${tracedCss}`;
|
|
|
9959
10226
|
getRememberedMainCssSource: cssMemory.getRememberedCssSourceEntry
|
|
9960
10227
|
});
|
|
9961
10228
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10229
|
+
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
9962
10230
|
const prepareTailwindGeneration = async () => {
|
|
9963
10231
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
9964
10232
|
await sourceScanSession.sync();
|
|
@@ -9975,6 +10243,7 @@ ${tracedCss}`;
|
|
|
9975
10243
|
mainCssChunkMatcher,
|
|
9976
10244
|
runtimeState,
|
|
9977
10245
|
styleHandler,
|
|
10246
|
+
syncSourceCandidatesForHotUpdate,
|
|
9978
10247
|
tailwindRootCssModuleIds,
|
|
9979
10248
|
uniAppX,
|
|
9980
10249
|
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
@@ -10044,12 +10313,14 @@ ${tracedCss}`;
|
|
|
10044
10313
|
syncCssEntriesFromAnchor
|
|
10045
10314
|
});
|
|
10046
10315
|
const plugins = [
|
|
10316
|
+
...extraPlugins,
|
|
10047
10317
|
...rewritePlugins,
|
|
10048
10318
|
sourceCandidatesPlugin,
|
|
10049
10319
|
...createViteCssGenerationPlugins({
|
|
10050
10320
|
generateCss: generateTailwindCssForVitePipeline,
|
|
10051
10321
|
getCommand: () => resolvedConfig?.command,
|
|
10052
10322
|
onTailwindRootCss: registerTailwindRootCss,
|
|
10323
|
+
shouldDeferGeneration: shouldDeferFrameworkPreTransformGeneration,
|
|
10053
10324
|
shouldGenerate: () => shouldOwnTailwindGeneration,
|
|
10054
10325
|
shouldGenerateBuild: () => resolveCurrentGeneratorBranch().isWeb
|
|
10055
10326
|
}),
|
|
@@ -10072,7 +10343,6 @@ ${tracedCss}`;
|
|
|
10072
10343
|
},
|
|
10073
10344
|
postPlugin
|
|
10074
10345
|
];
|
|
10075
|
-
plugins.push(...extraPlugins);
|
|
10076
10346
|
plugins.push(cssFinalizerOutputPlugin);
|
|
10077
10347
|
plugins.push(...createBuiltinViteStyleInjectorPlugins(styleInjector, () => frameworkBranch.styleInjectorDelegate));
|
|
10078
10348
|
return plugins;
|
|
@@ -10334,7 +10604,8 @@ function resolveUniAppXNativeCssHandlerOptions(opts) {
|
|
|
10334
10604
|
//#endregion
|
|
10335
10605
|
//#region src/bundlers/vite/frameworks/uni-app-x/index.ts
|
|
10336
10606
|
function isUniAppXNativeAppStyleTarget(context) {
|
|
10337
|
-
|
|
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);
|
|
10338
10609
|
}
|
|
10339
10610
|
function isUniAppXHarmonyAppStyleTarget(context) {
|
|
10340
10611
|
const uniUtsPlatform = resolveUniUtsPlatform();
|
|
@@ -10361,6 +10632,9 @@ const uniAppXCssPipelineStrategy = {
|
|
|
10361
10632
|
if (!context.cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(context.generatorCode)) return false;
|
|
10362
10633
|
return true;
|
|
10363
10634
|
},
|
|
10635
|
+
shouldDeferPreTransformTailwindGeneration(context) {
|
|
10636
|
+
return resolveUniAppXCssTarget(context.id) === "uvue" && hasTailwindApplyDirective(context.code) && !hasTailwindRootDirectives(context.code, { importFallback: true });
|
|
10637
|
+
},
|
|
10364
10638
|
transformGeneratedCss(css, context) {
|
|
10365
10639
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
10366
10640
|
return withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
@@ -10387,6 +10661,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10387
10661
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10388
10662
|
runtimeState: context.runtimeState,
|
|
10389
10663
|
styleHandler: context.styleHandler,
|
|
10664
|
+
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
|
10390
10665
|
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10391
10666
|
uniAppX: context.uniAppX,
|
|
10392
10667
|
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|