@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.js
CHANGED
|
@@ -25,6 +25,38 @@ node_process = require_html_transform.__toESM(node_process);
|
|
|
25
25
|
let postcss_rule_unit_converter = require("postcss-rule-unit-converter");
|
|
26
26
|
postcss_rule_unit_converter = require_html_transform.__toESM(postcss_rule_unit_converter);
|
|
27
27
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
28
|
+
const MODERN_COLOR_FUNCTION_NAMES = new Set([
|
|
29
|
+
"oklch",
|
|
30
|
+
"oklab",
|
|
31
|
+
"lch",
|
|
32
|
+
"lab"
|
|
33
|
+
]);
|
|
34
|
+
const PLACEHOLDER_PREFIX = "__weapp_tw_color_mix_";
|
|
35
|
+
const DYNAMIC_ALPHA_RE = /\b(?:var|env)\(|--[\w-]+\b/;
|
|
36
|
+
const INTERNAL_TAILWIND_ALPHA_RE = /var\(\s*--tw-[^)]+-alpha\s*\)/;
|
|
37
|
+
const TRANSPARENT_COLOR_RE = /^transparent$/i;
|
|
38
|
+
const CURRENT_COLOR_RE = /^currentcolor$/i;
|
|
39
|
+
const CSS_WIDE_KEYWORD_RE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
40
|
+
const CUSTOM_PROPERTY_RE = /^--[\w-]+$/;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/compat/color-mix/modern.ts
|
|
43
|
+
function isDisplayP3ColorFunction(colorSource) {
|
|
44
|
+
return /^color\(\s*display-p3\b/i.test(colorSource.trim());
|
|
45
|
+
}
|
|
46
|
+
function hasUnsupportedModernColorFunction(value) {
|
|
47
|
+
const parsed = (0, postcss_value_parser.default)(value);
|
|
48
|
+
let hasUnsupported = false;
|
|
49
|
+
parsed.walk((node) => {
|
|
50
|
+
if (node.type !== "function") return;
|
|
51
|
+
const name = node.value.toLowerCase();
|
|
52
|
+
if (name === "color-mix" || MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(postcss_value_parser.default.stringify(node))) {
|
|
53
|
+
hasUnsupported = true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return hasUnsupported;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
28
60
|
//#region ../../node_modules/.pnpm/@csstools+css-tokenizer@4.0.0/node_modules/@csstools/css-tokenizer/dist/index.mjs
|
|
29
61
|
var ParseError$1 = class extends Error {
|
|
30
62
|
sourceStart;
|
|
@@ -6524,21 +6556,7 @@ function color(e) {
|
|
|
6524
6556
|
return !1;
|
|
6525
6557
|
}
|
|
6526
6558
|
//#endregion
|
|
6527
|
-
//#region src/compat/color-mix.ts
|
|
6528
|
-
const COLOR_MIX_NAME = "color-mix";
|
|
6529
|
-
const MODERN_COLOR_FUNCTION_NAMES = new Set([
|
|
6530
|
-
"oklch",
|
|
6531
|
-
"oklab",
|
|
6532
|
-
"lch",
|
|
6533
|
-
"lab"
|
|
6534
|
-
]);
|
|
6535
|
-
const PLACEHOLDER_PREFIX = "__weapp_tw_color_mix_";
|
|
6536
|
-
const DYNAMIC_ALPHA_RE = /\b(?:var|env)\(|--[\w-]+\b/;
|
|
6537
|
-
const INTERNAL_TAILWIND_ALPHA_RE = /var\(\s*--tw-[^)]+-alpha\s*\)/;
|
|
6538
|
-
const TRANSPARENT_COLOR_RE = /^transparent$/i;
|
|
6539
|
-
const CURRENT_COLOR_RE = /^currentcolor$/i;
|
|
6540
|
-
const CSS_WIDE_KEYWORD_RE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
|
|
6541
|
-
const CUSTOM_PROPERTY_RE = /^--[\w-]+$/;
|
|
6559
|
+
//#region src/compat/color-mix/parse.ts
|
|
6542
6560
|
function splitArguments(nodes) {
|
|
6543
6561
|
const args = [];
|
|
6544
6562
|
let current = [];
|
|
@@ -6621,51 +6639,8 @@ function normalizeStandaloneColorFunction(colorSource) {
|
|
|
6621
6639
|
const resolvedColor = getParsedColorData(colorSource);
|
|
6622
6640
|
return resolvedColor ? serializeRGB(resolvedColor).toString() : void 0;
|
|
6623
6641
|
}
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
}
|
|
6627
|
-
function hasUnsupportedModernColorFunction(value) {
|
|
6628
|
-
const parsed = (0, postcss_value_parser.default)(value);
|
|
6629
|
-
let hasUnsupported = false;
|
|
6630
|
-
parsed.walk((node) => {
|
|
6631
|
-
if (node.type !== "function") return;
|
|
6632
|
-
const name = node.value.toLowerCase();
|
|
6633
|
-
if (name === COLOR_MIX_NAME || MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(postcss_value_parser.default.stringify(node))) {
|
|
6634
|
-
hasUnsupported = true;
|
|
6635
|
-
return false;
|
|
6636
|
-
}
|
|
6637
|
-
});
|
|
6638
|
-
return hasUnsupported;
|
|
6639
|
-
}
|
|
6640
|
-
function normalizeModernColorValue(value, customPropertyValues = /* @__PURE__ */ new Map()) {
|
|
6641
|
-
if (!hasUnsupportedModernColorFunction(value)) return {
|
|
6642
|
-
value,
|
|
6643
|
-
changed: false,
|
|
6644
|
-
hasUnsupported: false
|
|
6645
|
-
};
|
|
6646
|
-
const parsed = (0, postcss_value_parser.default)(value);
|
|
6647
|
-
let changed = false;
|
|
6648
|
-
parsed.walk((node) => {
|
|
6649
|
-
if (node.type !== "function") return;
|
|
6650
|
-
const name = node.value.toLowerCase();
|
|
6651
|
-
const source = postcss_value_parser.default.stringify(node);
|
|
6652
|
-
let normalized;
|
|
6653
|
-
if (MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(source)) normalized = normalizeStandaloneColorFunction(source);
|
|
6654
|
-
else if (name === COLOR_MIX_NAME) normalized = tryResolveColorMix(node, customPropertyValues)?.value;
|
|
6655
|
-
if (!normalized) return;
|
|
6656
|
-
const mutableNode = node;
|
|
6657
|
-
mutableNode.type = "word";
|
|
6658
|
-
mutableNode.value = normalized;
|
|
6659
|
-
delete mutableNode.nodes;
|
|
6660
|
-
changed = true;
|
|
6661
|
-
});
|
|
6662
|
-
const nextValue = changed ? parsed.toString() : value;
|
|
6663
|
-
return {
|
|
6664
|
-
value: nextValue,
|
|
6665
|
-
changed,
|
|
6666
|
-
hasUnsupported: hasUnsupportedModernColorFunction(nextValue)
|
|
6667
|
-
};
|
|
6668
|
-
}
|
|
6642
|
+
//#endregion
|
|
6643
|
+
//#region src/compat/color-mix/resolve.ts
|
|
6669
6644
|
function createRgbaWithAlpha(colorSource, alphaSource, customPropertyValues) {
|
|
6670
6645
|
const resolvedColor = resolveColorData(colorSource, customPropertyValues);
|
|
6671
6646
|
if (!resolvedColor) return;
|
|
@@ -6711,17 +6686,48 @@ function tryResolveColorMix(node, customPropertyValues) {
|
|
|
6711
6686
|
deferred: false
|
|
6712
6687
|
};
|
|
6713
6688
|
}
|
|
6689
|
+
//#endregion
|
|
6690
|
+
//#region src/compat/color-mix.ts
|
|
6691
|
+
function normalizeModernColorValue(value, customPropertyValues = /* @__PURE__ */ new Map()) {
|
|
6692
|
+
if (!hasUnsupportedModernColorFunction(value)) return {
|
|
6693
|
+
value,
|
|
6694
|
+
changed: false,
|
|
6695
|
+
hasUnsupported: false
|
|
6696
|
+
};
|
|
6697
|
+
const parsed = (0, postcss_value_parser.default)(value);
|
|
6698
|
+
let changed = false;
|
|
6699
|
+
parsed.walk((node) => {
|
|
6700
|
+
if (node.type !== "function") return;
|
|
6701
|
+
const name = node.value.toLowerCase();
|
|
6702
|
+
const source = postcss_value_parser.default.stringify(node);
|
|
6703
|
+
let normalized;
|
|
6704
|
+
if (MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(source)) normalized = normalizeStandaloneColorFunction(source);
|
|
6705
|
+
else if (name === "color-mix") normalized = tryResolveColorMix(node, customPropertyValues)?.value;
|
|
6706
|
+
if (!normalized) return;
|
|
6707
|
+
const mutableNode = node;
|
|
6708
|
+
mutableNode.type = "word";
|
|
6709
|
+
mutableNode.value = normalized;
|
|
6710
|
+
delete mutableNode.nodes;
|
|
6711
|
+
changed = true;
|
|
6712
|
+
});
|
|
6713
|
+
const nextValue = changed ? parsed.toString() : value;
|
|
6714
|
+
return {
|
|
6715
|
+
value: nextValue,
|
|
6716
|
+
changed,
|
|
6717
|
+
hasUnsupported: hasUnsupportedModernColorFunction(nextValue)
|
|
6718
|
+
};
|
|
6719
|
+
}
|
|
6714
6720
|
function createPlaceholder(index) {
|
|
6715
6721
|
return `${PLACEHOLDER_PREFIX}${index}__`;
|
|
6716
6722
|
}
|
|
6717
6723
|
function unwrapProtectedSupports(cssRoot) {
|
|
6718
6724
|
cssRoot.walkAtRules("supports", (atRule) => {
|
|
6719
|
-
if (!atRule.nodes || !atRule.toString().includes(
|
|
6725
|
+
if (!atRule.nodes || !atRule.toString().includes("__weapp_tw_color_mix_")) return;
|
|
6720
6726
|
atRule.replaceWith(atRule.nodes);
|
|
6721
6727
|
});
|
|
6722
6728
|
}
|
|
6723
6729
|
function protectDynamicColorMixAlpha(css, options = {}) {
|
|
6724
|
-
if (!css.includes(
|
|
6730
|
+
if (!css.includes("color-mix")) return {
|
|
6725
6731
|
css,
|
|
6726
6732
|
restore: (value) => value
|
|
6727
6733
|
};
|
|
@@ -6730,14 +6736,14 @@ function protectDynamicColorMixAlpha(css, options = {}) {
|
|
|
6730
6736
|
const customPropertyValues = new Map(options.customPropertyValues);
|
|
6731
6737
|
let changed = false;
|
|
6732
6738
|
root.walkDecls((decl) => {
|
|
6733
|
-
if (decl.prop.startsWith("--") && !decl.value.includes(
|
|
6739
|
+
if (decl.prop.startsWith("--") && !decl.value.includes("color-mix")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
6734
6740
|
});
|
|
6735
6741
|
root.walkDecls((decl) => {
|
|
6736
|
-
if (!decl.value.includes(
|
|
6742
|
+
if (!decl.value.includes("color-mix")) return;
|
|
6737
6743
|
const parsed = (0, postcss_value_parser.default)(decl.value);
|
|
6738
6744
|
let mutated = false;
|
|
6739
6745
|
parsed.walk((node) => {
|
|
6740
|
-
if (node.type !== "function" || node.value.toLowerCase() !==
|
|
6746
|
+
if (node.type !== "function" || node.value.toLowerCase() !== "color-mix") return;
|
|
6741
6747
|
const resolved = tryResolveColorMix(node, customPropertyValues);
|
|
6742
6748
|
if (resolved) {
|
|
6743
6749
|
if (resolved.deferred) {
|
|
@@ -7193,7 +7199,27 @@ function isTailwindcssV4DisplayP3Media(atRule) {
|
|
|
7193
7199
|
function isTailwindcssV4DisplayP3Declaration(decl) {
|
|
7194
7200
|
return DISPLAY_P3_VALUE_RE$1.test(decl.value);
|
|
7195
7201
|
}
|
|
7202
|
+
function normalizeTailwindcssV4EmptyVarFallback(value) {
|
|
7203
|
+
if (!value.includes("var(") || !value.includes("--tw-")) return value;
|
|
7204
|
+
const parsed = (0, postcss_value_parser.default)(value);
|
|
7205
|
+
let changed = false;
|
|
7206
|
+
parsed.walk((node) => {
|
|
7207
|
+
if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
|
|
7208
|
+
const firstArg = node.nodes.find((child) => child.type !== "space");
|
|
7209
|
+
const lastArg = node.nodes.findLast((child) => child.type !== "space");
|
|
7210
|
+
if (firstArg?.type !== "word" || !firstArg.value.startsWith("--tw-") || lastArg?.type !== "div" || lastArg.value !== "," || node.after === " ") return;
|
|
7211
|
+
node.after = " ";
|
|
7212
|
+
changed = true;
|
|
7213
|
+
});
|
|
7214
|
+
return changed ? parsed.toString() : value;
|
|
7215
|
+
}
|
|
7196
7216
|
function normalizeTailwindcssV4Declaration(decl) {
|
|
7217
|
+
let changed = false;
|
|
7218
|
+
const normalizedEmptyVarFallback = normalizeTailwindcssV4EmptyVarFallback(decl.value);
|
|
7219
|
+
if (normalizedEmptyVarFallback !== decl.value) {
|
|
7220
|
+
decl.value = normalizedEmptyVarFallback;
|
|
7221
|
+
changed = true;
|
|
7222
|
+
}
|
|
7197
7223
|
if (decl.prop === "--tw-gradient-position" && decl.value.endsWith(OKLAB_SUFFIX)) {
|
|
7198
7224
|
decl.value = decl.value.slice(0, decl.value.length - 8).trimEnd();
|
|
7199
7225
|
return true;
|
|
@@ -7215,17 +7241,38 @@ function normalizeTailwindcssV4Declaration(decl) {
|
|
|
7215
7241
|
return true;
|
|
7216
7242
|
}
|
|
7217
7243
|
}
|
|
7218
|
-
return
|
|
7244
|
+
return changed;
|
|
7219
7245
|
}
|
|
7220
7246
|
//#endregion
|
|
7221
|
-
//#region src/compat/mini-program-css/
|
|
7222
|
-
const
|
|
7223
|
-
const
|
|
7224
|
-
function
|
|
7225
|
-
|
|
7247
|
+
//#region src/compat/mini-program-css/directives.ts
|
|
7248
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
7249
|
+
const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
|
|
7250
|
+
function hasTailwindcssV4Signal(css) {
|
|
7251
|
+
if (TAILWIND_V4_BANNER_RE.test(css)) return true;
|
|
7252
|
+
const root = postcss.default.parse(css);
|
|
7253
|
+
let hasProperty = false;
|
|
7254
|
+
root.walkAtRules("property", (atRule) => {
|
|
7255
|
+
if (atRule.params.trim().startsWith("--tw-")) {
|
|
7256
|
+
hasProperty = true;
|
|
7257
|
+
return false;
|
|
7258
|
+
}
|
|
7259
|
+
});
|
|
7260
|
+
return hasProperty;
|
|
7226
7261
|
}
|
|
7227
|
-
function
|
|
7228
|
-
|
|
7262
|
+
function unwrapTailwindSourceMedia(root) {
|
|
7263
|
+
root.walkAtRules("media", (atRule) => {
|
|
7264
|
+
if (!atRule.params.startsWith("source(")) return;
|
|
7265
|
+
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
7266
|
+
else atRule.remove();
|
|
7267
|
+
});
|
|
7268
|
+
}
|
|
7269
|
+
function removeTailwindGenerationDirectives(root) {
|
|
7270
|
+
root.walkComments((comment) => {
|
|
7271
|
+
if (GENERATOR_PLACEHOLDER_COMMENT_RE.test(comment.text)) comment.remove();
|
|
7272
|
+
});
|
|
7273
|
+
root.walkAtRules((atRule) => {
|
|
7274
|
+
if (atRule.name === "config" || atRule.name === "source" || atRule.name === "tailwind" || atRule.name === "reference" || atRule.name === "plugin") atRule.remove();
|
|
7275
|
+
});
|
|
7229
7276
|
}
|
|
7230
7277
|
//#endregion
|
|
7231
7278
|
//#region src/compat/mini-program-css/selectors.ts
|
|
@@ -7372,7 +7419,7 @@ function isCustomPropertyRule(rule) {
|
|
|
7372
7419
|
function isEmptyTwContentDeclaration(decl) {
|
|
7373
7420
|
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
7374
7421
|
}
|
|
7375
|
-
function isOnlyTwContentDeclarations(rule) {
|
|
7422
|
+
function isOnlyTwContentDeclarations$1(rule) {
|
|
7376
7423
|
let hasDeclaration = false;
|
|
7377
7424
|
let onlyContentVariable = true;
|
|
7378
7425
|
rule.walkDecls((decl) => {
|
|
@@ -7383,7 +7430,7 @@ function isOnlyTwContentDeclarations(rule) {
|
|
|
7383
7430
|
}
|
|
7384
7431
|
function isPseudoContentInitRule(rule) {
|
|
7385
7432
|
const selector = rule.selector.replace(/\s+/g, "");
|
|
7386
|
-
return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations(rule);
|
|
7433
|
+
return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations$1(rule);
|
|
7387
7434
|
}
|
|
7388
7435
|
function usesTwContentVariable(root) {
|
|
7389
7436
|
let used = false;
|
|
@@ -7401,82 +7448,92 @@ function isMiniProgramThemeVariableRule(node) {
|
|
|
7401
7448
|
return isMiniProgramThemeScopeSelector(getRuleSelectors(node)) && isCustomPropertyRule(node);
|
|
7402
7449
|
}
|
|
7403
7450
|
//#endregion
|
|
7404
|
-
//#region src/compat/mini-program-css/
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
});
|
|
7415
|
-
if (changed) rule.selectors = selectors;
|
|
7416
|
-
});
|
|
7417
|
-
}
|
|
7418
|
-
function removeEmptyAtRuleAncestors(parent) {
|
|
7419
|
-
while (parent?.type === "atrule" && (!parent.nodes || parent.nodes.length === 0)) {
|
|
7420
|
-
const nextParent = parent.parent;
|
|
7421
|
-
parent.remove();
|
|
7422
|
-
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
7451
|
+
//#region src/compat/mini-program-css/hoist.ts
|
|
7452
|
+
const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
|
|
7453
|
+
function getTopDirectiveTail(root) {
|
|
7454
|
+
let tail;
|
|
7455
|
+
for (const node of root.nodes ?? []) {
|
|
7456
|
+
if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
|
|
7457
|
+
tail = node;
|
|
7458
|
+
continue;
|
|
7459
|
+
}
|
|
7460
|
+
break;
|
|
7423
7461
|
}
|
|
7462
|
+
return tail;
|
|
7424
7463
|
}
|
|
7425
|
-
function
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7464
|
+
function reorderPreflightResetDeclarations(rule) {
|
|
7465
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
7466
|
+
if (declarations.length <= 1) return;
|
|
7467
|
+
const resetDeclarations = [];
|
|
7468
|
+
const otherDeclarations = [];
|
|
7469
|
+
for (const declaration of declarations) if (PREFLIGHT_RESET_PROPS.has(declaration.prop)) resetDeclarations.push(declaration);
|
|
7470
|
+
else otherDeclarations.push(declaration);
|
|
7471
|
+
if (resetDeclarations.length === 0 || otherDeclarations.length === 0) return;
|
|
7472
|
+
const orderedDeclarations = [...resetDeclarations, ...otherDeclarations];
|
|
7473
|
+
if (orderedDeclarations.every((declaration, index) => declaration === declarations[index])) return;
|
|
7474
|
+
for (const declaration of declarations) declaration.remove();
|
|
7475
|
+
rule.prepend(...orderedDeclarations);
|
|
7476
|
+
rule.raws.semicolon = true;
|
|
7438
7477
|
}
|
|
7439
|
-
function
|
|
7440
|
-
const
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
parent.remove();
|
|
7445
|
-
removeEmptyAtRuleAncestors(ruleParent);
|
|
7478
|
+
function createHoistInsertionAnchor(root) {
|
|
7479
|
+
for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
|
|
7480
|
+
const anchor = postcss.default.comment({ text: HOIST_ANCHOR_COMMENT });
|
|
7481
|
+
node.before(anchor);
|
|
7482
|
+
return anchor;
|
|
7446
7483
|
}
|
|
7447
7484
|
}
|
|
7448
|
-
function
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7485
|
+
function insertHoistedRules(root, rules, anchor) {
|
|
7486
|
+
if (anchor && !anchor.parent) anchor = void 0;
|
|
7487
|
+
if (rules.length === 0) {
|
|
7488
|
+
anchor?.remove();
|
|
7489
|
+
return;
|
|
7490
|
+
}
|
|
7491
|
+
const topDirectiveTail = getTopDirectiveTail(root);
|
|
7492
|
+
const firstRule = rules[0];
|
|
7493
|
+
if (!firstRule) return;
|
|
7494
|
+
if (anchor) {
|
|
7495
|
+
if (anchor.raws.before === void 0) delete firstRule.raws.before;
|
|
7496
|
+
else firstRule.raws.before = anchor.raws.before;
|
|
7497
|
+
anchor.replaceWith(rules);
|
|
7498
|
+
return;
|
|
7499
|
+
}
|
|
7500
|
+
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
7501
|
+
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
7502
|
+
else root.prepend(rules);
|
|
7456
7503
|
}
|
|
7457
|
-
function
|
|
7458
|
-
const
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
const
|
|
7464
|
-
if (
|
|
7465
|
-
|
|
7466
|
-
|
|
7504
|
+
function mergeEquivalentHoistedRules(rules) {
|
|
7505
|
+
const mergedRules = [];
|
|
7506
|
+
const ruleBySelector = /* @__PURE__ */ new Map();
|
|
7507
|
+
const propsBySelector = /* @__PURE__ */ new Map();
|
|
7508
|
+
for (const rule of rules) {
|
|
7509
|
+
const key = getSortedRuleSelectorKey(rule);
|
|
7510
|
+
const existingRule = ruleBySelector.get(key);
|
|
7511
|
+
if (existingRule) {
|
|
7512
|
+
const existingProps = propsBySelector.get(key) ?? /* @__PURE__ */ new Set();
|
|
7513
|
+
const nextNodes = (rule.nodes ?? []).filter((node) => {
|
|
7514
|
+
if (node.type !== "decl") return true;
|
|
7515
|
+
if (existingProps.has(node.prop)) return false;
|
|
7516
|
+
existingProps.add(node.prop);
|
|
7517
|
+
return true;
|
|
7518
|
+
});
|
|
7519
|
+
existingRule.append(...nextNodes.map((node) => node.clone()));
|
|
7520
|
+
reorderPreflightResetDeclarations(existingRule);
|
|
7521
|
+
propsBySelector.set(key, existingProps);
|
|
7522
|
+
continue;
|
|
7467
7523
|
}
|
|
7468
|
-
|
|
7469
|
-
|
|
7524
|
+
ruleBySelector.set(key, rule);
|
|
7525
|
+
propsBySelector.set(key, new Set((rule.nodes ?? []).flatMap((node) => node.type === "decl" ? [node.prop] : [])));
|
|
7526
|
+
reorderPreflightResetDeclarations(rule);
|
|
7527
|
+
mergedRules.push(rule);
|
|
7528
|
+
}
|
|
7529
|
+
return mergedRules;
|
|
7470
7530
|
}
|
|
7471
7531
|
//#endregion
|
|
7472
|
-
//#region src/compat/mini-program-css/
|
|
7473
|
-
const
|
|
7474
|
-
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
7475
|
-
const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
|
|
7476
|
-
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR = "::before,\n::after";
|
|
7532
|
+
//#region src/compat/mini-program-css/preflight.ts
|
|
7533
|
+
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1 = "::before,\n::after";
|
|
7477
7534
|
const MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS = new Set(["::before", "::after"]);
|
|
7478
7535
|
function createPseudoContentInitRule() {
|
|
7479
|
-
const rule = postcss.default.rule({ selector: MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR });
|
|
7536
|
+
const rule = postcss.default.rule({ selector: MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1 });
|
|
7480
7537
|
rule.append({
|
|
7481
7538
|
prop: "--tw-content",
|
|
7482
7539
|
value: "''"
|
|
@@ -7517,7 +7574,7 @@ function collectPreflightRules(root, options = {}) {
|
|
|
7517
7574
|
for (const rule of clonedPreflightRules) {
|
|
7518
7575
|
const selectors = getRuleSelectors(rule);
|
|
7519
7576
|
const hasElementSelector = selectors.some((selector) => selector === "view" || selector === "text");
|
|
7520
|
-
if (selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS.has(selector))) rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR;
|
|
7577
|
+
if (selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS.has(selector))) rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR$1;
|
|
7521
7578
|
else if (hasElementSelector && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector))) {
|
|
7522
7579
|
rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
|
|
7523
7580
|
applyConfiguredPreflightDeclarations(rule, options.cssPreflight);
|
|
@@ -7540,6 +7597,126 @@ function createPreflightResetRule(cssPreflight) {
|
|
|
7540
7597
|
}
|
|
7541
7598
|
return rule.nodes?.length ? rule : void 0;
|
|
7542
7599
|
}
|
|
7600
|
+
//#endregion
|
|
7601
|
+
//#region src/compat/mini-program-css/color-gamut.ts
|
|
7602
|
+
const DISPLAY_P3_VALUE_RE = /color\(\s*display-p3\b/i;
|
|
7603
|
+
const COLOR_GAMUT_P3_RE = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
|
|
7604
|
+
function isDisplayP3MediaRule(atRule) {
|
|
7605
|
+
return atRule.name === "media" && COLOR_GAMUT_P3_RE.test(atRule.params);
|
|
7606
|
+
}
|
|
7607
|
+
function isDisplayP3Declaration(decl) {
|
|
7608
|
+
return DISPLAY_P3_VALUE_RE.test(decl.value);
|
|
7609
|
+
}
|
|
7610
|
+
//#endregion
|
|
7611
|
+
//#region src/compat/mini-program-css/root-cleanups.ts
|
|
7612
|
+
function removeSpecificityPlaceholders(root) {
|
|
7613
|
+
root.walkRules((rule) => {
|
|
7614
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
7615
|
+
let changed = false;
|
|
7616
|
+
const selectors = rule.selectors.map((selector) => {
|
|
7617
|
+
let next = selector;
|
|
7618
|
+
for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (next.includes(suffix)) next = next.split(suffix).join("");
|
|
7619
|
+
if (next !== selector) changed = true;
|
|
7620
|
+
return next;
|
|
7621
|
+
});
|
|
7622
|
+
if (changed) rule.selectors = selectors;
|
|
7623
|
+
});
|
|
7624
|
+
}
|
|
7625
|
+
function isEffectivelyEmptyContainer(container) {
|
|
7626
|
+
return !container.nodes || container.nodes.every((node) => node.type === "comment");
|
|
7627
|
+
}
|
|
7628
|
+
function removeEmptyAtRuleAncestors(parent) {
|
|
7629
|
+
while (parent?.type === "atrule" && isEffectivelyEmptyContainer(parent)) {
|
|
7630
|
+
const nextParent = parent.parent;
|
|
7631
|
+
parent.remove();
|
|
7632
|
+
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
function removeUnsupportedBrowserSelectors(root) {
|
|
7636
|
+
root.walkRules((rule) => {
|
|
7637
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
7638
|
+
const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
|
|
7639
|
+
if (selectors.length === rule.selectors.length) return;
|
|
7640
|
+
if (selectors.length === 0) {
|
|
7641
|
+
const parent = rule.parent;
|
|
7642
|
+
rule.remove();
|
|
7643
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7644
|
+
return;
|
|
7645
|
+
}
|
|
7646
|
+
rule.selectors = selectors;
|
|
7647
|
+
});
|
|
7648
|
+
}
|
|
7649
|
+
function removeDeclarationAndEmptyRule$1(decl) {
|
|
7650
|
+
const parent = decl.parent;
|
|
7651
|
+
decl.remove();
|
|
7652
|
+
if (parent?.type === "rule" && parent.nodes.length === 0) {
|
|
7653
|
+
const ruleParent = parent.parent;
|
|
7654
|
+
parent.remove();
|
|
7655
|
+
removeEmptyAtRuleAncestors(ruleParent);
|
|
7656
|
+
}
|
|
7657
|
+
}
|
|
7658
|
+
function removeDisplayP3Declarations(root) {
|
|
7659
|
+
root.walkAtRules((atRule) => {
|
|
7660
|
+
if (isDisplayP3MediaRule(atRule)) {
|
|
7661
|
+
const parent = atRule.parent;
|
|
7662
|
+
atRule.remove();
|
|
7663
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7664
|
+
}
|
|
7665
|
+
});
|
|
7666
|
+
}
|
|
7667
|
+
const SIMPLE_MIN_WIDTH_MEDIA_RE = /^\(\s*min-width\s*:[^)]+\)$/i;
|
|
7668
|
+
const TAILWIND_GENERATED_TOKEN_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
|
|
7669
|
+
function isContainerMaxWidthOnlyRule(rule) {
|
|
7670
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7671
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7672
|
+
return declarations.length === 1 && declarations[0]?.prop === "max-width" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7673
|
+
}
|
|
7674
|
+
function removeTailwindContainerMaxWidthMediaRules(root) {
|
|
7675
|
+
root.walkAtRules("media", (atRule) => {
|
|
7676
|
+
if (!SIMPLE_MIN_WIDTH_MEDIA_RE.test(atRule.params.trim())) return;
|
|
7677
|
+
atRule.walkRules((rule) => {
|
|
7678
|
+
if (!isContainerMaxWidthOnlyRule(rule)) return;
|
|
7679
|
+
const parent = rule.parent;
|
|
7680
|
+
rule.remove();
|
|
7681
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7682
|
+
});
|
|
7683
|
+
});
|
|
7684
|
+
}
|
|
7685
|
+
function isContainerWidthOnlyRule(rule) {
|
|
7686
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7687
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7688
|
+
return declarations.length === 1 && declarations[0]?.prop === "width" && declarations[0].value.trim() === "100%" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7689
|
+
}
|
|
7690
|
+
function isTailwindGeneratedContainerRule(rule) {
|
|
7691
|
+
const previous = rule.prev();
|
|
7692
|
+
return previous?.type === "comment" && TAILWIND_GENERATED_TOKEN_COMMENT_RE.test(previous.text);
|
|
7693
|
+
}
|
|
7694
|
+
function removeTailwindContainerWidthRules(root, options = {}) {
|
|
7695
|
+
root.walkRules((rule) => {
|
|
7696
|
+
if (!isContainerWidthOnlyRule(rule)) return;
|
|
7697
|
+
if (options.generatedOnly && !isTailwindGeneratedContainerRule(rule)) return;
|
|
7698
|
+
const parent = rule.parent;
|
|
7699
|
+
if (isTailwindGeneratedContainerRule(rule)) rule.prev()?.remove();
|
|
7700
|
+
rule.remove();
|
|
7701
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7702
|
+
});
|
|
7703
|
+
}
|
|
7704
|
+
function removeUnsupportedModernColorDeclarations(root) {
|
|
7705
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
7706
|
+
root.walkDecls((decl) => {
|
|
7707
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7708
|
+
});
|
|
7709
|
+
root.walkDecls((decl) => {
|
|
7710
|
+
const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
|
|
7711
|
+
if (normalized.changed) {
|
|
7712
|
+
decl.value = normalized.value;
|
|
7713
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7714
|
+
}
|
|
7715
|
+
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule$1(decl);
|
|
7716
|
+
});
|
|
7717
|
+
}
|
|
7718
|
+
//#endregion
|
|
7719
|
+
//#region src/compat/mini-program-css/theme.ts
|
|
7543
7720
|
function collectThemeVariableRule(root, options = {}) {
|
|
7544
7721
|
const themeRules = [];
|
|
7545
7722
|
const declarations = /* @__PURE__ */ new Map();
|
|
@@ -7559,95 +7736,8 @@ function collectThemeVariableRule(root, options = {}) {
|
|
|
7559
7736
|
for (const decl of declarations.values()) rule.append(decl);
|
|
7560
7737
|
return rule;
|
|
7561
7738
|
}
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
const root = postcss.default.parse(css);
|
|
7565
|
-
let hasProperty = false;
|
|
7566
|
-
root.walkAtRules("property", (atRule) => {
|
|
7567
|
-
if (atRule.params.trim().startsWith("--tw-")) {
|
|
7568
|
-
hasProperty = true;
|
|
7569
|
-
return false;
|
|
7570
|
-
}
|
|
7571
|
-
});
|
|
7572
|
-
return hasProperty;
|
|
7573
|
-
}
|
|
7574
|
-
function getTopDirectiveTail(root) {
|
|
7575
|
-
let tail;
|
|
7576
|
-
for (const node of root.nodes ?? []) {
|
|
7577
|
-
if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
|
|
7578
|
-
tail = node;
|
|
7579
|
-
continue;
|
|
7580
|
-
}
|
|
7581
|
-
break;
|
|
7582
|
-
}
|
|
7583
|
-
return tail;
|
|
7584
|
-
}
|
|
7585
|
-
function createHoistInsertionAnchor(root) {
|
|
7586
|
-
for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
|
|
7587
|
-
const anchor = postcss.default.comment({ text: HOIST_ANCHOR_COMMENT });
|
|
7588
|
-
node.before(anchor);
|
|
7589
|
-
return anchor;
|
|
7590
|
-
}
|
|
7591
|
-
}
|
|
7592
|
-
function insertHoistedRules(root, rules, anchor) {
|
|
7593
|
-
if (anchor && !anchor.parent) anchor = void 0;
|
|
7594
|
-
if (rules.length === 0) {
|
|
7595
|
-
anchor?.remove();
|
|
7596
|
-
return;
|
|
7597
|
-
}
|
|
7598
|
-
const topDirectiveTail = getTopDirectiveTail(root);
|
|
7599
|
-
const firstRule = rules[0];
|
|
7600
|
-
if (!firstRule) return;
|
|
7601
|
-
if (anchor) {
|
|
7602
|
-
if (anchor.raws.before === void 0) delete firstRule.raws.before;
|
|
7603
|
-
else firstRule.raws.before = anchor.raws.before;
|
|
7604
|
-
anchor.replaceWith(rules);
|
|
7605
|
-
return;
|
|
7606
|
-
}
|
|
7607
|
-
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
7608
|
-
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
7609
|
-
else root.prepend(rules);
|
|
7610
|
-
}
|
|
7611
|
-
function mergeEquivalentHoistedRules(rules) {
|
|
7612
|
-
const mergedRules = [];
|
|
7613
|
-
const ruleBySelector = /* @__PURE__ */ new Map();
|
|
7614
|
-
const propsBySelector = /* @__PURE__ */ new Map();
|
|
7615
|
-
for (const rule of rules) {
|
|
7616
|
-
const key = getSortedRuleSelectorKey(rule);
|
|
7617
|
-
const existingRule = ruleBySelector.get(key);
|
|
7618
|
-
if (existingRule) {
|
|
7619
|
-
const existingProps = propsBySelector.get(key) ?? /* @__PURE__ */ new Set();
|
|
7620
|
-
const nextNodes = (rule.nodes ?? []).filter((node) => {
|
|
7621
|
-
if (node.type !== "decl") return true;
|
|
7622
|
-
if (existingProps.has(node.prop)) return false;
|
|
7623
|
-
existingProps.add(node.prop);
|
|
7624
|
-
return true;
|
|
7625
|
-
});
|
|
7626
|
-
existingRule.append(...nextNodes.map((node) => node.clone()));
|
|
7627
|
-
propsBySelector.set(key, existingProps);
|
|
7628
|
-
continue;
|
|
7629
|
-
}
|
|
7630
|
-
ruleBySelector.set(key, rule);
|
|
7631
|
-
propsBySelector.set(key, new Set((rule.nodes ?? []).flatMap((node) => node.type === "decl" ? [node.prop] : [])));
|
|
7632
|
-
mergedRules.push(rule);
|
|
7633
|
-
}
|
|
7634
|
-
return mergedRules;
|
|
7635
|
-
}
|
|
7636
|
-
function unwrapTailwindSourceMedia(root) {
|
|
7637
|
-
root.walkAtRules("media", (atRule) => {
|
|
7638
|
-
if (!atRule.params.startsWith("source(")) return;
|
|
7639
|
-
if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
7640
|
-
else atRule.remove();
|
|
7641
|
-
});
|
|
7642
|
-
}
|
|
7643
|
-
function removeTailwindGenerationDirectives(root) {
|
|
7644
|
-
root.walkComments((comment) => {
|
|
7645
|
-
if (GENERATOR_PLACEHOLDER_COMMENT_RE.test(comment.text)) comment.remove();
|
|
7646
|
-
});
|
|
7647
|
-
root.walkAtRules((atRule) => {
|
|
7648
|
-
if (atRule.name === "config" || atRule.name === "source" || atRule.name === "tailwind" || atRule.name === "reference" || atRule.name === "plugin") atRule.remove();
|
|
7649
|
-
});
|
|
7650
|
-
}
|
|
7739
|
+
//#endregion
|
|
7740
|
+
//#region src/compat/mini-program-css/finalize.ts
|
|
7651
7741
|
function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
7652
7742
|
const shouldInjectTailwindcssV4Defaults = options.isTailwindcssV4 === true;
|
|
7653
7743
|
const tailwindcssV4DefaultNodes = shouldInjectTailwindcssV4Defaults ? createMissingCssVarsV4Nodes(root, collectUsedTailwindcssV4Variables(root)) : [];
|
|
@@ -7660,6 +7750,8 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
7660
7750
|
removeSpecificityPlaceholders(root);
|
|
7661
7751
|
removeUnsupportedBrowserSelectors(root);
|
|
7662
7752
|
removeDisplayP3Declarations(root);
|
|
7753
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7754
|
+
removeTailwindContainerWidthRules(root, { generatedOnly: true });
|
|
7663
7755
|
removeUnsupportedModernColorDeclarations(root);
|
|
7664
7756
|
root.walkDecls((decl) => {
|
|
7665
7757
|
if (shouldInjectTailwindcssV4Defaults) normalizeTailwindcssV4Declaration(decl);
|
|
@@ -7712,6 +7804,7 @@ function finalizeMiniProgramCss(css, options = {}) {
|
|
|
7712
7804
|
//#endregion
|
|
7713
7805
|
//#region src/compat/mini-program-css/prune-generated.ts
|
|
7714
7806
|
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
7807
|
+
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR = "::before,\n::after";
|
|
7715
7808
|
const CLASS_SELECTOR_RE$1 = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
7716
7809
|
function isConditionalCompilationComment(text) {
|
|
7717
7810
|
return /#(?:ifn?def|endif)\b/.test(text);
|
|
@@ -7728,6 +7821,23 @@ function isMiniProgramElementVariableScopeRule(rule) {
|
|
|
7728
7821
|
const selectors = getRuleSelectors(rule);
|
|
7729
7822
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector));
|
|
7730
7823
|
}
|
|
7824
|
+
function isOnlyTwContentDeclarations(rule) {
|
|
7825
|
+
let hasDeclaration = false;
|
|
7826
|
+
let onlyContentVariable = true;
|
|
7827
|
+
rule.walkDecls((decl) => {
|
|
7828
|
+
hasDeclaration = true;
|
|
7829
|
+
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
7830
|
+
});
|
|
7831
|
+
return hasDeclaration && onlyContentVariable;
|
|
7832
|
+
}
|
|
7833
|
+
function isMiniProgramElementContentInitRule(rule) {
|
|
7834
|
+
if (!isMiniProgramElementVariableScopeRule(rule)) return false;
|
|
7835
|
+
let hasElementSelector = false;
|
|
7836
|
+
let hasPseudoSelector = false;
|
|
7837
|
+
for (const selector of getRuleSelectors(rule)) if (selector === "view" || selector === "text") hasElementSelector = true;
|
|
7838
|
+
else if (selector === "::before" || selector === "::after") hasPseudoSelector = true;
|
|
7839
|
+
return hasElementSelector && hasPseudoSelector && isOnlyTwContentDeclarations(rule);
|
|
7840
|
+
}
|
|
7731
7841
|
function isTailwindV4GradientRuntimeDeclaration(decl) {
|
|
7732
7842
|
return decl.prop.startsWith("--tw-gradient-");
|
|
7733
7843
|
}
|
|
@@ -7765,6 +7875,8 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7765
7875
|
});
|
|
7766
7876
|
removeUnsupportedCascadeLayers(root);
|
|
7767
7877
|
removeUnsupportedModernColorDeclarations(root);
|
|
7878
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7879
|
+
removeTailwindContainerWidthRules(root);
|
|
7768
7880
|
root.walkAtRules("supports", (atRule) => {
|
|
7769
7881
|
atRule.remove();
|
|
7770
7882
|
});
|
|
@@ -7776,6 +7888,18 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7776
7888
|
});
|
|
7777
7889
|
root.walkRules((rule) => {
|
|
7778
7890
|
if (isKeyframesRule(rule)) return;
|
|
7891
|
+
if (isPseudoContentInitRule(rule)) {
|
|
7892
|
+
if (!shouldPreserveContentInit) rule.remove();
|
|
7893
|
+
return;
|
|
7894
|
+
}
|
|
7895
|
+
if (isMiniProgramElementContentInitRule(rule)) {
|
|
7896
|
+
if (!shouldPreserveContentInit) {
|
|
7897
|
+
rule.remove();
|
|
7898
|
+
return;
|
|
7899
|
+
}
|
|
7900
|
+
rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR;
|
|
7901
|
+
return;
|
|
7902
|
+
}
|
|
7779
7903
|
if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
|
|
7780
7904
|
rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
|
|
7781
7905
|
return;
|
|
@@ -7788,10 +7912,6 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7788
7912
|
}
|
|
7789
7913
|
if (hasClassSelector$2(rule.selector)) return;
|
|
7790
7914
|
if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
|
|
7791
|
-
if (isPseudoContentInitRule(rule)) {
|
|
7792
|
-
if (!shouldPreserveContentInit) rule.remove();
|
|
7793
|
-
return;
|
|
7794
|
-
}
|
|
7795
7915
|
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
7796
7916
|
if (isCustomPropertyRule(rule)) {
|
|
7797
7917
|
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
@@ -43179,7 +43299,7 @@ var require_postcss_page_break = /* @__PURE__ */ require_html_transform.__common
|
|
|
43179
43299
|
module.exports.postcss = true;
|
|
43180
43300
|
}));
|
|
43181
43301
|
//#endregion
|
|
43182
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-specificity@6.0.0_postcss-selector-parser@7.1.
|
|
43302
|
+
//#region ../../node_modules/.pnpm/@csstools+selector-specificity@6.0.0_postcss-selector-parser@7.1.2/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
43183
43303
|
var import_postcss_page_break = /* @__PURE__ */ require_html_transform.__toESM(require_postcss_page_break(), 1);
|
|
43184
43304
|
function compare(e, t) {
|
|
43185
43305
|
return e.a === t.a ? e.b === t.b ? e.c - t.c : e.b - t.b : e.a - t.a;
|
|
@@ -49953,7 +50073,7 @@ const creator$18 = (s) => {
|
|
|
49953
50073
|
};
|
|
49954
50074
|
creator$18.postcss = !0;
|
|
49955
50075
|
//#endregion
|
|
49956
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-resolve-nested@4.0.0_postcss-selector-parser@7.1.
|
|
50076
|
+
//#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
50077
|
function sourceFrom(e) {
|
|
49958
50078
|
return {
|
|
49959
50079
|
sourceIndex: e.sourceIndex ?? 0,
|
|
@@ -53167,10 +53287,7 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
53167
53287
|
for (const declarations of grouped.values()) dedupeSpacingGroup(rule, declarations);
|
|
53168
53288
|
}
|
|
53169
53289
|
//#endregion
|
|
53170
|
-
//#region src/selectorParser/rule-transformer.ts
|
|
53171
|
-
const ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
53172
|
-
const SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
53173
|
-
const SIMPLE_SELECTOR_FAST_PATH = /^[#.][\w-]+(?:\s+[#.][\w-]+)*$/;
|
|
53290
|
+
//#region src/selectorParser/rule-transformer/pseudos.ts
|
|
53174
53291
|
const RTL_LANGUAGE_ANY_PSEUDO_SET = new Set([
|
|
53175
53292
|
":-moz-any",
|
|
53176
53293
|
":-webkit-any",
|
|
@@ -53186,6 +53303,23 @@ const EMPTY_FUNCTIONAL_PSEUDO_CLEANUP_SET = new Set([
|
|
|
53186
53303
|
":-moz-any",
|
|
53187
53304
|
":lang"
|
|
53188
53305
|
]);
|
|
53306
|
+
const UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53307
|
+
":after",
|
|
53308
|
+
":before",
|
|
53309
|
+
"::after",
|
|
53310
|
+
"::before",
|
|
53311
|
+
"::backdrop",
|
|
53312
|
+
"::-ms-backdrop",
|
|
53313
|
+
"::-webkit-backdrop",
|
|
53314
|
+
"::file-selector-button"
|
|
53315
|
+
]);
|
|
53316
|
+
const MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53317
|
+
"::backdrop",
|
|
53318
|
+
"::-ms-backdrop",
|
|
53319
|
+
"::-webkit-backdrop",
|
|
53320
|
+
"::file-selector-button"
|
|
53321
|
+
]);
|
|
53322
|
+
const NORMALIZED_PSEUDO_ELEMENT_SELECTOR = new Map([[":before", "::before"], [":after", "::after"]]);
|
|
53189
53323
|
function isRtlLanguageAnyPseudo(node) {
|
|
53190
53324
|
return node.type === "pseudo" && RTL_LANGUAGE_ANY_PSEUDO_SET.has(node.value);
|
|
53191
53325
|
}
|
|
@@ -53222,6 +53356,29 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
53222
53356
|
if (parent && parent.type === "selector" && parent.length === 0) parent.remove();
|
|
53223
53357
|
}
|
|
53224
53358
|
}
|
|
53359
|
+
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
53360
|
+
if (!isUniAppXEnabled(options)) return selector.nodes.some((node) => node.type === "pseudo" && MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53361
|
+
return selector.nodes.some((node) => node.type === "pseudo" && UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53362
|
+
}
|
|
53363
|
+
function handlePseudoNode(node, index, context, parent) {
|
|
53364
|
+
if (node.type !== "pseudo") return;
|
|
53365
|
+
if (isRtlLanguageAnyPseudo(node)) {
|
|
53366
|
+
stripUnsupportedRtlLanguagePseudo(node);
|
|
53367
|
+
return;
|
|
53368
|
+
}
|
|
53369
|
+
if (node.value === ":root" && context.rootReplacement) {
|
|
53370
|
+
node.value = context.rootReplacement;
|
|
53371
|
+
return;
|
|
53372
|
+
}
|
|
53373
|
+
const normalizedPseudoElement = NORMALIZED_PSEUDO_ELEMENT_SELECTOR.get(node.value);
|
|
53374
|
+
if (normalizedPseudoElement) {
|
|
53375
|
+
node.value = normalizedPseudoElement;
|
|
53376
|
+
return;
|
|
53377
|
+
}
|
|
53378
|
+
if (node.value === ":where") flattenWherePseudo(node, context, index, parent);
|
|
53379
|
+
}
|
|
53380
|
+
//#endregion
|
|
53381
|
+
//#region src/selectorParser/rule-transformer/nodes.ts
|
|
53225
53382
|
function handleClassNode(node, context) {
|
|
53226
53383
|
if (node.type !== "class") return;
|
|
53227
53384
|
node.value = context.selectorReplacerOptions === void 0 ? internalCssSelectorReplacer(node.value) : internalCssSelectorReplacer(node.value, context.selectorReplacerOptions);
|
|
@@ -53234,27 +53391,6 @@ function shouldRemoveHoverSelector(selector, options) {
|
|
|
53234
53391
|
if (!options.cssRemoveHoverPseudoClass) return false;
|
|
53235
53392
|
return selector.nodes.some((node) => node.type === "pseudo" && node.value === ":hover");
|
|
53236
53393
|
}
|
|
53237
|
-
const UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53238
|
-
":after",
|
|
53239
|
-
":before",
|
|
53240
|
-
"::after",
|
|
53241
|
-
"::before",
|
|
53242
|
-
"::backdrop",
|
|
53243
|
-
"::-ms-backdrop",
|
|
53244
|
-
"::-webkit-backdrop",
|
|
53245
|
-
"::file-selector-button"
|
|
53246
|
-
]);
|
|
53247
|
-
const MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53248
|
-
"::backdrop",
|
|
53249
|
-
"::-ms-backdrop",
|
|
53250
|
-
"::-webkit-backdrop",
|
|
53251
|
-
"::file-selector-button"
|
|
53252
|
-
]);
|
|
53253
|
-
const NORMALIZED_PSEUDO_ELEMENT_SELECTOR = new Map([[":before", "::before"], [":after", "::after"]]);
|
|
53254
|
-
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
53255
|
-
if (!isUniAppXEnabled(options)) return selector.nodes.some((node) => node.type === "pseudo" && MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53256
|
-
return selector.nodes.some((node) => node.type === "pseudo" && UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53257
|
-
}
|
|
53258
53394
|
function isHiddenOrTemplateNotPseudo(node) {
|
|
53259
53395
|
if (!node || node.type !== "pseudo" || node.value !== ":not") return false;
|
|
53260
53396
|
const selector = node.first;
|
|
@@ -53277,23 +53413,6 @@ function handleCombinatorNode(node, index, context) {
|
|
|
53277
53413
|
nodes.splice(index + 1, 3, ...ast);
|
|
53278
53414
|
}
|
|
53279
53415
|
}
|
|
53280
|
-
function handlePseudoNode(node, index, context, parent) {
|
|
53281
|
-
if (node.type !== "pseudo") return;
|
|
53282
|
-
if (isRtlLanguageAnyPseudo(node)) {
|
|
53283
|
-
stripUnsupportedRtlLanguagePseudo(node);
|
|
53284
|
-
return;
|
|
53285
|
-
}
|
|
53286
|
-
if (node.value === ":root" && context.rootReplacement) {
|
|
53287
|
-
node.value = context.rootReplacement;
|
|
53288
|
-
return;
|
|
53289
|
-
}
|
|
53290
|
-
const normalizedPseudoElement = NORMALIZED_PSEUDO_ELEMENT_SELECTOR.get(node.value);
|
|
53291
|
-
if (normalizedPseudoElement) {
|
|
53292
|
-
node.value = normalizedPseudoElement;
|
|
53293
|
-
return;
|
|
53294
|
-
}
|
|
53295
|
-
if (node.value === ":where") flattenWherePseudo(node, context, index, parent);
|
|
53296
|
-
}
|
|
53297
53416
|
function handleTagOrAttribute(node, context) {
|
|
53298
53417
|
stripUnsupportedNodeForUniAppX(node, context.options);
|
|
53299
53418
|
}
|
|
@@ -53308,6 +53427,11 @@ function handleSelectorNode(selector, context) {
|
|
|
53308
53427
|
}
|
|
53309
53428
|
if (transformSpacingSelector(selector.nodes, context.options)) context.requiresSpacingNormalization = true;
|
|
53310
53429
|
}
|
|
53430
|
+
//#endregion
|
|
53431
|
+
//#region src/selectorParser/rule-transformer.ts
|
|
53432
|
+
const ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
53433
|
+
const SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
53434
|
+
const SIMPLE_SELECTOR_FAST_PATH = /^[#.][\w-]+(?:\s+[#.][\w-]+)*$/;
|
|
53311
53435
|
function canSkipRuleTransform(rule) {
|
|
53312
53436
|
const selector = rule.selector.trim();
|
|
53313
53437
|
if (!selector) return false;
|
|
@@ -54088,11 +54212,46 @@ function makePseudoVarRule() {
|
|
|
54088
54212
|
function isEmptyContentInitDeclaration(decl) {
|
|
54089
54213
|
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
54090
54214
|
}
|
|
54215
|
+
function isPseudoContentInitSelector(selector) {
|
|
54216
|
+
return selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after";
|
|
54217
|
+
}
|
|
54218
|
+
function isElementContentInitSelector(selector) {
|
|
54219
|
+
return selector === "*" || selector === "view" || selector === "text";
|
|
54220
|
+
}
|
|
54221
|
+
function isOnlyEmptyContentInitRule(node) {
|
|
54222
|
+
let hasDeclaration = false;
|
|
54223
|
+
let onlyEmptyContentInit = true;
|
|
54224
|
+
node.walkDecls((decl) => {
|
|
54225
|
+
hasDeclaration = true;
|
|
54226
|
+
if (!isEmptyContentInitDeclaration(decl)) onlyEmptyContentInit = false;
|
|
54227
|
+
});
|
|
54228
|
+
return hasDeclaration && onlyEmptyContentInit;
|
|
54229
|
+
}
|
|
54230
|
+
function restorePseudoContentInitScope(node) {
|
|
54231
|
+
if (!isOnlyEmptyContentInitRule(node)) return false;
|
|
54232
|
+
let hasPseudoSelector = false;
|
|
54233
|
+
let hasElementSelector = false;
|
|
54234
|
+
for (const selector of node.selectors) if (isPseudoContentInitSelector(selector)) hasPseudoSelector = true;
|
|
54235
|
+
else if (isElementContentInitSelector(selector)) hasElementSelector = true;
|
|
54236
|
+
else return false;
|
|
54237
|
+
if (!hasPseudoSelector || !hasElementSelector) return false;
|
|
54238
|
+
assignRuleSelectors(node, ["::before", "::after"], {
|
|
54239
|
+
phase: "pre",
|
|
54240
|
+
reason: "restore-pseudo-content-init-scope"
|
|
54241
|
+
});
|
|
54242
|
+
return true;
|
|
54243
|
+
}
|
|
54091
54244
|
function removeTailwindV4EmptyContentInit(node) {
|
|
54092
54245
|
node.walkDecls((decl) => {
|
|
54093
54246
|
if (isEmptyContentInitDeclaration(decl)) decl.remove();
|
|
54094
54247
|
});
|
|
54095
54248
|
}
|
|
54249
|
+
function injectPreflightDeclarations(node, options) {
|
|
54250
|
+
const preflightDeclarations = options.cssInjectPreflight?.();
|
|
54251
|
+
if (!preflightDeclarations || preflightDeclarations.length === 0) return;
|
|
54252
|
+
node.prepend(...preflightDeclarations);
|
|
54253
|
+
node.raws.semicolon = true;
|
|
54254
|
+
}
|
|
54096
54255
|
function hasClassSelector(node) {
|
|
54097
54256
|
return node.selectors.some((selector) => selector.includes("."));
|
|
54098
54257
|
}
|
|
@@ -54118,7 +54277,7 @@ function resolveUniAppXVariableScopeSelectors(options) {
|
|
|
54118
54277
|
return ["view", "text"];
|
|
54119
54278
|
}
|
|
54120
54279
|
function commonChunkPreflight(node, options) {
|
|
54121
|
-
const { ctx,
|
|
54280
|
+
const { ctx, injectAdditionalCssVarScope } = options;
|
|
54122
54281
|
const uniAppXEnabled = isUniAppXEnabled(options);
|
|
54123
54282
|
const isTailwindcss4 = isTailwindcssV4(options);
|
|
54124
54283
|
const rootOption = options.cssSelectorReplacement?.root;
|
|
@@ -54131,6 +54290,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54131
54290
|
reason: "append-host-selector"
|
|
54132
54291
|
});
|
|
54133
54292
|
if (isTailwindcss4 && !usesTailwindcssV4ContentVariable(node.root()) && (!hasClassSelector(node) || isRootThemeScopeRule(node))) removeTailwindV4EmptyContentInit(node);
|
|
54293
|
+
if (!isTailwindcss4 && restorePseudoContentInitScope(node)) return;
|
|
54134
54294
|
if (testIfVariablesScope(node) || uniAppXEnabled && node.selectors.includes("*") && hasTwVars(node, 2)) {
|
|
54135
54295
|
ctx?.markVariablesScope(node);
|
|
54136
54296
|
assignRuleSelectors(node, uniAppXEnabled ? resolveUniAppXVariableScopeSelectors(options) : remakeCssVarSelector(node.selectors, options), {
|
|
@@ -54138,7 +54298,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54138
54298
|
reason: "rewrite-variable-scope"
|
|
54139
54299
|
});
|
|
54140
54300
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54141
|
-
|
|
54301
|
+
injectPreflightDeclarations(node, options);
|
|
54142
54302
|
}
|
|
54143
54303
|
if (injectAdditionalCssVarScope && (isTailwindcss4 ? testIfRootHostForV4(node) : testIfTwBackdrop(node))) {
|
|
54144
54304
|
const nodes = isTailwindcss4 ? createUsedCssVarsV4Nodes(collectUsedTailwindcssV4Variables(node.root())) : cssVarsV3Nodes;
|
|
@@ -54157,7 +54317,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54157
54317
|
});
|
|
54158
54318
|
node.before(syntheticRule);
|
|
54159
54319
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54160
|
-
|
|
54320
|
+
injectPreflightDeclarations(syntheticRule, options);
|
|
54161
54321
|
}
|
|
54162
54322
|
}
|
|
54163
54323
|
//#endregion
|