weapp-tailwindcss 5.2.4 → 5.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +11 -4
- package/dist/bundlers/vite/hot-css-modules.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
- package/dist/bundlers/vite/shared/framework-tailwind-root-css.d.ts +19 -0
- package/dist/{gulp-Nhszi1kK.cjs → gulp-CPIE1yPk.cjs} +2 -2
- package/dist/{gulp-DSi73qr-.js → gulp-DCItlfoq.js} +1 -1
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-WgN_3dIC.js → hmr-timing-BevXxu6p.js} +20 -3
- package/dist/{hmr-timing-Cye_A4mI.cjs → hmr-timing-Chyd_Yfw.cjs} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/{pipeline-helpers-DMO0otI8.cjs → pipeline-helpers-Cwv-X4Rj.cjs} +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{source-candidate-scan-signature-D4X_VprL.cjs → source-candidate-scan-signature-DG5mQZ8o.cjs} +1 -1
- package/dist/{source-candidate-scan-signature-ZozKGBbH.js → source-candidate-scan-signature-DLFqYads.js} +1 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +13 -0
- package/dist/uni-app-x/vite.d.ts +6 -5
- package/dist/{v4-generation-core-CDI6ChiH.cjs → v4-generation-core-Dtmu8Yax.cjs} +20 -3
- package/dist/{vite-DTWQPkyq.js → vite-Bk1YU9L0.js} +240 -161
- package/dist/{vite-BvbnZ6aZ.cjs → vite-DmN_Y8Uk.cjs} +241 -162
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +2 -2
- package/dist/{webpack-Rx3u2_2x.js → webpack-DtkSnYyR.js} +2 -2
- package/dist/{webpack-B2ojv_HI.cjs → webpack-DvmrFist.cjs} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -3,10 +3,10 @@ import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPl
|
|
|
3
3
|
import { t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
4
4
|
import { _ as resolveTailwindV4EntriesFromCssCached, a as findTailwindConfig, f as createSourceScanMatcher, h as resolveTailwindV4CssDependencies, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-CTpCc_nd.js";
|
|
5
5
|
import "./utils-MVwpU07P.js";
|
|
6
|
-
import { $ as createCompilationDependencyChanges, C as createBundlerGeneratedCssMarker, D as annotateCssSourceTrace, E as stripBundlerGeneratedCssMarkers, F as isPureLocalCssImportWrapper, G as createRuntimeAffectingSourceSignature, K as disposeCompilerOwner, M as createRuntimeClassSetManager, O as createCssSourceTraceCacheSignature, Q as recordCompilationDependencyChanges, R as finalizeCompilerShadowRun, S as stripRequestQuery, T as parseBundlerGeneratedCssMarkerBlocks, V as createRuntimeCompilationBuildState, W as updateRuntimeCompilationBuildState, Y as AssetEmissionPlan, a as extractMarkedUserLayerComponentsCss, d as normalizeMiniProgramGeneratorCssSource, et as createSourceCandidateCollector, f as normalizeMiniProgramImportShell, h as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as processCachedTask, k as createCssTokenSourceMap, nt as isSourceCandidateRequest, o as mergeMarkedUserLayerComponentsCss, p as scoreTailwindV4CssSourceFileMatch, q as beginCompilerShadowRun, r as generateTailwindV4Css, rt as extractCandidatesFromSource, t as createHmrTimingRecorder, u as runWithConcurrency, w as hasBundlerGeneratedCssMarker, x as isSourceStyleRequest, z as buildRuntimeCompilationSnapshot } from "./hmr-timing-
|
|
6
|
+
import { $ as createCompilationDependencyChanges, C as createBundlerGeneratedCssMarker, D as annotateCssSourceTrace, E as stripBundlerGeneratedCssMarkers, F as isPureLocalCssImportWrapper, G as createRuntimeAffectingSourceSignature, K as disposeCompilerOwner, M as createRuntimeClassSetManager, O as createCssSourceTraceCacheSignature, Q as recordCompilationDependencyChanges, R as finalizeCompilerShadowRun, S as stripRequestQuery, T as parseBundlerGeneratedCssMarkerBlocks, V as createRuntimeCompilationBuildState, W as updateRuntimeCompilationBuildState, Y as AssetEmissionPlan, a as extractMarkedUserLayerComponentsCss, d as normalizeMiniProgramGeneratorCssSource, et as createSourceCandidateCollector, f as normalizeMiniProgramImportShell, h as captureFrameworkPostcssOptions, i as validateCandidatesByGenerator, j as processCachedTask, k as createCssTokenSourceMap, nt as isSourceCandidateRequest, o as mergeMarkedUserLayerComponentsCss, p as scoreTailwindV4CssSourceFileMatch, q as beginCompilerShadowRun, r as generateTailwindV4Css, rt as extractCandidatesFromSource, t as createHmrTimingRecorder, u as runWithConcurrency, w as hasBundlerGeneratedCssMarker, x as isSourceStyleRequest, z as buildRuntimeCompilationSnapshot } from "./hmr-timing-BevXxu6p.js";
|
|
7
7
|
import { h as createDebug, m as replaceWxml } from "./wxml-IBzZSaQC.js";
|
|
8
8
|
import { a as vitePluginName, c as collectRuntimeClassSet, d as refreshTailwindRuntimeState, f as normalizeFrameworkStylePlatform, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, s as toCustomAttributesEntities, t as getCompilerContext } from "./context-YAvTyPV2.js";
|
|
9
|
-
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-
|
|
9
|
+
import { _ as createBuiltinViteStyleInjectorPlugins, a as createCandidateSignature, c as getSnapshotHash, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, i as createScopedGeneratorSourceTraceMap, l as hasRuntimeAffectingSourceChanges, m as normalizeOutputPathKey, n as createScopedGeneratorCandidateSignature, o as createJsHashSalt, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, s as createLinkedImpactSignature, t as createSourceCandidateScanSignature, u as summarizeStringDiff, x as resolveViteFrameworkProfile, y as viteStyleInjectorDelegates } from "./source-candidate-scan-signature-DLFqYads.js";
|
|
10
10
|
import { t as logger$1 } from "./logger-BNzxZbZj.js";
|
|
11
11
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
@@ -5747,6 +5747,169 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5747
5747
|
};
|
|
5748
5748
|
}
|
|
5749
5749
|
//#endregion
|
|
5750
|
+
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5751
|
+
function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5752
|
+
const modules = [];
|
|
5753
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5754
|
+
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
5755
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5756
|
+
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(path.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
5757
|
+
const isHotSourceStyleModule = (id) => {
|
|
5758
|
+
if (!isSourceStyleRequest(id)) return false;
|
|
5759
|
+
const file = cleanUrl(id);
|
|
5760
|
+
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5761
|
+
if (outDir && isAbsoluteFilePath(file)) {
|
|
5762
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5763
|
+
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
5764
|
+
}
|
|
5765
|
+
return true;
|
|
5766
|
+
};
|
|
5767
|
+
const collectModule = (mod) => {
|
|
5768
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5769
|
+
const modId = mod.id ?? mod.url;
|
|
5770
|
+
if (!isHotSourceStyleModule(modId)) return;
|
|
5771
|
+
seenModules.add(mod);
|
|
5772
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
5773
|
+
modules.push(mod);
|
|
5774
|
+
};
|
|
5775
|
+
for (const id of tailwindRootCssModuleIds) {
|
|
5776
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
5777
|
+
for (const moduleId of [id, cleanUrl(id)]) {
|
|
5778
|
+
if (moduleId.length === 0 || seenModuleIds.has(moduleId)) continue;
|
|
5779
|
+
seenModuleIds.add(moduleId);
|
|
5780
|
+
const candidates = [ctx.server.moduleGraph.getModuleById(moduleId), ...ctx.server.moduleGraph.getModulesByFile(moduleId) ?? []];
|
|
5781
|
+
for (const mod of candidates) collectModule(mod);
|
|
5782
|
+
}
|
|
5783
|
+
}
|
|
5784
|
+
return modules;
|
|
5785
|
+
}
|
|
5786
|
+
function resolveHotSourceModules(ctx) {
|
|
5787
|
+
const modules = [];
|
|
5788
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5789
|
+
const collectModule = (mod) => {
|
|
5790
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5791
|
+
if (isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
5792
|
+
seenModules.add(mod);
|
|
5793
|
+
modules.push(mod);
|
|
5794
|
+
};
|
|
5795
|
+
for (const mod of ctx.modules) collectModule(mod);
|
|
5796
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
5797
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(cleanUrl(ctx.file)) ?? []) collectModule(mod);
|
|
5798
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
5799
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(cleanUrl(ctx.file)));
|
|
5800
|
+
return modules;
|
|
5801
|
+
}
|
|
5802
|
+
function resolveModuleHotUrl(mod) {
|
|
5803
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
5804
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
5805
|
+
}
|
|
5806
|
+
function isAbsoluteFilePath(file) {
|
|
5807
|
+
return path.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
5808
|
+
}
|
|
5809
|
+
function normalizeAbsoluteFilePath(file) {
|
|
5810
|
+
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(path.win32.resolve(file));
|
|
5811
|
+
return slash(path.resolve(file));
|
|
5812
|
+
}
|
|
5813
|
+
function isRootMiniProgramStyleUrl(file) {
|
|
5814
|
+
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
5815
|
+
}
|
|
5816
|
+
function resolveCssHotUrl(id, root) {
|
|
5817
|
+
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5818
|
+
const file = cleanUrl(id);
|
|
5819
|
+
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
5820
|
+
if (isRootMiniProgramStyleUrl(file)) return;
|
|
5821
|
+
return `${file}${suffix}`;
|
|
5822
|
+
}
|
|
5823
|
+
if (!isAbsoluteFilePath(file)) return;
|
|
5824
|
+
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5825
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5826
|
+
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5827
|
+
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5828
|
+
}
|
|
5829
|
+
function includesHotModule(modules, target) {
|
|
5830
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
5831
|
+
const targetId = target.id;
|
|
5832
|
+
return modules.some((mod) => {
|
|
5833
|
+
if (mod === target) return true;
|
|
5834
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
5835
|
+
});
|
|
5836
|
+
}
|
|
5837
|
+
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
5838
|
+
return {
|
|
5839
|
+
type: "js-update",
|
|
5840
|
+
timestamp,
|
|
5841
|
+
path: hotUrl,
|
|
5842
|
+
acceptedPath: hotUrl,
|
|
5843
|
+
explicitImportRequired: false,
|
|
5844
|
+
isWithinCircularImport: false
|
|
5845
|
+
};
|
|
5846
|
+
}
|
|
5847
|
+
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
5848
|
+
return modules.some((mod) => {
|
|
5849
|
+
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5850
|
+
});
|
|
5851
|
+
}
|
|
5852
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
5853
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
5854
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5855
|
+
const updates = [];
|
|
5856
|
+
for (const id of fallbackCssIds) {
|
|
5857
|
+
if (!isSourceStyleRequest(id)) continue;
|
|
5858
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
5859
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5860
|
+
seenUrls.add(hotUrl);
|
|
5861
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5862
|
+
}
|
|
5863
|
+
for (const mod of cssModules) {
|
|
5864
|
+
if (includesHotModule(ctx.modules, mod)) continue;
|
|
5865
|
+
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5866
|
+
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5867
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5868
|
+
seenUrls.add(hotUrl);
|
|
5869
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5870
|
+
}
|
|
5871
|
+
if (updates.length === 0) return;
|
|
5872
|
+
queueMicrotask(() => {
|
|
5873
|
+
ctx.server.ws?.send?.({
|
|
5874
|
+
type: "update",
|
|
5875
|
+
updates
|
|
5876
|
+
});
|
|
5877
|
+
});
|
|
5878
|
+
}
|
|
5879
|
+
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
5880
|
+
ctx.server.ws?.send?.({
|
|
5881
|
+
type: "full-reload",
|
|
5882
|
+
path: "*",
|
|
5883
|
+
triggeredBy: ctx.file
|
|
5884
|
+
});
|
|
5885
|
+
}
|
|
5886
|
+
//#endregion
|
|
5887
|
+
//#region src/uni-app-x/vite/native-hmr.ts
|
|
5888
|
+
function createUniAppXNativeHmrReloader(options) {
|
|
5889
|
+
let previousRuntimeClassSet;
|
|
5890
|
+
function remember(runtimeClassSet) {
|
|
5891
|
+
previousRuntimeClassSet = new Set(runtimeClassSet);
|
|
5892
|
+
return runtimeClassSet;
|
|
5893
|
+
}
|
|
5894
|
+
async function refreshBaseline() {
|
|
5895
|
+
return remember(await options.ensureRuntimeClassSet(true));
|
|
5896
|
+
}
|
|
5897
|
+
async function handleHotUpdate(ctx) {
|
|
5898
|
+
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5899
|
+
const cssModules = ctx.server?.moduleGraph ? resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
5900
|
+
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5901
|
+
const hasAddedClass = previousRuntimeClassSet !== void 0 && [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate));
|
|
5902
|
+
remember(currentRuntimeClassSet);
|
|
5903
|
+
if (hasAddedClass) sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
5904
|
+
return cssModules.length > 0 ? [.../* @__PURE__ */ new Set([...ctx.modules, ...cssModules])] : void 0;
|
|
5905
|
+
}
|
|
5906
|
+
return {
|
|
5907
|
+
handleHotUpdate,
|
|
5908
|
+
refreshBaseline,
|
|
5909
|
+
remember
|
|
5910
|
+
};
|
|
5911
|
+
}
|
|
5912
|
+
//#endregion
|
|
5750
5913
|
//#region src/uni-app-x/vite/native-target.ts
|
|
5751
5914
|
function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
5752
5915
|
let observedNativeAppBuildTarget = false;
|
|
@@ -5793,13 +5956,19 @@ function isCssModuleExport(code) {
|
|
|
5793
5956
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5794
5957
|
}
|
|
5795
5958
|
function createUniAppXPlugins(options) {
|
|
5796
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX } = options;
|
|
5959
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5797
5960
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
5798
5961
|
const utsPlatform = resolveUniUtsPlatform();
|
|
5799
5962
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5800
5963
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
5801
5964
|
let componentLocalStyleEnabled;
|
|
5802
5965
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5966
|
+
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5967
|
+
ensureRuntimeClassSet,
|
|
5968
|
+
isNativeAppBuildTarget,
|
|
5969
|
+
tailwindRootCssModuleIds,
|
|
5970
|
+
viteProcessedCssSourceFiles
|
|
5971
|
+
});
|
|
5803
5972
|
function shouldEnableComponentLocalStyle() {
|
|
5804
5973
|
if (!resolvedUniAppXOptions.componentLocalStyles.enabled) {
|
|
5805
5974
|
componentLocalStyleEnabled = false;
|
|
@@ -5827,7 +5996,7 @@ function createUniAppXPlugins(options) {
|
|
|
5827
5996
|
if (!styleHandlerOptions) {
|
|
5828
5997
|
styleHandlerOptions = omitUndefined({
|
|
5829
5998
|
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
5830
|
-
uniAppXCssTarget: resolveUniAppXCssTarget(id),
|
|
5999
|
+
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
5831
6000
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5832
6001
|
postcssOptions: { options: {
|
|
5833
6002
|
from: id,
|
|
@@ -5852,6 +6021,7 @@ function createUniAppXPlugins(options) {
|
|
|
5852
6021
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5853
6022
|
if (isCssModuleExport(code)) return;
|
|
5854
6023
|
const shouldGenerateCss = hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
6024
|
+
if (!isNativeAppBuildTarget(id) && !shouldGenerateCss) return;
|
|
5855
6025
|
harmonyApply.rememberSource(code, id);
|
|
5856
6026
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
|
|
5857
6027
|
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
|
|
@@ -5905,7 +6075,7 @@ function createUniAppXPlugins(options) {
|
|
|
5905
6075
|
enforce: "pre",
|
|
5906
6076
|
async buildStart() {
|
|
5907
6077
|
if (!isEnabled()) return;
|
|
5908
|
-
await
|
|
6078
|
+
await nativeHmrReloader.refreshBaseline();
|
|
5909
6079
|
},
|
|
5910
6080
|
async transform(code, id) {
|
|
5911
6081
|
if (!isEnabled()) return;
|
|
@@ -5917,6 +6087,7 @@ function createUniAppXPlugins(options) {
|
|
|
5917
6087
|
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
5918
6088
|
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
5919
6089
|
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6090
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
5920
6091
|
const transformUVue = await loadTransformUVue();
|
|
5921
6092
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
5922
6093
|
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
@@ -5940,7 +6111,7 @@ function createUniAppXPlugins(options) {
|
|
|
5940
6111
|
if (!isEnabled()) return;
|
|
5941
6112
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
5942
6113
|
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
5943
|
-
|
|
6114
|
+
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
5944
6115
|
},
|
|
5945
6116
|
async watchChange(id) {
|
|
5946
6117
|
if (!isEnabled()) return;
|
|
@@ -8845,142 +9016,6 @@ function sameStringList(first, second) {
|
|
|
8845
9016
|
return first.every((item, index) => item === second[index]);
|
|
8846
9017
|
}
|
|
8847
9018
|
//#endregion
|
|
8848
|
-
//#region src/bundlers/vite/hot-css-modules.ts
|
|
8849
|
-
function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
8850
|
-
const modules = [];
|
|
8851
|
-
const seenModules = /* @__PURE__ */ new Set();
|
|
8852
|
-
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
8853
|
-
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(path.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
8854
|
-
const isHotSourceStyleModule = (id) => {
|
|
8855
|
-
if (!isSourceStyleRequest(id)) return false;
|
|
8856
|
-
const file = cleanUrl(id);
|
|
8857
|
-
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
8858
|
-
if (outDir && isAbsoluteFilePath(file)) {
|
|
8859
|
-
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
8860
|
-
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
8861
|
-
}
|
|
8862
|
-
return true;
|
|
8863
|
-
};
|
|
8864
|
-
const collectModule = (mod) => {
|
|
8865
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
8866
|
-
const modId = mod.id ?? mod.url;
|
|
8867
|
-
if (!isHotSourceStyleModule(modId)) return;
|
|
8868
|
-
seenModules.add(mod);
|
|
8869
|
-
ctx.server.moduleGraph.invalidateModule(mod);
|
|
8870
|
-
modules.push(mod);
|
|
8871
|
-
};
|
|
8872
|
-
for (const id of tailwindRootCssModuleIds) {
|
|
8873
|
-
const candidates = [
|
|
8874
|
-
ctx.server.moduleGraph.getModuleById(id),
|
|
8875
|
-
ctx.server.moduleGraph.getModuleById(cleanUrl(id)),
|
|
8876
|
-
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
8877
|
-
...ctx.server.moduleGraph.getModulesByFile(cleanUrl(id)) ?? []
|
|
8878
|
-
];
|
|
8879
|
-
for (const mod of candidates) collectModule(mod);
|
|
8880
|
-
}
|
|
8881
|
-
return modules;
|
|
8882
|
-
}
|
|
8883
|
-
function resolveHotSourceModules(ctx) {
|
|
8884
|
-
const modules = [];
|
|
8885
|
-
const seenModules = /* @__PURE__ */ new Set();
|
|
8886
|
-
const collectModule = (mod) => {
|
|
8887
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
8888
|
-
if (isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
8889
|
-
seenModules.add(mod);
|
|
8890
|
-
modules.push(mod);
|
|
8891
|
-
};
|
|
8892
|
-
for (const mod of ctx.modules) collectModule(mod);
|
|
8893
|
-
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
8894
|
-
for (const mod of ctx.server.moduleGraph.getModulesByFile(cleanUrl(ctx.file)) ?? []) collectModule(mod);
|
|
8895
|
-
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
8896
|
-
collectModule(ctx.server.moduleGraph.getModuleById?.(cleanUrl(ctx.file)));
|
|
8897
|
-
return modules;
|
|
8898
|
-
}
|
|
8899
|
-
function resolveModuleHotUrl(mod) {
|
|
8900
|
-
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
8901
|
-
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
8902
|
-
}
|
|
8903
|
-
function isAbsoluteFilePath(file) {
|
|
8904
|
-
return path.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
8905
|
-
}
|
|
8906
|
-
function normalizeAbsoluteFilePath(file) {
|
|
8907
|
-
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(path.win32.resolve(file));
|
|
8908
|
-
return slash(path.resolve(file));
|
|
8909
|
-
}
|
|
8910
|
-
function isRootMiniProgramStyleUrl(file) {
|
|
8911
|
-
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
8912
|
-
}
|
|
8913
|
-
function resolveCssHotUrl(id, root) {
|
|
8914
|
-
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
8915
|
-
const file = cleanUrl(id);
|
|
8916
|
-
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
8917
|
-
if (isRootMiniProgramStyleUrl(file)) return;
|
|
8918
|
-
return `${file}${suffix}`;
|
|
8919
|
-
}
|
|
8920
|
-
if (!isAbsoluteFilePath(file)) return;
|
|
8921
|
-
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
8922
|
-
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
8923
|
-
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
8924
|
-
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
8925
|
-
}
|
|
8926
|
-
function includesHotModule(modules, target) {
|
|
8927
|
-
const targetUrl = resolveModuleHotUrl(target);
|
|
8928
|
-
const targetId = target.id;
|
|
8929
|
-
return modules.some((mod) => {
|
|
8930
|
-
if (mod === target) return true;
|
|
8931
|
-
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
8932
|
-
});
|
|
8933
|
-
}
|
|
8934
|
-
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
8935
|
-
return {
|
|
8936
|
-
type: "js-update",
|
|
8937
|
-
timestamp,
|
|
8938
|
-
path: hotUrl,
|
|
8939
|
-
acceptedPath: hotUrl,
|
|
8940
|
-
explicitImportRequired: false,
|
|
8941
|
-
isWithinCircularImport: false
|
|
8942
|
-
};
|
|
8943
|
-
}
|
|
8944
|
-
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
8945
|
-
return modules.some((mod) => {
|
|
8946
|
-
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
8947
|
-
});
|
|
8948
|
-
}
|
|
8949
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
8950
|
-
const seenUrls = /* @__PURE__ */ new Set();
|
|
8951
|
-
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
8952
|
-
const updates = [];
|
|
8953
|
-
for (const id of fallbackCssIds) {
|
|
8954
|
-
if (!isSourceStyleRequest(id)) continue;
|
|
8955
|
-
const hotUrl = resolveCssHotUrl(id, root);
|
|
8956
|
-
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
8957
|
-
seenUrls.add(hotUrl);
|
|
8958
|
-
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
8959
|
-
}
|
|
8960
|
-
for (const mod of cssModules) {
|
|
8961
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
8962
|
-
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
8963
|
-
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
8964
|
-
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
8965
|
-
seenUrls.add(hotUrl);
|
|
8966
|
-
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
8967
|
-
}
|
|
8968
|
-
if (updates.length === 0) return;
|
|
8969
|
-
queueMicrotask(() => {
|
|
8970
|
-
ctx.server.ws?.send?.({
|
|
8971
|
-
type: "update",
|
|
8972
|
-
updates
|
|
8973
|
-
});
|
|
8974
|
-
});
|
|
8975
|
-
}
|
|
8976
|
-
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
8977
|
-
ctx.server.ws?.send?.({
|
|
8978
|
-
type: "full-reload",
|
|
8979
|
-
path: "*",
|
|
8980
|
-
triggeredBy: ctx.file
|
|
8981
|
-
});
|
|
8982
|
-
}
|
|
8983
|
-
//#endregion
|
|
8984
9019
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8985
9020
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
8986
9021
|
return {
|
|
@@ -9040,20 +9075,30 @@ function createFrameworkSourceCandidatesPlugin(options) {
|
|
|
9040
9075
|
options.hmrCandidateState.apply(options.hmrCandidateState.createChange(file, sourceCandidateChange, { runtimeAffecting: options.sourceScanSession.isDependency(file) }));
|
|
9041
9076
|
return;
|
|
9042
9077
|
}
|
|
9043
|
-
|
|
9078
|
+
const changedSource = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(id) && isCSSRequest(id) ? await readFile(cleanUrl(id), "utf8").catch(() => void 0) : void 0;
|
|
9079
|
+
if (typeof changedSource === "string") {
|
|
9080
|
+
options.rememberOriginalCssLayerSource(id, changedSource);
|
|
9081
|
+
await options.refreshTailwindRootCssSource(id, changedSource);
|
|
9082
|
+
}
|
|
9083
|
+
await options.sourceScanSession.syncChangedFile(id, changedSource);
|
|
9044
9084
|
}, { emit: false });
|
|
9045
9085
|
},
|
|
9046
9086
|
async handleHotUpdate(ctx) {
|
|
9047
9087
|
recordCompilationDependencyChanges(options.runtimeState, createCompilationDependencyChanges([path.resolve(cleanUrl(ctx.file))]));
|
|
9048
9088
|
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
9049
9089
|
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && isSourceCandidateRequest(ctx.file);
|
|
9050
|
-
if (isSourceCandidateHotUpdate && isSourceStyleRequest(ctx.file))
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9090
|
+
if (isSourceCandidateHotUpdate && isSourceStyleRequest(ctx.file)) {
|
|
9091
|
+
for (const mod of ctx.modules) for (const id of [
|
|
9092
|
+
mod.id,
|
|
9093
|
+
mod.url,
|
|
9094
|
+
mod.file
|
|
9095
|
+
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
9054
9096
|
}
|
|
9055
9097
|
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
|
|
9056
|
-
if (typeof hotSource === "string" && isCSSRequest(ctx.file))
|
|
9098
|
+
if (typeof hotSource === "string" && isCSSRequest(ctx.file)) {
|
|
9099
|
+
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
9100
|
+
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
9101
|
+
}
|
|
9057
9102
|
const sourceCandidateChange = await options.sourceScanSession.syncChangedFile(ctx.file, hotSource);
|
|
9058
9103
|
const isWebLikeHotUpdate = options.isCurrentWebLikeStylePlatform();
|
|
9059
9104
|
let canUseHmrCandidateAppend = false;
|
|
@@ -9261,6 +9306,39 @@ function createFrameworkSourceScanSession(options) {
|
|
|
9261
9306
|
};
|
|
9262
9307
|
}
|
|
9263
9308
|
//#endregion
|
|
9309
|
+
//#region src/bundlers/vite/shared/framework-tailwind-root-css.ts
|
|
9310
|
+
function createFrameworkTailwindRootCss(options) {
|
|
9311
|
+
const hotSourceByFile = /* @__PURE__ */ new Map();
|
|
9312
|
+
const moduleIds = /* @__PURE__ */ new Set();
|
|
9313
|
+
const normalizeSourceFile = (id) => path.normalize(path.resolve(cleanUrl(id)));
|
|
9314
|
+
const rememberModule = (id) => {
|
|
9315
|
+
if (!options.shouldOwnTailwindGeneration || typeof id !== "string" || id.length === 0) return;
|
|
9316
|
+
moduleIds.add(id);
|
|
9317
|
+
const cleanId = cleanUrl(id);
|
|
9318
|
+
if (isSourceStyleRequest(cleanId)) moduleIds.add(cleanId);
|
|
9319
|
+
};
|
|
9320
|
+
const register = async (id, code) => {
|
|
9321
|
+
rememberModule(id);
|
|
9322
|
+
const hotSource = hotSourceByFile.get(normalizeSourceFile(id));
|
|
9323
|
+
await options.registerAutoCssSource(id, hotSource ?? code);
|
|
9324
|
+
};
|
|
9325
|
+
const refreshSource = async (id, code) => {
|
|
9326
|
+
const file = cleanUrl(id);
|
|
9327
|
+
if (!moduleIds.has(id) && !moduleIds.has(file) && !hasTailwindRootDirectives(code, { importFallback: options.getImportFallback() })) return;
|
|
9328
|
+
hotSourceByFile.set(normalizeSourceFile(id), code);
|
|
9329
|
+
await register(id, code);
|
|
9330
|
+
options.sourceScanSession.invalidate();
|
|
9331
|
+
await options.refreshRuntimeState(true);
|
|
9332
|
+
await options.sourceScanSession.sync({ force: true });
|
|
9333
|
+
};
|
|
9334
|
+
return {
|
|
9335
|
+
refreshSource,
|
|
9336
|
+
register,
|
|
9337
|
+
rememberModule,
|
|
9338
|
+
moduleIds
|
|
9339
|
+
};
|
|
9340
|
+
}
|
|
9341
|
+
//#endregion
|
|
9264
9342
|
//#region src/bundlers/vite/shared/create-framework-plugins-runtime.ts
|
|
9265
9343
|
const debug = createDebug();
|
|
9266
9344
|
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
@@ -9485,7 +9563,6 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9485
9563
|
debug,
|
|
9486
9564
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file)
|
|
9487
9565
|
});
|
|
9488
|
-
const tailwindRootCssModuleIds = /* @__PURE__ */ new Set();
|
|
9489
9566
|
const { runtimeState, refreshRuntimeState, ensureRuntimeClassSet, ensureBundleRuntimeClassSet } = createViteRuntimeClassSet({
|
|
9490
9567
|
opts,
|
|
9491
9568
|
initialTailwindRuntime,
|
|
@@ -9556,6 +9633,13 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9556
9633
|
shouldOwnTailwindGeneration,
|
|
9557
9634
|
sourceCandidateCollector
|
|
9558
9635
|
});
|
|
9636
|
+
const { moduleIds: tailwindRootCssModuleIds, refreshSource: refreshTailwindRootCssSource, register: registerTailwindRootCss, rememberModule: rememberTailwindRootCssModule } = createFrameworkTailwindRootCss({
|
|
9637
|
+
getImportFallback: () => resolveCurrentGeneratorOptions().importFallback,
|
|
9638
|
+
refreshRuntimeState,
|
|
9639
|
+
registerAutoCssSource,
|
|
9640
|
+
shouldOwnTailwindGeneration,
|
|
9641
|
+
sourceScanSession
|
|
9642
|
+
});
|
|
9559
9643
|
const recordCssAssetResult = (file, css) => {
|
|
9560
9644
|
touchMapEntry(cleanGeneratedCssByFile, normalizeVitePersistentCacheKey(file), css);
|
|
9561
9645
|
};
|
|
@@ -9582,16 +9666,6 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
9582
9666
|
};
|
|
9583
9667
|
const normalizeViteProcessedCssFile = (file) => path.resolve(cleanUrl(file));
|
|
9584
9668
|
const markViteProcessedCssSource = processedCssRegistry.markSource;
|
|
9585
|
-
const rememberTailwindRootCssModule = (id) => {
|
|
9586
|
-
if (!shouldOwnTailwindGeneration) return;
|
|
9587
|
-
tailwindRootCssModuleIds.add(id);
|
|
9588
|
-
const cleanId = cleanUrl(id);
|
|
9589
|
-
if (isSourceStyleRequest(cleanId)) tailwindRootCssModuleIds.add(cleanId);
|
|
9590
|
-
};
|
|
9591
|
-
const registerTailwindRootCss = async (id, code) => {
|
|
9592
|
-
rememberTailwindRootCssModule(id);
|
|
9593
|
-
await registerAutoCssSource(id, code);
|
|
9594
|
-
};
|
|
9595
9669
|
const isUniViteProject = () => {
|
|
9596
9670
|
return resolvedConfig?.plugins?.some((plugin) => plugin.name.includes("uni")) ?? false;
|
|
9597
9671
|
};
|
|
@@ -9901,7 +9975,9 @@ ${tracedCss}`;
|
|
|
9901
9975
|
mainCssChunkMatcher,
|
|
9902
9976
|
runtimeState,
|
|
9903
9977
|
styleHandler,
|
|
9904
|
-
|
|
9978
|
+
tailwindRootCssModuleIds,
|
|
9979
|
+
uniAppX,
|
|
9980
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
9905
9981
|
}) ?? [];
|
|
9906
9982
|
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
9907
9983
|
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
@@ -9931,6 +10007,7 @@ ${tracedCss}`;
|
|
|
9931
10007
|
prepareTailwindGeneration,
|
|
9932
10008
|
preGenerateBundleHook,
|
|
9933
10009
|
refreshRuntimeStateForAutoCssSources,
|
|
10010
|
+
refreshTailwindRootCssSource,
|
|
9934
10011
|
rememberOriginalCssLayerSource,
|
|
9935
10012
|
rememberTailwindRootCssModule,
|
|
9936
10013
|
resolveCurrentGeneratorBranch,
|
|
@@ -10310,7 +10387,9 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10310
10387
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10311
10388
|
runtimeState: context.runtimeState,
|
|
10312
10389
|
styleHandler: context.styleHandler,
|
|
10313
|
-
|
|
10390
|
+
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10391
|
+
uniAppX: context.uniAppX,
|
|
10392
|
+
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|
|
10314
10393
|
})
|
|
10315
10394
|
});
|
|
10316
10395
|
}
|