weapp-tailwindcss 5.5.4 → 5.5.6

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.
Files changed (134) hide show
  1. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -4
  2. package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -2
  3. package/dist/bundlers/shared/framework-css-composition.d.ts +1 -0
  4. package/dist/bundlers/shared/framework-postcss.d.ts +2 -1
  5. package/dist/bundlers/shared/framework-user-css.d.ts +1 -0
  6. package/dist/bundlers/shared/generated-css-marker.d.ts +1 -0
  7. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +5 -7
  8. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +4 -1
  9. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -4
  10. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
  11. package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +4 -2
  12. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -1
  13. package/dist/bundlers/shared/generator-css/types.d.ts +6 -3
  14. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +4 -0
  16. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +3 -1
  17. package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -1
  18. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +3 -0
  19. package/dist/bundlers/shared/style-handler-options.d.ts +7 -0
  20. package/dist/bundlers/shared/v4-generation-core.d.ts +0 -1
  21. package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +3 -0
  22. package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +3 -0
  23. package/dist/bundlers/vite/css-handler-options.d.ts +1 -1
  24. package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -1
  25. package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
  26. package/dist/bundlers/vite/generate-bundle/finalize/sync-processed-css.d.ts +4 -0
  27. package/dist/bundlers/vite/generate-bundle/framework-style-memory.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +7 -0
  29. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -0
  30. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +1 -1
  31. package/dist/bundlers/vite/generate-bundle/runtime.d.ts +3 -1
  32. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +1 -1
  33. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +2 -2
  34. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  35. package/dist/bundlers/vite/generate-bundle/web-css-module.d.ts +1 -0
  36. package/dist/bundlers/vite/plugin-hook.d.ts +3 -0
  37. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +3 -1
  38. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -1
  39. package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -1
  40. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
  41. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +2 -1
  42. package/dist/bundlers/vite/shared/framework-runtime-configuration.d.ts +3 -0
  43. package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +9 -0
  44. package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +6 -5
  45. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +3 -3
  46. package/dist/bundlers/vite/shared/framework-strategy.d.ts +3 -1
  47. package/dist/bundlers/vite/shared/hmr-source.d.ts +2 -0
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  50. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
  51. package/dist/compiler/index.d.ts +2 -0
  52. package/dist/compiler/semantic-css.d.ts +1 -1
  53. package/dist/compiler/types.d.ts +1 -1
  54. package/dist/{compiler-DFROuh5Z.cjs → compiler-C8FqI-P3.cjs} +1060 -1163
  55. package/dist/{compiler-CJ5yX-on.js → compiler-D3GBwxoa.js} +32 -23
  56. package/dist/core/compiler/transforms.d.ts +1 -1
  57. package/dist/core.cjs +4 -4
  58. package/dist/core.js +4 -4
  59. package/dist/{css-imports-_5cwJnx-.cjs → css-imports-XvtI1zCY.cjs} +2 -3
  60. package/dist/css-macro.cjs +1 -1
  61. package/dist/css-macro.js +1 -1
  62. package/dist/{defaults-CKx-4LcW.js → defaults-AQuvJS-h.js} +4 -2
  63. package/dist/{defaults-CiGsr8Xq.cjs → defaults-CyX5iO9y.cjs} +4 -2
  64. package/dist/defaults.cjs +1 -1
  65. package/dist/defaults.js +1 -1
  66. package/dist/final-css-cleanup-CDTmVAye.cjs +1 -0
  67. package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-u_sI2p56.js} +1 -126
  68. package/dist/framework/index.d.ts +1 -1
  69. package/dist/framework/platform.d.ts +2 -2
  70. package/dist/{generator-RK2HtgOb.cjs → generator-Bvr4WmuF.cjs} +150 -150
  71. package/dist/{generator-BgbYHNgD.js → generator-C0BJjyLM.js} +131 -131
  72. package/dist/generator.cjs +1 -1
  73. package/dist/generator.js +1 -1
  74. package/dist/{gulp-BS7fTmyj.cjs → gulp-BExe5RBF.cjs} +8 -8
  75. package/dist/{gulp-nl-2p5Dw.js → gulp-BhkIIk7J.js} +5 -5
  76. package/dist/gulp.cjs +1 -1
  77. package/dist/gulp.js +1 -1
  78. package/dist/{hmr-timing-BfxWwMeT.js → hmr-timing-B9Yt86-U.js} +299 -404
  79. package/dist/{hmr-timing-D45cTIzM.cjs → hmr-timing-CoiJIqDu.cjs} +4 -4
  80. package/dist/index.cjs +4 -4
  81. package/dist/index.js +4 -4
  82. package/dist/js/NodePathWalker.d.ts +1 -1
  83. package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
  84. package/dist/js/node-path-walker/import-tokens.d.ts +1 -1
  85. package/dist/{pipeline-helpers-BEhISt4D.cjs → pipeline-helpers-BOjTEmMi.cjs} +6 -6
  86. package/dist/postcss.cjs +1 -1
  87. package/dist/postcss.js +1 -1
  88. package/dist/presets.cjs +2 -2
  89. package/dist/presets.js +2 -2
  90. package/dist/rspack.cjs +2 -2
  91. package/dist/rspack.js +2 -2
  92. package/dist/{scoped-generator-Dqq2iLky.js → scoped-generator-B6Y1bxzM.js} +46 -31
  93. package/dist/{scoped-generator-DccPwmJT.cjs → scoped-generator-BUBls_oM.cjs} +46 -31
  94. package/dist/{source-candidate-scan-signature-CnUlGWhP.cjs → source-candidate-scan-signature-BtJZp28T.cjs} +32 -3
  95. package/dist/{source-candidate-scan-signature-BJkQJtRM.js → source-candidate-scan-signature-DNuGKTqf.js} +21 -4
  96. package/dist/style-injector/internal.d.ts +118 -8
  97. package/dist/style-injector/options.d.ts +5 -1
  98. package/dist/tailwindcss/runtime-options.d.ts +5 -0
  99. package/dist/tailwindcss/v4/preflight.d.ts +0 -1
  100. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +1 -0
  101. package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +4 -0
  102. package/dist/{tailwindcss-o3Xe-o7M.js → tailwindcss-B_4E52WF.js} +7 -13
  103. package/dist/{tailwindcss-B03BGeTO.cjs → tailwindcss-CBYjzRmV.cjs} +4 -10
  104. package/dist/{transform-BVH7iLHn.js → transform-CkEnJYIP.js} +18 -12
  105. package/dist/{transform-MIhriZRr.cjs → transform-FkqbTBJR.cjs} +17 -11
  106. package/dist/types/index.d.ts +3 -2
  107. package/dist/uni-app-x/border-preflight.d.ts +1 -2
  108. package/dist/uni-app-x/component-local-style.d.ts +2 -1
  109. package/dist/uni-app-x/transform.d.ts +4 -2
  110. package/dist/uni-app-x/vite/author-apply.d.ts +3 -1
  111. package/dist/uni-app-x/vite/native-hmr.d.ts +1 -1
  112. package/dist/uni-app-x/vite/style-result.d.ts +5 -0
  113. package/dist/{v4-generation-core-BvW2aK23.cjs → v4-generation-core-Cz1D7wm1.cjs} +313 -418
  114. package/dist/vite/web.cjs +1 -1
  115. package/dist/vite/web.js +1 -1
  116. package/dist/{vite-4RznbXVI.cjs → vite-DxuKPZlp.cjs} +565 -592
  117. package/dist/{vite-hGECCqfq.js → vite-lP35OguX.js} +558 -578
  118. package/dist/vite-web.d.ts +1 -1
  119. package/dist/vite.cjs +1 -1
  120. package/dist/vite.js +1 -1
  121. package/dist/weapp-tw-css-generation-loader.cjs +2 -2
  122. package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
  123. package/dist/{web-0FAisq6H.js → web-Dfz_jpNj.js} +144 -107
  124. package/dist/{web-DQZ27KWH.cjs → web-DhDxhlkq.cjs} +156 -107
  125. package/dist/{webpack-8cQlXIo4.js → webpack-D6jp1o3m.js} +18 -17
  126. package/dist/{webpack-DOQ_3ViW.cjs → webpack-R2Sbggiy.cjs} +20 -20
  127. package/dist/webpack.cjs +1 -1
  128. package/dist/webpack.js +1 -1
  129. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
  130. package/dist/wxml/utils/custom-template.d.ts +1 -1
  131. package/package.json +9 -11
  132. package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
  133. package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
  134. package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
