weapp-tailwindcss 5.2.8 → 5.2.9

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.
@@ -2,7 +2,7 @@ import type { OutputAsset, OutputChunk } from 'rollup';
2
2
  import type { BundleBuildState, BundleSnapshot } from '../../bundle-state.js';
3
3
  import type { ViteFrameworkCssPipelineContext, ViteFrameworkCssPipelineStrategy } from '../../shared/framework-strategy.js';
4
4
  import type { BundleMetrics } from '../metrics.js';
5
- import type { GenerateBundleContext } from '../types.js';
5
+ import type { GenerateBundleContext, PendingRememberedCssReplayUpdate } from '../types.js';
6
6
  export interface FinalizeGenerateBundleOptions {
7
7
  activeProcessCacheKeys: Set<string>;
8
8
  activeProcessHashKeys: Set<string | number>;
@@ -41,6 +41,7 @@ export interface FinalizeGenerateBundleOptions {
41
41
  opts: GenerateBundleContext['opts'];
42
42
  outDir: string;
43
43
  pendingLinkedUpdates: Array<() => void>;
44
+ pendingRememberedCssReplayUpdates: PendingRememberedCssReplayUpdate[];
44
45
  pruneViteCssCaches: GenerateBundleContext['pruneViteCssCaches'];
45
46
  recordCssAssetResult: GenerateBundleContext['recordCssAssetResult'];
46
47
  recordTimingDetail: (name: string, startedAt: number) => void;
@@ -1,7 +1,7 @@
1
1
  import type { OutputAsset, OutputChunk } from 'rollup';
2
2
  import type { ViteFrameworkCssPipelineContext, ViteFrameworkCssPipelineStrategy } from '../shared/framework-strategy.js';
3
3
  import type { BundleMetrics } from './metrics.js';
4
- import type { GenerateBundleContext, RememberedCssSource } from './types.js';
4
+ import type { GenerateBundleContext, PendingRememberedCssReplayUpdate, RememberedCssSource } from './types.js';
5
5
  interface ProcessRememberedCssReplayOptions {
6
6
  addWatchFile: (id: string) => void;
7
7
  bundle: Record<string, OutputAsset | OutputChunk>;
@@ -29,6 +29,7 @@ interface ProcessRememberedCssReplayOptions {
29
29
  getCssUserHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('./css-handler-options.js').createCssHandlerOptionsCache>['getCssUserHandlerOptions']>;
30
30
  getRememberedCssSignature?: ((file: string) => string | undefined) | undefined;
31
31
  getRememberedCssSources?: (() => Iterable<[string, RememberedCssSource]>) | undefined;
32
+ frameworkRootImportShellTargetByFile?: ReadonlyMap<string, string> | undefined;
32
33
  isNativeAppStyleTarget: boolean;
33
34
  isWebGeneratorTarget: boolean;
34
35
  lastCssRawSourceHashByFile: Map<string, string>;
@@ -39,6 +40,7 @@ interface ProcessRememberedCssReplayOptions {
39
40
  normalizeViteCssCacheKey: (file: string) => string;
40
41
  onUpdate: GenerateBundleContext['opts']['onUpdate'];
41
42
  opts: GenerateBundleContext['opts'];
43
+ pendingRememberedCssReplayUpdates: PendingRememberedCssReplayUpdate[];
42
44
  recordCssAssetResult: GenerateBundleContext['recordCssAssetResult'];
43
45
  recordViteProcessedCssAssetResult: GenerateBundleContext['recordViteProcessedCssAssetResult'];
44
46
  rootDir: string;
@@ -55,5 +57,6 @@ interface ProcessRememberedCssReplayOptions {
55
57
  activeViteCssCacheFiles: Set<string>;
56
58
  }
57
59
  export declare function shouldSkipRawRememberedCssSource(rawSource: string, sourceFile: string): boolean;
60
+ export declare function resolveRememberedCssReplayOutputFile(outputFile: string, targetByFile: ReadonlyMap<string, string> | undefined): string;
58
61
  export declare function processRememberedCssReplay(options: ProcessRememberedCssReplayOptions): Promise<void>;
59
62
  export {};
@@ -74,6 +74,12 @@ export interface RememberedCssSource {
74
74
  rawSource: string;
75
75
  sourceFile: string;
76
76
  }
77
+ export interface PendingRememberedCssReplayUpdate {
78
+ css: string;
79
+ file: string;
80
+ injectIntoMain?: boolean | undefined;
81
+ outputFile: string;
82
+ }
77
83
  export interface GenerateBundleThis {
78
84
  addWatchFile?: (id: string) => void;
79
85
  emitFile?: (emittedFile: {
@@ -27,6 +27,8 @@ export interface ViteFrameworkExtraPluginContext {
27
27
  getResolvedConfig: () => ResolvedConfig | undefined;
28
28
  isEnabled: () => boolean;
29
29
  isIosPlatform: boolean;
30
+ isNativeAppStyleTarget: () => boolean;
31
+ isWebGeneratorTarget: () => boolean;
30
32
  jsHandler: ReturnType<typeof getCompilerContext>['jsHandler'];
31
33
  mainCssChunkMatcher: ReturnType<typeof getCompilerContext>['mainCssChunkMatcher'];
32
34
  runtimeState: ReturnType<typeof createViteRuntimeClassSet>['runtimeState'];
@@ -22,7 +22,6 @@ interface CreateViteHmrCandidateStateOptions {
22
22
  generatedClassSetByFile: Map<string, Set<string>>;
23
23
  getCommand: () => string | undefined;
24
24
  getGeneratorOptions: () => ViteHmrGeneratorOptions;
25
- getSourceCandidate: (file: string) => string | undefined;
26
25
  isRuntimeAffectingSource?: (file: string) => boolean;
27
26
  }
28
27
  export declare function createViteHmrCandidateState(options: CreateViteHmrCandidateStateOptions): {
@@ -36,11 +35,13 @@ export declare function createViteHmrCandidateState(options: CreateViteHmrCandid
36
35
  hasPendingCandidateAppend: () => boolean;
37
36
  hasPendingChange: () => boolean;
38
37
  queueFullRegeneration: () => void;
38
+ reconcileRuntimeCandidates: (file: string, candidates: Iterable<string>, rootCssIds: Iterable<string>) => void;
39
39
  resolve: (generatorCode: string, file: string) => ViteSourceCandidateChange | undefined;
40
- shouldForceFullRegeneration: (resolved: boolean) => boolean;
40
+ shouldForceFullRegeneration: (file: string, resolved: boolean) => boolean;
41
41
  snapshotDebugState: () => {
42
42
  pendingAddedCandidates: number;
43
43
  pendingCssTargets: number;
44
+ pendingFullRegeneration: boolean;
44
45
  };
45
46
  };
46
47
  export {};
@@ -0,0 +1 @@
1
+ export declare function hasFrameworkHmrRuntimeSourceChange(file: string, previousSource: string | undefined, nextSource: string | undefined): boolean;
@@ -22,9 +22,11 @@ interface FrameworkSourceScanSessionOptions {
22
22
  export declare function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession: Pick<ReturnType<typeof createFrameworkSourceScanSession>, 'syncChangedFile' | 'waitForPendingSyncs'>, ctx: HmrContext): Promise<void>;
23
23
  export declare function createFrameworkSourceScanSession(options: FrameworkSourceScanSessionOptions): {
24
24
  cacheCurrent: () => void;
25
+ consumeHotUpdateChange: (id: string) => boolean;
25
26
  getStats: () => {
26
27
  pendingSourceCandidateSyncByFile: number;
27
28
  pendingSourceCandidateSyncs: number;
29
+ pendingHotUpdateChangeByFile: number;
28
30
  sourceCandidateScanCache: number;
29
31
  };
30
32
  invalidate: () => void;
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@ const require_framework = require("./framework.cjs");
3
3
  const require_generator = require("./generator-B0dCFlP1.cjs");
4
4
  const require_gulp = require("./gulp-BdoorWb5.cjs");
5
5
  const require_postcss = require("./postcss.cjs");
6
- const require_vite = require("./vite-V86H6PZa.cjs");
6
+ const require_vite = require("./vite-Dcx59GRQ.cjs");
7
7
  const require_webpack = require("./webpack-CzQrloDg.cjs");
8
8
  require("./webpack.cjs");
9
9
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMp
2
2
  import { t as createWeappTailwindcssGenerator } from "./generator-BLpOsd5O.js";
3
3
  import { t as createPlugins } from "./gulp-BWhCahA2.js";
4
4
  import weappTailwindcssPostcssPlugin from "./postcss.js";
5
- import { t as WeappTailwindcss } from "./vite-BJJqWc_F.js";
5
+ import { t as WeappTailwindcss } from "./vite-8l9_S4Qi.js";
6
6
  import { n as weappTailwindcssPackageDir } from "./webpack-CkeFhPY2.js";
7
7
  import "./webpack.js";
8
8
  import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
@@ -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 { _ as traverse$1, 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";
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;
@@ -2,6 +2,98 @@ const require_object = require("./object-C_Vr6_S5.cjs");
2
2
  const require_wxml = require("./wxml-DSMNuUaP.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;
@@ -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 {};