weapp-tailwindcss 5.0.0-next.23 → 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-BxWD-X7F.js → bundle-state-BY7PWHAc.js} +1 -1
  4. package/dist/{bundle-state-CCjtHdeS.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-BP_VdS_x.mjs → generator-CtqzN9L-.mjs} +1 -1
  23. package/dist/{generator-D6gEmxIp.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-DEf-VOwB.mjs → incremental-runtime-class-set-BlJ86j-A.mjs} +4 -16
  29. package/dist/{incremental-runtime-class-set-CdcqejGM.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-D8kdiqHg.js → postcss-BAO9tGi5.js} +2 -2
  34. package/dist/{postcss-KBUSjpTr.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-DT3ydSET.mjs → precheck-B4CpMt_w.mjs} +69 -32
  40. package/dist/{precheck-DrBpp5HA.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-CHJBRaDA.js → source-candidates-0jPRIPmC.js} +1 -1
  45. package/dist/{source-candidates-CvmmNj4x.mjs → source-candidates-DoyOltpZ.mjs} +1 -1
  46. package/dist/{tailwindcss-CxAd28dW.js → tailwindcss-nQetCaPp.js} +17 -26
  47. package/dist/{tailwindcss-eov9DmH3.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-CxCp7Ydh.js → v3-engine-Bbsrez2w.js} +72 -21
  56. package/dist/{v3-engine-CzD7OvXg.mjs → v3-engine-COw08vWd.mjs} +61 -22
  57. package/dist/{vite-xq8oINaq.js → vite-DE8Vfzal.js} +40 -10
  58. package/dist/{vite-DyQrAtpx.mjs → vite-hZsQAY1a.mjs} +40 -10
  59. package/dist/vite.js +1 -1
  60. package/dist/vite.mjs +1 -1
  61. package/dist/weapp-tw-css-import-rewrite-loader.js +334 -74
  62. package/dist/weapp-tw-runtime-classset-loader.js +1 -4
  63. package/dist/{webpack-bTvAcuj4.js → webpack-CTJcw_sX.js} +6 -6
  64. package/dist/{webpack-CZIJ7caJ.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
@@ -1379,7 +1666,7 @@ function createTailwindV4DefaultColorThemeCss() {
1379
1666
  const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
1380
1667
  const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
1381
1668
  const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
1382
- const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:([-+]?(?:\d+|\d*\.\d+)rpx)\\\]/g;
1669
+ const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
1383
1670
  const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
1384
1671
  "**/.git/**",
1385
1672
  "**/.hg/**",
@@ -1448,13 +1735,16 @@ function restoreRpxTextCandidates(candidates, restoreCandidates) {
1448
1735
  if (restoreCandidates.size === 0) return new Set(candidates);
1449
1736
  return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
1450
1737
  }
1738
+ function normalizeCssEscapedRpxSelectorValue(value) {
1739
+ return value.replace(/\\([.+-])/g, "$1");
1740
+ }
1451
1741
  function restoreRpxTextCssSelectors(css, restoreCandidates) {
1452
1742
  if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
1453
1743
  const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
1454
1744
  return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
1455
1745
  }).filter((value) => Boolean(value)));
1456
1746
  return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
1457
- return restoredValues.has(value) ? `text-\\[${value}\\]` : match;
1747
+ return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
1458
1748
  });
1459
1749
  }
1460
1750
  function createStableJson$2(value) {
@@ -1539,6 +1829,9 @@ function createIncrementalStyleOptions(styleOptions) {
1539
1829
  isMainChunk: false
1540
1830
  };
1541
1831
  }
1832
+ function resolveStyleOptions$1(source, options) {
1833
+ return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
1834
+ }
1542
1835
  function collectCustomPropertyValues(css) {
1543
1836
  const values = /* @__PURE__ */ new Map();
1544
1837
  try {
@@ -1692,6 +1985,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
1692
1985
  function createTailwindV4Engine(source) {
1693
1986
  async function generateOnce(generateSource, options = {}) {
1694
1987
  const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
1988
+ const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
1695
1989
  const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
1696
1990
  const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
1697
1991
  const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources)) : void 0;
@@ -1702,7 +1996,7 @@ function createTailwindV4Engine(source) {
1702
1996
  candidates: normalizedCandidates.candidates
1703
1997
  }));
1704
1998
  const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
1705
- const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
1999
+ const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
1706
2000
  return {
1707
2001
  ...result,
1708
2002
  classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
@@ -1716,8 +2010,9 @@ function createTailwindV4Engine(source) {
1716
2010
  const target = options.target ?? "weapp";
1717
2011
  const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
1718
2012
  const requestedCandidates = resolveTargetCandidates(options.candidates, target);
2013
+ const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
1719
2014
  if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
1720
- const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, options.styleOptions, options.tailwindcssV3Compatibility);
2015
+ const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
1721
2016
  if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
1722
2017
  const generated = await generateOnce(source, options);
1723
2018
  seedIncrementalGenerateCache({
@@ -1762,7 +2057,7 @@ function createTailwindV4Engine(source) {
1762
2057
  }
1763
2058
  const rawCss = rawCssParts.join("\n");
1764
2059
  const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
1765
- ...createIncrementalStyleOptions(options.styleOptions),
2060
+ ...createIncrementalStyleOptions(styleOptions),
1766
2061
  customPropertyValues: cached.customPropertyValues
1767
2062
  }) : "";
1768
2063
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
@@ -1790,7 +2085,7 @@ function createTailwindV4Engine(source) {
1790
2085
  compatibleSource,
1791
2086
  generated,
1792
2087
  requestedCandidates,
1793
- styleOptions: options.styleOptions,
2088
+ styleOptions,
1794
2089
  tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
1795
2090
  target
1796
2091
  });
