@pylonsync/react 0.18.1 → 0.19.1
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/dist/useShard.d.ts +1 -1
- package/package.json +4 -4
- package/src/useShard.ts +9 -6
package/dist/useShard.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { connectShard, type EntityTable, type ShardClient, type ShardConnectOpti
|
|
|
2
2
|
export { connectShard };
|
|
3
3
|
export type { ShardClient };
|
|
4
4
|
export interface UseShardOptions extends ShardConnectOptions {
|
|
5
|
-
/** Unused:
|
|
5
|
+
/** Unused: there is no SSE transport for shards. */
|
|
6
6
|
sseFallback?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface UseShardReturn<TSnapshot = unknown, TInput = unknown> {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.19.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"prepack": "bun run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pylonsync/realtime": "0.
|
|
18
|
-
"@pylonsync/sdk": "0.
|
|
19
|
-
"@pylonsync/sync": "0.
|
|
17
|
+
"@pylonsync/realtime": "0.19.1",
|
|
18
|
+
"@pylonsync/sdk": "0.19.1",
|
|
19
|
+
"@pylonsync/sync": "0.19.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=19.0.0"
|
package/src/useShard.ts
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* useShard — React hook for real-time sharded simulations (games, MMO zones, etc.).
|
|
5
5
|
*
|
|
6
|
-
* Connects to a Pylon shard
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `connectShardGame` from
|
|
6
|
+
* Connects to a Pylon shard (a WebSocket, or WebTransport with
|
|
7
|
+
* `transport`), receives snapshots as they arrive, and sends inputs
|
|
8
|
+
* upstream. It re-renders on every frame, so it suits small, turn-based,
|
|
9
|
+
* or UI-only use; a game's render loop should use `connectShardGame` from
|
|
10
|
+
* `@pylonsync/realtime`.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```tsx
|
|
@@ -40,7 +41,7 @@ export type { ShardClient };
|
|
|
40
41
|
// ---------------------------------------------------------------------------
|
|
41
42
|
|
|
42
43
|
export interface UseShardOptions extends ShardConnectOptions {
|
|
43
|
-
/** Unused:
|
|
44
|
+
/** Unused: there is no SSE transport for shards. */
|
|
44
45
|
sseFallback?: boolean;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -118,6 +119,8 @@ export function useShard<TSnapshot = unknown, TInput = unknown>(
|
|
|
118
119
|
const baseUrl = options.baseUrl;
|
|
119
120
|
const wsUrl = options.wsUrl;
|
|
120
121
|
const wsPort = options.wsPort;
|
|
122
|
+
const transport = options.transport;
|
|
123
|
+
const webTransportInfoUrl = options.webTransportInfoUrl;
|
|
121
124
|
|
|
122
125
|
useEffect(() => {
|
|
123
126
|
const client = connectShard<TSnapshot, TInput>(shardId, {
|
|
@@ -157,7 +160,7 @@ export function useShard<TSnapshot = unknown, TInput = unknown>(
|
|
|
157
160
|
clientRef.current = null;
|
|
158
161
|
};
|
|
159
162
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
|
-
}, [shardId, token, ticket, subscriberId, baseUrl, wsUrl, wsPort]);
|
|
163
|
+
}, [shardId, token, ticket, subscriberId, baseUrl, wsUrl, wsPort, transport, webTransportInfoUrl]);
|
|
161
164
|
|
|
162
165
|
const send = (input: TInput): number => {
|
|
163
166
|
if (clientRef.current) return clientRef.current.send(input);
|