weapp-tailwindcss 5.0.0-next.24 → 5.0.0-next.26

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 (76) hide show
  1. package/dist/auto-CqyEtds4.js +115 -0
  2. package/dist/auto-CsWz6lsU.mjs +78 -0
  3. package/dist/{bundle-state-CP_BWXfx.mjs → bundle-state-CWcrb3mH.mjs} +1 -2
  4. package/dist/{bundle-state-DXFq2nEo.js → bundle-state-uCtqRm0p.js} +2 -3
  5. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  6. package/dist/cli.js +167 -6
  7. package/dist/cli.mjs +166 -5
  8. package/dist/context/runtime-package-replacements.d.ts +2 -0
  9. package/dist/context/style-options.d.ts +3 -0
  10. package/dist/core.js +1 -1
  11. package/dist/core.mjs +1 -1
  12. package/dist/css-macro/auto.d.ts +10 -0
  13. package/dist/css-macro/constants.d.ts +5 -2
  14. package/dist/css-macro/postcss.d.ts +1 -0
  15. package/dist/css-macro/postcss.js +7 -47
  16. package/dist/css-macro/postcss.mjs +2 -47
  17. package/dist/css-macro.js +15 -6
  18. package/dist/css-macro.mjs +15 -6
  19. package/dist/{defaults-C6sIKXgC.mjs → defaults-B-1EEhdL.mjs} +2 -1
  20. package/dist/{defaults-D3cFX6Cq.js → defaults-C10hYUch.js} +2 -1
  21. package/dist/defaults.js +1 -1
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/{generator-BcH28HU-.js → generator-BH6a0xuB.js} +1 -1
  24. package/dist/{generator-DdEgn8nG.mjs → generator-iI_265gt.mjs} +1 -1
  25. package/dist/generator.js +2 -2
  26. package/dist/generator.mjs +2 -2
  27. package/dist/gulp.js +5 -5
  28. package/dist/gulp.mjs +5 -5
  29. package/dist/{incremental-runtime-class-set-Bux7viee.mjs → incremental-runtime-class-set-ECHyKwUL.mjs} +4 -16
  30. package/dist/{incremental-runtime-class-set-CWdfLHON.js → incremental-runtime-class-set-mY0v1k-Y.js} +4 -16
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +18 -4
  33. package/dist/index.mjs +6 -5
  34. package/dist/postcss-BwW8zO24.js +192 -0
  35. package/dist/postcss-BzaRjBL0.mjs +169 -0
  36. package/dist/{postcss-cD5PXmMU.js → postcss-DEEAZ8J5.js} +2 -2
  37. package/dist/{postcss-nk5bhdoV.mjs → postcss-DJoU--Z-.mjs} +2 -2
  38. package/dist/postcss.js +1 -1
  39. package/dist/postcss.mjs +1 -1
  40. package/dist/precheck-BI8oBeUg.mjs +4692 -0
  41. package/dist/{precheck-DtYqujIx.js → precheck-DLJg0_pu.js} +2070 -34
  42. package/dist/presets/index.d.ts +1 -0
  43. package/dist/presets/uni-app-x.d.ts +1 -0
  44. package/dist/presets.js +19 -5
  45. package/dist/presets.mjs +18 -6
  46. package/dist/{source-candidates-B7wmEa-G.mjs → source-candidates-DkScNh9A.mjs} +1 -1
  47. package/dist/{source-candidates-lHtAHLQq.js → source-candidates-mfvC9gMc.js} +1 -1
  48. package/dist/{tailwindcss-BtUBeOes.js → tailwindcss-Cm93idme.js} +17 -26
  49. package/dist/{tailwindcss-DO-VVR5k.mjs → tailwindcss-DFa5Yes8.mjs} +17 -26
  50. package/dist/types/index.d.ts +1 -1
  51. package/dist/types/shared.d.ts +3 -0
  52. package/dist/types/user-defined-options/general.d.ts +2 -1
  53. package/dist/types/user-defined-options/important.d.ts +3 -1
  54. package/dist/unocss/index.d.ts +2 -0
  55. package/dist/utils/options.d.ts +2 -0
  56. package/dist/utils/regex.d.ts +1 -0
  57. package/dist/{v3-engine-vHlppqaZ.js → v3-engine-CGsbY81C.js} +67 -19
  58. package/dist/{v3-engine-CXqgQZUc.mjs → v3-engine-CPJ9uGyr.mjs} +56 -20
  59. package/dist/{vite-BkNDGBZ2.js → vite-BM_ksf1q.js} +140 -21
  60. package/dist/{vite-BthAm8kt.mjs → vite-CqEF-Wx5.mjs} +140 -21
  61. package/dist/vite.js +1 -1
  62. package/dist/vite.mjs +1 -1
  63. package/dist/weapp-tw-css-import-rewrite-loader.js +327 -73
  64. package/dist/weapp-tw-runtime-classset-loader.js +1 -4
  65. package/dist/{webpack-prCus5xn.js → webpack-CfcuDhQ8.js} +10 -7
  66. package/dist/{webpack-hPc8wUAi.mjs → webpack-D--XZMBB.mjs} +11 -8
  67. package/dist/webpack.js +1 -1
  68. package/dist/webpack.mjs +1 -1
  69. package/package.json +14 -14
  70. package/dist/constants-BG12WAKw.mjs +0 -44
  71. package/dist/constants-BeeyfJ9k.js +0 -73
  72. package/dist/precheck-DreRGvYH.mjs +0 -2668
  73. /package/dist/{logger-EVNB9z7i.js → logger-Cdzl3p8j.js} +0 -0
  74. /package/dist/{logger-CZUxvJJD.mjs → logger-Dr7IvyH2.mjs} +0 -0
  75. /package/dist/{utils-CGBVVNm6.mjs → utils-B2SJgA1L.mjs} +0 -0
  76. /package/dist/{utils-4ODFyoqD.js → utils-CSA174-I.js} +0 -0
