UNPKG

vue-svg-loader

Version:
195 lines (169 loc) 6.21 kB
import { BindingMetadata } from '@vue/compiler-core'; import { CodegenResult } from '@vue/compiler-core'; import { CompilerError } from '@vue/compiler-core'; import { CompilerOptions } from '@vue/compiler-core'; import { generateCodeFrame } from '@vue/compiler-core'; import { LazyResult } from 'postcss'; import { ParserOptions } from '@vue/compiler-core'; import { ParserPlugin } from '@babel/parser'; import { RawSourceMap } from 'source-map'; import { Result } from 'postcss'; import { RootNode } from '@vue/compiler-core'; import { SourceLocation } from '@vue/compiler-core'; /** * Analyze bindings in normal `<script>` * Note that `compileScriptSetup` already analyzes bindings as part of its * compilation process so this should only be used on single `<script>` SFCs. */ export declare function analyzeScriptBindings(_script: SFCScriptBlock): BindingMetadata; declare interface AssetURLOptions { /** * If base is provided, instead of transforming relative asset urls into * imports, they will be directly rewritten to absolute urls. */ base?: string | null; /** * If true, also processes absolute urls. */ includeAbsolute?: boolean; tags?: AssetURLTagConfig; } declare interface AssetURLTagConfig { [name: string]: string[]; } export { BindingMetadata } export { CompilerError } export { CompilerOptions } /** * Compile `<script setup>` * It requires the whole SFC descriptor because we need to handle and merge * normal `<script>` + `<script setup>` if both are present. */ export declare function compileScript(sfc: SFCDescriptor, options?: SFCScriptCompileOptions): SFCScriptBlock; export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults; export declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>; export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults; export { generateCodeFrame } export declare function parse(source: string, { sourceMap, filename, sourceRoot, pad, compiler }?: SFCParseOptions): SFCParseResult; declare type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus'; /** * Utility for rewriting `export default` in a script block into a variable * declaration so that we can inject things into it */ export declare function rewriteDefault(input: string, as: string, parserPlugins?: ParserPlugin[]): string; export declare interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions { isAsync?: boolean; modules?: boolean; modulesOptions?: { scopeBehaviour?: 'global' | 'local'; globalModulePaths?: string[]; generateScopedName?: string | ((name: string, filename: string, css: string) => string); hashPrefix?: string; localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'; }; } export declare interface SFCBlock { type: string; content: string; attrs: Record<string, string | true>; loc: SourceLocation; map?: RawSourceMap; lang?: string; src?: string; } export declare interface SFCDescriptor { filename: string; source: string; template: SFCTemplateBlock | null; script: SFCScriptBlock | null; scriptSetup: SFCScriptBlock | null; styles: SFCStyleBlock[]; customBlocks: SFCBlock[]; } export declare interface SFCParseOptions { filename?: string; sourceMap?: boolean; sourceRoot?: string; pad?: boolean | 'line' | 'space'; compiler?: TemplateCompiler; } declare interface SFCParseResult { descriptor: SFCDescriptor; errors: (CompilerError | SyntaxError)[]; } export declare interface SFCScriptBlock extends SFCBlock { type: 'script'; setup?: string | boolean; bindings?: BindingMetadata; } export declare interface SFCScriptCompileOptions { /** * https://babeljs.io/docs/en/babel-parser#plugins */ babelParserPlugins?: ParserPlugin[]; } export declare interface SFCStyleBlock extends SFCBlock { type: 'style'; scoped?: boolean; vars?: string; module?: string | boolean; } export declare interface SFCStyleCompileOptions { source: string; filename: string; id: string; map?: RawSourceMap; scoped?: boolean; vars?: boolean; trim?: boolean; preprocessLang?: PreprocessLang; preprocessOptions?: any; preprocessCustomRequire?: (id: string) => any; postcssOptions?: any; postcssPlugins?: any[]; } export declare interface SFCStyleCompileResults { code: string; map: RawSourceMap | undefined; rawResult: LazyResult | Result | undefined; errors: Error[]; modules?: Record<string, string>; dependencies: Set<string>; } export declare interface SFCTemplateBlock extends SFCBlock { type: 'template'; functional?: boolean; } export declare interface SFCTemplateCompileOptions { source: string; filename: string; ssr?: boolean; inMap?: RawSourceMap; compiler?: TemplateCompiler; compilerOptions?: CompilerOptions; preprocessLang?: string; preprocessOptions?: any; /** * In some cases, compiler-sfc may not be inside the project root (e.g. when * linked or globally installed). In such cases a custom `require` can be * passed to correctly resolve the preprocessors. */ preprocessCustomRequire?: (id: string) => any; /** * Configure what tags/attributes to transform into asset url imports, * or disable the transform altogether with `false`. */ transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean; } export declare interface SFCTemplateCompileResults { code: string; source: string; tips: string[]; errors: (string | CompilerError)[]; map?: RawSourceMap; } export declare interface TemplateCompiler { compile(template: string, options: CompilerOptions): CodegenResult; parse(template: string, options: ParserOptions): RootNode; } export { }