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

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 (73) hide show
  1. package/dist/auto-AduSz49t.mjs +80 -0
  2. package/dist/auto-B11j1XiD.js +117 -0
  3. package/dist/{bundle-state-DXFq2nEo.js → bundle-state-BY7PWHAc.js} +1 -1
  4. package/dist/{bundle-state-CP_BWXfx.mjs → bundle-state-CBouNDzi.mjs} +1 -1
  5. package/dist/cli.js +167 -5
  6. package/dist/cli.mjs +166 -4
  7. package/dist/context/runtime-package-replacements.d.ts +2 -0
  8. package/dist/context/style-options.d.ts +3 -0
  9. package/dist/core.js +1 -1
  10. package/dist/core.mjs +1 -1
  11. package/dist/css-macro/auto.d.ts +10 -0
  12. package/dist/css-macro/constants.d.ts +5 -2
  13. package/dist/css-macro/postcss.d.ts +1 -0
  14. package/dist/css-macro/postcss.js +7 -47
  15. package/dist/css-macro/postcss.mjs +2 -47
  16. package/dist/css-macro.js +15 -6
  17. package/dist/css-macro.mjs +15 -6
  18. package/dist/{defaults-C6sIKXgC.mjs → defaults-B-1EEhdL.mjs} +2 -1
  19. package/dist/{defaults-D3cFX6Cq.js → defaults-C10hYUch.js} +2 -1
  20. package/dist/defaults.js +1 -1
  21. package/dist/defaults.mjs +1 -1
  22. package/dist/{generator-DdEgn8nG.mjs → generator-CtqzN9L-.mjs} +1 -1
  23. package/dist/{generator-BcH28HU-.js → generator-DTPePQZ9.js} +1 -1
  24. package/dist/generator.js +2 -2
  25. package/dist/generator.mjs +2 -2
  26. package/dist/gulp.js +5 -5
  27. package/dist/gulp.mjs +5 -5
  28. package/dist/{incremental-runtime-class-set-Bux7viee.mjs → incremental-runtime-class-set-BlJ86j-A.mjs} +4 -16
  29. package/dist/{incremental-runtime-class-set-CWdfLHON.js → incremental-runtime-class-set-CERcE0fP.js} +4 -16
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +18 -4
  32. package/dist/index.mjs +6 -5
  33. package/dist/{postcss-cD5PXmMU.js → postcss-BAO9tGi5.js} +2 -2
  34. package/dist/{postcss-nk5bhdoV.mjs → postcss-CYPHxj7a.mjs} +2 -2
  35. package/dist/postcss-DXkxsPNg.js +192 -0
  36. package/dist/postcss-DYktK8_T.mjs +169 -0
  37. package/dist/postcss.js +1 -1
  38. package/dist/postcss.mjs +1 -1
  39. package/dist/{precheck-DreRGvYH.mjs → precheck-B4CpMt_w.mjs} +69 -32
  40. package/dist/{precheck-DtYqujIx.js → precheck-ezN3ovAq.js} +75 -32
  41. package/dist/presets/uni-app-x.d.ts +1 -0
  42. package/dist/presets.js +5 -4
  43. package/dist/presets.mjs +5 -4
  44. package/dist/{source-candidates-lHtAHLQq.js → source-candidates-0jPRIPmC.js} +1 -1
  45. package/dist/{source-candidates-B7wmEa-G.mjs → source-candidates-DoyOltpZ.mjs} +1 -1
  46. package/dist/{tailwindcss-BtUBeOes.js → tailwindcss-nQetCaPp.js} +17 -26
  47. package/dist/{tailwindcss-DO-VVR5k.mjs → tailwindcss-ujlr9Iad.mjs} +17 -26
  48. package/dist/types/index.d.ts +1 -1
  49. package/dist/types/shared.d.ts +3 -0
  50. package/dist/types/user-defined-options/general.d.ts +2 -1
  51. package/dist/types/user-defined-options/important.d.ts +3 -1
  52. package/dist/unocss/index.d.ts +2 -0
  53. package/dist/utils/options.d.ts +2 -0
  54. package/dist/utils/regex.d.ts +1 -0
  55. package/dist/{v3-engine-vHlppqaZ.js → v3-engine-Bbsrez2w.js} +67 -19
  56. package/dist/{v3-engine-CXqgQZUc.mjs → v3-engine-COw08vWd.mjs} +56 -20
  57. package/dist/{vite-BkNDGBZ2.js → vite-DE8Vfzal.js} +9 -9
  58. package/dist/{vite-BthAm8kt.mjs → vite-hZsQAY1a.mjs} +9 -9
  59. package/dist/vite.js +1 -1
  60. package/dist/vite.mjs +1 -1
  61. package/dist/weapp-tw-css-import-rewrite-loader.js +329 -72
  62. package/dist/weapp-tw-runtime-classset-loader.js +1 -4
  63. package/dist/{webpack-prCus5xn.js → webpack-CTJcw_sX.js} +6 -6
  64. package/dist/{webpack-hPc8wUAi.mjs → webpack-c2WJnCJI.mjs} +6 -6
  65. package/dist/webpack.js +1 -1
  66. package/dist/webpack.mjs +1 -1
  67. package/package.json +9 -11
  68. package/dist/constants-BG12WAKw.mjs +0 -44
  69. package/dist/constants-BeeyfJ9k.js +0 -73
  70. /package/dist/{logger-EVNB9z7i.js → logger-Cdzl3p8j.js} +0 -0
  71. /package/dist/{logger-CZUxvJJD.mjs → logger-Dr7IvyH2.mjs} +0 -0
  72. /package/dist/{utils-CGBVVNm6.mjs → utils-B2SJgA1L.mjs} +0 -0
  73. /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);
