mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 18:39:58 +00:00
Switch to eslint and fix issues
This commit is contained in:
40
.eslintrc.json
Normal file
40
.eslintrc.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"root": true
|
||||||
|
, "parser": "@typescript-eslint/parser"
|
||||||
|
, "plugins": ["@typescript-eslint"]
|
||||||
|
, "extends": [
|
||||||
|
"eslint:recommended"
|
||||||
|
, "plugin:@typescript-eslint/recommended"
|
||||||
|
]
|
||||||
|
, "rules": {
|
||||||
|
"max-len": [ "error", 80, {
|
||||||
|
"tabWidth": 4
|
||||||
|
, "ignorePattern": "//|.*(\"|`);?$"
|
||||||
|
, "ignoreStrings": true
|
||||||
|
, "ignoreTemplateLiterals": true
|
||||||
|
, "ignoreRegExpLiterals": true
|
||||||
|
}]
|
||||||
|
, "space-before-function-paren": [ "error", {
|
||||||
|
"anonymous": "always"
|
||||||
|
, "named": "never"
|
||||||
|
, "asyncArrow": "always"
|
||||||
|
}]
|
||||||
|
, "no-useless-escape": "off"
|
||||||
|
, "no-prototype-builtins": "off"
|
||||||
|
, "no-async-promise-executor": "off"
|
||||||
|
, "semi": [ "error", "always"]
|
||||||
|
, "comma-dangle": [ "error", "never"]
|
||||||
|
, "comma-style": [ "error", "first"]
|
||||||
|
, "no-multiple-empty-lines": [ "error", { "max": 2 }]
|
||||||
|
, "no-console": [ "error", {
|
||||||
|
"allow": [ "info", "error" ]
|
||||||
|
}]
|
||||||
|
|
||||||
|
, "@typescript-eslint/no-empty-interface": "off"
|
||||||
|
, "@typescript-eslint/no-explicit-any": "off"
|
||||||
|
, "@typescript-eslint/explicit-module-boundary-types": "off"
|
||||||
|
, "@typescript-eslint/no-unused-vars": "off"
|
||||||
|
, "@typescript-eslint/ban-types": "off"
|
||||||
|
, "@typescript-eslint/ban-ts-comment": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/.eslintrc.json
Normal file
5
app/.eslintrc.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"package": "node bin/build.js --package",
|
"package": "node bin/build.js --package",
|
||||||
"install-manifest": "node bin/install-manifest.js",
|
"install-manifest": "node bin/install-manifest.js",
|
||||||
"remove-manifest": "node bin/install-manifest.js --remove",
|
"remove-manifest": "node bin/install-manifest.js --remove",
|
||||||
"lint": "tslint -c tslint.json -p ."
|
"lint": "eslint src --ext .ts,.tsx"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bplist-creator": "0.0.8",
|
"bplist-creator": "0.0.8",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import castv2 from "castv2";
|
|||||||
import Session from "./Session";
|
import Session from "./Session";
|
||||||
|
|
||||||
import { Message } from "../../messaging";
|
import { Message } from "../../messaging";
|
||||||
import { sendMessage } from "../../lib/nativeMessaging"
|
import { sendMessage } from "../../lib/nativeMessaging";
|
||||||
|
|
||||||
|
|
||||||
const NS_MEDIA = "urn:x-cast:com.google.cast.media";
|
const NS_MEDIA = "urn:x-cast:com.google.cast.media";
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default class Session {
|
|||||||
transportHeartbeat.send({ type: "PING" });
|
transportHeartbeat.send({ type: "PING" });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clientHeartbeat!.send({ type: "PING" });
|
this.clientHeartbeat?.send({ type: "PING" });
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
this.clientReceiver.send({
|
this.clientReceiver.send({
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export function handleMediaMessage (message: any) {
|
|||||||
|
|
||||||
if (existingMedia.has(mediaId)) {
|
if (existingMedia.has(mediaId)) {
|
||||||
// Forward message to instance message handler
|
// Forward message to instance message handler
|
||||||
existingMedia.get(mediaId)!.messageHandler(message);
|
existingMedia.get(mediaId)?.messageHandler(message);
|
||||||
} else {
|
} else {
|
||||||
if (message.subject === "bridge:media/initialize") {
|
if (message.subject === "bridge:media/initialize") {
|
||||||
// Get Session object media belongs to
|
// Get Session object media belongs to
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export let mediaServer: http.Server | undefined;
|
|||||||
|
|
||||||
export async function startMediaServer(filePath: string, port: number) {
|
export async function startMediaServer(filePath: string, port: number) {
|
||||||
if (mediaServer?.listening) {
|
if (mediaServer?.listening) {
|
||||||
await stopMediaServer();
|
stopMediaServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileDir: string;
|
let fileDir: string;
|
||||||
@@ -74,7 +74,9 @@ export async function startMediaServer (filePath: string, port: number) {
|
|||||||
path.join(fileDir, dirEntry.name)));
|
path.join(fileDir, dirEntry.name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {
|
||||||
|
// TODO: Handle?
|
||||||
|
}
|
||||||
|
|
||||||
mediaServer = http.createServer(async (req, res) => {
|
mediaServer = http.createServer(async (req, res) => {
|
||||||
if (!req.url) {
|
if (!req.url) {
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ export function init (port: number) {
|
|||||||
process.stdout.write("Starting WebSocket server... ");
|
process.stdout.write("Starting WebSocket server... ");
|
||||||
|
|
||||||
const wss = new WebSocket.Server({ port }, () => {
|
const wss = new WebSocket.Server({ port }, () => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log("Done!");
|
console.log("Done!");
|
||||||
});
|
});
|
||||||
|
|
||||||
wss.on("error", (err) => {
|
wss.on("error", (err) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log("Failed!");
|
console.log("Failed!");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
@@ -26,6 +28,7 @@ export function init (port: number) {
|
|||||||
wss.on("connection", socket => {
|
wss.on("connection", socket => {
|
||||||
// Stream for incoming WebSocket messages
|
// Stream for incoming WebSocket messages
|
||||||
const messageStream = new Readable({ objectMode: true });
|
const messageStream = new Readable({ objectMode: true });
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
messageStream._read = () => {};
|
messageStream._read = () => {};
|
||||||
|
|
||||||
socket.on("message", (message: string) => {
|
socket.on("message", (message: string) => {
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ const argv = minimist(process.argv.slice(2), {
|
|||||||
|
|
||||||
|
|
||||||
if (argv.version) {
|
if (argv.version) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(`v${__applicationVersion}`);
|
console.log(`v${__applicationVersion}`);
|
||||||
} else if (argv.help) {
|
} else if (argv.help) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(
|
console.log(
|
||||||
`Usage: ${argv.__name} [options]
|
`Usage: ${argv.__name} [options]
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../tslint.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
const { spawnSync } = require("child_process");
|
|
||||||
const { ROOT, INCLUDE_PATH } = require("./lib/paths");
|
|
||||||
|
|
||||||
|
|
||||||
spawnSync(`tslint --config ${ROOT}/tslint.json \
|
|
||||||
--project ${ROOT}/tsconfig.json \
|
|
||||||
"${INCLUDE_PATH}/**/*.ts{,x}"`
|
|
||||||
, {
|
|
||||||
shell: true
|
|
||||||
, stdio: [ process.stdin, process.stdout, process.stderr ]
|
|
||||||
});
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"package": "node bin/build.js --package",
|
"package": "node bin/build.js --package",
|
||||||
"watch": "node bin/build.js --watch",
|
"watch": "node bin/build.js --watch",
|
||||||
"start": "web-ext run -s ../dist/ext/",
|
"start": "web-ext run -s ../dist/ext/",
|
||||||
"lint": "node bin/lint.js"
|
"lint": "eslint src --ext .ts,.tsx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/firefox-webext-browser": "^82.0.0",
|
"@types/firefox-webext-browser": "^82.0.0",
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export interface Shim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// tslint:disable-next-line:new-parens
|
|
||||||
export default new class ShimManager {
|
export default new class ShimManager {
|
||||||
private activeShims = new Set<Shim>();
|
private activeShims = new Set<Shim>();
|
||||||
|
|
||||||
@@ -164,8 +163,6 @@ export default new class ShimManager {
|
|||||||
throw logger.error("Shim associated with content sender missing tab/frame ID");
|
throw logger.error("Shim associated with content sender missing tab/frame ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentTab = await browser.tabs.get(shim.contentTabId);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const selection =
|
const selection =
|
||||||
await ReceiverSelectorManager.getSelection(
|
await ReceiverSelectorManager.getSelection(
|
||||||
@@ -231,8 +228,8 @@ export default new class ShimManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: If we're closing a selector, make sure it's the
|
* TODO: If we're closing a selector, make sure it's the same
|
||||||
* same one that caused the session creation.
|
* one that caused the session creation.
|
||||||
*/
|
*/
|
||||||
case "main:sessionCreated": {
|
case "main:sessionCreated": {
|
||||||
const selector = await ReceiverSelectorManager.getSelector();
|
const selector = await ReceiverSelectorManager.getSelector();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ interface EventMap {
|
|||||||
"statusUpdate": { id: string, status: ReceiverStatus };
|
"statusUpdate": { id: string, status: ReceiverStatus };
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:new-parens
|
|
||||||
export default new class StatusManager
|
export default new class StatusManager
|
||||||
extends TypedEventTarget<EventMap> {
|
extends TypedEventTarget<EventMap> {
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ async function init () {
|
|||||||
*/
|
*/
|
||||||
messaging.onConnect.addListener(async port => {
|
messaging.onConnect.addListener(async port => {
|
||||||
if (port.name === "shim") {
|
if (port.name === "shim") {
|
||||||
ShimManager.createShim(port as any);
|
ShimManager.createShim(port);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import loadSender from "../lib/loadSender";
|
|||||||
import logger from "../lib/logger";
|
import logger from "../lib/logger";
|
||||||
import options from "../lib/options";
|
import options from "../lib/options";
|
||||||
|
|
||||||
import { getMediaTypesForPageUrl, stringify } from "../lib/utils";
|
import { stringify } from "../lib/utils";
|
||||||
|
|
||||||
import { ReceiverSelectionActionType
|
import { ReceiverSelectionActionType
|
||||||
, ReceiverSelectorMediaType } from "./receiverSelector";
|
, ReceiverSelectorMediaType } from "./receiverSelector";
|
||||||
@@ -98,9 +98,6 @@ browser.menus.onClicked.addListener(async (info, tab) => {
|
|||||||
throw logger.error("Menu handler page URL not found.");
|
throw logger.error("Menu handler page URL not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const availableMediaTypes = getMediaTypesForPageUrl(info.pageUrl);
|
|
||||||
|
|
||||||
switch (info.menuItemId) {
|
switch (info.menuItemId) {
|
||||||
case menuIdCast: {
|
case menuIdCast: {
|
||||||
const selection = await ReceiverSelectorManager.getSelection(
|
const selection = await ReceiverSelectorManager.getSelection(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const _ = browser.i18n.getMessage;
|
|||||||
// TODO: Figure out lifetime properly
|
// TODO: Figure out lifetime properly
|
||||||
export default class NativeReceiverSelector extends ReceiverSelector {
|
export default class NativeReceiverSelector extends ReceiverSelector {
|
||||||
private bridgePort: (Port | null) = null;
|
private bridgePort: (Port | null) = null;
|
||||||
private wasReceiverSelected: boolean = false;
|
private wasReceiverSelected = false;
|
||||||
|
|
||||||
#isOpen = false;
|
#isOpen = false;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
private defaultMediaType?: ReceiverSelectorMediaType;
|
private defaultMediaType?: ReceiverSelectorMediaType;
|
||||||
private availableMediaTypes?: ReceiverSelectorMediaType;
|
private availableMediaTypes?: ReceiverSelectorMediaType;
|
||||||
|
|
||||||
private wasReceiverSelected: boolean = false;
|
private wasReceiverSelected = false;
|
||||||
|
|
||||||
private appId?: string;
|
private appId?: string;
|
||||||
|
|
||||||
|
|||||||
18
ext/src/global.d.ts
vendored
18
ext/src/global.d.ts
vendored
@@ -5,7 +5,7 @@ declare const APPLICATION_VERSION: string;
|
|||||||
|
|
||||||
|
|
||||||
declare interface Object {
|
declare interface Object {
|
||||||
// tslint:disable-next-line:ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
wrappedJSObject: Object;
|
wrappedJSObject: Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,6 @@ declare function exportFunction (
|
|||||||
, options?: ExportFunctionOptions): ExportFunctionFunc;
|
, options?: ExportFunctionOptions): ExportFunctionFunc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Fix issues with @types/firefox-webext-browser
|
// Fix issues with @types/firefox-webext-browser
|
||||||
declare namespace browser.events {
|
declare namespace browser.events {
|
||||||
/**
|
/**
|
||||||
@@ -96,18 +95,3 @@ declare namespace browser.runtime {
|
|||||||
, includeTlsChannelId?: boolean
|
, includeTlsChannelId?: boolean
|
||||||
}): browser.runtime.Port;
|
}): browser.runtime.Port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Allow default attribute on <button>
|
|
||||||
declare namespace React {
|
|
||||||
interface ButtonHTMLAttributes<T> {
|
|
||||||
default?: boolean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare namespace JSX {
|
|
||||||
interface IntrinsicElements {
|
|
||||||
button: React.DetailedHTMLProps<
|
|
||||||
React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ export default class Messenger<T> {
|
|||||||
return browser.runtime.onConnect.hasListener(cb as any);
|
return browser.runtime.onConnect.hasListener(cb as any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ export class Logger {
|
|||||||
public log(message: string, data?: any) {
|
public log(message: string, data?: any) {
|
||||||
const formattedMessage = `${this.prefix} (Log): ${message}`;
|
const formattedMessage = `${this.prefix} (Log): ${message}`;
|
||||||
if (data) {
|
if (data) {
|
||||||
// tslint:disable-next-line:no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(formattedMessage, data);
|
console.log(formattedMessage, data);
|
||||||
} else {
|
} else {
|
||||||
// tslint:disable-next-line:no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(formattedMessage);
|
console.log(formattedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import options from "./options";
|
|||||||
import { Message, Port } from "../messaging";
|
import { Message, Port } from "../messaging";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type DisconnectListener = (port: Port) => void;
|
type DisconnectListener = (port: Port) => void;
|
||||||
type MessageListener = (message: Message) => void;
|
type MessageListener = (message: Message) => void;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ interface EventMap {
|
|||||||
"changed": Array<keyof Options>;
|
"changed": Array<keyof Options>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:new-parens
|
|
||||||
export default new class extends TypedEventTarget<EventMap> {
|
export default new class extends TypedEventTarget<EventMap> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import { ReceiverSelectorMediaType } from "../background/receiverSelector";
|
|||||||
|
|
||||||
|
|
||||||
export function getNextEllipsis(ellipsis: string): string {
|
export function getNextEllipsis(ellipsis: string): string {
|
||||||
/* tslint:disable:curly */
|
|
||||||
if (ellipsis === "") return ".";
|
if (ellipsis === "") return ".";
|
||||||
if (ellipsis === ".") return "..";
|
if (ellipsis === ".") return "..";
|
||||||
if (ellipsis === "..") return "...";
|
if (ellipsis === "..") return "...";
|
||||||
if (ellipsis === "...") return "";
|
if (ellipsis === "...") return "";
|
||||||
/* tslint:enable:curly */
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -111,7 +109,6 @@ export function getWindowCenteredProps (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// tslint:disable-next-line:max-line-length
|
|
||||||
export const REMOTE_MATCH_PATTERN_REGEX = /^(?:(?:(\*|https?|ftp):\/\/(\*|(?:\*\.(?:[^\/\*:]\.?)+(?:[^\.])|[^\/\*:]*))?)(\/.*)|<all_urls>)$/;
|
export const REMOTE_MATCH_PATTERN_REGEX = /^(?:(?:(\*|https?|ftp):\/\/(\*|(?:\*\.(?:[^\/\*:]\.?)+(?:[^\.])|[^\/\*:]*))?)(\/.*)|<all_urls>)$/;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -234,8 +234,6 @@ function getMedia (opts: InitOptions): Promise<cast.media.Media> {
|
|||||||
let ignoreMediaEvents = false;
|
let ignoreMediaEvents = false;
|
||||||
|
|
||||||
async function registerMediaElementListeners() {
|
async function registerMediaElementListeners() {
|
||||||
if (await options.get("mediaSyncElement")) {
|
|
||||||
|
|
||||||
function checkIgnore(ev: Event) {
|
function checkIgnore(ev: Event) {
|
||||||
if (ignoreMediaEvents) {
|
if (ignoreMediaEvents) {
|
||||||
ignoreMediaEvents = false;
|
ignoreMediaEvents = false;
|
||||||
@@ -243,6 +241,7 @@ async function registerMediaElementListeners () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await options.get("mediaSyncElement")) {
|
||||||
mediaElement.addEventListener("play", checkIgnore, true);
|
mediaElement.addEventListener("play", checkIgnore, true);
|
||||||
mediaElement.addEventListener("pause", checkIgnore, true);
|
mediaElement.addEventListener("pause", checkIgnore, true);
|
||||||
mediaElement.addEventListener("suspend", checkIgnore, true);
|
mediaElement.addEventListener("suspend", checkIgnore, true);
|
||||||
@@ -380,8 +379,7 @@ export async function init (opts: InitOptions) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (await options.get("mediaStopOnUnload")) {
|
if (await options.get("mediaStopOnUnload")) {
|
||||||
// tslint:disable-next-line: no-empty
|
currentSession.stop();
|
||||||
currentSession.stop(() => {}, () => {});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ Element.prototype.attachShadow = function (init) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getShadowRootFromNode(node: Node): ShadowRoot | undefined {
|
function getShadowRootFromNode(node: Node): ShadowRoot | undefined {
|
||||||
// Don't touch our custom element
|
// Don't touch our custom element
|
||||||
if (node instanceof PlayerElement) {
|
if (node instanceof PlayerElement) {
|
||||||
@@ -51,7 +50,7 @@ function deepQuerySelector (selector: string): Element | null {
|
|||||||
, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
|
, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
|
||||||
|
|
||||||
let node: Node | null;
|
let node: Node | null;
|
||||||
// tslint:disable-next-line: no-conditional-assignment
|
// eslint-disable-next-line no-cond-assign
|
||||||
while (node = result.iterateNext()) {
|
while (node = result.iterateNext()) {
|
||||||
const shadowRoot = getShadowRootFromNode(node);
|
const shadowRoot = getShadowRootFromNode(node);
|
||||||
if (!shadowRoot) {
|
if (!shadowRoot) {
|
||||||
@@ -79,7 +78,7 @@ function deepQuerySelectorAll (selector: string): Node[] {
|
|||||||
const nodes: Node[] = [];
|
const nodes: Node[] = [];
|
||||||
|
|
||||||
let node: Node | null;
|
let node: Node | null;
|
||||||
// tslint:disable-next-line: no-conditional-assignment
|
// eslint-disable-next-line no-cond-assign
|
||||||
while (node = result.iterateNext()) {
|
while (node = result.iterateNext()) {
|
||||||
const shadowRoot = getShadowRootFromNode(node);
|
const shadowRoot = getShadowRootFromNode(node);
|
||||||
if (shadowRoot) {
|
if (shadowRoot) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default class SessionRequest {
|
|||||||
public appId: string
|
public appId: string
|
||||||
, public capabilities = [ Capability.VIDEO_OUT
|
, public capabilities = [ Capability.VIDEO_OUT
|
||||||
, Capability.AUDIO_OUT ]
|
, Capability.AUDIO_OUT ]
|
||||||
, public requestSessionTimeout: number = (new Timeout()).requestSession
|
, public requestSessionTimeout = (new Timeout()).requestSession
|
||||||
, public androidReceiverCompatible = false
|
, public androidReceiverCompatible = false
|
||||||
, public credentialsData: (CredentialsData | null) = null) {}
|
, public credentialsData: (CredentialsData | null) = null) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export function initialize (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function logMessage(message: string): void {
|
export function logMessage(message: string): void {
|
||||||
/* tslint:disable-next-line:no-console */
|
// eslint-disable-next-line no-console
|
||||||
console.log("CAST MSG:", message);
|
console.log("CAST MSG:", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +343,7 @@ onMessage(async message => {
|
|||||||
(selectedReceiver as any)._address = message.data.receiver.host;
|
(selectedReceiver as any)._address = message.data.receiver.host;
|
||||||
(selectedReceiver as any)._port = message.data.receiver.port;
|
(selectedReceiver as any)._port = message.data.receiver.port;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-inner-declarations
|
||||||
function createSession() {
|
function createSession() {
|
||||||
sessionList.push(new Session(
|
sessionList.push(new Session(
|
||||||
sessionList.length.toString() // sessionId
|
sessionList.length.toString() // sessionId
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
export default class LiveSeekableRange {
|
export default class LiveSeekableRange {
|
||||||
constructor (public start?: number
|
constructor(
|
||||||
|
public start?: number
|
||||||
, public end?: number
|
, public end?: number
|
||||||
, public isMovingWindow?: boolean
|
, public isMovingWindow?: boolean
|
||||||
, public isLiveDone?: boolean) {}
|
, public isLiveDone?: boolean) {}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ export default class LoadRequest {
|
|||||||
public currentTime: (number | null) = null;
|
public currentTime: (number | null) = null;
|
||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
public media: MediaInfo;
|
public media: MediaInfo;
|
||||||
public requestId: number = 0;
|
public requestId = 0;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "LOAD";
|
public type = "LOAD";
|
||||||
|
|
||||||
constructor(mediaInfo: MediaInfo) {
|
constructor(mediaInfo: MediaInfo) {
|
||||||
this.media = mediaInfo;
|
this.media = mediaInfo;
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ export default class Media {
|
|||||||
public breakStatus?: BreakStatus;
|
public breakStatus?: BreakStatus;
|
||||||
public currentItemId: (number | null) = null;
|
public currentItemId: (number | null) = null;
|
||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
public currentTime: number = 0;
|
public currentTime = 0;
|
||||||
public idleReason: (string | null) = null;
|
public idleReason: (string | null) = null;
|
||||||
public items: (QueueItem[] | null) = null;
|
public items: (QueueItem[] | null) = null;
|
||||||
public liveSeekableRange?: LiveSeekableRange;
|
public liveSeekableRange?: LiveSeekableRange;
|
||||||
public loadingItemId: (number | null) = null;
|
public loadingItemId: (number | null) = null;
|
||||||
public media: (MediaInfo | null) = null;
|
public media: (MediaInfo | null) = null;
|
||||||
public playbackRate: number = 1;
|
public playbackRate = 1;
|
||||||
public playerState: string = PlayerState.IDLE;
|
public playerState: string = PlayerState.IDLE;
|
||||||
public preloadedItemId: (number | null) = null;
|
public preloadedItemId: (number | null) = null;
|
||||||
public queueData?: QueueData;
|
public queueData?: QueueData;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class QueueInsertItemsRequest {
|
|||||||
public insertBefore: (number | null) = null;
|
public insertBefore: (number | null) = null;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "QUEUE_INSERT";
|
public type = "QUEUE_INSERT";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public items: QueueItem[]) {}
|
public items: QueueItem[]) {}
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import MediaInfo from "./MediaInfo";
|
|||||||
|
|
||||||
export default class QueueItem {
|
export default class QueueItem {
|
||||||
public activeTrackIds: (number[] | null) = null;
|
public activeTrackIds: (number[] | null) = null;
|
||||||
public autoplay: boolean = true;
|
public autoplay = true;
|
||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
public itemId: (number | null) = null;
|
public itemId: (number | null) = null;
|
||||||
public media: MediaInfo;
|
public media: MediaInfo;
|
||||||
public playbackDuration: (number | null) = null;
|
public playbackDuration: (number | null) = null;
|
||||||
public preloadTime: number = 0;
|
public preloadTime = 0;
|
||||||
public startTime: number = 0;
|
public startTime = 0;
|
||||||
|
|
||||||
constructor(mediaInfo: MediaInfo) {
|
constructor(mediaInfo: MediaInfo) {
|
||||||
this.media = mediaInfo;
|
this.media = mediaInfo;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export default class QueueLoadRequest {
|
|||||||
public repeatMode: string = RepeatMode.OFF;
|
public repeatMode: string = RepeatMode.OFF;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public startIndex: number = 0;
|
public startIndex = 0;
|
||||||
public type: string = "QUEUE_LOAD";
|
public type = "QUEUE_LOAD";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public items: QueueItem[]) {}
|
public items: QueueItem[]) {}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export default class QueueRemoveItemsRequest {
|
|||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "QUEUE_REMOVE";
|
public type = "QUEUE_REMOVE";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public itemIds: number[]) {}
|
public itemIds: number[]) {}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default class QueueReorderItemsRequest {
|
|||||||
public insertBefore: (number | null) = null;
|
public insertBefore: (number | null) = null;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "QUEUE_REORDER";
|
public type = "QUEUE_REORDER";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public itemIds: number[]) {}
|
public itemIds: number[]) {}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ export default class QueueSetPropertiesRequest {
|
|||||||
public repeatMode: (string | null) = null;
|
public repeatMode: (string | null) = null;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "QUEUE_UPDATE";
|
public type = "QUEUE_UPDATE";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default class QueueUpdateItemsRequest {
|
|||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
public requestId: (number | null) = null;
|
public requestId: (number | null) = null;
|
||||||
public sessionId: (string | null) = null;
|
public sessionId: (string | null) = null;
|
||||||
public type: string = "QUEUE_UPDATE";
|
public type = "QUEUE_UPDATE";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public items: QueueItem[]) {}
|
public items: QueueItem[]) {}
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ import { UserAction } from "../enums";
|
|||||||
export default class UserActionState {
|
export default class UserActionState {
|
||||||
public customData: any = null;
|
public customData: any = null;
|
||||||
|
|
||||||
constructor (public userAction: UserAction) {}
|
constructor(
|
||||||
|
public userAction: UserAction) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { HdrType } from "../enums";
|
|||||||
|
|
||||||
|
|
||||||
export default class VideoInformation {
|
export default class VideoInformation {
|
||||||
constructor (public width: number
|
constructor(
|
||||||
|
public width: number
|
||||||
, public height: number
|
, public height: number
|
||||||
, public hdrType: HdrType) {}
|
, public hdrType: HdrType) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ export default class GoogleCastLauncher extends HTMLElement {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// tslint:disable:max-line-length
|
|
||||||
|
|
||||||
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
||||||
|
|
||||||
const icon = document.createElementNS(SVG_NAMESPACE, "svg");
|
const icon = document.createElementNS(SVG_NAMESPACE, "svg");
|
||||||
@@ -67,9 +65,6 @@ export default class GoogleCastLauncher extends HTMLElement {
|
|||||||
// Add icon paths to SVG
|
// Add icon paths to SVG
|
||||||
icon.append(iconArch0, iconArch1, iconArch2, iconBox, iconBoxFill);
|
icon.append(iconArch0, iconArch1, iconArch2, iconBox, iconBoxFill);
|
||||||
|
|
||||||
// tslint:enable:max-line-length
|
|
||||||
|
|
||||||
|
|
||||||
const shadow = this.attachShadow({ mode: "open" });
|
const shadow = this.attachShadow({ mode: "open" });
|
||||||
shadow.append(icon, style);
|
shadow.append(icon, style);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default class CastOptions {
|
|||||||
public autoJoinPolicy: string = cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;
|
public autoJoinPolicy: string = cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;
|
||||||
public language: (string | null) = null;
|
public language: (string | null) = null;
|
||||||
public receiverApplicationId: (string | null) = null;
|
public receiverApplicationId: (string | null) = null;
|
||||||
public resumeSavedSession: boolean = true;
|
public resumeSavedSession = true;
|
||||||
|
|
||||||
constructor(options: CastOptions = ({} as CastOptions)) {
|
constructor(options: CastOptions = ({} as CastOptions)) {
|
||||||
if (options.autoJoinPolicy) {
|
if (options.autoJoinPolicy) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* tslint:disable:max-line-length */
|
/* eslint-disable max-len */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* tslint:disable:max-line-length */
|
/* eslint-disable max-len */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* tslint:disable:max-line-length */
|
/* eslint-disable max-len */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
@@ -402,6 +402,7 @@ class OptionsApp extends Component<
|
|||||||
{ _("optionsReset") }
|
{ _("optionsReset") }
|
||||||
</button>
|
</button>
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
|
// @ts-ignore
|
||||||
default
|
default
|
||||||
disabled={ !this.state.isFormValid }>
|
disabled={ !this.state.isFormValid }>
|
||||||
{ _("optionsSave") }
|
{ _("optionsSave") }
|
||||||
@@ -469,7 +470,8 @@ class OptionsApp extends Component<
|
|||||||
|
|
||||||
this.setState(currentState => {
|
this.setState(currentState => {
|
||||||
if (currentState.options) {
|
if (currentState.options) {
|
||||||
currentState.options[ev.target.name] = parseInt(ev.target.value);
|
currentState.options[ev.target.name] =
|
||||||
|
parseInt(ev.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentState;
|
return currentState;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* tslint:disable:max-line-length */
|
/* eslint-disable max-len */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
@@ -29,6 +29,7 @@ browser.runtime.getPlatformInfo()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
interface PopupAppProps {}
|
||||||
interface PopupAppState {
|
interface PopupAppState {
|
||||||
receivers: Receiver[];
|
receivers: Receiver[];
|
||||||
mediaType: ReceiverSelectorMediaType;
|
mediaType: ReceiverSelectorMediaType;
|
||||||
@@ -41,12 +42,12 @@ interface PopupAppState {
|
|||||||
mirroringEnabled: boolean;
|
mirroringEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PopupApp extends Component<{}, PopupAppState> {
|
class PopupApp extends Component<PopupAppProps, PopupAppState> {
|
||||||
private port?: Port;
|
private port?: Port;
|
||||||
private win?: browser.windows.Window;
|
private win?: browser.windows.Window;
|
||||||
private defaultMediaType?: ReceiverSelectorMediaType;
|
private defaultMediaType?: ReceiverSelectorMediaType;
|
||||||
|
|
||||||
constructor (props: {}) {
|
constructor(props: PopupAppProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -128,6 +129,10 @@ class PopupApp extends Component<{}, PopupAppState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
/*
|
||||||
|
|
||||||
|
// TODO: Add file support back to popup
|
||||||
|
|
||||||
let truncatedFileName: string;
|
let truncatedFileName: string;
|
||||||
|
|
||||||
if (this.state.filePath) {
|
if (this.state.filePath) {
|
||||||
@@ -138,6 +143,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
|||||||
? `${fileName.substring(0, 12)}...`
|
? `${fileName.substring(0, 12)}...`
|
||||||
: fileName;
|
: fileName;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
const isAppMediaTypeSelected =
|
const isAppMediaTypeSelected =
|
||||||
this.state.mediaType === ReceiverSelectorMediaType.App;
|
this.state.mediaType === ReceiverSelectorMediaType.App;
|
||||||
@@ -147,7 +153,7 @@ class PopupApp extends Component<{}, PopupAppState> {
|
|||||||
this.state.mediaType === ReceiverSelectorMediaType.Screen;
|
this.state.mediaType === ReceiverSelectorMediaType.Screen;
|
||||||
|
|
||||||
const isSelectedMediaTypeAvailable =
|
const isSelectedMediaTypeAvailable =
|
||||||
!!(this.state.availableMediaTypes & this.state.mediaType)
|
!!(this.state.availableMediaTypes & this.state.mediaType);
|
||||||
const isAppMediaTypeAvailable = !!(this.state.availableMediaTypes
|
const isAppMediaTypeAvailable = !!(this.state.availableMediaTypes
|
||||||
& ReceiverSelectorMediaType.App);
|
& ReceiverSelectorMediaType.App);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../tslint.json"
|
|
||||||
]
|
|
||||||
, "rules": {
|
|
||||||
"no-bitwise": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1148
package-lock.json
generated
1148
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -26,13 +26,15 @@
|
|||||||
"@types/semver": "^7.3.4",
|
"@types/semver": "^7.3.4",
|
||||||
"@types/uuid": "^8.3.0",
|
"@types/uuid": "^8.3.0",
|
||||||
"@types/ws": "^7.4.0",
|
"@types/ws": "^7.4.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
|
"eslint": "^7.25.0",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"jasmine-console-reporter": "^3.1.0",
|
"jasmine-console-reporter": "^3.1.0",
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
"selenium-webdriver": "^4.0.0-beta.1",
|
"selenium-webdriver": "^4.0.0-beta.1",
|
||||||
"semver": "^7.3.4",
|
"semver": "^7.3.4",
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"typescript": "^4.1.5",
|
"typescript": "^4.1.5",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"ws": "^7.4.3"
|
"ws": "^7.4.3"
|
||||||
|
|||||||
33
tslint.json
33
tslint.json
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
"defaultSeverity": "error"
|
|
||||||
, "extends": [
|
|
||||||
"tslint:recommended"
|
|
||||||
]
|
|
||||||
, "jsRules": false
|
|
||||||
, "rules": {
|
|
||||||
"array-type": [ true, "array-simple" ],
|
|
||||||
"arrow-parens": false
|
|
||||||
, "import-spacing": false
|
|
||||||
, "interface-name": false
|
|
||||||
, "max-classes-per-file": false
|
|
||||||
, "max-line-length": [ true, {
|
|
||||||
"limit": 80
|
|
||||||
, "ignore-pattern": "//|.*(\"|`);?$"
|
|
||||||
}]
|
|
||||||
, "member-access": [ true ]
|
|
||||||
, "no-consecutive-blank-lines": false
|
|
||||||
, "no-console": [ true, "log" ]
|
|
||||||
, "no-namespace": [ true, "allow-declarations" ]
|
|
||||||
, "object-literal-sort-keys": false
|
|
||||||
, "radix": false
|
|
||||||
, "semicolon": [ true, "always" ]
|
|
||||||
, "space-before-function-paren": [ true, "always" ]
|
|
||||||
, "trailing-comma": false
|
|
||||||
, "variable-name": [ true
|
|
||||||
, "ban-keywords"
|
|
||||||
, "check-format"
|
|
||||||
, "allow-pascal-case"
|
|
||||||
, "allow-leading-underscore" ]
|
|
||||||
}
|
|
||||||
, "rulesDirectory": []
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user