weapp-tailwindcss 5.0.13 → 5.1.0

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 (178) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/auto-Ba6hDrse.mjs +13 -0
  4. package/dist/auto-DtU6f3X6.js +18 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
  7. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +21 -9
  8. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  9. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
  11. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
  12. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
  13. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  14. package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
  15. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  16. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  17. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  18. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  19. package/dist/bundlers/vite/css-memory.d.ts +10 -0
  20. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  21. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
  23. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +0 -1
  24. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +12 -0
  25. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +5 -0
  26. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
  27. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
  28. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
  29. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  30. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
  31. package/dist/bundlers/vite/generate-bundle.d.ts +3 -1
  32. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  33. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  34. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  35. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -5
  36. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  37. package/dist/bundlers/vite/source-candidates.d.ts +9 -2
  38. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
  39. package/dist/bundlers/vite/source-scan.d.ts +2 -2
  40. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  41. package/dist/bundlers/vite/utils.d.ts +1 -0
  42. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +24 -0
  43. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
  44. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  45. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
  46. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
  47. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  48. package/dist/cache/index.d.ts +1 -0
  49. package/dist/cli/mount-options.d.ts +2 -2
  50. package/dist/cli.js +124 -437
  51. package/dist/cli.mjs +120 -433
  52. package/dist/context/index.d.ts +3 -3
  53. package/dist/context/style-options.d.ts +4 -1
  54. package/dist/context/tailwindcss.d.ts +1 -1
  55. package/dist/{precheck-B0Z8yW7E.js → context-BHxLe743.js} +391 -153
  56. package/dist/{precheck-CRI90iL1.mjs → context-Mbzkek1q.mjs} +368 -137
  57. package/dist/core.js +15 -12
  58. package/dist/core.mjs +10 -7
  59. package/dist/css-macro.js +1 -1
  60. package/dist/css-macro.mjs +1 -1
  61. package/dist/{defaults-C_J_kBpw.js → defaults-CVcKbXBG.js} +4 -15
  62. package/dist/{defaults-Bqx18S1f.mjs → defaults-ZElj1zKc.mjs} +5 -10
  63. package/dist/defaults.d.ts +1 -7
  64. package/dist/defaults.js +1 -2
  65. package/dist/defaults.mjs +2 -2
  66. package/dist/generator/index.d.ts +6 -7
  67. package/dist/generator/options.d.ts +3 -3
  68. package/dist/generator/types.d.ts +9 -10
  69. package/dist/generator-9rUz4Hcb.js +170 -0
  70. package/dist/generator-Dc4qaPmT.mjs +123 -0
  71. package/dist/generator.js +10 -16
  72. package/dist/generator.mjs +3 -3
  73. package/dist/{gulp-XT8Jc7lH.js → gulp-B_sdP6dx.js} +47 -87
  74. package/dist/{gulp-DfOQERcV.mjs → gulp-uM36oIJs.mjs} +40 -80
  75. package/dist/gulp.js +1 -1
  76. package/dist/gulp.mjs +1 -1
  77. package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-BXMLsF4b.mjs} +1145 -842
  78. package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CogqkFaF.js} +1262 -881
  79. package/dist/index.js +4 -4
  80. package/dist/index.mjs +4 -4
  81. package/dist/js/fast-path/oxc.d.ts +4 -0
  82. package/dist/js/precheck.d.ts +1 -0
  83. package/dist/postcss.js +3 -4
  84. package/dist/postcss.mjs +2 -3
  85. package/dist/presets.js +9 -19
  86. package/dist/presets.mjs +8 -18
  87. package/dist/runtime-branch/create-branch.d.ts +2 -0
  88. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  89. package/dist/runtime-branch/index.d.ts +6 -0
  90. package/dist/runtime-branch/mini-program.d.ts +2 -0
  91. package/dist/runtime-branch/native-app.d.ts +2 -0
  92. package/dist/runtime-branch/platform.d.ts +6 -0
  93. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  94. package/dist/runtime-branch/types.d.ts +37 -0
  95. package/dist/runtime-branch/web.d.ts +2 -0
  96. package/dist/runtime-branch.d.ts +1 -0
  97. package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-2ybpptAK.js} +261 -19
  98. package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-Cvb5z1ha.mjs} +187 -17
  99. package/dist/tailwindcss/candidates.d.ts +7 -0
  100. package/dist/tailwindcss/index.d.ts +2 -2
  101. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  102. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  103. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  104. package/dist/tailwindcss/runtime-types.d.ts +86 -0
  105. package/dist/tailwindcss/runtime.d.ts +6 -6
  106. package/dist/tailwindcss/source-scan.d.ts +1 -1
  107. package/dist/tailwindcss/targets.d.ts +2 -2
  108. package/dist/tailwindcss/v4/config.d.ts +3 -3
  109. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  110. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  111. package/dist/tailwindcss/v4/index.d.ts +1 -1
  112. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  113. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  114. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  115. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  116. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  117. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  118. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  119. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  120. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  121. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  122. package/dist/tailwindcss/v4-engine/source.d.ts +23 -6
  123. package/dist/tailwindcss/v4-engine/types.d.ts +8 -9
  124. package/dist/tailwindcss/version.d.ts +1 -1
  125. package/dist/tailwindcss-DHIYcqXT.js +1523 -0
  126. package/dist/tailwindcss-wyUHrfil.mjs +1418 -0
  127. package/dist/{transform-YmrmxuF3.js → transform-CQVOgmzM.js} +17 -17
  128. package/dist/{transform-DfcEjsZF.mjs → transform-tExdt40m.mjs} +2 -2
  129. package/dist/typedoc.export.d.ts +1 -1
  130. package/dist/types/index.d.ts +16 -17
  131. package/dist/types/shared.d.ts +1 -1
  132. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  133. package/dist/types/user-defined-options/general.d.ts +5 -3
  134. package/dist/types/user-defined-options/important.d.ts +2 -2
  135. package/dist/uni-app-x/style-asset.d.ts +1 -0
  136. package/dist/v4-engine-CF9zt4Cw.mjs +2396 -0
  137. package/dist/v4-engine-D4ubP7N5.js +2778 -0
  138. package/dist/{vite-CXHVsHmX.js → vite-CP0ylSxZ.js} +1081 -542
  139. package/dist/{vite-DjI09vVN.mjs → vite-CPO83EhA.mjs} +916 -376
  140. package/dist/vite.js +1 -1
  141. package/dist/vite.mjs +1 -1
  142. package/dist/weapp-tw-css-import-rewrite-loader.js +5350 -4165
  143. package/dist/weapp-tw-runtime-classset-loader.js +15 -4
  144. package/dist/webpack-Bsek8VhR.js +2094 -0
  145. package/dist/webpack-BzqhJ8yK.mjs +2082 -0
  146. package/dist/webpack.js +1 -1
  147. package/dist/webpack.mjs +1 -1
  148. package/package.json +4 -5
  149. package/dist/auto-CTp6wE5a.js +0 -33
  150. package/dist/auto-Cl8_hsG6.mjs +0 -22
  151. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  152. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  153. package/dist/context/tailwindcss/rax.d.ts +0 -2
  154. package/dist/generator-CzpArpCL.js +0 -92
  155. package/dist/generator-ITLd7PTl.mjs +0 -67
  156. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  157. package/dist/tailwindcss/patcher.d.ts +0 -12
  158. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  159. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  160. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  161. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  162. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  163. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  164. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  165. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  166. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  167. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  168. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  169. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  170. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  171. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  172. package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
  173. package/dist/tailwindcss-DZEwT3C_.js +0 -613
  174. package/dist/v3-engine-2rrgylhn.js +0 -4686
  175. package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
  176. package/dist/webpack-BcPpnT90.mjs +0 -1184
  177. package/dist/webpack-CfkUkMXG.js +0 -1196
  178. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -1,14 +1,13 @@
1
- import { $ as loadTailwindV4DesignSystem, A as normalizeTailwindSourceDirectives, B as splitGeneratorPlaceholderCssBySourceOrder, C as resolveTailwindV4SourceFromPatcher, D as hasTailwindRootDirectives, E as hasTailwindApplyDirective, F as resolveCssEntrySource, G as stripTailwindBanners, H as splitTailwindV4GeneratedCssBySourceOrder, I as VITE_MARKER_RE, K as normalizeConfigDirective, L as createCssAppend, M as normalizeTailwindV3CssEntrySource, N as parseImportRequest, O as hasTailwindSourceDirectives, P as removeTailwindSourceDirectives, Q as filterUnsupportedMiniProgramTailwindV4Candidates, R as hasTailwindGeneratedCss, U as stripGeneratorPlaceholderMarkers, V as splitTailwindGeneratedCssByBanner, W as stripTailwindBanner, _ as resolveTailwindConfigEntriesFromCssCached, at as toPosixPath$1, et as FULL_SOURCE_SCAN_EXTENSION_RE, gt as omitUndefined, it as resolveTailwindV4CssSourceBase, n as resolveTailwindV3SourceFromPatcher, nt as normalizeLegacyContentEntries, ot as createDebug, q as prependConfigDirective, r as resolveTailwindV3SourceOptionsFromPatcher, rt as resolveSourceScanPath, t as resolveTailwindV3Source, tt as isFileMatchedByTailwindSourceEntries, u as getRuntimeClassSetSignature, v as resolveTailwindV4EntriesFromCss, w as resolveTailwindV4SourceOptionsFromPatcher, x as resolveTailwindV4Source$1, z as hasTailwindGeneratedCssMarkers } from "./v3-engine-C6eJ0YzK.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-ITLd7PTl.mjs";
3
- import { h as traverse, m as babelParse, p as replaceWxml, r as resolveStyleOptionsFromContext, x as md5Hash } from "./precheck-CRI90iL1.mjs";
4
- import { r as isUniAppXEnabled } from "./tailwindcss-DTq3uYBK.mjs";
5
- import { createRequire } from "node:module";
1
+ import { $ as isFileMatchedByTailwindSourceEntries, A as removeTailwindSourceDirectives, B as stripGeneratorPlaceholderMarkers, C as hasTailwindRootDirectives, D as normalizeTailwindSourceDirectives, F as hasTailwindGeneratedCss, H as stripTailwindBanners, I as hasTailwindGeneratedCssMarkers, L as splitGeneratorPlaceholderCssBySourceOrder, M as GENERATOR_PLACEHOLDER_MARKER_RE, N as VITE_MARKER_RE, P as createCssAppend, R as splitTailwindGeneratedCssByBanner, T as hasTailwindSourceDirectives, U as normalizeConfigDirective, V as stripTailwindBanner, W as prependConfigDirective, Y as FULL_SOURCE_SCAN_EXTENSION_RE, at as toPosixPath$1, ct as omitUndefined, i as resolveTailwindV4SourceOptionsFromRuntime, it as resolveTailwindV4CssSourceBase, j as resolveCssEntrySource, k as parseImportRequest, n as resolveTailwindV4SourceFromRuntime, rt as resolveSourceScanPath, st as filterUnsupportedMiniProgramTailwindV4Candidates, t as resolveTailwindV4Source$1, ut as loadTailwindV4DesignSystem, x as hasTailwindApplyDirective, z as splitTailwindV4GeneratedCssBySourceOrder } from "./v4-engine-CF9zt4Cw.mjs";
2
+ import { a as resolveGeneratorRuntimeBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch, t as createWeappTailwindcssGenerator } from "./generator-Dc4qaPmT.mjs";
3
+ import { S as md5Hash, h as traverse, m as babelParse, n as resolveStyleOptionsFromContext, p as replaceWxml, x as createDebug } from "./context-Mbzkek1q.mjs";
4
+ import { h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled } from "./tailwindcss-wyUHrfil.mjs";
6
5
  import { existsSync, readFileSync } from "node:fs";
7
6
  import path from "node:path";
8
7
  import process from "node:process";
9
- import { finalizeMiniProgramCss, postcss, pruneMiniProgramGeneratedCss, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules } from "@weapp-tailwindcss/postcss";
8
+ import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "@tailwindcss-mangle/engine";
9
+ import { filterExistingCssRules, finalizeMiniProgramCss, hasMiniProgramCssSpecificityPlaceholders, postcss, pruneMiniProgramGeneratedCss, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules, stripMiniProgramCssSpecificityPlaceholders } from "@weapp-tailwindcss/postcss";
10
10
  import { LRUCache } from "lru-cache";
11
- import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "tailwindcss-patch";
12
11
  import { readFile } from "node:fs/promises";
13
12
  import { MappingChars2String, unescape } from "@weapp-core/escape";
14
13
  //#region src/bundlers/shared/cache.ts
@@ -130,12 +129,14 @@ function annotateCssSourceTrace(css, options) {
130
129
  }
131
130
  //#endregion
132
131
  //#region src/bundlers/shared/generator-css/generation-helpers.ts
133
- function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
132
+ function hasMiniProgramTailwindV4PreflightReset(css) {
133
+ return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
134
+ }
135
+ function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
134
136
  if (target !== "weapp") return css;
135
137
  return finalizeMiniProgramCss(css, {
136
- cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
137
- isTailwindcssV4: majorVersion === 4,
138
- preservePseudoContentInit: majorVersion === 3,
138
+ cssPreflight: options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css) ? cssPreflight : void 0,
139
+ isTailwindcssV4: true,
139
140
  tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
140
141
  });
141
142
  }
@@ -145,11 +146,6 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
145
146
  return isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
146
147
  }
147
148
  function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
148
- if (options.majorVersion === 3 && !options.isolateCssSource) return new Set([
149
- ...scopedRuntime,
150
- ...runtime,
151
- ...options.currentCssCandidates ?? []
152
- ]);
153
149
  if (options.isolateCssSource) {
154
150
  if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
155
151
  return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
@@ -157,24 +153,24 @@ function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
157
153
  if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
158
154
  return new Set([...scopedRuntime, ...runtime]);
159
155
  }
160
- function shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, options) {
156
+ function shouldIsolateScopedCssSource(_majorVersion, source, sourceEntries, options) {
161
157
  if (options.target !== "weapp") return false;
162
158
  if (source.__weappTailwindcssMeta?.isolateCssSource) return true;
163
159
  if (source.__weappTailwindcssMeta?.matchedCssSourceFile && (sourceEntries?.length ?? 0) > 0) return true;
164
160
  if (sourceEntries?.length === 0) return false;
165
- return (majorVersion === 3 || majorVersion === 4) && sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
161
+ return sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
166
162
  }
167
- function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
168
- return majorVersion === 4 && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(options.rawSource) && !hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
163
+ function shouldIsolateCurrentTailwindV4CssCandidates(_majorVersion, cssHandlerOptions, options) {
164
+ return !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(options.rawSource) && !hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
169
165
  }
170
166
  function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
171
- if (majorVersion !== 4) return false;
167
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
172
168
  if (target === "web") return true;
173
169
  if (isolateCssSource) return false;
174
170
  return generatorRuntime.size === 0;
175
171
  }
176
- function shouldAppendWebBundleCssFallback(target, options) {
177
- return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
172
+ function shouldAppendWebBundleCssFallback(target, _options) {
173
+ return target === "web";
178
174
  }
179
175
  function isEmptyCssSourceOrderParts(parts) {
180
176
  return parts.before.trim().length === 0 && parts.after.trim().length === 0;
@@ -212,7 +208,9 @@ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
212
208
  }
213
209
  function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
214
210
  const hasApplyDirectives = hasTailwindApplyDirective(options.rawSource);
215
- return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || cssHandlerOptions.isMainChunk;
211
+ const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
212
+ const hasSourceCssDirectives = typeof sourceCss === "string" && (hasTailwindRootDirectives(sourceCss, { importFallback: true }) || hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || hasTailwindApplyDirective(sourceCss));
213
+ return options.forceGenerator === true || options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || hasSourceCssDirectives;
216
214
  }
