Make type imports explicit

This commit is contained in:
hensm
2022-08-25 22:39:54 +01:00
parent 7a60bb3278
commit 3dcf8552f7
29 changed files with 71 additions and 58 deletions

View File

@@ -1,11 +1,11 @@
"use strict"; "use strict";
import { Channel } from "castv2"; import type { Channel } from "castv2";
import messaging from "../../messaging"; import messaging from "../../messaging";
import { ReceiverDevice } from "../../messagingTypes"; import type { ReceiverDevice } from "../../messagingTypes";
import { ReceiverMessage } from "./types"; import type { ReceiverMessage } from "./types";
import CastClient, { NS_CONNECTION, NS_HEARTBEAT } from "./client"; import CastClient, { NS_CONNECTION, NS_HEARTBEAT } from "./client";

View File

@@ -2,7 +2,7 @@
import { Channel, Client } from "castv2"; import { Channel, Client } from "castv2";
import { ReceiverMessage, SenderMessage } from "./types"; import type { ReceiverMessage, SenderMessage } from "./types";
export const NS_CONNECTION = "urn:x-cast:com.google.cast.tp.connection"; export const NS_CONNECTION = "urn:x-cast:com.google.cast.tp.connection";
export const NS_HEARTBEAT = "urn:x-cast:com.google.cast.tp.heartbeat"; export const NS_HEARTBEAT = "urn:x-cast:com.google.cast.tp.heartbeat";

View File

