weapp-tailwindcss 5.1.5 → 5.1.6
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/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +7 -0
- package/dist/{context-rrYZuUBU.mjs → context-3GGqW9vw.mjs} +3 -3
- package/dist/{context-BziwyWy1.js → context-BCSk_YnL.js} +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-24-HgU9F.mjs → generator-CoT5vu9w.mjs} +2 -2
- package/dist/{generator-CilgHtxb.js → generator-CqWzj2Z1.js} +2 -2
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-ygWfmOqh.mjs → gulp-Bss4wJ8t.mjs} +4 -4
- package/dist/{gulp-CuVsZdO9.js → gulp-hXE1U4Cu.js} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-Dh_nn3w5.mjs → hmr-timing-Cfu-4Bnf.mjs} +24 -511
- package/dist/{hmr-timing-BKdCeIrn.js → hmr-timing-Df4203aI.js} +48 -565
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +6 -3
- package/dist/presets.mjs +6 -3
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/runtime-branch/generator-target-env.d.ts +1 -0
- package/dist/{source-candidate-scan-signature-DIj9m4wB.js → source-candidate-scan-signature-5Uk6U72B.js} +3 -3
- package/dist/{source-candidate-scan-signature-DATRnS1X.mjs → source-candidate-scan-signature-BbCmW975.mjs} +3 -3
- package/dist/{tailwindcss-C-uM4rB8.mjs → tailwindcss-Bjr3aphG.mjs} +15 -2
- package/dist/{tailwindcss-BwoNQ3t8.js → tailwindcss-DYJ3HZD2.js} +15 -2
- package/dist/{transform-DHLemtaX.mjs → transform--155BmeJ.mjs} +1 -1
- package/dist/{transform-KLD1tJdb.js → transform-B6_y_yCB.js} +1 -1
- package/dist/{v4-engine-CKtsdKxK.js → v4-engine-C9cmNlP8.js} +610 -3
- package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-DRQaCFMm.mjs} +529 -6
- package/dist/{vite-Yp14HNyS.js → vite-Baw9qNrc.js} +560 -112
- package/dist/{vite-cH0tTMHc.mjs → vite-PdxjaqhO.mjs} +561 -113
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +2994 -2958
- package/dist/{webpack-DBhmJ-_P.mjs → webpack-BffTDmod.mjs} +12 -13
- package/dist/{webpack-DN3tgLbF.js → webpack-C9u7mfGE.js} +18 -19
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
-
const require_v4_engine = require("./v4-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_context = require("./context-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
|
|
3
|
+
const require_generator = require("./generator-CqWzj2Z1.js");
|
|
4
|
+
const require_context = require("./context-BCSk_YnL.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
@@ -185,8 +185,11 @@ function isVueScopedStyleSource(from) {
|
|
|
185
185
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
186
186
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
187
187
|
}
|
|
188
|
+
function isMiniProgramGeneratorTarget(target) {
|
|
189
|
+
return target !== "web";
|
|
190
|
+
}
|
|
188
191
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
189
|
-
if (target
|
|
192
|
+
if (!isMiniProgramGeneratorTarget(target)) return css;
|
|
190
193
|
if (isVueScopedStyleSource(options.styleOptions?.postcssOptions?.options?.from)) return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
191
194
|
cssPreflight: false,
|
|
192
195
|
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
@@ -1385,501 +1388,6 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1385
1388
|
return resolved?.entries;
|
|
1386
1389
|
}
|
|
1387
1390
|
//#endregion
|
|
1388
|
-
//#region src/bundlers/shared/generator-css/user-css.ts
|
|
1389
|
-
const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
|
|
1390
|
-
"config",
|
|
1391
|
-
"custom-variant",
|
|
1392
|
-
"plugin",
|
|
1393
|
-
"source",
|
|
1394
|
-
"theme",
|
|
1395
|
-
"utility",
|
|
1396
|
-
"variant"
|
|
1397
|
-
]);
|
|
1398
|
-
function removeBalancedAtRuleBlock(source, atRuleStart) {
|
|
1399
|
-
const blockStart = source.indexOf("{", atRuleStart);
|
|
1400
|
-
if (blockStart === -1) {
|
|
1401
|
-
const semicolon = source.indexOf(";", atRuleStart);
|
|
1402
|
-
return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
|
|
1403
|
-
}
|
|
1404
|
-
let depth = 0;
|
|
1405
|
-
for (let index = blockStart; index < source.length; index++) {
|
|
1406
|
-
const char = source[index];
|
|
1407
|
-
if (char === "{") {
|
|
1408
|
-
depth++;
|
|
1409
|
-
continue;
|
|
1410
|
-
}
|
|
1411
|
-
if (char !== "}") continue;
|
|
1412
|
-
depth--;
|
|
1413
|
-
if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
|
|
1414
|
-
}
|
|
1415
|
-
return source.slice(0, atRuleStart);
|
|
1416
|
-
}
|
|
1417
|
-
function removeTailwindV4GeneratorAtRulesFallback(source) {
|
|
1418
|
-
let next = source;
|
|
1419
|
-
let changed = false;
|
|
1420
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1421
|
-
for (;;) {
|
|
1422
|
-
sourceMediaRE.lastIndex = 0;
|
|
1423
|
-
const match = sourceMediaRE.exec(next);
|
|
1424
|
-
if (!match) break;
|
|
1425
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1426
|
-
changed = true;
|
|
1427
|
-
}
|
|
1428
|
-
const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
|
|
1429
|
-
for (;;) {
|
|
1430
|
-
atRuleRE.lastIndex = 0;
|
|
1431
|
-
const match = atRuleRE.exec(next);
|
|
1432
|
-
if (!match) break;
|
|
1433
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1434
|
-
changed = true;
|
|
1435
|
-
}
|
|
1436
|
-
return changed ? next : source;
|
|
1437
|
-
}
|
|
1438
|
-
function isTailwindGeneratedPreflightComment(text) {
|
|
1439
|
-
return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
|
|
1440
|
-
}
|
|
1441
|
-
function isTailwindGeneratedThemeRule(selector, node) {
|
|
1442
|
-
if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
|
|
1443
|
-
return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
|
|
1444
|
-
}
|
|
1445
|
-
function isTailwindGeneratedPreflightRule(selector, node) {
|
|
1446
|
-
if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
|
|
1447
|
-
if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
|
|
1448
|
-
if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
|
|
1449
|
-
return false;
|
|
1450
|
-
}
|
|
1451
|
-
function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
1452
|
-
try {
|
|
1453
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1454
|
-
let changed = false;
|
|
1455
|
-
root.walkComments((comment) => {
|
|
1456
|
-
if (!isTailwindGeneratedPreflightComment(comment.text)) return;
|
|
1457
|
-
comment.remove();
|
|
1458
|
-
changed = true;
|
|
1459
|
-
});
|
|
1460
|
-
root.walkRules((rule) => {
|
|
1461
|
-
const selector = rule.selector.replace(/\s+/g, " ").trim();
|
|
1462
|
-
if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
|
|
1463
|
-
rule.remove();
|
|
1464
|
-
changed = true;
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
root.walkAtRules((rule) => {
|
|
1468
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
1469
|
-
rule.remove();
|
|
1470
|
-
changed = true;
|
|
1471
|
-
}
|
|
1472
|
-
});
|
|
1473
|
-
return changed ? root.toString() : source;
|
|
1474
|
-
} catch {
|
|
1475
|
-
return source;
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
function removeTailwindSourceMediaBlocks(source) {
|
|
1479
|
-
let next = source;
|
|
1480
|
-
let changed = false;
|
|
1481
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1482
|
-
for (;;) {
|
|
1483
|
-
sourceMediaRE.lastIndex = 0;
|
|
1484
|
-
const match = sourceMediaRE.exec(next);
|
|
1485
|
-
if (!match) break;
|
|
1486
|
-
const blockStart = next.indexOf("{", match.index);
|
|
1487
|
-
if (blockStart === -1) break;
|
|
1488
|
-
let depth = 0;
|
|
1489
|
-
let blockEnd = -1;
|
|
1490
|
-
for (let index = blockStart; index < next.length; index++) {
|
|
1491
|
-
const char = next[index];
|
|
1492
|
-
if (char === "{") {
|
|
1493
|
-
depth++;
|
|
1494
|
-
continue;
|
|
1495
|
-
}
|
|
1496
|
-
if (char !== "}") continue;
|
|
1497
|
-
depth--;
|
|
1498
|
-
if (depth === 0) {
|
|
1499
|
-
blockEnd = index;
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
if (blockEnd === -1) break;
|
|
1504
|
-
next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
|
|
1505
|
-
changed = true;
|
|
1506
|
-
}
|
|
1507
|
-
for (;;) {
|
|
1508
|
-
const atRuleStart = findTailwindSourceWrapperBlockStart(next);
|
|
1509
|
-
if (atRuleStart === -1) break;
|
|
1510
|
-
next = removeBalancedAtRuleBlock(next, atRuleStart);
|
|
1511
|
-
changed = true;
|
|
1512
|
-
}
|
|
1513
|
-
return changed ? next : source;
|
|
1514
|
-
}
|
|
1515
|
-
function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
|
|
1516
|
-
if (!source.includes("@source")) return source;
|
|
1517
|
-
let next = "";
|
|
1518
|
-
let searchIndex = 0;
|
|
1519
|
-
for (;;) {
|
|
1520
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1521
|
-
if (atRuleStart === -1) {
|
|
1522
|
-
next += source.slice(searchIndex);
|
|
1523
|
-
break;
|
|
1524
|
-
}
|
|
1525
|
-
const nextChar = source[atRuleStart + 7];
|
|
1526
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1527
|
-
next += source.slice(searchIndex, atRuleStart + 7);
|
|
1528
|
-
searchIndex = atRuleStart + 7;
|
|
1529
|
-
continue;
|
|
1530
|
-
}
|
|
1531
|
-
next += source.slice(searchIndex, atRuleStart);
|
|
1532
|
-
let quote;
|
|
1533
|
-
let parenDepth = 0;
|
|
1534
|
-
let terminated = false;
|
|
1535
|
-
let index = atRuleStart + 7;
|
|
1536
|
-
for (; index < source.length; index++) {
|
|
1537
|
-
const char = source[index];
|
|
1538
|
-
if (quote) {
|
|
1539
|
-
if (char === "\\") {
|
|
1540
|
-
index++;
|
|
1541
|
-
continue;
|
|
1542
|
-
}
|
|
1543
|
-
if (char === quote) quote = void 0;
|
|
1544
|
-
continue;
|
|
1545
|
-
}
|
|
1546
|
-
if (char === "\"" || char === "'") {
|
|
1547
|
-
quote = char;
|
|
1548
|
-
continue;
|
|
1549
|
-
}
|
|
1550
|
-
if (char === "(") {
|
|
1551
|
-
parenDepth++;
|
|
1552
|
-
continue;
|
|
1553
|
-
}
|
|
1554
|
-
if (char === ")" && parenDepth > 0) {
|
|
1555
|
-
parenDepth--;
|
|
1556
|
-
continue;
|
|
1557
|
-
}
|
|
1558
|
-
if (parenDepth > 0) continue;
|
|
1559
|
-
if (char === ";" || char === "{") {
|
|
1560
|
-
terminated = true;
|
|
1561
|
-
index++;
|
|
1562
|
-
break;
|
|
1563
|
-
}
|
|
1564
|
-
if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
|
|
1565
|
-
}
|
|
1566
|
-
const segment = source.slice(atRuleStart, index);
|
|
1567
|
-
const trimmedSegment = segment.trimEnd();
|
|
1568
|
-
next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
|
|
1569
|
-
searchIndex = index;
|
|
1570
|
-
}
|
|
1571
|
-
return next;
|
|
1572
|
-
}
|
|
1573
|
-
function findTailwindSourceWrapperBlockStart(source) {
|
|
1574
|
-
let searchIndex = 0;
|
|
1575
|
-
for (;;) {
|
|
1576
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1577
|
-
if (atRuleStart === -1) return -1;
|
|
1578
|
-
const nextChar = source[atRuleStart + 7];
|
|
1579
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1580
|
-
searchIndex = atRuleStart + 7;
|
|
1581
|
-
continue;
|
|
1582
|
-
}
|
|
1583
|
-
let quote;
|
|
1584
|
-
let parenDepth = 0;
|
|
1585
|
-
for (let index = atRuleStart + 7; index < source.length; index++) {
|
|
1586
|
-
const char = source[index];
|
|
1587
|
-
if (quote) {
|
|
1588
|
-
if (char === "\\") {
|
|
1589
|
-
index++;
|
|
1590
|
-
continue;
|
|
1591
|
-
}
|
|
1592
|
-
if (char === quote) quote = void 0;
|
|
1593
|
-
continue;
|
|
1594
|
-
}
|
|
1595
|
-
if (char === "\"" || char === "'") {
|
|
1596
|
-
quote = char;
|
|
1597
|
-
continue;
|
|
1598
|
-
}
|
|
1599
|
-
if (char === "(") {
|
|
1600
|
-
parenDepth++;
|
|
1601
|
-
continue;
|
|
1602
|
-
}
|
|
1603
|
-
if (char === ")" && parenDepth > 0) {
|
|
1604
|
-
parenDepth--;
|
|
1605
|
-
continue;
|
|
1606
|
-
}
|
|
1607
|
-
if (parenDepth > 0) continue;
|
|
1608
|
-
if (char === ";") {
|
|
1609
|
-
searchIndex = index + 1;
|
|
1610
|
-
break;
|
|
1611
|
-
}
|
|
1612
|
-
if (char === "{") return atRuleStart;
|
|
1613
|
-
}
|
|
1614
|
-
if (searchIndex <= atRuleStart) return -1;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
function removeTailwindApplyAtRules(source) {
|
|
1618
|
-
if (!source.includes("@apply")) return source;
|
|
1619
|
-
try {
|
|
1620
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1621
|
-
let changed = false;
|
|
1622
|
-
root.walkAtRules("apply", (rule) => {
|
|
1623
|
-
rule.remove();
|
|
1624
|
-
changed = true;
|
|
1625
|
-
});
|
|
1626
|
-
root.walk((node) => {
|
|
1627
|
-
if ("nodes" in node && node.nodes?.length === 0) node.remove();
|
|
1628
|
-
});
|
|
1629
|
-
return changed ? root.toString() : source;
|
|
1630
|
-
} catch {
|
|
1631
|
-
return source;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
function removeTailwindV4GeneratorAtRules(source) {
|
|
1635
|
-
try {
|
|
1636
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1637
|
-
let changed = false;
|
|
1638
|
-
root.walkAtRules((rule) => {
|
|
1639
|
-
if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
|
|
1640
|
-
rule.remove();
|
|
1641
|
-
changed = true;
|
|
1642
|
-
return;
|
|
1643
|
-
}
|
|
1644
|
-
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
1645
|
-
rule.remove();
|
|
1646
|
-
changed = true;
|
|
1647
|
-
});
|
|
1648
|
-
return changed ? root.toString() : source;
|
|
1649
|
-
} catch {
|
|
1650
|
-
return removeTailwindV4GeneratorAtRulesFallback(source);
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
function isCommentOnlyCss(source) {
|
|
1654
|
-
try {
|
|
1655
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1656
|
-
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1657
|
-
} catch {
|
|
1658
|
-
return false;
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
function removeMiniProgramHoverSelectors(source, enabled = true) {
|
|
1662
|
-
if (!enabled || !source.includes(":hover")) return source;
|
|
1663
|
-
try {
|
|
1664
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1665
|
-
let changed = false;
|
|
1666
|
-
root.walkRules((rule) => {
|
|
1667
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1668
|
-
const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
|
|
1669
|
-
if (keptSelectors.length === selectors.length) return;
|
|
1670
|
-
changed = true;
|
|
1671
|
-
if (keptSelectors.length === 0) {
|
|
1672
|
-
rule.remove();
|
|
1673
|
-
return;
|
|
1674
|
-
}
|
|
1675
|
-
rule.selectors = keptSelectors;
|
|
1676
|
-
});
|
|
1677
|
-
root.walk((node) => {
|
|
1678
|
-
if ("nodes" in node && node.nodes?.length === 0) {
|
|
1679
|
-
node.remove();
|
|
1680
|
-
changed = true;
|
|
1681
|
-
}
|
|
1682
|
-
});
|
|
1683
|
-
return changed ? root.toString() : source;
|
|
1684
|
-
} catch {
|
|
1685
|
-
return source;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
function removeProcessedMiniProgramUnsupportedCss(source, options) {
|
|
1689
|
-
return removeMiniProgramHoverSelectors((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(source), options.cssRemoveHoverPseudoClass);
|
|
1690
|
-
}
|
|
1691
|
-
function unwrapMiniProgramCascadeLayers(source) {
|
|
1692
|
-
if (!source.includes("@layer")) return source;
|
|
1693
|
-
try {
|
|
1694
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1695
|
-
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
1696
|
-
return root.toString();
|
|
1697
|
-
} catch {
|
|
1698
|
-
return source;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
function stripTailwindSourceMediaFragments(source) {
|
|
1702
|
-
let removedSourceMediaStart = false;
|
|
1703
|
-
return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
|
|
1704
|
-
if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
|
|
1705
|
-
removedSourceMediaStart = true;
|
|
1706
|
-
return false;
|
|
1707
|
-
}
|
|
1708
|
-
if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
|
|
1709
|
-
if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
|
|
1710
|
-
removedSourceMediaStart = false;
|
|
1711
|
-
return false;
|
|
1712
|
-
}
|
|
1713
|
-
return true;
|
|
1714
|
-
}).join("\n");
|
|
1715
|
-
}
|
|
1716
|
-
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1717
|
-
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1718
|
-
}
|
|
1719
|
-
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1720
|
-
try {
|
|
1721
|
-
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1722
|
-
return source;
|
|
1723
|
-
} catch {
|
|
1724
|
-
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
function splitUserCssLayerBlocks(source) {
|
|
1728
|
-
if (!source.includes("@layer")) return {
|
|
1729
|
-
layer: "",
|
|
1730
|
-
rest: source
|
|
1731
|
-
};
|
|
1732
|
-
try {
|
|
1733
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1734
|
-
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1735
|
-
const restRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1736
|
-
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1737
|
-
return {
|
|
1738
|
-
layer: layerRoot.toString(),
|
|
1739
|
-
rest: restRoot.toString()
|
|
1740
|
-
};
|
|
1741
|
-
} catch {
|
|
1742
|
-
return {
|
|
1743
|
-
layer: source,
|
|
1744
|
-
rest: ""
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
function hasUserCssLayerBlocks(source) {
|
|
1749
|
-
if (!source.includes("@layer")) return false;
|
|
1750
|
-
try {
|
|
1751
|
-
let hasLayerBlock = false;
|
|
1752
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1753
|
-
if (node.nodes?.length) hasLayerBlock = true;
|
|
1754
|
-
});
|
|
1755
|
-
return hasLayerBlock;
|
|
1756
|
-
} catch {
|
|
1757
|
-
return true;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
function collectUserLayerSelectors(source) {
|
|
1761
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1762
|
-
try {
|
|
1763
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1764
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1765
|
-
const normalized = selector.trim();
|
|
1766
|
-
if (normalized) selectors.add(normalized);
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
1769
|
-
} catch {}
|
|
1770
|
-
return selectors;
|
|
1771
|
-
}
|
|
1772
|
-
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1773
|
-
if (selector === userLayerSelector) return true;
|
|
1774
|
-
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1775
|
-
const next = selector[userLayerSelector.length];
|
|
1776
|
-
return next === ":" || next === "[";
|
|
1777
|
-
}
|
|
1778
|
-
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1779
|
-
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1780
|
-
if (selectors.size === 0) return {
|
|
1781
|
-
layer: "",
|
|
1782
|
-
rest: css
|
|
1783
|
-
};
|
|
1784
|
-
try {
|
|
1785
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1786
|
-
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1787
|
-
const selectorList = [...selectors];
|
|
1788
|
-
root.walkRules((rule) => {
|
|
1789
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1790
|
-
layerRoot.append(rule.clone());
|
|
1791
|
-
rule.remove();
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
return {
|
|
1795
|
-
layer: layerRoot.toString(),
|
|
1796
|
-
rest: root.toString()
|
|
1797
|
-
};
|
|
1798
|
-
} catch {
|
|
1799
|
-
return {
|
|
1800
|
-
layer: "",
|
|
1801
|
-
rest: css
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
function normalizeGeneratedSelector(selector) {
|
|
1806
|
-
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1807
|
-
}
|
|
1808
|
-
function collectApplyOnlySourceSelectors(source) {
|
|
1809
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1810
|
-
try {
|
|
1811
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1812
|
-
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1813
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1814
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1815
|
-
if (normalized) selectors.add(normalized);
|
|
1816
|
-
}
|
|
1817
|
-
});
|
|
1818
|
-
} catch {}
|
|
1819
|
-
return selectors;
|
|
1820
|
-
}
|
|
1821
|
-
function hasOnlyApplyBackedSourceRules(source) {
|
|
1822
|
-
let hasApplyRule = false;
|
|
1823
|
-
let hasNonApplyRule = false;
|
|
1824
|
-
try {
|
|
1825
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1826
|
-
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1827
|
-
else hasNonApplyRule = true;
|
|
1828
|
-
});
|
|
1829
|
-
} catch {
|
|
1830
|
-
return false;
|
|
1831
|
-
}
|
|
1832
|
-
return hasApplyRule && !hasNonApplyRule;
|
|
1833
|
-
}
|
|
1834
|
-
function filterApplyOnlyGeneratedCss(css, source) {
|
|
1835
|
-
const selectors = collectApplyOnlySourceSelectors(source);
|
|
1836
|
-
if (selectors.size === 0) return css;
|
|
1837
|
-
const selectorList = [...selectors];
|
|
1838
|
-
try {
|
|
1839
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1840
|
-
root.walkRules((rule) => {
|
|
1841
|
-
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
1842
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1843
|
-
return selectorList.some((sourceSelector) => {
|
|
1844
|
-
if (normalized === sourceSelector) return true;
|
|
1845
|
-
if (!normalized.startsWith(sourceSelector)) return false;
|
|
1846
|
-
const next = normalized[sourceSelector.length];
|
|
1847
|
-
return next === ":" || next === "[" || next === ".";
|
|
1848
|
-
});
|
|
1849
|
-
});
|
|
1850
|
-
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
1851
|
-
if (!isApplySelector && !isVariableRule) rule.remove();
|
|
1852
|
-
});
|
|
1853
|
-
root.walkAtRules((rule) => {
|
|
1854
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1855
|
-
});
|
|
1856
|
-
return root.toString();
|
|
1857
|
-
} catch {
|
|
1858
|
-
return css;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
1862
|
-
return target === "weapp" && require_v4_engine.hasTailwindApplyDirective(source) && !require_v4_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
1863
|
-
}
|
|
1864
|
-
async function transformGeneratorUserCss(source, options) {
|
|
1865
|
-
if (source.trim().length === 0) return "";
|
|
1866
|
-
if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
|
|
1867
|
-
...options.generatorStyleOptions,
|
|
1868
|
-
...options.cssUserHandlerOptions
|
|
1869
|
-
})) : source)));
|
|
1870
|
-
const cleanedSource = require_v4_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1871
|
-
if (cleanedSource.trim().length === 0) return "";
|
|
1872
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v4_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1873
|
-
if (userSource.trim().length === 0) return "";
|
|
1874
|
-
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1875
|
-
if (options.generatorTarget !== "weapp") return userSource;
|
|
1876
|
-
const { css } = await options.styleHandler(userSource, {
|
|
1877
|
-
...options.generatorStyleOptions,
|
|
1878
|
-
...options.cssUserHandlerOptions
|
|
1879
|
-
});
|
|
1880
|
-
return removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
|
|
1881
|
-
}
|
|
1882
|
-
//#endregion
|
|
1883
1391
|
//#region src/bundlers/shared/generator-css/legacy-compat.ts
|
|
1884
1392
|
const LEGACY_CONTAINER_COMPAT_CSS = [
|
|
1885
1393
|
".container {",
|
|
@@ -2005,7 +1513,7 @@ function removeTailwindApplyRules(rawSource) {
|
|
|
2005
1513
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
2006
1514
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
2007
1515
|
if (cached !== void 0) return cached;
|
|
2008
|
-
const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
|
|
1516
|
+
const resolved = closeTrailingUnclosedBlocks(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
|
|
2009
1517
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
2010
1518
|
return resolved;
|
|
2011
1519
|
}
|
|
@@ -2073,7 +1581,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
2073
1581
|
compatCss = (await styleHandler(compatSource, styleOptions)).css;
|
|
2074
1582
|
setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
|
|
2075
1583
|
}
|
|
2076
|
-
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
|
|
1584
|
+
const cleanedCompatCss = collectDedupedPostTransformCompatCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
|
|
2077
1585
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
2078
1586
|
return require_v4_engine.createCssAppend(css, cleanedCompatCss);
|
|
2079
1587
|
}
|
|
@@ -2384,11 +1892,12 @@ function finalizeWebGeneratorCss(css, target, webCompat) {
|
|
|
2384
1892
|
return target === "web" ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
|
|
2385
1893
|
}
|
|
2386
1894
|
async function generateCssByGenerator(options) {
|
|
2387
|
-
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1895
|
+
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, generatorPlatform, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1896
|
+
const platform = generatorPlatform ?? opts.cssOptions?.platform ?? opts.platform;
|
|
2388
1897
|
const generatorOptions = {
|
|
2389
1898
|
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2390
1899
|
appType: opts.appType,
|
|
2391
|
-
platform
|
|
1900
|
+
platform,
|
|
2392
1901
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2393
1902
|
uniAppX: opts.uniAppX
|
|
2394
1903
|
}),
|
|
@@ -2396,13 +1905,13 @@ async function generateCssByGenerator(options) {
|
|
|
2396
1905
|
};
|
|
2397
1906
|
const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
2398
1907
|
appType: opts.appType,
|
|
2399
|
-
platform
|
|
1908
|
+
platform,
|
|
2400
1909
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2401
1910
|
uniAppX: opts.uniAppX
|
|
2402
1911
|
});
|
|
2403
1912
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2404
1913
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
2405
|
-
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1914
|
+
const effectiveRawSource = require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2406
1915
|
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
2407
1916
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2408
1917
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
@@ -2420,12 +1929,12 @@ async function generateCssByGenerator(options) {
|
|
|
2420
1929
|
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2421
1930
|
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
2422
1931
|
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
2423
|
-
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
1932
|
+
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
|
|
2424
1933
|
};
|
|
2425
1934
|
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
2426
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
1935
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2427
1936
|
const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
|
|
2428
|
-
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
1937
|
+
const userCssRawSource = require_v4_engine.removeTailwindV4GeneratorAtRules(userSource);
|
|
2429
1938
|
const generatedUserCssOrderSource = require_v4_engine.hasTailwindGeneratedCss(userSource) ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
2430
1939
|
const generatedUserCssRawSource = generatedUserCssOrderSource ? require_v4_engine.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_v4_engine.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
2431
1940
|
const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_v4_engine.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
@@ -2433,6 +1942,10 @@ async function generateCssByGenerator(options) {
|
|
|
2433
1942
|
const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
|
|
2434
1943
|
const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
2435
1944
|
const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
1945
|
+
const normalizedCssSources = options.cssSources?.map((source) => ({
|
|
1946
|
+
...source,
|
|
1947
|
+
css: require_v4_engine.normalizeEmptyTailwindCustomVariants(source.css)
|
|
1948
|
+
}));
|
|
2436
1949
|
if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
2437
1950
|
forceGenerator: options.forceGenerator,
|
|
2438
1951
|
hasGeneratedCss,
|
|
@@ -2454,7 +1967,7 @@ async function generateCssByGenerator(options) {
|
|
|
2454
1967
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
2455
1968
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
2456
1969
|
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
2457
|
-
cssSources:
|
|
1970
|
+
cssSources: normalizedCssSources,
|
|
2458
1971
|
getSourceCandidatesForEntries,
|
|
2459
1972
|
runtime: runtimeWithCurrentCss
|
|
2460
1973
|
});
|
|
@@ -2495,12 +2008,12 @@ async function generateCssByGenerator(options) {
|
|
|
2495
2008
|
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
2496
2009
|
if (!generated) return;
|
|
2497
2010
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
2498
|
-
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2011
|
+
if ((generated.target !== "weapp" || !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2499
2012
|
const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
|
|
2500
2013
|
const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? require_v4_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2501
2014
|
injectPreflight: false,
|
|
2502
2015
|
styleOptions: generatorStyleOptions
|
|
2503
|
-
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
2016
|
+
})) : options.previousCss, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
|
|
2504
2017
|
return {
|
|
2505
2018
|
css: finalCss,
|
|
2506
2019
|
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
@@ -2515,12 +2028,12 @@ async function generateCssByGenerator(options) {
|
|
|
2515
2028
|
}
|
|
2516
2029
|
};
|
|
2517
2030
|
}
|
|
2518
|
-
const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2031
|
+
const shouldFilterApplyOnlyCss = require_v4_engine.shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2519
2032
|
hasGeneratedCss,
|
|
2520
2033
|
hasGeneratedMarkers
|
|
2521
2034
|
});
|
|
2522
2035
|
const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
|
|
2523
|
-
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
2036
|
+
const generatedCss = shouldFilterApplyOnlyCss ? require_v4_engine.filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
|
|
2524
2037
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2525
2038
|
const hasExplicitCssSource = sources.some((source) => {
|
|
2526
2039
|
const metadata = source.__weappTailwindcssMeta;
|
|
@@ -2548,29 +2061,29 @@ async function generateCssByGenerator(options) {
|
|
|
2548
2061
|
importFallback: generatorOptions.importFallback,
|
|
2549
2062
|
processed: userRawSourceProcessed
|
|
2550
2063
|
};
|
|
2551
|
-
const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2064
|
+
const afterLayerParts = generated.target === "weapp" ? require_v4_engine.splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2552
2065
|
layer: "",
|
|
2553
2066
|
rest: orderedExtraCss.after
|
|
2554
2067
|
};
|
|
2555
|
-
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2556
|
-
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2557
|
-
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2558
|
-
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && hasUserCssLayerBlocks(userCssRawSource) ? await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2068
|
+
const beforeUserCss = await require_v4_engine.transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2069
|
+
const afterLayerUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2070
|
+
const afterUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2071
|
+
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && require_v4_engine.hasUserCssLayerBlocks(userCssRawSource) ? await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2559
2072
|
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2560
2073
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2561
2074
|
hasSourceDirectives,
|
|
2562
2075
|
hasMatchedCssSourceFile
|
|
2563
2076
|
})) {
|
|
2564
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2077
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2565
2078
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2566
2079
|
}
|
|
2567
2080
|
if (generated.target === "web") {
|
|
2568
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2569
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2081
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2082
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2570
2083
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2571
2084
|
}
|
|
2572
2085
|
if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2573
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2086
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2574
2087
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2575
2088
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2576
2089
|
}
|
|
@@ -2601,7 +2114,7 @@ async function generateCssByGenerator(options) {
|
|
|
2601
2114
|
}
|
|
2602
2115
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
2603
2116
|
let css = generatedCss;
|
|
2604
|
-
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2117
|
+
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2605
2118
|
generatorTarget: generated.target,
|
|
2606
2119
|
generatorStyleOptions,
|
|
2607
2120
|
cssUserHandlerOptions,
|
|
@@ -2611,9 +2124,9 @@ async function generateCssByGenerator(options) {
|
|
|
2611
2124
|
}), css);
|
|
2612
2125
|
if (generated.target === "weapp") {
|
|
2613
2126
|
css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
|
|
2614
|
-
if (hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2615
|
-
const layerParts = splitUserCssLayerBlocks(generatorRawSource);
|
|
2616
|
-
const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
|
|
2127
|
+
if (require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2128
|
+
const layerParts = require_v4_engine.splitUserCssLayerBlocks(generatorRawSource);
|
|
2129
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(layerParts.layer, {
|
|
2617
2130
|
generatorTarget: generated.target,
|
|
2618
2131
|
generatorStyleOptions,
|
|
2619
2132
|
cssUserHandlerOptions,
|
|
@@ -2624,7 +2137,7 @@ async function generateCssByGenerator(options) {
|
|
|
2624
2137
|
const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
|
|
2625
2138
|
layer: layerUserCss,
|
|
2626
2139
|
rest: css
|
|
2627
|
-
} : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2140
|
+
} : require_v4_engine.extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2628
2141
|
if (layerCss.layer.trim().length > 0) {
|
|
2629
2142
|
css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
|
|
2630
2143
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
@@ -2633,7 +2146,7 @@ async function generateCssByGenerator(options) {
|
|
|
2633
2146
|
}
|
|
2634
2147
|
if (hasMatchedCssSourceFile || generated.target === "web") {
|
|
2635
2148
|
if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2636
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2149
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2637
2150
|
generatorTarget: generated.target,
|
|
2638
2151
|
generatorStyleOptions,
|
|
2639
2152
|
cssUserHandlerOptions,
|
|
@@ -2644,7 +2157,7 @@ async function generateCssByGenerator(options) {
|
|
|
2644
2157
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2645
2158
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2646
2159
|
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
|
|
2647
|
-
const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2160
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2648
2161
|
generatorTarget: generated.target,
|
|
2649
2162
|
generatorStyleOptions,
|
|
2650
2163
|
cssUserHandlerOptions,
|
|
@@ -2654,8 +2167,8 @@ async function generateCssByGenerator(options) {
|
|
|
2654
2167
|
});
|
|
2655
2168
|
const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2656
2169
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2657
|
-
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2658
|
-
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2170
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2171
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2659
2172
|
generatorTarget: generated.target,
|
|
2660
2173
|
generatorStyleOptions,
|
|
2661
2174
|
cssUserHandlerOptions,
|
|
@@ -2675,7 +2188,7 @@ async function generateCssByGenerator(options) {
|
|
|
2675
2188
|
hasSourceDirectives,
|
|
2676
2189
|
hasMatchedCssSourceFile
|
|
2677
2190
|
})) {
|
|
2678
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2191
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2679
2192
|
generatorTarget: generated.target,
|
|
2680
2193
|
generatorStyleOptions,
|
|
2681
2194
|
cssUserHandlerOptions,
|
|
@@ -2683,7 +2196,7 @@ async function generateCssByGenerator(options) {
|
|
|
2683
2196
|
importFallback: generatorOptions.importFallback,
|
|
2684
2197
|
processed: userRawSourceProcessed
|
|
2685
2198
|
});
|
|
2686
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2199
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2687
2200
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2688
2201
|
}
|
|
2689
2202
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
@@ -2709,7 +2222,7 @@ async function generateCssByGenerator(options) {
|
|
|
2709
2222
|
css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2710
2223
|
}
|
|
2711
2224
|
if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2712
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2225
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2713
2226
|
generatorTarget: generated.target,
|
|
2714
2227
|
generatorStyleOptions,
|
|
2715
2228
|
cssUserHandlerOptions,
|
|
@@ -3681,24 +3194,6 @@ Object.defineProperty(exports, "removeGeneratedSelectorCompatCss", {
|
|
|
3681
3194
|
return removeGeneratedSelectorCompatCss;
|
|
3682
3195
|
}
|
|
3683
3196
|
});
|
|
3684
|
-
Object.defineProperty(exports, "removeMiniProgramHoverSelectors", {
|
|
3685
|
-
enumerable: true,
|
|
3686
|
-
get: function() {
|
|
3687
|
-
return removeMiniProgramHoverSelectors;
|
|
3688
|
-
}
|
|
3689
|
-
});
|
|
3690
|
-
Object.defineProperty(exports, "removeTailwindV4GeneratedUserCssArtifacts", {
|
|
3691
|
-
enumerable: true,
|
|
3692
|
-
get: function() {
|
|
3693
|
-
return removeTailwindV4GeneratedUserCssArtifacts;
|
|
3694
|
-
}
|
|
3695
|
-
});
|
|
3696
|
-
Object.defineProperty(exports, "removeTailwindV4GeneratorAtRules", {
|
|
3697
|
-
enumerable: true,
|
|
3698
|
-
get: function() {
|
|
3699
|
-
return removeTailwindV4GeneratorAtRules;
|
|
3700
|
-
}
|
|
3701
|
-
});
|
|
3702
3197
|
Object.defineProperty(exports, "resolveSourceCandidateScanFiles", {
|
|
3703
3198
|
enumerable: true,
|
|
3704
3199
|
get: function() {
|
|
@@ -3723,18 +3218,6 @@ Object.defineProperty(exports, "scoreTailwindV4CssSourceFileMatch", {
|
|
|
3723
3218
|
return scoreTailwindV4CssSourceFileMatch;
|
|
3724
3219
|
}
|
|
3725
3220
|
});
|
|
3726
|
-
Object.defineProperty(exports, "stripTailwindSourceMediaFragments", {
|
|
3727
|
-
enumerable: true,
|
|
3728
|
-
get: function() {
|
|
3729
|
-
return stripTailwindSourceMediaFragments;
|
|
3730
|
-
}
|
|
3731
|
-
});
|
|
3732
|
-
Object.defineProperty(exports, "stripUnmatchedTailwindSourceMediaCloseFragments", {
|
|
3733
|
-
enumerable: true,
|
|
3734
|
-
get: function() {
|
|
3735
|
-
return stripUnmatchedTailwindSourceMediaCloseFragments;
|
|
3736
|
-
}
|
|
3737
|
-
});
|
|
3738
3221
|
Object.defineProperty(exports, "validateCandidatesByGenerator", {
|
|
3739
3222
|
enumerable: true,
|
|
3740
3223
|
get: function() {
|