@@ -1,19 +1,19 @@
1
1
  import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
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-BgbYHNgD.js";
3
- import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-o3Xe-o7M.js";
2
+ import { $ as hasTailwindApplyDirective, Dt as isFileMatchedByTailwindSourceEntries, H as stripMiniProgramCssSpecificityPlaceholders, K as normalizeEmptyTailwindCustomVariants, Mt as resolveTailwindV4CssSourceBase, Rt as getTailwindV4IncrementalGenerateCacheStats, T as omitUndefined, X as splitUserCssLayerBlocks, Y as hasUserCssLayerBlocks, _ as upsertTailwindV4CssSource, a as resolveGeneratorRuntimeBranch, at as normalizeTailwindSourceForGenerator, b as isTailwindV4CssEntry, c as shouldUseNativeAppCssBranch, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, k as resolveTailwindcssOptions, l as resolveUniUtsPlatform, m as filterTailwindV4CssSourceRoots, nt as hasTailwindSourceDirectives, ot as parseImportRequest, pt as hasTailwindGeneratedCssMarkers, rt as normalizeTailwindConfigDirectives, s as shouldUseMiniProgramCssBranch, st as removeTailwindSourceDirectives, tt as hasTailwindRootDirectives, x as normalizeCssEntries, z as hasMiniProgramCssSpecificityPlaceholders, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-C0BJjyLM.js";
3
+ import { g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as resolveTailwindV4CssDependencies, p as discoverTailwindV4CssEntries, r as isUniAppXEnabled } from "./tailwindcss-B_4E52WF.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 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-BfxWwMeT.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-CJ5yX-on.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-Dqq2iLky.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-0FAisq6H.js";
10
- import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-BJkQJtRM.js";
5
+ import { A as annotateCssSourceTrace, B as finalizeCompilerShadowRun, C as isSourceStyleRequest, D as hasBundlerGeneratedCssMarker, E as createBundlerGeneratedCssMarker, L as isPureLocalCssImportWrapper, M as createCssTokenSourceMap, N as isCssSourceTraceEnabled, O as parseBundlerGeneratedCssMarkerBlocks, S as isSourcePreprocessorRequest, T as createBundlerGeneratedCssEndMarker, U as isSourceCandidateRequest, V as createSourceCandidateCollector, W as extractCandidatesFromSource, a as collectGeneratedRawSourceCandidatesFromCss, d as normalizeMiniProgramImportShell, f as scoreTailwindV4CssSourceFileMatch, h as mergeMarkedUserLayerComponentsCss, i as validateCandidatesByGenerator, j as createCssSourceTraceCacheSignature, k as stripBundlerGeneratedCssMarkers, l as runWithConcurrency, m as extractMarkedUserLayerComponentsCss, r as generateTailwindV4Css, t as createHmrTimingRecorder, u as normalizeMiniProgramGeneratorCssSource } from "./hmr-timing-B9Yt86-U.js";
6
+ import { E as normalizeFrameworkStylePlatform, 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-D3GBwxoa.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-u_sI2p56.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-B6Y1bxzM.js";
9
+ import { $ as resolveSourceStyleSourceFromOutputFile, A as finalizeWebCss, At as cleanUrl$1, B as sendSupplementalCssHotUpdates, Bt as isMiniProgramStyleOutputFile, C as tryFinalizeGenericWebCss, Ct as canProcessViteSourceStyleAsCss, D as finalizeWebCssCalc, Dt as resolveViteCssOutputFile, E as shouldSkipGenericWebProductionSourceCandidates, Et as resolveReplayCssOutputFile, F as mergeHotModulesByIdentity, Ft as resolveViteCssPipelineRequestFile, G as collectChunkModuleIds$3, Gt as withViteSourceOutputRelationOwner, H as parseVueRequest, Ht as createViteCssAssetIdentityResolver, I as resolveHotSourceModules, It as slash, J as hasTailwindGenerationSource, K as extractSfcStyleBlocks, Kt as createGenericWebViteCapabilityProfile, L as resolveHotSourceModulesByIds, Lt as createCssHandlerOptionsCache, M as registerGeneratorDependencies$1, Mt as isCSSRequest, N as shouldGenerateCssByGenerator, Nt as isHTMLRequest, O as collectViteProcessedCssSources, Ot as resolveViteCssPipelineOutputFile, P as hasSelfAcceptingNonStyleHotModule, Pt as normalizePath, Q as resolveSfcStyleSourceFromOutputFile, R as resolveHotTailwindCssModules, Rt as resolveViteCssHandlerExtraOptions, S as createViteWebCssFinalizerOutputPlugin, St as SOURCE_STYLE_OUTPUT_EXT_RE, T as createGenericWebProductionSourceCandidatesApply, Tt as resolveMiniProgramStyleOutputExtension, U as resolveViteWebCssCompatOptions, Ut as createViteSourceOutputRelationOwner, V as resolveViteModuleIdentity, Vt as isRootStyleOutputFile, W as shouldApplyViteWebCssCompat, Wt as getActiveViteSourceOutputRelationOwner, X as normalizeSfcSourceFileForCompare, Y as isSfcStyleSourceFile, Z as resolveSfcStyleRequestFromKnownSource, _ as normalizeVitePersistentCacheKey, _t as removeDuplicateUnlinkedRootCssAssetsReferencedByHtml, a as readViteHmrSource, at as collectMatchingGeneratedCssMarkerFiles, b as shouldCollectTransformedSourceCandidates, bt as posix, c as createViteHmrCssModuleVersionFilterPlugin, ct as dedupeViteCssResults, d as createFrameworkCssGenerationQueue, dt as isMatchingGeneratedCssMarkerFile, et as hasMatchingStyleFileBase, f as createViteCssGenerationPlugins, ft as isStyleImportRequest, g as isMissingInternalCssSource, gt as readAssetSource$2, h as hasVitePipelineTailwindGenerationDirective, ht as normalizeMarkerOutputFile, i as syncFrameworkSourceCandidatesForHotUpdate, it as collectImportedStyleFiles, j as inferPlatformFromViteOutDir$1, jt as formatPostcssSourceMap, k as createCssHandlerOptions, kt as resolveViteCssPipelineOutputFileFromSourceFile, l as createViteHmrCssModuleVersionTracker, lt as getAssetFile$1, m as createRewriteCssImportsPlugins, mt as normalizeInjectableCssForTargetWithImports, n as createFrameworkTailwindRootCss, nt as appendCss$1, o as createFrameworkProcessedCssRegistry, ot as collectRootStyleBundleCssSources, p as createViteRuntimeClassSet, pt as normalizeInjectableCssForTarget, q as hasSfcStyleSources, qt as frameworkViteCapabilityProfile, r as createFrameworkSourceScanSession, rt as clearAssetSource, s as createFrameworkPostPlugin, st as createCssAssetPipelineContext, t as createGenericWebVitePlugins, tt as isMatchingCssSourceFile, u as createViteHmrCandidateState, ut as hasNonCommentCss, v as summarizeStringCache, vt as removeTailwindEntryDirectivesFromCss, w as createGenericWebProductionBundleHooks, wt as normalizeCssSourceForCompare, x as touchMapEntry, xt as CSS_SOURCE_OUTPUT_EXT_RE, y as createViteCssMemory, yt as resolveViteProcessedCssAssetSource, z as sendFullReloadForUnresolvedHotUpdate, zt as isCssOutputFile } from "./web-Dfz_jpNj.js";
10
+ import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, r as normalizeOutputPathKey } from "./source-candidate-scan-signature-DNuGKTqf.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, createCssRuleMatcher, createInjectPreflight, filterExistingCssRules, isMiniProgramLocalCssImportRequest, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, parseTailwindCssDirectiveRequest, postcss, restoreUniAppXImportantApplyMarker, transformWebCssCompat, transformWebCssSafeSelectors, unwrapUnsupportedCascadeLayers } from "@weapp-tailwindcss/postcss";
16
+ import { UNI_APP_X_BORDER_PREFLIGHT_CLASS, collectCssApplyUtilities, compileCssMacroConditionalComments, containsCssAfterMinify, createCssRuleMatcher, createUniAppXBorderPreflight, cssToClassStyleValue, expandCssApplySourcesToStyleValue, filterExistingCssRules, hoistUniAppXBorderPreflight, isMiniProgramLocalCssImportRequest, isTailwindRuntimePropertyRule, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, normalizeTailwindcssV4InfinityCalcCss, normalizeUniAppXImportantApplyForSass, parseCssImportSpecifier, parseTailwindCssDirectiveRequest, parseUniAppXStyleSource, postcss, quoteCssImportSpecifier, removeUnusedMiniProgramContentInit, restoreUniAppXImportantApplyMarker, retainUniAppXAuthorApplyCss, 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,21 +21,8 @@ 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 scss from "postcss-scss";
25
24
  import { NodeTypes } from "@vue/compiler-dom";
26
25
  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
39
26
  //#region src/uni-app-x/style-asset/harmony-apply.ts
40
27
  const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
41
28
  function createGeneratedRuleMap(css) {
@@ -73,7 +60,9 @@ function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
73
60
  changed = true;
74
61
  });
75
62
  if (!changed) return block;
76
- if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) => rule.remove());
63
+ if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) => {
64
+ rule.remove();
65
+ });
77
66
  return `${open}${root.toString()}${close}`;
78
67
  });
79
68
  }
@@ -107,7 +96,6 @@ const STYLE_ENTRY_RE = /\[\s*("((?:\\.|[^"\\])+)")\s*,\s*(_pS\(_uM\(\[[\s\S]*?\]
107
96
  const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
108
97
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
109
98
  const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
110
- const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
111
99
  const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
112
100
  function cloneStyleEntry(entry) {
113
101
  return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
@@ -135,9 +123,6 @@ function normalizeStyleValue(prop, value) {
135
123
  if (typeof value === "number") return STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) ? String(value) : value;
136
124
  return normalizeValue(prop, value);
137
125
  }
138
- function unescapeCssClassSelector(className) {
139
- return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
140
- }
141
126
  function parseStyleExport(source) {
142
127
  const json = source.replace(STYLE_EXPORT_PREFIX_RE, "").trim();
143
128
  if (!json) return;
@@ -213,35 +198,8 @@ function createUtsStyleArrayFromAppStyles(code, appSource) {
213
198
  if (used.size === 0) return;
214
199
  return createUtsStyleArray([...used].map((className) => entries.get(className)).filter(Boolean));
215
200
  }
216
- function cssToStyleExport(source) {
217
- let root;
218
- try {
219
- root = postcss.parse(source);
220
- } catch {
221
- return;
222
- }
223
- const result = {};
224
- root.walkRules((rule) => {
225
- const selectors = rule.selectors ?? [];
226
- for (const selector of selectors) {
227
- const match = selector.trim().match(CLASS_SELECTOR_PREFIX_RE);
228
- if (!match?.[1]) continue;
229
- const declarations = {};
230
- rule.walkDecls((decl) => {
231
- declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
232
- });
233
- if (Object.keys(declarations).length > 0) {
234
- result[match[1]] = { "": declarations };
235
- const className = unescapeCssClassSelector(match[1]);
236
- result[className] = { "": declarations };
237
- result[replaceWxml(className)] = { "": declarations };
238
- }
239
- }
240
- });
241
- return Object.keys(result).length > 0 ? result : void 0;
242
- }
243
201
  function cssSourceToStyleValue(source) {
244
- return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : cssToStyleExport(source);
202
+ return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : cssToClassStyleValue(source);
245
203
  }
246
204
  function mergeStyleValues(...items) {
247
205
  const result = {};
@@ -257,32 +215,9 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
257
215
  for (const source of sources) {
258
216
  const styleSources = source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source];
259
217
  for (const styleSource of styleSources) {
260
- let root;
261
- try {
262
- root = parseUniAppXStyleSource(styleSource);
263
- } catch {
264
- continue;
265
- }
266
- root.walkRules((rule) => {
267
- const applyRules = rule.nodes?.filter((node) => node.type === "atrule" && node.name === "apply") ?? [];
268
- if (applyRules.length === 0) return;
269
- const selectors = rule.selectors ?? [rule.selector];
270
- for (const selector of selectors) {
271
- const className = selector.trim().match(CLASS_SELECTOR_PREFIX_RE)?.[1];
272
- if (!className) continue;
273
- const declarations = {};
274
- for (const applyRule of applyRules) for (const utility of splitCandidateTokens(applyRule.params)) {
275
- const utilityDeclarations = utilityStyles[utility]?.[""] ?? utilityStyles[replaceWxml(utility)]?.[""];
276
- if (utilityDeclarations) Object.assign(declarations, utilityDeclarations);
277
- }
278
- if (Object.keys(declarations).length > 0) {
279
- const unescapedClassName = unescapeCssClassSelector(className);
280
- result[className] = { "": declarations };
281
- result[unescapedClassName] = { "": declarations };
282
- result[replaceWxml(unescapedClassName)] = { "": declarations };
283
- }
284
- }
285
- });
218
+ const applied = expandCssApplySourcesToStyleValue(styleSource, utilityStyles);
219
+ if (!applied) continue;
220
+ Object.assign(result, applied);
286
221
  }
287
222
  }
288
223
  return Object.keys(result).length > 0 ? result : void 0;
@@ -312,17 +247,7 @@ function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
312
247
  }
313
248
  function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
314
249
  const utilities = /* @__PURE__ */ new Set();
315
- for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) {
316
- let root;
317
- try {
318
- root = parseUniAppXStyleSource(styleSource);
319
- } catch {
320
- continue;
321
- }
322
- root.walkAtRules("apply", (rule) => {
323
- for (const utility of splitCandidateTokens(rule.params)) utilities.add(utility);
324
- });
325
- }
250
+ for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) for (const utility of collectCssApplyUtilities(styleSource)) utilities.add(utility);
326
251
  return utilities;
327
252
  }
328
253
  function createMergedStyleValue(code, localStyle, appStyle) {
@@ -824,6 +749,204 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
824
749
  }
825
750
  }
826
751
  //#endregion
