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