weapp-tailwindcss 5.5.0 → 5.5.2
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/bundlers/shared/css-imports.d.ts +1 -0
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
- package/dist/compiler/runtime-snapshot.d.ts +4 -1
- package/dist/{compiler-SwMb3lOX.cjs → compiler-BSMSbVVt.cjs} +6 -6
- package/dist/{compiler-B0YSc0DY.js → compiler-tHMcW3BT.js} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DsCSPIj2.cjs} +29 -0
- package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
- package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
- package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
- package/dist/defaults.cjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/{final-css-cleanup-CmVYbXPr.js → final-css-cleanup-B0HUBtiE.js} +63 -37
- package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
- package/dist/{generator-DsrQ9txU.cjs → generator-CCw17l0G.cjs} +72 -67
- package/dist/{generator-DyXTBPmE.js → generator-DxEsInLz.js} +61 -68
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-Dtc01FdI.cjs → gulp-C1r36Y_f.cjs} +6 -6
- package/dist/{gulp-CVUiPXPy.js → gulp-qGXKwQMZ.js} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-DixZjtTS.js} +245 -183
- package/dist/{hmr-timing-3SdRVfZx.cjs → hmr-timing-DuIbach8.cjs} +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-DVrgv1HS.cjs → pipeline-helpers-CUwwOFt3.cjs} +5 -5
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +6 -3
- package/dist/rspack.js +6 -3
- package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-BJvL2CKZ.js} +3 -3
- package/dist/{scoped-generator-B7thnzzm.cjs → scoped-generator-CO9xZ06m.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-CgJi--lh.js} +2 -2
- package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-_UPwg8oJ.cjs} +2 -2
- package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
- package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-D2joPNdN.js} +1 -1
- package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-DhaLV5a2.cjs} +1 -1
- package/dist/{transform-C0rWZblB.js → transform-BNtyKkZi.js} +14 -14
- package/dist/{transform-C7QxW-fV.cjs → transform-DAg85t9Z.cjs} +14 -14
- package/dist/uni-app-x/border-preflight.d.ts +18 -0
- package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
- package/dist/uni-app-x/vite/style-source.d.ts +21 -0
- package/dist/{v4-generation-core-DuIVZvRz.cjs → v4-generation-core-bOm8k4AY.cjs} +243 -181
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-0PsttwuR.js → vite-C_JJxZWl.js} +290 -69
- package/dist/{vite-CJbO-7AQ.cjs → vite-bJZi1V-l.cjs} +306 -66
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
- package/dist/weapp-tw-css-generation-loader.cjs +3 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
- package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
- package/dist/{web-BFOkkJ-8.cjs → web-B4wa3xrE.cjs} +13 -8
- package/dist/{web-D8HSs56R.js → web-BiubXhxs.js} +11 -6
- package/dist/{webpack-DVtKeBq1.js → webpack-BDOQUv3J.js} +39 -24
- package/dist/{webpack-BWknqSDV.cjs → webpack-CsBe1G_1.cjs} +37 -23
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +7 -5
- package/dist/final-css-cleanup-BMlUDzik.cjs +0 -112
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
2
|
-
import { $ as hasTailwindRootDirectives, At as resolveTailwindV4CssSourceBase,
|
|
3
|
-
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
2
|
+
import { $ as hasTailwindRootDirectives, At as resolveTailwindV4CssSourceBase, J as splitUserCssLayerBlocks, Nt as parseCssImportSpecifier, O as resolveTailwindcssOptions, Pt as quoteCssImportSpecifier, R as hasMiniProgramCssSpecificityPlaceholders, Rt as getTailwindV4IncrementalGenerateCacheStats, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, V as stripMiniProgramCssSpecificityPlaceholders, W as normalizeEmptyTailwindCustomVariants, Z as hasTailwindApplyDirective, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, at as removeTailwindSourceDirectives, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, dt as hasTailwindGeneratedCssMarkers, et as hasTailwindSourceDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as parseImportRequest, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, q as hasUserCssLayerBlocks, rt as normalizeTailwindSourceForGenerator, s as shouldUseMiniProgramCssBranch, tt as normalizeTailwindConfigDirectives, x as normalizeCssEntries, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-DxEsInLz.js";
|
|
3
|
+
import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-D2joPNdN.js";
|
|
4
4
|
import "./utils-MVwpU07P.js";
|
|
5
|
-
import { A as createCssSourceTraceCacheSignature, B as createSourceCandidateCollector, C as isSourceStyleRequest, D as parseBundlerGeneratedCssMarkerBlocks, E as hasBundlerGeneratedCssMarker, H as isSourceCandidateRequest, I as isPureLocalCssImportWrapper, M as isCssSourceTraceEnabled, O as stripBundlerGeneratedCssMarkers, S as isSourcePreprocessorRequest, T as createBundlerGeneratedCssMarker, U as extractCandidatesFromSource, a as
|
|
6
|
-
import { E as normalizeFrameworkStylePlatform, G as replaceWxml, K as createDebug, L as createCompilationDependencyChanges, N as recordCompilationDependencyChanges, O as AssetEmissionPlan, a as beginCompilerShadowRun, b as logTailwindcssTarget, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, v as shouldSkipJsTransform, x as logRuntimeTailwindcssVersion, y as toCustomAttributesEntities } from "./compiler-
|
|
7
|
-
import { i as buildRuntimeCompilationSnapshot, l as updateRuntimeCompilationBuildState, n as
|
|
8
|
-
import { a as createJsHashSalt, c as hasRuntimeAffectingSourceChanges, d as resolvePluginDisabledState, f as createBuiltinViteStyleInjectorPlugins, g as resolveViteFrameworkProfile, i as createCandidateSignature, l as summarizeStringDiff, m as viteStyleInjectorDelegates, n as createScopedGeneratorRuntime, o as createLinkedImpactSignature, r as createScopedGeneratorSourceTraceMap, s as getSnapshotHash, t as createScopedGeneratorCandidateSignature, u as classifyRuntimeEntry } from "./scoped-generator-
|
|
9
|
-
import { $ as isMatchingCssSourceFile, A as createGenericWebProductionSourceCandidatesApply, At as resolveViteCssPipelineOutputFileFromSourceFile, B as parseVueRequest, Bt as createViteCssAssetIdentityResolver, C as collectViteProcessedCssSources, Ct as SOURCE_STYLE_OUTPUT_EXT_RE, D as registerGeneratorDependencies$1, Dt as resolveReplayCssOutputFile, E as inferPlatformFromViteOutDir$1, Et as resolveMiniProgramStyleOutputExtension, F as resolveHotSourceModulesByIds, Ft as normalizePath, G as hasSfcStyleSources, Gt as frameworkViteCapabilityProfile, H as shouldApplyViteWebCssCompat, Ht as getActiveViteSourceOutputRelationOwner, I as resolveHotTailwindCssModules, It as resolveViteCssPipelineRequestFile, J as normalizeSfcSourceFileForCompare, K as hasTailwindGenerationSource, L as sendFullReloadForUnresolvedHotUpdate, Lt as slash, M as hasSelfAcceptingNonStyleHotModule, Mt as formatPostcssSourceMap, N as mergeHotModulesByIdentity, Nt as isCSSRequest, O as shouldGenerateCssByGenerator, Ot as resolveViteCssOutputFile, P as resolveHotSourceModules, Pt as isHTMLRequest, Q as hasMatchingStyleFileBase, R as sendSupplementalCssHotUpdates, Rt as createCssHandlerOptionsCache, S as tryFinalizeGenericWebCss, St as CSS_SOURCE_OUTPUT_EXT_RE, T as finalizeWebCss, Tt as normalizeCssSourceForCompare, U as collectChunkModuleIds$3, Ut as withViteSourceOutputRelationOwner, V as resolveViteWebCssCompatOptions, Vt as createViteSourceOutputRelationOwner, W as extractSfcStyleBlocks, Wt as createGenericWebViteCapabilityProfile, X as resolveSfcStyleSourceFromOutputFile, Y as resolveSfcStyleRequestFromKnownSource, Z as resolveSourceStyleSourceFromOutputFile, _ as summarizeStringCache, _t as resolveViteProcessedCssAssetSource, a as createFrameworkProcessedCssRegistry, at as createCssAssetPipelineContext, b as touchMapEntry, bt as isRootStyleOutputFile, c as createViteHmrCssModuleVersionTracker, ct as hasNonCommentCss, d as createViteCssGenerationPlugins, dt as normalizeInjectableCssForTarget, et as appendCss$1, f as createViteRuntimeClassSet, ft as normalizeInjectableCssForTargetWithImports, g as normalizeVitePersistentCacheKey, gt as removeTailwindEntryDirectivesFromCss, h as isMissingInternalCssSource, ht as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, i as syncFrameworkSourceCandidatesForHotUpdate, it as collectRootStyleBundleCssSources, j as shouldSkipGenericWebProductionSourceCandidates, jt as cleanUrl$1, k as createGenericWebProductionBundleHooks, kt as resolveViteCssPipelineOutputFile, l as createViteHmrCandidateState, lt as isMatchingGeneratedCssMarkerFile, m as hasVitePipelineTailwindGenerationDirective, mt as readAssetSource$2, n as createFrameworkTailwindRootCss, nt as collectImportedStyleFiles, o as createFrameworkPostPlugin, ot as dedupeViteCssResults, p as createRewriteCssImportsPlugins, pt as normalizeMarkerOutputFile, q as isSfcStyleSourceFile, r as createFrameworkSourceScanSession, rt as collectMatchingGeneratedCssMarkerFiles, s as createViteHmrCssModuleVersionFilterPlugin, st as getAssetFile$1, t as createGenericWebVitePlugins, tt as clearAssetSource, u as createFrameworkCssGenerationQueue, ut as isStyleImportRequest, v as createViteCssMemory, vt as isCssOutputFile, w as createCssHandlerOptions, wt as canProcessViteSourceStyleAsCss, x as createViteWebCssFinalizerOutputPlugin, xt as posix, y as shouldCollectTransformedSourceCandidates, yt as isMiniProgramStyleOutputFile, z as resolveViteModuleIdentity, zt as resolveViteCssHandlerExtraOptions } from "./web-
|
|
10
|
-
import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-
|
|
5
|
+
import { A as createCssSourceTraceCacheSignature, B as createSourceCandidateCollector, C as isSourceStyleRequest, D as parseBundlerGeneratedCssMarkerBlocks, E as hasBundlerGeneratedCssMarker, H as isSourceCandidateRequest, I as isPureLocalCssImportWrapper, M as isCssSourceTraceEnabled, O as stripBundlerGeneratedCssMarkers, S as isSourcePreprocessorRequest, T as createBundlerGeneratedCssMarker, U as extractCandidatesFromSource, a as collectGeneratedRawSourceCandidatesFromCss, d as normalizeMiniProgramImportShell, f as scoreTailwindV4CssSourceFileMatch, h as mergeMarkedUserLayerComponentsCss, i as validateCandidatesByGenerator, j as createCssTokenSourceMap, k as annotateCssSourceTrace, l as runWithConcurrency, m as extractMarkedUserLayerComponentsCss, r as generateTailwindV4Css, t as createHmrTimingRecorder, u as normalizeMiniProgramGeneratorCssSource, z as finalizeCompilerShadowRun } from "./hmr-timing-DixZjtTS.js";
|
|
6
|
+
import { E as normalizeFrameworkStylePlatform, G as replaceWxml, K as createDebug, L as createCompilationDependencyChanges, N as recordCompilationDependencyChanges, O as AssetEmissionPlan, a as beginCompilerShadowRun, b as logTailwindcssTarget, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, n as createRuntimeAffectingSourceSignature, v as shouldSkipJsTransform, x as logRuntimeTailwindcssVersion, y as toCustomAttributesEntities } from "./compiler-tHMcW3BT.js";
|
|
7
|
+
import { i as buildRuntimeCompilationSnapshot, l as updateRuntimeCompilationBuildState, n as hasEmptyCssBlockCandidate, o as createRuntimeCompilationBuildState, r as processCachedTask, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-B0HUBtiE.js";
|
|
8
|
+
import { a as createJsHashSalt, c as hasRuntimeAffectingSourceChanges, d as resolvePluginDisabledState, f as createBuiltinViteStyleInjectorPlugins, g as resolveViteFrameworkProfile, i as createCandidateSignature, l as summarizeStringDiff, m as viteStyleInjectorDelegates, n as createScopedGeneratorRuntime, o as createLinkedImpactSignature, r as createScopedGeneratorSourceTraceMap, s as getSnapshotHash, t as createScopedGeneratorCandidateSignature, u as classifyRuntimeEntry } from "./scoped-generator-BJvL2CKZ.js";
|
|
9
|
+
import { $ as isMatchingCssSourceFile, A as createGenericWebProductionSourceCandidatesApply, At as resolveViteCssPipelineOutputFileFromSourceFile, B as parseVueRequest, Bt as createViteCssAssetIdentityResolver, C as collectViteProcessedCssSources, Ct as SOURCE_STYLE_OUTPUT_EXT_RE, D as registerGeneratorDependencies$1, Dt as resolveReplayCssOutputFile, E as inferPlatformFromViteOutDir$1, Et as resolveMiniProgramStyleOutputExtension, F as resolveHotSourceModulesByIds, Ft as normalizePath, G as hasSfcStyleSources, Gt as frameworkViteCapabilityProfile, H as shouldApplyViteWebCssCompat, Ht as getActiveViteSourceOutputRelationOwner, I as resolveHotTailwindCssModules, It as resolveViteCssPipelineRequestFile, J as normalizeSfcSourceFileForCompare, K as hasTailwindGenerationSource, L as sendFullReloadForUnresolvedHotUpdate, Lt as slash, M as hasSelfAcceptingNonStyleHotModule, Mt as formatPostcssSourceMap, N as mergeHotModulesByIdentity, Nt as isCSSRequest, O as shouldGenerateCssByGenerator, Ot as resolveViteCssOutputFile, P as resolveHotSourceModules, Pt as isHTMLRequest, Q as hasMatchingStyleFileBase, R as sendSupplementalCssHotUpdates, Rt as createCssHandlerOptionsCache, S as tryFinalizeGenericWebCss, St as CSS_SOURCE_OUTPUT_EXT_RE, T as finalizeWebCss, Tt as normalizeCssSourceForCompare, U as collectChunkModuleIds$3, Ut as withViteSourceOutputRelationOwner, V as resolveViteWebCssCompatOptions, Vt as createViteSourceOutputRelationOwner, W as extractSfcStyleBlocks, Wt as createGenericWebViteCapabilityProfile, X as resolveSfcStyleSourceFromOutputFile, Y as resolveSfcStyleRequestFromKnownSource, Z as resolveSourceStyleSourceFromOutputFile, _ as summarizeStringCache, _t as resolveViteProcessedCssAssetSource, a as createFrameworkProcessedCssRegistry, at as createCssAssetPipelineContext, b as touchMapEntry, bt as isRootStyleOutputFile, c as createViteHmrCssModuleVersionTracker, ct as hasNonCommentCss, d as createViteCssGenerationPlugins, dt as normalizeInjectableCssForTarget, et as appendCss$1, f as createViteRuntimeClassSet, ft as normalizeInjectableCssForTargetWithImports, g as normalizeVitePersistentCacheKey, gt as removeTailwindEntryDirectivesFromCss, h as isMissingInternalCssSource, ht as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, i as syncFrameworkSourceCandidatesForHotUpdate, it as collectRootStyleBundleCssSources, j as shouldSkipGenericWebProductionSourceCandidates, jt as cleanUrl$1, k as createGenericWebProductionBundleHooks, kt as resolveViteCssPipelineOutputFile, l as createViteHmrCandidateState, lt as isMatchingGeneratedCssMarkerFile, m as hasVitePipelineTailwindGenerationDirective, mt as readAssetSource$2, n as createFrameworkTailwindRootCss, nt as collectImportedStyleFiles, o as createFrameworkPostPlugin, ot as dedupeViteCssResults, p as createRewriteCssImportsPlugins, pt as normalizeMarkerOutputFile, q as isSfcStyleSourceFile, r as createFrameworkSourceScanSession, rt as collectMatchingGeneratedCssMarkerFiles, s as createViteHmrCssModuleVersionFilterPlugin, st as getAssetFile$1, t as createGenericWebVitePlugins, tt as clearAssetSource, u as createFrameworkCssGenerationQueue, ut as isStyleImportRequest, v as createViteCssMemory, vt as isCssOutputFile, w as createCssHandlerOptions, wt as canProcessViteSourceStyleAsCss, x as createViteWebCssFinalizerOutputPlugin, xt as posix, y as shouldCollectTransformedSourceCandidates, yt as isMiniProgramStyleOutputFile, z as resolveViteModuleIdentity, zt as resolveViteCssHandlerExtraOptions } from "./web-BiubXhxs.js";
|
|
10
|
+
import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-CgJi--lh.js";
|
|
11
11
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
12
12
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import process from "node:process";
|
|
15
15
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
16
|
-
import { compileCssMacroConditionalComments, containsCssAfterMinify, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, parseTailwindCssDirectiveRequest, postcss, restoreUniAppXImportantApplyMarker, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
|
|
16
|
+
import { compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createInjectPreflight, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, parseTailwindCssDirectiveRequest, postcss, restoreUniAppXImportantApplyMarker, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
|
|
17
17
|
import { LRUCache } from "lru-cache";
|
|
18
18
|
import { readFile } from "node:fs/promises";
|
|
19
19
|
import micromatch from "micromatch";
|
|
@@ -21,7 +21,21 @@ import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
|
21
21
|
import { Buffer } from "node:buffer";
|
|
22
22
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
23
23
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
24
|
-
import
|
|
24
|
+
import scss from "postcss-scss";
|
|
25
|
+
import { NodeTypes } from "@vue/compiler-dom";
|
|
26
|
+
import { parse as parse$1 } from "comment-json";
|
|
27
|
+
//#region src/uni-app-x/style-asset/source-parser.ts
|
|
28
|
+
function parseUniAppXStyleSource(source) {
|
|
29
|
+
return scss.parse(source, { from: void 0 });
|
|
30
|
+
}
|
|
31
|
+
function isUniAppXStyleSourceEmpty(source) {
|
|
32
|
+
try {
|
|
33
|
+
return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
25
39
|
//#region src/uni-app-x/style-asset/harmony-apply.ts
|
|
26
40
|
const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
|
|
27
41
|
function createGeneratedRuleMap(css) {
|
|
@@ -45,7 +59,7 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
|
|
|
45
59
|
if (!styleSource.includes("@apply")) return block;
|
|
46
60
|
let root;
|
|
47
61
|
try {
|
|
48
|
-
root =
|
|
62
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
49
63
|
} catch {
|
|
50
64
|
return block;
|
|
51
65
|
}
|
|
@@ -237,7 +251,7 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
237
251
|
for (const styleSource of styleSources) {
|
|
238
252
|
let root;
|
|
239
253
|
try {
|
|
240
|
-
root =
|
|
254
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
241
255
|
} catch {
|
|
242
256
|
continue;
|
|
243
257
|
}
|
|
@@ -266,13 +280,13 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
266
280
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
267
281
|
}
|
|
268
282
|
function resolveReferencePaths(styleSource, sourceId) {
|
|
269
|
-
if (!sourceId || !styleSource.includes("@reference")) return styleSource;
|
|
270
283
|
let root;
|
|
271
284
|
try {
|
|
272
|
-
root =
|
|
285
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
273
286
|
} catch {
|
|
274
287
|
return styleSource;
|
|
275
288
|
}
|
|
289
|
+
if (!sourceId || !styleSource.includes("@reference")) return root.toString();
|
|
276
290
|
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
277
291
|
const pathApi = /^[a-z]:[\\/]/i.test(cleanSourceId) ? path.win32 : path;
|
|
278
292
|
root.walkAtRules("reference", (rule) => {
|
|
@@ -294,7 +308,7 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
|
294
308
|
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) {
|
|
295
309
|
let root;
|
|
296
310
|
try {
|
|
297
|
-
root =
|
|
311
|
+
root = parseUniAppXStyleSource(styleSource);
|
|
298
312
|
} catch {
|
|
299
313
|
continue;
|
|
300
314
|
}
|
|
@@ -518,7 +532,7 @@ function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtili
|
|
|
518
532
|
return applyStyleSources.map((source) => {
|
|
519
533
|
let root;
|
|
520
534
|
try {
|
|
521
|
-
root =
|
|
535
|
+
root = parseUniAppXStyleSource(source);
|
|
522
536
|
} catch {
|
|
523
537
|
return source;
|
|
524
538
|
}
|
|
@@ -840,7 +854,7 @@ function restoreCssImportAtRules(source, filtered, file) {
|
|
|
840
854
|
return appendCss$1(missingImports.join("\n"), filtered);
|
|
841
855
|
}
|
|
842
856
|
function removeCommentOnlyAtRules(css) {
|
|
843
|
-
if (!
|
|
857
|
+
if (!hasEmptyCssBlockCandidate(css)) return css;
|
|
844
858
|
try {
|
|
845
859
|
const root = postcss.parse(css);
|
|
846
860
|
let changed = false;
|
|
@@ -1456,7 +1470,7 @@ function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
|
1456
1470
|
return enabled === true;
|
|
1457
1471
|
}
|
|
1458
1472
|
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
1459
|
-
return !options.isWebGeneratorTarget && options.matchesCss &&
|
|
1473
|
+
return !options.isWebGeneratorTarget && options.matchesCss && isRootStyleOutputFile(options.file) && isPureLocalCssImportWrapper(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
1460
1474
|
}
|
|
1461
1475
|
function resolveFrameworkRootImportShellPlan(options) {
|
|
1462
1476
|
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
@@ -1471,7 +1485,7 @@ function resolveFrameworkRootImportShellPlan(options) {
|
|
|
1471
1485
|
return {
|
|
1472
1486
|
isCurrentImportShell,
|
|
1473
1487
|
reusableTarget: options.rememberedTarget,
|
|
1474
|
-
targetToRemember: importedFile &&
|
|
1488
|
+
targetToRemember: importedFile && isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
1475
1489
|
};
|
|
1476
1490
|
}
|
|
1477
1491
|
if (options.rememberedTarget) return {
|
|
@@ -1498,7 +1512,7 @@ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
1498
1512
|
const writeTargets = /* @__PURE__ */ new Map();
|
|
1499
1513
|
let restored = 0;
|
|
1500
1514
|
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
1501
|
-
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !
|
|
1515
|
+
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootStyleOutputFile(sourceFile) || !isRootStyleOutputFile(targetFile) || normalizeOutputPathKey(sourceFile) === normalizeOutputPathKey(targetFile)) continue;
|
|
1502
1516
|
const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && normalizeOutputPathKey(candidate.fileName || bundleFile) === normalizeOutputPathKey(sourceFile))?.[1];
|
|
1503
1517
|
if (output?.type !== "asset") continue;
|
|
1504
1518
|
const rawSource = output.source.toString();
|
|
@@ -1668,6 +1682,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1668
1682
|
if (removableRecords.length === 0) return 0;
|
|
1669
1683
|
const recordFileKeys = new Set(removableRecords.map((record) => normalizeOutputPathKey(record.file)));
|
|
1670
1684
|
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
1685
|
+
const targetMatcher = createCssRuleMatcher(targetCss);
|
|
1671
1686
|
let removed = 0;
|
|
1672
1687
|
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
1673
1688
|
if (candidateOutput.type !== "asset") continue;
|
|
@@ -1676,7 +1691,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1676
1691
|
const candidateIsRootWebStyle = isRootStyleOutputFile(candidateKey) && !isMiniProgramStyleOutputFile(candidateKey);
|
|
1677
1692
|
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
1678
1693
|
const candidateSource = readAssetSource$2(candidateOutput).trim();
|
|
1679
|
-
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) ||
|
|
1694
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || targetMatcher.contains(candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !hasNonCommentCss(targetMatcher.filter(candidateSource).trim())))) continue;
|
|
1680
1695
|
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
1681
1696
|
else clearAssetSource(candidateOutput);
|
|
1682
1697
|
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
@@ -2062,15 +2077,22 @@ function createTransformFilterSignature(options) {
|
|
|
2062
2077
|
//#region src/bundlers/vite/generate-bundle/bundle-markup-candidates.ts
|
|
2063
2078
|
async function collectBundleMarkupCandidates(options) {
|
|
2064
2079
|
const { extractSourceCandidates, previousCandidatesByFile, preserveMissingFiles, resolveSourceCandidateFile, rootDir, snapshot, transformFilter } = options;
|
|
2065
|
-
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file,
|
|
2080
|
+
const candidatesByFile = preserveMissingFiles ? new Map([...previousCandidatesByFile ?? []].map(([file, entry]) => [file, {
|
|
2081
|
+
...entry,
|
|
2082
|
+
candidates: new Set(entry.candidates)
|
|
2083
|
+
}])) : /* @__PURE__ */ new Map();
|
|
2084
|
+
for (const file of snapshot.removedFiles) candidatesByFile.delete(file);
|
|
2066
2085
|
await Promise.all(snapshot.entries.map(async (entry) => {
|
|
2067
2086
|
if (!extractSourceCandidates || entry.type !== "html" || entry.output.type !== "asset" || shouldSkipViteAssetTransform(entry.output, entry.file, rootDir, transformFilter)) return;
|
|
2068
2087
|
const sourceFile = resolveSourceCandidateFile(entry.file) ?? path.resolve(rootDir, entry.file);
|
|
2069
|
-
candidatesByFile.set(
|
|
2088
|
+
candidatesByFile.set(entry.file, {
|
|
2089
|
+
sourceFile,
|
|
2090
|
+
candidates: await extractSourceCandidates(sourceFile, entry.source)
|
|
2091
|
+
});
|
|
2070
2092
|
}));
|
|
2071
2093
|
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
2072
2094
|
const values = /* @__PURE__ */ new Set();
|
|
2073
|
-
for (const
|
|
2095
|
+
for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
|
|
2074
2096
|
if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(file, entries)) continue;
|
|
2075
2097
|
if (filterOptions.excludeEntries?.length && isFileMatchedByTailwindSourceEntries(file, filterOptions.excludeEntries)) continue;
|
|
2076
2098
|
for (const candidate of candidates) values.add(candidate);
|
|
@@ -2567,7 +2589,11 @@ async function processViteCssBundleEntry(options) {
|
|
|
2567
2589
|
const { activeViteCssCacheFiles, addWatchFile, annotateCssSourceTrace, applyCssResultToBundle, applyViteCssCacheResult, applyViteCssTransformTaskResult, bundle, bundleFiles, cache, collectedBundlerGeneratedCssFiles, configuredTailwindV4CssSourceFileKeysForScope, configuredTailwindV4ExplicitCssEntryFileKeysForScope, context, createCandidateSignature, createCssSourceTraceCacheSignature, createCssTokenSourceMap, createCssTransformShareScopeKey, createInitialCssPipelineContext, createRuntimeAffectingSourceSignature, createScopedGeneratorCandidateSignature, createScopedGeneratorRuntime, createScopedGeneratorSourceTraceMap, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, currentSubpackageRoots, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, envFlags, executeViteCssTransformTask, file, frameworkRootImportShellTargetByFile, generatorCandidatesChanged, generatorPlatform, generatorRuntime, getConfiguredTailwindV4CssSourceEntries, getCssHandlerOptions, getCssSource, getCssUserHandlerOptions, getLastCssResult, getOriginalCssLayerSource, getRememberedCssSources, getSfcSource, getSourceCandidateSources, getViteProcessedCssAssetResult, getViteProcessedCssAssetResults, hasExplicitConfiguredRootCssEntryForOutput, hasRuntimeAffectingChanges, hasViteProcessedCssResultForSource, isCssAssetProcessed, isCssImportOnlyBundleAsset, isMiniProgramStyleOutputFile, isRootMiniProgramStyleOutputFile, isSubpackageOutputFile, isTemporaryCssAssetFile, isViteProcessedCssAsset, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, measureElapsed, metrics, normalizeConfiguredTailwindV4CssEntryFileKey, normalizeGeneratorUserRawSource, normalizeMiniProgramGeneratorRawSource, normalizeOutputPathKey, normalizeRelativeCssConfigDirectives, normalizeViteCssCacheKey, onUpdate, opts, originalEntrySource, originalSource, outDir, processFiles, processViteCssCacheTask, recordCssAssetResult, recordViteProcessedCssAssetResult, rememberCssSource, rememberProcessCacheKey, removeCssCoveredByRootStyleBundleSources, resolveAssetSourceFile, resolveConfiguredCssEntryRootInjectionTarget, resolveConfiguredRootCssSourceStyle, resolveCssAssetIdentity, resolveCssAssetOutputPlan, resolveFrameworkRootImportShellPlan, resolveMatchedCssSourceOutputFile, resolveReplayCssOutputFile, resolveViteCssCompositionPlan, resolveViteCssLinkedImpactSignature, resolveViteCssPipelineOutputFile, resolveViteCssSourcePlan, resolveViteCssTransformCachePlan, resolveViteCssTransformDecisionPlan, rootDir, runtimeLinkedCssFiles, runtimeSignature, runtimeState, selectConfiguredRootCssSourceEntry, sharedCssResultCache, shouldExcludeSubpackageSourceCandidates, shouldGenerateWebCssByGenerator, shouldInjectCssIntoMainFromOutput, shouldKeepCurrentRootCssOutputForConfiguredSource, shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell, shouldKeepRootMiniProgramStyleAsImportShell, shouldMoveRootMiniProgramStyleToImportShellOrigin, shouldPreserveAppCssExtension, shouldProcessTailwindGeneration, shouldSkipRawRememberedCssSource, shouldSkipRawSourceStyleAsset, shouldSkipViteAssetTransform, snapshot, sourceRoot, state, styleHandler, temporaryCssAssetSourceResolver, timeTask, transformFilter, transformRuntime, transformWebTargetCss, useIncrementalMode, usedConfiguredTailwindV4CssSourceFiles } = options;
|
|
2568
2590
|
metrics.css.total++;
|
|
2569
2591
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
2570
|
-
const rawSource = normalizeRelativeCssConfigDirectives(originalEntrySource
|
|
2592
|
+
const rawSource = normalizeRelativeCssConfigDirectives(isWebGeneratorTarget ? originalEntrySource : normalizeMiniProgramImportShell(originalEntrySource, {
|
|
2593
|
+
cssOnly: true,
|
|
2594
|
+
outputFile: originalSource.fileName || file,
|
|
2595
|
+
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
2596
|
+
}), assetSourceFile, outDir, opts);
|
|
2571
2597
|
const currentRawSourceHasExplicitScanContext = rawSource.includes("@source") || rawSource.includes("@config");
|
|
2572
2598
|
const cssPipelineContext2 = {
|
|
2573
2599
|
...createInitialCssPipelineContext(file),
|
|
@@ -2626,7 +2652,10 @@ async function processViteCssBundleEntry(options) {
|
|
|
2626
2652
|
}))
|
|
2627
2653
|
});
|
|
2628
2654
|
let outputFile = cssAssetOutputPlan.outputFile;
|
|
2629
|
-
const resolveMatchedOutputFileForCurrentAsset =
|
|
2655
|
+
const resolveMatchedOutputFileForCurrentAsset = (sourceFile) => {
|
|
2656
|
+
const matched = cssAssetOutputPlan.resolveMatchedOutputFile(sourceFile);
|
|
2657
|
+
return matched ? frameworkRootImportShellTargetByFile.get(matched) ?? matched : matched;
|
|
2658
|
+
};
|
|
2630
2659
|
const resolvedFromConfiguredOriginalCssEntry = cssAssetOutputPlan.resolvedFromConfiguredOriginalCssEntry;
|
|
2631
2660
|
if (cssAssetOutputPlan.reusedRootImportShellTarget) debug("css reuse framework root import shell target: %s -> %s", rootImportShellOutputFile, outputFile);
|
|
2632
2661
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
@@ -2949,7 +2978,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2949
2978
|
function resolveCssBundleOutputFile(options) {
|
|
2950
2979
|
const { bundleFiles, defaultStyleOutputExtension, file, isWebGeneratorTarget, opts, pipelineContext, cssPipelineStrategy, shouldPreserveAppCssExtension } = options;
|
|
2951
2980
|
let outputFile = resolveViteCssOutputFile(file, opts, isWebGeneratorTarget, shouldPreserveAppCssExtension, defaultStyleOutputExtension, bundleFiles);
|
|
2952
|
-
if (outputFile === file && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
2981
|
+
if (outputFile === file && normalizeOutputPathKey(options.assetOutputFile ?? file) === normalizeOutputPathKey(file) && isRootMiniProgramStyleOutputFile$1(file) && shouldMoveRootMiniProgramStyleToImportShellOrigin(cssPipelineStrategy?.shouldMoveRootMiniProgramStyleToImportShellOrigin?.({
|
|
2953
2982
|
...pipelineContext,
|
|
2954
2983
|
file
|
|
2955
2984
|
}))) outputFile = createRootMiniProgramOriginStyleOutputFile(file);
|
|
@@ -2986,7 +3015,10 @@ function createMatchedCssSourceOutputResolver(options) {
|
|
|
2986
3015
|
};
|
|
2987
3016
|
}
|
|
2988
3017
|
function resolveCssAssetOutputPlan(options) {
|
|
2989
|
-
let outputFile = resolveCssBundleOutputFile(
|
|
3018
|
+
let outputFile = resolveCssBundleOutputFile({
|
|
3019
|
+
...options,
|
|
3020
|
+
assetOutputFile: options.rootImportShellOutputFile
|
|
3021
|
+
});
|
|
2990
3022
|
const reusedRootImportShellTarget = Boolean(options.rootImportShellTarget && !options.isWebGeneratorTarget && (options.opts.cssMatcher(options.rootImportShellOutputFile) || options.opts.cssMatcher(options.file)) && options.shouldReuseRootImportShell());
|
|
2991
3023
|
if (reusedRootImportShellTarget && options.rootImportShellTarget) outputFile = options.rootImportShellTarget;
|
|
2992
3024
|
const resolveMatchedOutputFile = createMatchedCssSourceOutputResolver({
|
|
@@ -3498,21 +3530,22 @@ function applyViteCssTransformTaskResult(options) {
|
|
|
3498
3530
|
}
|
|
3499
3531
|
//#endregion
|
|
3500
3532
|
//#region src/bundlers/vite/generate-bundle/css-transform-task.ts
|
|
3501
|
-
function
|
|
3502
|
-
|
|
3503
|
-
return [options.generatorUserLayerRawSource, bundleUserRawSource].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3533
|
+
function resolveBundleUserRawSource(options) {
|
|
3534
|
+
return options.vitePipelineCssAsset && !hasBundlerGeneratedCssMarker(options.rawSource) && normalizeCssSourceForCompare(options.rawSource) !== normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
|
|
3504
3535
|
}
|
|
3505
3536
|
async function executeViteCssTransformTask(options) {
|
|
3506
3537
|
await options.runtimeState.readyPromise;
|
|
3507
3538
|
const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
|
|
3508
3539
|
if (hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && hasBundlerGeneratedCssMarker(options.rawSource)) {
|
|
3509
|
-
const
|
|
3540
|
+
const bundleUserRawSource = resolveBundleUserRawSource(options);
|
|
3541
|
+
const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3510
3542
|
const generated = await (options.generateCss ?? generateTailwindV4Css)({
|
|
3511
3543
|
cssHandlerOptions: options.generatorCssHandlerOptions,
|
|
3512
3544
|
cssStage: "framework-processed",
|
|
3513
3545
|
cssUserHandlerOptions: options.cssUserHandlerOptions,
|
|
3514
3546
|
debug: options.debug,
|
|
3515
3547
|
file: options.generatorSourceFile,
|
|
3548
|
+
frameworkProcessedUserCss: options.isWebGeneratorTarget ? void 0 : bundleUserRawSource,
|
|
3516
3549
|
generatorPlatform: options.generatorPlatform,
|
|
3517
3550
|
getSourceCandidatesForEntries: options.getSourceCandidatesForEntries,
|
|
3518
3551
|
opts: options.opts,
|
|
@@ -4345,6 +4378,61 @@ function isUniAppXNativeAppOutDir(outDir) {
|
|
|
4345
4378
|
return typeof outDir === "string" && /(?:^|[/\\-])(?:\.uvue[/\\])?app-(?:android|ios|harmony)(?:[/\\-]|$)/.test(outDir);
|
|
4346
4379
|
}
|
|
4347
4380
|
//#endregion
|
|
4381
|
+
//#region src/uni-app-x/border-preflight.ts
|
|
4382
|
+
const BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
|
|
4383
|
+
/** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
|
|
4384
|
+
function hoistUniAppXBorderPreflight(css) {
|
|
4385
|
+
if (!css.includes("weapp-tw-border")) return css;
|
|
4386
|
+
const root = postcss.parse(css);
|
|
4387
|
+
const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
|
|
4388
|
+
const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
|
|
4389
|
+
if (!anchor || resets.length === 0) return css;
|
|
4390
|
+
for (const reset of resets) {
|
|
4391
|
+
reset.remove();
|
|
4392
|
+
root.insertBefore(anchor, reset);
|
|
4393
|
+
}
|
|
4394
|
+
return root.toString();
|
|
4395
|
+
}
|
|
4396
|
+
/** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
|
|
4397
|
+
function createUniAppXBorderPreflight(options) {
|
|
4398
|
+
const declarations = createInjectPreflight(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
|
|
4399
|
+
if (declarations.length === 0) return;
|
|
4400
|
+
const rule = postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
|
|
4401
|
+
for (const declaration of declarations) rule.append(postcss.decl(declaration));
|
|
4402
|
+
return rule.toString();
|
|
4403
|
+
}
|
|
4404
|
+
function resolveUniAppXBorderPreflightOptions(options, isWeb) {
|
|
4405
|
+
const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
|
|
4406
|
+
return borderPreflight ? {
|
|
4407
|
+
borderPreflight,
|
|
4408
|
+
borderPreflightRange: options.cssPreflightRange
|
|
4409
|
+
} : {};
|
|
4410
|
+
}
|
|
4411
|
+
function shouldInjectBorderPreflight(node, range) {
|
|
4412
|
+
return range === "all" ? ![
|
|
4413
|
+
"template",
|
|
4414
|
+
"slot",
|
|
4415
|
+
"block"
|
|
4416
|
+
].includes(node.tag) : node.tag === "view" || node.tag === "text";
|
|
4417
|
+
}
|
|
4418
|
+
/** 在既有 class 转换完成后插入基础类,保持 utility 与动态绑定的原始顺序。 */
|
|
4419
|
+
function injectBorderPreflightClass(ms, node, offset) {
|
|
4420
|
+
const attribute = node.props.find((prop) => prop.type === NodeTypes.ATTRIBUTE && prop.name === "class");
|
|
4421
|
+
if (attribute?.type === NodeTypes.ATTRIBUTE) {
|
|
4422
|
+
if (attribute.value) {
|
|
4423
|
+
if (attribute.value.content.split(/\s+/).includes("weapp-tw-border")) return;
|
|
4424
|
+
const start = offset + attribute.value.loc.start.offset;
|
|
4425
|
+
if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
|
|
4426
|
+
else {
|
|
4427
|
+
ms.prependRight(start, `"${BORDER_PREFLIGHT_CLASS} `);
|
|
4428
|
+
ms.appendLeft(offset + attribute.value.loc.end.offset, "\"");
|
|
4429
|
+
}
|
|
4430
|
+
} else ms.appendLeft(offset + attribute.loc.end.offset, `="${BORDER_PREFLIGHT_CLASS}"`);
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4433
|
+
ms.appendLeft(offset + node.loc.start.offset + node.tag.length + 1, ` class="${BORDER_PREFLIGHT_CLASS}"`);
|
|
4434
|
+
}
|
|
4435
|
+
//#endregion
|
|
4348
4436
|
//#region src/uni-app-x/style-isolation.ts
|
|
4349
4437
|
const manifestCache = /* @__PURE__ */ new Map();
|
|
4350
4438
|
function resolveUniAppXStyleIsolationEnabled(root) {
|
|
@@ -4356,7 +4444,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
4356
4444
|
let enabled = false;
|
|
4357
4445
|
try {
|
|
4358
4446
|
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
4359
|
-
enabled = `${parse(raw)["uni-app-x"]?.styleIsolationVersion ?? ""}` === "2";
|
|
4447
|
+
enabled = `${parse$1(raw)["uni-app-x"]?.styleIsolationVersion ?? ""}` === "2";
|
|
4360
4448
|
} catch {
|
|
4361
4449
|
enabled = false;
|
|
4362
4450
|
}
|
|
@@ -4557,6 +4645,59 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
4557
4645
|
if (!options.isNativeAppStyleTarget) return { result: void 0 };
|
|
4558
4646
|
}
|
|
4559
4647
|
//#endregion
|
|
4648
|
+
//#region src/uni-app-x/vite/style-source.ts
|
|
4649
|
+
const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
|
|
4650
|
+
function createUniAppXSfcStyleSources() {
|
|
4651
|
+
const authoredByFile = /* @__PURE__ */ new Map();
|
|
4652
|
+
const generatedByFile = /* @__PURE__ */ new Map();
|
|
4653
|
+
return {
|
|
4654
|
+
rememberSource(id, source) {
|
|
4655
|
+
authoredByFile.set(cleanUrl$1(id), extractSfcStyleBlocks(source));
|
|
4656
|
+
},
|
|
4657
|
+
rememberGenerated(id, source) {
|
|
4658
|
+
const file = cleanUrl$1(id);
|
|
4659
|
+
const authoredCount = authoredByFile.get(file)?.length ?? 0;
|
|
4660
|
+
const generated = /* @__PURE__ */ new Map();
|
|
4661
|
+
for (const [index, style] of extractSfcStyleBlocks(source).entries()) if (index >= authoredCount) generated.set(index, style.source);
|
|
4662
|
+
generatedByFile.set(file, generated);
|
|
4663
|
+
},
|
|
4664
|
+
getGenerated(id, index) {
|
|
4665
|
+
return generatedByFile.get(cleanUrl$1(id))?.get(index);
|
|
4666
|
+
},
|
|
4667
|
+
hasGenerated(id) {
|
|
4668
|
+
return Boolean(generatedByFile.get(cleanUrl$1(id))?.size);
|
|
4669
|
+
},
|
|
4670
|
+
load(id, index) {
|
|
4671
|
+
const file = cleanUrl$1(id);
|
|
4672
|
+
const style = authoredByFile.get(file)?.[index];
|
|
4673
|
+
if (!style) {
|
|
4674
|
+
const generated = generatedByFile.get(file)?.get(index);
|
|
4675
|
+
return generated === void 0 ? void 0 : {
|
|
4676
|
+
code: generated,
|
|
4677
|
+
map: null
|
|
4678
|
+
};
|
|
4679
|
+
}
|
|
4680
|
+
const normalized = normalizeUniAppXImportantApplyForSass(style.source);
|
|
4681
|
+
return normalized === style.source ? void 0 : {
|
|
4682
|
+
code: normalized,
|
|
4683
|
+
map: null
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4686
|
+
};
|
|
4687
|
+
}
|
|
4688
|
+
function resolveUniAppXStyleSource(code, query, generatedSource) {
|
|
4689
|
+
if (VITE_CSS_HMR_MODULE_RE.test(code)) return { skip: true };
|
|
4690
|
+
if (!query.vue || query.type !== "style") return { code };
|
|
4691
|
+
if (generatedSource !== void 0) return { code: generatedSource };
|
|
4692
|
+
const styleBlocks = extractSfcStyleBlocks(code);
|
|
4693
|
+
if (styleBlocks.length === 0) return { code };
|
|
4694
|
+
const style = styleBlocks[query.index ?? 0];
|
|
4695
|
+
return style ? { code: style.source } : { skip: true };
|
|
4696
|
+
}
|
|
4697
|
+
function hasUniAppXImportantApply(source, normalize) {
|
|
4698
|
+
return extractSfcStyleBlocks(source).some((style) => normalize(style.source) !== style.source);
|
|
4699
|
+
}
|
|
4700
|
+
//#endregion
|
|
4560
4701
|
//#region src/uni-app-x/vite/web-local-style.ts
|
|
4561
4702
|
function isStyleModule(mod) {
|
|
4562
4703
|
const request = mod.id ?? mod.url;
|
|
@@ -4632,14 +4773,11 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4632
4773
|
//#region src/uni-app-x/vite.ts
|
|
4633
4774
|
let transformUVuePromise;
|
|
4634
4775
|
function loadTransformUVue() {
|
|
4635
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
4776
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-BNtyKkZi.js").then((mod) => mod.transformUVue));
|
|
4636
4777
|
return transformUVuePromise;
|
|
4637
4778
|
}
|
|
4638
4779
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
4639
4780
|
const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
|
|
4640
|
-
function hasUniAppXImportantApply(source) {
|
|
4641
|
-
return extractSfcStyleBlocks(source).some((style) => normalizeUniAppXImportantApplyForSass(style.source) !== style.source);
|
|
4642
|
-
}
|
|
4643
4781
|
function createUniAppXPlugins(options) {
|
|
4644
4782
|
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, hmrCssModuleVersions, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [], webCssEntryDiagnostics } = options;
|
|
4645
4783
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
@@ -4647,7 +4785,7 @@ function createUniAppXPlugins(options) {
|
|
|
4647
4785
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
4648
4786
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
4649
4787
|
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
4650
|
-
const
|
|
4788
|
+
const sfcStyleSources = createUniAppXSfcStyleSources();
|
|
4651
4789
|
const pendingSfcTransforms = /* @__PURE__ */ new Map();
|
|
4652
4790
|
const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
|
|
4653
4791
|
let componentLocalStyleEnabled;
|
|
@@ -4711,6 +4849,9 @@ function createUniAppXPlugins(options) {
|
|
|
4711
4849
|
async function transformStyle(code, id, query, hookContext) {
|
|
4712
4850
|
const isNativeStyle = isNativeAppBuildTarget(id);
|
|
4713
4851
|
const parsed = query ?? parseVueRequest(id).query;
|
|
4852
|
+
const resolvedSource = resolveUniAppXStyleSource(code, parsed);
|
|
4853
|
+
if (resolvedSource.skip) return;
|
|
4854
|
+
code = resolvedSource.code;
|
|
4714
4855
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
4715
4856
|
if (isCssModuleExport(code)) return;
|
|
4716
4857
|
const sourceCode = normalizeRelativeTailwindReferences(restoreUniAppXImportantApplyMarker(code), id);
|
|
@@ -4763,14 +4904,8 @@ function createUniAppXPlugins(options) {
|
|
|
4763
4904
|
async handler(id) {
|
|
4764
4905
|
const { filename, query } = parseVueRequest(id);
|
|
4765
4906
|
if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
if (!style) return;
|
|
4769
|
-
const normalized = normalizeUniAppXImportantApplyForSass(style.source);
|
|
4770
|
-
return normalized === style.source ? void 0 : {
|
|
4771
|
-
code: normalized,
|
|
4772
|
-
map: null
|
|
4773
|
-
};
|
|
4907
|
+
await pendingSfcTransforms.get(cleanUrl$1(filename));
|
|
4908
|
+
return sfcStyleSources.load(filename, query.index ?? 0);
|
|
4774
4909
|
}
|
|
4775
4910
|
},
|
|
4776
4911
|
async transform(code, id) {
|
|
@@ -4778,7 +4913,9 @@ function createUniAppXPlugins(options) {
|
|
|
4778
4913
|
await runtimeState.readyPromise;
|
|
4779
4914
|
const { filename, query } = parseVueRequest(id);
|
|
4780
4915
|
if (query.vue && query.type === "style") await pendingSfcTransforms.get(cleanUrl$1(filename));
|
|
4781
|
-
const
|
|
4916
|
+
const resolvedSource = resolveUniAppXStyleSource(code, query, sfcStyleSources.getGenerated(filename, query.index ?? 0));
|
|
4917
|
+
if (resolvedSource.skip) return;
|
|
4918
|
+
const styleCode = query.vue && query.type === "style" && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4782
4919
|
const preprocessorCode = query.vue && query.type === "style" ? normalizeUniAppXImportantApplyForSass(styleCode) : styleCode;
|
|
4783
4920
|
const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
|
|
4784
4921
|
isIosPlatform,
|
|
@@ -4792,7 +4929,7 @@ function createUniAppXPlugins(options) {
|
|
|
4792
4929
|
}
|
|
4793
4930
|
}];
|
|
4794
4931
|
async function transformSfc(code, id, context) {
|
|
4795
|
-
|
|
4932
|
+
sfcStyleSources.rememberSource(id, code);
|
|
4796
4933
|
if (isWebGeneratorTarget()) for (const style of extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
|
|
4797
4934
|
if (isNativeAppBuildTarget(id)) {
|
|
4798
4935
|
nativeLocalStyleModuleIds.add(id);
|
|
@@ -4815,6 +4952,7 @@ function createUniAppXPlugins(options) {
|
|
|
4815
4952
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
4816
4953
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
4817
4954
|
native: true,
|
|
4955
|
+
...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
|
|
4818
4956
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
4819
4957
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
4820
4958
|
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
|
|
@@ -4823,6 +4961,7 @@ function createUniAppXPlugins(options) {
|
|
|
4823
4961
|
} } : {}
|
|
4824
4962
|
});
|
|
4825
4963
|
const result = Object.keys(transformOptions).length > 0 ? transformUVue(code, id, jsHandler, currentRuntimeSet, transformOptions) : transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
4964
|
+
sfcStyleSources.rememberGenerated(id, isWebGeneratorTarget() ? result?.code ?? "" : "");
|
|
4826
4965
|
if (!result?.code) return result;
|
|
4827
4966
|
harmonyApply.rememberSource(result.code, id);
|
|
4828
4967
|
const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
|
|
@@ -4851,7 +4990,8 @@ function createUniAppXPlugins(options) {
|
|
|
4851
4990
|
order: "pre",
|
|
4852
4991
|
async handler(code, id) {
|
|
4853
4992
|
if (!isEnabled()) return;
|
|
4854
|
-
|
|
4993
|
+
const { query } = parseVueRequest(id);
|
|
4994
|
+
if (!UVUE_NVUE_QUERY_RE.test(id) || query.vue && query.type === "style") return;
|
|
4855
4995
|
return runTransformSfc(code, id, this);
|
|
4856
4996
|
}
|
|
4857
4997
|
},
|
|
@@ -4861,8 +5001,9 @@ function createUniAppXPlugins(options) {
|
|
|
4861
5001
|
if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
|
|
4862
5002
|
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
4863
5003
|
if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") {
|
|
5004
|
+
hmrCssModuleVersions?.clear();
|
|
4864
5005
|
const source = await ctx.read();
|
|
4865
|
-
if (hasUniAppXImportantApply(source)) {
|
|
5006
|
+
if (hasUniAppXImportantApply(source, normalizeUniAppXImportantApplyForSass)) {
|
|
4866
5007
|
ctx.server.ws.send({
|
|
4867
5008
|
type: "full-reload",
|
|
4868
5009
|
path: ctx.file
|
|
@@ -5130,8 +5271,13 @@ async function processRememberedCssReplay(options) {
|
|
|
5130
5271
|
const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
|
|
5131
5272
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
5132
5273
|
if (!rememberedCssSource) continue;
|
|
5133
|
-
const {
|
|
5134
|
-
const
|
|
5274
|
+
const { sourceFile } = rememberedCssSource;
|
|
5275
|
+
const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
|
|
5276
|
+
cssOnly: true,
|
|
5277
|
+
outputFile,
|
|
5278
|
+
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
5279
|
+
});
|
|
5280
|
+
const generatorRawSource = isWebGeneratorTarget ? rawSource : normalizeMiniProgramGeneratorCssSource(rawSource, outputFile, [...bundleFiles, ...lastCssResultByFile.keys()]);
|
|
5135
5281
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5136
5282
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
5137
5283
|
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
@@ -5212,7 +5358,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5212
5358
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5213
5359
|
metrics.css.elapsed += measureElapsed(start);
|
|
5214
5360
|
metrics.css.transformed++;
|
|
5215
|
-
onUpdate(outputFile, rawSource, css);
|
|
5361
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5216
5362
|
debug("css replay preserve local import shell: %s", outputFile);
|
|
5217
5363
|
}));
|
|
5218
5364
|
continue;
|
|
@@ -5252,7 +5398,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5252
5398
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5253
5399
|
metrics.css.elapsed += measureElapsed(start);
|
|
5254
5400
|
metrics.css.transformed++;
|
|
5255
|
-
onUpdate(outputFile, rawSource, css);
|
|
5401
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5256
5402
|
debug("css replay handle: %s", outputFile);
|
|
5257
5403
|
}));
|
|
5258
5404
|
}
|
|
@@ -5336,7 +5482,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5336
5482
|
if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
|
|
5337
5483
|
const shouldRequireExplicitEntry = !options.cssPipelineContext.currentGeneratorBranch.isWeb && options.opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
|
|
5338
5484
|
const generationEntries = entries.filter((entry) => hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitEntry || explicitFileKeys.has(normalizeEntryFile(entry.file))));
|
|
5339
|
-
const matchedOutputEntries = generationEntries.filter((entry) => normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
|
|
5485
|
+
const matchedOutputEntries = generationEntries.filter((entry) => normalizeOutputPathKey(resolveEntryOutputFile(entry.file).replace(/[?#].*$/, "")) === normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")) || (originalFileNames?.length ?? 0) === 0 && normalizeOutputPathKey(options.rootImportShellTargets?.get(resolveEntryOutputFile(entry.file)) ?? "") === normalizeOutputPathKey(outputFile.replace(/[?#].*$/, "")));
|
|
5340
5486
|
if (matchedOutputEntries.length === 1) return matchedOutputEntries[0];
|
|
5341
5487
|
if (!shouldSelectRootOutput(outputFile)) return;
|
|
5342
5488
|
if (generationEntries.length <= 1) return generationEntries[0];
|
|
@@ -5400,7 +5546,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5400
5546
|
}
|
|
5401
5547
|
//#endregion
|
|
5402
5548
|
//#region src/bundlers/vite/generate-bundle/runtime-linked-css.ts
|
|
5403
|
-
const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan)$/i;
|
|
5549
|
+
const MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE = /\.(?:wxml|axml|jxml|ksml|ttml|qml|qxml|tyml|xhsml|swan)$/i;
|
|
5404
5550
|
const JS_STYLE_IMPORT_RE = /\b(?:import|require)\s*(?:\(\s*)?["']([^"']+\.(?:css|less|sass|scss|styl|stylus|pcss|postcss))(?:[?#][^"']*)?["']/g;
|
|
5405
5551
|
function addSiblingCssFile(files, file, extensionByStem, fallbackExtension) {
|
|
5406
5552
|
const templateMatch = file.replace(/[?#].*$/, "").match(MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE);
|
|
@@ -5881,7 +6027,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5881
6027
|
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
5882
6028
|
const defaultStyleOutputExtension = resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
|
|
5883
6029
|
const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
|
|
5884
|
-
return isWebGeneratorTarget ? source : normalizeMiniProgramGeneratorCssSource(source, outputFile);
|
|
6030
|
+
return isWebGeneratorTarget ? source : normalizeMiniProgramGeneratorCssSource(source, outputFile, [...Object.keys(bundle), ...lastCssResultByFile.keys()]);
|
|
5885
6031
|
};
|
|
5886
6032
|
await runtimeState.readyPromise;
|
|
5887
6033
|
debug("start");
|
|
@@ -5941,6 +6087,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5941
6087
|
currentSubpackageRoots,
|
|
5942
6088
|
defaultStyleOutputExtension,
|
|
5943
6089
|
entries: configuredTailwindV4CssSourceEntriesForScope,
|
|
6090
|
+
rootImportShellTargets: frameworkRootImportShellTargetByFile,
|
|
5944
6091
|
explicitCssEntryFiles: configuredTailwindV4ExplicitCssEntryFiles,
|
|
5945
6092
|
isWebGeneratorTarget,
|
|
5946
6093
|
opts,
|
|
@@ -6505,6 +6652,55 @@ function createGenerateBundleHook(context) {
|
|
|
6505
6652
|
};
|
|
6506
6653
|
}
|
|
6507
6654
|
//#endregion
|
|
6655
|
+
//#region src/bundlers/vite/generate-bundle/entry-style-graph.ts
|
|
6656
|
+
function linkEntryChunkStyles(bundle, options) {
|
|
6657
|
+
const assets = new Map(Object.entries(bundle).flatMap(([key, output]) => output.type === "asset" ? [[normalizeOutputPathKey(output.fileName || key), output]] : []));
|
|
6658
|
+
const imports = /* @__PURE__ */ new Map();
|
|
6659
|
+
for (const [file, asset] of assets) {
|
|
6660
|
+
if (!options.matchesCss(file)) continue;
|
|
6661
|
+
const targets = /* @__PURE__ */ new Set();
|
|
6662
|
+
postcss.parse(asset.source.toString()).walkAtRules("import", (rule) => {
|
|
6663
|
+
const request = parseCssImportSpecifier(rule.params)?.specifier;
|
|
6664
|
+
if (request && !/^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i.test(request)) {
|
|
6665
|
+
const target = path.posix.normalize(path.posix.join(path.posix.dirname(file), request));
|
|
6666
|
+
if (assets.has(target)) targets.add(target);
|
|
6667
|
+
}
|
|
6668
|
+
});
|
|
6669
|
+
imports.set(file, targets);
|
|
6670
|
+
}
|
|
6671
|
+
const reaches = (from, target, visited = /* @__PURE__ */ new Set()) => {
|
|
6672
|
+
if (from === target) return true;
|
|
6673
|
+
if (visited.has(from)) return false;
|
|
6674
|
+
visited.add(from);
|
|
6675
|
+
return [...imports.get(from) ?? []].some((next) => reaches(next, target, visited));
|
|
6676
|
+
};
|
|
6677
|
+
for (const chunk of Object.values(bundle)) {
|
|
6678
|
+
if (chunk.type !== "chunk" || !chunk.isEntry) continue;
|
|
6679
|
+
const entry = path.posix.parse(normalizeOutputPathKey(chunk.fileName));
|
|
6680
|
+
const roots = [...assets].filter(([file]) => {
|
|
6681
|
+
const style = path.posix.parse(file);
|
|
6682
|
+
return options.matchesCss(file) && style.dir === entry.dir && style.name === entry.name;
|
|
6683
|
+
});
|
|
6684
|
+
if (roots.length !== 1) continue;
|
|
6685
|
+
const [file, asset] = roots[0];
|
|
6686
|
+
const original = asset.source.toString();
|
|
6687
|
+
const requests = [];
|
|
6688
|
+
for (const id of Object.keys(chunk.modules ?? {})) {
|
|
6689
|
+
const output = options.resolveOutputFile(id);
|
|
6690
|
+
const target = output && normalizeOutputPathKey(output);
|
|
6691
|
+
if (!target || !imports.has(target) || reaches(file, target) || reaches(target, file)) continue;
|
|
6692
|
+
imports.get(file).add(target);
|
|
6693
|
+
const relative = path.posix.relative(path.posix.dirname(file), target);
|
|
6694
|
+
requests.push(`@import ${quoteCssImportSpecifier(relative.startsWith(".") ? relative : `./${relative}`)};\n`);
|
|
6695
|
+
}
|
|
6696
|
+
if (requests.length > 0) {
|
|
6697
|
+
const next = requests.join("") + original;
|
|
6698
|
+
asset.source = next;
|
|
6699
|
+
options.onUpdate?.(file, original, next);
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6702
|
+
}
|
|
6703
|
+
//#endregion
|
|
6508
6704
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6509
6705
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6510
6706
|
return {
|
|
@@ -6591,6 +6787,17 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6591
6787
|
finalCssAssetFiles.add(file);
|
|
6592
6788
|
opts.onUpdate(file, original, generated);
|
|
6593
6789
|
};
|
|
6790
|
+
const linkEntryStyles = () => {
|
|
6791
|
+
if (isWebGeneratorTarget) return;
|
|
6792
|
+
linkEntryChunkStyles(bundle, {
|
|
6793
|
+
matchesCss: opts.cssMatcher,
|
|
6794
|
+
onUpdate: trackFinalCssAssetUpdate,
|
|
6795
|
+
resolveOutputFile: (id) => {
|
|
6796
|
+
if (!opts.cssMatcher(id) || id.includes("?")) return;
|
|
6797
|
+
return resolveViteCssPipelineOutputFile(id, opts, rootDir, false, false, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle));
|
|
6798
|
+
}
|
|
6799
|
+
});
|
|
6800
|
+
};
|
|
6594
6801
|
restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
|
|
6595
6802
|
debug,
|
|
6596
6803
|
isWebGeneratorTarget,
|
|
@@ -6697,6 +6904,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6697
6904
|
await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
|
|
6698
6905
|
collectViteProcessedCssAssets();
|
|
6699
6906
|
injectViteProcessedCssIntoMainCss();
|
|
6907
|
+
linkEntryStyles();
|
|
6700
6908
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6701
6909
|
cssMatcher: opts.cssMatcher,
|
|
6702
6910
|
debug,
|
|
@@ -6821,6 +7029,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6821
7029
|
await injectHarmonyBundleStyles();
|
|
6822
7030
|
collectViteProcessedCssAssets();
|
|
6823
7031
|
injectViteProcessedCssIntoMainCss();
|
|
7032
|
+
linkEntryStyles();
|
|
6824
7033
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6825
7034
|
cssMatcher: opts.cssMatcher,
|
|
6826
7035
|
debug,
|
|
@@ -6859,7 +7068,7 @@ function createViteServeJsTransformPlugin(options) {
|
|
|
6859
7068
|
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
6860
7069
|
const handlerOptions = options.createHandlerOptions(id);
|
|
6861
7070
|
if (shouldSkipJsTransform(code, handlerOptions)) return;
|
|
6862
|
-
const runtime = await options.transformRuntime();
|
|
7071
|
+
const runtime = await options.transformRuntime(id, code);
|
|
6863
7072
|
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
6864
7073
|
if (transformed === code) return;
|
|
6865
7074
|
return {
|
|
@@ -6997,9 +7206,9 @@ function createConfiguredCssEntryDiagnostics(options) {
|
|
|
6997
7206
|
//#endregion
|
|
6998
7207
|
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
6999
7208
|
function createFrameworkModuleCandidateRegistrar(options) {
|
|
7000
|
-
return async (id, source) => {
|
|
7209
|
+
return async (id, source, extension) => {
|
|
7001
7210
|
await options.runtimeState.readyPromise;
|
|
7002
|
-
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
|
|
7211
|
+
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source, extension);
|
|
7003
7212
|
options.invalidateRecordedGeneratorCandidates();
|
|
7004
7213
|
options.cacheCurrent();
|
|
7005
7214
|
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
@@ -7738,7 +7947,7 @@ ${previousTracedCss}`;
|
|
|
7738
7947
|
previousCss: previousGeneratorCss,
|
|
7739
7948
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
7740
7949
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
7741
|
-
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7950
|
+
deferCssAdaptation: resolvedConfig?.command === "build" && !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7742
7951
|
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
7743
7952
|
cssStage: hookContext?.cssStage,
|
|
7744
7953
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
@@ -7931,6 +8140,8 @@ ${tracedCss}`;
|
|
|
7931
8140
|
await sourceScanSession.sync();
|
|
7932
8141
|
};
|
|
7933
8142
|
const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
|
|
8143
|
+
cssPreflight: opts.cssPreflight,
|
|
8144
|
+
cssPreflightRange: opts.cssPreflightRange,
|
|
7934
8145
|
customAttributesEntities,
|
|
7935
8146
|
disabledDefaultTemplateHandler,
|
|
7936
8147
|
ensureRuntimeClassSet,
|
|
@@ -8035,7 +8246,7 @@ ${tracedCss}`;
|
|
|
8035
8246
|
getCommand: () => resolvedConfig?.command,
|
|
8036
8247
|
jsHandler,
|
|
8037
8248
|
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
8038
|
-
transformRuntime:
|
|
8249
|
+
transformRuntime: (id, code) => registerModuleGraphCandidates(id, code, "js")
|
|
8039
8250
|
}) : void 0;
|
|
8040
8251
|
const plugins = [
|
|
8041
8252
|
...sourceAndRewritePlugins,
|
|
@@ -8084,7 +8295,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8084
8295
|
try {
|
|
8085
8296
|
return await hook.apply(this, args);
|
|
8086
8297
|
} finally {
|
|
8087
|
-
dispose();
|
|
8298
|
+
dispose.call(this);
|
|
8088
8299
|
}
|
|
8089
8300
|
};
|
|
8090
8301
|
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
|
|
@@ -8093,7 +8304,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8093
8304
|
try {
|
|
8094
8305
|
return await hook.handler.apply(this, args);
|
|
8095
8306
|
} finally {
|
|
8096
|
-
dispose();
|
|
8307
|
+
dispose.call(this);
|
|
8097
8308
|
}
|
|
8098
8309
|
}
|
|
8099
8310
|
};
|
|
@@ -8117,7 +8328,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8117
8328
|
})
|
|
8118
8329
|
}));
|
|
8119
8330
|
const cleanupPlugin = wrappedPlugins.at(-1);
|
|
8120
|
-
if (cleanupPlugin)
|
|
8331
|
+
if (cleanupPlugin) {
|
|
8332
|
+
cleanupPlugin.closeBundle = wrapPluginCloseBundle(cleanupPlugin.closeBundle, function() {
|
|
8333
|
+
if (!this.meta?.watchMode) relationOwner.dispose();
|
|
8334
|
+
});
|
|
8335
|
+
cleanupPlugin.closeWatcher = wrapPluginCloseBundle(cleanupPlugin.closeWatcher, relationOwner.dispose);
|
|
8336
|
+
}
|
|
8121
8337
|
return wrappedPlugins;
|
|
8122
8338
|
}
|
|
8123
8339
|
//#endregion
|
|
@@ -8156,11 +8372,13 @@ function createTaroAlipayBrowserslistAssetPlugin() {
|
|
|
8156
8372
|
};
|
|
8157
8373
|
}
|
|
8158
8374
|
function createTaroVitePlugins(options = {}) {
|
|
8159
|
-
|
|
8375
|
+
const plugins = createViteFrameworkPlugins(options, {
|
|
8160
8376
|
frameworkName: "taro",
|
|
8161
8377
|
cssPipelineStrategy: taroCssPipelineStrategy,
|
|
8162
8378
|
styleInjectorDelegate: viteStyleInjectorDelegates.taro
|
|
8163
|
-
})
|
|
8379
|
+
});
|
|
8380
|
+
if (!plugins) return;
|
|
8381
|
+
return [createTaroAlipayBrowserslistAssetPlugin(), ...plugins];
|
|
8164
8382
|
}
|
|
8165
8383
|
//#endregion
|
|
8166
8384
|
//#region src/bundlers/vite/frameworks/uni-app/index.ts
|
|
@@ -8355,7 +8573,8 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8355
8573
|
},
|
|
8356
8574
|
transformGeneratedCss(css, context) {
|
|
8357
8575
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8358
|
-
|
|
8576
|
+
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
8577
|
+
return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
|
|
8359
8578
|
}
|
|
8360
8579
|
};
|
|
8361
8580
|
function createUniAppXVitePlugins(options = {}) {
|
|
@@ -8369,6 +8588,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
8369
8588
|
sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
|
|
8370
8589
|
createExtraPlugins: (context) => createUniAppXPlugins({
|
|
8371
8590
|
appType: "uni-app-x",
|
|
8591
|
+
cssPreflight: context.cssPreflight,
|
|
8592
|
+
cssPreflightRange: context.cssPreflightRange,
|
|
8372
8593
|
customAttributesEntities: context.customAttributesEntities,
|
|
8373
8594
|
disabledDefaultTemplateHandler: context.disabledDefaultTemplateHandler,
|
|
8374
8595
|
ensureRuntimeClassSet: context.ensureRuntimeClassSet,
|
|
@@ -8647,4 +8868,4 @@ function WeappTailwindcss(options = {}) {
|
|
|
8647
8868
|
return createDispatcher(options);
|
|
8648
8869
|
}
|
|
8649
8870
|
//#endregion
|
|
8650
|
-
export { shouldEnableComponentLocalStyle as n,
|
|
8871
|
+
export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, isUniAppXStyleSourceEmpty as o, shouldInjectBorderPreflight as r, WeappTailwindcss as t };
|