Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
993501f049 | ||
|
|
343126bee3 | ||
|
|
588c778122 | ||
|
|
2ec9585c74 | ||
|
|
d5b4cfefc3 | ||
|
|
807cd568e1 | ||
|
|
04253f753a | ||
|
|
829e9c599b |
@@ -17,7 +17,7 @@ export class QueuedSong extends Song {
|
||||
}
|
||||
|
||||
export class PlayingSong extends QueuedSong {
|
||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, public length: number, public position: number) {
|
||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, public length: number, public position: number, public tags: string[]) {
|
||||
super(type, title, songId, image, listener);
|
||||
}
|
||||
}
|
||||
@@ -26,3 +26,7 @@ export class Playlist {
|
||||
constructor(public title: string, public listener: string, public songs: Song[]) {
|
||||
}
|
||||
}
|
||||
export class PlaylistDescription {
|
||||
constructor(public title: string, public listener: string) {
|
||||
}
|
||||
}
|
||||
|
||||
8
dist/dataTypes.d.ts
vendored
8
dist/dataTypes.d.ts
vendored
@@ -16,7 +16,8 @@ export declare class QueuedSong extends Song {
|
||||
export declare class PlayingSong extends QueuedSong {
|
||||
length: number;
|
||||
position: number;
|
||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, length: number, position: number);
|
||||
tags: string[];
|
||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, length: number, position: number, tags: string[]);
|
||||
}
|
||||
export declare class Playlist {
|
||||
title: string;
|
||||
@@ -24,3 +25,8 @@ export declare class Playlist {
|
||||
songs: Song[];
|
||||
constructor(title: string, listener: string, songs: Song[]);
|
||||
}
|
||||
export declare class PlaylistDescription {
|
||||
title: string;
|
||||
listener: string;
|
||||
constructor(title: string, listener: string);
|
||||
}
|
||||
|
||||
13
dist/dataTypes.js
vendored
13
dist/dataTypes.js
vendored
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.Playlist = 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";
|
||||
@@ -43,10 +43,11 @@ var QueuedSong = /** @class */ (function (_super) {
|
||||
exports.QueuedSong = QueuedSong;
|
||||
var PlayingSong = /** @class */ (function (_super) {
|
||||
__extends(PlayingSong, _super);
|
||||
function PlayingSong(type, title, songId, image, listener, length, position) {
|
||||
function PlayingSong(type, title, songId, image, listener, length, position, tags) {
|
||||
var _this = _super.call(this, type, title, songId, image, listener) || this;
|
||||
_this.length = length;
|
||||
_this.position = position;
|
||||
_this.tags = tags;
|
||||
return _this;
|
||||
}
|
||||
return PlayingSong;
|
||||
@@ -61,3 +62,11 @@ var Playlist = /** @class */ (function () {
|
||||
return Playlist;
|
||||
}());
|
||||
exports.Playlist = Playlist;
|
||||
var PlaylistDescription = /** @class */ (function () {
|
||||
function PlaylistDescription(title, listener) {
|
||||
this.title = title;
|
||||
this.listener = listener;
|
||||
}
|
||||
return PlaylistDescription;
|
||||
}());
|
||||
exports.PlaylistDescription = PlaylistDescription;
|
||||
|
||||
21
dist/messageTypes.d.ts
vendored
21
dist/messageTypes.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { Song, PlayingSong, QueuedSong, Playlist } from "./dataTypes";
|
||||
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong | SkipSong | SongLikes | CreatePlaylist | ToggleSongLike | AddSongToPlaylist | RemoveSongFromPlaylist | Playlists;
|
||||
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 | ToggleTag;
|
||||
export declare abstract class StuenMessage {
|
||||
type: string;
|
||||
constructor(type: string);
|
||||
@@ -74,8 +74,16 @@ export declare class CreatePlaylist extends StuenMessage {
|
||||
constructor(title: string);
|
||||
}
|
||||
export declare class Playlists extends StuenMessage {
|
||||
playlists: Playlist[];
|
||||
constructor(playlists: Playlist[]);
|
||||
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;
|
||||
@@ -87,3 +95,8 @@ export declare class RemoveSongFromPlaylist extends StuenMessage {
|
||||
playlist: string;
|
||||
constructor(song: Song, playlist: string);
|
||||
}
|
||||
export declare class ToggleTag extends StuenMessage {
|
||||
song: Song;
|
||||
tag: string;
|
||||
constructor(song: Song, tag: string);
|
||||
}
|
||||
|
||||
35
dist/messageTypes.js
vendored
35
dist/messageTypes.js
vendored
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.RemoveSongFromPlaylist = exports.AddSongToPlaylist = 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;
|
||||
exports.ToggleTag = 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;
|
||||
@@ -203,6 +203,26 @@ var Playlists = /** @class */ (function (_super) {
|
||||
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) {
|
||||
@@ -217,7 +237,7 @@ exports.AddSongToPlaylist = AddSongToPlaylist;
|
||||
var RemoveSongFromPlaylist = /** @class */ (function (_super) {
|
||||
__extends(RemoveSongFromPlaylist, _super);
|
||||
function RemoveSongFromPlaylist(song, playlist) {
|
||||
var _this = _super.call(this, 'RemoveSongToPlaylist') || this;
|
||||
var _this = _super.call(this, 'RemoveSongFromPlaylist') || this;
|
||||
_this.song = song;
|
||||
_this.playlist = playlist;
|
||||
return _this;
|
||||
@@ -225,3 +245,14 @@ var RemoveSongFromPlaylist = /** @class */ (function (_super) {
|
||||
return RemoveSongFromPlaylist;
|
||||
}(StuenMessage));
|
||||
exports.RemoveSongFromPlaylist = RemoveSongFromPlaylist;
|
||||
var ToggleTag = /** @class */ (function (_super) {
|
||||
__extends(ToggleTag, _super);
|
||||
function ToggleTag(song, tag) {
|
||||
var _this = _super.call(this, 'ToggleTag') || this;
|
||||
_this.song = song;
|
||||
_this.tag = tag;
|
||||
return _this;
|
||||
}
|
||||
return ToggleTag;
|
||||
}(StuenMessage));
|
||||
exports.ToggleTag = ToggleTag;
|
||||
|
||||
6
dist/parseMessage.js
vendored
6
dist/parseMessage.js
vendored
@@ -39,12 +39,18 @@ function parseMessage(message) {
|
||||
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);
|
||||
case 'ToggleTag':
|
||||
return new messageTypes_1.ToggleTag(data.song, data.tag);
|
||||
default:
|
||||
console.error('Unknown message type:', data.type);
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Song, PlayingSong, QueuedSong, Playlist} from "./dataTypes";
|
||||
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
|
||||
|
||||
export type StuenMessages =
|
||||
ListenerLeft
|
||||
@@ -15,11 +15,14 @@ export type StuenMessages =
|
||||
| ReorderSong
|
||||
| SkipSong
|
||||
| SongLikes
|
||||
| CreatePlaylist
|
||||
| ToggleSongLike
|
||||
| CreatePlaylist
|
||||
| AddSongToPlaylist
|
||||
| RemoveSongFromPlaylist
|
||||
| Playlists;
|
||||
| Playlists
|
||||
| GetPlaylist
|
||||
| PlaylistSongs
|
||||
| ToggleTag
|
||||
|
||||
export abstract class StuenMessage {
|
||||
constructor(public type: string) {
|
||||
@@ -132,11 +135,22 @@ export class CreatePlaylist extends StuenMessage {
|
||||
}
|
||||
|
||||
export class Playlists extends StuenMessage {
|
||||
constructor(public playlists: Playlist[]) {
|
||||
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');
|
||||
@@ -145,6 +159,12 @@ export class AddSongToPlaylist extends StuenMessage {
|
||||
|
||||
export class RemoveSongFromPlaylist extends StuenMessage {
|
||||
constructor(public song: Song, public playlist: string) {
|
||||
super('RemoveSongToPlaylist');
|
||||
super('RemoveSongFromPlaylist');
|
||||
}
|
||||
}
|
||||
|
||||
export class ToggleTag extends StuenMessage {
|
||||
constructor(public song: Song, public tag: string) {
|
||||
super('ToggleTag');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "stuen-common",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.7",
|
||||
"main": "dist/common.js",
|
||||
"type": "commonjs",
|
||||
"types": "dist/common.d.ts",
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
import {
|
||||
AddSongToPlaylist,
|
||||
ChatMessage, CreatePlaylist, CurrentQueue, CurrentSong,
|
||||
ChatMessage,
|
||||
CreatePlaylist,
|
||||
CurrentQueue,
|
||||
CurrentSong,
|
||||
GetPlaylist,
|
||||
Join,
|
||||
ListenerJoined,
|
||||
ListenerLeft,
|
||||
ListenerList, Playlists, QueueSong, RemoveSongFromPlaylist, ReorderSong, SearchSong, SearchSongResult,
|
||||
SendChatMessage, SkipSong, SongLikes,
|
||||
StuenMessage, ToggleSongLike, UnqueueSong
|
||||
ListenerList,
|
||||
Playlists,
|
||||
PlaylistSongs,
|
||||
QueueSong,
|
||||
RemoveSongFromPlaylist,
|
||||
ReorderSong,
|
||||
SearchSong,
|
||||
SearchSongResult,
|
||||
SendChatMessage,
|
||||
SkipSong,
|
||||
SongLikes,
|
||||
StuenMessage,
|
||||
ToggleSongLike, ToggleTag,
|
||||
UnqueueSong
|
||||
} from "./messageTypes";
|
||||
|
||||
export default function parseMessage(message: string): StuenMessage | null {
|
||||
@@ -48,12 +63,18 @@ export default function parseMessage(message: string): StuenMessage | null {
|
||||
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);
|
||||
case 'ToggleTag':
|
||||
return new ToggleTag(data.song, data.tag);
|
||||
default:
|
||||
console.error('Unknown message type:', data.type);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user