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
@@ -1,2 +1 @@
1
- import type postcss from 'postcss';
2
- export declare function removeUnsupportedCascadeLayers(root: postcss.Root): void;
1
+ export { removeUnsupportedCascadeLayers, } from '@weapp-tailwindcss/postcss';
@@ -1,4 +1,4 @@
1
- import { H as createTailwindcssPatcher, J as findWorkspacePackageDir, K as omitUndefined, U as readInstalledPackageMajorVersion, Y as findWorkspaceRoot, f as runtimeSignaturePatchersSymbol, q as findNearestPackageRoot } from "./v3-engine-DIXDEDmL.mjs";
1
+ import { G as omitUndefined, H as readInstalledPackageMajorVersion, J as findWorkspaceRoot, K as findNearestPackageRoot, V as createTailwindcssPatcher, f as runtimeSignaturePatchersSymbol, q as findWorkspacePackageDir } from "./v3-engine-DyIcbpZm.mjs";
2
2
  import { n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { existsSync, readFileSync } from "node:fs";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-5LoZUH-4.js");
2
+ const require_v3_engine = require("./v3-engine-CCwvhRrQ.js");
3
3
  require("./utils-4ODFyoqD.js");
4
4
  let node_fs = require("node:fs");
5
5
  let node_module = require("node:module");
@@ -722,222 +722,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
722
722
  return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
723
723
  }
724
724
  //#endregion
