@weapp-tailwindcss/postcss 3.0.3 → 3.0.4
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/compat/color-mix/constants.d.ts +9 -0
- package/dist/compat/color-mix/modern.d.ts +2 -0
- package/dist/compat/color-mix/parse.d.ts +9 -0
- package/dist/compat/color-mix/resolve.d.ts +5 -0
- package/dist/compat/mini-program-css/directives.d.ts +5 -0
- package/dist/compat/mini-program-css/finalize-options.d.ts +6 -0
- package/dist/compat/mini-program-css/finalize.d.ts +4 -12
- package/dist/compat/mini-program-css/hoist.d.ts +4 -0
- package/dist/compat/mini-program-css/preflight.d.ts +7 -0
- package/dist/compat/mini-program-css/root-cleanups.d.ts +6 -0
- package/dist/compat/mini-program-css/theme.d.ts +3 -0
- package/dist/index.js +441 -281
- package/dist/index.mjs +440 -281
- package/dist/selectorParser/rule-transformer/nodes.d.ts +7 -0
- package/dist/selectorParser/rule-transformer/pseudos.d.ts +6 -0
- package/dist/selectorParser/rule-transformer/types.d.ts +14 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -36,6 +36,37 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
enumerable: true
|
|
37
37
|
}) : target, mod));
|
|
38
38
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
39
|
+
const MODERN_COLOR_FUNCTION_NAMES = new Set([
|
|
40
|
+
"oklch",
|
|
41
|
+
"oklab",
|
|
42
|
+
"lch",
|
|
43
|
+
"lab"
|
|
44
|
+
]);
|
|
45
|
+
const PLACEHOLDER_PREFIX = "__weapp_tw_color_mix_";
|
|
46
|
+
const DYNAMIC_ALPHA_RE = /\b(?:var|env)\(|--[\w-]+\b/;
|
|
47
|
+
const INTERNAL_TAILWIND_ALPHA_RE = /var\(\s*--tw-[^)]+-alpha\s*\)/;
|
|
48
|
+
const TRANSPARENT_COLOR_RE = /^transparent$/i;
|
|
49
|
+
const CURRENT_COLOR_RE = /^currentcolor$/i;
|
|
50
|
+
const CSS_WIDE_KEYWORD_RE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
51
|
+
const CUSTOM_PROPERTY_RE = /^--[\w-]+$/;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/compat/color-mix/modern.ts
|
|
54
|
+
function isDisplayP3ColorFunction(colorSource) {
|
|
55
|
+
return /^color\(\s*display-p3\b/i.test(colorSource.trim());
|
|
56
|
+
}
|
|
57
|
+
function hasUnsupportedModernColorFunction(value) {
|
|
58
|
+
const parsed = valueParser(value);
|
|
59
|
+
let hasUnsupported = false;
|
|
60
|
+
parsed.walk((node) => {
|
|
61
|
+
if (node.type !== "function") return;
|
|
62
|
+
const name = node.value.toLowerCase();
|
|
63
|
+
if (name === "color-mix" || MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(valueParser.stringify(node))) {
|
|
64
|
+
hasUnsupported = true;
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return hasUnsupported;
|
|
69
|
+
}
|
|
39
70
|
//#endregion
|
|
40
71
|
//#region ../../node_modules/.pnpm/@csstools+css-tokenizer@4.0.0/node_modules/@csstools/css-tokenizer/dist/index.mjs
|
|
41
72
|
var ParseError$1 = class extends Error {
|
|
@@ -6536,21 +6567,7 @@ function color(e) {
|
|
|
6536
6567
|
return !1;
|
|
6537
6568
|
}
|
|
6538
6569
|
//#endregion
|
|
6539
|
-
//#region src/compat/color-mix.ts
|
|
6540
|
-
const COLOR_MIX_NAME = "color-mix";
|
|
6541
|
-
const MODERN_COLOR_FUNCTION_NAMES = new Set([
|
|
6542
|
-
"oklch",
|
|
6543
|
-
"oklab",
|
|
6544
|
-
"lch",
|
|
6545
|
-
"lab"
|
|
6546
|
-
]);
|
|
6547
|
-
const PLACEHOLDER_PREFIX = "__weapp_tw_color_mix_";
|
|
6548
|
-
const DYNAMIC_ALPHA_RE = /\b(?:var|env)\(|--[\w-]+\b/;
|
|
6549
|
-
const INTERNAL_TAILWIND_ALPHA_RE = /var\(\s*--tw-[^)]+-alpha\s*\)/;
|
|
6550
|
-
const TRANSPARENT_COLOR_RE = /^transparent$/i;
|
|
6551
|
-
const CURRENT_COLOR_RE = /^currentcolor$/i;
|
|
6552
|
-
const CSS_WIDE_KEYWORD_RE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
6553
|
-
const CUSTOM_PROPERTY_RE = /^--[\w-]+$/;
|
|
6570
|
+
//#region src/compat/color-mix/parse.ts
|
|
6554
6571
|
function splitArguments(nodes) {
|
|
6555
6572
|
const args = [];
|
|
6556
6573
|
let current = [];
|
|
@@ -6633,51 +6650,8 @@ function normalizeStandaloneColorFunction(colorSource) {
|
|
|
6633
6650
|
const resolvedColor = getParsedColorData(colorSource);
|
|
6634
6651
|
return resolvedColor ? serializeRGB(resolvedColor).toString() : void 0;
|
|
6635
6652
|
}
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
}
|
|
6639
|
-
function hasUnsupportedModernColorFunction(value) {
|
|
6640
|
-
const parsed = valueParser(value);
|
|
6641
|
-
let hasUnsupported = false;
|
|
6642
|
-
parsed.walk((node) => {
|
|
6643
|
-
if (node.type !== "function") return;
|
|
6644
|
-
const name = node.value.toLowerCase();
|
|
6645
|
-
if (name === COLOR_MIX_NAME || MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(valueParser.stringify(node))) {
|
|
6646
|
-
hasUnsupported = true;
|
|
6647
|
-
return false;
|
|
6648
|
-
}
|
|
6649
|
-
});
|
|
6650
|
-
return hasUnsupported;
|
|
6651
|
-
}
|
|
6652
|
-
function normalizeModernColorValue(value, customPropertyValues = /* @__PURE__ */ new Map()) {
|
|
6653
|
-
if (!hasUnsupportedModernColorFunction(value)) return {
|
|
6654
|
-
value,
|
|
6655
|
-
changed: false,
|
|
6656
|
-
hasUnsupported: false
|
|
6657
|
-
};
|
|
6658
|
-
const parsed = valueParser(value);
|
|
6659
|
-
let changed = false;
|
|
6660
|
-
parsed.walk((node) => {
|
|
6661
|
-
if (node.type !== "function") return;
|
|
6662
|
-
const name = node.value.toLowerCase();
|
|
6663
|
-
const source = valueParser.stringify(node);
|
|
6664
|
-
let normalized;
|
|
6665
|
-
if (MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(source)) normalized = normalizeStandaloneColorFunction(source);
|
|
6666
|
-
else if (name === COLOR_MIX_NAME) normalized = tryResolveColorMix(node, customPropertyValues)?.value;
|
|
6667
|
-
if (!normalized) return;
|
|
6668
|
-
const mutableNode = node;
|
|
6669
|
-
mutableNode.type = "word";
|
|
6670
|
-
mutableNode.value = normalized;
|
|
6671
|
-
delete mutableNode.nodes;
|
|
6672
|
-
changed = true;
|
|
6673
|
-
});
|
|
6674
|
-
const nextValue = changed ? parsed.toString() : value;
|
|
6675
|
-
return {
|
|
6676
|
-
value: nextValue,
|
|
6677
|
-
changed,
|
|
6678
|
-
hasUnsupported: hasUnsupportedModernColorFunction(nextValue)
|
|
6679
|
-
};
|
|
6680
|
-
}
|
|
6653
|
+
//#endregion
|
|
6654
|
+
//#region src/compat/color-mix/resolve.ts
|
|
6681
6655
|
function createRgbaWithAlpha(colorSource, alphaSource, customPropertyValues) {
|
|
6682
6656
|
const resolvedColor = resolveColorData(colorSource, customPropertyValues);
|
|
6683
6657
|
if (!resolvedColor) return;
|
|
@@ -6723,17 +6697,48 @@ function tryResolveColorMix(node, customPropertyValues) {
|
|
|
6723
6697
|
deferred: false
|
|
6724
6698
|
};
|
|
6725
6699
|
}
|
|
6700
|
+
//#endregion
|
|
6701
|
+
//#region src/compat/color-mix.ts
|
|
6702
|
+
function normalizeModernColorValue(value, customPropertyValues = /* @__PURE__ */ new Map()) {
|
|
6703
|
+
if (!hasUnsupportedModernColorFunction(value)) return {
|
|
6704
|
+
value,
|
|
6705
|
+
changed: false,
|
|
6706
|
+
hasUnsupported: false
|
|
6707
|
+
};
|
|
6708
|
+
const parsed = valueParser(value);
|
|
6709
|
+
let changed = false;
|
|
6710
|
+
parsed.walk((node) => {
|
|
6711
|
+
if (node.type !== "function") return;
|
|
6712
|
+
const name = node.value.toLowerCase();
|
|
6713
|
+
const source = valueParser.stringify(node);
|
|
6714
|
+
let normalized;
|
|
6715
|
+
if (MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(source)) normalized = normalizeStandaloneColorFunction(source);
|
|
6716
|
+
else if (name === "color-mix") normalized = tryResolveColorMix(node, customPropertyValues)?.value;
|
|
6717
|
+
if (!normalized) return;
|
|
6718
|
+
const mutableNode = node;
|
|
6719
|
+
mutableNode.type = "word";
|
|
6720
|
+
mutableNode.value = normalized;
|
|
6721
|
+
delete mutableNode.nodes;
|
|
6722
|
+
changed = true;
|
|
6723
|
+
});
|
|
6724
|
+
const nextValue = changed ? parsed.toString() : value;
|
|
6725
|
+
return {
|
|
6726
|
+
value: nextValue,
|
|
6727
|
+
changed,
|
|
6728
|
+
hasUnsupported: hasUnsupportedModernColorFunction(nextValue)
|
|
6729
|
+
};
|
|
6730
|
+
}
|
|
6726
6731
|
function createPlaceholder(index) {
|
|
6727
6732
|
return `${PLACEHOLDER_PREFIX}${index}__`;
|
|
6728
6733
|
}
|
|
6729
6734
|
function unwrapProtectedSupports(cssRoot) {
|
|
6730
6735
|
cssRoot.walkAtRules("supports", (atRule) => {
|
|
6731
|
-
if (!atRule.nodes || !atRule.toString().includes(
|
|
6736
|
+
if (!atRule.nodes || !atRule.toString().includes("__weapp_tw_color_mix_")) return;
|
|
6732
6737
|
atRule.replaceWith(atRule.nodes);
|
|
6733
6738
|
});
|
|
6734
6739
|
}
|
|
6735
6740
|
function protectDynamicColorMixAlpha(css, options = {}) {
|
|
6736
|
-
if (!css.includes(
|
|
6741
|
+
if (!css.includes("color-mix")) return {
|
|
6737
6742
|
css,
|
|
6738
6743
|
restore: (value) => value
|
|
6739
6744
|
};
|
|
@@ -6742,14 +6747,14 @@ function protectDynamicColorMixAlpha(css, options = {}) {
|
|
|
6742
6747
|
const customPropertyValues = new Map(options.customPropertyValues);
|
|
6743
6748
|
let changed = false;
|
|
6744
6749
|
root.walkDecls((decl) => {
|
|
6745
|
-
if (decl.prop.startsWith("--") && !decl.value.includes(
|
|
6750
|
+
if (decl.prop.startsWith("--") && !decl.value.includes("color-mix")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
6746
6751
|
});
|
|
6747
6752
|
root.walkDecls((decl) => {
|
|
6748
|
-
if (!decl.value.includes(
|
|
6753
|
+
if (!decl.value.includes("color-mix")) return;
|
|
6749
6754
|
const parsed = valueParser(decl.value);
|
|
6750
6755
|
let mutated = false;
|
|
6751
6756
|
parsed.walk((node) => {
|
|
6752
|
-
if (node.type !== "function" || node.value.toLowerCase() !==
|
|
6757
|
+
if (node.type !== "function" || node.value.toLowerCase() !== "color-mix") return;
|
|
6753
6758
|
const resolved = tryResolveColorMix(node, customPropertyValues);
|
|
6754
6759
|
if (resolved) {
|
|
6755
6760
|
if (resolved.deferred) {
|
|
@@ -7205,7 +7210,27 @@ function isTailwindcssV4DisplayP3Media(atRule) {
|
|
|
7205
7210
|
function isTailwindcssV4DisplayP3Declaration(decl) {
|
|
7206
7211
|
return DISPLAY_P3_VALUE_RE$1.test(decl.value);
|
|
7207
7212
|
}
|
|
7213
|
+
function normalizeTailwindcssV4EmptyVarFallback(value) {
|
|
7214
|
+
if (!value.includes("var(") || !value.includes("--tw-")) return value;
|
|
7215
|
+
const parsed = valueParser(value);
|
|
7216
|
+
let changed = false;
|
|
7217
|
+
parsed.walk((node) => {
|
|
7218
|
+
if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
|
|
7219
|
+
const firstArg = node.nodes.find((child) => child.type !== "space");
|
|
7220
|
+
const lastArg = node.nodes.findLast((child) => child.type !== "space");
|
|
7221
|
+
if (firstArg?.type !== "word" || !firstArg.value.startsWith("--tw-") || lastArg?.type !== "div" || lastArg.value !== "," || node.after === " ") return;
|
|
7222
|
+
node.after = " ";
|
|
7223
|
+
changed = true;
|
|
7224
|
+
});
|
|
7225
|
+
return changed ? parsed.toString() : value;
|
|
7226
|
+
}
|
|
7208
7227
|
function normalizeTailwindcssV4Declaration(decl) {
|
|
7228
|
+
let changed = false;
|
|
7229
|
+
const normalizedEmptyVarFallback = normalizeTailwindcssV4EmptyVarFallback(decl.value);
|
|
7230
|
+
if (normalizedEmptyVarFallback !== decl.value) {
|
|
7231
|
+
decl.value = normalizedEmptyVarFallback;
|
|
7232
|
+
changed = true;
|
|
7233
|
+
}
|
|
7209
7234
|
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OKLAB_SUFFIX)) {
|
|
7210
7235
|
decl.value = decl.value.slice(0, decl.value.length - 8).trimEnd();
|
|
7211
7236
|
return true;
|
|
@@ -7227,17 +7252,38 @@ function normalizeTailwindcssV4Declaration(decl) {
|
|
|
7227
7252
|
return true;
|
|
7228
7253
|
}
|
|
7229
7254
|
}
|
|
7230
|
-
return
|
|
7255
|
+
return changed;
|
|
7231
7256
|
}
|
|
7232
7257
|
//#endregion
|
|
7233
|
-
//#region src/compat/mini-program-css/
|
|
7234
|
-
const
|
|
7235
|
-
const
|
|
7236
|
-
function
|
|
7237
|
-
|
|
7258
|
+
//#region src/compat/mini-program-css/directives.ts
|
|
7259
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
7260
|
+
const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
|
|
7261
|
+
function hasTailwindcssV4Signal(css) {
|
|
7262
|
+
if (TAILWIND_V4_BANNER_RE.test(css)) return true;
|
|
7263
|
+
const root = postcss.parse(css);
|
|
7264
|
+
let hasProperty = false;
|
|
7265
|
+
root.walkAtRules("property", (atRule) => {
|
|
7266
|
+
if (atRule.params.trim().startsWith("--tw-")) {
|
|
7267
|
+
hasProperty = true;
|
|
7268
|
+
return false;
|
|
7269
|
+
}
|
|
7270
|
+
});
|
|
7271
|
+
return hasProperty;
|
|
7238
7272
|
}
|
|
7239
|
-
function
|
|
7240
|
-
|
|
7273
|
+
function unwrapTailwindSourceMedia(root) {
|
|
7274
|
+
root.walkAtRules("media", (atRule) => {
|
|
7275
|
+
if (!atRule.params.startsWith("source(")) return;
|
|
7276
|
+
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
7277
|
+
else atRule.remove();
|
|
7278
|
+
});
|
|
7279
|
+
}
|
|
7280
|
+
function removeTailwindGenerationDirectives(root) {
|
|
7281
|
+
root.walkComments((comment) => {
|
|
7282
|
+
if (GENERATOR_PLACEHOLDER_COMMENT_RE.test(comment.text)) comment.remove();
|
|
7283
|
+
});
|
|
7284
|
+
root.walkAtRules((atRule) => {
|
|
7285
|
+
if (atRule.name === "config" || atRule.name === "source" || atRule.name === "tailwind" || atRule.name === "reference" || atRule.name === "plugin") atRule.remove();
|
|
7286
|
+
});
|
|
7241
7287
|
}
|
|
7242
7288
|
//#endregion
|
|
7243
7289
|
//#region src/compat/mini-program-css/selectors.ts
|
|
@@ -7384,7 +7430,7 @@ function isCustomPropertyRule(rule) {
|
|
|
7384
7430
|
function isEmptyTwContentDeclaration(decl) {
|
|
7385
7431
|
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
7386
7432
|
}
|
|
7387
|
-
function isOnlyTwContentDeclarations(rule) {
|
|
7433
|
+
function isOnlyTwContentDeclarations$1(rule) {
|
|
7388
7434
|
let hasDeclaration = false;
|
|
7389
7435
|
let onlyContentVariable = true;
|
|
7390
7436
|
rule.walkDecls((decl) => {
|
|
@@ -7395,7 +7441,7 @@ function isOnlyTwContentDeclarations(rule) {
|
|
|
7395
7441
|
}
|
|
7396
7442
|
function isPseudoContentInitRule(rule) {
|
|
7397
7443
|
const selector = rule.selector.replace(/\s+/g, "");
|
|
7398
|
-
return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations(rule);
|
|
7444
|
+
return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations$1(rule);
|
|
7399
7445
|
}
|
|
7400
7446
|
function usesTwContentVariable(root) {
|
|
7401
7447
|
let used = false;
|
|
@@ -7413,82 +7459,92 @@ function isMiniProgramThemeVariableRule(node) {
|
|
|
7413
7459
|
return isMiniProgramThemeScopeSelector(getRuleSelectors(node)) && isCustomPropertyRule(node);
|
|
7414
7460
|
}
|
|
7415
7461
|
//#endregion
|
|
7416
|
-
//#region src/compat/mini-program-css/
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
});
|
|
7427
|
-
if (changed) rule.selectors = selectors;
|
|
7428
|
-
});
|
|
7429
|
-
}
|
|
7430
|
-
function removeEmptyAtRuleAncestors(parent) {
|
|
7431
|
-
while (parent?.type === "atrule" && (!parent.nodes || parent.nodes.length === 0)) {
|
|
7432
|
-
const nextParent = parent.parent;
|
|
7433
|
-
parent.remove();
|
|
7434
|
-
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
7462
|
+
//#region src/compat/mini-program-css/hoist.ts
|
|
7463
|
+
const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
|
|
7464
|
+
function getTopDirectiveTail(root) {
|
|
7465
|
+
let tail;
|
|
7466
|
+
for (const node of root.nodes ?? []) {
|
|
7467
|
+
if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
|
|
7468
|
+
tail = node;
|
|
7469
|
+
continue;
|
|
7470
|
+
}
|
|
7471
|
+
break;
|
|
7435
7472
|
}
|
|
7473
|
+
return tail;
|
|
7436
7474
|
}
|
|
7437
|
-
function
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7475
|
+
function reorderPreflightResetDeclarations(rule) {
|
|
7476
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
7477
|
+
if (declarations.length <= 1) return;
|
|
7478
|
+
const resetDeclarations = [];
|
|
7479
|
+
const otherDeclarations = [];
|
|
7480
|
+
for (const declaration of declarations) if (PREFLIGHT_RESET_PROPS.has(declaration.prop)) resetDeclarations.push(declaration);
|
|
7481
|
+
else otherDeclarations.push(declaration);
|
|
7482
|
+
if (resetDeclarations.length === 0 || otherDeclarations.length === 0) return;
|
|
7483
|
+
const orderedDeclarations = [...resetDeclarations, ...otherDeclarations];
|
|
7484
|
+
if (orderedDeclarations.every((declaration, index) => declaration === declarations[index])) return;
|
|
7485
|
+
for (const declaration of declarations) declaration.remove();
|
|
7486
|
+
rule.prepend(...orderedDeclarations);
|
|
7487
|
+
rule.raws.semicolon = true;
|
|
7450
7488
|
}
|
|
7451
|
-
function
|
|
7452
|
-
const
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
parent.remove();
|
|
7457
|
-
removeEmptyAtRuleAncestors(ruleParent);
|
|
7489
|
+
function createHoistInsertionAnchor(root) {
|
|
7490
|
+
for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
|
|
7491
|
+
const anchor = postcss.comment({ text: HOIST_ANCHOR_COMMENT });
|
|
7492
|
+
node.before(anchor);
|
|
7493
|
+
return anchor;
|
|
7458
7494
|
}
|
|
7459
7495
|
}
|
|
7460
|
-
function
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7496
|
+
function insertHoistedRules(root, rules, anchor) {
|
|
7497
|
+
if (anchor && !anchor.parent) anchor = void 0;
|
|
7498
|
+
if (rules.length === 0) {
|
|
7499
|
+
anchor?.remove();
|
|
7500
|
+
return;
|
|
7501
|
+
}
|
|
7502
|
+
const topDirectiveTail = getTopDirectiveTail(root);
|
|
7503
|
+
const firstRule = rules[0];
|
|
7504
|
+
if (!firstRule) return;
|
|
7505
|
+
if (anchor) {
|
|
7506
|
+
if (anchor.raws.before === void 0) delete firstRule.raws.before;
|
|
7507
|
+
else firstRule.raws.before = anchor.raws.before;
|
|
7508
|
+
anchor.replaceWith(rules);
|
|
7509
|
+
return;
|
|
7510
|
+
}
|
|
7511
|
+
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
7512
|
+
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
7513
|
+
else root.prepend(rules);
|
|
7468
7514
|
}
|
|
7469
|
-
function
|
|
7470
|
-
const
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
const
|
|
7476
|
-
if (
|
|
7477
|
-
|
|
7478
|
-
|
|
7515
|
+
function mergeEquivalentHoistedRules(rules) {
|
|
7516
|
+
const mergedRules = [];
|
|
7517
|
+
const ruleBySelector = /* @__PURE__ */ new Map();
|
|
7518
|
+
const propsBySelector = /* @__PURE__ */ new Map();
|
|
7519
|
+
for (const rule of rules) {
|
|
7520
|
+
const key = getSortedRuleSelectorKey(rule);
|
|
7521
|
+
const existingRule = ruleBySelector.get(key);
|
|
7522
|
+
if (existingRule) {
|
|
7523
|
+
const existingProps = propsBySelector.get(key) ?? /* @__PURE__ */ new Set();
|
|
7524
|
+
const nextNodes = (rule.nodes ?? []).filter((node) => {
|
|
7525
|
+
if (node.type !== "decl") return true;
|
|
7526
|
+
if (existingProps.has(node.prop)) return false;
|
|
7527
|
+
existingProps.add(node.prop);
|
|
7528
|
+
return true;
|
|
7529
|
+
});
|
|
7530
|
+
existingRule.append(...nextNodes.map((node) => node.clone()));
|
|
7531
|
+
reorderPreflightResetDeclarations(existingRule);
|
|
7532
|
+
propsBySelector.set(key, existingProps);
|
|
7533
|
+
continue;
|
|
7479
7534
|
}
|
|
7480
|
-
|
|
7481
|
-
|
|
7535
|
+
ruleBySelector.set(key, rule);
|
|
7536
|
+
propsBySelector.set(key, new Set((rule.nodes ?? []).flatMap((node) => node.type === "decl" ? [node.prop] : [])));
|
|
7537
|
+
reorderPreflightResetDeclarations(rule);
|
|
7538
|
+
mergedRules.push(rule);
|
|
7539
|
+
}
|
|
7540
|
+
return mergedRules;
|
|
7482
7541
|
}
|
|
7483
7542
|
//#endregion
|
|
7484
|
-
//#region src/compat/mini-program-css/
|
|
7485
|
-
const
|
|
7486
|
-
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
7487
|
-
const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
|
|
7488
|
-
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR = "::before,\n::after";
|
|
7543
|
+
//#region src/compat/mini-program-css/preflight.ts
|
|
7544
|
+
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1 = "::before,\n::after";
|
|
7489
7545
|
const MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS = new Set(["::before", "::after"]);
|
|
7490
7546
|
function createPseudoContentInitRule() {
|
|
7491
|
-
const rule = postcss.rule({ selector: MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR });
|
|
7547
|
+
const rule = postcss.rule({ selector: MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1 });
|
|
7492
7548
|
rule.append({
|
|
7493
7549
|
prop: "--tw-content",
|
|
7494
7550
|
value: "''"
|
|
@@ -7529,7 +7585,7 @@ function collectPreflightRules(root, options = {}) {
|
|
|
7529
7585
|
for (const rule of clonedPreflightRules) {
|
|
7530
7586
|
const selectors = getRuleSelectors(rule);
|
|
7531
7587
|
const hasElementSelector = selectors.some((selector) => selector === "view" || selector === "text");
|
|
7532
|
-
if (selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS.has(selector))) rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR;
|
|
7588
|
+
if (selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS.has(selector))) rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1;
|
|
7533
7589
|
else if (hasElementSelector && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector))) {
|
|
7534
7590
|
rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
|
|
7535
7591
|
applyConfiguredPreflightDeclarations(rule, options.cssPreflight);
|
|
@@ -7552,6 +7608,126 @@ function createPreflightResetRule(cssPreflight) {
|
|
|
7552
7608
|
}
|
|
7553
7609
|
return rule.nodes?.length ? rule : void 0;
|
|
7554
7610
|
}
|
|
7611
|
+
//#endregion
|
|
7612
|
+
//#region src/compat/mini-program-css/color-gamut.ts
|
|
7613
|
+
const DISPLAY_P3_VALUE_RE = /color\(\s*display-p3\b/i;
|
|
7614
|
+
const COLOR_GAMUT_P3_RE = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
|
|
7615
|
+
function isDisplayP3MediaRule(atRule) {
|
|
7616
|
+
return atRule.name === "media" && COLOR_GAMUT_P3_RE.test(atRule.params);
|
|
7617
|
+
}
|
|
7618
|
+
function isDisplayP3Declaration(decl) {
|
|
7619
|
+
return DISPLAY_P3_VALUE_RE.test(decl.value);
|
|
7620
|
+
}
|
|
7621
|
+
//#endregion
|
|
7622
|
+
//#region src/compat/mini-program-css/root-cleanups.ts
|
|
7623
|
+
function removeSpecificityPlaceholders(root) {
|
|
7624
|
+
root.walkRules((rule) => {
|
|
7625
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
7626
|
+
let changed = false;
|
|
7627
|
+
const selectors = rule.selectors.map((selector) => {
|
|
7628
|
+
let next = selector;
|
|
7629
|
+
for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (next.includes(suffix)) next = next.split(suffix).join("");
|
|
7630
|
+
if (next !== selector) changed = true;
|
|
7631
|
+
return next;
|
|
7632
|
+
});
|
|
7633
|
+
if (changed) rule.selectors = selectors;
|
|
7634
|
+
});
|
|
7635
|
+
}
|
|
7636
|
+
function isEffectivelyEmptyContainer(container) {
|
|
7637
|
+
return !container.nodes || container.nodes.every((node) => node.type === "comment");
|
|
7638
|
+
}
|
|
7639
|
+
function removeEmptyAtRuleAncestors(parent) {
|
|
7640
|
+
while (parent?.type === "atrule" && isEffectivelyEmptyContainer(parent)) {
|
|
7641
|
+
const nextParent = parent.parent;
|
|
7642
|
+
parent.remove();
|
|
7643
|
+
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
7644
|
+
}
|
|
7645
|
+
}
|
|
7646
|
+
function removeUnsupportedBrowserSelectors(root) {
|
|
7647
|
+
root.walkRules((rule) => {
|
|
7648
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
7649
|
+
const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
|
|
7650
|
+
if (selectors.length === rule.selectors.length) return;
|
|
7651
|
+
if (selectors.length === 0) {
|
|
7652
|
+
const parent = rule.parent;
|
|
7653
|
+
rule.remove();
|
|
7654
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7655
|
+
return;
|
|
7656
|
+
}
|
|
7657
|
+
rule.selectors = selectors;
|
|
7658
|
+
});
|
|
7659
|
+
}
|
|
7660
|
+
function removeDeclarationAndEmptyRule$1(decl) {
|
|
7661
|
+
const parent = decl.parent;
|
|
7662
|
+
decl.remove();
|
|
7663
|
+
if (parent?.type === "rule" && parent.nodes.length === 0) {
|
|
7664
|
+
const ruleParent = parent.parent;
|
|
7665
|
+
parent.remove();
|
|
7666
|
+
removeEmptyAtRuleAncestors(ruleParent);
|
|
7667
|
+
}
|
|
7668
|
+
}
|
|
7669
|
+
function removeDisplayP3Declarations(root) {
|
|
7670
|
+
root.walkAtRules((atRule) => {
|
|
7671
|
+
if (isDisplayP3MediaRule(atRule)) {
|
|
7672
|
+
const parent = atRule.parent;
|
|
7673
|
+
atRule.remove();
|
|
7674
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7675
|
+
}
|
|
7676
|
+
});
|
|
7677
|
+
}
|
|
7678
|
+
const SIMPLE_MIN_WIDTH_MEDIA_RE = /^\(\s*min-width\s*:[^)]+\)$/i;
|
|
7679
|
+
const TAILWIND_GENERATED_TOKEN_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
|
|
7680
|
+
function isContainerMaxWidthOnlyRule(rule) {
|
|
7681
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7682
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7683
|
+
return declarations.length === 1 && declarations[0]?.prop === "max-width" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7684
|
+
}
|
|
7685
|
+
function removeTailwindContainerMaxWidthMediaRules(root) {
|
|
7686
|
+
root.walkAtRules("media", (atRule) => {
|
|
7687
|
+
if (!SIMPLE_MIN_WIDTH_MEDIA_RE.test(atRule.params.trim())) return;
|
|
7688
|
+
atRule.walkRules((rule) => {
|
|
7689
|
+
if (!isContainerMaxWidthOnlyRule(rule)) return;
|
|
7690
|
+
const parent = rule.parent;
|
|
7691
|
+
rule.remove();
|
|
7692
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7693
|
+
});
|
|
7694
|
+
});
|
|
7695
|
+
}
|
|
7696
|
+
function isContainerWidthOnlyRule(rule) {
|
|
7697
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7698
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7699
|
+
return declarations.length === 1 && declarations[0]?.prop === "width" && declarations[0].value.trim() === "100%" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7700
|
+
}
|
|
7701
|
+
function isTailwindGeneratedContainerRule(rule) {
|
|
7702
|
+
const previous = rule.prev();
|
|
7703
|
+
return previous?.type === "comment" && TAILWIND_GENERATED_TOKEN_COMMENT_RE.test(previous.text);
|
|
7704
|
+
}
|
|
7705
|
+
function removeTailwindContainerWidthRules(root, options = {}) {
|
|
7706
|
+
root.walkRules((rule) => {
|
|
7707
|
+
if (!isContainerWidthOnlyRule(rule)) return;
|
|
7708
|
+
if (options.generatedOnly && !isTailwindGeneratedContainerRule(rule)) return;
|
|
7709
|
+
const parent = rule.parent;
|
|
7710
|
+
if (isTailwindGeneratedContainerRule(rule)) rule.prev()?.remove();
|
|
7711
|
+
rule.remove();
|
|
7712
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7713
|
+
});
|
|
7714
|
+
}
|
|
7715
|
+
function removeUnsupportedModernColorDeclarations(root) {
|
|
7716
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
7717
|
+
root.walkDecls((decl) => {
|
|
7718
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7719
|
+
});
|
|
7720
|
+
root.walkDecls((decl) => {
|
|
7721
|
+
const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
|
|
7722
|
+
if (normalized.changed) {
|
|
7723
|
+
decl.value = normalized.value;
|
|
7724
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7725
|
+
}
|
|
7726
|
+
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule$1(decl);
|
|
7727
|
+
});
|
|
7728
|
+
}
|
|
7729
|
+
//#endregion
|
|
7730
|
+
//#region src/compat/mini-program-css/theme.ts
|
|
7555
7731
|
function collectThemeVariableRule(root, options = {}) {
|
|
7556
7732
|
const themeRules = [];
|
|
7557
7733
|
const declarations = /* @__PURE__ */ new Map();
|
|
@@ -7571,95 +7747,8 @@ function collectThemeVariableRule(root, options = {}) {
|
|
|
7571
7747
|
for (const decl of declarations.values()) rule.append(decl);
|
|
7572
7748
|
return rule;
|
|
7573
7749
|
}
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
const root = postcss.parse(css);
|
|
7577
|
-
let hasProperty = false;
|
|
7578
|
-
root.walkAtRules("property", (atRule) => {
|
|
7579
|
-
if (atRule.params.trim().startsWith("--tw-")) {
|
|
7580
|
-
hasProperty = true;
|
|
7581
|
-
return false;
|
|
7582
|
-
}
|
|
7583
|
-
});
|
|
7584
|
-
return hasProperty;
|
|
7585
|
-
}
|
|
7586
|
-
function getTopDirectiveTail(root) {
|
|
7587
|
-
let tail;
|
|
7588
|
-
for (const node of root.nodes ?? []) {
|
|
7589
|
-
if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
|
|
7590
|
-
tail = node;
|
|
7591
|
-
continue;
|
|
7592
|
-
}
|
|
7593
|
-
break;
|
|
7594
|
-
}
|
|
7595
|
-
return tail;
|
|
7596
|
-
}
|
|
7597
|
-
function createHoistInsertionAnchor(root) {
|
|
7598
|
-
for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
|
|
7599
|
-
const anchor = postcss.comment({ text: HOIST_ANCHOR_COMMENT });
|
|
7600
|
-
node.before(anchor);
|
|
7601
|
-
return anchor;
|
|
7602
|
-
}
|
|
7603
|
-
}
|
|
7604
|
-
function insertHoistedRules(root, rules, anchor) {
|
|
7605
|
-
if (anchor && !anchor.parent) anchor = void 0;
|
|
7606
|
-
if (rules.length === 0) {
|
|
7607
|
-
anchor?.remove();
|
|
7608
|
-
return;
|
|
7609
|
-
}
|
|
7610
|
-
const topDirectiveTail = getTopDirectiveTail(root);
|
|
7611
|
-
const firstRule = rules[0];
|
|
7612
|
-
if (!firstRule) return;
|
|
7613
|
-
if (anchor) {
|
|
7614
|
-
if (anchor.raws.before === void 0) delete firstRule.raws.before;
|
|
7615
|
-
else firstRule.raws.before = anchor.raws.before;
|
|
7616
|
-
anchor.replaceWith(rules);
|
|
7617
|
-
return;
|
|
7618
|
-
}
|
|
7619
|
-
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
7620
|
-
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
7621
|
-
else root.prepend(rules);
|
|
7622
|
-
}
|
|
7623
|
-
function mergeEquivalentHoistedRules(rules) {
|
|
7624
|
-
const mergedRules = [];
|
|
7625
|
-
const ruleBySelector = /* @__PURE__ */ new Map();
|
|
7626
|
-
const propsBySelector = /* @__PURE__ */ new Map();
|
|
7627
|
-
for (const rule of rules) {
|
|
7628
|
-
const key = getSortedRuleSelectorKey(rule);
|
|
7629
|
-
const existingRule = ruleBySelector.get(key);
|
|
7630
|
-
if (existingRule) {
|
|
7631
|
-
const existingProps = propsBySelector.get(key) ?? /* @__PURE__ */ new Set();
|
|
7632
|
-
const nextNodes = (rule.nodes ?? []).filter((node) => {
|
|
7633
|
-
if (node.type !== "decl") return true;
|
|
7634
|
-
if (existingProps.has(node.prop)) return false;
|
|
7635
|
-
existingProps.add(node.prop);
|
|
7636
|
-
return true;
|
|
7637
|
-
});
|
|
7638
|
-
existingRule.append(...nextNodes.map((node) => node.clone()));
|
|
7639
|
-
propsBySelector.set(key, existingProps);
|
|
7640
|
-
continue;
|
|
7641
|
-
}
|
|
7642
|
-
ruleBySelector.set(key, rule);
|
|
7643
|
-
propsBySelector.set(key, new Set((rule.nodes ?? []).flatMap((node) => node.type === "decl" ? [node.prop] : [])));
|
|
7644
|
-
mergedRules.push(rule);
|
|
7645
|
-
}
|
|
7646
|
-
return mergedRules;
|
|
7647
|
-
}
|
|
7648
|
-
function unwrapTailwindSourceMedia(root) {
|
|
7649
|
-
root.walkAtRules("media", (atRule) => {
|
|
7650
|
-
if (!atRule.params.startsWith("source(")) return;
|
|
7651
|
-
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
7652
|
-
else atRule.remove();
|
|
7653
|
-
});
|
|
7654
|
-
}
|
|
7655
|
-
function removeTailwindGenerationDirectives(root) {
|
|
7656
|
-
root.walkComments((comment) => {
|
|
7657
|
-
if (GENERATOR_PLACEHOLDER_COMMENT_RE.test(comment.text)) comment.remove();
|
|
7658
|
-
});
|
|
7659
|
-
root.walkAtRules((atRule) => {
|
|
7660
|
-
if (atRule.name === "config" || atRule.name === "source" || atRule.name === "tailwind" || atRule.name === "reference" || atRule.name === "plugin") atRule.remove();
|
|
7661
|
-
});
|
|
7662
|
-
}
|
|
7750
|
+
//#endregion
|
|
7751
|
+
//#region src/compat/mini-program-css/finalize.ts
|
|
7663
7752
|
function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
7664
7753
|
const shouldInjectTailwindcssV4Defaults = options.isTailwindcssV4 === true;
|
|
7665
7754
|
const tailwindcssV4DefaultNodes = shouldInjectTailwindcssV4Defaults ? createMissingCssVarsV4Nodes(root, collectUsedTailwindcssV4Variables(root)) : [];
|
|
@@ -7672,6 +7761,8 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
7672
7761
|
removeSpecificityPlaceholders(root);
|
|
7673
7762
|
removeUnsupportedBrowserSelectors(root);
|
|
7674
7763
|
removeDisplayP3Declarations(root);
|
|
7764
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7765
|
+
removeTailwindContainerWidthRules(root, { generatedOnly: true });
|
|
7675
7766
|
removeUnsupportedModernColorDeclarations(root);
|
|
7676
7767
|
root.walkDecls((decl) => {
|
|
7677
7768
|
if (shouldInjectTailwindcssV4Defaults) normalizeTailwindcssV4Declaration(decl);
|
|
@@ -7724,6 +7815,7 @@ function finalizeMiniProgramCss(css, options = {}) {
|
|
|
7724
7815
|
//#endregion
|
|
7725
7816
|
//#region src/compat/mini-program-css/prune-generated.ts
|
|
7726
7817
|
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
7818
|
+
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR = "::before,\n::after";
|
|
7727
7819
|
const CLASS_SELECTOR_RE$1 = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
7728
7820
|
function isConditionalCompilationComment(text) {
|
|
7729
7821
|
return /#(?:ifn?def|endif)\b/.test(text);
|
|
@@ -7740,6 +7832,23 @@ function isMiniProgramElementVariableScopeRule(rule) {
|
|
|
7740
7832
|
const selectors = getRuleSelectors(rule);
|
|
7741
7833
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector));
|
|
7742
7834
|
}
|
|
7835
|
+
function isOnlyTwContentDeclarations(rule) {
|
|
7836
|
+
let hasDeclaration = false;
|
|
7837
|
+
let onlyContentVariable = true;
|
|
7838
|
+
rule.walkDecls((decl) => {
|
|
7839
|
+
hasDeclaration = true;
|
|
7840
|
+
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
7841
|
+
});
|
|
7842
|
+
return hasDeclaration && onlyContentVariable;
|
|
7843
|
+
}
|
|
7844
|
+
function isMiniProgramElementContentInitRule(rule) {
|
|
7845
|
+
if (!isMiniProgramElementVariableScopeRule(rule)) return false;
|
|
7846
|
+
let hasElementSelector = false;
|
|
7847
|
+
let hasPseudoSelector = false;
|
|
7848
|
+
for (const selector of getRuleSelectors(rule)) if (selector === "view" || selector === "text") hasElementSelector = true;
|
|
7849
|
+
else if (selector === "::before" || selector === "::after") hasPseudoSelector = true;
|
|
7850
|
+
return hasElementSelector && hasPseudoSelector && isOnlyTwContentDeclarations(rule);
|
|
7851
|
+
}
|
|
7743
7852
|
function isTailwindV4GradientRuntimeDeclaration(decl) {
|
|
7744
7853
|
return decl.prop.startsWith("--tw-gradient-");
|
|
7745
7854
|
}
|
|
@@ -7777,6 +7886,8 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7777
7886
|
});
|
|
7778
7887
|
removeUnsupportedCascadeLayers(root);
|
|
7779
7888
|
removeUnsupportedModernColorDeclarations(root);
|
|
7889
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7890
|
+
removeTailwindContainerWidthRules(root);
|
|
7780
7891
|
root.walkAtRules("supports", (atRule) => {
|
|
7781
7892
|
atRule.remove();
|
|
7782
7893
|
});
|
|
@@ -7788,6 +7899,18 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7788
7899
|
});
|
|
7789
7900
|
root.walkRules((rule) => {
|
|
7790
7901
|
if (isKeyframesRule(rule)) return;
|
|
7902
|
+
if (isPseudoContentInitRule(rule)) {
|
|
7903
|
+
if (!shouldPreserveContentInit) rule.remove();
|
|
7904
|
+
return;
|
|
7905
|
+
}
|
|
7906
|
+
if (isMiniProgramElementContentInitRule(rule)) {
|
|
7907
|
+
if (!shouldPreserveContentInit) {
|
|
7908
|
+
rule.remove();
|
|
7909
|
+
return;
|
|
7910
|
+
}
|
|
7911
|
+
rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR;
|
|
7912
|
+
return;
|
|
7913
|
+
}
|
|
7791
7914
|
if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
|
|
7792
7915
|
rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
|
|
7793
7916
|
return;
|
|
@@ -7800,10 +7923,6 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7800
7923
|
}
|
|
7801
7924
|
if (hasClassSelector$2(rule.selector)) return;
|
|
7802
7925
|
if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
|
|
7803
|
-
if (isPseudoContentInitRule(rule)) {
|
|
7804
|
-
if (!shouldPreserveContentInit) rule.remove();
|
|
7805
|
-
return;
|
|
7806
|
-
}
|
|
7807
7926
|
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
7808
7927
|
if (isCustomPropertyRule(rule)) {
|
|
7809
7928
|
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
@@ -43158,7 +43277,7 @@ const n$9 = "js-blank-pseudo", t$12 = ":blank", creator$48 = (s) => {
|
|
|
43158
43277
|
};
|
|
43159
43278
|
creator$48.postcss = !0;
|
|
43160
43279
|
//#endregion
|
|
43161
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-specificity@6.0.0_postcss-selector-parser@7.1.
|
|
43280
|
+
//#region ../../node_modules/.pnpm/@csstools+selector-specificity@6.0.0_postcss-selector-parser@7.1.2/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
43162
43281
|
var import_postcss_page_break = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
43163
43282
|
module.exports = function(options) {
|
|
43164
43283
|
return {
|
|
@@ -49953,7 +50072,7 @@ const creator$18 = (s) => {
|
|
|
49953
50072
|
};
|
|
49954
50073
|
creator$18.postcss = !0;
|
|
49955
50074
|
//#endregion
|
|
49956
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-resolve-nested@4.0.0_postcss-selector-parser@7.1.
|
|
50075
|
+
//#region ../../node_modules/.pnpm/@csstools+selector-resolve-nested@4.0.0_postcss-selector-parser@7.1.2/node_modules/@csstools/selector-resolve-nested/dist/index.mjs
|
|
49957
50076
|
function sourceFrom(e) {
|
|
49958
50077
|
return {
|
|
49959
50078
|
sourceIndex: e.sourceIndex ?? 0,
|
|
@@ -53161,10 +53280,7 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
53161
53280
|
for (const declarations of grouped.values()) dedupeSpacingGroup(rule, declarations);
|
|
53162
53281
|
}
|
|
53163
53282
|
//#endregion
|
|
53164
|
-
//#region src/selectorParser/rule-transformer.ts
|
|
53165
|
-
const ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
53166
|
-
const SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
53167
|
-
const SIMPLE_SELECTOR_FAST_PATH = /^[#.][\w-]+(?:\s+[#.][\w-]+)*$/;
|
|
53283
|
+
//#region src/selectorParser/rule-transformer/pseudos.ts
|
|
53168
53284
|
const RTL_LANGUAGE_ANY_PSEUDO_SET = new Set([
|
|
53169
53285
|
":-moz-any",
|
|
53170
53286
|
":-webkit-any",
|
|
@@ -53180,6 +53296,23 @@ const EMPTY_FUNCTIONAL_PSEUDO_CLEANUP_SET = new Set([
|
|
|
53180
53296
|
":-moz-any",
|
|
53181
53297
|
":lang"
|
|
53182
53298
|
]);
|
|
53299
|
+
const UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53300
|
+
":after",
|
|
53301
|
+
":before",
|
|
53302
|
+
"::after",
|
|
53303
|
+
"::before",
|
|
53304
|
+
"::backdrop",
|
|
53305
|
+
"::-ms-backdrop",
|
|
53306
|
+
"::-webkit-backdrop",
|
|
53307
|
+
"::file-selector-button"
|
|
53308
|
+
]);
|
|
53309
|
+
const MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53310
|
+
"::backdrop",
|
|
53311
|
+
"::-ms-backdrop",
|
|
53312
|
+
"::-webkit-backdrop",
|
|
53313
|
+
"::file-selector-button"
|
|
53314
|
+
]);
|
|
53315
|
+
const NORMALIZED_PSEUDO_ELEMENT_SELECTOR = new Map([[":before", "::before"], [":after", "::after"]]);
|
|
53183
53316
|
function isRtlLanguageAnyPseudo(node) {
|
|
53184
53317
|
return node.type === "pseudo" && RTL_LANGUAGE_ANY_PSEUDO_SET.has(node.value);
|
|
53185
53318
|
}
|
|
@@ -53216,6 +53349,29 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
53216
53349
|
if (parent && parent.type === "selector" && parent.length === 0) parent.remove();
|
|
53217
53350
|
}
|
|
53218
53351
|
}
|
|
53352
|
+
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
53353
|
+
if (!isUniAppXEnabled(options)) return selector.nodes.some((node) => node.type === "pseudo" && MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53354
|
+
return selector.nodes.some((node) => node.type === "pseudo" && UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53355
|
+
}
|
|
53356
|
+
function handlePseudoNode(node, index, context, parent) {
|
|
53357
|
+
if (node.type !== "pseudo") return;
|
|
53358
|
+
if (isRtlLanguageAnyPseudo(node)) {
|
|
53359
|
+
stripUnsupportedRtlLanguagePseudo(node);
|
|
53360
|
+
return;
|
|
53361
|
+
}
|
|
53362
|
+
if (node.value === ":root" && context.rootReplacement) {
|
|
53363
|
+
node.value = context.rootReplacement;
|
|
53364
|
+
return;
|
|
53365
|
+
}
|
|
53366
|
+
const normalizedPseudoElement = NORMALIZED_PSEUDO_ELEMENT_SELECTOR.get(node.value);
|
|
53367
|
+
if (normalizedPseudoElement) {
|
|
53368
|
+
node.value = normalizedPseudoElement;
|
|
53369
|
+
return;
|
|
53370
|
+
}
|
|
53371
|
+
if (node.value === ":where") flattenWherePseudo(node, context, index, parent);
|
|
53372
|
+
}
|
|
53373
|
+
//#endregion
|
|
53374
|
+
//#region src/selectorParser/rule-transformer/nodes.ts
|
|
53219
53375
|
function handleClassNode(node, context) {
|
|
53220
53376
|
if (node.type !== "class") return;
|
|
53221
53377
|
node.value = context.selectorReplacerOptions === void 0 ? internalCssSelectorReplacer(node.value) : internalCssSelectorReplacer(node.value, context.selectorReplacerOptions);
|
|
@@ -53228,27 +53384,6 @@ function shouldRemoveHoverSelector(selector, options) {
|
|
|
53228
53384
|
if (!options.cssRemoveHoverPseudoClass) return false;
|
|
53229
53385
|
return selector.nodes.some((node) => node.type === "pseudo" && node.value === ":hover");
|
|
53230
53386
|
}
|
|
53231
|
-
const UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53232
|
-
":after",
|
|
53233
|
-
":before",
|
|
53234
|
-
"::after",
|
|
53235
|
-
"::before",
|
|
53236
|
-
"::backdrop",
|
|
53237
|
-
"::-ms-backdrop",
|
|
53238
|
-
"::-webkit-backdrop",
|
|
53239
|
-
"::file-selector-button"
|
|
53240
|
-
]);
|
|
53241
|
-
const MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53242
|
-
"::backdrop",
|
|
53243
|
-
"::-ms-backdrop",
|
|
53244
|
-
"::-webkit-backdrop",
|
|
53245
|
-
"::file-selector-button"
|
|
53246
|
-
]);
|
|
53247
|
-
const NORMALIZED_PSEUDO_ELEMENT_SELECTOR = new Map([[":before", "::before"], [":after", "::after"]]);
|
|
53248
|
-
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
53249
|
-
if (!isUniAppXEnabled(options)) return selector.nodes.some((node) => node.type === "pseudo" && MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53250
|
-
return selector.nodes.some((node) => node.type === "pseudo" && UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53251
|
-
}
|
|
53252
53387
|
function isHiddenOrTemplateNotPseudo(node) {
|
|
53253
53388
|
if (!node || node.type !== "pseudo" || node.value !== ":not") return false;
|
|
53254
53389
|
const selector = node.first;
|
|
@@ -53271,23 +53406,6 @@ function handleCombinatorNode(node, index, context) {
|
|
|
53271
53406
|
nodes.splice(index + 1, 3, ...ast);
|
|
53272
53407
|
}
|
|
53273
53408
|
}
|
|
53274
|
-
function handlePseudoNode(node, index, context, parent) {
|
|
53275
|
-
if (node.type !== "pseudo") return;
|
|
53276
|
-
if (isRtlLanguageAnyPseudo(node)) {
|
|
53277
|
-
stripUnsupportedRtlLanguagePseudo(node);
|
|
53278
|
-
return;
|
|
53279
|
-
}
|
|
53280
|
-
if (node.value === ":root" && context.rootReplacement) {
|
|
53281
|
-
node.value = context.rootReplacement;
|
|
53282
|
-
return;
|
|
53283
|
-
}
|
|
53284
|
-
const normalizedPseudoElement = NORMALIZED_PSEUDO_ELEMENT_SELECTOR.get(node.value);
|
|
53285
|
-
if (normalizedPseudoElement) {
|
|
53286
|
-
node.value = normalizedPseudoElement;
|
|
53287
|
-
return;
|
|
53288
|
-
}
|
|
53289
|
-
if (node.value === ":where") flattenWherePseudo(node, context, index, parent);
|
|
53290
|
-
}
|
|
53291
53409
|
function handleTagOrAttribute(node, context) {
|
|
53292
53410
|
stripUnsupportedNodeForUniAppX(node, context.options);
|
|
53293
53411
|
}
|
|
@@ -53302,6 +53420,11 @@ function handleSelectorNode(selector, context) {
|
|
|
53302
53420
|
}
|
|
53303
53421
|
if (transformSpacingSelector(selector.nodes, context.options)) context.requiresSpacingNormalization = true;
|
|
53304
53422
|
}
|
|
53423
|
+
//#endregion
|
|
53424
|
+
//#region src/selectorParser/rule-transformer.ts
|
|
53425
|
+
const ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
53426
|
+
const SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
53427
|
+
const SIMPLE_SELECTOR_FAST_PATH = /^[#.][\w-]+(?:\s+[#.][\w-]+)*$/;
|
|
53305
53428
|
function canSkipRuleTransform(rule) {
|
|
53306
53429
|
const selector = rule.selector.trim();
|
|
53307
53430
|
if (!selector) return false;
|
|
@@ -54082,11 +54205,46 @@ function makePseudoVarRule() {
|
|
|
54082
54205
|
function isEmptyContentInitDeclaration(decl) {
|
|
54083
54206
|
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
54084
54207
|
}
|
|
54208
|
+
function isPseudoContentInitSelector(selector) {
|
|
54209
|
+
return selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after";
|
|
54210
|
+
}
|
|
54211
|
+
function isElementContentInitSelector(selector) {
|
|
54212
|
+
return selector === "*" || selector === "view" || selector === "text";
|
|
54213
|
+
}
|
|
54214
|
+
function isOnlyEmptyContentInitRule(node) {
|
|
54215
|
+
let hasDeclaration = false;
|
|
54216
|
+
let onlyEmptyContentInit = true;
|
|
54217
|
+
node.walkDecls((decl) => {
|
|
54218
|
+
hasDeclaration = true;
|
|
54219
|
+
if (!isEmptyContentInitDeclaration(decl)) onlyEmptyContentInit = false;
|
|
54220
|
+
});
|
|
54221
|
+
return hasDeclaration && onlyEmptyContentInit;
|
|
54222
|
+
}
|
|
54223
|
+
function restorePseudoContentInitScope(node) {
|
|
54224
|
+
if (!isOnlyEmptyContentInitRule(node)) return false;
|
|
54225
|
+
let hasPseudoSelector = false;
|
|
54226
|
+
let hasElementSelector = false;
|
|
54227
|
+
for (const selector of node.selectors) if (isPseudoContentInitSelector(selector)) hasPseudoSelector = true;
|
|
54228
|
+
else if (isElementContentInitSelector(selector)) hasElementSelector = true;
|
|
54229
|
+
else return false;
|
|
54230
|
+
if (!hasPseudoSelector || !hasElementSelector) return false;
|
|
54231
|
+
assignRuleSelectors(node, ["::before", "::after"], {
|
|
54232
|
+
phase: "pre",
|
|
54233
|
+
reason: "restore-pseudo-content-init-scope"
|
|
54234
|
+
});
|
|
54235
|
+
return true;
|
|
54236
|
+
}
|
|
54085
54237
|
function removeTailwindV4EmptyContentInit(node) {
|
|
54086
54238
|
node.walkDecls((decl) => {
|
|
54087
54239
|
if (isEmptyContentInitDeclaration(decl)) decl.remove();
|
|
54088
54240
|
});
|
|
54089
54241
|
}
|
|
54242
|
+
function injectPreflightDeclarations(node, options) {
|
|
54243
|
+
const preflightDeclarations = options.cssInjectPreflight?.();
|
|
54244
|
+
if (!preflightDeclarations || preflightDeclarations.length === 0) return;
|
|
54245
|
+
node.prepend(...preflightDeclarations);
|
|
54246
|
+
node.raws.semicolon = true;
|
|
54247
|
+
}
|
|
54090
54248
|
function hasClassSelector(node) {
|
|
54091
54249
|
return node.selectors.some((selector) => selector.includes("."));
|
|
54092
54250
|
}
|
|
@@ -54112,7 +54270,7 @@ function resolveUniAppXVariableScopeSelectors(options) {
|
|
|
54112
54270
|
return ["view", "text"];
|
|
54113
54271
|
}
|
|
54114
54272
|
function commonChunkPreflight(node, options) {
|
|
54115
|
-
const { ctx,
|
|
54273
|
+
const { ctx, injectAdditionalCssVarScope } = options;
|
|
54116
54274
|
const uniAppXEnabled = isUniAppXEnabled(options);
|
|
54117
54275
|
const isTailwindcss4 = isTailwindcssV4(options);
|
|
54118
54276
|
const rootOption = options.cssSelectorReplacement?.root;
|
|
@@ -54125,6 +54283,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54125
54283
|
reason: "append-host-selector"
|
|
54126
54284
|
});
|
|
54127
54285
|
if (isTailwindcss4 && !usesTailwindcssV4ContentVariable(node.root()) && (!hasClassSelector(node) || isRootThemeScopeRule(node))) removeTailwindV4EmptyContentInit(node);
|
|
54286
|
+
if (!isTailwindcss4 && restorePseudoContentInitScope(node)) return;
|
|
54128
54287
|
if (testIfVariablesScope(node) || uniAppXEnabled && node.selectors.includes("*") && hasTwVars(node, 2)) {
|
|
54129
54288
|
ctx?.markVariablesScope(node);
|
|
54130
54289
|
assignRuleSelectors(node, uniAppXEnabled ? resolveUniAppXVariableScopeSelectors(options) : remakeCssVarSelector(node.selectors, options), {
|
|
@@ -54132,7 +54291,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54132
54291
|
reason: "rewrite-variable-scope"
|
|
54133
54292
|
});
|
|
54134
54293
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54135
|
-
|
|
54294
|
+
injectPreflightDeclarations(node, options);
|
|
54136
54295
|
}
|
|
54137
54296
|
if (injectAdditionalCssVarScope && (isTailwindcss4 ? testIfRootHostForV4(node) : testIfTwBackdrop(node))) {
|
|
54138
54297
|
const nodes = isTailwindcss4 ? createUsedCssVarsV4Nodes(collectUsedTailwindcssV4Variables(node.root())) : cssVarsV3Nodes;
|
|
@@ -54151,7 +54310,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54151
54310
|
});
|
|
54152
54311
|
node.before(syntheticRule);
|
|
54153
54312
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54154
|
-
|
|
54313
|
+
injectPreflightDeclarations(syntheticRule, options);
|
|
54155
54314
|
}
|
|
54156
54315
|
}
|
|
54157
54316
|
//#endregion
|