weapp-tailwindcss 5.0.7 → 5.0.10

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.
Files changed (67) hide show
  1. package/dist/auto-CTp6wE5a.js +33 -0
  2. package/dist/auto-Cl8_hsG6.mjs +22 -0
  3. package/dist/{bundle-state-BzwPS-UI.js → bundle-state-BwtEqxvU.js} +3 -3
  4. package/dist/{bundle-state-ChcOKb9w.mjs → bundle-state-CXzPknlT.mjs} +2 -2
  5. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +0 -2
  6. package/dist/cli.js +3 -159
  7. package/dist/cli.mjs +3 -159
  8. package/dist/core.js +1 -1
  9. package/dist/core.mjs +1 -1
  10. package/dist/css-macro/auto.d.ts +1 -7
  11. package/dist/css-macro/postcss.d.ts +1 -6
  12. package/dist/css-macro/postcss.js +15 -3
  13. package/dist/css-macro/postcss.mjs +2 -2
  14. package/dist/css-macro.js +19 -5
  15. package/dist/css-macro.mjs +16 -2
  16. package/dist/{generator-6yF8wjxR.js → generator-ChgOWNOj.js} +1 -1
  17. package/dist/{generator-BON6M1bL.mjs → generator-h2XRiJ9-.mjs} +1 -1
  18. package/dist/generator.js +2 -2
  19. package/dist/generator.mjs +2 -2
  20. package/dist/{gulp-oE-Byqk6.mjs → gulp-Be88jhoY.mjs} +5 -5
  21. package/dist/{gulp-_7p1Z2vc.js → gulp-CHtZF-oT.js} +6 -6
  22. package/dist/gulp.js +1 -1
  23. package/dist/gulp.mjs +1 -1
  24. package/dist/{hmr-timing-BKQNRxHr.js → hmr-timing-BkivBZvN.js} +41 -43
  25. package/dist/{hmr-timing-BVTGf5ch.mjs → hmr-timing-Ct5w4hdM.mjs} +6 -7
  26. package/dist/index.js +6 -6
  27. package/dist/index.mjs +5 -5
  28. package/dist/postcss.d.ts +2 -13
  29. package/dist/postcss.js +14 -3
  30. package/dist/postcss.mjs +10 -1
  31. package/dist/{precheck-CZjr87m_.mjs → precheck-BpHxsWRd.mjs} +4 -4
  32. package/dist/{precheck-fhIkzCSU.js → precheck-CY9oaH49.js} +5 -5
  33. package/dist/presets.js +4 -4
  34. package/dist/presets.mjs +3 -3
  35. package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -1
  36. package/dist/{tailwindcss-bbQUg25J.mjs → tailwindcss-Bfy2egdX.mjs} +2 -2
  37. package/dist/{tailwindcss-vswd1gc3.js → tailwindcss-DbbAKAZP.js} +3 -3
  38. package/dist/{transform-CReJxxh_.js → transform-Cd634UZV.js} +1 -1
  39. package/dist/{transform-DEsFlG9k.mjs → transform-r5evL6Hn.mjs} +1 -1
  40. package/dist/types/index.d.ts +1 -2
  41. package/dist/{v3-engine-CdIwmHuc.mjs → v3-engine-CFkP6dWF.mjs} +55 -19
  42. package/dist/{v3-engine-CEMXFegG.js → v3-engine-D0yA9ZkF.js} +86 -87
  43. package/dist/{vite-C7BGAlCE.mjs → vite-BM_iIFmS.mjs} +10 -411
  44. package/dist/{vite-0jFbh9hx.js → vite-Bh-BNp5g.js} +27 -431
  45. package/dist/vite.js +1 -1
  46. package/dist/vite.mjs +1 -1
  47. package/dist/watch-dependencies-bpG6kmAf.js +80 -0
  48. package/dist/weapp-tw-css-import-rewrite-loader.js +111 -407
  49. package/dist/weapp-tw-runtime-classset-loader.js +2 -2
  50. package/dist/{webpack-aEuDoYfQ.js → webpack-CJAOcYEO.js} +16 -9
  51. package/dist/{webpack-Dx6_eg5k.mjs → webpack-DPdrcC2X.mjs} +15 -8
  52. package/dist/webpack.js +1 -1
  53. package/dist/webpack.mjs +1 -1
  54. package/package.json +5 -7
  55. package/dist/auto-Cvy0zWpS.js +0 -238
  56. package/dist/auto-DEHRmEAx.mjs +0 -200
  57. package/dist/bundlers/vite/postcss-config.d.ts +0 -6
  58. package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +0 -17
  59. package/dist/postcss/config-directive.d.ts +0 -1
  60. package/dist/postcss/context.d.ts +0 -9
  61. package/dist/postcss/source-files.d.ts +0 -8
  62. package/dist/postcss/tailwind-version.d.ts +0 -3
  63. package/dist/postcss-BTIunhWl.js +0 -284
  64. package/dist/postcss-BtmrrZ31.mjs +0 -275
  65. package/dist/postcss-C7BMYpEF.mjs +0 -169
  66. package/dist/postcss-CiYLsqZn.js +0 -192
  67. 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, ft as findTailwindConfig, gt as findNearestPackageRoot, h as discoverTailwindV4CssEntries, j as parseImportRequest, k as normalizeTailwindSourceForGenerator, l as getRuntimeClassSetSignature, lt as createDebug, m as resolveViteSourceScanEntries, ot as resolveTailwindV4CssSourceBase, p as createViteSourceScanMatcher, pt as resolveTailwindcssOptions, v as resolveViteTailwindV4CssDependencies, w as hasTailwindApplyDirective, yt as omitUndefined } from "./v3-engine-CdIwmHuc.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-BON6M1bL.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-CZjr87m_.mjs";
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-bbQUg25J.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-BVTGf5ch.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-ChcOKb9w.mjs";
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-DEsFlG9k.mjs").then((mod) => mod.transformUVue));
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.length === 0) 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) {
@@ -3061,12 +2702,12 @@ function createGenerateBundleHook(context) {
3061
2702
  debug("css replay generated result: %s bytes=%d", outputFile, css.length);
3062
2703
  }
3063
2704
  const replayAsset = createReplayCssAsset(outputFile, css);
2705
+ bundle[outputFile] = replayAsset;
3064
2706
  if (typeof this.emitFile === "function") this.emitFile({
3065
2707
  type: "asset",
3066
2708
  fileName: outputFile,
3067
2709
  source: css
3068
2710
  });
3069
- else bundle[outputFile] = replayAsset;
3070
2711
  markCssAssetProcessed?.(replayAsset, outputFile);
3071
2712
  metrics.css.elapsed += measureElapsed(start);
3072
2713
  metrics.css.transformed++;
@@ -3347,30 +2988,6 @@ function createViteCssFinalizerOutputPlugin(context) {
3347
2988
  }
3348
2989
  //#endregion
3349
2990
  //#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
2991
  function isTailwindVitePlugin(plugin) {
3375
2992
  if (!plugin || typeof plugin !== "object" || !("name" in plugin)) return false;
3376
2993
  const { name } = plugin;
@@ -3413,24 +3030,6 @@ function disableAndRemoveTailwindVitePlugins(plugins) {
3413
3030
  return removed;
3414
3031
  }
3415
3032
  //#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
3033
  //#region src/bundlers/vite/resolve-app-type.ts
3435
3034
  const PACKAGE_JSON_FILE$1 = "package.json";
3436
3035
  const MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;