webfont 12.1.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.
Files changed (71) hide show
  1. package/README.md +30 -12
  2. package/dist/cli.mjs +859 -769
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +513 -0
  5. package/dist/{parseTemplateOption-5T7rSw5J.mjs → parseTemplateOption-Bvbie1SQ.mjs} +0 -1
  6. package/dist/parseTemplateOption-DLNu6PPx.mjs +38 -0
  7. package/dist/{renderTemplates-DvRlS58E.mjs → renderTemplates-Biyrk6t-.mjs} +16 -17
  8. package/dist/renderTemplates-CXVKq3Op.mjs +102 -0
  9. package/dist/src/browser.d.mts +2 -0
  10. package/dist/src/index.d.mts +5 -0
  11. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.mts +3 -0
  12. package/dist/src/lib/evenoddFillRule.d.mts +2 -0
  13. package/dist/src/lib/execCLI/index.d.mts +24 -0
  14. package/dist/src/lib/inputSource.d.mts +2 -0
  15. package/dist/src/lib/inputSourceUtils.d.mts +4 -0
  16. package/dist/src/lib/largeFontLigatures.d.mts +4 -0
  17. package/dist/src/lib/optimizeSvgGlyphs.d.mts +4 -0
  18. package/dist/src/lib/p-limit/index.d.mts +2 -0
  19. package/dist/src/lib/parseFormats.d.mts +4 -0
  20. package/dist/src/lib/parseTemplateOption.d.mts +2 -0
  21. package/dist/src/lib/runtimeEnvironment.d.mts +4 -0
  22. package/dist/src/lib/sfnt/flavor.d.mts +2 -0
  23. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.mts +13 -0
  24. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +1 -0
  25. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.mts +3 -0
  26. package/dist/src/lib/svgTools/applySvgDiagnostics.d.mts +13 -0
  27. package/dist/src/lib/svgTools/applySvgTools.d.mts +14 -0
  28. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.mts +2 -0
  29. package/dist/src/lib/svgicons2svgfont/index.d.mts +14 -0
  30. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.mts +11 -0
  31. package/dist/src/lib/templateUnicodeRange.d.mts +4 -0
  32. package/dist/src/lib/ttf2eot/index.d.mts +2 -0
  33. package/dist/src/lib/ttfEncode.d.mts +5 -0
  34. package/dist/src/standalone/convertTtfInput.d.mts +3 -0
  35. package/dist/src/standalone/convertWebfontInput.d.mts +3 -0
  36. package/dist/src/standalone/defaultOptions.d.mts +3 -0
  37. package/dist/src/standalone/fetchWebfontUrl.d.mts +1 -0
  38. package/dist/src/standalone/generateSvgFont.d.mts +2 -0
  39. package/dist/src/standalone/getGlyphsDataFromInputs.d.mts +3 -0
  40. package/dist/src/standalone/glyphsData.d.mts +4 -0
  41. package/dist/src/standalone/index.d.mts +10 -0
  42. package/dist/src/standalone/inputMode.d.mts +9 -0
  43. package/dist/src/standalone/options.d.mts +5 -0
  44. package/dist/src/standalone/optionsFromGlyphs.d.mts +3 -0
  45. package/dist/src/standalone/renderTemplates.d.mts +10 -0
  46. package/dist/src/standalone/runSvgPipeline.d.mts +3 -0
  47. package/dist/src/standalone/templateFonts.d.mts +3 -0
  48. package/dist/src/standalone/toTtf.d.mts +4 -0
  49. package/dist/src/standalone/validateWebfontOptions.d.mts +6 -0
  50. package/dist/src/standalone/webfontFromGlyphs.d.mts +3 -0
  51. package/dist/src/types/DecompressedFont.d.mts +5 -0
  52. package/dist/src/types/Format.d.mts +9 -0
  53. package/dist/src/types/GlyphContentTransformFn.d.mts +2 -0
  54. package/dist/src/types/GlyphData.d.mts +6 -0
  55. package/dist/src/types/GlyphInput.d.mts +6 -0
  56. package/dist/src/types/GlyphMetadata.d.mts +10 -0
  57. package/dist/src/types/GlyphTransformFn.d.mts +2 -0
  58. package/dist/src/types/InitialOptions.d.mts +10 -0
  59. package/dist/src/types/MetadataProvider.d.mts +5 -0
  60. package/dist/src/types/OptionsBase.d.mts +39 -0
  61. package/dist/src/types/RenderedTemplate.d.mts +7 -0
  62. package/dist/src/types/Result.d.mts +26 -0
  63. package/dist/src/types/ResultConfig.d.mts +4 -0
  64. package/dist/src/types/SvgToolsOptions.d.mts +13 -0
  65. package/dist/src/types/SvgToolsOptions.d.ts +1 -1
  66. package/dist/src/types/TranscodedFont.d.mts +7 -0
  67. package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
  68. package/dist/src/types/WebfontOptions.d.mts +43 -0
  69. package/dist/src/types/index.d.mts +8 -0
  70. package/dist/templates/index.d.mts +19 -0
  71. package/package.json +32 -14
package/dist/cli.mjs CHANGED
@@ -2,48 +2,35 @@
2
2
  import { fileURLToPath as e } from "node:url";
3
3
  const t = e(import.meta.url);
4
4
  e(new URL(".", import.meta.url));
