fix: emitted visible scene bounds not accounting for offsets (#7450)

This commit is contained in:
David Luzar 2023-12-16 17:32:54 +01:00 committed by GitHub
parent 561e919a2e
commit 6dfa89e846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 54 deletions

View file

@ -10,6 +10,7 @@ import {
import { serializeAsJSON } from "../../packages/excalidraw/data/json";
import { restore } from "../../packages/excalidraw/data/restore";
import { ImportedDataState } from "../../packages/excalidraw/data/types";
import { SceneBounds } from "../../packages/excalidraw/element/bounds";
import { isInvisiblySmallElement } from "../../packages/excalidraw/element/sizeHelpers";
import { isInitializedImageElement } from "../../packages/excalidraw/element/typeChecks";
import {
@ -28,6 +29,7 @@ import {
DELETED_ELEMENT_TIMEOUT,
FILE_UPLOAD_MAX_BYTES,
ROOM_ID_BYTES,
WS_SUBTYPES,
} from "../app_constants";
import { encodeFilesForUpload } from "./FileManager";
import { saveFilesToFirebase } from "./firebase";
@ -97,20 +99,23 @@ export type EncryptedData = {
};
export type SocketUpdateDataSource = {
INVALID_RESPONSE: {
type: WS_SUBTYPES.INVALID_RESPONSE;
};
SCENE_INIT: {
type: "SCENE_INIT";
type: WS_SUBTYPES.INIT;
payload: {
elements: readonly ExcalidrawElement[];
};
};
SCENE_UPDATE: {
type: "SCENE_UPDATE";
type: WS_SUBTYPES.UPDATE;
payload: {
elements: readonly ExcalidrawElement[];
};
};
MOUSE_LOCATION: {
type: "MOUSE_LOCATION";
type: WS_SUBTYPES.MOUSE_LOCATION;
payload: {
socketId: string;
pointer: { x: number; y: number; tool: "pointer" | "laser" };
@ -119,16 +124,16 @@ export type SocketUpdateDataSource = {
username: string;
};
};
USER_VIEWPORT_BOUNDS: {
type: "USER_VIEWPORT_BOUNDS";
USER_VISIBLE_SCENE_BOUNDS: {
type: WS_SUBTYPES.USER_VISIBLE_SCENE_BOUNDS;
payload: {
socketId: string;
username: string;
bounds: [number, number, number, number];
sceneBounds: SceneBounds;
};
};
IDLE_STATUS: {
type: "IDLE_STATUS";
type: WS_SUBTYPES.IDLE_STATUS;
payload: {
socketId: string;
userState: UserIdleState;
@ -138,10 +143,7 @@ export type SocketUpdateDataSource = {
};
export type SocketUpdateDataIncoming =
| SocketUpdateDataSource[keyof SocketUpdateDataSource]
| {
type: "INVALID_RESPONSE";
};
SocketUpdateDataSource[keyof SocketUpdateDataSource];
export type SocketUpdateData =
SocketUpdateDataSource[keyof SocketUpdateDataSource] & {