applying changes from upstream commits 20e3acf7a6 and 561e919a2e which broke the yarn build (#1)
This commit is contained in:
parent
c4d5da3bf5
commit
8f410897a4
@ -23,7 +23,7 @@ import type { Socket } from "socket.io-client";
|
|||||||
|
|
||||||
class Portal {
|
class Portal {
|
||||||
collab: TCollabClass;
|
collab: TCollabClass;
|
||||||
socket: SocketIOClient.Socket | null = null;
|
socket: Socket | null = null;
|
||||||
socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized
|
socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized
|
||||||
roomId: string | null = null;
|
roomId: string | null = null;
|
||||||
roomKey: string | null = null;
|
roomKey: string | null = null;
|
||||||
@ -33,7 +33,7 @@ class Portal {
|
|||||||
this.collab = collab;
|
this.collab = collab;
|
||||||
}
|
}
|
||||||
|
|
||||||
open(socket: SocketIOClient.Socket, id: string, key: string) {
|
open(socket: Socket, id: string, key: string) {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.roomId = id;
|
this.roomId = id;
|
||||||
this.roomKey = key;
|
this.roomKey = key;
|
||||||
|
@ -2,6 +2,7 @@ import { SyncableExcalidrawElement } from ".";
|
|||||||
import { ExcalidrawElement, FileId } from "../../packages/excalidraw/element/types";
|
import { ExcalidrawElement, FileId } from "../../packages/excalidraw/element/types";
|
||||||
import { AppState, BinaryFileData } from "../../packages/excalidraw/types";
|
import { AppState, BinaryFileData } from "../../packages/excalidraw/types";
|
||||||
import Portal from "../collab/Portal";
|
import Portal from "../collab/Portal";
|
||||||
|
import type { Socket } from "socket.io-client";
|
||||||
|
|
||||||
export interface StorageBackend {
|
export interface StorageBackend {
|
||||||
isSaved: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
|
isSaved: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
|
||||||
@ -13,7 +14,7 @@ export interface StorageBackend {
|
|||||||
loadFromStorageBackend: (
|
loadFromStorageBackend: (
|
||||||
roomId: string,
|
roomId: string,
|
||||||
roomKey: string,
|
roomKey: string,
|
||||||
socket: SocketIOClient.Socket | null,
|
socket: Socket | null,
|
||||||
) => Promise<readonly ExcalidrawElement[] | null>;
|
) => Promise<readonly ExcalidrawElement[] | null>;
|
||||||
saveFilesToStorageBackend: ({
|
saveFilesToStorageBackend: ({
|
||||||
prefix,
|
prefix,
|
||||||
|
@ -21,7 +21,7 @@ import { MIME_TYPES } from "../../packages/excalidraw/constants";
|
|||||||
import { reconcileElements } from "../collab/reconciliation";
|
import { reconcileElements } from "../collab/reconciliation";
|
||||||
import { getSyncableElements, SyncableExcalidrawElement } from ".";
|
import { getSyncableElements, SyncableExcalidrawElement } from ".";
|
||||||
import { ResolutionType } from "../../packages/excalidraw/utility-types";
|
import { ResolutionType } from "../../packages/excalidraw/utility-types";
|
||||||
import { Socket } from "socket.io-client";
|
import type { Socket } from "socket.io-client";
|
||||||
|
|
||||||
// private
|
// private
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -141,12 +141,12 @@ const decryptElements = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
class FirebaseSceneVersionCache {
|
class FirebaseSceneVersionCache {
|
||||||
private static cache = new WeakMap<SocketIOClient.Socket, number>();
|
private static cache = new WeakMap<Socket, number>();
|
||||||
static get = (socket: SocketIOClient.Socket) => {
|
static get = (socket: Socket) => {
|
||||||
return FirebaseSceneVersionCache.cache.get(socket);
|
return FirebaseSceneVersionCache.cache.get(socket);
|
||||||
};
|
};
|
||||||
static set = (
|
static set = (
|
||||||
socket: SocketIOClient.Socket,
|
socket: Socket,
|
||||||
elements: readonly SyncableExcalidrawElement[],
|
elements: readonly SyncableExcalidrawElement[],
|
||||||
) => {
|
) => {
|
||||||
FirebaseSceneVersionCache.cache.set(socket, getSceneVersion(elements));
|
FirebaseSceneVersionCache.cache.set(socket, getSceneVersion(elements));
|
||||||
@ -288,7 +288,7 @@ export const saveToFirebase = async (
|
|||||||
export const loadFromFirebase = async (
|
export const loadFromFirebase = async (
|
||||||
roomId: string,
|
roomId: string,
|
||||||
roomKey: string,
|
roomKey: string,
|
||||||
socket: SocketIOClient.Socket | null,
|
socket: Socket | null,
|
||||||
): Promise<readonly ExcalidrawElement[] | null> => {
|
): Promise<readonly ExcalidrawElement[] | null> => {
|
||||||
const firebase = await loadFirestore();
|
const firebase = await loadFirestore();
|
||||||
const db = firebase.firestore();
|
const db = firebase.firestore();
|
||||||
|
@ -17,6 +17,7 @@ import {
|
|||||||
import Portal from "../collab/Portal";
|
import Portal from "../collab/Portal";
|
||||||
import { reconcileElements } from "../collab/reconciliation";
|
import { reconcileElements } from "../collab/reconciliation";
|
||||||
import { StoredScene } from "./StorageBackend";
|
import { StoredScene } from "./StorageBackend";
|
||||||
|
import type { Socket } from "socket.io-client";
|
||||||
|
|
||||||
const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
|
const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
|
||||||
const SCENE_VERSION_LENGTH_BYTES = 4
|
const SCENE_VERSION_LENGTH_BYTES = 4
|
||||||
@ -25,7 +26,7 @@ const SCENE_VERSION_LENGTH_BYTES = 4
|
|||||||
// to prevent modifying upstream files and ease futur maintenance of this fork
|
// to prevent modifying upstream files and ease futur maintenance of this fork
|
||||||
|
|
||||||
const httpStorageSceneVersionCache = new WeakMap<
|
const httpStorageSceneVersionCache = new WeakMap<
|
||||||
SocketIOClient.Socket,
|
Socket,
|
||||||
number
|
number
|
||||||
>();
|
>();
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ export const saveToHttpStorage = async (
|
|||||||
export const loadFromHttpStorage = async (
|
export const loadFromHttpStorage = async (
|
||||||
roomId: string,
|
roomId: string,
|
||||||
roomKey: string,
|
roomKey: string,
|
||||||
socket: SocketIOClient.Socket | null,
|
socket: Socket | null,
|
||||||
): Promise<readonly ExcalidrawElement[] | null> => {
|
): Promise<readonly ExcalidrawElement[] | null> => {
|
||||||
const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
|
const HTTP_STORAGE_BACKEND_URL = import.meta.env.VITE_APP_HTTP_STORAGE_BACKEND_URL;
|
||||||
const getResponse = await fetch(
|
const getResponse = await fetch(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user