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,12 +1,12 @@
1
- import { $ as hasTailwindRootDirectives, At as resolveTailwindV4CssSourceBase, B as removeUnsupportedMiniProgramAtRules, F as stripTailwindSourceMediaFragments, G as shouldFilterApplyOnlyGeneratedCss, H as removeTailwindV4GeneratedUserCssArtifacts, I as stripUnmatchedTailwindSourceMediaCloseFragments, J as splitUserCssLayerBlocks, K as extractGeneratedCssForUserLayerSelectors, L as finalizeMiniProgramCss$1, M as isCommentOnlyCss, Nt as parseCssImportSpecifier, P as removeTailwindV4GeneratorAtRules, Pt as quoteCssImportSpecifier, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, U as filterApplyOnlyGeneratedCss, Vt as loadTailwindV4DesignSystem, W as normalizeEmptyTailwindCustomVariants, Y as preferScopedGeneratedCssRules, Z as hasTailwindApplyDirective, _t as stripTailwindBanners, a as resolveGeneratorRuntimeBranch, at as removeTailwindSourceDirectives, ct as VITE_MARKER_RE, d as resolveTailwindV4SourceFromRuntime, dt as hasTailwindGeneratedCssMarkers, et as hasTailwindSourceDirectives, ft as splitGeneratorPlaceholderCssBySourceOrder, gt as stripTailwindBanner, ht as stripGeneratorPlaceholderMarkers, i as normalizeWeappTailwindcssGeneratorOptions, it as parseImportRequest, j as transformGeneratorUserCss, jt as toPosixPath, kt as resolveSourceScanPath, lt as createCssAppend, mt as splitTailwindV4GeneratedCssBySourceOrder, nt as normalizeTailwindSourceDirectives, ot as resolveCssEntrySource, p as resolveTailwindV4SourceOptionsFromRuntime, pt as splitTailwindGeneratedCssByBanner, q as hasUserCssLayerBlocks, s as shouldUseMiniProgramCssBranch, st as GENERATOR_PLACEHOLDER_MARKER_RE, u as resolveTailwindV4Source$1, ut as hasTailwindGeneratedCss, vt as normalizeConfigDirective, wt as isFileExcludedByTailwindSourceEntries, xt as FULL_SOURCE_SCAN_EXTENSION_RE, yt as prependConfigDirective, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-BgbYHNgD.js";
1
+ import { $ as hasTailwindApplyDirective, Ct as FULL_SOURCE_SCAN_EXTENSION_RE, Dt as isFileMatchedByTailwindSourceEntries, Et as isFileExcludedByTailwindSourceEntries, F as removeTailwindV4GeneratorAtRules, G as filterApplyOnlyGeneratedCss, I as stripTailwindSourceMediaFragments, J as extractGeneratedCssForUserLayerSelectors, K as normalizeEmptyTailwindCustomVariants, L as stripUnmatchedTailwindSourceMediaCloseFragments, M as transformGeneratorUserCss, Mt as resolveTailwindV4CssSourceBase, N as isCommentOnlyCss, Nt as toPosixPath, R as finalizeMiniProgramCss$1, T as omitUndefined, U as createGeneratedThemeDeclarationResolver, V as removeUnsupportedMiniProgramAtRules, Vt as loadTailwindV4DesignSystem, W as removeTailwindV4GeneratedUserCssArtifacts, X as splitUserCssLayerBlocks, Y as hasUserCssLayerBlocks, Z as preferScopedGeneratedCssRules, _t as stripGeneratorPlaceholderMarkers, a as resolveGeneratorRuntimeBranch, bt as normalizeConfigDirective, ct as resolveCssEntrySource, d as resolveTailwindV4SourceFromRuntime, dt as createCssAppend, ft as hasTailwindGeneratedCss, gt as splitTailwindV4GeneratedCssBySourceOrder, ht as splitTailwindGeneratedCssByBanner, i as normalizeWeappTailwindcssGeneratorOptions, it as normalizeTailwindSourceDirectives, jt as resolveSourceScanPath, lt as GENERATOR_PLACEHOLDER_MARKER_RE, mt as splitGeneratorPlaceholderCssBySourceOrder, nt as hasTailwindSourceDirectives, ot as parseImportRequest, p as resolveTailwindV4SourceOptionsFromRuntime, pt as hasTailwindGeneratedCssMarkers, q as shouldFilterApplyOnlyGeneratedCss, s as shouldUseMiniProgramCssBranch, st as removeTailwindSourceDirectives, tt as hasTailwindRootDirectives, u as resolveTailwindV4Source$1, ut as VITE_MARKER_RE, vt as stripTailwindBanner, xt as prependConfigDirective, yt as stripTailwindBanners, zt as filterUnsupportedMiniProgramTailwindV4Candidates } from "./generator-C0BJjyLM.js";
2
2
  import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.js";
3
- import { _ as includesTailwindV4PreflightDirective, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as collectCssInlineSourceCandidates } from "./tailwindcss-o3Xe-o7M.js";
4
- import { A as consumeCompilationScopeChanges, B as createGenerationArtifact, F as getCompilationSessionPool, G as replaceWxml, I as runCompilerOwnerActivity, J as traverse, K as createDebug, P as getTailwindGenerationSessionPool, R as mergeCompilationDependencyChanges, V as createAttributeMatcher, Y as md5Hash, k as composeGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as babelParse, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, z as createCssFragment } from "./compiler-CJ5yX-on.js";
3
+ import { _ as includesTailwindV4PreflightDirective, h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as collectCssInlineSourceCandidates } from "./tailwindcss-B_4E52WF.js";
4
+ import { A as consumeCompilationScopeChanges, B as createGenerationArtifact, F as getCompilationSessionPool, G as replaceWxml, I as runCompilerOwnerActivity, J as traverse, K as createDebug, P as getTailwindGenerationSessionPool, R as mergeCompilationDependencyChanges, V as createAttributeMatcher, Y as md5Hash, k as composeGenerationArtifact, l as recordCompilerShadowReport, m as resolveStyleOptionsFromContext, o as completeCompilerShadowReportRun, q as babelParse, r as createStylePlatformAdapter, s as getCompilerShadowRunRevision, u as getFrameworkCompilerSession, z as createCssFragment } from "./compiler-D3GBwxoa.js";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
8
8
  import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "@tailwindcss-mangle/engine";
9
- import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, filterExistingCssRules, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, normalizeMiniProgramGeneratedCssForPostcss, postcss, removeMatchingLocalCssImports, removeTailwindPostcssPlugins, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
9
+ import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, collectDedupedPostTransformCompatCss, collectGeneratedSelectors, compileTailwindAuthorFunctions, createTailwindAuthorFunctionProbe, filterExistingCssRules, inheritLegacyUnitConvertedDeclarations, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, normalizeMiniProgramGeneratedCssForPostcss, parseCssImportSpecifier, postcss, processFrameworkCss, quoteCssImportSpecifier, removeGeneratedSelectorCompatCss, removeMatchingLocalCssImports, removeTailwindApplyRules, removeTailwindPostcssPlugins, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
10
10
  import { LRUCache } from "lru-cache";
11
11
  import { readFile } from "node:fs/promises";
12
12
  import { Parser } from "htmlparser2";
@@ -1383,15 +1383,19 @@ function annotateCssSourceTrace(css, options) {
1383
1383
  const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/i;
1384
1384
  const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
1385
1385
  const BUNDLER_GENERATED_CSS_MARKER_CAPTURE_RE = /\/\*!?\s*weapp-tailwindcss (gulp|vite|webpack)-generated-css(?:\s*:\s*([^\s*]+))?\s*\*\/\s*/gi;
1386
+ const BUNDLER_GENERATED_CSS_END_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:gulp|vite|webpack)-generated-css-end\s*:\s*[^\s*]+\s*\*\/\s*/gi;
1386
1387
  const VITE_INTERNAL_CSS_MARKER_GLOBAL_RE = /\/\*\$vite\$:\d+\*\/\s*/g;
1387
1388
  function createBundlerGeneratedCssMarker(bundler, file) {
1388
1389
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
1389
1390
  }
1391
+ function createBundlerGeneratedCssEndMarker(bundler, file) {
1392
+ return `/*! weapp-tailwindcss ${bundler}-generated-css-end:${encodeURIComponent(file)} */`;
1393
+ }
1390
1394
  function hasBundlerGeneratedCssMarker(source) {
1391
1395
  return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
1392
1396
  }
1393
1397
  function stripBundlerGeneratedCssMarkers(source) {
1394
- return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "").replace(VITE_INTERNAL_CSS_MARKER_GLOBAL_RE, "");
1398
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "").replace(BUNDLER_GENERATED_CSS_END_MARKER_GLOBAL_RE, "").replace(VITE_INTERNAL_CSS_MARKER_GLOBAL_RE, "");
1395
1399
  }
