@xibosignage/xibo-layout-renderer 1.0.22 → 1.0.24

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.
Files changed (35) hide show
  1. package/README.md +67 -0
  2. package/dist/src/Lib/BlobLoader.d.ts +11 -0
  3. package/dist/src/Lib/index.d.ts +3 -0
  4. package/dist/src/Modules/ActionController/index.d.ts +2 -1
  5. package/dist/src/Modules/Generators/Generators.d.ts +13 -3
  6. package/dist/src/Modules/Generators/index.d.ts +1 -1
  7. package/dist/src/Modules/Layout/Layout.d.ts +5 -3
  8. package/dist/src/Modules/Layout/OverlayLayout.d.ts +3 -2
  9. package/dist/src/Modules/Media/Media.d.ts +13 -7
  10. package/dist/src/Modules/Media/VideoMedia.d.ts +14 -0
  11. package/dist/src/Modules/Region/Region.d.ts +51 -1
  12. package/dist/src/Modules/SplashScreen/index.d.ts +2 -1
  13. package/dist/src/Modules/Transitions/index.d.ts +2 -1
  14. package/dist/src/Types/Events/Events.types.d.ts +37 -0
  15. package/dist/src/Types/Events/index.d.ts +1 -0
  16. package/dist/src/Types/Layout/Layout.types.d.ts +11 -8
  17. package/dist/src/Types/Layout/index.d.ts +2 -1
  18. package/dist/src/Types/Media/Media.types.d.ts +6 -2
  19. package/dist/src/Types/Media/index.d.ts +2 -1
  20. package/dist/src/Types/Platform/Platform.types.d.ts +12 -0
  21. package/dist/src/Types/Platform/index.d.ts +1 -0
  22. package/dist/src/Types/Region/Region.types.d.ts +6 -6
  23. package/dist/src/Types/Region/index.d.ts +2 -1
  24. package/dist/src/Types/XLR/XLR.types.d.ts +3 -1
  25. package/dist/src/Types/XLR/index.d.ts +2 -1
  26. package/dist/src/types.d.ts +2 -0
  27. package/dist/xibo-layout-renderer.cjs.js +3836 -3119
  28. package/dist/xibo-layout-renderer.cjs.js.map +1 -1
  29. package/dist/xibo-layout-renderer.d.ts +167 -36
  30. package/dist/xibo-layout-renderer.esm.js +3824 -3119
  31. package/dist/xibo-layout-renderer.esm.js.map +1 -1
  32. package/dist/xibo-layout-renderer.js +3836 -3119
  33. package/dist/xibo-layout-renderer.min.js +8 -8
  34. package/dist/xibo-layout-renderer.min.js.map +1 -1
  35. 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(): Promise<void>;
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,26 @@ interface IXlr {
193
245
  }
194
246
  declare const initialXlr: IXlr;
195
247
 
