compiler.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. declare type CompilerOptions = {
  2. warn?: Function,
  3. isIE?: boolean,
  4. expectHTML?: boolean,
  5. preserveWhitespace?: boolean,
  6. modules?: Array<ModuleOptions>,
  7. staticKeys?: string,
  8. directives?: { [key: string]: Function },
  9. isUnaryTag?: (tag: string) => ?boolean,
  10. isReservedTag?: (tag: string) => ?boolean,
  11. mustUseProp?: (attr: string) => ?boolean,
  12. getTagNamespace?: (tag: string) => ?string,
  13. delimiters?: [string, string]
  14. }
  15. declare type ModuleOptions = {
  16. staticKeys?: Array<string>,
  17. parse: (el: ASTElement) => void,
  18. genData: (el: ASTElement) => string,
  19. transformElement?: (el: ASTElement, code: string) => string
  20. }
  21. declare type ASTElementHandler = {
  22. value: string,
  23. modifiers: ?{ [key: string]: true }
  24. }
  25. declare type ASTElementHandlers = {
  26. [key: string]: ASTElementHandler | Array<ASTElementHandler>
  27. }
  28. declare type ASTElementHooks = { [key: string]: Array<string> }
  29. declare type ASTDirective = {
  30. name: string,
  31. value: ?string,
  32. arg: ?string,
  33. modifiers: ?{ [key: string]: true }
  34. }
  35. declare type ASTNode = ASTElement | ASTText | ASTExpression
  36. declare type ASTElement = {
  37. type: 1,
  38. tag: string,
  39. attrsList: Array<{ name: string, value: string }>,
  40. attrsMap: { [key: string]: string | null },
  41. parent: ASTElement | void,
  42. children: Array<ASTNode>,
  43. static?: boolean,
  44. staticRoot?: boolean,
  45. text?: string,
  46. attrs?: Array<{ name: string, value: string }>,
  47. props?: Array<{ name: string, value: string }>,
  48. staticAttrs?: Array<{ name: string, value: string }>,
  49. plain?: boolean,
  50. pre?: true,
  51. ns?: string,
  52. component?: string,
  53. keepAlive?: boolean,
  54. inlineTemplate?: true,
  55. transitionMode?: string | null,
  56. slotName?: ?string,
  57. slotTarget?: ?string,
  58. ref?: string,
  59. refInFor?: boolean,
  60. render?: true,
  61. renderMethod?: ?string,
  62. renderArgs?: ?string,
  63. if?: string | null,
  64. else?: true,
  65. elseBlock?: ASTElement,
  66. for?: string | null,
  67. key?: string,
  68. alias?: string,
  69. iterator?: string,
  70. staticClass?: string,
  71. classBinding?: string,
  72. styleBinding?: string,
  73. hooks?: ASTElementHooks,
  74. events?: ASTElementHandlers,
  75. transition?: string | true,
  76. transitionOnAppear?: boolean,
  77. directives?: Array<ASTDirective>,
  78. forbidden?: true,
  79. once?: true
  80. }
  81. declare type ASTExpression = {
  82. type: 2,
  83. expression: string,
  84. static?: boolean
  85. }
  86. declare type ASTText = {
  87. type: 3,
  88. text: string,
  89. static?: boolean
  90. }