752
+ //#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
753
+ function applyViteAssetEmissionPlan(plan, options) {
754
+ for (const operation of plan.operations()) {
755
+ if (operation.kind === "delete") {
756
+ delete options.bundle[operation.assetId];
757
+ continue;
758
+ }
759
+ const writeTarget = options.writeTargets?.get(operation.assetId);
760
+ const existing = options.bundle[operation.assetId];
761
+ const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
762
+ if (asset) {
763
+ asset.source = operation.source;
764
+ continue;
765
+ }
766
+ const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
767
+ if (replayAsset) options.bundle[operation.assetId] = replayAsset;
768
+ }
769
+ }
770
+ //#endregion
771
+ //#region src/bundlers/vite/generate-bundle/root-style-output.ts
772
+ function isRootMiniProgramStyleOutputFile$1(file) {
773
+ const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
774
+ return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
775
+ }
776
+ function createRelativeCssImportRequest$1(targetFile, importedFile) {
777
+ const normalizedTargetFile = normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
778
+ const normalizedImportedFile = normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
779
+ const targetDir = path.posix.dirname(normalizedTargetFile);
780
+ const baseDir = targetDir === "." ? "" : targetDir;
781
+ const relative = path.posix.relative(baseDir, normalizedImportedFile);
782
+ return relative.startsWith(".") ? relative : `./${relative}`;
783
+ }
784
+ function createCssImportShell$1(targetFile, importedFile) {
785
+ return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
786
+ }
787
+ function resolveSingleCssImportOutputFile(targetFile, css) {
788
+ let importedFile;
789
+ try {
790
+ postcss.parse(css).walkAtRules("import", (atRule) => {
791
+ if (importedFile !== void 0) return;
792
+ const request = parseImportRequest(atRule.params);
793
+ if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
794
+ const cleanRequest = request.replace(/[?#].*$/, "");
795
+ if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
796
+ const targetDir = path.posix.dirname(normalizeOutputPathKey(targetFile));
797
+ importedFile = normalizeOutputPathKey(path.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
798
+ });
799
+ } catch {}
800
+ return importedFile;
801
+ }
802
+ function createRootMiniProgramOriginStyleOutputFile(file) {
803
+ const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
804
+ if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
805
+ return normalized.replace(/(\.[^.]+)$/, "-origin$1");
806
+ }
807
+ function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
808
+ return enabled === true;
809
+ }
810
+ function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
811
+ return !options.isWebGeneratorTarget && options.matchesCss && isRootStyleOutputFile(options.file) && isPureLocalCssImportWrapper(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
812
+ }
813
+ function resolveFrameworkRootImportShellPlan(options) {
814
+ const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
815
+ css: options.rawSource,
816
+ file: options.rootImportShellOutputFile,
817
+ isWebGeneratorTarget: options.isWebGeneratorTarget,
818
+ matchesCss: options.matchesCss,
819
+ shouldKeep: options.shouldKeep
820
+ });
821
+ if (isCurrentImportShell) {
822
+ const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
823
+ return {
824
+ isCurrentImportShell,
825
+ reusableTarget: options.rememberedTarget,
826
+ targetToRemember: importedFile && isRootStyleOutputFile(importedFile) ? importedFile : void 0
827
+ };
828
+ }
829
+ if (options.rememberedTarget) return {
830
+ isCurrentImportShell,
831
+ reusableTarget: options.rememberedTarget,
832
+ targetToRemember: void 0
833
+ };
834
+ if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && normalizeOutputPathKey(options.assetSourceFile) === normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
835
+ isCurrentImportShell,
836
+ reusableTarget: void 0,
837
+ targetToRemember: void 0
838
+ };
839
+ const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && normalizeOutputPathKey(file) !== normalizeOutputPathKey(options.rootImportShellOutputFile)));
840
+ const target = targets.size === 1 ? [...targets][0] : void 0;
841
+ return {
842
+ isCurrentImportShell,
843
+ reusableTarget: target,
844
+ targetToRemember: target
845
+ };
846
+ }
847
+ function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
848
+ if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
849
+ const plan = new AssetEmissionPlan();
850
+ const writeTargets = /* @__PURE__ */ new Map();
851
+ let restored = 0;
852
+ for (const [sourceFile, targetFile] of options.targetByFile) {
853
+ if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootStyleOutputFile(sourceFile) || !isRootStyleOutputFile(targetFile) || normalizeOutputPathKey(sourceFile) === normalizeOutputPathKey(targetFile)) continue;
854
+ const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && normalizeOutputPathKey(candidate.fileName || bundleFile) === normalizeOutputPathKey(sourceFile))?.[1];
855
+ if (output?.type !== "asset") continue;
856
+ const rawSource = output.source.toString();
857
+ if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
858
+ const nextSource = createCssImportShell$1(sourceFile, targetFile);
859
+ if (rawSource === nextSource) continue;
860
+ plan.write(sourceFile, nextSource);
861
+ writeTargets.set(sourceFile, output);
862
+ options.recordCssAssetResult?.(sourceFile, nextSource);
863
+ options.onUpdate?.(sourceFile, rawSource, nextSource);
864
+ options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
865
+ restored++;
866
+ }
867
+ applyViteAssetEmissionPlan(plan, {
868
+ bundle,
869
+ writeTargets
870
+ });
871
+ return restored;
872
+ }
873
+ function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
874
+ const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
875
+ if (output.type !== "chunk") return [];
876
+ const file = normalizeOutputPathKey(output.fileName || bundleFile);
877
+ if (file.includes("/")) return [];
878
+ return [{
879
+ file,
880
+ isEntry: output.isEntry === true
881
+ }];
882
+ });
883
+ const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
884
+ const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => path.posix.parse(chunk.file).name));
885
+ const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
886
+ if (output.type !== "asset") return [];
887
+ const file = normalizeOutputPathKey(output.fileName || bundleFile);
888
+ return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(path.posix.parse(file).name) ? [file] : [];
889
+ });
890
+ return candidates.length === 1 ? candidates[0] : void 0;
891
+ }
892
+ function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
893
+ if (options.targetByFile.size === 0) return 0;
894
+ const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
895
+ if (!runtimeRootFile) return 0;
896
+ const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => normalizeOutputPathKey(file) !== normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
897
+ if (frameworkRootFiles.length !== 1) return 0;
898
+ const frameworkRootFile = frameworkRootFiles[0];
899
+ const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(runtimeRootFile))?.[1];
900
+ const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(frameworkRootFile))?.[1];
901
+ if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
902
+ const runtimeSource = runtimeOutput.source.toString();
903
+ const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
904
+ if (importedRuntimeFile && normalizeOutputPathKey(importedRuntimeFile) === normalizeOutputPathKey(frameworkRootFile)) return 0;
905
+ const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
906
+ if (importedFrameworkFile && normalizeOutputPathKey(importedFrameworkFile) === normalizeOutputPathKey(runtimeRootFile)) return 0;
907
+ const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
908
+ runtimeOutput.source = nextSource;
909
+ options.recordCssAssetResult?.(runtimeRootFile, nextSource);
910
+ options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
911
+ options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
912
+ return 1;
913
+ }
914
+ function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
915
+ return enabled === true;
916
+ }
917
+ //#endregion
918
+ //#region src/bundlers/vite/generate-bundle/framework-style-memory.ts
919
+ function createFrameworkStyleMemory(targetByFile) {
920
+ const sources = /* @__PURE__ */ new Map();
921
+ return { prepare(bundle, removedFiles) {
922
+ for (const file of removedFiles) {
923
+ const key = normalizeOutputPathKey(file);
924
+ sources.delete(key);
925
+ for (const [source, target] of targetByFile) if (normalizeOutputPathKey(source) === key || normalizeOutputPathKey(target) === key) {
926
+ sources.delete(normalizeOutputPathKey(source));
927
+ targetByFile.delete(source);
928
+ }
929
+ }
930
+ const currentFiles = new Set(Object.entries(bundle).map(([file, asset]) => normalizeOutputPathKey(asset.fileName || file)));
931
+ for (const [file, asset] of sources) if (!currentFiles.has(file)) bundle[file] = { ...asset };
932
+ const inputs = /* @__PURE__ */ new Map();
933
+ for (const [file, asset] of Object.entries(bundle)) {
934
+ if (asset.type !== "asset" || !isRootMiniProgramStyleOutputFile$1(asset.fileName || file)) continue;
935
+ const source = typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString();
936
+ if (hasBundlerGeneratedCssMarker(source)) sources.delete(normalizeOutputPathKey(asset.fileName || file));
937
+ else inputs.set(normalizeOutputPathKey(asset.fileName || file), {
938
+ ...asset,
939
+ source
940
+ });
941
+ }
942
+ return () => {
943
+ const mappedFiles = new Set([...targetByFile.keys()].map(normalizeOutputPathKey));
944
+ for (const file of sources.keys()) if (!mappedFiles.has(file)) sources.delete(file);
945
+ for (const [file, asset] of inputs) if (mappedFiles.has(file)) sources.set(file, asset);
946
+ };
947
+ } };
948
+ }
949
+ //#endregion
827
950
  //#region src/bundlers/vite/processed-css-assets/cleanup.ts
828
951
  function collectCssImportAtRuleCss(css) {
829
952
  if (!css.includes("@import")) return [];
@@ -1286,7 +1409,7 @@ function isRuleCoveredByRootCss(rule, coverage) {
1286
1409
  return rootDeclarations != null && declarationKeys.every((declaration) => rootDeclarations.has(declaration));
1287
1410
  });
1288
1411
  }
1289
- function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
1412
+ function removeScopedCssCoveredByRootStyleSources(css, rootSources, preserveRuntimeProperties = false) {
1290
1413
  if (!hasVueScopedAttr(css)) return css;
1291
1414
  const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
1292
1415
  const coverage = collectRootScopedComparableCssCoverage(rootSources);
@@ -1300,13 +1423,14 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
1300
1423
  }
1301
1424
  });
1302
1425
  root.walkRules((rule) => {
1426
+ if (preserveRuntimeProperties && isTailwindRuntimePropertyRule(rule)) return;
1303
1427
  if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
1304
1428
  rule.remove();
1305
1429
  changed = true;
1306
1430
  }
1307
1431
  });
1308
1432
  root.walkAtRules((atRule) => {
1309
- if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1433
+ if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || !preserveRuntimeProperties && isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1310
1434
  atRule.remove();
1311
1435
  changed = true;
1312
1436
  return;
@@ -1321,8 +1445,8 @@ function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
1321
1445
  return css;
1322
1446
  }
1323
1447
  }
