@fangzhongya/vue-components 0.0.1
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/LICENSE +25 -0
- package/README.md +84 -0
- package/dist/chunk-DWAXBT53.cjs +430 -0
- package/dist/chunk-FHXKMI4F.cjs +67 -0
- package/dist/chunk-GCY6HHVL.cjs +21 -0
- package/dist/chunk-LOIJYJZQ.js +21 -0
- package/dist/chunk-SYAIFHVF.js +430 -0
- package/dist/chunk-ZDQS7PSJ.js +67 -0
- package/dist/config.cjs +6 -0
- package/dist/config.d.ts +79 -0
- package/dist/config.js +6 -0
- package/dist/fang-component.cjs +6 -0
- package/dist/fang-component.d.ts +21 -0
- package/dist/fang-component.js +6 -0
- package/dist/index.cjs +15 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -0
- package/dist/resolver.cjs +8 -0
- package/dist/resolver.d.ts +10 -0
- package/dist/resolver.js +8 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2024 fangzhongya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated
|
|
7
|
+
documentation files (the "Software"), to deal in the
|
|
8
|
+
Software without restriction, including without limitation
|
|
9
|
+
the rights to use, copy, modify, merge, publish, distribute,
|
|
10
|
+
sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so,
|
|
12
|
+
subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall
|
|
15
|
+
be included in all copies or substantial portions of the
|
|
16
|
+
Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
19
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
21
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
22
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
23
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# unplugin-vue-components 的 插件
|
|
2
|
+
|
|
3
|
+
支持自定义解析方式
|
|
4
|
+
|
|
5
|
+
支持多次配置
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
export interface Config {
|
|
9
|
+
/**
|
|
10
|
+
* 自动导入的文件目录
|
|
11
|
+
*/
|
|
12
|
+
dir?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 文件后缀
|
|
15
|
+
* 如果为空数组,
|
|
16
|
+
*/
|
|
17
|
+
extensions?: Array<string>;
|
|
18
|
+
/**
|
|
19
|
+
* 自己的别名
|
|
20
|
+
*/
|
|
21
|
+
alias?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 只支持自己的别名组件,与子别名无关
|
|
24
|
+
*/
|
|
25
|
+
onlyAlias?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 通过头匹配,默认转换成 - 模式匹配的
|
|
28
|
+
* dir下面子目录来配置别名
|
|
29
|
+
* 不区分首字母大小写
|
|
30
|
+
*/
|
|
31
|
+
aliass?: {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 匹配数组
|
|
36
|
+
* '' 表示匹配当前文件名
|
|
37
|
+
*/
|
|
38
|
+
matchs?: Array<string>;
|
|
39
|
+
/**
|
|
40
|
+
* 匹配文件名称和文件类型
|
|
41
|
+
*/
|
|
42
|
+
matchexts?: Array<string>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 指令文件夹名称
|
|
46
|
+
*/
|
|
47
|
+
directives?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 是否缓存
|
|
50
|
+
*/
|
|
51
|
+
isCache?: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 过滤 不匹配 通过头匹配,默认转换成 - 模式匹配的
|
|
55
|
+
* 不区分首字母大小写
|
|
56
|
+
*/
|
|
57
|
+
startss?: Array<string>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 过滤 不匹配 全匹配 - 模式匹配的
|
|
61
|
+
* 不区分首字母大小写
|
|
62
|
+
*/
|
|
63
|
+
filtes?: Array<string>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 匹配到的文件路径
|
|
67
|
+
*/
|
|
68
|
+
getFromName?(
|
|
69
|
+
url: string,
|
|
70
|
+
name: string,
|
|
71
|
+
type: string,
|
|
72
|
+
): string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 获取匹配数组
|
|
76
|
+
*/
|
|
77
|
+
getMatch?(
|
|
78
|
+
v: string,
|
|
79
|
+
extensions?: Array<string>,
|
|
80
|
+
matchs?: Array<string>,
|
|
81
|
+
matchexts?: Array<string>,
|
|
82
|
+
): Array<string | RegExp>;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// packages/fang-component.ts
|
|
2
|
+
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
|
3
|
+
var _path = require('path');
|
|
4
|
+
function firstUpper(vs) {
|
|
5
|
+
return vs.slice(0, 1).toUpperCase() + vs.slice(1);
|
|
6
|
+
}
|
|
7
|
+
function firstLower(vs) {
|
|
8
|
+
return vs.slice(0, 1).toLowerCase() + vs.slice(1);
|
|
9
|
+
}
|
|
10
|
+
function getNmaeBar(name) {
|
|
11
|
+
let reg = /(([A-Z])([^A-Z]*))/g;
|
|
12
|
+
let result;
|
|
13
|
+
let arr = [];
|
|
14
|
+
let i = 0;
|
|
15
|
+
while ((result = reg.exec(name)) !== null) {
|
|
16
|
+
if (i == 0 && result.index != 0) {
|
|
17
|
+
arr.push(name.substring(0, result.index));
|
|
18
|
+
}
|
|
19
|
+
i++;
|
|
20
|
+
arr.push(result[1].toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
if (arr.length == 0) {
|
|
23
|
+
return name;
|
|
24
|
+
} else {
|
|
25
|
+
let a = arr.join("-");
|
|
26
|
+
a = a.replace(/[-]{2,}/g, "-");
|
|
27
|
+
return a;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function getMatchDir(name) {
|
|
31
|
+
return [name + ".js"];
|
|
32
|
+
}
|
|
33
|
+
function isUrlsMatchi(key, arr) {
|
|
34
|
+
if (arr) {
|
|
35
|
+
for (let index = 0; index < arr.length; index++) {
|
|
36
|
+
const element = arr[index];
|
|
37
|
+
if (typeof element == "string") {
|
|
38
|
+
if (key.endsWith(element)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (element.test(key)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function getForUrl(arr, name) {
|
|
51
|
+
for (let index = 0; index < arr.length; index++) {
|
|
52
|
+
const element = arr[index];
|
|
53
|
+
if (typeof name == "string") {
|
|
54
|
+
if (element.endsWith(name)) {
|
|
55
|
+
return element;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
if (name.test(element)) {
|
|
59
|
+
return element;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getForUrlStart(arr, name) {
|
|
65
|
+
if (arr) {
|
|
66
|
+
for (let index = 0; index < arr.length; index++) {
|
|
67
|
+
const element = arr[index];
|
|
68
|
+
if (name.startsWith(element)) {
|
|
69
|
+
return name;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function getName(name) {
|
|
75
|
+
if (name.includes("-")) {
|
|
76
|
+
let arr = name.split("-");
|
|
77
|
+
arr = arr.map((vs) => {
|
|
78
|
+
return firstUpper(vs);
|
|
79
|
+
});
|
|
80
|
+
let upper = arr.join("");
|
|
81
|
+
let lower = firstLower(upper);
|
|
82
|
+
return [name, upper, lower];
|
|
83
|
+
} else if (/[A-Z]/.test(name)) {
|
|
84
|
+
let hg = getNmaeBar(name);
|
|
85
|
+
if (/[A-Z]/.test(name.slice(0, 1))) {
|
|
86
|
+
if (hg.includes("-")) {
|
|
87
|
+
let lower = firstLower(name);
|
|
88
|
+
return [hg, name, lower];
|
|
89
|
+
} else {
|
|
90
|
+
return [name, hg];
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
return [hg, name];
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
return [name];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var FangComponent = class {
|
|
100
|
+
|
|
101
|
+
#comUrls;
|
|
102
|
+
#dirUrls;
|
|
103
|
+
#cacheObj;
|
|
104
|
+
#curDir;
|
|
105
|
+
#aliassArr;
|
|
106
|
+
#aliassValueArr;
|
|
107
|
+
constructor(config) {
|
|
108
|
+
this.config = config || {};
|
|
109
|
+
this.#setConfigValue();
|
|
110
|
+
}
|
|
111
|
+
#setConfigValue() {
|
|
112
|
+
this.#setGetMatch();
|
|
113
|
+
this.#comUrls = [];
|
|
114
|
+
this.#dirUrls = [];
|
|
115
|
+
this.#cacheObj = {};
|
|
116
|
+
this.#curDir = "";
|
|
117
|
+
if (this.config.dir) {
|
|
118
|
+
this.#curDir = _path.resolve.call(void 0, __dirname, this.config.dir).replace(/\\/g, "/") + "/";
|
|
119
|
+
}
|
|
120
|
+
this.#aliassArr = [];
|
|
121
|
+
const aliass = this.config.aliass;
|
|
122
|
+
if (aliass) {
|
|
123
|
+
this.#aliassArr = Object.keys(aliass);
|
|
124
|
+
this.#aliassValueArr = this.#aliassArr.map((key) => {
|
|
125
|
+
return this.#curDir + aliass[key] + "/";
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
this.#getUrls();
|
|
129
|
+
}
|
|
130
|
+
#setGetMatch() {
|
|
131
|
+
if (!this.config.getMatch) {
|
|
132
|
+
this.config.getMatch = function(v, extensions, matchs, matchexts) {
|
|
133
|
+
const urls = [];
|
|
134
|
+
if (matchs) {
|
|
135
|
+
matchs.forEach((key) => {
|
|
136
|
+
const s = "/" + v + key;
|
|
137
|
+
if (extensions) {
|
|
138
|
+
_optionalChain([extensions, 'optionalAccess', _ => _.forEach, 'call', _2 => _2((z) => {
|
|
139
|
+
urls.push(s + "." + z);
|
|
140
|
+
})]);
|
|
141
|
+
} else {
|
|
142
|
+
const reg = new RegExp(s + ".([a-z|A-Z]+?)$");
|
|
143
|
+
urls.push(reg);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (matchexts) {
|
|
148
|
+
matchexts.forEach((key) => {
|
|
149
|
+
urls.push("/" + v + key);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return [...new Set(urls)];
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
#getUrls() {
|
|
157
|
+
const url = this.#getFgUrl();
|
|
158
|
+
if (url) {
|
|
159
|
+
this.#comUrls = _fastglob2.default.sync(url, {
|
|
160
|
+
onlyFiles: false,
|
|
161
|
+
absolute: true
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (this.config.directives) {
|
|
165
|
+
const durl = this.config.dir + "**/" + this.config.directives + "/*.js";
|
|
166
|
+
this.#dirUrls = _fastglob2.default.sync(durl, {
|
|
167
|
+
onlyFiles: false,
|
|
168
|
+
absolute: true
|
|
169
|
+
}) || [];
|
|
170
|
+
}
|
|
171
|
+
if (this.config.urlprefix) {
|
|
172
|
+
if (this.config.dir) {
|
|
173
|
+
const dir = this.config.dir;
|
|
174
|
+
const reg = new RegExp("^" + this.#curDir);
|
|
175
|
+
const urls = [];
|
|
176
|
+
const dirUrls = [];
|
|
177
|
+
_optionalChain([this, 'access', _3 => _3.#comUrls, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((key) => {
|
|
178
|
+
urls.push(key.replace(reg, dir));
|
|
179
|
+
})]);
|
|
180
|
+
_optionalChain([this, 'access', _6 => _6.#dirUrls, 'optionalAccess', _7 => _7.forEach, 'call', _8 => _8((key) => {
|
|
181
|
+
dirUrls.push(key.replace(reg, dir));
|
|
182
|
+
})]);
|
|
183
|
+
this.config.urls = urls;
|
|
184
|
+
this.config.dirUrls = dirUrls;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
#getFgUrl() {
|
|
189
|
+
if (this.config.extensions) {
|
|
190
|
+
if (this.config.extensions.length > 1) {
|
|
191
|
+
return this.config.dir + "**/*.{" + this.config.extensions.join(",") + "}";
|
|
192
|
+
} else if (this.config.extensions.length == 1) {
|
|
193
|
+
return this.config.dir + "**/*." + this.config.extensions[0];
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
return this.config.dir + "**/*.*";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
#getCache(name, type) {
|
|
200
|
+
if (this.#cacheObj) {
|
|
201
|
+
const obj = this.#cacheObj[type] || {};
|
|
202
|
+
return obj[name];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
#setCache(name, type, obj) {
|
|
206
|
+
const cach = this.#cacheObj || {};
|
|
207
|
+
const co = cach[type] || {};
|
|
208
|
+
co[name] = obj;
|
|
209
|
+
cach[type] = co;
|
|
210
|
+
}
|
|
211
|
+
#namefilter(name) {
|
|
212
|
+
name = getNmaeBar(name);
|
|
213
|
+
if (this.config.startss) {
|
|
214
|
+
for (let index = 0; index < this.config.startss.length; index++) {
|
|
215
|
+
const element = this.config.startss[index] + "-";
|
|
216
|
+
if (name.startsWith(element)) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (this.config.filtes) {
|
|
222
|
+
for (let index = 0; index < this.config.filtes.length; index++) {
|
|
223
|
+
const element = this.config.filtes[index];
|
|
224
|
+
if (name === element) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
#getNameFromUrl(from, name, type) {
|
|
232
|
+
let dname = "";
|
|
233
|
+
if (this.config.getFromName) {
|
|
234
|
+
dname = this.config.getFromName(from, name, type);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
name: dname || "default",
|
|
238
|
+
from
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
#getCorrespondUrl2(type, urls, ml, yname, top) {
|
|
242
|
+
const v = this.#curDir + ml + "/";
|
|
243
|
+
const as = [];
|
|
244
|
+
for (let index = 0; index < urls.length; index++) {
|
|
245
|
+
const element = urls[index];
|
|
246
|
+
if (element.startsWith(v)) {
|
|
247
|
+
as.push(element);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (as.length == 1) {
|
|
251
|
+
return as[0];
|
|
252
|
+
} else if (as.length > 1) {
|
|
253
|
+
let m;
|
|
254
|
+
if (/[A-Z]/.test(yname.slice(0, 1))) {
|
|
255
|
+
m = yname.replace(firstUpper(top), "");
|
|
256
|
+
} else {
|
|
257
|
+
m = yname.replace(top, "");
|
|
258
|
+
}
|
|
259
|
+
return this.#getCorrespondUrl(as, m, type, ml);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
#getConfigUrl(type, name, ml, yname, top) {
|
|
263
|
+
const ms = this.#setMatchUrls(name, type);
|
|
264
|
+
const urls = this.#getUrlsMatchi(ms, type);
|
|
265
|
+
if (urls.length == 1) {
|
|
266
|
+
return urls[0];
|
|
267
|
+
} else if (urls.length > 1) {
|
|
268
|
+
return this.#getCorrespondUrl2(type, urls, ml, yname, top);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
#setNameFrom(name, type) {
|
|
272
|
+
let mb = getNmaeBar(name);
|
|
273
|
+
const alias = this.config.alias;
|
|
274
|
+
if (alias) {
|
|
275
|
+
if (mb.startsWith(alias + "-")) {
|
|
276
|
+
const reg = new RegExp("^" + alias + "-");
|
|
277
|
+
mb = mb.replace(reg, "");
|
|
278
|
+
const reg1 = new RegExp("^" + alias);
|
|
279
|
+
const reg2 = new RegExp("^" + firstUpper(alias));
|
|
280
|
+
if (reg1.test(name)) {
|
|
281
|
+
name = name.replace(reg1, "");
|
|
282
|
+
} else if (reg2.test(name)) {
|
|
283
|
+
name = name.replace(reg2, "");
|
|
284
|
+
} else if (reg.test(name)) {
|
|
285
|
+
name = name.replace(reg, "");
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
if (this.config.onlyAlias) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (this.#aliassArr) {
|
|
294
|
+
for (let index = 0; index < this.#aliassArr.length; index++) {
|
|
295
|
+
const element = this.#aliassArr[index];
|
|
296
|
+
const aliass = this.config.aliass || {};
|
|
297
|
+
if (mb.startsWith(element + "-")) {
|
|
298
|
+
const sl = mb.substring(element.length + 1);
|
|
299
|
+
const from2 = this.#getConfigUrl(
|
|
300
|
+
type,
|
|
301
|
+
sl,
|
|
302
|
+
aliass[element],
|
|
303
|
+
name,
|
|
304
|
+
element
|
|
305
|
+
);
|
|
306
|
+
if (from2) {
|
|
307
|
+
return this.#getNameFromUrl(from2, name, type);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const from = this.#getMatchUrl(name, type);
|
|
313
|
+
if (from) {
|
|
314
|
+
return this.#getNameFromUrl(from, name, type);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
#setMatchUrls(name, type) {
|
|
318
|
+
const arr = getName(name);
|
|
319
|
+
const urls = [];
|
|
320
|
+
if (type == "directive") {
|
|
321
|
+
arr.forEach((v) => {
|
|
322
|
+
const vs = getMatchDir(v);
|
|
323
|
+
urls.push(...vs);
|
|
324
|
+
});
|
|
325
|
+
} else {
|
|
326
|
+
const getMatch = this.config.getMatch;
|
|
327
|
+
if (getMatch) {
|
|
328
|
+
arr.forEach((v) => {
|
|
329
|
+
const vs = getMatch(
|
|
330
|
+
v,
|
|
331
|
+
this.config.extensions,
|
|
332
|
+
this.config.matchs,
|
|
333
|
+
this.config.matchexts
|
|
334
|
+
);
|
|
335
|
+
if (vs) {
|
|
336
|
+
urls.push(...vs);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return urls;
|
|
342
|
+
}
|
|
343
|
+
#setMatchUrl(name, type) {
|
|
344
|
+
let urls = [];
|
|
345
|
+
if (type == "directive") {
|
|
346
|
+
urls = getMatchDir(name);
|
|
347
|
+
} else {
|
|
348
|
+
const getMatch = this.config.getMatch;
|
|
349
|
+
if (getMatch) {
|
|
350
|
+
urls = getMatch(
|
|
351
|
+
name,
|
|
352
|
+
this.config.extensions,
|
|
353
|
+
this.config.matchs,
|
|
354
|
+
this.config.matchexts
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return urls;
|
|
359
|
+
}
|
|
360
|
+
#getUrlsMatchi(arr, type) {
|
|
361
|
+
const as = [];
|
|
362
|
+
if (type == "directive") {
|
|
363
|
+
_optionalChain([this, 'access', _9 => _9.#dirUrls, 'optionalAccess', _10 => _10.forEach, 'call', _11 => _11((key) => {
|
|
364
|
+
if (isUrlsMatchi(key, arr)) {
|
|
365
|
+
as.push(key);
|
|
366
|
+
}
|
|
367
|
+
})]);
|
|
368
|
+
} else {
|
|
369
|
+
_optionalChain([this, 'access', _12 => _12.#comUrls, 'optionalAccess', _13 => _13.forEach, 'call', _14 => _14((key) => {
|
|
370
|
+
if (isUrlsMatchi(key, arr)) {
|
|
371
|
+
as.push(key);
|
|
372
|
+
}
|
|
373
|
+
})]);
|
|
374
|
+
}
|
|
375
|
+
return as;
|
|
376
|
+
}
|
|
377
|
+
#excludeBm(urls) {
|
|
378
|
+
let val = [];
|
|
379
|
+
urls.forEach((v) => {
|
|
380
|
+
if (!getForUrlStart(this.#aliassValueArr, v)) {
|
|
381
|
+
val.push(v);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
if (val.length == 0) {
|
|
385
|
+
val = urls;
|
|
386
|
+
}
|
|
387
|
+
return val;
|
|
388
|
+
}
|
|
389
|
+
#getCorrespondUrl(urls, name, type, bm) {
|
|
390
|
+
if (!bm) {
|
|
391
|
+
urls = this.#excludeBm(urls);
|
|
392
|
+
}
|
|
393
|
+
if (urls.length == 1) {
|
|
394
|
+
return urls[0];
|
|
395
|
+
}
|
|
396
|
+
const arr = this.#setMatchUrl(name, type);
|
|
397
|
+
for (let index = 0; index < arr.length; index++) {
|
|
398
|
+
const element = arr[index];
|
|
399
|
+
let url = getForUrl(urls, element);
|
|
400
|
+
if (url) {
|
|
401
|
+
return url;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
#getMatchUrl(name, type) {
|
|
406
|
+
const ml = this.#setMatchUrls(name, type);
|
|
407
|
+
const urls = this.#getUrlsMatchi(ml, type);
|
|
408
|
+
if (urls.length == 1) {
|
|
409
|
+
return urls[0];
|
|
410
|
+
} else if (urls.length > 1) {
|
|
411
|
+
return this.#getCorrespondUrl(urls, name, type);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
resolve(name, type) {
|
|
415
|
+
if (this.config.isCache && this.#getCache(name, type)) {
|
|
416
|
+
return this.#getCache(name, type);
|
|
417
|
+
} else if (this.#namefilter(name)) {
|
|
418
|
+
let obj = this.#setNameFrom(name, type);
|
|
419
|
+
if (obj) {
|
|
420
|
+
this.#setCache(name, type, obj);
|
|
421
|
+
return obj;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var fang_component_default = FangComponent;
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
exports.fang_component_default = fang_component_default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkGCY6HHVLcjs = require('./chunk-GCY6HHVL.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkDWAXBT53cjs = require('./chunk-DWAXBT53.cjs');
|
|
7
|
+
|
|
8
|
+
// packages/resolver.ts
|
|
9
|
+
function objectMerge(a, b, j = 1, i) {
|
|
10
|
+
for (const key in b) {
|
|
11
|
+
const v = a[key];
|
|
12
|
+
const t = b[key];
|
|
13
|
+
if (v) {
|
|
14
|
+
if (v instanceof Array) {
|
|
15
|
+
if (i) {
|
|
16
|
+
if (t instanceof Array) {
|
|
17
|
+
v.push(...t);
|
|
18
|
+
} else {
|
|
19
|
+
v.push(t);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
a[key] = t;
|
|
23
|
+
}
|
|
24
|
+
} else if (typeof v == "object") {
|
|
25
|
+
const cv = Object.prototype.toString.call(v);
|
|
26
|
+
const ct = Object.prototype.toString.call(t);
|
|
27
|
+
if (cv == ct) {
|
|
28
|
+
const n = j - 1;
|
|
29
|
+
if (n > 0) {
|
|
30
|
+
a[key] = objectMerge(v, t, n, i);
|
|
31
|
+
} else {
|
|
32
|
+
a[key] = t;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
a[key] = t;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
a[key] = t;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
a[key] = t;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return a;
|
|
45
|
+
}
|
|
46
|
+
function ComponentsResolver(con = {}) {
|
|
47
|
+
const configs = objectMerge(_chunkGCY6HHVLcjs.config, con);
|
|
48
|
+
const fangComp = new (0, _chunkDWAXBT53cjs.fang_component_default)(configs);
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
type: "component",
|
|
52
|
+
resolve: (name) => {
|
|
53
|
+
return fangComp.resolve(name, "component");
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "directive",
|
|
58
|
+
resolve: (name) => {
|
|
59
|
+
return fangComp.resolve(name, "directive");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
exports.ComponentsResolver = ComponentsResolver;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// packages/config.ts
|
|
2
|
+
var config = {
|
|
3
|
+
dir: "./src/components/",
|
|
4
|
+
extensions: ["vue"],
|
|
5
|
+
alias: "",
|
|
6
|
+
onlyAlias: false,
|
|
7
|
+
aliass: {},
|
|
8
|
+
matchs: [],
|
|
9
|
+
matchexts: [".vue", "/index.vue"],
|
|
10
|
+
directives: "directive",
|
|
11
|
+
isCache: true,
|
|
12
|
+
startss: [],
|
|
13
|
+
filtes: ["router-link", "router-view"],
|
|
14
|
+
getFromName() {
|
|
15
|
+
return "default";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.config = config;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/config.ts
|
|
2
|
+
var config = {
|
|
3
|
+
dir: "./src/components/",
|
|
4
|
+
extensions: ["vue"],
|
|
5
|
+
alias: "",
|
|
6
|
+
onlyAlias: false,
|
|
7
|
+
aliass: {},
|
|
8
|
+
matchs: [],
|
|
9
|
+
matchexts: [".vue", "/index.vue"],
|
|
10
|
+
directives: "directive",
|
|
11
|
+
isCache: true,
|
|
12
|
+
startss: [],
|
|
13
|
+
filtes: ["router-link", "router-view"],
|
|
14
|
+
getFromName() {
|
|
15
|
+
return "default";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
config
|
|
21
|
+
};
|