2024-08-23 15:54:59 +02:00
|
|
|
import type { SyncableExcalidrawElement } from ".";
|
|
|
|
import type {
|
|
|
|
ExcalidrawElement,
|
|
|
|
FileId,
|
|
|
|
} from "../../packages/excalidraw/element/types";
|
|
|
|
import type { AppState, BinaryFileData } from "../../packages/excalidraw/types";
|
|
|
|
import type Portal from "../collab/Portal";
|
2024-05-27 16:11:57 +02:00
|
|
|
import type { Socket } from "socket.io-client";
|
2024-01-01 18:05:48 +01:00
|
|
|
|
|
|
|
export interface StorageBackend {
|
|
|
|
isSaved: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
|
|
|
|
saveToStorageBackend: (
|
|
|
|
portal: Portal,
|
|
|
|
elements: readonly SyncableExcalidrawElement[],
|
|
|
|
appState: AppState,
|
2024-08-23 15:54:59 +02:00
|
|
|
) => Promise<false | readonly SyncableExcalidrawElement[] | null>;
|
2024-01-01 18:05:48 +01:00
|
|
|
loadFromStorageBackend: (
|
|
|
|
roomId: string,
|
|
|
|
roomKey: string,
|
2024-05-27 16:11:57 +02:00
|
|
|
socket: Socket | null,
|
2024-01-01 18:05:48 +01:00
|
|
|
) => 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;
|
|
|
|
}
|