import { type BindingMetadata, type CodegenSourceMapGenerator, type CompilerError, type ElementNode, NodeTypes, type ParserOptions, type RawSourceMap, type RootNode, type SourceLocation, createRoot, } from '@vue/compiler-core' import * as CompilerDOM from '@vue/compiler-dom' import { SourceMapGenerator } from 'source-map-js' import type { TemplateCompiler } from './compileTemplate' import { parseCssVars } from './style/cssVars' import { createCache } from './cache' import type { ImportBinding } from './compileScript' import { isImportUsed } from './script/importUsageCheck' export const DEFAULT_FILENAME = 'anonymous.vue' export interface SFCParseOptions { filename?: string sourceMap?: boolean sourceRoot?: string pad?: boolean | 'line' | 'space' ignoreEmpty?: boolean compiler?: TemplateCompiler templateParseOptions?: ParserOptions /** * TODO remove in 3.5 * @deprecated use `templateParseOptions: { prefixIdentifiers: false }` instead */ parseExpressions?: boolean } export interface SFCBlock { type: string content: string attrs: Record loc: SourceLocation map?: RawSourceMap lang?: string src?: string } export interface SFCTemplateBlock extends SFCBlock { type: 'template' ast?: RootNode } export interface SFCScriptBlock extends SFCBlock { type: 'script' setup?: string | boolean bindings?: BindingMetadata imports?: Record scriptAst?: import('@babel/types').Statement[] scriptSetupAst?: import('@babel/types').Statement[] warnings?: string[] /** * Fully resolved dependency file paths (unix slashes) with imported types * used in macros, used for HMR cache busting in @vitejs/plugin-vue and * vue-loader. */ deps?: string[] } export interface SFCStyleBlock extends SFCBlock { type: 'style' scoped?: boolean module?: string | boolean } export interface SFCDescriptor { filename: string source: string template: SFCTemplateBlock | null script: SFCScriptBlock | null scriptSetup: SFCScriptBlock | null styles: SFCStyleBlock[] customBlocks: SFCBlock[] cssVars: string[] /** * whether the SFC uses :slotted() modifier. * this is used as a compiler optimization hint. */ slotted: boolean vapor: boolean /** * compare with an existing descriptor to determine whether HMR should perform * a reload vs. re-render. * * Note: this comparison assumes the prev/next script are already identical, * and only checks the special case where