compiler-core.d.ts 41 KB

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