vnode.d.ts 2.5 KB

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