@@ -67,6 +65,286 @@ function createBundlerGeneratedCssMarker(bundler, file) {
67
65
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
68
66
  }
69
67
  //#endregion
68
+ //#region src/uni-app-x/options.ts
69
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
70
+ enabled: true,
71
+ onlyWhenStyleIsolationVersion2: true
72
+ };
73
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
74
+ enabled: false,
75
+ onlyWhenStyleIsolationVersion2: true
76
+ };
77
+ function isBooleanUniAppXShortcut(option) {
78
+ return option === true || option === false || option === void 0;
79
+ }
80
+ function resolveComponentLocalStyles(option) {
81
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
82
+ const componentLocalStyles = option.componentLocalStyles;
83
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
84
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
85
+ return {
86
+ enabled: componentLocalStyles.enabled !== false,
87
+ onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
88
+ };
89
+ }
90
+ function resolveUniAppXOptions(option) {
91
+ if (typeof option === "object" && option) return {
92
+ enabled: option.enabled !== false,
93
+ componentLocalStyles: resolveComponentLocalStyles(option),
94
+ uvueUnsupported: option.uvueUnsupported ?? "warn"
95
+ };
96
+ return {
97
+ enabled: Boolean(option),
98
+ componentLocalStyles: resolveComponentLocalStyles(option),
99
+ uvueUnsupported: "warn"
100
+ };
101
+ }
102
+ //#endregion
103
+ //#region src/context/style-options.ts
104
+ function resolveStyleOptionsFromContext(ctx) {
105
+ const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
106
+ return {
107
+ cssPreflight: ctx.cssPreflight,
108
+ cssPreflightRange: ctx.cssPreflightRange,
109
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
110
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
111
+ rem2rpx: ctx.rem2rpx,
112
+ cssRemoveProperty: ctx.cssRemoveProperty,
113
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
114
+ cssPresetEnv: ctx.cssPresetEnv,
115
+ autoprefixer: ctx.autoprefixer,
116
+ cssCalc: ctx.cssCalc,
117
+ uniAppX: resolvedUniAppXOptions.enabled,
118
+ platform: ctx.platform,
119
+ px2rpx: ctx.px2rpx,
120
+ unitsToPx: ctx.unitsToPx,
121
+ unitConversion: ctx.unitConversion
122
+ };
123
+ }
124
+ //#endregion
125
+ //#region src/css-macro/constants.ts
126
+ const queryKey = "weapp-tw-platform";
127
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
128
+ const WHITESPACE_RE = /\s+/g;
129
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
130
+ function normalComment(text) {
131
+ if (typeof text === "string") {
132
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
133
+ if (normalized.includes("\\")) return normalized;
134
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
135
+ }
136
+ return text;
137
+ }
138
+ function ifdef(text) {
139
+ return {
140
+ start: `#ifdef ${normalComment(text)}`,
141
+ end: `#endif`
142
+ };
143
+ }
144
+ function ifndef(text) {
145
+ return {
146
+ start: `#ifndef ${normalComment(text)}`,
147
+ end: `#endif`
148
+ };
149
+ }
150
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
151
+ function matchCustomPropertyFromValue(str, cb) {
152
+ let index = 0;
153
+ QUERY_KEY_REGEX.lastIndex = 0;
154
+ let arr = QUERY_KEY_REGEX.exec(str);
155
+ while (arr !== null) {
156
+ cb(arr, index);
157
+ index++;
158
+ arr = QUERY_KEY_REGEX.exec(str);
159
+ }
160
+ }
161
+ function parseConditionalAtRuleParam(params) {
162
+ const value = params.trim();
163
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
164
+ if (!quoted) return value;
165
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
166
+ }
167
+ //#endregion
168
+ //#region src/css-macro/postcss.ts
169
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
170
+ const CONDITIONAL_COMMENT_SPACING = " ";
171
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
172
+ const creator = () => {
173
+ return {
174
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
175
+ prepare() {
176
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
177
+ const hasPreviousNode = Boolean(atRule.prev());
178
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
179
+ const startComment = helper.comment({
180
+ raws: {
181
+ left: CONDITIONAL_COMMENT_SPACING,
182
+ right: CONDITIONAL_COMMENT_SPACING
183
+ },
184
+ text: comment.start
185
+ });
186
+ const endComment = helper.comment({
187
+ raws: {
188
+ left: CONDITIONAL_COMMENT_SPACING,
189
+ right: CONDITIONAL_COMMENT_SPACING
190
+ },
191
+ text: comment.end
192
+ });
193
+ const nextNodes = [
194
+ startComment,
195
+ ...clonedNodes,
196
+ endComment
197
+ ];
198
+ atRule.replaceWith(nextNodes);
199
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
200
+ startComment.raws.after = "\n";
201
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
202
+ endComment.raws.before = "\n";
203
+ endComment.raws.after = "\n";
204
+ const nextNode = endComment?.next();
205
+ if (nextNode) nextNode.raws.before = "\n";
206
+ }
207
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
208
+ if (atRule.parent?.type !== "rule") return false;
209
+ const parentRule = atRule.parent;
210
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
211
+ const conditionalRule = parentRule.clone();
212
+ conditionalRule.removeAll();
213
+ conditionalRule.append(...clonedNodes);
214
+ const startComment = helper.comment({
215
+ raws: {
216
+ left: CONDITIONAL_COMMENT_SPACING,
217
+ right: CONDITIONAL_COMMENT_SPACING
218
+ },
219
+ text: comment.start
220
+ });
221
+ const endComment = helper.comment({
222
+ raws: {
223
+ left: CONDITIONAL_COMMENT_SPACING,
224
+ right: CONDITIONAL_COMMENT_SPACING
225
+ },
226
+ text: comment.end
227
+ });
228
+ const nextNodes = [
229
+ startComment,
230
+ conditionalRule,
231
+ endComment
232
+ ];
233
+ const hasPreviousNode = Boolean(parentRule.prev());
234
+ atRule.remove();
235
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
236
+ else parentRule.after(nextNodes);
237
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
238
+ startComment.raws.after = "\n";
239
+ conditionalRule.raws.before = "\n";
240
+ endComment.raws.before = "\n";
241
+ endComment.raws.after = "\n";
242
+ const nextNode = endComment.next();
243
+ if (nextNode) nextNode.raws.before = "\n";
244
+ return true;
245
+ }
246
+ return {
247
+ AtRule(atRule, helper) {
248
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
249
+ const text = parseConditionalAtRuleParam(atRule.params);
250
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
251
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
252
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
253
+ return;
254
+ }
255
+ if (atRule.name === "media") {
256
+ const values = [];
257
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
258
+ const value = arr[1];
259
+ if (value) values.push(value);
260
+ });
261
+ if (values.length > 0) {
262
+ const isNegative = atRule.params.includes("not");
263
+ const text = values.join(" ");
264
+ const comment = isNegative ? ifndef(text) : ifdef(text);
265
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
266
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
267
+ }
268
+ }
269
+ },
270
+ CommentExit(comment) {
271
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
272
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
273
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
274
+ }
275
+ }
276
+ };
277
+ }
278
+ };
279
+ };
280
+ creator.postcss = true;
281
+ const CSS_MACRO_STYLE_OPTIONS_MARKER = "__weappTailwindcssCssMacroEnabled";
282
+ function isCssMacroTailwindPlugin(value) {
283
+ return Boolean(value && (typeof value === "function" || typeof value === "object") && value["__weappTailwindcssCssMacro"] === true);
284
+ }
285
+ function hasCssMacroTailwindPlugin(plugins) {
286
+ if (!plugins) return false;
287
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroTailwindPlugin);
288
+ if (typeof plugins === "object") return Object.values(plugins).some(isCssMacroTailwindPlugin);
289
+ return false;
290
+ }
291
+ function parseCssPluginRequest(params) {
292
+ const value = params.trim();
293
+ const quoted = /^(['"])(.*?)\1/.exec(value);
294
+ if (quoted) return quoted[2];
295
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
296
+ return url?.[2] ?? url?.[3];
297
+ }
298
+ function isCssMacroPluginRequest(request) {
299
+ return request === "weapp-tailwindcss/css-macro";
300
+ }
301
+ function hasCssMacroTailwindV4Directive(css) {
302
+ if (!css?.includes("css-macro")) return false;
303
+ try {
304
+ let found = false;
305
+ require_runtime_registry.postcss_default.parse(css).walkAtRules("plugin", (rule) => {
306
+ if (isCssMacroPluginRequest(parseCssPluginRequest(rule.params))) found = true;
307
+ });
308
+ return found;
309
+ } catch {
310
+ return /@plugin\s+(?:url\(\s*)?["']weapp-tailwindcss\/css-macro["']/.test(css);
311
+ }
312
+ }
313
+ function isCssMacroPostcssPlugin(plugin) {
314
+ if (plugin === creator) return true;
315
+ return Boolean(plugin && (typeof plugin === "function" || typeof plugin === "object") && plugin.postcssPlugin === "postcss-weapp-tw-css-macro-plugin");
316
+ }
317
+ function withCssMacroPostcssPlugins(plugins) {
318
+ const macroPlugin = creator();
319
+ if (!plugins) return [macroPlugin];
320
+ if (Array.isArray(plugins)) return plugins.some(isCssMacroPostcssPlugin) ? plugins : [...plugins, macroPlugin];
321
+ if (typeof plugins === "object") {
322
+ if (Object.values(plugins).some(isCssMacroPostcssPlugin)) return plugins;
323
+ return {
324
+ ...plugins,
325
+ [CSS_MACRO_POSTCSS_PLUGIN_NAME]: macroPlugin
326
+ };
327
+ }
328
+ return [macroPlugin];
329
+ }
330
+ function withCssMacroStyleOptions(options) {
331
+ const postcssOptions = options?.postcssOptions;
332
+ return {
333
+ ...options,
334
+ [CSS_MACRO_STYLE_OPTIONS_MARKER]: true,
335
+ postcssOptions: {
336
+ ...postcssOptions,
337
+ plugins: withCssMacroPostcssPlugins(postcssOptions?.plugins)
338
+ }
339
+ };
340
+ }
341
+ function hasCssMacroStyleOptions(options) {
342
+ return Boolean(options?.[CSS_MACRO_STYLE_OPTIONS_MARKER]);
343
+ }
344
+ async function transformCssMacroCss(css) {
345
+ return (await require_runtime_registry.postcss_default([creator()]).process(css, { from: void 0 })).css;
346
+ }
347
+ //#endregion
70
348
  //#region src/context/workspace.ts
71
349
  function findNearestPackageRoot(startDir) {
72
350
  if (!startDir) return;
@@ -87,17 +365,24 @@ function omitUndefined(value) {
87
365
  return Object.fromEntries(definedEntries(value));
88
366
  }
89
367
  //#endregion
368
+ //#region src/utils/options.ts
369
+ function resolveBooleanObjectOption(value, enabledValue) {
370
+ if (!value) return false;
371
+ if (value === true) return enabledValue;
372
+ return value;
373
+ }
374
+ //#endregion
90
375
  //#region src/tailwindcss/patcher-options.ts
91
376
  function resolveTailwindcssOptions(options) {
92
377
  return options?.tailwindcss ?? options?.tailwind;
93
378
  }
94
379
  function normalizeExtendLengthUnits(value) {
95
- if (value === false) return false;
96
- if (value === true) return { enabled: true };
97
- if (value && typeof value === "object") return {
380
+ if (value === void 0) return;
381
+ const resolved = resolveBooleanObjectOption(value, { enabled: true });
382
+ return resolved && typeof resolved === "object" ? {
98
383
  enabled: true,
99
- ...value
100
- };
384
+ ...resolved
385
+ } : resolved;
101
386
  }
102
387
  function normalizeTailwindcssPatcherOptions(options) {
103
388
  return options;
@@ -638,10 +923,12 @@ async function transformTailwindV4CssToWeapp(css, options) {
638
923
  majorVersion: 4,
639
924
  ...options
640
925
  });
641
- return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css));
926
+ const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
927
+ return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
642
928
  }
643
929
  async function transformTailwindV4CssByTarget(css, target, options) {
644
- return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
930
+ if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
931
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
645
932
  }
646
933
  //#endregion
647
934
  //#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
@@ -1542,6 +1829,9 @@ function createIncrementalStyleOptions(styleOptions) {
1542
1829
  isMainChunk: false
1543
1830
  };
1544
1831
  }
1832
+ function resolveStyleOptions$1(source, options) {
1833
+ return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
1834
+ }
1545
1835
  function collectCustomPropertyValues(css) {
1546
1836
  const values = /* @__PURE__ */ new Map();
1547
1837
  try {
@@ -1695,6 +1985,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
1695
1985
  function createTailwindV4Engine(source) {
1696
1986
  async function generateOnce(generateSource, options = {}) {
1697
1987
  const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
1988
+ const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
1698
1989
  const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
1699
1990
  const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1700
1991
  const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources)) : void 0;
@@ -1705,7 +1996,7 @@ function createTailwindV4Engine(source) {
1705
1996
  candidates: normalizedCandidates.candidates
1706
1997
  }));
1707
1998
  const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
1708
- const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
1999
+ const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
1709
2000
  return {
1710
2001
  ...result,
1711
2002
  classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
@@ -1719,8 +2010,9 @@ function createTailwindV4Engine(source) {
1719
2010
  const target = options.target ?? "weapp";
1720
2011
  const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
1721
2012
  const requestedCandidates = resolveTargetCandidates(options.candidates, target);
2013
+ const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
1722
2014
  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);
2015
+ const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
1724
2016
  if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1725
2017
  const generated = await generateOnce(source, options);
1726
2018
  seedIncrementalGenerateCache({
@@ -1765,7 +2057,7 @@ function createTailwindV4Engine(source) {
1765
2057
  }
1766
2058
  const rawCss = rawCssParts.join("\n");
1767
2059
  const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
1768
- ...createIncrementalStyleOptions(options.styleOptions),
2060
+ ...createIncrementalStyleOptions(styleOptions),
1769
2061
  customPropertyValues: cached.customPropertyValues
1770
2062
  }) : "";
1771
2063
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
@@ -1793,7 +2085,7 @@ function createTailwindV4Engine(source) {
1793
2085
  compatibleSource,
1794
2086
  generated,
1795
2087
  requestedCandidates,
1796
- styleOptions: options.styleOptions,
2088
+ styleOptions,
1797
2089
  tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
1798
2090
  target
1799
2091
  });
@@ -2336,16 +2628,22 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2336
2628
  }
