weapp-tailwindcss 5.0.0 → 5.0.2
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/{bundle-state-DgGEhk_z.js → bundle-state-Bvj01pW7.js} +35 -3
- package/dist/{bundle-state-CnaJxkFY.mjs → bundle-state-DY3eq4Gz.mjs} +24 -4
- package/dist/bundlers/shared/generated-css-marker.d.ts +6 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -5
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -0
- package/dist/bundlers/shared/generator-css.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +5 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +12 -3
- package/dist/bundlers/vite/generate-bundle.d.ts +22 -6
- package/dist/bundlers/vite/processed-css-assets.d.ts +10 -2
- package/dist/bundlers/vite/source-candidates.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +8 -0
- package/dist/cli.js +1 -0
- package/dist/cli.mjs +1 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator--0-ekuVO.js → generator-Bd1LntD3.js} +1 -1
- package/dist/{generator-B76ovqsv.mjs → generator-DRHWC1t-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +16 -10
- package/dist/gulp.mjs +14 -8
- package/dist/{incremental-runtime-class-set-CN6K_97P.js → incremental-runtime-class-set-Bl18sFqt.js} +540 -694
- package/dist/{incremental-runtime-class-set-x10M9bn_.mjs → incremental-runtime-class-set-CAEuUesH.mjs} +495 -619
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-CR9UCaIK.mjs → postcss-CJrmfXvi.mjs} +4 -4
- package/dist/{postcss-hYimKoN_.js → postcss-DfnqZ4Bm.js} +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-DPtJjZmV.js → precheck-Bj5ReSOU.js} +2 -2
- package/dist/{precheck-BrNwLG2e.mjs → precheck-CUr1DYyy.mjs} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-DN1mihlU.mjs → source-candidates-D7b-Jzsx.mjs} +44 -11
- package/dist/{source-candidates-DSxme_O2.js → source-candidates-DQxvGPSw.js} +49 -10
- package/dist/tailwindcss/source-scan.d.ts +3 -1
- package/dist/{tailwindcss-DWtPieNE.mjs → tailwindcss-D5RogwtV.mjs} +14 -49
- package/dist/{tailwindcss-glCm_d3H.js → tailwindcss-jvoYizzX.js} +19 -48
- package/dist/{v3-engine-DCxNPBVs.mjs → v3-engine-BCUGX3gX.mjs} +644 -36
- package/dist/{v3-engine-D3BMLVAN.js → v3-engine-CmIF_gsq.js} +775 -35
- package/dist/{vite-Ec0uX6kF.js → vite-D1ZdgbWa.js} +533 -290
- package/dist/{vite-DOprpdH-.mjs → vite-jBTi5CwO.mjs} +532 -289
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/{runtime-registry-DpcR3IHI.js → watch-dependencies-zwx4EhBn.js} +39 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +1953 -1630
- package/dist/weapp-tw-runtime-classset-loader.js +6 -6
- package/dist/{webpack-DFlZcqAU.mjs → webpack-CChDqRrl.mjs} +6 -6
- package/dist/{webpack-Ccohlg3A.js → webpack-vk2uqSnK.js} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
|
@@ -166,6 +166,11 @@ function createDefaultResolvePaths(basedir) {
|
|
|
166
166
|
appendNodeModules(paths, packageRoot);
|
|
167
167
|
fallbackCandidates.push(packageRoot);
|
|
168
168
|
}
|
|
169
|
+
const workspaceRoot = findWorkspaceRoot(resolvedBase);
|
|
170
|
+
if (workspaceRoot) {
|
|
171
|
+
appendNodeModules(paths, workspaceRoot);
|
|
172
|
+
fallbackCandidates.push(workspaceRoot);
|
|
173
|
+
}
|
|
169
174
|
}
|
|
170
175
|
const cwd = process.cwd();
|
|
171
176
|
appendNodeModules(paths, cwd);
|
|
@@ -262,9 +267,6 @@ function createFallbackTailwindcssPatcher() {
|
|
|
262
267
|
let hasLoggedMissingTailwind = false;
|
|
263
268
|
const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
|
|
264
269
|
const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
|
|
265
|
-
function isTailwindcssV4PackageName(packageName) {
|
|
266
|
-
return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
|
|
267
|
-
}
|
|
268
270
|
function createTailwindcssPatcher(options) {
|
|
269
271
|
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
270
272
|
const cache = { driver: "memory" };
|
|
@@ -283,7 +285,7 @@ function createTailwindcssPatcher(options) {
|
|
|
283
285
|
resolve: { paths: resolvePaths }
|
|
284
286
|
}));
|
|
285
287
|
if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
|
|
286
|
-
if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin =
|
|
288
|
+
if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = "tailwindcss";
|
|
287
289
|
if (typeof baseTailwindOptions.postcssPlugin === "string") {
|
|
288
290
|
const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
|
|
289
291
|
if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
@@ -301,7 +303,7 @@ function createTailwindcssPatcher(options) {
|
|
|
301
303
|
const resolvedTailwindOptions = resolvedOptions.tailwindcss;
|
|
302
304
|
if (resolvedTailwindOptions) {
|
|
303
305
|
const existingResolve = resolvedTailwindOptions.resolve ?? {};
|
|
304
|
-
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
|
|
306
|
+
const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? [...existingResolve.paths, ...resolvePaths] : resolvePaths;
|
|
305
307
|
resolvedTailwindOptions.resolve = {
|
|
306
308
|
...existingResolve,
|
|
307
309
|
paths: [...new Set(sourcePaths)]
|
|
@@ -623,7 +625,7 @@ function collectCssInlineSourceCandidates(root) {
|
|
|
623
625
|
excluded
|
|
624
626
|
};
|
|
625
627
|
}
|
|
626
|
-
function normalizeLegacyContentEntries(content, base) {
|
|
628
|
+
function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
627
629
|
if (typeof content === "string") {
|
|
628
630
|
const negated = content.startsWith("!");
|
|
629
631
|
return [{
|
|
@@ -632,8 +634,8 @@ function normalizeLegacyContentEntries(content, base) {
|
|
|
632
634
|
pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
|
|
633
635
|
}];
|
|
634
636
|
}
|
|
635
|
-
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
|
|
636
|
-
if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, base);
|
|
637
|
+
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
|
|
638
|
+
if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
|
|
637
639
|
return [];
|
|
638
640
|
}
|
|
639
641
|
async function pathExistsAsDirectory(file) {
|
|
@@ -1706,9 +1708,10 @@ function parseImportSourceParam$1(params) {
|
|
|
1706
1708
|
};
|
|
1707
1709
|
}
|
|
1708
1710
|
function isTailwindCssImport$1(params) {
|
|
1709
|
-
|
|
1711
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
1712
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1710
1713
|
}
|
|
1711
|
-
function parseCssImportSpecifier$
|
|
1714
|
+
function parseCssImportSpecifier$2(params) {
|
|
1712
1715
|
const value = params.trim();
|
|
1713
1716
|
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1714
1717
|
if (quoted) return quoted[2];
|
|
@@ -1716,7 +1719,7 @@ function parseCssImportSpecifier$1(params) {
|
|
|
1716
1719
|
return url?.[2] ?? url?.[3];
|
|
1717
1720
|
}
|
|
1718
1721
|
function isTailwindCssPreflightImport(params) {
|
|
1719
|
-
const specifier = parseCssImportSpecifier$
|
|
1722
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
1720
1723
|
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1721
1724
|
}
|
|
1722
1725
|
function hasImportLayerOption(params) {
|
|
@@ -1951,7 +1954,520 @@ function createTailwindV4Engine$1(source) {
|
|
|
1951
1954
|
};
|
|
1952
1955
|
}
|
|
1953
1956
|
//#endregion
|
|
1957
|
+
//#region src/bundlers/shared/generator-css/config-directive.ts
|
|
1958
|
+
function quoteCssString(value) {
|
|
1959
|
+
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
1960
|
+
}
|
|
1961
|
+
function toCssPath(value) {
|
|
1962
|
+
return value.replaceAll("\\", "/");
|
|
1963
|
+
}
|
|
1964
|
+
function prependConfigDirective(css, config) {
|
|
1965
|
+
if (!config || /@config\s+/.test(css)) return css;
|
|
1966
|
+
return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
|
|
1967
|
+
}
|
|
1968
|
+
function normalizeConfigDirective(css, config) {
|
|
1969
|
+
if (!config || !/@config\s+/.test(css)) return css;
|
|
1970
|
+
return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
1974
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
1975
|
+
const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
|
|
1976
|
+
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
1977
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
1978
|
+
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
1979
|
+
const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
|
|
1980
|
+
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
1981
|
+
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
1982
|
+
function createCssAppend(base, extra) {
|
|
1983
|
+
if (!base) return extra;
|
|
1984
|
+
if (!extra) return base;
|
|
1985
|
+
return `${base}\n${extra}`;
|
|
1986
|
+
}
|
|
1987
|
+
function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
1988
|
+
const trimmedRaw = rawSource.trim();
|
|
1989
|
+
const trimmedTailwind = rawTailwindCss.trim();
|
|
1990
|
+
if (trimmedRaw === trimmedTailwind) return {
|
|
1991
|
+
before: "",
|
|
1992
|
+
after: ""
|
|
1993
|
+
};
|
|
1994
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return {
|
|
1995
|
+
before: "",
|
|
1996
|
+
after: ""
|
|
1997
|
+
};
|
|
1998
|
+
const start = rawSource.indexOf(rawTailwindCss);
|
|
1999
|
+
if (start === -1) return;
|
|
2000
|
+
return {
|
|
2001
|
+
before: rawSource.slice(0, start),
|
|
2002
|
+
after: rawSource.slice(start + rawTailwindCss.length)
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
2006
|
+
const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
|
|
2007
|
+
if (!match || match.index === void 0) return;
|
|
2008
|
+
let afterStart = match.index + match[0].length;
|
|
2009
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
2010
|
+
if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
|
|
2011
|
+
afterStart += rawTailwindCss.length;
|
|
2012
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
2013
|
+
}
|
|
2014
|
+
return {
|
|
2015
|
+
before: rawSource.slice(0, match.index),
|
|
2016
|
+
after: rawSource.slice(afterStart)
|
|
2017
|
+
};
|
|
2018
|
+
}
|
|
2019
|
+
function splitTailwindGeneratedCssByBanner(rawSource, start) {
|
|
2020
|
+
const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
|
|
2021
|
+
if (!match || match.index === void 0) return;
|
|
2022
|
+
return {
|
|
2023
|
+
before: rawSource.slice(0, match.index),
|
|
2024
|
+
after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
function stripTailwindBanner(css) {
|
|
2028
|
+
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
2029
|
+
}
|
|
2030
|
+
function stripTailwindBanners(css) {
|
|
2031
|
+
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
2032
|
+
}
|
|
2033
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
2034
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
2035
|
+
}
|
|
2036
|
+
function hasTailwindGeneratedCss(rawSource) {
|
|
2037
|
+
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
2038
|
+
}
|
|
2039
|
+
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
2040
|
+
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2041
|
+
}
|
|
2042
|
+
//#endregion
|
|
2043
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
2044
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
2045
|
+
"config",
|
|
2046
|
+
"custom-variant",
|
|
2047
|
+
"layer",
|
|
2048
|
+
"plugin",
|
|
2049
|
+
"reference",
|
|
2050
|
+
"source",
|
|
2051
|
+
"tailwind",
|
|
2052
|
+
"theme",
|
|
2053
|
+
"utility",
|
|
2054
|
+
"variant"
|
|
2055
|
+
]);
|
|
2056
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
2057
|
+
"config",
|
|
2058
|
+
"custom-variant",
|
|
2059
|
+
"plugin",
|
|
2060
|
+
"source",
|
|
2061
|
+
"tailwind",
|
|
2062
|
+
"theme",
|
|
2063
|
+
"utility",
|
|
2064
|
+
"variant"
|
|
2065
|
+
]);
|
|
2066
|
+
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/;
|
|
2067
|
+
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
2068
|
+
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
2069
|
+
const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant)\b[\s\S]*\{/;
|
|
2070
|
+
const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
|
|
2071
|
+
["tailwindcss/base", "base"],
|
|
2072
|
+
["tailwindcss/components", "components"],
|
|
2073
|
+
["tailwindcss/utilities", "utilities"]
|
|
2074
|
+
]);
|
|
2075
|
+
function parseImportRequest(params) {
|
|
2076
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2077
|
+
}
|
|
2078
|
+
function parseConfigRequest(params) {
|
|
2079
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2080
|
+
}
|
|
2081
|
+
function isPackageJsonImportRequest(request) {
|
|
2082
|
+
return typeof request === "string" && request.startsWith("#");
|
|
2083
|
+
}
|
|
2084
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
2085
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2086
|
+
}
|
|
2087
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
2088
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2089
|
+
return request;
|
|
2090
|
+
}
|
|
2091
|
+
function replaceImportRequest(params, request, replacement) {
|
|
2092
|
+
const index = params.indexOf(request);
|
|
2093
|
+
if (index === -1) return params;
|
|
2094
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2095
|
+
}
|
|
2096
|
+
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
2097
|
+
if (!options.importFallback) return false;
|
|
2098
|
+
let changed = false;
|
|
2099
|
+
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
2100
|
+
root.walkAtRules("import", (node) => {
|
|
2101
|
+
const request = parseImportRequest(node.params);
|
|
2102
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2103
|
+
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
2104
|
+
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
2105
|
+
const normalizedKey = normalizedParams.trim();
|
|
2106
|
+
if (seenCanonicalImports.has(normalizedKey)) {
|
|
2107
|
+
node.remove();
|
|
2108
|
+
changed = true;
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
seenCanonicalImports.add(normalizedKey);
|
|
2112
|
+
if (normalizedParams !== node.params) {
|
|
2113
|
+
node.params = normalizedParams;
|
|
2114
|
+
changed = true;
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
return changed;
|
|
2118
|
+
}
|
|
2119
|
+
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
2120
|
+
const trimmed = line.trimStart();
|
|
2121
|
+
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
2122
|
+
const request = parseImportRequest(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
2123
|
+
if (isTailwindImportRequest(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
2124
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2125
|
+
return replaceImportRequest(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
2126
|
+
}
|
|
2127
|
+
return line;
|
|
2128
|
+
}
|
|
2129
|
+
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
2130
|
+
const request = parseImportRequest(trimmed.replace(/^@import\b/, ""));
|
|
2131
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
2132
|
+
return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
2133
|
+
}
|
|
2134
|
+
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
2135
|
+
const directives = [];
|
|
2136
|
+
const seenImports = /* @__PURE__ */ new Set();
|
|
2137
|
+
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
2138
|
+
const trimmed = line.trim();
|
|
2139
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
2140
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
|
|
2141
|
+
if (!directive) continue;
|
|
2142
|
+
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
2143
|
+
const normalizedTrimmed = normalized.trim();
|
|
2144
|
+
if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
|
|
2145
|
+
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
2146
|
+
if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest(request)) continue;
|
|
2147
|
+
if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
|
|
2148
|
+
if (request && isTailwindImportRequest(request)) {
|
|
2149
|
+
const key = normalizedTrimmed;
|
|
2150
|
+
if (seenImports.has(key)) continue;
|
|
2151
|
+
seenImports.add(key);
|
|
2152
|
+
}
|
|
2153
|
+
directives.push(normalized);
|
|
2154
|
+
}
|
|
2155
|
+
return directives;
|
|
2156
|
+
}
|
|
2157
|
+
function stripPreprocessorLineComment(line) {
|
|
2158
|
+
let quote;
|
|
2159
|
+
let escaped = false;
|
|
2160
|
+
for (let index = 0; index < line.length; index++) {
|
|
2161
|
+
const char = line[index];
|
|
2162
|
+
if (escaped) {
|
|
2163
|
+
escaped = false;
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
if (char === "\\") {
|
|
2167
|
+
escaped = true;
|
|
2168
|
+
continue;
|
|
2169
|
+
}
|
|
2170
|
+
if (quote) {
|
|
2171
|
+
if (char === quote) quote = void 0;
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
if (char === "\"" || char === "'") {
|
|
2175
|
+
quote = char;
|
|
2176
|
+
continue;
|
|
2177
|
+
}
|
|
2178
|
+
if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
|
|
2179
|
+
}
|
|
2180
|
+
return line;
|
|
2181
|
+
}
|
|
2182
|
+
function countBlockBraceDelta(line) {
|
|
2183
|
+
let quote;
|
|
2184
|
+
let escaped = false;
|
|
2185
|
+
let delta = 0;
|
|
2186
|
+
for (let index = 0; index < line.length; index++) {
|
|
2187
|
+
const char = line[index];
|
|
2188
|
+
if (escaped) {
|
|
2189
|
+
escaped = false;
|
|
2190
|
+
continue;
|
|
2191
|
+
}
|
|
2192
|
+
if (char === "\\") {
|
|
2193
|
+
escaped = true;
|
|
2194
|
+
continue;
|
|
2195
|
+
}
|
|
2196
|
+
if (quote) {
|
|
2197
|
+
if (char === quote) quote = void 0;
|
|
2198
|
+
continue;
|
|
2199
|
+
}
|
|
2200
|
+
if (char === "\"" || char === "'") {
|
|
2201
|
+
quote = char;
|
|
2202
|
+
continue;
|
|
2203
|
+
}
|
|
2204
|
+
if (char === "{") delta++;
|
|
2205
|
+
else if (char === "}") delta--;
|
|
2206
|
+
}
|
|
2207
|
+
return delta;
|
|
2208
|
+
}
|
|
2209
|
+
function extractTailwindFallbackBlocks(rawSource) {
|
|
2210
|
+
const blocks = [];
|
|
2211
|
+
let current;
|
|
2212
|
+
let depth = 0;
|
|
2213
|
+
for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
2214
|
+
const line = stripPreprocessorLineComment(rawLine);
|
|
2215
|
+
if (!line.trim()) continue;
|
|
2216
|
+
if (!current) {
|
|
2217
|
+
if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
|
|
2218
|
+
current = [line];
|
|
2219
|
+
depth = countBlockBraceDelta(line);
|
|
2220
|
+
if (depth <= 0) {
|
|
2221
|
+
blocks.push(current.join("\n"));
|
|
2222
|
+
current = void 0;
|
|
2223
|
+
depth = 0;
|
|
2224
|
+
}
|
|
2225
|
+
continue;
|
|
2226
|
+
}
|
|
2227
|
+
current.push(line);
|
|
2228
|
+
depth += countBlockBraceDelta(line);
|
|
2229
|
+
if (depth <= 0) {
|
|
2230
|
+
blocks.push(current.join("\n"));
|
|
2231
|
+
current = void 0;
|
|
2232
|
+
depth = 0;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return blocks;
|
|
2236
|
+
}
|
|
2237
|
+
function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
2238
|
+
const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
|
|
2239
|
+
return directives.length > 0 ? directives.join("\n") : void 0;
|
|
2240
|
+
}
|
|
2241
|
+
function extractConfigRequestFromSource(rawSource) {
|
|
2242
|
+
for (const line of rawSource.split(/\r?\n/)) {
|
|
2243
|
+
const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
|
|
2244
|
+
const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
|
|
2245
|
+
if (request) return request;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
function resolveConfigPath$1(base, configPath) {
|
|
2249
|
+
if (path.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return path.isAbsolute(configPath) ? configPath : void 0;
|
|
2250
|
+
return path.resolve(base, configPath);
|
|
2251
|
+
}
|
|
2252
|
+
function normalizeTailwindConfigDirectives(rawSource, base) {
|
|
2253
|
+
return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
|
|
2254
|
+
if (path.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
|
|
2255
|
+
return `@config ${quote}${path.resolve(base, request).replace(/\\/g, "/")}${quote};`;
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
function hasPreprocessorOnlySyntax(rawSource) {
|
|
2259
|
+
return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
|
|
2260
|
+
}
|
|
2261
|
+
function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
2262
|
+
return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
|
|
2263
|
+
}
|
|
2264
|
+
function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
2265
|
+
try {
|
|
2266
|
+
const root = postcss.parse(rawSource);
|
|
2267
|
+
let changed = false;
|
|
2268
|
+
root.walkAtRules("import", (node) => {
|
|
2269
|
+
const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
|
|
2270
|
+
if (!layer) return;
|
|
2271
|
+
node.replaceWith(postcss.atRule({
|
|
2272
|
+
name: "tailwind",
|
|
2273
|
+
params: layer
|
|
2274
|
+
}));
|
|
2275
|
+
changed = true;
|
|
2276
|
+
});
|
|
2277
|
+
return changed ? root.toString() : rawSource;
|
|
2278
|
+
} catch {
|
|
2279
|
+
return rawSource;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2283
|
+
if (!options.importFallback) return rawSource;
|
|
2284
|
+
try {
|
|
2285
|
+
const root = postcss.parse(rawSource);
|
|
2286
|
+
return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
|
|
2287
|
+
} catch {
|
|
2288
|
+
return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
function isTailwindImportRequest(request) {
|
|
2292
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
2293
|
+
}
|
|
2294
|
+
function isTailwindImportAtRule(node, options = {}) {
|
|
2295
|
+
if (node.name === "tailwind") return true;
|
|
2296
|
+
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
2297
|
+
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
2298
|
+
}
|
|
2299
|
+
function isTailwindSourceDirective(node, options = {}) {
|
|
2300
|
+
if (node.type !== "atrule") return false;
|
|
2301
|
+
const atRule = node;
|
|
2302
|
+
if (isTailwindImportAtRule(atRule, options)) return true;
|
|
2303
|
+
if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
2304
|
+
if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
|
|
2305
|
+
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
2306
|
+
}
|
|
2307
|
+
function hasGeneratedCssArtifacts(rawSource) {
|
|
2308
|
+
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2309
|
+
}
|
|
2310
|
+
function isTailwindGenerationDirective(node, options = {}) {
|
|
2311
|
+
if (node.type !== "atrule") return false;
|
|
2312
|
+
const atRule = node;
|
|
2313
|
+
const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
|
|
2314
|
+
return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
|
|
2315
|
+
}
|
|
2316
|
+
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2317
|
+
try {
|
|
2318
|
+
const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
|
|
2319
|
+
if (!source) return "";
|
|
2320
|
+
const root = postcss.parse(source);
|
|
2321
|
+
let removed = false;
|
|
2322
|
+
root.walk((node) => {
|
|
2323
|
+
if (isTailwindSourceDirective(node, options)) {
|
|
2324
|
+
node.remove();
|
|
2325
|
+
removed = true;
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
return removed ? root.toString() : source;
|
|
2329
|
+
} catch {
|
|
2330
|
+
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
2334
|
+
try {
|
|
2335
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
2336
|
+
const root = postcss.parse(rawSource);
|
|
2337
|
+
let found = false;
|
|
2338
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2339
|
+
root.walk((node) => {
|
|
2340
|
+
if (isTailwindGenerationDirective(node, {
|
|
2341
|
+
...options,
|
|
2342
|
+
ignoreLayer
|
|
2343
|
+
})) {
|
|
2344
|
+
found = true;
|
|
2345
|
+
return false;
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
return found;
|
|
2349
|
+
} catch {
|
|
2350
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
2354
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
2355
|
+
try {
|
|
2356
|
+
const root = postcss.parse(rawSource);
|
|
2357
|
+
let found = false;
|
|
2358
|
+
root.walkAtRules((node) => {
|
|
2359
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
2360
|
+
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
2361
|
+
found = true;
|
|
2362
|
+
return false;
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
return found;
|
|
2366
|
+
} catch {
|
|
2367
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
function hasTailwindApplyDirective(rawSource) {
|
|
2371
|
+
if (!rawSource.includes("@apply")) return false;
|
|
2372
|
+
try {
|
|
2373
|
+
const root = postcss.parse(rawSource);
|
|
2374
|
+
let found = false;
|
|
2375
|
+
root.walkAtRules("apply", () => {
|
|
2376
|
+
found = true;
|
|
2377
|
+
return false;
|
|
2378
|
+
});
|
|
2379
|
+
return found;
|
|
2380
|
+
} catch {
|
|
2381
|
+
return false;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
2385
|
+
try {
|
|
2386
|
+
const root = postcss.parse(rawSource);
|
|
2387
|
+
const normalizedImports = normalizeTailwindImportAtRules(root, options);
|
|
2388
|
+
let found = false;
|
|
2389
|
+
let config;
|
|
2390
|
+
let configRequest;
|
|
2391
|
+
let removedConfig = false;
|
|
2392
|
+
const removeConfig = options.removeConfig ?? true;
|
|
2393
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2394
|
+
root.walk((node) => {
|
|
2395
|
+
if (isTailwindGenerationDirective(node, {
|
|
2396
|
+
...options,
|
|
2397
|
+
ignoreLayer
|
|
2398
|
+
})) found = true;
|
|
2399
|
+
if (node.type === "atrule" && node.name === "config") {
|
|
2400
|
+
const configPath = parseConfigRequest(node.params);
|
|
2401
|
+
if (configPath && !config) {
|
|
2402
|
+
configRequest = configPath;
|
|
2403
|
+
config = resolveConfigPath$1(base, configPath);
|
|
2404
|
+
}
|
|
2405
|
+
if (removeConfig) {
|
|
2406
|
+
node.remove();
|
|
2407
|
+
removedConfig = true;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
if (!found) return;
|
|
2412
|
+
if (hasPreprocessorOnlySyntax(rawSource)) {
|
|
2413
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, {
|
|
2414
|
+
...options,
|
|
2415
|
+
removeConfig
|
|
2416
|
+
});
|
|
2417
|
+
if (css) return {
|
|
2418
|
+
css,
|
|
2419
|
+
config,
|
|
2420
|
+
configRequest,
|
|
2421
|
+
base
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
return {
|
|
2425
|
+
css: removedConfig || normalizedImports ? root.toString() : rawSource,
|
|
2426
|
+
config,
|
|
2427
|
+
configRequest,
|
|
2428
|
+
base
|
|
2429
|
+
};
|
|
2430
|
+
} catch {
|
|
2431
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, options);
|
|
2432
|
+
const configRequest = extractConfigRequestFromSource(rawSource);
|
|
2433
|
+
const config = configRequest ? resolveConfigPath$1(base, configRequest) : void 0;
|
|
2434
|
+
return css ? {
|
|
2435
|
+
css,
|
|
2436
|
+
config,
|
|
2437
|
+
configRequest,
|
|
2438
|
+
base
|
|
2439
|
+
} : void 0;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
//#endregion
|
|
1954
2443
|
//#region src/tailwindcss/v4-engine/source.ts
|
|
2444
|
+
const require$1 = createRequire(import.meta.url);
|
|
2445
|
+
function isCssEntryPoint(file) {
|
|
2446
|
+
return typeof file === "string" && path.basename(file) === "index.css" && existsSync(file);
|
|
2447
|
+
}
|
|
2448
|
+
function resolvePackageCssEntryPoint(specifier) {
|
|
2449
|
+
try {
|
|
2450
|
+
const resolved = require$1.resolve(specifier);
|
|
2451
|
+
if (isCssEntryPoint(resolved)) return resolved;
|
|
2452
|
+
} catch {}
|
|
2453
|
+
const packageName = specifier.replace(/\/index\.css$/, "");
|
|
2454
|
+
if (packageName !== "tailwindcss") return;
|
|
2455
|
+
try {
|
|
2456
|
+
const packageJson = require$1.resolve(`${packageName}/package.json`);
|
|
2457
|
+
const cssEntry = path.resolve(path.dirname(packageJson), "index.css");
|
|
2458
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2459
|
+
} catch {}
|
|
2460
|
+
try {
|
|
2461
|
+
let current = path.dirname(require$1.resolve("tailwindcss-patch"));
|
|
2462
|
+
while (true) {
|
|
2463
|
+
const cssEntry = path.resolve(current, "..", "tailwindcss", "index.css");
|
|
2464
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2465
|
+
const parent = path.dirname(current);
|
|
2466
|
+
if (parent === current) break;
|
|
2467
|
+
current = parent;
|
|
2468
|
+
}
|
|
2469
|
+
} catch {}
|
|
2470
|
+
}
|
|
1955
2471
|
function isPostcssPluginImportTarget(value) {
|
|
1956
2472
|
if (!value) return false;
|
|
1957
2473
|
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
@@ -1973,7 +2489,7 @@ function resolveConfigDir(config, projectRoot) {
|
|
|
1973
2489
|
function isBarePackageSpecifier(specifier) {
|
|
1974
2490
|
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
1975
2491
|
}
|
|
1976
|
-
function parseCssImportSpecifier(params) {
|
|
2492
|
+
function parseCssImportSpecifier$1(params) {
|
|
1977
2493
|
const value = params.trim();
|
|
1978
2494
|
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1979
2495
|
if (quoted) {
|
|
@@ -2014,13 +2530,69 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
|
2014
2530
|
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
2015
2531
|
let changed = false;
|
|
2016
2532
|
root.walkAtRules("import", (rule) => {
|
|
2017
|
-
const parsed = parseCssImportSpecifier(rule.params);
|
|
2533
|
+
const parsed = parseCssImportSpecifier$1(rule.params);
|
|
2018
2534
|
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
2019
|
-
|
|
2535
|
+
const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
|
|
2536
|
+
if (!cssEntryPoint) return;
|
|
2537
|
+
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
|
|
2020
2538
|
changed = true;
|
|
2021
2539
|
});
|
|
2022
2540
|
return changed ? root.toString() : css;
|
|
2023
2541
|
}
|
|
2542
|
+
function normalizeTailwindV4CssSources(cssSources, packageName) {
|
|
2543
|
+
if (!cssSources?.length) return cssSources;
|
|
2544
|
+
let changed = false;
|
|
2545
|
+
const normalizedCssSources = cssSources.map((cssSource) => {
|
|
2546
|
+
if (typeof cssSource.css !== "string") return cssSource;
|
|
2547
|
+
const css = normalizeTailwindV4CssPackageImports(cssSource.css, packageName);
|
|
2548
|
+
if (css === cssSource.css) return cssSource;
|
|
2549
|
+
changed = true;
|
|
2550
|
+
return {
|
|
2551
|
+
...cssSource,
|
|
2552
|
+
css
|
|
2553
|
+
};
|
|
2554
|
+
});
|
|
2555
|
+
return changed ? normalizedCssSources : cssSources;
|
|
2556
|
+
}
|
|
2557
|
+
function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
|
|
2558
|
+
if (!cssEntries?.length) return;
|
|
2559
|
+
const remainingCssEntries = [];
|
|
2560
|
+
const cssSources = [];
|
|
2561
|
+
for (const cssEntry of cssEntries) {
|
|
2562
|
+
const file = path.resolve(cssEntry);
|
|
2563
|
+
if (!existsSync(file)) {
|
|
2564
|
+
remainingCssEntries.push(cssEntry);
|
|
2565
|
+
continue;
|
|
2566
|
+
}
|
|
2567
|
+
const base = path.dirname(file);
|
|
2568
|
+
const rawCss = readFileSync(file, "utf8");
|
|
2569
|
+
const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, resolveCssEntrySource(rawCss, base, { removeConfig: false })?.config), packageName);
|
|
2570
|
+
cssSources.push({
|
|
2571
|
+
file,
|
|
2572
|
+
base,
|
|
2573
|
+
css,
|
|
2574
|
+
dependencies: [file]
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
return {
|
|
2578
|
+
cssEntries: remainingCssEntries,
|
|
2579
|
+
cssSources
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
function normalizeTailwindV4SourceOptions(options) {
|
|
2583
|
+
if (!options) return options;
|
|
2584
|
+
const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(options.css, options.packageName);
|
|
2585
|
+
const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
|
|
2586
|
+
const cssSources = normalizeTailwindV4CssSources(options.cssSources || entrySources?.cssSources ? [...options.cssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName);
|
|
2587
|
+
const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
|
|
2588
|
+
if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
|
|
2589
|
+
return {
|
|
2590
|
+
...options,
|
|
2591
|
+
...css === void 0 ? {} : { css },
|
|
2592
|
+
...cssEntries === void 0 ? {} : { cssEntries },
|
|
2593
|
+
...cssSources === void 0 ? {} : { cssSources }
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2024
2596
|
function resolveTailwindCssImportTarget(patcher) {
|
|
2025
2597
|
const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
|
|
2026
2598
|
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
@@ -2071,10 +2643,7 @@ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
|
2071
2643
|
});
|
|
2072
2644
|
}
|
|
2073
2645
|
function resolveTailwindV4Source$1(options) {
|
|
2074
|
-
return resolveTailwindV4Source(options
|
|
2075
|
-
...options,
|
|
2076
|
-
css: normalizeTailwindV4CssPackageImports(options.css, options.packageName)
|
|
2077
|
-
});
|
|
2646
|
+
return resolveTailwindV4Source(normalizeTailwindV4SourceOptions(options));
|
|
2078
2647
|
}
|
|
2079
2648
|
async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
2080
2649
|
return resolveTailwindV4Source$1(resolveTailwindV4SourceOptionsFromPatcher(patcher));
|
|
@@ -2262,22 +2831,22 @@ function parseImportSourceParam(params) {
|
|
|
2262
2831
|
sourcePath: match[3]
|
|
2263
2832
|
};
|
|
2264
2833
|
}
|
|
2834
|
+
function parseCssImportSpecifier(params) {
|
|
2835
|
+
const value = params.trim();
|
|
2836
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
2837
|
+
if (quoted) return quoted[2];
|
|
2838
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
2839
|
+
return url?.[2] ?? url?.[3];
|
|
2840
|
+
}
|
|
2265
2841
|
function isTailwindCssImport(params) {
|
|
2266
|
-
|
|
2842
|
+
const specifier = parseCssImportSpecifier(params);
|
|
2843
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
2267
2844
|
}
|
|
2268
2845
|
function resolveSourceBase(base, sourcePath) {
|
|
2269
2846
|
return path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
2270
2847
|
}
|
|
2271
2848
|
function resolveConfigPath(base, configPath) {
|
|
2272
2849
|
if (path.isAbsolute(configPath)) return path.resolve(configPath);
|
|
2273
|
-
let current = path.resolve(base);
|
|
2274
|
-
while (true) {
|
|
2275
|
-
const candidate = path.resolve(current, configPath);
|
|
2276
|
-
if (existsSync(candidate)) return candidate;
|
|
2277
|
-
const parent = path.dirname(current);
|
|
2278
|
-
if (parent === current) break;
|
|
2279
|
-
current = parent;
|
|
2280
|
-
}
|
|
2281
2850
|
return path.resolve(base, configPath);
|
|
2282
2851
|
}
|
|
2283
2852
|
function createCssEntriesCacheKey(css, base, dependencies) {
|
|
@@ -2299,6 +2868,11 @@ function createResolvedViteSourceScan(input, dependencies) {
|
|
|
2299
2868
|
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
2300
2869
|
};
|
|
2301
2870
|
}
|
|
2871
|
+
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
2872
|
+
if (options.sourceCount <= 1) return entries;
|
|
2873
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
2874
|
+
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
2875
|
+
}
|
|
2302
2876
|
async function statConfigDependency(file) {
|
|
2303
2877
|
try {
|
|
2304
2878
|
const stats = await stat(file);
|
|
@@ -2348,7 +2922,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
2348
2922
|
for (const configPath of configPaths) {
|
|
2349
2923
|
const staticContent = readStaticConfigContent(configPath);
|
|
2350
2924
|
if (staticContent !== void 0) {
|
|
2351
|
-
entries.push(...normalizeLegacyContentEntries(staticContent, path.dirname(configPath)));
|
|
2925
|
+
entries.push(...normalizeLegacyContentEntries(staticContent, path.dirname(configPath), { relativeBase: path.dirname(configPath) }));
|
|
2352
2926
|
continue;
|
|
2353
2927
|
}
|
|
2354
2928
|
try {
|
|
@@ -2356,7 +2930,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
2356
2930
|
config: configPath,
|
|
2357
2931
|
cwd: path.dirname(configPath)
|
|
2358
2932
|
});
|
|
2359
|
-
entries.push(...normalizeLegacyContentEntries(loaded?.config.content, path.dirname(configPath)));
|
|
2933
|
+
entries.push(...normalizeLegacyContentEntries(loaded?.config.content, path.dirname(configPath), { relativeBase: path.dirname(configPath) }));
|
|
2360
2934
|
} catch {}
|
|
2361
2935
|
}
|
|
2362
2936
|
return {
|
|
@@ -2430,6 +3004,37 @@ function collectExistingCssEntries(options) {
|
|
|
2430
3004
|
...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
2431
3005
|
].filter((item) => typeof item === "string" && item.length > 0).map((item) => path.resolve(item)).filter((item) => existsSync(item));
|
|
2432
3006
|
}
|
|
3007
|
+
async function resolveTailwindV3CssEntryScan(options, patcher) {
|
|
3008
|
+
const cssEntries = collectExistingCssEntries(options);
|
|
3009
|
+
const entries = [];
|
|
3010
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
3011
|
+
if (cssEntries.length === 0) return {
|
|
3012
|
+
entries,
|
|
3013
|
+
dependencies
|
|
3014
|
+
};
|
|
3015
|
+
const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(patcher);
|
|
3016
|
+
await Promise.all(cssEntries.map(async (cssEntry) => {
|
|
3017
|
+
addSourceScanDependency(dependencies, cssEntry);
|
|
3018
|
+
let css;
|
|
3019
|
+
try {
|
|
3020
|
+
css = readFileSync(cssEntry, "utf8");
|
|
3021
|
+
} catch {
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
const source = await resolveTailwindV3Source({
|
|
3025
|
+
...sourceOptions,
|
|
3026
|
+
base: path.dirname(cssEntry),
|
|
3027
|
+
css
|
|
3028
|
+
});
|
|
3029
|
+
addSourceScanDependency(dependencies, source.config);
|
|
3030
|
+
addSourceScanDependencies(dependencies, source.dependencies);
|
|
3031
|
+
entries.push(...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? path.dirname(source.config) : source.cwd }));
|
|
3032
|
+
}));
|
|
3033
|
+
return {
|
|
3034
|
+
entries,
|
|
3035
|
+
dependencies
|
|
3036
|
+
};
|
|
3037
|
+
}
|
|
2433
3038
|
async function pathExistsAsFile(file) {
|
|
2434
3039
|
try {
|
|
2435
3040
|
return (await stat(file)).isFile();
|
|
@@ -2483,10 +3088,11 @@ function collectConfiguredCssSources(options) {
|
|
|
2483
3088
|
}
|
|
2484
3089
|
async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
|
|
2485
3090
|
if (patcher.majorVersion === 3) {
|
|
2486
|
-
const source = await resolveTailwindV3SourceFromPatcher(patcher);
|
|
2487
|
-
const contentEntries = normalizeLegacyContentEntries(source.configObject?.content, source.config ? path.dirname(source.config) : source.cwd);
|
|
3091
|
+
const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
|
|
3092
|
+
const contentEntries = [...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? path.dirname(source.config) : source.cwd }), ...cssEntryScan.entries];
|
|
2488
3093
|
const dependencies = /* @__PURE__ */ new Set();
|
|
2489
3094
|
addSourceScanDependency(dependencies, source.config);
|
|
3095
|
+
for (const dependency of cssEntryScan.dependencies) dependencies.add(dependency);
|
|
2490
3096
|
return contentEntries.length > 0 ? createResolvedViteSourceScan({ entries: contentEntries }, dependencies) : void 0;
|
|
2491
3097
|
}
|
|
2492
3098
|
if (patcher.majorVersion === 4) {
|
|
@@ -2523,8 +3129,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
2523
3129
|
}
|
|
2524
3130
|
}
|
|
2525
3131
|
const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2526
|
-
|
|
2527
|
-
|
|
3132
|
+
const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
|
|
3133
|
+
if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
|
|
3134
|
+
entries: explicit ? scanEntries : scanEntries.length > 0 ? scanEntries : void 0,
|
|
2528
3135
|
explicit,
|
|
2529
3136
|
inlineCandidates
|
|
2530
3137
|
}, dependencies);
|
|
@@ -2551,8 +3158,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
2551
3158
|
}
|
|
2552
3159
|
}
|
|
2553
3160
|
const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2554
|
-
|
|
2555
|
-
|
|
3161
|
+
const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length });
|
|
3162
|
+
if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
|
|
3163
|
+
entries: explicit ? cssSourceScanEntries : cssSourceScanEntries.length > 0 ? cssSourceScanEntries : void 0,
|
|
2556
3164
|
explicit,
|
|
2557
3165
|
inlineCandidates: cssSourceInlineCandidates
|
|
2558
3166
|
}, dependencies);
|
|
@@ -3414,4 +4022,4 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
|
3414
4022
|
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
3415
4023
|
}
|
|
3416
4024
|
//#endregion
|
|
3417
|
-
export {
|
|
4025
|
+
export { createSourceScanPattern as $, parseImportRequest as A, stripGeneratorPlaceholderMarkers as B, hasTailwindApplyDirective as C, normalizeTailwindSourceDirectives as D, normalizeTailwindConfigDirectives as E, hasTailwindGeneratedCss as F, createTailwindV4Engine$1 as G, stripTailwindBanners as H, hasTailwindGeneratedCssMarkers as I, filterUnsupportedMiniProgramTailwindV4Candidates as J, transformTailwindV4CssByTarget as K, splitGeneratorPlaceholderCssBySourceOrder as L, resolveCssEntrySource as M, VITE_MARKER_RE as N, normalizeTailwindSourceForGenerator as O, createCssAppend as P, collectCssInlineSourceCandidates as Q, splitTailwindGeneratedCssByBanner as R, resolveTailwindV4SourceOptionsFromPatcher as S, hasTailwindSourceDirectives as T, normalizeConfigDirective as U, stripTailwindBanner as V, prependConfigDirective as W, DEFAULT_SOURCE_SCAN_EXTENSIONS as X, loadTailwindV4DesignSystem as Y, FULL_SOURCE_SCAN_EXTENSION_RE as Z, resolveViteSourceScanEntries as _, findWorkspacePackageDir as _t, transformTailwindV3CssByTarget as a, resolveSourceScanPath as at, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, createDebug as ct, invalidateRuntimeClassSet as d, findTailwindConfig as dt, expandTailwindSourceEntries as et, runtimeSignaturePatchersSymbol as f, resolveTailwindcssOptions as ft, resolveTailwindV4EntriesFromCssCached as g, findNearestPackageRoot as gt, resolveTailwindV4EntriesFromCss as h, omitUndefined as ht, createTailwindV3Engine as i, resolveCssSourceEntries as it, removeTailwindSourceDirectives as j, normalizeTailwindV3CssEntrySource as k, getRuntimeClassSetSignature as l, createTailwindcssPatcher as lt, discoverTailwindV4CssEntries as m, resolveBooleanObjectOption as mt, resolveTailwindV3SourceFromPatcher as n, normalizeLegacyContentEntries as nt, transformTailwindV3CssToWeapp as o, resolveTailwindV4CssSourceBase as ot, createViteSourceScanMatcher as p, normalizeStringListOption as pt, transformTailwindV4CssToWeapp as q, resolveTailwindV3SourceOptionsFromPatcher as r, parseConfigParam$1 as rt, ensureTailwindcssRuntimePatch as s, toPosixPath as st, resolveTailwindV3Source as t, isFileMatchedByTailwindSourceEntries as tt, getRuntimeClassSetSignatureWithSources as u, readInstalledPackageMajorVersion as ut, resolveViteTailwindV4CssDependencies as v, findWorkspaceRoot as vt, hasTailwindRootDirectives as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, splitTailwindV4GeneratedCssBySourceOrder as z };
|