Compare commits

...

8 Commits

Author SHA1 Message Date
Darius
921882054d 1.5.5 2026-02-05 04:32:04 +01:00
Darius
cdd2fcb59e set => map 2026-02-05 04:31:54 +01:00
Darius
8daeed6b5f 1.5.4 2026-02-05 01:00:05 +01:00
Darius
6d05233a6e fix logger import 2026-02-05 00:59:56 +01:00
Darius
3dd61ab4e8 1.5.3 2026-02-05 00:47:31 +01:00
Darius
b7ea7bc552 dont need volume 2026-02-05 00:47:23 +01:00
Darius
d23c89c3c9 1.5.2 2026-02-05 00:31:13 +01:00
Darius
fd766a822c add homepage information type pt2 2026-02-05 00:31:08 +01:00
9 changed files with 34 additions and 38 deletions

6
dist/homepage.d.ts vendored
View File

@@ -1,8 +1,8 @@
import { API_HA_DeskPosition } from "./homeassistant"; import { API_HA_DeskPosition } from "./homeassistant";
import { TidalGetCurrent } from "./tidal"; import { TidalGetCurrent } from "./tidal";
export type FullInformation = { export type FullInformation = {
ha_desk_position: API_HA_DeskPosition; ha_desk_position: API_HA_DeskPosition | null;
ha_temp: string; ha_temp: string | null;
tidal_current: TidalGetCurrent; tidal_current: TidalGetCurrent | null;
}; };
//# sourceMappingURL=homepage.d.ts.map //# sourceMappingURL=homepage.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../src/homepage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG;IAC7B,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,eAAe,CAAC;CAC/B,CAAA"} {"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../src/homepage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG;IAC7B,gBAAgB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC,CAAA"}

5
dist/sse.d.ts vendored
View File

@@ -1,5 +1,6 @@
import { UUID } from "crypto";
export type SseClient = { export type SseClient = {
id: number; id: UUID;
send: (data: SseEvent) => void; send: (data: SseEvent) => void;
}; };
export type SseEvent = { export type SseEvent = {
@@ -10,7 +11,7 @@ export type SseEvent = {
export declare class SseService { export declare class SseService {
private clients; private clients;
addClient(client: SseClient): void; addClient(client: SseClient): void;
removeClient(clientId: number): void; removeClient(clientId: string): void;
notifyClients(event: SseEvent): void; notifyClients(event: SseEvent): void;
getClientCount(): number; getClientCount(): number;
} }

2
dist/sse.d.ts.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../src/sse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC/B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAA;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"} {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../src/sse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC/B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAA;AAED,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAqC;IAEpD,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAOlC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOpC,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAMpC,cAAc,IAAI,MAAM;CAGxB"}

15
dist/sse.js vendored
View File

@@ -1,21 +1,18 @@
import { logInfo } from "./logger"; import { logInfo } from "./logger.js";
export class SseService { export class SseService {
clients = new Set(); clients = new Map();
addClient(client) { addClient(client) {
this.clients.add(client); this.clients.set(client.id, client);
logInfo(`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`); logInfo(`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`);
} }
removeClient(clientId) { removeClient(clientId) {
const client = [...this.clients].find((c) => c.id === clientId); this.clients.delete(clientId);
if (client) {
this.clients.delete(client);
logInfo(`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`); logInfo(`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`);
} }
}
notifyClients(event) { notifyClients(event) {
this.clients.forEach((client) => { for (const client of this.clients.values()) {
client.send(event); client.send(event);
}); }
} }
getClientCount() { getClientCount() {
return this.clients.size; return this.clients.size;

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.5.1", "version": "1.5.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.5.1", "version": "1.5.5",
"dependencies": { "dependencies": {
"axios": "^1.7.9", "axios": "^1.7.9",
"chalk": "^5.6.2", "chalk": "^5.6.2",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.5.1", "version": "1.5.5",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -2,7 +2,7 @@ import { API_HA_DeskPosition } from "./homeassistant";
import { TidalGetCurrent } from "./tidal"; import { TidalGetCurrent } from "./tidal";
export type FullInformation = { export type FullInformation = {
ha_desk_position: API_HA_DeskPosition; ha_desk_position: API_HA_DeskPosition | null;
ha_temp: string; ha_temp: string | null;
tidal_current: TidalGetCurrent; tidal_current: TidalGetCurrent | null;
} }

View File

@@ -1,7 +1,8 @@
import { logInfo } from "./logger"; import { UUID } from "crypto";
import { logInfo } from "./logger.js";
export type SseClient = { export type SseClient = {
id: number; id: UUID;
send: (data: SseEvent) => void; send: (data: SseEvent) => void;
} }
@@ -12,29 +13,26 @@ export type SseEvent = {
} }
export class SseService { export class SseService {
private clients = new Set<SseClient>(); private clients: Map<string, SseClient> = new Map();
addClient(client: SseClient): void { addClient(client: SseClient): void {
this.clients.add(client); this.clients.set(client.id, client);
logInfo( logInfo(
`SSE client connected: ${client.id}. Total clients: ${this.clients.size}`, `SSE client connected: ${client.id}. Total clients: ${this.clients.size}`,
); );
} }
removeClient(clientId: number): void { removeClient(clientId: string): void {
const client = [...this.clients].find((c) => c.id === clientId); this.clients.delete(clientId);
if (client) {
this.clients.delete(client);
logInfo( logInfo(
`SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`, `SSE client disconnected: ${clientId}. Total clients: ${this.clients.size}`,
); );
} }
}
notifyClients(event: SseEvent): void { notifyClients(event: SseEvent): void {
this.clients.forEach((client) => { for (const client of this.clients.values()) {
client.send(event); client.send(event);
}); }
} }
getClientCount(): number { getClientCount(): number {