217
215
  function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
218
216
  return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
@@ -234,10 +232,6 @@ function mergeGeneratorResults(generatedResults) {
234
232
  sources: generatedResults.flatMap((item) => item.sources)
235
233
  };
236
234
  }
237
- const SUPPORTED_GENERATOR_MAJOR_VERSIONS$1 = new Set([3, 4]);
238
- function isSupportedGeneratorMajorVersion(majorVersion) {
239
- return SUPPORTED_GENERATOR_MAJOR_VERSIONS$1.has(majorVersion ?? 0);
240
- }
241
235
  //#endregion
242
236
  //#region src/bundlers/shared/generator-css/legacy-selectors.ts
243
237
  const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
@@ -387,6 +381,21 @@ function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
387
381
  }
388
382
  return propsBySelector;
389
383
  }
384
+ function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
385
+ const nodeSelectors = getRuleCompatSelectorKeys(rule);
386
+ if (nodeSelectors.length === 0) return false;
387
+ const props = /* @__PURE__ */ new Set();
388
+ rule.walkDecls((decl) => {
389
+ props.add(decl.prop);
390
+ });
391
+ if (props.size === 0) return false;
392
+ for (const selector of nodeSelectors) {
393
+ const generatedProps = generatedDeclarationPropsBySelector.get(selector);
394
+ if (!generatedProps) continue;
395
+ if ([...props].every((prop) => generatedProps.has(prop))) return true;
396
+ }
397
+ return false;
398
+ }
390
399
  function removeGeneratedSelectorCompatCss(css, generatedCss) {
391
400
  const generatedSelectors = collectGeneratedSelectors(generatedCss);
392
401
  if (generatedSelectors.size === 0) return css;
@@ -427,6 +436,7 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
427
436
  preservedNodes.push(node.clone());
428
437
  return;
429
438
  }
439
+ if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
430
440
  if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
431
441
  const declarationProps = /* @__PURE__ */ new Set();
