weapp-tailwindcss 5.5.8 → 5.5.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/bundlers/vite/css-calc-stage.d.ts +8 -0
- package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/css-scope-graph.d.ts +5 -0
- package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer/options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-cache-task.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-result.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +3 -3
- package/dist/bundlers/vite/generate-bundle/scoped-generator-runtime-cache.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator-sources.d.ts +36 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +6 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/source-trace.d.ts +2 -0
- package/dist/bundlers/vite/runtime-class-set/cache.d.ts +14 -0
- package/dist/bundlers/vite/runtime-class-set/invalidation-plugin.d.ts +6 -0
- package/dist/bundlers/vite/runtime-class-set/lifecycle.d.ts +12 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +1 -2
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +1 -0
- package/dist/{compiler-DbwS3329.cjs → compiler-TvqqdOMD.cjs} +50 -38
- package/dist/{compiler-CThodfGH.js → compiler-v9sYta8W.js} +35 -30
- package/dist/core/compiler/generation-cache.d.ts +4 -2
- package/dist/core/compiler/root-store.d.ts +1 -1
- package/dist/core/compiler/source.d.ts +7 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{scoped-generator-DlQrVbuC.js → css-cleanup-B3xP5Qph.js} +26 -23
- package/dist/{generated-css-marker-B0RyziOH.cjs → generated-css-marker-nqjR6ntO.cjs} +102 -26
- package/dist/generation/pipeline/style-context.d.ts +3 -0
- package/dist/{generator-CxauQbx3.cjs → generator-B1sYQpWu.cjs} +165 -90
- package/dist/{generator-oKZ5mCJ5.js → generator-LqofzXgr.js} +155 -92
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-DhddVxGA.js → gulp-BCV0gOMb.js} +4 -4
- package/dist/{gulp-CngHA9cU.cjs → gulp-DrX6QS3N.cjs} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Dc4c1VRg.cjs → hmr-timing-B56wp7y-.cjs} +4 -4
- package/dist/{hmr-timing-xPpat-km.js → hmr-timing-Bb54exB0.js} +102 -26
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-EUud9R2K.cjs → pipeline-helpers-DJ3VZ01J.cjs} +3 -3
- 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/project-sources/candidates/view-memo.d.ts +7 -0
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-lbTwL6mD.cjs → scoped-generator-DqNb8nJG.cjs} +31 -24
- package/dist/{source-candidate-scan-signature-BjVQYL-C.js → source-candidate-scan-signature-BWLf4tuO.js} +2 -2
- package/dist/{source-candidate-scan-signature-nG-rg809.cjs → source-candidate-scan-signature-_ohG0ePd.cjs} +2 -2
- package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/raw-generation.d.ts +30 -0
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
- package/dist/{tailwindcss-kSd0ykiX.js → tailwindcss-XNfJSlhp.js} +2 -2
- package/dist/{tailwindcss-U3KIUegn.cjs → tailwindcss-uf04Iolj.cjs} +2 -2
- package/dist/{transform-DVg4q8hh.cjs → transform-CxVM0PfA.cjs} +3 -3
- package/dist/{transform-BAon9ykq.js → transform-D0NXKPmD.js} +3 -3
- package/dist/utils/stable-serialize.d.ts +1 -0
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-IX83wh_L.cjs → vite-C3Zh6iYK.cjs} +434 -209
- package/dist/{vite-D-RGkmOE.js → vite-D6_FxvdM.js} +434 -209
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{web-DHfZ_KC9.cjs → web-BzeWG_XO.cjs} +442 -155
- package/dist/{web--kA4HUTm.js → web-K3qAX4sN.js} +431 -156
- package/dist/{webpack-Bhkd27Rs.js → webpack-BZBqKB4Y.js} +6 -6
- package/dist/{webpack-BetjemzT.cjs → webpack-Dbj2uykF.cjs} +8 -8
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +5 -4
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { a as findTailwindConfig, f as resolveSourceScanEntries, l as getRuntimeClassSetSignature, v as source_scan_exports } from "./tailwindcss-
|
|
1
|
+
import { a as findTailwindConfig, f as resolveSourceScanEntries, l as getRuntimeClassSetSignature, v as source_scan_exports } from "./tailwindcss-XNfJSlhp.js";
|
|
2
2
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.js";
|
|
3
|
-
import { S as findNearestPackageRoot, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, i as normalizeWeappTailwindcssGeneratorOptions, k as resolveTailwindcssOptions } from "./generator-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { c as
|
|
3
|
+
import { S as findNearestPackageRoot, a as resolveGeneratorRuntimeBranch, b as isTailwindV4CssEntry, i as normalizeWeappTailwindcssGeneratorOptions, k as resolveTailwindcssOptions, l as resolveUniUtsPlatform } from "./generator-LqofzXgr.js";
|
|
4
|
+
import "./utils-MVwpU07P.js";
|
|
5
|
+
import { A as createTailwindRuntimeReadyPromise, M as refreshTailwindRuntimeState, N as createDebug, f as getCompilerContext, g as vitePluginName, i as disposeCompilerOwner, k as collectRuntimeClassSet, m as resolveStyleOptionsFromContext, n as createRuntimeAffectingSourceSignature, p as normalizeStyleHandlerMajorVersion, t as createCompilerRuntimeState } from "./compiler-v9sYta8W.js";
|
|
6
|
+
import { $ as createSourceCandidateEligibilityMatcher, H as stripRequestQuery, I as hasTailwindGeneratedCss, L as hasTailwindGeneratedCssMarkers, M as normalizeEmptyTailwindCustomVariants$1, N as captureFrameworkPostcssOptions, T as hasUserCssLayerBlocks, U as createRuntimeClassSetManager, V as isSourceStyleRequest, Y as createSourceCandidateCollector, Z as isSourceCandidateRequest, at as hasTailwindSourceDirectives, c as annotateCssSourceTrace, d as isCssSourceTraceEnabled, dt as finalizeCompilerShadowRun, f as generateTailwindV4Css, i as createBundlerGeneratedCssMarker, it as hasTailwindRootDirectives, nt as hasTailwindApplyDirective, o as parseBundlerGeneratedCssMarkerBlocks, ot as normalizeTailwindConfigDirectives$1, rt as hasTailwindNonRootGenerationDirectives, s as stripBundlerGeneratedCssMarkers, st as normalizeTailwindSourceForGenerator, t as createHmrTimingRecorder, tt as hasLocalCssImport, u as createCssTokenSourceMap, x as scoreTailwindV4CssSourceFileMatch } from "./hmr-timing-Bb54exB0.js";
|
|
7
|
+
import { c as getViteHookHandler, n as resolvePackageDir, o as normalizeStyleInjectorOptions, r as normalizeOutputPathKey, t as createSourceCandidateScanSignature } from "./source-candidate-scan-signature-BWLf4tuO.js";
|
|
7
8
|
import { existsSync, realpathSync } from "node:fs";
|
|
8
9
|
import path from "node:path";
|
|
9
10
|
import process$1 from "node:process";
|
|
10
|
-
import { applyConfiguredCssCalc, canProcessSourceStyleAsCss, collectImportedCssFiles, hasNonCommentCss, isStyleImportRequest, normalizeInjectableCssWithImports, removeTailwindEntryDirectivesFromCss, removeTailwindPostcssPlugins, resolvePostcssConfig, rewriteTailwindPackageImportStatements, stripTailwindConfigDirectives, transformWebCssCompat } from "@weapp-tailwindcss/postcss/transform";
|
|
11
|
+
import { applyConfiguredCssCalc, applyConfiguredCssUnits, canProcessSourceStyleAsCss, collectImportedCssFiles, createDeferredCssSourceMarker, hasNonCommentCss, isStyleImportRequest, normalizeInjectableCssWithImports, parseCssImportSpecifier, postcss, removeTailwindEntryDirectivesFromCss, removeTailwindPostcssPlugins, resolvePostcssConfig, rewriteTailwindPackageImportStatements, stripTailwindConfigDirectives, transformWebCssCompat } from "@weapp-tailwindcss/postcss/transform";
|
|
11
12
|
import { LRUCache } from "lru-cache";
|
|
12
13
|
import { cleanUrl as cleanUrl$1, ensurePosix } from "@weapp-tailwindcss/shared";
|
|
14
|
+
import { Buffer } from "node:buffer";
|
|
13
15
|
import { readFile } from "node:fs/promises";
|
|
14
16
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
15
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -202,6 +204,59 @@ function createViteCssAssetIdentityResolver(options) {
|
|
|
202
204
|
};
|
|
203
205
|
}
|
|
204
206
|
//#endregion
|
|
207
|
+
//#region src/bundlers/vite/css-calc-stage.ts
|
|
208
|
+
const deferredKeys = [
|
|
209
|
+
"cssCalc",
|
|
210
|
+
"rem2rpx",
|
|
211
|
+
"px2rpx",
|
|
212
|
+
"unitsToPx",
|
|
213
|
+
"unitConversion"
|
|
214
|
+
];
|
|
215
|
+
const deferredKeySet = new Set(deferredKeys);
|
|
216
|
+
const deferredOptions = Object.fromEntries(deferredKeys.map((key) => [key, false]));
|
|
217
|
+
/** 构建中保留原始单位和表达式;最终输出阶段仍读取用户的真实配置。 */
|
|
218
|
+
function createViteCssCalcStage(original, isBuild, getPlatform = () => void 0) {
|
|
219
|
+
const resolveFinalOptions = () => resolveStyleOptionsFromContext({
|
|
220
|
+
...original,
|
|
221
|
+
platform: original.cssOptions?.platform ?? original.platform ?? getPlatform()
|
|
222
|
+
}, original.tailwindRuntime.majorVersion);
|
|
223
|
+
const shouldDefer = () => {
|
|
224
|
+
if (!isBuild() || !(original.cssOptions?.cssCalc ?? original.cssCalc)) return false;
|
|
225
|
+
const finalOptions = resolveFinalOptions();
|
|
226
|
+
return finalOptions.uniAppX !== true && !resolveUniUtsPlatform(finalOptions.platform).isApp;
|
|
227
|
+
};
|
|
228
|
+
const defer = (options) => shouldDefer() ? {
|
|
229
|
+
...options,
|
|
230
|
+
...deferredOptions,
|
|
231
|
+
cssOptions: {
|
|
232
|
+
...options?.cssOptions,
|
|
233
|
+
...deferredOptions
|
|
234
|
+
}
|
|
235
|
+
} : options;
|
|
236
|
+
const styleHandler = Object.assign((css, options) => original.styleHandler(css, defer(options)), {
|
|
237
|
+
transformRoot: ((root, options) => original.styleHandler.transformRoot(root, defer(options))),
|
|
238
|
+
getPipeline: ((options) => original.styleHandler.getPipeline(defer(options)))
|
|
239
|
+
});
|
|
240
|
+
return {
|
|
241
|
+
options: new Proxy(original, { get(target, key, receiver) {
|
|
242
|
+
if (key === "styleHandler") return styleHandler;
|
|
243
|
+
if (shouldDefer()) {
|
|
244
|
+
if (deferredKeySet.has(key)) return false;
|
|
245
|
+
if (key === "cssOptions") return {
|
|
246
|
+
...target.cssOptions,
|
|
247
|
+
...deferredOptions
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return Reflect.get(target, key, receiver);
|
|
251
|
+
} }),
|
|
252
|
+
getFinalOptions: () => shouldDefer() ? {
|
|
253
|
+
...resolveFinalOptions(),
|
|
254
|
+
customPropertyValues: original.customPropertyValues
|
|
255
|
+
} : void 0,
|
|
256
|
+
shouldDefer
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
205
260
|
//#region src/bundlers/vite/processed-css-assets/style-files.ts
|
|
206
261
|
const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
|
|
207
262
|
function isCssOutputFile(file) {
|
|
@@ -1713,92 +1768,183 @@ function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
|
1713
1768
|
});
|
|
1714
1769
|
}
|
|
1715
1770
|
//#endregion
|
|
1716
|
-
//#region src/bundlers/vite/css-finalizer/
|
|
1717
|
-
function
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1771
|
+
//#region src/bundlers/vite/css-finalizer/css-scope-graph.ts
|
|
1772
|
+
function outputKey(file) {
|
|
1773
|
+
return path.posix.normalize(normalizeOutputPathKey(file));
|
|
1774
|
+
}
|
|
1775
|
+
function collectReachable(graph, roots) {
|
|
1776
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1777
|
+
const pending = [...roots];
|
|
1778
|
+
while (pending.length > 0) {
|
|
1779
|
+
const file = pending.pop();
|
|
1780
|
+
if (visited.has(file) || !graph.has(file)) continue;
|
|
1781
|
+
visited.add(file);
|
|
1782
|
+
pending.push(...graph.get(file));
|
|
1783
|
+
}
|
|
1784
|
+
return visited;
|
|
1785
|
+
}
|
|
1786
|
+
function collectSourceComponents(graph) {
|
|
1787
|
+
let nextIndex = 0;
|
|
1788
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
1789
|
+
const lowLinks = /* @__PURE__ */ new Map();
|
|
1790
|
+
const stack = [];
|
|
1791
|
+
const onStack = /* @__PURE__ */ new Set();
|
|
1792
|
+
const components = [];
|
|
1793
|
+
const owners = /* @__PURE__ */ new Map();
|
|
1794
|
+
const visit = (file) => {
|
|
1795
|
+
const index = nextIndex++;
|
|
1796
|
+
indexes.set(file, index);
|
|
1797
|
+
lowLinks.set(file, index);
|
|
1798
|
+
stack.push(file);
|
|
1799
|
+
onStack.add(file);
|
|
1800
|
+
for (const target of graph.get(file)) if (!indexes.has(target)) {
|
|
1801
|
+
visit(target);
|
|
1802
|
+
lowLinks.set(file, Math.min(lowLinks.get(file), lowLinks.get(target)));
|
|
1803
|
+
} else if (onStack.has(target)) lowLinks.set(file, Math.min(lowLinks.get(file), indexes.get(target)));
|
|
1804
|
+
if (lowLinks.get(file) !== index) return;
|
|
1805
|
+
const component = [];
|
|
1806
|
+
let member;
|
|
1807
|
+
do {
|
|
1808
|
+
member = stack.pop();
|
|
1809
|
+
onStack.delete(member);
|
|
1810
|
+
owners.set(member, components.length);
|
|
1811
|
+
component.push(member);
|
|
1812
|
+
} while (member !== file);
|
|
1813
|
+
components.push(component);
|
|
1814
|
+
};
|
|
1815
|
+
for (const file of graph.keys()) if (!indexes.has(file)) visit(file);
|
|
1816
|
+
const importedComponents = /* @__PURE__ */ new Set();
|
|
1817
|
+
for (const [file, targets] of graph) for (const target of targets) if (owners.get(file) !== owners.get(target)) importedComponents.add(owners.get(target));
|
|
1818
|
+
return components.filter((_, index) => !importedComponents.has(index));
|
|
1819
|
+
}
|
|
1820
|
+
/** 按最终入口及 CSS 导入关系收集每个样式产物可见的变量上下文。 */
|
|
1821
|
+
function collectCssCalcScopes(bundle, options) {
|
|
1822
|
+
const assets = new Map(Object.entries(bundle).flatMap(([key, output]) => {
|
|
1823
|
+
const file = outputKey(output.fileName || key);
|
|
1824
|
+
return output.type === "asset" && options.matchesCss(file) ? [[file, output]] : [];
|
|
1825
|
+
}));
|
|
1826
|
+
const graph = /* @__PURE__ */ new Map();
|
|
1827
|
+
const conditionalRoots = /* @__PURE__ */ new Set();
|
|
1828
|
+
for (const [file, asset] of assets) {
|
|
1829
|
+
const targets = /* @__PURE__ */ new Set();
|
|
1830
|
+
const source = typeof asset.source === "string" ? asset.source : Buffer.from(asset.source).toString();
|
|
1831
|
+
postcss.parse(source).walkAtRules("import", (rule) => {
|
|
1832
|
+
const params = rule.raws.params?.raw ?? rule.params;
|
|
1833
|
+
const parsed = parseCssImportSpecifier(params);
|
|
1834
|
+
const request = parsed?.specifier;
|
|
1835
|
+
if (!parsed || !request || /^(?:[a-z][a-z\d+.-]*:|\/|\\\\|#)/i.test(request)) return;
|
|
1836
|
+
const target = outputKey(path.posix.join(path.posix.dirname(file), outputKey(request.replace(/[?#].*$/, ""))));
|
|
1837
|
+
if (assets.has(target)) {
|
|
1838
|
+
targets.add(target);
|
|
1839
|
+
let conditional = params.slice(params.indexOf(parsed.raw) + parsed.raw.length).trim().length > 0 || Boolean(rule.raws.between?.trim());
|
|
1840
|
+
let ancestor = rule.parent;
|
|
1841
|
+
while (ancestor && ancestor.type !== "root" && !conditional) {
|
|
1842
|
+
conditional = ancestor.type === "atrule";
|
|
1843
|
+
ancestor = ancestor.parent;
|
|
1844
|
+
}
|
|
1845
|
+
if (conditional) conditionalRoots.add(target);
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
graph.set(file, targets);
|
|
1849
|
+
}
|
|
1850
|
+
for (const file of collectReachable(graph, conditionalRoots)) options.onConditionalSource?.(file);
|
|
1851
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
1852
|
+
const addScope = (roots) => {
|
|
1853
|
+
const visible = collectReachable(graph, roots);
|
|
1854
|
+
for (const file of visible) {
|
|
1855
|
+
const scope = scopes.get(file) ?? /* @__PURE__ */ new Set();
|
|
1856
|
+
for (const target of visible) scope.add(target);
|
|
1857
|
+
scopes.set(file, scope);
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
const chunks = new Map(Object.entries(bundle).flatMap(([key, output]) => output.type === "chunk" ? [[outputKey(output.fileName || key), output]] : []));
|
|
1861
|
+
for (const [file, entry] of chunks) {
|
|
1862
|
+
if (!entry.isEntry && !entry.isDynamicEntry) continue;
|
|
1863
|
+
const roots = /* @__PURE__ */ new Set();
|
|
1864
|
+
const entryName = path.posix.parse(file);
|
|
1865
|
+
const matchingAssets = [...assets.keys()].filter((assetFile) => {
|
|
1866
|
+
const assetName = path.posix.parse(assetFile);
|
|
1867
|
+
return assetName.dir === entryName.dir && assetName.name === entryName.name;
|
|
1868
|
+
});
|
|
1869
|
+
if (matchingAssets.length === 1) roots.add(matchingAssets[0]);
|
|
1870
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1871
|
+
const pending = [file];
|
|
1872
|
+
while (pending.length > 0) {
|
|
1873
|
+
const chunkFile = pending.pop();
|
|
1874
|
+
const chunk = chunks.get(chunkFile);
|
|
1875
|
+
if (!chunk || visited.has(chunkFile)) continue;
|
|
1876
|
+
visited.add(chunkFile);
|
|
1877
|
+
for (const css of chunk.viteMetadata?.importedCss ?? []) {
|
|
1878
|
+
const key = outputKey(css);
|
|
1879
|
+
if (assets.has(key)) roots.add(key);
|
|
1880
|
+
}
|
|
1881
|
+
for (const imported of chunk.imports) {
|
|
1882
|
+
const key = outputKey(imported);
|
|
1883
|
+
pending.push(chunks.has(key) ? key : outputKey(path.posix.join(path.posix.dirname(chunkFile), key)));
|
|
1884
|
+
}
|
|
1735
1885
|
}
|
|
1736
|
-
|
|
1886
|
+
addScope(roots);
|
|
1737
1887
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
const from = path.isAbsolute(file) ? file : outputRoot ? path.resolve(outputRoot, file) : file;
|
|
1741
|
-
return {
|
|
1742
|
-
...extraOptions,
|
|
1743
|
-
cssPreflight: opts.cssPreflight,
|
|
1744
|
-
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
1745
|
-
postcssOptions: { options: { from } },
|
|
1746
|
-
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
1747
|
-
};
|
|
1748
|
-
}
|
|
1749
|
-
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
1750
|
-
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
1751
|
-
appType: opts.appType,
|
|
1752
|
-
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
1753
|
-
tailwindcssMajorVersion: majorVersion,
|
|
1754
|
-
uniAppX: opts.uniAppX
|
|
1755
|
-
});
|
|
1756
|
-
if (!generatorOptions.enabled) return false;
|
|
1757
|
-
if (hasLocalCssImport(rawSource)) return false;
|
|
1758
|
-
if (hasTailwindGeneratedCssMarkers(rawSource)) return true;
|
|
1759
|
-
if (hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
1760
|
-
return processed && hasTailwindApplyDirective(rawSource) && shouldFinalizeProcessedCssAsset(opts, file);
|
|
1761
|
-
}
|
|
1762
|
-
function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
1763
|
-
return opts.mainCssChunkMatcher(file, opts.appType);
|
|
1764
|
-
}
|
|
1765
|
-
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
1766
|
-
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
1767
|
-
}
|
|
1768
|
-
function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
1769
|
-
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(context, cssPipelineStrategy);
|
|
1770
|
-
const defaultWebCssCompat = (value) => transformWebCssCompat(value, resolveViteWebCssCompatOptions(context));
|
|
1771
|
-
return cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
1772
|
-
...context,
|
|
1773
|
-
defaultWebCssCompat,
|
|
1774
|
-
removeScopedPreflight: (value) => value,
|
|
1775
|
-
shouldApplyWebCssCompat
|
|
1776
|
-
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
1888
|
+
for (const component of collectSourceComponents(graph)) if (component.some((file) => !scopes.has(file))) addScope(component);
|
|
1889
|
+
return scopes;
|
|
1777
1890
|
}
|
|
1778
1891
|
//#endregion
|
|
1779
1892
|
//#region src/bundlers/vite/css-finalizer/css-calc.ts
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
if (
|
|
1789
|
-
const
|
|
1790
|
-
const
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1893
|
+
const previousAssets = /* @__PURE__ */ new WeakMap();
|
|
1894
|
+
function readSource(asset) {
|
|
1895
|
+
return typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source);
|
|
1896
|
+
}
|
|
1897
|
+
/** 按最终消费作用域求值;保留原始表达式供后续 watch 构建重新判断。 */
|
|
1898
|
+
async function finalizeCssCalc(bundle, context, convertUnits = false) {
|
|
1899
|
+
const deferredOptions = context.getFinalCssCalcOptions?.();
|
|
1900
|
+
const options = deferredOptions ?? context.opts;
|
|
1901
|
+
if (!(options.cssOptions?.cssCalc ?? options.cssCalc)) return;
|
|
1902
|
+
const previous = previousAssets.get(context) ?? /* @__PURE__ */ new Map();
|
|
1903
|
+
const assets = new Map(Object.entries(bundle).flatMap(([key, output]) => {
|
|
1904
|
+
const file = normalizeOutputPathKey(output.fileName || key);
|
|
1905
|
+
return output.type === "asset" && context.opts.cssMatcher(file) && !context.opts.htmlMatcher(file) ? [[file, output]] : [];
|
|
1906
|
+
}));
|
|
1907
|
+
for (const [file, asset] of assets) {
|
|
1908
|
+
const prior = previous.get(file);
|
|
1909
|
+
if (prior?.asset === asset && readSource(asset) === prior.final) asset.source = prior.original;
|
|
1910
|
+
}
|
|
1911
|
+
const conditionalSources = /* @__PURE__ */ new Set();
|
|
1912
|
+
const scopes = collectCssCalcScopes(bundle, {
|
|
1913
|
+
matchesCss: (file) => assets.has(normalizeOutputPathKey(file)),
|
|
1914
|
+
onConditionalSource: (file) => conditionalSources.add(file)
|
|
1915
|
+
});
|
|
1916
|
+
const sources = new Map([...assets].map(([file, asset]) => [file, readSource(asset)]));
|
|
1917
|
+
const next = /* @__PURE__ */ new Map();
|
|
1918
|
+
for (const [file, asset] of assets) {
|
|
1919
|
+
const original = sources.get(file);
|
|
1920
|
+
const contextCss = [...scopes.get(file) ?? [file]].map((sourceFile) => {
|
|
1921
|
+
const source = sources.get(sourceFile) ?? "";
|
|
1922
|
+
return conditionalSources.has(sourceFile) ? `@media all{${source}}` : source;
|
|
1923
|
+
}).join("\n");
|
|
1924
|
+
const calculated = await applyConfiguredCssCalc(original, {
|
|
1925
|
+
...options,
|
|
1794
1926
|
contextCss
|
|
1795
1927
|
});
|
|
1928
|
+
const outDir = context.getResolvedConfig?.()?.build?.outDir;
|
|
1929
|
+
const root = context.getResolvedConfig?.()?.root;
|
|
1930
|
+
const css = convertUnits && deferredOptions ? await applyConfiguredCssUnits(calculated, {
|
|
1931
|
+
...options,
|
|
1932
|
+
postcssOptions: { options: { from: path.resolve(root ?? ".", outDir ?? ".", file) } }
|
|
1933
|
+
}) : calculated;
|
|
1934
|
+
next.set(file, {
|
|
1935
|
+
asset,
|
|
1936
|
+
original,
|
|
1937
|
+
final: css
|
|
1938
|
+
});
|
|
1796
1939
|
if (css !== original) {
|
|
1797
1940
|
asset.source = css;
|
|
1798
|
-
context.
|
|
1799
|
-
context.opts.onUpdate(asset.fileName, original, css);
|
|
1941
|
+
context.opts.onUpdate(asset.fileName || file, original, css);
|
|
1800
1942
|
}
|
|
1801
1943
|
}
|
|
1944
|
+
previousAssets.set(context, next);
|
|
1945
|
+
}
|
|
1946
|
+
function finalizeWebCssCalc(bundle, context) {
|
|
1947
|
+
return finalizeCssCalc(bundle, context, true);
|
|
1802
1948
|
}
|
|
1803
1949
|
//#endregion
|
|
1804
1950
|
//#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
|
|
@@ -1854,6 +2000,69 @@ function createGenericWebProductionBundleHooks(options) {
|
|
|
1854
2000
|
};
|
|
1855
2001
|
}
|
|
1856
2002
|
//#endregion
|
|
2003
|
+
//#region src/bundlers/vite/css-finalizer/options.ts
|
|
2004
|
+
function inferPlatformFromViteOutDir(outDir) {
|
|
2005
|
+
const segment = outDir ? path.basename(path.normalize(outDir)) : void 0;
|
|
2006
|
+
if (!segment) return;
|
|
2007
|
+
const normalized = segment.trim().toLowerCase();
|
|
2008
|
+
if (normalized === "h5" || normalized === "web" || normalized === "app" || normalized === "app-plus" || normalized.startsWith("app-") || normalized.startsWith("mp-") || normalized.startsWith("quickapp-webview")) return normalized;
|
|
2009
|
+
}
|
|
2010
|
+
function isAddWatchFileInvalidRollupPhaseError(error) {
|
|
2011
|
+
const candidate = error;
|
|
2012
|
+
return candidate?.code === "INVALID_ROLLUP_PHASE" || candidate?.pluginCode === "INVALID_ROLLUP_PHASE" || candidate?.message?.includes("Cannot call \"addWatchFile\" after the build has finished.") === true;
|
|
2013
|
+
}
|
|
2014
|
+
function registerGeneratorDependencies(ctx, dependencies) {
|
|
2015
|
+
if (typeof ctx.addWatchFile !== "function") return;
|
|
2016
|
+
for (const dependency of dependencies ?? []) try {
|
|
2017
|
+
ctx.addWatchFile(dependency);
|
|
2018
|
+
} catch (error) {
|
|
2019
|
+
if (isAddWatchFileInvalidRollupPhaseError(error)) {
|
|
2020
|
+
logger.debug("跳过生成模式依赖监听注册,当前 Rollup 阶段不允许 addWatchFile: %s", dependency);
|
|
2021
|
+
continue;
|
|
2022
|
+
}
|
|
2023
|
+
throw error;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
function createCssHandlerOptions(opts, majorVersion, file, outputRoot, extraOptions = {}) {
|
|
2027
|
+
const from = path.isAbsolute(file) ? file : outputRoot ? path.resolve(outputRoot, file) : file;
|
|
2028
|
+
return {
|
|
2029
|
+
...extraOptions,
|
|
2030
|
+
cssPreflight: opts.cssPreflight,
|
|
2031
|
+
isMainChunk: opts.mainCssChunkMatcher(file, opts.appType),
|
|
2032
|
+
postcssOptions: { options: { from } },
|
|
2033
|
+
...normalizeStyleHandlerMajorVersion(majorVersion) === void 0 ? {} : { majorVersion: 4 }
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
function shouldGenerateCssByGenerator(opts, majorVersion, file, rawSource, processed) {
|
|
2037
|
+
const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2038
|
+
appType: opts.appType,
|
|
2039
|
+
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
2040
|
+
tailwindcssMajorVersion: majorVersion,
|
|
2041
|
+
uniAppX: opts.uniAppX
|
|
2042
|
+
});
|
|
2043
|
+
if (!generatorOptions.enabled) return false;
|
|
2044
|
+
if (hasLocalCssImport(rawSource)) return false;
|
|
2045
|
+
if (hasTailwindGeneratedCssMarkers(rawSource)) return true;
|
|
2046
|
+
if (hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions.importFallback })) return true;
|
|
2047
|
+
return processed && hasTailwindApplyDirective(rawSource) && shouldFinalizeProcessedCssAsset(opts, file);
|
|
2048
|
+
}
|
|
2049
|
+
function shouldFinalizeProcessedCssAsset(opts, file) {
|
|
2050
|
+
return opts.mainCssChunkMatcher(file, opts.appType);
|
|
2051
|
+
}
|
|
2052
|
+
function collectViteProcessedCssSources(getViteProcessedCssAssetResults) {
|
|
2053
|
+
return [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css);
|
|
2054
|
+
}
|
|
2055
|
+
function finalizeWebCss(css, context, cssPipelineStrategy) {
|
|
2056
|
+
const shouldApplyWebCssCompat = shouldApplyViteWebCssCompat(context, cssPipelineStrategy);
|
|
2057
|
+
const defaultWebCssCompat = (value) => transformWebCssCompat(value, resolveViteWebCssCompatOptions(context));
|
|
2058
|
+
return cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
2059
|
+
...context,
|
|
2060
|
+
defaultWebCssCompat,
|
|
2061
|
+
removeScopedPreflight: (value) => value,
|
|
2062
|
+
shouldApplyWebCssCompat
|
|
2063
|
+
}) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
|
|
2064
|
+
}
|
|
2065
|
+
//#endregion
|
|
1857
2066
|
//#region src/bundlers/vite/css-finalizer/generic-web-fast-path.ts
|
|
1858
2067
|
function readAssetSource(asset) {
|
|
1859
2068
|
return typeof asset.source === "string" ? asset.source : asset.source.toString();
|
|
@@ -2346,8 +2555,9 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
2346
2555
|
};
|
|
2347
2556
|
}
|
|
2348
2557
|
if (!options.shouldRewrite) {
|
|
2349
|
-
|
|
2350
|
-
|
|
2558
|
+
const deferredCode = shouldOwnTailwindGeneration && hasTailwindRoot && !shouldGenerateInPreTransform ? `${normalizedCode}\n${createDeferredCssSourceMarker(id)}` : normalizedCode;
|
|
2559
|
+
if (deferredCode !== code) return {
|
|
2560
|
+
code: deferredCode,
|
|
2351
2561
|
map: null
|
|
2352
2562
|
};
|
|
2353
2563
|
return null;
|
|
@@ -2357,7 +2567,8 @@ function createRewriteCssImportsPlugins(options) {
|
|
|
2357
2567
|
appType: resolveAppType(),
|
|
2358
2568
|
rootImport
|
|
2359
2569
|
});
|
|
2360
|
-
const
|
|
2570
|
+
const transformed = shouldOwnTailwindGeneration ? stripTailwindConfigDirectives(rewritten ?? normalizedCode) : rewritten;
|
|
2571
|
+
const nextCode = shouldOwnTailwindGeneration && hasTailwindRoot && !shouldGenerateInPreTransform ? `${transformed ?? normalizedCode}\n${createDeferredCssSourceMarker(id)}` : transformed;
|
|
2361
2572
|
if (!nextCode || nextCode === code) return null;
|
|
2362
2573
|
return {
|
|
2363
2574
|
code: nextCode,
|
|
@@ -2370,6 +2581,79 @@ function hasVitePipelineTailwindGenerationDirective(code) {
|
|
|
2370
2581
|
return hasTailwindRootDirectives(code) || hasTailwindApplyDirective(code);
|
|
2371
2582
|
}
|
|
2372
2583
|
//#endregion
|
|
2584
|
+
//#region src/bundlers/vite/runtime-class-set/cache.ts
|
|
2585
|
+
/** 按失效版本串行刷新运行时,同版本请求共享任务,过期结果不进入缓存。 */
|
|
2586
|
+
function createRuntimeClassSetCache(options) {
|
|
2587
|
+
let revision = 0;
|
|
2588
|
+
let preparedRevision = -1;
|
|
2589
|
+
let value;
|
|
2590
|
+
let pending;
|
|
2591
|
+
let queue = Promise.resolve();
|
|
2592
|
+
let disposed = false;
|
|
2593
|
+
function invalidate() {
|
|
2594
|
+
revision++;
|
|
2595
|
+
value = void 0;
|
|
2596
|
+
pending = void 0;
|
|
2597
|
+
}
|
|
2598
|
+
function assertActive() {
|
|
2599
|
+
if (disposed) throw new Error("Vite runtime class set cache has been disposed");
|
|
2600
|
+
}
|
|
2601
|
+
function enqueue(operation) {
|
|
2602
|
+
const task = queue.then(operation);
|
|
2603
|
+
queue = task.catch(() => {});
|
|
2604
|
+
return task;
|
|
2605
|
+
}
|
|
2606
|
+
async function prepare(expectedRevision) {
|
|
2607
|
+
assertActive();
|
|
2608
|
+
if (expectedRevision !== revision || preparedRevision === expectedRevision) return;
|
|
2609
|
+
await options.refresh();
|
|
2610
|
+
if (expectedRevision === revision) preparedRevision = expectedRevision;
|
|
2611
|
+
}
|
|
2612
|
+
async function refresh() {
|
|
2613
|
+
do {
|
|
2614
|
+
const expectedRevision = revision;
|
|
2615
|
+
await enqueue(() => prepare(expectedRevision));
|
|
2616
|
+
} while (preparedRevision !== revision);
|
|
2617
|
+
}
|
|
2618
|
+
async function get() {
|
|
2619
|
+
while (true) {
|
|
2620
|
+
assertActive();
|
|
2621
|
+
if (value) return value;
|
|
2622
|
+
const expectedRevision = revision;
|
|
2623
|
+
pending ?? (pending = enqueue(async () => {
|
|
2624
|
+
await prepare(expectedRevision);
|
|
2625
|
+
if (expectedRevision !== revision) return;
|
|
2626
|
+
const next = await options.collect();
|
|
2627
|
+
if (expectedRevision === revision && !disposed) {
|
|
2628
|
+
value = next;
|
|
2629
|
+
return next;
|
|
2630
|
+
}
|
|
2631
|
+
}));
|
|
2632
|
+
const task = pending;
|
|
2633
|
+
try {
|
|
2634
|
+
const next = await task;
|
|
2635
|
+
if (next && expectedRevision === revision) return next;
|
|
2636
|
+
} finally {
|
|
2637
|
+
if (pending === task) pending = void 0;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
return {
|
|
2642
|
+
get,
|
|
2643
|
+
refresh,
|
|
2644
|
+
invalidate,
|
|
2645
|
+
peek: () => value,
|
|
2646
|
+
revision: () => revision,
|
|
2647
|
+
remember(next, expectedRevision) {
|
|
2648
|
+
if (!disposed && expectedRevision === revision) value = next;
|
|
2649
|
+
},
|
|
2650
|
+
dispose() {
|
|
2651
|
+
disposed = true;
|
|
2652
|
+
invalidate();
|
|
2653
|
+
}
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
//#endregion
|
|
2373
2657
|
//#region src/bundlers/vite/runtime-class-set.ts
|
|
2374
2658
|
function createViteRuntimeClassSet(options) {
|
|
2375
2659
|
const { opts, initialTailwindRuntime, refreshTailwindcssRuntime, uniAppXEnabled, customAttributesEntities, disabledDefaultTemplateHandler, debug } = options;
|
|
@@ -2387,8 +2671,25 @@ function createViteRuntimeClassSet(options) {
|
|
|
2387
2671
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
2388
2672
|
escapeMap: opts.escapeMap
|
|
2389
2673
|
});
|
|
2390
|
-
|
|
2391
|
-
|
|
2674
|
+
const runtimeCache = createRuntimeClassSetCache({
|
|
2675
|
+
async refresh() {
|
|
2676
|
+
await refreshTailwindRuntimeState(runtimeState, {
|
|
2677
|
+
force: true,
|
|
2678
|
+
clearCache: true
|
|
2679
|
+
});
|
|
2680
|
+
await runtimeState.readyPromise;
|
|
2681
|
+
},
|
|
2682
|
+
collect: () => collectRuntimeClassSet(runtimeState.tailwindRuntime, {
|
|
2683
|
+
force: true,
|
|
2684
|
+
skipRefresh: true,
|
|
2685
|
+
clearCache: true
|
|
2686
|
+
})
|
|
2687
|
+
});
|
|
2688
|
+
const disposeRuntimeState = runtimeState.dispose;
|
|
2689
|
+
runtimeState.dispose = () => {
|
|
2690
|
+
runtimeCache.dispose();
|
|
2691
|
+
disposeRuntimeState();
|
|
2692
|
+
};
|
|
2392
2693
|
let runtimeRefreshSignature;
|
|
2393
2694
|
let runtimeRefreshOptionsKey;
|
|
2394
2695
|
function resolveRuntimeRefreshOptions() {
|
|
@@ -2410,50 +2711,34 @@ function createViteRuntimeClassSet(options) {
|
|
|
2410
2711
|
optionsKey
|
|
2411
2712
|
};
|
|
2412
2713
|
}
|
|
2714
|
+
function invalidateRuntimeClassSet() {
|
|
2715
|
+
runtimeCache.invalidate();
|
|
2716
|
+
}
|
|
2413
2717
|
async function refreshRuntimeState(force) {
|
|
2414
2718
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
force: shouldRefresh,
|
|
2418
|
-
clearCache: force || invalidation.changed
|
|
2419
|
-
});
|
|
2420
|
-
if (invalidation.changed) debug("runtime signature changed, refresh triggered. signature: %s", invalidation.signature);
|
|
2421
|
-
if (refreshed) {
|
|
2422
|
-
runtimeSet = void 0;
|
|
2423
|
-
runtimeSetPromise = void 0;
|
|
2424
|
-
}
|
|
2719
|
+
if (force || invalidation.changed) invalidateRuntimeClassSet();
|
|
2720
|
+
await runtimeCache.refresh();
|
|
2425
2721
|
}
|
|
2426
2722
|
async function ensureRuntimeClassSet(force = false) {
|
|
2427
2723
|
const startedAt = performance.now();
|
|
2428
2724
|
const operationId = `vite-runtime-${Date.now()}-${runtimeState.revision}`;
|
|
2429
2725
|
const forceRuntimeRefresh = force || process$1.env["WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH"] === "1";
|
|
2430
|
-
await refreshRuntimeState(force);
|
|
2431
|
-
await runtimeState.readyPromise;
|
|
2432
|
-
if (!forceRuntimeRefresh && runtimeSet) return runtimeSet;
|
|
2433
2726
|
const invalidation = resolveRuntimeRefreshOptions();
|
|
2434
|
-
if (forceRuntimeRefresh ||
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2727
|
+
if (forceRuntimeRefresh || invalidation.changed) invalidateRuntimeClassSet();
|
|
2728
|
+
const cacheHit = runtimeCache.peek() !== void 0;
|
|
2729
|
+
const result = await runtimeCache.get();
|
|
2730
|
+
await runtimeState.events.emit({
|
|
2731
|
+
schemaVersion: 1,
|
|
2732
|
+
type: "diagnostic",
|
|
2733
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2734
|
+
adapter: "vite",
|
|
2735
|
+
phase: "candidate",
|
|
2736
|
+
revision: runtimeState.revision,
|
|
2737
|
+
operationId,
|
|
2738
|
+
durationMs: performance.now() - startedAt,
|
|
2739
|
+
cache: { hit: cacheHit }
|
|
2438
2740
|
});
|
|
2439
|
-
|
|
2440
|
-
try {
|
|
2441
|
-
runtimeSet = await task;
|
|
2442
|
-
await runtimeState.events.emit({
|
|
2443
|
-
schemaVersion: 1,
|
|
2444
|
-
type: "diagnostic",
|
|
2445
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2446
|
-
adapter: "vite",
|
|
2447
|
-
phase: "candidate",
|
|
2448
|
-
revision: runtimeState.revision,
|
|
2449
|
-
operationId,
|
|
2450
|
-
durationMs: performance.now() - startedAt,
|
|
2451
|
-
cache: { hit: !forceRuntimeRefresh && !invalidation.changed }
|
|
2452
|
-
});
|
|
2453
|
-
return runtimeSet;
|
|
2454
|
-
} finally {
|
|
2455
|
-
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
2456
|
-
}
|
|
2741
|
+
return result;
|
|
2457
2742
|
}
|
|
2458
2743
|
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false, options = {}) {
|
|
2459
2744
|
const startedAt = performance.now();
|
|
@@ -2465,21 +2750,17 @@ function createViteRuntimeClassSet(options) {
|
|
|
2465
2750
|
await refreshRuntimeState(shouldRefreshRuntime);
|
|
2466
2751
|
await runtimeState.readyPromise;
|
|
2467
2752
|
if (shouldRefreshRuntime) {
|
|
2468
|
-
runtimeSet = void 0;
|
|
2469
|
-
runtimeSetPromise = void 0;
|
|
2470
2753
|
await bundleRuntimeClassSetManager.reset();
|
|
2471
2754
|
await transformRuntimeClassSetManager.reset();
|
|
2472
2755
|
}
|
|
2756
|
+
const expectedRevision = runtimeCache.revision();
|
|
2473
2757
|
if (!forceRuntimeRefresh) try {
|
|
2474
|
-
const baseClassSet = options.baseClassSet ??
|
|
2475
|
-
force: invalidation.changed,
|
|
2476
|
-
clearCache: invalidation.changed
|
|
2477
|
-
});
|
|
2758
|
+
const baseClassSet = options.baseClassSet ?? await runtimeCache.get();
|
|
2478
2759
|
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.tailwindRuntime, snapshot, {
|
|
2479
2760
|
baseClassSet,
|
|
2480
2761
|
skipInitialFullScanWithBase: options.allowBaselineOnlyInitialSync
|
|
2481
2762
|
});
|
|
2482
|
-
|
|
2763
|
+
runtimeCache.remember(nextRuntimeSet, expectedRevision);
|
|
2483
2764
|
await runtimeState.events.emit({
|
|
2484
2765
|
schemaVersion: 1,
|
|
2485
2766
|
type: "diagnostic",
|
|
@@ -2497,35 +2778,26 @@ function createViteRuntimeClassSet(options) {
|
|
|
2497
2778
|
debug("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
2498
2779
|
await bundleRuntimeClassSetManager.reset();
|
|
2499
2780
|
}
|
|
2500
|
-
if (!forceRuntimeRefresh && !invalidation.changed &&
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2781
|
+
if (!forceRuntimeRefresh && !invalidation.changed && forceCollectBySource) invalidateRuntimeClassSet();
|
|
2782
|
+
const result = await runtimeCache.get();
|
|
2783
|
+
await runtimeState.events.emit({
|
|
2784
|
+
schemaVersion: 1,
|
|
2785
|
+
type: "diagnostic",
|
|
2786
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2787
|
+
adapter: "vite",
|
|
2788
|
+
phase: "candidate",
|
|
2789
|
+
revision: runtimeState.revision,
|
|
2790
|
+
operationId,
|
|
2791
|
+
durationMs: performance.now() - startedAt,
|
|
2792
|
+
cache: { hit: false },
|
|
2793
|
+
evidence: ["runtime-class-scan"]
|
|
2505
2794
|
});
|
|
2506
|
-
|
|
2507
|
-
try {
|
|
2508
|
-
runtimeSet = await task;
|
|
2509
|
-
await runtimeState.events.emit({
|
|
2510
|
-
schemaVersion: 1,
|
|
2511
|
-
type: "diagnostic",
|
|
2512
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2513
|
-
adapter: "vite",
|
|
2514
|
-
phase: "candidate",
|
|
2515
|
-
revision: runtimeState.revision,
|
|
2516
|
-
operationId,
|
|
2517
|
-
durationMs: performance.now() - startedAt,
|
|
2518
|
-
cache: { hit: false },
|
|
2519
|
-
evidence: ["runtime-class-scan"]
|
|
2520
|
-
});
|
|
2521
|
-
return runtimeSet;
|
|
2522
|
-
} finally {
|
|
2523
|
-
if (runtimeSetPromise === task) runtimeSetPromise = void 0;
|
|
2524
|
-
}
|
|
2795
|
+
return result;
|
|
2525
2796
|
}
|
|
2526
2797
|
return {
|
|
2527
2798
|
runtimeState,
|
|
2528
2799
|
refreshRuntimeState,
|
|
2800
|
+
invalidateRuntimeClassSet,
|
|
2529
2801
|
ensureRuntimeClassSet,
|
|
2530
2802
|
ensureBundleRuntimeClassSet
|
|
2531
2803
|
};
|
|
@@ -3380,6 +3652,7 @@ function createFrameworkSourceScanSession(options) {
|
|
|
3380
3652
|
pendingHotUpdateChangeByFile: pendingHotUpdateChangeByFile.size,
|
|
3381
3653
|
sourceCandidateScanCache: sourceCandidateScanCache.size
|
|
3382
3654
|
}),
|
|
3655
|
+
getWatchFiles: () => /* @__PURE__ */ new Set([...sourceScanEligibleFiles, ...sourceScanDependencies]),
|
|
3383
3656
|
invalidate,
|
|
3384
3657
|
isDependency,
|
|
3385
3658
|
matches: (file) => sourceScanMatcher?.(file) ?? true,
|
|
@@ -3472,7 +3745,8 @@ function resolveWebGeneratorOptions(opts) {
|
|
|
3472
3745
|
/** 创建不含 JS/template、分包和小程序 bundle 处理的 Generic Web Vite 插件。 */
|
|
3473
3746
|
function createCssOnlyVitePlugins(options = {}) {
|
|
3474
3747
|
const rawOptions = options;
|
|
3475
|
-
|
|
3748
|
+
let resolvedConfig;
|
|
3749
|
+
const cssCalcStage = createViteCssCalcStage("tailwindRuntime" in options ? options : getCompilerContext({
|
|
3476
3750
|
...rawOptions,
|
|
3477
3751
|
appType: void 0,
|
|
3478
3752
|
platform: "web",
|
|
@@ -3482,7 +3756,8 @@ function createCssOnlyVitePlugins(options = {}) {
|
|
|
3482
3756
|
} : { target: "web" },
|
|
3483
3757
|
__internalDeferMissingCssEntriesWarning: true,
|
|
3484
3758
|
__internalViteDeferRuntimeLogs: true
|
|
3485
|
-
});
|
|
3759
|
+
}), () => resolvedConfig?.command === "build");
|
|
3760
|
+
const opts = cssCalcStage.options;
|
|
3486
3761
|
const disabled = opts.disabled === true || typeof opts.disabled === "object" && opts.disabled.plugin === true;
|
|
3487
3762
|
const shouldGenerate = !disabled && resolveWebGeneratorOptions(opts).enabled;
|
|
3488
3763
|
const sourceCandidateCollector = createSourceCandidateCollector({
|
|
@@ -3512,7 +3787,6 @@ function createCssOnlyVitePlugins(options = {}) {
|
|
|
3512
3787
|
getGeneratorOptions: () => resolveWebGeneratorOptions(opts),
|
|
3513
3788
|
isRuntimeAffectingSource: () => false
|
|
3514
3789
|
});
|
|
3515
|
-
let resolvedConfig;
|
|
3516
3790
|
let recordedCandidates;
|
|
3517
3791
|
const processedCssRegistry = createFrameworkProcessedCssRegistry();
|
|
3518
3792
|
const processedCssAssets = /* @__PURE__ */ new WeakSet();
|
|
@@ -3651,6 +3925,7 @@ function createCssOnlyVitePlugins(options = {}) {
|
|
|
3651
3925
|
});
|
|
3652
3926
|
const finalizer = createViteWebCssFinalizerOutputPlugin({
|
|
3653
3927
|
opts,
|
|
3928
|
+
getFinalCssCalcOptions: cssCalcStage.getFinalOptions,
|
|
3654
3929
|
runtimeState,
|
|
3655
3930
|
ensureRuntimeClassSet: collectCssSourceCandidates,
|
|
3656
3931
|
debug,
|
|
@@ -3769,4 +4044,4 @@ function createGenericWebVitePlugins(options = {}) {
|
|
|
3769
4044
|
});
|
|
3770
4045
|
}
|
|
3771
4046
|
//#endregion
|
|
3772
|
-
export {
|
|
4047
|
+
export { resolveSfcStyleSourceFromOutputFile as $, createGenericWebProductionBundleHooks as A, cleanUrl$1 as At, sendFullReloadForUnresolvedHotUpdate as B, isMiniProgramStyleOutputFile as Bt, tryFinalizeGenericWebCss as C, canProcessViteSourceStyleAsCss as Ct, inferPlatformFromViteOutDir as D, resolveViteCssOutputFile as Dt, finalizeWebCss as E, resolveReplayCssOutputFile as Et, hasSelfAcceptingNonStyleHotModule as F, resolveViteCssPipelineRequestFile as Ft, shouldApplyViteWebCssCompat as G, getActiveViteSourceOutputRelationOwner as Gt, resolveViteModuleIdentity as H, createViteCssCalcStage as Ht, mergeHotModulesByIdentity as I, slash as It, hasSfcStyleSources as J, frameworkViteCapabilityProfile as Jt, collectChunkModuleIds as K, withViteSourceOutputRelationOwner as Kt, resolveHotSourceModules as L, createCssHandlerOptionsCache as Lt, shouldSkipGenericWebProductionSourceCandidates as M, isCSSRequest as Mt, finalizeCssCalc as N, isHTMLRequest as Nt, registerGeneratorDependencies as O, resolveViteCssPipelineOutputFile as Ot, finalizeWebCssCalc as P, normalizePath as Pt, resolveSfcStyleRequestFromKnownSource as Q, resolveHotSourceModulesByIds as R, resolveViteCssHandlerExtraOptions as Rt, createViteWebCssFinalizerOutputPlugin as S, SOURCE_STYLE_OUTPUT_EXT_RE as St, createCssHandlerOptions as T, resolveMiniProgramStyleOutputExtension as Tt, parseVueRequest as U, createViteCssAssetIdentityResolver as Ut, sendSupplementalCssHotUpdates as V, isRootStyleOutputFile as Vt, resolveViteWebCssCompatOptions as W, createViteSourceOutputRelationOwner as Wt, isSfcStyleSourceFile as X, hasTailwindGenerationSource as Y, normalizeSfcSourceFileForCompare as Z, normalizeVitePersistentCacheKey as _, removeDuplicateUnlinkedRootCssAssetsReferencedByHtml as _t, readViteHmrSource as a, collectImportedStyleFiles as at, shouldCollectTransformedSourceCandidates as b, posix as bt, createViteHmrCssModuleVersionFilterPlugin as c, createCssAssetPipelineContext as ct, createFrameworkCssGenerationQueue as d, hasNonCommentCss as dt, resolveSourceStyleSourceFromOutputFile as et, createViteCssGenerationPlugins as f, isMatchingGeneratedCssMarkerFile as ft, isMissingInternalCssSource as g, readAssetSource$1 as gt, hasVitePipelineTailwindGenerationDirective as h, normalizeMarkerOutputFile as ht, syncFrameworkSourceCandidatesForHotUpdate as i, clearAssetSource as it, createGenericWebProductionSourceCandidatesApply as j, formatPostcssSourceMap as jt, shouldGenerateCssByGenerator as k, resolveViteCssPipelineOutputFileFromSourceFile as kt, createViteHmrCssModuleVersionTracker as l, dedupeViteCssResults as lt, createRewriteCssImportsPlugins as m, normalizeInjectableCssForTargetWithImports as mt, createFrameworkTailwindRootCss as n, isMatchingCssSourceFile as nt, createFrameworkProcessedCssRegistry as o, collectMatchingGeneratedCssMarkerFiles as ot, createViteRuntimeClassSet as p, normalizeInjectableCssForTarget as pt, extractSfcStyleBlocks as q, createGenericWebViteCapabilityProfile as qt, createFrameworkSourceScanSession as r, appendCss as rt, createFrameworkPostPlugin as s, collectRootStyleBundleCssSources as st, createGenericWebVitePlugins as t, hasMatchingStyleFileBase as tt, createViteHmrCandidateState as u, getAssetFile as ut, summarizeStringCache as v, removeTailwindEntryDirectivesFromCss as vt, collectViteProcessedCssSources as w, normalizeCssSourceForCompare as wt, touchMapEntry as x, CSS_SOURCE_OUTPUT_EXT_RE as xt, createViteCssMemory as y, resolveViteProcessedCssAssetSource as yt, resolveHotTailwindCssModules as z, isCssOutputFile as zt };
|