1396
1400
  function parseBundlerGeneratedCssMarkerBlocks(source) {
1397
1401
  const blocks = [];
@@ -1559,21 +1563,21 @@ function createCssSourceOrderAppend(base, extra) {
1559
1563
  if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
1560
1564
  return `${base}\n${extra}`;
1561
1565
  }
1562
- const LEGACY_PSEUDO_ELEMENTS$1 = [
1566
+ const LEGACY_PSEUDO_ELEMENTS = [
1563
1567
  "before",
1564
1568
  "after",
1565
1569
  "first-letter",
1566
1570
  "first-line"
1567
1571
  ];
1568
1572
  const CSS_STRING_LITERAL_RE = /(["'])((?:\\[\s\S]|(?!\1)[\s\S])*)\1/g;
1569
- function isLegacyPseudoElementAt$1(selector, index) {
1570
- for (const name of LEGACY_PSEUDO_ELEMENTS$1) {
1573
+ function isLegacyPseudoElementAt(selector, index) {
1574
+ for (const name of LEGACY_PSEUDO_ELEMENTS) {
1571
1575
  if (!selector.startsWith(name, index)) continue;
1572
1576
  const next = selector[index + name.length];
1573
1577
  if (next === void 0 || !/[\w-]/.test(next)) return name;
1574
1578
  }
1575
1579
  }
1576
- function normalizeLegacyPseudoElements$1(selector) {
1580
+ function normalizeLegacyPseudoElements(selector) {
1577
1581
  let result = "";
1578
1582
  let quote;
1579
1583
  let bracketDepth = 0;
@@ -1615,7 +1619,7 @@ function normalizeLegacyPseudoElements$1(selector) {
1615
1619
  continue;
1616
1620
  }
1617
1621
  if (bracketDepth === 0 && char === ":") {
1618
- const name = isLegacyPseudoElementAt$1(selector, index + 1);
1622
+ const name = isLegacyPseudoElementAt(selector, index + 1);
1619
1623
  if (name) {
1620
1624
  result += `::${name}`;
1621
1625
  index += name.length + 1;
@@ -1628,7 +1632,7 @@ function normalizeLegacyPseudoElements$1(selector) {
1628
1632
  return result;
1629
1633
  }
1630
1634
  function normalizeCssRuleDeduplicationSelector(selector) {
1631
- return normalizeLegacyPseudoElements$1(selector).replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
1635
+ return normalizeLegacyPseudoElements(selector).replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
1632
1636
  }
1633
1637
  function normalizeCssRuleDeduplicationValue(value) {
1634
1638
  return value.replace(/\s+/g, " ").replace(CSS_STRING_LITERAL_RE, (_match, _quote, content) => {
@@ -1865,7 +1869,7 @@ function createFrameworkReplayArtifact(generated, options) {
1865
1869
  scope,
1866
1870
  stage: "raw"
1867
1871
  })], {
1868
- classSet: generated.classSet,
1872
+ classSet: new Set(generated.classSet),
1869
1873
  rawCandidates: new Set(options.rawCandidates),
1870
1874
  dependencies: generated.dependencies,
1871
1875
  sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
@@ -1873,7 +1877,9 @@ function createFrameworkReplayArtifact(generated, options) {
1873
1877
  });
1874
1878
  }
1875
1879
  async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options) {
1876
- const handled = await options.styleHandler(generated.css, createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file));
1880
+ const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1881
+ if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1882
+ const handled = await options.styleHandler(generated.css, handlerOptions);
1877
1883
  const preflightMode = generated.metadata?.preflightMode;
1878
1884
  const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
1879
1885
  const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
@@ -1885,6 +1891,7 @@ async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options)
1885
1891
  }
1886
1892
  async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, options) {
1887
1893
  const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
1894
+ if (generated.target === "web") return (await processFrameworkCss(generated.css, handlerOptions.postcssOptions)).css;
1888
1895
  const replayArtifact = createFrameworkReplayArtifact(generated, options);
1889
1896
  const handled = options.compiler && options.snapshot ? composeGenerationArtifact(await (async () => {
1890
1897
  for (const fragment of replayArtifact.fragments) {
@@ -1907,6 +1914,154 @@ async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, opti
1907
1914
  });
1908
1915
  }
1909
1916
  //#endregion
1917
+ //#region src/bundlers/shared/framework-css-composition.ts
1918
+ function nodeContent(node) {
1919
+ switch (node.type) {
1920
+ case "decl": return `decl\u0000${node.prop}\u0000${node.value}\u0000${node.important ? "1" : "0"}`;
1921
+ case "rule": return `rule\u0000${node.selectors.map((selector) => selector.trim()).join("")}\u0000${node.nodes.reduce((parts, child) => {
1922
+ if (child.type !== "comment") parts.push(nodeContent(child));
1923
+ return parts;
1924
+ }, []).join("")}`;
1925
+ case "atrule": return `atrule\u0000${node.name}\u0000${node.params}\u0000${node.nodes?.reduce((parts, child) => {
1926
+ if (child.type !== "comment") parts.push(nodeContent(child));
1927
+ return parts;
1928
+ }, []).join("") ?? ""}`;
1929
+ default: return `comment\u0000${node.text}`;
1930
+ }
1931
+ }
1932
+ function visitRules(container, context, visit) {
1933
+ container.each((node) => {
1934
+ if (node.type === "rule" || node.type === "atrule" && /^(?:font-face|(?:-\w+-)?keyframes)$/.test(node.name)) visit(node, `${context}\u0000${nodeContent(node)}`, context);
1935
+ else if (node.type === "atrule" && node.nodes && !(node.name === "layer" && !node.params.trim())) visitRules(node, `${context}\u0000${node.name}\u0000${node.params}`, visit);
1936
+ });
1937
+ }
1938
+ function collectRules(root) {
1939
+ const rules = [];
1940
+ visitRules(root, "", (node, key, context) => rules.push({
1941
+ node,
1942
+ key,
1943
+ context
1944
+ }));
1945
+ return rules;
1946
+ }
1947
+ function removeRules(container, removed, ruleKeys) {
1948
+ const nodes = container.nodes ?? [];
1949
+ const retained = [];
1950
+ for (const node of nodes) {
1951
+ if (removed.has(node)) continue;
1952
+ const key = ruleKeys.get(node);
1953
+ const previous = retained.at(-1);
1954
+ if (key && previous && key === ruleKeys.get(previous)) continue;
1955
+ if (node.type === "atrule" && node.nodes?.length) {
1956
+ removeRules(node, removed, ruleKeys);
1957
+ if (node.nodes.length === 0 && node.name !== "layer") continue;
1958
+ }
1959
+ retained.push(node);
1960
+ }
1961
+ if (retained.length !== nodes.length) {
1962
+ container.removeAll();
1963
+ container.append(retained);
1964
+ }
1965
+ }
1966
+ function matchOrderedPrefix(rules, positions) {
1967
+ const prefix = [];
1968
+ let previous = -1;
1969
+ for (const rule of rules) {
1970
+ const matches = positions.get(rule.key) ?? [];
1971
+ let left = 0;
1972
+ let right = matches.length;
1973
+ while (left < right) {
1974
+ const middle = left + right >>> 1;
1975
+ if (matches[middle] <= previous) left = middle + 1;
1976
+ else right = middle;
1977
+ }
1978
+ if (left === matches.length) break;
1979
+ previous = matches[left];
1980
+ prefix.push(previous);
1981
+ }
1982
+ return prefix;
1983
+ }
1984
+ /** 保留生成侧已确定的层位置;框架侧重复选择器及其间的覆盖区间按原顺序恢复。 */
1985
+ function composeFrameworkProcessedCss(before, generated, after) {
1986
+ if (!before.trim() && !after.trim()) return generated;
1987
+ const inputs = [
1988
+ before,
1989
+ generated,
1990
+ after
1991
+ ];
1992
+ try {
1993
+ const roots = inputs.map((css) => postcss.parse(css));
1994
+ const generatedRules = collectRules(roots[1]);
1995
+ const generatedKeys = new Set(generatedRules.map((rule) => rule.key));
1996
+ const positions = /* @__PURE__ */ new Map();
1997
+ generatedRules.forEach((rule, index) => {
1998
+ const matches = positions.get(rule.key) ?? [];
1999
+ matches.push(index);
2000
+ positions.set(rule.key, matches);
2001
+ });
2002
+ const frameworkRules = [...collectRules(roots[0]), ...collectRules(roots[2])];
2003
+ const ruleKeys = new Map([...generatedRules, ...frameworkRules].map((record) => [record.node, record.key]));
2004
+ const scopes = /* @__PURE__ */ new Map();
2005
+ for (const record of frameworkRules) {
2006
+ const rules = scopes.get(record.context) ?? [];
2007
+ rules.push(record);
2008
+ scopes.set(record.context, rules);
2009
+ }
2010
+ const preserve = /* @__PURE__ */ new Set();
2011
+ const generatedPrefix = /* @__PURE__ */ new Set();
2012
+ for (const rules of scopes.values()) {
2013
+ const ranges = /* @__PURE__ */ new Map();
2014
+ rules.forEach(({ node }, index) => {
2015
+ const selectors = node.type === "rule" ? node.selectors : [JSON.stringify([node.name, node.params])];
2016
+ for (const selector of selectors) {
2017
+ const range = ranges.get(selector);
2018
+ if (range) range[1] = index;
2019
+ else ranges.set(selector, [index, index]);
2020
+ }
2021
+ });
2022
+ const boundaries = new Int32Array(rules.length + 1);
2023
+ for (const [first, last] of ranges.values()) if (first !== last) {
2024
+ boundaries[first] += 1;
2025
+ boundaries[last + 1] -= 1;
2026
+ }
2027
+ let depth = 0;
2028
+ let start = 0;
2029
+ for (let index = 0; index < rules.length; index++) {
2030
+ const previousDepth = depth;
2031
+ depth += boundaries[index];
2032
+ if (previousDepth === 0 && depth > 0) start = index;
2033
+ if (depth > 0 && depth + boundaries[index + 1] === 0) {
2034
+ const group = rules.slice(start, index + 1);
2035
+ const prefix = matchOrderedPrefix(group, positions);
2036
+ if (prefix.length !== group.length) {
2037
+ prefix.forEach((position) => generatedPrefix.add(generatedRules[position].node));
2038
+ group.slice(prefix.length).forEach((record) => preserve.add(record));
2039
+ }
2040
+ }
2041
+ }
2042
+ }
2043
+ const restoredKeys = new Set([...preserve].map((record) => record.key));
2044
+ const removed = /* @__PURE__ */ new Set();
2045
+ for (const record of frameworkRules) if (!preserve.has(record) && generatedKeys.has(record.key)) removed.add(record.node);
2046
+ for (const record of generatedRules) if (restoredKeys.has(record.key) && !generatedPrefix.has(record.node)) removed.add(record.node);
2047
+ let charset;
2048
+ for (const root of roots) {
2049
+ removeRules(root, removed, ruleKeys);
2050
+ root.walkAtRules("charset", (rule) => {
2051
+ charset ?? (charset = rule.clone({ raws: {
2052
+ before: "",
2053
+ afterName: " "
2054
+ } }));
2055
+ rule.remove();
2056
+ });
2057
+ }
2058
+ const css = roots.map((root) => root.toString()).filter((value) => value.trim()).join("\n");
2059
+ return charset ? `${charset.toString()};\n${css}` : css;
2060
+ } catch {
2061
+ return inputs.filter((value) => value.trim()).join("\n");
2062
+ }
2063
+ }
2064
+ //#endregion
1910
2065
  //#region src/bundlers/shared/generator-css/user-layer-order.ts
1911
2066
  const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
1912
2067
  const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
@@ -2072,7 +2227,8 @@ function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
2072
2227
  }
2073
2228
  //#endregion
2074
2229
  //#region src/bundlers/shared/framework-user-css.ts
2075
- function normalizeUserSource(source) {
2230
+ function normalizeFrameworkProcessedUserCss(source) {
2231
+ if (!source.includes("source(")) return source;
2076
2232
  try {
2077
2233
  const root = postcss.parse(source);
2078
2234
  root.walkAtRules("media", (rule) => {
@@ -2084,8 +2240,11 @@ function normalizeUserSource(source) {
2084
2240
  }
2085
2241
  }
2086
2242
  async function restoreFrameworkProcessedUserCss(css, generated, source, options, generatorOptions) {
2243
+ const generatedSource = createGeneratedThemeDeclarationResolver([generated.metadata?.rawCss, css].filter(Boolean).join("\n"));
2087
2244
  const userCssOptions = {
2245
+ compileAuthorCssFunctions: generated.compileAuthorCssFunctions,
2088
2246
  generatorTarget: generated.target,
2247
+ generatedSource,
2089
2248
  generatorStyleOptions: resolveGeneratorStyleOptions(options.opts, options.cssHandlerOptions, generatorOptions.styleOptions),
2090
2249
  cssUserHandlerOptions: options.cssUserHandlerOptions,
2091
2250
  styleHandler: options.styleHandler,
@@ -2099,316 +2258,19 @@ async function restoreFrameworkProcessedUserCss(css, generated, source, options,
2099
2258
  injectPreflight: false,
2100
2259
  preservePreflight: generated.metadata?.preflightMode?.preserve,
2101
2260
  styleOptions: options.cssHandlerOptions
2102
- }));
2261
+ }), generatedSource);
2103
2262
  };
2104
- const userSource = normalizeUserSource(source);
2263
+ const userSource = normalizeFrameworkProcessedUserCss(source);
2105
2264
  const ordered = splitRawSourceByGeneratedCssOrder(userSource, generated.metadata?.rawCss ?? "") ?? {
2106
2265
  before: "",
2107
2266
  after: userSource
2108
2267
  };
2109
- const withBefore = createCssSourceOrderAppend(filterExistingCssRules(css, await transform(ordered.before)), css);
2110
- return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(withBefore, filterExistingCssRules(withBefore, await transform(ordered.after))));
2268
+ const before = await transform(ordered.before);
2269
+ const after = await transform(ordered.after);
2270
+ return stripTailwindBanners(reorderMarkedUserLayerComponentsCss(composeFrameworkProcessedCss(before, css, after)));
2111
2271
  }
2112
2272
  //#endregion
2113
2273
  //#region src/bundlers/shared/generator-css/legacy-selectors.ts
2114
- const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
2115
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
2116
- ":host",
2117
- "page",
2118
- ".tw-root",
2119
- "wx-root-portal-content"
2120
- ]);
2121
- const SPECIFICITY_PLACEHOLDER_RE = /:not\(#(?:\\#|n)\)/g;
2122
- const SELECTOR_CACHE_LIMIT = 64;
2123
- const LEGACY_PSEUDO_ELEMENTS = [
2124
- "before",
2125
- "after",
2126
- "first-letter",
2127
- "first-line"
2128
- ];
2129
- const generatedSelectorCache = /* @__PURE__ */ new Map();
2130
- function setGeneratedSelectorCache(css, selectors) {
2131
- if (generatedSelectorCache.size >= SELECTOR_CACHE_LIMIT) {
2132
- const firstKey = generatedSelectorCache.keys().next().value;
2133
- if (firstKey !== void 0) generatedSelectorCache.delete(firstKey);
2134
- }
2135
- generatedSelectorCache.set(css, selectors);
2136
- }
2137
- function normalizeCompatSelector(selector) {
2138
- return selector.replace(SPECIFICITY_PLACEHOLDER_RE, "").replace(/\s+/g, " ").trim();
2139
- }
2140
- function isLegacyPseudoElementAt(selector, index) {
2141
- for (const name of LEGACY_PSEUDO_ELEMENTS) {
2142
- if (!selector.startsWith(name, index)) continue;
2143
- const next = selector[index + name.length];
2144
- if (next === void 0 || !/[\w-]/.test(next)) return name;
2145
- }
2146
- }
2147
- function normalizeLegacyPseudoElements(selector) {
2148
- let result = "";
2149
- let quote;
2150
- let bracketDepth = 0;
2151
- let index = 0;
2152
- while (index < selector.length) {
2153
- const char = selector[index];
2154
- if (char === "\\") {
2155
- result += selector.slice(index, index + 2);
2156
- index += 2;
2157
- continue;
2158
- }
2159
- if (quote !== void 0) {
2160
- result += char;
2161
- if (char === quote) quote = void 0;
2162
- index += 1;
2163
- continue;
2164
- }
2165
- if (char === "\"" || char === "'") {
2166
- quote = char;
2167
- result += char;
2168
- index += 1;
2169
- continue;
2170
- }
2171
- if (char === "[") {
2172
- bracketDepth++;
2173
- result += char;
2174
- index += 1;
2175
- continue;
2176
- }
2177
- if (char === "]") {
2178
- bracketDepth = Math.max(0, bracketDepth - 1);
2179
- result += char;
2180
- index += 1;
2181
- continue;
2182
- }
2183
- if (bracketDepth === 0 && char === ":" && selector[index + 1] === ":") {
2184
- result += "::";
2185
- index += 2;
2186
- continue;
2187
- }
2188
- if (bracketDepth === 0 && char === ":") {
2189
- const name = isLegacyPseudoElementAt(selector, index + 1);
2190
- if (name) {
2191
- result += `::${name}`;
2192
- index += name.length + 1;
2193
- continue;
2194
- }
2195
- }
2196
- result += char;
2197
- index += 1;
2198
- }
2199
- return result;
2200
- }
2201
- function isClassSelectorTerminator(char) {
2202
- return /[\s>+~#,.:()[\]]/.test(char);
2203
- }
2204
- function unescapeSimpleCssIdent(value) {
2205
- return value.replaceAll(/\\(.)/g, "$1");
2206
- }
2207
- function escapeCompatSelectorClasses(selector) {
2208
- let result = "";
2209
- let index = 0;
2210
- let changed = false;
2211
- while (index < selector.length) {
2212
- const char = selector[index];
2213
- if (char !== ".") {
2214
- result += char;
2215
- index += 1;
2216
- continue;
2217
- }
2218
- let end = index + 1;
2219
- let className = "";
2220
- while (end < selector.length) {
2221
- const current = selector[end];
2222
- if (current === void 0) break;
2223
- if (current === "\\" && end + 1 < selector.length) {
2224
- const escaped = selector[end + 1];
2225
- if (escaped === void 0) break;
2226
- className += current + escaped;
2227
- end += 2;
2228
- continue;
2229
- }
2230
- if (isClassSelectorTerminator(current)) break;
2231
- className += current;
2232
- end += 1;
2233
- }
2234
- if (className.includes("\\")) {
2235
- result += `.${replaceWxml(unescapeSimpleCssIdent(className))}`;
2236
- changed = true;
2237
- } else result += `.${className}`;
2238
- index = end;
2239
- }
2240
- return changed ? result : selector;
2241
- }
2242
- function normalizeCompatSelectors(selector) {
2243
- const normalized = normalizeCompatSelector(selector);
2244
- if (!normalized) return [];
2245
- const selectors = /* @__PURE__ */ new Set([normalized]);
2246
- const escaped = normalizeCompatSelector(escapeCompatSelectorClasses(normalized));
2247
- if (escaped) selectors.add(escaped);
2248
- return [...selectors];
2249
- }
2250
- function normalizeCssSelector(selector) {
2251
- return normalizeLegacyPseudoElements(selector).trim().replace(/\s+/g, "");
2252
- }
2253
- function getCompatSelectorKeys(selector) {
2254
- return normalizeCompatSelectors(selector).map(normalizeCssSelector);
2255
- }
2256
- function getRuleCompatSelectorKeys(rule) {
2257
- return (rule.selectors?.length ? rule.selectors : [rule.selector]).flatMap((selector) => getCompatSelectorKeys(selector));
2258
- }
2259
- function hasClassSelector(selector) {
2260
- return CLASS_SELECTOR_RE.test(selector);
2261
- }
2262
- function getNormalizedSelectorList(selector) {
2263
- return selector.split(",").map(normalizeCssSelector).filter(Boolean);
2264
- }
2265
- function isMiniProgramThemeScopeSelector(selector) {
2266
- const selectors = getNormalizedSelectorList(selector);
2267
- return selectors.length > 0 && selectors.every((item) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(item));
2268
- }
2269
- function hasUtilityClassSelector(selector) {
2270
- return hasClassSelector(selector) && !isMiniProgramThemeScopeSelector(selector);
2271
- }
2272
- function isCustomPropertyOnlyRule(rule) {
2273
- let hasDeclaration = false;
2274
- let allCustomProperties = true;
2275
- rule.each((node) => {
2276
- if (node.type !== "decl") return;
2277
- hasDeclaration = true;
2278
- if (!node.prop.startsWith("--")) allCustomProperties = false;
2279
- });
2280
- return hasDeclaration && allCustomProperties;
2281
- }
2282
- function isPseudoContentInitRule(rule) {
2283
- let hasDeclaration = false;
2284
- let onlyContentVariable = true;
2285
- rule.each((node) => {
2286
- if (node.type !== "decl") return;
2287
- hasDeclaration = true;
2288
- if (node.prop !== "--tw-content") onlyContentVariable = false;
2289
- });
2290
- return hasDeclaration && onlyContentVariable;
2291
- }
2292
- function collectGeneratedSelectors(css) {
2293
- const cached = generatedSelectorCache.get(css);
2294
- if (cached) return cached;
2295
- const selectors = /* @__PURE__ */ new Set();
2296
- try {
2297
- postcss.parse(css).walkRules((rule) => {
2298
- if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
2299
- for (const selector of getRuleCompatSelectorKeys(rule)) selectors.add(selector);
2300
- });
2301
- } catch {
2302
- return selectors;
2303
- }
2304
- setGeneratedSelectorCache(css, selectors);
2305
- return selectors;
2306
- }
2307
- function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
2308
- const propsBySelector = /* @__PURE__ */ new Map();
2309
- try {
2310
- postcss.parse(generatedCss).walkRules((rule) => {
2311
- const matchedSelectors = getRuleCompatSelectorKeys(rule).filter((selector) => selectors.has(selector));
2312
- if (matchedSelectors.length === 0) return;
2313
- const props = /* @__PURE__ */ new Set();
2314
- rule.walkDecls((decl) => {
2315
- props.add(decl.prop);
2316
- });
2317
- for (const selector of matchedSelectors) {
2318
- const existing = propsBySelector.get(selector);
2319
- if (existing) for (const prop of props) existing.add(prop);
2320
- else propsBySelector.set(selector, new Set(props));
2321
- }
2322
- });
2323
- } catch {
2324
- return propsBySelector;
2325
- }
2326
- return propsBySelector;
2327
- }
2328
- function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
2329
- const nodeSelectors = getRuleCompatSelectorKeys(rule);
2330
- if (nodeSelectors.length === 0) return false;
2331
- const props = /* @__PURE__ */ new Set();
2332
- rule.walkDecls((decl) => {
2333
- props.add(decl.prop);
2334
- });
2335
- if (props.size === 0) return false;
2336
- for (const selector of nodeSelectors) {
2337
- const generatedProps = generatedDeclarationPropsBySelector.get(selector);
2338
- if (!generatedProps) continue;
2339
- if ([...props].every((prop) => generatedProps.has(prop))) return true;
2340
- }
2341
- return false;
2342
- }
2343
- function removeGeneratedSelectorCompatCss(css, generatedCss) {
2344
- const generatedSelectors = collectGeneratedSelectors(generatedCss);
2345
- if (generatedSelectors.size === 0) return css;
2346
- try {
2347
- const root = postcss.parse(css);
2348
- let removed = false;
2349
- root.walkRules((rule) => {
2350
- if (isPseudoContentInitRule(rule)) {
2351
- rule.remove();
2352
- removed = true;
2353
- return;
2354
- }
2355
- if (isCustomPropertyOnlyRule(rule) && !isPseudoContentInitRule(rule) && !hasUtilityClassSelector(rule.selector)) return;
2356
- if (getRuleCompatSelectorKeys(rule).some((selector) => generatedSelectors.has(selector))) {
2357
- rule.remove();
2358
- removed = true;
2359
- }
2360
- });
2361
- root.walkAtRules((atRule) => {
2362
- if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
2363
- });
2364
- return removed ? root.toString() : css;
2365
- } catch {
2366
- return css;
2367
- }
2368
- }
2369
- function collectDedupedPostTransformCompatCss(css, generatedCss) {
2370
- const generatedSelectors = collectGeneratedSelectors(generatedCss);
2371
- if (generatedSelectors.size === 0) return css;
2372
- const generatedDeclarationPropsBySelector = collectGeneratedDeclarationPropsBySelector(generatedCss, generatedSelectors);
2373
- const preservedNodes = [];
2374
- try {
2375
- const root = postcss.parse(css);
2376
- root.each((node) => {
2377
- if (node.type === "rule") {
2378
- const nodeSelectors = getRuleCompatSelectorKeys(node);
2379
- if (!nodeSelectors.some((selector) => generatedSelectors.has(selector))) {
2380
- preservedNodes.push(node.clone());
2381
- return;
2382
- }
2383
- if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
2384
- if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
2385
- const declarationProps = /* @__PURE__ */ new Set();
2386
- node.walkDecls((decl) => {
2387
- declarationProps.add(decl.prop);
2388
- });
2389
- for (const selector of nodeSelectors) {
2390
- const generatedProps = generatedDeclarationPropsBySelector.get(selector);
2391
- if (!generatedProps) continue;
2392
- for (const prop of generatedProps) declarationProps.delete(prop);
2393
- }
2394
- const nextRule = node.clone();
2395
- nextRule.walkDecls((decl) => {
2396
- if (!declarationProps.has(decl.prop)) decl.remove();
2397
- });
2398
- if (nextRule.nodes.length > 0) preservedNodes.push(nextRule);
2399
- }
2400
- return;
2401
- }
2402
- preservedNodes.push(node.clone());
2403
- });
2404
- if (preservedNodes.length === root.nodes.length) return css;
2405
- const nextRoot = postcss.root();
2406
- nextRoot.append(preservedNodes);
2407
- return nextRoot.toString();
2408
- } catch {
2409
- return css;
2410
- }
2411
- }
2412
2274
  function removeDuplicatedViteMarkers(css, baseCss) {
2413
2275
  if (!VITE_MARKER_RE.test(baseCss)) return css;
2414
2276
  VITE_MARKER_RE.lastIndex = 0;
@@ -3203,7 +3065,8 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
3203
3065
  }
3204
3066
  const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
3205
3067
  const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
3206
- const sourceSideCssSource = sourceSideEntrySource?.file && (sourceOptions?.cssEntries?.some((cssEntry) => path.resolve(cssEntry.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)) || isSfcStyleSourceRequest(file) && sourceOptions?.cssSources?.some((cssSource) => typeof cssSource.file === "string" && path.resolve(cssSource.file.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file))) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file, rawSource) : void 0;
3068
+ const shouldPreferMatchedSourceSideCssSource = sourceSideEntrySource?.file && (sourceOptions?.cssEntries?.some((cssEntry) => path.resolve(cssEntry.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)) || isSfcStyleSourceRequest(file) && sourceOptions?.cssSources?.some((cssSource) => typeof cssSource.file === "string" && path.resolve(cssSource.file.replace(/[?#].*$/, "")) === path.resolve(sourceSideEntrySource.file)));
3069
+ const sourceSideCssSource = normalizedSourceOptions && shouldPreferMatchedSourceSideCssSource ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file, rawSource) : void 0;
3207
3070
  if (sourceSideCssSource) return sourceSideCssSource;
3208
3071
  const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
3209
3072
  const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
@@ -3444,24 +3307,6 @@ function closeTrailingUnclosedBlocks(source) {
3444
3307
  return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
3445
3308
  }
3446
3309
  }
3447
- function removeTailwindApplyRules(rawSource) {
3448
- try {
3449
- const root = postcss.parse(rawSource);
3450
- let removed = false;
3451
- root.walkAtRules("apply", (rule) => {
3452
- const parent = rule.parent;
3453
- if (parent?.type === "rule") parent.remove();
3454
- else rule.remove();
3455
- removed = true;
3456
- });
3457
- root.walkAtRules((rule) => {
3458
- if (rule.nodes && rule.nodes.length === 0) rule.remove();
3459
- });
3460
- return removed ? root.toString() : rawSource;
3461
- } catch {
3462
- return rawSource;
3463
- }
3464
- }
3465
3310
  function resolveLegacyCompatCssSource(rawSource) {
3466
3311
  const cached = legacyCompatSourceCache.get(rawSource);
3467
3312
  if (cached !== void 0) return cached;
@@ -3524,8 +3369,9 @@ function hasConfiguredContainerCompatSources(sources) {
3524
3369
  async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions, options = {}) {
3525
3370
  const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
3526
3371
  const normalizedCompatSource = generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource;
3527
- const compatSource = options.preserveSelectorOverrides ? normalizedCompatSource : removeGeneratedSelectorCompatCss(normalizedCompatSource, css);
3528
- if (compatSource.trim().length === 0) return css;
3372
+ const filteredCompatSource = options.preserveSelectorOverrides ? normalizedCompatSource : removeGeneratedSelectorCompatCss(normalizedCompatSource, css);
3373
+ if (filteredCompatSource.trim().length === 0) return css;
3374
+ const compatSource = await options.compileAuthorCssFunctions?.(filteredCompatSource) ?? filteredCompatSource;
3529
3375
  if (generatorTarget !== "weapp") return createCssAppend(css, compatSource);
3530
3376
  const styleOptions = {
3531
3377
  ...cssHandlerOptions,
@@ -3537,7 +3383,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
3537
3383
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
3538
3384
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
3539
3385
  }
3540
- const transformedCompatCss = removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css));
3386
+ const transformedCompatCss = removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css), options.generatedSource ?? css);
3541
3387
  const cleanedCompatCss = options.preserveSelectorOverrides ? filterExistingCssRules(css, transformedCompatCss) : collectDedupedPostTransformCompatCss(transformedCompatCss, css);
3542
3388
  if (cleanedCompatCss.trim().length === 0) return css;
3543
3389
  return createCssAppend(css, cleanedCompatCss);
@@ -3562,50 +3408,6 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
3562
3408
  return createCssAppend(css, cleanedCompatCss);
3563
3409
  }
3564
3410
  //#endregion
3565
- //#region src/bundlers/shared/generator-css/legacy-units.ts
3566
- const CSS_LENGTH_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)(?:px|rem)\b/i;
3567
- const RPX_UNIT_RE = /(?:^|[\s(,])[-+]?(?:\d+|\d*\.\d+)rpx\b/i;
3568
- function createLegacyDeclarationValueMap(css) {
3569
- const values = /* @__PURE__ */ new Map();
3570
- postcss.parse(css).walkRules((rule) => {
3571
- if (!rule.selectors || rule.selectors.length === 0) return;
3572
- for (const selector of rule.selectors) {
3573
- const normalizedSelectors = normalizeCompatSelectors(selector);
3574
- rule.walkDecls((decl) => {
3575
- if (RPX_UNIT_RE.test(decl.value)) for (const normalizedSelector of normalizedSelectors) values.set(`${normalizedSelector}\n${decl.prop}`, decl.value);
3576
- });
3577
- }
3578
- });
3579
- return values;
3580
- }
3581
- function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
3582
- try {
3583
- const legacyValues = createLegacyDeclarationValueMap(legacyCss);
3584
- if (legacyValues.size === 0) return css;
3585
- const root = postcss.parse(css);
3586
- let changed = false;
3587
- root.walkRules((rule) => {
3588
- if (!rule.selectors || rule.selectors.length === 0) return;
3589
- const selectors = rule.selectors.flatMap((selector) => normalizeCompatSelectors(selector));
3590
- if (selectors.length === 0) return;
3591
- rule.walkDecls((decl) => {
3592
- if (!CSS_LENGTH_UNIT_RE.test(decl.value)) return;
3593
- for (const selector of selectors) {
3594
- const legacyValue = legacyValues.get(`${selector}\n${decl.prop}`);
3595
- if (legacyValue && legacyValue !== decl.value) {
3596
- decl.value = legacyValue;
3597
- changed = true;
3598
- return;
3599
- }
3600
- }
3601
- });
3602
- });
3603
- return changed ? root.toString() : css;
3604
- } catch {
3605
- return css;
3606
- }
3607
- }
3608
- //#endregion
3609
3411
  //#region src/bundlers/shared/generator-css/output-import-shell.ts