@@ -6,8 +6,6 @@ const require_runtime_registry = require("./runtime-registry-CdCV3Opt.js");
6
6
  let node_buffer = require("node:buffer");
7
7
  let node_process = require("node:process");
8
8
  node_process = require_runtime_registry.__toESM(node_process);
9
- let loader_utils = require("loader-utils");
10
- loader_utils = require_runtime_registry.__toESM(loader_utils);
11
9
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
12
10
  let node_path = require("node:path");
13
11
  node_path = require_runtime_registry.__toESM(node_path);
@@ -33,7 +31,6 @@ require("@babel/parser");
33
31
  require("@babel/types");
34
32
  require("@ast-core/escape");
35
33
  require("@weapp-tailwindcss/shared/extractors");
36
- require("htmlparser2");
37
34
  //#region src/bundlers/shared/css-imports.ts
38
35
  const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
39
36
  const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
@@ -67,6 +64,284 @@ function createBundlerGeneratedCssMarker(bundler, file) {
67
64
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
68
65
  }
69
66
  //#endregion
67
+ //#region src/uni-app-x/options.ts
68
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
69
+ enabled: true,
70
+ onlyWhenStyleIsolationVersion2: true
71
+ };
72
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
73
+ enabled: false,
74
+ onlyWhenStyleIsolationVersion2: true
75
+ };
76
+ function isBooleanUniAppXShortcut(option) {
77
+ return option === true || option === false || option === void 0;
78
+ }
79
+ function resolveComponentLocalStyles(option) {
80
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
81
+ const componentLocalStyles = option.componentLocalStyles;
82
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
83
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
84
+ return {
85
+ enabled: componentLocalStyles.enabled !== false,
86
+ onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
87
+ };
88
+ }
89
+ function resolveUniAppXOptions(option) {
90
+ if (typeof option === "object" && option) return {
91
+ enabled: option.enabled !== false,
92
+ componentLocalStyles: resolveComponentLocalStyles(option),
93
+ uvueUnsupported: option.uvueUnsupported ?? "warn"
94
+ };
95
+ return {
96
+ enabled: Boolean(option),
97
+ componentLocalStyles: resolveComponentLocalStyles(option),
98
+ uvueUnsupported: "warn"
99
+ };
100
+ }
101
+ //#endregion
102
+ //#region src/context/style-options.ts
103
+ function resolveStyleOptionsFromContext(ctx) {
104
+ const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
105
+ return {
106
+ cssPreflight: ctx.cssPreflight,
107
+ cssPreflightRange: ctx.cssPreflightRange,
108
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
109
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
110
+ rem2rpx: ctx.rem2rpx,
111
+ cssRemoveProperty: ctx.cssRemoveProperty,
112
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
113
+ cssPresetEnv: ctx.cssPresetEnv,
114
+ autoprefixer: ctx.autoprefixer,
115
+ cssCalc: ctx.cssCalc,
116
+ uniAppX: resolvedUniAppXOptions.enabled,
117
+ platform: ctx.platform,
118
+ px2rpx: ctx.px2rpx,
119
+ unitsToPx: ctx.unitsToPx,
120
+ unitConversion: ctx.unitConversion
121
+ };
122
+ }
123
+ //#endregion
124
+ //#region src/css-macro/constants.ts
125
+ const queryKey = "weapp-tw-platform";
126
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
127
+ const WHITESPACE_RE = /\s+/g;
128
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
129
+ function normalComment(text) {
130
+ if (typeof text === "string") {
131
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
132
+ if (normalized.includes("\\")) return normalized;
133
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
134
+ }
135
+ return text;
136
+ }
137
+ function ifdef(text) {
138
+ return {
139
+ start: `#ifdef ${normalComment(text)}`,
140
+ end: `#endif`
141
+ };
142
+ }
143
+ function ifndef(text) {
144
+ return {
145
+ start: `#ifndef ${normalComment(text)}`,
146
+ end: `#endif`
147
+ };
148
+ }
149
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
150
+ function matchCustomPropertyFromValue(str, cb) {
151
+ let index = 0;
152
+ QUERY_KEY_REGEX.lastIndex = 0;
153
+ let arr = QUERY_KEY_REGEX.exec(str);
154
+ while (arr !== null) {
155
+ cb(arr, index);
156
+ index++;
157
+ arr = QUERY_KEY_REGEX.exec(str);
158
+ }
159
+ }
160
+ function parseConditionalAtRuleParam(params) {
161
+ const value = params.trim();
162
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
163
+ if (!quoted) return value;
164
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
165
+ }
166
+ //#endregion
167
+ //#region src/css-macro/postcss.ts
168
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
169
+ const CONDITIONAL_COMMENT_SPACING = " ";
170
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
171
+ const creator = () => {
172
+ return {
173
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
174
+ prepare() {
175
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
176
+ const hasPreviousNode = Boolean(atRule.prev());
177
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
178
+ const startComment = helper.comment({
179
+ raws: {
180
+ left: CONDITIONAL_COMMENT_SPACING,
181
+ right: CONDITIONAL_COMMENT_SPACING
182
+ },
183
+ text: comment.start
184
+ });
185
+ const endComment = helper.comment({
186
+ raws: {
187
+ left: CONDITIONAL_COMMENT_SPACING,
188
+ right: CONDITIONAL_COMMENT_SPACING
189
+ },
190
+ text: comment.end
191
+ });
192
+ const nextNodes = [
193
+ startComment,
194
+ ...clonedNodes,
195
+ endComment
196
+ ];
197
+ atRule.replaceWith(nextNodes);
198
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
199
+ startComment.raws["after"] = "\n";
200
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
201
+ endComment.raws.before = "\n";
202
+ endComment.raws["after"] = "\n";
203
+ const nextNode = endComment?.next();
204
+ if (nextNode) nextNode.raws.before = "\n";
205
+ }
206
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
207
+ if (atRule.parent?.type !== "rule") return false;
208
+ const parentRule = atRule.parent;
209
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
210
+ const conditionalRule = parentRule.clone();
211
+ conditionalRule.removeAll();
212
+ conditionalRule.append(...clonedNodes);
213
+ const startComment = helper.comment({
214
+ raws: {
215
+ left: CONDITIONAL_COMMENT_SPACING,
216
+ right: CONDITIONAL_COMMENT_SPACING
217
+ },
218
+ text: comment.start
219
+ });
220
+ const endComment = helper.comment({
221
+ raws: {
222
+ left: CONDITIONAL_COMMENT_SPACING,
223
+ right: CONDITIONAL_COMMENT_SPACING
224
+ },
225
+ text: comment.end
226
+ });
227
+ const nextNodes = [
228
+ startComment,
229
+ conditionalRule,
230
+ endComment
231
+ ];
232
+ const hasPreviousNode = Boolean(parentRule.prev());
233
+ atRule.remove();
234
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
235
+ else parentRule.after(nextNodes);
236
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
237
+ startComment.raws["after"] = "\n";
238
+ conditionalRule.raws.before = "\n";
239
+ endComment.raws.before = "\n";
240
+ endComment.raws["after"] = "\n";
241
+ const nextNode = endComment.next();
242
+ if (nextNode) nextNode.raws.before = "\n";
243
+ return true;
244
+ }
245
+ return {
246
+ AtRule(atRule, helper) {
247
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
248
+ const text = parseConditionalAtRuleParam(atRule.params);
249
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
250
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
251
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
252
+ return;
253
+ }
254
+ if (atRule.name === "media") {
255
+ const values = [];
256
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
257
+ const value = arr[1];
258
+ if (value) values.push(value);
259
+ });
260
+ if (values.length > 0) {
261
+ const isNegative = atRule.params.includes("not");
262
+ const text = values.join(" ");
263
+ const comment = isNegative ? ifndef(text) : ifdef(text);
264
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
265
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
266
+ }
267
+ }
268
+ },
269
+ CommentExit(comment) {
270
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
271
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
272
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
273
+ }
274
+ }
275
+ };
276
+ }
277
+ };
278
+ };
279
+ creator.postcss = true;
280
+ const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
281
+ function isCssMacroTailwindPlugin(value) {
282
+ return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
283
+ }
284
+ function hasCssMacroTailwindPlugin(plugins) {
285
+ if (!plugins) return false;
286
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
287
+ if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
288
+ return false;
289
+ }
290
+ function parseCssPluginRequest(params) {
291
+ const value = params.trim();
292
+ const quoted = /^(['"])(.*?)\1/.exec(value);
293
+ if (quoted) return quoted[2];
294
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
295
+ return url?.[2] ?? url?.[3];
296
+ }
297
+ function isCssMacroPluginRequest(request) {
298
+ return request === "weapp-tailwindcss/css-macro";
299
+ }
300
+ function hasCssMacroTailwindV4Directive(css) {
301
+ if (!css?.includes("css-macro")) return false;
302
+ try {
303
+ let found = false;
304
+ require_runtime_registry.postcss_default.parse(css).walkAtRules("plugin", (rule) => {
305
+ if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
306
+ });
307
+ return found;
308
+ } catch {
309
+ return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
310
+ }
311
+ }
312
+ function isCssMacroPostcssPlugin(plugin) {
313
+ if (plugin === creator) return true;
314
+ return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
315
+ }
316
+ function withCssMacroPostcssPlugins(plugins) {
317
+ const macroPlugin = creator();
318
+ if (!plugins) return [macroPlugin];
319
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
320
+ if (typeof plugins === "object") {
321
+ const values = Object.values(plugins).filter(Boolean);
322
+ if (values.some(isCssMacroPostcssPlugin)) return values;
323
+ return [...values, macroPlugin];
324
+ }
325
+ return [macroPlugin];
326
+ }
327
+ function withCssMacroStyleOptions(options) {
328
+ const postcssOptions = options?.postcssOptions;
329
+ return {
330
+ ...options,
331
+ [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
332
+ postcssOptions: {
333
+ ...postcssOptions,
334
+ plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
335
+ }
336
+ };
337
+ }
338
+ function hasCssMacroStyleOptions(options) {
339
+ return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
340
+ }
341
+ async function transformCssMacroCss(css) {
342
+ return (await require_runtime_registry.postcss_default([creator()]).process(css, { from: void 0 })).css;
343
+ }
344
+ //#endregion
70
345
  //#region src/context/workspace.ts
71
346
  function findNearestPackageRoot(startDir) {
72
347
  if (!startDir) return;
@@ -87,17 +362,24 @@ function omitUndefined(value) {
87
362
  return Object.fromEntries(definedEntries(value));
88
363
  }
89
364
  //#endregion
365
+ //#region src/utils/options.ts
366
+ function resolveBooleanObjectOption(value, enabledValue) {
367
+ if (!value) return false;
368
+ if (value === true) return enabledValue;
369
+ return value;
370
+ }
371
+ //#endregion
90
372
  //#region src/tailwindcss/patcher-options.ts
91
373
  function resolveTailwindcssOptions(options) {
92
374
  return options?.tailwindcss ?? options?.tailwind;
93
375
  }
94
376
  function normalizeExtendLengthUnits(value) {
95
- if (value === false) return false;
96
- if (value === true) return { enabled: true };
97
- if (value && typeof value === "object") return {
377
+ if (value === void 0) return;
378
+ const resolved = resolveBooleanObjectOption(value, { enabled: true });
379
+ return resolved && typeof resolved === "object" ? {
98
380
  enabled: true,
99
- ...value
100
- };
381
+ ...resolved
382
+ } : resolved;
101
383
  }
102
384
  function normalizeTailwindcssPatcherOptions(options) {
103
385
  return options;
@@ -638,10 +920,12 @@ async function transformTailwindV4CssToWeapp(css, options) {
638
920
  majorVersion: 4,
639
921
  ...options
640
922
  });
641
- return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css));
923
+ const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
924
+ return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
642
925
  }
643
926
  async function transformTailwindV4CssByTarget(css, target, options) {
644
- return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
927
+ if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
928
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
645
929
  }
646
930
  //#endregion
647
931
  //#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
@@ -1542,6 +1826,9 @@ function createIncrementalStyleOptions(styleOptions) {
1542
1826
  isMainChunk: false
1543
1827
  };
1544
1828
  }
