yuang-framework-ui-pc 1.1.92 → 1.1.93
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/es/utils/resolvers.d.ts +1 -1
- package/es/utils/resolvers.js +32 -42
- package/lib/utils/resolvers.cjs +32 -42
- package/lib/utils/resolvers.d.ts +1 -1
- package/package.json +1 -1
package/es/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件:支持所有 Ele/Yu 开头的组件
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|
package/es/utils/resolvers.js
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
function getSideEffects(path, options) {
|
|
2
2
|
if (!path) return void 0;
|
|
3
|
-
const importStyle = options == null ? void 0 : options.importStyle;
|
|
3
|
+
const importStyle = (options == null ? void 0 : options.importStyle) ?? true;
|
|
4
4
|
if (!importStyle) {
|
|
5
5
|
return void 0;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
return `${path}/style/css`;
|
|
9
|
-
}
|
|
10
|
-
return `${path}/style/index`;
|
|
7
|
+
return importStyle === "css" ? `${path}/style/css` : `${path}/style/index`;
|
|
11
8
|
}
|
|
12
9
|
function getStylePath(namePath, packageName, path = "/es") {
|
|
13
|
-
const safePath = path
|
|
14
|
-
if (
|
|
15
|
-
return `${packageName}/
|
|
10
|
+
const safePath = ["", "/es", "/lib", "/es/core", "/lib/core"].includes(path) ? path : "/es";
|
|
11
|
+
if (safePath === "/lib/core") {
|
|
12
|
+
return `${packageName}/lib/${namePath}`;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
return `${packageName}${finalPath}/${namePath}`;
|
|
14
|
+
return `${packageName}/es/${namePath}`;
|
|
19
15
|
}
|
|
20
16
|
const componentDependencyMap = {
|
|
21
17
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
18
|
+
// 后续有依赖的组件可继续加:EleTable: ['EleTableColumn']
|
|
22
19
|
};
|
|
23
|
-
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
24
|
-
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
25
|
-
Object.values(componentDependencyMap).forEach((children) => {
|
|
26
|
-
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
27
|
-
});
|
|
28
20
|
function generateComponentResolveConfig(name, options) {
|
|
29
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
path = "/es",
|
|
23
|
+
exclude = []
|
|
24
|
+
} = options || {};
|
|
30
25
|
const packageName = "yuang-framework-ui-pc";
|
|
31
26
|
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
32
|
-
const
|
|
27
|
+
const safePath = path || "/es";
|
|
33
28
|
let fromPath = "";
|
|
34
|
-
if (["", "/es/core", "/lib/core"].includes(
|
|
35
|
-
fromPath = `${packageName}
|
|
29
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
30
|
+
fromPath = `${packageName}/${safePath === "/lib/core" ? "lib" : "es"}`;
|
|
31
|
+
} else if (safePath === "/lib") {
|
|
32
|
+
fromPath = `${packageName}/lib/${namePath}/index`;
|
|
36
33
|
} else {
|
|
37
|
-
fromPath = `${packageName}
|
|
34
|
+
fromPath = `${packageName}/es/${namePath}/index`;
|
|
38
35
|
}
|
|
39
|
-
fromPath = fromPath.replace(
|
|
36
|
+
fromPath = fromPath.replace(/undefined/g, "").replace(/\/+/g, "/").replace(/^\/|\/$/g, "");
|
|
40
37
|
if (!fromPath || fromPath === packageName) {
|
|
41
38
|
fromPath = `${packageName}/es/${namePath}`;
|
|
42
39
|
}
|
|
40
|
+
const stylePath = getStylePath(namePath, packageName, safePath);
|
|
43
41
|
const config = {
|
|
44
|
-
name: name
|
|
42
|
+
name: name.trim(),
|
|
43
|
+
// 组件名去空格
|
|
45
44
|
from: fromPath,
|
|
45
|
+
// 核心路径(绝对合法)
|
|
46
46
|
sideEffects: getSideEffects(stylePath, options)
|
|
47
|
+
// 样式路径(允许undefined)
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
-
console.error(`[配置修复] 组件${name}的from路径异常,强制兜底为: ${packageName}/es/${namePath}`);
|
|
50
|
-
config.from = `${packageName}/es/${namePath}`;
|
|
51
|
-
}
|
|
49
|
+
console.log(`[组件解析] ${name} -> 路径: ${config.from},样式: ${config.sideEffects}`);
|
|
52
50
|
return config;
|
|
53
51
|
}
|
|
54
52
|
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
@@ -56,24 +54,16 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
|
|
|
56
54
|
type: "component",
|
|
57
55
|
resolve: (name) => {
|
|
58
56
|
const { exclude = [] } = options;
|
|
59
|
-
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name)
|
|
57
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name);
|
|
60
58
|
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
61
|
-
if (isMatch)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (dependencyList && dependencyList.length) {
|
|
68
|
-
const dependencyConfigs = dependencyList.map((depName) => generateComponentResolveConfig(depName, options)).filter((config) => !!config && !!config.from);
|
|
69
|
-
const allConfigs = [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
70
|
-
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(allConfigs));
|
|
71
|
-
return allConfigs;
|
|
72
|
-
}
|
|
73
|
-
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(currentConfig));
|
|
74
|
-
return currentConfig;
|
|
59
|
+
if (!isMatch) return void 0;
|
|
60
|
+
const currentConfig = generateComponentResolveConfig(name, options);
|
|
61
|
+
const dependencyList = componentDependencyMap[name];
|
|
62
|
+
if (dependencyList && dependencyList.length) {
|
|
63
|
+
const dependencyConfigs = dependencyList.filter((depName) => !exclude.includes(depName)).map((depName) => generateComponentResolveConfig(depName, options));
|
|
64
|
+
return [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
75
65
|
}
|
|
76
|
-
return
|
|
66
|
+
return currentConfig;
|
|
77
67
|
}
|
|
78
68
|
};
|
|
79
69
|
}
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -2,55 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
function getSideEffects(path, options) {
|
|
4
4
|
if (!path) return void 0;
|
|
5
|
-
const importStyle = options == null ? void 0 : options.importStyle;
|
|
5
|
+
const importStyle = (options == null ? void 0 : options.importStyle) ?? true;
|
|
6
6
|
if (!importStyle) {
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
return `${path}/style/css`;
|
|
11
|
-
}
|
|
12
|
-
return `${path}/style/index`;
|
|
9
|
+
return importStyle === "css" ? `${path}/style/css` : `${path}/style/index`;
|
|
13
10
|
}
|
|
14
11
|
function getStylePath(namePath, packageName, path = "/es") {
|
|
15
|
-
const safePath = path
|
|
16
|
-
if (
|
|
17
|
-
return `${packageName}/
|
|
12
|
+
const safePath = ["", "/es", "/lib", "/es/core", "/lib/core"].includes(path) ? path : "/es";
|
|
13
|
+
if (safePath === "/lib/core") {
|
|
14
|
+
return `${packageName}/lib/${namePath}`;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
return `${packageName}${finalPath}/${namePath}`;
|
|
16
|
+
return `${packageName}/es/${namePath}`;
|
|
21
17
|
}
|
|
22
18
|
const componentDependencyMap = {
|
|
23
19
|
YuFrameworkAttachmentUpload: ["EleUploadList"]
|
|
20
|
+
// 后续有依赖的组件可继续加:EleTable: ['EleTableColumn']
|
|
24
21
|
};
|
|
25
|
-
const allNeedResolveComponents = /* @__PURE__ */ new Set();
|
|
26
|
-
Object.keys(componentDependencyMap).forEach((parent) => allNeedResolveComponents.add(parent));
|
|
27
|
-
Object.values(componentDependencyMap).forEach((children) => {
|
|
28
|
-
children.forEach((child) => allNeedResolveComponents.add(child));
|
|
29
|
-
});
|
|
30
22
|
function generateComponentResolveConfig(name, options) {
|
|
31
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
path = "/es",
|
|
25
|
+
exclude = []
|
|
26
|
+
} = options || {};
|
|
32
27
|
const packageName = "yuang-framework-ui-pc";
|
|
33
28
|
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").filter(Boolean).join("-").toLowerCase() || name.toLowerCase();
|
|
34
|
-
const
|
|
29
|
+
const safePath = path || "/es";
|
|
35
30
|
let fromPath = "";
|
|
36
|
-
if (["", "/es/core", "/lib/core"].includes(
|
|
37
|
-
fromPath = `${packageName}
|
|
31
|
+
if (["", "/es/core", "/lib/core"].includes(safePath)) {
|
|
32
|
+
fromPath = `${packageName}/${safePath === "/lib/core" ? "lib" : "es"}`;
|
|
33
|
+
} else if (safePath === "/lib") {
|
|
34
|
+
fromPath = `${packageName}/lib/${namePath}/index`;
|
|
38
35
|
} else {
|
|
39
|
-
fromPath = `${packageName}
|
|
36
|
+
fromPath = `${packageName}/es/${namePath}/index`;
|
|
40
37
|
}
|
|
41
|
-
fromPath = fromPath.replace(
|
|
38
|
+
fromPath = fromPath.replace(/undefined/g, "").replace(/\/+/g, "/").replace(/^\/|\/$/g, "");
|
|
42
39
|
if (!fromPath || fromPath === packageName) {
|
|
43
40
|
fromPath = `${packageName}/es/${namePath}`;
|
|
44
41
|
}
|
|
42
|
+
const stylePath = getStylePath(namePath, packageName, safePath);
|
|
45
43
|
const config = {
|
|
46
|
-
name: name
|
|
44
|
+
name: name.trim(),
|
|
45
|
+
// 组件名去空格
|
|
47
46
|
from: fromPath,
|
|
47
|
+
// 核心路径(绝对合法)
|
|
48
48
|
sideEffects: getSideEffects(stylePath, options)
|
|
49
|
+
// 样式路径(允许undefined)
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
console.error(`[配置修复] 组件${name}的from路径异常,强制兜底为: ${packageName}/es/${namePath}`);
|
|
52
|
-
config.from = `${packageName}/es/${namePath}`;
|
|
53
|
-
}
|
|
51
|
+
console.log(`[组件解析] ${name} -> 路径: ${config.from},样式: ${config.sideEffects}`);
|
|
54
52
|
return config;
|
|
55
53
|
}
|
|
56
54
|
function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: true }) {
|
|
@@ -58,24 +56,16 @@ function EleAdminResolver(options = { path: "/es", exclude: [], importStyle: tru
|
|
|
58
56
|
type: "component",
|
|
59
57
|
resolve: (name) => {
|
|
60
58
|
const { exclude = [] } = options;
|
|
61
|
-
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name)
|
|
59
|
+
const isMatch = /^(Ele|Yu)/.test(name) && !exclude.includes(name);
|
|
62
60
|
console.log(`[匹配校验] 组件名: ${name},是否匹配: ${isMatch}`);
|
|
63
|
-
if (isMatch)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (dependencyList && dependencyList.length) {
|
|
70
|
-
const dependencyConfigs = dependencyList.map((depName) => generateComponentResolveConfig(depName, options)).filter((config) => !!config && !!config.from);
|
|
71
|
-
const allConfigs = [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
72
|
-
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(allConfigs));
|
|
73
|
-
return allConfigs;
|
|
74
|
-
}
|
|
75
|
-
console.log(`[返回配置] 组件${name}的解析配置:`, JSON.stringify(currentConfig));
|
|
76
|
-
return currentConfig;
|
|
61
|
+
if (!isMatch) return void 0;
|
|
62
|
+
const currentConfig = generateComponentResolveConfig(name, options);
|
|
63
|
+
const dependencyList = componentDependencyMap[name];
|
|
64
|
+
if (dependencyList && dependencyList.length) {
|
|
65
|
+
const dependencyConfigs = dependencyList.filter((depName) => !exclude.includes(depName)).map((depName) => generateComponentResolveConfig(depName, options));
|
|
66
|
+
return [currentConfig, ...dependencyConfigs].filter(Boolean);
|
|
77
67
|
}
|
|
78
|
-
return
|
|
68
|
+
return currentConfig;
|
|
79
69
|
}
|
|
80
70
|
};
|
|
81
71
|
}
|
package/lib/utils/resolvers.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EleAdminResolverOptions {
|
|
|
12
12
|
importStyle?: boolean | 'css' | 'sass';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 按需加载插件:支持所有 Ele/Yu 开头的组件
|
|
16
16
|
* @param options 参数
|
|
17
17
|
*/
|
|
18
18
|
export declare function EleAdminResolver(options?: EleAdminResolverOptions): ComponentResolver;
|