ledung 1.2.0 → 1.3.0

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.
package/dist/main.js CHANGED
@@ -15318,6 +15318,7 @@ var LINK_PAIRINGS_KEPT = 20;
15318
15318
  var LINK_PAIR_TIMES_KEY = "link-pair-times";
15319
15319
  var WAITING_POLL_MS = 3e4;
15320
15320
  var WAITING_PUSH_MS = 1e3;
15321
+ var exercised463 = false;
15321
15322
  var LINKED_HERE = "Computers are linked and unlinked";
15322
15323
  var MAX_BODY2 = 1024 * 1024;
15323
15324
  var NOT_PAIRED = "This device is not paired with Ledung. Pair it from Settings \u2192 Phones in Ledung on the computer.";
@@ -15697,6 +15698,7 @@ var LedungServer = class {
15697
15698
  if (this.remote) this.setRemote(this.remote);
15698
15699
  }
15699
15700
  close() {
15701
+ this.closed = true;
15700
15702
  if (this.waitingPoll) clearInterval(this.waitingPoll);
15701
15703
  if (this.waitingPush) clearTimeout(this.waitingPush);
15702
15704
  for (const ws of this.clients) ws.close(1001, "Ledung is shutting down.");
@@ -16051,6 +16053,11 @@ var LedungServer = class {
16051
16053
  waitingThere = /* @__PURE__ */ new Map();
16052
16054
  waitingPoll = null;
16053
16055
  waitingPush = null;
16056
+ /**
16057
+ * Set by close: an exchange still on its way then changes nothing and starts no new one, as the database may be
16058
+ * closed by the time its answer comes (#463: it threw "database is not open" after a test's end).
16059
+ */
16060
+ closed = false;
16054
16061
  /** The count last sent to the linked computers, so an unchanged one isn't sent again. */
16055
16062
  waitingSent = null;
16056
16063
  /** What waits for the user here, as this computer's page counts it (App: questions, prompts, cards). */
@@ -16059,7 +16066,7 @@ var LedungServer = class {
16059
16066
  }
16060
16067
  /** Something that may change the count happened: sent to the linked computers shortly, if it did change. */
16061
16068
  waitingChanged() {
16062
- if (this.waitingPush || !this.linked || !this.servers.length) return;
16069
+ if (this.closed || this.waitingPush || !this.linked || !this.servers.length) return;
16063
16070
  this.waitingPush = setTimeout(() => {
16064
16071
  this.waitingPush = null;
16065
16072
  if (this.waitingNow() !== this.waitingSent) this.exchangeWaiting();
@@ -16069,7 +16076,7 @@ var LedungServer = class {
16069
16076
  /** Sends this computer's count to every linked one and keeps theirs; one that doesn't answer loses its badge. */
16070
16077
  exchangeWaiting() {
16071
16078
  const linked = this.linked;
16072
- if (!linked) return;
16079
+ if (!linked || this.closed) return;
16073
16080
  const count = this.waitingNow();
16074
16081
  this.waitingSent = count;
16075
16082
  for (const link of linked.list()) {
@@ -16078,6 +16085,13 @@ var LedungServer = class {
16078
16085
  }
16079
16086
  /** A linked computer's count, or undefined when it is offline: the open pages get its tab's badge at once. */
16080
16087
  noteWaiting(id, raw) {
16088
+ if (this.closed) {
16089
+ if (!exercised463) {
16090
+ exercised463 = true;
16091
+ exercisedLine("EXERCISED #463 a linked computer's answer after close was let go");
16092
+ }
16093
+ return;
16094
+ }
16081
16095
  const count = typeof raw === "number" && Number.isInteger(raw) && raw >= 0 && raw < 1e6 ? raw : void 0;
16082
16096
  if (this.waitingThere.get(id) === count) return;
16083
16097
  if (count === void 0) this.waitingThere.delete(id);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ledung",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ledung",
9
- "version": "1.2.0",
9
+ "version": "1.3.0",
10
10
  "license": "AGPL-3.0-only",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/claude-agent-sdk": "0.3.295",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ledung",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Project Ledung <martin@projectledung.com>",
6
6
  "description": "Runs several Claude Code sessions locally and shows them in one place.",