@xibosignage/xibo-layout-renderer 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/src/Lib/BlobLoader.d.ts +11 -0
- package/dist/src/Lib/index.d.ts +3 -0
- package/dist/src/Modules/ActionController/index.d.ts +2 -1
- package/dist/src/Modules/Generators/Generators.d.ts +11 -1
- package/dist/src/Modules/Generators/index.d.ts +2 -1
- package/dist/src/Modules/Layout/Layout.d.ts +5 -3
- package/dist/src/Modules/Layout/OverlayLayout.d.ts +3 -2
- package/dist/src/Modules/Media/Media.d.ts +13 -7
- package/dist/src/Modules/Media/VideoMedia.d.ts +16 -1
- package/dist/src/Modules/Region/Region.d.ts +54 -1
- package/dist/src/Modules/SplashScreen/index.d.ts +2 -1
- package/dist/src/Modules/Transitions/index.d.ts +2 -1
- package/dist/src/Types/Events/Events.types.d.ts +37 -0
- package/dist/src/Types/Events/index.d.ts +1 -0
- package/dist/src/Types/Layout/Layout.types.d.ts +11 -8
- package/dist/src/Types/Layout/index.d.ts +2 -1
- package/dist/src/Types/Media/Media.types.d.ts +6 -2
- package/dist/src/Types/Media/index.d.ts +2 -1
- package/dist/src/Types/Platform/Platform.types.d.ts +12 -0
- package/dist/src/Types/Platform/index.d.ts +1 -0
- package/dist/src/Types/Region/Region.types.d.ts +6 -6
- package/dist/src/Types/Region/index.d.ts +2 -1
- package/dist/src/Types/XLR/XLR.types.d.ts +3 -1
- package/dist/src/Types/XLR/index.d.ts +2 -1
- package/dist/src/types.d.ts +2 -0
- package/dist/xibo-layout-renderer.cjs.js +10063 -9117
- package/dist/xibo-layout-renderer.cjs.js.map +1 -1
- package/dist/xibo-layout-renderer.d.ts +160 -35
- package/dist/xibo-layout-renderer.esm.js +10058 -9117
- package/dist/xibo-layout-renderer.esm.js.map +1 -1
- package/dist/xibo-layout-renderer.js +10063 -9117
- package/dist/xibo-layout-renderer.min.js +8 -8
- package/dist/xibo-layout-renderer.min.js.map +1 -1
- package/package.json +5 -3
|
@@ -2,6 +2,55 @@ import * as nanoevents from 'nanoevents';
|
|
|
2
2
|
import { Emitter, Unsubscribe, DefaultEvents } from 'nanoevents';
|
|
3
3
|
import Player from 'video.js/dist/types/player';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Centralized event type definitions
|
|
7
|
+
* All module events should be defined here
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Events emitted by Layout
|
|
12
|
+
*/
|
|
13
|
+
interface ILayoutEvents {
|
|
14
|
+
start: (layout: ILayout) => void;
|
|
15
|
+
end: (layout: ILayout) => void;
|
|
16
|
+
cancelled: (layout: ILayout) => void;
|
|
17
|
+
layoutStart?: (layout: ILayout) => void;
|
|
18
|
+
layoutEnd?: (layout: ILayout) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Events emitted by Region
|
|
22
|
+
*/
|
|
23
|
+
interface IRegionEvents {
|
|
24
|
+
start: (region: IRegion) => void;
|
|
25
|
+
end: (region: IRegion) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Events emitted by Media
|
|
29
|
+
*/
|
|
30
|
+
interface IMediaEvents {
|
|
31
|
+
start: (media: IMedia) => void;
|
|
32
|
+
end: (media: IMedia) => void;
|
|
33
|
+
cancelled: (media: IMedia) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type alias for event unsubscriber
|
|
37
|
+
*/
|
|
38
|
+
type EventUnsubscriber = () => void;
|
|
39
|
+
type EventEmitter<T> = <K extends keyof T>(event: K, ...args: Parameters<T[K] extends (...args: any[]) => any ? T[K] : never>) => void;
|
|
40
|
+
|
|
41
|
+
declare enum ConsumerPlatform {
|
|
42
|
+
CMS = "CMS",
|
|
43
|
+
CHROMEOS = "chromeOS",
|
|
44
|
+
ELECTRON = "electron",
|
|
45
|
+
IOS = "ios",
|
|
46
|
+
MACOS = "macos",
|
|
47
|
+
ANDROID = "android",
|
|
48
|
+
LINUX = "linux",
|
|
49
|
+
WINDOWS = "windows",
|
|
50
|
+
WEBOS = "webos",
|
|
51
|
+
TIZEN = "tizen"
|
|
52
|
+
}
|
|
53
|
+
|
|
5
54
|
declare class Action {
|
|
6
55
|
readonly id: string;
|
|
7
56
|
readonly xml: Element;
|
|
@@ -83,6 +132,7 @@ declare class Layout implements ILayout {
|
|
|
83
132
|
layoutNode?: Document;
|
|
84
133
|
path?: string;
|
|
85
134
|
errorCode: number | null;
|
|
135
|
+
html: HTMLElement | null;
|
|
86
136
|
options: OptionsType;
|
|
87
137
|
xlr: IXlr;
|
|
88
138
|
private readonly layoutObj;
|
|
@@ -94,11 +144,11 @@ declare class Layout implements ILayout {
|
|
|
94
144
|
playRegions(): void;
|
|
95
145
|
regionExpired(): void;
|
|
96
146
|
end(): void;
|
|
97
|
-
regionEnded():
|
|
147
|
+
regionEnded(): void;
|
|
98
148
|
stopAllMedia(): Promise<void>;
|
|
99
149
|
resetLayout(): Promise<void>;
|
|
100
150
|
finishAllRegions(): Promise<void[]>;
|
|
101
|
-
removeLayout(): void;
|
|
151
|
+
removeLayout(caller?: LayoutPlaybackType): void;
|
|
102
152
|
getXlf(): string;
|
|
103
153
|
isInterrupt(): boolean;
|
|
104
154
|
on<E extends keyof ILayoutEvents>(event: E, callback: ILayoutEvents[E]): nanoevents.Unsubscribe;
|
|
@@ -144,6 +194,8 @@ type IXlrEvents = {
|
|
|
144
194
|
updateOverlays: (overlays: InputLayoutType[]) => void;
|
|
145
195
|
overlayStart: (overlay: ILayout) => void;
|
|
146
196
|
overlayEnd: (overlay: ILayout) => void;
|
|
197
|
+
commandCodeReceived: (commandCode: string) => void;
|
|
198
|
+
commandStringReceived: (commandString: string) => void;
|
|
147
199
|
};
|
|
148
200
|
interface IXlrPlayback {
|
|
149
201
|
currentLayout: ILayout | undefined;
|
|
@@ -179,7 +231,7 @@ interface IXlr {
|
|
|
179
231
|
overlays: InputLayoutType[];
|
|
180
232
|
parseLayouts(loopUpdate?: boolean): IXlrPlayback;
|
|
181
233
|
playLayouts(xlr: IXlr): void;
|
|
182
|
-
playSchedules(xlr: IXlr): void
|
|
234
|
+
playSchedules(xlr: IXlr): Promise<void>;
|
|
183
235
|
prepareForSsp(nextLayout: ILayout): Promise<ILayout>;
|
|
184
236
|
prepareLayoutXlf(inputLayout: ILayout | undefined): Promise<ILayout>;
|
|
185
237
|
prepareLayouts(): Promise<IXlr>;
|
|
@@ -193,10 +245,27 @@ interface IXlr {
|
|
|
193
245
|
}
|
|
194
246
|
declare const initialXlr: IXlr;
|
|
195
247
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
248
|
+
declare function composeVideoSource($media: HTMLVideoElement, media: IMedia): HTMLVideoElement;
|
|
249
|
+
declare const defaultVjsOpts: {
|
|
250
|
+
autoplay: boolean;
|
|
251
|
+
muted: boolean;
|
|
252
|
+
preload: string;
|
|
253
|
+
controls: boolean;
|
|
254
|
+
};
|
|
255
|
+
declare const vjsDefaultOptions: (opts?: any) => any;
|
|
256
|
+
interface IVideoMediaHandler {
|
|
257
|
+
player: Player | undefined;
|
|
258
|
+
duration: number;
|
|
259
|
+
stop(disposeOnly?: boolean): void;
|
|
199
260
|
}
|
|
261
|
+
declare function videoMediaHandler(media: IMedia, platform: OptionsType['platform']): IVideoMediaHandler;
|
|
262
|
+
declare function VideoMedia(media: IMedia, xlr: IXlr): {
|
|
263
|
+
duration: number;
|
|
264
|
+
init: () => void;
|
|
265
|
+
stop: (disposeOnly?: boolean) => void;
|
|
266
|
+
play: () => void;
|
|
267
|
+
};
|
|
268
|
+
|
|
200
269
|
declare class Media implements IMedia {
|
|
201
270
|
attachedAudio: boolean;
|
|
202
271
|
checkIframeStatus: boolean;
|
|
@@ -236,23 +305,37 @@ declare class Media implements IMedia {
|
|
|
236
305
|
url: string | null;
|
|
237
306
|
useDuration: boolean;
|
|
238
307
|
xml: Element | null;
|
|
239
|
-
|
|
308
|
+
videoHandler?: IVideoMediaHandler;
|
|
309
|
+
mediaTimer: ReturnType<typeof setInterval> | undefined;
|
|
240
310
|
private mediaTimeCount;
|
|
241
311
|
private xlr;
|
|
242
312
|
private readonly statsBC;
|
|
313
|
+
private hasCommandExecuted;
|
|
243
314
|
constructor(region: IRegion, mediaId: string, xml: Element, options: OptionsType, xlr: IXlr);
|
|
244
315
|
private startMediaTimer;
|
|
245
316
|
private on;
|
|
246
317
|
private init;
|
|
247
318
|
run(): void;
|
|
248
319
|
stop(): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Emits a command from the shell command widget.
|
|
322
|
+
*
|
|
323
|
+
* @param media
|
|
324
|
+
* @private
|
|
325
|
+
*/
|
|
326
|
+
private emitCommand;
|
|
249
327
|
}
|
|
250
328
|
|
|
251
|
-
|
|
329
|
+
declare function AudioMedia(media: IMedia): {
|
|
330
|
+
init(): void;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
type MediaState = 'idle' | 'playing' | 'ended' | 'cancelled';
|
|
252
334
|
declare const MediaState: {
|
|
253
335
|
readonly IDLE: "idle";
|
|
254
336
|
readonly PLAYING: "playing";
|
|
255
337
|
readonly ENDED: "ended";
|
|
338
|
+
readonly CANCELLED: "cancelled";
|
|
256
339
|
};
|
|
257
340
|
interface IMedia {
|
|
258
341
|
attachedAudio: boolean;
|
|
@@ -295,18 +378,16 @@ interface IMedia {
|
|
|
295
378
|
url: string | null;
|
|
296
379
|
useDuration: boolean;
|
|
297
380
|
xml: Element | null;
|
|
381
|
+
videoHandler?: IVideoMediaHandler;
|
|
382
|
+
mediaTimer: ReturnType<typeof setInterval> | undefined;
|
|
298
383
|
}
|
|
299
384
|
declare const initialMedia: IMedia;
|
|
300
385
|
|
|
301
|
-
interface IRegionEvents {
|
|
302
|
-
start: (layout: IRegion) => void;
|
|
303
|
-
end: (layout: IRegion) => void;
|
|
304
|
-
}
|
|
305
386
|
interface IRegion {
|
|
306
387
|
complete: boolean;
|
|
307
388
|
containerName: string;
|
|
308
389
|
currMedia: IMedia | undefined;
|
|
309
|
-
currEl: HTMLElement |
|
|
390
|
+
currEl: HTMLElement | null;
|
|
310
391
|
currentMedia: number;
|
|
311
392
|
currentMediaIndex: number;
|
|
312
393
|
emitter?: Emitter<DefaultEvents>;
|
|
@@ -323,7 +404,7 @@ interface IRegion {
|
|
|
323
404
|
mediaObjects: IMedia[];
|
|
324
405
|
mediaObjectsActions: IMedia[];
|
|
325
406
|
nxtMedia: IMedia | undefined;
|
|
326
|
-
nxtEl: HTMLElement |
|
|
407
|
+
nxtEl: HTMLElement | null;
|
|
327
408
|
offsetX: number;
|
|
328
409
|
offsetY: number;
|
|
329
410
|
oldMedia: IMedia | undefined;
|
|
@@ -347,14 +428,11 @@ interface IRegion {
|
|
|
347
428
|
uniqueId: string;
|
|
348
429
|
xml: null | Element;
|
|
349
430
|
zIndex: number;
|
|
431
|
+
prepareNextMedia(): void;
|
|
432
|
+
xlr: IXlr;
|
|
350
433
|
}
|
|
351
434
|
declare const initialRegion: IRegion;
|
|
352
435
|
|
|
353
|
-
interface ILayoutEvents {
|
|
354
|
-
start: (layout: ILayout) => void;
|
|
355
|
-
end: (layout: ILayout) => void;
|
|
356
|
-
cancelled: (layout: ILayout) => void;
|
|
357
|
-
}
|
|
358
436
|
declare enum ELayoutState {
|
|
359
437
|
IDLE = 0,
|
|
360
438
|
RUNNING = 1,
|
|
@@ -362,6 +440,11 @@ declare enum ELayoutState {
|
|
|
362
440
|
CANCELLED = 3,
|
|
363
441
|
ERROR = 4
|
|
364
442
|
}
|
|
443
|
+
declare enum LayoutPlaybackType {
|
|
444
|
+
CURRENT = "current",
|
|
445
|
+
NEXT = "next",
|
|
446
|
+
OVERLAY = "overlay"
|
|
447
|
+
}
|
|
365
448
|
type InputLayoutType = {
|
|
366
449
|
response: any;
|
|
367
450
|
layoutId: number;
|
|
@@ -383,7 +466,7 @@ type OptionsType = {
|
|
|
383
466
|
idCounter: number;
|
|
384
467
|
inPreview: boolean;
|
|
385
468
|
appHost?: string | null;
|
|
386
|
-
platform:
|
|
469
|
+
platform: ConsumerPlatform;
|
|
387
470
|
config?: {
|
|
388
471
|
cmsUrl: string | null;
|
|
389
472
|
schemaVersion: number;
|
|
@@ -436,7 +519,7 @@ interface ILayout {
|
|
|
436
519
|
on<E extends keyof ILayoutEvents>(event: E, callback: ILayoutEvents[E]): Unsubscribe;
|
|
437
520
|
regionExpired(): void;
|
|
438
521
|
end(): void;
|
|
439
|
-
regionEnded():
|
|
522
|
+
regionEnded(): void;
|
|
440
523
|
stopAllMedia(): Promise<void>;
|
|
441
524
|
resetLayout(): Promise<void>;
|
|
442
525
|
index: number;
|
|
@@ -445,7 +528,7 @@ interface ILayout {
|
|
|
445
528
|
xlr: IXlr;
|
|
446
529
|
finishAllRegions(): Promise<void[]>;
|
|
447
530
|
inLoop: boolean;
|
|
448
|
-
removeLayout(): void;
|
|
531
|
+
removeLayout(caller?: LayoutPlaybackType): void;
|
|
449
532
|
xlfString: string;
|
|
450
533
|
getXlf(): string;
|
|
451
534
|
ad: any;
|
|
@@ -454,6 +537,7 @@ interface ILayout {
|
|
|
454
537
|
isInterrupt(): boolean;
|
|
455
538
|
state: ELayoutState;
|
|
456
539
|
errorCode: number | null;
|
|
540
|
+
html: HTMLElement | null;
|
|
457
541
|
}
|
|
458
542
|
declare const initialLayout: ILayout;
|
|
459
543
|
type GetLayoutParamType = {
|
|
@@ -513,19 +597,60 @@ declare function setExpiry(numDays: number): string;
|
|
|
513
597
|
*/
|
|
514
598
|
declare function isLayoutValid(layouts: InputLayoutType[], layoutId: number | undefined): boolean;
|
|
515
599
|
declare function hasDefaultOnly(inputLayouts: InputLayoutType[]): boolean;
|
|
600
|
+
declare function createMediaElement(mediaObject: IMedia): HTMLElement;
|
|
516
601
|
|
|
517
|
-
declare
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
602
|
+
declare class Region implements IRegion {
|
|
603
|
+
layout: ILayout;
|
|
604
|
+
xml: Element | null;
|
|
605
|
+
regionId: string;
|
|
606
|
+
options: OptionsType;
|
|
607
|
+
xlr: IXlr;
|
|
608
|
+
complete: boolean;
|
|
609
|
+
containerName: string;
|
|
610
|
+
currMedia: IMedia | undefined;
|
|
611
|
+
currEl: HTMLElement | null;
|
|
612
|
+
currentMedia: number;
|
|
613
|
+
currentMediaIndex: number;
|
|
614
|
+
ended: boolean;
|
|
615
|
+
ending: boolean;
|
|
616
|
+
html: HTMLDivElement;
|
|
617
|
+
id: string;
|
|
618
|
+
index: number;
|
|
619
|
+
mediaObjects: IMedia[];
|
|
620
|
+
mediaObjectsActions: IMedia[];
|
|
621
|
+
nxtMedia: IMedia | undefined;
|
|
622
|
+
nxtEl: HTMLElement | null;
|
|
623
|
+
offsetX: number;
|
|
624
|
+
offsetY: number;
|
|
625
|
+
oldMedia: IMedia | undefined;
|
|
626
|
+
oneMedia: boolean;
|
|
627
|
+
ready: boolean;
|
|
628
|
+
sHeight: number;
|
|
629
|
+
sWidth: number;
|
|
630
|
+
totalMediaObjects: number;
|
|
631
|
+
uniqueId: string;
|
|
632
|
+
zIndex: number;
|
|
633
|
+
emitter: nanoevents.Emitter<IRegionEvents>;
|
|
634
|
+
constructor(layout: ILayout, xml: Element, regionId: string, options: OptionsType, xlr: IXlr);
|
|
635
|
+
prepareRegion(): void;
|
|
636
|
+
prepareMedia(media: IMedia): void;
|
|
637
|
+
prepareFirstMedia(): void;
|
|
638
|
+
prepareNextMedia(): void;
|
|
639
|
+
prepareMediaObjects(): void;
|
|
640
|
+
finished(): void;
|
|
641
|
+
private prepareVideo;
|
|
642
|
+
private prepareImage;
|
|
643
|
+
private prepareIframe;
|
|
644
|
+
run(): void;
|
|
645
|
+
transitionNodes(oldMedia: IMedia | undefined, newMedia: IMedia | undefined): void;
|
|
646
|
+
playNextMedia(): void;
|
|
647
|
+
playPreviousMedia(): void;
|
|
648
|
+
end(): void;
|
|
649
|
+
exitTransition(): void;
|
|
650
|
+
exitTransitionComplete(): void;
|
|
651
|
+
reset(): void;
|
|
652
|
+
on<E extends keyof IRegionEvents>(event: E, callback: IRegionEvents[E]): nanoevents.Unsubscribe;
|
|
653
|
+
}
|
|
529
654
|
|
|
530
655
|
interface ISplashScreen {
|
|
531
656
|
init: () => void;
|
|
@@ -628,4 +753,4 @@ type flyTransitionParams = {
|
|
|
628
753
|
};
|
|
629
754
|
declare const flyTransitionKeyframes: (params: flyTransitionParams) => KeyframeOptionsType;
|
|
630
755
|
|
|
631
|
-
export { Action, ActionsWrapper, AudioMedia, ELayoutState, ELayoutType, type GetLayoutParamType, type GetLayoutType, type ILayout, type ILayoutEvents, type IMedia, type IMediaEvents, type IRegion, type IRegionEvents, type ISplashScreen, type IXlr, type IXlrEvents, type IXlrPlayback, type InactOptions, type InputLayoutType, type KeyframeOptionsType, Media, type MediaTypes, type OptionsType, type PrepareLayoutsType, type PreviewSplashElement, Region, type TransitionElementOptions, type TransitionNameType, VideoMedia, audioFileType, capitalizeStr, type compassPoints, composeBgUrlByPlatform, composeMediaUrl, composeResourceUrl, composeResourceUrlByPlatform, composeVideoSource, XiboLayoutRenderer as default, defaultTrans, fadeInElem, fadeOutElem, fetchJSON, fetchText, flyInElem, flyOutElem, flyTransitionKeyframes, type flyTransitionParams, getDataBlob, getFileExt, getIndexByLayoutId, getLayout, getMediaId, getXlf, hasDefaultOnly, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, isEmpty, isLayoutValid, nextId, preloadMediaBlob, setExpiry, transitionElement, videoFileType };
|
|
756
|
+
export { Action, ActionsWrapper, AudioMedia, ConsumerPlatform, ELayoutState, ELayoutType, type EventEmitter, type EventUnsubscriber, type GetLayoutParamType, type GetLayoutType, type ILayout, type ILayoutEvents, type IMedia, type IMediaEvents, type IRegion, type IRegionEvents, type ISplashScreen, type IVideoMediaHandler, type IXlr, type IXlrEvents, type IXlrPlayback, type InactOptions, type InputLayoutType, type KeyframeOptionsType, LayoutPlaybackType, Media, MediaState, type MediaTypes, type OptionsType, type PrepareLayoutsType, type PreviewSplashElement, Region, type TransitionElementOptions, type TransitionNameType, VideoMedia, audioFileType, capitalizeStr, type compassPoints, composeBgUrlByPlatform, composeMediaUrl, composeResourceUrl, composeResourceUrlByPlatform, composeVideoSource, createMediaElement, XiboLayoutRenderer as default, defaultTrans, defaultVjsOpts, fadeInElem, fadeOutElem, fetchJSON, fetchText, flyInElem, flyOutElem, flyTransitionKeyframes, type flyTransitionParams, getDataBlob, getFileExt, getIndexByLayoutId, getLayout, getMediaId, getXlf, hasDefaultOnly, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, isEmpty, isLayoutValid, nextId, preloadMediaBlob, setExpiry, transitionElement, videoFileType, videoMediaHandler, vjsDefaultOptions };
|