weapp-tailwindcss 5.0.1 → 5.0.3
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-CBF5YX1m.js → bundle-state-CW1X7QIy.js} +35 -3
- package/dist/{bundle-state-CQmxxx0R.mjs → bundle-state-s5HwfrmR.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 +5 -4
- package/dist/cli.mjs +5 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CvmsIQFI.js → generator-Bd1LntD3.js} +1 -1
- package/dist/{generator-DDtsUvkH.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-DArodvWs.mjs → incremental-runtime-class-set-BcAFhVvu.mjs} +496 -619
- package/dist/{incremental-runtime-class-set-BffodqHh.js → incremental-runtime-class-set-BdCWIuPW.js} +541 -694
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-BzNYQUOH.mjs → postcss-CJrmfXvi.mjs} +4 -4
- package/dist/{postcss-DE0TOtV9.js → postcss-DfnqZ4Bm.js} +4 -4
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-BzYPm-EG.js → precheck-8Ik4q0yI.js} +6 -6
- package/dist/{precheck-jZvTVXXG.mjs → precheck-h6TNzFbF.mjs} +6 -6
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-BuTlMabx.mjs → source-candidates-D7b-Jzsx.mjs} +44 -11
- package/dist/{source-candidates-CxoIaS88.js → source-candidates-DQxvGPSw.js} +49 -10
- package/dist/tailwindcss/source-scan.d.ts +3 -1
- package/dist/{tailwindcss-CCZcu0lr.mjs → tailwindcss-D5RogwtV.mjs} +2 -2
- package/dist/{tailwindcss-DZckITp1.js → tailwindcss-jvoYizzX.js} +7 -1
- package/dist/{v3-engine-DGBhUnjn.mjs → v3-engine-BCUGX3gX.mjs} +637 -31
- package/dist/{v3-engine-M6Aqru5T.js → v3-engine-CmIF_gsq.js} +768 -30
- package/dist/{vite-DgRkWVPG.js → vite-DT-VUrl0.js} +539 -296
- package/dist/{vite-BBcQIJpD.mjs → vite-yCeZWm7n.mjs} +538 -295
- 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 +1933 -1621
- package/dist/weapp-tw-runtime-classset-loader.js +6 -6
- package/dist/{webpack-D-gb4ZvO.js → webpack-BFMJqCH9.js} +7 -7
- package/dist/{webpack-D43aMQzO.mjs → webpack-E0gT72EX.mjs} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
|
@@ -633,7 +633,7 @@ function collectCssInlineSourceCandidates(root) {
|
|
|
633
633
|
excluded
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
|
-
function normalizeLegacyContentEntries(content, base) {
|
|
636
|
+
function normalizeLegacyContentEntries(content, base, options = {}) {
|
|
637
637
|
if (typeof content === "string") {
|
|
638
638
|
const negated = content.startsWith("!");
|
|
639
639
|
return [{
|
|
@@ -642,8 +642,8 @@ function normalizeLegacyContentEntries(content, base) {
|
|
|
642
642
|
pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
|
|
643
643
|
}];
|
|
644
644
|
}
|
|
645
|
-
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
|
|
646
|
-
if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, base);
|
|
645
|
+
if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base, options));
|
|
646
|
+
if (isLegacyContentObject$1(content)) return normalizeLegacyContentEntries(content.files, content.relative && options.relativeBase ? options.relativeBase : base, options);
|
|
647
647
|
return [];
|
|
648
648
|
}
|
|
649
649
|
async function pathExistsAsDirectory(file) {
|
|
@@ -1716,9 +1716,10 @@ function parseImportSourceParam$1(params) {
|
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
1718
|
function isTailwindCssImport$1(params) {
|
|
1719
|
-
|
|
1719
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
1720
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
1720
1721
|
}
|
|
1721
|
-
function parseCssImportSpecifier$
|
|
1722
|
+
function parseCssImportSpecifier$2(params) {
|
|
1722
1723
|
const value = params.trim();
|
|
1723
1724
|
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1724
1725
|
if (quoted) return quoted[2];
|
|
@@ -1726,7 +1727,7 @@ function parseCssImportSpecifier$1(params) {
|
|
|
1726
1727
|
return url?.[2] ?? url?.[3];
|
|
1727
1728
|
}
|
|
1728
1729
|
function isTailwindCssPreflightImport(params) {
|
|
1729
|
-
const specifier = parseCssImportSpecifier$
|
|
1730
|
+
const specifier = parseCssImportSpecifier$2(params);
|
|
1730
1731
|
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1731
1732
|
}
|
|
1732
1733
|
function hasImportLayerOption(params) {
|
|
@@ -1961,7 +1962,520 @@ function createTailwindV4Engine(source) {
|
|
|
1961
1962
|
};
|
|
1962
1963
|
}
|
|
1963
1964
|
//#endregion
|
|
1965
|
+
//#region src/bundlers/shared/generator-css/config-directive.ts
|
|
1966
|
+
function quoteCssString(value) {
|
|
1967
|
+
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
1968
|
+
}
|
|
1969
|
+
function toCssPath(value) {
|
|
1970
|
+
return value.replaceAll("\\", "/");
|
|
1971
|
+
}
|
|
1972
|
+
function prependConfigDirective(css, config) {
|
|
1973
|
+
if (!config || /@config\s+/.test(css)) return css;
|
|
1974
|
+
return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
|
|
1975
|
+
}
|
|
1976
|
+
function normalizeConfigDirective(css, config) {
|
|
1977
|
+
if (!config || !/@config\s+/.test(css)) return css;
|
|
1978
|
+
return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
|
|
1979
|
+
}
|
|
1980
|
+
//#endregion
|
|
1981
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
1982
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
1983
|
+
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)-/;
|
|
1984
|
+
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
1985
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
1986
|
+
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
1987
|
+
const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
|
|
1988
|
+
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
1989
|
+
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
1990
|
+
function createCssAppend(base, extra) {
|
|
1991
|
+
if (!base) return extra;
|
|
1992
|
+
if (!extra) return base;
|
|
1993
|
+
return `${base}\n${extra}`;
|
|
1994
|
+
}
|
|
1995
|
+
function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
1996
|
+
const trimmedRaw = rawSource.trim();
|
|
1997
|
+
const trimmedTailwind = rawTailwindCss.trim();
|
|
1998
|
+
if (trimmedRaw === trimmedTailwind) return {
|
|
1999
|
+
before: "",
|
|
2000
|
+
after: ""
|
|
2001
|
+
};
|
|
2002
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return {
|
|
2003
|
+
before: "",
|
|
2004
|
+
after: ""
|
|
2005
|
+
};
|
|
2006
|
+
const start = rawSource.indexOf(rawTailwindCss);
|
|
2007
|
+
if (start === -1) return;
|
|
2008
|
+
return {
|
|
2009
|
+
before: rawSource.slice(0, start),
|
|
2010
|
+
after: rawSource.slice(start + rawTailwindCss.length)
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
2014
|
+
const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
|
|
2015
|
+
if (!match || match.index === void 0) return;
|
|
2016
|
+
let afterStart = match.index + match[0].length;
|
|
2017
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
2018
|
+
if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
|
|
2019
|
+
afterStart += rawTailwindCss.length;
|
|
2020
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
2021
|
+
}
|
|
2022
|
+
return {
|
|
2023
|
+
before: rawSource.slice(0, match.index),
|
|
2024
|
+
after: rawSource.slice(afterStart)
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
function splitTailwindGeneratedCssByBanner(rawSource, start) {
|
|
2028
|
+
const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
|
|
2029
|
+
if (!match || match.index === void 0) return;
|
|
2030
|
+
return {
|
|
2031
|
+
before: rawSource.slice(0, match.index),
|
|
2032
|
+
after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
function stripTailwindBanner(css) {
|
|
2036
|
+
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
2037
|
+
}
|
|
2038
|
+
function stripTailwindBanners(css) {
|
|
2039
|
+
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
2040
|
+
}
|
|
2041
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
2042
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
2043
|
+
}
|
|
2044
|
+
function hasTailwindGeneratedCss(rawSource) {
|
|
2045
|
+
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
2046
|
+
}
|
|
2047
|
+
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
2048
|
+
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2049
|
+
}
|
|
2050
|
+
//#endregion
|
|
2051
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
2052
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
2053
|
+
"config",
|
|
2054
|
+
"custom-variant",
|
|
2055
|
+
"layer",
|
|
2056
|
+
"plugin",
|
|
2057
|
+
"reference",
|
|
2058
|
+
"source",
|
|
2059
|
+
"tailwind",
|
|
2060
|
+
"theme",
|
|
2061
|
+
"utility",
|
|
2062
|
+
"variant"
|
|
2063
|
+
]);
|
|
2064
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
2065
|
+
"config",
|
|
2066
|
+
"custom-variant",
|
|
2067
|
+
"plugin",
|
|
2068
|
+
"source",
|
|
2069
|
+
"tailwind",
|
|
2070
|
+
"theme",
|
|
2071
|
+
"utility",
|
|
2072
|
+
"variant"
|
|
2073
|
+
]);
|
|
2074
|
+
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/;
|
|
2075
|
+
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|use|forward|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
2076
|
+
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
2077
|
+
const TAILWIND_EXTRACTABLE_BLOCK_START_RE = /^\s*@(?:layer|theme|utility|variant|custom-variant)\b[\s\S]*\{/;
|
|
2078
|
+
const TAILWIND_V3_SUBPATH_IMPORT_LAYERS = new Map([
|
|
2079
|
+
["tailwindcss/base", "base"],
|
|
2080
|
+
["tailwindcss/components", "components"],
|
|
2081
|
+
["tailwindcss/utilities", "utilities"]
|
|
2082
|
+
]);
|
|
2083
|
+
function parseImportRequest(params) {
|
|
2084
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
2085
|
+
}
|
|
2086
|
+
function parseConfigRequest(params) {
|
|
2087
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
2088
|
+
}
|
|
2089
|
+
function isPackageJsonImportRequest(request) {
|
|
2090
|
+
return typeof request === "string" && request.startsWith("#");
|
|
2091
|
+
}
|
|
2092
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
2093
|
+
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
2094
|
+
}
|
|
2095
|
+
function normalizeTailwindImportRequest(request, options = {}) {
|
|
2096
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
2097
|
+
return request;
|
|
2098
|
+
}
|
|
2099
|
+
function replaceImportRequest(params, request, replacement) {
|
|
2100
|
+
const index = params.indexOf(request);
|
|
2101
|
+
if (index === -1) return params;
|
|
2102
|
+
return `${params.slice(0, index)}${replacement}${params.slice(index + request.length)}`;
|
|
2103
|
+
}
|
|
2104
|
+
function normalizeTailwindImportAtRules(root, options = {}) {
|
|
2105
|
+
if (!options.importFallback) return false;
|
|
2106
|
+
let changed = false;
|
|
2107
|
+
const seenCanonicalImports = /* @__PURE__ */ new Set();
|
|
2108
|
+
root.walkAtRules("import", (node) => {
|
|
2109
|
+
const request = parseImportRequest(node.params);
|
|
2110
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2111
|
+
if (!normalizedRequest || !isTailwindImportRequest(normalizedRequest)) return;
|
|
2112
|
+
const normalizedParams = request && normalizedRequest !== request ? replaceImportRequest(node.params, request, normalizedRequest) : node.params;
|
|
2113
|
+
const normalizedKey = normalizedParams.trim();
|
|
2114
|
+
if (seenCanonicalImports.has(normalizedKey)) {
|
|
2115
|
+
node.remove();
|
|
2116
|
+
changed = true;
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
seenCanonicalImports.add(normalizedKey);
|
|
2120
|
+
if (normalizedParams !== node.params) {
|
|
2121
|
+
node.params = normalizedParams;
|
|
2122
|
+
changed = true;
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
return changed;
|
|
2126
|
+
}
|
|
2127
|
+
function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
2128
|
+
const trimmed = line.trimStart();
|
|
2129
|
+
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
2130
|
+
const request = parseImportRequest(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
2131
|
+
if (isTailwindImportRequest(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
2132
|
+
const normalizedRequest = normalizeTailwindImportRequest(request, options);
|
|
2133
|
+
return replaceImportRequest(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
2134
|
+
}
|
|
2135
|
+
return line;
|
|
2136
|
+
}
|
|
2137
|
+
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
2138
|
+
const request = parseImportRequest(trimmed.replace(/^@import\b/, ""));
|
|
2139
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
2140
|
+
return replaceImportRequest(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
2141
|
+
}
|
|
2142
|
+
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
2143
|
+
const directives = [];
|
|
2144
|
+
const seenImports = /* @__PURE__ */ new Set();
|
|
2145
|
+
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
2146
|
+
const trimmed = line.trim();
|
|
2147
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
2148
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
|
|
2149
|
+
if (!directive) continue;
|
|
2150
|
+
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
2151
|
+
const normalizedTrimmed = normalized.trim();
|
|
2152
|
+
if (options.removeConfig && normalizedTrimmed.startsWith("@config")) continue;
|
|
2153
|
+
const request = /^@(?:import|use|forward)\b/.test(normalizedTrimmed) ? parseImportRequest(normalizedTrimmed.replace(/^@(?:import|use|forward)\b/, "")) : void 0;
|
|
2154
|
+
if (request && !isTailwindImportRequest(request) && !isPackageJsonImportRequest(request)) continue;
|
|
2155
|
+
if (/^@(?:import|use|forward)\b/.test(normalizedTrimmed) && !request) continue;
|
|
2156
|
+
if (request && isTailwindImportRequest(request)) {
|
|
2157
|
+
const key = normalizedTrimmed;
|
|
2158
|
+
if (seenImports.has(key)) continue;
|
|
2159
|
+
seenImports.add(key);
|
|
2160
|
+
}
|
|
2161
|
+
directives.push(normalized);
|
|
2162
|
+
}
|
|
2163
|
+
return directives;
|
|
2164
|
+
}
|
|
2165
|
+
function stripPreprocessorLineComment(line) {
|
|
2166
|
+
let quote;
|
|
2167
|
+
let escaped = false;
|
|
2168
|
+
for (let index = 0; index < line.length; index++) {
|
|
2169
|
+
const char = line[index];
|
|
2170
|
+
if (escaped) {
|
|
2171
|
+
escaped = false;
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
if (char === "\\") {
|
|
2175
|
+
escaped = true;
|
|
2176
|
+
continue;
|
|
2177
|
+
}
|
|
2178
|
+
if (quote) {
|
|
2179
|
+
if (char === quote) quote = void 0;
|
|
2180
|
+
continue;
|
|
2181
|
+
}
|
|
2182
|
+
if (char === "\"" || char === "'") {
|
|
2183
|
+
quote = char;
|
|
2184
|
+
continue;
|
|
2185
|
+
}
|
|
2186
|
+
if (char === "/" && line[index + 1] === "/" && (index === 0 || /\s/.test(line[index - 1]))) return line.slice(0, index).trimEnd();
|
|
2187
|
+
}
|
|
2188
|
+
return line;
|
|
2189
|
+
}
|
|
2190
|
+
function countBlockBraceDelta(line) {
|
|
2191
|
+
let quote;
|
|
2192
|
+
let escaped = false;
|
|
2193
|
+
let delta = 0;
|
|
2194
|
+
for (let index = 0; index < line.length; index++) {
|
|
2195
|
+
const char = line[index];
|
|
2196
|
+
if (escaped) {
|
|
2197
|
+
escaped = false;
|
|
2198
|
+
continue;
|
|
2199
|
+
}
|
|
2200
|
+
if (char === "\\") {
|
|
2201
|
+
escaped = true;
|
|
2202
|
+
continue;
|
|
2203
|
+
}
|
|
2204
|
+
if (quote) {
|
|
2205
|
+
if (char === quote) quote = void 0;
|
|
2206
|
+
continue;
|
|
2207
|
+
}
|
|
2208
|
+
if (char === "\"" || char === "'") {
|
|
2209
|
+
quote = char;
|
|
2210
|
+
continue;
|
|
2211
|
+
}
|
|
2212
|
+
if (char === "{") delta++;
|
|
2213
|
+
else if (char === "}") delta--;
|
|
2214
|
+
}
|
|
2215
|
+
return delta;
|
|
2216
|
+
}
|
|
2217
|
+
function extractTailwindFallbackBlocks(rawSource) {
|
|
2218
|
+
const blocks = [];
|
|
2219
|
+
let current;
|
|
2220
|
+
let depth = 0;
|
|
2221
|
+
for (const rawLine of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
2222
|
+
const line = stripPreprocessorLineComment(rawLine);
|
|
2223
|
+
if (!line.trim()) continue;
|
|
2224
|
+
if (!current) {
|
|
2225
|
+
if (!TAILWIND_EXTRACTABLE_BLOCK_START_RE.test(line)) continue;
|
|
2226
|
+
current = [line];
|
|
2227
|
+
depth = countBlockBraceDelta(line);
|
|
2228
|
+
if (depth <= 0) {
|
|
2229
|
+
blocks.push(current.join("\n"));
|
|
2230
|
+
current = void 0;
|
|
2231
|
+
depth = 0;
|
|
2232
|
+
}
|
|
2233
|
+
continue;
|
|
2234
|
+
}
|
|
2235
|
+
current.push(line);
|
|
2236
|
+
depth += countBlockBraceDelta(line);
|
|
2237
|
+
if (depth <= 0) {
|
|
2238
|
+
blocks.push(current.join("\n"));
|
|
2239
|
+
current = void 0;
|
|
2240
|
+
depth = 0;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return blocks;
|
|
2244
|
+
}
|
|
2245
|
+
function extractTailwindSourceForPostcssFallback(rawSource, options = {}) {
|
|
2246
|
+
const directives = [...extractTailwindDirectiveLines(rawSource, options), ...extractTailwindFallbackBlocks(rawSource)];
|
|
2247
|
+
return directives.length > 0 ? directives.join("\n") : void 0;
|
|
2248
|
+
}
|
|
2249
|
+
function extractConfigRequestFromSource(rawSource) {
|
|
2250
|
+
for (const line of rawSource.split(/\r?\n/)) {
|
|
2251
|
+
const match = /^\s*@config\b([\s\S]*?)(?:;|$)/.exec(line);
|
|
2252
|
+
const request = match ? parseConfigRequest(match[1] ?? "") : void 0;
|
|
2253
|
+
if (request) return request;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
function resolveConfigPath$1(base, configPath) {
|
|
2257
|
+
if (node_path.default.isAbsolute(configPath) || isPackageJsonImportRequest(configPath)) return node_path.default.isAbsolute(configPath) ? configPath : void 0;
|
|
2258
|
+
return node_path.default.resolve(base, configPath);
|
|
2259
|
+
}
|
|
2260
|
+
function normalizeTailwindConfigDirectives(rawSource, base) {
|
|
2261
|
+
return rawSource.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
|
|
2262
|
+
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return full;
|
|
2263
|
+
return `@config ${quote}${node_path.default.resolve(base, request).replace(/\\/g, "/")}${quote};`;
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
function hasPreprocessorOnlySyntax(rawSource) {
|
|
2267
|
+
return /(?:^|\n)\s*(?:\/\/|\$[\w-]+\s*:|@[\w-]+\s*:|@(?:mixin|include|function|use|forward)\b)/.test(rawSource);
|
|
2268
|
+
}
|
|
2269
|
+
function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
2270
|
+
return hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource : rawSource;
|
|
2271
|
+
}
|
|
2272
|
+
function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
2273
|
+
try {
|
|
2274
|
+
const root = postcss.default.parse(rawSource);
|
|
2275
|
+
let changed = false;
|
|
2276
|
+
root.walkAtRules("import", (node) => {
|
|
2277
|
+
const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
|
|
2278
|
+
if (!layer) return;
|
|
2279
|
+
node.replaceWith(postcss.default.atRule({
|
|
2280
|
+
name: "tailwind",
|
|
2281
|
+
params: layer
|
|
2282
|
+
}));
|
|
2283
|
+
changed = true;
|
|
2284
|
+
});
|
|
2285
|
+
return changed ? root.toString() : rawSource;
|
|
2286
|
+
} catch {
|
|
2287
|
+
return rawSource;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2291
|
+
if (!options.importFallback) return rawSource;
|
|
2292
|
+
try {
|
|
2293
|
+
const root = postcss.default.parse(rawSource);
|
|
2294
|
+
return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
|
|
2295
|
+
} catch {
|
|
2296
|
+
return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
function isTailwindImportRequest(request) {
|
|
2300
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
2301
|
+
}
|
|
2302
|
+
function isTailwindImportAtRule(node, options = {}) {
|
|
2303
|
+
if (node.name === "tailwind") return true;
|
|
2304
|
+
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
2305
|
+
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
2306
|
+
}
|
|
2307
|
+
function isTailwindSourceDirective(node, options = {}) {
|
|
2308
|
+
if (node.type !== "atrule") return false;
|
|
2309
|
+
const atRule = node;
|
|
2310
|
+
if (isTailwindImportAtRule(atRule, options)) return true;
|
|
2311
|
+
if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
2312
|
+
if (atRule.name === "layer") return !atRule.nodes || atRule.nodes.length === 0;
|
|
2313
|
+
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
2314
|
+
}
|
|
2315
|
+
function hasGeneratedCssArtifacts(rawSource) {
|
|
2316
|
+
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
2317
|
+
}
|
|
2318
|
+
function isTailwindGenerationDirective(node, options = {}) {
|
|
2319
|
+
if (node.type !== "atrule") return false;
|
|
2320
|
+
const atRule = node;
|
|
2321
|
+
const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
|
|
2322
|
+
return isTailwindImportAtRule(atRule, options) || isPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
|
|
2323
|
+
}
|
|
2324
|
+
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2325
|
+
try {
|
|
2326
|
+
const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
|
|
2327
|
+
if (!source) return "";
|
|
2328
|
+
const root = postcss.default.parse(source);
|
|
2329
|
+
let removed = false;
|
|
2330
|
+
root.walk((node) => {
|
|
2331
|
+
if (isTailwindSourceDirective(node, options)) {
|
|
2332
|
+
node.remove();
|
|
2333
|
+
removed = true;
|
|
2334
|
+
}
|
|
2335
|
+
});
|
|
2336
|
+
return removed ? root.toString() : source;
|
|
2337
|
+
} catch {
|
|
2338
|
+
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
2342
|
+
try {
|
|
2343
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
2344
|
+
const root = postcss.default.parse(rawSource);
|
|
2345
|
+
let found = false;
|
|
2346
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2347
|
+
root.walk((node) => {
|
|
2348
|
+
if (isTailwindGenerationDirective(node, {
|
|
2349
|
+
...options,
|
|
2350
|
+
ignoreLayer
|
|
2351
|
+
})) {
|
|
2352
|
+
found = true;
|
|
2353
|
+
return false;
|
|
2354
|
+
}
|
|
2355
|
+
});
|
|
2356
|
+
return found;
|
|
2357
|
+
} catch {
|
|
2358
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
2362
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
2363
|
+
try {
|
|
2364
|
+
const root = postcss.default.parse(rawSource);
|
|
2365
|
+
let found = false;
|
|
2366
|
+
root.walkAtRules((node) => {
|
|
2367
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
2368
|
+
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
2369
|
+
found = true;
|
|
2370
|
+
return false;
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
return found;
|
|
2374
|
+
} catch {
|
|
2375
|
+
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
function hasTailwindApplyDirective(rawSource) {
|
|
2379
|
+
if (!rawSource.includes("@apply")) return false;
|
|
2380
|
+
try {
|
|
2381
|
+
const root = postcss.default.parse(rawSource);
|
|
2382
|
+
let found = false;
|
|
2383
|
+
root.walkAtRules("apply", () => {
|
|
2384
|
+
found = true;
|
|
2385
|
+
return false;
|
|
2386
|
+
});
|
|
2387
|
+
return found;
|
|
2388
|
+
} catch {
|
|
2389
|
+
return false;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
2393
|
+
try {
|
|
2394
|
+
const root = postcss.default.parse(rawSource);
|
|
2395
|
+
const normalizedImports = normalizeTailwindImportAtRules(root, options);
|
|
2396
|
+
let found = false;
|
|
2397
|
+
let config;
|
|
2398
|
+
let configRequest;
|
|
2399
|
+
let removedConfig = false;
|
|
2400
|
+
const removeConfig = options.removeConfig ?? true;
|
|
2401
|
+
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2402
|
+
root.walk((node) => {
|
|
2403
|
+
if (isTailwindGenerationDirective(node, {
|
|
2404
|
+
...options,
|
|
2405
|
+
ignoreLayer
|
|
2406
|
+
})) found = true;
|
|
2407
|
+
if (node.type === "atrule" && node.name === "config") {
|
|
2408
|
+
const configPath = parseConfigRequest(node.params);
|
|
2409
|
+
if (configPath && !config) {
|
|
2410
|
+
configRequest = configPath;
|
|
2411
|
+
config = resolveConfigPath$1(base, configPath);
|
|
2412
|
+
}
|
|
2413
|
+
if (removeConfig) {
|
|
2414
|
+
node.remove();
|
|
2415
|
+
removedConfig = true;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
if (!found) return;
|
|
2420
|
+
if (hasPreprocessorOnlySyntax(rawSource)) {
|
|
2421
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, {
|
|
2422
|
+
...options,
|
|
2423
|
+
removeConfig
|
|
2424
|
+
});
|
|
2425
|
+
if (css) return {
|
|
2426
|
+
css,
|
|
2427
|
+
config,
|
|
2428
|
+
configRequest,
|
|
2429
|
+
base
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
return {
|
|
2433
|
+
css: removedConfig || normalizedImports ? root.toString() : rawSource,
|
|
2434
|
+
config,
|
|
2435
|
+
configRequest,
|
|
2436
|
+
base
|
|
2437
|
+
};
|
|
2438
|
+
} catch {
|
|
2439
|
+
const css = extractTailwindSourceForPostcssFallback(rawSource, options);
|
|
2440
|
+
const configRequest = extractConfigRequestFromSource(rawSource);
|
|
2441
|
+
const config = configRequest ? resolveConfigPath$1(base, configRequest) : void 0;
|
|
2442
|
+
return css ? {
|
|
2443
|
+
css,
|
|
2444
|
+
config,
|
|
2445
|
+
configRequest,
|
|
2446
|
+
base
|
|
2447
|
+
} : void 0;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
//#endregion
|
|
1964
2451
|
//#region src/tailwindcss/v4-engine/source.ts
|
|
2452
|
+
const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
2453
|
+
function isCssEntryPoint(file) {
|
|
2454
|
+
return typeof file === "string" && node_path.default.basename(file) === "index.css" && (0, node_fs.existsSync)(file);
|
|
2455
|
+
}
|
|
2456
|
+
function resolvePackageCssEntryPoint(specifier) {
|
|
2457
|
+
try {
|
|
2458
|
+
const resolved = require$2.resolve(specifier);
|
|
2459
|
+
if (isCssEntryPoint(resolved)) return resolved;
|
|
2460
|
+
} catch {}
|
|
2461
|
+
const packageName = specifier.replace(/\/index\.css$/, "");
|
|
2462
|
+
if (packageName !== "tailwindcss") return;
|
|
2463
|
+
try {
|
|
2464
|
+
const packageJson = require$2.resolve(`${packageName}/package.json`);
|
|
2465
|
+
const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
|
|
2466
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2467
|
+
} catch {}
|
|
2468
|
+
try {
|
|
2469
|
+
let current = node_path.default.dirname(require$2.resolve("tailwindcss-patch"));
|
|
2470
|
+
while (true) {
|
|
2471
|
+
const cssEntry = node_path.default.resolve(current, "..", "tailwindcss", "index.css");
|
|
2472
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
2473
|
+
const parent = node_path.default.dirname(current);
|
|
2474
|
+
if (parent === current) break;
|
|
2475
|
+
current = parent;
|
|
2476
|
+
}
|
|
2477
|
+
} catch {}
|
|
2478
|
+
}
|
|
1965
2479
|
function isPostcssPluginImportTarget(value) {
|
|
1966
2480
|
if (!value) return false;
|
|
1967
2481
|
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
@@ -1983,7 +2497,7 @@ function resolveConfigDir(config, projectRoot) {
|
|
|
1983
2497
|
function isBarePackageSpecifier(specifier) {
|
|
1984
2498
|
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
1985
2499
|
}
|
|
1986
|
-
function parseCssImportSpecifier(params) {
|
|
2500
|
+
function parseCssImportSpecifier$1(params) {
|
|
1987
2501
|
const value = params.trim();
|
|
1988
2502
|
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1989
2503
|
if (quoted) {
|
|
@@ -2024,13 +2538,69 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
|
2024
2538
|
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
2025
2539
|
let changed = false;
|
|
2026
2540
|
root.walkAtRules("import", (rule) => {
|
|
2027
|
-
const parsed = parseCssImportSpecifier(rule.params);
|
|
2541
|
+
const parsed = parseCssImportSpecifier$1(rule.params);
|
|
2028
2542
|
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
2029
|
-
|
|
2543
|
+
const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
|
|
2544
|
+
if (!cssEntryPoint) return;
|
|
2545
|
+
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
|
|
2030
2546
|
changed = true;
|
|
2031
2547
|
});
|
|
2032
2548
|
return changed ? root.toString() : css;
|
|
2033
2549
|
}
|
|
2550
|
+
function normalizeTailwindV4CssSources(cssSources, packageName) {
|
|
2551
|
+
if (!cssSources?.length) return cssSources;
|
|
2552
|
+
let changed = false;
|
|
2553
|
+
const normalizedCssSources = cssSources.map((cssSource) => {
|
|
2554
|
+
if (typeof cssSource.css !== "string") return cssSource;
|
|
2555
|
+
const css = normalizeTailwindV4CssPackageImports(cssSource.css, packageName);
|
|
2556
|
+
if (css === cssSource.css) return cssSource;
|
|
2557
|
+
changed = true;
|
|
2558
|
+
return {
|
|
2559
|
+
...cssSource,
|
|
2560
|
+
css
|
|
2561
|
+
};
|
|
2562
|
+
});
|
|
2563
|
+
return changed ? normalizedCssSources : cssSources;
|
|
2564
|
+
}
|
|
2565
|
+
function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
|
|
2566
|
+
if (!cssEntries?.length) return;
|
|
2567
|
+
const remainingCssEntries = [];
|
|
2568
|
+
const cssSources = [];
|
|
2569
|
+
for (const cssEntry of cssEntries) {
|
|
2570
|
+
const file = node_path.default.resolve(cssEntry);
|
|
2571
|
+
if (!(0, node_fs.existsSync)(file)) {
|
|
2572
|
+
remainingCssEntries.push(cssEntry);
|
|
2573
|
+
continue;
|
|
2574
|
+
}
|
|
2575
|
+
const base = node_path.default.dirname(file);
|
|
2576
|
+
const rawCss = (0, node_fs.readFileSync)(file, "utf8");
|
|
2577
|
+
const css = normalizeTailwindV4CssPackageImports(normalizeConfigDirective(rawCss, resolveCssEntrySource(rawCss, base, { removeConfig: false })?.config), packageName);
|
|
2578
|
+
cssSources.push({
|
|
2579
|
+
file,
|
|
2580
|
+
base,
|
|
2581
|
+
css,
|
|
2582
|
+
dependencies: [file]
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
return {
|
|
2586
|
+
cssEntries: remainingCssEntries,
|
|
2587
|
+
cssSources
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
function normalizeTailwindV4SourceOptions(options) {
|
|
2591
|
+
if (!options) return options;
|
|
2592
|
+
const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports(options.css, options.packageName);
|
|
2593
|
+
const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
|
|
2594
|
+
const cssSources = normalizeTailwindV4CssSources(options.cssSources || entrySources?.cssSources ? [...options.cssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName);
|
|
2595
|
+
const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
|
|
2596
|
+
if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
|
|
2597
|
+
return {
|
|
2598
|
+
...options,
|
|
2599
|
+
...css === void 0 ? {} : { css },
|
|
2600
|
+
...cssEntries === void 0 ? {} : { cssEntries },
|
|
2601
|
+
...cssSources === void 0 ? {} : { cssSources }
|
|
2602
|
+
};
|
|
2603
|
+
}
|
|
2034
2604
|
function resolveTailwindCssImportTarget(patcher) {
|
|
2035
2605
|
const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
|
|
2036
2606
|
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
@@ -2081,10 +2651,7 @@ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
|
2081
2651
|
});
|
|
2082
2652
|
}
|
|
2083
2653
|
function resolveTailwindV4Source(options) {
|
|
2084
|
-
return (0, tailwindcss_patch.resolveTailwindV4Source)(options
|
|
2085
|
-
...options,
|
|
2086
|
-
css: normalizeTailwindV4CssPackageImports(options.css, options.packageName)
|
|
2087
|
-
});
|
|
2654
|
+
return (0, tailwindcss_patch.resolveTailwindV4Source)(normalizeTailwindV4SourceOptions(options));
|
|
2088
2655
|
}
|
|
2089
2656
|
async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
2090
2657
|
return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromPatcher(patcher));
|
|
@@ -2272,22 +2839,22 @@ function parseImportSourceParam(params) {
|
|
|
2272
2839
|
sourcePath: match[3]
|
|
2273
2840
|
};
|
|
2274
2841
|
}
|
|
2842
|
+
function parseCssImportSpecifier(params) {
|
|
2843
|
+
const value = params.trim();
|
|
2844
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
2845
|
+
if (quoted) return quoted[2];
|
|
2846
|
+
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
2847
|
+
return url?.[2] ?? url?.[3];
|
|
2848
|
+
}
|
|
2275
2849
|
function isTailwindCssImport(params) {
|
|
2276
|
-
|
|
2850
|
+
const specifier = parseCssImportSpecifier(params);
|
|
2851
|
+
return specifier === "tailwindcss" || specifier?.startsWith("tailwindcss/") || specifier?.replaceAll("\\", "/").endsWith("/tailwindcss/index.css");
|
|
2277
2852
|
}
|
|
2278
2853
|
function resolveSourceBase(base, sourcePath) {
|
|
2279
2854
|
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
2280
2855
|
}
|
|
2281
2856
|
function resolveConfigPath(base, configPath) {
|
|
2282
2857
|
if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
|
|
2283
|
-
let current = node_path.default.resolve(base);
|
|
2284
|
-
while (true) {
|
|
2285
|
-
const candidate = node_path.default.resolve(current, configPath);
|
|
2286
|
-
if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
2287
|
-
const parent = node_path.default.dirname(current);
|
|
2288
|
-
if (parent === current) break;
|
|
2289
|
-
current = parent;
|
|
2290
|
-
}
|
|
2291
2858
|
return node_path.default.resolve(base, configPath);
|
|
2292
2859
|
}
|
|
2293
2860
|
function createCssEntriesCacheKey(css, base, dependencies) {
|
|
@@ -2309,6 +2876,11 @@ function createResolvedViteSourceScan(input, dependencies) {
|
|
|
2309
2876
|
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
|
|
2310
2877
|
};
|
|
2311
2878
|
}
|
|
2879
|
+
function createMergedCssEntrySourceScanEntries(entries, options) {
|
|
2880
|
+
if (options.sourceCount <= 1) return entries;
|
|
2881
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
2882
|
+
return positiveEntries.length > 0 ? positiveEntries : entries;
|
|
2883
|
+
}
|
|
2312
2884
|
async function statConfigDependency(file) {
|
|
2313
2885
|
try {
|
|
2314
2886
|
const stats = await (0, node_fs_promises.stat)(file);
|
|
@@ -2358,7 +2930,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
2358
2930
|
for (const configPath of configPaths) {
|
|
2359
2931
|
const staticContent = readStaticConfigContent(configPath);
|
|
2360
2932
|
if (staticContent !== void 0) {
|
|
2361
|
-
entries.push(...normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath)));
|
|
2933
|
+
entries.push(...normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
|
|
2362
2934
|
continue;
|
|
2363
2935
|
}
|
|
2364
2936
|
try {
|
|
@@ -2366,7 +2938,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
2366
2938
|
config: configPath,
|
|
2367
2939
|
cwd: node_path.default.dirname(configPath)
|
|
2368
2940
|
});
|
|
2369
|
-
entries.push(...normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath)));
|
|
2941
|
+
entries.push(...normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
|
|
2370
2942
|
} catch {}
|
|
2371
2943
|
}
|
|
2372
2944
|
return {
|
|
@@ -2440,6 +3012,37 @@ function collectExistingCssEntries(options) {
|
|
|
2440
3012
|
...options.tailwindcssPatcherOptions?.tailwindcss?.v4?.cssEntries ?? []
|
|
2441
3013
|
].filter((item) => typeof item === "string" && item.length > 0).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
|
|
2442
3014
|
}
|
|
3015
|
+
async function resolveTailwindV3CssEntryScan(options, patcher) {
|
|
3016
|
+
const cssEntries = collectExistingCssEntries(options);
|
|
3017
|
+
const entries = [];
|
|
3018
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
3019
|
+
if (cssEntries.length === 0) return {
|
|
3020
|
+
entries,
|
|
3021
|
+
dependencies
|
|
3022
|
+
};
|
|
3023
|
+
const sourceOptions = resolveTailwindV3SourceOptionsFromPatcher(patcher);
|
|
3024
|
+
await Promise.all(cssEntries.map(async (cssEntry) => {
|
|
3025
|
+
addSourceScanDependency(dependencies, cssEntry);
|
|
3026
|
+
let css;
|
|
3027
|
+
try {
|
|
3028
|
+
css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
3029
|
+
} catch {
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
const source = await resolveTailwindV3Source({
|
|
3033
|
+
...sourceOptions,
|
|
3034
|
+
base: node_path.default.dirname(cssEntry),
|
|
3035
|
+
css
|
|
3036
|
+
});
|
|
3037
|
+
addSourceScanDependency(dependencies, source.config);
|
|
3038
|
+
addSourceScanDependencies(dependencies, source.dependencies);
|
|
3039
|
+
entries.push(...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }));
|
|
3040
|
+
}));
|
|
3041
|
+
return {
|
|
3042
|
+
entries,
|
|
3043
|
+
dependencies
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
2443
3046
|
async function pathExistsAsFile(file) {
|
|
2444
3047
|
try {
|
|
2445
3048
|
return (await (0, node_fs_promises.stat)(file)).isFile();
|
|
@@ -2493,10 +3096,11 @@ function collectConfiguredCssSources(options) {
|
|
|
2493
3096
|
}
|
|
2494
3097
|
async function resolveViteSourceScanEntries(options, patcher, scanOptions = {}) {
|
|
2495
3098
|
if (patcher.majorVersion === 3) {
|
|
2496
|
-
const source = await resolveTailwindV3SourceFromPatcher(patcher);
|
|
2497
|
-
const contentEntries = normalizeLegacyContentEntries(source.configObject?.content, source.config ? node_path.default.dirname(source.config) : source.cwd);
|
|
3099
|
+
const [source, cssEntryScan] = await Promise.all([resolveTailwindV3SourceFromPatcher(patcher), resolveTailwindV3CssEntryScan(options, patcher)]);
|
|
3100
|
+
const contentEntries = [...normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd }), ...cssEntryScan.entries];
|
|
2498
3101
|
const dependencies = /* @__PURE__ */ new Set();
|
|
2499
3102
|
addSourceScanDependency(dependencies, source.config);
|
|
3103
|
+
for (const dependency of cssEntryScan.dependencies) dependencies.add(dependency);
|
|
2500
3104
|
return contentEntries.length > 0 ? createResolvedViteSourceScan({ entries: contentEntries }, dependencies) : void 0;
|
|
2501
3105
|
}
|
|
2502
3106
|
if (patcher.majorVersion === 4) {
|
|
@@ -2533,8 +3137,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
2533
3137
|
}
|
|
2534
3138
|
}
|
|
2535
3139
|
const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2536
|
-
|
|
2537
|
-
|
|
3140
|
+
const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
|
|
3141
|
+
if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedViteSourceScan({
|
|
3142
|
+
entries: explicit ? scanEntries : scanEntries.length > 0 ? scanEntries : void 0,
|
|
2538
3143
|
explicit,
|
|
2539
3144
|
inlineCandidates
|
|
2540
3145
|
}, dependencies);
|
|
@@ -2561,8 +3166,9 @@ async function resolveViteSourceScanEntries(options, patcher, scanOptions = {})
|
|
|
2561
3166
|
}
|
|
2562
3167
|
}
|
|
2563
3168
|
const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
|
|
2564
|
-
|
|
2565
|
-
|
|
3169
|
+
const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length });
|
|
3170
|
+
if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit || sourceOptions.cssSources?.length || configuredCssSources.length > 0) return createResolvedViteSourceScan({
|
|
3171
|
+
entries: explicit ? cssSourceScanEntries : cssSourceScanEntries.length > 0 ? cssSourceScanEntries : void 0,
|
|
2566
3172
|
explicit,
|
|
2567
3173
|
inlineCandidates: cssSourceInlineCandidates
|
|
2568
3174
|
}, dependencies);
|
|
@@ -3436,12 +4042,24 @@ Object.defineProperty(exports, "FULL_SOURCE_SCAN_EXTENSION_RE", {
|
|
|
3436
4042
|
return FULL_SOURCE_SCAN_EXTENSION_RE;
|
|
3437
4043
|
}
|
|
3438
4044
|
});
|
|
4045
|
+
Object.defineProperty(exports, "VITE_MARKER_RE", {
|
|
4046
|
+
enumerable: true,
|
|
4047
|
+
get: function() {
|
|
4048
|
+
return VITE_MARKER_RE;
|
|
4049
|
+
}
|
|
4050
|
+
});
|
|
3439
4051
|
Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
|
|
3440
4052
|
enumerable: true,
|
|
3441
4053
|
get: function() {
|
|
3442
4054
|
return collectCssInlineSourceCandidates;
|
|
3443
4055
|
}
|
|
3444
4056
|
});
|
|
4057
|
+
Object.defineProperty(exports, "createCssAppend", {
|
|
4058
|
+
enumerable: true,
|
|
4059
|
+
get: function() {
|
|
4060
|
+
return createCssAppend;
|
|
4061
|
+
}
|
|
4062
|
+
});
|
|
3445
4063
|
Object.defineProperty(exports, "createDebug", {
|
|
3446
4064
|
enumerable: true,
|
|
3447
4065
|
get: function() {
|
|
@@ -3544,6 +4162,36 @@ Object.defineProperty(exports, "getRuntimeClassSetSignatureWithSources", {
|
|
|
3544
4162
|
return getRuntimeClassSetSignatureWithSources;
|
|
3545
4163
|
}
|
|
3546
4164
|
});
|
|
4165
|
+
Object.defineProperty(exports, "hasTailwindApplyDirective", {
|
|
4166
|
+
enumerable: true,
|
|
4167
|
+
get: function() {
|
|
4168
|
+
return hasTailwindApplyDirective;
|
|
4169
|
+
}
|
|
4170
|
+
});
|
|
4171
|
+
Object.defineProperty(exports, "hasTailwindGeneratedCss", {
|
|
4172
|
+
enumerable: true,
|
|
4173
|
+
get: function() {
|
|
4174
|
+
return hasTailwindGeneratedCss;
|
|
4175
|
+
}
|
|
4176
|
+
});
|
|
4177
|
+
Object.defineProperty(exports, "hasTailwindGeneratedCssMarkers", {
|
|
4178
|
+
enumerable: true,
|
|
4179
|
+
get: function() {
|
|
4180
|
+
return hasTailwindGeneratedCssMarkers;
|
|
4181
|
+
}
|
|
4182
|
+
});
|
|
4183
|
+
Object.defineProperty(exports, "hasTailwindRootDirectives", {
|
|
4184
|
+
enumerable: true,
|
|
4185
|
+
get: function() {
|
|
4186
|
+
return hasTailwindRootDirectives;
|
|
4187
|
+
}
|
|
4188
|
+
});
|
|
4189
|
+
Object.defineProperty(exports, "hasTailwindSourceDirectives", {
|
|
4190
|
+
enumerable: true,
|
|
4191
|
+
get: function() {
|
|
4192
|
+
return hasTailwindSourceDirectives;
|
|
4193
|
+
}
|
|
4194
|
+
});
|
|
3547
4195
|
Object.defineProperty(exports, "invalidateRuntimeClassSet", {
|
|
3548
4196
|
enumerable: true,
|
|
3549
4197
|
get: function() {
|
|
@@ -3556,6 +4204,12 @@ Object.defineProperty(exports, "isFileMatchedByTailwindSourceEntries", {
|
|
|
3556
4204
|
return isFileMatchedByTailwindSourceEntries;
|
|
3557
4205
|
}
|
|
3558
4206
|
});
|
|
4207
|
+
Object.defineProperty(exports, "normalizeConfigDirective", {
|
|
4208
|
+
enumerable: true,
|
|
4209
|
+
get: function() {
|
|
4210
|
+
return normalizeConfigDirective;
|
|
4211
|
+
}
|
|
4212
|
+
});
|
|
3559
4213
|
Object.defineProperty(exports, "normalizeLegacyContentEntries", {
|
|
3560
4214
|
enumerable: true,
|
|
3561
4215
|
get: function() {
|
|
@@ -3568,6 +4222,30 @@ Object.defineProperty(exports, "normalizeStringListOption", {
|
|
|
3568
4222
|
return normalizeStringListOption;
|
|
3569
4223
|
}
|
|
3570
4224
|
});
|
|
4225
|
+
Object.defineProperty(exports, "normalizeTailwindConfigDirectives", {
|
|
4226
|
+
enumerable: true,
|
|
4227
|
+
get: function() {
|
|
4228
|
+
return normalizeTailwindConfigDirectives;
|
|
4229
|
+
}
|
|
4230
|
+
});
|
|
4231
|
+
Object.defineProperty(exports, "normalizeTailwindSourceDirectives", {
|
|
4232
|
+
enumerable: true,
|
|
4233
|
+
get: function() {
|
|
4234
|
+
return normalizeTailwindSourceDirectives;
|
|
4235
|
+
}
|
|
4236
|
+
});
|
|
4237
|
+
Object.defineProperty(exports, "normalizeTailwindSourceForGenerator", {
|
|
4238
|
+
enumerable: true,
|
|
4239
|
+
get: function() {
|
|
4240
|
+
return normalizeTailwindSourceForGenerator;
|
|
4241
|
+
}
|
|
4242
|
+
});
|
|
4243
|
+
Object.defineProperty(exports, "normalizeTailwindV3CssEntrySource", {
|
|
4244
|
+
enumerable: true,
|
|
4245
|
+
get: function() {
|
|
4246
|
+
return normalizeTailwindV3CssEntrySource;
|
|
4247
|
+
}
|
|
4248
|
+
});
|
|
3571
4249
|
Object.defineProperty(exports, "omitUndefined", {
|
|
3572
4250
|
enumerable: true,
|
|
3573
4251
|
get: function() {
|
|
@@ -3580,18 +4258,42 @@ Object.defineProperty(exports, "parseConfigParam", {
|
|
|
3580
4258
|
return parseConfigParam$1;
|
|
3581
4259
|
}
|
|
3582
4260
|
});
|
|
4261
|
+
Object.defineProperty(exports, "parseImportRequest", {
|
|
4262
|
+
enumerable: true,
|
|
4263
|
+
get: function() {
|
|
4264
|
+
return parseImportRequest;
|
|
4265
|
+
}
|
|
4266
|
+
});
|
|
4267
|
+
Object.defineProperty(exports, "prependConfigDirective", {
|
|
4268
|
+
enumerable: true,
|
|
4269
|
+
get: function() {
|
|
4270
|
+
return prependConfigDirective;
|
|
4271
|
+
}
|
|
4272
|
+
});
|
|
3583
4273
|
Object.defineProperty(exports, "readInstalledPackageMajorVersion", {
|
|
3584
4274
|
enumerable: true,
|
|
3585
4275
|
get: function() {
|
|
3586
4276
|
return readInstalledPackageMajorVersion;
|
|
3587
4277
|
}
|
|
3588
4278
|
});
|
|
4279
|
+
Object.defineProperty(exports, "removeTailwindSourceDirectives", {
|
|
4280
|
+
enumerable: true,
|
|
4281
|
+
get: function() {
|
|
4282
|
+
return removeTailwindSourceDirectives;
|
|
4283
|
+
}
|
|
4284
|
+
});
|
|
3589
4285
|
Object.defineProperty(exports, "resolveBooleanObjectOption", {
|
|
3590
4286
|
enumerable: true,
|
|
3591
4287
|
get: function() {
|
|
3592
4288
|
return resolveBooleanObjectOption;
|
|
3593
4289
|
}
|
|
3594
4290
|
});
|
|
4291
|
+
Object.defineProperty(exports, "resolveCssEntrySource", {
|
|
4292
|
+
enumerable: true,
|
|
4293
|
+
get: function() {
|
|
4294
|
+
return resolveCssEntrySource;
|
|
4295
|
+
}
|
|
4296
|
+
});
|
|
3595
4297
|
Object.defineProperty(exports, "resolveCssSourceEntries", {
|
|
3596
4298
|
enumerable: true,
|
|
3597
4299
|
get: function() {
|
|
@@ -3682,6 +4384,42 @@ Object.defineProperty(exports, "runtimeSignaturePatchersSymbol", {
|
|
|
3682
4384
|
return runtimeSignaturePatchersSymbol;
|
|
3683
4385
|
}
|
|
3684
4386
|
});
|
|
4387
|
+
Object.defineProperty(exports, "splitGeneratorPlaceholderCssBySourceOrder", {
|
|
4388
|
+
enumerable: true,
|
|
4389
|
+
get: function() {
|
|
4390
|
+
return splitGeneratorPlaceholderCssBySourceOrder;
|
|
4391
|
+
}
|
|
4392
|
+
});
|
|
4393
|
+
Object.defineProperty(exports, "splitTailwindGeneratedCssByBanner", {
|
|
4394
|
+
enumerable: true,
|
|
4395
|
+
get: function() {
|
|
4396
|
+
return splitTailwindGeneratedCssByBanner;
|
|
4397
|
+
}
|
|
4398
|
+
});
|
|
4399
|
+
Object.defineProperty(exports, "splitTailwindV4GeneratedCssBySourceOrder", {
|
|
4400
|
+
enumerable: true,
|
|
4401
|
+
get: function() {
|
|
4402
|
+
return splitTailwindV4GeneratedCssBySourceOrder;
|
|
4403
|
+
}
|
|
4404
|
+
});
|
|
4405
|
+
Object.defineProperty(exports, "stripGeneratorPlaceholderMarkers", {
|
|
4406
|
+
enumerable: true,
|
|
4407
|
+
get: function() {
|
|
4408
|
+
return stripGeneratorPlaceholderMarkers;
|
|
4409
|
+
}
|
|
4410
|
+
});
|
|
4411
|
+
Object.defineProperty(exports, "stripTailwindBanner", {
|
|
4412
|
+
enumerable: true,
|
|
4413
|
+
get: function() {
|
|
4414
|
+
return stripTailwindBanner;
|
|
4415
|
+
}
|
|
4416
|
+
});
|
|
4417
|
+
Object.defineProperty(exports, "stripTailwindBanners", {
|
|
4418
|
+
enumerable: true,
|
|
4419
|
+
get: function() {
|
|
4420
|
+
return stripTailwindBanners;
|
|
4421
|
+
}
|
|
4422
|
+
});
|
|
3685
4423
|
Object.defineProperty(exports, "toPosixPath", {
|
|
3686
4424
|
enumerable: true,
|
|
3687
4425
|
get: function() {
|