432
442
  node.walkDecls((decl) => {
@@ -463,6 +473,16 @@ function removeDuplicatedViteMarkers(css, baseCss) {
463
473
  //#endregion
464
474
  //#region src/bundlers/shared/generator-css/source-files.ts
465
475
  const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
476
+ const STYLE_IMPORT_EXTENSIONS = [
477
+ ".css",
478
+ ".scss",
479
+ ".sass",
480
+ ".less",
481
+ ".styl",
482
+ ".stylus",
483
+ ".pcss",
484
+ ".postcss"
485
+ ];
466
486
  function stripStyleExtension(file) {
467
487
  const normalized = file.replace(/[?#].*$/, "");
468
488
  const ext = path.extname(normalized);
@@ -570,15 +590,71 @@ function extractStyleDirectiveSources(source) {
570
590
  if (styleSources.length > 0) return styleSources;
571
591
  return hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
572
592
  }
593
+ function extractSfcStyleSources(source) {
594
+ const styleSources = [];
595
+ SFC_STYLE_BLOCK_RE.lastIndex = 0;
596
+ let match = SFC_STYLE_BLOCK_RE.exec(source);
597
+ while (match !== null) {
598
+ styleSources.push(match[1] ?? "");
599
+ match = SFC_STYLE_BLOCK_RE.exec(source);
600
+ }
601
+ return styleSources;
602
+ }
603
+ function isLocalStyleImportRequest(request) {
604
+ return typeof request === "string" && request.length > 0 && (request.startsWith(".") || request.startsWith("/"));
605
+ }
606
+ function resolveLocalStyleImportFile(request, base) {
607
+ const normalized = (path.isAbsolute(request) ? request : path.resolve(base, request)).replace(/[?#].*$/, "");
608
+ if (existsSync(normalized)) return normalized;
609
+ if (path.extname(normalized)) return;
610
+ for (const extension of STYLE_IMPORT_EXTENSIONS) {
611
+ const candidate = `${normalized}${extension}`;
612
+ if (existsSync(candidate)) return candidate;
613
+ }
614
+ }
615
+ function collectLocalStyleImportFiles(source, base) {
616
+ const files = [];
617
+ const sources = extractSfcStyleSources(source);
618
+ if (sources.length === 0) sources.push(source);
619
+ for (const styleSource of sources) try {
620
+ postcss.parse(styleSource).walkAtRules("import", (rule) => {
621
+ const request = parseImportRequest(rule.params);
622
+ if (!isLocalStyleImportRequest(request)) return;
623
+ const file = resolveLocalStyleImportFile(request, base);
624
+ if (file) files.push(file);
625
+ });
626
+ } catch {}
627
+ return files;
628
+ }
629
+ function extractStyleDirectiveSourcesDeep(source, sourceFile, seen) {
630
+ const ownSources = extractStyleDirectiveSources(source);
631
+ if (ownSources.length > 0) return ownSources.map((styleSource) => ({
632
+ source: styleSource,
633
+ file: sourceFile
634
+ }));
635
+ const sources = [];
636
+ const base = path.dirname(sourceFile);
637
+ for (const importedFile of collectLocalStyleImportFiles(source, base)) {
638
+ const normalizedImportedFile = path.resolve(importedFile);
639
+ if (seen.has(normalizedImportedFile)) continue;
640
+ seen.add(normalizedImportedFile);
641
+ try {
642
+ const importedSource = readFileSync(normalizedImportedFile, "utf8");
643
+ sources.push(...extractStyleDirectiveSourcesDeep(importedSource, normalizedImportedFile, seen));
644
+ } catch {}
645
+ }
646
+ return sources;
647
+ }
573
648
  function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
574
649
  for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
575
650
  const source = sourceOptions.sourceFile && path.resolve(sourceOptions.sourceFile) === path.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : existsSync(sourceFile) ? readFileSync(sourceFile, "utf8") : void 0;
576
651
  if (source === void 0) continue;
577
- for (const styleSource of extractStyleDirectiveSources(source)) {
578
- const cssEntrySource = resolveCssEntrySource(styleSource, path.dirname(sourceFile), resolveOptions);
652
+ const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, new Set([path.resolve(sourceFile)]));
653
+ for (const styleSource of directiveSources) {
654
+ const cssEntrySource = resolveCssEntrySource(styleSource.source, path.dirname(styleSource.file), resolveOptions);
579
655
  if (cssEntrySource) return {
580
656
  ...cssEntrySource,
581
- file: sourceFile
657
+ file: styleSource.file
582
658
  };
583
659
  }
584
660
  } catch {
@@ -588,14 +664,40 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
588
664
  //#endregion
589
665
  //#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
590
666
  function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
591
- if (!hasTailwindApplyDirective(css) || hasTailwindRootDirectives(css)) return css;
592
- const utilities = collectTailwindApplyUtilities(css);
667
+ return createTailwindV4SourceReferenceSource(css, sourceOptions);
668
+ }
669
+ function createTailwindV4SourceReferenceSource(css, sourceOptions) {
670
+ if (hasTailwindV4RootImport(css, sourceOptions)) return css;
671
+ const hasApplyDirective = hasTailwindApplyDirective(css);
672
+ if (!hasApplyDirective && !hasTailwindSourceDirectives(css, { importFallback: true })) return css;
673
+ const utilities = hasApplyDirective ? collectTailwindApplyUtilities(css) : [];
593
674
  return [
594
675
  `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
595
676
  utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
596
677
  css
597
678
  ].filter(Boolean).join("\n");
598
679
  }
680
+ function hasTailwindV4RootImport(css, sourceOptions) {
681
+ try {
682
+ const root = postcss.parse(css);
683
+ let found = false;
684
+ root.walkAtRules((rule) => {
685
+ if (rule.name === "tailwind") {
686
+ found = true;
687
+ return false;
688
+ }
689
+ if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
690
+ const request = parseImportRequest(rule.params);
691
+ if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
692
+ found = true;
693
+ return false;
694
+ }
695
+ });
696
+ return found;
697
+ } catch {
698
+ return /@(?:import|use|forward|tailwind)(?:[\s"'(;]|$)/.test(css) && (css.includes("tailwindcss") || css.includes("tailwindcss4") || css.includes("weapp-tailwindcss"));
699
+ }
700
+ }
599
701
  function collectTailwindApplyUtilities(css) {
600
702
  let root;
601
703
  try {
@@ -642,10 +744,6 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
642
744
  function normalizeCssSourceForCompare(css) {
643
745
  return stripGeneratorPlaceholderMarkers(stripTailwindBanners(css)).trim();
644
746
  }
645
- function getOutputFileStem(file) {
646
- const normalized = file.replace(/[?#].*$/, "");
647
- return path.basename(normalized, path.extname(normalized));
648
- }
649
747
  function getOutputFileWithoutExtension(file) {
650
748
  const normalized = file.replace(/[?#].*$/, "");
651
749
  const ext = path.extname(normalized);
@@ -654,6 +752,12 @@ function getOutputFileWithoutExtension(file) {
654
752
  function normalizeMatchPath(file) {
655
753
  return file.split(path.sep).join("/");
656
754
  }
755
+ function stripBundlerContentHash(name) {
756
+ return name.replace(/[._-]?[a-f0-9]{6,32}$/i, "");
757
+ }
758
+ function getMatchBasename(file) {
759
+ return stripBundlerContentHash(path.basename(getOutputFileWithoutExtension(file.replace(/[?#].*$/, ""))));
760
+ }
657
761
  function isPathWithinRoot(file, root) {
658
762
  const relative = path.relative(root, file);
659
763
  return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
@@ -663,11 +767,7 @@ function collectCssSourceMatchBases(file, roots) {
663
767
  const bases = /* @__PURE__ */ new Set();
664
768
  const addBase = (candidate) => {
665
769
  const base = normalizeMatchPath(getOutputFileWithoutExtension(candidate));
666
- if (base.length > 0) {
667
- bases.add(base);
668
- const withoutWorkspaceSegment = base.replace(/^(?:src|dist)\//, "");
669
- if (withoutWorkspaceSegment !== base && withoutWorkspaceSegment.length > 0) bases.add(withoutWorkspaceSegment);
670
- }
770
+ if (base.length > 0) bases.add(base);
671
771
  };
672
772
  addBase(normalizedFile);
673
773
  const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => path.resolve(root));
@@ -683,10 +783,13 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
683
783
  sourceOptions.cwd
684
784
  ]);
685
785
  const sourceBases = collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]);
786
+ const outputBasename = getMatchBasename(file);
787
+ const sourceBasename = getMatchBasename(cssSourceFile);
686
788
  let bestScore = 0;
687
789
  for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
688
790
  else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
689
791
  else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
792
+ if (outputBasename && outputBasename === sourceBasename) bestScore = Math.max(bestScore, 100 + outputBasename.length);
690
793
  return bestScore;
691
794
  }
692
795
  //#endregion
@@ -730,12 +833,16 @@ function createCssEntrySources(cssEntries) {
730
833
  }
731
834
  function mergeCssSources(cssSources, cssEntrySources) {
732
835
  const merged = [];
733
- const seenFiles = /* @__PURE__ */ new Set();
836
+ const fileIndex = /* @__PURE__ */ new Map();
734
837
  const addSource = (cssSource) => {
735
838
  const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.resolve(cssSource.file) : void 0;
736
839
  if (file) {
737
- if (seenFiles.has(file)) return;
738
- seenFiles.add(file);
840
+ const previousIndex = fileIndex.get(file);
841
+ if (previousIndex !== void 0) {
842
+ if (typeof merged[previousIndex]?.css !== "string" && typeof cssSource.css === "string") merged[previousIndex] = cssSource;
843
+ return;
844
+ }
845
+ fileIndex.set(file, merged.length);
739
846
  }
740
847
  merged.push(cssSource);
741
848
  };
@@ -784,17 +891,13 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
784
891
  function shouldResolveSourceSideCssEntry(rawSource) {
785
892
  return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
786
893
  }
787
- function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
788
- return Boolean(sourceSideEntrySource) && !hasTailwindSourceDirectives(rawSource, { importFallback: true });
789
- }
790
- function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
791
- return Boolean(sourceSideEntrySource?.config) && (Boolean(cssEntrySource?.configRequest) || !cssEntrySource?.config) && (!cssEntrySource?.config || !existsSync(cssEntrySource.config));
792
- }
793
894
  function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
794
895
  const cssEntries = sourceOptions.cssEntries;
795
896
  if (!cssEntries?.length) return;
897
+ const normalizedFile = path.resolve(file.replace(/[?#].*$/, ""));
898
+ const pathMatchedEntries = cssEntries.filter((cssEntry) => path.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
899
+ if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions);
796
900
  const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
797
- const outputStem = getOutputFileStem(file);
798
901
  const matches = cssEntries.map((cssEntry) => {
799
902
  if (!existsSync(cssEntry)) return;
800
903
  try {
@@ -804,14 +907,6 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
804
907
  cssEntry,
805
908
  score: 1e6 + pathScore
806
909
  };
807
- if (pathScore > 0) return {
808
- cssEntry,
809
- score: pathScore
810
- };
811
- if (cssEntries.length === 1 && outputStem.length > 0 && getOutputFileStem(cssEntry) === outputStem) return {
812
- cssEntry,
813
- score: 1
814
- };
815
910
  return;
816
911
  } catch {
817
912
  return;
@@ -831,6 +926,18 @@ function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
831
926
  css: normalizeConfigDirective(cssSource.css, entrySource.config)
832
927
  };
833
928
  }
929
+ function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
930
+ if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
931
+ const sourceFile = typeof file === "string" && file.length > 0 ? file : source.__weappTailwindcssMeta?.matchedCssSourceFile;
932
+ if (!sourceFile) return source;
933
+ const entrySource = resolveCssEntrySource(source.css, path.dirname(path.resolve(sourceFile)), { removeConfig: false });
934
+ const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
935
+ const normalizedCss = normalizeConfigDirective(source.css, config);
936
+ return normalizedCss === source.css ? source : {
937
+ ...source,
938
+ css: normalizedCss
939
+ };
940
+ }
834
941
  function hydrateTailwindV4CssSource(cssSource) {
835
942
  if (typeof cssSource.css === "string" && cssSource.css.length > 0) return cssSource;
836
943
  if (typeof cssSource.file !== "string" || !existsSync(cssSource.file)) return cssSource;
@@ -870,18 +977,10 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
870
977
  index,
871
978
  score: 1e6
872
979
  };
873
- if (typeof cssSource.file === "string") {
874
- const pathScore = scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions);
875
- if (pathScore > 0) return {
876
- cssSource,
877
- index,
878
- score: pathScore
879
- };
880
- }
881
980
  if (normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource) return {
882
981
  cssSource,
883
982
  index,
884
- score: 1
983
+ score: 1 + (typeof cssSource.file === "string" ? scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions) : 0)
885
984
  };
886
985
  }).filter((match) => Boolean(match)).sort((a, b) => b.score - a.score || a.index - b.index);
887
986
  const bestScore = matches[0]?.score;
@@ -891,7 +990,7 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
891
990
  }
892
991
  function tryResolveTailwindV4SourceOptions(runtimeState) {
893
992
  try {
894
- return resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
993
+ return resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
895
994
  } catch {
896
995
  return;
897
996
  }
@@ -902,10 +1001,10 @@ function hasConfiguredTailwindV4CssSource(sourceOptions) {
902
1001
  async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
903
1002
  const sourceBase = resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? process.cwd());
904
1003
  const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
905
- return withGeneratorSourceMetadata(await resolveTailwindV4Source$1({
906
- ...omitUndefined(sourceOptions),
907
- cssSources: [normalizedCssSource]
908
- }), {
1004
+ return withGeneratorSourceMetadata(await resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(sourceOptions, {
1005
+ base: sourceBase,
1006
+ css: normalizedCssSource.css
1007
+ })), {
909
1008
  matchedCssSourceFile: options.matched && typeof normalizedCssSource.file === "string" ? normalizedCssSource.file : void 0,
910
1009
  sourceBase,
911
1010
  sourceCss: normalizedCssSource.css
@@ -961,62 +1060,22 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
961
1060
  ...resolvedSourceOptions,
962
1061
  sourceFile: resolvedEntrySource.file
963
1062
  });
964
- const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
1063
+ const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
965
1064
  return withMatchedSourceSideMetadata(await resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
966
1065
  base: resolvedEntrySource.base,
967
1066
  css
968
1067
  })), resolvedEntrySource);
969
1068
  }
970
- function resolveTailwindV3SourceEntries(source) {
971
- if (!("version" in source) || source.version !== 3) return;
972
- const entries = normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? path.dirname(source.config) : source.cwd });
973
- return entries.length > 0 ? entries : void 0;
974
- }
975
- function withTailwindV3SourceMetadata(source) {
976
- const sourceEntries = resolveTailwindV3SourceEntries(source);
977
- return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
978
- }
979
- async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1069
+ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
980
1070
  const base = resolveCssSourceBase(file, cssHandlerOptions);
981
1071
  const cssEntrySource = resolveCssEntrySource(rawSource, base, {
982
1072
  importFallback: generatorOptions?.importFallback ?? false,
983
- removeConfig: majorVersion === 3
1073
+ removeConfig: false
984
1074
  });
985
1075
  const applyEntrySource = hasTailwindApplyDirective(rawSource) ? {
986
1076
  base,
987
1077
  css: rawSource
988
1078
  } : void 0;
989
- if (majorVersion === 3) {
990
- const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(runtimeState.twPatcher);
991
- const mergedSourceOptions = omitUndefined({
992
- ...sourceOptions,
993
- config: generatorOptions?.config ?? sourceOptions.config,
994
- sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
995
- ...resolveCssHandlerSourceOptions(cssHandlerOptions),
996
- cssEntries: selectionOptions?.cssEntries,
997
- cssSources: createCssEntrySources(selectionOptions?.cssEntries)
998
- });
999
- const sourceSideEntrySource = canResolveSourceSideCssEntry(file, cssHandlerOptions, mergedSourceOptions) ? resolveSourceSideCssEntrySource(file, mergedSourceOptions, { removeConfig: true }) : void 0;
1000
- const shouldPreferSourceSideEntry = shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource);
1001
- const resolvedEntrySource = shouldResolveSourceSideCssEntry(rawSource) ? shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource : shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) || shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource;
1002
- if (!resolvedEntrySource) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? resolveTailwindV3Source(mergedSourceOptions) : resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
1003
- if (cssEntrySource && !sourceSideEntrySource && !applyEntrySource && !hasTailwindRootDirectives(rawSource, { importFallback: true })) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? resolveTailwindV3Source(mergedSourceOptions) : resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
1004
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, omitUndefined(mergedSourceOptions));
1005
- const sourceWithMetadata = withTailwindV3SourceMetadata(await resolveTailwindV3Source({
1006
- ...mergedSourceOptions,
1007
- base: resolvedEntrySource.base,
1008
- css: normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
1009
- ...config ? { config } : {}
1010
- }));
1011
- const cssEntrySourceEntries = await resolveTailwindConfigEntriesFromCssCached(rawSource, resolvedEntrySource.base);
1012
- const sourceMetadata = sourceWithMetadata.__weappTailwindcssMeta;
1013
- const matchedSourceFile = resolvedEntrySource.file ?? sourceSideEntrySource?.file;
1014
- return withGeneratorSourceMetadata(sourceWithMetadata, {
1015
- ...sourceMetadata,
1016
- matchedCssSourceFile: matchedSourceFile,
1017
- sourceEntries: cssEntrySourceEntries?.entries ?? sourceMetadata?.sourceEntries
1018
- });
1019
- }
1020
1079
  const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
1021
1080
  const resolvedSourceOptions = sourceOptions ? omitUndefined({
1022
1081
  ...sourceOptions,
@@ -1052,16 +1111,19 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
1052
1111
  } : preferredCssEntrySource;
1053
1112
  const resolvedEntrySource = sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource;
1054
1113
  if (!resolvedEntrySource) {
1055
- const source = await resolveTailwindV4SourceFromPatcher(runtimeState.twPatcher);
1114
+ const source = await resolveTailwindV4SourceFromRuntime(runtimeState.tailwindRuntime);
1056
1115
  return generatorOptions?.config ? {
1057
1116
  ...source,
1058
1117
  css: prependConfigDirective(source.css, generatorOptions.config)
1059
1118
  } : source;
1060
1119
  }
1061
1120
  if (sourceSideEntrySource && normalizedSourceOptions) return resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file);
1062
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, resolvedSourceOptions ?? {});
1121
+ const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, omitUndefined({
1122
+ ...resolvedSourceOptions ?? {},
1123
+ sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
1124
+ }));
1063
1125
  const sourceBase = resolvedEntrySource === cssEntrySource && config ? path.dirname(config) : resolvedEntrySource.base;
1064
- const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1126
+ const css = createTailwindV4SourceReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
1065
1127
  return resolveTailwindV4Source$1(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
1066
1128
  base: sourceBase,
1067
1129
  css
@@ -1070,47 +1132,48 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
1070
1132
  async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
1071
1133
  const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
1072
1134
  importFallback: generatorOptions?.importFallback ?? false,
1073
- removeConfig: majorVersion === 3
1135
+ removeConfig: false
1074
1136
  });
1075
- if (majorVersion !== 4 || cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(rawSource) && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1137
+ if (cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(rawSource) && !hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
1076
1138
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1077
1139
  return resolved ? [resolved] : [];
1078
1140
  }
1079
1141
  let sourceOptions;
1080
1142
  try {
1081
- const sourceOptionsFromPatcher = resolveTailwindV4SourceOptionsFromPatcher(runtimeState.twPatcher);
1082
- const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromPatcher.cssEntries;
1143
+ const sourceOptionsFromRuntime = resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
1144
+ const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromRuntime.cssEntries;
1145
+ const runtimeCssSources = selectionOptions?.cssEntries ? void 0 : sourceOptionsFromRuntime.cssSources;
1083
1146
  sourceOptions = omitUndefined({
1084
- ...sourceOptionsFromPatcher,
1147
+ ...sourceOptionsFromRuntime,
1085
1148
  sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
1086
1149
  ...resolveCssHandlerSourceOptions(cssHandlerOptions),
1087
1150
  cssEntries,
1088
- cssSources: mergeCssSources(mergeCssSources(sourceOptionsFromPatcher.cssSources, selectionOptions?.cssSources), sourceOptionsFromPatcher.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
1151
+ cssSources: mergeCssSources(mergeCssSources(runtimeCssSources, selectionOptions?.cssSources), void 0)
1089
1152
  });
1090
1153
  } catch {
1091
1154
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1092
1155
  return resolved ? [resolved] : [];
1093
1156
  }
1094
1157
  const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
1095
- if (matchedCssEntrySource) return [generatorOptions?.config ? {
1158
+ if (matchedCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1096
1159
  ...matchedCssEntrySource,
1097
1160
  css: prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
1098
- } : matchedCssEntrySource];
1161
+ } : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1099
1162
  const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
1100
1163
  if (sourceSideCssSource) return [sourceSideCssSource];
1101
1164
  const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
1102
1165
  const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
1103
1166
  const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
1104
- if (preferredCssEntrySource) return [generatorOptions?.config ? {
1167
+ if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
1105
1168
  ...preferredCssEntrySource,
1106
1169
  css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
1107
- } : preferredCssEntrySource];
1170
+ } : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
1108
1171
  if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
1109
1172
  if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions)).then((source) => generatorOptions?.config ? {
1110
1173
  ...source,
1111
1174
  css: prependConfigDirective(source.css, generatorOptions.config)
1112
1175
  } : source)];
1113
- if (sourceOptions.cssSources?.length === 1) return [await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0])];
1176
+ if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0]), sourceOptions.cssSources[0]?.file, sourceOptions)];
1114
1177
  const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
1115
1178
  return resolved ? [resolved] : [];
1116
1179
  }
@@ -1153,136 +1216,631 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
1153
1216
  return resolved?.entries;
1154
1217
  }
1155
1218
  //#endregion
1156
- //#region src/bundlers/shared/generator-css/legacy-compat.ts
1157
- const LEGACY_CONTAINER_COMPAT_CSS = [
1158
- ".container {",
1159
- " width: 100%;",
1160
- "}",
1161
- "@media (min-width: 40rem) {",
1162
- " .container {",
1163
- " max-width: 40rem;",
1164
- " }",
1165
- "}",
1166
- "@media (min-width: 48rem) {",
1167
- " .container {",
1168
- " max-width: 48rem;",
1169
- " }",
1170
- "}",
1171
- "@media (min-width: 64rem) {",
1172
- " .container {",
1173
- " max-width: 64rem;",
1174
- " }",
1175
- "}",
1176
- "@media (min-width: 80rem) {",
1177
- " .container {",
1178
- " max-width: 80rem;",
1179
- " }",
1180
- "}",
1181
- "@media (min-width: 96rem) {",
1182
- " .container {",
1183
- " max-width: 96rem;",
1184
- " }",
1185
- "}"
1186
- ].join("\n");
1187
- const LEGACY_COMPAT_CACHE_LIMIT = 128;
1188
- const legacyCompatSourceCache = /* @__PURE__ */ new Map();
1189
- const legacyCompatTransformCache = /* @__PURE__ */ new Map();
1190
- function setLimitedCacheValue(cache, key, value) {
1191
- if (cache.size >= LEGACY_COMPAT_CACHE_LIMIT) {
1192
- const firstKey = cache.keys().next().value;
1193
- if (firstKey !== void 0) cache.delete(firstKey);
1219
+ //#region src/bundlers/shared/generator-css/user-css.ts
1220
+ const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
1221
+ "config",
1222
+ "custom-variant",
1223
+ "plugin",
1224
+ "source",
1225
+ "theme",
1226
+ "utility",
1227
+ "variant"
1228
+ ]);
1229
+ function removeBalancedAtRuleBlock(source, atRuleStart) {
1230
+ const blockStart = source.indexOf("{", atRuleStart);
1231
+ if (blockStart === -1) {
1232
+ const semicolon = source.indexOf(";", atRuleStart);
1233
+ return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
1194
1234
  }
1195
- cache.set(key, value);
1235
+ let depth = 0;
1236
+ for (let index = blockStart; index < source.length; index++) {
1237
+ const char = source[index];
1238
+ if (char === "{") {
1239
+ depth++;
1240
+ continue;
1241
+ }
1242
+ if (char !== "}") continue;
1243
+ depth--;
1244
+ if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
1245
+ }
1246
+ return source.slice(0, atRuleStart);
1196
1247
  }
1197
- function createStableJson(value) {
1198
- if (value === void 0) return "undefined";
1199
- if (value === null || typeof value !== "object") return JSON.stringify(value);
1200
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
1201
- return `{${Object.keys(value).sort().map((key) => {
1202
- const record = value;
1203
- return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
1204
- }).join(",")}}`;
1248
+ function removeTailwindV4GeneratorAtRulesFallback(source) {
1249
+ let next = source;
1250
+ let changed = false;
1251
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1252
+ for (;;) {
1253
+ sourceMediaRE.lastIndex = 0;
1254
+ const match = sourceMediaRE.exec(next);
1255
+ if (!match) break;
1256
+ next = removeBalancedAtRuleBlock(next, match.index);
1257
+ changed = true;
1258
+ }
1259
+ const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
1260
+ for (;;) {
1261
+ atRuleRE.lastIndex = 0;
1262
+ const match = atRuleRE.exec(next);
1263
+ if (!match) break;
1264
+ next = removeBalancedAtRuleBlock(next, match.index);
1265
+ changed = true;
1266
+ }
1267
+ return changed ? next : source;
1268
+ }
1269
+ function isTailwindGeneratedPreflightComment(text) {
1270
+ return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
1271
+ }
1272
+ function isTailwindGeneratedThemeRule(selector, node) {
1273
+ if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
1274
+ return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
1275
+ }
1276
+ function isTailwindGeneratedPreflightRule(selector, node) {
1277
+ if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
1278
+ if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
1279
+ if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
1280
+ return false;
1205
1281
  }
1206
- function createLegacyCompatTransformCacheKey(source, options) {
1207
- return `${createStableJson(options)}\0${source}`;
1282
+ function removeTailwindV4GeneratedUserCssArtifacts(source) {
1283
+ try {
1284
+ const root = postcss.parse(source);
1285
+ let changed = false;
1286
+ root.walkComments((comment) => {
1287
+ if (!isTailwindGeneratedPreflightComment(comment.text)) return;
1288
+ comment.remove();
1289
+ changed = true;
1290
+ });
1291
+ root.walkRules((rule) => {
1292
+ const selector = rule.selector.replace(/\s+/g, " ").trim();
1293
+ if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
1294
+ rule.remove();
1295
+ changed = true;
1296
+ }
1297
+ });
1298
+ root.walkAtRules((rule) => {
1299
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) {
1300
+ rule.remove();
1301
+ changed = true;
1302
+ }
1303
+ });
1304
+ return changed ? root.toString() : source;
1305
+ } catch {
1306
+ return source;
1307
+ }
1208
1308
  }
1209
- function countUnclosedBlocks(source) {
1210
- let depth = 0;
1211
- let quote;
1212
- let inComment = false;
1213
- let escaped = false;
1214
- for (let index = 0; index < source.length; index += 1) {
1215
- const char = source[index];
1216
- const next = source[index + 1];
1217
- if (inComment) {
1218
- if (char === "*" && next === "/") {
1219
- inComment = false;
1220
- index += 1;
1309
+ function removeTailwindSourceMediaBlocks(source) {
1310
+ let next = source;
1311
+ let changed = false;
1312
+ const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
1313
+ for (;;) {
1314
+ sourceMediaRE.lastIndex = 0;
1315
+ const match = sourceMediaRE.exec(next);
1316
+ if (!match) break;
1317
+ const blockStart = next.indexOf("{", match.index);
1318
+ if (blockStart === -1) break;
1319
+ let depth = 0;
1320
+ let blockEnd = -1;
1321
+ for (let index = blockStart; index < next.length; index++) {
1322
+ const char = next[index];
1323
+ if (char === "{") {
1324
+ depth++;
1325
+ continue;
1326
+ }
1327
+ if (char !== "}") continue;
1328
+ depth--;
1329
+ if (depth === 0) {
1330
+ blockEnd = index;
1331
+ break;
1221
1332
  }
1333
+ }
1334
+ if (blockEnd === -1) break;
1335
+ next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
1336
+ changed = true;
1337
+ }
1338
+ for (;;) {
1339
+ const atRuleStart = findTailwindSourceWrapperBlockStart(next);
1340
+ if (atRuleStart === -1) break;
1341
+ next = removeBalancedAtRuleBlock(next, atRuleStart);
1342
+ changed = true;
1343
+ }
1344
+ return changed ? next : source;
1345
+ }
1346
+ function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
1347
+ if (!source.includes("@source")) return source;
1348
+ let next = "";
1349
+ let searchIndex = 0;
1350
+ for (;;) {
1351
+ const atRuleStart = source.indexOf("@source", searchIndex);
1352
+ if (atRuleStart === -1) {
1353
+ next += source.slice(searchIndex);
1354
+ break;
1355
+ }
1356
+ const nextChar = source[atRuleStart + 7];
1357
+ if (nextChar && /[\w-]/.test(nextChar)) {
1358
+ next += source.slice(searchIndex, atRuleStart + 7);
1359
+ searchIndex = atRuleStart + 7;
1222
1360
  continue;
1223
1361
  }
1224
- if (quote) {
1225
- if (escaped) {
1226
- escaped = false;
1362
+ next += source.slice(searchIndex, atRuleStart);
1363
+ let quote;
1364
+ let parenDepth = 0;
1365
+ let terminated = false;
1366
+ let index = atRuleStart + 7;
1367
+ for (; index < source.length; index++) {
1368
+ const char = source[index];
1369
+ if (quote) {
1370
+ if (char === "\\") {
1371
+ index++;
1372
+ continue;
1373
+ }
1374
+ if (char === quote) quote = void 0;
1227
1375
  continue;
1228
1376
  }
1229
- if (char === "\\") {
1230
- escaped = true;
1377
+ if (char === "\"" || char === "'") {
1378
+ quote = char;
1231
1379
  continue;
1232
1380
  }
1233
- if (char === quote) quote = void 0;
1234
- continue;
1381
+ if (char === "(") {
1382
+ parenDepth++;
1383
+ continue;
1384
+ }
1385
+ if (char === ")" && parenDepth > 0) {
1386
+ parenDepth--;
1387
+ continue;
1388
+ }
1389
+ if (parenDepth > 0) continue;
1390
+ if (char === ";" || char === "{") {
1391
+ terminated = true;
1392
+ index++;
1393
+ break;
1394
+ }
1395
+ if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
1235
1396
  }
1236
- if (char === "/" && next === "*") {
1237
- inComment = true;
1238
- index += 1;
1397
+ const segment = source.slice(atRuleStart, index);
1398
+ const trimmedSegment = segment.trimEnd();
1399
+ next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
1400
+ searchIndex = index;
1401
+ }
1402
+ return next;
1403
+ }
1404
+ function findTailwindSourceWrapperBlockStart(source) {
1405
+ let searchIndex = 0;
1406
+ for (;;) {
1407
+ const atRuleStart = source.indexOf("@source", searchIndex);
1408
+ if (atRuleStart === -1) return -1;
1409
+ const nextChar = source[atRuleStart + 7];
1410
+ if (nextChar && /[\w-]/.test(nextChar)) {
1411
+ searchIndex = atRuleStart + 7;
1239
1412
  continue;
1240
1413
  }
1241
- if (char === "\"" || char === "'") {
1242
- quote = char;
1243
- continue;
1414
+ let quote;
1415
+ let parenDepth = 0;
1416
+ for (let index = atRuleStart + 7; index < source.length; index++) {
1417
+ const char = source[index];
1418
+ if (quote) {
1419
+ if (char === "\\") {
1420
+ index++;
1421
+ continue;
1422
+ }
1423
+ if (char === quote) quote = void 0;
1424
+ continue;
1425
+ }
1426
+ if (char === "\"" || char === "'") {
1427
+ quote = char;
1428
+ continue;
1429
+ }
1430
+ if (char === "(") {
1431
+ parenDepth++;
1432
+ continue;
1433
+ }
1434
+ if (char === ")" && parenDepth > 0) {
1435
+ parenDepth--;
1436
+ continue;
1437
+ }
1438
+ if (parenDepth > 0) continue;
1439
+ if (char === ";") {
1440
+ searchIndex = index + 1;
1441
+ break;
1442
+ }
1443
+ if (char === "{") return atRuleStart;
1244
1444
  }
1245
- if (char === "{") depth += 1;
1246
- else if (char === "}" && depth > 0) depth -= 1;
1445
+ if (searchIndex <= atRuleStart) return -1;
1247
1446
  }
1248
- return depth;
1249
1447
  }
1250
- function closeTrailingUnclosedBlocks(source) {
1448
+ function removeTailwindApplyAtRules(source) {
1449
+ if (!source.includes("@apply")) return source;
1251
1450
  try {
1252
- postcss.parse(source);
1451
+ const root = postcss.parse(source);
1452
+ let changed = false;
1453
+ root.walkAtRules("apply", (rule) => {
1454
+ rule.remove();
1455
+ changed = true;
1456
+ });
1457
+ root.walk((node) => {
1458
+ if ("nodes" in node && node.nodes?.length === 0) node.remove();
1459
+ });
1460
+ return changed ? root.toString() : source;
1461
+ } catch {
1253
1462
  return source;
1254
- } catch (error) {
1255
- if (error.reason !== "Unclosed block") return source;
1256
- const unclosedBlocks = countUnclosedBlocks(source);
1257
- return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
1258
1463
  }
1259
1464
  }
1260
- function removeTailwindApplyRules(rawSource) {
1465
+ function removeTailwindV4GeneratorAtRules(source) {
1261
1466
  try {
1262
- const root = postcss.parse(rawSource);
1263
- let removed = false;
1264
- root.walkAtRules("apply", (rule) => {
1265
- const parent = rule.parent;
1266
- if (parent?.type === "rule") parent.remove();
1267
- else rule.remove();
1268
- removed = true;
1269
- });
1467
+ const root = postcss.parse(source);
1468
+ let changed = false;
1270
1469
  root.walkAtRules((rule) => {
1271
- if (rule.nodes && rule.nodes.length === 0) rule.remove();
1470
+ if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
1471
+ rule.remove();
1472
+ changed = true;
1473
+ return;
1474
+ }
1475
+ if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
1476
+ rule.remove();
1477
+ changed = true;
1272
1478
  });
1273
- return removed ? root.toString() : rawSource;
1479
+ return changed ? root.toString() : source;
1274
1480
  } catch {
1275
- return rawSource;
1481
+ return removeTailwindV4GeneratorAtRulesFallback(source);
1276
1482
  }
1277
1483
  }
1278
- function resolveLegacyCompatCssSource(rawSource) {
1279
- const cached = legacyCompatSourceCache.get(rawSource);
1280
- if (cached !== void 0) return cached;
1281
- const resolved = closeTrailingUnclosedBlocks(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
1282
- setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
1283
- return resolved;
1484
+ function isCommentOnlyCss(source) {
1485
+ try {
1486
+ const root = postcss.parse(source);
1487
+ return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
1488
+ } catch {
1489
+ return false;
1490
+ }
1284
1491
  }
1285
- function removeMiniProgramContainerCompatCss(css) {
1492
+ function removeMiniProgramHoverSelectors(source, enabled = true) {
1493
+ if (!enabled || !source.includes(":hover")) return source;
1494
+ try {
1495
+ const root = postcss.parse(source);
1496
+ let changed = false;
1497
+ root.walkRules((rule) => {
1498
+ const selectors = rule.selectors ?? [rule.selector];
1499
+ const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
1500
+ if (keptSelectors.length === selectors.length) return;
1501
+ changed = true;
1502
+ if (keptSelectors.length === 0) {
1503
+ rule.remove();
1504
+ return;
1505
+ }
1506
+ rule.selectors = keptSelectors;
1507
+ });
1508
+ root.walk((node) => {
1509
+ if ("nodes" in node && node.nodes?.length === 0) {
1510
+ node.remove();
1511
+ changed = true;
1512
+ }
1513
+ });
1514
+ return changed ? root.toString() : source;
1515
+ } catch {
1516
+ return source;
1517
+ }
1518
+ }
1519
+ function removeProcessedMiniProgramUnsupportedCss(source, options) {
1520
+ return removeMiniProgramHoverSelectors(removeUnsupportedMiniProgramAtRules(source), options.cssRemoveHoverPseudoClass);
1521
+ }
1522
+ function unwrapMiniProgramCascadeLayers(source) {
1523
+ if (!source.includes("@layer")) return source;
1524
+ try {
1525
+ const root = postcss.parse(source);
1526
+ removeUnsupportedCascadeLayers(root);
1527
+ return root.toString();
1528
+ } catch {
1529
+ return source;
1530
+ }
1531
+ }
1532
+ function stripTailwindSourceMediaFragments(source) {
1533
+ let removedSourceMediaStart = false;
1534
+ return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
1535
+ if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
1536
+ removedSourceMediaStart = true;
1537
+ return false;
1538
+ }
1539
+ if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
1540
+ if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
1541
+ removedSourceMediaStart = false;
1542
+ return false;
1543
+ }
1544
+ return true;
1545
+ }).join("\n");
1546
+ }
1547
+ function stripLeadingTailwindSourceMediaCloseFragment(source) {
1548
+ return source.replace(/^\s*\}\s*(?:\n|$)/, "");
1549
+ }
1550
+ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
1551
+ try {
1552
+ postcss.parse(source);
1553
+ return source;
1554
+ } catch {
1555
+ return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
1556
+ }
1557
+ }
1558
+ function splitUserCssLayerBlocks(source) {
1559
+ if (!source.includes("@layer")) return {
1560
+ layer: "",
1561
+ rest: source
1562
+ };
1563
+ try {
1564
+ const root = postcss.parse(source);
1565
+ const layerRoot = postcss.root();
1566
+ const restRoot = postcss.root();
1567
+ for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
1568
+ return {
1569
+ layer: layerRoot.toString(),
1570
+ rest: restRoot.toString()
1571
+ };
1572
+ } catch {
1573
+ return {
1574
+ layer: source,
1575
+ rest: ""
1576
+ };
1577
+ }
1578
+ }
1579
+ function hasUserCssLayerBlocks(source) {
1580
+ if (!source.includes("@layer")) return false;
1581
+ try {
1582
+ let hasLayerBlock = false;
1583
+ postcss.parse(source).walkAtRules("layer", (node) => {
1584
+ if (node.nodes?.length) hasLayerBlock = true;
1585
+ });
1586
+ return hasLayerBlock;
1587
+ } catch {
1588
+ return true;
1589
+ }
1590
+ }
1591
+ function collectUserLayerSelectors(source) {
1592
+ const selectors = /* @__PURE__ */ new Set();
1593
+ try {
1594
+ postcss.parse(source).walkRules((rule) => {
1595
+ for (const selector of rule.selectors ?? [rule.selector]) {
1596
+ const normalized = selector.trim();
1597
+ if (normalized) selectors.add(normalized);
1598
+ }
1599
+ });
1600
+ } catch {}
1601
+ return selectors;
1602
+ }
1603
+ function matchesUserLayerSelector(selector, userLayerSelector) {
1604
+ if (selector === userLayerSelector) return true;
1605
+ if (!selector.startsWith(userLayerSelector)) return false;
1606
+ const next = selector[userLayerSelector.length];
1607
+ return next === ":" || next === "[";
1608
+ }
1609
+ function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
1610
+ const selectors = collectUserLayerSelectors(userLayerSource);
1611
+ if (selectors.size === 0) return {
1612
+ layer: "",
1613
+ rest: css
1614
+ };
1615
+ try {
1616
+ const root = postcss.parse(css);
1617
+ const layerRoot = postcss.root();
1618
+ const selectorList = [...selectors];
1619
+ root.walkRules((rule) => {
1620
+ if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
1621
+ layerRoot.append(rule.clone());
1622
+ rule.remove();
1623
+ }
1624
+ });
1625
+ return {
1626
+ layer: layerRoot.toString(),
1627
+ rest: root.toString()
1628
+ };
1629
+ } catch {
1630
+ return {
1631
+ layer: "",
1632
+ rest: css
1633
+ };
1634
+ }
1635
+ }
1636
+ function normalizeGeneratedSelector(selector) {
1637
+ return selector.replace(/:not\(#\\#\)/g, "").trim();
1638
+ }
1639
+ function collectApplyOnlySourceSelectors(source) {
1640
+ const selectors = /* @__PURE__ */ new Set();
1641
+ try {
1642
+ postcss.parse(source).walkRules((rule) => {
1643
+ if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
1644
+ for (const selector of rule.selectors ?? [rule.selector]) {
1645
+ const normalized = normalizeGeneratedSelector(selector);
1646
+ if (normalized) selectors.add(normalized);
1647
+ }
1648
+ });
1649
+ } catch {}
1650
+ return selectors;
1651
+ }
1652
+ function hasOnlyApplyBackedSourceRules(source) {
1653
+ let hasApplyRule = false;
1654
+ let hasNonApplyRule = false;
1655
+ try {
1656
+ postcss.parse(source).walkRules((rule) => {
1657
+ if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
1658
+ else hasNonApplyRule = true;
1659
+ });
1660
+ } catch {
1661
+ return false;
1662
+ }
1663
+ return hasApplyRule && !hasNonApplyRule;
1664
+ }
1665
+ function filterApplyOnlyGeneratedCss(css, source) {
1666
+ const selectors = collectApplyOnlySourceSelectors(source);
1667
+ if (selectors.size === 0) return css;
1668
+ const selectorList = [...selectors];
1669
+ try {
1670
+ const root = postcss.parse(css);
1671
+ root.walkRules((rule) => {
1672
+ const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
1673
+ const normalized = normalizeGeneratedSelector(selector);
1674
+ return selectorList.some((sourceSelector) => {
1675
+ if (normalized === sourceSelector) return true;
1676
+ if (!normalized.startsWith(sourceSelector)) return false;
1677
+ const next = normalized[sourceSelector.length];
1678
+ return next === ":" || next === "[" || next === ".";
1679
+ });
1680
+ });
1681
+ const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
1682
+ if (!isApplySelector && !isVariableRule) rule.remove();
1683
+ });
1684
+ root.walkAtRules((rule) => {
1685
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
1686
+ });
1687
+ return root.toString();
1688
+ } catch {
1689
+ return css;
1690
+ }
1691
+ }
1692
+ function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
1693
+ return target === "weapp" && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
1694
+ }
1695
+ async function transformGeneratorUserCss(source, options) {
1696
+ if (source.trim().length === 0) return "";
1697
+ if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
1698
+ ...options.generatorStyleOptions,
1699
+ ...options.cssUserHandlerOptions
1700
+ })) : source)));
1701
+ const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
1702
+ if (cleanedSource.trim().length === 0) return "";
1703
+ const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
1704
+ if (userSource.trim().length === 0) return "";
1705
+ if (isCommentOnlyCss(userSource)) return userSource;
1706
+ if (options.generatorTarget !== "weapp") return userSource;
1707
+ const { css } = await options.styleHandler(userSource, {
1708
+ ...options.generatorStyleOptions,
1709
+ ...options.cssUserHandlerOptions
1710
+ });
1711
+ return removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(css));
1712
+ }
1713
+ //#endregion
1714
+ //#region src/bundlers/shared/generator-css/legacy-compat.ts
1715
+ const LEGACY_CONTAINER_COMPAT_CSS = [
1716
+ ".container {",
1717
+ " width: 100%;",
1718
+ "}",
1719
+ "@media (min-width: 40rem) {",
1720
+ " .container {",
1721
+ " max-width: 40rem;",
1722
+ " }",
1723
+ "}",
1724
+ "@media (min-width: 48rem) {",
1725
+ " .container {",
1726
+ " max-width: 48rem;",
1727
+ " }",
1728
+ "}",
1729
+ "@media (min-width: 64rem) {",
1730
+ " .container {",
1731
+ " max-width: 64rem;",
1732
+ " }",
1733
+ "}",
1734
+ "@media (min-width: 80rem) {",
1735
+ " .container {",
1736
+ " max-width: 80rem;",
1737
+ " }",
1738
+ "}",
1739
+ "@media (min-width: 96rem) {",
1740
+ " .container {",
1741
+ " max-width: 96rem;",
1742
+ " }",
1743
+ "}"
1744
+ ].join("\n");
1745
+ const LEGACY_COMPAT_CACHE_LIMIT = 128;
1746
+ const legacyCompatSourceCache = /* @__PURE__ */ new Map();
1747
+ const legacyCompatTransformCache = /* @__PURE__ */ new Map();
1748
+ function setLimitedCacheValue(cache, key, value) {
1749
+ if (cache.size >= LEGACY_COMPAT_CACHE_LIMIT) {
1750
+ const firstKey = cache.keys().next().value;
1751
+ if (firstKey !== void 0) cache.delete(firstKey);
1752
+ }
1753
+ cache.set(key, value);
1754
+ }
1755
+ function createStableJson(value) {
1756
+ if (value === void 0) return "undefined";
1757
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
1758
+ if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
1759
+ return `{${Object.keys(value).sort().map((key) => {
1760
+ const record = value;
1761
+ return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
1762
+ }).join(",")}}`;
1763
+ }
1764
+ function createLegacyCompatTransformCacheKey(source, options) {
1765
+ return `${createStableJson(options)}\0${source}`;
1766
+ }
1767
+ function countUnclosedBlocks(source) {
1768
+ let depth = 0;
1769
+ let quote;
1770
+ let inComment = false;
1771
+ let escaped = false;
1772
+ for (let index = 0; index < source.length; index += 1) {
1773
+ const char = source[index];
1774
+ const next = source[index + 1];
1775
+ if (inComment) {
1776
+ if (char === "*" && next === "/") {
1777
+ inComment = false;
1778
+ index += 1;
1779
+ }
1780
+ continue;
1781
+ }
1782
+ if (quote) {
1783
+ if (escaped) {
1784
+ escaped = false;
1785
+ continue;
1786
+ }
1787
+ if (char === "\\") {
1788
+ escaped = true;
1789
+ continue;
1790
+ }
1791
+ if (char === quote) quote = void 0;
1792
+ continue;
1793
+ }
1794
+ if (char === "/" && next === "*") {
1795
+ inComment = true;
1796
+ index += 1;
1797
+ continue;
1798
+ }
1799
+ if (char === "\"" || char === "'") {
1800
+ quote = char;
1801
+ continue;
1802
+ }
1803
+ if (char === "{") depth += 1;
1804
+ else if (char === "}" && depth > 0) depth -= 1;
1805
+ }
1806
+ return depth;
1807
+ }
1808
+ function closeTrailingUnclosedBlocks(source) {
1809
+ try {
1810
+ postcss.parse(source);
1811
+ return source;
1812
+ } catch (error) {
1813
+ if (error.reason !== "Unclosed block") return source;
1814
+ const unclosedBlocks = countUnclosedBlocks(source);
1815
+ return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
1816
+ }
1817
+ }
1818
+ function removeTailwindApplyRules(rawSource) {
1819
+ try {
1820
+ const root = postcss.parse(rawSource);
1821
+ let removed = false;
1822
+ root.walkAtRules("apply", (rule) => {
1823
+ const parent = rule.parent;
1824
+ if (parent?.type === "rule") parent.remove();
1825
+ else rule.remove();
1826
+ removed = true;
1827
+ });
1828
+ root.walkAtRules((rule) => {
1829
+ if (rule.nodes && rule.nodes.length === 0) rule.remove();
1830
+ });
1831
+ return removed ? root.toString() : rawSource;
1832
+ } catch {
1833
+ return rawSource;
1834
+ }
1835
+ }
1836
+ function resolveLegacyCompatCssSource(rawSource) {
1837
+ const cached = legacyCompatSourceCache.get(rawSource);
1838
+ if (cached !== void 0) return cached;
1839
+ const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource)))))));
1840
+ setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
1841
+ return resolved;
1842
+ }
1843
+ function removeMiniProgramContainerCompatCss(css) {
1286
1844
  try {
1287
1845
  const root = postcss.parse(css);
1288
1846
  let removed = false;
@@ -1317,6 +1875,7 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
1317
1875
  }
1318
1876
  }
1319
1877
  function hasConfiguredContainerCompatSource(source) {
1878
+ if (typeof source.css !== "string") return false;
1320
1879
  if (hasContainerConfigToken(source.css)) return true;
1321
1880
  const cssEntrySource = resolveCssEntrySource(source.css, source.base);
1322
1881
  if (cssEntrySource?.config) try {
@@ -1345,7 +1904,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
1345
1904
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
1346
1905
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
1347
1906
  }
1348
- const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css), css);
1907
+ const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css)), css);
1349
1908
  if (cleanedCompatCss.trim().length === 0) return css;
1350
1909
  return createCssAppend(css, cleanedCompatCss);
1351
1910
  }
@@ -1415,6 +1974,8 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
1415
1974
  //#endregion
1416
1975
  //#region src/bundlers/shared/generator-css/local-imports.ts
1417
1976
  const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
1977
+ const CSS_STYLE_EXTENSION_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
1978
+ const SOURCE_STYLE_EXTENSION_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
1418
1979
  function createCssSourceOrderAppend(base, extra) {
1419
1980
  if (!base) return extra;
1420
1981
  if (!extra) return base;
@@ -1450,300 +2011,92 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
1450
2011
  if (node.type === "atrule" && node.name === "import") {
1451
2012
  const request = parseImportRequest(node.params);
1452
2013
  if (!request || !isLocalImportRequest(request)) return;
1453
- hasLocalImport = true;
1454
- continue;
1455
- }
1456
- if (node.type === "atrule" && node.name === "source") {
1457
- hasTailwindDirective = true;
1458
- continue;
1459
- }
1460
- return;
1461
- }
1462
- } catch {
1463
- return;
1464
- }
1465
- return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
1466
- }
1467
- function prefixLocalCssImportsWithWebpackIgnore(css) {
1468
- try {
1469
- const root = postcss.parse(css);
1470
- root.walkAtRules("import", (atRule) => {
1471
- const request = parseImportRequest(atRule.params);
1472
- if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
1473
- });
1474
- return root.toString();
1475
- } catch {
1476
- return css;
1477
- }
1478
- }
1479
- function splitLocalCssImports(source) {
1480
- try {
1481
- const root = postcss.parse(source);
1482
- const importRoot = postcss.root();
1483
- let changed = false;
1484
- for (const node of [...root.nodes]) {
1485
- if (node.type !== "atrule" || node.name !== "import") continue;
1486
- const request = parseImportRequest(node.params);
1487
- if (!request || !isLocalImportRequest(request)) continue;
1488
- importRoot.append(node.clone());
1489
- node.remove();
1490
- changed = true;
1491
- }
1492
- const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
1493
- return changed ? {
1494
- imports,
1495
- source: root.toString()
1496
- } : void 0;
1497
- } catch {
1498
- return;
1499
- }
1500
- }
1501
- function restoreLocalCssImports(css, imports) {
1502
- if (!imports?.trim()) return css;
1503
- return createCssSourceOrderAppend(imports, css);
1504
- }
1505
- //#endregion
1506
- //#region src/bundlers/shared/generator-css/user-css.ts
1507
- const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
1508
- "config",
1509
- "custom-variant",
1510
- "plugin",
1511
- "source",
1512
- "theme",
1513
- "utility",
1514
- "variant"
1515
- ]);
1516
- function removeTailwindApplyAtRules(source) {
1517
- if (!source.includes("@apply")) return source;
1518
- try {
1519
- const root = postcss.parse(source);
1520
- let changed = false;
1521
- root.walkAtRules("apply", (rule) => {
1522
- rule.remove();
1523
- changed = true;
1524
- });
1525
- root.walk((node) => {
1526
- if ("nodes" in node && node.nodes?.length === 0) node.remove();
1527
- });
1528
- return changed ? root.toString() : source;
1529
- } catch {
1530
- return source;
1531
- }
1532
- }
1533
- function removeTailwindV4GeneratorAtRules(source) {
1534
- try {
1535
- const root = postcss.parse(source);
1536
- let changed = false;
1537
- root.walkAtRules((rule) => {
1538
- if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
1539
- rule.remove();
1540
- changed = true;
1541
- });
1542
- root.walk((node) => {
1543
- if ("nodes" in node && node.nodes?.length === 0) {
1544
- node.remove();
1545
- changed = true;
1546
- }
1547
- });
1548
- return changed ? root.toString() : source;
1549
- } catch {
1550
- return source;
1551
- }
1552
- }
1553
- function isCommentOnlyCss(source) {
1554
- try {
1555
- const root = postcss.parse(source);
1556
- return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
1557
- } catch {
1558
- return false;
1559
- }
1560
- }
1561
- function unwrapMiniProgramCascadeLayers(source) {
1562
- if (!source.includes("@layer")) return source;
1563
- try {
1564
- const root = postcss.parse(source);
1565
- removeUnsupportedCascadeLayers(root);
1566
- return root.toString();
1567
- } catch {
1568
- return source;
1569
- }
1570
- }
1571
- function stripTailwindSourceMediaFragments(source) {
1572
- let removedSourceMediaStart = false;
1573
- return source.split(/\r?\n/).filter((line) => {
1574
- if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
1575
- removedSourceMediaStart = true;
1576
- return false;
1577
- }
1578
- if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
1579
- if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
1580
- removedSourceMediaStart = false;
1581
- return false;
1582
- }
1583
- return true;
1584
- }).join("\n").replace(/\}[^\S\r\n]*(?=@(?:config|source)\b)/g, "");
1585
- }
1586
- function stripLeadingTailwindSourceMediaCloseFragment(source) {
1587
- return source.replace(/^\s*\}\s*(?:\n|$)/, "");
1588
- }
1589
- function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
1590
- try {
1591
- postcss.parse(source);
1592
- return source;
1593
- } catch {
1594
- return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
1595
- }
1596
- }
1597
- function splitUserCssLayerBlocks(source) {
1598
- if (!source.includes("@layer")) return {
1599
- layer: "",
1600
- rest: source
1601
- };
1602
- try {
1603
- const root = postcss.parse(source);
1604
- const layerRoot = postcss.root();
1605
- const restRoot = postcss.root();
1606
- for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
1607
- return {
1608
- layer: layerRoot.toString(),
1609
- rest: restRoot.toString()
1610
- };
1611
- } catch {
1612
- return {
1613
- layer: source,
1614
- rest: ""
1615
- };
1616
- }
1617
- }
1618
- function hasUserCssLayerBlocks(source) {
1619
- if (!source.includes("@layer")) return false;
1620
- try {
1621
- let hasLayerBlock = false;
1622
- postcss.parse(source).walkAtRules("layer", (node) => {
1623
- if (node.nodes?.length) hasLayerBlock = true;
1624
- });
1625
- return hasLayerBlock;
1626
- } catch {
1627
- return true;
1628
- }
1629
- }
1630
- function collectUserLayerSelectors(source) {
1631
- const selectors = /* @__PURE__ */ new Set();
1632
- try {
1633
- postcss.parse(source).walkRules((rule) => {
1634
- for (const selector of rule.selectors ?? [rule.selector]) {
1635
- const normalized = selector.trim();
1636
- if (normalized) selectors.add(normalized);
1637
- }
1638
- });
1639
- } catch {}
1640
- return selectors;
1641
- }
1642
- function matchesUserLayerSelector(selector, userLayerSelector) {
1643
- if (selector === userLayerSelector) return true;
1644
- if (!selector.startsWith(userLayerSelector)) return false;
1645
- const next = selector[userLayerSelector.length];
1646
- return next === ":" || next === "[";
1647
- }
1648
- function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
1649
- const selectors = collectUserLayerSelectors(userLayerSource);
1650
- if (selectors.size === 0) return {
1651
- layer: "",
1652
- rest: css
1653
- };
1654
- try {
1655
- const root = postcss.parse(css);
1656
- const layerRoot = postcss.root();
1657
- const selectorList = [...selectors];
1658
- root.walkRules((rule) => {
1659
- if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
1660
- layerRoot.append(rule.clone());
1661
- rule.remove();
1662
- }
1663
- });
1664
- return {
1665
- layer: layerRoot.toString(),
1666
- rest: root.toString()
1667
- };
1668
- } catch {
1669
- return {
1670
- layer: "",
1671
- rest: css
1672
- };
1673
- }
1674
- }
1675
- function normalizeGeneratedSelector(selector) {
1676
- return selector.replace(/:not\(#\\#\)/g, "").trim();
1677
- }
1678
- function collectApplyOnlySourceSelectors(source) {
1679
- const selectors = /* @__PURE__ */ new Set();
1680
- try {
1681
- postcss.parse(source).walkRules((rule) => {
1682
- if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
1683
- for (const selector of rule.selectors ?? [rule.selector]) {
1684
- const normalized = normalizeGeneratedSelector(selector);
1685
- if (normalized) selectors.add(normalized);
1686
- }
1687
- });
1688
- } catch {}
1689
- return selectors;
1690
- }
1691
- function hasOnlyApplyBackedSourceRules(source) {
1692
- let hasApplyRule = false;
1693
- let hasNonApplyRule = false;
1694
- try {
1695
- postcss.parse(source).walkRules((rule) => {
1696
- if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
1697
- else hasNonApplyRule = true;
1698
- });
2014
+ hasLocalImport = true;
2015
+ continue;
2016
+ }
2017
+ if (node.type === "atrule" && node.name === "source") {
2018
+ hasTailwindDirective = true;
2019
+ continue;
2020
+ }
2021
+ return;
2022
+ }
1699
2023
  } catch {
1700
- return false;
2024
+ return;
1701
2025
  }
1702
- return hasApplyRule && !hasNonApplyRule;
2026
+ return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
1703
2027
  }
1704
- function filterApplyOnlyGeneratedCss(css, source) {
1705
- const selectors = collectApplyOnlySourceSelectors(source);
1706
- if (selectors.size === 0) return css;
1707
- const selectorList = [...selectors];
2028
+ function prefixLocalCssImportsWithWebpackIgnore(css) {
1708
2029
  try {
1709
2030
  const root = postcss.parse(css);
1710
- root.walkRules((rule) => {
1711
- const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
1712
- const normalized = normalizeGeneratedSelector(selector);
1713
- return selectorList.some((sourceSelector) => {
1714
- if (normalized === sourceSelector) return true;
1715
- if (!normalized.startsWith(sourceSelector)) return false;
1716
- const next = normalized[sourceSelector.length];
1717
- return next === ":" || next === "[" || next === ".";
1718
- });
1719
- });
1720
- const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
1721
- if (!isApplySelector && !isVariableRule) rule.remove();
1722
- });
1723
- root.walkAtRules((rule) => {
1724
- if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
2031
+ root.walkAtRules("import", (atRule) => {
2032
+ const request = parseImportRequest(atRule.params);
2033
+ if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
1725
2034
  });
1726
2035
  return root.toString();
1727
2036
  } catch {
1728
2037
  return css;
1729
2038
  }
1730
2039
  }
1731
- function shouldFilterApplyOnlyGeneratedCss(majorVersion, target, source, options) {
1732
- return majorVersion === 4 && target === "weapp" && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
2040
+ function splitLocalCssImports(source) {
2041
+ try {
2042
+ const root = postcss.parse(source);
2043
+ const importRoot = postcss.root();
2044
+ let changed = false;
2045
+ for (const node of [...root.nodes]) {
2046
+ if (node.type !== "atrule" || node.name !== "import") continue;
2047
+ const request = parseImportRequest(node.params);
2048
+ if (!request || !isLocalImportRequest(request)) continue;
2049
+ importRoot.append(node.clone());
2050
+ node.remove();
2051
+ changed = true;
2052
+ }
2053
+ const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
2054
+ return changed ? {
2055
+ imports,
2056
+ source: root.toString()
2057
+ } : void 0;
2058
+ } catch {
2059
+ return;
2060
+ }
1733
2061
  }
1734
- async function transformGeneratorUserCss(source, options) {
1735
- if (source.trim().length === 0) return "";
1736
- const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
1737
- if (cleanedSource.trim().length === 0) return "";
1738
- const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(unwrapMiniProgramCascadeLayers(cleanedSource)) : cleanedSource)), { importFallback: options.importFallback })));
1739
- if (userSource.trim().length === 0) return "";
1740
- if (isCommentOnlyCss(userSource)) return userSource;
1741
- if (options.generatorTarget !== "weapp") return userSource;
1742
- const { css } = await options.styleHandler(userSource, {
1743
- ...options.generatorStyleOptions,
1744
- ...options.cssUserHandlerOptions
1745
- });
1746
- return removeUnsupportedMiniProgramAtRules(css);
2062
+ function restoreLocalCssImports(css, imports) {
2063
+ if (!imports?.trim()) return css;
2064
+ return createCssSourceOrderAppend(imports, css);
2065
+ }
2066
+ function splitRequestSuffix(request) {
2067
+ const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
2068
+ const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
2069
+ if (suffixIndex < 0) return {
2070
+ clean: request,
2071
+ suffix: ""
2072
+ };
2073
+ return {
2074
+ clean: request.slice(0, suffixIndex),
2075
+ suffix: request.slice(suffixIndex)
2076
+ };
2077
+ }
2078
+ function normalizeOutputImportRequest(request, styleOutputExtension) {
2079
+ const normalizedStyleOutputExtension = styleOutputExtension?.startsWith(".") ? styleOutputExtension : styleOutputExtension ? `.${styleOutputExtension}` : void 0;
2080
+ const { clean, suffix } = splitRequestSuffix(request.replace(/\\/g, "/"));
2081
+ return `${clean.replace(/^(?:\.\/)?src\//, "./").replace(SOURCE_STYLE_EXTENSION_RE, normalizedStyleOutputExtension ?? ".css")}${suffix}`;
2082
+ }
2083
+ function rewriteLocalCssImportRequestsForOutput(css, options = {}) {
2084
+ if (!css.includes("@import")) return css;
2085
+ try {
2086
+ const root = postcss.parse(css);
2087
+ let changed = false;
2088
+ root.walkAtRules("import", (atRule) => {
2089
+ const request = parseImportRequest(atRule.params);
2090
+ if (!request || !isLocalImportRequest(request) || !CSS_STYLE_EXTENSION_RE.test(request)) return;
2091
+ const rewritten = normalizeOutputImportRequest(request, options.styleOutputExtension);
2092
+ if (rewritten === request) return;
2093
+ atRule.params = atRule.params.replace(request, rewritten);
2094
+ changed = true;
2095
+ });
2096
+ return changed ? root.toString() : css;
2097
+ } catch {
2098
+ return css;
2099
+ }
1747
2100
  }
1748
2101
  //#endregion
1749
2102
  //#region src/bundlers/shared/generator-css/user-layer-order.ts
@@ -1892,17 +2245,21 @@ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, fac
1892
2245
  await Promise.all(executing);
1893
2246
  return results;
1894
2247
  }
2248
+ function resolveTaskConcurrency(defaultLimit = 1) {
2249
+ const configured = Number.parseInt(process.env["WEAPP_TW_TASK_CONCURRENCY"] ?? "", 10);
2250
+ if (Number.isFinite(configured) && configured > 0) return configured;
2251
+ return defaultLimit;
2252
+ }
1895
2253
  function pushConcurrentTaskFactories(queue, factories, limit) {
1896
2254
  if (factories.length === 0) return;
1897
2255
  queue.push(runWithConcurrency(factories, limit).then(() => void 0));
1898
2256
  }
1899
2257
  //#endregion
1900
2258
  //#region src/bundlers/shared/generator-css/validate.ts
1901
- const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
1902
2259
  async function validateCandidatesByGenerator(options) {
1903
2260
  const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState, skipGenerateFallback } = options;
1904
- const majorVersion = runtimeState.twPatcher.majorVersion;
1905
- if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
2261
+ const majorVersion = runtimeState.tailwindRuntime.majorVersion;
2262
+ if (majorVersion !== 4 || candidates.size === 0) return /* @__PURE__ */ new Set();
1906
2263
  const generatorOptions = {
1907
2264
  ...normalizeWeappTailwindcssGeneratorOptions(opts.generator),
1908
2265
  bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
@@ -1920,7 +2277,7 @@ async function validateCandidatesByGenerator(options) {
1920
2277
  return (await generator.generate({
1921
2278
  bareArbitraryValues: generatorOptions.bareArbitraryValues,
1922
2279
  candidates,
1923
- target: "tailwind"
2280
+ target: "web"
1924
2281
  })).classSet;
1925
2282
  }));
1926
2283
  const classSet = new Set(classSets.flatMap((item) => [...item]));
@@ -1934,38 +2291,87 @@ function resolveGeneratorSourceConcurrency() {
1934
2291
  if (Number.isFinite(configured) && configured > 0) return configured;
1935
2292
  return 1;
1936
2293
  }
2294
+ function intersectCandidateSets(left, right) {
2295
+ if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
2296
+ const [small, large] = left.size <= right.size ? [left, right] : [right, left];
2297
+ const matched = /* @__PURE__ */ new Set();
2298
+ for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
2299
+ return matched;
2300
+ }
2301
+ function collectCssRuleIdentityMarkers(source) {
2302
+ const markers = /* @__PURE__ */ new Set();
2303
+ try {
2304
+ const root = postcss.parse(source);
2305
+ root.walkRules((rule) => {
2306
+ for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
2307
+ });
2308
+ root.walkAtRules("keyframes", (rule) => {
2309
+ if (rule.params) markers.add(`keyframes:${rule.params}`);
2310
+ });
2311
+ } catch {}
2312
+ return markers;
2313
+ }
2314
+ function isCssAlreadyRepresentedByMarkers(css, source) {
2315
+ const sourceMarkers = collectCssRuleIdentityMarkers(source);
2316
+ if (sourceMarkers.size === 0) return false;
2317
+ const cssMarkers = collectCssRuleIdentityMarkers(css);
2318
+ for (const marker of sourceMarkers) if (!cssMarkers.has(marker)) return false;
2319
+ return true;
2320
+ }
1937
2321
  async function generateCssByGenerator(options) {
1938
- const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
2322
+ const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
1939
2323
  const generatorOptions = {
1940
- ...normalizeWeappTailwindcssGeneratorOptions(opts.generator),
2324
+ ...normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
2325
+ appType: opts.appType,
2326
+ platform: opts.cssOptions?.platform ?? opts.platform,
2327
+ tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
2328
+ uniAppX: opts.uniAppX
2329
+ }),
1941
2330
  bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
1942
2331
  };
1943
- const majorVersion = runtimeState.twPatcher.majorVersion;
2332
+ const generatorBranch = resolveGeneratorRuntimeBranch(generatorOptions, {
2333
+ appType: opts.appType,
2334
+ platform: opts.cssOptions?.platform ?? opts.platform,
2335
+ tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
2336
+ uniAppX: opts.uniAppX
2337
+ });
2338
+ const majorVersion = runtimeState.tailwindRuntime.majorVersion;
2339
+ if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
1944
2340
  const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
1945
2341
  const localImportParts = splitLocalCssImports(effectiveRawSource);
2342
+ const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
1946
2343
  const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
1947
- const userCssRawSource = majorVersion === 4 ? removeTailwindV4GeneratorAtRules(generatorRawSource) : generatorRawSource;
2344
+ const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
2345
+ const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
2346
+ const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
2347
+ const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : userCssRawSource;
2348
+ const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(userCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
1948
2349
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
1949
2350
  if (cleanedLocalImportWrapper !== void 0) return {
1950
- css: generatorOptions.target === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
2351
+ css: shouldUseMiniProgramCssBranch(generatorBranch) ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
2352
+ classSet: /* @__PURE__ */ new Set(),
1951
2353
  target: generatorOptions.target,
1952
2354
  source: "generator",
1953
- dependencies: []
2355
+ dependencies: [],
2356
+ metadata: {
2357
+ file,
2358
+ majorVersion
2359
+ }
1954
2360
  };
1955
2361
  if (isPureLocalCssImportWrapper(effectiveRawSource)) return;
1956
2362
  const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
1957
2363
  const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
1958
2364
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
1959
- const shouldGenerateCurrentCss = shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
2365
+ if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
2366
+ forceGenerator: options.forceGenerator,
1960
2367
  hasGeneratedCss,
1961
2368
  hasGeneratedMarkers,
1962
2369
  hasSourceDirectives,
1963
2370
  rawSource: generatorRawSource
1964
- });
1965
- if (!isSupportedGeneratorMajorVersion(majorVersion) || !shouldGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) return;
2371
+ })) return;
1966
2372
  try {
1967
2373
  await runtimeState.readyPromise;
1968
- const currentCssCandidates = majorVersion === 4 ? await extractSourceCandidates(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } }) : [];
2374
+ const currentCssCandidates = await extractSourceCandidates(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } });
1969
2375
  const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
