@raydiant/playlist-window-manager 0.28.2 → 0.29.1-rc1
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.
|
@@ -17,6 +17,7 @@ export interface PlaylistWindowManagerOptions {
|
|
|
17
17
|
parentWindowId?: string;
|
|
18
18
|
windowName?: string;
|
|
19
19
|
isPreview?: boolean;
|
|
20
|
+
closeWindowDelayMs?: number;
|
|
20
21
|
onEnableInterruptLock?: () => void;
|
|
21
22
|
onDisableInterruptLock?: () => void;
|
|
22
23
|
getTerminal?: () => Terminal | null;
|
|
@@ -904,7 +904,8 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
904
904
|
};
|
|
905
905
|
PlaylistWindowManager.prototype.swapWindows = function () {
|
|
906
906
|
return __awaiter(this, void 0, void 0, function () {
|
|
907
|
-
var nextPreviewPresentationId, preview, result, nextPresentation, shouldPreload;
|
|
907
|
+
var nextPreviewPresentationId, preview, result, nextPresentation, shouldPreload, closeWindowPromise;
|
|
908
|
+
var _this = this;
|
|
908
909
|
return __generator(this, function (_a) {
|
|
909
910
|
switch (_a.label) {
|
|
910
911
|
case 0:
|
|
@@ -940,13 +941,42 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
940
941
|
if (this.nextWindow) {
|
|
941
942
|
this.nextWindow.show(this.isFocused);
|
|
942
943
|
}
|
|
943
|
-
if (!this.currentWindow) return [3 /*break*/,
|
|
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
|
+
// We can't use this.removeCurrentWindow because the currentWindow reference has already
|
|
958
|
+
// changed by the time the timeout fires.
|
|
959
|
+
return [4 /*yield*/, windowToClose.remove()];
|
|
960
|
+
case 1:
|
|
961
|
+
// We can't use this.removeCurrentWindow because the currentWindow reference has already
|
|
962
|
+
// changed by the time the timeout fires.
|
|
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:
|
|
944
974
|
this.currentWindow.hide();
|
|
945
975
|
return [4 /*yield*/, this.removeCurrentWindow()];
|
|
946
|
-
case 1:
|
|
947
|
-
_a.sent();
|
|
948
|
-
_a.label = 2;
|
|
949
976
|
case 2:
|
|
977
|
+
_a.sent();
|
|
978
|
+
_a.label = 3;
|
|
979
|
+
case 3:
|
|
950
980
|
// Swap windows.
|
|
951
981
|
this.currentWindow = this.nextWindow;
|
|
952
982
|
if (this.currentWindow) {
|
|
@@ -974,7 +1004,12 @@ var PlaylistWindowManager = /** @class */ (function (_super) {
|
|
|
974
1004
|
this.nextWindow = null;
|
|
975
1005
|
this.nextPresentation = null;
|
|
976
1006
|
}
|
|
977
|
-
return [
|
|
1007
|
+
if (!closeWindowPromise) return [3 /*break*/, 5];
|
|
1008
|
+
return [4 /*yield*/, closeWindowPromise];
|
|
1009
|
+
case 4:
|
|
1010
|
+
_a.sent();
|
|
1011
|
+
_a.label = 5;
|
|
1012
|
+
case 5: return [2 /*return*/];
|
|
978
1013
|
}
|
|
979
1014
|
});
|
|
980
1015
|
});
|
package/build/preload.js
CHANGED
|
@@ -89,3 +89,12 @@ Object.defineProperty(window, 'removeEventListener', {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
});
|
|
92
|
+
// Hide the Cast button on video elements to prevent casting from the device.
|
|
93
|
+
// After trying many different approaches including flags, chrome policies and
|
|
94
|
+
// blocking ports, the only reliable way to hide the Cast button is via CSS without
|
|
95
|
+
// updating every video element with disableRemotePlayback.
|
|
96
|
+
window.addEventListener('DOMContentLoaded', function () {
|
|
97
|
+
var style = document.createElement('style');
|
|
98
|
+
style.textContent = "\n video::-internal-media-controls-overlay-cast-button {\n display: none !important;\n }\n ";
|
|
99
|
+
document.head.append(style);
|
|
100
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raydiant/playlist-window-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1-rc1",
|
|
4
4
|
"description": "Window manager for playlist playback.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"deploy": "sh tasks/npm-publish.sh"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@raydiant/playlist-rule-engine": "3.3.0",
|
|
15
|
-
"eventemitter3": "^4.0.7",
|
|
16
14
|
"fast-deep-equal": "^3.1.3",
|
|
15
|
+
"@raydiant/playlist-rule-engine": "3.3.0",
|
|
17
16
|
"raydiant-kit": "4.7.3",
|
|
18
|
-
"uuid": "^8.3.0"
|
|
17
|
+
"uuid": "^8.3.0",
|
|
18
|
+
"eventemitter3": "^4.0.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/core": "^7.5.5",
|
|
22
|
-
"@types/jest": "^24.0.15",
|
|
23
22
|
"@types/jschannel": "^1.0.1",
|
|
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"
|
|
@@ -70,6 +70,8 @@ export interface PlaylistWindowManagerOptions {
|
|
|
70
70
|
// Set to true to render the presentation window as a preview.
|
|
71
71
|
isPreview?: boolean;
|
|
72
72
|
|
|
73
|
+
closeWindowDelayMs?: number;
|
|
74
|
+
|
|
73
75
|
// Called when the current window wants to enable the interrupt lock
|
|
74
76
|
onEnableInterruptLock?: () => void;
|
|
75
77
|
|
|
@@ -749,9 +751,28 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
749
751
|
|
|
750
752
|
// If current window isn't defined we don't need to hide it but we still
|
|
751
753
|
// want to make the next window the new current window.
|
|
754
|
+
let closeWindowPromise;
|
|
752
755
|
if (this.currentWindow) {
|
|
753
|
-
this.
|
|
754
|
-
|
|
756
|
+
if (this.options.closeWindowDelayMs !== undefined) {
|
|
757
|
+
// Don't await here because this will cause a slight delay when playing the next window.
|
|
758
|
+
// Instead we want to wait for window close at the end of this method.
|
|
759
|
+
closeWindowPromise = new Promise((resolve) => {
|
|
760
|
+
// Capture the current window reference to close because this.currentWindow will be
|
|
761
|
+
// set to the next window before the timeout fires.
|
|
762
|
+
const windowToClose = this.currentWindow;
|
|
763
|
+
setTimeout(async () => {
|
|
764
|
+
if (windowToClose) {
|
|
765
|
+
// We can't use this.removeCurrentWindow because the currentWindow reference has already
|
|
766
|
+
// changed by the time the timeout fires.
|
|
767
|
+
await windowToClose.remove();
|
|
768
|
+
}
|
|
769
|
+
resolve(undefined);
|
|
770
|
+
}, this.options.closeWindowDelayMs);
|
|
771
|
+
});
|
|
772
|
+
} else {
|
|
773
|
+
this.currentWindow.hide();
|
|
774
|
+
await this.removeCurrentWindow();
|
|
775
|
+
}
|
|
755
776
|
}
|
|
756
777
|
|
|
757
778
|
// Swap windows.
|
|
@@ -784,6 +805,10 @@ export default class PlaylistWindowManager extends EventEmitter {
|
|
|
784
805
|
this.nextWindow = null;
|
|
785
806
|
this.nextPresentation = null;
|
|
786
807
|
}
|
|
808
|
+
|
|
809
|
+
if (closeWindowPromise) {
|
|
810
|
+
await closeWindowPromise;
|
|
811
|
+
}
|
|
787
812
|
}
|
|
788
813
|
|
|
789
814
|
private evalRuleEngine(warnIfPreloadMismatch = true): EvalRuleEngineResult {
|
package/src/preload.ts
CHANGED
|
@@ -106,3 +106,18 @@ Object.defineProperty(window, 'removeEventListener', {
|
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
|
+
|
|
110
|
+
// Hide the Cast button on video elements to prevent casting from the device.
|
|
111
|
+
// After trying many different approaches including flags, chrome policies and
|
|
112
|
+
// blocking ports, the only reliable way to hide the Cast button is via CSS without
|
|
113
|
+
// updating every video element with disableRemotePlayback.
|
|
114
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
115
|
+
const style = document.createElement('style');
|
|
116
|
+
style.textContent = `
|
|
117
|
+
video::-internal-media-controls-overlay-cast-button {
|
|
118
|
+
display: none !important;
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
document.head.append(style);
|
|
123
|
+
});
|
package/tasks/npm-publish.sh
CHANGED