Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,20 @@ module.exports = {
],
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/strict-boolean-expressions": [
"error",
{
allowAny: false,
allowNullableBoolean: false,
allowNullableEnum: false,
allowNullableNumber: false,
allowNullableObject: false,
allowNullableString: false,
allowNumber: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
allowString: false,
},
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion src/compat/browser_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ let isA1KStb40xx = false;
isPanasonic = true;
} else if (navigator.userAgent.indexOf("Xbox") !== -1) {
isXbox = true;
} else if (navigator.userAgent.indexOf("Model/a1-kstb40xx")) {
} else if (navigator.userAgent.indexOf("Model/a1-kstb40xx") !== -1) {
isA1KStb40xx = true;
}
})();
Expand Down
4 changes: 2 additions & 2 deletions src/main_thread/api/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
* `false` otherwise.
*/
isPaused(): boolean {
if (this.videoElement) {
if (this.videoElement !== null) {
if (arrayIncludes(["LOADING", "RELOADING"], this.state)) {
return !this._priv_lastAutoPlay;
} else {
Expand Down Expand Up @@ -2778,7 +2778,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
// Emit initial events for the Period
if (!isNullOrUndefined(tracksStore)) {
const periodRef = tracksStore.getPeriodObjectFromPeriod(period);
if (periodRef) {
if (periodRef !== undefined) {
const audioTrack = tracksStore.getChosenAudioTrack(periodRef, true);
this._priv_triggerEventIfNotStopped("audioTrackChange", audioTrack, cancelSignal);
const textTrack = tracksStore.getChosenTextTrack(periodRef);
Expand Down
2 changes: 1 addition & 1 deletion src/main_thread/init/utils/rebuffering_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export default class RebufferingController extends EventEmitter<IRebufferingCont
}
const observation = this._playbackObserver.getReference().getValue();
if (
!observation.rebuffering ||
observation.rebuffering === null ||
observation.paused ||
this._speed.getValue() <= 0 ||
(bufferType !== "audio" && bufferType !== "video")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export default class TextTrackCuesStore {
}
}

if (cuesBuffer.length) {
if (cuesBuffer.length > 0) {
const lastCue = cuesBuffer[cuesBuffer.length - 1];
if (areNearlyEqual(lastCue.end, start, relativeDelta)) {
// Match the end of the previous cue to the start of the following one
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/manifest/dash/common/parse_representations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getHDRInformation({
return { eotf: "hlg" };
}
}
if (codecs !== undefined && /^vp(08|09|10)/.exec(codecs)) {
if (codecs !== undefined && /^vp(08|09|10)/.test(codecs)) {
return getWEBMHDRInformation(codecs);
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ export default function parseRepresentations(
(r) =>
r.schemeIdUri === "tag:dolby.com,2018:dash:EC3_ExtensionType:2018" &&
r.value === "JOC",
)
) !== undefined
) {
parsedRepresentation.isSpatialAudio = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/playback_observer/media_element_playback_observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ function getFreezingStatus(
bufferGap: number | undefined,
): IFreezingStatus | null {
const { MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING } = config.getCurrent();
if (prevObservation.freezing) {
if (prevObservation.freezing !== null) {
if (
currentInfo.ended ||
currentInfo.paused ||
Expand Down
21 changes: 11 additions & 10 deletions src/utils/url-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import isNonEmptyString from "./is_non_empty_string";
import startsWith from "./starts_with";

// Scheme part of an url (e.g. "http://").
Expand Down Expand Up @@ -135,12 +136,12 @@ function getRelativeUrl(baseUrl: string, newUrl: string): string | null {
let result = relativePath;
if (relativePath === "" && newParts.query === baseParts.query) {
// path and query is the same, we don't need to rewrite it
} else if (newParts.query) {
} else if (isNonEmptyString(newParts.query)) {
result += "?";
result += newParts.query;
}

if (newParts.fragment) {
if (isNonEmptyString(newParts.fragment)) {
result += "#";
result += newParts.fragment;
}
Expand All @@ -160,7 +161,7 @@ function _resolveURL(base: string, relative: string) {
const baseParts = parseURL(base);
const relativeParts = parseURL(relative);

if (relativeParts.scheme) {
if (isNonEmptyString(relativeParts.scheme)) {
return formatURL(relativeParts);
}

Expand All @@ -172,15 +173,15 @@ function _resolveURL(base: string, relative: string) {
fragment: relativeParts.fragment,
};

if (relativeParts.authority) {
if (isNonEmptyString(relativeParts.authority)) {
target.authority = relativeParts.authority;
target.path = removeDotSegment(relativeParts.path);
return formatURL(target);
}

if (relativeParts.path === "") {
target.path = baseParts.path;
if (!relativeParts.query) {
if (!isNonEmptyString(relativeParts.query)) {
target.query = baseParts.query;
}
} else {
Expand Down Expand Up @@ -255,20 +256,20 @@ function parseURL(url: string): IParsedURL {
*/
function formatURL(parts: IParsedURL): string {
let url = "";
if (parts.scheme) {
if (isNonEmptyString(parts.scheme)) {
url += parts.scheme + ":";
}

if (parts.authority) {
if (isNonEmptyString(parts.authority)) {
url += "//" + parts.authority;
}
url += parts.path;

if (parts.query) {
if (isNonEmptyString(parts.query)) {
url += "?" + parts.query;
}

if (parts.fragment) {
if (isNonEmptyString(parts.fragment)) {
url += "#" + parts.fragment;
}
return url;
Expand Down Expand Up @@ -321,7 +322,7 @@ function removeDotSegment(path: string): string {
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.3
*/
function mergePaths(baseParts: IParsedURL, relativePath: string): string {
if (baseParts.authority && baseParts.path === "") {
if (isNonEmptyString(baseParts.authority) && baseParts.path === "") {
return "/" + relativePath;
}
const basePath = baseParts.path;
Expand Down
21 changes: 13 additions & 8 deletions src/utils/xml-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* https://github.com/TobiasNickel/tXml
*/

import isNonEmptyString from "./is_non_empty_string";

// import arrayIncludes from "./array_includes";

/**
Expand Down Expand Up @@ -94,7 +96,7 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str
out = parseChildren("");
}

if (options.filter) {
if (options.filter !== undefined) {
out = filter(out, options.filter);
}
return out;
Expand All @@ -106,7 +108,7 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str
*/
function parseChildren(tagName: string): Array<ITNode | string> {
const children: Array<ITNode | string> = [];
while (src[pos]) {
while (src[pos] !== undefined) {
if (src.charCodeAt(pos) === openBracketCC) {
if (src.charCodeAt(pos + 1) === slashCC) {
const closeStart = pos + 2;
Expand Down Expand Up @@ -170,7 +172,10 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str
const startDoctype = pos + 1;
pos += 2;
let encapsuled = false;
while ((src.charCodeAt(pos) !== closeBracketCC || encapsuled) && src[pos]) {
while (
(src.charCodeAt(pos) !== closeBracketCC || encapsuled) &&
src[pos] !== undefined
) {
if (src.charCodeAt(pos) === openCornerBracketCC) {
encapsuled = true;
} else if (encapsuled && src.charCodeAt(pos) === closeCornerBracketCC) {
Expand Down Expand Up @@ -221,7 +226,7 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str

function parseName(): string {
const start = pos;
while (nameSpacer.indexOf(src[pos]) === -1 && src[pos]) {
while (nameSpacer.indexOf(src[pos]) === -1 && src[pos] !== undefined) {
pos++;
}
return src.slice(start, pos);
Expand All @@ -235,15 +240,15 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str
let children: Array<ITNode | string> = [];

// parsing attributes
while (src.charCodeAt(pos) !== closeBracketCC && src[pos]) {
while (src.charCodeAt(pos) !== closeBracketCC && src[pos] !== undefined) {
const c = src.charCodeAt(pos);
if ((c > 64 && c < 91) || (c > 96 && c < 123)) {
// if('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(src[pos])!==-1 ){
const name = parseName();
// search beginning of the string
let code = src.charCodeAt(pos);
while (
code &&
!isNaN(code) &&
code !== singleQuoteCC &&
code !== doubleQuoteCC &&
!((code > 64 && code < 91) || (code > 96 && code < 123)) &&
Expand Down Expand Up @@ -298,7 +303,7 @@ function parseXml(src: string, options: ITParseOptions = {}): Array<ITNode | str
const r = new RegExp(
"\\s" + options.attrName + "\\s*=['\"]" + options.attrValue + "['\"]",
).exec(src);
if (r) {
if (r !== null) {
return r.index;
} else {
return -1;
Expand Down Expand Up @@ -328,7 +333,7 @@ function filter(
child.children,
f,
dept + 1,
(path ? path + "." : "") + i + "." + child.tagName,
(isNonEmptyString(path) ? path + "." : "") + i + "." + child.tagName,
);
out = out.concat(kids);
}
Expand Down
Loading