utils.d.ts 2.6 KB

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