webfont 11.2.20 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/NOTICE.md +153 -0
  2. package/README.md +135 -28
  3. package/dist/cli.mjs +628 -0
  4. package/dist/index.js +1 -5022
  5. package/dist/src/index.d.ts +2 -2
  6. package/dist/src/lib/execCLI/index.d.ts +3 -4
  7. package/dist/src/lib/inputSource.d.ts +5 -0
  8. package/dist/src/lib/p-limit/index.d.ts +2 -0
  9. package/dist/src/lib/sfnt/flavor.d.ts +2 -0
  10. package/dist/src/lib/svgicons2svgfont/index.d.ts +9 -0
  11. package/dist/src/lib/ttf2eot/index.d.ts +2 -0
  12. package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
  13. package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
  14. package/dist/src/standalone/glyphsData.d.ts +2 -2
  15. package/dist/src/standalone/index.d.ts +3 -3
  16. package/dist/src/standalone/inputMode.d.ts +7 -0
  17. package/dist/src/standalone/options.d.ts +3 -3
  18. package/dist/src/standalone/templateFonts.d.ts +3 -0
  19. package/dist/src/standalone/toTtf.d.ts +4 -0
  20. package/dist/src/types/DecompressedFont.d.ts +5 -0
  21. package/dist/src/types/Format.d.ts +4 -4
  22. package/dist/src/types/GlyphData.d.ts +2 -2
  23. package/dist/src/types/GlyphMetadata.d.ts +1 -1
  24. package/dist/src/types/GlyphTransformFn.d.ts +2 -2
  25. package/dist/src/types/InitialOptions.d.ts +5 -4
  26. package/dist/src/types/MetadataProvider.d.ts +5 -0
  27. package/dist/src/types/OptionsBase.d.ts +3 -2
  28. package/dist/src/types/Result.d.ts +8 -5
  29. package/dist/src/types/ResultConfig.d.ts +4 -0
  30. package/dist/src/types/WebfontOptions.d.ts +29 -3
  31. package/dist/src/types/index.d.ts +7 -6
  32. package/package.json +52 -57
  33. package/dist/cli.js +0 -5314
  34. package/dist/jest.config.d.ts +0 -3
  35. package/dist/src/cli/index.d.ts +0 -1
  36. package/dist/src/cli/index.test.d.ts +0 -1
  37. package/dist/src/cli/meow/index.d.ts +0 -104
  38. package/dist/src/index.test.d.ts +0 -1
  39. package/dist/src/standalone/index.test.d.ts +0 -1
@@ -1,3 +1,3 @@
1
- import { webfont } from "./standalone";
2
- export { webfont } from "./standalone";
1
+ import { webfont } from './standalone';
2
+ export { webfont } from './standalone';
3
3
  export default webfont;