1324
- function removeScopedTailwindPreflightCss(css) {
1325
- return removeScopedCssCoveredByRootStyleSources(css, []);
1448
+ function removeScopedTailwindPreflightCss(css, options) {
1449
+ return removeScopedCssCoveredByRootStyleSources(css, [], options?.preserveRuntimeProperties);
1326
1450
  }
1327
1451
  function collectSingleViteGeneratedCssMarkerFile(rawSource) {
1328
1452
  const blocks = parseBundlerGeneratedCssMarkerBlocks(rawSource).filter((block) => block.bundler === "vite");
@@ -1347,241 +1471,78 @@ function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
1347
1471
  try {
1348
1472
  const root = postcss.parse(css);
1349
1473
  let changed = false;
1350
- root.walkRules((rule) => {
1351
- if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
1352
- rule.remove();
1353
- changed = true;
1354
- }
1355
- });
1356
- if (hasScopedCss) root.walkAtRules((atRule) => {
1357
- if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1358
- atRule.remove();
1359
- changed = true;
1360
- return;
1361
- }
1362
- if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
1363
- atRule.remove();
1364
- changed = true;
1365
- }
1366
- });
1367
- root.walkComments((comment) => {
1368
- if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
1369
- comment.remove();
1370
- changed = true;
1371
- return;
1372
- }
1373
- if (!comment.text.trim().startsWith("tokens:")) return;
1374
- const next = comment.next();
1375
- if (next?.type === "rule" || next?.type === "atrule") return;
1376
- comment.remove();
1377
- changed = true;
1378
- });
1379
- if (changed) nextCss = root.toString().trim();
1380
- } catch {}
1381
- return hasNonCommentCss(nextCss) ? nextCss : "";
1382
- }
1383
- function removeDanglingCssSourceTraceComments(css) {
1384
- if (!css.includes("/* tokens:")) return css;
1385
- try {
1386
- const root = postcss.parse(css);
1387
- let changed = false;
1388
- root.each((node) => {
1389
- if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
1390
- const next = node.next();
1391
- if (next?.type === "rule" || next?.type === "atrule") return;
1392
- node.remove();
1393
- changed = true;
1394
- });
1395
- return changed ? root.toString().trim() : css;
1396
- } catch {
1397
- return css;
1398
- }
1399
- }
1400
- function removeCssCoveredByRootStyleAssets(bundle, options) {
1401
- let updated = 0;
1402
- for (const [bundleFile, output] of Object.entries(bundle)) {
1403
- if (output.type !== "asset") continue;
1404
- const file = getAssetFile$1(bundleFile, output);
1405
- const rawSource = readAssetSource$2(output);
1406
- const hasScopedCss = hasVueScopedAttr(rawSource);
1407
- const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
1408
- const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
1409
- if (!(options.cssMatcher(file) || hasScopedCss && isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
1410
- const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
1411
- if (nextCss === rawSource) continue;
1412
- output.source = nextCss;
1413
- options.recordCssAssetResult?.(file, nextCss);
1414
- options.onUpdate?.(file, rawSource, nextCss);
1415
- options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
1416
- updated++;
1417
- }
1418
- return updated;
1419
- }
1420
- //#endregion
1421
- //#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
1422
- function applyViteAssetEmissionPlan(plan, options) {
1423
- for (const operation of plan.operations()) {
1424
- if (operation.kind === "delete") {
1425
- delete options.bundle[operation.assetId];
1426
- continue;
1427
- }
1428
- const writeTarget = options.writeTargets?.get(operation.assetId);
1429
- const existing = options.bundle[operation.assetId];
1430
- const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
1431
- if (asset) {
1432
- asset.source = operation.source;
1433
- continue;
1434
- }
1435
- const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
1436
- if (replayAsset) options.bundle[operation.assetId] = replayAsset;
1437
- }
1438
- }
1439
- //#endregion
1440
- //#region src/bundlers/vite/generate-bundle/root-style-output.ts
1441
- function isRootMiniProgramStyleOutputFile$1(file) {
1442
- const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
1443
- return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
1444
- }
1445
- function createRelativeCssImportRequest$1(targetFile, importedFile) {
1446
- const normalizedTargetFile = normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
1447
- const normalizedImportedFile = normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
1448
- const targetDir = path.posix.dirname(normalizedTargetFile);
1449
- const baseDir = targetDir === "." ? "" : targetDir;
1450
- const relative = path.posix.relative(baseDir, normalizedImportedFile);
1451
- return relative.startsWith(".") ? relative : `./${relative}`;
1452
- }
1453
- function createCssImportShell$1(targetFile, importedFile) {
1454
- return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
1455
- }
1456
- function resolveSingleCssImportOutputFile(targetFile, css) {
1457
- let importedFile;
1458
- try {
1459
- postcss.parse(css).walkAtRules("import", (atRule) => {
1460
- if (importedFile !== void 0) return;
1461
- const request = parseImportRequest(atRule.params);
1462
- if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
1463
- const cleanRequest = request.replace(/[?#].*$/, "");
1464
- if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
1465
- const targetDir = path.posix.dirname(normalizeOutputPathKey(targetFile));
1466
- importedFile = normalizeOutputPathKey(path.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
1467
- });
1468
- } catch {}
1469
- return importedFile;
1470
- }
1471
- function createRootMiniProgramOriginStyleOutputFile(file) {
1472
- const normalized = normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
1473
- if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
1474
- return normalized.replace(/(\.[^.]+)$/, "-origin$1");
1475
- }
1476
- function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
1477
- return enabled === true;
1478
- }
1479
- function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
1480
- return !options.isWebGeneratorTarget && options.matchesCss && isRootStyleOutputFile(options.file) && isPureLocalCssImportWrapper(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
1481
- }
1482
- function resolveFrameworkRootImportShellPlan(options) {
1483
- const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
1484
- css: options.rawSource,
1485
- file: options.rootImportShellOutputFile,
1486
- isWebGeneratorTarget: options.isWebGeneratorTarget,
1487
- matchesCss: options.matchesCss,
1488
- shouldKeep: options.shouldKeep
1489
- });
1490
- if (isCurrentImportShell) {
1491
- const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
1492
- return {
1493
- isCurrentImportShell,
1494
- reusableTarget: options.rememberedTarget,
1495
- targetToRemember: importedFile && isRootStyleOutputFile(importedFile) ? importedFile : void 0
1496
- };
1497
- }
1498
- if (options.rememberedTarget) return {
1499
- isCurrentImportShell,
1500
- reusableTarget: options.rememberedTarget,
1501
- targetToRemember: void 0
1502
- };
1503
- if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && normalizeOutputPathKey(options.assetSourceFile) === normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
1504
- isCurrentImportShell,
1505
- reusableTarget: void 0,
1506
- targetToRemember: void 0
1507
- };
1508
- const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && normalizeOutputPathKey(file) !== normalizeOutputPathKey(options.rootImportShellOutputFile)));
1509
- const target = targets.size === 1 ? [...targets][0] : void 0;
1510
- return {
1511
- isCurrentImportShell,
1512
- reusableTarget: target,
1513
- targetToRemember: target
1514
- };
1515
- }
1516
- function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
1517
- if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
1518
- const plan = new AssetEmissionPlan();
1519
- const writeTargets = /* @__PURE__ */ new Map();
1520
- let restored = 0;
1521
- for (const [sourceFile, targetFile] of options.targetByFile) {
1522
- if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !isRootStyleOutputFile(sourceFile) || !isRootStyleOutputFile(targetFile) || normalizeOutputPathKey(sourceFile) === normalizeOutputPathKey(targetFile)) continue;
1523
- const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && normalizeOutputPathKey(candidate.fileName || bundleFile) === normalizeOutputPathKey(sourceFile))?.[1];
1524
- if (output?.type !== "asset") continue;
1525
- const rawSource = output.source.toString();
1526
- if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
1527
- const nextSource = createCssImportShell$1(sourceFile, targetFile);
1528
- if (rawSource === nextSource) continue;
1529
- plan.write(sourceFile, nextSource);
1530
- writeTargets.set(sourceFile, output);
1531
- options.recordCssAssetResult?.(sourceFile, nextSource);
1532
- options.onUpdate?.(sourceFile, rawSource, nextSource);
1533
- options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
1534
- restored++;
1535
- }
1536
- applyViteAssetEmissionPlan(plan, {
1537
- bundle,
1538
- writeTargets
1539
- });
1540
- return restored;
1541
- }
1542
- function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
1543
- const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
1544
- if (output.type !== "chunk") return [];
1545
- const file = normalizeOutputPathKey(output.fileName || bundleFile);
1546
- if (file.includes("/")) return [];
1547
- return [{
1548
- file,
1549
- isEntry: output.isEntry === true
1550
- }];
1551
- });
1552
- const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
1553
- const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => path.posix.parse(chunk.file).name));
1554
- const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
1555
- if (output.type !== "asset") return [];
1556
- const file = normalizeOutputPathKey(output.fileName || bundleFile);
1557
- return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(path.posix.parse(file).name) ? [file] : [];
1558
- });
1559
- return candidates.length === 1 ? candidates[0] : void 0;
1474
+ root.walkRules((rule) => {
1475
+ if (coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) || hasScopedCss && (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule))) {
1476
+ rule.remove();
1477
+ changed = true;
1478
+ }
1479
+ });
1480
+ if (hasScopedCss) root.walkAtRules((atRule) => {
1481
+ if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
1482
+ atRule.remove();
1483
+ changed = true;
1484
+ return;
1485
+ }
1486
+ if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
1487
+ atRule.remove();
1488
+ changed = true;
1489
+ }
1490
+ });
1491
+ root.walkComments((comment) => {
1492
+ if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
1493
+ comment.remove();
1494
+ changed = true;
1495
+ return;
1496
+ }
1497
+ if (!comment.text.trim().startsWith("tokens:")) return;
1498
+ const next = comment.next();
1499
+ if (next?.type === "rule" || next?.type === "atrule") return;
1500
+ comment.remove();
1501
+ changed = true;
1502
+ });
1503
+ if (changed) {
1504
+ removeUnusedMiniProgramContentInit(root);
1505
+ nextCss = root.toString().trim();
1506
+ }
1507
+ } catch {}
1508
+ return hasNonCommentCss(nextCss) ? nextCss : "";
1560
1509
  }
1561
- function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
1562
- if (options.targetByFile.size === 0) return 0;
1563
- const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
1564
- if (!runtimeRootFile) return 0;
1565
- const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => normalizeOutputPathKey(file) !== normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
1566
- if (frameworkRootFiles.length !== 1) return 0;
1567
- const frameworkRootFile = frameworkRootFiles[0];
1568
- const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(runtimeRootFile))?.[1];
1569
- const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && normalizeOutputPathKey(output.fileName || bundleFile) === normalizeOutputPathKey(frameworkRootFile))?.[1];
1570
- if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
1571
- const runtimeSource = runtimeOutput.source.toString();
1572
- const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
1573
- if (importedRuntimeFile && normalizeOutputPathKey(importedRuntimeFile) === normalizeOutputPathKey(frameworkRootFile)) return 0;
1574
- const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
1575
- if (importedFrameworkFile && normalizeOutputPathKey(importedFrameworkFile) === normalizeOutputPathKey(runtimeRootFile)) return 0;
1576
- const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
1577
- runtimeOutput.source = nextSource;
1578
- options.recordCssAssetResult?.(runtimeRootFile, nextSource);
1579
- options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
1580
- options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
1581
- return 1;
1510
+ function removeDanglingCssSourceTraceComments(css) {
1511
+ if (!css.includes("/* tokens:")) return css;
1512
+ try {
1513
+ const root = postcss.parse(css);
1514
+ let changed = false;
1515
+ root.each((node) => {
1516
+ if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
1517
+ const next = node.next();
1518
+ if (next?.type === "rule" || next?.type === "atrule") return;
1519
+ node.remove();
1520
+ changed = true;
1521
+ });
1522
+ return changed ? root.toString().trim() : css;
1523
+ } catch {
1524
+ return css;
1525
+ }
1582
1526
  }
1583
- function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
1584
- return enabled === true;
1527
+ function removeCssCoveredByRootStyleAssets(bundle, options) {
1528
+ let updated = 0;
1529
+ for (const [bundleFile, output] of Object.entries(bundle)) {
1530
+ if (output.type !== "asset") continue;
1531
+ const file = getAssetFile$1(bundleFile, output);
1532
+ const rawSource = readAssetSource$2(output);
1533
+ const hasScopedCss = hasVueScopedAttr(rawSource);
1534
+ const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
1535
+ const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && isCssOutputFile(file) && !isMiniProgramStyleOutputFile(file);
1536
+ if (!(options.cssMatcher(file) || hasScopedCss && isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
1537
+ const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
1538
+ if (nextCss === rawSource) continue;
1539
+ output.source = nextCss;
1540
+ options.recordCssAssetResult?.(file, nextCss);
1541
+ options.onUpdate?.(file, rawSource, nextCss);
1542
+ options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
1543
+ updated++;
1544
+ }
1545
+ return updated;
1585
1546
  }
1586
1547
  //#endregion
1587
1548
  //#region src/bundlers/vite/processed-css-assets/injection-plan.ts
@@ -1735,10 +1696,15 @@ function collectViteProcessedCssAssetResults(bundle, options) {
1735
1696
  for (const [bundleFile, output] of Object.entries(bundle)) {
1736
1697
  if (output.type !== "asset") continue;
1737
1698
  const file = getAssetFile$1(bundleFile, output);
1738
- if (!isCssOutputFile(file) || !options.isViteProcessedCssAsset?.(output, file)) continue;
1699
+ if (!isCssOutputFile(file)) continue;
1739
1700
  const rawSource = readAssetSource$2(output);
1740
- let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
1741
1701
  const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
1702
+ if (singleMarkerFile) {
1703
+ getActiveViteSourceOutputRelationOwner()?.recordOwnedOutput(singleMarkerFile, file);
1704
+ options.debug?.("css marker ownership: %s -> %s", singleMarkerFile, file);
1705
+ }
1706
+ if (!options.isViteProcessedCssAsset?.(output, file)) continue;
1707
+ let nextCss = resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
1742
1708
  if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
1743
1709
  nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
1744
1710
  if (nextCss !== rawSource) {
@@ -1850,7 +1816,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
1850
1816
  }
1851
1817
  const fileKey = normalizeOutputPathKey(file);
1852
1818
  const mainFileKey = normalizeOutputPathKey(file);
1853
- const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource), file), file));
1819
+ const normalizedOriginalCss = measure("normalizeTarget", () => normalizeInjectableCssForTargetWithImports(transformCss(removeTailwindEntryDirectivesFromCss(originalSource, options.createCssPipelineContext?.(file)?.currentGeneratorBranch?.isWeb === true), file), file));
1854
1820
  let nextCss = normalizedOriginalCss.css;
1855
1821
  const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
1856
1822
  const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
