weapp-tailwindcss 5.0.6 → 5.0.7

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 (103) hide show
  1. package/dist/{bundle-state-CFgzVHFP.js → bundle-state-BzwPS-UI.js} +2 -1
  2. package/dist/{bundle-state-CdNXQl-o.mjs → bundle-state-ChcOKb9w.mjs} +2 -1
  3. package/dist/bundlers/gulp/index.d.ts +3 -4
  4. package/dist/bundlers/gulp/module-graph.d.ts +2 -0
  5. package/dist/bundlers/gulp/runtime-snapshot.d.ts +5 -0
  6. package/dist/bundlers/gulp/vinyl-transform.d.ts +3 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  8. package/dist/bundlers/shared/css-source-trace.d.ts +20 -0
  9. package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +11 -0
  10. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +56 -0
  11. package/dist/bundlers/shared/generator-css/local-imports.d.ts +7 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  13. package/dist/bundlers/shared/generator-css/types.d.ts +27 -0
  14. package/dist/bundlers/shared/generator-css/user-css.d.ts +26 -0
  15. package/dist/bundlers/shared/generator-css/validate.d.ts +5 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +4 -32
  17. package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
  18. package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +2 -0
  19. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +14 -0
  20. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +11 -0
  21. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +9 -0
  22. package/dist/bundlers/vite/generate-bundle/style-matching.d.ts +5 -0
  23. package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +7 -0
  24. package/dist/bundlers/vite/generate-bundle/types.d.ts +68 -0
  25. package/dist/bundlers/vite/generate-bundle.d.ts +4 -62
  26. package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +4 -0
  27. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +2 -0
  28. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +13 -0
  29. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
  30. package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +17 -0
  31. package/dist/bundlers/vite/processed-css-assets.d.ts +2 -0
  32. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +10 -0
  33. package/dist/bundlers/vite/source-candidates/script.d.ts +7 -0
  34. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +1 -0
  35. package/dist/bundlers/vite/source-candidates.d.ts +8 -3
  36. package/dist/bundlers/vite/source-scan/css-entries.d.ts +20 -0
  37. package/dist/bundlers/vite/source-scan/dependencies.d.ts +2 -0
  38. package/dist/bundlers/vite/source-scan.d.ts +2 -12
  39. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -0
  40. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -20
  41. package/dist/cli.js +69 -69
  42. package/dist/cli.mjs +69 -69
  43. package/dist/core.js +1 -1
  44. package/dist/core.mjs +1 -1
  45. package/dist/{defaults-BPUuNYcD.js → defaults-Boc26eel.js} +1 -0
  46. package/dist/{defaults-8xrgzxFY.mjs → defaults-DH0ZQRhy.mjs} +1 -0
  47. package/dist/defaults.js +1 -1
  48. package/dist/defaults.mjs +1 -1
  49. package/dist/{generator-C56PJYxA.js → generator-6yF8wjxR.js} +1 -1
  50. package/dist/{generator-Bgn4m8An.mjs → generator-BON6M1bL.mjs} +1 -1
  51. package/dist/generator.js +2 -2
  52. package/dist/generator.mjs +2 -2
  53. package/dist/gulp-_7p1Z2vc.js +473 -0
  54. package/dist/gulp-oE-Byqk6.mjs +463 -0
  55. package/dist/gulp.js +4 -414
  56. package/dist/gulp.mjs +1 -406
  57. package/dist/{incremental-runtime-class-set-Bmzdjlk0.js → hmr-timing-BKQNRxHr.js} +1205 -449
  58. package/dist/{incremental-runtime-class-set-BEYHQkZc.mjs → hmr-timing-BVTGf5ch.mjs} +1169 -467
  59. package/dist/index.js +5 -5
  60. package/dist/index.mjs +5 -5
  61. package/dist/{postcss-B7QNe78h.js → postcss-BTIunhWl.js} +7 -7
  62. package/dist/{postcss-BgINK7Nm.mjs → postcss-BtmrrZ31.mjs} +4 -4
  63. package/dist/postcss.js +1 -1
  64. package/dist/postcss.mjs +1 -1
  65. package/dist/{precheck-Copn2SqE.mjs → precheck-CZjr87m_.mjs} +19 -5
  66. package/dist/{precheck-CyPbGn38.js → precheck-fhIkzCSU.js} +19 -5
  67. package/dist/presets.js +2 -2
  68. package/dist/presets.mjs +2 -2
  69. package/dist/tailwindcss/source-scan/inline-source.d.ts +7 -0
  70. package/dist/tailwindcss/source-scan.d.ts +2 -7
  71. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +3 -0
  72. package/dist/tailwindcss/v3-engine/generator/content.d.ts +10 -0
  73. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +2 -0
  74. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +2 -0
  75. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +6 -0
  76. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -0
  77. package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
  78. package/dist/{tailwindcss-C0Zgo3Es.mjs → tailwindcss-bbQUg25J.mjs} +2 -2
  79. package/dist/{tailwindcss-Tw6CSVHL.js → tailwindcss-vswd1gc3.js} +2 -2
  80. package/dist/{transform-95ivJthq.js → transform-CReJxxh_.js} +11 -2
  81. package/dist/{transform-DgCFGtQR.mjs → transform-DEsFlG9k.mjs} +11 -2
  82. package/dist/types/typedoc-tailwindcss-patch.d.ts +4 -2
  83. package/dist/types/user-defined-options/general.d.ts +5 -0
  84. package/dist/uni-app-x/component-local-style.d.ts +1 -0
  85. package/dist/uni-app-x/harmony.d.ts +1 -0
  86. package/dist/uni-app-x/style-asset/style-value.d.ts +16 -0
  87. package/dist/uni-app-x/style-asset.d.ts +20 -0
  88. package/dist/uni-app-x/transform.d.ts +1 -0
  89. package/dist/uni-app-x/vite.d.ts +1 -0
  90. package/dist/{v3-engine-6FVAcrZl.js → v3-engine-CEMXFegG.js} +758 -708
  91. package/dist/{v3-engine-Ji6AXPh2.mjs → v3-engine-CdIwmHuc.mjs} +756 -706
  92. package/dist/{vite-Bw6LOXvf.js → vite-0jFbh9hx.js} +1797 -386
  93. package/dist/{vite-ChZ2cbn4.mjs → vite-C7BGAlCE.mjs} +1779 -369
  94. package/dist/vite.js +1 -1
  95. package/dist/vite.mjs +1 -1
  96. package/dist/weapp-tw-css-import-rewrite-loader.js +1104 -980
  97. package/dist/{webpack-CMJ7iqN7.mjs → webpack-Dx6_eg5k.mjs} +96 -36
  98. package/dist/{webpack-nn3P8_S_.js → webpack-aEuDoYfQ.js} +105 -44
  99. package/dist/webpack.js +1 -1
  100. package/dist/webpack.mjs +1 -1
  101. package/package.json +7 -6
  102. package/dist/source-candidates-BODCmzz5.mjs +0 -355
  103. package/dist/source-candidates-Caf2GDvx.js +0 -374
@@ -20,9 +20,9 @@ let node_url = require("node:url");
20
20
  let debug = require("debug");
21
21
  debug = require_watch_dependencies.__toESM(debug);
22
22
  let node_fs_promises = require("node:fs/promises");
23
+ require("micromatch");
23
24
  require("fast-glob");
24
25
  let tailwindcss_config = require("tailwindcss-config");
25
- require("micromatch");
26
26
  let _weapp_core_escape = require("@weapp-core/escape");
27
27
  require("magic-string");
28
28
  let _babel_traverse = require("@babel/traverse");
@@ -63,66 +63,6 @@ function createBundlerGeneratedCssMarker(bundler, file) {
63
63
  return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
64
64
  }
65
65
  //#endregion
66
- //#region src/uni-app-x/options.ts
67
- const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
68
- enabled: true,
69
- onlyWhenStyleIsolationVersion2: true
70
- };
71
- const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
72
- enabled: false,
73
- onlyWhenStyleIsolationVersion2: true
74
- };
75
- function isBooleanUniAppXShortcut(option) {
76
- return option === true || option === false || option === void 0;
77
- }
78
- function resolveComponentLocalStyles(option) {
79
- if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
80
- const componentLocalStyles = option.componentLocalStyles;
81
- if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
82
- if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
83
- return {
84
- enabled: componentLocalStyles.enabled !== false,
85
- onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
86
- };
87
- }
88
- function resolveUniAppXOptions(option) {
89
- if (typeof option === "object" && option) return {
90
- enabled: option.enabled !== false,
91
- componentLocalStyles: resolveComponentLocalStyles(option),
92
- uvueUnsupported: option.uvueUnsupported ?? "warn"
93
- };
94
- return {
95
- enabled: Boolean(option),
96
- componentLocalStyles: resolveComponentLocalStyles(option),
97
- uvueUnsupported: "warn"
98
- };
99
- }
100
- function isUniAppXEnabled(option) {
101
- return resolveUniAppXOptions(option).enabled;
102
- }
103
- //#endregion
104
- //#region src/context/style-options.ts
105
- function resolveStyleOptionsFromContext(ctx) {
106
- const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
107
- return {
108
- cssPreflight: ctx.cssPreflight,
109
- cssPreflightRange: ctx.cssPreflightRange,
110
- cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
111
- cssSelectorReplacement: ctx.cssSelectorReplacement,
112
- rem2rpx: ctx.rem2rpx,
113
- cssRemoveProperty: ctx.cssRemoveProperty,
114
- cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
115
- cssPresetEnv: ctx.cssPresetEnv,
116
- autoprefixer: ctx.autoprefixer,
117
- cssCalc: ctx.cssCalc,
118
- uniAppX: resolvedUniAppXOptions.enabled,
119
- platform: ctx.platform,
120
- px2rpx: ctx.px2rpx,
121
- unitsToPx: ctx.unitsToPx,
122
- unitConversion: ctx.unitConversion
123
- };
124
- }
125
- //#endregion
126
66
  //#region src/css-macro/constants.ts
127
67
  const queryKey = "weapp-tw-platform";
128
68
  const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
@@ -465,6 +405,169 @@ async function transformCssMacroCss(css, options) {
465
405
  return compileCssMacroConditionalComments(result, options);
466
406
  }
467
407
  //#endregion
408
+ //#region src/utils/object.ts
409
+ function definedEntries(value) {
410
+ return Object.entries(value).filter(([, item]) => item !== void 0);
411
+ }
412
+ function omitUndefined(value) {
413
+ return Object.fromEntries(definedEntries(value));
414
+ }
415
+ //#endregion
416
+ //#region src/tailwindcss/v3-engine/generator/content.ts
417
+ function isLegacyContentObject$1(value) {
418
+ return typeof value === "object" && value !== null && "files" in value;
419
+ }
420
+ function createRawContentEntries(candidates, sources) {
421
+ const entries = [];
422
+ const candidateContent = [...candidates].join(" ");
423
+ if (candidateContent.length > 0) entries.push({
424
+ raw: candidateContent,
425
+ extension: "html"
426
+ });
427
+ for (const source of sources) entries.push({
428
+ raw: source.content,
429
+ extension: source.extension ?? "html"
430
+ });
431
+ return entries;
432
+ }
433
+ function createChangedContentEntries(candidates, sources) {
434
+ return createRawContentEntries(candidates, sources).map((entry) => ({
435
+ content: entry.raw,
436
+ extension: entry.extension
437
+ }));
438
+ }
439
+ function collectCandidates$1(candidates) {
440
+ return new Set(candidates ?? []);
441
+ }
442
+ function collectApplyCandidatesFromCss(css) {
443
+ if (!css.includes("@apply")) return [];
444
+ const candidates = /* @__PURE__ */ new Set();
445
+ try {
446
+ require_watch_dependencies.postcss_default.parse(css).walkAtRules("apply", (rule) => {
447
+ for (const candidate of rule.params.split(/\s+/)) {
448
+ const normalized = candidate.replace(/!important$/, "").trim();
449
+ if (normalized) candidates.add(normalized);
450
+ }
451
+ });
452
+ } catch {}
453
+ return [...candidates];
454
+ }
455
+ function isTailwindCandidateLayer(params) {
456
+ return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
457
+ }
458
+ function extractClassCandidatesFromSelector(selector, candidates) {
459
+ for (let index = 0; index < selector.length; index++) {
460
+ if (selector[index] !== ".") continue;
461
+ let candidate = "";
462
+ let escaped = false;
463
+ for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
464
+ const char = selector[tokenIndex];
465
+ if (escaped) {
466
+ candidate += char;
467
+ escaped = false;
468
+ continue;
469
+ }
470
+ if (char === "\\") {
471
+ escaped = true;
472
+ continue;
473
+ }
474
+ if (char && /[\w-]/.test(char)) {
475
+ candidate += char;
476
+ continue;
477
+ }
478
+ break;
479
+ }
480
+ if (candidate) candidates.add(candidate);
481
+ }
482
+ }
483
+ function collectLayerCandidatesFromCss(css) {
484
+ if (!css.includes("@layer")) return [];
485
+ const candidates = /* @__PURE__ */ new Set();
486
+ try {
487
+ require_watch_dependencies.postcss_default.parse(css).walkAtRules("layer", (layer) => {
488
+ if (!isTailwindCandidateLayer(layer.params)) return;
489
+ layer.walkRules((rule) => {
490
+ extractClassCandidatesFromSelector(rule.selector, candidates);
491
+ });
492
+ });
493
+ } catch {}
494
+ return [...candidates];
495
+ }
496
+ function mergeGenerateCandidates(source, options) {
497
+ return collectCandidates$1([
498
+ ...collectLayerCandidatesFromCss(source.css),
499
+ ...collectApplyCandidatesFromCss(source.css),
500
+ ...collectCandidates$1(options.candidates)
501
+ ]);
502
+ }
503
+ function mergeContent(content, rawEntries) {
504
+ if (isLegacyContentObject$1(content)) return {
505
+ ...content,
506
+ relative: content.relative ?? true,
507
+ files: [...[].concat(content.files ?? []), ...rawEntries]
508
+ };
509
+ return {
510
+ relative: true,
511
+ files: [...[].concat(content ?? []), ...rawEntries]
512
+ };
513
+ }
514
+ function normalizeConfigObject(config) {
515
+ if (!config || typeof config !== "object") return config;
516
+ const maybeDefault = config.default;
517
+ if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
518
+ return config;
519
+ }
520
+ function hasExplicitContentInput(options) {
521
+ return options.candidates !== void 0 || options.sources !== void 0;
522
+ }
523
+ function createExplicitContentConfig(rawEntries) {
524
+ return {
525
+ relative: true,
526
+ files: rawEntries
527
+ };
528
+ }
529
+ function createTailwindConfig(source, options) {
530
+ const config = { ...normalizeConfigObject(source.configObject) ?? {} };
531
+ const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
532
+ config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
533
+ return config;
534
+ }
535
+ //#endregion
536
+ //#region src/tailwindcss/v3-engine/generator/cache-key.ts
537
+ function createStableJson$2(value) {
538
+ if (value === void 0) return "undefined";
539
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
540
+ if (Array.isArray(value)) return `[${value.map((item) => createStableJson$2(item)).join(",")}]`;
541
+ return `{${Object.keys(value).sort().map((key) => {
542
+ const record = value;
543
+ return `${JSON.stringify(key)}:${createStableJson$2(record[key])}`;
544
+ }).join(",")}}`;
545
+ }
546
+ function createDependencyFingerprint$1(files) {
547
+ return files.map((file) => {
548
+ try {
549
+ const stat = node_fs.default.statSync(file);
550
+ return `${file}:${stat.size}:${stat.mtimeMs}`;
551
+ } catch {
552
+ return `${file}:missing`;
553
+ }
554
+ }).join("|");
555
+ }
556
+ function createIncrementalGenerateCacheKey$1(source, target, styleOptions, bareArbitraryValues) {
557
+ return [
558
+ source.packageName,
559
+ source.postcssPlugin,
560
+ source.cwd,
561
+ source.config ?? "config:missing",
562
+ createDependencyFingerprint$1(source.dependencies),
563
+ source.css,
564
+ createStableJson$2(normalizeConfigObject(source.configObject)?.content),
565
+ target,
566
+ createStableJson$2(styleOptions),
567
+ createStableJson$2(bareArbitraryValues)
568
+ ].join("\0");
569
+ }
570
+ //#endregion
468
571
  //#region src/context/workspace.ts
