weapp-tailwindcss 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-CrJJc5rK.mjs +13 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/{context-B07Vf584.mjs → context-Bkpmt3ja.mjs} +31 -5
- package/dist/{context-D75pwtBW.js → context-DCVMkTRj.js} +36 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/framework/platform.d.ts +2 -0
- package/dist/{generator-DNs6ekoC.mjs → generator-24-HgU9F.mjs} +5 -3
- package/dist/{generator-CV_0irKO.js → generator-CilgHtxb.js} +5 -3
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-aQMZ0M7c.mjs → gulp-0RsqkF_d.mjs} +4 -4
- package/dist/{gulp-B_u8NjQL.js → gulp-Bogfnoki.js} +7 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DLYQTCDb.mjs → hmr-timing-BRNaz8Od.mjs} +41 -148
- package/dist/{hmr-timing-DOoHun3i.js → hmr-timing-BV6nFPoT.js} +41 -166
- 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 +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-pS87mdHZ.mjs → source-candidate-scan-signature-BB1hvW68.mjs} +12 -6
- package/dist/{source-candidate-scan-signature-DzwebZrf.js → source-candidate-scan-signature-CaDT0gkj.js} +13 -6
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-BwV3_Ryc.mjs → tailwindcss-D0JF0fuZ.mjs} +4 -4
- package/dist/{tailwindcss-BSCvrs1p.js → tailwindcss-D2xs4OEu.js} +4 -4
- package/dist/{transform-Clj7R818.mjs → transform-BP86eSZp.mjs} +1 -1
- package/dist/{transform-fin-OTVD.js → transform-CXCQ28Tc.js} +1 -1
- package/dist/{v4-engine-BklH3CpJ.mjs → v4-engine-BuuYDXt1.mjs} +54 -114
- package/dist/{v4-engine-CKbS27-o.js → v4-engine-CKtsdKxK.js} +57 -111
- package/dist/{vite-5Wn0PIzJ.mjs → vite-B1SlBmqO.mjs} +212 -44
- package/dist/{vite-CkVMSDDp.js → vite-BYgT1ir9.js} +214 -46
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +89 -191
- package/dist/{webpack-DEag6ueE.mjs → webpack-Bg6pefpb.mjs} +49 -6
- package/dist/{webpack-hvSFaicc.js → webpack-khSwkXP5.js} +50 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- package/dist/auto-Ba6hDrse.mjs +0 -13
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as transformCssMacroCss, o as transformCssMacroTailwindV4Source, r as hasCssMacroTailwindV4Source, s as withCssMacroStyleOptions, t as hasCssMacroStyleOptions } from "./auto-CrJJc5rK.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs, { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { createTailwindV4Engine, extractRawCandidates, loadTailwindV4DesignSystem, resolveProjectSourceFiles, resolveTailwindV4Source, resolveValidTailwindV4Candidates as resolveValidTailwindV4Candidates$1 } from "@tailwindcss-mangle/engine";
|
|
7
|
-
import { createStyleHandler, normalizeTailwindcssWebRpxDeclarations, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
|
|
7
|
+
import { analyzeTailwindCssDirectives, createStyleHandler, isTailwindCssGenerationDirective, isTailwindCssImportAtRule, isTailwindCssPackageJsonImportRequest, normalizeTailwindCssImportRequest, normalizeTailwindcssWebRpxDeclarations, parseTailwindCssConfigRequest, parseTailwindCssDirectiveRequest, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
|
|
8
8
|
import { LRUCache } from "lru-cache";
|
|
9
9
|
import { stat } from "node:fs/promises";
|
|
10
10
|
import micromatch from "micromatch";
|
|
@@ -63,6 +63,15 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
63
63
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
|
+
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
67
|
+
function resolveCssMacroTailwindV4Source(source) {
|
|
68
|
+
const css = transformCssMacroTailwindV4Source(source.css);
|
|
69
|
+
return css === source.css ? source : {
|
|
70
|
+
...source,
|
|
71
|
+
css
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
66
75
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
67
76
|
const TAILWIND_V4_COLOR_STEPS = [
|
|
68
77
|
"50",
|
|
@@ -1164,7 +1173,7 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1164
1173
|
};
|
|
1165
1174
|
}
|
|
1166
1175
|
function resolveStyleOptions(source, options) {
|
|
1167
|
-
return
|
|
1176
|
+
return hasCssMacroTailwindV4Source(source.css) ? withCssMacroStyleOptions(options) : options;
|
|
1168
1177
|
}
|
|
1169
1178
|
function collectCustomPropertyValues(css) {
|
|
1170
1179
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -1231,7 +1240,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1231
1240
|
async function generateOnce(generateSource, options = {}) {
|
|
1232
1241
|
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
1233
1242
|
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
1234
|
-
const engine = createTailwindV4Engine(createCompatibleSource(generateSource, target));
|
|
1243
|
+
const engine = createTailwindV4Engine(createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target));
|
|
1235
1244
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1236
1245
|
const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
|
|
1237
1246
|
const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
@@ -1254,13 +1263,14 @@ function createTailwindV4Engine$1(source) {
|
|
|
1254
1263
|
}
|
|
1255
1264
|
async function generateWithIncrementalCache(options = {}) {
|
|
1256
1265
|
const target = options.target ?? "weapp";
|
|
1257
|
-
const
|
|
1266
|
+
const cssMacroSource = resolveCssMacroTailwindV4Source(source);
|
|
1267
|
+
const compatibleSource = createCompatibleSource(cssMacroSource, target);
|
|
1258
1268
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1259
1269
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
1260
|
-
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(
|
|
1270
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
|
|
1261
1271
|
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
1262
1272
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1263
|
-
const generated = await generateOnce(
|
|
1273
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1264
1274
|
if (!seedIncrementalGenerateCache({
|
|
1265
1275
|
compatibleSource,
|
|
1266
1276
|
generated,
|
|
@@ -1273,7 +1283,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1273
1283
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
1274
1284
|
if (cached) {
|
|
1275
1285
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1276
|
-
const generated = await generateOnce(
|
|
1286
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1277
1287
|
if (!seedIncrementalGenerateCache({
|
|
1278
1288
|
compatibleSource,
|
|
1279
1289
|
generated,
|
|
@@ -1297,7 +1307,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1297
1307
|
target: cached.target
|
|
1298
1308
|
};
|
|
1299
1309
|
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1300
|
-
const generated = await generateOnce(
|
|
1310
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1301
1311
|
if (!seedIncrementalGenerateCache({
|
|
1302
1312
|
compatibleSource,
|
|
1303
1313
|
generated,
|
|
@@ -1347,7 +1357,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1347
1357
|
});
|
|
1348
1358
|
}
|
|
1349
1359
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1350
|
-
const generated = await generateOnce(
|
|
1360
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1351
1361
|
seedIncrementalGenerateCache({
|
|
1352
1362
|
compatibleSource,
|
|
1353
1363
|
generated,
|
|
@@ -1490,14 +1500,14 @@ function parseConfigRequest$1(params) {
|
|
|
1490
1500
|
function isPackageJsonImportRequest$1(request) {
|
|
1491
1501
|
return typeof request === "string" && request.startsWith("#");
|
|
1492
1502
|
}
|
|
1493
|
-
function isWeappTailwindcssImportRequest
|
|
1503
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
1494
1504
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1495
1505
|
}
|
|
1496
1506
|
function isTailwindImportRequest$1(request) {
|
|
1497
1507
|
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
1498
1508
|
}
|
|
1499
1509
|
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
1500
|
-
if (options.importFallback && isWeappTailwindcssImportRequest
|
|
1510
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
1501
1511
|
return request;
|
|
1502
1512
|
}
|
|
1503
1513
|
function replaceImportRequest$1(params, request, replacement) {
|
|
@@ -1509,7 +1519,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
1509
1519
|
const trimmed = line.trimStart();
|
|
1510
1520
|
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
1511
1521
|
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
1512
|
-
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest
|
|
1522
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
1513
1523
|
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
1514
1524
|
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
1515
1525
|
}
|
|
@@ -1517,7 +1527,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
1517
1527
|
}
|
|
1518
1528
|
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
1519
1529
|
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
1520
|
-
if (!request || !isWeappTailwindcssImportRequest
|
|
1530
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
1521
1531
|
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
1522
1532
|
}
|
|
1523
1533
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
@@ -1649,45 +1659,21 @@ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
|
1649
1659
|
"utility",
|
|
1650
1660
|
"variant"
|
|
1651
1661
|
]);
|
|
1652
|
-
const TAILWIND_ROOT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
1653
|
-
"config",
|
|
1654
|
-
"custom-variant",
|
|
1655
|
-
"plugin",
|
|
1656
|
-
"source",
|
|
1657
|
-
"tailwind",
|
|
1658
|
-
"theme",
|
|
1659
|
-
"utility",
|
|
1660
|
-
"variant"
|
|
1661
|
-
]);
|
|
1662
1662
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
1663
1663
|
function parseImportRequest(params) {
|
|
1664
|
-
return
|
|
1664
|
+
return parseTailwindCssDirectiveRequest(params);
|
|
1665
1665
|
}
|
|
1666
1666
|
function hasLocalCssImport(rawSource) {
|
|
1667
|
-
|
|
1668
|
-
try {
|
|
1669
|
-
postcss.parse(rawSource).walkAtRules("import", (rule) => {
|
|
1670
|
-
const request = parseImportRequest(rule.params);
|
|
1671
|
-
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
1672
|
-
found = true;
|
|
1673
|
-
return false;
|
|
1674
|
-
}
|
|
1675
|
-
});
|
|
1676
|
-
} catch {}
|
|
1677
|
-
return found;
|
|
1667
|
+
return analyzeParseableTailwindDirectives(rawSource)?.hasLocalCssImport ?? false;
|
|
1678
1668
|
}
|
|
1679
1669
|
function parseConfigRequest(params) {
|
|
1680
|
-
return
|
|
1670
|
+
return parseTailwindCssConfigRequest(params);
|
|
1681
1671
|
}
|
|
1682
1672
|
function isPackageJsonImportRequest(request) {
|
|
1683
|
-
return
|
|
1684
|
-
}
|
|
1685
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
1686
|
-
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1673
|
+
return isTailwindCssPackageJsonImportRequest(request);
|
|
1687
1674
|
}
|
|
1688
1675
|
function normalizeTailwindImportRequest(request, options = {}) {
|
|
1689
|
-
|
|
1690
|
-
return request;
|
|
1676
|
+
return normalizeTailwindCssImportRequest(request, options);
|
|
1691
1677
|
}
|
|
1692
1678
|
function replaceImportRequest(params, request, replacement) {
|
|
1693
1679
|
const index = params.indexOf(request);
|
|
@@ -1743,12 +1729,11 @@ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
1743
1729
|
}
|
|
1744
1730
|
}
|
|
1745
1731
|
function isTailwindImportRequest(request) {
|
|
1746
|
-
|
|
1732
|
+
const normalized = normalizeTailwindImportRequest(request);
|
|
1733
|
+
return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
|
|
1747
1734
|
}
|
|
1748
1735
|
function isTailwindImportAtRule(node, options = {}) {
|
|
1749
|
-
|
|
1750
|
-
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
1751
|
-
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
1736
|
+
return isTailwindCssImportAtRule(node, options);
|
|
1752
1737
|
}
|
|
1753
1738
|
function isTailwindSourceDirective(node, options = {}) {
|
|
1754
1739
|
if (node.type !== "atrule") return false;
|
|
@@ -1762,10 +1747,18 @@ function hasGeneratedCssArtifacts(rawSource) {
|
|
|
1762
1747
|
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
1763
1748
|
}
|
|
1764
1749
|
function isTailwindGenerationDirective(node, options = {}) {
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1750
|
+
return isTailwindCssGenerationDirective(node, options);
|
|
1751
|
+
}
|
|
1752
|
+
function analyzeParseableTailwindDirectives(rawSource, options = {}) {
|
|
1753
|
+
try {
|
|
1754
|
+
const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
|
|
1755
|
+
return analyzeTailwindCssDirectives(postcss.parse(rawSource), {
|
|
1756
|
+
...options,
|
|
1757
|
+
ignoreLayer
|
|
1758
|
+
});
|
|
1759
|
+
} catch {
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1769
1762
|
}
|
|
1770
1763
|
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
1771
1764
|
try {
|
|
@@ -1785,76 +1778,23 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
1785
1778
|
}
|
|
1786
1779
|
}
|
|
1787
1780
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
const root = postcss.parse(rawSource);
|
|
1791
|
-
let found = false;
|
|
1792
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1793
|
-
root.walk((node) => {
|
|
1794
|
-
if (isTailwindGenerationDirective(node, {
|
|
1795
|
-
...options,
|
|
1796
|
-
ignoreLayer
|
|
1797
|
-
})) {
|
|
1798
|
-
found = true;
|
|
1799
|
-
return false;
|
|
1800
|
-
}
|
|
1801
|
-
});
|
|
1802
|
-
return found;
|
|
1803
|
-
} catch {
|
|
1804
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1805
|
-
}
|
|
1781
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1782
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1806
1783
|
}
|
|
1807
1784
|
function hasTailwindNonRootGenerationDirectives(rawSource, options = {}) {
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
const root = postcss.parse(rawSource);
|
|
1811
|
-
let found = false;
|
|
1812
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1813
|
-
root.walk((node) => {
|
|
1814
|
-
if (isTailwindGenerationDirective(node, {
|
|
1815
|
-
...options,
|
|
1816
|
-
ignoreLayer
|
|
1817
|
-
}) && !(node.type === "atrule" && isTailwindImportAtRule(node, options))) {
|
|
1818
|
-
found = true;
|
|
1819
|
-
return false;
|
|
1820
|
-
}
|
|
1821
|
-
});
|
|
1822
|
-
return found;
|
|
1823
|
-
} catch {
|
|
1824
|
-
return GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource) || /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
|
|
1825
|
-
}
|
|
1785
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1786
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindNonRootGenerationDirectives ?? /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
|
|
1826
1787
|
}
|
|
1827
1788
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
1828
1789
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
1829
|
-
|
|
1830
|
-
const root = postcss.parse(rawSource);
|
|
1831
|
-
let found = false;
|
|
1832
|
-
root.walkAtRules((node) => {
|
|
1833
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
1834
|
-
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
1835
|
-
found = true;
|
|
1836
|
-
return false;
|
|
1837
|
-
}
|
|
1838
|
-
});
|
|
1839
|
-
return found;
|
|
1840
|
-
} catch {
|
|
1841
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1842
|
-
}
|
|
1790
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1843
1791
|
}
|
|
1844
1792
|
function hasTailwindApplyDirective(rawSource) {
|
|
1845
1793
|
if (!rawSource.includes("@apply")) return false;
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
found = true;
|
|
1851
|
-
return false;
|
|
1852
|
-
});
|
|
1853
|
-
return found;
|
|
1854
|
-
} catch {
|
|
1855
|
-
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
1856
|
-
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
1857
|
-
}
|
|
1794
|
+
const analysis = analyzeParseableTailwindDirectives(rawSource);
|
|
1795
|
+
if (analysis) return analysis.hasTailwindApplyDirective;
|
|
1796
|
+
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
1797
|
+
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
1858
1798
|
}
|
|
1859
1799
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
1860
1800
|
try {
|
|
@@ -2373,4 +2313,4 @@ async function resolveTailwindV4SourceFromRuntime(runtime) {
|
|
|
2373
2313
|
return resolveTailwindV4Source$1(resolveTailwindV4SourceOptionsFromRuntime(runtime));
|
|
2374
2314
|
}
|
|
2375
2315
|
//#endregion
|
|
2376
|
-
export { normalizeLegacyContentEntries as $, resolveCssEntrySource as A, stripTailwindBanner as B, hasTailwindRootDirectives as C, normalizeTailwindSourceForGenerator as D, normalizeTailwindSourceDirectives as E, hasTailwindGeneratedCssMarkers as F, getTailwindV4IncrementalGenerateCacheStats as G, normalizeConfigDirective as H, splitGeneratorPlaceholderCssBySourceOrder as I, FULL_SOURCE_SCAN_EXTENSION_RE as J, transformTailwindV4CssByTarget as K, splitTailwindGeneratedCssByBanner as L, VITE_MARKER_RE as M, createCssAppend as N, parseImportRequest as O, hasTailwindGeneratedCss as P, isFileMatchedByTailwindSourceEntries as Q, splitTailwindV4GeneratedCssBySourceOrder as R, hasTailwindNonRootGenerationDirectives as S, normalizeTailwindConfigDirectives as T, prependConfigDirective as U, stripTailwindBanners as V, createTailwindV4Engine$1 as W, createTailwindSourceEntryMatcher as X, FULL_SOURCE_SCAN_PATTERN as Y, expandTailwindSourceEntries as Z, resolveTailwindcssOptions as _, filterTailwindV4CssSourceRoots as a, collectCssInlineSourceCandidates as at, hasLocalCssImport as b, groupCssEntriesByBase as c,
|
|
2316
|
+
export { normalizeLegacyContentEntries as $, resolveCssEntrySource as A, stripTailwindBanner as B, hasTailwindRootDirectives as C, normalizeTailwindSourceForGenerator as D, normalizeTailwindSourceDirectives as E, hasTailwindGeneratedCssMarkers as F, getTailwindV4IncrementalGenerateCacheStats as G, normalizeConfigDirective as H, splitGeneratorPlaceholderCssBySourceOrder as I, FULL_SOURCE_SCAN_EXTENSION_RE as J, transformTailwindV4CssByTarget as K, splitTailwindGeneratedCssByBanner as L, VITE_MARKER_RE as M, createCssAppend as N, parseImportRequest as O, hasTailwindGeneratedCss as P, isFileMatchedByTailwindSourceEntries as Q, splitTailwindV4GeneratedCssBySourceOrder as R, hasTailwindNonRootGenerationDirectives as S, normalizeTailwindConfigDirectives as T, prependConfigDirective as U, stripTailwindBanners as V, createTailwindV4Engine$1 as W, createTailwindSourceEntryMatcher as X, FULL_SOURCE_SCAN_PATTERN as Y, expandTailwindSourceEntries as Z, resolveTailwindcssOptions as _, filterTailwindV4CssSourceRoots as a, collectCssInlineSourceCandidates as at, hasLocalCssImport as b, groupCssEntriesByBase as c, omitUndefined as ct, normalizeCssEntries as d, resolveValidTailwindV4Candidates$1 as dt, parseConfigParam as et, findNearestPackageRoot as f, normalizeTailwindcssRuntimeOptions as g, normalizeExtendLengthUnits as h, resolveTailwindV4SourceOptionsFromRuntime as i, toPosixPath as it, GENERATOR_PLACEHOLDER_MARKER_RE as j, removeTailwindSourceDirectives as k, guessBasedirFromEntries as l, inferGeneratorTargetFromEnv as lt, findWorkspaceRoot as m, resolveTailwindV4SourceFromRuntime as n, resolveSourceScanPath as nt, hasConfiguredTailwindV4CssRoots as o, resolveCssMacroTailwindV4Source as ot, findWorkspacePackageDir as p, transformTailwindV4CssToWeapp as q, resolveTailwindV4SourceFromRuntimeOptions as r, resolveTailwindV4CssSourceBase as rt, upsertTailwindV4CssSource as s, filterUnsupportedMiniProgramTailwindV4Candidates as st, resolveTailwindV4Source$1 as t, resolveCssSourceEntries as tt, isTailwindV4CssEntry as u, loadTailwindV4DesignSystem as ut, normalizeStringListOption as v, hasTailwindSourceDirectives as w, hasTailwindApplyDirective as x, resolveBooleanObjectOption as y, stripGeneratorPlaceholderMarkers as z };
|
|
@@ -68,6 +68,15 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
68
68
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
|
+
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
72
|
+
function resolveCssMacroTailwindV4Source(source) {
|
|
73
|
+
const css = (0, _weapp_tailwindcss_postcss.transformCssMacroTailwindV4Source)(source.css);
|
|
74
|
+
return css === source.css ? source : {
|
|
75
|
+
...source,
|
|
76
|
+
css
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
71
80
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
72
81
|
const TAILWIND_V4_COLOR_STEPS = [
|
|
73
82
|
"50",
|
|
@@ -1169,7 +1178,7 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1169
1178
|
};
|
|
1170
1179
|
}
|
|
1171
1180
|
function resolveStyleOptions(source, options) {
|
|
1172
|
-
return (0, _weapp_tailwindcss_postcss.
|
|
1181
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Source)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
1173
1182
|
}
|
|
1174
1183
|
function collectCustomPropertyValues(css) {
|
|
1175
1184
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -1236,7 +1245,7 @@ function createTailwindV4Engine(source) {
|
|
|
1236
1245
|
async function generateOnce(generateSource, options = {}) {
|
|
1237
1246
|
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
1238
1247
|
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
1239
|
-
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(generateSource, target));
|
|
1248
|
+
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target));
|
|
1240
1249
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1241
1250
|
const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
|
|
1242
1251
|
const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await (0, _tailwindcss_mangle_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
@@ -1259,13 +1268,14 @@ function createTailwindV4Engine(source) {
|
|
|
1259
1268
|
}
|
|
1260
1269
|
async function generateWithIncrementalCache(options = {}) {
|
|
1261
1270
|
const target = options.target ?? "weapp";
|
|
1262
|
-
const
|
|
1271
|
+
const cssMacroSource = resolveCssMacroTailwindV4Source(source);
|
|
1272
|
+
const compatibleSource = createCompatibleSource(cssMacroSource, target);
|
|
1263
1273
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1264
1274
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
1265
|
-
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(
|
|
1275
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
|
|
1266
1276
|
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
1267
1277
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1268
|
-
const generated = await generateOnce(
|
|
1278
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1269
1279
|
if (!seedIncrementalGenerateCache({
|
|
1270
1280
|
compatibleSource,
|
|
1271
1281
|
generated,
|
|
@@ -1278,7 +1288,7 @@ function createTailwindV4Engine(source) {
|
|
|
1278
1288
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
1279
1289
|
if (cached) {
|
|
1280
1290
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1281
|
-
const generated = await generateOnce(
|
|
1291
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1282
1292
|
if (!seedIncrementalGenerateCache({
|
|
1283
1293
|
compatibleSource,
|
|
1284
1294
|
generated,
|
|
@@ -1302,7 +1312,7 @@ function createTailwindV4Engine(source) {
|
|
|
1302
1312
|
target: cached.target
|
|
1303
1313
|
};
|
|
1304
1314
|
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1305
|
-
const generated = await generateOnce(
|
|
1315
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1306
1316
|
if (!seedIncrementalGenerateCache({
|
|
1307
1317
|
compatibleSource,
|
|
1308
1318
|
generated,
|
|
@@ -1352,7 +1362,7 @@ function createTailwindV4Engine(source) {
|
|
|
1352
1362
|
});
|
|
1353
1363
|
}
|
|
1354
1364
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1355
|
-
const generated = await generateOnce(
|
|
1365
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1356
1366
|
seedIncrementalGenerateCache({
|
|
1357
1367
|
compatibleSource,
|
|
1358
1368
|
generated,
|
|
@@ -1495,14 +1505,14 @@ function parseConfigRequest$1(params) {
|
|
|
1495
1505
|
function isPackageJsonImportRequest$1(request) {
|
|
1496
1506
|
return typeof request === "string" && request.startsWith("#");
|
|
1497
1507
|
}
|
|
1498
|
-
function isWeappTailwindcssImportRequest
|
|
1508
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
1499
1509
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1500
1510
|
}
|
|
1501
1511
|
function isTailwindImportRequest$1(request) {
|
|
1502
1512
|
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
1503
1513
|
}
|
|
1504
1514
|
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
1505
|
-
if (options.importFallback && isWeappTailwindcssImportRequest
|
|
1515
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
1506
1516
|
return request;
|
|
1507
1517
|
}
|
|
1508
1518
|
function replaceImportRequest$1(params, request, replacement) {
|
|
@@ -1514,7 +1524,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
1514
1524
|
const trimmed = line.trimStart();
|
|
1515
1525
|
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
1516
1526
|
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
1517
|
-
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest
|
|
1527
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
1518
1528
|
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
1519
1529
|
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
1520
1530
|
}
|
|
@@ -1522,7 +1532,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
1522
1532
|
}
|
|
1523
1533
|
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
1524
1534
|
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
1525
|
-
if (!request || !isWeappTailwindcssImportRequest
|
|
1535
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
1526
1536
|
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
1527
1537
|
}
|
|
1528
1538
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
@@ -1654,45 +1664,21 @@ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
|
1654
1664
|
"utility",
|
|
1655
1665
|
"variant"
|
|
1656
1666
|
]);
|
|
1657
|
-
const TAILWIND_ROOT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
1658
|
-
"config",
|
|
1659
|
-
"custom-variant",
|
|
1660
|
-
"plugin",
|
|
1661
|
-
"source",
|
|
1662
|
-
"tailwind",
|
|
1663
|
-
"theme",
|
|
1664
|
-
"utility",
|
|
1665
|
-
"variant"
|
|
1666
|
-
]);
|
|
1667
1667
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
1668
1668
|
function parseImportRequest(params) {
|
|
1669
|
-
return
|
|
1669
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(params);
|
|
1670
1670
|
}
|
|
1671
1671
|
function hasLocalCssImport(rawSource) {
|
|
1672
|
-
|
|
1673
|
-
try {
|
|
1674
|
-
_weapp_tailwindcss_postcss.postcss.parse(rawSource).walkAtRules("import", (rule) => {
|
|
1675
|
-
const request = parseImportRequest(rule.params);
|
|
1676
|
-
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
1677
|
-
found = true;
|
|
1678
|
-
return false;
|
|
1679
|
-
}
|
|
1680
|
-
});
|
|
1681
|
-
} catch {}
|
|
1682
|
-
return found;
|
|
1672
|
+
return analyzeParseableTailwindDirectives(rawSource)?.hasLocalCssImport ?? false;
|
|
1683
1673
|
}
|
|
1684
1674
|
function parseConfigRequest(params) {
|
|
1685
|
-
return
|
|
1675
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssConfigRequest)(params);
|
|
1686
1676
|
}
|
|
1687
1677
|
function isPackageJsonImportRequest(request) {
|
|
1688
|
-
return
|
|
1689
|
-
}
|
|
1690
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
1691
|
-
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
1678
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssPackageJsonImportRequest)(request);
|
|
1692
1679
|
}
|
|
1693
1680
|
function normalizeTailwindImportRequest(request, options = {}) {
|
|
1694
|
-
|
|
1695
|
-
return request;
|
|
1681
|
+
return (0, _weapp_tailwindcss_postcss.normalizeTailwindCssImportRequest)(request, options);
|
|
1696
1682
|
}
|
|
1697
1683
|
function replaceImportRequest(params, request, replacement) {
|
|
1698
1684
|
const index = params.indexOf(request);
|
|
@@ -1748,12 +1734,11 @@ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
1748
1734
|
}
|
|
1749
1735
|
}
|
|
1750
1736
|
function isTailwindImportRequest(request) {
|
|
1751
|
-
|
|
1737
|
+
const normalized = normalizeTailwindImportRequest(request);
|
|
1738
|
+
return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
|
|
1752
1739
|
}
|
|
1753
1740
|
function isTailwindImportAtRule(node, options = {}) {
|
|
1754
|
-
|
|
1755
|
-
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
1756
|
-
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
1741
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssImportAtRule)(node, options);
|
|
1757
1742
|
}
|
|
1758
1743
|
function isTailwindSourceDirective(node, options = {}) {
|
|
1759
1744
|
if (node.type !== "atrule") return false;
|
|
@@ -1767,10 +1752,18 @@ function hasGeneratedCssArtifacts(rawSource) {
|
|
|
1767
1752
|
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
1768
1753
|
}
|
|
1769
1754
|
function isTailwindGenerationDirective(node, options = {}) {
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1755
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssGenerationDirective)(node, options);
|
|
1756
|
+
}
|
|
1757
|
+
function analyzeParseableTailwindDirectives(rawSource, options = {}) {
|
|
1758
|
+
try {
|
|
1759
|
+
const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
|
|
1760
|
+
return (0, _weapp_tailwindcss_postcss.analyzeTailwindCssDirectives)(_weapp_tailwindcss_postcss.postcss.parse(rawSource), {
|
|
1761
|
+
...options,
|
|
1762
|
+
ignoreLayer
|
|
1763
|
+
});
|
|
1764
|
+
} catch {
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1774
1767
|
}
|
|
1775
1768
|
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
1776
1769
|
try {
|
|
@@ -1790,76 +1783,23 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
1790
1783
|
}
|
|
1791
1784
|
}
|
|
1792
1785
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1796
|
-
let found = false;
|
|
1797
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1798
|
-
root.walk((node) => {
|
|
1799
|
-
if (isTailwindGenerationDirective(node, {
|
|
1800
|
-
...options,
|
|
1801
|
-
ignoreLayer
|
|
1802
|
-
})) {
|
|
1803
|
-
found = true;
|
|
1804
|
-
return false;
|
|
1805
|
-
}
|
|
1806
|
-
});
|
|
1807
|
-
return found;
|
|
1808
|
-
} catch {
|
|
1809
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1810
|
-
}
|
|
1786
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1787
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1811
1788
|
}
|
|
1812
1789
|
function hasTailwindNonRootGenerationDirectives(rawSource, options = {}) {
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1816
|
-
let found = false;
|
|
1817
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
1818
|
-
root.walk((node) => {
|
|
1819
|
-
if (isTailwindGenerationDirective(node, {
|
|
1820
|
-
...options,
|
|
1821
|
-
ignoreLayer
|
|
1822
|
-
}) && !(node.type === "atrule" && isTailwindImportAtRule(node, options))) {
|
|
1823
|
-
found = true;
|
|
1824
|
-
return false;
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1827
|
-
return found;
|
|
1828
|
-
} catch {
|
|
1829
|
-
return GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource) || /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
|
|
1830
|
-
}
|
|
1790
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
1791
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindNonRootGenerationDirectives ?? /@(?:apply|config|custom-variant|plugin|source|theme|utility|variant)\b/.test(rawSource);
|
|
1831
1792
|
}
|
|
1832
1793
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
1833
1794
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
1834
|
-
|
|
1835
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1836
|
-
let found = false;
|
|
1837
|
-
root.walkAtRules((node) => {
|
|
1838
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
1839
|
-
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
1840
|
-
found = true;
|
|
1841
|
-
return false;
|
|
1842
|
-
}
|
|
1843
|
-
});
|
|
1844
|
-
return found;
|
|
1845
|
-
} catch {
|
|
1846
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1847
|
-
}
|
|
1795
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
1848
1796
|
}
|
|
1849
1797
|
function hasTailwindApplyDirective(rawSource) {
|
|
1850
1798
|
if (!rawSource.includes("@apply")) return false;
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
found = true;
|
|
1856
|
-
return false;
|
|
1857
|
-
});
|
|
1858
|
-
return found;
|
|
1859
|
-
} catch {
|
|
1860
|
-
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
1861
|
-
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
1862
|
-
}
|
|
1799
|
+
const analysis = analyzeParseableTailwindDirectives(rawSource);
|
|
1800
|
+
if (analysis) return analysis.hasTailwindApplyDirective;
|
|
1801
|
+
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
1802
|
+
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
1863
1803
|
}
|
|
1864
1804
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
1865
1805
|
try {
|
|
@@ -2642,6 +2582,12 @@ Object.defineProperty(exports, "resolveCssEntrySource", {
|
|
|
2642
2582
|
return resolveCssEntrySource;
|
|
2643
2583
|
}
|
|
2644
2584
|
});
|
|
2585
|
+
Object.defineProperty(exports, "resolveCssMacroTailwindV4Source", {
|
|
2586
|
+
enumerable: true,
|
|
2587
|
+
get: function() {
|
|
2588
|
+
return resolveCssMacroTailwindV4Source;
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2645
2591
|
Object.defineProperty(exports, "resolveCssSourceEntries", {
|
|
2646
2592
|
enumerable: true,
|
|
2647
2593
|
get: function() {
|