vnode.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import * as vue from "vue";
  2. import { VNode, VNodeChild, VNodeNormalizedChildren, createBlock } from "vue";
  3. //#region ../../packages/utils/vue/vnode.d.ts
  4. declare enum PatchFlags {
  5. TEXT = 1,
  6. CLASS = 2,
  7. STYLE = 4,
  8. PROPS = 8,
  9. FULL_PROPS = 16,
  10. HYDRATE_EVENTS = 32,
  11. STABLE_FRAGMENT = 64,
  12. KEYED_FRAGMENT = 128,
  13. UNKEYED_FRAGMENT = 256,
  14. NEED_PATCH = 512,
  15. DYNAMIC_SLOTS = 1024,
  16. HOISTED = -1,
  17. BAIL = -2
  18. }
  19. type VNodeChildAtom = Exclude<VNodeChild, Array<any>>;
  20. type RawSlots = Exclude<VNodeNormalizedChildren, Array<any> | null | string>;
  21. declare function isFragment(node: VNode): boolean;
  22. declare function isFragment(node: unknown): node is VNode;
  23. declare function isText(node: VNode): boolean;
  24. declare function isText(node: unknown): node is VNode;
  25. declare function isComment(node: VNode): boolean;
  26. declare function isComment(node: unknown): node is VNode;
  27. declare function isTemplate(node: VNode): boolean;
  28. declare function isTemplate(node: unknown): node is VNode;
  29. /**
  30. * determine if the element is a valid element type rather than fragments and comment e.g. <template> v-if
  31. * @param node {VNode} node to be tested
  32. */
  33. declare function isValidElementNode(node: VNode): boolean;
  34. declare function isValidElementNode(node: unknown): node is VNode;
  35. declare const getFirstValidNode: (nodes: VNodeNormalizedChildren, maxDepth?: number) => string | number | boolean | void | vue.VNodeArrayChildren | {
  36. [name: string]: unknown;
  37. $stable?: boolean;
  38. } | VNode<vue.RendererNode, vue.RendererElement, {
  39. [key: string]: any;
  40. }> | null | undefined;
  41. declare function renderIf(condition: boolean, ...args: Parameters<typeof createBlock>): VNode<vue.RendererNode, vue.RendererElement, {
  42. [key: string]: any;
  43. }>;
  44. declare function renderBlock(...args: Parameters<typeof createBlock>): VNode<vue.RendererNode, vue.RendererElement, {
  45. [key: string]: any;
  46. }>;
  47. declare const getNormalizedProps: (node: VNode) => Record<string, any>;
  48. type FlattenVNodes = Array<VNodeChildAtom | RawSlots>;
  49. declare const flattedChildren: (children: FlattenVNodes | VNode | VNodeNormalizedChildren) => FlattenVNodes;
  50. //#endregion
  51. export { FlattenVNodes, PatchFlags, RawSlots, VNodeChildAtom, flattedChildren, getFirstValidNode, getNormalizedProps, isComment, isFragment, isTemplate, isText, isValidElementNode, renderBlock, renderIf };