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