jsflow-sdk 1.1.1 → 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 +56 -0
- package/README.md +1 -1
- package/jsflow.js +2 -2
- package/package.json +1 -1
- package/sri.json +3 -3
- package/worker.js +16 -7
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,62 @@ 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
|
+
|
|
30
|
+
## [1.1.2] - 2026-11-22
|
|
31
|
+
|
|
32
|
+
A patch under the npm tag `latest`. Nothing in the API changes (`jsflow.d.ts`
|
|
33
|
+
is byte-identical to 1.1.1's), the wire version is still 2, and the messages
|
|
34
|
+
on the wire are the same bytes; peers on 1.1.0, 1.1.1 and 1.1.2 share a room.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **A peer whose links are slow (a relay far away) no longer goes silent for
|
|
39
|
+
seconds after someone joins.** Each peer worked out routes from the link
|
|
40
|
+
delays every peer announces, except for its own links, where it used the
|
|
41
|
+
delay it had measured. A new link is announced at 50 ms until its first
|
|
42
|
+
refresh, 10 s later; on a link through a distant relay (200 ms and more) the
|
|
43
|
+
two ends of a route each saw the other's way as shorter and passed messages
|
|
44
|
+
back and forth until they expired. A peer now costs its own links from the
|
|
45
|
+
announced delays too, so every peer agrees on the routes.
|
|
46
|
+
|
|
47
|
+
Measured on staging, one Chrome with 8 peers per room joined through the
|
|
48
|
+
US entry (relay-only peers among them): before, 30 pauses of 1.5 to 5.5 s
|
|
49
|
+
between messages from one peer and 800 packets dropped in loops; with
|
|
50
|
+
1.1.2, the same rooms: none of either, and every reliable message arrived
|
|
51
|
+
once. Through the EU entry there were none before either. In the
|
|
52
|
+
simulator, with relayed links 75 to 125 ms slower each way: before, every
|
|
53
|
+
seed looped (a relay-only peer silent up to 7.0 s); now none.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Routes are chosen a little differently, so latencies in the simulator move
|
|
58
|
+
within the limits the tests hold them to: a heavy stream at 5 % loss,
|
|
59
|
+
median 25 to 32 ms and 99th percentile 743 to 615 ms; ordinary traffic,
|
|
60
|
+
99th percentile 282 to 288 ms; under reordering, 247 to 265 ms; a transfer
|
|
61
|
+
whose route changes through another peer, median 647 to 137 ms. A new link
|
|
62
|
+
is routed at its announced 50 ms until its refresh, as every other peer
|
|
63
|
+
already did.
|
|
64
|
+
|
|
9
65
|
## [1.1.1] - 2026-11-22
|
|
10
66
|
|
|
11
67
|
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.
|
|
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.
|
|
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.
|
|
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
package/sri.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
3
|
-
"jsflow.js": "sha384-
|
|
4
|
-
"worker.js": "sha384-
|
|
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.
|
|
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;
|
|
@@ -416,8 +416,8 @@ function meshNode(opts = {}) {
|
|
|
416
416
|
if (routes) return routes;
|
|
417
417
|
const dist = /* @__PURE__ */ new Map([[me, 0]]), first = /* @__PURE__ */ new Map(), done = /* @__PURE__ */ new Set();
|
|
418
418
|
const cost = (a, b) => {
|
|
419
|
-
if (a === me) return nbr.get(b)?.rtt ?? 50;
|
|
420
419
|
const ra = lsdb.get(a)?.links.get(b), rb = lsdb.get(b)?.links.get(a);
|
|
420
|
+
if (a === me) return ra !== void 0 && rb !== void 0 ? (ra + rb) / 2 : nbr.get(b)?.rtt ?? 50;
|
|
421
421
|
if (ra === void 0 || rb === void 0) return Infinity;
|
|
422
422
|
const w = lsdb.get(a)?.will ?? 7;
|
|
423
423
|
return (ra + rb) / 2 + 0.5 + (w === 0 ? 1e3 : (15 - w) * 2);
|
|
@@ -867,7 +867,10 @@ function meshNode(opts = {}) {
|
|
|
867
867
|
}
|
|
868
868
|
function hello() {
|
|
869
869
|
every(o.helloMs, hello);
|
|
870
|
-
if (leaving)
|
|
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
|
|
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
|
},
|