@couch-kit/display 0.5.0 → 0.6.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 +13 -0
- package/dist/index.js +1 -0
- package/lib/relay-display-host.d.ts +13 -7
- package/lib/relay-display-host.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/relay-display-host.ts +15 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @couch-kit/display
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#208](https://github.com/faluciano/react-native-couch-kit/pull/208) [`99598d6`](https://github.com/faluciano/react-native-couch-kit/commit/99598d6796b0bd3042aa9f3fbd3bf44ee891b890) Thanks [@faluciano](https://github.com/faluciano)! - `RelayDisplayHost` gains `subscribeActions(listener)`, the runtime's complete action stream: the display's own dispatches, players' actions, and join/leave lifecycle actions. State updates are no longer sent through the relay while no phone has joined the game.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`f4b57e3`](https://github.com/faluciano/react-native-couch-kit/commit/f4b57e3fba385d18396781d22a413a1d8afcb909), [`99598d6`](https://github.com/faluciano/react-native-couch-kit/commit/99598d6796b0bd3042aa9f3fbd3bf44ee891b890), [`99598d6`](https://github.com/faluciano/react-native-couch-kit/commit/99598d6796b0bd3042aa9f3fbd3bf44ee891b890)]:
|
|
12
|
+
- @couch-kit/client@0.15.1
|
|
13
|
+
- @couch-kit/core@0.10.1
|
|
14
|
+
- @couch-kit/runtime@0.5.0
|
|
15
|
+
|
|
3
16
|
## 0.5.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,7 @@ class RelayDisplayHost {
|
|
|
72
72
|
}
|
|
73
73
|
getState = () => this.runtime.getState();
|
|
74
74
|
subscribe = (listener) => this.runtime.subscribe(listener);
|
|
75
|
+
subscribeActions = (listener) => this.runtime.subscribeActions(listener);
|
|
75
76
|
dispatch = (action) => this.runtime.dispatch(action);
|
|
76
77
|
stop() {
|
|
77
78
|
this.stopped = true;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { type GameHostRuntimeConfig } from "@couch-kit/runtime";
|
|
1
|
+
import { type GameHostRuntimeConfig, type RuntimeActionListener } from "@couch-kit/runtime";
|
|
2
2
|
import type { IGameState, IAction } from "@couch-kit/core";
|
|
3
3
|
import { type RelayErrorCode } from "@couch-kit/client";
|
|
4
4
|
/**
|
|
5
5
|
* Default minimum interval (ms) between state broadcasts through a relay.
|
|
6
6
|
*
|
|
7
|
-
* Slower than the LAN default on purpose:
|
|
8
|
-
*
|
|
9
|
-
* the socket —
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Slower than the LAN default on purpose: every frame the display sends is
|
|
8
|
+
* billed by the relay and counted against the display's rate limit, whose
|
|
9
|
+
* breach closes the socket — and, for the display, ends the room. 20
|
|
10
|
+
* broadcasts/second is smooth for a party game and leaves the display's budget
|
|
11
|
+
* (1200 messages/second on the reference relays) to the unicast replies it
|
|
12
|
+
* also sends: WELCOME, PONG, errors.
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_RELAY_STATE_THROTTLE_MS = 50;
|
|
15
15
|
/**
|
|
@@ -104,6 +104,12 @@ export declare class RelayDisplayHost<S extends IGameState, A extends IAction> {
|
|
|
104
104
|
getState: () => S;
|
|
105
105
|
/** Subscribe to state changes (for `useSyncExternalStore` or manual render). */
|
|
106
106
|
subscribe: (listener: () => void) => (() => void);
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to every action the runtime reduces — the display's own
|
|
109
|
+
* dispatches, players' actions, and join/leave lifecycle actions. A
|
|
110
|
+
* `RelayDisplayHost` can be passed straight to `useActionRecorder({ source })`.
|
|
111
|
+
*/
|
|
112
|
+
subscribeActions: (listener: RuntimeActionListener<S, A>) => (() => void);
|
|
107
113
|
/** Dispatch a trusted host-display action. */
|
|
108
114
|
dispatch: (action: A) => void;
|
|
109
115
|
/** Tear down the runtime and relay socket. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-display-host.d.ts","sourceRoot":"","sources":["../src/relay-display-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"relay-display-host.d.ts","sourceRoot":"","sources":["../src/relay-display-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAe,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAElE,0EAA0E;AAC1E,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAE9B,YAAY,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAIhD;CACF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB,CACtC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,OAAO,CACjB,SAAQ,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC;IACnC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC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qBpB,OAAO,CAAC,kBAAkB;CA4C3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@couch-kit/display",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"clean": "rm -rf dist lib"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@couch-kit/client": "0.15.
|
|
55
|
-
"@couch-kit/core": "0.10.
|
|
56
|
-
"@couch-kit/runtime": "0.
|
|
54
|
+
"@couch-kit/client": "0.15.1",
|
|
55
|
+
"@couch-kit/core": "0.10.1",
|
|
56
|
+
"@couch-kit/runtime": "0.5.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"typescript": "^7.0.0"
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type AddressedMessage,
|
|
6
6
|
type GameHostRuntimeConfig,
|
|
7
7
|
type GameRuntimeTransport,
|
|
8
|
+
type RuntimeActionListener,
|
|
8
9
|
} from "@couch-kit/runtime";
|
|
9
10
|
import type { IGameState, IAction, HostMessage } from "@couch-kit/core";
|
|
10
11
|
import {
|
|
@@ -17,12 +18,12 @@ import {
|
|
|
17
18
|
/**
|
|
18
19
|
* Default minimum interval (ms) between state broadcasts through a relay.
|
|
19
20
|
*
|
|
20
|
-
* Slower than the LAN default on purpose:
|
|
21
|
-
*
|
|
22
|
-
* the socket —
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
21
|
+
* Slower than the LAN default on purpose: every frame the display sends is
|
|
22
|
+
* billed by the relay and counted against the display's rate limit, whose
|
|
23
|
+
* breach closes the socket — and, for the display, ends the room. 20
|
|
24
|
+
* broadcasts/second is smooth for a party game and leaves the display's budget
|
|
25
|
+
* (1200 messages/second on the reference relays) to the unicast replies it
|
|
26
|
+
* also sends: WELCOME, PONG, errors.
|
|
26
27
|
*/
|
|
27
28
|
export const DEFAULT_RELAY_STATE_THROTTLE_MS = 50;
|
|
28
29
|
|
|
@@ -189,6 +190,14 @@ export class RelayDisplayHost<S extends IGameState, A extends IAction> {
|
|
|
189
190
|
subscribe = (listener: () => void): (() => void) =>
|
|
190
191
|
this.runtime.subscribe(listener);
|
|
191
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Subscribe to every action the runtime reduces — the display's own
|
|
195
|
+
* dispatches, players' actions, and join/leave lifecycle actions. A
|
|
196
|
+
* `RelayDisplayHost` can be passed straight to `useActionRecorder({ source })`.
|
|
197
|
+
*/
|
|
198
|
+
subscribeActions = (listener: RuntimeActionListener<S, A>): (() => void) =>
|
|
199
|
+
this.runtime.subscribeActions(listener);
|
|
200
|
+
|
|
192
201
|
/** Dispatch a trusted host-display action. */
|
|
193
202
|
dispatch = (action: A): void => this.runtime.dispatch(action);
|
|
194
203
|
|