@driftime/sanity-plugin-icon 0.4.1 → 0.4.3

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.
@@ -1,5 +1,6 @@
1
- import { r as pluginName, t as parseIconSet } from "./sets-kepuObH8.js";
1
+ import { n as pluginName } from "./defaults-BEzCWZtH.js";
2
2
  import { n as isDefined, r as isRecord } from "./utils-COPacfAq.js";
3
+ import { t as parseIconSet } from "./sets-BFcRq7dc.js";
3
4
  import { i as registryModulePath } from "./registry-B0Dxiwhh.js";
4
5
  import { a as readDeclaredPackages, c as convertIcon, n as createCustomAdapter, o as readJson, r as findPackage, s as readPluginBuild, t as iconAdapters } from "./adapters-Bx_MyEX_.js";
5
6
  import path from "node:path";
@@ -255,4 +256,4 @@ function describeReport(label, style, report) {
255
256
  }
256
257
  export { writeIconNames as a, loadIconSet as i, detectLibraries as n, listRegistryDependencies as r, describeReport as t };
257
258
 
258
- //# sourceMappingURL=sets-D5_YGFll.js.map
259
+ //# sourceMappingURL=sets-B2lHNI7c.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sets-D5_YGFll.js","names":["readFile","rename","writeFile","path","isDefined","registryModulePath","pluginName","namesFile","join","dirname","writeIconNames","names","Map","Set","entries","toSorted","first","second","localeCompare","map","library","icons","union","name","JSON","stringify","content","current","catch","temporary","process","pid","once","mkdir","writeFile","path","Worker","isDefined","isRecord","createCustomAdapter","iconAdapters","IconAdapter","SourceIcon","convertIcon","InstalledPackage","findPackage","readDeclaredPackages","readJson","readPluginBuild","IconSet","IconSetIcon","parseIconSet","IconSetReport","total","skipped","name","reason","duration","DetectedStyle","style","installed","DetectedLibrary","adapter","styles","listed","sitePackage","folder","IconSetContext","root","cacheDir","detectLibraries","custom","Record","Promise","declared","known","all","map","packageName","packagePrefix","packagePattern","names","filter","startsWith","toSorted","found","slice","length","flat","has","undefined","find","test","folders","Object","entries","library","directory","resolve","version","findCommonRoot","icons","NonNullable","counts","Map","count","key","JSON","stringify","set","get","common","values","first","second","isSourceIcon","value","keywords","svg","Array","isArray","every","keyword","readSources","candidate","worker","URL","import","meta","url","workerData","env","process","NODE_ENV","received","sources","source","terminate","convertIconSet","started","performance","now","report","converted","icon","problem","push","iconRoot","Math","round","parseReport","flatMap","entry","loadIconSet","context","cacheable","cacheFile","join","replaceAll","cached","dirname","recursive","listRegistryDependencies","libraries","files","describeReport","label","kept","toLocaleString","timing","summary","shown","hidden","more","\"total\"","\"skipped\"","\"name\"","\"reason\"","\"set\"","\"report\""],"sources":["../src/build/names.ts","../src/build/sets.ts"],"sourcesContent":["import { readFile, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport { registryModulePath } from \"@/build/registry\";\nimport { pluginName } from \"@/config/defaults\";\n\n/** Types file the plugin reads icon names from, published next to the placeholder registry. */\nconst namesFile = path.join(path.dirname(registryModulePath), \"names.d.ts\");\n\n/**\n * Writes the installed icon names into the plugin's own types, so options that list icons are checked against them.\n * The file is replaced rather than edited, because pnpm shares a package's files between projects.\n *\n * @param names - Icon names keyed by library.\n */\nexport async function writeIconNames(names: Map<string, Set<string>>) {\n const entries = [...names]\n .toSorted(([first], [second]) => first.localeCompare(second))\n .map(([library, icons]) => {\n const union = [...icons].toSorted().map((name) => JSON.stringify(name));\n\n return ` ${JSON.stringify(library)}: ${isDefined(union) ? union.join(\" | \") : \"never\"};`;\n });\n\n const content = [\n `// Written by ${pluginName}'s build step from the project's installed icon libraries.`,\n \"export type SanityIconNames = {\",\n ...entries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n const current = await readFile(namesFile, \"utf8\").catch(() => \"\");\n if (current === content) return;\n\n const temporary = `${namesFile}.${process.pid}.tmp`;\n await writeFile(temporary, content);\n await rename(temporary, namesFile);\n}\n","import { once } from \"node:events\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\n\nimport { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport { createCustomAdapter } from \"@/build/adapters/custom\";\nimport { iconAdapters } from \"@/build/adapters/index\";\nimport type { IconAdapter } from \"@/build/adapters/types\";\nimport type { SourceIcon } from \"@/build/convert\";\nimport { convertIcon } from \"@/build/convert\";\nimport type { InstalledPackage } from \"@/build/packages\";\nimport { findPackage, readDeclaredPackages, readJson, readPluginBuild } from \"@/build/packages\";\nimport type { IconSet, IconSetIcon } from \"@/lib/sets\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** What happened converting a set, for the build's log. */\nexport interface IconSetReport {\n /** Icons the library ships in the style. */\n total: number;\n /** Icons skipped, with why. */\n skipped: { name: string; reason: string }[];\n /** Time the conversion took, in milliseconds, or 0 when it came from the cache. */\n duration: number;\n}\n\n/** One installed style of a library, and the package it's read from. */\nexport interface DetectedStyle {\n /** Identifier of the style. */\n style: string;\n /** The package the style is read from. */\n installed: InstalledPackage;\n}\n\n/** A library found in the project, and where each of its styles is installed. */\nexport interface DetectedLibrary {\n /** How to read the library. */\n adapter: IconAdapter;\n /** The styles the project has installed, empty when it has none. */\n styles: DetectedStyle[];\n /** Whether the project's `package.json` lists the package the library is read from, installed or not. */\n listed: boolean;\n /**\n * Another package of the library the project lists, such as its React version, or undefined when there's none or the\n * library's own package is listed.\n */\n sitePackage?: string;\n /** Folder of the project's own icons, relative to the project, or undefined for a known library. */\n folder?: string;\n}\n\n/** Where the build step reads libraries from and caches conversions. */\nexport interface IconSetContext {\n /** The project folder. */\n root: string;\n /** Folder for cached conversions, or undefined to convert every time. */\n cacheDir: string | undefined;\n}\n\n/**\n * Finds every library the project can use: known libraries whose package it lists and has installed, and its own icon\n * folders. Only listed packages count, so a package that's only there because another one depends on it is ignored.\n *\n * @param root - The project folder.\n * @param custom - The project's own icon folders, keyed by identifier.\n * @returns Every library the build step knows, with where it's installed.\n */\nexport async function detectLibraries(root: string, custom: Record<string, string> = {}): Promise<DetectedLibrary[]> {\n const declared = await readDeclaredPackages(root);\n\n const known = await Promise.all(\n iconAdapters.map(async (adapter) => {\n const { packageName, packagePrefix, packagePattern } = adapter;\n\n if (isDefined(packagePrefix)) {\n const names = [...declared].filter((name) => name.startsWith(packagePrefix)).toSorted();\n const found = await Promise.all(\n names.map(async (name) => {\n const installed = await findPackage(root, name);\n\n return isDefined(installed) ? [{ style: name.slice(packagePrefix.length), installed }] : [];\n }),\n );\n\n return { adapter, styles: found.flat(), listed: isDefined(names) };\n }\n\n const listed = isDefined(packageName) && declared.has(packageName);\n const installed = listed ? await findPackage(root, packageName) : undefined;\n const styles = isDefined(installed) ? adapter.styles.map((style) => ({ style, installed })) : [];\n const sitePackage =\n listed || !isDefined(packagePattern)\n ? undefined\n : [...declared].toSorted().find((name) => packagePattern.test(name));\n\n return { adapter, styles, listed, ...(isDefined(sitePackage) && { sitePackage }) };\n }),\n );\n\n const folders = Object.entries(custom).map(([library, folder]) => ({\n adapter: createCustomAdapter(library, folder),\n listed: true,\n folder,\n styles: [\n { style: \"default\", installed: { name: library, directory: path.resolve(root, folder), version: \"custom\" } },\n ],\n }));\n\n return [...known, ...folders];\n}\n\n/**\n * Picks the root most icons in a set share, so only the others need their own.\n *\n * @param icons - The converted icons.\n * @returns The most common root.\n */\nfunction findCommonRoot(icons: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[]) {\n const counts = new Map<string, { root: IconSet[\"root\"]; count: number }>();\n\n for (const { root } of icons) {\n const key = JSON.stringify(root);\n counts.set(key, { root, count: (counts.get(key)?.count ?? 0) + 1 });\n }\n\n const [common] = [...counts.values()].toSorted((first, second) => second.count - first.count);\n\n return common?.root ?? {};\n}\n\n/**\n * Checks whether a value is an icon as a worker read it from its library.\n *\n * @param value - The value to check.\n * @returns True if the value is a source icon.\n */\nfunction isSourceIcon(value: unknown): value is SourceIcon {\n if (!isRecord(value)) return false;\n\n const { name, keywords, svg } = value;\n\n return (\n typeof name === \"string\" &&\n Array.isArray(keywords) &&\n keywords.every((keyword) => typeof keyword === \"string\") &&\n typeof svg === \"string\"\n );\n}\n\n/**\n * Reads a library's icons in a fresh worker thread. A long-running bundler keeps every module it has imported, so an\n * icon package updated in place would otherwise be read from the old copy.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to read.\n * @param root - The project folder.\n * @returns The icons as the library ships them.\n */\nasync function readSources(library: DetectedLibrary, style: string, root: string) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n if (!isDefined(installed)) return [];\n\n const worker = new Worker(new URL(\"read-worker.js\", import.meta.url), {\n workerData: { library: adapter.library, folder, style, root, directory: installed.directory },\n // Libraries' components render with React's production build, which writes the same markup without warnings.\n env: { ...process.env, NODE_ENV: \"production\" },\n });\n\n try {\n const received: unknown[] = await once(worker, \"message\");\n const [sources] = received;\n\n return Array.isArray(sources) ? sources.filter((source) => isSourceIcon(source)) : [];\n } finally {\n void worker.terminate();\n }\n}\n\n/**\n * Converts one style of a library into a set, reporting anything skipped.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to convert.\n * @param root - The project folder.\n * @returns The set and its report.\n */\nasync function convertIconSet(library: DetectedLibrary, style: string, root: string) {\n const { adapter } = library;\n const started = performance.now();\n const sources = await readSources(library, style, root);\n\n const report: IconSetReport = { total: sources.length, skipped: [], duration: 0 };\n const converted: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[] = [];\n\n for (const source of sources) {\n const { icon, problem } = convertIcon(source);\n\n if (isDefined(icon)) converted.push(icon);\n else if (isDefined(problem)) report.skipped.push({ name: source.name, reason: problem });\n }\n\n const common = findCommonRoot(converted);\n const set: IconSet = {\n library: adapter.library,\n style,\n root: common,\n icons: converted.map(({ root: iconRoot, ...icon }) =>\n JSON.stringify(iconRoot) === JSON.stringify(common) ? icon : { ...icon, root: iconRoot },\n ),\n };\n\n report.duration = Math.round(performance.now() - started);\n\n return { set, report };\n}\n\n/**\n * Reads a cached conversion's report.\n *\n * @param value - The cached report.\n * @returns The report, or undefined when the value isn't one.\n */\nfunction parseReport(value: unknown): IconSetReport | undefined {\n if (!isRecord(value) || typeof value[\"total\"] !== \"number\" || !Array.isArray(value[\"skipped\"])) return undefined;\n\n const skipped = value[\"skipped\"].flatMap((entry: unknown) =>\n isRecord(entry) && typeof entry[\"name\"] === \"string\" && typeof entry[\"reason\"] === \"string\"\n ? [{ name: entry[\"name\"], reason: entry[\"reason\"] }]\n : [],\n );\n\n return { total: value[\"total\"], skipped, duration: 0 };\n}\n\n/**\n * Loads a converted set, from the cache when the same package version was converted before.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to load.\n * @param context - The project folder and cache folder.\n * @returns The set and its report.\n */\nexport async function loadIconSet(library: DetectedLibrary, style: string, context: IconSetContext) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n const cacheable = isDefined(context.cacheDir) && isDefined(installed) && !isDefined(folder);\n const cacheFile =\n cacheable && isDefined(context.cacheDir)\n ? path.join(\n context.cacheDir,\n \"driftime-icon\",\n `${adapter.library}-${style}-${installed.name.replaceAll(/[@/]/gu, \"_\")}-${installed.version}-${await readPluginBuild()}.json`,\n )\n : undefined;\n\n if (isDefined(cacheFile)) {\n const cached = await readJson(cacheFile);\n const set = isRecord(cached) ? parseIconSet(cached[\"set\"]) : undefined;\n const report = isRecord(cached) ? parseReport(cached[\"report\"]) : undefined;\n\n if (isDefined(set) && isDefined(report)) return { set, report };\n }\n\n const { set, report } = await convertIconSet(library, style, context.root);\n\n if (isDefined(cacheFile)) {\n await mkdir(path.dirname(cacheFile), { recursive: true });\n await writeFile(cacheFile, JSON.stringify({ set, report }));\n }\n\n return { set, report };\n}\n\n/**\n * Lists the files the registry is generated from, so the bundler regenerates it when a library is installed, removed,\n * or updated, instead of keeping a cached copy.\n *\n * @param root - The project folder.\n * @param libraries - Every library the build step knows.\n * @returns The files, and the folders of the project's own icons.\n */\nexport function listRegistryDependencies(root: string, libraries: DetectedLibrary[]) {\n const files = [path.join(root, \"package.json\")];\n const folders: string[] = [];\n\n for (const { styles, folder } of libraries) {\n for (const { installed } of styles) {\n if (isDefined(folder)) folders.push(installed.directory);\n else files.push(path.join(installed.directory, \"package.json\"));\n }\n }\n\n return { files, folders };\n}\n\n/**\n * Summarises a set's conversion for the build's log, listing the first few icons it skipped and why.\n *\n * @param label - Readable name of the library.\n * @param style - The style converted.\n * @param report - What happened.\n * @returns The summary, one line per skipped icon after the first.\n */\nexport function describeReport(label: string, style: string, report: IconSetReport) {\n const { total, skipped, duration } = report;\n const kept = total - skipped.length;\n const count = `${kept.toLocaleString(\"en-US\")} ${kept === 1 ? \"icon\" : \"icons\"}`;\n const timing = duration > 0 ? `converted in ${duration.toLocaleString(\"en-US\")} ms` : \"loaded from the cache\";\n const summary = `${label} (\\`${style}\\`): ${count} ${timing}`;\n if (!isDefined(skipped)) return `${summary}.`;\n\n const shown = skipped.slice(0, 5).map(({ name, reason }) => ` \\`${name}\\` ${reason}.`);\n const hidden = skipped.length - shown.length;\n const more = hidden > 0 ? [` …and ${hidden.toLocaleString(\"en-US\")} more.`] : [];\n\n return [`${summary}, ${skipped.length.toLocaleString(\"en-US\")} skipped:`, ...shown, ...more].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAMO,YAAYJ,KAAKK,KAAKL,KAAKM,QAAQJ,kBAAkB,GAAG,YAAY;;;;;;;AAQ1E,eAAsBK,eAAeC,OAAiC;CACpE,IAAMG,UAAU,CAAC,GAAGH,KAAK,CAAC,CACvBI,UAAU,CAACC,QAAQ,CAACC,YAAYD,MAAME,cAAcD,MAAM,CAAC,CAAC,CAC5DE,KAAK,CAACC,SAASC,WAAW;EACzB,IAAMC,QAAQ,CAAC,GAAGD,KAAK,CAAC,CAACN,SAAS,CAAC,CAACI,KAAKI,SAASC,KAAKC,UAAUF,IAAI,CAAC;EAEtE,OAAO,KAAKC,KAAKC,UAAUL,OAAO,EAAC,IAAKhB,UAAUkB,KAAK,IAAIA,MAAMd,KAAK,KAAK,IAAI,QAAO;C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ClF,IAAM,EAAEzF,OAAOC,SAASG,aAAaqF,QAC/ByB,OAAOlH,QAAQC,QAAQiC,QAGvBmF,UAAU,GAAGJ,MAAK,MAAO3G,MAAK,OAAQ8C,GAF3B8D,KAAKC,eAAe,OAAO,EAAC,GAAID,SAAS,IAAI,SAAS,UAEtB,GADlC9G,WAAW,IAAI,gBAAgBA,SAAS+G,eAAe,OAAO,EAAC,OAAQ;CAEtF,IAAI,CAACnI,UAAUiB,OAAO,GAAG,OAAO,GAAGoH,QAAO;CAE1C,IAAMC,QAAQrH,QAAQgC,MAAM,GAAG,CAAC,CAAC,CAACT,KAAK,EAAEtB,MAAMC,aAAa,OAAOD,KAAI,KAAMC,OAAM,EAAG,GAChFoH,SAAStH,QAAQiC,SAASoF,MAAMpF,QAChCsF,OAAOD,SAAS,IAAI,CAAC,UAAUA,OAAOJ,eAAe,OAAO,EAAC,OAAQ,IAAI,CAAA;CAE/E,OAAO;EAAC,GAAGE,QAAO,IAAKpH,QAAQiC,OAAOiF,eAAe,OAAO,EAAC;EAAa,GAAGG;EAAO,GAAGE;CAAI,CAAC,CAAChB,KAAK,IAAI;AACxG"}
1
+ {"version":3,"file":"sets-B2lHNI7c.js","names":["readFile","rename","writeFile","path","isDefined","registryModulePath","pluginName","namesFile","join","dirname","writeIconNames","names","Map","Set","entries","toSorted","first","second","localeCompare","map","library","icons","union","name","JSON","stringify","content","current","catch","temporary","process","pid","once","mkdir","writeFile","path","Worker","isDefined","isRecord","createCustomAdapter","iconAdapters","IconAdapter","SourceIcon","convertIcon","InstalledPackage","findPackage","readDeclaredPackages","readJson","readPluginBuild","IconSet","IconSetIcon","parseIconSet","IconSetReport","total","skipped","name","reason","duration","DetectedStyle","style","installed","DetectedLibrary","adapter","styles","listed","sitePackage","folder","IconSetContext","root","cacheDir","detectLibraries","custom","Record","Promise","declared","known","all","map","packageName","packagePrefix","packagePattern","names","filter","startsWith","toSorted","found","slice","length","flat","has","undefined","find","test","folders","Object","entries","library","directory","resolve","version","findCommonRoot","icons","NonNullable","counts","Map","count","key","JSON","stringify","set","get","common","values","first","second","isSourceIcon","value","keywords","svg","Array","isArray","every","keyword","readSources","candidate","worker","URL","import","meta","url","workerData","env","process","NODE_ENV","received","sources","source","terminate","convertIconSet","started","performance","now","report","converted","icon","problem","push","iconRoot","Math","round","parseReport","flatMap","entry","loadIconSet","context","cacheable","cacheFile","join","replaceAll","cached","dirname","recursive","listRegistryDependencies","libraries","files","describeReport","label","kept","toLocaleString","timing","summary","shown","hidden","more","\"total\"","\"skipped\"","\"name\"","\"reason\"","\"set\"","\"report\""],"sources":["../src/build/names.ts","../src/build/sets.ts"],"sourcesContent":["import { readFile, rename, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { isDefined } from \"@repo/lib/utils\";\n\nimport { registryModulePath } from \"@/build/registry\";\nimport { pluginName } from \"@/config/defaults\";\n\n/** Types file the plugin reads icon names from, published next to the placeholder registry. */\nconst namesFile = path.join(path.dirname(registryModulePath), \"names.d.ts\");\n\n/**\n * Writes the installed icon names into the plugin's own types, so options that list icons are checked against them.\n * The file is replaced rather than edited, because pnpm shares a package's files between projects.\n *\n * @param names - Icon names keyed by library.\n */\nexport async function writeIconNames(names: Map<string, Set<string>>) {\n const entries = [...names]\n .toSorted(([first], [second]) => first.localeCompare(second))\n .map(([library, icons]) => {\n const union = [...icons].toSorted().map((name) => JSON.stringify(name));\n\n return ` ${JSON.stringify(library)}: ${isDefined(union) ? union.join(\" | \") : \"never\"};`;\n });\n\n const content = [\n `// Written by ${pluginName}'s build step from the project's installed icon libraries.`,\n \"export type SanityIconNames = {\",\n ...entries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n const current = await readFile(namesFile, \"utf8\").catch(() => \"\");\n if (current === content) return;\n\n const temporary = `${namesFile}.${process.pid}.tmp`;\n await writeFile(temporary, content);\n await rename(temporary, namesFile);\n}\n","import { once } from \"node:events\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\n\nimport { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport { createCustomAdapter } from \"@/build/adapters/custom\";\nimport { iconAdapters } from \"@/build/adapters/index\";\nimport type { IconAdapter } from \"@/build/adapters/types\";\nimport type { SourceIcon } from \"@/build/convert\";\nimport { convertIcon } from \"@/build/convert\";\nimport type { InstalledPackage } from \"@/build/packages\";\nimport { findPackage, readDeclaredPackages, readJson, readPluginBuild } from \"@/build/packages\";\nimport type { IconSet, IconSetIcon } from \"@/lib/sets\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** What happened converting a set, for the build's log. */\nexport interface IconSetReport {\n /** Icons the library ships in the style. */\n total: number;\n /** Icons skipped, with why. */\n skipped: { name: string; reason: string }[];\n /** Time the conversion took, in milliseconds, or 0 when it came from the cache. */\n duration: number;\n}\n\n/** One installed style of a library, and the package it's read from. */\nexport interface DetectedStyle {\n /** Identifier of the style. */\n style: string;\n /** The package the style is read from. */\n installed: InstalledPackage;\n}\n\n/** A library found in the project, and where each of its styles is installed. */\nexport interface DetectedLibrary {\n /** How to read the library. */\n adapter: IconAdapter;\n /** The styles the project has installed, empty when it has none. */\n styles: DetectedStyle[];\n /** Whether the project's `package.json` lists the package the library is read from, installed or not. */\n listed: boolean;\n /**\n * Another package of the library the project lists, such as its React version, or undefined when there's none or the\n * library's own package is listed.\n */\n sitePackage?: string;\n /** Folder of the project's own icons, relative to the project, or undefined for a known library. */\n folder?: string;\n}\n\n/** Where the build step reads libraries from and caches conversions. */\nexport interface IconSetContext {\n /** The project folder. */\n root: string;\n /** Folder for cached conversions, or undefined to convert every time. */\n cacheDir: string | undefined;\n}\n\n/**\n * Finds every library the project can use: known libraries whose package it lists and has installed, and its own icon\n * folders. Only listed packages count, so a package that's only there because another one depends on it is ignored.\n *\n * @param root - The project folder.\n * @param custom - The project's own icon folders, keyed by identifier.\n * @returns Every library the build step knows, with where it's installed.\n */\nexport async function detectLibraries(root: string, custom: Record<string, string> = {}): Promise<DetectedLibrary[]> {\n const declared = await readDeclaredPackages(root);\n\n const known = await Promise.all(\n iconAdapters.map(async (adapter) => {\n const { packageName, packagePrefix, packagePattern } = adapter;\n\n if (isDefined(packagePrefix)) {\n const names = [...declared].filter((name) => name.startsWith(packagePrefix)).toSorted();\n const found = await Promise.all(\n names.map(async (name) => {\n const installed = await findPackage(root, name);\n\n return isDefined(installed) ? [{ style: name.slice(packagePrefix.length), installed }] : [];\n }),\n );\n\n return { adapter, styles: found.flat(), listed: isDefined(names) };\n }\n\n const listed = isDefined(packageName) && declared.has(packageName);\n const installed = listed ? await findPackage(root, packageName) : undefined;\n const styles = isDefined(installed) ? adapter.styles.map((style) => ({ style, installed })) : [];\n const sitePackage =\n listed || !isDefined(packagePattern)\n ? undefined\n : [...declared].toSorted().find((name) => packagePattern.test(name));\n\n return { adapter, styles, listed, ...(isDefined(sitePackage) && { sitePackage }) };\n }),\n );\n\n const folders = Object.entries(custom).map(([library, folder]) => ({\n adapter: createCustomAdapter(library, folder),\n listed: true,\n folder,\n styles: [\n { style: \"default\", installed: { name: library, directory: path.resolve(root, folder), version: \"custom\" } },\n ],\n }));\n\n return [...known, ...folders];\n}\n\n/**\n * Picks the root most icons in a set share, so only the others need their own.\n *\n * @param icons - The converted icons.\n * @returns The most common root.\n */\nfunction findCommonRoot(icons: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[]) {\n const counts = new Map<string, { root: IconSet[\"root\"]; count: number }>();\n\n for (const { root } of icons) {\n const key = JSON.stringify(root);\n counts.set(key, { root, count: (counts.get(key)?.count ?? 0) + 1 });\n }\n\n const [common] = [...counts.values()].toSorted((first, second) => second.count - first.count);\n\n return common?.root ?? {};\n}\n\n/**\n * Checks whether a value is an icon as a worker read it from its library.\n *\n * @param value - The value to check.\n * @returns True if the value is a source icon.\n */\nfunction isSourceIcon(value: unknown): value is SourceIcon {\n if (!isRecord(value)) return false;\n\n const { name, keywords, svg } = value;\n\n return (\n typeof name === \"string\" &&\n Array.isArray(keywords) &&\n keywords.every((keyword) => typeof keyword === \"string\") &&\n typeof svg === \"string\"\n );\n}\n\n/**\n * Reads a library's icons in a fresh worker thread. A long-running bundler keeps every module it has imported, so an\n * icon package updated in place would otherwise be read from the old copy.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to read.\n * @param root - The project folder.\n * @returns The icons as the library ships them.\n */\nasync function readSources(library: DetectedLibrary, style: string, root: string) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n if (!isDefined(installed)) return [];\n\n const worker = new Worker(new URL(\"read-worker.js\", import.meta.url), {\n workerData: { library: adapter.library, folder, style, root, directory: installed.directory },\n // Libraries' components render with React's production build, which writes the same markup without warnings.\n env: { ...process.env, NODE_ENV: \"production\" },\n });\n\n try {\n const received: unknown[] = await once(worker, \"message\");\n const [sources] = received;\n\n return Array.isArray(sources) ? sources.filter((source) => isSourceIcon(source)) : [];\n } finally {\n void worker.terminate();\n }\n}\n\n/**\n * Converts one style of a library into a set, reporting anything skipped.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to convert.\n * @param root - The project folder.\n * @returns The set and its report.\n */\nasync function convertIconSet(library: DetectedLibrary, style: string, root: string) {\n const { adapter } = library;\n const started = performance.now();\n const sources = await readSources(library, style, root);\n\n const report: IconSetReport = { total: sources.length, skipped: [], duration: 0 };\n const converted: (IconSetIcon & { root: NonNullable<IconSetIcon[\"root\"]> })[] = [];\n\n for (const source of sources) {\n const { icon, problem } = convertIcon(source);\n\n if (isDefined(icon)) converted.push(icon);\n else if (isDefined(problem)) report.skipped.push({ name: source.name, reason: problem });\n }\n\n const common = findCommonRoot(converted);\n const set: IconSet = {\n library: adapter.library,\n style,\n root: common,\n icons: converted.map(({ root: iconRoot, ...icon }) =>\n JSON.stringify(iconRoot) === JSON.stringify(common) ? icon : { ...icon, root: iconRoot },\n ),\n };\n\n report.duration = Math.round(performance.now() - started);\n\n return { set, report };\n}\n\n/**\n * Reads a cached conversion's report.\n *\n * @param value - The cached report.\n * @returns The report, or undefined when the value isn't one.\n */\nfunction parseReport(value: unknown): IconSetReport | undefined {\n if (!isRecord(value) || typeof value[\"total\"] !== \"number\" || !Array.isArray(value[\"skipped\"])) return undefined;\n\n const skipped = value[\"skipped\"].flatMap((entry: unknown) =>\n isRecord(entry) && typeof entry[\"name\"] === \"string\" && typeof entry[\"reason\"] === \"string\"\n ? [{ name: entry[\"name\"], reason: entry[\"reason\"] }]\n : [],\n );\n\n return { total: value[\"total\"], skipped, duration: 0 };\n}\n\n/**\n * Loads a converted set, from the cache when the same package version was converted before.\n *\n * @param library - The library and where it's installed.\n * @param style - The style to load.\n * @param context - The project folder and cache folder.\n * @returns The set and its report.\n */\nexport async function loadIconSet(library: DetectedLibrary, style: string, context: IconSetContext) {\n const { adapter, folder } = library;\n const installed = library.styles.find((candidate) => candidate.style === style)?.installed;\n const cacheable = isDefined(context.cacheDir) && isDefined(installed) && !isDefined(folder);\n const cacheFile =\n cacheable && isDefined(context.cacheDir)\n ? path.join(\n context.cacheDir,\n \"driftime-icon\",\n `${adapter.library}-${style}-${installed.name.replaceAll(/[@/]/gu, \"_\")}-${installed.version}-${await readPluginBuild()}.json`,\n )\n : undefined;\n\n if (isDefined(cacheFile)) {\n const cached = await readJson(cacheFile);\n const set = isRecord(cached) ? parseIconSet(cached[\"set\"]) : undefined;\n const report = isRecord(cached) ? parseReport(cached[\"report\"]) : undefined;\n\n if (isDefined(set) && isDefined(report)) return { set, report };\n }\n\n const { set, report } = await convertIconSet(library, style, context.root);\n\n if (isDefined(cacheFile)) {\n await mkdir(path.dirname(cacheFile), { recursive: true });\n await writeFile(cacheFile, JSON.stringify({ set, report }));\n }\n\n return { set, report };\n}\n\n/**\n * Lists the files the registry is generated from, so the bundler regenerates it when a library is installed, removed,\n * or updated, instead of keeping a cached copy.\n *\n * @param root - The project folder.\n * @param libraries - Every library the build step knows.\n * @returns The files, and the folders of the project's own icons.\n */\nexport function listRegistryDependencies(root: string, libraries: DetectedLibrary[]) {\n const files = [path.join(root, \"package.json\")];\n const folders: string[] = [];\n\n for (const { styles, folder } of libraries) {\n for (const { installed } of styles) {\n if (isDefined(folder)) folders.push(installed.directory);\n else files.push(path.join(installed.directory, \"package.json\"));\n }\n }\n\n return { files, folders };\n}\n\n/**\n * Summarises a set's conversion for the build's log, listing the first few icons it skipped and why.\n *\n * @param label - Readable name of the library.\n * @param style - The style converted.\n * @param report - What happened.\n * @returns The summary, one line per skipped icon after the first.\n */\nexport function describeReport(label: string, style: string, report: IconSetReport) {\n const { total, skipped, duration } = report;\n const kept = total - skipped.length;\n const count = `${kept.toLocaleString(\"en-US\")} ${kept === 1 ? \"icon\" : \"icons\"}`;\n const timing = duration > 0 ? `converted in ${duration.toLocaleString(\"en-US\")} ms` : \"loaded from the cache\";\n const summary = `${label} (\\`${style}\\`): ${count} ${timing}`;\n if (!isDefined(skipped)) return `${summary}.`;\n\n const shown = skipped.slice(0, 5).map(({ name, reason }) => ` \\`${name}\\` ${reason}.`);\n const hidden = skipped.length - shown.length;\n const more = hidden > 0 ? [` …and ${hidden.toLocaleString(\"en-US\")} more.`] : [];\n\n return [`${summary}, ${skipped.length.toLocaleString(\"en-US\")} skipped:`, ...shown, ...more].join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;AASA,MAAMO,YAAYJ,KAAKK,KAAKL,KAAKM,QAAQJ,kBAAkB,GAAG,YAAY;;;;;;;AAQ1E,eAAsBK,eAAeC,OAAiC;CACpE,IAAMG,UAAU,CAAC,GAAGH,KAAK,CAAC,CACvBI,UAAU,CAACC,QAAQ,CAACC,YAAYD,MAAME,cAAcD,MAAM,CAAC,CAAC,CAC5DE,KAAK,CAACC,SAASC,WAAW;EACzB,IAAMC,QAAQ,CAAC,GAAGD,KAAK,CAAC,CAACN,SAAS,CAAC,CAACI,KAAKI,SAASC,KAAKC,UAAUF,IAAI,CAAC;EAEtE,OAAO,KAAKC,KAAKC,UAAUL,OAAO,EAAC,IAAKhB,UAAUkB,KAAK,IAA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wE,eAAeC,OAAe3G,OAAemF,QAAuB;CAClF,IAAM,EAAEzF,OAAOC,SAASG,aAAaqF,QAC/ByB,OAAOlH,QAAQC,QAAQiC,QAGvBmF,UAAU,GAAGJ,MAAK,MAAO3G,MAAK,OAAQ8C,GAF3B8D,KAAKC,eAAe,OAAO,EAAC,GAAID,SAAS,IAAI,SAAS,UAEtB,GADlC9G,WAAW,IAAI,gBAAgBA,SAAS+G,eAAe,OAAO,EAAC,OAAQ;CAEtF,IAAI,CAACnI,UAAUiB,OAAO,GAAG,OAAO,GAAGoH,QAAO;CAE1C,IAAMC,QAAQrH,QAAQgC,MAAM,GAAG,CAAC,CAAC,CAACT,KAAK,EAAEtB,MAAMC,aAAa,OAAOD,KAAI,KAAMC,OAAM,EAAG,GAChFoH,SAAStH,QAAQiC,SAASoF,MAAMpF,QAChCsF,OAAOD,SAAS,IAAI,CAAC,UAAUA,OAAOJ,eAAe,OAAO,EAAC,OAAQ,IAAI,CAAA;CAE/E,OAAO;EAAC,GAAGE,QAAO,IAAKpH,QAAQiC,OAAOiF,eAAe,OAAO,EAAC;EAAa,GAAGG;EAAO,GAAGE;CAAI,CAAC,CAAChB,KAAK,IAAI;AACxG"}
@@ -0,0 +1,40 @@
1
+ import { n as isDefined, r as isRecord } from "./utils-COPacfAq.js";
2
+ import { i as parseIconRoot, r as parseIconNode } from "./nodes-DAzj56Xn.js";
3
+ /**
4
+ * Reads one icon of a converted set, skipping it when its data isn't usable.
5
+ *
6
+ * @param value - The value to read.
7
+ * @returns The icon, or undefined when the value isn't one.
8
+ */
9
+ function parseIconSetIcon(value) {
10
+ if (!isRecord(value)) return;
11
+ let { name, keywords, node, root } = value, parsedNode = parseIconNode(node), parsedRoot = isDefined(root) ? parseIconRoot(root) : void 0;
12
+ if (typeof name == "string" && Array.isArray(keywords) && isDefined(parsedNode) && (!isDefined(root) || isDefined(parsedRoot))) return {
13
+ name,
14
+ keywords: keywords.filter((keyword) => typeof keyword == "string"),
15
+ node: parsedNode,
16
+ ...isDefined(parsedRoot) && { root: parsedRoot }
17
+ };
18
+ }
19
+ /**
20
+ * Reads a converted set, keeping only the icons whose data is usable.
21
+ *
22
+ * @param value - The value to read.
23
+ * @returns The set, or undefined when the value isn't one.
24
+ */
25
+ function parseIconSet(value) {
26
+ if (!isRecord(value)) return;
27
+ let { library, style, root, icons } = value, parsedRoot = parseIconRoot(root);
28
+ if (typeof library == "string" && typeof style == "string" && isDefined(parsedRoot) && Array.isArray(icons)) return {
29
+ library,
30
+ style,
31
+ root: parsedRoot,
32
+ icons: icons.flatMap((icon) => {
33
+ let parsed = parseIconSetIcon(icon);
34
+ return isDefined(parsed) ? [parsed] : [];
35
+ })
36
+ };
37
+ }
38
+ export { parseIconSet as t };
39
+
40
+ //# sourceMappingURL=sets-BFcRq7dc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sets-BFcRq7dc.js","names":["isDefined","isRecord","IconNode","IconRoot","parseIconNode","parseIconRoot","IconSetIcon","name","keywords","node","root","IconSet","library","style","icons","IconLibraryInfo","label","packageName","packagePrefix","styles","listed","installed","sitePackage","parseIconSetIcon","value","undefined","parsedNode","parsedRoot","Array","isArray","filter","keyword","parseIconSet","flatMap","icon","parsed"],"sources":["../src/lib/sets.ts"],"sourcesContent":["import { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport type { IconNode, IconRoot } from \"@/lib/nodes\";\nimport { parseIconNode, parseIconRoot } from \"@/lib/nodes\";\n\n/** One icon in a converted set. */\nexport interface IconSetIcon {\n /** Name of the icon in its library. */\n name: string;\n /** Words describing the icon, from its library. */\n keywords: string[];\n /** Shapes the icon is drawn from. */\n node: IconNode;\n /** Root for this icon, or undefined when it uses the set's. */\n root?: IconRoot;\n}\n\n/** Icons of one library style, converted by the build step into the stored drawing format. */\nexport interface IconSet {\n /** Identifier of the library, such as `lucide`. */\n library: string;\n /** Identifier of the style, such as `bold`. */\n style: string;\n /** Root most icons in the set share. */\n root: IconRoot;\n /** Every icon in the set. */\n icons: IconSetIcon[];\n}\n\n/**\n * A library the build step knows how to convert, and whether the project has it installed.\n *\n * @public\n */\nexport interface IconLibraryInfo {\n /** Readable name of the library. */\n label: string;\n /** Package the library is read from, or an example of one for a family of packages. */\n packageName: string;\n /** Shared start of the package names of a family of packages, one per style, or undefined for a single package. */\n packagePrefix?: string;\n /** Styles the library offers, the first being the default. */\n styles: string[];\n /** Whether the project's `package.json` lists the package, installed or not. */\n listed: boolean;\n /** Whether the project has the package installed. */\n installed: boolean;\n /** Another package of the library the project lists, such as its React version, or undefined when there's none. */\n sitePackage?: string;\n}\n\n/**\n * Reads one icon of a converted set, skipping it when its data isn't usable.\n *\n * @param value - The value to read.\n * @returns The icon, or undefined when the value isn't one.\n */\nfunction parseIconSetIcon(value: unknown): IconSetIcon | undefined {\n if (!isRecord(value)) return undefined;\n\n const { name, keywords, node, root } = value;\n const parsedNode = parseIconNode(node);\n const parsedRoot = isDefined(root) ? parseIconRoot(root) : undefined;\n\n if (typeof name !== \"string\" || !Array.isArray(keywords) || !isDefined(parsedNode)) return undefined;\n if (isDefined(root) && !isDefined(parsedRoot)) return undefined;\n\n return {\n name,\n keywords: keywords.filter((keyword: unknown) => typeof keyword === \"string\"),\n node: parsedNode,\n ...(isDefined(parsedRoot) && { root: parsedRoot }),\n };\n}\n\n/**\n * Reads a converted set, keeping only the icons whose data is usable.\n *\n * @param value - The value to read.\n * @returns The set, or undefined when the value isn't one.\n */\nexport function parseIconSet(value: unknown): IconSet | undefined {\n if (!isRecord(value)) return undefined;\n\n const { library, style, root, icons } = value;\n const parsedRoot = parseIconRoot(root);\n\n if (typeof library !== \"string\" || typeof style !== \"string\" || !isDefined(parsedRoot) || !Array.isArray(icons)) {\n return undefined;\n }\n\n return {\n library,\n style,\n root: parsedRoot,\n icons: icons.flatMap((icon: unknown) => {\n const parsed = parseIconSetIcon(icon);\n\n return isDefined(parsed) ? [parsed] : [];\n }),\n };\n}\n"],"mappings":";;;;;;;;AAyDA,SAASuB,iBAAiBC,OAAyC;CACjE,IAAI,CAACvB,SAASuB,KAAK,GAAG;CAEtB,IAAM,EAAEjB,MAAMC,UAAUC,MAAMC,SAASc,OACjCE,aAAatB,cAAcK,IAAI,GAC/BkB,aAAa3B,UAAUU,IAAI,IAAIL,cAAcK,IAAI,IAAIe,KAAAA;CAE3D,IAAI,OAAOlB,QAAS,YAAaqB,MAAMC,QAAQrB,QAAQ,KAAMR,UAAU0B,UAAU,MAC7E1B,WAAUU,IAAI,KAAMV,UAAU2B,UAAU,IAE5C,OAAO;EACLpB;EACAC,UAAUA,SAASsB,QAAQC,YAAqB,OAAOA,WAAY,QAAQ;EAC3EtB,MAAMiB;EACN,GAAI1B,UAAU2B,UAAU,KAAK,EAAEjB,MAAMiB,WAAW;CAClD;AACF;;;;;;;AAQA,SAAgBK,aAAaR,OAAqC;CAChE,IAAI,CAACvB,SAASuB,KAAK,GAAG;CAEtB,IAAM,EAAEZ,SAASC,OAAOH,MAAMI,UAAUU,OAClCG,aAAatB,cAAcK,IAAI;CAErC,IAAI,OAAOE,WAAY,YAAY,OAAOC,SAAU,YAAab,UAAU2B,UAAU,KAAMC,MAAMC,QAAQf,KAAK,GAI9G,OAAO;EACLF;EACAC;EACAH,MAAMiB;EACNb,OAAOA,MAAMmB,SAASC,SAAkB;GACtC,IAAMC,SAASZ,iBAAiBW,IAAI;GAEpC,OAAOlC,UAAUmC,MAAM,IAAI,CAACA,MAAM,IAAI,CAAA;EACxC,CAAC;CACH;AACF"}
@@ -0,0 +1,59 @@
1
+ import { SanityIconNames } from "@driftime/sanity-plugin-icon/names";
2
+ /**
3
+ * Styles of each library the plugin supports, the first being the default. For a library published as a family of
4
+ * packages, its styles are the packages it publishes, and the installed ones are used.
5
+ */
6
+ declare const iconLibraryStyles: {
7
+ readonly central: ("round-filled-radius-0-stroke-1" | "round-filled-radius-0-stroke-1.5" | "round-filled-radius-0-stroke-2" | "round-filled-radius-1-stroke-1" | "round-filled-radius-1-stroke-1.5" | "round-filled-radius-1-stroke-2" | "round-filled-radius-2-stroke-1" | "round-filled-radius-2-stroke-1.5" | "round-filled-radius-2-stroke-2" | "round-filled-radius-3-stroke-1" | "round-filled-radius-3-stroke-1.5" | "round-filled-radius-3-stroke-2" | "round-outlined-radius-0-stroke-1" | "round-outlined-radius-0-stroke-1.5" | "round-outlined-radius-0-stroke-2" | "round-outlined-radius-1-stroke-1" | "round-outlined-radius-1-stroke-1.5" | "round-outlined-radius-1-stroke-2" | "round-outlined-radius-2-stroke-1" | "round-outlined-radius-2-stroke-1.5" | "round-outlined-radius-2-stroke-2" | "round-outlined-radius-3-stroke-1" | "round-outlined-radius-3-stroke-1.5" | "round-outlined-radius-3-stroke-2" | "square-filled-radius-0-stroke-1" | "square-filled-radius-0-stroke-1.5" | "square-filled-radius-0-stroke-2" | "square-outlined-radius-0-stroke-1" | "square-outlined-radius-0-stroke-1.5" | "square-outlined-radius-0-stroke-2")[];
8
+ readonly heroicons: readonly ["outline", "solid", "mini", "micro"];
9
+ readonly hugeicons: readonly ["stroke-rounded"];
10
+ readonly iconoir: readonly ["regular", "solid"];
11
+ readonly lucide: readonly ["default"];
12
+ readonly nucleo: readonly ["arcade", "core-essential-fill-24", "core-essential-fill-32", "core-essential-fill-48", "core-essential-outline-24", "core-essential-outline-32", "core-essential-outline-48", "core-fill-24", "core-fill-32", "core-fill-48", "core-outline-24", "core-outline-32", "core-outline-48", "credit-cards", "flags", "glass", "isometric", "micro-bold", "micro-bold-essential", "pixel", "pixel-essential", "sharp", "sharp-essential", "social-media", "ui-essential-fill-12", "ui-essential-fill-18", "ui-essential-fill-duo-18", "ui-essential-outline-12", "ui-essential-outline-18", "ui-essential-outline-duo-18", "ui-fill-12", "ui-fill-18", "ui-fill-duo-18", "ui-outline-12", "ui-outline-18", "ui-outline-duo-18"];
13
+ readonly phosphor: readonly ["regular", "thin", "light", "bold", "fill", "duotone"];
14
+ readonly tabler: readonly ["outline", "filled"];
15
+ };
16
+ /** Schema type name of the icon object. */
17
+ declare const iconTypeName = "icon";
18
+ /**
19
+ * Stored icon: which library it came from, its name, and the shapes it's drawn from.
20
+ *
21
+ * @public
22
+ */
23
+ interface SanityIcon {
24
+ _type: typeof iconTypeName;
25
+ /** Identifier of the library the icon came from. */
26
+ library?: string;
27
+ /** Identifier of the library style the icon came from. */
28
+ style?: string;
29
+ /** Name of the icon in its library. */
30
+ name?: string;
31
+ /** Shapes the icon is drawn from, saved when it's chosen. */
32
+ node?: string;
33
+ }
34
+ /** Styles of each supported library, from the plugin's own list. */
35
+ type IconLibraryStyles = typeof iconLibraryStyles;
36
+ /**
37
+ * Identifier of a library the plugin supports.
38
+ *
39
+ * @public
40
+ */
41
+ type SanityIconLibrary = keyof IconLibraryStyles;
42
+ /**
43
+ * Styles a library offers. The project's own icon folders have one style, `default`.
44
+ *
45
+ * @public
46
+ */
47
+ type SanityIconStyle<Library extends string> = Library extends SanityIconLibrary ? IconLibraryStyles[Library][number] : "default";
48
+ /**
49
+ * Names of a library's icons, once the build step has listed the installed version's, or any name before then.
50
+ *
51
+ * @public
52
+ */
53
+ type SanityIconName<Library extends string> = Library extends keyof SanityIconNames ? SanityIconNames[Library] : string;
54
+ /** Libraries the build step has listed, or any identifier before it has, so the project's own folders can be named. */
55
+ type ListedLibraryId = [keyof SanityIconNames] extends [never] ? string & NonNullable<unknown> : Extract<keyof SanityIconNames, string>;
56
+ /** Libraries a field can name: the supported ones, plus the project's own folders. */
57
+ type IconLibraryId = SanityIconLibrary | ListedLibraryId;
58
+ export { SanityIconName as a, SanityIconLibrary as i, ListedLibraryId as n, SanityIconStyle as o, SanityIcon as r, iconTypeName as s, IconLibraryId as t };
59
+ //# sourceMappingURL=types-D9GjPlhU.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-D9GjPlhU.d.ts","names":["SanityIconNames","iconLibraryStyles","iconTypeName","SanityIcon","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId"],"sources":["../src/lib/libraries.ts","../src/types.ts"],"mappings":";;;;;cAiEa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;cCpEWE;;;;;;UAOIC;EACf,cAAcD;;EAEd;;EAEA;;EAEA;;EAEA;;;KAIGE,2BAA2BH;;;;;;KAOpBI,0BAA0BD;;;;;;KAO1BE,gBAAgB,0BAA0BC,gBAAgBF,oBAClED,kBAAkBG;;;;;;KAQVC,eAAe,0BAA0BD,sBAAsBP,kBACvEA,gBAAgBO;;KAIRE,yBAAyBT,4CACxBU,uBACTC,cAAcX;;KAGNY,gBAAgBP,oBAAoBI"}
@@ -0,0 +1,191 @@
1
+ import { n as isDefined, t as convertCase } from "./utils-COPacfAq.js";
2
+ import { n as iconSvgAttributes } from "./nodes-DAzj56Xn.js";
3
+ import { t as getIconSetKey } from "./registry-BEEpqK3z.js";
4
+ import { t as parseIconSet } from "./sets-BFcRq7dc.js";
5
+ import { createElement } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { iconRegistry } from "@driftime/sanity-plugin-icon/sets";
8
+ /**
9
+ * Converts stored attributes to React props, turning a `style` attribute into the object React expects.
10
+ *
11
+ * @param attributes - The stored attributes.
12
+ * @returns The props.
13
+ */
14
+ function toProps({ style, ...attributes }) {
15
+ if (!isDefined(style)) return attributes;
16
+ let declarations = style.split(";").flatMap((declaration) => {
17
+ let [property = "", ...value] = declaration.split(":"), name = property.trim(), joined = value.join(":").trim();
18
+ return !isDefined(name) || !isDefined(joined) ? [] : [[name.startsWith("--") ? name : name.replace(/^-ms-/u, "ms-").replaceAll(/-(?<letter>[a-z])/gu, (_match, letter) => letter.toUpperCase()), joined]];
19
+ });
20
+ return {
21
+ ...attributes,
22
+ style: Object.fromEntries(declarations)
23
+ };
24
+ }
25
+ /**
26
+ * Draws one element of a stored drawing, with its children.
27
+ *
28
+ * @param child - The element, or text inside one.
29
+ * @param index - Its position among its siblings.
30
+ * @returns The element.
31
+ */
32
+ function renderChild(child, index) {
33
+ if (typeof child == "string") return child;
34
+ let [element, attributes, children] = child;
35
+ return createElement(element, {
36
+ ...toProps(attributes),
37
+ key: String(index)
38
+ }, children?.map((nested, position) => renderChild(nested, position)));
39
+ }
40
+ function Drawing({ drawing, ...props }) {
41
+ if (!isDefined(drawing)) return null;
42
+ let root = toProps(drawing.root);
43
+ return /* @__PURE__ */ jsx("svg", {
44
+ ...iconSvgAttributes,
45
+ ...root,
46
+ "aria-hidden": "true",
47
+ ...props,
48
+ children: drawing.node.map((child, index) => renderChild(child, index))
49
+ });
50
+ }
51
+ /**
52
+ * Normalises text for search, so hyphenated names and multi-word keywords match the same way.
53
+ *
54
+ * @param value - The text.
55
+ * @returns The normalised text.
56
+ */
57
+ function normalizeTerms(value) {
58
+ return value.toLowerCase().replaceAll(/[\s-]+/gu, " ").trim();
59
+ }
60
+ /**
61
+ * Splits text into the parts a search matches and the parts it doesn't, matching the way search does: ignoring case,
62
+ * and treating spaces and hyphens alike.
63
+ *
64
+ * @param text - The text to split.
65
+ * @param query - The normalised search.
66
+ * @returns The parts in order, each with where it starts in the text and whether it matches.
67
+ */
68
+ function splitMatches(text, query) {
69
+ if (!isDefined(query)) return [{
70
+ text,
71
+ start: 0,
72
+ match: !1
73
+ }];
74
+ let pattern = query.split(" ").map((word) => word.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`)).join(String.raw`[\s-]+`), parts = text.split(RegExp(`(${pattern})`, "giu"));
75
+ return parts.map((part, index) => ({
76
+ text: part,
77
+ start: parts.slice(0, index).join("").length,
78
+ match: index % 2 == 1
79
+ }));
80
+ }
81
+ /**
82
+ * Narrows the library to the named icons, in the order given. Unknown names are skipped, so a list keeps working
83
+ * across library releases.
84
+ *
85
+ * @param library - Every icon in the library.
86
+ * @param names - The icons to offer, or undefined for all of them.
87
+ * @returns The icons to offer.
88
+ */
89
+ function selectIcons(library, names) {
90
+ if (!isDefined(names)) return library;
91
+ let byName = new Map(library.map((icon) => [icon.name, icon]));
92
+ return [...new Set(names)].flatMap((name) => {
93
+ let icon = byName.get(name);
94
+ return isDefined(icon) ? [icon] : [];
95
+ });
96
+ }
97
+ /**
98
+ * Lists identifiers as inline code, separated by commas.
99
+ *
100
+ * @param identifiers - The identifiers.
101
+ * @returns The list.
102
+ */
103
+ function formatList(identifiers) {
104
+ return identifiers.map((identifier) => `\`${identifier}\``).join(", ");
105
+ }
106
+ /**
107
+ * Describes why a library the project hasn't installed can't be shown, and what to add.
108
+ *
109
+ * @param label - Readable name of the library.
110
+ * @param packageName - Package the library is read from, or an example of one for a family of packages.
111
+ * @param family - Whether the library is a family of packages, one per style.
112
+ * @param listed - Whether the project's `package.json` lists the package.
113
+ * @param sitePackage - Another package of the library the project lists, or undefined when there's none.
114
+ * @returns The problem.
115
+ */
116
+ function describeMissingLibrary(label, packageName, family, listed, sitePackage) {
117
+ return listed ? {
118
+ title: `${label} isn't installed yet`,
119
+ description: `\`${packageName}\` is in \`package.json\` but not in \`node_modules\`. Reinstall the project's dependencies.`
120
+ } : isDefined(sitePackage) ? {
121
+ title: `${label} needs \`${packageName}\``,
122
+ description: `The Studio reads ${label} from \`${packageName}\`, not \`${sitePackage}\`. Add it as a dev dependency.`
123
+ } : {
124
+ title: `${label} isn't installed`,
125
+ description: family ? `Install a ${label} style package, such as \`${packageName}\`.` : `Install \`${packageName}\` in the project.`
126
+ };
127
+ }
128
+ /**
129
+ * Loads one library style from the sets the build step converted.
130
+ *
131
+ * @param library - Identifier of the library, or undefined when none is set.
132
+ * @param style - Identifier of the style, or undefined for the library's default.
133
+ * @returns The icons, or why they can't be shown.
134
+ */
135
+ async function readLibrary(library, style) {
136
+ if (!isDefined(library)) return { problem: {
137
+ title: "No icon library set",
138
+ description: "Set `library` in the icon plugin's configuration or in the field's options."
139
+ } };
140
+ if (!iconRegistry.ready) return { problem: {
141
+ title: "Icons aren't set up",
142
+ description: "Add `withIcons()` to the Studio's build configuration, then restart the Studio."
143
+ } };
144
+ let info = iconRegistry.libraries[library];
145
+ if (!isDefined(info)) return { problem: {
146
+ title: "Unknown icon library",
147
+ description: `There's no icon library called \`${library}\`. Use one of: ${formatList(Object.keys(iconRegistry.libraries))}.`
148
+ } };
149
+ let { label, packageName, packagePrefix, styles, listed, installed, sitePackage } = info;
150
+ if (!installed) return { problem: describeMissingLibrary(label, packageName, isDefined(packagePrefix), listed, sitePackage) };
151
+ let resolvedStyle = style ?? styles[0] ?? "", loader = iconRegistry.sets[getIconSetKey(library, resolvedStyle)];
152
+ if (!isDefined(loader)) return { problem: isDefined(packagePrefix) ? {
153
+ title: `${label} style \`${resolvedStyle}\` isn't installed`,
154
+ description: `Install \`${packagePrefix}${resolvedStyle}\` in the project.`
155
+ } : {
156
+ title: `Unknown ${label} style`,
157
+ description: `${label} has no \`${resolvedStyle}\` style. Use one of: ${formatList(styles)}.`
158
+ } };
159
+ let module = await loader(), set = parseIconSet(module.default);
160
+ return isDefined(set) ? { icons: set.icons.map(({ name, keywords, node, root }) => ({
161
+ name,
162
+ label: convertCase(name, "title"),
163
+ tags: keywords.join(", "),
164
+ drawing: {
165
+ root: root ?? set.root,
166
+ node
167
+ },
168
+ terms: normalizeTerms([name, ...keywords].join(" "))
169
+ })) } : { problem: {
170
+ title: `Couldn't load ${label}`,
171
+ description: "Restart the Studio and try again."
172
+ } };
173
+ }
174
+ /** Library requests shared by every field in the session, keyed by library and style, since the data never changes. */
175
+ const libraryRequests = /* @__PURE__ */ new Map();
176
+ /**
177
+ * Loads a library style, reusing a request already in progress.
178
+ *
179
+ * @param library - Identifier of the library, or undefined when none is set.
180
+ * @param style - Identifier of the style, or undefined for the library's default.
181
+ * @returns The icons, or why they can't be shown.
182
+ */
183
+ async function requestLibrary(library, style) {
184
+ let key = getIconSetKey(library ?? "", style ?? ""), request = libraryRequests.get(key);
185
+ return isDefined(request) || (request = readLibrary(library, style), libraryRequests.set(key, request)), await request;
186
+ }
187
+ /** Schema type name of the icon object. */
188
+ const iconTypeName = "icon";
189
+ export { splitMatches as a, selectIcons as i, normalizeTerms as n, Drawing as o, requestLibrary as r, iconTypeName as t };
190
+
191
+ //# sourceMappingURL=types-v7Qz7ogk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-v7Qz7ogk.js","names":["isDefined","ComponentProps","ReactElement","createElement","IconDrawing","IconElement","iconSvgAttributes","toProps","style","attributes","Record","declarations","split","flatMap","declaration","property","value","name","trim","joined","join","key","startsWith","replace","replaceAll","_match","letter","toUpperCase","Object","fromEntries","renderChild","child","index","element","children","String","map","nested","position","DrawingProps","Omit","drawing","Drawing","props","root","node","iconRegistry","convertCase","isDefined","IconDrawing","getIconSetKey","parseIconSet","LibraryIcon","name","label","tags","drawing","terms","LibraryProblem","title","description","LibraryResult","icons","problem","normalizeTerms","value","toLowerCase","replaceAll","trim","splitMatches","text","query","start","match","pattern","split","map","word","String","raw","join","parts","RegExp","part","index","slice","length","selectIcons","library","names","byName","Map","icon","Set","flatMap","get","formatList","identifiers","identifier","describeMissingLibrary","packageName","family","listed","sitePackage","readLibrary","style","Promise","ready","info","libraries","Object","keys","packagePrefix","styles","installed","resolvedStyle","loader","sets","module","set","default","keywords","node","root","libraryRequests","requestLibrary","key","request","result","SanityIconNames","iconLibraryStyles","iconTypeName","SanityIcon","_type","library","style","name","node","IconLibraryStyles","SanityIconLibrary","SanityIconStyle","Library","SanityIconName","ListedLibraryId","NonNullable","Extract","IconLibraryId"],"sources":["../src/components/drawing.tsx","../src/lib/library.ts","../src/types.ts"],"sourcesContent":["// Consumers render this in server components, where the compiler's memo cache hook can't run.\n\"use no memo\";\n\nimport { isDefined } from \"@repo/lib/utils\";\nimport type { ComponentProps, ReactElement } from \"react\";\nimport { createElement } from \"react\";\n\nimport type { IconDrawing, IconElement } from \"@/lib/nodes\";\nimport { iconSvgAttributes } from \"@/lib/nodes\";\n\n/**\n * Converts stored attributes to React props, turning a `style` attribute into the object React expects.\n *\n * @param attributes - The stored attributes.\n * @returns The props.\n */\nfunction toProps({ style, ...attributes }: Record<string, string>) {\n if (!isDefined(style)) return attributes;\n\n const declarations = style.split(\";\").flatMap((declaration): [string, string][] => {\n const [property = \"\", ...value] = declaration.split(\":\");\n const name = property.trim();\n const joined = value.join(\":\").trim();\n if (!isDefined(name) || !isDefined(joined)) return [];\n\n const key = name.startsWith(\"--\")\n ? name\n : name\n .replace(/^-ms-/u, \"ms-\")\n .replaceAll(/-(?<letter>[a-z])/gu, (_match, letter: string) => letter.toUpperCase());\n\n return [[key, joined]];\n });\n\n return { ...attributes, style: Object.fromEntries(declarations) };\n}\n\n/**\n * Draws one element of a stored drawing, with its children.\n *\n * @param child - The element, or text inside one.\n * @param index - Its position among its siblings.\n * @returns The element.\n */\nfunction renderChild(child: IconElement | string, index: number): ReactElement | string {\n if (typeof child === \"string\") return child;\n\n const [element, attributes, children] = child;\n\n return createElement(\n element,\n { ...toProps(attributes), key: String(index) },\n children?.map((nested, position) => renderChild(nested, position)),\n );\n}\n\nexport type DrawingProps = Omit<ComponentProps<\"svg\">, \"children\"> & { drawing: IconDrawing | undefined };\n\nexport function Drawing({ drawing, ...props }: DrawingProps) {\n if (!isDefined(drawing)) return null;\n\n // Stored roots only hold checked attribute names, but their values are text, not React's literal types.\n const root = toProps(drawing.root) as ComponentProps<\"svg\">;\n\n return (\n <svg {...iconSvgAttributes} {...root} aria-hidden=\"true\" {...props}>\n {drawing.node.map((child, index) => renderChild(child, index))}\n </svg>\n );\n}\n","import { iconRegistry } from \"@driftime/sanity-plugin-icon/sets\";\nimport { convertCase, isDefined } from \"@repo/lib/utils\";\n\nimport type { IconDrawing } from \"@/lib/nodes\";\nimport { getIconSetKey } from \"@/lib/registry\";\nimport { parseIconSet } from \"@/lib/sets\";\n\n/** Icon in the library, with the terms a search matches against. */\nexport interface LibraryIcon {\n /** Name of the icon in its library. */\n name: string;\n /** Readable form of the name. */\n label: string;\n /** Keywords describing the icon, as a comma-separated list. */\n tags: string;\n /** The icon's shapes and the SVG attributes they're drawn inside. */\n drawing: IconDrawing;\n /** Name and keywords, normalised for search. */\n terms: string;\n}\n\n/** Why a library's icons can't be shown, and what to do about it, with code marked by backticks. */\nexport interface LibraryProblem {\n /** What's wrong, in a few words. */\n title: string;\n /** What to do about it. */\n description: string;\n}\n\n/** Outcome of loading a library: its icons, or why they can't be shown. */\nexport type LibraryResult =\n | { icons: LibraryIcon[]; problem?: undefined }\n | { icons?: undefined; problem: LibraryProblem };\n\n/**\n * Normalises text for search, so hyphenated names and multi-word keywords match the same way.\n *\n * @param value - The text.\n * @returns The normalised text.\n */\nexport function normalizeTerms(value: string) {\n return value\n .toLowerCase()\n .replaceAll(/[\\s-]+/gu, \" \")\n .trim();\n}\n\n/**\n * Splits text into the parts a search matches and the parts it doesn't, matching the way search does: ignoring case,\n * and treating spaces and hyphens alike.\n *\n * @param text - The text to split.\n * @param query - The normalised search.\n * @returns The parts in order, each with where it starts in the text and whether it matches.\n */\nexport function splitMatches(text: string, query: string) {\n if (!isDefined(query)) return [{ text, start: 0, match: false }];\n\n const pattern = query\n .split(\" \")\n .map((word) => word.replaceAll(/[$()*+.?[\\\\\\]^{|}]/gu, String.raw`\\$&`))\n .join(String.raw`[\\s-]+`);\n\n const parts = text.split(new RegExp(`(${pattern})`, \"giu\"));\n\n return parts.map((part, index) => ({\n text: part,\n start: parts.slice(0, index).join(\"\").length,\n match: index % 2 === 1,\n }));\n}\n\n/**\n * Narrows the library to the named icons, in the order given. Unknown names are skipped, so a list keeps working\n * across library releases.\n *\n * @param library - Every icon in the library.\n * @param names - The icons to offer, or undefined for all of them.\n * @returns The icons to offer.\n */\nexport function selectIcons(library: LibraryIcon[], names: string[] | undefined) {\n if (!isDefined(names)) return library;\n\n const byName = new Map(library.map((icon) => [icon.name, icon]));\n\n return [...new Set(names)].flatMap((name) => {\n const icon = byName.get(name);\n\n return isDefined(icon) ? [icon] : [];\n });\n}\n\n/**\n * Lists identifiers as inline code, separated by commas.\n *\n * @param identifiers - The identifiers.\n * @returns The list.\n */\nfunction formatList(identifiers: string[]) {\n return identifiers.map((identifier) => `\\`${identifier}\\``).join(\", \");\n}\n\n/**\n * Describes why a library the project hasn't installed can't be shown, and what to add.\n *\n * @param label - Readable name of the library.\n * @param packageName - Package the library is read from, or an example of one for a family of packages.\n * @param family - Whether the library is a family of packages, one per style.\n * @param listed - Whether the project's `package.json` lists the package.\n * @param sitePackage - Another package of the library the project lists, or undefined when there's none.\n * @returns The problem.\n */\nfunction describeMissingLibrary(\n label: string,\n packageName: string,\n family: boolean,\n listed: boolean,\n sitePackage: string | undefined,\n): LibraryProblem {\n if (listed) {\n return {\n title: `${label} isn't installed yet`,\n description: `\\`${packageName}\\` is in \\`package.json\\` but not in \\`node_modules\\`. Reinstall the project's dependencies.`,\n };\n }\n\n if (isDefined(sitePackage)) {\n return {\n title: `${label} needs \\`${packageName}\\``,\n description: `The Studio reads ${label} from \\`${packageName}\\`, not \\`${sitePackage}\\`. Add it as a dev dependency.`,\n };\n }\n\n return {\n title: `${label} isn't installed`,\n description: family\n ? `Install a ${label} style package, such as \\`${packageName}\\`.`\n : `Install \\`${packageName}\\` in the project.`,\n };\n}\n\n/**\n * Loads one library style from the sets the build step converted.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nasync function readLibrary(library: string | undefined, style: string | undefined): Promise<LibraryResult> {\n if (!isDefined(library)) {\n return {\n problem: {\n title: \"No icon library set\",\n description: \"Set `library` in the icon plugin's configuration or in the field's options.\",\n },\n };\n }\n\n if (!iconRegistry.ready) {\n return {\n problem: {\n title: \"Icons aren't set up\",\n description: \"Add `withIcons()` to the Studio's build configuration, then restart the Studio.\",\n },\n };\n }\n\n const info = iconRegistry.libraries[library];\n if (!isDefined(info)) {\n return {\n problem: {\n title: \"Unknown icon library\",\n description: `There's no icon library called \\`${library}\\`. Use one of: ${formatList(Object.keys(iconRegistry.libraries))}.`,\n },\n };\n }\n\n const { label, packageName, packagePrefix, styles, listed, installed, sitePackage } = info;\n if (!installed) {\n return { problem: describeMissingLibrary(label, packageName, isDefined(packagePrefix), listed, sitePackage) };\n }\n\n const resolvedStyle = style ?? styles[0] ?? \"\";\n const loader = iconRegistry.sets[getIconSetKey(library, resolvedStyle)];\n if (!isDefined(loader)) {\n return {\n problem: isDefined(packagePrefix)\n ? {\n title: `${label} style \\`${resolvedStyle}\\` isn't installed`,\n description: `Install \\`${packagePrefix}${resolvedStyle}\\` in the project.`,\n }\n : {\n title: `Unknown ${label} style`,\n description: `${label} has no \\`${resolvedStyle}\\` style. Use one of: ${formatList(styles)}.`,\n },\n };\n }\n\n const module = await loader();\n const set = parseIconSet(module.default);\n if (!isDefined(set)) {\n return { problem: { title: `Couldn't load ${label}`, description: \"Restart the Studio and try again.\" } };\n }\n\n return {\n icons: set.icons.map(({ name, keywords, node, root }) => ({\n name,\n label: convertCase(name, \"title\"),\n tags: keywords.join(\", \"),\n drawing: { root: root ?? set.root, node },\n terms: normalizeTerms([name, ...keywords].join(\" \")),\n })),\n };\n}\n\n/** Library requests shared by every field in the session, keyed by library and style, since the data never changes. */\nconst libraryRequests = new Map<string, Promise<LibraryResult>>();\n\n/**\n * Loads a library style, reusing a request already in progress.\n *\n * @param library - Identifier of the library, or undefined when none is set.\n * @param style - Identifier of the style, or undefined for the library's default.\n * @returns The icons, or why they can't be shown.\n */\nexport async function requestLibrary(library: string | undefined, style: string | undefined) {\n const key = getIconSetKey(library ?? \"\", style ?? \"\");\n let request = libraryRequests.get(key);\n\n if (!isDefined(request)) {\n request = readLibrary(library, style);\n libraryRequests.set(key, request);\n }\n\n const result = await request;\n\n return result;\n}\n","import type { SanityIconNames } from \"@driftime/sanity-plugin-icon/names\";\n\nimport type { iconLibraryStyles } from \"@/lib/libraries\";\n\n/** Schema type name of the icon object. */\nexport const iconTypeName = \"icon\";\n\n/**\n * Stored icon: which library it came from, its name, and the shapes it's drawn from.\n *\n * @public\n */\nexport interface SanityIcon {\n _type: typeof iconTypeName;\n /** Identifier of the library the icon came from. */\n library?: string;\n /** Identifier of the library style the icon came from. */\n style?: string;\n /** Name of the icon in its library. */\n name?: string;\n /** Shapes the icon is drawn from, saved when it's chosen. */\n node?: string;\n}\n\n/** Styles of each supported library, from the plugin's own list. */\ntype IconLibraryStyles = typeof iconLibraryStyles;\n\n/**\n * Identifier of a library the plugin supports.\n *\n * @public\n */\nexport type SanityIconLibrary = keyof IconLibraryStyles;\n\n/**\n * Styles a library offers. The project's own icon folders have one style, `default`.\n *\n * @public\n */\nexport type SanityIconStyle<Library extends string> = Library extends SanityIconLibrary\n ? IconLibraryStyles[Library][number]\n : \"default\";\n\n/**\n * Names of a library's icons, once the build step has listed the installed version's, or any name before then.\n *\n * @public\n */\nexport type SanityIconName<Library extends string> = Library extends keyof SanityIconNames\n ? SanityIconNames[Library]\n : string;\n\n/** Libraries the build step has listed, or any identifier before it has, so the project's own folders can be named. */\nexport type ListedLibraryId = [keyof SanityIconNames] extends [never]\n ? string & NonNullable<unknown>\n : Extract<keyof SanityIconNames, string>;\n\n/** Libraries a field can name: the supported ones, plus the project's own folders. */\nexport type IconLibraryId = SanityIconLibrary | ListedLibraryId;\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAASO,QAAQ,EAAEC,OAAO,GAAGC,cAAsC;CACjE,IAAI,CAACT,UAAUQ,KAAK,GAAG,OAAOC;CAE9B,IAAME,eAAeH,MAAMI,MAAM,GAAG,CAAC,CAACC,SAASC,gBAAoC;EACjF,IAAM,CAACC,WAAW,IAAI,GAAGC,SAASF,YAAYF,MAAM,GAAG,GACjDK,OAAOF,SAASG,KAAK,GACrBC,SAASH,MAAMI,KAAK,GAAG,CAAC,CAACF,KAAK;EASpC,OARI,CAAClB,UAAUiB,IAAI,KAAK,CAACjB,UAAUmB,MAAM,IAAU,CAAA,IAQ5C,CAAC,CANIF,KAAKK,WAAW,IAAI,IAC5BL,OACAA,KACGM,QAAQ,UAAU,KAAK,CAAC,CACxBC,WAAW,wBAAwBC,QAAQC,WAAmBA,OAAOC,YAAY,CAAC,GAE3ER,MAAM,C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AO,iBAAiBL;EAASM,aAAa;CAAoC,EAAE;AAY5G;;AAGA,MAAMgE,kCAAkB,IAAIjC,IAAoC;;;;;;;;AAShE,eAAsBkC,eAAerC,SAA6BiB,OAA2B;CAC3F,IAAMqB,MAAM5E,cAAcsC,WAAW,IAAIiB,SAAS,EAAE,GAChDsB,UAAUH,gBAAgB7B,IAAI+B,GAAG;CASrC,OAPK9E,UAAU+E,OAAO,MACpBA,UAAUvB,YAAYhB,SAASiB,KAAK,GACpCmB,gBAAgBL,IAAIO,KAAKC,OAAO,IAK3BC,MAFcD;AAGvB;;ACxOA,MAAaI,eAAe"}
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
- import { n as logger, r as pluginName } from "./sets-kepuObH8.js";
1
+ import { n as pluginName, t as logger } from "./defaults-BEzCWZtH.js";
2
2
  import { n as isDefined } from "./utils-COPacfAq.js";
3
3
  import { r as isRegistryModule, t as createRegistryModule } from "./registry-B0Dxiwhh.js";
4
- import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-D5_YGFll.js";
4
+ import { a as writeIconNames, i as loadIconSet, n as detectLibraries, r as listRegistryDependencies, t as describeReport } from "./sets-B2lHNI7c.js";
5
5
  import path from "node:path";
6
6
  /** Prefix of the module each set is loaded from, followed by its library and style. */
7
7
  const setPrefix = `virtual:${pluginName}/set/`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftime/sanity-plugin-icon",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Icons for Sanity Studio, managed as content by the authors who use them.",
5
5
  "keywords": [
6
6
  "central-icons",
@@ -1,50 +0,0 @@
1
- import { n as isDefined } from "./utils-COPacfAq.js";
2
- import { n as iconSvgAttributes } from "./nodes-DAzj56Xn.js";
3
- import { createElement } from "react";
4
- import { jsx } from "react/jsx-runtime";
5
- /**
6
- * Converts stored attributes to React props, turning a `style` attribute into the object React expects.
7
- *
8
- * @param attributes - The stored attributes.
9
- * @returns The props.
10
- */
11
- function toProps({ style, ...attributes }) {
12
- if (!isDefined(style)) return attributes;
13
- let declarations = style.split(";").flatMap((declaration) => {
14
- let [property = "", ...value] = declaration.split(":"), name = property.trim(), joined = value.join(":").trim();
15
- return !isDefined(name) || !isDefined(joined) ? [] : [[name.startsWith("--") ? name : name.replace(/^-ms-/u, "ms-").replaceAll(/-(?<letter>[a-z])/gu, (_match, letter) => letter.toUpperCase()), joined]];
16
- });
17
- return {
18
- ...attributes,
19
- style: Object.fromEntries(declarations)
20
- };
21
- }
22
- /**
23
- * Draws one element of a stored drawing, with its children.
24
- *
25
- * @param child - The element, or text inside one.
26
- * @param index - Its position among its siblings.
27
- * @returns The element.
28
- */
29
- function renderChild(child, index) {
30
- if (typeof child == "string") return child;
31
- let [element, attributes, children] = child;
32
- return createElement(element, {
33
- ...toProps(attributes),
34
- key: String(index)
35
- }, children?.map((nested, position) => renderChild(nested, position)));
36
- }
37
- function Drawing({ drawing, ...props }) {
38
- if (!isDefined(drawing)) return null;
39
- let root = toProps(drawing.root);
40
- return /* @__PURE__ */ jsx("svg", {
41
- ...iconSvgAttributes,
42
- ...root,
43
- "aria-hidden": "true",
44
- ...props,
45
- children: drawing.node.map((child, index) => renderChild(child, index))
46
- });
47
- }
48
- export { Drawing as t };
49
-
50
- //# sourceMappingURL=drawing-ByrcBbWB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"drawing-ByrcBbWB.js","names":["isDefined","ComponentProps","ReactElement","createElement","IconDrawing","IconElement","iconSvgAttributes","toProps","style","attributes","Record","declarations","split","flatMap","declaration","property","value","name","trim","joined","join","key","startsWith","replace","replaceAll","_match","letter","toUpperCase","Object","fromEntries","renderChild","child","index","element","children","String","map","nested","position","DrawingProps","Omit","drawing","Drawing","props","root","node"],"sources":["../src/components/drawing.tsx"],"sourcesContent":["// Consumers render this in server components, where the compiler's memo cache hook can't run.\n\"use no memo\";\n\nimport { isDefined } from \"@repo/lib/utils\";\nimport type { ComponentProps, ReactElement } from \"react\";\nimport { createElement } from \"react\";\n\nimport type { IconDrawing, IconElement } from \"@/lib/nodes\";\nimport { iconSvgAttributes } from \"@/lib/nodes\";\n\n/**\n * Converts stored attributes to React props, turning a `style` attribute into the object React expects.\n *\n * @param attributes - The stored attributes.\n * @returns The props.\n */\nfunction toProps({ style, ...attributes }: Record<string, string>) {\n if (!isDefined(style)) return attributes;\n\n const declarations = style.split(\";\").flatMap((declaration): [string, string][] => {\n const [property = \"\", ...value] = declaration.split(\":\");\n const name = property.trim();\n const joined = value.join(\":\").trim();\n if (!isDefined(name) || !isDefined(joined)) return [];\n\n const key = name.startsWith(\"--\")\n ? name\n : name\n .replace(/^-ms-/u, \"ms-\")\n .replaceAll(/-(?<letter>[a-z])/gu, (_match, letter: string) => letter.toUpperCase());\n\n return [[key, joined]];\n });\n\n return { ...attributes, style: Object.fromEntries(declarations) };\n}\n\n/**\n * Draws one element of a stored drawing, with its children.\n *\n * @param child - The element, or text inside one.\n * @param index - Its position among its siblings.\n * @returns The element.\n */\nfunction renderChild(child: IconElement | string, index: number): ReactElement | string {\n if (typeof child === \"string\") return child;\n\n const [element, attributes, children] = child;\n\n return createElement(\n element,\n { ...toProps(attributes), key: String(index) },\n children?.map((nested, position) => renderChild(nested, position)),\n );\n}\n\nexport type DrawingProps = Omit<ComponentProps<\"svg\">, \"children\"> & { drawing: IconDrawing | undefined };\n\nexport function Drawing({ drawing, ...props }: DrawingProps) {\n if (!isDefined(drawing)) return null;\n\n // Stored roots only hold checked attribute names, but their values are text, not React's literal types.\n const root = toProps(drawing.root) as ComponentProps<\"svg\">;\n\n return (\n <svg {...iconSvgAttributes} {...root} aria-hidden=\"true\" {...props}>\n {drawing.node.map((child, index) => renderChild(child, index))}\n </svg>\n );\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAASO,QAAQ,EAAEC,OAAO,GAAGC,cAAsC;CACjE,IAAI,CAACT,UAAUQ,KAAK,GAAG,OAAOC;CAE9B,IAAME,eAAeH,MAAMI,MAAM,GAAG,CAAC,CAACC,SAASC,gBAAoC;EACjF,IAAM,CAACC,WAAW,IAAI,GAAGC,SAASF,YAAYF,MAAM,GAAG,GACjDK,OAAOF,SAASG,KAAK,GACrBC,SAASH,MAAMI,KAAK,GAAG,CAAC,CAACF,KAAK;EASpC,OARI,CAAClB,UAAUiB,IAAI,KAAK,CAACjB,UAAUmB,MAAM,IAAU,CAAA,IAQ5C,CAAC,CANIF,KAAKK,WAAW,IAAI,IAC5BL,OACAA,KACGM,QAAQ,UAAU,KAAK,CAAC,CACxBC,WAAW,wBAAwBC,QAAQC,WAAmBA,OAAOC,YAAY,CAAC,GAE3ER,MAAM,CAAC;CACvB,CAAC;CAED,OAAO;EAAE,GAAGV;EAAYD,OAAOoB,OAAOC,YAAYlB,YAAY;CAAE;AAClE;;;;;;;;AASA,SAASmB,YAAYC,OAA6BC,OAAsC;CACtF,IAAI,OAAOD,SAAU,UAAU,OAAOA;CAEtC,IAAM,CAACE,SAASxB,YAAYyB,YAAYH;CAExC,OAAO5B,cACL8B,SACA;EAAE,GAAG1B,QAAQE,UAAU;EAAGY,KAAKc,OAAOH,KAAK;CAAE,GAC7CE,UAAUE,KAAKC,QAAQC,aAAaR,YAAYO,QAAQC,QAAQ,CAAC,CACnE;AACF;AAIA,SAAgBI,QAAQ,EAAED,SAAS,GAAGE,SAAuB;CAC3D,IAAI,CAAC3C,UAAUyC,OAAO,GAAG,OAAO;CAGhC,IAAMG,OAAOrC,QAAQkC,QAAQG,IAAI;CAEjC,OACE,oBAAC,OAAD;EAAK,GAAItC;EAAmB,GAAIsC;EAAM,eAAY;EAAO,GAAID;EAC1DF,UAAAA,QAAQI,KAAKT,KAAKL,OAAOC,UAAUF,YAAYC,OAAOC,KAAK,CAAC;CAC1D,CAAA;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sets-kepuObH8.js","names":["isDevelopment","process","env","isDevelopment","prefixStyle","createLogger","name","prefix","format","message","info","console","warn","error","createLogger","pluginName","logger","isDefined","isRecord","IconNode","IconRoot","parseIconNode","parseIconRoot","IconSetIcon","name","keywords","node","root","IconSet","library","style","icons","IconLibraryInfo","label","packageName","packagePrefix","styles","listed","installed","sitePackage","parseIconSetIcon","value","undefined","parsedNode","parsedRoot","Array","isArray","filter","keyword","parseIconSet","flatMap","icon","parsed","\"NODE_ENV\""],"sources":["../../@repo/lib/environment.ts","../../@repo/lib/logger.ts","../src/config/defaults.ts","../src/lib/sets.ts"],"sourcesContent":["/** Whether this is a development build, the only kind in which the plugin logs. */\nexport const isDevelopment = process.env[\"NODE_ENV\"] === \"development\";\n","import { isDevelopment } from \"./environment\";\n\n/** Console style for the prefix, in the blue the Studio uses for its own messages. */\nconst prefixStyle = \"color: #2276fc\";\n\n/**\n * Creates a logger that prefixes messages with the plugin's name and only logs in development builds.\n * Browser consoles show the prefix in blue.\n *\n * @param name - The package name to prefix messages with.\n * @returns Functions that log progress, a warning, or an error, or format a message to throw.\n */\nexport function createLogger(name: string) {\n const prefix = `[${name}]`;\n\n /**\n * Prefixes a message with the package name.\n *\n * @param message - The message.\n * @returns The prefixed message.\n */\n function format(message: string) {\n return `${prefix} ${message}`;\n }\n\n return {\n /**\n * Logs progress worth seeing, such as what a build step did, in development builds only.\n *\n * @param message - What happened.\n */\n info(message: string) {\n if (isDevelopment) console.info(`%c${prefix}%c ${message}`, prefixStyle, \"\");\n },\n /**\n * Logs a warning about something the plugin recovered from, in development builds only.\n *\n * @param message - What happened and what to do about it.\n */\n warn(message: string) {\n if (isDevelopment) console.warn(`%c${prefix}%c ${message}`, prefixStyle, \"\");\n },\n /**\n * Logs an error the plugin couldn't recover from, in development builds only.\n *\n * @param message - What went wrong and what to do about it.\n */\n error(message: string) {\n if (isDevelopment) console.error(`%c${prefix}%c ${message}`, prefixStyle, \"\");\n },\n format,\n };\n}\n","import { createLogger } from \"@repo/lib/logger\";\n\n/** Package name, used as the prefix on every logged message. */\nexport const pluginName = \"@driftime/sanity-plugin-icon\";\n\n/** The package's logger. */\nexport const logger = createLogger(pluginName);\n","import { isDefined, isRecord } from \"@repo/lib/utils\";\n\nimport type { IconNode, IconRoot } from \"@/lib/nodes\";\nimport { parseIconNode, parseIconRoot } from \"@/lib/nodes\";\n\n/** One icon in a converted set. */\nexport interface IconSetIcon {\n /** Name of the icon in its library. */\n name: string;\n /** Words describing the icon, from its library. */\n keywords: string[];\n /** Shapes the icon is drawn from. */\n node: IconNode;\n /** Root for this icon, or undefined when it uses the set's. */\n root?: IconRoot;\n}\n\n/** Icons of one library style, converted by the build step into the stored drawing format. */\nexport interface IconSet {\n /** Identifier of the library, such as `lucide`. */\n library: string;\n /** Identifier of the style, such as `bold`. */\n style: string;\n /** Root most icons in the set share. */\n root: IconRoot;\n /** Every icon in the set. */\n icons: IconSetIcon[];\n}\n\n/**\n * A library the build step knows how to convert, and whether the project has it installed.\n *\n * @public\n */\nexport interface IconLibraryInfo {\n /** Readable name of the library. */\n label: string;\n /** Package the library is read from, or an example of one for a family of packages. */\n packageName: string;\n /** Shared start of the package names of a family of packages, one per style, or undefined for a single package. */\n packagePrefix?: string;\n /** Styles the library offers, the first being the default. */\n styles: string[];\n /** Whether the project's `package.json` lists the package, installed or not. */\n listed: boolean;\n /** Whether the project has the package installed. */\n installed: boolean;\n /** Another package of the library the project lists, such as its React version, or undefined when there's none. */\n sitePackage?: string;\n}\n\n/**\n * Reads one icon of a converted set, skipping it when its data isn't usable.\n *\n * @param value - The value to read.\n * @returns The icon, or undefined when the value isn't one.\n */\nfunction parseIconSetIcon(value: unknown): IconSetIcon | undefined {\n if (!isRecord(value)) return undefined;\n\n const { name, keywords, node, root } = value;\n const parsedNode = parseIconNode(node);\n const parsedRoot = isDefined(root) ? parseIconRoot(root) : undefined;\n\n if (typeof name !== \"string\" || !Array.isArray(keywords) || !isDefined(parsedNode)) return undefined;\n if (isDefined(root) && !isDefined(parsedRoot)) return undefined;\n\n return {\n name,\n keywords: keywords.filter((keyword: unknown) => typeof keyword === \"string\"),\n node: parsedNode,\n ...(isDefined(parsedRoot) && { root: parsedRoot }),\n };\n}\n\n/**\n * Reads a converted set, keeping only the icons whose data is usable.\n *\n * @param value - The value to read.\n * @returns The set, or undefined when the value isn't one.\n */\nexport function parseIconSet(value: unknown): IconSet | undefined {\n if (!isRecord(value)) return undefined;\n\n const { library, style, root, icons } = value;\n const parsedRoot = parseIconRoot(root);\n\n if (typeof library !== \"string\" || typeof style !== \"string\" || !isDefined(parsedRoot) || !Array.isArray(icons)) {\n return undefined;\n }\n\n return {\n library,\n style,\n root: parsedRoot,\n icons: icons.flatMap((icon: unknown) => {\n const parsed = parseIconSetIcon(icon);\n\n return isDefined(parsed) ? [parsed] : [];\n }),\n };\n}\n"],"mappings":";;;AACA,MAAaA,gBAAgBC,QAAQC,IAAImD,aAAgB,eCEnDjD,cAAc;;;;;;;;AASpB,SAAgBC,aAAaC,MAAc;CACzC,IAAMC,SAAS,IAAID,KAAI;;;;;;;CAQvB,SAASE,OAAOC,SAAiB;EAC/B,OAAO,GAAGF,OAAM,GAAIE;CACtB;CAEA,OAAO;;;;;;EAMLC,KAAKD,SAAiB;GACpB,AAAIN,iBAAeQ,QAAQD,KAAK,KAAKH,OAAM,KAAME,WAAWL,aAAa,EAAE;EAC7E;;;;;;EAMAQ,KAAKH,SAAiB;GACpB,AAAIN,iBAAeQ,QAAQC,KAAK,KAAKL,OAAM,KAAME,WAAWL,aAAa,EAAE;EAC7E;;;;;;EAMAS,MAAMJ,SAAiB;GACrB,AAAIN,iBAAeQ,QAAQE,MAAM,KAAKN,OAAM,KAAME,WAAWL,aAAa,EAAE;EAC9E;EACAI;CACF;AACF;;ACjDA,MAAaO,aAAa,gCAGbC,SAASF,aAAaC,UAAU;;;;;;;ACmD7C,SAASyB,iBAAiBC,OAAyC;CACjE,IAAI,CAACvB,SAASuB,KAAK,GAAG;CAEtB,IAAM,EAAEjB,MAAMC,UAAUC,MAAMC,SAASc,OACjCE,aAAatB,cAAcK,IAAI,GAC/BkB,aAAa3B,UAAUU,IAAI,IAAIL,cAAcK,IAAI,IAAIe,KAAAA;CAE3D,IAAI,OAAOlB,QAAS,YAAaqB,MAAMC,QAAQrB,QAAQ,KAAMR,UAAU0B,UAAU,MAC7E1B,WAAUU,IAAI,KAAMV,UAAU2B,UAAU,IAE5C,OAAO;EACLpB;EACAC,UAAUA,SAASsB,QAAQC,YAAqB,OAAOA,WAAY,QAAQ;EAC3EtB,MAAMiB;EACN,GAAI1B,UAAU2B,UAAU,KAAK,EAAEjB,MAAMiB,WAAW;CAClD;AACF;;;;;;;AAQA,SAAgBK,aAAaR,OAAqC;CAChE,IAAI,CAACvB,SAASuB,KAAK,GAAG;CAEtB,IAAM,EAAEZ,SAASC,OAAOH,MAAMI,UAAUU,OAClCG,aAAatB,cAAcK,IAAI;CAErC,IAAI,OAAOE,WAAY,YAAY,OAAOC,SAAU,YAAab,UAAU2B,UAAU,KAAMC,MAAMC,QAAQf,KAAK,GAI9G,OAAO;EACLF;EACAC;EACAH,MAAMiB;EACNb,OAAOA,MAAMmB,SAASC,SAAkB;GACtC,IAAMC,SAASZ,iBAAiBW,IAAI;GAEpC,OAAOlC,UAAUmC,MAAM,IAAI,CAACA,MAAM,IAAI,CAAA;EACxC,CAAC;CACH;AACF"}
@@ -1,20 +0,0 @@
1
- /** Schema type name of the icon object. */
2
- declare const iconTypeName = "icon";
3
- /**
4
- * Stored icon: which library it came from, its name, and the shapes it's drawn from.
5
- *
6
- * @public
7
- */
8
- interface SanityIcon {
9
- _type: typeof iconTypeName;
10
- /** Identifier of the library the icon came from. */
11
- library?: string;
12
- /** Identifier of the library style the icon came from. */
13
- style?: string;
14
- /** Name of the icon in its library. */
15
- name?: string;
16
- /** Shapes the icon is drawn from, saved when it's chosen. */
17
- node?: string;
18
- }
19
- export { iconTypeName as n, SanityIcon as t };
20
- //# sourceMappingURL=types-qlHEYDoN.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-qlHEYDoN.d.ts","names":["iconTypeName","SanityIcon"],"sources":["../src/types.ts"],"mappings":"AACA;cAAaA;;;;;;UAOIC;EACf,cAAcD;;EAEd;;EAEA;;EAEA;;EAEA"}