weapp-tailwindcss 5.0.8 → 5.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-CTp6wE5a.js +33 -0
- package/dist/auto-Cl8_hsG6.mjs +22 -0
- package/dist/{bundle-state-cHwTyrOS.js → bundle-state-BwtEqxvU.js} +3 -3
- package/dist/{bundle-state-5FtFktJr.mjs → bundle-state-CXzPknlT.mjs} +2 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +0 -2
- package/dist/cli.js +1 -159
- package/dist/cli.mjs +1 -159
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -7
- package/dist/css-macro/postcss.d.ts +1 -6
- package/dist/css-macro/postcss.js +15 -3
- package/dist/css-macro/postcss.mjs +2 -2
- package/dist/css-macro.js +19 -5
- package/dist/css-macro.mjs +16 -2
- package/dist/{generator-C--TrAod.js → generator-ChgOWNOj.js} +1 -1
- package/dist/{generator-DnwUQOXB.mjs → generator-h2XRiJ9-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-B22YSGU_.mjs → gulp-Be88jhoY.mjs} +5 -5
- package/dist/{gulp-5Tan5bHG.js → gulp-CHtZF-oT.js} +6 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-CscCNKb9.js → hmr-timing-BkivBZvN.js} +41 -43
- package/dist/{hmr-timing-DK-mine6.mjs → hmr-timing-Ct5w4hdM.mjs} +6 -7
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/postcss.d.ts +2 -13
- package/dist/postcss.js +14 -3
- package/dist/postcss.mjs +10 -1
- package/dist/{precheck-CcxTR7E_.mjs → precheck-BpHxsWRd.mjs} +4 -4
- package/dist/{precheck-B8y6tDvG.js → precheck-CY9oaH49.js} +5 -5
- package/dist/presets.js +4 -4
- package/dist/presets.mjs +3 -3
- package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -1
- package/dist/{tailwindcss-0DaftXcU.mjs → tailwindcss-Bfy2egdX.mjs} +2 -2
- package/dist/{tailwindcss-DbZ4o4m_.js → tailwindcss-DbbAKAZP.js} +3 -3
- package/dist/{transform-DiW_u3eD.js → transform-Cd634UZV.js} +1 -1
- package/dist/{transform-DRyWUN5X.mjs → transform-r5evL6Hn.mjs} +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/{v3-engine-ArQVHEau.mjs → v3-engine-CFkP6dWF.mjs} +4 -5
- package/dist/{v3-engine-DdlvXpID.js → v3-engine-D0yA9ZkF.js} +35 -73
- package/dist/{vite-_iUhzc4t.mjs → vite-Bd8qf9dK.mjs} +21 -423
- package/dist/{vite-C_IUnDBy.js → vite-j9cB2Ff1.js} +38 -443
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/watch-dependencies-bpG6kmAf.js +80 -0
- package/dist/weapp-tw-css-import-rewrite-loader.js +60 -393
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-KLoTb5Dr.js → webpack-CJAOcYEO.js} +8 -8
- package/dist/{webpack-CqnI4Ymw.mjs → webpack-DPdrcC2X.mjs} +7 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -5
- package/dist/auto-Cvy0zWpS.js +0 -238
- package/dist/auto-DEHRmEAx.mjs +0 -200
- package/dist/bundlers/vite/postcss-config.d.ts +0 -6
- package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +0 -17
- package/dist/postcss/config-directive.d.ts +0 -1
- package/dist/postcss/context.d.ts +0 -9
- package/dist/postcss/source-files.d.ts +0 -8
- package/dist/postcss/tailwind-version.d.ts +0 -3
- package/dist/postcss-C7BMYpEF.mjs +0 -169
- package/dist/postcss-CiYLsqZn.js +0 -192
- package/dist/postcss-CjWuDZwL.mjs +0 -275
- package/dist/postcss-R5pDVHUy.js +0 -284
- package/dist/watch-dependencies-zwx4EhBn.js +0 -5535
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { C as hasLocalCssImport, D as normalizeTailwindConfigDirectives, E as hasTailwindSourceDirectives, L as hasTailwindGeneratedCssMarkers, M as removeTailwindSourceDirectives, T as hasTailwindRootDirectives, Y as filterUnsupportedMiniProgramTailwindV4Candidates, _ as resolveTailwindV4EntriesFromCssCached,
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
3
|
-
import { _ as collectRuntimeClassSet, a as vitePluginName, b as refreshTailwindRuntimeState, g as toCustomAttributesEntities, n as getCompilerContext, p as replaceWxml, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise } from "./precheck-
|
|
1
|
+
import { C as hasLocalCssImport, D as normalizeTailwindConfigDirectives, E as hasTailwindSourceDirectives, L as hasTailwindGeneratedCssMarkers, M as removeTailwindSourceDirectives, T as hasTailwindRootDirectives, Y as filterUnsupportedMiniProgramTailwindV4Candidates, _ as resolveTailwindV4EntriesFromCssCached, h as discoverTailwindV4CssEntries, j as parseImportRequest, k as normalizeTailwindSourceForGenerator, l as getRuntimeClassSetSignature, m as resolveViteSourceScanEntries, ot as findTailwindConfig, p as createViteSourceScanMatcher, pt as omitUndefined, rt as createDebug, st as resolveTailwindcssOptions, tt as resolveTailwindV4CssSourceBase, ut as findNearestPackageRoot, v as resolveViteTailwindV4CssDependencies, w as hasTailwindApplyDirective } from "./v3-engine-CFkP6dWF.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-h2XRiJ9-.mjs";
|
|
3
|
+
import { _ as collectRuntimeClassSet, a as vitePluginName, b as refreshTailwindRuntimeState, g as toCustomAttributesEntities, n as getCompilerContext, p as replaceWxml, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise } from "./precheck-BpHxsWRd.mjs";
|
|
4
4
|
import { o as resolveUniUtsPlatform } from "./utils-DsaS975I.mjs";
|
|
5
|
-
import { a as normalizeCssEntries, c as hasConfiguredTailwindV4CssRoots, i as resolveUniAppXOptions, l as upsertTailwindV4CssSource, r as isUniAppXEnabled } from "./tailwindcss-
|
|
6
|
-
import { a as createTailwindV3DefaultExtractor, c as validateCandidatesByGenerator, g as createCssTokenSourceMap, h as createCssSourceTraceCacheSignature, i as isSourceCandidateRequest, l as extractMarkedUserLayerComponentsCss, m as annotateCssSourceTrace, o as createBundleRuntimeClassSetManager, r as createSourceCandidateCollector, s as generateCssByGenerator, t as createHmrTimingRecorder, u as mergeMarkedUserLayerComponentsCss, v as processCachedTask } from "./hmr-timing-
|
|
7
|
-
import { C as toAbsoluteOutputPath, _ as normalizePath, a as applyLinkedResults, b as stripRequestQuery, c as createBundlerGeneratedCssMarker, d as stripBundlerGeneratedCssMarkers, f as resolvePackageDir, g as isCSSRequest, h as formatPostcssSourceMap, i as createRuntimeAffectingSourceSignature, l as hasBundlerGeneratedCssMarker, m as cleanUrl, n as createBundleBuildState, o as createBundleModuleGraphOptions, p as resolvePluginDisabledState, r as updateBundleBuildState, s as pushConcurrentTaskFactories, t as buildBundleSnapshot, u as parseBundlerGeneratedCssMarkerBlocks, v as slash, x as normalizeOutputPathKey, y as isSourceStyleRequest } from "./bundle-state-
|
|
5
|
+
import { a as normalizeCssEntries, c as hasConfiguredTailwindV4CssRoots, i as resolveUniAppXOptions, l as upsertTailwindV4CssSource, r as isUniAppXEnabled } from "./tailwindcss-Bfy2egdX.mjs";
|
|
6
|
+
import { a as createTailwindV3DefaultExtractor, c as validateCandidatesByGenerator, g as createCssTokenSourceMap, h as createCssSourceTraceCacheSignature, i as isSourceCandidateRequest, l as extractMarkedUserLayerComponentsCss, m as annotateCssSourceTrace, o as createBundleRuntimeClassSetManager, r as createSourceCandidateCollector, s as generateCssByGenerator, t as createHmrTimingRecorder, u as mergeMarkedUserLayerComponentsCss, v as processCachedTask } from "./hmr-timing-Ct5w4hdM.mjs";
|
|
7
|
+
import { C as toAbsoluteOutputPath, _ as normalizePath, a as applyLinkedResults, b as stripRequestQuery, c as createBundlerGeneratedCssMarker, d as stripBundlerGeneratedCssMarkers, f as resolvePackageDir, g as isCSSRequest, h as formatPostcssSourceMap, i as createRuntimeAffectingSourceSignature, l as hasBundlerGeneratedCssMarker, m as cleanUrl, n as createBundleBuildState, o as createBundleModuleGraphOptions, p as resolvePluginDisabledState, r as updateBundleBuildState, s as pushConcurrentTaskFactories, t as buildBundleSnapshot, u as parseBundlerGeneratedCssMarkerBlocks, v as slash, x as normalizeOutputPathKey, y as isSourceStyleRequest } from "./bundle-state-CXzPknlT.mjs";
|
|
8
8
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
9
|
-
import postcss from "postcss";
|
|
9
|
+
import { containsCssAfterMinify, filterExistingCssRules, getPostcssPluginName, mergeCoveredCssRuleDeclarations, mergeMiniProgramPreflightRuleDeclarations, mergeMiniProgramThemeScopeRuleDeclarations, postcss, removeTailwindPostcssPlugins, resolveFilteredPostcssConfig } from "@weapp-tailwindcss/postcss";
|
|
10
10
|
import { splitCandidateTokens } from "tailwindcss-patch";
|
|
11
|
-
import process$1 from "node:process";
|
|
12
11
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
13
12
|
import path from "node:path";
|
|
13
|
+
import process$1 from "node:process";
|
|
14
14
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
15
15
|
import { readFile } from "node:fs/promises";
|
|
16
16
|
import { Buffer } from "node:buffer";
|
|
17
17
|
import postcssHtmlTransform from "@weapp-tailwindcss/postcss/html-transform";
|
|
18
18
|
import { parse } from "comment-json";
|
|
19
|
-
import selectorParser from "postcss-selector-parser";
|
|
20
|
-
import postcssrc from "postcss-load-config";
|
|
21
19
|
//#region src/uni-app-x/harmony.ts
|
|
22
20
|
function isUniAppXHarmonyOutDir(outDir) {
|
|
23
21
|
return typeof outDir === "string" && /(?:^|[/\\])\.?app-harmony(?:[/\\]|$)/.test(outDir);
|
|
@@ -476,7 +474,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
476
474
|
//#region src/uni-app-x/vite.ts
|
|
477
475
|
let transformUVuePromise;
|
|
478
476
|
function loadTransformUVue() {
|
|
479
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform-
|
|
477
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-r5evL6Hn.mjs").then((mod) => mod.transformUVue));
|
|
480
478
|
return transformUVuePromise;
|
|
481
479
|
}
|
|
482
480
|
const preprocessorLangs = new Set([
|
|
@@ -1874,363 +1872,6 @@ const mix = (del = delimiter) => {
|
|
|
1874
1872
|
const posix = /* @__PURE__ */ mix(":");
|
|
1875
1873
|
const win32 = /* @__PURE__ */ mix(";");
|
|
1876
1874
|
//#endregion
|
|
1877
|
-
//#region src/bundlers/vite/processed-css-assets/css-rules.ts
|
|
1878
|
-
const MINI_PROGRAM_PREFLIGHT_SELECTOR_KEY = "view,text,::after,::before";
|
|
1879
|
-
const MINI_PROGRAM_PREFLIGHT_SELECTOR_KEYS = new Set([
|
|
1880
|
-
"view",
|
|
1881
|
-
"text",
|
|
1882
|
-
"::after",
|
|
1883
|
-
"::before"
|
|
1884
|
-
]);
|
|
1885
|
-
const MINI_PROGRAM_THEME_SCOPE_SELECTOR_KEY = ":host,page,.tw-root,wx-root-portal-content";
|
|
1886
|
-
const MINI_PROGRAM_THEME_SCOPE_SELECTOR_KEYS = new Set([
|
|
1887
|
-
":host",
|
|
1888
|
-
"page",
|
|
1889
|
-
".tw-root",
|
|
1890
|
-
"wx-root-portal-content"
|
|
1891
|
-
]);
|
|
1892
|
-
function normalizeCssForContainment(css) {
|
|
1893
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/::(before|after)\b/g, ":$1").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~()])\s*/g, "$1").replace(/;\}/g, "}").trim();
|
|
1894
|
-
}
|
|
1895
|
-
function collectNormalizedCssNodes(css) {
|
|
1896
|
-
try {
|
|
1897
|
-
return (postcss.parse(css).nodes ?? []).filter((node) => node.type !== "comment").map((node) => normalizeCssForContainment(node.toString())).filter(Boolean);
|
|
1898
|
-
} catch {
|
|
1899
|
-
const normalizedCss = normalizeCssForContainment(css);
|
|
1900
|
-
return normalizedCss ? [normalizedCss] : [];
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
function normalizeCssRuleKeyPart(value) {
|
|
1904
|
-
return value.replace(/::(before|after)\b/g, ":$1").replace(/\s+/g, " ").replace(/\s*([>+~(),])\s*/g, "$1").trim();
|
|
1905
|
-
}
|
|
1906
|
-
function getRuleAtRuleChain(rule) {
|
|
1907
|
-
const chain = [];
|
|
1908
|
-
let parent = rule.parent;
|
|
1909
|
-
while (parent && parent.type !== "root") {
|
|
1910
|
-
if (parent.type === "atrule") chain.unshift(`@${parent.name} ${normalizeCssRuleKeyPart(parent.params)}`);
|
|
1911
|
-
parent = parent.parent;
|
|
1912
|
-
}
|
|
1913
|
-
return chain;
|
|
1914
|
-
}
|
|
1915
|
-
function getCssRuleStructuralKey(rule) {
|
|
1916
|
-
const selector = normalizeCssRuleKeyPart(rule.selector);
|
|
1917
|
-
if (selector.length === 0) return;
|
|
1918
|
-
return [...getRuleAtRuleChain(rule), selector].join("|");
|
|
1919
|
-
}
|
|
1920
|
-
function getCssRuleStructuralKeyWithSelectorKey(rule, selectorKey) {
|
|
1921
|
-
return [...getRuleAtRuleChain(rule), selectorKey].join("|");
|
|
1922
|
-
}
|
|
1923
|
-
function getCssRuleContentKey(rule) {
|
|
1924
|
-
const structuralKey = getCssRuleStructuralKey(rule);
|
|
1925
|
-
if (!structuralKey) return;
|
|
1926
|
-
return [structuralKey, normalizeCssForContainment(rule.toString())].join("|");
|
|
1927
|
-
}
|
|
1928
|
-
function collectCssRuleContentKeys(css) {
|
|
1929
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1930
|
-
try {
|
|
1931
|
-
postcss.parse(css).walkRules((rule) => {
|
|
1932
|
-
const key = getCssRuleContentKey(rule);
|
|
1933
|
-
if (key) keys.add(key);
|
|
1934
|
-
});
|
|
1935
|
-
} catch {}
|
|
1936
|
-
return keys;
|
|
1937
|
-
}
|
|
1938
|
-
function normalizeCssDeclarationKey(decl) {
|
|
1939
|
-
return [
|
|
1940
|
-
decl.prop.trim(),
|
|
1941
|
-
normalizeCssForContainment(decl.value),
|
|
1942
|
-
decl.important ? "!important" : ""
|
|
1943
|
-
].join(":");
|
|
1944
|
-
}
|
|
1945
|
-
function collectCssRuleDeclarationKeys(rule) {
|
|
1946
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1947
|
-
for (const node of rule.nodes ?? []) if (node.type === "decl") keys.add(normalizeCssDeclarationKey(node));
|
|
1948
|
-
return keys;
|
|
1949
|
-
}
|
|
1950
|
-
function collectCssRuleDeclarationProps(rule) {
|
|
1951
|
-
const props = /* @__PURE__ */ new Set();
|
|
1952
|
-
for (const node of rule.nodes ?? []) if (node.type === "decl") props.add(node.prop.trim());
|
|
1953
|
-
return props;
|
|
1954
|
-
}
|
|
1955
|
-
function collectCssRuleDeclarations(rule) {
|
|
1956
|
-
return (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
1957
|
-
}
|
|
1958
|
-
function collectCssRuleDeclarationKeyMap(css) {
|
|
1959
|
-
const map = /* @__PURE__ */ new Map();
|
|
1960
|
-
try {
|
|
1961
|
-
postcss.parse(css).walkRules((rule) => {
|
|
1962
|
-
const key = getCssRuleStructuralKey(rule);
|
|
1963
|
-
if (!key) return;
|
|
1964
|
-
const declarations = collectCssRuleDeclarationKeys(rule);
|
|
1965
|
-
if (declarations.size === 0) return;
|
|
1966
|
-
let existing = map.get(key);
|
|
1967
|
-
if (!existing) {
|
|
1968
|
-
existing = /* @__PURE__ */ new Set();
|
|
1969
|
-
map.set(key, existing);
|
|
1970
|
-
}
|
|
1971
|
-
for (const declaration of declarations) existing.add(declaration);
|
|
1972
|
-
});
|
|
1973
|
-
} catch {}
|
|
1974
|
-
return map;
|
|
1975
|
-
}
|
|
1976
|
-
function collectCssRuleDeclarationRecords(root, resolveRuleKey = getCssRuleStructuralKey) {
|
|
1977
|
-
const map = /* @__PURE__ */ new Map();
|
|
1978
|
-
root.walkRules((rule) => {
|
|
1979
|
-
const key = resolveRuleKey(rule);
|
|
1980
|
-
if (!key) return;
|
|
1981
|
-
const keys = collectCssRuleDeclarationKeys(rule);
|
|
1982
|
-
if (keys.size === 0) return;
|
|
1983
|
-
const records = map.get(key) ?? [];
|
|
1984
|
-
records.push({
|
|
1985
|
-
rule,
|
|
1986
|
-
keys,
|
|
1987
|
-
props: collectCssRuleDeclarationProps(rule)
|
|
1988
|
-
});
|
|
1989
|
-
map.set(key, records);
|
|
1990
|
-
});
|
|
1991
|
-
return map;
|
|
1992
|
-
}
|
|
1993
|
-
function normalizeSimpleMiniProgramSelectorNode(node) {
|
|
1994
|
-
if (node.type === "tag") {
|
|
1995
|
-
const value = node.value.toLowerCase();
|
|
1996
|
-
if (value === "view" || value === "text" || value === "page" || value === "wx-root-portal-content") return value;
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
if (node.type === "class") return node.value.toLowerCase() === "tw-root" ? ".tw-root" : void 0;
|
|
2000
|
-
if (node.type === "pseudo") {
|
|
2001
|
-
if (node.nodes && node.nodes.length > 0) return;
|
|
2002
|
-
const value = node.value.toLowerCase();
|
|
2003
|
-
if (value === ":before" || value === "::before") return "::before";
|
|
2004
|
-
if (value === ":after" || value === "::after") return "::after";
|
|
2005
|
-
if (value === ":host") return ":host";
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
function normalizeSimpleMiniProgramSelector(selector) {
|
|
2009
|
-
if (selector.nodes.length !== 1) return;
|
|
2010
|
-
return normalizeSimpleMiniProgramSelectorNode(selector.nodes[0]);
|
|
2011
|
-
}
|
|
2012
|
-
function collectMiniProgramSelectorSet(selector) {
|
|
2013
|
-
try {
|
|
2014
|
-
const selectorSet = /* @__PURE__ */ new Set();
|
|
2015
|
-
const ast = selectorParser().astSync(selector);
|
|
2016
|
-
for (const child of ast.nodes) {
|
|
2017
|
-
const key = normalizeSimpleMiniProgramSelector(child);
|
|
2018
|
-
if (!key || selectorSet.has(key)) return;
|
|
2019
|
-
selectorSet.add(key);
|
|
2020
|
-
}
|
|
2021
|
-
return selectorSet;
|
|
2022
|
-
} catch {
|
|
2023
|
-
return;
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
function isSameSelectorSet(actual, expected) {
|
|
2027
|
-
return actual?.size === expected.size && [...expected].every((key) => actual.has(key));
|
|
2028
|
-
}
|
|
2029
|
-
function getMiniProgramPreflightRuleStructuralKey(rule) {
|
|
2030
|
-
if (!isSameSelectorSet(collectMiniProgramSelectorSet(rule.selector), MINI_PROGRAM_PREFLIGHT_SELECTOR_KEYS)) return;
|
|
2031
|
-
return getCssRuleStructuralKeyWithSelectorKey(rule, MINI_PROGRAM_PREFLIGHT_SELECTOR_KEY);
|
|
2032
|
-
}
|
|
2033
|
-
function getMiniProgramThemeScopeRuleStructuralKey(rule) {
|
|
2034
|
-
if (!isSameSelectorSet(collectMiniProgramSelectorSet(rule.selector), MINI_PROGRAM_THEME_SCOPE_SELECTOR_KEYS)) return;
|
|
2035
|
-
return getCssRuleStructuralKeyWithSelectorKey(rule, MINI_PROGRAM_THEME_SCOPE_SELECTOR_KEY);
|
|
2036
|
-
}
|
|
2037
|
-
function mergeMiniProgramPreflightRuleDeclarations(baseCss, css) {
|
|
2038
|
-
try {
|
|
2039
|
-
const baseRoot = postcss.parse(baseCss);
|
|
2040
|
-
const root = postcss.parse(css);
|
|
2041
|
-
const baseRuleRecords = collectCssRuleDeclarationRecords(baseRoot, getMiniProgramPreflightRuleStructuralKey);
|
|
2042
|
-
let changedBase = false;
|
|
2043
|
-
let changedCss = false;
|
|
2044
|
-
root.walkRules((rule) => {
|
|
2045
|
-
const key = getMiniProgramPreflightRuleStructuralKey(rule);
|
|
2046
|
-
if (!key) return;
|
|
2047
|
-
const records = baseRuleRecords.get(key);
|
|
2048
|
-
const targetRecord = records?.[0];
|
|
2049
|
-
if (!targetRecord) return;
|
|
2050
|
-
const existingProps = new Set(records.flatMap((record) => [...record.props]));
|
|
2051
|
-
for (const decl of collectCssRuleDeclarations(rule)) {
|
|
2052
|
-
const prop = decl.prop.trim();
|
|
2053
|
-
if (existingProps.has(prop)) continue;
|
|
2054
|
-
targetRecord.rule.append(decl.clone());
|
|
2055
|
-
targetRecord.keys.add(normalizeCssDeclarationKey(decl));
|
|
2056
|
-
targetRecord.props.add(prop);
|
|
2057
|
-
existingProps.add(prop);
|
|
2058
|
-
changedBase = true;
|
|
2059
|
-
}
|
|
2060
|
-
rule.remove();
|
|
2061
|
-
changedCss = true;
|
|
2062
|
-
});
|
|
2063
|
-
if (!changedBase && !changedCss) return {
|
|
2064
|
-
baseCss,
|
|
2065
|
-
css,
|
|
2066
|
-
changed: false
|
|
2067
|
-
};
|
|
2068
|
-
removeEmptyAtRules(root);
|
|
2069
|
-
return {
|
|
2070
|
-
baseCss: changedBase ? baseRoot.toString() : baseCss,
|
|
2071
|
-
css: changedCss ? root.toString().trim() : css,
|
|
2072
|
-
changed: true
|
|
2073
|
-
};
|
|
2074
|
-
} catch {
|
|
2075
|
-
return {
|
|
2076
|
-
baseCss,
|
|
2077
|
-
css,
|
|
2078
|
-
changed: false
|
|
2079
|
-
};
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
function mergeMiniProgramThemeScopeRuleDeclarations(baseCss, css) {
|
|
2083
|
-
try {
|
|
2084
|
-
const baseRoot = postcss.parse(baseCss);
|
|
2085
|
-
const root = postcss.parse(css);
|
|
2086
|
-
const baseRuleRecords = collectCssRuleDeclarationRecords(baseRoot, getMiniProgramThemeScopeRuleStructuralKey);
|
|
2087
|
-
let changedBase = false;
|
|
2088
|
-
let changedCss = false;
|
|
2089
|
-
root.walkRules((rule) => {
|
|
2090
|
-
const key = getMiniProgramThemeScopeRuleStructuralKey(rule);
|
|
2091
|
-
if (!key) return;
|
|
2092
|
-
const records = baseRuleRecords.get(key);
|
|
2093
|
-
const targetRecord = records?.[0];
|
|
2094
|
-
if (!targetRecord) return;
|
|
2095
|
-
const incomingDeclarations = collectCssRuleDeclarations(rule);
|
|
2096
|
-
if (incomingDeclarations.length === 0) return;
|
|
2097
|
-
const existingKeys = new Set(records.flatMap((record) => [...record.keys]));
|
|
2098
|
-
const existingProps = new Set(records.flatMap((record) => [...record.props]));
|
|
2099
|
-
if (incomingDeclarations.some((decl) => {
|
|
2100
|
-
const prop = decl.prop.trim();
|
|
2101
|
-
return existingProps.has(prop) && !existingKeys.has(normalizeCssDeclarationKey(decl));
|
|
2102
|
-
})) return;
|
|
2103
|
-
for (const decl of incomingDeclarations) {
|
|
2104
|
-
const declarationKey = normalizeCssDeclarationKey(decl);
|
|
2105
|
-
if (existingKeys.has(declarationKey)) continue;
|
|
2106
|
-
targetRecord.rule.append(decl.clone());
|
|
2107
|
-
targetRecord.keys.add(declarationKey);
|
|
2108
|
-
targetRecord.props.add(decl.prop.trim());
|
|
2109
|
-
existingKeys.add(declarationKey);
|
|
2110
|
-
existingProps.add(decl.prop.trim());
|
|
2111
|
-
changedBase = true;
|
|
2112
|
-
}
|
|
2113
|
-
rule.remove();
|
|
2114
|
-
changedCss = true;
|
|
2115
|
-
});
|
|
2116
|
-
if (!changedBase && !changedCss) return {
|
|
2117
|
-
baseCss,
|
|
2118
|
-
css,
|
|
2119
|
-
changed: false
|
|
2120
|
-
};
|
|
2121
|
-
removeEmptyAtRules(root);
|
|
2122
|
-
return {
|
|
2123
|
-
baseCss: changedBase ? baseRoot.toString() : baseCss,
|
|
2124
|
-
css: changedCss ? root.toString().trim() : css,
|
|
2125
|
-
changed: true
|
|
2126
|
-
};
|
|
2127
|
-
} catch {
|
|
2128
|
-
return {
|
|
2129
|
-
baseCss,
|
|
2130
|
-
css,
|
|
2131
|
-
changed: false
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
function isCssRuleCoveredByDeclarations(rule, baseRuleDeclarationKeys) {
|
|
2136
|
-
const key = getCssRuleStructuralKey(rule);
|
|
2137
|
-
if (!key) return false;
|
|
2138
|
-
const baseDeclarations = baseRuleDeclarationKeys.get(key);
|
|
2139
|
-
if (!baseDeclarations) return false;
|
|
2140
|
-
const declarations = collectCssRuleDeclarationKeys(rule);
|
|
2141
|
-
return declarations.size > 0 && [...declarations].every((declaration) => baseDeclarations.has(declaration));
|
|
2142
|
-
}
|
|
2143
|
-
function mergeCoveredCssRuleDeclarations(baseCss, css) {
|
|
2144
|
-
try {
|
|
2145
|
-
const baseRoot = postcss.parse(baseCss);
|
|
2146
|
-
const root = postcss.parse(css);
|
|
2147
|
-
const baseRuleRecords = collectCssRuleDeclarationRecords(baseRoot);
|
|
2148
|
-
let changedBase = false;
|
|
2149
|
-
let changedCss = false;
|
|
2150
|
-
root.walkRules((rule) => {
|
|
2151
|
-
const key = getCssRuleStructuralKey(rule);
|
|
2152
|
-
const records = key ? baseRuleRecords.get(key) : void 0;
|
|
2153
|
-
if (!records || records.length === 0) return;
|
|
2154
|
-
const incomingDeclarations = collectCssRuleDeclarations(rule);
|
|
2155
|
-
if (incomingDeclarations.length === 0) return;
|
|
2156
|
-
const baseKeys = new Set(records.flatMap((record) => [...record.keys]));
|
|
2157
|
-
if (incomingDeclarations.filter((decl) => baseKeys.has(normalizeCssDeclarationKey(decl))).length === 0) return;
|
|
2158
|
-
const missingDeclarations = incomingDeclarations.filter((decl) => !baseKeys.has(normalizeCssDeclarationKey(decl)));
|
|
2159
|
-
if (missingDeclarations.length === 0) {
|
|
2160
|
-
rule.remove();
|
|
2161
|
-
changedCss = true;
|
|
2162
|
-
return;
|
|
2163
|
-
}
|
|
2164
|
-
const baseProps = new Set(records.flatMap((record) => [...record.props]));
|
|
2165
|
-
if (missingDeclarations.filter((decl) => baseProps.has(decl.prop.trim())).length > 0) return;
|
|
2166
|
-
const targetRecord = records[0];
|
|
2167
|
-
if (!targetRecord) return;
|
|
2168
|
-
for (const decl of missingDeclarations) {
|
|
2169
|
-
targetRecord.rule.append(decl.clone());
|
|
2170
|
-
targetRecord.keys.add(normalizeCssDeclarationKey(decl));
|
|
2171
|
-
targetRecord.props.add(decl.prop.trim());
|
|
2172
|
-
}
|
|
2173
|
-
rule.remove();
|
|
2174
|
-
changedBase = true;
|
|
2175
|
-
changedCss = true;
|
|
2176
|
-
});
|
|
2177
|
-
if (!changedBase && !changedCss) return {
|
|
2178
|
-
baseCss,
|
|
2179
|
-
css,
|
|
2180
|
-
changed: false
|
|
2181
|
-
};
|
|
2182
|
-
removeEmptyAtRules(root);
|
|
2183
|
-
return {
|
|
2184
|
-
baseCss: changedBase ? baseRoot.toString() : baseCss,
|
|
2185
|
-
css: changedCss ? root.toString().trim() : css,
|
|
2186
|
-
changed: true
|
|
2187
|
-
};
|
|
2188
|
-
} catch {
|
|
2189
|
-
return {
|
|
2190
|
-
baseCss,
|
|
2191
|
-
css,
|
|
2192
|
-
changed: false
|
|
2193
|
-
};
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
function removeEmptyAtRules(root) {
|
|
2197
|
-
root.walkAtRules((atRule) => {
|
|
2198
|
-
if (atRule.nodes && atRule.nodes.every((node) => node.type === "comment")) atRule.remove();
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
function filterExistingCssRules(baseCss, css) {
|
|
2202
|
-
const baseRuleKeys = collectCssRuleContentKeys(baseCss);
|
|
2203
|
-
if (baseRuleKeys.size === 0) return css;
|
|
2204
|
-
try {
|
|
2205
|
-
const root = postcss.parse(css);
|
|
2206
|
-
const baseRuleDeclarationKeys = collectCssRuleDeclarationKeyMap(baseCss);
|
|
2207
|
-
let changed = false;
|
|
2208
|
-
root.walkRules((rule) => {
|
|
2209
|
-
const key = getCssRuleContentKey(rule);
|
|
2210
|
-
if (key && baseRuleKeys.has(key) || isCssRuleCoveredByDeclarations(rule, baseRuleDeclarationKeys)) {
|
|
2211
|
-
rule.remove();
|
|
2212
|
-
changed = true;
|
|
2213
|
-
}
|
|
2214
|
-
});
|
|
2215
|
-
if (!changed) return css;
|
|
2216
|
-
removeEmptyAtRules(root);
|
|
2217
|
-
return root.toString().trim();
|
|
2218
|
-
} catch {
|
|
2219
|
-
return css;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
function containsCssAfterMinify(baseCss, css) {
|
|
2223
|
-
if (baseCss.includes(css)) return true;
|
|
2224
|
-
const normalizedBaseCss = normalizeCssForContainment(baseCss);
|
|
2225
|
-
const normalizedCss = normalizeCssForContainment(css);
|
|
2226
|
-
if (normalizedCss.length > 0 && normalizedBaseCss.includes(normalizedCss)) return true;
|
|
2227
|
-
const normalizedNodes = collectNormalizedCssNodes(css);
|
|
2228
|
-
if (normalizedNodes.length > 0 && normalizedNodes.every((node) => normalizedBaseCss.includes(node))) return true;
|
|
2229
|
-
const baseRuleKeys = collectCssRuleContentKeys(baseCss);
|
|
2230
|
-
const ruleKeys = collectCssRuleContentKeys(css);
|
|
2231
|
-
return ruleKeys.size > 0 && [...ruleKeys].every((key) => baseRuleKeys.has(key));
|
|
2232
|
-
}
|
|
2233
|
-
//#endregion
|
|
2234
1875
|
//#region src/bundlers/vite/processed-css-assets.ts
|
|
2235
1876
|
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
2236
1877
|
function isCssOutputFile(file) {
|
|
@@ -2534,6 +2175,16 @@ function createGenerateBundleHook(context) {
|
|
|
2534
2175
|
recordTimingDetail(`tasks.${name}`, start);
|
|
2535
2176
|
}
|
|
2536
2177
|
};
|
|
2178
|
+
const emitOrReplayCssAsset = (fileName, source) => {
|
|
2179
|
+
const replayAsset = createReplayCssAsset(fileName, source);
|
|
2180
|
+
if (typeof this.emitFile === "function") this.emitFile({
|
|
2181
|
+
type: "asset",
|
|
2182
|
+
fileName,
|
|
2183
|
+
source
|
|
2184
|
+
});
|
|
2185
|
+
else bundle[fileName] = replayAsset;
|
|
2186
|
+
return replayAsset;
|
|
2187
|
+
};
|
|
2537
2188
|
const metrics = createEmptyMetrics();
|
|
2538
2189
|
const forceRuntimeRefreshByEnv = process$1.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
2539
2190
|
const disableDirtyOptimization = process$1.env["WEAPP_TW_VITE_DISABLE_DIRTY"] === "1";
|
|
@@ -2726,12 +2377,7 @@ function createGenerateBundleHook(context) {
|
|
|
2726
2377
|
const applyCssResult = (source) => {
|
|
2727
2378
|
if (outputFile !== file) {
|
|
2728
2379
|
delete bundle[file];
|
|
2729
|
-
|
|
2730
|
-
type: "asset",
|
|
2731
|
-
fileName: outputFile,
|
|
2732
|
-
source
|
|
2733
|
-
});
|
|
2734
|
-
else bundle[outputFile] = createReplayCssAsset(outputFile, source);
|
|
2380
|
+
emitOrReplayCssAsset(outputFile, source);
|
|
2735
2381
|
originalSource.fileName = outputFile;
|
|
2736
2382
|
}
|
|
2737
2383
|
originalSource.source = source;
|
|
@@ -3060,13 +2706,7 @@ function createGenerateBundleHook(context) {
|
|
|
3060
2706
|
});
|
|
3061
2707
|
debug("css replay generated result: %s bytes=%d", outputFile, css.length);
|
|
3062
2708
|
}
|
|
3063
|
-
const replayAsset =
|
|
3064
|
-
if (typeof this.emitFile === "function") this.emitFile({
|
|
3065
|
-
type: "asset",
|
|
3066
|
-
fileName: outputFile,
|
|
3067
|
-
source: css
|
|
3068
|
-
});
|
|
3069
|
-
else bundle[outputFile] = replayAsset;
|
|
2709
|
+
const replayAsset = emitOrReplayCssAsset(outputFile, css);
|
|
3070
2710
|
markCssAssetProcessed?.(replayAsset, outputFile);
|
|
3071
2711
|
metrics.css.elapsed += measureElapsed(start);
|
|
3072
2712
|
metrics.css.transformed++;
|
|
@@ -3347,30 +2987,6 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
3347
2987
|
}
|
|
3348
2988
|
//#endregion
|
|
3349
2989
|
//#region src/bundlers/vite/official-tailwind-plugins.ts
|
|
3350
|
-
const tailwindPostcssPluginNames = new Set(["tailwindcss", "@tailwindcss/postcss"]);
|
|
3351
|
-
function getPostcssPluginName(plugin) {
|
|
3352
|
-
if (!plugin) return;
|
|
3353
|
-
if (typeof plugin === "function" && "postcss" in plugin) try {
|
|
3354
|
-
return getPostcssPluginName(plugin());
|
|
3355
|
-
} catch {
|
|
3356
|
-
return;
|
|
3357
|
-
}
|
|
3358
|
-
if (typeof plugin !== "object" || !("postcssPlugin" in plugin)) return;
|
|
3359
|
-
const { postcssPlugin } = plugin;
|
|
3360
|
-
return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
|
|
3361
|
-
}
|
|
3362
|
-
function isTailwindPostcssPlugin(plugin) {
|
|
3363
|
-
const name = getPostcssPluginName(plugin);
|
|
3364
|
-
return typeof name === "string" && tailwindPostcssPluginNames.has(name);
|
|
3365
|
-
}
|
|
3366
|
-
function removeTailwindPostcssPlugins(plugins) {
|
|
3367
|
-
let removed = 0;
|
|
3368
|
-
for (let i = plugins.length - 1; i >= 0; i--) if (isTailwindPostcssPlugin(plugins[i])) {
|
|
3369
|
-
plugins.splice(i, 1);
|
|
3370
|
-
removed++;
|
|
3371
|
-
}
|
|
3372
|
-
return removed;
|
|
3373
|
-
}
|
|
3374
2990
|
function isTailwindVitePlugin(plugin) {
|
|
3375
2991
|
if (!plugin || typeof plugin !== "object" || !("name" in plugin)) return false;
|
|
3376
2992
|
const { name } = plugin;
|
|
@@ -3413,24 +3029,6 @@ function disableAndRemoveTailwindVitePlugins(plugins) {
|
|
|
3413
3029
|
return removed;
|
|
3414
3030
|
}
|
|
3415
3031
|
//#endregion
|
|
3416
|
-
//#region src/bundlers/vite/postcss-config.ts
|
|
3417
|
-
async function resolveFilteredPostcssConfig(root) {
|
|
3418
|
-
try {
|
|
3419
|
-
const loaded = await postcssrc({}, root);
|
|
3420
|
-
const plugins = Array.isArray(loaded.plugins) ? [...loaded.plugins] : [];
|
|
3421
|
-
const removed = removeTailwindPostcssPlugins(plugins);
|
|
3422
|
-
if (removed === 0) return;
|
|
3423
|
-
return {
|
|
3424
|
-
options: loaded.options,
|
|
3425
|
-
plugins,
|
|
3426
|
-
removed
|
|
3427
|
-
};
|
|
3428
|
-
} catch (error) {
|
|
3429
|
-
if ((error instanceof Error ? error.message : String(error)).includes("No PostCSS Config found")) return;
|
|
3430
|
-
throw error;
|
|
3431
|
-
}
|
|
3432
|
-
}
|
|
3433
|
-
//#endregion
|
|
3434
3032
|
//#region src/bundlers/vite/resolve-app-type.ts
|
|
3435
3033
|
const PACKAGE_JSON_FILE$1 = "package.json";
|
|
3436
3034
|
const MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
|