@@ -1,13 +1,12 @@
1
- /// <reference types="node" />
2
- import { ExecException } from "child_process";
3
- export declare type Output = {
1
+ import { ExecException } from 'child_process';
2
+ export type Output = {
4
3
  code?: number;
5
4
  error: ExecException | null;
6
5
  files: string[];
7
6
  stderr?: string;
8
7
  stdout?: string;
9
8
  };
10
- export declare type ExecCLI = (args?: string, destination?: string) => Promise<Output>;
9
+ export type ExecCLI = (_args?: string, _destination?: string) => Promise<Output>;
11
10
  /**
12
11
  * @name execCLI
13
12
  * @description Execute webfont CLI commands using child_process.
@@ -0,0 +1,5 @@
1
+ export declare const isHttpUrl: (value: string) => boolean;
2
+ export declare const getInputExtension: (source: string) => string;
3
+ export declare const resolveInputSources: (patterns: readonly string[]) => Promise<string[]>;
4
+ export declare const getWebfontSourceBasename: (source: string) => string;
5
+ export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
@@ -0,0 +1,2 @@
1
+ import { default as pLimit } from 'p-limit';
2
+ export default pLimit;
@@ -0,0 +1,2 @@
1
+ export type SfntFlavor = "otf" | "ttf";
2
+ export declare const getSfntFlavor: (buffer: Buffer) => SfntFlavor;
@@ -0,0 +1,9 @@
1
+ import { SVGIcons2SVGFontStreamOptions, fileSorter, getMetadataService, SVGIcons2SVGFontStream } from 'svgicons2svgfont';
2
+ import { WebfontOptions } from '../../types';
3
+ export { fileSorter, getMetadataService, SVGIcons2SVGFontStream };
4
+ type MetadataServiceOptions = {
5
+ prependUnicode: boolean;
6
+ startUnicode: number;
7
+ };
8
+ export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
9
+ export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
@@ -0,0 +1,2 @@
1
+ declare const convertTtfToEot: (ttf: Buffer) => Buffer;
2
+ export default convertTtfToEot;
@@ -0,0 +1,3 @@
1
+ import { Result } from '../types/Result';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ export declare const convertWebfontInput: (fontFiles: readonly string[], options: WebfontOptions) => Promise<Result>;
@@ -0,0 +1 @@
1
+ export declare const fetchWebfontFromUrl: (url: string) => Promise<Buffer>;
@@ -1,4 +1,4 @@
1
- import type { GlyphData, WebfontOptions } from "../types";
2
- declare type GlyphsDataGetter = (files: Array<GlyphData["srcPath"]>, options: WebfontOptions) => unknown;
1
+ import { GlyphData, WebfontOptions } from '../types';
2
+ type GlyphsDataGetter = (_files: Array<GlyphData["srcPath"]>, _options: WebfontOptions) => unknown;
3
3
  export declare const getGlyphsData: GlyphsDataGetter;
4
4
  export {};
@@ -1,5 +1,5 @@
1
- import type { InitialOptions } from "../types";
2
- import type { Result } from "../types/Result";
3
- declare type Webfont = (initialOptions?: InitialOptions) => Promise<Result>;
1
+ import { InitialOptions } from '../types';
2
+ import { Result } from '../types/Result';
3
+ type Webfont = (_initialOptions?: InitialOptions) => Promise<Result>;
4
4
  export declare const webfont: Webfont;
5
5
  export default webfont;
@@ -0,0 +1,7 @@
1
+ import { Format } from '../types/Format';
2
+ export type InputMode = "empty" | "mixed" | "svg" | "webfont";
3
+ export declare const classifyInputFiles: (filePaths: readonly string[]) => InputMode;
4
+ export declare const assertSvgPipelineFormats: (formats: readonly Format[]) => void;
5
+ export declare const filterInputFilesByMode: (filePaths: readonly string[], mode: InputMode) => string[];
6
+ export type ConversionFormat = "otf" | "ttf";
7
+ export declare const resolveWebfontConversionFormats: (formats: readonly Format[]) => ConversionFormat[];
@@ -1,5 +1,5 @@
1
- import type { InitialOptions } from "../types/InitialOptions";
2
- import { WebfontOptions } from "../types/WebfontOptions";
3
- declare type OptionsGetter = (initialOptions?: InitialOptions) => WebfontOptions;
1
+ import { InitialOptions } from '../types/InitialOptions';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ type OptionsGetter = (_initialOptions?: InitialOptions) => WebfontOptions;
4
4
  export declare const getOptions: OptionsGetter;
5
5
  export {};
@@ -0,0 +1,3 @@
1
+ import { Format } from '../types/Format';
2
+ import { Result } from '../types/Result';
3
+ export declare const getTemplateFontBase64: (format: Format, result: Result) => string;
@@ -0,0 +1,4 @@
1
+ import { default as svg2ttf } from 'svg2ttf';
2
+ export type ToTtfOptions = Parameters<typeof svg2ttf>[1];
3
+ declare const toTtf: (svgFontString: string, options?: ToTtfOptions) => Buffer;
4
+ export default toTtf;
@@ -0,0 +1,5 @@
1
+ export type DecompressedFont = {
2
+ source: string;
3
+ ttf?: Buffer;
4
+ otf?: Buffer;
5
+ };
@@ -1,9 +1,9 @@
1
- export declare type Format = "eot" | "woff" | "woff2" | "svg" | "ttf";
2
- export declare type Formats = Array<Format>;
3
- declare type FormatOption = {
1
+ export type Format = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf";
2
+ export type Formats = Array<Format>;
3
+ type FormatOption = {
4
4
  copyright: null;
5
5
  ts: null;
6
6
  version: null;
7
7
  };
8
- export declare type FormatsOptions = Partial<Record<Format, FormatOption>>;
8
+ export type FormatsOptions = Partial<Record<Format, FormatOption>>;
9
9
  export {};
@@ -1,5 +1,5 @@
1
- import { GlyphMetadata } from "./GlyphMetadata";
2
- export declare type GlyphData = {
1
+ import { GlyphMetadata } from './GlyphMetadata';
2
+ export type GlyphData = {
3
3
  contents: string;
4
4
  metadata?: GlyphMetadata;
5
5
  srcPath: string;
@@ -1,4 +1,4 @@
1
- export declare type GlyphMetadata = {
1
+ export type GlyphMetadata = {
2
2
  name: string;
3
3
  /**
4
4
  * @example
@@ -1,2 +1,2 @@
1
- import { GlyphMetadata } from "./GlyphMetadata";
2
- export declare type GlyphTransformFn = (obj: GlyphMetadata) => GlyphMetadata | Promise<GlyphMetadata>;
1
+ import { GlyphMetadata } from './GlyphMetadata';
2
+ export type GlyphTransformFn = (_obj: GlyphMetadata) => GlyphMetadata | Promise<GlyphMetadata>;
@@ -1,7 +1,8 @@
1
- import { GlyphTransformFn } from "./GlyphTransformFn";
2
- import { OptionsBase } from "./OptionsBase";
3
- export declare type InitialOptions = OptionsBase & {
4
- filePath?: string;
1
+ import { GlyphTransformFn } from './GlyphTransformFn';
2
+ import { MetadataProvider } from './MetadataProvider';
3
+ import { OptionsBase } from './OptionsBase';
4
+ export type InitialOptions = OptionsBase & {
5
5
  files: string | Array<string>;
6
6
  glyphTransformFn?: GlyphTransformFn;
7
+ metadataProvider?: MetadataProvider;
7
8
  };
@@ -0,0 +1,5 @@
1
+ export type FileMetadata = {
2
+ name: string;
3
+ unicode?: string | string[];
4
+ };
5
+ export type MetadataProvider = (srcPath: string, callback: (error: Error | null, metadata?: FileMetadata) => void) => void;
@@ -1,5 +1,5 @@
1
- import { Formats } from "./Format";
2
- export declare type OptionsBase = {
1
+ import { Formats } from './Format';
2
+ export type OptionsBase = {
3
3
  configFile?: string;
4
4
  dest?: string;
5
5
  destCreate?: boolean;
@@ -26,5 +26,6 @@ export declare type OptionsBase = {
26
26
  prependUnicode?: boolean | unknown;
27
27
  metadata?: unknown;
28
28
  sort?: boolean;
29
+ ligatures?: boolean;
29
30
  addHashInFontUrl?: boolean | unknown;
30
31
  };
@@ -1,11 +1,14 @@
1
- /// <reference types="node" />
2
- import { GlyphData } from "./GlyphData";
3
- import { OptionsBase } from "./OptionsBase";
4
- export declare type Result = {
5
- config?: OptionsBase;
1
+ import { DecompressedFont } from './DecompressedFont';
2
+ import { GlyphData } from './GlyphData';
3
+ import { ResultConfig } from './ResultConfig';
4
+ export type { DecompressedFont } from './DecompressedFont';
5
+ export type Result = {
6
+ config?: ResultConfig;
7
+ decompressedFonts?: DecompressedFont[];
6
8
  eot?: Buffer;
7
9
  glyphsData?: Array<GlyphData>;
8
10
  hash?: string;
11
+ otf?: Buffer;
9
12
  svg?: string | Buffer;
10
13
  template?: string;
11
14
  ttf?: Buffer;
@@ -0,0 +1,4 @@
1
+ import { WebfontOptions } from './WebfontOptions';
2
+ export type ResultConfig = WebfontOptions & {
3
+ filePath?: string;
4
+ };
@@ -1,7 +1,33 @@
1
- import type { FormatsOptions } from "./Format";
2
- import type { InitialOptions } from "./InitialOptions";
1
+ import { Formats, FormatsOptions } from './Format';
2
+ import { GlyphTransformFn } from './GlyphTransformFn';
3
+ import { InitialOptions } from './InitialOptions';
4
+ import { MetadataProvider } from './MetadataProvider';
3
5
  export interface WebfontOptions extends InitialOptions {
6
+ centerHorizontally: boolean;
7
+ descent: number;
8
+ fixedWidth: boolean;
9
+ fontHeight: unknown;
10
+ fontId: unknown;
11
+ fontName: string;
12
+ fontStyle: string;
13
+ fontWeight: string;
14
+ formats: Formats;
4
15
  formatsOptions: FormatsOptions;
16
+ glyphTransformFn?: GlyphTransformFn;
17
+ ligatures: boolean;
5
18
  maxConcurrency: number;
6
- metadataProvider: null;
19
+ metadata: unknown;
20
+ metadataProvider?: MetadataProvider;
21
+ normalize: boolean;
22
+ prependUnicode: boolean;
23
+ round: number;
24
+ sort: boolean;
25
+ startUnicode: number;
26
+ template?: string;
27
+ templateCacheString?: unknown;
28
+ templateClassName?: unknown;
29
+ templateFontName?: unknown;
30
+ templateFontPath: string;
31
+ verbose: boolean;
32
+ addHashInFontUrl?: boolean;
7
33
  }
@@ -1,6 +1,7 @@
1
- export type { Format } from "../types/Format";
2
- export type { GlyphMetadata } from "./GlyphMetadata";
3
- export type { GlyphTransformFn } from "./GlyphTransformFn";
4
- export type { GlyphData } from "./GlyphData";
5
- export type { InitialOptions } from "./InitialOptions";
6
- export type { WebfontOptions } from "./WebfontOptions";
1
+ export type { Format } from '../types/Format';
2
+ export type { GlyphData } from './GlyphData';
3
+ export type { GlyphMetadata } from './GlyphMetadata';
4
+ export type { GlyphTransformFn } from './GlyphTransformFn';
5
+ export type { InitialOptions } from './InitialOptions';
6
+ export type { MetadataProvider } from './MetadataProvider';
7
+ export type { WebfontOptions } from './WebfontOptions';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webfont",
3
- "version": "11.2.20",
4
- "description": "Generator of fonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2",
3
+ "version": "12.0.0",
4
+ "description": "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)",
5
5
  "directories": {
6
6
  "lib": "dist",
7
7
  "source": "src"
@@ -12,83 +12,78 @@
12
12
  "templates",
13
13
  "!**/__tests__",
14
14
  "!**/__mocks__",
15
- "README.md"
15
+ "README.md",
16
+ "NOTICE.md"
16
17
  ],
17
18
  "main": "dist/index.js",
18
- "bin": "dist/cli.js",
19
+ "bin": "dist/cli.mjs",
19
20
  "source": "src/index.ts",
20
21
  "types": "dist/src/index.d.ts",
21
22
  "typings": "dist/src/index.d.ts",
22
23
  "scripts": {
23
- "build": "rollup -c",
24
+ "build": "vite build --mode library && vite build --mode cli",
24
25
  "clean": "rm -rf dist/ temp/",
25
- "demo": "node dist/cli.js './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
26
- "lint": "eslint .",
27
- "postbuild": "tsc --declaration --declarationDir dist --emitDeclarationOnly",
26
+ "demo": "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
27
+ "lint": "biome check .",
28
+ "depcheck": "knip",
28
29
  "prebuild": "npm run clean && npm run lint",
30
+ "prepare": "lefthook install",
29
31
  "predemo": "npm run build",
30
32
  "prepublishOnly": "npm run build",
31
- "prerelease": "npm run test",
32
33
  "pretest": "npm run build",
33
- "prettify": "npm run lint --fix",
34
- "preversion": "npm run test",
35
- "push-tags": "git push origin --tags",
36
- "release": "standard-version",
37
- "release-alpha": "npm run release -- --prerelease alpha",
38
- "test": "jest src",
39
- "testc": "npm test -- --coverage",
40
- "test-debug": "npm test --detectOpenHandles --runInBand",
41
- "testu": "npm test -- -u"
34
+ "prettify": "biome check --write .",
35
+ "test": "vitest run src",
36
+ "testc": "vitest run src --coverage",
37
+ "test-debug": "vitest run src --no-file-parallelism",
38
+ "testu": "vitest run src -u"
42
39
  },
43
40
  "dependencies": {
41
+ "cosmiconfig": "9.0.2",
44
42
  "deepmerge": "^4.2.2",
45
- "globby": "^11.0.0",
46
- "meow": "^9.0.0",
47
- "nunjucks": "^3.2.3",
48
- "p-limit": "^3.1.0",
49
- "parse-json": "^5.2.0",
43
+ "fontverter": "2.0.0",
44
+ "globby": "16.2.0",
45
+ "meow": "14.1.0",
46
+ "nunjucks": "3.2.4",
47
+ "p-limit": "7.3.0",
50
48
  "resolve-from": "^5.0.0",
51
- "svg2ttf": "^6.0.2",
52
- "svgicons2svgfont": "^10.0.3",
53
- "ttf2eot": "^2.0.0",
54
- "ttf2woff": "^2.0.2",
55
- "wawoff2": "^2.0.0",
56
- "xml2js": "^0.4.23"
49
+ "svg2ttf": "^6.1.0",
50
+ "svgicons2svgfont": "^16.0.0",
51
+ "ttf2eot": "3.1.0",
52
+ "ttf2woff": "^3.0.0",
53
+ "wawoff2": "2.0.0",
54
+ "xml2js": "0.6.2"
57
55
  },
58
56
  "devDependencies": {
59
- "@babel/eslint-plugin": "latest",
60
- "@babel/preset-env": "latest",
61
- "@babel/preset-typescript": "latest",
62
- "@rollup/plugin-commonjs": "latest",
63
- "@rollup/plugin-typescript": "latest",
64
- "@types/jest": "latest",
65
- "@types/node": "latest",
66
- "@types/nunjucks": "latest",
57
+ "@biomejs/biome": "2.5.2",
58
+ "@types/node": "^22.15.0",
59
+ "@types/nunjucks": "3.2.6",
67
60
  "@types/rimraf": "latest",
68
- "@typescript-eslint/eslint-plugin": "latest",
69
- "@typescript-eslint/parser": "latest",
70
- "babel-jest": "latest",
71
- "cosmiconfig": "^5.2.0",
72
- "eslint": "latest",
73
- "eslint-plugin-import": "latest",
74
- "eslint-plugin-jest": "latest",
75
- "eslint-plugin-node": "latest",
76
- "eslint-plugin-promise": "latest",
77
- "eslint-plugin-unicorn": "latest",
78
- "husky": "latest",
61
+ "@types/svg2ttf": "5.0.3",
62
+ "@types/ttf2eot": "2.0.2",
63
+ "@types/ttf2woff": "2.0.4",
64
+ "@types/wawoff2": "1.0.2",
65
+ "@types/xml2js": "0.4.14",
66
+ "@vitest/coverage-v8": "4.1.9",
67
+ "fast-glob": "3.2.12",
79
68
  "is-eot": "latest",
80
- "is-svg": "latest",
69
+ "is-svg": "6.1.0",
81
70
  "is-ttf": "latest",
82
71
  "is-woff": "latest",
83
72
  "is-woff2": "latest",
84
- "jest": "26.x",
85
- "lint-staged": "latest",
73
+ "knip": "6.24.0",
74
+ "lefthook": "2.1.9",
86
75
  "rimraf": "latest",
87
- "rollup": "latest",
88
- "standard-version": "latest",
89
- "ts-node": "latest",
90
- "tslib": "latest",
91
- "typescript": "latest"
76
+ "typescript": "6.0.3",
77
+ "vite": "8.1.3",
78
+ "vite-plugin-checker": "0.14.4",
79
+ "vite-plugin-dts": "5.0.3",
80
+ "vitest": "4.1.9"
81
+ },
82
+ "overrides": {
83
+ "fast-glob": "3.2.12",
84
+ "minimatch": "10.2.5",
85
+ "test-exclude": "7.0.2",
86
+ "woff2sfnt-sfnt2woff": "1.0.0"
92
87
  },
93
88
  "repository": {
94
89
  "type": "git",
@@ -113,7 +108,7 @@
113
108
  },
114
109
  "homepage": "https://github.com/itgalaxy/webfont#readme",
115
110
  "engines": {
116
- "node": ">= 12.0.0"
111
+ "node": ">= 24.14.0"
117
112
  },
118
113
  "keywords": [
119
114
  "cli",