@raydiant/playlist-window-manager 0.28.2-rc3 → 0.28.2-rc5
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.
|
@@ -128,7 +128,6 @@ var BrowserWindowRenderer = /** @class */ (function () {
|
|
|
128
128
|
},
|
|
129
129
|
})
|
|
130
130
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
131
|
-
paintWhenInitiallyHidden: false,
|
|
132
131
|
show: false,
|
|
133
132
|
/**
|
|
134
133
|
* This option fixes window not being able to take fullscreen leaving
|
|
@@ -74,7 +74,6 @@ var WindowLoadError_1 = __importDefault(require("./WindowLoadError"));
|
|
|
74
74
|
// Wait at least 3 seconds before restarting or moving onto the next window
|
|
75
75
|
// to prevent log spam causing devices to become unresponsive.
|
|
76
76
|
var minTimeBetweenCompletes = 3000;
|
|
77
|
-
var delay = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); };
|
|
78
77
|
var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
79
78
|
__extends(PlaylistWindowManager, _super);
|
|
80
79
|
function PlaylistWindowManager(options) {
|
|
@@ -124,7 +123,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
124
123
|
_this.emitCurrentWindowEvent('window_charge_request', request);
|
|
125
124
|
};
|
|
126
125
|
_this.handleCurrentPresentationComplete = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
127
|
-
var logger, isThrottled, now, timeSinceLastComplete,
|
|
126
|
+
var logger, isThrottled, now, timeSinceLastComplete, delay, _a, next, preview, nextPreviewPresentationId;
|
|
128
127
|
var _this = this;
|
|
129
128
|
return __generator(this, function (_b) {
|
|
130
129
|
switch (_b.label) {
|
|
@@ -138,12 +137,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
138
137
|
isThrottled = true;
|
|
139
138
|
// Throttle presentation complete handler if we have not throttled already.
|
|
140
139
|
if (this.currentPresentationCompleteTimeout === null) {
|
|
141
|
-
|
|
142
|
-
logger.warn("Throttling presentation complete handler for ".concat(
|
|
140
|
+
delay = minTimeBetweenCompletes - timeSinceLastComplete + 1;
|
|
141
|
+
logger.warn("Throttling presentation complete handler for ".concat(delay, "ms because it was called again in less than ").concat(minTimeBetweenCompletes, "ms"));
|
|
143
142
|
this.currentPresentationCompleteTimeout = setTimeout(function () {
|
|
144
143
|
_this.currentPresentationCompleteTimeout = null;
|
|
145
144
|
_this.handleCurrentPresentationComplete();
|
|
146
|
-
},
|
|
145
|
+
}, delay);
|
|
147
146
|
}
|
|
148
147
|
else {
|
|
149
148
|
logger.warn("Skipping presentation complete because it is currently throttled");
|
|
@@ -906,6 +905,7 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
906
905
|
PlaylistWindowManager.prototype.swapWindows = function () {
|
|
907
906
|
return __awaiter(this, void 0, void 0, function () {
|
|
908
907
|
var nextPreviewPresentationId, preview, result, nextPresentation, shouldPreload, closeWindowPromise;
|
|
908
|
+
var _this = this;
|
|
909
909
|
return __generator(this, function (_a) {
|
|
910
910
|
switch (_a.label) {
|
|
911
911
|
case 0:
|
|
@@ -941,22 +941,42 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
941
941
|
if (this.nextWindow) {
|
|
942
942
|
this.nextWindow.show(this.isFocused);
|
|
943
943
|
}
|
|
944
|
-
if (!this.currentWindow) return [3 /*break*/,
|
|
945
|
-
|
|
946
|
-
//
|
|
947
|
-
//
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
//
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
944
|
+
if (!this.currentWindow) return [3 /*break*/, 3];
|
|
945
|
+
if (!(this.options.closeWindowDelayMs !== undefined)) return [3 /*break*/, 1];
|
|
946
|
+
// Don't await here because this will cause a slight delay when playing the next window.
|
|
947
|
+
// Instead we want to wait for window close at the end of this method.
|
|
948
|
+
closeWindowPromise = new Promise(function (resolve) {
|
|
949
|
+
// Capture the current window reference to close because this.currentWindow will be
|
|
950
|
+
// set to the next window before the timeout fires.
|
|
951
|
+
var windowToClose = _this.currentWindow;
|
|
952
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
953
|
+
return __generator(this, function (_a) {
|
|
954
|
+
switch (_a.label) {
|
|
955
|
+
case 0:
|
|
956
|
+
if (!windowToClose) return [3 /*break*/, 2];
|
|
957
|
+
// TODO: Do we need to check if the window is already removed/destroyed?
|
|
958
|
+
// TODO: Add a guard in BrowserWindowRenderer.removeWindow to check if the window is destroyed?
|
|
959
|
+
return [4 /*yield*/, windowToClose.remove()];
|
|
960
|
+
case 1:
|
|
961
|
+
// TODO: Do we need to check if the window is already removed/destroyed?
|
|
962
|
+
// TODO: Add a guard in BrowserWindowRenderer.removeWindow to check if the window is destroyed?
|
|
963
|
+
_a.sent();
|
|
964
|
+
_a.label = 2;
|
|
965
|
+
case 2:
|
|
966
|
+
resolve(undefined);
|
|
967
|
+
return [2 /*return*/];
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}); }, _this.options.closeWindowDelayMs);
|
|
971
|
+
});
|
|
972
|
+
return [3 /*break*/, 3];
|
|
973
|
+
case 1:
|
|
954
974
|
this.currentWindow.hide();
|
|
955
975
|
return [4 /*yield*/, this.removeCurrentWindow()];
|
|
956
|
-
case 1:
|
|
957
|
-
_a.sent();
|
|
958
|
-
_a.label = 2;
|
|
959
976
|
case 2:
|
|
977
|
+
_a.sent();
|
|
978
|
+
_a.label = 3;
|
|
979
|
+
case 3:
|
|
960
980
|
// Swap windows.
|
|
961
981
|
this.currentWindow = this.nextWindow;
|
|
962
982
|
if (this.currentWindow) {
|
|
@@ -984,12 +1004,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
984
1004
|
this.nextWindow = null;
|
|
985
1005
|
this.nextPresentation = null;
|
|
986
1006
|
}
|
|
987
|
-
if (!closeWindowPromise) return [3 /*break*/,
|
|
1007
|
+
if (!closeWindowPromise) return [3 /*break*/, 5];
|
|
988
1008
|
return [4 /*yield*/, closeWindowPromise];
|
|
989
|
-
case
|
|
1009
|
+
case 4:
|
|
990
1010
|
_a.sent();
|
|
991
|
-
_a.label =
|
|
992
|
-
case
|
|
1011
|
+
_a.label = 5;
|
|
1012
|
+
case 5: return [2 /*return*/];
|
|
993
1013
|
}
|
|
994
1014
|
});
|
|
995
1015
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raydiant/playlist-window-manager",
|
|
3
|
-
"version": "0.28.2-
|
|
3
|
+
"version": "0.28.2-rc5",
|
|
4
4
|
"description": "Window manager for playlist playback.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@types/jschannel": "^1.0.1",
|
|
23
23
|
"@types/jest": "^24.0.15",
|
|
24
24
|
"@types/uuid": "8.3.0",
|
|
25
|
-
"electron": "
|
|
25
|
+
"electron": "38.0.0",
|
|
26
26
|
"jest": "^24.8.0",
|
|
27
27
|
"ts-jest": "^24.0.2",
|
|
28
28
|
"typescript": "^4.1.2"
|
|
@@ -89,8 +89,6 @@ export interface PlaylistWindowManagerOptions {
|
|
|
89
89
|
// to prevent log spam causing devices to become unresponsive.
|
|
90
90
|
const minTimeBetweenCompletes = 3000;
|
|
91
91
|
|
|
92
|
-
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
|
93
|
-
|
|
94
92
|
interface EvalRuleEngineResult {
|
|
95
93
|
next: RE.NextPresentationID;
|
|
96
94
|
preview: RE.NextPresentationID;
|
|
@@ -751,21 +749,35 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
751
749
|
this.nextWindow.show(this.isFocused);
|
|
752
750
|
}
|
|
753
751
|
|
|
752
|
+
// If current window isn't defined we don't need to hide it but we still
|
|
753
|
+
// want to make the next window the new current window.
|
|
754
754
|
// If current window isn't defined we don't need to hide it but we still
|
|
755
755
|
// want to make the next window the new current window.
|
|
756
756
|
let closeWindowPromise;
|
|
757
757
|
if (this.currentWindow) {
|
|
758
|
-
// TODO: Kind of a hack, could use win.on('show') event to trigger hide?
|
|
759
|
-
// Would only work in electron environment so need to do in BrowserWindowRenderer.
|
|
760
|
-
// Should show be async then?
|
|
761
|
-
// Or try paintWhenInitiallyHidden: false?
|
|
762
758
|
if (this.options.closeWindowDelayMs !== undefined) {
|
|
763
759
|
// Don't await here because this will cause a slight delay when playing the next window.
|
|
764
760
|
// Instead we want to wait for window close at the end of this method.
|
|
765
|
-
closeWindowPromise =
|
|
761
|
+
closeWindowPromise = new Promise((resolve) => {
|
|
762
|
+
// Capture the current window reference to close because this.currentWindow will be
|
|
763
|
+
// set to the next window before the timeout fires.
|
|
764
|
+
const windowToClose = this.currentWindow;
|
|
765
|
+
setTimeout(async () => {
|
|
766
|
+
if (windowToClose) {
|
|
767
|
+
// TODO: Do we need to check if the window is already removed/destroyed?
|
|
768
|
+
// TODO: Add a guard in BrowserWindowRenderer.removeWindow to check if the window is destroyed?
|
|
769
|
+
await windowToClose.remove();
|
|
770
|
+
// TODO: We can't use this.removeCurrentWindow because the currentWindow reference has already
|
|
771
|
+
// changed by the time the timeout fires. Is there a better way to handle this?
|
|
772
|
+
// await this.removeCurrentWindow();
|
|
773
|
+
}
|
|
774
|
+
resolve(undefined);
|
|
775
|
+
}, this.options.closeWindowDelayMs);
|
|
776
|
+
});
|
|
777
|
+
} else {
|
|
778
|
+
this.currentWindow.hide();
|
|
779
|
+
await this.removeCurrentWindow();
|
|
766
780
|
}
|
|
767
|
-
this.currentWindow.hide();
|
|
768
|
-
await this.removeCurrentWindow();
|
|
769
781
|
}
|
|
770
782
|
|
|
771
783
|
// Swap windows.
|