Compare commits
5 Commits
1.2.7
...
283d7ea4ec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
283d7ea4ec | ||
|
|
e2475c254e | ||
|
|
d08afcc4d6 | ||
|
|
d47379aacc | ||
|
|
01b8319aef |
10
dataTypes.ts
10
dataTypes.ts
@@ -5,20 +5,20 @@ export enum SongType {
|
|||||||
|
|
||||||
|
|
||||||
export class Song {
|
export class Song {
|
||||||
constructor(public type: SongType, public title: string, public songId: string, public image: string) {
|
constructor(public type: SongType, public title: string, public songId: string, public image: string, public inAutoPlay: boolean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class QueuedSong extends Song {
|
export class QueuedSong extends Song {
|
||||||
constructor(type: SongType, title: string, songId: string, image: string, public listener: string) {
|
constructor(type: SongType, title: string, songId: string, image: string, public listener: string, public inAutoPlay: boolean) {
|
||||||
super(type, title, songId, image);
|
super(type, title, songId, image, inAutoPlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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[]) {
|
constructor(type: SongType, title: string, songId: string, image: string, listener: string, public length: number, public position: number, public tags: string[], public inAutoPlay: boolean) {
|
||||||
super(type, title, songId, image, listener);
|
super(type, title, songId, image, listener, inAutoPlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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);
|
||||||
};
|
};
|
||||||
exports.__esModule = true;
|
Object.defineProperty(exports, "__esModule", { value: 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);
|
||||||
|
|||||||
4
dist/dataTypes.js
vendored
4
dist/dataTypes.js
vendored
@@ -14,13 +14,13 @@ 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 __());
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
exports.__esModule = true;
|
Object.defineProperty(exports, "__esModule", { value: 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 || (exports.SongType = {}));
|
})(SongType || (exports.SongType = SongType = {}));
|
||||||
var Song = /** @class */ (function () {
|
var Song = /** @class */ (function () {
|
||||||
function Song(type, title, songId, image) {
|
function Song(type, title, songId, image) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|||||||
12
dist/messageTypes.d.ts
vendored
12
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 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 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 | RemoveFromAutoPlay;
|
||||||
export declare abstract class StuenMessage {
|
export declare abstract class StuenMessage {
|
||||||
type: string;
|
type: string;
|
||||||
constructor(type: string);
|
constructor(type: string);
|
||||||
@@ -73,6 +73,10 @@ export declare class CreatePlaylist extends StuenMessage {
|
|||||||
title: string;
|
title: string;
|
||||||
constructor(title: string);
|
constructor(title: string);
|
||||||
}
|
}
|
||||||
|
export declare class RemovePlaylist extends StuenMessage {
|
||||||
|
title: string;
|
||||||
|
constructor(title: string);
|
||||||
|
}
|
||||||
export declare class Playlists extends StuenMessage {
|
export declare class Playlists extends StuenMessage {
|
||||||
playlists: PlaylistDescription[];
|
playlists: PlaylistDescription[];
|
||||||
constructor(playlists: PlaylistDescription[]);
|
constructor(playlists: PlaylistDescription[]);
|
||||||
@@ -100,3 +104,9 @@ export declare class ToggleTag extends StuenMessage {
|
|||||||
tag: string;
|
tag: string;
|
||||||
constructor(song: Song, tag: string);
|
constructor(song: Song, tag: string);
|
||||||
}
|
}
|
||||||
|
export declare class Shuffle extends StuenMessage {
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
export declare class RemoveFromAutoPlay extends StuenMessage {
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
|||||||
30
dist/messageTypes.js
vendored
30
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 __());
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
exports.__esModule = true;
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
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;
|
exports.RemoveFromAutoPlay = 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;
|
||||||
@@ -193,6 +193,16 @@ var CreatePlaylist = /** @class */ (function (_super) {
|
|||||||
return CreatePlaylist;
|
return CreatePlaylist;
|
||||||
}(StuenMessage));
|
}(StuenMessage));
|
||||||
exports.CreatePlaylist = CreatePlaylist;
|
exports.CreatePlaylist = CreatePlaylist;
|
||||||
|
var RemovePlaylist = /** @class */ (function (_super) {
|
||||||
|
__extends(RemovePlaylist, _super);
|
||||||
|
function RemovePlaylist(title) {
|
||||||
|
var _this = _super.call(this, 'RemovePlaylist') || this;
|
||||||
|
_this.title = title;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
return RemovePlaylist;
|
||||||
|
}(StuenMessage));
|
||||||
|
exports.RemovePlaylist = RemovePlaylist;
|
||||||
var Playlists = /** @class */ (function (_super) {
|
var Playlists = /** @class */ (function (_super) {
|
||||||
__extends(Playlists, _super);
|
__extends(Playlists, _super);
|
||||||
function Playlists(playlists) {
|
function Playlists(playlists) {
|
||||||
@@ -256,3 +266,19 @@ var ToggleTag = /** @class */ (function (_super) {
|
|||||||
return ToggleTag;
|
return ToggleTag;
|
||||||
}(StuenMessage));
|
}(StuenMessage));
|
||||||
exports.ToggleTag = ToggleTag;
|
exports.ToggleTag = ToggleTag;
|
||||||
|
var Shuffle = /** @class */ (function (_super) {
|
||||||
|
__extends(Shuffle, _super);
|
||||||
|
function Shuffle() {
|
||||||
|
return _super.call(this, 'Shuffle') || this;
|
||||||
|
}
|
||||||
|
return Shuffle;
|
||||||
|
}(StuenMessage));
|
||||||
|
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;
|
||||||
|
|||||||
10
dist/parseMessage.js
vendored
10
dist/parseMessage.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
exports.__esModule = true;
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var messageTypes_1 = require("./messageTypes");
|
var messageTypes_1 = require("./messageTypes");
|
||||||
function parseMessage(message) {
|
function parseMessage(message) {
|
||||||
try {
|
try {
|
||||||
@@ -45,12 +45,18 @@ function parseMessage(message) {
|
|||||||
return new messageTypes_1.PlaylistSongs(data.playlist);
|
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 'RemovePlaylist':
|
||||||
|
return new messageTypes_1.RemovePlaylist(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':
|
case 'ToggleTag':
|
||||||
return new messageTypes_1.ToggleTag(data.song, data.tag);
|
return new messageTypes_1.ToggleTag(data.song, data.tag);
|
||||||
|
case '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;
|
||||||
@@ -61,4 +67,4 @@ function parseMessage(message) {
|
|||||||
return null; // Handle parsing errors
|
return null; // Handle parsing errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = parseMessage;
|
exports.default = parseMessage;
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ export type StuenMessages =
|
|||||||
| SongLikes
|
| SongLikes
|
||||||
| ToggleSongLike
|
| ToggleSongLike
|
||||||
| CreatePlaylist
|
| CreatePlaylist
|
||||||
|
| RemovePlaylist
|
||||||
| AddSongToPlaylist
|
| AddSongToPlaylist
|
||||||
| RemoveSongFromPlaylist
|
| RemoveSongFromPlaylist
|
||||||
| Playlists
|
| Playlists
|
||||||
| GetPlaylist
|
| GetPlaylist
|
||||||
| PlaylistSongs
|
| PlaylistSongs
|
||||||
| ToggleTag
|
| ToggleTag
|
||||||
|
| Shuffle
|
||||||
|
| RemoveFromAutoPlay
|
||||||
|
|
||||||
export abstract class StuenMessage {
|
export abstract class StuenMessage {
|
||||||
constructor(public type: string) {
|
constructor(public type: string) {
|
||||||
@@ -133,6 +136,11 @@ export class CreatePlaylist extends StuenMessage {
|
|||||||
super('CreatePlaylist');
|
super('CreatePlaylist');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class RemovePlaylist extends StuenMessage {
|
||||||
|
constructor(public title: string) {
|
||||||
|
super('RemovePlaylist');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Playlists extends StuenMessage {
|
export class Playlists extends StuenMessage {
|
||||||
constructor(public playlists: PlaylistDescription[]) {
|
constructor(public playlists: PlaylistDescription[]) {
|
||||||
@@ -168,3 +176,15 @@ export class ToggleTag extends StuenMessage {
|
|||||||
super('ToggleTag');
|
super('ToggleTag');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Shuffle extends StuenMessage {
|
||||||
|
constructor() {
|
||||||
|
super('Shuffle');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RemoveFromAutoPlay extends StuenMessage {
|
||||||
|
constructor() {
|
||||||
|
super('RemoveFromAutoPlay');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stuen-common",
|
"name": "stuen-common",
|
||||||
"version": "1.2.7",
|
"version": "1.2.11",
|
||||||
"main": "dist/common.js",
|
"main": "dist/common.js",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"types": "dist/common.d.ts",
|
"types": "dist/common.d.ts",
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import {
|
|||||||
ListenerList,
|
ListenerList,
|
||||||
Playlists,
|
Playlists,
|
||||||
PlaylistSongs,
|
PlaylistSongs,
|
||||||
QueueSong,
|
QueueSong, RemoveFromAutoPlay, RemovePlaylist,
|
||||||
RemoveSongFromPlaylist,
|
RemoveSongFromPlaylist,
|
||||||
ReorderSong,
|
ReorderSong,
|
||||||
SearchSong,
|
SearchSong,
|
||||||
SearchSongResult,
|
SearchSongResult,
|
||||||
SendChatMessage,
|
SendChatMessage, Shuffle,
|
||||||
SkipSong,
|
SkipSong,
|
||||||
SongLikes,
|
SongLikes,
|
||||||
StuenMessage,
|
StuenMessage,
|
||||||
@@ -69,12 +69,18 @@ export default function parseMessage(message: string): StuenMessage | null {
|
|||||||
return new PlaylistSongs(data.playlist);
|
return new PlaylistSongs(data.playlist);
|
||||||
case 'CreatePlaylist':
|
case 'CreatePlaylist':
|
||||||
return new CreatePlaylist(data.title);
|
return new CreatePlaylist(data.title);
|
||||||
|
case 'RemovePlaylist':
|
||||||
|
return new RemovePlaylist(data.title);
|
||||||
case 'AddSongToPlaylist':
|
case 'AddSongToPlaylist':
|
||||||
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':
|
case 'ToggleTag':
|
||||||
return new ToggleTag(data.song, data.tag);
|
return new ToggleTag(data.song, data.tag);
|
||||||
|
case '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;
|
||||||
|
|||||||
Reference in New Issue
Block a user