compiler-core.d.ts 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. import type { BlockStatement as BlockStatement_2 } from '@babel/types';
  2. import type { Function as Function_2 } from '@babel/types';
  3. import { generateCodeFrame } from '@vue/shared';
  4. import type { Identifier } from '@babel/types';
  5. import type { Node as Node_3 } from '@babel/types';
  6. import type { ObjectProperty } from '@babel/types';
  7. import { ParserPlugin } from '@babel/parser';
  8. import type { Program } from '@babel/types';
  9. import { RawSourceMap } from 'source-map';
  10. import { SourceMapGenerator } from 'source-map';
  11. export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
  12. export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
  13. export declare interface ArrayExpression extends Node_2 {
  14. type: NodeTypes.JS_ARRAY_EXPRESSION;
  15. elements: Array<string | Node_2>;
  16. }
  17. declare function assert_2(condition: boolean, msg?: string): void;
  18. export { assert_2 as assert }
  19. export declare interface AssignmentExpression extends Node_2 {
  20. type: NodeTypes.JS_ASSIGNMENT_EXPRESSION;
  21. left: SimpleExpressionNode;
  22. right: JSChildNode;
  23. }
  24. export declare interface AttributeNode extends Node_2 {
  25. type: NodeTypes.ATTRIBUTE;
  26. name: string;
  27. value: TextNode | undefined;
  28. }
  29. export declare const BASE_TRANSITION: unique symbol;
  30. export declare function baseCompile(template: string | RootNode, options?: CompilerOptions): CodegenResult;
  31. export declare interface BaseElementNode extends Node_2 {
  32. type: NodeTypes.ELEMENT;
  33. ns: Namespace;
  34. tag: string;
  35. tagType: ElementTypes;
  36. isSelfClosing: boolean;
  37. props: Array<AttributeNode | DirectiveNode>;
  38. children: TemplateChildNode[];
  39. }
  40. export declare function baseParse(content: string, options?: ParserOptions): RootNode;
  41. export declare type BindingMetadata = {
  42. [key: string]: BindingTypes | undefined;
  43. } & {
  44. __isScriptSetup?: boolean;
  45. __propsAliases?: Record<string, string>;
  46. };
  47. export declare const enum BindingTypes {
  48. /**
  49. * returned from data()
  50. */
  51. DATA = "data",
  52. /**
  53. * declared as a prop
  54. */
  55. PROPS = "props",
  56. /**
  57. * a local alias of a `<script setup>` destructured prop.
  58. * the original is stored in __propsAliases of the bindingMetadata object.
  59. */
  60. PROPS_ALIASED = "props-aliased",
  61. /**
  62. * a let binding (may or may not be a ref)
  63. */
  64. SETUP_LET = "setup-let",
  65. /**
  66. * a const binding that can never be a ref.
  67. * these bindings don't need `unref()` calls when processed in inlined
  68. * template expressions.
  69. */
  70. SETUP_CONST = "setup-const",
  71. /**
  72. * a const binding that does not need `unref()`, but may be mutated.
  73. */
  74. SETUP_REACTIVE_CONST = "setup-reactive-const",
  75. /**
  76. * a const binding that may be a ref.
  77. */
  78. SETUP_MAYBE_REF = "setup-maybe-ref",
  79. /**
  80. * bindings that are guaranteed to be refs
  81. */
  82. SETUP_REF = "setup-ref",
  83. /**
  84. * declared by other options, e.g. computed, inject
  85. */
  86. OPTIONS = "options"
  87. }
  88. export declare type BlockCodegenNode = VNodeCall | RenderSlotCall;
  89. export declare interface BlockStatement extends Node_2 {
  90. type: NodeTypes.JS_BLOCK_STATEMENT;
  91. body: (JSChildNode | IfStatement)[];
  92. }
  93. export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
  94. export declare function buildProps(node: ElementNode, context: TransformContext, props: (DirectiveNode | AttributeNode)[] | undefined, isComponent: boolean, isDynamicComponent: boolean, ssr?: boolean): {
  95. props: PropsExpression | undefined;
  96. directives: DirectiveNode[];
  97. patchFlag: number;
  98. dynamicPropNames: string[];
  99. shouldUseBlock: boolean;
  100. };
  101. export declare function buildSlots(node: ElementNode, context: TransformContext, buildSlotFn?: SlotFnBuilder): {
  102. slots: SlotsExpression;
  103. hasDynamicSlots: boolean;
  104. };
  105. export declare interface CacheExpression extends Node_2 {
  106. type: NodeTypes.JS_CACHE_EXPRESSION;
  107. index: number;
  108. value: JSChildNode;
  109. isVNode: boolean;
  110. }
  111. export declare interface CallExpression extends Node_2 {
  112. type: NodeTypes.JS_CALL_EXPRESSION;
  113. callee: string | symbol;
  114. arguments: (string | symbol | JSChildNode | SSRCodegenNode | TemplateChildNode | TemplateChildNode[])[];
  115. }
  116. export declare const CAMELIZE: unique symbol;
  117. export declare const CAPITALIZE: unique symbol;
  118. export declare function checkCompatEnabled(key: CompilerDeprecationTypes, context: ParserContext | TransformContext, loc: SourceLocation | null, ...args: any[]): boolean;
  119. export declare interface CodegenContext extends Omit<Required<CodegenOptions>, 'bindingMetadata' | 'inline'> {
  120. source: string;
  121. code: string;
  122. line: number;
  123. column: number;
  124. offset: number;
  125. indentLevel: number;
  126. pure: boolean;
  127. map?: SourceMapGenerator;
  128. helper(key: symbol): string;
  129. push(code: string, node?: CodegenNode): void;
  130. indent(): void;
  131. deindent(withoutNewLine?: boolean): void;
  132. newline(): void;
  133. }
  134. declare type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
  135. export declare interface CodegenOptions extends SharedTransformCodegenOptions {
  136. /**
  137. * - `module` mode will generate ES module import statements for helpers
  138. * and export the render function as the default export.
  139. * - `function` mode will generate a single `const { helpers... } = Vue`
  140. * statement and return the render function. It expects `Vue` to be globally
  141. * available (or passed by wrapping the code with an IIFE). It is meant to be
  142. * used with `new Function(code)()` to generate a render function at runtime.
  143. * @default 'function'
  144. */
  145. mode?: 'module' | 'function';
  146. /**
  147. * Generate source map?
  148. * @default false
  149. */
  150. sourceMap?: boolean;
  151. /**
  152. * SFC scoped styles ID
  153. */
  154. scopeId?: string | null;
  155. /**
  156. * Option to optimize helper import bindings via variable assignment
  157. * (only used for webpack code-split)
  158. * @default false
  159. */
  160. optimizeImports?: boolean;
  161. /**
  162. * Customize where to import runtime helpers from.
  163. * @default 'vue'
  164. */
  165. runtimeModuleName?: string;
  166. /**
  167. * Customize where to import ssr runtime helpers from/**
  168. * @default 'vue/server-renderer'
  169. */
  170. ssrRuntimeModuleName?: string;
  171. /**
  172. * Customize the global variable name of `Vue` to get helpers from
  173. * in function mode
  174. * @default 'Vue'
  175. */
  176. runtimeGlobalName?: string;
  177. }
  178. export declare interface CodegenResult {
  179. code: string;
  180. preamble: string;
  181. ast: RootNode;
  182. map?: RawSourceMap;
  183. }
  184. export declare interface CommentNode extends Node_2 {
  185. type: NodeTypes.COMMENT;
  186. content: string;
  187. }
  188. declare type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>> & {
  189. MODE?: 2 | 3;
  190. };
  191. declare interface CompilerCompatOptions {
  192. compatConfig?: CompilerCompatConfig;
  193. }
  194. export declare const enum CompilerDeprecationTypes {
  195. COMPILER_IS_ON_ELEMENT = "COMPILER_IS_ON_ELEMENT",
  196. COMPILER_V_BIND_SYNC = "COMPILER_V_BIND_SYNC",
  197. COMPILER_V_BIND_PROP = "COMPILER_V_BIND_PROP",
  198. COMPILER_V_BIND_OBJECT_ORDER = "COMPILER_V_BIND_OBJECT_ORDER",
  199. COMPILER_V_ON_NATIVE = "COMPILER_V_ON_NATIVE",
  200. COMPILER_V_IF_V_FOR_PRECEDENCE = "COMPILER_V_IF_V_FOR_PRECEDENCE",
  201. COMPILER_NATIVE_TEMPLATE = "COMPILER_NATIVE_TEMPLATE",
  202. COMPILER_INLINE_TEMPLATE = "COMPILER_INLINE_TEMPLATE",
  203. COMPILER_FILTERS = "COMPILER_FILTER"
  204. }
  205. export declare interface CompilerError extends SyntaxError {
  206. code: number | string;
  207. loc?: SourceLocation;
  208. }
  209. export declare type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
  210. export declare interface ComponentNode extends BaseElementNode {
  211. tagType: ElementTypes.COMPONENT;
  212. codegenNode: VNodeCall | CacheExpression | MemoExpression | undefined;
  213. ssrCodegenNode?: CallExpression;
  214. }
  215. export declare interface CompoundExpressionNode extends Node_2 {
  216. type: NodeTypes.COMPOUND_EXPRESSION;
  217. children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string | symbol)[];
  218. /**
  219. * an expression parsed as the params of a function will track
  220. * the identifiers declared inside the function body.
  221. */
  222. identifiers?: string[];
  223. isHandlerKey?: boolean;
  224. }
  225. export declare interface ConditionalDynamicSlotNode extends ConditionalExpression {
  226. consequent: DynamicSlotNode;
  227. alternate: DynamicSlotNode | SimpleExpressionNode;
  228. }
  229. export declare interface ConditionalExpression extends Node_2 {
  230. type: NodeTypes.JS_CONDITIONAL_EXPRESSION;
  231. test: JSChildNode;
  232. consequent: JSChildNode;
  233. alternate: JSChildNode;
  234. newline: boolean;
  235. }
  236. /**
  237. * Static types have several levels.
  238. * Higher levels implies lower levels. e.g. a node that can be stringified
  239. * can always be hoisted and skipped for patch.
  240. */
  241. export declare const enum ConstantTypes {
  242. NOT_CONSTANT = 0,
  243. CAN_SKIP_PATCH = 1,
  244. CAN_HOIST = 2,
  245. CAN_STRINGIFY = 3
  246. }
  247. export declare interface CoreCompilerError extends CompilerError {
  248. code: ErrorCodes;
  249. }
  250. export declare const CREATE_BLOCK: unique symbol;
  251. export declare const CREATE_COMMENT: unique symbol;
  252. export declare const CREATE_ELEMENT_BLOCK: unique symbol;
  253. export declare const CREATE_ELEMENT_VNODE: unique symbol;
  254. export declare const CREATE_SLOTS: unique symbol;
  255. export declare const CREATE_STATIC: unique symbol;
  256. export declare const CREATE_TEXT: unique symbol;
  257. export declare const CREATE_VNODE: unique symbol;
  258. export declare function createArrayExpression(elements: ArrayExpression['elements'], loc?: SourceLocation): ArrayExpression;
  259. export declare function createAssignmentExpression(left: AssignmentExpression['left'], right: AssignmentExpression['right']): AssignmentExpression;
  260. export declare function createBlockStatement(body: BlockStatement['body']): BlockStatement;
  261. export declare function createCacheExpression(index: number, value: JSChildNode, isVNode?: boolean): CacheExpression;
  262. export declare function createCallExpression<T extends CallExpression['callee']>(callee: T, args?: CallExpression['arguments'], loc?: SourceLocation): InferCodegenNodeType<T>;
  263. export declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
  264. [code: number]: string;
  265. }, additionalMessage?: string): InferCompilerError<T>;
  266. export declare function createCompoundExpression(children: CompoundExpressionNode['children'], loc?: SourceLocation): CompoundExpressionNode;
  267. export declare function createConditionalExpression(test: ConditionalExpression['test'], consequent: ConditionalExpression['consequent'], alternate: ConditionalExpression['alternate'], newline?: boolean): ConditionalExpression;
  268. export declare function createForLoopParams({ value, key, index }: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
  269. export declare function createFunctionExpression(params: FunctionExpression['params'], returns?: FunctionExpression['returns'], newline?: boolean, isSlot?: boolean, loc?: SourceLocation): FunctionExpression;
  270. export declare function createIfStatement(test: IfStatement['test'], consequent: IfStatement['consequent'], alternate?: IfStatement['alternate']): IfStatement;
  271. export declare function createInterpolation(content: InterpolationNode['content'] | string, loc: SourceLocation): InterpolationNode;
  272. export declare function createObjectExpression(properties: ObjectExpression['properties'], loc?: SourceLocation): ObjectExpression;
  273. export declare function createObjectProperty(key: Property['key'] | string, value: Property['value']): Property;
  274. export declare function createReturnStatement(returns: ReturnStatement['returns']): ReturnStatement;
  275. export declare function createRoot(children: TemplateChildNode[], loc?: SourceLocation): RootNode;
  276. export declare function createSequenceExpression(expressions: SequenceExpression['expressions']): SequenceExpression;
  277. export declare function createSimpleExpression(content: SimpleExpressionNode['content'], isStatic?: SimpleExpressionNode['isStatic'], loc?: SourceLocation, constType?: ConstantTypes): SimpleExpressionNode;
  278. export declare function createStructuralDirectiveTransform(name: string | RegExp, fn: StructuralDirectiveTransform): NodeTransform;
  279. export declare function createTemplateLiteral(elements: TemplateLiteral['elements']): TemplateLiteral;
  280. export declare function createTransformContext(root: RootNode, { filename, prefixIdentifiers, hoistStatic, cacheHandlers, nodeTransforms, directiveTransforms, transformHoist, isBuiltInComponent, isCustomElement, expressionPlugins, scopeId, slotted, ssr, inSSR, ssrCssVars, bindingMetadata, inline, isTS, onError, onWarn, compatConfig }: TransformOptions): TransformContext;
  281. export declare function createVNodeCall(context: TransformContext | null, tag: VNodeCall['tag'], props?: VNodeCall['props'], children?: VNodeCall['children'], patchFlag?: VNodeCall['patchFlag'], dynamicProps?: VNodeCall['dynamicProps'], directives?: VNodeCall['directives'], isBlock?: VNodeCall['isBlock'], disableTracking?: VNodeCall['disableTracking'], isComponent?: VNodeCall['isComponent'], loc?: SourceLocation): VNodeCall;
  282. export declare interface DirectiveArgumentNode extends ArrayExpression {
  283. elements: [string] | [string, ExpressionNode] | [string, ExpressionNode, ExpressionNode] | [string, ExpressionNode, ExpressionNode, ObjectExpression];
  284. }
  285. export declare interface DirectiveArguments extends ArrayExpression {
  286. elements: DirectiveArgumentNode[];
  287. }
  288. export declare interface DirectiveNode extends Node_2 {
  289. type: NodeTypes.DIRECTIVE;
  290. name: string;
  291. exp: ExpressionNode | undefined;
  292. arg: ExpressionNode | undefined;
  293. modifiers: string[];
  294. /**
  295. * optional property to cache the expression parse result for v-for
  296. */
  297. parseResult?: ForParseResult;
  298. }
  299. export declare type DirectiveTransform = (dir: DirectiveNode, node: ElementNode, context: TransformContext, augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult) => DirectiveTransformResult;
  300. declare interface DirectiveTransformResult {
  301. props: Property[];
  302. needRuntime?: boolean | symbol;
  303. ssrTagParts?: TemplateLiteral['elements'];
  304. }
  305. export declare interface DynamicSlotEntries extends ArrayExpression {
  306. elements: (ConditionalDynamicSlotNode | ListDynamicSlotNode)[];
  307. }
  308. export declare interface DynamicSlotFnProperty extends Property {
  309. value: SlotFunctionExpression;
  310. }
  311. export declare interface DynamicSlotNode extends ObjectExpression {
  312. properties: [Property, DynamicSlotFnProperty];
  313. }
  314. export declare interface DynamicSlotsExpression extends CallExpression {
  315. callee: typeof CREATE_SLOTS;
  316. arguments: [SlotsObjectExpression, DynamicSlotEntries];
  317. }
  318. export declare type ElementNode = PlainElementNode | ComponentNode | SlotOutletNode | TemplateNode;
  319. export declare const enum ElementTypes {
  320. ELEMENT = 0,
  321. COMPONENT = 1,
  322. SLOT = 2,
  323. TEMPLATE = 3
  324. }
  325. export declare const enum ErrorCodes {
  326. ABRUPT_CLOSING_OF_EMPTY_COMMENT = 0,
  327. CDATA_IN_HTML_CONTENT = 1,
  328. DUPLICATE_ATTRIBUTE = 2,
  329. END_TAG_WITH_ATTRIBUTES = 3,
  330. END_TAG_WITH_TRAILING_SOLIDUS = 4,
  331. EOF_BEFORE_TAG_NAME = 5,
  332. EOF_IN_CDATA = 6,
  333. EOF_IN_COMMENT = 7,
  334. EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT = 8,
  335. EOF_IN_TAG = 9,
  336. INCORRECTLY_CLOSED_COMMENT = 10,
  337. INCORRECTLY_OPENED_COMMENT = 11,
  338. INVALID_FIRST_CHARACTER_OF_TAG_NAME = 12,
  339. MISSING_ATTRIBUTE_VALUE = 13,
  340. MISSING_END_TAG_NAME = 14,
  341. MISSING_WHITESPACE_BETWEEN_ATTRIBUTES = 15,
  342. NESTED_COMMENT = 16,
  343. UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME = 17,
  344. UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE = 18,
  345. UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME = 19,
  346. UNEXPECTED_NULL_CHARACTER = 20,
  347. UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME = 21,
  348. UNEXPECTED_SOLIDUS_IN_TAG = 22,
  349. X_INVALID_END_TAG = 23,
  350. X_MISSING_END_TAG = 24,
  351. X_MISSING_INTERPOLATION_END = 25,
  352. X_MISSING_DIRECTIVE_NAME = 26,
  353. X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END = 27,
  354. X_V_IF_NO_EXPRESSION = 28,
  355. X_V_IF_SAME_KEY = 29,
  356. X_V_ELSE_NO_ADJACENT_IF = 30,
  357. X_V_FOR_NO_EXPRESSION = 31,
  358. X_V_FOR_MALFORMED_EXPRESSION = 32,
  359. X_V_FOR_TEMPLATE_KEY_PLACEMENT = 33,
  360. X_V_BIND_NO_EXPRESSION = 34,
  361. X_V_ON_NO_EXPRESSION = 35,
  362. X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET = 36,
  363. X_V_SLOT_MIXED_SLOT_USAGE = 37,
  364. X_V_SLOT_DUPLICATE_SLOT_NAMES = 38,
  365. X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN = 39,
  366. X_V_SLOT_MISPLACED = 40,
  367. X_V_MODEL_NO_EXPRESSION = 41,
  368. X_V_MODEL_MALFORMED_EXPRESSION = 42,
  369. X_V_MODEL_ON_SCOPE_VARIABLE = 43,
  370. X_V_MODEL_ON_PROPS = 44,
  371. X_INVALID_EXPRESSION = 45,
  372. X_KEEP_ALIVE_INVALID_CHILDREN = 46,
  373. X_PREFIX_ID_NOT_SUPPORTED = 47,
  374. X_MODULE_MODE_NOT_SUPPORTED = 48,
  375. X_CACHE_HANDLER_NOT_SUPPORTED = 49,
  376. X_SCOPE_ID_NOT_SUPPORTED = 50,
  377. __EXTEND_POINT__ = 51
  378. }
  379. declare interface ErrorHandlingOptions {
  380. onWarn?: (warning: CompilerError) => void;
  381. onError?: (error: CompilerError) => void;
  382. }
  383. export declare type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode;
  384. export declare function extractIdentifiers(param: Node_3, nodes?: Identifier[]): Identifier[];
  385. export declare function findDir(node: ElementNode, name: string | RegExp, allowEmpty?: boolean): DirectiveNode | undefined;
  386. export declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode['props'][0] | undefined;
  387. export declare interface ForCodegenNode extends VNodeCall {
  388. isBlock: true;
  389. tag: typeof FRAGMENT;
  390. props: undefined;
  391. children: ForRenderListExpression;
  392. patchFlag: string;
  393. disableTracking: boolean;
  394. }
  395. export declare interface ForIteratorExpression extends FunctionExpression {
  396. returns: BlockCodegenNode;
  397. }
  398. export declare interface ForNode extends Node_2 {
  399. type: NodeTypes.FOR;
  400. source: ExpressionNode;
  401. valueAlias: ExpressionNode | undefined;
  402. keyAlias: ExpressionNode | undefined;
  403. objectIndexAlias: ExpressionNode | undefined;
  404. parseResult: ForParseResult;
  405. children: TemplateChildNode[];
  406. codegenNode?: ForCodegenNode;
  407. }
  408. declare interface ForParseResult {
  409. source: ExpressionNode;
  410. value: ExpressionNode | undefined;
  411. key: ExpressionNode | undefined;
  412. index: ExpressionNode | undefined;
  413. }
  414. export declare interface ForRenderListExpression extends CallExpression {
  415. callee: typeof RENDER_LIST;
  416. arguments: [ExpressionNode, ForIteratorExpression];
  417. }
  418. export declare const FRAGMENT: unique symbol;
  419. export declare interface FunctionExpression extends Node_2 {
  420. type: NodeTypes.JS_FUNCTION_EXPRESSION;
  421. params: ExpressionNode | string | (ExpressionNode | string)[] | undefined;
  422. returns?: TemplateChildNode | TemplateChildNode[] | JSChildNode;
  423. body?: BlockStatement | IfStatement;
  424. newline: boolean;
  425. /**
  426. * This flag is for codegen to determine whether it needs to generate the
  427. * withScopeId() wrapper
  428. */
  429. isSlot: boolean;
  430. /**
  431. * __COMPAT__ only, indicates a slot function that should be excluded from
  432. * the legacy $scopedSlots instance property.
  433. */
  434. isNonScopedSlot?: boolean;
  435. }
  436. export declare function generate(ast: RootNode, options?: CodegenOptions & {
  437. onContextCreated?: (context: CodegenContext) => void;
  438. }): CodegenResult;
  439. export { generateCodeFrame }
  440. export declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
  441. export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode, context: TransformContext): ConstantTypes;
  442. export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
  443. export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
  444. export declare function getVNodeBlockHelper(ssr: boolean, isComponent: boolean): typeof CREATE_BLOCK | typeof CREATE_ELEMENT_BLOCK;
  445. export declare function getVNodeHelper(ssr: boolean, isComponent: boolean): typeof CREATE_VNODE | typeof CREATE_ELEMENT_VNODE;
  446. export declare const GUARD_REACTIVE_PROPS: unique symbol;
  447. export declare function hasDynamicKeyVBind(node: ElementNode): boolean;
  448. export declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined, ids: TransformContext['identifiers']): boolean;
  449. export declare const helperNameMap: Record<symbol, string>;
  450. export declare type HoistTransform = (children: TemplateChildNode[], context: TransformContext, parent: ParentNode_2) => void;
  451. export declare interface IfBranchNode extends Node_2 {
  452. type: NodeTypes.IF_BRANCH;
  453. condition: ExpressionNode | undefined;
  454. children: TemplateChildNode[];
  455. userKey?: AttributeNode | DirectiveNode;
  456. isTemplateIf?: boolean;
  457. }
  458. export declare interface IfConditionalExpression extends ConditionalExpression {
  459. consequent: BlockCodegenNode | MemoExpression;
  460. alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression;
  461. }
  462. export declare interface IfNode extends Node_2 {
  463. type: NodeTypes.IF;
  464. branches: IfBranchNode[];
  465. codegenNode?: IfConditionalExpression | CacheExpression;
  466. }
  467. export declare interface IfStatement extends Node_2 {
  468. type: NodeTypes.JS_IF_STATEMENT;
  469. test: ExpressionNode;
  470. consequent: BlockStatement;
  471. alternate: IfStatement | BlockStatement | ReturnStatement | undefined;
  472. }
  473. declare interface ImportItem {
  474. exp: string | ExpressionNode;
  475. path: string;
  476. }
  477. declare type InferCodegenNodeType<T> = T extends typeof RENDER_SLOT ? RenderSlotCall : CallExpression;
  478. declare type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : CompilerError;
  479. export declare function injectProp(node: VNodeCall | RenderSlotCall, prop: Property, context: TransformContext): void;
  480. export declare interface InterpolationNode extends Node_2 {
  481. type: NodeTypes.INTERPOLATION;
  482. content: ExpressionNode;
  483. }
  484. export declare const IS_MEMO_SAME: unique symbol;
  485. export declare const IS_REF: unique symbol;
  486. export declare const isBuiltInType: (tag: string, expected: string) => boolean;
  487. export declare function isCoreComponent(tag: string): symbol | void;
  488. export declare const isFunctionType: (node: Node_3) => node is Function_2;
  489. export declare function isInDestructureAssignment(parent: Node_3, parentStack: Node_3[]): boolean;
  490. export declare const isMemberExpression: (path: string, context: TransformContext) => boolean;
  491. /**
  492. * Simple lexer to check if an expression is a member expression. This is
  493. * lax and only checks validity at the root level (i.e. does not validate exps
  494. * inside square brackets), but it's ok since these are only used on template
  495. * expressions and false positives are invalid expressions in the first place.
  496. */
  497. export declare const isMemberExpressionBrowser: (path: string) => boolean;
  498. export declare const isMemberExpressionNode: (path: string, context: TransformContext) => boolean;
  499. export declare function isReferencedIdentifier(id: Identifier, parent: Node_3 | null, parentStack: Node_3[]): boolean;
  500. export declare const isSimpleIdentifier: (name: string) => boolean;
  501. export declare function isSlotOutlet(node: RootNode | TemplateChildNode): node is SlotOutletNode;
  502. export declare function isStaticArgOf(arg: DirectiveNode['arg'], name: string): boolean;
  503. export declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
  504. export declare const isStaticProperty: (node: Node_3) => node is ObjectProperty;
  505. export declare const isStaticPropertyKey: (node: Node_3, parent: Node_3) => boolean;
  506. export declare function isTemplateNode(node: RootNode | TemplateChildNode): node is TemplateNode;
  507. export declare function isText(node: TemplateChildNode): node is TextNode | InterpolationNode;
  508. export declare function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode;
  509. export declare type JSChildNode = VNodeCall | CallExpression | ObjectExpression | ArrayExpression | ExpressionNode | FunctionExpression | ConditionalExpression | CacheExpression | AssignmentExpression | SequenceExpression;
  510. export declare const KEEP_ALIVE: unique symbol;
  511. export declare interface ListDynamicSlotIterator extends FunctionExpression {
  512. returns: DynamicSlotNode;
  513. }
  514. export declare interface ListDynamicSlotNode extends CallExpression {
  515. callee: typeof RENDER_LIST;
  516. arguments: [ExpressionNode, ListDynamicSlotIterator];
  517. }
  518. export declare const locStub: SourceLocation;
  519. export declare function makeBlock(node: VNodeCall, { helper, removeHelper, inSSR }: TransformContext): void;
  520. export declare interface MemoExpression extends CallExpression {
  521. callee: typeof WITH_MEMO;
  522. arguments: [ExpressionNode, MemoFactory, string, string];
  523. }
  524. declare interface MemoFactory extends FunctionExpression {
  525. returns: BlockCodegenNode;
  526. }
  527. export declare const MERGE_PROPS: unique symbol;
  528. declare type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> & Pick<ParserOptions, OptionalOptions>;
  529. export declare type Namespace = number;
  530. export declare const enum Namespaces {
  531. HTML = 0
  532. }
  533. declare interface Node_2 {
  534. type: NodeTypes;
  535. loc: SourceLocation;
  536. }
  537. export { Node_2 as Node }
  538. export declare type NodeTransform = (node: RootNode | TemplateChildNode, context: TransformContext) => void | (() => void) | (() => void)[];
  539. export declare const enum NodeTypes {
  540. ROOT = 0,
  541. ELEMENT = 1,
  542. TEXT = 2,
  543. COMMENT = 3,
  544. SIMPLE_EXPRESSION = 4,
  545. INTERPOLATION = 5,
  546. ATTRIBUTE = 6,
  547. DIRECTIVE = 7,
  548. COMPOUND_EXPRESSION = 8,
  549. IF = 9,
  550. IF_BRANCH = 10,
  551. FOR = 11,
  552. TEXT_CALL = 12,
  553. VNODE_CALL = 13,
  554. JS_CALL_EXPRESSION = 14,
  555. JS_OBJECT_EXPRESSION = 15,
  556. JS_PROPERTY = 16,
  557. JS_ARRAY_EXPRESSION = 17,
  558. JS_FUNCTION_EXPRESSION = 18,
  559. JS_CONDITIONAL_EXPRESSION = 19,
  560. JS_CACHE_EXPRESSION = 20,
  561. JS_BLOCK_STATEMENT = 21,
  562. JS_TEMPLATE_LITERAL = 22,
  563. JS_IF_STATEMENT = 23,
  564. JS_ASSIGNMENT_EXPRESSION = 24,
  565. JS_SEQUENCE_EXPRESSION = 25,
  566. JS_RETURN_STATEMENT = 26
  567. }
  568. export declare const noopDirectiveTransform: DirectiveTransform;
  569. export declare const NORMALIZE_CLASS: unique symbol;
  570. export declare const NORMALIZE_PROPS: unique symbol;
  571. export declare const NORMALIZE_STYLE: unique symbol;
  572. export declare interface ObjectExpression extends Node_2 {
  573. type: NodeTypes.JS_OBJECT_EXPRESSION;
  574. properties: Array<Property>;
  575. }
  576. export declare const OPEN_BLOCK: unique symbol;
  577. declare type OptionalOptions = 'whitespace' | 'isNativeTag' | 'isBuiltInComponent' | keyof CompilerCompatOptions;
  578. declare type ParentNode_2 = RootNode | ElementNode | IfBranchNode | ForNode;
  579. export { ParentNode_2 as ParentNode }
  580. declare interface ParserContext {
  581. options: MergedParserOptions;
  582. readonly originalSource: string;
  583. source: string;
  584. offset: number;
  585. line: number;
  586. column: number;
  587. inPre: boolean;
  588. inVPre: boolean;
  589. onWarn: NonNullable<ErrorHandlingOptions['onWarn']>;
  590. }
  591. export declare interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptions {
  592. /**
  593. * e.g. platform native elements, e.g. `<div>` for browsers
  594. */
  595. isNativeTag?: (tag: string) => boolean;
  596. /**
  597. * e.g. native elements that can self-close, e.g. `<img>`, `<br>`, `<hr>`
  598. */
  599. isVoidTag?: (tag: string) => boolean;
  600. /**
  601. * e.g. elements that should preserve whitespace inside, e.g. `<pre>`
  602. */
  603. isPreTag?: (tag: string) => boolean;
  604. /**
  605. * Platform-specific built-in components e.g. `<Transition>`
  606. */
  607. isBuiltInComponent?: (tag: string) => symbol | void;
  608. /**
  609. * Separate option for end users to extend the native elements list
  610. */
  611. isCustomElement?: (tag: string) => boolean | void;
  612. /**
  613. * Get tag namespace
  614. */
  615. getNamespace?: (tag: string, parent: ElementNode | undefined) => Namespace;
  616. /**
  617. * Get text parsing mode for this element
  618. */
  619. getTextMode?: (node: ElementNode, parent: ElementNode | undefined) => TextModes;
  620. /**
  621. * @default ['{{', '}}']
  622. */
  623. delimiters?: [string, string];
  624. /**
  625. * Whitespace handling strategy
  626. */
  627. whitespace?: 'preserve' | 'condense';
  628. /**
  629. * Only needed for DOM compilers
  630. */
  631. decodeEntities?: (rawText: string, asAttr: boolean) => string;
  632. /**
  633. * Whether to keep comments in the templates AST.
  634. * This defaults to `true` in development and `false` in production builds.
  635. */
  636. comments?: boolean;
  637. }
  638. export declare interface PlainElementNode extends BaseElementNode {
  639. tagType: ElementTypes.ELEMENT;
  640. codegenNode: VNodeCall | SimpleExpressionNode | CacheExpression | MemoExpression | undefined;
  641. ssrCodegenNode?: TemplateLiteral;
  642. }
  643. export declare const POP_SCOPE_ID: unique symbol;
  644. export declare interface Position {
  645. offset: number;
  646. line: number;
  647. column: number;
  648. }
  649. export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean, localVars?: Record<string, number>): ExpressionNode;
  650. export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
  651. export declare function processIf(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (node: IfNode, branch: IfBranchNode, isRoot: boolean) => (() => void) | undefined): (() => void) | undefined;
  652. export declare function processSlotOutlet(node: SlotOutletNode, context: TransformContext): SlotOutletProcessResult;
  653. export declare interface Property extends Node_2 {
  654. type: NodeTypes.JS_PROPERTY;
  655. key: ExpressionNode;
  656. value: JSChildNode;
  657. }
  658. export declare type PropsExpression = ObjectExpression | CallExpression | ExpressionNode;
  659. export declare const PUSH_SCOPE_ID: unique symbol;
  660. export declare function registerRuntimeHelpers(helpers: Record<symbol, string>): void;
  661. export declare const RENDER_LIST: unique symbol;
  662. export declare const RENDER_SLOT: unique symbol;
  663. export declare interface RenderSlotCall extends CallExpression {
  664. callee: typeof RENDER_SLOT;
  665. arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [
  666. string,
  667. string | ExpressionNode,
  668. PropsExpression | '{}',
  669. TemplateChildNode[]
  670. ];
  671. }
  672. export declare const RESOLVE_COMPONENT: unique symbol;
  673. export declare const RESOLVE_DIRECTIVE: unique symbol;
  674. export declare const RESOLVE_DYNAMIC_COMPONENT: unique symbol;
  675. export declare const RESOLVE_FILTER: unique symbol;
  676. export declare function resolveComponentType(node: ComponentNode, context: TransformContext, ssr?: boolean): string | symbol | CallExpression;
  677. export declare interface ReturnStatement extends Node_2 {
  678. type: NodeTypes.JS_RETURN_STATEMENT;
  679. returns: TemplateChildNode | TemplateChildNode[] | JSChildNode;
  680. }
  681. export declare interface RootNode extends Node_2 {
  682. type: NodeTypes.ROOT;
  683. children: TemplateChildNode[];
  684. helpers: Set<symbol>;
  685. components: string[];
  686. directives: string[];
  687. hoists: (JSChildNode | null)[];
  688. imports: ImportItem[];
  689. cached: number;
  690. temps: number;
  691. ssrHelpers?: symbol[];
  692. codegenNode?: TemplateChildNode | JSChildNode | BlockStatement;
  693. filters?: string[];
  694. }
  695. export declare interface SequenceExpression extends Node_2 {
  696. type: NodeTypes.JS_SEQUENCE_EXPRESSION;
  697. expressions: JSChildNode[];
  698. }
  699. export declare const SET_BLOCK_TRACKING: unique symbol;
  700. declare interface SharedTransformCodegenOptions {
  701. /**
  702. * Transform expressions like {{ foo }} to `_ctx.foo`.
  703. * If this option is false, the generated code will be wrapped in a
  704. * `with (this) { ... }` block.
  705. * - This is force-enabled in module mode, since modules are by default strict
  706. * and cannot use `with`
  707. * @default mode === 'module'
  708. */
  709. prefixIdentifiers?: boolean;
  710. /**
  711. * Control whether generate SSR-optimized render functions instead.
  712. * The resulting function must be attached to the component via the
  713. * `ssrRender` option instead of `render`.
  714. *
  715. * When compiler generates code for SSR's fallback branch, we need to set it to false:
  716. * - context.ssr = false
  717. *
  718. * see `subTransform` in `ssrTransformComponent.ts`
  719. */
  720. ssr?: boolean;
  721. /**
  722. * Indicates whether the compiler generates code for SSR,
  723. * it is always true when generating code for SSR,
  724. * regardless of whether we are generating code for SSR's fallback branch,
  725. * this means that when the compiler generates code for SSR's fallback branch:
  726. * - context.ssr = false
  727. * - context.inSSR = true
  728. */
  729. inSSR?: boolean;
  730. /**
  731. * Optional binding metadata analyzed from script - used to optimize
  732. * binding access when `prefixIdentifiers` is enabled.
  733. */
  734. bindingMetadata?: BindingMetadata;
  735. /**
  736. * Compile the function for inlining inside setup().
  737. * This allows the function to directly access setup() local bindings.
  738. */
  739. inline?: boolean;
  740. /**
  741. * Indicates that transforms and codegen should try to output valid TS code
  742. */
  743. isTS?: boolean;
  744. /**
  745. * Filename for source map generation.
  746. * Also used for self-recursive reference in templates
  747. * @default 'template.vue.html'
  748. */
  749. filename?: string;
  750. }
  751. export declare interface SimpleExpressionNode extends Node_2 {
  752. type: NodeTypes.SIMPLE_EXPRESSION;
  753. content: string;
  754. isStatic: boolean;
  755. constType: ConstantTypes;
  756. /**
  757. * Indicates this is an identifier for a hoist vnode call and points to the
  758. * hoisted node.
  759. */
  760. hoisted?: JSChildNode;
  761. /**
  762. * an expression parsed as the params of a function will track
  763. * the identifiers declared inside the function body.
  764. */
  765. identifiers?: string[];
  766. isHandlerKey?: boolean;
  767. }
  768. export declare type SlotFnBuilder = (slotProps: ExpressionNode | undefined, slotChildren: TemplateChildNode[], loc: SourceLocation) => FunctionExpression;
  769. export declare interface SlotFunctionExpression extends FunctionExpression {
  770. returns: TemplateChildNode[];
  771. }
  772. export declare interface SlotOutletNode extends BaseElementNode {
  773. tagType: ElementTypes.SLOT;
  774. codegenNode: RenderSlotCall | CacheExpression | undefined;
  775. ssrCodegenNode?: CallExpression;
  776. }
  777. declare interface SlotOutletProcessResult {
  778. slotName: string | ExpressionNode;
  779. slotProps: PropsExpression | undefined;
  780. }
  781. export declare type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
  782. export declare interface SlotsObjectExpression extends ObjectExpression {
  783. properties: SlotsObjectProperty[];
  784. }
  785. export declare interface SlotsObjectProperty extends Property {
  786. value: SlotFunctionExpression;
  787. }
  788. export declare interface SourceLocation {
  789. start: Position;
  790. end: Position;
  791. source: string;
  792. }
  793. export declare type SSRCodegenNode = BlockStatement | TemplateLiteral | IfStatement | AssignmentExpression | ReturnStatement | SequenceExpression;
  794. export declare function stringifyExpression(exp: ExpressionNode | string): string;
  795. export declare type StructuralDirectiveTransform = (node: ElementNode, dir: DirectiveNode, context: TransformContext) => void | (() => void);
  796. export declare const SUSPENSE: unique symbol;
  797. export declare const TELEPORT: unique symbol;
  798. export declare type TemplateChildNode = ElementNode | InterpolationNode | CompoundExpressionNode | TextNode | CommentNode | IfNode | IfBranchNode | ForNode | TextCallNode;
  799. export declare interface TemplateLiteral extends Node_2 {
  800. type: NodeTypes.JS_TEMPLATE_LITERAL;
  801. elements: (string | JSChildNode)[];
  802. }
  803. export declare interface TemplateNode extends BaseElementNode {
  804. tagType: ElementTypes.TEMPLATE;
  805. codegenNode: undefined;
  806. }
  807. export declare type TemplateTextChildNode = TextNode | InterpolationNode | CompoundExpressionNode;
  808. export declare interface TextCallNode extends Node_2 {
  809. type: NodeTypes.TEXT_CALL;
  810. content: TextNode | InterpolationNode | CompoundExpressionNode;
  811. codegenNode: CallExpression | SimpleExpressionNode;
  812. }
  813. export declare const enum TextModes {
  814. DATA = 0,
  815. RCDATA = 1,
  816. RAWTEXT = 2,
  817. CDATA = 3,
  818. ATTRIBUTE_VALUE = 4
  819. }
  820. export declare interface TextNode extends Node_2 {
  821. type: NodeTypes.TEXT;
  822. content: string;
  823. }
  824. export declare const TO_DISPLAY_STRING: unique symbol;
  825. export declare const TO_HANDLER_KEY: unique symbol;
  826. export declare const TO_HANDLERS: unique symbol;
  827. export declare function toValidAssetId(name: string, type: 'component' | 'directive' | 'filter'): string;
  828. export declare const trackSlotScopes: NodeTransform;
  829. export declare const trackVForSlotScopes: NodeTransform;
  830. export declare function transform(root: RootNode, options: TransformOptions): void;
  831. export declare const transformBind: DirectiveTransform;
  832. export declare interface TransformContext extends Required<Omit<TransformOptions, 'filename' | keyof CompilerCompatOptions>>, CompilerCompatOptions {
  833. selfName: string | null;
  834. root: RootNode;
  835. helpers: Map<symbol, number>;
  836. components: Set<string>;
  837. directives: Set<string>;
  838. hoists: (JSChildNode | null)[];
  839. imports: ImportItem[];
  840. temps: number;
  841. cached: number;
  842. identifiers: {
  843. [name: string]: number | undefined;
  844. };
  845. scopes: {
  846. vFor: number;
  847. vSlot: number;
  848. vPre: number;
  849. vOnce: number;
  850. };
  851. parent: ParentNode_2 | null;
  852. childIndex: number;
  853. currentNode: RootNode | TemplateChildNode | null;
  854. inVOnce: boolean;
  855. helper<T extends symbol>(name: T): T;
  856. removeHelper<T extends symbol>(name: T): void;
  857. helperString(name: symbol): string;
  858. replaceNode(node: TemplateChildNode): void;
  859. removeNode(node?: TemplateChildNode): void;
  860. onNodeRemoved(): void;
  861. addIdentifiers(exp: ExpressionNode | string): void;
  862. removeIdentifiers(exp: ExpressionNode | string): void;
  863. hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
  864. cache<T extends JSChildNode>(exp: T, isVNode?: boolean): CacheExpression | T;
  865. constantCache: Map<TemplateChildNode, ConstantTypes>;
  866. filters?: Set<string>;
  867. }
  868. export declare const transformElement: NodeTransform;
  869. export declare const transformExpression: NodeTransform;
  870. export declare const transformModel: DirectiveTransform;
  871. export declare const transformOn: DirectiveTransform;
  872. export declare interface TransformOptions extends SharedTransformCodegenOptions, ErrorHandlingOptions, CompilerCompatOptions {
  873. /**
  874. * An array of node transforms to be applied to every AST node.
  875. */
  876. nodeTransforms?: NodeTransform[];
  877. /**
  878. * An object of { name: transform } to be applied to every directive attribute
  879. * node found on element nodes.
  880. */
  881. directiveTransforms?: Record<string, DirectiveTransform | undefined>;
  882. /**
  883. * An optional hook to transform a node being hoisted.
  884. * used by compiler-dom to turn hoisted nodes into stringified HTML vnodes.
  885. * @default null
  886. */
  887. transformHoist?: HoistTransform | null;
  888. /**
  889. * If the pairing runtime provides additional built-in elements, use this to
  890. * mark them as built-in so the compiler will generate component vnodes
  891. * for them.
  892. */
  893. isBuiltInComponent?: (tag: string) => symbol | void;
  894. /**
  895. * Used by some transforms that expects only native elements
  896. */
  897. isCustomElement?: (tag: string) => boolean | void;
  898. /**
  899. * Transform expressions like {{ foo }} to `_ctx.foo`.
  900. * If this option is false, the generated code will be wrapped in a
  901. * `with (this) { ... }` block.
  902. * - This is force-enabled in module mode, since modules are by default strict
  903. * and cannot use `with`
  904. * @default mode === 'module'
  905. */
  906. prefixIdentifiers?: boolean;
  907. /**
  908. * Hoist static VNodes and props objects to `_hoisted_x` constants
  909. * @default false
  910. */
  911. hoistStatic?: boolean;
  912. /**
  913. * Cache v-on handlers to avoid creating new inline functions on each render,
  914. * also avoids the need for dynamically patching the handlers by wrapping it.
  915. * e.g `@click="foo"` by default is compiled to `{ onClick: foo }`. With this
  916. * option it's compiled to:
  917. * ```js
  918. * { onClick: _cache[0] || (_cache[0] = e => _ctx.foo(e)) }
  919. * ```
  920. * - Requires "prefixIdentifiers" to be enabled because it relies on scope
  921. * analysis to determine if a handler is safe to cache.
  922. * @default false
  923. */
  924. cacheHandlers?: boolean;
  925. /**
  926. * A list of parser plugins to enable for `@babel/parser`, which is used to
  927. * parse expressions in bindings and interpolations.
  928. * https://babeljs.io/docs/en/next/babel-parser#plugins
  929. */
  930. expressionPlugins?: ParserPlugin[];
  931. /**
  932. * SFC scoped styles ID
  933. */
  934. scopeId?: string | null;
  935. /**
  936. * Indicates this SFC template has used :slotted in its styles
  937. * Defaults to `true` for backwards compatibility - SFC tooling should set it
  938. * to `false` if no `:slotted` usage is detected in `<style>`
  939. */
  940. slotted?: boolean;
  941. /**
  942. * SFC `<style vars>` injection string
  943. * Should already be an object expression, e.g. `{ 'xxxx-color': color }`
  944. * needed to render inline CSS variables on component root
  945. */
  946. ssrCssVars?: string;
  947. }
  948. export declare type TransformPreset = [
  949. NodeTransform[],
  950. Record<string, DirectiveTransform>
  951. ];
  952. export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
  953. export declare const UNREF: unique symbol;
  954. export declare interface VNodeCall extends Node_2 {
  955. type: NodeTypes.VNODE_CALL;
  956. tag: string | symbol | CallExpression;
  957. props: PropsExpression | undefined;
  958. children: TemplateChildNode[] | TemplateTextChildNode | SlotsExpression | ForRenderListExpression | SimpleExpressionNode | undefined;
  959. patchFlag: string | undefined;
  960. dynamicProps: string | SimpleExpressionNode | undefined;
  961. directives: DirectiveArguments | undefined;
  962. isBlock: boolean;
  963. disableTracking: boolean;
  964. isComponent: boolean;
  965. }
  966. export declare function walkBlockDeclarations(block: BlockStatement_2 | Program, onIdent: (node: Identifier) => void): void;
  967. export declare function walkFunctionParams(node: Function_2, onIdent: (id: Identifier) => void): void;
  968. export declare function walkIdentifiers(root: Node_3, onIdentifier: (node: Identifier, parent: Node_3, parentStack: Node_3[], isReference: boolean, isLocal: boolean) => void, includeAll?: boolean, parentStack?: Node_3[], knownIds?: Record<string, number>): void;
  969. export declare function warnDeprecation(key: CompilerDeprecationTypes, context: ParserContext | TransformContext, loc: SourceLocation | null, ...args: any[]): void;
  970. export declare const WITH_CTX: unique symbol;
  971. export declare const WITH_DIRECTIVES: unique symbol;
  972. export declare const WITH_MEMO: unique symbol;
  973. export { }