Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeScript to v3.9.3 and other dependencies #737

Merged
merged 8 commits into from
Jun 4, 2020
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ language:
- java

node_js:
- "8"
- "12"

# exclusive
branches:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "8"
nodejs_version: "12"

branches:
only:
Expand Down
7,264 changes: 4,573 additions & 2,691 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,60 +124,60 @@
"rxjs": "6.5.5"
},
"devDependencies": {
"@babel/core": "7.9.0",
"@babel/core": "7.10.2",
"@babel/plugin-transform-runtime": "7.10.1",
"@babel/preset-env": "7.9.5",
"@babel/preset-react": "7.9.4",
"@babel/preset-env": "7.10.2",
"@babel/preset-react": "7.10.1",
"@types/chai": "4.2.11",
"@types/jest": "25.2.1",
"@types/jest": "25.2.3",
"@types/mocha": "7.0.2",
"@types/node": "13.11.1",
"@types/sinon": "9.0.0",
"@types/node": "14.0.9",
"@types/sinon": "9.0.4",
"arraybuffer-loader": "1.0.8",
"babel-loader": "8.1.0",
"chai": "4.2.0",
"chart.js": "2.9.3",
"cheerio": "1.0.0-rc.3",
"core-js": "3.6.5",
"cross-env": "7.0.2",
"css-loader": "3.5.2",
"eslint": "6.8.0",
"eslint-plugin-react": "7.19.0",
"css-loader": "3.5.3",
"eslint": "7.1.0",
"eslint-plugin-react": "7.20.0",
"esm": "3.2.25",
"express": "4.17.1",
"file-loader": "6.0.0",
"highlight.js": "9.18.1",
"highlight.js": "10.0.3",
"husky": "4.2.5",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "25.3.0",
"karma": "5.0.1",
"jest": "26.0.1",
"karma": "5.0.9",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "2.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-firefox-launcher": "1.3.0",
"karma-mocha": "2.0.0",
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"karma-webpack": "4.0.2",
"markdown-it": "10.0.0",
"markdown-it": "11.0.0",
"markdown-it-emoji": "1.4.0",
"mocha": "7.1.1",
"mocha": "7.2.0",
"mocha-loader": "5.0.0",
"npm-scripts-info": "0.3.9",
"raw-loader": "4.0.0",
"raw-loader": "4.0.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"regenerator-runtime": "0.13.5",
"sanitize-html": "1.23.0",
"semver": "7.3.0",
"sanitize-html": "1.25.0",
"semver": "7.3.2",
"sinon": "9.0.2",
"style-loader": "1.1.3",
"terser-webpack-plugin": "2.3.5",
"ts-jest": "25.3.1",
"ts-loader": "6.2.2",
"tslint": "6.1.1",
"typescript": "3.8.3",
"style-loader": "1.2.1",
"terser-webpack-plugin": "3.0.2",
"ts-jest": "26.1.0",
"ts-loader": "7.0.5",
"tslint": "6.1.2",
"typescript": "3.9.3",
"url-loader": "4.1.0",
"webpack": "4.42.1",
"webpack-bundle-analyzer": "3.7.0",
"webpack": "4.43.0",
"webpack-bundle-analyzer": "3.8.0",
"webpack-cli": "3.3.11"
}
}
8 changes: 4 additions & 4 deletions src/compat/add_text_track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export default function addTextTrack(

if (isIEOrEdge) {
const tracksLength = mediaElement.textTracks.length;
track = tracksLength > 0 ? mediaElement.textTracks[tracksLength - 1] :
mediaElement.addTextTrack(kind);
track.mode = hidden ? track.HIDDEN :
track.SHOWING;
track = (tracksLength > 0 ? mediaElement.textTracks[tracksLength - 1] :
mediaElement.addTextTrack(kind)) as ICompatTextTrack;
track.mode = hidden ? (track.HIDDEN ?? "hidden") :
(track.SHOWING ?? "showing");
} else {
trackElement = document.createElement("track");
mediaElement.appendChild(trackElement);
Expand Down
74 changes: 74 additions & 0 deletions src/compat/browser_compatibility_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ interface ICompatVTTCue { align : string;
interface ICompatTextTrack extends TextTrack {
addCue(cue: TextTrackCue | ICompatVTTCue) : void;
removeCue(cue: TextTrackCue | ICompatVTTCue) : void;
HIDDEN? : "hidden";
SHOWING? : "showing";
}

/**
Expand All @@ -72,11 +74,79 @@ interface ICompatDocument extends Document { mozCancelFullScreen? : () => void;
/**
* HTMLMediaElement with added optional vendored functions used by "old"
* browsers.
* And TypeScript forgot to add assiociated AudioTrackList and VideoTrackList
* (and yes apparently a HTMLAudioElement can have an assiociated
* VideoTrackList).
*
* Note: I prefer to define my own `ICompatHTMLMediaElement` rather to extend
* the original definition to better detect which types have been extended and
* are not actually valid TypeScript types.
*/
interface ICompatHTMLMediaElement extends HTMLMediaElement {
mozRequestFullScreen? : () => void;
msRequestFullscreen? : () => void;
webkitRequestFullscreen : () => void;
readonly audioTracks? : ICompatAudioTrackList;
readonly videoTracks? : ICompatVideoTrackList;
}

/**
* AudioTrackList implementation (that TS forgot).
* Directly taken from the WHATG spec:
* https://html.spec.whatwg.org/multipage/media.html#audiotracklist
*/
interface ICompatAudioTrackList extends EventTarget {
readonly length : number;
getTrackById(id : string) : ICompatAudioTrack;
onchange? : ((n : Event) => void) | null;
onaddtrack? : ((n : Event) => void) | null;
onremovetrack? : ((n : Event) => void) | null;

// It can be indexed
[x : number] : ICompatAudioTrack;
}

/**
* AudioTrack implementation (that TS forgot).
* Directly taken from the WHATG spec:
* https://html.spec.whatwg.org/multipage/media.html#audiotracklist
*/
interface ICompatAudioTrack {
id : string;
kind : string;
label : string;
language : string;
enabled : boolean;
}

/**
* VideoTrackList implementation (that TS forgot).
* Directly taken from the WHATG spec:
* https://html.spec.whatwg.org/multipage/media.html#audiotracklist
*/
interface ICompatVideoTrackList extends EventTarget {
readonly length : number;
selectedIndex : number;
getTrackById(id : string) : ICompatVideoTrack;
onchange? : ((n : Event) => void) | null;
onaddtrack? : ((n : Event) => void) | null;
onremovetrack? : ((n : Event) => void) | null;

// It can be indexed
[x : number] : ICompatVideoTrack;
}

/**
* VideoTrack implementation (that TS forgot).
* Directly taken from the WHATG spec:
* https://html.spec.whatwg.org/multipage/media.html#audiotracklist
*/
interface ICompatVideoTrack {
id : string;
kind : string;
label : string;
language : string;
selected : boolean;
}

/**
Expand Down Expand Up @@ -188,6 +258,10 @@ export {
HTMLElement_,
ICompatDocument,
ICompatHTMLMediaElement,
ICompatAudioTrackList,
ICompatVideoTrackList,
ICompatAudioTrack,
ICompatVideoTrack,
ICompatMediaKeySystemAccess,
ICompatMediaKeySystemConfiguration,
ICompatMediaKeysConstructor,
Expand Down
3 changes: 3 additions & 0 deletions src/compat/remove_cue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { isFirefox } from "./browser_detection";
*/
function isActiveCue(track: TextTrack, cue: TextTrackCue): boolean {
const { activeCues } = track;
if (activeCues === null) {
return false;
}
for (let i = 0; i < activeCues.length; i++) {
if (activeCues[i] === cue) {
return true;
Expand Down
47 changes: 27 additions & 20 deletions src/core/api/media_element_track_choice_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
*/

import { BehaviorSubject } from "rxjs";
import { ICompatTextTrackList } from "../../compat/browser_compatibility_types";
import {
ICompatAudioTrack,
ICompatAudioTrackList,
ICompatHTMLMediaElement,
ICompatTextTrackList,
ICompatVideoTrack,
ICompatVideoTrackList,
} from "../../compat/browser_compatibility_types";
import EventEmitter from "../../utils/event_emitter";
import normalizeLanguage from "../../utils/languages";
import {
Expand Down Expand Up @@ -52,8 +59,8 @@ interface IMediaElementTrackChoiceManagerEvents {
* @returns {boolean}
*/
function areTrackArraysDifferent(
oldTrackArray: Array<{ nativeTrack: VideoTrack|AudioTrack|TextTrack }>,
newTrackArray: Array<{ nativeTrack: VideoTrack|AudioTrack|TextTrack }>
oldTrackArray: Array<{ nativeTrack: ICompatVideoTrack|ICompatAudioTrack|TextTrack }>,
newTrackArray: Array<{ nativeTrack: ICompatVideoTrack|ICompatAudioTrack|TextTrack }>
): boolean {
if (newTrackArray.length !== oldTrackArray.length) {
return true;
Expand All @@ -72,12 +79,12 @@ function areTrackArraysDifferent(
* @returns {Array.<Object>}
*/
function createAudioTracks(
audioTracks: AudioTrackList
audioTracks: ICompatAudioTrackList
): Array<{ track: { id: string;
normalized: string;
language: string;
audioDescription: boolean; };
nativeTrack: AudioTrack; }> {
nativeTrack: ICompatAudioTrack; }> {
const newAudioTracks = [];
const languagesOccurences: Partial<Record<string, number>> = {};
for (let i = 0; i < audioTracks.length; i++) {
Expand Down Expand Up @@ -140,10 +147,10 @@ function createTextTracks(
* @returns {Array.<Object>}
*/
function createVideoTracks(
videoTracks: VideoTrackList
videoTracks: ICompatVideoTrackList
): Array<{ track: { id: string;
representations: []; };
nativeTrack: VideoTrack; }> {
nativeTrack: ICompatVideoTrack; }> {
const newVideoTracks = [];
const languagesOccurences: Partial<Record<string, number>> = {};
for (let i = 0; i < videoTracks.length; i++) {
Expand Down Expand Up @@ -188,23 +195,23 @@ export default class MediaElementTrackChoiceManager
private _preferredVideoTracks : BehaviorSubject<IVideoTrackPreference[]>;

/** List every available audio tracks available on the media element. */
private _audioTracks : Array<{ track: ITMAudioTrack; nativeTrack: AudioTrack }>;
private _audioTracks : Array<{ track: ITMAudioTrack; nativeTrack: ICompatAudioTrack }>;
/** List every available text tracks available on the media element. */
private _textTracks : Array<{ track: ITMTextTrack; nativeTrack: TextTrack }>;
/** List every available video tracks available on the media element. */
private _videoTracks : Array<{ track: ITMVideoTrack; nativeTrack: VideoTrack }>;
private _videoTracks : Array<{ track: ITMVideoTrack; nativeTrack: ICompatVideoTrack }>;

/** Last audio track emitted as active. */
private _lastEmittedNativeAudioTrack : AudioTrack | null | undefined;
private _lastEmittedNativeAudioTrack : ICompatAudioTrack | null | undefined;
/** Last video track emitted as active. */
private _lastEmittedNativeVideoTrack : VideoTrack | null | undefined;
private _lastEmittedNativeVideoTrack : ICompatVideoTrack | null | undefined;
/** Last text track emitted as active. */
private _lastEmittedNativeTextTrack : TextTrack | null | undefined;

/** Native `AudioTrackList` implemented on the media element. */
private _nativeAudioTracks : AudioTrackList|undefined;
private _nativeAudioTracks : ICompatAudioTrackList | undefined;
/** Native `VideoTrackList` implemented on the media element. */
private _nativeVideoTracks : VideoTrackList|undefined;
private _nativeVideoTracks : ICompatVideoTrackList | undefined;
/** Native `TextTrackList` implemented on the media element. */
private _nativeTextTracks : ICompatTextTrackList|undefined;

Expand All @@ -215,7 +222,7 @@ export default class MediaElementTrackChoiceManager
* through audio track list updates, as long as it is still available.
* `undefined` if the audio track was not manually set.
*/
private _audioTrackLockedOn : AudioTrack | undefined;
private _audioTrackLockedOn : ICompatAudioTrack | undefined;

/**
* Last text track manually set active through the corresponding
Expand All @@ -235,7 +242,7 @@ export default class MediaElementTrackChoiceManager
* `null` if the video track was disabled.
* `undefined` if the video track was not manually set.
*/
private _videoTrackLockedOn : VideoTrack | undefined | null;
private _videoTrackLockedOn : ICompatVideoTrack | undefined | null;

constructor(
defaults : { preferredAudioTracks : BehaviorSubject<IAudioTrackPreference[]>;
Expand All @@ -252,8 +259,8 @@ export default class MediaElementTrackChoiceManager
// TODO In practice, the audio/video/text tracks API are not always implemented on
// the media element, although Typescript HTMLMediaElement types tend to mean
// that can't be undefined.
this._nativeAudioTracks = mediaElement.audioTracks as AudioTrackList|undefined;
this._nativeVideoTracks = mediaElement.videoTracks as VideoTrackList|undefined;
this._nativeAudioTracks = (mediaElement as ICompatHTMLMediaElement).audioTracks;
this._nativeVideoTracks = (mediaElement as ICompatHTMLMediaElement).videoTracks;
this._nativeTextTracks = mediaElement.textTracks as ICompatTextTrackList|undefined;

this._audioTracks =
Expand Down Expand Up @@ -462,7 +469,7 @@ export default class MediaElementTrackChoiceManager
* @returns {Object|undefined|null}
*/
private _getPrivateChosenAudioTrack(): { track: ITMAudioTrack;
nativeTrack: AudioTrack; } |
nativeTrack: ICompatAudioTrack; } |
undefined |
null {
if (this._nativeAudioTracks === undefined) {
Expand All @@ -484,7 +491,7 @@ export default class MediaElementTrackChoiceManager
* @returns {Object|undefined|null}
*/
private _getPrivateChosenVideoTrack(): { track: ITMVideoTrack;
nativeTrack: VideoTrack; } |
nativeTrack: ICompatVideoTrack; } |
undefined |
null {
if (this._nativeVideoTracks === undefined) {
Expand Down Expand Up @@ -863,7 +870,7 @@ function disableAllTextTracksBut(
* @param {Array.<Object>} videoTracks
*/
function disableVideoTracks(
videoTracks : Array<{ nativeTrack : VideoTrack }>
videoTracks : Array<{ nativeTrack : ICompatVideoTrack }>
) {
for (let i = 0; i < videoTracks.length; i++) {
const { nativeTrack } = videoTracks[i];
Expand Down
5 changes: 0 additions & 5 deletions src/core/init/manifest_update_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
import config from "../../config";
import log from "../../log";
import Manifest from "../../manifest";
import isNonEmptyString from "../../utils/is_non_empty_string";
import {
IManifestFetcherParsedResult,
IManifestFetcherParserOptions,
Expand Down Expand Up @@ -203,10 +202,6 @@ export default function manifestUpdateScheduler({
const fullRefresh = completeRefresh || manifestUpdateUrl === undefined;
const refreshURL = fullRefresh ? manifest.getUrl() :
manifestUpdateUrl;
if (!isNonEmptyString(refreshURL)) {
log.warn("Init: Cannot refresh the manifest: no url");
return EMPTY;
}
const externalClockOffset = manifest.clockOffset;

if (unsafeMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class NativeTextSourceBuffer
// IE/Edge.
// TODO Move to compat
const currentCues = this._track.cues;
if (currentCues.length > 0) {
if (currentCues !== null && currentCues.length > 0) {
if (
firstCue.startTime < currentCues[currentCues.length - 1].startTime
) {
Expand Down
Loading