@domicile-desktop/manganese-bar-module-network 0.0.0-alpha-38fad70baaba → 0.0.0-alpha-e5bdc59ffdf6

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/component-library": "0.0.0-alpha-38fad70baaba",
5
- "@domicile-desktop/manganese-bar": "0.0.0-alpha-38fad70baaba",
6
- "@domicile-desktop/manganese-host": "0.0.0-alpha-38fad70baaba",
7
- "@domicile-desktop/react": "0.0.0-alpha-38fad70baaba",
8
- "@domicile-desktop/sdk": "0.0.0-alpha-38fad70baaba",
9
- "@domicile-desktop/system-network": "0.0.0-alpha-38fad70baaba",
4
+ "@domicile-desktop/component-library": "0.0.0-alpha-e5bdc59ffdf6",
5
+ "@domicile-desktop/manganese-bar": "0.0.0-alpha-e5bdc59ffdf6",
6
+ "@domicile-desktop/manganese-host": "0.0.0-alpha-e5bdc59ffdf6",
7
+ "@domicile-desktop/react": "0.0.0-alpha-e5bdc59ffdf6",
8
+ "@domicile-desktop/sdk": "0.0.0-alpha-e5bdc59ffdf6",
9
+ "@domicile-desktop/system-network": "0.0.0-alpha-e5bdc59ffdf6",
10
10
  "@pandacss/dev": "^2.5.0",
11
11
  "@phosphor-icons/react": "^2.1.10",
12
12
  "react": "^19.3.1"
@@ -56,5 +56,5 @@
56
56
  "test:unit": "bun test"
57
57
  },
58
58
  "type": "module",
59
- "version": "0.0.0-alpha-38fad70baaba"
59
+ "version": "0.0.0-alpha-e5bdc59ffdf6"
60
60
  }
@@ -10,6 +10,9 @@ import { LinkKind } from "@domicile-desktop/system-network/network";
10
10
  /** How long to wait between checks while the sign-in page shows. */
11
11
  const RECHECK_MS = 3000;
12
12
 
13
+ /** The longest wait after checks that got no answer, which double from {@link RECHECK_MS}. */
14
+ const MOST_PATIENCE_MS = 60_000;
15
+
13
16
  type Options = {
14
17
  network: SharedWatch<Result<Network, SystemError>>;
15
18
  /** Where to sign in, or `None` for a network with no portal. */
@@ -18,8 +21,8 @@ type Options = {
18
21
  show: (url: string | undefined) => void;
19
22
  /** Hears a check that got no answer. */
20
23
  report: (error: SystemError) => void;
21
- /** Calls `then` after a while; returns what cancels it. */
22
- wait?: (then: () => void) => () => void;
24
+ /** Calls `then` after `ms`; returns what cancels it. */
25
+ wait?: (ms: number, then: () => void) => () => void;
23
26
  };
24
27
 
25
28
  /** What {@link followPortals} returns. */
@@ -35,7 +38,9 @@ export type PortalWatch = {
35
38
  *
36
39
  * A network is checked once on joining, so a signal change does not check it
37
40
  * again. While the page shows, the check repeats, and the page hides once the
38
- * portal lets the desk through or the desk leaves the network.
41
+ * portal lets the desk through or the desk leaves the network. A check that
42
+ * gets no answer, such as one whose name lookup outlasts it, repeats too,
43
+ * waiting longer each time, until one gets an answer.
39
44
  */
40
45
  export const followPortals = ({
41
46
  check,
@@ -58,18 +63,19 @@ export const followPortals = ({
58
63
  state.cancel = undefined;
59
64
  };
60
65
 
61
- const run = (round: number) => {
66
+ const run = (round: number, unanswered: number) => {
62
67
  check()
63
68
  .then((checked) => {
64
69
  if (round === state.round) {
65
70
  checked.match({
66
71
  Err: (error) => {
67
72
  report(error);
68
- if (state.shown) {
69
- state.cancel = wait(() => {
70
- run(round);
71
- });
72
- }
73
+ state.cancel = wait(
74
+ Math.min(RECHECK_MS * 2 ** unanswered, MOST_PATIENCE_MS),
75
+ () => {
76
+ run(round, unanswered + 1);
77
+ },
78
+ );
73
79
  },
74
80
  Ok: (portal) => {
75
81
  portal.match({
@@ -84,8 +90,8 @@ export const followPortals = ({
84
90
  state.shown = true;
85
91
  show(url);
86
92
  }
87
- state.cancel = wait(() => {
88
- run(round);
93
+ state.cancel = wait(RECHECK_MS, () => {
94
+ run(round, 0);
89
95
  });
90
96
  },
91
97
  });
@@ -113,7 +119,7 @@ export const followPortals = ({
113
119
  show(undefined);
114
120
  }
115
121
  if (name !== undefined) {
116
- run(state.round);
122
+ run(state.round, 0);
117
123
  }
118
124
  }
119
125
  },
@@ -143,8 +149,8 @@ type FollowState = {
143
149
  shown: boolean;
144
150
  };
145
151
 
146
- const waitToRecheck = (then: () => void): (() => void) => {
147
- const timer = setTimeout(then, RECHECK_MS);
152
+ const waitToRecheck = (ms: number, then: () => void): (() => void) => {
153
+ const timer = setTimeout(then, ms);
148
154
  return () => {
149
155
  clearTimeout(timer);
150
156
  };