@raydiant/playlist-window-manager 0.0.0-test-27 → 0.0.0-test-29
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 +1 -1
- package/build/BrowserViewRenderer.js +1 -5
- package/build/BrowserWindowRenderer.d.ts +0 -9
- package/build/BrowserWindowRenderer.js +18 -174
- package/build/PlaylistWindowManager.d.ts +6 -1
- package/build/PlaylistWindowManager.js +39 -2
- package/build/PresentationWindow.d.ts +8 -1
- package/build/PresentationWindow.js +101 -9
- package/build/PresentationWindow.test.js +99 -0
- package/build/testUtils.js +1 -0
- package/build/types.d.ts +20 -1
- package/package.json +6 -8
- package/src/BrowserViewRenderer.ts +1 -18
- package/src/BrowserWindowRenderer.ts +28 -307
- package/src/PlaylistWindowManager.ts +59 -13
- package/src/PresentationWindow.test.ts +112 -0
- package/src/PresentationWindow.ts +128 -34
- package/src/testUtils.ts +1 -0
- package/src/types.ts +24 -1
- package/tasks/npm-publish.sh +1 -1
- package/build/boundUtils.d.ts +0 -3
- package/build/boundUtils.js +0 -16
- package/src/boundUtils.ts +0 -21
|
@@ -5,7 +5,7 @@ export default class BrowserViewRenderer implements PresentationWindowRenderer {
|
|
|
5
5
|
private offscreenWindow;
|
|
6
6
|
private windows;
|
|
7
7
|
constructor(mainWindow: BrowserWindow, offscreenWindow: BrowserWindow);
|
|
8
|
-
createWindow({ windowId, parentWindowId, bounds,
|
|
8
|
+
createWindow({ windowId, parentWindowId, bounds, backgroundColor, receiveMessageCallback, }: CreateWindowOptions): Promise<void>;
|
|
9
9
|
loadWindow(windowId: string, url: string): Promise<void>;
|
|
10
10
|
updateWindowBounds(windowId: string, bounds: WindowBounds): void;
|
|
11
11
|
showWindow(windowId: string, isFocused: boolean): void;
|
|
@@ -79,11 +79,10 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
79
79
|
this.windows = {};
|
|
80
80
|
}
|
|
81
81
|
BrowserViewRenderer.prototype.createWindow = function (_a) {
|
|
82
|
-
var windowId = _a.windowId, parentWindowId = _a.parentWindowId, bounds = _a.bounds,
|
|
82
|
+
var windowId = _a.windowId, parentWindowId = _a.parentWindowId, bounds = _a.bounds, backgroundColor = _a.backgroundColor, receiveMessageCallback = _a.receiveMessageCallback;
|
|
83
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
84
|
var window;
|
|
85
85
|
return __generator(this, function (_b) {
|
|
86
|
-
logger.info("playlist-window-manager/src/BrowserViewRenderer.ts createWindow1 ".concat(JSON.stringify(bounds || __assign(__assign({}, this.mainWindow.getBounds()), { x: 0, y: 0 }))));
|
|
87
86
|
window = {
|
|
88
87
|
view: new electron_1.BrowserView({
|
|
89
88
|
webPreferences: {
|
|
@@ -100,9 +99,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
100
99
|
this.windows[windowId] = window;
|
|
101
100
|
electron_1.ipcMain.on(windowId, window.receiveMessageCallback);
|
|
102
101
|
this.offscreenWindow.addBrowserView(window.view);
|
|
103
|
-
logger.info("playlist-window-manager/src/BrowserViewRenderer.ts createWindow2 ".concat(JSON.stringify(window.bounds)));
|
|
104
102
|
window.view.setBounds(window.bounds);
|
|
105
|
-
logger.info("playlist-window-manager/src/BrowserViewRenderer.ts createWindow3 ".concat(JSON.stringify(window.view.getBounds())));
|
|
106
103
|
if (backgroundColor) {
|
|
107
104
|
window.view.setBackgroundColor(backgroundColor);
|
|
108
105
|
}
|
|
@@ -141,7 +138,6 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
141
138
|
if (!window) {
|
|
142
139
|
throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
|
|
143
140
|
}
|
|
144
|
-
// TODO log bounds
|
|
145
141
|
window.bounds = bounds;
|
|
146
142
|
window.view.setBounds(window.bounds);
|
|
147
143
|
};
|
|
@@ -16,7 +16,6 @@ interface BrowserWindowRendererOptions {
|
|
|
16
16
|
export default class BrowserWindowRenderer implements PresentationWindowRenderer {
|
|
17
17
|
private opts;
|
|
18
18
|
private windows;
|
|
19
|
-
private windowsBounds;
|
|
20
19
|
private windowCrashHandler;
|
|
21
20
|
private browserWindowPool;
|
|
22
21
|
private browserViewPool;
|
|
@@ -34,15 +33,7 @@ export default class BrowserWindowRenderer implements PresentationWindowRenderer
|
|
|
34
33
|
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
35
34
|
muteWindow(windowId: string): void;
|
|
36
35
|
unMuteWindow(windowId: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* This function is designed to solve missing 1px issue.
|
|
39
|
-
* If we set 1920x1080 bounds on 1920x1080 display
|
|
40
|
-
* then the actual BrowserWindow resolution would be
|
|
41
|
-
* 1919x1079.
|
|
42
|
-
*/
|
|
43
|
-
private setWindowOrViewBounds;
|
|
44
36
|
private getWindow;
|
|
45
|
-
private getWindowBounds;
|
|
46
37
|
private moveWindowOffscreen;
|
|
47
38
|
private addWindowToParent;
|
|
48
39
|
private removeWindowFromParent;
|
|
@@ -75,34 +75,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
76
|
var path = __importStar(require("path"));
|
|
77
77
|
var electron_1 = require("electron");
|
|
78
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
79
78
|
var WindowUnresponsiveError_1 = __importDefault(require("./WindowUnresponsiveError"));
|
|
80
|
-
var boundUtils_1 = require("./boundUtils");
|
|
81
79
|
var BrowserWindowRenderer = /** @class */ (function () {
|
|
82
80
|
function BrowserWindowRenderer(opts) {
|
|
83
81
|
this.opts = opts;
|
|
84
82
|
this.windows = {};
|
|
85
|
-
this.windowsBounds = {};
|
|
86
83
|
this.windowCrashHandler = function (_) { };
|
|
87
84
|
this.browserWindowPool = new WindowPool();
|
|
88
85
|
this.browserViewPool = new WindowPool();
|
|
89
86
|
// Create a hidden window to preload BrowserViews.
|
|
90
|
-
this.offscreenWindow = new electron_1.BrowserWindow(
|
|
87
|
+
this.offscreenWindow = new electron_1.BrowserWindow({
|
|
88
|
+
show: false,
|
|
89
|
+
frame: this.opts.frame,
|
|
90
|
+
hasShadow: this.opts.hasShadow,
|
|
91
|
+
webPreferences: {
|
|
91
92
|
preload: path.join(__dirname, 'preload.js'),
|
|
92
|
-
|
|
93
|
+
contextIsolation: false,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
93
96
|
this.proxySettings = null;
|
|
94
|
-
this.
|
|
95
|
-
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor1 ".concat(JSON.stringify(opts.bounds)));
|
|
96
|
-
this.setWindowOrViewBounds(this.offscreenWindow, opts.bounds);
|
|
97
|
-
opts.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts constructor2 ".concat(JSON.stringify({
|
|
98
|
-
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
99
|
-
bounds: this.offscreenWindow.getBounds(),
|
|
100
|
-
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
101
|
-
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
102
|
-
})));
|
|
97
|
+
this.offscreenWindow.setBounds(opts.bounds);
|
|
103
98
|
if (opts.proxySettings) {
|
|
104
99
|
this.proxySettings = opts.proxySettings;
|
|
105
100
|
}
|
|
101
|
+
this.logger = opts.logger;
|
|
106
102
|
if (opts.windowCrashHandler) {
|
|
107
103
|
this.windowCrashHandler = opts.windowCrashHandler;
|
|
108
104
|
}
|
|
@@ -110,14 +106,11 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
110
106
|
BrowserWindowRenderer.prototype.createWindow = function (_a) {
|
|
111
107
|
var windowId = _a.windowId, parentWindowId = _a.parentWindowId, _b = _a.bounds, bounds = _b === void 0 ? this.opts.bounds : _b, backgroundColor = _a.backgroundColor, receiveMessageCallback = _a.receiveMessageCallback, errorCallback = _a.errorCallback;
|
|
112
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
-
var
|
|
109
|
+
var window;
|
|
114
110
|
var _this = this;
|
|
115
111
|
return __generator(this, function (_c) {
|
|
116
112
|
switch (_c.label) {
|
|
117
113
|
case 0:
|
|
118
|
-
windowBounds = parentWindowId && !this.opts.renderChildWindowsAsBrowserViews
|
|
119
|
-
? __assign(__assign({}, bounds), { x: bounds.x + this.opts.bounds.x, y: bounds.y + this.opts.bounds.y }) : bounds;
|
|
120
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow1: ".concat(JSON.stringify(windowBounds)));
|
|
121
114
|
window = {
|
|
122
115
|
parentWindowId: parentWindowId,
|
|
123
116
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is true,
|
|
@@ -131,7 +124,6 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
131
124
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
132
125
|
show: false,
|
|
133
126
|
frame: this.opts.frame,
|
|
134
|
-
fullscreen: (0, boundUtils_1.isFullscreen)(this.opts.bounds),
|
|
135
127
|
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
136
128
|
// because the parent can't be changed after creating the BrowserWindow.
|
|
137
129
|
parent: parentWindowId
|
|
@@ -141,13 +133,15 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
141
133
|
hasShadow: this.opts.hasShadow,
|
|
142
134
|
webPreferences: {
|
|
143
135
|
preload: path.join(__dirname, 'preload.js'),
|
|
136
|
+
contextIsolation: false,
|
|
144
137
|
},
|
|
145
138
|
}),
|
|
146
139
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
147
140
|
// we are rendering child windows with BrowserWindow. BrowserWindows are positioned absolutely so
|
|
148
141
|
// to place them in the correct spot relative to their parent we need to add the main window's x / y.
|
|
149
142
|
// BrowserViews are relatively positioned so we don't need to do that.
|
|
150
|
-
bounds:
|
|
143
|
+
bounds: parentWindowId && !this.opts.renderChildWindowsAsBrowserViews
|
|
144
|
+
? __assign(__assign({}, bounds), { x: bounds.x + this.opts.bounds.x, y: bounds.y + this.opts.bounds.y }) : bounds,
|
|
151
145
|
receiveMessageCallback: function (_, type, payload) {
|
|
152
146
|
if (receiveMessageCallback) {
|
|
153
147
|
receiveMessageCallback(type, payload);
|
|
@@ -171,15 +165,8 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
171
165
|
window.view.webContents.on('unresponsive', window.unresponsiveCallback);
|
|
172
166
|
if (window.view instanceof electron_1.BrowserView) {
|
|
173
167
|
this.moveWindowOffscreen(window);
|
|
174
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow2: ".concat(JSON.stringify({
|
|
175
|
-
fullscreen: this.offscreenWindow.isFullScreen(),
|
|
176
|
-
bounds: this.offscreenWindow.getBounds(),
|
|
177
|
-
normalBounds: this.offscreenWindow.getNormalBounds(),
|
|
178
|
-
contentBounds: this.offscreenWindow.getContentBounds(),
|
|
179
|
-
})));
|
|
180
168
|
}
|
|
181
169
|
this.windows[windowId] = window;
|
|
182
|
-
this.windowsBounds[windowId] = lodash_1.default.cloneDeep(windowBounds);
|
|
183
170
|
// Listen for messages from window.
|
|
184
171
|
electron_1.ipcMain.on(windowId, window.receiveMessageCallback);
|
|
185
172
|
if (backgroundColor) {
|
|
@@ -187,35 +174,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
187
174
|
// Electron issue: https://github.com/electron/electron/issues/20357
|
|
188
175
|
window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
|
|
189
176
|
}
|
|
190
|
-
|
|
191
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow4: ".concat(JSON.stringify({
|
|
192
|
-
newBounds: window.bounds,
|
|
193
|
-
fullscreen: window.view.isFullScreen(),
|
|
194
|
-
bounds: window.view.getBounds(),
|
|
195
|
-
contentBounds: window.view.getContentBounds(),
|
|
196
|
-
normalBounds: window.view.getNormalBounds(),
|
|
197
|
-
})));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow5: ".concat(JSON.stringify({
|
|
201
|
-
newBounds: window.bounds,
|
|
202
|
-
bounds: window.view.getBounds(),
|
|
203
|
-
})));
|
|
204
|
-
}
|
|
205
|
-
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
206
|
-
if (window.view instanceof electron_1.BrowserWindow) {
|
|
207
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow7: ".concat(JSON.stringify({
|
|
208
|
-
fullscreen: window.view.isFullScreen(),
|
|
209
|
-
bounds: window.view.getBounds(),
|
|
210
|
-
contentBounds: window.view.getContentBounds(),
|
|
211
|
-
normalBounds: window.view.getNormalBounds(),
|
|
212
|
-
})));
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createWindow8: ".concat(JSON.stringify({
|
|
216
|
-
bounds: window.view.getBounds(),
|
|
217
|
-
})));
|
|
218
|
-
}
|
|
177
|
+
window.view.setBounds(window.bounds);
|
|
219
178
|
if (!this.proxySettings) return [3 /*break*/, 2];
|
|
220
179
|
return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
|
|
221
180
|
case 1:
|
|
@@ -253,54 +212,22 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
253
212
|
if (!window) {
|
|
254
213
|
throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
|
|
255
214
|
}
|
|
256
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds1: ".concat(JSON.stringify(bounds)));
|
|
257
215
|
window.bounds = bounds;
|
|
258
216
|
if (window.view instanceof electron_1.BrowserWindow && window.parentWindowId) {
|
|
259
217
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
260
218
|
// x/y to when updating the child window's bounds.
|
|
261
|
-
|
|
262
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds2: ".concat(JSON.stringify(newBounds)));
|
|
263
|
-
this.setWindowOrViewBounds(window.view, newBounds);
|
|
264
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds3: ".concat(JSON.stringify({
|
|
265
|
-
fullscreen: window.view.isFullScreen(),
|
|
266
|
-
bounds: window.view.getBounds(),
|
|
267
|
-
normalBounds: window.view.getNormalBounds(),
|
|
268
|
-
contentBounds: window.view.getContentBounds(),
|
|
269
|
-
})));
|
|
219
|
+
window.view.setBounds(__assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y }));
|
|
270
220
|
}
|
|
271
221
|
else {
|
|
272
|
-
|
|
273
|
-
this.setWindowOrViewBounds(window.view, window.bounds);
|
|
274
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts updateWindowBounds5: ".concat(JSON.stringify(window.view.getBounds())));
|
|
222
|
+
window.view.setBounds(window.bounds);
|
|
275
223
|
}
|
|
276
224
|
};
|
|
277
225
|
BrowserWindowRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
278
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts showWindow1: ".concat(windowId));
|
|
279
226
|
var window = this.getWindow(windowId);
|
|
280
|
-
|
|
281
|
-
if (!window || !windowBounds) {
|
|
227
|
+
if (!window) {
|
|
282
228
|
throw new Error("Failed to show window, missing window id '".concat(windowId, "'"));
|
|
283
229
|
}
|
|
284
230
|
if (window.view instanceof electron_1.BrowserWindow) {
|
|
285
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts showWindow2: ".concat(JSON.stringify({
|
|
286
|
-
fullscreen: window.view.isFullScreen(),
|
|
287
|
-
isMaximized: window.view.isMaximized(),
|
|
288
|
-
bounds: window.view.getBounds(),
|
|
289
|
-
windowBounds: windowBounds,
|
|
290
|
-
normalBounds: window.view.getNormalBounds(),
|
|
291
|
-
contentBounds: window.view.getContentBounds(),
|
|
292
|
-
})));
|
|
293
|
-
if (!(0, boundUtils_1.areBoundsEqual)(window.view.getBounds(), windowBounds)) {
|
|
294
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts showWindow3: setWindowOrViewBounds");
|
|
295
|
-
this.setWindowOrViewBounds(window.view, windowBounds);
|
|
296
|
-
}
|
|
297
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts showWindow4: ".concat(JSON.stringify({
|
|
298
|
-
fullscreen: window.view.isFullScreen(),
|
|
299
|
-
isMaximized: window.view.isMaximized(),
|
|
300
|
-
bounds: window.view.getBounds(),
|
|
301
|
-
normalBounds: window.view.getNormalBounds(),
|
|
302
|
-
contentBounds: window.view.getContentBounds(),
|
|
303
|
-
})));
|
|
304
231
|
if (isFocused) {
|
|
305
232
|
window.view.show();
|
|
306
233
|
}
|
|
@@ -360,7 +287,6 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
360
287
|
_a.label = 4;
|
|
361
288
|
case 4:
|
|
362
289
|
delete this.windows[windowId];
|
|
363
|
-
delete this.windowsBounds[windowId];
|
|
364
290
|
if (this.opts.useWindowPool) {
|
|
365
291
|
this.logPoolStats();
|
|
366
292
|
}
|
|
@@ -397,81 +323,9 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
397
323
|
}
|
|
398
324
|
window.view.webContents.setAudioMuted(false);
|
|
399
325
|
};
|
|
400
|
-
/**
|
|
401
|
-
* This function is designed to solve missing 1px issue.
|
|
402
|
-
* If we set 1920x1080 bounds on 1920x1080 display
|
|
403
|
-
* then the actual BrowserWindow resolution would be
|
|
404
|
-
* 1919x1079.
|
|
405
|
-
*/
|
|
406
|
-
BrowserWindowRenderer.prototype.setWindowOrViewBounds = function (window, bounds) {
|
|
407
|
-
if (window instanceof electron_1.BrowserView) {
|
|
408
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds1: ".concat(JSON.stringify({
|
|
409
|
-
windowBounds: window.getBounds(),
|
|
410
|
-
bounds: bounds,
|
|
411
|
-
})));
|
|
412
|
-
window.setBounds(bounds);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds2: ".concat(JSON.stringify({
|
|
416
|
-
newBounds: bounds,
|
|
417
|
-
fullscreen: window.isFullScreen(),
|
|
418
|
-
isMaximized: window.isMaximized(),
|
|
419
|
-
bounds: window.getBounds(),
|
|
420
|
-
contentBounds: window.getContentBounds(),
|
|
421
|
-
normalBounds: window.getNormalBounds(),
|
|
422
|
-
})));
|
|
423
|
-
// calling setBounds or setFullscreen may introduce -1px resolution error
|
|
424
|
-
// so we try to avoid unnecessary calls
|
|
425
|
-
if ((0, boundUtils_1.areBoundsEqual)(window.getBounds(), bounds)) {
|
|
426
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds3: bounds are equal");
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
if ((0, boundUtils_1.isFullscreen)(bounds) !== window.isFullScreen()) {
|
|
430
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds4: setFullScreen");
|
|
431
|
-
window.setFullScreen((0, boundUtils_1.isFullscreen)(bounds));
|
|
432
|
-
}
|
|
433
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds5: ".concat(JSON.stringify({
|
|
434
|
-
fullscreen: window.isFullScreen(),
|
|
435
|
-
isMaximized: window.isMaximized(),
|
|
436
|
-
bounds: window.getBounds(),
|
|
437
|
-
contentBounds: window.getContentBounds(),
|
|
438
|
-
normalBounds: window.getNormalBounds(),
|
|
439
|
-
})));
|
|
440
|
-
if (!(0, boundUtils_1.areBoundsEqual)(window.getBounds(), bounds)) {
|
|
441
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds6: setBounds");
|
|
442
|
-
window.setBounds(bounds);
|
|
443
|
-
}
|
|
444
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds7: ".concat(JSON.stringify({
|
|
445
|
-
fullscreen: window.isFullScreen(),
|
|
446
|
-
isMaximized: window.isMaximized(),
|
|
447
|
-
bounds: window.getBounds(),
|
|
448
|
-
contentBounds: window.getContentBounds(),
|
|
449
|
-
normalBounds: window.getNormalBounds(),
|
|
450
|
-
})));
|
|
451
|
-
if (window.isFullScreen() && !(0, boundUtils_1.isFullscreen)(window.getBounds())) {
|
|
452
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds8: maximize: ".concat(JSON.stringify({
|
|
453
|
-
fullscreen: window.isFullScreen(),
|
|
454
|
-
isMaximized: window.isMaximized(),
|
|
455
|
-
bounds: window.getBounds(),
|
|
456
|
-
contentBounds: window.getContentBounds(),
|
|
457
|
-
normalBounds: window.getNormalBounds(),
|
|
458
|
-
})));
|
|
459
|
-
window.maximize();
|
|
460
|
-
}
|
|
461
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts setWindowOrViewBounds9: ".concat(JSON.stringify({
|
|
462
|
-
fullscreen: window.isFullScreen(),
|
|
463
|
-
isMaximized: window.isMaximized(),
|
|
464
|
-
bounds: window.getBounds(),
|
|
465
|
-
contentBounds: window.getContentBounds(),
|
|
466
|
-
normalBounds: window.getNormalBounds(),
|
|
467
|
-
})));
|
|
468
|
-
};
|
|
469
326
|
BrowserWindowRenderer.prototype.getWindow = function (windowId) {
|
|
470
327
|
return this.windows[windowId];
|
|
471
328
|
};
|
|
472
|
-
BrowserWindowRenderer.prototype.getWindowBounds = function (windowId) {
|
|
473
|
-
return this.windowsBounds[windowId];
|
|
474
|
-
};
|
|
475
329
|
BrowserWindowRenderer.prototype.moveWindowOffscreen = function (window) {
|
|
476
330
|
if (!(window.view instanceof electron_1.BrowserView)) {
|
|
477
331
|
throw new Error("Failed move window offscreen, window is not a BrowserView");
|
|
@@ -545,13 +399,6 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
545
399
|
this.browserWindowPool.add(browserWindow);
|
|
546
400
|
}
|
|
547
401
|
}
|
|
548
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts createOrGetPooledBrowserWindow1: ".concat(JSON.stringify({
|
|
549
|
-
screen: electron_1.screen.getPrimaryDisplay().bounds,
|
|
550
|
-
fullscreen: browserWindow.isFullScreen(),
|
|
551
|
-
bounds: browserWindow.getBounds(),
|
|
552
|
-
contentBounds: browserWindow.getContentBounds(),
|
|
553
|
-
normalBounds: browserWindow.getNormalBounds(),
|
|
554
|
-
})));
|
|
555
402
|
return browserWindow;
|
|
556
403
|
};
|
|
557
404
|
BrowserWindowRenderer.prototype.destroyOrUnloadPooledBrowserWindow = function (windowId, browserWindow) {
|
|
@@ -559,9 +406,6 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
559
406
|
return __generator(this, function (_a) {
|
|
560
407
|
switch (_a.label) {
|
|
561
408
|
case 0:
|
|
562
|
-
this.logger.info("playlist-window-manager/src/BrowserWindowRenderer.ts destroyOrUnloadPooledBrowserWindow1: ".concat(JSON.stringify({
|
|
563
|
-
windowId: windowId,
|
|
564
|
-
})));
|
|
565
409
|
if (!this.opts.useWindowPool) return [3 /*break*/, 2];
|
|
566
410
|
this.hideWindow(windowId);
|
|
567
411
|
return [4 /*yield*/, browserWindow.webContents.loadURL('about:blank')];
|
|
@@ -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, WorkerState } from './types';
|
|
3
|
+
import { PresentationWindowRenderer, Device, WindowBounds, Theme, Logger, WorkerState, Charge, ChargeResponse, Terminal } from './types';
|
|
4
4
|
import PlaylistWindowManagerState from './PlaylistWindowManagerState';
|
|
5
5
|
export interface PlaylistWindowManagerOptions {
|
|
6
6
|
ruleEngine: RE.RuleEngine;
|
|
@@ -18,6 +18,7 @@ export interface PlaylistWindowManagerOptions {
|
|
|
18
18
|
isPreview?: boolean;
|
|
19
19
|
onEnableInterruptLock?: () => void;
|
|
20
20
|
onDisableInterruptLock?: () => void;
|
|
21
|
+
getTerminal?: () => Terminal | null;
|
|
21
22
|
}
|
|
22
23
|
export default class PlaylistWindowManager extends EventEmitter {
|
|
23
24
|
private options;
|
|
@@ -75,6 +76,9 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
75
76
|
isReady(): boolean;
|
|
76
77
|
isLocked(): boolean;
|
|
77
78
|
runWorkerSubscriptions(state: WorkerState): void;
|
|
79
|
+
sendChargeResponse(response: ChargeResponse): void;
|
|
80
|
+
sendCharge(charge: Charge): void;
|
|
81
|
+
sendTerminal(terminal: Terminal | null): void;
|
|
78
82
|
private createWindow;
|
|
79
83
|
private loadCurrentWindow;
|
|
80
84
|
private shouldPreload;
|
|
@@ -90,6 +94,7 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
90
94
|
private handleEnableInterruptLock;
|
|
91
95
|
private handleDisableInterruptLock;
|
|
92
96
|
private handleAnalyticsEvent;
|
|
97
|
+
private handleChargeRequest;
|
|
93
98
|
private handleCurrentPresentationComplete;
|
|
94
99
|
private handleCurrentPresentationError;
|
|
95
100
|
private handleNextPresentationError;
|
|
@@ -117,6 +117,11 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
117
117
|
// send analytics events since the next window is not visible.
|
|
118
118
|
_this.emitCurrentWindowEvent('window_analytics_event', event);
|
|
119
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
|
+
};
|
|
120
125
|
_this.handleCurrentPresentationComplete = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
121
126
|
var logger, isThrottled, now, timeSinceLastComplete, delay, _a, next, preview, nextPreviewPresentationId;
|
|
122
127
|
var _this = this;
|
|
@@ -547,7 +552,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
547
552
|
});
|
|
548
553
|
};
|
|
549
554
|
PlaylistWindowManager.prototype.updateBounds = function (bounds) {
|
|
550
|
-
// TODO log bounds
|
|
551
555
|
this.bounds = bounds;
|
|
552
556
|
if (this.currentWindow) {
|
|
553
557
|
this.currentWindow.updateBounds(this.bounds);
|
|
@@ -641,6 +645,37 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
641
645
|
this.nextWindow.runWorkerSubscriptions(state);
|
|
642
646
|
}
|
|
643
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
|
+
};
|
|
644
679
|
PlaylistWindowManager.prototype.createWindow = function (pr) {
|
|
645
680
|
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;
|
|
646
681
|
if (!this.ruleEngine) {
|
|
@@ -659,7 +694,6 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
659
694
|
var presentation = this.state.getPresentation(presentationId);
|
|
660
695
|
var applicationVersion = this.state.getApplicationVersion(presentation.applicationDeploymentId);
|
|
661
696
|
var windowId = (0, uuid_1.v4)();
|
|
662
|
-
logger.info("playlist-window-manager/src/PlaylistWindowManager.ts createWindow1 ".concat(JSON.stringify(this.bounds)));
|
|
663
697
|
return new PresentationWindow_1.default({
|
|
664
698
|
windowManager: this,
|
|
665
699
|
renderer: this.renderer,
|
|
@@ -685,6 +719,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
685
719
|
globalRule: this.ruleEngine.globalRule,
|
|
686
720
|
isPreview: isPreview,
|
|
687
721
|
workerState: this.workerState,
|
|
722
|
+
getTerminal: this.options.getTerminal,
|
|
688
723
|
});
|
|
689
724
|
};
|
|
690
725
|
PlaylistWindowManager.prototype.loadCurrentWindow = function () {
|
|
@@ -704,6 +739,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
704
739
|
this.currentWindow.onEnableInterruptLock(this.handleEnableInterruptLock);
|
|
705
740
|
this.currentWindow.onDisableInterruptLock(this.handleDisableInterruptLock);
|
|
706
741
|
this.currentWindow.onAnalyticsEvent(this.handleAnalyticsEvent);
|
|
742
|
+
this.currentWindow.onChargeRequest(this.handleChargeRequest);
|
|
707
743
|
return [4 /*yield*/, this.currentWindow.load()];
|
|
708
744
|
case 1:
|
|
709
745
|
_a.sent();
|
|
@@ -908,6 +944,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
908
944
|
this.currentWindow.onEnableInterruptLock(this.handleEnableInterruptLock);
|
|
909
945
|
this.currentWindow.onDisableInterruptLock(this.handleDisableInterruptLock);
|
|
910
946
|
this.currentWindow.onAnalyticsEvent(this.handleAnalyticsEvent);
|
|
947
|
+
this.currentWindow.onChargeRequest(this.handleChargeRequest);
|
|
911
948
|
}
|
|
912
949
|
// Play new current window.
|
|
913
950
|
this.playCurrentWindow();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as RE from '@raydiant/playlist-rule-engine';
|
|
2
2
|
import PlaylistWindowManagerState from './PlaylistWindowManagerState';
|
|
3
3
|
import PlaylistWindowManager from './PlaylistWindowManager';
|
|
4
|
-
import { Presentation, ApplicationVersion, Theme, Device, PresentationWindowRenderer, WindowBounds, Logger, BuilderState, WorkerState, AnalyticsEvent } from './types';
|
|
4
|
+
import { Presentation, ApplicationVersion, Theme, Device, PresentationWindowRenderer, WindowBounds, Logger, BuilderState, WorkerState, AnalyticsEvent, Charge, ChargeRequest, ChargeResponse, Terminal } from './types';
|
|
5
5
|
export interface PresentationWindowOptions {
|
|
6
6
|
windowManager?: PlaylistWindowManager;
|
|
7
7
|
windowId: string;
|
|
@@ -31,6 +31,7 @@ export interface PresentationWindowOptions {
|
|
|
31
31
|
onPresentationProperties?: (properties: any[], string: {
|
|
32
32
|
[key: string]: string;
|
|
33
33
|
}) => void;
|
|
34
|
+
getTerminal?: () => Terminal | null;
|
|
34
35
|
}
|
|
35
36
|
export default class PresentationWindow {
|
|
36
37
|
private options;
|
|
@@ -50,6 +51,7 @@ export default class PresentationWindow {
|
|
|
50
51
|
private enableInterruptLockCallback;
|
|
51
52
|
private disableInterruptLockCallback;
|
|
52
53
|
private analyticsEventCallback;
|
|
54
|
+
private chargeRequestCallback;
|
|
53
55
|
private builderState;
|
|
54
56
|
private presentation;
|
|
55
57
|
private playlistWindowManagerState;
|
|
@@ -62,6 +64,7 @@ export default class PresentationWindow {
|
|
|
62
64
|
private runtimeSubscriptions;
|
|
63
65
|
private previewSubscriptions;
|
|
64
66
|
private previewState;
|
|
67
|
+
private paymentSubscriptions;
|
|
65
68
|
private createObjectURLResolvers;
|
|
66
69
|
private createObjectURLTimeouts;
|
|
67
70
|
constructor(options: PresentationWindowOptions);
|
|
@@ -79,6 +82,7 @@ export default class PresentationWindow {
|
|
|
79
82
|
onEnableInterruptLock(callback: (() => void) | null): void;
|
|
80
83
|
onDisableInterruptLock(callback: (() => void) | null): void;
|
|
81
84
|
onAnalyticsEvent(callback: ((event: AnalyticsEvent) => void) | null): void;
|
|
85
|
+
onChargeRequest(callback: ((request: ChargeRequest) => void) | null): void;
|
|
82
86
|
isReady(): boolean;
|
|
83
87
|
isComplete(): boolean;
|
|
84
88
|
isPlaying(): boolean;
|
|
@@ -92,6 +96,9 @@ export default class PresentationWindow {
|
|
|
92
96
|
reload(): Promise<void>;
|
|
93
97
|
runGetProperties(builderState?: BuilderState): void;
|
|
94
98
|
createObjectURL(blob: Blob): Promise<string>;
|
|
99
|
+
sendChargeResponse(response: ChargeResponse): void;
|
|
100
|
+
sendCharge(charge: Charge): void;
|
|
101
|
+
sendTerminal(terminal: Terminal | null): void;
|
|
95
102
|
private isEmbeddedApp;
|
|
96
103
|
private allChildWindowManagersReady;
|
|
97
104
|
private checkIsReadyCallback;
|