725
- //#region src/tailwindcss/remove-unsupported-css.ts
726
- /**
727
- * 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
728
- */
729
- function removeUnsupportedCascadeLayers(root) {
730
- root.walkAtRules("layer", (atRule) => {
731
- if (!atRule.nodes || atRule.nodes.length === 0) {
732
- atRule.remove();
733
- return;
734
- }
735
- atRule.replaceWith(...atRule.nodes);
736
- });
737
- }
738
- //#endregion
739
- //#region src/tailwindcss/miniprogram.ts
740
- const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
741
- const DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE = "view,text,:before,:after";
742
- const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
743
- const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
744
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
745
- ":root",
746
- ":host",
747
- "page",
748
- ".tw-root",
749
- "wx-root-portal-content"
750
- ]);
751
- const MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS = new Set([
752
- "view",
753
- "text",
754
- ":before",
755
- ":after",
756
- "::before",
757
- "::after"
758
- ]);
759
- const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
760
- "*",
761
- "view",
762
- "text",
763
- ":before",
764
- ":after",
765
- "::before",
766
- "::after"
767
- ]);
768
- const PREFLIGHT_RESET_PROPS = new Set([
769
- "box-sizing",
770
- "border",
771
- "border-width",
772
- "border-style",
773
- "border-color",
774
- "margin",
775
- "padding"
776
- ]);
777
- const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
778
- function hasClassSelector(selector) {
779
- return CLASS_SELECTOR_RE.test(selector);
780
- }
781
- function normalizeSelector$1(selector) {
782
- return selector.trim().replace(/\s+/g, "");
783
- }
784
- function getRuleSelectors(rule) {
785
- return rule.selector.split(",").map(normalizeSelector$1).filter(Boolean);
786
- }
787
- function isCustomPropertyRule(rule) {
788
- let hasDeclaration = false;
789
- let allCustomProperties = true;
790
- rule.walkDecls((decl) => {
791
- hasDeclaration = true;
792
- if (!decl.prop.startsWith("--")) allCustomProperties = false;
793
- });
794
- return hasDeclaration && allCustomProperties;
795
- }
796
- function isEmptyContentInitDeclaration(decl) {
797
- return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
798
- }
799
- function removeEmptyContentInitDeclarations(rule) {
800
- rule.walkDecls((decl) => {
801
- if (isEmptyContentInitDeclaration(decl)) decl.remove();
802
- });
803
- }
804
- function usesTwContentVariable(root) {
805
- let used = false;
806
- root.walkDecls((decl) => {
807
- if (CONTENT_VAR_RE.test(decl.value)) used = true;
808
- });
809
- return used;
810
- }
811
- function isPseudoContentInitRule(rule) {
812
- const selector = rule.selector.replace(/\s+/g, "");
813
- if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
814
- let hasDeclaration = false;
815
- let onlyContentVariable = true;
816
- rule.walkDecls((decl) => {
817
- hasDeclaration = true;
818
- if (decl.prop !== "--tw-content") onlyContentVariable = false;
819
- });
820
- return hasDeclaration && onlyContentVariable;
821
- }
822
- function isMiniProgramPreflightRule(rule) {
823
- const selectors = getRuleSelectors(rule);
824
- if (selectors.length === 0 || !selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) || !selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after")) return false;
825
- let hasTailwindVariable = false;
826
- let hasResetProp = false;
827
- rule.walkDecls((decl) => {
828
- if (decl.prop.startsWith("--tw-")) hasTailwindVariable = true;
829
- if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
830
- });
831
- return hasTailwindVariable || hasResetProp;
832
- }
833
- function isMiniProgramThemeScopeRule(rule) {
834
- const selectors = getRuleSelectors(rule);
835
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
836
- }
837
- function isMiniProgramElementVariableScopeRule(rule) {
838
- const selectors = getRuleSelectors(rule);
839
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS.has(selector));
840
- }
841
- function isTailwindV4GradientRuntimeDeclaration(decl) {
842
- return decl.prop.startsWith("--tw-gradient-");
843
- }
844
- function moveTailwindV4GradientRuntimeDeclarations(rule) {
845
- const gradientDeclarations = [];
846
- rule.walkDecls((decl) => {
847
- if (isTailwindV4GradientRuntimeDeclaration(decl)) {
848
- gradientDeclarations.push(decl.clone());
849
- decl.remove();
850
- }
851
- });
852
- if (gradientDeclarations.length > 0) rule.before(new postcss.default.Rule({
853
- selector: DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE,
854
- nodes: gradientDeclarations
855
- }));
856
- if (rule.nodes.length === 0) rule.remove();
857
- }
858
- function isKeyframesRule(rule) {
859
- let parent = rule.parent;
860
- while (parent) {
861
- if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
862
- parent = parent.parent;
863
- }
864
- return false;
865
- }
866
- function removeDeclarationAndEmptyRule(decl) {
867
- const parent = decl.parent;
868
- decl.remove();
869
- if (parent?.type === "rule" && parent.nodes.length === 0) parent.remove();
870
- }
871
- function normalizeMiniProgramColorValues(root) {
872
- const customPropertyValues = /* @__PURE__ */ new Map();
873
- root.walkDecls((decl) => {
874
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
875
- });
876
- root.walkDecls((decl) => {
877
- const normalized = (0, _weapp_tailwindcss_postcss.normalizeModernColorValue)(decl.value, customPropertyValues);
878
- if (normalized.changed) {
879
- decl.value = normalized.value;
880
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
881
- }
882
- if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
883
- });
884
- }
885
- /**
886
- * 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
887
- *
888
- * 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
889
- * 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
890
- */
891
- function pruneMiniProgramGeneratedCss(css, options = {}) {
892
- const root = postcss.default.parse(css);
893
- const shouldPreserveContentInit = options.preservePreflight || usesTwContentVariable(root);
894
- root.walkComments((comment) => {
895
- comment.remove();
896
- });
897
- removeUnsupportedCascadeLayers(root);
898
- normalizeMiniProgramColorValues(root);
899
- root.walkAtRules("supports", (atRule) => {
900
- atRule.remove();
901
- });
902
- root.walkAtRules((atRule) => {
903
- (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramPrefixedAtRule)(atRule);
904
- });
905
- root.walkDecls((decl) => {
906
- (0, _weapp_tailwindcss_postcss.normalizeMiniProgramPrefixedDeclaration)(decl);
907
- });
908
- root.walkRules((rule) => {
909
- if (isKeyframesRule(rule)) return;
910
- if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
911
- rule.selector = DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE;
912
- return;
913
- }
914
- if (isCustomPropertyRule(rule) && isMiniProgramThemeScopeRule(rule)) {
915
- moveTailwindV4GradientRuntimeDeclarations(rule);
916
- if (!rule.parent) return;
917
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
918
- return;
919
- }
920
- if (hasClassSelector(rule.selector)) return;
921
- if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
922
- if (isPseudoContentInitRule(rule)) {
923
- if (!shouldPreserveContentInit) rule.remove();
924
- return;
925
- }
926
- if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
927
- if (isCustomPropertyRule(rule)) {
928
- moveTailwindV4GradientRuntimeDeclarations(rule);
929
- if (!rule.parent) return;
930
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
931
- return;
932
- }
933
- rule.remove();
934
- });
935
- root.walkAtRules((atRule) => {
936
- if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
937
- });
938
- return root.toString();
939
- }
940
- //#endregion
941
725
  //#region src/tailwindcss/v4-engine/miniprogram.ts
