weapp-tailwindcss 5.0.4 → 5.0.5

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 (57) hide show
  1. package/dist/{auto-BZ4n4Icc.js → auto-Cvy0zWpS.js} +1 -1
  2. package/dist/{bundle-state-D3RZHkXz.js → bundle-state-Cso_ceUo.js} +8 -2
  3. package/dist/{bundle-state-C-p9eFz1.mjs → bundle-state-DEyxCR4f.mjs} +2 -2
  4. package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
  5. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
  6. package/dist/bundlers/vite/generate-bundle.d.ts +3 -1
  7. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -0
  8. package/dist/bundlers/vite/serve-css-generation.d.ts +5 -0
  9. package/dist/bundlers/vite/uni-app-x-css-options.d.ts +2 -0
  10. package/dist/{chunk-D6vf50IK.js → chunk-emK7D4bc.js} +7 -0
  11. package/dist/core.js +1 -1
  12. package/dist/core.mjs +1 -1
  13. package/dist/css-macro.js +3 -3
  14. package/dist/{defaults-C5w9OOrj.js → defaults-BPUuNYcD.js} +1 -1
  15. package/dist/defaults.js +1 -1
  16. package/dist/{generator-DaPOkJ7W.js → generator-AD-eX8Tr.js} +2 -2
  17. package/dist/{generator-DRHWC1t-.mjs → generator-DVWLNO0n.mjs} +1 -1
  18. package/dist/generator.js +2 -2
  19. package/dist/generator.mjs +2 -2
  20. package/dist/gulp.js +6 -6
  21. package/dist/gulp.mjs +5 -5
  22. package/dist/{incremental-runtime-class-set-BYV0yQdp.js → incremental-runtime-class-set-vOetpdWs.js} +195 -43
  23. package/dist/{incremental-runtime-class-set-Dt-FUQB5.mjs → incremental-runtime-class-set-xf49kky6.mjs} +194 -42
  24. package/dist/index.js +4 -4
  25. package/dist/index.mjs +4 -4
  26. package/dist/{postcss-Du8hY-MN.js → postcss-Cbi6RFpf.js} +57 -10
  27. package/dist/{postcss-CJrmfXvi.mjs → postcss-hSUxK7oR.mjs} +55 -8
  28. package/dist/postcss-html-transform.js +1 -1
  29. package/dist/postcss.js +1 -1
  30. package/dist/postcss.mjs +1 -1
  31. package/dist/{precheck-lfenbOTF.mjs → precheck-Bsn_LMmo.mjs} +14 -3
  32. package/dist/{precheck-DgpVCvYk.js → precheck-b8Y8qZg0.js} +17 -6
  33. package/dist/presets.js +9 -5
  34. package/dist/presets.mjs +7 -3
  35. package/dist/reset.js +1 -1
  36. package/dist/{source-candidates-D7b-Jzsx.mjs → source-candidates-BsWYoIPN.mjs} +1 -1
  37. package/dist/{source-candidates-B4NvId_j.js → source-candidates-o2ZrKWzu.js} +2 -2
  38. package/dist/{tailwindcss-D5RogwtV.mjs → tailwindcss-AWaPVF2B.mjs} +1 -1
  39. package/dist/{tailwindcss-26ZFr5kv.js → tailwindcss-CpQ6X4l6.js} +3 -3
  40. package/dist/transform-BkGtbxb1.js +14868 -0
  41. package/dist/transform-DumSZmTh.mjs +14871 -0
  42. package/dist/uni-app-x/vite.d.ts +3 -0
  43. package/dist/{utils-nta4tfFs.js → utils-Dolmt8EO.js} +1 -1
  44. package/dist/{v3-engine-CBahpuIg.js → v3-engine-CM0TRa8V.js} +29 -5
  45. package/dist/{v3-engine-BCUGX3gX.mjs → v3-engine-Cczrkzqt.mjs} +22 -4
  46. package/dist/{vite-tjYalmVX.js → vite-CTuHPC91.js} +733 -79
  47. package/dist/{vite-DS4H5d0f.mjs → vite-DLXDMHON.mjs} +745 -91
  48. package/dist/vite.js +1 -1
  49. package/dist/vite.mjs +1 -1
  50. package/dist/weapp-tw-css-import-rewrite-loader.js +201 -42
  51. package/dist/{webpack-0BwLOE_f.js → webpack-BBHJYKqB.js} +8 -8
  52. package/dist/{webpack-CA-40WU9.mjs → webpack-DJFw08SK.mjs} +6 -6
  53. package/dist/webpack.js +1 -1
  54. package/dist/webpack.mjs +1 -1
  55. package/package.json +2 -3
  56. package/dist/transform-Crn84vTL.js +0 -257
  57. package/dist/transform-FAxHXVZp.mjs +0 -255
@@ -1,12 +1,12 @@
1
- const require_chunk = require("./chunk-D6vf50IK.js");
2
- const require_v3_engine = require("./v3-engine-CBahpuIg.js");
3
- const require_generator = require("./generator-DaPOkJ7W.js");
4
- const require_precheck = require("./precheck-DgpVCvYk.js");
5
- const require_utils = require("./utils-nta4tfFs.js");
6
- const require_tailwindcss = require("./tailwindcss-26ZFr5kv.js");
7
- const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-BYV0yQdp.js");
8
- const require_source_candidates = require("./source-candidates-B4NvId_j.js");
9
- const require_bundle_state = require("./bundle-state-D3RZHkXz.js");
1
+ const require_chunk = require("./chunk-emK7D4bc.js");
2
+ const require_v3_engine = require("./v3-engine-CM0TRa8V.js");
3
+ const require_generator = require("./generator-AD-eX8Tr.js");
4
+ const require_precheck = require("./precheck-b8Y8qZg0.js");
5
+ const require_utils = require("./utils-Dolmt8EO.js");
6
+ const require_tailwindcss = require("./tailwindcss-CpQ6X4l6.js");
7
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-vOetpdWs.js");
8
+ const require_source_candidates = require("./source-candidates-o2ZrKWzu.js");
9
+ const require_bundle_state = require("./bundle-state-Cso_ceUo.js");
10
10
  require("./logger-TlKT3xmR.js");
11
11
  let node_fs = require("node:fs");
12
12
  node_fs = require_chunk.__toESM(node_fs);
@@ -66,7 +66,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
66
66
  //#region src/uni-app-x/vite.ts
67
67
  let transformUVuePromise;
68
68
  function loadTransformUVue() {
69
- transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-Crn84vTL.js")).then((mod) => mod.transformUVue));
69
+ transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-BkGtbxb1.js")).then((mod) => mod.transformUVue));
70
70
  return transformUVuePromise;
71
71
  }
