mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 17:49:58 +00:00
Narrow linting rules and fix for eslintrc for js files
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
import logger from "../lib/logger";
|
||||
import { TypedEventTarget } from "../lib/TypedEventTarget";
|
||||
import { Message } from "../messaging";
|
||||
|
||||
type EventMessengerListener = (message: Message) => void;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
import messaging, { Message } from "../messaging";
|
||||
import { Message } from "../messaging";
|
||||
|
||||
import { BridgeInfo } from "../lib/bridge";
|
||||
import { TypedMessagePort } from "../lib/TypedMessagePort";
|
||||
|
||||
@@ -17,8 +17,7 @@ if (!_window.chrome) {
|
||||
// Create page-accessible API object
|
||||
_window.chrome.cast = new CastSDK();
|
||||
|
||||
let bridgeInfo: any;
|
||||
let frameworkScriptPromise: Promise<HTMLScriptElement>;
|
||||
let frameworkScriptPromise: Promise<HTMLScriptElement> | undefined;
|
||||
|
||||
/**
|
||||
* If loaded within a page via a <script> element,
|
||||
@@ -27,8 +26,9 @@ let frameworkScriptPromise: Promise<HTMLScriptElement>;
|
||||
*/
|
||||
if (document.currentScript) {
|
||||
const currentScript = document.currentScript as HTMLScriptElement;
|
||||
const currentScriptUrl = new URL(currentScript.src);
|
||||
const currentScriptParams = new URLSearchParams(currentScriptUrl.search);
|
||||
const currentScriptParams = new URLSearchParams(
|
||||
new URL(currentScript.src).search
|
||||
);
|
||||
|
||||
// Load Framework API if requested
|
||||
if (currentScriptParams.get("loadCastFramework") === "1") {
|
||||
@@ -43,17 +43,13 @@ if (document.currentScript) {
|
||||
eventMessaging.page.addListener(async message => {
|
||||
switch (message.subject) {
|
||||
case "cast:initialized": {
|
||||
bridgeInfo = message.data;
|
||||
|
||||
// If framework API is requested, ensure loaded
|
||||
if (frameworkScriptPromise) {
|
||||
await frameworkScriptPromise;
|
||||
}
|
||||
await frameworkScriptPromise;
|
||||
|
||||
// Call page script/framework API script's init function
|
||||
const initFn = _window.__onGCastApiAvailable;
|
||||
if (initFn && typeof initFn === "function") {
|
||||
initFn(bridgeInfo && bridgeInfo.isVersionCompatible);
|
||||
initFn(message.data.isVersionCompatible);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,7 @@ export class Error {
|
||||
constructor(
|
||||
public code: string,
|
||||
public description: Nullable<string> = null,
|
||||
public details: any = null
|
||||
public details: unknown = null
|
||||
) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export default class Media {
|
||||
activeTrackIds: Nullable<number[]> = null;
|
||||
breakStatus?: BreakStatus;
|
||||
currentTime = 0;
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
idleReason: Nullable<string> = null;
|
||||
liveSeekableRange?: LiveSeekableRange;
|
||||
media: Nullable<MediaInfo> = null;
|
||||
|
||||
@@ -49,7 +49,7 @@ export class BreakClip {
|
||||
contentId?: string;
|
||||
contentType?: string;
|
||||
contentUrl?: string;
|
||||
customData?: {};
|
||||
customData?: unknown;
|
||||
duration?: number;
|
||||
hlsSegmentFormat?: HlsSegmentFormat;
|
||||
posterUrl?: string;
|
||||
@@ -99,7 +99,7 @@ export class GenericMediaMetadata {
|
||||
}
|
||||
|
||||
export class GetStatusRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
}
|
||||
|
||||
export class LiveSeekableRange {
|
||||
@@ -117,7 +117,7 @@ export class LoadRequest {
|
||||
atvCredentialsType?: string;
|
||||
autoplay: Nullable<boolean> = true;
|
||||
currentTime: Nullable<number> = null;
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
media: MediaInfo;
|
||||
requestId = 0;
|
||||
sessionId: Nullable<string> = null;
|
||||
@@ -139,7 +139,7 @@ export class MediaInfo {
|
||||
atvEntity?: string;
|
||||
breakClips?: BreakClip[];
|
||||
breaks?: Break[];
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
contentUrl?: string;
|
||||
duration: Nullable<number> = null;
|
||||
entity?: string;
|
||||
@@ -200,7 +200,7 @@ export class MusicTrackMediaMetadata {
|
||||
}
|
||||
|
||||
export class PauseRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
}
|
||||
|
||||
export class PhotoMediaMetadata {
|
||||
@@ -218,7 +218,7 @@ export class PhotoMediaMetadata {
|
||||
}
|
||||
|
||||
export class PlayRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
}
|
||||
|
||||
export class QueueData {
|
||||
@@ -236,7 +236,7 @@ export class QueueData {
|
||||
}
|
||||
|
||||
export class QueueInsertItemsRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
insertBefore: Nullable<number> = null;
|
||||
requestId: Nullable<number> = null;
|
||||
sessionId: Nullable<string> = null;
|
||||
@@ -248,7 +248,7 @@ export class QueueInsertItemsRequest {
|
||||
export class QueueItem {
|
||||
activeTrackIds: Nullable<number[]> = null;
|
||||
autoplay = true;
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
itemId: Nullable<number> = null;
|
||||
media: MediaInfo;
|
||||
playbackDuration: Nullable<number> = null;
|
||||
@@ -268,7 +268,7 @@ export class QueueJumpRequest {
|
||||
|
||||
export class QueueLoadRequest {
|
||||
type = "QUEUE_LOAD";
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
repeatMode: string = RepeatMode.OFF;
|
||||
startIndex = 0;
|
||||
|
||||
@@ -277,13 +277,13 @@ export class QueueLoadRequest {
|
||||
|
||||
export class QueueRemoveItemsRequest {
|
||||
type = "QUEUE_REMOVE";
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
|
||||
constructor(public itemIds: number[]) {}
|
||||
}
|
||||
|
||||
export class QueueReorderItemsRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
insertBefore: Nullable<number> = null;
|
||||
type = "QUEUE_REORDER";
|
||||
|
||||
@@ -292,30 +292,30 @@ export class QueueReorderItemsRequest {
|
||||
|
||||
export class QueueSetPropertiesRequest {
|
||||
type = "QUEUE_UPDATE";
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
repeatMode: Nullable<string> = null;
|
||||
}
|
||||
|
||||
export class QueueUpdateItemsRequest {
|
||||
type = "QUEUE_UPDATE";
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
|
||||
constructor(public items: QueueItem[]) {}
|
||||
}
|
||||
|
||||
export class SeekRequest {
|
||||
currentTime: Nullable<number> = null;
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
resumeState: Nullable<ResumeState> = null;
|
||||
}
|
||||
|
||||
export class StopRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
}
|
||||
|
||||
export class TextTrackStyle {
|
||||
backgroundColor: Nullable<string> = null;
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
edgeColor: Nullable<string> = null;
|
||||
edgeType: Nullable<string> = null;
|
||||
fontFamily: Nullable<string> = null;
|
||||
@@ -329,7 +329,7 @@ export class TextTrackStyle {
|
||||
}
|
||||
|
||||
export class Track {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
language: Nullable<string> = null;
|
||||
name: Nullable<string> = null;
|
||||
subtype: Nullable<string> = null;
|
||||
@@ -355,7 +355,7 @@ export class TvShowMediaMetadata {
|
||||
}
|
||||
|
||||
export class UserActionState {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
|
||||
constructor(public userAction: UserAction) {}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ export class VideoInformation {
|
||||
}
|
||||
|
||||
export class VolumeRequest {
|
||||
customData: any = null;
|
||||
customData: unknown = null;
|
||||
|
||||
constructor(public volume: Volume) {}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ import cast, { ensureInit } from "../../export";
|
||||
import { Message } from "../../../messaging";
|
||||
import { ReceiverDevice } from "../../../types";
|
||||
|
||||
import type Session from "../../sdk/Session";
|
||||
import type Media from "../../sdk/media/Media";
|
||||
import type { Error as Error_ } from "../../sdk/classes";
|
||||
|
||||
function startMediaServer(
|
||||
filePath: string,
|
||||
port: number
|
||||
@@ -49,12 +53,12 @@ function startMediaServer(
|
||||
|
||||
let backgroundPort: MessagePort;
|
||||
|
||||
let currentSession: cast.Session;
|
||||
let currentMedia: cast.media.Media;
|
||||
let currentSession: Session;
|
||||
let currentMedia: Media;
|
||||
|
||||
let targetElement: HTMLElement;
|
||||
|
||||
function getSession(opts: InitOptions): Promise<cast.Session> {
|
||||
function getSession(opts: InitOptions): Promise<Session> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
/**
|
||||
* If a receiver is available, call requestSession. If a
|
||||
@@ -76,10 +80,10 @@ function getSession(opts: InitOptions): Promise<cast.Session> {
|
||||
// TODO: Handle this
|
||||
}
|
||||
|
||||
function onRequestSessionSuccess(session: cast.Session) {
|
||||
function onRequestSessionSuccess(session: Session) {
|
||||
resolve(session);
|
||||
}
|
||||
function onRequestSessionError(err: cast.Error) {
|
||||
function onRequestSessionError(err: Error_) {
|
||||
reject(err.description);
|
||||
}
|
||||
|
||||
@@ -97,7 +101,7 @@ function getSession(opts: InitOptions): Promise<cast.Session> {
|
||||
});
|
||||
}
|
||||
|
||||
function getMedia(opts: InitOptions): Promise<cast.media.Media> {
|
||||
function getMedia(opts: InitOptions): Promise<Media> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let mediaUrl = new URL(opts.mediaUrl);
|
||||
const mediaTitle = mediaUrl.pathname.slice(1);
|
||||
|
||||
@@ -6,6 +6,8 @@ import cast, { ensureInit } from "../export";
|
||||
import { ReceiverSelectorMediaType } from "../../background/receiverSelector";
|
||||
import { ReceiverDevice } from "../../types";
|
||||
|
||||
import type Session from "../sdk/Session";
|
||||
|
||||
// Variables passed from background
|
||||
const {
|
||||
selectedMedia,
|
||||
@@ -17,7 +19,7 @@ const {
|
||||
|
||||
const FX_CAST_RECEIVER_APP_NAMESPACE = "urn:x-cast:fx_cast";
|
||||
|
||||
let session: cast.Session;
|
||||
let session: Session;
|
||||
let wasSessionRequested = false;
|
||||
|
||||
let peerConnection: RTCPeerConnection;
|
||||
@@ -26,7 +28,7 @@ let peerConnection: RTCPeerConnection;
|
||||
* Sends a message to the fx_cast app running on the
|
||||
* receiver device.
|
||||
*/
|
||||
function sendAppMessage(subject: string, data: any) {
|
||||
function sendAppMessage(subject: string, data: unknown) {
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
@@ -41,7 +43,7 @@ window.addEventListener("beforeunload", () => {
|
||||
sendAppMessage("close", null);
|
||||
});
|
||||
|
||||
async function onRequestSessionSuccess(newSession: cast.Session) {
|
||||
async function onRequestSessionSuccess(newSession: Session) {
|
||||
cast.logMessage("onRequestSessionSuccess");
|
||||
|
||||
session = newSession;
|
||||
|
||||
Reference in New Issue
Block a user