1- import { SplitsContentBoxContent , SplitsContentBoxProperties } from './content.js'
1+ /**
2+ * This file defines the types for content previews that can be returned from blueprints.
3+ */
4+ import { 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
853 warnings ?: InvalidPreview [ ]
54+ /**
55+ * Add custom content preview content
56+ */
57+ additionalPreviewContent ?: Array < PreviewContent >
958}
1059export type Previews = TablePreview | ScriptPreview | HTMLPreview | SplitPreview | VTPreview | BlueprintImagePreview
1160
@@ -19,22 +68,99 @@ export enum PreviewType {
1968 BlueprintImage = 'blueprintImage' ,
2069}
2170
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+ */
78+ export type PreviewContent =
79+ | {
80+ /** Embed an iframe with optional postMessage communication */
81+ type : 'iframe'
82+ href : string
83+ postMessage ?: any
84+ dimensions ?: { width : number ; height : number }
85+ }
86+ | {
87+ /** Display an image */
88+ type : 'image'
89+ src : string
90+ }
91+ | {
92+ /** Display a video player */
93+ type : 'video'
94+ src : string
95+ }
96+ | {
97+ /** Show script content with timing words and metadata */
98+ type : 'script'
99+ script ?: string
100+ firstWords ?: string
101+ lastWords ?: string
102+ comment ?: string
103+ lastModified ?: number
104+ }
105+ | {
106+ /** Display a title heading */
107+ type : 'title'
108+ content : string
109+ }
110+ | {
111+ /** Show in/out timing words */
112+ type : 'inOutWords'
113+ in ?: string
114+ out : string
115+ }
116+ | {
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+ */
123+ type : 'layerInfo'
124+ layerType : SourceLayerType
125+ text : Array < string >
126+ inTime ?: number | string
127+ outTime ?: number | string
128+ duration ?: number | string
129+ }
130+ | {
131+ /** Add a visual separator line */
132+ type : 'separationLine'
133+ }
134+ | {
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+ */
139+ type : 'data'
140+ content : { key : string ; value : string } [ ]
141+ }
142+
22143interface PreviewBase {
23144 type : PreviewType
24145}
25146
147+ /** Indicates an invalid preview with a severity level and reason */
26148export interface InvalidPreview extends PreviewBase {
27149 type : PreviewType . Invalid
28150
29151 severity : NoteSeverity
30152 reason : ITranslatableMessage
31153}
154+
155+ /** Display a table of key-value pairs, optionally with timing information */
32156export interface TablePreview extends PreviewBase {
33157 type : PreviewType . Table
34158
35159 entries : { key : string ; value : string } [ ]
36160 displayTiming : boolean
37161}
162+
163+ /** Show script text with last words, comments, and last modified time */
38164export interface ScriptPreview extends PreviewBase {
39165 type : PreviewType . Script
40166
@@ -43,6 +169,8 @@ export interface ScriptPreview extends PreviewBase {
43169 comment ?: string
44170 lastModified ?: number
45171}
172+
173+ /** Embed a custom HTML preview via URL, with optional steps and dimensions */
46174export interface HTMLPreview extends PreviewBase {
47175 // todo - expose if and how steps can be controlled
48176 type : PreviewType . HTML
@@ -56,12 +184,16 @@ export interface HTMLPreview extends PreviewBase {
56184
57185 steps ?: { current : number ; total : number }
58186}
187+
188+ /** Show a split screen with multiple content boxes (e.g. for multi-camera or multi-source content) */
59189export interface SplitPreview extends PreviewBase {
60190 type : PreviewType . Split
61191
62192 background ?: string // file asset upload?
63193 boxes : ( SplitsContentBoxContent & SplitsContentBoxProperties ) [ ]
64194}
195+
196+ /** Video Tape preview with in/out words for timing */
65197export interface VTPreview extends PreviewBase {
66198 type : PreviewType . VT
67199
@@ -71,6 +203,8 @@ export interface VTPreview extends PreviewBase {
71203 inWords ?: string // note - only displayed if outWords are present
72204 outWords ?: string
73205}
206+
207+ /** Show an image asset as a preview */
74208export interface BlueprintImagePreview extends PreviewBase {
75209 type : PreviewType . BlueprintImage
76210
0 commit comments