942
726
  const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
943
727
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -964,7 +748,7 @@ async function transformTailwindV4CssToWeapp(css, options) {
964
748
  majorVersion: 4,
965
749
  ...options
966
750
  });
967
- return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css));
751
+ return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css));
968
752
  }
969
753
  async function transformTailwindV4CssByTarget(css, target, options) {
970
754
  return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
@@ -2931,7 +2715,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
2931
2715
  }
2932
2716
  }
2933
2717
  async function transformTailwindV3CssToWeapp(css, options) {
2934
- return ensureMiniProgramV3PreflightReset(pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
2718
+ return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)((await defaultStyleHandler(css, {
2935
2719
  cssChildCombinatorReplaceValue: ["view", "text"],
2936
2720
  cssRemoveHoverPseudoClass: true,
2937
2721
  isMainChunk: true,
@@ -3567,12 +3351,6 @@ Object.defineProperty(exports, "readInstalledPackageMajorVersion", {
3567
3351
  return readInstalledPackageMajorVersion;
3568
3352
  }
3569
3353
  });
3570
- Object.defineProperty(exports, "removeUnsupportedCascadeLayers", {
3571
- enumerable: true,
3572
- get: function() {
3573
- return removeUnsupportedCascadeLayers;
3574
- }
3575
- });
3576
3354
  Object.defineProperty(exports, "resolveCssSourceEntries", {
3577
3355
  enumerable: true,
3578
3356
  get: function() {
@@ -12,7 +12,7 @@ import { stat } from "node:fs/promises";
12
12
  import fg from "fast-glob";
13
13
  import { loadConfig } from "tailwindcss-config";
14
14
  import micromatch from "micromatch";
15
- import { createStyleHandler, normalizeMiniProgramPrefixedDeclaration, normalizeModernColorValue, protectDynamicColorMixAlpha, removeUnsupportedMiniProgramPrefixedAtRule } from "@weapp-tailwindcss/postcss";
15
+ import { createStyleHandler, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
16
16
  //#region src/context/workspace.ts
17
17
  const IGNORED_WORKSPACE_DIRS = new Set([
18
18
  "node_modules",
@@ -714,222 +714,6 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
714
714
  return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
715
715
  }
716
716
  //#endregion
717
- //#region src/tailwindcss/remove-unsupported-css.ts
718
- /**
719
- * 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
720
- */
721
- function removeUnsupportedCascadeLayers(root) {
722
- root.walkAtRules("layer", (atRule) => {
723
- if (!atRule.nodes || atRule.nodes.length === 0) {
724
- atRule.remove();
725
- return;
726
- }
727
- atRule.replaceWith(...atRule.nodes);
728
- });
729
- }
730
- //#endregion
731
- //#region src/tailwindcss/miniprogram.ts
732
- const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
733
- const DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE = "view,text,:before,:after";
734
- const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
735
- const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
736
- const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
737
- ":root",
738
- ":host",
739
- "page",
740
- ".tw-root",
741
- "wx-root-portal-content"
742
- ]);
743
- const MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS = new Set([
744
- "view",
745
- "text",
746
- ":before",
747
- ":after",
748
- "::before",
749
- "::after"
750
- ]);
751
- const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
752
- "*",
753
- "view",
754
- "text",
755
- ":before",
756
- ":after",
757
- "::before",
758
- "::after"
759
- ]);
760
- const PREFLIGHT_RESET_PROPS = new Set([
761
- "box-sizing",
762
- "border",
763
- "border-width",
764
- "border-style",
765
- "border-color",
766
- "margin",
767
- "padding"
768
- ]);
769
- const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
770
- function hasClassSelector(selector) {
771
- return CLASS_SELECTOR_RE.test(selector);
772
- }
773
- function normalizeSelector$1(selector) {
774
- return selector.trim().replace(/\s+/g, "");
775
- }
776
- function getRuleSelectors(rule) {
777
- return rule.selector.split(",").map(normalizeSelector$1).filter(Boolean);
778
- }
779
- function isCustomPropertyRule(rule) {
780
- let hasDeclaration = false;
781
- let allCustomProperties = true;
782
- rule.walkDecls((decl) => {
783
- hasDeclaration = true;
784
- if (!decl.prop.startsWith("--")) allCustomProperties = false;
785
- });
786
- return hasDeclaration && allCustomProperties;
787
- }
788
- function isEmptyContentInitDeclaration(decl) {
789
- return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
790
- }
791
- function removeEmptyContentInitDeclarations(rule) {
792
- rule.walkDecls((decl) => {
793
- if (isEmptyContentInitDeclaration(decl)) decl.remove();
794
- });
795
- }
796
- function usesTwContentVariable(root) {
797
- let used = false;
798
- root.walkDecls((decl) => {
799
- if (CONTENT_VAR_RE.test(decl.value)) used = true;
800
- });
801
- return used;
802
- }
803
- function isPseudoContentInitRule(rule) {
804
- const selector = rule.selector.replace(/\s+/g, "");
805
- if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
806
- let hasDeclaration = false;
807
- let onlyContentVariable = true;
808
- rule.walkDecls((decl) => {
809
- hasDeclaration = true;
810
- if (decl.prop !== "--tw-content") onlyContentVariable = false;
811
- });
812
- return hasDeclaration && onlyContentVariable;
813
- }
814
- function isMiniProgramPreflightRule(rule) {
815
- const selectors = getRuleSelectors(rule);
816
- if (selectors.length === 0 || !selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) || !selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after")) return false;
817
- let hasTailwindVariable = false;
818
- let hasResetProp = false;
819
- rule.walkDecls((decl) => {
820
- if (decl.prop.startsWith("--tw-")) hasTailwindVariable = true;
821
- if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
822
- });
823
- return hasTailwindVariable || hasResetProp;
824
- }
825
- function isMiniProgramThemeScopeRule(rule) {
826
- const selectors = getRuleSelectors(rule);
827
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
828
- }
829
- function isMiniProgramElementVariableScopeRule(rule) {
830
- const selectors = getRuleSelectors(rule);
831
- return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_VARIABLE_SCOPE_SELECTORS.has(selector));
832
- }
833
- function isTailwindV4GradientRuntimeDeclaration(decl) {
834
- return decl.prop.startsWith("--tw-gradient-");
835
- }
836
- function moveTailwindV4GradientRuntimeDeclarations(rule) {
837
- const gradientDeclarations = [];
838
- rule.walkDecls((decl) => {
839
- if (isTailwindV4GradientRuntimeDeclaration(decl)) {
840
- gradientDeclarations.push(decl.clone());
841
- decl.remove();
842
- }
843
- });
844
- if (gradientDeclarations.length > 0) rule.before(new postcss.Rule({
845
- selector: DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE,
846
- nodes: gradientDeclarations
847
- }));
848
- if (rule.nodes.length === 0) rule.remove();
849
- }
850
- function isKeyframesRule(rule) {
851
- let parent = rule.parent;
852
- while (parent) {
853
- if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
854
- parent = parent.parent;
855
- }
856
- return false;
857
- }
858
- function removeDeclarationAndEmptyRule(decl) {
859
- const parent = decl.parent;
860
- decl.remove();
861
- if (parent?.type === "rule" && parent.nodes.length === 0) parent.remove();
862
- }
863
- function normalizeMiniProgramColorValues(root) {
864
- const customPropertyValues = /* @__PURE__ */ new Map();
865
- root.walkDecls((decl) => {
866
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
867
- });
868
- root.walkDecls((decl) => {
869
- const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
870
- if (normalized.changed) {
871
- decl.value = normalized.value;
872
- if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
873
- }
874
- if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
875
- });
876
- }
877
- /**
878
- * 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
879
- *
880
- * 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
881
- * 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
882
- */
883
- function pruneMiniProgramGeneratedCss(css, options = {}) {
884
- const root = postcss.parse(css);
885
- const shouldPreserveContentInit = options.preservePreflight || usesTwContentVariable(root);
886
- root.walkComments((comment) => {
887
- comment.remove();
888
- });
889
- removeUnsupportedCascadeLayers(root);
890
- normalizeMiniProgramColorValues(root);
891
- root.walkAtRules("supports", (atRule) => {
892
- atRule.remove();
893
- });
894
- root.walkAtRules((atRule) => {
895
- removeUnsupportedMiniProgramPrefixedAtRule(atRule);
896
- });
897
- root.walkDecls((decl) => {
898
- normalizeMiniProgramPrefixedDeclaration(decl);
899
- });
900
- root.walkRules((rule) => {
901
- if (isKeyframesRule(rule)) return;
902
- if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
903
- rule.selector = DEFAULT_WEAPP_ELEMENT_VARIABLE_SCOPE;
904
- return;
905
- }
906
- if (isCustomPropertyRule(rule) && isMiniProgramThemeScopeRule(rule)) {
907
- moveTailwindV4GradientRuntimeDeclarations(rule);
908
- if (!rule.parent) return;
909
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
910
- return;
911
- }
912
- if (hasClassSelector(rule.selector)) return;
913
- if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
914
- if (isPseudoContentInitRule(rule)) {
915
- if (!shouldPreserveContentInit) rule.remove();
916
- return;
917
- }
918
- if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
919
- if (isCustomPropertyRule(rule)) {
920
- moveTailwindV4GradientRuntimeDeclarations(rule);
921
- if (!rule.parent) return;
922
- rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
923
- return;
924
- }
925
- rule.remove();
926
- });
927
- root.walkAtRules((atRule) => {
928
- if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
929
- });
930
- return root.toString();
931
- }
932
- //#endregion
933
717
  //#region src/tailwindcss/v4-engine/miniprogram.ts
934
718
  const defaultStyleHandler$1 = createStyleHandler({
935
719
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -3403,4 +3187,4 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
3403
3187
  return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
3404
3188
  }
3405
3189
  //#endregion
3406
- export { FULL_SOURCE_SCAN_EXTENSION_RE as A, toPosixPath as B, createTailwindV4Engine$1 as C, filterUnsupportedMiniProgramTailwindV4Candidates as D, removeUnsupportedCascadeLayers as E, normalizeLegacyContentEntries as F, resolveTailwindcssOptions as G, createTailwindcssPatcher as H, parseConfigParam$1 as I, findWorkspacePackageDir as J, omitUndefined as K, resolveCssSourceEntries as L, createSourceScanPattern as M, expandTailwindSourceEntries as N, loadTailwindV4DesignSystem as O, isFileMatchedByTailwindSourceEntries as P, resolveSourceScanPath as R, resolveTailwindV4SourceOptionsFromPatcher as S, transformTailwindV4CssToWeapp as T, readInstalledPackageMajorVersion as U, createDebug as V, findTailwindConfig as W, findWorkspaceRoot as Y, resolveViteSourceScanEntries as _, transformTailwindV3CssByTarget as a, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, invalidateRuntimeClassSet as d, runtimeSignaturePatchersSymbol as f, resolveTailwindV4EntriesFromCssCached as g, resolveTailwindV4EntriesFromCss as h, createTailwindV3Engine as i, collectCssInlineSourceCandidates as j, DEFAULT_SOURCE_SCAN_EXTENSIONS as k, getRuntimeClassSetSignature as l, discoverTailwindV4CssEntries as m, resolveTailwindV3SourceFromPatcher as n, transformTailwindV3CssToWeapp as o, createViteSourceScanMatcher as p, findNearestPackageRoot as q, resolveTailwindV3SourceOptionsFromPatcher as r, ensureTailwindcssRuntimePatch as s, resolveTailwindV3Source as t, getRuntimeClassSetSignatureWithSources as u, resolveViteTailwindV4CssDependencies as v, transformTailwindV4CssByTarget as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, resolveTailwindV4CssSourceBase as z };
3190
+ export { collectCssInlineSourceCandidates as A, createDebug as B, createTailwindV4Engine$1 as C, loadTailwindV4DesignSystem as D, filterUnsupportedMiniProgramTailwindV4Candidates as E, parseConfigParam$1 as F, omitUndefined as G, readInstalledPackageMajorVersion as H, resolveCssSourceEntries as I, findWorkspaceRoot as J, findNearestPackageRoot as K, resolveSourceScanPath as L, expandTailwindSourceEntries as M, isFileMatchedByTailwindSourceEntries as N, DEFAULT_SOURCE_SCAN_EXTENSIONS as O, normalizeLegacyContentEntries as P, resolveTailwindV4CssSourceBase as R, resolveTailwindV4SourceOptionsFromPatcher as S, transformTailwindV4CssToWeapp as T, findTailwindConfig as U, createTailwindcssPatcher as V, resolveTailwindcssOptions as W, resolveViteSourceScanEntries as _, transformTailwindV3CssByTarget as a, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, invalidateRuntimeClassSet as d, runtimeSignaturePatchersSymbol as f, resolveTailwindV4EntriesFromCssCached as g, resolveTailwindV4EntriesFromCss as h, createTailwindV3Engine as i, createSourceScanPattern as j, FULL_SOURCE_SCAN_EXTENSION_RE as k, getRuntimeClassSetSignature as l, discoverTailwindV4CssEntries as m, resolveTailwindV3SourceFromPatcher as n, transformTailwindV3CssToWeapp as o, createViteSourceScanMatcher as p, findWorkspacePackageDir as q, resolveTailwindV3SourceOptionsFromPatcher as r, ensureTailwindcssRuntimePatch as s, resolveTailwindV3Source as t, getRuntimeClassSetSignatureWithSources as u, resolveViteTailwindV4CssDependencies as v, transformTailwindV4CssByTarget as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, toPosixPath as z };
@@ -1,11 +1,11 @@
1
- import { D as filterUnsupportedMiniProgramTailwindV4Candidates, G as resolveTailwindcssOptions, K as omitUndefined, V as createDebug, W as findTailwindConfig, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, q as findNearestPackageRoot, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-DIXDEDmL.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-DIuglJub.mjs";
3
- import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-hF-uiw6W.mjs";
4
- import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-tbk626YL.mjs";
1
+ import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates, G as omitUndefined, K as findNearestPackageRoot, U as findTailwindConfig, W as resolveTailwindcssOptions, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-DyIcbpZm.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-DvyhmC76.mjs";
3
+ import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-C7Q7fC5u.mjs";
4
+ import { a as analyzeSource, c as isClassContextLiteralPath, g as createTailwindRuntimeReadyPromise, h as collectRuntimeClassSet, i as createAttributeMatcher, l as replaceWxml, m as toCustomAttributesEntities, n as getCompilerContext, o as JsTokenUpdater, p as vitePluginName, r as generateCode, s as _defineProperty, t as shouldSkipJsTransform, u as babelParse, v as refreshTailwindRuntimeState } from "./precheck-D1O5AWzy.mjs";
5
5
  import { o as resolveUniUtsPlatform } from "./utils-CGBVVNm6.mjs";
6
- import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-c6ROlNNW.mjs";
7
- import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-BrvneDDd.mjs";
8
- import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-PO6MysTJ.mjs";
6
+ import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-B_JAdOQf.mjs";
7
+ import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-CnD4vyic.mjs";
8
+ import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-CLnuf2CW.mjs";
9
9
  import { t as logger$1 } from "./logger-CZUxvJJD.mjs";
10
10
  import fs, { existsSync, readFileSync } from "node:fs";
11
11
  import postcss from "postcss";
@@ -1,12 +1,12 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_v3_engine = require("./v3-engine-5LoZUH-4.js");
3
- const require_generator = require("./generator-N4jy1HCk.js");
4
- const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CJ0Pnsw2.js");
5
- const require_precheck = require("./precheck-BjEbVEpX.js");
2
+ const require_v3_engine = require("./v3-engine-CCwvhRrQ.js");
3
+ const require_generator = require("./generator-B4RNgMLx.js");
4
+ const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-DZsbM0-a.js");
5
+ const require_precheck = require("./precheck-8pQbjqpq.js");
6
6
  const require_utils = require("./utils-4ODFyoqD.js");
7
- const require_tailwindcss = require("./tailwindcss-BhG7BtB-.js");
8
- const require_source_candidates = require("./source-candidates-gxijpPI3.js");
9
- const require_bundle_state = require("./bundle-state-BlXvU4jl.js");
7
+ const require_tailwindcss = require("./tailwindcss-whZE3HpL.js");
8
+ const require_source_candidates = require("./source-candidates-CUTNdsiz.js");
9
+ const require_bundle_state = require("./bundle-state-BnV8o2Yn.js");
10
10
  require("./logger-EVNB9z7i.js");
11
11
  let node_fs = require("node:fs");
12
12
  node_fs = require_chunk.__toESM(node_fs);
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_vite = require("./vite-MyXBNux0.js");
2
+ const require_vite = require("./vite-BcnwgJMt.js");
3
3
  exports.WeappTailwindcss = require_vite.WeappTailwindcss;
4
4
  exports.weappTailwindcss = require_vite.WeappTailwindcss;
package/dist/vite.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as WeappTailwindcss } from "./vite-B5faZcbE.mjs";
1
+ import { t as WeappTailwindcss } from "./vite-B8IiXgVD.mjs";
2
2
  export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };