clavarium 0.2.117-next.1 → 0.2.118-next.1

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,17 +1,17 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.117-next.1",
3
+ "version": "0.2.118-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.117-next.1",
9
+ "version": "0.2.118-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
- "clavarium-binder": "0.1.24-next.1",
14
+ "clavarium-binder": "0.1.28-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
16
  "clavarium-parley": "0.17.12-next.1",
17
17
  "clavarium-tether": "0.1.0-next.29",
@@ -716,9 +716,9 @@
716
716
  }
717
717
  },
718
718
  "node_modules/clavarium-binder": {
719
- "version": "0.1.24-next.1",
720
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.24-next.1.tgz",
721
- "integrity": "sha512-XaTztixmK5t7hTZDWhyO/qvHMksBZdKKJnLZnvFAzz9A7rgw0ytKFLXH4p3wFDRdMnhZFLh5DQ4wT5KQ/0l57w==",
719
+ "version": "0.1.28-next.1",
720
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.28-next.1.tgz",
721
+ "integrity": "sha512-/6YAE9OE+qAbzUxVPmPH83uIwqxfRXpASQN8dAAmh7dpQRHPXKtGIG6iz1hSYvvVru9Cx93y/niQWU0raxzE2A==",
722
722
  "license": "MIT",
723
723
  "bin": {
724
724
  "binder": "bin/binder.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.117-next.1",
3
+ "version": "0.2.118-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.24-next.1",
47
+ "clavarium-binder": "0.1.28-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
49
  "clavarium-parley": "0.17.12-next.1",
50
50
  "clavarium-tether": "0.1.0-next.29",
package/server/api.mjs CHANGED
@@ -152,6 +152,9 @@ function readBody(request, max = BODY_MAX) {
152
152
  }
153
153
 
154
154
  /* Returns true when the request was an API request (answered here). */
155
+ /* This run of the server: a page's count of binder changes is of one run, and starts again with the next. */
156
+ const BOOT = Math.random().toString(36).slice(2, 10);
157
+
155
158
  export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups) {
156
159
  const { pathname } = new URL(request.url ?? '/', 'http://local');
157
160
  if (!pathname.startsWith('/api/')) return false;
@@ -300,7 +303,7 @@ export async function handleApi(request, response, conversations, headers, resou
300
303
  if (pathname === '/api/wifi/scan' && wifi) return send(200, await wifi.scan()), true;
301
304
  if (pathname === '/api/meshcentral' && meshcentral) return send(200, await meshcentral.status()), true;
302
305
  if (pathname === '/api/operators') return send(200, team ? { operators: team.list(), me: identity } : { local: true }), true;
303
- if (pathname === '/api/binder/people' && binders) return send(200, { people: binders.people(identity), changes: binders.changes() }), true;
306
+ if (pathname === '/api/binder/people' && binders) return send(200, { people: binders.people(identity), changes: `${BOOT}:${binders.changes()}` }), true;
304
307
  if (pathname === '/api/certificate' && certificate) return send(200, await certificate.about({ fresh: query.get('fresh') === '1' })), true;
305
308
  /* This server's disk and memory (capacity.mjs): everything for Settings; only whether it is high for the list. */
306
309
  if (pathname === '/api/server' && capacity) return send(200, await capacity.about()), true;
package/web/app.js CHANGED
@@ -4834,18 +4834,26 @@
4834
4834
  if (!repo || !rest) return;
4835
4835
  void openGit(repo, kind === 'commit' ? { commit: rest } : { branch: rest });
4836
4836
  }
4837
+ /* Read again every screen of a binder when the binders changed. Taken as seen only once every
4838
+ screen read it again: one that failed (the server restarting) is read again at the next turn. */
4839
+ async function catchUpBinders() {
4840
+ const now = await getJson('/binder/people', null);
4841
+ if (!now) return;
4842
+ binderPeople = now.people;
4843
+ if (now.changes === binderChanges) return;
4844
+ const read = await Promise.all([...binderViews].map((one) => Promise.resolve(one.view.refresh()).then((ok) => ok !== false, () => false)));
4845
+ if (read.every(Boolean)) binderChanges = now.changes;
4846
+ }
4837
4847
  function watchBinders() {
4838
4848
  if (binderTimer) return;
4839
- binderTimer = setInterval(async () => {
4849
+ binderTimer = setInterval(() => {
4840
4850
  for (const one of binderViews) if (!one.box?.isConnected) { one.view.destroy(); binderViews.delete(one); }
4841
4851
  if (binderViews.size === 0) { clearInterval(binderTimer); binderTimer = null; return; }
4842
- if (document.hidden) return;
4843
- const now = await getJson('/binder/people', null);
4844
- if (!now) return;
4845
- binderPeople = now.people;
4846
- if (now.changes !== binderChanges) { binderChanges = now.changes; for (const one of binderViews) void one.view.refresh(); }
4852
+ if (!document.hidden) void catchUpBinders();
4847
4853
  }, 4000);
4848
4854
  }
4855
+ /* Back on the page (a tablet woken, a tab shown again): looked at at once, not 4 s later. */
4856
+ document.addEventListener('visibilitychange', () => { if (!document.hidden && binderViews.size) void catchUpBinders(); });
4849
4857
  /* WHERE A BINDER IS, IN THIS PAGE'S BACK: a card (or a binder's settings) is one step over
4850
4858
  its list; Back, Escape and its "‹" close it, and the list is there again. Another binder
4851
4859
  picked takes no step. `viewOf()`: the screen shown now (it may be drawn again).