1829
+ function resolveStyleOptions$1(source, options) {
1830
+ return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
1831
+ }
1545
1832
  function collectCustomPropertyValues(css) {
1546
1833
  const values = /* @__PURE__ */ new Map();
1547
1834
  try {
@@ -1695,6 +1982,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
1695
1982
  function createTailwindV4Engine(source) {
1696
1983
  async function generateOnce(generateSource, options = {}) {
1697
1984
  const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
1985
+ const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
1698
1986
  const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
1699
1987
  const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1700
1988
  const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources)) : void 0;
@@ -1705,7 +1993,7 @@ function createTailwindV4Engine(source) {
1705
1993
  candidates: normalizedCandidates.candidates
1706
1994
  }));
1707
1995
  const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
1708
- const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
1996
+ const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
1709
1997
  return {
1710
1998
  ...result,
1711
1999
  classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
@@ -1719,8 +2007,9 @@ function createTailwindV4Engine(source) {
1719
2007
  const target = options.target ?? "weapp";
1720
2008
  const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
1721
2009
  const requestedCandidates = resolveTargetCandidates(options.candidates, target);
2010
+ const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
1722
2011
  if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
1723
- const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, options.styleOptions, options.tailwindcssV3Compatibility);
2012
+ const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
1724
2013
  if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1725
2014
  const generated = await generateOnce(source, options);
1726
2015
  seedIncrementalGenerateCache({
@@ -1765,7 +2054,7 @@ function createTailwindV4Engine(source) {
1765
2054
  }
1766
2055
  const rawCss = rawCssParts.join("\n");
1767
2056
  const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
1768
- ...createIncrementalStyleOptions(options.styleOptions),
2057
+ ...createIncrementalStyleOptions(styleOptions),
1769
2058
  customPropertyValues: cached.customPropertyValues
1770
2059
  }) : "";
1771
2060
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
@@ -1793,7 +2082,7 @@ function createTailwindV4Engine(source) {
1793
2082
  compatibleSource,
1794
2083
  generated,
1795
2084
  requestedCandidates,
1796
- styleOptions: options.styleOptions,
2085
+ styleOptions,
1797
2086
  tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
1798
2087
  target
1799
2088
  });
