weapp-tailwindcss 5.5.1 → 5.5.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/bundlers/shared/css-imports.d.ts +1 -0
- package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
- package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
- package/dist/compiler/runtime-snapshot.d.ts +4 -1
- package/dist/{compiler-B0YSc0DY.js → compiler-C9X5Afn4.js} +3 -3
- package/dist/{compiler-D2ZJc3uA.cjs → compiler-DMPaUcH6.cjs} +6 -6
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DXplvodk.cjs} +29 -0
- package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
- package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
- package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
- package/dist/defaults.cjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/{generator-DsrQ9txU.cjs → generator-BoZIiZD5.cjs} +130 -77
- package/dist/{generator-DyXTBPmE.js → generator-C2aWns8n.js} +119 -78
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DXeQfvVC.js → gulp-COAAztkm.js} +4 -4
- package/dist/{gulp-C9ENAx3f.cjs → gulp-D50z06nw.cjs} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-CTk1uZr9.js} +245 -183
- package/dist/{hmr-timing-Cz4IesEM.cjs → hmr-timing-DK0MJKpl.cjs} +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CSGnR5gh.cjs → pipeline-helpers-BzjYXNTa.cjs} +4 -4
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +6 -3
- package/dist/rspack.js +6 -3
- package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-C21A7fis.js} +3 -3
- package/dist/{scoped-generator-TVjEaOeP.cjs → scoped-generator-CTkuf9Ae.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-4mZDDaKT.cjs} +2 -2
- package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-BB5DfjO2.js} +2 -2
- package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
- package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-Bji4u8In.cjs} +1 -1
- package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-c4PkOe1F.js} +1 -1
- package/dist/{transform-DUPOPZ54.cjs → transform-Cy0ddBWf.cjs} +14 -14
- package/dist/{transform-CfOzh007.js → transform-DmLonqPE.js} +14 -14
- package/dist/uni-app-x/border-preflight.d.ts +18 -0
- package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
- package/dist/uni-app-x/style-reference-path.d.ts +1 -0
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
- package/dist/uni-app-x/vite/style-request.d.ts +5 -0
- package/dist/uni-app-x/vite/style-source.d.ts +14 -4
- package/dist/uni-app-x/vite/web-sfc-hmr.d.ts +14 -0
- package/dist/{v4-generation-core-CRNUU_Rr.cjs → v4-generation-core-DQeiq-g1.cjs} +243 -181
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-BXe-axax.js → vite-CaUxtQx5.js} +340 -88
- package/dist/{vite-D_mAIfTU.cjs → vite-OG66oLpb.cjs} +356 -85
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
- package/dist/weapp-tw-css-generation-loader.cjs +3 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
- package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
- package/dist/{web-Cv7ualrU.js → web-Bd-9OHFE.js} +7 -6
- package/dist/{web-B2Ea9K4B.cjs → web-CZKIefdl.cjs} +9 -8
- package/dist/{webpack-7Um2GFtx.js → webpack-Cyvq3H7Z.js} +38 -23
- package/dist/{webpack-Ce04-btG.cjs → webpack-DJGgU27Y.cjs} +37 -23
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +7 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-BoZIiZD5.cjs");
|
|
3
3
|
require("./auto-DtU6f3X6.cjs");
|
|
4
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
5
|
-
const require_compiler = require("./compiler-
|
|
4
|
+
const require_tailwindcss = require("./tailwindcss-Bji4u8In.cjs");
|
|
5
|
+
const require_compiler = require("./compiler-DMPaUcH6.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
@@ -219,6 +219,7 @@ const TEMPLATE_SOURCE_CANDIDATE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
219
219
|
"ksml",
|
|
220
220
|
"ttml",
|
|
221
221
|
"qml",
|
|
222
|
+
"qxml",
|
|
222
223
|
"tyml",
|
|
223
224
|
"xhsml",
|
|
224
225
|
"swan",
|
|
@@ -464,11 +465,11 @@ function createSourceCandidateStore(options = {}) {
|
|
|
464
465
|
cssSourceById.set(normalizedId, source);
|
|
465
466
|
replaceCssLayer(normalizedId, await resolveCandidates(normalizedId, source, "css"));
|
|
466
467
|
}
|
|
467
|
-
async function syncModuleSource(id, source) {
|
|
468
|
+
async function syncModuleSource(id, source, sourceExtension) {
|
|
468
469
|
const normalizedId = cleanUrl(id);
|
|
469
470
|
if (moduleSourceById.get(normalizedId) !== source) revision++;
|
|
470
471
|
moduleSourceById.set(normalizedId, source);
|
|
471
|
-
const candidates = await resolveCandidates(normalizedId, source, resolveSourceCandidateExtension(normalizedId));
|
|
472
|
+
const candidates = await resolveCandidates(normalizedId, source, sourceExtension ?? resolveSourceCandidateExtension(normalizedId));
|
|
472
473
|
replaceModuleLayer(normalizedId, candidates);
|
|
473
474
|
return new Set(candidates);
|
|
474
475
|
}
|
|
@@ -1688,6 +1689,209 @@ async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, opti
|
|
|
1688
1689
|
});
|
|
1689
1690
|
}
|
|
1690
1691
|
//#endregion
|
|
1692
|
+
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
1693
|
+
const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
|
|
1694
|
+
const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
|
|
1695
|
+
function appendCss(base, extra) {
|
|
1696
|
+
if (!base) return extra;
|
|
1697
|
+
if (!extra) return base;
|
|
1698
|
+
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
1699
|
+
return `${base}\n${extra}`;
|
|
1700
|
+
}
|
|
1701
|
+
function removeFirstCssOccurrence(css, chunk) {
|
|
1702
|
+
const trimmed = chunk.trim();
|
|
1703
|
+
if (!trimmed) return css;
|
|
1704
|
+
const index = css.indexOf(trimmed);
|
|
1705
|
+
if (index === -1) return css;
|
|
1706
|
+
return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
|
|
1707
|
+
}
|
|
1708
|
+
function collectSelectorsFromCss(css) {
|
|
1709
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1710
|
+
try {
|
|
1711
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
1712
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1713
|
+
const normalized = selector.trim();
|
|
1714
|
+
if (normalized) selectors.add(normalized);
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
} catch {}
|
|
1718
|
+
return selectors;
|
|
1719
|
+
}
|
|
1720
|
+
function normalizeRuleValue(value) {
|
|
1721
|
+
return value.replace(/\s+/g, " ").trim();
|
|
1722
|
+
}
|
|
1723
|
+
function createRuleKey(rule) {
|
|
1724
|
+
const parents = [];
|
|
1725
|
+
let parent = rule.parent;
|
|
1726
|
+
while (parent && parent.type !== "root") {
|
|
1727
|
+
if (parent.type === "atrule") parents.push(`${parent.name}:${normalizeRuleValue(parent.params)}`);
|
|
1728
|
+
parent = parent.parent;
|
|
1729
|
+
}
|
|
1730
|
+
const selectors = (rule.selectors ?? [rule.selector]).map((selector) => normalizeRuleValue(selector)).join(",");
|
|
1731
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeRuleValue(node.value)}:${node.important ? "1" : "0"}`).join(";");
|
|
1732
|
+
return `${parents.reverse().join("|")}\n${selectors}\n${declarations}`;
|
|
1733
|
+
}
|
|
1734
|
+
function collectRuleKeysFromCss(css) {
|
|
1735
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1736
|
+
try {
|
|
1737
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
1738
|
+
keys.add(createRuleKey(rule));
|
|
1739
|
+
});
|
|
1740
|
+
} catch {}
|
|
1741
|
+
return keys;
|
|
1742
|
+
}
|
|
1743
|
+
function matchesLayerSelector(selector, layerSelector) {
|
|
1744
|
+
if (selector === layerSelector) return true;
|
|
1745
|
+
if (!selector.startsWith(layerSelector)) return false;
|
|
1746
|
+
const next = selector[layerSelector.length];
|
|
1747
|
+
return next === ":" || next === "[";
|
|
1748
|
+
}
|
|
1749
|
+
function removeCssRulesForSelectors(css, layerCss) {
|
|
1750
|
+
const selectors = [...collectSelectorsFromCss(layerCss)];
|
|
1751
|
+
if (selectors.length === 0) return css;
|
|
1752
|
+
try {
|
|
1753
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1754
|
+
root.walkRules((rule) => {
|
|
1755
|
+
if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
|
|
1756
|
+
});
|
|
1757
|
+
return root.toString();
|
|
1758
|
+
} catch {
|
|
1759
|
+
return removeFirstCssOccurrence(css, layerCss);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
function removeExactCssRules(css, duplicateCss) {
|
|
1763
|
+
const duplicateKeys = collectRuleKeysFromCss(duplicateCss);
|
|
1764
|
+
if (duplicateKeys.size === 0) return css;
|
|
1765
|
+
try {
|
|
1766
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1767
|
+
root.walkRules((rule) => {
|
|
1768
|
+
if (duplicateKeys.has(createRuleKey(rule))) rule.remove();
|
|
1769
|
+
});
|
|
1770
|
+
return root.toString();
|
|
1771
|
+
} catch {
|
|
1772
|
+
return css;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function wrapUserLayerComponentsCss(css) {
|
|
1776
|
+
return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
|
|
1777
|
+
}
|
|
1778
|
+
function extractMarkedUserLayerComponentsCss(css) {
|
|
1779
|
+
const layers = [];
|
|
1780
|
+
let rest = "";
|
|
1781
|
+
let cursor = 0;
|
|
1782
|
+
while (cursor < css.length) {
|
|
1783
|
+
const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
|
|
1784
|
+
if (startIndex === -1) {
|
|
1785
|
+
rest += css.slice(cursor);
|
|
1786
|
+
break;
|
|
1787
|
+
}
|
|
1788
|
+
rest += css.slice(cursor, startIndex);
|
|
1789
|
+
const contentStart = startIndex + 47;
|
|
1790
|
+
const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
|
|
1791
|
+
if (endIndex === -1) {
|
|
1792
|
+
rest += css.slice(startIndex);
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
const layerCss = css.slice(contentStart, endIndex).trim();
|
|
1796
|
+
if (layerCss) layers.push(layerCss);
|
|
1797
|
+
cursor = endIndex + 45;
|
|
1798
|
+
}
|
|
1799
|
+
return {
|
|
1800
|
+
layers,
|
|
1801
|
+
rest
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
function isGeneratedInfrastructureRule(rule) {
|
|
1805
|
+
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
1806
|
+
if (declarations.length === 0) return false;
|
|
1807
|
+
if (declarations.every((declaration) => declaration.prop.startsWith("--"))) return true;
|
|
1808
|
+
const selectors = (rule.selectors ?? [rule.selector]).map((selector) => selector.trim());
|
|
1809
|
+
if (!(selectors.length > 0 && selectors.every((selector) => selector === "view" || selector === "text" || selector === "::before" || selector === "::after"))) return false;
|
|
1810
|
+
const declarationMap = new Map(declarations.map((declaration) => [declaration.prop, declaration.value]));
|
|
1811
|
+
return declarationMap.get("box-sizing") === "border-box" && declarationMap.has("border");
|
|
1812
|
+
}
|
|
1813
|
+
function findLayerInsertionIndex(css) {
|
|
1814
|
+
try {
|
|
1815
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1816
|
+
let insertionIndex = -1;
|
|
1817
|
+
root.walkRules((rule) => {
|
|
1818
|
+
if (insertionIndex !== -1 || isGeneratedInfrastructureRule(rule)) return;
|
|
1819
|
+
let topLevelNode = rule;
|
|
1820
|
+
while (topLevelNode.parent && topLevelNode.parent.type !== "root") topLevelNode = topLevelNode.parent;
|
|
1821
|
+
const offset = topLevelNode.source?.start?.offset;
|
|
1822
|
+
if (typeof offset === "number") insertionIndex = css.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
|
|
1823
|
+
});
|
|
1824
|
+
return insertionIndex;
|
|
1825
|
+
} catch {
|
|
1826
|
+
return -1;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function reorderMarkedUserLayerComponentsCss(css) {
|
|
1830
|
+
if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
|
|
1831
|
+
const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
|
|
1832
|
+
if (layers.length === 0) return rest;
|
|
1833
|
+
const layerCss = layers.join("\n");
|
|
1834
|
+
const restWithoutLayerDuplicates = removeExactCssRules(rest, layerCss);
|
|
1835
|
+
const insertionIndex = findLayerInsertionIndex(restWithoutLayerDuplicates);
|
|
1836
|
+
if (insertionIndex === -1) return appendCss(restWithoutLayerDuplicates, layerCss);
|
|
1837
|
+
return appendCss(appendCss(restWithoutLayerDuplicates.slice(0, insertionIndex), layerCss), restWithoutLayerDuplicates.slice(insertionIndex));
|
|
1838
|
+
}
|
|
1839
|
+
function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
|
|
1840
|
+
if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
|
|
1841
|
+
css: baseCss,
|
|
1842
|
+
merged: false
|
|
1843
|
+
};
|
|
1844
|
+
const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
|
|
1845
|
+
if (layers.length === 0) return {
|
|
1846
|
+
css: baseCss,
|
|
1847
|
+
merged: false
|
|
1848
|
+
};
|
|
1849
|
+
const layerCss = layers.join("\n");
|
|
1850
|
+
return {
|
|
1851
|
+
css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
|
|
1852
|
+
merged: true
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
//#endregion
|
|
1856
|
+
//#region src/bundlers/shared/framework-user-css.ts
|
|
1857
|
+
function normalizeUserSource(source) {
|
|
1858
|
+
try {
|
|
1859
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1860
|
+
root.walkAtRules("media", (rule) => {
|
|
1861
|
+
if (/^source\(/.test(rule.params)) rule.replaceWith(...rule.nodes ?? []);
|
|
1862
|
+
});
|
|
1863
|
+
return root.toString();
|
|
1864
|
+
} catch {
|
|
1865
|
+
return require_generator.stripUnmatchedTailwindSourceMediaCloseFragments(require_generator.stripTailwindSourceMediaFragments(source));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
async function restoreFrameworkProcessedUserCss(css, generated, source, options, generatorOptions) {
|
|
1869
|
+
const userCssOptions = {
|
|
1870
|
+
generatorTarget: generated.target,
|
|
1871
|
+
generatorStyleOptions: resolveGeneratorStyleOptions(options.opts, options.cssHandlerOptions, generatorOptions.styleOptions),
|
|
1872
|
+
cssUserHandlerOptions: options.cssUserHandlerOptions,
|
|
1873
|
+
styleHandler: options.styleHandler,
|
|
1874
|
+
importFallback: generatorOptions.importFallback
|
|
1875
|
+
};
|
|
1876
|
+
const transform = async (value) => {
|
|
1877
|
+
const parts = require_generator.splitUserCssLayerBlocks(value);
|
|
1878
|
+
const layer = await require_generator.transformGeneratorUserCss(parts.layer, userCssOptions);
|
|
1879
|
+
const rest = await require_generator.transformGeneratorUserCss(parts.rest, userCssOptions);
|
|
1880
|
+
return require_generator.removeTailwindV4GeneratedUserCssArtifacts(finalizeMiniProgramGeneratorCss(createCssSourceOrderAppend(wrapUserLayerComponentsCss(layer), rest), generated.target, options.runtimeState.tailwindRuntime.majorVersion, options.opts.cssPreflight, {
|
|
1881
|
+
injectPreflight: false,
|
|
1882
|
+
preservePreflight: generated.metadata?.preflightMode?.preserve,
|
|
1883
|
+
styleOptions: options.cssHandlerOptions
|
|
1884
|
+
}));
|
|
1885
|
+
};
|
|
1886
|
+
const userSource = normalizeUserSource(source);
|
|
1887
|
+
const ordered = splitRawSourceByGeneratedCssOrder(userSource, generated.metadata?.rawCss ?? "") ?? {
|
|
1888
|
+
before: "",
|
|
1889
|
+
after: userSource
|
|
1890
|
+
};
|
|
1891
|
+
const withBefore = createCssSourceOrderAppend((0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, await transform(ordered.before)), css);
|
|
1892
|
+
return reorderMarkedUserLayerComponentsCss(createCssSourceOrderAppend(withBefore, (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(withBefore, await transform(ordered.after))));
|
|
1893
|
+
}
|
|
1894
|
+
//#endregion
|
|
1691
1895
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
1692
1896
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
1693
1897
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
|
|
@@ -3191,10 +3395,20 @@ function normalizeMiniProgramOutputImportRequest(request) {
|
|
|
3191
3395
|
if (request.startsWith(".") || request.startsWith("/") || /^(?:[a-z][a-z\d+.-]*:|#)/i.test(request)) return request;
|
|
3192
3396
|
return `./${request}`;
|
|
3193
3397
|
}
|
|
3194
|
-
function normalizeMiniProgramImportShell(css) {
|
|
3195
|
-
|
|
3398
|
+
function normalizeMiniProgramImportShell(css, output) {
|
|
3399
|
+
const normalized = output?.cssOnly ? css : css.replace(MINI_PROGRAM_OUTPUT_IMPORT_RE, (_match, prefix, quote, request, suffix) => {
|
|
3196
3400
|
return `${prefix}${quote}${normalizeMiniProgramOutputImportRequest(request)}${quote}${suffix}`;
|
|
3197
3401
|
});
|
|
3402
|
+
if (!output || !normalized.includes("@import")) return normalized;
|
|
3403
|
+
const files = new Set([...output.outputFiles].map(normalizeOutputPath));
|
|
3404
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(normalized);
|
|
3405
|
+
root.walkAtRules("import", (rule) => {
|
|
3406
|
+
const parsed = require_generator.parseCssImportSpecifier(rule.params);
|
|
3407
|
+
if (!parsed || output.cssOnly && !/\.css(?:$|[?#])/i.test(parsed.specifier) || !files.has(resolveOutputImportRequest(output.outputFile, parsed.specifier))) return;
|
|
3408
|
+
const request = normalizeMiniProgramOutputImportRequest(parsed.specifier);
|
|
3409
|
+
if (request !== parsed.specifier) rule.params = rule.params.replace(parsed.raw, require_generator.quoteCssImportSpecifier(request, parsed.quote));
|
|
3410
|
+
});
|
|
3411
|
+
return root.toString();
|
|
3198
3412
|
}
|
|
3199
3413
|
function normalizeOutputPath(file) {
|
|
3200
3414
|
const segments = [];
|
|
@@ -3227,9 +3441,9 @@ function isMiniProgramOutputImport(node) {
|
|
|
3227
3441
|
return request !== void 0 && MINI_PROGRAM_OUTPUT_STYLE_RE.test(request);
|
|
3228
3442
|
}
|
|
3229
3443
|
function isSelfMiniProgramOutputImport(outputFile, node) {
|
|
3230
|
-
if (
|
|
3231
|
-
const request = require_generator.
|
|
3232
|
-
return request !== void 0 && resolveOutputImportRequest(outputFile, request) === normalizeOutputPath(outputFile);
|
|
3444
|
+
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
3445
|
+
const request = require_generator.parseCssImportSpecifier(node.params)?.specifier;
|
|
3446
|
+
return request !== void 0 && /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(request) && resolveOutputImportRequest(outputFile, request) === normalizeOutputPath(outputFile);
|
|
3233
3447
|
}
|
|
3234
3448
|
function removeMiniProgramOutputImportsBy(css, predicate) {
|
|
3235
3449
|
if (!css.includes("@import")) return css;
|
|
@@ -3253,8 +3467,11 @@ function removeSelfMiniProgramOutputImports(css, outputFile) {
|
|
|
3253
3467
|
function removeMiniProgramOutputImports(css) {
|
|
3254
3468
|
return removeMiniProgramOutputImportsBy(css, isMiniProgramOutputImport);
|
|
3255
3469
|
}
|
|
3256
|
-
function normalizeMiniProgramGeneratorCssSource(css, outputFile) {
|
|
3257
|
-
const normalized = normalizeMiniProgramImportShell(css
|
|
3470
|
+
function normalizeMiniProgramGeneratorCssSource(css, outputFile, outputFiles) {
|
|
3471
|
+
const normalized = normalizeMiniProgramImportShell(css, outputFile && outputFiles ? {
|
|
3472
|
+
outputFile,
|
|
3473
|
+
outputFiles
|
|
3474
|
+
} : void 0);
|
|
3258
3475
|
if (outputFile) return removeSelfMiniProgramOutputImports(normalized, outputFile);
|
|
3259
3476
|
return (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(normalized) ? normalized : removeMiniProgramOutputImports(normalized);
|
|
3260
3477
|
}
|
|
@@ -3364,170 +3581,6 @@ function finalizeIncrementalGeneratorCss(previousCss, incrementalCss, target, ma
|
|
|
3364
3581
|
return require_generator.createCssAppend(previousCss, finalizedIncrementalCss);
|
|
3365
3582
|
}
|
|
3366
3583
|
//#endregion
|
|
3367
|
-
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
3368
|
-
const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
|
|
3369
|
-
const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
|
|
3370
|
-
function appendCss(base, extra) {
|
|
3371
|
-
if (!base) return extra;
|
|
3372
|
-
if (!extra) return base;
|
|
3373
|
-
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
3374
|
-
return `${base}\n${extra}`;
|
|
3375
|
-
}
|
|
3376
|
-
function removeFirstCssOccurrence(css, chunk) {
|
|
3377
|
-
const trimmed = chunk.trim();
|
|
3378
|
-
if (!trimmed) return css;
|
|
3379
|
-
const index = css.indexOf(trimmed);
|
|
3380
|
-
if (index === -1) return css;
|
|
3381
|
-
return appendCss(css.slice(0, index).trimEnd(), css.slice(index + trimmed.length).trimStart());
|
|
3382
|
-
}
|
|
3383
|
-
function collectSelectorsFromCss(css) {
|
|
3384
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
3385
|
-
try {
|
|
3386
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
3387
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
3388
|
-
const normalized = selector.trim();
|
|
3389
|
-
if (normalized) selectors.add(normalized);
|
|
3390
|
-
}
|
|
3391
|
-
});
|
|
3392
|
-
} catch {}
|
|
3393
|
-
return selectors;
|
|
3394
|
-
}
|
|
3395
|
-
function normalizeRuleValue(value) {
|
|
3396
|
-
return value.replace(/\s+/g, " ").trim();
|
|
3397
|
-
}
|
|
3398
|
-
function createRuleKey(rule) {
|
|
3399
|
-
const parents = [];
|
|
3400
|
-
let parent = rule.parent;
|
|
3401
|
-
while (parent && parent.type !== "root") {
|
|
3402
|
-
if (parent.type === "atrule") parents.push(`${parent.name}:${normalizeRuleValue(parent.params)}`);
|
|
3403
|
-
parent = parent.parent;
|
|
3404
|
-
}
|
|
3405
|
-
const selectors = (rule.selectors ?? [rule.selector]).map((selector) => normalizeRuleValue(selector)).join(",");
|
|
3406
|
-
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeRuleValue(node.value)}:${node.important ? "1" : "0"}`).join(";");
|
|
3407
|
-
return `${parents.reverse().join("|")}\n${selectors}\n${declarations}`;
|
|
3408
|
-
}
|
|
3409
|
-
function collectRuleKeysFromCss(css) {
|
|
3410
|
-
const keys = /* @__PURE__ */ new Set();
|
|
3411
|
-
try {
|
|
3412
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).walkRules((rule) => {
|
|
3413
|
-
keys.add(createRuleKey(rule));
|
|
3414
|
-
});
|
|
3415
|
-
} catch {}
|
|
3416
|
-
return keys;
|
|
3417
|
-
}
|
|
3418
|
-
function matchesLayerSelector(selector, layerSelector) {
|
|
3419
|
-
if (selector === layerSelector) return true;
|
|
3420
|
-
if (!selector.startsWith(layerSelector)) return false;
|
|
3421
|
-
const next = selector[layerSelector.length];
|
|
3422
|
-
return next === ":" || next === "[";
|
|
3423
|
-
}
|
|
3424
|
-
function removeCssRulesForSelectors(css, layerCss) {
|
|
3425
|
-
const selectors = [...collectSelectorsFromCss(layerCss)];
|
|
3426
|
-
if (selectors.length === 0) return css;
|
|
3427
|
-
try {
|
|
3428
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3429
|
-
root.walkRules((rule) => {
|
|
3430
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectors.some((layerSelector) => matchesLayerSelector(selector.trim(), layerSelector)))) rule.remove();
|
|
3431
|
-
});
|
|
3432
|
-
return root.toString();
|
|
3433
|
-
} catch {
|
|
3434
|
-
return removeFirstCssOccurrence(css, layerCss);
|
|
3435
|
-
}
|
|
3436
|
-
}
|
|
3437
|
-
function removeExactCssRules(css, duplicateCss) {
|
|
3438
|
-
const duplicateKeys = collectRuleKeysFromCss(duplicateCss);
|
|
3439
|
-
if (duplicateKeys.size === 0) return css;
|
|
3440
|
-
try {
|
|
3441
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3442
|
-
root.walkRules((rule) => {
|
|
3443
|
-
if (duplicateKeys.has(createRuleKey(rule))) rule.remove();
|
|
3444
|
-
});
|
|
3445
|
-
return root.toString();
|
|
3446
|
-
} catch {
|
|
3447
|
-
return css;
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
function wrapUserLayerComponentsCss(css) {
|
|
3451
|
-
return css.trim().length > 0 ? `${USER_LAYER_COMPONENTS_START}\n${css}\n${USER_LAYER_COMPONENTS_END}` : css;
|
|
3452
|
-
}
|
|
3453
|
-
function extractMarkedUserLayerComponentsCss(css) {
|
|
3454
|
-
const layers = [];
|
|
3455
|
-
let rest = "";
|
|
3456
|
-
let cursor = 0;
|
|
3457
|
-
while (cursor < css.length) {
|
|
3458
|
-
const startIndex = css.indexOf(USER_LAYER_COMPONENTS_START, cursor);
|
|
3459
|
-
if (startIndex === -1) {
|
|
3460
|
-
rest += css.slice(cursor);
|
|
3461
|
-
break;
|
|
3462
|
-
}
|
|
3463
|
-
rest += css.slice(cursor, startIndex);
|
|
3464
|
-
const contentStart = startIndex + 47;
|
|
3465
|
-
const endIndex = css.indexOf(USER_LAYER_COMPONENTS_END, contentStart);
|
|
3466
|
-
if (endIndex === -1) {
|
|
3467
|
-
rest += css.slice(startIndex);
|
|
3468
|
-
break;
|
|
3469
|
-
}
|
|
3470
|
-
const layerCss = css.slice(contentStart, endIndex).trim();
|
|
3471
|
-
if (layerCss) layers.push(layerCss);
|
|
3472
|
-
cursor = endIndex + 45;
|
|
3473
|
-
}
|
|
3474
|
-
return {
|
|
3475
|
-
layers,
|
|
3476
|
-
rest
|
|
3477
|
-
};
|
|
3478
|
-
}
|
|
3479
|
-
function isGeneratedInfrastructureRule(rule) {
|
|
3480
|
-
const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
|
|
3481
|
-
if (declarations.length === 0) return false;
|
|
3482
|
-
if (declarations.every((declaration) => declaration.prop.startsWith("--"))) return true;
|
|
3483
|
-
const selectors = (rule.selectors ?? [rule.selector]).map((selector) => selector.trim());
|
|
3484
|
-
if (!(selectors.length > 0 && selectors.every((selector) => selector === "view" || selector === "text" || selector === "::before" || selector === "::after"))) return false;
|
|
3485
|
-
const declarationMap = new Map(declarations.map((declaration) => [declaration.prop, declaration.value]));
|
|
3486
|
-
return declarationMap.get("box-sizing") === "border-box" && declarationMap.has("border");
|
|
3487
|
-
}
|
|
3488
|
-
function findLayerInsertionIndex(css) {
|
|
3489
|
-
try {
|
|
3490
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3491
|
-
let insertionIndex = -1;
|
|
3492
|
-
root.walkRules((rule) => {
|
|
3493
|
-
if (insertionIndex !== -1 || isGeneratedInfrastructureRule(rule)) return;
|
|
3494
|
-
let topLevelNode = rule;
|
|
3495
|
-
while (topLevelNode.parent && topLevelNode.parent.type !== "root") topLevelNode = topLevelNode.parent;
|
|
3496
|
-
const offset = topLevelNode.source?.start?.offset;
|
|
3497
|
-
if (typeof offset === "number") insertionIndex = css.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
|
|
3498
|
-
});
|
|
3499
|
-
return insertionIndex;
|
|
3500
|
-
} catch {
|
|
3501
|
-
return -1;
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
function reorderMarkedUserLayerComponentsCss(css) {
|
|
3505
|
-
if (!css.includes(USER_LAYER_COMPONENTS_START)) return css;
|
|
3506
|
-
const { layers, rest } = extractMarkedUserLayerComponentsCss(css);
|
|
3507
|
-
if (layers.length === 0) return rest;
|
|
3508
|
-
const layerCss = layers.join("\n");
|
|
3509
|
-
const restWithoutLayerDuplicates = removeExactCssRules(rest, layerCss);
|
|
3510
|
-
const insertionIndex = findLayerInsertionIndex(restWithoutLayerDuplicates);
|
|
3511
|
-
if (insertionIndex === -1) return appendCss(restWithoutLayerDuplicates, layerCss);
|
|
3512
|
-
return appendCss(appendCss(restWithoutLayerDuplicates.slice(0, insertionIndex), layerCss), restWithoutLayerDuplicates.slice(insertionIndex));
|
|
3513
|
-
}
|
|
3514
|
-
function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
|
|
3515
|
-
if (!markedCss.includes(USER_LAYER_COMPONENTS_START)) return {
|
|
3516
|
-
css: baseCss,
|
|
3517
|
-
merged: false
|
|
3518
|
-
};
|
|
3519
|
-
const { layers } = extractMarkedUserLayerComponentsCss(markedCss);
|
|
3520
|
-
if (layers.length === 0) return {
|
|
3521
|
-
css: baseCss,
|
|
3522
|
-
merged: false
|
|
3523
|
-
};
|
|
3524
|
-
const layerCss = layers.join("\n");
|
|
3525
|
-
return {
|
|
3526
|
-
css: reorderMarkedUserLayerComponentsCss(appendCss(removeCssRulesForSelectors(baseCss, layerCss), wrapUserLayerComponentsCss(layerCss))),
|
|
3527
|
-
merged: true
|
|
3528
|
-
};
|
|
3529
|
-
}
|
|
3530
|
-
//#endregion
|
|
3531
3584
|
//#region src/bundlers/shared/generator-css/pipeline/deferred-output.ts
|
|
3532
3585
|
async function finalizeDeferredGeneratorCss(context) {
|
|
3533
3586
|
const { cssUserHandlerOptions, file, filterGeneratedApplyOnlyCss, generated, generatedUserCssRawSource, generatorOptions, generatorRawSource, generatorStyleOptions, hasMatchedCssSourceFile, localImports, majorVersion, options, opts, preflightMode, runtimeWithCurrentCss, styleHandler, userCssOrderSource, userRawSourceProcessed } = context;
|
|
@@ -4315,12 +4368,16 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
|
|
|
4315
4368
|
uniAppX: options.opts.uniAppX
|
|
4316
4369
|
});
|
|
4317
4370
|
const shouldReplayFrameworkPostcss = options.cssStage === "framework-processed" && hasFrameworkPostcssOptions(frameworkPostcssOwner) && normalizedGeneratorOptions.target === "weapp";
|
|
4371
|
+
const generationInput = !shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? {
|
|
4372
|
+
...options,
|
|
4373
|
+
userRawSource: [options.userRawSource, options.frameworkProcessedUserCss].filter(Boolean).join("\n")
|
|
4374
|
+
} : options;
|
|
4318
4375
|
const scope = options.scope ?? {
|
|
4319
4376
|
id: options.outputFile ?? options.file,
|
|
4320
4377
|
kind: options.cssHandlerOptions.isMainChunk ? "global" : "component"
|
|
4321
4378
|
};
|
|
4322
4379
|
const generated = await generateCssByGenerator(shouldReplayFrameworkPostcss ? {
|
|
4323
|
-
...
|
|
4380
|
+
...generationInput,
|
|
4324
4381
|
compilation: implementation.frameworkAdapter === "graph" ? {
|
|
4325
4382
|
enabled: true,
|
|
4326
4383
|
preserveDeletedCss: normalizedGeneratorOptions.hmr?.preserveDeletedCss ?? true,
|
|
@@ -4329,7 +4386,7 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
|
|
|
4329
4386
|
} : void 0,
|
|
4330
4387
|
deferCssAdaptation: true
|
|
4331
4388
|
} : {
|
|
4332
|
-
...
|
|
4389
|
+
...generationInput,
|
|
4333
4390
|
compilation: implementation.frameworkAdapter === "graph" ? {
|
|
4334
4391
|
enabled: true,
|
|
4335
4392
|
preserveDeletedCss: normalizedGeneratorOptions.hmr?.preserveDeletedCss ?? true,
|
|
@@ -4349,13 +4406,18 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
|
|
|
4349
4406
|
snapshot: generated.snapshot
|
|
4350
4407
|
} : {}
|
|
4351
4408
|
}) : generated.css;
|
|
4352
|
-
const
|
|
4353
|
-
const
|
|
4409
|
+
const composedCss = shouldReplayFrameworkPostcss && options.frameworkProcessedUserCss ? await restoreFrameworkProcessedUserCss(adaptedCss, generated, options.frameworkProcessedUserCss, options, normalizedGeneratorOptions) : adaptedCss;
|
|
4410
|
+
const css = isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions)) ? require_generator.preferScopedGeneratedCssRules(composedCss) : composedCss;
|
|
4411
|
+
const classSet = options.frameworkProcessedUserCss ? resolveGeneratedCssClassSet(generated.target, generated.classSet, options.runtime, css, options.opts.escapeMap, options.previousClassSet) : generated.classSet;
|
|
4412
|
+
const artifact = implementation.emitArtifact ? createCoreArtifact({
|
|
4413
|
+
...generated,
|
|
4414
|
+
classSet
|
|
4415
|
+
}, css, options) : void 0;
|
|
4354
4416
|
return {
|
|
4355
4417
|
...generated,
|
|
4356
4418
|
...artifact ? { artifact } : {},
|
|
4357
4419
|
css,
|
|
4358
|
-
classSet
|
|
4420
|
+
classSet,
|
|
4359
4421
|
dependencies: generated.dependencies,
|
|
4360
4422
|
metadata: {
|
|
4361
4423
|
file: options.file,
|
package/dist/vite/web.cjs
CHANGED
package/dist/vite/web.js
CHANGED