@fastkit/icon-font-gen 0.12.8 → 0.12.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.
- package/bin/cli.mjs +2 -0
- package/dist/chunk-USVWZGQ7.mjs +332 -0
- package/dist/chunk-USVWZGQ7.mjs.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.mjs +142 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/icon-font-gen.d.ts +86 -106
- package/dist/icon-font-gen.mjs +3 -368
- package/dist/icon-font-gen.mjs.map +1 -0
- package/package.json +73 -39
- package/lib/cli.mjs +0 -4
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import path2 from 'node:path';
|
|
2
|
+
import { installPackage, HashComparator } from '@fastkit/node-util';
|
|
3
|
+
import { TinyLogger, createTinyError } from '@fastkit/tiny-logger';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import chokidar from 'chokidar';
|
|
6
|
+
import { EV } from '@fastkit/ev';
|
|
7
|
+
|
|
8
|
+
var ICON_FONT_FORMATS = [
|
|
9
|
+
"eot",
|
|
10
|
+
"woff",
|
|
11
|
+
"woff2",
|
|
12
|
+
"svg",
|
|
13
|
+
"ttf"
|
|
14
|
+
];
|
|
15
|
+
var ICON_FONT_FORMAT_MAP = {
|
|
16
|
+
eot: "embedded-opentype",
|
|
17
|
+
woff2: "woff2",
|
|
18
|
+
woff: "woff",
|
|
19
|
+
ttf: "truetype",
|
|
20
|
+
svg: "svg"
|
|
21
|
+
};
|
|
22
|
+
async function resolveRawIconFontEntry(rootDir, rawEntry) {
|
|
23
|
+
const entry = {
|
|
24
|
+
...rawEntry
|
|
25
|
+
};
|
|
26
|
+
if (entry.src === "@mdi") {
|
|
27
|
+
const installedDir = await findOrInstallMDI();
|
|
28
|
+
entry.src = path2.join(installedDir, "svg");
|
|
29
|
+
if (entry.fontHeight == null) {
|
|
30
|
+
entry.fontHeight = 512;
|
|
31
|
+
}
|
|
32
|
+
if (entry.descent == null) {
|
|
33
|
+
entry.descent = 64;
|
|
34
|
+
}
|
|
35
|
+
if (entry.name == null) {
|
|
36
|
+
entry.name = "mdi";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const name2 = entry.name || path2.basename(entry.src);
|
|
40
|
+
const fontName = entry.fontName || `${name2}-icon`;
|
|
41
|
+
const dest = path2.join(rootDir, name2);
|
|
42
|
+
const prefix = entry.disablePrefix ? "" : `${name2}-`;
|
|
43
|
+
return {
|
|
44
|
+
...entry,
|
|
45
|
+
name: name2,
|
|
46
|
+
fontName,
|
|
47
|
+
prefix,
|
|
48
|
+
dest
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function findOrInstallMDI() {
|
|
52
|
+
return installPackage("@mdi/svg", { dev: true });
|
|
53
|
+
}
|
|
54
|
+
var DEFAULT_CONFIG_FILENAME = "icon-font.config";
|
|
55
|
+
var DEFAULT_DEST_DIRNAME = ".icon-font";
|
|
56
|
+
function ceateIconFontConfig(options) {
|
|
57
|
+
return options;
|
|
58
|
+
}
|
|
59
|
+
var name = "icon-font-gen";
|
|
60
|
+
var logger = new TinyLogger(name);
|
|
61
|
+
var IconFontGenError = createTinyError(name);
|
|
62
|
+
var DEFAULT_OPTIONS = {
|
|
63
|
+
formats: ["woff2"],
|
|
64
|
+
fixedWidth: true,
|
|
65
|
+
normalize: true
|
|
66
|
+
};
|
|
67
|
+
var BANNER = `
|
|
68
|
+
/**
|
|
69
|
+
* This is auto generated file.
|
|
70
|
+
* Do not edit !!!
|
|
71
|
+
*
|
|
72
|
+
* @see: https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen
|
|
73
|
+
*/
|
|
74
|
+
`.trim();
|
|
75
|
+
function mergeDefaults(entry) {
|
|
76
|
+
return {
|
|
77
|
+
...DEFAULT_OPTIONS,
|
|
78
|
+
...entry
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function generateTS(entry, ids) {
|
|
82
|
+
const code = `
|
|
83
|
+
/* eslint-disable */
|
|
84
|
+
// @ts-nocheck
|
|
85
|
+
${BANNER}
|
|
86
|
+
import type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
87
|
+
import { registerIconNames } from '@fastkit/icon-font';
|
|
88
|
+
declare module "@fastkit/icon-font" {
|
|
89
|
+
export interface IconNameMap {
|
|
90
|
+
${ids.map((id) => ` '${id}': true,`).join("\n")}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const ICON_NAMES = registerIconNames([
|
|
94
|
+
${ids.map((id) => `'${id}'`).join(",\n ")}
|
|
95
|
+
]);
|
|
96
|
+
export type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
97
|
+
`.trim();
|
|
98
|
+
const fileName = `${entry.name || "icons"}.ts`;
|
|
99
|
+
const dest = path2.resolve(entry.dest, fileName);
|
|
100
|
+
await fs.writeFile(dest, code);
|
|
101
|
+
return {
|
|
102
|
+
fileName,
|
|
103
|
+
dest,
|
|
104
|
+
code
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function generateEntry(entry) {
|
|
108
|
+
const options = mergeDefaults(entry);
|
|
109
|
+
const cssPrefix = `icon-${options.prefix}`;
|
|
110
|
+
const hash = new HashComparator(options.src, options.dest);
|
|
111
|
+
const srcHash = await hash.hasChanged();
|
|
112
|
+
if (!srcHash) {
|
|
113
|
+
logger.info(`Has not chaged files. Skip process. >>> ${options.src}`);
|
|
114
|
+
return { entry };
|
|
115
|
+
}
|
|
116
|
+
await fs.ensureDir(options.dest);
|
|
117
|
+
const { webfont } = await import('webfont');
|
|
118
|
+
const { startUnicode = 47617 } = options;
|
|
119
|
+
let i = startUnicode;
|
|
120
|
+
const result = await webfont({
|
|
121
|
+
files: options.src,
|
|
122
|
+
fontName: options.fontName,
|
|
123
|
+
formats: options.formats,
|
|
124
|
+
fixedWidth: options.fixedWidth,
|
|
125
|
+
centerHorizontally: options.centerHorizontally,
|
|
126
|
+
normalize: options.normalize,
|
|
127
|
+
fontHeight: options.fontHeight,
|
|
128
|
+
round: options.round,
|
|
129
|
+
descent: options.descent,
|
|
130
|
+
addHashInFontUrl: options.addHashInFontUrl,
|
|
131
|
+
glyphTransformFn: (obj) => {
|
|
132
|
+
const char = String.fromCodePoint(i);
|
|
133
|
+
obj.unicode = [char];
|
|
134
|
+
i++;
|
|
135
|
+
return obj;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const buildedFormats = [];
|
|
139
|
+
ICON_FONT_FORMATS.forEach((format) => {
|
|
140
|
+
const code = result[format];
|
|
141
|
+
if (code) {
|
|
142
|
+
buildedFormats.push({ format, code });
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
await Promise.all(
|
|
146
|
+
buildedFormats.map(({ format, code }) => {
|
|
147
|
+
return fs.writeFile(
|
|
148
|
+
path2.join(options.dest, `${options.name}.${format}`),
|
|
149
|
+
code
|
|
150
|
+
);
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
const glyphs = [];
|
|
154
|
+
result.glyphsData.forEach(({ metadata }) => {
|
|
155
|
+
if (!metadata)
|
|
156
|
+
return;
|
|
157
|
+
const { name: name2, unicode } = metadata;
|
|
158
|
+
if (!unicode) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const code = unicode[0].charCodeAt(0).toString(16);
|
|
162
|
+
glyphs.push({ name: name2, code });
|
|
163
|
+
});
|
|
164
|
+
const urlPath = options.absolutePath ? options.dest : ".";
|
|
165
|
+
const hashSuffix = options.addHashInFontUrl ? `?${Date.now()}` : "";
|
|
166
|
+
const src = buildedFormats.map(({ format }) => {
|
|
167
|
+
return `url("${urlPath}/${options.name}.${format}${hashSuffix}") format("${ICON_FONT_FORMAT_MAP[format]}")`;
|
|
168
|
+
}).join(",");
|
|
169
|
+
const cssCode = `/* stylelint-disable */
|
|
170
|
+
@font-face {
|
|
171
|
+
font-family: "${options.fontName}";
|
|
172
|
+
font-display: block;
|
|
173
|
+
font-style: normal;
|
|
174
|
+
font-weight: 400;
|
|
175
|
+
src: ${src};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
i[class^="${cssPrefix}"]:before, i[class*=" ${cssPrefix}"]:before {
|
|
179
|
+
font-family: ${options.fontName} !important;
|
|
180
|
+
font-style: normal;
|
|
181
|
+
font-weight: normal !important;
|
|
182
|
+
font-variant: normal;
|
|
183
|
+
text-transform: none;
|
|
184
|
+
text-rendering: auto;
|
|
185
|
+
line-height: 1;
|
|
186
|
+
-webkit-font-smoothing: antialiased;
|
|
187
|
+
-moz-osx-font-smoothing: grayscale;
|
|
188
|
+
}
|
|
189
|
+
${glyphs.map(({ name: name2, code }) => {
|
|
190
|
+
return `
|
|
191
|
+
.${cssPrefix}${name2}:before { content: "\\${code}"; }
|
|
192
|
+
`;
|
|
193
|
+
}).join("\n")}
|
|
194
|
+
`;
|
|
195
|
+
await fs.writeFile(path2.join(options.dest, `${options.name}.css`), cssCode);
|
|
196
|
+
const ids = glyphs.map(({ name: name2 }) => `${options.prefix}${name2}`);
|
|
197
|
+
await generateTS(options, ids);
|
|
198
|
+
await hash.commit(srcHash);
|
|
199
|
+
return {
|
|
200
|
+
entry,
|
|
201
|
+
result
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
async function generateIndex(dest, entries) {
|
|
205
|
+
const names = entries.map(({ name: name2 }) => name2);
|
|
206
|
+
const tsCode = `
|
|
207
|
+
/* eslint-disable */
|
|
208
|
+
// @ts-nocheck
|
|
209
|
+
import './index.css';
|
|
210
|
+
${BANNER}
|
|
211
|
+
${names.map(
|
|
212
|
+
(name2, index) => (
|
|
213
|
+
// `import { IconName as IconName_${index}, IconNameMap as IconNameMap_${index} } from './${name}/${name}';`,
|
|
214
|
+
`import './${name2}/${name2}';`
|
|
215
|
+
)
|
|
216
|
+
).join("\n")}
|
|
217
|
+
export type { IconName } from '@fastkit/icon-font';
|
|
218
|
+
export { ICON_NAMES } from '@fastkit/icon-font';
|
|
219
|
+
`.trim();
|
|
220
|
+
const tsDest = path2.join(dest, "index.ts");
|
|
221
|
+
await fs.writeFile(tsDest, tsCode);
|
|
222
|
+
const cssCode = `
|
|
223
|
+
/* stylelint-disable */
|
|
224
|
+
${BANNER}
|
|
225
|
+
${names.map((name2) => `@import './${name2}/${name2}.css';`).join("\n")}
|
|
226
|
+
`.trim();
|
|
227
|
+
const cssDest = path2.join(dest, "index.css");
|
|
228
|
+
await fs.writeFile(cssDest, cssCode);
|
|
229
|
+
}
|
|
230
|
+
async function generate(opts) {
|
|
231
|
+
await fs.emptyDir(opts.dest);
|
|
232
|
+
const results = await Promise.all(
|
|
233
|
+
opts.entries.map(
|
|
234
|
+
(entry) => resolveRawIconFontEntry(opts.dest, entry).then(
|
|
235
|
+
(entry2) => generateEntry(entry2)
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
);
|
|
239
|
+
const entries = results.map(({ entry }) => entry);
|
|
240
|
+
await generateIndex(opts.dest, entries);
|
|
241
|
+
}
|
|
242
|
+
var IconFontRunnerItem = class extends EV {
|
|
243
|
+
entry;
|
|
244
|
+
ctx;
|
|
245
|
+
_resolveEntryPromise;
|
|
246
|
+
_watcher = null;
|
|
247
|
+
watchMode;
|
|
248
|
+
// get name() {
|
|
249
|
+
// return this.entry.name;
|
|
250
|
+
// }
|
|
251
|
+
constructor(ctx, entry, watch = false) {
|
|
252
|
+
super();
|
|
253
|
+
this.ctx = ctx;
|
|
254
|
+
this.entry = entry;
|
|
255
|
+
this.watchMode = watch;
|
|
256
|
+
this.build = this.build.bind(this);
|
|
257
|
+
}
|
|
258
|
+
async run() {
|
|
259
|
+
const result = await this.build();
|
|
260
|
+
if (this.watchMode && !this._watcher) {
|
|
261
|
+
const watchDir = path2.resolve(this.entry.src);
|
|
262
|
+
this._watcher = chokidar.watch(watchDir, { ignoreInitial: true });
|
|
263
|
+
this._watcher.on("all", this.build);
|
|
264
|
+
}
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
resolveEntry() {
|
|
268
|
+
if (!this._resolveEntryPromise) {
|
|
269
|
+
this._resolveEntryPromise = resolveRawIconFontEntry(
|
|
270
|
+
this.ctx.dest,
|
|
271
|
+
this.entry
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return this._resolveEntryPromise;
|
|
275
|
+
}
|
|
276
|
+
async build() {
|
|
277
|
+
const entry = await this.resolveEntry();
|
|
278
|
+
const result = await generateEntry(entry);
|
|
279
|
+
this.emit("build", result);
|
|
280
|
+
return { entry };
|
|
281
|
+
}
|
|
282
|
+
destroy() {
|
|
283
|
+
if (this._watcher) {
|
|
284
|
+
this._watcher.close();
|
|
285
|
+
this._watcher = null;
|
|
286
|
+
}
|
|
287
|
+
this.offAll();
|
|
288
|
+
if (this.ctx) {
|
|
289
|
+
delete this.ctx;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var IconFontRunner = class extends EV {
|
|
294
|
+
items = [];
|
|
295
|
+
dest;
|
|
296
|
+
// private _opts: IconFontOptions;
|
|
297
|
+
// private entries: IconFontEntry[] = [];
|
|
298
|
+
constructor(opts, watch) {
|
|
299
|
+
super();
|
|
300
|
+
this.dest = opts.dest;
|
|
301
|
+
opts.entries.forEach((entry) => {
|
|
302
|
+
const item = new IconFontRunnerItem(this, entry, watch);
|
|
303
|
+
item.on("build", (result) => {
|
|
304
|
+
this.emit("build", { item, result });
|
|
305
|
+
});
|
|
306
|
+
this.items.push(item);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
async buildIndex() {
|
|
310
|
+
const entries = await Promise.all(
|
|
311
|
+
this.items.map((item) => item.resolveEntry())
|
|
312
|
+
);
|
|
313
|
+
return generateIndex(this.dest, entries);
|
|
314
|
+
}
|
|
315
|
+
async run() {
|
|
316
|
+
await fs.ensureDir(this.dest);
|
|
317
|
+
await Promise.all([
|
|
318
|
+
this.buildIndex(),
|
|
319
|
+
Promise.all(this.items.map((item) => item.run()))
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
destroy() {
|
|
323
|
+
this.items.forEach((item) => item.destroy());
|
|
324
|
+
this.items.length = 0;
|
|
325
|
+
this.offAll();
|
|
326
|
+
delete this._opts;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export { DEFAULT_CONFIG_FILENAME, DEFAULT_DEST_DIRNAME, DEFAULT_OPTIONS, ICON_FONT_FORMATS, ICON_FONT_FORMAT_MAP, IconFontGenError, IconFontRunner, IconFontRunnerItem, ceateIconFontConfig, generate, generateEntry, generateIndex, mergeDefaults, resolveRawIconFontEntry };
|
|
331
|
+
//# sourceMappingURL=out.js.map
|
|
332
|
+
//# sourceMappingURL=chunk-USVWZGQ7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemes.ts","../src/logger.ts","../src/generator.ts"],"names":["name","path","entry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,sBAAsB;AAIxB,IAAM,oBAAsC;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,uBAAuD;AAAA,EAClE,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AACP;AAqCA,eAAsB,wBACpB,SACA,UACwB;AACxB,QAAM,QAAQ;AAAA,IACZ,GAAG;AAAA,EACL;AAGA,MAAI,MAAM,QAAQ,QAAQ;AACxB,UAAM,eAAe,MAAM,iBAAiB;AAC5C,UAAM,MAAM,KAAK,KAAK,cAAc,KAAK;AACzC,QAAI,MAAM,cAAc,MAAM;AAC5B,YAAM,aAAa;AAAA,IACrB;AACA,QAAI,MAAM,WAAW,MAAM;AACzB,YAAM,UAAU;AAAA,IAClB;AACA,QAAI,MAAM,QAAQ,MAAM;AACtB,YAAM,OAAO;AAAA,IACf;AAAA,EACF;AAEA,QAAMA,QAAO,MAAM,Q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C;AACD,WAAK,MAAM,KAAK,IAAI;AAAA,IACtB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa;AACjB,UAAM,UAAU,MAAM,QAAQ;AAAA,MAC5B,KAAK,MAAM,IAAI,CAAC,SAAS,KAAK,aAAa,CAAC;AAAA,IAC9C;AACA,WAAO,cAAc,KAAK,MAAM,OAAO;AAAA,EACzC;AAAA,EAEA,MAAM,MAAM;AACV,UAAM,GAAG,UAAU,KAAK,IAAI;AAC5B,UAAM,QAAQ,IAAI;AAAA,MAChB,KAAK,WAAW;AAAA,MAChB,QAAQ,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AAAA,EAEA,UAAU;AACR,SAAK,MAAM,QAAQ,CAAC,SAAS,KAAK,QAAQ,CAAC;AAC3C,SAAK,MAAM,SAAS;AACpB,SAAK,OAAO;AACZ,WAAQ,KAAa;AAAA,EACvB;AACF","sourcesContent":["import type { OptionsBase } from 'webfont/dist/src/types/OptionsBase';\nimport path from 'node:path';\nimport { installPackage } from '@fastkit/node-util';\n\nexport type IconFontFormat = NonNullable<OptionsBase['formats']>[number];\n\nexport const ICON_FONT_FORMATS: IconFontFormat[] = [\n 'eot',\n 'woff',\n 'woff2',\n 'svg',\n 'ttf',\n];\n\nexport const ICON_FONT_FORMAT_MAP: Record<IconFontFormat, string> = {\n eot: 'embedded-opentype',\n woff2: 'woff2',\n woff: 'woff',\n ttf: 'truetype',\n svg: 'svg',\n};\n\nexport interface IconFontSettings {\n fixedWidth?: boolean;\n centerHorizontally?: boolean;\n normalize?: boolean;\n fontHeight?: number;\n round?: number;\n descent?: number;\n disablePrefix?: boolean;\n absolutePath?: boolean;\n addHashInFontUrl?: boolean;\n}\n\nexport interface IconFontEntry extends IconFontSettings {\n name: string;\n fontName: string;\n formats?: IconFontFormat[];\n startUnicode?: number;\n prefix: string;\n src: string;\n dest: string;\n}\n\nexport interface RawIconFontEntry\n extends Omit<IconFontEntry, 'name' | 'fontName' | 'prefix' | 'dest'> {\n name?: string;\n fontName?: string;\n}\n\n// export type RawIconFontOptions = IconFontEntry | IconFontEntry[];\n\nexport interface IconFontOptions {\n entries: RawIconFontEntry[];\n dest: string;\n}\n\nexport async function resolveRawIconFontEntry(\n rootDir: string,\n rawEntry: RawIconFontEntry,\n): Promise<IconFontEntry> {\n const entry = {\n ...rawEntry,\n };\n\n // mdi support\n if (entry.src === '@mdi') {\n const installedDir = await findOrInstallMDI();\n entry.src = path.join(installedDir, 'svg');\n if (entry.fontHeight == null) {\n entry.fontHeight = 512;\n }\n if (entry.descent == null) {\n entry.descent = 64;\n }\n if (entry.name == null) {\n entry.name = 'mdi';\n }\n }\n\n const name = entry.name || path.basename(entry.src);\n const fontName = entry.fontName || `${name}-icon`;\n const dest = path.join(rootDir, name);\n const prefix = entry.disablePrefix ? '' : `${name}-`;\n return {\n ...entry,\n name,\n fontName,\n prefix,\n dest,\n };\n}\n\nfunction findOrInstallMDI() {\n return installPackage('@mdi/svg', { dev: true });\n}\n\nexport const DEFAULT_CONFIG_FILENAME = 'icon-font.config';\n\nexport const DEFAULT_DEST_DIRNAME = '.icon-font';\n\nexport interface IconFontConfig extends Omit<IconFontOptions, 'dest'> {\n dest?: string;\n}\n\nexport function ceateIconFontConfig(options: IconFontConfig) {\n return options;\n}\n","import { TinyLogger, createTinyError } from '@fastkit/tiny-logger';\n\nconst name = 'icon-font-gen';\n\nexport const logger = new TinyLogger(name);\n\nexport const IconFontGenError = createTinyError(name);\n","import fs from 'fs-extra';\nimport path from 'node:path';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport { EV } from '@fastkit/ev';\nimport {\n IconFontOptions,\n IconFontEntry,\n RawIconFontEntry,\n resolveRawIconFontEntry,\n ICON_FONT_FORMATS,\n IconFontFormat,\n ICON_FONT_FORMAT_MAP,\n} from './schemes';\nimport { HashComparator } from '@fastkit/node-util';\nimport { UnPromisify } from '@fastkit/helpers';\nimport { logger } from './logger';\nimport type webfont from 'webfont';\n\nexport type IconFontEntryResult = {\n entry: IconFontEntry;\n result?: UnPromisify<ReturnType<typeof webfont>>;\n};\n\nexport const DEFAULT_OPTIONS: Partial<IconFontEntry> = {\n formats: ['woff2'],\n fixedWidth: true,\n normalize: true,\n};\n\nconst BANNER = `\n/**\n * This is auto generated file.\n * Do not edit !!!\n *\n * @see: https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen\n */\n`.trim();\n\nexport function mergeDefaults(entry: IconFontEntry): IconFontEntry {\n return {\n ...DEFAULT_OPTIONS,\n ...entry,\n };\n}\n\nasync function generateTS(entry: IconFontEntry, ids: string[]) {\n const code = `\n/* eslint-disable */\n// @ts-nocheck\n${BANNER}\nimport type { IconName, IconNameMap } from '@fastkit/icon-font';\nimport { registerIconNames } from '@fastkit/icon-font';\ndeclare module \"@fastkit/icon-font\" {\n export interface IconNameMap {\n${ids.map((id) => ` '${id}': true,`).join('\\n')}\n }\n}\nexport const ICON_NAMES = registerIconNames([\n ${ids.map((id) => `'${id}'`).join(',\\n ')}\n]);\nexport type { IconName, IconNameMap } from '@fastkit/icon-font';\n `.trim();\n const fileName = `${entry.name || 'icons'}.ts`;\n const dest = path.resolve(entry.dest, fileName);\n await fs.writeFile(dest, code);\n return {\n fileName,\n dest,\n code,\n };\n}\n\nexport async function generateEntry(\n entry: IconFontEntry,\n): Promise<IconFontEntryResult> {\n const options = mergeDefaults(entry);\n\n // @TODO support empty prefix\n // const namePrefix = options.name;\n const cssPrefix = `icon-${options.prefix}`;\n\n const hash = new HashComparator(options.src, options.dest);\n const srcHash = await hash.hasChanged();\n if (!srcHash) {\n logger.info(`Has not chaged files. Skip process. >>> ${options.src}`);\n return { entry };\n }\n\n await fs.ensureDir(options.dest);\n\n const { webfont } = await import('webfont');\n\n // const { startUnicode = 0xea01 } = options;\n const { startUnicode = 0xba01 } = options;\n\n let i = startUnicode;\n\n const result = await webfont({\n files: options.src,\n fontName: options.fontName,\n formats: options.formats,\n fixedWidth: options.fixedWidth,\n centerHorizontally: options.centerHorizontally,\n normalize: options.normalize,\n fontHeight: options.fontHeight,\n round: options.round,\n descent: options.descent,\n addHashInFontUrl: options.addHashInFontUrl,\n glyphTransformFn: (obj) => {\n const char = String.fromCodePoint(i);\n obj.unicode = [char];\n i++;\n return obj;\n },\n });\n\n const buildedFormats: { format: IconFontFormat; code: string | Buffer }[] =\n [];\n ICON_FONT_FORMATS.forEach((format) => {\n const code = result[format];\n if (code) {\n buildedFormats.push({ format, code });\n }\n });\n\n await Promise.all(\n buildedFormats.map(({ format, code }) => {\n return fs.writeFile(\n path.join(options.dest, `${options.name}.${format}`),\n code,\n );\n }),\n );\n\n const glyphs: { name: string; code: string }[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n result.glyphsData!.forEach(({ metadata }) => {\n if (!metadata) return;\n const { name, unicode } = metadata;\n if (!unicode) {\n return;\n }\n\n const code = unicode[0].charCodeAt(0).toString(16);\n glyphs.push({ name, code });\n });\n\n const urlPath = options.absolutePath ? options.dest : '.';\n const hashSuffix = options.addHashInFontUrl ? `?${Date.now()}` : '';\n ICON_FONT_FORMAT_MAP;\n const src = buildedFormats\n .map(({ format }) => {\n return `url(\"${urlPath}/${options.name}.${format}${hashSuffix}\") format(\"${ICON_FONT_FORMAT_MAP[format]}\")`;\n })\n .join(',');\n\n const cssCode = `/* stylelint-disable */\n@font-face {\n font-family: \"${options.fontName}\";\n font-display: block;\n font-style: normal;\n font-weight: 400;\n src: ${src};\n}\n\ni[class^=\"${cssPrefix}\"]:before, i[class*=\" ${cssPrefix}\"]:before {\n font-family: ${options.fontName} !important;\n font-style: normal;\n font-weight: normal !important;\n font-variant: normal;\n text-transform: none;\n text-rendering: auto;\n line-height: 1;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n${glyphs\n .map(({ name, code }) => {\n return `\n.${cssPrefix}${name}:before { content: \"\\\\${code}\"; }\n `;\n })\n .join('\\n')}\n `;\n await fs.writeFile(path.join(options.dest, `${options.name}.css`), cssCode);\n\n // const prefix = options.prefix ? `${options.prefix}-` : '';\n const ids = glyphs.map(({ name }) => `${options.prefix}${name}`);\n await generateTS(options, ids);\n await hash.commit(srcHash);\n return {\n entry,\n result,\n };\n}\n\nexport async function generateIndex(dest: string, entries: IconFontEntry[]) {\n const names = entries.map(({ name }) => name);\n const tsCode = `\n/* eslint-disable */\n// @ts-nocheck\nimport './index.css';\n${BANNER}\n${names\n .map(\n (name, index) =>\n // `import { IconName as IconName_${index}, IconNameMap as IconNameMap_${index} } from './${name}/${name}';`,\n `import './${name}/${name}';`,\n )\n .join('\\n')}\nexport type { IconName } from '@fastkit/icon-font';\nexport { ICON_NAMES } from '@fastkit/icon-font';\n `.trim();\n const tsDest = path.join(dest, 'index.ts');\n await fs.writeFile(tsDest, tsCode);\n\n const cssCode = `\n/* stylelint-disable */\n${BANNER}\n${names.map((name) => `@import './${name}/${name}.css';`).join('\\n')}\n `.trim();\n const cssDest = path.join(dest, 'index.css');\n await fs.writeFile(cssDest, cssCode);\n}\n\nexport async function generate(opts: IconFontOptions) {\n await fs.emptyDir(opts.dest);\n const results = await Promise.all(\n opts.entries.map((entry) =>\n resolveRawIconFontEntry(opts.dest, entry).then((entry) =>\n generateEntry(entry),\n ),\n ),\n );\n const entries = results.map(({ entry }) => entry);\n await generateIndex(opts.dest, entries);\n}\n\nexport class IconFontRunnerItem extends EV<{\n build: IconFontEntryResult;\n}> {\n readonly entry: RawIconFontEntry;\n readonly ctx: IconFontRunner;\n private _resolveEntryPromise?: Promise<IconFontEntry>;\n private _watcher: FSWatcher | null = null;\n watchMode: boolean;\n\n // get name() {\n // return this.entry.name;\n // }\n\n constructor(ctx: IconFontRunner, entry: RawIconFontEntry, watch = false) {\n super();\n this.ctx = ctx;\n this.entry = entry;\n this.watchMode = watch;\n this.build = this.build.bind(this);\n }\n\n async run() {\n const result = await this.build();\n if (this.watchMode && !this._watcher) {\n const watchDir = path.resolve(this.entry.src);\n this._watcher = chokidar.watch(watchDir, { ignoreInitial: true });\n this._watcher.on('all', this.build);\n }\n return result;\n }\n\n resolveEntry() {\n if (!this._resolveEntryPromise) {\n this._resolveEntryPromise = resolveRawIconFontEntry(\n this.ctx.dest,\n this.entry,\n );\n }\n return this._resolveEntryPromise;\n }\n\n async build() {\n const entry = await this.resolveEntry();\n const result = await generateEntry(entry);\n this.emit('build', result);\n return { entry };\n }\n\n destroy() {\n if (this._watcher) {\n this._watcher.close();\n this._watcher = null;\n }\n this.offAll();\n if (this.ctx) {\n delete (this as any).ctx;\n }\n }\n}\n\nexport class IconFontRunner extends EV<{\n build: {\n item: IconFontRunnerItem;\n result: IconFontEntryResult;\n };\n}> {\n readonly items: IconFontRunnerItem[] = [];\n readonly dest: string;\n // private _opts: IconFontOptions;\n // private entries: IconFontEntry[] = [];\n\n constructor(opts: IconFontOptions, watch?: boolean) {\n super();\n\n // this._opts = opts;\n this.dest = opts.dest;\n // this.entries = opts.entries.map((entry) =>\n // resolveRawIconFontEntry(this.outputDir, entry),\n // );\n\n opts.entries.forEach((entry) => {\n const item = new IconFontRunnerItem(this, entry, watch);\n item.on('build', (result) => {\n this.emit('build', { item, result });\n });\n this.items.push(item);\n });\n }\n\n async buildIndex() {\n const entries = await Promise.all(\n this.items.map((item) => item.resolveEntry()),\n );\n return generateIndex(this.dest, entries);\n }\n\n async run() {\n await fs.ensureDir(this.dest);\n await Promise.all([\n this.buildIndex(),\n Promise.all(this.items.map((item) => item.run())),\n ]);\n }\n\n destroy() {\n this.items.forEach((item) => item.destroy());\n this.items.length = 0;\n this.offAll();\n delete (this as any)._opts;\n }\n}\n"]}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import __plugboy_path from 'node:path';
|
|
2
|
+
import { DEFAULT_DEST_DIRNAME, DEFAULT_CONFIG_FILENAME, IconFontGenError, generate } from './chunk-USVWZGQ7.mjs';
|
|
3
|
+
import { cac } from 'cac';
|
|
4
|
+
import { findPackageDir, esbuildRequire } from '@fastkit/node-util';
|
|
5
|
+
|
|
6
|
+
// package.json
|
|
7
|
+
var package_default = {
|
|
8
|
+
name: "@fastkit/icon-font-gen",
|
|
9
|
+
version: "0.12.8",
|
|
10
|
+
description: "A tool to generate icon web fonts and their definitions Type-safe for your application.",
|
|
11
|
+
keywords: [
|
|
12
|
+
"fastkit",
|
|
13
|
+
"icon"
|
|
14
|
+
],
|
|
15
|
+
homepage: "https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen#readme",
|
|
16
|
+
bugs: {
|
|
17
|
+
url: "https://github.com/dadajam4/fastkit/issues"
|
|
18
|
+
},
|
|
19
|
+
repository: {
|
|
20
|
+
type: "git",
|
|
21
|
+
url: "git+https://github.com/dadajam4/fastkit.git"
|
|
22
|
+
},
|
|
23
|
+
license: "MIT",
|
|
24
|
+
author: "dadajam4",
|
|
25
|
+
type: "module",
|
|
26
|
+
exports: {
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
".": {
|
|
29
|
+
types: "./dist/icon-font-gen.d.ts",
|
|
30
|
+
import: {
|
|
31
|
+
default: "./dist/icon-font-gen.mjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./cli": {
|
|
35
|
+
types: "./dist/cli.d.ts",
|
|
36
|
+
import: {
|
|
37
|
+
default: "./dist/cli.mjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./*": "./dist/*"
|
|
41
|
+
},
|
|
42
|
+
main: "./dist/icon-font-gen.mjs",
|
|
43
|
+
types: "./dist/icon-font-gen.d.ts",
|
|
44
|
+
typesVersions: {
|
|
45
|
+
"*": {
|
|
46
|
+
".": [
|
|
47
|
+
"./dist/icon-font-gen.d.ts"
|
|
48
|
+
],
|
|
49
|
+
cli: [
|
|
50
|
+
"./dist/cli.d.ts"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
bin: {
|
|
55
|
+
"icon-font": "./bin/cli.mjs"
|
|
56
|
+
},
|
|
57
|
+
files: [
|
|
58
|
+
"./cli.mjs",
|
|
59
|
+
"dist"
|
|
60
|
+
],
|
|
61
|
+
scripts: {
|
|
62
|
+
build: "plugboy build",
|
|
63
|
+
clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
64
|
+
eslint: "eslint . --ext ts,tsx,js,vue,html,yaml",
|
|
65
|
+
"eslint:fix": "eslint . --ext ts,tsx,js,vue,html,yaml --fix",
|
|
66
|
+
format: "pnpm run eslint:fix",
|
|
67
|
+
lint: "pnpm run eslint",
|
|
68
|
+
stub: "plugboy stub",
|
|
69
|
+
test: "vitest run",
|
|
70
|
+
typecheck: "tsc --noEmit"
|
|
71
|
+
},
|
|
72
|
+
dependencies: {
|
|
73
|
+
"@fastkit/ev": "workspace:*",
|
|
74
|
+
"@fastkit/helpers": "workspace:*",
|
|
75
|
+
"@fastkit/icon-font": "workspace:*",
|
|
76
|
+
"@fastkit/node-util": "workspace:*",
|
|
77
|
+
"@fastkit/tiny-logger": "workspace:*",
|
|
78
|
+
cac: "^6.7.14",
|
|
79
|
+
chokidar: "^3.5.3",
|
|
80
|
+
"fs-extra": "^11.1.1",
|
|
81
|
+
webfont: "^11.2.26"
|
|
82
|
+
},
|
|
83
|
+
buildOptions: {
|
|
84
|
+
name: "IconFont"
|
|
85
|
+
},
|
|
86
|
+
_docs: {
|
|
87
|
+
scope: "",
|
|
88
|
+
feature: "icon",
|
|
89
|
+
description: {
|
|
90
|
+
en: "A tool to generate icon web fonts and their definitions Type-safe for your application.",
|
|
91
|
+
ja: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u305F\u3081\u306B\u30A2\u30A4\u30B3\u30F3Web\u30D5\u30A9\u30F3\u30C8\u3068\u305D\u306E\u5B9A\u7FA9\u3092Type\u30BB\u30FC\u30D5\u306B\u751F\u6210\u3059\u308B\u30C4\u30FC\u30EB\u3002"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/cli.ts
|
|
97
|
+
async function cli() {
|
|
98
|
+
const cli2 = cac("icon-font");
|
|
99
|
+
cli2.option("-d, --dest <string>", "Destination for generated fonts.", {
|
|
100
|
+
default: __plugboy_path.join(process.cwd(), `${DEFAULT_DEST_DIRNAME}`)
|
|
101
|
+
}).command(
|
|
102
|
+
"[config file path]",
|
|
103
|
+
`
|
|
104
|
+
Path of the configuration file. (default: [your package directory]${__plugboy_path.sep}${DEFAULT_CONFIG_FILENAME})
|
|
105
|
+
You must export default <IconFontConfig>.
|
|
106
|
+
|
|
107
|
+
e.g.
|
|
108
|
+
\`\`\`
|
|
109
|
+
import { ceateIconFontConfig } from '@fastkit/icon-font-gen';
|
|
110
|
+
|
|
111
|
+
export default ceateIconFontConfig({ ... });
|
|
112
|
+
\`\`\`
|
|
113
|
+
`.trim()
|
|
114
|
+
).action(
|
|
115
|
+
async (configPath, options) => {
|
|
116
|
+
if (!configPath) {
|
|
117
|
+
const pkgDir = await findPackageDir();
|
|
118
|
+
if (!pkgDir) {
|
|
119
|
+
throw new IconFontGenError("missing package directory.");
|
|
120
|
+
}
|
|
121
|
+
configPath = __plugboy_path.join(pkgDir, DEFAULT_CONFIG_FILENAME);
|
|
122
|
+
}
|
|
123
|
+
const dest = __plugboy_path.resolve(options.dest);
|
|
124
|
+
const mod = await esbuildRequire(
|
|
125
|
+
configPath
|
|
126
|
+
);
|
|
127
|
+
const config = mod.exports.default;
|
|
128
|
+
await generate({
|
|
129
|
+
...config,
|
|
130
|
+
dest
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
cli2.help();
|
|
135
|
+
cli2.version(package_default.version);
|
|
136
|
+
cli2.parse();
|
|
137
|
+
}
|
|
138
|
+
cli();
|
|
139
|
+
|
|
140
|
+
export { cli };
|
|
141
|
+
//# sourceMappingURL=out.js.map
|
|
142
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../package.json"],"names":["cli"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW;AACpB,OAAO,UAAU;AAOjB,SAAS,gBAAgB,sBAAsB;;;ACR/C;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,UAAY;AAAA,IACV;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAY;AAAA,EACZ,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,SAAW;AAAA,EACX,QAAU;AAAA,EACV,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,kBAAkB;AAAA,IAClB,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,QACR,SAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,OAAS;AAAA,MACT,QAAU;AAAA,QACR,SAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA,OAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,OAAS;AAAA,EACT,eAAiB;AAAA,IACf,KAAK;AAAA,MACH,KAAK;AAAA,QACH;AAAA,MACF;AAAA,MACA,KAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,QAAU;AAAA,IACV,cAAc;AAAA,IACd,QAAU;AAAA,IACV,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,MAAQ;AAAA,IACR,WAAa;AAAA,EACf;AAAA,EACA,cAAgB;AAAA,IACd,eAAe;AA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DIRNAME,\n DEFAULT_CONFIG_FILENAME,\n IconFontConfig,\n} from './schemes';\nimport { generate } from './generator';\nimport { findPackageDir, esbuildRequire } from '@fastkit/node-util';\nimport { IconFontGenError } from './logger';\nimport pkg from '../package.json';\n\nexport async function cli() {\n const cli = cac('icon-font');\n\n cli\n .option('-d, --dest <string>', 'Destination for generated fonts.', {\n default: path.join(process.cwd(), `${DEFAULT_DEST_DIRNAME}`),\n })\n .command(\n '[config file path]',\n `\nPath of the configuration file. (default: [your package directory]${path.sep}${DEFAULT_CONFIG_FILENAME})\n You must export default <IconFontConfig>.\n\n e.g.\n \\`\\`\\`\n import { ceateIconFontConfig } from '@fastkit/icon-font-gen';\n\n export default ceateIconFontConfig({ ... });\n \\`\\`\\`\n `.trim(),\n )\n .action(\n async (configPath: string | undefined, options: { dest: string }) => {\n if (!configPath) {\n const pkgDir = await findPackageDir();\n if (!pkgDir) {\n throw new IconFontGenError('missing package directory.');\n }\n configPath = path.join(pkgDir, DEFAULT_CONFIG_FILENAME);\n }\n\n const dest = path.resolve(options.dest);\n const mod = await esbuildRequire<{ default: IconFontConfig }>(\n configPath,\n );\n const config = mod.exports.default;\n\n await generate({\n ...config,\n dest,\n });\n },\n );\n\n cli.help();\n\n cli.version(pkg.version);\n\n cli.parse();\n}\n\ncli();\n","{\n \"name\": \"@fastkit/icon-font-gen\",\n \"version\": \"0.12.8\",\n \"description\": \"A tool to generate icon web fonts and their definitions Type-safe for your application.\",\n \"keywords\": [\n \"fastkit\",\n \"icon\"\n ],\n \"homepage\": \"https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/dadajam4/fastkit/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/dadajam4/fastkit.git\"\n },\n \"license\": \"MIT\",\n \"author\": \"dadajam4\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"types\": \"./dist/icon-font-gen.d.ts\",\n \"import\": {\n \"default\": \"./dist/icon-font-gen.mjs\"\n }\n },\n \"./cli\": {\n \"types\": \"./dist/cli.d.ts\",\n \"import\": {\n \"default\": \"./dist/cli.mjs\"\n }\n },\n \"./*\": \"./dist/*\"\n },\n \"main\": \"./dist/icon-font-gen.mjs\",\n \"types\": \"./dist/icon-font-gen.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \".\": [\n \"./dist/icon-font-gen.d.ts\"\n ],\n \"cli\": [\n \"./dist/cli.d.ts\"\n ]\n }\n },\n \"bin\": {\n \"icon-font\": \"./bin/cli.mjs\"\n },\n \"files\": [\n \"./cli.mjs\",\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"plugboy build\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist\",\n \"eslint\": \"eslint . --ext ts,tsx,js,vue,html,yaml\",\n \"eslint:fix\": \"eslint . --ext ts,tsx,js,vue,html,yaml --fix\",\n \"format\": \"pnpm run eslint:fix\",\n \"lint\": \"pnpm run eslint\",\n \"stub\": \"plugboy stub\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@fastkit/ev\": \"workspace:*\",\n \"@fastkit/helpers\": \"workspace:*\",\n \"@fastkit/icon-font\": \"workspace:*\",\n \"@fastkit/node-util\": \"workspace:*\",\n \"@fastkit/tiny-logger\": \"workspace:*\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.5.3\",\n \"fs-extra\": \"^11.1.1\",\n \"webfont\": \"^11.2.26\"\n },\n \"buildOptions\": {\n \"name\": \"IconFont\"\n },\n \"_docs\": {\n \"scope\": \"\",\n \"feature\": \"icon\",\n \"description\": {\n \"en\": \"A tool to generate icon web fonts and their definitions Type-safe for your application.\",\n \"ja\": \"アプリケーションのためにアイコンWebフォントとその定義をTypeセーフに生成するツール。\"\n }\n }\n}"]}
|
package/dist/icon-font-gen.d.ts
CHANGED
|
@@ -1,106 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { UnPromisify } from '@fastkit/helpers';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
dest
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
readonly
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
build:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
centerHorizontally?: boolean;
|
|
88
|
-
normalize?: boolean;
|
|
89
|
-
fontHeight?: number;
|
|
90
|
-
round?: number;
|
|
91
|
-
descent?: number;
|
|
92
|
-
disablePrefix?: boolean;
|
|
93
|
-
absolutePath?: boolean;
|
|
94
|
-
addHashInFontUrl?: boolean;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export declare function mergeDefaults(entry: IconFontEntry): IconFontEntry;
|
|
98
|
-
|
|
99
|
-
export declare interface RawIconFontEntry extends Omit<IconFontEntry, 'name' | 'fontName' | 'prefix' | 'dest'> {
|
|
100
|
-
name?: string;
|
|
101
|
-
fontName?: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export declare function resolveRawIconFontEntry(rootDir: string, rawEntry: RawIconFontEntry): Promise<IconFontEntry>;
|
|
105
|
-
|
|
106
|
-
export { }
|
|
1
|
+
import { OptionsBase } from 'webfont/dist/src/types/OptionsBase';
|
|
2
|
+
import { EV } from '@fastkit/ev';
|
|
3
|
+
import { UnPromisify } from '@fastkit/helpers';
|
|
4
|
+
import webfont from 'webfont';
|
|
5
|
+
|
|
6
|
+
type IconFontFormat = NonNullable<OptionsBase['formats']>[number];
|
|
7
|
+
declare const ICON_FONT_FORMATS: IconFontFormat[];
|
|
8
|
+
declare const ICON_FONT_FORMAT_MAP: Record<IconFontFormat, string>;
|
|
9
|
+
interface IconFontSettings {
|
|
10
|
+
fixedWidth?: boolean;
|
|
11
|
+
centerHorizontally?: boolean;
|
|
12
|
+
normalize?: boolean;
|
|
13
|
+
fontHeight?: number;
|
|
14
|
+
round?: number;
|
|
15
|
+
descent?: number;
|
|
16
|
+
disablePrefix?: boolean;
|
|
17
|
+
absolutePath?: boolean;
|
|
18
|
+
addHashInFontUrl?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface IconFontEntry extends IconFontSettings {
|
|
21
|
+
name: string;
|
|
22
|
+
fontName: string;
|
|
23
|
+
formats?: IconFontFormat[];
|
|
24
|
+
startUnicode?: number;
|
|
25
|
+
prefix: string;
|
|
26
|
+
src: string;
|
|
27
|
+
dest: string;
|
|
28
|
+
}
|
|
29
|
+
interface RawIconFontEntry extends Omit<IconFontEntry, 'name' | 'fontName' | 'prefix' | 'dest'> {
|
|
30
|
+
name?: string;
|
|
31
|
+
fontName?: string;
|
|
32
|
+
}
|
|
33
|
+
interface IconFontOptions {
|
|
34
|
+
entries: RawIconFontEntry[];
|
|
35
|
+
dest: string;
|
|
36
|
+
}
|
|
37
|
+
declare function resolveRawIconFontEntry(rootDir: string, rawEntry: RawIconFontEntry): Promise<IconFontEntry>;
|
|
38
|
+
declare const DEFAULT_CONFIG_FILENAME = "icon-font.config";
|
|
39
|
+
declare const DEFAULT_DEST_DIRNAME = ".icon-font";
|
|
40
|
+
interface IconFontConfig extends Omit<IconFontOptions, 'dest'> {
|
|
41
|
+
dest?: string;
|
|
42
|
+
}
|
|
43
|
+
declare function ceateIconFontConfig(options: IconFontConfig): IconFontConfig;
|
|
44
|
+
|
|
45
|
+
type IconFontEntryResult = {
|
|
46
|
+
entry: IconFontEntry;
|
|
47
|
+
result?: UnPromisify<ReturnType<typeof webfont>>;
|
|
48
|
+
};
|
|
49
|
+
declare const DEFAULT_OPTIONS: Partial<IconFontEntry>;
|
|
50
|
+
declare function mergeDefaults(entry: IconFontEntry): IconFontEntry;
|
|
51
|
+
declare function generateEntry(entry: IconFontEntry): Promise<IconFontEntryResult>;
|
|
52
|
+
declare function generateIndex(dest: string, entries: IconFontEntry[]): Promise<void>;
|
|
53
|
+
declare function generate(opts: IconFontOptions): Promise<void>;
|
|
54
|
+
declare class IconFontRunnerItem extends EV<{
|
|
55
|
+
build: IconFontEntryResult;
|
|
56
|
+
}> {
|
|
57
|
+
readonly entry: RawIconFontEntry;
|
|
58
|
+
readonly ctx: IconFontRunner;
|
|
59
|
+
private _resolveEntryPromise?;
|
|
60
|
+
private _watcher;
|
|
61
|
+
watchMode: boolean;
|
|
62
|
+
constructor(ctx: IconFontRunner, entry: RawIconFontEntry, watch?: boolean);
|
|
63
|
+
run(): Promise<{
|
|
64
|
+
entry: IconFontEntry;
|
|
65
|
+
}>;
|
|
66
|
+
resolveEntry(): Promise<IconFontEntry>;
|
|
67
|
+
build(): Promise<{
|
|
68
|
+
entry: IconFontEntry;
|
|
69
|
+
}>;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
}
|
|
72
|
+
declare class IconFontRunner extends EV<{
|
|
73
|
+
build: {
|
|
74
|
+
item: IconFontRunnerItem;
|
|
75
|
+
result: IconFontEntryResult;
|
|
76
|
+
};
|
|
77
|
+
}> {
|
|
78
|
+
readonly items: IconFontRunnerItem[];
|
|
79
|
+
readonly dest: string;
|
|
80
|
+
constructor(opts: IconFontOptions, watch?: boolean);
|
|
81
|
+
buildIndex(): Promise<void>;
|
|
82
|
+
run(): Promise<void>;
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { DEFAULT_CONFIG_FILENAME, DEFAULT_DEST_DIRNAME, DEFAULT_OPTIONS, ICON_FONT_FORMATS, ICON_FONT_FORMAT_MAP, IconFontConfig, IconFontEntry, IconFontEntryResult, IconFontFormat, IconFontOptions, IconFontRunner, IconFontRunnerItem, IconFontSettings, RawIconFontEntry, ceateIconFontConfig, generate, generateEntry, generateIndex, mergeDefaults, resolveRawIconFontEntry };
|
package/dist/icon-font-gen.mjs
CHANGED
|
@@ -1,368 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import chokidar from 'chokidar';
|
|
5
|
-
import { EV } from '@fastkit/ev';
|
|
6
|
-
import { TinyLogger, createTinyError } from '@fastkit/tiny-logger';
|
|
7
|
-
import { cac } from 'cac';
|
|
8
|
-
|
|
9
|
-
const ICON_FONT_FORMATS = [
|
|
10
|
-
'eot',
|
|
11
|
-
'woff',
|
|
12
|
-
'woff2',
|
|
13
|
-
'svg',
|
|
14
|
-
'ttf',
|
|
15
|
-
];
|
|
16
|
-
const ICON_FONT_FORMAT_MAP = {
|
|
17
|
-
eot: 'embedded-opentype',
|
|
18
|
-
woff2: 'woff2',
|
|
19
|
-
woff: 'woff',
|
|
20
|
-
ttf: 'truetype',
|
|
21
|
-
svg: 'svg',
|
|
22
|
-
};
|
|
23
|
-
async function resolveRawIconFontEntry(rootDir, rawEntry) {
|
|
24
|
-
const entry = {
|
|
25
|
-
...rawEntry,
|
|
26
|
-
};
|
|
27
|
-
// mdi support
|
|
28
|
-
if (entry.src === '@mdi') {
|
|
29
|
-
const installedDir = await findOrInstallMDI();
|
|
30
|
-
entry.src = path.join(installedDir, 'svg');
|
|
31
|
-
if (entry.fontHeight == null) {
|
|
32
|
-
entry.fontHeight = 512;
|
|
33
|
-
}
|
|
34
|
-
if (entry.descent == null) {
|
|
35
|
-
entry.descent = 64;
|
|
36
|
-
}
|
|
37
|
-
if (entry.name == null) {
|
|
38
|
-
entry.name = 'mdi';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const name = entry.name || path.basename(entry.src);
|
|
42
|
-
const fontName = entry.fontName || `${name}-icon`;
|
|
43
|
-
const dest = path.join(rootDir, name);
|
|
44
|
-
const prefix = entry.disablePrefix ? '' : `${name}-`;
|
|
45
|
-
return {
|
|
46
|
-
...entry,
|
|
47
|
-
name,
|
|
48
|
-
fontName,
|
|
49
|
-
prefix,
|
|
50
|
-
dest,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function findOrInstallMDI() {
|
|
54
|
-
return installPackage('@mdi/svg', { dev: true });
|
|
55
|
-
}
|
|
56
|
-
const DEFAULT_CONFIG_FILENAME = 'icon-font.config';
|
|
57
|
-
const DEFAULT_DEST_DIRNAME = '.icon-font';
|
|
58
|
-
function ceateIconFontConfig(options) {
|
|
59
|
-
return options;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const name = 'icon-font-gen';
|
|
63
|
-
const logger = new TinyLogger(name);
|
|
64
|
-
const IconFontGenError = createTinyError(name);
|
|
65
|
-
|
|
66
|
-
const DEFAULT_OPTIONS = {
|
|
67
|
-
formats: ['woff2'],
|
|
68
|
-
fixedWidth: true,
|
|
69
|
-
normalize: true,
|
|
70
|
-
};
|
|
71
|
-
const BANNER = `
|
|
72
|
-
/**
|
|
73
|
-
* This is auto generated file.
|
|
74
|
-
* Do not edit !!!
|
|
75
|
-
*
|
|
76
|
-
* @see: https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen
|
|
77
|
-
*/
|
|
78
|
-
`.trim();
|
|
79
|
-
function mergeDefaults(entry) {
|
|
80
|
-
return {
|
|
81
|
-
...DEFAULT_OPTIONS,
|
|
82
|
-
...entry,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
async function generateTS(entry, ids) {
|
|
86
|
-
const code = `
|
|
87
|
-
/* eslint-disable */
|
|
88
|
-
// @ts-nocheck
|
|
89
|
-
${BANNER}
|
|
90
|
-
import type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
91
|
-
import { registerIconNames } from '@fastkit/icon-font';
|
|
92
|
-
declare module "@fastkit/icon-font" {
|
|
93
|
-
export interface IconNameMap {
|
|
94
|
-
${ids.map((id) => ` '${id}': true,`).join('\n')}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export const ICON_NAMES = registerIconNames([
|
|
98
|
-
${ids.map((id) => `'${id}'`).join(',\n ')}
|
|
99
|
-
]);
|
|
100
|
-
export type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
101
|
-
`.trim();
|
|
102
|
-
const fileName = `${entry.name || 'icons'}.ts`;
|
|
103
|
-
const dest = path.resolve(entry.dest, fileName);
|
|
104
|
-
await fs.writeFile(dest, code);
|
|
105
|
-
return {
|
|
106
|
-
fileName,
|
|
107
|
-
dest,
|
|
108
|
-
code,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
async function generateEntry(entry) {
|
|
112
|
-
const options = mergeDefaults(entry);
|
|
113
|
-
// @TODO support empty prefix
|
|
114
|
-
// const namePrefix = options.name;
|
|
115
|
-
const cssPrefix = `icon-${options.prefix}`;
|
|
116
|
-
const hash = new HashComparator(options.src, options.dest);
|
|
117
|
-
const srcHash = await hash.hasChanged();
|
|
118
|
-
if (!srcHash) {
|
|
119
|
-
logger.info(`Has not chaged files. Skip process. >>> ${options.src}`);
|
|
120
|
-
return { entry };
|
|
121
|
-
}
|
|
122
|
-
await fs.ensureDir(options.dest);
|
|
123
|
-
const { webfont } = await import('webfont');
|
|
124
|
-
// const { startUnicode = 0xea01 } = options;
|
|
125
|
-
const { startUnicode = 0xba01 } = options;
|
|
126
|
-
let i = startUnicode;
|
|
127
|
-
const result = await webfont({
|
|
128
|
-
files: options.src,
|
|
129
|
-
fontName: options.fontName,
|
|
130
|
-
formats: options.formats,
|
|
131
|
-
fixedWidth: options.fixedWidth,
|
|
132
|
-
centerHorizontally: options.centerHorizontally,
|
|
133
|
-
normalize: options.normalize,
|
|
134
|
-
fontHeight: options.fontHeight,
|
|
135
|
-
round: options.round,
|
|
136
|
-
descent: options.descent,
|
|
137
|
-
addHashInFontUrl: options.addHashInFontUrl,
|
|
138
|
-
glyphTransformFn: (obj) => {
|
|
139
|
-
const char = String.fromCodePoint(i);
|
|
140
|
-
obj.unicode = [char];
|
|
141
|
-
i++;
|
|
142
|
-
return obj;
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
const buildedFormats = [];
|
|
146
|
-
ICON_FONT_FORMATS.forEach((format) => {
|
|
147
|
-
const code = result[format];
|
|
148
|
-
if (code) {
|
|
149
|
-
buildedFormats.push({ format, code });
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
await Promise.all(buildedFormats.map(({ format, code }) => {
|
|
153
|
-
return fs.writeFile(path.join(options.dest, `${options.name}.${format}`), code);
|
|
154
|
-
}));
|
|
155
|
-
const glyphs = [];
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
157
|
-
result.glyphsData.forEach(({ metadata }) => {
|
|
158
|
-
if (!metadata)
|
|
159
|
-
return;
|
|
160
|
-
const { name, unicode } = metadata;
|
|
161
|
-
if (!unicode) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const code = unicode[0].charCodeAt(0).toString(16);
|
|
165
|
-
glyphs.push({ name, code });
|
|
166
|
-
});
|
|
167
|
-
const urlPath = options.absolutePath ? options.dest : '.';
|
|
168
|
-
const hashSuffix = options.addHashInFontUrl ? `?${Date.now()}` : '';
|
|
169
|
-
const src = buildedFormats
|
|
170
|
-
.map(({ format }) => {
|
|
171
|
-
return `url("${urlPath}/${options.name}.${format}${hashSuffix}") format("${ICON_FONT_FORMAT_MAP[format]}")`;
|
|
172
|
-
})
|
|
173
|
-
.join(',');
|
|
174
|
-
const cssCode = `/* stylelint-disable */
|
|
175
|
-
@font-face {
|
|
176
|
-
font-family: "${options.fontName}";
|
|
177
|
-
font-display: block;
|
|
178
|
-
font-style: normal;
|
|
179
|
-
font-weight: 400;
|
|
180
|
-
src: ${src};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
i[class^="${cssPrefix}"]:before, i[class*=" ${cssPrefix}"]:before {
|
|
184
|
-
font-family: ${options.fontName} !important;
|
|
185
|
-
font-style: normal;
|
|
186
|
-
font-weight: normal !important;
|
|
187
|
-
font-variant: normal;
|
|
188
|
-
text-transform: none;
|
|
189
|
-
text-rendering: auto;
|
|
190
|
-
line-height: 1;
|
|
191
|
-
-webkit-font-smoothing: antialiased;
|
|
192
|
-
-moz-osx-font-smoothing: grayscale;
|
|
193
|
-
}
|
|
194
|
-
${glyphs
|
|
195
|
-
.map(({ name, code }) => {
|
|
196
|
-
return `
|
|
197
|
-
.${cssPrefix}${name}:before { content: "\\${code}"; }
|
|
198
|
-
`;
|
|
199
|
-
})
|
|
200
|
-
.join('\n')}
|
|
201
|
-
`;
|
|
202
|
-
await fs.writeFile(path.join(options.dest, `${options.name}.css`), cssCode);
|
|
203
|
-
// const prefix = options.prefix ? `${options.prefix}-` : '';
|
|
204
|
-
const ids = glyphs.map(({ name }) => `${options.prefix}${name}`);
|
|
205
|
-
await generateTS(options, ids);
|
|
206
|
-
await hash.commit(srcHash);
|
|
207
|
-
return {
|
|
208
|
-
entry,
|
|
209
|
-
result,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
async function generateIndex(dest, entries) {
|
|
213
|
-
const names = entries.map(({ name }) => name);
|
|
214
|
-
const tsCode = `
|
|
215
|
-
/* eslint-disable */
|
|
216
|
-
// @ts-nocheck
|
|
217
|
-
import './index.css';
|
|
218
|
-
${BANNER}
|
|
219
|
-
${names
|
|
220
|
-
.map((name, index) =>
|
|
221
|
-
// `import { IconName as IconName_${index}, IconNameMap as IconNameMap_${index} } from './${name}/${name}';`,
|
|
222
|
-
`import './${name}/${name}';`)
|
|
223
|
-
.join('\n')}
|
|
224
|
-
export type { IconName } from '@fastkit/icon-font';
|
|
225
|
-
export { ICON_NAMES } from '@fastkit/icon-font';
|
|
226
|
-
`.trim();
|
|
227
|
-
const tsDest = path.join(dest, 'index.ts');
|
|
228
|
-
await fs.writeFile(tsDest, tsCode);
|
|
229
|
-
const cssCode = `
|
|
230
|
-
/* stylelint-disable */
|
|
231
|
-
${BANNER}
|
|
232
|
-
${names.map((name) => `@import './${name}/${name}.css';`).join('\n')}
|
|
233
|
-
`.trim();
|
|
234
|
-
const cssDest = path.join(dest, 'index.css');
|
|
235
|
-
await fs.writeFile(cssDest, cssCode);
|
|
236
|
-
}
|
|
237
|
-
async function generate(opts) {
|
|
238
|
-
await fs.emptyDir(opts.dest);
|
|
239
|
-
const results = await Promise.all(opts.entries.map((entry) => resolveRawIconFontEntry(opts.dest, entry).then((entry) => generateEntry(entry))));
|
|
240
|
-
const entries = results.map(({ entry }) => entry);
|
|
241
|
-
await generateIndex(opts.dest, entries);
|
|
242
|
-
}
|
|
243
|
-
class IconFontRunnerItem extends EV {
|
|
244
|
-
entry;
|
|
245
|
-
ctx;
|
|
246
|
-
_resolveEntryPromise;
|
|
247
|
-
_watcher = null;
|
|
248
|
-
watchMode;
|
|
249
|
-
// get name() {
|
|
250
|
-
// return this.entry.name;
|
|
251
|
-
// }
|
|
252
|
-
constructor(ctx, entry, watch = false) {
|
|
253
|
-
super();
|
|
254
|
-
this.ctx = ctx;
|
|
255
|
-
this.entry = entry;
|
|
256
|
-
this.watchMode = watch;
|
|
257
|
-
this.build = this.build.bind(this);
|
|
258
|
-
}
|
|
259
|
-
async run() {
|
|
260
|
-
const result = await this.build();
|
|
261
|
-
if (this.watchMode && !this._watcher) {
|
|
262
|
-
const watchDir = path.resolve(this.entry.src);
|
|
263
|
-
this._watcher = chokidar.watch(watchDir, { ignoreInitial: true });
|
|
264
|
-
this._watcher.on('all', this.build);
|
|
265
|
-
}
|
|
266
|
-
return result;
|
|
267
|
-
}
|
|
268
|
-
resolveEntry() {
|
|
269
|
-
if (!this._resolveEntryPromise) {
|
|
270
|
-
this._resolveEntryPromise = resolveRawIconFontEntry(this.ctx.dest, this.entry);
|
|
271
|
-
}
|
|
272
|
-
return this._resolveEntryPromise;
|
|
273
|
-
}
|
|
274
|
-
async build() {
|
|
275
|
-
const entry = await this.resolveEntry();
|
|
276
|
-
const result = await generateEntry(entry);
|
|
277
|
-
this.emit('build', result);
|
|
278
|
-
return { entry };
|
|
279
|
-
}
|
|
280
|
-
destroy() {
|
|
281
|
-
if (this._watcher) {
|
|
282
|
-
this._watcher.close();
|
|
283
|
-
this._watcher = null;
|
|
284
|
-
}
|
|
285
|
-
this.offAll();
|
|
286
|
-
if (this.ctx) {
|
|
287
|
-
delete this.ctx;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
class IconFontRunner extends EV {
|
|
292
|
-
items = [];
|
|
293
|
-
dest;
|
|
294
|
-
// private _opts: IconFontOptions;
|
|
295
|
-
// private entries: IconFontEntry[] = [];
|
|
296
|
-
constructor(opts, watch) {
|
|
297
|
-
super();
|
|
298
|
-
// this._opts = opts;
|
|
299
|
-
this.dest = opts.dest;
|
|
300
|
-
// this.entries = opts.entries.map((entry) =>
|
|
301
|
-
// resolveRawIconFontEntry(this.outputDir, entry),
|
|
302
|
-
// );
|
|
303
|
-
opts.entries.forEach((entry) => {
|
|
304
|
-
const item = new IconFontRunnerItem(this, entry, watch);
|
|
305
|
-
item.on('build', (result) => {
|
|
306
|
-
this.emit('build', { item, result });
|
|
307
|
-
});
|
|
308
|
-
this.items.push(item);
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
async buildIndex() {
|
|
312
|
-
const entries = await Promise.all(this.items.map((item) => item.resolveEntry()));
|
|
313
|
-
return generateIndex(this.dest, entries);
|
|
314
|
-
}
|
|
315
|
-
async run() {
|
|
316
|
-
await fs.ensureDir(this.dest);
|
|
317
|
-
await Promise.all([
|
|
318
|
-
this.buildIndex(),
|
|
319
|
-
Promise.all(this.items.map((item) => item.run())),
|
|
320
|
-
]);
|
|
321
|
-
}
|
|
322
|
-
destroy() {
|
|
323
|
-
this.items.forEach((item) => item.destroy());
|
|
324
|
-
this.items.length = 0;
|
|
325
|
-
this.offAll();
|
|
326
|
-
delete this._opts;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
async function cli() {
|
|
331
|
-
const cli = cac('icon-font');
|
|
332
|
-
cli
|
|
333
|
-
.option('-d, --dest <string>', 'Destination for generated fonts.', {
|
|
334
|
-
default: path.join(process.cwd(), `${DEFAULT_DEST_DIRNAME}`),
|
|
335
|
-
})
|
|
336
|
-
.command('[config file path]', `
|
|
337
|
-
Path of the configuration file. (default: [your package directory]${path.sep}${DEFAULT_CONFIG_FILENAME})
|
|
338
|
-
You must export default <IconFontConfig>.
|
|
339
|
-
|
|
340
|
-
e.g.
|
|
341
|
-
\`\`\`
|
|
342
|
-
import { ceateIconFontConfig } from '@fastkit/icon-font-gen';
|
|
343
|
-
|
|
344
|
-
export default ceateIconFontConfig({ ... });
|
|
345
|
-
\`\`\`
|
|
346
|
-
`.trim())
|
|
347
|
-
.action(async (configPath, options) => {
|
|
348
|
-
if (!configPath) {
|
|
349
|
-
const pkgDir = await findPackageDir();
|
|
350
|
-
if (!pkgDir) {
|
|
351
|
-
throw new IconFontGenError('missing package directory.');
|
|
352
|
-
}
|
|
353
|
-
configPath = path.join(pkgDir, DEFAULT_CONFIG_FILENAME);
|
|
354
|
-
}
|
|
355
|
-
const dest = path.resolve(options.dest);
|
|
356
|
-
const mod = await esbuildRequire(configPath);
|
|
357
|
-
const config = mod.exports.default;
|
|
358
|
-
await generate({
|
|
359
|
-
...config,
|
|
360
|
-
dest,
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
cli.help();
|
|
364
|
-
cli.version("0.12.8");
|
|
365
|
-
cli.parse();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
export { DEFAULT_CONFIG_FILENAME, DEFAULT_DEST_DIRNAME, DEFAULT_OPTIONS, ICON_FONT_FORMATS, ICON_FONT_FORMAT_MAP, IconFontRunner, IconFontRunnerItem, ceateIconFontConfig, cli, generate, generateEntry, generateIndex, mergeDefaults, resolveRawIconFontEntry };
|
|
1
|
+
export { DEFAULT_CONFIG_FILENAME, DEFAULT_DEST_DIRNAME, DEFAULT_OPTIONS, ICON_FONT_FORMATS, ICON_FONT_FORMAT_MAP, IconFontRunner, IconFontRunnerItem, ceateIconFontConfig, generate, generateEntry, generateIndex, mergeDefaults, resolveRawIconFontEntry } from './chunk-USVWZGQ7.mjs';
|
|
2
|
+
//# sourceMappingURL=out.js.map
|
|
3
|
+
//# sourceMappingURL=icon-font-gen.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/icon-font-gen",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9",
|
|
4
4
|
"description": "A tool to generate icon web fonts and their definitions Type-safe for your application.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fastkit",
|
|
7
|
+
"icon"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dadajam4/fastkit/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/dadajam4/fastkit.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "dadajam4",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/icon-font-gen.d.ts",
|
|
24
|
+
"import": {
|
|
25
|
+
"default": "./dist/icon-font-gen.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"./cli": {
|
|
29
|
+
"types": "./dist/cli.d.ts",
|
|
30
|
+
"import": {
|
|
31
|
+
"default": "./dist/cli.mjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./*": "./dist/*"
|
|
35
|
+
},
|
|
36
|
+
"main": "./dist/icon-font-gen.mjs",
|
|
37
|
+
"types": "./dist/icon-font-gen.d.ts",
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"*": {
|
|
40
|
+
".": [
|
|
41
|
+
"./dist/icon-font-gen.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"cli": [
|
|
44
|
+
"./dist/cli.d.ts"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"bin": {
|
|
49
|
+
"icon-font": "./bin/cli.mjs"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"./cli.mjs",
|
|
53
|
+
"dist"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"cac": "^6.7.14",
|
|
57
|
+
"chokidar": "^3.5.3",
|
|
58
|
+
"fs-extra": "^11.1.1",
|
|
59
|
+
"webfont": "^11.2.26",
|
|
60
|
+
"@fastkit/ev": "0.12.9",
|
|
61
|
+
"@fastkit/icon-font": "0.12.9",
|
|
62
|
+
"@fastkit/node-util": "0.12.9",
|
|
63
|
+
"@fastkit/tiny-logger": "0.12.9",
|
|
64
|
+
"@fastkit/helpers": "0.12.9"
|
|
65
|
+
},
|
|
5
66
|
"buildOptions": {
|
|
6
67
|
"name": "IconFont"
|
|
7
68
|
},
|
|
@@ -13,42 +74,15 @@
|
|
|
13
74
|
"ja": "アプリケーションのためにアイコンWebフォントとその定義をTypeセーフに生成するツール。"
|
|
14
75
|
}
|
|
15
76
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"lib",
|
|
27
|
-
"dist"
|
|
28
|
-
],
|
|
29
|
-
"types": "dist/icon-font-gen.d.ts",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/dadajam4/fastkit.git"
|
|
33
|
-
},
|
|
34
|
-
"keywords": [
|
|
35
|
-
"fastkit",
|
|
36
|
-
"icon"
|
|
37
|
-
],
|
|
38
|
-
"author": "dadajam4",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/dadajam4/fastkit/issues"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen#readme",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@fastkit/ev": "0.12.8",
|
|
46
|
-
"@fastkit/icon-font": "0.12.8",
|
|
47
|
-
"@fastkit/node-util": "0.12.8",
|
|
48
|
-
"@fastkit/tiny-logger": "0.12.8",
|
|
49
|
-
"cac": "^6.7.11",
|
|
50
|
-
"chokidar": "^3.5.0",
|
|
51
|
-
"fs-extra": "^11.1.0",
|
|
52
|
-
"webfont": "^11.2.26"
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "plugboy build",
|
|
79
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
80
|
+
"eslint": "eslint . --ext ts,tsx,js,vue,html,yaml",
|
|
81
|
+
"eslint:fix": "eslint . --ext ts,tsx,js,vue,html,yaml --fix",
|
|
82
|
+
"format": "pnpm run eslint:fix",
|
|
83
|
+
"lint": "pnpm run eslint",
|
|
84
|
+
"stub": "plugboy stub",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"typecheck": "tsc --noEmit"
|
|
53
87
|
}
|
|
54
|
-
}
|
|
88
|
+
}
|
package/lib/cli.mjs
DELETED