@fangzhongya/vue-components 0.1.29 → 0.1.30
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/archive.cjs +190 -340
- package/dist/archive.d.cts +5 -4
- package/dist/archive.d.ts +5 -4
- package/dist/archive.js +190 -341
- package/dist/chunk-J7CICTHH-DzD10422.cjs +25 -0
- package/dist/chunk-J7CICTHH-Ikr5rmAQ.js +20 -0
- package/dist/component-B-5G8Yjc.js +431 -0
- package/dist/component-CVkcT_sw.cjs +459 -0
- package/dist/component.cjs +2 -8
- package/dist/component.d.cts +14 -14
- package/dist/component.d.ts +15 -14
- package/dist/component.js +2 -8
- package/dist/config.cjs +59 -6
- package/dist/config.d.cts +134 -133
- package/dist/config.d.ts +134 -133
- package/dist/config.js +57 -5
- package/dist/import.cjs +18 -25
- package/dist/import.d.cts +5 -4
- package/dist/import.d.ts +5 -4
- package/dist/import.js +18 -26
- package/dist/imports-Cl3zPCxJ.cjs +971 -0
- package/dist/imports-DLu2DPCK.js +966 -0
- package/dist/imports.cjs +2 -8
- package/dist/imports.d.cts +14 -14
- package/dist/imports.d.ts +15 -14
- package/dist/imports.js +2 -8
- package/dist/index-5NuL-vgA.d.ts +5609 -0
- package/dist/index-DORWvPc3.d.cts +5609 -0
- package/dist/index.cjs +8 -17
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +6 -17
- package/dist/library.cjs +32 -48
- package/dist/library.d.cts +7 -6
- package/dist/library.d.ts +7 -6
- package/dist/library.js +32 -49
- package/dist/resolver.cjs +25 -10
- package/dist/resolver.d.cts +5 -4
- package/dist/resolver.d.ts +5 -4
- package/dist/resolver.js +24 -10
- package/dist/types-CZdqb5KI-T7Ielv5Y.d.cts +134 -0
- package/dist/types-CZdqb5KI-T7Ielv5Y.d.ts +134 -0
- package/dist/util-Ddld3oFr.js +93 -0
- package/dist/util-DtBzae46.cjs +116 -0
- package/dist/util.cjs +8 -16
- package/dist/util.d.cts +104 -5
- package/dist/util.d.ts +104 -5
- package/dist/util.js +3 -16
- package/package.json +10 -10
- package/dist/chunk-2SBJQUCI.cjs +0 -1238
- package/dist/chunk-3XFEJIQP.js +0 -135
- package/dist/chunk-6PYVVU7E.cjs +0 -581
- package/dist/chunk-7JRVVHVI.cjs +0 -33
- package/dist/chunk-AKNB7BKJ.cjs +0 -25
- package/dist/chunk-DURXCSNX.js +0 -62
- package/dist/chunk-HFFYPZA3.js +0 -1238
- package/dist/chunk-IXN2F3IJ.js +0 -581
- package/dist/chunk-NLSI7A24.cjs +0 -135
- package/dist/chunk-RRQV2YXW.js +0 -33
- package/dist/chunk-TVGK2KRP.js +0 -25
- package/dist/chunk-UNBQUEQ4.cjs +0 -62
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
import { i as styleLog$1 } from "./util-Ddld3oFr.js";
|
|
2
|
+
import { access, constants, createReadStream, mkdir, open, readFile, readdir, stat, write, writeFile } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
//#region node_modules/.pnpm/@fangzhongya+utils@0.0.80/node_modules/@fangzhongya/utils/dist/chunk-FS4JPT23.js
|
|
5
|
+
function deComment(code) {
|
|
6
|
+
let output = "";
|
|
7
|
+
let state = "code";
|
|
8
|
+
let escaping = false;
|
|
9
|
+
let i = 0;
|
|
10
|
+
const len = code.length;
|
|
11
|
+
while (i < len) {
|
|
12
|
+
const char = code[i];
|
|
13
|
+
const nextChar = code[i + 1];
|
|
14
|
+
switch (state) {
|
|
15
|
+
case "code":
|
|
16
|
+
if (char === "/" && nextChar === "/") {
|
|
17
|
+
state = "singleLine";
|
|
18
|
+
i += 2;
|
|
19
|
+
} else if (char === "/" && nextChar === "*") {
|
|
20
|
+
state = "multiLine";
|
|
21
|
+
i += 2;
|
|
22
|
+
} else if (char === "'") {
|
|
23
|
+
state = "singleQuote";
|
|
24
|
+
output += char;
|
|
25
|
+
i++;
|
|
26
|
+
} else if (char === "\"") {
|
|
27
|
+
state = "doubleQuote";
|
|
28
|
+
output += char;
|
|
29
|
+
i++;
|
|
30
|
+
} else if (char === "`") {
|
|
31
|
+
state = "template";
|
|
32
|
+
output += char;
|
|
33
|
+
i++;
|
|
34
|
+
} else {
|
|
35
|
+
output += char;
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case "singleLine":
|
|
40
|
+
if (char === "\n" || char === "\r") {
|
|
41
|
+
state = "code";
|
|
42
|
+
output += char;
|
|
43
|
+
i++;
|
|
44
|
+
if (char === "\r" && nextChar === "\n") {
|
|
45
|
+
output += nextChar;
|
|
46
|
+
i++;
|
|
47
|
+
}
|
|
48
|
+
} else i++;
|
|
49
|
+
break;
|
|
50
|
+
case "multiLine":
|
|
51
|
+
if (char === "*" && nextChar === "/") {
|
|
52
|
+
state = "code";
|
|
53
|
+
i += 2;
|
|
54
|
+
if (output.length > 0 && /[a-zA-Z0-9_$]$/.test(output) && i < len && /[a-zA-Z0-9_$]/.test(code[i])) output += " ";
|
|
55
|
+
} else i++;
|
|
56
|
+
break;
|
|
57
|
+
case "singleQuote":
|
|
58
|
+
output += char;
|
|
59
|
+
if (!escaping && char === "'") state = "code";
|
|
60
|
+
escaping = !escaping && char === "\\";
|
|
61
|
+
i++;
|
|
62
|
+
break;
|
|
63
|
+
case "doubleQuote":
|
|
64
|
+
output += char;
|
|
65
|
+
if (!escaping && char === "\"") state = "code";
|
|
66
|
+
escaping = !escaping && char === "\\";
|
|
67
|
+
i++;
|
|
68
|
+
break;
|
|
69
|
+
case "template":
|
|
70
|
+
output += char;
|
|
71
|
+
if (!escaping && char === "`") state = "code";
|
|
72
|
+
else if (!escaping && char === "$" && nextChar === "{") {
|
|
73
|
+
output += nextChar;
|
|
74
|
+
i += 2;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
escaping = !escaping && char === "\\";
|
|
78
|
+
i++;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return output;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region node_modules/.pnpm/@fangzhongya+utils@0.0.80/node_modules/@fangzhongya/utils/dist/chunk-4KYAGDPN.js
|
|
86
|
+
var REGEX_PATTERNS = {
|
|
87
|
+
VAR_EXPORT: /export\s+(?:const|let|var)\s+(\w+)/g,
|
|
88
|
+
FUNCTION_EXPORT: /export\s+function\s+(\w+)/g,
|
|
89
|
+
CLASS_EXPORT: /export\s+class\s+(\w+)/g,
|
|
90
|
+
NAMED_EXPORTS: /export\s*\{([^}]+)\}/g,
|
|
91
|
+
DEFAULT_EXPORT: /export\s+default\s+(\w+)/,
|
|
92
|
+
RENAME_SPLIT: /\s+as\s+/
|
|
93
|
+
};
|
|
94
|
+
function getExports(code) {
|
|
95
|
+
code = deComment(code);
|
|
96
|
+
const exports = {
|
|
97
|
+
named: [],
|
|
98
|
+
default: null
|
|
99
|
+
};
|
|
100
|
+
const namedExportsSet = /* @__PURE__ */ new Set();
|
|
101
|
+
const processMatches = (pattern, extractName) => {
|
|
102
|
+
const matches = code.matchAll(pattern);
|
|
103
|
+
for (const match of matches) {
|
|
104
|
+
const name = extractName(match);
|
|
105
|
+
if (name) namedExportsSet.add(name);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
processMatches(REGEX_PATTERNS.VAR_EXPORT, (match) => match[1]);
|
|
109
|
+
processMatches(REGEX_PATTERNS.FUNCTION_EXPORT, (match) => match[1]);
|
|
110
|
+
processMatches(REGEX_PATTERNS.CLASS_EXPORT, (match) => match[1]);
|
|
111
|
+
const namedExportMatches = code.matchAll(REGEX_PATTERNS.NAMED_EXPORTS);
|
|
112
|
+
for (const match of namedExportMatches) {
|
|
113
|
+
const items = match[1];
|
|
114
|
+
if (!items) continue;
|
|
115
|
+
items.split(",").forEach((item) => {
|
|
116
|
+
const trimmed = item.trim();
|
|
117
|
+
if (!trimmed) return;
|
|
118
|
+
const parts = trimmed.split(REGEX_PATTERNS.RENAME_SPLIT);
|
|
119
|
+
const name = parts[parts.length - 1].trim();
|
|
120
|
+
if (name) namedExportsSet.add(name);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const defaultMatch = code.match(REGEX_PATTERNS.DEFAULT_EXPORT);
|
|
124
|
+
if (defaultMatch) exports.default = defaultMatch[1];
|
|
125
|
+
exports.named = Array.from(namedExportsSet).sort();
|
|
126
|
+
return exports;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region node_modules/.pnpm/@fangzhongya+create@0.2.52/node_modules/@fangzhongya/create/dist/common-CbVDCztd.js
|
|
130
|
+
function getUrlCatalogueObj(str) {
|
|
131
|
+
const reg = /(\\|\/)([^\\|\/]+)\.([a-z|A-Z][a-z|A-Z|0-9]*)$/g;
|
|
132
|
+
const ml = str.replace(reg, "");
|
|
133
|
+
let name = "";
|
|
134
|
+
let suffix = "";
|
|
135
|
+
let apart = "";
|
|
136
|
+
const arr = reg.exec(str);
|
|
137
|
+
if (arr) {
|
|
138
|
+
apart = arr[1];
|
|
139
|
+
name = arr[2];
|
|
140
|
+
suffix = arr[3];
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
catalogue: ml,
|
|
144
|
+
name,
|
|
145
|
+
suffix,
|
|
146
|
+
apart
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function getNewFileName(url) {
|
|
150
|
+
const obj = getUrlCatalogueObj(url);
|
|
151
|
+
let wb = obj.name;
|
|
152
|
+
if (wb) {
|
|
153
|
+
const regs = /([0-9]+)$/g.exec(wb);
|
|
154
|
+
if (regs && regs.length > 0) {
|
|
155
|
+
const sl = Number(regs[1]) + 1;
|
|
156
|
+
const reg1 = new RegExp(regs[1] + "$");
|
|
157
|
+
wb = wb.replace(reg1, (sl + "").padStart(regs[1].length, "0"));
|
|
158
|
+
} else wb = wb + "1";
|
|
159
|
+
return obj.catalogue + obj.apart + wb + "." + obj.suffix;
|
|
160
|
+
} else return "";
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 读取文件内容
|
|
164
|
+
* @param url 文件地址
|
|
165
|
+
* @param type 文件编码
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
function fsReadFile(url, type) {
|
|
169
|
+
if (!type || type === true) type = "utf-8";
|
|
170
|
+
return new Promise((resolve, reject) => {
|
|
171
|
+
readFile(url, type, (err, dataStr) => {
|
|
172
|
+
if (err) {
|
|
173
|
+
console.log("2", err);
|
|
174
|
+
reject("");
|
|
175
|
+
} else resolve(dataStr);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function fsCreateReadStream(url, type) {
|
|
180
|
+
if (!type || type === true) type = "utf-8";
|
|
181
|
+
return new Promise((resolve) => {
|
|
182
|
+
const stream = createReadStream(url, {
|
|
183
|
+
start: 0,
|
|
184
|
+
end: 100,
|
|
185
|
+
encoding: type
|
|
186
|
+
});
|
|
187
|
+
let st = "";
|
|
188
|
+
stream.on("data", (data) => {
|
|
189
|
+
st += data;
|
|
190
|
+
});
|
|
191
|
+
stream.on("end", () => {
|
|
192
|
+
resolve(st);
|
|
193
|
+
});
|
|
194
|
+
stream.on("error", () => {
|
|
195
|
+
resolve("");
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 判断文件夹是否存在
|
|
201
|
+
* @param reaPath {String} 文件路径
|
|
202
|
+
* @returns {Promise<boolean>}
|
|
203
|
+
*/
|
|
204
|
+
function fsAccess(reaPath) {
|
|
205
|
+
return new Promise((resolve) => {
|
|
206
|
+
try {
|
|
207
|
+
access(reaPath, constants.F_OK, (err) => {
|
|
208
|
+
if (err) resolve(false);
|
|
209
|
+
else resolve(true);
|
|
210
|
+
});
|
|
211
|
+
} catch (e) {
|
|
212
|
+
resolve(false);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function fsReaddir(filePath) {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
readdir(filePath, (err, files) => {
|
|
219
|
+
if (err) reject(err);
|
|
220
|
+
else {
|
|
221
|
+
const lg = files.length;
|
|
222
|
+
const dirs = [];
|
|
223
|
+
const file = [];
|
|
224
|
+
if (lg) {
|
|
225
|
+
let i = 0;
|
|
226
|
+
files.forEach((filename) => {
|
|
227
|
+
stat(join(filePath, filename), (err, stats) => {
|
|
228
|
+
i++;
|
|
229
|
+
if (err) console.log("4", err);
|
|
230
|
+
else {
|
|
231
|
+
const isFile = stats.isFile();
|
|
232
|
+
const isDir = stats.isDirectory();
|
|
233
|
+
if (isFile) file.push(filename);
|
|
234
|
+
if (isDir) dirs.push(filename);
|
|
235
|
+
}
|
|
236
|
+
if (i >= lg) resolve({
|
|
237
|
+
file,
|
|
238
|
+
dirs
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
} else resolve({
|
|
243
|
+
file,
|
|
244
|
+
dirs
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 异步地打开文件。详见 open(2)。 flags 可以是:
|
|
252
|
+
* 以写入模式打开文件。文件会被创建(如果文件不存在)或截断(如果文件存在)。
|
|
253
|
+
* @param {*} path
|
|
254
|
+
* @param {*} json
|
|
255
|
+
* @param {number} type
|
|
256
|
+
* 0 文件不存在,或者存在都写入数据
|
|
257
|
+
* 1 文件不存在 就不写入数据
|
|
258
|
+
* 2 文件不存在 才写入数据
|
|
259
|
+
* 3 如果文件存在,追加
|
|
260
|
+
* @param {*} callback
|
|
261
|
+
*/
|
|
262
|
+
function fsOpenStream(path, json, type = 0, cover, callback) {
|
|
263
|
+
open(path, "wx", async (err, fd) => {
|
|
264
|
+
if (err) {
|
|
265
|
+
if (err.code === "EEXIST") {
|
|
266
|
+
if (type == 1 || type == 0) {
|
|
267
|
+
const fwrite = () => {
|
|
268
|
+
writeFile(path, json, "utf-8", (err) => {
|
|
269
|
+
if (err) {
|
|
270
|
+
console.log("6", err);
|
|
271
|
+
if (callback) callback(path, cover ? 3 : 2, false, type);
|
|
272
|
+
} else if (callback) callback(path, cover ? 3 : 2, true, type);
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
if (cover) {
|
|
276
|
+
if (!(await fsCreateReadStream(path)).includes("@config cover=true")) fwrite();
|
|
277
|
+
else if (callback) callback(path, 3, false, type);
|
|
278
|
+
} else fwrite();
|
|
279
|
+
} else if (type == 3) {
|
|
280
|
+
path = getNewFileName(path);
|
|
281
|
+
if (path) fsOpenStream(path, json, type, cover, callback);
|
|
282
|
+
else if (callback) callback(path, 3, false, type);
|
|
283
|
+
} else if (callback) callback(path, 2, false, type);
|
|
284
|
+
} else if (callback) callback(path, 0, false, type);
|
|
285
|
+
} else if (type != 1) write(fd, json, (err) => {
|
|
286
|
+
if (err) {
|
|
287
|
+
console.log("8", err);
|
|
288
|
+
if (callback) callback(path, 1, false, type);
|
|
289
|
+
} else if (callback) callback(path, 1, true, type);
|
|
290
|
+
});
|
|
291
|
+
else if (callback) callback(path, 1, false, type);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 判断文件夹是否存在,不存在可以直接创建
|
|
296
|
+
* @param reaPath {String} 文件路径
|
|
297
|
+
* @returns {Promise<boolean>}
|
|
298
|
+
*/
|
|
299
|
+
function fsMkdir(reaPath, callback) {
|
|
300
|
+
mkdir(reaPath, { recursive: true }, (err, path) => {
|
|
301
|
+
if (err) {
|
|
302
|
+
console.log("0", err);
|
|
303
|
+
if (callback) callback(reaPath, false);
|
|
304
|
+
} else if (callback) callback(reaPath, true, path);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* 当前目录文件地址
|
|
309
|
+
* @param url 文件目录地址
|
|
310
|
+
* @param callback 执行回调方法
|
|
311
|
+
* @returns
|
|
312
|
+
*/
|
|
313
|
+
function writeInit(url, callback, isDirs, isFile, issynch) {
|
|
314
|
+
return new Promise(async (resolve) => {
|
|
315
|
+
if (url) resolve(await writeFileUrl(url, await fsReaddir(url), callback, isDirs, isFile, issynch));
|
|
316
|
+
else resolve([]);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 读取子目录
|
|
321
|
+
* @param url
|
|
322
|
+
* @param file
|
|
323
|
+
* @param callback
|
|
324
|
+
* @returns
|
|
325
|
+
*/
|
|
326
|
+
function writeFileUrl(url, files, callback, isDirs, isFile, issynch) {
|
|
327
|
+
return new Promise(async (resolve) => {
|
|
328
|
+
const arr = [];
|
|
329
|
+
const dirs = [];
|
|
330
|
+
if (files.dirs.length > 0) for (let i = 0; i < files.dirs.length; i++) {
|
|
331
|
+
const dir = files.dirs[i];
|
|
332
|
+
let is = true;
|
|
333
|
+
if (isDirs) is = isDirs(url, dir);
|
|
334
|
+
if (is) {
|
|
335
|
+
dirs.push(dir);
|
|
336
|
+
const urls = await writeInit(join(url, dir), callback, isDirs, isFile, issynch);
|
|
337
|
+
arr.push(...urls);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
files.dirs = dirs;
|
|
341
|
+
const file = [];
|
|
342
|
+
if (files.file.length > 0) files.file.forEach((name) => {
|
|
343
|
+
let is = true;
|
|
344
|
+
if (isFile) is = isFile(url, name);
|
|
345
|
+
if (is) {
|
|
346
|
+
file.push(name);
|
|
347
|
+
arr.push(join(url, name));
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
files.file = file;
|
|
351
|
+
if (callback) if (issynch) await callback(url, files, arr);
|
|
352
|
+
else callback(url, files, arr);
|
|
353
|
+
resolve(arr);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region node_modules/.pnpm/@fangzhongya+create@0.2.52/node_modules/@fangzhongya/create/dist/com-CzlVBzld.js
|
|
358
|
+
function styleLog(msg = "", obj) {
|
|
359
|
+
const arr = ["\x1B[0m"];
|
|
360
|
+
if (obj?.revert) arr.push("\x1B[4m");
|
|
361
|
+
if (obj?.lineThrough) arr.push("\x1B[9m");
|
|
362
|
+
if (obj?.italic) arr.push("\x1B[3m");
|
|
363
|
+
if (obj?.bold) arr.push("\x1B[1m");
|
|
364
|
+
if (obj?.bag) arr.push(`\x1B[4${obj?.bag}m`);
|
|
365
|
+
else arr.push("\x1B[40m");
|
|
366
|
+
if (obj?.text) arr.push(`\x1B[3${obj?.text}m`);
|
|
367
|
+
else arr.push("\x1B[30m");
|
|
368
|
+
arr.push(msg);
|
|
369
|
+
arr.push("\x1B[0m");
|
|
370
|
+
return arr.join("");
|
|
371
|
+
}
|
|
372
|
+
function getSuffix(url) {
|
|
373
|
+
const regs = /\.([a-z|A-Z][a-z|A-Z|0-9]*)$/.exec(url);
|
|
374
|
+
if (regs && regs.length > 0) return regs[1];
|
|
375
|
+
return "";
|
|
376
|
+
}
|
|
377
|
+
function matchsEnd(key, matchs) {
|
|
378
|
+
if (matchs && matchs.length > 0) {
|
|
379
|
+
for (const value of matchs) if (typeof value == "string") {
|
|
380
|
+
if (key.endsWith(value)) return true;
|
|
381
|
+
} else if (value.test(key)) return true;
|
|
382
|
+
return false;
|
|
383
|
+
} else return true;
|
|
384
|
+
}
|
|
385
|
+
function matchsStart(key, matchs) {
|
|
386
|
+
if (matchs && matchs.length > 0) {
|
|
387
|
+
for (const value of matchs) if (typeof value == "string") {
|
|
388
|
+
if (key.startsWith(value)) return true;
|
|
389
|
+
} else if (value.test(key)) return true;
|
|
390
|
+
return false;
|
|
391
|
+
} else return true;
|
|
392
|
+
}
|
|
393
|
+
function getUrlCatalogue(str) {
|
|
394
|
+
return str.replace(/((\\|\/)([^\\|\/]+)(\.[a-z|A-Z][a-z|A-Z|0-9]*))?$/g, "");
|
|
395
|
+
}
|
|
396
|
+
const defaultSuffixReg = /\\.[a-z|A-Z]+$/;
|
|
397
|
+
const defaultConfig$1 = {
|
|
398
|
+
name: "com",
|
|
399
|
+
/**
|
|
400
|
+
* 打包的文件地址
|
|
401
|
+
*/
|
|
402
|
+
dir: "./packages/",
|
|
403
|
+
/**
|
|
404
|
+
* 文件后缀
|
|
405
|
+
*/
|
|
406
|
+
extensions: ["js", "ts"],
|
|
407
|
+
suffixReg: defaultSuffixReg,
|
|
408
|
+
fileTongre: false,
|
|
409
|
+
/**
|
|
410
|
+
* 是否替换文件
|
|
411
|
+
*/
|
|
412
|
+
fileCover: false,
|
|
413
|
+
/**
|
|
414
|
+
* 判断当前文件100个字节内存在 @config cover=true 就不写入
|
|
415
|
+
*/
|
|
416
|
+
coverConfig: false,
|
|
417
|
+
/**
|
|
418
|
+
* 写入注释
|
|
419
|
+
*/
|
|
420
|
+
writeNotes: false,
|
|
421
|
+
/**
|
|
422
|
+
* 读取当前文件,文件的编码类型,默认utf-8
|
|
423
|
+
*/
|
|
424
|
+
read: false,
|
|
425
|
+
/**
|
|
426
|
+
* 匹配目录数组
|
|
427
|
+
* 从头开始匹配
|
|
428
|
+
*/
|
|
429
|
+
matchs: [],
|
|
430
|
+
/**
|
|
431
|
+
* 匹配文件路径
|
|
432
|
+
* 从尾部开始匹配
|
|
433
|
+
*/
|
|
434
|
+
matchexts: [],
|
|
435
|
+
forceUpdate: [],
|
|
436
|
+
/**
|
|
437
|
+
* 不匹配目录数组
|
|
438
|
+
* 从头开始匹配
|
|
439
|
+
*/
|
|
440
|
+
nomatchs: [],
|
|
441
|
+
/**
|
|
442
|
+
* 不匹配文件路径
|
|
443
|
+
* 从尾部开始匹配
|
|
444
|
+
*/
|
|
445
|
+
nomatchexts: [],
|
|
446
|
+
issort: false,
|
|
447
|
+
issynch: false
|
|
448
|
+
};
|
|
449
|
+
function getSuffixReg(ex = []) {
|
|
450
|
+
if (ex.length == 0) return defaultSuffixReg;
|
|
451
|
+
return new RegExp(`\\.(${ex.join("|")})$`);
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* 不清楚怎么定义抽象方法
|
|
455
|
+
*/
|
|
456
|
+
var FangCom = class {
|
|
457
|
+
_configCallback;
|
|
458
|
+
_defaultConfig;
|
|
459
|
+
config;
|
|
460
|
+
constructor(config, callback) {
|
|
461
|
+
this.config = {};
|
|
462
|
+
this._configCallback = callback;
|
|
463
|
+
this._defaultConfig = defaultConfig$1;
|
|
464
|
+
this.initConfig(config);
|
|
465
|
+
}
|
|
466
|
+
async runDev(callback, configCallback, config, nosort) {
|
|
467
|
+
this.initConfig(config);
|
|
468
|
+
const call = configCallback || this._configCallback;
|
|
469
|
+
if (call) {
|
|
470
|
+
const c = call(this.config);
|
|
471
|
+
if (c) this.initConfig(c);
|
|
472
|
+
}
|
|
473
|
+
return await this.handle(callback, nosort);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* 初始化
|
|
477
|
+
* @param config
|
|
478
|
+
* @returns
|
|
479
|
+
*/
|
|
480
|
+
initConfig(config) {
|
|
481
|
+
if (config) {
|
|
482
|
+
this.config = config;
|
|
483
|
+
this.setDefaultConfig();
|
|
484
|
+
this.config.suffixReg = getSuffixReg(this.config.extensions);
|
|
485
|
+
if (!this.config.matchexts || this.config.matchexts.length == 0) this.config.matchexts = [this.config.suffixReg];
|
|
486
|
+
}
|
|
487
|
+
return this.config;
|
|
488
|
+
}
|
|
489
|
+
setDefaultConfig() {
|
|
490
|
+
Object.keys(this._defaultConfig).forEach((key) => {
|
|
491
|
+
if (typeof this.config[key] == "undefined") this.config[key] = this._defaultConfig[key];
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
getFileName(name) {
|
|
495
|
+
if (this.config.suffixReg) return name.replace(this.config.suffixReg, "");
|
|
496
|
+
else return name.replace(defaultSuffixReg, "");
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* 获取当前位置
|
|
500
|
+
* @param dir
|
|
501
|
+
* @returns
|
|
502
|
+
*/
|
|
503
|
+
getDirUrl(dir) {
|
|
504
|
+
const str = dir || this.config.dir;
|
|
505
|
+
if (str) return resolve(process.cwd(), str);
|
|
506
|
+
else return "";
|
|
507
|
+
}
|
|
508
|
+
isForceUpdate(url) {
|
|
509
|
+
if (this.config.forceUpdate && this.config.forceUpdate.length > 0) return matchsEnd(url.replace(/\\/g, "/"), this.config.forceUpdate);
|
|
510
|
+
else return false;
|
|
511
|
+
}
|
|
512
|
+
isMatchFile(url, name) {
|
|
513
|
+
const dirUrl = this.getDirUrl();
|
|
514
|
+
const dir = join(url, name).replace(dirUrl, "").replace(/\\/g, "/");
|
|
515
|
+
const is = matchsEnd(dir, this.config.matchexts);
|
|
516
|
+
const nomatchexts = this.config.nomatchexts;
|
|
517
|
+
if (is && nomatchexts && nomatchexts.length > 0) if (matchsEnd(dir, nomatchexts)) return false;
|
|
518
|
+
else return true;
|
|
519
|
+
else return is;
|
|
520
|
+
}
|
|
521
|
+
isMatchDir(url, name) {
|
|
522
|
+
const dirUrl = this.getDirUrl();
|
|
523
|
+
const dir = join(url, name).replace(dirUrl, "").replace(/\\/g, "/");
|
|
524
|
+
const is = matchsStart(dir, this.config.matchs);
|
|
525
|
+
const nomatchs = this.config.nomatchs;
|
|
526
|
+
if (is && nomatchs && nomatchs.length > 0) if (matchsStart(dir, nomatchs)) return false;
|
|
527
|
+
else return true;
|
|
528
|
+
else return is;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* 处理方法
|
|
532
|
+
* @param callback
|
|
533
|
+
*/
|
|
534
|
+
handle(callback, nosort) {
|
|
535
|
+
return new Promise(async (resolve) => {
|
|
536
|
+
const url = this.getDirUrl();
|
|
537
|
+
if (url) resolve(await writeInit(url, async (...arr) => {
|
|
538
|
+
if (callback) await callback(...arr);
|
|
539
|
+
return await this.writeCallback(...arr, nosort);
|
|
540
|
+
}, (...arr) => {
|
|
541
|
+
return this.isMatchDir(...arr);
|
|
542
|
+
}, (...arr) => {
|
|
543
|
+
return this.isMatchFile(...arr);
|
|
544
|
+
}, this.config.issynch));
|
|
545
|
+
else resolve([]);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
getFileNotes(url) {
|
|
549
|
+
const suffix = getSuffix(url);
|
|
550
|
+
const sz = [
|
|
551
|
+
`@config cover=false`,
|
|
552
|
+
`cover 是否覆盖当前文件,默认是false, true 表示不覆盖`,
|
|
553
|
+
`当前已经由@fangzhongya/create自动生成`,
|
|
554
|
+
`${(/* @__PURE__ */ new Date()).toString()}`
|
|
555
|
+
];
|
|
556
|
+
if ([
|
|
557
|
+
"md",
|
|
558
|
+
"html",
|
|
559
|
+
"vue"
|
|
560
|
+
].includes(suffix)) {
|
|
561
|
+
const arr = ["<!--"];
|
|
562
|
+
sz.forEach((v) => {
|
|
563
|
+
arr.push(" - " + v);
|
|
564
|
+
});
|
|
565
|
+
arr.push("-->");
|
|
566
|
+
return arr;
|
|
567
|
+
} else {
|
|
568
|
+
const arr = ["/**"];
|
|
569
|
+
sz.forEach((v) => {
|
|
570
|
+
arr.push(" * " + v);
|
|
571
|
+
});
|
|
572
|
+
arr.push(" */");
|
|
573
|
+
return arr;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* 输出文件,判断目录是否存在
|
|
578
|
+
* @param url
|
|
579
|
+
* @param sts
|
|
580
|
+
*/
|
|
581
|
+
fileOpen(url, sts, fileUrls, type) {
|
|
582
|
+
fsMkdir(getUrlCatalogue(url), (reaPath, is, ml) => {
|
|
583
|
+
const logs = this.getLogs();
|
|
584
|
+
logs.push(styleLog("dir", {}));
|
|
585
|
+
if (is) {
|
|
586
|
+
if (ml) {
|
|
587
|
+
logs.push(styleLog("add", {
|
|
588
|
+
text: 2,
|
|
589
|
+
italic: true
|
|
590
|
+
}));
|
|
591
|
+
logs.push(styleLog(reaPath, {
|
|
592
|
+
text: 2,
|
|
593
|
+
revert: true
|
|
594
|
+
}));
|
|
595
|
+
console.log(logs.join(" "));
|
|
596
|
+
}
|
|
597
|
+
} else {
|
|
598
|
+
logs.push(styleLog(reaPath, {
|
|
599
|
+
text: 1,
|
|
600
|
+
revert: true
|
|
601
|
+
}));
|
|
602
|
+
console.log(logs.join(" "));
|
|
603
|
+
}
|
|
604
|
+
this.setOpen(url, sts, type, (kurl, _type, is, _tn) => {
|
|
605
|
+
if (is && fileUrls) fileUrls.push(kurl);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* 输出文件
|
|
611
|
+
* @param url
|
|
612
|
+
* @param str
|
|
613
|
+
* @param callback
|
|
614
|
+
*/
|
|
615
|
+
setOpen(url, str, type, callback) {
|
|
616
|
+
let tn = this.config.fileTongre ? 3 : 2;
|
|
617
|
+
if (this.config.fileCover) tn = 0;
|
|
618
|
+
if (tn == 2) {
|
|
619
|
+
if (this.isForceUpdate(url)) tn = 0;
|
|
620
|
+
}
|
|
621
|
+
if (typeof type != "undefined") tn = type;
|
|
622
|
+
if (this.config.writeNotes && !/\.json$/.test(url)) str = this.getFileNotes(url).join("\n") + "\n" + str;
|
|
623
|
+
fsOpenStream(url, str, tn, this.config.coverConfig, (kurl, type, is) => {
|
|
624
|
+
if (!(tn == 2 && type == 2)) {
|
|
625
|
+
const logs = this.getLogs();
|
|
626
|
+
logs.push(styleLog("file", {}));
|
|
627
|
+
if (type == 1) logs.push(styleLog("add", {
|
|
628
|
+
text: 2,
|
|
629
|
+
italic: true
|
|
630
|
+
}));
|
|
631
|
+
else if (type == 2) logs.push(styleLog("update", {
|
|
632
|
+
italic: true,
|
|
633
|
+
text: 4
|
|
634
|
+
}));
|
|
635
|
+
if (is) logs.push(styleLog(kurl, {
|
|
636
|
+
text: 2,
|
|
637
|
+
revert: true
|
|
638
|
+
}));
|
|
639
|
+
else logs.push(styleLog(kurl, {
|
|
640
|
+
text: 1,
|
|
641
|
+
revert: true
|
|
642
|
+
}));
|
|
643
|
+
console.log(logs.join(" "));
|
|
644
|
+
}
|
|
645
|
+
if (callback) callback(kurl, type, is, tn);
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* 获取日志头
|
|
650
|
+
*/
|
|
651
|
+
getLogs() {
|
|
652
|
+
const logs = [];
|
|
653
|
+
logs.push(styleLog("[@fangzhongya/create]", { text: 3 }));
|
|
654
|
+
logs.push(styleLog(this._defaultConfig.name, { text: 4 }));
|
|
655
|
+
return logs;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region node_modules/.pnpm/@fangzhongya+create@0.2.52/node_modules/@fangzhongya/create/dist/chunk-KDOS4NFR-4twmajmu.js
|
|
660
|
+
function getStartSames(str, val) {
|
|
661
|
+
let s = "";
|
|
662
|
+
const vs = [...val];
|
|
663
|
+
let index = 0;
|
|
664
|
+
for (; index < vs.length; index++) {
|
|
665
|
+
const element = vs[index];
|
|
666
|
+
if (element === str.charAt(index)) s += element;
|
|
667
|
+
else break;
|
|
668
|
+
}
|
|
669
|
+
return [
|
|
670
|
+
s,
|
|
671
|
+
str.substring(index),
|
|
672
|
+
val.substring(index)
|
|
673
|
+
];
|
|
674
|
+
}
|
|
675
|
+
function getImportUrl(url, imp) {
|
|
676
|
+
const arr = getStartSames(url, imp);
|
|
677
|
+
const ts = arr[0];
|
|
678
|
+
if (!/[\\|\/]$/.test(ts)) {
|
|
679
|
+
const regs = ts.match(/[\\|\/]([^\\|\/]*)$/);
|
|
680
|
+
if (regs && regs.length > 0) {
|
|
681
|
+
const a = regs[1];
|
|
682
|
+
arr[0] = ts.substring(0, regs.index + 1);
|
|
683
|
+
arr[1] = a + arr[1];
|
|
684
|
+
arr[2] = a + arr[2];
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
const l = arr[1].split(/\\|\//).length - 1;
|
|
688
|
+
let ds = ["./"];
|
|
689
|
+
if (l > 0) {
|
|
690
|
+
ds = [];
|
|
691
|
+
for (let index = 0; index < l; index++) ds.push("../");
|
|
692
|
+
}
|
|
693
|
+
return ds.join("") + arr[2].replace(/\\/g, "/");
|
|
694
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region node_modules/.pnpm/@fangzhongya+create@0.2.52/node_modules/@fangzhongya/create/dist/chunk-NWIJYHAJ-CaD2i2BV.js
|
|
697
|
+
function getImportUrlSuffix(url, imp) {
|
|
698
|
+
return getImportUrl(url, imp).replace(/\.([a-z|A-Z][a-z|A-Z|0-9]*)$/, "");
|
|
699
|
+
}
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region node_modules/.pnpm/@fangzhongya+create@0.2.52/node_modules/@fangzhongya/create/dist/file.js
|
|
702
|
+
const defaultConfig = Object.assign({}, defaultConfig$1, {
|
|
703
|
+
name: "file",
|
|
704
|
+
/**
|
|
705
|
+
* 生成的文件名称
|
|
706
|
+
*/
|
|
707
|
+
gene: void 0,
|
|
708
|
+
/**
|
|
709
|
+
* 文件生成方法
|
|
710
|
+
*/
|
|
711
|
+
fileSet: void 0
|
|
712
|
+
});
|
|
713
|
+
var FangFile = class extends FangCom {
|
|
714
|
+
constructor(config, callback) {
|
|
715
|
+
super();
|
|
716
|
+
this.config = {};
|
|
717
|
+
this._configCallback = callback;
|
|
718
|
+
this._defaultConfig = defaultConfig;
|
|
719
|
+
this.initConfig(config || this.config);
|
|
720
|
+
}
|
|
721
|
+
getDefaultGene(name, url, _wj) {
|
|
722
|
+
return join(url, name);
|
|
723
|
+
}
|
|
724
|
+
getDefaultFileSet(_name, _url, _text, _wjm, _imp, _surl) {
|
|
725
|
+
return [];
|
|
726
|
+
}
|
|
727
|
+
getGeneObj(url, name, outDir) {
|
|
728
|
+
return getUrlCatalogueObj(join(resolve(process.cwd(), outDir), join(url, name).replace(this.getDirUrl(), "")));
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* 获取输出地址方法
|
|
732
|
+
* @param gene
|
|
733
|
+
* @returns
|
|
734
|
+
*/
|
|
735
|
+
getGene(gene) {
|
|
736
|
+
gene = gene || this.config.gene;
|
|
737
|
+
if (!gene) return (...arr) => {
|
|
738
|
+
return this.getDefaultGene(...arr);
|
|
739
|
+
};
|
|
740
|
+
else return gene;
|
|
741
|
+
}
|
|
742
|
+
fileRead(url, type) {
|
|
743
|
+
return new Promise((resolve) => {
|
|
744
|
+
fsAccess(url).then(() => {
|
|
745
|
+
resolve(fsReadFile(url, type));
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
getFileSet(fileSet) {
|
|
750
|
+
fileSet = fileSet || this.config.fileSet;
|
|
751
|
+
if (!fileSet) return (...arr) => {
|
|
752
|
+
return this.getDefaultFileSet(...arr);
|
|
753
|
+
};
|
|
754
|
+
else return fileSet;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* 回调方法
|
|
758
|
+
* @param url
|
|
759
|
+
* @param file
|
|
760
|
+
* @param urls
|
|
761
|
+
*/
|
|
762
|
+
async writeCallback(url, readdir, fileUrls) {
|
|
763
|
+
const gene = this.getGene();
|
|
764
|
+
const fileSet = this.getFileSet();
|
|
765
|
+
const read = this.config.read;
|
|
766
|
+
if (readdir.file) for (let i = 0; i < readdir.file.length; i++) {
|
|
767
|
+
const name = readdir.file[i];
|
|
768
|
+
const furl = join(url, name);
|
|
769
|
+
const wjmc = this.getFileName(name);
|
|
770
|
+
const gu = gene(name, url, wjmc);
|
|
771
|
+
const imp = getImportUrlSuffix(gu, furl);
|
|
772
|
+
const arr = [];
|
|
773
|
+
if (fileSet) {
|
|
774
|
+
let text = "";
|
|
775
|
+
if (read) text = await fsReadFile(furl, read);
|
|
776
|
+
arr.push(...fileSet(name, url, text, wjmc, imp, gu));
|
|
777
|
+
}
|
|
778
|
+
if (arr.length > 0) this.fileOpen(gu, arr.join("\n"), fileUrls);
|
|
779
|
+
}
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
async function runDev(config, configCallback, callback) {
|
|
784
|
+
await new FangFile(config).runDev(callback, configCallback);
|
|
785
|
+
}
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region packages/imports.ts
|
|
788
|
+
const type = "import";
|
|
789
|
+
/**
|
|
790
|
+
* 自动注册组件和指令的方法
|
|
791
|
+
*/
|
|
792
|
+
var FangImport = class {
|
|
793
|
+
config;
|
|
794
|
+
#comUrls;
|
|
795
|
+
#cacheObj;
|
|
796
|
+
#exports;
|
|
797
|
+
constructor(config) {
|
|
798
|
+
this.config = config || {};
|
|
799
|
+
this.#setConfigValue();
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* 初始化数据
|
|
803
|
+
*/
|
|
804
|
+
#setConfigValue() {
|
|
805
|
+
/**
|
|
806
|
+
* 组件的地址
|
|
807
|
+
*/
|
|
808
|
+
this.#comUrls = [];
|
|
809
|
+
/**
|
|
810
|
+
* 缓存的数据
|
|
811
|
+
*/
|
|
812
|
+
this.#cacheObj = {};
|
|
813
|
+
this.#exports = {};
|
|
814
|
+
/**
|
|
815
|
+
* 当前完整的地址
|
|
816
|
+
*/
|
|
817
|
+
this.#getUrls();
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* 读取url地址列表
|
|
821
|
+
*/
|
|
822
|
+
#getUrls() {
|
|
823
|
+
runDev({
|
|
824
|
+
dir: this.config.dir,
|
|
825
|
+
extensions: this.config.extensions,
|
|
826
|
+
writeNotes: false,
|
|
827
|
+
coverConfig: false,
|
|
828
|
+
fileTongre: false,
|
|
829
|
+
fileCover: false,
|
|
830
|
+
issort: false,
|
|
831
|
+
issynch: false,
|
|
832
|
+
read: true,
|
|
833
|
+
matchs: this.config.matchs,
|
|
834
|
+
matchexts: this.config.matchexts,
|
|
835
|
+
nomatchs: this.config.nomatchs,
|
|
836
|
+
nomatchexts: this.config.nomatchexts,
|
|
837
|
+
fileSet: (name, url, text, wjm, _imp, surl) => {
|
|
838
|
+
const dm = wjm || name.replace(/\.([^.]+)$/, "");
|
|
839
|
+
const u = (surl || join(url, name)).replace(/\\/g, "/");
|
|
840
|
+
const es = getExports(text);
|
|
841
|
+
if (es.default) es.default = dm;
|
|
842
|
+
this.#comUrls?.push(u);
|
|
843
|
+
this.#exports[u] = es;
|
|
844
|
+
return [];
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* 获取当前缓存数
|
|
850
|
+
* @param {String} name 名称
|
|
851
|
+
* @param {String} type 类型
|
|
852
|
+
* @returns { Object } 注册的对象
|
|
853
|
+
*/
|
|
854
|
+
#getCache(name) {
|
|
855
|
+
if (this.#cacheObj) return this.#cacheObj[name];
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* 设置缓存数据
|
|
859
|
+
* @param {String} name 名称
|
|
860
|
+
* @param {String} type 类型
|
|
861
|
+
* @param { Object } 注册的对象
|
|
862
|
+
*/
|
|
863
|
+
#setCache(name, obj) {
|
|
864
|
+
this.#cacheObj = this.#cacheObj || {};
|
|
865
|
+
this.#cacheObj[name] = obj;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* 是否要替换
|
|
869
|
+
* @param { String } name 名称
|
|
870
|
+
* @returns { Boolean } 是否要替换
|
|
871
|
+
*/
|
|
872
|
+
#namefilter(name) {
|
|
873
|
+
if (this.config.startss) for (let index = 0; index < this.config.startss.length; index++) {
|
|
874
|
+
const element = this.config.startss[index];
|
|
875
|
+
if (name.startsWith(element)) return false;
|
|
876
|
+
}
|
|
877
|
+
if (this.config.filtes) {
|
|
878
|
+
for (let index = 0; index < this.config.filtes.length; index++) if (name === this.config.filtes[index]) return false;
|
|
879
|
+
}
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* 返回对应的值
|
|
884
|
+
* @param {String} from 文件地址
|
|
885
|
+
* @param {String} name 名称
|
|
886
|
+
* @returns { Object } 注册的对象
|
|
887
|
+
*/
|
|
888
|
+
#getNameFromUrl(name) {
|
|
889
|
+
const o = this.#exports || {};
|
|
890
|
+
const keys = Object.keys(o);
|
|
891
|
+
for (const key of keys) {
|
|
892
|
+
const es = o[key];
|
|
893
|
+
if (es.named.includes(name)) return {
|
|
894
|
+
name,
|
|
895
|
+
from: key
|
|
896
|
+
};
|
|
897
|
+
if (es.default === name) return {
|
|
898
|
+
name: "default",
|
|
899
|
+
from: key
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* 通过名称匹配对应路径
|
|
905
|
+
* @param {String} name 名称
|
|
906
|
+
* @param {String} type 类型
|
|
907
|
+
* @returns { Object } 注册的对象
|
|
908
|
+
*/
|
|
909
|
+
#setNameFrom(name) {
|
|
910
|
+
if (this.config.alias) name = name.replace(new RegExp("^" + this.config.alias), "");
|
|
911
|
+
return this.#getNameFromUrl(name);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* 输出日志
|
|
915
|
+
* @param name
|
|
916
|
+
* @param type
|
|
917
|
+
* @param obj
|
|
918
|
+
* @param is
|
|
919
|
+
*/
|
|
920
|
+
#setLog(name, obj, is) {
|
|
921
|
+
if (this.config.log) {
|
|
922
|
+
const texts = 4;
|
|
923
|
+
const arr = [];
|
|
924
|
+
arr.push(styleLog$1("[@fangzhongya/vue-components]", { text: 3 }));
|
|
925
|
+
if (obj && obj.from) {
|
|
926
|
+
let sfrom = styleLog$1(obj?.from, {
|
|
927
|
+
text: 4,
|
|
928
|
+
revert: true
|
|
929
|
+
});
|
|
930
|
+
arr.push(styleLog$1("import", { text: texts }));
|
|
931
|
+
arr.push(styleLog$1(name, { bold: true }));
|
|
932
|
+
if (!is) sfrom = styleLog$1("+", { text: 2 }) + sfrom;
|
|
933
|
+
arr.push(sfrom);
|
|
934
|
+
} else {
|
|
935
|
+
arr.push(styleLog$1(type, { text: texts }));
|
|
936
|
+
arr.push(styleLog$1(name, {
|
|
937
|
+
bold: true,
|
|
938
|
+
text: 1
|
|
939
|
+
}));
|
|
940
|
+
}
|
|
941
|
+
console.log(arr.join(" "));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* 自动按需匹配注册
|
|
946
|
+
* @param {String} name 名称
|
|
947
|
+
* @param {String} type 类型
|
|
948
|
+
* @returns { Object } 注册的对象
|
|
949
|
+
*/
|
|
950
|
+
resolve(name) {
|
|
951
|
+
const cache = this.#getCache(name);
|
|
952
|
+
if (this.config.isCache && cache) {
|
|
953
|
+
this.#setLog(name, cache, true);
|
|
954
|
+
return cache;
|
|
955
|
+
} else if (this.#namefilter(name)) {
|
|
956
|
+
let obj = this.#setNameFrom(name);
|
|
957
|
+
if (obj) {
|
|
958
|
+
this.#setLog(name, obj);
|
|
959
|
+
this.#setCache(name, obj);
|
|
960
|
+
return obj;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
//#endregion
|
|
966
|
+
export { FangImport as t };
|