Compare commits
7 Commits
v1.3.0
...
3b7ef0f3ee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b7ef0f3ee | ||
|
|
ada7268062 | ||
|
|
b55e1dd0a6 | ||
|
|
49f04ef82f | ||
|
|
862401fa9b | ||
|
|
20e94a7e0e | ||
|
|
7f2b8ce5aa |
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
|||||||
export * from "./fastify.js";
|
export * from "./fastify.js";
|
||||||
export * from "./homeassistant.js";
|
export * from "./homeassistant.js";
|
||||||
export * from "./logger.js";
|
export * from "./logger.js";
|
||||||
|
export * from "./sse.js";
|
||||||
export * from "./tidal.js";
|
export * from "./tidal.js";
|
||||||
export * from "./timehelper.js";
|
export * from "./timehelper.js";
|
||||||
//# sourceMappingURL=index.d.ts.map
|
//# sourceMappingURL=index.d.ts.map
|
||||||
2
dist/index.d.ts.map
vendored
2
dist/index.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
||||||
1
dist/index.js
vendored
1
dist/index.js
vendored
@@ -1,5 +1,6 @@
|
|||||||
export * from "./fastify.js";
|
export * from "./fastify.js";
|
||||||
export * from "./homeassistant.js";
|
export * from "./homeassistant.js";
|
||||||
export * from "./logger.js";
|
export * from "./logger.js";
|
||||||
|
export * from "./sse.js";
|
||||||
export * from "./tidal.js";
|
export * from "./tidal.js";
|
||||||
export * from "./timehelper.js";
|
export * from "./timehelper.js";
|
||||||
|
|||||||
17
dist/sse.d.ts
vendored
Normal file
17
dist/sse.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export interface SseClient {
|
||||||
|
id: number;
|
||||||
|
send: (data: SseEvent) => void;
|
||||||
|
}
|
||||||
|
export interface SseEvent {
|
||||||
|
type: string;
|
||||||
|
data?: unknown;
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
export declare class SseService {
|
||||||
|
private clients;
|
||||||
|
addClient(client: SseClient): void;
|
||||||
|
removeClient(clientId: number): void;
|
||||||
|
notifyClients(event: SseEvent): void;
|
||||||
|
getClientCount(): number;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=sse.d.ts.map
|
||||||
1
dist/sse.d.ts.map
vendored
Normal file
1
dist/sse.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../src/sse.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAwB;IAEvC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAOlC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAUpC,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAMpC,cAAc,IAAI,MAAM;CAGxB"}
|
||||||
23
dist/sse.js
vendored
Normal file
23
dist/sse.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { logInfo } from "./logger";
|
||||||
|
export class SseService {
|
||||||
|
clients = new Set();
|
||||||
|
addClient(client) {
|
||||||
|
this.clients.add(client);
|
||||||
|
logInfo(`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
removeClient(clientId) {
|
||||||
|
const client = [...this.clients].find((c) => c.id === clientId);
|
||||||
|
if (client) {
|
||||||
|
this.clients.delete(client);
|
||||||
|
logInfo(`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notifyClients(event) {
|
||||||
|
this.clients.forEach((client) => {
|
||||||
|
client.send(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getClientCount() {
|
||||||
|
return this.clients.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
dist/tidal.d.ts
vendored
18
dist/tidal.d.ts
vendored
@@ -1,14 +1,26 @@
|
|||||||
export type TidalSong = {
|
export type TidalGetCurrent = {
|
||||||
title: string;
|
title: string;
|
||||||
artists: string;
|
artists: string;
|
||||||
|
artistsArray: string[];
|
||||||
album: string;
|
album: string;
|
||||||
playingFrom: string;
|
playingFrom: string;
|
||||||
status: "playing" | "paused";
|
status: "playing" | "paused";
|
||||||
url: string;
|
url: string;
|
||||||
current: string;
|
current: string;
|
||||||
|
currentInSeconds: number;
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
durationInSeconds: number;
|
||||||
export type TidalVolume = {
|
image: string;
|
||||||
|
icon: string;
|
||||||
|
localAlbumArt: string;
|
||||||
|
favorite: boolean;
|
||||||
|
trackId: string;
|
||||||
volume: number;
|
volume: number;
|
||||||
|
player: {
|
||||||
|
status: "playing" | "paused";
|
||||||
|
shuffle: boolean;
|
||||||
|
repeat: "all" | "single" | "none";
|
||||||
|
};
|
||||||
|
artist: string;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=tidal.d.ts.map
|
//# sourceMappingURL=tidal.d.ts.map
|
||||||
2
dist/tidal.d.ts.map
vendored
2
dist/tidal.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"tidal.d.ts","sourceRoot":"","sources":["../src/tidal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
{"version":3,"file":"tidal.d.ts","sourceRoot":"","sources":["../src/tidal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACP,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC7B,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;KAClC,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CACf,CAAC"}
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.3.0",
|
"version": "1.5.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.3.0",
|
"version": "1.5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"chalk": "^5.6.2",
|
"chalk": "^5.6.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.3.0",
|
"version": "1.5.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
export * from "./fastify.js";
|
export * from "./fastify.js";
|
||||||
export * from "./homeassistant.js";
|
export * from "./homeassistant.js";
|
||||||
export * from "./logger.js";
|
export * from "./logger.js";
|
||||||
|
export * from "./sse.js";
|
||||||
export * from "./tidal.js";
|
export * from "./tidal.js";
|
||||||
export * from "./timehelper.js";
|
export * from "./timehelper.js";
|
||||||
|
|
||||||
|
|||||||
43
src/sse.ts
Normal file
43
src/sse.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { logInfo } from "./logger";
|
||||||
|
|
||||||
|
export interface SseClient {
|
||||||
|
id: number;
|
||||||
|
send: (data: SseEvent) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SseEvent {
|
||||||
|
type: string;
|
||||||
|
data?: unknown;
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SseService {
|
||||||
|
private clients = new Set<SseClient>();
|
||||||
|
|
||||||
|
addClient(client: SseClient): void {
|
||||||
|
this.clients.add(client);
|
||||||
|
logInfo(
|
||||||
|
`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeClient(clientId: number): void {
|
||||||
|
const client = [...this.clients].find((c) => c.id === clientId);
|
||||||
|
if (client) {
|
||||||
|
this.clients.delete(client);
|
||||||
|
logInfo(
|
||||||
|
`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyClients(event: SseEvent): void {
|
||||||
|
this.clients.forEach((client) => {
|
||||||
|
client.send(event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getClientCount(): number {
|
||||||
|
return this.clients.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/tidal.ts
37
src/tidal.ts
@@ -1,14 +1,25 @@
|
|||||||
export type TidalSong = {
|
export type TidalGetCurrent = {
|
||||||
title: string;
|
title: string;
|
||||||
artists: string;
|
artists: string;
|
||||||
album: string;
|
artistsArray: string[];
|
||||||
playingFrom: string;
|
album: string;
|
||||||
status: "playing" | "paused";
|
playingFrom: string;
|
||||||
url: string;
|
status: "playing" | "paused";
|
||||||
current: string;
|
url: string;
|
||||||
duration: string;
|
current: string;
|
||||||
};
|
currentInSeconds: number;
|
||||||
|
duration: string;
|
||||||
export type TidalVolume = {
|
durationInSeconds: number;
|
||||||
volume: number;
|
image: string;
|
||||||
|
icon: string;
|
||||||
|
localAlbumArt: string;
|
||||||
|
favorite: boolean;
|
||||||
|
trackId: string;
|
||||||
|
volume: number;
|
||||||
|
player: {
|
||||||
|
status: "playing" | "paused";
|
||||||
|
shuffle: boolean;
|
||||||
|
repeat: "all" | "single" | "none";
|
||||||
|
};
|
||||||
|
artist: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user