1970
2376
  hasGeneratedCss,
1971
2377
  hasGeneratedMarkers,
@@ -1983,8 +2389,9 @@ async function generateCssByGenerator(options) {
1983
2389
  const sourceConcurrency = resolveGeneratorSourceConcurrency();
1984
2390
  const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
1985
2391
  const generator = createWeappTailwindcssGenerator(source);
1986
- const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
1987
- const scopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
2392
+ const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
2393
+ const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
2394
+ const scopedRuntime = options.sourceCandidates && sourceScopedRuntime ? intersectCandidateSets(options.sourceCandidates, sourceScopedRuntime) : options.sourceCandidates ?? sourceScopedRuntime;
1988
2395
  const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
1989
2396
  cssHandlerOptions,
1990
2397
  target: generatorOptions.target
@@ -2002,15 +2409,13 @@ async function generateCssByGenerator(options) {
2002
2409
  majorVersion,
2003
2410
  matchedCssSourceFile
2004
2411
  }) : runtimeWithCurrentCss;
2005
- const generatorRuntime = majorVersion === 4 && generatorOptions.target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
2006
- const useIncrementalCache = (majorVersion === 3 || majorVersion === 4) && !(majorVersion === 3 && isolateCssSource);
2412
+ const generatorRuntime = shouldUseMiniProgramCssBranch(generatorBranch) ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
2007
2413
  return generator.generate({
2008
2414
  bareArbitraryValues: generatorOptions.bareArbitraryValues,
2009
2415
  candidates: generatorRuntime,
2010
- incrementalCache: useIncrementalCache,
2416
+ incrementalCache: true,
2011
2417
  scanSources: shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, generatorRuntime, isolateCssSource),
2012
2418
  styleOptions: generatorStyleOptions,
2013
- tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
2014
2419
  target: generatorOptions.target
2015
2420
  });
