weapp-tailwindcss 5.0.0-next.20 → 5.0.0-next.21

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 (52) hide show
  1. package/dist/{bundle-state-BlXvU4jl.js → bundle-state-BnV8o2Yn.js} +1 -1
  2. package/dist/{bundle-state-PO6MysTJ.mjs → bundle-state-CLnuf2CW.mjs} +1 -1
  3. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
  4. package/dist/bundlers/shared/css-cleanup.d.ts +1 -8
  5. package/dist/core.js +1 -1
  6. package/dist/core.mjs +1 -1
  7. package/dist/{generator-N4jy1HCk.js → generator-B4RNgMLx.js} +1 -1
  8. package/dist/{generator-DIuglJub.mjs → generator-DvyhmC76.mjs} +1 -1
  9. package/dist/generator.js +2 -2
  10. package/dist/generator.mjs +2 -2
  11. package/dist/gulp.js +5 -5
  12. package/dist/gulp.mjs +5 -5
  13. package/dist/{incremental-runtime-class-set-hF-uiw6W.mjs → incremental-runtime-class-set-C7Q7fC5u.mjs} +5 -427
  14. package/dist/{incremental-runtime-class-set-CJ0Pnsw2.js → incremental-runtime-class-set-DZsbM0-a.js} +11 -433
  15. package/dist/index.js +4 -4
  16. package/dist/index.mjs +4 -4
  17. package/dist/{postcss-DlY-YRvA.js → postcss-CFa6-qO9.js} +2 -2
  18. package/dist/{postcss-D4UdbBQ6.mjs → postcss-Drpy7j-g.mjs} +2 -2
  19. package/dist/postcss.js +1 -1
  20. package/dist/postcss.mjs +1 -1
  21. package/dist/{precheck-BjEbVEpX.js → precheck-8pQbjqpq.js} +2 -2
  22. package/dist/{precheck-tbk626YL.mjs → precheck-D1O5AWzy.mjs} +2 -2
  23. package/dist/presets.js +2 -2
  24. package/dist/presets.mjs +2 -2
  25. package/dist/{runtime-registry-D5qnaSpo.js → runtime-registry-CdCV3Opt.js} +0 -20
  26. package/dist/{source-candidates-gxijpPI3.js → source-candidates-CUTNdsiz.js} +1 -1
  27. package/dist/{source-candidates-BrvneDDd.mjs → source-candidates-CnD4vyic.mjs} +1 -1
  28. package/dist/tailwindcss/miniprogram.d.ts +1 -5
  29. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  30. package/dist/{tailwindcss-c6ROlNNW.mjs → tailwindcss-B_JAdOQf.mjs} +1 -1
  31. package/dist/{tailwindcss-BhG7BtB-.js → tailwindcss-whZE3HpL.js} +1 -1
  32. package/dist/{v3-engine-5LoZUH-4.js → v3-engine-CCwvhRrQ.js} +2 -224
  33. package/dist/{v3-engine-DIXDEDmL.mjs → v3-engine-DyIcbpZm.mjs} +2 -218
  34. package/dist/{vite-B5faZcbE.mjs → vite-B8IiXgVD.mjs} +7 -7
  35. package/dist/{vite-MyXBNux0.js → vite-BcnwgJMt.js} +7 -7
  36. package/dist/vite.js +1 -1
  37. package/dist/vite.mjs +1 -1
  38. package/dist/weapp-tw-css-import-rewrite-loader.js +13 -637
  39. package/dist/weapp-tw-runtime-classset-loader.js +3 -2
  40. package/dist/{webpack-Mz1V0A9p.js → webpack-C4zI624R.js} +5 -5
  41. package/dist/{webpack-BnVyDmsD.mjs → webpack-DTkshAtp.mjs} +5 -5
  42. package/dist/webpack.js +1 -1
  43. package/dist/webpack.mjs +1 -1
  44. package/package.json +2 -2
  45. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
  46. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -5
  47. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
  48. package/dist/lightningcss/index.d.ts +0 -8
  49. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  50. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  51. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  52. package/dist/lightningcss/style-handler.d.ts +0 -17
@@ -2,12 +2,13 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_runtime_registry = require("./runtime-registry-D5qnaSpo.js");
5
+ const require_runtime_registry = require("./runtime-registry-CdCV3Opt.js");
6
6
  let node_buffer = require("node:buffer");
7
7
  let node_process = require("node:process");
8
8
  node_process = require_runtime_registry.__toESM(node_process);
9
9
  let loader_utils = require("loader-utils");
