mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Offline support with increments peristed and restored to / from indexedb
This commit is contained in:
parent
15d2942aaa
commit
040a57f56a
19 changed files with 1827 additions and 1104 deletions
|
@ -1,34 +1,34 @@
|
|||
import type { ElementsChange } from "../change";
|
||||
import type { StoreIncrement } from "../store";
|
||||
|
||||
export type RELAY_PAYLOAD = { buffer: ArrayBuffer };
|
||||
export type PULL_PAYLOAD = { lastAcknowledgedVersion: number };
|
||||
export type PUSH_PAYLOAD = {
|
||||
type: "durable" | "ephemeral";
|
||||
changes: Array<CLIENT_CHANGE>;
|
||||
increments: Array<CLIENT_INCREMENT>;
|
||||
};
|
||||
|
||||
export type CLIENT_CHANGE = ElementsChange;
|
||||
export type CLIENT_INCREMENT = StoreIncrement;
|
||||
|
||||
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_INCREMENT = { id: string; version: number; payload: string };
|
||||
export type SERVER_MESSAGE =
|
||||
| {
|
||||
type: "relayed";
|
||||
payload: { changes: Array<CLIENT_CHANGE> } | RELAY_PAYLOAD;
|
||||
payload: { increments: Array<CLIENT_INCREMENT> } | RELAY_PAYLOAD;
|
||||
}
|
||||
| { type: "acknowledged"; payload: { changes: Array<SERVER_CHANGE> } }
|
||||
| { type: "acknowledged"; payload: { increments: Array<SERVER_INCREMENT> } }
|
||||
| {
|
||||
type: "rejected";
|
||||
payload: { changes: Array<CLIENT_CHANGE>; message: string };
|
||||
payload: { increments: Array<CLIENT_INCREMENT>; message: string };
|
||||
};
|
||||
|
||||
export interface ChangesRepository {
|
||||
saveAll(changes: Array<CLIENT_CHANGE>): Array<SERVER_CHANGE>;
|
||||
getSinceVersion(version: number): Array<SERVER_CHANGE>;
|
||||
export interface IncrementsRepository {
|
||||
saveAll(increments: Array<CLIENT_INCREMENT>): Array<SERVER_INCREMENT>;
|
||||
getSinceVersion(version: number): Array<SERVER_INCREMENT>;
|
||||
getLastVersion(): number;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue