UNPKG

fantasticon

Version:
127 lines (117 loc) 3.23 kB
import svg2ttf from 'svg2ttf'; import ttf2woff from 'ttf2woff'; import { SVGIcons2SVGFontStreamOptions } from 'svgicons2svgfont'; declare enum FontAssetType { EOT = "eot", WOFF2 = "woff2", WOFF = "woff", TTF = "ttf", SVG = "svg" } declare enum OtherAssetType { CSS = "css", SCSS = "scss", SASS = "sass", HTML = "html", JSON = "json", TS = "ts" } declare const ASSET_TYPES: { CSS: OtherAssetType.CSS; SCSS: OtherAssetType.SCSS; SASS: OtherAssetType.SASS; HTML: OtherAssetType.HTML; JSON: OtherAssetType.JSON; TS: OtherAssetType.TS; EOT: FontAssetType.EOT; WOFF2: FontAssetType.WOFF2; WOFF: FontAssetType.WOFF; TTF: FontAssetType.TTF; SVG: FontAssetType.SVG; }; type AssetType = FontAssetType | OtherAssetType; interface GetIconIdOptions { basename: string; relativeDirPath: string; absoluteFilePath: string; relativeFilePath: string; index: number; } type GetIconIdFn = (options: GetIconIdOptions) => string; type Arguments<T> = T extends (...args: infer T) => any ? T : never; type WoffOptions = Arguments<typeof ttf2woff>[1]; type TtfOptions = svg2ttf.FontOptions; type SvgOptions = Omit<SVGIcons2SVGFontStreamOptions, 'fontName' | 'fontHeight' | 'descent' | 'normalize'>; interface JsonOptions { indent?: number; } interface TsOptions { types?: ('enum' | 'constant' | 'literalId' | 'literalKey')[]; singleQuotes?: boolean; enumName?: string; constantName?: string; literalIdName?: string; literalKeyName?: string; } interface FormatOptions { woff?: WoffOptions; ttf?: TtfOptions; svg?: SvgOptions; json?: JsonOptions; ts?: TsOptions; } type GeneratedAssets = { [key in FontAssetType | OtherAssetType]?: string | Buffer; }; type WriteResult = { content: string | Buffer; writePath: string; }; type WriteResults = WriteResult[]; interface IconAsset { id: string; absolutePath: string; relativePath: string; } interface AssetsMap { [key: string]: IconAsset; } type CodepointsMap = { [key: string]: number; }; interface RunnerMandatoryOptions { inputDir: string; outputDir: string; } type RunnerOptionalOptions = { name: string; fontTypes: FontAssetType[]; assetTypes: OtherAssetType[]; formatOptions: FormatOptions; pathOptions: { [key in AssetType]?: string; }; codepoints: CodepointsMap; fontHeight: number; descent: number; normalize: boolean; round: number; selector: string; tag: string; templates: { [key in OtherAssetType]?: string; }; prefix: string; fontsUrl: string; getIconId: GetIconIdFn; }; type RunnerOptions = RunnerMandatoryOptions & Partial<RunnerOptionalOptions>; interface RunnerResults { options: RunnerOptions; writeResults: WriteResults; assetsIn: AssetsMap; assetsOut: GeneratedAssets; codepoints: CodepointsMap; } declare const generateFonts: (userOptions: RunnerOptions, mustWrite?: boolean) => Promise<RunnerResults>; export { ASSET_TYPES, type AssetType, FontAssetType, type GetIconIdFn, type GetIconIdOptions, OtherAssetType, type RunnerOptions, generateFonts as default, generateFonts };