2337
2629
  }
2338
2630
  async function transformTailwindV3CssToWeapp(css, options) {
2339
- return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)((await defaultStyleHandler(css, {
2631
+ const result = await defaultStyleHandler(css, {
2340
2632
  cssChildCombinatorReplaceValue: ["view", "text"],
2341
2633
  cssRemoveHoverPseudoClass: true,
2342
2634
  isMainChunk: true,
2343
2635
  majorVersion: 3,
2344
2636
  ...options
2345
- })).css, { preservePreflight: true }), options?.cssPreflight);
2637
+ });
2638
+ const pruneOptions = {
2639
+ preservePreflight: true,
2640
+ preserveConditionalComments: hasCssMacroStyleOptions(options)
2641
+ };
2642
+ return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
2346
2643
  }
2347
2644
  async function transformTailwindV3CssByTarget(css, target, options) {
2348
- return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
2645
+ if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
2646
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
2349
2647
  }
2350
2648
  //#endregion
2351
2649
  //#region src/tailwindcss/v3-engine/generator.ts
@@ -2408,7 +2706,7 @@ function extractClassCandidatesFromSelector(selector, candidates) {
2408
2706
  escaped = true;
2409
2707
  continue;
2410
2708
  }
2411
- if (/[\w-]/.test(char)) {
2709
+ if (char && /[\w-]/.test(char)) {
2412
2710
  candidate += char;
2413
2711
  continue;
2414
2712
  }
@@ -2469,6 +2767,12 @@ function createTailwindConfig(source, options) {
2469
2767
  config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
2470
2768
  return config;
2471
2769
  }
2770
+ function shouldAutoEnableCssMacro(source) {
2771
+ return hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
2772
+ }
2773
+ function resolveStyleOptions(source, options) {
2774
+ return shouldAutoEnableCssMacro(source) ? withCssMacroStyleOptions(options) : options;
2775
+ }
2472
2776
  function loadTailwindV3Internals(source) {
2473
2777
  const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
2474
2778
  const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
@@ -2603,6 +2907,7 @@ function createTailwindV3Engine(source) {
2603
2907
  tailwindInternals ??= loadTailwindV3Internals(source);
2604
2908
  const internals = tailwindInternals;
2605
2909
  const { styleOptions, target = "weapp" } = options;
2910
+ const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
2606
2911
  const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, options)));
