diff --git a/gen-types.mjs b/gen-types.mjs index 4893fc8..9cc3245 100644 --- a/gen-types.mjs +++ b/gen-types.mjs @@ -7,9 +7,9 @@ const collections = req("@iconify/json/collections.json") fs.writeFileSync( "types.ts", - `export const availableCollectionNames = [${Object.keys(collections) + `export const collectionNames = [${Object.keys(collections) .map((v) => JSON.stringify(v)) .join(", ")}] as const -/** All the available icon collections when you have \`@iconify/json\` installed */\nexport type CollectionNames = typeof availableCollectionNames[number] +/** All the available icon collections when you have \`@iconify/json\` installed */\nexport type CollectionNames = typeof collectionNames[number] `, ) diff --git a/src/dynamic.ts b/src/dynamic.ts index 5bca29c..c31330b 100644 --- a/src/dynamic.ts +++ b/src/dynamic.ts @@ -1,4 +1,4 @@ -import { availableCollectionNames } from "../types" +import { collectionNames } from "../types" import { generateComponent, getIconCollections } from "./core" import type { CollectionNames } from "../types" @@ -27,7 +27,7 @@ export function getDynamicCSSRules( const prefix = nameParts[0] const name = nameParts[1]! - if (!availableCollectionNames.includes(prefix as CollectionNames)) { + if (!collectionNames.includes(prefix as CollectionNames)) { throw new Error(`Invalid collection name: "${prefix}"`) } diff --git a/src/index.ts b/src/index.ts index 07d8efb..7219598 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { parseIconSet } from "@iconify/utils" import plugin from "tailwindcss/plugin.js" -import { availableCollectionNames } from "../types" +import { collectionNames } from "../types" import { generateIconComponent, getIconCollections, @@ -14,7 +14,7 @@ import type { GenerateOptions } from "./core" import type { Optional } from "./utils" import type { IconifyJSONIconsData } from "@iconify/types" -export { getIconCollections, type CollectionNames } +export { getIconCollections, collectionNames, type CollectionNames } type CollectionNamesAlias = { [key in CollectionNames]?: string @@ -47,7 +47,7 @@ export const iconsPlugin = (iconsPluginOptions?: IconsPluginOptions) => { const collections = propsCollections ?? getIconCollections( - availableCollectionNames.filter((name) => + collectionNames.filter((name) => isPackageExists(`@iconify-json/${name}`), ), )