mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Temporarily move sync into package
This commit is contained in:
parent
245d681b7d
commit
508cfbc843
13 changed files with 1110 additions and 34 deletions
40
packages/excalidraw/sync/protocol.ts
Normal file
40
packages/excalidraw/sync/protocol.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
export type RELAY_PAYLOAD = { buffer: ArrayBuffer };
|
||||
export type PULL_PAYLOAD = { lastAcknowledgedVersion: number };
|
||||
export type PUSH_PAYLOAD = {
|
||||
type: "durable" | "ephemeral";
|
||||
changes: Array<CLIENT_CHANGE>;
|
||||
};
|
||||
|
||||
export type CLIENT_CHANGE = {
|
||||
id: string;
|
||||
appStateChange: any;
|
||||
elementsChange: any;
|
||||
};
|
||||
|
||||
export type CLIENT_MESSAGE =
|
||||
| { type: "relay"; payload: RELAY_PAYLOAD }
|
||||
| { type: "pull"; payload: PULL_PAYLOAD }
|
||||
| { type: "push"; payload: PUSH_PAYLOAD };
|
||||
|
||||
export type SERVER_CHANGE = { id: string; version: number; payload: string };
|
||||
export type SERVER_MESSAGE =
|
||||
| {
|
||||
type: "relayed";
|
||||
payload: { changes: Array<CLIENT_CHANGE> } | RELAY_PAYLOAD;
|
||||
}
|
||||
| { type: "acknowledged"; payload: { changes: Array<SERVER_CHANGE> } }
|
||||
| { type: "rejected"; payload: { ids: Array<string>; message: string } };
|
||||
|
||||
export interface ChangesRepository {
|
||||
saveAll(changes: Array<CLIENT_CHANGE>): Array<SERVER_CHANGE>;
|
||||
getSinceVersion(version: number): Array<SERVER_CHANGE>;
|
||||
getLastVersion(): number;
|
||||
}
|
||||
|
||||
// TODO: should come from the shared types package
|
||||
export type ExcalidrawElement = {
|
||||
id: string;
|
||||
type: any;
|
||||
version: number;
|
||||
[key: string]: any;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue