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.
Files changed (120) hide show
  1. package/NOTICE.md +14 -2
  2. package/README.md +199 -20
  3. package/dist/browser.js +4 -0
  4. package/dist/cli.mjs +850 -495
  5. package/dist/index.js +1 -1
  6. package/dist/index.mjs +513 -0
  7. package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
  8. package/dist/parseTemplateOption-Bvbie1SQ.mjs +19 -0
  9. package/dist/parseTemplateOption-DLNu6PPx.mjs +38 -0
  10. package/dist/renderTemplates-Biyrk6t-.mjs +92 -0
  11. package/dist/renderTemplates-CXVKq3Op.mjs +102 -0
  12. package/dist/renderTemplates-zCYCzeOt.js +1 -0
  13. package/dist/src/browser.d.mts +2 -0
  14. package/dist/src/browser.d.ts +2 -0
  15. package/dist/src/index.d.mts +5 -0
  16. package/dist/src/index.d.ts +2 -0
  17. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.mts +3 -0
  18. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
  19. package/dist/src/lib/evenoddFillRule.d.mts +2 -0
  20. package/dist/src/lib/evenoddFillRule.d.ts +2 -0
  21. package/dist/src/lib/execCLI/index.d.mts +24 -0
  22. package/dist/src/lib/inputSource.d.mts +2 -0
  23. package/dist/src/lib/inputSource.d.ts +1 -4
  24. package/dist/src/lib/inputSourceUtils.d.mts +4 -0
  25. package/dist/src/lib/inputSourceUtils.d.ts +4 -0
  26. package/dist/src/lib/largeFontLigatures.d.mts +4 -0
  27. package/dist/src/lib/largeFontLigatures.d.ts +4 -0
  28. package/dist/src/lib/optimizeSvgGlyphs.d.mts +4 -0
  29. package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
  30. package/dist/src/lib/p-limit/index.d.mts +2 -0
  31. package/dist/src/lib/parseFormats.d.mts +4 -0
  32. package/dist/src/lib/parseFormats.d.ts +4 -0
  33. package/dist/src/lib/parseTemplateOption.d.mts +2 -0
  34. package/dist/src/lib/parseTemplateOption.d.ts +2 -0
  35. package/dist/src/lib/runtimeEnvironment.d.mts +4 -0
  36. package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
  37. package/dist/src/lib/sfnt/flavor.d.mts +2 -0
  38. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.mts +13 -0
  39. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +13 -0
  40. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.mts +3 -0
  41. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
  42. package/dist/src/lib/svgTools/applySvgDiagnostics.d.mts +13 -0
  43. package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
  44. package/dist/src/lib/svgTools/applySvgTools.d.mts +14 -0
  45. package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
  46. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.mts +2 -0
  47. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
  48. package/dist/src/lib/svgicons2svgfont/index.d.mts +14 -0
  49. package/dist/src/lib/svgicons2svgfont/index.d.ts +5 -0
  50. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.mts +11 -0
  51. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
  52. package/dist/src/lib/templateUnicodeRange.d.mts +4 -0
  53. package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
  54. package/dist/src/lib/ttf2eot/index.d.mts +2 -0
  55. package/dist/src/lib/ttfEncode.d.mts +5 -0
  56. package/dist/src/lib/ttfEncode.d.ts +5 -0
  57. package/dist/src/standalone/convertTtfInput.d.mts +3 -0
  58. package/dist/src/standalone/convertTtfInput.d.ts +3 -0
  59. package/dist/src/standalone/convertWebfontInput.d.mts +3 -0
  60. package/dist/src/standalone/defaultOptions.d.mts +3 -0
  61. package/dist/src/standalone/defaultOptions.d.ts +3 -0
  62. package/dist/src/standalone/fetchWebfontUrl.d.mts +1 -0
  63. package/dist/src/standalone/generateSvgFont.d.mts +2 -0
  64. package/dist/src/standalone/generateSvgFont.d.ts +2 -0
  65. package/dist/src/standalone/getGlyphsDataFromInputs.d.mts +3 -0
  66. package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
  67. package/dist/src/standalone/glyphsData.d.mts +4 -0
  68. package/dist/src/standalone/glyphsData.d.ts +1 -1
  69. package/dist/src/standalone/index.d.mts +10 -0
  70. package/dist/src/standalone/index.d.ts +5 -0
  71. package/dist/src/standalone/inputMode.d.mts +9 -0
  72. package/dist/src/standalone/inputMode.d.ts +3 -1
  73. package/dist/src/standalone/options.d.mts +5 -0
  74. package/dist/src/standalone/optionsFromGlyphs.d.mts +3 -0
  75. package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
  76. package/dist/src/standalone/renderTemplates.d.mts +10 -0
  77. package/dist/src/standalone/renderTemplates.d.ts +10 -0
  78. package/dist/src/standalone/runSvgPipeline.d.mts +3 -0
  79. package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
  80. package/dist/src/standalone/templateFonts.d.mts +3 -0
  81. package/dist/src/standalone/toTtf.d.mts +4 -0
  82. package/dist/src/standalone/validateWebfontOptions.d.mts +6 -0
  83. package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
  84. package/dist/src/standalone/webfontFromGlyphs.d.mts +3 -0
  85. package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
  86. package/dist/src/types/DecompressedFont.d.mts +5 -0
  87. package/dist/src/types/Format.d.mts +9 -0
  88. package/dist/src/types/GlyphContentTransformFn.d.mts +2 -0
  89. package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
  90. package/dist/src/types/GlyphData.d.mts +6 -0
  91. package/dist/src/types/GlyphInput.d.mts +6 -0
  92. package/dist/src/types/GlyphInput.d.ts +6 -0
  93. package/dist/src/types/GlyphMetadata.d.mts +10 -0
  94. package/dist/src/types/GlyphTransformFn.d.mts +2 -0
  95. package/dist/src/types/InitialOptions.d.mts +10 -0
  96. package/dist/src/types/InitialOptions.d.ts +2 -0
  97. package/dist/src/types/MetadataProvider.d.mts +5 -0
  98. package/dist/src/types/OptionsBase.d.mts +39 -0
  99. package/dist/src/types/OptionsBase.d.ts +9 -1
  100. package/dist/src/types/RenderedTemplate.d.mts +7 -0
  101. package/dist/src/types/RenderedTemplate.d.ts +7 -0
  102. package/dist/src/types/Result.d.mts +26 -0
  103. package/dist/src/types/Result.d.ts +8 -0
  104. package/dist/src/types/ResultConfig.d.mts +4 -0
  105. package/dist/src/types/SvgToolsOptions.d.mts +13 -0
  106. package/dist/src/types/SvgToolsOptions.d.ts +13 -0
  107. package/dist/src/types/TranscodedFont.d.mts +7 -0
  108. package/dist/src/types/TranscodedFont.d.ts +7 -0
  109. package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
  110. package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
  111. package/dist/src/types/WebfontOptions.d.mts +43 -0
  112. package/dist/src/types/WebfontOptions.d.ts +12 -2
  113. package/dist/src/types/index.d.mts +8 -0
  114. package/dist/src/types/index.d.ts +2 -1
  115. package/dist/templates/index.d.mts +19 -0
  116. package/package.json +42 -11
  117. package/templates/template.css.njk +6 -3
  118. package/templates/template.html.njk +15 -4
  119. package/templates/template.scss.njk +6 -3
  120. package/templates/template.styl.njk +6 -3
