weapp-tailwindcss 5.2.7 → 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.
Files changed (65) hide show
  1. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
  2. package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +2 -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/hot-css-modules.d.ts +5 -3
  6. package/dist/bundlers/vite/module-identity.d.ts +9 -0
  7. package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +4 -0
  8. package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
  9. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +4 -1
  10. package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +4 -2
  11. package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
  12. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +4 -0
  13. package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -0
  14. package/dist/cli.js +1 -0
  15. package/dist/{context-YAvTyPV2.js → context-BMkbwnH8.js} +10 -23
  16. package/dist/{context-OqD_eBxQ.cjs → context-CByXWyhQ.cjs} +179 -25
  17. package/dist/core.cjs +1 -1
  18. package/dist/core.js +1 -1
  19. package/dist/{generator-BE34PYSC.cjs → generator-B0dCFlP1.cjs} +10 -0
  20. package/dist/{generator-DYeAa2-5.js → generator-BLpOsd5O.js} +10 -0
  21. package/dist/generator.cjs +1 -1
  22. package/dist/generator.js +1 -1
  23. package/dist/{gulp-BydhuCbr.js → gulp-BWhCahA2.js} +4 -4
  24. package/dist/{gulp-Bun9iCRE.cjs → gulp-BdoorWb5.cjs} +7 -7
  25. package/dist/gulp.cjs +1 -1
  26. package/dist/gulp.js +1 -1
  27. package/dist/{hmr-timing-Gs9P-QtZ.js → hmr-timing-CJocHeZr.js} +22 -14
  28. package/dist/{hmr-timing-D607CWrq.cjs → hmr-timing-DiYnyg_W.cjs} +3 -3
  29. package/dist/index.cjs +4 -4
  30. package/dist/index.js +4 -4
  31. package/dist/{options-hVsoTfwL.cjs → options-zpZez7qe.cjs} +1 -1
  32. package/dist/{pipeline-helpers-BLpoT8fX.cjs → pipeline-helpers-CsNLoEX1.cjs} +3 -3
  33. package/dist/postcss.cjs +1 -1
  34. package/dist/postcss.js +1 -1
  35. package/dist/presets.cjs +2 -2
  36. package/dist/presets.js +1 -1
  37. package/dist/rspack.cjs +1 -1
  38. package/dist/rspack.js +1 -1
  39. package/dist/{source-candidate-scan-signature-BGDNJE2r.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
  40. package/dist/{source-candidate-scan-signature-CdjPWQqv.js → source-candidate-scan-signature-of-TmeOs.js} +3 -3
  41. package/dist/{style-options-B_ppaVIg.cjs → style-options-COpQc8fr.cjs} +2 -2
  42. package/dist/{tailwindcss-CTpCc_nd.js → tailwindcss-2zdmASlM.js} +1 -1
  43. package/dist/{tailwindcss-DcpiKvmJ.cjs → tailwindcss-LtnGCxF0.cjs} +2 -2
  44. package/dist/{transform-BbaPIji9.js → transform-DhDe9eSf.js} +131 -15
  45. package/dist/{transform-BUEyOCT7.cjs → transform-GzbxfNGA.cjs} +130 -14
  46. package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
  47. package/dist/uni-app-x/component-local-style.d.ts +2 -0
  48. package/dist/uni-app-x/vite/author-apply.d.ts +1 -0
  49. package/dist/uni-app-x/vite/harmony-apply.d.ts +4 -1
  50. package/dist/uni-app-x/vite/native-hmr.d.ts +2 -0
  51. package/dist/uni-app-x/vite/plugin-options.d.ts +29 -0
  52. package/dist/uni-app-x/vite/style-request.d.ts +15 -0
  53. package/dist/uni-app-x/vite.d.ts +3 -24
  54. package/dist/{v4-generation-core-BrkM1vCs.cjs → v4-generation-core-BjHT6qGC.cjs} +22 -14
  55. package/dist/{vite-DM-U-Ins.js → vite-8l9_S4Qi.js} +680 -230
  56. package/dist/{vite-n0mRgEcF.cjs → vite-Dcx59GRQ.cjs} +683 -233
  57. package/dist/vite.cjs +1 -1
  58. package/dist/vite.js +1 -1
  59. package/dist/weapp-tw-css-generation-loader.cjs +1 -1
  60. package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
  61. package/dist/{webpack-BlUJf8Ru.js → webpack-CkeFhPY2.js} +6 -6
  62. package/dist/{webpack-Bf8yJwTO.cjs → webpack-CzQrloDg.cjs} +9 -9
  63. package/dist/webpack.cjs +1 -1
  64. package/dist/webpack.js +1 -1
  65. package/package.json +4 -4
@@ -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;
@@ -177,13 +276,16 @@ var UniAppXComponentLocalStyleCollector = class {
177
276
  }
178
277
  toStyleBlock() {
179
278
  if (!this.hasStyles()) return "";
180
- const lines = ["<style scoped>"];
279
+ return `<style scoped>\n${this.toStyleRules()}</style>\n`;
280
+ }
281
+ toStyleRules() {
282
+ if (!this.hasStyles()) return "";
283
+ const lines = [];
181
284
  for (const [utility, alias] of this.aliasByUtility) {
182
285
  lines.push(`.${alias} {`);
183
286
  lines.push(` @apply ${utility};`);
184
287
  lines.push("}");
185
288
  }
186
- lines.push("</style>");
187
289
  return `${lines.join("\n")}\n`;
188
290
  }
189
291
  };