3610
3412
  const MINI_PROGRAM_OUTPUT_IMPORT_RE = /(@import\s+(?:url\(\s*)?)(["'])([^"']+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:[?#][^"']*)?)\2([^;]*;)/gi;
3611
3413
  const MINI_PROGRAM_OUTPUT_STYLE_RE = /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
@@ -3731,6 +3533,54 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
3731
3533
  queue.push(runWithConcurrency(factories, limit).then(() => void 0));
3732
3534
  }
3733
3535
  //#endregion
3536
+ //#region src/bundlers/shared/generator-css/user-css/compile-functions.ts
3537
+ const AUTHOR_THEME_FUNCTION_RE = /(?:^|[^-\w])(?:theme|--theme)\(/;
3538
+ const AUTHOR_SPACING_FUNCTION_RE = /(?:--spacing|--alpha)\(/;
3539
+ const GENERATED_AUTHOR_FUNCTION_SKIP_MAX_LENGTH = 8192;
3540
+ /**
3541
+ * 判断这段 CSS 是否还需要走作者函数编译。
3542
+ *
3543
+ * `theme()` / `--theme()` 一定要编译。`--spacing()` / `--alpha()` 只在短小的作者 CSS 里保留;
3544
+ * 大段或带生成标记的样式里它们通常已是 Tailwind 工具输出,再 parse 会拖垮 generateBundle。
3545
+ */
3546
+ function shouldCompileAuthorCssFunctions(css) {
3547
+ if (AUTHOR_THEME_FUNCTION_RE.test(css)) return true;
3548
+ if (!AUTHOR_SPACING_FUNCTION_RE.test(css)) return false;
3549
+ return css.length <= GENERATED_AUTHOR_FUNCTION_SKIP_MAX_LENGTH && !css.includes("weapp-tailwindcss") && !css.includes("tailwindcss v4");
3550
+ }
3551
+ function createAuthorCssFunctionCompiler(sources, session) {
3552
+ const cache = /* @__PURE__ */ new Map();
3553
+ return (css) => {
3554
+ if (!shouldCompileAuthorCssFunctions(css)) return Promise.resolve(css);
3555
+ return compileTailwindAuthorFunctions(css, async (values) => {
3556
+ const missing = [...new Set(values.filter((value) => !cache.has(value)))];
3557
+ if (missing.length > 0) {
3558
+ let selector = `.weapp-author-functions-${md5Hash(missing.join("\0"))}`;
3559
+ while (sources.some((source) => source.css.includes(selector))) selector += "-probe";
3560
+ const probe = createTailwindAuthorFunctionProbe(missing, selector);
3561
+ let resolved;
3562
+ for (const source of sources) {
3563
+ const result = await session.generate({
3564
+ ...source,
3565
+ css: `${source.css}\n${probe.css}`
3566
+ }, {
3567
+ candidates: [],
3568
+ scanSources: false,
3569
+ incrementalCache: false,
3570
+ target: "web"
3571
+ });
3572
+ const current = probe.read(result.rawCss);
3573
+ if (resolved && current.some((value, index) => value !== resolved[index])) throw new Error("作者样式函数匹配到多个不同的 Tailwind 配置上下文,无法安全回填。");
3574
+ resolved = current;
3575
+ }
3576
+ if (!resolved) throw new Error("作者样式函数缺少 Tailwind 编译上下文。");
3577
+ missing.forEach((value, index) => cache.set(value, resolved[index]));
3578
+ }
3579
+ return values.map((value) => cache.get(value));
3580
+ });
3581
+ };
3582
+ }
3583
+ //#endregion
3734
3584
  //#region src/bundlers/shared/generator-css/class-selectors.ts
3735
3585
  function normalizeCssClassSelector(value) {
3736
3586
  return value.replace(/\\([^\da-f\r\n])/gi, "$1").replace(/\\([\da-f]{1,6})\s?/gi, (_, code) => String.fromCodePoint(Number.parseInt(code, 16)));
@@ -3739,7 +3589,7 @@ function collectRawSourceClassSelectors(rawSource) {
3739
3589
  const selectors = /* @__PURE__ */ new Set();
3740
3590
  try {
3741
3591
  postcss.parse(rawSource).walkRules((rule) => {
3742
- for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) selectors.add(normalizeCssClassSelector(match[1]));
3592
+ for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) if (match[1]) selectors.add(normalizeCssClassSelector(match[1]));
3743
3593
  });
3744
3594
  } catch {}
3745
3595
  return selectors;
@@ -3816,6 +3666,8 @@ async function finalizeDeferredGeneratorCss(context) {
3816
3666
  if (generated.target !== "weapp" || generatedUserCssRawSource.trim().length === 0) return css;
3817
3667
  const userCssOptions = {
3818
3668
  generatorTarget: generated.target,
3669
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3670
+ generatedSource: generated.rawCss,
3819
3671
  generatorStyleOptions,
3820
3672
  cssUserHandlerOptions,
3821
3673
  styleHandler,
@@ -3840,8 +3692,9 @@ async function finalizeDeferredGeneratorCss(context) {
3840
3692
  };
3841
3693
  const canAppendIncrementalCss = generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource);
3842
3694
  const incrementalRawCss = generated.incrementalRawCss ?? generated.incrementalCss;
3843
- const shouldAppendIncrementalCss = canAppendIncrementalCss && typeof options.previousCss === "string" && typeof incrementalRawCss === "string";
3844
- const normalizedCss = shouldAppendIncrementalCss ? incrementalRawCss.trim().length > 0 ? createCssAppend(options.previousCss, await normalizeDeferredGeneratedCss(incrementalRawCss)) : options.previousCss : await normalizeDeferredGeneratedCss(generated.rawCss ?? generated.css);
3695
+ const previousCss = options.previousCss;
3696
+ const shouldAppendIncrementalCss = canAppendIncrementalCss && typeof previousCss === "string" && typeof incrementalRawCss === "string";
3697
+ const normalizedCss = shouldAppendIncrementalCss ? incrementalRawCss.trim().length > 0 ? createCssAppend(previousCss, await normalizeDeferredGeneratedCss(incrementalRawCss)) : previousCss : await normalizeDeferredGeneratedCss(generated.rawCss ?? generated.css);
3845
3698
  const intermediateCss = shouldAppendIncrementalCss ? normalizedCss : await restoreDeferredUserCss(normalizedCss);
3846
3699
  const css = restoreLocalCssImports(intermediateCss, localImports, { outputFile: file });
3847
3700
  return {
@@ -3849,7 +3702,7 @@ async function finalizeDeferredGeneratorCss(context) {
3849
3702
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, css, opts.escapeMap, options.previousClassSet),
3850
3703
  target: generated.target,
3851
3704
  source: "generator",
3852
- dependencies: generated.dependencies,
3705
+ dependencies: [...generated.dependencies],
3853
3706
  incremental: shouldAppendIncrementalCss,
3854
3707
  metadata: {
3855
3708
  file,
@@ -3870,6 +3723,8 @@ async function finalizeFallbackGeneratorCss(context) {
3870
3723
  let restoredDistinctUserLayerCss = false;
3871
3724
  if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend(await transformGeneratorUserCss(generatedUserCssRawSource, {
3872
3725
  generatorTarget: generated.target,
3726
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3727
+ generatedSource: generated.rawCss,
3873
3728
  generatorStyleOptions,
3874
3729
  cssUserHandlerOptions,
3875
3730
  styleHandler,
@@ -3882,6 +3737,8 @@ async function finalizeFallbackGeneratorCss(context) {
3882
3737
  const layerParts = splitUserCssLayerBlocks(generatorRawSource);
3883
3738
  const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
3884
3739
  generatorTarget: generated.target,
3740
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3741
+ generatedSource: generated.rawCss,
3885
3742
  generatorStyleOptions,
3886
3743
  cssUserHandlerOptions,
3887
3744
  styleHandler,
@@ -3900,6 +3757,8 @@ async function finalizeFallbackGeneratorCss(context) {
3900
3757
  if (hasDistinctUserRawSource && distinctUserLayerParts) {
3901
3758
  const layerUserCss = await transformGeneratorUserCss(distinctUserLayerParts.layer, {
3902
3759
  generatorTarget: generated.target,
3760
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3761
+ generatedSource: generated.rawCss,
3903
3762
  generatorStyleOptions,
3904
3763
  cssUserHandlerOptions,
3905
3764
  styleHandler,
@@ -3918,6 +3777,8 @@ async function finalizeFallbackGeneratorCss(context) {
3918
3777
  const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
3919
3778
  const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
3920
3779
  generatorTarget: generated.target,
3780
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3781
+ generatedSource: generated.rawCss,
3921
3782
  generatorStyleOptions,
3922
3783
  cssUserHandlerOptions,
3923
3784
  styleHandler,
@@ -3927,10 +3788,12 @@ async function finalizeFallbackGeneratorCss(context) {
3927
3788
  const missingUserCss = isCssAlreadyRepresentedByMarkers(css, distinctUserCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
3928
3789
  css = createCssSourceOrderAppend(css, missingUserCss);
3929
3790
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
3930
- const cleanedUserCssRawSource = removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource);
3791
+ const cleanedUserCssRawSource = removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource, generated.rawCss);
3931
3792
  const cleanedUserCssRestSource = restoredDistinctUserLayerCss && hasUserCssLayerBlocks(cleanedUserCssRawSource) ? splitUserCssLayerBlocks(cleanedUserCssRawSource).rest : cleanedUserCssRawSource;
3932
3793
  const userCss = await transformGeneratorUserCss(cleanedUserCssRestSource, {
3933
3794
  generatorTarget: generated.target,
3795
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3796
+ generatedSource: generated.rawCss,
3934
3797
  generatorStyleOptions,
3935
3798
  cssUserHandlerOptions,
3936
3799
  styleHandler,
@@ -3942,6 +3805,8 @@ async function finalizeFallbackGeneratorCss(context) {
3942
3805
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
3943
3806
  const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
3944
3807
  generatorTarget: generated.target,
3808
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3809
+ generatedSource: generated.rawCss,
3945
3810
  generatorStyleOptions,
3946
3811
  cssUserHandlerOptions,
3947
3812
  styleHandler,
@@ -3962,6 +3827,8 @@ async function finalizeFallbackGeneratorCss(context) {
3962
3827
  })) {
3963
3828
  const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
3964
3829
  generatorTarget: generated.target,
3830
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3831
+ generatedSource: generated.rawCss,
3965
3832
  generatorStyleOptions,
3966
3833
  cssUserHandlerOptions,
3967
3834
  styleHandler,
@@ -3981,7 +3848,7 @@ async function finalizeFallbackGeneratorCss(context) {
3981
3848
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
3982
3849
  target: generated.target,
3983
3850
  source: "generator",
3984
- dependencies: generated.dependencies,
3851
+ dependencies: [...generated.dependencies],
3985
3852
  metadata: {
3986
3853
  file,
3987
3854
  majorVersion,
@@ -3990,13 +3857,19 @@ async function finalizeFallbackGeneratorCss(context) {
3990
3857
  };
3991
3858
  }
3992
3859
  if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
3993
- css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, { preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides });
3860
+ css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, {
3861
+ preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides,
3862
+ generatedSource: generated.rawCss,
3863
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions
3864
+ });
3994
3865
  css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
3995
3866
  }
3996
3867
  if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !hasTailwindApplyDirective(generatedUserCssRawSource)) {
3997
3868
  const distinctUserCssRawSource = restoredDistinctUserLayerCss ? distinctUserLayerParts?.rest ?? generatedUserCssRawSource : generatedUserCssRawSource;
3998
3869
  const userCss = await transformGeneratorUserCss(distinctUserCssRawSource, {
3999
3870
  generatorTarget: generated.target,
3871
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3872
+ generatedSource: generated.rawCss,
4000
3873
  generatorStyleOptions,
4001
3874
  cssUserHandlerOptions,
4002
3875
  styleHandler,
@@ -4016,7 +3889,7 @@ async function finalizeFallbackGeneratorCss(context) {
4016
3889
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4017
3890
  target: generated.target,
4018
3891
  source: "generator",
4019
- dependencies: generated.dependencies,
3892
+ dependencies: [...generated.dependencies],
4020
3893
  metadata: {
4021
3894
  file,
4022
3895
  majorVersion,
@@ -4041,7 +3914,7 @@ async function finalizeOrderedGeneratorCss(context) {
4041
3914
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4042
3915
  target: generated.target,
4043
3916
  source: "generator",
4044
- dependencies: generated.dependencies,
3917
+ dependencies: [...generated.dependencies],
4045
3918
  incremental: true,
4046
3919
  metadata: {
4047
3920
  file,
@@ -4058,6 +3931,8 @@ async function finalizeOrderedGeneratorCss(context) {
4058
3931
  if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
4059
3932
  const userCssOptions = {
4060
3933
  generatorTarget: generated.target,
3934
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions,
3935
+ generatedSource: generated.rawCss,
4061
3936
  generatorStyleOptions,
4062
3937
  cssUserHandlerOptions,
4063
3938
  styleHandler,
@@ -4093,7 +3968,11 @@ async function finalizeOrderedGeneratorCss(context) {
4093
3968
  if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
4094
3969
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
4095
3970
  if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
4096
- css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, { preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides });
3971
+ css = await appendLegacyCompatCss(css, legacyCompatUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions, {
3972
+ preserveSelectorOverrides: shouldPreserveLegacyCompatSelectorOverrides,
3973
+ generatedSource: generated.rawCss,
3974
+ compileAuthorCssFunctions: context.compileAuthorCssFunctions
3975
+ });
4097
3976
  if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
4098
3977
  }
4099
3978
  } else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
@@ -4107,7 +3986,7 @@ async function finalizeOrderedGeneratorCss(context) {
4107
3986
  classSet: resolveGeneratedCssClassSet(generated.target, generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap, options.previousClassSet),
4108
3987
  target: generated.target,
4109
3988
  source: "generator",
4110
- dependencies: generated.dependencies,
3989
+ dependencies: [...generated.dependencies],
4111
3990
  metadata: {
4112
3991
  file,
4113
3992
  majorVersion,
@@ -4256,7 +4135,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4256
4135
  dependenciesBySource: results.map((result) => [result.sourceId, resolveCompilationDependencies(result.generated.dependencies)]),
4257
4136
  generated: merged,
4258
4137
  ...compilerSession ? (() => {
4259
- const snapshots = results.map((result) => result.generated.snapshot).filter((snapshot) => snapshot !== void 0);
4138
+ const snapshots = results.map((result) => "snapshot" in result.generated ? result.generated.snapshot : void 0).filter((snapshot) => snapshot !== void 0);
4260
4139
  return snapshots.length > 0 ? { snapshot: compilerSession.mergeSnapshots(snapshots) } : {};
4261
4140
  })() : {}
4262
4141
  } : void 0;
@@ -4292,7 +4171,10 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4292
4171
  });
4293
4172
  const filterGeneratedApplyOnlyCss = (css) => {
4294
4173
  if (!shouldFilterApplyOnlyCss) return css;
4295
- return filterApplyOnlyGeneratedCss(css, generatorRawSource, { preserveVariables: generated.target !== "web" });
4174
+ return filterApplyOnlyGeneratedCss(css, generatorRawSource, {
4175
+ preserveVariables: generated.target !== "web",
4176
+ preserveRuntimeProperties: generated.target === "web" && opts.appType === "uni-app-x"
4177
+ });
4296
4178
  };
4297
4179
  const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
4298
4180
  cssHandlerOptions,
@@ -4301,6 +4183,8 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4301
4183
  explicitCssSource: hasExplicitCssSource,
4302
4184
  primaryCssSource: hasOnlyPrimaryCssSource || hasPreflightCssSource || hasPreflightRawSource
4303
4185
  });
4186
+ const compileAuthorCssFunctions = createAuthorCssFunctionCompiler(preparedGenerationInputs.map((input) => input.generatorSource), generationSession);
4187
+ const frameworkProcessedUserCss = options.frameworkProcessedUserCss === void 0 ? void 0 : await compileAuthorCssFunctions(options.frameworkProcessedUserCss);
4304
4188
  const outputContext = {
4305
4189
  ...context,
4306
4190
  ...compilerSession && options.compilation?.preserveDeletedCss !== true ? { options: {
@@ -4308,6 +4192,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4308
4192
  previousClassSet: void 0,
4309
4193
  previousCss: void 0
4310
4194
  } } : {},
4195
+ compileAuthorCssFunctions,
4311
4196
  configuredContainerCompat,
4312
4197
  filterGeneratedApplyOnlyCss,
4313
4198
  generated,
@@ -4320,10 +4205,17 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
4320
4205
  shouldFilterApplyOnlyCss
4321
4206
  };
4322
4207
  const withCompilationMetadata = (result) => {
4208
+ if (result && frameworkProcessedUserCss !== void 0) result = {
4209
+ ...result,
4210
+ compileAuthorCssFunctions,
4211
+ frameworkProcessedUserCss
4212
+ };
4323
4213
  if (!result || compilationRevision === void 0) return result;
4324
4214
  return {
4325
4215
  ...result,
4216
+ ...generated.snapshot ? { snapshot: generated.snapshot } : {},
4326
4217
  metadata: {
4218
+ file,
4327
4219
  ...result.metadata,
4328
4220
  revision: compilationRevision
4329
4221
  }
@@ -4385,7 +4277,7 @@ async function generateCssByGenerator(options) {
4385
4277
  return useMiniProgramCssBranch ? normalizeMiniProgramGeneratorCssSource(css, file) : css;
4386
4278
  };
4387
4279
  const normalizeGeneratorSource = (source) => {
4388
- const css = normalizeGeneratorCssSource(source.css);
4280
+ const css = useMiniProgramCssBranch ? removeMiniProgramOutputImports(normalizeGeneratorCssSource(source.css)) : source.css;
4389
4281
  return css === source.css ? source : {
4390
4282
  ...source,
4391
4283
  css
@@ -4568,7 +4460,7 @@ function createCoreArtifact(generated, css, options) {
4568
4460
  scope,
4569
4461
  stage: "adapted"
4570
4462
  })], {
4571
- classSet: generated.classSet,
4463
+ classSet: new Set(generated.classSet),
4572
4464
  rawCandidates: options.runtime,
4573
4465
  dependencies: generated.dependencies,
4574
4466
  sourceEntries: options.cssHandlerOptions.sourceOptions?.cssEntries ?? [],
@@ -4585,10 +4477,11 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4585
4477
  tailwindcssMajorVersion: majorVersion,
4586
4478
  uniAppX: options.opts.uniAppX
4587
4479
  });
4588
- const shouldReplayFrameworkPostcss = options.cssStage === "framework-processed" && hasFrameworkPostcssOptions(frameworkPostcssOwner) && normalizedGeneratorOptions.target === "weapp";
4480
+ const shouldReplayFrameworkPostcss = options.cssStage === "framework-processed" && hasFrameworkPostcssOptions(frameworkPostcssOwner);
4589
4481
  const generationInput = !shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? {
4590
4482
  ...options,
4591
- userRawSource: [options.userRawSource, options.frameworkProcessedUserCss].filter(Boolean).join("\n")
4483
+ userRawSource: [options.userRawSource, options.frameworkProcessedUserCss].filter(Boolean).join("\n"),
4484
+ frameworkProcessedUserCss: void 0
4592
4485
  } : options;
4593
4486
  const scope = options.scope ?? {
4594
4487
  id: options.outputFile ?? options.file,
@@ -4596,13 +4489,14 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4596
4489
  };
4597
4490
  const generated = await generateCssByGenerator(shouldReplayFrameworkPostcss ? {
4598
4491
  ...generationInput,
4492
+ frameworkProcessedUserCss: options.frameworkProcessedUserCss === void 0 ? void 0 : normalizeFrameworkProcessedUserCss(options.frameworkProcessedUserCss),
4599
4493
  compilation: implementation.frameworkAdapter === "graph" ? {
4600
4494
  enabled: true,
4601
4495
  preserveDeletedCss: normalizedGeneratorOptions.hmr?.preserveDeletedCss ?? true,
4602
4496
  scope,
4603
4497
  ...options.compilationChanges === void 0 ? {} : { changes: options.compilationChanges }
4604
4498
  } : void 0,
4605
- deferCssAdaptation: true
4499
+ deferCssAdaptation: normalizedGeneratorOptions.target === "weapp"
4606
4500
  } : {
4607
4501
  ...generationInput,
4608
4502
  compilation: implementation.frameworkAdapter === "graph" ? {
@@ -4624,15 +4518,16 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
4624
4518
  snapshot: generated.snapshot
4625
4519
  } : {}
4626
4520
  }) : generated.css;
4627
- const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
4521
+ const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, generated.frameworkProcessedUserCss ?? options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
4628
4522
  const css = isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions)) ? preferScopedGeneratedCssRules(composedCss) : composedCss;
4629
- const classSet = options.frameworkProcessedUserCss ? resolveGeneratedCssClassSet(generated.target, generated.classSet, options.runtime, css, options.opts.escapeMap, options.previousClassSet) : generated.classSet;
4523
+ const classSet = options.frameworkProcessedUserCss ? resolveGeneratedCssClassSet(generated.target, generated.classSet, options.runtime, css, options.opts.escapeMap, options.previousClassSet) : new Set(generated.classSet);
4630
4524
  const artifact = implementation.emitArtifact ? createCoreArtifact({
4631
4525
  ...generated,
4632
4526
  classSet
4633
4527
  }, css, options) : void 0;
4528
+ const { compileAuthorCssFunctions: _compileAuthorCssFunctions, ...generatedRest } = generated;
4634
4529
  return {
4635
- ...generated,
4530
+ ...generatedRest,
4636
4531
  ...artifact ? { artifact } : {},
4637
4532
  css,
4638
4533
  classSet,
@@ -4753,4 +4648,4 @@ function createHmrTimingRecorder(bundler) {
4753
4648
  };
4754
4649
  }
4755
4650
  //#endregion
4756
- export { createCssSourceTraceCacheSignature as A, createSourceCandidateCollector as B, isSourceStyleRequest as C, parseBundlerGeneratedCssMarkerBlocks as D, hasBundlerGeneratedCssMarker as E, createEscapeFragments as F, resolveSourceCandidateScanFiles as G, isSourceCandidateRequest as H, isPureLocalCssImportWrapper as I, rewriteLocalCssImportRequestsForOutput as L, isCssSourceTraceEnabled as M, createRuntimeClassSetManager as N, stripBundlerGeneratedCssMarkers as O, collectStrictEscapedRuntimeCandidates as P, splitLocalCssImports as R, isSourcePreprocessorRequest as S, createBundlerGeneratedCssMarker as T, extractCandidatesFromSource as U, createSourceCandidateStore as V, createSourceCandidateEligibilityMatcher as W, captureResolvedFrameworkPostcssOptions as _, collectGeneratedRawSourceCandidatesFromCss as a, finalizeMiniProgramGeneratorCss as b, resolveTaskConcurrency as c, normalizeMiniProgramImportShell as d, scoreTailwindV4CssSourceFileMatch as f, captureFrameworkPostcssOptions as g, mergeMarkedUserLayerComponentsCss as h, validateCandidatesByGenerator as i, createCssTokenSourceMap as j, annotateCssSourceTrace as k, runWithConcurrency as l, extractMarkedUserLayerComponentsCss as m, emitHmrTiming as n, collectRawSourceClassSelectors as o, removeGeneratedSelectorCompatCss as p, generateTailwindV4Css as r, pushConcurrentTaskFactories as s, createHmrTimingRecorder as t, normalizeMiniProgramGeneratorCssSource as u, collectFrameworkPostcssOptionsFromLoaderEntries as v, stripRequestQuery as w, hasMiniProgramTailwindV4PreflightReset as x, createCssSourceOrderAppend as y, finalizeCompilerShadowRun as z };
4651
+ export { annotateCssSourceTrace as A, finalizeCompilerShadowRun as B, isSourceStyleRequest as C, hasBundlerGeneratedCssMarker as D, createBundlerGeneratedCssMarker as E, collectStrictEscapedRuntimeCandidates as F, createSourceCandidateEligibilityMatcher as G, createSourceCandidateStore as H, createEscapeFragments as I, resolveSourceCandidateScanFiles as K, isPureLocalCssImportWrapper as L, createCssTokenSourceMap as M, isCssSourceTraceEnabled as N, parseBundlerGeneratedCssMarkerBlocks as O, createRuntimeClassSetManager as P, rewriteLocalCssImportRequestsForOutput as R, isSourcePreprocessorRequest as S, createBundlerGeneratedCssEndMarker as T, isSourceCandidateRequest as U, createSourceCandidateCollector as V, extractCandidatesFromSource as W, captureResolvedFrameworkPostcssOptions as _, collectGeneratedRawSourceCandidatesFromCss as a, finalizeMiniProgramGeneratorCss as b, resolveTaskConcurrency as c, normalizeMiniProgramImportShell as d, scoreTailwindV4CssSourceFileMatch as f, captureFrameworkPostcssOptions as g, mergeMarkedUserLayerComponentsCss as h, validateCandidatesByGenerator as i, createCssSourceTraceCacheSignature as j, stripBundlerGeneratedCssMarkers as k, runWithConcurrency as l, extractMarkedUserLayerComponentsCss as m, emitHmrTiming as n, collectRawSourceClassSelectors as o, removeGeneratedSelectorCompatCss as p, generateTailwindV4Css as r, pushConcurrentTaskFactories as s, createHmrTimingRecorder as t, normalizeMiniProgramGeneratorCssSource as u, collectFrameworkPostcssOptionsFromLoaderEntries as v, stripRequestQuery as w, hasMiniProgramTailwindV4PreflightReset as x, createCssSourceOrderAppend as y, splitLocalCssImports as z };