app_constants.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // time constants (ms)
  2. export const SAVE_TO_LOCAL_STORAGE_TIMEOUT = 300;
  3. export const INITIAL_SCENE_UPDATE_TIMEOUT = 5000;
  4. export const FILE_UPLOAD_TIMEOUT = 300;
  5. export const LOAD_IMAGES_TIMEOUT = 500;
  6. export const SYNC_FULL_SCENE_INTERVAL_MS = 20000;
  7. export const SYNC_BROWSER_TABS_TIMEOUT = 50;
  8. export const CURSOR_SYNC_TIMEOUT = 33; // ~30fps
  9. export const DELETED_ELEMENT_TIMEOUT = 24 * 60 * 60 * 1000; // 1 day
  10. // should be aligned with MAX_ALLOWED_FILE_BYTES
  11. export const FILE_UPLOAD_MAX_BYTES = 4 * 1024 * 1024; // 4 MiB
  12. // 1 year (https://stackoverflow.com/a/25201898/927631)
  13. export const FILE_CACHE_MAX_AGE_SEC = 31536000;
  14. export const WS_EVENTS = {
  15. SERVER_VOLATILE: "server-volatile-broadcast",
  16. SERVER: "server-broadcast",
  17. USER_FOLLOW_CHANGE: "user-follow",
  18. USER_FOLLOW_ROOM_CHANGE: "user-follow-room-change",
  19. } as const;
  20. export enum WS_SUBTYPES {
  21. INVALID_RESPONSE = "INVALID_RESPONSE",
  22. INIT = "SCENE_INIT",
  23. UPDATE = "SCENE_UPDATE",
  24. MOUSE_LOCATION = "MOUSE_LOCATION",
  25. IDLE_STATUS = "IDLE_STATUS",
  26. USER_VISIBLE_SCENE_BOUNDS = "USER_VISIBLE_SCENE_BOUNDS",
  27. }
  28. export const FIREBASE_STORAGE_PREFIXES = {
  29. shareLinkFiles: `/files/shareLinks`,
  30. collabFiles: `/files/rooms`,
  31. };
  32. export const ROOM_ID_BYTES = 10;
  33. export const STORAGE_KEYS = {
  34. LOCAL_STORAGE_ELEMENTS: "excalidraw",
  35. LOCAL_STORAGE_APP_STATE: "excalidraw-state",
  36. LOCAL_STORAGE_COLLAB: "excalidraw-collab",
  37. LOCAL_STORAGE_THEME: "excalidraw-theme",
  38. LOCAL_STORAGE_DEBUG: "excalidraw-debug",
  39. VERSION_DATA_STATE: "version-dataState",
  40. VERSION_FILES: "version-files",
  41. IDB_LIBRARY: "excalidraw-library",
  42. IDB_TTD_CHATS: "excalidraw-ttd-chats",
  43. // do not use apart from migrations
  44. __LEGACY_LOCAL_STORAGE_LIBRARY: "excalidraw-library",
  45. } as const;
  46. export const COOKIES = {
  47. AUTH_STATE_COOKIE: "excplus-auth",
  48. } as const;
  49. export const isExcalidrawPlusSignedUser = document.cookie.includes(
  50. COOKIES.AUTH_STATE_COOKIE,
  51. );