@pylonsync/realtime 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/src/game.ts CHANGED
@@ -26,7 +26,12 @@
26
26
  */
27
27
 
28
28
  import type { ShardClock } from "./clock";
29
- import { connectShard, type ShardClient, type ShardConnectOptions } from "./connection";
29
+ import {
30
+ connectShard,
31
+ type ShardClient,
32
+ type ShardConnectOptions,
33
+ type ShardTransport,
34
+ } from "./connection";
30
35
  import {
31
36
  EntityInterpolator,
32
37
  type InterpolatedEntity,
@@ -37,6 +42,11 @@ import type { EntityTable, ReplicationSummary } from "./replication";
37
42
  import type { ShardInputRejection } from "./wire";
38
43
 
39
44
  export interface ShardGameOptions extends ShardConnectOptions {
45
+ /**
46
+ * Default `"auto"`: WebTransport where the browser and the app support
47
+ * it, else a WebSocket. See `ShardTransport`.
48
+ */
49
+ transport?: ShardTransport;
40
50
  /**
41
51
  * How far behind the shard's estimated current tick entities are drawn,
42
52
  * in ms. It must cover the time between frames plus network jitter.
@@ -94,7 +104,11 @@ export function connectShardGame<TInput = unknown>(
94
104
  options: ShardGameOptions,
95
105
  ): ShardGame<TInput> {
96
106
  const now = options.now ?? (() => performance.now());
97
- const connection = connectShard<unknown, TInput>(shardId, { ...options, now });
107
+ const connection = connectShard<unknown, TInput>(shardId, {
108
+ transport: "auto",
109
+ ...options,
110
+ now,
111
+ });
98
112
  const interpolator = new EntityInterpolator(options.interpolation);
99
113
  const delayMs = options.interpolationDelayMs ?? 100;
100
114
  const predictors: Array<Predictor<unknown, TInput>> = [];