469
572
  function findWorkspaceRoot(startDir) {
470
573
  if (!startDir) return;
@@ -487,14 +590,6 @@ function findNearestPackageRoot(startDir) {
487
590
  }
488
591
  }
489
592
  //#endregion
490
- //#region src/utils/object.ts
491
- function definedEntries(value) {
492
- return Object.entries(value).filter(([, item]) => item !== void 0);
493
- }
494
- function omitUndefined(value) {
495
- return Object.fromEntries(definedEntries(value));
496
- }
497
- //#endregion
498
593
  //#region src/utils/options.ts
499
594
  function resolveBooleanObjectOption(value, enabledValue) {
500
595
  if (!value) return false;
@@ -665,7 +760,7 @@ function createTailwindcssPatcher(options) {
665
760
  const resolvedTailwindOptions = resolvedOptions.tailwindcss;
666
761
  if (resolvedTailwindOptions) {
667
762
  const existingResolve = resolvedTailwindOptions.resolve ?? {};
668
- const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths, ...resolvePaths] : resolvePaths;
763
+ const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths ?? [], ...resolvePaths] : resolvePaths;
669
764
  resolvedTailwindOptions.resolve = {
670
765
  ...existingResolve,
671
766
  paths: [...new Set(sourcePaths)]
@@ -727,104 +822,8 @@ function createDebug(prefix) {
727
822
  return debug$3;
728
823
  }
729
824
  //#endregion
730
- //#region src/tailwindcss/source-scan.ts
731
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
732
- "html",
733
- "wxml",
734
- "axml",
735
- "jxml",
736
- "ksml",
737
- "ttml",
738
- "qml",
739
- "tyml",
740
- "xhsml",
741
- "swan",
742
- "vue",
743
- "mpx",
744
- "js",
745
- "jsx",
746
- "ts",
747
- "tsx"
748
- ];
749
- const FULL_SOURCE_SCAN_EXTENSIONS = [
750
- "js",
751
- "jsx",
752
- "mjs",
753
- "cjs",
754
- "ts",
755
- "tsx",
756
- "mts",
757
- "cts",
758
- "vue",
759
- "uvue",
760
- "nvue",
761
- "svelte",
762
- "mpx",
763
- "html",
764
- "wxml",
765
- "axml",
766
- "jxml",
767
- "ksml",
768
- "ttml",
769
- "qml",
770
- "tyml",
771
- "xhsml",
772
- "swan",
773
- "css",
774
- "wxss",
775
- "acss",
776
- "jxss",
777
- "ttss",
778
- "qss",
779
- "tyss",
780
- "scss",
781
- "sass",
782
- "less",
783
- "styl",
784
- "stylus"
785
- ];
786
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
787
- return `**/*.{${extensions.join(",")}}`;
788
- }
789
- const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
790
- new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
791
- function resolveTailwindV4CssSourceBase(source, fallbackBase) {
792
- if (typeof source.base === "string" && source.base.length > 0) return source.base;
793
- if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
794
- return fallbackBase;
795
- }
825
+ //#region src/tailwindcss/source-scan/inline-source.ts
796
826
  const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
797
- function parseConfigParam$1(params) {
798
- const value = params.trim();
799
- return /^(['"])(.+)\1$/.exec(value)?.[2];
800
- }
801
- function isLegacyContentObject$1(value) {
802
- return typeof value === "object" && value !== null && "files" in value;
803
- }
804
- function normalizeGlobPattern(pattern) {
805
- return pattern.startsWith("./") ? pattern.slice(2) : pattern;
806
- }
807
- function hasGlobMagic(value) {
808
- return /[*?[\]{}()!+@]/.test(value);
809
- }
810
- function splitStaticGlobPrefix(pattern) {
811
- const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
812
- const prefix = [];
813
- const rest = [];
814
- let reachedGlob = false;
815
- for (const segment of segments) {
816
- if (!reachedGlob && segment && !hasGlobMagic(segment)) {
817
- prefix.push(segment);
818
- continue;
819
- }
820
- reachedGlob = true;
821
- rest.push(segment);
822
- }
823
- return {
824
- prefix,
825
- rest
826
- };
827
- }
828
827
  function segmentTopLevel(input, separator, options = {}) {
829
828
  const parts = [];
830
829
  const stack = [];
@@ -951,6 +950,104 @@ function collectCssInlineSourceCandidates(root) {
951
950
  excluded
952
951
  };
953
952
  }
953
+ //#endregion
954
+ //#region src/tailwindcss/source-scan.ts
955
+ const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
956
+ "html",
957
+ "wxml",
958
+ "axml",
959
+ "jxml",
960
+ "ksml",
961
+ "ttml",
962
+ "qml",
963
+ "tyml",
964
+ "xhsml",
965
+ "swan",
966
+ "vue",
967
+ "mpx",
968
+ "js",
969
+ "jsx",
970
+ "ts",
971
+ "tsx"
972
+ ];
973
+ const FULL_SOURCE_SCAN_EXTENSIONS = [
974
+ "js",
975
+ "jsx",
976
+ "mjs",
977
+ "cjs",
978
+ "ts",
979
+ "tsx",
980
+ "mts",
981
+ "cts",
982
+ "vue",
983
+ "uvue",
984
+ "nvue",
985
+ "svelte",
986
+ "mpx",
987
+ "html",
988
+ "wxml",
989
+ "axml",
990
+ "jxml",
991
+ "ksml",
992
+ "ttml",
993
+ "qml",
994
+ "tyml",
995
+ "xhsml",
996
+ "swan",
997
+ "css",
998
+ "wxss",
999
+ "acss",
1000
+ "jxss",
1001
+ "ttss",
1002
+ "qss",
1003
+ "tyss",
1004
+ "scss",
1005
+ "sass",
1006
+ "less",
1007
+ "styl",
1008
+ "stylus"
1009
+ ];
1010
+ function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
1011
+ return `**/*.{${extensions.join(",")}}`;
1012
+ }
1013
+ const FULL_SOURCE_SCAN_PATTERN = createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
1014
+ new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
1015
+ function resolveTailwindV4CssSourceBase(source, fallbackBase) {
1016
+ if (typeof source.base === "string" && source.base.length > 0) return source.base;
1017
+ if (typeof source.file === "string" && source.file.length > 0) return node_path.default.dirname(source.file);
1018
+ return fallbackBase;
1019
+ }
1020
+ function parseConfigParam$1(params) {
1021
+ const value = params.trim();
1022
+ return /^(['"])(.+)\1$/.exec(value)?.[2];
1023
+ }
1024
+ function isLegacyContentObject(value) {
1025
+ return typeof value === "object" && value !== null && "files" in value;
1026
+ }
1027
+ function normalizeGlobPattern(pattern) {
1028
+ return pattern.startsWith("./") ? pattern.slice(2) : pattern;
1029
+ }
1030
+ function hasGlobMagic(value) {
1031
+ return /[*?[\]{}()!+@]/.test(value);
1032
+ }
1033
+ function splitStaticGlobPrefix(pattern) {
1034
+ const segments = normalizeGlobPattern(pattern).split(/[\\/]+/);
1035
+ const prefix = [];
1036
+ const rest = [];
1037
+ let reachedGlob = false;
1038
+ for (const segment of segments) {
1039
+ if (!reachedGlob && segment && !hasGlobMagic(segment)) {
1040
+ prefix.push(segment);
1041
+ continue;
1042
+ }
1043
+ reachedGlob = true;
1044
+ rest.push(segment);
1045
+ }
1046
+ return {
1047
+ prefix,
1048
+ rest
1049
+ };
1050
+ }
954
1051
  function normalizeLegacyContentEntries(content, base, options = {}) {
955
1052
  if (typeof content === "string") {
956
1053
  const negated = content.startsWith("!");
@@ -961,7 +1058,7 @@ function normalizeLegacyContentEntries(content, base, options = {}) {
961
1058
  }];
962
1059
  }
963
1060
  if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
964
- if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
1061
+ if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
965
1062
  return [];
966
1063
  }
967
1064
  async function pathExistsAsDirectory(file) {
@@ -1029,40 +1126,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
1029
1126
  return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
1030
1127
  }
1031
1128
  //#endregion
1032
- //#region src/tailwindcss/v4-engine/miniprogram.ts
1033
- const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
1034
- cssChildCombinatorReplaceValue: ["view", "text"],
1035
- cssRemoveHoverPseudoClass: true,
1036
- isMainChunk: true,
1037
- majorVersion: 4
1038
- });
1039
- const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
1040
- function normalizeTailwindV4GeneratedUrlValues(css) {
1041
- return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
1042
- try {
1043
- return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
1044
- } catch {
1045
- return match;
1046
- }
1047
- });
1048
- }
1049
- async function transformTailwindV4CssToWeapp(css, options) {
1050
- const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
1051
- const result = await defaultStyleHandler$1(protectedCss.css, {
1052
- cssChildCombinatorReplaceValue: ["view", "text"],
1053
- cssRemoveHoverPseudoClass: true,
1054
- isMainChunk: true,
1055
- majorVersion: 4,
1056
- ...options
1057
- });
1058
- const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
1059
- return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
1060
- }
1061
- async function transformTailwindV4CssByTarget(css, target, options) {
1062
- if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
1063
- return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
1064
- }
1065
- //#endregion
1066
1129
  //#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
1067
1130
  const TAILWIND_V3_COLOR_STEPS = [
1068
1131
  "50",
@@ -1794,40 +1857,7 @@ function createTailwindV4DefaultColorThemeCss() {
1794
1857
  ].join("\n");
1795
1858
  }
1796
1859
  //#endregion
