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,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as resolveGeneratorRuntimeBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch, t as createWeappTailwindcssGenerator } from "./generator-
|
|
3
|
-
import { S as createDebug, g as traverse, h as babelParse, m as replaceWxml, r as resolveStyleOptionsFromContext, w as md5Hash } from "./context-
|
|
4
|
-
import { h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective } from "./tailwindcss-
|
|
1
|
+
import { $ as hasTailwindGeneratedCssMarkers, A as stripTailwindSourceMediaFragments, C as isCommentOnlyCss, D as removeTailwindV4GeneratorAtRules, E as removeTailwindV4GeneratedUserCssArtifacts, Et as omitUndefined, H as hasTailwindSourceDirectives, I as removeUnsupportedMiniProgramAtRules, J as resolveCssEntrySource, K as parseImportRequest, M as transformGeneratorUserCss, N as finalizeMiniProgramCss, O as shouldFilterApplyOnlyGeneratedCss, Q as hasTailwindGeneratedCss, S as hasUserCssLayerBlocks, St as toPosixPath$1, Tt as filterUnsupportedMiniProgramTailwindV4Candidates, V as hasTailwindRootDirectives, W as normalizeTailwindSourceDirectives, X as VITE_MARKER_RE, Y as GENERATOR_PLACEHOLDER_MARKER_RE, Z as createCssAppend, at as stripTailwindBanners, b as extractGeneratedCssForUserLayerSelectors, bt as resolveSourceScanPath, et as splitGeneratorPlaceholderCssBySourceOrder, ft as FULL_SOURCE_SCAN_EXTENSION_RE, gt as isFileMatchedByTailwindSourceEntries, i as resolveTailwindV4SourceOptionsFromRuntime, it as stripTailwindBanner, j as stripUnmatchedTailwindSourceMediaCloseFragments, k as splitUserCssLayerBlocks, kt as loadTailwindV4DesignSystem, n as resolveTailwindV4SourceFromRuntime, nt as splitTailwindV4GeneratedCssBySourceOrder, ot as normalizeConfigDirective, q as removeTailwindSourceDirectives, rt as stripGeneratorPlaceholderMarkers, st as prependConfigDirective, t as resolveTailwindV4Source$1, tt as splitTailwindGeneratedCssByBanner, w as normalizeEmptyTailwindCustomVariants, x as filterApplyOnlyGeneratedCss, xt as resolveTailwindV4CssSourceBase, z as hasTailwindApplyDirective } from "./v4-engine-CYSrDVNp.mjs";
|
|
2
|
+
import { a as resolveGeneratorRuntimeBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch, t as createWeappTailwindcssGenerator } from "./generator-BOt2Tvx3.mjs";
|
|
3
|
+
import { S as createDebug, g as traverse, h as babelParse, m as replaceWxml, r as resolveStyleOptionsFromContext, w as md5Hash } from "./context-BqeDu1Ha.mjs";
|
|
4
|
+
import { h as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective } from "./tailwindcss-DDGD90w7.mjs";
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
9
|
-
import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, filterExistingCssRules,
|
|
9
|
+
import { cleanLocalCssImportWrapperTailwindDirectives, cleanLocalCssImportWrapperTailwindDirectivesRoot, filterExistingCssRules, isPureLocalCssImportWrapper, isPureLocalCssImportWrapperRoot, postcss, restoreLocalCssImports, rewriteLocalCssImportRequestsForOutput, splitLocalCssImports, splitLocalCssImportsRoot, transformWebCssCompat } from "@weapp-tailwindcss/postcss";
|
|
10
10
|
import { LRUCache } from "lru-cache";
|
|
11
11
|
import { readFile } from "node:fs/promises";
|
|
12
12
|
import { MappingChars2String, unescape } from "@weapp-core/escape";
|
|
@@ -181,8 +181,11 @@ function isVueScopedStyleSource(from) {
|
|
|
181
181
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
182
182
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
183
183
|
}
|
|
184
|
+
function isMiniProgramGeneratorTarget(target) {
|
|
185
|
+
return target !== "web";
|
|
186
|
+
}
|
|
184
187
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
185
|
-
if (target
|
|
188
|
+
if (!isMiniProgramGeneratorTarget(target)) return css;
|
|
186
189
|
if (isVueScopedStyleSource(options.styleOptions?.postcssOptions?.options?.from)) return finalizeMiniProgramCss(css, {
|
|
187
190
|
cssPreflight: false,
|
|
188
191
|
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
@@ -1381,501 +1384,6 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1381
1384
|
return resolved?.entries;
|
|
1382
1385
|
}
|
|
1383
1386
|
//#endregion
|
|
1384
|
-
//#region src/bundlers/shared/generator-css/user-css.ts
|
|
1385
|
-
const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
|
|
1386
|
-
"config",
|
|
1387
|
-
"custom-variant",
|
|
1388
|
-
"plugin",
|
|
1389
|
-
"source",
|
|
1390
|
-
"theme",
|
|
1391
|
-
"utility",
|
|
1392
|
-
"variant"
|
|
1393
|
-
]);
|
|
1394
|
-
function removeBalancedAtRuleBlock(source, atRuleStart) {
|
|
1395
|
-
const blockStart = source.indexOf("{", atRuleStart);
|
|
1396
|
-
if (blockStart === -1) {
|
|
1397
|
-
const semicolon = source.indexOf(";", atRuleStart);
|
|
1398
|
-
return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
|
|
1399
|
-
}
|
|
1400
|
-
let depth = 0;
|
|
1401
|
-
for (let index = blockStart; index < source.length; index++) {
|
|
1402
|
-
const char = source[index];
|
|
1403
|
-
if (char === "{") {
|
|
1404
|
-
depth++;
|
|
1405
|
-
continue;
|
|
1406
|
-
}
|
|
1407
|
-
if (char !== "}") continue;
|
|
1408
|
-
depth--;
|
|
1409
|
-
if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
|
|
1410
|
-
}
|
|
1411
|
-
return source.slice(0, atRuleStart);
|
|
1412
|
-
}
|
|
1413
|
-
function removeTailwindV4GeneratorAtRulesFallback(source) {
|
|
1414
|
-
let next = source;
|
|
1415
|
-
let changed = false;
|
|
1416
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1417
|
-
for (;;) {
|
|
1418
|
-
sourceMediaRE.lastIndex = 0;
|
|
1419
|
-
const match = sourceMediaRE.exec(next);
|
|
1420
|
-
if (!match) break;
|
|
1421
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1422
|
-
changed = true;
|
|
1423
|
-
}
|
|
1424
|
-
const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
|
|
1425
|
-
for (;;) {
|
|
1426
|
-
atRuleRE.lastIndex = 0;
|
|
1427
|
-
const match = atRuleRE.exec(next);
|
|
1428
|
-
if (!match) break;
|
|
1429
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1430
|
-
changed = true;
|
|
1431
|
-
}
|
|
1432
|
-
return changed ? next : source;
|
|
1433
|
-
}
|
|
1434
|
-
function isTailwindGeneratedPreflightComment(text) {
|
|
1435
|
-
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");
|
|
1436
|
-
}
|
|
1437
|
-
function isTailwindGeneratedThemeRule(selector, node) {
|
|
1438
|
-
if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
|
|
1439
|
-
return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
|
|
1440
|
-
}
|
|
1441
|
-
function isTailwindGeneratedPreflightRule(selector, node) {
|
|
1442
|
-
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;
|
|
1443
|
-
if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
|
|
1444
|
-
if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
|
|
1445
|
-
return false;
|
|
1446
|
-
}
|
|
1447
|
-
function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
1448
|
-
try {
|
|
1449
|
-
const root = postcss.parse(source);
|
|
1450
|
-
let changed = false;
|
|
1451
|
-
root.walkComments((comment) => {
|
|
1452
|
-
if (!isTailwindGeneratedPreflightComment(comment.text)) return;
|
|
1453
|
-
comment.remove();
|
|
1454
|
-
changed = true;
|
|
1455
|
-
});
|
|
1456
|
-
root.walkRules((rule) => {
|
|
1457
|
-
const selector = rule.selector.replace(/\s+/g, " ").trim();
|
|
1458
|
-
if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
|
|
1459
|
-
rule.remove();
|
|
1460
|
-
changed = true;
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
root.walkAtRules((rule) => {
|
|
1464
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
1465
|
-
rule.remove();
|
|
1466
|
-
changed = true;
|
|
1467
|
-
}
|
|
1468
|
-
});
|
|
1469
|
-
return changed ? root.toString() : source;
|
|
1470
|
-
} catch {
|
|
1471
|
-
return source;
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
function removeTailwindSourceMediaBlocks(source) {
|
|
1475
|
-
let next = source;
|
|
1476
|
-
let changed = false;
|
|
1477
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1478
|
-
for (;;) {
|
|
1479
|
-
sourceMediaRE.lastIndex = 0;
|
|
1480
|
-
const match = sourceMediaRE.exec(next);
|
|
1481
|
-
if (!match) break;
|
|
1482
|
-
const blockStart = next.indexOf("{", match.index);
|
|
1483
|
-
if (blockStart === -1) break;
|
|
1484
|
-
let depth = 0;
|
|
1485
|
-
let blockEnd = -1;
|
|
1486
|
-
for (let index = blockStart; index < next.length; index++) {
|
|
1487
|
-
const char = next[index];
|
|
1488
|
-
if (char === "{") {
|
|
1489
|
-
depth++;
|
|
1490
|
-
continue;
|
|
1491
|
-
}
|
|
1492
|
-
if (char !== "}") continue;
|
|
1493
|
-
depth--;
|
|
1494
|
-
if (depth === 0) {
|
|
1495
|
-
blockEnd = index;
|
|
1496
|
-
break;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
if (blockEnd === -1) break;
|
|
1500
|
-
next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
|
|
1501
|
-
changed = true;
|
|
1502
|
-
}
|
|
1503
|
-
for (;;) {
|
|
1504
|
-
const atRuleStart = findTailwindSourceWrapperBlockStart(next);
|
|
1505
|
-
if (atRuleStart === -1) break;
|
|
1506
|
-
next = removeBalancedAtRuleBlock(next, atRuleStart);
|
|
1507
|
-
changed = true;
|
|
1508
|
-
}
|
|
1509
|
-
return changed ? next : source;
|
|
1510
|
-
}
|
|
1511
|
-
function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
|
|
1512
|
-
if (!source.includes("@source")) return source;
|
|
1513
|
-
let next = "";
|
|
1514
|
-
let searchIndex = 0;
|
|
1515
|
-
for (;;) {
|
|
1516
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1517
|
-
if (atRuleStart === -1) {
|
|
1518
|
-
next += source.slice(searchIndex);
|
|
1519
|
-
break;
|
|
1520
|
-
}
|
|
1521
|
-
const nextChar = source[atRuleStart + 7];
|
|
1522
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1523
|
-
next += source.slice(searchIndex, atRuleStart + 7);
|
|
1524
|
-
searchIndex = atRuleStart + 7;
|
|
1525
|
-
continue;
|
|
1526
|
-
}
|
|
1527
|
-
next += source.slice(searchIndex, atRuleStart);
|
|
1528
|
-
let quote;
|
|
1529
|
-
let parenDepth = 0;
|
|
1530
|
-
let terminated = false;
|
|
1531
|
-
let index = atRuleStart + 7;
|
|
1532
|
-
for (; index < source.length; index++) {
|
|
1533
|
-
const char = source[index];
|
|
1534
|
-
if (quote) {
|
|
1535
|
-
if (char === "\\") {
|
|
1536
|
-
index++;
|
|
1537
|
-
continue;
|
|
1538
|
-
}
|
|
1539
|
-
if (char === quote) quote = void 0;
|
|
1540
|
-
continue;
|
|
1541
|
-
}
|
|
1542
|
-
if (char === "\"" || char === "'") {
|
|
1543
|
-
quote = char;
|
|
1544
|
-
continue;
|
|
1545
|
-
}
|
|
1546
|
-
if (char === "(") {
|
|
1547
|
-
parenDepth++;
|
|
1548
|
-
continue;
|
|
1549
|
-
}
|
|
1550
|
-
if (char === ")" && parenDepth > 0) {
|
|
1551
|
-
parenDepth--;
|
|
1552
|
-
continue;
|
|
1553
|
-
}
|
|
1554
|
-
if (parenDepth > 0) continue;
|
|
1555
|
-
if (char === ";" || char === "{") {
|
|
1556
|
-
terminated = true;
|
|
1557
|
-
index++;
|
|
1558
|
-
break;
|
|
1559
|
-
}
|
|
1560
|
-
if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
|
|
1561
|
-
}
|
|
1562
|
-
const segment = source.slice(atRuleStart, index);
|
|
1563
|
-
const trimmedSegment = segment.trimEnd();
|
|
1564
|
-
next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
|
|
1565
|
-
searchIndex = index;
|
|
1566
|
-
}
|
|
1567
|
-
return next;
|
|
1568
|
-
}
|
|
1569
|
-
function findTailwindSourceWrapperBlockStart(source) {
|
|
1570
|
-
let searchIndex = 0;
|
|
1571
|
-
for (;;) {
|
|
1572
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1573
|
-
if (atRuleStart === -1) return -1;
|
|
1574
|
-
const nextChar = source[atRuleStart + 7];
|
|
1575
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1576
|
-
searchIndex = atRuleStart + 7;
|
|
1577
|
-
continue;
|
|
1578
|
-
}
|
|
1579
|
-
let quote;
|
|
1580
|
-
let parenDepth = 0;
|
|
1581
|
-
for (let index = atRuleStart + 7; index < source.length; index++) {
|
|
1582
|
-
const char = source[index];
|
|
1583
|
-
if (quote) {
|
|
1584
|
-
if (char === "\\") {
|
|
1585
|
-
index++;
|
|
1586
|
-
continue;
|
|
1587
|
-
}
|
|
1588
|
-
if (char === quote) quote = void 0;
|
|
1589
|
-
continue;
|
|
1590
|
-
}
|
|
1591
|
-
if (char === "\"" || char === "'") {
|
|
1592
|
-
quote = char;
|
|
1593
|
-
continue;
|
|
1594
|
-
}
|
|
1595
|
-
if (char === "(") {
|
|
1596
|
-
parenDepth++;
|
|
1597
|
-
continue;
|
|
1598
|
-
}
|
|
1599
|
-
if (char === ")" && parenDepth > 0) {
|
|
1600
|
-
parenDepth--;
|
|
1601
|
-
continue;
|
|
1602
|
-
}
|
|
1603
|
-
if (parenDepth > 0) continue;
|
|
1604
|
-
if (char === ";") {
|
|
1605
|
-
searchIndex = index + 1;
|
|
1606
|
-
break;
|
|
1607
|
-
}
|
|
1608
|
-
if (char === "{") return atRuleStart;
|
|
1609
|
-
}
|
|
1610
|
-
if (searchIndex <= atRuleStart) return -1;
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
function removeTailwindApplyAtRules(source) {
|
|
1614
|
-
if (!source.includes("@apply")) return source;
|
|
1615
|
-
try {
|
|
1616
|
-
const root = postcss.parse(source);
|
|
1617
|
-
let changed = false;
|
|
1618
|
-
root.walkAtRules("apply", (rule) => {
|
|
1619
|
-
rule.remove();
|
|
1620
|
-
changed = true;
|
|
1621
|
-
});
|
|
1622
|
-
root.walk((node) => {
|
|
1623
|
-
if ("nodes" in node && node.nodes?.length === 0) node.remove();
|
|
1624
|
-
});
|
|
1625
|
-
return changed ? root.toString() : source;
|
|
1626
|
-
} catch {
|
|
1627
|
-
return source;
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
function removeTailwindV4GeneratorAtRules(source) {
|
|
1631
|
-
try {
|
|
1632
|
-
const root = postcss.parse(source);
|
|
1633
|
-
let changed = false;
|
|
1634
|
-
root.walkAtRules((rule) => {
|
|
1635
|
-
if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
|
|
1636
|
-
rule.remove();
|
|
1637
|
-
changed = true;
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
|
-
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
1641
|
-
rule.remove();
|
|
1642
|
-
changed = true;
|
|
1643
|
-
});
|
|
1644
|
-
return changed ? root.toString() : source;
|
|
1645
|
-
} catch {
|
|
1646
|
-
return removeTailwindV4GeneratorAtRulesFallback(source);
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
function isCommentOnlyCss(source) {
|
|
1650
|
-
try {
|
|
1651
|
-
const root = postcss.parse(source);
|
|
1652
|
-
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1653
|
-
} catch {
|
|
1654
|
-
return false;
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
function removeMiniProgramHoverSelectors(source, enabled = true) {
|
|
1658
|
-
if (!enabled || !source.includes(":hover")) return source;
|
|
1659
|
-
try {
|
|
1660
|
-
const root = postcss.parse(source);
|
|
1661
|
-
let changed = false;
|
|
1662
|
-
root.walkRules((rule) => {
|
|
1663
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1664
|
-
const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
|
|
1665
|
-
if (keptSelectors.length === selectors.length) return;
|
|
1666
|
-
changed = true;
|
|
1667
|
-
if (keptSelectors.length === 0) {
|
|
1668
|
-
rule.remove();
|
|
1669
|
-
return;
|
|
1670
|
-
}
|
|
1671
|
-
rule.selectors = keptSelectors;
|
|
1672
|
-
});
|
|
1673
|
-
root.walk((node) => {
|
|
1674
|
-
if ("nodes" in node && node.nodes?.length === 0) {
|
|
1675
|
-
node.remove();
|
|
1676
|
-
changed = true;
|
|
1677
|
-
}
|
|
1678
|
-
});
|
|
1679
|
-
return changed ? root.toString() : source;
|
|
1680
|
-
} catch {
|
|
1681
|
-
return source;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
function removeProcessedMiniProgramUnsupportedCss(source, options) {
|
|
1685
|
-
return removeMiniProgramHoverSelectors(removeUnsupportedMiniProgramAtRules(source), options.cssRemoveHoverPseudoClass);
|
|
1686
|
-
}
|
|
1687
|
-
function unwrapMiniProgramCascadeLayers(source) {
|
|
1688
|
-
if (!source.includes("@layer")) return source;
|
|
1689
|
-
try {
|
|
1690
|
-
const root = postcss.parse(source);
|
|
1691
|
-
removeUnsupportedCascadeLayers(root);
|
|
1692
|
-
return root.toString();
|
|
1693
|
-
} catch {
|
|
1694
|
-
return source;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
function stripTailwindSourceMediaFragments(source) {
|
|
1698
|
-
let removedSourceMediaStart = false;
|
|
1699
|
-
return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
|
|
1700
|
-
if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
|
|
1701
|
-
removedSourceMediaStart = true;
|
|
1702
|
-
return false;
|
|
1703
|
-
}
|
|
1704
|
-
if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
|
|
1705
|
-
if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
|
|
1706
|
-
removedSourceMediaStart = false;
|
|
1707
|
-
return false;
|
|
1708
|
-
}
|
|
1709
|
-
return true;
|
|
1710
|
-
}).join("\n");
|
|
1711
|
-
}
|
|
1712
|
-
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1713
|
-
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1714
|
-
}
|
|
1715
|
-
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1716
|
-
try {
|
|
1717
|
-
postcss.parse(source);
|
|
1718
|
-
return source;
|
|
1719
|
-
} catch {
|
|
1720
|
-
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
function splitUserCssLayerBlocks(source) {
|
|
1724
|
-
if (!source.includes("@layer")) return {
|
|
1725
|
-
layer: "",
|
|
1726
|
-
rest: source
|
|
1727
|
-
};
|
|
1728
|
-
try {
|
|
1729
|
-
const root = postcss.parse(source);
|
|
1730
|
-
const layerRoot = postcss.root();
|
|
1731
|
-
const restRoot = postcss.root();
|
|
1732
|
-
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1733
|
-
return {
|
|
1734
|
-
layer: layerRoot.toString(),
|
|
1735
|
-
rest: restRoot.toString()
|
|
1736
|
-
};
|
|
1737
|
-
} catch {
|
|
1738
|
-
return {
|
|
1739
|
-
layer: source,
|
|
1740
|
-
rest: ""
|
|
1741
|
-
};
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
function hasUserCssLayerBlocks(source) {
|
|
1745
|
-
if (!source.includes("@layer")) return false;
|
|
1746
|
-
try {
|
|
1747
|
-
let hasLayerBlock = false;
|
|
1748
|
-
postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1749
|
-
if (node.nodes?.length) hasLayerBlock = true;
|
|
1750
|
-
});
|
|
1751
|
-
return hasLayerBlock;
|
|
1752
|
-
} catch {
|
|
1753
|
-
return true;
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
function collectUserLayerSelectors(source) {
|
|
1757
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1758
|
-
try {
|
|
1759
|
-
postcss.parse(source).walkRules((rule) => {
|
|
1760
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1761
|
-
const normalized = selector.trim();
|
|
1762
|
-
if (normalized) selectors.add(normalized);
|
|
1763
|
-
}
|
|
1764
|
-
});
|
|
1765
|
-
} catch {}
|
|
1766
|
-
return selectors;
|
|
1767
|
-
}
|
|
1768
|
-
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1769
|
-
if (selector === userLayerSelector) return true;
|
|
1770
|
-
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1771
|
-
const next = selector[userLayerSelector.length];
|
|
1772
|
-
return next === ":" || next === "[";
|
|
1773
|
-
}
|
|
1774
|
-
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1775
|
-
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1776
|
-
if (selectors.size === 0) return {
|
|
1777
|
-
layer: "",
|
|
1778
|
-
rest: css
|
|
1779
|
-
};
|
|
1780
|
-
try {
|
|
1781
|
-
const root = postcss.parse(css);
|
|
1782
|
-
const layerRoot = postcss.root();
|
|
1783
|
-
const selectorList = [...selectors];
|
|
1784
|
-
root.walkRules((rule) => {
|
|
1785
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1786
|
-
layerRoot.append(rule.clone());
|
|
1787
|
-
rule.remove();
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
1790
|
-
return {
|
|
1791
|
-
layer: layerRoot.toString(),
|
|
1792
|
-
rest: root.toString()
|
|
1793
|
-
};
|
|
1794
|
-
} catch {
|
|
1795
|
-
return {
|
|
1796
|
-
layer: "",
|
|
1797
|
-
rest: css
|
|
1798
|
-
};
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
function normalizeGeneratedSelector(selector) {
|
|
1802
|
-
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1803
|
-
}
|
|
1804
|
-
function collectApplyOnlySourceSelectors(source) {
|
|
1805
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1806
|
-
try {
|
|
1807
|
-
postcss.parse(source).walkRules((rule) => {
|
|
1808
|
-
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1809
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1810
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1811
|
-
if (normalized) selectors.add(normalized);
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1814
|
-
} catch {}
|
|
1815
|
-
return selectors;
|
|
1816
|
-
}
|
|
1817
|
-
function hasOnlyApplyBackedSourceRules(source) {
|
|
1818
|
-
let hasApplyRule = false;
|
|
1819
|
-
let hasNonApplyRule = false;
|
|
1820
|
-
try {
|
|
1821
|
-
postcss.parse(source).walkRules((rule) => {
|
|
1822
|
-
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1823
|
-
else hasNonApplyRule = true;
|
|
1824
|
-
});
|
|
1825
|
-
} catch {
|
|
1826
|
-
return false;
|
|
1827
|
-
}
|
|
1828
|
-
return hasApplyRule && !hasNonApplyRule;
|
|
1829
|
-
}
|
|
1830
|
-
function filterApplyOnlyGeneratedCss(css, source) {
|
|
1831
|
-
const selectors = collectApplyOnlySourceSelectors(source);
|
|
1832
|
-
if (selectors.size === 0) return css;
|
|
1833
|
-
const selectorList = [...selectors];
|
|
1834
|
-
try {
|
|
1835
|
-
const root = postcss.parse(css);
|
|
1836
|
-
root.walkRules((rule) => {
|
|
1837
|
-
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
1838
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1839
|
-
return selectorList.some((sourceSelector) => {
|
|
1840
|
-
if (normalized === sourceSelector) return true;
|
|
1841
|
-
if (!normalized.startsWith(sourceSelector)) return false;
|
|
1842
|
-
const next = normalized[sourceSelector.length];
|
|
1843
|
-
return next === ":" || next === "[" || next === ".";
|
|
1844
|
-
});
|
|
1845
|
-
});
|
|
1846
|
-
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
1847
|
-
if (!isApplySelector && !isVariableRule) rule.remove();
|
|
1848
|
-
});
|
|
1849
|
-
root.walkAtRules((rule) => {
|
|
1850
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1851
|
-
});
|
|
1852
|
-
return root.toString();
|
|
1853
|
-
} catch {
|
|
1854
|
-
return css;
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
1858
|
-
return target === "weapp" && hasTailwindApplyDirective(source) && !hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
1859
|
-
}
|
|
1860
|
-
async function transformGeneratorUserCss(source, options) {
|
|
1861
|
-
if (source.trim().length === 0) return "";
|
|
1862
|
-
if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
|
|
1863
|
-
...options.generatorStyleOptions,
|
|
1864
|
-
...options.cssUserHandlerOptions
|
|
1865
|
-
})) : source)));
|
|
1866
|
-
const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1867
|
-
if (cleanedSource.trim().length === 0) return "";
|
|
1868
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1869
|
-
if (userSource.trim().length === 0) return "";
|
|
1870
|
-
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1871
|
-
if (options.generatorTarget !== "weapp") return userSource;
|
|
1872
|
-
const { css } = await options.styleHandler(userSource, {
|
|
1873
|
-
...options.generatorStyleOptions,
|
|
1874
|
-
...options.cssUserHandlerOptions
|
|
1875
|
-
});
|
|
1876
|
-
return removeTailwindV4GeneratedUserCssArtifacts(removeUnsupportedMiniProgramAtRules(css));
|
|
1877
|
-
}
|
|
1878
|
-
//#endregion
|
|
1879
1387
|
//#region src/bundlers/shared/generator-css/legacy-compat.ts
|
|
1880
1388
|
const LEGACY_CONTAINER_COMPAT_CSS = [
|
|
1881
1389
|
".container {",
|
|
@@ -2334,6 +1842,12 @@ function intersectCandidateSets(left, right) {
|
|
|
2334
1842
|
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
2335
1843
|
return matched;
|
|
2336
1844
|
}
|
|
1845
|
+
function resolveScopedRuntimeCandidates(sourceCandidates, sourceScopedRuntime) {
|
|
1846
|
+
if (!sourceCandidates) return sourceScopedRuntime;
|
|
1847
|
+
if (!sourceScopedRuntime) return sourceCandidates;
|
|
1848
|
+
if (sourceCandidates.size === 0) return sourceScopedRuntime;
|
|
1849
|
+
return intersectCandidateSets(sourceCandidates, sourceScopedRuntime);
|
|
1850
|
+
}
|
|
2337
1851
|
function parseCssSourceRoot(rawSource) {
|
|
2338
1852
|
try {
|
|
2339
1853
|
return postcss.parse(rawSource);
|
|
@@ -2380,11 +1894,12 @@ function finalizeWebGeneratorCss(css, target, webCompat) {
|
|
|
2380
1894
|
return target === "web" ? transformWebCssCompat(css, webCompat) : css;
|
|
2381
1895
|
}
|
|
2382
1896
|
async function generateCssByGenerator(options) {
|
|
2383
|
-
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1897
|
+
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, generatorPlatform, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1898
|
+
const platform = generatorPlatform ?? opts.cssOptions?.platform ?? opts.platform;
|
|
2384
1899
|
const generatorOptions = {
|
|
2385
1900
|
...normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2386
1901
|
appType: opts.appType,
|
|
2387
|
-
platform
|
|
1902
|
+
platform,
|
|
2388
1903
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2389
1904
|
uniAppX: opts.uniAppX
|
|
2390
1905
|
}),
|
|
@@ -2392,13 +1907,13 @@ async function generateCssByGenerator(options) {
|
|
|
2392
1907
|
};
|
|
2393
1908
|
const generatorBranch = resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
2394
1909
|
appType: opts.appType,
|
|
2395
|
-
platform
|
|
1910
|
+
platform,
|
|
2396
1911
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2397
1912
|
uniAppX: opts.uniAppX
|
|
2398
1913
|
});
|
|
2399
1914
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2400
1915
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
2401
|
-
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1916
|
+
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2402
1917
|
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
2403
1918
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2404
1919
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
@@ -2416,10 +1931,10 @@ async function generateCssByGenerator(options) {
|
|
|
2416
1931
|
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2417
1932
|
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
2418
1933
|
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
2419
|
-
return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
1934
|
+
return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
|
|
2420
1935
|
};
|
|
2421
1936
|
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
2422
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
1937
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeEmptyTailwindCustomVariants(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2423
1938
|
const userSource = (rawUserSource === generatorRawSource ? void 0 : splitLocalCssImports(rawUserSource))?.source ?? rawUserSource;
|
|
2424
1939
|
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
2425
1940
|
const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
@@ -2429,6 +1944,10 @@ async function generateCssByGenerator(options) {
|
|
|
2429
1944
|
const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
|
|
2430
1945
|
const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
2431
1946
|
const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
1947
|
+
const normalizedCssSources = options.cssSources?.map((source) => ({
|
|
1948
|
+
...source,
|
|
1949
|
+
css: normalizeEmptyTailwindCustomVariants(source.css)
|
|
1950
|
+
}));
|
|
2432
1951
|
if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
2433
1952
|
forceGenerator: options.forceGenerator,
|
|
2434
1953
|
hasGeneratedCss,
|
|
@@ -2450,7 +1969,7 @@ async function generateCssByGenerator(options) {
|
|
|
2450
1969
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
2451
1970
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
2452
1971
|
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
2453
|
-
cssSources:
|
|
1972
|
+
cssSources: normalizedCssSources,
|
|
2454
1973
|
getSourceCandidatesForEntries,
|
|
2455
1974
|
runtime: runtimeWithCurrentCss
|
|
2456
1975
|
});
|
|
@@ -2461,7 +1980,7 @@ async function generateCssByGenerator(options) {
|
|
|
2461
1980
|
const generator = createWeappTailwindcssGenerator(source);
|
|
2462
1981
|
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
2463
1982
|
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2464
|
-
const scopedRuntime =
|
|
1983
|
+
const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
|
|
2465
1984
|
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
2466
1985
|
cssHandlerOptions,
|
|
2467
1986
|
target: generatorOptions.target
|
|
@@ -2496,7 +2015,7 @@ async function generateCssByGenerator(options) {
|
|
|
2496
2015
|
const finalCss = finalizeWebGeneratorCss(restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2497
2016
|
injectPreflight: false,
|
|
2498
2017
|
styleOptions: generatorStyleOptions
|
|
2499
|
-
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
2018
|
+
})) : options.previousCss, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
|
|
2500
2019
|
return {
|
|
2501
2020
|
css: finalCss,
|
|
2502
2021
|
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
@@ -2516,7 +2035,7 @@ async function generateCssByGenerator(options) {
|
|
|
2516
2035
|
hasGeneratedMarkers
|
|
2517
2036
|
});
|
|
2518
2037
|
const generatedCssSource = generated.target === "web" ? generated.css : stripTailwindBanner(generated.css);
|
|
2519
|
-
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
2038
|
+
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
|
|
2520
2039
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2521
2040
|
const hasExplicitCssSource = sources.some((source) => {
|
|
2522
2041
|
const metadata = source.__weappTailwindcssMeta;
|
|
@@ -2551,7 +2070,7 @@ async function generateCssByGenerator(options) {
|
|
|
2551
2070
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2552
2071
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2553
2072
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2554
|
-
const fallbackLayerUserCss = generated.target === "weapp" &&
|
|
2073
|
+
const fallbackLayerUserCss = generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource) ? filterExistingCssRules(afterLayerUserCss, await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
|
|
2555
2074
|
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2556
2075
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2557
2076
|
hasSourceDirectives,
|
|
@@ -3557,4 +3076,4 @@ function createHmrTimingRecorder(bundler) {
|
|
|
3557
3076
|
};
|
|
3558
3077
|
}
|
|
3559
3078
|
//#endregion
|
|
3560
|
-
export {
|
|
3079
|
+
export { hasMiniProgramTailwindV4PreflightReset as C, isCssSourceTraceEnabled as D, createCssTokenSourceMap as E, processCachedTask as O, createCssSourceOrderAppend$1 as S, createCssSourceTraceCacheSignature as T, isPureLocalCssImportWrapper as _, isSourceCandidateRequest as a, scoreTailwindV4CssSourceFileMatch as b, collectStrictEscapedRuntimeCandidates as c, validateCandidatesByGenerator as d, pushConcurrentTaskFactories as f, mergeMarkedUserLayerComponentsCss as g, extractMarkedUserLayerComponentsCss as h, createSourceCandidateStore as i, createEscapeFragments as l, runWithConcurrency as m, emitHmrTiming as n, resolveSourceCandidateScanFiles as o, resolveTaskConcurrency as p, createSourceCandidateCollector as r, createBundleRuntimeClassSetManager as s, createHmrTimingRecorder as t, generateCssByGenerator as u, rewriteLocalCssImportRequestsForOutput as v, annotateCssSourceTrace as w, removeGeneratedSelectorCompatCss as x, splitLocalCssImports as y };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_gulp = require("./gulp-
|
|
3
|
+
const require_generator = require("./generator-DASZwC6t.js");
|
|
4
|
+
const require_gulp = require("./gulp-D6hsaTLM.js");
|
|
5
5
|
const require_postcss = require("./postcss.js");
|
|
6
|
-
const require_vite = require("./vite-
|
|
7
|
-
const require_webpack = require("./webpack-
|
|
6
|
+
const require_vite = require("./vite-BJRlG835.js");
|
|
7
|
+
const require_webpack = require("./webpack-BxBOMUtY.js");
|
|
8
8
|
require("./webpack.js");
|
|
9
9
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
10
10
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|