@weapp-tailwindcss/postcss 3.0.3 → 3.0.5
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 +7 -0
- package/dist/compat/mini-program-css/theme.d.ts +3 -0
- package/dist/index.js +447 -281
- package/dist/index.mjs +446 -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,131 @@ 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 removeEmptyAtRules(root) {
|
|
7629
|
+
root.walkAtRules((atRule) => {
|
|
7630
|
+
if (isEffectivelyEmptyContainer(atRule)) atRule.remove();
|
|
7631
|
+
});
|
|
7632
|
+
}
|
|
7633
|
+
function removeEmptyAtRuleAncestors(parent) {
|
|
7634
|
+
while (parent?.type === "atrule" && isEffectivelyEmptyContainer(parent)) {
|
|
7635
|
+
const nextParent = parent.parent;
|
|
7636
|
+
parent.remove();
|
|
7637
|
+
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
function removeUnsupportedBrowserSelectors(root) {
|
|
7641
|
+
root.walkRules((rule) => {
|
|
7642
|
+
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
7643
|
+
const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
|
|
7644
|
+
if (selectors.length === rule.selectors.length) return;
|
|
7645
|
+
if (selectors.length === 0) {
|
|
7646
|
+
const parent = rule.parent;
|
|
7647
|
+
rule.remove();
|
|
7648
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7649
|
+
return;
|
|
7650
|
+
}
|
|
7651
|
+
rule.selectors = selectors;
|
|
7652
|
+
});
|
|
7653
|
+
}
|
|
7654
|
+
function removeDeclarationAndEmptyRule$1(decl) {
|
|
7655
|
+
const parent = decl.parent;
|
|
7656
|
+
decl.remove();
|
|
7657
|
+
if (parent?.type === "rule" && parent.nodes.length === 0) {
|
|
7658
|
+
const ruleParent = parent.parent;
|
|
7659
|
+
parent.remove();
|
|
7660
|
+
removeEmptyAtRuleAncestors(ruleParent);
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
function removeDisplayP3Declarations(root) {
|
|
7664
|
+
root.walkAtRules((atRule) => {
|
|
7665
|
+
if (isDisplayP3MediaRule(atRule)) {
|
|
7666
|
+
const parent = atRule.parent;
|
|
7667
|
+
atRule.remove();
|
|
7668
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7669
|
+
}
|
|
7670
|
+
});
|
|
7671
|
+
}
|
|
7672
|
+
const SIMPLE_MIN_WIDTH_MEDIA_RE = /^\(\s*min-width\s*:[^)]+\)$/i;
|
|
7673
|
+
const TAILWIND_GENERATED_TOKEN_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
|
|
7674
|
+
function isContainerMaxWidthOnlyRule(rule) {
|
|
7675
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7676
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7677
|
+
return declarations.length === 1 && declarations[0]?.prop === "max-width" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7678
|
+
}
|
|
7679
|
+
function removeTailwindContainerMaxWidthMediaRules(root) {
|
|
7680
|
+
root.walkAtRules("media", (atRule) => {
|
|
7681
|
+
if (!SIMPLE_MIN_WIDTH_MEDIA_RE.test(atRule.params.trim())) return;
|
|
7682
|
+
atRule.walkRules((rule) => {
|
|
7683
|
+
if (!isContainerMaxWidthOnlyRule(rule)) return;
|
|
7684
|
+
const parent = rule.parent;
|
|
7685
|
+
rule.remove();
|
|
7686
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7687
|
+
});
|
|
7688
|
+
});
|
|
7689
|
+
}
|
|
7690
|
+
function isContainerWidthOnlyRule(rule) {
|
|
7691
|
+
if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
|
|
7692
|
+
const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
7693
|
+
return declarations.length === 1 && declarations[0]?.prop === "width" && declarations[0].value.trim() === "100%" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
|
|
7694
|
+
}
|
|
7695
|
+
function isTailwindGeneratedContainerRule(rule) {
|
|
7696
|
+
const previous = rule.prev();
|
|
7697
|
+
return previous?.type === "comment" && TAILWIND_GENERATED_TOKEN_COMMENT_RE.test(previous.text);
|
|
7698
|
+
}
|
|
7699
|
+
function removeTailwindContainerWidthRules(root, options = {}) {
|
|
7700
|
+
root.walkRules((rule) => {
|
|
7701
|
+
if (!isContainerWidthOnlyRule(rule)) return;
|
|
7702
|
+
if (options.generatedOnly && !isTailwindGeneratedContainerRule(rule)) return;
|
|
7703
|
+
const parent = rule.parent;
|
|
7704
|
+
if (isTailwindGeneratedContainerRule(rule)) rule.prev()?.remove();
|
|
7705
|
+
rule.remove();
|
|
7706
|
+
removeEmptyAtRuleAncestors(parent);
|
|
7707
|
+
});
|
|
7708
|
+
}
|
|
7709
|
+
function removeUnsupportedModernColorDeclarations(root) {
|
|
7710
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
7711
|
+
root.walkDecls((decl) => {
|
|
7712
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7713
|
+
});
|
|
7714
|
+
root.walkDecls((decl) => {
|
|
7715
|
+
const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
|
|
7716
|
+
if (normalized.changed) {
|
|
7717
|
+
decl.value = normalized.value;
|
|
7718
|
+
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
7719
|
+
}
|
|
7720
|
+
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule$1(decl);
|
|
7721
|
+
});
|
|
7722
|
+
}
|
|
7723
|
+
//#endregion
|
|
7724
|
+
//#region src/compat/mini-program-css/theme.ts
|
|
7543
7725
|
function collectThemeVariableRule(root, options = {}) {
|
|
7544
7726
|
const themeRules = [];
|
|
7545
7727
|
const declarations = /* @__PURE__ */ new Map();
|
|
@@ -7559,95 +7741,8 @@ function collectThemeVariableRule(root, options = {}) {
|
|
|
7559
7741
|
for (const decl of declarations.values()) rule.append(decl);
|
|
7560
7742
|
return rule;
|
|
7561
7743
|
}
|
|
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
|
-
}
|
|
7744
|
+
//#endregion
|
|
7745
|
+
//#region src/compat/mini-program-css/finalize.ts
|
|
7651
7746
|
function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
7652
7747
|
const shouldInjectTailwindcssV4Defaults = options.isTailwindcssV4 === true;
|
|
7653
7748
|
const tailwindcssV4DefaultNodes = shouldInjectTailwindcssV4Defaults ? createMissingCssVarsV4Nodes(root, collectUsedTailwindcssV4Variables(root)) : [];
|
|
@@ -7660,6 +7755,8 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
7660
7755
|
removeSpecificityPlaceholders(root);
|
|
7661
7756
|
removeUnsupportedBrowserSelectors(root);
|
|
7662
7757
|
removeDisplayP3Declarations(root);
|
|
7758
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7759
|
+
removeTailwindContainerWidthRules(root, { generatedOnly: true });
|
|
7663
7760
|
removeUnsupportedModernColorDeclarations(root);
|
|
7664
7761
|
root.walkDecls((decl) => {
|
|
7665
7762
|
if (shouldInjectTailwindcssV4Defaults) normalizeTailwindcssV4Declaration(decl);
|
|
@@ -7680,6 +7777,7 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
7680
7777
|
}));
|
|
7681
7778
|
const themeRule = collectThemeVariableRule(root, options);
|
|
7682
7779
|
insertHoistedRules(root, mergeEquivalentHoistedRules(themeRule ? [...preflightRules, themeRule] : preflightRules), hoistAnchor);
|
|
7780
|
+
removeEmptyAtRules(root);
|
|
7683
7781
|
}
|
|
7684
7782
|
function hoistTailwindPreflightBase(css) {
|
|
7685
7783
|
try {
|
|
@@ -7712,6 +7810,7 @@ function finalizeMiniProgramCss(css, options = {}) {
|
|
|
7712
7810
|
//#endregion
|
|
7713
7811
|
//#region src/compat/mini-program-css/prune-generated.ts
|
|
7714
7812
|
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
7813
|
+
const MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR = "::before,\n::after";
|
|
7715
7814
|
const CLASS_SELECTOR_RE$1 = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
7716
7815
|
function isConditionalCompilationComment(text) {
|
|
7717
7816
|
return /#(?:ifn?def|endif)\b/.test(text);
|
|
@@ -7728,6 +7827,23 @@ function isMiniProgramElementVariableScopeRule(rule) {
|
|
|
7728
7827
|
const selectors = getRuleSelectors(rule);
|
|
7729
7828
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector));
|
|
7730
7829
|
}
|
|
7830
|
+
function isOnlyTwContentDeclarations(rule) {
|
|
7831
|
+
let hasDeclaration = false;
|
|
7832
|
+
let onlyContentVariable = true;
|
|
7833
|
+
rule.walkDecls((decl) => {
|
|
7834
|
+
hasDeclaration = true;
|
|
7835
|
+
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
7836
|
+
});
|
|
7837
|
+
return hasDeclaration && onlyContentVariable;
|
|
7838
|
+
}
|
|
7839
|
+
function isMiniProgramElementContentInitRule(rule) {
|
|
7840
|
+
if (!isMiniProgramElementVariableScopeRule(rule)) return false;
|
|
7841
|
+
let hasElementSelector = false;
|
|
7842
|
+
let hasPseudoSelector = false;
|
|
7843
|
+
for (const selector of getRuleSelectors(rule)) if (selector === "view" || selector === "text") hasElementSelector = true;
|
|
7844
|
+
else if (selector === "::before" || selector === "::after") hasPseudoSelector = true;
|
|
7845
|
+
return hasElementSelector && hasPseudoSelector && isOnlyTwContentDeclarations(rule);
|
|
7846
|
+
}
|
|
7731
7847
|
function isTailwindV4GradientRuntimeDeclaration(decl) {
|
|
7732
7848
|
return decl.prop.startsWith("--tw-gradient-");
|
|
7733
7849
|
}
|
|
@@ -7765,6 +7881,8 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7765
7881
|
});
|
|
7766
7882
|
removeUnsupportedCascadeLayers(root);
|
|
7767
7883
|
removeUnsupportedModernColorDeclarations(root);
|
|
7884
|
+
removeTailwindContainerMaxWidthMediaRules(root);
|
|
7885
|
+
removeTailwindContainerWidthRules(root);
|
|
7768
7886
|
root.walkAtRules("supports", (atRule) => {
|
|
7769
7887
|
atRule.remove();
|
|
7770
7888
|
});
|
|
@@ -7776,6 +7894,18 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7776
7894
|
});
|
|
7777
7895
|
root.walkRules((rule) => {
|
|
7778
7896
|
if (isKeyframesRule(rule)) return;
|
|
7897
|
+
if (isPseudoContentInitRule(rule)) {
|
|
7898
|
+
if (!shouldPreserveContentInit) rule.remove();
|
|
7899
|
+
return;
|
|
7900
|
+
}
|
|
7901
|
+
if (isMiniProgramElementContentInitRule(rule)) {
|
|
7902
|
+
if (!shouldPreserveContentInit) {
|
|
7903
|
+
rule.remove();
|
|
7904
|
+
return;
|
|
7905
|
+
}
|
|
7906
|
+
rule.selector = MINI_PROGRAM_PSEUDO_CONTENT_SCOPE_SELECTOR;
|
|
7907
|
+
return;
|
|
7908
|
+
}
|
|
7779
7909
|
if (isCustomPropertyRule(rule) && isMiniProgramElementVariableScopeRule(rule)) {
|
|
7780
7910
|
rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
|
|
7781
7911
|
return;
|
|
@@ -7788,10 +7918,6 @@ function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
|
7788
7918
|
}
|
|
7789
7919
|
if (hasClassSelector$2(rule.selector)) return;
|
|
7790
7920
|
if (!shouldPreserveContentInit) removeEmptyContentInitDeclarations(rule);
|
|
7791
|
-
if (isPseudoContentInitRule(rule)) {
|
|
7792
|
-
if (!shouldPreserveContentInit) rule.remove();
|
|
7793
|
-
return;
|
|
7794
|
-
}
|
|
7795
7921
|
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
7796
7922
|
if (isCustomPropertyRule(rule)) {
|
|
7797
7923
|
moveTailwindV4GradientRuntimeDeclarations(rule);
|
|
@@ -43179,7 +43305,7 @@ var require_postcss_page_break = /* @__PURE__ */ require_html_transform.__common
|
|
|
43179
43305
|
module.exports.postcss = true;
|
|
43180
43306
|
}));
|
|
43181
43307
|
//#endregion
|
|
43182
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-specificity@6.0.0_postcss-selector-parser@7.1.
|
|
43308
|
+
//#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
43309
|
var import_postcss_page_break = /* @__PURE__ */ require_html_transform.__toESM(require_postcss_page_break(), 1);
|
|
43184
43310
|
function compare(e, t) {
|
|
43185
43311
|
return e.a === t.a ? e.b === t.b ? e.c - t.c : e.b - t.b : e.a - t.a;
|
|
@@ -49953,7 +50079,7 @@ const creator$18 = (s) => {
|
|
|
49953
50079
|
};
|
|
49954
50080
|
creator$18.postcss = !0;
|
|
49955
50081
|
//#endregion
|
|
49956
|
-
//#region ../../node_modules/.pnpm/@csstools+selector-resolve-nested@4.0.0_postcss-selector-parser@7.1.
|
|
50082
|
+
//#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
50083
|
function sourceFrom(e) {
|
|
49958
50084
|
return {
|
|
49959
50085
|
sourceIndex: e.sourceIndex ?? 0,
|
|
@@ -53167,10 +53293,7 @@ function normalizeSpacingDeclarations(rule) {
|
|
|
53167
53293
|
for (const declarations of grouped.values()) dedupeSpacingGroup(rule, declarations);
|
|
53168
53294
|
}
|
|
53169
53295
|
//#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-]+)*$/;
|
|
53296
|
+
//#region src/selectorParser/rule-transformer/pseudos.ts
|
|
53174
53297
|
const RTL_LANGUAGE_ANY_PSEUDO_SET = new Set([
|
|
53175
53298
|
":-moz-any",
|
|
53176
53299
|
":-webkit-any",
|
|
@@ -53186,6 +53309,23 @@ const EMPTY_FUNCTIONAL_PSEUDO_CLEANUP_SET = new Set([
|
|
|
53186
53309
|
":-moz-any",
|
|
53187
53310
|
":lang"
|
|
53188
53311
|
]);
|
|
53312
|
+
const UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53313
|
+
":after",
|
|
53314
|
+
":before",
|
|
53315
|
+
"::after",
|
|
53316
|
+
"::before",
|
|
53317
|
+
"::backdrop",
|
|
53318
|
+
"::-ms-backdrop",
|
|
53319
|
+
"::-webkit-backdrop",
|
|
53320
|
+
"::file-selector-button"
|
|
53321
|
+
]);
|
|
53322
|
+
const MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET = new Set([
|
|
53323
|
+
"::backdrop",
|
|
53324
|
+
"::-ms-backdrop",
|
|
53325
|
+
"::-webkit-backdrop",
|
|
53326
|
+
"::file-selector-button"
|
|
53327
|
+
]);
|
|
53328
|
+
const NORMALIZED_PSEUDO_ELEMENT_SELECTOR = new Map([[":before", "::before"], [":after", "::after"]]);
|
|
53189
53329
|
function isRtlLanguageAnyPseudo(node) {
|
|
53190
53330
|
return node.type === "pseudo" && RTL_LANGUAGE_ANY_PSEUDO_SET.has(node.value);
|
|
53191
53331
|
}
|
|
@@ -53222,6 +53362,29 @@ function flattenWherePseudo(node, context, index, parent) {
|
|
|
53222
53362
|
if (parent && parent.type === "selector" && parent.length === 0) parent.remove();
|
|
53223
53363
|
}
|
|
53224
53364
|
}
|
|
53365
|
+
function shouldRemoveUnsupportedPseudoElementSelector(selector, options) {
|
|
53366
|
+
if (!isUniAppXEnabled(options)) return selector.nodes.some((node) => node.type === "pseudo" && MINI_PROGRAM_UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53367
|
+
return selector.nodes.some((node) => node.type === "pseudo" && UNSUPPORTED_PSEUDO_ELEMENT_SELECTOR_SET.has(node.value));
|
|
53368
|
+
}
|
|
53369
|
+
function handlePseudoNode(node, index, context, parent) {
|
|
53370
|
+
if (node.type !== "pseudo") return;
|
|
53371
|
+
if (isRtlLanguageAnyPseudo(node)) {
|
|
53372
|
+
stripUnsupportedRtlLanguagePseudo(node);
|
|
53373
|
+
return;
|
|
53374
|
+
}
|
|
53375
|
+
if (node.value === ":root" && context.rootReplacement) {
|
|
53376
|
+
node.value = context.rootReplacement;
|
|
53377
|
+
return;
|
|
53378
|
+
}
|
|
53379
|
+
const normalizedPseudoElement = NORMALIZED_PSEUDO_ELEMENT_SELECTOR.get(node.value);
|
|
53380
|
+
if (normalizedPseudoElement) {
|
|
53381
|
+
node.value = normalizedPseudoElement;
|
|
53382
|
+
return;
|
|
53383
|
+
}
|
|
53384
|
+
if (node.value === ":where") flattenWherePseudo(node, context, index, parent);
|
|
53385
|
+
}
|
|
53386
|
+
//#endregion
|
|
53387
|
+
//#region src/selectorParser/rule-transformer/nodes.ts
|
|
53225
53388
|
function handleClassNode(node, context) {
|
|
53226
53389
|
if (node.type !== "class") return;
|
|
53227
53390
|
node.value = context.selectorReplacerOptions === void 0 ? internalCssSelectorReplacer(node.value) : internalCssSelectorReplacer(node.value, context.selectorReplacerOptions);
|
|
@@ -53234,27 +53397,6 @@ function shouldRemoveHoverSelector(selector, options) {
|
|
|
53234
53397
|
if (!options.cssRemoveHoverPseudoClass) return false;
|
|
53235
53398
|
return selector.nodes.some((node) => node.type === "pseudo" && node.value === ":hover");
|
|
53236
53399
|
}
|
|
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
53400
|
function isHiddenOrTemplateNotPseudo(node) {
|
|
53259
53401
|
if (!node || node.type !== "pseudo" || node.value !== ":not") return false;
|
|
53260
53402
|
const selector = node.first;
|
|
@@ -53277,23 +53419,6 @@ function handleCombinatorNode(node, index, context) {
|
|
|
53277
53419
|
nodes.splice(index + 1, 3, ...ast);
|
|
53278
53420
|
}
|
|
53279
53421
|
}
|
|
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
53422
|
function handleTagOrAttribute(node, context) {
|
|
53298
53423
|
stripUnsupportedNodeForUniAppX(node, context.options);
|
|
53299
53424
|
}
|
|
@@ -53308,6 +53433,11 @@ function handleSelectorNode(selector, context) {
|
|
|
53308
53433
|
}
|
|
53309
53434
|
if (transformSpacingSelector(selector.nodes, context.options)) context.requiresSpacingNormalization = true;
|
|
53310
53435
|
}
|
|
53436
|
+
//#endregion
|
|
53437
|
+
//#region src/selectorParser/rule-transformer.ts
|
|
53438
|
+
const ruleTransformCache = /* @__PURE__ */ new WeakMap();
|
|
53439
|
+
const SELECTOR_TRANSFORM_OPTIONS = normalizeTransformOptions();
|
|
53440
|
+
const SIMPLE_SELECTOR_FAST_PATH = /^[#.][\w-]+(?:\s+[#.][\w-]+)*$/;
|
|
53311
53441
|
function canSkipRuleTransform(rule) {
|
|
53312
53442
|
const selector = rule.selector.trim();
|
|
53313
53443
|
if (!selector) return false;
|
|
@@ -54088,11 +54218,46 @@ function makePseudoVarRule() {
|
|
|
54088
54218
|
function isEmptyContentInitDeclaration(decl) {
|
|
54089
54219
|
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
54090
54220
|
}
|
|
54221
|
+
function isPseudoContentInitSelector(selector) {
|
|
54222
|
+
return selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after";
|
|
54223
|
+
}
|
|
54224
|
+
function isElementContentInitSelector(selector) {
|
|
54225
|
+
return selector === "*" || selector === "view" || selector === "text";
|
|
54226
|
+
}
|
|
54227
|
+
function isOnlyEmptyContentInitRule(node) {
|
|
54228
|
+
let hasDeclaration = false;
|
|
54229
|
+
let onlyEmptyContentInit = true;
|
|
54230
|
+
node.walkDecls((decl) => {
|
|
54231
|
+
hasDeclaration = true;
|
|
54232
|
+
if (!isEmptyContentInitDeclaration(decl)) onlyEmptyContentInit = false;
|
|
54233
|
+
});
|
|
54234
|
+
return hasDeclaration && onlyEmptyContentInit;
|
|
54235
|
+
}
|
|
54236
|
+
function restorePseudoContentInitScope(node) {
|
|
54237
|
+
if (!isOnlyEmptyContentInitRule(node)) return false;
|
|
54238
|
+
let hasPseudoSelector = false;
|
|
54239
|
+
let hasElementSelector = false;
|
|
54240
|
+
for (const selector of node.selectors) if (isPseudoContentInitSelector(selector)) hasPseudoSelector = true;
|
|
54241
|
+
else if (isElementContentInitSelector(selector)) hasElementSelector = true;
|
|
54242
|
+
else return false;
|
|
54243
|
+
if (!hasPseudoSelector || !hasElementSelector) return false;
|
|
54244
|
+
assignRuleSelectors(node, ["::before", "::after"], {
|
|
54245
|
+
phase: "pre",
|
|
54246
|
+
reason: "restore-pseudo-content-init-scope"
|
|
54247
|
+
});
|
|
54248
|
+
return true;
|
|
54249
|
+
}
|
|
54091
54250
|
function removeTailwindV4EmptyContentInit(node) {
|
|
54092
54251
|
node.walkDecls((decl) => {
|
|
54093
54252
|
if (isEmptyContentInitDeclaration(decl)) decl.remove();
|
|
54094
54253
|
});
|
|
54095
54254
|
}
|
|
54255
|
+
function injectPreflightDeclarations(node, options) {
|
|
54256
|
+
const preflightDeclarations = options.cssInjectPreflight?.();
|
|
54257
|
+
if (!preflightDeclarations || preflightDeclarations.length === 0) return;
|
|
54258
|
+
node.prepend(...preflightDeclarations);
|
|
54259
|
+
node.raws.semicolon = true;
|
|
54260
|
+
}
|
|
54096
54261
|
function hasClassSelector(node) {
|
|
54097
54262
|
return node.selectors.some((selector) => selector.includes("."));
|
|
54098
54263
|
}
|
|
@@ -54118,7 +54283,7 @@ function resolveUniAppXVariableScopeSelectors(options) {
|
|
|
54118
54283
|
return ["view", "text"];
|
|
54119
54284
|
}
|
|
54120
54285
|
function commonChunkPreflight(node, options) {
|
|
54121
|
-
const { ctx,
|
|
54286
|
+
const { ctx, injectAdditionalCssVarScope } = options;
|
|
54122
54287
|
const uniAppXEnabled = isUniAppXEnabled(options);
|
|
54123
54288
|
const isTailwindcss4 = isTailwindcssV4(options);
|
|
54124
54289
|
const rootOption = options.cssSelectorReplacement?.root;
|
|
@@ -54131,6 +54296,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54131
54296
|
reason: "append-host-selector"
|
|
54132
54297
|
});
|
|
54133
54298
|
if (isTailwindcss4 && !usesTailwindcssV4ContentVariable(node.root()) && (!hasClassSelector(node) || isRootThemeScopeRule(node))) removeTailwindV4EmptyContentInit(node);
|
|
54299
|
+
if (!isTailwindcss4 && restorePseudoContentInitScope(node)) return;
|
|
54134
54300
|
if (testIfVariablesScope(node) || uniAppXEnabled && node.selectors.includes("*") && hasTwVars(node, 2)) {
|
|
54135
54301
|
ctx?.markVariablesScope(node);
|
|
54136
54302
|
assignRuleSelectors(node, uniAppXEnabled ? resolveUniAppXVariableScopeSelectors(options) : remakeCssVarSelector(node.selectors, options), {
|
|
@@ -54138,7 +54304,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54138
54304
|
reason: "rewrite-variable-scope"
|
|
54139
54305
|
});
|
|
54140
54306
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54141
|
-
|
|
54307
|
+
injectPreflightDeclarations(node, options);
|
|
54142
54308
|
}
|
|
54143
54309
|
if (injectAdditionalCssVarScope && (isTailwindcss4 ? testIfRootHostForV4(node) : testIfTwBackdrop(node))) {
|
|
54144
54310
|
const nodes = isTailwindcss4 ? createUsedCssVarsV4Nodes(collectUsedTailwindcssV4Variables(node.root())) : cssVarsV3Nodes;
|
|
@@ -54157,7 +54323,7 @@ function commonChunkPreflight(node, options) {
|
|
|
54157
54323
|
});
|
|
54158
54324
|
node.before(syntheticRule);
|
|
54159
54325
|
if (!uniAppXEnabled && !isTailwindcss4) node.before(makePseudoVarRule());
|
|
54160
|
-
|
|
54326
|
+
injectPreflightDeclarations(syntheticRule, options);
|
|
54161
54327
|
}
|
|
54162
54328
|
}
|
|
54163
54329
|
//#endregion
|