weapp-tailwindcss 5.2.8 → 5.2.10

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 (49) hide show
  1. package/dist/bundlers/shared/generator-css/class-selectors.d.ts +1 -0
  2. package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +3 -1
  3. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -1
  4. package/dist/bundlers/vite/generate-bundle/types.d.ts +6 -0
  5. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
  6. package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +3 -2
  7. package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
  8. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +2 -0
  9. package/dist/bundlers/vite/utils.d.ts +2 -0
  10. package/dist/cli.cjs +4 -30
  11. package/dist/cli.js +4 -30
  12. package/dist/{context-CByXWyhQ.cjs → context-C3TryIjF.cjs} +8 -13
  13. package/dist/{context-BMkbwnH8.js → context-DbL0d-zB.js} +8 -13
  14. package/dist/core.cjs +1 -1
  15. package/dist/core.js +1 -1
  16. package/dist/{gulp-BWhCahA2.js → gulp-CB_GZky7.js} +3 -3
  17. package/dist/{gulp-BdoorWb5.cjs → gulp-G6af_vyo.cjs} +4 -4
  18. package/dist/gulp.cjs +1 -1
  19. package/dist/gulp.js +1 -1
  20. package/dist/{hmr-timing-CJocHeZr.js → hmr-timing-CZu2ITV8.js} +8 -3
  21. package/dist/{hmr-timing-DiYnyg_W.cjs → hmr-timing-gbPzjYTj.cjs} +2 -2
  22. package/dist/index.cjs +3 -3
  23. package/dist/index.js +3 -3
  24. package/dist/js/literal-transform.d.ts +1 -1
  25. package/dist/{pipeline-helpers-CsNLoEX1.cjs → pipeline-helpers-CtIXw85G.cjs} +1 -1
  26. package/dist/rspack.cjs +1 -1
  27. package/dist/rspack.js +1 -1
  28. package/dist/shared/classname-transform.d.ts +2 -3
  29. package/dist/{source-candidate-scan-signature-D9FXTD9a.cjs → source-candidate-scan-signature-CTX7eBJX.cjs} +1 -1
  30. package/dist/{source-candidate-scan-signature-of-TmeOs.js → source-candidate-scan-signature-DFZlYd3t.js} +1 -1
  31. package/dist/{transform-DzVJW6Dp.cjs → transform-9wbmvHcC.cjs} +107 -8
  32. package/dist/{transform-DVGsr8cV.js → transform-BlsDWgjt.js} +107 -8
  33. package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
  34. package/dist/uni-app-x/component-local-style.d.ts +1 -0
  35. package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
  36. package/dist/uni-app-x/vite/style-request.d.ts +12 -0
  37. package/dist/{v4-generation-core-BjHT6qGC.cjs → v4-generation-core-BVd_4348.cjs} +12 -1
  38. package/dist/{vite-V86H6PZa.cjs → vite-DjU_5LY6.cjs} +216 -59
  39. package/dist/{vite-BJJqWc_F.js → vite-cIvaBul_.js} +215 -58
  40. package/dist/vite.cjs +1 -1
  41. package/dist/vite.js +1 -1
  42. package/dist/weapp-tw-css-import-rewrite-loader.cjs +2 -2
  43. package/dist/{webpack-CzQrloDg.cjs → webpack-B9lRT1no.cjs} +6 -6
  44. package/dist/{webpack-CkeFhPY2.js → webpack-CvKV7U7L.js} +4 -4
  45. package/dist/webpack.cjs +1 -1
  46. package/dist/webpack.js +1 -1
  47. package/dist/{wxml-IBzZSaQC.js → wxml-CWJc0yY-.js} +5 -31
  48. package/dist/{wxml-DSMNuUaP.cjs → wxml-DUIdXCVa.cjs} +4 -36
  49. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
2
2
  const require_generator = require("./generator-B0dCFlP1.cjs");
3
- const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
3
+ const require_v4_generation_core = require("./v4-generation-core-BVd_4348.cjs");
4
4
  const require_defaults = require("./defaults.cjs");
5
5
  const require_style_options = require("./style-options-COpQc8fr.cjs");
6
6
  let node_path = require("node:path");
