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.
- package/dist/auto-CTp6wE5a.js +33 -0
- package/dist/auto-Cl8_hsG6.mjs +22 -0
- package/dist/{bundle-state-BzwPS-UI.js → bundle-state-BwtEqxvU.js} +3 -3
- package/dist/{bundle-state-ChcOKb9w.mjs → bundle-state-CXzPknlT.mjs} +2 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +0 -2
- package/dist/cli.js +3 -159
- package/dist/cli.mjs +3 -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-6yF8wjxR.js → generator-ChgOWNOj.js} +1 -1
- package/dist/{generator-BON6M1bL.mjs → generator-h2XRiJ9-.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-oE-Byqk6.mjs → gulp-Be88jhoY.mjs} +5 -5
- package/dist/{gulp-_7p1Z2vc.js → gulp-CHtZF-oT.js} +6 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BKQNRxHr.js → hmr-timing-BkivBZvN.js} +41 -43
- package/dist/{hmr-timing-BVTGf5ch.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-CZjr87m_.mjs → precheck-BpHxsWRd.mjs} +4 -4
- package/dist/{precheck-fhIkzCSU.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-bbQUg25J.mjs → tailwindcss-Bfy2egdX.mjs} +2 -2
- package/dist/{tailwindcss-vswd1gc3.js → tailwindcss-DbbAKAZP.js} +3 -3
- package/dist/{transform-CReJxxh_.js → transform-Cd634UZV.js} +1 -1
- package/dist/{transform-DEsFlG9k.mjs → transform-r5evL6Hn.mjs} +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/{v3-engine-CdIwmHuc.mjs → v3-engine-CFkP6dWF.mjs} +55 -19
- package/dist/{v3-engine-CEMXFegG.js → v3-engine-D0yA9ZkF.js} +86 -87
- package/dist/{vite-C7BGAlCE.mjs → vite-BM_iIFmS.mjs} +10 -411
- package/dist/{vite-0jFbh9hx.js → vite-Bh-BNp5g.js} +27 -431
- 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 +111 -407
- package/dist/weapp-tw-runtime-classset-loader.js +2 -2
- package/dist/{webpack-aEuDoYfQ.js → webpack-CJAOcYEO.js} +16 -9
- package/dist/{webpack-Dx6_eg5k.mjs → webpack-DPdrcC2X.mjs} +15 -8
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +5 -7
- 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-BTIunhWl.js +0 -284
- package/dist/postcss-BtmrrZ31.mjs +0 -275
- package/dist/postcss-C7BMYpEF.mjs +0 -169
- package/dist/postcss-CiYLsqZn.js +0 -192
- package/dist/watch-dependencies-zwx4EhBn.js +0 -5535
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { a as transformCssMacroCss, n as hasCssMacroTailwindPlugin, o as withCssMacroStyleOptions, r as hasCssMacroTailwindV4Directive, t as hasCssMacroStyleOptions } from "./auto-
|
|
1
|
+
import { a as transformCssMacroCss, n as hasCssMacroTailwindPlugin, o as withCssMacroStyleOptions, r as hasCssMacroTailwindV4Directive, t as hasCssMacroStyleOptions } from "./auto-Cl8_hsG6.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import postcss from "postcss";
|
|
3
|
+
import { createStyleHandler, postcss, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
|
|
4
|
+
import * as tailwindcssPatch from "tailwindcss-patch";
|
|
4
5
|
import { TailwindcssPatcher, createTailwindV4Engine, extractRawCandidates, extractSourceCandidates, isBareArbitraryValuesEnabled, loadTailwindV4DesignSystem, resolveBareArbitraryValueCandidate, resolveProjectSourceFiles, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions } from "tailwindcss-patch";
|
|
5
|
-
import process from "node:process";
|
|
6
6
|
import fs, { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
+
import process from "node:process";
|
|
8
9
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
9
10
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
10
11
|
import { fileURLToPath } from "node:url";
|
|
11
12
|
import _createDebug from "debug";
|
|
12
13
|
import { stat } from "node:fs/promises";
|
|
13
14
|
import micromatch from "micromatch";
|
|
14
|
-
import { createStyleHandler, protectDynamicColorMixAlpha, pruneMiniProgramGeneratedCss } from "@weapp-tailwindcss/postcss";
|
|
15
15
|
import fg from "fast-glob";
|
|
16
16
|
import { loadConfig } from "tailwindcss-config";
|
|
17
17
|
//#region src/utils/object.ts
|
|
@@ -3720,6 +3720,13 @@ async function transformTailwindV3CssByTarget(css, target, options) {
|
|
|
3720
3720
|
//#endregion
|
|
3721
3721
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
3722
3722
|
const incrementalGenerateCache = /* @__PURE__ */ new Map();
|
|
3723
|
+
const patchRawStyleGenerator = typeof tailwindcssPatch.generateTailwindV3RawStyle === "function" ? tailwindcssPatch.generateTailwindV3RawStyle : void 0;
|
|
3724
|
+
function isTailwindV3PatchResolutionError(error, packageName) {
|
|
3725
|
+
if (!error || typeof error !== "object") return false;
|
|
3726
|
+
const code = error.code;
|
|
3727
|
+
if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
|
|
3728
|
+
return String(error.message ?? "").includes(`${packageName}/lib/`);
|
|
3729
|
+
}
|
|
3723
3730
|
function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
|
|
3724
3731
|
return resolveBareArbitraryValueCandidate(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
|
|
3725
3732
|
}
|
|
@@ -3846,6 +3853,26 @@ function appendUtilityRules(root, context, rules) {
|
|
|
3846
3853
|
function appendDirectUtilityRules(root, context) {
|
|
3847
3854
|
appendUtilityRules(root, context, [...context.ruleCache]);
|
|
3848
3855
|
}
|
|
3856
|
+
async function generateRawStyleWithPatch(generateSource, candidates, sources) {
|
|
3857
|
+
if (!patchRawStyleGenerator) return;
|
|
3858
|
+
try {
|
|
3859
|
+
return await patchRawStyleGenerator({
|
|
3860
|
+
cwd: generateSource.cwd,
|
|
3861
|
+
packageName: generateSource.packageName,
|
|
3862
|
+
css: generateSource.css,
|
|
3863
|
+
candidates,
|
|
3864
|
+
sources,
|
|
3865
|
+
config: createTailwindConfig(generateSource, {
|
|
3866
|
+
candidates,
|
|
3867
|
+
sources
|
|
3868
|
+
}),
|
|
3869
|
+
directUtilitiesOnly: "auto"
|
|
3870
|
+
});
|
|
3871
|
+
} catch (error) {
|
|
3872
|
+
if (isTailwindV3PatchResolutionError(error, generateSource.packageName)) return;
|
|
3873
|
+
throw error;
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3849
3876
|
function createTailwindV3Engine(source) {
|
|
3850
3877
|
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
3851
3878
|
let tailwindInternals;
|
|
@@ -3871,23 +3898,32 @@ function createTailwindV3Engine(source) {
|
|
|
3871
3898
|
messages: []
|
|
3872
3899
|
};
|
|
3873
3900
|
let context;
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3901
|
+
let rawCss;
|
|
3902
|
+
let dependencies;
|
|
3903
|
+
const patchGenerated = await generateRawStyleWithPatch(generateSource, candidates, options.sources ?? []);
|
|
3904
|
+
if (patchGenerated) {
|
|
3905
|
+
context = patchGenerated.context;
|
|
3906
|
+
rawCss = restoreBareArbitraryValueCssSelectors(patchGenerated.css, requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3907
|
+
dependencies = new Set(patchGenerated.dependencies);
|
|
3882
3908
|
} else {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3909
|
+
if (isDirectUtilitiesOnlyCss(generateSource.css)) {
|
|
3910
|
+
context = internals.createContext(tailwindConfig, changedContent, root);
|
|
3911
|
+
internals.generateRules(new Set(sortCandidates([internals.notOnDemandCandidate, ...candidates])), context);
|
|
3912
|
+
root.removeAll();
|
|
3913
|
+
appendDirectUtilityRules(root, context);
|
|
3914
|
+
internals.resolveDefaultsAtRules(context)(root, result);
|
|
3915
|
+
internals.collapseAdjacentRules(context)(root, result);
|
|
3916
|
+
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3917
|
+
} else {
|
|
3918
|
+
const setupContext = () => {
|
|
3919
|
+
return (currentRoot) => internals.createContext(tailwindConfig, changedContent, currentRoot);
|
|
3920
|
+
};
|
|
3921
|
+
context = await internals.processTailwindFeatures(setupContext)(root, result);
|
|
3922
|
+
}
|
|
3923
|
+
rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3924
|
+
dependencies = collectDependencyMessages(result);
|
|
3887
3925
|
}
|
|
3888
|
-
const rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3889
3926
|
const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
3890
|
-
const dependencies = collectDependencyMessages(result);
|
|
3891
3927
|
for (const dependency of generateSource.dependencies) dependencies.add(dependency);
|
|
3892
3928
|
const classSet = restoreBareArbitraryValueClassSet(collectClassSet(context), requestedCandidates, options.bareArbitraryValues);
|
|
3893
3929
|
return {
|
|
@@ -4091,4 +4127,4 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
|
4091
4127
|
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
4092
4128
|
}
|
|
4093
4129
|
//#endregion
|
|
4094
|
-
export {
|
|
4130
|
+
export { normalizeLegacyContentEntries as $, normalizeTailwindV3CssEntrySource as A, splitTailwindV4GeneratedCssBySourceOrder as B, hasLocalCssImport as C, normalizeTailwindConfigDirectives as D, hasTailwindSourceDirectives as E, createCssAppend as F, prependConfigDirective as G, stripTailwindBanner as H, hasTailwindGeneratedCss as I, transformTailwindV4CssToWeapp as J, createTailwindV4Engine$1 as K, hasTailwindGeneratedCssMarkers as L, removeTailwindSourceDirectives as M, resolveCssEntrySource as N, normalizeTailwindSourceDirectives as O, VITE_MARKER_RE as P, isFileMatchedByTailwindSourceEntries as Q, splitGeneratorPlaceholderCssBySourceOrder as R, resolveTailwindV4SourceOptionsFromPatcher as S, hasTailwindRootDirectives as T, stripTailwindBanners as U, stripGeneratorPlaceholderMarkers as V, normalizeConfigDirective as W, loadTailwindV4DesignSystem as X, filterUnsupportedMiniProgramTailwindV4Candidates as Y, FULL_SOURCE_SCAN_EXTENSION_RE as Z, resolveTailwindV4EntriesFromCssCached as _, transformTailwindV3CssByTarget as a, readInstalledPackageMajorVersion as at, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, normalizeStringListOption as ct, invalidateRuntimeClassSet as d, findWorkspacePackageDir as dt, resolveSourceScanPath as et, runtimeSignaturePatchersSymbol as f, findWorkspaceRoot as ft, resolveTailwindV4EntriesFromCss as g, discoverTailwindV4CssEntries as h, createTailwindV3Engine as i, createTailwindcssPatcher as it, parseImportRequest as j, normalizeTailwindSourceForGenerator as k, getRuntimeClassSetSignature as l, resolveBooleanObjectOption as lt, resolveViteSourceScanEntries as m, resolveTailwindV3SourceFromPatcher as n, toPosixPath as nt, transformTailwindV3CssToWeapp as o, findTailwindConfig as ot, createViteSourceScanMatcher as p, omitUndefined as pt, transformTailwindV4CssByTarget as q, resolveTailwindV3SourceOptionsFromPatcher as r, createDebug as rt, ensureTailwindcssRuntimePatch as s, resolveTailwindcssOptions as st, resolveTailwindV3Source as t, resolveTailwindV4CssSourceBase as tt, getRuntimeClassSetSignatureWithSources as u, findNearestPackageRoot as ut, resolveViteTailwindV4CssDependencies as v, hasTailwindApplyDirective as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, splitTailwindGeneratedCssByBanner as z };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_auto = require("./auto-
|
|
2
|
+
const require_auto = require("./auto-CTp6wE5a.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
|
-
let
|
|
5
|
-
postcss = require_chunk.__toESM(postcss);
|
|
4
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
6
5
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
7
|
-
|
|
8
|
-
node_process = require_chunk.__toESM(node_process);
|
|
6
|
+
tailwindcss_patch = require_chunk.__toESM(tailwindcss_patch);
|
|
9
7
|
let node_fs = require("node:fs");
|
|
10
8
|
node_fs = require_chunk.__toESM(node_fs);
|
|
11
9
|
let node_path = require("node:path");
|
|
12
10
|
node_path = require_chunk.__toESM(node_path);
|
|
11
|
+
let node_process = require("node:process");
|
|
12
|
+
node_process = require_chunk.__toESM(node_process);
|
|
13
13
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
14
14
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
15
15
|
let node_url = require("node:url");
|
|
@@ -18,7 +18,6 @@ debug = require_chunk.__toESM(debug);
|
|
|
18
18
|
let node_fs_promises = require("node:fs/promises");
|
|
19
19
|
let micromatch = require("micromatch");
|
|
20
20
|
micromatch = require_chunk.__toESM(micromatch);
|
|
21
|
-
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
22
21
|
let fast_glob = require("fast-glob");
|
|
23
22
|
fast_glob = require_chunk.__toESM(fast_glob);
|
|
24
23
|
let tailwindcss_config = require("tailwindcss-config");
|
|
@@ -60,7 +59,7 @@ function collectApplyCandidatesFromCss(css) {
|
|
|
60
59
|
if (!css.includes("@apply")) return [];
|
|
61
60
|
const candidates = /* @__PURE__ */ new Set();
|
|
62
61
|
try {
|
|
63
|
-
postcss.
|
|
62
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("apply", (rule) => {
|
|
64
63
|
for (const candidate of rule.params.split(/\s+/)) {
|
|
65
64
|
const normalized = candidate.replace(/!important$/, "").trim();
|
|
66
65
|
if (normalized) candidates.add(normalized);
|
|
@@ -101,7 +100,7 @@ function collectLayerCandidatesFromCss(css) {
|
|
|
101
100
|
if (!css.includes("@layer")) return [];
|
|
102
101
|
const candidates = /* @__PURE__ */ new Set();
|
|
103
102
|
try {
|
|
104
|
-
postcss.
|
|
103
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("layer", (layer) => {
|
|
105
104
|
if (!isTailwindCandidateLayer(layer.params)) return;
|
|
106
105
|
layer.walkRules((rule) => {
|
|
107
106
|
extractClassCandidatesFromSelector(rule.selector, candidates);
|
|
@@ -1662,7 +1661,7 @@ function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
|
1662
1661
|
if (!css.includes("preflight")) return css;
|
|
1663
1662
|
let root;
|
|
1664
1663
|
try {
|
|
1665
|
-
root = postcss.
|
|
1664
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1666
1665
|
} catch {
|
|
1667
1666
|
return css;
|
|
1668
1667
|
}
|
|
@@ -1690,7 +1689,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
|
|
|
1690
1689
|
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1691
1690
|
let root;
|
|
1692
1691
|
try {
|
|
1693
|
-
root = postcss.
|
|
1692
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1694
1693
|
} catch {
|
|
1695
1694
|
return css;
|
|
1696
1695
|
}
|
|
@@ -1821,7 +1820,7 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1821
1820
|
const from = source.dependencies[0];
|
|
1822
1821
|
let root;
|
|
1823
1822
|
try {
|
|
1824
|
-
root = postcss.
|
|
1823
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(source.css, { from });
|
|
1825
1824
|
} catch {
|
|
1826
1825
|
return;
|
|
1827
1826
|
}
|
|
@@ -1868,7 +1867,7 @@ function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
|
1868
1867
|
});
|
|
1869
1868
|
}
|
|
1870
1869
|
async function transformTailwindV4CssToWeapp(css, options) {
|
|
1871
|
-
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(
|
|
1870
|
+
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css), { customPropertyValues: options && "customPropertyValues" in options ? options.customPropertyValues : void 0 });
|
|
1872
1871
|
const result = await defaultStyleHandler$1(protectedCss.css, {
|
|
1873
1872
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
1874
1873
|
cssRemoveHoverPseudoClass: true,
|
|
@@ -1876,12 +1875,12 @@ async function transformTailwindV4CssToWeapp(css, options) {
|
|
|
1876
1875
|
majorVersion: 4,
|
|
1877
1876
|
...options
|
|
1878
1877
|
});
|
|
1879
|
-
const pruneOptions = { preserveConditionalComments:
|
|
1878
|
+
const pruneOptions = { preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) };
|
|
1880
1879
|
return (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(protectedCss.restore(result.css), pruneOptions);
|
|
1881
1880
|
}
|
|
1882
1881
|
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
1883
1882
|
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
1884
|
-
return
|
|
1883
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
|
|
1885
1884
|
}
|
|
1886
1885
|
//#endregion
|
|
1887
1886
|
//#region src/tailwindcss/v4-engine/generator.ts
|
|
@@ -1968,12 +1967,12 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1968
1967
|
};
|
|
1969
1968
|
}
|
|
1970
1969
|
function resolveStyleOptions$1(source, options) {
|
|
1971
|
-
return
|
|
1970
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Directive)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
1972
1971
|
}
|
|
1973
1972
|
function collectCustomPropertyValues(css) {
|
|
1974
1973
|
const values = /* @__PURE__ */ new Map();
|
|
1975
1974
|
try {
|
|
1976
|
-
postcss.
|
|
1975
|
+
_weapp_tailwindcss_postcss.postcss.parse(css).walkDecls((decl) => {
|
|
1977
1976
|
if (decl.prop.startsWith("--")) values.set(decl.prop, decl.value.trim());
|
|
1978
1977
|
});
|
|
1979
1978
|
} catch {}
|
|
@@ -2412,7 +2411,7 @@ function parseImportRequest(params) {
|
|
|
2412
2411
|
function hasLocalCssImport(rawSource) {
|
|
2413
2412
|
let found = false;
|
|
2414
2413
|
try {
|
|
2415
|
-
postcss.
|
|
2414
|
+
_weapp_tailwindcss_postcss.postcss.parse(rawSource).walkAtRules("import", (rule) => {
|
|
2416
2415
|
const request = parseImportRequest(rule.params);
|
|
2417
2416
|
if (request?.startsWith(".") === true || request?.startsWith("/") === true) {
|
|
2418
2417
|
found = true;
|
|
@@ -2481,12 +2480,12 @@ function normalizeTailwindSourceForGenerator(rawSource, options = {}) {
|
|
|
2481
2480
|
}
|
|
2482
2481
|
function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
2483
2482
|
try {
|
|
2484
|
-
const root = postcss.
|
|
2483
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2485
2484
|
let changed = false;
|
|
2486
2485
|
root.walkAtRules("import", (node) => {
|
|
2487
2486
|
const layer = TAILWIND_V3_SUBPATH_IMPORT_LAYERS.get(parseImportRequest(node.params) ?? "");
|
|
2488
2487
|
if (!layer) return;
|
|
2489
|
-
node.replaceWith(postcss.
|
|
2488
|
+
node.replaceWith(_weapp_tailwindcss_postcss.postcss.atRule({
|
|
2490
2489
|
name: "tailwind",
|
|
2491
2490
|
params: layer
|
|
2492
2491
|
}));
|
|
@@ -2500,7 +2499,7 @@ function normalizeTailwindV3CssEntrySource(rawSource) {
|
|
|
2500
2499
|
function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
2501
2500
|
if (!options.importFallback) return rawSource;
|
|
2502
2501
|
try {
|
|
2503
|
-
const root = postcss.
|
|
2502
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2504
2503
|
return normalizeTailwindImportAtRules(root, options) ? root.toString() : rawSource;
|
|
2505
2504
|
} catch {
|
|
2506
2505
|
return extractTailwindSourceForPostcssFallback(rawSource, options) ?? rawSource;
|
|
@@ -2535,7 +2534,7 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2535
2534
|
try {
|
|
2536
2535
|
const source = hasPreprocessorOnlySyntax(rawSource) ? extractTailwindSourceForPostcssFallback(rawSource, options) : stripGeneratorPlaceholderMarkers(rawSource);
|
|
2537
2536
|
if (!source) return "";
|
|
2538
|
-
const root = postcss.
|
|
2537
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2539
2538
|
let removed = false;
|
|
2540
2539
|
root.walk((node) => {
|
|
2541
2540
|
if (isTailwindSourceDirective(node, options)) {
|
|
@@ -2551,7 +2550,7 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2551
2550
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
2552
2551
|
try {
|
|
2553
2552
|
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
2554
|
-
const root = postcss.
|
|
2553
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2555
2554
|
let found = false;
|
|
2556
2555
|
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
2557
2556
|
root.walk((node) => {
|
|
@@ -2571,7 +2570,7 @@ function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
2571
2570
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
2572
2571
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
2573
2572
|
try {
|
|
2574
|
-
const root = postcss.
|
|
2573
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2575
2574
|
let found = false;
|
|
2576
2575
|
root.walkAtRules((node) => {
|
|
2577
2576
|
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
@@ -2588,7 +2587,7 @@ function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
|
2588
2587
|
function hasTailwindApplyDirective(rawSource) {
|
|
2589
2588
|
if (!rawSource.includes("@apply")) return false;
|
|
2590
2589
|
try {
|
|
2591
|
-
const root = postcss.
|
|
2590
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2592
2591
|
let found = false;
|
|
2593
2592
|
root.walkAtRules("apply", () => {
|
|
2594
2593
|
found = true;
|
|
@@ -2601,7 +2600,7 @@ function hasTailwindApplyDirective(rawSource) {
|
|
|
2601
2600
|
}
|
|
2602
2601
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
2603
2602
|
try {
|
|
2604
|
-
const root = postcss.
|
|
2603
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
2605
2604
|
const normalizedImports = normalizeTailwindImportAtRules(root, options);
|
|
2606
2605
|
let found = false;
|
|
2607
2606
|
let config;
|
|
@@ -2744,7 +2743,7 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
|
2744
2743
|
if (!css.includes("tailwindcss")) return css;
|
|
2745
2744
|
let root;
|
|
2746
2745
|
try {
|
|
2747
|
-
root = postcss.
|
|
2746
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
2748
2747
|
} catch {
|
|
2749
2748
|
return css;
|
|
2750
2749
|
}
|
|
@@ -3155,7 +3154,7 @@ async function resolveConfigContentEntries(root, base) {
|
|
|
3155
3154
|
async function resolveTailwindV4EntriesFromCss(css, base) {
|
|
3156
3155
|
let root;
|
|
3157
3156
|
try {
|
|
3158
|
-
root = postcss.
|
|
3157
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3159
3158
|
} catch {
|
|
3160
3159
|
return;
|
|
3161
3160
|
}
|
|
@@ -3259,7 +3258,7 @@ async function pathExistsAsFile(file) {
|
|
|
3259
3258
|
async function resolveTailwindV4EntriesFromCssCached(css, base) {
|
|
3260
3259
|
let root;
|
|
3261
3260
|
try {
|
|
3262
|
-
root = postcss.
|
|
3261
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3263
3262
|
} catch {
|
|
3264
3263
|
return;
|
|
3265
3264
|
}
|
|
@@ -3683,7 +3682,7 @@ function hasResetDeclaration(rule) {
|
|
|
3683
3682
|
}
|
|
3684
3683
|
function createPreflightDeclarations(cssPreflight) {
|
|
3685
3684
|
if (!cssPreflight || typeof cssPreflight !== "object") return [];
|
|
3686
|
-
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => postcss.
|
|
3685
|
+
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => _weapp_tailwindcss_postcss.postcss.decl({
|
|
3687
3686
|
prop,
|
|
3688
3687
|
value: value.toString()
|
|
3689
3688
|
}));
|
|
@@ -3692,7 +3691,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
|
3692
3691
|
const declarations = createPreflightDeclarations(cssPreflight);
|
|
3693
3692
|
if (declarations.length === 0) return css;
|
|
3694
3693
|
try {
|
|
3695
|
-
const root = postcss.
|
|
3694
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
3696
3695
|
let targetRule;
|
|
3697
3696
|
let hasReset = false;
|
|
3698
3697
|
root.walkRules((rule) => {
|
|
@@ -3708,7 +3707,7 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
|
3708
3707
|
}
|
|
3709
3708
|
}
|
|
3710
3709
|
async function transformTailwindV3CssToWeapp(css, options) {
|
|
3711
|
-
const result = await defaultStyleHandler(
|
|
3710
|
+
const result = await defaultStyleHandler((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? await (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css, {
|
|
3712
3711
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
3713
3712
|
cssRemoveHoverPseudoClass: true,
|
|
3714
3713
|
isMainChunk: true,
|
|
@@ -3717,17 +3716,24 @@ async function transformTailwindV3CssToWeapp(css, options) {
|
|
|
3717
3716
|
});
|
|
3718
3717
|
const pruneOptions = {
|
|
3719
3718
|
preservePreflight: true,
|
|
3720
|
-
preserveConditionalComments:
|
|
3719
|
+
preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options)
|
|
3721
3720
|
};
|
|
3722
3721
|
return ensureMiniProgramV3PreflightReset((0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(result.css, pruneOptions), options?.cssPreflight);
|
|
3723
3722
|
}
|
|
3724
3723
|
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
3725
3724
|
if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
|
|
3726
|
-
return
|
|
3725
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css;
|
|
3727
3726
|
}
|
|
3728
3727
|
//#endregion
|
|
3729
3728
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
3730
3729
|
const incrementalGenerateCache = /* @__PURE__ */ new Map();
|
|
3730
|
+
const patchRawStyleGenerator = typeof tailwindcss_patch.generateTailwindV3RawStyle === "function" ? tailwindcss_patch.generateTailwindV3RawStyle : void 0;
|
|
3731
|
+
function isTailwindV3PatchResolutionError(error, packageName) {
|
|
3732
|
+
if (!error || typeof error !== "object") return false;
|
|
3733
|
+
const code = error.code;
|
|
3734
|
+
if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
|
|
3735
|
+
return String(error.message ?? "").includes(`${packageName}/lib/`);
|
|
3736
|
+
}
|
|
3731
3737
|
function normalizeBareArbitraryValueCandidate(candidate, bareArbitraryValues) {
|
|
3732
3738
|
return (0, tailwindcss_patch.resolveBareArbitraryValueCandidate)(candidate, bareArbitraryValues)?.canonicalCandidate ?? candidate;
|
|
3733
3739
|
}
|
|
@@ -3787,7 +3793,7 @@ function shouldAutoEnableCssMacro(source) {
|
|
|
3787
3793
|
return require_auto.hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
|
|
3788
3794
|
}
|
|
3789
3795
|
function resolveStyleOptions(source, options) {
|
|
3790
|
-
return shouldAutoEnableCssMacro(source) ?
|
|
3796
|
+
return shouldAutoEnableCssMacro(source) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
3791
3797
|
}
|
|
3792
3798
|
function loadTailwindV3Internals(source) {
|
|
3793
3799
|
const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
|
|
@@ -3854,6 +3860,26 @@ function appendUtilityRules(root, context, rules) {
|
|
|
3854
3860
|
function appendDirectUtilityRules(root, context) {
|
|
3855
3861
|
appendUtilityRules(root, context, [...context.ruleCache]);
|
|
3856
3862
|
}
|
|
3863
|
+
async function generateRawStyleWithPatch(generateSource, candidates, sources) {
|
|
3864
|
+
if (!patchRawStyleGenerator) return;
|
|
3865
|
+
try {
|
|
3866
|
+
return await patchRawStyleGenerator({
|
|
3867
|
+
cwd: generateSource.cwd,
|
|
3868
|
+
packageName: generateSource.packageName,
|
|
3869
|
+
css: generateSource.css,
|
|
3870
|
+
candidates,
|
|
3871
|
+
sources,
|
|
3872
|
+
config: createTailwindConfig(generateSource, {
|
|
3873
|
+
candidates,
|
|
3874
|
+
sources
|
|
3875
|
+
}),
|
|
3876
|
+
directUtilitiesOnly: "auto"
|
|
3877
|
+
});
|
|
3878
|
+
} catch (error) {
|
|
3879
|
+
if (isTailwindV3PatchResolutionError(error, generateSource.packageName)) return;
|
|
3880
|
+
throw error;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3857
3883
|
function createTailwindV3Engine(source) {
|
|
3858
3884
|
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
3859
3885
|
let tailwindInternals;
|
|
@@ -3873,29 +3899,38 @@ function createTailwindV3Engine(source) {
|
|
|
3873
3899
|
const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, tailwindOptions)));
|
|
3874
3900
|
const candidates = normalizedCandidates.candidates;
|
|
3875
3901
|
const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
|
|
3876
|
-
const root = postcss.
|
|
3902
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(generateSource.css, { from: void 0 });
|
|
3877
3903
|
const result = {
|
|
3878
3904
|
css: "",
|
|
3879
3905
|
messages: []
|
|
3880
3906
|
};
|
|
3881
3907
|
let context;
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3908
|
+
let rawCss;
|
|
3909
|
+
let dependencies;
|
|
3910
|
+
const patchGenerated = await generateRawStyleWithPatch(generateSource, candidates, options.sources ?? []);
|
|
3911
|
+
if (patchGenerated) {
|
|
3912
|
+
context = patchGenerated.context;
|
|
3913
|
+
rawCss = restoreBareArbitraryValueCssSelectors(patchGenerated.css, requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3914
|
+
dependencies = new Set(patchGenerated.dependencies);
|
|
3890
3915
|
} else {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3916
|
+
if (isDirectUtilitiesOnlyCss(generateSource.css)) {
|
|
3917
|
+
context = internals.createContext(tailwindConfig, changedContent, root);
|
|
3918
|
+
internals.generateRules(new Set(sortCandidates([internals.notOnDemandCandidate, ...candidates])), context);
|
|
3919
|
+
root.removeAll();
|
|
3920
|
+
appendDirectUtilityRules(root, context);
|
|
3921
|
+
internals.resolveDefaultsAtRules(context)(root, result);
|
|
3922
|
+
internals.collapseAdjacentRules(context)(root, result);
|
|
3923
|
+
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3924
|
+
} else {
|
|
3925
|
+
const setupContext = () => {
|
|
3926
|
+
return (currentRoot) => internals.createContext(tailwindConfig, changedContent, currentRoot);
|
|
3927
|
+
};
|
|
3928
|
+
context = await internals.processTailwindFeatures(setupContext)(root, result);
|
|
3929
|
+
}
|
|
3930
|
+
rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3931
|
+
dependencies = collectDependencyMessages(result);
|
|
3895
3932
|
}
|
|
3896
|
-
const rawCss = restoreBareArbitraryValueCssSelectors(root.toString(), requestedCandidates, options.bareArbitraryValues, internals.escapeClassName);
|
|
3897
3933
|
const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
3898
|
-
const dependencies = collectDependencyMessages(result);
|
|
3899
3934
|
for (const dependency of generateSource.dependencies) dependencies.add(dependency);
|
|
3900
3935
|
const classSet = restoreBareArbitraryValueClassSet(collectClassSet(context), requestedCandidates, options.bareArbitraryValues);
|
|
3901
3936
|
return {
|
|
@@ -3914,7 +3949,7 @@ function createTailwindV3Engine(source) {
|
|
|
3914
3949
|
async function generateIncrementalMissingUtilities(context, candidates, target, styleOptions, bareArbitraryValues) {
|
|
3915
3950
|
tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
|
|
3916
3951
|
const internals = tailwindInternals;
|
|
3917
|
-
const root = postcss.
|
|
3952
|
+
const root = _weapp_tailwindcss_postcss.postcss.root();
|
|
3918
3953
|
const result = {
|
|
3919
3954
|
css: "",
|
|
3920
3955
|
messages: []
|
|
@@ -4036,7 +4071,7 @@ function resolveCssConfig(css, base) {
|
|
|
4036
4071
|
css,
|
|
4037
4072
|
config: void 0
|
|
4038
4073
|
};
|
|
4039
|
-
const root = postcss.
|
|
4074
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
4040
4075
|
let config;
|
|
4041
4076
|
root.walkAtRules("config", (rule) => {
|
|
4042
4077
|
const configPath = parseConfigParam(rule.params);
|
|
@@ -4099,12 +4134,6 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
|
4099
4134
|
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
4100
4135
|
}
|
|
4101
4136
|
//#endregion
|
|
4102
|
-
Object.defineProperty(exports, "DEFAULT_SOURCE_SCAN_EXTENSIONS", {
|
|
4103
|
-
enumerable: true,
|
|
4104
|
-
get: function() {
|
|
4105
|
-
return DEFAULT_SOURCE_SCAN_EXTENSIONS;
|
|
4106
|
-
}
|
|
4107
|
-
});
|
|
4108
4137
|
Object.defineProperty(exports, "FULL_SOURCE_SCAN_EXTENSION_RE", {
|
|
4109
4138
|
enumerable: true,
|
|
4110
4139
|
get: function() {
|
|
@@ -4117,12 +4146,6 @@ Object.defineProperty(exports, "VITE_MARKER_RE", {
|
|
|
4117
4146
|
return VITE_MARKER_RE;
|
|
4118
4147
|
}
|
|
4119
4148
|
});
|
|
4120
|
-
Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
|
|
4121
|
-
enumerable: true,
|
|
4122
|
-
get: function() {
|
|
4123
|
-
return collectCssInlineSourceCandidates;
|
|
4124
|
-
}
|
|
4125
|
-
});
|
|
4126
4149
|
Object.defineProperty(exports, "createCssAppend", {
|
|
4127
4150
|
enumerable: true,
|
|
4128
4151
|
get: function() {
|
|
@@ -4135,12 +4158,6 @@ Object.defineProperty(exports, "createDebug", {
|
|
|
4135
4158
|
return createDebug;
|
|
4136
4159
|
}
|
|
4137
4160
|
});
|
|
4138
|
-
Object.defineProperty(exports, "createSourceScanPattern", {
|
|
4139
|
-
enumerable: true,
|
|
4140
|
-
get: function() {
|
|
4141
|
-
return createSourceScanPattern;
|
|
4142
|
-
}
|
|
4143
|
-
});
|
|
4144
4161
|
Object.defineProperty(exports, "createTailwindV3Engine", {
|
|
4145
4162
|
enumerable: true,
|
|
4146
4163
|
get: function() {
|
|
@@ -4177,12 +4194,6 @@ Object.defineProperty(exports, "ensureTailwindcssRuntimePatch", {
|
|
|
4177
4194
|
return ensureTailwindcssRuntimePatch;
|
|
4178
4195
|
}
|
|
4179
4196
|
});
|
|
4180
|
-
Object.defineProperty(exports, "expandTailwindSourceEntries", {
|
|
4181
|
-
enumerable: true,
|
|
4182
|
-
get: function() {
|
|
4183
|
-
return expandTailwindSourceEntries;
|
|
4184
|
-
}
|
|
4185
|
-
});
|
|
4186
4197
|
Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
|
|
4187
4198
|
enumerable: true,
|
|
4188
4199
|
get: function() {
|
|
@@ -4327,12 +4338,6 @@ Object.defineProperty(exports, "omitUndefined", {
|
|
|
4327
4338
|
return omitUndefined;
|
|
4328
4339
|
}
|
|
4329
4340
|
});
|
|
4330
|
-
Object.defineProperty(exports, "parseConfigParam", {
|
|
4331
|
-
enumerable: true,
|
|
4332
|
-
get: function() {
|
|
4333
|
-
return parseConfigParam$1;
|
|
4334
|
-
}
|
|
4335
|
-
});
|
|
4336
4341
|
Object.defineProperty(exports, "parseImportRequest", {
|
|
4337
4342
|
enumerable: true,
|
|
4338
4343
|
get: function() {
|
|
@@ -4369,12 +4374,6 @@ Object.defineProperty(exports, "resolveCssEntrySource", {
|
|
|
4369
4374
|
return resolveCssEntrySource;
|
|
4370
4375
|
}
|
|
4371
4376
|
});
|
|
4372
|
-
Object.defineProperty(exports, "resolveCssSourceEntries", {
|
|
4373
|
-
enumerable: true,
|
|
4374
|
-
get: function() {
|
|
4375
|
-
return resolveCssSourceEntries;
|
|
4376
|
-
}
|
|
4377
|
-
});
|
|
4378
4377
|
Object.defineProperty(exports, "resolveSourceScanPath", {
|
|
4379
4378
|
enumerable: true,
|
|
4380
4379
|
get: function() {
|