webfont 12.0.0 → 12.1.1
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 +14 -2
- package/README.md +199 -20
- package/dist/browser.js +4 -0
- package/dist/cli.mjs +850 -495
- package/dist/index.js +1 -1
- package/dist/index.mjs +513 -0
- package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
- package/dist/parseTemplateOption-Bvbie1SQ.mjs +19 -0
- package/dist/parseTemplateOption-DLNu6PPx.mjs +38 -0
- package/dist/renderTemplates-Biyrk6t-.mjs +92 -0
- package/dist/renderTemplates-CXVKq3Op.mjs +102 -0
- package/dist/renderTemplates-zCYCzeOt.js +1 -0
- package/dist/src/browser.d.mts +2 -0
- package/dist/src/browser.d.ts +2 -0
- package/dist/src/index.d.mts +5 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/lib/applyOptimizeSvgToGlyphs.d.mts +3 -0
- package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
- package/dist/src/lib/evenoddFillRule.d.mts +2 -0
- package/dist/src/lib/evenoddFillRule.d.ts +2 -0
- package/dist/src/lib/execCLI/index.d.mts +24 -0
- package/dist/src/lib/inputSource.d.mts +2 -0
- package/dist/src/lib/inputSource.d.ts +1 -4
- package/dist/src/lib/inputSourceUtils.d.mts +4 -0
- package/dist/src/lib/inputSourceUtils.d.ts +4 -0
- package/dist/src/lib/largeFontLigatures.d.mts +4 -0
- package/dist/src/lib/largeFontLigatures.d.ts +4 -0
- package/dist/src/lib/optimizeSvgGlyphs.d.mts +4 -0
- package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
- package/dist/src/lib/p-limit/index.d.mts +2 -0
- package/dist/src/lib/parseFormats.d.mts +4 -0
- package/dist/src/lib/parseFormats.d.ts +4 -0
- package/dist/src/lib/parseTemplateOption.d.mts +2 -0
- package/dist/src/lib/parseTemplateOption.d.ts +2 -0
- package/dist/src/lib/runtimeEnvironment.d.mts +4 -0
- package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
- package/dist/src/lib/sfnt/flavor.d.mts +2 -0
- package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.mts +13 -0
- package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +13 -0
- package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.mts +3 -0
- package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
- package/dist/src/lib/svgTools/applySvgDiagnostics.d.mts +13 -0
- package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
- package/dist/src/lib/svgTools/applySvgTools.d.mts +14 -0
- package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
- package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.mts +2 -0
- package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
- package/dist/src/lib/svgicons2svgfont/index.d.mts +14 -0
- package/dist/src/lib/svgicons2svgfont/index.d.ts +5 -0
- package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.mts +11 -0
- package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
- package/dist/src/lib/templateUnicodeRange.d.mts +4 -0
- package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
- package/dist/src/lib/ttf2eot/index.d.mts +2 -0
- package/dist/src/lib/ttfEncode.d.mts +5 -0
- package/dist/src/lib/ttfEncode.d.ts +5 -0
- package/dist/src/standalone/convertTtfInput.d.mts +3 -0
- package/dist/src/standalone/convertTtfInput.d.ts +3 -0
- package/dist/src/standalone/convertWebfontInput.d.mts +3 -0
- package/dist/src/standalone/defaultOptions.d.mts +3 -0
- package/dist/src/standalone/defaultOptions.d.ts +3 -0
- package/dist/src/standalone/fetchWebfontUrl.d.mts +1 -0
- package/dist/src/standalone/generateSvgFont.d.mts +2 -0
- package/dist/src/standalone/generateSvgFont.d.ts +2 -0
- package/dist/src/standalone/getGlyphsDataFromInputs.d.mts +3 -0
- package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
- package/dist/src/standalone/glyphsData.d.mts +4 -0
- package/dist/src/standalone/glyphsData.d.ts +1 -1
- package/dist/src/standalone/index.d.mts +10 -0
- package/dist/src/standalone/index.d.ts +5 -0
- package/dist/src/standalone/inputMode.d.mts +9 -0
- package/dist/src/standalone/inputMode.d.ts +3 -1
- package/dist/src/standalone/options.d.mts +5 -0
- package/dist/src/standalone/optionsFromGlyphs.d.mts +3 -0
- package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
- package/dist/src/standalone/renderTemplates.d.mts +10 -0
- package/dist/src/standalone/renderTemplates.d.ts +10 -0
- package/dist/src/standalone/runSvgPipeline.d.mts +3 -0
- package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
- package/dist/src/standalone/templateFonts.d.mts +3 -0
- package/dist/src/standalone/toTtf.d.mts +4 -0
- package/dist/src/standalone/validateWebfontOptions.d.mts +6 -0
- package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
- package/dist/src/standalone/webfontFromGlyphs.d.mts +3 -0
- package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
- package/dist/src/types/DecompressedFont.d.mts +5 -0
- package/dist/src/types/Format.d.mts +9 -0
- package/dist/src/types/GlyphContentTransformFn.d.mts +2 -0
- package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
- package/dist/src/types/GlyphData.d.mts +6 -0
- package/dist/src/types/GlyphInput.d.mts +6 -0
- package/dist/src/types/GlyphInput.d.ts +6 -0
- package/dist/src/types/GlyphMetadata.d.mts +10 -0
- package/dist/src/types/GlyphTransformFn.d.mts +2 -0
- package/dist/src/types/InitialOptions.d.mts +10 -0
- package/dist/src/types/InitialOptions.d.ts +2 -0
- package/dist/src/types/MetadataProvider.d.mts +5 -0
- package/dist/src/types/OptionsBase.d.mts +39 -0
- package/dist/src/types/OptionsBase.d.ts +9 -1
- package/dist/src/types/RenderedTemplate.d.mts +7 -0
- package/dist/src/types/RenderedTemplate.d.ts +7 -0
- package/dist/src/types/Result.d.mts +26 -0
- package/dist/src/types/Result.d.ts +8 -0
- package/dist/src/types/ResultConfig.d.mts +4 -0
- package/dist/src/types/SvgToolsOptions.d.mts +13 -0
- package/dist/src/types/SvgToolsOptions.d.ts +13 -0
- package/dist/src/types/TranscodedFont.d.mts +7 -0
- package/dist/src/types/TranscodedFont.d.ts +7 -0
- package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
- package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
- package/dist/src/types/WebfontOptions.d.mts +43 -0
- package/dist/src/types/WebfontOptions.d.ts +12 -2
- package/dist/src/types/index.d.mts +8 -0
- package/dist/src/types/index.d.ts +2 -1
- package/dist/templates/index.d.mts +19 -0
- package/package.json +42 -11
- package/templates/template.css.njk +6 -3
- package/templates/template.html.njk +15 -4
- package/templates/template.scss.njk +6 -3
- package/templates/template.styl.njk +6 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { fileURLToPath as e } from "node:url";
|
|
2
|
+
e(import.meta.url);
|
|
3
|
+
const t = e(new URL(".", import.meta.url));
|
|
4
|
+
import { t as n } from "./parseTemplateOption-Bvbie1SQ.mjs";
|
|
5
|
+
import r from "deepmerge";
|
|
6
|
+
import i from "path";
|
|
7
|
+
import a from "nunjucks";
|
|
8
|
+
//#region templates/index.ts
|
|
9
|
+
var o = () => i.resolve(t, "../templates"), s = (e) => `${o()}/template.${e}.njk`, c = () => {
|
|
10
|
+
let e = o();
|
|
11
|
+
return {
|
|
12
|
+
css: { path: i.join(e, "template.css.njk") },
|
|
13
|
+
html: { path: i.join(e, "template.html.njk") },
|
|
14
|
+
json: { path: i.join(e, "template.json.njk") },
|
|
15
|
+
scss: { path: i.join(e, "template.scss.njk") },
|
|
16
|
+
styl: { path: i.join(e, "template.styl.njk") }
|
|
17
|
+
};
|
|
18
|
+
}, l = (e) => {
|
|
19
|
+
let t = 4;
|
|
20
|
+
return e > 65535 && (t = 6), e.toString(16).toUpperCase().padStart(t, "0");
|
|
21
|
+
}, u = (e) => {
|
|
22
|
+
if (e.length === 0 || e.length > 2) return;
|
|
23
|
+
let t = e.codePointAt(0);
|
|
24
|
+
if (t !== void 0 && !(e.length > 1 && t < 128)) return t;
|
|
25
|
+
}, d = (e) => {
|
|
26
|
+
let t = [];
|
|
27
|
+
for (let n of e) for (let e of n.unicode ?? []) {
|
|
28
|
+
let n = u(e);
|
|
29
|
+
n !== void 0 && t.push(n);
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
}, f = (e) => {
|
|
33
|
+
let t = d(e);
|
|
34
|
+
if (t.length === 0) return;
|
|
35
|
+
let n = Math.min(...t), r = Math.max(...t);
|
|
36
|
+
return n === r ? `U+${l(n)}` : `U+${l(n)}-${l(r)}`;
|
|
37
|
+
}, p = (e, t) => {
|
|
38
|
+
if (!(e === !1 || e === void 0)) return typeof e == "string" ? e : f(t);
|
|
39
|
+
}, m = (e, t) => {
|
|
40
|
+
if (e === "woff2") {
|
|
41
|
+
if (!t.woff2) throw Error("Missing woff2 buffer for template rendering");
|
|
42
|
+
return Buffer.from(t.woff2).toString("base64");
|
|
43
|
+
}
|
|
44
|
+
let n = t[e];
|
|
45
|
+
if (!n) throw Error(`Missing ${e} buffer for template rendering`);
|
|
46
|
+
return n.toString("base64");
|
|
47
|
+
}, h = (e, o, l) => {
|
|
48
|
+
let u = n(e.template);
|
|
49
|
+
if (u.length === 0) return {
|
|
50
|
+
templates: [],
|
|
51
|
+
usedBuildInTemplate: !1
|
|
52
|
+
};
|
|
53
|
+
let d = c(), f = [], h = !1, g = {};
|
|
54
|
+
e.addHashInFontUrl && (g = { hash: o.hash });
|
|
55
|
+
let _ = o.glyphsData?.map((e) => e.metadata).filter((e) => e !== void 0) ?? [], v = r.all([
|
|
56
|
+
{ glyphs: _ },
|
|
57
|
+
e,
|
|
58
|
+
{
|
|
59
|
+
cacheString: e.templateCacheString || Date.now(),
|
|
60
|
+
className: e.templateClassName || e.fontName,
|
|
61
|
+
fontFamily: e.templateFontName || e.fontName,
|
|
62
|
+
fontPath: e.templateFontPath.replace(/\/?$/u, "/"),
|
|
63
|
+
svgFontId: e.fontId || e.fontName
|
|
64
|
+
},
|
|
65
|
+
g,
|
|
66
|
+
{ fonts: Object.fromEntries(new Map(l.map((e) => [e, () => m(e, o)]))) },
|
|
67
|
+
{ unicodeRange: p(e.unicodeRange, _) },
|
|
68
|
+
{ templateFontLigatures: e.templateFontLigatures !== !1 }
|
|
69
|
+
]);
|
|
70
|
+
for (let e of u) {
|
|
71
|
+
let n, r;
|
|
72
|
+
if (Object.keys(d).includes(e)) {
|
|
73
|
+
h = !0, r = e;
|
|
74
|
+
let o = i.resolve(t, "../..");
|
|
75
|
+
a.configure(o), n = s(e);
|
|
76
|
+
} else {
|
|
77
|
+
let t = i.resolve(e);
|
|
78
|
+
a.configure(i.dirname(t)), n = i.resolve(t);
|
|
79
|
+
}
|
|
80
|
+
f.push({
|
|
81
|
+
template: e,
|
|
82
|
+
content: a.render(n, v),
|
|
83
|
+
builtIn: r
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
templates: f,
|
|
88
|
+
usedBuildInTemplate: h
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { h as renderTemplates };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath as e } from "node:url";
|
|
3
|
+
e(import.meta.url);
|
|
4
|
+
const t = e(new URL(".", import.meta.url));
|
|
5
|
+
import { i as n, n as r, t as i } from "./parseTemplateOption-DLNu6PPx.mjs";
|
|
6
|
+
import a from "path";
|
|
7
|
+
import o from "deepmerge";
|
|
8
|
+
import s from "nunjucks";
|
|
9
|
+
//#region templates/index.ts
|
|
10
|
+
var c, l, u, d = n((() => {
|
|
11
|
+
c = () => a.resolve(t, "../templates"), l = (e) => `${c()}/template.${e}.njk`, u = () => {
|
|
12
|
+
let e = c();
|
|
13
|
+
return {
|
|
14
|
+
css: { path: a.join(e, "template.css.njk") },
|
|
15
|
+
html: { path: a.join(e, "template.html.njk") },
|
|
16
|
+
json: { path: a.join(e, "template.json.njk") },
|
|
17
|
+
scss: { path: a.join(e, "template.scss.njk") },
|
|
18
|
+
styl: { path: a.join(e, "template.styl.njk") }
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
})), f, p, m, h, g, _ = n((() => {
|
|
22
|
+
f = (e) => {
|
|
23
|
+
let t = 4;
|
|
24
|
+
return e > 65535 && (t = 6), e.toString(16).toUpperCase().padStart(t, "0");
|
|
25
|
+
}, p = (e) => {
|
|
26
|
+
if (e.length === 0 || e.length > 2) return;
|
|
27
|
+
let t = e.codePointAt(0);
|
|
28
|
+
if (t !== void 0 && !(e.length > 1 && t < 128)) return t;
|
|
29
|
+
}, m = (e) => {
|
|
30
|
+
let t = [];
|
|
31
|
+
for (let n of e) for (let e of n.unicode ?? []) {
|
|
32
|
+
let n = p(e);
|
|
33
|
+
n !== void 0 && t.push(n);
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
}, h = (e) => {
|
|
37
|
+
let t = m(e);
|
|
38
|
+
if (t.length === 0) return;
|
|
39
|
+
let n = Math.min(...t), r = Math.max(...t);
|
|
40
|
+
return n === r ? `U+${f(n)}` : `U+${f(n)}-${f(r)}`;
|
|
41
|
+
}, g = (e, t) => {
|
|
42
|
+
if (!(e === !1 || e === void 0)) return typeof e == "string" ? e : h(t);
|
|
43
|
+
};
|
|
44
|
+
})), v, y = n((() => {
|
|
45
|
+
v = (e, t) => {
|
|
46
|
+
if (e === "woff2") {
|
|
47
|
+
if (!t.woff2) throw Error("Missing woff2 buffer for template rendering");
|
|
48
|
+
return Buffer.from(t.woff2).toString("base64");
|
|
49
|
+
}
|
|
50
|
+
let n = t[e];
|
|
51
|
+
if (!n) throw Error(`Missing ${e} buffer for template rendering`);
|
|
52
|
+
return n.toString("base64");
|
|
53
|
+
};
|
|
54
|
+
})), b;
|
|
55
|
+
//#endregion
|
|
56
|
+
n((() => {
|
|
57
|
+
d(), i(), _(), y(), b = (e, n, i) => {
|
|
58
|
+
let c = r(e.template);
|
|
59
|
+
if (c.length === 0) return {
|
|
60
|
+
templates: [],
|
|
61
|
+
usedBuildInTemplate: !1
|
|
62
|
+
};
|
|
63
|
+
let d = u(), f = [], p = !1, m = {};
|
|
64
|
+
e.addHashInFontUrl && (m = { hash: n.hash });
|
|
65
|
+
let h = n.glyphsData?.map((e) => e.metadata).filter((e) => e !== void 0) ?? [], _ = o.all([
|
|
66
|
+
{ glyphs: h },
|
|
67
|
+
e,
|
|
68
|
+
{
|
|
69
|
+
cacheString: e.templateCacheString || Date.now(),
|
|
70
|
+
className: e.templateClassName || e.fontName,
|
|
71
|
+
fontFamily: e.templateFontName || e.fontName,
|
|
72
|
+
fontPath: e.templateFontPath.replace(/\/?$/u, "/"),
|
|
73
|
+
svgFontId: e.fontId || e.fontName
|
|
74
|
+
},
|
|
75
|
+
m,
|
|
76
|
+
{ fonts: Object.fromEntries(new Map(i.map((e) => [e, () => v(e, n)]))) },
|
|
77
|
+
{ unicodeRange: g(e.unicodeRange, h) },
|
|
78
|
+
{ templateFontLigatures: e.templateFontLigatures !== !1 }
|
|
79
|
+
]);
|
|
80
|
+
for (let e of c) {
|
|
81
|
+
let n, r;
|
|
82
|
+
if (Object.keys(d).includes(e)) {
|
|
83
|
+
p = !0, r = e;
|
|
84
|
+
let i = a.resolve(t, "../..");
|
|
85
|
+
s.configure(i), n = l(e);
|
|
86
|
+
} else {
|
|
87
|
+
let t = a.resolve(e);
|
|
88
|
+
s.configure(a.dirname(t)), n = a.resolve(t);
|
|
89
|
+
}
|
|
90
|
+
f.push({
|
|
91
|
+
template: e,
|
|
92
|
+
content: s.render(n, _),
|
|
93
|
+
builtIn: r
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
templates: f,
|
|
98
|
+
usedBuildInTemplate: p
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}))();
|
|
102
|
+
export { b as renderTemplates };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./parseTemplateOption-BmH_pcQh.js");let t=require("deepmerge");t=e.r(t);let n=require("path");n=e.r(n);let r=require("nunjucks");r=e.r(r);var i=()=>n.default.resolve(__dirname,`../templates`),a=e=>`${i()}/template.${e}.njk`,o=()=>{let e=i();return{css:{path:n.default.join(e,`template.css.njk`)},html:{path:n.default.join(e,`template.html.njk`)},json:{path:n.default.join(e,`template.json.njk`)},scss:{path:n.default.join(e,`template.scss.njk`)},styl:{path:n.default.join(e,`template.styl.njk`)}}},s=e=>{let t=4;return e>65535&&(t=6),e.toString(16).toUpperCase().padStart(t,`0`)},c=e=>{if(e.length===0||e.length>2)return;let t=e.codePointAt(0);if(t!==void 0&&!(e.length>1&&t<128))return t},l=e=>{let t=[];for(let n of e)for(let e of n.unicode??[]){let n=c(e);n!==void 0&&t.push(n)}return t},u=e=>{let t=l(e);if(t.length===0)return;let n=Math.min(...t),r=Math.max(...t);return n===r?`U+${s(n)}`:`U+${s(n)}-${s(r)}`},d=(e,t)=>{if(!(e===!1||e===void 0))return typeof e==`string`?e:u(t)},f=(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`)},p=(i,s,c)=>{let l=e.t(i.template);if(l.length===0)return{templates:[],usedBuildInTemplate:!1};let u=o(),p=[],m=!1,h={};i.addHashInFontUrl&&(h={hash:s.hash});let g=s.glyphsData?.map(e=>e.metadata).filter(e=>e!==void 0)??[],_=t.default.all([{glyphs:g},i,{cacheString:i.templateCacheString||Date.now(),className:i.templateClassName||i.fontName,fontFamily:i.templateFontName||i.fontName,fontPath:i.templateFontPath.replace(/\/?$/u,`/`),svgFontId:i.fontId||i.fontName},h,{fonts:Object.fromEntries(new Map(c.map(e=>[e,()=>f(e,s)])))},{unicodeRange:d(i.unicodeRange,g)},{templateFontLigatures:i.templateFontLigatures!==!1}]);for(let e of l){let t,i;if(Object.keys(u).includes(e)){m=!0,i=e;let o=n.default.resolve(__dirname,`../..`);r.default.configure(o),t=a(e)}else{let i=n.default.resolve(e);r.default.configure(n.default.dirname(i)),t=n.default.resolve(i)}p.push({template:e,content:r.default.render(t,_),builtIn:i})}return{templates:p,usedBuildInTemplate:m}};exports.renderTemplates=p;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { webfont } from './standalone/index.mjs';
|
|
2
|
+
export { diagnoseGlyphsData, diagnoseSvgContents } from './lib/svgDiagnostics/diagnoseSvgContents.mjs';
|
|
3
|
+
export { webfont } from './standalone/index.mjs';
|
|
4
|
+
export type { SvgDiagnosticCode, SvgGlyphDiagnostic, SvgToolsOptions } from './types/SvgToolsOptions.mjs';
|
|
5
|
+
export default webfont;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { webfont } from './standalone';
|
|
2
|
+
export { diagnoseGlyphsData, diagnoseSvgContents } from './lib/svgDiagnostics/diagnoseSvgContents';
|
|
2
3
|
export { webfont } from './standalone';
|
|
4
|
+
export type { SvgDiagnosticCode, SvgGlyphDiagnostic, SvgToolsOptions } from './types/SvgToolsOptions';
|
|
3
5
|
export default webfont;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExecException } from 'child_process';
|
|
2
|
+
export type Output = {
|
|
3
|
+
code?: number;
|
|
4
|
+
error: ExecException | null;
|
|
5
|
+
files: string[];
|
|
6
|
+
stderr?: string;
|
|
7
|
+
stdout?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ExecCLI = (_args?: string, _destination?: string) => Promise<Output>;
|
|
10
|
+
/**
|
|
11
|
+
* @name execCLI
|
|
12
|
+
* @description Execute webfont CLI commands using child_process.
|
|
13
|
+
*
|
|
14
|
+
* @param {String} args - Arguments to pass to the CLI.
|
|
15
|
+
* @param {String} destination - Path to read/write files
|
|
16
|
+
* @return {Promise.<Object>} - Contains CLI error, stdout, stderr data.
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* execCLI("--help").then((output) => {
|
|
20
|
+
* console.log(output.stdout) // => Outputs usage information.
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare const execCLI: ExecCLI;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const getInputExtension: (source: string) => string;
|
|
1
|
+
export { getInputExtension, getWebfontSourceBasename, isHttpUrl, resolveDecompressedFontBasenames, } from './inputSourceUtils';
|
|
3
2
|
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,4 @@
|
|
|
1
|
+
export declare const isHttpUrl: (value: string) => boolean;
|
|
2
|
+
export declare const getInputExtension: (source: string) => string;
|
|
3
|
+
export declare const getWebfontSourceBasename: (source: string) => string;
|
|
4
|
+
export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const isHttpUrl: (value: string) => boolean;
|
|
2
|
+
export declare const getInputExtension: (source: string) => string;
|
|
3
|
+
export declare const getWebfontSourceBasename: (source: string) => string;
|
|
4
|
+
export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Glyph count above which OpenType ligatures often hurt browser layout (Firefox / DirectWrite). */
|
|
2
|
+
export declare const LARGE_FONT_LIGATURE_GLYPH_THRESHOLD = 2000;
|
|
3
|
+
export declare const shouldWarnLargeFontLigatures: (glyphCount: number, ligaturesEnabled: boolean) => boolean;
|
|
4
|
+
export declare const formatLargeFontLigatureWarning: (glyphCount: number) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Glyph count above which OpenType ligatures often hurt browser layout (Firefox / DirectWrite). */
|
|
2
|
+
export declare const LARGE_FONT_LIGATURE_GLYPH_THRESHOLD = 2000;
|
|
3
|
+
export declare const shouldWarnLargeFontLigatures: (glyphCount: number, ligaturesEnabled: boolean) => boolean;
|
|
4
|
+
export declare const formatLargeFontLigatureWarning: (glyphCount: number) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Config } from 'svgo';
|
|
2
|
+
/** Conservative SVGO preset: cleanup cruft without rewriting paths or removing viewBox. */
|
|
3
|
+
export declare const defaultWebfontSvgoConfig: () => Config;
|
|
4
|
+
export declare const optimizeSvgContents: (contents: string, srcPath: string, config?: Config) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Config } from 'svgo';
|
|
2
|
+
/** Conservative SVGO preset: cleanup cruft without rewriting paths or removing viewBox. */
|
|
3
|
+
export declare const defaultWebfontSvgoConfig: () => Config;
|
|
4
|
+
export declare const optimizeSvgContents: (contents: string, srcPath: string, config?: Config) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Format, Formats } from '../types/Format.mjs';
|
|
2
|
+
export declare const assertValidFormat: (value: unknown) => Format;
|
|
3
|
+
export declare const parseFormatsList: (values: readonly unknown[]) => Formats;
|
|
4
|
+
export declare const assertFormatsOption: (formats: unknown) => Formats;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Format, Formats } from '../types/Format';
|
|
2
|
+
export declare const assertValidFormat: (value: unknown) => Format;
|
|
3
|
+
export declare const parseFormatsList: (values: readonly unknown[]) => Formats;
|
|
4
|
+
export declare const assertFormatsOption: (formats: unknown) => Formats;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions.mjs';
|
|
2
|
+
export declare const hasStrokeOnlySvg: (svgContents: string) => boolean;
|
|
3
|
+
export declare const hasUnsupportedSvgElements: (svgContents: string) => boolean;
|
|
4
|
+
export declare const hasUseReference: (svgContents: string) => boolean;
|
|
5
|
+
export declare const diagnoseSvgContents: (srcPath: string, svgContents: string) => SvgGlyphDiagnostic[];
|
|
6
|
+
export declare const diagnoseGlyphsData: (glyphs: ReadonlyArray<{
|
|
7
|
+
contents: string;
|
|
8
|
+
srcPath: string;
|
|
9
|
+
}>) => SvgGlyphDiagnostic[];
|
|
10
|
+
export declare const shouldLogDiagnostic: (diagnostic: SvgGlyphDiagnostic, options: {
|
|
11
|
+
diagnose?: boolean;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions';
|
|
2
|
+
export declare const hasStrokeOnlySvg: (svgContents: string) => boolean;
|
|
3
|
+
export declare const hasUnsupportedSvgElements: (svgContents: string) => boolean;
|
|
4
|
+
export declare const hasUseReference: (svgContents: string) => boolean;
|
|
5
|
+
export declare const diagnoseSvgContents: (srcPath: string, svgContents: string) => SvgGlyphDiagnostic[];
|
|
6
|
+
export declare const diagnoseGlyphsData: (glyphs: ReadonlyArray<{
|
|
7
|
+
contents: string;
|
|
8
|
+
srcPath: string;
|
|
9
|
+
}>) => SvgGlyphDiagnostic[];
|
|
10
|
+
export declare const shouldLogDiagnostic: (diagnostic: SvgGlyphDiagnostic, options: {
|
|
11
|
+
diagnose?: boolean;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
export declare const findEmptySvgFontGlyphNames: (svgFont: string) => string[];
|
|
3
|
+
export declare const assertNonEmptySvgFontGlyphs: (svgFont: string, glyphsData: ReadonlyArray<Pick<GlyphData, "metadata" | "srcPath">>) => void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData';
|
|
2
|
+
export declare const findEmptySvgFontGlyphNames: (svgFont: string) => string[];
|
|
3
|
+
export declare const assertNonEmptySvgFontGlyphs: (svgFont: string, glyphsData: ReadonlyArray<Pick<GlyphData, "metadata" | "srcPath">>) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions.mjs';
|
|
3
|
+
export type SvgToolsReporter = (message: string) => void;
|
|
4
|
+
export type ApplySvgDiagnosticsResult = {
|
|
5
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
6
|
+
glyphs: GlyphData[];
|
|
7
|
+
};
|
|
8
|
+
export declare const applySvgDiagnosticsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: {
|
|
9
|
+
diagnose?: boolean;
|
|
10
|
+
} | undefined, runtime?: {
|
|
11
|
+
reporter?: SvgToolsReporter;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => ApplySvgDiagnosticsResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData';
|
|
2
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions';
|
|
3
|
+
export type SvgToolsReporter = (message: string) => void;
|
|
4
|
+
export type ApplySvgDiagnosticsResult = {
|
|
5
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
6
|
+
glyphs: GlyphData[];
|
|
7
|
+
};
|
|
8
|
+
export declare const applySvgDiagnosticsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: {
|
|
9
|
+
diagnose?: boolean;
|
|
10
|
+
} | undefined, runtime?: {
|
|
11
|
+
reporter?: SvgToolsReporter;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => ApplySvgDiagnosticsResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
import { SvgGlyphDiagnostic, SvgToolsOptions } from '../../types/SvgToolsOptions.mjs';
|
|
3
|
+
import { SvgToolsReporter } from './applySvgDiagnostics.mjs';
|
|
4
|
+
export type { SvgToolsReporter } from './applySvgDiagnostics.mjs';
|
|
5
|
+
export type ApplySvgToolsResult = {
|
|
6
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
7
|
+
glyphs: GlyphData[];
|
|
8
|
+
};
|
|
9
|
+
export type ApplySvgToolsRuntime = {
|
|
10
|
+
reporter?: SvgToolsReporter;
|
|
11
|
+
/** When true, logs evenodd diagnostics even if svgTools.diagnose is off (backward compatible with --verbose). */
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const applySvgToolsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: SvgToolsOptions | undefined, runtime?: ApplySvgToolsRuntime) => ApplySvgToolsResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData';
|
|
2
|
+
import { SvgGlyphDiagnostic, SvgToolsOptions } from '../../types/SvgToolsOptions';
|
|
3
|
+
import { SvgToolsReporter } from './applySvgDiagnostics';
|
|
4
|
+
export type { SvgToolsReporter } from './applySvgDiagnostics';
|
|
5
|
+
export type ApplySvgToolsResult = {
|
|
6
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
7
|
+
glyphs: GlyphData[];
|
|
8
|
+
};
|
|
9
|
+
export type ApplySvgToolsRuntime = {
|
|
10
|
+
reporter?: SvgToolsReporter;
|
|
11
|
+
/** When true, logs evenodd diagnostics even if svgTools.diagnose is off (backward compatible with --verbose). */
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const applySvgToolsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: SvgToolsOptions | undefined, runtime?: ApplySvgToolsRuntime) => ApplySvgToolsResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SVGIcons2SVGFontStreamOptions, fileSorter, getMetadataService, SVGIcons2SVGFontStream } from 'svgicons2svgfont';
|
|
2
|
+
import { WebfontOptions } from '../../types/index.mjs';
|
|
3
|
+
export { fileSorter, getMetadataService, SVGIcons2SVGFontStream };
|
|
4
|
+
type MetadataServiceOptions = {
|
|
5
|
+
prependUnicode: boolean;
|
|
6
|
+
startUnicode: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Coerce `round` for svgicons2svgfont; accepts number or numeric string (CLI/config).
|
|
11
|
+
* Returns undefined for undefined/null/empty/non-numeric/non-finite inputs.
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeRoundOption: (round: string | number | null | undefined) => number | undefined;
|
|
14
|
+
export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
|
|
@@ -6,4 +6,9 @@ type MetadataServiceOptions = {
|
|
|
6
6
|
startUnicode: number;
|
|
7
7
|
};
|
|
8
8
|
export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Coerce `round` for svgicons2svgfont; accepts number or numeric string (CLI/config).
|
|
11
|
+
* Returns undefined for undefined/null/empty/non-numeric/non-finite inputs.
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeRoundOption: (round: string | number | null | undefined) => number | undefined;
|
|
9
14
|
export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MetadataProvider } from '../../types/MetadataProvider.mjs';
|
|
2
|
+
type MetadataServiceOptions = {
|
|
3
|
+
prependUnicode: boolean;
|
|
4
|
+
startUnicode: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Browser-safe metadata lookup from a virtual `srcPath` (no `fs`, no file rename).
|
|
8
|
+
* Mirrors {@link https://github.com/nfroidure/svgicons2svgfont | svgicons2svgfont} filename rules.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createMetadataFromSrcPathService: (options?: Partial<MetadataServiceOptions>) => MetadataProvider;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MetadataProvider } from '../../types/MetadataProvider';
|
|
2
|
+
type MetadataServiceOptions = {
|
|
3
|
+
prependUnicode: boolean;
|
|
4
|
+
startUnicode: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Browser-safe metadata lookup from a virtual `srcPath` (no `fs`, no file rename).
|
|
8
|
+
* Mirrors {@link https://github.com/nfroidure/svgicons2svgfont | svgicons2svgfont} filename rules.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createMetadataFromSrcPathService: (options?: Partial<MetadataServiceOptions>) => MetadataProvider;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GlyphMetadata } from '../types/GlyphMetadata.mjs';
|
|
2
|
+
export declare const collectCodePointsFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => number[];
|
|
3
|
+
export declare const computeUnicodeRangeFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
4
|
+
export declare const resolveTemplateUnicodeRange: (unicodeRange: boolean | string | undefined, glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GlyphMetadata } from '../types/GlyphMetadata';
|
|
2
|
+
export declare const collectCodePointsFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => number[];
|
|
3
|
+
export declare const computeUnicodeRangeFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
4
|
+
export declare const resolveTemplateUnicodeRange: (unicodeRange: boolean | string | undefined, glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchWebfontFromUrl: (url: string) => Promise<Buffer>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GlyphData, WebfontOptions } from '../types';
|
|
2
|
-
type GlyphsDataGetter = (_files: Array<GlyphData["srcPath"]>, _options: WebfontOptions) =>
|
|
2
|
+
type GlyphsDataGetter = (_files: Array<GlyphData["srcPath"]>, _options: WebfontOptions) => Promise<GlyphData[]>;
|
|
3
3
|
export declare const getGlyphsData: GlyphsDataGetter;
|
|
4
4
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cosmiconfig } from 'cosmiconfig';
|
|
2
|
+
import { InitialOptions } from '../types/index.mjs';
|
|
3
|
+
import { Result } from '../types/Result.mjs';
|
|
4
|
+
type CosmiconfigLoaded = NonNullable<Awaited<ReturnType<ReturnType<typeof cosmiconfig>["search"]>>>;
|
|
5
|
+
export declare const loadWebfontConfig: (options: {
|
|
6
|
+
configFile?: string;
|
|
7
|
+
}) => Promise<CosmiconfigLoaded | Record<string, never>>;
|
|
8
|
+
type Webfont = (_initialOptions?: InitialOptions) => Promise<Result>;
|
|
9
|
+
export declare const webfont: Webfont;
|
|
10
|
+
export default webfont;
|