@raydiant/playlist-window-manager 0.28.2-rc3 → 0.28.2-rc4
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.
|
@@ -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,36 @@ 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
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
950
|
+
return __generator(this, function (_a) {
|
|
951
|
+
switch (_a.label) {
|
|
952
|
+
case 0:
|
|
953
|
+
if (!this.currentWindow) return [3 /*break*/, 2];
|
|
954
|
+
this.currentWindow.hide();
|
|
955
|
+
return [4 /*yield*/, this.removeCurrentWindow()];
|
|
956
|
+
case 1:
|
|
957
|
+
_a.sent();
|
|
958
|
+
_a.label = 2;
|
|
959
|
+
case 2:
|
|
960
|
+
resolve(undefined);
|
|
961
|
+
return [2 /*return*/];
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}); }, _this.options.closeWindowDelayMs);
|
|
965
|
+
});
|
|
966
|
+
return [3 /*break*/, 3];
|
|
967
|
+
case 1:
|
|
954
968
|
this.currentWindow.hide();
|
|
955
969
|
return [4 /*yield*/, this.removeCurrentWindow()];
|
|
956
|
-
case 1:
|
|
957
|
-
_a.sent();
|
|
958
|
-
_a.label = 2;
|
|
959
970
|
case 2:
|
|
971
|
+
_a.sent();
|
|
972
|
+
_a.label = 3;
|
|
973
|
+
case 3:
|
|
960
974
|
// Swap windows.
|
|
961
975
|
this.currentWindow = this.nextWindow;
|
|
962
976
|
if (this.currentWindow) {
|
|
@@ -984,12 +998,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
984
998
|
this.nextWindow = null;
|
|
985
999
|
this.nextPresentation = null;
|
|
986
1000
|
}
|
|
987
|
-
if (!closeWindowPromise) return [3 /*break*/,
|
|
1001
|
+
if (!closeWindowPromise) return [3 /*break*/, 5];
|
|
988
1002
|
return [4 /*yield*/, closeWindowPromise];
|
|
989
|
-
case
|
|
1003
|
+
case 4:
|
|
990
1004
|
_a.sent();
|
|
991
|
-
_a.label =
|
|
992
|
-
case
|
|
1005
|
+
_a.label = 5;
|
|
1006
|
+
case 5: return [2 /*return*/];
|
|
993
1007
|
}
|
|
994
1008
|
});
|
|
995
1009
|
});
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -762,10 +760,19 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
762
760
|
if (this.options.closeWindowDelayMs !== undefined) {
|
|
763
761
|
// Don't await here because this will cause a slight delay when playing the next window.
|
|
764
762
|
// Instead we want to wait for window close at the end of this method.
|
|
765
|
-
closeWindowPromise =
|
|
763
|
+
closeWindowPromise = new Promise((resolve) => {
|
|
764
|
+
setTimeout(async () => {
|
|
765
|
+
if (this.currentWindow) {
|
|
766
|
+
this.currentWindow.hide();
|
|
767
|
+
await this.removeCurrentWindow();
|
|
768
|
+
}
|
|
769
|
+
resolve(undefined);
|
|
770
|
+
}, this.options.closeWindowDelayMs);
|
|
771
|
+
});
|
|
772
|
+
} else {
|
|
773
|
+
this.currentWindow.hide();
|
|
774
|
+
await this.removeCurrentWindow();
|
|
766
775
|
}
|
|
767
|
-
this.currentWindow.hide();
|
|
768
|
-
await this.removeCurrentWindow();
|
|
769
776
|
}
|
|
770
777
|
|
|
771
778
|
// Swap windows.
|