weapp-tailwindcss 5.2.4 → 5.2.5
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/shared/create-framework-plugins.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.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/{vite-BvbnZ6aZ.cjs → vite-AB_sUPv9.cjs} +180 -142
- package/dist/{vite-DTWQPkyq.js → vite-Dafw4jK-.js} +180 -142
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +4 -4
|
@@ -31,6 +31,8 @@ export interface ViteFrameworkExtraPluginContext {
|
|
|
31
31
|
mainCssChunkMatcher: ReturnType<typeof getCompilerContext>['mainCssChunkMatcher'];
|
|
32
32
|
runtimeState: ReturnType<typeof createViteRuntimeClassSet>['runtimeState'];
|
|
33
33
|
styleHandler: ReturnType<typeof getCompilerContext>['styleHandler'];
|
|
34
|
+
tailwindRootCssModuleIds: Set<string>;
|
|
34
35
|
uniAppX: ReturnType<typeof getCompilerContext>['uniAppX'];
|
|
36
|
+
viteProcessedCssSourceFiles: Iterable<string>;
|
|
35
37
|
}
|
|
36
38
|
export declare function createViteFrameworkPlugins(options: (UserDefinedOptions | InternalUserDefinedOptions) | undefined, frameworkBranch: ViteFrameworkBranchContext): WeappTailwindcssVitePlugin[] | undefined;
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const require_framework = require("./framework.cjs");
|
|
|
3
3
|
const require_generator = require("./generator-BE34PYSC.cjs");
|
|
4
4
|
const require_gulp = require("./gulp-Nhszi1kK.cjs");
|
|
5
5
|
const require_postcss = require("./postcss.cjs");
|
|
6
|
-
const require_vite = require("./vite-
|
|
6
|
+
const require_vite = require("./vite-AB_sUPv9.cjs");
|
|
7
7
|
const require_webpack = require("./webpack-B2ojv_HI.cjs");
|
|
8
8
|
require("./webpack.cjs");
|
|
9
9
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMp
|
|
|
2
2
|
import { t as createWeappTailwindcssGenerator } from "./generator-DYeAa2-5.js";
|
|
3
3
|
import { t as createPlugins } from "./gulp-DSi73qr-.js";
|
|
4
4
|
import weappTailwindcssPostcssPlugin from "./postcss.js";
|
|
5
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
5
|
+
import { t as WeappTailwindcss } from "./vite-Dafw4jK-.js";
|
|
6
6
|
import { n as weappTailwindcssPackageDir } from "./webpack-Rx3u2_2x.js";
|
|
7
7
|
import "./webpack.js";
|
|
8
8
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HmrContext } from 'vite';
|
|
2
|
+
interface CreateUniAppXNativeHmrReloaderOptions {
|
|
3
|
+
ensureRuntimeClassSet: (force?: boolean) => Promise<Set<string>>;
|
|
4
|
+
isNativeAppBuildTarget: (id?: string) => boolean;
|
|
5
|
+
tailwindRootCssModuleIds: Iterable<string>;
|
|
6
|
+
viteProcessedCssSourceFiles: Iterable<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createUniAppXNativeHmrReloader(options: CreateUniAppXNativeHmrReloaderOptions): {
|
|
9
|
+
handleHotUpdate: (ctx: HmrContext) => Promise<import("vite").ModuleNode[] | undefined>;
|
|
10
|
+
refreshBaseline: () => Promise<Set<string>>;
|
|
11
|
+
remember: (runtimeClassSet: Set<string>) => Set<string>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/dist/uni-app-x/vite.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ import type { OutputAsset } from 'rollup';
|
|
|
2
2
|
import type { Plugin, ResolvedConfig } from 'vite';
|
|
3
3
|
import type { ICreateCacheReturnType } from '../cache/index.js';
|
|
4
4
|
import type { AppType, CreateJsHandlerOptions, ICustomAttributesEntities, InternalUserDefinedOptions, JsHandler, LinkedJsModuleResult } from '../types/index.js';
|
|
5
|
-
interface UniAppXRuntimeState {
|
|
6
|
-
readyPromise: Promise<unknown>;
|
|
7
|
-
}
|
|
8
5
|
interface CreateUniAppXPluginsOptions {
|
|
9
6
|
appType: AppType;
|
|
10
7
|
customAttributesEntities: ICustomAttributesEntities;
|
|
11
|
-
disabledDefaultTemplateHandler: boolean;
|
|
8
|
+
disabledDefaultTemplateHandler: boolean | undefined;
|
|
12
9
|
mainCssChunkMatcher: NonNullable<InternalUserDefinedOptions['mainCssChunkMatcher']>;
|
|
13
|
-
runtimeState:
|
|
10
|
+
runtimeState: {
|
|
11
|
+
readyPromise: Promise<unknown>;
|
|
12
|
+
};
|
|
14
13
|
styleHandler: InternalUserDefinedOptions['styleHandler'];
|
|
14
|
+
tailwindRootCssModuleIds?: Iterable<string> | undefined;
|
|
15
15
|
generateCss?: ((id: string, code: string, hookContext?: {
|
|
16
16
|
addWatchFile?: (id: string) => void;
|
|
17
17
|
transient?: boolean;
|
|
@@ -22,6 +22,7 @@ interface CreateUniAppXPluginsOptions {
|
|
|
22
22
|
isIosPlatform?: boolean;
|
|
23
23
|
isEnabled?: (() => boolean) | undefined;
|
|
24
24
|
uniAppX?: InternalUserDefinedOptions['uniAppX'];
|
|
25
|
+
viteProcessedCssSourceFiles?: Iterable<string> | undefined;
|
|
25
26
|
}
|
|
26
27
|
export declare function createUniAppXPlugins(options: CreateUniAppXPluginsOptions): Plugin[];
|
|
27
28
|
type ApplyLinkedResults = (linked: Record<string, LinkedJsModuleResult> | undefined) => void;
|
|
@@ -5756,6 +5756,168 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
5756
5756
|
};
|
|
5757
5757
|
}
|
|
5758
5758
|
//#endregion
|
|
5759
|
+
//#region src/bundlers/vite/hot-css-modules.ts
|
|
5760
|
+
function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
5761
|
+
const modules = [];
|
|
5762
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5763
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5764
|
+
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(node_path.default.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
5765
|
+
const isHotSourceStyleModule = (id) => {
|
|
5766
|
+
if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
|
|
5767
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5768
|
+
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5769
|
+
if (outDir && isAbsoluteFilePath(file)) {
|
|
5770
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5771
|
+
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
5772
|
+
}
|
|
5773
|
+
return true;
|
|
5774
|
+
};
|
|
5775
|
+
const collectModule = (mod) => {
|
|
5776
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5777
|
+
const modId = mod.id ?? mod.url;
|
|
5778
|
+
if (!isHotSourceStyleModule(modId)) return;
|
|
5779
|
+
seenModules.add(mod);
|
|
5780
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
5781
|
+
modules.push(mod);
|
|
5782
|
+
};
|
|
5783
|
+
for (const id of tailwindRootCssModuleIds) {
|
|
5784
|
+
const candidates = [
|
|
5785
|
+
ctx.server.moduleGraph.getModuleById(id),
|
|
5786
|
+
ctx.server.moduleGraph.getModuleById((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
5787
|
+
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
5788
|
+
...ctx.server.moduleGraph.getModulesByFile((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ?? []
|
|
5789
|
+
];
|
|
5790
|
+
for (const mod of candidates) collectModule(mod);
|
|
5791
|
+
}
|
|
5792
|
+
return modules;
|
|
5793
|
+
}
|
|
5794
|
+
function resolveHotSourceModules(ctx) {
|
|
5795
|
+
const modules = [];
|
|
5796
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5797
|
+
const collectModule = (mod) => {
|
|
5798
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5799
|
+
if (require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
5800
|
+
seenModules.add(mod);
|
|
5801
|
+
modules.push(mod);
|
|
5802
|
+
};
|
|
5803
|
+
for (const mod of ctx.modules) collectModule(mod);
|
|
5804
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
5805
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) ?? []) collectModule(mod);
|
|
5806
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
5807
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)));
|
|
5808
|
+
return modules;
|
|
5809
|
+
}
|
|
5810
|
+
function resolveModuleHotUrl(mod) {
|
|
5811
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
5812
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
5813
|
+
}
|
|
5814
|
+
function isAbsoluteFilePath(file) {
|
|
5815
|
+
return node_path.default.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
5816
|
+
}
|
|
5817
|
+
function normalizeAbsoluteFilePath(file) {
|
|
5818
|
+
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(node_path.default.win32.resolve(file));
|
|
5819
|
+
return slash(node_path.default.resolve(file));
|
|
5820
|
+
}
|
|
5821
|
+
function isRootMiniProgramStyleUrl(file) {
|
|
5822
|
+
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
5823
|
+
}
|
|
5824
|
+
function resolveCssHotUrl(id, root) {
|
|
5825
|
+
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5826
|
+
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
5827
|
+
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
5828
|
+
if (isRootMiniProgramStyleUrl(file)) return;
|
|
5829
|
+
return `${file}${suffix}`;
|
|
5830
|
+
}
|
|
5831
|
+
if (!isAbsoluteFilePath(file)) return;
|
|
5832
|
+
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5833
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5834
|
+
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5835
|
+
return `/${slash(node_path.default.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5836
|
+
}
|
|
5837
|
+
function includesHotModule(modules, target) {
|
|
5838
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
5839
|
+
const targetId = target.id;
|
|
5840
|
+
return modules.some((mod) => {
|
|
5841
|
+
if (mod === target) return true;
|
|
5842
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
5843
|
+
});
|
|
5844
|
+
}
|
|
5845
|
+
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
5846
|
+
return {
|
|
5847
|
+
type: "js-update",
|
|
5848
|
+
timestamp,
|
|
5849
|
+
path: hotUrl,
|
|
5850
|
+
acceptedPath: hotUrl,
|
|
5851
|
+
explicitImportRequired: false,
|
|
5852
|
+
isWithinCircularImport: false
|
|
5853
|
+
};
|
|
5854
|
+
}
|
|
5855
|
+
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
5856
|
+
return modules.some((mod) => {
|
|
5857
|
+
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5858
|
+
});
|
|
5859
|
+
}
|
|
5860
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
5861
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
5862
|
+
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
5863
|
+
const updates = [];
|
|
5864
|
+
for (const id of fallbackCssIds) {
|
|
5865
|
+
if (!require_v4_generation_core.isSourceStyleRequest(id)) continue;
|
|
5866
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
5867
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5868
|
+
seenUrls.add(hotUrl);
|
|
5869
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5870
|
+
}
|
|
5871
|
+
for (const mod of cssModules) {
|
|
5872
|
+
if (includesHotModule(ctx.modules, mod)) continue;
|
|
5873
|
+
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5874
|
+
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5875
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5876
|
+
seenUrls.add(hotUrl);
|
|
5877
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5878
|
+
}
|
|
5879
|
+
if (updates.length === 0) return;
|
|
5880
|
+
queueMicrotask(() => {
|
|
5881
|
+
ctx.server.ws?.send?.({
|
|
5882
|
+
type: "update",
|
|
5883
|
+
updates
|
|
5884
|
+
});
|
|
5885
|
+
});
|
|
5886
|
+
}
|
|
5887
|
+
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
5888
|
+
ctx.server.ws?.send?.({
|
|
5889
|
+
type: "full-reload",
|
|
5890
|
+
path: "*",
|
|
5891
|
+
triggeredBy: ctx.file
|
|
5892
|
+
});
|
|
5893
|
+
}
|
|
5894
|
+
//#endregion
|
|
5895
|
+
//#region src/uni-app-x/vite/native-hmr.ts
|
|
5896
|
+
function createUniAppXNativeHmrReloader(options) {
|
|
5897
|
+
let previousRuntimeClassSet;
|
|
5898
|
+
function remember(runtimeClassSet) {
|
|
5899
|
+
previousRuntimeClassSet = new Set(runtimeClassSet);
|
|
5900
|
+
return runtimeClassSet;
|
|
5901
|
+
}
|
|
5902
|
+
async function refreshBaseline() {
|
|
5903
|
+
return remember(await options.ensureRuntimeClassSet(true));
|
|
5904
|
+
}
|
|
5905
|
+
async function handleHotUpdate(ctx) {
|
|
5906
|
+
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5907
|
+
const cssModules = ctx.server?.moduleGraph ? resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
5908
|
+
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5909
|
+
const hasAddedClass = previousRuntimeClassSet !== void 0 && [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate));
|
|
5910
|
+
remember(currentRuntimeClassSet);
|
|
5911
|
+
if (hasAddedClass) sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
5912
|
+
return cssModules.length > 0 ? [.../* @__PURE__ */ new Set([...ctx.modules, ...cssModules])] : void 0;
|
|
5913
|
+
}
|
|
5914
|
+
return {
|
|
5915
|
+
handleHotUpdate,
|
|
5916
|
+
refreshBaseline,
|
|
5917
|
+
remember
|
|
5918
|
+
};
|
|
5919
|
+
}
|
|
5920
|
+
//#endregion
|
|
5759
5921
|
//#region src/uni-app-x/vite/native-target.ts
|
|
5760
5922
|
function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
5761
5923
|
let observedNativeAppBuildTarget = false;
|
|
@@ -5802,13 +5964,19 @@ function isCssModuleExport(code) {
|
|
|
5802
5964
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5803
5965
|
}
|
|
5804
5966
|
function createUniAppXPlugins(options) {
|
|
5805
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX } = options;
|
|
5967
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5806
5968
|
const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
|
|
5807
5969
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
5808
5970
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5809
5971
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
5810
5972
|
let componentLocalStyleEnabled;
|
|
5811
5973
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5974
|
+
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5975
|
+
ensureRuntimeClassSet,
|
|
5976
|
+
isNativeAppBuildTarget,
|
|
5977
|
+
tailwindRootCssModuleIds,
|
|
5978
|
+
viteProcessedCssSourceFiles
|
|
5979
|
+
});
|
|
5812
5980
|
function shouldEnableComponentLocalStyle() {
|
|
5813
5981
|
if (!resolvedUniAppXOptions.componentLocalStyles.enabled) {
|
|
5814
5982
|
componentLocalStyleEnabled = false;
|
|
@@ -5836,7 +6004,7 @@ function createUniAppXPlugins(options) {
|
|
|
5836
6004
|
if (!styleHandlerOptions) {
|
|
5837
6005
|
styleHandlerOptions = require_object.omitUndefined({
|
|
5838
6006
|
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
5839
|
-
uniAppXCssTarget: resolveUniAppXCssTarget(id),
|
|
6007
|
+
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
5840
6008
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5841
6009
|
postcssOptions: { options: {
|
|
5842
6010
|
from: id,
|
|
@@ -5861,6 +6029,7 @@ function createUniAppXPlugins(options) {
|
|
|
5861
6029
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5862
6030
|
if (isCssModuleExport(code)) return;
|
|
5863
6031
|
const shouldGenerateCss = require_generator.hasTailwindSourceDirectives(code, { importFallback: true }) || require_generator.hasTailwindApplyDirective(code);
|
|
6032
|
+
if (!isNativeAppBuildTarget(id) && !shouldGenerateCss) return;
|
|
5864
6033
|
harmonyApply.rememberSource(code, id);
|
|
5865
6034
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
|
|
5866
6035
|
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
|
|
@@ -5914,7 +6083,7 @@ function createUniAppXPlugins(options) {
|
|
|
5914
6083
|
enforce: "pre",
|
|
5915
6084
|
async buildStart() {
|
|
5916
6085
|
if (!isEnabled()) return;
|
|
5917
|
-
await
|
|
6086
|
+
await nativeHmrReloader.refreshBaseline();
|
|
5918
6087
|
},
|
|
5919
6088
|
async transform(code, id) {
|
|
5920
6089
|
if (!isEnabled()) return;
|
|
@@ -5926,6 +6095,7 @@ function createUniAppXPlugins(options) {
|
|
|
5926
6095
|
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
5927
6096
|
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
5928
6097
|
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6098
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
5929
6099
|
const transformUVue = await loadTransformUVue();
|
|
5930
6100
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
5931
6101
|
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
@@ -5949,7 +6119,7 @@ function createUniAppXPlugins(options) {
|
|
|
5949
6119
|
if (!isEnabled()) return;
|
|
5950
6120
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
5951
6121
|
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
5952
|
-
|
|
6122
|
+
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
5953
6123
|
},
|
|
5954
6124
|
async watchChange(id) {
|
|
5955
6125
|
if (!isEnabled()) return;
|
|
@@ -8826,142 +8996,6 @@ function sameStringList(first, second) {
|
|
|
8826
8996
|
return first.every((item, index) => item === second[index]);
|
|
8827
8997
|
}
|
|
8828
8998
|
//#endregion
|
|
8829
|
-
//#region src/bundlers/vite/hot-css-modules.ts
|
|
8830
|
-
function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds) {
|
|
8831
|
-
const modules = [];
|
|
8832
|
-
const seenModules = /* @__PURE__ */ new Set();
|
|
8833
|
-
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
8834
|
-
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(node_path.default.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
8835
|
-
const isHotSourceStyleModule = (id) => {
|
|
8836
|
-
if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
|
|
8837
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
8838
|
-
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
8839
|
-
if (outDir && isAbsoluteFilePath(file)) {
|
|
8840
|
-
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
8841
|
-
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
8842
|
-
}
|
|
8843
|
-
return true;
|
|
8844
|
-
};
|
|
8845
|
-
const collectModule = (mod) => {
|
|
8846
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
8847
|
-
const modId = mod.id ?? mod.url;
|
|
8848
|
-
if (!isHotSourceStyleModule(modId)) return;
|
|
8849
|
-
seenModules.add(mod);
|
|
8850
|
-
ctx.server.moduleGraph.invalidateModule(mod);
|
|
8851
|
-
modules.push(mod);
|
|
8852
|
-
};
|
|
8853
|
-
for (const id of tailwindRootCssModuleIds) {
|
|
8854
|
-
const candidates = [
|
|
8855
|
-
ctx.server.moduleGraph.getModuleById(id),
|
|
8856
|
-
ctx.server.moduleGraph.getModuleById((0, _weapp_tailwindcss_shared.cleanUrl)(id)),
|
|
8857
|
-
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
8858
|
-
...ctx.server.moduleGraph.getModulesByFile((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ?? []
|
|
8859
|
-
];
|
|
8860
|
-
for (const mod of candidates) collectModule(mod);
|
|
8861
|
-
}
|
|
8862
|
-
return modules;
|
|
8863
|
-
}
|
|
8864
|
-
function resolveHotSourceModules(ctx) {
|
|
8865
|
-
const modules = [];
|
|
8866
|
-
const seenModules = /* @__PURE__ */ new Set();
|
|
8867
|
-
const collectModule = (mod) => {
|
|
8868
|
-
if (mod == null || seenModules.has(mod)) return;
|
|
8869
|
-
if (require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
8870
|
-
seenModules.add(mod);
|
|
8871
|
-
modules.push(mod);
|
|
8872
|
-
};
|
|
8873
|
-
for (const mod of ctx.modules) collectModule(mod);
|
|
8874
|
-
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
8875
|
-
for (const mod of ctx.server.moduleGraph.getModulesByFile((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) ?? []) collectModule(mod);
|
|
8876
|
-
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
8877
|
-
collectModule(ctx.server.moduleGraph.getModuleById?.((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)));
|
|
8878
|
-
return modules;
|
|
8879
|
-
}
|
|
8880
|
-
function resolveModuleHotUrl(mod) {
|
|
8881
|
-
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
8882
|
-
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
8883
|
-
}
|
|
8884
|
-
function isAbsoluteFilePath(file) {
|
|
8885
|
-
return node_path.default.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
8886
|
-
}
|
|
8887
|
-
function normalizeAbsoluteFilePath(file) {
|
|
8888
|
-
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(node_path.default.win32.resolve(file));
|
|
8889
|
-
return slash(node_path.default.resolve(file));
|
|
8890
|
-
}
|
|
8891
|
-
function isRootMiniProgramStyleUrl(file) {
|
|
8892
|
-
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
8893
|
-
}
|
|
8894
|
-
function resolveCssHotUrl(id, root) {
|
|
8895
|
-
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
8896
|
-
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
8897
|
-
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
8898
|
-
if (isRootMiniProgramStyleUrl(file)) return;
|
|
8899
|
-
return `${file}${suffix}`;
|
|
8900
|
-
}
|
|
8901
|
-
if (!isAbsoluteFilePath(file)) return;
|
|
8902
|
-
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
8903
|
-
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
8904
|
-
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
8905
|
-
return `/${slash(node_path.default.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
8906
|
-
}
|
|
8907
|
-
function includesHotModule(modules, target) {
|
|
8908
|
-
const targetUrl = resolveModuleHotUrl(target);
|
|
8909
|
-
const targetId = target.id;
|
|
8910
|
-
return modules.some((mod) => {
|
|
8911
|
-
if (mod === target) return true;
|
|
8912
|
-
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
8913
|
-
});
|
|
8914
|
-
}
|
|
8915
|
-
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
8916
|
-
return {
|
|
8917
|
-
type: "js-update",
|
|
8918
|
-
timestamp,
|
|
8919
|
-
path: hotUrl,
|
|
8920
|
-
acceptedPath: hotUrl,
|
|
8921
|
-
explicitImportRequired: false,
|
|
8922
|
-
isWithinCircularImport: false
|
|
8923
|
-
};
|
|
8924
|
-
}
|
|
8925
|
-
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
8926
|
-
return modules.some((mod) => {
|
|
8927
|
-
return !require_v4_generation_core.isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
8928
|
-
});
|
|
8929
|
-
}
|
|
8930
|
-
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
8931
|
-
const seenUrls = /* @__PURE__ */ new Set();
|
|
8932
|
-
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
8933
|
-
const updates = [];
|
|
8934
|
-
for (const id of fallbackCssIds) {
|
|
8935
|
-
if (!require_v4_generation_core.isSourceStyleRequest(id)) continue;
|
|
8936
|
-
const hotUrl = resolveCssHotUrl(id, root);
|
|
8937
|
-
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
8938
|
-
seenUrls.add(hotUrl);
|
|
8939
|
-
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
8940
|
-
}
|
|
8941
|
-
for (const mod of cssModules) {
|
|
8942
|
-
if (includesHotModule(ctx.modules, mod)) continue;
|
|
8943
|
-
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
8944
|
-
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
8945
|
-
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
8946
|
-
seenUrls.add(hotUrl);
|
|
8947
|
-
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
8948
|
-
}
|
|
8949
|
-
if (updates.length === 0) return;
|
|
8950
|
-
queueMicrotask(() => {
|
|
8951
|
-
ctx.server.ws?.send?.({
|
|
8952
|
-
type: "update",
|
|
8953
|
-
updates
|
|
8954
|
-
});
|
|
8955
|
-
});
|
|
8956
|
-
}
|
|
8957
|
-
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
8958
|
-
ctx.server.ws?.send?.({
|
|
8959
|
-
type: "full-reload",
|
|
8960
|
-
path: "*",
|
|
8961
|
-
triggeredBy: ctx.file
|
|
8962
|
-
});
|
|
8963
|
-
}
|
|
8964
|
-
//#endregion
|
|
8965
8999
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8966
9000
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
8967
9001
|
return {
|
|
@@ -9882,7 +9916,9 @@ ${tracedCss}`;
|
|
|
9882
9916
|
mainCssChunkMatcher,
|
|
9883
9917
|
runtimeState,
|
|
9884
9918
|
styleHandler,
|
|
9885
|
-
|
|
9919
|
+
tailwindRootCssModuleIds,
|
|
9920
|
+
uniAppX,
|
|
9921
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
9886
9922
|
}) ?? [];
|
|
9887
9923
|
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
9888
9924
|
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
@@ -10291,7 +10327,9 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10291
10327
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10292
10328
|
runtimeState: context.runtimeState,
|
|
10293
10329
|
styleHandler: context.styleHandler,
|
|
10294
|
-
|
|
10330
|
+
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10331
|
+
uniAppX: context.uniAppX,
|
|
10332
|
+
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|
|
10295
10333
|
})
|
|
10296
10334
|
});
|
|
10297
10335
|
}
|
|
@@ -5747,6 +5747,168 @@ 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 root = ctx.server.config?.root ?? process$1.cwd();
|
|
5755
|
+
const outDir = ctx.server.config?.build?.outDir ? normalizeAbsoluteFilePath(path.resolve(root, ctx.server.config.build.outDir)) : void 0;
|
|
5756
|
+
const isHotSourceStyleModule = (id) => {
|
|
5757
|
+
if (!isSourceStyleRequest(id)) return false;
|
|
5758
|
+
const file = cleanUrl(id);
|
|
5759
|
+
if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
|
|
5760
|
+
if (outDir && isAbsoluteFilePath(file)) {
|
|
5761
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5762
|
+
if (normalizedFile === outDir || normalizedFile.startsWith(`${outDir}/`)) return false;
|
|
5763
|
+
}
|
|
5764
|
+
return true;
|
|
5765
|
+
};
|
|
5766
|
+
const collectModule = (mod) => {
|
|
5767
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5768
|
+
const modId = mod.id ?? mod.url;
|
|
5769
|
+
if (!isHotSourceStyleModule(modId)) return;
|
|
5770
|
+
seenModules.add(mod);
|
|
5771
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
5772
|
+
modules.push(mod);
|
|
5773
|
+
};
|
|
5774
|
+
for (const id of tailwindRootCssModuleIds) {
|
|
5775
|
+
const candidates = [
|
|
5776
|
+
ctx.server.moduleGraph.getModuleById(id),
|
|
5777
|
+
ctx.server.moduleGraph.getModuleById(cleanUrl(id)),
|
|
5778
|
+
...ctx.server.moduleGraph.getModulesByFile(id) ?? [],
|
|
5779
|
+
...ctx.server.moduleGraph.getModulesByFile(cleanUrl(id)) ?? []
|
|
5780
|
+
];
|
|
5781
|
+
for (const mod of candidates) collectModule(mod);
|
|
5782
|
+
}
|
|
5783
|
+
return modules;
|
|
5784
|
+
}
|
|
5785
|
+
function resolveHotSourceModules(ctx) {
|
|
5786
|
+
const modules = [];
|
|
5787
|
+
const seenModules = /* @__PURE__ */ new Set();
|
|
5788
|
+
const collectModule = (mod) => {
|
|
5789
|
+
if (mod == null || seenModules.has(mod)) return;
|
|
5790
|
+
if (isSourceStyleRequest(mod.id ?? mod.url)) return;
|
|
5791
|
+
seenModules.add(mod);
|
|
5792
|
+
modules.push(mod);
|
|
5793
|
+
};
|
|
5794
|
+
for (const mod of ctx.modules) collectModule(mod);
|
|
5795
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(ctx.file) ?? []) collectModule(mod);
|
|
5796
|
+
for (const mod of ctx.server.moduleGraph.getModulesByFile(cleanUrl(ctx.file)) ?? []) collectModule(mod);
|
|
5797
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(ctx.file));
|
|
5798
|
+
collectModule(ctx.server.moduleGraph.getModuleById?.(cleanUrl(ctx.file)));
|
|
5799
|
+
return modules;
|
|
5800
|
+
}
|
|
5801
|
+
function resolveModuleHotUrl(mod) {
|
|
5802
|
+
if (typeof mod.url === "string" && mod.url.length > 0) return mod.url;
|
|
5803
|
+
if (typeof mod.id === "string" && mod.id.startsWith("/")) return mod.id;
|
|
5804
|
+
}
|
|
5805
|
+
function isAbsoluteFilePath(file) {
|
|
5806
|
+
return path.isAbsolute(file) || /^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\");
|
|
5807
|
+
}
|
|
5808
|
+
function normalizeAbsoluteFilePath(file) {
|
|
5809
|
+
if (/^[A-Z]:[\\/]/i.test(file) || file.startsWith("\\\\")) return slash(path.win32.resolve(file));
|
|
5810
|
+
return slash(path.resolve(file));
|
|
5811
|
+
}
|
|
5812
|
+
function isRootMiniProgramStyleUrl(file) {
|
|
5813
|
+
return /^\/[^/]+\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
|
|
5814
|
+
}
|
|
5815
|
+
function resolveCssHotUrl(id, root) {
|
|
5816
|
+
const suffix = /[?#]/.test(id) ? id.slice(id.search(/[?#]/)) : "";
|
|
5817
|
+
const file = cleanUrl(id);
|
|
5818
|
+
if (/^\/(?![A-Z]:)/i.test(file) && !file.startsWith(slash(root))) {
|
|
5819
|
+
if (isRootMiniProgramStyleUrl(file)) return;
|
|
5820
|
+
return `${file}${suffix}`;
|
|
5821
|
+
}
|
|
5822
|
+
if (!isAbsoluteFilePath(file)) return;
|
|
5823
|
+
const normalizedRoot = normalizeAbsoluteFilePath(root);
|
|
5824
|
+
const normalizedFile = normalizeAbsoluteFilePath(file);
|
|
5825
|
+
if (!normalizedFile.startsWith(`${normalizedRoot}/`)) return;
|
|
5826
|
+
return `/${slash(path.relative(normalizedRoot, normalizedFile))}${suffix}`;
|
|
5827
|
+
}
|
|
5828
|
+
function includesHotModule(modules, target) {
|
|
5829
|
+
const targetUrl = resolveModuleHotUrl(target);
|
|
5830
|
+
const targetId = target.id;
|
|
5831
|
+
return modules.some((mod) => {
|
|
5832
|
+
if (mod === target) return true;
|
|
5833
|
+
return targetUrl !== void 0 && resolveModuleHotUrl(mod) === targetUrl || typeof targetId === "string" && targetId.length > 0 && mod.id === targetId;
|
|
5834
|
+
});
|
|
5835
|
+
}
|
|
5836
|
+
function createSupplementalHotUpdate(hotUrl, timestamp) {
|
|
5837
|
+
return {
|
|
5838
|
+
type: "js-update",
|
|
5839
|
+
timestamp,
|
|
5840
|
+
path: hotUrl,
|
|
5841
|
+
acceptedPath: hotUrl,
|
|
5842
|
+
explicitImportRequired: false,
|
|
5843
|
+
isWithinCircularImport: false
|
|
5844
|
+
};
|
|
5845
|
+
}
|
|
5846
|
+
function hasSelfAcceptingNonStyleHotModule(modules) {
|
|
5847
|
+
return modules.some((mod) => {
|
|
5848
|
+
return !isSourceStyleRequest(mod.id ?? mod.url) && mod.isSelfAccepting === true;
|
|
5849
|
+
});
|
|
5850
|
+
}
|
|
5851
|
+
function sendSupplementalCssHotUpdates(ctx, cssModules, fallbackCssIds = []) {
|
|
5852
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
5853
|
+
const root = ctx.server.config?.root ?? process$1.cwd();
|
|
5854
|
+
const updates = [];
|
|
5855
|
+
for (const id of fallbackCssIds) {
|
|
5856
|
+
if (!isSourceStyleRequest(id)) continue;
|
|
5857
|
+
const hotUrl = resolveCssHotUrl(id, root);
|
|
5858
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5859
|
+
seenUrls.add(hotUrl);
|
|
5860
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5861
|
+
}
|
|
5862
|
+
for (const mod of cssModules) {
|
|
5863
|
+
if (includesHotModule(ctx.modules, mod)) continue;
|
|
5864
|
+
const moduleHotUrl = resolveModuleHotUrl(mod);
|
|
5865
|
+
const hotUrl = moduleHotUrl ? resolveCssHotUrl(moduleHotUrl, root) : void 0;
|
|
5866
|
+
if (!hotUrl || seenUrls.has(hotUrl)) continue;
|
|
5867
|
+
seenUrls.add(hotUrl);
|
|
5868
|
+
updates.push(createSupplementalHotUpdate(hotUrl, ctx.timestamp));
|
|
5869
|
+
}
|
|
5870
|
+
if (updates.length === 0) return;
|
|
5871
|
+
queueMicrotask(() => {
|
|
5872
|
+
ctx.server.ws?.send?.({
|
|
5873
|
+
type: "update",
|
|
5874
|
+
updates
|
|
5875
|
+
});
|
|
5876
|
+
});
|
|
5877
|
+
}
|
|
5878
|
+
function sendFullReloadForUnresolvedHotUpdate(ctx) {
|
|
5879
|
+
ctx.server.ws?.send?.({
|
|
5880
|
+
type: "full-reload",
|
|
5881
|
+
path: "*",
|
|
5882
|
+
triggeredBy: ctx.file
|
|
5883
|
+
});
|
|
5884
|
+
}
|
|
5885
|
+
//#endregion
|
|
5886
|
+
//#region src/uni-app-x/vite/native-hmr.ts
|
|
5887
|
+
function createUniAppXNativeHmrReloader(options) {
|
|
5888
|
+
let previousRuntimeClassSet;
|
|
5889
|
+
function remember(runtimeClassSet) {
|
|
5890
|
+
previousRuntimeClassSet = new Set(runtimeClassSet);
|
|
5891
|
+
return runtimeClassSet;
|
|
5892
|
+
}
|
|
5893
|
+
async function refreshBaseline() {
|
|
5894
|
+
return remember(await options.ensureRuntimeClassSet(true));
|
|
5895
|
+
}
|
|
5896
|
+
async function handleHotUpdate(ctx) {
|
|
5897
|
+
if (!options.isNativeAppBuildTarget(ctx.file)) return;
|
|
5898
|
+
const cssModules = ctx.server?.moduleGraph ? resolveHotTailwindCssModules(ctx, /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles])) : [];
|
|
5899
|
+
const currentRuntimeClassSet = await options.ensureRuntimeClassSet(true);
|
|
5900
|
+
const hasAddedClass = previousRuntimeClassSet !== void 0 && [...currentRuntimeClassSet].some((candidate) => !previousRuntimeClassSet.has(candidate));
|
|
5901
|
+
remember(currentRuntimeClassSet);
|
|
5902
|
+
if (hasAddedClass) sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
5903
|
+
return cssModules.length > 0 ? [.../* @__PURE__ */ new Set([...ctx.modules, ...cssModules])] : void 0;
|
|
5904
|
+
}
|
|
5905
|
+
return {
|
|
5906
|
+
handleHotUpdate,
|
|
5907
|
+
refreshBaseline,
|
|
5908
|
+
remember
|
|
5909
|
+
};
|
|
5910
|
+
}
|
|
5911
|
+
//#endregion
|
|
5750
5912
|
//#region src/uni-app-x/vite/native-target.ts
|
|
5751
5913
|
function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
5752
5914
|
let observedNativeAppBuildTarget = false;
|
|
@@ -5793,13 +5955,19 @@ function isCssModuleExport(code) {
|
|
|
5793
5955
|
return CSS_MODULE_EXPORT_RE.test(code);
|
|
5794
5956
|
}
|
|
5795
5957
|
function createUniAppXPlugins(options) {
|
|
5796
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX } = options;
|
|
5958
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
5797
5959
|
const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
|
|
5798
5960
|
const utsPlatform = resolveUniUtsPlatform();
|
|
5799
5961
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
5800
5962
|
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
5801
5963
|
let componentLocalStyleEnabled;
|
|
5802
5964
|
const isNativeAppBuildTarget = createUniAppXNativeBuildTargetResolver(getResolvedConfig);
|
|
5965
|
+
const nativeHmrReloader = createUniAppXNativeHmrReloader({
|
|
5966
|
+
ensureRuntimeClassSet,
|
|
5967
|
+
isNativeAppBuildTarget,
|
|
5968
|
+
tailwindRootCssModuleIds,
|
|
5969
|
+
viteProcessedCssSourceFiles
|
|
5970
|
+
});
|
|
5803
5971
|
function shouldEnableComponentLocalStyle() {
|
|
5804
5972
|
if (!resolvedUniAppXOptions.componentLocalStyles.enabled) {
|
|
5805
5973
|
componentLocalStyleEnabled = false;
|
|
@@ -5827,7 +5995,7 @@ function createUniAppXPlugins(options) {
|
|
|
5827
5995
|
if (!styleHandlerOptions) {
|
|
5828
5996
|
styleHandlerOptions = omitUndefined({
|
|
5829
5997
|
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
5830
|
-
uniAppXCssTarget: resolveUniAppXCssTarget(id),
|
|
5998
|
+
uniAppXCssTarget: isNativeAppBuildTarget(id) ? resolveUniAppXCssTarget(id) : void 0,
|
|
5831
5999
|
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
5832
6000
|
postcssOptions: { options: {
|
|
5833
6001
|
from: id,
|
|
@@ -5852,6 +6020,7 @@ function createUniAppXPlugins(options) {
|
|
|
5852
6020
|
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
5853
6021
|
if (isCssModuleExport(code)) return;
|
|
5854
6022
|
const shouldGenerateCss = hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
6023
|
+
if (!isNativeAppBuildTarget(id) && !shouldGenerateCss) return;
|
|
5855
6024
|
harmonyApply.rememberSource(code, id);
|
|
5856
6025
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, code, hookContext) : void 0;
|
|
5857
6026
|
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? generatedCss : code;
|
|
@@ -5905,7 +6074,7 @@ function createUniAppXPlugins(options) {
|
|
|
5905
6074
|
enforce: "pre",
|
|
5906
6075
|
async buildStart() {
|
|
5907
6076
|
if (!isEnabled()) return;
|
|
5908
|
-
await
|
|
6077
|
+
await nativeHmrReloader.refreshBaseline();
|
|
5909
6078
|
},
|
|
5910
6079
|
async transform(code, id) {
|
|
5911
6080
|
if (!isEnabled()) return;
|
|
@@ -5917,6 +6086,7 @@ function createUniAppXPlugins(options) {
|
|
|
5917
6086
|
const isWatchBuild = resolvedConfig?.command === "build" && !!resolvedConfig.build?.watch;
|
|
5918
6087
|
const isNonWatchBuild = resolvedConfig?.command === "build" && !resolvedConfig.build?.watch;
|
|
5919
6088
|
const currentRuntimeSet = isServeCommand || isWatchBuild || isNonWatchBuild ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
6089
|
+
nativeHmrReloader.remember(currentRuntimeSet);
|
|
5920
6090
|
const transformUVue = await loadTransformUVue();
|
|
5921
6091
|
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
5922
6092
|
const enablePageLocalStyle = shouldEnableNativePageLocalStyle(id);
|
|
@@ -5940,7 +6110,7 @@ function createUniAppXPlugins(options) {
|
|
|
5940
6110
|
if (!isEnabled()) return;
|
|
5941
6111
|
if (getResolvedConfig()?.command !== "serve") return;
|
|
5942
6112
|
if (!UVUE_NVUE_RE.test(ctx.file)) return;
|
|
5943
|
-
|
|
6113
|
+
return nativeHmrReloader.handleHotUpdate(ctx);
|
|
5944
6114
|
},
|
|
5945
6115
|
async watchChange(id) {
|
|
5946
6116
|
if (!isEnabled()) return;
|
|
@@ -8845,142 +9015,6 @@ function sameStringList(first, second) {
|
|
|
8845
9015
|
return first.every((item, index) => item === second[index]);
|
|
8846
9016
|
}
|
|
8847
9017
|
//#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
9018
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
8985
9019
|
function createFrameworkSourceCandidatesPlugin(options) {
|
|
8986
9020
|
return {
|
|
@@ -9901,7 +9935,9 @@ ${tracedCss}`;
|
|
|
9901
9935
|
mainCssChunkMatcher,
|
|
9902
9936
|
runtimeState,
|
|
9903
9937
|
styleHandler,
|
|
9904
|
-
|
|
9938
|
+
tailwindRootCssModuleIds,
|
|
9939
|
+
uniAppX,
|
|
9940
|
+
viteProcessedCssSourceFiles: processedCssRegistry.sourceFiles
|
|
9905
9941
|
}) ?? [];
|
|
9906
9942
|
const installFrameworkWatchCssCacheAdapter = async (config) => {
|
|
9907
9943
|
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
@@ -10310,7 +10346,9 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
10310
10346
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
10311
10347
|
runtimeState: context.runtimeState,
|
|
10312
10348
|
styleHandler: context.styleHandler,
|
|
10313
|
-
|
|
10349
|
+
tailwindRootCssModuleIds: context.tailwindRootCssModuleIds,
|
|
10350
|
+
uniAppX: context.uniAppX,
|
|
10351
|
+
viteProcessedCssSourceFiles: context.viteProcessedCssSourceFiles
|
|
10314
10352
|
})
|
|
10315
10353
|
});
|
|
10316
10354
|
}
|
package/dist/vite.cjs
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-AB_sUPv9.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-Dafw4jK-.js";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.2.
|
|
4
|
+
"version": "5.2.5",
|
|
5
5
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -216,14 +216,14 @@
|
|
|
216
216
|
"semver": "~7.8.5",
|
|
217
217
|
"yaml": "^2.9.0",
|
|
218
218
|
"@weapp-tailwindcss/logger": "2.0.1",
|
|
219
|
-
"@weapp-tailwindcss/postcss": "3.2.
|
|
220
|
-
"@weapp-tailwindcss/shared": "2.0.1",
|
|
219
|
+
"@weapp-tailwindcss/postcss": "3.2.5",
|
|
221
220
|
"@weapp-tailwindcss/reset": "0.1.2",
|
|
221
|
+
"@weapp-tailwindcss/shared": "2.0.1",
|
|
222
222
|
"tailwindcss-config": "2.0.2",
|
|
223
223
|
"weapp-style-injector": "1.0.2"
|
|
224
224
|
},
|
|
225
225
|
"devDependencies": {
|
|
226
|
-
"@mpxjs/webpack-plugin": "^2.11.
|
|
226
|
+
"@mpxjs/webpack-plugin": "^2.11.1",
|
|
227
227
|
"webpack": "5.105.4"
|
|
228
228
|
},
|
|
229
229
|
"scripts": {
|