weapp-tailwindcss 5.1.5 → 5.1.7
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/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +10 -0
- package/dist/{context-rrYZuUBU.mjs → context-BqeDu1Ha.mjs} +5 -4
- package/dist/{context-BziwyWy1.js → context-C7KTDlrG.js} +5 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-24-HgU9F.mjs → generator-BOt2Tvx3.mjs} +2 -2
- package/dist/{generator-CilgHtxb.js → generator-DASZwC6t.js} +2 -2
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-CuVsZdO9.js → gulp-D6hsaTLM.js} +4 -4
- package/dist/{gulp-ygWfmOqh.mjs → gulp-alDZryyB.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BKdCeIrn.js → hmr-timing-BIr_CiPW.js} +55 -566
- package/dist/{hmr-timing-Dh_nn3w5.mjs → hmr-timing-CYwVMRol.mjs} +32 -513
- 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-DATRnS1X.mjs → source-candidate-scan-signature-D97ZEXcj.mjs} +3 -3
- package/dist/{source-candidate-scan-signature-DIj9m4wB.js → source-candidate-scan-signature-Djr2Hw8y.js} +3 -3
- package/dist/{tailwindcss-C-uM4rB8.mjs → tailwindcss-DDGD90w7.mjs} +15 -2
- package/dist/{tailwindcss-BwoNQ3t8.js → tailwindcss-DPxJpRVP.js} +15 -2
- package/dist/{transform-KLD1tJdb.js → transform-CvqqZBuq.js} +1 -1
- package/dist/{transform-DHLemtaX.mjs → transform-DPPr79r2.mjs} +1 -1
- package/dist/uni-app-x/web-preflight-reset.d.ts +3 -0
- package/dist/{v4-engine-CKtsdKxK.js → v4-engine-3UmJkAY7.js} +641 -3
- package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-CYSrDVNp.mjs} +560 -6
- package/dist/{vite-Yp14HNyS.js → vite-BJRlG835.js} +636 -114
- package/dist/{vite-cH0tTMHc.mjs → vite-XxJh7Xtu.mjs} +637 -115
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +3078 -2907
- package/dist/{webpack-DN3tgLbF.js → webpack-BxBOMUtY.js} +286 -47
- package/dist/{webpack-DBhmJ-_P.mjs → webpack-eN8WzIT-.mjs} +280 -41
- 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-3UmJkAY7.js");
|
|
3
|
+
const require_generator = require("./generator-DASZwC6t.js");
|
|
4
|
+
const require_context = require("./context-C7KTDlrG.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-DPxJpRVP.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
|
}
|
|
@@ -2338,6 +1846,12 @@ function intersectCandidateSets(left, right) {
|
|
|
2338
1846
|
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
2339
1847
|
return matched;
|
|
2340
1848
|
}
|
|
1849
|
+
function resolveScopedRuntimeCandidates(sourceCandidates, sourceScopedRuntime) {
|
|
1850
|
+
if (!sourceCandidates) return sourceScopedRuntime;
|
|
1851
|
+
if (!sourceScopedRuntime) return sourceCandidates;
|
|
1852
|
+
if (sourceCandidates.size === 0) return sourceScopedRuntime;
|
|
1853
|
+
return intersectCandidateSets(sourceCandidates, sourceScopedRuntime);
|
|
1854
|
+
}
|
|
2341
1855
|
function parseCssSourceRoot(rawSource) {
|
|
2342
1856
|
try {
|
|
2343
1857
|
return _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
@@ -2384,11 +1898,12 @@ function finalizeWebGeneratorCss(css, target, webCompat) {
|
|
|
2384
1898
|
return target === "web" ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
|
|
2385
1899
|
}
|
|
2386
1900
|
async function generateCssByGenerator(options) {
|
|
2387
|
-
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1901
|
+
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, generatorPlatform, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1902
|
+
const platform = generatorPlatform ?? opts.cssOptions?.platform ?? opts.platform;
|
|
2388
1903
|
const generatorOptions = {
|
|
2389
1904
|
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2390
1905
|
appType: opts.appType,
|
|
2391
|
-
platform
|
|
1906
|
+
platform,
|
|
2392
1907
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2393
1908
|
uniAppX: opts.uniAppX
|
|
2394
1909
|
}),
|
|
@@ -2396,13 +1911,13 @@ async function generateCssByGenerator(options) {
|
|
|
2396
1911
|
};
|
|
2397
1912
|
const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
2398
1913
|
appType: opts.appType,
|
|
2399
|
-
platform
|
|
1914
|
+
platform,
|
|
2400
1915
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2401
1916
|
uniAppX: opts.uniAppX
|
|
2402
1917
|
});
|
|
2403
1918
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2404
1919
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
2405
|
-
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1920
|
+
const effectiveRawSource = require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2406
1921
|
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
2407
1922
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2408
1923
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
@@ -2420,12 +1935,12 @@ async function generateCssByGenerator(options) {
|
|
|
2420
1935
|
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2421
1936
|
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
2422
1937
|
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
2423
|
-
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
1938
|
+
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
|
|
2424
1939
|
};
|
|
2425
1940
|
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
2426
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
1941
|
+
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
1942
|
const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
|
|
2428
|
-
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
1943
|
+
const userCssRawSource = require_v4_engine.removeTailwindV4GeneratorAtRules(userSource);
|
|
2429
1944
|
const generatedUserCssOrderSource = require_v4_engine.hasTailwindGeneratedCss(userSource) ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
2430
1945
|
const generatedUserCssRawSource = generatedUserCssOrderSource ? require_v4_engine.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_v4_engine.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
2431
1946
|
const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_v4_engine.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
@@ -2433,6 +1948,10 @@ async function generateCssByGenerator(options) {
|
|
|
2433
1948
|
const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
|
|
2434
1949
|
const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
2435
1950
|
const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
1951
|
+
const normalizedCssSources = options.cssSources?.map((source) => ({
|
|
1952
|
+
...source,
|
|
1953
|
+
css: require_v4_engine.normalizeEmptyTailwindCustomVariants(source.css)
|
|
1954
|
+
}));
|
|
2436
1955
|
if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
2437
1956
|
forceGenerator: options.forceGenerator,
|
|
2438
1957
|
hasGeneratedCss,
|
|
@@ -2454,7 +1973,7 @@ async function generateCssByGenerator(options) {
|
|
|
2454
1973
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
2455
1974
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
2456
1975
|
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
2457
|
-
cssSources:
|
|
1976
|
+
cssSources: normalizedCssSources,
|
|
2458
1977
|
getSourceCandidatesForEntries,
|
|
2459
1978
|
runtime: runtimeWithCurrentCss
|
|
2460
1979
|
});
|
|
@@ -2465,7 +1984,7 @@ async function generateCssByGenerator(options) {
|
|
|
2465
1984
|
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
2466
1985
|
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
2467
1986
|
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2468
|
-
const scopedRuntime =
|
|
1987
|
+
const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
|
|
2469
1988
|
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
2470
1989
|
cssHandlerOptions,
|
|
2471
1990
|
target: generatorOptions.target
|
|
@@ -2495,12 +2014,12 @@ async function generateCssByGenerator(options) {
|
|
|
2495
2014
|
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
2496
2015
|
if (!generated) return;
|
|
2497
2016
|
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") {
|
|
2017
|
+
if ((generated.target !== "weapp" || !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2499
2018
|
const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
|
|
2500
2019
|
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
2020
|
injectPreflight: false,
|
|
2502
2021
|
styleOptions: generatorStyleOptions
|
|
2503
|
-
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
2022
|
+
})) : options.previousCss, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
|
|
2504
2023
|
return {
|
|
2505
2024
|
css: finalCss,
|
|
2506
2025
|
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
@@ -2515,12 +2034,12 @@ async function generateCssByGenerator(options) {
|
|
|
2515
2034
|
}
|
|
2516
2035
|
};
|
|
2517
2036
|
}
|
|
2518
|
-
const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2037
|
+
const shouldFilterApplyOnlyCss = require_v4_engine.shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2519
2038
|
hasGeneratedCss,
|
|
2520
2039
|
hasGeneratedMarkers
|
|
2521
2040
|
});
|
|
2522
2041
|
const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
|
|
2523
|
-
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
2042
|
+
const generatedCss = shouldFilterApplyOnlyCss ? require_v4_engine.filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
|
|
2524
2043
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2525
2044
|
const hasExplicitCssSource = sources.some((source) => {
|
|
2526
2045
|
const metadata = source.__weappTailwindcssMeta;
|
|
@@ -2548,29 +2067,29 @@ async function generateCssByGenerator(options) {
|
|
|
2548
2067
|
importFallback: generatorOptions.importFallback,
|
|
2549
2068
|
processed: userRawSourceProcessed
|
|
2550
2069
|
};
|
|
2551
|
-
const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2070
|
+
const afterLayerParts = generated.target === "weapp" ? require_v4_engine.splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2552
2071
|
layer: "",
|
|
2553
2072
|
rest: orderedExtraCss.after
|
|
2554
2073
|
};
|
|
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" &&
|
|
2074
|
+
const beforeUserCss = await require_v4_engine.transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2075
|
+
const afterLayerUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2076
|
+
const afterUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2077
|
+
const fallbackLayerUserCss = generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(afterLayerUserCss, await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
|
|
2559
2078
|
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2560
2079
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2561
2080
|
hasSourceDirectives,
|
|
2562
2081
|
hasMatchedCssSourceFile
|
|
2563
2082
|
})) {
|
|
2564
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2083
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2565
2084
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2566
2085
|
}
|
|
2567
2086
|
if (generated.target === "web") {
|
|
2568
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2569
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2087
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2088
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2570
2089
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2571
2090
|
}
|
|
2572
2091
|
if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2573
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2092
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2574
2093
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2575
2094
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2576
2095
|
}
|
|
@@ -2601,7 +2120,7 @@ async function generateCssByGenerator(options) {
|
|
|
2601
2120
|
}
|
|
2602
2121
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
2603
2122
|
let css = generatedCss;
|
|
2604
|
-
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2123
|
+
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
2124
|
generatorTarget: generated.target,
|
|
2606
2125
|
generatorStyleOptions,
|
|
2607
2126
|
cssUserHandlerOptions,
|
|
@@ -2611,9 +2130,9 @@ async function generateCssByGenerator(options) {
|
|
|
2611
2130
|
}), css);
|
|
2612
2131
|
if (generated.target === "weapp") {
|
|
2613
2132
|
css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
|
|
2614
|
-
if (hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2615
|
-
const layerParts = splitUserCssLayerBlocks(generatorRawSource);
|
|
2616
|
-
const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
|
|
2133
|
+
if (require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2134
|
+
const layerParts = require_v4_engine.splitUserCssLayerBlocks(generatorRawSource);
|
|
2135
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(layerParts.layer, {
|
|
2617
2136
|
generatorTarget: generated.target,
|
|
2618
2137
|
generatorStyleOptions,
|
|
2619
2138
|
cssUserHandlerOptions,
|
|
@@ -2624,7 +2143,7 @@ async function generateCssByGenerator(options) {
|
|
|
2624
2143
|
const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
|
|
2625
2144
|
layer: layerUserCss,
|
|
2626
2145
|
rest: css
|
|
2627
|
-
} : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2146
|
+
} : require_v4_engine.extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2628
2147
|
if (layerCss.layer.trim().length > 0) {
|
|
2629
2148
|
css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
|
|
2630
2149
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
@@ -2633,7 +2152,7 @@ async function generateCssByGenerator(options) {
|
|
|
2633
2152
|
}
|
|
2634
2153
|
if (hasMatchedCssSourceFile || generated.target === "web") {
|
|
2635
2154
|
if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2636
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2155
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2637
2156
|
generatorTarget: generated.target,
|
|
2638
2157
|
generatorStyleOptions,
|
|
2639
2158
|
cssUserHandlerOptions,
|
|
@@ -2644,7 +2163,7 @@ async function generateCssByGenerator(options) {
|
|
|
2644
2163
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2645
2164
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2646
2165
|
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
|
|
2647
|
-
const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2166
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2648
2167
|
generatorTarget: generated.target,
|
|
2649
2168
|
generatorStyleOptions,
|
|
2650
2169
|
cssUserHandlerOptions,
|
|
@@ -2654,8 +2173,8 @@ async function generateCssByGenerator(options) {
|
|
|
2654
2173
|
});
|
|
2655
2174
|
const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2656
2175
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2657
|
-
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2658
|
-
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2176
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2177
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2659
2178
|
generatorTarget: generated.target,
|
|
2660
2179
|
generatorStyleOptions,
|
|
2661
2180
|
cssUserHandlerOptions,
|
|
@@ -2675,7 +2194,7 @@ async function generateCssByGenerator(options) {
|
|
|
2675
2194
|
hasSourceDirectives,
|
|
2676
2195
|
hasMatchedCssSourceFile
|
|
2677
2196
|
})) {
|
|
2678
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2197
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2679
2198
|
generatorTarget: generated.target,
|
|
2680
2199
|
generatorStyleOptions,
|
|
2681
2200
|
cssUserHandlerOptions,
|
|
@@ -2683,7 +2202,7 @@ async function generateCssByGenerator(options) {
|
|
|
2683
2202
|
importFallback: generatorOptions.importFallback,
|
|
2684
2203
|
processed: userRawSourceProcessed
|
|
2685
2204
|
});
|
|
2686
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2205
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2687
2206
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2688
2207
|
}
|
|
2689
2208
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
@@ -2709,7 +2228,7 @@ async function generateCssByGenerator(options) {
|
|
|
2709
2228
|
css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2710
2229
|
}
|
|
2711
2230
|
if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2712
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2231
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2713
2232
|
generatorTarget: generated.target,
|
|
2714
2233
|
generatorStyleOptions,
|
|
2715
2234
|
cssUserHandlerOptions,
|
|
@@ -3681,24 +3200,6 @@ Object.defineProperty(exports, "removeGeneratedSelectorCompatCss", {
|
|
|
3681
3200
|
return removeGeneratedSelectorCompatCss;
|
|
3682
3201
|
}
|
|
3683
3202
|
});
|
|
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
3203
|
Object.defineProperty(exports, "resolveSourceCandidateScanFiles", {
|
|
3703
3204
|
enumerable: true,
|
|
3704
3205
|
get: function() {
|
|
@@ -3723,18 +3224,6 @@ Object.defineProperty(exports, "scoreTailwindV4CssSourceFileMatch", {
|
|
|
3723
3224
|
return scoreTailwindV4CssSourceFileMatch;
|
|
3724
3225
|
}
|
|
3725
3226
|
});
|
|
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
3227
|
Object.defineProperty(exports, "validateCandidatesByGenerator", {
|
|
3739
3228
|
enumerable: true,
|
|
3740
3229
|
get: function() {
|