1+ /**
2+ * This file defines the types for content previews that can be returned from blueprints.
3+ */
14import { SourceLayerType , SplitsContentBoxContent , SplitsContentBoxProperties } from './content.js'
25import { NoteSeverity } from './lib.js'
36import { ITranslatableMessage } from './translations.js'
47
8+ /**
9+ * Optional container for preview content with optional warnings and additional content.
10+ * If not added to a piece, the core will use the default preview handling.
11+ *
12+ * @example
13+ * ```ts
14+ * import { TablePreview, PreviewType } from 'blueprints-integration';
15+ * const preview: TablePreview = {
16+ * type: PreviewType.Table,
17+ * entries: [ { key: 'Title', value: 'My Piece' } ],
18+ * displayTiming: true,
19+ * // the additionalPreviewContent can contain any number of content items of various types
20+ * additionalPreviewContent: [
21+ * {
22+ * type: 'script',
23+ * script: 'console.log("Hello World")',
24+ * },
25+ * { type: 'separationLine' },
26+ * {
27+ * type: 'layerInfo',
28+ * layerType: SourceLayerType.Graphics,
29+ * text: ['Breaking News: Something happened!'],
30+ * inTime: 0,
31+ * duration: 5000
32+ * },
33+ * {
34+ * type: 'layerInfo',
35+ * layerType: SourceLayerType.Graphics,
36+ * text: ['Person Name - Title'],
37+ * inTime: 1000,
38+ * duration: 3000
39+ * },
40+ * { type: 'separationLine' },
41+ * {
42+ * type: 'iframe',
43+ * href: 'https://example.com/preview', // Could be an external URL or a local server serving live preview content
44+ * }
45+ * ]
46+ * };
47+ * return { preview };
48+ * ```
49+ */
550export interface PopupPreview < P extends Previews = Previews > {
651 name ?: string
752 preview ?: P
@@ -23,23 +68,33 @@ export enum PreviewType {
2368 BlueprintImage = 'blueprintImage' ,
2469}
2570
26- // The PreviewContent types are a partly replica of the types in PreviewPopUpContext.tsx
71+ /**
72+ * Additional preview content that can be added to a PopupPreview.
73+ * Supports various content types: iframe, image, video, script, title, inOutWords, layerInfo, separationLine, and data.
74+ * The purpose of this is to allow blueprints to provide extra preview content for pieces, e.g. showing script text,
75+ * Lower3rd GFX information, images, an iFrame with a live preview or other relevant information.
76+ * These preview content types are the same that are used in thedefault PreviewPopUp component in the web UI.
77+ */
2778export type PreviewContent =
2879 | {
80+ /** Embed an iframe with optional postMessage communication */
2981 type : 'iframe'
3082 href : string
3183 postMessage ?: any
3284 dimensions ?: { width : number ; height : number }
3385 }
3486 | {
87+ /** Display an image */
3588 type : 'image'
3689 src : string
3790 }
3891 | {
92+ /** Display a video player */
3993 type : 'video'
4094 src : string
4195 }
4296 | {
97+ /** Show script content with timing words and metadata */
4398 type : 'script'
4499 script ?: string
45100 firstWords ?: string
@@ -48,15 +103,23 @@ export type PreviewContent =
48103 lastModified ?: number
49104 }
50105 | {
106+ /** Display a title heading */
51107 type : 'title'
52108 content : string
53109 }
54110 | {
111+ /** Show in/out timing words */
55112 type : 'inOutWords'
56113 in ?: string
57114 out : string
58115 }
59116 | {
117+ /** Display layer information with timing
118+ * Used for showing information about a specific source layer, such as graphics or lower thirds.
119+ * The inTime, outTime, and duration is for information only and can be specified as
120+ * numbers (milliseconds) or strings (e.g. "00:00:05:00" for 5 seconds).
121+ * They are optional, and if not specified, the layer info is shown without timing.
122+ */
60123 type : 'layerInfo'
61124 layerType : SourceLayerType
62125 text : Array < string >
@@ -65,9 +128,14 @@ export type PreviewContent =
65128 duration ?: number | string
66129 }
67130 | {
131+ /** Add a visual separator line */
68132 type : 'separationLine'
69133 }
70134 | {
135+ /** Display key-value data pairs
136+ * this is a basic data preview where the key is the Label and the value is the value
137+ * the layerInfo should preferably be used for layer specific information and color
138+ */
71139 type : 'data'
72140 content : { key : string ; value : string } [ ]
73141 }
@@ -76,18 +144,23 @@ interface PreviewBase {
76144 type : PreviewType
77145}
78146
147+ /** Indicates an invalid preview with a severity level and reason */
79148export interface InvalidPreview extends PreviewBase {
80149 type : PreviewType . Invalid
81150
82151 severity : NoteSeverity
83152 reason : ITranslatableMessage
84153}
154+
155+ /** Display a table of key-value pairs, optionally with timing information */
85156export interface TablePreview extends PreviewBase {
86157 type : PreviewType . Table
87158
88159 entries : { key : string ; value : string } [ ]
89160 displayTiming : boolean
90161}
162+
163+ /** Show script text with last words, comments, and last modified time */
91164export interface ScriptPreview extends PreviewBase {
92165 type : PreviewType . Script
93166
@@ -96,6 +169,8 @@ export interface ScriptPreview extends PreviewBase {
96169 comment ?: string
97170 lastModified ?: number
98171}
172+
173+ /** Embed a custom HTML preview via URL, with optional steps and dimensions */
99174export interface HTMLPreview extends PreviewBase {
100175 // todo - expose if and how steps can be controlled
101176 type : PreviewType . HTML
@@ -109,12 +184,16 @@ export interface HTMLPreview extends PreviewBase {
109184
110185 steps ?: { current : number ; total : number }
111186}
187+
188+ /** Show a split screen with multiple content boxes (e.g. for multi-camera or multi-source content) */
112189export interface SplitPreview extends PreviewBase {
113190 type : PreviewType . Split
114191
115192 background ?: string // file asset upload?
116193 boxes : ( SplitsContentBoxContent & SplitsContentBoxProperties ) [ ]
117194}
195+
196+ /** Video Tape preview with in/out words for timing */
118197export interface VTPreview extends PreviewBase {
119198 type : PreviewType . VT
120199
@@ -124,6 +203,8 @@ export interface VTPreview extends PreviewBase {
124203 inWords ?: string // note - only displayed if outWords are present
125204 outWords ?: string
126205}
206+
207+ /** Show an image asset as a preview */
127208export interface BlueprintImagePreview extends PreviewBase {
128209 type : PreviewType . BlueprintImage
129210
0 commit comments