1797
- //#region src/tailwindcss/v4-engine/generator.ts
1798
- const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
1799
- const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
1800
- const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
1801
- const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
1802
- const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
1803
- "**/.git/**",
1804
- "**/.hg/**",
1805
- "**/.jj/**",
1806
- "**/.next/**",
1807
- "**/.parcel-cache/**",
1808
- "**/.pnpm-store/**",
1809
- "**/.svelte-kit/**",
1810
- "**/.svn/**",
1811
- "**/.turbo/**",
1812
- "**/.venv/**",
1813
- "**/.vercel/**",
1814
- "**/.yarn/**",
1815
- "**/__pycache__/**",
1816
- "**/node_modules/**",
1817
- "**/venv/**",
1818
- "**/*.less",
1819
- "**/*.lock",
1820
- "**/*.sass",
1821
- "**/*.scss",
1822
- "**/*.styl",
1823
- "**/*.log",
1824
- "**/package-lock.json",
1825
- "**/pnpm-lock.yaml",
1826
- "**/bun.lockb",
1827
- "**/.gitignore",
1828
- "**/.env",
1829
- "**/.env.*"
1830
- ];
1860
+ //#region src/tailwindcss/v4-engine/generator/css-compat.ts
1831
1861
  function findLeadingImportInsertionIndex(css) {
1832
1862
  const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
1833
1863
  let insertionIndex = 0;
@@ -1844,100 +1874,64 @@ function applyMiniProgramTailwindV4DefaultColorCss(css) {
1844
1874
  if (insertionIndex === 0) return `${themeCss}\n${css}`;
1845
1875
  return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
1846
1876
  }
1847
- function collectCandidates$1(candidates) {
1848
- return new Set(candidates ?? []);
1877
+ function parseCssImportSpecifier$3(params) {
1878
+ const value = params.trim();
1879
+ const quoted = /^(['"])(.*?)\1/.exec(value);
1880
+ if (quoted) return quoted[2];
1881
+ const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
1882
+ return url?.[2] ?? url?.[3];
1849
1883
  }
1850
- function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
1851
- for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
1852
- return false;
1884
+ function isTailwindCssPreflightImport(params) {
1885
+ const specifier = parseCssImportSpecifier$3(params);
1886
+ return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
1853
1887
  }
1854
- function normalizeRpxTextCandidate(candidate) {
1855
- return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
1888
+ function hasImportLayerOption(params) {
1889
+ return /\blayer(?:\s*\(|\s*$)/.test(params);
1856
1890
  }
1857
- function normalizeRpxTextCandidates(candidates) {
1858
- const normalized = /* @__PURE__ */ new Set();
1859
- const restoreCandidates = /* @__PURE__ */ new Map();
1860
- for (const candidate of candidates) {
1861
- const normalizedCandidate = normalizeRpxTextCandidate(candidate);
1862
- normalized.add(normalizedCandidate);
1863
- if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
1864
- }
1865
- return {
1866
- candidates: normalized,
1867
- restoreCandidates
1868
- };
1869
- }
1870
- function restoreRpxTextCandidates(candidates, restoreCandidates) {
1871
- if (restoreCandidates.size === 0) return new Set(candidates);
1872
- return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
1873
- }
1874
- function normalizeCssEscapedRpxSelectorValue(value) {
1875
- return value.replace(/\\([.+-])/g, "$1");
1876
- }
1877
- function restoreRpxTextCssSelectors(css, restoreCandidates) {
1878
- if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
1879
- const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
1880
- return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
1881
- }).filter((value) => Boolean(value)));
1882
- return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
1883
- return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
1884
- });
1885
- }
1886
- function createStableJson$2(value) {
1887
- if (value === void 0) return "undefined";
1888
- if (value === null || typeof value !== "object") return JSON.stringify(value);
1889
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson$2(item)).join(",")}]`;
1890
- return `{${Object.keys(value).sort().map((key) => {
1891
- const record = value;
1892
- return `${JSON.stringify(key)}:${createStableJson$2(record[key])}`;
1893
- }).join(",")}}`;
1894
- }
1895
- function createDependencyFingerprint$1(files) {
1896
- return files.map((file) => {
1897
- try {
1898
- const stat = node_fs.default.statSync(file);
1899
- return `${file}:${stat.size}:${stat.mtimeMs}`;
1900
- } catch {
1901
- return `${file}:missing`;
1891
+ function removeUnlayeredTailwindV4PreflightImports(css) {
1892
+ if (!css.includes("preflight")) return css;
1893
+ let root;
1894
+ try {
1895
+ root = require_watch_dependencies.postcss_default.parse(css);
1896
+ } catch {
1897
+ return css;
1898
+ }
1899
+ let changed = false;
1900
+ root.walkAtRules("import", (rule) => {
1901
+ if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
1902
+ rule.remove();
1903
+ changed = true;
1902
1904
  }
1903
- }).join("|");
1904
- }
1905
- function createIncrementalGenerateCacheKey$1(source, target, styleOptions, tailwindcssV3Compatibility) {
1906
- return [
1907
- source.projectRoot,
1908
- source.base,
1909
- createStableJson$2(source.baseFallbacks),
1910
- source.css,
1911
- createDependencyFingerprint$1(source.dependencies),
1912
- target,
1913
- createStableJson$2(styleOptions),
1914
- createStableJson$2(tailwindcssV3Compatibility)
1915
- ].join("\0");
1905
+ });
1906
+ return changed ? root.toString() : css;
1916
1907
  }
1917
- function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
1918
- return [
1919
- cacheKey,
1920
- scanSources === true ? "scan:1" : "scan:0",
1921
- [...requestedCandidates].sort().join("\n")
1922
- ].join("\0");
1908
+ function hasThemeParent(rule) {
1909
+ let parent = rule.parent;
1910
+ while (parent) {
1911
+ if (parent.type === "atrule" && parent.name === "theme") return true;
1912
+ parent = parent.parent;
1913
+ }
1914
+ return false;
1923
1915
  }
1924
- function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
1925
- const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
1926
- const cachedTask = incrementalGenerateTaskCache.get(taskKey);
1927
- if (cachedTask) return cachedTask;
1928
- const promise = task();
1929
- incrementalGenerateTaskCache.set(taskKey, promise);
1930
- promise.finally(() => {
1931
- if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
1932
- });
1933
- return promise;
1916
+ function isVendorPrefixedKeyframes(rule) {
1917
+ return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
1934
1918
  }
1935
- function createIncrementalDesignSystemPromise(source, cacheKey) {
1936
- const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
1937
- promise.catch(() => {
1938
- if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
1919
+ function removeUnsupportedThemeVendorKeyframes(css) {
1920
+ if (!css.includes("@theme") || !css.includes("@-")) return css;
1921
+ let root;
1922
+ try {
1923
+ root = require_watch_dependencies.postcss_default.parse(css);
1924
+ } catch {
1925
+ return css;
1926
+ }
1927
+ let changed = false;
1928
+ root.walkAtRules((rule) => {
1929
+ if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
1930
+ rule.remove();
1931
+ changed = true;
1932
+ }
1939
1933
  });
1940
- return promise;
1934
+ return changed ? root.toString() : css;
1941
1935
  }
1942
1936
  function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
1943
1937
  const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
@@ -1948,55 +1942,73 @@ function createCompatibleSource(source, target, tailwindcssV3Compatibility) {
1948
1942
  css: compatibleSourceCss
1949
1943
  };
1950
1944
  }
1951
- function resolveTargetCandidates(candidates, target) {
1952
- const collected = collectCandidates$1(candidates);
1953
- return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
1954
- }
1955
- function collectSeenCandidates(generated, requestedCandidates) {
1956
- return new Set([
1957
- ...requestedCandidates,
1958
- ...generated.rawCandidates,
1959
- ...generated.classSet
1960
- ]);
1945
+ //#endregion
1946
+ //#region src/tailwindcss/v4-engine/generator/rpx-candidates.ts
1947
+ const BARE_RPX_TEXT_CANDIDATE_RE = /(^|:)text-\[([-+]?(?:\d+|\d*\.\d+)rpx)\](.*)$/u;
1948
+ const RPX_TEXT_LENGTH_SELECTOR_RE = /text-\\\[length\\:((?:\\[.+-]|[+\-.\d])+rpx)\\\]/g;
1949
+ function normalizeRpxTextCandidate(candidate) {
1950
+ return candidate.replace(BARE_RPX_TEXT_CANDIDATE_RE, "$1text-[length:$2]$3");
1961
1951
  }
1962
- function createIncrementalStyleOptions(styleOptions) {
1952
+ function normalizeRpxTextCandidates(candidates) {
1953
+ const normalized = /* @__PURE__ */ new Set();
1954
+ const restoreCandidates = /* @__PURE__ */ new Map();
1955
+ for (const candidate of candidates) {
1956
+ const normalizedCandidate = normalizeRpxTextCandidate(candidate);
1957
+ normalized.add(normalizedCandidate);
1958
+ if (normalizedCandidate !== candidate) restoreCandidates.set(normalizedCandidate, candidate);
1959
+ }
1963
1960
  return {
1964
- ...styleOptions,
1965
- isMainChunk: false
1961
+ candidates: normalized,
1962
+ restoreCandidates
1966
1963
  };
1967
1964
  }
1968
- function resolveStyleOptions$1(source, options) {
1969
- return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
1970
- }
1971
- function collectCustomPropertyValues(css) {
1972
- const values = /* @__PURE__ */ new Map();
1973
- try {
1974
- require_watch_dependencies.postcss_default.parse(css).walkDecls((decl) => {
1975
- if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
1976
- });
1977
- } catch {}
1978
- return values;
1965
+ function restoreRpxTextCandidates(candidates, restoreCandidates) {
1966
+ if (restoreCandidates.size === 0) return new Set(candidates);
1967
+ return new Set([...candidates].map((candidate) => restoreCandidates.get(candidate) ?? candidate));
1979
1968
  }
1980
- function mergeCustomPropertyValues(target, css) {
1981
- for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
1969
+ function normalizeCssEscapedRpxSelectorValue(value) {
1970
+ return value.replace(/\\([.+-])/g, "$1");
1982
1971
  }
1983
- function seedIncrementalGenerateCache(options) {
1984
- const cacheKey = createIncrementalGenerateCacheKey$1(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
1985
- const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
1986
- mergeCustomPropertyValues(customPropertyValues, options.generated.css);
1987
- incrementalGenerateCache$1.set(cacheKey, {
1988
- seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
1989
- classSet: new Set(options.generated.classSet),
1990
- css: options.generated.css,
1991
- rawCss: options.generated.rawCss,
1992
- customPropertyValues,
1993
- designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
1994
- dependencies: options.generated.dependencies,
1995
- sources: options.generated.sources,
1996
- root: options.generated.root,
1997
- target: options.generated.target
1972
+ function restoreRpxTextCssSelectors(css, restoreCandidates) {
1973
+ if (restoreCandidates.size === 0 || !css.includes("text-\\[length\\:")) return css;
1974
+ const restoredValues = new Set([...restoreCandidates.keys()].map((candidate) => {
1975
+ return BARE_RPX_TEXT_CANDIDATE_RE.exec(candidate.replace("[length:", "["))?.[2];
1976
+ }).filter((value) => Boolean(value)));
1977
+ return css.replace(RPX_TEXT_LENGTH_SELECTOR_RE, (match, value) => {
1978
+ return restoredValues.has(normalizeCssEscapedRpxSelectorValue(value)) ? `text-\\[${value}\\]` : match;
1998
1979
  });
1999
1980
  }
1981
+ //#endregion
1982
+ //#region src/tailwindcss/v4-engine/generator/scan-sources.ts
1983
+ const TAILWIND_V4_DEFAULT_IGNORED_SOURCE_PATTERNS = [
1984
+ "**/.git/**",
1985
+ "**/.hg/**",
1986
+ "**/.jj/**",
1987
+ "**/.next/**",
1988
+ "**/.parcel-cache/**",
1989
+ "**/.pnpm-store/**",
1990
+ "**/.svelte-kit/**",
1991
+ "**/.svn/**",
1992
+ "**/.turbo/**",
1993
+ "**/.venv/**",
1994
+ "**/.vercel/**",
1995
+ "**/.yarn/**",
1996
+ "**/__pycache__/**",
1997
+ "**/node_modules/**",
1998
+ "**/venv/**",
1999
+ "**/*.less",
2000
+ "**/*.lock",
2001
+ "**/*.sass",
2002
+ "**/*.scss",
2003
+ "**/*.styl",
2004
+ "**/*.log",
2005
+ "**/package-lock.json",
2006
+ "**/pnpm-lock.yaml",
2007
+ "**/bun.lockb",
2008
+ "**/.gitignore",
2009
+ "**/.env",
2010
+ "**/.env.*"
2011
+ ];
2000
2012
  function parseImportSourceParam$1(params) {
2001
2013
  const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
2002
2014
  if (!match) return;
@@ -2005,10 +2017,6 @@ function parseImportSourceParam$1(params) {
2005
2017
  sourcePath: match[3]
2006
2018
  };
2007
2019
  }
2008
- function isTailwindCssImport$1(params) {
2009
- const specifier = parseCssImportSpecifier$2(params);
2010
- return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
2011
- }
2012
2020
  function parseCssImportSpecifier$2(params) {
2013
2021
  const value = params.trim();
2014
2022
  const quoted = /^(['"])(.*?)\1/.exec(value);
@@ -2016,29 +2024,9 @@ function parseCssImportSpecifier$2(params) {
2016
2024
  const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
2017
2025
  return url?.[2] ?? url?.[3];
2018
2026
  }
2019
- function isTailwindCssPreflightImport(params) {
2027
+ function isTailwindCssImport$1(params) {
2020
2028
  const specifier = parseCssImportSpecifier$2(params);
2021
- return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
2022
- }
2023
- function hasImportLayerOption(params) {
2024
- return /\blayer(?:\s*\(|\s*$)/.test(params);
2025
- }
2026
- function removeUnlayeredTailwindV4PreflightImports(css) {
2027
- if (!css.includes("preflight")) return css;
2028
- let root;
2029
- try {
2030
- root = require_watch_dependencies.postcss_default.parse(css);
2031
- } catch {
2032
- return css;
2033
- }
2034
- let changed = false;
2035
- root.walkAtRules("import", (rule) => {
2036
- if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
2037
- rule.remove();
2038
- changed = true;
2039
- }
2040
- });
2041
- return changed ? root.toString() : css;
2029
+ return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
2042
2030
  }
2043
2031
  function resolveSourceBase$1(base, sourcePath) {
2044
2032
  return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
@@ -2091,33 +2079,155 @@ async function resolveScanSources(source, scanSources) {
2091
2079
  if (scanSources !== true) return scanSources;
2092
2080
  return await resolveCssDefinedScanSources(source) ?? false;
2093
2081
  }
2094
- function hasThemeParent(rule) {
2095
- let parent = rule.parent;
2096
- while (parent) {
2097
- if (parent.type === "atrule" && parent.name === "theme") return true;
2098
- parent = parent.parent;
2099
- }
2100
- return false;
2082
+ //#endregion
2083
+ //#region src/tailwindcss/v4-engine/miniprogram.ts
2084
+ const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
2085
+ cssChildCombinatorReplaceValue: ["view", "text"],
2086
+ cssRemoveHoverPseudoClass: true,
2087
+ isMainChunk: true,
2088
+ majorVersion: 4
2089
+ });
2090
+ const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
2091
+ function normalizeTailwindV4GeneratedUrlValues(css) {
2092
+ return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
2093
+ try {
2094
+ return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
2095
+ } catch {
2096
+ return match;
2097
+ }
2098
+ });
2099
+ }
2100
+ async function transformTailwindV4CssToWeapp(css, options) {
2101
+ const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(hasCssMacroStyleOptions(options) ? await transformCssMacroCss(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
2102
+ const result = await defaultStyleHandler$1(protectedCss.css, {
2103
+ cssChildCombinatorReplaceValue: ["view", "text"],
2104
+ cssRemoveHoverPseudoClass: true,
2105
+ isMainChunk: true,
2106
+ majorVersion: 4,
2107
+ ...options
2108
+ });
2109
+ const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
2110
+ return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
2111
+ }
2112
+ async function transformTailwindV4CssByTarget(css, target, options) {
2113
+ if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
2114
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
2115
+ }
2116
+ //#endregion
2117
+ //#region src/tailwindcss/v4-engine/generator.ts
2118
+ const incrementalGenerateCache$1 = /* @__PURE__ */ new Map();
2119
+ const incrementalGenerateTaskCache = /* @__PURE__ */ new Map();
2120
+ function collectCandidates(candidates) {
2121
+ return new Set(candidates ?? []);
2122
+ }
2123
+ function hasRemovedCandidates$1(previousCandidates, nextCandidates) {
2124
+ for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
2125
+ return false;
2126
+ }
2127
+ function createStableJson$1(value) {
2128
+ if (value === void 0) return "undefined";
2129
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
2130
+ if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
2131
+ return `{${Object.keys(value).sort().map((key) => {
2132
+ const record = value;
2133
+ return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
2134
+ }).join(",")}}`;
2135
+ }
2136
+ function createDependencyFingerprint(files) {
2137
+ return files.map((file) => {
2138
+ try {
2139
+ const stat = node_fs.default.statSync(file);
2140
+ return `${file}:${stat.size}:${stat.mtimeMs}`;
2141
+ } catch {
2142
+ return `${file}:missing`;
2143
+ }
2144
+ }).join("|");
2145
+ }
2146
+ function createIncrementalGenerateCacheKey(source, target, styleOptions, tailwindcssV3Compatibility) {
2147
+ return [
2148
+ source.projectRoot,
2149
+ source.base,
2150
+ createStableJson$1(source.baseFallbacks),
2151
+ source.css,
2152
+ createDependencyFingerprint(source.dependencies),
2153
+ target,
2154
+ createStableJson$1(styleOptions),
2155
+ createStableJson$1(tailwindcssV3Compatibility)
2156
+ ].join("\0");
2157
+ }
2158
+ function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
2159
+ return [
2160
+ cacheKey,
2161
+ scanSources === true ? "scan:1" : "scan:0",
2162
+ [...requestedCandidates].sort().join("\n")
2163
+ ].join("\0");
2164
+ }
2165
+ function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
2166
+ const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
2167
+ const cachedTask = incrementalGenerateTaskCache.get(taskKey);
2168
+ if (cachedTask) return cachedTask;
2169
+ const promise = task();
2170
+ incrementalGenerateTaskCache.set(taskKey, promise);
2171
+ promise.finally(() => {
2172
+ if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
2173
+ });
2174
+ return promise;
2175
+ }
2176
+ function createIncrementalDesignSystemPromise(source, cacheKey) {
2177
+ const promise = (0, tailwindcss_patch.loadTailwindV4DesignSystem)(source);
2178
+ promise.catch(() => {
2179
+ if (incrementalGenerateCache$1.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache$1.delete(cacheKey);
2180
+ });
2181
+ return promise;
2182
+ }
2183
+ function resolveTargetCandidates(candidates, target) {
2184
+ const collected = collectCandidates(candidates);
2185
+ return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
2186
+ }
2187
+ function collectSeenCandidates(generated, requestedCandidates) {
2188
+ return new Set([
2189
+ ...requestedCandidates,
2190
+ ...generated.rawCandidates,
2191
+ ...generated.classSet
2192
+ ]);
2193
+ }
2194
+ function createIncrementalStyleOptions(styleOptions) {
2195
+ return {
2196
+ ...styleOptions,
2197
+ isMainChunk: false
2198
+ };
2101
2199
  }
2102
- function isVendorPrefixedKeyframes(rule) {
2103
- return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
2200
+ function resolveStyleOptions$1(source, options) {
2201
+ return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
2104
2202
  }
2105
- function removeUnsupportedThemeVendorKeyframes(css) {
2106
- if (!css.includes("@theme") || !css.includes("@-")) return css;
2107
- let root;
2203
+ function collectCustomPropertyValues(css) {
2204
+ const values = /* @__PURE__ */ new Map();
2108
2205
  try {
2109
- root = require_watch_dependencies.postcss_default.parse(css);
2110
- } catch {
2111
- return css;
2112
- }
2113
- let changed = false;
2114
- root.walkAtRules((rule) => {
2115
- if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
2116
- rule.remove();
2117
- changed = true;
2118
- }
2206
+ require_watch_dependencies.postcss_default.parse(css).walkDecls((decl) => {
2207
+ if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
2208
+ });
2209
+ } catch {}
2210
+ return values;
2211
+ }
2212
+ function mergeCustomPropertyValues(target, css) {
2213
+ for (const [prop, value] of collectCustomPropertyValues(css)) target.set(prop, value);
2214
+ }
2215
+ function seedIncrementalGenerateCache(options) {
2216
+ const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions, options.tailwindcssV3Compatibility);
2217
+ const customPropertyValues = collectCustomPropertyValues(options.compatibleSource.css);
2218
+ mergeCustomPropertyValues(customPropertyValues, options.generated.css);
2219
+ incrementalGenerateCache$1.set(cacheKey, {
2220
+ seenCandidates: collectSeenCandidates(options.generated, options.requestedCandidates),
2221
+ classSet: new Set(options.generated.classSet),
2222
+ css: options.generated.css,
2223
+ rawCss: options.generated.rawCss,
2224
+ customPropertyValues,
2225
+ designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
2226
+ dependencies: options.generated.dependencies,
2227
+ sources: options.generated.sources,
2228
+ root: options.generated.root,
2229
+ target: options.generated.target
2119
2230
  });
2120
- return changed ? root.toString() : css;
2121
2231
  }
2122
2232
  function createTailwindV4Engine(source) {
2123
2233
  async function generateOnce(generateSource, options = {}) {
@@ -2125,8 +2235,8 @@ function createTailwindV4Engine(source) {
2125
2235
  const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
2126
2236
  const engine = (0, tailwindcss_patch.createTailwindV4Engine)(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
2127
2237
  const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
2128
- const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { bareArbitraryValues: patchOptions.bareArbitraryValues })) : void 0;
2129
- const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates$1(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
2238
+ const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, tailwindcss_patch.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
2239
+ const normalizedCandidates = normalizeRpxTextCandidates(resolveTargetCandidates(new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target));
2130
2240
  const result = await engine.generate(omitUndefined({
2131
2241
  scanSources: false,
2132
2242
  ...patchOptions,
@@ -2149,7 +2259,7 @@ function createTailwindV4Engine(source) {
2149
2259
  const requestedCandidates = resolveTargetCandidates(options.candidates, target);
2150
2260
  const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
2151
2261
  if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
2152
- const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
2262
+ const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
2153
2263
  if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
2154
2264
  const generated = await generateOnce(source, options);
2155
2265
  seedIncrementalGenerateCache({
@@ -2338,96 +2448,48 @@ function hasTailwindGeneratedCssMarkers(rawSource) {
2338
2448
  return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
2339
2449
  }
2340
2450
  //#endregion
2341
- //#region src/bundlers/shared/generator-css/directives.ts
2342
- const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
2343
- "config",
2344
- "custom-variant",
2345
- "layer",
2346
- "plugin",
2347
- "reference",
2348
- "source",
2349
- "tailwind",
2350
- "theme",
2351
- "utility",
2352
- "variant"
2353
- ]);
2354
- const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
2355
- "config",
2356
- "custom-variant",
2357
- "plugin",
2358
- "source",
2359
- "tailwind",
2360
- "theme",
2361
- "utility",
2362
- "variant"
2363
- ]);
2364
- const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
2451
+ //#region src/bundlers/shared/generator-css/directives/fallback.ts
2365
2452
  const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
2366
2453
  const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
2367
2454
  const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant|plugin)\b[\s\S]*\{/;
2368
- const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
2369
- ["tailwindcss/base", "base"],
2370
- ["tailwindcss/components", "components"],
2371
- ["tailwindcss/utilities", "utilities"]
2372
- ]);
2373
- function parseImportRequest(params) {
2455
+ function parseImportRequest$1(params) {
2374
2456
  return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
2375
2457
  }
2376
- function parseConfigRequest(params) {
2458
+ function parseConfigRequest$1(params) {
2377
2459
  return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2378
2460
  }
2379
- function isPackageJsonImportRequest$1(request) {
2461
+ function isPackageJsonImportRequest$2(request) {
2380
2462
  return typeof request === "string" && request.startsWith("#");
2381
2463
  }
2382
- function isWeappTailwindcssImportRequest(request) {
2464
+ function isWeappTailwindcssImportRequest$1(request) {
2383
2465
  return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
2384
2466
  }
2385
- function normalizeTailwindImportRequest(request, options = {}) {
2386
- if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2467
+ function isTailwindImportRequest$1(request) {
2468
+ return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
2469
+ }
2470
+ function normalizeTailwindImportRequest$1(request, options = {}) {
2471
+ if (options.importFallback && isWeappTailwindcssImportRequest$1(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2387
2472
  return request;
2388
2473
  }
2389
- function replaceImportRequest(params, request, replacement) {
2474
+ function replaceImportRequest$1(params, request, replacement) {
2390
2475
  const index = params.indexOf(request);
2391
2476
  if (index === -1) return params;
2392
2477
  return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
2393
2478
  }
2394
- function normalizeTailwindImportAtRules(root, options = {}) {
2395
- if (!options.importFallback) return false;
2396
- let changed = false;
2397
- const seenCanonicalImports = /* @__PURE__ */ new Set();
2398
- root.walkAtRules("import", (node) => {
2399
- const request = parseImportRequest(node.params);
2400
- const normalizedRequest = normalizeTailwindImportRequest(request, options);
2401
- if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
2402
- const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
2403
- const normalizedKey = normalizedParams.trim();
2404
- if (seenCanonicalImports.has(normalizedKey)) {
2405
- node.remove();
2406
- changed = true;
2407
- return;
2408
- }
2409
- seenCanonicalImports.add(normalizedKey);
2410
- if (normalizedParams !== node.params) {
2411
- node.params = normalizedParams;
2412
- changed = true;
2413
- }
2414
- });
2415
- return changed;
2416
- }
2417
2479
  function normalizeTailwindDirectiveLine(line, options = {}) {
2418
2480
  const trimmed = line.trimStart();
2419
2481
  if (/^@(?:use|forward)\b/.test(trimmed)) {
2420
- const request = parseImportRequest(trimmed.replace(/^@(?:use|forward)\b/, ""));
2421
- if (isTailwindImportRequest(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
2422
- const normalizedRequest = normalizeTailwindImportRequest(request, options);
2423
- return replaceImportRequest(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
2482
+ const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
2483
+ if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest$1(request)) {
2484
+ const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
2485
+ return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
2424
2486
  }
2425
2487
  return line;
2426
2488
  }
2427
2489
  if (!options.importFallback || !trimmed.startsWith("@import")) return line;
2428
- const request = parseImportRequest(trimmed.replace(/^@import\b/, ""));
2429
- if (!request || !isWeappTailwindcssImportRequest(request)) return line;
2430
- return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
2490
+ const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
2491
+ if (!request || !isWeappTailwindcssImportRequest$1(request)) return line;
2492
+ return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
2431
2493
  }
2432
2494
  function extractTailwindDirectiveLines(rawSource, options = {}) {
2433
2495
  const directives = [];
@@ -2441,10 +2503,10 @@ function extractTailwindDirectiveLines(rawSource, options = {}) {
2441
2503
  const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
2442
2504
  const normalizedTrimmed = normalized.trim();
2443
2505
  if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
2444
- const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
2445
- if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest$1(request)) continue;
2506
+ const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest$1(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
2507
+ if (request && !isTailwindImportRequest$1(request) && !isPackageJsonImportRequest$2(request)) continue;
2446
2508
  if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
2447
- if (request && isTailwindImportRequest(request)) {
2509
+ if (request && isTailwindImportRequest$1(request)) {
2448
2510
  const key = normalizedTrimmed;
2449
2511
  if (seenImports.has(key)) continue;
2450
2512
  seenImports.add(key);
@@ -2540,10 +2602,84 @@ function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
2540
2602
  function extractConfigRequestFromSource(rawSource) {
2541
2603
  for (const line of rawSource.split(/\r?\n/)) {
2542
2604
  const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
2543
- const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
2605
+ const request = match ? parseConfigRequest$1(match[1] ?? "") : void 0;
2544
2606
  if (request) return request;
2545
2607
  }
2546
2608
  }
2609
+ //#endregion
2610
+ //#region src/bundlers/shared/generator-css/directives.ts
2611
+ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
2612
+ "config",
2613
+ "custom-variant",
2614
+ "layer",
2615
+ "plugin",
2616
+ "reference",
2617
+ "source",
2618
+ "tailwind",
2619
+ "theme",
2620
+ "utility",
2621
+ "variant"
2622
+ ]);
2623
+ const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
2624
+ "config",
2625
+ "custom-variant",
2626
+ "plugin",
2627
+ "source",
2628
+ "tailwind",
2629
+ "theme",
2630
+ "utility",
2631
+ "variant"
2632
+ ]);
2633
+ const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
2634
+ const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
2635
+ ["tailwindcss/base", "base"],
2636
+ ["tailwindcss/components", "components"],
2637
+ ["tailwindcss/utilities", "utilities"]
2638
+ ]);
2639
+ function parseImportRequest(params) {
2640
+ return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
2641
+ }
2642
+ function parseConfigRequest(params) {
2643
+ return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2644
+ }
2645
+ function isPackageJsonImportRequest$1(request) {
2646
+ return typeof request === "string" && request.startsWith("#");
2647
+ }
2648
+ function isWeappTailwindcssImportRequest(request) {
2649
+ return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
2650
+ }
2651
+ function normalizeTailwindImportRequest(request, options = {}) {
2652
+ if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
2653
+ return request;
2654
+ }
2655
+ function replaceImportRequest(params, request, replacement) {
2656
+ const index = params.indexOf(request);
2657
+ if (index === -1) return params;
2658
+ return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
2659
+ }
2660
+ function normalizeTailwindImportAtRules(root, options = {}) {
2661
+ if (!options.importFallback) return false;
2662
+ let changed = false;
2663
+ const seenCanonicalImports = /* @__PURE__ */ new Set();
2664
+ root.walkAtRules("import", (node) => {
2665
+ const request = parseImportRequest(node.params);
2666
+ const normalizedRequest = normalizeTailwindImportRequest(request, options);
2667
+ if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
2668
+ const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
2669
+ const normalizedKey = normalizedParams.trim();
2670
+ if (seenCanonicalImports.has(normalizedKey)) {
2671
+ node.remove();
2672
+ changed = true;
2673
+ return;
2674
+ }
2675
+ seenCanonicalImports.add(normalizedKey);
2676
+ if (normalizedParams !== node.params) {
2677
+ node.params = normalizedParams;
2678
+ changed = true;
2679
+ }
2680
+ });
2681
+ return changed;
2682
+ }
2547
2683
  function resolveConfigPath$1(base, configPath) {
2548
2684
  if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest$1(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
2549
2685
  return node_path.default.resolve(base, configPath);
@@ -3117,7 +3253,7 @@ function readStaticConfigContent(configPath) {
3117
3253
  return parseStaticContentValue(source, contentProperty.start)?.value;
3118
3254
  }
3119
3255
  //#endregion
3120
- //#region src/bundlers/vite/source-scan.ts
3256
+ //#region src/bundlers/vite/source-scan/css-entries.ts
3121
3257
  const VITE_SOURCE_CANDIDATE_PATTERN = FULL_SOURCE_SCAN_PATTERN;
3122
3258
  function parseImportSourceParam(params) {
3123
3259
  const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
@@ -3281,6 +3417,40 @@ async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
3281
3417
  return task;
3282
3418
  }
3283
3419
  //#endregion
3420
+ //#region src/tailwindcss/v3-engine/generator/runtime-ready.ts
3421
+ const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
3422
+ function createRuntimeReadyCacheKey(source, rootPath) {
3423
+ return [
3424
+ source.packageName,
3425
+ source.postcssPlugin,
3426
+ rootPath ?? "missing",
3427
+ source.config ?? "config:missing",
3428
+ source.cwd
3429
+ ].join("\0");
3430
+ }
3431
+ function createRuntimeReadyPromise(source) {
3432
+ const patcher = createTailwindcssPatcher({
3433
+ basedir: source.cwd,
3434
+ supportCustomLengthUnitsPatch: true,
3435
+ tailwindcss: {
3436
+ ...source.config === void 0 ? {} : { config: source.config },
3437
+ cwd: source.cwd,
3438
+ packageName: source.packageName,
3439
+ postcssPlugin: source.postcssPlugin,
3440
+ version: 3
3441
+ }
3442
+ });
3443
+ const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
3444
+ const cached = runtimeReadyPromiseCache.get(cacheKey);
3445
+ if (cached) return cached;
3446
+ const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
3447
+ runtimeReadyPromiseCache.delete(cacheKey);
3448
+ throw error;
3449
+ });
3450
+ runtimeReadyPromiseCache.set(cacheKey, task);
3451
+ return task;
3452
+ }
3453
+ //#endregion
3284
3454
  //#region src/tailwindcss/v3-engine/miniprogram.ts
3285
3455
  const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
3286
3456
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -3354,41 +3524,15 @@ async function transformTailwindV3CssToWeapp(css, options) {
3354
3524
  preservePreflight: true,
3355
3525
  preserveConditionalComments: hasCssMacroStyleOptions(options)
3356
3526
  };
3357
- return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
3358
- }
3359
- async function transformTailwindV3CssByTarget(css, target, options) {
3360
- if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
3361
- return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
3362
- }
3363
- //#endregion
3364
- //#region src/tailwindcss/v3-engine/generator.ts
3365
- const runtimeReadyPromiseCache = /* @__PURE__ */ new Map();
3366
- const incrementalGenerateCache = /* @__PURE__ */ new Map();
3367
- function isLegacyContentObject(value) {
3368
- return typeof value === "object" && value !== null && "files" in value;
3369
- }
3370
- function createRawContentEntries(candidates, sources) {
3371
- const entries = [];
3372
- const candidateContent = [...candidates].join(" ");
3373
- if (candidateContent.length > 0) entries.push({
3374
- raw: candidateContent,
3375
- extension: "html"
3376
- });
3377
- for (const source of sources) entries.push({
3378
- raw: source.content,
3379
- extension: source.extension ?? "html"
3380
- });
3381
- return entries;
3382
- }
3383
- function createChangedContentEntries(candidates, sources) {
3384
- return createRawContentEntries(candidates, sources).map((entry) => ({
3385
- content: entry.raw,
3386
- extension: entry.extension
3387
- }));
3527
+ return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
3388
3528
  }
3389
- function collectCandidates(candidates) {
3390
- return new Set(candidates ?? []);
3529
+ async function transformTailwindV3CssByTarget(css, target, options) {
3530
+ if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
3531
+ return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css, options) : css;
3391
3532
  }
3533
+ //#endregion
3534
+ //#region src/tailwindcss/v3-engine/generator.ts
3535
+ const incrementalGenerateCache = /* @__PURE__ */ new Map();
3392
3536
  function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
3393
3537
  return (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
3394
3538
  }
@@ -3408,7 +3552,7 @@ function normalizeBareArbitraryValueCandidates(candidates, bareArbitraryValues)
3408
3552
  async function collectSourceBareArbitraryValueCandidates(sources, bareArbitraryValues) {
3409
3553
  if (!(0, tailwindcss_patch.isBareArbitraryValuesEnabled)(bareArbitraryValues)) return [];
3410
3554
  const candidates = /* @__PURE__ */ new Set();
3411
- for (const source of sources ?? []) for (const candidate of await (0, tailwindcss_patch.extractSourceCandidates)(source.content, source.extension ?? "html", { bareArbitraryValues })) if ((0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)) candidates.add(candidate);
3555
+ for (const source of sources ?? []) for (const candidate of await (0, tailwindcss_patch.extractSourceCandidates)(source.content, source.extension ?? "html", omitUndefined({ bareArbitraryValues }))) if ((0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)) candidates.add(candidate);
3412
3556
  return [...candidates];
3413
3557
  }
3414
3558
  function escapeCssClassSelector(className) {
@@ -3444,99 +3588,6 @@ function hasRemovedCandidates(previousCandidates, nextCandidates) {
3444
3588
  for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
3445
3589
  return false;
3446
3590
  }
3447
- function collectApplyCandidatesFromCss(css) {
3448
- if (!css.includes("@apply")) return [];
3449
- const candidates = /* @__PURE__ */ new Set();
3450
- try {
3451
- require_watch_dependencies.postcss_default.parse(css).walkAtRules("apply", (rule) => {
3452
- for (const candidate of rule.params.split(/\s+/)) {
3453
- const normalized = candidate.replace(/!important$/, "").trim();
3454
- if (normalized) candidates.add(normalized);
3455
- }
3456
- });
3457
- } catch {}
3458
- return [...candidates];
3459
- }
3460
- function isTailwindCandidateLayer(params) {
3461
- return params.split(/[,\s]+/).some((layer) => layer === "components" || layer === "utilities");
3462
- }
3463
- function extractClassCandidatesFromSelector(selector, candidates) {
3464
- for (let index = 0; index < selector.length; index++) {
3465
- if (selector[index] !== ".") continue;
3466
- let candidate = "";
3467
- let escaped = false;
3468
- for (let tokenIndex = index + 1; tokenIndex < selector.length; tokenIndex++) {
3469
- const char = selector[tokenIndex];
3470
- if (escaped) {
3471
- candidate += char;
3472
- escaped = false;
3473
- continue;
3474
- }
3475
- if (char === "\\") {
3476
- escaped = true;
3477
- continue;
3478
- }
3479
- if (char && /[\w-]/.test(char)) {
3480
- candidate += char;
3481
- continue;
3482
- }
3483
- break;
3484
- }
3485
- if (candidate) candidates.add(candidate);
3486
- }
3487
- }
3488
- function collectLayerCandidatesFromCss(css) {
3489
- if (!css.includes("@layer")) return [];
3490
- const candidates = /* @__PURE__ */ new Set();
3491
- try {
3492
- require_watch_dependencies.postcss_default.parse(css).walkAtRules("layer", (layer) => {
3493
- if (!isTailwindCandidateLayer(layer.params)) return;
3494
- layer.walkRules((rule) => {
3495
- extractClassCandidatesFromSelector(rule.selector, candidates);
3496
- });
3497
- });
3498
- } catch {}
3499
- return [...candidates];
3500
- }
3501
- function mergeGenerateCandidates(source, options) {
3502
- return collectCandidates([
3503
- ...collectLayerCandidatesFromCss(source.css),
3504
- ...collectApplyCandidatesFromCss(source.css),
3505
- ...collectCandidates(options.candidates)
3506
- ]);
3507
- }
3508
- function mergeContent(content, rawEntries) {
3509
- if (isLegacyContentObject(content)) return {
3510
- ...content,
3511
- relative: content.relative ?? true,
3512
- files: [...[].concat(content.files ?? []), ...rawEntries]
3513
- };
3514
- return {
3515
- relative: true,
3516
- files: [...[].concat(content ?? []), ...rawEntries]
3517
- };
3518
- }
3519
- function normalizeConfigObject(config) {
3520
- if (!config || typeof config !== "object") return config;
3521
- const maybeDefault = config.default;
3522
- if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
3523
- return config;
3524
- }
3525
- function hasExplicitContentInput(options) {
3526
- return options.candidates !== void 0 || options.sources !== void 0;
3527
- }
3528
- function createExplicitContentConfig(rawEntries) {
3529
- return {
3530
- relative: true,
3531
- files: rawEntries
3532
- };
3533
- }
3534
- function createTailwindConfig(source, options) {
3535
- const config = { ...normalizeConfigObject(source.configObject) ?? {} };
3536
- const rawEntries = createRawContentEntries(mergeGenerateCandidates(source, options), options.sources ?? []);
3537
- config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
3538
- return config;
3539
- }
3540
3591
  function shouldAutoEnableCssMacro(source) {
3541
3592
  return hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
3542
3593
  }
@@ -3576,48 +3627,6 @@ function loadTailwindV3Internals(source) {
3576
3627
  validateConfig: validateConfigModule["validateConfig"]
3577
3628
  };
3578
3629
  }
3579
- function createStableJson$1(value) {
3580
- if (value === void 0) return "undefined";
3581
- if (value === null || typeof value !== "object") return JSON.stringify(value);
3582
- if (Array.isArray(value)) return `[${value.map((item) => createStableJson$1(item)).join(",")}]`;
3583
- return `{${Object.keys(value).sort().map((key) => {
3584
- const record = value;
3585
- return `${JSON.stringify(key)}:${createStableJson$1(record[key])}`;
3586
- }).join(",")}}`;
3587
- }
3588
- function createDependencyFingerprint(files) {
3589
- return files.map((file) => {
3590
- try {
3591
- const stat = node_fs.default.statSync(file);
3592
- return `${file}:${stat.size}:${stat.mtimeMs}`;
3593
- } catch {
3594
- return `${file}:missing`;
3595
- }
3596
- }).join("|");
3597
- }
3598
- function createIncrementalGenerateCacheKey(source, target, styleOptions, bareArbitraryValues) {
3599
- return [
3600
- source.packageName,
3601
- source.postcssPlugin,
3602
- source.cwd,
3603
- source.config ?? "config:missing",
3604
- createDependencyFingerprint(source.dependencies),
3605
- source.css,
3606
- createStableJson$1(normalizeConfigObject(source.configObject)?.content),
3607
- target,
3608
- createStableJson$1(styleOptions),
3609
- createStableJson$1(bareArbitraryValues)
3610
- ].join("\0");
3611
- }
3612
- function createRuntimeReadyCacheKey(source, rootPath) {
3613
- return [
3614
- source.packageName,
3615
- source.postcssPlugin,
3616
- rootPath ?? "missing",
3617
- source.config ?? "config:missing",
3618
- source.cwd
3619
- ].join("\0");
3620
- }
3621
3630
  function isDirectUtilitiesOnlyCss(css) {
3622
3631
  return css.replace(/\s+/g, "") === "@tailwindutilities;";
3623
3632
  }
@@ -3650,28 +3659,6 @@ function appendUtilityRules(root, context, rules) {
3650
3659
  function appendDirectUtilityRules(root, context) {
3651
3660
  appendUtilityRules(root, context, [...context.ruleCache]);
3652
3661
  }
3653
- function createRuntimeReadyPromise(source) {
3654
- const patcher = createTailwindcssPatcher({
3655
- basedir: source.cwd,
3656
- supportCustomLengthUnitsPatch: true,
3657
- tailwindcss: {
3658
- ...source.config === void 0 ? {} : { config: source.config },
3659
- cwd: source.cwd,
3660
- packageName: source.packageName,
3661
- postcssPlugin: source.postcssPlugin,
3662
- version: 3
3663
- }
3664
- });
3665
- const cacheKey = createRuntimeReadyCacheKey(source, patcher.packageInfo?.rootPath);
3666
- const cached = runtimeReadyPromiseCache.get(cacheKey);
3667
- if (cached) return cached;
3668
- const task = ensureTailwindcssRuntimePatch(patcher, { clearRequireCache: true }).catch((error) => {
3669
- runtimeReadyPromiseCache.delete(cacheKey);
3670
- throw error;
3671
- });
3672
- runtimeReadyPromiseCache.set(cacheKey, task);
3673
- return task;
3674
- }
3675
3662
  function createTailwindV3Engine(source) {
3676
3663
  const runtimeReadyPromise = createRuntimeReadyPromise(source);
3677
3664
  let tailwindInternals;
@@ -3757,7 +3744,7 @@ function createTailwindV3Engine(source) {
3757
3744
  const requestedCandidates = mergeGenerateCandidates(source, options);
3758
3745
  if (requestedCandidates.size === 0) return generateOnce(source, options);
3759
3746
  const styleOptions = resolveStyleOptions(source, options.styleOptions);
3760
- const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions, options.bareArbitraryValues);
3747
+ const cacheKey = createIncrementalGenerateCacheKey$1(source, target, styleOptions, options.bareArbitraryValues);
3761
3748
  const cached = incrementalGenerateCache.get(cacheKey);
3762
3749
  if (cached) {
3763
3750
  if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) {
@@ -3913,66 +3900,223 @@ function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
3913
3900
  postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
3914
3901
  };
3915
3902
  }
3916
- function resolveTailwindV3SourceFromPatcher(patcher) {
3917
- return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
3903
+ function resolveTailwindV3SourceFromPatcher(patcher) {
3904
+ return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
3905
+ }
3906
+ //#endregion
3907
+ //#region src/generator/options.ts
3908
+ const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
3909
+ const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
3910
+ const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
3911
+ function getEnvValue(key) {
3912
+ return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
3913
+ }
3914
+ function normalizeGeneratorTargetValue(value) {
3915
+ return value === "weapp" || value === "web" || value === "tailwind" ? value : void 0;
3916
+ }
3917
+ function isUniWebPlatform(value) {
3918
+ const normalized = value?.trim().toLowerCase();
3919
+ return normalized === "h5" || normalized?.startsWith("web") === true;
3920
+ }
3921
+ function isUniAppWebViewPlatform(value) {
3922
+ const normalized = value?.trim().toLowerCase();
3923
+ return normalized === "app" || normalized === "app-plus";
3924
+ }
3925
+ function isUniNativeAppPlatform(value) {
3926
+ return (value?.trim().toLowerCase())?.startsWith("app-") === true;
3927
+ }
3928
+ function isMpxWebPlatform(value) {
3929
+ return value?.trim().toLowerCase() === "web";
3930
+ }
3931
+ function inferGeneratorTargetFromEnv() {
3932
+ for (const key of explicitGeneratorTargetEnvKeys) {
3933
+ const target = normalizeGeneratorTargetValue(getEnvValue(key));
3934
+ if (target !== void 0) return target;
3935
+ }
3936
+ if (uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5") return "web";
3937
+ return "weapp";
3938
+ }
3939
+ function normalizeWeappTailwindcssGeneratorOptions(options) {
3940
+ const target = options?.target ?? inferGeneratorTargetFromEnv();
3941
+ if (options == null) return {
3942
+ target,
3943
+ importFallback: true,
3944
+ tailwindcssV3Compatibility: target === "weapp",
3945
+ bareArbitraryValues: void 0
3946
+ };
3947
+ return {
3948
+ target,
3949
+ config: options.config,
3950
+ styleOptions: options.styleOptions,
3951
+ importFallback: options.importFallback ?? true,
3952
+ tailwindcssV3Compatibility: options.tailwindcssV3Compatibility ?? target === "weapp",
3953
+ bareArbitraryValues: options.bareArbitraryValues
3954
+ };
3955
+ }
3956
+ //#endregion
3957
+ //#region src/generator/index.ts
3958
+ function isTailwindV3Source(source) {
3959
+ return "version" in source && source.version === 3;
3960
+ }
3961
+ function createWeappTailwindcssGenerator(source) {
3962
+ return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
3963
+ }
3964
+ //#endregion
3965
+ //#region src/uni-app-x/options.ts
3966
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
3967
+ enabled: true,
3968
+ onlyWhenStyleIsolationVersion2: true
3969
+ };
3970
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
3971
+ enabled: false,
3972
+ onlyWhenStyleIsolationVersion2: true
3973
+ };
3974
+ function isBooleanUniAppXShortcut(option) {
3975
+ return option === true || option === false || option === void 0;
3976
+ }
3977
+ function resolveComponentLocalStyles(option) {
3978
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
3979
+ const componentLocalStyles = option.componentLocalStyles;
3980
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
3981
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
3982
+ return {
3983
+ enabled: componentLocalStyles.enabled !== false,
3984
+ onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
3985
+ };
3986
+ }
3987
+ function resolveUniAppXOptions(option) {
3988
+ if (typeof option === "object" && option) return {
3989
+ enabled: option.enabled !== false,
3990
+ componentLocalStyles: resolveComponentLocalStyles(option),
3991
+ uvueUnsupported: option.uvueUnsupported ?? "warn"
3992
+ };
3993
+ return {
3994
+ enabled: Boolean(option),
3995
+ componentLocalStyles: resolveComponentLocalStyles(option),
3996
+ uvueUnsupported: "warn"
3997
+ };
3998
+ }
3999
+ function isUniAppXEnabled(option) {
4000
+ return resolveUniAppXOptions(option).enabled;
3918
4001
  }
3919
4002
  //#endregion
3920
- //#region src/generator/options.ts
3921
- const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
3922
- const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
3923
- const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
3924
- function getEnvValue(key) {
3925
- return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
4003
+ //#region src/context/style-options.ts
4004
+ function resolveStyleOptionsFromContext(ctx) {
4005
+ const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
4006
+ return {
4007
+ cssPreflight: ctx.cssPreflight,
4008
+ cssPreflightRange: ctx.cssPreflightRange,
4009
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
4010
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
4011
+ rem2rpx: ctx.rem2rpx,
4012
+ cssRemoveProperty: ctx.cssRemoveProperty,
4013
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
4014
+ cssPresetEnv: ctx.cssPresetEnv,
4015
+ autoprefixer: ctx.autoprefixer,
4016
+ cssCalc: ctx.cssCalc,
4017
+ uniAppX: resolvedUniAppXOptions.enabled,
4018
+ platform: ctx.platform,
4019
+ px2rpx: ctx.px2rpx,
4020
+ unitsToPx: ctx.unitsToPx,
4021
+ unitConversion: ctx.unitConversion
4022
+ };
3926
4023
  }
3927
- function normalizeGeneratorTargetValue(value) {
3928
- return value === "weapp" || value === "web" || value === "tailwind" ? value : void 0;
4024
+ //#endregion
4025
+ //#region src/bundlers/shared/generator-css/generation-helpers.ts
4026
+ function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
4027
+ if (target !== "weapp") return css;
4028
+ return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
4029
+ cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
4030
+ isTailwindcssV4: majorVersion === 4,
4031
+ preservePseudoContentInit: majorVersion === 3
4032
+ });
3929
4033
  }
3930
- function isUniWebPlatform(value) {
3931
- const normalized = value?.trim().toLowerCase();
3932
- return normalized === "h5" || normalized?.startsWith("web") === true;
4034
+ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
4035
+ if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return false;
4036
+ if (!options.isolateCurrentCssCandidates) return true;
4037
+ return isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
3933
4038
  }
3934
- function isUniAppWebViewPlatform(value) {
3935
- const normalized = value?.trim().toLowerCase();
3936
- return normalized === "app" || normalized === "app-plus";
4039
+ function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
4040
+ if (options.isolateCssSource && options.currentCssCandidates?.length) return new Set([...scopedRuntime, ...options.currentCssCandidates]);
4041
+ if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk || options.matchedCssSourceFile || options.isolateCssSource && scopedRuntime.size === 0) return scopedRuntime;
4042
+ return new Set([...scopedRuntime, ...runtime]);
3937
4043
  }
3938
- function isUniNativeAppPlatform(value) {
3939
- return (value?.trim().toLowerCase())?.startsWith("app-") === true;
4044
+ function shouldIsolateScopedCssSource(source, sourceEntries) {
4045
+ return Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile) || sourceEntries !== void 0 && sourceEntries.length > 0;
3940
4046
  }
3941
- function isMpxWebPlatform(value) {
3942
- return value?.trim().toLowerCase() === "web";
4047
+ function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
4048
+ return majorVersion === 4 && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(options.rawSource) && !hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
3943
4049
  }
3944
- function inferGeneratorTargetFromEnv() {
3945
- for (const key of explicitGeneratorTargetEnvKeys) {
3946
- const target = normalizeGeneratorTargetValue(getEnvValue(key));
3947
- if (target !== void 0) return target;
3948
- }
3949
- if (uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5") return "web";
3950
- return "weapp";
4050
+ function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
4051
+ if (majorVersion !== 4) return false;
4052
+ if (target === "web") return true;
4053
+ if (isolateCssSource) return false;
4054
+ return generatorRuntime.size === 0;
3951
4055
  }
3952
- function normalizeWeappTailwindcssGeneratorOptions(options) {
3953
- const target = options?.target ?? inferGeneratorTargetFromEnv();
3954
- if (options == null) return {
3955
- target,
3956
- importFallback: true,
3957
- tailwindcssV3Compatibility: target === "weapp",
3958
- bareArbitraryValues: void 0
4056
+ function shouldAppendWebBundleCssFallback(target, options) {
4057
+ return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
4058
+ }
4059
+ function isEmptyCssSourceOrderParts(parts) {
4060
+ return parts.before.trim().length === 0 && parts.after.trim().length === 0;
4061
+ }
4062
+ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
4063
+ const preflightStyleOptions = {
4064
+ cssPreflight: opts.cssPreflight,
4065
+ cssPreflightRange: opts.cssPreflightRange
3959
4066
  };
3960
4067
  return {
3961
- target,
3962
- config: options.config,
3963
- styleOptions: options.styleOptions,
3964
- importFallback: options.importFallback ?? true,
3965
- tailwindcssV3Compatibility: options.tailwindcssV3Compatibility ?? target === "weapp",
3966
- bareArbitraryValues: options.bareArbitraryValues
4068
+ ...resolveStyleOptionsFromContext(opts),
4069
+ atRules: opts.atRules,
4070
+ uniAppXCssTarget: opts.uniAppXCssTarget,
4071
+ uniAppXUnsupported: opts.uniAppXUnsupported,
4072
+ ...cssHandlerOptions,
4073
+ ...preflightStyleOptions,
4074
+ ...generatorStyleOptions
3967
4075
  };
3968
4076
  }
3969
- //#endregion
3970
- //#region src/generator/index.ts
3971
- function isTailwindV3Source(source) {
3972
- return "version" in source && source.version === 3;
4077
+ function createCssSourceOrderAppend$1(base, extra) {
4078
+ if (!base) return extra;
4079
+ if (!extra) return base;
4080
+ if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
4081
+ return `${base}\n${extra}`;
3973
4082
  }
3974
- function createWeappTailwindcssGenerator(source) {
3975
- return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
4083
+ function shouldFinalizeMarkedUserLayerComponentsCss(file) {
4084
+ return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
4085
+ }
4086
+ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
4087
+ const placeholderParts = splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
4088
+ if (placeholderParts) return placeholderParts;
4089
+ const exactParts = splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
4090
+ if (exactParts) return exactParts;
4091
+ return splitTailwindGeneratedCssByBanner(rawSource);
4092
+ }
4093
+ function shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, options) {
4094
+ const hasApplyDirectives = hasTailwindApplyDirective(options.rawSource);
4095
+ return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || majorVersion === 4 && hasApplyDirectives || cssHandlerOptions.isMainChunk;
4096
+ }
4097
+ function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
4098
+ return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
4099
+ }
4100
+ function mergeGeneratorResults(generatedResults) {
4101
+ const firstGenerated = generatedResults[0];
4102
+ if (!firstGenerated) return;
4103
+ if (generatedResults.length === 1) return firstGenerated;
4104
+ const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
4105
+ const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
4106
+ return {
4107
+ ...firstGenerated,
4108
+ css: generatedResults.map((item) => item.css).join("\n"),
4109
+ rawCss: generatedResults.map((item) => item.rawCss).join("\n"),
4110
+ incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
4111
+ incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
4112
+ classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
4113
+ dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
4114
+ sources: generatedResults.flatMap((item) => item.sources)
4115
+ };
4116
+ }
4117
+ const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
4118
+ function isSupportedGeneratorMajorVersion(majorVersion) {
4119
+ return SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0);
3976
4120
  }
3977
4121
  //#endregion
3978
4122
  //#region src/wxml/shared.ts
@@ -4376,13 +4520,6 @@ function isPathWithinRoot$1(file, root) {
4376
4520
  const relative = node_path.default.relative(root, file);
4377
4521
  return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
4378
4522
  }
4379
- function countCommonSuffixSegments(a, b) {
4380
- const aSegments = a.split("/").filter(Boolean);
4381
- const bSegments = b.split("/").filter(Boolean);
4382
- let count = 0;
4383
- while (count < aSegments.length && count < bSegments.length && aSegments[aSegments.length - 1 - count] === bSegments[bSegments.length - 1 - count]) count++;
4384
- return count;
4385
- }
4386
4523
  function collectOutputMatchBases(file, sourceOptions) {
4387
4524
  const normalizedFile = file.replace(/[?#].*$/, "");
4388
4525
  const roots = [
@@ -4417,7 +4554,7 @@ function isMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
4417
4554
  const normalizedRoot = node_path.default.resolve(root);
4418
4555
  if (isPathWithinRoot$1(normalizedSourceFile, normalizedRoot)) addSourceBase(node_path.default.relative(normalizedRoot, normalizedSourceFile));
4419
4556
  }
4420
- for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`) || countCommonSuffixSegments(outputBase, sourceBase) >= 2) return true;
4557
+ for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
4421
4558
  return false;
