@couch-kit/client 0.15.0 → 0.16.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 +20 -0
- package/dist/index.js +10 -1
- package/lib/assets.d.ts.map +1 -1
- package/lib/relay-protocol.d.ts +43 -2
- package/lib/relay-protocol.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/assets.ts +5 -1
- package/src/relay-protocol.ts +46 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @couch-kit/client
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#210](https://github.com/faluciano/react-native-couch-kit/pull/210) [`0810bd2`](https://github.com/faluciano/react-native-couch-kit/commit/0810bd28a55fca11eb780c9ba19e3c8e17d4086d) Thanks [@faluciano](https://github.com/faluciano)! - Relay protocol support for display resumption. `CreateRoomMessage` gains an optional `resumeToken` and `RoomCreatedMessage` carries one. New in this release:
|
|
8
|
+
|
|
9
|
+
- the `ROOM_RESUMED` message type (`RoomResumedMessage`, which lists the phones still in the room)
|
|
10
|
+
- the `RELAY_CLOSE_HOST_REPLACED` (4002) close code
|
|
11
|
+
- `RELAY_HOST_RESUME_GRACE_MS` (30 seconds)
|
|
12
|
+
|
|
13
|
+
Phones need no change. They stay connected while a display reconnects.
|
|
14
|
+
|
|
15
|
+
## 0.15.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#208](https://github.com/faluciano/react-native-couch-kit/pull/208) [`f4b57e3`](https://github.com/faluciano/react-native-couch-kit/commit/f4b57e3fba385d18396781d22a413a1d8afcb909) Thanks [@faluciano](https://github.com/faluciano)! - `usePreload` counts an HTTP error response (a 404, say) as a failed asset. Before, any response that arrived counted as loaded, so a missing sound file came back as `loaded: true` with an empty `failedAssets`.
|
|
20
|
+
- Updated dependencies [[`99598d6`](https://github.com/faluciano/react-native-couch-kit/commit/99598d6796b0bd3042aa9f3fbd3bf44ee891b890)]:
|
|
21
|
+
- @couch-kit/core@0.10.1
|
|
22
|
+
|
|
3
23
|
## 0.15.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -399,6 +399,7 @@ function useGameClient(config) {
|
|
|
399
399
|
var RelayMessageTypes = {
|
|
400
400
|
CREATE_ROOM: "CREATE_ROOM",
|
|
401
401
|
ROOM_CREATED: "ROOM_CREATED",
|
|
402
|
+
ROOM_RESUMED: "ROOM_RESUMED",
|
|
402
403
|
JOIN_ROOM: "JOIN_ROOM",
|
|
403
404
|
ROOM_JOINED: "ROOM_JOINED",
|
|
404
405
|
PEER_JOINED: "PEER_JOINED",
|
|
@@ -419,6 +420,8 @@ var RelayErrorCodes = {
|
|
|
419
420
|
HOST_LEFT: "HOST_LEFT"
|
|
420
421
|
};
|
|
421
422
|
var RELAY_CLOSE_HOST_LEFT = 4001;
|
|
423
|
+
var RELAY_CLOSE_HOST_REPLACED = 4002;
|
|
424
|
+
var RELAY_HOST_RESUME_GRACE_MS = 30000;
|
|
422
425
|
function relayRoomUrl(url, roomId) {
|
|
423
426
|
const trimmed = url.replace(/\/+$/, "");
|
|
424
427
|
const [base, query] = trimmed.split("?", 2);
|
|
@@ -641,7 +644,11 @@ function usePreload(assets, sendMessage) {
|
|
|
641
644
|
};
|
|
642
645
|
img.src = src;
|
|
643
646
|
} else {
|
|
644
|
-
fetch(src).then(
|
|
647
|
+
fetch(src).then((response) => {
|
|
648
|
+
if (!response.ok)
|
|
649
|
+
failed.push(src);
|
|
650
|
+
tick();
|
|
651
|
+
}).catch(() => {
|
|
645
652
|
failed.push(src);
|
|
646
653
|
tick();
|
|
647
654
|
});
|
|
@@ -713,6 +720,8 @@ function useDebugPanel(options) {
|
|
|
713
720
|
export {
|
|
714
721
|
DEFAULT_OPTIMISTIC_TIMEOUT,
|
|
715
722
|
RELAY_CLOSE_HOST_LEFT,
|
|
723
|
+
RELAY_CLOSE_HOST_REPLACED,
|
|
724
|
+
RELAY_HOST_RESUME_GRACE_MS,
|
|
716
725
|
RELAY_MINT_PATH,
|
|
717
726
|
RelayClientTransport,
|
|
718
727
|
RelayErrorCodes,
|
package/lib/assets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAcD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,GAC9D,aAAa,
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAcD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EAAE,EAChB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,GAC9D,aAAa,CAsFf"}
|
package/lib/relay-protocol.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare const RelayMessageTypes: {
|
|
|
17
17
|
readonly CREATE_ROOM: "CREATE_ROOM";
|
|
18
18
|
/** Relay → display: room created; includes the display's own `peerId`. */
|
|
19
19
|
readonly ROOM_CREATED: "ROOM_CREATED";
|
|
20
|
+
/** Relay → display: a dropped display took its room back; lists the phones still in it. */
|
|
21
|
+
readonly ROOM_RESUMED: "ROOM_RESUMED";
|
|
20
22
|
/** Phone → relay: join an existing room. */
|
|
21
23
|
readonly JOIN_ROOM: "JOIN_ROOM";
|
|
22
24
|
/** Relay → phone: joined; includes the phone's assigned `peerId`. */
|
|
@@ -57,17 +59,56 @@ export declare const RelayErrorCodes: {
|
|
|
57
59
|
* phones are dropped with it.
|
|
58
60
|
*/
|
|
59
61
|
export declare const RELAY_CLOSE_HOST_LEFT = 4001;
|
|
62
|
+
/**
|
|
63
|
+
* WebSocket close code the relay sends a host connection that another
|
|
64
|
+
* connection has resumed the room from — typically the display's own previous
|
|
65
|
+
* socket, which the relay had not yet noticed was dead.
|
|
66
|
+
*/
|
|
67
|
+
export declare const RELAY_CLOSE_HOST_REPLACED = 4002;
|
|
68
|
+
/**
|
|
69
|
+
* How long the relay keeps a room whose display dropped without closing its
|
|
70
|
+
* socket, waiting for it to resume. Phones stay connected meanwhile, and what
|
|
71
|
+
* they send is held for the display (up to a bound).
|
|
72
|
+
*/
|
|
73
|
+
export declare const RELAY_HOST_RESUME_GRACE_MS = 30000;
|
|
60
74
|
export type RelayErrorCode = (typeof RelayErrorCodes)[keyof typeof RelayErrorCodes];
|
|
61
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Display → relay: create and host a room — or, with `resumeToken`, take back
|
|
77
|
+
* a room this display was hosting before its connection dropped.
|
|
78
|
+
*/
|
|
62
79
|
export interface CreateRoomMessage {
|
|
63
80
|
type: typeof RelayMessageTypes.CREATE_ROOM;
|
|
64
81
|
roomId: string;
|
|
82
|
+
/**
|
|
83
|
+
* The token from this room's {@link RoomCreatedMessage}. Present only when
|
|
84
|
+
* resuming; the relay then answers {@link RoomResumedMessage}, or
|
|
85
|
+
* `ROOM_NOT_FOUND` if the room has already gone.
|
|
86
|
+
*/
|
|
87
|
+
resumeToken?: string;
|
|
65
88
|
}
|
|
66
89
|
/** Relay → display: room created; `peerId` is the display's own id. */
|
|
67
90
|
export interface RoomCreatedMessage {
|
|
68
91
|
type: typeof RelayMessageTypes.ROOM_CREATED;
|
|
69
92
|
roomId: string;
|
|
70
93
|
peerId: string;
|
|
94
|
+
/**
|
|
95
|
+
* The credential for resuming this room after a dropped connection. Sent
|
|
96
|
+
* only to the host; anyone holding it can take the room over. Absent from
|
|
97
|
+
* relays that predate resumption.
|
|
98
|
+
*/
|
|
99
|
+
resumeToken?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Relay → display: the room is this connection's again. `peers` are the phones
|
|
103
|
+
* in the room now — phones that left while the display was away are not in
|
|
104
|
+
* it, and phones that arrived are. Anything phones sent meanwhile follows as
|
|
105
|
+
* ordinary `DATA` frames.
|
|
106
|
+
*/
|
|
107
|
+
export interface RoomResumedMessage {
|
|
108
|
+
type: typeof RelayMessageTypes.ROOM_RESUMED;
|
|
109
|
+
roomId: string;
|
|
110
|
+
peerId: string;
|
|
111
|
+
peers: string[];
|
|
71
112
|
}
|
|
72
113
|
/** Phone → relay: join an existing room. */
|
|
73
114
|
export interface JoinRoomMessage {
|
|
@@ -136,7 +177,7 @@ export interface RelayErrorMessage {
|
|
|
136
177
|
/** Any message a client may send to the relay. */
|
|
137
178
|
export type RelayClientMessage = CreateRoomMessage | JoinRoomMessage | DataMessage | DataMultiMessage;
|
|
138
179
|
/** Any message the relay may send to a client. */
|
|
139
|
-
export type RelayServerMessage = RoomCreatedMessage | RoomJoinedMessage | PeerJoinedMessage | PeerLeftMessage | DataMessage | RelayErrorMessage;
|
|
180
|
+
export type RelayServerMessage = RoomCreatedMessage | RoomResumedMessage | RoomJoinedMessage | PeerJoinedMessage | PeerLeftMessage | DataMessage | RelayErrorMessage;
|
|
140
181
|
/** Every relay wire message. */
|
|
141
182
|
export type RelayMessage = RelayClientMessage | RelayServerMessage;
|
|
142
183
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-protocol.d.ts","sourceRoot":"","sources":["../src/relay-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB;IAC5B,8DAA8D;aAC9D,WAAW,EAAE,aAAa;IAC1B,0EAA0E;aAC1E,YAAY,EAAE,cAAc;IAC5B,4CAA4C;aAC5C,SAAS,EAAE,WAAW;IACtB,qEAAqE;aACrE,WAAW,EAAE,aAAa;IAC1B,gDAAgD;aAChD,WAAW,EAAE,aAAa;IAC1B,8CAA8C;aAC9C,SAAS,EAAE,WAAW;IACtB,yEAAyE;aACzE,IAAI,EAAE,MAAM;IACZ,yEAAyE;aACzE,UAAU,EAAE,YAAY;IACxB,6CAA6C;aAC7C,KAAK,EAAE,OAAO;CACN,CAAC;AAEX,wEAAwE;AACxE,eAAO,MAAM,eAAe;aAC1B,cAAc,EAAE,gBAAgB;aAChC,WAAW,EAAE,aAAa;aAC1B,SAAS,EAAE,WAAW;aACtB,WAAW,EAAE,aAAa;aAC1B,iBAAiB,EAAE,mBAAmB;aACtC,SAAS,EAAE,WAAW;IACtB,yEAAyE;aACzE,YAAY,EAAE,cAAc;IAC5B,qCAAqC;aACrC,WAAW,EAAE,aAAa;IAC1B;;;;;OAKG;aACH,SAAS,EAAE,WAAW;CACd,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"relay-protocol.d.ts","sourceRoot":"","sources":["../src/relay-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB;IAC5B,8DAA8D;aAC9D,WAAW,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,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;IACrC,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAC5B,iBAAiB,GAAG,eAAe,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAEvE,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,iBAAiB,CAAC;AAEtB,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAQjE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@couch-kit/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"clean": "rm -rf dist lib"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@couch-kit/core": "0.10.
|
|
52
|
+
"@couch-kit/core": "0.10.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@happy-dom/global-registrator": "^20.10.6",
|
package/src/assets.ts
CHANGED
|
@@ -100,7 +100,11 @@ export function usePreload(
|
|
|
100
100
|
img.src = src;
|
|
101
101
|
} else {
|
|
102
102
|
fetch(src)
|
|
103
|
-
.then(
|
|
103
|
+
.then((response) => {
|
|
104
|
+
// fetch resolves on any HTTP response; a 404 is still a failure.
|
|
105
|
+
if (!response.ok) failed.push(src);
|
|
106
|
+
tick();
|
|
107
|
+
})
|
|
104
108
|
.catch(() => {
|
|
105
109
|
failed.push(src);
|
|
106
110
|
tick();
|
package/src/relay-protocol.ts
CHANGED
|
@@ -18,6 +18,8 @@ export const RelayMessageTypes = {
|
|
|
18
18
|
CREATE_ROOM: "CREATE_ROOM",
|
|
19
19
|
/** Relay → display: room created; includes the display's own `peerId`. */
|
|
20
20
|
ROOM_CREATED: "ROOM_CREATED",
|
|
21
|
+
/** Relay → display: a dropped display took its room back; lists the phones still in it. */
|
|
22
|
+
ROOM_RESUMED: "ROOM_RESUMED",
|
|
21
23
|
/** Phone → relay: join an existing room. */
|
|
22
24
|
JOIN_ROOM: "JOIN_ROOM",
|
|
23
25
|
/** Relay → phone: joined; includes the phone's assigned `peerId`. */
|
|
@@ -61,13 +63,36 @@ export const RelayErrorCodes = {
|
|
|
61
63
|
*/
|
|
62
64
|
export const RELAY_CLOSE_HOST_LEFT = 4001;
|
|
63
65
|
|
|
66
|
+
/**
|
|
67
|
+
* WebSocket close code the relay sends a host connection that another
|
|
68
|
+
* connection has resumed the room from — typically the display's own previous
|
|
69
|
+
* socket, which the relay had not yet noticed was dead.
|
|
70
|
+
*/
|
|
71
|
+
export const RELAY_CLOSE_HOST_REPLACED = 4002;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* How long the relay keeps a room whose display dropped without closing its
|
|
75
|
+
* socket, waiting for it to resume. Phones stay connected meanwhile, and what
|
|
76
|
+
* they send is held for the display (up to a bound).
|
|
77
|
+
*/
|
|
78
|
+
export const RELAY_HOST_RESUME_GRACE_MS = 30_000;
|
|
79
|
+
|
|
64
80
|
export type RelayErrorCode =
|
|
65
81
|
(typeof RelayErrorCodes)[keyof typeof RelayErrorCodes];
|
|
66
82
|
|
|
67
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Display → relay: create and host a room — or, with `resumeToken`, take back
|
|
85
|
+
* a room this display was hosting before its connection dropped.
|
|
86
|
+
*/
|
|
68
87
|
export interface CreateRoomMessage {
|
|
69
88
|
type: typeof RelayMessageTypes.CREATE_ROOM;
|
|
70
89
|
roomId: string;
|
|
90
|
+
/**
|
|
91
|
+
* The token from this room's {@link RoomCreatedMessage}. Present only when
|
|
92
|
+
* resuming; the relay then answers {@link RoomResumedMessage}, or
|
|
93
|
+
* `ROOM_NOT_FOUND` if the room has already gone.
|
|
94
|
+
*/
|
|
95
|
+
resumeToken?: string;
|
|
71
96
|
}
|
|
72
97
|
|
|
73
98
|
/** Relay → display: room created; `peerId` is the display's own id. */
|
|
@@ -75,6 +100,25 @@ export interface RoomCreatedMessage {
|
|
|
75
100
|
type: typeof RelayMessageTypes.ROOM_CREATED;
|
|
76
101
|
roomId: string;
|
|
77
102
|
peerId: string;
|
|
103
|
+
/**
|
|
104
|
+
* The credential for resuming this room after a dropped connection. Sent
|
|
105
|
+
* only to the host; anyone holding it can take the room over. Absent from
|
|
106
|
+
* relays that predate resumption.
|
|
107
|
+
*/
|
|
108
|
+
resumeToken?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Relay → display: the room is this connection's again. `peers` are the phones
|
|
113
|
+
* in the room now — phones that left while the display was away are not in
|
|
114
|
+
* it, and phones that arrived are. Anything phones sent meanwhile follows as
|
|
115
|
+
* ordinary `DATA` frames.
|
|
116
|
+
*/
|
|
117
|
+
export interface RoomResumedMessage {
|
|
118
|
+
type: typeof RelayMessageTypes.ROOM_RESUMED;
|
|
119
|
+
roomId: string;
|
|
120
|
+
peerId: string;
|
|
121
|
+
peers: string[];
|
|
78
122
|
}
|
|
79
123
|
|
|
80
124
|
/** Phone → relay: join an existing room. */
|
|
@@ -155,6 +199,7 @@ export type RelayClientMessage =
|
|
|
155
199
|
/** Any message the relay may send to a client. */
|
|
156
200
|
export type RelayServerMessage =
|
|
157
201
|
| RoomCreatedMessage
|
|
202
|
+
| RoomResumedMessage
|
|
158
203
|
| RoomJoinedMessage
|
|
159
204
|
| PeerJoinedMessage
|
|
160
205
|
| PeerLeftMessage
|