@@ -2333,16 +2628,22 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2333
2628
  }
2334
2629
  }
2335
2630
  async function transformTailwindV3CssToWeapp(css, options) {
2336
- return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)((await defaultStyleHandler(css, {
2631
+ const result = await defaultStyleHandler(css, {
2337
2632
  cssChildCombinatorReplaceValue: ["view", "text"],
2338
2633
  cssRemoveHoverPseudoClass: true,
2339
2634
  isMainChunk: true,
2340
2635
  majorVersion: 3,
2341
2636
  ...options
2342
- })).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);
2343
2643
  }
2344
2644
  async function transformTailwindV3CssByTarget(css, target, options) {
2345
- return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
2645
+ if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
2646
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
2346
2647
  }
2347
2648
  //#endregion
2348
2649
  //#region src/tailwindcss/v3-engine/generator.ts
@@ -2405,7 +2706,7 @@ function extractClassCandidatesFromSelector(selector, candidates) {
2405
2706
  escaped = true;
2406
2707
  continue;
2407
2708
  }
2408
- if (/[\w-]/.test(char)) {
2709
+ if (char && /[\w-]/.test(char)) {
2409
2710
  candidate += char;
2410
2711
  continue;
2411
2712
  }
@@ -2466,6 +2767,12 @@ function createTailwindConfig(source, options) {
2466
2767
  config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
2467
2768
  return config;
2468
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
+ }
2469
2776
  function loadTailwindV3Internals(source) {
2470
2777
  const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
2471
2778
  const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
@@ -2600,6 +2907,7 @@ function createTailwindV3Engine(source) {
2600
2907
  tailwindInternals ??= loadTailwindV3Internals(source);
2601
2908
  const internals = tailwindInternals;
2602
2909
  const { styleOptions, target = "weapp" } = options;
2910
+ const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
2603
2911
  const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, options)));
2604
2912
  const candidates = mergeGenerateCandidates(generateSource, options);
2605
2913
  const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
@@ -2624,7 +2932,7 @@ function createTailwindV3Engine(source) {
2624
2932
  context = await internals.processTailwindFeatures(setupContext)(root, result);
2625
2933
  }
2626
2934
  const rawCss = root.toString();
2627
- const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
2935
+ const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
2628
2936
  const dependencies = collectDependencyMessages(result);
2629
2937
  for (const dependency of generateSource.dependencies) dependencies.add(dependency);
2630
2938
  const classSet = collectClassSet(context);
@@ -2655,7 +2963,7 @@ function createTailwindV3Engine(source) {
2655
2963
  internals.collapseDuplicateDeclarations(context)(root, result);
2656
2964
  const rawCss = root.toString();
2657
2965
  return {
2658
- css: await transformTailwindV3CssByTarget(rawCss, target, styleOptions),
2966
+ css: await transformTailwindV3CssByTarget(rawCss, target, resolveStyleOptions(source, styleOptions)),
2659
2967
  rawCss,
2660
2968
  classSet: collectClassSet(context),
2661
2969
  dependencies: collectDependencyMessages(result)
@@ -2666,7 +2974,8 @@ function createTailwindV3Engine(source) {
2666
2974
  const target = options.target ?? "weapp";
2667
2975
  const requestedCandidates = mergeGenerateCandidates(source, options);
2668
2976
  if (requestedCandidates.size === 0) return generateOnce(source, options);
2669
- const cacheKey = createIncrementalGenerateCacheKey(source, target, options.styleOptions);
2977
+ const styleOptions = resolveStyleOptions(source, options.styleOptions);
2978
+ const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions);
2670
2979
  const cached = incrementalGenerateCache.get(cacheKey);
2671
2980
  if (cached) {
2672
2981
  const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
@@ -2683,7 +2992,7 @@ function createTailwindV3Engine(source) {
2683
2992
  target: cached.target,
2684
2993
  version: 3
2685
2994
  };
2686
- const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, options.styleOptions);
2995
+ const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions);
2687
2996
  for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
2688
2997
  for (const className of generated.classSet) cached.classSet.add(className);
2689
2998
  cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
@@ -2862,43 +3171,6 @@ function createWeappTailwindcssGenerator(source) {
2862
3171
  return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
2863
3172
  }
2864
3173
  //#endregion
2865
- //#region src/uni-app-x/options.ts
2866
- function resolveComponentLocalStyles(option) {
2867
- if (option === false) return {
2868
- enabled: false,
2869
- onlyWhenStyleIsolationVersion2: true
2870
- };
2871
- if (option === true || option === void 0) return {
2872
- enabled: false,
2873
- onlyWhenStyleIsolationVersion2: true
2874
- };
2875
- const componentLocalStyles = option.componentLocalStyles;
2876
- if (componentLocalStyles === false) return {
2877
- enabled: false,
2878
- onlyWhenStyleIsolationVersion2: true
2879
- };
2880
- if (componentLocalStyles === true || componentLocalStyles === void 0) return {
2881
- enabled: true,
2882
- onlyWhenStyleIsolationVersion2: true
2883
- };
2884
- return {
2885
- enabled: componentLocalStyles.enabled !== false,
2886
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
2887
- };
2888
- }
2889
- function resolveUniAppXOptions(option) {
2890
- if (typeof option === "object" && option) return {
2891
- enabled: option.enabled !== false,
2892
- componentLocalStyles: resolveComponentLocalStyles(option),
2893
- uvueUnsupported: option.uvueUnsupported ?? "warn"
2894
- };
2895
- return {
2896
- enabled: Boolean(option),
2897
- componentLocalStyles: resolveComponentLocalStyles(option),
2898
- uvueUnsupported: "warn"
2899
- };
2900
- }
2901
- //#endregion
2902
3174
  //#region src/bundlers/shared/generator-css/markers.ts
2903
3175
  const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
2904
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)-/;
@@ -4351,20 +4623,9 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
4351
4623
  cssPreflight: opts.cssPreflight,
4352
4624
  cssPreflightRange: opts.cssPreflightRange
4353
4625
  };
