(package, style, format)
| 101 | } |
| 102 | |
| 103 | async function buildIcons(package, style, format) { |
| 104 | let outDir = `./${package}/${style}` |
| 105 | if (format === 'esm') { |
| 106 | outDir += '/esm' |
| 107 | } |
| 108 | |
| 109 | let icons = await getIcons(style) |
| 110 | |
| 111 | await Promise.all( |
| 112 | icons.flatMap(async ({ componentName, svg, isDeprecated }) => { |
| 113 | let content = await transform[package](svg, componentName, format, isDeprecated) |
| 114 | |
| 115 | /** @type {string[]} */ |
| 116 | let types = [] |
| 117 | |
| 118 | if (package === 'react') { |
| 119 | types.push(`import * as React from 'react';`) |
| 120 | if (isDeprecated) { |
| 121 | types.push(`/** @deprecated */`) |
| 122 | } |
| 123 | types.push(`declare const ${componentName}: React.ForwardRefExoticComponent<React.PropsWithoutRef<React.SVGProps<SVGSVGElement>> & { title?: string, titleId?: string } & React.RefAttributes<SVGSVGElement>>;`) |
| 124 | types.push(`export default ${componentName};`) |
| 125 | } else { |
| 126 | types.push(`import type { FunctionalComponent, HTMLAttributes, VNodeProps } from 'vue';`) |
| 127 | if (isDeprecated) { |
| 128 | types.push(`/** @deprecated */`) |
| 129 | } |
| 130 | types.push(`declare const ${componentName}: FunctionalComponent<HTMLAttributes & VNodeProps>;`) |
| 131 | types.push(`export default ${componentName};`) |
| 132 | } |
| 133 | |
| 134 | return [ |
| 135 | ensureWrite(`${outDir}/${componentName}.js`, content), |
| 136 | ...(types ? [ensureWrite(`${outDir}/${componentName}.d.ts`, types.join("\n") + "\n")] : []), |
| 137 | ] |
| 138 | }) |
| 139 | ) |
| 140 | |
| 141 | await ensureWrite(`${outDir}/index.js`, exportAll(icons, format)) |
| 142 | |
| 143 | await ensureWrite(`${outDir}/index.d.ts`, exportAll(icons, 'esm', false)) |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * @param {string[]} styles |
no test coverage detected
searching dependent graphs…