10
10
  loader_utils = require_runtime_registry.__toESM(loader_utils);
11
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
11
12
  let node_path = require("node:path");
12
13
  node_path = require_runtime_registry.__toESM(node_path);
13
14
  let node_util = require("node:util");
@@ -24,7 +25,6 @@ let node_fs_promises = require("node:fs/promises");
24
25
  require("fast-glob");
25
26
  let tailwindcss_config = require("tailwindcss-config");
26
27
  require("micromatch");
27
- let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
28
28
  let _weapp_core_escape = require("@weapp-core/escape");
29
29
  require("magic-string");
30
30
  let _babel_traverse = require("@babel/traverse");
@@ -612,208 +612,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
612
612
  return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
613
613
  }
614
614
  //#endregion
615
- //#region src/tailwindcss/miniprogram.ts
616
- const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
617
- const DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE = "view,text,:before,:after";
618
- const CLASS_SELECTOR_RE$1 = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
619
- const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
620
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS$2 = new Set([
621
- ":root",
622
- ":host",
623
- "page",
624
- ".tw-root",
625
- "wx-root-portal-content"
626
- ]);
627
- const MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS = new Set([
628
- "view",
629
- "text",
630
- ":before",
631
- ":after",
632
- "::before",
633
- "::after"
634
- ]);
635
- const MINI_PROGRAM_PREFLIGHT_SELECTORS$1 = new Set([
636
- "*",
637
- "view",
638
- "text",
639
- ":before",
640
- ":after",
641
- "::before",
642
- "::after"
643
- ]);
644
- const PREFLIGHT_RESET_PROPS$1 = new Set([
645
- "box-sizing",
646
- "border",
647
- "border-width",
648
- "border-style",
649
- "border-color",
650
- "margin",
651
- "padding"
652
- ]);
653
- const CONTENT_VAR_RE$1 = /var\(\s*--tw-content\b/;
654
- function hasClassSelector$1(selector) {
655
- return CLASS_SELECTOR_RE$1.test(selector);
656
- }
657
- function normalizeSelector$2(selector) {
658
- return selector.trim().replace(/\s+/g, "");
659
- }
660
- function getRuleSelectors$1(rule) {
661
- return rule.selector.split(",").map(normalizeSelector$2).filter(Boolean);
662
- }
663
- function isCustomPropertyRule(rule) {
664
- let hasDeclaration = false;
665
- let allCustomProperties = true;
666
- rule.walkDecls((decl) => {
667
- hasDeclaration = true;
668
- if (!decl.prop.startsWith("--")) allCustomProperties = false;
669
- });
670
- return hasDeclaration && allCustomProperties;
671
- }
672
- function isEmptyContentInitDeclaration$1(decl) {
673
- return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
674
- }
675
- function removeEmptyContentInitDeclarations(rule) {
676
- rule.walkDecls((decl) => {
677
- if (isEmptyContentInitDeclaration$1(decl)) decl.remove();
678
- });
679
- }
680
- function usesTwContentVariable$1(root) {
681
- let used = false;
682
- root.walkDecls((decl) => {
683
- if (CONTENT_VAR_RE$1.test(decl.value)) used = true;
684
- });
685
- return used;
686
- }
687
- function isPseudoContentInitRule$1(rule) {
688
- const selector = rule.selector.replace(/\s+/g, "");
689
- if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
690
- let hasDeclaration = false;
691
- let onlyContentVariable = true;
692
- rule.walkDecls((decl) => {
693
- hasDeclaration = true;
694
- if (decl.prop !== "--tw-content") onlyContentVariable = false;
695
- });
696
- return hasDeclaration && onlyContentVariable;
697
- }
698
- function isMiniProgramPreflightRule(rule) {
699
- const selectors = getRuleSelectors$1(rule);
700
- if (selectors.length === 0 || !selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS$1.has(selector)) || !selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after")) return false;
701
- let hasTailwindVariable = false;
702
- let hasResetProp = false;
703
- rule.walkDecls((decl) => {
704
- if (decl.prop.startsWith("--tw-")) hasTailwindVariable = true;
705
- if (PREFLIGHT_RESET_PROPS$1.has(decl.prop)) hasResetProp = true;
706
- });
707
- return hasTailwindVariable || hasResetProp;
708
- }
709
- function isMiniProgramThemeScopeRule(rule) {
710
- const selectors = getRuleSelectors$1(rule);
711
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS$2.has(selector));
712
- }
713
- function isMiniProgramElementVariableScopeRule(rule) {
714
- const selectors = getRuleSelectors$1(rule);
715
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS.has(selector));
716
- }
717
- function isTailwindV4GradientRuntimeDeclaration(decl) {
718
- return decl.prop.startsWith("--tw-gradient-");
719
- }
720
- function moveTailwindV4GradientRuntimeDeclarations(rule) {
721
- const gradientDeclarations = [];
722
- rule.walkDecls((decl) => {
723
- if (isTailwindV4GradientRuntimeDeclaration(decl)) {
724
- gradientDeclarations.push(decl.clone());
725
- decl.remove();
726
- }
727
- });
728
- if (gradientDeclarations.length > 0) rule.before(new require_runtime_registry.postcss_default.Rule({
729
- selector: DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE,
730
- nodes: gradientDeclarations
731
- }));
732
- if (rule.nodes.length === 0) rule.remove();
733
- }
734
- function isKeyframesRule(rule) {
735
- let parent = rule.parent;
736
- while (parent) {
737
- if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
738
- parent = parent.parent;
739
- }
740
- return false;
741
- }
742
- function removeDeclarationAndEmptyRule$1(decl) {
743
- const parent = decl.parent;
744
- decl.remove();
745
- if (parent?.type === "rule" && parent.nodes.length === 0) parent.remove();
746
- }
747
- function normalizeMiniProgramColorValues(root) {
748
- const customPropertyValues = /* @__PURE__ */ new Map();
749
- root.walkDecls((decl) => {
750
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
751
- });
752
- root.walkDecls((decl) => {
753
- const normalized = (0, _weapp_tailwindcss_postcss.normalizeModernColorValue)(decl.value, customPropertyValues);
754
- if (normalized.changed) {
755
- decl.value = normalized.value;
756
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
757
- }
758
- if (normalized.hasUnsupported) removeDeclarationAndEmptyRule$1(decl);
759
- });
760
- }
761
- /**
762
- * 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
763
- *
764
- * 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
765
- * 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
766
- */
767
- function pruneMiniProgramGeneratedCss(css, options = {}) {
768
- const root = require_runtime_registry.postcss_default.parse(css);
769
- const shouldPreserveContentInit = options.preservePreflight || usesTwContentVariable$1(root);
770
- root.walkComments((comment) => {
771
- comment.remove();
772
- });
773
- require_runtime_registry.removeUnsupportedCascadeLayers(root);
774
- normalizeMiniProgramColorValues(root);
775
- root.walkAtRules("supports", (atRule) => {
776
- atRule.remove();
777
- });
778
- root.walkAtRules((atRule) => {
779
- (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramPrefixedAtRule)(atRule);
780
- });
781
- root.walkDecls((decl) => {
782
- (0, _weapp_tailwindcss_postcss.normalizeMiniProgramPrefixedDeclaration)(decl);
783
- });
784
- root.walkRules((rule) => {
785
- if (isKeyframesRule(rule)) return;
786
- if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
787
- rule.selector = DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE;
788
- return;
789
- }
790
- if (isCustomPropertyRule(rule) && isMiniProgramThemeScopeRule(rule)) {
791
- moveTailwindV4GradientRuntimeDeclarations(rule);
792
- if (!rule.parent) return;
793
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
794
- return;
795
- }
796
- if (hasClassSelector$1(rule.selector)) return;
797
- if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
798
- if (isPseudoContentInitRule$1(rule)) {
799
- if (!shouldPreserveContentInit) rule.remove();
800
- return;
801
- }
802
- if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
803
- if (isCustomPropertyRule(rule)) {
804
- moveTailwindV4GradientRuntimeDeclarations(rule);
805
- if (!rule.parent) return;
806
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
807
- return;
808
- }
809
- rule.remove();
810
- });
811
- root.walkAtRules((atRule) => {
812
- if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
813
- });
814
- return root.toString();
815
- }
816
- //#endregion
817
615
  //#region src/tailwindcss/v4-engine/miniprogram.ts
