@xibosignage/xibo-layout-renderer 1.0.21 → 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.
Files changed (38) 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 +15 -5
  6. package/dist/src/Modules/Generators/index.d.ts +2 -1
  7. package/dist/src/Modules/Layout/Layout.d.ts +6 -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 +16 -1
  11. package/dist/src/Modules/Region/Region.d.ts +54 -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 +15 -10
  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/index.d.ts +0 -1
  27. package/dist/src/types.d.ts +2 -0
  28. package/dist/xibo-layout-renderer.cjs.js +6216 -5253
  29. package/dist/xibo-layout-renderer.cjs.js.map +1 -1
  30. package/dist/xibo-layout-renderer.d.ts +169 -43
  31. package/dist/xibo-layout-renderer.esm.js +6211 -5252
  32. package/dist/xibo-layout-renderer.esm.js.map +1 -1
  33. package/dist/xibo-layout-renderer.js +6216 -5253
  34. package/dist/xibo-layout-renderer.min.js +8 -8
  35. package/dist/xibo-layout-renderer.min.js.map +1 -1
  36. package/package.json +5 -3
  37. package/dist/src/Modules/Platform/Platform.d.ts +0 -2
  38. package/dist/src/Modules/Platform/index.d.ts +0 -1
@@ -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;
@@ -82,6 +131,8 @@ declare class Layout implements ILayout {
82
131
  scheduleId?: number;
83
132
  layoutNode?: Document;
84
133
  path?: string;
134
+ errorCode: number | null;
135
+ html: HTMLElement | null;
85
136
  options: OptionsType;
86
137
  xlr: IXlr;
87
138
  private readonly layoutObj;
@@ -93,11 +144,11 @@ declare class Layout implements ILayout {
93
144
  playRegions(): void;
94
145
  regionExpired(): void;
95
146
  end(): void;
96
- regionEnded(): Promise<void>;
147
+ regionEnded(): void;
97
148
  stopAllMedia(): Promise<void>;
98
149
  resetLayout(): Promise<void>;
99
150
  finishAllRegions(): Promise<void[]>;
100
- removeLayout(): void;
151
+ removeLayout(caller?: LayoutPlaybackType): void;
101
152
  getXlf(): string;
102
153
  isInterrupt(): boolean;
103
154
  on<E extends keyof ILayoutEvents>(event: E, callback: ILayoutEvents[E]): nanoevents.Unsubscribe;
@@ -143,6 +194,8 @@ type IXlrEvents = {
143
194
  updateOverlays: (overlays: InputLayoutType[]) => void;
144
195
  overlayStart: (overlay: ILayout) => void;
145
196
  overlayEnd: (overlay: ILayout) => void;
197
+ commandCodeReceived: (commandCode: string) => void;
198
+ commandStringReceived: (commandString: string) => void;
146
199
  };
147
200
  interface IXlrPlayback {
148
201
  currentLayout: ILayout | undefined;
@@ -178,7 +231,7 @@ interface IXlr {
178
231
  overlays: InputLayoutType[];
179
232
  parseLayouts(loopUpdate?: boolean): IXlrPlayback;
180
233
  playLayouts(xlr: IXlr): void;
181
- playSchedules(xlr: IXlr): void;
234
+ playSchedules(xlr: IXlr): Promise<void>;
182
235
  prepareForSsp(nextLayout: ILayout): Promise<ILayout>;
183
236
  prepareLayoutXlf(inputLayout: ILayout | undefined): Promise<ILayout>;
184
237
  prepareLayouts(): Promise<IXlr>;
@@ -192,10 +245,27 @@ interface IXlr {
192
245
  }
193
246
  declare const initialXlr: IXlr;
194
247
 
195
- interface IMediaEvents {
196
- start: (media: IMedia) => void;
197
- 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;
198
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
+
199
269
  declare class Media implements IMedia {
200
270
  attachedAudio: boolean;
201
271
  checkIframeStatus: boolean;
@@ -235,23 +305,37 @@ declare class Media implements IMedia {
235
305
  url: string | null;
236
306
  useDuration: boolean;
237
307
  xml: Element | null;
238
- private mediaTimer;
308
+ videoHandler?: IVideoMediaHandler;
309
+ mediaTimer: ReturnType<typeof setInterval> | undefined;
239
310
  private mediaTimeCount;
240
311
  private xlr;
241
312
  private readonly statsBC;
313
+ private hasCommandExecuted;
242
314
  constructor(region: IRegion, mediaId: string, xml: Element, options: OptionsType, xlr: IXlr);
243
315
  private startMediaTimer;
244
316
  private on;
245
317
  private init;
246
318
  run(): void;
247
319
  stop(): Promise<void>;
320
+ /**
321
+ * Emits a command from the shell command widget.
322
+ *
323
+ * @param media
324
+ * @private
325
+ */
326
+ private emitCommand;
248
327
  }
249
328
 
250
- type MediaState = 'idle' | 'playing' | 'ended';
329
+ declare function AudioMedia(media: IMedia): {
330
+ init(): void;
331
+ };
332
+
333
+ type MediaState = 'idle' | 'playing' | 'ended' | 'cancelled';
251
334
  declare const MediaState: {
252
335
  readonly IDLE: "idle";
253
336
  readonly PLAYING: "playing";
254
337
  readonly ENDED: "ended";
338
+ readonly CANCELLED: "cancelled";
255
339
  };
256
340
  interface IMedia {
257
341
  attachedAudio: boolean;
@@ -294,18 +378,16 @@ interface IMedia {
294
378
  url: string | null;
295
379
  useDuration: boolean;
296
380
  xml: Element | null;
381
+ videoHandler?: IVideoMediaHandler;
382
+ mediaTimer: ReturnType<typeof setInterval> | undefined;
297
383
  }
298
384
  declare const initialMedia: IMedia;
299
385
 
300
- interface IRegionEvents {
301
- start: (layout: IRegion) => void;
302
- end: (layout: IRegion) => void;
303
- }
304
386
  interface IRegion {
305
387
  complete: boolean;
306
388
  containerName: string;
307
389
  currMedia: IMedia | undefined;
308
- currEl: HTMLElement | undefined;
390
+ currEl: HTMLElement | null;
309
391
  currentMedia: number;
310
392
  currentMediaIndex: number;
311
393
  emitter?: Emitter<DefaultEvents>;
@@ -322,7 +404,7 @@ interface IRegion {
322
404
  mediaObjects: IMedia[];
323
405
  mediaObjectsActions: IMedia[];
324
406
  nxtMedia: IMedia | undefined;
325
- nxtEl: HTMLElement | undefined;
407
+ nxtEl: HTMLElement | null;
326
408
  offsetX: number;
327
409
  offsetY: number;
328
410
  oldMedia: IMedia | undefined;
@@ -346,19 +428,22 @@ interface IRegion {
346
428
  uniqueId: string;
347
429
  xml: null | Element;
348
430
  zIndex: number;
431
+ prepareNextMedia(): void;
432
+ xlr: IXlr;
349
433
  }
350
434
  declare const initialRegion: IRegion;
351
435
 
352
- interface ILayoutEvents {
353
- start: (layout: ILayout) => void;
354
- end: (layout: ILayout) => void;
355
- cancelled: (layout: ILayout) => void;
356
- }
357
436
  declare enum ELayoutState {
358
437
  IDLE = 0,
359
438
  RUNNING = 1,
360
439
  PLAYED = 2,
361
- CANCELLED = 3
440
+ CANCELLED = 3,
441
+ ERROR = 4
442
+ }
443
+ declare enum LayoutPlaybackType {
444
+ CURRENT = "current",
445
+ NEXT = "next",
446
+ OVERLAY = "overlay"
362
447
  }
363
448
  type InputLayoutType = {
364
449
  response: any;
@@ -376,12 +461,12 @@ type OptionsType = {
376
461
  getResourceUrl: string;
377
462
  layoutBackgroundDownloadUrl: string;
378
463
  layoutPreviewUrl: string;
379
- libraryDownloadUrl: string;
380
464
  loaderUrl: string;
465
+ previewJwt: string;
381
466
  idCounter: number;
382
467
  inPreview: boolean;
383
468
  appHost?: string | null;
384
- platform: 'CMS' | 'chromeOS';
469
+ platform: ConsumerPlatform;
385
470
  config?: {
386
471
  cmsUrl: string | null;
387
472
  schemaVersion: number;
@@ -434,7 +519,7 @@ interface ILayout {
434
519
  on<E extends keyof ILayoutEvents>(event: E, callback: ILayoutEvents[E]): Unsubscribe;
435
520
  regionExpired(): void;
436
521
  end(): void;
437
- regionEnded(): Promise<void>;
522
+ regionEnded(): void;
438
523
  stopAllMedia(): Promise<void>;
439
524
  resetLayout(): Promise<void>;
440
525
  index: number;
@@ -443,7 +528,7 @@ interface ILayout {
443
528
  xlr: IXlr;
444
529
  finishAllRegions(): Promise<void[]>;
445
530
  inLoop: boolean;
446
- removeLayout(): void;
531
+ removeLayout(caller?: LayoutPlaybackType): void;
447
532
  xlfString: string;
448
533
  getXlf(): string;
449
534
  ad: any;
@@ -451,6 +536,8 @@ interface ILayout {
451
536
  shareOfVoice: number;
452
537
  isInterrupt(): boolean;
453
538
  state: ELayoutState;
539
+ errorCode: number | null;
540
+ html: HTMLElement | null;
454
541
  }
455
542
  declare const initialLayout: ILayout;
456
543
  type GetLayoutParamType = {
@@ -472,11 +559,11 @@ declare function nextId(options: {
472
559
  }): number;
473
560
  declare const getMediaId: ({ mediaType, containerName }: IMedia) => string;
474
561
  declare const capitalizeStr: (inputStr: string) => string;
475
- declare function getDataBlob(src: string): Promise<unknown>;
562
+ declare function getDataBlob(src: string, jwtToken: string | null): Promise<unknown>;
476
563
  type MediaTypes = 'video' | 'audio' | 'image';
477
- declare function preloadMediaBlob(src: string, type: MediaTypes): Promise<string>;
478
- declare function fetchJSON(url: string): Promise<any>;
479
- declare function fetchText(url: string): Promise<string>;
564
+ declare function preloadMediaBlob(src: string, type: MediaTypes, jwtToken: string | null): Promise<string>;
565
+ declare function fetchJSON(url: string, jwtToken: string | null): Promise<any>;
566
+ declare function fetchText(url: string, jwtToken: string | null): Promise<string>;
480
567
  declare function getFileExt(filename: string): string;
481
568
  declare function audioFileType(str: string): string | undefined;
482
569
  declare function videoFileType(str: string): string | undefined;
@@ -510,21 +597,60 @@ declare function setExpiry(numDays: number): string;
510
597
  */
511
598
  declare function isLayoutValid(layouts: InputLayoutType[], layoutId: number | undefined): boolean;
512
599
  declare function hasDefaultOnly(inputLayouts: InputLayoutType[]): boolean;
600
+ declare function createMediaElement(mediaObject: IMedia): HTMLElement;
513
601
 
514
- declare function composeVideoSource($media: HTMLVideoElement, media: IMedia): HTMLVideoElement;
515
- declare function VideoMedia(media: IMedia, xlr: IXlr): {
516
- duration: number;
517
- init: () => void;
518
- stop: (disposeOnly?: boolean) => void;
519
- };
520
-
521
- declare function AudioMedia(media: IMedia): {
522
- init(): void;
523
- };
524
-
525
- declare const platform: OptionsType;
526
-
527
- declare function Region(layout: ILayout, xml: Element, regionId: string, options: OptionsType, xlr: IXlr): IRegion;
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
+ }
528
654
 
529
655
  interface ISplashScreen {
530
656
  init: () => void;
@@ -627,4 +753,4 @@ type flyTransitionParams = {
627
753
  };
628
754
  declare const flyTransitionKeyframes: (params: flyTransitionParams) => KeyframeOptionsType;
629
755
 
630
- 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, platform, 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 };