@@ -2336,16 +2625,22 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2336
2625
  }
2337
2626
  }
2338
2627
  async function transformTailwindV3CssToWeapp(css, options) {
2339
- return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)((await defaultStyleHandler(css, {
2628
+ const result = await defaultStyleHandler(css, {
2340
2629
  cssChildCombinatorReplaceValue: ["view", "text"],
2341
2630
  cssRemoveHoverPseudoClass: true,
2342
2631
  isMainChunk: true,
2343
2632
  majorVersion: 3,
2344
2633
  ...options
2345
- })).css, { preservePreflight: true }), options?.cssPreflight);
2634
+ });
2635
+ const pruneOptions = {
2636
+ preservePreflight: true,
2637
+ preserveConditionalComments: hasCssMacroStyleOptions(options)
2638
+ };
2639
+ return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
2346
2640
  }
2347
2641
  async function transformTailwindV3CssByTarget(css, target, options) {
2348
- return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
2642
+ if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
2643
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
2349
2644
  }
2350
2645
  //#endregion
2351
2646
  //#region src/tailwindcss/v3-engine/generator.ts
@@ -2408,7 +2703,7 @@ function extractClassCandidatesFromSelector(selector, candidates) {
2408
2703
  escaped = true;
2409
2704
  continue;
2410
2705
  }
