@fangzhongya/icons 0.0.15 → 0.0.17
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/{vue.cjs → async.cjs} +23 -23
- package/dist/{vue.d.cts → async.d.cts} +20 -20
- package/dist/{vue.d.ts → async.d.ts} +20 -20
- package/dist/{vue.js → async.js} +23 -23
- package/dist/chunk-BKYM5ZD6.js +909 -0
- package/dist/{chunk-Y2JUP3JH.js → chunk-CDXRU53D.js} +4 -123
- package/dist/chunk-HSJ3RNOH.js +124 -0
- package/dist/chunk-OSHAEKZL.cjs +124 -0
- package/dist/{chunk-6UMRW5ES.cjs → chunk-P3DB3N7Y.cjs} +5 -124
- package/dist/chunk-V6F7B2R3.cjs +909 -0
- package/dist/iconify.cjs +2 -4
- package/dist/iconify.d.cts +1 -100
- package/dist/iconify.d.ts +1 -100
- package/dist/iconify.js +3 -5
- package/dist/index.cjs +17 -17
- package/dist/index.js +19 -19
- package/dist/index.json +1 -1
- package/dist/json.cjs +7 -0
- package/dist/json.d.cts +110 -0
- package/dist/json.d.ts +110 -0
- package/dist/json.js +7 -0
- package/dist/vite/index.cjs +293 -988
- package/dist/vite/index.d.cts +20 -1
- package/dist/vite/index.d.ts +20 -1
- package/dist/vite/index.js +298 -993
- package/dist/vite/index2.cjs +31 -9
- package/dist/vite/index2.d.cts +8 -7
- package/dist/vite/index2.d.ts +8 -7
- package/dist/vite/index2.js +32 -10
- package/dist/vite/index3.cjs +130 -0
- package/dist/vite/index3.d.cts +12 -0
- package/dist/vite/index3.d.ts +12 -0
- package/dist/vite/index3.js +130 -0
- package/dist/vue/index.cjs +16 -16
- package/dist/vue/index.js +19 -19
- package/package.json +2 -2
- package/dist/{chunk-3YRVWHZK.js → chunk-54HT4HDM.js} +18 -18
- package/dist/{chunk-BWFROGEZ.cjs → chunk-KXZN54UH.cjs} +15 -15
package/dist/vite/index.js
CHANGED
|
@@ -1,1033 +1,338 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runDev
|
|
3
|
+
} from "../chunk-BKYM5ZD6.js";
|
|
4
|
+
import {
|
|
5
|
+
getIconifySVG,
|
|
6
|
+
lineToLargeHump
|
|
7
|
+
} from "../chunk-HSJ3RNOH.js";
|
|
8
|
+
import "../chunk-MOHILOKE.js";
|
|
9
|
+
import {
|
|
10
|
+
json_default
|
|
11
|
+
} from "../chunk-CDXRU53D.js";
|
|
1
12
|
import "../chunk-MLKGABMK.js";
|
|
2
13
|
|
|
3
|
-
//
|
|
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";
|
|
14
|
+
// packages/vite/index.ts
|
|
59
15
|
import { join } from "path";
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
16
|
+
var virtualModuleId = "virtual:fang-icon";
|
|
17
|
+
function simpleFangIcon(options = {}) {
|
|
18
|
+
const {
|
|
19
|
+
name = "FangIcon",
|
|
20
|
+
type = "svg",
|
|
21
|
+
directory = "./svg",
|
|
22
|
+
dynamic = true,
|
|
23
|
+
virtual = false,
|
|
24
|
+
replaced = true,
|
|
25
|
+
customReplacement
|
|
26
|
+
} = options;
|
|
27
|
+
if (type === "pub" && options.mobile) {
|
|
28
|
+
const outDir = join("./public/", directory);
|
|
29
|
+
runDev({
|
|
30
|
+
issort: true,
|
|
31
|
+
dir: "./node_modules/@fangzhongya/icons/dist/svg",
|
|
32
|
+
outDir,
|
|
33
|
+
extensions: ["svg"],
|
|
34
|
+
read: true,
|
|
35
|
+
fileCover: true,
|
|
36
|
+
isNeader: false
|
|
37
|
+
});
|
|
71
38
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
name,
|
|
75
|
-
suffix,
|
|
76
|
-
apart
|
|
39
|
+
const plugin = {
|
|
40
|
+
name: "simple-fang-icon"
|
|
77
41
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
42
|
+
if (virtual) {
|
|
43
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
44
|
+
const pub = `
|
|
45
|
+
import { defineComponent, h,} from 'vue'
|
|
46
|
+
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
47
|
+
const component = defineComponent({
|
|
48
|
+
name: '${name}',
|
|
49
|
+
props: {
|
|
50
|
+
name: {
|
|
51
|
+
type: [String, Object],
|
|
52
|
+
},
|
|
53
|
+
default: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: '${type}'
|
|
56
|
+
},
|
|
57
|
+
directory: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '${directory}'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
setup(props, { attrs }) {
|
|
63
|
+
return () => {
|
|
64
|
+
return h(FangIcon, {
|
|
65
|
+
...attrs,
|
|
66
|
+
name: props.name,
|
|
67
|
+
default: props.default,
|
|
68
|
+
directory: props.directory
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
// \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
|
|
74
|
+
export const install = (app) => {
|
|
75
|
+
app.component('${name}', component)
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default component;`;
|
|
79
|
+
const svg = `
|
|
80
|
+
import { defineComponent, h, computed} from 'vue'
|
|
81
|
+
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
82
|
+
import icons from '@fangzhongya/icons/async'
|
|
83
|
+
const component = defineComponent({
|
|
84
|
+
name: '${name}',
|
|
85
|
+
props: {
|
|
86
|
+
name: {
|
|
87
|
+
type: [String, Object],
|
|
88
|
+
},
|
|
89
|
+
type: {
|
|
90
|
+
type: String,
|
|
91
|
+
},
|
|
92
|
+
default: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: '${type}'
|
|
95
|
+
},
|
|
96
|
+
directory: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: '${directory}'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
setup(props, { attrs }) {
|
|
102
|
+
const iconName = computed(() => {
|
|
103
|
+
const name = props.name;
|
|
104
|
+
if (typeof name === 'string' && (props.type === 'svg' ||
|
|
105
|
+
(!props.type && props.default === 'svg'))) {
|
|
106
|
+
const icon = icons[name];
|
|
107
|
+
if(icon){
|
|
108
|
+
return icon;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return name;
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
return h(FangIcon, {
|
|
115
|
+
...attrs,
|
|
116
|
+
name: iconName.value,
|
|
117
|
+
type: props.type,
|
|
118
|
+
default: props.default,
|
|
119
|
+
directory: props.directory
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
// \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
|
|
125
|
+
export const install = (app) => {
|
|
126
|
+
app.component('${name}', component)
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default component;`;
|
|
130
|
+
const text = type === "svg" ? svg : pub;
|
|
131
|
+
plugin.resolveId = function(id) {
|
|
132
|
+
if (id === virtualModuleId) {
|
|
133
|
+
return resolvedVirtualModuleId;
|
|
108
134
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}
|
|
135
|
+
return void 0;
|
|
136
|
+
};
|
|
137
|
+
plugin.load = function(id) {
|
|
138
|
+
if (id === resolvedVirtualModuleId) {
|
|
139
|
+
return text;
|
|
190
140
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
}
|
|
141
|
+
return null;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (replaced) {
|
|
145
|
+
const targetComponents = Array.isArray(name) ? name : [name];
|
|
146
|
+
plugin.enforce = "pre";
|
|
147
|
+
plugin.transform = function(code, id) {
|
|
148
|
+
if (!shouldProcess(id)) {
|
|
149
|
+
return null;
|
|
241
150
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
151
|
+
try {
|
|
152
|
+
const components = findComponents(code, targetComponents);
|
|
153
|
+
if (components.length === 0) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
let transformedCode = code;
|
|
157
|
+
let replacedCount = 0;
|
|
158
|
+
const imports = /* @__PURE__ */ new Set();
|
|
159
|
+
for (let i = components.length - 1; i >= 0; i--) {
|
|
160
|
+
const component = components[i];
|
|
161
|
+
if (component) {
|
|
162
|
+
const { text, imptext } = replaceComponent(
|
|
163
|
+
component,
|
|
164
|
+
type,
|
|
165
|
+
dynamic,
|
|
166
|
+
customReplacement
|
|
167
|
+
);
|
|
168
|
+
imports.add(imptext);
|
|
169
|
+
if (text !== component.fullMatch) {
|
|
170
|
+
transformedCode = transformedCode.slice(0, component.start) + text + transformedCode.slice(component.end);
|
|
171
|
+
replacedCount++;
|
|
253
172
|
}
|
|
254
173
|
}
|
|
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
174
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
files.file.forEach((name) => {
|
|
324
|
-
let is = true;
|
|
325
|
-
if (isFile) {
|
|
326
|
-
is = isFile(url, name);
|
|
175
|
+
if (/.vue$/.test(id)) {
|
|
176
|
+
const i = transformedCode.indexOf("</script>");
|
|
177
|
+
transformedCode = transformedCode.slice(0, i) + [...imports].join(";") + transformedCode.slice(i);
|
|
178
|
+
} else {
|
|
179
|
+
transformedCode = [...imports].join(";") + transformedCode;
|
|
327
180
|
}
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
|
|
181
|
+
if (replacedCount > 0) {
|
|
182
|
+
return {
|
|
183
|
+
code: transformedCode,
|
|
184
|
+
map: null
|
|
185
|
+
};
|
|
331
186
|
}
|
|
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);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.error(`\u5904\u7406\u6587\u4EF6 ${id} \u65F6\u51FA\u9519:`, error);
|
|
340
189
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
-
}
|
|
190
|
+
return null;
|
|
191
|
+
};
|
|
192
|
+
plugin.handleHotUpdate = function({
|
|
193
|
+
file,
|
|
194
|
+
server
|
|
195
|
+
}) {
|
|
196
|
+
if (shouldProcess(file)) {
|
|
197
|
+
server.ws.send({
|
|
198
|
+
type: "full-reload"
|
|
199
|
+
});
|
|
200
|
+
return [];
|
|
395
201
|
}
|
|
396
|
-
}
|
|
397
|
-
return false;
|
|
398
|
-
} else {
|
|
399
|
-
return true;
|
|
202
|
+
};
|
|
400
203
|
}
|
|
204
|
+
return plugin;
|
|
401
205
|
}
|
|
402
|
-
function
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
206
|
+
function parseAttributes(attrString) {
|
|
207
|
+
const attributes = { name: "" };
|
|
208
|
+
const attrRegex = /(?:@|:|v-bind:)?([\w-]+)(?:="([^"]*)"|='([^']*)')/g;
|
|
209
|
+
let match;
|
|
210
|
+
while ((match = attrRegex.exec(attrString)) !== null) {
|
|
211
|
+
const name = match[1];
|
|
212
|
+
if (name) {
|
|
213
|
+
const value = match[2] || match[3] || "";
|
|
214
|
+
if (name === "name") {
|
|
215
|
+
attributes.name = value;
|
|
216
|
+
} else if (value === "true" || value === "false") {
|
|
217
|
+
attributes[name] = value === "true";
|
|
218
|
+
} else if (!isNaN(Number(value)) && value !== "") {
|
|
219
|
+
attributes[name] = Number(value);
|
|
409
220
|
} else {
|
|
410
|
-
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
221
|
+
attributes[name] = value;
|
|
413
222
|
}
|
|
414
223
|
}
|
|
415
|
-
return false;
|
|
416
|
-
} else {
|
|
417
|
-
return true;
|
|
418
224
|
}
|
|
225
|
+
return attributes;
|
|
419
226
|
}
|
|
420
|
-
function
|
|
421
|
-
const
|
|
422
|
-
|
|
227
|
+
function hasStringNameAttribute(attrString) {
|
|
228
|
+
const nameRegex = /(?:^|\s)name="[^"]*"/i;
|
|
229
|
+
const singleQuoteRegex = /(?:^|\s)name='[^']*'/i;
|
|
230
|
+
return nameRegex.test(attrString) || singleQuoteRegex.test(attrString);
|
|
423
231
|
}
|
|
424
|
-
|
|
425
|
-
|
|
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("|")})$`);
|
|
232
|
+
function isOnlyWhitespace(content) {
|
|
233
|
+
return !content || /^\s*$/.test(content);
|
|
482
234
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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;
|
|
235
|
+
function findComponents(code, name) {
|
|
236
|
+
const components = [];
|
|
237
|
+
for (const componentName of name) {
|
|
238
|
+
let currentIndex = 0;
|
|
239
|
+
while (currentIndex < code.length) {
|
|
240
|
+
const startTagIndex = code.indexOf(
|
|
241
|
+
`<${componentName}`,
|
|
242
|
+
currentIndex
|
|
243
|
+
);
|
|
244
|
+
if (startTagIndex === -1) break;
|
|
245
|
+
let tagEndIndex = code.indexOf(">", startTagIndex);
|
|
246
|
+
if (tagEndIndex === -1) break;
|
|
247
|
+
const startTag = code.slice(startTagIndex, tagEndIndex + 1);
|
|
248
|
+
const attrString = startTag.slice(componentName.length + 1, -1).trim();
|
|
249
|
+
if (!hasStringNameAttribute(attrString)) {
|
|
250
|
+
currentIndex = startTagIndex + 1;
|
|
251
|
+
continue;
|
|
579
252
|
}
|
|
580
|
-
|
|
581
|
-
|
|
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([]);
|
|
253
|
+
const attributes = parseAttributes(attrString);
|
|
254
|
+
if (!attributes.name) {
|
|
255
|
+
currentIndex = startTagIndex + 1;
|
|
256
|
+
continue;
|
|
611
257
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
-
}
|
|
258
|
+
const isSelfClosing = startTag.endsWith("/>");
|
|
259
|
+
let endIndex;
|
|
260
|
+
let fullMatch;
|
|
261
|
+
if (isSelfClosing) {
|
|
262
|
+
endIndex = tagEndIndex + 1;
|
|
263
|
+
fullMatch = startTag;
|
|
664
264
|
} else {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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(" "));
|
|
265
|
+
const endTag = `</${componentName}>`;
|
|
266
|
+
let endTagIndex = code.indexOf(endTag, tagEndIndex + 1);
|
|
267
|
+
if (endTagIndex === -1) {
|
|
268
|
+
currentIndex = startTagIndex + 1;
|
|
269
|
+
continue;
|
|
742
270
|
}
|
|
743
|
-
|
|
744
|
-
|
|
271
|
+
const content = code.slice(tagEndIndex + 1, endTagIndex);
|
|
272
|
+
if (!isOnlyWhitespace(content)) {
|
|
273
|
+
currentIndex = startTagIndex + 1;
|
|
274
|
+
continue;
|
|
745
275
|
}
|
|
276
|
+
endIndex = endTagIndex + endTag.length;
|
|
277
|
+
fullMatch = code.slice(startTagIndex, endIndex);
|
|
746
278
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
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));
|
|
279
|
+
components.push({
|
|
280
|
+
componentName,
|
|
281
|
+
fullMatch,
|
|
282
|
+
start: startTagIndex,
|
|
283
|
+
end: endIndex,
|
|
284
|
+
attributes,
|
|
285
|
+
isSelfClosing
|
|
822
286
|
});
|
|
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];
|
|
287
|
+
currentIndex = endIndex;
|
|
900
288
|
}
|
|
901
|
-
return arr;
|
|
902
289
|
}
|
|
903
|
-
|
|
904
|
-
function runDev(config, configCallback, callback) {
|
|
905
|
-
const fang = new FangOut(config);
|
|
906
|
-
fang.runDev(callback, configCallback);
|
|
290
|
+
return components;
|
|
907
291
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
issort: true,
|
|
920
|
-
dir: "./node_modules/@fangzhongya/icons/dist/svg",
|
|
921
|
-
outDir,
|
|
922
|
-
extensions: ["svg"],
|
|
923
|
-
read: true,
|
|
924
|
-
fileCover: true,
|
|
925
|
-
isNeader: false
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
const pub = `
|
|
929
|
-
import { defineComponent, h,} from 'vue'
|
|
930
|
-
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
931
|
-
const component = defineComponent({
|
|
932
|
-
name: '${name}',
|
|
933
|
-
props: {
|
|
934
|
-
name: {
|
|
935
|
-
type: [String, Object],
|
|
936
|
-
},
|
|
937
|
-
default: {
|
|
938
|
-
type: String,
|
|
939
|
-
default: '${type}'
|
|
940
|
-
},
|
|
941
|
-
directory: {
|
|
942
|
-
type: String,
|
|
943
|
-
default: '${directory}'
|
|
944
|
-
}
|
|
945
|
-
},
|
|
946
|
-
setup(props, { attrs }) {
|
|
947
|
-
return () => {
|
|
948
|
-
return h(FangIcon, {
|
|
949
|
-
...attrs,
|
|
950
|
-
name: props.name,
|
|
951
|
-
default: props.default,
|
|
952
|
-
directory: props.directory
|
|
953
|
-
});
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
// \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
|
|
958
|
-
export const install = (app) => {
|
|
959
|
-
app.component('${name}', component)
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
export default component;`;
|
|
963
|
-
const svg = `
|
|
964
|
-
import { defineComponent, h, computed} from 'vue'
|
|
965
|
-
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
966
|
-
import { icons } from '@fangzhongya/icons/vue'
|
|
967
|
-
const component = defineComponent({
|
|
968
|
-
name: '${name}',
|
|
969
|
-
props: {
|
|
970
|
-
name: {
|
|
971
|
-
type: [String, Object],
|
|
972
|
-
},
|
|
973
|
-
type: {
|
|
974
|
-
type: String,
|
|
975
|
-
},
|
|
976
|
-
default: {
|
|
977
|
-
type: String,
|
|
978
|
-
default: '${type}'
|
|
979
|
-
},
|
|
980
|
-
directory: {
|
|
981
|
-
type: String,
|
|
982
|
-
default: '${directory}'
|
|
983
|
-
}
|
|
984
|
-
},
|
|
985
|
-
setup(props, { attrs }) {
|
|
986
|
-
const iconName = computed(() => {
|
|
987
|
-
const name = props.name;
|
|
988
|
-
if (typeof name === 'string' && (props.type === 'svg' ||
|
|
989
|
-
(props.type === undefined && props.default === 'svg'))) {
|
|
990
|
-
const icon = icons[name];
|
|
991
|
-
if(icon){
|
|
992
|
-
return icon;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
return name;
|
|
996
|
-
});
|
|
997
|
-
return () => {
|
|
998
|
-
return h(FangIcon, {
|
|
999
|
-
...attrs,
|
|
1000
|
-
name: iconName.value,
|
|
1001
|
-
type: props.type,
|
|
1002
|
-
default: props.default,
|
|
1003
|
-
directory: props.directory
|
|
1004
|
-
});
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
// \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
|
|
1009
|
-
export const install = (app) => {
|
|
1010
|
-
app.component('${name}', component)
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
export default component;`;
|
|
1014
|
-
const text = type === "svg" ? svg : pub;
|
|
292
|
+
function getText(iconName, match) {
|
|
293
|
+
const svg = getIconifySVG(json_default, iconName, 'v-bind="scope"');
|
|
294
|
+
const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`name='${iconName}'`, "").replace(`</${match.componentName}>`, "");
|
|
295
|
+
const text = `${s}<template #default="scope">${svg}</template></${match.componentName}>`;
|
|
296
|
+
return { text, imptext: "" };
|
|
297
|
+
}
|
|
298
|
+
function getImportName(iconName) {
|
|
299
|
+
return lineToLargeHump("fang-icon-" + iconName);
|
|
300
|
+
}
|
|
301
|
+
function getVue(iconName, match) {
|
|
302
|
+
const text = match.fullMatch.replace(`name="${iconName}"`, `:name="${getImportName(iconName)}"`).replace(`name='${iconName}'`, `:name='${getImportName(iconName)}'`);
|
|
1015
303
|
return {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
return void 0;
|
|
1022
|
-
},
|
|
1023
|
-
load(id) {
|
|
1024
|
-
if (id === resolvedVirtualModuleId) {
|
|
1025
|
-
return text;
|
|
1026
|
-
}
|
|
1027
|
-
return null;
|
|
1028
|
-
}
|
|
304
|
+
text,
|
|
305
|
+
imptext: `import ${getImportName(
|
|
306
|
+
iconName
|
|
307
|
+
)} from '@fangzhongya/icons/vue/${iconName}'`
|
|
1029
308
|
};
|
|
1030
309
|
}
|
|
310
|
+
function replaceComponent(match, type, dynamic, customReplacement) {
|
|
311
|
+
const { attributes } = match;
|
|
312
|
+
const iconName = attributes.name;
|
|
313
|
+
if (customReplacement) {
|
|
314
|
+
return customReplacement(iconName, attributes);
|
|
315
|
+
}
|
|
316
|
+
let svgContent = json_default.icons[iconName];
|
|
317
|
+
if (!svgContent) {
|
|
318
|
+
return { text: match.fullMatch, imptext: "" };
|
|
319
|
+
}
|
|
320
|
+
if (!attributes.type && type == "svg" || attributes.type === "svg") {
|
|
321
|
+
if (dynamic) {
|
|
322
|
+
return getVue(iconName, match);
|
|
323
|
+
} else {
|
|
324
|
+
return getText(iconName, match);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return { text: match.fullMatch, imptext: "" };
|
|
328
|
+
}
|
|
329
|
+
function shouldProcess(id) {
|
|
330
|
+
const validExtensions = [".vue", ".jsx", ".tsx", ".js", ".ts"];
|
|
331
|
+
const hasValidExtension = validExtensions.some((ext) => id.endsWith(ext));
|
|
332
|
+
if (!hasValidExtension) return false;
|
|
333
|
+
if (id.includes("/node_modules/")) return false;
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
1031
336
|
export {
|
|
1032
337
|
simpleFangIcon
|
|
1033
338
|
};
|