More stuff

This commit is contained in:
Torben Pi Jensen 2023-11-09 19:30:55 +01:00
parent f8104ffbfe
commit 2da7f2f1c9
7 changed files with 165 additions and 53 deletions

View File

@ -1,23 +1,44 @@
export class Song {
public type: SongType
public title: string;
public url: string;
public image: string;
public length: number | null;
constructor(type: SongType, title: string, url: string, image: string, length: number | null = null) {
this.type = type;
this.title = title;
this.url = url;
this.image = image;
this.length = length;
}
}
export enum SongType {
YouTube,
Spotify
}
export class SearchResult {
public type: SongType
public title: string;
public songId: string;
public image: string;
constructor(type: SongType, title: string, songId: string, image: string) {
this.type = type;
this.title = title;
this.songId = songId;
this.image = image;
}
}
export class QueuedSong {
public title: string;
public image: string;
constructor(title: string, image: string) {
this.title = title;
this.image = image;
}
}
export class Song {
public type: SongType
public songId: string;
public title: string;
public position: number;
constructor(type: SongType, songId: string, title: string, position: number) {
this.type = type;
this.songId = songId;
this.title = title;
this.position = position;
}
}

27
dist/dataTypes.d.ts vendored
View File

@ -1,12 +1,23 @@
export declare class Song {
type: SongType;
title: string;
url: string;
image: string;
length: number | null;
constructor(type: SongType, title: string, url: string, image: string, length?: number | null);
}
export declare enum SongType {
YouTube = 0,
Spotify = 1
}
export declare class SearchResult {
type: SongType;
title: string;
songId: string;
image: string;
constructor(type: SongType, title: string, songId: string, image: string);
}
export declare class QueuedSong {
title: string;
image: string;
constructor(title: string, image: string);
}
export declare class Song {
type: SongType;
songId: string;
title: string;
position: number;
constructor(type: SongType, songId: string, title: string, position: number);
}

42
dist/dataTypes.js vendored
View File

@ -1,20 +1,36 @@
"use strict";
exports.__esModule = true;
exports.SongType = exports.Song = void 0;
var Song = /** @class */ (function () {
function Song(type, title, url, image, length) {
if (length === void 0) { length = null; }
this.type = type;
this.title = title;
this.url = url;
this.image = image;
this.length = length;
}
return Song;
}());
exports.Song = Song;
exports.Song = exports.QueuedSong = exports.SearchResult = exports.SongType = void 0;
var SongType;
(function (SongType) {
SongType[SongType["YouTube"] = 0] = "YouTube";
SongType[SongType["Spotify"] = 1] = "Spotify";
})(SongType = exports.SongType || (exports.SongType = {}));
var SearchResult = /** @class */ (function () {
function SearchResult(type, title, songId, image) {
this.type = type;
this.title = title;
this.songId = songId;
this.image = image;
}
return SearchResult;
}());
exports.SearchResult = SearchResult;
var QueuedSong = /** @class */ (function () {
function QueuedSong(title, image) {
this.title = title;
this.image = image;
}
return QueuedSong;
}());
exports.QueuedSong = QueuedSong;
var Song = /** @class */ (function () {
function Song(type, songId, title, position) {
this.type = type;
this.songId = songId;
this.title = title;
this.position = position;
}
return Song;
}());
exports.Song = Song;

View File

@ -1,5 +1,5 @@
import { Song } from "./dataTypes";
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue;
import { Song, SearchResult, QueuedSong } from "./dataTypes";
export declare type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong;
export declare abstract class StuenMessage {
type: string;
constructor(type: string);
@ -34,14 +34,28 @@ export declare class SearchSong extends StuenMessage {
constructor(query: string);
}
export declare class SearchSongResult extends StuenMessage {
result: Song[];
constructor(result: Song[]);
result: SearchResult[];
constructor(result: SearchResult[]);
}
export declare class QueueSong extends StuenMessage {
song: SearchResult;
constructor(song: SearchResult);
}
export declare class CurrentQueue extends StuenMessage {
songs: QueuedSong[];
constructor(songs: QueuedSong[]);
}
export declare class CurrentSong extends StuenMessage {
song: Song;
constructor(song: Song);
}
export declare class CurrentQueue extends StuenMessage {
songs: Song[];
constructor(songs: Song[]);
export declare class UnqueueSong extends StuenMessage {
position: number | null;
all: boolean | undefined;
constructor(position: number | null, all?: boolean | undefined);
}
export declare class ReorderSong extends StuenMessage {
positionToMove: number;
placePosition: number;
constructor(positionToMove: number, placePosition: number);
}

35
dist/messageTypes.js vendored
View File

@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
};
})();
exports.__esModule = true;
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.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;
@ -124,3 +124,36 @@ var CurrentQueue = /** @class */ (function (_super) {
return CurrentQueue;
}(StuenMessage));
exports.CurrentQueue = CurrentQueue;
var CurrentSong = /** @class */ (function (_super) {
__extends(CurrentSong, _super);
function CurrentSong(song) {
var _this = _super.call(this, 'CurrentSong') || this;
_this.song = song;
return _this;
}
return CurrentSong;
}(StuenMessage));
exports.CurrentSong = CurrentSong;
var UnqueueSong = /** @class */ (function (_super) {
__extends(UnqueueSong, _super);
function UnqueueSong(position, all) {
if (all === void 0) { all = false; }
var _this = _super.call(this, 'UnqueueSong') || this;
_this.position = position;
_this.all = all;
return _this;
}
return UnqueueSong;
}(StuenMessage));
exports.UnqueueSong = UnqueueSong;
var ReorderSong = /** @class */ (function (_super) {
__extends(ReorderSong, _super);
function ReorderSong(positionToMove, placePosition) {
var _this = _super.call(this, 'ReorderSong') || this;
_this.positionToMove = positionToMove;
_this.placePosition = placePosition;
return _this;
}
return ReorderSong;
}(StuenMessage));
exports.ReorderSong = ReorderSong;

View File

@ -1,6 +1,6 @@
import {Song} from "./dataTypes";
import {Song, SearchResult, QueuedSong} from "./dataTypes";
export type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue;
export type StuenMessages = ListenerLeft | ListenerList | ListenerJoined | SendChatMessage | SearchSong | SearchSongResult | Join | QueueSong | CurrentQueue | CurrentSong | UnqueueSong | ReorderSong;
export abstract class StuenMessage {
constructor(public type: string) {}
}
@ -50,19 +50,36 @@ export class SearchSong extends StuenMessage {
export class SearchSongResult extends StuenMessage {
constructor(public result: Song[]) {
constructor(public result: SearchResult[]) {
super('SearchSongResult');
}
}
export class QueueSong extends StuenMessage {
constructor(public song: Song) {
constructor(public song: SearchResult) {
super('QueueSong');
}
}
export class CurrentQueue extends StuenMessage {
constructor(public songs: Song[]) {
constructor(public songs: QueuedSong[]) {
super('CurrentQueue');
}
}
export class CurrentSong extends StuenMessage {
constructor(public song: Song) {
super('CurrentSong');
}
}
export class UnqueueSong extends StuenMessage {
constructor(public position: number | null, public all: boolean | undefined = false) {
super('UnqueueSong');
}
}
export class ReorderSong extends StuenMessage {
constructor(public positionToMove: number, public placePosition: number) {
super('ReorderSong');
}
}

View File

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