excalidraw/excalidraw-app/data/StorageBackend.ts

46 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { SyncableExcalidrawElement } from ".";
import { ExcalidrawElement, FileId } from "../../packages/excalidraw/element/types";
import { AppState, BinaryFileData } from "../../packages/excalidraw/types";
import Portal from "../collab/Portal";
export interface StorageBackend {
isSaved: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
saveToStorageBackend: (
portal: Portal,
elements: readonly SyncableExcalidrawElement[],
appState: AppState,
) => Promise<false | { reconciledElements: any }>;
loadFromStorageBackend: (
roomId: string,
roomKey: string,
socket: SocketIOClient.Socket | null,
) => Promise<readonly ExcalidrawElement[] | null>;
saveFilesToStorageBackend: ({
prefix,
files,
}: {
prefix: string;
files: {
id: FileId;
buffer: Uint8Array;
}[];
}) => Promise<{
savedFiles: Map<FileId, true>;
erroredFiles: Map<FileId, true>;
}>;
loadFilesFromStorageBackend: (
prefix: string,
decryptionKey: string,
filesIds: readonly FileId[],
) => Promise<{
loadedFiles: BinaryFileData[];
erroredFiles: Map<FileId, true>;
}>;
}
export interface StoredScene {
sceneVersion: number;
iv: Uint8Array;
ciphertext: ArrayBuffer;
}