Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
807cd568e1 | ||
|
|
04253f753a | ||
|
|
829e9c599b | ||
|
|
9345dd1fd0 | ||
|
|
9ce896cd33 | ||
|
|
29d8ee56f6 |
11
dataTypes.ts
11
dataTypes.ts
@@ -21,3 +21,14 @@ export class PlayingSong extends QueuedSong {
|
||||
super(type, title, songId, image, listener);
|
||||
}
|
||||
}
|
||||
|
||||
export class Playlist {
|
||||
constructor(public title: string, public listener: string, public songs: Song[]) {
|
||||
}
|
||||
}
|
||||
export class PlaylistDescription {
|
||||
constructor(public title: string, public listener: string) {
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
}
|
||||
}
|
||||
|
||||
11
dist/dataTypes.d.ts
vendored
11
dist/dataTypes.d.ts
vendored
@@ -18,3 +18,14 @@ export declare class PlayingSong extends QueuedSong {
|
||||
position: number;
|
||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, length: number, position: number);
|
||||
}
|
||||
export declare class Playlist {
|
||||
title: string;
|
||||
listener: string;
|
||||
songs: Song[];
|
||||
constructor(title: string, listener: string, songs: Song[]);
|
||||
}
|
||||
export declare class PlaylistDescription {
|
||||
title: string;
|
||||
listener: string;
|
||||
constructor(title: string, listener: string);
|
||||
}
|
||||
|
||||
21
dist/dataTypes.js
vendored
21
dist/dataTypes.js
vendored
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.PlayingSong = exports.QueuedSong = exports.Song = exports.SongType = void 0;
|
||||
exports.PlaylistDescription = exports.Playlist = exports.PlayingSong = exports.QueuedSong = exports.Song = exports.SongType = void 0;
|
||||
var SongType;
|
||||
(function (SongType) {
|
||||
SongType[SongType["YouTube"] = 0] = "YouTube";
|
||||
@@ -52,3 +52,22 @@ var PlayingSong = /** @class */ (function (_super) {
|
||||
return PlayingSong;
|
||||
}(QueuedSong));
|
||||
exports.PlayingSong = PlayingSong;
|
||||
var Playlist = /** @class */ (function () {
|
||||
function Playlist(title, listener, songs) {
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
this.songs = songs;
|
||||
}
|
||||
return Playlist;
|
||||
}());
|
||||
exports.Playlist = Playlist;
|
||||
var PlaylistDescription = /** @class */ (function () {
|
||||
function PlaylistDescription(title, listener) {
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
}
|
||||
return PlaylistDescription;
|
||||
}());
|
||||
exports.PlaylistDescription = PlaylistDescription;
|
||||
|
||||
30
dist/messageTypes.d.ts
vendored
30
dist/messageTypes.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { Song, PlayingSong, QueuedSong } from "./dataTypes";
|
||||
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong | SkipSong | SongLikes | ToggleSongLike;
|
||||
import { Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription } from "./dataTypes";
|
||||
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong | SkipSong | SongLikes | ToggleSongLike | CreatePlaylist | AddSongToPlaylist | RemoveSongFromPlaylist | Playlists | GetPlaylist | PlaylistSongs;
|
||||
export declare abstract class StuenMessage {
|
||||
type: string;
|
||||
constructor(type: string);
|
||||
@@ -69,3 +69,29 @@ export declare class SongLikes extends StuenMessage {
|
||||
listeners: string[];
|
||||
constructor(listeners: string[]);
|
||||
}
|
||||
export declare class CreatePlaylist extends StuenMessage {
|
||||
title: string;
|
||||
constructor(title: string);
|
||||
}
|
||||
export declare class Playlists extends StuenMessage {
|
||||
playlists: PlaylistDescription[];
|
||||
constructor(playlists: PlaylistDescription[]);
|
||||
}
|
||||
export declare class GetPlaylist extends StuenMessage {
|
||||
playlist: PlaylistDescription;
|
||||
constructor(playlist: PlaylistDescription);
|
||||
}
|
||||
export declare class PlaylistSongs extends StuenMessage {
|
||||
playlist: Playlist;
|
||||
constructor(playlist: Playlist);
|
||||
}
|
||||
export declare class AddSongToPlaylist extends StuenMessage {
|
||||
song: Song;
|
||||
playlist: string;
|
||||
constructor(song: Song, playlist: string);
|
||||
}
|
||||
export declare class RemoveSongFromPlaylist extends StuenMessage {
|
||||
song: Song;
|
||||
playlist: string;
|
||||
constructor(song: Song, playlist: string);
|
||||
}
|
||||
|
||||
64
dist/messageTypes.js
vendored
64
dist/messageTypes.js
vendored
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.SongLikes = exports.ToggleSongLike = exports.SkipSong = exports.ReorderSong = exports.UnqueueSong = exports.CurrentSong = exports.CurrentQueue = exports.QueueSong = exports.SearchSongResult = exports.SearchSong = exports.ChatMessage = exports.SendChatMessage = exports.ListenerList = exports.ListenerLeft = exports.ListenerJoined = exports.Join = exports.StuenMessage = void 0;
|
||||
exports.RemoveSongFromPlaylist = exports.AddSongToPlaylist = exports.PlaylistSongs = exports.GetPlaylist = exports.Playlists = exports.CreatePlaylist = exports.SongLikes = exports.ToggleSongLike = exports.SkipSong = exports.ReorderSong = exports.UnqueueSong = exports.CurrentSong = exports.CurrentQueue = exports.QueueSong = exports.SearchSongResult = exports.SearchSong = exports.ChatMessage = exports.SendChatMessage = exports.ListenerList = exports.ListenerLeft = exports.ListenerJoined = exports.Join = exports.StuenMessage = void 0;
|
||||
var StuenMessage = /** @class */ (function () {
|
||||
function StuenMessage(type) {
|
||||
this.type = type;
|
||||
@@ -183,3 +183,65 @@ var SongLikes = /** @class */ (function (_super) {
|
||||
return SongLikes;
|
||||
}(StuenMessage));
|
||||
exports.SongLikes = SongLikes;
|
||||
var CreatePlaylist = /** @class */ (function (_super) {
|
||||
__extends(CreatePlaylist, _super);
|
||||
function CreatePlaylist(title) {
|
||||
var _this = _super.call(this, 'CreatePlaylist') || this;
|
||||
_this.title = title;
|
||||
return _this;
|
||||
}
|
||||
return CreatePlaylist;
|
||||
}(StuenMessage));
|
||||
exports.CreatePlaylist = CreatePlaylist;
|
||||
var Playlists = /** @class */ (function (_super) {
|
||||
__extends(Playlists, _super);
|
||||
function Playlists(playlists) {
|
||||
var _this = _super.call(this, 'Playlists') || this;
|
||||
_this.playlists = playlists;
|
||||
return _this;
|
||||
}
|
||||
return Playlists;
|
||||
}(StuenMessage));
|
||||
exports.Playlists = Playlists;
|
||||
var GetPlaylist = /** @class */ (function (_super) {
|
||||
__extends(GetPlaylist, _super);
|
||||
function GetPlaylist(playlist) {
|
||||
var _this = _super.call(this, 'GetPlaylist') || this;
|
||||
_this.playlist = playlist;
|
||||
return _this;
|
||||
}
|
||||
return GetPlaylist;
|
||||
}(StuenMessage));
|
||||
exports.GetPlaylist = GetPlaylist;
|
||||
var PlaylistSongs = /** @class */ (function (_super) {
|
||||
__extends(PlaylistSongs, _super);
|
||||
function PlaylistSongs(playlist) {
|
||||
var _this = _super.call(this, 'PlaylistSongs') || this;
|
||||
_this.playlist = playlist;
|
||||
return _this;
|
||||
}
|
||||
return PlaylistSongs;
|
||||
}(StuenMessage));
|
||||
exports.PlaylistSongs = PlaylistSongs;
|
||||
var AddSongToPlaylist = /** @class */ (function (_super) {
|
||||
__extends(AddSongToPlaylist, _super);
|
||||
function AddSongToPlaylist(song, playlist) {
|
||||
var _this = _super.call(this, 'AddSongToPlaylist') || this;
|
||||
_this.song = song;
|
||||
_this.playlist = playlist;
|
||||
return _this;
|
||||
}
|
||||
return AddSongToPlaylist;
|
||||
}(StuenMessage));
|
||||
exports.AddSongToPlaylist = AddSongToPlaylist;
|
||||
var RemoveSongFromPlaylist = /** @class */ (function (_super) {
|
||||
__extends(RemoveSongFromPlaylist, _super);
|
||||
function RemoveSongFromPlaylist(song, playlist) {
|
||||
var _this = _super.call(this, 'RemoveSongFromPlaylist') || this;
|
||||
_this.song = song;
|
||||
_this.playlist = playlist;
|
||||
return _this;
|
||||
}
|
||||
return RemoveSongFromPlaylist;
|
||||
}(StuenMessage));
|
||||
exports.RemoveSongFromPlaylist = RemoveSongFromPlaylist;
|
||||
|
||||
12
dist/parseMessage.js
vendored
12
dist/parseMessage.js
vendored
@@ -37,6 +37,18 @@ function parseMessage(message) {
|
||||
return new messageTypes_1.ToggleSongLike();
|
||||
case 'SongLikes':
|
||||
return new messageTypes_1.SongLikes(data.listeners);
|
||||
case 'Playlists':
|
||||
return new messageTypes_1.Playlists(data.playlists);
|
||||
case 'GetPlaylist':
|
||||
return new messageTypes_1.GetPlaylist(data.playlist);
|
||||
case 'PlaylistSongs':
|
||||
return new messageTypes_1.PlaylistSongs(data.playlist);
|
||||
case 'CreatePlaylist':
|
||||
return new messageTypes_1.CreatePlaylist(data.title);
|
||||
case 'AddSongToPlaylist':
|
||||
return new messageTypes_1.AddSongToPlaylist(data.song, data.playlist);
|
||||
case 'RemoveSongFromPlaylist':
|
||||
return new messageTypes_1.RemoveSongFromPlaylist(data.song, data.playlist);
|
||||
default:
|
||||
console.error('Unknown message type:', data.type);
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Song, PlayingSong, QueuedSong} from "./dataTypes";
|
||||
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
|
||||
|
||||
export type StuenMessages =
|
||||
ListenerLeft
|
||||
@@ -15,7 +15,13 @@ export type StuenMessages =
|
||||
| ReorderSong
|
||||
| SkipSong
|
||||
| SongLikes
|
||||
| ToggleSongLike;
|
||||
| ToggleSongLike
|
||||
| CreatePlaylist
|
||||
| AddSongToPlaylist
|
||||
| RemoveSongFromPlaylist
|
||||
| Playlists
|
||||
| GetPlaylist
|
||||
| PlaylistSongs
|
||||
|
||||
export abstract class StuenMessage {
|
||||
constructor(public type: string) {
|
||||
@@ -120,3 +126,38 @@ export class SongLikes extends StuenMessage {
|
||||
super('SongLikes');
|
||||
}
|
||||
}
|
||||
|
||||
export class CreatePlaylist extends StuenMessage {
|
||||
constructor(public title: string) {
|
||||
super('CreatePlaylist');
|
||||
}
|
||||
}
|
||||
|
||||
export class Playlists extends StuenMessage {
|
||||
constructor(public playlists: PlaylistDescription[]) {
|
||||
super('Playlists');
|
||||
}
|
||||
}
|
||||
|
||||
export class GetPlaylist extends StuenMessage {
|
||||
constructor(public playlist: PlaylistDescription) {
|
||||
super('GetPlaylist');
|
||||
}
|
||||
}
|
||||
export class PlaylistSongs extends StuenMessage {
|
||||
constructor(public playlist: Playlist) {
|
||||
super('PlaylistSongs');
|
||||
}
|
||||
}
|
||||
|
||||
export class AddSongToPlaylist extends StuenMessage {
|
||||
constructor(public song: Song, public playlist: string) {
|
||||
super('AddSongToPlaylist');
|
||||
}
|
||||
}
|
||||
|
||||
export class RemoveSongFromPlaylist extends StuenMessage {
|
||||
constructor(public song: Song, public playlist: string) {
|
||||
super('RemoveSongFromPlaylist');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stuen-common",
|
||||
"version": "1.1.4",
|
||||
"version": "1.2.3",
|
||||
"main": "dist/common.js",
|
||||
"type": "commonjs",
|
||||
"types": "dist/common.d.ts",
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
import {
|
||||
ChatMessage, CurrentQueue, CurrentSong,
|
||||
AddSongToPlaylist,
|
||||
ChatMessage,
|
||||
CreatePlaylist,
|
||||
CurrentQueue,
|
||||
CurrentSong,
|
||||
GetPlaylist,
|
||||
Join,
|
||||
ListenerJoined,
|
||||
ListenerLeft,
|
||||
ListenerList, QueueSong, ReorderSong, SearchSong, SearchSongResult,
|
||||
SendChatMessage, SkipSong, SongLikes,
|
||||
StuenMessage, ToggleSongLike, UnqueueSong
|
||||
ListenerList,
|
||||
Playlists,
|
||||
PlaylistSongs,
|
||||
QueueSong,
|
||||
RemoveSongFromPlaylist,
|
||||
ReorderSong,
|
||||
SearchSong,
|
||||
SearchSongResult,
|
||||
SendChatMessage,
|
||||
SkipSong,
|
||||
SongLikes,
|
||||
StuenMessage,
|
||||
ToggleSongLike,
|
||||
UnqueueSong
|
||||
} from "./messageTypes";
|
||||
|
||||
export default function parseMessage(message: string): StuenMessage | null {
|
||||
@@ -45,6 +61,18 @@ export default function parseMessage(message: string): StuenMessage | null {
|
||||
return new ToggleSongLike();
|
||||
case 'SongLikes':
|
||||
return new SongLikes(data.listeners);
|
||||
case 'Playlists':
|
||||
return new Playlists(data.playlists);
|
||||
case 'GetPlaylist':
|
||||
return new GetPlaylist(data.playlist);
|
||||
case 'PlaylistSongs':
|
||||
return new PlaylistSongs(data.playlist);
|
||||
case 'CreatePlaylist':
|
||||
return new CreatePlaylist(data.title);
|
||||
case 'AddSongToPlaylist':
|
||||
return new AddSongToPlaylist(data.song, data.playlist);
|
||||
case 'RemoveSongFromPlaylist':
|
||||
return new RemoveSongFromPlaylist(data.song, data.playlist);
|
||||
default:
|
||||
console.error('Unknown message type:', data.type);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user