Compare commits

...

17 Commits

Author SHA1 Message Date
Thomas Viesmose Birch
5211a4a976 Adding songtype to playlists 2024-05-04 17:31:58 +02:00
Thomas Viesmose Birch
58f972156e Typescript is hard! 2024-05-04 16:20:19 +02:00
Thomas Viesmose Birch
1f69d0e867 Added OthersPlaylists to the parseMessages 2024-05-04 16:19:16 +02:00
Thomas Viesmose Birch
de19886518 Added OthersPlaylists to the parseMessages 2024-05-04 16:16:45 +02:00
Thomas Viesmose Birch
4ef0946605 Removed the ListenerJoined and ListenerLeft events 2024-05-04 16:09:35 +02:00
Thomas Viesmose Birch
365132977a Fixed unused include before bump 2024-05-04 15:36:49 +02:00
Thomas Viesmose Birch
3c80493446 bump to 17! 2024-05-04 15:35:11 +02:00
Thomas Viesmose Birch
927aa80398 bump to 16 2024-05-04 15:29:06 +02:00
Thomas Viesmose Birch
1b31aaf549 Renaming to GetOtherPlaylists 2024-05-04 15:27:43 +02:00
Thomas Viesmose Birch
7e1136acad Me and typescript is not friends. 2024-05-04 14:50:27 +02:00
Thomas Viesmose Birch
1487f6e1f5 Changed "Added new messages for returning users with playlists" to a call that just returns all playslists. 2024-05-04 14:43:05 +02:00
Thomas Viesmose Birch
8760a3affc Added new messages for returning users with playlists. 2024-05-04 13:17:06 +02:00
Thomas Viesmose Birch
00dedc1d85 Added inAutoPlay property to songs 2024-05-04 12:31:30 +02:00
Thomas Viesmose Birch
283d7ea4ec Added inAutoPlay property to songs 2024-05-04 12:16:22 +02:00
Thomas Viesmose Birch
e2475c254e Added inAutoPlay property to songs 2024-05-04 12:13:59 +02:00
Thomas Viesmose Birch
d08afcc4d6 Added RemoveSongFromAutoPlay 2024-05-04 10:28:11 +02:00
Torben Pi Jensen
d47379aacc Added remove playlist 2024-02-04 08:51:53 +01:00
10 changed files with 135 additions and 83 deletions

View File

@ -5,28 +5,29 @@ export enum SongType {
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 {
constructor(type: SongType, title: string, songId: string, image: string, public listener: string) {
super(type, title, songId, image);
constructor(type: SongType, title: string, songId: string, image: string, public listener: string, public inAutoPlay: boolean) {
super(type, title, songId, image, inAutoPlay);
}
}
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[]) {
super(type, title, songId, image, listener);
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, inAutoPlay);
}
}
export class Playlist {
constructor(public title: string, public listener: string, public songs: Song[]) {
constructor(public title: string, public listener: string, public type: SongType, public songs: Song[]) {
}
}
export class PlaylistDescription {
constructor(public title: string, public listener: string) {
constructor(public title: string, public listener: string, public type: SongType) {
}
}

2
dist/common.js vendored
View File

@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
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);
};
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./dataTypes"), exports);
__exportStar(require("./messageTypes"), exports);
__exportStar(require("./parseMessage"), exports);

15
dist/dataTypes.d.ts vendored
View File

@ -7,26 +7,31 @@ export declare class Song {
title: string;
songId: string;
image: string;
constructor(type: SongType, title: string, songId: string, image: string);
inAutoPlay: boolean;
constructor(type: SongType, title: string, songId: string, image: string, inAutoPlay: boolean);
}
export declare class QueuedSong extends Song {
listener: string;
constructor(type: SongType, title: string, songId: string, image: string, listener: string);
inAutoPlay: boolean;
constructor(type: SongType, title: string, songId: string, image: string, listener: string, inAutoPlay: boolean);
}
export declare class PlayingSong extends QueuedSong {
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;
constructor(type: SongType, title: string, songId: string, image: string, listener: string, length: number, position: number, tags: string[], inAutoPlay: boolean);
}
export declare class Playlist {
title: string;
listener: string;
type: SongType;
songs: Song[];
constructor(title: string, listener: string, songs: Song[]);
constructor(title: string, listener: string, type: SongType, songs: Song[]);
}
export declare class PlaylistDescription {
title: string;
listener: string;
constructor(title: string, listener: string);
type: SongType;
constructor(title: string, listener: string, type: SongType);
}

23
dist/dataTypes.js vendored
View File

