@fangzhongya/vue-components 0.1.21 → 0.1.23
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 +6 -6
- package/dist/archive.js +4 -4
- package/dist/{chunk-IV2Z7LZ7.js → chunk-3XFEJIQP.js} +8 -8
- package/dist/{chunk-4A5AX2PJ.cjs → chunk-A3DD44G3.cjs} +4 -4
- package/dist/{chunk-LIKH5T7R.cjs → chunk-AFAUWAXD.cjs} +15 -15
- package/dist/{chunk-YW7CKAOG.cjs → chunk-AKNB7BKJ.cjs} +1 -1
- package/dist/{chunk-RHYZ76ZY.js → chunk-M5UXFPLK.js} +2 -2
- package/dist/{chunk-OQIBNUVK.cjs → chunk-NLSI7A24.cjs} +10 -10
- package/dist/chunk-PCU5YQMB.cjs +1237 -0
- package/dist/chunk-SDVC6K2I.js +1237 -0
- package/dist/{chunk-E3I6537N.js → chunk-TVGK2KRP.js} +1 -1
- package/dist/{chunk-25JYZGRF.js → chunk-VMVQOQNJ.js} +4 -4
- package/dist/component.cjs +4 -4
- package/dist/component.js +3 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/import.cjs +28 -0
- package/dist/import.d.cts +10 -0
- package/dist/import.d.ts +10 -0
- package/dist/import.js +28 -0
- package/dist/imports.cjs +8 -0
- package/dist/imports.d.cts +21 -0
- package/dist/imports.d.ts +21 -0
- package/dist/imports.js +8 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +4 -4
- package/dist/library.cjs +2 -2
- package/dist/library.js +1 -1
- package/dist/resolver.cjs +5 -5
- package/dist/resolver.js +4 -4
- package/dist/util.cjs +3 -3
- package/dist/util.js +2 -2
- package/package.json +18 -6
|
@@ -0,0 +1,1237 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
2
|
+
|
|
3
|
+
var _chunkNLSI7A24cjs = require('./chunk-NLSI7A24.cjs');
|
|
4
|
+
|
|
5
|
+
// packages/imports.ts
|
|
6
|
+
var _path = require('path');
|
|
7
|
+
|
|
8
|
+
// node_modules/.pnpm/@fangzhongya+utils@0.0.75/node_modules/@fangzhongya/utils/dist/chunk-FS4JPT23.js
|
|
9
|
+
function deComment(code) {
|
|
10
|
+
let output = "";
|
|
11
|
+
let state = "code";
|
|
12
|
+
let escaping = false;
|
|
13
|
+
let i = 0;
|
|
14
|
+
const len = code.length;
|
|
15
|
+
while (i < len) {
|
|
16
|
+
const char = code[i];
|
|
17
|
+
const nextChar = code[i + 1];
|
|
18
|
+
switch (state) {
|
|
19
|
+
case "code":
|
|
20
|
+
if (char === "/" && nextChar === "/") {
|
|
21
|
+
state = "singleLine";
|
|
22
|
+
i += 2;
|
|
23
|
+
} else if (char === "/" && nextChar === "*") {
|
|
24
|
+
state = "multiLine";
|
|
25
|
+
i += 2;
|
|
26
|
+
} else if (char === "'") {
|
|
27
|
+
state = "singleQuote";
|
|
28
|
+
output += char;
|
|
29
|
+
i++;
|
|
30
|
+
} else if (char === '"') {
|
|
31
|
+
state = "doubleQuote";
|
|
32
|
+
output += char;
|
|
33
|
+
i++;
|
|
34
|
+
} else if (char === "`") {
|
|
35
|
+
state = "template";
|
|
36
|
+
output += char;
|
|
37
|
+
i++;
|
|
38
|
+
} else {
|
|
39
|
+
output += char;
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case "singleLine":
|
|
44
|
+
if (char === "\n" || char === "\r") {
|
|
45
|
+
state = "code";
|
|
46
|
+
output += char;
|
|
47
|
+
i++;
|
|
48
|
+
if (char === "\r" && nextChar === "\n") {
|
|
49
|
+
output += nextChar;
|
|
50
|
+
i++;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
i++;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case "multiLine":
|
|
57
|
+
if (char === "*" && nextChar === "/") {
|
|
58
|
+
state = "code";
|
|
59
|
+
i += 2;
|
|
60
|
+
if (output.length > 0 && /[a-zA-Z0-9_$]$/.test(output) && i < len && /[a-zA-Z0-9_$]/.test(code[i])) {
|
|
61
|
+
output += " ";
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
i++;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case "singleQuote":
|
|
68
|
+
output += char;
|
|
69
|
+
if (!escaping && char === "'") {
|
|
70
|
+
state = "code";
|
|
71
|
+
}
|
|
72
|
+
escaping = !escaping && char === "\\";
|
|
73
|
+
i++;
|
|
74
|
+
break;
|
|
75
|
+
case "doubleQuote":
|
|
76
|
+
output += char;
|
|
77
|
+
if (!escaping && char === '"') {
|
|
78
|
+
state = "code";
|
|
79
|
+
}
|
|
80
|
+
escaping = !escaping && char === "\\";
|
|
81
|
+
i++;
|
|
82
|
+
break;
|
|
83
|
+
case "template":
|
|
84
|
+
output += char;
|
|
85
|
+
if (!escaping && char === "`") {
|
|
86
|
+
state = "code";
|
|
87
|
+
} else if (!escaping && char === "$" && nextChar === "{") {
|
|
88
|
+
output += nextChar;
|
|
89
|
+
i += 2;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
escaping = !escaping && char === "\\";
|
|
93
|
+
i++;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return output;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// node_modules/.pnpm/@fangzhongya+utils@0.0.75/node_modules/@fangzhongya/utils/dist/chunk-4KYAGDPN.js
|
|
101
|
+
var REGEX_PATTERNS = {
|
|
102
|
+
// export const/let/var variableName
|
|
103
|
+
VAR_EXPORT: /export\s+(?:const|let|var)\s+(\w+)/g,
|
|
104
|
+
// export function functionName
|
|
105
|
+
FUNCTION_EXPORT: /export\s+function\s+(\w+)/g,
|
|
106
|
+
// export class ClassName
|
|
107
|
+
CLASS_EXPORT: /export\s+class\s+(\w+)/g,
|
|
108
|
+
// export { a, b as c, d }
|
|
109
|
+
NAMED_EXPORTS: /export\s*\{([^}]+)\}/g,
|
|
110
|
+
// export default identifier
|
|
111
|
+
DEFAULT_EXPORT: /export\s+default\s+(\w+)/,
|
|
112
|
+
// 提取重命名后的名称
|
|
113
|
+
RENAME_SPLIT: /\s+as\s+/
|
|
114
|
+
};
|
|
115
|
+
function getExports(code) {
|
|
116
|
+
code = deComment(code);
|
|
117
|
+
const exports = {
|
|
118
|
+
named: [],
|
|
119
|
+
default: null
|
|
120
|
+
};
|
|
121
|
+
const namedExportsSet = /* @__PURE__ */ new Set();
|
|
122
|
+
const processMatches = (pattern, extractName) => {
|
|
123
|
+
const matches = code.matchAll(pattern);
|
|
124
|
+
for (const match of matches) {
|
|
125
|
+
const name = extractName(match);
|
|
126
|
+
if (name) {
|
|
127
|
+
namedExportsSet.add(name);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
processMatches(REGEX_PATTERNS.VAR_EXPORT, (match) => match[1]);
|
|
132
|
+
processMatches(REGEX_PATTERNS.FUNCTION_EXPORT, (match) => match[1]);
|
|
133
|
+
processMatches(REGEX_PATTERNS.CLASS_EXPORT, (match) => match[1]);
|
|
134
|
+
const namedExportMatches = code.matchAll(REGEX_PATTERNS.NAMED_EXPORTS);
|
|
135
|
+
for (const match of namedExportMatches) {
|
|
136
|
+
const items = match[1];
|
|
137
|
+
if (!items) continue;
|
|
138
|
+
items.split(",").forEach((item) => {
|
|
139
|
+
const trimmed = item.trim();
|
|
140
|
+
if (!trimmed) return;
|
|
141
|
+
const parts = trimmed.split(REGEX_PATTERNS.RENAME_SPLIT);
|
|
142
|
+
const name = parts[parts.length - 1].trim();
|
|
143
|
+
if (name) {
|
|
144
|
+
namedExportsSet.add(name);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const defaultMatch = code.match(REGEX_PATTERNS.DEFAULT_EXPORT);
|
|
149
|
+
if (defaultMatch) {
|
|
150
|
+
exports.default = defaultMatch[1];
|
|
151
|
+
}
|
|
152
|
+
exports.named = Array.from(namedExportsSet).sort();
|
|
153
|
+
return exports;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// node_modules/.pnpm/@fangzhongya+create@0.2.50/node_modules/@fangzhongya/create/dist/chunk-ER44O4IJ.js
|
|
157
|
+
function getStartSames(str, val) {
|
|
158
|
+
let s = "";
|
|
159
|
+
const vs = [...val];
|
|
160
|
+
let index = 0;
|
|
161
|
+
for (; index < vs.length; index++) {
|
|
162
|
+
const element = vs[index];
|
|
163
|
+
if (element === str.charAt(index)) {
|
|
164
|
+
s += element;
|
|
165
|
+
} else {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [s, str.substring(index), val.substring(index)];
|
|
170
|
+
}
|
|
171
|
+
function getImportUrl(url, imp) {
|
|
172
|
+
const arr = getStartSames(url, imp);
|
|
173
|
+
const ts = arr[0];
|
|
174
|
+
if (!/[\\|\/]$/.test(ts)) {
|
|
175
|
+
const regs = ts.match(/[\\|\/]([^\\|\/]*)$/);
|
|
176
|
+
if (regs && regs.length > 0) {
|
|
177
|
+
const a = regs[1];
|
|
178
|
+
arr[0] = ts.substring(0, regs.index + 1);
|
|
179
|
+
arr[1] = a + arr[1];
|
|
180
|
+
arr[2] = a + arr[2];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const l = arr[1].split(/\\|\//).length - 1;
|
|
184
|
+
let ds = ["./"];
|
|
185
|
+
if (l > 0) {
|
|
186
|
+
ds = [];
|
|
187
|
+
for (let index = 0; index < l; index++) {
|
|
188
|
+
ds.push("../");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return ds.join("") + arr[2].replace(/\\/g, "/");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// node_modules/.pnpm/@fangzhongya+create@0.2.50/node_modules/@fangzhongya/create/dist/chunk-A7RAGYE3.js
|
|
195
|
+
function getImportUrlSuffix(url, imp) {
|
|
196
|
+
return getImportUrl(url, imp).replace(/\.([a-z|A-Z][a-z|A-Z|0-9]*)$/, "");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// node_modules/.pnpm/@fangzhongya+create@0.2.50/node_modules/@fangzhongya/create/dist/chunk-36XULS54.js
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
var _fs = require('fs');
|
|
212
|
+
|
|
213
|
+
function getUrlCatalogueObj(str) {
|
|
214
|
+
const reg = /(\\|\/)([^\\|\/]+)\.([a-z|A-Z][a-z|A-Z|0-9]*)$/g;
|
|
215
|
+
const ml = str.replace(reg, "");
|
|
216
|
+
let name = "";
|
|
217
|
+
let suffix = "";
|
|
218
|
+
let apart = "";
|
|
219
|
+
const arr = reg.exec(str);
|
|
220
|
+
if (arr) {
|
|
221
|
+
apart = arr[1];
|
|
222
|
+
name = arr[2];
|
|
223
|
+
suffix = arr[3];
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
catalogue: ml,
|
|
227
|
+
name,
|
|
228
|
+
suffix,
|
|
229
|
+
apart
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function getNewFileName(url) {
|
|
233
|
+
const obj = getUrlCatalogueObj(url);
|
|
234
|
+
let wb = obj.name;
|
|
235
|
+
if (wb) {
|
|
236
|
+
const reg = /([0-9]+)$/g;
|
|
237
|
+
const regs = reg.exec(wb);
|
|
238
|
+
if (regs && regs.length > 0) {
|
|
239
|
+
const sl = Number(regs[1]) + 1;
|
|
240
|
+
const reg1 = new RegExp(regs[1] + "$");
|
|
241
|
+
wb = wb.replace(reg1, (sl + "").padStart(regs[1].length, "0"));
|
|
242
|
+
} else {
|
|
243
|
+
wb = wb + "1";
|
|
244
|
+
}
|
|
245
|
+
return obj.catalogue + obj.apart + wb + "." + obj.suffix;
|
|
246
|
+
} else {
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function fsReadFile(url, type2) {
|
|
251
|
+
if (!type2 || type2 === true) {
|
|
252
|
+
type2 = "utf-8";
|
|
253
|
+
}
|
|
254
|
+
return new Promise((resolve3, reject) => {
|
|
255
|
+
_fs.readFile.call(void 0, url, type2, (err, dataStr) => {
|
|
256
|
+
if (err) {
|
|
257
|
+
console.log("2", err);
|
|
258
|
+
reject("");
|
|
259
|
+
} else {
|
|
260
|
+
resolve3(dataStr);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function fsCreateReadStream(url, type2) {
|
|
266
|
+
if (!type2 || type2 === true) {
|
|
267
|
+
type2 = "utf-8";
|
|
268
|
+
}
|
|
269
|
+
return new Promise((resolve3) => {
|
|
270
|
+
const stream = _fs.createReadStream.call(void 0, url, {
|
|
271
|
+
start: 0,
|
|
272
|
+
end: 100,
|
|
273
|
+
encoding: type2
|
|
274
|
+
});
|
|
275
|
+
let st = "";
|
|
276
|
+
stream.on("data", (data) => {
|
|
277
|
+
st += data;
|
|
278
|
+
});
|
|
279
|
+
stream.on("end", () => {
|
|
280
|
+
resolve3(st);
|
|
281
|
+
});
|
|
282
|
+
stream.on("error", () => {
|
|
283
|
+
resolve3("");
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function fsAccess(reaPath) {
|
|
288
|
+
return new Promise((resolve3) => {
|
|
289
|
+
try {
|
|
290
|
+
_fs.access.call(void 0, reaPath, _fs.constants.F_OK, (err) => {
|
|
291
|
+
if (err) {
|
|
292
|
+
resolve3(false);
|
|
293
|
+
} else {
|
|
294
|
+
resolve3(true);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
} catch (e) {
|
|
298
|
+
resolve3(false);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function fsReaddir(filePath) {
|
|
303
|
+
return new Promise((resolve3, reject) => {
|
|
304
|
+
_fs.readdir.call(void 0, filePath, (err, files) => {
|
|
305
|
+
if (err) {
|
|
306
|
+
reject(err);
|
|
307
|
+
} else {
|
|
308
|
+
const lg = files.length;
|
|
309
|
+
const dirs = [];
|
|
310
|
+
const file = [];
|
|
311
|
+
if (lg) {
|
|
312
|
+
let i = 0;
|
|
313
|
+
files.forEach((filename) => {
|
|
314
|
+
const filedir = _path.join.call(void 0, filePath, filename);
|
|
315
|
+
_fs.stat.call(void 0, filedir, (err2, stats) => {
|
|
316
|
+
i++;
|
|
317
|
+
if (err2) {
|
|
318
|
+
console.log("4", err2);
|
|
319
|
+
} else {
|
|
320
|
+
const isFile = stats.isFile();
|
|
321
|
+
const isDir = stats.isDirectory();
|
|
322
|
+
if (isFile) {
|
|
323
|
+
file.push(filename);
|
|
324
|
+
}
|
|
325
|
+
if (isDir) {
|
|
326
|
+
dirs.push(filename);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (i >= lg) {
|
|
330
|
+
resolve3({
|
|
331
|
+
file,
|
|
332
|
+
dirs
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
resolve3({
|
|
339
|
+
file,
|
|
340
|
+
dirs
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function fsOpenStream(path, json, type2 = 0, cover, callback) {
|
|
348
|
+
_fs.open.call(void 0, path, "wx", async (err, fd) => {
|
|
349
|
+
if (err) {
|
|
350
|
+
if (err.code === "EEXIST") {
|
|
351
|
+
if (type2 == 1 || type2 == 0) {
|
|
352
|
+
const fwrite = () => {
|
|
353
|
+
_fs.writeFile.call(void 0, path, json, "utf-8", (err2) => {
|
|
354
|
+
if (err2) {
|
|
355
|
+
console.log("6", err2);
|
|
356
|
+
if (callback) {
|
|
357
|
+
callback(path, cover ? 3 : 2, false, type2);
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
if (callback) {
|
|
361
|
+
callback(path, cover ? 3 : 2, true, type2);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
if (cover) {
|
|
367
|
+
const st = await fsCreateReadStream(path);
|
|
368
|
+
if (!st.includes("@config cover=true")) {
|
|
369
|
+
fwrite();
|
|
370
|
+
} else {
|
|
371
|
+
if (callback) callback(path, 3, false, type2);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
fwrite();
|
|
375
|
+
}
|
|
376
|
+
} else if (type2 == 3) {
|
|
377
|
+
path = getNewFileName(path);
|
|
378
|
+
if (path) {
|
|
379
|
+
fsOpenStream(path, json, type2, cover, callback);
|
|
380
|
+
} else {
|
|
381
|
+
if (callback) {
|
|
382
|
+
callback(path, 3, false, type2);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
if (callback) {
|
|
387
|
+
callback(path, 2, false, type2);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
if (callback) {
|
|
392
|
+
callback(path, 0, false, type2);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
if (type2 != 1) {
|
|
397
|
+
_fs.write.call(void 0, fd, json, (err2) => {
|
|
398
|
+
if (err2) {
|
|
399
|
+
console.log("8", err2);
|
|
400
|
+
if (callback) {
|
|
401
|
+
callback(path, 1, false, type2);
|
|
402
|
+
}
|
|
403
|
+
} else {
|
|
404
|
+
if (callback) {
|
|
405
|
+
callback(path, 1, true, type2);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
if (callback) {
|
|
411
|
+
callback(path, 1, false, type2);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function fsMkdir(reaPath, callback) {
|
|
418
|
+
_fs.mkdir.call(void 0, reaPath, { recursive: true }, (err, path) => {
|
|
419
|
+
if (err) {
|
|
420
|
+
console.log("0", err);
|
|
421
|
+
if (callback) {
|
|
422
|
+
callback(reaPath, false);
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
if (callback) {
|
|
426
|
+
callback(reaPath, true, path);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function writeInit(url, callback, isDirs, isFile, issynch) {
|
|
432
|
+
return new Promise(async (resolve3) => {
|
|
433
|
+
if (url) {
|
|
434
|
+
const data = await fsReaddir(url);
|
|
435
|
+
const arr = await writeFileUrl(
|
|
436
|
+
url,
|
|
437
|
+
data,
|
|
438
|
+
callback,
|
|
439
|
+
isDirs,
|
|
440
|
+
isFile,
|
|
441
|
+
issynch
|
|
442
|
+
);
|
|
443
|
+
resolve3(arr);
|
|
444
|
+
} else {
|
|
445
|
+
resolve3([]);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function writeFileUrl(url, files, callback, isDirs, isFile, issynch) {
|
|
450
|
+
return new Promise(async (resolve3) => {
|
|
451
|
+
const arr = [];
|
|
452
|
+
const dirs = [];
|
|
453
|
+
if (files.dirs.length > 0) {
|
|
454
|
+
for (let i = 0; i < files.dirs.length; i++) {
|
|
455
|
+
const dir = files.dirs[i];
|
|
456
|
+
let is = true;
|
|
457
|
+
if (isDirs) {
|
|
458
|
+
is = isDirs(url, dir);
|
|
459
|
+
}
|
|
460
|
+
if (is) {
|
|
461
|
+
dirs.push(dir);
|
|
462
|
+
const urls = await writeInit(
|
|
463
|
+
_path.join.call(void 0, url, dir),
|
|
464
|
+
callback,
|
|
465
|
+
isDirs,
|
|
466
|
+
isFile,
|
|
467
|
+
issynch
|
|
468
|
+
);
|
|
469
|
+
arr.push(...urls);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
files.dirs = dirs;
|
|
474
|
+
const file = [];
|
|
475
|
+
if (files.file.length > 0) {
|
|
476
|
+
files.file.forEach((name) => {
|
|
477
|
+
let is = true;
|
|
478
|
+
if (isFile) {
|
|
479
|
+
is = isFile(url, name);
|
|
480
|
+
}
|
|
481
|
+
if (is) {
|
|
482
|
+
file.push(name);
|
|
483
|
+
arr.push(_path.join.call(void 0, url, name));
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
files.file = file;
|
|
488
|
+
if (callback) {
|
|
489
|
+
if (issynch) {
|
|
490
|
+
await callback(url, files, arr);
|
|
491
|
+
} else {
|
|
492
|
+
callback(url, files, arr);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
resolve3(arr);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// node_modules/.pnpm/@fangzhongya+create@0.2.50/node_modules/@fangzhongya/create/dist/chunk-55GZI3ZZ.js
|
|
500
|
+
|
|
501
|
+
function styleLog2(msg = "", obj) {
|
|
502
|
+
const arr = ["\x1B[0m"];
|
|
503
|
+
if (_optionalChain([obj, 'optionalAccess', _ => _.revert])) {
|
|
504
|
+
arr.push("\x1B[4m");
|
|
505
|
+
}
|
|
506
|
+
if (_optionalChain([obj, 'optionalAccess', _2 => _2.lineThrough])) {
|
|
507
|
+
arr.push("\x1B[9m");
|
|
508
|
+
}
|
|
509
|
+
if (_optionalChain([obj, 'optionalAccess', _3 => _3.italic])) {
|
|
510
|
+
arr.push("\x1B[3m");
|
|
511
|
+
}
|
|
512
|
+
if (_optionalChain([obj, 'optionalAccess', _4 => _4.bold])) {
|
|
513
|
+
arr.push("\x1B[1m");
|
|
514
|
+
}
|
|
515
|
+
if (_optionalChain([obj, 'optionalAccess', _5 => _5.bag])) {
|
|
516
|
+
arr.push(`\x1B[4${_optionalChain([obj, 'optionalAccess', _6 => _6.bag])}m`);
|
|
517
|
+
} else {
|
|
518
|
+
arr.push("\x1B[40m");
|
|
519
|
+
}
|
|
520
|
+
if (_optionalChain([obj, 'optionalAccess', _7 => _7.text])) {
|
|
521
|
+
arr.push(`\x1B[3${_optionalChain([obj, 'optionalAccess', _8 => _8.text])}m`);
|
|
522
|
+
} else {
|
|
523
|
+
arr.push("\x1B[30m");
|
|
524
|
+
}
|
|
525
|
+
arr.push(msg);
|
|
526
|
+
arr.push("\x1B[0m");
|
|
527
|
+
return arr.join("");
|
|
528
|
+
}
|
|
529
|
+
function getSuffix(url) {
|
|
530
|
+
const reg = /\.([a-z|A-Z][a-z|A-Z|0-9]*)$/;
|
|
531
|
+
const regs = reg.exec(url);
|
|
532
|
+
if (regs && regs.length > 0) {
|
|
533
|
+
return regs[1];
|
|
534
|
+
}
|
|
535
|
+
return "";
|
|
536
|
+
}
|
|
537
|
+
function matchsEnd(key, matchs) {
|
|
538
|
+
if (matchs && matchs.length > 0) {
|
|
539
|
+
for (const value of matchs) {
|
|
540
|
+
if (typeof value == "string") {
|
|
541
|
+
if (key.endsWith(value)) {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
} else {
|
|
545
|
+
if (value.test(key)) {
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return false;
|
|
551
|
+
} else {
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function matchsStart(key, matchs) {
|
|
556
|
+
if (matchs && matchs.length > 0) {
|
|
557
|
+
for (const value of matchs) {
|
|
558
|
+
if (typeof value == "string") {
|
|
559
|
+
if (key.startsWith(value)) {
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
} else {
|
|
563
|
+
if (value.test(key)) {
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return false;
|
|
569
|
+
} else {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function getUrlCatalogue(str) {
|
|
574
|
+
const reg = /((\\|\/)([^\\|\/]+)(\.[a-z|A-Z][a-z|A-Z|0-9]*))?$/g;
|
|
575
|
+
return str.replace(reg, "");
|
|
576
|
+
}
|
|
577
|
+
var defaultSuffixReg = /\\.[a-z|A-Z]+$/;
|
|
578
|
+
var defaultConfig = {
|
|
579
|
+
name: "com",
|
|
580
|
+
/**
|
|
581
|
+
* 打包的文件地址
|
|
582
|
+
*/
|
|
583
|
+
dir: "./packages/",
|
|
584
|
+
/**
|
|
585
|
+
* 文件后缀
|
|
586
|
+
*/
|
|
587
|
+
extensions: ["js", "ts"],
|
|
588
|
+
suffixReg: defaultSuffixReg,
|
|
589
|
+
fileTongre: false,
|
|
590
|
+
/**
|
|
591
|
+
* 是否替换文件
|
|
592
|
+
*/
|
|
593
|
+
fileCover: false,
|
|
594
|
+
/**
|
|
595
|
+
* 判断当前文件100个字节内存在 @config cover=true 就不写入
|
|
596
|
+
*/
|
|
597
|
+
coverConfig: false,
|
|
598
|
+
/**
|
|
599
|
+
* 写入注释
|
|
600
|
+
*/
|
|
601
|
+
writeNotes: false,
|
|
602
|
+
/**
|
|
603
|
+
* 读取当前文件,文件的编码类型,默认utf-8
|
|
604
|
+
*/
|
|
605
|
+
read: false,
|
|
606
|
+
/**
|
|
607
|
+
* 匹配目录数组
|
|
608
|
+
* 从头开始匹配
|
|
609
|
+
*/
|
|
610
|
+
matchs: [],
|
|
611
|
+
/**
|
|
612
|
+
* 匹配文件路径
|
|
613
|
+
* 从尾部开始匹配
|
|
614
|
+
*/
|
|
615
|
+
matchexts: [],
|
|
616
|
+
forceUpdate: [],
|
|
617
|
+
/**
|
|
618
|
+
* 不匹配目录数组
|
|
619
|
+
* 从头开始匹配
|
|
620
|
+
*/
|
|
621
|
+
nomatchs: [],
|
|
622
|
+
/**
|
|
623
|
+
* 不匹配文件路径
|
|
624
|
+
* 从尾部开始匹配
|
|
625
|
+
*/
|
|
626
|
+
nomatchexts: [],
|
|
627
|
+
issort: false,
|
|
628
|
+
issynch: false
|
|
629
|
+
};
|
|
630
|
+
function getSuffixReg(ex = []) {
|
|
631
|
+
if (ex.length == 0) {
|
|
632
|
+
return defaultSuffixReg;
|
|
633
|
+
}
|
|
634
|
+
return new RegExp(`\\.(${ex.join("|")})$`);
|
|
635
|
+
}
|
|
636
|
+
var FangCom = class {
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
constructor(config, callback) {
|
|
641
|
+
this.config = {};
|
|
642
|
+
this._configCallback = callback;
|
|
643
|
+
this._defaultConfig = defaultConfig;
|
|
644
|
+
this.initConfig(config);
|
|
645
|
+
}
|
|
646
|
+
async runDev(callback, configCallback, config, nosort) {
|
|
647
|
+
this.initConfig(config);
|
|
648
|
+
const call = configCallback || this._configCallback;
|
|
649
|
+
if (call) {
|
|
650
|
+
const c = call(this.config);
|
|
651
|
+
if (c) {
|
|
652
|
+
this.initConfig(c);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return await this.handle(callback, nosort);
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* 初始化
|
|
659
|
+
* @param config
|
|
660
|
+
* @returns
|
|
661
|
+
*/
|
|
662
|
+
initConfig(config) {
|
|
663
|
+
if (config) {
|
|
664
|
+
this.config = config;
|
|
665
|
+
this.setDefaultConfig();
|
|
666
|
+
this.config.suffixReg = getSuffixReg(this.config.extensions);
|
|
667
|
+
if (!this.config.matchexts || this.config.matchexts.length == 0) {
|
|
668
|
+
this.config.matchexts = [this.config.suffixReg];
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return this.config;
|
|
672
|
+
}
|
|
673
|
+
setDefaultConfig() {
|
|
674
|
+
Object.keys(this._defaultConfig).forEach((key) => {
|
|
675
|
+
if (typeof this.config[key] == "undefined") {
|
|
676
|
+
this.config[key] = this._defaultConfig[key];
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
getFileName(name) {
|
|
681
|
+
if (this.config.suffixReg) {
|
|
682
|
+
return name.replace(this.config.suffixReg, "");
|
|
683
|
+
} else {
|
|
684
|
+
return name.replace(defaultSuffixReg, "");
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* 获取当前位置
|
|
689
|
+
* @param dir
|
|
690
|
+
* @returns
|
|
691
|
+
*/
|
|
692
|
+
getDirUrl(dir) {
|
|
693
|
+
const str = dir || this.config.dir;
|
|
694
|
+
if (str) {
|
|
695
|
+
return _path.resolve.call(void 0, process.cwd(), str);
|
|
696
|
+
} else {
|
|
697
|
+
return "";
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
isForceUpdate(url) {
|
|
701
|
+
if (this.config.forceUpdate && this.config.forceUpdate.length > 0) {
|
|
702
|
+
return matchsEnd(url.replace(/\\/g, "/"), this.config.forceUpdate);
|
|
703
|
+
} else {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
isMatchFile(url, name) {
|
|
708
|
+
const dirUrl = this.getDirUrl();
|
|
709
|
+
const dir = _path.join.call(void 0, url, name).replace(dirUrl, "").replace(/\\/g, "/");
|
|
710
|
+
const is = matchsEnd(dir, this.config.matchexts);
|
|
711
|
+
const nomatchexts = this.config.nomatchexts;
|
|
712
|
+
if (is && nomatchexts && nomatchexts.length > 0) {
|
|
713
|
+
if (matchsEnd(dir, nomatchexts)) {
|
|
714
|
+
return false;
|
|
715
|
+
} else {
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
return is;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
isMatchDir(url, name) {
|
|
723
|
+
const dirUrl = this.getDirUrl();
|
|
724
|
+
const dir = _path.join.call(void 0, url, name).replace(dirUrl, "").replace(/\\/g, "/");
|
|
725
|
+
const is = matchsStart(dir, this.config.matchs);
|
|
726
|
+
const nomatchs = this.config.nomatchs;
|
|
727
|
+
if (is && nomatchs && nomatchs.length > 0) {
|
|
728
|
+
if (matchsStart(dir, nomatchs)) {
|
|
729
|
+
return false;
|
|
730
|
+
} else {
|
|
731
|
+
return true;
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
return is;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* 处理方法
|
|
739
|
+
* @param callback
|
|
740
|
+
*/
|
|
741
|
+
handle(callback, nosort) {
|
|
742
|
+
return new Promise(async (resolve22) => {
|
|
743
|
+
const url = this.getDirUrl();
|
|
744
|
+
if (url) {
|
|
745
|
+
const rarr = await writeInit(
|
|
746
|
+
url,
|
|
747
|
+
async (...arr) => {
|
|
748
|
+
if (callback) {
|
|
749
|
+
await callback(...arr);
|
|
750
|
+
}
|
|
751
|
+
return await this.writeCallback(...arr, nosort);
|
|
752
|
+
},
|
|
753
|
+
(...arr) => {
|
|
754
|
+
return this.isMatchDir(...arr);
|
|
755
|
+
},
|
|
756
|
+
(...arr) => {
|
|
757
|
+
return this.isMatchFile(...arr);
|
|
758
|
+
},
|
|
759
|
+
this.config.issynch
|
|
760
|
+
);
|
|
761
|
+
resolve22(rarr);
|
|
762
|
+
} else {
|
|
763
|
+
resolve22([]);
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
getFileNotes(url) {
|
|
768
|
+
const suffix = getSuffix(url);
|
|
769
|
+
const sz = [
|
|
770
|
+
`@config cover=false`,
|
|
771
|
+
`cover \u662F\u5426\u8986\u76D6\u5F53\u524D\u6587\u4EF6\uFF0C\u9ED8\u8BA4\u662Ffalse\uFF0C true \u8868\u793A\u4E0D\u8986\u76D6`,
|
|
772
|
+
`\u5F53\u524D\u5DF2\u7ECF\u7531@fangzhongya/create\u81EA\u52A8\u751F\u6210`,
|
|
773
|
+
`${(/* @__PURE__ */ new Date()).toString()}`
|
|
774
|
+
];
|
|
775
|
+
const hy = ["md", "html", "vue"];
|
|
776
|
+
if (hy.includes(suffix)) {
|
|
777
|
+
const arr = ["<!--"];
|
|
778
|
+
sz.forEach((v) => {
|
|
779
|
+
arr.push(" - " + v);
|
|
780
|
+
});
|
|
781
|
+
arr.push("-->");
|
|
782
|
+
return arr;
|
|
783
|
+
} else {
|
|
784
|
+
const arr = ["/**"];
|
|
785
|
+
sz.forEach((v) => {
|
|
786
|
+
arr.push(" * " + v);
|
|
787
|
+
});
|
|
788
|
+
arr.push(" */");
|
|
789
|
+
return arr;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* 输出文件,判断目录是否存在
|
|
794
|
+
* @param url
|
|
795
|
+
* @param sts
|
|
796
|
+
*/
|
|
797
|
+
fileOpen(url, sts, fileUrls, type2) {
|
|
798
|
+
fsMkdir(getUrlCatalogue(url), (reaPath, is, ml) => {
|
|
799
|
+
const logs = this.getLogs();
|
|
800
|
+
logs.push(styleLog2("dir", {}));
|
|
801
|
+
if (is) {
|
|
802
|
+
if (ml) {
|
|
803
|
+
logs.push(
|
|
804
|
+
styleLog2("add", {
|
|
805
|
+
text: 2,
|
|
806
|
+
italic: true
|
|
807
|
+
})
|
|
808
|
+
);
|
|
809
|
+
logs.push(
|
|
810
|
+
styleLog2(reaPath, {
|
|
811
|
+
text: 2,
|
|
812
|
+
revert: true
|
|
813
|
+
})
|
|
814
|
+
);
|
|
815
|
+
console.log(logs.join(" "));
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
logs.push(
|
|
819
|
+
styleLog2(reaPath, {
|
|
820
|
+
text: 1,
|
|
821
|
+
revert: true
|
|
822
|
+
})
|
|
823
|
+
);
|
|
824
|
+
console.log(logs.join(" "));
|
|
825
|
+
}
|
|
826
|
+
this.setOpen(url, sts, type2, (kurl, _type, is2, _tn) => {
|
|
827
|
+
if (is2 && fileUrls) {
|
|
828
|
+
fileUrls.push(kurl);
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* 输出文件
|
|
835
|
+
* @param url
|
|
836
|
+
* @param str
|
|
837
|
+
* @param callback
|
|
838
|
+
*/
|
|
839
|
+
setOpen(url, str, type2, callback) {
|
|
840
|
+
let tn = this.config.fileTongre ? 3 : 2;
|
|
841
|
+
if (this.config.fileCover) {
|
|
842
|
+
tn = 0;
|
|
843
|
+
}
|
|
844
|
+
if (tn == 2) {
|
|
845
|
+
if (this.isForceUpdate(url)) {
|
|
846
|
+
tn = 0;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
if (typeof type2 != "undefined") {
|
|
850
|
+
tn = type2;
|
|
851
|
+
}
|
|
852
|
+
if (this.config.writeNotes && !/\.json$/.test(url)) {
|
|
853
|
+
str = this.getFileNotes(url).join("\n") + "\n" + str;
|
|
854
|
+
}
|
|
855
|
+
fsOpenStream(
|
|
856
|
+
url,
|
|
857
|
+
str,
|
|
858
|
+
tn,
|
|
859
|
+
this.config.coverConfig,
|
|
860
|
+
(kurl, type22, is) => {
|
|
861
|
+
if (!(tn == 2 && type22 == 2)) {
|
|
862
|
+
const logs = this.getLogs();
|
|
863
|
+
logs.push(styleLog2("file", {}));
|
|
864
|
+
if (type22 == 1) {
|
|
865
|
+
logs.push(
|
|
866
|
+
styleLog2("add", {
|
|
867
|
+
text: 2,
|
|
868
|
+
italic: true
|
|
869
|
+
})
|
|
870
|
+
);
|
|
871
|
+
} else if (type22 == 2) {
|
|
872
|
+
logs.push(
|
|
873
|
+
styleLog2("update", {
|
|
874
|
+
italic: true,
|
|
875
|
+
text: 4
|
|
876
|
+
})
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
if (is) {
|
|
880
|
+
logs.push(
|
|
881
|
+
styleLog2(kurl, {
|
|
882
|
+
text: 2,
|
|
883
|
+
revert: true
|
|
884
|
+
})
|
|
885
|
+
);
|
|
886
|
+
} else {
|
|
887
|
+
logs.push(
|
|
888
|
+
styleLog2(kurl, {
|
|
889
|
+
text: 1,
|
|
890
|
+
revert: true
|
|
891
|
+
})
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
console.log(logs.join(" "));
|
|
895
|
+
}
|
|
896
|
+
if (callback) {
|
|
897
|
+
callback(kurl, type22, is, tn);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* 获取日志头
|
|
904
|
+
*/
|
|
905
|
+
getLogs() {
|
|
906
|
+
const logs = [];
|
|
907
|
+
logs.push(
|
|
908
|
+
styleLog2("[@fangzhongya/create]", {
|
|
909
|
+
text: 3
|
|
910
|
+
})
|
|
911
|
+
);
|
|
912
|
+
logs.push(
|
|
913
|
+
styleLog2(this._defaultConfig.name, {
|
|
914
|
+
text: 4
|
|
915
|
+
})
|
|
916
|
+
);
|
|
917
|
+
return logs;
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// node_modules/.pnpm/@fangzhongya+create@0.2.50/node_modules/@fangzhongya/create/dist/chunk-VZKQWRZ3.js
|
|
922
|
+
|
|
923
|
+
var defaultConfig2 = Object.assign({}, defaultConfig, {
|
|
924
|
+
name: "file",
|
|
925
|
+
/**
|
|
926
|
+
* 生成的文件名称
|
|
927
|
+
*/
|
|
928
|
+
gene: void 0,
|
|
929
|
+
/**
|
|
930
|
+
* 文件生成方法
|
|
931
|
+
*/
|
|
932
|
+
fileSet: void 0
|
|
933
|
+
});
|
|
934
|
+
var FangFile = class extends FangCom {
|
|
935
|
+
constructor(config, callback) {
|
|
936
|
+
super();
|
|
937
|
+
this.config = {};
|
|
938
|
+
this._configCallback = callback;
|
|
939
|
+
this._defaultConfig = defaultConfig2;
|
|
940
|
+
this.initConfig(config || this.config);
|
|
941
|
+
}
|
|
942
|
+
getDefaultGene(name, url, _wj) {
|
|
943
|
+
return _path.join.call(void 0, url, name);
|
|
944
|
+
}
|
|
945
|
+
getDefaultFileSet(_name, _url, _text, _wjm, _imp, _surl) {
|
|
946
|
+
return [];
|
|
947
|
+
}
|
|
948
|
+
getGeneObj(url, name, outDir) {
|
|
949
|
+
return getUrlCatalogueObj(
|
|
950
|
+
_path.join.call(void 0,
|
|
951
|
+
_path.resolve.call(void 0, process.cwd(), outDir),
|
|
952
|
+
_path.join.call(void 0, url, name).replace(this.getDirUrl(), "")
|
|
953
|
+
)
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* 获取输出地址方法
|
|
958
|
+
* @param gene
|
|
959
|
+
* @returns
|
|
960
|
+
*/
|
|
961
|
+
getGene(gene) {
|
|
962
|
+
gene = gene || this.config.gene;
|
|
963
|
+
if (!gene) {
|
|
964
|
+
return (...arr) => {
|
|
965
|
+
return this.getDefaultGene(...arr);
|
|
966
|
+
};
|
|
967
|
+
} else {
|
|
968
|
+
return gene;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
fileRead(url, type2) {
|
|
972
|
+
return new Promise((resolve22) => {
|
|
973
|
+
fsAccess(url).then(() => {
|
|
974
|
+
resolve22(fsReadFile(url, type2));
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
getFileSet(fileSet) {
|
|
979
|
+
fileSet = fileSet || this.config.fileSet;
|
|
980
|
+
if (!fileSet) {
|
|
981
|
+
return (...arr) => {
|
|
982
|
+
return this.getDefaultFileSet(...arr);
|
|
983
|
+
};
|
|
984
|
+
} else {
|
|
985
|
+
return fileSet;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* 回调方法
|
|
990
|
+
* @param url
|
|
991
|
+
* @param file
|
|
992
|
+
* @param urls
|
|
993
|
+
*/
|
|
994
|
+
async writeCallback(url, readdir2, fileUrls) {
|
|
995
|
+
const gene = this.getGene();
|
|
996
|
+
const fileSet = this.getFileSet();
|
|
997
|
+
const read = this.config.read;
|
|
998
|
+
if (readdir2.file) {
|
|
999
|
+
for (let i = 0; i < readdir2.file.length; i++) {
|
|
1000
|
+
const name = readdir2.file[i];
|
|
1001
|
+
const furl = _path.join.call(void 0, url, name);
|
|
1002
|
+
const wjmc = this.getFileName(name);
|
|
1003
|
+
const gu = gene(name, url, wjmc);
|
|
1004
|
+
const imp = getImportUrlSuffix(gu, furl);
|
|
1005
|
+
const arr = [];
|
|
1006
|
+
if (fileSet) {
|
|
1007
|
+
let text = "";
|
|
1008
|
+
if (read) {
|
|
1009
|
+
text = await fsReadFile(furl, read);
|
|
1010
|
+
}
|
|
1011
|
+
arr.push(...fileSet(name, url, text, wjmc, imp, gu));
|
|
1012
|
+
}
|
|
1013
|
+
if (arr.length > 0) {
|
|
1014
|
+
this.fileOpen(gu, arr.join("\n"), fileUrls);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return true;
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
async function runDev(config, configCallback, callback) {
|
|
1022
|
+
const fang = new FangFile(config);
|
|
1023
|
+
await fang.runDev(callback, configCallback);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// packages/imports.ts
|
|
1027
|
+
var type = "import";
|
|
1028
|
+
var FangImport = class {
|
|
1029
|
+
|
|
1030
|
+
#comUrls;
|
|
1031
|
+
#cacheObj;
|
|
1032
|
+
#exports;
|
|
1033
|
+
constructor(config) {
|
|
1034
|
+
this.config = config || {};
|
|
1035
|
+
this.#setConfigValue();
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* 初始化数据
|
|
1039
|
+
*/
|
|
1040
|
+
#setConfigValue() {
|
|
1041
|
+
this.#comUrls = [];
|
|
1042
|
+
this.#cacheObj = {};
|
|
1043
|
+
this.#exports = {};
|
|
1044
|
+
this.#getUrls();
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* 读取url地址列表
|
|
1048
|
+
*/
|
|
1049
|
+
#getUrls() {
|
|
1050
|
+
runDev({
|
|
1051
|
+
dir: this.config.dir,
|
|
1052
|
+
extensions: this.config.extensions,
|
|
1053
|
+
writeNotes: false,
|
|
1054
|
+
coverConfig: false,
|
|
1055
|
+
fileTongre: false,
|
|
1056
|
+
fileCover: false,
|
|
1057
|
+
issort: false,
|
|
1058
|
+
issynch: false,
|
|
1059
|
+
read: true,
|
|
1060
|
+
matchs: this.config.matchs,
|
|
1061
|
+
matchexts: this.config.matchexts,
|
|
1062
|
+
nomatchs: this.config.nomatchs,
|
|
1063
|
+
nomatchexts: this.config.nomatchexts,
|
|
1064
|
+
fileSet: (name, url, text, wjm, _imp, surl) => {
|
|
1065
|
+
const v = surl || _path.join.call(void 0, url, name);
|
|
1066
|
+
const es = getExports(text);
|
|
1067
|
+
const dm = wjm || name.replace(/\.([^.]+)$/, "");
|
|
1068
|
+
if (es.default) {
|
|
1069
|
+
es.default = dm;
|
|
1070
|
+
}
|
|
1071
|
+
_optionalChain([this, 'access', _9 => _9.#comUrls, 'optionalAccess', _10 => _10.push, 'call', _11 => _11(v)]);
|
|
1072
|
+
this.#exports[v] = es;
|
|
1073
|
+
return [];
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* 获取当前缓存数
|
|
1079
|
+
* @param {String} name 名称
|
|
1080
|
+
* @param {String} type 类型
|
|
1081
|
+
* @returns { Object } 注册的对象
|
|
1082
|
+
*/
|
|
1083
|
+
#getCache(name) {
|
|
1084
|
+
if (this.#cacheObj) {
|
|
1085
|
+
return this.#cacheObj[name];
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* 设置缓存数据
|
|
1090
|
+
* @param {String} name 名称
|
|
1091
|
+
* @param {String} type 类型
|
|
1092
|
+
* @param { Object } 注册的对象
|
|
1093
|
+
*/
|
|
1094
|
+
#setCache(name, obj) {
|
|
1095
|
+
this.#cacheObj = this.#cacheObj || {};
|
|
1096
|
+
this.#cacheObj[name] = obj;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* 是否要替换
|
|
1100
|
+
* @param { String } name 名称
|
|
1101
|
+
* @returns { Boolean } 是否要替换
|
|
1102
|
+
*/
|
|
1103
|
+
#namefilter(name) {
|
|
1104
|
+
if (this.config.startss) {
|
|
1105
|
+
for (let index = 0; index < this.config.startss.length; index++) {
|
|
1106
|
+
const element = this.config.startss[index];
|
|
1107
|
+
if (name.startsWith(element)) {
|
|
1108
|
+
return false;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (this.config.filtes) {
|
|
1113
|
+
for (let index = 0; index < this.config.filtes.length; index++) {
|
|
1114
|
+
const element = this.config.filtes[index];
|
|
1115
|
+
if (name === element) {
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return true;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* 返回对应的值
|
|
1124
|
+
* @param {String} from 文件地址
|
|
1125
|
+
* @param {String} name 名称
|
|
1126
|
+
* @returns { Object } 注册的对象
|
|
1127
|
+
*/
|
|
1128
|
+
#getNameFromUrl(name) {
|
|
1129
|
+
const o = this.#exports || {};
|
|
1130
|
+
const keys = Object.keys(o);
|
|
1131
|
+
for (const key of keys) {
|
|
1132
|
+
const es = o[key];
|
|
1133
|
+
if (es.named.includes(name)) {
|
|
1134
|
+
return {
|
|
1135
|
+
name,
|
|
1136
|
+
from: key
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
if (es.default === name) {
|
|
1140
|
+
return {
|
|
1141
|
+
name: "default",
|
|
1142
|
+
from: key
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* 通过名称匹配对应路径
|
|
1149
|
+
* @param {String} name 名称
|
|
1150
|
+
* @param {String} type 类型
|
|
1151
|
+
* @returns { Object } 注册的对象
|
|
1152
|
+
*/
|
|
1153
|
+
#setNameFrom(name) {
|
|
1154
|
+
if (this.config.alias) {
|
|
1155
|
+
name = name.replace(new RegExp("^" + this.config.alias), "");
|
|
1156
|
+
}
|
|
1157
|
+
return this.#getNameFromUrl(name);
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* 输出日志
|
|
1161
|
+
* @param name
|
|
1162
|
+
* @param type
|
|
1163
|
+
* @param obj
|
|
1164
|
+
* @param is
|
|
1165
|
+
*/
|
|
1166
|
+
#setLog(name, obj, is) {
|
|
1167
|
+
if (this.config.log) {
|
|
1168
|
+
const texts = 1;
|
|
1169
|
+
const arr = [];
|
|
1170
|
+
arr.push(
|
|
1171
|
+
_chunkNLSI7A24cjs.styleLog.call(void 0, "[@fangzhongya/vue-components]", {
|
|
1172
|
+
text: 3
|
|
1173
|
+
})
|
|
1174
|
+
);
|
|
1175
|
+
if (obj && obj.from) {
|
|
1176
|
+
let sfrom = _chunkNLSI7A24cjs.styleLog.call(void 0, _optionalChain([obj, 'optionalAccess', _12 => _12.from]), {
|
|
1177
|
+
text: 4,
|
|
1178
|
+
revert: true
|
|
1179
|
+
});
|
|
1180
|
+
arr.push(
|
|
1181
|
+
_chunkNLSI7A24cjs.styleLog.call(void 0, "import", {
|
|
1182
|
+
text: texts
|
|
1183
|
+
})
|
|
1184
|
+
);
|
|
1185
|
+
arr.push(
|
|
1186
|
+
_chunkNLSI7A24cjs.styleLog.call(void 0, name, {
|
|
1187
|
+
bold: true
|
|
1188
|
+
})
|
|
1189
|
+
);
|
|
1190
|
+
if (!is) {
|
|
1191
|
+
sfrom = _chunkNLSI7A24cjs.styleLog.call(void 0, "+", {
|
|
1192
|
+
text: 2
|
|
1193
|
+
}) + sfrom;
|
|
1194
|
+
}
|
|
1195
|
+
arr.push(sfrom);
|
|
1196
|
+
} else {
|
|
1197
|
+
arr.push(
|
|
1198
|
+
_chunkNLSI7A24cjs.styleLog.call(void 0, type, {
|
|
1199
|
+
text: texts
|
|
1200
|
+
})
|
|
1201
|
+
);
|
|
1202
|
+
arr.push(
|
|
1203
|
+
_chunkNLSI7A24cjs.styleLog.call(void 0, name, {
|
|
1204
|
+
bold: true,
|
|
1205
|
+
text: 1
|
|
1206
|
+
})
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
console.log(arr.join(" "));
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* 自动按需匹配注册
|
|
1214
|
+
* @param {String} name 名称
|
|
1215
|
+
* @param {String} type 类型
|
|
1216
|
+
* @returns { Object } 注册的对象
|
|
1217
|
+
*/
|
|
1218
|
+
resolve(name) {
|
|
1219
|
+
const cache = this.#getCache(name);
|
|
1220
|
+
if (this.config.isCache && cache) {
|
|
1221
|
+
this.#setLog(name, cache, true);
|
|
1222
|
+
return cache;
|
|
1223
|
+
} else if (this.#namefilter(name)) {
|
|
1224
|
+
let obj = this.#setNameFrom(name);
|
|
1225
|
+
this.#setLog(name, obj);
|
|
1226
|
+
if (obj) {
|
|
1227
|
+
this.#setCache(name, obj);
|
|
1228
|
+
return obj;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
var imports_default = FangImport;
|
|
1234
|
+
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
exports.imports_default = imports_default;
|