2411
- if (/[\w-]/.test(char)) {
2706
+ if (char && /[\w-]/.test(char)) {
2412
2707
  candidate += char;
2413
2708
  continue;
2414
2709
  }
@@ -2469,6 +2764,12 @@ function createTailwindConfig(source, options) {
2469
2764
  config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
2470
2765
  return config;
2471
2766
  }
2767
+ function shouldAutoEnableCssMacro(source) {
2768
+ return hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
2769
+ }
2770
+ function resolveStyleOptions(source, options) {
2771
+ return shouldAutoEnableCssMacro(source) ? withCssMacroStyleOptions(options) : options;
2772
+ }
2472
2773
  function loadTailwindV3Internals(source) {
2473
2774
  const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
2474
2775
  const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
@@ -2603,6 +2904,7 @@ function createTailwindV3Engine(source) {
2603
2904
  tailwindInternals ??= loadTailwindV3Internals(source);
2604
2905
  const internals = tailwindInternals;
2605
2906
  const { styleOptions, target = "weapp" } = options;
2907
+ const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
2606
2908
  const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, options)));
2607
2909
  const candidates = mergeGenerateCandidates(generateSource, options);
2608
2910
  const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
@@ -2627,7 +2929,7 @@ function createTailwindV3Engine(source) {
2627
2929
  context = await internals.processTailwindFeatures(setupContext)(root, result);
2628
2930
  }