818
616
  const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
819
617
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -840,7 +638,7 @@ async function transformTailwindV4CssToWeapp(css, options) {
840
638
  majorVersion: 4,
841
639
  ...options
842
640
  });
843
- return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css));
641
+ return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css));
844
642
  }
845
643
  async function transformTailwindV4CssByTarget(css, target, options) {
846
644
  return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
@@ -2411,11 +2209,11 @@ const V3_PREFLIGHT_RESET_PROPS = new Set([
2411
2209
  "margin",
2412
2210
  "padding"
2413
2211
  ]);
2414
- function normalizeSelector$1(selector) {
2212
+ function normalizeSelector(selector) {
2415
2213
  return selector.trim().replace(/\s+/g, "");
2416
2214
  }
2417
2215
  function isMiniProgramV3PreflightRule(rule) {
2418
- return MINI_PROGRAM_V3_PREFLIGHT_SELECTORS.has(normalizeSelector$1(rule.selector));
2216
+ return MINI_PROGRAM_V3_PREFLIGHT_SELECTORS.has(normalizeSelector(rule.selector));
2419
2217
  }
2420
2218
  function hasResetDeclaration(rule) {
2421
2219
  let found = false;
@@ -2451,7 +2249,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2451
2249
  }
2452
2250
  }
2453
2251
  async function transformTailwindV3CssToWeapp(css, options) {
2454
- return ensureMiniProgramV3PreflightReset(pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
2252
+ return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)((await defaultStyleHandler(css, {
2455
2253
  cssChildCombinatorReplaceValue: ["view", "text"],
2456
2254
  cssRemoveHoverPseudoClass: true,
2457
2255
  isMainChunk: true,
@@ -2992,428 +2790,6 @@ function resolveUniAppXOptions(option) {
2992
2790
  };
2993
2791
  }
2994
2792
  //#endregion
2995
- //#region src/bundlers/shared/css-cleanup/at-rules.ts
2996
- const MINI_PROGRAM_UNSUPPORTED_AT_RULES = new Set(["property", "supports"]);
2997
- function removeAtRulesByScan(css, names) {
2998
- let index = 0;
2999
- let result = "";
3000
- const atRulePattern = new RegExp(`@(?:${[...names].join("|")})\\b`, "i");
3001
- while (index < css.length) {
3002
- const match = atRulePattern.exec(css.slice(index));
3003
- if (!match || match.index === void 0) {
3004
- result += css.slice(index);
3005
- break;
3006
- }
3007
- const start = index + match.index;
3008
- result += css.slice(index, start);
3009
- const blockStart = css.indexOf("{", start);
3010
- if (blockStart === -1) {
3011
- result += css.slice(start);
3012
- break;
3013
- }
3014
- let depth = 0;
3015
- let cursor = blockStart;
3016
- for (; cursor < css.length; cursor++) {
3017
- const char = css[cursor];
3018
- if (char === "{") depth++;
3019
- else if (char === "}") {
3020
- depth--;
3021
- if (depth === 0) {
3022
- cursor++;
3023
- break;
3024
- }
3025
- }
3026
- }
3027
- index = cursor;
3028
- }
3029
- return result;
3030
- }
3031
- function removeUnsupportedMiniProgramAtRules(css) {
3032
- try {
3033
- const root = require_runtime_registry.postcss_default.parse(css);
3034
- root.walkAtRules((atRule) => {
3035
- if (MINI_PROGRAM_UNSUPPORTED_AT_RULES.has(atRule.name)) atRule.remove();
3036
- });
3037
- root.walkAtRules((atRule) => {
3038
- if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
3039
- });
3040
- return root.toString();
3041
- } catch {
3042
- return removeAtRulesByScan(css, MINI_PROGRAM_UNSUPPORTED_AT_RULES);
3043
- }
3044
- }
3045
- //#endregion
3046
- //#region src/bundlers/shared/css-cleanup/color-gamut.ts
3047
- const DISPLAY_P3_VALUE_RE = /color\(\s*display-p3\b/i;
3048
- const COLOR_GAMUT_P3_RE = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
3049
- function isDisplayP3MediaRule(atRule) {
3050
- return atRule.name === "media" && COLOR_GAMUT_P3_RE.test(atRule.params);
3051
- }
3052
- function isDisplayP3Declaration(decl) {
3053
- return DISPLAY_P3_VALUE_RE.test(decl.value);
3054
- }
3055
- //#endregion
3056
- //#region src/bundlers/shared/css-cleanup/selectors.ts
3057
- const MINI_PROGRAM_THEME_SCOPE_SELECTOR = ":host,page,.tw-root,wx-root-portal-content";
3058
- const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
3059
- "*",
3060
- "view",
3061
- "text",
3062
- ":before",
3063
- ":after",
3064
- "::before",
3065
- "::after"
3066
- ]);
3067
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS$1 = new Set([
3068
- ":host",
3069
- ":root",
3070
- "page",
3071
- ".tw-root",
3072
- "wx-root-portal-content"
3073
- ]);
3074
- const SPECIFICITY_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
3075
- const MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS = new Set([
3076
- ":-moz-focusring",
3077
- ":-moz-ui-invalid",
3078
- "::-webkit-calendar-picker-indicator",
3079
- "::-webkit-date-and-time-value",
3080
- "::-webkit-datetime-edit",
3081
- "::-webkit-datetime-edit-day-field",
3082
- "::-webkit-datetime-edit-fields-wrapper",
3083
- "::-webkit-datetime-edit-hour-field",
3084
- "::-webkit-datetime-edit-meridiem-field",
3085
- "::-webkit-datetime-edit-millisecond-field",
3086
- "::-webkit-datetime-edit-minute-field",
3087
- "::-webkit-datetime-edit-month-field",
3088
- "::-webkit-datetime-edit-second-field",
3089
- "::-webkit-datetime-edit-year-field",
3090
- "::-webkit-inner-spin-button",
3091
- "::-webkit-input-placeholder",
3092
- "::-webkit-outer-spin-button",
3093
- "::-webkit-search-decoration",
3094
- "::placeholder",
3095
- "[hidden]:where(:not([hidden='until-found']))"
3096
- ]);
3097
- const MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS = new Set([
3098
- "a",
3099
- "abbr:where([title])",
3100
- "audio",
3101
- "b",
3102
- "button",
3103
- "canvas",
3104
- "code",
3105
- "embed",
3106
- "h1",
3107
- "h2",
3108
- "h3",
3109
- "h4",
3110
- "h5",
3111
- "h6",
3112
- "hr",
3113
- "html",
3114
- "iframe",
3115
- "img",
3116
- "input",
3117
- "input:where([type='button'],[type='reset'],[type='submit'])",
3118
- "kbd",
3119
- "menu",
3120
- "object",
3121
- "ol",
3122
- "optgroup",
3123
- "pre",
3124
- "progress",
3125
- "samp",
3126
- "select",
3127
- "select[multiple]optgroup",
3128
- "select[multiple]optgroupoption",
3129
- "select[size]optgroup",
3130
- "select[size]optgroupoption",
3131
- "small",
3132
- "strong",
3133
- "sub",
3134
- "summary",
3135
- "sup",
3136
- "svg",
3137
- "table",
3138
- "textarea",
3139
- "ul",
3140
- "video"
3141
- ]);
3142
- function normalizeSelector(selector) {
3143
- return selector.trim().replace(/\s+/g, "");
3144
- }
3145
- function getRuleSelectors(rule) {
3146
- return rule.selector.split(",").map(normalizeSelector).filter(Boolean);
3147
- }
3148
- function isUnsupportedBrowserSelector(selector) {
3149
- const normalized = normalizeSelector(selector);
3150
- return MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS.has(normalized) || MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS.has(normalized);
3151
- }
3152
- //#endregion
3153
- //#region src/bundlers/shared/css-cleanup/root-cleanups.ts
3154
- function removeSpecificityPlaceholders(root) {
3155
- root.walkRules((rule) => {
3156
- if (!rule.selectors || rule.selectors.length === 0) return;
3157
- let changed = false;
3158
- const selectors = rule.selectors.map((selector) => {
3159
- let next = selector;
3160
- for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (next.includes(suffix)) next = next.split(suffix).join("");
3161
- if (next !== selector) changed = true;
3162
- return next;
3163
- });
3164
- if (changed) rule.selectors = selectors;
3165
- });
3166
- }
3167
- function removeEmptyAtRuleAncestors(parent) {
3168
- while (parent?.type === "atrule" && (!parent.nodes || parent.nodes.length === 0)) {
3169
- const nextParent = parent.parent;
3170
- parent.remove();
3171
- parent = nextParent?.type === "atrule" ? nextParent : void 0;
3172
- }
3173
- }
3174
- function removeUnsupportedBrowserSelectors(root) {
3175
- root.walkRules((rule) => {
3176
- if (!rule.selectors || rule.selectors.length === 0) return;
3177
- const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
3178
- if (selectors.length === rule.selectors.length) return;
3179
- if (selectors.length === 0) {
3180
- const parent = rule.parent;
3181
- rule.remove();
3182
- removeEmptyAtRuleAncestors(parent);
3183
- return;
3184
- }
3185
- rule.selectors = selectors;
3186
- });
3187
- }
3188
- function removeDeclarationAndEmptyRule(decl) {
3189
- const parent = decl.parent;
3190
- decl.remove();
3191
- if (parent?.type === "rule" && parent.nodes.length === 0) {
3192
- const ruleParent = parent.parent;
3193
- parent.remove();
3194
- removeEmptyAtRuleAncestors(ruleParent);
3195
- }
3196
- }
3197
- function removeDisplayP3Declarations(root) {
3198
- root.walkAtRules((atRule) => {
3199
- if (isDisplayP3MediaRule(atRule)) {
3200
- const parent = atRule.parent;
3201
- atRule.remove();
3202
- removeEmptyAtRuleAncestors(parent);
3203
- }
3204
- });
3205
- }
3206
- function removeUnsupportedModernColorDeclarations(root) {
3207
- const customPropertyValues = /* @__PURE__ */ new Map();
3208
- root.walkDecls((decl) => {
3209
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
3210
- });
3211
- root.walkDecls((decl) => {
3212
- const normalized = (0, _weapp_tailwindcss_postcss.normalizeModernColorValue)(decl.value, customPropertyValues);
3213
- if (normalized.changed) {
3214
- decl.value = normalized.value;
3215
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
3216
- }
3217
- if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
3218
- });
3219
- }
3220
- //#endregion
3221
- //#region src/bundlers/shared/css-cleanup.ts
3222
- const PREFLIGHT_RESET_PROPS = new Set([
3223
- "box-sizing",
3224
- "border",
3225
- "border-width",
3226
- "border-style",
3227
- "border-color",
3228
- "margin",
3229
- "padding"
3230
- ]);
3231
- const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
3232
- const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
3233
- function isMiniProgramThemeScopeSelector$1(selectors) {
3234
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS$1.has(selector));
3235
- }
3236
- function isMiniProgramPreflightSelector(selectors) {
3237
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) && selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after");
3238
- }
3239
- function hasTailwindPreflightDeclaration(rule) {
3240
- let hasTailwindVar = false;
3241
- let hasResetProp = false;
3242
- rule.walkDecls((decl) => {
3243
- if (decl.prop.startsWith("--tw-")) hasTailwindVar = true;
3244
- if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
3245
- });
3246
- return hasTailwindVar || hasResetProp;
3247
- }
3248
- function isCustomPropertyOnlyRule$1(rule) {
3249
- let hasDeclaration = false;
3250
- let allCustomProperties = true;
3251
- rule.each((node) => {
3252
- if (node.type !== "decl") return;
3253
- hasDeclaration = true;
3254
- if (!node.prop.startsWith("--")) allCustomProperties = false;
3255
- });
3256
- return hasDeclaration && allCustomProperties;
3257
- }
3258
- function hasContentInitDeclaration(rule) {
3259
- let hasContentInit = false;
3260
- rule.walkDecls("--tw-content", () => {
3261
- hasContentInit = true;
3262
- });
3263
- return hasContentInit;
3264
- }
3265
- function isEmptyContentInitDeclaration(decl) {
3266
- return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
3267
- }
3268
- function usesTwContentVariable(root) {
3269
- let used = false;
3270
- root.walkDecls((decl) => {
3271
- if (CONTENT_VAR_RE.test(decl.value)) used = true;
3272
- });
3273
- return used;
3274
- }
3275
- function isTailwindPreflightRule(node) {
3276
- if (node.type !== "rule" || node.parent?.type !== "root") return false;
3277
- const rule = node;
3278
- return isMiniProgramPreflightSelector(getRuleSelectors(rule)) && hasTailwindPreflightDeclaration(rule);
3279
- }
3280
- function isMiniProgramThemeVariableRule(node) {
3281
- if (node.type !== "rule" || node.parent?.type !== "root") return false;
3282
- const rule = node;
3283
- return isMiniProgramThemeScopeSelector$1(getRuleSelectors(rule)) && isCustomPropertyOnlyRule$1(rule);
3284
- }
3285
- function createPseudoContentInitRule() {
3286
- const rule = require_runtime_registry.postcss_default.rule({ selector: "::before,\n::after" });
3287
- rule.append({
3288
- prop: "--tw-content",
3289
- value: "''"
3290
- });
3291
- return rule;
3292
- }
3293
- function collectPreflightRules(root, options = {}) {
3294
- const preflightNodes = [];
3295
- let hasContentInit = false;
3296
- for (const node of root.nodes ?? []) if (isTailwindPreflightRule(node)) {
3297
- preflightNodes.push(node);
3298
- if (hasContentInitDeclaration(node)) hasContentInit = true;
3299
- }
3300
- if (preflightNodes.length === 0) return [];
3301
- const clonedPreflightRules = preflightNodes.map((node) => node.clone());
3302
- const contentInitRules = options.preservePseudoContentInit ? clonedPreflightRules.filter((rule) => hasContentInitDeclaration(rule)) : [];
3303
- const otherPreflightRules = clonedPreflightRules.filter((rule) => !hasContentInitDeclaration(rule));
3304
- const preflightRules = hasContentInit ? [...contentInitRules, ...otherPreflightRules] : [...options.preservePseudoContentInit ? [createPseudoContentInitRule()] : [], ...otherPreflightRules];
3305
- for (const node of preflightNodes) node.remove();
3306
- return preflightRules;
3307
- }
3308
- function createPreflightResetRule(cssPreflight) {
3309
- if (!cssPreflight || typeof cssPreflight !== "object") return;
3310
- const rule = require_runtime_registry.postcss_default.rule({ selector: "view,text,:after,:before" });
3311
- for (const [prop, value] of Object.entries(cssPreflight)) {
3312
- if (value === false) continue;
3313
- rule.append({
3314
- prop,
3315
- value: value.toString()
3316
- });
3317
- }
3318
- return rule.nodes?.length ? rule : void 0;
3319
- }
3320
- function collectThemeVariableRule(root, options = {}) {
3321
- const themeRules = [];
3322
- const declarations = /* @__PURE__ */ new Map();
3323
- const shouldPreserveContentInit = options.preservePseudoContentInit || usesTwContentVariable(root);
3324
- for (const node of root.nodes ?? []) {
3325
- if (!isMiniProgramThemeVariableRule(node)) continue;
3326
- themeRules.push(node);
3327
- node.walkDecls((decl) => {
3328
- if (isDisplayP3Declaration(decl)) return;
3329
- if (!shouldPreserveContentInit && isEmptyContentInitDeclaration(decl)) return;
3330
- declarations.set(decl.prop, decl.clone());
3331
- });
3332
- }
3333
- for (const rule of themeRules) rule.remove();
3334
- if (declarations.size === 0) return;
3335
- const rule = require_runtime_registry.postcss_default.rule({ selector: MINI_PROGRAM_THEME_SCOPE_SELECTOR });
3336
- for (const decl of declarations.values()) rule.append(decl);
3337
- return rule;
3338
- }
3339
- function getTopDirectiveTail(root) {
3340
- let tail;
3341
- for (const node of root.nodes ?? []) {
3342
- if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
3343
- tail = node;
3344
- continue;
3345
- }
3346
- break;
3347
- }
3348
- return tail;
3349
- }
3350
- function createHoistInsertionAnchor(root) {
3351
- for (const node of root.nodes ?? []) if (isTailwindPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
3352
- const anchor = require_runtime_registry.postcss_default.comment({ text: HOIST_ANCHOR_COMMENT });
3353
- node.before(anchor);
3354
- return anchor;
3355
- }
3356
- }
3357
- function insertHoistedRules(root, rules, anchor) {
3358
- if (anchor && !anchor.parent) anchor = void 0;
3359
- if (rules.length === 0) {
3360
- anchor?.remove();
3361
- return;
3362
- }
3363
- const topDirectiveTail = getTopDirectiveTail(root);
3364
- const firstRule = rules[0];
3365
- if (!firstRule) return;
3366
- if (anchor) {
3367
- if (anchor.raws.before === void 0) delete firstRule.raws.before;
3368
- else firstRule.raws.before = anchor.raws.before;
3369
- anchor.replaceWith(rules);
3370
- return;
3371
- }
3372
- firstRule.raws.before = topDirectiveTail ? "\n" : "";
3373
- if (topDirectiveTail) topDirectiveTail.after(rules);
3374
- else root.prepend(rules);
3375
- }
3376
- function finalizeMiniProgramCssRoot(root, options = {}) {
3377
- require_runtime_registry.removeUnsupportedCascadeLayers(root);
3378
- unwrapTailwindSourceMedia(root);
3379
- root.walkAtRules("property", (atRule) => {
3380
- atRule.remove();
3381
- });
3382
- removeSpecificityPlaceholders(root);
3383
- removeUnsupportedBrowserSelectors(root);
3384
- removeDisplayP3Declarations(root);
3385
- removeUnsupportedModernColorDeclarations(root);
3386
- root.walkDecls((decl) => {
3387
- (0, _weapp_tailwindcss_postcss.normalizeMiniProgramPrefixedDeclaration)(decl);
3388
- });
3389
- root.walkAtRules((atRule) => {
3390
- (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramPrefixedAtRule)(atRule);
3391
- });
3392
- const hoistAnchor = createHoistInsertionAnchor(root);
3393
- const preflightRules = collectPreflightRules(root, options);
3394
- if (preflightRules.length === 0) {
3395
- const resetRule = createPreflightResetRule(options.cssPreflight);
3396
- if (resetRule) preflightRules.push(resetRule);
3397
- }
3398
- const themeRule = collectThemeVariableRule(root, options);
3399
- insertHoistedRules(root, themeRule ? [...preflightRules, themeRule] : preflightRules, hoistAnchor);
3400
- }
3401
- function unwrapTailwindSourceMedia(root) {
3402
- root.walkAtRules("media", (atRule) => {
3403
- if (atRule.params.startsWith("source(") && atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
3404
- });
3405
- }
3406
- function finalizeMiniProgramCss(css, options = {}) {
3407
- const cleanedCss = removeUnsupportedMiniProgramAtRules(css);
3408
- try {
3409
- const root = require_runtime_registry.postcss_default.parse(cleanedCss);
3410
- finalizeMiniProgramCssRoot(root, options);
3411
- return root.toString();
3412
- } catch {
3413
- return cleanedCss;
3414
- }
3415
- }
3416
- //#endregion
3417
2793
  //#region src/bundlers/shared/generator-css/markers.ts
3418
2794
  const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
3419
2795
  const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
@@ -4723,7 +4099,7 @@ function removeTailwindApplyRules(rawSource) {
4723
4099
  function resolveLegacyCompatCssSource(rawSource) {
4724
4100
  const cached = legacyCompatSourceCache.get(rawSource);
4725
4101
  if (cached !== void 0) return cached;
4726
- const resolved = closeTrailingUnclosedBlocks(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
4102
+ const resolved = closeTrailingUnclosedBlocks((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
4727
4103
  setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
4728
4104
  return resolved;
4729
4105
  }
@@ -4768,7 +4144,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
4768
4144
  compatCss = (await styleHandler(compatSource, styleOptions)).css;
4769
4145
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
4770
4146
  }
4771
- const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css), css);
4147
+ const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css), css);
4772
4148
  if (cleanedCompatCss.trim().length === 0) return css;
4773
4149
  return createCssAppend(css, cleanedCompatCss);
4774
4150
  }
