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
@@ -0,0 +1,169 @@
1
+ //#region src/css-macro/constants.ts
2
+ const queryKey = "weapp-tw-platform";
3
+ const ifdefAtRule = "weapp-tw-ifdef";
4
+ const ifndefAtRule = "weapp-tw-ifndef";
5
+ function quoteAtRuleParam(value) {
6
+ return `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
7
+ }
8
+ function createConditionalAtRule(value) {
9
+ return `@${ifdefAtRule} ${quoteAtRuleParam(value)}{&}`;
10
+ }
11
+ function createNegativeConditionalAtRule(value) {
12
+ return `@${ifndefAtRule} ${quoteAtRuleParam(value)}{&}`;
13
+ }
14
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
15
+ const WHITESPACE_RE = /\s+/g;
16
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
17
+ function normalComment(text) {
18
+ if (typeof text === "string") {
19
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
20
+ if (normalized.includes("\\")) return normalized;
21
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
22
+ }
23
+ return text;
24
+ }
25
+ function ifdef(text) {
26
+ return {
27
+ start: `#ifdef ${normalComment(text)}`,
28
+ end: `#endif`
29
+ };
30
+ }
31
+ function ifndef(text) {
32
+ return {
33
+ start: `#ifndef ${normalComment(text)}`,
34
+ end: `#endif`
35
+ };
36
+ }
37
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
38
+ function matchCustomPropertyFromValue(str, cb) {
39
+ let index = 0;
40
+ QUERY_KEY_REGEX.lastIndex = 0;
41
+ let arr = QUERY_KEY_REGEX.exec(str);
42
+ while (arr !== null) {
43
+ cb(arr, index);
44
+ index++;
45
+ arr = QUERY_KEY_REGEX.exec(str);
46
+ }
47
+ }
48
+ function parseConditionalAtRuleParam(params) {
49
+ const value = params.trim();
50
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
51
+ if (!quoted) return value;
52
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
53
+ }
54
+ //#endregion
55
+ //#region src/css-macro/postcss.ts
56
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
57
+ const CONDITIONAL_COMMENT_SPACING = " ";
58
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
59
+ const creator = () => {
60
+ return {
61
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
62
+ prepare() {
63
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
64
+ const hasPreviousNode = Boolean(atRule.prev());
65
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
66
+ const startComment = helper.comment({
67
+ raws: {
68
+ left: CONDITIONAL_COMMENT_SPACING,
69
+ right: CONDITIONAL_COMMENT_SPACING
70
+ },
71
+ text: comment.start
72
+ });
73
+ const endComment = helper.comment({
74
+ raws: {
75
+ left: CONDITIONAL_COMMENT_SPACING,
76
+ right: CONDITIONAL_COMMENT_SPACING
77
+ },
78
+ text: comment.end
79
+ });
80
+ const nextNodes = [
81
+ startComment,
82
+ ...clonedNodes,
83
+ endComment
84
+ ];
85
+ atRule.replaceWith(nextNodes);
86
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
87
+ startComment.raws.after = "\n";
88
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
89
+ endComment.raws.before = "\n";
90
+ endComment.raws.after = "\n";
91
+ const nextNode = endComment?.next();
92
+ if (nextNode) nextNode.raws.before = "\n";
93
+ }
94
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
95
+ if (atRule.parent?.type !== "rule") return false;
96
+ const parentRule = atRule.parent;
97
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
98
+ const conditionalRule = parentRule.clone();
99
+ conditionalRule.removeAll();
100
+ conditionalRule.append(...clonedNodes);
101
+ const startComment = helper.comment({
102
+ raws: {
103
+ left: CONDITIONAL_COMMENT_SPACING,
104
+ right: CONDITIONAL_COMMENT_SPACING
105
+ },
106
+ text: comment.start
107
+ });
108
+ const endComment = helper.comment({
109
+ raws: {
110
+ left: CONDITIONAL_COMMENT_SPACING,
111
+ right: CONDITIONAL_COMMENT_SPACING
112
+ },
113
+ text: comment.end
114
+ });
115
+ const nextNodes = [
116
+ startComment,
117
+ conditionalRule,
118
+ endComment
119
+ ];
120
+ const hasPreviousNode = Boolean(parentRule.prev());
121
+ atRule.remove();
122
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
123
+ else parentRule.after(nextNodes);
124
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
125
+ startComment.raws.after = "\n";
126
+ conditionalRule.raws.before = "\n";
127
+ endComment.raws.before = "\n";
128
+ endComment.raws.after = "\n";
129
+ const nextNode = endComment.next();
130
+ if (nextNode) nextNode.raws.before = "\n";
131
+ return true;
132
+ }
133
+ return {
134
+ AtRule(atRule, helper) {
135
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
136
+ const text = parseConditionalAtRuleParam(atRule.params);
137
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
138
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
139
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
140
+ return;
141
+ }
142
+ if (atRule.name === "media") {
143
+ const values = [];
144
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
145
+ const value = arr[1];
146
+ if (value) values.push(value);
147
+ });
148
+ if (values.length > 0) {
149
+ const isNegative = atRule.params.includes("not");
150
+ const text = values.join(" ");
151
+ const comment = isNegative ? ifndef(text) : ifdef(text);
152
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
153
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
154
+ }
155
+ }
156
+ },
157
+ CommentExit(comment) {
158
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
159
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
160
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
161
+ }
162
+ }
163
+ };
164
+ }
165
+ };
166
+ };
167
+ creator.postcss = true;
168
+ //#endregion
169
+ export { createNegativeConditionalAtRule as i, creator as n, createConditionalAtRule as r, CSS_MACRO_POSTCSS_PLUGIN_NAME as t };
package/dist/postcss.js CHANGED
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_postcss = require("./postcss-cD5PXmMU.js");
5
+ const require_postcss = require("./postcss-BAO9tGi5.js");
6
6
  exports.default = require_postcss.weappTailwindcssPostcssPlugin;
