weapp-tailwindcss 5.0.0-next.24 → 5.0.0-next.26
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-CqyEtds4.js +115 -0
- package/dist/auto-CsWz6lsU.mjs +78 -0
- package/dist/{bundle-state-CP_BWXfx.mjs → bundle-state-CWcrb3mH.mjs} +1 -2
- package/dist/{bundle-state-DXFq2nEo.js → bundle-state-uCtqRm0p.js} +2 -3
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/cli.js +167 -6
- package/dist/cli.mjs +166 -5
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +10 -0
- package/dist/css-macro/constants.d.ts +5 -2
- package/dist/css-macro/postcss.d.ts +1 -0
- package/dist/css-macro/postcss.js +7 -47
- package/dist/css-macro/postcss.mjs +2 -47
- package/dist/css-macro.js +15 -6
- package/dist/css-macro.mjs +15 -6
- package/dist/{defaults-C6sIKXgC.mjs → defaults-B-1EEhdL.mjs} +2 -1
- package/dist/{defaults-D3cFX6Cq.js → defaults-C10hYUch.js} +2 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-BcH28HU-.js → generator-BH6a0xuB.js} +1 -1
- package/dist/{generator-DdEgn8nG.mjs → generator-iI_265gt.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-Bux7viee.mjs → incremental-runtime-class-set-ECHyKwUL.mjs} +4 -16
- package/dist/{incremental-runtime-class-set-CWdfLHON.js → incremental-runtime-class-set-mY0v1k-Y.js} +4 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -4
- package/dist/index.mjs +6 -5
- package/dist/postcss-BwW8zO24.js +192 -0
- package/dist/postcss-BzaRjBL0.mjs +169 -0
- package/dist/{postcss-cD5PXmMU.js → postcss-DEEAZ8J5.js} +2 -2
- package/dist/{postcss-nk5bhdoV.mjs → postcss-DJoU--Z-.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/precheck-BI8oBeUg.mjs +4692 -0
- package/dist/{precheck-DtYqujIx.js → precheck-DLJg0_pu.js} +2070 -34
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/uni-app-x.d.ts +1 -0
- package/dist/presets.js +19 -5
- package/dist/presets.mjs +18 -6
- package/dist/{source-candidates-B7wmEa-G.mjs → source-candidates-DkScNh9A.mjs} +1 -1
- package/dist/{source-candidates-lHtAHLQq.js → source-candidates-mfvC9gMc.js} +1 -1
- package/dist/{tailwindcss-BtUBeOes.js → tailwindcss-Cm93idme.js} +17 -26
- package/dist/{tailwindcss-DO-VVR5k.mjs → tailwindcss-DFa5Yes8.mjs} +17 -26
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +2 -1
- package/dist/types/user-defined-options/important.d.ts +3 -1
- package/dist/unocss/index.d.ts +2 -0
- package/dist/utils/options.d.ts +2 -0
- package/dist/utils/regex.d.ts +1 -0
- package/dist/{v3-engine-vHlppqaZ.js → v3-engine-CGsbY81C.js} +67 -19
- package/dist/{v3-engine-CXqgQZUc.mjs → v3-engine-CPJ9uGyr.mjs} +56 -20
- package/dist/{vite-BkNDGBZ2.js → vite-BM_ksf1q.js} +140 -21
- package/dist/{vite-BthAm8kt.mjs → vite-CqEF-Wx5.mjs} +140 -21
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +327 -73
- package/dist/weapp-tw-runtime-classset-loader.js +1 -4
- package/dist/{webpack-prCus5xn.js → webpack-CfcuDhQ8.js} +10 -7
- package/dist/{webpack-hPc8wUAi.mjs → webpack-D--XZMBB.mjs} +11 -8
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +14 -14
- package/dist/constants-BG12WAKw.mjs +0 -44
- package/dist/constants-BeeyfJ9k.js +0 -73
- package/dist/precheck-DreRGvYH.mjs +0 -2668
- /package/dist/{logger-EVNB9z7i.js → logger-Cdzl3p8j.js} +0 -0
- /package/dist/{logger-CZUxvJJD.mjs → logger-Dr7IvyH2.mjs} +0 -0
- /package/dist/{utils-CGBVVNm6.mjs → utils-B2SJgA1L.mjs} +0 -0
- /package/dist/{utils-4ODFyoqD.js → utils-CSA174-I.js} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { a as transformCssMacroCss, n as hasCssMacroTailwindPlugin, o as withCssMacroStyleOptions, r as hasCssMacroTailwindV4Directive, t as hasCssMacroStyleOptions } from "./auto-CsWz6lsU.mjs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import fs, { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
3
4
|
import postcss from "postcss";
|
|
@@ -80,17 +81,31 @@ function omitUndefined(value) {
|
|
|
80
81
|
return Object.fromEntries(definedEntries(value));
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
84
|
+
//#region src/utils/options.ts
|
|
85
|
+
function resolveBooleanObjectOption(value, enabledValue) {
|
|
86
|
+
if (!value) return false;
|
|
87
|
+
if (value === true) return enabledValue;
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
function normalizeStringListOption(value) {
|
|
91
|
+
if (!value) return;
|
|
92
|
+
const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
|
|
93
|
+
if (!values) return;
|
|
94
|
+
const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
95
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
83
98
|
//#region src/tailwindcss/patcher-options.ts
|
|
84
99
|
function resolveTailwindcssOptions(options) {
|
|
85
100
|
return options?.tailwindcss ?? options?.tailwind;
|
|
86
101
|
}
|
|
87
102
|
function normalizeExtendLengthUnits(value) {
|
|
88
|
-
if (value ===
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
if (value === void 0) return;
|
|
104
|
+
const resolved = resolveBooleanObjectOption(value, { enabled: true });
|
|
105
|
+
return resolved && typeof resolved === "object" ? {
|
|
91
106
|
enabled: true,
|
|
92
|
-
...
|
|
93
|
-
};
|
|
107
|
+
...resolved
|
|
108
|
+
} : resolved;
|
|
94
109
|
}
|
|
95
110
|
function normalizeTailwindcssPatcherOptions(options) {
|
|
96
111
|
return options;
|
|
@@ -740,10 +755,12 @@ async function transformTailwindV4CssToWeapp(css, options) {
|
|
|
740
755
|
majorVersion: 4,
|
|
741
756
|
...options
|
|
742
757
|
});
|
|
743
|
-
|
|
758
|
+
const pruneOptions = { preserveConditionalComments: hasCssMacroStyleOptions(options) };
|
|
759
|
+
return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css), pruneOptions);
|
|
744
760
|
}
|
|
745
761
|
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
746
|
-
|
|
762
|
+
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
763
|
+
return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
|
|
747
764
|
}
|
|
748
765
|
//#endregion
|
|
749
766
|
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
@@ -1644,6 +1661,9 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1644
1661
|
isMainChunk: false
|
|
1645
1662
|
};
|
|
1646
1663
|
}
|
|
1664
|
+
function resolveStyleOptions$1(source, options) {
|
|
1665
|
+
return hasCssMacroTailwindV4Directive(source.css) ? withCssMacroStyleOptions(options) : options;
|
|
1666
|
+
}
|
|
1647
1667
|
function collectCustomPropertyValues(css) {
|
|
1648
1668
|
const values = /* @__PURE__ */ new Map();
|
|
1649
1669
|
try {
|
|
@@ -1797,6 +1817,7 @@ function removeUnsupportedThemeVendorKeyframes(css) {
|
|
|
1797
1817
|
function createTailwindV4Engine$1(source) {
|
|
1798
1818
|
async function generateOnce(generateSource, options = {}) {
|
|
1799
1819
|
const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
|
|
1820
|
+
const resolvedStyleOptions = resolveStyleOptions$1(generateSource, styleOptions);
|
|
1800
1821
|
const engine = createTailwindV4Engine(createCompatibleSource(generateSource, target, tailwindcssV3Compatibility));
|
|
1801
1822
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1802
1823
|
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await extractRawCandidates(resolvedScanSources)) : void 0;
|
|
@@ -1807,7 +1828,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1807
1828
|
candidates: normalizedCandidates.candidates
|
|
1808
1829
|
}));
|
|
1809
1830
|
const rawCss = restoreRpxTextCssSelectors(result.css, normalizedCandidates.restoreCandidates);
|
|
1810
|
-
const css = await transformTailwindV4CssByTarget(rawCss, target,
|
|
1831
|
+
const css = await transformTailwindV4CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
1811
1832
|
return {
|
|
1812
1833
|
...result,
|
|
1813
1834
|
classSet: restoreRpxTextCandidates(result.classSet, normalizedCandidates.restoreCandidates),
|
|
@@ -1821,8 +1842,9 @@ function createTailwindV4Engine$1(source) {
|
|
|
1821
1842
|
const target = options.target ?? "weapp";
|
|
1822
1843
|
const compatibleSource = createCompatibleSource(source, target, options.tailwindcssV3Compatibility);
|
|
1823
1844
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1845
|
+
const styleOptions = resolveStyleOptions$1(source, options.styleOptions);
|
|
1824
1846
|
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(source, options);
|
|
1825
|
-
const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target,
|
|
1847
|
+
const cacheKey = createIncrementalGenerateCacheKey$1(compatibleSource, target, styleOptions, options.tailwindcssV3Compatibility);
|
|
1826
1848
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1827
1849
|
const generated = await generateOnce(source, options);
|
|
1828
1850
|
seedIncrementalGenerateCache({
|
|
@@ -1867,7 +1889,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1867
1889
|
}
|
|
1868
1890
|
const rawCss = rawCssParts.join("\n");
|
|
1869
1891
|
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
|
|
1870
|
-
...createIncrementalStyleOptions(
|
|
1892
|
+
...createIncrementalStyleOptions(styleOptions),
|
|
1871
1893
|
customPropertyValues: cached.customPropertyValues
|
|
1872
1894
|
}) : "";
|
|
1873
1895
|
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
@@ -1895,7 +1917,7 @@ function createTailwindV4Engine$1(source) {
|
|
|
1895
1917
|
compatibleSource,
|
|
1896
1918
|
generated,
|
|
1897
1919
|
requestedCandidates,
|
|
1898
|
-
styleOptions
|
|
1920
|
+
styleOptions,
|
|
1899
1921
|
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility,
|
|
1900
1922
|
target
|
|
1901
1923
|
});
|
|
@@ -2794,16 +2816,22 @@ function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
|
2794
2816
|
}
|
|
2795
2817
|
}
|
|
2796
2818
|
async function transformTailwindV3CssToWeapp(css, options) {
|
|
2797
|
-
|
|
2819
|
+
const result = await defaultStyleHandler(css, {
|
|
2798
2820
|
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
2799
2821
|
cssRemoveHoverPseudoClass: true,
|
|
2800
2822
|
isMainChunk: true,
|
|
2801
2823
|
majorVersion: 3,
|
|
2802
2824
|
...options
|
|
2803
|
-
})
|
|
2825
|
+
});
|
|
2826
|
+
const pruneOptions = {
|
|
2827
|
+
preservePreflight: true,
|
|
2828
|
+
preserveConditionalComments: hasCssMacroStyleOptions(options)
|
|
2829
|
+
};
|
|
2830
|
+
return ensureMiniProgramV3PreflightReset(pruneMiniProgramGeneratedCss(result.css, pruneOptions), options?.cssPreflight);
|
|
2804
2831
|
}
|
|
2805
2832
|
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
2806
|
-
|
|
2833
|
+
if (target === "weapp") return transformTailwindV3CssToWeapp(css, options);
|
|
2834
|
+
return hasCssMacroStyleOptions(options) ? transformCssMacroCss(css) : css;
|
|
2807
2835
|
}
|
|
2808
2836
|
//#endregion
|
|
2809
2837
|
//#region src/tailwindcss/v3-engine/generator.ts
|
|
@@ -2866,7 +2894,7 @@ function extractClassCandidatesFromSelector(selector, candidates) {
|
|
|
2866
2894
|
escaped = true;
|
|
2867
2895
|
continue;
|
|
2868
2896
|
}
|
|
2869
|
-
if (/[\w-]/.test(char)) {
|
|
2897
|
+
if (char && /[\w-]/.test(char)) {
|
|
2870
2898
|
candidate += char;
|
|
2871
2899
|
continue;
|
|
2872
2900
|
}
|
|
@@ -2927,6 +2955,12 @@ function createTailwindConfig(source, options) {
|
|
|
2927
2955
|
config.content = hasExplicitContentInput(options) ? createExplicitContentConfig(rawEntries) : mergeContent(config.content, rawEntries);
|
|
2928
2956
|
return config;
|
|
2929
2957
|
}
|
|
2958
|
+
function shouldAutoEnableCssMacro(source) {
|
|
2959
|
+
return hasCssMacroTailwindPlugin(normalizeConfigObject(source.configObject)?.plugins);
|
|
2960
|
+
}
|
|
2961
|
+
function resolveStyleOptions(source, options) {
|
|
2962
|
+
return shouldAutoEnableCssMacro(source) ? withCssMacroStyleOptions(options) : options;
|
|
2963
|
+
}
|
|
2930
2964
|
function loadTailwindV3Internals(source) {
|
|
2931
2965
|
const requireFromProject = createRequire(`${source.cwd}/package.json`);
|
|
2932
2966
|
const requireFromRuntime = createRequire(import.meta.url);
|
|
@@ -3061,6 +3095,7 @@ function createTailwindV3Engine(source) {
|
|
|
3061
3095
|
tailwindInternals ?? (tailwindInternals = loadTailwindV3Internals(source));
|
|
3062
3096
|
const internals = tailwindInternals;
|
|
3063
3097
|
const { styleOptions, target = "weapp" } = options;
|
|
3098
|
+
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
3064
3099
|
const tailwindConfig = internals.validateConfig(internals.resolveConfig(createTailwindConfig(generateSource, options)));
|
|
3065
3100
|
const candidates = mergeGenerateCandidates(generateSource, options);
|
|
3066
3101
|
const changedContent = createChangedContentEntries(candidates, options.sources ?? []);
|
|
@@ -3085,7 +3120,7 @@ function createTailwindV3Engine(source) {
|
|
|
3085
3120
|
context = await internals.processTailwindFeatures(setupContext)(root, result);
|
|
3086
3121
|
}
|
|
3087
3122
|
const rawCss = root.toString();
|
|
3088
|
-
const css = await transformTailwindV3CssByTarget(rawCss, target,
|
|
3123
|
+
const css = await transformTailwindV3CssByTarget(rawCss, target, resolvedStyleOptions);
|
|
3089
3124
|
const dependencies = collectDependencyMessages(result);
|
|
3090
3125
|
for (const dependency of generateSource.dependencies) dependencies.add(dependency);
|
|
3091
3126
|
const classSet = collectClassSet(context);
|
|
@@ -3116,7 +3151,7 @@ function createTailwindV3Engine(source) {
|
|
|
3116
3151
|
internals.collapseDuplicateDeclarations(context)(root, result);
|
|
3117
3152
|
const rawCss = root.toString();
|
|
3118
3153
|
return {
|
|
3119
|
-
css: await transformTailwindV3CssByTarget(rawCss, target, styleOptions),
|
|
3154
|
+
css: await transformTailwindV3CssByTarget(rawCss, target, resolveStyleOptions(source, styleOptions)),
|
|
3120
3155
|
rawCss,
|
|
3121
3156
|
classSet: collectClassSet(context),
|
|
3122
3157
|
dependencies: collectDependencyMessages(result)
|
|
@@ -3127,7 +3162,8 @@ function createTailwindV3Engine(source) {
|
|
|
3127
3162
|
const target = options.target ?? "weapp";
|
|
3128
3163
|
const requestedCandidates = mergeGenerateCandidates(source, options);
|
|
3129
3164
|
if (requestedCandidates.size === 0) return generateOnce(source, options);
|
|
3130
|
-
const
|
|
3165
|
+
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
3166
|
+
const cacheKey = createIncrementalGenerateCacheKey(source, target, styleOptions);
|
|
3131
3167
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
3132
3168
|
if (cached) {
|
|
3133
3169
|
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
@@ -3144,7 +3180,7 @@ function createTailwindV3Engine(source) {
|
|
|
3144
3180
|
target: cached.target,
|
|
3145
3181
|
version: 3
|
|
3146
3182
|
};
|
|
3147
|
-
const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target,
|
|
3183
|
+
const generated = await generateIncrementalMissingUtilities(cached.context, missingCandidates, target, styleOptions);
|
|
3148
3184
|
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
3149
3185
|
for (const className of generated.classSet) cached.classSet.add(className);
|
|
3150
3186
|
cached.css = [cached.css, generated.css].filter(Boolean).join("\n");
|
|
@@ -3274,4 +3310,4 @@ function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
|
3274
3310
|
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
3275
3311
|
}
|
|
3276
3312
|
//#endregion
|
|
3277
|
-
export { collectCssInlineSourceCandidates as A, createDebug as B, createTailwindV4Engine$1 as C, loadTailwindV4DesignSystem as D, filterUnsupportedMiniProgramTailwindV4Candidates as E, parseConfigParam$1 as F,
|
|
3313
|
+
export { collectCssInlineSourceCandidates as A, createDebug as B, createTailwindV4Engine$1 as C, loadTailwindV4DesignSystem as D, filterUnsupportedMiniProgramTailwindV4Candidates as E, parseConfigParam$1 as F, normalizeStringListOption as G, readInstalledPackageMajorVersion as H, resolveCssSourceEntries as I, findNearestPackageRoot as J, resolveBooleanObjectOption as K, resolveSourceScanPath as L, expandTailwindSourceEntries as M, isFileMatchedByTailwindSourceEntries as N, DEFAULT_SOURCE_SCAN_EXTENSIONS as O, normalizeLegacyContentEntries as P, resolveTailwindV4CssSourceBase as R, resolveTailwindV4SourceOptionsFromPatcher as S, transformTailwindV4CssToWeapp as T, findTailwindConfig as U, createTailwindcssPatcher as V, resolveTailwindcssOptions as W, findWorkspaceRoot as X, findWorkspacePackageDir as Y, resolveViteSourceScanEntries as _, transformTailwindV3CssByTarget as a, resolveTailwindV4SourceFromPatchOptions as b, getRuntimeClassSetCacheEntry as c, invalidateRuntimeClassSet as d, runtimeSignaturePatchersSymbol as f, resolveTailwindV4EntriesFromCssCached as g, resolveTailwindV4EntriesFromCss as h, createTailwindV3Engine as i, createSourceScanPattern as j, FULL_SOURCE_SCAN_EXTENSION_RE as k, getRuntimeClassSetSignature as l, discoverTailwindV4CssEntries as m, resolveTailwindV3SourceFromPatcher as n, transformTailwindV3CssToWeapp as o, createViteSourceScanMatcher as p, omitUndefined as q, resolveTailwindV3SourceOptionsFromPatcher as r, ensureTailwindcssRuntimePatch as s, resolveTailwindV3Source as t, getRuntimeClassSetSignatureWithSources as u, resolveViteTailwindV4CssDependencies as v, transformTailwindV4CssByTarget as w, resolveTailwindV4SourceFromPatcher as x, resolveTailwindV4Source$1 as y, toPosixPath as z };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
6
|
-
const require_utils = require("./utils-
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_source_candidates = require("./source-candidates-
|
|
9
|
-
const require_bundle_state = require("./bundle-state-
|
|
10
|
-
require("./logger-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CGsbY81C.js");
|
|
3
|
+
const require_generator = require("./generator-BH6a0xuB.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-mY0v1k-Y.js");
|
|
5
|
+
const require_precheck = require("./precheck-DLJg0_pu.js");
|
|
6
|
+
const require_utils = require("./utils-CSA174-I.js");
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-Cm93idme.js");
|
|
8
|
+
const require_source_candidates = require("./source-candidates-mfvC9gMc.js");
|
|
9
|
+
const require_bundle_state = require("./bundle-state-uCtqRm0p.js");
|
|
10
|
+
require("./logger-Cdzl3p8j.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_chunk.__toESM(node_fs);
|
|
13
13
|
let postcss = require("postcss");
|
|
@@ -1814,6 +1814,83 @@ function createViteRuntimeClassSet(options) {
|
|
|
1814
1814
|
};
|
|
1815
1815
|
}
|
|
1816
1816
|
//#endregion
|
|
1817
|
+
//#region src/bundlers/vite/serve-css-generation.ts
|
|
1818
|
+
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
1819
|
+
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
1820
|
+
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
1821
|
+
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
1822
|
+
function decodeJsStringLiteral(literal) {
|
|
1823
|
+
try {
|
|
1824
|
+
return JSON.parse(literal);
|
|
1825
|
+
} catch {
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function encodeJsStringLiteral(value) {
|
|
1830
|
+
return JSON.stringify(value);
|
|
1831
|
+
}
|
|
1832
|
+
function extractViteCssHmrModuleCss(code) {
|
|
1833
|
+
const match = VITE_CSS_CONST_RE.exec(code);
|
|
1834
|
+
if (!match?.[1]) return;
|
|
1835
|
+
const css = decodeJsStringLiteral(match[1]);
|
|
1836
|
+
if (typeof css !== "string") return;
|
|
1837
|
+
return {
|
|
1838
|
+
css,
|
|
1839
|
+
start: match.index + match[0].lastIndexOf(match[1]),
|
|
1840
|
+
end: match.index + match[0].length
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
function replaceViteCssHmrModuleCss(code, css) {
|
|
1844
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
1845
|
+
if (!extracted) return;
|
|
1846
|
+
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
1847
|
+
}
|
|
1848
|
+
function isViteServeStyleRequest(id, command) {
|
|
1849
|
+
return command === "serve" && require_bundle_state.isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
1850
|
+
}
|
|
1851
|
+
function isViteServeCssRootRequest(id, command) {
|
|
1852
|
+
return command === "serve" && require_bundle_state.isCSSRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
1853
|
+
}
|
|
1854
|
+
function isViteCssHmrModule(code, id, command) {
|
|
1855
|
+
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
1856
|
+
}
|
|
1857
|
+
function createViteServeCssGenerationPlugins(options) {
|
|
1858
|
+
return [{
|
|
1859
|
+
name: `${require_precheck.vitePluginName}:generate:serve`,
|
|
1860
|
+
apply: "serve",
|
|
1861
|
+
enforce: "pre",
|
|
1862
|
+
async transform(code, id) {
|
|
1863
|
+
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
1864
|
+
if (!require_incremental_runtime_class_set.hasTailwindRootDirectives(code)) return;
|
|
1865
|
+
await options.onTailwindRootCss?.(id, code);
|
|
1866
|
+
const generatedCss = await options.generateCss(id, code, this);
|
|
1867
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
1868
|
+
return {
|
|
1869
|
+
code: generatedCss,
|
|
1870
|
+
map: null
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
}, {
|
|
1874
|
+
name: `${require_precheck.vitePluginName}:generate:serve-hmr`,
|
|
1875
|
+
apply: "serve",
|
|
1876
|
+
enforce: "post",
|
|
1877
|
+
async transform(code, id) {
|
|
1878
|
+
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
1879
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
1880
|
+
if (!extracted) return;
|
|
1881
|
+
await options.onTailwindRootCss?.(id, extracted.css);
|
|
1882
|
+
const generatedCss = await options.generateCss(id, extracted.css, this);
|
|
1883
|
+
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
1884
|
+
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
1885
|
+
if (nextCode === void 0 || nextCode === code) return;
|
|
1886
|
+
return {
|
|
1887
|
+
code: nextCode,
|
|
1888
|
+
map: null
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
}];
|
|
1892
|
+
}
|
|
1893
|
+
//#endregion
|
|
1817
1894
|
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
1818
1895
|
const PACKAGE_JSON_FILE = "package.json";
|
|
1819
1896
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
@@ -1885,7 +1962,6 @@ function WeappTailwindcss(options = {}) {
|
|
|
1885
1962
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
1886
1963
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
1887
1964
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
1888
|
-
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
1889
1965
|
const shouldInferAppType = !hasExplicitAppType && generatorOptions.target !== "web";
|
|
1890
1966
|
const hasInitialTailwindCssRoots = require_tailwindcss.hasConfiguredTailwindV4CssRoots({
|
|
1891
1967
|
...options,
|
|
@@ -2154,20 +2230,57 @@ function WeappTailwindcss(options = {}) {
|
|
|
2154
2230
|
const resolveHotTailwindCssModules = (ctx) => {
|
|
2155
2231
|
const modules = [];
|
|
2156
2232
|
const seenModules = /* @__PURE__ */ new Set();
|
|
2233
|
+
const collectModule = (mod) => {
|
|
2234
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
2235
|
+
if (!require_bundle_state.isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
2236
|
+
seenModules.add(mod);
|
|
2237
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
2238
|
+
modules.push(mod);
|
|
2239
|
+
};
|
|
2157
2240
|
for (const id of tailwindRootCssModuleIds) {
|
|
2158
|
-
const candidates = [
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
ctx.server.moduleGraph.invalidateModule(mod);
|
|
2166
|
-
modules.push(mod);
|
|
2167
|
-
}
|
|
2241
|
+
const candidates = [
|
|
2242
|
+
ctx.server.moduleGraph.getModuleById(id),
|
|
2243
|
+
ctx.server.moduleGraph.getModuleById((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
2244
|
+
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
2245
|
+
...ctx.server.moduleGraph.getModulesByFile((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ?? []
|
|
2246
|
+
];
|
|
2247
|
+
for (const mod of candidates) collectModule(mod);
|
|
2168
2248
|
}
|
|
2169
2249
|
return modules;
|
|
2170
2250
|
};
|
|
2251
|
+
const resolveModuleHotUrl = (mod) => {
|
|
2252
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
2253
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
2254
|
+
};
|
|
2255
|
+
const includesHotModule = (modules, target) => {
|
|
2256
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
2257
|
+
const targetId = target.id;
|
|
2258
|
+
return modules.some((mod) => {
|
|
2259
|
+
if (mod === target) return true;
|
|
2260
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
2261
|
+
});
|
|
2262
|
+
};
|
|
2263
|
+
const sendSupplementalCssHotUpdates = (ctx, cssModules) => {
|
|
2264
|
+
const updates = cssModules.filter((mod) => !includesHotModule(ctx.modules, mod)).map((mod) => {
|
|
2265
|
+
const hotUrl = resolveModuleHotUrl(mod);
|
|
2266
|
+
if (!hotUrl) return;
|
|
2267
|
+
return {
|
|
2268
|
+
type: "js-update",
|
|
2269
|
+
timestamp: ctx.timestamp,
|
|
2270
|
+
path: hotUrl,
|
|
2271
|
+
acceptedPath: hotUrl,
|
|
2272
|
+
explicitImportRequired: false,
|
|
2273
|
+
isWithinCircularImport: false
|
|
2274
|
+
};
|
|
2275
|
+
}).filter((update) => update !== void 0);
|
|
2276
|
+
if (updates.length === 0) return;
|
|
2277
|
+
queueMicrotask(() => {
|
|
2278
|
+
ctx.server.ws?.send?.({
|
|
2279
|
+
type: "update",
|
|
2280
|
+
updates
|
|
2281
|
+
});
|
|
2282
|
+
});
|
|
2283
|
+
};
|
|
2171
2284
|
const matchesViteProcessedCssSource = (candidate) => {
|
|
2172
2285
|
const normalized = normalizeViteProcessedCssFile(candidate);
|
|
2173
2286
|
return viteProcessedCssSourceFiles.has(normalized);
|
|
@@ -2268,7 +2381,6 @@ function WeappTailwindcss(options = {}) {
|
|
|
2268
2381
|
});
|
|
2269
2382
|
const isIosPlatform = require_utils.resolveUniUtsPlatform().isAppIos;
|
|
2270
2383
|
const prepareTailwindGeneration = async () => {
|
|
2271
|
-
if (isWebGeneratorTarget && runtimeState.twPatcher.majorVersion !== 3) return;
|
|
2272
2384
|
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
2273
2385
|
await syncSourceCandidateScan();
|
|
2274
2386
|
};
|
|
@@ -2323,6 +2435,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2323
2435
|
await syncChangedSourceCandidateFile(ctx.file);
|
|
2324
2436
|
invalidateRecordedGeneratorCandidates();
|
|
2325
2437
|
const cssModules = resolveHotTailwindCssModules(ctx);
|
|
2438
|
+
sendSupplementalCssHotUpdates(ctx, cssModules);
|
|
2326
2439
|
return cssModules.length > 0 ? [...ctx.modules, ...cssModules] : void 0;
|
|
2327
2440
|
}, { emit: false });
|
|
2328
2441
|
},
|
|
@@ -2332,6 +2445,12 @@ function WeappTailwindcss(options = {}) {
|
|
|
2332
2445
|
}, { emit: false });
|
|
2333
2446
|
}
|
|
2334
2447
|
},
|
|
2448
|
+
...createViteServeCssGenerationPlugins({
|
|
2449
|
+
generateCss: generateTailwindCssForVitePipeline,
|
|
2450
|
+
getCommand: () => resolvedConfig?.command,
|
|
2451
|
+
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
2452
|
+
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
2453
|
+
}),
|
|
2335
2454
|
{
|
|
2336
2455
|
name: `${require_precheck.vitePluginName}:post`,
|
|
2337
2456
|
enforce: "post",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates,
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-
|
|
3
|
-
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-
|
|
4
|
-
import {
|
|
5
|
-
import { o as resolveUniUtsPlatform } from "./utils-
|
|
6
|
-
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
7
|
-
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-
|
|
8
|
-
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-
|
|
9
|
-
import { t as logger$1 } from "./logger-
|
|
1
|
+
import { B as createDebug, E as filterUnsupportedMiniProgramTailwindV4Candidates, J as findNearestPackageRoot, U as findTailwindConfig, W as resolveTailwindcssOptions, _ as resolveViteSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as createViteSourceScanMatcher, q as omitUndefined, v as resolveViteTailwindV4CssDependencies } from "./v3-engine-CPJ9uGyr.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-iI_265gt.mjs";
|
|
3
|
+
import { a as validateCandidatesByGenerator, c as hasTailwindSourceDirectives, i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, n as createHmrTimingRecorder, o as processCachedTask, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager, u as hasTailwindGeneratedCssMarkers } from "./incremental-runtime-class-set-ECHyKwUL.mjs";
|
|
4
|
+
import { _ as collectRuntimeClassSet, a as vitePluginName, b as refreshTailwindRuntimeState, c as createAttributeMatcher, d as _defineProperty, f as isClassContextLiteralPath, g as toCustomAttributesEntities, l as analyzeSource, m as babelParse, n as getCompilerContext, p as replaceWxml, s as generateCode, t as shouldSkipJsTransform, u as JsTokenUpdater, v as createTailwindRuntimeReadyPromise } from "./precheck-BI8oBeUg.mjs";
|
|
5
|
+
import { o as resolveUniUtsPlatform } from "./utils-B2SJgA1L.mjs";
|
|
6
|
+
import { c as upsertTailwindV4CssSource, i as resolveUniAppXOptions, r as isUniAppXEnabled, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-DFa5Yes8.mjs";
|
|
7
|
+
import { n as isSourceCandidateRequest, t as createSourceCandidateCollector } from "./source-candidates-DkScNh9A.mjs";
|
|
8
|
+
import { a as createBundleModuleGraphOptions, b as toAbsoluteOutputPath, c as hasBundlerGeneratedCssMarker, d as resolvePluginDisabledState, f as cleanUrl, g as isSourceStyleRequest, h as slash, i as applyLinkedResults, l as stripBundlerGeneratedCssMarkers, m as isCSSRequest, n as createBundleBuildState, o as pushConcurrentTaskFactories, p as formatPostcssSourceMap, r as updateBundleBuildState, s as createBundlerGeneratedCssMarker, t as buildBundleSnapshot, u as resolvePackageDir, v as normalizeOutputPathKey } from "./bundle-state-CWcrb3mH.mjs";
|
|
9
|
+
import { t as logger$1 } from "./logger-Dr7IvyH2.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
11
11
|
import postcss from "postcss";
|
|
12
12
|
import path from "node:path";
|
|
@@ -1805,6 +1805,83 @@ function createViteRuntimeClassSet(options) {
|
|
|
1805
1805
|
};
|
|
1806
1806
|
}
|
|
1807
1807
|
//#endregion
|
|
1808
|
+
//#region src/bundlers/vite/serve-css-generation.ts
|
|
1809
|
+
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
|
1810
|
+
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/;
|
|
1811
|
+
const VITE_CSS_HMR_MODULE_RE = /\b__vite__updateStyle\s*\(/;
|
|
1812
|
+
const VITE_CSS_CONST_RE = /\bconst\s+__vite__css\s*=\s*("(?:\\[\s\S]|[^"])*")/;
|
|
1813
|
+
function decodeJsStringLiteral(literal) {
|
|
1814
|
+
try {
|
|
1815
|
+
return JSON.parse(literal);
|
|
1816
|
+
} catch {
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
function encodeJsStringLiteral(value) {
|
|
1821
|
+
return JSON.stringify(value);
|
|
1822
|
+
}
|
|
1823
|
+
function extractViteCssHmrModuleCss(code) {
|
|
1824
|
+
const match = VITE_CSS_CONST_RE.exec(code);
|
|
1825
|
+
if (!match?.[1]) return;
|
|
1826
|
+
const css = decodeJsStringLiteral(match[1]);
|
|
1827
|
+
if (typeof css !== "string") return;
|
|
1828
|
+
return {
|
|
1829
|
+
css,
|
|
1830
|
+
start: match.index + match[0].lastIndexOf(match[1]),
|
|
1831
|
+
end: match.index + match[0].length
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
function replaceViteCssHmrModuleCss(code, css) {
|
|
1835
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
1836
|
+
if (!extracted) return;
|
|
1837
|
+
return `${code.slice(0, extracted.start)}${encodeJsStringLiteral(css)}${code.slice(extracted.end)}`;
|
|
1838
|
+
}
|
|
1839
|
+
function isViteServeStyleRequest(id, command) {
|
|
1840
|
+
return command === "serve" && isSourceStyleRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
1841
|
+
}
|
|
1842
|
+
function isViteServeCssRootRequest(id, command) {
|
|
1843
|
+
return command === "serve" && isCSSRequest(id) && !SPECIAL_QUERY_RE.test(id) && !COMMON_JS_PROXY_RE.test(id);
|
|
1844
|
+
}
|
|
1845
|
+
function isViteCssHmrModule(code, id, command) {
|
|
1846
|
+
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
1847
|
+
}
|
|
1848
|
+
function createViteServeCssGenerationPlugins(options) {
|
|
1849
|
+
return [{
|
|
1850
|
+
name: `${vitePluginName}:generate:serve`,
|
|
1851
|
+
apply: "serve",
|
|
1852
|
+
enforce: "pre",
|
|
1853
|
+
async transform(code, id) {
|
|
1854
|
+
if (!options.shouldGenerate() || !isViteServeCssRootRequest(id, options.getCommand())) return;
|
|
1855
|
+
if (!hasTailwindRootDirectives(code)) return;
|
|
1856
|
+
await options.onTailwindRootCss?.(id, code);
|
|
1857
|
+
const generatedCss = await options.generateCss(id, code, this);
|
|
1858
|
+
if (generatedCss === void 0 || generatedCss === code) return;
|
|
1859
|
+
return {
|
|
1860
|
+
code: generatedCss,
|
|
1861
|
+
map: null
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
}, {
|
|
1865
|
+
name: `${vitePluginName}:generate:serve-hmr`,
|
|
1866
|
+
apply: "serve",
|
|
1867
|
+
enforce: "post",
|
|
1868
|
+
async transform(code, id) {
|
|
1869
|
+
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
1870
|
+
const extracted = extractViteCssHmrModuleCss(code);
|
|
1871
|
+
if (!extracted) return;
|
|
1872
|
+
await options.onTailwindRootCss?.(id, extracted.css);
|
|
1873
|
+
const generatedCss = await options.generateCss(id, extracted.css, this);
|
|
1874
|
+
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
1875
|
+
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
1876
|
+
if (nextCode === void 0 || nextCode === code) return;
|
|
1877
|
+
return {
|
|
1878
|
+
code: nextCode,
|
|
1879
|
+
map: null
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
}];
|
|
1883
|
+
}
|
|
1884
|
+
//#endregion
|
|
1808
1885
|
//#region src/bundlers/vite/tailwind-basedir.ts
|
|
1809
1886
|
const PACKAGE_JSON_FILE = "package.json";
|
|
1810
1887
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
@@ -1876,7 +1953,6 @@ function WeappTailwindcss(options = {}) {
|
|
|
1876
1953
|
const shouldOwnTailwindGeneration = !disabledOptions.plugin;
|
|
1877
1954
|
const shouldRewriteCssImports = tailwindcssMajorVersion >= 4;
|
|
1878
1955
|
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
1879
|
-
const isWebGeneratorTarget = generatorOptions.target === "web";
|
|
1880
1956
|
const shouldInferAppType = !hasExplicitAppType && generatorOptions.target !== "web";
|
|
1881
1957
|
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots({
|
|
1882
1958
|
...options,
|
|
@@ -2145,20 +2221,57 @@ function WeappTailwindcss(options = {}) {
|
|
|
2145
2221
|
const resolveHotTailwindCssModules = (ctx) => {
|
|
2146
2222
|
const modules = [];
|
|
2147
2223
|
const seenModules = /* @__PURE__ */ new Set();
|
|
2224
|
+
const collectModule = (mod) => {
|
|
2225
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
2226
|
+
if (!isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
2227
|
+
seenModules.add(mod);
|
|
2228
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
2229
|
+
modules.push(mod);
|
|
2230
|
+
};
|
|
2148
2231
|
for (const id of tailwindRootCssModuleIds) {
|
|
2149
|
-
const candidates = [
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
ctx.server.moduleGraph.invalidateModule(mod);
|
|
2157
|
-
modules.push(mod);
|
|
2158
|
-
}
|
|
2232
|
+
const candidates = [
|
|
2233
|
+
ctx.server.moduleGraph.getModuleById(id),
|
|
2234
|
+
ctx.server.moduleGraph.getModuleById(cleanUrl(id)),
|
|
2235
|
+
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
2236
|
+
...ctx.server.moduleGraph.getModulesByFile(cleanUrl(id)) ?? []
|
|
2237
|
+
];
|
|
2238
|
+
for (const mod of candidates) collectModule(mod);
|
|
2159
2239
|
}
|
|
2160
2240
|
return modules;
|
|
2161
2241
|
};
|
|
2242
|
+
const resolveModuleHotUrl = (mod) => {
|
|
2243
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
2244
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
2245
|
+
};
|
|
2246
|
+
const includesHotModule = (modules, target) => {
|
|
2247
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
2248
|
+
const targetId = target.id;
|
|
2249
|
+
return modules.some((mod) => {
|
|
2250
|
+
if (mod === target) return true;
|
|
2251
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
2252
|
+
});
|
|
2253
|
+
};
|
|
2254
|
+
const sendSupplementalCssHotUpdates = (ctx, cssModules) => {
|
|
2255
|
+
const updates = cssModules.filter((mod) => !includesHotModule(ctx.modules, mod)).map((mod) => {
|
|
2256
|
+
const hotUrl = resolveModuleHotUrl(mod);
|
|
2257
|
+
if (!hotUrl) return;
|
|
2258
|
+
return {
|
|
2259
|
+
type: "js-update",
|
|
2260
|
+
timestamp: ctx.timestamp,
|
|
2261
|
+
path: hotUrl,
|
|
2262
|
+
acceptedPath: hotUrl,
|
|
2263
|
+
explicitImportRequired: false,
|
|
2264
|
+
isWithinCircularImport: false
|
|
2265
|
+
};
|
|
2266
|
+
}).filter((update) => update !== void 0);
|
|
2267
|
+
if (updates.length === 0) return;
|
|
2268
|
+
queueMicrotask(() => {
|
|
2269
|
+
ctx.server.ws?.send?.({
|
|
2270
|
+
type: "update",
|
|
2271
|
+
updates
|
|
2272
|
+
});
|
|
2273
|
+
});
|
|
2274
|
+
};
|
|
2162
2275
|
const matchesViteProcessedCssSource = (candidate) => {
|
|
2163
2276
|
const normalized = normalizeViteProcessedCssFile(candidate);
|
|
2164
2277
|
return viteProcessedCssSourceFiles.has(normalized);
|
|
@@ -2259,7 +2372,6 @@ function WeappTailwindcss(options = {}) {
|
|
|
2259
2372
|
});
|
|
2260
2373
|
const isIosPlatform = resolveUniUtsPlatform().isAppIos;
|
|
2261
2374
|
const prepareTailwindGeneration = async () => {
|
|
2262
|
-
if (isWebGeneratorTarget && runtimeState.twPatcher.majorVersion !== 3) return;
|
|
2263
2375
|
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
2264
2376
|
await syncSourceCandidateScan();
|
|
2265
2377
|
};
|
|
@@ -2314,6 +2426,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
2314
2426
|
await syncChangedSourceCandidateFile(ctx.file);
|
|
2315
2427
|
invalidateRecordedGeneratorCandidates();
|
|
2316
2428
|
const cssModules = resolveHotTailwindCssModules(ctx);
|
|
2429
|
+
sendSupplementalCssHotUpdates(ctx, cssModules);
|
|
2317
2430
|
return cssModules.length > 0 ? [...ctx.modules, ...cssModules] : void 0;
|
|
2318
2431
|
}, { emit: false });
|
|
2319
2432
|
},
|
|
@@ -2323,6 +2436,12 @@ function WeappTailwindcss(options = {}) {
|
|
|
2323
2436
|
}, { emit: false });
|
|
2324
2437
|
}
|
|
2325
2438
|
},
|
|
2439
|
+
...createViteServeCssGenerationPlugins({
|
|
2440
|
+
generateCss: generateTailwindCssForVitePipeline,
|
|
2441
|
+
getCommand: () => resolvedConfig?.command,
|
|
2442
|
+
onTailwindRootCss: (id, code) => registerAutoCssSource(id, code),
|
|
2443
|
+
shouldGenerate: () => shouldOwnTailwindGeneration
|
|
2444
|
+
}),
|
|
2326
2445
|
{
|
|
2327
2446
|
name: `${vitePluginName}:post`,
|
|
2328
2447
|
enforce: "post",
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-BM_ksf1q.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-CqEF-Wx5.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|