2016
2421
  }), sourceConcurrency)).filter((item) => Boolean(item)));
@@ -2022,20 +2427,27 @@ async function generateCssByGenerator(options) {
2022
2427
  css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
2023
2428
  injectPreflight: false,
2024
2429
  styleOptions: generatorStyleOptions
2025
- })) : options.previousCss, localImportParts?.imports),
2430
+ })) : options.previousCss, localImports),
2431
+ classSet: generated.classSet,
2026
2432
  target: generated.target,
2027
2433
  source: "generator",
2028
2434
  dependencies: generated.dependencies,
2029
- incremental: true
2435
+ incremental: true,
2436
+ metadata: {
2437
+ file,
2438
+ majorVersion,
2439
+ rawCss: generated.rawCss
2440
+ }
2030
2441
  };
2031
2442
  }
2032
2443
  const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
2033
2444
  hasGeneratedCss,
2034
2445
  hasGeneratedMarkers
2035
2446
  });
2036
- const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(stripTailwindBanner(generated.css), generatorRawSource) : stripTailwindBanner(generated.css);
2447
+ const generatedCssSource = generated.target === "web" ? generated.css : stripTailwindBanner(generated.css);
2448
+ const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
2037
2449
  const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
2038
- const orderedExtraCss = hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssRawSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssRawSource, generated.rawCss);
2450
+ const orderedExtraCss = splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
2039
2451
  const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