196
- interface IMediaEvents {
197
- start: (media: IMedia) => void;
198
- end: (media: IMedia) => void;
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 VideoMedia(media: IMedia, xlr: IXlr): {
262
+ duration: number;
263
+ init: () => void;
264
+ stop: (disposeOnly?: boolean) => void;
265
+ play: () => void;
266
+ };
267
+
200
268
  declare class Media implements IMedia {
201
269
  attachedAudio: boolean;
202
270
  checkIframeStatus: boolean;
@@ -236,23 +304,37 @@ declare class Media implements IMedia {
236
304
  url: string | null;
237
305
  useDuration: boolean;
238
306
  xml: Element | null;
239
- private mediaTimer;
307
+ videoHandler?: IVideoMediaHandler;
308
+ mediaTimer: ReturnType<typeof setInterval> | undefined;
240
309
  private mediaTimeCount;
241
310
  private xlr;
242
311
  private readonly statsBC;
312
+ private hasCommandExecuted;
243
313
  constructor(region: IRegion, mediaId: string, xml: Element, options: OptionsType, xlr: IXlr);
244
314
  private startMediaTimer;
245
315
  private on;
246
316
  private init;
247
317
  run(): void;
248
318
  stop(): Promise<void>;
319
+ /**
320
+ * Emits a command from the shell command widget.
321
+ *
322
+ * @param media
323
+ * @private
324
+ */
325
+ private emitCommand;
249
326
  }
250
327
 
251
- type MediaState = 'idle' | 'playing' | 'ended';
328
+ declare function AudioMedia(media: IMedia): {
329
+ init(): void;
330
+ };
331
+
332
+ type MediaState = 'idle' | 'playing' | 'ended' | 'cancelled';
252
333
  declare const MediaState: {
253
334
  readonly IDLE: "idle";
254
335
  readonly PLAYING: "playing";
255
336
  readonly ENDED: "ended";
337
+ readonly CANCELLED: "cancelled";
256
338
  };
257
339
  interface IMedia {
258
340
  attachedAudio: boolean;
@@ -295,18 +377,16 @@ interface IMedia {
295
377
  url: string | null;
296
378
  useDuration: boolean;
297
379
  xml: Element | null;
380
+ videoHandler?: IVideoMediaHandler;
381
+ mediaTimer: ReturnType<typeof setInterval> | undefined;
298
382
  }
299
383
  declare const initialMedia: IMedia;
300
384
 
301
- interface IRegionEvents {
302
- start: (layout: IRegion) => void;
303
- end: (layout: IRegion) => void;
304
- }
305
385
  interface IRegion {
306
386
  complete: boolean;
307
387
  containerName: string;
308
388
  currMedia: IMedia | undefined;
309
- currEl: HTMLElement | undefined;
389
+ currEl: HTMLElement | null;
310
390
  currentMedia: number;
311
391
  currentMediaIndex: number;
312
392
  emitter?: Emitter<DefaultEvents>;
@@ -323,7 +403,7 @@ interface IRegion {
323
403
  mediaObjects: IMedia[];
324
404
  mediaObjectsActions: IMedia[];
325
405
  nxtMedia: IMedia | undefined;
326
- nxtEl: HTMLElement | undefined;
406
+ nxtEl: HTMLElement | null;
327
407
  offsetX: number;
328
408
  offsetY: number;
329
409
  oldMedia: IMedia | undefined;
@@ -347,14 +427,11 @@ interface IRegion {
347
427
  uniqueId: string;
348
428
  xml: null | Element;
349
429
  zIndex: number;
430
+ prepareNextMedia(): void;
431
+ xlr: IXlr;
350
432
  }
351
433
  declare const initialRegion: IRegion;
352
434
 
353
- interface ILayoutEvents {
354
- start: (layout: ILayout) => void;
355
- end: (layout: ILayout) => void;
356
- cancelled: (layout: ILayout) => void;
357
- }
358
435
  declare enum ELayoutState {
359
436
  IDLE = 0,
360
437
  RUNNING = 1,
@@ -362,6 +439,11 @@ declare enum ELayoutState {
362
439
  CANCELLED = 3,
363
440
  ERROR = 4
364
441
  }
442
+ declare enum LayoutPlaybackType {
443
+ CURRENT = "current",
444
+ NEXT = "next",
445
+ OVERLAY = "overlay"
446
+ }
365
447
  type InputLayoutType = {
366
448
  response: any;
367
449
  layoutId: number;
@@ -383,7 +465,7 @@ type OptionsType = {
383
465
  idCounter: number;
384
466
  inPreview: boolean;
385
467
  appHost?: string | null;
386
- platform: 'CMS' | 'chromeOS';
468
+ platform: ConsumerPlatform;
387
469
  config?: {
388
470
  cmsUrl: string | null;
389
471
  schemaVersion: number;
@@ -436,7 +518,7 @@ interface ILayout {
436
518
  on<E extends keyof ILayoutEvents>(event: E, callback: ILayoutEvents[E]): Unsubscribe;
437
519
  regionExpired(): void;
438
520
  end(): void;
439
- regionEnded(): Promise<void>;
521
+ regionEnded(): void;
440
522
  stopAllMedia(): Promise<void>;
441
523
  resetLayout(): Promise<void>;
442
524
  index: number;
@@ -445,7 +527,7 @@ interface ILayout {
445
527
  xlr: IXlr;
446
528
  finishAllRegions(): Promise<void[]>;
447
529
  inLoop: boolean;
448
- removeLayout(): void;
530
+ removeLayout(caller?: LayoutPlaybackType): void;
449
531
  xlfString: string;
450
532
  getXlf(): string;
451
533
  ad: any;
@@ -454,6 +536,7 @@ interface ILayout {
454
536
  isInterrupt(): boolean;
455
537
  state: ELayoutState;
456
538
  errorCode: number | null;
539
+ html: HTMLElement | null;
457
540
  }
458
541
  declare const initialLayout: ILayout;
459
542
  type GetLayoutParamType = {
@@ -486,7 +569,7 @@ declare function videoFileType(str: string): string | undefined;
486
569
  declare function composeResourceUrlByPlatform(options: OptionsType, params: any): string;
487
570
  declare function composeResourceUrl(options: OptionsType, params: any): string;
488
571
  declare function composeMediaUrl(params: any): string;
489
- declare function composeBgUrlByPlatform(platform: OptionsType['platform'], params: any): string;
572
+ declare function composeBgUrlByPlatform(platform: OptionsType['platform'], params: ILayout): string;
490
573
  type LayoutIndexType = {
491
574
  [k: string]: InputLayoutType & {
492
575
  index: number;
@@ -498,6 +581,9 @@ declare function getIndexByLayoutId(layoutsInput: InputLayoutType[], layoutId?:
498
581
  index: number;
499
582
  };
500
583
  declare function isEmpty(input: any): boolean;
584
+ declare function getAllAttributes(elem: Element): {
585
+ [k: string]: any;
586
+ };
501
587
  /**
502
588
  * Create expiration day based on current date
503
589
  * @param numDays Number of days as expiry
@@ -512,20 +598,65 @@ declare function setExpiry(numDays: number): string;
512
598
  * @return boolean
513
599
  */
514
600
  declare function isLayoutValid(layouts: InputLayoutType[], layoutId: number | undefined): boolean;
601
+ declare function getLayoutIndexByLayoutId(layouts: InputLayoutType[], layoutId: number): number | null;
515
602
  declare function hasDefaultOnly(inputLayouts: InputLayoutType[]): boolean;
603
+ declare function hasSspLayout(inputLayouts: InputLayoutType[], defaultValue?: boolean): boolean;
604
+ declare function createMediaElement(mediaObject: IMedia): HTMLElement;
605
+ declare function prepareVideoMedia(media: IMedia, region: IRegion): void;
606
+ declare function prepareImageMedia(media: IMedia, region: IRegion): void;
607
+ declare function prepareAudioMedia(media: IMedia, region: IRegion): void;
608
+ declare function prepareHtmlMedia(media: IMedia, region: IRegion): void;
609
+ declare function playerReportFault(msg: string, media: IMedia): Promise<void>;
516
610
 
517
- declare function composeVideoSource($media: HTMLVideoElement, media: IMedia): HTMLVideoElement;
518
- declare function VideoMedia(media: IMedia, xlr: IXlr): {
519
- duration: number;
520
- init: () => void;
521
- stop: (disposeOnly?: boolean) => void;
522
- };
523
-
524
- declare function AudioMedia(media: IMedia): {
525
- init(): void;
526
- };
527
-
528
- declare function Region(layout: ILayout, xml: Element, regionId: string, options: OptionsType, xlr: IXlr): IRegion;
611
+ declare class Region implements IRegion {
612
+ layout: ILayout;
613
+ xml: Element | null;
614
+ regionId: string;
615
+ options: OptionsType;
616
+ xlr: IXlr;
617
+ complete: boolean;
618
+ containerName: string;
619
+ currMedia: IMedia | undefined;
620
+ currEl: HTMLElement | null;
621
+ currentMedia: number;
622
+ currentMediaIndex: number;
623
+ ended: boolean;
624
+ ending: boolean;
625
+ html: HTMLDivElement;
626
+ id: string;
627
+ index: number;
628
+ mediaObjects: IMedia[];
629
+ mediaObjectsActions: IMedia[];
630
+ nxtMedia: IMedia | undefined;
631
+ nxtEl: HTMLElement | null;
632
+ offsetX: number;
633
+ offsetY: number;
634
+ oldMedia: IMedia | undefined;
635
+ oneMedia: boolean;
636
+ ready: boolean;
637
+ sHeight: number;
638
+ sWidth: number;
639
+ totalMediaObjects: number;
640
+ uniqueId: string;
641
+ zIndex: number;
642
+ emitter: nanoevents.Emitter<IRegionEvents>;
643
+ constructor(layout: ILayout, xml: Element, regionId: string, options: OptionsType, xlr: IXlr);
644
+ prepareRegion(): void;
645
+ prepareMedia(media: IMedia): void;
646
+ prepareFirstMedia(): void;
647
+ prepareNextMedia(): void;
648
+ prepareMediaObjects(): void;
649
+ finished(): void;
650
+ run(): void;
651
+ transitionNodes(oldMedia: IMedia | undefined, newMedia: IMedia | undefined): void;
652
+ playNextMedia(): void;
653
+ playPreviousMedia(): void;
654
+ end(): void;
655
+ exitTransition(): void;
656
+ exitTransitionComplete(): void;
657
+ reset(): void;
658
+ on<E extends keyof IRegionEvents>(event: E, callback: IRegionEvents[E]): nanoevents.Unsubscribe;
659
+ }
529
660
 
530
661
  interface ISplashScreen {
531
662
  init: () => void;
@@ -628,4 +759,4 @@ type flyTransitionParams = {
628
759
  };
629
760
  declare const flyTransitionKeyframes: (params: flyTransitionParams) => KeyframeOptionsType;
630
761
 
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 };
762
+ 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, getAllAttributes, getDataBlob, getFileExt, getIndexByLayoutId, getLayout, getLayoutIndexByLayoutId, getMediaId, getXlf, hasDefaultOnly, hasSspLayout, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, isEmpty, isLayoutValid, nextId, playerReportFault, preloadMediaBlob, prepareAudioMedia, prepareHtmlMedia, prepareImageMedia, prepareVideoMedia, setExpiry, transitionElement, videoFileType, vjsDefaultOptions };