@fastkit/icon-font-gen 0.6.12 → 0.6.16
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/icon-font-gen.cjs.js +34 -19
- package/dist/icon-font-gen.cjs.prod.js +34 -19
- package/dist/icon-font-gen.d.ts +1 -0
- package/package.json +5 -5
|
@@ -59,6 +59,9 @@ async function resolveRawIconFontEntry(rootDir, rawEntry) {
|
|
|
59
59
|
if (entry.name == null) {
|
|
60
60
|
entry.name = 'mdi';
|
|
61
61
|
}
|
|
62
|
+
if (entry.startUnicode == null) {
|
|
63
|
+
entry.startUnicode = 0xea0;
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
const name = entry.name || path__default.basename(entry.src);
|
|
64
67
|
const fontName = entry.fontName || `${name}-icon`;
|
|
@@ -109,7 +112,8 @@ async function generateTS(entry, ids) {
|
|
|
109
112
|
/* eslint-disable */
|
|
110
113
|
// @ts-nocheck
|
|
111
114
|
${BANNER}
|
|
112
|
-
import { IconName, IconNameMap
|
|
115
|
+
import type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
116
|
+
import { registerIconNames } from '@fastkit/icon-font';
|
|
113
117
|
declare module "@fastkit/icon-font" {
|
|
114
118
|
export interface IconNameMap {
|
|
115
119
|
${ids.map((id) => ` '${id}': true,`).join('\n')}
|
|
@@ -118,7 +122,7 @@ ${ids.map((id) => ` '${id}': true,`).join('\n')}
|
|
|
118
122
|
export const ICON_NAMES = registerIconNames([
|
|
119
123
|
${ids.map((id) => `'${id}'`).join(',\n ')}
|
|
120
124
|
]);
|
|
121
|
-
export { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
125
|
+
export type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
122
126
|
`.trim();
|
|
123
127
|
const fileName = `${entry.name || 'icons'}.ts`;
|
|
124
128
|
const dest = path__default.resolve(entry.dest, fileName);
|
|
@@ -142,6 +146,8 @@ async function generateEntry(entry) {
|
|
|
142
146
|
}
|
|
143
147
|
await fs__default.ensureDir(options.dest);
|
|
144
148
|
const webfont = await (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('webfont')); })).default;
|
|
149
|
+
const { startUnicode = 0xea01 } = options;
|
|
150
|
+
let i = startUnicode;
|
|
145
151
|
const result = await webfont({
|
|
146
152
|
files: options.src,
|
|
147
153
|
fontName: options.fontName,
|
|
@@ -153,6 +159,12 @@ async function generateEntry(entry) {
|
|
|
153
159
|
round: options.round,
|
|
154
160
|
descent: options.descent,
|
|
155
161
|
addHashInFontUrl: options.addHashInFontUrl,
|
|
162
|
+
glyphTransformFn: (obj) => {
|
|
163
|
+
const char = String.fromCodePoint(i);
|
|
164
|
+
obj.unicode = [char];
|
|
165
|
+
i++;
|
|
166
|
+
return obj;
|
|
167
|
+
},
|
|
156
168
|
});
|
|
157
169
|
const buildedFormats = [];
|
|
158
170
|
ICON_FONT_FORMATS.forEach((format) => {
|
|
@@ -170,8 +182,9 @@ async function generateEntry(entry) {
|
|
|
170
182
|
if (!metadata)
|
|
171
183
|
return;
|
|
172
184
|
const { name, unicode } = metadata;
|
|
173
|
-
if (!unicode)
|
|
185
|
+
if (!unicode) {
|
|
174
186
|
return;
|
|
187
|
+
}
|
|
175
188
|
const code = unicode[0].charCodeAt(0).toString(16);
|
|
176
189
|
glyphs.push({ name, code });
|
|
177
190
|
});
|
|
@@ -182,25 +195,25 @@ async function generateEntry(entry) {
|
|
|
182
195
|
return `url("${urlPath}/${options.name}.${format}${hashSuffix}") format("${ICON_FONT_FORMAT_MAP[format]}")`;
|
|
183
196
|
})
|
|
184
197
|
.join(',');
|
|
185
|
-
const cssCode =
|
|
198
|
+
const cssCode = `/* stylelint-disable */
|
|
186
199
|
@font-face {
|
|
187
|
-
font-family: "${options.fontName}";
|
|
188
|
-
font-display: block;
|
|
189
|
-
font-style: normal;
|
|
190
|
-
font-weight: 400;
|
|
191
|
-
src: ${src};
|
|
200
|
+
font-family: "${options.fontName}";
|
|
201
|
+
font-display: block;
|
|
202
|
+
font-style: normal;
|
|
203
|
+
font-weight: 400;
|
|
204
|
+
src: ${src};
|
|
192
205
|
}
|
|
193
206
|
|
|
194
207
|
i[class^="${cssPrefix}"]:before, i[class*=" ${cssPrefix}"]:before {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
font-family: ${options.fontName} !important;
|
|
209
|
+
font-style: normal;
|
|
210
|
+
font-weight: normal !important;
|
|
211
|
+
font-variant: normal;
|
|
212
|
+
text-transform: none;
|
|
213
|
+
text-rendering: auto;
|
|
214
|
+
line-height: 1;
|
|
215
|
+
-webkit-font-smoothing: antialiased;
|
|
216
|
+
-moz-osx-font-smoothing: grayscale;
|
|
204
217
|
}
|
|
205
218
|
${glyphs
|
|
206
219
|
.map(({ name, code }) => {
|
|
@@ -228,7 +241,9 @@ async function generateIndex(dest, entries) {
|
|
|
228
241
|
import './index.css';
|
|
229
242
|
${BANNER}
|
|
230
243
|
${names
|
|
231
|
-
.map((name, index) =>
|
|
244
|
+
.map((name, index) =>
|
|
245
|
+
// `import { IconName as IconName_${index}, IconNameMap as IconNameMap_${index} } from './${name}/${name}';`,
|
|
246
|
+
`import './${name}/${name}';`)
|
|
232
247
|
.join('\n')}
|
|
233
248
|
export type { IconName } from '@fastkit/icon-font';
|
|
234
249
|
export { ICON_NAMES } from '@fastkit/icon-font';
|
|
@@ -59,6 +59,9 @@ async function resolveRawIconFontEntry(rootDir, rawEntry) {
|
|
|
59
59
|
if (entry.name == null) {
|
|
60
60
|
entry.name = 'mdi';
|
|
61
61
|
}
|
|
62
|
+
if (entry.startUnicode == null) {
|
|
63
|
+
entry.startUnicode = 0xea0;
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
const name = entry.name || path__default.basename(entry.src);
|
|
64
67
|
const fontName = entry.fontName || `${name}-icon`;
|
|
@@ -109,7 +112,8 @@ async function generateTS(entry, ids) {
|
|
|
109
112
|
/* eslint-disable */
|
|
110
113
|
// @ts-nocheck
|
|
111
114
|
${BANNER}
|
|
112
|
-
import { IconName, IconNameMap
|
|
115
|
+
import type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
116
|
+
import { registerIconNames } from '@fastkit/icon-font';
|
|
113
117
|
declare module "@fastkit/icon-font" {
|
|
114
118
|
export interface IconNameMap {
|
|
115
119
|
${ids.map((id) => ` '${id}': true,`).join('\n')}
|
|
@@ -118,7 +122,7 @@ ${ids.map((id) => ` '${id}': true,`).join('\n')}
|
|
|
118
122
|
export const ICON_NAMES = registerIconNames([
|
|
119
123
|
${ids.map((id) => `'${id}'`).join(',\n ')}
|
|
120
124
|
]);
|
|
121
|
-
export { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
125
|
+
export type { IconName, IconNameMap } from '@fastkit/icon-font';
|
|
122
126
|
`.trim();
|
|
123
127
|
const fileName = `${entry.name || 'icons'}.ts`;
|
|
124
128
|
const dest = path__default.resolve(entry.dest, fileName);
|
|
@@ -142,6 +146,8 @@ async function generateEntry(entry) {
|
|
|
142
146
|
}
|
|
143
147
|
await fs__default.ensureDir(options.dest);
|
|
144
148
|
const webfont = await (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('webfont')); })).default;
|
|
149
|
+
const { startUnicode = 0xea01 } = options;
|
|
150
|
+
let i = startUnicode;
|
|
145
151
|
const result = await webfont({
|
|
146
152
|
files: options.src,
|
|
147
153
|
fontName: options.fontName,
|
|
@@ -153,6 +159,12 @@ async function generateEntry(entry) {
|
|
|
153
159
|
round: options.round,
|
|
154
160
|
descent: options.descent,
|
|
155
161
|
addHashInFontUrl: options.addHashInFontUrl,
|
|
162
|
+
glyphTransformFn: (obj) => {
|
|
163
|
+
const char = String.fromCodePoint(i);
|
|
164
|
+
obj.unicode = [char];
|
|
165
|
+
i++;
|
|
166
|
+
return obj;
|
|
167
|
+
},
|
|
156
168
|
});
|
|
157
169
|
const buildedFormats = [];
|
|
158
170
|
ICON_FONT_FORMATS.forEach((format) => {
|
|
@@ -170,8 +182,9 @@ async function generateEntry(entry) {
|
|
|
170
182
|
if (!metadata)
|
|
171
183
|
return;
|
|
172
184
|
const { name, unicode } = metadata;
|
|
173
|
-
if (!unicode)
|
|
185
|
+
if (!unicode) {
|
|
174
186
|
return;
|
|
187
|
+
}
|
|
175
188
|
const code = unicode[0].charCodeAt(0).toString(16);
|
|
176
189
|
glyphs.push({ name, code });
|
|
177
190
|
});
|
|
@@ -182,25 +195,25 @@ async function generateEntry(entry) {
|
|
|
182
195
|
return `url("${urlPath}/${options.name}.${format}${hashSuffix}") format("${ICON_FONT_FORMAT_MAP[format]}")`;
|
|
183
196
|
})
|
|
184
197
|
.join(',');
|
|
185
|
-
const cssCode =
|
|
198
|
+
const cssCode = `/* stylelint-disable */
|
|
186
199
|
@font-face {
|
|
187
|
-
font-family: "${options.fontName}";
|
|
188
|
-
font-display: block;
|
|
189
|
-
font-style: normal;
|
|
190
|
-
font-weight: 400;
|
|
191
|
-
src: ${src};
|
|
200
|
+
font-family: "${options.fontName}";
|
|
201
|
+
font-display: block;
|
|
202
|
+
font-style: normal;
|
|
203
|
+
font-weight: 400;
|
|
204
|
+
src: ${src};
|
|
192
205
|
}
|
|
193
206
|
|
|
194
207
|
i[class^="${cssPrefix}"]:before, i[class*=" ${cssPrefix}"]:before {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
font-family: ${options.fontName} !important;
|
|
209
|
+
font-style: normal;
|
|
210
|
+
font-weight: normal !important;
|
|
211
|
+
font-variant: normal;
|
|
212
|
+
text-transform: none;
|
|
213
|
+
text-rendering: auto;
|
|
214
|
+
line-height: 1;
|
|
215
|
+
-webkit-font-smoothing: antialiased;
|
|
216
|
+
-moz-osx-font-smoothing: grayscale;
|
|
204
217
|
}
|
|
205
218
|
${glyphs
|
|
206
219
|
.map(({ name, code }) => {
|
|
@@ -228,7 +241,9 @@ async function generateIndex(dest, entries) {
|
|
|
228
241
|
import './index.css';
|
|
229
242
|
${BANNER}
|
|
230
243
|
${names
|
|
231
|
-
.map((name, index) =>
|
|
244
|
+
.map((name, index) =>
|
|
245
|
+
// `import { IconName as IconName_${index}, IconNameMap as IconNameMap_${index} } from './${name}/${name}';`,
|
|
246
|
+
`import './${name}/${name}';`)
|
|
232
247
|
.join('\n')}
|
|
233
248
|
export type { IconName } from '@fastkit/icon-font';
|
|
234
249
|
export { ICON_NAMES } from '@fastkit/icon-font';
|
package/dist/icon-font-gen.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/icon-font-gen",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"description": "@fastkit/icon-font-gen",
|
|
5
5
|
"buildOptions": {
|
|
6
6
|
"name": "IconFont",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/dadajam4/fastkit/tree/main/packages/icon-font-gen#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@fastkit/ev": "0.6.
|
|
37
|
-
"@fastkit/icon-font": "0.6.
|
|
38
|
-
"@fastkit/node-util": "0.6.
|
|
39
|
-
"@fastkit/tiny-logger": "0.6.
|
|
36
|
+
"@fastkit/ev": "0.6.16",
|
|
37
|
+
"@fastkit/icon-font": "0.6.16",
|
|
38
|
+
"@fastkit/node-util": "0.6.16",
|
|
39
|
+
"@fastkit/tiny-logger": "0.6.16",
|
|
40
40
|
"cac": "^6.7.11",
|
|
41
41
|
"chokidar": "^3.5.0",
|
|
42
42
|
"fs-extra": "^9.1.0",
|