@decentnetwork/beagle 0.1.66 → 0.1.68

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.
@@ -1,4 +1,4 @@
1
- window.__DK_UI_VERSION="0.1.66";
1
+ window.__DK_UI_VERSION="0.1.68";
2
2
  "use strict";
3
3
  (() => {
4
4
  // packages/beagle-ui/dist/beagle-ui.js
@@ -145,6 +145,43 @@ export class SwitchablePeerHost {
145
145
  // not silently lose chat.
146
146
  if (this.#state === "daemon" && !daemonUp) {
147
147
  await this.#backToEmbedded("the daemon is no longer running");
148
+ return;
149
+ }
150
+ // ...and the way back, which was missing. Every `agentnet restart` — an
151
+ // ordinary event, and exactly what an update tells you to run — took the
152
+ // daemon away for a second or two. This state machine fell back to the
153
+ // embedded peer and then had no transition to return, so beagle stayed
154
+ // demoted for the life of the process: the daemon it was meant to front
155
+ // was running the whole time, invisible to it. The version panel then
156
+ // reported the APP's peer as the daemon's, so an update that had actually
157
+ // landed looked like it had not.
158
+ if (this.#state === "embedded" && daemonUp) {
159
+ await this.#backToDaemon();
160
+ }
161
+ }
162
+ /** Hand the identity back to a daemon that has (re)appeared. */
163
+ async #backToDaemon() {
164
+ if (this.#busy)
165
+ return;
166
+ this.#busy = true;
167
+ try {
168
+ this.#log.info("the daemon is back — handing the identity over to it");
169
+ const old = this.#inner;
170
+ // Null first: reject calls rather than racing a peer that is stopping,
171
+ // the same order the manual release uses.
172
+ this.#inner = null;
173
+ await old?.stop();
174
+ this.#inner = this.#opts.makeDaemon();
175
+ this.#setState("daemon");
176
+ }
177
+ catch (err) {
178
+ // Could not stop cleanly — go back to embedded on the next tick rather
179
+ // than sitting with a null backend.
180
+ this.#log.error(`could not hand over to the daemon: ${err.message}`);
181
+ this.#setState("embedded");
182
+ }
183
+ finally {
184
+ this.#busy = false;
148
185
  }
149
186
  }
150
187
  async #backToEmbedded(why) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@decentnetwork/chat-components": "^0.1.3",
29
29
  "@decentnetwork/lan": "^0.1.283",
30
- "@decentnetwork/peer": "0.1.143",
30
+ "@decentnetwork/peer": "0.1.151",
31
31
  "@decentnetwork/peer-webrtc": "^0.2.16",
32
32
  "js-yaml": "^4.1.0",
33
33
  "yargs": "^17.7.2"