compiler-core.d.ts 43 KB

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