@jsenv/core 41.4.7 → 41.4.8

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.
@@ -768,7 +768,9 @@ const parseUserAgentHeader = (userAgent) => {
768
768
  * - "clients_list" the whole registry (the dashboard renders it)
769
769
  * - "client_log" a single log line (a monitor appends it)
770
770
  * - "client_activity" a single qualified activity (a monitor appends it)
771
- * - "client_here" a client just appeared/resumed (every page can toast it)
771
+ * - "client_here" a networked client just appeared/resumed (every page
772
+ * can toast it); never sent for the main client, which
773
+ * is the person reading the toast
772
774
  * - "client_command" pilot one client (navigate/reload its tab) from the
773
775
  * dashboard; the matching reporter runs it
774
776
  * Server events are broadcast, so consumers filter what they care about.
@@ -783,7 +785,7 @@ const parseUserAgentHeader = (userAgent) => {
783
785
  *
784
786
  * The monitoring script is injected into EVERY cooked page, including our own
785
787
  * dashboard and monitor pages — so opening one of those counts as a connected
786
- * client, and any open page gets toasted when another client appears.
788
+ * client, and any open page gets toasted when another networked client appears.
787
789
  *
788
790
  * Pages:
789
791
  * - /.internal/clients → dashboard listing every client seen
@@ -1114,12 +1116,25 @@ const jsenvPluginClientMonitoring = () => {
1114
1116
  pruneTabs(client);
1115
1117
  pruneClients();
1116
1118
 
1117
- if (firstEver) {
1118
- sendClientHere({ reason: "new", client: serializeClient(client) });
1119
- sendClientsList();
1120
- } else if (!wasOnline) {
1121
- // A report after a long quiet spell means the client was picked back up.
1122
- sendClientHere({ reason: "resumed", client: serializeClient(client) });
1119
+ if (firstEver || !wasOnline) {
1120
+ // The toast invites the reader to monitor the client that just appeared,
1121
+ // so it is only worth showing for a client there is something to watch:
1122
+ // one reaching the server over the network. The machine running the dev
1123
+ // server is the person reading the toast it browses over localhost, its
1124
+ // devtools are one keystroke away and nothing is captured for it, so
1125
+ // announcing it means interrupting someone about themselves. It happens
1126
+ // more than one would think: the client id lives in localStorage, so the
1127
+ // same browser gets a fresh id per origin (localhost vs 127.0.0.1 vs the
1128
+ // LAN ip, another port) and in private windows, and each of those looks
1129
+ // like a brand new client to the server.
1130
+ if (!isLocalIp(client.ip)) {
1131
+ sendClientHere({
1132
+ // A report after a long quiet spell means the client was picked back
1133
+ // up rather than newly seen.
1134
+ reason: firstEver ? "new" : "resumed",
1135
+ client: serializeClient(client),
1136
+ });
1137
+ }
1123
1138
  sendClientsList();
1124
1139
  }
1125
1140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "41.4.7",
3
+ "version": "41.4.8",
4
4
  "type": "module",
5
5
  "description": "Tool to develop, test and build js projects",
6
6
  "repository": {
@@ -22,7 +22,9 @@
22
22
  * - "clients_list" the whole registry (the dashboard renders it)
23
23
  * - "client_log" a single log line (a monitor appends it)
24
24
  * - "client_activity" a single qualified activity (a monitor appends it)
25
- * - "client_here" a client just appeared/resumed (every page can toast it)
25
+ * - "client_here" a networked client just appeared/resumed (every page
26
+ * can toast it); never sent for the main client, which
27
+ * is the person reading the toast
26
28
  * - "client_command" pilot one client (navigate/reload its tab) from the
27
29
  * dashboard; the matching reporter runs it
28
30
  * Server events are broadcast, so consumers filter what they care about.
@@ -37,7 +39,7 @@
37
39
  *
38
40
  * The monitoring script is injected into EVERY cooked page, including our own
39
41
  * dashboard and monitor pages — so opening one of those counts as a connected
40
- * client, and any open page gets toasted when another client appears.
42
+ * client, and any open page gets toasted when another networked client appears.
41
43
  *
42
44
  * Pages:
43
45
  * - /.internal/clients → dashboard listing every client seen
@@ -370,12 +372,25 @@ export const jsenvPluginClientMonitoring = () => {
370
372
  pruneTabs(client);
371
373
  pruneClients();
372
374
 
373
- if (firstEver) {
374
- sendClientHere({ reason: "new", client: serializeClient(client) });
375
- sendClientsList();
376
- } else if (!wasOnline) {
377
- // A report after a long quiet spell means the client was picked back up.
378
- sendClientHere({ reason: "resumed", client: serializeClient(client) });
375
+ if (firstEver || !wasOnline) {
376
+ // The toast invites the reader to monitor the client that just appeared,
377
+ // so it is only worth showing for a client there is something to watch:
378
+ // one reaching the server over the network. The machine running the dev
379
+ // server is the person reading the toast it browses over localhost, its
380
+ // devtools are one keystroke away and nothing is captured for it, so
381
+ // announcing it means interrupting someone about themselves. It happens
382
+ // more than one would think: the client id lives in localStorage, so the
383
+ // same browser gets a fresh id per origin (localhost vs 127.0.0.1 vs the
384
+ // LAN ip, another port) and in private windows, and each of those looks
385
+ // like a brand new client to the server.
386
+ if (!isLocalIp(client.ip)) {
387
+ sendClientHere({
388
+ // A report after a long quiet spell means the client was picked back
389
+ // up rather than newly seen.
390
+ reason: firstEver ? "new" : "resumed",
391
+ client: serializeClient(client),
392
+ });
393
+ }
379
394
  sendClientsList();
380
395
  }
381
396