/* tslint:disable */
/* eslint-disable */
/**
 * Collects the fetch task urls from the node.
 */
export function collectNodeFetchTasks(node: AnyNode): string[];

export type AnyNode = { type: string; [key: string]: any };

export type ByteBuf = Uint8Array | ArrayBuffer | Buffer;

export type RenderOptions = {
  /**
   * The width of the image. If not provided, the width will be automatically calculated based on the content.
   */
  width?: number,
  /**
   * The height of the image. If not provided, the height will be automatically calculated based on the content.
   */
  height?: number,
  /**
   * The format of the image.
   * @default "png"
   */
  format?: "png" | "jpeg" | "webp",
  /**
   * The quality of JPEG format (0-100).
   */
  quality?: number,
  /**
   * The resources fetched externally. You should collect the fetch tasks first using `collectNodeFetchTasks` and then pass the resources here.
   */
  fetchedResources?: Map<string, ByteBuf>,
  /**
   * Whether to draw debug borders.
   */
  drawDebugBorder?: boolean,
  /**
   * Defines the ratio resolution of the image to the physical pixels.
   * @default 1.0
   */
  devicePixelRatio?: number,
};

export type RenderAnimationOptions = {
  width: number,
  height: number,
  format?: "webp" | "apng",
  drawDebugBorder?: boolean,
};

export type FontDetails = {
  name?: string,
  data: ByteBuf,
  weight?: number,
  style?: "normal" | "italic" | "oblique",
};

export type Font = FontDetails | ByteBuf;


export class AnimationFrameSource {
  free(): void;
  [Symbol.dispose](): void;
  constructor(node: AnyNode, durationMs: number);
}
export class Renderer {
  free(): void;
  [Symbol.dispose](): void;
  renderAnimation(frames: AnimationFrameSource[], options: RenderAnimationOptions): Uint8Array;
  clearImageStore(): void;
  renderAsDataUrl(node: AnyNode, options: RenderOptions): string;
  /**
   * @deprecated use `loadFont` instead.
   */
  loadFontWithInfo(font: Font): void;
  putPersistentImage(src: string, data: Uint8Array): void;
  constructor();
  render(node: AnyNode, options: RenderOptions): Uint8Array;
  loadFont(font: Font): void;
}

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
  readonly memory: WebAssembly.Memory;
  readonly __wbg_animationframesource_free: (a: number, b: number) => void;
  readonly __wbg_renderer_free: (a: number, b: number) => void;
  readonly animationframesource_new: (a: number, b: number) => number;
  readonly collectNodeFetchTasks: (a: number, b: number) => void;
  readonly renderer_clearImageStore: (a: number) => void;
  readonly renderer_loadFont: (a: number, b: number) => void;
  readonly renderer_loadFontWithInfo: (a: number, b: number) => void;
  readonly renderer_new: () => number;
  readonly renderer_putPersistentImage: (a: number, b: number, c: number, d: number, e: number) => void;
  readonly renderer_render: (a: number, b: number, c: number, d: number) => void;
  readonly renderer_renderAnimation: (a: number, b: number, c: number, d: number, e: number) => void;
  readonly renderer_renderAsDataUrl: (a: number, b: number, c: number, d: number) => void;
  readonly __wbindgen_export: (a: number, b: number) => number;
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
  readonly __wbindgen_export3: (a: number) => void;
  readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