package/dist/rspack.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
3
- const require_webpack = require("./webpack-CzQrloDg.cjs");
3
+ const require_webpack = require("./webpack-B9lRT1no.cjs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
6
6
  //#region src/bundlers/rspack/index.ts
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-CkeFhPY2.js";
1
+ import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-CvKV7U7L.js";
2
2
  import path from "node:path";
3
3
  //#region src/bundlers/rspack/index.ts
4
4
  const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
@@ -1,5 +1,5 @@
1
1
  import type { IJsHandlerOptions } from '../types/index.js';
2
- export type ClassNameTransformDecision = 'direct' | 'escaped' | 'fallback' | 'skip';
2
+ export type ClassNameTransformDecision = 'direct' | 'escaped' | 'skip';
3
3
  export interface ClassNameTransformResult {
4
4
  decision: ClassNameTransformDecision;
5
5
  escapedValue?: string;
@@ -7,8 +7,7 @@ export interface ClassNameTransformResult {
7
7
  interface ResolveClassNameTransformOptions extends Pick<IJsHandlerOptions, 'alwaysEscape' | 'classNameSet' | 'escapeMap' | 'jsArbitraryValueFallback' | 'jsPreserveClass' | 'tailwindcssMajorVersion'> {
8
8
  classContext?: boolean;
9
9
  }
10
- export declare function shouldEnableArbitraryValueFallback({ classNameSet, jsArbitraryValueFallback, tailwindcssMajorVersion, }: Pick<ResolveClassNameTransformOptions, 'classNameSet' | 'jsArbitraryValueFallback' | 'tailwindcssMajorVersion'>): boolean;
11
- export declare function resolveClassNameTransformWithResult(candidate: string, { alwaysEscape, classNameSet, escapeMap, jsArbitraryValueFallback, jsPreserveClass, tailwindcssMajorVersion, classContext, }: ResolveClassNameTransformOptions): ClassNameTransformResult;
10
+ export declare function resolveClassNameTransformWithResult(candidate: string, { alwaysEscape, classNameSet, escapeMap, jsPreserveClass, classContext, }: ResolveClassNameTransformOptions): ClassNameTransformResult;
12
11
  export declare function resolveClassNameTransformDecision(candidate: string, options: ResolveClassNameTransformOptions): ClassNameTransformDecision;
13
12
  export declare function shouldTransformClassNameCandidate(candidate: string, options: ResolveClassNameTransformOptions): boolean;
14
13
  export {};
@@ -3,7 +3,7 @@ const require_framework = require("./framework.cjs");
3
3
  const require_generator = require("./generator-B0dCFlP1.cjs");
4
4
  require("./auto-DtU6f3X6.cjs");
5
5
  const require_options = require("./options-zpZez7qe.cjs");
6
- const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
6
+ const require_v4_generation_core = require("./v4-generation-core-BVd_4348.cjs");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
9
9
  let node_module = require("node:module");
@@ -2,7 +2,7 @@ import { detectAppType } from "./framework.js";
2
2
  import { At as toPosixPath } from "./generator-BLpOsd5O.js";
3
3
  import { n as hasCssMacroTailwindV4CustomVariantConditionalComments } from "./auto-2dg_uhEJ.js";
4
4
  import { _ as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-2zdmASlM.js";
5
- import { x as isSourceStyleRequest } from "./hmr-timing-CJocHeZr.js";
5
+ import { S as isSourceStyleRequest } from "./hmr-timing-CZu2ITV8.js";
6
6
  import { createRequire } from "node:module";
7
7
  import path from "node:path";
8
8
  import { weappStyleInjector } from "weapp-style-injector/vite";
@@ -1,7 +1,99 @@
1
1
  const require_object = require("./object-C_Vr6_S5.cjs");
2
- const require_wxml = require("./wxml-DSMNuUaP.cjs");
2
+ const require_wxml = require("./wxml-DUIdXCVa.cjs");
3
3
  let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
4
4
  let _vue_compiler_dom = require("@vue/compiler-dom");
5
+ //#region src/uni-app-x/component-local-style-binding.ts
6
+ const OPTIONS_CLASS_SECTIONS = /* @__PURE__ */ new Set(["computed", "methods"]);
7
+ function readStaticName(path) {
8
+ if (path.isIdentifier()) return path.node.name;
9
+ if (path.isStringLiteral()) return path.node.value;
10
+ }
11
+ function isClassBindingName(path, names) {
12
+ const name = readStaticName(path);
13
+ return name !== void 0 && names.has(name);
14
+ }
15
+ function isExportDefaultOptionsObject(path) {
16
+ return path?.isObjectExpression() === true && path.parentPath?.isExportDefaultDeclaration() === true;
17
+ }
18
+ function isOptionsSectionMember(path) {
19
+ const sectionObject = path.parentPath;
20
+ if (!sectionObject?.isObjectExpression()) return false;
21
+ const sectionProperty = sectionObject.parentPath;
22
+ if (!sectionProperty?.isObjectProperty() || sectionProperty.get("value").node !== sectionObject.node) return false;
23
+ const sectionName = readStaticName(sectionProperty.get("key"));
24
+ return sectionName !== void 0 && OPTIONS_CLASS_SECTIONS.has(sectionName) && isExportDefaultOptionsObject(sectionProperty.parentPath);
25
+ }
26
+ function findContainingFunction(path) {
27
+ let current = path;
28
+ while (current) {
29
+ if (current.isFunction()) return current;
30
+ current = current.parentPath;
31
+ }
32
+ }
33
+ function isOptionsDataFunction(path) {
34
+ if (!path) return false;
35
+ if (path.isObjectMethod()) return readStaticName(path.get("key")) === "data" && isExportDefaultOptionsObject(path.parentPath);
36
+ if (!path.isFunctionExpression() && !path.isArrowFunctionExpression()) return false;
37
+ const property = path.parentPath;
38
+ return property?.isObjectProperty() === true && property.get("value").node === path.node && readStaticName(property.get("key")) === "data" && isExportDefaultOptionsObject(property.parentPath);
39
+ }
40
+ function isOptionsDataReturnMember(path) {
41
+ const dataObject = path.parentPath;
42
+ if (!dataObject?.isObjectExpression()) return false;
43
+ const parent = dataObject.parentPath;
44
+ if (parent?.isReturnStatement()) return isOptionsDataFunction(findContainingFunction(parent));
45
+ if (parent?.isArrowFunctionExpression() && parent.get("body").node === dataObject.node) return isOptionsDataFunction(parent);
46
+ return false;
47
+ }
48
+ function isProgramBinding(path, name, declaration) {
49
+ const binding = path.scope.getBinding(name);
50
+ return binding?.scope.path.isProgram() === true && (declaration === void 0 || binding.path.node === declaration);
51
+ }
52
+ function isClassAssignmentTarget(path, names) {
53
+ const directName = readStaticName(path);
54
+ if (directName !== void 0) return names.has(directName) && isProgramBinding(path, directName);
55
+ if (!path.isMemberExpression()) return false;
56
+ const object = path.get("object");
57
+ const property = path.get("property");
58
+ return object.isThisExpression() && isClassBindingName(property, names);
59
+ }
60
+ function collectClassBindingNames(ast, names) {
61
+ require_wxml.traverse(ast, { ReferencedIdentifier(path) {
62
+ names.add(path.node.name);
63
+ } });
64
+ }
65
+ function collectClassBindingRoots(ast, names) {
66
+ const roots = /* @__PURE__ */ new WeakSet();
67
+ if (names.size === 0) return roots;
68
+ require_wxml.traverse(ast, {
69
+ Program(path) {
70
+ for (const name of names) {
71
+ const binding = path.scope.getBinding(name);
72
+ if (binding?.scope === path.scope) roots.add(binding.path.node);
73
+ }
74
+ },
75
+ AssignmentExpression(path) {
76
+ if (isClassAssignmentTarget(path.get("left"), names)) roots.add(path.node);
77
+ },
78
+ ObjectMethod(path) {
79
+ if (isClassBindingName(path.get("key"), names) && isOptionsSectionMember(path)) roots.add(path.node);
80
+ },
81
+ ObjectProperty(path) {
82
+ if (isClassBindingName(path.get("key"), names) && (isOptionsSectionMember(path) || isOptionsDataReturnMember(path))) roots.add(path.node);
83
+ }
84
+ });
85
+ return roots;
86
+ }
87
+ function isClassBindingLiteralPath(path, roots) {
88
+ if (!roots) return false;
89
+ let current = path;
90
+ while (current) {
91
+ if (roots.has(current.node)) return true;
92
+ current = current.parentPath;
93
+ }
94
+ return false;
95
+ }
96
+ //#endregion
5
97
  //#region src/uni-app-x/component-local-style.ts
6
98
  const EXPRESSION_WRAPPER_PREFIX = "(\n";
7
99
  const EXPRESSION_WRAPPER_SUFFIX = "\n)";
@@ -86,6 +178,7 @@ var UniAppXComponentLocalStyleCollector = class {
86
178
  this.runtimeSet = runtimeSet;
87
179
  require_object._defineProperty(this, "aliasByUtility", /* @__PURE__ */ new Map());
88
180
  require_object._defineProperty(this, "aliasByLookup", /* @__PURE__ */ new Map());
181
+ require_object._defineProperty(this, "classBindingNames", /* @__PURE__ */ new Set());
89
182
  }
90
183
  ensureAlias(utility) {
91
184
  const cached = this.aliasByUtility.get(utility);
@@ -112,17 +205,20 @@ var UniAppXComponentLocalStyleCollector = class {
112
205
  collectRuntimeClasses(rawSource, options = {}) {
113
206
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
114
207
  try {
115
- const analysis = require_wxml.analyzeSource(require_wxml.babelParse(wrapped, {
208
+ const ast = require_wxml.babelParse(wrapped, {
116
209
  plugins: ["typescript"],
117
210
  sourceType: options.wrapExpression ? "module" : "unambiguous"
118
- }), {}, void 0, false);
211
+ });
212
+ if (options.wrapExpression) collectClassBindingNames(ast, this.classBindingNames);
213
+ const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
214
+ const analysis = require_wxml.analyzeSource(ast, {}, void 0, false);
119
215
  for (const path of analysis.targetPaths) {
120
216
  const { literal } = extractLiteralValue(path);
121
217
  const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal);
122
- const classContext = options.wrapExpression || require_wxml.isClassContextLiteralPath(path);
218
+ const classContext = options.wrapExpression || require_wxml.isClassContextLiteralPath(path) || isClassBindingLiteralPath(path, classBindingRoots);
123
219
  for (const candidate of candidates) {
124
- if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
125
- if (isRuntimeCandidate(candidate, this.runtimeSet) && !hasTopLevelVariant(candidate)) this.ensureAlias(candidate);
220
+ if (!candidate || !classContext || !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
221
+ if (!hasTopLevelVariant(candidate)) this.ensureAlias(candidate);
126
222
  }
127
223
  }
128
224
  } catch {}
@@ -131,13 +227,16 @@ var UniAppXComponentLocalStyleCollector = class {
131
227
  if (this.aliasByLookup.size === 0) return rawSource;
132
228
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
133
229
  try {
134
- const analysis = require_wxml.analyzeSource(require_wxml.babelParse(wrapped, {
230
+ const ast = require_wxml.babelParse(wrapped, {
135
231
  plugins: ["typescript"],
136
232
  sourceType: options.wrapExpression ? "module" : "unambiguous"
137
- }), {}, void 0, false);
233
+ });
234
+ const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
235
+ const analysis = require_wxml.analyzeSource(ast, {}, void 0, false);
138
236
  if (analysis.targetPaths.length === 0) return rawSource;
139
237
  const updater = new require_wxml.JsTokenUpdater();
140
238
  for (const path of analysis.targetPaths) {
239
+ if (!options.wrapExpression && !require_wxml.isClassContextLiteralPath(path) && !isClassBindingLiteralPath(path, classBindingRoots)) continue;
141
240
  const { literal, offset } = extractLiteralValue(path);
142
241
  const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal);
143
242
  if (candidates.length === 0) continue;
@@ -1,8 +1,100 @@
1
1
  import { n as _defineProperty } from "./object-Bvy6-w9r.js";
2
- import { g as babelParse, i as analyzeSource, m as replaceWxml, n as generateCode, o as JsTokenUpdater, r as createAttributeMatcher, u as isClassContextLiteralPath } from "./wxml-IBzZSaQC.js";
2
+ import { g as traverse$1, h as babelParse, i as analyzeSource, n as generateCode, o as JsTokenUpdater, p as replaceWxml, r as createAttributeMatcher, u as isClassContextLiteralPath } from "./wxml-CWJc0yY-.js";
3
3
  import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
4
4
  import MagicString from "magic-string";
5
5
  import { NodeTypes, parse } from "@vue/compiler-dom";
6
+ //#region src/uni-app-x/component-local-style-binding.ts
7
+ const OPTIONS_CLASS_SECTIONS = /* @__PURE__ */ new Set(["computed", "methods"]);
8
+ function readStaticName(path) {
9
+ if (path.isIdentifier()) return path.node.name;
10
+ if (path.isStringLiteral()) return path.node.value;
11
+ }
12
+ function isClassBindingName(path, names) {
13
+ const name = readStaticName(path);
14
+ return name !== void 0 && names.has(name);
15
+ }
16
+ function isExportDefaultOptionsObject(path) {
17
+ return path?.isObjectExpression() === true && path.parentPath?.isExportDefaultDeclaration() === true;
18
+ }
19
+ function isOptionsSectionMember(path) {
20
+ const sectionObject = path.parentPath;
21
+ if (!sectionObject?.isObjectExpression()) return false;
22
+ const sectionProperty = sectionObject.parentPath;
23
+ if (!sectionProperty?.isObjectProperty() || sectionProperty.get("value").node !== sectionObject.node) return false;
24
+ const sectionName = readStaticName(sectionProperty.get("key"));
25
+ return sectionName !== void 0 && OPTIONS_CLASS_SECTIONS.has(sectionName) && isExportDefaultOptionsObject(sectionProperty.parentPath);
26
+ }
27
+ function findContainingFunction(path) {
28
+ let current = path;
29
+ while (current) {
30
+ if (current.isFunction()) return current;
31
+ current = current.parentPath;
32
+ }
33
+ }
34
+ function isOptionsDataFunction(path) {
35
+ if (!path) return false;
36
+ if (path.isObjectMethod()) return readStaticName(path.get("key")) === "data" && isExportDefaultOptionsObject(path.parentPath);
37
+ if (!path.isFunctionExpression() && !path.isArrowFunctionExpression()) return false;
38
+ const property = path.parentPath;
39
+ return property?.isObjectProperty() === true && property.get("value").node === path.node && readStaticName(property.get("key")) === "data" && isExportDefaultOptionsObject(property.parentPath);
40
+ }
41
+ function isOptionsDataReturnMember(path) {
42
+ const dataObject = path.parentPath;
43
+ if (!dataObject?.isObjectExpression()) return false;
44
+ const parent = dataObject.parentPath;
45
+ if (parent?.isReturnStatement()) return isOptionsDataFunction(findContainingFunction(parent));
46
+ if (parent?.isArrowFunctionExpression() && parent.get("body").node === dataObject.node) return isOptionsDataFunction(parent);
47
+ return false;
48
+ }
49
+ function isProgramBinding(path, name, declaration) {
50
+ const binding = path.scope.getBinding(name);
51
+ return binding?.scope.path.isProgram() === true && (declaration === void 0 || binding.path.node === declaration);
52
+ }
53
+ function isClassAssignmentTarget(path, names) {
54
+ const directName = readStaticName(path);
55
+ if (directName !== void 0) return names.has(directName) && isProgramBinding(path, directName);
56
+ if (!path.isMemberExpression()) return false;
57
+ const object = path.get("object");
58
+ const property = path.get("property");
59
+ return object.isThisExpression() && isClassBindingName(property, names);
60
+ }
61
+ function collectClassBindingNames(ast, names) {
62
+ traverse$1(ast, { ReferencedIdentifier(path) {
63
+ names.add(path.node.name);
64
+ } });
65
+ }
66
+ function collectClassBindingRoots(ast, names) {
67
+ const roots = /* @__PURE__ */ new WeakSet();
68
+ if (names.size === 0) return roots;
69
+ traverse$1(ast, {
70
+ Program(path) {
71
+ for (const name of names) {
72
+ const binding = path.scope.getBinding(name);
73
+ if (binding?.scope === path.scope) roots.add(binding.path.node);
74
+ }
75
+ },
76
+ AssignmentExpression(path) {
77
+ if (isClassAssignmentTarget(path.get("left"), names)) roots.add(path.node);
78
+ },
79
+ ObjectMethod(path) {
80
+ if (isClassBindingName(path.get("key"), names) && isOptionsSectionMember(path)) roots.add(path.node);
81
+ },
82
+ ObjectProperty(path) {
83
+ if (isClassBindingName(path.get("key"), names) && (isOptionsSectionMember(path) || isOptionsDataReturnMember(path))) roots.add(path.node);
84
+ }
85
+ });
86
+ return roots;
87
+ }
88
+ function isClassBindingLiteralPath(path, roots) {
89
+ if (!roots) return false;
90
+ let current = path;
91
+ while (current) {
92
+ if (roots.has(current.node)) return true;
93
+ current = current.parentPath;
94
+ }
95
+ return false;
96
+ }
97
+ //#endregion
6
98
  //#region src/uni-app-x/component-local-style.ts
7
99
  const EXPRESSION_WRAPPER_PREFIX = "(\n";
8
100
  const EXPRESSION_WRAPPER_SUFFIX = "\n)";
@@ -87,6 +179,7 @@ var UniAppXComponentLocalStyleCollector = class {
87
179
  this.runtimeSet = runtimeSet;
88
180
  _defineProperty(this, "aliasByUtility", /* @__PURE__ */ new Map());
89
181
  _defineProperty(this, "aliasByLookup", /* @__PURE__ */ new Map());
182
+ _defineProperty(this, "classBindingNames", /* @__PURE__ */ new Set());
90
183
  }
91
184
  ensureAlias(utility) {
92
185
  const cached = this.aliasByUtility.get(utility);
@@ -113,17 +206,20 @@ var UniAppXComponentLocalStyleCollector = class {
113
206
  collectRuntimeClasses(rawSource, options = {}) {
114
207
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
115
208
  try {
116
- const analysis = analyzeSource(babelParse(wrapped, {
209
+ const ast = babelParse(wrapped, {
117
210
  plugins: ["typescript"],
118
211
  sourceType: options.wrapExpression ? "module" : "unambiguous"
119
- }), {}, void 0, false);
212
+ });
213
+ if (options.wrapExpression) collectClassBindingNames(ast, this.classBindingNames);
214
+ const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
215
+ const analysis = analyzeSource(ast, {}, void 0, false);
120
216
  for (const path of analysis.targetPaths) {
121
217
  const { literal } = extractLiteralValue(path);
122
218
  const candidates = splitCandidateTokens(literal);
123
- const classContext = options.wrapExpression || isClassContextLiteralPath(path);
219
+ const classContext = options.wrapExpression || isClassContextLiteralPath(path) || isClassBindingLiteralPath(path, classBindingRoots);
124
220
  for (const candidate of candidates) {
125
- if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
126
- if (isRuntimeCandidate(candidate, this.runtimeSet) && !hasTopLevelVariant(candidate)) this.ensureAlias(candidate);
221
+ if (!candidate || !classContext || !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
222
+ if (!hasTopLevelVariant(candidate)) this.ensureAlias(candidate);
127
223
  }
128
224
  }
129
225
  } catch {}
@@ -132,13 +228,16 @@ var UniAppXComponentLocalStyleCollector = class {
132
228
  if (this.aliasByLookup.size === 0) return rawSource;
133
229
  const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
134
230
  try {
135
- const analysis = analyzeSource(babelParse(wrapped, {
231
+ const ast = babelParse(wrapped, {
136
232
  plugins: ["typescript"],
137
233
  sourceType: options.wrapExpression ? "module" : "unambiguous"
138
- }), {}, void 0, false);
234
+ });
235
+ const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
236
+ const analysis = analyzeSource(ast, {}, void 0, false);
139
237
  if (analysis.targetPaths.length === 0) return rawSource;
140
238
  const updater = new JsTokenUpdater();
141
239
  for (const path of analysis.targetPaths) {
240
+ if (!options.wrapExpression && !isClassContextLiteralPath(path) && !isClassBindingLiteralPath(path, classBindingRoots)) continue;
142
241
  const { literal, offset } = extractLiteralValue(path);
143
242
  const candidates = splitCandidateTokens(literal);
144
243
  if (candidates.length === 0) continue;
@@ -0,0 +1,6 @@
1
+ import type { ParseResult } from '@babel/parser';
2
+ import type { NodePath } from '@babel/traverse';
3
+ import type { File, Node } from '@babel/types';
4
+ export declare function collectClassBindingNames(ast: ParseResult<File>, names: Set<string>): void;
5
+ export declare function collectClassBindingRoots(ast: ParseResult<File>, names: Set<string>): WeakSet<Node>;
6
+ export declare function isClassBindingLiteralPath(path: NodePath<Node>, roots?: WeakSet<Node>): boolean;
@@ -9,6 +9,7 @@ export declare class UniAppXComponentLocalStyleCollector {
9
9
  private readonly runtimeSet?;
10
10
  private aliasByUtility;
11
11
  private aliasByLookup;
12
+ private classBindingNames;
12
13
  constructor(fileId: string, runtimeSet?: Set<string> | undefined);
13
14
  private ensureAlias;
14
15
  private rewriteLiteral;
@@ -21,6 +21,8 @@ export interface CreateUniAppXPluginsOptions {
21
21
  ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
22
22
  getResolvedConfig: () => ResolvedConfig | undefined;
23
23
  isIosPlatform?: boolean;
24
+ isNativeAppStyleTarget?: (() => boolean) | undefined;
25
+ isWebGeneratorTarget?: (() => boolean) | undefined;
24
26
  isEnabled?: (() => boolean) | undefined;
25
27
  uniAppX?: InternalUserDefinedOptions['uniAppX'];
26
28
  viteProcessedCssSourceFiles?: Iterable<string> | undefined;
@@ -1,3 +1,15 @@
1
1
  export declare function isPreprocessorRequest(id: string, lang?: string): boolean;
2
2
  export declare function resolveUniAppXCssTarget(id: string): "uvue" | undefined;
3
3
  export declare function isCssModuleExport(code: string): boolean;
4
+ interface ResolvePreprocessorTransformOptions {
5
+ isIosPlatform: boolean;
6
+ isNativeAppStyleTarget: boolean;
7
+ isWebGeneratorTarget: boolean;
8
+ }
9
+ export declare function resolvePreprocessorTransform(code: string, id: string, lang: string | undefined, options: ResolvePreprocessorTransformOptions): {
10
+ result: {
11
+ code: string;
12
+ map: null;
13
+ } | undefined;
14
+ } | undefined;
15
+ export {};
@@ -3,7 +3,7 @@ const require_generator = require("./generator-B0dCFlP1.cjs");
3
3
  require("./auto-DtU6f3X6.cjs");
4
4
  const require_object = require("./object-C_Vr6_S5.cjs");
5
5
  const require_options = require("./options-zpZez7qe.cjs");
6
- const require_wxml = require("./wxml-DSMNuUaP.cjs");
6
+ const require_wxml = require("./wxml-DUIdXCVa.cjs");
7
7
  const require_style_options = require("./style-options-COpQc8fr.cjs");
8
8
  let node_fs = require("node:fs");
9
9
  let node_path = require("node:path");
@@ -4265,6 +4265,11 @@ function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
4265
4265
  }
4266
4266
  return matched;
4267
4267
  }
4268
+ function collectGeneratedRawSourceCandidatesFromCss(candidates, cssSources, escapeMap) {
4269
+ const matched = /* @__PURE__ */ new Set();
4270
+ for (const css of cssSources) for (const candidate of collectGeneratedRawSourceCandidates(candidates, css, escapeMap)) matched.add(candidate);
4271
+ return matched;
4272
+ }
4268
4273
  //#endregion
4269
4274
  //#region src/bundlers/shared/generator-css/result-helpers.ts
4270
4275
  function collectCssRuleIdentityMarkers(source) {
@@ -5342,6 +5347,12 @@ Object.defineProperty(exports, "collectFrameworkPostcssOptionsFromLoaderEntries"
5342
5347
  return collectFrameworkPostcssOptionsFromLoaderEntries;
5343
5348
  }
5344
5349
  });
5350
+ Object.defineProperty(exports, "collectGeneratedRawSourceCandidatesFromCss", {
5351
+ enumerable: true,
5352
+ get: function() {
5353
+ return collectGeneratedRawSourceCandidatesFromCss;
5354
+ }
5355
+ });
5345
5356
  Object.defineProperty(exports, "collectRawSourceClassSelectors", {
5346
5357
  enumerable: true,
5347
5358
  get: function() {