weapp-tailwindcss 5.0.13 → 5.1.1

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 (200) 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/class-selectors.d.ts +2 -0
  7. package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
  8. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +10 -6
  9. package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  11. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
  12. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
  13. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
  14. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -2
  15. package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
  16. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
  17. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
  18. package/dist/bundlers/shared/run-tasks.d.ts +1 -0
  19. package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
  20. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  21. package/dist/bundlers/vite/css-memory.d.ts +16 -0
  22. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
  23. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
  24. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
  25. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
  26. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +39 -0
  27. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
  28. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +1 -1
  29. package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +13 -0
  30. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +7 -0
  31. package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +26 -0
  32. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +4 -0
  33. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
  34. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -1
  35. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  36. package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +6 -0
  37. package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +25 -0
  38. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
  39. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
  40. package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +9 -0
  41. package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +9 -0
  42. package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +15 -0
  43. package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -1
  44. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
  45. package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
  46. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
  47. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
  48. package/dist/bundlers/vite/plugin-cache.d.ts +15 -0
  49. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  50. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -4
  51. package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
  52. package/dist/bundlers/vite/source-candidates.d.ts +9 -2
  53. package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
  54. package/dist/bundlers/vite/source-scan.d.ts +2 -2
  55. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
  56. package/dist/bundlers/vite/utils.d.ts +1 -0
  57. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +26 -2
  58. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +34 -0
  59. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
  60. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +37 -0
  61. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +199 -0
  62. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
  63. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +11 -0
  64. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
  65. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
  66. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
  67. package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
  68. package/dist/cache/index.d.ts +1 -0
  69. package/dist/cli/mount-options.d.ts +2 -2
  70. package/dist/cli.js +138 -444
  71. package/dist/cli.mjs +134 -440
  72. package/dist/context/index.d.ts +3 -3
  73. package/dist/context/style-options.d.ts +5 -1
  74. package/dist/context/tailwindcss.d.ts +1 -1
  75. package/dist/{precheck-B0Z8yW7E.js → context-B6hVF7dr.js} +405 -156
  76. package/dist/{precheck-CRI90iL1.mjs → context-DlpKD7aN.mjs} +377 -141
  77. package/dist/core.js +15 -12
  78. package/dist/core.mjs +10 -7
  79. package/dist/css-macro/index.d.ts +3 -7
  80. package/dist/css-macro.js +1 -1
  81. package/dist/css-macro.mjs +1 -1
  82. package/dist/{defaults-Bqx18S1f.mjs → defaults-BhE26nSw.mjs} +12 -13
  83. package/dist/{defaults-C_J_kBpw.js → defaults-CmFBmxsr.js} +11 -18
  84. package/dist/defaults.d.ts +2 -8
  85. package/dist/defaults.js +1 -2
  86. package/dist/defaults.mjs +2 -2
  87. package/dist/generator/index.d.ts +6 -7
  88. package/dist/generator/options.d.ts +3 -3
  89. package/dist/generator/types.d.ts +9 -10
  90. package/dist/generator-6oMJtTDO.js +170 -0
  91. package/dist/generator-CjzBK7h-.mjs +123 -0
  92. package/dist/generator.js +10 -16
  93. package/dist/generator.mjs +3 -3
  94. package/dist/{gulp-XT8Jc7lH.js → gulp-BtGq6LP9.js} +49 -87
  95. package/dist/{gulp-DfOQERcV.mjs → gulp-DNU10Vtc.mjs} +42 -80
  96. package/dist/gulp.js +1 -1
  97. package/dist/gulp.mjs +1 -1
  98. package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-B0KuWDjV.mjs} +1197 -858
  99. package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CegXR9O4.js} +1356 -927
  100. package/dist/index.js +4 -4
  101. package/dist/index.mjs +4 -4
  102. package/dist/js/fast-path/oxc.d.ts +4 -0
  103. package/dist/js/precheck.d.ts +1 -0
  104. package/dist/postcss.js +3 -4
  105. package/dist/postcss.mjs +2 -3
  106. package/dist/presets.js +9 -19
  107. package/dist/presets.mjs +8 -18
  108. package/dist/runtime-branch/create-branch.d.ts +2 -0
  109. package/dist/runtime-branch/generator-target-env.d.ts +4 -0
  110. package/dist/runtime-branch/index.d.ts +6 -0
  111. package/dist/runtime-branch/mini-program.d.ts +2 -0
  112. package/dist/runtime-branch/native-app.d.ts +2 -0
  113. package/dist/runtime-branch/platform.d.ts +6 -0
  114. package/dist/runtime-branch/tailwind-version.d.ts +2 -0
  115. package/dist/runtime-branch/types.d.ts +37 -0
  116. package/dist/runtime-branch/web.d.ts +2 -0
  117. package/dist/runtime-branch.d.ts +1 -0
  118. package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-B5af2Ahe.mjs} +187 -17
  119. package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-BKYb9jxa.js} +261 -19
  120. package/dist/tailwindcss/candidates.d.ts +7 -0
  121. package/dist/tailwindcss/index.d.ts +2 -2
  122. package/dist/tailwindcss/runtime/cache.d.ts +6 -6
  123. package/dist/tailwindcss/runtime-factory.d.ts +12 -0
  124. package/dist/tailwindcss/runtime-options.d.ts +8 -0
  125. package/dist/tailwindcss/runtime-types.d.ts +87 -0
  126. package/dist/tailwindcss/runtime.d.ts +6 -6
  127. package/dist/tailwindcss/source-scan.d.ts +1 -1
  128. package/dist/tailwindcss/targets.d.ts +2 -2
  129. package/dist/tailwindcss/v4/config.d.ts +3 -3
  130. package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
  131. package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
  132. package/dist/tailwindcss/v4/index.d.ts +1 -1
  133. package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
  134. package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
  135. package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
  136. package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
  137. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
  138. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
  139. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
  140. package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
  141. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  142. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
  143. package/dist/tailwindcss/v4-engine/source.d.ts +15 -7
  144. package/dist/tailwindcss/v4-engine/types.d.ts +17 -10
  145. package/dist/tailwindcss/version.d.ts +1 -1
  146. package/dist/tailwindcss-B5mRo0-M.mjs +1423 -0
  147. package/dist/tailwindcss-dbrbY4cd.js +1528 -0
  148. package/dist/{transform-DfcEjsZF.mjs → transform-fRBeuuK-.mjs} +2 -2
  149. package/dist/{transform-YmrmxuF3.js → transform-vLwZpiTE.js} +17 -17
  150. package/dist/typedoc.export.d.ts +1 -1
  151. package/dist/types/index.d.ts +16 -17
  152. package/dist/types/shared.d.ts +1 -1
  153. package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
  154. package/dist/types/user-defined-options/general.d.ts +5 -3
  155. package/dist/types/user-defined-options/important.d.ts +2 -2
  156. package/dist/types/user-defined-options/matcher.d.ts +7 -0
  157. package/dist/uni-app-x/style-asset.d.ts +1 -0
  158. package/dist/v4-engine-C3qSwQ-e.mjs +2376 -0
  159. package/dist/v4-engine-ON_oSLfO.js +2752 -0
  160. package/dist/{vite-DjI09vVN.mjs → vite-CWRooooa.mjs} +1417 -540
  161. package/dist/{vite-CXHVsHmX.js → vite-w-RkgaTY.js} +1575 -698
  162. package/dist/vite.js +1 -1
  163. package/dist/vite.mjs +1 -1
  164. package/dist/weapp-tw-css-import-rewrite-loader.js +5665 -4443
  165. package/dist/weapp-tw-runtime-classset-loader.js +15 -4
  166. package/dist/webpack-8PaV1gG3.mjs +2334 -0
  167. package/dist/webpack-CGgBOx9l.js +2346 -0
  168. package/dist/webpack.js +1 -1
  169. package/dist/webpack.mjs +1 -1
  170. package/package.json +6 -7
  171. package/dist/auto-CTp6wE5a.js +0 -33
  172. package/dist/auto-Cl8_hsG6.mjs +0 -22
  173. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
  174. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
  175. package/dist/context/tailwindcss/rax.d.ts +0 -2
  176. package/dist/generator-CzpArpCL.js +0 -92
  177. package/dist/generator-ITLd7PTl.mjs +0 -67
  178. package/dist/tailwindcss/patcher-options.d.ts +0 -8
  179. package/dist/tailwindcss/patcher.d.ts +0 -12
  180. package/dist/tailwindcss/runtime-patch.d.ts +0 -5
  181. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
  182. package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
  183. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
  184. package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
  185. package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
  186. package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
  187. package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
  188. package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
  189. package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
  190. package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
  191. package/dist/tailwindcss/v4/patcher.d.ts +0 -15
  192. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
  193. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
  194. package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
  195. package/dist/tailwindcss-DZEwT3C_.js +0 -613
  196. package/dist/v3-engine-2rrgylhn.js +0 -4686
  197. package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
  198. package/dist/webpack-BcPpnT90.mjs +0 -1184
  199. package/dist/webpack-CfkUkMXG.js +0 -1196
  200. /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