@@ -2148,7 +2114,7 @@ function createCssAssetEmitter(context, bundle) {
2148
2114
  return (fileName, source) => {
2149
2115
  const fileNameKey = normalizeOutputPathKey(fileName);
2150
2116
  const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
2151
- if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
2117
+ if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset" && "source" in existing) {
2152
2118
  existing.source = source;
2153
2119
  return existing;
2154
2120
  }
@@ -2256,6 +2222,10 @@ function processViteCssCacheTask(options) {
2256
2222
  function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash) {
2257
2223
  return `${cssRuntimeSignature}:${cssRuntimeAffectingHash}`;
2258
2224
  }
2225
+ /** 入口重放的干净生成结果,避免和已合并框架贡献的产物缓存混用。 */
2226
+ function createGeneratedReplayCacheKey(outputFile) {
2227
+ return `${normalizeOutputPathKey(outputFile)}::__generated_replay__`;
2228
+ }
2259
2229
  function normalizeRememberedSourceIdentity(file) {
2260
2230
  return normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
2261
2231
  }
@@ -2295,9 +2265,23 @@ function mergeRememberedCssSources(sources, outputFile) {
2295
2265
  }
2296
2266
  function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
2297
2267
  const groups = /* @__PURE__ */ new Map();
2268
+ const outputFiles = [...styleOutputFiles ?? []];
2269
+ const currentOutputs = new Set(outputFiles.map(normalizeOutputPathKey));
2270
+ const relationOwner = getActiveViteSourceOutputRelationOwner();
2298
2271
  for (const [key, remembered] of sources ?? []) {
2272
+ const ownedOutputs = [...relationOwner?.getOwnedOutputs(remembered.sourceFile) ?? []].filter((file) => currentOutputs.has(normalizeOutputPathKey(file)) && opts.cssMatcher(file));
2273
+ if (ownedOutputs.length === 1) {
2274
+ const outputKey = normalizeOutputPathKey(ownedOutputs[0]);
2275
+ const group = groups.get(outputKey) ?? [];
2276
+ group.push({
2277
+ key,
2278
+ remembered
2279
+ });
2280
+ groups.set(outputKey, group);
2281
+ continue;
2282
+ }
2299
2283
  const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
2300
- const resolvedOutputFile = CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles);
2284
+ const resolvedOutputFile = CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles) : resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles);
2301
2285
  const rememberedOutputFile = remembered.outputFile.replace(/[?#].*$/, "");
2302
2286
  const outputFile = opts.cssMatcher(rememberedOutputFile) && !normalizeOutputPathKey(rememberedOutputFile).includes("/") && normalizeOutputPathKey(rememberedOutputFile) !== normalizeOutputPathKey(resolvedOutputFile.replace(/[?#].*$/, "")) ? remembered.outputFile : resolvedOutputFile;
2303
2287
  const outputKey = normalizeOutputPathKey(outputFile);
@@ -2893,6 +2877,7 @@ async function processViteCssBundleEntry(options) {
2893
2877
  runtimeAffectingSignatureByFile: snapshot.runtimeAffectingSignatureByFile
2894
2878
  }) : "";
2895
2879
  const { cssCacheKey, cssHashKey, cssSharedCacheKey, cssTaskHash, rememberedCssRuntimeSignature } = resolveViteCssTransformCachePlan({
2880
+ cssBundleSourceHash: isWebGeneratorTarget ? cache.computeHash(rawSource) : void 0,
2896
2881
  cssIsMainChunk: cssHandlerOptions2.isMainChunk === true,
2897
2882
  cssRuntimeAffectingHash,
2898
2883
  cssShareScope,
@@ -3498,13 +3483,15 @@ function resolveViteCssTransformCachePlan(options) {
3498
3483
  options.cssIsMainChunk ? "1" : "0",
3499
3484
  options.cssRuntimeAffectingHash,
3500
3485
  options.scopedGeneratorCandidateSignature,
3501
- options.sourceTraceSignature
3486
+ options.sourceTraceSignature,
3487
+ ...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
3502
3488
  ].join(":"),
3503
3489
  cssTaskHash: [
3504
3490
  options.cssRuntimeAffectingHash,
3505
3491
  options.scopedGeneratorCandidateSignature,
3506
3492
  options.sourceTraceSignature,
3507
- options.linkedImpactSignature
3493
+ options.linkedImpactSignature,
3494
+ ...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
3508
3495
  ].join(":"),
3509
3496
  rememberedCssRuntimeSignature
3510
3497
  };
@@ -3536,6 +3523,27 @@ function applyViteCssTransformTaskResult(options) {
3536
3523
  return result.css;
3537
3524
  }
3538
3525
  //#endregion
3526
+ //#region src/bundlers/vite/generate-bundle/web-css-module.ts
3527
+ /** 仅替换 transform 阶段标记的模块区间,保留 bundler 合并的前后样式及其层叠顺序。 */
3528
+ function replaceWebCssModule(source, sourceFile, generated) {
3529
+ const markers = [...source.matchAll(/\/\*!?\s*weapp-tailwindcss vite-generated-css(-end)?\s*:\s*([^\s*]+)\s*\*\//gi)];
3530
+ const sourceKey = normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
3531
+ let cursor = 0;
3532
+ let result = "";
3533
+ let replaced = false;
3534
+ for (let index = 0; index < markers.length; index++) {
3535
+ const start = markers[index];
3536
+ const end = markers[index + 1];
3537
+ if (start[1] || !end?.[1] || start[2] !== end[2]) continue;
3538
+ if (normalizeOutputPathKey(decodeURIComponent(start[2])) !== sourceKey) continue;
3539
+ result += source.slice(cursor, start.index) + generated;
3540
+ cursor = end.index + end[0].length;
3541
+ replaced = true;
3542
+ index++;
3543
+ }
3544
+ return replaced ? result + source.slice(cursor) : void 0;
3545
+ }
3546
+ //#endregion
3539
3547
  //#region src/bundlers/vite/generate-bundle/css-transform-task.ts
3540
3548
  function resolveBundleUserRawSource(options) {
3541
3549
  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;
@@ -3543,7 +3551,7 @@ function resolveBundleUserRawSource(options) {
3543
3551
  async function executeViteCssTransformTask(options) {
3544
3552
  await options.runtimeState.readyPromise;
3545
3553
  const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
3546
- if (hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget && hasBundlerGeneratedCssMarker(options.rawSource)) {
3554
+ if (hasTailwindGenerationSource(options.generatorRawSource) && (!options.isWebGeneratorTarget || !hasBundlerGeneratedCssMarker(options.rawSource) || hasTailwindRootDirectives(options.generatorRawSource, { importFallback: true })) || !options.isWebGeneratorTarget && hasBundlerGeneratedCssMarker(options.rawSource)) {
3547
3555
  const bundleUserRawSource = resolveBundleUserRawSource(options);
3548
3556
  const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
3549
3557
  const generated = await (options.generateCss ?? generateTailwindV4Css)({
@@ -3567,7 +3575,7 @@ async function executeViteCssTransformTask(options) {
3567
3575
  userRawSource: generatorUserRawSource || void 0
3568
3576
  });
3569
3577
  if (generated) {
3570
- const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(generated.css)));
3578
+ const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(options.isWebGeneratorTarget ? replaceWebCssModule(options.rawSource, options.generatorSourceFile, generated.css) ?? generated.css : generated.css)));
3571
3579
  return {
3572
3580
  classSet: generated.classSet,
3573
3581
  css,
@@ -4008,9 +4016,58 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
4008
4016
  return updated;
4009
4017
  }
4010
4018
  //#endregion
4019
+ //#region src/bundlers/vite/generate-bundle/finalize/sync-processed-css.ts
4020
+ function syncProcessedCss(options) {
4021
+ const { bundle, opts, cssPipelineStrategy, createCssPipelineContext, isViteProcessedCssAsset, markCssAssetProcessed, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles, transformWebTargetCss, debug, recordTimingDetail, getViteProcessedCssAssetResults, onUpdate, pendingRememberedCssReplayUpdates } = options;
4022
+ const collectStartedAt = performance.now();
4023
+ collectViteProcessedCssAssetResults(bundle, {
4024
+ opts,
4025
+ cssPipelineStrategy,
4026
+ createCssPipelineContext,
4027
+ isViteProcessedCssAsset,
4028
+ markCssAssetProcessed,
4029
+ recordCssAssetResult,
4030
+ recordViteProcessedCssAssetResult,
4031
+ resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
4032
+ subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
4033
+ transformCss: transformWebTargetCss,
4034
+ debug
4035
+ });
4036
+ recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
4037
+ const injectStartedAt = performance.now();
4038
+ const currentResults = new Map([...getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => [normalizeOutputPathKey(file), [file, record]]));
4039
+ for (const update of pendingRememberedCssReplayUpdates) {
4040
+ recordViteProcessedCssAssetResult?.(update.file, update.css, update);
4041
+ currentResults.set(normalizeOutputPathKey(update.file), [update.file, {
4042
+ css: update.css,
4043
+ injectIntoMain: update.injectIntoMain,
4044
+ outputFile: update.outputFile
4045
+ }]);
4046
+ }
4047
+ const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
4048
+ opts,
4049
+ cssPipelineStrategy,
4050
+ createCssPipelineContext,
4051
+ getViteProcessedCssAssetResults: () => currentResults.values(),
4052
+ markCssAssetProcessed,
4053
+ recordCssAssetResult,
4054
+ transformCss: transformWebTargetCss,
4055
+ shouldRemoveInjectedSourceAsset: (targetFile, record) => {
4056
+ if (record.injectIntoMain === false) return false;
4057
+ const targetFileKey = normalizeOutputPathKey(targetFile);
4058
+ return normalizeOutputPathKey(record.file) !== targetFileKey;
4059
+ },
4060
+ debug,
4061
+ onUpdate,
4062
+ recordTimingDetail
4063
+ });
4064
+ recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
4065
+ return injected;
4066
+ }
4067
+ //#endregion
4011
4068
  //#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
4012
4069
  async function finalizeGenerateBundle(options) {
4013
- const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, defaultStyleOutputExtension, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, markCssAssetProcessed, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, pendingRememberedCssReplayUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, recordViteProcessedCssAssetResult, rootDir, runtime, runtimeState, shouldPreserveAppCssExtension, snapshot, sourceCandidates, sourceRoot, state, styleHandler, tasks, timingDetails, transformRuntime, transformWebTargetCss, useIncrementalMode } = options;
4070
+ const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, runtime, runtimeState, snapshot, sourceCandidates, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
4014
4071
  const tasksStart = performance.now();
4015
4072
  if (cssTaskFactories.length > 0) {
4016
4073
  const cssConcurrency = resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion);
@@ -4041,68 +4098,11 @@ async function finalizeGenerateBundle(options) {
4041
4098
  styleHandler
4042
4099
  });
4043
4100
  recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
4044
- const syncViteProcessedCssIntoMainCssAssets = () => {
4045
- const collectStartedAt = performance.now();
4046
- collectViteProcessedCssAssetResults(bundle, {
4047
- opts,
4048
- cssPipelineStrategy,
4049
- createCssPipelineContext,
4050
- isViteProcessedCssAsset,
4051
- markCssAssetProcessed,
4052
- recordCssAssetResult,
4053
- recordViteProcessedCssAssetResult,
4054
- resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
4055
- subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
4056
- transformCss: transformWebTargetCss,
4057
- debug
4058
- });
4059
- recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
4060
- const injectStartedAt = performance.now();
4061
- let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
4062
- opts,
4063
- cssPipelineStrategy,
4064
- createCssPipelineContext,
4065
- getViteProcessedCssAssetResults,
4066
- markCssAssetProcessed,
4067
- recordCssAssetResult,
4068
- transformCss: transformWebTargetCss,
4069
- shouldRemoveInjectedSourceAsset: (targetFile, record) => {
4070
- if (record.injectIntoMain === false) return false;
4071
- const targetFileKey = normalizeOutputPathKey(targetFile);
4072
- return normalizeOutputPathKey(record.file) !== targetFileKey;
4073
- },
4074
- debug,
4075
- onUpdate,
4076
- recordTimingDetail
4077
- });
4078
- if (pendingRememberedCssReplayUpdates.length > 0) {
4079
- for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
4080
- injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
4081
- opts,
4082
- cssPipelineStrategy,
4083
- createCssPipelineContext,
4084
- getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
4085
- css: update.css,
4086
- injectIntoMain: update.injectIntoMain,
4087
- outputFile: update.outputFile
4088
- }]),
4089
- markCssAssetProcessed,
4090
- recordCssAssetResult,
4091
- transformCss: transformWebTargetCss,
4092
- debug,
4093
- onUpdate,
4094
- recordTimingDetail
4095
- });
4096
- debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
4097
- }
4098
- recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
4099
- return injected;
4100
- };
4101
4101
  const processedCssStartedAt = performance.now();