package/dist/cli.mjs CHANGED
@@ -1,47 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  import { fileURLToPath as e } from "node:url";
3
- const t = e(import.meta.url), n = e(new URL(".", import.meta.url));
4
- import { pathToFileURL as r } from "node:url";
5
- import i from "meow";
6
- import * as a from "fs";
7
- import { createReadStream as o } from "fs";
8
- import * as s from "path";
9
- import c from "path";
10
- import l from "resolve-from";
11
- import { globby as u } from "globby";
12
- import { cosmiconfig as d } from "cosmiconfig";
13
- import ee from "crypto";
14
- import f from "deepmerge";
15
- import p from "nunjucks";
16
- import { Readable as m } from "stream";
17
- import h from "ttf2woff";
18
- import g from "wawoff2";
19
- import { SVGIcons2SVGFontStream as te, fileSorter as _, getMetadataService as v } from "svgicons2svgfont";
20
- import y from "ttf2eot";
21
- import b from "fontverter";
22
- import * as ne from "fs/promises";
23
- import re from "xml2js";
24
- import ie from "p-limit";
25
- import ae from "svg2ttf";
26
- //#region \0rolldown/runtime.js
27
- var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDescriptor, ce = Object.getOwnPropertyNames, le = Object.getPrototypeOf, ue = Object.prototype.hasOwnProperty, S = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), C = (e, t, n, r) => {
28
- if (t && typeof t == "object" || typeof t == "function") for (var i = ce(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ue.call(e, s) && s !== n && x(e, s, {
29
- get: ((e) => t[e]).bind(null, s),
30
- enumerable: !(r = se(t, s)) || r.enumerable
31
- });
32
- return e;
33
- }, w = (e, t, n) => (n = e == null ? {} : oe(le(e)), C(t || !e || !e.__esModule ? x(n, "default", {
34
- value: e,
35
- enumerable: !0
36
- }) : n, e)), T = {
37
- name: "webfont",
38
- version: "12.0.0",
39
- description: "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)",
40
- directories: {
3
+ const t = e(import.meta.url);
4
+ e(new URL(".", import.meta.url));
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 = {
41
31
  lib: "dist",
42
32
  source: "src"
43
- },
44
- files: [
33
+ }, Se = [
45
34
  "dist",
46
35
  "dist/src/index.d.ts",
47
36
  "templates",
@@ -49,14 +38,30 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
49
38
  "!**/__mocks__",
50
39
  "README.md",
51
40
  "NOTICE.md"
52
- ],
53
- main: "dist/index.js",
54
- bin: "dist/cli.mjs",
55
- source: "src/index.ts",
56
- types: "dist/src/index.d.ts",
57
- typings: "dist/src/index.d.ts",
58
- scripts: {
59
- build: "vite build --mode library && vite build --mode cli",
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 = {
42
+ ".": {
43
+ browser: {
44
+ types: "./dist/src/index.d.ts",
45
+ default: "./dist/browser.js"
46
+ },
47
+ node: {
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
+ }
56
+ },
57
+ default: {
58
+ types: "./dist/src/index.d.ts",
59
+ default: "./dist/browser.js"
60
+ }
61
+ },
62
+ "./package.json": "./package.json"
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",
60
65
  clean: "rm -rf dist/ temp/",
61
66
  demo: "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
62
67
  lint: "biome check .",
@@ -64,15 +69,19 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
64
69
  prebuild: "npm run clean && npm run lint",
65
70
  prepare: "lefthook install",
66
71
  predemo: "npm run build",
67
- prepublishOnly: "npm run build",
72
+ prepublishOnly: "npm run build && npm run test:package",
68
73
  pretest: "npm run build",
69
74
  prettify: "biome check --write .",
70
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",
71
80
  testc: "vitest run src --coverage",
72
81
  "test-debug": "vitest run src --no-file-parallelism",
73
- testu: "vitest run src -u"
74
- },
75
- dependencies: {
82
+ testu: "vitest run src -u",
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 = {
76
85
  cosmiconfig: "9.0.2",
77
86
  deepmerge: "^4.2.2",
78
87
  fontverter: "2.0.0",
@@ -83,23 +92,22 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
83
92
  "resolve-from": "^5.0.0",
84
93
  svg2ttf: "^6.1.0",
85
94
  svgicons2svgfont: "^16.0.0",
95
+ svgo: "4.0.1",
86
96
  ttf2eot: "3.1.0",
87
97
  ttf2woff: "^3.0.0",
88
- wawoff2: "2.0.0",
98
+ wawoff2: "2.0.1",
89
99
  xml2js: "0.6.2"
90
- },
91
- devDependencies: {
100
+ }, y = {
101
+ "@arethetypeswrong/cli": "0.18.4",
92
102
  "@biomejs/biome": "2.5.2",
93
- "@types/node": "^22.15.0",
103
+ "@types/node": "26.1.0",
94
104
  "@types/nunjucks": "3.2.6",
95
- "@types/rimraf": "latest",
96
105
  "@types/svg2ttf": "5.0.3",
97
106
  "@types/ttf2eot": "2.0.2",
98
107
  "@types/ttf2woff": "2.0.4",
99
108
  "@types/wawoff2": "1.0.2",
100
109
  "@types/xml2js": "0.4.14",
101
110
  "@vitest/coverage-v8": "4.1.9",
102
- "fast-glob": "3.2.12",
103
111
  "is-eot": "latest",
104
112
  "is-svg": "6.1.0",
105
113
  "is-ttf": "latest",
@@ -107,26 +115,20 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
107
115
  "is-woff2": "latest",
108
116
  knip: "6.24.0",
109
117
  lefthook: "2.1.9",
110
- rimraf: "latest",
118
+ publint: "0.3.21",
111
119
  typescript: "6.0.3",
112
120
  vite: "8.1.3",
113
121
  "vite-plugin-checker": "0.14.4",
114
122
  "vite-plugin-dts": "5.0.3",
115
123
  vitest: "4.1.9"
116
- },
117
- overrides: {
118
- "fast-glob": "3.2.12",
124
+ }, b = {
119
125
  minimatch: "10.2.5",
120
126
  "test-exclude": "7.0.2",
121
127
  "woff2sfnt-sfnt2woff": "1.0.0"
122
- },
123
- repository: {
128
+ }, x = {
124
129
  type: "git",
125
130
  url: "git+https://github.com/itgalaxy/webfont.git"
126
- },
127
- author: "itgalaxy <development@itgalaxy.company>",
128
- license: "MIT",
129
- contributors: [{
131
+ }, S = "itgalaxy <development@itgalaxy.company>", C = [{
130
132
  name: "Alexander Krasnoyarov",
131
133
  email: "alexander.krasnoyarov@itgalaxy.company",
132
134
  url: "https://vk.com/sterling_archer"
@@ -134,11 +136,7 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
134
136
  name: "Jimmy Andrade",
135
137
  email: "webfont@jimmyandrade.com",
136
138
  url: "https://github.com/jimmyandrade"
137
- }],
138
- bugs: { url: "https://github.com/itgalaxy/webfont/issues" },
139
- homepage: "https://github.com/itgalaxy/webfont#readme",
140
- engines: { node: ">= 24.14.0" },
141
- keywords: [
139
+ }], w = { url: "https://github.com/itgalaxy/webfont/issues" }, T = "https://github.com/itgalaxy/webfont#readme", E = { node: ">=24.14.0" }, Oe = [
142
140
  "cli",
143
141
  "standalone",
144
142
  "font",
@@ -158,252 +156,385 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
158
156
  "scss",
159
157
  "builder",
160
158
  "generator"
161
- ]
162
- }, E = "\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 Type of template ('css', 'scss', 'styl') or path to custom template.\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 --no-ligatures\n\n Prevents adding ligature unicode\n\n --verbose\n\n Tell me everything!.\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 Generated font url will be : [webfont].[ext]?v=[hash]\n", D = {
163
- ascent: { type: "string" },
164
- centerHorizontally: { type: "boolean" },
165
- config: { type: "string" },
166
- descent: { type: "string" },
167
- dest: {
168
- shortFlag: "d",
169
- default: process.cwd(),
170
- type: "string"
171
- },
172
- destCreate: {
173
- shortFlag: "m",
174
- default: !1,
175
- type: "boolean"
176
- },
177
- destTemplate: {
178
- shortFlag: "s",
179
- type: "string"
180
- },
181
- fixedWidth: { type: "boolean" },
182
- fontHeight: { type: "string" },
183
- fontId: { type: "string" },
184
- fontName: {
185
- shortFlag: "u",
186
- type: "string"
187
- },
188
- fontStyle: { type: "string" },
189
- fontWeight: { type: "string" },
190
- formats: {
191
- shortFlag: "f",
192
- type: "string"
193
- },
194
- help: {
195
- shortFlag: "h",
196
- type: "boolean"
197
- },
198
- ligatures: {
199
- default: !0,
200
- type: "boolean"
201
- },
202
- metadata: { type: "string" },
203
- normalize: { type: "boolean" },
204
- prependUnicode: { type: "boolean" },
205
- round: { type: "string" },
206
- sort: {
207
- default: !0,
208
- type: "boolean"
209
- },
210
- startUnicode: { type: "string" },
211
- template: {
212
- shortFlag: "t",
213
- type: "string"
214
- },
215
- templateClassName: {
216
- shortFlag: "c",
217
- type: "string"
218
- },
219
- templateFontName: {
220
- shortFlag: "n",
221
- type: "string"
222
- },
223
- addHashInFontUrl: {
224
- default: !1,
225
- type: "boolean"
226
- },
227
- templateFontPath: {
228
- shortFlag: "p",
229
- type: "string"
230
- },
231
- templateCacheString: {
232
- default: "",
233
- type: "string"
234
- },
235
- verbose: {
236
- default: !1,
237
- type: "boolean"
238
- },
239
- version: {
240
- shortFlag: "v",
241
- type: "boolean"
242
- }
243
- }, O = { url: r(t).href }, k = ((e = process.argv.slice(2)) => i(E, {
244
- argv: [...e],
245
- autoHelp: !1,
246
- autoVersion: !1,
247
- flags: D,
248
- importMeta: O,
249
- pkg: T
250
- }))(), A = /^https?:\/\//iu, j = (e) => A.test(e), M = (e) => {
251
- if (j(e)) try {
252
- return c.extname(new URL(e).pathname).toLowerCase();
253
- } catch {
254
- return "";
255
- }
256
- return c.extname(e).toLowerCase();
257
- }, N = async (e) => (await Promise.all(e.map((e) => j(e) ? Promise.resolve([e]) : u(e)))).flat(), P = (e) => {
258
- let t = e;
259
- j(e) && (t = new URL(e).pathname);
260
- let n = c.basename(t), r = M(e);
261
- return r === ".woff2" ? n.slice(0, -6) : r === ".woff" ? n.slice(0, -5) : n.replace(/\.[^.]+$/u, "");
262
- }, F = {
263
- ".woff": "-woff",
264
- ".woff2": "-woff2"
265
- }, I = (e) => {
266
- let t = e.map((e) => P(e)), n = /* @__PURE__ */ new Map();
267
- for (let e of t) n.set(e, (n.get(e) ?? 0) + 1);
268
- return e.map((e, r) => {
269
- let i = t[r], a = (n.get(i) ?? 0) > 1, o = M(e);
270
- return a ? `${i}${F[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
271
295
  });
272
- }, L = () => c.resolve(n, "../templates"), R = (e) => `${L()}/template.${e}.njk`, z = () => {
273
- let e = L();
274
- return {
275
- css: { path: c.join(e, "template.css.njk") },
276
- html: { path: c.join(e, "template.html.njk") },
277
- json: { path: c.join(e, "template.json.njk") },
278
- scss: { path: c.join(e, "template.scss.njk") },
279
- styl: { path: c.join(e, "template.styl.njk") }
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)];
280
370
  };
281
- }, B = (e) => ({
282
- prependUnicode: !!e.prependUnicode,
283
- startUnicode: Number(e.startUnicode)
284
- }), V = (e) => ({
285
- ascent: e.ascent,
286
- centerHorizontally: e.centerHorizontally,
287
- descent: e.descent,
288
- fixedWidth: e.fixedWidth,
289
- fontHeight: e.fontHeight,
290
- fontId: e.fontId,
291
- fontName: e.fontName,
292
- fontStyle: e.fontStyle,
293
- fontWeight: e.fontWeight,
294
- metadata: e.metadata,
295
- normalize: e.normalize,
296
- round: e.round
297
- }), H = (e) => Buffer.from(y(e)), U = 1330926671, de = 1953658213, fe = 65536, pe = (e) => {
298
- if (e.length < 4) throw Error("SFNT buffer is too short to read flavor");
299
- let t = e.readUInt32BE(0);
300
- if (t === U) return "otf";
301
- if (t === de || t === fe) return "ttf";
302
- throw Error(`Unsupported SFNT flavor 0x${t.toString(16)}`);
303
- }, me = /* @__PURE__ */ S(((e, t) => {
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) => {
379
+ let n;
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;
419
+ };
420
+ })), dt = /* @__PURE__ */ a(((e, t) => {
304
421
  t.exports = function(e) {
305
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;
306
423
  };
307
- })), he = /* @__PURE__ */ S(((e, t) => {
424
+ })), ft = /* @__PURE__ */ a(((e, t) => {
308
425
  t.exports = function(e) {
309
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;
310
427
  };
311
- })), ge = /* @__PURE__ */ w(me()), _e = /* @__PURE__ */ w(he()), ve = (e, t) => {
312
- let n = M(t);
313
- if (n === ".woff2" && !(0, _e.default)(e)) throw Error(`URL did not return a valid WOFF2 font: ${t}`);
314
- if (n === ".woff" && !(0, ge.default)(e)) throw Error(`URL did not return a valid WOFF font: ${t}`);
315
- if (e.length === 0) throw Error(`URL returned an empty response: ${t}`);
316
- }, ye = async (e) => {
317
- let t;
318
- try {
319
- t = await fetch(e);
320
- } catch (t) {
321
- let n = String(t);
322
- throw t instanceof Error && (n = t.message), Error(`Failed to fetch font URL ${e}: ${n}`);
323
- }
324
- if (!t.ok) throw Error(`Failed to fetch font URL ${e}: HTTP ${t.status} ${t.statusText}`);
325
- let n = await t.arrayBuffer(), r = Buffer.from(n);
326
- return ve(r, e), r;
327
- }, W = /* @__PURE__ */ new Set([".woff", ".woff2"]), G = ".svg", K = [
328
- "svg",
329
- "ttf",
330
- "eot",
331
- "woff",
332
- "woff2"
333
- ], q = (e) => e === G, J = (e) => W.has(e), be = (e) => q(e) || J(e), xe = (e) => {
334
- if (e.length === 0) return "empty";
335
- let t = e.map((e) => M(e));
336
- if (!t.every(be)) return "empty";
337
- let n = t.some(q), r = t.some(J);
338
- return n && r ? "mixed" : r ? "webfont" : n ? "svg" : "empty";
339
- }, Se = (e) => {
340
- 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.");
341
- }, Y = (e, t) => t === "svg" ? e.filter((e) => M(e) === G) : t === "webfont" ? e.filter((e) => W.has(M(e))) : [], Ce = (e) => {
342
- let t = e.filter((e) => e === "ttf" || e === "otf");
343
- if (e.length === K.length && K.every((t) => e.includes(t))) return ["ttf"];
344
- if (t.length === 0) throw Error("formats must include \"ttf\" and/or \"otf\" when converting WOFF/WOFF2 input");
345
- return [...new Set(t)];
346
- }, we = (e) => {
347
- if (e.length === 0) throw Error("No WOFF or WOFF2 files matched");
348
- }, Te = (e) => {
349
- if (e.template) throw Error("Templates are not supported when converting WOFF/WOFF2 input");
350
- if (e.glyphTransformFn) throw Error("glyphTransformFn is not supported when converting WOFF/WOFF2 input");
351
- }, Ee = (e) => {
352
- let { decompressed: t, sfnt: n, format: r, flavor: i, source: a } = e;
353
- if (r === "ttf" && i !== "ttf") throw Error(`Input decompresses to OpenType (OTF). Request "otf" format instead of "ttf" for ${a}.`);
354
- if (r === "otf" && i !== "otf") throw Error(`Input decompresses to TrueType (TTF). Request "ttf" format instead of "otf" for ${a}.`);
355
- if (r === "ttf") {
356
- t.ttf = n;
357
- return;
358
- }
359
- t.otf = n;
360
- }, De = (e) => j(e) ? ye(e) : ne.readFile(e), Oe = async (e, t, n) => {
361
- n && console.log(`Decompressing ${e}...`);
362
- let r = await De(e), i = Buffer.from(await b.convert(r, "sfnt")), a = pe(i), o = { source: e };
363
- for (let n of t) Ee({
364
- decompressed: o,
365
- sfnt: i,
366
- format: n,
367
- flavor: a,
368
- source: e
369
- });
370
- return o;
371
- }, ke = async (e, t) => {
372
- Te(t), we(e);
373
- let n = Ce(t.formats), r = await Promise.all(e.map((e) => Oe(e, n, t.verbose))), i = {
374
- config: { ...t },
375
- decompressedFonts: r
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;
376
445
  };
377
- return r.length === 1 && (i.ttf = r[0].ttf, i.otf = r[0].otf), i;
378
- }, Ae = ie, je = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], Me = (e) => ({
379
- name: e.name,
380
- unicode: je(e.unicode)
381
- }), Ne = (e, t) => {
382
- let n = t.metadataProvider || v(B(t)), r = new re.Parser(), i = Ae(t.maxConcurrency);
383
- return Promise.all(e.map((e) => i(() => new Promise((t, n) => {
384
- let i = o(e), a = "";
385
- i.on("error", (e) => n(e)).on("data", (e) => {
386
- a += e.toString();
387
- }).on("end", () => a.length === 0 ? n(/* @__PURE__ */ Error(`Empty file ${e}`)) : r.parseString(a, (r) => r ? n(r) : t({
388
- contents: a,
389
- srcPath: e
390
- })));
391
- })))).then((e) => {
392
- let r = e;
393
- t.sort && (r = e.sort((e, t) => _(e.srcPath, t.srcPath)));
394
- let { ligatures: i } = t;
395
- return Promise.all(r.map((e) => new Promise((t, r) => {
396
- n(e.srcPath, (n, a) => {
397
- if (n) return r(n);
398
- if (!a) return r(/* @__PURE__ */ Error(`Missing metadata for ${e.srcPath}`));
399
- let o = Me(a);
400
- return i && o.unicode.push(a.name.replace(/-/gu, "_")), e.metadata = o, t(e);
401
- });
402
- })));
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)
403
507
  });
404
- }, Pe = (e) => {
405
- if (!e?.files) throw Error("You must pass webfont a `files` glob");
406
- return {
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
+ });
535
+ };
536
+ })), Ft, It = r((() => {
537
+ Ft = () => ({
407
538
  centerHorizontally: !1,
408
539
  descent: 0,
409
540
  fixedWidth: !1,
@@ -424,7 +555,7 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
424
555
  ts: null,
425
556
  version: null
426
557
  } },
427
- ligatures: !0,
558
+ ligatures: !1,
428
559
  maxConcurrency: 100,
429
560
  metadata: void 0,
430
561
  normalize: !1,
@@ -433,196 +564,420 @@ var oe = Object.create, x = Object.defineProperty, se = Object.getOwnPropertyDes
433
564
  sort: !0,
434
565
  startUnicode: 59905,
435
566
  templateFontPath: "./",
436
- verbose: !1,
437
- ...e
438
- };
439
- }, Fe = (e, t) => {
440
- if (e === "woff2") {
441
- if (!t.woff2) throw Error("Missing woff2 buffer for template rendering");
442
- return Buffer.from(t.woff2).toString("base64");
443
- }
444
- let n = t[e];
445
- if (!n) throw Error(`Missing ${e} buffer for template rendering`);
446
- return n.toString("base64");
447
- }, Ie = (e, t = {}) => Buffer.from(ae(e, t).buffer), Le = (e) => "filepath" in e, Re = async (e) => {
448
- let t = d("webfont", { searchStrategy: "global" });
449
- if (e.configFile) {
450
- let n = c.resolve(process.cwd(), e.configFile);
451
- return await t.load(n) ?? {};
452
- }
453
- return await t.search(process.cwd()) ?? {};
454
- }, ze = (e, t) => {
455
- let n = "";
456
- return new Promise((r, i) => {
457
- t.verbose && console.log("Generating SVG font...");
458
- let a = new te(V(t)).on("finish", () => r(n)).on("data", (e) => {
459
- n += e;
460
- }).on("error", (e) => i(e));
461
- e.forEach((e) => {
462
- let t = new m();
463
- t.push(e.contents), t.push(null), t.metadata = e.metadata ?? {
464
- name: "",
465
- unicode: []
466
- }, a.write(t);
467
- }), a.end();
567
+ unicodeRange: !1,
568
+ verbose: !1
468
569
  });
469
- }, Be = (e) => H(e), Ve = (e, t) => Buffer.from(h(e, t).buffer), He = (e) => g.compress(e), Ue = async (e) => {
470
- let t = Pe(e);
471
- delete t.filePath;
472
- let r = await Re({ configFile: t.configFile }), i;
473
- Le(r) && (t = f(t, r.config, { arrayMerge: (e, t) => t }), i = r.filepath);
474
- let a;
475
- a = Array.isArray(t.files) ? t.files : [t.files];
476
- let o = await N(a), s = xe(o);
477
- if (s === "mixed") throw Error("Cannot mix SVG icons with WOFF/WOFF2 font files in the same run");
478
- if (s === "empty") throw Error("Files glob patterns specified did not match any supported files");
479
- if (s === "webfont") {
480
- let e = await ke(Y(o, s), t);
481
- return i && (e.config = {
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 ? {
482
594
  ...t,
483
- filePath: i
484
- }), e;
485
- }
486
- Se(t.formats);
487
- let l = await Ne(Y(o, "svg"), t);
488
- if (t.glyphTransformFn) {
489
- let e = t.glyphTransformFn, n = l.map(async (t) => {
490
- let n = await e(t.metadata ?? {
491
- name: "",
492
- unicode: []
493
- });
494
- return {
495
- ...t,
496
- metadata: n
497
- };
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();
498
708
  });
499
- l = await Promise.all(n);
500
- }
501
- let u = {};
502
- t.formatsOptions?.ttf && (u = t.formatsOptions.ttf);
503
- let d = await ze(l, t), m = Ie(d, u), h = {
504
- glyphsData: l,
505
- hash: ee.createHash("md5").update(d).digest("hex"),
506
- svg: d,
507
- ttf: m
508
- }, { formats: g } = t;
509
- if (g.includes("eot") && (h.eot = Be(m)), g.includes("woff")) {
510
- let e;
511
- typeof t.metadata == "string" && (e = t.metadata), h.woff = Ve(m, { metadata: e });
512
- }
513
- if (g.includes("woff2") && (h.woff2 = Buffer.from(await He(m))), t.template) {
514
- let e = z(), r;
515
- if (Object.keys(e).includes(t.template)) {
516
- h.usedBuildInTemplate = !0;
517
- let e = c.resolve(n, "../..");
518
- p.configure(e), r = R(t.template);
519
- } else {
520
- let e = c.resolve(t.template);
521
- p.configure(c.dirname(e)), r = c.resolve(e);
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
+ }));
522
735
  }
523
- let i = {};
524
- t.addHashInFontUrl && (i = { hash: h.hash });
525
- let a = f.all([
526
- { glyphs: h.glyphsData?.map((e) => e.metadata) ?? [] },
527
- t,
528
- {
529
- cacheString: t.templateCacheString || Date.now(),
530
- className: t.templateClassName || t.fontName,
531
- fontName: t.templateFontName || t.fontName,
532
- fontPath: t.templateFontPath.replace(/\/?$/u, "/")
533
- },
534
- i,
535
- { fonts: Object.fromEntries(new Map(g.map((e) => [e, () => Fe(e, h)]))) }
536
- ]);
537
- h.template = p.render(r, a);
538
- }
539
- return g.includes("svg") || delete h.svg, g.includes("ttf") || delete h.ttf, g.includes("otf") || delete h.otf, i ? h.config = {
540
- ...t,
541
- filePath: i
542
- } : h.config = t, h;
543
- }, X = /* @__PURE__ */ new Set([
544
- "eot",
545
- "otf",
546
- "svg",
547
- "ttf",
548
- "woff",
549
- "woff2"
550
- ]), Z = (e) => {
551
- if (typeof e != "string" || !X.has(e)) throw Error(`Invalid format "${String(e)}". Expected one of: ${[...X].join(", ")}`);
552
- return e;
553
- }, We = (e) => {
554
- let t = e.trim();
555
- if (t.startsWith("{") || t.startsWith("[")) {
556
- let e = JSON.parse(t);
557
- if (!Array.isArray(e)) throw Error("formats must be a JSON array");
558
- return e.map(Z);
559
- }
560
- if (t.length === 0) throw Error("formats must not be empty");
561
- return t.split(",").map((e) => Z(e.trim()));
562
- }, Ge = [
563
- "svg",
564
- "ttf",
565
- "otf",
566
- "eot",
567
- "woff",
568
- "woff2",
569
- "hash",
570
- "template"
571
- ], Q = (e) => {
572
- let t = {};
573
- return 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 = We(e.flags.formats)), e.flags.dest && (t.dest = e.flags.dest), e.flags.destCreate && (t.destCreate = e.flags.destCreate), e.flags.template && (t.template = 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.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 === !1 && (t.ligatures = e.flags.ligatures), e.flags.addHashInFontUrl && (t.addHashInFontUrl = e.flags.addHashInFontUrl), t;
574
- }, $ = (e) => {
575
- if (!e.config) throw Error("Missing config in webfont result");
576
- return e.config;
577
- }, Ke = (e, t) => (e.config = {
578
- ...$(e),
579
- dest: t.dest,
580
- destTemplate: t.destTemplate
581
- }, e), qe = (e, t) => {
582
- if (!e.template) return;
583
- let n = t.dest ?? process.cwd(), r;
584
- return r = typeof t.destTemplate == "string" ? t.destTemplate : n, e.usedBuildInTemplate && typeof t.template == "string" ? s.join(r, `${t.fontName}.${t.template}`) : typeof t.template == "string" ? s.join(r, s.basename(t.template).replace(".njk", "")) : r;
585
- }, Je = (e, t, n, r) => {
586
- let i = n.fontName, a = n.dest ?? process.cwd();
587
- return e === "template" ? s.resolve(r ?? a) : e === "hash" ? s.resolve(s.join(a, `${i}.hash`)) : s.resolve(s.join(a, `${i}.${e}`));
588
- }, Ye = (e) => /* @__PURE__ */ Error(`Destination directory "${e}" does not exist. Use --dest-create (-m) to create it.`), Xe = async (e, t) => {
589
- try {
590
- await a.promises.access(e, a.constants.F_OK);
591
- } catch {
592
- if (t) {
593
- await a.promises.mkdir(e, { recursive: !0 });
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",
777
+ "svg",
778
+ "ttf",
779
+ "woff",
780
+ "woff2"
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);
790
+ };
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");
594
803
  return;
595
804
  }
596
- throw Ye(e);
597
- }
598
- }, Ze = (e, t, n) => e.length === 1 && n.fontName ? n.fontName : I(e.map((e) => e.source))[e.indexOf(t)] ?? n.fontName, Qe = async (e, t, n) => {
599
- await Promise.all(e.flatMap((r) => {
600
- let i = Ze(e, r, t), o = [];
601
- 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;
602
- }));
603
- }, $e = async (e) => {
604
- let t = $(e), n = t.dest ?? process.cwd(), r = qe(e, t);
605
- return e.template && delete e.hash, await Xe(n, t.destCreate), e.decompressedFonts && e.decompressedFonts.length > 1 ? (await Qe(e.decompressedFonts, t, n), e) : (await Promise.all(Ge.filter((t) => e[t] !== void 0).map(async (n) => {
606
- let i = e[n];
607
- if (i === void 0) return;
608
- let o = Je(n, e, t, r);
609
- await a.promises.writeFile(o, i);
610
- })), e);
611
- }, et = (e) => typeof e == "object" && e && "code" in e && typeof e.code == "number" ? e.code : 1, tt = (e) => {
612
- nt(e).catch((e) => {
613
- console.log(e.stack), process.exit(et(e));
614
- });
615
- }, nt = async (e) => {
616
- e.flags.help && e.showHelp(), e.flags.version && e.showVersion();
617
- let t = {
618
- ...Q(e),
619
- files: e.input
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 = {
833
+ ...t,
834
+ filePath: r
835
+ }), e;
836
+ }
837
+ if (o === "ttf") {
838
+ let e = await lt(V(a, o), t);
839
+ return r && (e.config = {
840
+ ...t,
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 = {
847
+ ...t,
848
+ filePath: r
849
+ } : s.config = t, s;
620
850
  };
621
- t.files.length === 0 && e.showHelp();
622
- let n = await Ue(t);
623
- return Ke(n, t), $e(n);
624
- };
625
- //#endregion
626
- //#region src/cli/index.ts
627
- tt(k);
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);
869
+ }
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) => {
938
+ try {
939
+ await l.promises.access(e, l.constants.F_OK);
940
+ } catch {
941
+ if (t) {
942
+ await l.promises.mkdir(e, { recursive: !0 });
943
+ return;
944
+ }
945
+ throw ar(e);
946
+ }
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
+ }));
628
982
  //#endregion
983
+ export default hr();