@@ -4786,7 +4162,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
4786
4162
  compatCss = (await styleHandler(LEGACY_CONTAINER_COMPAT_CSS, styleOptions)).css;
4787
4163
  setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
4788
4164
  }
4789
- const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeUnsupportedMiniProgramAtRules(compatCss), css);
4165
+ const cleanedCompatCss = collectDedupedPostTransformCompatCss((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css);
4790
4166
  if (cleanedCompatCss.trim().length === 0) return css;
4791
4167
  return createCssAppend(css, cleanedCompatCss);
4792
4168
  }
@@ -4840,7 +4216,7 @@ const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
4840
4216
  const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
4841
4217
  function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
4842
4218
  if (target !== "weapp") return css;
4843
- return finalizeMiniProgramCss(css, {
4219
+ return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
4844
4220
  cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
4845
4221
  preservePseudoContentInit: majorVersion === 3
4846
4222
  });
@@ -4920,7 +4296,7 @@ async function transformGeneratorUserCss(source, options) {
4920
4296
  if (source.trim().length === 0) return "";
4921
4297
  const cleanedSource = removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source)), { importFallback: options.importFallback });
4922
4298
  if (cleanedSource.trim().length === 0) return "";
4923
- const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
4299
+ const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
4924
4300
  if (userSource.trim().length === 0) return "";
4925
4301
  if (isCommentOnlyCss(userSource)) return userSource;
4926
4302
  if (options.generatorTarget !== "weapp") return userSource;
@@ -4928,7 +4304,7 @@ async function transformGeneratorUserCss(source, options) {
4928
4304
  ...options.generatorStyleOptions,
4929
4305
  ...options.cssUserHandlerOptions
4930
4306
  });
4931
- return removeUnsupportedMiniProgramAtRules(css);
4307
+ return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
4932
4308
  }
4933
4309
  function isPureLocalCssImportWrapper(css) {
4934
4310
  let hasImport = false;
@@ -4989,7 +4365,7 @@ async function generateCssByGenerator(options) {
4989
4365
  const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
4990
4366
  const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
4991
4367
  if (cleanedLocalImportWrapper !== void 0) return {
4992
- css: generatorOptions.target === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
4368
+ css: generatorOptions.target === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
4993
4369
  target: generatorOptions.target,
4994
4370
  source: "generator",
4995
4371
  dependencies: []