weapp-tailwindcss 5.5.1 → 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/dist/bundlers/shared/css-imports.d.ts +1 -0
- 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-D2ZJc3uA.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/{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-C9ENAx3f.cjs → gulp-C1r36Y_f.cjs} +5 -5
- package/dist/{gulp-DXeQfvVC.js → gulp-qGXKwQMZ.js} +4 -4
- 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-Cz4IesEM.cjs → hmr-timing-DuIbach8.cjs} +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CSGnR5gh.cjs → pipeline-helpers-CUwwOFt3.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 +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-TVjEaOeP.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-CfOzh007.js → transform-BNtyKkZi.js} +14 -14
- package/dist/{transform-DUPOPZ54.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 +14 -4
- package/dist/{v4-generation-core-CRNUU_Rr.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-BXe-axax.js → vite-C_JJxZWl.js} +271 -66
- package/dist/{vite-D_mAIfTU.cjs → vite-bJZi1V-l.cjs} +287 -63
- 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-B2Ea9K4B.cjs → web-B4wa3xrE.cjs} +9 -8
- package/dist/{web-Cv7ualrU.js → web-BiubXhxs.js} +7 -6
- package/dist/{webpack-7Um2GFtx.js → webpack-BDOQUv3J.js} +38 -23
- package/dist/{webpack-Ce04-btG.cjs → webpack-CsBe1G_1.cjs} +37 -23
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -4
|
@@ -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-
|
|
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
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-
|
|
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-
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -4559,9 +4647,48 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
4559
4647
|
//#endregion
|
|
4560
4648
|
//#region src/uni-app-x/vite/style-source.ts
|
|
4561
4649
|
const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
|
|
4562
|
-
function
|
|
4563
|
-
|
|
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) {
|
|
4564
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 };
|
|
4565
4692
|
const styleBlocks = extractSfcStyleBlocks(code);
|
|
4566
4693
|
if (styleBlocks.length === 0) return { code };
|
|
4567
4694
|
const style = styleBlocks[query.index ?? 0];
|
|
@@ -4646,7 +4773,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4646
4773
|
//#region src/uni-app-x/vite.ts
|
|
4647
4774
|
let transformUVuePromise;
|
|
4648
4775
|
function loadTransformUVue() {
|
|
4649
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
4776
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-BNtyKkZi.js").then((mod) => mod.transformUVue));
|
|
4650
4777
|
return transformUVuePromise;
|
|
4651
4778
|
}
|
|
4652
4779
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -4658,7 +4785,7 @@ function createUniAppXPlugins(options) {
|
|
|
4658
4785
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
4659
4786
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
4660
4787
|
const nativeLocalStyleModuleIds = /* @__PURE__ */ new Set();
|
|
4661
|
-
const
|
|
4788
|
+
const sfcStyleSources = createUniAppXSfcStyleSources();
|
|
4662
4789
|
const pendingSfcTransforms = /* @__PURE__ */ new Map();
|
|
4663
4790
|
const webLocalStyle = createUniAppXWebLocalStyleBridge(isWebGeneratorTarget, hmrCssModuleVersions);
|
|
4664
4791
|
let componentLocalStyleEnabled;
|
|
@@ -4777,14 +4904,8 @@ function createUniAppXPlugins(options) {
|
|
|
4777
4904
|
async handler(id) {
|
|
4778
4905
|
const { filename, query } = parseVueRequest(id);
|
|
4779
4906
|
if (!query.vue || query.type !== "style" || !UVUE_NVUE_RE.test(filename)) return;
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
if (!style) return;
|
|
4783
|
-
const normalized = normalizeUniAppXImportantApplyForSass(style.source);
|
|
4784
|
-
return normalized === style.source ? void 0 : {
|
|
4785
|
-
code: normalized,
|
|
4786
|
-
map: null
|
|
4787
|
-
};
|
|
4907
|
+
await pendingSfcTransforms.get(cleanUrl$1(filename));
|
|
4908
|
+
return sfcStyleSources.load(filename, query.index ?? 0);
|
|
4788
4909
|
}
|
|
4789
4910
|
},
|
|
4790
4911
|
async transform(code, id) {
|
|
@@ -4792,9 +4913,9 @@ function createUniAppXPlugins(options) {
|
|
|
4792
4913
|
await runtimeState.readyPromise;
|
|
4793
4914
|
const { filename, query } = parseVueRequest(id);
|
|
4794
4915
|
if (query.vue && query.type === "style") await pendingSfcTransforms.get(cleanUrl$1(filename));
|
|
4795
|
-
const resolvedSource = resolveUniAppXStyleSource(code, query);
|
|
4916
|
+
const resolvedSource = resolveUniAppXStyleSource(code, query, sfcStyleSources.getGenerated(filename, query.index ?? 0));
|
|
4796
4917
|
if (resolvedSource.skip) return;
|
|
4797
|
-
const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4918
|
+
const styleCode = query.vue && query.type === "style" && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4798
4919
|
const preprocessorCode = query.vue && query.type === "style" ? normalizeUniAppXImportantApplyForSass(styleCode) : styleCode;
|
|
4799
4920
|
const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
|
|
4800
4921
|
isIosPlatform,
|
|
@@ -4808,7 +4929,7 @@ function createUniAppXPlugins(options) {
|
|
|
4808
4929
|
}
|
|
4809
4930
|
}];
|
|
4810
4931
|
async function transformSfc(code, id, context) {
|
|
4811
|
-
|
|
4932
|
+
sfcStyleSources.rememberSource(id, code);
|
|
4812
4933
|
if (isWebGeneratorTarget()) for (const style of extractSfcStyleBlocks(code)) webCssEntryDiagnostics?.observeSourceImports(style.source, id);
|
|
4813
4934
|
if (isNativeAppBuildTarget(id)) {
|
|
4814
4935
|
nativeLocalStyleModuleIds.add(id);
|
|
@@ -4831,6 +4952,7 @@ function createUniAppXPlugins(options) {
|
|
|
4831
4952
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
4832
4953
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
4833
4954
|
native: true,
|
|
4955
|
+
...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
|
|
4834
4956
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
4835
4957
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
4836
4958
|
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => {
|
|
@@ -4839,6 +4961,7 @@ function createUniAppXPlugins(options) {
|
|
|
4839
4961
|
} } : {}
|
|
4840
4962
|
});
|
|
4841
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 ?? "" : "");
|
|
4842
4965
|
if (!result?.code) return result;
|
|
4843
4966
|
harmonyApply.rememberSource(result.code, id);
|
|
4844
4967
|
const expandedCode = await harmonyApply.expandStyles(result.code, id, context);
|
|
@@ -4867,7 +4990,8 @@ function createUniAppXPlugins(options) {
|
|
|
4867
4990
|
order: "pre",
|
|
4868
4991
|
async handler(code, id) {
|
|
4869
4992
|
if (!isEnabled()) return;
|
|
4870
|
-
|
|
4993
|
+
const { query } = parseVueRequest(id);
|
|
4994
|
+
if (!UVUE_NVUE_QUERY_RE.test(id) || query.vue && query.type === "style") return;
|
|
4871
4995
|
return runTransformSfc(code, id, this);
|
|
4872
4996
|
}
|
|
4873
4997
|
},
|
|
@@ -4877,6 +5001,7 @@ function createUniAppXPlugins(options) {
|
|
|
4877
5001
|
if (!isEnabled() || getResolvedConfig()?.command !== "serve") return;
|
|
4878
5002
|
if (!UVUE_NVUE_RE.test(ctx.file) && !isCSSRequest(ctx.file)) return;
|
|
4879
5003
|
if (isWebGeneratorTarget() && UVUE_NVUE_RE.test(ctx.file) && typeof ctx.read === "function") {
|
|
5004
|
+
hmrCssModuleVersions?.clear();
|
|
4880
5005
|
const source = await ctx.read();
|
|
4881
5006
|
if (hasUniAppXImportantApply(source, normalizeUniAppXImportantApplyForSass)) {
|
|
4882
5007
|
ctx.server.ws.send({
|
|
@@ -5146,8 +5271,13 @@ async function processRememberedCssReplay(options) {
|
|
|
5146
5271
|
const rememberedKeys = replayableRememberedGroup.map((item) => item.key);
|
|
5147
5272
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
5148
5273
|
if (!rememberedCssSource) continue;
|
|
5149
|
-
const {
|
|
5150
|
-
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()]);
|
|
5151
5281
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5152
5282
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
5153
5283
|
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
@@ -5228,7 +5358,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5228
5358
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5229
5359
|
metrics.css.elapsed += measureElapsed(start);
|
|
5230
5360
|
metrics.css.transformed++;
|
|
5231
|
-
onUpdate(outputFile, rawSource, css);
|
|
5361
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5232
5362
|
debug("css replay preserve local import shell: %s", outputFile);
|
|
5233
5363
|
}));
|
|
5234
5364
|
continue;
|
|
@@ -5268,7 +5398,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5268
5398
|
if (shouldEmitRememberedReplayCssAsset) emitRememberedCssAsset(css);
|
|
5269
5399
|
metrics.css.elapsed += measureElapsed(start);
|
|
5270
5400
|
metrics.css.transformed++;
|
|
5271
|
-
onUpdate(outputFile, rawSource, css);
|
|
5401
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, css);
|
|
5272
5402
|
debug("css replay handle: %s", outputFile);
|
|
5273
5403
|
}));
|
|
5274
5404
|
}
|
|
@@ -5352,7 +5482,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5352
5482
|
if (matchedOriginalEntry && outputFile.replace(/[?#].*$/, "").endsWith(".css")) return matchedOriginalEntry;
|
|
5353
5483
|
const shouldRequireExplicitEntry = !options.cssPipelineContext.currentGeneratorBranch.isWeb && options.opts.cssMatcher(outputFile) && isRootStyleOutputFile(outputFile);
|
|
5354
5484
|
const generationEntries = entries.filter((entry) => hasTailwindGenerationSource(entry.source) && (!shouldRequireExplicitEntry || explicitFileKeys.has(normalizeEntryFile(entry.file))));
|
|
5355
|
-
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(/[?#].*$/, "")));
|
|
5356
5486
|
if (matchedOutputEntries.length === 1) return matchedOutputEntries[0];
|
|
5357
5487
|
if (!shouldSelectRootOutput(outputFile)) return;
|
|
5358
5488
|
if (generationEntries.length <= 1) return generationEntries[0];
|
|
@@ -5416,7 +5546,7 @@ function createConfiguredCssRootResolvers(options) {
|
|
|
5416
5546
|
}
|
|
5417
5547
|
//#endregion
|
|
5418
5548
|
//#region src/bundlers/vite/generate-bundle/runtime-linked-css.ts
|
|
5419
|
-
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;
|
|
5420
5550
|
const JS_STYLE_IMPORT_RE = /\b(?:import|require)\s*(?:\(\s*)?["']([^"']+\.(?:css|less|sass|scss|styl|stylus|pcss|postcss))(?:[?#][^"']*)?["']/g;
|
|
5421
5551
|
function addSiblingCssFile(files, file, extensionByStem, fallbackExtension) {
|
|
5422
5552
|
const templateMatch = file.replace(/[?#].*$/, "").match(MINI_PROGRAM_TEMPLATE_OUTPUT_EXT_RE);
|
|
@@ -5897,7 +6027,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5897
6027
|
const outDir = resolvedConfig?.build?.outDir ? path.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
5898
6028
|
const defaultStyleOutputExtension = resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
|
|
5899
6029
|
const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
|
|
5900
|
-
return isWebGeneratorTarget ? source : normalizeMiniProgramGeneratorCssSource(source, outputFile);
|
|
6030
|
+
return isWebGeneratorTarget ? source : normalizeMiniProgramGeneratorCssSource(source, outputFile, [...Object.keys(bundle), ...lastCssResultByFile.keys()]);
|
|
5901
6031
|
};
|
|
5902
6032
|
await runtimeState.readyPromise;
|
|
5903
6033
|
debug("start");
|
|
@@ -5957,6 +6087,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
5957
6087
|
currentSubpackageRoots,
|
|
5958
6088
|
defaultStyleOutputExtension,
|
|
5959
6089
|
entries: configuredTailwindV4CssSourceEntriesForScope,
|
|
6090
|
+
rootImportShellTargets: frameworkRootImportShellTargetByFile,
|
|
5960
6091
|
explicitCssEntryFiles: configuredTailwindV4ExplicitCssEntryFiles,
|
|
5961
6092
|
isWebGeneratorTarget,
|
|
5962
6093
|
opts,
|
|
@@ -6521,6 +6652,55 @@ function createGenerateBundleHook(context) {
|
|
|
6521
6652
|
};
|
|
6522
6653
|
}
|
|
6523
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
|
|
6524
6704
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6525
6705
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6526
6706
|
return {
|
|
@@ -6607,6 +6787,17 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6607
6787
|
finalCssAssetFiles.add(file);
|
|
6608
6788
|
opts.onUpdate(file, original, generated);
|
|
6609
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
|
+
};
|
|
6610
6801
|
restoreFrameworkRootMiniProgramImportShellAssets(bundle, {
|
|
6611
6802
|
debug,
|
|
6612
6803
|
isWebGeneratorTarget,
|
|
@@ -6713,6 +6904,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6713
6904
|
await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
|
|
6714
6905
|
collectViteProcessedCssAssets();
|
|
6715
6906
|
injectViteProcessedCssIntoMainCss();
|
|
6907
|
+
linkEntryStyles();
|
|
6716
6908
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6717
6909
|
cssMatcher: opts.cssMatcher,
|
|
6718
6910
|
debug,
|
|
@@ -6837,6 +7029,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6837
7029
|
await injectHarmonyBundleStyles();
|
|
6838
7030
|
collectViteProcessedCssAssets();
|
|
6839
7031
|
injectViteProcessedCssIntoMainCss();
|
|
7032
|
+
linkEntryStyles();
|
|
6840
7033
|
normalizeRootMiniProgramImportShellAssets(bundle, {
|
|
6841
7034
|
cssMatcher: opts.cssMatcher,
|
|
6842
7035
|
debug,
|
|
@@ -6875,7 +7068,7 @@ function createViteServeJsTransformPlugin(options) {
|
|
|
6875
7068
|
if (!options.shouldTransform() || !isViteServeJsRequest(id, options.getCommand())) return;
|
|
6876
7069
|
const handlerOptions = options.createHandlerOptions(id);
|
|
6877
7070
|
if (shouldSkipJsTransform(code, handlerOptions)) return;
|
|
6878
|
-
const runtime = await options.transformRuntime();
|
|
7071
|
+
const runtime = await options.transformRuntime(id, code);
|
|
6879
7072
|
const { code: transformed } = await options.jsHandler(code, runtime, handlerOptions);
|
|
6880
7073
|
if (transformed === code) return;
|
|
6881
7074
|
return {
|
|
@@ -7013,9 +7206,9 @@ function createConfiguredCssEntryDiagnostics(options) {
|
|
|
7013
7206
|
//#endregion
|
|
7014
7207
|
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
7015
7208
|
function createFrameworkModuleCandidateRegistrar(options) {
|
|
7016
|
-
return async (id, source) => {
|
|
7209
|
+
return async (id, source, extension) => {
|
|
7017
7210
|
await options.runtimeState.readyPromise;
|
|
7018
|
-
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
|
|
7211
|
+
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source, extension);
|
|
7019
7212
|
options.invalidateRecordedGeneratorCandidates();
|
|
7020
7213
|
options.cacheCurrent();
|
|
7021
7214
|
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
@@ -7754,7 +7947,7 @@ ${previousTracedCss}`;
|
|
|
7754
7947
|
previousCss: previousGeneratorCss,
|
|
7755
7948
|
previousClassSet: pendingHmrChange && !forceFullHmrCssRegeneration ? generatedClassSetByFile.get(fileKey) : void 0,
|
|
7756
7949
|
deferEmptyScopedCssSource: shouldDeferEmptyScopedCssSource,
|
|
7757
|
-
deferCssAdaptation: !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7950
|
+
deferCssAdaptation: resolvedConfig?.command === "build" && !transient && !currentGeneratorBranch.isWeb && !shouldAdaptFrameworkWatchCss(),
|
|
7758
7951
|
disableSourceScan: hookContext?.disableSourceScan === true,
|
|
7759
7952
|
cssStage: hookContext?.cssStage,
|
|
7760
7953
|
restoreLocalCssImports: !currentGeneratorBranch.isWeb
|
|
@@ -7947,6 +8140,8 @@ ${tracedCss}`;
|
|
|
7947
8140
|
await sourceScanSession.sync();
|
|
7948
8141
|
};
|
|
7949
8142
|
const extraPlugins = capability.frameworkExtras ? frameworkBranch.createExtraPlugins?.({
|
|
8143
|
+
cssPreflight: opts.cssPreflight,
|
|
8144
|
+
cssPreflightRange: opts.cssPreflightRange,
|
|
7950
8145
|
customAttributesEntities,
|
|
7951
8146
|
disabledDefaultTemplateHandler,
|
|
7952
8147
|
ensureRuntimeClassSet,
|
|
@@ -8051,7 +8246,7 @@ ${tracedCss}`;
|
|
|
8051
8246
|
getCommand: () => resolvedConfig?.command,
|
|
8052
8247
|
jsHandler,
|
|
8053
8248
|
shouldTransform: () => shouldOwnTailwindGeneration && (frameworkCssPipelineStrategy?.shouldTransformServeJs?.(createCssPipelineContext()) ?? !resolveCurrentGeneratorBranch().isWeb),
|
|
8054
|
-
transformRuntime:
|
|
8249
|
+
transformRuntime: (id, code) => registerModuleGraphCandidates(id, code, "js")
|
|
8055
8250
|
}) : void 0;
|
|
8056
8251
|
const plugins = [
|
|
8057
8252
|
...sourceAndRewritePlugins,
|
|
@@ -8100,7 +8295,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8100
8295
|
try {
|
|
8101
8296
|
return await hook.apply(this, args);
|
|
8102
8297
|
} finally {
|
|
8103
|
-
dispose();
|
|
8298
|
+
dispose.call(this);
|
|
8104
8299
|
}
|
|
8105
8300
|
};
|
|
8106
8301
|
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
|
|
@@ -8109,7 +8304,7 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8109
8304
|
try {
|
|
8110
8305
|
return await hook.handler.apply(this, args);
|
|
8111
8306
|
} finally {
|
|
8112
|
-
dispose();
|
|
8307
|
+
dispose.call(this);
|
|
8113
8308
|
}
|
|
8114
8309
|
}
|
|
8115
8310
|
};
|
|
@@ -8133,7 +8328,12 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8133
8328
|
})
|
|
8134
8329
|
}));
|
|
8135
8330
|
const cleanupPlugin = wrappedPlugins.at(-1);
|
|
8136
|
-
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
|
+
}
|
|
8137
8337
|
return wrappedPlugins;
|
|
8138
8338
|
}
|
|
8139
8339
|
//#endregion
|
|
@@ -8172,11 +8372,13 @@ function createTaroAlipayBrowserslistAssetPlugin() {
|
|
|
8172
8372
|
};
|
|
8173
8373
|
}
|
|
8174
8374
|
function createTaroVitePlugins(options = {}) {
|
|
8175
|
-
|
|
8375
|
+
const plugins = createViteFrameworkPlugins(options, {
|
|
8176
8376
|
frameworkName: "taro",
|
|
8177
8377
|
cssPipelineStrategy: taroCssPipelineStrategy,
|
|
8178
8378
|
styleInjectorDelegate: viteStyleInjectorDelegates.taro
|
|
8179
|
-
})
|
|
8379
|
+
});
|
|
8380
|
+
if (!plugins) return;
|
|
8381
|
+
return [createTaroAlipayBrowserslistAssetPlugin(), ...plugins];
|
|
8180
8382
|
}
|
|
8181
8383
|
//#endregion
|
|
8182
8384
|
//#region src/bundlers/vite/frameworks/uni-app/index.ts
|
|
@@ -8371,7 +8573,8 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8371
8573
|
},
|
|
8372
8574
|
transformGeneratedCss(css, context) {
|
|
8373
8575
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8374
|
-
|
|
8576
|
+
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
8577
|
+
return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
|
|
8375
8578
|
}
|
|
8376
8579
|
};
|
|
8377
8580
|
function createUniAppXVitePlugins(options = {}) {
|
|
@@ -8385,6 +8588,8 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
8385
8588
|
sourceCandidatesBeforeExtraPlugin: (plugin) => plugin.name === "weapp-tailwindcss:uni-app-x:nvue",
|
|
8386
8589
|
createExtraPlugins: (context) => createUniAppXPlugins({
|
|
8387
8590
|
appType: "uni-app-x",
|
|
8591
|
+
cssPreflight: context.cssPreflight,
|
|
8592
|
+
cssPreflightRange: context.cssPreflightRange,
|
|
8388
8593
|
customAttributesEntities: context.customAttributesEntities,
|
|
8389
8594
|
disabledDefaultTemplateHandler: context.disabledDefaultTemplateHandler,
|
|
8390
8595
|
ensureRuntimeClassSet: context.ensureRuntimeClassSet,
|
|
@@ -8663,4 +8868,4 @@ function WeappTailwindcss(options = {}) {
|
|
|
8663
8868
|
return createDispatcher(options);
|
|
8664
8869
|
}
|
|
8665
8870
|
//#endregion
|
|
8666
|
-
export { shouldEnableComponentLocalStyle as n,
|
|
8871
|
+
export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, isUniAppXStyleSourceEmpty as o, shouldInjectBorderPreflight as r, WeappTailwindcss as t };
|