{
  "version": 3,
  "sources": ["../src/index.ts", "../src/oracle.ts", "../src/faviconsDefaults.ts"],
  "sourcesContent": ["import type { Plugin, HtmlTagDescriptor, ResolvedConfig } from 'vite';\nimport type { PluginContext } from 'rollup';\nimport favicons from 'favicons';\nimport Oracle from './oracle.js';\nimport path from 'path';\nimport { getDefaultFaviconConfig } from './faviconsDefaults.js';\nimport { parseFragment } from 'parse5';\nimport type { FaviconOptions } from './faviconsTypes.js';\n\ntype FaviconsConfig = Partial<FaviconOptions>\nexport type ViteFaviconsPluginOptions = {\n\t/** Your source logo (Will default to )\n\t\t@default \"assets/logo.png\"\n\t */\n\tlogo?: string,\n\t/** Inject html links/metadata -- set to `false` to generate a webapp.html` file.\n\t\t@default true\n\t */\n\tinject?: boolean,\n\t/** `Favicons` configuration options\n\t *  - [See `favicons` documentation](https://github.com/itgalaxy/favicons)\n\t*/\n\tfavicons?: FaviconsConfig,\n\t/** The root of the project from which you want to load metadata\n\t\t@default process.cwd()\n\t */\n\tprojectRoot?: string,\n\t/** Output Path for the favicon images & files, relative to the Vite assets directory\n\t */\n\toutputPath?: string,\n\t/** prefix is delegated to Rollup/Vite (keeping for people migrating from Webpack)\n\t * @deprecated\n\t*/\n\tprefix?: string,\n\t/** Caching is delegated to Rollup/Vite (keeping for people migrating from Webpack)\n\t * @deprecated\n\t*/\n\tcache?: boolean,\n\t/** Public Path is delegated to Rollup/Vite (keeping for people migrating from Webpack)\n\t * @deprecated\n\t*/\n\tpublicPath?: string,\n}\n\nclass HtmlTag implements HtmlTagDescriptor {\n\ttag: string\n\tattrs: Record<string,string|boolean>;\n\tconstructor (tag: string, attrs: Record<string,string|boolean>) {\n\t\tthis.tag = tag;\n\t\tthis.attrs = attrs;\n\t}\n}\n\ntype FaviconsPluginArgs = Partial<ViteFaviconsPluginOptions> | ViteFaviconsPluginOptions['logo']\n\nexport const ViteFaviconsPlugin = (options: FaviconsPluginArgs = {} ): Plugin => {\n\tlet viteConfig: ResolvedConfig;\n\tconst lOptions = typeof options === 'string' ? {logo:options} : options;\n\tlOptions.outputPath = lOptions.outputPath === undefined ? '' : lOptions.outputPath;\n\tlOptions.inject = lOptions.inject === undefined ? true : lOptions.inject;\n\tlOptions.projectRoot = lOptions.projectRoot === undefined ? process.cwd() : lOptions.projectRoot;\n\tconst LOGO_PATH = path.resolve(lOptions.logo || path.join('assets','logo.png'));\n\tconst oracle = new Oracle(lOptions.projectRoot);\n\tconst {\n\t\tappName = oracle.guessAppName(),\n\t\tappDescription = oracle.guessDescription(),\n\t\tversion = oracle.guessVersion(),\n\t\tdeveloperName = oracle.guessDeveloperName(),\n\t\tdeveloperURL = oracle.guessDeveloperURL(),\n\t} = lOptions.favicons || {};\n\tlOptions.favicons = lOptions.favicons || {};\n\tObject.assign(lOptions.favicons, {\n\t\tappName,\n\t\tappDescription,\n\t\tversion,\n\t\tdeveloperName,\n\t\tdeveloperURL,\n\t});\n\tconst getFavicons = async () => {\n\t\tif (lOptions && lOptions.favicons) {\n\t\t\tconst outputPath = lOptions.outputPath === undefined ? '' : lOptions.outputPath;\n\t\t\tlOptions.favicons.path = path.join(viteConfig.base, viteConfig.build.assetsDir, outputPath);\n\t\t}\n\t\tconst faviconConfig = getDefaultFaviconConfig(lOptions);\n\t\treturn await favicons(LOGO_PATH,faviconConfig);\n\t};\n\n\tconst tags: HtmlTag[] = [];\n\tconst assetIds: Map<string,string> = new Map();\n\n\tconst rebuildFavicons = async (ctx: PluginContext) => {\n\t\tctx.addWatchFile(LOGO_PATH);\n\t\tconst res = await getFavicons();\n\t\t// Only emit files if we're doing a build\n\t\tif (viteConfig.command === 'build') {\n\t\t\tfor (const {name, contents} of res.files) {\n\t\t\t\tconst outputPath = lOptions.outputPath === undefined ? '' : lOptions.outputPath;\n\t\t\t\tconst filePath = path.join(viteConfig.build.assetsDir, outputPath, name);\n\t\t\t\tassetIds.set(name, ctx.emitFile({type: 'asset', fileName: filePath, source: contents}));\n\t\t\t}\n\t\t\tfor (const {name, contents} of res.images) {\n\t\t\t\tconst outputPath = lOptions.outputPath === undefined ? '' : lOptions.outputPath;\n\t\t\t\tconst filePath = path.join(viteConfig.build.assetsDir, outputPath, name);\n\t\t\t\tassetIds.set(name, ctx.emitFile({type: 'asset', fileName: filePath, source: contents}));\n\t\t\t}\n\t\t\tif (!lOptions.inject) {\n\t\t\t\tconst name = 'webapp.html';\n\t\t\t\tconst contents = res.html.join(\"\\n\");\n\t\t\t\tconst outputPath = lOptions.outputPath === undefined ? '' : lOptions.outputPath;\n\t\t\t\tconst filePath = path.join(viteConfig.build.assetsDir, outputPath, name);\n\t\t\t\tassetIds.set(name, ctx.emitFile({type: 'asset', fileName: filePath, source: contents}));\n\t\t\t}\n\t\t}\n\t\t// Parse the HTML into tag objects for later injection\n\t\tfor (const tag of res.html) {\n\t\t\tconst node = <{nodeName:string, attrs: [{name: string,value:string}]}><unknown>parseFragment(tag).childNodes[0];\n\t\t\ttags.push(new HtmlTag(node.nodeName,node.attrs.reduce((acc,v) => {\n\t\t\t\tconst resolvedValue = assetIds.has(v.value.slice(1))\n\t\t\t\t\t? assetIds.get(v.value.slice(1)) || v.value\n\t\t\t\t\t: v.value;\n\t\t\t\tacc[v.name] = resolvedValue;\n\t\t\t\treturn acc;\n\t\t\t},<Record<string,string>>{})));\n\t\t}\n\t};\n\n\treturn {\n\t\tname: 'vite-plugin-favicon',\n\t\tapply: 'build',\n\t\tasync buildStart () {\n\t\t\tawait rebuildFavicons(this);\n\t\t},\n\t\tconfigResolved(resolvedConfig: ResolvedConfig) {\n\t\t\tviteConfig = resolvedConfig;\n\t\t},\n\t\ttransformIndexHtml () {\n\t\t\tif (lOptions.inject) {\n\t\t\t\treturn tags;\n\t\t\t}\n\t\t},\n\t};\n};\nexport default ViteFaviconsPlugin;\n", "import path from 'path';\nimport findRoot from 'find-root';\nimport parseAuthor from 'parse-author';\ntype pack = Partial<typeof import('../package.json')>\ntype nString = string | undefined\nexport default class Oracle {\n\tpkg: pack;\n\tconstructor (startingPath: string) {\n\t\ttry {\n\t\t\tthis.pkg = require(path.join(findRoot(startingPath), 'package.json'));\n\t\t} catch (_) {\n\t\t\tthis.pkg = {};\n\t\t}\n\t}\n\n\t/**\n\t * Tries to guess the name from package.json\n\t */\n\tguessAppName (): nString {\n\t\treturn this.pkg.name;\n\t}\n\n\t/**\n\t * Tries to guess the description from package.json\n\t */\n\tguessDescription (): nString {\n\t\treturn this.pkg.description;\n\t}\n\n\t/**\n\t * Tries to guess the version from package.json\n\t */\n\tguessVersion (): nString {\n\t\treturn this.pkg.version;\n\t}\n\n\t/**\n\t * Tries to guess the developer {name, email, url} from package.json\n\t */\n\tguessDeveloper (): {name?: nString, email?: nString, url?: nString} {\n\t\tlet author = typeof this.pkg.author === 'string'\n\t\t\t? parseAuthor(this.pkg.author)\n\t\t\t: typeof this.pkg.author === 'object' && this.pkg.author\n\t\t\t\t? {\n\t\t\t\t\tname: this.pkg.author.name,\n\t\t\t\t\temail: this.pkg.author?.email,\n\t\t\t\t\turl: this.pkg.author?.url,\n\t\t\t\t}\n\t\t\t\t: {};\n\t\tif (!Object.keys(author).length){\n\t\t\tif (Array.isArray(this.pkg.maintainers) && this.pkg.maintainers.length) {\n\t\t\t\tconst maintainer = this.pkg.maintainers[0];\n\t\t\t\tauthor = typeof maintainer === 'string'\n\t\t\t\t\t? parseAuthor(<string>(<unknown>this.pkg.maintainers[0]))\n\t\t\t\t\t: typeof maintainer === 'object' && maintainer\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\tname: maintainer.name,\n\t\t\t\t\t\t\temail: maintainer?.email,\n\t\t\t\t\t\t\turl: maintainer?.url,\n\t\t\t\t\t\t}\n\t\t\t\t\t\t: {};\n\t\t\t}\n\t\t}\n\t\treturn author;\n\t}\n\n\t/**\n\t * Tries to guess the developer name from package.json\n\t */\n\tguessDeveloperName (): string | undefined {\n\t\treturn this.guessDeveloper().name;\n\t}\n\n\t/**\n\t * Tries to guess the developer URL from package.json\n\t */\n\tguessDeveloperURL (): string | undefined {\n\t\treturn this.guessDeveloper().url;\n\t}\n}\n", "import { FaviconOptions } from 'favicons';\nimport { ViteFaviconsPluginOptions } from './index.js';\n\nexport const getDefaultFaviconConfig = (options: ViteFaviconsPluginOptions): Partial<FaviconOptions> => {\n\tconst fOptions = options.favicons;\n\treturn {\n\t\tappShortName: null,                       // Your application's short_name. `string`. Optional. If not set, appName will be used\n\t\tdir: 'auto',                              // Primary text direction for name, short_name, and description\n\t\tlang: 'en-US',                            // Primary language for name and short_name\n\t\tbackground: '#fff',                       // Background colour for flattened icons. `string`\n\t\ttheme_color: '#fff',                      // Theme color user for example in Android's task switcher. `string`\n\t\tappleStatusBarStyle: 'black-translucent', // Style for Apple status bar: \"black-translucent\", \"default\", \"black\". `string`\n\t\tdisplay: 'standalone',                    // Preferred display mode: \"fullscreen\", \"standalone\", \"minimal-ui\" or \"browser\". `string`\n\t\torientation: 'any',                       // Default orientation: \"any\", \"natural\", \"portrait\" or \"landscape\". `string`\n\t\tscope: '/',                               // set of URLs that the browser considers within your app\n\t\tstart_url: '/?homescreen=1',              // Start URL when launching the application from a device. `string`\n\t\tversion: '1.0',                           // Your application's version string. `string`\n\t\tlogging: false,                           // Print logs to console? `boolean`\n\t\tpixel_art: false,                         // Keeps pixels \"sharp\" when scaling up, for pixel art.  Only supported in offline mode.\n\t\tloadManifestWithCredentials: false,       // Browsers don't send cookies when fetching a manifest, enable this to fix that. `boolean`\n\t\t...fOptions,\n\t\ticons: {\n\t\t\t// Platform Options:\n\t\t\t// - offset - offset in percentage\n\t\t\t// - background:\n\t\t\t//   * false - use default\n\t\t\t//   * true - force use default, e.g. set background for Android icons\n\t\t\t//   * color - set background for the specified icons\n\t\t\t//   * mask - apply mask in order to create circle icon (applied by default for firefox). `boolean`\n\t\t\t//   * overlayGlow - apply glow effect after mask has been applied (applied by default for firefox). `boolean`\n\t\t\t//   * overlayShadow - apply drop shadow after mask has been applied .`boolean`\n\t\t\t//\n\t\t\tandroid: true,              // Create Android homescreen icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tappleIcon: true,            // Create Apple touch icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tappleStartup: true,         // Create Apple startup images. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tcoast: true,                // Create Opera Coast icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tfavicons: true,             // Create regular favicons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tfirefox: true,              // Create Firefox OS icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\twindows: true,              // Create Windows 8 tile icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\tyandex: true,                // Create Yandex browser icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources\n\t\t\t...fOptions?.icons,\n\t\t},\n\t};\n};\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;AAEA;;;ACFA;AACA;AACA;AAGA,mBAA4B;AAAA,EAE3B,YAAa,cAAsB;AAClC,QAAI;AACH,WAAK,MAAM,QAAQ,KAAK,KAAK,SAAS,eAAe;AAAA,aAC7C,GAAP;AACD,WAAK,MAAM;AAAA;AAAA;AAAA,EAOb,eAAyB;AACxB,WAAO,KAAK,IAAI;AAAA;AAAA,EAMjB,mBAA6B;AAC5B,WAAO,KAAK,IAAI;AAAA;AAAA,EAMjB,eAAyB;AACxB,WAAO,KAAK,IAAI;AAAA;AAAA,EAMjB,iBAAoE;AAvCrE;AAwCE,QAAI,SAAS,OAAO,KAAK,IAAI,WAAW,WACrC,YAAY,KAAK,IAAI,UACrB,OAAO,KAAK,IAAI,WAAW,YAAY,KAAK,IAAI,SAC/C;AAAA,MACD,MAAM,KAAK,IAAI,OAAO;AAAA,MACtB,OAAO,WAAK,IAAI,WAAT,mBAAiB;AAAA,MACxB,KA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