Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Reducer,
State,
Store,
Ctx,
} from '../types';

type ClientAction = ActionShape.Reset | ActionShape.Sync | ActionShape.Update;
Expand Down Expand Up @@ -86,8 +87,11 @@ export const createEventDispatchers = createDispatchers.bind(null, 'gameEvent');
// Creates a set of dispatchers to dispatch actions to plugins.
export const createPluginDispatchers = createDispatchers.bind(null, 'plugin');

export interface ClientOpts<G extends any = any> {
game: Game<G>;
export interface ClientOpts<
G extends any = any,
CtxWithPlugins extends Ctx = Ctx
> {
game: Game<G, CtxWithPlugins>;
debug?: DebugOpt | boolean;
numPlayers?: number;
multiplayer?: (opts: TransportOpts) => Transport;
Expand Down
32 changes: 17 additions & 15 deletions src/client/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Client as RawClient, ClientOpts, _ClientImpl } from './client';
import { State } from '../types';

type WrappedBoardDelegates = 'matchID' | 'playerID' | 'credentials';

Expand All @@ -18,20 +17,23 @@ export type WrappedBoardProps = Pick<
WrappedBoardDelegates | 'debug'
>;

export type BoardProps<G extends any = any> = State<G> &
Pick<
_ClientImpl<G>,
| 'log'
| 'moves'
| 'events'
| 'reset'
| 'undo'
| 'redo'
| 'playerID'
| 'matchID'
| 'matchData'
> & {
isActive: boolean;
type ClientState<G extends any = any> = ReturnType<_ClientImpl<G>['getState']>;
type ExposedClientProps<G extends any = any> = Pick<
_ClientImpl<G>,
| 'log'
| 'moves'
| 'events'
| 'reset'
| 'undo'
| 'redo'
| 'playerID'
| 'matchID'
| 'matchData'
>;

export type BoardProps<G extends any = any> = ClientState<G> &
Omit<WrappedBoardProps, keyof ExposedClientProps<G>> &
ExposedClientProps<G> & {
isMultiplayer: boolean;
};

Expand Down