2040
2452
  if (orderedExtraCss) {
2041
2453
  let css = generatedCss;
@@ -2045,7 +2457,8 @@ async function generateCssByGenerator(options) {
2045
2457
  generatorStyleOptions,
2046
2458
  cssUserHandlerOptions,
2047
2459
  styleHandler,
2048
- importFallback: generatorOptions.importFallback
2460
+ importFallback: generatorOptions.importFallback,
2461
+ processed: userRawSourceProcessed
2049
2462
  };
2050
2463
  const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
2051
2464
  layer: "",
@@ -2063,9 +2476,19 @@ async function generateCssByGenerator(options) {
2063
2476
  const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2064
2477
  css = createCssSourceOrderAppend$1(css, userCss);
2065
2478
  }
2479
+ if (generated.target === "web") {
2480
+ const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2481
+ const missingUserCss = isCommentOnlyCss(userCss) ? "" : filterExistingCssRules(css, userCss);
2482
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2483
+ }
2484
+ if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !hasTailwindApplyDirective(userCssRawSource)) {
2485
+ const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
2486
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
2487
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2488
+ }
2066
2489
  if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
2067
2490
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
2068
- if (!shouldFilterApplyOnlyCss) {
2491
+ if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed) {
2069
2492
  css = await appendLegacyCompatCss(css, userCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2070
2493
  if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2071
2494
  }
@@ -2075,17 +2498,31 @@ async function generateCssByGenerator(options) {
2075
2498
  injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2076
2499
  cssHandlerOptions,
2077
2500
  isolateCurrentCssCandidates,
2078
- localImports: localImportParts?.imports
2501
+ localImports
2079
2502
  }),
2080
2503
  styleOptions: generatorStyleOptions
2081
- }), localImportParts?.imports),
2504
+ }), localImports),
2505
+ classSet: generated.classSet,
2082
2506
  target: generated.target,
2083
2507
  source: "generator",
2084
- dependencies: generated.dependencies
2508
+ dependencies: generated.dependencies,
2509
+ metadata: {
2510
+ file,
2511
+ majorVersion,
2512
+ rawCss: generated.rawCss
2513
+ }
2085
2514
  };
2086
2515
  }
2087
2516
  debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
2088
2517
  let css = generatedCss;
2518
+ if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(userCssRawSource, {
2519
+ generatorTarget: generated.target,
2520
+ generatorStyleOptions,
2521
+ cssUserHandlerOptions,
2522
+ styleHandler,
2523
+ importFallback: generatorOptions.importFallback,
2524
+ processed: userRawSourceProcessed
2525
+ }), css);
2089
2526
  if (generated.target === "weapp") {
2090
2527
  css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
2091
2528
  if (hasUserCssLayerBlocks(generatorRawSource)) {
@@ -2095,7 +2532,8 @@ async function generateCssByGenerator(options) {
2095
2532
  generatorStyleOptions,
2096
2533
  cssUserHandlerOptions,
2097
2534
  styleHandler,
2098
- importFallback: generatorOptions.importFallback
2535
+ importFallback: generatorOptions.importFallback,
2536
+ processed: userRawSourceProcessed
2099
2537
  });
2100
2538
  const layerCss = layerUserCss.trim().length > 0 && !hasTailwindApplyDirective(layerUserCss) ? {
2101
2539
  layer: layerUserCss,
@@ -2108,22 +2546,36 @@ async function generateCssByGenerator(options) {
2108
2546
  }
2109
2547
  }
2110
2548
  if (hasMatchedCssSourceFile || generated.target === "web") {
2111
- if (hasMatchedCssSourceFile && generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
2549
+ if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
2112
2550
  const userCss = await transformGeneratorUserCss(userCssRawSource, {
2113
2551
  generatorTarget: generated.target,
2114
2552
  generatorStyleOptions,
2115
2553
  cssUserHandlerOptions,
2116
2554
  styleHandler,
2117
- importFallback: generatorOptions.importFallback
2555
+ importFallback: generatorOptions.importFallback,
2556
+ processed: userRawSourceProcessed
2118
2557
  });
2119
- css = createCssSourceOrderAppend$1(css, userCss);
2558
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
2559
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2560
+ } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers) {
2561
+ const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
2562
+ generatorTarget: generated.target,
2563
+ generatorStyleOptions,
2564
+ cssUserHandlerOptions,
2565
+ styleHandler,
2566
+ importFallback: generatorOptions.importFallback,
2567
+ processed: userRawSourceProcessed
2568
+ });
2569
+ const missingUserCss = filterExistingCssRules(css, userCss);
2570
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2120
2571
  } else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource)) {
2121
2572
  const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, {
2122
2573
  generatorTarget: generated.target,
2123
2574
  generatorStyleOptions,
2124
2575
  cssUserHandlerOptions,
2125
2576
  styleHandler,
2126
- importFallback: generatorOptions.importFallback
2577
+ importFallback: generatorOptions.importFallback,
2578
+ processed: userRawSourceProcessed
2127
2579
  });