2629
2931
  const rawCss = root.toString();
2630
- const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
2932
+ const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
2631
2933
  const dependencies = collectDependencyMessages(result);
2632
2934
  for (const dependency of generateSource.dependencies) dependencies.add(dependency);
2633
2935
  const classSet = collectClassSet(context);
@@ -2658,7 +2960,7 @@ function createTailwindV3Engine(source) {
2658
2960
  internals.collapseDuplicateDeclarations(context)(root, result);
2659
2961
  const rawCss = root.toString();
2660
2962
  return {
2661
- css: await transformTailwindV3CssByTarget(rawCss, target, styleOptions),
2963
+ css: await transformTailwindV3CssByTarget(rawCss, target, resolveStyleOptions(source, styleOptions)),
2662
2964
  rawCss,
2663
2965
  classSet: collectClassSet(context),
2664
2966
  dependencies: collectDependencyMessages(result)
@@ -2669,7 +2971,8 @@ function createTailwindV3Engine(source) {
2669
2971
  const target = options.target ?? "weapp";
2670
2972
  const requestedCandidates = mergeGenerateCandidates(source, options);
2671
2973
  if (requestedCandidates.size === 0) return generateOnce(source, options);
2672
- const cacheKey = createIncrementalGenerateCacheKey(source, target, options.styleOptions);
2974
+ const styleOptions = resolveStyleOptions(source, options.styleOptions);
2975
+ const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions);
2673
2976
  const cached = incrementalGenerateCache.get(cacheKey);
2674
2977
  if (cached) {
2675
2978
  const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
@@ -2686,7 +2989,7 @@ function createTailwindV3Engine(source) {
2686
2989
  target: cached.target,
2687
2990
  version: 3
2688
2991
  };
2689
- const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, options.styleOptions);
2992
+ const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions);
2690
2993
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
2691
2994
  for (const className of generated.classSet) cached.classSet.add(className);
2692
2995
  cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
@@ -2865,43 +3168,6 @@ function createWeappTailwindcssGenerator(source) {
2865
3168
  return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
2866
3169
  }
2867
3170
  //#endregion
2868
- //#region src/uni-app-x/options.ts
2869
- function resolveComponentLocalStyles(option) {
2870
- if (option === false) return {
2871
- enabled: false,
2872
- onlyWhenStyleIsolationVersion2: true
2873
- };
2874
- if (option === true || option === void 0) return {
2875
- enabled: false,
2876
- onlyWhenStyleIsolationVersion2: true
2877
- };
2878
- const componentLocalStyles = option.componentLocalStyles;
2879
- if (componentLocalStyles === false) return {
2880
- enabled: false,
2881
- onlyWhenStyleIsolationVersion2: true
2882
- };
2883
- if (componentLocalStyles === true || componentLocalStyles === void 0) return {
2884
- enabled: true,
2885
- onlyWhenStyleIsolationVersion2: true
2886
- };
2887
- return {
2888
- enabled: componentLocalStyles.enabled !== false,
2889
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
2890
- };
2891
- }
2892
- function resolveUniAppXOptions(option) {
2893
- if (typeof option === "object" && option) return {
2894
- enabled: option.enabled !== false,
2895
- componentLocalStyles: resolveComponentLocalStyles(option),
2896
- uvueUnsupported: option.uvueUnsupported ?? "warn"
2897
- };
2898
- return {
2899
- enabled: Boolean(option),
2900
- componentLocalStyles: resolveComponentLocalStyles(option),
2901
- uvueUnsupported: "warn"
2902
- };
2903
- }
2904
- //#endregion
2905
3171
  //#region src/bundlers/shared/generator-css/markers.ts
2906
3172
  const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
2907
3173
  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)-/;
@@ -4354,20 +4620,9 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
4354
4620
  cssPreflight: opts.cssPreflight,
4355
4621
  cssPreflightRange: opts.cssPreflightRange
4356
4622
  };
