Skip to content

Commit

Permalink
chore: shared model
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Nov 7, 2023
1 parent dbe552d commit c2a2973
Showing 1 changed file with 118 additions and 16 deletions.
134 changes: 118 additions & 16 deletions packages/shared/model/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { ProtectedString } from './ProtectedString.js'

/*
These types are shared between the server and the client
*/

export type RundownPlaylistId = ProtectedString<'RundownPlaylistId', string>
export interface RundownPlaylist {
_id: RundownPlaylistId

/** Rundown playlist slug - user-presentable name */
name: string
label: string
created: number
modified: number

Expand All @@ -15,38 +19,73 @@ export interface RundownPlaylist {
rehearsal: boolean
/** Actual time of playback starting */
startedPlayback?: number

// To be implemented later:
// timing: {
// expectedStart?: number
// expectedEnd?: number
// expectedDuration?: number
// startedPlayback?: number
// }
}

export type RundownId = ProtectedString<'RundownId', string>
export interface Rundown {
_id: RundownId

playlistId: RundownPlaylistId
/** The position of the Rundown within its Playlist */
rank: number

// To be implemented later:
// timing: {
// expectedStart?: number
// expectedEnd?: number
// expectedDuration?: number
// startedPlayback?: number
// }
}

export type SegmentId = ProtectedString<'SegmentId', string>
export interface Segment {
_id: SegmentId
rundownId: RundownId
/** The position of the Segment within its Rundown */
rank: number

/** User-presentable name (Slug) for the Title */
name: string
label: string

/** Hide the Segment in the UI */
isHidden?: boolean

// To be implemented later:
/** User-facing identifier that can be used by the User to identify the contents of a segment in the Rundown source system */
identifier?: string
// identifier?: string

timing: {
expectedStart?: number
expectedEnd?: number
budgetDuration?: number
}
}

export type PartId = ProtectedString<'PartId', string>
export interface Part {
_id: PartId
rundownId: RundownId
segmentId: SegmentId
/** The position of the Part within its Segment */
rank: number

isOnAir: boolean
isNext: boolean

/** The story title/slug, displayable to user */
label: string

/** The story title */
title: string
/** An alternative override to show in the rendered prompter output */
prompterLabel?: string

/** User-facing identifier that can be used by the User to identify the contents of a segment in the Rundown source system */
identifier?: string
Expand All @@ -57,19 +96,82 @@ export interface Part {
/** Expected duration of the Part, in milliseconds */
expectedDuration?: number

/** The type of Part, eg STK, FULL. To be displayed to user */
displayType: string
/** Is true if the Part has been updated since user last saw it. User can acknowledge*/
isNew?: boolean

/** The type of Part, eg STK, FULL. */
display: {
/** Styling information (colors, etc.) */
type: PartDisplayType // ie sourceLayer.type in Sofie
/** Label to be displayed to user */
label: string // ie sourceLayer.name in Sofie
}

scriptContents?: ScriptContents
}
export enum PartDisplayType {
KAM,
FULL,
STK,
SPL,
DIR,
}

export type PieceId = ProtectedString<'PieceId', string>
export interface Piece {
_id: PieceId
rundownId: RundownId
partId: PartId
/** Stored as markdown */
export type ScriptContents = string

/** Expected duration of the piece, in milliseconds */
expectedDuration?: number
/** TBD, something used to mark places in ScriptContents */
export type TextMarkerId = ProtectedString<'TextMarkerId', string>

/** Represents a view of the prompter, is streamed from the viewPort. This is always the last connected viewport. */
export interface ViewPort {
_id: 'viewport'

/**
* When a ViewPort starts up, it randomizes its instanceId and sends it to the Server.
* If the ViewPorts' instanceId is the "last one" it is in control.
* The ViewPort "in control" will stream its data to the server continuously.
* If a ViewPort is not "in control" it could listen to the ViewPort data and jump to the same position to stay in sync.
*/
instanceId: string

/** The width of the viewport (as percentage of viewport height) */
width: number

/** Current position of the viewport */
position: ViewPortPosition
}

/** Set by a user */
export interface PrompterSettings {
fontSize: number // in percentage of viewport height

mirrorHorizontally: boolean
mirrorVertically: boolean

focusPosition: 'start' | 'center' | 'end'
showFocusPosition: boolean

/** Adds padding between the edge of the screen and the text */
marginHorizontal: number
/** In percentage of viewport height */
marginVertical: number
}

/** Sent from the user control interface to the ViewPort */
export type ControllerMessage = {
speed: number // unit (lines per second)?
/** If set, viewport should jump to that position */
position?: ViewPortPosition
}

content: SomePieceContent
/** Defines a position of the viewport */
export interface ViewPortPosition {
/**
* The Part which the current offset is calculated from.
* `null` means "top of page"
*/
scrollOffsetTarget: SegmentId | PartId | TextMarkerId | null
/** The position of the ViewPort */
scrollOffset: number
}
type SomePieceContent = unknown // todo

0 comments on commit c2a2973

Please sign in to comment.