@raydiant/playlist-window-manager 0.24.1 → 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 -32
- package/build/PresentationWindow.js +93 -506
- 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 -44
- package/package.json +1 -1
- package/src/BrowserViewRenderer.ts +6 -5
- package/src/BrowserWindowRenderer.ts +16 -14
- package/src/PresentationWindow.test.ts +95 -0
- package/src/PresentationWindow.ts +224 -8
- package/src/types.ts +6 -0
- package/tasks/npm-publish.sh +1 -1
- package/build/PresentationWindow.test.d.ts +0 -1
- package/build/PresentationWindow.test.js +0 -340
- package/build/testUtils.d.ts +0 -43
- package/build/testUtils.js +0 -209
|
@@ -5,14 +5,13 @@ 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, backgroundColor, receiveMessageCallback
|
|
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;
|
|
12
12
|
hideWindow(windowId: string): void;
|
|
13
13
|
removeWindow(windowId: string): Promise<void>;
|
|
14
|
-
|
|
15
|
-
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
14
|
+
sendMessage(windowId: string, message: string): void;
|
|
16
15
|
muteWindow(windowId: string): void;
|
|
17
16
|
unMuteWindow(windowId: string): void;
|
|
18
17
|
private getWindow;
|
|
@@ -10,35 +10,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
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
13
|
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
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
15
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
16
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
42
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
19
|
});
|
|
44
20
|
};
|
|
@@ -48,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
25
|
function step(op) {
|
|
50
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (
|
|
27
|
+
while (_) try {
|
|
52
28
|
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
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
30
|
switch (op[0]) {
|
|
@@ -69,6 +45,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
46
|
}
|
|
71
47
|
};
|
|
48
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
52
|
+
result["default"] = mod;
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
72
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
56
|
var path = __importStar(require("path"));
|
|
74
57
|
var electron_1 = require("electron");
|
|
@@ -86,16 +69,15 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
86
69
|
window = {
|
|
87
70
|
view: new electron_1.BrowserView({
|
|
88
71
|
webPreferences: {
|
|
89
|
-
preload: path.join(__dirname, 'preload.js')
|
|
90
|
-
|
|
91
|
-
},
|
|
72
|
+
preload: path.join(__dirname, 'preload.js')
|
|
73
|
+
}
|
|
92
74
|
}),
|
|
93
|
-
bounds: bounds || __assign(
|
|
75
|
+
bounds: bounds || __assign({}, this.mainWindow.getBounds(), { x: 0, y: 0 }),
|
|
94
76
|
receiveMessageCallback: function (_, type, payload) {
|
|
95
77
|
if (receiveMessageCallback) {
|
|
96
78
|
receiveMessageCallback(type, payload);
|
|
97
79
|
}
|
|
98
|
-
}
|
|
80
|
+
}
|
|
99
81
|
};
|
|
100
82
|
this.windows[windowId] = window;
|
|
101
83
|
electron_1.ipcMain.on(windowId, window.receiveMessageCallback);
|
|
@@ -109,7 +91,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
109
91
|
if (!parentWindowId) {
|
|
110
92
|
window.view.setAutoResize({
|
|
111
93
|
width: true,
|
|
112
|
-
height: true
|
|
94
|
+
height: true
|
|
113
95
|
});
|
|
114
96
|
}
|
|
115
97
|
return [2 /*return*/];
|
|
@@ -124,7 +106,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
124
106
|
case 0:
|
|
125
107
|
window = this.getWindow(windowId);
|
|
126
108
|
if (!window) {
|
|
127
|
-
throw new Error("Failed to load window, missing window id '"
|
|
109
|
+
throw new Error("Failed to load window, missing window id '" + windowId + "'");
|
|
128
110
|
}
|
|
129
111
|
return [4 /*yield*/, window.view.webContents.loadURL(url)];
|
|
130
112
|
case 1:
|
|
@@ -137,7 +119,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
137
119
|
BrowserViewRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
|
|
138
120
|
var window = this.getWindow(windowId);
|
|
139
121
|
if (!window) {
|
|
140
|
-
throw new Error("Failed to update window bounds, missing window id '"
|
|
122
|
+
throw new Error("Failed to update window bounds, missing window id '" + windowId + "'");
|
|
141
123
|
}
|
|
142
124
|
window.bounds = bounds;
|
|
143
125
|
window.view.setBounds(window.bounds);
|
|
@@ -145,7 +127,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
145
127
|
BrowserViewRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
146
128
|
var window = this.getWindow(windowId);
|
|
147
129
|
if (!window) {
|
|
148
|
-
throw new Error("Failed to show window, missing window id '"
|
|
130
|
+
throw new Error("Failed to show window, missing window id '" + windowId + "'");
|
|
149
131
|
}
|
|
150
132
|
this.mainWindow.addBrowserView(window.view);
|
|
151
133
|
if (isFocused) {
|
|
@@ -157,7 +139,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
157
139
|
BrowserViewRenderer.prototype.hideWindow = function (windowId) {
|
|
158
140
|
var window = this.getWindow(windowId);
|
|
159
141
|
if (!window) {
|
|
160
|
-
throw new Error("Failed to hide window, missing window id '"
|
|
142
|
+
throw new Error("Failed to hide window, missing window id '" + windowId + "'");
|
|
161
143
|
}
|
|
162
144
|
this.offscreenWindow.addBrowserView(window.view);
|
|
163
145
|
};
|
|
@@ -167,7 +149,7 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
167
149
|
return __generator(this, function (_a) {
|
|
168
150
|
window = this.getWindow(windowId);
|
|
169
151
|
if (!window) {
|
|
170
|
-
throw new Error("Failed to hide window, missing window id '"
|
|
152
|
+
throw new Error("Failed to hide window, missing window id '" + windowId + "'");
|
|
171
153
|
}
|
|
172
154
|
this.hideWindow(windowId);
|
|
173
155
|
window.view.webContents.loadURL('about:blank');
|
|
@@ -177,31 +159,24 @@ var BrowserViewRenderer = /** @class */ (function () {
|
|
|
177
159
|
});
|
|
178
160
|
});
|
|
179
161
|
};
|
|
180
|
-
BrowserViewRenderer.prototype.
|
|
162
|
+
BrowserViewRenderer.prototype.sendMessage = function (windowId, message) {
|
|
181
163
|
var window = this.getWindow(windowId);
|
|
182
164
|
if (!window) {
|
|
183
|
-
throw new Error("Failed to send message to window, missing window id '"
|
|
165
|
+
throw new Error("Failed to send message to window, missing window id '" + windowId + "'");
|
|
184
166
|
}
|
|
185
167
|
window.view.webContents.send('electron-main', message);
|
|
186
168
|
};
|
|
187
|
-
BrowserViewRenderer.prototype.sendMessageObject = function (windowId, type, payload) {
|
|
188
|
-
var window = this.getWindow(windowId);
|
|
189
|
-
if (!window) {
|
|
190
|
-
throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
|
|
191
|
-
}
|
|
192
|
-
window.view.webContents.send('electron-main', { type: type, payload: payload });
|
|
193
|
-
};
|
|
194
169
|
BrowserViewRenderer.prototype.muteWindow = function (windowId) {
|
|
195
170
|
var window = this.getWindow(windowId);
|
|
196
171
|
if (!window) {
|
|
197
|
-
throw new Error("Failed to mute window, missing window id '"
|
|
172
|
+
throw new Error("Failed to mute window, missing window id '" + windowId + "'");
|
|
198
173
|
}
|
|
199
174
|
window.view.webContents.setAudioMuted(true);
|
|
200
175
|
};
|
|
201
176
|
BrowserViewRenderer.prototype.unMuteWindow = function (windowId) {
|
|
202
177
|
var window = this.getWindow(windowId);
|
|
203
178
|
if (!window) {
|
|
204
|
-
throw new Error("Failed to unmute window, missing window id '"
|
|
179
|
+
throw new Error("Failed to unmute window, missing window id '" + windowId + "'");
|
|
205
180
|
}
|
|
206
181
|
window.view.webContents.setAudioMuted(false);
|
|
207
182
|
};
|
|
@@ -23,14 +23,13 @@ export default class BrowserWindowRenderer implements PresentationWindowRenderer
|
|
|
23
23
|
private proxySettings;
|
|
24
24
|
private logger;
|
|
25
25
|
constructor(opts: BrowserWindowRendererOptions);
|
|
26
|
-
createWindow({ windowId, parentWindowId, bounds, backgroundColor, receiveMessageCallback, errorCallback
|
|
26
|
+
createWindow({ windowId, parentWindowId, bounds, backgroundColor, receiveMessageCallback, errorCallback }: CreateWindowOptions): Promise<void>;
|
|
27
27
|
loadWindow(windowId: string, url: string): Promise<void>;
|
|
28
28
|
updateWindowBounds(windowId: string, bounds: WindowBounds): void;
|
|
29
29
|
showWindow(windowId: string, isFocused: boolean): void;
|
|
30
30
|
hideWindow(windowId: string): void;
|
|
31
31
|
removeWindow(windowId: string): Promise<void>;
|
|
32
|
-
|
|
33
|
-
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
32
|
+
sendMessage(windowId: string, message: string): void;
|
|
34
33
|
muteWindow(windowId: string): void;
|
|
35
34
|
unMuteWindow(windowId: string): void;
|
|
36
35
|
private getWindow;
|
|
@@ -10,35 +10,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
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
13
|
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
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
15
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
16
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
42
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
19
|
});
|
|
44
20
|
};
|
|
@@ -48,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
25
|
function step(op) {
|
|
50
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (
|
|
27
|
+
while (_) try {
|
|
52
28
|
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
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
30
|
switch (op[0]) {
|
|
@@ -69,6 +45,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
46
|
}
|
|
71
47
|
};
|
|
48
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
52
|
+
result["default"] = mod;
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
72
55
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
57
|
};
|
|
@@ -89,9 +72,8 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
89
72
|
frame: this.opts.frame,
|
|
90
73
|
hasShadow: this.opts.hasShadow,
|
|
91
74
|
webPreferences: {
|
|
92
|
-
preload: path.join(__dirname, 'preload.js')
|
|
93
|
-
|
|
94
|
-
},
|
|
75
|
+
preload: path.join(__dirname, 'preload.js')
|
|
76
|
+
}
|
|
95
77
|
});
|
|
96
78
|
this.proxySettings = null;
|
|
97
79
|
this.offscreenWindow.setBounds(opts.bounds);
|
|
@@ -118,9 +100,8 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
118
100
|
view: parentWindowId && this.opts.renderChildWindowsAsBrowserViews
|
|
119
101
|
? this.createOrGetPooledBrowserView(windowId, {
|
|
120
102
|
webPreferences: {
|
|
121
|
-
preload: path.join(__dirname, 'preload.js')
|
|
122
|
-
|
|
123
|
-
},
|
|
103
|
+
preload: path.join(__dirname, 'preload.js')
|
|
104
|
+
}
|
|
124
105
|
})
|
|
125
106
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
126
107
|
show: false,
|
|
@@ -133,16 +114,15 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
133
114
|
transparent: backgroundColor === 'transparent',
|
|
134
115
|
hasShadow: this.opts.hasShadow,
|
|
135
116
|
webPreferences: {
|
|
136
|
-
preload: path.join(__dirname, 'preload.js')
|
|
137
|
-
|
|
138
|
-
},
|
|
117
|
+
preload: path.join(__dirname, 'preload.js')
|
|
118
|
+
}
|
|
139
119
|
}),
|
|
140
120
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
141
121
|
// we are rendering child windows with BrowserWindow. BrowserWindows are positioned absolutely so
|
|
142
122
|
// to place them in the correct spot relative to their parent we need to add the main window's x / y.
|
|
143
123
|
// BrowserViews are relatively positioned so we don't need to do that.
|
|
144
124
|
bounds: parentWindowId && !this.opts.renderChildWindowsAsBrowserViews
|
|
145
|
-
? __assign(
|
|
125
|
+
? __assign({}, bounds, { x: bounds.x + this.opts.bounds.x, y: bounds.y + this.opts.bounds.y }) : bounds,
|
|
146
126
|
receiveMessageCallback: function (_, type, payload) {
|
|
147
127
|
if (receiveMessageCallback) {
|
|
148
128
|
receiveMessageCallback(type, payload);
|
|
@@ -151,15 +131,15 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
151
131
|
unresponsiveCallback: function () {
|
|
152
132
|
_this.logger.error("Window received 'unresponsive' event", { windowId: windowId });
|
|
153
133
|
_this.windowCrashHandler('unresponsive');
|
|
154
|
-
errorCallback(new WindowUnresponsiveError_1.default("Window '"
|
|
134
|
+
errorCallback(new WindowUnresponsiveError_1.default("Window '" + windowId + "' is unresponsive"));
|
|
155
135
|
},
|
|
156
136
|
renderProcessGoneCallback: function (_, details) {
|
|
157
|
-
_this.logger.error("Window received 'render-process-gone' event. Reason: "
|
|
137
|
+
_this.logger.error("Window received 'render-process-gone' event. Reason: " + details.reason, { windowId: windowId });
|
|
158
138
|
// TODO: Handle different reasons for render-process-gone?
|
|
159
139
|
// https://www.electronjs.org/docs/api/web-contents#event-render-process-gone
|
|
160
140
|
_this.windowCrashHandler('render-process-gone');
|
|
161
|
-
errorCallback(new WindowUnresponsiveError_1.default("Window '"
|
|
162
|
-
}
|
|
141
|
+
errorCallback(new WindowUnresponsiveError_1.default("Window '" + windowId + "' render process gone"));
|
|
142
|
+
}
|
|
163
143
|
};
|
|
164
144
|
// Attached crash handlers to skip presentation on error.
|
|
165
145
|
window.view.webContents.on('render-process-gone', window.renderProcessGoneCallback);
|
|
@@ -198,7 +178,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
198
178
|
case 0:
|
|
199
179
|
window = this.getWindow(windowId);
|
|
200
180
|
if (!window) {
|
|
201
|
-
throw new Error("Failed to load window, missing window id '"
|
|
181
|
+
throw new Error("Failed to load window, missing window id '" + windowId + "'");
|
|
202
182
|
}
|
|
203
183
|
return [4 /*yield*/, window.view.webContents.loadURL(url)];
|
|
204
184
|
case 1:
|
|
@@ -211,13 +191,13 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
211
191
|
BrowserWindowRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
|
|
212
192
|
var window = this.getWindow(windowId);
|
|
213
193
|
if (!window) {
|
|
214
|
-
throw new Error("Failed to update window bounds, missing window id '"
|
|
194
|
+
throw new Error("Failed to update window bounds, missing window id '" + windowId + "'");
|
|
215
195
|
}
|
|
216
196
|
window.bounds = bounds;
|
|
217
197
|
if (window.view instanceof electron_1.BrowserWindow && window.parentWindowId) {
|
|
218
198
|
// Child BrowserWindows are absolutely positioned so we need to add the main windows
|
|
219
199
|
// x/y to when updating the child window's bounds.
|
|
220
|
-
window.view.setBounds(__assign(
|
|
200
|
+
window.view.setBounds(__assign({}, window.bounds, { x: window.bounds.x + this.opts.bounds.x, y: window.bounds.y + this.opts.bounds.y }));
|
|
221
201
|
}
|
|
222
202
|
else {
|
|
223
203
|
window.view.setBounds(window.bounds);
|
|
@@ -226,7 +206,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
226
206
|
BrowserWindowRenderer.prototype.showWindow = function (windowId, isFocused) {
|
|
227
207
|
var window = this.getWindow(windowId);
|
|
228
208
|
if (!window) {
|
|
229
|
-
throw new Error("Failed to show window, missing window id '"
|
|
209
|
+
throw new Error("Failed to show window, missing window id '" + windowId + "'");
|
|
230
210
|
}
|
|
231
211
|
if (window.view instanceof electron_1.BrowserWindow) {
|
|
232
212
|
if (isFocused) {
|
|
@@ -248,7 +228,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
248
228
|
BrowserWindowRenderer.prototype.hideWindow = function (windowId) {
|
|
249
229
|
var window = this.getWindow(windowId);
|
|
250
230
|
if (!window) {
|
|
251
|
-
throw new Error("Failed to hide window, missing window id '"
|
|
231
|
+
throw new Error("Failed to hide window, missing window id '" + windowId + "'");
|
|
252
232
|
}
|
|
253
233
|
if (window.view instanceof electron_1.BrowserWindow) {
|
|
254
234
|
window.view.hide();
|
|
@@ -265,7 +245,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
265
245
|
case 0:
|
|
266
246
|
window = this.getWindow(windowId);
|
|
267
247
|
if (!window) {
|
|
268
|
-
throw new Error("Failed to remove window, missing window id '"
|
|
248
|
+
throw new Error("Failed to remove window, missing window id '" + windowId + "'");
|
|
269
249
|
}
|
|
270
250
|
// Remove crash handlers
|
|
271
251
|
window.view.webContents.removeListener('render-process-gone', window.renderProcessGoneCallback);
|
|
@@ -296,31 +276,24 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
296
276
|
});
|
|
297
277
|
});
|
|
298
278
|
};
|
|
299
|
-
BrowserWindowRenderer.prototype.
|
|
279
|
+
BrowserWindowRenderer.prototype.sendMessage = function (windowId, message) {
|
|
300
280
|
var window = this.getWindow(windowId);
|
|
301
281
|
if (!window) {
|
|
302
|
-
throw new Error("Failed to send message to window, missing window id '"
|
|
282
|
+
throw new Error("Failed to send message to window, missing window id '" + windowId + "'");
|
|
303
283
|
}
|
|
304
284
|
window.view.webContents.send('electron-main', message);
|
|
305
285
|
};
|
|
306
|
-
BrowserWindowRenderer.prototype.sendMessageObject = function (windowId, type, payload) {
|
|
307
|
-
var window = this.getWindow(windowId);
|
|
308
|
-
if (!window) {
|
|
309
|
-
throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
|
|
310
|
-
}
|
|
311
|
-
window.view.webContents.send('electron-main', { type: type, payload: payload });
|
|
312
|
-
};
|
|
313
286
|
BrowserWindowRenderer.prototype.muteWindow = function (windowId) {
|
|
314
287
|
var window = this.getWindow(windowId);
|
|
315
288
|
if (!window) {
|
|
316
|
-
throw new Error("Failed to mute window, missing window id '"
|
|
289
|
+
throw new Error("Failed to mute window, missing window id '" + windowId + "'");
|
|
317
290
|
}
|
|
318
291
|
window.view.webContents.setAudioMuted(true);
|
|
319
292
|
};
|
|
320
293
|
BrowserWindowRenderer.prototype.unMuteWindow = function (windowId) {
|
|
321
294
|
var window = this.getWindow(windowId);
|
|
322
295
|
if (!window) {
|
|
323
|
-
throw new Error("Failed to unmute window, missing window id '"
|
|
296
|
+
throw new Error("Failed to unmute window, missing window id '" + windowId + "'");
|
|
324
297
|
}
|
|
325
298
|
window.view.webContents.setAudioMuted(false);
|
|
326
299
|
};
|
|
@@ -339,7 +312,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
339
312
|
BrowserWindowRenderer.prototype.addWindowToParent = function (parentWindowId, window) {
|
|
340
313
|
var parentWindow = this.getWindow(parentWindowId);
|
|
341
314
|
if (!parentWindow) {
|
|
342
|
-
throw new Error("Failed to add window to parent, missing parent window id '"
|
|
315
|
+
throw new Error("Failed to add window to parent, missing parent window id '" + parentWindowId + "'");
|
|
343
316
|
}
|
|
344
317
|
if (parentWindow.view instanceof electron_1.BrowserWindow) {
|
|
345
318
|
if (window.view instanceof electron_1.BrowserView) {
|
|
@@ -347,34 +320,34 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
347
320
|
parentWindow.view.addBrowserView(window.view);
|
|
348
321
|
}
|
|
349
322
|
else {
|
|
350
|
-
throw new Error("Failed add window to parent window id '"
|
|
323
|
+
throw new Error("Failed add window to parent window id '" + parentWindowId + "', child window is not a BrowserView");
|
|
351
324
|
}
|
|
352
325
|
}
|
|
353
326
|
else {
|
|
354
|
-
throw new Error("Failed add window to parent window id '"
|
|
327
|
+
throw new Error("Failed add window to parent window id '" + parentWindowId + "', parent window is not a BrowserWindow");
|
|
355
328
|
}
|
|
356
329
|
};
|
|
357
330
|
BrowserWindowRenderer.prototype.removeWindowFromParent = function (parentWindowId, window) {
|
|
358
331
|
var parentWindow = this.getWindow(parentWindowId);
|
|
359
332
|
if (!parentWindow) {
|
|
360
|
-
throw new Error("Failed to remove window from parent, missing parent window id '"
|
|
333
|
+
throw new Error("Failed to remove window from parent, missing parent window id '" + parentWindowId + "'");
|
|
361
334
|
}
|
|
362
335
|
if (parentWindow.view instanceof electron_1.BrowserWindow) {
|
|
363
336
|
if (window.view instanceof electron_1.BrowserView) {
|
|
364
337
|
parentWindow.view.removeBrowserView(window.view);
|
|
365
338
|
}
|
|
366
339
|
else {
|
|
367
|
-
throw new Error("Failed remove window from parent window id '"
|
|
340
|
+
throw new Error("Failed remove window from parent window id '" + parentWindowId + "', child window is not a BrowserView");
|
|
368
341
|
}
|
|
369
342
|
}
|
|
370
343
|
else {
|
|
371
|
-
throw new Error("Failed remove window from parent window id '"
|
|
344
|
+
throw new Error("Failed remove window from parent window id '" + parentWindowId + "', parent window is not a BrowserWindow");
|
|
372
345
|
}
|
|
373
346
|
};
|
|
374
347
|
BrowserWindowRenderer.prototype.getParentBrowserView = function (parentWindowId) {
|
|
375
348
|
var parentWindow = this.getWindow(parentWindowId);
|
|
376
349
|
if (!parentWindow) {
|
|
377
|
-
throw new Error("Failed to get parent BrowserView, missing parent window id '"
|
|
350
|
+
throw new Error("Failed to get parent BrowserView, missing parent window id '" + parentWindowId + "'");
|
|
378
351
|
}
|
|
379
352
|
if (!(parentWindow.view instanceof electron_1.BrowserWindow)) {
|
|
380
353
|
throw new Error("Failed to get parent BrowserView, window is not a BrowserView");
|
|
@@ -390,7 +363,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
390
363
|
}
|
|
391
364
|
else {
|
|
392
365
|
this.logger.info("No free browser windows, adding new window to pool", {
|
|
393
|
-
windowId: windowId
|
|
366
|
+
windowId: windowId
|
|
394
367
|
});
|
|
395
368
|
}
|
|
396
369
|
}
|
|
@@ -439,7 +412,7 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
439
412
|
}
|
|
440
413
|
else {
|
|
441
414
|
this.logger.info("No free browser views, adding new view to pool", {
|
|
442
|
-
windowId: windowId
|
|
415
|
+
windowId: windowId
|
|
443
416
|
});
|
|
444
417
|
}
|
|
445
418
|
}
|
|
@@ -484,8 +457,8 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
484
457
|
BrowserWindowRenderer.prototype.logPoolStats = function () {
|
|
485
458
|
var bwSize = this.browserWindowPool.size();
|
|
486
459
|
var bvSize = this.browserViewPool.size();
|
|
487
|
-
this.logger.info("BrowserWindow pool total="
|
|
488
|
-
this.logger.info("BrowserView pool total="
|
|
460
|
+
this.logger.info("BrowserWindow pool total=" + bwSize.total + " inuse=" + bwSize.inuse + " free=" + bwSize.free);
|
|
461
|
+
this.logger.info("BrowserView pool total=" + bvSize.total + " inuse=" + bvSize.inuse + " free=" + bvSize.free);
|
|
489
462
|
};
|
|
490
463
|
return BrowserWindowRenderer;
|
|
491
464
|
}());
|
|
@@ -517,7 +490,7 @@ var WindowPool = /** @class */ (function () {
|
|
|
517
490
|
return {
|
|
518
491
|
total: inuse + free,
|
|
519
492
|
inuse: inuse,
|
|
520
|
-
free: free
|
|
493
|
+
free: free
|
|
521
494
|
};
|
|
522
495
|
};
|
|
523
496
|
return WindowPool;
|
|
@@ -3,18 +3,16 @@ export default class IFrameRenderer implements PresentationWindowRenderer {
|
|
|
3
3
|
private container;
|
|
4
4
|
private windows;
|
|
5
5
|
constructor(container: HTMLElement);
|
|
6
|
-
createWindow({ windowId, bounds, backgroundColor, receiveMessageCallback
|
|
6
|
+
createWindow({ windowId, bounds, backgroundColor, receiveMessageCallback }: CreateWindowOptions): Promise<void>;
|
|
7
7
|
loadWindow(windowId: string, url: string): Promise<void>;
|
|
8
8
|
updateWindowBounds(windowId: string, bounds: WindowBounds): void;
|
|
9
9
|
showWindow(windowId: string, isFocused: boolean): void;
|
|
10
10
|
hideWindow(windowId: string): void;
|
|
11
11
|
removeWindow(windowId: string): Promise<void>;
|
|
12
|
-
|
|
13
|
-
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
12
|
+
sendMessage(windowId: string, message: string): void;
|
|
14
13
|
muteWindow(windowId: string): void;
|
|
15
14
|
unMuteWindow(windowId: string): void;
|
|
16
15
|
destroy(): void;
|
|
17
16
|
private getWindow;
|
|
18
17
|
private globalMessageHandler;
|
|
19
|
-
private deserializeMessage;
|
|
20
18
|
}
|