weapp-tailwindcss 5.0.0-next.20 → 5.0.0-next.22
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.
- package/dist/{bundle-state-BlXvU4jl.js → bundle-state-BnV8o2Yn.js} +1 -1
- package/dist/{bundle-state-PO6MysTJ.mjs → bundle-state-CLnuf2CW.mjs} +1 -1
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -8
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-N4jy1HCk.js → generator-CV_APjnB.js} +33 -5
- package/dist/generator-DPX8vA2P.mjs +58 -0
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-CJ0Pnsw2.js → incremental-runtime-class-set-C6akmwlk.js} +11 -433
- package/dist/{incremental-runtime-class-set-hF-uiw6W.mjs → incremental-runtime-class-set-Cwpw6aZK.mjs} +5 -427
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-DlY-YRvA.js → postcss-Csaggbm7.js} +2 -2
- package/dist/{postcss-D4UdbBQ6.mjs → postcss-ioX7S9x5.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-BjEbVEpX.js → precheck-8pQbjqpq.js} +2 -2
- package/dist/{precheck-tbk626YL.mjs → precheck-D1O5AWzy.mjs} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{runtime-registry-D5qnaSpo.js → runtime-registry-CdCV3Opt.js} +0 -20
- package/dist/{source-candidates-gxijpPI3.js → source-candidates-CUTNdsiz.js} +1 -1
- package/dist/{source-candidates-BrvneDDd.mjs → source-candidates-CnD4vyic.mjs} +1 -1
- package/dist/tailwindcss/miniprogram.d.ts +1 -5
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/{tailwindcss-c6ROlNNW.mjs → tailwindcss-B_JAdOQf.mjs} +1 -1
- package/dist/{tailwindcss-BhG7BtB-.js → tailwindcss-whZE3HpL.js} +1 -1
- package/dist/{v3-engine-5LoZUH-4.js → v3-engine-CCwvhRrQ.js} +2 -224
- package/dist/{v3-engine-DIXDEDmL.mjs → v3-engine-DyIcbpZm.mjs} +2 -218
- package/dist/{vite-B5faZcbE.mjs → vite-BcXuBYy3.mjs} +7 -7
- package/dist/{vite-MyXBNux0.js → vite-k4Nlk42j.js} +7 -7
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +42 -641
- package/dist/weapp-tw-runtime-classset-loader.js +3 -2
- package/dist/{webpack-BnVyDmsD.mjs → webpack-C4pViZ7V.mjs} +5 -5
- package/dist/{webpack-Mz1V0A9p.js → webpack-DC7v6ylA.js} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +7 -7
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -5
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
- package/dist/generator-DIuglJub.mjs +0 -32
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
|
@@ -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,
|
|
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 {
|
|
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 {
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
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-
|
|
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-
|
|
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-DPX8vA2P.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-Cwpw6aZK.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-
|
|
7
|
-
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-
|
|
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-
|
|
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-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CCwvhRrQ.js");
|
|
3
|
+
const require_generator = require("./generator-CV_APjnB.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-C6akmwlk.js");
|
|
5
|
+
const require_precheck = require("./precheck-8pQbjqpq.js");
|
|
6
6
|
const require_utils = require("./utils-4ODFyoqD.js");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_source_candidates = require("./source-candidates-
|
|
9
|
-
const require_bundle_state = require("./bundle-state-
|
|
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-
|
|
2
|
+
const require_vite = require("./vite-k4Nlk42j.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-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-BcXuBYy3.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|