@raydiant/playlist-window-manager 0.28.2-rc2 → 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");
|
|
@@ -905,7 +904,8 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
905
904
|
};
|
|
906
905
|
PlaylistWindowManager.prototype.swapWindows = function () {
|
|
907
906
|
return __awaiter(this, void 0, void 0, function () {
|
|
908
|
-
var nextPreviewPresentationId, preview, result, nextPresentation, shouldPreload;
|
|
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,19 +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
|
-
if (!(this.options.closeWindowDelayMs !== undefined)) return [3 /*break*/,
|
|
946
|
-
|
|
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];
|
|
947
967
|
case 1:
|
|
948
|
-
_a.sent();
|
|
949
|
-
_a.label = 2;
|
|
950
|
-
case 2:
|
|
951
968
|
this.currentWindow.hide();
|
|
952
969
|
return [4 /*yield*/, this.removeCurrentWindow()];
|
|
953
|
-
case
|
|
970
|
+
case 2:
|
|
954
971
|
_a.sent();
|
|
955
|
-
_a.label =
|
|
956
|
-
case
|
|
972
|
+
_a.label = 3;
|
|
973
|
+
case 3:
|
|
957
974
|
// Swap windows.
|
|
958
975
|
this.currentWindow = this.nextWindow;
|
|
959
976
|
if (this.currentWindow) {
|
|
@@ -981,7 +998,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
981
998
|
this.nextWindow = null;
|
|
982
999
|
this.nextPresentation = null;
|
|
983
1000
|
}
|
|
984
|
-
return [
|
|
1001
|
+
if (!closeWindowPromise) return [3 /*break*/, 5];
|
|
1002
|
+
return [4 /*yield*/, closeWindowPromise];
|
|
1003
|
+
case 4:
|
|
1004
|
+
_a.sent();
|
|
1005
|
+
_a.label = 5;
|
|
1006
|
+
case 5: return [2 /*return*/];
|
|
985
1007
|
}
|
|
986
1008
|
});
|
|
987
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;
|
|
@@ -753,16 +751,28 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
753
751
|
|
|
754
752
|
// If current window isn't defined we don't need to hide it but we still
|
|
755
753
|
// want to make the next window the new current window.
|
|
754
|
+
let closeWindowPromise;
|
|
756
755
|
if (this.currentWindow) {
|
|
757
756
|
// TODO: Kind of a hack, could use win.on('show') event to trigger hide?
|
|
758
757
|
// Would only work in electron environment so need to do in BrowserWindowRenderer.
|
|
759
758
|
// Should show be async then?
|
|
760
759
|
// Or try paintWhenInitiallyHidden: false?
|
|
761
760
|
if (this.options.closeWindowDelayMs !== undefined) {
|
|
762
|
-
await delay
|
|
761
|
+
// Don't await here because this will cause a slight delay when playing the next window.
|
|
762
|
+
// Instead we want to wait for window close at the end of this method.
|
|
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();
|
|
763
775
|
}
|
|
764
|
-
this.currentWindow.hide();
|
|
765
|
-
await this.removeCurrentWindow();
|
|
766
776
|
}
|
|
767
777
|
|
|
768
778
|
// Swap windows.
|
|
@@ -795,6 +805,10 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
795
805
|
this.nextWindow = null;
|
|
796
806
|
this.nextPresentation = null;
|
|
797
807
|
}
|
|
808
|
+
|
|
809
|
+
if (closeWindowPromise) {
|
|
810
|
+
await closeWindowPromise;
|
|
811
|
+
}
|
|
798
812
|
}
|
|
799
813
|
|
|
800
814
|
private evalRuleEngine(warnIfPreloadMismatch = true): EvalRuleEngineResult {
|