7
7
  exports.weappTailwindcssPostcssPlugin = require_postcss.weappTailwindcssPostcssPlugin;
package/dist/postcss.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as weappTailwindcssPostcssPlugin } from "./postcss-nk5bhdoV.mjs";
1
+ import { t as weappTailwindcssPostcssPlugin } from "./postcss-CYPHxj7a.mjs";
2
2
  export { weappTailwindcssPostcssPlugin as default, weappTailwindcssPostcssPlugin };
@@ -1,7 +1,7 @@
1
- import { B as createDebug, C as createTailwindV4Engine, G as omitUndefined, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-CXqgQZUc.mjs";
2
- import { a as resolveDefaultCssPreflight, i as getDefaultOptions, o as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, s as HARD_PARSE_CACHE_MAX_ENTRIES } from "./defaults-C6sIKXgC.mjs";
3
- import { i as isMap, n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
4
- import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, r as isUniAppXEnabled, t as createTailwindcssPatcherFromContext } from "./tailwindcss-DO-VVR5k.mjs";
1
+ import { B as createDebug, C as createTailwindV4Engine, K as resolveBooleanObjectOption, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, q as omitUndefined, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-COw08vWd.mjs";
2
+ import { a as resolveDefaultCssPreflight, i as getDefaultOptions, o as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, s as HARD_PARSE_CACHE_MAX_ENTRIES } from "./defaults-B-1EEhdL.mjs";
3
+ import { i as isMap, n as defuOverrideArray } from "./utils-B2SJgA1L.mjs";
4
+ import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, t as createTailwindcssPatcherFromContext } from "./tailwindcss-ujlr9Iad.mjs";
5
5
  import path from "node:path";
6
6
  import process from "node:process";
7
7
  import { logger, pc } from "@weapp-tailwindcss/logger";
@@ -13,7 +13,6 @@ import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
13
13
  import { MappingChars2String, escape } from "@weapp-core/escape";
14
14
  import _babelTraverse from "@babel/traverse";
15
15
  import { parse, parseExpression } from "@babel/parser";
16
- import { escapeStringRegexp } from "@weapp-core/regex";
17
16
  import MagicString from "magic-string";
18
17
  import { jsStringEscape } from "@ast-core/escape";
19
18
  import { splitCode } from "@weapp-tailwindcss/shared/extractors";
@@ -345,6 +344,23 @@ function logTailwindcssTarget(patcher, baseDir) {
345
344
  logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
346
345
  }
347
346
  //#endregion
347
+ //#region src/unocss/index.ts
348
+ function normalizeUnocssOptions(unocss) {
349
+ return resolveBooleanObjectOption(unocss, {});
350
+ }
351
+ function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
352
+ const baseArbitraryValues = arbitraryValues ?? {};
353
+ const options = normalizeUnocssOptions(unocss);
354
+ if (!options) return baseArbitraryValues;
355
+ if (baseArbitraryValues.bareArbitraryValues !== void 0 && baseArbitraryValues.bareArbitraryValues !== false) return baseArbitraryValues;
356
+ const bareArbitraryValues = options.bareArbitraryValues ?? true;
357
+ if (bareArbitraryValues === false) return baseArbitraryValues;
358
+ return {
359
+ ...baseArbitraryValues,
360
+ bareArbitraryValues
361
+ };
362
+ }
363
+ //#endregion
348
364
  //#region src/context/compiler-context-cache.ts