@@ -251,10 +353,14 @@ function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, ma
251
353
  }
252
354
  const defaultCreateJsHandlerOptions = { babelParserOptions: { plugins: ["typescript"] } };
253
355
  const UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
254
- const SFC_BLOCK_RE = /<(template|script)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
356
+ const SFC_BLOCK_RE = /<(template|script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
255
357
  const SCRIPT_SETUP_RE = /(?:^|\s)setup(?:\s|=|$)/;
358
+ const STYLE_SCOPED_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
256
359
  function parseSfc(code) {
257
- const descriptor = { errors: [] };
360
+ const descriptor = {
361
+ errors: [],
362
+ styles: []
363
+ };
258
364
  for (const match of code.matchAll(SFC_BLOCK_RE)) {
259
365
  const type = match[1];
260
366
  const attrs = match[2] ?? "";
@@ -279,8 +385,12 @@ function parseSfc(code) {
279
385
  }
280
386
  continue;
281
387
  }
282
- if (type === "script") if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
283
- else descriptor.script ?? (descriptor.script = block);
388
+ if (type === "script") {
389
+ if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
390
+ else descriptor.script ?? (descriptor.script = block);
391
+ continue;
392
+ }
393
+ if (type === "style") descriptor.styles.push(block);
284
394
  }
285
395
  return descriptor;
286
396
  }
@@ -322,7 +432,13 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
322
432
  const { code } = jsHandler(descriptor.scriptSetup.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
323
433
  ms.update(descriptor.scriptSetup.start, descriptor.scriptSetup.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
324
434
  }
325
- if (localStyleCollector?.hasStyles()) ms.append(`\n${localStyleCollector.toStyleBlock()}`);
435
+ if (localStyleCollector?.hasStyles()) {
436
+ const scopedStyle = descriptor.styles.findLast((style) => STYLE_SCOPED_RE.test(style.attrs));
437
+ if (scopedStyle) {
438
+ const separator = scopedStyle.content.endsWith("\n") ? "" : "\n";
439
+ ms.appendLeft(scopedStyle.end, `${separator}${localStyleCollector.toStyleRules()}`);
440
+ } else ms.append(`\n${localStyleCollector.toStyleBlock()}`);
441
+ }
326
442
  }
