Compare commits
No commits in common. "master" and "1.2.9" have entirely different histories.
15
dataTypes.ts
15
dataTypes.ts
@ -5,29 +5,28 @@ export enum SongType {
|
|||||||
|
|
||||||
|
|
||||||
export class Song {
|
export class Song {
|
||||||
constructor(public type: SongType, public title: string, public songId: string, public image: string, public inAutoPlay: boolean) {
|
constructor(public type: SongType, public title: string, public songId: string, public image: string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class QueuedSong extends Song {
|
export class QueuedSong extends Song {
|
||||||
constructor(type: SongType, title: string, songId: string, image: string, public listener: string, public inAutoPlay: boolean) {
|
constructor(type: SongType, title: string, songId: string, image: string, public listener: string) {
|
||||||
super(type, title, songId, image, inAutoPlay);
|
super(type, title, songId, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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, public tags: string[], public inAutoPlay: boolean) {
|
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, inAutoPlay);
|
super(type, title, songId, image, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Playlist {
|
export class Playlist {
|
||||||
constructor(public title: string, public listener: string, public type: SongType, public songs: Song[]) {
|
constructor(public title: string, public listener: string, public songs: Song[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PlaylistDescription {
|
export class PlaylistDescription {
|
||||||
constructor(public title: string, public listener: string, public type: SongType) {
|
constructor(public title: string, public listener: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
dist/common.js
vendored
2
dist/common.js
vendored
@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|||||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
exports.__esModule = true;
|
||||||
__exportStar(require("./dataTypes"), exports);
|
__exportStar(require("./dataTypes"), exports);
|
||||||
__exportStar(require("./messageTypes"), exports);
|
__exportStar(require("./messageTypes"), exports);
|
||||||
__exportStar(require("./parseMessage"), exports);
|
__exportStar(require("./parseMessage"), exports);
|
||||||
|
|||||||
15
dist/dataTypes.d.ts
vendored
15
dist/dataTypes.d.ts
vendored
@ -7,31 +7,26 @@ export declare class Song {
|
|||||||
title: string;
|
title: string;
|
||||||
songId: string;
|
songId: string;
|
||||||
image: string;
|
image: string;
|
||||||
inAutoPlay: boolean;
|
constructor(type: SongType, title: string, songId: string, image: string);
|
||||||
constructor(type: SongType, title: string, songId: string, image: string, inAutoPlay: boolean);
|
|
||||||
}
|
}
|
||||||
export declare class QueuedSong extends Song {
|
export declare class QueuedSong extends Song {
|
||||||
listener: string;
|
listener: string;
|
||||||
inAutoPlay: boolean;
|
constructor(type: SongType, title: string, songId: string, image: string, listener: string);
|
||||||
constructor(type: SongType, title: string, songId: string, image: string, listener: string, inAutoPlay: boolean);
|
|
||||||
}
|
}
|
||||||
export declare class PlayingSong extends QueuedSong {
|
export declare class PlayingSong extends QueuedSong {
|
||||||
length: number;
|
length: number;
|
||||||
position: number;
|
position: number;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
inAutoPlay: boolean;
|
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[], inAutoPlay: boolean);
|
|
||||||
}
|
}
|
||||||
export declare class Playlist {
|
export declare class Playlist {
|
||||||
title: string;
|
title: string;
|
||||||
listener: string;
|
listener: string;
|
||||||
type: SongType;
|
|
||||||
songs: Song[];
|
songs: Song[];
|
||||||
constructor(title: string, listener: string, type: SongType, songs: Song[]);
|
constructor(title: string, listener: string, songs: Song[]);
|
||||||
}
|
}
|
||||||
export declare class PlaylistDescription {
|
export declare class PlaylistDescription {
|
||||||
title: string;
|
title: string;
|
||||||
listener: string;
|
listener: string;
|
||||||
type: SongType;
|
constructor(title: string, listener: string);
|
||||||
constructor(title: string, listener: string, type: SongType);
|
|
||||||
}
|
}
|
||||||
|
|||||||
23
dist/dataTypes.js
vendored
23
dist/dataTypes.js
vendored
@ -14,30 +14,28 @@ var __extends = (this && this.__extends) || (function () {
|
|||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
exports.__esModule = true;
|
||||||
exports.PlaylistDescription = 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";
|
||||||
SongType[SongType["Spotify"] = 1] = "Spotify";
|
SongType[SongType["Spotify"] = 1] = "Spotify";
|
||||||
})(SongType || (exports.SongType = SongType = {}));
|
})(SongType = exports.SongType || (exports.SongType = {}));
|
||||||
var Song = /** @class */ (function () {
|
var Song = /** @class */ (function () {
|
||||||
function Song(type, title, songId, image, inAutoPlay) {
|
function Song(type, title, songId, image) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.songId = songId;
|
this.songId = songId;
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.inAutoPlay = inAutoPlay;
|
|
||||||
}
|
}
|
||||||
return Song;
|
return Song;
|
||||||
}());
|
}());
|
||||||
exports.Song = Song;
|
exports.Song = Song;
|
||||||
var QueuedSong = /** @class */ (function (_super) {
|
var QueuedSong = /** @class */ (function (_super) {
|
||||||
__extends(QueuedSong, _super);
|
__extends(QueuedSong, _super);
|
||||||
function QueuedSong(type, title, songId, image, listener, inAutoPlay) {
|
function QueuedSong(type, title, songId, image, listener) {
|
||||||
var _this = _super.call(this, type, title, songId, image, inAutoPlay) || this;
|
var _this = _super.call(this, type, title, songId, image) || this;
|
||||||
_this.listener = listener;
|
_this.listener = listener;
|
||||||
_this.inAutoPlay = inAutoPlay;
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
return QueuedSong;
|
return QueuedSong;
|
||||||
@ -45,32 +43,29 @@ 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, tags, inAutoPlay) {
|
function PlayingSong(type, title, songId, image, listener, length, position, tags) {
|
||||||
var _this = _super.call(this, type, title, songId, image, listener, inAutoPlay) || 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;
|
_this.tags = tags;
|
||||||
_this.inAutoPlay = inAutoPlay;
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
return PlayingSong;
|
return PlayingSong;
|
||||||
}(QueuedSong));
|
}(QueuedSong));
|
||||||
exports.PlayingSong = PlayingSong;
|
exports.PlayingSong = PlayingSong;
|
||||||
var Playlist = /** @class */ (function () {
|
var Playlist = /** @class */ (function () {
|
||||||
function Playlist(title, listener, type, songs) {
|
function Playlist(title, listener, songs) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.type = type;
|
|
||||||
this.songs = songs;
|
this.songs = songs;
|
||||||
}
|
}
|
||||||
return Playlist;
|
return Playlist;
|
||||||
}());
|
}());
|
||||||
exports.Playlist = Playlist;
|
exports.Playlist = Playlist;
|
||||||
var PlaylistDescription = /** @class */ (function () {
|
var PlaylistDescription = /** @class */ (function () {
|
||||||
function PlaylistDescription(title, listener, type) {
|
function PlaylistDescription(title, listener) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
return PlaylistDescription;
|
return PlaylistDescription;
|
||||||
}());
|
}());
|
||||||
|
|||||||
20
dist/messageTypes.d.ts
vendored
20
dist/messageTypes.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
import { Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription } from "./dataTypes";
|
import { Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription } from "./dataTypes";
|
||||||
export type StuenMessages = ListenerList | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong | SkipSong | SongLikes | ToggleSongLike | CreatePlaylist | RemovePlaylist | AddSongToPlaylist | RemoveSongFromPlaylist | Playlists | GetPlaylist | PlaylistSongs | GetOtherPlaylists | ToggleTag | Shuffle | RemoveFromAutoPlay;
|
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong | SkipSong | SongLikes | ToggleSongLike | CreatePlaylist | RemovePlaylist | AddSongToPlaylist | RemoveSongFromPlaylist | Playlists | GetPlaylist | PlaylistSongs | ToggleTag | Shuffle;
|
||||||
export declare abstract class StuenMessage {
|
export declare abstract class StuenMessage {
|
||||||
type: string;
|
type: string;
|
||||||
constructor(type: string);
|
constructor(type: string);
|
||||||
@ -8,6 +8,14 @@ export declare class Join extends StuenMessage {
|
|||||||
name: string;
|
name: string;
|
||||||
constructor(name: string);
|
constructor(name: string);
|
||||||
}
|
}
|
||||||
|
export declare class ListenerJoined extends StuenMessage {
|
||||||
|
name: string;
|
||||||
|
constructor(name: string);
|
||||||
|
}
|
||||||
|
export declare class ListenerLeft extends StuenMessage {
|
||||||
|
name: string;
|
||||||
|
constructor(name: string);
|
||||||
|
}
|
||||||
export declare class ListenerList extends StuenMessage {
|
export declare class ListenerList extends StuenMessage {
|
||||||
names: string[];
|
names: string[];
|
||||||
constructor(names: string[]);
|
constructor(names: string[]);
|
||||||
@ -81,13 +89,6 @@ export declare class PlaylistSongs extends StuenMessage {
|
|||||||
playlist: Playlist;
|
playlist: Playlist;
|
||||||
constructor(playlist: Playlist);
|
constructor(playlist: Playlist);
|
||||||
}
|
}
|
||||||
export declare class GetOtherPlaylists extends StuenMessage {
|
|
||||||
constructor();
|
|
||||||
}
|
|
||||||
export declare class OthersPlaylists extends StuenMessage {
|
|
||||||
playlists: PlaylistDescription[];
|
|
||||||
constructor(playlists: PlaylistDescription[]);
|
|
||||||
}
|
|
||||||
export declare class AddSongToPlaylist extends StuenMessage {
|
export declare class AddSongToPlaylist extends StuenMessage {
|
||||||
song: Song;
|
song: Song;
|
||||||
playlist: string;
|
playlist: string;
|
||||||
@ -106,6 +107,3 @@ export declare class ToggleTag extends StuenMessage {
|
|||||||
export declare class Shuffle extends StuenMessage {
|
export declare class Shuffle extends StuenMessage {
|
||||||
constructor();
|
constructor();
|
||||||
}
|
}
|
||||||
export declare class RemoveFromAutoPlay extends StuenMessage {
|
|
||||||
constructor();
|
|
||||||
}
|
|
||||||
|
|||||||
50
dist/messageTypes.js
vendored
50
dist/messageTypes.js
vendored
@ -14,8 +14,8 @@ var __extends = (this && this.__extends) || (function () {
|
|||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
exports.__esModule = true;
|
||||||
exports.RemoveFromAutoPlay = exports.Shuffle = exports.ToggleTag = exports.RemoveSongFromPlaylist = exports.AddSongToPlaylist = exports.OthersPlaylists = exports.GetOtherPlaylists = exports.PlaylistSongs = exports.GetPlaylist = exports.Playlists = exports.RemovePlaylist = 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.Join = exports.StuenMessage = void 0;
|
exports.Shuffle = exports.ToggleTag = exports.RemoveSongFromPlaylist = exports.AddSongToPlaylist = exports.PlaylistSongs = exports.GetPlaylist = exports.Playlists = exports.RemovePlaylist = 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;
|
||||||
@ -33,6 +33,26 @@ var Join = /** @class */ (function (_super) {
|
|||||||
return Join;
|
return Join;
|
||||||
}(StuenMessage));
|
}(StuenMessage));
|
||||||
exports.Join = Join;
|
exports.Join = Join;
|
||||||
|
var ListenerJoined = /** @class */ (function (_super) {
|
||||||
|
__extends(ListenerJoined, _super);
|
||||||
|
function ListenerJoined(name) {
|
||||||
|
var _this = _super.call(this, 'ListenerJoined') || this;
|
||||||
|
_this.name = name;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
return ListenerJoined;
|
||||||
|
}(StuenMessage));
|
||||||
|
exports.ListenerJoined = ListenerJoined;
|
||||||
|
var ListenerLeft = /** @class */ (function (_super) {
|
||||||
|
__extends(ListenerLeft, _super);
|
||||||
|
function ListenerLeft(name) {
|
||||||
|
var _this = _super.call(this, 'ListenerLeft') || this;
|
||||||
|
_this.name = name;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
return ListenerLeft;
|
||||||
|
}(StuenMessage));
|
||||||
|
exports.ListenerLeft = ListenerLeft;
|
||||||
var ListenerList = /** @class */ (function (_super) {
|
var ListenerList = /** @class */ (function (_super) {
|
||||||
__extends(ListenerList, _super);
|
__extends(ListenerList, _super);
|
||||||
function ListenerList(names) {
|
function ListenerList(names) {
|
||||||
@ -213,24 +233,6 @@ var PlaylistSongs = /** @class */ (function (_super) {
|
|||||||
return PlaylistSongs;
|
return PlaylistSongs;
|
||||||
}(StuenMessage));
|
}(StuenMessage));
|
||||||
exports.PlaylistSongs = PlaylistSongs;
|
exports.PlaylistSongs = PlaylistSongs;
|
||||||
var GetOtherPlaylists = /** @class */ (function (_super) {
|
|
||||||
__extends(GetOtherPlaylists, _super);
|
|
||||||
function GetOtherPlaylists() {
|
|
||||||
return _super.call(this, 'GetOtherPlaylists') || this;
|
|
||||||
}
|
|
||||||
return GetOtherPlaylists;
|
|
||||||
}(StuenMessage));
|
|
||||||
exports.GetOtherPlaylists = GetOtherPlaylists;
|
|
||||||
var OthersPlaylists = /** @class */ (function (_super) {
|
|
||||||
__extends(OthersPlaylists, _super);
|
|
||||||
function OthersPlaylists(playlists) {
|
|
||||||
var _this = _super.call(this, 'OthersPlaylists') || this;
|
|
||||||
_this.playlists = playlists;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
return OthersPlaylists;
|
|
||||||
}(StuenMessage));
|
|
||||||
exports.OthersPlaylists = OthersPlaylists;
|
|
||||||
var AddSongToPlaylist = /** @class */ (function (_super) {
|
var AddSongToPlaylist = /** @class */ (function (_super) {
|
||||||
__extends(AddSongToPlaylist, _super);
|
__extends(AddSongToPlaylist, _super);
|
||||||
function AddSongToPlaylist(song, playlist) {
|
function AddSongToPlaylist(song, playlist) {
|
||||||
@ -272,11 +274,3 @@ var Shuffle = /** @class */ (function (_super) {
|
|||||||
return Shuffle;
|
return Shuffle;
|
||||||
}(StuenMessage));
|
}(StuenMessage));
|
||||||
exports.Shuffle = Shuffle;
|
exports.Shuffle = Shuffle;
|
||||||
var RemoveFromAutoPlay = /** @class */ (function (_super) {
|
|
||||||
__extends(RemoveFromAutoPlay, _super);
|
|
||||||
function RemoveFromAutoPlay() {
|
|
||||||
return _super.call(this, 'RemoveFromAutoPlay') || this;
|
|
||||||
}
|
|
||||||
return RemoveFromAutoPlay;
|
|
||||||
}(StuenMessage));
|
|
||||||
exports.RemoveFromAutoPlay = RemoveFromAutoPlay;
|
|
||||||
|
|||||||
14
dist/parseMessage.js
vendored
14
dist/parseMessage.js
vendored
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
exports.__esModule = true;
|
||||||
var messageTypes_1 = require("./messageTypes");
|
var messageTypes_1 = require("./messageTypes");
|
||||||
function parseMessage(message) {
|
function parseMessage(message) {
|
||||||
try {
|
try {
|
||||||
@ -7,6 +7,10 @@ function parseMessage(message) {
|
|||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'Join':
|
case 'Join':
|
||||||
return new messageTypes_1.Join(data.name);
|
return new messageTypes_1.Join(data.name);
|
||||||
|
case 'ListenerJoined':
|
||||||
|
return new messageTypes_1.ListenerJoined(data.name);
|
||||||
|
case 'ListenerLeft':
|
||||||
|
return new messageTypes_1.ListenerLeft(data.name);
|
||||||
case 'ListenerList':
|
case 'ListenerList':
|
||||||
return new messageTypes_1.ListenerList(data.names);
|
return new messageTypes_1.ListenerList(data.names);
|
||||||
case 'SendChatMessage':
|
case 'SendChatMessage':
|
||||||
@ -47,16 +51,10 @@ function parseMessage(message) {
|
|||||||
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 'GetOtherPlaylists':
|
|
||||||
return new messageTypes_1.GetOtherPlaylists();
|
|
||||||
case 'OthersPlaylists':
|
|
||||||
return new messageTypes_1.OthersPlaylists(data.playlists);
|
|
||||||
case 'ToggleTag':
|
case 'ToggleTag':
|
||||||
return new messageTypes_1.ToggleTag(data.song, data.tag);
|
return new messageTypes_1.ToggleTag(data.song, data.tag);
|
||||||
case 'Shuffle':
|
case 'Shuffle':
|
||||||
return new messageTypes_1.Shuffle();
|
return new messageTypes_1.Shuffle();
|
||||||
case 'RemoveFromAutoPlay':
|
|
||||||
return new messageTypes_1.RemoveFromAutoPlay();
|
|
||||||
default:
|
default:
|
||||||
console.error('Unknown message type:', data.type);
|
console.error('Unknown message type:', data.type);
|
||||||
return null;
|
return null;
|
||||||
@ -67,4 +65,4 @@ function parseMessage(message) {
|
|||||||
return null; // Handle parsing errors
|
return null; // Handle parsing errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.default = parseMessage;
|
exports["default"] = parseMessage;
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
|
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
|
||||||
|
|
||||||
export type StuenMessages =
|
export type StuenMessages =
|
||||||
ListenerList
|
ListenerLeft
|
||||||
|
| ListenerList
|
||||||
|
| ListenerJoined
|
||||||
| SendChatMessage
|
| SendChatMessage
|
||||||
| SearchSong
|
| SearchSong
|
||||||
| SearchSongResult
|
| SearchSongResult
|
||||||
@ -21,10 +23,8 @@ export type StuenMessages =
|
|||||||
| Playlists
|
| Playlists
|
||||||
| GetPlaylist
|
| GetPlaylist
|
||||||
| PlaylistSongs
|
| PlaylistSongs
|
||||||
| GetOtherPlaylists
|
|
||||||
| ToggleTag
|
| ToggleTag
|
||||||
| Shuffle
|
| Shuffle
|
||||||
| RemoveFromAutoPlay
|
|
||||||
|
|
||||||
export abstract class StuenMessage {
|
export abstract class StuenMessage {
|
||||||
constructor(public type: string) {
|
constructor(public type: string) {
|
||||||
@ -37,6 +37,18 @@ export class Join extends StuenMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ListenerJoined extends StuenMessage {
|
||||||
|
constructor(public name: string) {
|
||||||
|
super('ListenerJoined');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ListenerLeft extends StuenMessage {
|
||||||
|
constructor(public name: string) {
|
||||||
|
super('ListenerLeft');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ListenerList extends StuenMessage {
|
export class ListenerList extends StuenMessage {
|
||||||
constructor(public names: string[]) {
|
constructor(public names: string[]) {
|
||||||
super('ListenerList');
|
super('ListenerList');
|
||||||
@ -140,24 +152,12 @@ export class GetPlaylist extends StuenMessage {
|
|||||||
super('GetPlaylist');
|
super('GetPlaylist');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PlaylistSongs extends StuenMessage {
|
export class PlaylistSongs extends StuenMessage {
|
||||||
constructor(public playlist: Playlist) {
|
constructor(public playlist: Playlist) {
|
||||||
super('PlaylistSongs');
|
super('PlaylistSongs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GetOtherPlaylists extends StuenMessage {
|
|
||||||
constructor() {
|
|
||||||
super('GetOtherPlaylists');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class OthersPlaylists extends StuenMessage {
|
|
||||||
constructor(public playlists: PlaylistDescription[]) {
|
|
||||||
super('OthersPlaylists');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export class AddSongToPlaylist extends StuenMessage {
|
export class AddSongToPlaylist extends StuenMessage {
|
||||||
constructor(public song: Song, public playlist: string) {
|
constructor(public song: Song, public playlist: string) {
|
||||||
super('AddSongToPlaylist');
|
super('AddSongToPlaylist');
|
||||||
@ -181,9 +181,3 @@ export class Shuffle extends StuenMessage {
|
|||||||
super('Shuffle');
|
super('Shuffle');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoveFromAutoPlay extends StuenMessage {
|
|
||||||
constructor() {
|
|
||||||
super('RemoveFromAutoPlay');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stuen-common",
|
"name": "stuen-common",
|
||||||
"version": "1.2.17",
|
"version": "1.2.9",
|
||||||
"main": "dist/common.js",
|
"main": "dist/common.js",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"types": "dist/common.d.ts",
|
"types": "dist/common.d.ts",
|
||||||
|
|||||||
@ -6,11 +6,12 @@ import {
|
|||||||
CurrentSong,
|
CurrentSong,
|
||||||
GetPlaylist,
|
GetPlaylist,
|
||||||
Join,
|
Join,
|
||||||
|
ListenerJoined,
|
||||||
|
ListenerLeft,
|
||||||
ListenerList,
|
ListenerList,
|
||||||
Playlists,
|
Playlists,
|
||||||
PlaylistSongs,
|
PlaylistSongs,
|
||||||
GetOtherPlaylists,
|
QueueSong, RemovePlaylist,
|
||||||
QueueSong, RemoveFromAutoPlay, RemovePlaylist,
|
|
||||||
RemoveSongFromPlaylist,
|
RemoveSongFromPlaylist,
|
||||||
ReorderSong,
|
ReorderSong,
|
||||||
SearchSong,
|
SearchSong,
|
||||||
@ -20,7 +21,7 @@ import {
|
|||||||
SongLikes,
|
SongLikes,
|
||||||
StuenMessage,
|
StuenMessage,
|
||||||
ToggleSongLike, ToggleTag,
|
ToggleSongLike, ToggleTag,
|
||||||
UnqueueSong, OthersPlaylists,
|
UnqueueSong
|
||||||
} from "./messageTypes";
|
} from "./messageTypes";
|
||||||
|
|
||||||
export default function parseMessage(message: string): StuenMessage | null {
|
export default function parseMessage(message: string): StuenMessage | null {
|
||||||
@ -30,6 +31,10 @@ export default function parseMessage(message: string): StuenMessage | null {
|
|||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'Join':
|
case 'Join':
|
||||||
return new Join(data.name);
|
return new Join(data.name);
|
||||||
|
case 'ListenerJoined':
|
||||||
|
return new ListenerJoined(data.name);
|
||||||
|
case 'ListenerLeft':
|
||||||
|
return new ListenerLeft(data.name);
|
||||||
case 'ListenerList':
|
case 'ListenerList':
|
||||||
return new ListenerList(data.names);
|
return new ListenerList(data.names);
|
||||||
case 'SendChatMessage':
|
case 'SendChatMessage':
|
||||||
@ -70,16 +75,10 @@ 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 'GetOtherPlaylists':
|
|
||||||
return new GetOtherPlaylists();
|
|
||||||
case 'OthersPlaylists':
|
|
||||||
return new OthersPlaylists(data.playlists);
|
|
||||||
case 'ToggleTag':
|
case 'ToggleTag':
|
||||||
return new ToggleTag(data.song, data.tag);
|
return new ToggleTag(data.song, data.tag);
|
||||||
case 'Shuffle':
|
case 'Shuffle':
|
||||||
return new Shuffle();
|
return new Shuffle();
|
||||||
case 'RemoveFromAutoPlay':
|
|
||||||
return new RemoveFromAutoPlay();
|
|
||||||
default:
|
default:
|
||||||
console.error('Unknown message type:', data.type);
|
console.error('Unknown message type:', data.type);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user