349
365
  const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
350
366
  const AT_LOCATION_RE = /at\s+(\S.*)$/u;
@@ -547,21 +563,18 @@ function toCustomAttributesEntities(customAttributes) {
547
563
  return Object.entries(customAttributes);
548
564
  }
549
565
  //#endregion
550
- //#region src/constants.ts
551
- const pluginName = "weapp-tailwindcss";
552
- const vitePluginName = "weapp-tailwindcss:adaptor";
553
- const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
554
- "tailwind-merge": "@weapp-tailwindcss/merge",
555
- "class-variance-authority": "@weapp-tailwindcss/cva",
556
- "tailwind-variants": "@weapp-tailwindcss/variants"
557
- };
558
- //#endregion
559
566
  //#region src/babel/index.ts
560
567
  function _interopDefaultCompat(e) {
561
568
  return e && typeof e === "object" && "default" in e ? e.default : e;
562
569
  }
563
570
  const traverse = _interopDefaultCompat(_babelTraverse);
564
571
  //#endregion
572
+ //#region src/utils/regex.ts
573
+ function escapeStringRegexp(str) {
574
+ if (typeof str !== "string") throw new TypeError("Expected a string");
575
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
576
+ }
577
+ //#endregion
565
578
  //#region src/utils/nameMatcher.ts
566
579
  const NEVER_MATCH_NAME$1 = () => false;
567
580
  const GLOBAL_FLAG_REGEXP = /g/g;
@@ -2498,10 +2511,19 @@ function createTemplateHandler(options = {}) {
2498
2511
  };
2499
2512
  }
2500
2513
  //#endregion