4422
4559
  }
4423
4560
  function scoreMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
@@ -4435,13 +4572,9 @@ function scoreMatchingSourceStyleFile(file, sourceFile, sourceOptions) {
4435
4572
  if (isPathWithinRoot$1(normalizedSourceFile, normalizedRoot)) addSourceBase(node_path.default.relative(normalizedRoot, normalizedSourceFile));
4436
4573
  }
4437
4574
  let bestScore = 0;
4438
- for (const outputBase of outputBases) for (const sourceBase of sourceBases) {
4439
- const commonSuffixSegments = countCommonSuffixSegments(outputBase, sourceBase);
4440
- if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
4441
- else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
4442
- else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
4443
- else if (commonSuffixSegments >= 2) bestScore = Math.max(bestScore, 100 + commonSuffixSegments);
4444
- }
4575
+ for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
4576
+ else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
4577
+ else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
4445
4578
  return bestScore;
4446
4579
  }
4447
4580
  function collectMatchedConfiguredSourceFiles(file, sourceOptions) {
@@ -4600,7 +4733,7 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
4600
4733
  return true;
4601
4734
  }
4602
4735
  function shouldResolveSourceSideCssEntry(rawSource) {
4603
- return rawSource.includes("@apply") || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
4736
+ return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
4604
4737
  }
