import { ErrorHandlingOptions, ParserOptions } from './options' import { NO, isArray, makeMap, extend } from '@vue/shared' import { ErrorCodes, createCompilerError, defaultOnError, defaultOnWarn } from './errors' import { assert, advancePositionWithMutation, advancePositionWithClone, isCoreComponent } from './utils' import { Namespaces, AttributeNode, CommentNode, DirectiveNode, ElementNode, ElementTypes, ExpressionNode, NodeTypes, Position, RootNode, SourceLocation, TextNode, TemplateChildNode, InterpolationNode, createRoot, ConstantTypes } from './ast' import { CompilerCompatOptions } from './compat/compatConfig' type OptionalOptions = | 'isNativeTag' | 'isBuiltInComponent' | keyof CompilerCompatOptions type MergedParserOptions = Omit, OptionalOptions> & Pick type AttributeValue = | { content: string isQuoted: boolean loc: SourceLocation } | undefined // The default decoder only provides escapes for characters reserved as part of // the template syntax, and is only used if the custom renderer did not provide // a platform-specific decoder. const decodeRE = /&(gt|lt|amp|apos|quot);/g const decodeMap: Record = { gt: '>', lt: '<', amp: '&', apos: "'", quot: '"' } export const defaultParserOptions: MergedParserOptions = { delimiters: [`{{`, `}}`], getNamespace: () => Namespaces.HTML, getTextMode: () => TextModes.DATA, isVoidTag: NO, isPreTag: NO, isCustomElement: NO, decodeEntities: (rawText: string): string => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]), onError: defaultOnError, onWarn: defaultOnWarn, comments: false } export const enum TextModes { // | Elements | Entities | End sign | Inside of DATA, // | ✔ | ✔ | End tags of ancestors | RCDATA, // | ✘ | ✔ | End tag of the parent |