@raydiant/playlist-window-manager 0.21.1 → 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/tasks/npm-publish.sh +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
|
@@ -1,521 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
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;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
|
-
};
|
|
75
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
var path = __importStar(require("path"));
|
|
77
|
-
var electron_1 = require("electron");
|
|
78
|
-
var WindowUnresponsiveError_1 = __importDefault(require("./WindowUnresponsiveError"));
|
|
79
|
-
var BrowserWindowRenderer = /** @class */ (function () {
|
|
80
|
-
function BrowserWindowRenderer(opts) {
|
|
81
|
-
this.opts = opts;
|
|
82
|
-
this.windows = {};
|
|
83
|
-
this.windowCrashHandler = function (_) { };
|
|
84
|
-
this.browserWindowPool = new WindowPool();
|
|
85
|
-
this.browserViewPool = new WindowPool();
|
|
86
|
-
// Create a hidden window to preload BrowserViews.
|
|
87
|
-
this.offscreenWindow = new electron_1.BrowserWindow({
|
|
88
|
-
show: false,
|
|
89
|
-
frame: this.opts.frame,
|
|
90
|
-
hasShadow: this.opts.hasShadow,
|
|
91
|
-
webPreferences: {
|
|
92
|
-
preload: path.join(__dirname, 'preload.js'),
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
this.proxySettings = null;
|
|
96
|
-
this.offscreenWindow.setBounds(opts.bounds);
|
|
97
|
-
if (opts.proxySettings) {
|
|
98
|
-
this.proxySettings = opts.proxySettings;
|
|
99
|
-
}
|
|
100
|
-
this.logger = opts.logger;
|
|
101
|
-
if (opts.windowCrashHandler) {
|
|
102
|
-
this.windowCrashHandler = opts.windowCrashHandler;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
BrowserWindowRenderer.prototype.createWindow = function (_a) {
|
|
106
|
-
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;
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var window;
|
|
109
|
-
var _this = this;
|
|
110
|
-
return __generator(this, function (_c) {
|
|
111
|
-
switch (_c.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
window = {
|
|
114
|
-
parentWindowId: parentWindowId,
|
|
115
|
-
// If we are creating a child window and renderChildWindowsAsBrowserViews is true,
|
|
116
|
-
// render all child windows as browser views.
|
|
117
|
-
view: parentWindowId && this.opts.renderChildWindowsAsBrowserViews
|
|
118
|
-
? this.createOrGetPooledBrowserView(windowId, {
|
|
119
|
-
webPreferences: {
|
|
120
|
-
preload: path.join(__dirname, 'preload.js'),
|
|
121
|
-
},
|
|
122
|
-
})
|
|
123
|
-
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
124
|
-
show: false,
|
|
125
|
-
frame: this.opts.frame,
|
|
126
|
-
// NOTE: useWindowPool: true does not work with renderChildWindowsAsBrowserViews: false
|
|
127
|
-
// because the parent can't be changed after creating the BrowserWindow.
|
|
128
|
-
parent: parentWindowId
|
|
129
|
-
? this.getParentBrowserView(parentWindowId)
|
|
130
|
-
: undefined,
|
|
131
|
-
transparent: backgroundColor === 'transparent',
|
|
132
|
-
hasShadow: this.opts.hasShadow,
|
|
133
|
-
webPreferences: {
|
|
134
|
-
preload: path.join(__dirname, 'preload.js'),
|
|
135
|
-
},
|
|
136
|
-
}),
|
|
137
|
-
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
138
|
-
// we are rendering child windows with BrowserWindow. BrowserWindows are positioned absolutely so
|
|
139
|
-
// to place them in the correct spot relative to their parent we need to add the main window's x / y.
|
|
140
|
-
// BrowserViews are relatively positioned so we don't need to do that.
|
|
141
|
-
bounds: parentWindowId && !this.opts.renderChildWindowsAsBrowserViews
|
|
142
|
-
? __assign(__assign({}, bounds), { x: bounds.x + this.opts.bounds.x, y: bounds.y + this.opts.bounds.y }) : bounds,
|
|
143
|
-
receiveMessageCallback: function (_, type, payload) {
|
|
144
|
-
if (receiveMessageCallback) {
|
|
145
|
-
receiveMessageCallback(type, payload);
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
unresponsiveCallback: function () {
|
|
149
|
-
_this.logger.error("Window received 'unresponsive' event", { windowId: windowId });
|
|
150
|
-
_this.windowCrashHandler('unresponsive');
|
|
151
|
-
errorCallback(new WindowUnresponsiveError_1.default("Window '".concat(windowId, "' is unresponsive")));
|
|
152
|
-
},
|
|
153
|
-
renderProcessGoneCallback: function (_, details) {
|
|
154
|
-
_this.logger.error("Window received 'render-process-gone' event. Reason: ".concat(details.reason), { windowId: windowId });
|
|
155
|
-
// TODO: Handle different reasons for render-process-gone?
|
|
156
|
-
// https://www.electronjs.org/docs/api/web-contents#event-render-process-gone
|
|
157
|
-
_this.windowCrashHandler('render-process-gone');
|
|
158
|
-
errorCallback(new WindowUnresponsiveError_1.default("Window '".concat(windowId, "' render process gone")));
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
// Attached crash handlers to skip presentation on error.
|
|
162
|
-
window.view.webContents.on('render-process-gone', window.renderProcessGoneCallback);
|
|
163
|
-
window.view.webContents.on('unresponsive', window.unresponsiveCallback);
|
|
164
|
-
if (window.view instanceof electron_1.BrowserView) {
|
|
165
|
-
this.moveWindowOffscreen(window);
|
|
166
|
-
}
|
|
167
|
-
this.windows[windowId] = window;
|
|
168
|
-
// Listen for messages from window.
|
|
169
|
-
electron_1.ipcMain.on(windowId, window.receiveMessageCallback);
|
|
170
|
-
if (backgroundColor) {
|
|
171
|
-
// To make a transparent window you need to set it's value to #00000000
|
|
172
|
-
// Electron issue: https://github.com/electron/electron/issues/20357
|
|
173
|
-
window.view.setBackgroundColor(backgroundColor === 'transparent' ? '#00000000' : backgroundColor);
|
|
174
|
-
}
|
|
175
|
-
window.view.setBounds(window.bounds);
|
|
176
|
-
if (!this.proxySettings) return [3 /*break*/, 2];
|
|
177
|
-
return [4 /*yield*/, window.view.webContents.session.setProxy(this.proxySettings)];
|
|
178
|
-
case 1:
|
|
179
|
-
_c.sent();
|
|
180
|
-
_c.label = 2;
|
|
181
|
-
case 2:
|
|
182
|
-
if (this.opts.useWindowPool) {
|
|
183
|
-
this.logPoolStats();
|
|
184
|
-
}
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
BrowserWindowRenderer.prototype.loadWindow = function (windowId, url) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
-
var window;
|
|
193
|
-
return __generator(this, function (_a) {
|
|
194
|
-
switch (_a.label) {
|
|
195
|
-
case 0:
|
|
196
|
-
window = this.getWindow(windowId);
|
|
197
|
-
if (!window) {
|
|
198
|
-
throw new Error("Failed to load window, missing window id '".concat(windowId, "'"));
|
|
199
|
-
}
|
|
200
|
-
return [4 /*yield*/, window.view.webContents.loadURL(url)];
|
|
201
|
-
case 1:
|
|
202
|
-
_a.sent();
|
|
203
|
-
return [2 /*return*/];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
BrowserWindowRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
|
|
209
|
-
var window = this.getWindow(windowId);
|
|
210
|
-
if (!window) {
|
|
211
|
-
throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
|
|
212
|
-
}
|
|
213
|
-
window.bounds = bounds;
|
|
214
|
-
if (window.view instanceof electron_1.BrowserWindow && window.parentWindowId) {
|
|
215
|
-
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
216
|
-
// x/y to when updating the child window's bounds.
|
|
217
|
-
window.view.setBounds(__assign(__assign({}, window.bounds), { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y }));
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
window.view.setBounds(window.bounds);
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
BrowserWindowRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
224
|
-
var window = this.getWindow(windowId);
|
|
225
|
-
if (!window) {
|
|
226
|
-
throw new Error("Failed to show window, missing window id '".concat(windowId, "'"));
|
|
227
|
-
}
|
|
228
|
-
if (window.view instanceof electron_1.BrowserWindow) {
|
|
229
|
-
if (isFocused) {
|
|
230
|
-
window.view.show();
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
window.view.showInactive();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else if (window.view instanceof electron_1.BrowserView && window.parentWindowId) {
|
|
237
|
-
this.addWindowToParent(window.parentWindowId, window);
|
|
238
|
-
if (isFocused) {
|
|
239
|
-
// The setTimeout is required to set focus after the BrowserView has
|
|
240
|
-
// been added to the parent BrowserWindow.
|
|
241
|
-
setTimeout(function () { return window.view.webContents.focus(); }, 0);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
BrowserWindowRenderer.prototype.hideWindow = function (windowId) {
|
|
246
|
-
var window = this.getWindow(windowId);
|
|
247
|
-
if (!window) {
|
|
248
|
-
throw new Error("Failed to hide window, missing window id '".concat(windowId, "'"));
|
|
249
|
-
}
|
|
250
|
-
if (window.view instanceof electron_1.BrowserWindow) {
|
|
251
|
-
window.view.hide();
|
|
252
|
-
}
|
|
253
|
-
else if (window.view instanceof electron_1.BrowserView) {
|
|
254
|
-
this.moveWindowOffscreen(window);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
BrowserWindowRenderer.prototype.removeWindow = function (windowId) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
-
var window;
|
|
260
|
-
return __generator(this, function (_a) {
|
|
261
|
-
switch (_a.label) {
|
|
262
|
-
case 0:
|
|
263
|
-
window = this.getWindow(windowId);
|
|
264
|
-
if (!window) {
|
|
265
|
-
throw new Error("Failed to remove window, missing window id '".concat(windowId, "'"));
|
|
266
|
-
}
|
|
267
|
-
// Remove crash handlers
|
|
268
|
-
window.view.webContents.removeListener('render-process-gone', window.renderProcessGoneCallback);
|
|
269
|
-
window.view.webContents.removeListener('unresponsive', window.unresponsiveCallback);
|
|
270
|
-
// Remove message handler
|
|
271
|
-
electron_1.ipcMain.removeListener(windowId, window.receiveMessageCallback);
|
|
272
|
-
if (!(window.view instanceof electron_1.BrowserView)) return [3 /*break*/, 2];
|
|
273
|
-
if (window.parentWindowId) {
|
|
274
|
-
this.removeWindowFromParent(window.parentWindowId, window);
|
|
275
|
-
}
|
|
276
|
-
return [4 /*yield*/, this.destroyOrUnloadPooledBrowserView(windowId, window.view)];
|
|
277
|
-
case 1:
|
|
278
|
-
_a.sent();
|
|
279
|
-
return [3 /*break*/, 4];
|
|
280
|
-
case 2:
|
|
281
|
-
if (!(window.view instanceof electron_1.BrowserWindow)) return [3 /*break*/, 4];
|
|
282
|
-
return [4 /*yield*/, this.destroyOrUnloadPooledBrowserWindow(windowId, window.view)];
|
|
283
|
-
case 3:
|
|
284
|
-
_a.sent();
|
|
285
|
-
_a.label = 4;
|
|
286
|
-
case 4:
|
|
287
|
-
delete this.windows[windowId];
|
|
288
|
-
if (this.opts.useWindowPool) {
|
|
289
|
-
this.logPoolStats();
|
|
290
|
-
}
|
|
291
|
-
return [2 /*return*/];
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
BrowserWindowRenderer.prototype.sendMessageString = function (windowId, message) {
|
|
297
|
-
var window = this.getWindow(windowId);
|
|
298
|
-
if (!window) {
|
|
299
|
-
throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
|
|
300
|
-
}
|
|
301
|
-
window.view.webContents.send('electron-main', message);
|
|
302
|
-
};
|
|
303
|
-
BrowserWindowRenderer.prototype.sendMessageObject = function (windowId, type, payload) {
|
|
304
|
-
var window = this.getWindow(windowId);
|
|
305
|
-
if (!window) {
|
|
306
|
-
throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
|
|
307
|
-
}
|
|
308
|
-
window.view.webContents.send('electron-main', { type: type, payload: payload });
|
|
309
|
-
};
|
|
310
|
-
BrowserWindowRenderer.prototype.muteWindow = function (windowId) {
|
|
311
|
-
var window = this.getWindow(windowId);
|
|
312
|
-
if (!window) {
|
|
313
|
-
throw new Error("Failed to mute window, missing window id '".concat(windowId, "'"));
|
|
314
|
-
}
|
|
315
|
-
window.view.webContents.setAudioMuted(true);
|
|
316
|
-
};
|
|
317
|
-
BrowserWindowRenderer.prototype.unMuteWindow = function (windowId) {
|
|
318
|
-
var window = this.getWindow(windowId);
|
|
319
|
-
if (!window) {
|
|
320
|
-
throw new Error("Failed to unmute window, missing window id '".concat(windowId, "'"));
|
|
321
|
-
}
|
|
322
|
-
window.view.webContents.setAudioMuted(false);
|
|
323
|
-
};
|
|
324
|
-
BrowserWindowRenderer.prototype.getWindow = function (windowId) {
|
|
325
|
-
return this.windows[windowId];
|
|
326
|
-
};
|
|
327
|
-
BrowserWindowRenderer.prototype.moveWindowOffscreen = function (window) {
|
|
328
|
-
if (!(window.view instanceof electron_1.BrowserView)) {
|
|
329
|
-
throw new Error("Failed move window offscreen, window is not a BrowserView");
|
|
330
|
-
}
|
|
331
|
-
if (window.parentWindowId) {
|
|
332
|
-
this.removeWindowFromParent(window.parentWindowId, window);
|
|
333
|
-
}
|
|
334
|
-
this.offscreenWindow.addBrowserView(window.view);
|
|
335
|
-
};
|
|
336
|
-
BrowserWindowRenderer.prototype.addWindowToParent = function (parentWindowId, window) {
|
|
337
|
-
var parentWindow = this.getWindow(parentWindowId);
|
|
338
|
-
if (!parentWindow) {
|
|
339
|
-
throw new Error("Failed to add window to parent, missing parent window id '".concat(parentWindowId, "'"));
|
|
340
|
-
}
|
|
341
|
-
if (parentWindow.view instanceof electron_1.BrowserWindow) {
|
|
342
|
-
if (window.view instanceof electron_1.BrowserView) {
|
|
343
|
-
this.offscreenWindow.removeBrowserView(window.view);
|
|
344
|
-
parentWindow.view.addBrowserView(window.view);
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
throw new Error("Failed add window to parent window id '".concat(parentWindowId, "', child window is not a BrowserView"));
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
throw new Error("Failed add window to parent window id '".concat(parentWindowId, "', parent window is not a BrowserWindow"));
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
BrowserWindowRenderer.prototype.removeWindowFromParent = function (parentWindowId, window) {
|
|
355
|
-
var parentWindow = this.getWindow(parentWindowId);
|
|
356
|
-
if (!parentWindow) {
|
|
357
|
-
throw new Error("Failed to remove window from parent, missing parent window id '".concat(parentWindowId, "'"));
|
|
358
|
-
}
|
|
359
|
-
if (parentWindow.view instanceof electron_1.BrowserWindow) {
|
|
360
|
-
if (window.view instanceof electron_1.BrowserView) {
|
|
361
|
-
parentWindow.view.removeBrowserView(window.view);
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
throw new Error("Failed remove window from parent window id '".concat(parentWindowId, "', child window is not a BrowserView"));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
throw new Error("Failed remove window from parent window id '".concat(parentWindowId, "', parent window is not a BrowserWindow"));
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
BrowserWindowRenderer.prototype.getParentBrowserView = function (parentWindowId) {
|
|
372
|
-
var parentWindow = this.getWindow(parentWindowId);
|
|
373
|
-
if (!parentWindow) {
|
|
374
|
-
throw new Error("Failed to get parent BrowserView, missing parent window id '".concat(parentWindowId, "'"));
|
|
375
|
-
}
|
|
376
|
-
if (!(parentWindow.view instanceof electron_1.BrowserWindow)) {
|
|
377
|
-
throw new Error("Failed to get parent BrowserView, window is not a BrowserView");
|
|
378
|
-
}
|
|
379
|
-
return parentWindow.view;
|
|
380
|
-
};
|
|
381
|
-
BrowserWindowRenderer.prototype.createOrGetPooledBrowserWindow = function (windowId, options) {
|
|
382
|
-
var browserWindow = null;
|
|
383
|
-
if (this.opts.useWindowPool) {
|
|
384
|
-
browserWindow = this.browserWindowPool.get();
|
|
385
|
-
if (browserWindow) {
|
|
386
|
-
this.logger.info("Found free browser window from pool", { windowId: windowId });
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
this.logger.info("No free browser windows, adding new window to pool", {
|
|
390
|
-
windowId: windowId,
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (!browserWindow) {
|
|
395
|
-
browserWindow = new electron_1.BrowserWindow(options);
|
|
396
|
-
if (this.opts.useWindowPool) {
|
|
397
|
-
this.browserWindowPool.add(browserWindow);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return browserWindow;
|
|
401
|
-
};
|
|
402
|
-
BrowserWindowRenderer.prototype.destroyOrUnloadPooledBrowserWindow = function (windowId, browserWindow) {
|
|
403
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
-
return __generator(this, function (_a) {
|
|
405
|
-
switch (_a.label) {
|
|
406
|
-
case 0:
|
|
407
|
-
if (!this.opts.useWindowPool) return [3 /*break*/, 2];
|
|
408
|
-
this.hideWindow(windowId);
|
|
409
|
-
return [4 /*yield*/, browserWindow.webContents.loadURL('about:blank')];
|
|
410
|
-
case 1:
|
|
411
|
-
_a.sent();
|
|
412
|
-
this.browserWindowPool.release(browserWindow);
|
|
413
|
-
return [3 /*break*/, 3];
|
|
414
|
-
case 2:
|
|
415
|
-
if (browserWindow.isDestroyed()) {
|
|
416
|
-
this.logger.warn("Attempted to destroy BrowserWindow but it's already destroyed", { windowId: windowId });
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
// https://github.com/electron/electron/issues/26929#issuecomment-763837953
|
|
420
|
-
setImmediate(function () {
|
|
421
|
-
browserWindow.destroy();
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
_a.label = 3;
|
|
425
|
-
case 3: return [2 /*return*/];
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
BrowserWindowRenderer.prototype.createOrGetPooledBrowserView = function (windowId, options) {
|
|
431
|
-
var browserView = null;
|
|
432
|
-
if (this.opts.useWindowPool) {
|
|
433
|
-
browserView = this.browserViewPool.get();
|
|
434
|
-
if (browserView) {
|
|
435
|
-
this.logger.info("Found free browser view from pool", { windowId: windowId });
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
this.logger.info("No free browser views, adding new view to pool", {
|
|
439
|
-
windowId: windowId,
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
if (!browserView) {
|
|
444
|
-
browserView = new electron_1.BrowserView(options);
|
|
445
|
-
if (this.opts.useWindowPool) {
|
|
446
|
-
this.browserViewPool.add(browserView);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return browserView;
|
|
450
|
-
};
|
|
451
|
-
BrowserWindowRenderer.prototype.destroyOrUnloadPooledBrowserView = function (windowId, browserView) {
|
|
452
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
453
|
-
return __generator(this, function (_a) {
|
|
454
|
-
switch (_a.label) {
|
|
455
|
-
case 0:
|
|
456
|
-
if (!this.opts.useWindowPool) return [3 /*break*/, 2];
|
|
457
|
-
this.hideWindow(windowId);
|
|
458
|
-
return [4 /*yield*/, browserView.webContents.loadURL('about:blank')];
|
|
459
|
-
case 1:
|
|
460
|
-
_a.sent();
|
|
461
|
-
this.browserViewPool.release(browserView);
|
|
462
|
-
return [3 /*break*/, 3];
|
|
463
|
-
case 2:
|
|
464
|
-
if (browserView.webContents.isDestroyed()) {
|
|
465
|
-
this.logger.warn("Attempted to destroy BrowserView but it's already destroyed", { windowId: windowId });
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
// Call destroy on webContents as workaround for BrowserView.destroy() being deprecated.
|
|
469
|
-
// https://github.com/electron/electron/pull/23578
|
|
470
|
-
// https://github.com/electron/electron/issues/26929
|
|
471
|
-
setImmediate(function () {
|
|
472
|
-
browserView.webContents.destroy();
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
_a.label = 3;
|
|
476
|
-
case 3: return [2 /*return*/];
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
};
|
|
481
|
-
BrowserWindowRenderer.prototype.logPoolStats = function () {
|
|
482
|
-
var bwSize = this.browserWindowPool.size();
|
|
483
|
-
var bvSize = this.browserViewPool.size();
|
|
484
|
-
this.logger.info("BrowserWindow pool total=".concat(bwSize.total, " inuse=").concat(bwSize.inuse, " free=").concat(bwSize.free));
|
|
485
|
-
this.logger.info("BrowserView pool total=".concat(bvSize.total, " inuse=").concat(bvSize.inuse, " free=").concat(bvSize.free));
|
|
486
|
-
};
|
|
487
|
-
return BrowserWindowRenderer;
|
|
488
|
-
}());
|
|
489
|
-
exports.default = BrowserWindowRenderer;
|
|
490
|
-
var WindowPool = /** @class */ (function () {
|
|
491
|
-
function WindowPool() {
|
|
492
|
-
this.inuse = new Set();
|
|
493
|
-
this.free = new Set();
|
|
494
|
-
}
|
|
495
|
-
WindowPool.prototype.add = function (window) {
|
|
496
|
-
this.inuse.add(window);
|
|
497
|
-
};
|
|
498
|
-
WindowPool.prototype.get = function () {
|
|
499
|
-
var firstFreeWindow = this.free.values().next().value;
|
|
500
|
-
if (!firstFreeWindow)
|
|
501
|
-
return null;
|
|
502
|
-
// Mark window as inuse, call poo.release(window) to mark as free to use.
|
|
503
|
-
this.free.delete(firstFreeWindow);
|
|
504
|
-
this.inuse.add(firstFreeWindow);
|
|
505
|
-
return firstFreeWindow;
|
|
506
|
-
};
|
|
507
|
-
WindowPool.prototype.release = function (window) {
|
|
508
|
-
this.inuse.delete(window);
|
|
509
|
-
this.free.add(window);
|
|
510
|
-
};
|
|
511
|
-
WindowPool.prototype.size = function () {
|
|
512
|
-
var inuse = this.inuse.size;
|
|
513
|
-
var free = this.free.size;
|
|
514
|
-
return {
|
|
515
|
-
total: inuse + free,
|
|
516
|
-
inuse: inuse,
|
|
517
|
-
free: free,
|
|
518
|
-
};
|
|
519
|
-
};
|
|
520
|
-
return WindowPool;
|
|
521
|
-
}());
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { PresentationWindowRenderer, CreateWindowOptions, WindowBounds } from './types';
|
|
2
|
-
export default class IFrameRenderer implements PresentationWindowRenderer {
|
|
3
|
-
private container;
|
|
4
|
-
private windows;
|
|
5
|
-
constructor(container: HTMLElement);
|
|
6
|
-
createWindow({ windowId, bounds, backgroundColor, receiveMessageCallback, }: CreateWindowOptions): Promise<void>;
|
|
7
|
-
loadWindow(windowId: string, url: string): Promise<void>;
|
|
8
|
-
updateWindowBounds(windowId: string, bounds: WindowBounds): void;
|
|
9
|
-
showWindow(windowId: string, isFocused: boolean): void;
|
|
10
|
-
hideWindow(windowId: string): void;
|
|
11
|
-
removeWindow(windowId: string): Promise<void>;
|
|
12
|
-
sendMessageString(windowId: string, message: string): void;
|
|
13
|
-
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
14
|
-
muteWindow(windowId: string): void;
|
|
15
|
-
unMuteWindow(windowId: string): void;
|
|
16
|
-
destroy(): void;
|
|
17
|
-
private getWindow;
|
|
18
|
-
private globalMessageHandler;
|
|
19
|
-
private deserializeMessage;
|
|
20
|
-
}
|