2607
2912
  const candidates = mergeGenerateCandidates(generateSource, options);
2608
2913
  const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
@@ -2627,7 +2932,7 @@ function createTailwindV3Engine(source) {
2627
2932
  context = await internals.processTailwindFeatures(setupContext)(root, result);
2628
2933
  }
2629
2934
  const rawCss = root.toString();
2630
- const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
2935
+ const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
2631
2936
  const dependencies = collectDependencyMessages(result);
2632
2937
  for (const dependency of generateSource.dependencies) dependencies.add(dependency);
2633
2938
  const classSet = collectClassSet(context);
@@ -2658,7 +2963,7 @@ function createTailwindV3Engine(source) {
2658
2963
  internals.collapseDuplicateDeclarations(context)(root, result);
2659
2964
  const rawCss = root.toString();
2660
2965
  return {
2661
- css: await transformTailwindV3CssByTarget(rawCss, target, styleOptions),
2966
+ css: await transformTailwindV3CssByTarget(rawCss, target, resolveStyleOptions(source, styleOptions)),
2662
2967
  rawCss,
2663
2968
  classSet: collectClassSet(context),
2664
2969
  dependencies: collectDependencyMessages(result)
@@ -2669,7 +2974,8 @@ function createTailwindV3Engine(source) {
2669
2974
  const target = options.target ?? "weapp";
2670
2975
  const requestedCandidates = mergeGenerateCandidates(source, options);
2671
2976
  if (requestedCandidates.size === 0) return generateOnce(source, options);
2672
- const cacheKey = createIncrementalGenerateCacheKey(source, target, options.styleOptions);
2977
+ const styleOptions = resolveStyleOptions(source, options.styleOptions);
2978
+ const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions);
2673
2979
  const cached = incrementalGenerateCache.get(cacheKey);
2674
2980
  if (cached) {
2675
2981
  const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
@@ -2686,7 +2992,7 @@ function createTailwindV3Engine(source) {
2686
2992
  target: cached.target,
2687
2993
  version: 3
2688
2994
  };
2689
- const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, options.styleOptions);
2995
+ const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions);
2690
2996
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
2691
2997
  for (const className of generated.classSet) cached.classSet.add(className);
2692
2998
  cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
@@ -2865,43 +3171,6 @@ function createWeappTailwindcssGenerator(source) {
2865
3171
  return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
2866
3172
  }
2867
3173
  //#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
3174
  //#region src/bundlers/shared/generator-css/markers.ts
2906
3175
  const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
2907
3176
  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 +4623,9 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
4354
4623
  cssPreflight: opts.cssPreflight,
4355
4624
  cssPreflightRange: opts.cssPreflightRange
4356
4625
  };
