diff options
author | Ajay Ramachandran <[email protected]> | 2021-01-17 12:56:37 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-01-17 12:56:37 -0500 |
commit | 7bb8f446bffbab9ecf6b8ee790653960d1d72928 (patch) | |
tree | e3264fce233627892c1f508008cdb046e6b5cdeb | |
parent | 7307340afa08f681f0c4a8ae8c64954dc4d67056 (diff) | |
download | SponsorBlock-7bb8f446bffbab9ecf6b8ee790653960d1d72928.tar.gz SponsorBlock-7bb8f446bffbab9ecf6b8ee790653960d1d72928.zip |
Fix type issues
-rw-r--r-- | src/config.ts | 6 | ||||
-rw-r--r-- | src/types.ts | 46 |
2 files changed, 19 insertions, 33 deletions
diff --git a/src/config.ts b/src/config.ts index c64800e8..4eb3e43d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ import * as CompileConfig from "../config.json"; -import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime, StorageChangesObject } from "./types"; +import { CategorySelection, CategorySkipOption, PreviewBarOption, SponsorTime, StorageChangesObject, UnEncodedSegmentTimes as UnencodedSegmentTimes } from "./types"; import Utils from "./utils"; const utils = new Utils(); @@ -247,7 +247,7 @@ const Config: SBObject = { * * @param data */ -function encodeStoredItem<T>(data: T): T | Array<[string, Array<SponsorTime>]> { +function encodeStoredItem<T>(data: T): T | UnencodedSegmentTimes { // if data is SBMap convert to json for storing if(!(data instanceof SBMap)) return data; return Array.from(data.entries()).filter((element) => element[1] === []); // Remove empty entries @@ -265,7 +265,7 @@ function decodeStoredItem<T>(id: string, data: T): T | SBMap<string, SponsorTime if (Config.defaults[id] instanceof SBMap) { try { if (!Array.isArray(data)) return data; - return new SBMap(id, data); + return new SBMap(id, data as UnencodedSegmentTimes); } catch(e) { console.error("Failed to parse SBMap: " + id); } diff --git a/src/types.ts b/src/types.ts index 64afe352..1d79e015 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,7 +1,7 @@ import SubmissionNotice from "./render/SubmissionNotice"; import SkipNoticeComponent from "./components/SkipNoticeComponent"; -interface ContentContainer { +export interface ContentContainer { (): { vote: (type: number, UUID: string, category?: string, skipNotice?: SkipNoticeComponent) => void, dontShowNoticeAgain: () => void, @@ -22,34 +22,34 @@ interface ContentContainer { } } -interface FetchResponse { +export interface FetchResponse { responseText: string, status: number, ok: boolean } -interface VideoDurationResponse { +export interface VideoDurationResponse { duration: number; } -enum CategorySkipOption { +export enum CategorySkipOption { ShowOverlay, ManualSkip, AutoSkip } -interface CategorySelection { +export interface CategorySelection { name: string; option: CategorySkipOption } -enum SponsorHideType { +export enum SponsorHideType { Visible = undefined, Downvoted = 1, MinimumDuration } -interface SponsorTime { +export interface SponsorTime { segment: number[]; UUID: string; @@ -58,13 +58,13 @@ interface SponsorTime { hidden?: SponsorHideType; } -interface PreviewBarOption { +export interface PreviewBarOption { color: string, opacity: string } -interface Registration { +export interface Registration { message: string, id: string, allFrames: boolean, @@ -73,12 +73,12 @@ interface Registration { matches: string[] } -interface BackgroundScriptContainer { +export interface BackgroundScriptContainer { registerFirefoxContentScript: (opts: Registration) => void, unregisterFirefoxContentScript: (id: string) => void } -interface VideoInfo { +export interface VideoInfo { responseContext: { serviceTrackingParams: Array<{service: string, params: Array<{key: string, value: string}>}>, webResponseContextExtensionData: { @@ -154,22 +154,8 @@ interface VideoInfo { messages: unknown; } -type VideoID = string; - -type StorageChangesObject = { [key: string]: chrome.storage.StorageChange }; - -export { - FetchResponse, - VideoDurationResponse, - ContentContainer, - CategorySelection, - CategorySkipOption, - SponsorTime, - VideoID, - SponsorHideType, - PreviewBarOption, - Registration, - BackgroundScriptContainer, - VideoInfo, - StorageChangesObject, -}; +export type VideoID = string; + +export type StorageChangesObject = { [key: string]: chrome.storage.StorageChange }; + +export type UnEncodedSegmentTimes = [string, SponsorTime[]][];
\ No newline at end of file |