import { Pose2DMap } from '@models/utils/coordinates' ; import { MapObject } from './MapObject' ; const MAXIMIZABLE_IMAGE_MIN_WIDTH = 200 ; export type ContentType = 'img' | 'text' | 'pdf' | 'youtube' | 'iframe' | 'screen' | 'camera' | 'gdrive' | 'whiteboard' | 'playbackScreen' | 'playbackCamera' | '' ; export interface SharedContentInfoData { name : string ; ownerName : string ; color : number [ ] ; textColor : number [ ] ; type : ContentType ; } export interface SharedContentId { id : string ; } export interface SharedContentInfo extends SharedContentInfoData , SharedContentId { } export function isEqualSharedContentInfo ( a , b ) { return a . name === b . name && a . ownerName === b . ownerName && a . color . toString ( ) === b . color . toString ( ) && a . textColor . toString ( ) === b . textColor . toString ( ) ; } export function extractSharedContentInfo ( c ) { const rv = { id : c . id , name : c . name , ownerName : c . ownerName , color : c . color , textColor : c . textColor , type : c . type } ; return rv ; } export type ZoneType = 'open' | 'close' ; export interface SharedContentData extends SharedContentInfoData { zorder : number ; url : string ; pose : Pose2DMap ; size : [ number , number ] ; originalSize : [ number , number ] ; pinned : boolean ; noFrame ? : boolean ; opacity ? : number ; zone ? : ZoneType ; playback ? : boolean ; } export interface ISharedContent extends MapObject , SharedContentData , SharedContentId { zIndex ? : number ; } export const TIME_RESOLUTION_IN_MS = 100 ; export const TEN_YEAR = 1000 * 60 * 60 * 24 * 365 * 10 / TIME_RESOLUTION_IN_MS ; export function doseContentEditingUseKeyinput ( c ) { return c . type === 'text' || c . type === 'pdf' ; } export function canContentBeAWallpaper ( c ? ) { return c && ( c . type !== 'camera' && c . type !== 'screen' ) ; } export function isContentEditable ( c ? ) { return c && ( c . type === 'text' || c . type === 'iframe' || c . type === 'pdf' || c . type === 'whiteboard' || c . type === 'gdrive' || c . type === 'youtube' ) ; } export function isContentMaximizable ( c ? ) { return c && ( c . type === 'iframe' || c . type === 'pdf' || c . type === 'whiteboard' || c . type === 'gdrive' || c . type === 'youtube' || c . type === 'screen' || c . type === 'camera' || ( c . type === 'img' && c . size [ 0 ] > MAXIMIZABLE_IMAGE_MIN_WIDTH ) ) ; } export function isContentWallpaper ( c ? ) { return c && c . zorder <= TEN_YEAR ; } export const CONTENT_OUT_OF_RANGE_VALUE = 1024 * 1024 ; export function isContentOutOfRange ( c ? ) { return ! c || c . pose . position [ 0 ] === CONTENT_OUT_OF_RANGE_VALUE ; } export interface WallpaperStore { room : string ; contents : SharedContentData [ ] ; } export interface TextMessage { message : string ; name : string ; color ? : number [ ] ; textColor ? : number [ ] ; pid : string ; time : number ; } export interface TextMessages { messages : TextMessage [ ] ; scroll : [ number , number ] ; } export function compTextMessage ( t1 , t2 ) { return t1 . time - t2 . time ; }