@xibosignage/xibo-layout-renderer 1.0.23 → 1.0.25

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 CHANGED
@@ -67,3 +67,52 @@ The library supports multiple platforms via `ConsumerPlatform` enum and the `opt
67
67
  | `chromeOS` | Local file path | Fault reporting via Service Worker |
68
68
  | `electron` | App host + URL | Standard playback |
69
69
  | PWA | Proxy/hosted | Service Worker caching |
70
+
71
+ ## CMS Integration — postMessage Protocol
72
+
73
+ When XLR is embedded in a sandboxed `<iframe>` (e.g. in CMS Preview), it communicates with the parent frame via `window.parent.postMessage` instead of using browser dialogs that require `allow-modals`.
74
+
75
+ ### Iframe requirements
76
+
77
+ The iframe must include `allow-scripts` in its `sandbox` attribute. `allow-modals` is **not** required.
78
+
79
+ ```html
80
+ <iframe src="..." sandbox="allow-scripts allow-same-origin"></iframe>
81
+ ```
82
+
83
+ ### Messages sent by XLR
84
+
85
+ #### `xlr:navLayout`
86
+
87
+ Fired when a "Navigate to Layout" touch/webhook action is triggered. The parent frame is responsible for showing a confirmation prompt and opening the layout.
88
+
89
+ ```typescript
90
+ interface XlrNavLayoutMessage {
91
+ type: 'xlr:navLayout';
92
+ layoutCode: string; // The layout code from the action
93
+ url: string; // Pre-constructed preview URL (ready to open)
94
+ }
95
+ ```
96
+
97
+ **CMS listener example:**
98
+
99
+ ```javascript
100
+ window.addEventListener('message', (event) => {
101
+ // In production, validate event.origin against your known CMS origin.
102
+ if (event.data?.type === 'xlr:navLayout') {
103
+ if (confirm(`Navigate to layout with code ${event.data.layoutCode}?`)) {
104
+ window.open(event.data.url, '_blank');
105
+ }
106
+ }
107
+ });
108
+ ```
109
+
110
+ ### Event API (non-iframe consumers)
111
+
112
+ The same action also emits a `navLayout` event via the XLR event system, usable by consumers that have direct access to the `IXlr` object:
113
+
114
+ ```typescript
115
+ xlr.on('navLayout', (layoutCode: string, url: string) => {
116
+ // Show your own confirmation UI and open the URL as needed.
117
+ });
118
+ ```
@@ -1,5 +1,5 @@
1
1
  import { IMedia } from '../../Types/Media';
2
- import { InputLayoutType, OptionsType } from '../../Types/Layout';
2
+ import { ILayout, InputLayoutType, OptionsType } from '../../Types/Layout';
3
3
  import { IRegion } from "../../Types/Region";
4
4
  export declare function nextId(options: {
5
5
  idCounter: number;
@@ -17,7 +17,7 @@ export declare function videoFileType(str: string): string | undefined;
17
17
  export declare function composeResourceUrlByPlatform(options: OptionsType, params: any): string;
18
18
  export declare function composeResourceUrl(options: OptionsType, params: any): string;
19
19
  export declare function composeMediaUrl(params: any): string;
20
- export declare function composeBgUrlByPlatform(platform: OptionsType['platform'], params: any): string;
20
+ export declare function composeBgUrlByPlatform(platform: OptionsType['platform'], params: ILayout): string;
21
21
  type LayoutIndexType = {
22
22
  [k: string]: InputLayoutType & {
23
23
  index: number;
@@ -62,4 +62,5 @@ export declare function prepareImageMedia(media: IMedia, region: IRegion): void;
62
62
  export declare function prepareAudioMedia(media: IMedia, region: IRegion): void;
63
63
  export declare function prepareHtmlMedia(media: IMedia, region: IRegion): void;
64
64
  export declare function playerReportFault(msg: string, media: IMedia): Promise<void>;
65
+ export declare function setLayoutIndex(layout: ILayout | undefined, layoutIndex: number): ILayout | undefined;
65
66
  export {};
@@ -1,2 +1 @@
1
- export type { MediaTypes, } from './Generators';
2
- export { getFileExt, nextId, preloadMediaBlob, getMediaId, fetchJSON, capitalizeStr, audioFileType, videoFileType, setExpiry, composeMediaUrl, fetchText, getDataBlob, composeResourceUrl, composeResourceUrlByPlatform, getIndexByLayoutId, isEmpty, composeBgUrlByPlatform, hasDefaultOnly, isLayoutValid, createMediaElement, } from './Generators';
1
+ export { getFileExt, nextId, preloadMediaBlob, getMediaId, fetchJSON, capitalizeStr, audioFileType, videoFileType, setExpiry, composeMediaUrl, fetchText, getDataBlob, composeResourceUrl, composeResourceUrlByPlatform, getIndexByLayoutId, isEmpty, composeBgUrlByPlatform, hasDefaultOnly, isLayoutValid, createMediaElement, playerReportFault, getAllAttributes, prepareAudioMedia, prepareHtmlMedia, prepareImageMedia, prepareVideoMedia, getLayoutIndexByLayoutId, hasSspLayout, type MediaTypes, } from './Generators';
@@ -1,6 +1,6 @@
1
1
  import Player from "video.js/dist/types/player";
2
2
  import { IMedia } from '../../Types/Media';
3
- import { IXlr, OptionsType } from '../../types';
3
+ import { IXlr } from '../../types';
4
4
  import './media.css';
5
5
  export declare function composeVideoSource($media: HTMLVideoElement, media: IMedia): HTMLVideoElement;
6
6
  export declare const defaultVjsOpts: {
@@ -15,7 +15,6 @@ export interface IVideoMediaHandler {
15
15
  duration: number;
16
16
  stop(disposeOnly?: boolean): void;
17
17
  }
18
- export declare function videoMediaHandler(media: IMedia, platform: OptionsType['platform']): IVideoMediaHandler;
19
18
  export declare function VideoMedia(media: IMedia, xlr: IXlr): {
20
19
  duration: number;
21
20
  init: () => void;
@@ -42,9 +42,6 @@ export default class Region implements IRegion {
42
42
  prepareNextMedia(): void;
43
43
  prepareMediaObjects(): void;
44
44
  finished(): void;
45
- private prepareVideo;
46
- private prepareImage;
47
- private prepareIframe;
48
45
  run(): void;
49
46
  transitionNodes(oldMedia: IMedia | undefined, newMedia: IMedia | undefined): void;
50
47
  playNextMedia(): void;
@@ -26,6 +26,7 @@ export type InputLayoutType = {
26
26
  getXlf?(): string;
27
27
  duration?: number;
28
28
  isOverlay?: boolean;
29
+ shareOfVoice?: number;
29
30
  };
30
31
  export type OptionsType = {
31
32
  xlfUrl: string;
@@ -23,6 +23,7 @@ export type IXlrEvents = {
23
23
  overlayEnd: (overlay: ILayout) => void;
24
24
  commandCodeReceived: (commandCode: string) => void;
25
25
  commandStringReceived: (commandString: string) => void;
26
+ navLayout: (layoutCode: string, url: string) => void;
26
27
  };
27
28
  export interface IXlrPlayback {
28
29
  currentLayout: ILayout | undefined;