4357
- const resolvedUniAppXOptions = resolveUniAppXOptions(opts.uniAppX);
4358
4623
  return {
4359
- cssChildCombinatorReplaceValue: opts.cssChildCombinatorReplaceValue,
4360
- cssSelectorReplacement: opts.cssSelectorReplacement,
4361
- rem2rpx: opts.rem2rpx,
4362
- px2rpx: opts.px2rpx,
4363
- unitsToPx: opts.unitsToPx,
4364
- cssRemoveProperty: opts.cssRemoveProperty,
4365
- cssRemoveHoverPseudoClass: opts.cssRemoveHoverPseudoClass,
4366
- cssPresetEnv: opts.cssPresetEnv,
4367
- autoprefixer: opts.autoprefixer,
4368
- cssCalc: opts.cssCalc,
4624
+ ...resolveStyleOptionsFromContext(opts),
4369
4625
  atRules: opts.atRules,
4370
- uniAppX: resolvedUniAppXOptions.enabled,
4371
4626
  uniAppXCssTarget: opts.uniAppXCssTarget,
4372
4627
  uniAppXUnsupported: opts.uniAppXUnsupported,
4373
4628
  ...cssHandlerOptions,
@@ -4599,7 +4854,6 @@ async function generateCssByGenerator(options) {
4599
4854
  }
4600
4855
  //#endregion
4601
4856
  //#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
4602
- const getLoaderOptions = loader_utils.default.getOptions;
4603
4857
  function resolveLoaderOptions(options) {
4604
4858
  const runtime = require_runtime_registry.getWebpackLoaderRuntime(options?.tailwindcssImportRewriteRuntimeKey)?.cssImportRewrite;
4605
4859
  return runtime ? {
@@ -4685,7 +4939,7 @@ function transformCssImportRewriteSource(source, options) {
4685
4939
  }
4686
4940
  const WeappTwCssImportRewriteLoader = function(source) {
4687
4941
  if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-css-import-rewrite-loader] executing for ${this.resourcePath}\n`);
4688
- const opt = resolveLoaderOptions(getLoaderOptions(this));
4942
+ const opt = resolveLoaderOptions(this.getOptions());
4689
4943
  const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
4690
4944
  const hasTailwindRoot = typeof input === "string" && hasTailwindRootDirectives(input, { importFallback: true });
4691
4945
  const registerTask = hasTailwindRoot ? opt?.tailwindcssImportRewrite?.registerCssSource?.({
@@ -2,14 +2,11 @@ const require_runtime_registry = require("./runtime-registry-CdCV3Opt.js");
2
2
  let node_buffer = require("node:buffer");
3
3
  let node_process = require("node:process");
4
4
  node_process = require_runtime_registry.__toESM(node_process);
5
- let loader_utils = require("loader-utils");
6
- loader_utils = require_runtime_registry.__toESM(loader_utils);
7
5
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
8
6
  //#region src/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.ts
9
7
  function isPromiseLike(value) {
10
8
  return Boolean(value && typeof value.then === "function");
11
9
  }
12
- const getLoaderOptions = loader_utils.default.getOptions;
13
10
  function normalizeRuntimeCssSource(source) {
14
11
  if (node_buffer.Buffer.isBuffer(source)) {
15
12
  const css = source.toString("utf8");
@@ -35,7 +32,7 @@ function removeUnsupportedThemeKeyframes(root) {
35
32
  }
36
33
  const WeappTwRuntimeClassSetLoader = function(source) {
37
34
  if (node_process.default.env["WEAPP_TW_LOADER_DEBUG"]) node_process.default.stdout.write(`[weapp-tw-runtime-classset-loader] executing for ${this.resourcePath}\n`);
38
- const rawOptions = getLoaderOptions(this);
35
+ const rawOptions = this.getOptions();
39
36
  const opt = require_runtime_registry.getWebpackLoaderRuntime(rawOptions?.weappTailwindcssRuntimeKey)?.classSet ?? rawOptions;
40
37
  const maybePromise = opt?.getClassSet?.();
41
38
  const applyWatchDependencies = (dependencies) => {
@@ -1,10 +1,11 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-vHlppqaZ.js");
3
- const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CWdfLHON.js");
4
- const require_precheck = require("./precheck-DtYqujIx.js");
5
- const require_utils = require("./utils-4ODFyoqD.js");
6
- const require_tailwindcss = require("./tailwindcss-BtUBeOes.js");
7
- const require_bundle_state = require("./bundle-state-DXFq2nEo.js");
2
+ const require_v3_engine = require("./v3-engine-CGsbY81C.js");
3
+ const require_generator = require("./generator-BH6a0xuB.js");
4
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-mY0v1k-Y.js");
5
+ const require_precheck = require("./precheck-DLJg0_pu.js");
6
+ const require_utils = require("./utils-CSA174-I.js");
7
+ const require_tailwindcss = require("./tailwindcss-Cm93idme.js");
8
+ const require_bundle_state = require("./bundle-state-uCtqRm0p.js");
8
9
  let node_fs = require("node:fs");
9
10
  node_fs = require_chunk.__toESM(node_fs);
10
11
  let node_module = require("node:module");
@@ -687,7 +688,9 @@ var UnifiedWebpackPluginV5 = class {
687
688
  compiler.options = compiler.options || {};
688
689
  const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
689
690
  const disabledOptions = require_bundle_state.resolvePluginDisabledState(disabled);
690
- const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4;
691
+ const isTailwindcssV4 = (initialTwPatcher.majorVersion ?? 0) >= 4;
692
+ const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(this.options.generator);
693
+ const shouldRewriteCssImports = isTailwindcssV4 || generatorOptions.target === "web";
691
694
  const isMpxApp = isMpx(this.appType);
692
695
  if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
693
696
  if (disabledOptions.plugin) return;
@@ -1,9 +1,10 @@
1
- import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-CXqgQZUc.mjs";
2
- import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-Bux7viee.mjs";
3
- import { _ as ensureRuntimeClassSet, f as pluginName, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, s as _defineProperty, t as shouldSkipJsTransform, v as refreshTailwindRuntimeState } from "./precheck-DreRGvYH.mjs";
4
- import { r as getGroupedEntries } from "./utils-CGBVVNm6.mjs";
5
- import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-DO-VVR5k.mjs";
6
- import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-CP_BWXfx.mjs";
1
+ import { B as createDebug, W as resolveTailwindcssOptions, l as getRuntimeClassSetSignature } from "./v3-engine-CPJ9uGyr.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-iI_265gt.mjs";
3
+ import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-ECHyKwUL.mjs";
4
+ import { b as refreshTailwindRuntimeState, d as _defineProperty, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-BI8oBeUg.mjs";
5
+ import { r as getGroupedEntries } from "./utils-B2SJgA1L.mjs";
6
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-DFa5Yes8.mjs";
7
+ import { _ as stripRequestQuery, b as toAbsoluteOutputPath, d as resolvePluginDisabledState, g as isSourceStyleRequest, l as stripBundlerGeneratedCssMarkers, n as createBundleBuildState, o as pushConcurrentTaskFactories, r as updateBundleBuildState, t as buildBundleSnapshot, u as resolvePackageDir, y as resolveOutputSpecifier } from "./bundle-state-CWcrb3mH.mjs";
7
8
  import Module, { createRequire } from "node:module";
8
9
  import fs from "node:fs";
9
10
  import path from "node:path";
@@ -532,7 +533,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
532
533
  });
533
534
  }
534
535
  //#endregion
535
- //#region ../../node_modules/.pnpm/tsdown@0.22.0_oxc-resolver@11.19.1_@emnapi+core@1.10.0_@emnapi+runtime@1.10.0__tsx@4.22_d5fec98bd6da0af22d9e6961a46a32e3/node_modules/tsdown/esm-shims.js
536
+ //#region ../../node_modules/.pnpm/tsdown@0.22.0_oxc-resolver@11.19.1_@emnapi+core@1.10.0_@emnapi+runtime@1.10.0__tsx@4.22_d9b0fe6ae33481a579c49980b4e80572/node_modules/tsdown/esm-shims.js
536
537
  const getFilename = () => fileURLToPath(import.meta.url);
537
538
  const getDirname = () => path.dirname(getFilename());
538
539
  const __dirname = /* @__PURE__ */ getDirname();
@@ -688,7 +689,9 @@ var UnifiedWebpackPluginV5 = class {
688
689
  compiler.options = compiler.options || {};
689
690
  const { disabled, onLoad, runtimeLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
690
691
  const disabledOptions = resolvePluginDisabledState(disabled);
691
- const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4;
692
+ const isTailwindcssV4 = (initialTwPatcher.majorVersion ?? 0) >= 4;
693
+ const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(this.options.generator);
694
+ const shouldRewriteCssImports = isTailwindcssV4 || generatorOptions.target === "web";
692
695
  const isMpxApp = isMpx(this.appType);
693
696
  if (shouldRewriteCssImports) setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
694
697
  if (disabledOptions.plugin) return;
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_webpack = require("./webpack-prCus5xn.js");
2
+ const require_webpack = require("./webpack-CfcuDhQ8.js");
3
3
  exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
4
4
  exports.WeappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
5
5
  exports.weappTailwindcss = require_webpack.UnifiedWebpackPluginV5;