utils.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import * as t from '@babel/types';
  2. import { NodePath } from '@babel/traverse';
  3. import type { State } from './interface';
  4. import SlotFlags from './slotFlags';
  5. export declare const JSX_HELPER_KEY = "JSX_HELPER_KEY";
  6. export declare const FRAGMENT = "Fragment";
  7. export declare const KEEP_ALIVE = "KeepAlive";
  8. /**
  9. * create Identifier
  10. * @param path NodePath
  11. * @param state
  12. * @param name string
  13. * @returns MemberExpression
  14. */
  15. export declare const createIdentifier: (state: State, name: string) => t.Identifier | t.MemberExpression;
  16. /**
  17. * Checks if string is describing a directive
  18. * @param src string
  19. */
  20. export declare const isDirective: (src: string) => boolean;
  21. /**
  22. * Should transformed to slots
  23. * @param tag string
  24. * @returns boolean
  25. */
  26. export declare const shouldTransformedToSlots: (tag: string) => boolean;
  27. /**
  28. * Check if a Node is a component
  29. *
  30. * @param t
  31. * @param path JSXOpeningElement
  32. * @returns boolean
  33. */
  34. export declare const checkIsComponent: (path: NodePath<t.JSXOpeningElement>, state: State) => boolean;
  35. /**
  36. * Transform JSXMemberExpression to MemberExpression
  37. * @param path JSXMemberExpression
  38. * @returns MemberExpression
  39. */
  40. export declare const transformJSXMemberExpression: (path: NodePath<t.JSXMemberExpression>) => t.MemberExpression;
  41. /**
  42. * Get tag (first attribute for h) from JSXOpeningElement
  43. * @param path JSXElement
  44. * @param state State
  45. * @returns Identifier | StringLiteral | MemberExpression | CallExpression
  46. */
  47. export declare const getTag: (path: NodePath<t.JSXElement>, state: State) => t.Identifier | t.CallExpression | t.StringLiteral | t.MemberExpression;
  48. export declare const getJSXAttributeName: (path: NodePath<t.JSXAttribute>) => string;
  49. /**
  50. * Transform JSXText to StringLiteral
  51. * @param path JSXText
  52. * @returns StringLiteral | null
  53. */
  54. export declare const transformJSXText: (path: NodePath<t.JSXText>) => t.StringLiteral | null;
  55. /**
  56. * Transform JSXExpressionContainer to Expression
  57. * @param path JSXExpressionContainer
  58. * @returns Expression
  59. */
  60. export declare const transformJSXExpressionContainer: (path: NodePath<t.JSXExpressionContainer>) => (t.Expression);
  61. /**
  62. * Transform JSXSpreadChild
  63. * @param path JSXSpreadChild
  64. * @returns SpreadElement
  65. */
  66. export declare const transformJSXSpreadChild: (path: NodePath<t.JSXSpreadChild>) => t.SpreadElement;
  67. export declare const walksScope: (path: NodePath, name: string, slotFlag: SlotFlags) => void;
  68. export declare const buildIIFE: (path: NodePath<t.JSXElement>, children: t.Expression[]) => t.Expression[];
  69. export declare const isOn: (key: string) => boolean;
  70. export declare const dedupeProperties: (properties?: t.ObjectProperty[], mergeProps?: boolean | undefined) => t.ObjectProperty[];
  71. /**
  72. * Check if an attribute value is constant
  73. * @param node
  74. * @returns boolean
  75. */
  76. export declare const isConstant: (node: t.Expression | t.Identifier | t.Literal | t.SpreadElement | null) => boolean;
  77. export declare const transformJSXSpreadAttribute: (nodePath: NodePath, path: NodePath<t.JSXSpreadAttribute>, mergeProps: boolean, args: (t.ObjectProperty | t.Expression | t.SpreadElement)[]) => void;