72
72
  const preprocessorLangs = new Set([
@@ -80,6 +80,7 @@ const INLINE_LANG_RE = /lang\.([a-z]+)/i;
80
80
  const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
81
81
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
82
82
  const UVUE_NVUE_RE = /\.(?:uvue|nvue)$/;
83
+ const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
83
84
  function isPreprocessorRequest(id, lang) {
84
85
  const normalizedLang = lang?.toLowerCase();
85
86
  if (normalizedLang && preprocessorLangs.has(normalizedLang)) return true;
@@ -93,8 +94,11 @@ function resolveUniAppXCssTarget(id) {
93
94
  function resolveUniAppXJsTransformEnabled$1(uniAppX) {
94
95
  return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
95
96
  }
97
+ function isCssModuleExport(code) {
98
+ return CSS_MODULE_EXPORT_RE.test(code);
99
+ }
96
100
  function createUniAppXPlugins(options) {
97
- const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, jsHandler, ensureRuntimeClassSet, getResolvedConfig, uniAppX } = options;
101
+ const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, uniAppX } = options;
98
102
  const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
99
103
  const isIosPlatform = providedIosPlatform ?? require_utils.resolveUniUtsPlatform().isAppIos;
100
104
  const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
@@ -113,9 +117,12 @@ function createUniAppXPlugins(options) {
113
117
  componentLocalStyleEnabled = resolveUniAppXStyleIsolationEnabled(root);
114
118
  return componentLocalStyleEnabled;
115
119
  }
116
- async function transformStyle(code, id, query) {
120
+ async function transformStyle(code, id, query, hookContext) {
117
121
  const parsed = query ?? parseVueRequest(id).query;
118
122
  if (require_bundle_state.isCSSRequest(id) || parsed.vue && parsed.type === "style") {
123
+ if (isCssModuleExport(code)) return;
124
+ const generatedCss = require_v3_engine.hasTailwindSourceDirectives(code, { importFallback: true }) || require_v3_engine.hasTailwindApplyDirective(code) ? await generateCss?.(id, code, hookContext) : void 0;
125
+ const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
119
126
  const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
120
127
  let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
121
128
  if (!styleHandlerOptions) {
@@ -134,10 +141,10 @@ function createUniAppXPlugins(options) {
134
141
  });
135
142
  cssHandlerOptionsCache.set(cacheKey, styleHandlerOptions);
136
143
  }
137
- const postcssResult = await styleHandler(code, styleHandlerOptions);
144
+ const postcssResult = await styleHandler(styleCode, styleHandlerOptions);
138
145
  const warnings = typeof postcssResult.warnings === "function" ? postcssResult.warnings() : [];
139
146
  for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
140
- const postcssMap = await require_bundle_state.formatPostcssSourceMap(postcssResult.map.toJSON(), (0, _weapp_tailwindcss_shared.cleanUrl)(id));
147
+ const postcssMap = await require_bundle_state.formatPostcssSourceMap(postcssResult.map.toJSON(), require_bundle_state.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
141
148
  return {
142
149
  code: postcssResult.css,
143
150
  map: postcssMap
@@ -148,7 +155,7 @@ function createUniAppXPlugins(options) {
148
155
  name: "weapp-tailwindcss:uni-app-x:css",
149
156
  async transform(code, id) {
150
157
  await runtimeState.readyPromise;
151
- return transformStyle(code, id);
158
+ return transformStyle(code, id, void 0, this);
152
159
  }
153
160
  }, {
154
161
  name: "weapp-tailwindcss:uni-app-x:css:pre",
@@ -158,7 +165,7 @@ function createUniAppXPlugins(options) {
158
165
  const { query } = parseVueRequest(id);
159
166
  const lang = query.lang;
160
167
  if (isIosPlatform && isPreprocessorRequest(id, lang)) return;
161
- return transformStyle(code, id, query);
168
+ return transformStyle(code, id, query, this);
162
169
  }
163
170
  }];
164
171
  const nvuePlugin = {
@@ -312,10 +319,12 @@ function createCssHandlerOptionsCache(options) {
312
319
  const isMainChunk = options.mainCssChunkMatcher(file, appType);
313
320
  const outputRoot = options.getOutputRoot?.();
314
321
  const from = outputRoot ? node_path.default.resolve(outputRoot, file) : file;
315
- const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}`;
322
+ const extraOptions = options.getExtraOptions?.(file) ?? {};
323
+ const cacheKey = `${majorVersion ?? "unknown"}:${appType ?? "unknown"}:${isMainChunk ? "1" : "0"}:${outputRoot ?? ""}:${file}:${JSON.stringify(extraOptions)}`;
316
324
  const cached = cssHandlerOptionsCache.get(cacheKey);
317
325
  if (cached) return cached;
318
326
  const created = {
327
+ ...extraOptions,
319
328
  isMainChunk,
320
329
  postcssOptions: { options: { from } },
321
330
  majorVersion,
@@ -558,6 +567,452 @@ function hasRuntimeAffectingSourceChanges(changedByType) {
558
567
  return changedByType.html.size > 0 || changedByType.js.size > 0;
559
568
  }
560
569
  //#endregion
570
+ //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
571
+ let _lazyMatch = () => {
572
+ var __lib__ = (() => {
573
+ var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
574
+ for (var n in e) m(r, n, {
575
+ get: e[n],
576
+ enumerable: true
577
+ });
578
+ }, H = (r, e, n, a) => {
579
+ if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, {
580
+ get: () => e[t],
581
+ enumerable: !(a = V(e, t)) || a.enumerable
582
+ });
583
+ return r;
584
+ }, J = (r) => H(m({}, "__esModule", { value: true }), r), w = {};
585
+ q(w, { default: () => re });
586
+ var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
587
+ const e = /* @__PURE__ */ new Map();
588
+ return (n) => {
589
+ const a = e.get(n);
590
+ if (a) return a;
591
+ const t = r(n);
592
+ return e.set(n, t), t;
593
+ };
594
+ }, rr = (r, e, n = {}) => {
595
+ const a = {
596
+ cache: {},
597
+ input: r,
598
+ index: 0,
599
+ indexMax: 0,
600
+ options: n,
601
+ output: []
602
+ };
603
+ if (v(e)(a) && a.index === r.length) return a.output;
604
+ throw new Error(`Failed to parse at index ${a.indexMax}`);
605
+ }, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
606
+ const n = {};
607
+ for (const a of r) {
608
+ if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
609
+ const t = a.charCodeAt(0);
610
+ n[t] = true;
611
+ }
612
+ return (a) => {
613
+ const t = a.index, o = a.input;
614
+ for (; a.index < o.length && o.charCodeAt(a.index) in n;) a.index += 1;
615
+ const u = a.index;
616
+ if (u > t) {
617
+ if (!h(e) && !a.options.silent) {
618
+ const s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
619
+ h(c) || a.output.push(c);
620
+ }
621
+ a.indexMax = Math.max(a.indexMax, a.index);
622
+ }
623
+ return true;
624
+ };
625
+ }, nr = (r, e) => {
626
+ const n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
627
+ return g((o) => {
628
+ t.lastIndex = o.index;
629
+ const u = t.exec(o.input);
630
+ if (u) {
631
+ if (!h(e) && !o.options.silent) {
632
+ const s = d(e) ? e(...u, o.input, String(o.index)) : e;
633
+ h(s) || o.output.push(s);
634
+ }
635
+ return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), true;
636
+ } else return false;
637
+ });
638
+ }, ar = (r, e) => (n) => {
639
+ if (n.input.startsWith(r, n.index)) {
640
+ if (!h(e) && !n.options.silent) {
641
+ const t = d(e) ? e(r, n.input, String(n.index)) : e;
642
+ h(t) || n.output.push(t);
643
+ }
644
+ return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), true;
645
+ } else return false;
646
+ }, C = (r, e, n, a) => {
647
+ const t = v(r);
648
+ return g(_(M((o) => {
649
+ let u = 0;
650
+ for (; u < n;) {
651
+ const s = o.index;
652
+ if (!t(o) || (u += 1, o.index === s)) break;
653
+ }
654
+ return u >= e;
655
+ })));
656
+ }, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, Infinity), x = (r, e) => {
657
+ const n = r.map(v);
658
+ return g(_(M((a) => {
659
+ for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return false;
660
+ return true;
661
+ })));
662
+ }, l = (r, e) => {
663
+ const n = r.map(v);
664
+ return g(_((a) => {
665
+ for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return true;
666
+ return false;
667
+ }));
668
+ }, M = (r, e = false) => {
669
+ const n = v(r);
670
+ return (a) => {
671
+ const t = a.index, o = a.output.length, u = n(a);
672
+ return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
673
+ };
674
+ }, _ = (r, e) => {
675
+ return v(r);
676
+ }, g = (() => {
677
+ let r = 0;
678
+ return (e) => {
679
+ const n = v(e), a = r += 1;
680
+ return (t) => {
681
+ var o;
682
+ if (t.options.memoization === false) return n(t);
683
+ const u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
684
+ if (c === false) return false;
685
+ if (W(c)) return t.index = c, true;
686
+ if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), true;
687
+ {
688
+ const Z = t.output.length;
689
+ if (n(t)) {
690
+ const D = t.index, U = t.output.length;
691
+ if (U > Z) {
692
+ const ee = t.output.slice(Z, U);
693
+ s.set(u, {
694
+ index: D,
695
+ output: ee
696
+ });
697
+ } else s.set(u, D);
698
+ return true;
699
+ } else return s.set(u, false), false;
700
+ }
701
+ };
702
+ };
703
+ })(), E = (r) => {
704
+ let e;
705
+ return (n) => (e || (e = v(r())), e(n));
706
+ }, v = Y((r) => {
707
+ if (d(r)) return Q(r) ? E(r) : r;
708
+ if (b(r) || X(r)) return i(r);
709
+ if (A(r)) return x(r);
710
+ if (K(r)) return l(Object.values(r));
711
+ throw new Error("Invalid rule");
712
+ }), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
713
+ let e = "";
714
+ for (; r > 0;) e = P[(r - 1) % 26] + e, r = Math.floor((r - 1) / 26);
715
+ return e;
716
+ }, O = (r) => {
717
+ let e = 0;
718
+ for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
719
+ return e;
720
+ }, S = (r, e) => {
721
+ if (e < r) return S(e, r);
722
+ const n = [];
723
+ for (; r <= e;) n.push(r++);
724
+ return n;
725
+ }, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: false }).join("")), ur = (r) => {
726
+ const e = {};
727
+ return (n) => e[n] ?? (e[n] = r(n));
728
+ }, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), fr = l([i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), i(/^(!!)+/, "")]), j = l([
729
+ i(/\/(\*\*\/)+/, "(?:/.+/|/)"),
730
+ i(/^(\*\*\/)+/, "(?:^|.*/)"),
731
+ i(/\/(\*\*)$/, "(?:/.*|$)"),
732
+ i(/\*\*/, ".*")
733
+ ]), N = l([i(/\*\/(?!\*\*\/)/, "[^/]*/"), i(/\*/, "[^/]*")]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Er = l([
734
+ y,
735
+ i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`),
736
+ br,
737
+ i(/[^\]]/, p)
738
+ ]), B = x([
739
+ $r,
740
+ tr(Ar),
741
+ f(Er),
742
+ wr
743
+ ]), Pr = i("{", "(?:"), Or = i("}", ")"), I = x([
744
+ Pr,
745
+ l([
746
+ i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")),
747
+ i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")),
748
+ i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase())
749
+ ]),
750
+ Or
751
+ ]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), F = x([
752
+ kr,
753
+ f(l([
754
+ j,
755
+ N,
756
+ k,
757
+ B,
758
+ I,
759
+ E(() => F),
760
+ y,
761
+ Fr,
762
+ Ir,
763
+ Lr
764
+ ])),
765
+ Br
766
+ ]), L = z(f(l([
767
+ sr,
768
+ cr,
769
+ lr,
770
+ fr,
771
+ j,
772
+ N,
773
+ k,
774
+ B,
775
+ I,
776
+ F,
777
+ y,
778
+ pr,
779
+ vr
780
+ ]))), Tr = i(/\\./, p), qr = i(/./, p), Yr = z(f(l([
781
+ Tr,
782
+ i(/\*\*\*+/, "*"),
783
+ i(/([^/{[(!])\*\*/, (r, e) => `${e}*`),
784
+ i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`),
785
+ qr
786
+ ]))), $ = (r, e) => {
787
+ const n = Array.isArray(r) ? r : [r];
788
+ if (!n.length) return false;
789
+ const a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
790
+ return a.some((s) => s.test(o));
791
+ };
792
+ $.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
793
+ var re = $;
794
+ return J(w);
795
+ })();
796
+ return __lib__.default || __lib__;
797
+ };
798
+ let _match;
799
+ const zeptomatch = (path, pattern) => {
800
+ if (!_match) {
801
+ _match = _lazyMatch();
802
+ _lazyMatch = null;
803
+ }
804
+ return _match(path, pattern);
805
+ };
806
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
807
+ function normalizeWindowsPath(input = "") {
808
+ if (!input) return input;
809
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
810
+ }
811
+ const _UNC_REGEX = /^[/\\]{2}/;
812
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
813
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
814
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
815
+ const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
816
+ const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
817
+ const normalize = function(path) {
818
+ if (path.length === 0) return ".";
819
+ path = normalizeWindowsPath(path);
820
+ const isUNCPath = path.match(_UNC_REGEX);
821
+ const isPathAbsolute = isAbsolute(path);
822
+ const trailingSeparator = path[path.length - 1] === "/";
823
+ path = normalizeString(path, !isPathAbsolute);
824
+ if (path.length === 0) {
825
+ if (isPathAbsolute) return "/";
826
+ return trailingSeparator ? "./" : ".";
827
+ }
828
+ if (trailingSeparator) path += "/";
829
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
830
+ if (isUNCPath) {
831
+ if (!isPathAbsolute) return `//./${path}`;
832
+ return `//${path}`;
833
+ }
834
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
835
+ };
836
+ const join = function(...segments) {
837
+ let path = "";
838
+ for (const seg of segments) {
839
+ if (!seg) continue;
840
+ if (path.length > 0) {
841
+ const pathTrailing = path[path.length - 1] === "/";
842
+ const segLeading = seg[0] === "/";
843
+ if (pathTrailing && segLeading) path += seg.slice(1);
844
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
845
+ } else path += seg;
846
+ }
847
+ return normalize(path);
848
+ };
849
+ function cwd() {
850
+ if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
851
+ return "/";
852
+ }
853
+ const resolve = function(...arguments_) {
854
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
855
+ let resolvedPath = "";
856
+ let resolvedAbsolute = false;
857
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
858
+ const path = index >= 0 ? arguments_[index] : cwd();
859
+ if (!path || path.length === 0) continue;
860
+ resolvedPath = `${path}/${resolvedPath}`;
861
+ resolvedAbsolute = isAbsolute(path);
862
+ }
863
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
864
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
865
+ return resolvedPath.length > 0 ? resolvedPath : ".";
866
+ };
867
+ function normalizeString(path, allowAboveRoot) {
868
+ let res = "";
869
+ let lastSegmentLength = 0;
870
+ let lastSlash = -1;
871
+ let dots = 0;
872
+ let char = null;
873
+ for (let index = 0; index <= path.length; ++index) {
874
+ if (index < path.length) char = path[index];
875
+ else if (char === "/") break;
876
+ else char = "/";
877
+ if (char === "/") {
878
+ if (lastSlash === index - 1 || dots === 1);
879
+ else if (dots === 2) {
880
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
881
+ if (res.length > 2) {
882
+ const lastSlashIndex = res.lastIndexOf("/");
883
+ if (lastSlashIndex === -1) {
884
+ res = "";
885
+ lastSegmentLength = 0;
886
+ } else {
887
+ res = res.slice(0, lastSlashIndex);
888
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
889
+ }
890
+ lastSlash = index;
891
+ dots = 0;
892
+ continue;
893
+ } else if (res.length > 0) {
894
+ res = "";
895
+ lastSegmentLength = 0;
896
+ lastSlash = index;
897
+ dots = 0;
898
+ continue;
899
+ }
900
+ }
901
+ if (allowAboveRoot) {
902
+ res += res.length > 0 ? "/.." : "..";
903
+ lastSegmentLength = 2;
904
+ }
905
+ } else {
906
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
907
+ else res = path.slice(lastSlash + 1, index);
908
+ lastSegmentLength = index - lastSlash - 1;
909
+ }
910
+ lastSlash = index;
911
+ dots = 0;
912
+ } else if (char === "." && dots !== -1) ++dots;
913
+ else dots = -1;
914
+ }
915
+ return res;
916
+ }
917
+ const isAbsolute = function(p) {
918
+ return _IS_ABSOLUTE_RE.test(p);
919
+ };
920
+ const toNamespacedPath = function(p) {
921
+ return normalizeWindowsPath(p);
922
+ };
923
+ const extname = function(p) {
924
+ if (p === "..") return "";
925
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
926
+ return match && match[1] || "";
927
+ };
928
+ const relative = function(from, to) {
929
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
930
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
931
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
932
+ const _fromCopy = [..._from];
933
+ for (const segment of _fromCopy) {
934
+ if (_to[0] !== segment) break;
935
+ _from.shift();
936
+ _to.shift();
937
+ }
938
+ return [..._from.map(() => ".."), ..._to].join("/");
939
+ };
940
+ const dirname = function(p) {
941
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
942
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
943
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
944
+ };
945
+ const format = function(p) {
946
+ const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
947
+ const segments = [
948
+ p.root,
949
+ p.dir,
950
+ p.base ?? (p.name ?? "") + ext
951
+ ].filter(Boolean);
952
+ return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
953
+ };
954
+ const basename = function(p, extension) {
955
+ const segments = normalizeWindowsPath(p).split("/");
956
+ let lastSegment = "";
957
+ for (let i = segments.length - 1; i >= 0; i--) {
958
+ const val = segments[i];
959
+ if (val) {
960
+ lastSegment = val;
961
+ break;
962
+ }
963
+ }
964
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
965
+ };
966
+ const parse = function(p) {
967
+ const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
968
+ const base = basename(p);
969
+ const extension = extname(base);
970
+ return {
971
+ root,
972
+ dir: dirname(p),
973
+ base,
974
+ ext: extension,
975
+ name: base.slice(0, base.length - extension.length)
976
+ };
977
+ };
978
+ const matchesGlob = (path, pattern) => {
979
+ return zeptomatch(pattern, normalize(path));
980
+ };
981
+ const _path = {
982
+ __proto__: null,
983
+ basename,
984
+ dirname,
985
+ extname,
986
+ format,
987
+ isAbsolute,
988
+ join,
989
+ matchesGlob,
990
+ normalize,
991
+ normalizeString,
992
+ parse,
993
+ relative,
994
+ resolve,
995
+ sep: "/",
996
+ toNamespacedPath
997
+ };
998
+ //#endregion
999
+ //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs
1000
+ const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
1001
+ const _platforms = {
1002
+ posix: void 0,
1003
+ win32: void 0
1004
+ };
1005
+ const mix = (del = delimiter) => {
1006
+ return new Proxy(_path, { get(_, prop) {
1007
+ if (prop === "delimiter") return del;
1008
+ if (prop === "posix") return posix;
1009
+ if (prop === "win32") return win32;
1010
+ return _platforms[prop] || _path[prop];
1011
+ } });
1012
+ };
1013
+ const posix = /* @__PURE__ */ mix(":");
1014
+ const win32 = /* @__PURE__ */ mix(";");
1015
+ //#endregion
561
1016
  //#region src/bundlers/vite/processed-css-assets.ts
562
1017
  const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
563
1018
  function isCssOutputFile(file) {
@@ -574,11 +1029,53 @@ function appendCss(baseCss, css) {
574
1029
  if (css.length === 0) return baseCss;
575
1030
  return `${baseCss}\n${css}`;
576
1031
  }
1032
+ function removeTailwindSourceMediaWrappers(css) {
1033
+ if (!css.includes("@media source(")) return css;
1034
+ try {
1035
+ const root = postcss.default.parse(css);
1036
+ let changed = false;
1037
+ root.walkAtRules("media", (atRule) => {
1038
+ if (!atRule.params.startsWith("source(")) return;
1039
+ if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
1040
+ else atRule.remove();
1041
+ changed = true;
1042
+ });
1043
+ root.walkAtRules((atRule) => {
1044
+ if (atRule.nodes && atRule.nodes.length === 0) {
1045
+ atRule.remove();
1046
+ changed = true;
1047
+ }
1048
+ });
1049
+ return changed ? root.toString() : css;
1050
+ } catch {
1051
+ return css.replace(/@media\s+source\([^)]*\)\s*\{\s*\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/?\s*\}/gi, "").replace(/@media\s+source\([^)]*\)\s*\{\s*\}/gi, "");
1052
+ }
1053
+ }
1054
+ function removeTailwindEntryDirectivesFromCss(css) {
1055
+ return require_v3_engine.removeTailwindSourceDirectives(removeTailwindSourceMediaWrappers(css));
1056
+ }
577
1057
  function stripStyleExtension(file) {
578
1058
  return file.replace(/[?#].*$/, "").replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)$/i, "");
579
1059
  }
580
- function isAppOriginCssFile$1(file) {
581
- return stripStyleExtension(file).split("/").pop() === "app-origin";
1060
+ function isStyleImportRequest(request) {
1061
+ return typeof request === "string" && request.length > 0 && !/^(?:https?:)?\/\//i.test(request) && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request);
1062
+ }
1063
+ function resolveImportedStyleFile(targetFile, request) {
1064
+ if (!isStyleImportRequest(request)) return;
1065
+ const cleanRequest = request.replace(/[?#].*$/, "");
1066
+ if (cleanRequest.startsWith("/")) return require_bundle_state.normalizeOutputPathKey(cleanRequest.slice(1));
1067
+ const targetDir = posix.posix.dirname(require_bundle_state.normalizeOutputPathKey(targetFile));
1068
+ return require_bundle_state.normalizeOutputPathKey(posix.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
1069
+ }
1070
+ function collectImportedStyleFiles(css, targetFile) {
1071
+ const imports = /* @__PURE__ */ new Set();
1072
+ try {
1073
+ postcss.default.parse(css).walkAtRules("import", (atRule) => {
1074
+ const importedFile = resolveImportedStyleFile(targetFile, require_v3_engine.parseImportRequest(atRule.params));
1075
+ if (importedFile) imports.add(importedFile);
1076
+ });
1077
+ } catch {}
1078
+ return imports;
582
1079
  }
583
1080
  function normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile) {
584
1081
  return resolveViteProcessedCssOutputFile?.(markerFile) ?? markerFile;
@@ -595,6 +1092,7 @@ function resolveViteProcessedCssAssetSource(file, rawSource, resolveViteProcesse
595
1092
  }
596
1093
  function shouldInjectViteProcessedCssResult(opts, targetFile, sourceFile, options) {
597
1094
  if (options.injectIntoMain === true) return true;
1095
+ if (options.injectIntoMain === false) return false;
598
1096
  const targetFileKey = require_bundle_state.normalizeOutputPathKey(targetFile);
599
1097
  const sourceFileKey = require_bundle_state.normalizeOutputPathKey(sourceFile);
600
1098
  const sourceBaseName = sourceFileKey.replace(/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i, "").split("/").pop();
@@ -612,7 +1110,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
612
1110
  options.markCssAssetProcessed?.(output, file);
613
1111
  options.recordCssAssetResult?.(file, nextCss);
614
1112
  const resolvedOutputFile = options.resolveViteProcessedCssOutputFile?.(file) ?? file;
615
- const shouldReplayIntoMainCss = options.opts != null && (require_bundle_state.normalizeOutputPathKey(resolvedOutputFile) !== require_bundle_state.normalizeOutputPathKey(file) && options.opts.mainCssChunkMatcher(resolvedOutputFile, options.opts.appType) || isAppOriginCssFile$1(file));
1113
+ const shouldReplayIntoMainCss = options.opts != null && require_bundle_state.normalizeOutputPathKey(resolvedOutputFile) !== require_bundle_state.normalizeOutputPathKey(file) && options.opts.mainCssChunkMatcher(resolvedOutputFile, options.opts.appType);
616
1114
  options.recordViteProcessedCssAssetResult?.(file, nextCss, { injectIntoMain: shouldReplayIntoMainCss || void 0 });
617
1115
  options.debug?.("collect vite-processed css asset: %s bytes=%d", file, nextCss.length);
618
1116
  collected++;
@@ -639,9 +1137,11 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
639
1137
  if (!options.opts.cssMatcher(file) || !options.opts.mainCssChunkMatcher(file, options.opts.appType)) continue;
640
1138
  const mainFileKey = require_bundle_state.normalizeOutputPathKey(file);
641
1139
  const originalSource = readAssetSource(output);
642
- let nextCss = originalSource;
1140
+ let nextCss = removeTailwindEntryDirectivesFromCss(originalSource);
1141
+ const importedStyleFiles = collectImportedStyleFiles(nextCss, file);
643
1142
  for (const record of viteCssResults) {
644
1143
  if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
1144
+ if (importedStyleFiles.has(require_bundle_state.normalizeOutputPathKey(record.file))) continue;
645
1145
  const css = require_bundle_state.stripBundlerGeneratedCssMarkers(record.css).trim();
646
1146
  if (css.length === 0) continue;
647
1147
  const mergedLayerCss = require_incremental_runtime_class_set.mergeMarkedUserLayerComponentsCss(nextCss, css);
@@ -663,6 +1163,16 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
663
1163
  return injected;
664
1164
  }
665
1165
  //#endregion
1166
+ //#region src/bundlers/vite/uni-app-x-css-options.ts
1167
+ function resolveUniAppXNativeCssHandlerOptions(opts) {
1168
+ if (opts.appType !== "uni-app-x" || !require_tailwindcss.isUniAppXEnabled(opts.uniAppX) || !require_utils.resolveUniUtsPlatform().isApp) return {};
1169
+ return {
1170
+ uniAppX: true,
1171
+ uniAppXCssTarget: "uvue",
1172
+ uniAppXUnsupported: require_tailwindcss.resolveUniAppXOptions(opts.uniAppX).uvueUnsupported
1173
+ };
1174
+ }
1175
+ //#endregion
666
1176
  //#region src/bundlers/vite/generate-bundle.ts
667
1177
  function addSiblingCssFile(files, file) {
668
1178
  if (file.endsWith(".wxml")) files.add(file.replace(/\.wxml$/, ".wxss"));
@@ -687,9 +1197,9 @@ function resolveViteCssOutputFile(file, opts, isWebGeneratorTarget) {
687
1197
  if (isWebGeneratorTarget || opts.cssMatcher(file) || !SOURCE_STYLE_OUTPUT_EXT_RE.test(file) || !require_bundle_state.isCSSRequest(file)) return file;
688
1198
  return file.replace(SOURCE_STYLE_OUTPUT_EXT_RE, ".wxss");
689
1199
  }
690
- function resolveViteCssPipelineOutputFile(file, _opts, rootDir, isWebGeneratorTarget = false) {
1200
+ function resolveViteCssPipelineOutputFile(file, _opts, rootDir, isWebGeneratorTarget = false, preserveCssExtension = false) {
691
1201
  const normalizedFile = resolveReplayCssOutputFile(rootDir, file);
692
- if (isWebGeneratorTarget || MINI_PROGRAM_STYLE_OUTPUT_EXT_RE.test(normalizedFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedFile) || !require_bundle_state.isCSSRequest(normalizedFile)) return normalizedFile;
1202
+ if (isWebGeneratorTarget || preserveCssExtension || MINI_PROGRAM_STYLE_OUTPUT_EXT_RE.test(normalizedFile) || !CSS_SOURCE_OUTPUT_EXT_RE.test(normalizedFile) || !require_bundle_state.isCSSRequest(normalizedFile)) return normalizedFile;
693
1203
  return normalizedFile.replace(CSS_SOURCE_OUTPUT_EXT_RE, ".wxss");
694
1204
  }
695
1205
  function canProcessViteSourceStyleAsCss(source, file) {
@@ -716,9 +1226,15 @@ function stripStyleFileExtension(file) {
716
1226
  function isAppOriginCssFile(file) {
717
1227
  return node_path.default.basename(stripStyleFileExtension(file)) === "app-origin";
718
1228
  }
1229
+ function isMainAppCssFile(file) {
1230
+ return node_path.default.basename(stripStyleFileExtension(file)) === "app";
1231
+ }
719
1232
  function normalizeCssSourceForCompare(css) {
720
1233
  return css.trim();
721
1234
  }
1235
+ function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash) {
1236
+ return `${cssRuntimeSignature}:${cssRuntimeAffectingHash}`;
1237
+ }
722
1238
  async function createScopedGeneratorCandidateSignature(rawSource, sourceFile, fallbackSignature, getSourceCandidatesForEntries, options = {}) {
723
1239
  if (!getSourceCandidatesForEntries || !rawSource.includes("@source")) return fallbackSignature;
724
1240
  const resolved = await require_v3_engine.resolveTailwindV4EntriesFromCssCached(rawSource, node_path.default.dirname(node_path.default.resolve(sourceFile.replace(/[?#].*$/, ""))));
@@ -757,10 +1273,35 @@ function collectParentDirectories(file) {
757
1273
  return directories;
758
1274
  }
759
1275
  function hasMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) {
1276
+ return scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) > 0;
1277
+ }
1278
+ function scoreMatchingStyleFileBase(outputFile, sourceFile, outputRoot, sourceRoot) {
760
1279
  const outputBases = collectStyleFileMatchBases(outputFile, [outputRoot]);
761
1280
  const sourceBases = collectStyleFileMatchBases(sourceFile, [sourceRoot, ...collectParentDirectories(sourceFile)]);
762
- for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
763
- return false;
1281
+ let bestScore = 0;
1282
+ for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
1283
+ else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
1284
+ else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
1285
+ return bestScore;
1286
+ }
1287
+ function findRememberedCssSource(sources, outputFile, file, originalSource, outputRoot, sourceRoot) {
1288
+ if (!sources) return;
1289
+ const rememberedSources = [...sources].map(([, remembered]) => remembered);
1290
+ const originalFiles = [
1291
+ file,
1292
+ originalSource.originalFileName,
1293
+ ...originalSource.originalFileNames ?? []
1294
+ ].filter((item) => typeof item === "string" && item.length > 0);
1295
+ const sourceMatched = rememberedSources.find((remembered) => originalFiles.some((originalFile) => require_bundle_state.normalizeOutputPathKey(remembered.sourceFile) === require_bundle_state.normalizeOutputPathKey(originalFile)));
1296
+ if (sourceMatched) return sourceMatched;
1297
+ const outputMatched = rememberedSources.find((remembered) => require_bundle_state.normalizeOutputPathKey(remembered.outputFile) === require_bundle_state.normalizeOutputPathKey(outputFile));
1298
+ if (outputMatched) return outputMatched;
1299
+ const scoredMatches = rememberedSources.filter((remembered) => !(isMainAppCssFile(outputFile) && isAppOriginCssFile(remembered.outputFile))).map((remembered) => ({
1300
+ remembered,
1301
+ score: Math.max(scoreMatchingStyleFileBase(outputFile, remembered.sourceFile, outputRoot, sourceRoot), scoreMatchingStyleFileBase(outputFile, remembered.outputFile, outputRoot, sourceRoot))
1302
+ })).filter((match) => match.score > 0).sort((a, b) => b.score - a.score);
1303
+ const bestScore = scoredMatches[0]?.score;
1304
+ return bestScore && scoredMatches.filter((match) => match.score === bestScore).length === 1 ? scoredMatches[0]?.remembered : void 0;
764
1305
  }
765
1306
  function collectConfiguredTailwindV4CssSources(opts) {
766
1307
  const patcherCssSources = opts.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssSources ?? [];
@@ -823,14 +1364,16 @@ function createGenerateBundleHook(context) {
823
1364
  getAppType: () => context.opts.appType,
824
1365
  mainCssChunkMatcher: context.opts.mainCssChunkMatcher,
825
1366
  getMajorVersion: () => context.runtimeState.twPatcher.majorVersion,
826
- getOutputRoot: () => currentOutDir
1367
+ getOutputRoot: () => currentOutDir,
1368
+ getExtraOptions: () => resolveUniAppXNativeCssHandlerOptions(context.opts)
827
1369
  });
828
1370
  return async function generateBundle(_opt, bundle) {
829
1371
  const addWatchFile = (id) => this.addWatchFile?.(id);
830
- const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, recordGeneratorCandidates, hmrTimingRecorder } = context;
1372
+ const { opts, runtimeState, ensureBundleRuntimeClassSet, debug, getResolvedConfig, markCssAssetProcessed, isCssAssetProcessed, isViteProcessedCssAsset, recordCssAssetResult, recordViteProcessedCssAssetResult, getViteProcessedCssAssetResults, getViteProcessedCssAssetResult, getSourceCandidates, getSourceCandidatesForEntries, waitForSourceCandidateSyncs, rememberCssSource, refreshRememberedCssSource, getRememberedCssSources, getRememberedCssSignature, setRememberedCssSignature, recordGeneratorCandidates, hmrTimingRecorder } = context;
831
1373
  const { cache, onEnd, onStart, onUpdate, styleHandler, templateHandler, jsHandler, uniAppX } = opts;
832
1374
  const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
833
1375
  const isWebGeneratorTarget = generatorOptions.target === "web";
1376
+ const isNativeAppStyleTarget = require_utils.resolveUniUtsPlatform().isApp;
834
1377
  const shouldGenerateWebCssByGenerator = isWebGeneratorTarget && runtimeState.twPatcher.majorVersion === 3;
835
1378
  const { getCssHandlerOptions, getCssUserHandlerOptions } = cssHandlerOptions;
836
1379
  const resolvedConfig = getResolvedConfig();
@@ -845,7 +1388,7 @@ function createGenerateBundleHook(context) {
845
1388
  markCssAssetProcessed,
846
1389
  recordCssAssetResult,
847
1390
  recordViteProcessedCssAssetResult,
848
- resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget),
1391
+ resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget),
849
1392
  debug
850
1393
  });
851
1394
  const hmrTimingStartedAt = performance.now();
@@ -1041,29 +1584,30 @@ function createGenerateBundleHook(context) {
1041
1584
  const viteProcessedCssAsset = isViteProcessedCssAsset?.(originalSource, file) === true || hasViteProcessedCssRecord;
1042
1585
  const cssAssetProcessed = isCssAssetProcessed?.(originalSource, file) === true;
1043
1586
  const alreadyProcessedCssAsset = viteProcessedCssAsset || cssAssetProcessed;
1044
- const rememberedCssSource = viteProcessedCssAsset && getRememberedCssSources != null ? [...getRememberedCssSources()].map(([, remembered]) => remembered).find((remembered) => {
1045
- const originalFiles = [
1046
- file,
1047
- originalSource.originalFileName,
1048
- ...originalSource.originalFileNames ?? []
1049
- ].filter((item) => typeof item === "string" && item.length > 0);
1050
- return require_bundle_state.normalizeOutputPathKey(remembered.outputFile) === require_bundle_state.normalizeOutputPathKey(outputFile) || originalFiles.some((originalFile) => require_bundle_state.normalizeOutputPathKey(remembered.sourceFile) === require_bundle_state.normalizeOutputPathKey(originalFile));
1051
- }) : void 0;
1052
- const generatorRawSource = viteProcessedCssAsset ? rememberedCssSource?.rawSource ?? rawSource : rawSource;
1053
- const generatorSourceFile = viteProcessedCssAsset ? rememberedCssSource?.sourceFile ?? file : file;
1587
+ let rememberedCssSource = findRememberedCssSource(getRememberedCssSources?.(), outputFile, file, originalSource, outDir, opts.tailwindcssBasedir);
1588
+ if (rememberedCssSource != null) rememberedCssSource = await refreshRememberedCssSource?.(rememberedCssSource) ?? rememberedCssSource;
1589
+ const useRememberedCssSource = rememberedCssSource != null && require_bundle_state.normalizeOutputPathKey(rememberedCssSource.sourceFile) !== require_bundle_state.normalizeOutputPathKey(file);
1590
+ const vitePipelineCssAsset = viteProcessedCssAsset || useRememberedCssSource;
1591
+ const generatorRawSource = vitePipelineCssAsset ? rememberedCssSource?.rawSource ?? rawSource : rawSource;
1592
+ const hasRememberedApplySource = vitePipelineCssAsset && rememberedCssSource != null && require_v3_engine.hasTailwindApplyDirective(generatorRawSource);
1593
+ const hasDifferentRememberedCssSource = rememberedCssSource != null && normalizeCssSourceForCompare(rememberedCssSource.rawSource) !== normalizeCssSourceForCompare(rawSource);
1594
+ const hasCurrentTailwindGenerationDirective = require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindApplyDirective(rawSource);
1595
+ const hasRememberedApplyDirective = rememberedCssSource != null && require_v3_engine.hasTailwindApplyDirective(rememberedCssSource.rawSource);
1596
+ const hasStaleViteProcessedCssSource = vitePipelineCssAsset && hasDifferentRememberedCssSource && (hasCurrentTailwindGenerationDirective || hasRememberedApplyDirective);
1597
+ const generatorSourceFile = vitePipelineCssAsset ? rememberedCssSource?.sourceFile ?? file : file;
1054
1598
  const outputCssHandlerOptions = getCssHandlerOptions(outputFile);
1055
- const cssHandlerOptions = viteProcessedCssAsset ? {
1599
+ const cssHandlerOptions = vitePipelineCssAsset ? {
1056
1600
  ...getCssHandlerOptions(generatorSourceFile),
1057
1601
  isMainChunk: outputCssHandlerOptions.isMainChunk || isAppOriginCssFile(file)
1058
1602
  } : getCssHandlerOptions(file);
1059
1603
  const generatorCssUserHandlerOptions = getCssUserHandlerOptions(generatorSourceFile);
1060
- const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? require_bundle_state.createRuntimeAffectingSourceSignature(generatorRawSource, "css");
1061
- const cssRuntimeAffectingHash = snapshot.runtimeAffectingHashByFile.get(file) ?? cache.computeHash(cssRuntimeAffectingSignature);
1604
+ const cssRuntimeAffectingSignature = vitePipelineCssAsset ? require_bundle_state.createRuntimeAffectingSourceSignature(generatorRawSource, "css") : snapshot.runtimeAffectingSignatureByFile.get(file) ?? require_bundle_state.createRuntimeAffectingSourceSignature(generatorRawSource, "css");
1605
+ const cssRuntimeAffectingHash = vitePipelineCssAsset ? cache.computeHash(cssRuntimeAffectingSignature) : snapshot.runtimeAffectingHashByFile.get(file) ?? cache.computeHash(cssRuntimeAffectingSignature);
1062
1606
  const cssShareScope = createCssTransformShareScopeKey(opts, generatorSourceFile, generatorRawSource);
1063
1607
  const shouldRegenerateAppOriginCss = viteProcessedCssAsset && isAppOriginCssFile(file);
1064
- const shouldTrackGeneratorRuntime = shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || shouldRegenerateAppOriginCss);
1608
+ const shouldTrackGeneratorRuntime = hasStaleViteProcessedCssSource || shouldProcessTailwindGeneration && (!useIncrementalMode || cssHandlerOptions.isMainChunk || processFiles.css.has(file) || runtimeLinkedCssFiles.has(file) || shouldRegenerateAppOriginCss);
1065
1609
  const canRegenerateProcessedMainCss = cssHandlerOptions.isMainChunk && (getViteProcessedCssAssetResult?.(file)?.injectIntoMain === true || shouldRegenerateAppOriginCss);
1066
- if (alreadyProcessedCssAsset && (!shouldTrackGeneratorRuntime || !canRegenerateProcessedMainCss)) {
1610
+ if (alreadyProcessedCssAsset && !hasStaleViteProcessedCssSource && !hasRememberedApplySource && (!shouldTrackGeneratorRuntime || !canRegenerateProcessedMainCss)) {
1067
1611
  const nextCss = require_bundle_state.stripBundlerGeneratedCssMarkers(rawSource);
1068
1612
  applyCssResult(nextCss);
1069
1613
  markCssAssetProcessed?.(originalSource, outputFile);
@@ -1075,6 +1619,7 @@ function createGenerateBundleHook(context) {
1075
1619
  const trackedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? generatorCandidateSignature : "generator:stable";
1076
1620
  const scopedGeneratorCandidateSignature = shouldTrackGeneratorRuntime ? await createScopedGeneratorCandidateSignature(generatorRawSource, generatorSourceFile, trackedGeneratorCandidateSignature, getSourceCandidatesForEntries, { includeFallbackSignature: cssHandlerOptions.isMainChunk }) : trackedGeneratorCandidateSignature;
1077
1621
  const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, scopedGeneratorCandidateSignature);
1622
+ const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash);
1078
1623
  const cssSharedCacheKey = `${cssShareScope}:${cssRuntimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingSignature}`;
1079
1624
  if (!shouldTrackGeneratorRuntime) {
1080
1625
  const lastCss = lastCssResultByFile.get(outputFile) ?? lastCssResultByFile.get(file);
@@ -1090,7 +1635,7 @@ function createGenerateBundleHook(context) {
1090
1635
  cache,
1091
1636
  cacheKey: file,
1092
1637
  hashKey: `${file}:css:${cssRuntimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}`,
1093
- hash: `${getSnapshotHash(snapshot.runtimeAffectingHashByFile, file, cssRuntimeAffectingHash)}:${scopedGeneratorCandidateSignature}`,
1638
+ hash: `${cssRuntimeAffectingHash}:${scopedGeneratorCandidateSignature}`,
1094
1639
  applyResult(source) {
1095
1640
  applyCssResult(source);
1096
1641
  lastCssResultByFile.set(outputFile, source);
@@ -1099,7 +1644,7 @@ function createGenerateBundleHook(context) {
1099
1644
  outputFile,
1100
1645
  rawSource: generatorRawSource,
1101
1646
  sourceFile: generatorSourceFile
1102
- }, cssRuntimeSignature);
1647
+ }, rememberedCssRuntimeSignature);
1103
1648
  },
1104
1649
  onCacheHit() {
1105
1650
  metrics.css.cacheHits++;
@@ -1119,7 +1664,7 @@ function createGenerateBundleHook(context) {
1119
1664
  const runTransform = async () => {
1120
1665
  const start = performance.now();
1121
1666
  await runtimeState.readyPromise;
1122
- const previousCss = useIncrementalMode && !hasRuntimeAffectingChanges && !snapshot.changedByType.css.has(file) ? lastCssResultByFile.get(outputFile) ?? lastCssResultByFile.get(file) : void 0;
1667
+ const previousCss = !vitePipelineCssAsset && useIncrementalMode && !hasRuntimeAffectingChanges && !snapshot.changedByType.css.has(file) ? lastCssResultByFile.get(outputFile) ?? lastCssResultByFile.get(file) : void 0;
1123
1668
  const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
1124
1669
  opts,
1125
1670
  runtimeState,
@@ -1138,7 +1683,8 @@ function createGenerateBundleHook(context) {
1138
1683
  if (debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorRawSource, generated.css));
1139
1684
  debug("css generated result: %s bytes=%d", file, generated.css.length);
1140
1685
  recordCssAssetResult?.(outputFile, generated.css);
1141
- if (viteProcessedCssAsset && cssHandlerOptions.isMainChunk) recordViteProcessedCssAssetResult?.(file, generated.css, { injectIntoMain: true });
1686
+ if (vitePipelineCssAsset && cssHandlerOptions.isMainChunk) recordViteProcessedCssAssetResult?.(file, generated.css, { injectIntoMain: !isAppOriginCssFile(file) });
1687
+ if (vitePipelineCssAsset) recordViteProcessedCssAssetResult?.(outputFile, generated.css, { injectIntoMain: false });
1142
1688
  metrics.css.elapsed += measureElapsed(start);
1143
1689
  metrics.css.transformed++;
1144
1690
  debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, outputFile);
@@ -1150,8 +1696,8 @@ function createGenerateBundleHook(context) {
1150
1696
  debug("css preserve web target: %s", outputFile);
1151
1697
  return rawSource;
1152
1698
  }
1153
- const { css } = await styleHandler(rawSource, getCssHandlerOptions(file));
1154
- if (debugCssDiff) debug("css diff %s: %s", file, summarizeStringDiff(rawSource, css));
1699
+ const { css } = await styleHandler(generatorRawSource, cssHandlerOptions);
1700
+ if (debugCssDiff) debug("css diff %s: %s", generatorSourceFile, summarizeStringDiff(generatorRawSource, css));
1155
1701
  metrics.css.elapsed += measureElapsed(start);
1156
1702
  metrics.css.transformed++;
1157
1703
  return css;
@@ -1266,12 +1812,12 @@ function createGenerateBundleHook(context) {
1266
1812
  });
1267
1813
  }
1268
1814
  }
1269
- if (useIncrementalMode) for (const [key, remembered] of getRememberedCssSources?.() ?? []) {
1270
- const { outputFile: rememberedOutputFile, rawSource, sourceFile } = remembered;
1271
- const outputFile = resolveViteCssPipelineOutputFile(rememberedOutputFile, opts, rootDir, isWebGeneratorTarget);
1272
- const cssHandlerOptions = getCssHandlerOptions(sourceFile);
1273
- const cssRuntimeSignature = createCssRuntimeSignature(runtimeSignature, await createScopedGeneratorCandidateSignature(rawSource, sourceFile, generatorCandidateSignature, getSourceCandidatesForEntries, { includeFallbackSignature: cssHandlerOptions.isMainChunk }));
1274
- if (bundleFiles.includes(outputFile) || bundleFiles.includes(sourceFile) || getRememberedCssSignature?.(key) === cssRuntimeSignature) continue;
1815
+ if (useIncrementalMode || isNativeAppStyleTarget) for (const [key, rememberedEntry] of getRememberedCssSources?.() ?? []) {
1816
+ const { outputFile: rememberedOutputFile, rawSource, sourceFile } = await refreshRememberedCssSource?.(rememberedEntry) ?? rememberedEntry;
1817
+ const outputFile = resolveViteCssPipelineOutputFile(rememberedOutputFile, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget);
1818
+ const cssHandlerOptions = getCssHandlerOptions(outputFile);
1819
+ const rememberedCssRuntimeSignature = createRememberedCssRuntimeSignature(createCssRuntimeSignature(runtimeSignature, await createScopedGeneratorCandidateSignature(rawSource, sourceFile, generatorCandidateSignature, getSourceCandidatesForEntries, { includeFallbackSignature: cssHandlerOptions.isMainChunk })), cache.computeHash(require_bundle_state.createRuntimeAffectingSourceSignature(rawSource, "css")));
1820
+ if (bundleFiles.includes(outputFile) || bundleFiles.includes(sourceFile) || getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature) continue;
1275
1821
  tasks.push(timeTask("css.replay", async () => {
1276
1822
  const start = performance.now();
1277
1823
  const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
@@ -1281,13 +1827,13 @@ function createGenerateBundleHook(context) {
1281
1827
  rawSource,
1282
1828
  file: sourceFile,
1283
1829
  cssHandlerOptions,
1284
- cssUserHandlerOptions: getCssUserHandlerOptions(sourceFile),
1830
+ cssUserHandlerOptions: getCssUserHandlerOptions(outputFile),
1285
1831
  getSourceCandidatesForEntries,
1286
1832
  styleHandler,
1287
1833
  debug
1288
1834
  });
1289
1835
  const css = generated?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
1290
- setRememberedCssSignature?.(key, cssRuntimeSignature);
1836
+ setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
1291
1837
  if (generated) {
1292
1838
  registerGeneratorDependencies$1({ addWatchFile }, generated.dependencies);
1293
1839
  recordCssAssetResult?.(outputFile, generated.css);
@@ -1354,6 +1900,7 @@ function registerGeneratorDependencies(ctx, dependencies) {
1354
1900
  }
1355
1901
  function createCssHandlerOptions(opts, majorVersion, file) {
1356
1902
  return {
1903
+ ...resolveUniAppXNativeCssHandlerOptions(opts),
1357
1904
  isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
1358
1905
  postcssOptions: { options: { from: file } },
1359
1906
  ...majorVersion === void 0 ? {} : { majorVersion }
@@ -1361,10 +1908,11 @@ function createCssHandlerOptions(opts, majorVersion, file) {
1361
1908
  }
1362
1909
  function shouldGenerateCssByGenerator(opts, file, rawSource, processed) {
1363
1910
  const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
1364
- if (generatorOptions.target === "web" && opts.twPatcher.majorVersion !== 3) return false;
1365
- if (require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
1911
+ if (require_v3_engine.hasLocalCssImport(rawSource)) return false;
1912
+ if (require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource)) return true;
1913
+ if (require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
1366
1914
  if (opts.twPatcher.majorVersion === 3) return false;
1367
- return processed && shouldFinalizeProcessedCssAsset(opts, file);
1915
+ return processed && require_v3_engine.hasTailwindApplyDirective(rawSource) && shouldFinalizeProcessedCssAsset(opts, file);
1368
1916
  }
1369
1917
  function shouldFinalizeProcessedCssAsset(opts, file) {
1370
1918
  return opts.mainCssChunkMatcher(file, opts.appType);
@@ -1381,6 +1929,7 @@ function createViteCssFinalizerOutputPlugin(context) {
1381
1929
  if (resolvedConfig?.command !== "build") return;
1382
1930
  const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
1383
1931
  const isWebGeneratorTarget = generatorOptions.target === "web";
1932
+ const isNativeAppStyleTarget = require_utils.resolveUniUtsPlatform().isApp;
1384
1933
  const rootDir = resolvedConfig.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
1385
1934
  collectViteProcessedCssAssetResults(bundle, {
1386
1935
  opts,
@@ -1388,7 +1937,7 @@ function createViteCssFinalizerOutputPlugin(context) {
1388
1937
  markCssAssetProcessed,
1389
1938
  recordCssAssetResult,
1390
1939
  recordViteProcessedCssAssetResult,
1391
- resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget),
1940
+ resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget),
1392
1941
  debug
1393
1942
  });
1394
1943
  const isCssOutputAssetEntry = (entry) => {
@@ -1683,15 +2232,15 @@ function createRewriteCssImportsPlugins(options) {
1683
2232
  if (!require_bundle_state.isCSSRequest(id)) return null;
1684
2233
  const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
1685
2234
  const normalizedCode = require_v3_engine.hasTailwindRootDirectives(code) ? require_v3_engine.normalizeTailwindConfigDirectives(code, node_path.default.dirname(file)) : code;
1686
- if (require_v3_engine.hasTailwindRootDirectives(normalizedCode)) {
1687
- await options.onTailwindRootCss?.(id, normalizedCode);
1688
- if (options.shouldOwnTailwindGeneration) {
1689
- const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, this);
1690
- if (generatedCss !== void 0) return {
1691
- code: generatedCss,
1692
- map: null
1693
- };
1694
- }
2235
+ await options.onCssSourceTransform?.(id, normalizedCode);
2236
+ const hasTailwindRoot = require_v3_engine.hasTailwindRootDirectives(normalizedCode);
2237
+ if (hasTailwindRoot) await options.onTailwindRootCss?.(id, normalizedCode);
2238
+ if (options.shouldOwnTailwindGeneration && (hasTailwindRoot || options.shouldGenerateCss?.(id, normalizedCode))) {
2239
+ const generatedCss = await options.generateTailwindCss?.(id, normalizedCode, this);
2240
+ if (generatedCss !== void 0) return {
2241
+ code: generatedCss,
2242
+ map: null
2243
+ };
1695
2244
  }
1696
2245
  if (!options.shouldRewrite) return null;
1697
2246
  const rewritten = rewriteTailwindcssImportsInCode(normalizedCode, weappTailwindcssDirPosix, {
@@ -1708,6 +2257,9 @@ function createRewriteCssImportsPlugins(options) {
1708
2257
  }
1709
2258
  }];
1710
2259
  }
2260
+ function hasVitePipelineTailwindGenerationDirective(code) {
2261
+ return require_v3_engine.hasTailwindRootDirectives(code) || require_v3_engine.hasTailwindApplyDirective(code);
2262
+ }
1711
2263
  //#endregion
1712
2264
  //#region src/bundlers/vite/runtime-class-set.ts
1713
2265
  function createViteRuntimeClassSet(options) {
@@ -1945,6 +2497,7 @@ const debug = require_v3_engine.createDebug();
1945
2497
  const weappTailwindcssPackageDir = require_bundle_state.resolvePackageDir("weapp-tailwindcss");
1946
2498
  const weappTailwindcssDirPosix = require_bundle_state.slash(weappTailwindcssPackageDir);
1947
2499
  const sourceCandidateScanSnapshotCache = /* @__PURE__ */ new Map();
2500
+ const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
1948
2501
  function normalizeSignaturePath(value) {
1949
2502
  return require_bundle_state.slash(node_path.default.resolve(value));
1950
2503
  }
@@ -1972,6 +2525,17 @@ function createSourceCandidateScanSignature(input) {
1972
2525
  scanAllSources: input.scanAllSources ?? false
1973
2526
  });
1974
2527
  }
2528
+ function stripSourceHash(sourceFile) {
2529
+ const hashIndex = sourceFile.indexOf("#");
2530
+ return hashIndex === -1 ? sourceFile : sourceFile.slice(0, hashIndex);
2531
+ }
2532
+ function normalizeCssSourceIdentity(sourceFile) {
2533
+ const cleanSourceFile = stripSourceHash(sourceFile);
2534
+ const { filename, query } = parseVueRequest(cleanSourceFile);
2535
+ const normalizedFile = require_bundle_state.normalizeOutputPathKey(filename);
2536
+ if (query.type === "style") return `${normalizedFile}?type=style&index=${query.index ?? 0}`;
2537
+ return require_bundle_state.normalizeOutputPathKey(require_bundle_state.stripRequestQuery(cleanSourceFile));
2538
+ }
1975
2539
  /**
1976
2540
  * @name WeappTailwindcss
1977
2541
  * @description uni-app vite / uni-app-x 版本插件
@@ -2223,18 +2787,19 @@ function WeappTailwindcss(options = {}) {
2223
2787
  const syncChangedSourceCandidateFile = (id) => {
2224
2788
  if (!shouldOwnTailwindGeneration || !require_source_candidates.isSourceCandidateRequest(id)) return Promise.resolve();
2225
2789
  const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
2790
+ const refreshRememberedCssSourceTask = refreshRememberedCssSourceByCurrentFile(file);
2226
2791
  if (isSourceScanDependency(file)) invalidateSourceCandidateScan();
2227
2792
  if (sourceScanMatcher && !sourceScanMatcher(file)) {
2228
2793
  sourceCandidateCollector.remove(file);
2229
2794
  cacheCurrentSourceCandidateScan();
2230
- return Promise.resolve();
2795
+ return refreshRememberedCssSourceTask;
2231
2796
  }
2232
2797
  if (sourceScanExplicit && sourceScanEntries?.length === 0) {
2233
2798
  cacheCurrentSourceCandidateScan();
2234
- return Promise.resolve();
2799
+ return refreshRememberedCssSourceTask;
2235
2800
  }
2236
2801
  const existingTask = pendingSourceCandidateSyncByFile.get(file);
2237
- if (existingTask) return existingTask;
2802
+ if (existingTask) return Promise.all([refreshRememberedCssSourceTask, existingTask]).then(() => void 0);
2238
2803
  const task = sourceCandidateCollector.syncCurrentFile(id).catch((error) => {
2239
2804
  debug("source candidate watch sync failed: %s %O", id, error);
2240
2805
  }).then(() => {
@@ -2245,7 +2810,7 @@ function WeappTailwindcss(options = {}) {
2245
2810
  });
2246
2811
  pendingSourceCandidateSyncs.add(task);
2247
2812
  pendingSourceCandidateSyncByFile.set(file, task);
2248
- return task;
2813
+ return Promise.all([refreshRememberedCssSourceTask, task]).then(() => void 0);
2249
2814
  };
2250
2815
  const shouldCollectTransformedSourceCandidates = (id) => {
2251
2816
  if (id.search(/[?#]/) < 0) return true;
@@ -2254,8 +2819,85 @@ function WeappTailwindcss(options = {}) {
2254
2819
  };
2255
2820
  const rememberCssSource = (entry, cssRuntimeSignature) => {
2256
2821
  const key = require_bundle_state.normalizeOutputPathKey(entry.outputFile);
2822
+ const previous = rememberedCssSources.get(key);
2257
2823
  rememberedCssSources.set(key, entry);
2824
+ const normalizedSourceFile = normalizeCssSourceIdentity(entry.sourceFile);
2825
+ for (const [rememberedKey, remembered] of rememberedCssSources) {
2826
+ if (rememberedKey === key || normalizeCssSourceIdentity(remembered.sourceFile) !== normalizedSourceFile) continue;
2827
+ rememberedCssSources.set(rememberedKey, {
2828
+ ...remembered,
2829
+ rawSource: entry.rawSource,
2830
+ sourceFile: entry.sourceFile
2831
+ });
2832
+ rememberedCssSignatureByFile.delete(rememberedKey);
2833
+ }
2258
2834
  if (cssRuntimeSignature) rememberedCssSignatureByFile.set(key, cssRuntimeSignature);
2835
+ else if (previous?.rawSource !== entry.rawSource || previous?.sourceFile !== entry.sourceFile) rememberedCssSignatureByFile.delete(key);
2836
+ };
2837
+ const refreshRememberedCssSourceEntry = (rememberedKey, remembered, sourceFile, rawSource) => {
2838
+ if (remembered.rawSource === rawSource && remembered.sourceFile === sourceFile) return remembered;
2839
+ const nextRemembered = {
2840
+ ...remembered,
2841
+ rawSource,
2842
+ sourceFile
2843
+ };
2844
+ rememberedCssSources.set(rememberedKey, nextRemembered);
2845
+ rememberedCssSignatureByFile.delete(rememberedKey);
2846
+ return nextRemembered;
2847
+ };
2848
+ const refreshRememberedCssSourceBySourceFile = (sourceFile, rawSource) => {
2849
+ const normalizedSourceFile = normalizeCssSourceIdentity(sourceFile);
2850
+ for (const [rememberedKey, remembered] of rememberedCssSources) {
2851
+ if (normalizeCssSourceIdentity(remembered.sourceFile) !== normalizedSourceFile) continue;
2852
+ refreshRememberedCssSourceEntry(rememberedKey, remembered, sourceFile, rawSource);
2853
+ }
2854
+ };
2855
+ const extractSfcStyleBlock = (source, index) => {
2856
+ const targetIndex = index ?? 0;
2857
+ SFC_STYLE_BLOCK_RE.lastIndex = 0;
2858
+ let currentIndex = 0;
2859
+ let match = SFC_STYLE_BLOCK_RE.exec(source);
2860
+ while (match !== null) {
2861
+ if (currentIndex === targetIndex) return match[1] ?? "";
2862
+ currentIndex++;
2863
+ match = SFC_STYLE_BLOCK_RE.exec(source);
2864
+ }
2865
+ };
2866
+ const refreshRememberedCssSourceByCurrentFile = async (sourceFile) => {
2867
+ const file = (0, _weapp_tailwindcss_shared.cleanUrl)(sourceFile);
2868
+ const normalizedSourceFile = require_bundle_state.normalizeOutputPathKey(file);
2869
+ const matchedRememberedSources = [...rememberedCssSources.values()].filter((remembered) => require_bundle_state.normalizeOutputPathKey(require_bundle_state.stripRequestQuery((0, _weapp_tailwindcss_shared.cleanUrl)(remembered.sourceFile))) === normalizedSourceFile);
2870
+ if (matchedRememberedSources.length === 0) return;
2871
+ try {
2872
+ const source = await (0, node_fs_promises.readFile)(file, "utf8");
2873
+ if (/\.(?:vue|uvue|nvue|svelte|mpx)$/i.test(file)) {
2874
+ for (const remembered of matchedRememberedSources) {
2875
+ const { query } = parseVueRequest(remembered.sourceFile);
2876
+ const styleSource = extractSfcStyleBlock(source, query.type === "style" ? query.index : void 0);
2877
+ if (styleSource !== void 0) refreshRememberedCssSourceBySourceFile(remembered.sourceFile, styleSource);
2878
+ }
2879
+ return;
2880
+ }
2881
+ if (require_bundle_state.isSourceStyleRequest(file)) refreshRememberedCssSourceBySourceFile(file, source);
2882
+ } catch (error) {
2883
+ debug("refresh remembered css source failed: %s %O", file, error);
2884
+ }
2885
+ };
2886
+ const refreshRememberedCssSource = async (remembered) => {
2887
+ const file = (0, _weapp_tailwindcss_shared.cleanUrl)(require_bundle_state.stripRequestQuery(remembered.sourceFile));
2888
+ const rememberedKey = [...rememberedCssSources.entries()].find(([, entry]) => entry === remembered)?.[0];
2889
+ if (!rememberedKey || !node_path.default.isAbsolute(file)) return;
2890
+ try {
2891
+ const source = await (0, node_fs_promises.readFile)(file, "utf8");
2892
+ if (/\.(?:vue|uvue|nvue|svelte|mpx)$/i.test(file)) {
2893
+ const { query } = parseVueRequest(remembered.sourceFile);
2894
+ const styleSource = extractSfcStyleBlock(source, query.type === "style" ? query.index : void 0);
2895
+ return styleSource === void 0 ? void 0 : refreshRememberedCssSourceEntry(rememberedKey, remembered, remembered.sourceFile, styleSource);
2896
+ }
2897
+ if (require_bundle_state.isSourceStyleRequest(file)) return refreshRememberedCssSourceEntry(rememberedKey, remembered, remembered.sourceFile, source);
2898
+ } catch (error) {
2899
+ debug("refresh remembered css source before bundle replay failed: %s %O", file, error);
2900
+ }
2259
2901
  };
2260
2902
  const getRememberedCssSources = () => rememberedCssSources;
2261
2903
  const getRememberedCssSourceEntry = (file) => rememberedCssSources.get(require_bundle_state.normalizeOutputPathKey(file));
@@ -2368,15 +3010,19 @@ function WeappTailwindcss(options = {}) {
2368
3010
  getAppType: () => opts.appType,
2369
3011
  mainCssChunkMatcher,
2370
3012
  getMajorVersion: () => runtimeState.twPatcher.majorVersion,
2371
- getOutputRoot: () => resolvedConfig?.build?.outDir ? node_path.default.resolve(resolvedConfig.root, resolvedConfig.build.outDir) : resolvedConfig?.root
3013
+ getOutputRoot: () => resolvedConfig?.build?.outDir ? node_path.default.resolve(resolvedConfig.root, resolvedConfig.build.outDir) : resolvedConfig?.root,
3014
+ getExtraOptions: () => resolveUniAppXNativeCssHandlerOptions(opts)
2372
3015
  });
2373
3016
  const generateTailwindCssForVitePipeline = async (id, code, hookContext) => {
2374
3017
  if (!shouldOwnTailwindGeneration) return;
2375
3018
  await runtimeState.readyPromise;
2376
3019
  await waitForSourceCandidateSyncs();
2377
3020
  const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
3021
+ const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
3022
+ const isNativeAppStyleTarget = require_utils.resolveUniUtsPlatform().isApp;
3023
+ const outputFile = resolveViteCssPipelineOutputFile(file, opts, rootDir, generatorOptions.target === "web", isNativeAppStyleTarget);
2378
3024
  const runtime = getRecordedGeneratorCandidates() ?? getSourceCandidates() ?? await ensureRuntimeClassSet();
2379
- const cssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(file);
3025
+ const cssHandlerOptions = transformCssHandlerOptions.getCssHandlerOptions(outputFile);
2380
3026
  const generated = await require_incremental_runtime_class_set.generateCssByGenerator({
2381
3027
  opts,
2382
3028
  runtimeState,
@@ -2384,7 +3030,7 @@ function WeappTailwindcss(options = {}) {
2384
3030
  rawSource: code,
2385
3031
  file,
2386
3032
  cssHandlerOptions,
2387
- cssUserHandlerOptions: transformCssHandlerOptions.getCssUserHandlerOptions(file),
3033
+ cssUserHandlerOptions: transformCssHandlerOptions.getCssUserHandlerOptions(outputFile),
2388
3034
  getSourceCandidatesForEntries,
2389
3035
  styleHandler,
2390
3036
  debug,
@@ -2392,17 +3038,21 @@ function WeappTailwindcss(options = {}) {
2392
3038
  deferEmptyScopedCssSource: true
2393
3039
  });
2394
3040
  if (!generated) return;
2395
- const outputFile = resolveViteCssPipelineOutputFile(file, opts, resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd(), generatorOptions.target === "web");
2396
3041
  for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
2397
3042
  viteGeneratedCssByFile.set(file, generated.css);
2398
3043
  if (generated.css.includes("weapp-tailwindcss layer components start")) recordViteProcessedCssAssetResult(file, generated.css, { injectIntoMain: cssHandlerOptions.isMainChunk });
3044
+ if (isNativeAppStyleTarget && outputFile.endsWith(".css")) hookContext?.emitFile?.({
3045
+ type: "asset",
3046
+ fileName: outputFile,
3047
+ source: generated.css
3048
+ });
2399
3049
  markViteProcessedCssSource(file);
2400
3050
  rememberTailwindRootCssModule(id);
2401
3051
  recordGeneratorCandidates(runtime);
2402
3052
  rememberCssSource({
2403
3053
  outputFile,
2404
3054
  rawSource: code,
2405
- sourceFile: file
3055
+ sourceFile: id
2406
3056
  });
2407
3057
  debug("css generated for vite postcss pipeline: %s bytes=%d", file, generated.css.length);
2408
3058
  return `${require_bundle_state.createBundlerGeneratedCssMarker("vite", normalizeViteProcessedCssFile(file))}\n${generated.css}`;
@@ -2412,6 +3062,8 @@ function WeappTailwindcss(options = {}) {
2412
3062
  generateTailwindCss: generateTailwindCssForVitePipeline,
2413
3063
  rootImport: shouldOwnTailwindGeneration ? `${weappTailwindcssDirPosix}/generator-placeholder.css` : void 0,
2414
3064
  onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
3065
+ onCssSourceTransform: (id, code) => refreshRememberedCssSourceBySourceFile(id, code),
3066
+ shouldGenerateCss: (_id, code) => hasVitePipelineTailwindGenerationDirective(code),
2415
3067
  shouldOwnTailwindGeneration,
2416
3068
  shouldRewrite: shouldRewriteCssImports,
2417
3069
  weappTailwindcssDirPosix
@@ -2435,6 +3087,7 @@ function WeappTailwindcss(options = {}) {
2435
3087
  getSourceCandidatesForEntries,
2436
3088
  waitForSourceCandidateSyncs,
2437
3089
  rememberCssSource,
3090
+ refreshRememberedCssSource,
2438
3091
  getRememberedCssSources,
2439
3092
  getRememberedCssSignature,
2440
3093
  setRememberedCssSignature,
@@ -2477,6 +3130,7 @@ function WeappTailwindcss(options = {}) {
2477
3130
  mainCssChunkMatcher,
2478
3131
  runtimeState,
2479
3132
  styleHandler,
3133
+ generateCss: generateTailwindCssForVitePipeline,
2480
3134
  jsHandler,
2481
3135
  ensureRuntimeClassSet,
2482
3136
  getResolvedConfig,