2128
2580
  if (layerUserCss.trim().length > 0) {
2129
2581
  css = createCssSourceOrderAppend$1(css, wrapUserLayerComponentsCss(layerUserCss));
@@ -2131,7 +2583,7 @@ async function generateCssByGenerator(options) {
2131
2583
  }
2132
2584
  }
2133
2585
  if (hasMatchedCssSourceFile && generated.target === "weapp") {
2134
- if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2586
+ if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss && !userRawSourceProcessed) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2135
2587
  }
2136
2588
  if (shouldAppendWebBundleCssFallback(generated.target, {
2137
2589
  hasSourceDirectives,
@@ -2142,40 +2594,66 @@ async function generateCssByGenerator(options) {
2142
2594
  generatorStyleOptions,
2143
2595
  cssUserHandlerOptions,
2144
2596
  styleHandler,
2145
- importFallback: generatorOptions.importFallback
2597
+ importFallback: generatorOptions.importFallback,
2598
+ processed: userRawSourceProcessed
2146
2599
  });
2147
- css = createCssSourceOrderAppend$1(css, userCss);
2600
+ const missingUserCss = isCommentOnlyCss(userCss) ? "" : filterExistingCssRules(css, userCss);
2601
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2148
2602
  }
2149
2603
  return {
2150
2604
  css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
2151
2605
  injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2152
2606
  cssHandlerOptions,
2153
2607
  isolateCurrentCssCandidates,
2154
- localImports: localImportParts?.imports
2608
+ localImports
2155
2609
  }),
2156
2610
  styleOptions: generatorStyleOptions
2157
- }), localImportParts?.imports),
2611
+ }), localImports),
2612
+ classSet: generated.classSet,
2158
2613
  target: generated.target,
2159
2614
  source: "generator",
2160
- dependencies: generated.dependencies
2615
+ dependencies: generated.dependencies,
2616
+ metadata: {
2617
+ file,
2618
+ majorVersion,
2619
+ rawCss: generated.rawCss
2620
+ }
2161
2621
  };
2162
2622
  }
2163
- if (!shouldFilterApplyOnlyCss) {
2623
+ if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed) {
2164
2624
  css = await appendLegacyCompatCss(css, userCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2165
2625
  css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
2166
2626
  }
2627
+ if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !hasTailwindApplyDirective(userCssRawSource)) {
2628
+ const userCss = await transformGeneratorUserCss(userCssRawSource, {
2629
+ generatorTarget: generated.target,
2630
+ generatorStyleOptions,
2631
+ cssUserHandlerOptions,
2632
+ styleHandler,
2633
+ importFallback: generatorOptions.importFallback,
2634
+ processed: userRawSourceProcessed
2635
+ });
2636
+ const missingUserCss = isCssAlreadyRepresentedByMarkers(css, userCssRawSource) ? filterExistingCssRules(css, userCss) : userCss;
2637
+ css = createCssSourceOrderAppend$1(css, missingUserCss);
2638
+ }
2167
2639
  return {
2168
2640
  css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
2169
2641
  injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
2170
2642
  cssHandlerOptions,
2171
2643
  isolateCurrentCssCandidates,
2172
- localImports: localImportParts?.imports
2644
+ localImports
2173
2645
  }),
2174
2646
  styleOptions: generatorStyleOptions
2175
- }), localImportParts?.imports),
2647
+ }), localImports),
2648
+ classSet: generated.classSet,
2176
2649
  target: generated.target,
2177
2650
  source: "generator",
2178
- dependencies: generated.dependencies
2651
+ dependencies: generated.dependencies,
2652
+ metadata: {
2653
+ file,
2654
+ majorVersion,
2655
+ rawCss: generated.rawCss
2656
+ }
2179
2657
  };
2180
2658
  } catch (error) {
2181
2659
  debug("tailwind direct css generation failed: %s %O", file, error);
@@ -2276,182 +2754,19 @@ function collectEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
2276
2754
  }
2277
2755
  return candidates;
2278
2756
  }
