import { getPackageInfo , isPackageExists } from 'local-pkg' ; import createDebugger from 'debug' ; import type { Options , ResolvedOptions } from '../types' ; const debug = createDebugger ( 'unplugin-icons:options' ) ; export async function resolveOptions ( options ) { const { scale = 1.2 , defaultStyle = '' , defaultClass = '' , compiler = await guessCompiler ( ) , jsx = guessJSX ( ) , customCollections = { } , iconCustomizer = ( ) => { } , autoInstall = false , } = options ; const webComponents = Object . assign ( { autoDefine : false , iconPrefix : 'icon' , } , options . webComponents ) ; debug ( 'compiler' , compiler ) ; return { scale , defaultStyle , defaultClass , customCollections , iconCustomizer , compiler , jsx , webComponents , autoInstall , } ; } async function guessCompiler ( ) { return await getVueVersion ( ) || ( isPackageExists ( '@svgr/core' ) ? 'jsx' : 'vue3' ) ; } function guessJSX ( ) { if ( isPackageExists ( 'preact' ) ) return 'preact' ; return 'react' ; } async function getVueVersion ( ) { try { const result = await getPackageInfo ( 'vue' ) ; if ( ! result ) return null ; return result . version . startsWith ( '2.' ) ? 'vue2' : 'vue3' ; } catch { return null ; } }