compiler-core.d.ts 45 KB

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