@fangzhongya/icons 0.0.20 → 0.0.22

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.
@@ -1,6 +1,3 @@
1
- import {
2
- runDev
3
- } from "../chunk-BKYM5ZD6.js";
4
1
  import {
5
2
  getIconifySVG,
6
3
  lineToLargeHump
@@ -8,11 +5,917 @@ import {
8
5
  import "../chunk-MOHILOKE.js";
9
6
  import {
10
7
  json_default
11
- } from "../chunk-7HXPUNMG.js";
8
+ } from "../chunk-E432JW5M.js";
12
9
  import "../chunk-MLKGABMK.js";
13
10
 
14
- // packages/vite/index.ts
11
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-4CBOJSDB.js
12
+ function getStartSames(str, val) {
13
+ let s = "";
14
+ const vs = [...val];
15
+ let index = 0;
16
+ for (; index < vs.length; index++) {
17
+ const element = vs[index];
18
+ if (element === str.charAt(index)) {
19
+ s += element;
20
+ } else {
21
+ break;
22
+ }
23
+ }
24
+ return [s, str.substring(index), val.substring(index)];
25
+ }
26
+ function getImportUrl(url, imp) {
27
+ const arr = getStartSames(url, imp);
28
+ const ts = arr[0];
29
+ if (!/[\\|\/]$/.test(ts)) {
30
+ const regs = ts.match(/[\\|\/]([^\\|\/]*)$/);
31
+ if (regs && regs.length > 0) {
32
+ const a = regs[1];
33
+ arr[0] = ts.substring(0, regs.index + 1);
34
+ arr[1] = a + arr[1];
35
+ arr[2] = a + arr[2];
36
+ }
37
+ }
38
+ const l = arr[1].split(/\\|\//).length - 1;
39
+ let ds = ["./"];
40
+ if (l > 0) {
41
+ ds = [];
42
+ for (let index = 0; index < l; index++) {
43
+ ds.push("../");
44
+ }
45
+ }
46
+ return ds.join("") + arr[2].replace(/\\/g, "/");
47
+ }
48
+
49
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-3GUX6LOY.js
50
+ function getImportUrlSuffix(url, imp) {
51
+ return getImportUrl(url, imp).replace(/\.([a-z|A-Z][a-z|A-Z|0-9]*)$/, "");
52
+ }
53
+
54
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-I5KYQX4M.js
55
+ import {
56
+ open,
57
+ readdir,
58
+ stat,
59
+ writeFile,
60
+ write,
61
+ mkdir,
62
+ readFile,
63
+ createReadStream,
64
+ access,
65
+ constants
66
+ } from "fs";
15
67
  import { join } from "path";
68
+ function getUrlCatalogueObj(str) {
69
+ const reg = /(\\|\/)([^\\|\/]+)\.([a-z|A-Z][a-z|A-Z|0-9]*)$/g;
70
+ const ml = str.replace(reg, "");
71
+ let name = "";
72
+ let suffix = "";
73
+ let apart = "";
74
+ const arr = reg.exec(str);
75
+ if (arr) {
76
+ apart = arr[1];
77
+ name = arr[2];
78
+ suffix = arr[3];
79
+ }
80
+ return {
81
+ catalogue: ml,
82
+ name,
83
+ suffix,
84
+ apart
85
+ };
86
+ }
87
+ function getNewFileName(url) {
88
+ const obj = getUrlCatalogueObj(url);
89
+ let wb = obj.name;
90
+ if (wb) {
91
+ const reg = /([0-9]+)$/g;
92
+ const regs = reg.exec(wb);
93
+ if (regs && regs.length > 0) {
94
+ const sl = Number(regs[1]) + 1;
95
+ const reg1 = new RegExp(regs[1] + "$");
96
+ wb = wb.replace(reg1, (sl + "").padStart(regs[1].length, "0"));
97
+ } else {
98
+ wb = wb + "1";
99
+ }
100
+ return obj.catalogue + obj.apart + wb + "." + obj.suffix;
101
+ } else {
102
+ return "";
103
+ }
104
+ }
105
+ function fsReadFile(url, type) {
106
+ if (!type || type === true) {
107
+ type = "utf-8";
108
+ }
109
+ return new Promise((resolve3, reject) => {
110
+ readFile(url, type, (err, dataStr) => {
111
+ if (err) {
112
+ console.log("2", err);
113
+ reject("");
114
+ } else {
115
+ resolve3(dataStr);
116
+ }
117
+ });
118
+ });
119
+ }
120
+ function fsCreateReadStream(url, type) {
121
+ if (!type || type === true) {
122
+ type = "utf-8";
123
+ }
124
+ return new Promise((resolve3) => {
125
+ const stream = createReadStream(url, {
126
+ start: 0,
127
+ end: 100,
128
+ encoding: type
129
+ });
130
+ let st = "";
131
+ stream.on("data", (data) => {
132
+ st += data;
133
+ });
134
+ stream.on("end", () => {
135
+ resolve3(st);
136
+ });
137
+ stream.on("error", () => {
138
+ resolve3("");
139
+ });
140
+ });
141
+ }
142
+ function fsAccess(reaPath) {
143
+ return new Promise((resolve3) => {
144
+ try {
145
+ access(reaPath, constants.F_OK, (err) => {
146
+ if (err) {
147
+ resolve3(false);
148
+ } else {
149
+ resolve3(true);
150
+ }
151
+ });
152
+ } catch (e) {
153
+ resolve3(false);
154
+ }
155
+ });
156
+ }
157
+ function fsReaddir(filePath) {
158
+ return new Promise((resolve3, reject) => {
159
+ readdir(filePath, (err, files) => {
160
+ if (err) {
161
+ reject(err);
162
+ } else {
163
+ const lg = files.length;
164
+ const dirs = [];
165
+ const file = [];
166
+ if (lg) {
167
+ let i = 0;
168
+ files.forEach((filename) => {
169
+ const filedir = join(filePath, filename);
170
+ stat(filedir, (err2, stats) => {
171
+ i++;
172
+ if (err2) {
173
+ console.log("4", err2);
174
+ } else {
175
+ const isFile = stats.isFile();
176
+ const isDir = stats.isDirectory();
177
+ if (isFile) {
178
+ file.push(filename);
179
+ }
180
+ if (isDir) {
181
+ dirs.push(filename);
182
+ }
183
+ }
184
+ if (i >= lg) {
185
+ resolve3({
186
+ file,
187
+ dirs
188
+ });
189
+ }
190
+ });
191
+ });
192
+ } else {
193
+ resolve3({
194
+ file,
195
+ dirs
196
+ });
197
+ }
198
+ }
199
+ });
200
+ });
201
+ }
202
+ function fsOpenStream(path, json, type = 0, cover, callback) {
203
+ open(path, "wx", async (err, fd) => {
204
+ if (err) {
205
+ if (err.code === "EEXIST") {
206
+ if (type == 1 || type == 0) {
207
+ const fwrite = () => {
208
+ writeFile(path, json, "utf-8", (err2) => {
209
+ if (err2) {
210
+ console.log("6", err2);
211
+ if (callback) {
212
+ callback(path, cover ? 3 : 2, false, type);
213
+ }
214
+ } else {
215
+ if (callback) {
216
+ callback(path, cover ? 3 : 2, true, type);
217
+ }
218
+ }
219
+ });
220
+ };
221
+ if (cover) {
222
+ const st = await fsCreateReadStream(path);
223
+ if (!st.includes("@config cover=true")) {
224
+ fwrite();
225
+ } else {
226
+ if (callback) callback(path, 3, false, type);
227
+ }
228
+ } else {
229
+ fwrite();
230
+ }
231
+ } else if (type == 3) {
232
+ path = getNewFileName(path);
233
+ if (path) {
234
+ fsOpenStream(path, json, type, cover, callback);
235
+ } else {
236
+ if (callback) {
237
+ callback(path, 3, false, type);
238
+ }
239
+ }
240
+ } else {
241
+ if (callback) {
242
+ callback(path, 2, false, type);
243
+ }
244
+ }
245
+ } else {
246
+ if (callback) {
247
+ callback(path, 0, false, type);
248
+ }
249
+ }
250
+ } else {
251
+ if (type != 1) {
252
+ write(fd, json, (err2) => {
253
+ if (err2) {
254
+ console.log("8", err2);
255
+ if (callback) {
256
+ callback(path, 1, false, type);
257
+ }
258
+ } else {
259
+ if (callback) {
260
+ callback(path, 1, true, type);
261
+ }
262
+ }
263
+ });
264
+ } else {
265
+ if (callback) {
266
+ callback(path, 1, false, type);
267
+ }
268
+ }
269
+ }
270
+ });
271
+ }
272
+ function fsMkdir(reaPath, callback) {
273
+ mkdir(reaPath, { recursive: true }, (err, path) => {
274
+ if (err) {
275
+ console.log("0", err);
276
+ if (callback) {
277
+ callback(reaPath, false);
278
+ }
279
+ } else {
280
+ if (callback) {
281
+ callback(reaPath, true, path);
282
+ }
283
+ }
284
+ });
285
+ }
286
+ function writeInit(url, callback, isDirs, isFile, issynch) {
287
+ return new Promise(async (resolve3) => {
288
+ if (url) {
289
+ const data = await fsReaddir(url);
290
+ const arr = await writeFileUrl(
291
+ url,
292
+ data,
293
+ callback,
294
+ isDirs,
295
+ isFile,
296
+ issynch
297
+ );
298
+ resolve3(arr);
299
+ } else {
300
+ resolve3([]);
301
+ }
302
+ });
303
+ }
304
+ function writeFileUrl(url, files, callback, isDirs, isFile, issynch) {
305
+ return new Promise(async (resolve3) => {
306
+ const arr = [];
307
+ const dirs = [];
308
+ if (files.dirs.length > 0) {
309
+ for (let i = 0; i < files.dirs.length; i++) {
310
+ const dir = files.dirs[i];
311
+ let is = true;
312
+ if (isDirs) {
313
+ is = isDirs(url, dir);
314
+ }
315
+ if (is) {
316
+ dirs.push(dir);
317
+ const urls = await writeInit(
318
+ join(url, dir),
319
+ callback,
320
+ isDirs,
321
+ isFile,
322
+ issynch
323
+ );
324
+ arr.push(...urls);
325
+ }
326
+ }
327
+ }
328
+ files.dirs = dirs;
329
+ const file = [];
330
+ if (files.file.length > 0) {
331
+ files.file.forEach((name) => {
332
+ let is = true;
333
+ if (isFile) {
334
+ is = isFile(url, name);
335
+ }
336
+ if (is) {
337
+ file.push(name);
338
+ arr.push(join(url, name));
339
+ }
340
+ });
341
+ }
342
+ files.file = file;
343
+ if (callback) {
344
+ if (issynch) {
345
+ await callback(url, files, arr);
346
+ } else {
347
+ callback(url, files, arr);
348
+ }
349
+ }
350
+ resolve3(arr);
351
+ });
352
+ }
353
+
354
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-FWEGYLR7.js
355
+ import { resolve, join as join2 } from "path";
356
+ function styleLog(msg = "", obj) {
357
+ const arr = ["\x1B[0m"];
358
+ if (obj == null ? void 0 : obj.revert) {
359
+ arr.push("\x1B[4m");
360
+ }
361
+ if (obj == null ? void 0 : obj.lineThrough) {
362
+ arr.push("\x1B[9m");
363
+ }
364
+ if (obj == null ? void 0 : obj.italic) {
365
+ arr.push("\x1B[3m");
366
+ }
367
+ if (obj == null ? void 0 : obj.bold) {
368
+ arr.push("\x1B[1m");
369
+ }
370
+ if (obj == null ? void 0 : obj.bag) {
371
+ arr.push(`\x1B[4${obj == null ? void 0 : obj.bag}m`);
372
+ } else {
373
+ arr.push("\x1B[40m");
374
+ }
375
+ if (obj == null ? void 0 : obj.text) {
376
+ arr.push(`\x1B[3${obj == null ? void 0 : obj.text}m`);
377
+ } else {
378
+ arr.push("\x1B[30m");
379
+ }
380
+ arr.push(msg);
381
+ arr.push("\x1B[0m");
382
+ return arr.join("");
383
+ }
384
+ function getSuffix(url) {
385
+ const reg = /\.([a-z|A-Z][a-z|A-Z|0-9]*)$/;
386
+ const regs = reg.exec(url);
387
+ if (regs && regs.length > 0) {
388
+ return regs[1];
389
+ }
390
+ return "";
391
+ }
392
+ function matchsEnd(key, matchs) {
393
+ if (matchs && matchs.length > 0) {
394
+ for (const value of matchs) {
395
+ if (typeof value == "string") {
396
+ if (key.endsWith(value)) {
397
+ return true;
398
+ }
399
+ } else {
400
+ if (value.test(key)) {
401
+ return true;
402
+ }
403
+ }
404
+ }
405
+ return false;
406
+ } else {
407
+ return true;
408
+ }
409
+ }
410
+ function matchsStart(key, matchs) {
411
+ if (matchs && matchs.length > 0) {
412
+ for (const value of matchs) {
413
+ if (typeof value == "string") {
414
+ if (key.startsWith(value)) {
415
+ return true;
416
+ }
417
+ } else {
418
+ if (value.test(key)) {
419
+ return true;
420
+ }
421
+ }
422
+ }
423
+ return false;
424
+ } else {
425
+ return true;
426
+ }
427
+ }
428
+ function getUrlCatalogue(str) {
429
+ const reg = /((\\|\/)([^\\|\/]+)(\.[a-z|A-Z][a-z|A-Z|0-9]*))?$/g;
430
+ return str.replace(reg, "");
431
+ }
432
+ var defaultSuffixReg = /\\.[a-z|A-Z]+$/;
433
+ var defaultConfig = {
434
+ name: "com",
435
+ /**
436
+ * 打包的文件地址
437
+ */
438
+ dir: "./packages/",
439
+ /**
440
+ * 文件后缀
441
+ */
442
+ extensions: ["js", "ts"],
443
+ suffixReg: defaultSuffixReg,
444
+ fileTongre: false,
445
+ /**
446
+ * 是否替换文件
447
+ */
448
+ fileCover: false,
449
+ /**
450
+ * 判断当前文件100个字节内存在 @config cover=true 就不写入
451
+ */
452
+ coverConfig: false,
453
+ /**
454
+ * 写入注释
455
+ */
456
+ writeNotes: false,
457
+ /**
458
+ * 读取当前文件,文件的编码类型,默认utf-8
459
+ */
460
+ read: false,
461
+ /**
462
+ * 匹配目录数组
463
+ * 从头开始匹配
464
+ */
465
+ matchs: [],
466
+ /**
467
+ * 匹配文件路径
468
+ * 从尾部开始匹配
469
+ */
470
+ matchexts: [],
471
+ forceUpdate: [],
472
+ /**
473
+ * 不匹配目录数组
474
+ * 从头开始匹配
475
+ */
476
+ nomatchs: [],
477
+ /**
478
+ * 不匹配文件路径
479
+ * 从尾部开始匹配
480
+ */
481
+ nomatchexts: [],
482
+ issort: false,
483
+ issynch: false
484
+ };
485
+ function getSuffixReg(ex = []) {
486
+ if (ex.length == 0) {
487
+ return defaultSuffixReg;
488
+ }
489
+ return new RegExp(`\\.(${ex.join("|")})$`);
490
+ }
491
+ var FangCom = class {
492
+ _configCallback;
493
+ _defaultConfig;
494
+ config;
495
+ constructor(config, callback) {
496
+ this.config = {};
497
+ this._configCallback = callback;
498
+ this._defaultConfig = defaultConfig;
499
+ this.initConfig(config);
500
+ }
501
+ async runDev(callback, configCallback, config, nosort) {
502
+ this.initConfig(config);
503
+ const call = configCallback || this._configCallback;
504
+ if (call) {
505
+ const c = call(this.config);
506
+ if (c) {
507
+ this.initConfig(c);
508
+ }
509
+ }
510
+ return await this.handle(callback, nosort);
511
+ }
512
+ /**
513
+ * 初始化
514
+ * @param config
515
+ * @returns
516
+ */
517
+ initConfig(config) {
518
+ if (config) {
519
+ this.config = config;
520
+ this.setDefaultConfig();
521
+ this.config.suffixReg = getSuffixReg(this.config.extensions);
522
+ if (!this.config.matchexts || this.config.matchexts.length == 0) {
523
+ this.config.matchexts = [this.config.suffixReg];
524
+ }
525
+ }
526
+ return this.config;
527
+ }
528
+ setDefaultConfig() {
529
+ Object.keys(this._defaultConfig).forEach((key) => {
530
+ if (typeof this.config[key] == "undefined") {
531
+ this.config[key] = this._defaultConfig[key];
532
+ }
533
+ });
534
+ }
535
+ getFileName(name) {
536
+ if (this.config.suffixReg) {
537
+ return name.replace(this.config.suffixReg, "");
538
+ } else {
539
+ return name.replace(defaultSuffixReg, "");
540
+ }
541
+ }
542
+ /**
543
+ * 获取当前位置
544
+ * @param dir
545
+ * @returns
546
+ */
547
+ getDirUrl(dir) {
548
+ const str = dir || this.config.dir;
549
+ if (str) {
550
+ return resolve(process.cwd(), str);
551
+ } else {
552
+ return "";
553
+ }
554
+ }
555
+ isForceUpdate(url) {
556
+ if (this.config.forceUpdate && this.config.forceUpdate.length > 0) {
557
+ return matchsEnd(url.replace(/\\/g, "/"), this.config.forceUpdate);
558
+ } else {
559
+ return false;
560
+ }
561
+ }
562
+ isMatchFile(url, name) {
563
+ const dirUrl = this.getDirUrl();
564
+ const dir = join2(url, name).replace(dirUrl, "").replace(/\\/g, "/");
565
+ const is = matchsEnd(dir, this.config.matchexts);
566
+ const nomatchexts = this.config.nomatchexts;
567
+ if (is && nomatchexts && nomatchexts.length > 0) {
568
+ if (matchsEnd(dir, nomatchexts)) {
569
+ return false;
570
+ } else {
571
+ return true;
572
+ }
573
+ } else {
574
+ return is;
575
+ }
576
+ }
577
+ isMatchDir(url, name) {
578
+ const dirUrl = this.getDirUrl();
579
+ const dir = join2(url, name).replace(dirUrl, "").replace(/\\/g, "/");
580
+ const is = matchsStart(dir, this.config.matchs);
581
+ const nomatchs = this.config.nomatchs;
582
+ if (is && nomatchs && nomatchs.length > 0) {
583
+ if (matchsStart(dir, nomatchs)) {
584
+ return false;
585
+ } else {
586
+ return true;
587
+ }
588
+ } else {
589
+ return is;
590
+ }
591
+ }
592
+ /**
593
+ * 处理方法
594
+ * @param callback
595
+ */
596
+ handle(callback, nosort) {
597
+ return new Promise(async (resolve22) => {
598
+ const url = this.getDirUrl();
599
+ if (url) {
600
+ const rarr = await writeInit(
601
+ url,
602
+ async (...arr) => {
603
+ if (callback) {
604
+ await callback(...arr);
605
+ }
606
+ return await this.writeCallback(...arr, nosort);
607
+ },
608
+ (...arr) => {
609
+ return this.isMatchDir(...arr);
610
+ },
611
+ (...arr) => {
612
+ return this.isMatchFile(...arr);
613
+ },
614
+ this.config.issynch
615
+ );
616
+ resolve22(rarr);
617
+ } else {
618
+ resolve22([]);
619
+ }
620
+ });
621
+ }
622
+ getFileNotes(url) {
623
+ const suffix = getSuffix(url);
624
+ const sz = [
625
+ `@config cover=false`,
626
+ `cover \u662F\u5426\u8986\u76D6\u5F53\u524D\u6587\u4EF6\uFF0C\u9ED8\u8BA4\u662Ffalse\uFF0C true \u8868\u793A\u4E0D\u8986\u76D6`,
627
+ `\u5F53\u524D\u5DF2\u7ECF\u7531@fangzhongya/create\u81EA\u52A8\u751F\u6210`,
628
+ `${(/* @__PURE__ */ new Date()).toString()}`
629
+ ];
630
+ const hy = ["md", "html", "vue"];
631
+ if (hy.includes(suffix)) {
632
+ const arr = ["<!--"];
633
+ sz.forEach((v) => {
634
+ arr.push(" - " + v);
635
+ });
636
+ arr.push("-->");
637
+ return arr;
638
+ } else {
639
+ const arr = ["/**"];
640
+ sz.forEach((v) => {
641
+ arr.push(" * " + v);
642
+ });
643
+ arr.push(" */");
644
+ return arr;
645
+ }
646
+ }
647
+ /**
648
+ * 输出文件,判断目录是否存在
649
+ * @param url
650
+ * @param sts
651
+ */
652
+ fileOpen(url, sts, fileUrls, type) {
653
+ fsMkdir(getUrlCatalogue(url), (reaPath, is, ml) => {
654
+ const logs = this.getLogs();
655
+ logs.push(styleLog("dir", {}));
656
+ if (is) {
657
+ if (ml) {
658
+ logs.push(
659
+ styleLog("add", {
660
+ text: 2,
661
+ italic: true
662
+ })
663
+ );
664
+ logs.push(
665
+ styleLog(reaPath, {
666
+ text: 2,
667
+ revert: true
668
+ })
669
+ );
670
+ console.log(logs.join(" "));
671
+ }
672
+ } else {
673
+ logs.push(
674
+ styleLog(reaPath, {
675
+ text: 1,
676
+ revert: true
677
+ })
678
+ );
679
+ console.log(logs.join(" "));
680
+ }
681
+ this.setOpen(url, sts, type, (kurl, _type, is2, _tn) => {
682
+ if (is2 && fileUrls) {
683
+ fileUrls.push(kurl);
684
+ }
685
+ });
686
+ });
687
+ }
688
+ /**
689
+ * 输出文件
690
+ * @param url
691
+ * @param str
692
+ * @param callback
693
+ */
694
+ setOpen(url, str, type, callback) {
695
+ let tn = this.config.fileTongre ? 3 : 2;
696
+ if (this.config.fileCover) {
697
+ tn = 0;
698
+ }
699
+ if (tn == 2) {
700
+ if (this.isForceUpdate(url)) {
701
+ tn = 0;
702
+ }
703
+ }
704
+ if (typeof type != "undefined") {
705
+ tn = type;
706
+ }
707
+ if (this.config.writeNotes && !/\.json$/.test(url)) {
708
+ str = this.getFileNotes(url).join("\n") + "\n" + str;
709
+ }
710
+ fsOpenStream(
711
+ url,
712
+ str,
713
+ tn,
714
+ this.config.coverConfig,
715
+ (kurl, type2, is) => {
716
+ if (!(tn == 2 && type2 == 2)) {
717
+ const logs = this.getLogs();
718
+ logs.push(styleLog("file", {}));
719
+ if (type2 == 1) {
720
+ logs.push(
721
+ styleLog("add", {
722
+ text: 2,
723
+ italic: true
724
+ })
725
+ );
726
+ } else if (type2 == 2) {
727
+ logs.push(
728
+ styleLog("update", {
729
+ italic: true,
730
+ text: 4
731
+ })
732
+ );
733
+ }
734
+ if (is) {
735
+ logs.push(
736
+ styleLog(kurl, {
737
+ text: 2,
738
+ revert: true
739
+ })
740
+ );
741
+ } else {
742
+ logs.push(
743
+ styleLog(kurl, {
744
+ text: 1,
745
+ revert: true
746
+ })
747
+ );
748
+ }
749
+ console.log(logs.join(" "));
750
+ }
751
+ if (callback) {
752
+ callback(kurl, type2, is, tn);
753
+ }
754
+ }
755
+ );
756
+ }
757
+ /**
758
+ * 获取日志头
759
+ */
760
+ getLogs() {
761
+ const logs = [];
762
+ logs.push(
763
+ styleLog("[@fangzhongya/create]", {
764
+ text: 3
765
+ })
766
+ );
767
+ logs.push(
768
+ styleLog(this._defaultConfig.name, {
769
+ text: 4
770
+ })
771
+ );
772
+ return logs;
773
+ }
774
+ };
775
+
776
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-IMEZSVK5.js
777
+ import { resolve as resolve2, join as join3 } from "path";
778
+ var defaultConfig2 = Object.assign({}, defaultConfig, {
779
+ name: "file",
780
+ /**
781
+ * 生成的文件名称
782
+ */
783
+ gene: void 0,
784
+ /**
785
+ * 文件生成方法
786
+ */
787
+ fileSet: void 0
788
+ });
789
+ var FangFile = class extends FangCom {
790
+ constructor(config, callback) {
791
+ super();
792
+ this.config = {};
793
+ this._configCallback = callback;
794
+ this._defaultConfig = defaultConfig2;
795
+ this.initConfig(config || this.config);
796
+ }
797
+ getDefaultGene(name, url, _wj) {
798
+ return join3(url, name);
799
+ }
800
+ getDefaultFileSet(_name, _url, _text, _wjm, _imp, _surl) {
801
+ return [];
802
+ }
803
+ getGeneObj(url, name, outDir) {
804
+ return getUrlCatalogueObj(
805
+ join3(
806
+ resolve2(process.cwd(), outDir),
807
+ join3(url, name).replace(this.getDirUrl(), "")
808
+ )
809
+ );
810
+ }
811
+ /**
812
+ * 获取输出地址方法
813
+ * @param gene
814
+ * @returns
815
+ */
816
+ getGene(gene) {
817
+ gene = gene || this.config.gene;
818
+ if (!gene) {
819
+ return (...arr) => {
820
+ return this.getDefaultGene(...arr);
821
+ };
822
+ } else {
823
+ return gene;
824
+ }
825
+ }
826
+ fileRead(url, type) {
827
+ return new Promise((resolve22) => {
828
+ fsAccess(url).then(() => {
829
+ resolve22(fsReadFile(url, type));
830
+ });
831
+ });
832
+ }
833
+ getFileSet(fileSet) {
834
+ fileSet = fileSet || this.config.fileSet;
835
+ if (!fileSet) {
836
+ return (...arr) => {
837
+ return this.getDefaultFileSet(...arr);
838
+ };
839
+ } else {
840
+ return fileSet;
841
+ }
842
+ }
843
+ /**
844
+ * 回调方法
845
+ * @param url
846
+ * @param file
847
+ * @param urls
848
+ */
849
+ async writeCallback(url, readdir2, fileUrls) {
850
+ const gene = this.getGene();
851
+ const fileSet = this.getFileSet();
852
+ const read = this.config.read;
853
+ if (readdir2.file) {
854
+ for (let i = 0; i < readdir2.file.length; i++) {
855
+ const name = readdir2.file[i];
856
+ const furl = join3(url, name);
857
+ const wjmc = this.getFileName(name);
858
+ const gu = gene(name, url, wjmc);
859
+ const imp = getImportUrlSuffix(gu, furl);
860
+ const arr = [];
861
+ if (fileSet) {
862
+ let text = "";
863
+ if (read) {
864
+ text = await fsReadFile(furl, read);
865
+ }
866
+ arr.push(...fileSet(name, url, text, wjmc, imp, gu));
867
+ }
868
+ if (arr.length > 0) {
869
+ this.fileOpen(gu, arr.join("\n"), fileUrls);
870
+ }
871
+ }
872
+ }
873
+ return true;
874
+ }
875
+ };
876
+
877
+ // node_modules/.pnpm/@fangzhongya+create@0.2.49/node_modules/@fangzhongya/create/dist/chunk-3VPCYJWK.js
878
+ import { join as join4 } from "path";
879
+ var defaultConfig22 = Object.assign({}, defaultConfig2, {
880
+ name: "out",
881
+ outDir: "./",
882
+ isNeader: true
883
+ });
884
+ var FangOut = class extends FangFile {
885
+ constructor(config, callback) {
886
+ super();
887
+ this.config = {};
888
+ this._configCallback = callback;
889
+ this._defaultConfig = defaultConfig22;
890
+ this.initConfig(config || this.config);
891
+ }
892
+ getFileNeader(name, url) {
893
+ return [`/**`, ` * ${join4(url, name).replace(/\\/g, "/")}`, " */"];
894
+ }
895
+ /**
896
+ * 获取输出地址方法
897
+ * @param gene
898
+ * @returns
899
+ */
900
+ getDefaultGene(name, url, _wj) {
901
+ const obj = this.getGeneObj(url, name, this.config.outDir);
902
+ return join4(obj.catalogue, obj.name + "." + obj.suffix);
903
+ }
904
+ getDefaultFileSet(name, url, text, _wjm, _imp) {
905
+ const arr = [text];
906
+ if (this.config.isNeader) {
907
+ return [...this.getFileNeader(name, url), ...arr];
908
+ }
909
+ return arr;
910
+ }
911
+ };
912
+ function runDev(config, configCallback, callback) {
913
+ const fang = new FangOut(config);
914
+ fang.runDev(callback, configCallback);
915
+ }
916
+
917
+ // packages/vite/index.ts
918
+ import { join as join5 } from "path";
16
919
  var runType = "svg";
17
920
  var virtualModuleId = "virtual:fang-icon";
18
921
  function simpleFangIcon(options = {}) {
@@ -26,7 +929,7 @@ function simpleFangIcon(options = {}) {
26
929
  customReplacement
27
930
  } = options;
28
931
  if (options.mobile) {
29
- const outDir = join("./public/", directory);
932
+ const outDir = join5("./public/", directory);
30
933
  runDev({
31
934
  issort: true,
32
935
  dir: "./node_modules/@fangzhongya/icons/dist/svg",
@@ -40,8 +943,8 @@ function simpleFangIcon(options = {}) {
40
943
  const plugin = {
41
944
  name: "simple-fang-icon"
42
945
  };
946
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
43
947
  if (virtual) {
44
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
45
948
  const pub = `
46
949
  import { defineComponent, h,} from 'vue'
47
950
  import FangIcon from '@fangzhongya/icons/icon/index'
@@ -141,6 +1044,20 @@ function simpleFangIcon(options = {}) {
141
1044
  }
142
1045
  return null;
143
1046
  };
1047
+ } else {
1048
+ plugin.resolveId = function(id) {
1049
+ if (id === virtualModuleId) {
1050
+ return resolvedVirtualModuleId;
1051
+ }
1052
+ return void 0;
1053
+ };
1054
+ plugin.load = function(id) {
1055
+ if (id === resolvedVirtualModuleId) {
1056
+ return `export const install = () => {};
1057
+ export default {};`;
1058
+ }
1059
+ return null;
1060
+ };
144
1061
  }
145
1062
  if (replaced) {
146
1063
  const targetComponents = Array.isArray(name) ? name : [name];
@@ -164,7 +1081,7 @@ function simpleFangIcon(options = {}) {
164
1081
  }
165
1082
  for (let i = components.length - 1; i >= 0; i--) {
166
1083
  const component = components[i];
167
- if (component) {
1084
+ if (isReplaced(component)) {
168
1085
  const { text, imptext } = replaceComponent(
169
1086
  component,
170
1087
  type,
@@ -238,6 +1155,26 @@ function hasStringNameAttribute(attrString) {
238
1155
  function isOnlyWhitespace(content) {
239
1156
  return !content || /^\s*$/.test(content);
240
1157
  }
1158
+ function isReplaced(m) {
1159
+ if (!m) {
1160
+ return false;
1161
+ }
1162
+ const { fullMatch, attributes } = m;
1163
+ if (!hasStringNameAttribute(fullMatch)) {
1164
+ return false;
1165
+ }
1166
+ if (!attributes.name) {
1167
+ return false;
1168
+ }
1169
+ const content = fullMatch.slice(
1170
+ fullMatch.indexOf(">") + 1,
1171
+ fullMatch.indexOf("</")
1172
+ );
1173
+ if (!isOnlyWhitespace(content)) {
1174
+ return false;
1175
+ }
1176
+ return true;
1177
+ }
241
1178
  function findComponents(code, name) {
242
1179
  const components = [];
243
1180
  for (const componentName of name) {
@@ -252,15 +1189,7 @@ function findComponents(code, name) {
252
1189
  if (tagEndIndex === -1) break;
253
1190
  const startTag = code.slice(startTagIndex, tagEndIndex + 1);
254
1191
  const attrString = startTag.slice(componentName.length + 1, -1).trim();
255
- if (!hasStringNameAttribute(attrString)) {
256
- currentIndex = startTagIndex + 1;
257
- continue;
258
- }
259
1192
  const attributes = parseAttributes(attrString);
260
- if (!attributes.name) {
261
- currentIndex = startTagIndex + 1;
262
- continue;
263
- }
264
1193
  const isSelfClosing = startTag.endsWith("/>");
265
1194
  let endIndex;
266
1195
  let fullMatch;
@@ -274,11 +1203,6 @@ function findComponents(code, name) {
274
1203
  currentIndex = startTagIndex + 1;
275
1204
  continue;
276
1205
  }
277
- const content = code.slice(tagEndIndex + 1, endTagIndex);
278
- if (!isOnlyWhitespace(content)) {
279
- currentIndex = startTagIndex + 1;
280
- continue;
281
- }
282
1206
  endIndex = endTagIndex + endTag.length;
283
1207
  fullMatch = code.slice(startTagIndex, endIndex);
284
1208
  }