2279
- //#endregion
2280
- //#region src/bundlers/vite/incremental-runtime-class-set/v3-candidates.ts
2281
- const TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES = new Set([
2282
- "accent",
2283
- "animate",
2284
- "basis",
2285
- "bg",
2286
- "blur",
2287
- "border",
2288
- "bottom",
2289
- "brightness",
2290
- "caret",
2291
- "col",
2292
- "columns",
2293
- "content",
2294
- "contrast",
2295
- "decoration",
2296
- "delay",
2297
- "divide",
2298
- "drop-shadow",
2299
- "duration",
2300
- "ease",
2301
- "fill",
2302
- "font",
2303
- "gap",
2304
- "gradient",
2305
- "grid",
2306
- "grayscale",
2307
- "grow",
2308
- "h",
2309
- "hue-rotate",
2310
- "indent",
2311
- "inset",
2312
- "invert",
2313
- "leading",
2314
- "left",
2315
- "list",
2316
- "m",
2317
- "max",
2318
- "mb",
2319
- "min",
2320
- "ml",
2321
- "mr",
2322
- "mt",
2323
- "mx",
2324
- "my",
2325
- "object",
2326
- "opacity",
2327
- "order",
2328
- "outline",
2329
- "overflow",
2330
- "p",
2331
- "pb",
2332
- "pl",
2333
- "pr",
2334
- "pt",
2335
- "px",
2336
- "py",
2337
- "right",
2338
- "ring",
2339
- "rotate",
2340
- "rounded",
2341
- "row",
2342
- "saturate",
2343
- "scale",
2344
- "scroll",
2345
- "sepia",
2346
- "shadow",
2347
- "shrink",
2348
- "skew",
2349
- "space",
2350
- "stroke",
2351
- "text",
2352
- "top",
2353
- "tracking",
2354
- "translate",
2355
- "underline",
2356
- "w",
2357
- "z"
2358
- ]);
2359
- function isUrlLikeCandidate(candidate) {
2360
- return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
2361
- }
2362
- function getBaseUtilityCandidate(candidate) {
2363
- let bracketDepth = 0;
2364
- let lastVariantSeparator = -1;
2365
- for (let index = 0; index < candidate.length; index++) {
2366
- const char = candidate[index];
2367
- if (char === "[") bracketDepth += 1;
2368
- else if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
2369
- else if (char === ":" && bracketDepth === 0) lastVariantSeparator = index;
2370
- }
2371
- let utility = lastVariantSeparator >= 0 ? candidate.slice(lastVariantSeparator + 1) : candidate;
2372
- if (utility.startsWith("!")) utility = utility.slice(1);
2373
- if (utility.startsWith("-")) utility = utility.slice(1);
2374
- return utility;
2375
- }
2376
- function getArbitraryUtilityPrefix(utility) {
2377
- const bracketIndex = utility.indexOf("[");
2378
- if (bracketIndex <= 0 || !utility.endsWith("]")) return;
2379
- const prefix = utility.slice(0, bracketIndex).replace(/-$/, "");
2380
- const firstDash = prefix.indexOf("-");
2381
- return firstDash >= 0 ? prefix.slice(0, firstDash) : prefix;
2382
- }
2383
- function isLikelyTailwindV3ArbitraryUtility(candidate) {
2384
- const utility = getBaseUtilityCandidate(candidate);
2385
- if (utility.startsWith("[") && utility.endsWith("]") && utility.includes(":")) return true;
2386
- const prefix = getArbitraryUtilityPrefix(utility);
2387
- return Boolean(prefix && TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES.has(prefix));
2388
- }
2389
- function isLikelyTailwindV3VariantUtility(candidate) {
2390
- if (!candidate.includes(":") || isUrlLikeCandidate(candidate)) return false;
2391
- const utility = getBaseUtilityCandidate(candidate);
2392
- return /^[!-]?[a-z@[]/.test(utility);
2393
- }
2394
- function isLikelyTailwindV3OpacityModifier(candidate) {
2395
- if (!candidate.includes("/") || isUrlLikeCandidate(candidate)) return false;
2396
- const utility = getBaseUtilityCandidate(candidate);
2397
- return /^[!-]?[a-z][\w-]*-\w[\w-]*\/(?:\d+|\[[^\]]+\])$/.test(utility);
2398
- }
2399
- function isHighConfidenceV3Candidate(candidate) {
2400
- return isLikelyTailwindV3ArbitraryUtility(candidate) || isLikelyTailwindV3VariantUtility(candidate) || isLikelyTailwindV3OpacityModifier(candidate);
2401
- }
2402
- function isRawCandidateInClassContext(source, start, extension) {
2403
- if (typeof start !== "number" || start <= 0) return false;
2404
- const before = source.slice(Math.max(0, start - 200), start);
2405
- if (extension === "html") return /\bclass\s*=\s*["'][^"']*$/i.test(before);
2406
- return /\bclass(?:Name)?\s*[:=]\s*["'][^"']*$/i.test(before) || /\.classList\.(?:add|remove|toggle|contains)\([^)]*$/i.test(before);
2407
- }
2408
- function resolveQuotedLiteralRange(source, start) {
2409
- if (typeof start !== "number" || start <= 0) return;
2410
- let quote;
2411
- let literalStart = -1;
2412
- for (let index = start - 1; index >= 0; index--) {
2413
- const char = source[index];
2414
- if (char !== "\"" && char !== "'" && char !== "`") continue;
2415
- quote = char;
2416
- literalStart = index;
2417
- break;
2418
- }
2419
- if (!quote) return;
2420
- let escaped = false;
2421
- for (let index = literalStart + 1; index < source.length; index++) {
2422
- const char = source[index];
2423
- if (escaped) {
2424
- escaped = false;
2425
- continue;
2426
- }
2427
- if (char === "\\") {
2428
- escaped = true;
2429
- continue;
2430
- }
2431
- if (char === quote) {
2432
- if (start < index) return {
2433
- start: literalStart,
2434
- end: index
2435
- };
2436
- return;
2757
+ function collectStrictEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
2758
+ const candidates = /* @__PURE__ */ new Set();
2759
+ ESCAPED_CLASS_TOKEN_RE.lastIndex = 0;
2760
+ let match = ESCAPED_CLASS_TOKEN_RE.exec(source);
2761
+ while (match) {
2762
+ const token = match[0];
2763
+ if (hasEscapeFragment(token, escapeFragments)) {
2764
+ const restored = unescape(token, { map: escapeMap });
2765
+ if (restored !== token && TAILWIND_RESTORED_CANDIDATE_SIGNAL_RE.test(restored) && !/\s/.test(restored)) candidates.add(restored);
2437
2766
  }
2767
+ match = ESCAPED_CLASS_TOKEN_RE.exec(source);
2438
2768
  }
2439
- }
2440
- function createHighConfidenceLiteralRanges(source, matches) {
2441
- const ranges = [];
2442
- for (const match of matches) {
2443
- const candidate = match?.rawCandidate;
2444
- if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
2445
- const range = resolveQuotedLiteralRange(source, match?.start ?? source.indexOf(candidate));
2446
- if (range) ranges.push(range);
2447
- }
2448
- return ranges;
2449
- }
2450
- function isRawCandidateInRanges(start, ranges) {
2451
- return typeof start === "number" && ranges.some((range) => start > range.start && start < range.end);
2452
- }
2453
- function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
2454
- return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
2769
+ return candidates;
2455
2770
  }
2456
2771
  //#endregion
2457
2772
  //#region src/bundlers/vite/incremental-runtime-class-set.ts
@@ -2517,8 +2832,8 @@ function createBundleRuntimeClassSetManager(options = {}) {
2517
2832
  validationContext = void 0;
2518
2833
  designSystemPromise = void 0;
2519
2834
  }
2520
- async function resolveValidationContextCached(patcher) {
2521
- if (!validationContext) validationContext = await resolveTailwindV4SourceFromPatcher(patcher);
2835
+ async function resolveValidationContextCached(runtime) {
2836
+ if (!validationContext) validationContext = await resolveTailwindV4SourceFromRuntime(runtime);
2522
2837
  return validationContext;
2523
2838
  }
2524
2839
  async function loadDesignSystem(context) {
@@ -2529,13 +2844,9 @@ function createBundleRuntimeClassSetManager(options = {}) {
2529
2844
  const validCandidates = resolveValidTailwindV4Candidates(designSystem, unknownCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2530
2845
  for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
2531
2846
  }
2532
- async function validateUnknownCandidates(patcher, unknownCandidates) {
2847
+ async function validateUnknownCandidates(runtime, unknownCandidates) {
2533
2848
  if (unknownCandidates.size === 0) return;
2534
- if (patcher.majorVersion === 3 && !customExtractCandidates) {
2535
- for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, true);
2536
- return;
2537
- }
2538
- const context = await resolveValidationContextCached(patcher);
2849
+ const context = await resolveValidationContextCached(runtime);
2539
2850
  if (!customExtractCandidates) try {
2540
2851
  populateCandidateValidityCacheFromDesignSystem(await loadDesignSystem(context), unknownCandidates);
2541
2852
  return;
@@ -2548,23 +2859,19 @@ function createBundleRuntimeClassSetManager(options = {}) {
2548
2859
  const validCandidates = new Set(await extractCandidates(createExtractOptions(context, source, options.bareArbitraryValues)));
2549
2860
  for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
2550
2861
  }
2551
- async function extractEntryRawCandidates(entry, patcher, knownSourceCandidates) {
2862
+ async function extractEntryRawCandidates(entry, _runtime, _knownSourceCandidates) {
2552
2863
  const extension = resolveEntryExtension(entry);
2553
2864
  const matches = options.bareArbitraryValues === void 0 || options.bareArbitraryValues === false ? await extractRawCandidates(entry.source, extension) : await extractRawCandidates(entry.source, extension, { bareArbitraryValues: options.bareArbitraryValues });
2554
- const highConfidenceLiteralRanges = patcher.majorVersion === 3 && !customExtractCandidates ? createHighConfidenceLiteralRanges(entry.source, matches) : [];
2555
2865
  const candidates = /* @__PURE__ */ new Set();
2556
2866
  for (const match of matches) {
2557
2867
  const candidate = match?.rawCandidate;
2558
- if (typeof candidate === "string" && candidate.length > 0) {
2559
- if (patcher.majorVersion === 3 && !customExtractCandidates && !isRawCandidateAllowedForV3(entry.source, candidate, match.start, extension, knownSourceCandidates, highConfidenceLiteralRanges)) continue;
2560
- candidates.add(candidate);
2561
- }
2868
+ if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
2562
2869
  }
2563
- if (patcher.majorVersion === 4) for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
2870
+ for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
2564
2871
  return candidates;
2565
2872
  }
2566
- async function sync(patcher, snapshot, options = {}) {
2567
- const nextSignature = getRuntimeClassSetSignature(patcher) ?? "runtime:missing";
2873
+ async function sync(runtime, snapshot, options = {}) {
2874
+ const nextSignature = getRuntimeClassSetSignature(runtime) ?? "runtime:missing";
2568
2875
  const runtimeEntries = createRuntimeEntries(snapshot);
2569
2876
  const runtimeEntriesByFile = new Map(runtimeEntries.map((entry) => [entry.file, entry]));
2570
2877
  const currentRuntimeFiles = new Set(runtimeEntriesByFile.keys());
@@ -2589,14 +2896,14 @@ function createBundleRuntimeClassSetManager(options = {}) {
2589
2896
  }
2590
2897
  const rawCandidatesByFile = /* @__PURE__ */ new Map();
2591
2898
  const unknownCandidates = /* @__PURE__ */ new Set();
2592
- await Promise.all(changedRuntimeFiles.map(async (file) => {
2899
+ for (const file of changedRuntimeFiles) {
2593
2900
  const entry = runtimeEntriesByFile.get(file);
2594
- if (!entry) return;
2595
- const candidates = await extractEntryRawCandidates(entry, patcher, nextBaseClassSet);
2901
+ if (!entry) continue;
2902
+ const candidates = await extractEntryRawCandidates(entry, runtime, nextBaseClassSet);
2596
2903
  rawCandidatesByFile.set(file, candidates);
2597
2904
  for (const candidate of candidates) if (!candidateValidityCache.has(candidate)) unknownCandidates.add(candidate);
2598
- }));
2599
- await validateUnknownCandidates(patcher, unknownCandidates);
2905
+ }
2906
+ await validateUnknownCandidates(runtime, unknownCandidates);
2600
2907
  let rawCandidateCount = 0;
2601
2908
  for (const file of changedRuntimeFiles) {
2602
2909
  const nextRawCandidates = rawCandidatesByFile.get(file);
@@ -2626,6 +2933,52 @@ function createBundleRuntimeClassSetManager(options = {}) {
2626
2933
  };
2627
2934
  }
2628
2935
  //#endregion
2936
+ //#region src/tailwindcss/candidates.ts
2937
+ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
2938
+ "js",
2939
+ "jsx",
2940
+ "mjs",
2941
+ "cjs",
2942
+ "ts",
2943
+ "tsx",
2944
+ "mts",
2945
+ "cts"
2946
+ ]);
2947
+ async function extractCandidatesFromSource(source, extension, options = {}) {
2948
+ const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await extractSourceCandidates(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
2949
+ const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
2950
+ for (const candidate of scriptCandidates) candidates.add(candidate);
2951
+ return candidates;
2952
+ }
2953
+ async function extractScriptStringCandidates(source, extension, options) {
2954
+ if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
2955
+ const values = /* @__PURE__ */ new Set();
2956
+ try {
2957
+ traverse(babelParse(source, {
2958
+ cache: true,
2959
+ cacheKey: `source-candidates:${extension}`,
2960
+ plugins: ["jsx", "typescript"],
2961
+ sourceType: "unambiguous"
2962
+ }), {
2963
+ noScope: true,
2964
+ StringLiteral(path) {
2965
+ values.add(path.node.value);
2966
+ },
2967
+ TemplateElement(path) {
2968
+ values.add(path.node.value.raw);
2969
+ }
2970
+ });
2971
+ } catch {
2972
+ return [];
2973
+ }
2974
+ const candidates = /* @__PURE__ */ new Set();
2975
+ for (const value of values) {
2976
+ const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await extractSourceCandidates(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2977
+ for (const candidate of extractedCandidates) candidates.add(candidate);
2978
+ }
2979
+ return candidates;
2980
+ }
2981
+ //#endregion
2629
2982
  //#region src/bundlers/vite/source-candidates/scan-root.ts
2630
2983
  const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
2631
2984
  ".git",
@@ -2733,76 +3086,6 @@ function resolveSourceCandidateScanFiles(options) {
2733
3086
  });
2734
3087
  }
2735
3088
  //#endregion
2736
- //#region src/bundlers/vite/source-candidates/script.ts
2737
- const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
2738
- "js",
2739
- "jsx",
2740
- "mjs",
2741
- "cjs",
2742
- "ts",
2743
- "tsx",
2744
- "mts",
2745
- "cts"
2746
- ]);
2747
- async function extractScriptStringCandidates(source, extension, options) {
2748
- if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
2749
- const values = /* @__PURE__ */ new Set();
2750
- try {
2751
- traverse(babelParse(source, {
2752
- cache: true,
2753
- cacheKey: `vite-source-candidates:${extension}`,
2754
- plugins: ["jsx", "typescript"],
2755
- sourceType: "unambiguous"
2756
- }), {
2757
- noScope: true,
2758
- StringLiteral(path) {
2759
- values.add(path.node.value);
2760
- },
2761
- TemplateElement(path) {
2762
- values.add(path.node.value.raw);
2763
- }
2764
- });
2765
- } catch {
2766
- return [];
2767
- }
2768
- const candidates = /* @__PURE__ */ new Set();
2769
- for (const value of values) {
2770
- const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await extractSourceCandidates(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
2771
- for (const candidate of extractedCandidates) candidates.add(candidate);
2772
- }
2773
- return candidates;
2774
- }
2775
- //#endregion
2776
- //#region src/bundlers/vite/source-candidates/tailwind-v3-default-extractor.ts
2777
- const require = createRequire(import.meta.url);
2778
- const TAILWIND_V3_HTML_TOKEN_CANDIDATES = new Set([
2779
- "/block",
2780
- "/div",
2781
- "/span",
2782
- "/template",
2783
- "/text",
2784
- "/view",
2785
- "class",
2786
- "className",
2787
- "div",
2788
- "hover-class",
2789
- "span",
2790
- "template",
2791
- "text",
2792
- "view"
2793
- ]);
2794
- function createTailwindV3DefaultExtractor() {
2795
- try {
2796
- const defaultExtractorModule = require("tailwindcss/lib/lib/defaultExtractor");
2797
- const resolveConfigModule = require("tailwindcss/resolveConfig");
2798
- const resolveConfig = resolveConfigModule.default ?? resolveConfigModule;
2799
- const extractor = (defaultExtractorModule.defaultExtractor ?? defaultExtractorModule.default ?? defaultExtractorModule)({ tailwindConfig: resolveConfig({ content: [] }) });
2800
- return (source) => new Set(extractor(source).filter((candidate) => !TAILWIND_V3_HTML_TOKEN_CANDIDATES.has(candidate)));
2801
- } catch {
2802
- return;
2803
- }
2804
- }
2805
- //#endregion
2806
3089
  //#region src/bundlers/vite/source-candidates.ts
2807
3090
  const CLEAN_URL_RE = /[?#].*$/;
2808
3091
  const sourceCandidateContentCache = new LRUCache({ max: 128 });
@@ -2817,10 +3100,7 @@ function createSourceCandidateContentCacheKey(extension, source, bareArbitraryVa
2817
3100
  return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${md5Hash(source)}`;
2818
3101
  }
2819
3102
  async function extractCandidates(source, extension, options) {
2820
- const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await extractSourceCandidates(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
2821
- const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
2822
- for (const candidate of scriptCandidates) candidates.add(candidate);
2823
- return candidates;
3103
+ return extractCandidatesFromSource(source, extension, options);
2824
3104
  }
2825
3105
  function isSourceCandidateRequest(id) {
2826
3106
  return FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
@@ -2839,18 +3119,20 @@ function removeCandidateSet(candidateCount, candidates) {
2839
3119
  function addCandidateSet(candidateCount, candidates) {
2840
3120
  for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
2841
3121
  }
2842
- function createSourceCandidateCollector(options = {}) {
3122
+ function createSourceCandidateStore(options = {}) {
2843
3123
  const candidatesById = /* @__PURE__ */ new Map();
2844
3124
  const scanCandidatesById = /* @__PURE__ */ new Map();
2845
3125
  const transformCandidatesById = /* @__PURE__ */ new Map();
2846
3126
  const cssCandidatesById = /* @__PURE__ */ new Map();
2847
- const sourceById = /* @__PURE__ */ new Map();
3127
+ const scanSourceById = /* @__PURE__ */ new Map();
3128
+ const transformSourceById = /* @__PURE__ */ new Map();
3129
+ const cssSourceById = /* @__PURE__ */ new Map();
2848
3130
  const candidateCount = /* @__PURE__ */ new Map();
2849
3131
  let inlineIncludedCandidates = /* @__PURE__ */ new Set();
2850
3132
  let inlineExcludedCandidates = /* @__PURE__ */ new Set();
2851
3133
  async function sync(id, source) {
2852
3134
  const normalizedId = cleanUrl(id);
2853
- sourceById.set(normalizedId, source);
3135
+ scanSourceById.set(normalizedId, source);
2854
3136
  const extension = resolveSourceCandidateExtension(normalizedId);
2855
3137
  const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
2856
3138
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
@@ -2864,7 +3146,7 @@ function createSourceCandidateCollector(options = {}) {
2864
3146
  }
2865
3147
  async function syncCss(id, source) {
2866
3148
  const normalizedId = cleanUrl(id);
2867
- sourceById.set(normalizedId, source);
3149
+ cssSourceById.set(normalizedId, source);
2868
3150
  const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
2869
3151
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
2870
3152
  if (cachedCandidates) {
@@ -2877,7 +3159,7 @@ function createSourceCandidateCollector(options = {}) {
2877
3159
  }
2878
3160
  async function merge(id, source) {
2879
3161
  const normalizedId = cleanUrl(id);
2880
- sourceById.set(normalizedId, source);
3162
+ transformSourceById.set(normalizedId, source);
2881
3163
  const extension = resolveSourceCandidateExtension(normalizedId);
2882
3164
  const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
2883
3165
  const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
@@ -2959,17 +3241,20 @@ function createSourceCandidateCollector(options = {}) {
2959
3241
  scanCandidatesById.delete(normalizedId);
2960
3242
  transformCandidatesById.delete(normalizedId);
2961
3243
  cssCandidatesById.delete(normalizedId);
2962
- sourceById.delete(normalizedId);
3244
+ scanSourceById.delete(normalizedId);
3245
+ transformSourceById.delete(normalizedId);
3246
+ cssSourceById.delete(normalizedId);
2963
3247
  const previousCandidates = candidatesById.get(normalizedId);
2964
3248
  if (!previousCandidates) return;
2965
3249
  removeCandidateSet(candidateCount, previousCandidates);
2966
3250
  candidatesById.delete(normalizedId);
2967
3251
  }
2968
3252
  function source(id) {
2969
- return sourceById.get(cleanUrl(id));
3253
+ const normalizedId = cleanUrl(id);
3254
+ return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId);
2970
3255
  }
2971
3256
  function sources() {
2972
- return sourceById.entries();
3257
+ return mergeSourcesByPriority().entries();
2973
3258
  }
2974
3259
  function values() {
2975
3260
  const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
@@ -3020,7 +3305,9 @@ function createSourceCandidateCollector(options = {}) {
3020
3305
  scanCandidatesById.clear();
3021
3306
  transformCandidatesById.clear();
3022
3307
  cssCandidatesById.clear();
3023
- sourceById.clear();
3308
+ scanSourceById.clear();
3309
+ transformSourceById.clear();
3310
+ cssSourceById.clear();
3024
3311
  candidateCount.clear();
3025
3312
  inlineIncludedCandidates.clear();
3026
3313
  inlineExcludedCandidates.clear();
@@ -3041,9 +3328,12 @@ function createSourceCandidateCollector(options = {}) {
3041
3328
  return {
3042
3329
  candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3043
3330
  cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3331
+ cssSourceById: [...cssSourceById.entries()],
3044
3332
  scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3045
- sourceById: [...sourceById.entries()],
3333
+ scanSourceById: [...scanSourceById.entries()],
3334
+ sourceById: [...mergeSourcesByPriority().entries()],
3046
3335
  transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
3336
+ transformSourceById: [...transformSourceById.entries()],
3047
3337
  inlineExcludedCandidates: [...inlineExcludedCandidates],
3048
3338
  inlineIncludedCandidates: [...inlineIncludedCandidates]
3049
3339
  };
@@ -3068,7 +3358,9 @@ function createSourceCandidateCollector(options = {}) {
3068
3358
  if (candidateSet.size === 0) continue;
3069
3359
  cssCandidatesById.set(id, candidateSet);
3070
3360
  }
3071
- for (const [id, source] of snapshot.sourceById ?? []) sourceById.set(id, source);
3361
+ for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
3362
+ for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
3363
+ for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
3072
3364
  const ids = new Set([
3073
3365
  ...scanCandidatesById.keys(),
3074
3366
  ...transformCandidatesById.keys(),
@@ -3077,6 +3369,7 @@ function createSourceCandidateCollector(options = {}) {
3077
3369
  for (const id of ids) recompute(id);
3078
3370
  }
3079
3371
  return {
3372
+ syncSource: sync,
3080
3373
  sync,
3081
3374
  syncCss,
3082
3375
  merge,
@@ -3096,6 +3389,16 @@ function createSourceCandidateCollector(options = {}) {
3096
3389
  resetScan,
3097
3390
  clear
3098
3391
  };
3392
+ function mergeSourcesByPriority() {
3393
+ const sources = /* @__PURE__ */ new Map();
3394
+ for (const [id, source] of transformSourceById) sources.set(id, source);
3395
+ for (const [id, source] of cssSourceById) sources.set(id, source);
3396
+ for (const [id, source] of scanSourceById) sources.set(id, source);
3397
+ return sources;
3398
+ }
3399
+ }
3400
+ function createSourceCandidateCollector(options = {}) {
3401
+ return createSourceCandidateStore(options);
3099
3402
  }
3100
3403
  //#endregion
3101
3404
  //#region src/bundlers/shared/hmr-timing.ts
@@ -3176,4 +3479,4 @@ function createHmrTimingRecorder(bundler) {
3176
3479
  };
3177
3480
  }
3178
3481
  //#endregion
3179
- export { createCssSourceTraceCacheSignature as _, createTailwindV3DefaultExtractor as a, processCachedTask as b, validateCandidatesByGenerator as c, extractMarkedUserLayerComponentsCss as d, mergeMarkedUserLayerComponentsCss as f, annotateCssSourceTrace as g, pruneMiniProgramGeneratedCss as h, isSourceCandidateRequest as i, pushConcurrentTaskFactories as l, finalizeMiniProgramCss as m, emitHmrTiming as n, createBundleRuntimeClassSetManager as o, isPureLocalCssImportWrapper as p, createSourceCandidateCollector as r, generateCssByGenerator as s, createHmrTimingRecorder as t, runWithConcurrency as u, createCssTokenSourceMap as v, isCssSourceTraceEnabled as y };
3482
+ export { stripMiniProgramCssSpecificityPlaceholders as A, stripUnmatchedTailwindSourceMediaCloseFragments as C, finalizeMiniProgramCss as D, hasMiniProgramTailwindV4PreflightReset as E, processCachedTask as F, createCssSourceTraceCacheSignature as M, createCssTokenSourceMap as N, hasMiniProgramCssSpecificityPlaceholders as O, isCssSourceTraceEnabled as P, stripTailwindSourceMediaFragments as S, createCssSourceOrderAppend$1 as T, isPureLocalCssImportWrapper as _, isSourceCandidateRequest as a, removeMiniProgramHoverSelectors as b, collectStrictEscapedRuntimeCandidates as c, validateCandidatesByGenerator as d, pushConcurrentTaskFactories as f, mergeMarkedUserLayerComponentsCss as g, extractMarkedUserLayerComponentsCss as h, createSourceCandidateStore as i, annotateCssSourceTrace as j, pruneMiniProgramGeneratedCss as k, createEscapeFragments as l, runWithConcurrency as m, emitHmrTiming as n, resolveSourceCandidateScanFiles as o, resolveTaskConcurrency as p, createSourceCandidateCollector as r, createBundleRuntimeClassSetManager as s, createHmrTimingRecorder as t, generateCssByGenerator as u, rewriteLocalCssImportRequestsForOutput as v, scoreTailwindV4CssSourceFileMatch as w, removeTailwindV4GeneratorAtRules as x, splitLocalCssImports as y };