4605
4738
  function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
4606
4739
  return Boolean(sourceSideEntrySource) && !hasTailwindSourceDirectives(rawSource, { importFallback: true });
@@ -4645,17 +4778,6 @@ function collectCssSourceMatchBases(file, roots) {
4645
4778
  } else for (const root of resolvedRoots) addBase(node_path.default.resolve(root, normalizedFile));
4646
4779
  return bases;
4647
4780
  }
4648
- function hasMatchingCssSourceBase(outputBases, sourceBases) {
4649
- for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase || outputBase.endsWith(`/${sourceBase}`) || sourceBase.endsWith(`/${outputBase}`)) return true;
4650
- return false;
4651
- }
4652
- function isMatchingTailwindV4CssSourceFile(file, cssSourceFile, sourceOptions) {
4653
- return hasMatchingCssSourceBase(collectCssSourceMatchBases(file, [
4654
- sourceOptions.outputRoot,
4655
- sourceOptions.projectRoot,
4656
- sourceOptions.cwd
4657
- ]), collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]));
4658
- }
4659
4781
  function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
4660
4782
  const outputBases = collectCssSourceMatchBases(file, [
4661
4783
  sourceOptions.outputRoot,
@@ -4742,12 +4864,29 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
4742
4864
  if (!cssSources?.length) return;
4743
4865
  const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
4744
4866
  const sourceFile = resolvePostcssSourceFile(cssHandlerOptions);
4745
- const matchingSource = cssSources.find((cssSource) => {
4746
- if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return false;
4747
- if (sourceFile && typeof cssSource.file === "string" && node_path.default.resolve(sourceFile) === node_path.default.resolve(cssSource.file)) return true;
4748
- if (typeof cssSource.file === "string" && isMatchingTailwindV4CssSourceFile(file, cssSource.file, sourceOptions)) return true;
4749
- return normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource;
4750
- });
4867
+ const matches = cssSources.map((cssSource, index) => {
4868
+ if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
4869
+ if (sourceFile && typeof cssSource.file === "string" && node_path.default.resolve(sourceFile) === node_path.default.resolve(cssSource.file)) return {
4870
+ cssSource,
4871
+ index,
4872
+ score: 1e6
4873
+ };
4874
+ if (typeof cssSource.file === "string") {
4875
+ const pathScore = scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions);
4876
+ if (pathScore > 0) return {
4877
+ cssSource,
4878
+ index,
4879
+ score: pathScore
4880
+ };
4881
+ }
4882
+ if (normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource) return {
4883
+ cssSource,
4884
+ index,
4885
+ score: 1
4886
+ };
4887
+ }).filter((match) => Boolean(match)).sort((a, b) => b.score - a.score || a.index - b.index);
4888
+ const bestScore = matches[0]?.score;
4889
+ const matchingSource = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssSource : void 0;
4751
4890
  if (!matchingSource) return;
4752
4891
  return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, { matched: true });
