@fangzhongya/icons 0.0.8 → 0.0.9

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