4354
- const resolvedUniAppXOptions = resolveUniAppXOptions(opts.uniAppX);
4355
4626
  return {
4356
- cssChildCombinatorReplaceValue: opts.cssChildCombinatorReplaceValue,
4357
- cssSelectorReplacement: opts.cssSelectorReplacement,
4358
- rem2rpx: opts.rem2rpx,
4359
- px2rpx: opts.px2rpx,
4360
- unitsToPx: opts.unitsToPx,
4361
- cssRemoveProperty: opts.cssRemoveProperty,
4362
- cssRemoveHoverPseudoClass: opts.cssRemoveHoverPseudoClass,
4363
- cssPresetEnv: opts.cssPresetEnv,
4364
- autoprefixer: opts.autoprefixer,
4365
- cssCalc: opts.cssCalc,
4627
+ ...resolveStyleOptionsFromContext(opts),
4366
4628
  atRules: opts.atRules,
4367
- uniAppX: resolvedUniAppXOptions.enabled,
4368
4629
  uniAppXCssTarget: opts.uniAppXCssTarget,
4369
4630
  uniAppXUnsupported: opts.uniAppXUnsupported,
4370
4631
  ...cssHandlerOptions,
@@ -4596,7 +4857,6 @@ async function generateCssByGenerator(options) {
4596
4857
  }
4597
4858
  //#endregion
4598
4859
  //#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
4599
- const getLoaderOptions = loader_utils.default.getOptions;
4600
4860
  function resolveLoaderOptions(options) {
4601
4861
  const runtime = require_runtime_registry.getWebpackLoaderRuntime(options?.tailwindcssImportRewriteRuntimeKey)?.cssImportRewrite;
4602
4862
  return runtime ? {
@@ -4682,7 +4942,7 @@ function transformCssImportRewriteSource(source, options) {
4682
4942
  }
4683
4943
  const WeappTwCssImportRewriteLoader = function(source) {
4684
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`);
4685
- const opt = resolveLoaderOptions(getLoaderOptions(this));
4945
+ const opt = resolveLoaderOptions(this.getOptions());
4686
4946
  const input = node_buffer.Buffer.isBuffer(source) ? source.toString("utf-8") : source;
4687
4947
  const hasTailwindRoot = typeof input === "string" && hasTailwindRootDirectives(input, { importFallback: true });
4688
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-CxCp7Ydh.js");
3
- const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CdcqejGM.js");
4
- const require_precheck = require("./precheck-DrBpp5HA.js");
5
- const require_utils = require("./utils-4ODFyoqD.js");
6
- const require_tailwindcss = require("./tailwindcss-CxAd28dW.js");
7
- const require_bundle_state = require("./bundle-state-BxWD-X7F.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-CzD7OvXg.mjs";
2
- import { i as generateCssByGenerator, o as processCachedTask, r as emitHmrTiming, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-DEf-VOwB.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-DT3ydSET.mjs";
4
- import { r as getGroupedEntries } from "./utils-CGBVVNm6.mjs";
5
- import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-eov9DmH3.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-CCjtHdeS.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-bTvAcuj4.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-CZIJ7caJ.mjs";
1
+ import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-c2WJnCJI.mjs";
2
2
  export { UnifiedWebpackPluginV5, UnifiedWebpackPluginV5 as WeappTailwindcss, UnifiedWebpackPluginV5 as weappTailwindcss, weappTailwindcssPackageDir };