@evandu/super-pi 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,7 @@ export class WsBroadcaster {
34
34
  return this.getState();
35
35
  }
36
36
  }
37
+ import { checkDiskVersion } from "./version.js";
37
38
  /**
38
39
  * WebSocket transport manager handling upgrade, connection lifecycles, and command dispatch.
39
40
  */
@@ -43,11 +44,13 @@ export class WsServer {
43
44
  commandHandler;
44
45
  catalogService;
45
46
  accessToken;
47
+ rootDir;
46
48
  constructor(options) {
47
49
  this.broadcaster = options.broadcaster;
48
50
  this.commandHandler = options.commandHandler;
49
51
  this.catalogService = options.catalogService;
50
52
  this.accessToken = options.accessToken;
53
+ this.rootDir = options.rootDir;
51
54
  this.websocketServer = new WebSocketServer({ noServer: true });
52
55
  this.setupUpgrade(options.httpServer);
53
56
  this.setupConnectionHandling();
@@ -67,6 +70,9 @@ export class WsServer {
67
70
  this.websocketServer.on("connection", (socket) => {
68
71
  this.broadcaster.register(socket);
69
72
  socket.send(JSON.stringify({ type: "state", state: this.broadcaster.getStateSnapshot() }));
73
+ if (this.rootDir) {
74
+ socket.send(JSON.stringify({ type: "server.version", version: checkDiskVersion(this.rootDir) }));
75
+ }
70
76
  void this.catalogService.agentCatalog().then((catalog) => {
71
77
  if (socket.readyState === WebSocket.OPEN) {
72
78
  socket.send(JSON.stringify({ type: "agent.catalog", catalog }));
@@ -80,6 +86,12 @@ export class WsServer {
80
86
  const heartbeat = setInterval(() => {
81
87
  if (socket.readyState === WebSocket.OPEN) {
82
88
  socket.ping();
89
+ if (this.rootDir) {
90
+ const v = checkDiskVersion(this.rootDir);
91
+ if (v.needsRestart) {
92
+ socket.send(JSON.stringify({ type: "server.version", version: v }));
93
+ }
94
+ }
83
95
  }
84
96
  }, 30_000);
85
97
  socket.on("close", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",