2501
- //#region src/context/handlers.ts
2514
+ //#region src/constants.ts
2515
+ const pluginName = "weapp-tailwindcss";
2516
+ const vitePluginName = "weapp-tailwindcss:adaptor";
2517
+ const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
2518
+ "tailwind-merge": "@weapp-tailwindcss/merge",
2519
+ "class-variance-authority": "@weapp-tailwindcss/cva",
2520
+ "tailwind-variants": "@weapp-tailwindcss/variants"
2521
+ };
2522
+ //#endregion
2523
+ //#region src/context/runtime-package-replacements.ts
2502
2524
  function resolveRuntimePackageReplacements(option) {
2503
- if (!option) return;
2504
- const mapping = option === true ? DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS : option;
2525
+ const mapping = resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
2526
+ if (!mapping) return;
2505
2527
  const normalized = {};
2506
2528
  for (const [from, to] of Object.entries(mapping)) {
2507
2529
  if (!from || typeof to !== "string" || to.length === 0) continue;
@@ -2509,29 +2531,43 @@ function resolveRuntimePackageReplacements(option) {
2509
2531
  }
2510
2532
  return Object.keys(normalized).length > 0 ? normalized : void 0;
2511
2533
  }
2534
+ //#endregion
2535
+ //#region src/context/style-options.ts
2536
+ function resolveStyleOptionsFromContext(ctx) {
2537
+ const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
2538
+ return {
2539
+ cssPreflight: ctx.cssPreflight,
2540
+ cssPreflightRange: ctx.cssPreflightRange,
2541
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
2542
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
2543
+ rem2rpx: ctx.rem2rpx,
2544
+ cssRemoveProperty: ctx.cssRemoveProperty,
2545
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
2546
+ cssPresetEnv: ctx.cssPresetEnv,
2547
+ autoprefixer: ctx.autoprefixer,
2548
+ cssCalc: ctx.cssCalc,
2549
+ uniAppX: resolvedUniAppXOptions.enabled,
2550
+ platform: ctx.platform,
2551
+ px2rpx: ctx.px2rpx,
2552
+ unitsToPx: ctx.unitsToPx,
2553
+ unitConversion: ctx.unitConversion
2554
+ };
2555
+ }
2556
+ //#endregion
2557
+ //#region src/context/handlers.ts
2512
2558
  function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
2513
- const { cssPreflight, cssPreflightRange, escapeMap, cssChildCombinatorReplaceValue, injectAdditionalCssVarScope, cssSelectorReplacement, rem2rpx, postcssOptions, cssRemoveProperty, cssRemoveHoverPseudoClass, cssPresetEnv, autoprefixer, uniAppX, px2rpx, unitsToPx, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
2514
- const uniAppXEnabled = isUniAppXEnabled(uniAppX);
2559
+ const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
2515
2560
  const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
2561
+ const styleOptions = resolveStyleOptionsFromContext(ctx);
2562
+ const uniAppXEnabled = styleOptions.uniAppX === true;
2516
2563
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
2517
2564
  const styleHandler = createStyleHandler({
2518
- cssPreflight,
2519
- cssPreflightRange,
2565
+ ...styleOptions,
2520
2566
  escapeMap,
2521
- cssChildCombinatorReplaceValue,
2522
2567
  injectAdditionalCssVarScope,
2523
- cssSelectorReplacement,
2524
- rem2rpx,
2525
2568
  postcssOptions,
2526
- cssRemoveProperty,
2527
- cssRemoveHoverPseudoClass,
2528
- cssPresetEnv,
2529
- autoprefixer,
2530
- uniAppX: uniAppXEnabled,
2531
2569
  uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
2532
2570
  cssCalc: cssCalcOptions,
2533
- px2rpx,
2534
- unitsToPx,
2535
2571
  majorVersion: tailwindcssMajorVersion
2536
2572
  });
2537
2573
  const jsHandler = createJsHandler({
@@ -2602,6 +2638,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2602
2638
  }
2603
2639
  function createInternalCompilerContext(opts) {
2604
2640
  const ctx = defuOverrideArray(opts, getDefaultOptions(), {});
2641
+ ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
2605
2642
  ctx.escapeMap = ctx.customReplaceDictionary;
2606
2643
  applyLoggerLevel(ctx.logLevel);
2607
2644
  const twPatcher = createTailwindcssPatcherFromContext(ctx);
@@ -2665,4 +2702,4 @@ function shouldSkipJsTransform(rawSource, options) {
2665
2702
  return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
2666
2703
  }
2667
2704
  //#endregion
2668
- export { ensureRuntimeClassSet as _, analyzeSource as a, isClassContextLiteralPath as c, traverse as d, pluginName as f, createTailwindRuntimeReadyPromise as g, collectRuntimeClassSet as h, createAttributeMatcher as i, replaceWxml as l, toCustomAttributesEntities as m, getCompilerContext as n, JsTokenUpdater as o, vitePluginName as p, generateCode as r, _defineProperty as s, shouldSkipJsTransform as t, babelParse as u, refreshTailwindRuntimeState as v };
2705
+ export { createTailwindRuntimeReadyPromise as _, vitePluginName as a, analyzeSource as c, isClassContextLiteralPath as d, replaceWxml as f, collectRuntimeClassSet as g, toCustomAttributesEntities as h, pluginName as i, JsTokenUpdater as l, traverse as m, getCompilerContext as n, generateCode as o, babelParse as p, resolveStyleOptionsFromContext as r, createAttributeMatcher as s, shouldSkipJsTransform as t, _defineProperty as u, ensureRuntimeClassSet as v, refreshTailwindRuntimeState as y };
@@ -1,8 +1,8 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-vHlppqaZ.js");
3
- const require_defaults = require("./defaults-D3cFX6Cq.js");
4
- require("./utils-4ODFyoqD.js");
5
- const require_tailwindcss = require("./tailwindcss-BtUBeOes.js");
2
+ const require_v3_engine = require("./v3-engine-Bbsrez2w.js");
3
+ const require_defaults = require("./defaults-C10hYUch.js");
4
+ require("./utils-CSA174-I.js");
5
+ const require_tailwindcss = require("./tailwindcss-nQetCaPp.js");
6
6
  let node_path = require("node:path");
7
7
  node_path = require_chunk.__toESM(node_path);
8
8
  let node_process = require("node:process");
@@ -17,7 +17,6 @@ let _weapp_core_escape = require("@weapp-core/escape");
17
17
  let _babel_traverse = require("@babel/traverse");
18
18
  _babel_traverse = require_chunk.__toESM(_babel_traverse);
19
19
  let _babel_parser = require("@babel/parser");
20
- let _weapp_core_regex = require("@weapp-core/regex");
21
20
  let magic_string = require("magic-string");
22
21
  magic_string = require_chunk.__toESM(magic_string);
23
22
  let _ast_core_escape = require("@ast-core/escape");
@@ -352,6 +351,23 @@ function logTailwindcssTarget(patcher, baseDir) {
352
351
  _weapp_tailwindcss_logger.logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
353
352
  }
354
353
  //#endregion
354
+ //#region src/unocss/index.ts
355
+ function normalizeUnocssOptions(unocss) {
356
+ return require_v3_engine.resolveBooleanObjectOption(unocss, {});
357
+ }
358
+ function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
359
+ const baseArbitraryValues = arbitraryValues ?? {};
360
+ const options = normalizeUnocssOptions(unocss);
361
+ if (!options) return baseArbitraryValues;
362
+ if (baseArbitraryValues.bareArbitraryValues !== void 0 && baseArbitraryValues.bareArbitraryValues !== false) return baseArbitraryValues;
363
+ const bareArbitraryValues = options.bareArbitraryValues ?? true;
364
+ if (bareArbitraryValues === false) return baseArbitraryValues;
365
+ return {
366
+ ...baseArbitraryValues,
367
+ bareArbitraryValues
368
+ };
369
+ }
370
+ //#endregion
355
371
  //#region src/context/compiler-context-cache.ts
356
372
  const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
357
373
  const AT_LOCATION_RE = /at\s+(\S.*)$/u;
@@ -554,21 +570,18 @@ function toCustomAttributesEntities(customAttributes) {
554
570
  return Object.entries(customAttributes);
555
571
  }
556
572
  //#endregion
557
- //#region src/constants.ts
558
- const pluginName = "weapp-tailwindcss";
559
- const vitePluginName = "weapp-tailwindcss:adaptor";
560
- const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
561
- "tailwind-merge": "@weapp-tailwindcss/merge",
562
- "class-variance-authority": "@weapp-tailwindcss/cva",
563
- "tailwind-variants": "@weapp-tailwindcss/variants"
564
- };
565
- //#endregion
566
573
  //#region src/babel/index.ts
567
574
  function _interopDefaultCompat(e) {
568
575
  return e && typeof e === "object" && "default" in e ? e.default : e;
569
576
  }
570
577
  const traverse = _interopDefaultCompat(_babel_traverse.default);
571
578
  //#endregion
579
+ //#region src/utils/regex.ts
580
+ function escapeStringRegexp(str) {
581
+ if (typeof str !== "string") throw new TypeError("Expected a string");
582
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
583
+ }
584
+ //#endregion
572
585
  //#region src/utils/nameMatcher.ts
573
586
  const NEVER_MATCH_NAME$1 = () => false;
574
587
  const GLOBAL_FLAG_REGEXP = /g/g;
@@ -580,7 +593,7 @@ function buildFuzzyMatcher(fuzzyStrings) {
580
593
  return (value) => value.includes(needle);
581
594
  }
582
595
  const unique = [...new Set(fuzzyStrings)];
583
- const pattern = new RegExp(unique.map(_weapp_core_regex.escapeStringRegexp).join("|"));
596
+ const pattern = new RegExp(unique.map(escapeStringRegexp).join("|"));
584
597
  return (value) => pattern.test(value);
585
598
  }
586
599
  function normaliseRegex(regex) {
@@ -2505,10 +2518,19 @@ function createTemplateHandler(options = {}) {
2505
2518
  };
2506
2519
  }
2507
2520
  //#endregion
2508
- //#region src/context/handlers.ts
2521
+ //#region src/constants.ts
2522
+ const pluginName = "weapp-tailwindcss";
2523
+ const vitePluginName = "weapp-tailwindcss:adaptor";
2524
+ const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
2525
+ "tailwind-merge": "@weapp-tailwindcss/merge",
2526
+ "class-variance-authority": "@weapp-tailwindcss/cva",
2527
+ "tailwind-variants": "@weapp-tailwindcss/variants"
2528
+ };
2529
+ //#endregion
2530
+ //#region src/context/runtime-package-replacements.ts
2509
2531
  function resolveRuntimePackageReplacements(option) {
2510
- if (!option) return;
2511
- const mapping = option === true ? DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS : option;
2532
+ const mapping = require_v3_engine.resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
2533
+ if (!mapping) return;
2512
2534
  const normalized = {};
2513
2535
  for (const [from, to] of Object.entries(mapping)) {
2514
2536
  if (!from || typeof to !== "string" || to.length === 0) continue;
@@ -2516,29 +2538,43 @@ function resolveRuntimePackageReplacements(option) {
2516
2538
  }
2517
2539
  return Object.keys(normalized).length > 0 ? normalized : void 0;
2518
2540
  }
2541
+ //#endregion
2542
+ //#region src/context/style-options.ts
2543
+ function resolveStyleOptionsFromContext(ctx) {
2544
+ const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX);
2545
+ return {
2546
+ cssPreflight: ctx.cssPreflight,
2547
+ cssPreflightRange: ctx.cssPreflightRange,
2548
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
2549
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
2550
+ rem2rpx: ctx.rem2rpx,
2551
+ cssRemoveProperty: ctx.cssRemoveProperty,
2552
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
2553
+ cssPresetEnv: ctx.cssPresetEnv,
2554
+ autoprefixer: ctx.autoprefixer,
2555
+ cssCalc: ctx.cssCalc,
2556
+ uniAppX: resolvedUniAppXOptions.enabled,
2557
+ platform: ctx.platform,
2558
+ px2rpx: ctx.px2rpx,
2559
+ unitsToPx: ctx.unitsToPx,
2560
+ unitConversion: ctx.unitConversion
2561
+ };
2562
+ }
2563
+ //#endregion
2564
+ //#region src/context/handlers.ts
2519
2565
  function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