4102
- syncViteProcessedCssIntoMainCssAssets();
4102
+ syncProcessedCss(options);
4103
4103
  if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
4104
4104
  if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
4105
- syncViteProcessedCssIntoMainCssAssets();
4105
+ syncProcessedCss(options);
4106
4106
  }
4107
4107
  recordTimingDetail("finalize.processedCss", processedCssStartedAt);
4108
4108
  const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
@@ -4333,6 +4333,16 @@ function createJsEntryResolver(jsEntries) {
4333
4333
  function resolveUniAppXJsTransformEnabled$1(uniAppX) {
4334
4334
  return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
4335
4335
  }
4336
+ /**
4337
+ * generateBundle 里每个 chunk 都会独立转译。
4338
+ * 生产构建再走 moduleGraph 只会把已在产物里的 JS 再 Babel 一遍;增量模式才需要它更新被跳过的 clean chunk。
4339
+ */
4340
+ function resolveGenerateBundleJsFastPath(options) {
4341
+ return {
4342
+ experimentalJsFastPath: options.experimentalJsFastPath ?? "oxc",
4343
+ moduleGraphEnabled: options.useIncrementalMode
4344
+ };
4345
+ }
4336
4346
  function createJsHandlerOptionsFactory(options) {
4337
4347
  return (absoluteFilename, extra) => ({
4338
4348
  ...extra,
@@ -4386,28 +4396,7 @@ function isUniAppXNativeAppOutDir(outDir) {
4386
4396
  }
4387
4397
  //#endregion
4388
4398
  //#region src/uni-app-x/border-preflight.ts
4389
- const BORDER_PREFLIGHT_CLASS = "weapp-tw-border";
4390
- /** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
4391
- function hoistUniAppXBorderPreflight(css) {
4392
- if (!css.includes("weapp-tw-border")) return css;
4393
- const root = postcss.parse(css);
4394
- const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
4395
- const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
4396
- if (!anchor || resets.length === 0) return css;
4397
- for (const reset of resets) {
4398
- reset.remove();
4399
- root.insertBefore(anchor, reset);
4400
- }
4401
- return root.toString();
4402
- }
4403
- /** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
4404
- function createUniAppXBorderPreflight(options) {
4405
- const declarations = createInjectPreflight(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
4406
- if (declarations.length === 0) return;
4407
- const rule = postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
4408
- for (const declaration of declarations) rule.append(postcss.decl(declaration));
4409
- return rule.toString();
4410
- }
4399
+ const BORDER_PREFLIGHT_CLASS = UNI_APP_X_BORDER_PREFLIGHT_CLASS;
4411
4400
  function resolveUniAppXBorderPreflightOptions(options, isWeb) {
4412
4401
  const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
4413
4402
  return borderPreflight ? {
@@ -4427,7 +4416,7 @@ function injectBorderPreflightClass(ms, node, offset) {
4427
4416
  const attribute = node.props.find((prop) => prop.type === NodeTypes.ATTRIBUTE && prop.name === "class");
4428
4417
  if (attribute?.type === NodeTypes.ATTRIBUTE) {
4429
4418
  if (attribute.value) {
4430
- if (attribute.value.content.split(/\s+/).includes("weapp-tw-border")) return;
4419
+ if (attribute.value.content.split(/\s+/).includes(BORDER_PREFLIGHT_CLASS)) return;
4431
4420
  const start = offset + attribute.value.loc.start.offset;
4432
4421
  if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
4433
4422
  else {
@@ -4460,50 +4449,8 @@ function resolveUniAppXStyleIsolationEnabled(root) {
4460
4449
  }
4461
4450
  //#endregion
4462
4451
  //#region src/uni-app-x/vite/author-apply.ts
4463
- function normalizeSelector(selector) {
4464
- return selector.replace(/\s+/g, " ").trim();
4465
- }
4466
- function atRuleKey(name, params) {
4467
- return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
4468
- }
4469
- /**
4470
- * `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
4471
- * utilities 和 property 注册复制进 scoped style 模块。
4472
- */
4473
- function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
4474
- try {
4475
- const authorRoot = postcss.parse(removeTailwindSourceDirectives(authorCss, { importFallback: true }));
4476
- const authorSelectors = /* @__PURE__ */ new Set();
4477
- const authorAtRules = /* @__PURE__ */ new Set();
4478
- authorRoot.walkRules((rule) => {
4479
- for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
4480
- });
4481
- authorRoot.walkAtRules((atRule) => {
4482
- if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
4483
- });
4484
- const root = postcss.parse(generatedCss);
4485
- let changed = false;
4486
- root.walkRules((rule) => {
4487
- if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
4488
- rule.remove();
4489
- changed = true;
4490
- });
4491
- root.walkAtRules((atRule) => {
4492
- if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
4493
- if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
4494
- atRule.remove();
4495
- changed = true;
4496
- });
4497
- root.walkComments((comment) => {
4498
- if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
4499
- comment.remove();
4500
- changed = true;
4501
- }
4502
- });
4503
- return changed ? root.toString().trim() : generatedCss;
4504
- } catch {
4505
- return generatedCss;
4506
- }
4452
+ function retainUniAppXAuthorApplyCss$1(generatedCss, authorCss, options) {
4453
+ return retainUniAppXAuthorApplyCss(generatedCss, removeTailwindSourceDirectives(authorCss, { importFallback: true }), options);
4507
4454
  }
4508
4455
  //#endregion
4509
4456
  //#region src/uni-app-x/vite/harmony-apply.ts
@@ -4550,7 +4497,7 @@ function createUniAppXHarmonyApplyExpander(options) {
4550
4497
  const cssFile = path.resolve(options.getResolvedConfig()?.root ?? process.cwd(), `uni-app-x-harmony-apply-${createStableHash(normalizePath(cleanUrl$1(id)))}.css`);
4551
4498
  const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
4552
4499
  const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
4553
- addWatchFile: hookContext.addWatchFile?.bind(hookContext),
4500
+ ...hookContext.addWatchFile ? { addWatchFile: hookContext.addWatchFile.bind(hookContext) } : {},
4554
4501
  disableSourceScan: true,
4555
4502
  sourceCandidates: [],
4556
4503
  transient: true
@@ -4653,6 +4600,18 @@ function reportStyleWarnings(result) {
4653
4600
  for (const warning of warnings) logger$1.warn(warning.toString());
4654
4601
  }
4655
4602
  //#endregion
4603
+ //#region src/uni-app-x/vite/style-result.ts
4604
+ /** 将样式处理结果和源码映射统一转换为 Vite 模块结果。 */
4605
+ async function createUniAppXStyleResult(id, result) {
4606
+ reportStyleWarnings(result);
4607
+ const rawPostcssMap = result.map.toJSON();
4608
+ const map = await formatPostcssSourceMap(rawPostcssMap, normalizePath(cleanUrl$1(id)));
4609
+ return {
4610
+ code: result.css,
4611
+ map: JSON.stringify(map)
4612
+ };
4613
+ }
4614
+ //#endregion
4656
4615
  //#region src/uni-app-x/vite/style-source.ts
4657
4616
  const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
4658
4617
  function createUniAppXSfcStyleSources() {
@@ -4821,7 +4780,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
4821
4780
  //#region src/uni-app-x/vite.ts
4822
4781
  let transformUVuePromise;
4823
4782
  function loadTransformUVue() {
4824
- transformUVuePromise ?? (transformUVuePromise = import("./transform-BVH7iLHn.js").then((mod) => mod.transformUVue));
4783
+ transformUVuePromise ?? (transformUVuePromise = import("./transform-CkEnJYIP.js").then((mod) => mod.transformUVue));
4825
4784
  return transformUVuePromise;
4826
4785
  }
4827
4786
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
@@ -4913,19 +4872,12 @@ function createUniAppXPlugins(options) {
4913
4872
  const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(sourceCode, id) : sourceCode, {
4914
4873
  ...hookContext,
4915
4874
  disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
4916
- sourceCandidates: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? [] : void 0,
4875
+ ...isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? { sourceCandidates: [] } : {},
4917
4876
  transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
4918
4877
  }) : void 0;
4919
- const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode) : generatedCss : sourceCode;
4878
+ const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss$1(generatedCss, sourceCode, { preserveRuntimeProperties: isWebGeneratorTarget() }) : generatedCss : sourceCode;
4920
4879
  const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
4921
- const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
4922
- reportStyleWarnings(postcssResult);
4923
- const rawPostcssMap = postcssResult.map.toJSON();
4924
- const postcssMap = await formatPostcssSourceMap(rawPostcssMap, normalizePath(cleanUrl$1(id)));
4925
- return {
4926
- code: postcssResult.css,
4927
- map: postcssMap
4928
- };
4880
+ return createUniAppXStyleResult(id, isWebGeneratorTarget() && typeof generatedCss === "string" && generatedCss.trim().length > 0 ? await postcss().process(styleCode, styleHandlerOptions.postcssOptions.options) : await styleHandler(styleCode, styleHandlerOptions));
4929
4881
  }
4930
4882
  }
4931
4883
  const harmonyApply = createUniAppXHarmonyApplyExpander({
@@ -5009,6 +4961,7 @@ function createUniAppXPlugins(options) {
5009
4961
  ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
5010
4962
  ...enablePageLocalStyle ? { enablePageLocalStyle } : {},
5011
4963
  native: true,
4964
+ localStyleVariants: !isNativeAppBuildTarget(id) && !isWebGeneratorTarget() ? true : void 0,
5012
4965
  ...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
5013
4966
  pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
5014
4967
  ...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
@@ -5319,6 +5272,7 @@ async function processRememberedCssReplay(options) {
5319
5272
  const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
5320
5273
  if (!rememberedCssSource) continue;
5321
5274
  const { sourceFile } = rememberedCssSource;
5275
+ if (normalizedBundleFiles.has(normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
5322
5276
  const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : normalizeMiniProgramImportShell(rememberedCssSource.rawSource, {
5323
5277
  cssOnly: true,
5324
5278
  outputFile,
@@ -5346,21 +5300,11 @@ async function processRememberedCssReplay(options) {
5346
5300
  const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
5347
5301
  const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
5348
5302
  const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
5349
- if (bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
5350
- const shouldMergeReplayIntoFrameworkRootTarget = outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
5351
- if (allRememberedSignaturesFresh) {
5352
- if (!shouldMergeReplayIntoFrameworkRootTarget) continue;
5353
- else {
5354
- const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
5355
- if (cachedCss != null) {
5356
- pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
5357
- metrics.css.cacheHits++;
5358
- debug("css replay cached result into framework root target: %s", outputFile);
5359
- continue;
5360
- }
5361
- debug("css replay framework root target cache miss, regenerate: %s", outputFile);
5362
- }
5363
- }
5303
+ const shouldMergeReplayIntoFrameworkRootTarget = [...frameworkRootImportShellTargetByFile ?? []].some(([file, target]) => normalizeOutputPathKey(target) === normalizeOutputPathKey(outputFile) && normalizedBundleFiles.has(normalizeOutputPathKey(file))) || outputFile !== rememberedOutputFile && normalizedBundleFiles.has(normalizeOutputPathKey(outputFile));
5304
+ const generatedReplayKey = createGeneratedReplayCacheKey(outputFile);
5305
+ activeViteCssCacheFiles.add(generatedReplayKey);
5306
+ const cachedGeneratedReplayCss = allRememberedSignaturesFresh && shouldMergeReplayIntoFrameworkRootTarget ? lastCssResultByFile.get(generatedReplayKey) : void 0;
5307
+ if (allRememberedSignaturesFresh && !shouldMergeReplayIntoFrameworkRootTarget) continue;
5364
5308
  const sourceTraceSources = scopedSourceCandidateSourceGetter ? await createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
5365
5309
  const sourceTraceTokenSources = sourceTraceSources ? createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
5366
5310
  const annotateCss = (css) => annotateCssSourceTrace(css, {
@@ -5410,6 +5354,20 @@ async function processRememberedCssReplay(options) {
5410
5354
  }));
5411
5355
  continue;
5412
5356
  }
5357
+ if (cachedGeneratedReplayCss) {
5358
+ cssTaskFactories.push(() => timeTask("css.replay", async () => {
5359
+ const start = performance.now();
5360
+ lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
5361
+ for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
5362
+ recordCssAssetResult?.(outputFile, cachedGeneratedReplayCss);
5363
+ pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedGeneratedReplayCss, sourceFile, outputFile, true));
5364
+ metrics.css.elapsed += measureElapsed(start);
5365
+ metrics.css.cacheHits++;
5366
+ onUpdate(outputFile, rememberedCssSource.rawSource, cachedGeneratedReplayCss);
5367
+ debug("css replay reuse generated cache: %s bytes=%d", outputFile, cachedGeneratedReplayCss.length);
5368
+ }));
5369
+ continue;
5370
+ }
5413
5371
  cssTaskFactories.push(() => timeTask("css.replay", async () => {
5414
5372
  const start = performance.now();
5415
5373
  const generated = await generateTailwindV4Css({
@@ -5426,11 +5384,12 @@ async function processRememberedCssReplay(options) {
5426
5384
  generatorPlatform,
5427
5385
  styleHandler,
5428
5386
  debug,
5429
- previousCss
5387
+ previousCss: shouldMergeReplayIntoFrameworkRootTarget ? void 0 : previousCss
5430
5388
  });
5431
5389
  const css = annotateCss(generated?.css ?? (await styleHandler(generatorRawSource, cssHandlerOptions)).css);
5432
5390
  lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
5433
5391
  rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
5392
+ rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, generatedReplayKey, css, cssRuntimeAffectingHash);
5434
5393
  for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
5435
5394
  if (generated) {
5436
5395
  registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
@@ -5490,7 +5449,7 @@ function createConfiguredCssSourceRegistry(options) {
5490
5449
  return {
5491
5450
  explicitCssEntryFiles,
5492
5451
  getSourceEntries,
5493
- normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || fallbackFile, options.outDir, options.opts),
5452
+ normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || (fallbackFile ?? ""), options.outDir, options.opts),
5494
5453
  resolveMatchedSourceOutputFile: (sourceFile) => resolveOutputFileFromMatchedCssSource({
5495
5454
  bundleFiles: options.bundleFiles,
5496
5455
  defaultStyleOutputExtension: options.defaultStyleOutputExtension,
@@ -6200,7 +6159,11 @@ function createGenerateBundleHook$1(context) {
6200
6159
  const jsEntries = snapshot.jsEntries;
6201
6160
  const getJsEntry = createJsEntryResolver(jsEntries);
6202
6161
  const transformFilterSignature = createTransformFilterSignature(opts.transform);
6203
- const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
6162
+ const jsFastPath = resolveGenerateBundleJsFastPath({
6163
+ experimentalJsFastPath: opts.experimentalJsFastPath,
6164
+ useIncrementalMode
6165
+ });
6166
+ const moduleGraphOptions = jsFastPath.moduleGraphEnabled ? createBundleModuleGraphOptions(outDir, jsEntries) : void 0;
6204
6167
  const hasRuntimeAffectingChanges = hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
6205
6168
  const runtimeStart = performance.now();
6206
6169
  const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
@@ -6310,7 +6273,7 @@ function createGenerateBundleHook$1(context) {
6310
6273
  debug
6311
6274
  });
6312
6275
  const createBaseHandlerOptions = createJsHandlerOptionsFactory({
6313
- getExperimentalJsFastPath: () => opts.experimentalJsFastPath ?? (resolvedConfig?.build?.watch != null ? "oxc" : false),
6276
+ getExperimentalJsFastPath: () => jsFastPath.experimentalJsFastPath,
6314
6277
  getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
6315
6278
  moduleGraph: moduleGraphOptions
6316
6279
  });
@@ -6683,8 +6646,11 @@ function createGenerateBundleHook(context) {
6683
6646
  const relationOwner = getActiveViteSourceOutputRelationOwner();
6684
6647
  const removalConsumer = relationOwner?.createRemovalConsumer();
6685
6648
  const rememberCssSource = context.rememberCssSource;
6649
+ const frameworkRootImportShellTargetByFile = context.frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map();
6650
+ const frameworkStyleMemory = createFrameworkStyleMemory(frameworkRootImportShellTargetByFile);
6686
6651
  const runtimeHandler = createGenerateBundleHook$1({
6687
6652
  ...context,
6653
+ frameworkRootImportShellTargetByFile,
6688
6654
  rememberCssSource: rememberCssSource ? (entry, cssRuntimeSignature) => {
6689
6655
  relationOwner?.recordOwnedOutput(entry.sourceFile, entry.outputFile);
6690
6656
  rememberCssSource(entry, cssRuntimeSignature);
@@ -6693,9 +6659,11 @@ function createGenerateBundleHook(context) {
6693
6659
  return async function generateBundle(options, bundle) {
6694
6660
  relationOwner?.recordBundle(bundle);
6695
6661
  const removedFiles = removalConsumer?.consume(Object.keys(bundle)) ?? [];
6662
+ const rememberFrameworkStyles = frameworkStyleMemory.prepare(bundle, removedFiles);
6696
6663
  beginCompilerShadowRun(context.runtimeState);
6697
6664
  const runRuntime = () => runWithRemovedBundleFiles(removedFiles, () => runtimeHandler.call(this, options, bundle));
6698
6665
  await (relationOwner ? withViteSourceOutputRelationOwner(relationOwner, runRuntime) : runRuntime());
6666
+ rememberFrameworkStyles();
6699
6667
  };
6700
6668
  }
6701
6669
  //#endregion
@@ -6748,6 +6716,20 @@ function linkEntryChunkStyles(bundle, options) {
6748
6716
  }
6749
6717
  }
6750
6718
  //#endregion
6719
+ //#region src/bundlers/vite/css-finalizer/final-assets.ts
6720
+ /** 按生成目标统一收尾已组装的 CSS 资产,供空资产和常规分支复用。 */
6721
+ function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
6722
+ if (isWebGeneratorTarget) return finalizeWebCssCalc(bundle, context);
6723
+ finalizeMiniProgramCssAssetStructures(bundle, {
6724
+ cssMatcher: context.opts.cssMatcher,
6725
+ debug: context.debug,
6726
+ files,
6727
+ isWebGeneratorTarget,
6728
+ onUpdate: context.opts.onUpdate,
6729
+ recordCssAssetResult: context.recordCssAssetResult
6730
+ });
6731
+ }
6732
+ //#endregion
6751
6733
  //#region src/bundlers/vite/css-finalizer/plugin.ts
6752
6734
  function createViteCssFinalizerOutputPlugin(context) {
6753
6735
  return {
@@ -6825,6 +6807,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6825
6807
  rootDir,
6826
6808
  sourceRoot
6827
6809
  })) {
6810
+ await finalizeWebCssCalc(bundle, context);
6828
6811
  finalizeCompilerShadowRun(runtimeState);
6829
6812
  finishTiming();
6830
6813
  return;
@@ -6948,7 +6931,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6948
6931
  const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
6949
6932
  recordTiming("assets.enumerate", enumerateStartedAt);
6950
6933
  if (entries.length === 0) {
6951
- await injectHarmonyBundleStyles(getRecordedGeneratorCandidates?.() ?? getSourceCandidates?.() ?? await ensureRuntimeClassSet());
6934
+ await injectHarmonyBundleStyles();
6952
6935
  collectViteProcessedCssAssets();
6953
6936
  injectViteProcessedCssIntoMainCss();
6954
6937
  linkEntryStyles();
@@ -6959,14 +6942,7 @@ function createViteCssFinalizerOutputPlugin(context) {
6959
6942
  onUpdate: trackFinalCssAssetUpdate,
6960
6943
  recordCssAssetResult
6961
6944
  });
6962
- finalizeMiniProgramCssAssetStructures(bundle, {
6963
- cssMatcher: opts.cssMatcher,
6964
- debug,
6965
- files: finalCssAssetFiles,
6966
- isWebGeneratorTarget,
6967
- onUpdate: opts.onUpdate,
6968
- recordCssAssetResult
6969
- });
6945
+ await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
6970
6946
  finalizeCompilerShadowRun(runtimeState);
6971
6947
  finishTiming();
6972
6948
  return;
@@ -7084,14 +7060,7 @@ function createViteCssFinalizerOutputPlugin(context) {
7084
7060
  onUpdate: trackFinalCssAssetUpdate,
7085
7061
  recordCssAssetResult
7086
7062
  });
7087
- finalizeMiniProgramCssAssetStructures(bundle, {
7088
- cssMatcher: opts.cssMatcher,
7089
- debug,
7090
- files: finalCssAssetFiles,
7091
- isWebGeneratorTarget,
7092
- onUpdate: opts.onUpdate,
7093
- recordCssAssetResult
7094
- });
7063
+ await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
7095
7064
  finalizeCompilerShadowRun(runtimeState);
7096
7065
  recordTiming("assets.write", writeStartedAt);
7097
7066
  finishTiming();
@@ -7317,7 +7286,7 @@ function isWebOrNativeAppPlatform(platform) {
7317
7286
  return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
7318
7287
  }
7319
7288
  function isInternalUserDefinedOptions(options) {
7320
- return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
7289
+ return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && "tailwindRuntime" in options && typeof options.tailwindRuntime === "object" && "refreshTailwindcssRuntime" in options && typeof options.refreshTailwindcssRuntime === "function";
7321
7290
  }
7322
7291
  function isNuxtPageHotModule(id) {
7323
7292
  if (typeof id !== "string") return false;
@@ -7327,6 +7296,41 @@ function isNuxtPageHotModule(id) {
7327
7296
  return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
7328
7297
  }
7329
7298
  //#endregion
7299
+ //#region src/bundlers/vite/shared/framework-runtime-configuration.ts
7300
+ const ENV_PLATFORM_KEYS = [
7301
+ "UNI_PLATFORM",
7302
+ "UNI_UTS_PLATFORM",
7303
+ "TARO_ENV",
7304
+ "MPX_CURRENT_TARGET_MODE",
7305
+ "MPX_CLI_MODE"
7306
+ ];
7307
+ /** 在配置基准确定后同步显式 CSS 入口,保留运行时与用户选项的一致性。 */
7308
+ function createFrameworkCssEntrySync(opts, rawCssEntries) {
7309
+ return (anchor) => {
7310
+ var _opts$tailwindcss;
7311
+ const entries = normalizeCssEntries(rawCssEntries, anchor ?? process.cwd());
7312
+ if (!entries) return false;
7313
+ const changed = !sameStringList(opts.cssEntries, entries);
7314
+ opts.cssEntries = entries;
7315
+ opts.tailwindcss ?? (opts.tailwindcss = {});
7316
+ (_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
7317
+ opts.tailwindcss.v4.cssEntries = entries;
7318
+ if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = entries;
7319
+ if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = entries;
7320
+ return changed;
7321
+ };
7322
+ }
7323
+ /** 按显式配置、框架环境与输出目录顺序解析当前样式平台。 */
7324
+ function resolveFrameworkStylePlatform(opts, outDir) {
7325
+ const explicit = normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
7326
+ if (explicit) return explicit;
7327
+ for (const key of ENV_PLATFORM_KEYS) {
7328
+ const platform = normalizeFrameworkStylePlatform(process.env[key], opts.appType);
7329
+ if (platform) return platform;
7330
+ }
7331
+ return inferPlatformFromOutDir(outDir);
7332
+ }
7333
+ //#endregion
7330
7334
  //#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
7331
7335
  function createFrameworkSourceCandidatesPlugin(options, apply) {
7332
7336
  const shouldSkipSourceCandidateState = () => options.shouldSkipSourceCandidateState?.() === true;
@@ -7360,7 +7364,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
7360
7364
  };
7361
7365
  return {
7362
7366
  name: `${vitePluginName}:source-candidates`,
7363
- apply,
7367
+ ...apply === void 0 ? {} : { apply },
7364
7368
  enforce: "pre",
7365
7369
  async load(id) {
7366
7370
  if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !isCSSRequest(id) || !shouldCollectTransformedSourceCandidates(id)) return;
@@ -7459,7 +7463,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
7459
7463
  mod.file
7460
7464
  ]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
7461
7465
  }
7462
- const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
7466
+ const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await readViteHmrSource(ctx) : void 0;
7463
7467
  if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
7464
7468
  options.rememberOriginalCssLayerSource(ctx.file, hotSource);
7465
7469
  await options.refreshTailwindRootCssSource(ctx.file, hotSource);
@@ -7546,13 +7550,6 @@ const debug = createDebug();
7546
7550
  const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
7547
7551
  const weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
7548
7552
  const generatorPlaceholderCssFile = path.join(weappTailwindcssPackageDir, "generator-placeholder.css");
7549
- const ENV_PLATFORM_KEYS = [
7550
- "UNI_PLATFORM",
7551
- "UNI_UTS_PLATFORM",
7552
- "TARO_ENV",
7553
- "MPX_CURRENT_TARGET_MODE",
7554
- "MPX_CLI_MODE"
7555
- ];
7556
7553
  function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7557
7554
  debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
7558
7555
  const capability = options.__internalViteCapabilityProfile ?? frameworkViteCapabilityProfile;
@@ -7560,23 +7557,12 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7560
7557
  const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
7561
7558
  const hasExplicitTailwindcssBasedir = typeof options.__internalViteRawExplicitTailwindcssBasedir === "boolean" ? options.__internalViteRawExplicitTailwindcssBasedir : typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
7562
7559
  const rawCssEntries = collectConfiguredCssEntries(rawOptions);
7563
- const opts = isInternalUserDefinedOptions(options) ? options : getCompilerContext({
7560
+ const deferredOptions = {
7564
7561
  ...options,
7565
7562
  __internalDeferMissingCssEntriesWarning: true
7566
- });
7567
- const syncCssEntriesFromAnchor = (anchor) => {
7568
- var _opts$tailwindcss;
7569
- const normalizedCssEntries = normalizeCssEntries(rawCssEntries, anchor ?? process.cwd());
7570
- if (!normalizedCssEntries) return false;
7571
- const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
7572
- opts.cssEntries = normalizedCssEntries;
7573
- opts.tailwindcss ?? (opts.tailwindcss = {});
7574
- (_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
7575
- opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
7576
- if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
7577
- if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
7578
- return changed;
7579
7563
  };
7564
+ const opts = isInternalUserDefinedOptions(options) ? options : getCompilerContext(deferredOptions);
7565
+ const syncCssEntriesFromAnchor = createFrameworkCssEntrySync(opts, rawCssEntries);
7580
7566
  syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
7581
7567
  const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
7582
7568
  const initialTailwindRuntime = tailwindRuntime;
@@ -7595,15 +7581,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7595
7581
  isWeb: () => resolveCurrentGeneratorBranch().isWeb
7596
7582
  });
7597
7583
  const hmrCssModuleVersions = createViteHmrCssModuleVersionTracker();
7598
- const resolveViteStylePlatform = () => {
7599
- const explicit = normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
7600
- if (explicit) return explicit;
7601
- for (const key of ENV_PLATFORM_KEYS) {
7602
- const envPlatform = normalizeFrameworkStylePlatform(process.env[key], opts.appType);
7603
- if (envPlatform) return envPlatform;
7604
- }
7605
- return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
7606
- };
7584
+ const resolveViteStylePlatform = () => resolveFrameworkStylePlatform(opts, resolvedConfig?.build?.outDir);
7607
7585
  const resolveGeneratorPlatform = () => opts.cssOptions?.platform ?? opts.platform ?? resolveViteStylePlatform();
7608
7586
  const resolveCurrentGeneratorOptions = () => normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
7609
7587
  appType: opts.appType,
@@ -7631,7 +7609,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
7631
7609
  const platform = resolveViteStylePlatform();
7632
7610
  if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb)) return code;
7633
7611
  let transformedCode = code;
7634
- if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { platform: resolveViteStylePlatform() });
7612
+ if (transformedCode.includes("#if")) transformedCode = compileCssMacroConditionalComments(transformedCode, { ...platform ? { platform } : {} });
7635
7613
  if (transformedCode.includes("@layer")) transformedCode = unwrapUnsupportedCascadeLayers(transformedCode);
7636
7614
  return transformedCode;
7637
7615
  };
@@ -8060,7 +8038,7 @@ ${previousTracedCss}`;
8060
8038
  });
8061
8039
  debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
8062
8040
  return `${createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}
8063
- ${tracedCss}`;
8041
+ ${tracedCss}${currentGeneratorBranch.isWeb ? `\n${createBundlerGeneratedCssEndMarker("vite", normalizeViteProcessedCssFile(file))}` : ""}`;
8064
8042
  };
8065
8043
  const generateTailwindCssForVitePipeline = createFrameworkCssGenerationQueue(normalizeGeneratedCssCacheFile, generateTailwindCssForVitePipelineNow);
8066
8044
  const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
@@ -8328,13 +8306,16 @@ function wrapPluginHook(hook, before) {
8328
8306
  before(...args);
8329
8307
  return hook.apply(this, args);
8330
8308
  };
8331
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
8332
- ...hook,
8333
- handler(...args) {
8334
- before(...args);
8335
- return hook.handler.apply(this, args);
8336
- }
8337
- };
8309
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
8310
+ const handler = hook.handler;
8311
+ return {
8312
+ ...hook,
8313
+ handler(...args) {
8314
+ before(...args);
8315
+ return handler.apply(this, args);
8316
+ }
8317
+ };
8318
+ }
8338
8319
  return hook;
8339
8320
  }
8340
8321
  function wrapPluginCloseBundle(hook, dispose) {
@@ -8345,16 +8326,19 @@ function wrapPluginCloseBundle(hook, dispose) {
8345
8326
  dispose.call(this);
8346
8327
  }
8347
8328
  };
8348
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return {
8349
- ...hook,
8350
- async handler(...args) {
8351
- try {
8352
- return await hook.handler.apply(this, args);
8353
- } finally {
8354
- dispose.call(this);
8329
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
8330
+ const handler = hook.handler;
8331
+ return {
8332
+ ...hook,
8333
+ async handler(...args) {
8334
+ try {
8335
+ return await handler.apply(this, args);
8336
+ } finally {
8337
+ dispose.call(this);
8338
+ }
8355
8339
  }
8356
- }
8357
- };
8340
+ };
8341
+ }
8358
8342
  return dispose;
8359
8343
  }
8360
8344
  function createViteFrameworkPlugins(options = {}, frameworkBranch) {
@@ -8366,11 +8350,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
8366
8350
  }
8367
8351
  const wrappedPlugins = plugins.map((plugin) => ({
8368
8352
  ...plugin,
8369
- watchChange: wrapPluginHook(plugin.watchChange, (id, change) => {
8353
+ watchChange: wrapPluginHook(plugin["watchChange"], (id, change) => {
8370
8354
  if (change?.event === "delete") relationOwner.removeSource(id);
8371
8355
  else relationOwner.observeSource(id);
8372
8356
  }),
8373
- handleHotUpdate: wrapPluginHook(plugin.handleHotUpdate, (context) => {
8357
+ handleHotUpdate: wrapPluginHook(plugin["handleHotUpdate"], (context) => {
8374
8358
  if (context?.file) relationOwner.observeSource(context.file);
8375
8359
  })
8376
8360
  }));
@@ -8409,12 +8393,8 @@ function createTaroAlipayBrowserslistAssetPlugin() {
8409
8393
  name: "weapp-tailwindcss:taro-alipay-browserslist-asset",
8410
8394
  enforce: "pre",
8411
8395
  generateBundle(_options, bundle) {
8412
- if (process.env.TARO_ENV !== "alipay") return;
8413
- bundle[".browserslistrc"] = {
8414
- type: "asset",
8415
- fileName: ".browserslistrc",
8416
- source: "defaults and fully supports es6-module"
8417
- };
8396
+ if (process.env["TARO_ENV"] !== "alipay") return;
8397
+ bundle[".browserslistrc"] = createReplayCssAsset(".browserslistrc", "defaults and fully supports es6-module");
8418
8398
  }
8419
8399
  };
8420
8400
  }
@@ -8620,7 +8600,7 @@ const uniAppXCssPipelineStrategy = {
8620
8600
  },
8621
8601
  transformGeneratedCss(css, context) {
8622
8602
  const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
8623
- const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
8603
+ const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss, { preserveRuntimeProperties: context.currentGeneratorBranch.isWeb }), context.currentGeneratorBranch.isWeb);
8624
8604
  return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
8625
8605
  }
8626
8606
  };
@@ -8744,7 +8724,7 @@ function resolveViteProfile(options, config, environmentName) {
8744
8724
  }
8745
8725
  const family = platformFamily(selectedPlatform ?? (config.build?.outDir ? path.basename(path.normalize(config.build.outDir)) : void 0));
8746
8726
  if (!explicitAppType && !(rawTarget !== "web" && family !== "web")) appType = void 0;
8747
- const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && rawTarget !== "app" && family !== "mini-program";
8727
+ const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && family !== "mini-program";
8748
8728
  const cssOnlyGenericWeb = isGenericWeb && (forceGenericWeb || rawTarget === void 0 && explicitAppType === void 0 && selectedPlatform === void 0);
8749
8729
  const capability = isGenericWeb ? {
8750
8730
  ...createGenericWebViteCapabilityProfile(options),
@@ -8769,8 +8749,8 @@ function resolveViteProfile(options, config, environmentName) {
8769
8749
  }
8770
8750
  function invokeHook(plugin, hookName, thisArg, args) {
8771
8751
  const hook = plugin?.[hookName];
8772
- if (typeof hook === "function") return hook.apply(thisArg, args);
8773
- if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return hook.handler.apply(thisArg, args);
8752
+ if (typeof hook === "function") return Reflect.apply(hook, thisArg, args);
8753
+ if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return Reflect.apply(hook.handler, thisArg, args);
8774
8754
  }
8775
8755
  function emitDeferredRuntimeLogs(opts, profile, rawOptions) {
8776
8756
  const hasExplicitLogLevel = Object.hasOwn(rawOptions, "logLevel");
@@ -8879,7 +8859,7 @@ function createDispatcher(options) {
8879
8859
  opts.appType = profile.appType;
8880
8860
  logger.debug("根据 Vite 项目根目录自动推断 appType -> %s", profile.appType);
8881
8861
  }
8882
- if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && opts.generator !== false && !options.platform && !options.cssOptions?.platform && !process.env["UNI_PLATFORM"] && !process.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
8862
+ if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && !options.platform && !options.cssOptions?.platform && !process.env["UNI_PLATFORM"] && !process.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
8883
8863
  const capability = opts.__internalViteCapabilityProfile;
8884
8864
  if (capability) Object.assign(capability, profile.capability);
8885
8865
  else opts.__internalViteCapabilityProfile = profile.capability;
@@ -8915,4 +8895,4 @@ function WeappTailwindcss(options = {}) {
8915
8895
  return createDispatcher(options);
8916
8896
  }
8917
8897
  //#endregion
8918
- export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, isUniAppXStyleSourceEmpty as o, shouldInjectBorderPreflight as r, WeappTailwindcss as t };
8898
+ export { shouldEnablePageLocalStyle as a, shouldEnableComponentLocalStyle as i, injectBorderPreflightClass as n, shouldInjectBorderPreflight as r, WeappTailwindcss as t };