@ -14,28 +14,30 @@ var __extends = (this && this.__extends) || (function () {
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;
var SongType;
(function (SongType) {
SongType[SongType["YouTube"] = 0] = "YouTube";
SongType[SongType["Spotify"] = 1] = "Spotify";
})(SongType = exports.SongType || (exports.SongType = {}));
})(SongType || (exports.SongType = SongType = {}));
var Song = /** @class */ (function () {
function Song(type, title, songId, image) {
function Song(type, title, songId, image, inAutoPlay) {
this.type = type;
this.title = title;
this.songId = songId;
this.image = image;
this.inAutoPlay = inAutoPlay;
}
return Song;
}());
exports.Song = Song;
var QueuedSong = /** @class */ (function (_super) {
__extends(QueuedSong, _super);
function QueuedSong(type, title, songId, image, listener) {
var _this = _super.call(this, type, title, songId, image) || this;
function QueuedSong(type, title, songId, image, listener, inAutoPlay) {
var _this = _super.call(this, type, title, songId, image, inAutoPlay) || this;
_this.listener = listener;
_this.inAutoPlay = inAutoPlay;
return _this;
}
return QueuedSong;
@ -43,29 +45,32 @@ 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, tags) {
var _this = _super.call(this, type, title, songId, image, listener) || this;
function PlayingSong(type, title, songId, image, listener, length, position, tags, inAutoPlay) {
var _this = _super.call(this, type, title, songId, image, listener, inAutoPlay) || this;
_this.length = length;
_this.position = position;
_this.tags = tags;
_this.inAutoPlay = inAutoPlay;
return _this;
}
return PlayingSong;
}(QueuedSong));
exports.PlayingSong = PlayingSong;
var Playlist = /** @class */ (function () {
function Playlist(title, listener, songs) {
function Playlist(title, listener, type, songs) {
this.title = title;
this.listener = listener;
this.type = type;
this.songs = songs;
}
return Playlist;
}());
exports.Playlist = Playlist;
var PlaylistDescription = /** @class */ (function () {
function PlaylistDescription(title, listener) {
function PlaylistDescription(title, listener, type) {
this.title = title;
this.listener = listener;
this.type = type;
}
return PlaylistDescription;
}());

View File

@ -1,5 +1,5 @@
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 | Shuffle;
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 abstract class StuenMessage {
type: string;
constructor(type: string);
@ -8,14 +8,6 @@ export declare class Join extends StuenMessage {
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 {
names: string[];
constructor(names: string[]);
@ -73,6 +65,10 @@ export declare class CreatePlaylist extends StuenMessage {
title: string;
constructor(title: string);
}
export declare class RemovePlaylist extends StuenMessage {
title: string;
constructor(title: string);
}
export declare class Playlists extends StuenMessage {
playlists: PlaylistDescription[];
constructor(playlists: PlaylistDescription[]);
@ -85,6 +81,13 @@ export declare class PlaylistSongs extends StuenMessage {
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 {
song: Song;
playlist: string;
@ -103,3 +106,6 @@ export declare class ToggleTag extends StuenMessage {
export declare class Shuffle extends StuenMessage {
constructor();
}
export declare class RemoveFromAutoPlay extends StuenMessage {
constructor();
}

60
dist/messageTypes.js vendored
View File

@ -14,8 +14,8 @@ var __extends = (this && this.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
exports.Shuffle = 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;
Object.defineProperty(exports, "__esModule", { value: 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;
var StuenMessage = /** @class */ (function () {
function StuenMessage(type) {
this.type = type;
@ -33,26 +33,6 @@ var Join = /** @class */ (function (_super) {
return Join;
}(StuenMessage));
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) {
__extends(ListenerList, _super);
function ListenerList(names) {
@ -193,6 +173,16 @@ var CreatePlaylist = /** @class */ (function (_super) {
return CreatePlaylist;
}(StuenMessage));
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) {
__extends(Playlists, _super);
function Playlists(playlists) {
@ -223,6 +213,24 @@ var PlaylistSongs = /** @class */ (function (_super) {
return PlaylistSongs;
}(StuenMessage));
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) {
__extends(AddSongToPlaylist, _super);
function AddSongToPlaylist(song, playlist) {
@ -264,3 +272,11 @@ var Shuffle = /** @class */ (function (_super) {
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;

16
dist/parseMessage.js vendored
View File

@ -1,5 +1,5 @@
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var messageTypes_1 = require("./messageTypes");
function parseMessage(message) {
try {
@ -7,10 +7,6 @@ function parseMessage(message) {
switch (data.type) {
case 'Join':
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':
return new messageTypes_1.ListenerList(data.names);
case 'SendChatMessage':
@ -45,14 +41,22 @@ function parseMessage(message) {
return new messageTypes_1.PlaylistSongs(data.playlist);
case 'CreatePlaylist':
return new messageTypes_1.CreatePlaylist(data.title);
case 'RemovePlaylist':
return new messageTypes_1.RemovePlaylist(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 'GetOtherPlaylists':
return new messageTypes_1.GetOtherPlaylists();
case 'OthersPlaylists':
return new messageTypes_1.OthersPlaylists(data.playlists);
case 'ToggleTag':
return new messageTypes_1.ToggleTag(data.song, data.tag);
case 'Shuffle':
return new messageTypes_1.Shuffle();
case 'RemoveFromAutoPlay':
return new messageTypes_1.RemoveFromAutoPlay();
default:
console.error('Unknown message type:', data.type);
return null;
@ -63,4 +67,4 @@ function parseMessage(message) {
return null; // Handle parsing errors
}
}
exports["default"] = parseMessage;
exports.default = parseMessage;

View File

@ -1,9 +1,7 @@
import {Song, PlayingSong, QueuedSong, Playlist, PlaylistDescription} from "./dataTypes";
export type StuenMessages =
ListenerLeft
| ListenerList
| ListenerJoined
ListenerList
| SendChatMessage
| SearchSong
| SearchSongResult
@ -17,13 +15,16 @@ export type StuenMessages =
| SongLikes
| ToggleSongLike
| CreatePlaylist
| RemovePlaylist
| AddSongToPlaylist
| RemoveSongFromPlaylist
| Playlists
| GetPlaylist
| PlaylistSongs
| GetOtherPlaylists
| ToggleTag
| Shuffle
| RemoveFromAutoPlay
export abstract class StuenMessage {
constructor(public type: string) {
@ -36,18 +37,6 @@ 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 {
constructor(public names: string[]) {
super('ListenerList');
@ -134,6 +123,11 @@ export class CreatePlaylist extends StuenMessage {
super('CreatePlaylist');
}
}
export class RemovePlaylist extends StuenMessage {
constructor(public title: string) {
super('RemovePlaylist');
}
}
export class Playlists extends StuenMessage {
constructor(public playlists: PlaylistDescription[]) {
@ -146,12 +140,24 @@ export class GetPlaylist extends StuenMessage {
super('GetPlaylist');
}
}
export class PlaylistSongs extends StuenMessage {
constructor(public playlist: Playlist) {
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 {
constructor(public song: Song, public playlist: string) {
super('AddSongToPlaylist');
@ -175,3 +181,9 @@ export class Shuffle extends StuenMessage {
super('Shuffle');
}
}
export class RemoveFromAutoPlay extends StuenMessage {
constructor() {
super('RemoveFromAutoPlay');
}
}

View File

@ -1,6 +1,6 @@
{
"name": "stuen-common",
"version": "1.2.8",
"version": "1.2.17",
"main": "dist/common.js",
"type": "commonjs",
"types": "dist/common.d.ts",

View File

@ -6,12 +6,11 @@ import {
CurrentSong,
GetPlaylist,
Join,
ListenerJoined,
ListenerLeft,
ListenerList,
Playlists,
PlaylistSongs,
QueueSong,
GetOtherPlaylists,
QueueSong, RemoveFromAutoPlay, RemovePlaylist,
RemoveSongFromPlaylist,
ReorderSong,
SearchSong,
@ -21,7 +20,7 @@ import {
SongLikes,
StuenMessage,
ToggleSongLike, ToggleTag,
UnqueueSong
UnqueueSong, OthersPlaylists,
} from "./messageTypes";
export default function parseMessage(message: string): StuenMessage | null {
@ -31,10 +30,6 @@ export default function parseMessage(message: string): StuenMessage | null {
switch (data.type) {
case 'Join':
return new Join(data.name);
case 'ListenerJoined':
return new ListenerJoined(data.name);
case 'ListenerLeft':
return new ListenerLeft(data.name);
case 'ListenerList':
return new ListenerList(data.names);
case 'SendChatMessage':
@ -69,14 +64,22 @@ export default function parseMessage(message: string): StuenMessage | null {
return new PlaylistSongs(data.playlist);
case 'CreatePlaylist':
return new CreatePlaylist(data.title);
case 'RemovePlaylist':
return new RemovePlaylist(data.title);
case 'AddSongToPlaylist':
return new AddSongToPlaylist(data.song, data.playlist);
case 'RemoveSongFromPlaylist':
return new RemoveSongFromPlaylist(data.song, data.playlist);
case 'GetOtherPlaylists':
return new GetOtherPlaylists();
case 'OthersPlaylists':
return new OthersPlaylists(data.playlists);
case 'ToggleTag':
return new ToggleTag(data.song, data.tag);
case 'Shuffle':
return new Shuffle();
case 'RemoveFromAutoPlay':
return new RemoveFromAutoPlay();
default:
console.error('Unknown message type:', data.type);
return null;