@raydiant/playlist-window-manager 0.21.2 → 0.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydiant/playlist-window-manager",
3
- "version": "0.21.2",
3
+ "version": "0.21.3",
4
4
  "description": "Window manager for playlist playback.",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@ export interface PresentationWindowOptions {
55
55
  }
56
56
 
57
57
  // TODO: Automatically inject latest version when building in CI.
58
- const defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.2/index.html';
58
+ const defaultAppRendererUrl = 'https://apps.raydiant.com/3.0.3/index.html';
59
59
 
60
60
  const isValidNumber = (value: any) =>
61
61
  typeof value === 'number' && !isNaN(value);
@@ -1,19 +0,0 @@
1
- import { BrowserWindow } from 'electron';
2
- import { PresentationWindowRenderer, CreateWindowOptions, WindowBounds } from './types';
3
- export default class BrowserViewRenderer implements PresentationWindowRenderer {
4
- private mainWindow;
5
- private offscreenWindow;
6
- private windows;
7
- constructor(mainWindow: BrowserWindow, offscreenWindow: BrowserWindow);
8
- createWindow({ windowId, parentWindowId, bounds, backgroundColor, receiveMessageCallback, }: CreateWindowOptions): Promise<void>;
9
- loadWindow(windowId: string, url: string): Promise<void>;
10
- updateWindowBounds(windowId: string, bounds: WindowBounds): void;
11
- showWindow(windowId: string, isFocused: boolean): void;
12
- hideWindow(windowId: string): void;
13
- removeWindow(windowId: string): Promise<void>;
14
- sendMessageString(windowId: string, message: string): void;
15
- sendMessageObject(windowId: string, type: string, payload?: any): void;
16
- muteWindow(windowId: string): void;
17
- unMuteWindow(windowId: string): void;
18
- private getWindow;
19
- }
@@ -1,212 +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
- Object.defineProperty(exports, "__esModule", { value: true });
73
- var path = __importStar(require("path"));
74
- var electron_1 = require("electron");
75
- var BrowserViewRenderer = /** @class */ (function () {
76
- function BrowserViewRenderer(mainWindow, offscreenWindow) {
77
- this.mainWindow = mainWindow;
78
- this.offscreenWindow = offscreenWindow;
79
- this.windows = {};
80
- }
81
- BrowserViewRenderer.prototype.createWindow = function (_a) {
82
- var windowId = _a.windowId, parentWindowId = _a.parentWindowId, bounds = _a.bounds, backgroundColor = _a.backgroundColor, receiveMessageCallback = _a.receiveMessageCallback;
83
- return __awaiter(this, void 0, void 0, function () {
84
- var window;
85
- return __generator(this, function (_b) {
86
- window = {
87
- view: new electron_1.BrowserView({
88
- webPreferences: {
89
- preload: path.join(__dirname, 'preload.js'),
90
- },
91
- }),
92
- bounds: bounds || __assign(__assign({}, this.mainWindow.getBounds()), { x: 0, y: 0 }),
93
- receiveMessageCallback: function (_, type, payload) {
94
- if (receiveMessageCallback) {
95
- receiveMessageCallback(type, payload);
96
- }
97
- },
98
- };
99
- this.windows[windowId] = window;
100
- electron_1.ipcMain.on(windowId, window.receiveMessageCallback);
101
- this.offscreenWindow.addBrowserView(window.view);
102
- window.view.setBounds(window.bounds);
103
- if (backgroundColor) {
104
- window.view.setBackgroundColor(backgroundColor);
105
- }
106
- // The main window browserviews should auto size with the container but child window
107
- // browser views have their own resize handlers and are updated via updateWindowBounds.
108
- if (!parentWindowId) {
109
- window.view.setAutoResize({
110
- width: true,
111
- height: true,
112
- });
113
- }
114
- return [2 /*return*/];
115
- });
116
- });
117
- };
118
- BrowserViewRenderer.prototype.loadWindow = function (windowId, url) {
119
- return __awaiter(this, void 0, void 0, function () {
120
- var window;
121
- return __generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0:
124
- window = this.getWindow(windowId);
125
- if (!window) {
126
- throw new Error("Failed to load window, missing window id '".concat(windowId, "'"));
127
- }
128
- return [4 /*yield*/, window.view.webContents.loadURL(url)];
129
- case 1:
130
- _a.sent();
131
- return [2 /*return*/];
132
- }
133
- });
134
- });
135
- };
136
- BrowserViewRenderer.prototype.updateWindowBounds = function (windowId, bounds) {
137
- var window = this.getWindow(windowId);
138
- if (!window) {
139
- throw new Error("Failed to update window bounds, missing window id '".concat(windowId, "'"));
140
- }
141
- window.bounds = bounds;
142
- window.view.setBounds(window.bounds);
143
- };
144
- BrowserViewRenderer.prototype.showWindow = function (windowId, isFocused) {
145
- var window = this.getWindow(windowId);
146
- if (!window) {
147
- throw new Error("Failed to show window, missing window id '".concat(windowId, "'"));
148
- }
149
- this.mainWindow.addBrowserView(window.view);
150
- if (isFocused) {
151
- // The setTimeout is required to set focus after the BrowserView has
152
- // been added to the parent BrowserWindow.
153
- setTimeout(function () { return window.view.webContents.focus(); }, 0);
154
- }
155
- };
156
- BrowserViewRenderer.prototype.hideWindow = function (windowId) {
157
- var window = this.getWindow(windowId);
158
- if (!window) {
159
- throw new Error("Failed to hide window, missing window id '".concat(windowId, "'"));
160
- }
161
- this.offscreenWindow.addBrowserView(window.view);
162
- };
163
- BrowserViewRenderer.prototype.removeWindow = function (windowId) {
164
- return __awaiter(this, void 0, void 0, function () {
165
- var window;
166
- return __generator(this, function (_a) {
167
- window = this.getWindow(windowId);
168
- if (!window) {
169
- throw new Error("Failed to hide window, missing window id '".concat(windowId, "'"));
170
- }
171
- this.hideWindow(windowId);
172
- window.view.webContents.loadURL('about:blank');
173
- electron_1.ipcMain.off(windowId, window.receiveMessageCallback);
174
- delete this.windows[windowId];
175
- return [2 /*return*/];
176
- });
177
- });
178
- };
179
- BrowserViewRenderer.prototype.sendMessageString = function (windowId, message) {
180
- var window = this.getWindow(windowId);
181
- if (!window) {
182
- throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
183
- }
184
- window.view.webContents.send('electron-main', message);
185
- };
186
- BrowserViewRenderer.prototype.sendMessageObject = function (windowId, type, payload) {
187
- var window = this.getWindow(windowId);
188
- if (!window) {
189
- throw new Error("Failed to send message to window, missing window id '".concat(windowId, "'"));
190
- }
191
- window.view.webContents.send('electron-main', { type: type, payload: payload });
192
- };
193
- BrowserViewRenderer.prototype.muteWindow = function (windowId) {
194
- var window = this.getWindow(windowId);
195
- if (!window) {
196
- throw new Error("Failed to mute window, missing window id '".concat(windowId, "'"));
197
- }
198
- window.view.webContents.setAudioMuted(true);
199
- };
200
- BrowserViewRenderer.prototype.unMuteWindow = function (windowId) {
201
- var window = this.getWindow(windowId);
202
- if (!window) {
203
- throw new Error("Failed to unmute window, missing window id '".concat(windowId, "'"));
204
- }
205
- window.view.webContents.setAudioMuted(false);
206
- };
207
- BrowserViewRenderer.prototype.getWindow = function (windowId) {
208
- return this.windows[windowId];
209
- };
210
- return BrowserViewRenderer;
211
- }());
212
- exports.default = BrowserViewRenderer;
@@ -1,47 +0,0 @@
1
- import { PresentationWindowRenderer, CreateWindowOptions, WindowBounds, Logger } from './types';
2
- interface ProxySettings {
3
- proxyRules: string;
4
- proxyBypassRules: string;
5
- }
6
- interface BrowserWindowRendererOptions {
7
- bounds: WindowBounds;
8
- frame: boolean;
9
- hasShadow: boolean;
10
- renderChildWindowsAsBrowserViews: boolean;
11
- useWindowPool: boolean;
12
- logger: Logger;
13
- proxySettings?: ProxySettings;
14
- windowCrashHandler?: () => void;
15
- }
16
- export default class BrowserWindowRenderer implements PresentationWindowRenderer {
17
- private opts;
18
- private windows;
19
- private windowCrashHandler;
20
- private browserWindowPool;
21
- private browserViewPool;
22
- private offscreenWindow;
23
- private proxySettings;
24
- private logger;
25
- constructor(opts: BrowserWindowRendererOptions);
26
- createWindow({ windowId, parentWindowId, bounds, backgroundColor, receiveMessageCallback, errorCallback, }: CreateWindowOptions): Promise<void>;
27
- loadWindow(windowId: string, url: string): Promise<void>;
28
- updateWindowBounds(windowId: string, bounds: WindowBounds): void;
29
- showWindow(windowId: string, isFocused: boolean): void;
30
- hideWindow(windowId: string): void;
31
- removeWindow(windowId: string): Promise<void>;
32
- sendMessageString(windowId: string, message: string): void;
33
- sendMessageObject(windowId: string, type: string, payload?: any): void;
34
- muteWindow(windowId: string): void;
35
- unMuteWindow(windowId: string): void;
36
- private getWindow;
37
- private moveWindowOffscreen;
38
- private addWindowToParent;
39
- private removeWindowFromParent;
40
- private getParentBrowserView;
41
- private createOrGetPooledBrowserWindow;
42
- private destroyOrUnloadPooledBrowserWindow;
43
- private createOrGetPooledBrowserView;
44
- private destroyOrUnloadPooledBrowserView;
45
- private logPoolStats;
46
- }
47
- export {};