@raydiant/playlist-window-manager 0.25.0 → 0.25.1-canary.0
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/build/BrowserViewRenderer.d.ts +2 -3
- package/build/BrowserViewRenderer.js +23 -48
- package/build/BrowserWindowRenderer.d.ts +2 -3
- package/build/BrowserWindowRenderer.js +42 -69
- package/build/IFrameRenderer.d.ts +2 -4
- package/build/IFrameRenderer.js +44 -63
- package/build/PlaylistWindowManager.d.ts +1 -10
- package/build/PlaylistWindowManager.js +18 -87
- package/build/PlaylistWindowManagerState.js +3 -3
- package/build/PresentationWindow.d.ts +5 -39
- package/build/PresentationWindow.js +98 -683
- package/build/WindowLoadError.js +1 -3
- package/build/WindowTimeoutError.js +1 -3
- package/build/WindowUnresponsiveError.js +1 -3
- package/build/embeddedApps.d.ts +2 -2
- package/build/embeddedApps.js +15 -36
- package/build/embeddedApps.test.js +36 -89
- package/build/index.js +6 -19
- package/build/preload.js +14 -14
- package/build/types.d.ts +2 -49
- package/package.json +1 -1
- package/src/BrowserViewRenderer.ts +6 -5
- package/src/BrowserWindowRenderer.ts +16 -14
- package/build/PresentationWindow.test.d.ts +0 -1
- package/build/PresentationWindow.test.js +0 -406
- package/build/testUtils.d.ts +0 -43
- package/build/testUtils.js +0 -209
package/build/IFrameRenderer.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
4
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
5
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
@@ -14,7 +13,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
13
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
14
|
function step(op) {
|
|
16
15
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (
|
|
16
|
+
while (_) try {
|
|
18
17
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
18
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
19
|
switch (op[0]) {
|
|
@@ -36,27 +35,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var namespace = 'raydiant';
|
|
40
38
|
var IFrameRenderer = /** @class */ (function () {
|
|
41
39
|
function IFrameRenderer(container) {
|
|
42
40
|
var _this = this;
|
|
43
41
|
this.container = container;
|
|
44
42
|
this.windows = {};
|
|
45
43
|
this.globalMessageHandler = function (event) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
var _a;
|
|
45
|
+
var windowId;
|
|
46
|
+
var type;
|
|
47
|
+
var payload;
|
|
48
|
+
try {
|
|
49
|
+
(_a = JSON.parse(event.data), windowId = _a.windowId, type = _a.type, payload = _a.payload);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.warn("Invalid message received from iframe '" + JSON.stringify(event.data) + "', ignoring message");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!windowId) {
|
|
56
|
+
// ignore messages that don't have windowId
|
|
57
|
+
// such message are comming from 3rd party IFrames like google
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var window = _this.getWindow(windowId);
|
|
61
|
+
if (!window) {
|
|
62
|
+
throw new Error("Failed add receive message callback to window, window with window id: '" + windowId + "' was not found");
|
|
63
|
+
}
|
|
64
|
+
if (window.receiveMessageCallback) {
|
|
65
|
+
window.receiveMessageCallback(type, payload);
|
|
60
66
|
}
|
|
61
67
|
};
|
|
62
68
|
// Post message is a single channel for all window so we need to
|
|
@@ -82,10 +88,10 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
82
88
|
frame.style.border = 'none';
|
|
83
89
|
// Position will be 0,0 for the main window.
|
|
84
90
|
if (bounds) {
|
|
85
|
-
frame.style.top =
|
|
86
|
-
frame.style.left =
|
|
87
|
-
frame.style.width =
|
|
88
|
-
frame.style.height =
|
|
91
|
+
frame.style.top = bounds.y + "px";
|
|
92
|
+
frame.style.left = bounds.x + "px";
|
|
93
|
+
frame.style.width = bounds.width + "px";
|
|
94
|
+
frame.style.height = bounds.height + "px";
|
|
89
95
|
}
|
|
90
96
|
else {
|
|
91
97
|
// If bounds assume fullscreen.
|
|
@@ -108,7 +114,7 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
108
114
|
IFrameRenderer.prototype.loadWindow = function (windowId, url) {
|
|
109
115
|
var window = this.getWindow(windowId);
|
|
110
116
|
if (!window) {
|
|
111
|
-
throw new Error("Failed to update window bounds, missing window id '"
|
|
117
|
+
throw new Error("Failed to update window bounds, missing window id '" + windowId + "'");
|
|
112
118
|
}
|
|
113
119
|
// Return a promise that resolves then the window has successfully loaded.
|
|
114
120
|
return new Promise(function (resolve, reject) {
|
|
@@ -116,7 +122,7 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
116
122
|
resolve();
|
|
117
123
|
};
|
|
118
124
|
window.frame.onerror = function () {
|
|
119
|
-
reject(new Error("Error loading window for '"
|
|
125
|
+
reject(new Error("Error loading window for '" + url + "'"));
|
|
120
126
|
};
|
|
121
127
|
window.frame.src = url;
|
|
122
128
|
});
|
|
@@ -124,17 +130,17 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
124
130
|
IFrameRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
|
|
125
131
|
var window = this.getWindow(windowId);
|
|
126
132
|
if (!window) {
|
|
127
|
-
throw new Error("Failed to update window bounds, missing window id '"
|
|
133
|
+
throw new Error("Failed to update window bounds, missing window id '" + windowId + "'");
|
|
128
134
|
}
|
|
129
|
-
window.frame.style.top =
|
|
130
|
-
window.frame.style.left =
|
|
131
|
-
window.frame.style.width =
|
|
132
|
-
window.frame.style.height =
|
|
135
|
+
window.frame.style.top = bounds.y + "px";
|
|
136
|
+
window.frame.style.left = bounds.x + "px";
|
|
137
|
+
window.frame.style.width = bounds.width + "px";
|
|
138
|
+
window.frame.style.height = bounds.height + "px";
|
|
133
139
|
};
|
|
134
140
|
IFrameRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
135
141
|
var window = this.getWindow(windowId);
|
|
136
142
|
if (!window) {
|
|
137
|
-
throw new Error("Failed to show window, missing window id '"
|
|
143
|
+
throw new Error("Failed to show window, missing window id '" + windowId + "'");
|
|
138
144
|
}
|
|
139
145
|
window.frame.style.zIndex = '9999';
|
|
140
146
|
window.frame.style.visibility = 'visible';
|
|
@@ -145,7 +151,7 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
145
151
|
IFrameRenderer.prototype.hideWindow = function (windowId) {
|
|
146
152
|
var window = this.getWindow(windowId);
|
|
147
153
|
if (!window) {
|
|
148
|
-
throw new Error("Failed to hide window, missing window id '"
|
|
154
|
+
throw new Error("Failed to hide window, missing window id '" + windowId + "'");
|
|
149
155
|
}
|
|
150
156
|
window.frame.style.zIndex = '0';
|
|
151
157
|
window.frame.style.visibility = 'hidden';
|
|
@@ -156,7 +162,7 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
156
162
|
return __generator(this, function (_a) {
|
|
157
163
|
window = this.getWindow(windowId);
|
|
158
164
|
if (!window) {
|
|
159
|
-
throw new Error("Failed to remove window, missing window id '"
|
|
165
|
+
throw new Error("Failed to remove window, missing window id '" + windowId + "'");
|
|
160
166
|
}
|
|
161
167
|
this.container.removeChild(window.frame);
|
|
162
168
|
delete this.windows[windowId];
|
|
@@ -164,30 +170,20 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
164
170
|
});
|
|
165
171
|
});
|
|
166
172
|
};
|
|
167
|
-
IFrameRenderer.prototype.
|
|
168
|
-
var window = this.getWindow(windowId);
|
|
169
|
-
if (!window) {
|
|
170
|
-
throw new Error("Failed to send message '".concat(message, "', missing window id '").concat(windowId, "'"));
|
|
171
|
-
}
|
|
172
|
-
if (!window.frame.contentWindow) {
|
|
173
|
-
throw new Error("Failed to send message '".concat(message, "', contentWindow missing for '").concat(windowId, "'"));
|
|
174
|
-
}
|
|
175
|
-
window.frame.contentWindow.postMessage("".concat(namespace, ":").concat(message), '*');
|
|
176
|
-
};
|
|
177
|
-
IFrameRenderer.prototype.sendMessageObject = function (windowId, type, payload) {
|
|
173
|
+
IFrameRenderer.prototype.sendMessage = function (windowId, message) {
|
|
178
174
|
var window = this.getWindow(windowId);
|
|
179
175
|
if (!window) {
|
|
180
|
-
throw new Error("Failed to send message '"
|
|
176
|
+
throw new Error("Failed to send message '" + message + "', missing window id '" + windowId + "'");
|
|
181
177
|
}
|
|
182
178
|
if (!window.frame.contentWindow) {
|
|
183
|
-
throw new Error("Failed to send message '"
|
|
179
|
+
throw new Error("Failed to send message '" + message + "', contentWindow missing for '" + windowId + "'");
|
|
184
180
|
}
|
|
185
|
-
window.frame.contentWindow.postMessage(
|
|
181
|
+
window.frame.contentWindow.postMessage(message, '*');
|
|
186
182
|
};
|
|
187
183
|
IFrameRenderer.prototype.muteWindow = function (windowId) {
|
|
188
184
|
var window = this.getWindow(windowId);
|
|
189
185
|
if (!window) {
|
|
190
|
-
throw new Error("Failed to mute window, missing window id '"
|
|
186
|
+
throw new Error("Failed to mute window, missing window id '" + windowId + "'");
|
|
191
187
|
}
|
|
192
188
|
// There is no mute/unmute API for iframes so we rely on the window manager overriding any
|
|
193
189
|
// mute presentation properties.
|
|
@@ -195,7 +191,7 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
195
191
|
IFrameRenderer.prototype.unMuteWindow = function (windowId) {
|
|
196
192
|
var window = this.getWindow(windowId);
|
|
197
193
|
if (!window) {
|
|
198
|
-
throw new Error("Failed to unmute window, missing window id '"
|
|
194
|
+
throw new Error("Failed to unmute window, missing window id '" + windowId + "'");
|
|
199
195
|
}
|
|
200
196
|
// There is no mute/unmute API for iframes so we rely on the window manager overriding any
|
|
201
197
|
// mute presentation properties.
|
|
@@ -206,21 +202,6 @@ var IFrameRenderer = /** @class */ (function () {
|
|
|
206
202
|
IFrameRenderer.prototype.getWindow = function (windowId) {
|
|
207
203
|
return this.windows[windowId];
|
|
208
204
|
};
|
|
209
|
-
IFrameRenderer.prototype.deserializeMessage = function (message) {
|
|
210
|
-
var _a;
|
|
211
|
-
var windowId = '';
|
|
212
|
-
var type = '';
|
|
213
|
-
var payload;
|
|
214
|
-
var json = message.replace('raydiant:', '');
|
|
215
|
-
try {
|
|
216
|
-
// Messages are sent as json in the format of { type: string, payload: unknown }.
|
|
217
|
-
(_a = JSON.parse(json), windowId = _a.windowId, type = _a.type, payload = _a.payload);
|
|
218
|
-
}
|
|
219
|
-
catch (err) {
|
|
220
|
-
// Not a valid message, return empty type and payload.
|
|
221
|
-
}
|
|
222
|
-
return { windowId: windowId, type: type, payload: payload };
|
|
223
|
-
};
|
|
224
205
|
return IFrameRenderer;
|
|
225
206
|
}());
|
|
226
207
|
exports.default = IFrameRenderer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as RE from '@raydiant/playlist-rule-engine';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { PresentationWindowRenderer, Device, WindowBounds, Theme, Logger
|
|
3
|
+
import { PresentationWindowRenderer, Device, WindowBounds, Theme, Logger } from './types';
|
|
4
4
|
import PlaylistWindowManagerState from './PlaylistWindowManagerState';
|
|
5
5
|
export interface PlaylistWindowManagerOptions {
|
|
6
6
|
ruleEngine: RE.RuleEngine;
|
|
@@ -9,7 +9,6 @@ export interface PlaylistWindowManagerOptions {
|
|
|
9
9
|
device?: Device;
|
|
10
10
|
readyTimeoutDurationSeconds?: number;
|
|
11
11
|
appRendererUrl?: string;
|
|
12
|
-
appRendererOfflineSupport?: boolean;
|
|
13
12
|
bounds?: WindowBounds;
|
|
14
13
|
backgroundColor?: string;
|
|
15
14
|
themeOverride?: Theme;
|
|
@@ -19,7 +18,6 @@ export interface PlaylistWindowManagerOptions {
|
|
|
19
18
|
isPreview?: boolean;
|
|
20
19
|
onEnableInterruptLock?: () => void;
|
|
21
20
|
onDisableInterruptLock?: () => void;
|
|
22
|
-
getTerminal?: () => Terminal | null;
|
|
23
21
|
}
|
|
24
22
|
export default class PlaylistWindowManager extends EventEmitter {
|
|
25
23
|
private options;
|
|
@@ -42,7 +40,6 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
42
40
|
private themeOverride?;
|
|
43
41
|
private forceMute;
|
|
44
42
|
private isFocused;
|
|
45
|
-
private workerState;
|
|
46
43
|
constructor(options: PlaylistWindowManagerOptions);
|
|
47
44
|
private currentPresentationId;
|
|
48
45
|
private nextPresentationId;
|
|
@@ -76,10 +73,6 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
76
73
|
hide(): Promise<void>;
|
|
77
74
|
isReady(): boolean;
|
|
78
75
|
isLocked(): boolean;
|
|
79
|
-
runWorkerSubscriptions(state: WorkerState): void;
|
|
80
|
-
sendChargeResponse(response: ChargeResponse): void;
|
|
81
|
-
sendCharge(charge: Charge): void;
|
|
82
|
-
sendTerminal(terminal: Terminal | null): void;
|
|
83
76
|
private createWindow;
|
|
84
77
|
private loadCurrentWindow;
|
|
85
78
|
private shouldPreload;
|
|
@@ -94,8 +87,6 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
94
87
|
private evalRuleEngine;
|
|
95
88
|
private handleEnableInterruptLock;
|
|
96
89
|
private handleDisableInterruptLock;
|
|
97
|
-
private handleAnalyticsEvent;
|
|
98
|
-
private handleChargeRequest;
|
|
99
90
|
private handleCurrentPresentationComplete;
|
|
100
91
|
private handleCurrentPresentationError;
|
|
101
92
|
private handleNextPresentationError;
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -26,11 +24,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
26
24
|
return __assign.apply(this, arguments);
|
|
27
25
|
};
|
|
28
26
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
28
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
29
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
34
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
32
|
});
|
|
36
33
|
};
|
|
@@ -40,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40
37
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
38
|
function step(op) {
|
|
42
39
|
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (
|
|
40
|
+
while (_) try {
|
|
44
41
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
42
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
43
|
switch (op[0]) {
|
|
@@ -96,7 +93,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
96
93
|
_this.lastCompleteAt = null;
|
|
97
94
|
_this.forceMute = false;
|
|
98
95
|
_this.isFocused = false;
|
|
99
|
-
_this.workerState = {};
|
|
100
96
|
_this.handleEnableInterruptLock = function () {
|
|
101
97
|
var onEnableInterruptLock = _this.options.onEnableInterruptLock;
|
|
102
98
|
if (onEnableInterruptLock) {
|
|
@@ -112,16 +108,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
112
108
|
_this.endCurrentPresentation();
|
|
113
109
|
}
|
|
114
110
|
};
|
|
115
|
-
_this.handleAnalyticsEvent = function (event) {
|
|
116
|
-
// Emit the event on the current window. Only the current window should
|
|
117
|
-
// send analytics events since the next window is not visible.
|
|
118
|
-
_this.emitCurrentWindowEvent('window_analytics_event', event);
|
|
119
|
-
};
|
|
120
|
-
_this.handleChargeRequest = function (request) {
|
|
121
|
-
// Emit the event on the current window. Only the current window should
|
|
122
|
-
// send charge requests since the next window is not visible.
|
|
123
|
-
_this.emitCurrentWindowEvent('window_charge_request', request);
|
|
124
|
-
};
|
|
125
111
|
_this.handleCurrentPresentationComplete = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
126
112
|
var logger, isThrottled, now, timeSinceLastComplete, delay, _a, next, preview, nextPreviewPresentationId;
|
|
127
113
|
var _this = this;
|
|
@@ -138,7 +124,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
138
124
|
// Throttle presentation complete handler if we have not throttled already.
|
|
139
125
|
if (this.currentPresentationCompleteTimeout === null) {
|
|
140
126
|
delay = minTimeBetweenCompletes - timeSinceLastComplete + 1;
|
|
141
|
-
logger.warn("Throttling presentation complete handler for "
|
|
127
|
+
logger.warn("Throttling presentation complete handler for " + delay + "ms because it was called again in less than " + minTimeBetweenCompletes + "ms");
|
|
142
128
|
this.currentPresentationCompleteTimeout = setTimeout(function () {
|
|
143
129
|
_this.currentPresentationCompleteTimeout = null;
|
|
144
130
|
_this.handleCurrentPresentationComplete();
|
|
@@ -295,7 +281,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
295
281
|
}
|
|
296
282
|
preview = this.ruleEngine.previewNext();
|
|
297
283
|
if (!this.shouldPreload(preview.presentationId)) return [3 /*break*/, 3];
|
|
298
|
-
logger.info("Preview check replacing preloaded presentation '"
|
|
284
|
+
logger.info("Preview check replacing preloaded presentation '" + this.nextPresentationId() + "' with new presentation '" + preview.presentationId + "'");
|
|
299
285
|
return [4 /*yield*/, this.removeNextWindow()];
|
|
300
286
|
case 1:
|
|
301
287
|
_a.sent();
|
|
@@ -306,7 +292,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
306
292
|
_a.label = 3;
|
|
307
293
|
case 3:
|
|
308
294
|
if (preview.shouldInterrupt) {
|
|
309
|
-
logger.info("Interrupting current presentation with '"
|
|
295
|
+
logger.info("Interrupting current presentation with '" + preview.presentationId + "'");
|
|
310
296
|
this.registerInterrupt();
|
|
311
297
|
}
|
|
312
298
|
return [2 /*return*/];
|
|
@@ -478,9 +464,10 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
478
464
|
PlaylistWindowManager.prototype.reinitializeRuleEngineState = function (newRulesDataStoreObj) {
|
|
479
465
|
var _this = this;
|
|
480
466
|
var logger = this.options.logger;
|
|
481
|
-
logger.
|
|
467
|
+
logger.info('Dynamic Rule engine state change event received!');
|
|
482
468
|
if (this.ruleEngine) {
|
|
483
|
-
logger.
|
|
469
|
+
logger.info("Existing Rule Data Store: ", this.ruleEngine.state);
|
|
470
|
+
logger.info("New Rule Data Store data received: ", newRulesDataStoreObj);
|
|
484
471
|
this.ruleEngine.state.rulesDataStore = newRulesDataStoreObj;
|
|
485
472
|
}
|
|
486
473
|
else {
|
|
@@ -633,51 +620,8 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
633
620
|
}
|
|
634
621
|
return this.currentWindow.isLocked();
|
|
635
622
|
};
|
|
636
|
-
PlaylistWindowManager.prototype.runWorkerSubscriptions = function (state) {
|
|
637
|
-
// Persist worker state so new windows can be initialized with it.
|
|
638
|
-
this.workerState = state;
|
|
639
|
-
// Run worker subcriptions on the current window.
|
|
640
|
-
if (this.currentWindow) {
|
|
641
|
-
this.currentWindow.runWorkerSubscriptions(state);
|
|
642
|
-
}
|
|
643
|
-
// Run worker subscriptions on the next window.
|
|
644
|
-
if (this.nextWindow) {
|
|
645
|
-
this.nextWindow.runWorkerSubscriptions(state);
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
PlaylistWindowManager.prototype.sendChargeResponse = function (response) {
|
|
649
|
-
// Send charge response to the current window. The window will check if
|
|
650
|
-
// has a matching request id and if so, send the response to the app.
|
|
651
|
-
if (this.currentWindow) {
|
|
652
|
-
this.currentWindow.sendChargeResponse(response);
|
|
653
|
-
}
|
|
654
|
-
// Send charge response to the next window.
|
|
655
|
-
if (this.nextWindow) {
|
|
656
|
-
this.nextWindow.sendChargeResponse(response);
|
|
657
|
-
}
|
|
658
|
-
};
|
|
659
|
-
PlaylistWindowManager.prototype.sendCharge = function (charge) {
|
|
660
|
-
// Send charge to the current window.
|
|
661
|
-
if (this.currentWindow) {
|
|
662
|
-
this.currentWindow.sendCharge(charge);
|
|
663
|
-
}
|
|
664
|
-
// Send charge to the next window.
|
|
665
|
-
if (this.nextWindow) {
|
|
666
|
-
this.nextWindow.sendCharge(charge);
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
PlaylistWindowManager.prototype.sendTerminal = function (terminal) {
|
|
670
|
-
// Send terminal to the current window.
|
|
671
|
-
if (this.currentWindow) {
|
|
672
|
-
this.currentWindow.sendTerminal(terminal);
|
|
673
|
-
}
|
|
674
|
-
// Send terminal to the next window.
|
|
675
|
-
if (this.nextWindow) {
|
|
676
|
-
this.nextWindow.sendTerminal(terminal);
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
623
|
PlaylistWindowManager.prototype.createWindow = function (pr) {
|
|
680
|
-
var _a = this.options, readyTimeoutDurationSeconds = _a.readyTimeoutDurationSeconds, appRendererUrl = _a.appRendererUrl,
|
|
624
|
+
var _a = this.options, readyTimeoutDurationSeconds = _a.readyTimeoutDurationSeconds, appRendererUrl = _a.appRendererUrl, backgroundColor = _a.backgroundColor, device = _a.device, logger = _a.logger, windowName = _a.windowName, parentWindowId = _a.parentWindowId, isPreview = _a.isPreview;
|
|
681
625
|
if (!this.ruleEngine) {
|
|
682
626
|
throw new Error('Attempted to create window but ruleEngine was not provided');
|
|
683
627
|
}
|
|
@@ -693,7 +637,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
693
637
|
}
|
|
694
638
|
var presentation = this.state.getPresentation(presentationId);
|
|
695
639
|
var applicationVersion = this.state.getApplicationVersion(presentation.applicationDeploymentId);
|
|
696
|
-
var windowId =
|
|
640
|
+
var windowId = uuid_1.v4();
|
|
697
641
|
return new PresentationWindow_1.default({
|
|
698
642
|
windowManager: this,
|
|
699
643
|
renderer: this.renderer,
|
|
@@ -712,15 +656,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
712
656
|
forceMute: this.forceMute,
|
|
713
657
|
readyTimeoutDurationSeconds: readyTimeoutDurationSeconds,
|
|
714
658
|
appRendererUrl: appRendererUrl,
|
|
715
|
-
appRendererOfflineSupport: appRendererOfflineSupport,
|
|
716
659
|
bounds: this.bounds,
|
|
717
660
|
backgroundColor: backgroundColor,
|
|
718
661
|
playlistWindowManagerState: this.state,
|
|
719
662
|
ruleEngineState: this.ruleEngine.state,
|
|
720
663
|
globalRule: this.ruleEngine.globalRule,
|
|
721
|
-
isPreview: isPreview
|
|
722
|
-
workerState: this.workerState,
|
|
723
|
-
getTerminal: this.options.getTerminal,
|
|
664
|
+
isPreview: isPreview
|
|
724
665
|
});
|
|
725
666
|
};
|
|
726
667
|
PlaylistWindowManager.prototype.loadCurrentWindow = function () {
|
|
@@ -739,8 +680,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
739
680
|
this.currentWindow.onError(this.handleCurrentPresentationError);
|
|
740
681
|
this.currentWindow.onEnableInterruptLock(this.handleEnableInterruptLock);
|
|
741
682
|
this.currentWindow.onDisableInterruptLock(this.handleDisableInterruptLock);
|
|
742
|
-
this.currentWindow.onAnalyticsEvent(this.handleAnalyticsEvent);
|
|
743
|
-
this.currentWindow.onChargeRequest(this.handleChargeRequest);
|
|
744
683
|
return [4 /*yield*/, this.currentWindow.load()];
|
|
745
684
|
case 1:
|
|
746
685
|
_a.sent();
|
|
@@ -895,7 +834,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
895
834
|
};
|
|
896
835
|
PlaylistWindowManager.prototype.swapWindows = function () {
|
|
897
836
|
return __awaiter(this, void 0, void 0, function () {
|
|
898
|
-
var nextPreviewPresentationId, preview, result,
|
|
837
|
+
var nextPreviewPresentationId, preview, result, shouldPreload;
|
|
899
838
|
return __generator(this, function (_a) {
|
|
900
839
|
switch (_a.label) {
|
|
901
840
|
case 0:
|
|
@@ -911,7 +850,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
911
850
|
preview = result.preview;
|
|
912
851
|
nextPreviewPresentationId = preview.presentationId;
|
|
913
852
|
}
|
|
914
|
-
nextPresentation = this.nextPresentation;
|
|
915
853
|
// Set this.currentPresentationId before removing the current window to avoid timing issues with previewCheck
|
|
916
854
|
// triggering during removeCurrentWindow. Current presentation id needs to be set to the next
|
|
917
855
|
// presentation before calling shouldPreload().
|
|
@@ -941,17 +879,10 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
941
879
|
// Swap windows.
|
|
942
880
|
this.currentWindow = this.nextWindow;
|
|
943
881
|
if (this.currentWindow) {
|
|
944
|
-
// Restore this.currentPresentation value since if this.removeCurrentWindow()
|
|
945
|
-
// was called then this.currentPresentation was set to null.
|
|
946
|
-
// This fixes an issue where publishing a playlist with single presentation results
|
|
947
|
-
// in two iFrames created. See CX-2602 for more details.
|
|
948
|
-
this.currentPresentation = nextPresentation;
|
|
949
882
|
this.currentWindow.onComplete(this.handleCurrentPresentationComplete);
|
|
950
883
|
this.currentWindow.onError(this.handleCurrentPresentationError);
|
|
951
884
|
this.currentWindow.onEnableInterruptLock(this.handleEnableInterruptLock);
|
|
952
885
|
this.currentWindow.onDisableInterruptLock(this.handleDisableInterruptLock);
|
|
953
|
-
this.currentWindow.onAnalyticsEvent(this.handleAnalyticsEvent);
|
|
954
|
-
this.currentWindow.onChargeRequest(this.handleChargeRequest);
|
|
955
886
|
}
|
|
956
887
|
// Play new current window.
|
|
957
888
|
this.playCurrentWindow();
|
|
@@ -984,7 +915,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
984
915
|
warnIfPreloadMismatch) {
|
|
985
916
|
// TODO: Handle the case when the next presentation isn't the preloaded window.
|
|
986
917
|
// This can happen when we support dynamic rule engine state.
|
|
987
|
-
logger.warn("The next presentation id '"
|
|
918
|
+
logger.warn("The next presentation id '" + nextPresentationId + "' doesnt match preloaded presentation id '" + this.nextPresentationId() + "'");
|
|
988
919
|
}
|
|
989
920
|
return { next: next, preview: preview };
|
|
990
921
|
};
|
|
@@ -1029,10 +960,10 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
1029
960
|
PlaylistWindowManager.prototype.emitWindowEvent = function (label, event, window, data) {
|
|
1030
961
|
var logger = this.options.logger;
|
|
1031
962
|
if (window) {
|
|
1032
|
-
this.emit(event, __assign(
|
|
963
|
+
this.emit(event, __assign({}, window.metadata(), { data: data }));
|
|
1033
964
|
}
|
|
1034
965
|
else {
|
|
1035
|
-
logger.warn("Attempted to emit "
|
|
966
|
+
logger.warn("Attempted to emit " + label + " window event but window not set");
|
|
1036
967
|
}
|
|
1037
968
|
};
|
|
1038
969
|
PlaylistWindowManager.prototype.emitCurrentWindowEvent = function (event, data) {
|
|
@@ -1043,12 +974,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
1043
974
|
};
|
|
1044
975
|
PlaylistWindowManager.prototype.emitCurrentWindowErrorEvent = function (event, error) {
|
|
1045
976
|
return this.emitCurrentWindowEvent(event, {
|
|
1046
|
-
errorMessage: this.getErrorMessage(error)
|
|
977
|
+
errorMessage: this.getErrorMessage(error)
|
|
1047
978
|
});
|
|
1048
979
|
};
|
|
1049
980
|
PlaylistWindowManager.prototype.emitNextWindowErrorEvent = function (event, error) {
|
|
1050
981
|
return this.emitNextWindowEvent(event, {
|
|
1051
|
-
errorMessage: this.getErrorMessage(error)
|
|
982
|
+
errorMessage: this.getErrorMessage(error)
|
|
1052
983
|
});
|
|
1053
984
|
};
|
|
1054
985
|
PlaylistWindowManager.prototype.getErrorMessage = function (error) {
|
|
@@ -25,7 +25,7 @@ var PlaylistWindowManagerState = /** @class */ (function () {
|
|
|
25
25
|
PlaylistWindowManagerState.prototype.getPresentation = function (presentationId) {
|
|
26
26
|
var presentation = this.options.presentations[presentationId];
|
|
27
27
|
if (!presentation) {
|
|
28
|
-
throw new Error("Failed to create window, missing presentation for '"
|
|
28
|
+
throw new Error("Failed to create window, missing presentation for '" + presentationId + "'");
|
|
29
29
|
}
|
|
30
30
|
return presentation;
|
|
31
31
|
};
|
|
@@ -35,7 +35,7 @@ var PlaylistWindowManagerState = /** @class */ (function () {
|
|
|
35
35
|
PlaylistWindowManagerState.prototype.getApplicationVersion = function (applicationVersionId) {
|
|
36
36
|
var applicationVersion = this.options.applicationVersions[applicationVersionId];
|
|
37
37
|
if (!applicationVersion) {
|
|
38
|
-
throw new Error("Failed to create window, missing application version for "
|
|
38
|
+
throw new Error("Failed to create window, missing application version for " + applicationVersionId);
|
|
39
39
|
}
|
|
40
40
|
return applicationVersion;
|
|
41
41
|
};
|
|
@@ -45,7 +45,7 @@ var PlaylistWindowManagerState = /** @class */ (function () {
|
|
|
45
45
|
PlaylistWindowManagerState.prototype.getTheme = function (themeId) {
|
|
46
46
|
var theme = this.options.themes[themeId];
|
|
47
47
|
if (!theme) {
|
|
48
|
-
throw new Error("Failed to create window, missing theme for '"
|
|
48
|
+
throw new Error("Failed to create window, missing theme for '" + themeId + "'");
|
|
49
49
|
}
|
|
50
50
|
return theme;
|
|
51
51
|
};
|