diff --git a/dataTypes.ts b/dataTypes.ts index 6204478..8cc4173 100644 --- a/dataTypes.ts +++ b/dataTypes.ts @@ -4,41 +4,14 @@ export enum SongType { } -export class SearchResult { - public type: SongType - public title: string; - public songId: string; - public image: string; - - constructor(type: SongType, title: string, songId: string, image: string) { - this.type = type; - this.title = title; - this.songId = songId; - this.image = image; - } -} - -export class QueuedSong { - public title: string; - public image: string; - - - constructor(title: string, image: string) { - this.title = title; - this.image = image; - } -} - export class Song { - public type: SongType - public songId: string; - public title: string; - public position: number; + constructor(public type: SongType, public title: string, public songId: string, public image: string) { - constructor(type: SongType, songId: string, title: string, position: number) { - this.type = type; - this.songId = songId; - this.title = title; - this.position = position; + } +} + +export class PlayingSong extends Song { + constructor(type: SongType, title: string, songId: string, image: string, public position: number) { + super(type, title, songId, image); } } diff --git a/dist/dataTypes.d.ts b/dist/dataTypes.d.ts index 2b1c2a3..b252342 100644 --- a/dist/dataTypes.d.ts +++ b/dist/dataTypes.d.ts @@ -2,22 +2,14 @@ export declare enum SongType { YouTube = 0, Spotify = 1 } -export declare class SearchResult { +export declare class Song { type: SongType; title: string; songId: string; image: string; constructor(type: SongType, title: string, songId: string, image: string); } -export declare class QueuedSong { - title: string; - image: string; - constructor(title: string, image: string); -} -export declare class Song { - type: SongType; - songId: string; - title: string; +export declare class PlayingSong extends Song { position: number; - constructor(type: SongType, songId: string, title: string, position: number); + constructor(type: SongType, title: string, songId: string, image: string, position: number); } diff --git a/dist/dataTypes.js b/dist/dataTypes.js index dfc1f7b..5664084 100644 --- a/dist/dataTypes.js +++ b/dist/dataTypes.js @@ -1,36 +1,43 @@ "use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); exports.__esModule = true; -exports.Song = exports.QueuedSong = exports.SearchResult = exports.SongType = void 0; +exports.PlayingSong = exports.Song = exports.SongType = void 0; var SongType; (function (SongType) { SongType[SongType["YouTube"] = 0] = "YouTube"; SongType[SongType["Spotify"] = 1] = "Spotify"; })(SongType = exports.SongType || (exports.SongType = {})); -var SearchResult = /** @class */ (function () { - function SearchResult(type, title, songId, image) { - this.type = type; - this.title = title; - this.songId = songId; - this.image = image; - } - return SearchResult; -}()); -exports.SearchResult = SearchResult; -var QueuedSong = /** @class */ (function () { - function QueuedSong(title, image) { - this.title = title; - this.image = image; - } - return QueuedSong; -}()); -exports.QueuedSong = QueuedSong; var Song = /** @class */ (function () { - function Song(type, songId, title, position) { + function Song(type, title, songId, image) { this.type = type; - this.songId = songId; this.title = title; - this.position = position; + this.songId = songId; + this.image = image; } return Song; }()); exports.Song = Song; +var PlayingSong = /** @class */ (function (_super) { + __extends(PlayingSong, _super); + function PlayingSong(type, title, songId, image, position) { + var _this = _super.call(this, type, title, songId, image) || this; + _this.position = position; + return _this; + } + return PlayingSong; +}(Song)); +exports.PlayingSong = PlayingSong; diff --git a/dist/messageTypes.d.ts b/dist/messageTypes.d.ts index 70bf84d..903fc97 100644 --- a/dist/messageTypes.d.ts +++ b/dist/messageTypes.d.ts @@ -1,4 +1,4 @@ -import { Song, SearchResult, QueuedSong } from "./dataTypes"; +import { Song, PlayingSong } from "./dataTypes"; export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong; export declare abstract class StuenMessage { type: string; @@ -34,21 +34,21 @@ export declare class SearchSong extends StuenMessage { constructor(query: string); } export declare class SearchSongResult extends StuenMessage { - result: SearchResult[]; - constructor(result: SearchResult[]); + result: Song[]; + constructor(result: Song[]); } export declare class QueueSong extends StuenMessage { - song: SearchResult; - constructor(song: SearchResult); -} -export declare class CurrentQueue extends StuenMessage { - songs: QueuedSong[]; - constructor(songs: QueuedSong[]); -} -export declare class CurrentSong extends StuenMessage { song: Song; constructor(song: Song); } +export declare class CurrentQueue extends StuenMessage { + songs: Song[]; + constructor(songs: Song[]); +} +export declare class CurrentSong extends StuenMessage { + song: PlayingSong; + constructor(song: PlayingSong); +} export declare class UnqueueSong extends StuenMessage { position: number | null; all: boolean | undefined; diff --git a/messageTypes.ts b/messageTypes.ts index e2b1b02..8d2621f 100644 --- a/messageTypes.ts +++ b/messageTypes.ts @@ -1,4 +1,4 @@ -import {Song, SearchResult, QueuedSong} from "./dataTypes"; +import {Song, PlayingSong} from "./dataTypes"; export type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong; export abstract class StuenMessage { @@ -50,25 +50,25 @@ export class SearchSong extends StuenMessage { export class SearchSongResult extends StuenMessage { - constructor(public result: SearchResult[]) { + constructor(public result: Song[]) { super('SearchSongResult'); } } export class QueueSong extends StuenMessage { - constructor(public song: SearchResult) { + constructor(public song: Song) { super('QueueSong'); } } export class CurrentQueue extends StuenMessage { - constructor(public songs: QueuedSong[]) { + constructor(public songs: Song[]) { super('CurrentQueue'); } } export class CurrentSong extends StuenMessage { - constructor(public song: Song) { + constructor(public song: PlayingSong) { super('CurrentSong'); } }