@gcorevideo/player 2.22.24 → 2.22.26
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/assets/clappr-nerd-stats/clappr-nerd-stats.scss +11 -0
- package/assets/seek-time/seek-time.html +3 -2
- package/dist/core.js +1 -1
- package/dist/index.css +1448 -1441
- package/dist/index.js +147 -139
- package/dist/plugins/index.css +724 -724
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +7 -1
- package/lib/plugins/seek-time/SeekTime.d.ts +14 -10
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
- package/lib/plugins/seek-time/SeekTime.js +72 -69
- package/package.json +1 -1
- package/rollup.config.js +28 -28
- package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +0 -3
- package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +1 -0
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +8 -1
- package/src/plugins/seek-time/SeekTime.ts +156 -113
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Speedtest.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IAC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AAG,IAAI,CAAA;CACtB,CAAA;AAED,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAA;AAEnD,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;AAIrD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAsB;IAEpC,OAAO,CAAC,SAAS,CAAsB;IAEvC,OAAO,CAAC,mBAAmB,CAAQ;IAEnC,OAAO,CAAC,eAAe,CAAsB;IAE7C,OAAO,CAAC,WAAW,CAAe;IAElC,OAAO,CAAC,SAAS,CAAU;IAE3B,OAAO,CAAC,MAAM,CAAI;IAElB,OAAO,CAAC,OAAO,CAAuB;IAEtC,OAAO,CAAC,SAAS,CAA8B;IAE/C,OAAO,CAAC,cAAc,CAAK;IAE3B,KAAK,EAAE,UAAU,GAAG,IAAI,CAAO;IAE/B,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAO;IAErC,QAAQ;IAIR,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAY9C,sBAAsB,CAAC,MAAM,EAAE,MAAM;IAiCrC,YAAY,CAAC,MAAM,EAAE,MAAM;IAY3B,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE;IAM5B,iBAAiB;IAQjB,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAShC,YAAY,CAAC,MAAM,EAAE,cAAc;IA0KnC,KAAK;IAuEL,KAAK;IASL,OAAO,CAAC,UAAU;CAUnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clappr-nerd-stats/speedtest/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/clappr-nerd-stats/speedtest/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAkC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqC9C,wBAAgB,oBAAoB,SAoBnC;AAID,eAAO,MAAM,aAAa,kBAAmB,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAmF3E,CAAC;AAEF,eAAO,MAAM,aAAa,YAIzB,CAAC;AAEF,eAAO,MAAM,cAAc,YAI1B,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAGjC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAGnD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { trace } from '@gcorevideo/utils';
|
|
1
2
|
import { Speedtest } from './Speedtest.js';
|
|
2
3
|
const DIGITS_THRESHOLD = 99999;
|
|
3
4
|
const DEFAULT_DOWNLOAD_SPEED = '0.00';
|
|
4
5
|
const DRAW_SIZE = 5;
|
|
5
|
-
|
|
6
|
+
const T = 'plugins.clappr_nerd_stats.speedtest';
|
|
6
7
|
function limitDigits(value) {
|
|
7
8
|
return value > DIGITS_THRESHOLD ? '> ' + DIGITS_THRESHOLD : value.toFixed(2);
|
|
8
9
|
}
|
|
@@ -30,6 +31,7 @@ const getColor = (speedValue) => {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
export function drawSpeedTestResults() {
|
|
34
|
+
trace(`${T} drawSpeedTestResults`);
|
|
33
35
|
const canvas = document.getElementById('nerd-stats-speed-test-canvas');
|
|
34
36
|
if (!canvas) {
|
|
35
37
|
return;
|
|
@@ -52,6 +54,7 @@ export const initSpeedTest = (customMetrics) => {
|
|
|
52
54
|
return inited;
|
|
53
55
|
}
|
|
54
56
|
inited = (async () => {
|
|
57
|
+
trace(`${T} initSpeedTest run`);
|
|
55
58
|
// TODO: fix server selection
|
|
56
59
|
// const response = await fetch('https://iam.gcdn.co/info/json');
|
|
57
60
|
// const data = await response.json();
|
|
@@ -106,6 +109,7 @@ export const initSpeedTest = (customMetrics) => {
|
|
|
106
109
|
await fetch('https://iam.gcdn.co/info/json')
|
|
107
110
|
.then(r => r.json())
|
|
108
111
|
.then(data => {
|
|
112
|
+
trace(`${T} initSpeedTest fetched`);
|
|
109
113
|
const country = data['Server Country code'].toLowerCase();
|
|
110
114
|
const server = serversList.find(s => s.country === country) || serversList[0];
|
|
111
115
|
if (!server) {
|
|
@@ -113,6 +117,7 @@ export const initSpeedTest = (customMetrics) => {
|
|
|
113
117
|
}
|
|
114
118
|
speedTest.addTestPoint(server);
|
|
115
119
|
speedTest.setSelectedServer(server);
|
|
120
|
+
trace(`${T} initSpeedTest done`);
|
|
116
121
|
});
|
|
117
122
|
})();
|
|
118
123
|
return inited;
|
|
@@ -128,6 +133,7 @@ export const startSpeedtest = () => {
|
|
|
128
133
|
}
|
|
129
134
|
};
|
|
130
135
|
export const clearSpeedTestResults = () => {
|
|
136
|
+
trace(`${T} clearSpeedTestResults`);
|
|
131
137
|
speedtestResults.splice(0, speedtestResults.length);
|
|
132
138
|
};
|
|
133
139
|
export function configureSpeedTest(servers) {
|
|
@@ -9,15 +9,13 @@ export declare class SeekTime extends UICorePlugin {
|
|
|
9
9
|
get supportedVersion(): {
|
|
10
10
|
min: string;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
private static readonly template;
|
|
13
13
|
get attributes(): {
|
|
14
14
|
class: string;
|
|
15
15
|
'data-seek-time': string;
|
|
16
16
|
};
|
|
17
|
-
get
|
|
18
|
-
get
|
|
19
|
-
get isLiveStreamWithDvr(): any;
|
|
20
|
-
get durationShown(): boolean;
|
|
17
|
+
private get isLiveStreamWithDvr();
|
|
18
|
+
private get durationShown();
|
|
21
19
|
private hoveringOverSeekBar;
|
|
22
20
|
private hoverPosition;
|
|
23
21
|
private displayedDuration;
|
|
@@ -26,17 +24,23 @@ export declare class SeekTime extends UICorePlugin {
|
|
|
26
24
|
private rendered;
|
|
27
25
|
private $durationEl;
|
|
28
26
|
private $seekTimeEl;
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
29
30
|
bindEvents(): void;
|
|
31
|
+
private onCoreReady;
|
|
30
32
|
private onContainerChanged;
|
|
31
33
|
private onTimeUpdate;
|
|
32
34
|
private showTime;
|
|
33
35
|
private hideTime;
|
|
34
36
|
private calculateHoverPosition;
|
|
35
|
-
getSeekTime
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
private getSeekTime;
|
|
38
|
+
private update;
|
|
39
|
+
private shouldBeVisible;
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
40
43
|
render(): this;
|
|
44
|
+
private mount;
|
|
41
45
|
}
|
|
42
46
|
//# sourceMappingURL=SeekTime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeekTime.d.ts","sourceRoot":"","sources":["../../../src/plugins/seek-time/SeekTime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,YAAY,EAAmB,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"SeekTime.d.ts","sourceRoot":"","sources":["../../../src/plugins/seek-time/SeekTime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,YAAY,EAAmB,MAAM,cAAc,CAAA;AAM9E,OAAO,0CAA0C,CAAA;AAMjD;;;GAGG;AACH,qBAAa,QAAS,SAAQ,YAAY;IACxC,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD,IAAa,UAAU;;;MAKtB;IAED,OAAO,KAAK,mBAAmB,GAM9B;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,mBAAmB,CAAQ;IAEnC,OAAO,CAAC,aAAa,CAAI;IAEzB,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,QAAQ,CAAI;IAGpB,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,WAAW,CAA2B;IAE9C,OAAO,CAAC,WAAW,CAA2B;IAE9C;;OAEG;IACM,UAAU;IAInB,OAAO,CAAC,WAAW;IAoCnB,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,MAAM;IAgDd,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACM,MAAM;IAcf,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -5,6 +5,7 @@ import { Events, Playback, UICorePlugin, Utils, template } from '@clappr/core';
|
|
|
5
5
|
import { CLAPPR_VERSION } from '../../build.js';
|
|
6
6
|
import seekTimeHTML from '../../../assets/seek-time/seek-time.html';
|
|
7
7
|
import '../../../assets/seek-time/seek-time.scss';
|
|
8
|
+
import assert from 'assert';
|
|
8
9
|
const { formatTime } = Utils;
|
|
9
10
|
/**
|
|
10
11
|
* `PLUGIN` that adds a seek time indicator to the media control UI.
|
|
@@ -17,25 +18,17 @@ export class SeekTime extends UICorePlugin {
|
|
|
17
18
|
get supportedVersion() {
|
|
18
19
|
return { min: CLAPPR_VERSION };
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
return template(seekTimeHTML);
|
|
22
|
-
}
|
|
21
|
+
static template = template(seekTimeHTML);
|
|
23
22
|
get attributes() {
|
|
24
23
|
return {
|
|
25
|
-
|
|
26
|
-
'data-seek-time': ''
|
|
24
|
+
class: 'seek-time',
|
|
25
|
+
'data-seek-time': '',
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
|
-
get mediaControl() {
|
|
30
|
-
return this.core.mediaControl;
|
|
31
|
-
}
|
|
32
|
-
get mediaControlContainer() {
|
|
33
|
-
return this.mediaControl.container;
|
|
34
|
-
}
|
|
35
28
|
get isLiveStreamWithDvr() {
|
|
36
|
-
return this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
29
|
+
return (this.core.activeContainer &&
|
|
30
|
+
this.core.activeContainer.getPlaybackType() === Playback.LIVE &&
|
|
31
|
+
this.core.activeContainer.isDvrEnabled());
|
|
39
32
|
}
|
|
40
33
|
get durationShown() {
|
|
41
34
|
return !this.isLiveStreamWithDvr;
|
|
@@ -49,20 +42,27 @@ export class SeekTime extends UICorePlugin {
|
|
|
49
42
|
rendered = false;
|
|
50
43
|
$durationEl = null;
|
|
51
44
|
$seekTimeEl = null;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
52
48
|
bindEvents() {
|
|
53
|
-
this.listenTo(this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
this.listenTo(this.core, Events.CORE_READY, this.onCoreReady);
|
|
50
|
+
}
|
|
51
|
+
onCoreReady() {
|
|
52
|
+
const mediaControl = this.core.getPlugin('media_control');
|
|
53
|
+
assert(mediaControl, 'MediaControl plugin is required for SeekTime plugin to work');
|
|
54
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, this.mount);
|
|
55
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, this.showTime);
|
|
56
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_MOUSELEAVE_SEEKBAR, this.hideTime);
|
|
57
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.onContainerChanged);
|
|
58
|
+
if (this.core.activeContainer) {
|
|
59
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAYBACKDVRSTATECHANGED, this.update);
|
|
60
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_TIMEUPDATE, this.onTimeUpdate);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
onContainerChanged() {
|
|
63
|
-
|
|
64
|
-
this.
|
|
65
|
-
this.bindEvents();
|
|
64
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAYBACKDVRSTATECHANGED, this.update);
|
|
65
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_TIMEUPDATE, this.onTimeUpdate);
|
|
66
66
|
}
|
|
67
67
|
onTimeUpdate({ total }) {
|
|
68
68
|
this.duration = total;
|
|
@@ -78,18 +78,15 @@ export class SeekTime extends UICorePlugin {
|
|
|
78
78
|
this.update();
|
|
79
79
|
}
|
|
80
80
|
calculateHoverPosition(event) {
|
|
81
|
-
const
|
|
81
|
+
const mediaControl = this.core.getPlugin('media_control');
|
|
82
|
+
const offset = event.pageX - mediaControl.$seekBarContainer.offset().left;
|
|
82
83
|
// proportion into the seek bar that the mouse is hovered over 0-1
|
|
83
|
-
this.hoverPosition = Math.min(1, Math.max(offset /
|
|
84
|
+
this.hoverPosition = Math.min(1, Math.max(offset / mediaControl.$seekBarContainer.width(), 0));
|
|
84
85
|
}
|
|
85
86
|
getSeekTime() {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
seekTime = this.hoverPosition * this.duration;
|
|
92
|
-
}
|
|
87
|
+
const seekTime = this.isLiveStreamWithDvr
|
|
88
|
+
? this.duration - this.hoverPosition * this.duration
|
|
89
|
+
: this.hoverPosition * this.duration;
|
|
93
90
|
return { seekTime };
|
|
94
91
|
}
|
|
95
92
|
update() {
|
|
@@ -100,57 +97,63 @@ export class SeekTime extends UICorePlugin {
|
|
|
100
97
|
if (!this.shouldBeVisible()) {
|
|
101
98
|
this.$el.hide();
|
|
102
99
|
this.$el.css('left', '-100%');
|
|
100
|
+
return;
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.displayedDuration = currentDuration;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
this.$durationEl.hide();
|
|
102
|
+
const seekTime = this.getSeekTime();
|
|
103
|
+
let currentSeekTime = formatTime(seekTime.seekTime, false);
|
|
104
|
+
if (this.isLiveStreamWithDvr) {
|
|
105
|
+
currentSeekTime = `-${currentSeekTime}`;
|
|
106
|
+
}
|
|
107
|
+
// only update dom if necessary, ie time actually changed
|
|
108
|
+
if (currentSeekTime !== this.displayedSeekTime) {
|
|
109
|
+
this.$seekTimeEl.text(currentSeekTime);
|
|
110
|
+
this.displayedSeekTime = currentSeekTime;
|
|
111
|
+
}
|
|
112
|
+
if (this.durationShown) {
|
|
113
|
+
this.$durationEl.show();
|
|
114
|
+
const currentDuration = formatTime(this.duration, false);
|
|
115
|
+
if (currentDuration !== this.displayedDuration) {
|
|
116
|
+
this.$durationEl.text(currentDuration);
|
|
117
|
+
this.displayedDuration = currentDuration;
|
|
125
118
|
}
|
|
126
|
-
// the element must be unhidden before its width is requested, otherwise it's width will be reported as 0
|
|
127
|
-
this.$el.show();
|
|
128
|
-
const containerWidth = this.mediaControl.$seekBarContainer.width();
|
|
129
|
-
const elWidth = this.$el.width();
|
|
130
|
-
let elLeftPos = this.hoverPosition * containerWidth;
|
|
131
|
-
elLeftPos -= elWidth / 2;
|
|
132
|
-
elLeftPos = Math.max(0, Math.min(elLeftPos, containerWidth - elWidth));
|
|
133
|
-
this.$el.css('left', elLeftPos);
|
|
134
119
|
}
|
|
120
|
+
else {
|
|
121
|
+
this.$durationEl.hide();
|
|
122
|
+
}
|
|
123
|
+
// the element must be unhidden before its width is requested, otherwise it's width will be reported as 0
|
|
124
|
+
this.$el.show();
|
|
125
|
+
const mediaControl = this.core.getPlugin('media_control');
|
|
126
|
+
const containerWidth = mediaControl.$seekBarContainer.width();
|
|
127
|
+
const elWidth = this.$el.width();
|
|
128
|
+
let elLeftPos = this.hoverPosition * containerWidth;
|
|
129
|
+
elLeftPos -= elWidth / 2;
|
|
130
|
+
elLeftPos = Math.max(0, Math.min(elLeftPos, containerWidth - elWidth));
|
|
131
|
+
this.$el.css('left', elLeftPos);
|
|
135
132
|
}
|
|
136
133
|
shouldBeVisible() {
|
|
137
|
-
return this.
|
|
138
|
-
this.
|
|
134
|
+
return (this.core.activeContainer &&
|
|
135
|
+
this.core.activeContainer.settings.seekEnabled &&
|
|
139
136
|
this.hoveringOverSeekBar &&
|
|
140
137
|
this.hoverPosition !== null &&
|
|
141
|
-
this.duration !== null;
|
|
138
|
+
this.duration !== null);
|
|
142
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
143
|
render() {
|
|
144
144
|
this.rendered = true;
|
|
145
145
|
this.displayedDuration = null;
|
|
146
146
|
this.displayedSeekTime = null;
|
|
147
|
-
this.$el.html(
|
|
147
|
+
this.$el.html(SeekTime.template());
|
|
148
148
|
this.$el.hide();
|
|
149
|
-
this.mediaControl.$el.append(this.el);
|
|
150
|
-
this.$seekTimeEl = this.$el.find('
|
|
151
|
-
this.$durationEl = this.$el.find('
|
|
149
|
+
// this.mediaControl.$el.append(this.el);
|
|
150
|
+
this.$seekTimeEl = this.$el.find('#mc-seek-time');
|
|
151
|
+
this.$durationEl = this.$el.find('#mc-duration');
|
|
152
152
|
this.$durationEl.hide();
|
|
153
153
|
this.update();
|
|
154
154
|
return this;
|
|
155
155
|
}
|
|
156
|
+
mount() {
|
|
157
|
+
this.core.getPlugin('media_control').$el.append(this.$el); // TODO use a method
|
|
158
|
+
}
|
|
156
159
|
}
|
package/package.json
CHANGED
package/rollup.config.js
CHANGED
|
@@ -23,34 +23,34 @@ export default [
|
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
26
|
+
// {
|
|
27
|
+
// input: 'lib/index.plugins.js',
|
|
28
|
+
// plugins: [
|
|
29
|
+
// resolve(), // TODO check which aren't inlined in the bundle and put them here
|
|
30
|
+
// commonjs(),
|
|
31
|
+
// json(),
|
|
32
|
+
// polyfillNode(),
|
|
33
|
+
// sass({
|
|
34
|
+
// output: 'dist/plugins/index.css',
|
|
35
|
+
// verbose: true,
|
|
36
|
+
// }),
|
|
37
|
+
// string({
|
|
38
|
+
// include: [
|
|
39
|
+
// '**/*.ejs',
|
|
40
|
+
// '**/*.html',
|
|
41
|
+
// '**/*.svg',
|
|
42
|
+
// '**/*.worker.js',
|
|
43
|
+
// ],
|
|
44
|
+
// }),
|
|
45
|
+
// ],
|
|
46
|
+
// output: [
|
|
47
|
+
// {
|
|
48
|
+
// file: 'dist/plugins/index.js',
|
|
49
|
+
// format: 'es',
|
|
50
|
+
// generatedCode: 'es2015',
|
|
51
|
+
// }
|
|
52
|
+
// ]
|
|
53
|
+
// },
|
|
54
54
|
{
|
|
55
55
|
input: 'lib/index.js',
|
|
56
56
|
plugins: [
|
|
@@ -71,11 +71,8 @@ describe('BottomGear', () => {
|
|
|
71
71
|
})
|
|
72
72
|
describe('when clicked twice', () => {
|
|
73
73
|
beforeEach(() => {
|
|
74
|
-
console.log('display:%s', bottomGear.$el.find('#gear-options-wrapper').css('display'))
|
|
75
74
|
bottomGear.$el.find('#gear-button').click()
|
|
76
|
-
console.log('display:%s', bottomGear.$el.find('#gear-options-wrapper').css('display'))
|
|
77
75
|
bottomGear.$el.find('#gear-button').click()
|
|
78
|
-
console.log('display:%s', bottomGear.$el.find('#gear-options-wrapper').css('display'))
|
|
79
76
|
})
|
|
80
77
|
it('should collapse the gear menu', () => {
|
|
81
78
|
expect(bottomGear.$el.find('#gear-options-wrapper').css('display')).toBe(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { trace } from '@gcorevideo/utils';
|
|
1
2
|
import { type Server, type TestStatusInfo, Speedtest } from './Speedtest.js';
|
|
2
3
|
import { SpeedtestMetrics } from './types.js';
|
|
3
4
|
|
|
@@ -6,7 +7,7 @@ const DEFAULT_DOWNLOAD_SPEED = '0.00';
|
|
|
6
7
|
|
|
7
8
|
const DRAW_SIZE = 5;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const T = 'plugins.clappr_nerd_stats.speedtest';
|
|
10
11
|
|
|
11
12
|
function limitDigits(value: number): string {
|
|
12
13
|
return value > DIGITS_THRESHOLD ? '> ' + DIGITS_THRESHOLD : value.toFixed(2);
|
|
@@ -37,6 +38,7 @@ const getColor = (speedValue: number): string => {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export function drawSpeedTestResults() {
|
|
41
|
+
trace(`${T} drawSpeedTestResults`);
|
|
40
42
|
const canvas = document.getElementById('nerd-stats-speed-test-canvas');
|
|
41
43
|
if (!canvas) {
|
|
42
44
|
return;
|
|
@@ -64,6 +66,7 @@ export const initSpeedTest = (customMetrics: SpeedtestMetrics): Promise<void> =>
|
|
|
64
66
|
return inited;
|
|
65
67
|
}
|
|
66
68
|
inited = (async () => {
|
|
69
|
+
trace(`${T} initSpeedTest run`);
|
|
67
70
|
// TODO: fix server selection
|
|
68
71
|
// const response = await fetch('https://iam.gcdn.co/info/json');
|
|
69
72
|
// const data = await response.json();
|
|
@@ -127,6 +130,8 @@ export const initSpeedTest = (customMetrics: SpeedtestMetrics): Promise<void> =>
|
|
|
127
130
|
await fetch('https://iam.gcdn.co/info/json')
|
|
128
131
|
.then(r => r.json())
|
|
129
132
|
.then(data => {
|
|
133
|
+
trace(`${T} initSpeedTest fetched`);
|
|
134
|
+
|
|
130
135
|
const country = data['Server Country code'].toLowerCase();
|
|
131
136
|
const server = serversList.find(s => s.country === country) || serversList[0];
|
|
132
137
|
if (!server) {
|
|
@@ -134,6 +139,7 @@ export const initSpeedTest = (customMetrics: SpeedtestMetrics): Promise<void> =>
|
|
|
134
139
|
}
|
|
135
140
|
speedTest.addTestPoint(server);
|
|
136
141
|
speedTest.setSelectedServer(server);
|
|
142
|
+
trace(`${T} initSpeedTest done`);
|
|
137
143
|
});
|
|
138
144
|
})();
|
|
139
145
|
|
|
@@ -153,6 +159,7 @@ export const startSpeedtest = () => {
|
|
|
153
159
|
};
|
|
154
160
|
|
|
155
161
|
export const clearSpeedTestResults = () => {
|
|
162
|
+
trace(`${T} clearSpeedTestResults`);
|
|
156
163
|
speedtestResults.splice(0, speedtestResults.length);
|
|
157
164
|
};
|
|
158
165
|
|