5
- import { t as n } from "./parseTemplateOption-5T7rSw5J.mjs";
6
- import { pathToFileURL as r } from "node:url";
7
- import i from "meow";
8
- import * as a from "fs";
9
- import { createReadStream as o } from "fs";
10
- import * as s from "path";
11
- import c from "path";
12
- import l from "resolve-from";
13
- import { globby as u } from "globby";
14
- import { cosmiconfig as d } from "cosmiconfig";
15
- import f from "deepmerge";
16
- import * as p from "fs/promises";
17
- import ee from "ttf2woff";
18
- import te from "wawoff2";
19
- import ne from "ttf2eot";
20
- import re from "fontverter";
21
- import m from "xml2js";
22
- import h from "p-limit";
23
- import { SVGIcons2SVGFontStream as g, fileSorter as _, getMetadataService as ie } from "svgicons2svgfont";
24
- import ae from "crypto";
25
- import { optimize as oe } from "svgo";
26
- import { Readable as se } from "stream";
27
- import ce from "svg2ttf";
28
- //#region \0rolldown/runtime.js
29
- var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, de = Object.getOwnPropertyNames, fe = Object.getPrototypeOf, pe = Object.prototype.hasOwnProperty, y = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), me = (e, t, n, r) => {
30
- if (t && typeof t == "object" || typeof t == "function") for (var i = de(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !pe.call(e, s) && s !== n && v(e, s, {
31
- get: ((e) => t[e]).bind(null, s),
32
- enumerable: !(r = ue(t, s)) || r.enumerable
33
- });
34
- return e;
35
- }, b = (e, t, n) => (n = e == null ? {} : le(fe(e)), me(t || !e || !e.__esModule ? v(n, "default", {
36
- value: e,
37
- enumerable: !0
38
- }) : n, e)), he = {
39
- name: "webfont",
40
- version: "12.1.0",
41
- description: "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)",
42
- directories: {
5
+ import { a as n, i as r, n as i, r as a, t as o } from "./parseTemplateOption-DLNu6PPx.mjs";
6
+ import { pathToFileURL as s } from "node:url";
7
+ import c from "meow";
8
+ import * as l from "fs";
9
+ import { createReadStream as u } from "fs";
10
+ import * as d from "path";
11
+ import f from "path";
12
+ import ee from "resolve-from";
13
+ import { globby as te } from "globby";
14
+ import { cosmiconfig as ne } from "cosmiconfig";
15
+ import re from "deepmerge";
16
+ import * as ie from "fs/promises";
17
+ import ae from "ttf2woff";
18
+ import oe from "wawoff2";
19
+ import se from "ttf2eot";
20
+ import ce from "fontverter";
21
+ import le from "xml2js";
22
+ import ue from "p-limit";
23
+ import { SVGIcons2SVGFontStream as de, fileSorter as fe, getMetadataService as pe } from "svgicons2svgfont";
24
+ import me from "crypto";
25
+ import { optimize as he } from "svgo";
26
+ import { Readable as ge } from "stream";
27
+ import _e from "svg2ttf";
28
+ //#region package.json
29
+ var ve, ye, be, xe, Se, Ce, we, Te, Ee, De, p, m, h, g, _, v, y, b, x, S, C, w, T, E, Oe, ke, Ae = r((() => {
30
+ ve = "webfont", ye = "12.1.1", be = "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)", xe = {
43
31
  lib: "dist",
44
32
  source: "src"
45
- },
46
- files: [
33
+ }, Se = [
47
34
  "dist",
48
35
  "dist/src/index.d.ts",
49
36
  "templates",
@@ -51,25 +38,30 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
51
38
  "!**/__mocks__",
52
39
  "README.md",
53
40
  "NOTICE.md"
54
- ],
55
- main: "dist/index.js",
56
- browser: "dist/browser.js",
57
- bin: "dist/cli.mjs",
58
- source: "src/index.ts",
59
- types: "dist/src/index.d.ts",
60
- typings: "dist/src/index.d.ts",
61
- exports: {
41
+ ], Ce = "commonjs", we = "dist/index.js", Te = "dist/index.mjs", Ee = "dist/browser.js", De = "dist/cli.mjs", p = "src/index.ts", m = "dist/src/index.d.ts", h = "dist/src/index.d.ts", g = {
62
42
  ".": {
43
+ browser: {
44
+ types: "./dist/src/index.d.ts",
45
+ default: "./dist/browser.js"
46
+ },
63
47
  node: {
64
- import: "./dist/index.js",
65
- require: "./dist/index.js"
48
+ import: {
49
+ types: "./dist/src/index.d.mts",
50
+ default: "./dist/index.mjs"
51
+ },
52
+ require: {
53
+ types: "./dist/src/index.d.ts",
54
+ default: "./dist/index.js"
55
+ }
66
56
  },
67
- default: "./dist/browser.js"
57
+ default: {
58
+ types: "./dist/src/index.d.ts",
59
+ default: "./dist/browser.js"
60
+ }
68
61
  },
69
62
  "./package.json": "./package.json"
70
- },
71
- scripts: {
72
- build: "vite build --mode library && vite build --mode browser && vite build --mode cli",
63
+ }, _ = {
64
+ build: "vite build --mode library && vite build --mode library-esm && vite build --mode browser && vite build --mode cli && node scripts/emit-mts-types.mjs",
73
65
  clean: "rm -rf dist/ temp/",
74
66
  demo: "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
75
67
  lint: "biome check .",
@@ -77,16 +69,19 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
77
69
  prebuild: "npm run clean && npm run lint",
78
70
  prepare: "lefthook install",
79
71
  predemo: "npm run build",
80
- prepublishOnly: "npm run build",
72
+ prepublishOnly: "npm run build && npm run test:package",
81
73
  pretest: "npm run build",
82
74
  prettify: "biome check --write .",
83
75
  test: "vitest run src",
76
+ "test:attw": "attw --pack .",
77
+ "test:pack": "node scripts/pack-smoke-test.mjs",
78
+ "test:package": "npm run test:publint && npm run test:attw && npm run test:pack",
79
+ "test:publint": "publint --level=warning",
84
80
  testc: "vitest run src --coverage",
85
81
  "test-debug": "vitest run src --no-file-parallelism",
86
82
  testu: "vitest run src -u",
87
- "deprecate-pre-12": "npm deprecate 'webfont@>=10.0.0 <12.0.0' 'Deprecated: upgrade to webfont@12. v10–11 enabled ligatures by default (browser hangs on large fonts, #558). 12.x: ligatures off, Node 12+, named import, unicode-range off, template fixes. See MIGRATION.md'"
88
- },
89
- dependencies: {
83
+ "deprecate-pre-12": "npm deprecate 'webfont@>=10.0.0 <12.0.0' 'Deprecated: upgrade to webfont@12. v10–11 enabled ligatures by default (browser hangs on large fonts, #558). 12.x: ligatures off, Node 24.14+, named import, unicode-range off, template fixes. See MIGRATION.md'"
84
+ }, v = {
90
85
  cosmiconfig: "9.0.2",
91
86
  deepmerge: "^4.2.2",
92
87
  fontverter: "2.0.0",
@@ -100,21 +95,19 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
100
95
  svgo: "4.0.1",
101
96
  ttf2eot: "3.1.0",
102
97
  ttf2woff: "^3.0.0",
103
- wawoff2: "2.0.0",
98
+ wawoff2: "2.0.1",
104
99
  xml2js: "0.6.2"
105
- },
106
- devDependencies: {
100
+ }, y = {
101
+ "@arethetypeswrong/cli": "0.18.4",
107
102
  "@biomejs/biome": "2.5.2",
108
- "@types/node": "^22.15.0",
103
+ "@types/node": "26.1.0",
109
104
  "@types/nunjucks": "3.2.6",
110
- "@types/rimraf": "latest",
111
105
  "@types/svg2ttf": "5.0.3",
112
106
  "@types/ttf2eot": "2.0.2",
113
107
  "@types/ttf2woff": "2.0.4",
114
108
  "@types/wawoff2": "1.0.2",
115
109
  "@types/xml2js": "0.4.14",
116
110
  "@vitest/coverage-v8": "4.1.9",
117
- "fast-glob": "3.2.12",
118
111
  "is-eot": "latest",
119
112
  "is-svg": "6.1.0",
120
113
  "is-ttf": "latest",
@@ -122,26 +115,20 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
122
115
  "is-woff2": "latest",
123
116
  knip: "6.24.0",
124
117
  lefthook: "2.1.9",
125
- rimraf: "latest",
118
+ publint: "0.3.21",
126
119
  typescript: "6.0.3",
127
120
  vite: "8.1.3",
128
121
  "vite-plugin-checker": "0.14.4",
129
122
  "vite-plugin-dts": "5.0.3",
130
123
  vitest: "4.1.9"
131
- },
132
- overrides: {
133
- "fast-glob": "3.2.12",
124
+ }, b = {
134
125
  minimatch: "10.2.5",
135
126
  "test-exclude": "7.0.2",
136
127
  "woff2sfnt-sfnt2woff": "1.0.0"
137
- },
138
- repository: {
128
+ }, x = {
139
129
  type: "git",
140
130
  url: "git+https://github.com/itgalaxy/webfont.git"
141
- },
142
- author: "itgalaxy <development@itgalaxy.company>",
143
- license: "MIT",
144
- contributors: [{
131
+ }, S = "itgalaxy <development@itgalaxy.company>", C = [{
145
132
  name: "Alexander Krasnoyarov",
146
133
  email: "alexander.krasnoyarov@itgalaxy.company",
147
134
  url: "https://vk.com/sterling_archer"
@@ -149,11 +136,7 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
149
136
  name: "Jimmy Andrade",
150
137
  email: "webfont@jimmyandrade.com",
151
138
  url: "https://github.com/jimmyandrade"
152
- }],
153
- bugs: { url: "https://github.com/itgalaxy/webfont/issues" },
154
- homepage: "https://github.com/itgalaxy/webfont#readme",
155
- engines: { node: ">= 24.14.0" },
156
- keywords: [
139
+ }], w = { url: "https://github.com/itgalaxy/webfont/issues" }, T = "https://github.com/itgalaxy/webfont#readme", E = { node: ">=24.14.0" }, Oe = [
157
140
  "cli",
158
141
  "standalone",
159
142
  "font",
@@ -173,721 +156,828 @@ var le = Object.create, v = Object.defineProperty, ue = Object.getOwnPropertyDes
173
156
  "scss",
174
157
  "builder",
175
158
  "generator"
176
- ]
177
- }, ge = "\n Usage: webfont [input] [options]\n\n Input: File(s) or glob(s).\n\n SVG icons: one or more `.svg` files (default pipeline).\n Webfont decompression: one or more `.woff` / `.woff2` paths, globs, or http(s) URLs.\n You must have rights to any font file you process (see NOTICE.md).\n\n If an input argument is wrapped in quotation marks, it will be passed to \"fast-glob\"\n for cross-platform glob support.\n\n Options:\n\n --config\n\n Path to a specific configuration file (JSON, YAML, or CommonJS)\n or the name of a module in `node_modules` that points to one.\n If no `--config` argument is provided, webfont will search for\n configuration files in the following places, in this order:\n - a `webfont` property in `package.json`\n - a `.webfontrc` file (with or without filename extension:\n `.json`, `.yaml`, and `.js` are available)\n - a `webfont.config.js` file exporting a JS object\n The search will begin in the working directory and move up the\n directory tree until a configuration file is found.\n\n -u, --fontName\n\n The font family name you want, default: \"webfont\".\n\n -h, --help\n\n Output usage information.\n\n -v, --version\n\n Output the version number.\n\n -f, --formats\n\n Font formats to generate. Pass a JSON array (e.g. '[\"woff2\"]') or a\n comma-separated list (e.g. woff2 or svg, ttf, woff2).\n SVG input: svg, ttf, eot, woff, woff2 (not otf).\n WOFF/WOFF2 input: ttf and/or otf matching the embedded SFNT flavor.\n\n -d, --dest\n\n Destination for generated fonts.\n\n -m, --dest-create\n\n Create destination directory if it does not exist.\n\n -t, --template\n\n Built-in template name(s) ('css', 'scss', 'styl', 'html', 'json') or path to a custom template.\n Pass a JSON array (e.g. '[\"html\",\"scss\"]') or comma-separated list for multiple outputs.\n\n -s, --destTemplate\n\n Destination for generated template. If not passed used `dest` argument value.\n\n -c, --templateClassName\n\n Class name in css template.\n\n -p, --templateFontPath\n\n Font path in css template.\n\n -n, --templateFontName\n\n Font name in css template.\n\n --templateCacheString\n\n Specify cache string in scss/css template.\n\n --no-sort\n\n Keeps the files in the same order of entry\n\n --ligatures\n\n Add OpenType ligature glyphs (icon names as text). Off by default — large\n icon sets can hang Firefox on Windows (#558). Prefer class + codepoint CSS.\n\n --unicode-range\n\n Emit unicode-range in built-in @font-face rules (computed from glyph code points).\n Off by default — enabling may prevent ligature names from rendering; see README.\n\n --no-template-font-ligatures\n\n Omit font-feature-settings: \"liga\" from the built-in HTML preview template\n\n --optimize-svg\n\n Run a conservative SVGO pass on each SVG before font generation\n (does not convert strokes to fills; use glyphContentTransformFn for that)\n\n --verbose\n\n Tell me everything!.\n\n --svg-diagnose\n\n (Alpha) Scan SVG icons for icon-font incompatibilities (stroke-only paths,\n fill-rule: evenodd, unsupported elements) and log warnings.\n\n For \"svgicons2svgfont\":\n\n --fontId\n\n The font id you want, default as \"--fontName\".\n\n --fontStyle\n\n The font style you want.\n\n --fontWeight\n\n The font weight you want.\n\n --fixedWidth\n\n Creates a monospace font of the width of the largest input icon.\n\n --centerHorizontally\n\n Calculate the bounds of a glyph and center it horizontally.\n\n --normalize\n\n Normalize icons by scaling them to the height of the highest icon.\n\n --fontHeight\n\n The outputted font height [MAX(icons.height)].\n\n --round\n\n Setup the SVG path rounding [10e12].\n\n --descent\n\n The font descent [0].\n\n --ascent\n\n The font ascent [height - descent].\n\n --startUnicode\n\n The start unicode codepoint for files without prefix [0xEA01].\n\n --prependUnicode\n\n Prefix files with their automatically allocated unicode codepoint.\n\n --metadata\n\n Content of the metadata tag.\n\n --addHashInFontUrl\n\n Append an MD5 content hash to font URLs in built-in templates\n (?v=[hash]) while keeping output filenames stable (fontName.woff2, etc.).\n Use with a fixed fontName — do not randomize fontName for cache busting.\n", _e = {
178
- ascent: { type: "string" },
179
- centerHorizontally: { type: "boolean" },
180
- config: { type: "string" },
181
- descent: { type: "string" },
182
- dest: {
183
- shortFlag: "d",
184
- default: process.cwd(),
185
- type: "string"
186
- },
187
- destCreate: {
188
- shortFlag: "m",
189
- default: !1,
190
- type: "boolean"
191
- },
192
- destTemplate: {
193
- shortFlag: "s",
194
- type: "string"
195
- },
196
- fixedWidth: { type: "boolean" },
197
- fontHeight: { type: "string" },
198
- fontId: { type: "string" },
199
- fontName: {
200
- shortFlag: "u",
201
- type: "string"
202
- },
203
- fontStyle: { type: "string" },
204
- fontWeight: { type: "string" },
205
- formats: {
206
- shortFlag: "f",
207
- type: "string"
208
- },
209
- help: {
210
- shortFlag: "h",
211
- type: "boolean"
212
- },
213
- ligatures: {
214
- default: !1,
215
- type: "boolean"
216
- },
217
- metadata: { type: "string" },
218
- normalize: { type: "boolean" },
219
- prependUnicode: { type: "boolean" },
220
- round: { type: "string" },
221
- sort: {
222
- default: !0,
223
- type: "boolean"
224
- },
225
- startUnicode: { type: "string" },
226
- template: {
227
- shortFlag: "t",
228
- type: "string"
229
- },
230
- templateClassName: {
231
- shortFlag: "c",
232
- type: "string"
233
- },
234
- templateFontName: {
235
- shortFlag: "n",
236
- type: "string"
237
- },
238
- addHashInFontUrl: {
239
- default: !1,
240
- type: "boolean"
241
- },
242
- optimizeSvg: {
243
- default: !1,
244
- type: "boolean"
245
- },
246
- templateFontPath: {
247
- shortFlag: "p",
248
- type: "string"
249
- },
250
- templateCacheString: {
251
- default: "",
252
- type: "string"
253
- },
254
- unicodeRange: {
255
- default: !1,
256
- type: "boolean"
257
- },
258
- templateFontLigatures: {
259
- default: !0,
260
- type: "boolean"
261
- },
262
- verbose: {
263
- default: !1,
264
- type: "boolean"
265
- },
266
- svgDiagnose: {
267
- default: !1,
268
- type: "boolean"
269
- },
270
- version: {
271
- shortFlag: "v",
272
- type: "boolean"
273
- }
274
- }, ve = { url: r(t).href }, ye = ((e = process.argv.slice(2)) => i(ge, {
275
- argv: [...e],
276
- autoHelp: !1,
277
- autoVersion: !1,
278
- flags: _e,
279
- importMeta: ve,
280
- pkg: he
281
- }))(), be = /^https?:\/\//iu, x = (e) => be.test(e), S = (e) => {
282
- if (x(e)) try {
283
- return c.extname(new URL(e).pathname).toLowerCase();
284
- } catch {
285
- return "";
286
- }
287
- return c.extname(e).toLowerCase();
288
- }, C = (e) => {
289
- let t = e;
290
- x(e) && (t = new URL(e).pathname);
291
- let n = c.basename(t), r = S(e);
292
- return r === ".woff2" ? n.slice(0, -6) : r === ".woff" ? n.slice(0, -5) : n.replace(/\.[^.]+$/u, "");
293
- }, w = {
294
- ".woff": "-woff",
295
- ".woff2": "-woff2"
296
- }, T = (e) => {
297
- let t = e.map((e) => C(e)), n = /* @__PURE__ */ new Map();
298
- for (let e of t) n.set(e, (n.get(e) ?? 0) + 1);
299
- return e.map((e, r) => {
300
- let i = t[r], a = (n.get(i) ?? 0) > 1, o = S(e);
301
- return a ? `${i}${w[o] ?? `-${r + 1}`}` : i;
159
+ ], ke = {
160
+ name: ve,
161
+ version: ye,
162
+ description: be,
163
+ directories: xe,
164
+ files: Se,
165
+ type: Ce,
166
+ sideEffects: !1,
167
+ main: we,
168
+ module: Te,
169
+ browser: Ee,
170
+ bin: De,
171
+ source: p,
172
+ types: m,
173
+ typings: h,
174
+ exports: g,
175
+ scripts: _,
176
+ dependencies: v,
177
+ devDependencies: y,
178
+ overrides: b,
179
+ repository: x,
180
+ author: S,
181
+ license: "MIT",
182
+ contributors: C,
183
+ bugs: w,
184
+ homepage: T,
185
+ engines: E,
186
+ keywords: Oe
187
+ };
188
+ })), je, Me, Ne = r((() => {
189
+ je = "\n Usage: webfont [input] [options]\n\n Input: File(s) or glob(s).\n\n SVG icons: one or more `.svg` files (default pipeline).\n Webfont decompression: one or more `.woff` / `.woff2` paths, globs, or http(s) URLs.\n You must have rights to any font file you process (see NOTICE.md).\n\n If an input argument is wrapped in quotation marks, it will be passed to \"fast-glob\"\n for cross-platform glob support.\n\n Options:\n\n --config\n\n Path to a specific configuration file (JSON, YAML, or CommonJS)\n or the name of a module in `node_modules` that points to one.\n If no `--config` argument is provided, webfont will search for\n configuration files in the following places, in this order:\n - a `webfont` property in `package.json`\n - a `.webfontrc` file (with or without filename extension:\n `.json`, `.yaml`, and `.js` are available)\n - a `webfont.config.js` file exporting a JS object\n The search will begin in the working directory and move up the\n directory tree until a configuration file is found.\n\n -u, --fontName\n\n The font family name you want, default: \"webfont\".\n\n -h, --help\n\n Output usage information.\n\n -v, --version\n\n Output the version number.\n\n -f, --formats\n\n Font formats to generate. Pass a JSON array (e.g. '[\"woff2\"]') or a\n comma-separated list (e.g. woff2 or svg, ttf, woff2).\n SVG input: svg, ttf, eot, woff, woff2 (not otf).\n WOFF/WOFF2 input: ttf and/or otf matching the embedded SFNT flavor.\n\n -d, --dest\n\n Destination for generated fonts.\n\n -m, --dest-create\n\n Create destination directory if it does not exist.\n\n -t, --template\n\n Built-in template name(s) ('css', 'scss', 'styl', 'html', 'json') or path to a custom template.\n Pass a JSON array (e.g. '[\"html\",\"scss\"]') or comma-separated list for multiple outputs.\n\n -s, --destTemplate\n\n Destination for generated template. If not passed used `dest` argument value.\n\n -c, --templateClassName\n\n Class name in css template.\n\n -p, --templateFontPath\n\n Font path in css template.\n\n -n, --templateFontName\n\n Font name in css template.\n\n --templateCacheString\n\n Specify cache string in scss/css template.\n\n --no-sort\n\n Keeps the files in the same order of entry\n\n --ligatures\n\n Add OpenType ligature glyphs (icon names as text). Off by default — large\n icon sets can hang Firefox on Windows (#558). Prefer class + codepoint CSS.\n\n --unicode-range\n\n Emit unicode-range in built-in @font-face rules (computed from glyph code points).\n Off by default — enabling may prevent ligature names from rendering; see README.\n\n --no-template-font-ligatures\n\n Omit font-feature-settings: \"liga\" from the built-in HTML preview template\n\n --optimize-svg\n\n Run a conservative SVGO pass on each SVG before font generation\n (does not convert strokes to fills; use glyphContentTransformFn for that)\n\n --verbose\n\n Tell me everything!.\n\n --svg-diagnose\n\n (Alpha) Scan SVG icons for icon-font incompatibilities (stroke-only paths,\n fill-rule: evenodd, unsupported elements) and log warnings.\n\n For \"svgicons2svgfont\":\n\n --fontId\n\n The font id you want, default as \"--fontName\".\n\n --fontStyle\n\n The font style you want.\n\n --fontWeight\n\n The font weight you want.\n\n --fixedWidth\n\n Creates a monospace font of the width of the largest input icon.\n\n --centerHorizontally\n\n Calculate the bounds of a glyph and center it horizontally.\n\n --normalize\n\n Normalize icons by scaling them to the height of the highest icon.\n\n --fontHeight\n\n The outputted font height [MAX(icons.height)].\n\n --round\n\n Setup the SVG path rounding [10e12].\n\n --descent\n\n The font descent [0].\n\n --ascent\n\n The font ascent [height - descent].\n\n --startUnicode\n\n The start unicode codepoint for files without prefix [0xEA01].\n\n --prependUnicode\n\n Prefix files with their automatically allocated unicode codepoint.\n\n --metadata\n\n Content of the metadata tag.\n\n --addHashInFontUrl\n\n Append an MD5 content hash to font URLs in built-in templates\n (?v=[hash]) while keeping output filenames stable (fontName.woff2, etc.).\n Use with a fixed fontName — do not randomize fontName for cache busting.\n", Me = {
190
+ ascent: { type: "string" },
191
+ centerHorizontally: { type: "boolean" },
192
+ config: { type: "string" },
193
+ descent: { type: "string" },
194
+ dest: {
195
+ shortFlag: "d",
196
+ default: process.cwd(),
197
+ type: "string"
198
+ },
199
+ destCreate: {
200
+ shortFlag: "m",
201
+ default: !1,
202
+ type: "boolean"
203
+ },
204
+ destTemplate: {
205
+ shortFlag: "s",
206
+ type: "string"
207
+ },
208
+ fixedWidth: { type: "boolean" },
209
+ fontHeight: { type: "string" },
210
+ fontId: { type: "string" },
211
+ fontName: {
212
+ shortFlag: "u",
213
+ type: "string"
214
+ },
215
+ fontStyle: { type: "string" },
216
+ fontWeight: { type: "string" },
217
+ formats: {
218
+ shortFlag: "f",
219
+ type: "string"
220
+ },
221
+ help: {
222
+ shortFlag: "h",
223
+ type: "boolean"
224
+ },
225
+ ligatures: {
226
+ default: !1,
227
+ type: "boolean"
228
+ },
229
+ metadata: { type: "string" },
230
+ normalize: { type: "boolean" },
231
+ prependUnicode: { type: "boolean" },
232
+ round: { type: "string" },
233
+ sort: {
234
+ default: !0,
235
+ type: "boolean"
236
+ },
237
+ startUnicode: { type: "string" },
238
+ template: {
239
+ shortFlag: "t",
240
+ type: "string"
241
+ },
242
+ templateClassName: {
243
+ shortFlag: "c",
244
+ type: "string"
245
+ },
246
+ templateFontName: {
247
+ shortFlag: "n",
248
+ type: "string"
249
+ },
250
+ addHashInFontUrl: {
251
+ default: !1,
252
+ type: "boolean"
253
+ },
254
+ optimizeSvg: {
255
+ default: !1,
256
+ type: "boolean"
257
+ },
258
+ templateFontPath: {
259
+ shortFlag: "p",
260
+ type: "string"
261
+ },
262
+ templateCacheString: {
263
+ default: "",
264
+ type: "string"
265
+ },
266
+ unicodeRange: {
267
+ default: !1,
268
+ type: "boolean"
269
+ },
270
+ templateFontLigatures: {
271
+ default: !0,
272
+ type: "boolean"
273
+ },
274
+ verbose: {
275
+ default: !1,
276
+ type: "boolean"
277
+ },
278
+ svgDiagnose: {
279
+ default: !1,
280
+ type: "boolean"
281
+ },
282
+ version: {
283
+ shortFlag: "v",
284
+ type: "boolean"
285
+ }
286
+ };
287
+ })), Pe, Fe, Ie = r((() => {
288
+ Ae(), Ne(), Pe = { url: s(t).href }, Fe = (e = process.argv.slice(2)) => c(je, {
289
+ argv: [...e],
290
+ autoHelp: !1,
291
+ autoVersion: !1,
292
+ flags: Me,
293
+ importMeta: Pe,
294
+ pkg: ke
302
295
  });
303
- }, E = async (e) => (await Promise.all(e.map((e) => x(e) ? Promise.resolve([e]) : u(e)))).flat(), D = 1330926671, O = 1953658213, k = 65536, A = (e) => {
304
- if (e.length < 4) throw Error("SFNT buffer is too short to read flavor");
305
- let t = e.readUInt32BE(0);
306
- if (t === D) return "otf";
307
- if (t === O || t === k) return "ttf";
308
- throw Error(`Unsupported SFNT flavor 0x${t.toString(16)}`);
309
- }, j = (e) => Buffer.from(ne(e)), M = (e) => j(e), N = (e, t = {}) => Buffer.from(ee(e, t).buffer), P = async (e) => Buffer.from(await te.compress(e)), F = /* @__PURE__ */ new Set([".woff", ".woff2"]), I = ".svg", L = ".ttf", R = [
310
- "svg",
311
- "ttf",
312
- "eot",
313
- "woff",
314
- "woff2"
315
- ], z = (e) => e === I, B = (e) => e === L, V = (e) => F.has(e), xe = (e) => z(e) || V(e) || B(e), Se = (e) => {
316
- if (e.length === 0) return "empty";
317
- let t = e.map((e) => S(e));
318
- if (!t.every(xe)) return "empty";
319
- let n = t.some(z), r = t.some(V), i = t.some(B);
320
- return [
321
- n,
322
- r,
323
- i
324
- ].filter(Boolean).length > 1 ? "mixed" : r ? "webfont" : i ? "ttf" : n ? "svg" : "empty";
325
- }, Ce = (e) => {
326
- 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.");
327
- }, H = (e, t) => t === "svg" ? e.filter((e) => S(e) === I) : t === "webfont" ? e.filter((e) => F.has(S(e))) : t === "ttf" ? e.filter((e) => S(e) === L) : [], we = /* @__PURE__ */ new Set([
328
- "ttf",
329
- "eot",
330
- "woff",
331
- "woff2"
332
- ]), Te = (e) => {
333
- let t = e.filter((e) => we.has(e));
334
- if (e.length === R.length && R.every((t) => e.includes(t))) return ["woff", "woff2"];
335
- if (t.length === 0) throw Error("formats must include at least one of \"ttf\", \"eot\", \"woff\", or \"woff2\" when converting TTF input");
336
- return [...new Set(t)];
337
- }, Ee = (e) => {
338
- let t = e.filter((e) => e === "ttf" || e === "otf");
339
- if (e.length === R.length && R.every((t) => e.includes(t))) return ["ttf"];
340
- if (t.length === 0) throw Error("formats must include \"ttf\" and/or \"otf\" when converting WOFF/WOFF2 input");
341
- return [...new Set(t)];
342
- }, De = (e) => {
343
- if (e.length === 0) throw Error("No TTF files matched");
344
- }, Oe = (e) => {
345
- if (e.template) throw Error("Templates are not supported when converting TTF input");
346
- if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting TTF input");
347
- if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting TTF input");
348
- }, ke = (e, t) => {
349
- let n;
350
- try {
351
- n = A(e);
352
- } catch {
353
- throw Error(`Input is not a valid TrueType font: ${t}`);
354
- }
355
- if (n !== "ttf") throw Error(`OpenType (OTF) input is not supported for webfont encoding. Use a .ttf file for ${t}.`);
356
- }, Ae = async (e, t, n, r) => {
357
- if (n === "ttf") {
358
- e.ttf = t;
359
- return;
360
- }
361
- if (n === "eot") {
362
- e.eot = M(t);
363
- return;
364
- }
365
- if (n === "woff") {
296
+ })), Le, Re = r((() => {
297
+ Ie(), Ne(), Le = Fe();
298
+ })), ze, D, O, Be, Ve, He, k = r((() => {
299
+ ze = /^https?:\/\//iu, D = (e) => ze.test(e), O = (e) => {
300
+ if (D(e)) try {
301
+ return f.extname(new URL(e).pathname).toLowerCase();
302
+ } catch {
303
+ return "";
304
+ }
305
+ return f.extname(e).toLowerCase();
306
+ }, Be = (e) => {
307
+ let t = e;
308
+ D(e) && (t = new URL(e).pathname);
309
+ let n = f.basename(t), r = O(e);
310
+ return r === ".woff2" ? n.slice(0, -6) : r === ".woff" ? n.slice(0, -5) : n.replace(/\.[^.]+$/u, "");
311
+ }, Ve = {
312
+ ".woff": "-woff",
313
+ ".woff2": "-woff2"
314
+ }, He = (e) => {
315
+ let t = e.map((e) => Be(e)), n = /* @__PURE__ */ new Map();
316
+ for (let e of t) n.set(e, (n.get(e) ?? 0) + 1);
317
+ return e.map((e, r) => {
318
+ let i = t[r], a = (n.get(i) ?? 0) > 1, o = O(e);
319
+ return a ? `${i}${Ve[o] ?? `-${r + 1}`}` : i;
320
+ });
321
+ };
322
+ })), Ue, We = r((() => {
323
+ k(), Ue = async (e) => (await Promise.all(e.map((e) => D(e) ? Promise.resolve([e]) : te(e)))).flat();
324
+ })), Ge, Ke, qe, A, Je = r((() => {
325
+ Ge = 1330926671, Ke = 1953658213, qe = 65536, A = (e) => {
326
+ if (e.length < 4) throw Error("SFNT buffer is too short to read flavor");
327
+ let t = e.readUInt32BE(0);
328
+ if (t === Ge) return "otf";
329
+ if (t === Ke || t === qe) return "ttf";
330
+ throw Error(`Unsupported SFNT flavor 0x${t.toString(16)}`);
331
+ };
332
+ })), Ye, Xe = r((() => {
333
+ Ye = (e) => Buffer.from(se(e));
334
+ })), j, M, N, Ze = r((() => {
335
+ Xe(), j = (e) => Ye(e), M = (e, t = {}) => Buffer.from(ae(e, t).buffer), N = async (e) => Buffer.from(await oe.compress(e));
336
+ })), P, F, I, L, R, z, B, Qe, $e, et, V, tt, nt, rt, H = r((() => {
337
+ k(), P = /* @__PURE__ */ new Set([".woff", ".woff2"]), F = ".svg", I = ".ttf", L = [
338
+ "svg",
339
+ "ttf",
340
+ "eot",
341
+ "woff",
342
+ "woff2"
343
+ ], R = (e) => e === F, z = (e) => e === I, B = (e) => P.has(e), Qe = (e) => R(e) || B(e) || z(e), $e = (e) => {
344
+ if (e.length === 0) return "empty";
345
+ let t = e.map((e) => O(e));
346
+ if (!t.every(Qe)) return "empty";
347
+ let n = t.some(R), r = t.some(B), i = t.some(z);
348
+ return [
349
+ n,
350
+ r,
351
+ i
352
+ ].filter(Boolean).length > 1 ? "mixed" : r ? "webfont" : i ? "ttf" : n ? "svg" : "empty";
353
+ }, et = (e) => {
354
+ 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.");
355
+ }, V = (e, t) => t === "svg" ? e.filter((e) => O(e) === F) : t === "webfont" ? e.filter((e) => P.has(O(e))) : t === "ttf" ? e.filter((e) => O(e) === I) : [], tt = /* @__PURE__ */ new Set([
356
+ "ttf",
357
+ "eot",
358
+ "woff",
359
+ "woff2"
360
+ ]), nt = (e) => {
361
+ let t = e.filter((e) => tt.has(e));
362
+ if (e.length === L.length && L.every((t) => e.includes(t))) return ["woff", "woff2"];
363
+ if (t.length === 0) throw Error("formats must include at least one of \"ttf\", \"eot\", \"woff\", or \"woff2\" when converting TTF input");
364
+ return [...new Set(t)];
365
+ }, rt = (e) => {
366
+ let t = e.filter((e) => e === "ttf" || e === "otf");
367
+ if (e.length === L.length && L.every((t) => e.includes(t))) return ["ttf"];
368
+ if (t.length === 0) throw Error("formats must include \"ttf\" and/or \"otf\" when converting WOFF/WOFF2 input");
369
+ return [...new Set(t)];
370
+ };
371
+ })), it, at, ot, st, ct, lt, ut = r((() => {
372
+ k(), Je(), Ze(), H(), it = (e) => {
373
+ if (e.length === 0) throw Error("No TTF files matched");
374
+ }, at = (e) => {
375
+ if (e.template) throw Error("Templates are not supported when converting TTF input");
376
+ if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting TTF input");
377
+ if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting TTF input");
378
+ }, ot = (e, t) => {
366
379
  let n;
367
- typeof r.metadata == "string" && (n = r.metadata), e.woff = N(t, { metadata: n });
368
- return;
369
- }
370
- e.woff2 = await P(t);
371
- }, je = async (e, t, n, r) => {
372
- if (x(e)) throw Error(`Remote TTF URLs are not supported. Download the file first: ${e}`);
373
- r && console.log(`Encoding ${e}...`);
374
- let i = await p.readFile(e);
375
- ke(i, e);
376
- let a = { source: e };
377
- return await Promise.all(t.map((e) => Ae(a, i, e, n))), a;
378
- }, Me = async (e, t) => {
379
- Oe(t), De(e);
380
- let n = Te(t.formats), r = await Promise.all(e.map((e) => je(e, n, t, t.verbose))), i = {
381
- config: { ...t },
382
- transcodedFonts: r
380
+ try {
381
+ n = A(e);
382
+ } catch {
383
+ throw Error(`Input is not a valid TrueType font: ${t}`);
384
+ }
385
+ if (n !== "ttf") throw Error(`OpenType (OTF) input is not supported for webfont encoding. Use a .ttf file for ${t}.`);
386
+ }, st = async (e, t, n, r) => {
387
+ if (n === "ttf") {
388
+ e.ttf = t;
389
+ return;
390
+ }
391
+ if (n === "eot") {
392
+ e.eot = j(t);
393
+ return;
394
+ }
395
+ if (n === "woff") {
396
+ let n;
397
+ typeof r.metadata == "string" && (n = r.metadata), e.woff = M(t, { metadata: n });
398
+ return;
399
+ }
400
+ e.woff2 = await N(t);
401
+ }, ct = async (e, t, n, r) => {
402
+ if (D(e)) throw Error(`Remote TTF URLs are not supported. Download the file first: ${e}`);
403
+ r && console.log(`Encoding ${e}...`);
404
+ let i = await ie.readFile(e);
405
+ ot(i, e);
406
+ let a = { source: e };
407
+ return await Promise.all(t.map((e) => st(a, i, e, n))), a;
408
+ }, lt = async (e, t) => {
409
+ at(t), it(e);
410
+ let n = nt(t.formats), r = await Promise.all(e.map((e) => ct(e, n, t, t.verbose))), i = {
411
+ config: { ...t },
412
+ transcodedFonts: r
413
+ };
414
+ if (r.length === 1) {
415
+ let [e] = r;
416
+ i.ttf = e.ttf, i.eot = e.eot, i.woff = e.woff, i.woff2 = e.woff2;
417
+ }
418
+ return i;
383
419
  };
384
- if (r.length === 1) {
385
- let [e] = r;
386
- i.ttf = e.ttf, i.eot = e.eot, i.woff = e.woff, i.woff2 = e.woff2;
387
- }
388
- return i;
389
- }, Ne = /* @__PURE__ */ y(((e, t) => {
420
+ })), dt = /* @__PURE__ */ a(((e, t) => {
390
421
  t.exports = function(e) {
391
422
  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;
392
423
  };
393
- })), Pe = /* @__PURE__ */ y(((e, t) => {
424
+ })), ft = /* @__PURE__ */ a(((e, t) => {
394
425
  t.exports = function(e) {
395
426
  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;
396
427
  };
397
- })), Fe = /* @__PURE__ */ b(Ne()), Ie = /* @__PURE__ */ b(Pe()), Le = (e, t) => {
398
- let n = S(t);
399
- if (n === ".woff2" && !(0, Ie.default)(e)) throw Error(`URL did not return a valid WOFF2 font: ${t}`);
400
- if (n === ".woff" && !(0, Fe.default)(e)) throw Error(`URL did not return a valid WOFF font: ${t}`);
401
- if (e.length === 0) throw Error(`URL returned an empty response: ${t}`);
402
- }, Re = async (e) => {
403
- let t;
404
- try {
405
- t = await fetch(e);
406
- } catch (t) {
407
- let n = String(t);
408
- throw t instanceof Error && (n = t.message), Error(`Failed to fetch font URL ${e}: ${n}`);
409
- }
410
- if (!t.ok) throw Error(`Failed to fetch font URL ${e}: HTTP ${t.status} ${t.statusText}`);
411
- let n = await t.arrayBuffer(), r = Buffer.from(n);
412
- return Le(r, e), r;
413
- }, ze = (e) => {
414
- if (e.length === 0) throw Error("No WOFF or WOFF2 files matched");
415
- }, Be = (e) => {
416
- if (e.template) throw Error("Templates are not supported when converting WOFF/WOFF2 input");
417
- if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting WOFF/WOFF2 input");
418
- if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting WOFF/WOFF2 input");
419
- }, Ve = (e) => {
420
- let { decompressed: t, sfnt: n, format: r, flavor: i, source: a } = e;
421
- if (r === "ttf" && i !== "ttf") throw Error(`Input decompresses to OpenType (OTF). Request "otf" format instead of "ttf" for ${a}.`);
422
- if (r === "otf" && i !== "otf") throw Error(`Input decompresses to TrueType (TTF). Request "ttf" format instead of "otf" for ${a}.`);
423
- if (r === "ttf") {
424
- t.ttf = n;
425
- return;
426
- }
427
- t.otf = n;
428
- }, He = (e) => x(e) ? Re(e) : p.readFile(e), Ue = async (e, t, n) => {
429
- n && console.log(`Decompressing ${e}...`);
430
- let r = await He(e), i = Buffer.from(await re.convert(r, "sfnt")), a = A(i), o = { source: e };
431
- for (let n of t) Ve({
432
- decompressed: o,
433
- sfnt: i,
434
- format: n,
435
- flavor: a,
436
- source: e
428
+ })), pt, mt, ht, gt, _t = r((() => {
429
+ pt = /* @__PURE__ */ n(dt()), mt = /* @__PURE__ */ n(ft()), k(), ht = (e, t) => {
430
+ let n = O(t);
431
+ if (n === ".woff2" && !(0, mt.default)(e)) throw Error(`URL did not return a valid WOFF2 font: ${t}`);
432
+ if (n === ".woff" && !(0, pt.default)(e)) throw Error(`URL did not return a valid WOFF font: ${t}`);
433
+ if (e.length === 0) throw Error(`URL returned an empty response: ${t}`);
434
+ }, gt = async (e) => {
435
+ let t;
436
+ try {
437
+ t = await fetch(e);
438
+ } catch (t) {
439
+ let n = String(t);
440
+ throw t instanceof Error && (n = t.message), Error(`Failed to fetch font URL ${e}: ${n}`);
441
+ }
442
+ if (!t.ok) throw Error(`Failed to fetch font URL ${e}: HTTP ${t.status} ${t.statusText}`);
443
+ let n = await t.arrayBuffer(), r = Buffer.from(n);
444
+ return ht(r, e), r;
445
+ };
446
+ })), vt, yt, bt, xt, St, Ct, wt = r((() => {
447
+ k(), Je(), _t(), H(), vt = (e) => {
448
+ if (e.length === 0) throw Error("No WOFF or WOFF2 files matched");
449
+ }, yt = (e) => {
450
+ if (e.template) throw Error("Templates are not supported when converting WOFF/WOFF2 input");
451
+ if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting WOFF/WOFF2 input");
452
+ if (e.glyphContentTransformFn) throw Error("glyphContentTransformFn is not supported when converting WOFF/WOFF2 input");
453
+ }, bt = (e) => {
454
+ let { decompressed: t, sfnt: n, format: r, flavor: i, source: a } = e;
455
+ if (r === "ttf" && i !== "ttf") throw Error(`Input decompresses to OpenType (OTF). Request "otf" format instead of "ttf" for ${a}.`);
456
+ if (r === "otf" && i !== "otf") throw Error(`Input decompresses to TrueType (TTF). Request "ttf" format instead of "otf" for ${a}.`);
457
+ if (r === "ttf") {
458
+ t.ttf = n;
459
+ return;
460
+ }
461
+ t.otf = n;
462
+ }, xt = (e) => D(e) ? gt(e) : ie.readFile(e), St = async (e, t, n) => {
463
+ n && console.log(`Decompressing ${e}...`);
464
+ let r = await xt(e), i = Buffer.from(await ce.convert(r, "sfnt")), a = A(i), o = { source: e };
465
+ for (let n of t) bt({
466
+ decompressed: o,
467
+ sfnt: i,
468
+ format: n,
469
+ flavor: a,
470
+ source: e
471
+ });
472
+ return o;
473
+ }, Ct = async (e, t) => {
474
+ yt(t), vt(e);
475
+ let n = rt(t.formats), r = await Promise.all(e.map((e) => St(e, n, t.verbose))), i = {
476
+ config: { ...t },
477
+ decompressedFonts: r
478
+ };
479
+ return r.length === 1 && (i.ttf = r[0].ttf, i.otf = r[0].otf), i;
480
+ };
481
+ })), Tt, Et = r((() => {
482
+ Tt = ue;
483
+ })), Dt, Ot, kt, At = r((() => {
484
+ Dt = (e) => ({
485
+ prependUnicode: !!e.prependUnicode,
486
+ startUnicode: Number(e.startUnicode)
487
+ }), Ot = (e) => {
488
+ if (e == null) return;
489
+ if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
490
+ let t = e.trim();
491
+ if (t.length === 0) return;
492
+ let n = Number(t);
493
+ if (Number.isFinite(n)) return n;
494
+ }, kt = (e) => ({
495
+ ascent: e.ascent,
496
+ centerHorizontally: e.centerHorizontally,
497
+ descent: e.descent,
498
+ fixedWidth: e.fixedWidth,
499
+ fontHeight: e.fontHeight,
500
+ fontId: e.fontId,
501
+ fontName: e.fontName,
502
+ fontStyle: e.fontStyle,
503
+ fontWeight: e.fontWeight,
504
+ metadata: e.metadata,
505
+ normalize: e.normalize,
506
+ round: Ot(e.round)
437
507
  });
438
- return o;
439
- }, We = async (e, t) => {
440
- Be(t), ze(e);
441
- let n = Ee(t.formats), r = await Promise.all(e.map((e) => Ue(e, n, t.verbose))), i = {
442
- config: { ...t },
443
- decompressedFonts: r
508
+ })), jt, Mt, Nt, Pt = r((() => {
509
+ Et(), At(), jt = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], Mt = (e) => ({
510
+ name: e.name,
511
+ unicode: jt(e.unicode)
512
+ }), Nt = (e, t) => {
513
+ let n = t.metadataProvider || pe(Dt(t)), r = new le.Parser(), i = Tt(t.maxConcurrency);
514
+ return Promise.all(e.map((e) => i(() => new Promise((t, n) => {
515
+ let i = u(e), a = "";
516
+ i.on("error", (e) => n(e)).on("data", (e) => {
517
+ a += e.toString();
518
+ }).on("end", () => a.length === 0 ? n(/* @__PURE__ */ Error(`Empty file ${e}`)) : r.parseString(a, (r) => r ? n(r) : t({
519
+ contents: a,
520
+ srcPath: e
521
+ })));
522
+ })))).then((e) => {
523
+ let r = e;
524
+ t.sort && (r = e.sort((e, t) => fe(e.srcPath, t.srcPath)));
525
+ let { ligatures: i } = t;
526
+ return Promise.all(r.map((e) => new Promise((t, r) => {
527
+ n(e.srcPath, (n, a) => {
528
+ if (n) return r(n);
529
+ if (!a) return r(/* @__PURE__ */ Error(`Missing metadata for ${e.srcPath}`));
530
+ let o = Mt(a);
531
+ return i && o.unicode.push(a.name.replace(/-/gu, "_")), e.metadata = o, t(e);
532
+ });
533
+ })));
534
+ });
444
535
  };
445
- return r.length === 1 && (i.ttf = r[0].ttf, i.otf = r[0].otf), i;
446
- }, Ge = h, Ke = (e) => ({
447
- prependUnicode: !!e.prependUnicode,
448
- startUnicode: Number(e.startUnicode)
449
- }), qe = (e) => {
450
- if (e == null) return;
451
- if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
452
- let t = e.trim();
453
- if (t.length === 0) return;
454
- let n = Number(t);
455
- if (Number.isFinite(n)) return n;
456
- }, Je = (e) => ({
457
- ascent: e.ascent,
458
- centerHorizontally: e.centerHorizontally,
459
- descent: e.descent,
460
- fixedWidth: e.fixedWidth,
461
- fontHeight: e.fontHeight,
462
- fontId: e.fontId,
463
- fontName: e.fontName,
464
- fontStyle: e.fontStyle,
465
- fontWeight: e.fontWeight,
466
- metadata: e.metadata,
467
- normalize: e.normalize,
468
- round: qe(e.round)
469
- }), Ye = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], Xe = (e) => ({
470
- name: e.name,
471
- unicode: Ye(e.unicode)
472
- }), Ze = (e, t) => {
473
- let n = t.metadataProvider || ie(Ke(t)), r = new m.Parser(), i = Ge(t.maxConcurrency);
474
- return Promise.all(e.map((e) => i(() => new Promise((t, n) => {
475
- let i = o(e), a = "";
476
- i.on("error", (e) => n(e)).on("data", (e) => {
477
- a += e.toString();
478
- }).on("end", () => a.length === 0 ? n(/* @__PURE__ */ Error(`Empty file ${e}`)) : r.parseString(a, (r) => r ? n(r) : t({
479
- contents: a,
480
- srcPath: e
481
- })));
482
- })))).then((e) => {
483
- let r = e;
484
- t.sort && (r = e.sort((e, t) => _(e.srcPath, t.srcPath)));
485
- let { ligatures: i } = t;
486
- return Promise.all(r.map((e) => new Promise((t, r) => {
487
- n(e.srcPath, (n, a) => {
488
- if (n) return r(n);
489
- if (!a) return r(/* @__PURE__ */ Error(`Missing metadata for ${e.srcPath}`));
490
- let o = Xe(a);
491
- return i && o.unicode.push(a.name.replace(/-/gu, "_")), e.metadata = o, t(e);
492
- });
493
- })));
536
+ })), Ft, It = r((() => {
537
+ Ft = () => ({
538
+ centerHorizontally: !1,
539
+ descent: 0,
540
+ fixedWidth: !1,
541
+ fontHeight: void 0,
542
+ fontId: void 0,
543
+ fontName: "webfont",
544
+ fontStyle: "",
545
+ fontWeight: "",
546
+ formats: [
547
+ "svg",
548
+ "ttf",
549
+ "eot",
550
+ "woff",
551
+ "woff2"
552
+ ],
553
+ formatsOptions: { ttf: {
554
+ copyright: null,
555
+ ts: null,
556
+ version: null
557
+ } },
558
+ ligatures: !1,
559
+ maxConcurrency: 100,
560
+ metadata: void 0,
561
+ normalize: !1,
562
+ prependUnicode: !1,
563
+ round: 0x9184e72a000,
564
+ sort: !0,
565
+ startUnicode: 59905,
566
+ templateFontPath: "./",
567
+ unicodeRange: !1,
568
+ verbose: !1
494
569
  });
495
- }, Qe = () => ({
496
- centerHorizontally: !1,
497
- descent: 0,
498
- fixedWidth: !1,
499
- fontHeight: void 0,
500
- fontId: void 0,
501
- fontName: "webfont",
502
- fontStyle: "",
503
- fontWeight: "",
504
- formats: [
570
+ })), Lt, Rt = r((() => {
571
+ It(), Lt = (e) => {
572
+ if (!e?.files) throw Error("You must pass webfont a `files` glob");
573
+ return {
574
+ ...Ft(),
575
+ ...e
576
+ };
577
+ };
578
+ })), zt, Bt, Vt, Ht = r((() => {
579
+ zt = () => ({
580
+ multipass: !1,
581
+ plugins: [
582
+ "removeDoctype",
583
+ "removeXMLProcInst",
584
+ "removeComments",
585
+ "removeMetadata",
586
+ "removeEditorsNSData",
587
+ "removeDesc",
588
+ "cleanupAttrs",
589
+ "removeUnusedNS"
590
+ ]
591
+ }), Bt = (e) => {
592
+ let t = zt();
593
+ return e ? {
594
+ ...t,
595
+ ...e,
596
+ plugins: e.plugins ?? t.plugins
597
+ } : t;
598
+ }, Vt = (e, t, n) => he(e, {
599
+ ...Bt(n),
600
+ path: t
601
+ }).data;
602
+ })), Ut, Wt = r((() => {
603
+ Ht(), Ut = (e, t) => e.map((e) => ({
604
+ ...e,
605
+ contents: Vt(e.contents, e.srcPath, t)
606
+ }));
607
+ })), Gt, Kt, qt = r((() => {
608
+ Gt = (e, t) => t && e > 2e3, Kt = (e) => `Warning: ${e} glyphs with ligatures enabled may cause severe browser slowdown or hangs (especially Firefox on Windows). Ligatures are off by default; enable only if needed: --ligatures or ligatures: true. See TROUBLESHOOTING.md and https://github.com/itgalaxy/webfont/issues/558`;
609
+ })), Jt, Yt, Xt, Zt, Qt, $t, en, tn = r((() => {
610
+ Jt = /<glyph\b([^>/]*)(?:\/>|>)/giu, Yt = /\bglyph-name=["']([^"']+)["']/iu, Xt = /\bd=["']([^"']*)["']/iu, Zt = (e) => {
611
+ let t = [];
612
+ for (let n of e.matchAll(Jt)) {
613
+ let e = n[1] ?? "", r = Yt.exec(e);
614
+ r && (Xt.exec(e)?.[1] ?? "").trim().length === 0 && t.push(r[1]);
615
+ }
616
+ return t;
617
+ }, Qt = (e, t) => {
618
+ for (let n of t) {
619
+ let t = n.metadata?.name;
620
+ if (t && (e === t || e.startsWith(`${t}-`))) return n.srcPath;
621
+ }
622
+ }, $t = (e, t) => {
623
+ let n = /* @__PURE__ */ new Set(), r = [];
624
+ for (let i of e) {
625
+ let e = Qt(i, t), a = e ?? i;
626
+ n.has(a) || (n.add(a), e ? r.push(`${i} (${e})`) : r.push(i));
627
+ }
628
+ return r.join("; ");
629
+ }, en = (e, t) => {
630
+ let n = Zt(e);
631
+ if (n.length === 0) return;
632
+ let r = $t(n, t);
633
+ throw Error(`Empty glyph path(s) in SVG font output for: ${r}. Stroke-only SVGs (fill="none" with stroke) often produce empty glyphs because svgicons2svgfont does not convert strokes. Convert strokes to filled paths in your design tool, preprocess with glyphContentTransformFn (for example svg-outline-stroke), or run with --svg-diagnose for compatibility warnings. See TROUBLESHOOTING.md ("Stroke-only SVGs produce blank icons").`);
634
+ };
635
+ })), nn, rn, an = r((() => {
636
+ nn = /fill-rule\s*:\s*evenodd|fill-rule\s*=\s*["']evenodd["']/iu, rn = (e) => nn.test(e);
637
+ })), on, sn, cn, ln, un, dn, fn, U, pn, mn, hn, gn = r((() => {
638
+ an(), on = /\bstroke\s*=|\bstroke\s*:/iu, sn = /fill\s*=\s*["']none["']|fill\s*:\s*none/iu, cn = /<(line|polyline|clipPath)\b/iu, ln = /<use\b/iu, un = (e) => on.test(e) ? sn.test(e) : !1, dn = (e) => cn.test(e), fn = (e) => ln.test(e), U = (e, t) => {
639
+ switch (e) {
640
+ case "evenodd-fill-rule": return `[webfont:diagnose] ${t} uses fill-rule: evenodd. Icon fonts render glyphs with the nonzero fill rule, so holes and counter-shapes can disappear. See TROUBLESHOOTING.md ("Icon details missing after export").`;
641
+ case "stroke-only": return `[webfont:diagnose] ${t} uses stroke-based paths (fill="none"). svgicons2svgfont ignores stroke; outlines may render as solid shapes or lose detail. Preprocess with glyphContentTransformFn (for example svg-outline-stroke) before conversion. See TROUBLESHOOTING.md ("Icon details missing after export").`;
642
+ case "unsupported-element": return `[webfont:diagnose] ${t} contains <line>, <polyline>, or <clipPath>. These elements are poorly supported in icon fonts; results may differ from the browser preview. Convert to filled paths or preprocess with glyphContentTransformFn.`;
643
+ case "use-reference": return `[webfont:diagnose] ${t} contains <use> (symbol/instance references). svgicons2svgfont does not resolve <use> or apply transform on references — the glyph may be empty or wrong. Flatten to paths in your editor, or preprocess with SVGO / glyphContentTransformFn before conversion. See TROUBLESHOOTING.md ("SVG transform and <use> references", #612).`;
644
+ default: return e;
645
+ }
646
+ }, pn = (e, t) => {
647
+ let n = [];
648
+ return rn(t) && n.push({
649
+ code: "evenodd-fill-rule",
650
+ message: U("evenodd-fill-rule", e),
651
+ srcPath: e
652
+ }), un(t) && n.push({
653
+ code: "stroke-only",
654
+ message: U("stroke-only", e),
655
+ srcPath: e
656
+ }), dn(t) && n.push({
657
+ code: "unsupported-element",
658
+ message: U("unsupported-element", e),
659
+ srcPath: e
660
+ }), fn(t) && n.push({
661
+ code: "use-reference",
662
+ message: U("use-reference", e),
663
+ srcPath: e
664
+ }), n;
665
+ }, mn = (e) => e.flatMap((e) => pn(e.srcPath, e.contents)), hn = (e, t) => t.diagnose ? !0 : !!(t.verbose && e.code === "evenodd-fill-rule");
666
+ })), _n, vn = r((() => {
667
+ _n = (e) => {
668
+ if (!e || !e.diagnose) return;
669
+ let t = { diagnose: !0 };
670
+ return e.onMessage && (t.onMessage = e.onMessage), t;
671
+ };
672
+ })), yn, bn = r((() => {
673
+ gn(), vn(), yn = (e, t, n = {}) => {
674
+ let r = _n(t), i = mn(e), { reporter: a, verbose: o = !1 } = n;
675
+ for (let e of i) hn(e, {
676
+ diagnose: r?.diagnose,
677
+ verbose: o
678
+ }) && a?.(e.message);
679
+ let s = [];
680
+ return r?.diagnose && (s = i), {
681
+ diagnostics: s,
682
+ glyphs: e
683
+ };
684
+ };
685
+ })), xn, Sn = r((() => {
686
+ bn(), xn = (e, t, n = {}) => {
687
+ let { diagnostics: r, glyphs: i } = yn(e, t, n);
688
+ return {
689
+ diagnostics: r,
690
+ glyphs: i
691
+ };
692
+ };
693
+ })), Cn, wn = r((() => {
694
+ At(), Cn = (e, t) => {
695
+ let n = "";
696
+ return new Promise((r, i) => {
697
+ t.verbose && console.log("Generating SVG font...");
698
+ let a = new de(kt(t)).on("finish", () => r(n)).on("data", (e) => {
699
+ n += e;
700
+ }).on("error", (e) => i(e));
701
+ e.forEach((e) => {
702
+ let t = new ge();
703
+ t.push(e.contents), t.push(null), t.metadata = e.metadata ?? {
704
+ name: "",
705
+ unicode: []
706
+ }, a.write(t);
707
+ }), a.end();
708
+ });
709
+ };
710
+ })), Tn, En = r((() => {
711
+ Tn = (e, t = {}) => Buffer.from(_e(e, t).buffer);
712
+ })), Dn, On, kn, An, jn = r((() => {
713
+ Wt(), qt(), tn(), Sn(), Ze(), wn(), En(), Dn = (e) => j(e), On = (e, t) => M(e, t), kn = (e) => N(e), An = async (e, t) => {
714
+ let n = (e) => {
715
+ if (t.svgTools?.onMessage) {
716
+ t.svgTools.onMessage(e);
717
+ return;
718
+ }
719
+ (t.svgTools?.diagnose || t.verbose) && console.log(e);
720
+ }, r = !!(t.svgTools?.onMessage || t.svgTools?.diagnose || t.verbose), i;
721
+ r && (i = n);
722
+ let { diagnostics: a, glyphs: o } = xn(e, t.svgTools, {
723
+ reporter: i,
724
+ verbose: t.verbose
725
+ }), s = o;
726
+ if (t.optimizeSvg && (s = Ut(s, t.svgoConfig)), t.glyphContentTransformFn) {
727
+ let e = t.glyphContentTransformFn;
728
+ s = await Promise.all(s.map(async (t) => {
729
+ let n = await e(t);
730
+ return {
731
+ ...t,
732
+ contents: n
733
+ };
734
+ }));
735
+ }
736
+ if (t.glyphTransformFn) {
737
+ let e = t.glyphTransformFn;
738
+ s = await Promise.all(s.map(async (t) => {
739
+ let n = await e(t.metadata ?? {
740
+ name: "",
741
+ unicode: []
742
+ });
743
+ return {
744
+ ...t,
745
+ metadata: n
746
+ };
747
+ }));
748
+ }
749
+ Gt(s.length, t.ligatures) && console.log(Kt(s.length));
750
+ let c = {};
751
+ t.formatsOptions?.ttf && (c = t.formatsOptions.ttf);
752
+ let l = await Cn(s, t);
753
+ en(l, s);
754
+ let u = Tn(l, c), d = {
755
+ config: t,
756
+ glyphsData: s,
757
+ hash: me.createHash("md5").update(l).digest("hex"),
758
+ svg: l,
759
+ ttf: u
760
+ };
761
+ a.length > 0 && (d.svgDiagnostics = a);
762
+ let { formats: f } = t;
763
+ if (f.includes("eot") && (d.eot = Dn(u)), f.includes("woff")) {
764
+ let e;
765
+ typeof t.metadata == "string" && (e = t.metadata), d.woff = On(u, { metadata: e });
766
+ }
767
+ if (f.includes("woff2") && (d.woff2 = Buffer.from(await kn(u))), t.template) {
768
+ let { renderTemplates: e } = await import("./renderTemplates-CXVKq3Op.mjs"), { templates: n, usedBuildInTemplate: r } = e(t, d, f);
769
+ n.length > 0 && (d.templates = n, d.template = n[0]?.content, d.usedBuildInTemplate = r);
770
+ }
771
+ return f.includes("svg") || delete d.svg, f.includes("ttf") || delete d.ttf, f.includes("otf") || delete d.otf, d;
772
+ };
773
+ })), W, Mn, G, K, Nn, Pn = r((() => {
774
+ W = /* @__PURE__ */ new Set([
775
+ "eot",
776
+ "otf",
505
777
  "svg",
506
778
  "ttf",
507
- "eot",
508
779
  "woff",
509
780
  "woff2"
510
- ],
511
- formatsOptions: { ttf: {
512
- copyright: null,
513
- ts: null,
514
- version: null
515
- } },
516
- ligatures: !1,
517
- maxConcurrency: 100,
518
- metadata: void 0,
519
- normalize: !1,
520
- prependUnicode: !1,
521
- round: 0x9184e72a000,
522
- sort: !0,
523
- startUnicode: 59905,
524
- templateFontPath: "./",
525
- unicodeRange: !1,
526
- verbose: !1
527
- }), $e = (e) => {
528
- if (!e?.files) throw Error("You must pass webfont a `files` glob");
529
- return {
530
- ...Qe(),
531
- ...e
532
- };
533
- }, et = () => ({
534
- multipass: !1,
535
- plugins: [
536
- "removeDoctype",
537
- "removeXMLProcInst",
538
- "removeComments",
539
- "removeMetadata",
540
- "removeEditorsNSData",
541
- "removeDesc",
542
- "cleanupAttrs",
543
- "removeUnusedNS"
544
- ]
545
- }), tt = (e) => {
546
- let t = et();
547
- return e ? {
548
- ...t,
549
- ...e,
550
- plugins: e.plugins ?? t.plugins
551
- } : t;
552
- }, nt = (e, t, n) => oe(e, {
553
- ...tt(n),
554
- path: t
555
- }).data, rt = (e, t) => e.map((e) => ({
556
- ...e,
557
- contents: nt(e.contents, e.srcPath, t)
558
- })), it = (e, t) => t && e > 2e3, at = (e) => `Warning: ${e} glyphs with ligatures enabled may cause severe browser slowdown or hangs (especially Firefox on Windows). Ligatures are off by default; enable only if needed: --ligatures or ligatures: true. See TROUBLESHOOTING.md and https://github.com/itgalaxy/webfont/issues/558`, ot = /<glyph\b([^>/]*)(?:\/>|>)/giu, st = /\bglyph-name=["']([^"']+)["']/iu, ct = /\bd=["']([^"']*)["']/iu, lt = (e) => {
559
- let t = [];
560
- for (let n of e.matchAll(ot)) {
561
- let e = n[1] ?? "", r = st.exec(e);
562
- r && (ct.exec(e)?.[1] ?? "").trim().length === 0 && t.push(r[1]);
563
- }
564
- return t;
565
- }, ut = (e, t) => {
566
- for (let n of t) {
567
- let t = n.metadata?.name;
568
- if (t && (e === t || e.startsWith(`${t}-`))) return n.srcPath;
569
- }
570
- }, dt = (e, t) => {
571
- let n = /* @__PURE__ */ new Set(), r = [];
572
- for (let i of e) {
573
- let e = ut(i, t), a = e ?? i;
574
- n.has(a) || (n.add(a), e ? r.push(`${i} (${e})`) : r.push(i));
575
- }
576
- return r.join("; ");
577
- }, ft = (e, t) => {
578
- let n = lt(e);
579
- if (n.length === 0) return;
580
- let r = dt(n, t);
581
- throw Error(`Empty glyph path(s) in SVG font output for: ${r}. Stroke-only SVGs (fill="none" with stroke) often produce empty glyphs because svgicons2svgfont does not convert strokes. Convert strokes to filled paths in your design tool, preprocess with glyphContentTransformFn (for example svg-outline-stroke), or run with --svg-diagnose for compatibility warnings. See TROUBLESHOOTING.md ("Stroke-only SVGs produce blank icons").`);
582
- }, pt = /fill-rule\s*:\s*evenodd|fill-rule\s*=\s*["']evenodd["']/iu, mt = (e) => pt.test(e), ht = /\bstroke\s*=|\bstroke\s*:/iu, gt = /fill\s*=\s*["']none["']|fill\s*:\s*none/iu, _t = /<(line|polyline|clipPath)\b/iu, vt = (e) => ht.test(e) ? gt.test(e) : !1, yt = (e) => _t.test(e), U = (e, t) => {
583
- switch (e) {
584
- case "evenodd-fill-rule": return `[webfont:diagnose] ${t} uses fill-rule: evenodd. Icon fonts render glyphs with the nonzero fill rule, so holes and counter-shapes can disappear. See TROUBLESHOOTING.md ("Icon details missing after export").`;
585
- case "stroke-only": return `[webfont:diagnose] ${t} uses stroke-based paths (fill="none"). svgicons2svgfont ignores stroke; outlines may render as solid shapes or lose detail. Preprocess with glyphContentTransformFn (for example svg-outline-stroke) before conversion. See TROUBLESHOOTING.md ("Icon details missing after export").`;
586
- case "unsupported-element": return `[webfont:diagnose] ${t} contains <line>, <polyline>, or <clipPath>. These elements are poorly supported in icon fonts; results may differ from the browser preview. Convert to filled paths or preprocess with glyphContentTransformFn.`;
587
- default: return e;
588
- }
589
- }, bt = (e, t) => {
590
- let n = [];
591
- return mt(t) && n.push({
592
- code: "evenodd-fill-rule",
593
- message: U("evenodd-fill-rule", e),
594
- srcPath: e
595
- }), vt(t) && n.push({
596
- code: "stroke-only",
597
- message: U("stroke-only", e),
598
- srcPath: e
599
- }), yt(t) && n.push({
600
- code: "unsupported-element",
601
- message: U("unsupported-element", e),
602
- srcPath: e
603
- }), n;
604
- }, xt = (e) => e.flatMap((e) => bt(e.srcPath, e.contents)), St = (e, t) => t.diagnose ? !0 : !!(t.verbose && e.code === "evenodd-fill-rule"), Ct = (e) => {
605
- if (!e || !e.diagnose) return;
606
- let t = { diagnose: !0 };
607
- return e.onMessage && (t.onMessage = e.onMessage), t;
608
- }, wt = (e, t, n = {}) => {
609
- let r = Ct(t), i = xt(e), { reporter: a, verbose: o = !1 } = n;
610
- for (let e of i) St(e, {
611
- diagnose: r?.diagnose,
612
- verbose: o
613
- }) && a?.(e.message);
614
- let s = [];
615
- return r?.diagnose && (s = i), {
616
- diagnostics: s,
617
- glyphs: e
618
- };
619
- }, Tt = (e, t, n = {}) => {
620
- let { diagnostics: r, glyphs: i } = wt(e, t, n);
621
- return {
622
- diagnostics: r,
623
- glyphs: i
781
+ ]), Mn = [...W].join(", "), G = (e) => {
782
+ if (typeof e != "string" || !W.has(e)) throw Error(`Invalid format "${String(e)}". Expected one of: ${Mn}`);
783
+ return e;
784
+ }, K = (e) => {
785
+ if (e.length === 0) throw Error("formats must not be empty");
786
+ return e.map(G);
787
+ }, Nn = (e) => {
788
+ if (!Array.isArray(e)) throw Error("formats must be an array of format names (e.g. [\"woff2\", \"svg\"])");
789
+ return K(e);
624
790
  };
625
- }, Et = (e, t) => {
626
- let n = "";
627
- return new Promise((r, i) => {
628
- t.verbose && console.log("Generating SVG font...");
629
- let a = new g(Je(t)).on("finish", () => r(n)).on("data", (e) => {
630
- n += e;
631
- }).on("error", (e) => i(e));
632
- e.forEach((e) => {
633
- let t = new se();
634
- t.push(e.contents), t.push(null), t.metadata = e.metadata ?? {
635
- name: "",
636
- unicode: []
637
- }, a.write(t);
638
- }), a.end();
639
- });
640
- }, Dt = (e, t = {}) => Buffer.from(ce(e, t).buffer), Ot = (e) => M(e), kt = (e, t) => N(e, t), At = (e) => P(e), jt = async (e, t) => {
641
- let n = (e) => {
642
- if (t.svgTools?.onMessage) {
643
- t.svgTools.onMessage(e);
791
+ })), q, Fn, J, In, Ln, Rn, zn = r((() => {
792
+ Pn(), o(), q = (e, t) => {
793
+ if (t !== void 0 && typeof t != "string") throw Error(`${e} must be a string`);
794
+ }, Fn = (e, t) => {
795
+ if (t !== void 0 && typeof t != "boolean" && typeof t != "string") throw Error(`${e} must be a boolean or string`);
796
+ }, J = (e, t) => {
797
+ if (t !== void 0 && typeof t != "boolean") throw Error(`${e} must be a boolean`);
798
+ }, In = (e, t) => {
799
+ if (t !== void 0 && (typeof t != "object" || !t || Array.isArray(t))) throw Error(`${e} must be an object`);
800
+ }, Ln = (e) => {
801
+ if (typeof e == "string") {
802
+ if (e.length === 0) throw Error("files must not be empty");
644
803
  return;
645
804
  }
646
- (t.svgTools?.diagnose || t.verbose) && console.log(e);
647
- }, r = !!(t.svgTools?.onMessage || t.svgTools?.diagnose || t.verbose), i;
648
- r && (i = n);
649
- let { diagnostics: a, glyphs: o } = Tt(e, t.svgTools, {
650
- reporter: i,
651
- verbose: t.verbose
652
- }), s = o;
653
- if (t.optimizeSvg && (s = rt(s, t.svgoConfig)), t.glyphContentTransformFn) {
654
- let e = t.glyphContentTransformFn;
655
- s = await Promise.all(s.map(async (t) => {
656
- let n = await e(t);
657
- return {
805
+ if (Array.isArray(e)) {
806
+ if (e.length === 0) throw Error("files must not be empty");
807
+ if (!e.every((e) => typeof e == "string")) throw Error("files must be a string or an array of strings");
808
+ return;
809
+ }
810
+ throw Error("files must be a string or an array of strings");
811
+ }, Rn = (e) => (Ln(e.files), e.formats = Nn(e.formats), q("fontName", e.fontName), Fn("unicodeRange", e.unicodeRange), J("optimizeSvg", e.optimizeSvg), In("svgoConfig", e.svgoConfig), J("templateFontLigatures", e.templateFontLigatures), e.template !== void 0 && i(e.template), q("templateFontPath", e.templateFontPath), e);
812
+ })), Bn, Y, Vn, Hn, Un = r((() => {
813
+ We(), ut(), wt(), Pt(), H(), Rt(), jn(), zn(), Bn = (e) => "filepath" in e, Y = async (e) => {
814
+ let t = ne("webfont", { searchStrategy: "global" });
815
+ if (e.configFile) {
816
+ let n = f.resolve(process.cwd(), e.configFile);
817
+ return await t.load(n) ?? {};
818
+ }
819
+ return await t.search(process.cwd()) ?? {};
820
+ }, Vn = Y, Hn = async (e) => {
821
+ let t = Lt(e);
822
+ delete t.filePath;
823
+ let n = await Y({ configFile: t.configFile }), r;
824
+ Bn(n) && (t = re(t, n.config, { arrayMerge: (e, t) => t }), r = n.filepath), t = Rn(t);
825
+ let i;
826
+ i = Array.isArray(t.files) ? t.files : [t.files];
827
+ let a = await Ue(i), o = $e(a);
828
+ if (o === "mixed") throw Error("Cannot mix SVG icons, TTF fonts, and WOFF/WOFF2 files in the same run");
829
+ if (o === "empty") throw Error("Files glob patterns specified did not match any supported files");
830
+ if (o === "webfont") {
831
+ let e = await Ct(V(a, o), t);
832
+ return r && (e.config = {
658
833
  ...t,
659
- contents: n
660
- };
661
- }));
662
- }
663
- if (t.glyphTransformFn) {
664
- let e = t.glyphTransformFn;
665
- s = await Promise.all(s.map(async (t) => {
666
- let n = await e(t.metadata ?? {
667
- name: "",
668
- unicode: []
669
- });
670
- return {
834
+ filePath: r
835
+ }), e;
836
+ }
837
+ if (o === "ttf") {
838
+ let e = await lt(V(a, o), t);
839
+ return r && (e.config = {
671
840
  ...t,
672
- metadata: n
673
- };
674
- }));
675
- }
676
- it(s.length, t.ligatures) && console.log(at(s.length));
677
- let c = {};
678
- t.formatsOptions?.ttf && (c = t.formatsOptions.ttf);
679
- let l = await Et(s, t);
680
- ft(l, s);
681
- let u = Dt(l, c), d = {
682
- config: t,
683
- glyphsData: s,
684
- hash: ae.createHash("md5").update(l).digest("hex"),
685
- svg: l,
686
- ttf: u
687
- };
688
- a.length > 0 && (d.svgDiagnostics = a);
689
- let { formats: f } = t;
690
- if (f.includes("eot") && (d.eot = Ot(u)), f.includes("woff")) {
691
- let e;
692
- typeof t.metadata == "string" && (e = t.metadata), d.woff = kt(u, { metadata: e });
693
- }
694
- if (f.includes("woff2") && (d.woff2 = Buffer.from(await At(u))), t.template) {
695
- let { renderTemplates: e } = await import("./renderTemplates-DvRlS58E.mjs"), { templates: n, usedBuildInTemplate: r } = e(t, d, f);
696
- n.length > 0 && (d.templates = n, d.template = n[0]?.content, d.usedBuildInTemplate = r);
697
- }
698
- return f.includes("svg") || delete d.svg, f.includes("ttf") || delete d.ttf, f.includes("otf") || delete d.otf, d;
699
- }, W = /* @__PURE__ */ new Set([
700
- "eot",
701
- "otf",
702
- "svg",
703
- "ttf",
704
- "woff",
705
- "woff2"
706
- ]), Mt = [...W].join(", "), G = (e) => {
707
- if (typeof e != "string" || !W.has(e)) throw Error(`Invalid format "${String(e)}". Expected one of: ${Mt}`);
708
- return e;
709
- }, K = (e) => {
710
- if (e.length === 0) throw Error("formats must not be empty");
711
- return e.map(G);
712
- }, Nt = (e) => {
713
- if (!Array.isArray(e)) throw Error("formats must be an array of format names (e.g. [\"woff2\", \"svg\"])");
714
- return K(e);
715
- }, q = (e, t) => {
716
- if (t !== void 0 && typeof t != "string") throw Error(`${e} must be a string`);
717
- }, Pt = (e, t) => {
718
- if (t !== void 0 && typeof t != "boolean" && typeof t != "string") throw Error(`${e} must be a boolean or string`);
719
- }, J = (e, t) => {
720
- if (t !== void 0 && typeof t != "boolean") throw Error(`${e} must be a boolean`);
721
- }, Ft = (e, t) => {
722
- if (t !== void 0 && (typeof t != "object" || !t || Array.isArray(t))) throw Error(`${e} must be an object`);
723
- }, It = (e) => {
724
- if (typeof e == "string") {
725
- if (e.length === 0) throw Error("files must not be empty");
726
- return;
727
- }
728
- if (Array.isArray(e)) {
729
- if (e.length === 0) throw Error("files must not be empty");
730
- if (!e.every((e) => typeof e == "string")) throw Error("files must be a string or an array of strings");
731
- return;
732
- }
733
- throw Error("files must be a string or an array of strings");
734
- }, Lt = (e) => (It(e.files), e.formats = Nt(e.formats), q("fontName", e.fontName), Pt("unicodeRange", e.unicodeRange), J("optimizeSvg", e.optimizeSvg), Ft("svgoConfig", e.svgoConfig), J("templateFontLigatures", e.templateFontLigatures), e.template !== void 0 && n(e.template), q("templateFontPath", e.templateFontPath), e), Rt = (e) => "filepath" in e, Y = async (e) => {
735
- let t = d("webfont", { searchStrategy: "global" });
736
- if (e.configFile) {
737
- let n = c.resolve(process.cwd(), e.configFile);
738
- return await t.load(n) ?? {};
739
- }
740
- return await t.search(process.cwd()) ?? {};
741
- }, zt = Y, Bt = async (e) => {
742
- let t = $e(e);
743
- delete t.filePath;
744
- let n = await Y({ configFile: t.configFile }), r;
745
- Rt(n) && (t = f(t, n.config, { arrayMerge: (e, t) => t }), r = n.filepath), t = Lt(t);
746
- let i;
747
- i = Array.isArray(t.files) ? t.files : [t.files];
748
- let a = await E(i), o = Se(a);
749
- if (o === "mixed") throw Error("Cannot mix SVG icons, TTF fonts, and WOFF/WOFF2 files in the same run");
750
- if (o === "empty") throw Error("Files glob patterns specified did not match any supported files");
751
- if (o === "webfont") {
752
- let e = await We(H(a, o), t);
753
- return r && (e.config = {
754
- ...t,
755
- filePath: r
756
- }), e;
757
- }
758
- if (o === "ttf") {
759
- let e = await Me(H(a, o), t);
760
- return r && (e.config = {
841
+ filePath: r
842
+ }), e;
843
+ }
844
+ et(t.formats);
845
+ let s = await An(await Nt(V(a, "svg"), t), t);
846
+ return r ? s.config = {
761
847
  ...t,
762
848
  filePath: r
763
- }), e;
764
- }
765
- Ce(t.formats);
766
- let s = await jt(await Ze(H(a, "svg"), t), t);
767
- return r ? s.config = {
768
- ...t,
769
- filePath: r
770
- } : s.config = t, s;
771
- }, Vt = (e) => {
772
- if (e.svgDiagnose) return { diagnose: !0 };
773
- }, Ht = (e) => {
774
- if (e === void 0) return;
775
- let t = e.trim();
776
- if (t.length === 0) throw Error("formats must not be empty");
777
- if (t.startsWith("[") || t.startsWith("{")) {
778
- let e;
779
- try {
780
- e = JSON.parse(t);
781
- } catch {
782
- throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
849
+ } : s.config = t, s;
850
+ };
851
+ })), Wn, Gn = r((() => {
852
+ Wn = (e) => {
853
+ if (e.svgDiagnose) return { diagnose: !0 };
854
+ };
855
+ })), Kn, qn = r((() => {
856
+ Pn(), Kn = (e) => {
857
+ if (e === void 0) return;
858
+ let t = e.trim();
859
+ if (t.length === 0) throw Error("formats must not be empty");
860
+ if (t.startsWith("[") || t.startsWith("{")) {
861
+ let e;
862
+ try {
863
+ e = JSON.parse(t);
864
+ } catch {
865
+ throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
866
+ }
867
+ if (!Array.isArray(e)) throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
868
+ return K(e);
783
869
  }
784
- if (!Array.isArray(e)) throw Error("formats must be a JSON array (e.g. [\"woff2\",\"svg\"]) or comma-separated list");
785
- return K(e);
786
- }
787
- return t.split(",").map((e) => e.trim()).filter((e) => e.length > 0).map(G);
788
- }, Ut = (e) => {
789
- if (e === void 0) return;
790
- let t = e.trim();
791
- if (t.length === 0) throw Error("template must not be empty");
792
- if (t.startsWith("[") || t.startsWith("{")) {
793
- let e;
870
+ return t.split(",").map((e) => e.trim()).filter((e) => e.length > 0).map(G);
871
+ };
872
+ })), Jn, Yn = r((() => {
873
+ o(), Jn = (e) => {
874
+ if (e === void 0) return;
875
+ let t = e.trim();
876
+ if (t.length === 0) throw Error("template must not be empty");
877
+ if (t.startsWith("[") || t.startsWith("{")) {
878
+ let e;
879
+ try {
880
+ e = JSON.parse(t);
881
+ } catch {
882
+ throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
883
+ }
884
+ if (!Array.isArray(e)) throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
885
+ return i(e);
886
+ }
887
+ return t.includes(",") ? i(t.split(",").map((e) => e.trim()).filter((e) => e.length > 0)) : t;
888
+ };
889
+ })), Xn, X, Zn = r((() => {
890
+ Un(), Xn = (e) => {
891
+ if (!(!("config" in e) || e.config?.files === void 0)) return Array.isArray(e.config.files) ? e.config.files : [e.config.files];
892
+ }, X = async (e, t) => {
893
+ let n = await Vn({ configFile: t.configFile }), r = Xn(n);
894
+ if (e.input.length > 0 && r !== void 0) throw Error("Cannot specify input files on the command line when `files` is set in the config file");
895
+ return e.input.length > 0 ? e.input : r === void 0 ? [] : r;
896
+ };
897
+ })), Qn, $n, Z, er, Q, tr, nr, rr, ir, ar, or, $, sr, cr, lr, ur, dr, fr, pr, mr = r((() => {
898
+ We(), Un(), Gn(), qn(), Yn(), Zn(), Qn = [
899
+ "svg",
900
+ "ttf",
901
+ "otf",
902
+ "eot",
903
+ "woff",
904
+ "woff2",
905
+ "hash",
906
+ "template"
907
+ ], $n = (e) => {
908
+ let t = {};
909
+ typeof e.flags.config == "string" && (t.configFile = ee.silent(process.cwd(), e.flags.config) || d.join(process.cwd(), e.flags.config)), e.flags.fontName && (t.fontName = e.flags.fontName), e.flags.formats && (t.formats = Kn(e.flags.formats)), e.flags.dest && (t.dest = e.flags.dest), e.flags.destCreate && (t.destCreate = e.flags.destCreate), e.flags.template && (t.template = Jn(e.flags.template)), e.flags.templateClassName && (t.templateClassName = e.flags.templateClassName), e.flags.templateFontPath && (t.templateFontPath = e.flags.templateFontPath), e.flags.templateFontName && (t.templateFontName = e.flags.templateFontName), e.flags.templateCacheString && (t.templateCacheString = e.flags.templateCacheString), e.flags.destTemplate && (t.destTemplate = e.flags.destTemplate), e.flags.verbose && (t.verbose = e.flags.verbose), e.flags.fontId && (t.fontId = e.flags.fontId), e.flags.fontStyle && (t.fontStyle = e.flags.fontStyle), e.flags.fontWeight && (t.fontWeight = e.flags.fontWeight), e.flags.fixedWidth && (t.fixedWidth = e.flags.fixedWidth), e.flags.centerHorizontally && (t.centerHorizontally = e.flags.centerHorizontally), e.flags.normalize && (t.normalize = e.flags.normalize), e.flags.optimizeSvg && (t.optimizeSvg = e.flags.optimizeSvg), e.flags.fontHeight && (t.fontHeight = e.flags.fontHeight), e.flags.round && (t.round = e.flags.round), e.flags.descent && (t.descent = e.flags.descent), e.flags.ascent && (t.ascent = e.flags.ascent), e.flags.startUnicode && (t.startUnicode = e.flags.startUnicode), e.flags.prependUnicode && (t.prependUnicode = e.flags.prependUnicode), e.flags.metadata && (t.metadata = e.flags.metadata), e.flags.sort === !1 && (t.sort = e.flags.sort), e.flags.ligatures && (t.ligatures = e.flags.ligatures), e.flags.unicodeRange && (t.unicodeRange = e.flags.unicodeRange), e.flags.templateFontLigatures === !1 && (t.templateFontLigatures = e.flags.templateFontLigatures), e.flags.addHashInFontUrl && (t.addHashInFontUrl = e.flags.addHashInFontUrl);
910
+ let n = Wn(e.flags);
911
+ return n && (t.svgTools = n), t;
912
+ }, Z = (e) => {
913
+ if (!e.config) throw Error("Missing config in webfont result");
914
+ return e.config;
915
+ }, er = (e, t) => (e.config = {
916
+ ...Z(e),
917
+ dest: t.dest,
918
+ destTemplate: t.destTemplate
919
+ }, e), Q = (e, t, n) => {
920
+ let r = t.dest ?? process.cwd();
921
+ return typeof t.destTemplate == "string" && (r = t.destTemplate), n ? d.join(r, `${t.fontName}.${e}`) : d.join(r, d.basename(e).replace(".njk", ""));
922
+ }, tr = (e) => Array.isArray(e) ? e[0] : e, nr = (e, t) => {
923
+ if (!e.template) return;
924
+ let n = tr(t.template);
925
+ if (e.usedBuildInTemplate && n) return Q(n, t, !0);
926
+ if (n) return Q(n, t, !1);
927
+ let r = t.dest ?? process.cwd();
928
+ return typeof t.destTemplate == "string" ? t.destTemplate : r;
929
+ }, rr = async (e, t) => {
930
+ await Promise.all(e.map(async (e) => {
931
+ let n = d.resolve(Q(e.template, t, !!e.builtIn));
932
+ await l.promises.mkdir(d.dirname(n), { recursive: !0 }), await l.promises.writeFile(n, e.content);
933
+ }));
934
+ }, ir = (e, t, n, r) => {
935
+ let i = n.fontName, a = n.dest ?? process.cwd();
936
+ return e === "template" ? d.resolve(r ?? a) : e === "hash" ? d.resolve(d.join(a, `${i}.hash`)) : d.resolve(d.join(a, `${i}.${e}`));
937
+ }, ar = (e) => /* @__PURE__ */ Error(`Destination directory "${e}" does not exist. Use --dest-create (-m) to create it.`), or = async (e, t) => {
794
938
  try {
795
- e = JSON.parse(t);
939
+ await l.promises.access(e, l.constants.F_OK);
796
940
  } catch {
797
- throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
941
+ if (t) {
942
+ await l.promises.mkdir(e, { recursive: !0 });
943
+ return;
944
+ }
945
+ throw ar(e);
798
946
  }
799
- if (!Array.isArray(e)) throw Error("template must be a JSON array (e.g. [\"html\",\"scss\"]) or a template name");
800
- return n(e);
801
- }
802
- return t.includes(",") ? n(t.split(",").map((e) => e.trim()).filter((e) => e.length > 0)) : t;
803
- }, Wt = (e) => {
804
- if (!(!("config" in e) || e.config?.files === void 0)) return Array.isArray(e.config.files) ? e.config.files : [e.config.files];
805
- }, Gt = async (e, t) => {
806
- let n = Wt(await zt({ configFile: t.configFile }));
807
- if (e.input.length > 0 && n !== void 0) throw Error("Cannot specify input files on the command line when `files` is set in the config file");
808
- return e.input.length > 0 ? e.input : n === void 0 ? [] : n;
809
- }, Kt = [
810
- "svg",
811
- "ttf",
812
- "otf",
813
- "eot",
814
- "woff",
815
- "woff2",
816
- "hash",
817
- "template"
818
- ], qt = (e) => {
819
- let t = {};
820
- typeof e.flags.config == "string" && (t.configFile = l.silent(process.cwd(), e.flags.config) || s.join(process.cwd(), e.flags.config)), e.flags.fontName && (t.fontName = e.flags.fontName), e.flags.formats && (t.formats = Ht(e.flags.formats)), e.flags.dest && (t.dest = e.flags.dest), e.flags.destCreate && (t.destCreate = e.flags.destCreate), e.flags.template && (t.template = Ut(e.flags.template)), e.flags.templateClassName && (t.templateClassName = e.flags.templateClassName), e.flags.templateFontPath && (t.templateFontPath = e.flags.templateFontPath), e.flags.templateFontName && (t.templateFontName = e.flags.templateFontName), e.flags.templateCacheString && (t.templateCacheString = e.flags.templateCacheString), e.flags.destTemplate && (t.destTemplate = e.flags.destTemplate), e.flags.verbose && (t.verbose = e.flags.verbose), e.flags.fontId && (t.fontId = e.flags.fontId), e.flags.fontStyle && (t.fontStyle = e.flags.fontStyle), e.flags.fontWeight && (t.fontWeight = e.flags.fontWeight), e.flags.fixedWidth && (t.fixedWidth = e.flags.fixedWidth), e.flags.centerHorizontally && (t.centerHorizontally = e.flags.centerHorizontally), e.flags.normalize && (t.normalize = e.flags.normalize), e.flags.optimizeSvg && (t.optimizeSvg = e.flags.optimizeSvg), e.flags.fontHeight && (t.fontHeight = e.flags.fontHeight), e.flags.round && (t.round = e.flags.round), e.flags.descent && (t.descent = e.flags.descent), e.flags.ascent && (t.ascent = e.flags.ascent), e.flags.startUnicode && (t.startUnicode = e.flags.startUnicode), e.flags.prependUnicode && (t.prependUnicode = e.flags.prependUnicode), e.flags.metadata && (t.metadata = e.flags.metadata), e.flags.sort === !1 && (t.sort = e.flags.sort), e.flags.ligatures && (t.ligatures = e.flags.ligatures), e.flags.unicodeRange && (t.unicodeRange = e.flags.unicodeRange), e.flags.templateFontLigatures === !1 && (t.templateFontLigatures = e.flags.templateFontLigatures), e.flags.addHashInFontUrl && (t.addHashInFontUrl = e.flags.addHashInFontUrl);
821
- let n = Vt(e.flags);
822
- return n && (t.svgTools = n), t;
823
- }, X = (e) => {
824
- if (!e.config) throw Error("Missing config in webfont result");
825
- return e.config;
826
- }, Jt = (e, t) => (e.config = {
827
- ...X(e),
828
- dest: t.dest,
829
- destTemplate: t.destTemplate
830
- }, e), Z = (e, t, n) => {
831
- let r = t.dest ?? process.cwd();
832
- return typeof t.destTemplate == "string" && (r = t.destTemplate), n ? s.join(r, `${t.fontName}.${e}`) : s.join(r, s.basename(e).replace(".njk", ""));
833
- }, Q = (e) => Array.isArray(e) ? e[0] : e, Yt = (e, t) => {
834
- if (!e.template) return;
835
- let n = Q(t.template);
836
- if (e.usedBuildInTemplate && n) return Z(n, t, !0);
837
- if (n) return Z(n, t, !1);
838
- let r = t.dest ?? process.cwd();
839
- return typeof t.destTemplate == "string" ? t.destTemplate : r;
840
- }, Xt = async (e, t) => {
841
- await Promise.all(e.map(async (e) => {
842
- let n = s.resolve(Z(e.template, t, !!e.builtIn));
843
- await a.promises.mkdir(s.dirname(n), { recursive: !0 }), await a.promises.writeFile(n, e.content);
844
- }));
845
- }, Zt = (e, t, n, r) => {
846
- let i = n.fontName, a = n.dest ?? process.cwd();
847
- return e === "template" ? s.resolve(r ?? a) : e === "hash" ? s.resolve(s.join(a, `${i}.hash`)) : s.resolve(s.join(a, `${i}.${e}`));
848
- }, Qt = (e) => /* @__PURE__ */ Error(`Destination directory "${e}" does not exist. Use --dest-create (-m) to create it.`), $t = async (e, t) => {
849
- try {
850
- await a.promises.access(e, a.constants.F_OK);
851
- } catch {
852
- if (t) {
853
- await a.promises.mkdir(e, { recursive: !0 });
854
- return;
855
- }
856
- throw Qt(e);
857
- }
858
- }, $ = (e, t, n) => e.length === 1 && n.fontName ? n.fontName : T(e.map((e) => e.source))[e.indexOf(t)] ?? n.fontName, en = async (e, t, n) => {
859
- await Promise.all(e.flatMap((r) => {
860
- let i = $(e, r, t), o = [];
861
- return r.ttf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.ttf`)), r.ttf)), r.otf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.otf`)), r.otf)), o;
862
- }));
863
- }, tn = (e, t, n) => $(e, t, n), nn = async (e, t, n) => {
864
- await Promise.all(e.flatMap((r) => {
865
- let i = tn(e, r, t), o = [];
866
- return r.ttf && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.ttf`)), r.ttf)), r.eot && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.eot`)), r.eot)), r.woff && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.woff`)), r.woff)), r.woff2 && o.push(a.promises.writeFile(s.resolve(s.join(n, `${i}.woff2`)), r.woff2)), o;
867
- }));
868
- }, rn = async (e) => {
869
- let t = X(e), n = t.dest ?? process.cwd(), r = Yt(e, t);
870
- return e.template && delete e.hash, await $t(n, t.destCreate), e.templates && e.templates.length > 0 && await Xt(e.templates, t), e.transcodedFonts && e.transcodedFonts.length > 1 ? (await nn(e.transcodedFonts, t, n), e) : e.decompressedFonts && e.decompressedFonts.length > 1 ? (await en(e.decompressedFonts, t, n), e) : (await Promise.all(Kt.filter((t) => t === "template" && e.templates && e.templates.length > 0 ? !1 : e[t] !== void 0).map(async (n) => {
871
- let i = e[n];
872
- if (i === void 0) return;
873
- let o = Zt(n, e, t, r);
874
- await a.promises.writeFile(o, i);
875
- })), e);
876
- }, an = (e) => typeof e == "object" && e && "code" in e && typeof e.code == "number" ? e.code : 1, on = (e) => {
877
- sn(e).catch((e) => {
878
- console.log(e.stack), process.exit(an(e));
879
- });
880
- }, sn = async (e) => {
881
- e.flags.help && e.showHelp(), e.flags.version && e.showVersion();
882
- let t = qt(e), n = await Gt(e, t);
883
- n.length === 0 && e.showHelp();
884
- let r = {
885
- ...t,
886
- files: n
887
- }, i = await Bt(r);
888
- return Jt(i, r), rn(i);
889
- };
890
- //#endregion
891
- //#region src/cli/index.ts
892
- on(ye);
947
+ }, $ = (e, t, n) => e.length === 1 && n.fontName ? n.fontName : He(e.map((e) => e.source))[e.indexOf(t)] ?? n.fontName, sr = async (e, t, n) => {
948
+ await Promise.all(e.flatMap((r) => {
949
+ let i = $(e, r, t), a = [];
950
+ return r.ttf && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.ttf`)), r.ttf)), r.otf && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.otf`)), r.otf)), a;
951
+ }));
952
+ }, cr = (e, t, n) => $(e, t, n), lr = async (e, t, n) => {
953
+ await Promise.all(e.flatMap((r) => {
954
+ let i = cr(e, r, t), a = [];
955
+ return r.ttf && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.ttf`)), r.ttf)), r.eot && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.eot`)), r.eot)), r.woff && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.woff`)), r.woff)), r.woff2 && a.push(l.promises.writeFile(d.resolve(d.join(n, `${i}.woff2`)), r.woff2)), a;
956
+ }));
957
+ }, ur = async (e) => {
958
+ let t = Z(e), n = t.dest ?? process.cwd(), r = nr(e, t);
959
+ return e.template && delete e.hash, await or(n, t.destCreate), e.templates && e.templates.length > 0 && await rr(e.templates, t), e.transcodedFonts && e.transcodedFonts.length > 1 ? (await lr(e.transcodedFonts, t, n), e) : e.decompressedFonts && e.decompressedFonts.length > 1 ? (await sr(e.decompressedFonts, t, n), e) : (await Promise.all(Qn.filter((t) => t === "template" && e.templates && e.templates.length > 0 ? !1 : e[t] !== void 0).map(async (n) => {
960
+ let i = e[n];
961
+ if (i === void 0) return;
962
+ let a = ir(n, e, t, r);
963
+ await l.promises.writeFile(a, i);
964
+ })), e);
965
+ }, dr = (e) => typeof e == "object" && e && "code" in e && typeof e.code == "number" ? e.code : 1, fr = (e) => {
966
+ pr(e).catch((e) => {
967
+ console.log(e.stack), process.exit(dr(e));
968
+ });
969
+ }, pr = async (e) => {
970
+ e.flags.help && e.showHelp(), e.flags.version && e.showVersion();
971
+ let t = $n(e), n = await X(e, t);
972
+ n.length === 0 && e.showHelp();
973
+ let r = {
974
+ ...t,
975
+ files: n
976
+ }, i = await Hn(r);
977
+ return er(i, r), ur(i);
978
+ };
979
+ })), hr = /* @__PURE__ */ a((() => {
980
+ Re(), mr(), fr(Le);
981
+ }));
893
982
  //#endregion
983
+ export default hr();