zrender.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*!
  2. * ZRender, a high performance 2d drawing library.
  3. *
  4. * Copyright (c) 2013, Baidu Inc.
  5. * All rights reserved.
  6. *
  7. * LICENSE
  8. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  9. */
  10. import * as zrUtil from './core/util';
  11. import Handler from './Handler';
  12. import Storage from './Storage';
  13. import { PainterBase } from './PainterBase';
  14. import Animation from './animation/Animation';
  15. import Element, { ElementEventCallback } from './Element';
  16. import { ElementEventName, WithThisType } from './core/types';
  17. import { LayerConfig } from './canvas/Layer';
  18. import { GradientObject } from './graphic/Gradient';
  19. import { PatternObject } from './graphic/Pattern';
  20. import { EventCallback } from './core/Eventful';
  21. import Displayable from './graphic/Displayable';
  22. declare type PainterBaseCtor = {
  23. new (dom: HTMLElement, storage: Storage, ...args: any[]): PainterBase;
  24. };
  25. declare class ZRender {
  26. dom?: HTMLElement;
  27. id: number;
  28. storage: Storage;
  29. painter: PainterBase;
  30. handler: Handler;
  31. animation: Animation;
  32. private _sleepAfterStill;
  33. private _stillFrameAccum;
  34. private _needsRefresh;
  35. private _needsRefreshHover;
  36. private _disposed;
  37. private _darkMode;
  38. private _backgroundColor;
  39. constructor(id: number, dom?: HTMLElement, opts?: ZRenderInitOpt);
  40. add(el: Element): void;
  41. remove(el: Element): void;
  42. configLayer(zLevel: number, config: LayerConfig): void;
  43. setBackgroundColor(backgroundColor: string | GradientObject | PatternObject): void;
  44. getBackgroundColor(): string | GradientObject | PatternObject;
  45. setDarkMode(darkMode: boolean): void;
  46. isDarkMode(): boolean;
  47. refreshImmediately(fromInside?: boolean): void;
  48. refresh(): void;
  49. flush(): void;
  50. private _flush;
  51. setSleepAfterStill(stillFramesCount: number): void;
  52. wakeUp(): void;
  53. refreshHover(): void;
  54. refreshHoverImmediately(): void;
  55. resize(opts?: {
  56. width?: number | string;
  57. height?: number | string;
  58. }): void;
  59. clearAnimation(): void;
  60. getWidth(): number | undefined;
  61. getHeight(): number | undefined;
  62. setCursorStyle(cursorStyle: string): void;
  63. findHover(x: number, y: number): {
  64. target: Displayable;
  65. topTarget: Displayable;
  66. } | undefined;
  67. on<Ctx>(eventName: ElementEventName, eventHandler: ElementEventCallback<Ctx, ZRenderType>, context?: Ctx): this;
  68. on<Ctx>(eventName: string, eventHandler: WithThisType<EventCallback<any[]>, unknown extends Ctx ? ZRenderType : Ctx>, context?: Ctx): this;
  69. off(eventName?: string, eventHandler?: EventCallback): void;
  70. trigger(eventName: string, event?: unknown): void;
  71. clear(): void;
  72. dispose(): void;
  73. }
  74. export interface ZRenderInitOpt {
  75. renderer?: string;
  76. devicePixelRatio?: number;
  77. width?: number | string;
  78. height?: number | string;
  79. useDirtyRect?: boolean;
  80. useCoarsePointer?: 'auto' | boolean;
  81. pointerSize?: number;
  82. ssr?: boolean;
  83. }
  84. export declare function init(dom?: HTMLElement | null, opts?: ZRenderInitOpt): ZRender;
  85. export declare function dispose(zr: ZRender): void;
  86. export declare function disposeAll(): void;
  87. export declare function getInstance(id: number): ZRender;
  88. export declare function registerPainter(name: string, Ctor: PainterBaseCtor): void;
  89. export declare type ElementSSRData = zrUtil.HashMap<unknown>;
  90. export declare type ElementSSRDataGetter<T> = (el: Element) => zrUtil.HashMap<T>;
  91. export declare function getElementSSRData(el: Element): ElementSSRData;
  92. export declare function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>): void;
  93. export declare const version = "5.6.0";
  94. export interface ZRenderType extends ZRender {
  95. }
  96. export {};