327
443
  const result = {
328
444
  code: ms.toString(),
@@ -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;
@@ -17,5 +18,6 @@ export declare class UniAppXComponentLocalStyleCollector {
17
18
  rewriteTransformedCode(rawSource: string, options?: RewriteCodeOptions): string;
18
19
  hasStyles(): boolean;
19
20
  toStyleBlock(): string;
21
+ toStyleRules(): string;
20
22
  }
21
23
  export {};
@@ -0,0 +1 @@
1
+ export declare function retainUniAppXAuthorApplyCss(generatedCss: string, authorCss: string): string;
@@ -4,6 +4,8 @@ interface HarmonyApplyHookContext {
4
4
  }
5
5
  interface CreateUniAppXHarmonyApplyExpanderOptions {
6
6
  generateCss?: ((id: string, code: string, hookContext?: HarmonyApplyHookContext & {
7
+ disableSourceScan?: boolean;
8
+ sourceCandidates?: Iterable<string>;
7
9
  transient?: boolean;
8
10
  }) => Promise<string | undefined> | string | undefined) | undefined;
9
11
  getResolvedConfig: () => ResolvedConfig | undefined;
@@ -12,7 +14,8 @@ interface CreateUniAppXHarmonyApplyExpanderOptions {
12
14
  }
13
15
  export declare function createUniAppXHarmonyApplyExpander(options: CreateUniAppXHarmonyApplyExpanderOptions): {
14
16
  expandStyles: (code: string, id: string, hookContext: HarmonyApplyHookContext) => Promise<string>;
15
- rememberSource: (code: string, id: string) => void;
17
+ prepareStyles: (code: string, id: string) => string;
18
+ rememberSource: (code: string, id: string, authoritative?: boolean) => void;
16
19
  styleSources: Set<string>;
17
20
  utilities: Set<string>;
18
21
  };
@@ -2,6 +2,8 @@ import type { HmrContext } from 'vite';
2
2
  interface CreateUniAppXNativeHmrReloaderOptions {
3
3
  ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
4
4
  isNativeAppBuildTarget: (id?: string) => boolean;
5
+ localStyleModuleIds: Iterable<string>;
6
+ syncSourceCandidates?: (ctx: HmrContext) => Promise<void>;
5
7
  tailwindRootCssModuleIds: Iterable<string>;
6
8
  viteProcessedCssSourceFiles: Iterable<string>;
7
9
  }
@@ -0,0 +1,29 @@
1
+ import type { HmrContext, ResolvedConfig } from 'vite';
2
+ import type { AppType, ICustomAttributesEntities, InternalUserDefinedOptions, JsHandler } from '../../types/index.js';
3
+ export interface CreateUniAppXPluginsOptions {
4
+ appType: AppType;
5
+ customAttributesEntities: ICustomAttributesEntities;
6
+ disabledDefaultTemplateHandler: boolean | undefined;
7
+ mainCssChunkMatcher: NonNullable<InternalUserDefinedOptions['mainCssChunkMatcher']>;
8
+ runtimeState: {
9
+ readyPromise: Promise<unknown>;
10
+ };
11
+ styleHandler: InternalUserDefinedOptions['styleHandler'];
12
+ syncSourceCandidatesForHotUpdate?: ((ctx: HmrContext) => Promise<void>) | undefined;
13
+ tailwindRootCssModuleIds?: Iterable<string> | undefined;
14
+ generateCss?: ((id: string, code: string, hookContext?: {
15
+ addWatchFile?: (id: string) => void;
16
+ disableSourceScan?: boolean;
17
+ sourceCandidates?: Iterable<string>;
18
+ transient?: boolean;
19
+ }) => Promise<string | undefined> | string | undefined) | undefined;
20
+ jsHandler: JsHandler;
21
+ ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
22
+ getResolvedConfig: () => ResolvedConfig | undefined;
23
+ isIosPlatform?: boolean;
24
+ isNativeAppStyleTarget?: (() => boolean) | undefined;
25
+ isWebGeneratorTarget?: (() => boolean) | undefined;
26
+ isEnabled?: (() => boolean) | undefined;
27
+ uniAppX?: InternalUserDefinedOptions['uniAppX'];
28
+ viteProcessedCssSourceFiles?: Iterable<string> | undefined;
29
+ }
@@ -0,0 +1,15 @@
1
+ export declare function isPreprocessorRequest(id: string, lang?: string): boolean;
2
+ export declare function resolveUniAppXCssTarget(id: string): "uvue" | undefined;
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 {};
@@ -1,29 +1,8 @@
1
1
  import type { OutputAsset } from 'rollup';
2
- import type { Plugin, ResolvedConfig } from 'vite';
2
+ import type { Plugin } from 'vite';
3
+ import type { CreateUniAppXPluginsOptions } from './vite/plugin-options.js';
3
4
  import type { ICreateCacheReturnType } from '../cache/index.js';
4
- import type { AppType, CreateJsHandlerOptions, ICustomAttributesEntities, InternalUserDefinedOptions, JsHandler, LinkedJsModuleResult } from '../types/index.js';
5
- interface CreateUniAppXPluginsOptions {
6
- appType: AppType;
7
- customAttributesEntities: ICustomAttributesEntities;
8
- disabledDefaultTemplateHandler: boolean | undefined;
9
- mainCssChunkMatcher: NonNullable<InternalUserDefinedOptions['mainCssChunkMatcher']>;
10
- runtimeState: {
11
- readyPromise: Promise<unknown>;
12
- };
13
- styleHandler: InternalUserDefinedOptions['styleHandler'];
14
- tailwindRootCssModuleIds?: Iterable<string> | undefined;
15
- generateCss?: ((id: string, code: string, hookContext?: {
16
- addWatchFile?: (id: string) => void;
17
- transient?: boolean;
18
- }) => Promise<string | undefined> | string | undefined) | undefined;
19
- jsHandler: JsHandler;
20
- ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
21
- getResolvedConfig: () => ResolvedConfig | undefined;
22
- isIosPlatform?: boolean;
23
- isEnabled?: (() => boolean) | undefined;
24
- uniAppX?: InternalUserDefinedOptions['uniAppX'];
25
- viteProcessedCssSourceFiles?: Iterable<string> | undefined;
26
- }
5
+ import type { CreateJsHandlerOptions, InternalUserDefinedOptions, JsHandler, LinkedJsModuleResult } from '../types/index.js';
27
6
  export declare function createUniAppXPlugins(options: CreateUniAppXPluginsOptions): Plugin[];
28
7
  type ApplyLinkedResults = (linked: Record<string, LinkedJsModuleResult> | undefined) => void;
29
8
  interface CreateUniAppXAssetTaskOptions {
@@ -1,10 +1,10 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
2
- const require_generator = require("./generator-BE34PYSC.cjs");
2
+ 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
- const require_options = require("./options-hVsoTfwL.cjs");
5
+ const require_options = require("./options-zpZez7qe.cjs");
6
6
  const require_wxml = require("./wxml-DSMNuUaP.cjs");
7
- const require_style_options = require("./style-options-B_ppaVIg.cjs");
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");
10
10
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
@@ -341,15 +341,17 @@ function createSourceCandidateStore(options = {}) {
341
341
  }
342
342
  async function syncCurrentSource(id, source) {
343
343
  const normalizedId = cleanUrl(id);
344
- transformCandidatesById.delete(normalizedId);
345
- cssCandidatesById.delete(normalizedId);
346
- transformSourceById.delete(normalizedId);
347
- cssSourceById.delete(normalizedId);
348
- recompute(normalizedId);
349
344
  const previousFileCandidates = new Set(candidatesById.get(normalizedId) ?? []);
350
- const nextCandidates = await resolveCandidates(source, resolveSourceCandidateExtension(normalizedId));
345
+ const extension = resolveSourceCandidateExtension(normalizedId);
346
+ const nextCandidates = await resolveCandidates(source, extension);
351
347
  const affectedCandidates = /* @__PURE__ */ new Set([...previousFileCandidates, ...nextCandidates]);
352
348
  const previousVisibleCandidates = collectVisibleCandidates(affectedCandidates);
349
+ if (extension !== "css") {
350
+ transformCandidatesById.delete(normalizedId);
351
+ cssCandidatesById.delete(normalizedId);
352
+ transformSourceById.delete(normalizedId);
353
+ cssSourceById.delete(normalizedId);
354
+ }
353
355
  scanSourceById.set(normalizedId, source);
354
356
  replaceScanLayer(normalizedId, nextCandidates);
355
357
  return diffCandidateSets(previousVisibleCandidates, collectVisibleCandidates(affectedCandidates));
@@ -3199,14 +3201,17 @@ function collectGeneratorCssCandidates(css) {
3199
3201
  //#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
3200
3202
  function resolveTailwindV4ApplyReference(options) {
3201
3203
  const references = /* @__PURE__ */ new Set();
3202
- for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && require_generator.hasTailwindRootDirectives(source.css, { importFallback: true }) && hasTailwindThemeDirective(source.css)) references.add(source.file);
3204
+ for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && require_generator.hasTailwindRootDirectives(source.css, { importFallback: true }) && hasTailwindApplyContextDirective(source.css)) references.add(source.file);
3203
3205
  return references.size === 1 ? references.values().next().value : void 0;
3204
3206
  }
3205
- function hasTailwindThemeDirective(css) {
3207
+ function hasTailwindApplyContextDirective(css) {
3206
3208
  try {
3207
3209
  let found = false;
3208
- _weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("theme", () => {
3209
- found = true;
3210
+ _weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules((rule) => {
3211
+ if (rule.name === "theme" || rule.name === "config") {
3212
+ found = true;
3213
+ return false;
3214
+ }
3210
3215
  });
3211
3216
  return found;
3212
3217
  } catch {
@@ -4832,7 +4837,10 @@ async function executeGeneratorPipelineWithOwner(context) {
4832
4837
  const sourceCss = options.deferCssAdaptation ? (0, _weapp_tailwindcss_postcss.removeMatchingLocalCssImports)(source.css, localImports) : source.css;
4833
4838
  const generatorSource = options.disableSourceScan === true ? {
4834
4839
  ...source,
4835
- css: require_generator.removeTailwindSourceDirectives(sourceCss, { importFallback: generatorOptions.importFallback })
4840
+ css: require_generator.removeTailwindSourceDirectives(sourceCss, {
4841
+ importFallback: generatorOptions.importFallback,
4842
+ preserveApplyContext: true
4843
+ })
4836
4844
  } : sourceCss === source.css ? source : {
4837
4845
  ...source,
4838
4846
  css: sourceCss