jsflow-sdk 1.0.0-rc.3 → 1.0.0

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,42 +6,12 @@ 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.0.0-rc.3] - 2026-11-18
10
-
11
- The third release candidate for 1.0.0, under the npm tag `next` as before.
12
-
13
- ### Fixed
14
- - **Two peers no longer fail to link for 10 seconds or more when one joins
15
- through the other while the other is also trying to reach it.** A peer
16
- joining (or rejoining) a room through another member's waiting offer
17
- could, if that member also reached out to it at the same moment, send its
18
- reply to the wrong place, give up on the member's connection after 4
19
- seconds, and hold back from it for another 10. Both then waited without an
20
- error until their attempts timed out. It was most likely with a relay
21
- (TURN) configured, as in production, where a connection takes up to 1.5
22
- seconds to prepare. Nothing changes on the wire or in the API.
23
-
24
- ## [1.0.0-rc.2] - 2026-11-18
25
-
26
- The second release candidate for 1.0.0, under the npm tag `next` as before.
27
-
28
- ### Fixed
29
- - **A reliable message is never delivered twice across a page reload.** If a
30
- receiver got a `sendReliable()` message, then reloaded (or restarted)
31
- before its acknowledgement reached the sender (for example while the
32
- sender's page was hidden), the sender's retransmission could reach the
33
- receiver's new page as well. The new page now drops it, and the sender
34
- gets `undelivered` for it, as for any message whose delivery it cannot
35
- confirm. Nothing changes on the wire.
36
-
37
- ## [1.0.0-rc.1] - 2026-11-18
38
-
39
- The release candidate for 1.0.0: everything listed under 1.0.0 below. Published under the npm tag `next`
40
- (`npm install jsflow-sdk@next`); `npm install jsflow-sdk` keeps the stable release.
41
-
42
- ## [1.0.0] - unreleased
9
+ ## [1.0.0] - 2026-11-19
43
10
 
44
- The first stable API, on wire version 2.
11
+ The first stable API, on wire version 2, under the npm tag `latest`
12
+ (`npm install jsflow-sdk`). The code is 1.0.0-rc.3's: since rc.3 only the
13
+ documentation comments in `jsflow.d.ts` changed (the spend cap is the
14
+ account's, and the examples fit 72 columns).
45
15
 
46
16
  ### Migrating from 0.1.x
47
17
 
@@ -143,3 +113,36 @@ The first stable API, on wire version 2.
143
113
  ### Removed
144
114
  - Lab-only options and methods (`lab`, `want`, `pool`, `target`, `max`,
145
115
  `room.lab()`).
116
+
117
+ ## [1.0.0-rc.3] - 2026-11-18
118
+
119
+ The third release candidate for 1.0.0, under the npm tag `next` as before.
120
+
121
+ ### Fixed
122
+ - **Two peers no longer fail to link for 10 seconds or more when one joins
123
+ through the other while the other is also trying to reach it.** A peer
124
+ joining (or rejoining) a room through another member's waiting offer
125
+ could, if that member also reached out to it at the same moment, send its
126
+ reply to the wrong place, give up on the member's connection after 4
127
+ seconds, and hold back from it for another 10. Both then waited without an
128
+ error until their attempts timed out. It was most likely with a relay
129
+ (TURN) configured, as in production, where a connection takes up to 1.5
130
+ seconds to prepare. Nothing changes on the wire or in the API.
131
+
132
+ ## [1.0.0-rc.2] - 2026-11-18
133
+
134
+ The second release candidate for 1.0.0, under the npm tag `next` as before.
135
+
136
+ ### Fixed
137
+ - **A reliable message is never delivered twice across a page reload.** If a
138
+ receiver got a `sendReliable()` message, then reloaded (or restarted)
139
+ before its acknowledgement reached the sender (for example while the
140
+ sender's page was hidden), the sender's retransmission could reach the
141
+ receiver's new page as well. The new page now drops it, and the sender
142
+ gets `undelivered` for it, as for any message whose delivery it cannot
143
+ confirm. Nothing changes on the wire.
144
+
145
+ ## [1.0.0-rc.1] - 2026-11-18
146
+
147
+ The release candidate for 1.0.0: everything listed under 1.0.0 above. Published under the npm tag `next`
148
+ (`npm install jsflow-sdk@next`); `npm install jsflow-sdk` keeps the stable release.
package/jsflow.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * The signalling service join() uses unless given another.
5
5
  * @since 1.0.0
6
6
  * @example
7
- * const room = await join({ app: 'pk_…', room: 'lobby' }); // uses SERVER
7
+ * // uses SERVER
8
+ * const room = await join({ app: 'pk_…', room: 'lobby' });
8
9
  */
9
10
  export const SERVER: string;
10
11
  /**
@@ -18,14 +19,16 @@ export const SDK_VERSION: string;
18
19
  * The wire version this SDK speaks. A room runs one: a peer of the other gets JoinError code 'wire'.
19
20
  * @since 1.0.0
20
21
  * @example
21
- * const roomName = `game-${id}-w${WIRE}`; // a room per wire version during an upgrade
22
+ * // a room per wire version during an upgrade
23
+ * const roomName = `game-${id}-w${WIRE}`;
22
24
  */
23
25
  export const WIRE: 2;
24
26
  /**
25
27
  * Bytes of app data per send() / broadcast() (1099 in 0.1.x).
26
28
  * @since 1.0.0
27
29
  * @example
28
- * if (bytes.length > MAX_DATAGRAM) await room.sendReliable(to, bytes); else room.send(to, bytes);
30
+ * if (bytes.length > MAX_DATAGRAM) await room.sendReliable(to, bytes);
31
+ * else room.send(to, bytes);
29
32
  */
30
33
  export const MAX_DATAGRAM: 1052;
31
34
  /**
@@ -47,7 +50,9 @@ export type Data = Uint8Array | ArrayBuffer | string;
47
50
  * A peer's id in the room: an integer the service assigns at each join.
48
51
  * @since 1.0.0
49
52
  * @example
50
- * room.on('peer', (id: PeerId, up) => console.log(id, up ? 'joined' : 'left'));
53
+ * room.on('peer', (id: PeerId, up) => {
54
+ * console.log(id, up ? 'joined' : 'left');
55
+ * });
51
56
  */
52
57
  export type PeerId = number;
53
58
  /**
@@ -61,10 +66,12 @@ export type Channel = number;
61
66
  /**
62
67
  * Where this peer is. 'away': its page is hidden (phones, desktop Safari) and it holds no slot;
63
68
  * 'superseded': a newer tab with the same id took over; 'evicted': the app's backend removed it;
64
- * 'suspended': the app's cost cap is reached (links kept, joins refused); 'left': leave() was called.
69
+ * 'suspended': the account's spend cap is reached (links kept, joins refused); 'left': leave() was called.
65
70
  * @since 1.0.0
66
71
  * @example
67
- * room.on('state', (s: State) => { if (s === 'suspended') showBanner('Paused: the app is over its plan'); });
72
+ * room.on('state', (s: State) => {
73
+ * if (s === 'suspended') showBanner('Paused: the app is over its plan');
74
+ * });
68
75
  */
69
76
  export type State =
70
77
  /** join() is connecting: the service admitted this peer, its first links are forming. */
@@ -77,7 +84,7 @@ export type State =
77
84
  | 'superseded'
78
85
  /** The app's backend removed this peer (see the 'evicted' event); it has stopped for good. */
79
86
  | 'evicted'
80
- /** The app's cost cap is reached: links are kept, but no new peer can join the app until the cap is raised (see the 'suspended' event). */
87
+ /** The account's spend cap is reached: links stay up, but new joins to the account's apps are refused ('quota') until an owner raises the cap or the next period starts (see the 'suspended' event). */
81
88
  | 'suspended'
82
89
  /** leave() was called. */
83
90
  | 'left';
@@ -86,7 +93,9 @@ export type State =
86
93
  * How a message was sent.
87
94
  * @since 1.0.0
88
95
  * @example
89
- * room.on('message', (from, data, info: MessageInfo) => { if (info.reliable) apply(text(data)); });
96
+ * room.on('message', (from, data, info: MessageInfo) => {
97
+ * if (info.reliable) apply(text(data));
98
+ * });
90
99
  */
91
100
  export interface MessageInfo {
92
101
  /** The channel it was sent on (0–13; 0 unless the sender chose another). */
@@ -101,7 +110,10 @@ export interface MessageInfo {
101
110
  * A region jsflow runs signalling and relays in: Stockholm (`eu-north-1`) or Ohio (`us-east-2`).
102
111
  * @since 1.0.0
103
112
  * @example
104
- * const room = await join({ app: 'pk_…', room: 'round-42', region: 'eu-north-1' }); // an EU-pinned app
113
+ * // an EU-pinned app
114
+ * const room = await join({
115
+ * app: 'pk_…', room: 'round-42', region: 'eu-north-1',
116
+ * });
105
117
  */
106
118
  export type Region = 'eu-north-1' | 'us-east-2';
107
119
 
@@ -109,7 +121,12 @@ export type Region = 'eu-north-1' | 'us-east-2';
109
121
  * What join() needs.
110
122
  * @since 1.0.0
111
123
  * @example
112
- * const opts: JoinOptions = { app: 'pk_…', room: 'round-42', ticket: () => fetch('/ticket', { method: 'POST' }).then((r) => r.text()) };
124
+ * const opts: JoinOptions = {
125
+ * app: 'pk_…',
126
+ * room: 'round-42',
127
+ * ticket: () =>
128
+ * fetch('/ticket', { method: 'POST' }).then((r) => r.text()),
129
+ * };
113
130
  */
114
131
  export interface JoinOptions {
115
132
  /** The app's publishable key ("pk_…"), from the dashboard. The page's origin must be one the app allows. */
@@ -182,7 +199,7 @@ export interface Room {
182
199
  on(ev: 'error', f: (e: Error) => void): this;
183
200
  /** The app's backend removed this peer; every other peer has cut it off. Joining again is refused (code 'blocked') until `until` (unix s). */
184
201
  on(ev: 'evicted', f: (info: { until: number }) => void): this;
185
- /** The app's cost cap is reached (the service said so in a signed notice at this peer's refresh). Links are kept; new joins to the app are refused (402 'quota') until the cap is raised; the state returns to 'connected' after a refresh without the notice. */
202
+ /** The account's spend cap is reached (the service said so in a signed notice at this peer's refresh). Links stay up, but new joins to the account's apps are refused (402 'quota') until an owner raises the cap or the next period starts; the state returns to 'connected' after a refresh without the notice. */
186
203
  on(ev: 'suspended', f: (info: { reason: 'quota' }) => void): this;
187
204
  /** Remove a listener added with on(): the same event name and the same function. */
188
205
  off(ev: string, f: (...a: any[]) => void): this;
@@ -267,8 +284,14 @@ export type ErrorCode =
267
284
  * 'quota'. A network failure rejects with a TypeError instead.
268
285
  * @since 1.0.0
269
286
  * @example
270
- * try { await join(opts); }
271
- * catch (e) { if (e instanceof JoinError && e.code === 'ticket_expired') return join({ ...opts, ticket: await fresh() }); throw e; }
287
+ * try {
288
+ * await join(opts);
289
+ * } catch (e) {
290
+ * if (e instanceof JoinError && e.code === 'ticket_expired') {
291
+ * return join({ ...opts, ticket: await fresh() });
292
+ * }
293
+ * throw e;
294
+ * }
272
295
  */
273
296
  export class JoinError extends Error {
274
297
  /** Always 'JoinError', so it survives a structured clone or a log line where instanceof does not. */
@@ -285,7 +308,12 @@ export class JoinError extends Error {
285
308
  * Join a room. Rejects with a JoinError if the service (or the SDK itself) refuses.
286
309
  * @since 1.0.0
287
310
  * @example
288
- * const room = await join({ app: 'pk_…', room: 'round-42', ticket: () => fetch('/ticket', { method: 'POST' }).then((r) => r.text()) });
311
+ * const room = await join({
312
+ * app: 'pk_…',
313
+ * room: 'round-42',
314
+ * ticket: () =>
315
+ * fetch('/ticket', { method: 'POST' }).then((r) => r.text()),
316
+ * });
289
317
  */
290
318
  export function join(opts: JoinOptions): Promise<Room>;
291
319
  /**
package/jsflow.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.0.0-rc.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.0.0. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/link-main.js
4
4
  function linkKind(stats) {
@@ -215,7 +215,7 @@ function ticketRegion(ticket) {
215
215
  return void 0;
216
216
  }
217
217
  }
218
- var SDK_VERSION = "1.0.0-rc.3";
218
+ var SDK_VERSION = "1.0.0";
219
219
  var WIRE = 2;
220
220
  var MAX_DATAGRAM = 1052;
221
221
  var MAX_RELIABLE = 65536;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsflow-sdk",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0",
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.0.0-rc.3",
3
- "jsflow.js": "sha384-R+KY9ySstq/BD2iK1rSeAi2cc7e/TvACrSegqTksn0hr1a4shMCRUy3Y8ZU2rz7R",
4
- "worker.js": "sha384-gHQ1l7u/ITLWPAt16wSLhVN9dZAYoh0DxJosUe9bt0Feft84eVIhrBHMT+BsZ8mS",
5
- "jsflow.d.ts": "sha384-ZQeEwggqNXnSnd25+7iK7oiLLI636vR16LRNPNflzbnxx/IsTmEsct592Eiq2mEg"
2
+ "version": "1.0.0",
3
+ "jsflow.js": "sha384-9ak4UNlO3ZaMWtzVXcCR5f6A8amo2mNxe61IE8UAmHv9ASKTjyAQJ70sd19jpY28",
4
+ "worker.js": "sha384-XMuPhWF0rckfgKkgs//zn+J1BMIGfatYL2BQra7RdXd8FAaOUCfBTczVjlD3GOBv",
5
+ "jsflow.d.ts": "sha384-6O9/JrVDLxYg34iUU/B+gVUlI/WS6/gyncTRbVRdt/9xx9r1L4bVNTZlw7jfR8Bi"
6
6
  }
package/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- // jsflow-sdk 1.0.0-rc.3. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
1
+ // jsflow-sdk 1.0.0. Licence: see LICENSE (https://jsflow.com). Built by client/build.js.
2
2
 
3
3
  // core/header.js
4
4
  var VERSION = 2;