UNPKG

@excalidraw/math

Version:

Excalidraw math functions

54 lines (53 loc) 3.65 kB
import { IMAGE_MIME_TYPES, MIME_TYPES } from "@excalidraw/common"; import type { ValueOf } from "@excalidraw/common/utility-types"; import type { ExcalidrawElement, FileId } from "@excalidraw/element/types"; import type { AppState, DataURL, LibraryItem } from "../types"; import type { FileSystemHandle } from "./filesystem"; import type { ImportedLibraryData } from "./types"; export declare const getMimeType: (blob: Blob | string) => string; export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null; export declare const isImageFileHandleType: (type: string | null) => type is "png" | "svg"; export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean; export declare const isSupportedImageFileType: (type: string | null | undefined) => boolean; export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & { type: ValueOf<typeof IMAGE_MIME_TYPES>; }; export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<{ type: "application/vnd.excalidraw+json"; data: import("./restore").RestoredDataState; } | { type: "application/vnd.excalidrawlib+json"; data: ImportedLibraryData; }>; export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<import("./restore").RestoredDataState>; export declare const parseLibraryJSON: (json: string, defaultStatus?: LibraryItem["status"]) => LibraryItem[]; export declare const loadLibraryFromBlob: (blob: Blob, defaultStatus?: LibraryItem["status"]) => Promise<LibraryItem[]>; export declare const canvasToBlob: (canvas: HTMLCanvasElement | Promise<HTMLCanvasElement>) => Promise<Blob>; /** generates SHA-1 digest from supplied file (if not supported, falls back to a 40-char base64 random id) */ export declare const generateIdFromFile: (file: File) => Promise<FileId>; /** async. For sync variant, use getDataURL_sync */ export declare const getDataURL: (file: Blob | File) => Promise<DataURL>; export declare const getDataURL_sync: (data: string | Uint8Array | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>) => DataURL; export declare const dataURLToFile: (dataURL: DataURL, filename?: string) => File; export declare const dataURLToString: (dataURL: DataURL) => string; export declare const resizeImageFile: (file: File, opts: { /** undefined indicates auto */ outputType?: (typeof MIME_TYPES)["jpg"]; maxWidthOrHeight: number; }) => Promise<File>; export declare const SVGStringToFile: (SVGString: string, filename?: string) => File & { type: typeof MIME_TYPES.svg; }; export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>; export declare const getFileFromEvent: (event: React.DragEvent<HTMLDivElement>) => Promise<{ file: File | null; fileHandle: FileSystemHandle | null; }>; export declare const getFileHandle: (event: React.DragEvent<HTMLDivElement>) => Promise<FileSystemHandle | null>; export declare const createFile: (blob: File | Blob | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>, name: string | undefined) => File; /** attempts to detect correct mimeType if none is set, or if an image * has an incorrect extension. * Note: doesn't handle missing .excalidraw/.excalidrawlib extension */ export declare const normalizeFile: (file: File) => Promise<File>; export declare const blobToArrayBuffer: (blob: Blob) => Promise<ArrayBuffer>;