@@ -1,613 +0,0 @@
1
- const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_v3_engine = require("./v3-engine-2rrgylhn.js");
3
- require("./utils-BCa37Wqj.js");
4
- let node_fs = require("node:fs");
5
- let node_path = require("node:path");
6
- node_path = require_chunk.__toESM(node_path);
7
- let node_process = require("node:process");
8
- node_process = require_chunk.__toESM(node_process);
9
- let node_module = require("node:module");
10
- let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
11
- let node_url = require("node:url");
12
- let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
13
- //#region src/tailwindcss/v4/css-sources.ts
14
- function hasCssEntriesValue(value) {
15
- if (typeof value === "string") return value.trim().length > 0;
16
- return Array.isArray(value) && value.some((entry) => typeof entry === "string" && entry.trim().length > 0);
17
- }
18
- function hasCssSourcesValue(value) {
19
- return Array.isArray(value) && value.some((source) => {
20
- return typeof source === "object" && source !== null && typeof source.css === "string" && source.css.trim().length > 0;
21
- });
22
- }
23
- function hasConfiguredTailwindV4CssRoots(options) {
24
- return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources);
25
- }
26
- function normalizeCssSourceFile(file) {
27
- if (!file) return;
28
- return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
29
- }
30
- function normalizeCssSourceBase(base) {
31
- if (!base) return;
32
- return node_path.default.resolve(base);
33
- }
34
- function normalizeDependencies(dependencies) {
35
- return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
36
- }
37
- function isSameCssSource(a, b) {
38
- return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
39
- }
40
- function upsertTailwindV4CssSource(opts, source) {
41
- const normalizedSource = require_v3_engine.omitUndefined({
42
- ...source,
43
- ...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
44
- ...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
45
- ...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
46
- });
47
- const tailwindcss = opts.tailwindcss ?? {};
48
- const v4 = tailwindcss.v4 ?? {};
49
- const cssSources = [...v4.cssSources ?? []];
50
- const sourceFile = normalizeCssSourceFile(normalizedSource.file);
51
- const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
52
- if (existingIndex >= 0) {
53
- const existing = cssSources[existingIndex];
54
- if (!existing) {
55
- cssSources[existingIndex] = normalizedSource;
56
- return true;
57
- }
58
- const nextSource = {
59
- ...existing,
60
- ...normalizedSource
61
- };
62
- if (isSameCssSource(existing, nextSource)) return false;
63
- cssSources[existingIndex] = nextSource;
64
- } else cssSources.push(normalizedSource);
65
- opts.tailwindcss = {
66
- ...tailwindcss,
67
- v4: {
68
- ...v4,
69
- cssSources
70
- }
71
- };
72
- return true;
73
- }
74
- //#endregion
75
- //#region src/tailwindcss/v4/config.ts
76
- const DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
77
- function includesToken(list, token) {
78
- return list.some((candidate) => {
79
- if (typeof token === "string") {
80
- if (typeof candidate === "string") return candidate === token;
81
- candidate.lastIndex = 0;
82
- return candidate.test(token);
83
- }
84
- if (typeof candidate === "string") {
85
- token.lastIndex = 0;
86
- return token.test(candidate);
87
- }
88
- return candidate.source === token.source && candidate.flags === token.flags;
89
- });
90
- }
91
- function ensureDefaultsIncluded(value) {
92
- if (value === true) return { includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES] };
93
- if (Array.isArray(value)) {
94
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
95
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
96
- return missing.length > 0 ? [...value, ...missing] : value;
97
- }
98
- if (value && typeof value === "object") {
99
- const include = value.includeCustomProperties;
100
- if (!Array.isArray(include)) return {
101
- ...value,
102
- includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
103
- };
104
- if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) return value;
105
- const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
106
- return missing.length > 0 ? {
107
- ...value,
108
- includeCustomProperties: [...include, ...missing]
109
- } : value;
110
- }
111
- return value;
112
- }
113
- function normalizeCssEntriesConfig(entries) {
114
- return require_v3_engine.normalizeStringListOption(entries);
115
- }
116
- function hasConfiguredCssEntries(ctx) {
117
- if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
118
- if (normalizeCssEntriesConfig(ctx.tailwindcss?.v4?.cssEntries)) return true;
119
- const patcherOptions = ctx.tailwindcssPatcherOptions;
120
- if (patcherOptions) {
121
- if (normalizeCssEntriesConfig(patcherOptions.tailwindcss?.v4?.cssEntries)) return true;
122
- }
123
- return false;
124
- }
125
- let hasWarnedMissingCssEntries = false;
126
- function warnMissingCssEntries(ctx, patcher) {
127
- if (hasWarnedMissingCssEntries) return;
128
- if (patcher?.majorVersion !== 4) return;
129
- if (hasConfiguredCssEntries(ctx) || hasConfiguredTailwindV4CssRoots(ctx)) return;
130
- hasWarnedMissingCssEntries = true;
131
- _weapp_tailwindcss_logger.logger.warn("[tailwindcss@4] 未检测到 cssEntries 配置。请传入包含 tailwindcss 引用的 CSS 绝对路径,例如 cssEntries: [\"/absolute/path/to/src/app.css\"],否则 tailwindcss 生成的类名不会参与转译。");
132
- }
133
- function applyV4CssCalcDefaults(cssCalc, patcher) {
134
- const cssCalcOptions = cssCalc ?? patcher?.majorVersion === 4;
135
- if (patcher?.majorVersion === 4 && cssCalcOptions) return ensureDefaultsIncluded(cssCalcOptions);
136
- return cssCalcOptions;
137
- }
138
- //#endregion
139
- //#region src/tailwindcss/v4/multi-patcher.ts
140
- function createMultiTailwindcssPatcher(patchers) {
141
- if (patchers.length <= 1) {
142
- const [patcher] = patchers;
143
- if (!patcher) throw new Error("createMultiTailwindcssPatcher requires at least one patcher.");
144
- return patcher;
145
- }
146
- const first = patchers[0];
147
- const firstWithoutPatch = { ...first };
148
- delete firstWithoutPatch.patch;
149
- const multiPatcher = {
150
- ...firstWithoutPatch,
151
- packageInfo: first?.packageInfo,
152
- majorVersion: first?.majorVersion,
153
- options: first?.options,
154
- async getClassSet() {
155
- const aggregated = /* @__PURE__ */ new Set();
156
- for (const patcher of patchers) {
157
- const current = await patcher.getClassSet();
158
- for (const className of current) aggregated.add(className);
159
- }
160
- return aggregated;
161
- },
162
- async extract(options) {
163
- const aggregatedSet = /* @__PURE__ */ new Set();
164
- const aggregatedList = [];
165
- let filename;
166
- for (const patcher of patchers) {
167
- const result = await patcher.extract(options);
168
- if (!result) continue;
169
- if (filename === void 0 && result.filename) filename = result.filename;
170
- if (result.classList) for (const className of result.classList) {
171
- if (!aggregatedSet.has(className)) aggregatedList.push(className);
172
- aggregatedSet.add(className);
173
- }
174
- if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
175
- }
176
- return require_v3_engine.omitUndefined({
177
- classList: aggregatedList,
178
- classSet: aggregatedSet,
179
- filename
180
- });
181
- }
182
- };
183
- if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) multiPatcher.getClassSetSync = () => {
184
- const aggregated = /* @__PURE__ */ new Set();
185
- for (const patcher of patchers) {
186
- const current = patcher.getClassSetSync?.();
187
- if (!current) continue;
188
- for (const className of current) aggregated.add(className);
189
- }
190
- return aggregated;
191
- };
192
- Object.defineProperty(multiPatcher, require_v3_engine.runtimeSignaturePatchersSymbol, {
193
- value: [...patchers],
194
- configurable: true
195
- });
196
- return multiPatcher;
197
- }
198
- //#endregion
199
- //#region src/tailwindcss/v4/patcher-options.ts
200
- function overrideTailwindcssPatcherOptionsForBase(options, baseDir, cssEntries) {
201
- const hasCssEntries = cssEntries.length > 0;
202
- if (!options) return options;
203
- const modernTailwind = options.tailwindcss;
204
- if (!modernTailwind) return options;
205
- return {
206
- ...options,
207
- tailwindcss: {
208
- ...modernTailwind,
209
- v4: {
210
- ...modernTailwind.v4 ?? {},
211
- ...hasCssEntries ? {} : { base: modernTailwind.v4?.base ?? baseDir },
212
- cssEntries: hasCssEntries ? cssEntries : modernTailwind.v4?.cssEntries ?? cssEntries
213
- }
214
- }
215
- };
216
- }
217
- //#endregion
218
- //#region src/tailwindcss/v4/css-entries.ts
219
- function guessBasedirFromEntries(entries) {
220
- if (!entries) return;
221
- for (const entry of entries) {
222
- if (typeof entry !== "string") continue;
223
- const trimmed = entry.trim();
224
- if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
225
- const entryDir = node_path.default.dirname(trimmed);
226
- const resolved = require_v3_engine.findNearestPackageRoot(entryDir) ?? entryDir;
227
- if (resolved) return resolved;
228
- }
229
- }
230
- function normalizeCssEntries(entries, anchor) {
231
- if (!entries || entries.length === 0) return;
232
- const normalized = /* @__PURE__ */ new Set();
233
- for (const entry of entries) {
234
- if (typeof entry !== "string") continue;
235
- const trimmed = entry.trim();
236
- if (trimmed.length === 0) continue;
237
- const resolved = node_path.default.isAbsolute(trimmed) ? node_path.default.normalize(trimmed) : node_path.default.normalize(node_path.default.resolve(anchor, trimmed));
238
- normalized.add(resolved);
239
- }
240
- return normalized.size > 0 ? [...normalized] : void 0;
241
- }
242
- function isSubPath(parent, child) {
243
- if (!parent || !child) return false;
244
- const relative = node_path.default.relative(parent, child);
245
- return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
246
- }
247
- function resolveCssEntryBase(entryDir, options) {
248
- const normalizedDir = node_path.default.normalize(entryDir);
249
- const { preferredBaseDir, workspaceRoot } = options;
250
- if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
251
- if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
252
- const packageRoot = require_v3_engine.findNearestPackageRoot(normalizedDir);
253
- if (packageRoot) return node_path.default.normalize(packageRoot);
254
- return normalizedDir;
255
- }
256
- function groupCssEntriesByBase(entries, options = {}) {
257
- const normalizedOptions = {
258
- preferredBaseDir: options.preferredBaseDir ? node_path.default.normalize(options.preferredBaseDir) : void 0,
259
- workspaceRoot: options.workspaceRoot ? node_path.default.normalize(options.workspaceRoot) : void 0
260
- };
261
- const groups = /* @__PURE__ */ new Map();
262
- for (const entry of entries) {
263
- const baseDir = resolveCssEntryBase(node_path.default.dirname(entry), normalizedOptions);
264
- const bucket = groups.get(baseDir);
265
- if (bucket) bucket.push(entry);
266
- else groups.set(baseDir, [entry]);
267
- }
268
- return groups;
269
- }
270
- //#endregion
271
- //#region src/tailwindcss/v4/patcher.ts
272
- function isTailwindcss4Package(packageName) {
273
- return Boolean(packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")));
274
- }
275
- function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
276
- if (typeof configuredVersion === "number") return configuredVersion;
277
- if (isTailwindcss4Package(configuredPackageName)) return 4;
278
- }
279
- function createPatcherForBase(baseDir, cssEntries, options) {
280
- const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch, bareArbitraryValues } = options;
281
- const hasCssEntries = Boolean(cssEntries?.length);
282
- const defaultTailwindcssConfig = {
283
- cwd: baseDir,
284
- v2: { cwd: baseDir },
285
- v3: { cwd: baseDir },
286
- v4: hasCssEntries ? require_v3_engine.omitUndefined({ cssEntries }) : require_v3_engine.omitUndefined({
287
- base: baseDir,
288
- cssEntries
289
- })
290
- };
291
- const mergedTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, defaultTailwindcssConfig);
292
- if (!mergedTailwindOptions.v4) mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
293
- base: baseDir,
294
- cssEntries: cssEntries ?? []
295
- };
296
- else {
297
- if (!hasCssEntries && !mergedTailwindOptions.v4.base) mergedTailwindOptions.v4.base = baseDir;
298
- if (hasCssEntries) {
299
- if (cssEntries?.length) mergedTailwindOptions.v4.cssEntries = cssEntries;
300
- else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = [];
301
- } else if (!mergedTailwindOptions.v4.cssEntries) mergedTailwindOptions.v4.cssEntries = cssEntries ?? [];
302
- }
303
- if (bareArbitraryValues !== void 0 && bareArbitraryValues !== false) mergedTailwindOptions.v4.bareArbitraryValues = bareArbitraryValues;
304
- const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
305
- const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName;
306
- const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
307
- const resolvedTailwindVersion = require_v3_engine.readInstalledPackageMajorVersion(configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss", baseDir) ?? explicitTailwindVersion;
308
- const supportedResolvedTailwindVersion = resolvedTailwindVersion === 2 || resolvedTailwindVersion === 3 || resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
309
- const tailwindOptionsForPackage = {
310
- ...mergedTailwindOptions,
311
- packageName: mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss"
312
- };
313
- if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
314
- return require_v3_engine.createTailwindcssPatcher(require_v3_engine.omitUndefined({
315
- basedir: baseDir,
316
- supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
317
- tailwindcss: tailwindOptionsForPackage,
318
- tailwindcssPatcherOptions: patchedOptions
319
- }));
320
- }
321
- function tryCreateMultiTailwindcssPatcher(groups, options) {
322
- if (groups.size <= 1) return;
323
- _weapp_tailwindcss_logger.logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
324
- const patchers = [];
325
- for (const [baseDir, entries] of groups) {
326
- const patcher = createPatcherForBase(baseDir, entries, options);
327
- if (patcher) patchers.push(patcher);
328
- }
329
- return createMultiTailwindcssPatcher(patchers);
330
- }
331
- //#endregion
332
- //#region src/uni-app-x/options.ts
333
- const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
334
- enabled: true,
335
- onlyWhenStyleIsolationVersion2: true
336
- };
337
- const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
338
- enabled: false,
339
- onlyWhenStyleIsolationVersion2: true
340
- };
341
- function isBooleanUniAppXShortcut(option) {
342
- return option === true || option === false || option === void 0;
343
- }
344
- function resolveComponentLocalStyles(option) {
345
- if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
346
- const componentLocalStyles = option.componentLocalStyles;
347
- if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
348
- if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
349
- return {
350
- enabled: componentLocalStyles.enabled !== false,
351
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
352
- };
353
- }
354
- function resolveUniAppXOptions(option) {
355
- if (typeof option === "object" && option) return {
356
- enabled: option.enabled !== false,
357
- componentLocalStyles: resolveComponentLocalStyles(option),
358
- uvueUnsupported: option.uvueUnsupported ?? "warn"
359
- };
360
- return {
361
- enabled: Boolean(option),
362
- componentLocalStyles: resolveComponentLocalStyles(option),
363
- uvueUnsupported: "warn"
364
- };
365
- }
366
- function isUniAppXEnabled(option) {
367
- return resolveUniAppXOptions(option).enabled;
368
- }
369
- //#endregion
370
- //#region src/context/tailwindcss/basedir.ts
371
- const ENV_BASEDIR_KEYS = [
372
- "WEAPP_TAILWINDCSS_BASEDIR",
373
- "WEAPP_TAILWINDCSS_BASE_DIR",
374
- "TAILWINDCSS_BASEDIR",
375
- "TAILWINDCSS_BASE_DIR",
376
- "UNI_INPUT_DIR",
377
- "UNI_INPUT_ROOT",
378
- "UNI_CLI_ROOT",
379
- "UNI_APP_INPUT_DIR",
380
- "INIT_CWD",
381
- "PWD"
382
- ];
383
- const GENERIC_ENV_BASEDIR_KEYS = new Set(["INIT_CWD", "PWD"]);
384
- function pickEnvBasedir() {
385
- for (const key of ENV_BASEDIR_KEYS) {
386
- const value = node_process.default.env[key];
387
- if (value && node_path.default.isAbsolute(value)) return {
388
- key,
389
- value
390
- };
391
- }
392
- }
393
- function pickPackageEnvBasedir() {
394
- const packageJsonPath = node_process.default.env["npm_package_json"];
395
- if (packageJsonPath) {
396
- const packageDir = node_path.default.dirname(packageJsonPath);
397
- if (packageDir && node_path.default.isAbsolute(packageDir)) return packageDir;
398
- }
399
- const localPrefix = node_process.default.env["npm_config_local_prefix"];
400
- if (localPrefix && node_path.default.isAbsolute(localPrefix)) return localPrefix;
401
- }
402
- const STACK_PAREN_RE = /\(([^)]+)\)/u;
403
- const STACK_AT_RE = /at\s+(\S.*)$/u;
404
- function detectCallerBasedir() {
405
- const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
406
- if (!stack) return;
407
- if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("caller stack: %s", stack);
408
- const lines = stack.split("\n");
409
- for (const line of lines) {
410
- const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
411
- if (!location) continue;
412
- let filePath = location;
413
- if (filePath.startsWith("file://")) try {
414
- filePath = (0, node_url.fileURLToPath)(filePath);
415
- } catch {
416
- continue;
417
- }
418
- const [candidate = ""] = filePath.split(":");
419
- const resolvedPath = node_path.default.isAbsolute(filePath) ? filePath : candidate;
420
- if (!node_path.default.isAbsolute(resolvedPath)) continue;
421
- if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
422
- try {
423
- return node_path.default.dirname(resolvedPath);
424
- } catch {
425
- continue;
426
- }
427
- }
428
- }
429
- function resolveTailwindcssBasedir(basedir, fallback) {
430
- const envBasedirResult = pickEnvBasedir();
431
- const envBasedir = envBasedirResult?.value;
432
- const envBasedirKey = envBasedirResult?.key;
433
- const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
434
- const packageEnvBasedir = pickPackageEnvBasedir();
435
- const callerBasedir = !envBasedir || envBasedirIsGeneric ? detectCallerBasedir() : void 0;
436
- const cwd = node_process.default.cwd();
437
- const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
438
- const resolveRelative = (value) => node_path.default.isAbsolute(value) ? node_path.default.normalize(value) : node_path.default.normalize(node_path.default.resolve(anchor, value));
439
- if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("resolveTailwindcssBasedir anchor %O", {
440
- basedir,
441
- envBasedir,
442
- envBasedirKey,
443
- envBasedirIsGeneric,
444
- packageEnvBasedir,
445
- fallback,
446
- callerBasedir,
447
- npm_package_json: node_process.default.env["npm_package_json"],
448
- cwd,
449
- anchor
450
- });
451
- if (basedir && basedir.trim().length > 0) return resolveRelative(basedir);
452
- if (envBasedir && !envBasedirIsGeneric) return node_path.default.normalize(envBasedir);
453
- if (fallback && fallback.trim().length > 0) return resolveRelative(fallback);
454
- if (packageEnvBasedir) return node_path.default.normalize(packageEnvBasedir);
455
- if (callerBasedir) {
456
- const normalizedCaller = node_path.default.normalize(callerBasedir);
457
- const librarySegment = `${node_path.default.sep}weapp-tailwindcss${node_path.default.sep}`;
458
- if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
459
- }
460
- const packageName = node_process.default.env["PNPM_PACKAGE_NAME"];
461
- if (packageName) try {
462
- const packageJsonPath = (0, node_module.createRequire)(node_path.default.join(anchor, "__resolve_tailwindcss_basedir__.cjs")).resolve(`${packageName}/package.json`);
463
- if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
464
- return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
465
- } catch {
466
- if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("failed to resolve package json for %s", packageName);
467
- const workspaceRoot = require_v3_engine.findWorkspaceRoot(anchor);
468
- if (workspaceRoot) {
469
- const packageDir = require_v3_engine.findWorkspacePackageDir(workspaceRoot, packageName);
470
- if (packageDir) return packageDir;
471
- }
472
- }
473
- if (envBasedir) return node_path.default.normalize(envBasedir);
474
- return node_path.default.normalize(cwd);
475
- }
476
- //#endregion
477
- //#region src/context/tailwindcss/rax.ts
478
- function isRaxWorkspace(appType, baseDir) {
479
- if (appType === "rax") return true;
480
- try {
481
- const pkgPath = node_path.default.join(baseDir, "package.json");
482
- if (!(0, node_fs.existsSync)(pkgPath)) return false;
483
- const pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"));
484
- const deps = {
485
- ...pkg["dependencies"] ?? {},
486
- ...pkg["devDependencies"] ?? {}
487
- };
488
- if (deps["rax-app"] || deps.rax) return true;
489
- } catch {
490
- return false;
491
- }
492
- return false;
493
- }
494
- function collectRaxStyleEntries(baseDir) {
495
- const STYLE_CANDIDATES = [
496
- "src/global.css",
497
- "src/global.scss",
498
- "src/global.less",
499
- "src/global.sass",
500
- "src/global.styl",
501
- "src/global.stylus"
502
- ];
503
- const discovered = [];
504
- for (const relative of STYLE_CANDIDATES) {
505
- const candidate = node_path.default.resolve(baseDir, relative);
506
- if ((0, node_fs.existsSync)(candidate)) discovered.push(node_path.default.normalize(candidate));
507
- }
508
- return discovered;
509
- }
510
- function detectImplicitCssEntries(appType, baseDir) {
511
- const baseCandidates = /* @__PURE__ */ new Set();
512
- baseCandidates.add(node_path.default.normalize(baseDir));
513
- const envCandidates = [
514
- node_process.default.cwd(),
515
- node_process.default.env["INIT_CWD"],
516
- node_process.default.env["PWD"]
517
- ];
518
- for (const candidate of envCandidates) if (candidate) baseCandidates.add(node_path.default.normalize(candidate));
519
- for (const candidateBase of baseCandidates) {
520
- if (!isRaxWorkspace(appType, candidateBase)) continue;
521
- const entries = collectRaxStyleEntries(candidateBase);
522
- if (entries.length) return entries;
523
- }
524
- }
525
- //#endregion
526
- //#region src/context/tailwindcss.ts
527
- function createTailwindcssPatcherFromContext(ctx) {
528
- const { tailwindcssBasedir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions, cssEntries: rawCssEntries, appType, arbitraryValues } = ctx;
529
- const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
530
- const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
531
- ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
532
- _weapp_tailwindcss_logger.logger.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
533
- let normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
534
- if (!normalizedCssEntries) normalizedCssEntries = detectImplicitCssEntries(ctx.appType, resolvedTailwindcssBasedir);
535
- if (normalizedCssEntries) ctx.cssEntries = normalizedCssEntries;
536
- const patcherOptions = {
537
- tailwindcss,
538
- tailwindcssPatcherOptions,
539
- supportCustomLengthUnitsPatch,
540
- appType,
541
- bareArbitraryValues: arbitraryValues?.bareArbitraryValues
542
- };
543
- const workspaceRoot = require_v3_engine.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_v3_engine.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
544
- const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, require_v3_engine.omitUndefined({
545
- preferredBaseDir: resolvedTailwindcssBasedir,
546
- workspaceRoot
547
- })) : void 0;
548
- const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
549
- if (multiPatcher) return multiPatcher;
550
- if (groupedCssEntries?.size === 1) {
551
- const firstGroup = groupedCssEntries.entries().next().value;
552
- if (firstGroup) {
553
- const [baseDir, entries] = firstGroup;
554
- return createPatcherForBase(baseDir, entries, patcherOptions);
555
- }
556
- }
557
- return createPatcherForBase(resolvedTailwindcssBasedir, normalizedCssEntries ?? rawCssEntries, patcherOptions);
558
- }
559
- //#endregion
560
- Object.defineProperty(exports, "applyV4CssCalcDefaults", {
561
- enumerable: true,
562
- get: function() {
563
- return applyV4CssCalcDefaults;
564
- }
565
- });
566
- Object.defineProperty(exports, "createTailwindcssPatcherFromContext", {
567
- enumerable: true,
568
- get: function() {
569
- return createTailwindcssPatcherFromContext;
570
- }
571
- });
572
- Object.defineProperty(exports, "hasConfiguredTailwindV4CssRoots", {
573
- enumerable: true,
574
- get: function() {
575
- return hasConfiguredTailwindV4CssRoots;
576
- }
577
- });
578
- Object.defineProperty(exports, "isUniAppXEnabled", {
579
- enumerable: true,
580
- get: function() {
581
- return isUniAppXEnabled;
582
- }
583
- });
584
- Object.defineProperty(exports, "normalizeCssEntries", {
585
- enumerable: true,
586
- get: function() {
587
- return normalizeCssEntries;
588
- }
589
- });
590
- Object.defineProperty(exports, "resolveTailwindcssBasedir", {
591
- enumerable: true,
592
- get: function() {
593
- return resolveTailwindcssBasedir;
594
- }
595
- });
596
- Object.defineProperty(exports, "resolveUniAppXOptions", {
597
- enumerable: true,
598
- get: function() {
599
- return resolveUniAppXOptions;
600
- }
601
- });
602
- Object.defineProperty(exports, "upsertTailwindV4CssSource", {
603
- enumerable: true,
604
- get: function() {
605
- return upsertTailwindV4CssSource;
606
- }
607
- });
608
- Object.defineProperty(exports, "warnMissingCssEntries", {
609
- enumerable: true,
610
- get: function() {
611
- return warnMissingCssEntries;
612
- }
613
- });