@raydiant/playlist-window-manager 0.21.2 → 0.21.3
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/package.json +1 -1
- package/src/PresentationWindow.ts +1 -1
- package/build/BrowserViewRenderer.d.ts +0 -19
- package/build/BrowserViewRenderer.js +0 -212
- package/build/BrowserWindowRenderer.d.ts +0 -47
- package/build/BrowserWindowRenderer.js +0 -521
- package/build/IFrameRenderer.d.ts +0 -20
- package/build/IFrameRenderer.js +0 -226
- package/build/PlaylistWindowManager.d.ts +0 -106
- package/build/PlaylistWindowManager.js +0 -1017
- package/build/PlaylistWindowManagerState.d.ts +0 -28
- package/build/PlaylistWindowManagerState.js +0 -60
- package/build/PresentationWindow.d.ts +0 -142
- package/build/PresentationWindow.js +0 -1138
- package/build/PresentationWindow.test.d.ts +0 -1
- package/build/PresentationWindow.test.js +0 -241
- package/build/WindowLoadError.d.ts +0 -3
- package/build/WindowLoadError.js +0 -29
- package/build/WindowTimeoutError.d.ts +0 -3
- package/build/WindowTimeoutError.js +0 -29
- package/build/WindowUnresponsiveError.d.ts +0 -3
- package/build/WindowUnresponsiveError.js +0 -29
- package/build/embeddedApps.d.ts +0 -2
- package/build/embeddedApps.js +0 -59
- package/build/embeddedApps.test.d.ts +0 -1
- package/build/embeddedApps.test.js +0 -123
- package/build/index.d.ts +0 -10
- package/build/index.js +0 -30
- package/build/preload.d.ts +0 -1
- package/build/preload.js +0 -20
- package/build/testUtils.d.ts +0 -43
- package/build/testUtils.js +0 -208
- package/build/types.d.ts +0 -142
- package/build/types.js +0 -2
package/build/IFrameRenderer.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var namespace = 'raydiant';
|
|
40
|
-
var IFrameRenderer = /** @class */ (function () {
|
|
41
|
-
function IFrameRenderer(container) {
|
|
42
|
-
var _this = this;
|
|
43
|
-
this.container = container;
|
|
44
|
-
this.windows = {};
|
|
45
|
-
this.globalMessageHandler = function (event) {
|
|
46
|
-
// Ignore messages that don't start with the message prefix.
|
|
47
|
-
if (typeof event.data === 'string' && event.data.startsWith(namespace)) {
|
|
48
|
-
var _a = _this.deserializeMessage(event.data), windowId = _a.windowId, type = _a.type, payload = _a.payload;
|
|
49
|
-
if (!windowId || !type) {
|
|
50
|
-
console.warn("Invalid message received from child window '".concat(event.data, "'"));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
var window_1 = _this.getWindow(windowId);
|
|
54
|
-
if (!window_1) {
|
|
55
|
-
throw new Error("Failed add receive message callback to window, window with window id: '".concat(windowId, "' was not found"));
|
|
56
|
-
}
|
|
57
|
-
if (window_1.receiveMessageCallback) {
|
|
58
|
-
window_1.receiveMessageCallback(type, payload);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
// Post message is a single channel for all window so we need to
|
|
63
|
-
// attach a global message handler that forwards the event to the
|
|
64
|
-
// correct window.
|
|
65
|
-
window.addEventListener('message', this.globalMessageHandler, false);
|
|
66
|
-
}
|
|
67
|
-
IFrameRenderer.prototype.createWindow = function (_a) {
|
|
68
|
-
var windowId = _a.windowId, bounds = _a.bounds, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? 'black' : _b, receiveMessageCallback = _a.receiveMessageCallback;
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var frame;
|
|
71
|
-
return __generator(this, function (_c) {
|
|
72
|
-
frame = document.createElement('iframe');
|
|
73
|
-
this.windows[windowId] = { frame: frame, receiveMessageCallback: receiveMessageCallback };
|
|
74
|
-
frame.setAttribute('data-windowId', windowId);
|
|
75
|
-
// Set the allowed permissions for the iframe.
|
|
76
|
-
// * allows any loaded domain to have access, which is required for
|
|
77
|
-
// third-party sites loaded into the iframe.
|
|
78
|
-
frame.allow = 'microphone *; camera *; autoplay';
|
|
79
|
-
// Default styles.
|
|
80
|
-
frame.style.position = 'absolute';
|
|
81
|
-
frame.style.zIndex = '0';
|
|
82
|
-
frame.style.border = 'none';
|
|
83
|
-
// Position will be 0,0 for the main window.
|
|
84
|
-
if (bounds) {
|
|
85
|
-
frame.style.top = "".concat(bounds.y, "px");
|
|
86
|
-
frame.style.left = "".concat(bounds.x, "px");
|
|
87
|
-
frame.style.width = "".concat(bounds.width, "px");
|
|
88
|
-
frame.style.height = "".concat(bounds.height, "px");
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// If bounds assume fullscreen.
|
|
92
|
-
frame.style.top = '0px';
|
|
93
|
-
frame.style.left = '0px';
|
|
94
|
-
frame.style.width = '100%';
|
|
95
|
-
frame.style.height = '100%';
|
|
96
|
-
}
|
|
97
|
-
if (backgroundColor) {
|
|
98
|
-
frame.style.backgroundColor = backgroundColor;
|
|
99
|
-
}
|
|
100
|
-
// Set initial visibility and send to background.
|
|
101
|
-
frame.style.zIndex = '0';
|
|
102
|
-
frame.style.visibility = 'hidden';
|
|
103
|
-
this.container.appendChild(frame);
|
|
104
|
-
return [2 /*return*/];
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
IFrameRenderer.prototype.loadWindow = function (windowId, url) {
|
|
109
|
-
var window = this.getWindow(windowId);
|
|
110
|
-
if (!window) {
|
|
111
|
-
throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
|
|
112
|
-
}
|
|
113
|
-
// Return a promise that resolves then the window has successfully loaded.
|
|
114
|
-
return new Promise(function (resolve, reject) {
|
|
115
|
-
window.frame.onload = function () {
|
|
116
|
-
resolve();
|
|
117
|
-
};
|
|
118
|
-
window.frame.onerror = function () {
|
|
119
|
-
reject(new Error("Error loading window for '".concat(url, "'")));
|
|
120
|
-
};
|
|
121
|
-
window.frame.src = url;
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
IFrameRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
|
|
125
|
-
var window = this.getWindow(windowId);
|
|
126
|
-
if (!window) {
|
|
127
|
-
throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
|
|
128
|
-
}
|
|
129
|
-
window.frame.style.top = "".concat(bounds.y, "px");
|
|
130
|
-
window.frame.style.left = "".concat(bounds.x, "px");
|
|
131
|
-
window.frame.style.width = "".concat(bounds.width, "px");
|
|
132
|
-
window.frame.style.height = "".concat(bounds.height, "px");
|
|
133
|
-
};
|
|
134
|
-
IFrameRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
135
|
-
var window = this.getWindow(windowId);
|
|
136
|
-
if (!window) {
|
|
137
|
-
throw new Error("Failed to show window, missing window id '".concat(windowId, "'"));
|
|
138
|
-
}
|
|
139
|
-
window.frame.style.zIndex = '9999';
|
|
140
|
-
window.frame.style.visibility = 'visible';
|
|
141
|
-
if (isFocused) {
|
|
142
|
-
window.frame.focus();
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
IFrameRenderer.prototype.hideWindow = function (windowId) {
|
|
146
|
-
var window = this.getWindow(windowId);
|
|
147
|
-
if (!window) {
|
|
148
|
-
throw new Error("Failed to hide window, missing window id '".concat(windowId, "'"));
|
|
149
|
-
}
|
|
150
|
-
window.frame.style.zIndex = '0';
|
|
151
|
-
window.frame.style.visibility = 'hidden';
|
|
152
|
-
};
|
|
153
|
-
IFrameRenderer.prototype.removeWindow = function (windowId) {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
-
var window;
|
|
156
|
-
return __generator(this, function (_a) {
|
|
157
|
-
window = this.getWindow(windowId);
|
|
158
|
-
if (!window) {
|
|
159
|
-
throw new Error("Failed to remove window, missing window id '".concat(windowId, "'"));
|
|
160
|
-
}
|
|
161
|
-
this.container.removeChild(window.frame);
|
|
162
|
-
delete this.windows[windowId];
|
|
163
|
-
return [2 /*return*/];
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
IFrameRenderer.prototype.sendMessageString = function (windowId, message) {
|
|
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) {
|
|
178
|
-
var window = this.getWindow(windowId);
|
|
179
|
-
if (!window) {
|
|
180
|
-
throw new Error("Failed to send message '".concat(type, "', missing window id '").concat(windowId, "'"));
|
|
181
|
-
}
|
|
182
|
-
if (!window.frame.contentWindow) {
|
|
183
|
-
throw new Error("Failed to send message '".concat(type, "', contentWindow missing for '").concat(windowId, "'"));
|
|
184
|
-
}
|
|
185
|
-
window.frame.contentWindow.postMessage({ namespace: namespace, windowId: windowId, type: type, payload: payload }, '*');
|
|
186
|
-
};
|
|
187
|
-
IFrameRenderer.prototype.muteWindow = function (windowId) {
|
|
188
|
-
var window = this.getWindow(windowId);
|
|
189
|
-
if (!window) {
|
|
190
|
-
throw new Error("Failed to mute window, missing window id '".concat(windowId, "'"));
|
|
191
|
-
}
|
|
192
|
-
// There is no mute/unmute API for iframes so we rely on the window manager overriding any
|
|
193
|
-
// mute presentation properties.
|
|
194
|
-
};
|
|
195
|
-
IFrameRenderer.prototype.unMuteWindow = function (windowId) {
|
|
196
|
-
var window = this.getWindow(windowId);
|
|
197
|
-
if (!window) {
|
|
198
|
-
throw new Error("Failed to unmute window, missing window id '".concat(windowId, "'"));
|
|
199
|
-
}
|
|
200
|
-
// There is no mute/unmute API for iframes so we rely on the window manager overriding any
|
|
201
|
-
// mute presentation properties.
|
|
202
|
-
};
|
|
203
|
-
IFrameRenderer.prototype.destroy = function () {
|
|
204
|
-
window.removeEventListener('message', this.globalMessageHandler, false);
|
|
205
|
-
};
|
|
206
|
-
IFrameRenderer.prototype.getWindow = function (windowId) {
|
|
207
|
-
return this.windows[windowId];
|
|
208
|
-
};
|
|
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
|
-
return IFrameRenderer;
|
|
225
|
-
}());
|
|
226
|
-
exports.default = IFrameRenderer;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import * as RE from '@raydiant/playlist-rule-engine';
|
|
2
|
-
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { PresentationWindowRenderer, Device, WindowBounds, Theme, Logger, WorkerState } from './types';
|
|
4
|
-
import PlaylistWindowManagerState from './PlaylistWindowManagerState';
|
|
5
|
-
export interface PlaylistWindowManagerOptions {
|
|
6
|
-
ruleEngine: RE.RuleEngine;
|
|
7
|
-
state: PlaylistWindowManagerState;
|
|
8
|
-
logger: Logger;
|
|
9
|
-
device?: Device;
|
|
10
|
-
readyTimeoutDurationSeconds?: number;
|
|
11
|
-
appRendererUrl?: string;
|
|
12
|
-
bounds?: WindowBounds;
|
|
13
|
-
backgroundColor?: string;
|
|
14
|
-
themeOverride?: Theme;
|
|
15
|
-
forceMute?: boolean;
|
|
16
|
-
parentWindowId?: string;
|
|
17
|
-
windowName?: string;
|
|
18
|
-
isPreview?: boolean;
|
|
19
|
-
onEnableInterruptLock?: () => void;
|
|
20
|
-
onDisableInterruptLock?: () => void;
|
|
21
|
-
}
|
|
22
|
-
export default class PlaylistWindowManager extends EventEmitter {
|
|
23
|
-
private options;
|
|
24
|
-
private currentPresentation;
|
|
25
|
-
private nextPresentation;
|
|
26
|
-
private overrideNextPresentation;
|
|
27
|
-
private currentWindow;
|
|
28
|
-
private nextWindow;
|
|
29
|
-
private hasPendingInterrupt;
|
|
30
|
-
private ruleEngine;
|
|
31
|
-
private state;
|
|
32
|
-
private renderer;
|
|
33
|
-
private restartCurrentWindowOnEnd;
|
|
34
|
-
private shouldHardRestart;
|
|
35
|
-
private currentWindowError;
|
|
36
|
-
private interruptCheckTimeout;
|
|
37
|
-
private currentPresentationCompleteTimeout;
|
|
38
|
-
private lastCompleteAt;
|
|
39
|
-
private bounds?;
|
|
40
|
-
private themeOverride?;
|
|
41
|
-
private forceMute;
|
|
42
|
-
private isFocused;
|
|
43
|
-
private workerState;
|
|
44
|
-
constructor(options: PlaylistWindowManagerOptions);
|
|
45
|
-
private currentPresentationId;
|
|
46
|
-
private nextPresentationId;
|
|
47
|
-
load(): Promise<void>;
|
|
48
|
-
isEmpty(): boolean;
|
|
49
|
-
play(): void;
|
|
50
|
-
isPlaying(): boolean;
|
|
51
|
-
pause(): void;
|
|
52
|
-
resume(): void;
|
|
53
|
-
blur(): void;
|
|
54
|
-
isPaused(): boolean;
|
|
55
|
-
getRenderer(): PresentationWindowRenderer | null;
|
|
56
|
-
setRenderer(renderer: PresentationWindowRenderer | null): void;
|
|
57
|
-
getRuleEngine(): RE.RuleEngine | null;
|
|
58
|
-
setRuleEngine(ruleEngine: RE.RuleEngine): Promise<void>;
|
|
59
|
-
getState(): PlaylistWindowManagerState | null;
|
|
60
|
-
setState(state: PlaylistWindowManagerState): void;
|
|
61
|
-
reinitializeRuleEngineState(newRulesDataStoreObj: RE.RulesDataStore): void;
|
|
62
|
-
reinitialize(state: PlaylistWindowManagerState, ruleEngine: RE.RuleEngine, shouldInterruptPlayback: boolean): Promise<void>;
|
|
63
|
-
private registerInterrupt;
|
|
64
|
-
endCurrentPresentation(): void;
|
|
65
|
-
destroy(): Promise<void>;
|
|
66
|
-
updateBounds(bounds: WindowBounds): void;
|
|
67
|
-
getBounds(): WindowBounds | undefined;
|
|
68
|
-
setThemeOverride(theme?: Theme): void;
|
|
69
|
-
getThemeOverride(): Theme | undefined;
|
|
70
|
-
setForceMute(forceMute: boolean): void;
|
|
71
|
-
getForceMute(): boolean;
|
|
72
|
-
reload(): void;
|
|
73
|
-
show(isFocused?: boolean): Promise<void>;
|
|
74
|
-
hide(): Promise<void>;
|
|
75
|
-
isReady(): boolean;
|
|
76
|
-
isLocked(): boolean;
|
|
77
|
-
runWorkerSubscriptions(state: WorkerState): void;
|
|
78
|
-
private createWindow;
|
|
79
|
-
private loadCurrentWindow;
|
|
80
|
-
private shouldPreload;
|
|
81
|
-
private preloadNextWindow;
|
|
82
|
-
private playCurrentWindow;
|
|
83
|
-
private pauseCurrentWindow;
|
|
84
|
-
private resumeCurrentWindow;
|
|
85
|
-
private restartCurrentWindow;
|
|
86
|
-
private removeCurrentWindow;
|
|
87
|
-
private removeNextWindow;
|
|
88
|
-
private swapWindows;
|
|
89
|
-
private evalRuleEngine;
|
|
90
|
-
private handleEnableInterruptLock;
|
|
91
|
-
private handleDisableInterruptLock;
|
|
92
|
-
private handleAnalyticsEvent;
|
|
93
|
-
private handleCurrentPresentationComplete;
|
|
94
|
-
private handleCurrentPresentationError;
|
|
95
|
-
private handleNextPresentationError;
|
|
96
|
-
private checkPreviewAction;
|
|
97
|
-
private startPreviewCheck;
|
|
98
|
-
private stopInterruptCheck;
|
|
99
|
-
private getTheme;
|
|
100
|
-
private emitWindowEvent;
|
|
101
|
-
private emitCurrentWindowEvent;
|
|
102
|
-
private emitNextWindowEvent;
|
|
103
|
-
private emitCurrentWindowErrorEvent;
|
|
104
|
-
private emitNextWindowErrorEvent;
|
|
105
|
-
private getErrorMessage;
|
|
106
|
-
}
|