2520
- const { cssPreflight, cssPreflightRange, escapeMap, cssChildCombinatorReplaceValue, injectAdditionalCssVarScope, cssSelectorReplacement, rem2rpx, postcssOptions, cssRemoveProperty, cssRemoveHoverPseudoClass, cssPresetEnv, autoprefixer, uniAppX, px2rpx, unitsToPx, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
2521
- const uniAppXEnabled = require_tailwindcss.isUniAppXEnabled(uniAppX);
2566
+ const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
2522
2567
  const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
2568
+ const styleOptions = resolveStyleOptionsFromContext(ctx);
2569
+ const uniAppXEnabled = styleOptions.uniAppX === true;
2523
2570
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
2524
2571
  const styleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
2525
- cssPreflight,
2526
- cssPreflightRange,
2572
+ ...styleOptions,
2527
2573
  escapeMap,
2528
- cssChildCombinatorReplaceValue,
2529
2574
  injectAdditionalCssVarScope,
2530
- cssSelectorReplacement,
2531
- rem2rpx,
2532
2575
  postcssOptions,
2533
- cssRemoveProperty,
2534
- cssRemoveHoverPseudoClass,
2535
- cssPresetEnv,
2536
- autoprefixer,
2537
- uniAppX: uniAppXEnabled,
2538
2576
  uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
2539
2577
  cssCalc: cssCalcOptions,
2540
- px2rpx,
2541
- unitsToPx,
2542
2578
  majorVersion: tailwindcssMajorVersion
2543
2579
  });
