webfont 11.2.26 → 12.0.0
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/NOTICE.md +153 -0
- package/README.md +135 -28
- package/dist/cli.mjs +628 -0
- package/dist/index.js +1 -507
- package/dist/src/index.d.ts +2 -2
- package/dist/src/lib/execCLI/index.d.ts +3 -4
- package/dist/src/lib/inputSource.d.ts +5 -0
- package/dist/src/lib/p-limit/index.d.ts +2 -0
- package/dist/src/lib/sfnt/flavor.d.ts +2 -0
- package/dist/src/lib/svgicons2svgfont/index.d.ts +9 -0
- package/dist/src/lib/ttf2eot/index.d.ts +2 -0
- package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
- package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
- package/dist/src/standalone/glyphsData.d.ts +2 -2
- package/dist/src/standalone/index.d.ts +3 -3
- package/dist/src/standalone/inputMode.d.ts +7 -0
- package/dist/src/standalone/options.d.ts +3 -3
- package/dist/src/standalone/templateFonts.d.ts +3 -0
- package/dist/src/standalone/toTtf.d.ts +4 -0
- package/dist/src/types/DecompressedFont.d.ts +5 -0
- package/dist/src/types/Format.d.ts +4 -4
- package/dist/src/types/GlyphData.d.ts +2 -2
- package/dist/src/types/GlyphMetadata.d.ts +1 -1
- package/dist/src/types/GlyphTransformFn.d.ts +2 -2
- package/dist/src/types/InitialOptions.d.ts +5 -4
- package/dist/src/types/MetadataProvider.d.ts +5 -0
- package/dist/src/types/OptionsBase.d.ts +3 -2
- package/dist/src/types/Result.d.ts +8 -5
- package/dist/src/types/ResultConfig.d.ts +4 -0
- package/dist/src/types/WebfontOptions.d.ts +29 -3
- package/dist/src/types/index.d.ts +7 -6
- package/package.json +52 -57
- package/dist/cli.js +0 -801
- package/dist/jest.config.d.ts +0 -3
- package/dist/src/cli/index.d.ts +0 -1
- package/dist/src/cli/index.test.d.ts +0 -1
- package/dist/src/cli/meow/index.d.ts +0 -104
- package/dist/src/index.test.d.ts +0 -1
- package/dist/src/standalone/index.test.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,507 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var path$1 = require('path');
|
|
6
|
-
var stream = require('stream');
|
|
7
|
-
var SVGIcons2SVGFontStream = require('svgicons2svgfont');
|
|
8
|
-
var cosmiconfig = require('cosmiconfig');
|
|
9
|
-
var crypto = require('crypto');
|
|
10
|
-
var deepmerge = require('deepmerge');
|
|
11
|
-
var require$$1 = require('fs');
|
|
12
|
-
var pLimit = require('p-limit');
|
|
13
|
-
var xml2js = require('xml2js');
|
|
14
|
-
var globby = require('globby');
|
|
15
|
-
var nunjucks = require('nunjucks');
|
|
16
|
-
var svg2ttf = require('svg2ttf');
|
|
17
|
-
var ttf2eot = require('ttf2eot');
|
|
18
|
-
var ttf2woff = require('ttf2woff');
|
|
19
|
-
var wawoff2 = require('wawoff2');
|
|
20
|
-
|
|
21
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
-
|
|
23
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
|
|
24
|
-
var SVGIcons2SVGFontStream__default = /*#__PURE__*/_interopDefaultLegacy(SVGIcons2SVGFontStream);
|
|
25
|
-
var cosmiconfig__default = /*#__PURE__*/_interopDefaultLegacy(cosmiconfig);
|
|
26
|
-
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
27
|
-
var deepmerge__default = /*#__PURE__*/_interopDefaultLegacy(deepmerge);
|
|
28
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
29
|
-
var pLimit__default = /*#__PURE__*/_interopDefaultLegacy(pLimit);
|
|
30
|
-
var xml2js__default = /*#__PURE__*/_interopDefaultLegacy(xml2js);
|
|
31
|
-
var globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
|
|
32
|
-
var nunjucks__default = /*#__PURE__*/_interopDefaultLegacy(nunjucks);
|
|
33
|
-
var svg2ttf__default = /*#__PURE__*/_interopDefaultLegacy(svg2ttf);
|
|
34
|
-
var ttf2eot__default = /*#__PURE__*/_interopDefaultLegacy(ttf2eot);
|
|
35
|
-
var ttf2woff__default = /*#__PURE__*/_interopDefaultLegacy(ttf2woff);
|
|
36
|
-
var wawoff2__default = /*#__PURE__*/_interopDefaultLegacy(wawoff2);
|
|
37
|
-
|
|
38
|
-
/*! *****************************************************************************
|
|
39
|
-
Copyright (c) Microsoft Corporation.
|
|
40
|
-
|
|
41
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
-
purpose with or without fee is hereby granted.
|
|
43
|
-
|
|
44
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
-
***************************************************************************** */
|
|
52
|
-
|
|
53
|
-
var __assign = function() {
|
|
54
|
-
__assign = Object.assign || function __assign(t) {
|
|
55
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
56
|
-
s = arguments[i];
|
|
57
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
58
|
-
}
|
|
59
|
-
return t;
|
|
60
|
-
};
|
|
61
|
-
return __assign.apply(this, arguments);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
65
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
66
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
67
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
68
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
69
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
70
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function __generator(thisArg, body) {
|
|
75
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
76
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
77
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
78
|
-
function step(op) {
|
|
79
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
80
|
-
while (_) try {
|
|
81
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
82
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
83
|
-
switch (op[0]) {
|
|
84
|
-
case 0: case 1: t = op; break;
|
|
85
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
86
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
87
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
88
|
-
default:
|
|
89
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
90
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
91
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
92
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
93
|
-
if (t[2]) _.ops.pop();
|
|
94
|
-
_.trys.pop(); continue;
|
|
95
|
-
}
|
|
96
|
-
op = body.call(thisArg, _);
|
|
97
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
98
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
var getTemplateDirectory = function () { return path__default['default'].resolve(__dirname, "../templates"); };
|
|
103
|
-
var getTemplateFilePath = function (template) {
|
|
104
|
-
var templateDirectory = getTemplateDirectory();
|
|
105
|
-
return templateDirectory + "/template." + template + ".njk";
|
|
106
|
-
};
|
|
107
|
-
var getBuiltInTemplates = function () {
|
|
108
|
-
var templateDirectory = getTemplateDirectory();
|
|
109
|
-
return {
|
|
110
|
-
css: { path: path__default['default'].join(templateDirectory, "template.css.njk") },
|
|
111
|
-
html: { path: path__default['default'].join(templateDirectory, "template.html.njk") },
|
|
112
|
-
json: { path: path__default['default'].join(templateDirectory, "template.json.njk") },
|
|
113
|
-
scss: { path: path__default['default'].join(templateDirectory, "template.scss.njk") },
|
|
114
|
-
styl: { path: path__default['default'].join(templateDirectory, "template.styl.njk") }
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/* eslint-disable complexity */
|
|
119
|
-
|
|
120
|
-
const testExpression = /(^|\/|\\)(?:((?:u[0-9a-f]{4,6},?)+)-)(.+)\.svg$/i;
|
|
121
|
-
|
|
122
|
-
function fileSorter(fileA, fileB) {
|
|
123
|
-
const hasUnicodeA = testExpression.test(fileA);
|
|
124
|
-
const hasUnicodeB = testExpression.test(fileB);
|
|
125
|
-
|
|
126
|
-
if (hasUnicodeA == hasUnicodeB) {
|
|
127
|
-
// just compare alphabetically
|
|
128
|
-
const fileA_ = fileA.substr(0, fileA.lastIndexOf('.'));
|
|
129
|
-
const fileB_ = fileB.substr(0, fileB.lastIndexOf('.'));
|
|
130
|
-
return fileA_ < fileB_ ? -1 : 1;
|
|
131
|
-
} else {
|
|
132
|
-
// map true to 0, because we want it to be first
|
|
133
|
-
return (hasUnicodeA ? 0 : 1) - (hasUnicodeB ? 0 : 1);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var filesorter = fileSorter;
|
|
138
|
-
|
|
139
|
-
/* eslint-disable prefer-template,newline-per-chained-call,complexity */
|
|
140
|
-
|
|
141
|
-
const path = path__default['default'];
|
|
142
|
-
const fs = require$$1__default['default'];
|
|
143
|
-
|
|
144
|
-
function getMetadataService(options = {}) {
|
|
145
|
-
let usedUnicodes = [];
|
|
146
|
-
|
|
147
|
-
// Default options
|
|
148
|
-
options.prependUnicode = !!options.prependUnicode;
|
|
149
|
-
options.startUnicode =
|
|
150
|
-
'number' === typeof options.startUnicode ? options.startUnicode : 0xea01;
|
|
151
|
-
options.log = options.log || console.log; // eslint-disable-line
|
|
152
|
-
options.err = options.err || console.err; // eslint-disable-line
|
|
153
|
-
|
|
154
|
-
// Throw on old options usage
|
|
155
|
-
if ('undefined' !== typeof options.appendUnicode) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
'The "appendUnicode" option was renamed "prependUnicode".' +
|
|
158
|
-
' See https://github.com/nfroidure/gulp-svgicons2svgfont/issues/33'
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return function getMetadataFromFile(file, cb) {
|
|
163
|
-
const basename = path.basename(file);
|
|
164
|
-
const metadata = {
|
|
165
|
-
path: file,
|
|
166
|
-
name: '',
|
|
167
|
-
unicode: [],
|
|
168
|
-
renamed: false,
|
|
169
|
-
};
|
|
170
|
-
const matches = basename.match(/^(?:((?:u[0-9a-f]{4,6},?)+)-)?(.+)\.svg$/i);
|
|
171
|
-
|
|
172
|
-
metadata.name =
|
|
173
|
-
matches && matches[2] ? matches[2] : 'icon' + options.startUnicode;
|
|
174
|
-
if (matches && matches[1]) {
|
|
175
|
-
metadata.unicode = matches[1].split(',').map((match) => {
|
|
176
|
-
match = match.substr(1);
|
|
177
|
-
return match
|
|
178
|
-
.split('u')
|
|
179
|
-
.map((code) => String.fromCodePoint(parseInt(code, 16)))
|
|
180
|
-
.join('');
|
|
181
|
-
});
|
|
182
|
-
if (-1 !== usedUnicodes.indexOf(metadata.unicode[0])) {
|
|
183
|
-
cb(
|
|
184
|
-
new Error(
|
|
185
|
-
'The unicode codepoint of the glyph ' +
|
|
186
|
-
metadata.name +
|
|
187
|
-
' seems to be already used by another glyph.'
|
|
188
|
-
)
|
|
189
|
-
);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
usedUnicodes.push(...metadata.unicode);
|
|
193
|
-
} else {
|
|
194
|
-
do {
|
|
195
|
-
metadata.unicode[0] = String.fromCodePoint(options.startUnicode++);
|
|
196
|
-
} while (usedUnicodes.includes(metadata.unicode[0]));
|
|
197
|
-
usedUnicodes.push(metadata.unicode[0]);
|
|
198
|
-
if (options.prependUnicode) {
|
|
199
|
-
metadata.renamed = true;
|
|
200
|
-
metadata.path = path.join(
|
|
201
|
-
path.dirname(file),
|
|
202
|
-
'u' +
|
|
203
|
-
metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() +
|
|
204
|
-
'-' +
|
|
205
|
-
basename
|
|
206
|
-
);
|
|
207
|
-
fs.rename(file, metadata.path, (err) => {
|
|
208
|
-
if (err) {
|
|
209
|
-
cb(
|
|
210
|
-
new Error(
|
|
211
|
-
'Could not save codepoint: ' +
|
|
212
|
-
'u' +
|
|
213
|
-
metadata.unicode[0]
|
|
214
|
-
.codePointAt(0)
|
|
215
|
-
.toString(16)
|
|
216
|
-
.toUpperCase() +
|
|
217
|
-
' for ' +
|
|
218
|
-
basename
|
|
219
|
-
)
|
|
220
|
-
);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
cb(null, metadata);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (!metadata.renamed) {
|
|
228
|
-
setImmediate(() => cb(null, metadata));
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
var metadata = getMetadataService;
|
|
234
|
-
|
|
235
|
-
var getGlyphsData = function (files, options) {
|
|
236
|
-
var metadataProvider = options.metadataProvider ||
|
|
237
|
-
metadata({
|
|
238
|
-
prependUnicode: options.prependUnicode,
|
|
239
|
-
startUnicode: options.startUnicode
|
|
240
|
-
});
|
|
241
|
-
var xmlParser = new xml2js__default['default'].Parser();
|
|
242
|
-
var throttle = pLimit__default['default'](options.maxConcurrency);
|
|
243
|
-
return Promise.all(files.map(function (srcPath) { return throttle(function () { return new Promise(function (resolve, reject) {
|
|
244
|
-
var glyph = require$$1.createReadStream(srcPath);
|
|
245
|
-
var glyphContents = "";
|
|
246
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
247
|
-
return glyph.
|
|
248
|
-
on("error", function (glyphError) { return reject(glyphError); }).
|
|
249
|
-
on("data", function (data) {
|
|
250
|
-
glyphContents += data.toString();
|
|
251
|
-
}).
|
|
252
|
-
on("end", function () {
|
|
253
|
-
// Maybe bug in xml2js
|
|
254
|
-
if (glyphContents.length === 0) {
|
|
255
|
-
return reject(new Error("Empty file " + srcPath));
|
|
256
|
-
}
|
|
257
|
-
return xmlParser.parseString(glyphContents, function (error) {
|
|
258
|
-
if (error) {
|
|
259
|
-
return reject(error);
|
|
260
|
-
}
|
|
261
|
-
var glyphData = {
|
|
262
|
-
contents: glyphContents,
|
|
263
|
-
srcPath: srcPath
|
|
264
|
-
};
|
|
265
|
-
return resolve(glyphData);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
}); }); })).then(function (glyphsData) {
|
|
269
|
-
var sortedGlyphsData = glyphsData;
|
|
270
|
-
if (options.sort) {
|
|
271
|
-
var sortCallback = function (fileA, fileB) { return filesorter(fileA.srcPath, fileB.srcPath); };
|
|
272
|
-
sortedGlyphsData = glyphsData.sort(sortCallback);
|
|
273
|
-
}
|
|
274
|
-
return Promise.all(sortedGlyphsData.map(function (glyphData) { return new Promise(function (resolve, reject) {
|
|
275
|
-
metadataProvider(glyphData.srcPath, function (error, metadata) {
|
|
276
|
-
if (error) {
|
|
277
|
-
return reject(error);
|
|
278
|
-
}
|
|
279
|
-
metadata.unicode.push(metadata.name.replace(/-/gu, "_"));
|
|
280
|
-
glyphData.metadata = metadata;
|
|
281
|
-
return resolve(glyphData);
|
|
282
|
-
});
|
|
283
|
-
}); }));
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
var getOptions = function (initialOptions) {
|
|
288
|
-
if (!initialOptions || !initialOptions.files) {
|
|
289
|
-
throw new Error("You must pass webfont a `files` glob");
|
|
290
|
-
}
|
|
291
|
-
return __assign({ centerHorizontally: false, descent: 0, fixedWidth: false, fontHeight: null, fontId: null, fontName: "webfont", fontStyle: "", fontWeight: "", formats: ["svg", "ttf", "eot", "woff", "woff2"], formatsOptions: {
|
|
292
|
-
ttf: {
|
|
293
|
-
copyright: null,
|
|
294
|
-
ts: null,
|
|
295
|
-
version: null
|
|
296
|
-
}
|
|
297
|
-
}, glyphTransformFn: null,
|
|
298
|
-
/*
|
|
299
|
-
* Maybe allow setup from CLI
|
|
300
|
-
* This is usually less than file read maximums while staying performance
|
|
301
|
-
*/
|
|
302
|
-
maxConcurrency: 100, metadata: null, metadataProvider: null, normalize: false, prependUnicode: false, round: 10e12, sort: true, startUnicode: 0xea01, template: null, templateCacheString: null, templateClassName: null, templateFontName: null, templateFontPath: "./", verbose: false }, initialOptions);
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
var buildConfig = function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
306
|
-
var searchPath, configPath, configExplorer, config;
|
|
307
|
-
return __generator(this, function (_a) {
|
|
308
|
-
switch (_a.label) {
|
|
309
|
-
case 0:
|
|
310
|
-
searchPath = process.cwd();
|
|
311
|
-
configPath = null;
|
|
312
|
-
if (options.configFile) {
|
|
313
|
-
searchPath = null;
|
|
314
|
-
configPath = path__default['default'].resolve(process.cwd(), options.configFile);
|
|
315
|
-
}
|
|
316
|
-
configExplorer = cosmiconfig__default['default']("webfont");
|
|
317
|
-
return [4 /*yield*/, configExplorer.search(searchPath)];
|
|
318
|
-
case 1:
|
|
319
|
-
config = _a.sent();
|
|
320
|
-
if (!configPath) return [3 /*break*/, 3];
|
|
321
|
-
return [4 /*yield*/, configExplorer.load(configPath)];
|
|
322
|
-
case 2:
|
|
323
|
-
config = _a.sent();
|
|
324
|
-
_a.label = 3;
|
|
325
|
-
case 3:
|
|
326
|
-
if (!config) {
|
|
327
|
-
return [2 /*return*/, {}];
|
|
328
|
-
}
|
|
329
|
-
return [2 /*return*/, config];
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}); };
|
|
333
|
-
var toSvg = function (glyphsData, options) {
|
|
334
|
-
var result = "";
|
|
335
|
-
return new Promise(function (resolve, reject) {
|
|
336
|
-
var log = function () {
|
|
337
|
-
Function.prototype();
|
|
338
|
-
};
|
|
339
|
-
if (options.verbose) {
|
|
340
|
-
// eslint-disable-next-line no-console
|
|
341
|
-
log = console.log.bind(console);
|
|
342
|
-
}
|
|
343
|
-
var fontStream = new SVGIcons2SVGFontStream__default['default']({
|
|
344
|
-
ascent: options.ascent,
|
|
345
|
-
centerHorizontally: options.centerHorizontally,
|
|
346
|
-
descent: options.descent,
|
|
347
|
-
fixedWidth: options.fixedWidth,
|
|
348
|
-
fontHeight: options.fontHeight,
|
|
349
|
-
fontId: options.fontId,
|
|
350
|
-
fontName: options.fontName,
|
|
351
|
-
fontStyle: options.fontStyle,
|
|
352
|
-
fontWeight: options.fontWeight,
|
|
353
|
-
log: log,
|
|
354
|
-
metadata: options.metadata,
|
|
355
|
-
normalize: options.normalize,
|
|
356
|
-
round: options.round
|
|
357
|
-
}).
|
|
358
|
-
on("finish", function () { return resolve(result); }).
|
|
359
|
-
on("data", function (data) {
|
|
360
|
-
result += data;
|
|
361
|
-
}).
|
|
362
|
-
on("error", function (error) { return reject(error); });
|
|
363
|
-
glyphsData.forEach(function (glyphData) {
|
|
364
|
-
var glyphStream = new stream.Readable();
|
|
365
|
-
glyphStream.push(glyphData.contents);
|
|
366
|
-
glyphStream.push(null);
|
|
367
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
368
|
-
// @ts-ignore
|
|
369
|
-
glyphStream.metadata = glyphData.metadata;
|
|
370
|
-
fontStream.write(glyphStream);
|
|
371
|
-
});
|
|
372
|
-
fontStream.end();
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
var toTtf = function (buffer, options) { return Buffer.from(svg2ttf__default['default'](buffer, options).buffer); };
|
|
376
|
-
var toEot = function (buffer) { return Buffer.from(ttf2eot__default['default'](buffer).buffer); };
|
|
377
|
-
var toWoff = function (buffer, options) { return Buffer.from(ttf2woff__default['default'](buffer, options).buffer); };
|
|
378
|
-
var toWoff2 = function (buffer) { return wawoff2__default['default'].compress(buffer); };
|
|
379
|
-
var webfont = function (initialOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
|
380
|
-
var options, config, foundFiles, filteredFiles, glyphsData, transformedGlyphs, ttfOptions, svg, ttf, result, _a, builtInTemplates, templateFilePath, builtInPath, resolvedTemplateFilePath, hashOption, nunjucksOptions;
|
|
381
|
-
return __generator(this, function (_b) {
|
|
382
|
-
switch (_b.label) {
|
|
383
|
-
case 0:
|
|
384
|
-
options = getOptions(initialOptions);
|
|
385
|
-
return [4 /*yield*/, buildConfig({
|
|
386
|
-
configFile: options.configFile
|
|
387
|
-
})];
|
|
388
|
-
case 1:
|
|
389
|
-
config = _b.sent();
|
|
390
|
-
if (Object.keys(config).length > 0) {
|
|
391
|
-
options = deepmerge__default['default'](options, config.config, {
|
|
392
|
-
arrayMerge: function (_destinationArray, sourceArray) { return sourceArray; }
|
|
393
|
-
});
|
|
394
|
-
options.filePath = config.filepath;
|
|
395
|
-
}
|
|
396
|
-
return [4 /*yield*/, globby__default['default']([].concat(options.files))];
|
|
397
|
-
case 2:
|
|
398
|
-
foundFiles = _b.sent();
|
|
399
|
-
filteredFiles = foundFiles.filter(function (foundFile) { return path__default['default'].extname(foundFile) === ".svg"; });
|
|
400
|
-
if (filteredFiles.length === 0) {
|
|
401
|
-
throw new Error("Files glob patterns specified did not match any files");
|
|
402
|
-
}
|
|
403
|
-
return [4 /*yield*/, getGlyphsData(filteredFiles, options)];
|
|
404
|
-
case 3:
|
|
405
|
-
glyphsData = _b.sent();
|
|
406
|
-
if (!(options.glyphTransformFn && typeof options.glyphTransformFn === "function")) return [3 /*break*/, 5];
|
|
407
|
-
transformedGlyphs = glyphsData.map(function (glyphData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
408
|
-
var metadata;
|
|
409
|
-
return __generator(this, function (_a) {
|
|
410
|
-
switch (_a.label) {
|
|
411
|
-
case 0: return [4 /*yield*/, options.glyphTransformFn(glyphData.metadata)];
|
|
412
|
-
case 1:
|
|
413
|
-
metadata = _a.sent();
|
|
414
|
-
return [2 /*return*/, __assign(__assign({}, glyphData), { metadata: metadata })];
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}); });
|
|
418
|
-
return [4 /*yield*/, Promise.all(transformedGlyphs)];
|
|
419
|
-
case 4:
|
|
420
|
-
glyphsData = _b.sent();
|
|
421
|
-
_b.label = 5;
|
|
422
|
-
case 5:
|
|
423
|
-
ttfOptions = {};
|
|
424
|
-
if (options.formatsOptions && options.formatsOptions.ttf) {
|
|
425
|
-
ttfOptions = options.formatsOptions.ttf;
|
|
426
|
-
}
|
|
427
|
-
return [4 /*yield*/, toSvg(glyphsData, options)];
|
|
428
|
-
case 6:
|
|
429
|
-
svg = _b.sent();
|
|
430
|
-
ttf = toTtf(svg, ttfOptions);
|
|
431
|
-
result = {
|
|
432
|
-
glyphsData: glyphsData,
|
|
433
|
-
hash: crypto__default['default'].createHash("md5").update(svg).
|
|
434
|
-
digest("hex"),
|
|
435
|
-
svg: svg,
|
|
436
|
-
ttf: ttf
|
|
437
|
-
};
|
|
438
|
-
if (options.formats.includes("eot")) {
|
|
439
|
-
result.eot = toEot(ttf);
|
|
440
|
-
}
|
|
441
|
-
if (options.formats.includes("woff")) {
|
|
442
|
-
result.woff = toWoff(ttf, { metadata: options.metadata });
|
|
443
|
-
}
|
|
444
|
-
if (!options.formats.includes("woff2")) return [3 /*break*/, 8];
|
|
445
|
-
_a = result;
|
|
446
|
-
return [4 /*yield*/, toWoff2(ttf)];
|
|
447
|
-
case 7:
|
|
448
|
-
_a.woff2 = _b.sent();
|
|
449
|
-
_b.label = 8;
|
|
450
|
-
case 8:
|
|
451
|
-
if (options.template) {
|
|
452
|
-
builtInTemplates = getBuiltInTemplates();
|
|
453
|
-
templateFilePath = void 0;
|
|
454
|
-
if (Object.keys(builtInTemplates).includes(options.template)) {
|
|
455
|
-
result.usedBuildInTemplate = true;
|
|
456
|
-
builtInPath = path__default['default'].resolve(__dirname, "../..");
|
|
457
|
-
nunjucks__default['default'].configure(builtInPath);
|
|
458
|
-
templateFilePath = getTemplateFilePath(options.template);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
resolvedTemplateFilePath = path__default['default'].resolve(options.template);
|
|
462
|
-
nunjucks__default['default'].configure(path__default['default'].dirname(resolvedTemplateFilePath));
|
|
463
|
-
templateFilePath = path__default['default'].resolve(resolvedTemplateFilePath);
|
|
464
|
-
}
|
|
465
|
-
hashOption = {};
|
|
466
|
-
if (options.addHashInFontUrl) {
|
|
467
|
-
hashOption = { hash: result.hash };
|
|
468
|
-
}
|
|
469
|
-
nunjucksOptions = deepmerge__default['default'].all([
|
|
470
|
-
{
|
|
471
|
-
glyphs: result.glyphsData.map(function (glyph) { return glyph.metadata; })
|
|
472
|
-
},
|
|
473
|
-
options,
|
|
474
|
-
{
|
|
475
|
-
cacheString: options.templateCacheString || Date.now(),
|
|
476
|
-
className: options.templateClassName || options.fontName,
|
|
477
|
-
fontName: options.templateFontName || options.fontName,
|
|
478
|
-
fontPath: options.templateFontPath.replace(/\/?$/u, "/")
|
|
479
|
-
},
|
|
480
|
-
hashOption,
|
|
481
|
-
{
|
|
482
|
-
fonts: Object.fromEntries(new Map(options.formats.map(function (format) { return [
|
|
483
|
-
format, function () {
|
|
484
|
-
if (format === "woff2") {
|
|
485
|
-
return Buffer.from(result.woff2).toString("base64");
|
|
486
|
-
}
|
|
487
|
-
return result[format].toString("base64");
|
|
488
|
-
},
|
|
489
|
-
]; })))
|
|
490
|
-
},
|
|
491
|
-
]);
|
|
492
|
-
result.template = nunjucks__default['default'].render(templateFilePath, nunjucksOptions);
|
|
493
|
-
}
|
|
494
|
-
if (!options.formats.includes("svg")) {
|
|
495
|
-
delete result.svg;
|
|
496
|
-
}
|
|
497
|
-
if (!options.formats.includes("ttf")) {
|
|
498
|
-
delete result.ttf;
|
|
499
|
-
}
|
|
500
|
-
result.config = options;
|
|
501
|
-
return [2 /*return*/, result];
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}); };
|
|
505
|
-
|
|
506
|
-
exports['default'] = webfont;
|
|
507
|
-
exports.webfont = webfont;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require("cosmiconfig"),u=require("crypto");u=c(u);let d=require("deepmerge");d=c(d);let f=require("nunjucks");f=c(f);let p=require("path");p=c(p);let m=require("stream"),h=require("ttf2woff");h=c(h);let g=require("wawoff2");g=c(g);let _=require("globby"),v=require("svgicons2svgfont"),y=require("ttf2eot");y=c(y);let b=require("fontverter");b=c(b);let x=require("fs/promises");x=c(x);let S=require("fs"),C=require("xml2js");C=c(C);let w=require("p-limit");w=c(w);let T=require("svg2ttf");T=c(T);var E=()=>p.default.resolve(__dirname,`../templates`),D=e=>`${E()}/template.${e}.njk`,O=()=>{let e=E();return{css:{path:p.default.join(e,`template.css.njk`)},html:{path:p.default.join(e,`template.html.njk`)},json:{path:p.default.join(e,`template.json.njk`)},scss:{path:p.default.join(e,`template.scss.njk`)},styl:{path:p.default.join(e,`template.styl.njk`)}}},k=/^https?:\/\//iu,A=e=>k.test(e),j=e=>{if(A(e))try{return p.default.extname(new URL(e).pathname).toLowerCase()}catch{return``}return p.default.extname(e).toLowerCase()},M=async e=>(await Promise.all(e.map(e=>A(e)?Promise.resolve([e]):(0,_.globby)(e)))).flat(),ee=e=>({prependUnicode:!!e.prependUnicode,startUnicode:Number(e.startUnicode)}),te=e=>({ascent:e.ascent,centerHorizontally:e.centerHorizontally,descent:e.descent,fixedWidth:e.fixedWidth,fontHeight:e.fontHeight,fontId:e.fontId,fontName:e.fontName,fontStyle:e.fontStyle,fontWeight:e.fontWeight,metadata:e.metadata,normalize:e.normalize,round:e.round}),ne=e=>Buffer.from((0,y.default)(e)),N=1330926671,P=1953658213,F=65536,I=e=>{if(e.length<4)throw Error(`SFNT buffer is too short to read flavor`);let t=e.readUInt32BE(0);if(t===N)return`otf`;if(t===P||t===F)return`ttf`;throw Error(`Unsupported SFNT flavor 0x${t.toString(16)}`)},L=o(((e,t)=>{t.exports=function(e){return!e||e.length<8?!1:e[0]===119&&e[1]===79&&e[2]===70&&e[3]===70&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0||e[4]===79&&e[5]===84&&e[6]===84&&e[7]===79}})),R=o(((e,t)=>{t.exports=function(e){return!e||e.length<8?!1:e[0]===119&&e[1]===79&&e[2]===70&&e[3]===50&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0}})),z=c(L()),B=c(R()),V=(e,t)=>{let n=j(t);if(n===`.woff2`&&!(0,B.default)(e))throw Error(`URL did not return a valid WOFF2 font: ${t}`);if(n===`.woff`&&!(0,z.default)(e))throw Error(`URL did not return a valid WOFF font: ${t}`);if(e.length===0)throw Error(`URL returned an empty response: ${t}`)},H=async e=>{let t;try{t=await fetch(e)}catch(t){let n=String(t);throw t instanceof Error&&(n=t.message),Error(`Failed to fetch font URL ${e}: ${n}`)}if(!t.ok)throw Error(`Failed to fetch font URL ${e}: HTTP ${t.status} ${t.statusText}`);let n=await t.arrayBuffer(),r=Buffer.from(n);return V(r,e),r},U=new Set([`.woff`,`.woff2`]),W=`.svg`,G=[`svg`,`ttf`,`eot`,`woff`,`woff2`],K=e=>e===W,q=e=>U.has(e),J=e=>K(e)||q(e),Y=e=>{if(e.length===0)return`empty`;let t=e.map(e=>j(e));if(!t.every(J))return`empty`;let n=t.some(K),r=t.some(q);return n&&r?`mixed`:r?`webfont`:n?`svg`:`empty`},X=e=>{if(e.includes(`otf`))throw Error(`OTF output is only supported when converting WOFF/WOFF2 input. Request "ttf" for SVG icons, or pass a .woff/.woff2 file.`)},Z=(e,t)=>t===`svg`?e.filter(e=>j(e)===W):t===`webfont`?e.filter(e=>U.has(j(e))):[],re=e=>{let t=e.filter(e=>e===`ttf`||e===`otf`);if(e.length===G.length&&G.every(t=>e.includes(t)))return[`ttf`];if(t.length===0)throw Error(`formats must include "ttf" and/or "otf" when converting WOFF/WOFF2 input`);return[...new Set(t)]},ie=e=>{if(e.length===0)throw Error(`No WOFF or WOFF2 files matched`)},ae=e=>{if(e.template)throw Error(`Templates are not supported when converting WOFF/WOFF2 input`);if(e.glyphTransformFn)throw Error(`glyphTransformFn is not supported when converting WOFF/WOFF2 input`)},oe=e=>{let{decompressed:t,sfnt:n,format:r,flavor:i,source:a}=e;if(r===`ttf`&&i!==`ttf`)throw Error(`Input decompresses to OpenType (OTF). Request "otf" format instead of "ttf" for ${a}.`);if(r===`otf`&&i!==`otf`)throw Error(`Input decompresses to TrueType (TTF). Request "ttf" format instead of "otf" for ${a}.`);if(r===`ttf`){t.ttf=n;return}t.otf=n},se=e=>A(e)?H(e):x.readFile(e),ce=async(e,t,n)=>{n&&console.log(`Decompressing ${e}...`);let r=await se(e),i=Buffer.from(await b.default.convert(r,`sfnt`)),a=I(i),o={source:e};for(let n of t)oe({decompressed:o,sfnt:i,format:n,flavor:a,source:e});return o},le=async(e,t)=>{ae(t),ie(e);let n=re(t.formats),r=await Promise.all(e.map(e=>ce(e,n,t.verbose))),i={config:{...t},decompressedFonts:r};return r.length===1&&(i.ttf=r[0].ttf,i.otf=r[0].otf),i},ue=w.default,de=e=>e===void 0?[]:Array.isArray(e)?e:[e],fe=e=>({name:e.name,unicode:de(e.unicode)}),pe=(e,t)=>{let n=t.metadataProvider||(0,v.getMetadataService)(ee(t)),r=new C.default.Parser,i=ue(t.maxConcurrency);return Promise.all(e.map(e=>i(()=>new Promise((t,n)=>{let i=(0,S.createReadStream)(e),a=``;i.on(`error`,e=>n(e)).on(`data`,e=>{a+=e.toString()}).on(`end`,()=>a.length===0?n(Error(`Empty file ${e}`)):r.parseString(a,r=>r?n(r):t({contents:a,srcPath:e})))})))).then(e=>{let r=e;t.sort&&(r=e.sort((e,t)=>(0,v.fileSorter)(e.srcPath,t.srcPath)));let{ligatures:i}=t;return Promise.all(r.map(e=>new Promise((t,r)=>{n(e.srcPath,(n,a)=>{if(n)return r(n);if(!a)return r(Error(`Missing metadata for ${e.srcPath}`));let o=fe(a);return i&&o.unicode.push(a.name.replace(/-/gu,`_`)),e.metadata=o,t(e)})})))})},me=e=>{if(!e?.files)throw Error("You must pass webfont a `files` glob");return{centerHorizontally:!1,descent:0,fixedWidth:!1,fontHeight:void 0,fontId:void 0,fontName:`webfont`,fontStyle:``,fontWeight:``,formats:[`svg`,`ttf`,`eot`,`woff`,`woff2`],formatsOptions:{ttf:{copyright:null,ts:null,version:null}},ligatures:!0,maxConcurrency:100,metadata:void 0,normalize:!1,prependUnicode:!1,round:0x9184e72a000,sort:!0,startUnicode:59905,templateFontPath:`./`,verbose:!1,...e}},Q=(e,t)=>{if(e===`woff2`){if(!t.woff2)throw Error(`Missing woff2 buffer for template rendering`);return Buffer.from(t.woff2).toString(`base64`)}let n=t[e];if(!n)throw Error(`Missing ${e} buffer for template rendering`);return n.toString(`base64`)},he=(e,t={})=>Buffer.from((0,T.default)(e,t).buffer),ge=e=>`filepath`in e,_e=async e=>{let t=(0,l.cosmiconfig)(`webfont`,{searchStrategy:`global`});if(e.configFile){let n=p.default.resolve(process.cwd(),e.configFile);return await t.load(n)??{}}return await t.search(process.cwd())??{}},ve=(e,t)=>{let n=``;return new Promise((r,i)=>{t.verbose&&console.log(`Generating SVG font...`);let a=new v.SVGIcons2SVGFontStream(te(t)).on(`finish`,()=>r(n)).on(`data`,e=>{n+=e}).on(`error`,e=>i(e));e.forEach(e=>{let t=new m.Readable;t.push(e.contents),t.push(null),t.metadata=e.metadata??{name:``,unicode:[]},a.write(t)}),a.end()})},ye=e=>ne(e),be=(e,t)=>Buffer.from((0,h.default)(e,t).buffer),xe=e=>g.default.compress(e),$=async e=>{let t=me(e);delete t.filePath;let n=await _e({configFile:t.configFile}),r;ge(n)&&(t=(0,d.default)(t,n.config,{arrayMerge:(e,t)=>t}),r=n.filepath);let i;i=Array.isArray(t.files)?t.files:[t.files];let a=await M(i),o=Y(a);if(o===`mixed`)throw Error(`Cannot mix SVG icons with WOFF/WOFF2 font files in the same run`);if(o===`empty`)throw Error(`Files glob patterns specified did not match any supported files`);if(o===`webfont`){let e=await le(Z(a,o),t);return r&&(e.config={...t,filePath:r}),e}X(t.formats);let s=await pe(Z(a,`svg`),t);if(t.glyphTransformFn){let e=t.glyphTransformFn,n=s.map(async t=>{let n=await e(t.metadata??{name:``,unicode:[]});return{...t,metadata:n}});s=await Promise.all(n)}let c={};t.formatsOptions?.ttf&&(c=t.formatsOptions.ttf);let l=await ve(s,t),m=he(l,c),h={glyphsData:s,hash:u.default.createHash(`md5`).update(l).digest(`hex`),svg:l,ttf:m},{formats:g}=t;if(g.includes(`eot`)&&(h.eot=ye(m)),g.includes(`woff`)){let e;typeof t.metadata==`string`&&(e=t.metadata),h.woff=be(m,{metadata:e})}if(g.includes(`woff2`)&&(h.woff2=Buffer.from(await xe(m))),t.template){let e=O(),n;if(Object.keys(e).includes(t.template)){h.usedBuildInTemplate=!0;let e=p.default.resolve(__dirname,`../..`);f.default.configure(e),n=D(t.template)}else{let e=p.default.resolve(t.template);f.default.configure(p.default.dirname(e)),n=p.default.resolve(e)}let r={};t.addHashInFontUrl&&(r={hash:h.hash});let i=d.default.all([{glyphs:h.glyphsData?.map(e=>e.metadata)??[]},t,{cacheString:t.templateCacheString||Date.now(),className:t.templateClassName||t.fontName,fontName:t.templateFontName||t.fontName,fontPath:t.templateFontPath.replace(/\/?$/u,`/`)},r,{fonts:Object.fromEntries(new Map(g.map(e=>[e,()=>Q(e,h)])))}]);h.template=f.default.render(n,i)}return g.includes(`svg`)||delete h.svg,g.includes(`ttf`)||delete h.ttf,g.includes(`otf`)||delete h.otf,r?h.config={...t,filePath:r}:h.config=t,h},Se=$;exports.default=Se,exports.webfont=$;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { webfont } from
|
|
2
|
-
export { webfont } from
|
|
1
|
+
import { webfont } from './standalone';
|
|
2
|
+
export { webfont } from './standalone';
|
|
3
3
|
export default webfont;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare type Output = {
|
|
1
|
+
import { ExecException } from 'child_process';
|
|
2
|
+
export type Output = {
|
|
4
3
|
code?: number;
|
|
5
4
|
error: ExecException | null;
|
|
6
5
|
files: string[];
|
|
7
6
|
stderr?: string;
|
|
8
7
|
stdout?: string;
|
|
9
8
|
};
|
|
10
|
-
export
|
|
9
|
+
export type ExecCLI = (_args?: string, _destination?: string) => Promise<Output>;
|
|
11
10
|
/**
|
|
12
11
|
* @name execCLI
|
|
13
12
|
* @description Execute webfont CLI commands using child_process.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const isHttpUrl: (value: string) => boolean;
|
|
2
|
+
export declare const getInputExtension: (source: string) => string;
|
|
3
|
+
export declare const resolveInputSources: (patterns: readonly string[]) => Promise<string[]>;
|
|
4
|
+
export declare const getWebfontSourceBasename: (source: string) => string;
|
|
5
|
+
export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SVGIcons2SVGFontStreamOptions, fileSorter, getMetadataService, SVGIcons2SVGFontStream } from 'svgicons2svgfont';
|
|
2
|
+
import { WebfontOptions } from '../../types';
|
|
3
|
+
export { fileSorter, getMetadataService, SVGIcons2SVGFontStream };
|
|
4
|
+
type MetadataServiceOptions = {
|
|
5
|
+
prependUnicode: boolean;
|
|
6
|
+
startUnicode: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
|
|
9
|
+
export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchWebfontFromUrl: (url: string) => Promise<Buffer>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { GlyphData, WebfontOptions } from '../types';
|
|
2
|
+
type GlyphsDataGetter = (_files: Array<GlyphData["srcPath"]>, _options: WebfontOptions) => unknown;
|
|
3
3
|
export declare const getGlyphsData: GlyphsDataGetter;
|
|
4
4
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { InitialOptions } from '../types';
|
|
2
|
+
import { Result } from '../types/Result';
|
|
3
|
+
type Webfont = (_initialOptions?: InitialOptions) => Promise<Result>;
|
|
4
4
|
export declare const webfont: Webfont;
|
|
5
5
|
export default webfont;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Format } from '../types/Format';
|
|
2
|
+
export type InputMode = "empty" | "mixed" | "svg" | "webfont";
|
|
3
|
+
export declare const classifyInputFiles: (filePaths: readonly string[]) => InputMode;
|
|
4
|
+
export declare const assertSvgPipelineFormats: (formats: readonly Format[]) => void;
|
|
5
|
+
export declare const filterInputFilesByMode: (filePaths: readonly string[], mode: InputMode) => string[];
|
|
6
|
+
export type ConversionFormat = "otf" | "ttf";
|
|
7
|
+
export declare const resolveWebfontConversionFormats: (formats: readonly Format[]) => ConversionFormat[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { WebfontOptions } from
|
|
3
|
-
|
|
1
|
+
import { InitialOptions } from '../types/InitialOptions';
|
|
2
|
+
import { WebfontOptions } from '../types/WebfontOptions';
|
|
3
|
+
type OptionsGetter = (_initialOptions?: InitialOptions) => WebfontOptions;
|
|
4
4
|
export declare const getOptions: OptionsGetter;
|
|
5
5
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
export type Format = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf";
|
|
2
|
+
export type Formats = Array<Format>;
|
|
3
|
+
type FormatOption = {
|
|
4
4
|
copyright: null;
|
|
5
5
|
ts: null;
|
|
6
6
|
version: null;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type FormatsOptions = Partial<Record<Format, FormatOption>>;
|
|
9
9
|
export {};
|