@@ -2,7 +2,7 @@
import mdns from "mdns"; import mdns from "mdns";
import { ReceiverDevice } from "../../messagingTypes"; import type { ReceiverDevice } from "../../messagingTypes";
/** /**
* Chromecast TXT record * Chromecast TXT record

View File

@@ -2,7 +2,7 @@
import CastClient from "./client"; import CastClient from "./client";
import { import type {
MediaStatus, MediaStatus,
ReceiverMessage, ReceiverMessage,
ReceiverMediaMessage, ReceiverMediaMessage,

View File

@@ -4,14 +4,14 @@ import { TypedEmitter } from "tiny-typed-emitter";
import { DecodeTransform, EncodeTransform } from "../transforms"; import { DecodeTransform, EncodeTransform } from "../transforms";
import { import type {
MediaStatus, MediaStatus,
ReceiverStatus, ReceiverStatus,
SenderMediaMessage, SenderMediaMessage,
SenderMessage SenderMessage
} from "./components/cast/types"; } from "./components/cast/types";
import { import type {
ReceiverDevice, ReceiverDevice,
CastSessionCreatedDetails, CastSessionCreatedDetails,
CastSessionUpdatedDetails CastSessionUpdatedDetails

View File

@@ -1,6 +1,6 @@
"use strict"; "use strict";
import { import type {
Image, Image,
ReceiverStatus, ReceiverStatus,
SenderApplication, SenderApplication,

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
import { Transform, TransformCallback } from "stream"; import { Transform, TransformCallback } from "stream";
import { Message } from "./bridge/messaging"; import type { Message } from "./bridge/messaging";
type ResponseHandlerFunction = (message: Message) => Promise<unknown>; type ResponseHandlerFunction = (message: Message) => Promise<unknown>;

View File

@@ -4,9 +4,10 @@ import bridge from "../lib/bridge";
import logger from "../lib/logger"; import logger from "../lib/logger";
import { TypedEventTarget } from "../lib/TypedEventTarget"; import { TypedEventTarget } from "../lib/TypedEventTarget";
import { Message, Port } from "../messaging"; import type { Message, Port } from "../messaging";
import { ReceiverDevice } from "../types"; import type { ReceiverDevice } from "../types";
import {
import type {
MediaStatus, MediaStatus,
ReceiverStatus, ReceiverStatus,
SenderMediaMessage, SenderMediaMessage,

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
import logger from "../lib/logger"; import logger from "../lib/logger";
import { Message } from "../messaging"; import type { Message } from "../messaging";
type EventMessengerListener = (message: Message) => void; type EventMessengerListener = (message: Message) => void;

View File

@@ -1,9 +1,9 @@
"use strict"; "use strict";
import { Message } from "../messaging"; import type { Message } from "../messaging";
import { BridgeInfo } from "../lib/bridge"; import type { BridgeInfo } from "../lib/bridge";
import { TypedMessagePort } from "../lib/TypedMessagePort"; import type { TypedMessagePort } from "../lib/TypedMessagePort";
import CastSDK from "./sdk"; import CastSDK from "./sdk";

View File

@@ -6,7 +6,7 @@ import logger from "../../lib/logger";
import eventMessaging from "../eventMessaging"; import eventMessaging from "../eventMessaging";
import { import type {
ErrorCallback, ErrorCallback,
LoadSuccessCallback, LoadSuccessCallback,
MediaListener, MediaListener,
@@ -24,10 +24,10 @@ import {
} from "./types"; } from "./types";
import { SessionStatus } from "./enums"; import { SessionStatus } from "./enums";
import { Image, Receiver, SenderApplication } from "./classes"; import type { Image, Receiver, SenderApplication } from "./classes";
import { MediaCommand } from "./media/enums"; import { MediaCommand } from "./media/enums";
import { LoadRequest, QueueLoadRequest, QueueItem } from "./media/classes"; import type { LoadRequest, QueueLoadRequest, QueueItem } from "./media/classes";
import Media, { NS_MEDIA } from "./media/Media"; import Media, { NS_MEDIA } from "./media/Media";
/** /**

View File

@@ -1,6 +1,6 @@
"use strict"; "use strict";
import Session from "./Session"; import type Session from "./Session";
import { import {
AutoJoinPolicy, AutoJoinPolicy,

View File

@@ -2,11 +2,11 @@
import logger from "../../lib/logger"; import logger from "../../lib/logger";
import { Message } from "../../messaging"; import type { Message } from "../../messaging";
import eventMessaging from "../eventMessaging"; import eventMessaging from "../eventMessaging";
import { ReceiverDevice } from "../../types"; import type { ReceiverDevice } from "../../types";
import { ErrorCallback, SuccessCallback } from "../types"; import type { ErrorCallback, SuccessCallback } from "../types";
import { import {
AutoJoinPolicy, AutoJoinPolicy,

View File

@@ -30,8 +30,12 @@ import {
import { PlayerState, RepeatMode } from "./enums"; import { PlayerState, RepeatMode } from "./enums";
import { ErrorCode } from "../enums"; import { ErrorCode } from "../enums";
import { ErrorCallback, SuccessCallback, UpdateListener } from "../../types"; import type {
import { SenderMediaMessage } from "../types"; ErrorCallback,
SuccessCallback,
UpdateListener
} from "../../types";
import type { SenderMediaMessage } from "../types";
import { getEstimatedTime } from "../../utils"; import { getEstimatedTime } from "../../utils";
export const NS_MEDIA = "urn:x-cast:com.google.cast.media"; export const NS_MEDIA = "urn:x-cast:com.google.cast.media";

View File

@@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Image, Volume } from "../classes"; import type { Image, Volume } from "../classes";
import { import {
ContainerType, ContainerType,

View File

@@ -5,9 +5,9 @@
* app/src/bridge/components/cast/types.ts * app/src/bridge/components/cast/types.ts
*/ */
import { SenderApplication, Volume, Image } from "./classes"; import type { SenderApplication, Volume, Image } from "./classes";
import { MediaInfo, QueueItem } from "./media/classes"; import type { MediaInfo, QueueItem } from "./media/classes";
import { import type {
IdleReason, IdleReason,
PlayerState, PlayerState,
RepeatMode, RepeatMode,

View File

@@ -4,8 +4,8 @@ import logger from "../../../lib/logger";
import options from "../../../lib/options"; import options from "../../../lib/options";
import cast, { ensureInit } from "../../export"; import cast, { ensureInit } from "../../export";
import { Message } from "../../../messaging"; import type { Message } from "../../../messaging";
import { ReceiverDevice } from "../../../types"; import type { ReceiverDevice } from "../../../types";
import type Session from "../../sdk/Session"; import type Session from "../../sdk/Session";
import type Media from "../../sdk/media/Media"; import type Media from "../../sdk/media/Media";

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
import { Error as Error_ } from "./sdk/classes"; import type { Error as Error_ } from "./sdk/classes";
import Media from "./sdk/media/Media"; import type Media from "./sdk/media/Media";
export type SuccessCallback = () => void; export type SuccessCallback = () => void;
export type ErrorCallback = (err: Error_) => void; export type ErrorCallback = (err: Error_) => void;

View File

@@ -3,7 +3,7 @@
import semver from "semver"; import semver from "semver";
import logger from "./logger"; import logger from "./logger";
import { Port } from "../messaging"; import type { Port } from "../messaging";
import * as nativeMessaging from "./nativeMessaging"; import * as nativeMessaging from "./nativeMessaging";
import options from "./options"; import options from "./options";

View File

@@ -3,7 +3,7 @@
import logger from "./logger"; import logger from "./logger";
import options from "./options"; import options from "./options";
import { Message, Port } from "../messaging"; import type { Message, Port } from "../messaging";
type DisconnectListener = (port: Port) => void; type DisconnectListener = (port: Port) => void;
type MessageListener = (message: Message) => void; type MessageListener = (message: Message) => void;

View File

@@ -1,9 +1,9 @@
"use strict"; "use strict";
import { TypedPort } from "./lib/TypedPort"; import type { TypedPort } from "./lib/TypedPort";
import { BridgeInfo } from "./lib/bridge"; import type { BridgeInfo } from "./lib/bridge";
import { import type {
ReceiverSelection, ReceiverSelection,
ReceiverSelectionCast, ReceiverSelectionCast,
ReceiverSelectionStop, ReceiverSelectionStop,
@@ -11,7 +11,7 @@ import {
ReceiverSelectorReceiverMessage ReceiverSelectorReceiverMessage
} from "./background/receiverSelector"; } from "./background/receiverSelector";
import { import type {
CastSessionCreatedDetails, CastSessionCreatedDetails,
CastSessionUpdatedDetails, CastSessionUpdatedDetails,
MediaStatus, MediaStatus,
@@ -19,9 +19,9 @@ import {
SenderMediaMessage, SenderMediaMessage,
SenderMessage SenderMessage
} from "./cast/sdk/types"; } from "./cast/sdk/types";
import { SessionRequest } from "./cast/sdk/classes"; import type { SessionRequest } from "./cast/sdk/classes";
import { ReceiverDevice, ReceiverSelectorMediaType } from "./types"; import type { ReceiverDevice, ReceiverSelectorMediaType } from "./types";
/** /**
* Messages are JSON objects with a `subject` string key and a * Messages are JSON objects with a `subject` string key and a

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
import { SessionRequest } from "./cast/sdk/classes"; import type { SessionRequest } from "./cast/sdk/classes";
import { MediaStatus, ReceiverStatus } from "./cast/sdk/types"; import type { MediaStatus, ReceiverStatus } from "./cast/sdk/types";
export enum ReceiverDeviceCapabilities { export enum ReceiverDeviceCapabilities {
NONE = 0, NONE = 0,

View File

@@ -11,7 +11,7 @@
} from "../../lib/bridge"; } from "../../lib/bridge";
import logger from "../../lib/logger"; import logger from "../../lib/logger";
import { Options } from "../../lib/options"; import type { Options } from "../../lib/options";
const _ = browser.i18n.getMessage; const _ = browser.i18n.getMessage;

View File

@@ -1,10 +1,12 @@
<script lang="ts"> <script lang="ts">
import { tick } from "svelte"; import { tick } from "svelte";
import knownApps, { KnownApp } from "../../cast/knownApps"; import type { WhitelistItemData } from "../../background/whitelist";
import { WhitelistItemData } from "../../background/whitelist";
import { REMOTE_MATCH_PATTERN_REGEX } from "../../lib/matchPattern"; import { REMOTE_MATCH_PATTERN_REGEX } from "../../lib/matchPattern";
import { Options } from "../../lib/options"; import type { Options } from "../../lib/options";
import knownApps, { KnownApp } from "../../cast/knownApps";
const _ = browser.i18n.getMessage; const _ = browser.i18n.getMessage;

View File

@@ -430,7 +430,8 @@
{device} {device}
{isMediaTypeAvailable} {isMediaTypeAvailable}
isAnyMediaTypeAvailable={availableMediaTypes !== isAnyMediaTypeAvailable={availableMediaTypes !==
ReceiverSelectorMediaType.None && isDeviceCompatible(device)} ReceiverSelectorMediaType.None &&
isDeviceCompatible(device)}
isAnyConnecting={isConnecting} isAnyConnecting={isConnecting}
on:cast={ev => onReceiverCast(ev.detail.device)} on:cast={ev => onReceiverCast(ev.detail.device)}
on:stop={ev => onReceiverStop(ev.detail.device)} on:stop={ev => onReceiverStop(ev.detail.device)}

View File

@@ -1,11 +1,14 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, onMount } from "svelte"; import { createEventDispatcher, onMount } from "svelte";
import { PlayerState } from "../../cast/sdk/media/enums"; import type { ReceiverDevice } from "../../types";
import { SenderMediaMessage, SenderMessage } from "../../cast/sdk/types"; import type { Port } from "../../messaging";
import { ReceiverDevice } from "../../types";
import { Port } from "../../messaging"; import { PlayerState } from "../../cast/sdk/media/enums";
import type {
SenderMediaMessage,
SenderMessage
} from "../../cast/sdk/types";
import LoadingIndicator from "../LoadingIndicator.svelte"; import LoadingIndicator from "../LoadingIndicator.svelte";
import ReceiverMedia from "./ReceiverMedia.svelte"; import ReceiverMedia from "./ReceiverMedia.svelte";

View File

@@ -1,20 +1,21 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, onMount } from "svelte"; import { createEventDispatcher, onMount } from "svelte";
import { ReceiverDevice } from "../../types"; import type { ReceiverDevice } from "../../types";
import { MediaStatus, _MediaCommand } from "../../cast/sdk/types"; import { MediaStatus, _MediaCommand } from "../../cast/sdk/types";
import { Image, Volume } from "../../cast/sdk/classes"; import type { Image, Volume } from "../../cast/sdk/classes";
import { import {
MetadataType, MetadataType,
PlayerState, PlayerState,
StreamType, StreamType,
TrackType TrackType
} from "../../cast/sdk/media/enums"; } from "../../cast/sdk/media/enums";
import { getEstimatedTime } from "../../cast/utils";
const _ = browser.i18n.getMessage; const _ = browser.i18n.getMessage;
import deviceStore from "./deviceStore"; import deviceStore from "./deviceStore";
import { getEstimatedTime } from "../../cast/utils";
const dispatch = createEventDispatcher<{ const dispatch = createEventDispatcher<{
togglePlayback: void; togglePlayback: void;

View File

@@ -1,4 +1,4 @@
import { writable } from "svelte/store"; import { writable } from "svelte/store";
import { ReceiverDevice } from "../../types"; import type { ReceiverDevice } from "../../types";
export default writable<ReceiverDevice[]>([]); export default writable<ReceiverDevice[]>([]);

View File

@@ -7,7 +7,8 @@
"removeComments": true, "removeComments": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"target": "es6", "target": "es6",
"strict": true "strict": true,
"importsNotUsedAsValues": "error"
}, },
"exclude": ["node_modules/**/*", "**/node_modules/**/*", "dist/**/*"] "exclude": ["node_modules/**/*", "**/node_modules/**/*", "dist/**/*"]
} }