4 Commits

Author SHA1 Message Date
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
10 changed files with 51 additions and 23 deletions

View File

@@ -5,20 +5,20 @@ 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);
}
}

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);

9
dist/dataTypes.d.ts vendored
View File

@@ -7,17 +7,20 @@ 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;

17
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,11 +45,12 @@ 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;

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 | RemovePlaylist | AddSongToPlaylist | RemoveSongFromPlaylist | Playlists | GetPlaylist | PlaylistSongs | ToggleTag | Shuffle;
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 {
type: string;
constructor(type: string);
@@ -107,3 +107,6 @@ export declare class ToggleTag extends StuenMessage {
export declare class Shuffle extends StuenMessage {
constructor();
}
export declare class RemoveFromAutoPlay extends StuenMessage {
constructor();
}

12
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.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;
Object.defineProperty(exports, "__esModule", { value: true });
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 () {
function StuenMessage(type) {
this.type = type;
@@ -274,3 +274,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;

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 {
@@ -55,6 +55,8 @@ function parseMessage(message) {
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;
@@ -65,4 +67,4 @@ function parseMessage(message) {
return null; // Handle parsing errors
}
}
exports["default"] = parseMessage;
exports.default = parseMessage;

View File

@@ -25,6 +25,7 @@ export type StuenMessages =
| PlaylistSongs
| ToggleTag
| Shuffle
| RemoveFromAutoPlay
export abstract class StuenMessage {
constructor(public type: string) {
@@ -181,3 +182,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.9",
"version": "1.2.12",
"main": "dist/common.js",
"type": "commonjs",
"types": "dist/common.d.ts",

View File

@@ -11,7 +11,7 @@ import {
ListenerList,
Playlists,
PlaylistSongs,
QueueSong, RemovePlaylist,
QueueSong, RemoveFromAutoPlay, RemovePlaylist,
RemoveSongFromPlaylist,
ReorderSong,
SearchSong,
@@ -79,6 +79,8 @@ export default function parseMessage(message: string): StuenMessage | null {
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;