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,4686 +0,0 @@
1
- const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_auto = require("./auto-CTp6wE5a.js");
3
- let node_fs = require("node:fs");
4
- node_fs = require_chunk.__toESM(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_postcss = require("@weapp-tailwindcss/postcss");
11
- let lru_cache = require("lru-cache");
12
- let tailwindcss_patch = require("tailwindcss-patch");
13
- tailwindcss_patch = require_chunk.__toESM(tailwindcss_patch);
14
- let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
15
- let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
16
- let node_url = require("node:url");
17
- let debug = require("debug");
18
- debug = require_chunk.__toESM(debug);
19
- let node_fs_promises = require("node:fs/promises");
20
- let micromatch = require("micromatch");
21
- micromatch = require_chunk.__toESM(micromatch);
22
- let fast_glob = require("fast-glob");
23
- fast_glob = require_chunk.__toESM(fast_glob);
24
- let tailwindcss_config = require("tailwindcss-config");
25
- //#region src/utils/object.ts
26
- function definedEntries(value) {
27
- return Object.entries(value).filter(([, item]) => item !== void 0);
28
- }
29
- function omitUndefined(value) {
30
- return Object.fromEntries(definedEntries(value));
31
- }
32
- //#endregion
33
- //#region src/tailwindcss/v3-engine/generator/content.ts
34
- function isLegacyContentObject$1(value) {
35
- return typeof value === "object" && value !== null && "files" in value;
36
- }
37
- function createRawContentEntries(candidates, sources) {
38
- const entries = [];
39
- const candidateContent = [...candidates].join(" ");
40
- if (candidateContent.length > 0) entries.push({
41
- raw: candidateContent,
42
- extension: "html"
43
- });
44
- for (const source of sources) entries.push({
45
- raw: source.content,
46
- extension: source.extension ?? "html"
47
- });
48
- return entries;
49
- }
50
- function createChangedContentEntries(candidates, sources) {
51
- return createRawContentEntries(candidates, sources).map((entry) => ({
52
- content: entry.raw,
53
- extension: entry.extension
54
- }));
55
- }
56
- function collectCandidates$1(candidates) {
57
- return new Set(candidates ?? []);
58
- }
59
- function collectApplyCandidatesFromCss(css) {
60
- if (!css.includes("@apply")) return [];
61
- const candidates = /* @__PURE__ */ new Set();
62
- try {
63
- _weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("apply", (rule) => {
64
- for (const candidate of rule.params.split(/\s+/)) {
65
- const normalized = candidate.replace(/!important$/, "").trim();
66
- if (normalized) candidates.add(normalized);
67
- }
68
- });
69
- } catch {}
70
- return [...candidates];
71
- }
72
- function isTailwindCandidateLayer(params) {
73
- return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
74
- }
75
- function extractClassCandidatesFromSelector(selector, candidates) {
76
- for (let index = 0; index < selector.length; index++) {
77
- if (selector[index] !== ".") continue;
78
- let candidate = "";
79
- let escaped = false;
80
- for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
81
- const char = selector[tokenIndex];
82
- if (escaped) {
83
- candidate += char;
84
- escaped = false;
85
- continue;
86
- }
87
- if (char === "\\") {
88
- escaped = true;
89
- continue;
90
- }
91
- if (char && /[\w-]/.test(char)) {
92
- candidate += char;
93
- continue;
94
- }
95
- break;
96
- }
97
- if (candidate) candidates.add(candidate);
98
- }
99
- }
100
- function collectLayerCandidatesFromCss(css) {
101
- if (!css.includes("@layer")) return [];
102
- const candidates = /* @__PURE__ */ new Set();
103
- try {
104
- _weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("layer", (layer) => {
105
- if (!isTailwindCandidateLayer(layer.params)) return;
106
- layer.walkRules((rule) => {
107
- extractClassCandidatesFromSelector(rule.selector, candidates);
108
- });
109
- });
110
- } catch {}
111
- return [...candidates];
112
- }
113
- function mergeGenerateCandidates(source, options) {
114
- return collectCandidates$1([
115
- ...collectLayerCandidatesFromCss(source.css),
116
- ...collectApplyCandidatesFromCss(source.css),
117
- ...collectCandidates$1(options.candidates)
118
- ]);
119
- }
120
- function mergeContent(content, rawEntries) {
121
- if (isLegacyContentObject$1(content)) return {
122
- ...content,
123
- relative: content.relative ?? true,
124
- files: [...[].concat(content.files ?? []), ...rawEntries]
125
- };
126
- return {
127
- relative: true,
128
- files: [...[].concat(content ?? []), ...rawEntries]
129
- };
130
- }
131
- function normalizeConfigObject(config) {
132
- if (!config || typeof config !== "object") return config;
133
- const maybeDefault = config.default;
134
- if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
135
- return config;
136
- }
137
- function hasExplicitContentInput(options) {
138
- return options.candidates !== void 0 || options.sources !== void 0;
139
- }
140
- function createExplicitContentConfig(rawEntries) {
141
- return {
142
- relative: true,
143
- files: rawEntries
144
- };
145
- }
146
- function createTailwindConfig(source, options) {
147
- const config = { ...normalizeConfigObject(source.configObject) ?? {} };
148
- const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
149
- config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
150
- return config;
151
- }
152
- //#endregion
153
- //#region src/tailwindcss/v3-engine/generator/cache-key.ts
154
- function createStableJson$1(value) {
155
- if (value === void 0) return "undefined";
156
- if (value === null || typeof value !== "object") return JSON.stringify(value);
157
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
158
- return `{${Object.keys(value).sort().map((key) => {
159
- const record = value;
160
- return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
161
- }).join(",")}}`;
162
- }
163
- function createDependencyFingerprint$1(files) {
164
- return files.map((file) => {
165
- try {
166
- const stat = node_fs.default.statSync(file);
167
- return `${file}:${stat.size}:${stat.mtimeMs}`;
168
- } catch {
169
- return `${file}:missing`;
170
- }
171
- }).join("|");
172
- }
173
- function createIncrementalGenerateCacheKey$1(source, target, styleOptions, bareArbitraryValues) {
174
- return [
175
- source.packageName,
176
- source.postcssPlugin,
177
- source.cwd,
178
- source.config ?? "config:missing",
179
- createDependencyFingerprint$1(source.dependencies),
180
- source.css,
181
- createStableJson$1(normalizeConfigObject(source.configObject)?.content),
182
- target,
183
- createStableJson$1(styleOptions),
184
- createStableJson$1(bareArbitraryValues)
185
- ].join("\0");
186
- }
187
- //#endregion
188
- //#region src/context/workspace.ts
189
- const IGNORED_WORKSPACE_DIRS = new Set([
190
- "node_modules",
191
- ".git",
192
- ".hg",
193
- ".svn",
194
- ".turbo",
195
- ".output",
196
- ".next",
197
- "dist",
198
- "build"
199
- ]);
200
- function findWorkspaceRoot(startDir) {
201
- if (!startDir) return;
202
- let current = node_path.default.resolve(startDir);
203
- while (true) {
204
- if ((0, node_fs.existsSync)(node_path.default.join(current, "pnpm-workspace.yaml"))) return current;
205
- const parent = node_path.default.dirname(current);
206
- if (parent === current) return;
207
- current = parent;
208
- }
209
- }
210
- function findNearestPackageRoot(startDir) {
211
- if (!startDir) return;
212
- let current = node_path.default.resolve(startDir);
213
- while (true) {
214
- if ((0, node_fs.existsSync)(node_path.default.join(current, "package.json"))) return current;
215
- const parent = node_path.default.dirname(current);
216
- if (parent === current) return;
217
- current = parent;
218
- }
219
- }
220
- function findWorkspacePackageDir(rootDir, packageName) {
221
- const visited = /* @__PURE__ */ new Set();
222
- const queue = [node_path.default.resolve(rootDir)];
223
- while (queue.length > 0) {
224
- const current = queue.shift();
225
- const normalized = node_path.default.normalize(current);
226
- if (visited.has(normalized)) continue;
227
- visited.add(normalized);
228
- try {
229
- const pkgPath = node_path.default.join(normalized, "package.json");
230
- if ((0, node_fs.existsSync)(pkgPath)) {
231
- if (JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"))?.name === packageName) return normalized;
232
- }
233
- } catch {}
234
- let entries;
235
- try {
236
- entries = (0, node_fs.readdirSync)(normalized, { withFileTypes: true });
237
- } catch {
238
- continue;
239
- }
240
- for (const entry of entries) {
241
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
242
- queue.push(node_path.default.join(normalized, entry.name));
243
- }
244
- }
245
- }
246
- //#endregion
247
- //#region src/utils/options.ts
248
- function resolveBooleanObjectOption(value, enabledValue) {
249
- if (!value) return false;
250
- if (value === true) return enabledValue;
251
- return value;
252
- }
253
- function normalizeStringListOption(value) {
254
- if (!value) return;
255
- const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
256
- if (!values) return;
257
- const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
258
- return normalized.length > 0 ? normalized : void 0;
259
- }
260
- //#endregion
261
- //#region src/tailwindcss/patcher-options.ts
262
- function resolveTailwindcssOptions(options) {
263
- return options?.tailwindcss ?? options?.tailwind;
264
- }
265
- function normalizeExtendLengthUnits(value) {
266
- if (value === void 0) return;
267
- const resolved = resolveBooleanObjectOption(value, { enabled: true });
268
- return resolved && typeof resolved === "object" ? {
269
- enabled: true,
270
- ...resolved
271
- } : resolved;
272
- }
273
- function normalizeTailwindcssPatcherOptions(options) {
274
- return options;
275
- }
276
- //#endregion
277
- //#region src/tailwindcss/patcher-resolve.ts
278
- const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
279
- const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
280
- const TAILWIND_CONFIG_FILES = [
281
- "tailwind.config.js",
282
- "tailwind.config.cjs",
283
- "tailwind.config.mjs",
284
- "tailwind.config.ts",
285
- "tailwind.config.cts",
286
- "tailwind.config.mts"
287
- ];
288
- function isPathSpecifier(specifier) {
289
- if (!specifier) return false;
290
- if (specifier.startsWith("file://")) return true;
291
- if (node_path.default.isAbsolute(specifier)) return true;
292
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
293
- }
294
- function resolveModuleFromPaths(specifier, paths) {
295
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
296
- try {
297
- return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve(specifier, { paths });
298
- } catch {
299
- return;
300
- }
301
- }
302
- function resolveTailwindConfigFallback(packageName, paths) {
303
- if (!packageName) return;
304
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
305
- const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
306
- if (resolved) return resolved;
307
- }
308
- }
309
- function appendNodeModules(paths, dir) {
310
- if (!dir) return;
311
- const nodeModulesDir = node_path.default.join(dir, "node_modules");
312
- if ((0, node_fs.existsSync)(nodeModulesDir)) paths.add(nodeModulesDir);
313
- }
314
- function findTailwindConfig(searchRoots) {
315
- for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
316
- const candidate = node_path.default.resolve(root, file);
317
- if ((0, node_fs.existsSync)(candidate)) return candidate;
318
- }
319
- }
320
- function createDefaultResolvePaths(basedir) {
321
- const paths = /* @__PURE__ */ new Set();
322
- let fallbackCandidates = [];
323
- if (basedir) {
324
- const resolvedBase = node_path.default.resolve(basedir);
325
- appendNodeModules(paths, resolvedBase);
326
- fallbackCandidates.push(resolvedBase);
327
- const packageRoot = findNearestPackageRoot(resolvedBase);
328
- if (packageRoot) {
329
- appendNodeModules(paths, packageRoot);
330
- fallbackCandidates.push(packageRoot);
331
- }
332
- const workspaceRoot = findWorkspaceRoot(resolvedBase);
333
- if (workspaceRoot) {
334
- appendNodeModules(paths, workspaceRoot);
335
- fallbackCandidates.push(workspaceRoot);
336
- }
337
- }
338
- const cwd = node_process.default.cwd();
339
- appendNodeModules(paths, cwd);
340
- try {
341
- const modulePath = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
342
- const candidate = (0, node_fs.existsSync)(modulePath) && !node_path.default.extname(modulePath) ? modulePath : node_path.default.dirname(modulePath);
343
- paths.add(candidate);
344
- } catch {
345
- paths.add(require("url").pathToFileURL(__filename).href);
346
- }
347
- if (paths.size === 0) {
348
- fallbackCandidates = fallbackCandidates.filter(Boolean);
349
- if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
350
- for (const candidate of fallbackCandidates) paths.add(candidate);
351
- }
352
- return [...paths];
353
- }
354
- //#endregion
355
- //#region src/tailwindcss/version.ts
356
- function normalizeSupportedTailwindcssMajorVersion(version) {
357
- return version === 3 || version === 4 ? version : void 0;
358
- }
359
- function readPackageJson(packageJsonPath) {
360
- try {
361
- return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
362
- } catch {
363
- return;
364
- }
365
- }
366
- function findPackageJsonDeclaringPackage(packageName, base) {
367
- let current = node_path.default.resolve(base);
368
- while (true) {
369
- const pkgPath = node_path.default.join(current, "package.json");
370
- if ((0, node_fs.existsSync)(pkgPath)) {
371
- const pkg = readPackageJson(pkgPath);
372
- if (readDeclaredPackageVersion(packageName, pkg)) return pkgPath;
373
- if (pkg?.name !== "weapp-tailwindcss") return;
374
- }
375
- const parent = node_path.default.dirname(current);
376
- if (parent === current) return;
377
- current = parent;
378
- }
379
- }
380
- function readDeclaredPackageVersion(packageName, pkg) {
381
- return pkg?.dependencies?.[packageName] ?? pkg?.devDependencies?.[packageName] ?? pkg?.peerDependencies?.[packageName] ?? pkg?.optionalDependencies?.[packageName];
382
- }
383
- function readDeclaredPackageMajorVersion(version) {
384
- const match = version?.match(/(?:^|\D)([34])(?:\.|\b)/);
385
- return normalizeSupportedTailwindcssMajorVersion(match ? Number(match[1]) : void 0);
386
- }
387
- function readInstalledPackageMajorVersion(packageName, base) {
388
- const packageJsonPath = findPackageJsonDeclaringPackage(packageName, base);
389
- if (!packageJsonPath) return;
390
- const declaredVersion = readDeclaredPackageVersion(packageName, readPackageJson(packageJsonPath));
391
- if (!declaredVersion) return;
392
- try {
393
- const pkg = (0, node_module.createRequire)(packageJsonPath)(`${packageName}/package.json`);
394
- return normalizeSupportedTailwindcssMajorVersion(Number(pkg.version?.split(".")[0]));
395
- } catch {
396
- return readDeclaredPackageMajorVersion(declaredVersion);
397
- }
398
- }
399
- //#endregion
400
- //#region src/tailwindcss/patcher.ts
401
- function createFallbackTailwindcssPatcher() {
402
- return {
403
- packageInfo: {
404
- name: "tailwindcss",
405
- version: void 0,
406
- rootPath: "",
407
- packageJsonPath: "",
408
- packageJson: {}
409
- },
410
- majorVersion: 4,
411
- async getClassSet() {
412
- return /* @__PURE__ */ new Set();
413
- },
414
- async extract(_options) {
415
- return {
416
- classList: [],
417
- classSet: /* @__PURE__ */ new Set()
418
- };
419
- },
420
- async collectContentTokens() {
421
- return {
422
- entries: [],
423
- filesScanned: 0,
424
- sources: [],
425
- skippedFiles: []
426
- };
427
- }
428
- };
429
- }
430
- let hasLoggedMissingTailwind = false;
431
- const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
432
- const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
433
- function createTailwindcssPatcher(options) {
434
- const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
435
- const cache = { driver: "memory" };
436
- const normalizedBasedir = basedir ? node_path.default.resolve(basedir) : void 0;
437
- const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? node_process.default.cwd();
438
- if (cacheDir) if (node_path.default.isAbsolute(cacheDir)) cache.dir = cacheDir;
439
- else if (normalizedBasedir) cache.dir = node_path.default.resolve(normalizedBasedir, cacheDir);
440
- else cache.dir = node_path.default.resolve(node_process.default.cwd(), cacheDir);
441
- else cache.dir = node_path.default.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
442
- if (normalizedBasedir) cache.cwd = normalizedBasedir;
443
- const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? node_process.default.cwd());
444
- const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
445
- const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
446
- const baseTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, omitUndefined({
447
- cwd: normalizedBasedir,
448
- resolve: { paths: resolvePaths }
449
- }));
450
- if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
451
- if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = "tailwindcss";
452
- if (typeof baseTailwindOptions.postcssPlugin === "string") {
453
- const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
454
- if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
455
- }
456
- const baseOptions = omitUndefined({
457
- projectRoot: normalizedBasedir,
458
- cache,
459
- tailwindcss: baseTailwindOptions,
460
- apply: omitUndefined({
461
- exposeContext: true,
462
- extendLengthUnits
463
- })
464
- });
465
- const resolvedOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(normalizedUserOptions ?? {}, baseOptions);
466
- const resolvedTailwindOptions = resolvedOptions.tailwindcss;
467
- if (resolvedTailwindOptions) {
468
- const existingResolve = resolvedTailwindOptions.resolve ?? {};
469
- const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths ?? [], ...resolvePaths] : resolvePaths;
470
- resolvedTailwindOptions.resolve = {
471
- ...existingResolve,
472
- paths: [...new Set(sourcePaths)]
473
- };
474
- _weapp_tailwindcss_logger.logger.debug("Tailwind resolve config %O", {
475
- packageName: resolvedTailwindOptions.packageName,
476
- version: resolvedTailwindOptions.version,
477
- resolve: resolvedTailwindOptions.resolve,
478
- cwd: resolvedTailwindOptions.cwd
479
- });
480
- if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
481
- const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
482
- if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
483
- }
484
- const searchRoots = /* @__PURE__ */ new Set();
485
- if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
486
- for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
487
- const parentDir = node_path.default.dirname(resolvePath);
488
- searchRoots.add(parentDir);
489
- }
490
- const configPath = findTailwindConfig(searchRoots);
491
- if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
492
- else {
493
- const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
494
- if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
495
- }
496
- if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = node_path.default.dirname(configPath);
497
- resolvedOptions.tailwindcss = resolvedTailwindOptions;
498
- }
499
- try {
500
- return new tailwindcss_patch.TailwindcssPatcher(resolvedOptions);
501
- } catch (error) {
502
- const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
503
- if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
504
- if (!hasLoggedMissingTailwind) {
505
- _weapp_tailwindcss_logger.logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 运行时能力。若需使用 Tailwind 能力,请安装 tailwindcss。");
506
- hasLoggedMissingTailwind = true;
507
- }
508
- return createFallbackTailwindcssPatcher();
509
- }
510
- if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) _weapp_tailwindcss_logger.logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
511
- throw error;
512
- }
513
- }
514
- //#endregion
515
- //#region src/debug/index.ts
516
- const _debug = (0, debug.default)("weapp-tw");
517
- function createDebug(prefix) {
518
- const debug$2 = ((formatter, ...args) => {
519
- return _debug((prefix ?? "") + formatter, ...args);
520
- });
521
- Object.defineProperty(debug$2, "enabled", {
522
- enumerable: false,
523
- configurable: false,
524
- get() {
525
- return _debug.enabled;
526
- }
527
- });
528
- return debug$2;
529
- }
530
- //#endregion
531
- //#region src/tailwindcss/source-scan/inline-source.ts
532
- const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
533
- function segmentTopLevel(input, separator, options = {}) {
534
- const parts = [];
535
- const stack = [];
536
- let lastPos = 0;
537
- let quote;
538
- for (let index = 0; index < input.length; index++) {
539
- const char = input[index];
540
- if (char === "\\") {
541
- index += 1;
542
- continue;
543
- }
544
- if (quote) {
545
- if (char === quote) quote = void 0;
546
- continue;
547
- }
548
- if (char === "\"" || char === "'") {
549
- quote = char;
550
- continue;
551
- }
552
- if (char === "(") {
553
- stack.push(")");
554
- continue;
555
- }
556
- if (char === "[") {
557
- stack.push("]");
558
- continue;
559
- }
560
- if (char === "{") {
561
- stack.push("}");
562
- continue;
563
- }
564
- if (stack.length > 0 && char === stack[stack.length - 1]) {
565
- stack.pop();
566
- continue;
567
- }
568
- if (stack.length === 0 && char === separator) {
569
- const part = input.slice(lastPos, index);
570
- if (part || options.keepEmpty) parts.push(part);
571
- lastPos = index + 1;
572
- }
573
- }
574
- const part = input.slice(lastPos);
575
- if (part || options.keepEmpty) parts.push(part);
576
- return parts;
577
- }
578
- function isSequence(value) {
579
- return NUMERICAL_RANGE_RE.test(value);
580
- }
581
- function expandSequence(value) {
582
- const match = value.match(NUMERICAL_RANGE_RE);
583
- if (!match) return [value];
584
- const [, start, end, stepValue] = match;
585
- if (start === void 0 || end === void 0) return [value];
586
- let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
587
- const startNumber = Number.parseInt(start, 10);
588
- const endNumber = Number.parseInt(end, 10);
589
- const increasing = startNumber < endNumber;
590
- if (step === void 0) step = increasing ? 1 : -1;
591
- if (step === 0) return [];
592
- if (increasing && step < 0) step = -step;
593
- if (!increasing && step > 0) step = -step;
594
- const result = [];
595
- for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
596
- return result;
597
- }
598
- function expandInlineSourceCandidatePattern(pattern) {
599
- const index = pattern.indexOf("{");
600
- if (index === -1) return [pattern];
601
- const prefix = pattern.slice(0, index);
602
- const rest = pattern.slice(index);
603
- let depth = 0;
604
- let endIndex = -1;
605
- for (let index = 0; index < rest.length; index++) {
606
- const char = rest[index];
607
- if (char === "{") depth += 1;
608
- else if (char === "}") {
609
- depth -= 1;
610
- if (depth === 0) {
611
- endIndex = index;
612
- break;
613
- }
614
- }
615
- }
616
- if (endIndex === -1) return [pattern];
617
- const inner = rest.slice(1, endIndex);
618
- const suffix = rest.slice(endIndex + 1);
619
- const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
620
- return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
621
- }
622
- function parseSourceInlineParam(params) {
623
- let value = params.trim();
624
- const negated = value.startsWith("not ");
625
- if (negated) value = value.slice(4).trim();
626
- if (!value.startsWith("inline(") || !value.endsWith(")")) return;
627
- const inlineValue = value.slice(7, -1).trim();
628
- const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
629
- if (!match) return;
630
- const source = match[2];
631
- if (source === void 0) return;
632
- return {
633
- negated,
634
- source
635
- };
636
- }
637
- function collectCssInlineSourceCandidates(root) {
638
- const included = /* @__PURE__ */ new Set();
639
- const excluded = /* @__PURE__ */ new Set();
640
- root.walkAtRules("source", (rule) => {
641
- const parsed = parseSourceInlineParam(rule.params);
642
- if (!parsed) return;
643
- const target = parsed.negated ? excluded : included;
644
- for (const source of segmentTopLevel(parsed.source, " ")) {
645
- const trimmed = source.trim();
646
- if (!trimmed) continue;
647
- for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
648
- const normalized = candidate.trim();
649
- if (normalized) target.add(normalized);
650
- }
651
- }
652
- });
653
- for (const candidate of excluded) included.delete(candidate);
654
- return {
655
- included,
656
- excluded
657
- };
658
- }
659
- //#endregion
660
- //#region src/tailwindcss/source-scan.ts
661
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
662
- "html",
663
- "wxml",
664
- "axml",
665
- "jxml",
666
- "ksml",
667
- "ttml",
668
- "qml",
669
- "tyml",
670
- "xhsml",
671
- "swan",
672
- "vue",
673
- "mpx",
674
- "js",
675
- "jsx",
676
- "ts",
677
- "tsx"
678
- ];
679
- const FULL_SOURCE_SCAN_EXTENSIONS = [
680
- "js",
681
- "jsx",
682
- "mjs",
683
- "cjs",
684
- "ts",
685
- "tsx",
686
- "mts",
687
- "cts",
688
- "vue",
689
- "uvue",
690
- "nvue",
691
- "svelte",
692
- "mpx",
693
- "html",
694
- "wxml",
695
- "axml",
696
- "jxml",
697
- "ksml",
698
- "ttml",
699
- "qml",
700
- "tyml",
701
- "xhsml",
702
- "swan",
703
- "css",
704
- "wxss",
705
- "acss",
706
- "jxss",
707
- "ttss",
708
- "qss",
709
- "tyss",
710
- "scss",
711
- "sass",
712
- "less",
713
- "styl",
714
- "stylus"
715
- ];
716
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
717
- return `**/*.{${extensions.join(",")}}`;
718
- }
719
- const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
720
- const FULL_SOURCE_SCAN_EXTENSION_RE = new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
721
- function toPosixPath(value) {
722
- return value.split(node_path.default.sep).join("/");
723
- }
724
- function resolveSourceScanPath(value) {
725
- const resolved = node_path.default.resolve(value);
726
- try {
727
- return node_fs.realpathSync.native(resolved);
728
- } catch {
729
- return resolved;
730
- }
731
- }
732
- function normalizeEntryPattern(entry) {
733
- return node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), entry.pattern)) : entry.pattern;
734
- }
735
- function isFileMatchedByTailwindSourceEntry(file, entry) {
736
- const relative = toPosixPath(node_path.default.relative(resolveSourceScanPath(entry.base), file));
737
- return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeEntryPattern(entry));
738
- }
739
- function isFileExcludedByTailwindSourceEntries(file, entries) {
740
- if (!entries?.length) return false;
741
- const resolvedFile = resolveSourceScanPath(file);
742
- return entries.some((entry) => entry.negated && isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
743
- }
744
- function isFileMatchedByTailwindSourceEntries(file, entries) {
745
- if (!entries?.length) return true;
746
- const positiveEntries = entries.filter((entry) => !entry.negated);
747
- const negativeEntries = entries.filter((entry) => entry.negated);
748
- const resolvedFile = resolveSourceScanPath(file);
749
- if (positiveEntries.length === 0) return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
750
- if (!positiveEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry))) return false;
751
- return !negativeEntries.some((entry) => isFileMatchedByTailwindSourceEntry(resolvedFile, entry));
752
- }
753
- function createTailwindSourceEntryMatcher(entries) {
754
- if (!entries?.length) return;
755
- return (file) => isFileMatchedByTailwindSourceEntries(file, entries);
756
- }
757
- function resolveTailwindV4CssSourceBase(source, fallbackBase) {
758
- if (typeof source.base === "string" && source.base.length > 0) return source.base;
759
- if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
760
- return fallbackBase;
761
- }
762
- function parseConfigParam$1(params) {
763
- const value = params.trim();
764
- return /^(['"])(.+)\1$/.exec(value)?.[2];
765
- }
766
- function isLegacyContentObject(value) {
767
- return typeof value === "object" && value !== null && "files" in value;
768
- }
769
- function normalizeGlobPattern(pattern) {
770
- return pattern.startsWith("./") ? pattern.slice(2) : pattern;
771
- }
772
- function hasGlobMagic(value) {
773
- return /[*?[\]{}()!+@]/.test(value);
774
- }
775
- function splitStaticGlobPrefix(pattern) {
776
- const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
777
- const prefix = [];
778
- const rest = [];
779
- let reachedGlob = false;
780
- for (const segment of segments) {
781
- if (!reachedGlob && segment && !hasGlobMagic(segment)) {
782
- prefix.push(segment);
783
- continue;
784
- }
785
- reachedGlob = true;
786
- rest.push(segment);
787
- }
788
- return {
789
- prefix,
790
- rest
791
- };
792
- }
793
- function normalizeLegacyContentEntries(content, base, options = {}) {
794
- if (typeof content === "string") {
795
- const negated = content.startsWith("!");
796
- return [{
797
- base,
798
- negated,
799
- pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
800
- }];
801
- }
802
- if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
803
- if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
804
- return [];
805
- }
806
- async function pathExistsAsDirectory(file) {
807
- try {
808
- return (await (0, node_fs_promises.stat)(file)).isDirectory();
809
- } catch {
810
- return false;
811
- }
812
- }
813
- async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
814
- const absoluteSource = node_path.default.isAbsolute(sourcePath) ? node_path.default.resolve(sourcePath) : node_path.default.resolve(base, sourcePath);
815
- if (await pathExistsAsDirectory(absoluteSource)) return {
816
- base: absoluteSource,
817
- negated,
818
- pattern: normalizeGlobPattern(defaultPattern)
819
- };
820
- if (node_path.default.isAbsolute(sourcePath)) return {
821
- base: node_path.default.dirname(absoluteSource),
822
- negated,
823
- pattern: normalizeGlobPattern(node_path.default.basename(absoluteSource))
824
- };
825
- const { prefix, rest } = splitStaticGlobPrefix(sourcePath);
826
- if (prefix.length > 0 && rest.length > 0) return {
827
- base: node_path.default.resolve(base, ...prefix),
828
- negated,
829
- pattern: normalizeGlobPattern(rest.join("/"))
830
- };
831
- return {
832
- base,
833
- negated,
834
- pattern: normalizeGlobPattern(sourcePath)
835
- };
836
- }
837
- function parseSourceFileParam(params) {
838
- const value = params.trim();
839
- if (!value || value === "none" || value.startsWith("inline(")) return;
840
- const negated = value.startsWith("not ");
841
- const sourceValue = negated ? value.slice(4).trim() : value;
842
- if (sourceValue.startsWith("inline(")) return;
843
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
844
- return match?.[2] ? {
845
- negated,
846
- sourcePath: match[2]
847
- } : void 0;
848
- }
849
- async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
850
- const entries = [];
851
- const tasks = [];
852
- root.walkAtRules("source", (rule) => {
853
- const parsed = parseSourceFileParam(rule.params);
854
- if (!parsed) return;
855
- tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
856
- });
857
- entries.push(...await Promise.all(tasks));
858
- return entries;
859
- }
860
- async function expandTailwindSourceEntries(entries, options = {}) {
861
- if (entries.length === 0) return [];
862
- const files = /* @__PURE__ */ new Set();
863
- const entriesByBase = /* @__PURE__ */ new Map();
864
- for (const entry of entries) {
865
- const base = node_path.default.resolve(entry.base);
866
- const group = entriesByBase.get(base) ?? [];
867
- group.push({
868
- ...entry,
869
- base
870
- });
871
- entriesByBase.set(base, group);
872
- }
873
- await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
874
- const ignoredSources = options.ignore?.map((pattern) => ({
875
- base,
876
- pattern: normalizeGlobPattern(pattern),
877
- negated: true
878
- }));
879
- const matched = await (0, tailwindcss_patch.resolveProjectSourceFiles)({
880
- cwd: base,
881
- sources: group,
882
- ...ignoredSources === void 0 ? {} : { ignoredSources }
883
- });
884
- for (const file of matched) files.add(node_path.default.resolve(file));
885
- }));
886
- return [...files].filter((file) => !isFileExcludedByTailwindSourceEntries(file, entries));
887
- }
888
- //#endregion
889
- //#region src/tailwindcss/v4-engine/candidates.ts
890
- const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
891
- function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
892
- return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
893
- }
894
- function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
895
- if (!candidates) return;
896
- return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
897
- }
898
- //#endregion
899
- //#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
900
- const TAILWIND_V3_COLOR_STEPS = [
901
- "50",
902
- "100",
903
- "200",
904
- "300",
905
- "400",
906
- "500",
907
- "600",
908
- "700",
909
- "800",
910
- "900",
911
- "950"
912
- ];
913
- const TAILWIND_V3_COLOR_PALETTE = {
914
- slate: [
915
- "#f8fafc",
916
- "#f1f5f9",
917
- "#e2e8f0",
918
- "#cbd5e1",
919
- "#94a3b8",
920
- "#64748b",
921
- "#475569",
922
- "#334155",
923
- "#1e293b",
924
- "#0f172a",
925
- "#020617"
926
- ],
927
- gray: [
928
- "#f9fafb",
929
- "#f3f4f6",
930
- "#e5e7eb",
931
- "#d1d5db",
932
- "#9ca3af",
933
- "#6b7280",
934
- "#4b5563",
935
- "#374151",
936
- "#1f2937",
937
- "#111827",
938
- "#030712"
939
- ],
940
- zinc: [
941
- "#fafafa",
942
- "#f4f4f5",
943
- "#e4e4e7",
944
- "#d4d4d8",
945
- "#a1a1aa",
946
- "#71717a",
947
- "#52525b",
948
- "#3f3f46",
949
- "#27272a",
950
- "#18181b",
951
- "#09090b"
952
- ],
953
- neutral: [
954
- "#fafafa",
955
- "#f5f5f5",
956
- "#e5e5e5",
957
- "#d4d4d4",
958
- "#a3a3a3",
959
- "#737373",
960
- "#525252",
961
- "#404040",
962
- "#262626",
963
- "#171717",
964
- "#0a0a0a"
965
- ],
966
- stone: [
967
- "#fafaf9",
968
- "#f5f5f4",
969
- "#e7e5e4",
970
- "#d6d3d1",
971
- "#a8a29e",
972
- "#78716c",
973
- "#57534e",
974
- "#44403c",
975
- "#292524",
976
- "#1c1917",
977
- "#0c0a09"
978
- ],
979
- red: [
980
- "#fef2f2",
981
- "#fee2e2",
982
- "#fecaca",
983
- "#fca5a5",
984
- "#f87171",
985
- "#ef4444",
986
- "#dc2626",
987
- "#b91c1c",
988
- "#991b1b",
989
- "#7f1d1d",
990
- "#450a0a"
991
- ],
992
- orange: [
993
- "#fff7ed",
994
- "#ffedd5",
995
- "#fed7aa",
996
- "#fdba74",
997
- "#fb923c",
998
- "#f97316",
999
- "#ea580c",
1000
- "#c2410c",
1001
- "#9a3412",
1002
- "#7c2d12",
1003
- "#431407"
1004
- ],
1005
- amber: [
1006
- "#fffbeb",
1007
- "#fef3c7",
1008
- "#fde68a",
1009
- "#fcd34d",
1010
- "#fbbf24",
1011
- "#f59e0b",
1012
- "#d97706",
1013
- "#b45309",
1014
- "#92400e",
1015
- "#78350f",
1016
- "#451a03"
1017
- ],
1018
- yellow: [
1019
- "#fefce8",
1020
- "#fef9c3",
1021
- "#fef08a",
1022
- "#fde047",
1023
- "#facc15",
1024
- "#eab308",
1025
- "#ca8a04",
1026
- "#a16207",
1027
- "#854d0e",
1028
- "#713f12",
1029
- "#422006"
1030
- ],
1031
- lime: [
1032
- "#f7fee7",
1033
- "#ecfccb",
1034
- "#d9f99d",
1035
- "#bef264",
1036
- "#a3e635",
1037
- "#84cc16",
1038
- "#65a30d",
1039
- "#4d7c0f",
1040
- "#3f6212",
1041
- "#365314",
1042
- "#1a2e05"
1043
- ],
1044
- green: [
1045
- "#f0fdf4",
1046
- "#dcfce7",
1047
- "#bbf7d0",
1048
- "#86efac",
1049
- "#4ade80",
1050
- "#22c55e",
1051
- "#16a34a",
1052
- "#15803d",
1053
- "#166534",
1054
- "#14532d",
1055
- "#052e16"
1056
- ],
1057
- emerald: [
1058
- "#ecfdf5",
1059
- "#d1fae5",
1060
- "#a7f3d0",
1061
- "#6ee7b7",
1062
- "#34d399",
1063
- "#10b981",
1064
- "#059669",
1065
- "#047857",
1066
- "#065f46",
1067
- "#064e3b",
1068
- "#022c22"
1069
- ],
1070
- teal: [
1071
- "#f0fdfa",
1072
- "#ccfbf1",
1073
- "#99f6e4",
1074
- "#5eead4",
1075
- "#2dd4bf",
1076
- "#14b8a6",
1077
- "#0d9488",
1078
- "#0f766e",
1079
- "#115e59",
1080
- "#134e4a",
1081
- "#042f2e"
1082
- ],
1083
- cyan: [
1084
- "#ecfeff",
1085
- "#cffafe",
1086
- "#a5f3fc",
1087
- "#67e8f9",
1088
- "#22d3ee",
1089
- "#06b6d4",
1090
- "#0891b2",
1091
- "#0e7490",
1092
- "#155e75",
1093
- "#164e63",
1094
- "#083344"
1095
- ],
1096
- sky: [
1097
- "#f0f9ff",
1098
- "#e0f2fe",
1099
- "#bae6fd",
1100
- "#7dd3fc",
1101
- "#38bdf8",
1102
- "#0ea5e9",
1103
- "#0284c7",
1104
- "#0369a1",
1105
- "#075985",
1106
- "#0c4a6e",
1107
- "#082f49"
1108
- ],
1109
- blue: [
1110
- "#eff6ff",
1111
- "#dbeafe",
1112
- "#bfdbfe",
1113
- "#93c5fd",
1114
- "#60a5fa",
1115
- "#3b82f6",
1116
- "#2563eb",
1117
- "#1d4ed8",
1118
- "#1e40af",
1119
- "#1e3a8a",
1120
- "#172554"
1121
- ],
1122
- indigo: [
1123
- "#eef2ff",
1124
- "#e0e7ff",
1125
- "#c7d2fe",
1126
- "#a5b4fc",
1127
- "#818cf8",
1128
- "#6366f1",
1129
- "#4f46e5",
1130
- "#4338ca",
1131
- "#3730a3",
1132
- "#312e81",
1133
- "#1e1b4b"
1134
- ],
1135
- violet: [
1136
- "#f5f3ff",
1137
- "#ede9fe",
1138
- "#ddd6fe",
1139
- "#c4b5fd",
1140
- "#a78bfa",
1141
- "#8b5cf6",
1142
- "#7c3aed",
1143
- "#6d28d9",
1144
- "#5b21b6",
1145
- "#4c1d95",
1146
- "#2e1065"
1147
- ],
1148
- purple: [
1149
- "#faf5ff",
1150
- "#f3e8ff",
1151
- "#e9d5ff",
1152
- "#d8b4fe",
1153
- "#c084fc",
1154
- "#a855f7",
1155
- "#9333ea",
1156
- "#7e22ce",
1157
- "#6b21a8",
1158
- "#581c87",
1159
- "#3b0764"
1160
- ],
1161
- fuchsia: [
1162
- "#fdf4ff",
1163
- "#fae8ff",
1164
- "#f5d0fe",
1165
- "#f0abfc",
1166
- "#e879f9",
1167
- "#d946ef",
1168
- "#c026d3",
1169
- "#a21caf",
1170
- "#86198f",
1171
- "#701a75",
1172
- "#4a044e"
1173
- ],
1174
- pink: [
1175
- "#fdf2f8",
1176
- "#fce7f3",
1177
- "#fbcfe8",
1178
- "#f9a8d4",
1179
- "#f472b6",
1180
- "#ec4899",
1181
- "#db2777",
1182
- "#be185d",
1183
- "#9d174d",
1184
- "#831843",
1185
- "#500724"
1186
- ],
1187
- rose: [
1188
- "#fff1f2",
1189
- "#ffe4e6",
1190
- "#fecdd3",
1191
- "#fda4af",
1192
- "#fb7185",
1193
- "#f43f5e",
1194
- "#e11d48",
1195
- "#be123c",
1196
- "#9f1239",
1197
- "#881337",
1198
- "#4c0519"
1199
- ]
1200
- };
1201
- function createTailwindV3DefaultColorThemeCss() {
1202
- const declarations = [" --color-black: #000;", " --color-white: #fff;"];
1203
- for (const [color, values] of Object.entries(TAILWIND_V3_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V3_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V3_COLOR_STEPS[index]}: ${values[index]};`);
1204
- return [
1205
- "@theme {",
1206
- ...declarations,
1207
- "}"
1208
- ].join("\n");
1209
- }
1210
- //#endregion
1211
- //#region src/tailwindcss/v4-engine/tailwind-v3-compatibility.ts
1212
- const TAILWIND_V3_COMPATIBILITY_THEME_CSS = [
1213
- "@theme {",
1214
- " --default-ring-width: 3px;",
1215
- " --default-ring-color: var(--color-blue-500, #3b82f6);",
1216
- " --default-outline-width: 3px;",
1217
- "",
1218
- " --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
1219
- " --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
1220
- " --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
1221
- " --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
1222
- " --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
1223
- " --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
1224
- "",
1225
- " --blur-xs: 4px;",
1226
- " --blur-sm: 4px;",
1227
- " --blur: 8px;",
1228
- " --backdrop-blur-xs: 4px;",
1229
- " --backdrop-blur-sm: 4px;",
1230
- " --backdrop-blur: 8px;",
1231
- "",
1232
- " --radius-xs: 0.125rem;",
1233
- " --radius-sm: 0.125rem;",
1234
- " --radius: 0.25rem;",
1235
- "}",
1236
- createTailwindV3DefaultColorThemeCss()
1237
- ].join("\n");
1238
- const TAILWIND_V3_COMPATIBILITY_BASE_CSS = [
1239
- "*,",
1240
- "::after,",
1241
- "::before,",
1242
- "::backdrop,",
1243
- "::file-selector-button {",
1244
- " border-color: var(--color-gray-200, currentcolor);",
1245
- "}",
1246
- "",
1247
- "input::placeholder,",
1248
- "textarea::placeholder {",
1249
- " opacity: 1;",
1250
- " color: var(--color-gray-400, currentcolor);",
1251
- "}",
1252
- "",
1253
- "button:not(:disabled),",
1254
- "[role=\"button\"]:not(:disabled) {",
1255
- " cursor: pointer;",
1256
- "}",
1257
- "",
1258
- "dialog {",
1259
- " margin: auto;",
1260
- "}"
1261
- ].join("\n");
1262
- function applyTailwindV3CompatibilityCss(css) {
1263
- return `${TAILWIND_V3_COMPATIBILITY_THEME_CSS}\n${css}\n${TAILWIND_V3_COMPATIBILITY_BASE_CSS}`;
1264
- }
1265
- //#endregion
1266
- //#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
1267
- const TAILWIND_V4_COLOR_STEPS = [
1268
- "50",
1269
- "100",
1270
- "200",
1271
- "300",
1272
- "400",
1273
- "500",
1274
- "600",
1275
- "700",
1276
- "800",
1277
- "900",
1278
- "950"
1279
- ];
1280
- const TAILWIND_V4_COLOR_PALETTE = {
1281
- slate: [
1282
- "#f8fafc",
1283
- "#f1f5f9",
1284
- "#e2e8f0",
1285
- "#cad5e2",
1286
- "#90a1b9",
1287
- "#62748e",
1288
- "#45556c",
1289
- "#314158",
1290
- "#1d293d",
1291
- "#0f172b",
1292
- "#020618"
1293
- ],
1294
- gray: [
1295
- "#f9fafb",
1296
- "#f3f4f6",
1297
- "#e5e7eb",
1298
- "#d1d5dc",
1299
- "#99a1af",
1300
- "#6a7282",
1301
- "#4a5565",
1302
- "#364153",
1303
- "#1e2939",
1304
- "#101828",
1305
- "#030712"
1306
- ],
1307
- zinc: [
1308
- "#fafafa",
1309
- "#f4f4f5",
1310
- "#e4e4e7",
1311
- "#d4d4d8",
1312
- "#9f9fa9",
1313
- "#71717b",
1314
- "#52525c",
1315
- "#3f3f46",
1316
- "#27272a",
1317
- "#18181b",
1318
- "#09090b"
1319
- ],
1320
- neutral: [
1321
- "#fafafa",
1322
- "#f5f5f5",
1323
- "#e5e5e5",
1324
- "#d4d4d4",
1325
- "#a1a1a1",
1326
- "#737373",
1327
- "#525252",
1328
- "#404040",
1329
- "#262626",
1330
- "#171717",
1331
- "#0a0a0a"
1332
- ],
1333
- stone: [
1334
- "#fafaf9",
1335
- "#f5f5f4",
1336
- "#e7e5e4",
1337
- "#d6d3d1",
1338
- "#a6a09b",
1339
- "#79716b",
1340
- "#57534d",
1341
- "#44403b",
1342
- "#292524",
1343
- "#1c1917",
1344
- "#0c0a09"
1345
- ],
1346
- mauve: [
1347
- "#fafafa",
1348
- "#f3f1f3",
1349
- "#e7e4e7",
1350
- "#d7d0d7",
1351
- "#a89ea9",
1352
- "#79697b",
1353
- "#594c5b",
1354
- "#463947",
1355
- "#2a212c",
1356
- "#1d161e",
1357
- "#0c090c"
1358
- ],
1359
- olive: [
1360
- "#fbfbf9",
1361
- "#f4f4f0",
1362
- "#e8e8e3",
1363
- "#d8d8d0",
1364
- "#abab9c",
1365
- "#7c7c67",
1366
- "#5b5b4b",
1367
- "#474739",
1368
- "#2b2b22",
1369
- "#1d1d16",
1370
- "#0c0c09"
1371
- ],
1372
- mist: [
1373
- "#f9fbfb",
1374
- "#f1f3f3",
1375
- "#e3e7e8",
1376
- "#d0d6d8",
1377
- "#9ca8ab",
1378
- "#67787c",
1379
- "#4b585b",
1380
- "#394447",
1381
- "#22292b",
1382
- "#161b1d",
1383
- "#090b0c"
1384
- ],
1385
- taupe: [
1386
- "#fbfaf9",
1387
- "#f3f1f1",
1388
- "#e8e4e3",
1389
- "#d8d2d0",
1390
- "#aba09c",
1391
- "#7c6d67",
1392
- "#5b4f4b",
1393
- "#473c39",
1394
- "#2b2422",
1395
- "#1d1816",
1396
- "#0c0a09"
1397
- ],
1398
- red: [
1399
- "#fef2f2",
1400
- "#ffe2e2",
1401
- "#ffc9c9",
1402
- "#ffa2a2",
1403
- "#ff6467",
1404
- "#fb2c36",
1405
- "#e7000b",
1406
- "#c10007",
1407
- "#9f0712",
1408
- "#82181a",
1409
- "#460809"
1410
- ],
1411
- orange: [
1412
- "#fff7ed",
1413
- "#ffedd4",
1414
- "#ffd6a7",
1415
- "#ffb86a",
1416
- "#ff8904",
1417
- "#ff6900",
1418
- "#f54900",
1419
- "#ca3500",
1420
- "#9f2d00",
1421
- "#7e2a0c",
1422
- "#441306"
1423
- ],
1424
- amber: [
1425
- "#fffbeb",
1426
- "#fef3c6",
1427
- "#fee685",
1428
- "#ffd230",
1429
- "#ffb900",
1430
- "#fe9a00",
1431
- "#e17100",
1432
- "#bb4d00",
1433
- "#973c00",
1434
- "#7b3306",
1435
- "#461901"
1436
- ],
1437
- yellow: [
1438
- "#fefce8",
1439
- "#fef9c2",
1440
- "#fff085",
1441
- "#ffdf20",
1442
- "#fdc700",
1443
- "#f0b100",
1444
- "#d08700",
1445
- "#a65f00",
1446
- "#894b00",
1447
- "#733e0a",
1448
- "#432004"
1449
- ],
1450
- lime: [
1451
- "#f7fee7",
1452
- "#ecfcca",
1453
- "#d8f999",
1454
- "#bbf451",
1455
- "#9ae600",
1456
- "#7ccf00",
1457
- "#5ea500",
1458
- "#497d00",
1459
- "#3c6300",
1460
- "#35530e",
1461
- "#192e03"
1462
- ],
1463
- green: [
1464
- "#f0fdf4",
1465
- "#dcfce7",
1466
- "#b9f8cf",
1467
- "#7bf1a8",
1468
- "#05df72",
1469
- "#00c950",
1470
- "#00a63e",
1471
- "#008236",
1472
- "#016630",
1473
- "#0d542b",
1474
- "#032e15"
1475
- ],
1476
- emerald: [
1477
- "#ecfdf5",
1478
- "#d0fae5",
1479
- "#a4f4cf",
1480
- "#5ee9b5",
1481
- "#00d492",
1482
- "#00bc7d",
1483
- "#009966",
1484
- "#007a55",
1485
- "#006045",
1486
- "#004f3b",
1487
- "#002c22"
1488
- ],
1489
- teal: [
1490
- "#f0fdfa",
1491
- "#cbfbf1",
1492
- "#96f7e4",
1493
- "#46ecd5",
1494
- "#00d5be",
1495
- "#00bba7",
1496
- "#009689",
1497
- "#00786f",
1498
- "#005f5a",
1499
- "#0b4f4a",
1500
- "#022f2e"
1501
- ],
1502
- cyan: [
1503
- "#ecfeff",
1504
- "#cefafe",
1505
- "#a2f4fd",
1506
- "#53eafd",
1507
- "#00d3f2",
1508
- "#00b8db",
1509
- "#0092b8",
1510
- "#007595",
1511
- "#005f78",
1512
- "#104e64",
1513
- "#053345"
1514
- ],
1515
- sky: [
1516
- "#f0f9ff",
1517
- "#dff2fe",
1518
- "#b8e6fe",
1519
- "#74d4ff",
1520
- "#00bcff",
1521
- "#00a6f4",
1522
- "#0084d1",
1523
- "#0069a8",
1524
- "#00598a",
1525
- "#024a70",
1526
- "#052f4a"
1527
- ],
1528
- blue: [
1529
- "#eff6ff",
1530
- "#dbeafe",
1531
- "#bedbff",
1532
- "#8ec5ff",
1533
- "#51a2ff",
1534
- "#2b7fff",
1535
- "#155dfc",
1536
- "#1447e6",
1537
- "#193cb8",
1538
- "#1c398e",
1539
- "#162456"
1540
- ],
1541
- indigo: [
1542
- "#eef2ff",
1543
- "#e0e7ff",
1544
- "#c6d2ff",
1545
- "#a3b3ff",
1546
- "#7c86ff",
1547
- "#615fff",
1548
- "#4f39f6",
1549
- "#432dd7",
1550
- "#372aac",
1551
- "#312c85",
1552
- "#1e1a4d"
1553
- ],
1554
- violet: [
1555
- "#f5f3ff",
1556
- "#ede9fe",
1557
- "#ddd6ff",
1558
- "#c4b4ff",
1559
- "#a684ff",
1560
- "#8e51ff",
1561
- "#7f22fe",
1562
- "#7008e7",
1563
- "#5d0ec0",
1564
- "#4d179a",
1565
- "#2f0d68"
1566
- ],
1567
- purple: [
1568
- "#faf5ff",
1569
- "#f3e8ff",
1570
- "#e9d4ff",
1571
- "#dab2ff",
1572
- "#c27aff",
1573
- "#ad46ff",
1574
- "#9810fa",
1575
- "#8200db",
1576
- "#6e11b0",
1577
- "#59168b",
1578
- "#3c0366"
1579
- ],
1580
- fuchsia: [
1581
- "#fdf4ff",
1582
- "#fae8ff",
1583
- "#f6cfff",
1584
- "#f4a8ff",
1585
- "#ed6aff",
1586
- "#e12afb",
1587
- "#c800de",
1588
- "#a800b7",
1589
- "#8a0194",
1590
- "#721378",
1591
- "#4b004f"
1592
- ],
1593
- pink: [
1594
- "#fdf2f8",
1595
- "#fce7f3",
1596
- "#fccee8",
1597
- "#fda5d5",
1598
- "#fb64b6",
1599
- "#f6339a",
1600
- "#e60076",
1601
- "#c6005c",
1602
- "#a3004c",
1603
- "#861043",
1604
- "#510424"
1605
- ],
1606
- rose: [
1607
- "#fff1f2",
1608
- "#ffe4e6",
1609
- "#ffccd3",
1610
- "#ffa1ad",
1611
- "#ff637e",
1612
- "#ff2056",
1613
- "#ec003f",
1614
- "#c70036",
1615
- "#a50036",
1616
- "#8b0836",
1617
- "#4d0218"
1618
- ]
1619
- };
1620
- function createTailwindV4DefaultColorThemeCss() {
1621
- const declarations = [" --color-black: #000;", " --color-white: #fff;"];
1622
- for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
1623
- return [
1624
- "@theme {",
1625
- ...declarations,
1626
- "}"
1627
- ].join("\n");
1628
- }
1629
- //#endregion
1630
- //#region src/tailwindcss/v4-engine/generator/css-compat.ts
1631
- function findLeadingImportInsertionIndex(css) {
1632
- const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
1633
- let insertionIndex = 0;
1634
- let match = importPattern.exec(css);
1635
- while (match !== null) {
1636
- insertionIndex = match.index + match[0].length;
1637
- match = importPattern.exec(css);
1638
- }
1639
- return insertionIndex;
1640
- }
1641
- function applyMiniProgramTailwindV4DefaultColorCss(css) {
1642
- const themeCss = createTailwindV4DefaultColorThemeCss();
1643
- const insertionIndex = findLeadingImportInsertionIndex(css);
1644
- if (insertionIndex === 0) return `${themeCss}\n${css}`;
1645
- return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
1646
- }
1647
- function parseCssImportSpecifier$3(params) {
1648
- const value = params.trim();
1649
- const quoted = /^(['"])(.*?)\1/.exec(value);
1650
- if (quoted) return quoted[2];
1651
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
1652
- return url?.[2] ?? url?.[3];
1653
- }
1654
- function isTailwindCssPreflightImport(params) {
1655
- const specifier = parseCssImportSpecifier$3(params);
1656
- return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
1657
- }
1658
- function hasImportLayerOption(params) {
1659
- return /\blayer(?:\s*\(|\s*$)/.test(params);
1660
- }
1661
- function removeUnlayeredTailwindV4PreflightImports(css) {
1662
- if (!css.includes("preflight")) return css;
1663
- let root;
1664
- try {
1665
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
1666
- } catch {
1667
- return css;
1668
- }
1669
- let changed = false;
1670
- root.walkAtRules("import", (rule) => {
1671
- if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
1672
- rule.remove();
1673
- changed = true;
1674
- }
1675
- });
1676
- return changed ? root.toString() : css;
1677
- }
1678
- function hasThemeParent(rule) {
1679
- let parent = rule.parent;
1680
- while (parent) {
1681
- if (parent.type === "atrule" && parent.name === "theme") return true;
1682
- parent = parent.parent;
1683
- }
1684
- return false;
1685
- }
1686
- function isVendorPrefixedKeyframes(rule) {
1687
- return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
1688
- }
1689
- function removeUnsupportedThemeVendorKeyframes(css) {
1690
- if (!css.includes("@theme") || !css.includes("@-")) return css;
1691
- let root;
1692
- try {
1693
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
1694
- } catch {
1695
- return css;
1696
- }
1697
- let changed = false;
1698
- root.walkAtRules((rule) => {
1699
- if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
1700
- rule.remove();
1701
- changed = true;
1702
- }
1703
- });
1704
- return changed ? root.toString() : css;
1705
- }
1706
- function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
1707
- const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
1708
- const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
1709
- const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
1710
- return compatibleSourceCss === source.css ? source : {
1711
- ...source,
1712
- css: compatibleSourceCss
1713
- };
1714
- }
1715
- //#endregion
1716
- //#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
1717
- const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
1718
- const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
1719
- function normalizeRpxTextCandidate(candidate) {
1720
- return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
1721
- }
1722
- function normalizeRpxTextCandidates(candidates) {
1723
- const normalized = /* @__PURE__ */ new Set();
1724
- const restoreCandidates = /* @__PURE__ */ new Map();
1725
- for (const candidate of candidates) {
1726
- const normalizedCandidate = normalizeRpxTextCandidate(candidate);
1727
- normalized.add(normalizedCandidate);
1728
- if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
1729
- }
1730
- return {
1731
- candidates: normalized,
1732
- restoreCandidates
1733
- };
1734
- }
1735
- function restoreRpxTextCandidates(candidates, restoreCandidates) {
1736
- if (restoreCandidates.size === 0) return new Set(candidates);
1737
- return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
1738
- }
1739
- function normalizeCssEscapedRpxSelectorValue(value) {
1740
- return value.replace(/\\([.+-])/g, "$1");
1741
- }
1742
- function restoreRpxTextCssSelectors(css, restoreCandidates) {
1743
- if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
1744
- const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
1745
- return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
1746
- }).filter((value) => Boolean(value)));
1747
- return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
1748
- return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
1749
- });
1750
- }
1751
- //#endregion
1752
- //#region src/tailwindcss/v4-engine/generator/scan-sources.ts
1753
- const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
1754
- "**/.git/**",
1755
- "**/.hg/**",
1756
- "**/.jj/**",
1757
- "**/.next/**",
1758
- "**/.parcel-cache/**",
1759
- "**/.pnpm-store/**",
1760
- "**/.svelte-kit/**",
1761
- "**/.svn/**",
1762
- "**/.turbo/**",
1763
- "**/.venv/**",
1764
- "**/.vercel/**",
1765
- "**/.yarn/**",
1766
- "**/__pycache__/**",
1767
- "**/node_modules/**",
1768
- "**/venv/**",
1769
- "**/*.less",
1770
- "**/*.lock",
1771
- "**/*.sass",
1772
- "**/*.scss",
1773
- "**/*.styl",
1774
- "**/*.log",
1775
- "**/package-lock.json",
1776
- "**/pnpm-lock.yaml",
1777
- "**/bun.lockb",
1778
- "**/.gitignore",
1779
- "**/.env",
1780
- "**/.env.*"
1781
- ];
1782
- function parseImportSourceParam$1(params) {
1783
- const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
1784
- if (!match) return;
1785
- return {
1786
- none: match[1] === "none",
1787
- sourcePath: match[3]
1788
- };
1789
- }
1790
- function parseCssImportSpecifier$2(params) {
1791
- const value = params.trim();
1792
- const quoted = /^(['"])(.*?)\1/.exec(value);
1793
- if (quoted) return quoted[2];
1794
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
1795
- return url?.[2] ?? url?.[3];
1796
- }
1797
- function isTailwindCssImport$1(params) {
1798
- const specifier = parseCssImportSpecifier$2(params);
1799
- return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
1800
- }
1801
- function resolveSourceBase$1(base, sourcePath) {
1802
- return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
1803
- }
1804
- function createDefaultIgnoredScanSources(base) {
1805
- return TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS.map((pattern) => ({
1806
- base,
1807
- pattern,
1808
- negated: true
1809
- }));
1810
- }
1811
- function normalizeCssDefinedScanSources(base, entries) {
1812
- return entries.length > 0 && entries.every((entry) => entry.negated) ? [{
1813
- base,
1814
- pattern: "**/*",
1815
- negated: false
1816
- }, ...entries] : entries;
1817
- }
1818
- async function resolveCssDefinedScanSources(source) {
1819
- let importSourceBase;
1820
- let hasSourceNone = false;
1821
- const from = source.dependencies[0];
1822
- let root;
1823
- try {
1824
- root = _weapp_tailwindcss_postcss.postcss.parse(source.css, { from });
1825
- } catch {
1826
- return;
1827
- }
1828
- root.walkAtRules((rule) => {
1829
- if (rule.name === "import") {
1830
- if (!isTailwindCssImport$1(rule.params)) return;
1831
- const sourceParam = parseImportSourceParam$1(rule.params);
1832
- if (sourceParam?.none) hasSourceNone = true;
1833
- if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase$1(source.base, sourceParam.sourcePath);
1834
- }
1835
- });
1836
- const sourcePatterns = await resolveCssSourceEntries(root, source.base, "**/*");
1837
- if (!importSourceBase) {
1838
- if (sourcePatterns.length > 0) return [...normalizeCssDefinedScanSources(source.base, sourcePatterns), ...createDefaultIgnoredScanSources(source.base)];
1839
- if (hasSourceNone) return false;
1840
- return;
1841
- }
1842
- return [
1843
- await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
1844
- ...sourcePatterns,
1845
- ...createDefaultIgnoredScanSources(importSourceBase)
1846
- ];
1847
- }
1848
- async function resolveScanSources(source, scanSources) {
1849
- if (scanSources !== true) return scanSources;
1850
- return await resolveCssDefinedScanSources(source) ?? false;
1851
- }
1852
- //#endregion
1853
- //#region src/tailwindcss/v4-engine/miniprogram.ts
1854
- const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
1855
- cssChildCombinatorReplaceValue: ["view", "text"],
1856
- cssRemoveHoverPseudoClass: true,
1857
- isMainChunk: true,
1858
- majorVersion: 4
1859
- });
1860
- const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
1861
- function normalizeTailwindV4GeneratedUrlValues(css) {
1862
- return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
1863
- try {
1864
- return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
1865
- } catch {
1866
- return match;
1867
- }
1868
- });
1869
- }
1870
- async function transformTailwindV4CssToWeapp(css, options) {
1871
- const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
1872
- const result = await defaultStyleHandler$1(protectedCss.css, {
1873
- cssChildCombinatorReplaceValue: ["view", "text"],
1874
- cssRemoveHoverPseudoClass: true,
1875
- isMainChunk: true,
1876
- majorVersion: 4,
1877
- ...options
1878
- });
1879
- const pruneOptions = { preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) };
1880
- return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
1881
- }
1882
- async function transformTailwindV4CssByTarget(css, target, options) {
1883
- if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
1884
- return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
1885
- }
1886
- //#endregion
1887
- //#region src/tailwindcss/v4-engine/generator.ts
1888
- const INCREMENTAL_GENERATE_CACHE_MAX$1 = 8;
1889
- const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
1890
- const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1 = 128;
1891
- const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 = 256 * 1024;
1892
- const incrementalGenerateCache$1 = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX$1 });
1893
- const incrementalGenerateTaskCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
1894
- function collectCandidates(candidates) {
1895
- return new Set(candidates ?? []);
1896
- }
1897
- function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
1898
- for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
1899
- return false;
1900
- }
1901
- function createStableJson(value) {
1902
- if (value === void 0) return "undefined";
1903
- if (value === null || typeof value !== "object") return JSON.stringify(value);
1904
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
1905
- return `{${Object.keys(value).sort().map((key) => {
1906
- const record = value;
1907
- return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
1908
- }).join(",")}}`;
1909
- }
1910
- function createDependencyFingerprint(files) {
1911
- return files.map((file) => {
1912
- try {
1913
- const stat = node_fs.default.statSync(file);
1914
- return `${file}:${stat.size}:${stat.mtimeMs}`;
1915
- } catch {
1916
- return `${file}:missing`;
1917
- }
1918
- }).join("|");
1919
- }
1920
- function createIncrementalGenerateCacheKey(source, target, styleOptions, tailwindcssV3Compatibility) {
1921
- return [
1922
- source.projectRoot,
1923
- source.base,
1924
- createStableJson(source.baseFallbacks),
1925
- source.css,
1926
- createDependencyFingerprint(source.dependencies),
1927
- target,
1928
- createStableJson(styleOptions),
1929
- createStableJson(tailwindcssV3Compatibility)
1930
- ].join("\0");
1931
- }
1932
- function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
1933
- return [
1934
- cacheKey,
1935
- scanSources === true ? "scan:1" : "scan:0",
1936
- [...requestedCandidates].sort().join("\n")
1937
- ].join("\0");
1938
- }
1939
- function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
1940
- const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
1941
- const cachedTask = incrementalGenerateTaskCache.get(taskKey);
1942
- if (cachedTask) return cachedTask;
1943
- const promise = task();
1944
- incrementalGenerateTaskCache.set(taskKey, promise);
1945
- promise.finally(() => {
1946
- if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
1947
- });
1948
- return promise;
1949
- }
1950
- function createIncrementalDesignSystemPromise(source, cacheKey) {
1951
- const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
1952
- promise.catch(() => {
1953
- if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
1954
- });
1955
- return promise;
1956
- }
1957
- function resolveTargetCandidates(candidates, target) {
1958
- const collected = collectCandidates(candidates);
1959
- return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
1960
- }
1961
- function collectSeenCandidates(generated, requestedCandidates) {
1962
- return new Set([
1963
- ...requestedCandidates,
1964
- ...generated.rawCandidates,
1965
- ...generated.classSet
1966
- ]);
1967
- }
1968
- function createIncrementalStyleOptions(styleOptions) {
1969
- return {
1970
- ...styleOptions,
1971
- isMainChunk: false
1972
- };
1973
- }
1974
- function resolveStyleOptions$1(source, options) {
1975
- return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Directive)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
1976
- }
1977
- function collectCustomPropertyValues(css) {
1978
- const values = /* @__PURE__ */ new Map();
1979
- try {
1980
- _weapp_tailwindcss_postcss.postcss.parse(css).walkDecls((decl) => {
1981
- if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
1982
- });
1983
- } catch {}
1984
- return values;
1985
- }
1986
- function mergeCustomPropertyValues(target, css) {
1987
- for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
1988
- }
1989
- function shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates) {
1990
- return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1 || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1 || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1;
1991
- }
1992
- function seedIncrementalGenerateCache(options) {
1993
- const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
1994
- const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
1995
- mergeCustomPropertyValues(customPropertyValues, options.generated.css);
1996
- incrementalGenerateCache$1.set(cacheKey, {
1997
- seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
1998
- classSet: new Set(options.generated.classSet),
1999
- css: options.generated.css,
2000
- rawCss: options.generated.rawCss,
2001
- customPropertyValues,
2002
- designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
2003
- dependencies: options.generated.dependencies,
2004
- sources: options.generated.sources,
2005
- root: options.generated.root,
2006
- target: options.generated.target
2007
- });
2008
- }
2009
- function createTailwindV4Engine(source) {
2010
- async function generateOnce(generateSource, options = {}) {
2011
- const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
2012
- const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
2013
- const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
2014
- const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
2015
- const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
2016
- const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
2017
- const result = await engine.generate(omitUndefined({
2018
- scanSources: false,
2019
- ...patchOptions,
2020
- candidates: normalizedCandidates.candidates
2021
- }));
2022
- const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
2023
- const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
2024
- return {
2025
- ...result,
2026
- classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
2027
- rawCandidates: restoreRpxTextCandidates(result.rawCandidates, normalizedCandidates.restoreCandidates),
2028
- css,
2029
- rawCss,
2030
- target
2031
- };
2032
- }
2033
- async function generateWithIncrementalCache(options = {}) {
2034
- const target = options.target ?? "weapp";
2035
- const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
2036
- const requestedCandidates = resolveTargetCandidates(options.candidates, target);
2037
- const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
2038
- if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
2039
- const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
2040
- if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2041
- const generated = await generateOnce(source, options);
2042
- seedIncrementalGenerateCache({
2043
- compatibleSource,
2044
- generated,
2045
- requestedCandidates,
2046
- styleOptions: options.styleOptions,
2047
- tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2048
- target
2049
- });
2050
- return generated;
2051
- });
2052
- const cached = incrementalGenerateCache$1.get(cacheKey);
2053
- if (cached) {
2054
- if (hasRemovedCandidates$1(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2055
- const generated = await generateOnce(source, options);
2056
- seedIncrementalGenerateCache({
2057
- compatibleSource,
2058
- generated,
2059
- requestedCandidates,
2060
- styleOptions,
2061
- tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2062
- target
2063
- });
2064
- return generated;
2065
- });
2066
- const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
2067
- if (missingCandidates.length === 0) return {
2068
- css: cached.css,
2069
- rawCss: cached.rawCss,
2070
- incrementalCss: "",
2071
- incrementalRawCss: "",
2072
- classSet: new Set(cached.classSet),
2073
- rawCandidates: new Set(cached.seenCandidates),
2074
- dependencies: cached.dependencies,
2075
- sources: cached.sources,
2076
- root: cached.root,
2077
- target: cached.target
2078
- };
2079
- if (shouldRebuildIncrementalEntry$1(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2080
- const generated = await generateOnce(source, options);
2081
- seedIncrementalGenerateCache({
2082
- compatibleSource,
2083
- generated,
2084
- requestedCandidates,
2085
- styleOptions,
2086
- tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2087
- target
2088
- });
2089
- return generated;
2090
- });
2091
- return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2092
- const designSystem = await cached.designSystemPromise;
2093
- const normalizedMissing = normalizeRpxTextCandidates(missingCandidates);
2094
- const normalizedMissingCandidates = [...normalizedMissing.candidates];
2095
- const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
2096
- const rawCssParts = [];
2097
- const classSet = /* @__PURE__ */ new Set();
2098
- for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
2099
- const candidate = normalizedMissingCandidates[index];
2100
- const css = cssByCandidate[index];
2101
- if (candidate && typeof css === "string" && css.trim().length > 0) {
2102
- rawCssParts.push(restoreRpxTextCssSelectors(css, normalizedMissing.restoreCandidates));
2103
- classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
2104
- }
2105
- }
2106
- const rawCss = rawCssParts.join("\n");
2107
- const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
2108
- ...createIncrementalStyleOptions(styleOptions),
2109
- customPropertyValues: cached.customPropertyValues
2110
- }) : "";
2111
- for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
2112
- for (const className of classSet) cached.classSet.add(className);
2113
- cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
2114
- cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
2115
- mergeCustomPropertyValues(cached.customPropertyValues, incrementalCss);
2116
- return {
2117
- css: cached.css,
2118
- rawCss: cached.rawCss,
2119
- incrementalCss,
2120
- incrementalRawCss: rawCss,
2121
- classSet: new Set(cached.classSet),
2122
- rawCandidates: new Set(cached.seenCandidates),
2123
- dependencies: cached.dependencies,
2124
- sources: cached.sources,
2125
- root: cached.root,
2126
- target: cached.target
2127
- };
2128
- });
2129
- }
2130
- return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2131
- const generated = await generateOnce(source, options);
2132
- seedIncrementalGenerateCache({
2133
- compatibleSource,
2134
- generated,
2135
- requestedCandidates,
2136
- styleOptions,
2137
- tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
2138
- target
2139
- });
2140
- return generated;
2141
- });
2142
- }
2143
- async function generate(options = {}) {
2144
- return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
2145
- }
2146
- return {
2147
- source,
2148
- loadDesignSystem: (0, tailwindcss_patch.createTailwindV4Engine)(source).loadDesignSystem,
2149
- validateCandidates: (0, tailwindcss_patch.createTailwindV4Engine)(source).validateCandidates,
2150
- generate
2151
- };
2152
- }
2153
- function getTailwindV4IncrementalGenerateCacheStats() {
2154
- return {
2155
- max: INCREMENTAL_GENERATE_CACHE_MAX$1,
2156
- entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX$1,
2157
- entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX$1,
2158
- size: incrementalGenerateCache$1.size,
2159
- taskMax: INCREMENTAL_GENERATE_TASK_CACHE_MAX,
2160
- taskSize: incrementalGenerateTaskCache.size,
2161
- entries: [...incrementalGenerateCache$1.entries()].map(([key, entry]) => ({
2162
- key,
2163
- candidates: entry.seenCandidates.size,
2164
- classSet: entry.classSet.size,
2165
- cssBytes: entry.css.length,
2166
- rawCssBytes: entry.rawCss.length
2167
- })),
2168
- keys: [...incrementalGenerateCache$1.keys()],
2169
- taskKeys: [...incrementalGenerateTaskCache.keys()]
2170
- };
2171
- }
2172
- //#endregion
2173
- //#region src/bundlers/shared/generator-css/config-directive.ts
2174
- function quoteCssString(value) {
2175
- return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
2176
- }
2177
- function toCssPath(value) {
2178
- return value.replaceAll("\\", "/");
2179
- }
2180
- function prependConfigDirective(css, config) {
2181
- if (!config || /@config\s+/.test(css)) return css;
2182
- return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
2183
- }
2184
- function normalizeConfigDirective(css, config) {
2185
- if (!config || !/@config\s+/.test(css)) return css;
2186
- return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
2187
- }
2188
- //#endregion
2189
- //#region src/bundlers/shared/generator-css/markers.ts
2190
- const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
2191
- const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
2192
- const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
2193
- const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
2194
- const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
2195
- const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
2196
- const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
2197
- const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
2198
- function createCssAppend(base, extra) {
2199
- if (!base) return extra;
2200
- if (!extra) return base;
2201
- return `${base}\n${extra}`;
2202
- }
2203
- function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
2204
- const trimmedRaw = rawSource.trim();
2205
- const trimmedTailwind = rawTailwindCss.trim();
2206
- if (trimmedRaw === trimmedTailwind) return {
2207
- before: "",
2208
- after: ""
2209
- };
2210
- if (trimmedTailwind.startsWith(trimmedRaw)) return {
2211
- before: "",
2212
- after: ""
2213
- };
2214
- const start = rawSource.indexOf(rawTailwindCss);
2215
- if (start === -1) return;
2216
- return {
2217
- before: rawSource.slice(0, start),
2218
- after: rawSource.slice(start + rawTailwindCss.length)
2219
- };
2220
- }
2221
- function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
2222
- const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
2223
- if (!match || match.index === void 0) return;
2224
- let afterStart = match.index + match[0].length;
2225
- while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
2226
- if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
2227
- afterStart += rawTailwindCss.length;
2228
- while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
2229
- }
2230
- return {
2231
- before: rawSource.slice(0, match.index),
2232
- after: rawSource.slice(afterStart)
2233
- };
2234
- }
2235
- function splitTailwindGeneratedCssByBanner(rawSource, start) {
2236
- const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
2237
- if (!match || match.index === void 0) return;
2238
- return {
2239
- before: rawSource.slice(0, match.index),
2240
- after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
2241
- };
2242
- }
2243
- function stripTailwindBanner(css) {
2244
- return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
2245
- }
2246
- function stripTailwindBanners(css) {
2247
- return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
2248
- }
2249
- function stripGeneratorPlaceholderMarkers(css) {
2250
- return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
2251
- }
2252
- function hasTailwindGeneratedCss(rawSource) {
2253
- return TAILWIND_V4_BANNER_RE.test(rawSource);
2254
- }
2255
- function hasTailwindGeneratedCssMarkers(rawSource) {
2256
- return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
2257
- }
2258
- //#endregion
2259
- //#region src/bundlers/shared/generator-css/directives/fallback.ts
2260
- const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
2261
- const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
2262
- const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
2263
- function parseImportRequest$1(params) {
2264
- return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
2265
- }
2266
- function parseConfigRequest$1(params) {
2267
- return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2268
- }
2269
- function isPackageJsonImportRequest$1(request) {
2270
- return typeof request === "string" && request.startsWith("#");
2271
- }
2272
- function isWeappTailwindcssImportRequest$1(request) {
2273
- return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
2274
- }
2275
- function isTailwindImportRequest$1(request) {
2276
- return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
2277
- }
2278
- function normalizeTailwindImportRequest$1(request, options = {}) {
2279
- if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2280
- return request;
2281
- }
2282
- function replaceImportRequest$1(params, request, replacement) {
2283
- const index = params.indexOf(request);
2284
- if (index === -1) return params;
2285
- return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
2286
- }
2287
- function normalizeTailwindDirectiveLine(line, options = {}) {
2288
- const trimmed = line.trimStart();
2289
- if (/^@(?:use|forward)\b/.test(trimmed)) {
2290
- const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
2291
- if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
2292
- const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
2293
- return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
2294
- }
2295
- return line;
2296
- }
2297
- if (!options.importFallback || !trimmed.startsWith("@import")) return line;
2298
- const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
2299
- if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
2300
- return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
2301
- }
2302
- function extractTailwindDirectiveLines(rawSource, options = {}) {
2303
- const directives = [];
2304
- const seenImports = /* @__PURE__ */ new Set();
2305
- for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
2306
- const trimmed = line.trim();
2307
- if (!trimmed || trimmed.startsWith("//")) continue;
2308
- const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
2309
- if (!directive) continue;
2310
- if (TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(directive)) continue;
2311
- const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
2312
- const normalizedTrimmed = normalized.trim();
2313
- if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
2314
- const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
2315
- if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$1(request)) continue;
2316
- if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
2317
- if (request && isTailwindImportRequest$1(request)) {
2318
- const key = normalizedTrimmed;
2319
- if (seenImports.has(key)) continue;
2320
- seenImports.add(key);
2321
- }
2322
- directives.push(normalized);
2323
- }
2324
- return directives;
2325
- }
2326
- function stripPreprocessorLineComment(line) {
2327
- let quote;
2328
- let escaped = false;
2329
- for (let index = 0; index < line.length; index++) {
2330
- const char = line[index];
2331
- if (escaped) {
2332
- escaped = false;
2333
- continue;
2334
- }
2335
- if (char === "\\") {
2336
- escaped = true;
2337
- continue;
2338
- }
2339
- if (quote) {
2340
- if (char === quote) quote = void 0;
2341
- continue;
2342
- }
2343
- if (char === "\"" || char === "'") {
2344
- quote = char;
2345
- continue;
2346
- }
2347
- if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
2348
- }
2349
- return line;
2350
- }
2351
- function countBlockBraceDelta(line) {
2352
- let quote;
2353
- let escaped = false;
2354
- let delta = 0;
2355
- for (let index = 0; index < line.length; index++) {
2356
- const char = line[index];
2357
- if (escaped) {
2358
- escaped = false;
2359
- continue;
2360
- }
2361
- if (char === "\\") {
2362
- escaped = true;
2363
- continue;
2364
- }
2365
- if (quote) {
2366
- if (char === quote) quote = void 0;
2367
- continue;
2368
- }
2369
- if (char === "\"" || char === "'") {
2370
- quote = char;
2371
- continue;
2372
- }
2373
- if (char === "{") delta++;
2374
- else if (char === "}") delta--;
2375
- }
2376
- return delta;
2377
- }
2378
- function extractTailwindFallbackBlocks(rawSource) {
2379
- const blocks = [];
2380
- let current;
2381
- let depth = 0;
2382
- for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
2383
- const line = stripPreprocessorLineComment(rawLine);
2384
- if (!line.trim()) continue;
2385
- if (!current) {
2386
- if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
2387
- current = [line];
2388
- depth = countBlockBraceDelta(line);
2389
- if (depth <= 0) {
2390
- blocks.push(current.join("\n"));
2391
- current = void 0;
2392
- depth = 0;
2393
- }
2394
- continue;
2395
- }
2396
- current.push(line);
2397
- depth += countBlockBraceDelta(line);
2398
- if (depth <= 0) {
2399
- blocks.push(current.join("\n"));
2400
- current = void 0;
2401
- depth = 0;
2402
- }
2403
- }
2404
- return blocks;
2405
- }
2406
- function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
2407
- const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
2408
- return directives.length > 0 ? directives.join("\n") : void 0;
2409
- }
2410
- function extractConfigRequestFromSource(rawSource) {
2411
- for (const line of rawSource.split(/\r?\n/)) {
2412
- const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
2413
- const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
2414
- if (request) return request;
2415
- }
2416
- }
2417
- //#endregion
2418
- //#region src/bundlers/shared/generator-css/directives.ts
2419
- const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
2420
- "config",
2421
- "custom-variant",
2422
- "layer",
2423
- "plugin",
2424
- "reference",
2425
- "source",
2426
- "tailwind",
2427
- "theme",
2428
- "utility",
2429
- "variant"
2430
- ]);
2431
- const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
2432
- "config",
2433
- "custom-variant",
2434
- "plugin",
2435
- "source",
2436
- "tailwind",
2437
- "theme",
2438
- "utility",
2439
- "variant"
2440
- ]);
2441
- const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
2442
- const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
2443
- ["tailwindcss/base", "base"],
2444
- ["tailwindcss/components", "components"],
2445
- ["tailwindcss/utilities", "utilities"]
2446
- ]);
2447
- function parseImportRequest(params) {
2448
- return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
2449
- }
2450
- function hasLocalCssImport(rawSource) {
2451
- let found = false;
2452
- try {
2453
- _weapp_tailwindcss_postcss.postcss.parse(rawSource).walkAtRules("import", (rule) => {
2454
- const request = parseImportRequest(rule.params);
2455
- if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
2456
- found = true;
2457
- return false;
2458
- }
2459
- });
2460
- } catch {}
2461
- return found;
2462
- }
2463
- function parseConfigRequest(params) {
2464
- return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2465
- }
2466
- function isPackageJsonImportRequest(request) {
2467
- return typeof request === "string" && request.startsWith("#");
2468
- }
2469
- function isWeappTailwindcssImportRequest(request) {
2470
- return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
2471
- }
2472
- function normalizeTailwindImportRequest(request, options = {}) {
2473
- if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2474
- return request;
2475
- }
2476
- function replaceImportRequest(params, request, replacement) {
2477
- const index = params.indexOf(request);
2478
- if (index === -1) return params;
2479
- return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
2480
- }
2481
- function normalizeTailwindImportAtRules(root, options = {}) {
2482
- if (!options.importFallback) return false;
2483
- let changed = false;
2484
- const seenCanonicalImports = /* @__PURE__ */ new Set();
2485
- root.walkAtRules("import", (node) => {
2486
- const request = parseImportRequest(node.params);
2487
- const normalizedRequest = normalizeTailwindImportRequest(request, options);
2488
- if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
2489
- const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
2490
- const normalizedKey = normalizedParams.trim();
2491
- if (seenCanonicalImports.has(normalizedKey)) {
2492
- node.remove();
2493
- changed = true;
2494
- return;
2495
- }
2496
- seenCanonicalImports.add(normalizedKey);
2497
- if (normalizedParams !== node.params) {
2498
- node.params = normalizedParams;
2499
- changed = true;
2500
- }
2501
- });
2502
- return changed;
2503
- }
2504
- function resolveConfigPath$1(base, configPath) {
2505
- if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
2506
- return node_path.default.resolve(base, configPath);
2507
- }
2508
- function normalizeTailwindConfigDirectives(rawSource, base) {
2509
- return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
2510
- if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
2511
- return `@config ${quote}${node_path.default.resolve(base, request).replace(/\\/g, "/")}${quote};`;
2512
- });
2513
- }
2514
- function hasPreprocessorOnlySyntax(rawSource) {
2515
- return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
2516
- }
2517
- function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
2518
- return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
2519
- }
2520
- function normalizeTailwindV3CssEntrySource(rawSource) {
2521
- try {
2522
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2523
- let changed = false;
2524
- root.walkAtRules("import", (node) => {
2525
- const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
2526
- if (!layer) return;
2527
- node.replaceWith(_weapp_tailwindcss_postcss.postcss.atRule({
2528
- name: "tailwind",
2529
- params: layer
2530
- }));
2531
- changed = true;
2532
- });
2533
- return changed ? root.toString() : rawSource;
2534
- } catch {
2535
- return rawSource;
2536
- }
2537
- }
2538
- function normalizeTailwindSourceDirectives(rawSource, options = {}) {
2539
- if (!options.importFallback) return rawSource;
2540
- try {
2541
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2542
- return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
2543
- } catch {
2544
- return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
2545
- }
2546
- }
2547
- function isTailwindImportRequest(request) {
2548
- return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
2549
- }
2550
- function isTailwindImportAtRule(node, options = {}) {
2551
- if (node.name === "tailwind") return true;
2552
- if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
2553
- return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
2554
- }
2555
- function isTailwindSourceDirective(node, options = {}) {
2556
- if (node.type !== "atrule") return false;
2557
- const atRule = node;
2558
- if (isTailwindImportAtRule(atRule, options)) return true;
2559
- if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
2560
- if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
2561
- return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
2562
- }
2563
- function hasGeneratedCssArtifacts(rawSource) {
2564
- return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
2565
- }
2566
- function isTailwindGenerationDirective(node, options = {}) {
2567
- if (node.type !== "atrule") return false;
2568
- const atRule = node;
2569
- const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
2570
- return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
2571
- }
2572
- function removeTailwindSourceDirectives(rawSource, options = {}) {
2573
- try {
2574
- const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
2575
- if (!source) return "";
2576
- const root = _weapp_tailwindcss_postcss.postcss.parse(source);
2577
- let removed = false;
2578
- root.walk((node) => {
2579
- if (isTailwindSourceDirective(node, options)) {
2580
- node.remove();
2581
- removed = true;
2582
- }
2583
- });
2584
- return removed ? root.toString() : source;
2585
- } catch {
2586
- return stripGeneratorPlaceholderMarkers(rawSource);
2587
- }
2588
- }
2589
- function hasTailwindSourceDirectives(rawSource, options = {}) {
2590
- try {
2591
- if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
2592
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2593
- let found = false;
2594
- const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
2595
- root.walk((node) => {
2596
- if (isTailwindGenerationDirective(node, {
2597
- ...options,
2598
- ignoreLayer
2599
- })) {
2600
- found = true;
2601
- return false;
2602
- }
2603
- });
2604
- return found;
2605
- } catch {
2606
- return extractTailwindDirectiveLines(rawSource, options).length > 0;
2607
- }
2608
- }
2609
- function hasTailwindRootDirectives(rawSource, options = {}) {
2610
- if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
2611
- try {
2612
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2613
- let found = false;
2614
- root.walkAtRules((node) => {
2615
- const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
2616
- if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
2617
- found = true;
2618
- return false;
2619
- }
2620
- });
2621
- return found;
2622
- } catch {
2623
- return extractTailwindDirectiveLines(rawSource, options).length > 0;
2624
- }
2625
- }
2626
- function hasTailwindApplyDirective(rawSource) {
2627
- if (!rawSource.includes("@apply")) return false;
2628
- try {
2629
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2630
- let found = false;
2631
- root.walkAtRules("apply", () => {
2632
- found = true;
2633
- return false;
2634
- });
2635
- return found;
2636
- } catch {
2637
- return false;
2638
- }
2639
- }
2640
- function resolveCssEntrySource(rawSource, base, options = {}) {
2641
- try {
2642
- const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
2643
- const normalizedImports = normalizeTailwindImportAtRules(root, options);
2644
- let found = false;
2645
- let config;
2646
- let configRequest;
2647
- let removedConfig = false;
2648
- const removeConfig = options.removeConfig ?? true;
2649
- const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
2650
- root.walk((node) => {
2651
- if (isTailwindGenerationDirective(node, {
2652
- ...options,
2653
- ignoreLayer
2654
- })) found = true;
2655
- if (node.type === "atrule" && node.name === "config") {
2656
- const configPath = parseConfigRequest(node.params);
2657
- if (configPath && !config) {
2658
- configRequest = configPath;
2659
- config = resolveConfigPath$1(base, configPath);
2660
- }
2661
- if (removeConfig) {
2662
- node.remove();
2663
- removedConfig = true;
2664
- }
2665
- }
2666
- });
2667
- if (!found) return;
2668
- if (hasPreprocessorOnlySyntax(rawSource)) {
2669
- const css = extractTailwindSourceForPostcssFallback(rawSource, {
2670
- ...options,
2671
- removeConfig
2672
- });
2673
- if (css) return {
2674
- css,
2675
- config,
2676
- configRequest,
2677
- base
2678
- };
2679
- }
2680
- return {
2681
- css: removedConfig || normalizedImports ? root.toString() : rawSource,
2682
- config,
2683
- configRequest,
2684
- base
2685
- };
2686
- } catch {
2687
- const css = extractTailwindSourceForPostcssFallback(rawSource, options);
2688
- const configRequest = extractConfigRequestFromSource(rawSource);
2689
- const config = configRequest ? resolveConfigPath$1(base, configRequest) : void 0;
2690
- return css ? {
2691
- css,
2692
- config,
2693
- configRequest,
2694
- base
2695
- } : void 0;
2696
- }
2697
- }
2698
- //#endregion
2699
- //#region src/tailwindcss/v4-engine/source.ts
2700
- const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2701
- function isCssEntryPoint(file) {
2702
- return typeof file === "string" && node_path.default.basename(file) === "index.css" && (0, node_fs.existsSync)(file);
2703
- }
2704
- function resolvePackageCssEntryPoint(specifier) {
2705
- try {
2706
- const resolved = require$2.resolve(specifier);
2707
- if (isCssEntryPoint(resolved)) return resolved;
2708
- } catch {}
2709
- const packageName = specifier.replace(/\/index\.css$/, "");
2710
- if (packageName !== "tailwindcss") return;
2711
- try {
2712
- const packageJson = require$2.resolve(`${packageName}/package.json`);
2713
- const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
2714
- if (isCssEntryPoint(cssEntry)) return cssEntry;
2715
- } catch {}
2716
- try {
2717
- let current = node_path.default.dirname(require$2.resolve("tailwindcss-patch"));
2718
- while (true) {
2719
- const cssEntry = node_path.default.resolve(current, "..", "tailwindcss", "index.css");
2720
- if (isCssEntryPoint(cssEntry)) return cssEntry;
2721
- const parent = node_path.default.dirname(current);
2722
- if (parent === current) break;
2723
- current = parent;
2724
- }
2725
- } catch {}
2726
- }
2727
- function isPostcssPluginImportTarget(value) {
2728
- if (!value) return false;
2729
- return value === "@tailwindcss/postcss" || value.includes("/postcss");
2730
- }
2731
- function uniqueDefined(values) {
2732
- return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
2733
- }
2734
- function getProjectRoot$1(patcher) {
2735
- return patcher.options?.projectRoot ?? node_process.default.cwd();
2736
- }
2737
- function resolveBase(value, fallback) {
2738
- return value === void 0 ? fallback : node_path.default.isAbsolute(value) ? node_path.default.resolve(value) : node_path.default.resolve(fallback, value);
2739
- }
2740
- function resolveConfigDir(config, projectRoot) {
2741
- if (!config) return;
2742
- const configPath = node_path.default.isAbsolute(config) ? config : node_path.default.resolve(projectRoot, config);
2743
- return node_path.default.dirname(configPath);
2744
- }
2745
- function isBarePackageSpecifier(specifier) {
2746
- return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
2747
- }
2748
- function isPackageJsonImportSpecifier(specifier) {
2749
- return typeof specifier === "string" && specifier.startsWith("#");
2750
- }
2751
- function parseCssImportSpecifier$1(params) {
2752
- const value = params.trim();
2753
- const quoted = /^(['"])(.*?)\1/.exec(value);
2754
- if (quoted) {
2755
- const specifier = quoted[2];
2756
- if (specifier === void 0) return;
2757
- return {
2758
- quote: quoted[1],
2759
- raw: quoted[0],
2760
- specifier
2761
- };
2762
- }
2763
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
2764
- if (!url) return;
2765
- const specifier = url[2] ?? url[3];
2766
- if (specifier === void 0) return;
2767
- return {
2768
- quote: url[1],
2769
- raw: url[0],
2770
- specifier
2771
- };
2772
- }
2773
- function quoteCssImportSpecifier(specifier, quote = "\"") {
2774
- return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
2775
- }
2776
- function createTailwindV4CssImportSpecifierSet(packageName) {
2777
- const specifiers = new Set(["tailwindcss"]);
2778
- if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
2779
- return specifiers;
2780
- }
2781
- function normalizeTailwindV4CssPackageImports(css, packageName) {
2782
- if (!css.includes("tailwindcss")) return css;
2783
- let root;
2784
- try {
2785
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
2786
- } catch {
2787
- return css;
2788
- }
2789
- const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
2790
- let changed = false;
2791
- root.walkAtRules((rule) => {
2792
- if (rule.name !== "import" && rule.name !== "reference") return;
2793
- const parsed = parseCssImportSpecifier$1(rule.params);
2794
- if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
2795
- const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
2796
- if (!cssEntryPoint) return;
2797
- rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
2798
- changed = true;
2799
- });
2800
- return changed ? root.toString() : css;
2801
- }
2802
- function normalizeTailwindV4CssSources(cssSources, packageName) {
2803
- if (!cssSources?.length) return cssSources;
2804
- let changed = false;
2805
- const normalizedCssSources = cssSources.map((cssSource) => {
2806
- if (typeof cssSource.css !== "string") return cssSource;
2807
- const css = normalizeTailwindV4CssPackageImports(cssSource.css, packageName);
2808
- if (css === cssSource.css) return cssSource;
2809
- changed = true;
2810
- return {
2811
- ...cssSource,
2812
- css
2813
- };
2814
- });
2815
- return changed ? normalizedCssSources : cssSources;
2816
- }
2817
- function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
2818
- if (!cssEntries?.length) return;
2819
- const remainingCssEntries = [];
2820
- const cssSources = [];
2821
- for (const cssEntry of cssEntries) {
2822
- const file = node_path.default.resolve(cssEntry);
2823
- if (!(0, node_fs.existsSync)(file)) {
2824
- remainingCssEntries.push(cssEntry);
2825
- continue;
2826
- }
2827
- const base = node_path.default.dirname(file);
2828
- const rawCss = (0, node_fs.readFileSync)(file, "utf8");
2829
- const entrySource = resolveCssEntrySource(rawCss, base, { removeConfig: false });
2830
- const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, entrySource?.config && (0, node_fs.existsSync)(entrySource.config) ? entrySource.config : entrySource?.configRequest && !node_path.default.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? node_path.default.resolve(base, entrySource.configRequest) : entrySource?.config), packageName);
2831
- cssSources.push({
2832
- file,
2833
- base,
2834
- css,
2835
- dependencies: [file]
2836
- });
2837
- }
2838
- return {
2839
- cssEntries: remainingCssEntries,
2840
- cssSources
2841
- };
2842
- }
2843
- function normalizeTailwindV4SourceOptions(options) {
2844
- if (!options) return options;
2845
- const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(options.css, options.packageName);
2846
- const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
2847
- const cssSources = normalizeTailwindV4CssSources(options.cssSources || entrySources?.cssSources ? [...options.cssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName);
2848
- const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
2849
- if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
2850
- return {
2851
- ...options,
2852
- ...css === void 0 ? {} : { css },
2853
- ...cssEntries === void 0 ? {} : { cssEntries },
2854
- ...cssSources === void 0 ? {} : { cssSources }
2855
- };
2856
- }
2857
- function resolveTailwindCssImportTarget(patcher) {
2858
- const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
2859
- if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
2860
- const packageName = patcher.packageInfo?.name;
2861
- if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
2862
- return "tailwindcss";
2863
- }
2864
- function readTailwindV4Options(patcher) {
2865
- return resolveTailwindcssOptions(patcher.options)?.v4 ?? patcher.options?.tailwind?.v4;
2866
- }
2867
- function isRawTailwindcssPatchOptions(options) {
2868
- return Boolean(options && "tailwindcss" in options);
2869
- }
2870
- function resolvePatchTailwindV4SourceOptions(patcher) {
2871
- if (patcher.options) {
2872
- const projectRoot = getProjectRoot$1(patcher);
2873
- const tailwindOptions = resolveTailwindcssOptions(patcher.options);
2874
- const tailwindV4Options = readTailwindV4Options(patcher);
2875
- const cwd = resolveBase(tailwindOptions?.cwd, projectRoot);
2876
- const configuredBase = tailwindV4Options?.configuredBase ?? (isRawTailwindcssPatchOptions(patcher.options) ? tailwindV4Options?.base : void 0);
2877
- const baseFallbacks = uniqueDefined([
2878
- configuredBase,
2879
- cwd,
2880
- projectRoot,
2881
- resolveConfigDir(tailwindOptions?.config, projectRoot)
2882
- ]);
2883
- return {
2884
- projectRoot,
2885
- cwd,
2886
- ...configuredBase === void 0 ? {} : { base: configuredBase },
2887
- baseFallbacks,
2888
- ...tailwindV4Options?.css === void 0 ? {} : { css: tailwindV4Options.css },
2889
- ...tailwindV4Options?.cssSources === void 0 ? {} : { cssSources: tailwindV4Options.cssSources },
2890
- ...tailwindV4Options?.cssEntries === void 0 ? {} : { cssEntries: tailwindV4Options.cssEntries },
2891
- packageName: resolveTailwindCssImportTarget(patcher)
2892
- };
2893
- }
2894
- return {
2895
- projectRoot: getProjectRoot$1(patcher),
2896
- packageName: resolveTailwindCssImportTarget(patcher)
2897
- };
2898
- }
2899
- function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
2900
- const tailwindV4Options = readTailwindV4Options(patcher);
2901
- return omitUndefined({
2902
- ...resolvePatchTailwindV4SourceOptions(patcher),
2903
- sources: tailwindV4Options?.sources
2904
- });
2905
- }
2906
- function resolveTailwindV4Source(options) {
2907
- return (0, tailwindcss_patch.resolveTailwindV4Source)(normalizeTailwindV4SourceOptions(options));
2908
- }
2909
- async function resolveTailwindV4SourceFromPatcher(patcher) {
2910
- return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromPatcher(patcher));
2911
- }
2912
- //#endregion
2913
- //#region src/bundlers/vite/static-config-content.ts
2914
- function skipWhitespaceAndComments(source, start) {
2915
- let index = start;
2916
- while (index < source.length) {
2917
- const char = source[index];
2918
- if (/\s/.test(char ?? "")) {
2919
- index += 1;
2920
- continue;
2921
- }
2922
- if (char === "/" && source[index + 1] === "/") {
2923
- index += 2;
2924
- while (index < source.length && source[index] !== "\n") index += 1;
2925
- continue;
2926
- }
2927
- if (char === "/" && source[index + 1] === "*") {
2928
- index += 2;
2929
- while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
2930
- index = Math.min(index + 2, source.length);
2931
- continue;
2932
- }
2933
- break;
2934
- }
2935
- return index;
2936
- }
2937
- function readQuotedString(source, start) {
2938
- const quote = source[start];
2939
- if (quote !== "\"" && quote !== "'") return;
2940
- let value = "";
2941
- for (let index = start + 1; index < source.length; index++) {
2942
- const char = source[index];
2943
- if (char === "\\") {
2944
- const next = source[index + 1];
2945
- if (next === void 0) return;
2946
- value += next;
2947
- index += 1;
2948
- continue;
2949
- }
2950
- if (char === quote) return {
2951
- end: index + 1,
2952
- value
2953
- };
2954
- value += char;
2955
- }
2956
- }
2957
- function readIdentifier(source, start) {
2958
- return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
2959
- }
2960
- function findMatchingBracket(source, start, open, close) {
2961
- let depth = 0;
2962
- let quote;
2963
- for (let index = start; index < source.length; index++) {
2964
- const char = source[index];
2965
- if (char === "\\") {
2966
- index += 1;
2967
- continue;
2968
- }
2969
- if (quote) {
2970
- if (char === quote) quote = void 0;
2971
- continue;
2972
- }
2973
- if (char === "\"" || char === "'") {
2974
- quote = char;
2975
- continue;
2976
- }
2977
- if (char === "`") return;
2978
- if (char === open) {
2979
- depth += 1;
2980
- continue;
2981
- }
2982
- if (char === close) {
2983
- depth -= 1;
2984
- if (depth === 0) return index;
2985
- }
2986
- }
2987
- }
2988
- function findContentPropertyValue(source) {
2989
- let index = 0;
2990
- while (index < source.length) {
2991
- const nextIndex = source.indexOf("content", index);
2992
- if (nextIndex === -1) return;
2993
- const previous = source[nextIndex - 1];
2994
- const next = source[nextIndex + 7];
2995
- if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
2996
- index = nextIndex + 7;
2997
- continue;
2998
- }
2999
- let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
3000
- if (source[colonIndex] !== ":") {
3001
- index = nextIndex + 7;
3002
- continue;
3003
- }
3004
- colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
3005
- return { start: colonIndex };
3006
- }
3007
- }
3008
- function parseStaticContentArray(source, start) {
3009
- if (source[start] !== "[") return;
3010
- const value = [];
3011
- let index = skipWhitespaceAndComments(source, start + 1);
3012
- while (index < source.length) {
3013
- if (source[index] === "]") return {
3014
- end: index + 1,
3015
- value
3016
- };
3017
- const parsed = parseStaticContentValue(source, index);
3018
- if (!parsed) return;
3019
- value.push(parsed.value);
3020
- index = skipWhitespaceAndComments(source, parsed.end);
3021
- if (source[index] === ",") {
3022
- index = skipWhitespaceAndComments(source, index + 1);
3023
- continue;
3024
- }
3025
- if (source[index] === "]") continue;
3026
- return;
3027
- }
3028
- }
3029
- function parseStaticContentObject(source, start) {
3030
- if (source[start] !== "{") return;
3031
- const end = findMatchingBracket(source, start, "{", "}");
3032
- if (end === void 0) return;
3033
- let index = skipWhitespaceAndComments(source, start + 1);
3034
- let files;
3035
- while (index < end) {
3036
- let key;
3037
- const quotedKey = readQuotedString(source, index);
3038
- if (quotedKey) {
3039
- key = quotedKey.value;
3040
- index = quotedKey.end;
3041
- } else {
3042
- key = readIdentifier(source, index);
3043
- if (!key) return;
3044
- index += key.length;
3045
- }
3046
- index = skipWhitespaceAndComments(source, index);
3047
- if (source[index] !== ":") return;
3048
- index = skipWhitespaceAndComments(source, index + 1);
3049
- const parsedValue = parseStaticContentValue(source, index);
3050
- if (!parsedValue) return;
3051
- if (key === "files") files = parsedValue.value;
3052
- index = skipWhitespaceAndComments(source, parsedValue.end);
3053
- if (source[index] === ",") {
3054
- index = skipWhitespaceAndComments(source, index + 1);
3055
- continue;
3056
- }
3057
- if (index < end) return;
3058
- }
3059
- return files === void 0 ? void 0 : {
3060
- end: end + 1,
3061
- value: { files }
3062
- };
3063
- }
3064
- function parseStaticContentValue(source, start) {
3065
- const index = skipWhitespaceAndComments(source, start);
3066
- const quoted = readQuotedString(source, index);
3067
- if (quoted) return quoted;
3068
- if (source[index] === "[") return parseStaticContentArray(source, index);
3069
- if (source[index] === "{") return parseStaticContentObject(source, index);
3070
- }
3071
- function readStaticConfigContent(configPath) {
3072
- let source;
3073
- try {
3074
- source = (0, node_fs.readFileSync)(configPath, "utf8");
3075
- } catch {
3076
- return;
3077
- }
3078
- const contentProperty = findContentPropertyValue(source);
3079
- if (!contentProperty) return;
3080
- return parseStaticContentValue(source, contentProperty.start)?.value;
3081
- }
3082
- //#endregion
3083
- //#region src/bundlers/vite/source-scan/dependencies.ts
3084
- function addSourceScanDependency(dependencies, file) {
3085
- if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
3086
- }
3087
- function addSourceScanDependencies(dependencies, files) {
3088
- for (const file of files ?? []) addSourceScanDependency(dependencies, file);
3089
- }
3090
- //#endregion
3091
- //#region src/bundlers/vite/source-scan/css-entries.ts
3092
- const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
3093
- const VITE_TAILWIND_CSS_ENTRY_PATTERN = "**/*.{css,less,sass,scss,styl,stylus,pcss,postcss}";
3094
- const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
3095
- const tailwindConfigCssEntriesCache = /* @__PURE__ */ new Map();
3096
- function parseImportSourceParam(params) {
3097
- const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
3098
- if (!match) return;
3099
- return {
3100
- none: match[1] === "none",
3101
- sourcePath: match[3]
3102
- };
3103
- }
3104
- function parseCssImportSpecifier(params) {
3105
- const value = params.trim();
3106
- const quoted = /^(['"])(.*?)\1/.exec(value);
3107
- if (quoted) return quoted[2];
3108
- const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
3109
- return url?.[2] ?? url?.[3];
3110
- }
3111
- function isTailwindCssImport(params) {
3112
- const specifier = parseCssImportSpecifier(params);
3113
- return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
3114
- }
3115
- function resolveSourceBase(base, sourcePath) {
3116
- return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
3117
- }
3118
- function resolveConfigPath(base, configPath) {
3119
- if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
3120
- return node_path.default.resolve(base, configPath);
3121
- }
3122
- function createCssEntriesCacheKey(css, base, dependencies) {
3123
- return JSON.stringify({
3124
- base: node_path.default.resolve(base),
3125
- css,
3126
- dependencies
3127
- });
3128
- }
3129
- function createDependencyExcludeEntries(files) {
3130
- return [...files].map((file) => ({
3131
- base: node_path.default.dirname(file),
3132
- negated: true,
3133
- pattern: node_path.default.basename(file)
3134
- }));
3135
- }
3136
- async function statConfigDependency(file) {
3137
- try {
3138
- const stats = await (0, node_fs_promises.stat)(file);
3139
- return {
3140
- file,
3141
- mtimeMs: stats.mtimeMs,
3142
- size: stats.size
3143
- };
3144
- } catch {
3145
- return {
3146
- file,
3147
- mtimeMs: -1,
3148
- size: -1
3149
- };
3150
- }
3151
- }
3152
- async function collectConfigDependencySignatures(root, base) {
3153
- const configPaths = /* @__PURE__ */ new Set();
3154
- root.walkAtRules("config", (rule) => {
3155
- const configPath = parseConfigParam$1(rule.params);
3156
- if (configPath) configPaths.add(resolveConfigPath(base, configPath));
3157
- });
3158
- return Promise.all([...configPaths].sort().map(statConfigDependency));
3159
- }
3160
- function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
3161
- const merged = {
3162
- included: /* @__PURE__ */ new Set(),
3163
- excluded: /* @__PURE__ */ new Set()
3164
- };
3165
- for (const inlineCandidates of allInlineCandidates) {
3166
- if (!inlineCandidates) continue;
3167
- for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
3168
- for (const candidate of inlineCandidates.excluded) {
3169
- merged.excluded.add(candidate);
3170
- merged.included.delete(candidate);
3171
- }
3172
- }
3173
- return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
3174
- }
3175
- async function resolveConfigContentEntries(root, base) {
3176
- const configPaths = /* @__PURE__ */ new Set();
3177
- root.walkAtRules("config", (rule) => {
3178
- const configPath = parseConfigParam$1(rule.params);
3179
- if (configPath) configPaths.add(resolveConfigPath(base, configPath));
3180
- });
3181
- const entries = [];
3182
- for (const configPath of configPaths) {
3183
- const staticContent = readStaticConfigContent(configPath);
3184
- if (staticContent !== void 0) {
3185
- entries.push(...normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
3186
- continue;
3187
- }
3188
- try {
3189
- const loaded = await (0, tailwindcss_config.loadConfig)({
3190
- config: configPath,
3191
- cwd: node_path.default.dirname(configPath)
3192
- });
3193
- entries.push(...normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
3194
- } catch {}
3195
- }
3196
- return {
3197
- dependencies: [...configPaths],
3198
- entries
3199
- };
3200
- }
3201
- async function resolveTailwindV4EntriesFromCss(css, base) {
3202
- let root;
3203
- try {
3204
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
3205
- } catch {
3206
- return;
3207
- }
3208
- let importSourceBase;
3209
- let hasSourceNone = false;
3210
- let hasTailwindCssImport = false;
3211
- const [sourceEntries, configEntries] = await Promise.all([resolveCssSourceEntries(root, base, VITE_SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
3212
- const entries = [...configEntries.entries, ...sourceEntries];
3213
- const hasPositiveEntries = entries.some((entry) => !entry.negated);
3214
- const inlineCandidates = collectCssInlineSourceCandidates(root);
3215
- root.walkAtRules("import", (rule) => {
3216
- if (!isTailwindCssImport(rule.params)) return;
3217
- hasTailwindCssImport = true;
3218
- const sourceParam = parseImportSourceParam(rule.params);
3219
- if (sourceParam?.none) hasSourceNone = true;
3220
- if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
3221
- });
3222
- if (importSourceBase) return {
3223
- entries: [{
3224
- base: importSourceBase,
3225
- negated: false,
3226
- pattern: VITE_SOURCE_CANDIDATE_PATTERN
3227
- }, ...entries],
3228
- explicit: true,
3229
- inlineCandidates,
3230
- dependencies: configEntries.dependencies
3231
- };
3232
- if (hasSourceNone) return {
3233
- entries,
3234
- explicit: true,
3235
- inlineCandidates,
3236
- dependencies: configEntries.dependencies
3237
- };
3238
- if (hasPositiveEntries) return {
3239
- entries,
3240
- explicit: true,
3241
- inlineCandidates,
3242
- dependencies: configEntries.dependencies
3243
- };
3244
- if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
3245
- entries: [],
3246
- explicit: true,
3247
- inlineCandidates,
3248
- dependencies: configEntries.dependencies
3249
- };
3250
- return hasTailwindCssImport ? {
3251
- entries,
3252
- explicit: false,
3253
- inlineCandidates,
3254
- dependencies: configEntries.dependencies
3255
- } : void 0;
3256
- }
3257
- async function resolveViteTailwindV4CssDependencies(css, base) {
3258
- return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
3259
- }
3260
- function collectExistingCssEntries(options) {
3261
- return [
3262
- ...options.cssEntries ?? [],
3263
- ...options.tailwindcss?.v4?.cssEntries ?? [],
3264
- ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? []
3265
- ].filter((item) => typeof item === "string" && item.length > 0).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
3266
- }
3267
- async function resolveTailwindV3CssEntryScan(options, patcher) {
3268
- const cssEntries = collectExistingCssEntries(options);
3269
- const entries = [];
3270
- const dependencies = /* @__PURE__ */ new Set();
3271
- if (cssEntries.length === 0) return {
3272
- entries,
3273
- dependencies
3274
- };
3275
- const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(patcher);
3276
- await Promise.all(cssEntries.map(async (cssEntry) => {
3277
- addSourceScanDependency(dependencies, cssEntry);
3278
- let css;
3279
- try {
3280
- css = (0, node_fs.readFileSync)(cssEntry, "utf8");
3281
- } catch {
3282
- return;
3283
- }
3284
- const cssConfigEntries = await resolveTailwindConfigEntriesFromCssCached(css, node_path.default.dirname(cssEntry));
3285
- if (cssConfigEntries) {
3286
- addSourceScanDependencies(dependencies, cssConfigEntries.dependencies);
3287
- entries.push(...cssConfigEntries.entries);
3288
- return;
3289
- }
3290
- const source = await resolveTailwindV3Source({
3291
- ...sourceOptions,
3292
- base: node_path.default.dirname(cssEntry),
3293
- css
3294
- });
3295
- addSourceScanDependency(dependencies, source.config);
3296
- addSourceScanDependencies(dependencies, source.dependencies);
3297
- entries.push(...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }));
3298
- }));
3299
- return {
3300
- entries,
3301
- dependencies
3302
- };
3303
- }
3304
- async function pathExistsAsFile(file) {
3305
- try {
3306
- return (await (0, node_fs_promises.stat)(file)).isFile();
3307
- } catch {
3308
- return false;
3309
- }
3310
- }
3311
- async function resolveTailwindV4EntriesFromCssCached(css, base) {
3312
- let root;
3313
- try {
3314
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
3315
- } catch {
3316
- return;
3317
- }
3318
- const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
3319
- const cached = tailwindV4CssEntriesCache.get(cacheKey);
3320
- if (cached) return cached;
3321
- const task = resolveTailwindV4EntriesFromCss(css, base);
3322
- tailwindV4CssEntriesCache.set(cacheKey, task);
3323
- return task;
3324
- }
3325
- async function resolveTailwindConfigEntriesFromCssCached(css, base) {
3326
- let root;
3327
- try {
3328
- root = _weapp_tailwindcss_postcss.postcss.parse(css);
3329
- } catch {
3330
- return;
3331
- }
3332
- const dependencies = await collectConfigDependencySignatures(root, base);
3333
- if (dependencies.length === 0) return;
3334
- const cacheKey = createCssEntriesCacheKey(css, base, dependencies);
3335
- const cached = tailwindConfigCssEntriesCache.get(cacheKey);
3336
- if (cached) return cached;
3337
- const task = resolveConfigContentEntries(root, base).then((resolved) => {
3338
- return {
3339
- entries: [...resolved.entries, ...createDependencyExcludeEntries(resolved.dependencies)],
3340
- explicit: true,
3341
- inlineCandidates: {
3342
- excluded: /* @__PURE__ */ new Set(),
3343
- included: /* @__PURE__ */ new Set()
3344
- },
3345
- dependencies: resolved.dependencies
3346
- };
3347
- });
3348
- tailwindConfigCssEntriesCache.set(cacheKey, task);
3349
- return task;
3350
- }
3351
- async function discoverTailwindV4CssEntries(root, outDir) {
3352
- const resolvedRoot = node_path.default.resolve(root);
3353
- const ignore = ["**/node_modules/**", "**/.git/**"];
3354
- const resolvedOutDir = outDir ? node_path.default.resolve(resolvedRoot, outDir) : void 0;
3355
- if (resolvedOutDir) {
3356
- const relativeOutDir = node_path.default.relative(resolvedRoot, resolvedOutDir);
3357
- if (relativeOutDir && !relativeOutDir.startsWith("..") && !node_path.default.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(node_path.default.sep).join("/")}/**`);
3358
- }
3359
- const candidates = await (0, fast_glob.default)(VITE_TAILWIND_CSS_ENTRY_PATTERN, {
3360
- absolute: true,
3361
- cwd: resolvedRoot,
3362
- ignore,
3363
- onlyFiles: true,
3364
- unique: true
3365
- });
3366
- const entries = [];
3367
- for (const file of candidates) {
3368
- if (!await pathExistsAsFile(file)) continue;
3369
- try {
3370
- const css = (0, node_fs.readFileSync)(file, "utf8");
3371
- if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
3372
- if (await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(file))) entries.push(file);
3373
- }
3374
- } catch {}
3375
- }
3376
- return entries;
3377
- }
3378
- function collectConfiguredCssSources(options) {
3379
- return [...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? []];
3380
- }
3381
- //#endregion
3382
- //#region src/bundlers/vite/source-scan.ts
3383
- function createResolvedViteSourceScan(input, dependencies) {
3384
- return {
3385
- ...input,
3386
- ...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
3387
- };
3388
- }
3389
- function createMergedCssEntrySourceScanEntries(entries, options) {
3390
- if (options.sourceCount <= 1) return entries;
3391
- const positiveEntries = entries.filter((entry) => !entry.negated);
3392
- return positiveEntries.length > 0 ? positiveEntries : entries;
3393
- }
3394
- function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
3395
- return {
3396
- entries: explicit ? entries : entries.length > 0 ? entries : void 0,
3397
- explicit,
3398
- inlineCandidates
3399
- };
3400
- }
3401
- async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
3402
- if (patcher.majorVersion === 3) {
3403
- const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
3404
- const contentEntries = [...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }), ...cssEntryScan.entries];
3405
- const dependencies = /* @__PURE__ */ new Set();
3406
- addSourceScanDependency(dependencies, source.config);
3407
- for (const dependency of cssEntryScan.dependencies) dependencies.add(dependency);
3408
- return contentEntries.length > 0 ? createResolvedViteSourceScan({ entries: contentEntries }, dependencies) : void 0;
3409
- }
3410
- if (patcher.majorVersion === 4) {
3411
- const sourceOptions = resolveTailwindV4SourceOptionsFromPatcher(patcher);
3412
- const cssEntries = collectExistingCssEntries(options);
3413
- if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
3414
- const scanRoot = scanOptions.root;
3415
- const sourceProjectRoot = sourceOptions.projectRoot;
3416
- if (scanRoot && sourceProjectRoot && node_path.default.resolve(scanRoot) === node_path.default.resolve(sourceProjectRoot)) {
3417
- const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
3418
- cssEntries.push(...discoveredCssEntries);
3419
- }
3420
- }
3421
- const entries = [];
3422
- const cssInlineCandidates = [];
3423
- const dependencies = /* @__PURE__ */ new Set();
3424
- let explicit = false;
3425
- let readableCssEntryCount = 0;
3426
- for (const cssEntry of cssEntries) {
3427
- addSourceScanDependency(dependencies, cssEntry);
3428
- let css;
3429
- try {
3430
- css = (0, node_fs.readFileSync)(cssEntry, "utf8");
3431
- } catch {
3432
- continue;
3433
- }
3434
- readableCssEntryCount++;
3435
- const resolved = await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
3436
- if (resolved) {
3437
- entries.push(...resolved.entries);
3438
- cssInlineCandidates.push(resolved.inlineCandidates);
3439
- addSourceScanDependencies(dependencies, resolved.dependencies);
3440
- explicit || (explicit = resolved.explicit);
3441
- }
3442
- }
3443
- const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
3444
- const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
3445
- if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
3446
- entries: explicit ? scanEntries : scanEntries.length > 0 ? scanEntries : void 0,
3447
- explicit,
3448
- inlineCandidates
3449
- }, dependencies);
3450
- if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
3451
- const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
3452
- return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set(resolved.dependencies)) : void 0;
3453
- }
3454
- const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
3455
- const configuredCssSources = collectConfiguredCssSources(options);
3456
- for (const cssSource of [...configuredCssSources, ...sourceOptions.cssSources ?? []]) {
3457
- if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
3458
- addSourceScanDependency(dependencies, cssSource.file);
3459
- addSourceScanDependencies(dependencies, cssSource.dependencies);
3460
- const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
3461
- if (resolved) {
3462
- entries.push(...resolved.entries);
3463
- cssInlineCandidates.push(resolved.inlineCandidates);
3464
- addSourceScanDependencies(dependencies, resolved.dependencies);
3465
- explicit || (explicit = resolved.explicit);
3466
- }
3467
- }
3468
- const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
3469
- const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length });
3470
- if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
3471
- entries: explicit ? cssSourceScanEntries : cssSourceScanEntries.length > 0 ? cssSourceScanEntries : void 0,
3472
- explicit,
3473
- inlineCandidates: cssSourceInlineCandidates
3474
- }, dependencies);
3475
- const source = await resolveTailwindV4SourceFromPatcher(patcher);
3476
- addSourceScanDependency(dependencies, source.file);
3477
- addSourceScanDependencies(dependencies, source.dependencies);
3478
- const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
3479
- return resolved ? createResolvedViteSourceScan(createResolvedV4CssScanInput(resolved.entries.length > 0 ? resolved.entries : [], resolved.inlineCandidates, resolved.entries.length > 0 ? resolved.explicit : false), new Set([...dependencies, ...resolved.dependencies])) : void 0;
3480
- }
3481
- }
3482
- function createViteSourceScanMatcher(entries) {
3483
- if (entries?.length === 0) return;
3484
- return createTailwindSourceEntryMatcher(entries);
3485
- }
3486
- //#endregion
3487
- //#region src/tailwindcss/runtime/cache.ts
3488
- const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
3489
- const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
3490
- const runtimeTrackedSourceFilesCache = /* @__PURE__ */ new Map();
3491
- let runtimeFileSignatureCacheClearTimer;
3492
- const runtimeSignaturePatchersSymbol = Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
3493
- function getCacheEntry(twPatcher) {
3494
- let entry = runtimeClassSetCache.get(twPatcher);
3495
- if (!entry) {
3496
- entry = {};
3497
- runtimeClassSetCache.set(twPatcher, entry);
3498
- }
3499
- return entry;
3500
- }
3501
- function scheduleRuntimeConfigSignatureCacheClear() {
3502
- if (runtimeFileSignatureCacheClearTimer) return;
3503
- runtimeFileSignatureCacheClearTimer = setTimeout(() => {
3504
- runtimeFileSignatureCache.clear();
3505
- runtimeTrackedSourceFilesCache.clear();
3506
- runtimeFileSignatureCacheClearTimer = void 0;
3507
- }, 0);
3508
- runtimeFileSignatureCacheClearTimer.unref?.();
3509
- }
3510
- function getFileSignature(filePath) {
3511
- const cached = runtimeFileSignatureCache.get(filePath);
3512
- if (cached !== void 0) return cached;
3513
- let signature;
3514
- try {
3515
- const stats = (0, node_fs.statSync)(filePath);
3516
- signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
3517
- } catch {
3518
- signature = `${filePath}:missing`;
3519
- }
3520
- runtimeFileSignatureCache.set(filePath, signature);
3521
- scheduleRuntimeConfigSignatureCacheClear();
3522
- return signature;
3523
- }
3524
- function getTailwindTrackedFiles(twPatcher) {
3525
- const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
3526
- const tracked = /* @__PURE__ */ new Set();
3527
- const configPath = tailwindOptions?.config;
3528
- if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
3529
- for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
3530
- for (const source of tailwindOptions?.v4?.cssSources ?? []) {
3531
- if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
3532
- for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
3533
- }
3534
- return tracked;
3535
- }
3536
- function normalizeTrackedSourceSignature(cssEntries, cssSources) {
3537
- return normalizeSignatureValue({
3538
- cssEntries: cssEntries?.map((entry) => {
3539
- if (!(0, node_fs.existsSync)(entry)) return `${entry}:missing`;
3540
- return getFileSignature(entry);
3541
- }),
3542
- cssSources
3543
- });
3544
- }
3545
- async function collectTailwindV4TrackedSourceFiles(twPatcher) {
3546
- const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
3547
- const signature = normalizeTrackedSourceSignature(tailwindOptions?.v4?.cssEntries, tailwindOptions?.v4?.cssSources);
3548
- const cached = runtimeTrackedSourceFilesCache.get(signature);
3549
- if (cached) return cached;
3550
- const files = /* @__PURE__ */ new Set();
3551
- for (const cssEntry of tailwindOptions?.v4?.cssEntries ?? []) {
3552
- if (!(0, node_fs.existsSync)(cssEntry)) continue;
3553
- const resolved = await resolveTailwindV4EntriesFromCssCached((0, node_fs.readFileSync)(cssEntry, "utf8"), node_path.default.dirname(cssEntry));
3554
- const expanded = resolved?.entries?.length ? await expandTailwindSourceEntries(resolved.entries) : [];
3555
- for (const file of expanded) files.add(file);
3556
- }
3557
- for (const cssSource of tailwindOptions?.v4?.cssSources ?? []) {
3558
- if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
3559
- const base = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.dirname(cssSource.file) : tailwindOptions?.v4?.base ?? tailwindOptions?.cwd ?? twPatcher.options?.projectRoot ?? node_process.default.cwd();
3560
- const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, base);
3561
- const expanded = resolved?.entries?.length ? await expandTailwindSourceEntries(resolved.entries) : [];
3562
- for (const file of expanded) files.add(file);
3563
- }
3564
- const result = [...files].sort((a, b) => a.localeCompare(b));
3565
- runtimeTrackedSourceFilesCache.set(signature, result);
3566
- return result;
3567
- }
3568
- function normalizeSignatureValue(value) {
3569
- if (value == null) return "null";
3570
- if (typeof value === "string") return value;
3571
- if (typeof value === "number" || typeof value === "boolean") return String(value);
3572
- if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
3573
- if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
3574
- return String(value);
3575
- }
3576
- function readOptionalProperty(value, key) {
3577
- if (typeof value !== "object" || value === null || !(key in value)) return;
3578
- return value[key];
3579
- }
3580
- function getTailwindOptionsSignature(twPatcher) {
3581
- const options = twPatcher.options;
3582
- const tailwindOptions = resolveTailwindcssOptions(options);
3583
- return normalizeSignatureValue({
3584
- projectRoot: options?.projectRoot,
3585
- packageName: tailwindOptions?.packageName,
3586
- versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
3587
- cwd: tailwindOptions?.cwd,
3588
- config: tailwindOptions?.config,
3589
- v2: tailwindOptions?.v2,
3590
- v3: tailwindOptions?.v3,
3591
- v4: {
3592
- base: tailwindOptions?.v4?.base,
3593
- configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
3594
- css: tailwindOptions?.v4?.css,
3595
- cssEntries: tailwindOptions?.v4?.cssEntries,
3596
- cssSources: tailwindOptions?.v4?.cssSources,
3597
- hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
3598
- sources: tailwindOptions?.v4?.sources
3599
- }
3600
- });
3601
- }
3602
- function getRuntimeTargetSignature(twPatcher) {
3603
- const packageInfo = twPatcher.packageInfo;
3604
- return [
3605
- packageInfo?.name ?? "missing",
3606
- packageInfo?.rootPath ?? "missing",
3607
- packageInfo?.version ?? "unknown",
3608
- twPatcher.majorVersion ?? "unknown",
3609
- getTailwindOptionsSignature(twPatcher)
3610
- ].join(":");
3611
- }
3612
- function getNestedPatchers$1(twPatcher) {
3613
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
3614
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
3615
- }
3616
- function getOwnRuntimeClassSetSignature(twPatcher) {
3617
- const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
3618
- return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|runtime:${getRuntimeTargetSignature(twPatcher)}`;
3619
- }
3620
- function invalidateRuntimeClassSet(twPatcher) {
3621
- if (!twPatcher) return;
3622
- const nestedPatchers = getNestedPatchers$1(twPatcher);
3623
- if (nestedPatchers) for (const patcher of nestedPatchers) invalidateRuntimeClassSet(patcher);
3624
- for (const trackedFile of getTailwindTrackedFiles(twPatcher)) runtimeFileSignatureCache.delete(trackedFile);
3625
- runtimeTrackedSourceFilesCache.clear();
3626
- runtimeClassSetCache.delete(twPatcher);
3627
- }
3628
- function getRuntimeClassSetCacheEntry(twPatcher) {
3629
- return getCacheEntry(twPatcher);
3630
- }
3631
- function getRuntimeClassSetSignature(twPatcher) {
3632
- const nestedPatchers = getNestedPatchers$1(twPatcher);
3633
- if (nestedPatchers) return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
3634
- return getOwnRuntimeClassSetSignature(twPatcher);
3635
- }
3636
- async function getRuntimeClassSetSignatureWithSources(twPatcher) {
3637
- const baseSignature = getRuntimeClassSetSignature(twPatcher);
3638
- if (twPatcher.majorVersion !== 4) return baseSignature;
3639
- const trackedSourceFiles = await collectTailwindV4TrackedSourceFiles(twPatcher);
3640
- if (trackedSourceFiles.length === 0) return baseSignature;
3641
- return [baseSignature, trackedSourceFiles.map(getFileSignature).join("|")].join("|sources:");
3642
- }
3643
- //#endregion
3644
- //#region src/tailwindcss/runtime-patch.ts
3645
- const debug$1 = createDebug("[tailwindcss:runtime-patch] ");
3646
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
3647
- const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
3648
- function getNestedPatchers(twPatcher) {
3649
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
3650
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
3651
- }
3652
- function shouldApplyRuntimePatch(twPatcher) {
3653
- return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
3654
- }
3655
- function clearTailwindcssRequireCache(twPatcher) {
3656
- const rootPath = twPatcher.packageInfo?.rootPath;
3657
- if (!rootPath) return;
3658
- const normalizedRoot = node_path.default.resolve(rootPath);
3659
- let count = 0;
3660
- for (const id of Object.keys(require$1.cache)) {
3661
- const normalizedId = node_path.default.resolve(id);
3662
- if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${node_path.default.sep}`)) {
3663
- delete require$1.cache[id];
3664
- count += 1;
3665
- }
3666
- }
3667
- if (count > 0) debug$1("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
3668
- }
3669
- async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
3670
- const nestedPatchers = getNestedPatchers(twPatcher);
3671
- if (nestedPatchers) {
3672
- await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
3673
- return;
3674
- }
3675
- if (!shouldApplyRuntimePatch(twPatcher)) return;
3676
- const cached = runtimePatchPromiseCache.get(twPatcher);
3677
- if (cached) {
3678
- await cached;
3679
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
3680
- return;
3681
- }
3682
- const task = Promise.resolve().then(async () => {
3683
- debug$1("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
3684
- await twPatcher.patch?.();
3685
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
3686
- }).catch((error) => {
3687
- runtimePatchPromiseCache.delete(twPatcher);
3688
- throw error;
3689
- });
3690
- runtimePatchPromiseCache.set(twPatcher, task);
3691
- return task;
3692
- }
3693
- //#endregion
3694
- //#region src/tailwindcss/v3-engine/generator/runtime-ready.ts
3695
- const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
3696
- function createRuntimeReadyCacheKey(source, rootPath) {
3697
- return [
3698
- source.packageName,
3699
- source.postcssPlugin,
3700
- rootPath ?? "missing",
3701
- source.config ?? "config:missing",
3702
- source.cwd
3703
- ].join("\0");
3704
- }
3705
- function createRuntimeReadyPromise(source) {
3706
- const patcher = createTailwindcssPatcher({
3707
- basedir: source.cwd,
3708
- supportCustomLengthUnitsPatch: true,
3709
- tailwindcss: {
3710
- ...source.config === void 0 ? {} : { config: source.config },
3711
- cwd: source.cwd,
3712
- packageName: source.packageName,
3713
- postcssPlugin: source.postcssPlugin,
3714
- version: 3
3715
- }
3716
- });
3717
- const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
3718
- const cached = runtimeReadyPromiseCache.get(cacheKey);
3719
- if (cached) return cached;
3720
- const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
3721
- runtimeReadyPromiseCache.delete(cacheKey);
3722
- throw error;
3723
- });
3724
- runtimeReadyPromiseCache.set(cacheKey, task);
3725
- return task;
3726
- }
3727
- //#endregion
3728
- //#region src/tailwindcss/v3-engine/miniprogram.ts
3729
- const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
3730
- cssChildCombinatorReplaceValue: ["view", "text"],
3731
- cssRemoveHoverPseudoClass: true,
3732
- isMainChunk: true,
3733
- majorVersion: 3
3734
- });
3735
- const MINI_PROGRAM_V3_PREFLIGHT_SELECTORS = new Set([
3736
- "view,text,:before,:after",
3737
- "view,text,:after,:before",
3738
- "view,text,::before,::after",
3739
- "view,text,::after,::before"
3740
- ]);
3741
- const V3_PREFLIGHT_RESET_PROPS = new Set([
3742
- "box-sizing",
3743
- "border",
3744
- "border-width",
3745
- "border-style",
3746
- "border-color",
3747
- "margin",
3748
- "padding"
3749
- ]);
3750
- function normalizeSelector(selector) {
3751
- return selector.trim().replace(/\s+/g, "");
3752
- }
3753
- function isMiniProgramV3PreflightRule(rule) {
3754
- return MINI_PROGRAM_V3_PREFLIGHT_SELECTORS.has(normalizeSelector(rule.selector));
3755
- }
3756
- function hasResetDeclaration(rule) {
3757
- let found = false;
3758
- rule.walkDecls((decl) => {
3759
- if (V3_PREFLIGHT_RESET_PROPS.has(decl.prop)) found = true;
3760
- });
3761
- return found;
3762
- }
3763
- function createPreflightDeclarations(cssPreflight) {
3764
- if (!cssPreflight || typeof cssPreflight !== "object") return [];
3765
- return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => _weapp_tailwindcss_postcss.postcss.decl({
3766
- prop,
3767
- value: value.toString()
3768
- }));
3769
- }
3770
- function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
3771
- const declarations = createPreflightDeclarations(cssPreflight);
3772
- if (declarations.length === 0) return css;
3773
- try {
3774
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
3775
- let targetRule;
3776
- let hasReset = false;
3777
- root.walkRules((rule) => {
3778
- if (!isMiniProgramV3PreflightRule(rule)) return;
3779
- targetRule ?? (targetRule = rule);
3780
- if (hasResetDeclaration(rule)) hasReset = true;
3781
- });
3782
- if (!targetRule || hasReset) return css;
3783
- targetRule.append(...declarations.map((decl) => decl.clone()));
3784
- return root.toString();
3785
- } catch {
3786
- return css;
3787
- }
3788
- }
3789
- async function transformTailwindV3CssToWeapp(css, options) {
3790
- const result = await defaultStyleHandler((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css, {
3791
- cssChildCombinatorReplaceValue: ["view", "text"],
3792
- cssRemoveHoverPseudoClass: true,
3793
- isMainChunk: true,
3794
- majorVersion: 3,
3795
- ...options
3796
- });
3797
- const pruneOptions = {
3798
- preservePreflight: true,
3799
- preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options)
3800
- };
3801
- return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
3802
- }
3803
- async function transformTailwindV3CssByTarget(css, target, options) {
3804
- if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
3805
- return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
3806
- }
3807
- //#endregion
3808
- //#region src/tailwindcss/v3-engine/generator.ts
3809
- const INCREMENTAL_GENERATE_CACHE_MAX = 8;
3810
- const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 128;
3811
- const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 256 * 1024;
3812
- const incrementalGenerateCache = new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX });
3813
- const patchRawStyleGenerator = typeof tailwindcss_patch.generateTailwindV3RawStyle === "function" ? tailwindcss_patch.generateTailwindV3RawStyle : void 0;
3814
- function isTailwindV3PatchResolutionError(error, packageName) {
3815
- if (!error || typeof error !== "object") return false;
3816
- const code = error.code;
3817
- if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
3818
- return String(error.message ?? "").includes(`${packageName}/lib/`);
3819
- }
3820
- function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
3821
- return (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
3822
- }
3823
- function normalizeBareArbitraryValueCandidates(candidates, bareArbitraryValues) {
3824
- const normalized = /* @__PURE__ */ new Set();
3825
- const restoreCandidates = /* @__PURE__ */ new Map();
3826
- for (const candidate of candidates) {
3827
- const normalizedCandidate = normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues);
3828
- normalized.add(normalizedCandidate);
3829
- if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
3830
- }
3831
- return {
3832
- candidates: normalized,
3833
- restoreCandidates
3834
- };
3835
- }
3836
- async function collectSourceBareArbitraryValueCandidates(sources, bareArbitraryValues) {
3837
- if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return [];
3838
- const candidates = /* @__PURE__ */ new Set();
3839
- for (const source of sources ?? []) for (const candidate of await (0, tailwindcss_patch.extractSourceCandidates)(source.content, source.extension ?? "html", omitUndefined({ bareArbitraryValues }))) if ((0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)) candidates.add(candidate);
3840
- return [...candidates];
3841
- }
3842
- function escapeCssClassSelector(className) {
3843
- return className.replace(/[^\w-]/g, (char) => `\\${char}`);
3844
- }
3845
- function restoreBareArbitraryValueCssSelectors(css, originalCandidates, bareArbitraryValues, escapeClassName) {
3846
- if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return css;
3847
- let restored = css;
3848
- for (const originalCandidate of originalCandidates) {
3849
- const canonical = (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(originalCandidate, bareArbitraryValues)?.canonicalCandidate;
3850
- if (canonical) restored = restored.split(`.${escapeClassName(canonical)}`).join(`.${escapeCssClassSelector(originalCandidate)}`);
3851
- }
3852
- return restored;
3853
- }
3854
- function restoreBareArbitraryValueClassSet(classSet, originalCandidates, bareArbitraryValues) {
3855
- if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return new Set(classSet);
3856
- const restored = new Set(classSet);
3857
- for (const originalCandidate of originalCandidates) {
3858
- const canonical = (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(originalCandidate, bareArbitraryValues)?.canonicalCandidate;
3859
- if (canonical && restored.has(canonical)) {
3860
- restored.delete(canonical);
3861
- restored.add(originalCandidate);
3862
- }
3863
- }
3864
- return restored;
3865
- }
3866
- function collectGeneratedCandidates(context, candidates, restoreCandidates) {
3867
- const classSet = /* @__PURE__ */ new Set();
3868
- for (const candidate of candidates) if (context.classCache.has(candidate)) classSet.add(restoreCandidates.get(candidate) ?? candidate);
3869
- return classSet;
3870
- }
3871
- function hasRemovedCandidates(previousCandidates, nextCandidates) {
3872
- for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
3873
- return false;
3874
- }
3875
- function shouldAutoEnableCssMacro(source) {
3876
- return require_auto.hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
3877
- }
3878
- function resolveStyleOptions(source, options) {
3879
- return shouldAutoEnableCssMacro(source) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
3880
- }
3881
- function loadTailwindV3Internals(source) {
3882
- const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
3883
- const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
3884
- const requireTailwind = (id) => {
3885
- try {
3886
- return requireFromProject(id);
3887
- } catch {
3888
- return requireFromRuntime(id);
3889
- }
3890
- };
3891
- const collapseAdjacentRulesModule = requireTailwind(`${source.packageName}/lib/lib/collapseAdjacentRules`);
3892
- const collapseDuplicateDeclarationsModule = requireTailwind(`${source.packageName}/lib/lib/collapseDuplicateDeclarations`);
3893
- const escapeClassNameModule = requireTailwind(`${source.packageName}/lib/util/escapeClassName`);
3894
- const generateRulesModule = requireTailwind(`${source.packageName}/lib/lib/generateRules`);
3895
- const sharedStateModule = requireTailwind(`${source.packageName}/lib/lib/sharedState`);
3896
- const setupContextUtils = requireTailwind(`${source.packageName}/lib/lib/setupContextUtils`);
3897
- const processTailwindFeaturesModule = requireTailwind(`${source.packageName}/lib/processTailwindFeatures`);
3898
- const resolveDefaultsAtRulesModule = requireTailwind(`${source.packageName}/lib/lib/resolveDefaultsAtRules`);
3899
- const resolveConfigModule = requireTailwind(`${source.packageName}/lib/public/resolve-config`);
3900
- const validateConfigModule = requireTailwind(`${source.packageName}/lib/util/validateConfig.js`);
3901
- return {
3902
- collapseAdjacentRules: collapseAdjacentRulesModule["default"] ?? collapseAdjacentRulesModule,
3903
- collapseDuplicateDeclarations: collapseDuplicateDeclarationsModule["default"] ?? collapseDuplicateDeclarationsModule,
3904
- createContext: setupContextUtils["createContext"],
3905
- escapeClassName: escapeClassNameModule["default"] ?? escapeClassNameModule,
3906
- generateRules: generateRulesModule["generateRules"],
3907
- notOnDemandCandidate: String(sharedStateModule["NOT_ON_DEMAND"] ?? "*"),
3908
- processTailwindFeatures: processTailwindFeaturesModule["default"] ?? processTailwindFeaturesModule,
3909
- resolveDefaultsAtRules: resolveDefaultsAtRulesModule["default"] ?? resolveDefaultsAtRulesModule,
3910
- resolveConfig: resolveConfigModule["default"] ?? resolveConfigModule,
3911
- validateConfig: validateConfigModule["validateConfig"]
3912
- };
3913
- }
3914
- function isDirectUtilitiesOnlyCss(css) {
3915
- return css.replace(/\s+/g, "") === "@tailwindutilities;";
3916
- }
3917
- function collectClassSet(context) {
3918
- const classSet = /* @__PURE__ */ new Set();
3919
- for (const candidate of context.classCache.keys()) if (String(candidate) !== "*") classSet.add(candidate);
3920
- return classSet;
3921
- }
3922
- function collectDependencyMessages(result) {
3923
- const dependencies = /* @__PURE__ */ new Set();
3924
- for (const message of result.messages) {
3925
- const file = message["file"];
3926
- if (message["type"] === "dependency" && typeof file === "string") dependencies.add(file);
3927
- }
3928
- return dependencies;
3929
- }
3930
- function sortCandidates(candidates) {
3931
- return [...candidates].sort((a, z) => {
3932
- if (a === z) return 0;
3933
- return a < z ? -1 : 1;
3934
- });
3935
- }
3936
- function createRequestedCandidatesCacheKey(candidates) {
3937
- return sortCandidates(candidates).join("\n");
3938
- }
3939
- function createIncrementalResultsCache() {
3940
- return new lru_cache.LRUCache({ max: 16 });
3941
- }
3942
- function replaceIncrementalEntry(entry, candidates, generated) {
3943
- if (!generated.context) return;
3944
- entry.context = generated.context;
3945
- entry.seenCandidates = new Set(candidates);
3946
- entry.classSet = new Set(generated.classSet);
3947
- entry.css = generated.css;
3948
- entry.rawCss = generated.rawCss;
3949
- entry.dependencies = generated.dependencies;
3950
- entry.resultsByCandidates.clear();
3951
- }
3952
- function seedIncrementalResult(entry, candidates, result) {
3953
- entry.resultsByCandidates.set(createRequestedCandidatesCacheKey(candidates), {
3954
- classSet: new Set(result.classSet),
3955
- css: result.css,
3956
- rawCss: result.rawCss,
3957
- dependencies: result.dependencies
3958
- });
3959
- }
3960
- function createGenerateResultFromCache(cached, result, candidates) {
3961
- return {
3962
- css: result.css,
3963
- rawCss: result.rawCss,
3964
- incrementalCss: "",
3965
- incrementalRawCss: "",
3966
- classSet: new Set(result.classSet),
3967
- rawCandidates: new Set(candidates),
3968
- dependencies: result.dependencies,
3969
- sources: [],
3970
- root: null,
3971
- target: cached.target,
3972
- version: 3
3973
- };
3974
- }
3975
- function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
3976
- return cached.seenCandidates.size + missingCandidates.length > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX || cached.css.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || cached.rawCss.length > INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX || requestedCandidates.size > INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX;
3977
- }
3978
- function appendUtilityRules(root, context, rules) {
3979
- const sortedRules = context.offsets.sort(rules);
3980
- for (const [sort, rule] of sortedRules) {
3981
- const tailwindRaw = rule.raws.tailwind;
3982
- if (sort.layer === "utilities" || sort.layer === "variants" && tailwindRaw?.parentLayer === "utilities") root.append(rule.clone());
3983
- }
3984
- }
3985
- function appendDirectUtilityRules(root, context) {
3986
- appendUtilityRules(root, context, [...context.ruleCache]);
3987
- }
3988
- async function generateRawStyleWithPatch(generateSource, candidates, sources) {
3989
- if (!patchRawStyleGenerator) return;
3990
- try {
3991
- return await patchRawStyleGenerator({
3992
- cwd: generateSource.cwd,
3993
- packageName: generateSource.packageName,
3994
- css: generateSource.css,
3995
- candidates,
3996
- sources,
3997
- config: createTailwindConfig(generateSource, {
3998
- candidates,
3999
- sources
4000
- }),
4001
- directUtilitiesOnly: "auto"
4002
- });
4003
- } catch (error) {
4004
- if (isTailwindV3PatchResolutionError(error, generateSource.packageName)) return;
4005
- throw error;
4006
- }
4007
- }
4008
- function createTailwindV3Engine(source) {
4009
- const runtimeReadyPromise = createRuntimeReadyPromise(source);
4010
- let tailwindInternals;
4011
- async function generateOnce(generateSource, options = {}) {
4012
- await runtimeReadyPromise;
4013
- tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
4014
- const internals = tailwindInternals;
4015
- const { styleOptions, target = "weapp" } = options;
4016
- const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
4017
- const requestedCandidates = mergeGenerateCandidates(generateSource, options);
4018
- for (const candidate of await collectSourceBareArbitraryValueCandidates(options.sources, options.bareArbitraryValues)) requestedCandidates.add(candidate);
4019
- const normalizedCandidates = normalizeBareArbitraryValueCandidates(requestedCandidates, options.bareArbitraryValues);
4020
- const tailwindOptions = {
4021
- ...options,
4022
- candidates: normalizedCandidates.candidates
4023
- };
4024
- const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, tailwindOptions)));
4025
- const candidates = normalizedCandidates.candidates;
4026
- const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
4027
- const root = _weapp_tailwindcss_postcss.postcss.parse(generateSource.css, { from: void 0 });
4028
- const result = {
4029
- css: "",
4030
- messages: []
4031
- };
4032
- let context;
4033
- let rawCss;
4034
- let dependencies;
4035
- const patchGenerated = await generateRawStyleWithPatch(generateSource, candidates, options.sources ?? []);
4036
- if (patchGenerated) {
4037
- context = patchGenerated.context;
4038
- rawCss = restoreBareArbitraryValueCssSelectors(patchGenerated.css, requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
4039
- dependencies = new Set(patchGenerated.dependencies);
4040
- } else {
4041
- if (isDirectUtilitiesOnlyCss(generateSource.css)) {
4042
- context = internals.createContext(tailwindConfig, changedContent, root);
4043
- internals.generateRules(new Set(sortCandidates([internals.notOnDemandCandidate, ...candidates])), context);
4044
- root.removeAll();
4045
- appendDirectUtilityRules(root, context);
4046
- internals.resolveDefaultsAtRules(context)(root, result);
4047
- internals.collapseAdjacentRules(context)(root, result);
4048
- internals.collapseDuplicateDeclarations(context)(root, result);
4049
- } else {
4050
- const setupContext = () => {
4051
- return (currentRoot) => internals.createContext(tailwindConfig, changedContent, currentRoot);
4052
- };
4053
- context = await internals.processTailwindFeatures(setupContext)(root, result);
4054
- }
4055
- rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
4056
- dependencies = collectDependencyMessages(result);
4057
- }
4058
- const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
4059
- for (const dependency of generateSource.dependencies) dependencies.add(dependency);
4060
- const classSet = restoreBareArbitraryValueClassSet(collectClassSet(context), requestedCandidates, options.bareArbitraryValues);
4061
- return {
4062
- css,
4063
- rawCss,
4064
- context,
4065
- classSet,
4066
- rawCandidates: requestedCandidates,
4067
- dependencies: [...dependencies],
4068
- sources: [],
4069
- root: null,
4070
- target,
4071
- version: 3
4072
- };
4073
- }
4074
- async function generateIncrementalMissingUtilities(context, candidates, target, styleOptions, bareArbitraryValues) {
4075
- tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
4076
- const internals = tailwindInternals;
4077
- const root = _weapp_tailwindcss_postcss.postcss.root();
4078
- const result = {
4079
- css: "",
4080
- messages: []
4081
- };
4082
- const normalizedCandidates = normalizeBareArbitraryValueCandidates(candidates, bareArbitraryValues);
4083
- const sortedCandidates = sortCandidates(normalizedCandidates.candidates);
4084
- appendUtilityRules(root, context, internals.generateRules(new Set(sortedCandidates), context));
4085
- internals.resolveDefaultsAtRules(context)(root, result);
4086
- internals.collapseAdjacentRules(context)(root, result);
4087
- internals.collapseDuplicateDeclarations(context)(root, result);
4088
- const rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), candidates, bareArbitraryValues, internals.escapeClassName);
4089
- return {
4090
- css: await transformTailwindV3CssByTarget(rawCss, target, resolveStyleOptions(source, styleOptions)),
4091
- rawCss,
4092
- classSet: collectGeneratedCandidates(context, sortedCandidates, normalizedCandidates.restoreCandidates),
4093
- dependencies: collectDependencyMessages(result)
4094
- };
4095
- }
4096
- async function generateWithIncrementalCache(options = {}) {
4097
- if ((options.sources?.length ?? 0) > 0) return generateOnce(source, options);
4098
- const target = options.target ?? "weapp";
4099
- const requestedCandidates = mergeGenerateCandidates(source, options);
4100
- if (requestedCandidates.size === 0) return generateOnce(source, options);
4101
- const styleOptions = resolveStyleOptions(source, options.styleOptions);
4102
- const cacheKey = createIncrementalGenerateCacheKey$1(source, target, styleOptions, options.bareArbitraryValues);
4103
- const cached = incrementalGenerateCache.get(cacheKey);
4104
- if (cached) {
4105
- if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
4106
- const generated = await generateOnce(source, options);
4107
- replaceIncrementalEntry(cached, requestedCandidates, generated);
4108
- seedIncrementalResult(cached, requestedCandidates, generated);
4109
- return generated;
4110
- }
4111
- const requestedCacheKey = createRequestedCandidatesCacheKey(requestedCandidates);
4112
- const cachedResult = cached.resultsByCandidates.get(requestedCacheKey);
4113
- if (cachedResult) return createGenerateResultFromCache(cached, cachedResult, requestedCandidates);
4114
- const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
4115
- if (missingCandidates.length === 0) {
4116
- seedIncrementalResult(cached, requestedCandidates, cached);
4117
- return createGenerateResultFromCache(cached, cached, requestedCandidates);
4118
- }
4119
- if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) {
4120
- const generated = await generateOnce(source, options);
4121
- replaceIncrementalEntry(cached, requestedCandidates, generated);
4122
- seedIncrementalResult(cached, requestedCandidates, generated);
4123
- return generated;
4124
- }
4125
- const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions, options.bareArbitraryValues);
4126
- for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
4127
- for (const className of generated.classSet) cached.classSet.add(className);
4128
- cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
4129
- cached.rawCss = [cached.rawCss, generated.rawCss].filter(Boolean).join("\n");
4130
- cached.dependencies = [...new Set([...cached.dependencies, ...generated.dependencies])];
4131
- const result = {
4132
- css: cached.css,
4133
- rawCss: cached.rawCss,
4134
- incrementalCss: generated.css,
4135
- incrementalRawCss: generated.rawCss,
4136
- classSet: new Set(cached.classSet),
4137
- rawCandidates: new Set(cached.seenCandidates),
4138
- dependencies: cached.dependencies,
4139
- sources: [],
4140
- root: null,
4141
- target: cached.target,
4142
- version: 3
4143
- };
4144
- seedIncrementalResult(cached, requestedCandidates, result);
4145
- return result;
4146
- }
4147
- const generated = await generateOnce(source, options);
4148
- const resultsByCandidates = createIncrementalResultsCache();
4149
- const entry = {
4150
- context: generated.context,
4151
- seenCandidates: new Set(requestedCandidates),
4152
- classSet: new Set(generated.classSet),
4153
- css: generated.css,
4154
- rawCss: generated.rawCss,
4155
- dependencies: generated.dependencies,
4156
- resultsByCandidates,
4157
- target: generated.target
4158
- };
4159
- seedIncrementalResult(entry, requestedCandidates, generated);
4160
- incrementalGenerateCache.set(cacheKey, entry);
4161
- return generated;
4162
- }
4163
- async function generate(options = {}) {
4164
- return options.incrementalCache ? generateWithIncrementalCache(options) : generateOnce(source, options);
4165
- }
4166
- return {
4167
- source,
4168
- async validateCandidates(candidates) {
4169
- return (await generate({
4170
- candidates,
4171
- incrementalCache: true,
4172
- target: "tailwind"
4173
- })).classSet;
4174
- },
4175
- generate
4176
- };
4177
- }
4178
- function getTailwindV3IncrementalGenerateCacheStats() {
4179
- return {
4180
- max: INCREMENTAL_GENERATE_CACHE_MAX,
4181
- entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
4182
- entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
4183
- size: incrementalGenerateCache.size,
4184
- entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
4185
- key,
4186
- candidates: entry.seenCandidates.size,
4187
- classSet: entry.classSet.size,
4188
- cssBytes: entry.css.length,
4189
- rawCssBytes: entry.rawCss.length,
4190
- exactResults: entry.resultsByCandidates.size
4191
- })),
4192
- keys: [...incrementalGenerateCache.keys()]
4193
- };
4194
- }
4195
- //#endregion
4196
- //#region src/tailwindcss/v3-engine/source.ts
4197
- const DEFAULT_TAILWIND_V3_CSS = [
4198
- "@tailwind base;",
4199
- "@tailwind components;",
4200
- "@tailwind utilities;"
4201
- ].join("\n");
4202
- function parseConfigParam(params) {
4203
- const value = params.trim();
4204
- return /^(['"])(.+)\1$/.exec(value)?.[2];
4205
- }
4206
- function resolveOptionalPath(value, base) {
4207
- if (!value) return;
4208
- return node_path.default.isAbsolute(value) ? value : node_path.default.resolve(base, value);
4209
- }
4210
- function resolveCssConfig(css, base) {
4211
- if (!css) return {
4212
- css,
4213
- config: void 0
4214
- };
4215
- const root = _weapp_tailwindcss_postcss.postcss.parse(css);
4216
- let config;
4217
- root.walkAtRules("config", (rule) => {
4218
- const configPath = parseConfigParam(rule.params);
4219
- if (!configPath) return;
4220
- if (!config) config = resolveOptionalPath(configPath, base);
4221
- rule.remove();
4222
- });
4223
- return {
4224
- config,
4225
- css: root.toString()
4226
- };
4227
- }
4228
- function getProjectRoot(patcher) {
4229
- return patcher.options?.projectRoot ?? node_process.default.cwd();
4230
- }
4231
- function normalizeLoadedConfig(config) {
4232
- if (!config || typeof config !== "object") return config;
4233
- const maybeDefault = config.default;
4234
- if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
4235
- return config;
4236
- }
4237
- function resolveTailwindCssPackageName(patcher) {
4238
- return resolveTailwindcssOptions(patcher.options)?.packageName ?? patcher.packageInfo?.name ?? "tailwindcss";
4239
- }
4240
- async function resolveTailwindV3Source(options = {}) {
4241
- const projectRoot = options.projectRoot ?? node_process.default.cwd();
4242
- const base = options.base ?? options.cwd ?? projectRoot;
4243
- const cssConfig = resolveCssConfig(options.css, base);
4244
- const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
4245
- const cwd = options.cwd ?? (config ? node_path.default.dirname(config) : projectRoot);
4246
- const explicitConfigObject = normalizeLoadedConfig(options.configObject);
4247
- const loaded = await (0, tailwindcss_config.loadConfig)(omitUndefined({
4248
- config,
4249
- cwd
4250
- }));
4251
- return {
4252
- version: 3,
4253
- projectRoot,
4254
- cwd,
4255
- base,
4256
- css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
4257
- config: loaded?.filepath ?? config,
4258
- configObject: explicitConfigObject ?? normalizeLoadedConfig(loaded?.config),
4259
- dependencies: loaded?.filepath ? [loaded.filepath] : [],
4260
- packageName: options.packageName ?? "tailwindcss",
4261
- postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
4262
- };
4263
- }
4264
- function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
4265
- const projectRoot = getProjectRoot(patcher);
4266
- const tailwindOptions = resolveTailwindcssOptions(patcher.options);
4267
- return {
4268
- projectRoot,
4269
- cwd: tailwindOptions?.v3?.cwd ?? tailwindOptions?.cwd ?? projectRoot,
4270
- config: tailwindOptions?.v3?.config ?? tailwindOptions?.config,
4271
- packageName: resolveTailwindCssPackageName(patcher),
4272
- postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
4273
- };
4274
- }
4275
- function resolveTailwindV3SourceFromPatcher(patcher) {
4276
- return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
4277
- }
4278
- //#endregion
4279
- Object.defineProperty(exports, "FULL_SOURCE_SCAN_EXTENSION_RE", {
4280
- enumerable: true,
4281
- get: function() {
4282
- return FULL_SOURCE_SCAN_EXTENSION_RE;
4283
- }
4284
- });
4285
- Object.defineProperty(exports, "VITE_MARKER_RE", {
4286
- enumerable: true,
4287
- get: function() {
4288
- return VITE_MARKER_RE;
4289
- }
4290
- });
4291
- Object.defineProperty(exports, "createCssAppend", {
4292
- enumerable: true,
4293
- get: function() {
4294
- return createCssAppend;
4295
- }
4296
- });
4297
- Object.defineProperty(exports, "createDebug", {
4298
- enumerable: true,
4299
- get: function() {
4300
- return createDebug;
4301
- }
4302
- });
4303
- Object.defineProperty(exports, "createTailwindV3Engine", {
4304
- enumerable: true,
4305
- get: function() {
4306
- return createTailwindV3Engine;
4307
- }
4308
- });
4309
- Object.defineProperty(exports, "createTailwindV4Engine", {
4310
- enumerable: true,
4311
- get: function() {
4312
- return createTailwindV4Engine;
4313
- }
4314
- });
4315
- Object.defineProperty(exports, "createTailwindcssPatcher", {
4316
- enumerable: true,
4317
- get: function() {
4318
- return createTailwindcssPatcher;
4319
- }
4320
- });
4321
- Object.defineProperty(exports, "createViteSourceScanMatcher", {
4322
- enumerable: true,
4323
- get: function() {
4324
- return createViteSourceScanMatcher;
4325
- }
4326
- });
4327
- Object.defineProperty(exports, "discoverTailwindV4CssEntries", {
4328
- enumerable: true,
4329
- get: function() {
4330
- return discoverTailwindV4CssEntries;
4331
- }
4332
- });
4333
- Object.defineProperty(exports, "ensureTailwindcssRuntimePatch", {
4334
- enumerable: true,
4335
- get: function() {
4336
- return ensureTailwindcssRuntimePatch;
4337
- }
4338
- });
4339
- Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
4340
- enumerable: true,
4341
- get: function() {
4342
- return filterUnsupportedMiniProgramTailwindV4Candidates;
4343
- }
4344
- });
4345
- Object.defineProperty(exports, "findNearestPackageRoot", {
4346
- enumerable: true,
4347
- get: function() {
4348
- return findNearestPackageRoot;
4349
- }
4350
- });
4351
- Object.defineProperty(exports, "findTailwindConfig", {
4352
- enumerable: true,
4353
- get: function() {
4354
- return findTailwindConfig;
4355
- }
4356
- });
4357
- Object.defineProperty(exports, "findWorkspacePackageDir", {
4358
- enumerable: true,
4359
- get: function() {
4360
- return findWorkspacePackageDir;
4361
- }
4362
- });
4363
- Object.defineProperty(exports, "findWorkspaceRoot", {
4364
- enumerable: true,
4365
- get: function() {
4366
- return findWorkspaceRoot;
4367
- }
4368
- });
4369
- Object.defineProperty(exports, "getRuntimeClassSetCacheEntry", {
4370
- enumerable: true,
4371
- get: function() {
4372
- return getRuntimeClassSetCacheEntry;
4373
- }
4374
- });
4375
- Object.defineProperty(exports, "getRuntimeClassSetSignature", {
4376
- enumerable: true,
4377
- get: function() {
4378
- return getRuntimeClassSetSignature;
4379
- }
4380
- });
4381
- Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
4382
- enumerable: true,
4383
- get: function() {
4384
- return getRuntimeClassSetSignatureWithSources;
4385
- }
4386
- });
4387
- Object.defineProperty(exports, "getTailwindV3IncrementalGenerateCacheStats", {
4388
- enumerable: true,
4389
- get: function() {
4390
- return getTailwindV3IncrementalGenerateCacheStats;
4391
- }
4392
- });
4393
- Object.defineProperty(exports, "getTailwindV4IncrementalGenerateCacheStats", {
4394
- enumerable: true,
4395
- get: function() {
4396
- return getTailwindV4IncrementalGenerateCacheStats;
4397
- }
4398
- });
4399
- Object.defineProperty(exports, "hasLocalCssImport", {
4400
- enumerable: true,
4401
- get: function() {
4402
- return hasLocalCssImport;
4403
- }
4404
- });
4405
- Object.defineProperty(exports, "hasTailwindApplyDirective", {
4406
- enumerable: true,
4407
- get: function() {
4408
- return hasTailwindApplyDirective;
4409
- }
4410
- });
4411
- Object.defineProperty(exports, "hasTailwindGeneratedCss", {
4412
- enumerable: true,
4413
- get: function() {
4414
- return hasTailwindGeneratedCss;
4415
- }
4416
- });
4417
- Object.defineProperty(exports, "hasTailwindGeneratedCssMarkers", {
4418
- enumerable: true,
4419
- get: function() {
4420
- return hasTailwindGeneratedCssMarkers;
4421
- }
4422
- });
4423
- Object.defineProperty(exports, "hasTailwindRootDirectives", {
4424
- enumerable: true,
4425
- get: function() {
4426
- return hasTailwindRootDirectives;
4427
- }
4428
- });
4429
- Object.defineProperty(exports, "hasTailwindSourceDirectives", {
4430
- enumerable: true,
4431
- get: function() {
4432
- return hasTailwindSourceDirectives;
4433
- }
4434
- });
4435
- Object.defineProperty(exports, "invalidateRuntimeClassSet", {
4436
- enumerable: true,
4437
- get: function() {
4438
- return invalidateRuntimeClassSet;
4439
- }
4440
- });
4441
- Object.defineProperty(exports, "isFileMatchedByTailwindSourceEntries", {
4442
- enumerable: true,
4443
- get: function() {
4444
- return isFileMatchedByTailwindSourceEntries;
4445
- }
4446
- });
4447
- Object.defineProperty(exports, "normalizeConfigDirective", {
4448
- enumerable: true,
4449
- get: function() {
4450
- return normalizeConfigDirective;
4451
- }
4452
- });
4453
- Object.defineProperty(exports, "normalizeLegacyContentEntries", {
4454
- enumerable: true,
4455
- get: function() {
4456
- return normalizeLegacyContentEntries;
4457
- }
4458
- });
4459
- Object.defineProperty(exports, "normalizeStringListOption", {
4460
- enumerable: true,
4461
- get: function() {
4462
- return normalizeStringListOption;
4463
- }
4464
- });
4465
- Object.defineProperty(exports, "normalizeTailwindConfigDirectives", {
4466
- enumerable: true,
4467
- get: function() {
4468
- return normalizeTailwindConfigDirectives;
4469
- }
4470
- });
4471
- Object.defineProperty(exports, "normalizeTailwindSourceDirectives", {
4472
- enumerable: true,
4473
- get: function() {
4474
- return normalizeTailwindSourceDirectives;
4475
- }
4476
- });
4477
- Object.defineProperty(exports, "normalizeTailwindSourceForGenerator", {
4478
- enumerable: true,
4479
- get: function() {
4480
- return normalizeTailwindSourceForGenerator;
4481
- }
4482
- });
4483
- Object.defineProperty(exports, "normalizeTailwindV3CssEntrySource", {
4484
- enumerable: true,
4485
- get: function() {
4486
- return normalizeTailwindV3CssEntrySource;
4487
- }
4488
- });
4489
- Object.defineProperty(exports, "omitUndefined", {
4490
- enumerable: true,
4491
- get: function() {
4492
- return omitUndefined;
4493
- }
4494
- });
4495
- Object.defineProperty(exports, "parseImportRequest", {
4496
- enumerable: true,
4497
- get: function() {
4498
- return parseImportRequest;
4499
- }
4500
- });
4501
- Object.defineProperty(exports, "prependConfigDirective", {
4502
- enumerable: true,
4503
- get: function() {
4504
- return prependConfigDirective;
4505
- }
4506
- });
4507
- Object.defineProperty(exports, "readInstalledPackageMajorVersion", {
4508
- enumerable: true,
4509
- get: function() {
4510
- return readInstalledPackageMajorVersion;
4511
- }
4512
- });
4513
- Object.defineProperty(exports, "removeTailwindSourceDirectives", {
4514
- enumerable: true,
4515
- get: function() {
4516
- return removeTailwindSourceDirectives;
4517
- }
4518
- });
4519
- Object.defineProperty(exports, "resolveBooleanObjectOption", {
4520
- enumerable: true,
4521
- get: function() {
4522
- return resolveBooleanObjectOption;
4523
- }
4524
- });
4525
- Object.defineProperty(exports, "resolveCssEntrySource", {
4526
- enumerable: true,
4527
- get: function() {
4528
- return resolveCssEntrySource;
4529
- }
4530
- });
4531
- Object.defineProperty(exports, "resolveSourceScanPath", {
4532
- enumerable: true,
4533
- get: function() {
4534
- return resolveSourceScanPath;
4535
- }
4536
- });
4537
- Object.defineProperty(exports, "resolveTailwindConfigEntriesFromCssCached", {
4538
- enumerable: true,
4539
- get: function() {
4540
- return resolveTailwindConfigEntriesFromCssCached;
4541
- }
4542
- });
4543
- Object.defineProperty(exports, "resolveTailwindV3Source", {
4544
- enumerable: true,
4545
- get: function() {
4546
- return resolveTailwindV3Source;
4547
- }
4548
- });
4549
- Object.defineProperty(exports, "resolveTailwindV3SourceFromPatcher", {
4550
- enumerable: true,
4551
- get: function() {
4552
- return resolveTailwindV3SourceFromPatcher;
4553
- }
4554
- });
4555
- Object.defineProperty(exports, "resolveTailwindV3SourceOptionsFromPatcher", {
4556
- enumerable: true,
4557
- get: function() {
4558
- return resolveTailwindV3SourceOptionsFromPatcher;
4559
- }
4560
- });
4561
- Object.defineProperty(exports, "resolveTailwindV4CssSourceBase", {
4562
- enumerable: true,
4563
- get: function() {
4564
- return resolveTailwindV4CssSourceBase;
4565
- }
4566
- });
4567
- Object.defineProperty(exports, "resolveTailwindV4EntriesFromCss", {
4568
- enumerable: true,
4569
- get: function() {
4570
- return resolveTailwindV4EntriesFromCss;
4571
- }
4572
- });
4573
- Object.defineProperty(exports, "resolveTailwindV4EntriesFromCssCached", {
4574
- enumerable: true,
4575
- get: function() {
4576
- return resolveTailwindV4EntriesFromCssCached;
4577
- }
4578
- });
4579
- Object.defineProperty(exports, "resolveTailwindV4Source", {
4580
- enumerable: true,
4581
- get: function() {
4582
- return resolveTailwindV4Source;
4583
- }
4584
- });
4585
- Object.defineProperty(exports, "resolveTailwindV4SourceFromPatcher", {
4586
- enumerable: true,
4587
- get: function() {
4588
- return resolveTailwindV4SourceFromPatcher;
4589
- }
4590
- });
4591
- Object.defineProperty(exports, "resolveTailwindV4SourceOptionsFromPatcher", {
4592
- enumerable: true,
4593
- get: function() {
4594
- return resolveTailwindV4SourceOptionsFromPatcher;
4595
- }
4596
- });
4597
- Object.defineProperty(exports, "resolveTailwindcssOptions", {
4598
- enumerable: true,
4599
- get: function() {
4600
- return resolveTailwindcssOptions;
4601
- }
4602
- });
4603
- Object.defineProperty(exports, "resolveViteSourceScanEntries", {
4604
- enumerable: true,
4605
- get: function() {
4606
- return resolveViteSourceScanEntries;
4607
- }
4608
- });
4609
- Object.defineProperty(exports, "resolveViteTailwindV4CssDependencies", {
4610
- enumerable: true,
4611
- get: function() {
4612
- return resolveViteTailwindV4CssDependencies;
4613
- }
4614
- });
4615
- Object.defineProperty(exports, "runtimeSignaturePatchersSymbol", {
4616
- enumerable: true,
4617
- get: function() {
4618
- return runtimeSignaturePatchersSymbol;
4619
- }
4620
- });
4621
- Object.defineProperty(exports, "splitGeneratorPlaceholderCssBySourceOrder", {
4622
- enumerable: true,
4623
- get: function() {
4624
- return splitGeneratorPlaceholderCssBySourceOrder;
4625
- }
4626
- });
4627
- Object.defineProperty(exports, "splitTailwindGeneratedCssByBanner", {
4628
- enumerable: true,
4629
- get: function() {
4630
- return splitTailwindGeneratedCssByBanner;
4631
- }
4632
- });
4633
- Object.defineProperty(exports, "splitTailwindV4GeneratedCssBySourceOrder", {
4634
- enumerable: true,
4635
- get: function() {
4636
- return splitTailwindV4GeneratedCssBySourceOrder;
4637
- }
4638
- });
4639
- Object.defineProperty(exports, "stripGeneratorPlaceholderMarkers", {
4640
- enumerable: true,
4641
- get: function() {
4642
- return stripGeneratorPlaceholderMarkers;
4643
- }
4644
- });
4645
- Object.defineProperty(exports, "stripTailwindBanner", {
4646
- enumerable: true,
4647
- get: function() {
4648
- return stripTailwindBanner;
4649
- }
4650
- });
4651
- Object.defineProperty(exports, "stripTailwindBanners", {
4652
- enumerable: true,
4653
- get: function() {
4654
- return stripTailwindBanners;
4655
- }
4656
- });
4657
- Object.defineProperty(exports, "toPosixPath", {
4658
- enumerable: true,
4659
- get: function() {
4660
- return toPosixPath;
4661
- }
4662
- });
4663
- Object.defineProperty(exports, "transformTailwindV3CssByTarget", {
4664
- enumerable: true,
4665
- get: function() {
4666
- return transformTailwindV3CssByTarget;
4667
- }
4668
- });
4669
- Object.defineProperty(exports, "transformTailwindV3CssToWeapp", {
4670
- enumerable: true,
4671
- get: function() {
4672
- return transformTailwindV3CssToWeapp;
4673
- }
4674
- });
4675
- Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
4676
- enumerable: true,
4677
- get: function() {
4678
- return transformTailwindV4CssByTarget;
4679
- }
4680
- });
4681
- Object.defineProperty(exports, "transformTailwindV4CssToWeapp", {
4682
- enumerable: true,
4683
- get: function() {
4684
- return transformTailwindV4CssToWeapp;
4685
- }
4686
- });