@clockworkdog/cogs-client 2.1.0 → 2.2.0
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/dist/CogsConnection.d.ts +4 -0
- package/dist/CogsConnection.js +19 -4
- package/dist/browser/index.js +20 -5
- package/package.json +1 -1
package/dist/CogsConnection.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export default class CogsConnection<Manifest extends CogsPluginManifest> {
|
|
|
35
35
|
private audioOutputs;
|
|
36
36
|
private _selectedAudioOutput;
|
|
37
37
|
get selectedAudioOutput(): string;
|
|
38
|
+
/**
|
|
39
|
+
* URL parameters use for the websocket connection and asset URLs
|
|
40
|
+
*/
|
|
41
|
+
private urlParams;
|
|
38
42
|
constructor(manifest: Manifest, { hostname, port }?: {
|
|
39
43
|
hostname?: string;
|
|
40
44
|
port?: number;
|
package/dist/CogsConnection.js
CHANGED
|
@@ -28,7 +28,8 @@ class CogsConnection {
|
|
|
28
28
|
* Return asset URLs using the information about the client and server support for HTTP/2
|
|
29
29
|
*/
|
|
30
30
|
getAssetUrl(path) {
|
|
31
|
-
|
|
31
|
+
var _a, _b;
|
|
32
|
+
return `${(0, urls_1.assetUrl)(path, this.supportsHttp2Assets)}?${(_b = (_a = this.urlParams) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''}`;
|
|
32
33
|
}
|
|
33
34
|
get selectedAudioOutput() {
|
|
34
35
|
return this._selectedAudioOutput;
|
|
@@ -53,9 +54,22 @@ class CogsConnection {
|
|
|
53
54
|
*/
|
|
54
55
|
this.audioOutputs = undefined;
|
|
55
56
|
this._selectedAudioOutput = '';
|
|
57
|
+
/**
|
|
58
|
+
* URL parameters use for the websocket connection and asset URLs
|
|
59
|
+
*/
|
|
60
|
+
this.urlParams = null;
|
|
56
61
|
this.currentState = { ...initialClientState };
|
|
57
62
|
const { useReconnectingWebsocket, path, pathParams, supportsHttp2Assets } = websocketParametersFromUrl(document.location.href);
|
|
58
|
-
|
|
63
|
+
// Store the URL parameters for use in asset URLs
|
|
64
|
+
// and add screen dimensions which COGS can use to determine the best asset quality to serve
|
|
65
|
+
//
|
|
66
|
+
// Note that content always runs fullscreen and
|
|
67
|
+
// we assume the screen resolution will not change while the content is running.
|
|
68
|
+
this.urlParams = new URLSearchParams(pathParams);
|
|
69
|
+
this.urlParams.set('screenWidth', window.screen.width.toString());
|
|
70
|
+
this.urlParams.set('screenHeight', window.screen.height.toString());
|
|
71
|
+
this.urlParams.set('screenPixelRatio', window.devicePixelRatio.toString());
|
|
72
|
+
const socketUrl = `ws://${hostname}:${port}${path}?${this.urlParams}`;
|
|
59
73
|
this.websocket = useReconnectingWebsocket ? new reconnecting_websocket_1.default(socketUrl) : new WebSocket(socketUrl);
|
|
60
74
|
this.clientSupportsHttp2Assets = !!supportsHttp2Assets;
|
|
61
75
|
this.websocket.onopen = () => {
|
|
@@ -245,8 +259,9 @@ function websocketParametersFromUrl(url) {
|
|
|
245
259
|
const serial = (_g = pathParams.get('serial')) !== null && _g !== void 0 ? _g : '';
|
|
246
260
|
pathParams.delete('serial');
|
|
247
261
|
// Check if cogs-box-av is a version which added support for ignoring HTTP/2 self-signed certificates
|
|
248
|
-
const
|
|
249
|
-
const
|
|
262
|
+
const firmwareVersion = ((_h = pathParams.get('f')) !== null && _h !== void 0 ? _h : '').replace(/^v/, '');
|
|
263
|
+
const isCogsBoxAvDevBuild = firmwareVersion === '0.0.0'; // We assume dev firmware builds have HTTP/2 assets support - Added in 2024-03
|
|
264
|
+
const supportsHttp2Assets = isCogsBoxAvDevBuild || ((0, compare_versions_1.validate)(firmwareVersion) && (0, compare_versions_1.satisfies)(firmwareVersion, '>=4.9.0'));
|
|
250
265
|
return {
|
|
251
266
|
path: `/client/${encodeURIComponent(serial)}`,
|
|
252
267
|
pathParams,
|