2544
2580
  const jsHandler = createJsHandler({
@@ -2609,6 +2645,7 @@ async function clearTailwindcssPatcherCache(patcher, options) {
2609
2645
  }
2610
2646
  function createInternalCompilerContext(opts) {
2611
2647
  const ctx = (0, _weapp_tailwindcss_shared.defuOverrideArray)(opts, require_defaults.getDefaultOptions(), {});
2648
+ ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
2612
2649
  ctx.escapeMap = ctx.customReplaceDictionary;
2613
2650
  applyLoggerLevel(ctx.logLevel);
2614
2651
  const twPatcher = require_tailwindcss.createTailwindcssPatcherFromContext(ctx);
@@ -2756,6 +2793,12 @@ Object.defineProperty(exports, "replaceWxml", {
2756
2793
  return replaceWxml;
2757
2794
  }
2758
2795
  });
2796
+ Object.defineProperty(exports, "resolveStyleOptionsFromContext", {
2797
+ enumerable: true,
2798
+ get: function() {
2799
+ return resolveStyleOptionsFromContext;
2800
+ }
2801
+ });
2759
2802
  Object.defineProperty(exports, "shouldSkipJsTransform", {
2760
2803
  enumerable: true,
2761
2804
  get: function() {
@@ -6,6 +6,7 @@ export interface UniAppXOptions {
6
6
  rem2rpx?: UserDefinedOptions['rem2rpx'];
7
7
  generator?: UserDefinedOptions['generator'];
8
8
  unitsToPx?: UserDefinedOptions['unitsToPx'];
9
+ unitConversion?: UserDefinedOptions['unitConversion'];
9
10
  rawOptions?: UserDefinedOptions;
10
11
  resolve?: PackageResolvingOptions;
11
12
  customAttributes?: UserDefinedOptions['customAttributes'];
package/dist/presets.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-8l464Juk.js");
3
- const require_v3_engine = require("./v3-engine-vHlppqaZ.js");
4
- const require_utils = require("./utils-4ODFyoqD.js");
5
- const require_tailwindcss = require("./tailwindcss-BtUBeOes.js");
6
- require("./logger-EVNB9z7i.js");
3
+ const require_v3_engine = require("./v3-engine-Bbsrez2w.js");
4
+ const require_utils = require("./utils-CSA174-I.js");
5
+ const require_tailwindcss = require("./tailwindcss-nQetCaPp.js");
6
+ require("./logger-Cdzl3p8j.js");
7
7
  let node_process = require("node:process");
8
8
  node_process = require_chunk.__toESM(node_process);
9
9
  let local_pkg = require("local-pkg");
@@ -101,6 +101,7 @@ function uniAppX(options) {
101
101
  ...options.generator !== void 0 ? { generator: options.generator } : {},
102
102
  rem2rpx: options.rem2rpx,
103
103
  unitsToPx: options.unitsToPx,
104
+ unitConversion: options.unitConversion,
104
105
  tailwindcssBasedir: options.base,
105
106
  tailwindcssPatcherOptions: {
106
107
  projectRoot: options.base,
package/dist/presets.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { G as omitUndefined } from "./v3-engine-CXqgQZUc.mjs";
2
- import { n as defuOverrideArray, o as resolveUniUtsPlatform } from "./utils-CGBVVNm6.mjs";
3
- import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-DO-VVR5k.mjs";
4
- import { t as logger } from "./logger-CZUxvJJD.mjs";
1
+ import { q as omitUndefined } from "./v3-engine-COw08vWd.mjs";
2
+ import { n as defuOverrideArray, o as resolveUniUtsPlatform } from "./utils-B2SJgA1L.mjs";
3
+ import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-ujlr9Iad.mjs";
4
+ import { t as logger } from "./logger-Dr7IvyH2.mjs";
5
5
  import process from "node:process";
6
6
  import { getPackageInfoSync } from "local-pkg";
7
7
  //#region src/presets/shared.ts
@@ -96,6 +96,7 @@ function uniAppX(options) {
96
96
  ...options.generator !== void 0 ? { generator: options.generator } : {},
97
97
  rem2rpx: options.rem2rpx,
98
98
  unitsToPx: options.unitsToPx,
99
+ unitConversion: options.unitConversion,
99
100
  tailwindcssBasedir: options.base,
100
101
  tailwindcssPatcherOptions: {
101
102
  projectRoot: options.base,
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-vHlppqaZ.js");
2
+ const require_v3_engine = require("./v3-engine-Bbsrez2w.js");
3
3
  let node_path = require("node:path");
4
4
  node_path = require_chunk.__toESM(node_path);
5
5
  let tailwindcss_patch = require("tailwindcss-patch");
@@ -1,4 +1,4 @@
1
- import { L as resolveSourceScanPath, N as isFileMatchedByTailwindSourceEntries, k as FULL_SOURCE_SCAN_EXTENSION_RE, z as toPosixPath } from "./v3-engine-CXqgQZUc.mjs";
1
+ import { L as resolveSourceScanPath, N as isFileMatchedByTailwindSourceEntries, k as FULL_SOURCE_SCAN_EXTENSION_RE, z as toPosixPath } from "./v3-engine-COw08vWd.mjs";
2
2
  import path from "node:path";
3
3
  import { extractSourceCandidates, resolveProjectSourceFiles } from "tailwindcss-patch";
4
4
  import { readFile } from "node:fs/promises";
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-vHlppqaZ.js");
3
- require("./utils-4ODFyoqD.js");
2
+ const require_v3_engine = require("./v3-engine-Bbsrez2w.js");
3
+ require("./utils-CSA174-I.js");
4
4
  let node_fs = require("node:fs");
5
5
  let node_module = require("node:module");
6
6
  let node_path = require("node:path");
@@ -111,14 +111,7 @@ function ensureDefaultsIncluded(value) {
111
111
  return value;
112
112
  }
113
113
  function normalizeCssEntriesConfig(entries) {
114
- if (!entries) return;
115
- if (typeof entries === "string") {
116
- const trimmed = entries.trim();
117
- return trimmed ? [trimmed] : void 0;
118
- }
119
- if (!Array.isArray(entries)) return;
120
- const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
121
- return normalized.length > 0 ? normalized : void 0;
114
+ return require_v3_engine.normalizeStringListOption(entries);
122
115
  }
123
116
  function hasConfiguredCssEntries(ctx) {
124
117
  if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
@@ -372,24 +365,22 @@ function tryCreateMultiTailwindcssPatcher(groups, options) {
372
365
  }
373
366
  //#endregion
374
367
  //#region src/uni-app-x/options.ts
368
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
369
+ enabled: true,
370
+ onlyWhenStyleIsolationVersion2: true
371
+ };
372
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
373
+ enabled: false,
374
+ onlyWhenStyleIsolationVersion2: true
375
+ };
376
+ function isBooleanUniAppXShortcut(option) {
377
+ return option === true || option === false || option === void 0;
378
+ }
375
379
  function resolveComponentLocalStyles(option) {
376
- if (option === false) return {
377
- enabled: false,
378
- onlyWhenStyleIsolationVersion2: true
379
- };
380
- if (option === true || option === void 0) return {
381
- enabled: false,
382
- onlyWhenStyleIsolationVersion2: true
383
- };
380
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
384
381
  const componentLocalStyles = option.componentLocalStyles;
385
- if (componentLocalStyles === false) return {
386
- enabled: false,
387
- onlyWhenStyleIsolationVersion2: true
388
- };
389
- if (componentLocalStyles === true || componentLocalStyles === void 0) return {
390
- enabled: true,
391
- onlyWhenStyleIsolationVersion2: true
392
- };
382
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
383
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
393
384
  return {
394
385
  enabled: componentLocalStyles.enabled !== false,
395
386
  onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false