jsflow-sdk 1.1.2 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ All notable changes to `jsflow-sdk`. The format follows
6
6
  contract; metric names passed to `onMetric` are diagnostic and may change in
7
7
  any minor release.
8
8
 
9
+ ## [1.1.3] - 2026-11-24
10
+
11
+ A patch under the npm tag `latest`. Nothing in the API changes (`jsflow.d.ts`
12
+ is byte-identical to 1.1.2's), the wire version is still 2, and no message
13
+ changes its bytes: a hidden page sends its BYE more often. Peers on 1.1.0
14
+ to 1.1.3 share a room.
15
+
16
+ ### Fixed
17
+
18
+ - **A hidden page no longer stays "connected" at one of its peers while it is
19
+ away.** A phone page says goodbye (BYE) to its neighbours when it is hidden.
20
+ It said it once: a neighbour that never processed it (the link to it finished
21
+ setting up just after, or the page was held up before the message left) kept
22
+ the page reachable for the whole hide, because the page still passes on the
23
+ room's broadcasts and any message counted as a sign of life. That peer showed
24
+ no `'peer'` down, and an app's cursor or presence for the page stayed. The
25
+ BYE now repeats every hello interval (250 ms) until the page is shown, and
26
+ follows the first hello on a link that comes up while the page is hidden.
27
+ Peers on 1.1.2 and earlier handle the repeats as they did the first BYE; they
28
+ pass the `bye` metric to `onMetric` for each one.
29
+
9
30
  ## [1.1.2] - 2026-11-22
10
31
 
11
32
  A patch under the npm tag `latest`. Nothing in the API changes (`jsflow.d.ts`
package/README.md CHANGED
@@ -20,7 +20,7 @@ Or from the CDN, at an exact version with its integrity hash (`sri.json` in
20
20
  each version directory):
21
21
 
22
22
  ```html
23
- <script type="module" integrity="sha384-…" crossorigin src="https://cdn.jsflow.com/v1.1.2/jsflow.js"></script>
23
+ <script type="module" integrity="sha384-…" crossorigin src="https://cdn.jsflow.com/v1.1.3/jsflow.js"></script>
24
24
  ```
25
25
 
26
26
  The SDK starts a worker (`worker.js`, next to `jsflow.js`). Vite and webpack
package/jsflow.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.1.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.1.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/link-main.js
4
4
  function linkKind(stats) {
@@ -285,7 +285,7 @@ function ticketRegion(ticket) {
285
285
  return void 0;
286
286
  }
287
287
  }
288
- var SDK_VERSION = "1.1.2";
288
+ var SDK_VERSION = "1.1.3";
289
289
  var WIRE = 2;
290
290
  var MAX_DATAGRAM = 1052;
291
291
  var MAX_RELIABLE = 65536;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsflow-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "jsflow: peer-to-peer rooms for the browser (WebRTC mesh, signalling and relays as a service).",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
package/sri.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.1.2",
3
- "jsflow.js": "sha384-6iaDEfAX53o/sELinRUcwhyTPcO+v1yX9sXNJKhf8U7yEEPXiKMRzRSRvVortkTA",
4
- "worker.js": "sha384-59Il1fBPtlj1gK19+ZC7Ei361OucDLcAPFFKN2ozLC2RrRu5SOuHpS54+SDnQwOY",
2
+ "version": "1.1.3",
3
+ "jsflow.js": "sha384-sQqHAdflDDfP6VfM2G8YqC1hhovmh2U2eb+iNhq+HXfoNI4x/2SlOlIHl7T4mfwH",
4
+ "worker.js": "sha384-yNqRxZkG2fOu739pXTKLMPhEtxOIvafrJktt6sFGtMi1Bn8Z53y0AJPn9sxdJmGr",
5
5
  "jsflow.d.ts": "sha384-VM+jOFBiVG6Z3ElnDVldrvSTyha/lJh9kC8el+JL/77bYFOp6ScbTHFK2tCnFsN5"
6
6
  }
package/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.1.2. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.1.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/header.js
4
4
  var VERSION = 2;
@@ -867,7 +867,10 @@ function meshNode(opts = {}) {
867
867
  }
868
868
  function hello() {
869
869
  every(o.helloMs, hello);
870
- if (leaving) return;
870
+ if (leaving) {
871
+ for (const peer of nbr.keys()) sendBye(peer);
872
+ return;
873
+ }
871
874
  const now = env2.now();
872
875
  const deadMs = o.deadMs ?? o.missK * o.helloMs;
873
876
  for (const [peer, n] of [...nbr]) {
@@ -916,9 +919,15 @@ function meshNode(opts = {}) {
916
919
  n.echoTs = v.getUint32(0);
917
920
  n.echoAt = env2.now();
918
921
  }
922
+ function sendBye(peer) {
923
+ const p = new Uint8Array(4);
924
+ new DataView(p.buffer).setUint32(0, ts10());
925
+ env2.send(peer, P(T.BYE, peer, p, { ttl: 1 }));
926
+ }
919
927
  function onBye(peer, h2) {
920
928
  const n = nbr.get(peer);
921
929
  if (!n || h2.payload.length < 4) return;
930
+ const first = n.byeTs === void 0;
922
931
  const ts = new DataView(h2.payload.buffer, h2.payload.byteOffset, 4).getUint32(0), last = n.echoTs ?? 0;
923
932
  n.byeTs = ts - last >>> 0 < 1e5 ? ts : last;
924
933
  if (!n.sus) {
@@ -926,7 +935,7 @@ function meshNode(opts = {}) {
926
935
  routes = null;
927
936
  originateSoon();
928
937
  }
929
- env2.metric("bye", peer);
938
+ if (first) env2.metric("bye", peer);
930
939
  }
931
940
  function down(peer) {
932
941
  if (!nbr.delete(peer)) return;
@@ -1005,6 +1014,7 @@ function meshNode(opts = {}) {
1005
1014
  reject.delete(peer);
1006
1015
  nbr.set(peer, { lastHeard: env2.now(), rtt: null, echoTs: 0, echoAt: 0 });
1007
1016
  sendHello(peer, nbr.get(peer));
1017
+ if (leaving) sendBye(peer);
1008
1018
  for (const e of lsdb.values()) if (env2.now() - e.at < 2 * o.lsaRefreshMs) env2.send(peer, e.raw);
1009
1019
  routes = null;
1010
1020
  originateSoon();
@@ -1065,10 +1075,9 @@ function meshNode(opts = {}) {
1065
1075
  },
1066
1076
  // Announced leave (page hiding on a phone): BYE to every neighbour,
1067
1077
  // withdraw own links from the map, then stay silent until onWake.
1078
+ // The BYE repeats every hello interval until wake (hello()).
1068
1079
  bye() {
1069
- const p = new Uint8Array(4);
1070
- new DataView(p.buffer).setUint32(0, ts10());
1071
- for (const peer of nbr.keys()) env2.send(peer, P(T.BYE, peer, p, { ttl: 1 }));
1080
+ for (const peer of nbr.keys()) sendBye(peer);
1072
1081
  leaving = true;
1073
1082
  originate();
1074
1083
  },