4357
- const resolvedUniAppXOptions = resolveUniAppXOptions(opts.uniAppX);
4358
4626
  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,
4627
+ ...resolveStyleOptionsFromContext(opts),
4369
4628
  atRules: opts.atRules,
4370
- uniAppX: resolvedUniAppXOptions.enabled,
4371
4629
  uniAppXCssTarget: opts.uniAppXCssTarget,
4372
4630
  uniAppXUnsupported: opts.uniAppXUnsupported,
4373
4631
  ...cssHandlerOptions,
@@ -4599,7 +4857,6 @@ async function generateCssByGenerator(options) {
4599
4857
  }
4600
4858
  //#endregion
4601
4859
  //#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
4602
- const getLoaderOptions = loader_utils.default.getOptions;
4603
4860
  function resolveLoaderOptions(options) {
4604
4861
  const runtime = require_runtime_registry.getWebpackLoaderRuntime(options?.tailwindcssImportRewriteRuntimeKey)?.cssImportRewrite;
4605
4862
  return runtime ? {
@@ -4685,7 +4942,7 @@ function transformCssImportRewriteSource(source, options) {
4685
4942
  }
4686
4943
  const WeappTwCssImportRewriteLoader = function(source) {
4687
4944
  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));
4945
+ const opt = resolveLoaderOptions(this.getOptions());
4689
4946
  const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
4690
4947
  const hasTailwindRoot = typeof input === "string" && hasTailwindRootDirectives(input, { importFallback: true });
4691
4948
  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,10 @@
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-Bbsrez2w.js");
3
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CERcE0fP.js");
4
+ const require_precheck = require("./precheck-ezN3ovAq.js");
5
+ const require_utils = require("./utils-CSA174-I.js");
6
+ const require_tailwindcss = require("./tailwindcss-nQetCaPp.js");
7
+ const require_bundle_state = require("./bundle-state-BY7PWHAc.js");
8
8
  let node_fs = require("node:fs");
9
9
  node_fs = require_chunk.__toESM(node_fs);
10
10
  let node_module = require("node:module");
@@ -1,9 +1,9 @@
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-COw08vWd.mjs";
2
+ import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-BlJ86j-A.mjs";
3
+ import { _ as createTailwindRuntimeReadyPromise, i as pluginName, n as getCompilerContext, t as shouldSkipJsTransform, u as _defineProperty, v as ensureRuntimeClassSet, y as refreshTailwindRuntimeState } from "./precheck-B4CpMt_w.mjs";
4
+ import { r as getGroupedEntries } from "./utils-B2SJgA1L.mjs";
5
+ import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-ujlr9Iad.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-CBouNDzi.mjs";
7
7
  import Module, { createRequire } from "node:module";
8
8
  import fs from "node:fs";
9
9
  import path from "node:path";
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-CTJcw_sX.js");
3
3
  exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
4
4
  exports.WeappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
5
5
  exports.weappTailwindcss = require_webpack.UnifiedWebpackPluginV5;
package/dist/webpack.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-hPc8wUAi.mjs";
1
+ import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-c2WJnCJI.mjs";
2
2
  export { UnifiedWebpackPluginV5, UnifiedWebpackPluginV5 as WeappTailwindcss, UnifiedWebpackPluginV5 as weappTailwindcss, weappTailwindcssPackageDir };