4753
4892
  }
@@ -4819,7 +4958,10 @@ function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
4819
4958
  async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
4820
4959
  if (!resolvedEntrySource) return;
4821
4960
  const resolvedSourceOptions = omitUndefined(sourceOptions);
4822
- const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, resolvedSourceOptions);
4961
+ const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
4962
+ ...resolvedSourceOptions,
4963
+ sourceFile: resolvedEntrySource.file
4964
+ });
4823
4965
  const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
4824
4966
  return withMatchedSourceSideMetadata(await resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
4825
4967
  base: resolvedEntrySource.base,
@@ -4850,7 +4992,25 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
4850
4992
  }
4851
4993
  function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
4852
4994
  if (!hasTailwindApplyDirective(css) || hasTailwindRootDirectives(css)) return css;
4853
- return `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);\n${css}`;
4995
+ const utilities = collectTailwindApplyUtilities(css);
4996
+ return [
4997
+ `@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
4998
+ utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
4999
+ css
5000
+ ].filter(Boolean).join("\n");
5001
+ }
5002
+ function collectTailwindApplyUtilities(css) {
5003
+ let root;
5004
+ try {
5005
+ root = require_watch_dependencies.postcss_default.parse(css);
5006
+ } catch {
5007
+ return [];
5008
+ }
5009
+ const utilities = /* @__PURE__ */ new Set();
5010
+ root.walkAtRules("apply", (rule) => {
5011
+ for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
5012
+ });
5013
+ return [...utilities].sort();
4854
5014
  }
4855
5015
  async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
4856
5016
  const base = resolveCssSourceBase(file, cssHandlerOptions);
@@ -4963,11 +5123,15 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
4963
5123
  return resolved ? [resolved] : [];
4964
5124
  }
4965
5125
  const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
5126
+ if (matchedCssEntrySource) return [generatorOptions?.config ? {
5127
+ ...matchedCssEntrySource,
5128
+ css: prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
5129
+ } : matchedCssEntrySource];
5130
+ const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource((shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions.cssEntries?.length ?? 0) <= 1) && canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
5131
+ if (sourceSideCssSource) return [sourceSideCssSource];
4966
5132
  const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
4967
5133
  const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
4968
- const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource((shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions.cssEntries?.length ?? 0) <= 1) && canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
4969
5134
  const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
4970
- if (sourceSideCssSource) return [sourceSideCssSource];
4971
5135
  if (preferredCssEntrySource) return [generatorOptions?.config ? {
4972
5136
  ...preferredCssEntrySource,
4973
5137
  css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
@@ -5145,6 +5309,27 @@ function resolveLegacyCompatCssSource(rawSource) {
5145
5309
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
5146
5310
  return resolved;
5147
5311
  }
5312
+ function removeMiniProgramContainerCompatCss(css) {
5313
+ try {
5314
+ const root = require_watch_dependencies.postcss_default.parse(css);
5315
+ let removed = false;
5316
+ root.walkRules((rule) => {
5317
+ if (rule.selectors?.length === 1 && rule.selectors[0] === ".container") {
5318
+ rule.remove();
5319
+ removed = true;
5320
+ }
5321
+ });
5322
+ root.walkAtRules((atRule) => {
5323
+ if (atRule.nodes && atRule.nodes.length === 0) {
5324
+ atRule.remove();
5325
+ removed = true;
5326
+ }
5327
+ });
5328
+ return removed ? root.toString() : css;
5329
+ } catch {
5330
+ return css;
5331
+ }
5332
+ }
5148
5333
  function hasContainerConfigToken(rawSource) {
5149
5334
  return rawSource.includes("@config") && /\bcontainer\b/.test(rawSource);
5150
5335
  }
@@ -5173,7 +5358,8 @@ function hasConfiguredContainerCompatSources(sources) {
5173
5358
  return sources.some((source) => hasConfiguredContainerCompatSource(source));
5174
5359
  }
5175
5360
  async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
5176
- const compatSource = removeGeneratedSelectorCompatCss(resolveLegacyCompatCssSource(rawSource), css);
5361
+ const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
5362
+ const compatSource = removeGeneratedSelectorCompatCss(generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource, css);
5177
5363
  if (compatSource.trim().length === 0) return css;
5178
5364
  if (generatorTarget !== "weapp") return createCssAppend(css, compatSource);
5179
5365
  const styleOptions = {
@@ -5191,6 +5377,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
5191
5377
  return createCssAppend(css, cleanedCompatCss);
5192
5378
  }
5193
5379
  async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
5380
+ if (generatorTarget === "weapp") return css;
5194
5381
  const compatSource = resolveLegacyCompatCssSource(rawSource);
5195
5382
  const shouldAppendContainer = runtime.has("container") || hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) || configuredContainerCompat || collectGeneratedSelectors(compatSource).has(".container");
5196
5383
  if (generatorTarget !== "weapp" || !shouldAppendContainer || collectGeneratedSelectors(css).has(".container")) return css;
@@ -5253,74 +5440,97 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
5253
5440
  }
5254
5441
  }
5255
5442
  //#endregion
5256
- //#region src/bundlers/shared/generator-css/user-layer-order.ts
5257
- const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
5258
- const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
5259
- const UTILITY_LAYER_INSERTION_RES = [
5260
- /(^|\n)\.(?:fixed|absolute|relative|sticky|static)\s*\{/,
5261
- /(^|\n)\.(?:block|inline-block|inline|flex|inline-flex|grid|hidden)\s*\{/,
5262
- /(^|\n)\.(?:m|mx|my|mt|mr|mb|ml|p|px|py|pt|pr|pb|pl)-/,
5263
- /(^|\n)\.(?:w|h|min-w|min-h|max-w|max-h)-/,
5264
- /(^|\n)\.(?:bg|text|border|rounded|shadow|opacity|transition|transform|translate|scale|rotate|gap|items|justify|content)-/
5265
- ];
5266
- function appendCss(base, extra) {
5443
+ //#region src/bundlers/shared/generator-css/local-imports.ts
5444
+ const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
5445
+ function createCssSourceOrderAppend(base, extra) {
5267
5446
  if (!base) return extra;
5268
5447
  if (!extra) return base;
5269
5448
  if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
5270
5449
  return `${base}\n${extra}`;
5271
5450
  }
5272
- function wrapUserLayerComponentsCss(css) {
5273
- return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
5451
+ function isLocalImportRequest(request) {
5452
+ return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
5274
5453
  }
5275
- function extractMarkedUserLayerComponentsCss(css) {
5276
- const layers = [];
5277
- let rest = "";
5278
- let cursor = 0;
5279
- while (cursor < css.length) {
5280
- const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
5281
- if (startIndex === -1) {
5282
- rest += css.slice(cursor);
5283
- break;
5454
+ function isPureLocalCssImportWrapper(css) {
5455
+ let hasImport = false;
5456
+ try {
5457
+ const root = require_watch_dependencies.postcss_default.parse(css);
5458
+ for (const node of root.nodes) {
5459
+ if (node.type === "comment") continue;
5460
+ if (node.type !== "atrule" || node.name !== "import") return false;
5461
+ const request = parseImportRequest(node.params);
5462
+ if (!request || !isLocalImportRequest(request)) return false;
5463
+ hasImport = true;
5284
5464
  }
5285
- rest += css.slice(cursor, startIndex);
5286
- const contentStart = startIndex + 47;
5287
- const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
5288
- if (endIndex === -1) {
5289
- rest += css.slice(startIndex);
5290
- break;
5465
+ } catch {
5466
+ return false;
5467
+ }
5468
+ return hasImport;
5469
+ }
5470
+ function cleanLocalCssImportWrapperTailwindDirectives(css) {
5471
+ let hasLocalImport = false;
5472
+ let hasTailwindDirective = false;
5473
+ try {
5474
+ const root = require_watch_dependencies.postcss_default.parse(css);
5475
+ for (const node of root.nodes) {
5476
+ if (node.type === "comment") continue;
5477
+ if (node.type === "atrule" && node.name === "import") {
5478
+ const request = parseImportRequest(node.params);
5479
+ if (!request || !isLocalImportRequest(request)) return;
5480
+ hasLocalImport = true;
5481
+ continue;
5482
+ }
5483
+ if (node.type === "atrule" && node.name === "source") {
5484
+ hasTailwindDirective = true;
5485
+ continue;
5486
+ }
5487
+ return;
5291
5488
  }
5292
- const layerCss = css.slice(contentStart, endIndex).trim();
5293
- if (layerCss) layers.push(layerCss);
5294
- cursor = endIndex + 45;
5489
+ } catch {
5490
+ return;
5491
+ }
5492
+ return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
5493
+ }
5494
+ function prefixLocalCssImportsWithWebpackIgnore(css) {
5495
+ try {
5496
+ const root = require_watch_dependencies.postcss_default.parse(css);
5497
+ root.walkAtRules("import", (atRule) => {
5498
+ const request = parseImportRequest(atRule.params);
5499
+ if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
5500
+ });
5501
+ return root.toString();
5502
+ } catch {
5503
+ return css;
5295
5504
  }
5296
- return {
5297
- layers,
5298
- rest
5299
- };
5300
5505
  }
5301
- function findUtilityLayerInsertionIndex(css) {
5302
- let index = -1;
5303
- for (const pattern of UTILITY_LAYER_INSERTION_RES) {
5304
- const match = pattern.exec(css);
5305
- if (!match) continue;
5306
- const nextIndex = match.index + (match[1]?.length ?? 0);
5307
- index = index === -1 ? nextIndex : Math.min(index, nextIndex);
5506
+ function splitLocalCssImports(source) {
5507
+ try {
5508
+ const root = require_watch_dependencies.postcss_default.parse(source);
5509
+ const importRoot = require_watch_dependencies.postcss_default.root();
5510
+ let changed = false;
5511
+ for (const node of [...root.nodes]) {
5512
+ if (node.type !== "atrule" || node.name !== "import") continue;
5513
+ const request = parseImportRequest(node.params);
5514
+ if (!request || !isLocalImportRequest(request)) continue;
5515
+ importRoot.append(node.clone());
5516
+ node.remove();
5517
+ changed = true;
5518
+ }
5519
+ const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
5520
+ return changed ? {
5521
+ imports,
5522
+ source: root.toString()
5523
+ } : void 0;
5524
+ } catch {
5525
+ return;
5308
5526
  }
5309
- return index;
5310
5527
  }
5311
- function reorderMarkedUserLayerComponentsCss(css) {
5312
- if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
5313
- const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
5314
- if (layers.length === 0) return rest;
5315
- const layerCss = layers.join("\n");
5316
- const insertionIndex = findUtilityLayerInsertionIndex(rest);
5317
- if (insertionIndex === -1) return appendCss(rest, layerCss);
5318
- return appendCss(appendCss(rest.slice(0, insertionIndex), layerCss), rest.slice(insertionIndex));
5528
+ function restoreLocalCssImports(css, imports) {
5529
+ if (!imports?.trim()) return css;
5530
+ return createCssSourceOrderAppend(imports, css);
5319
5531
  }
5320
5532
  //#endregion
5321
- //#region src/bundlers/shared/generator-css.ts
5322
- const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
5323
- const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
5533
+ //#region src/bundlers/shared/generator-css/user-css.ts
5324
5534
  const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
5325
5535
  "config",
5326
5536
  "custom-variant",
@@ -5330,30 +5540,6 @@ const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
5330
5540
  "utility",
5331
5541
  "variant"
5332
5542
  ]);
5333
- function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
5334
- if (target !== "weapp") return css;
5335
- return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
5336
- cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
5337
- isTailwindcssV4: majorVersion === 4,
5338
- preservePseudoContentInit: majorVersion === 3
5339
- });
5340
- }
5341
- function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
5342
- if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return false;
5343
- if (!options.isolateCurrentCssCandidates) return true;
5344
- return isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
5345
- }
5346
- function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
5347
- if (options.isolateCssSource && options.currentCssCandidates?.length) return new Set([...scopedRuntime, ...options.currentCssCandidates]);
5348
- if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk || options.matchedCssSourceFile || options.isolateCssSource && scopedRuntime.size === 0) return scopedRuntime;
5349
- return new Set([...scopedRuntime, ...runtime]);
5350
- }
5351
- function shouldIsolateScopedCssSource(source, sourceEntries) {
5352
- return Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile) || sourceEntries !== void 0 && sourceEntries.length > 0;
5353
- }
5354
- function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
5355
- return majorVersion === 4 && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(options.rawSource) && !hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
5356
- }
5357
5543
  function removeTailwindApplyAtRules(source) {
5358
5544
  if (!source.includes("@apply")) return source;
5359
5545
  try {
@@ -5391,34 +5577,6 @@ function removeTailwindV4GeneratorAtRules(source) {
5391
5577
  return source;
5392
5578
  }
5393
5579
  }
5394
- function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
5395
- if (majorVersion !== 4 || isolateCssSource) return false;
5396
- return target === "web" || generatorRuntime.size === 0;
5397
- }
5398
- function shouldAppendWebBundleCssFallback(target, options) {
5399
- return target === "web" && !options.hasMatchedCssSourceFile && !options.hasSourceDirectives;
5400
- }
5401
- function isEmptyCssSourceOrderParts(parts) {
5402
- return parts.before.trim().length === 0 && parts.after.trim().length === 0;
5403
- }
5404
- function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
5405
- const preflightStyleOptions = {
5406
- cssPreflight: opts.cssPreflight,
5407
- cssPreflightRange: opts.cssPreflightRange
5408
- };
5409
- return {
5410
- ...resolveStyleOptionsFromContext(opts),
5411
- atRules: opts.atRules,
5412
- uniAppXCssTarget: opts.uniAppXCssTarget,
5413
- uniAppXUnsupported: opts.uniAppXUnsupported,
5414
- ...cssHandlerOptions,
5415
- ...preflightStyleOptions,
5416
- ...generatorStyleOptions
5417
- };
5418
- }
5419
- function isLocalImportRequest(request) {
5420
- return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
5421
- }
5422
5580
  function isCommentOnlyCss(source) {
5423
5581
  try {
5424
5582
  const root = require_watch_dependencies.postcss_default.parse(source);
@@ -5453,22 +5611,6 @@ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
5453
5611
  return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
5454
5612
  }
5455
5613
  }
5456
- function createCssSourceOrderAppend(base, extra) {
5457
- if (!base) return extra;
5458
- if (!extra) return base;
5459
- if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
5460
- return `${base}\n${extra}`;
5461
- }
5462
- function shouldFinalizeMarkedUserLayerComponentsCss(file) {
5463
- return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
5464
- }
5465
- function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
5466
- const placeholderParts = splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
5467
- if (placeholderParts) return placeholderParts;
5468
- const exactParts = splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
5469
- if (exactParts) return exactParts;
5470
- return splitTailwindGeneratedCssByBanner(rawSource);
5471
- }
5472
5614
  function splitUserCssLayerBlocks(source) {
5473
5615
  if (!source.includes("@layer")) return {
5474
5616
  layer: "",
@@ -5620,84 +5762,73 @@ async function transformGeneratorUserCss(source, options) {
5620
5762
  });
5621
5763
  return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
5622
5764
  }
5623
- function isPureLocalCssImportWrapper(css) {
5624
- let hasImport = false;
5625
- try {
5626
- const root = require_watch_dependencies.postcss_default.parse(css);
5627
- for (const node of root.nodes) {
5628
- if (node.type === "comment") continue;
5629
- if (node.type !== "atrule" || node.name !== "import") return false;
5630
- const request = parseImportRequest(node.params);
5631
- if (!request || !isLocalImportRequest(request)) return false;
5632
- hasImport = true;
5633
- }
5634
- } catch {
5635
- return false;
5636
- }
5637
- return hasImport;
5765
+ //#endregion
5766
+ //#region src/bundlers/shared/generator-css/user-layer-order.ts
5767
+ const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
5768
+ const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
5769
+ const UTILITY_LAYER_INSERTION_RES = [
5770
+ /(^|\n)\.(?:fixed|absolute|relative|sticky|static)\s*\{/,
5771
+ /(^|\n)\.(?:block|inline-block|inline|flex|inline-flex|grid|hidden)\s*\{/,
5772
+ /(^|\n)\.(?:m|mx|my|mt|mr|mb|ml|p|px|py|pt|pr|pb|pl)-/,
5773
+ /(^|\n)\.(?:w|h|min-w|min-h|max-w|max-h)-/,
5774
+ /(^|\n)\.(?:bg|text|border|rounded|shadow|opacity|transition|transform|translate|scale|rotate|gap|items|justify|content)-/
5775
+ ];
5776
+ function appendCss(base, extra) {
5777
+ if (!base) return extra;
5778
+ if (!extra) return base;
5779
+ if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
5780
+ return `${base}\n${extra}`;
5638
5781
  }
5639
- function cleanLocalCssImportWrapperTailwindDirectives(css) {
5640
- let hasLocalImport = false;
5641
- let hasTailwindDirective = false;
5642
- try {
5643
- const root = require_watch_dependencies.postcss_default.parse(css);
5644
- for (const node of root.nodes) {
5645
- if (node.type === "comment") continue;
5646
- if (node.type === "atrule" && node.name === "import") {
5647
- const request = parseImportRequest(node.params);
5648
- if (!request || !isLocalImportRequest(request)) return;
5649
- hasLocalImport = true;
5650
- continue;
5651
- }
5652
- if (node.type === "atrule" && node.name === "source") {
5653
- hasTailwindDirective = true;
5654
- continue;
5655
- }
5656
- return;
5657
- }
5658
- } catch {
5659
- return;
5660
- }
5661
- return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
5782
+ function wrapUserLayerComponentsCss(css) {
5783
+ return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
5662
5784
  }
5663
- function prefixLocalCssImportsWithWebpackIgnore(css) {
5664
- try {
5665
- const root = require_watch_dependencies.postcss_default.parse(css);
5666
- root.walkAtRules("import", (atRule) => {
5667
- const request = parseImportRequest(atRule.params);
5668
- if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
5669
- });
5670
- return root.toString();
5671
- } catch {
5672
- return css;
5785
+ function extractMarkedUserLayerComponentsCss(css) {
5786
+ const layers = [];
5787
+ let rest = "";
5788
+ let cursor = 0;
5789
+ while (cursor < css.length) {
5790
+ const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
5791
+ if (startIndex === -1) {
5792
+ rest += css.slice(cursor);
5793
+ break;
5794
+ }
5795
+ rest += css.slice(cursor, startIndex);
5796
+ const contentStart = startIndex + 47;
5797
+ const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
5798
+ if (endIndex === -1) {
5799
+ rest += css.slice(startIndex);
5800
+ break;
5801
+ }
5802
+ const layerCss = css.slice(contentStart, endIndex).trim();
5803
+ if (layerCss) layers.push(layerCss);
5804
+ cursor = endIndex + 45;
5673
5805
  }
5806
+ return {
5807
+ layers,
5808
+ rest
5809
+ };
5674
5810
  }
5675
- function splitLocalCssImports(source) {
5676
- try {
5677
- const root = require_watch_dependencies.postcss_default.parse(source);
5678
- const importRoot = require_watch_dependencies.postcss_default.root();
5679
- let changed = false;
5680
- for (const node of [...root.nodes]) {
5681
- if (node.type !== "atrule" || node.name !== "import") continue;
5682
- const request = parseImportRequest(node.params);
5683
- if (!request || !isLocalImportRequest(request)) continue;
5684
- importRoot.append(node.clone());
5685
- node.remove();
5686
- changed = true;
5687
- }
5688
- const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
5689
- return changed ? {
5690
- imports,
5691
- source: root.toString()
5692
- } : void 0;
5693
- } catch {
5694
- return;
5811
+ function findUtilityLayerInsertionIndex(css) {
5812
+ let index = -1;
5813
+ for (const pattern of UTILITY_LAYER_INSERTION_RES) {
5814
+ const match = pattern.exec(css);
5815
+ if (!match) continue;
5816
+ const nextIndex = match.index + (match[1]?.length ?? 0);
5817
+ index = index === -1 ? nextIndex : Math.min(index, nextIndex);
5695
5818
  }
5819
+ return index;
5696
5820
  }
5697
- function restoreLocalCssImports(css, imports) {
5698
- if (!imports?.trim()) return css;
5699
- return createCssSourceOrderAppend(imports, css);
5821
+ function reorderMarkedUserLayerComponentsCss(css) {
5822
+ if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
5823
+ const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
5824
+ if (layers.length === 0) return rest;
5825
+ const layerCss = layers.join("\n");
5826
+ const insertionIndex = findUtilityLayerInsertionIndex(rest);
5827
+ if (insertionIndex === -1) return appendCss(rest, layerCss);
5828
+ return appendCss(appendCss(rest.slice(0, insertionIndex), layerCss), rest.slice(insertionIndex));
5700
5829
  }
5830
+ //#endregion
5831
+ //#region src/bundlers/shared/generator-css.ts
5701
5832
  async function generateCssByGenerator(options) {
5702
5833
  const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
5703
5834
  const generatorOptions = {
@@ -5720,8 +5851,13 @@ async function generateCssByGenerator(options) {
5720
5851
  const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
5721
5852
  const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
5722
5853
  const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
5723
- const shouldGenerateCurrentCss = hasGeneratedCss || hasGeneratedMarkers || hasSourceDirectives || cssHandlerOptions.isMainChunk;
5724
- if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || !shouldGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) return;
5854
+ const shouldGenerateCurrentCss = shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
5855
+ hasGeneratedCss,
5856
+ hasGeneratedMarkers,
5857
+ hasSourceDirectives,
5858
+ rawSource: generatorRawSource
5859
+ });
5860
+ if (!isSupportedGeneratorMajorVersion(majorVersion) || !shouldGenerateCurrentCss || majorVersion === 3 && !hasSourceDirectives && !hasGeneratedCss && !hasGeneratedMarkers) return;
5725
5861
  try {
5726
5862
  await runtimeState.readyPromise;
5727
5863
  const currentCssCandidates = majorVersion === 4 ? await (0, tailwindcss_patch.extractSourceCandidates)(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } }) : [];
@@ -5730,7 +5866,7 @@ async function generateCssByGenerator(options) {
5730
5866
  hasGeneratedMarkers,
5731
5867
  rawSource: generatorRawSource
5732
5868
  });
5733
- const runtimeWithCurrentCss = isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
5869
+ const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
5734
5870
  const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
5735
5871
  cssEntries: opts.cssEntries,
5736
5872
  getSourceCandidatesForEntries,
@@ -5738,12 +5874,13 @@ async function generateCssByGenerator(options) {
5738
5874
  });
5739
5875
  const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
5740
5876
  const configuredContainerCompat = hasConfiguredContainerCompatSources(sources);
5741
- const generatedResults = (await Promise.all(sources.map(async (source) => {
5877
+ const generated = mergeGeneratorResults((await Promise.all(sources.map(async (source) => {
5742
5878
  const generator = createWeappTailwindcssGenerator(source);
5743
5879
  const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
5744
5880
  const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
5745
5881
  const isolateCssSource = shouldIsolateScopedCssSource(source, sourceEntries);
5746
- const matchedCssSourceFile = Boolean(source.__weappTailwindcssMeta?.matchedCssSourceFile);
5882
+ const sourceMetadata = source.__weappTailwindcssMeta;
5883
+ const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
5747
5884
  if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
5748
5885
  debug("defer empty scoped css source generation: %s", file);
5749
5886
  return;
@@ -5765,21 +5902,8 @@ async function generateCssByGenerator(options) {
5765
5902
  tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
5766
5903
  target: generatorOptions.target
5767
5904
  });
5768
- }))).filter((item) => Boolean(item));
5769
- const firstGenerated = generatedResults[0];
5770
- if (!firstGenerated) return;
5771
- const incrementalCssResults = generatedResults.map((item) => item.incrementalCss).filter((css) => typeof css === "string");
5772
- const incrementalRawCssResults = generatedResults.map((item) => item.incrementalRawCss).filter((css) => typeof css === "string");
5773
- const generated = generatedResults.length === 1 ? firstGenerated : {
5774
- ...firstGenerated,
5775
- css: generatedResults.map((item) => item.css).join("\n"),
5776
- rawCss: generatedResults.map((item) => item.rawCss).join("\n"),
5777
- incrementalCss: incrementalCssResults.length === generatedResults.length ? incrementalCssResults.filter(Boolean).join("\n") : void 0,
5778
- incrementalRawCss: incrementalRawCssResults.length === generatedResults.length ? incrementalRawCssResults.filter(Boolean).join("\n") : void 0,
5779
- classSet: new Set(generatedResults.flatMap((item) => [...item.classSet])),
5780
- dependencies: [...new Set(generatedResults.flatMap((item) => item.dependencies))],
5781
- sources: generatedResults.flatMap((item) => item.sources)
5782
- };
5905
+ }))).filter((item) => Boolean(item)));
5906
+ if (!generated) return;
5783
5907
  debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
5784
5908
  if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
5785
5909
  const incrementalCss = stripTailwindBanner(generated.incrementalCss);
@@ -5816,13 +5940,13 @@ async function generateCssByGenerator(options) {
5816
5940
  const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
5817
5941
  const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
5818
5942
  const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
5819
- css = createCssSourceOrderAppend(createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
5943
+ css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(afterLayerUserCss) : afterLayerUserCss), css), afterUserCss);
5820
5944
  if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
5821
5945
  hasSourceDirectives,
5822
5946
  hasMatchedCssSourceFile
5823
5947
  })) {
5824
5948
  const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
5825
- css = createCssSourceOrderAppend(css, userCss);
5949
+ css = createCssSourceOrderAppend$1(css, userCss);
5826
5950
  }
5827
5951
  if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
5828
5952
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
@@ -5860,7 +5984,7 @@ async function generateCssByGenerator(options) {
5860
5984
  rest: css
5861
5985
  } : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
5862
5986
  if (layerCss.layer.trim().length > 0) {
5863
- css = createCssSourceOrderAppend(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
5987
+ css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
5864
5988
  if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
5865
5989
  }
5866
5990
  }
@@ -5874,7 +5998,7 @@ async function generateCssByGenerator(options) {
5874
5998
  styleHandler,
5875
5999
  importFallback: generatorOptions.importFallback
5876
6000
  });
5877
- css = createCssSourceOrderAppend(css, userCss);
6001
+ css = createCssSourceOrderAppend$1(css, userCss);
5878
6002
  }
5879
6003
  if (hasMatchedCssSourceFile && generated.target === "weapp") {
5880
6004
  if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
@@ -5890,7 +6014,7 @@ async function generateCssByGenerator(options) {
5890
6014
  styleHandler,
5891
6015
  importFallback: generatorOptions.importFallback
5892
6016
  });
5893
- css = createCssSourceOrderAppend(css, userCss);
6017
+ css = createCssSourceOrderAppend$1(css, userCss);
5894
6018
  }
5895
6019
  return {
5896
6020
  css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {