@raydiant/playlist-window-manager 0.0.0-test-26 → 0.0.0-test-28

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