@mnbroatch/boardgame.io 0.0.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/LICENSE +21 -0
- package/README.md +102 -0
- package/ai/package.json +7 -0
- package/client/package.json +7 -0
- package/core/package.json +7 -0
- package/debug/package.json +7 -0
- package/dist/boardgameio.es.js +14238 -0
- package/dist/boardgameio.js +14277 -0
- package/dist/boardgameio.min.js +16 -0
- package/dist/cjs/Debug-9d141c06.js +9586 -0
- package/dist/cjs/ai-e0e8a768.js +377 -0
- package/dist/cjs/ai.js +20 -0
- package/dist/cjs/client-76dec77b.js +258 -0
- package/dist/cjs/client-a22d7500.js +524 -0
- package/dist/cjs/client.js +26 -0
- package/dist/cjs/core.js +52 -0
- package/dist/cjs/debug.js +18 -0
- package/dist/cjs/filter-player-view-bb02e2f6.js +89 -0
- package/dist/cjs/initialize-267fcd69.js +61 -0
- package/dist/cjs/internal.js +25 -0
- package/dist/cjs/master-2904879d.js +320 -0
- package/dist/cjs/master.js +18 -0
- package/dist/cjs/multiplayer.js +23 -0
- package/dist/cjs/plugin-random-7425844d.js +229 -0
- package/dist/cjs/plugins.js +59 -0
- package/dist/cjs/react-native.js +182 -0
- package/dist/cjs/react.js +727 -0
- package/dist/cjs/reducer-16eec232.js +1203 -0
- package/dist/cjs/server.js +4087 -0
- package/dist/cjs/socketio-7a0837eb.js +478 -0
- package/dist/cjs/testing.js +30 -0
- package/dist/cjs/transport-b1874dfa.js +37 -0
- package/dist/cjs/turn-order-b2ff8740.js +1136 -0
- package/dist/cjs/util-fcfd8fb8.js +140 -0
- package/dist/esm/Debug-0141fe2d.js +9577 -0
- package/dist/esm/ai-5c06e761.js +371 -0
- package/dist/esm/ai.js +8 -0
- package/dist/esm/client-2e653027.js +522 -0
- package/dist/esm/client-5f57c3f2.js +255 -0
- package/dist/esm/client.js +16 -0
- package/dist/esm/core.js +40 -0
- package/dist/esm/debug.js +10 -0
- package/dist/esm/filter-player-view-2c6cc96f.js +87 -0
- package/dist/esm/initialize-11d626ca.js +59 -0
- package/dist/esm/internal.js +10 -0
- package/dist/esm/master-fa8f2e43.js +318 -0
- package/dist/esm/master.js +10 -0
- package/dist/esm/multiplayer.js +14 -0
- package/dist/esm/plugin-random-087f861e.js +226 -0
- package/dist/esm/plugins.js +55 -0
- package/dist/esm/react-native.js +173 -0
- package/dist/esm/react.js +716 -0
- package/dist/esm/reducer-c46da7e5.js +1198 -0
- package/dist/esm/socketio-c22ffa65.js +455 -0
- package/dist/esm/testing.js +26 -0
- package/dist/esm/transport-ce07b771.js +35 -0
- package/dist/esm/turn-order-376d315e.js +1091 -0
- package/dist/esm/util-b6147cef.js +135 -0
- package/dist/types/packages/ai.d.ts +5 -0
- package/dist/types/packages/client.d.ts +3 -0
- package/dist/types/packages/core.d.ts +5 -0
- package/dist/types/packages/debug.d.ts +2 -0
- package/dist/types/packages/internal.d.ts +8 -0
- package/dist/types/packages/master.d.ts +2 -0
- package/dist/types/packages/multiplayer.d.ts +3 -0
- package/dist/types/packages/plugins.d.ts +3 -0
- package/dist/types/packages/react-native.d.ts +2 -0
- package/dist/types/packages/react.d.ts +3 -0
- package/dist/types/packages/server.d.ts +6 -0
- package/dist/types/packages/testing.d.ts +1 -0
- package/dist/types/src/ai/ai.d.ts +53 -0
- package/dist/types/src/ai/ai.test.d.ts +1 -0
- package/dist/types/src/ai/bot.d.ts +40 -0
- package/dist/types/src/ai/mcts-bot.d.ts +60 -0
- package/dist/types/src/ai/random-bot.d.ts +27 -0
- package/dist/types/src/client/client.d.ts +104 -0
- package/dist/types/src/client/client.test.d.ts +1 -0
- package/dist/types/src/client/debug/tests/debug.test.d.ts +1 -0
- package/dist/types/src/client/manager.d.ts +61 -0
- package/dist/types/src/client/react.d.ts +75 -0
- package/dist/types/src/client/react.ssr.test.d.ts +4 -0
- package/dist/types/src/client/react.test.d.ts +1 -0
- package/dist/types/src/client/transport/dummy.d.ts +18 -0
- package/dist/types/src/client/transport/local.d.ts +59 -0
- package/dist/types/src/client/transport/local.test.d.ts +1 -0
- package/dist/types/src/client/transport/socketio.d.ts +45 -0
- package/dist/types/src/client/transport/socketio.test.d.ts +1 -0
- package/dist/types/src/client/transport/transport.d.ts +50 -0
- package/dist/types/src/client/transport/transport.test.d.ts +1 -0
- package/dist/types/src/core/action-creators.d.ts +144 -0
- package/dist/types/src/core/action-types.d.ts +10 -0
- package/dist/types/src/core/backwards-compatibility.d.ts +12 -0
- package/dist/types/src/core/constants.d.ts +6 -0
- package/dist/types/src/core/errors.d.ts +15 -0
- package/dist/types/src/core/flow.d.ts +28 -0
- package/dist/types/src/core/flow.test.d.ts +1 -0
- package/dist/types/src/core/game-methods.d.ts +9 -0
- package/dist/types/src/core/game.d.ts +26 -0
- package/dist/types/src/core/game.test.d.ts +1 -0
- package/dist/types/src/core/initialize.d.ts +9 -0
- package/dist/types/src/core/logger.d.ts +2 -0
- package/dist/types/src/core/player-view.d.ts +7 -0
- package/dist/types/src/core/player-view.test.d.ts +1 -0
- package/dist/types/src/core/reducer.d.ts +155 -0
- package/dist/types/src/core/reducer.test.d.ts +1 -0
- package/dist/types/src/core/turn-order.d.ts +179 -0
- package/dist/types/src/core/turn-order.test.d.ts +8 -0
- package/dist/types/src/lobby/client.d.ts +194 -0
- package/dist/types/src/lobby/client.test.d.ts +1 -0
- package/dist/types/src/lobby/connection.d.ts +44 -0
- package/dist/types/src/lobby/connection.test.d.ts +1 -0
- package/dist/types/src/lobby/create-match-form.d.ts +26 -0
- package/dist/types/src/lobby/login-form.d.ts +23 -0
- package/dist/types/src/lobby/match-instance.d.ts +31 -0
- package/dist/types/src/lobby/react.d.ts +113 -0
- package/dist/types/src/lobby/react.ssr.test.d.ts +4 -0
- package/dist/types/src/lobby/react.test.d.ts +1 -0
- package/dist/types/src/master/filter-player-view.d.ts +96 -0
- package/dist/types/src/master/filter-player-view.test.d.ts +1 -0
- package/dist/types/src/master/master.d.ts +94 -0
- package/dist/types/src/master/master.test.d.ts +1 -0
- package/dist/types/src/plugins/events/events.d.ts +54 -0
- package/dist/types/src/plugins/events/events.test.d.ts +1 -0
- package/dist/types/src/plugins/main.d.ts +75 -0
- package/dist/types/src/plugins/main.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-events.d.ts +5 -0
- package/dist/types/src/plugins/plugin-immer.d.ts +7 -0
- package/dist/types/src/plugins/plugin-immer.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-log.d.ts +14 -0
- package/dist/types/src/plugins/plugin-log.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-player.d.ts +29 -0
- package/dist/types/src/plugins/plugin-player.test.d.ts +1 -0
- package/dist/types/src/plugins/plugin-random.d.ts +4 -0
- package/dist/types/src/plugins/plugin-serializable.d.ts +7 -0
- package/dist/types/src/plugins/plugin-serializable.test.d.ts +1 -0
- package/dist/types/src/plugins/random/random.alea.d.ts +19 -0
- package/dist/types/src/plugins/random/random.d.ts +54 -0
- package/dist/types/src/plugins/random/random.test.d.ts +1 -0
- package/dist/types/src/server/api.d.ts +13 -0
- package/dist/types/src/server/api.test.d.ts +1 -0
- package/dist/types/src/server/auth.d.ts +38 -0
- package/dist/types/src/server/auth.test.d.ts +1 -0
- package/dist/types/src/server/cors.d.ts +4 -0
- package/dist/types/src/server/cors.test.d.ts +1 -0
- package/dist/types/src/server/db/base.d.ts +192 -0
- package/dist/types/src/server/db/flatfile.d.ts +44 -0
- package/dist/types/src/server/db/flatfile.test.d.ts +1 -0
- package/dist/types/src/server/db/index.d.ts +4 -0
- package/dist/types/src/server/db/index.test.d.ts +1 -0
- package/dist/types/src/server/db/inmemory.d.ts +43 -0
- package/dist/types/src/server/db/inmemory.test.d.ts +1 -0
- package/dist/types/src/server/db/localstorage.d.ts +7 -0
- package/dist/types/src/server/db/localstorage.test.d.ts +1 -0
- package/dist/types/src/server/index.d.ts +68 -0
- package/dist/types/src/server/index.test.d.ts +1 -0
- package/dist/types/src/server/transport/pubsub/generic-pub-sub.d.ts +6 -0
- package/dist/types/src/server/transport/pubsub/in-memory-pub-sub.d.ts +7 -0
- package/dist/types/src/server/transport/pubsub/in-memory-pub-sub.test.d.ts +1 -0
- package/dist/types/src/server/transport/socketio-simultaneous.test.d.ts +1 -0
- package/dist/types/src/server/transport/socketio.d.ts +65 -0
- package/dist/types/src/server/transport/socketio.test.d.ts +1 -0
- package/dist/types/src/server/util.d.ts +35 -0
- package/dist/types/src/testing/mock-random.d.ts +15 -0
- package/dist/types/src/testing/mock-random.test.d.ts +1 -0
- package/dist/types/src/types.d.ts +387 -0
- package/internal/package.json +7 -0
- package/master/package.json +7 -0
- package/multiplayer/package.json +7 -0
- package/package.json +211 -0
- package/plugins/package.json +7 -0
- package/react/package.json +7 -0
- package/react-native/package.json +7 -0
- package/server/package.json +6 -0
- package/src/ai/ai.test.ts +433 -0
- package/src/ai/ai.ts +84 -0
- package/src/ai/bot.ts +122 -0
- package/src/ai/mcts-bot.ts +331 -0
- package/src/ai/random-bot.ts +20 -0
- package/src/client/client.test.ts +993 -0
- package/src/client/client.ts +588 -0
- package/src/client/debug/Debug.svelte +239 -0
- package/src/client/debug/Menu.svelte +65 -0
- package/src/client/debug/ai/AI.svelte +215 -0
- package/src/client/debug/ai/Options.svelte +48 -0
- package/src/client/debug/info/Info.svelte +22 -0
- package/src/client/debug/info/Item.svelte +24 -0
- package/src/client/debug/log/Log.svelte +157 -0
- package/src/client/debug/log/LogEvent.svelte +149 -0
- package/src/client/debug/log/LogMetadata.svelte +7 -0
- package/src/client/debug/log/PhaseMarker.svelte +27 -0
- package/src/client/debug/log/TurnMarker.svelte +23 -0
- package/src/client/debug/main/ClientSwitcher.svelte +59 -0
- package/src/client/debug/main/Controls.svelte +58 -0
- package/src/client/debug/main/Hotkey.svelte +84 -0
- package/src/client/debug/main/InteractiveFunction.svelte +85 -0
- package/src/client/debug/main/Main.svelte +121 -0
- package/src/client/debug/main/Move.svelte +68 -0
- package/src/client/debug/main/PlayerInfo.svelte +70 -0
- package/src/client/debug/mcts/Action.svelte +22 -0
- package/src/client/debug/mcts/MCTS.svelte +78 -0
- package/src/client/debug/mcts/Table.svelte +98 -0
- package/src/client/debug/tests/JSONTree.mock.svelte +3 -0
- package/src/client/debug/tests/debug.test.ts +183 -0
- package/src/client/debug/utils/shortcuts.js +50 -0
- package/src/client/debug/utils/shortcuts.test.js +49 -0
- package/src/client/manager.ts +177 -0
- package/src/client/react-native.js +136 -0
- package/src/client/react-native.test.js +229 -0
- package/src/client/react.ssr.test.tsx +24 -0
- package/src/client/react.test.tsx +213 -0
- package/src/client/react.tsx +192 -0
- package/src/client/transport/dummy.ts +19 -0
- package/src/client/transport/local.test.ts +353 -0
- package/src/client/transport/local.ts +230 -0
- package/src/client/transport/socketio.test.ts +328 -0
- package/src/client/transport/socketio.ts +210 -0
- package/src/client/transport/transport.test.ts +27 -0
- package/src/client/transport/transport.ts +95 -0
- package/src/core/action-creators.ts +159 -0
- package/src/core/action-types.ts +18 -0
- package/src/core/backwards-compatibility.ts +23 -0
- package/src/core/constants.ts +6 -0
- package/src/core/errors.ts +35 -0
- package/src/core/flow.test.ts +2433 -0
- package/src/core/flow.ts +897 -0
- package/src/core/game-methods.ts +9 -0
- package/src/core/game.test.ts +286 -0
- package/src/core/game.ts +114 -0
- package/src/core/initialize.ts +77 -0
- package/src/core/logger.test.js +90 -0
- package/src/core/logger.ts +18 -0
- package/src/core/player-view.test.ts +50 -0
- package/src/core/player-view.ts +39 -0
- package/src/core/reducer.test.ts +991 -0
- package/src/core/reducer.ts +532 -0
- package/src/core/turn-order.test.ts +1123 -0
- package/src/core/turn-order.ts +473 -0
- package/src/lobby/client.test.ts +385 -0
- package/src/lobby/client.ts +358 -0
- package/src/lobby/connection.test.ts +207 -0
- package/src/lobby/connection.ts +162 -0
- package/src/lobby/create-match-form.tsx +122 -0
- package/src/lobby/login-form.tsx +75 -0
- package/src/lobby/match-instance.tsx +135 -0
- package/src/lobby/react.ssr.test.tsx +22 -0
- package/src/lobby/react.test.tsx +594 -0
- package/src/lobby/react.tsx +402 -0
- package/src/master/filter-player-view.test.ts +381 -0
- package/src/master/filter-player-view.ts +102 -0
- package/src/master/master.test.ts +1068 -0
- package/src/master/master.ts +492 -0
- package/src/plugins/events/events.test.ts +108 -0
- package/src/plugins/events/events.ts +209 -0
- package/src/plugins/main.test.ts +411 -0
- package/src/plugins/main.ts +314 -0
- package/src/plugins/plugin-events.ts +40 -0
- package/src/plugins/plugin-immer.test.ts +86 -0
- package/src/plugins/plugin-immer.ts +37 -0
- package/src/plugins/plugin-log.test.ts +37 -0
- package/src/plugins/plugin-log.ts +40 -0
- package/src/plugins/plugin-player.test.ts +172 -0
- package/src/plugins/plugin-player.ts +100 -0
- package/src/plugins/plugin-random.ts +40 -0
- package/src/plugins/plugin-serializable.test.ts +40 -0
- package/src/plugins/plugin-serializable.ts +55 -0
- package/src/plugins/random/random.alea.ts +109 -0
- package/src/plugins/random/random.test.ts +167 -0
- package/src/plugins/random/random.ts +198 -0
- package/src/server/api.test.ts +1699 -0
- package/src/server/api.ts +527 -0
- package/src/server/auth.test.ts +275 -0
- package/src/server/auth.ts +89 -0
- package/src/server/cors.test.ts +121 -0
- package/src/server/cors.ts +7 -0
- package/src/server/db/base.ts +296 -0
- package/src/server/db/flatfile.test.ts +221 -0
- package/src/server/db/flatfile.ts +228 -0
- package/src/server/db/index.test.ts +8 -0
- package/src/server/db/index.ts +12 -0
- package/src/server/db/inmemory.test.ts +143 -0
- package/src/server/db/inmemory.ts +143 -0
- package/src/server/db/localstorage.test.ts +73 -0
- package/src/server/db/localstorage.ts +44 -0
- package/src/server/index.test.ts +265 -0
- package/src/server/index.ts +175 -0
- package/src/server/transport/pubsub/generic-pub-sub.ts +11 -0
- package/src/server/transport/pubsub/in-memory-pub-sub.test.ts +47 -0
- package/src/server/transport/pubsub/in-memory-pub-sub.ts +28 -0
- package/src/server/transport/socketio-simultaneous.test.ts +603 -0
- package/src/server/transport/socketio.test.ts +303 -0
- package/src/server/transport/socketio.ts +279 -0
- package/src/server/util.ts +85 -0
- package/src/testing/mock-random.test.ts +45 -0
- package/src/testing/mock-random.ts +27 -0
- package/src/types.ts +511 -0
- package/testing/package.json +7 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { I as InitializeGame } from './initialize-11d626ca.js';
|
|
2
|
+
|
|
3
|
+
var Type;
|
|
4
|
+
(function (Type) {
|
|
5
|
+
Type[Type["SYNC"] = 0] = "SYNC";
|
|
6
|
+
Type[Type["ASYNC"] = 1] = "ASYNC";
|
|
7
|
+
})(Type || (Type = {}));
|
|
8
|
+
/**
|
|
9
|
+
* Type guard that checks if a storage implementation is synchronous.
|
|
10
|
+
*/
|
|
11
|
+
function isSynchronous(storageAPI) {
|
|
12
|
+
return storageAPI.type() === Type.SYNC;
|
|
13
|
+
}
|
|
14
|
+
class Async {
|
|
15
|
+
/* istanbul ignore next */
|
|
16
|
+
type() {
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
return Type.ASYNC;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a new match.
|
|
22
|
+
*
|
|
23
|
+
* This might just need to call setState and setMetadata in
|
|
24
|
+
* most implementations.
|
|
25
|
+
*
|
|
26
|
+
* However, it exists as a separate call so that the
|
|
27
|
+
* implementation can provision things differently when
|
|
28
|
+
* a match is created. For example, it might stow away the
|
|
29
|
+
* initial match state in a separate field for easier retrieval.
|
|
30
|
+
*/
|
|
31
|
+
/* istanbul ignore next */
|
|
32
|
+
async createMatch(matchID, opts) {
|
|
33
|
+
if (this.createGame) {
|
|
34
|
+
console.warn('The database connector does not implement a createMatch method.', '\nUsing the deprecated createGame method instead.');
|
|
35
|
+
return this.createGame(matchID, opts);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error('The database connector does not implement a createMatch method.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return all matches.
|
|
43
|
+
*/
|
|
44
|
+
/* istanbul ignore next */
|
|
45
|
+
async listMatches(opts) {
|
|
46
|
+
if (this.listGames) {
|
|
47
|
+
console.warn('The database connector does not implement a listMatches method.', '\nUsing the deprecated listGames method instead.');
|
|
48
|
+
return this.listGames(opts);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.error('The database connector does not implement a listMatches method.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class Sync {
|
|
56
|
+
type() {
|
|
57
|
+
return Type.SYNC;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Connect.
|
|
61
|
+
*/
|
|
62
|
+
connect() {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a new match.
|
|
67
|
+
*
|
|
68
|
+
* This might just need to call setState and setMetadata in
|
|
69
|
+
* most implementations.
|
|
70
|
+
*
|
|
71
|
+
* However, it exists as a separate call so that the
|
|
72
|
+
* implementation can provision things differently when
|
|
73
|
+
* a match is created. For example, it might stow away the
|
|
74
|
+
* initial match state in a separate field for easier retrieval.
|
|
75
|
+
*/
|
|
76
|
+
/* istanbul ignore next */
|
|
77
|
+
createMatch(matchID, opts) {
|
|
78
|
+
if (this.createGame) {
|
|
79
|
+
console.warn('The database connector does not implement a createMatch method.', '\nUsing the deprecated createGame method instead.');
|
|
80
|
+
return this.createGame(matchID, opts);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.error('The database connector does not implement a createMatch method.');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Return all matches.
|
|
88
|
+
*/
|
|
89
|
+
/* istanbul ignore next */
|
|
90
|
+
listMatches(opts) {
|
|
91
|
+
if (this.listGames) {
|
|
92
|
+
console.warn('The database connector does not implement a listMatches method.', '\nUsing the deprecated listGames method instead.');
|
|
93
|
+
return this.listGames(opts);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error('The database connector does not implement a listMatches method.');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new match metadata object.
|
|
103
|
+
*/
|
|
104
|
+
const createMetadata = ({ game, unlisted, setupData, numPlayers, }) => {
|
|
105
|
+
const metadata = {
|
|
106
|
+
gameName: game.name,
|
|
107
|
+
unlisted: !!unlisted,
|
|
108
|
+
players: {},
|
|
109
|
+
createdAt: Date.now(),
|
|
110
|
+
updatedAt: Date.now(),
|
|
111
|
+
};
|
|
112
|
+
if (setupData !== undefined)
|
|
113
|
+
metadata.setupData = setupData;
|
|
114
|
+
for (let playerIndex = 0; playerIndex < numPlayers; playerIndex++) {
|
|
115
|
+
metadata.players[playerIndex] = { id: playerIndex };
|
|
116
|
+
}
|
|
117
|
+
return metadata;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Creates initial state and metadata for a new match.
|
|
121
|
+
* If the provided `setupData` doesn’t pass the game’s validation,
|
|
122
|
+
* an error object is returned instead.
|
|
123
|
+
*/
|
|
124
|
+
const createMatch = ({ game, numPlayers, setupData, unlisted, }) => {
|
|
125
|
+
if (!numPlayers || typeof numPlayers !== 'number')
|
|
126
|
+
numPlayers = 2;
|
|
127
|
+
const setupDataError = game.validateSetupData && game.validateSetupData(setupData, numPlayers);
|
|
128
|
+
if (setupDataError !== undefined)
|
|
129
|
+
return { setupDataError };
|
|
130
|
+
const metadata = createMetadata({ game, numPlayers, setupData, unlisted });
|
|
131
|
+
const initialState = InitializeGame({ game, numPlayers, setupData });
|
|
132
|
+
return { metadata, initialState };
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { Async as A, Sync as S, createMatch as c, isSynchronous as i };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { INVALID_MOVE } from '../src/core/constants';
|
|
2
|
+
import { GameMethod } from '../src/core/game-methods';
|
|
3
|
+
import { ActivePlayers, TurnOrder, Stage } from '../src/core/turn-order';
|
|
4
|
+
import { PlayerView } from '../src/core/player-view';
|
|
5
|
+
export { ActivePlayers, GameMethod, Stage, TurnOrder, PlayerView, INVALID_MOVE, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InitializeGame } from '../src/core/initialize';
|
|
2
|
+
import { ProcessGameConfig } from '../src/core/game';
|
|
3
|
+
import { CreateGameReducer } from '../src/core/reducer';
|
|
4
|
+
import { getFilterPlayerView } from '../src/master/filter-player-view';
|
|
5
|
+
import { Async, Sync } from '../src/server/db/base';
|
|
6
|
+
import { Transport } from '../src/client/transport/transport';
|
|
7
|
+
import { createMatch } from '../src/server/util';
|
|
8
|
+
export { Async, Sync, Transport, ProcessGameConfig, InitializeGame, CreateGameReducer, createMatch, getFilterPlayerView, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Server, configureRouter, configureApp, createServerRunConfig, getPortFromServer } from '../src/server';
|
|
2
|
+
import { Origins } from '../src/server/cors';
|
|
3
|
+
import { FlatFile } from '../src/server/db';
|
|
4
|
+
import { SocketIO, Master, TransportAPI } from '../src/server/transport/socketio';
|
|
5
|
+
import { GenericPubSub } from '../src/server/transport/pubsub/generic-pub-sub';
|
|
6
|
+
export { Server, Origins, FlatFile, SocketIO, GenericPubSub, configureRouter, configureApp, createServerRunConfig, getPortFromServer, Master, TransportAPI, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MockRandom } from '../src/testing/mock-random';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Bot } from './bot';
|
|
2
|
+
import type { Game, PlayerID, State, Store } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Make a single move on the client with a bot.
|
|
5
|
+
*
|
|
6
|
+
* @param {...object} client - The game client.
|
|
7
|
+
* @param {...object} bot - The bot.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Step(client: {
|
|
10
|
+
store: Store;
|
|
11
|
+
}, bot: Bot): Promise<{
|
|
12
|
+
payload: {
|
|
13
|
+
metadata: any;
|
|
14
|
+
type: string;
|
|
15
|
+
args: any;
|
|
16
|
+
playerID: string;
|
|
17
|
+
} | {
|
|
18
|
+
metadata: any;
|
|
19
|
+
type: string;
|
|
20
|
+
args: any;
|
|
21
|
+
playerID: string;
|
|
22
|
+
};
|
|
23
|
+
type: "MAKE_MOVE";
|
|
24
|
+
} | {
|
|
25
|
+
payload: {
|
|
26
|
+
metadata: any;
|
|
27
|
+
type: string;
|
|
28
|
+
args: any;
|
|
29
|
+
playerID: string;
|
|
30
|
+
} | {
|
|
31
|
+
metadata: any;
|
|
32
|
+
type: string;
|
|
33
|
+
args: any;
|
|
34
|
+
playerID: string;
|
|
35
|
+
};
|
|
36
|
+
type: "GAME_EVENT";
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Simulates the game till the end or a max depth.
|
|
40
|
+
*
|
|
41
|
+
* @param {...object} game - The game object.
|
|
42
|
+
* @param {...object} bots - An array of bots.
|
|
43
|
+
* @param {...object} state - The game state to start from.
|
|
44
|
+
*/
|
|
45
|
+
export declare function Simulate({ game, bots, state, depth, }: {
|
|
46
|
+
game: Game;
|
|
47
|
+
bots: Bot | Record<PlayerID, Bot>;
|
|
48
|
+
state: State;
|
|
49
|
+
depth?: number;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
state: State<any>;
|
|
52
|
+
metadata: any;
|
|
53
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ActionShape, Game, Ctx, PlayerID, State } from '../types';
|
|
2
|
+
export declare type BotAction = ActionShape.GameEvent | ActionShape.MakeMove;
|
|
3
|
+
/**
|
|
4
|
+
* Base class that bots can extend.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class Bot {
|
|
7
|
+
private enumerateFn;
|
|
8
|
+
private seed?;
|
|
9
|
+
protected iterationCounter: number;
|
|
10
|
+
private _opts;
|
|
11
|
+
private prngstate?;
|
|
12
|
+
constructor({ enumerate, seed, }: {
|
|
13
|
+
enumerate: Game['ai']['enumerate'];
|
|
14
|
+
seed?: string | number;
|
|
15
|
+
});
|
|
16
|
+
abstract play(state: State, playerID: PlayerID): Promise<{
|
|
17
|
+
action: BotAction;
|
|
18
|
+
metadata?: any;
|
|
19
|
+
}>;
|
|
20
|
+
addOpt({ key, range, initial, }: {
|
|
21
|
+
key: string;
|
|
22
|
+
range?: {
|
|
23
|
+
min: number;
|
|
24
|
+
max: number;
|
|
25
|
+
};
|
|
26
|
+
initial: any;
|
|
27
|
+
}): void;
|
|
28
|
+
getOpt(key: string): any;
|
|
29
|
+
setOpt(key: string, value: any): void;
|
|
30
|
+
opts(): Record<string, {
|
|
31
|
+
range?: {
|
|
32
|
+
min: number;
|
|
33
|
+
max: number;
|
|
34
|
+
};
|
|
35
|
+
value: any;
|
|
36
|
+
}>;
|
|
37
|
+
enumerate(G: any, ctx: Ctx, playerID: PlayerID): BotAction[];
|
|
38
|
+
random<T extends any = any>(arg: T[]): T;
|
|
39
|
+
random(arg?: number): number;
|
|
40
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import 'setimmediate';
|
|
2
|
+
import { Bot } from './bot';
|
|
3
|
+
import type { BotAction } from './bot';
|
|
4
|
+
import type { Game, PlayerID, Ctx, State } from '../types';
|
|
5
|
+
export interface Node {
|
|
6
|
+
/** Game state at this node. */
|
|
7
|
+
state: State;
|
|
8
|
+
/** Parent of the node. */
|
|
9
|
+
parent?: Node;
|
|
10
|
+
/** Move used to get to this node. */
|
|
11
|
+
parentAction?: BotAction;
|
|
12
|
+
/** Unexplored actions. */
|
|
13
|
+
actions: BotAction[];
|
|
14
|
+
/** Current objectives. */
|
|
15
|
+
objectives: Objectives | Objectives[];
|
|
16
|
+
/** Children of the node. */
|
|
17
|
+
children: Node[];
|
|
18
|
+
/** Number of simulations that pass through this node. */
|
|
19
|
+
visits: number;
|
|
20
|
+
/** Number of wins for this node. */
|
|
21
|
+
value: number;
|
|
22
|
+
}
|
|
23
|
+
interface Objective {
|
|
24
|
+
checker: (G: any, ctx: Ctx) => boolean;
|
|
25
|
+
weight: number;
|
|
26
|
+
}
|
|
27
|
+
declare type Objectives = Record<string, Objective>;
|
|
28
|
+
/**
|
|
29
|
+
* Bot that uses Monte-Carlo Tree Search to find promising moves.
|
|
30
|
+
*/
|
|
31
|
+
export declare class MCTSBot extends Bot {
|
|
32
|
+
private objectives;
|
|
33
|
+
private iterationCallback;
|
|
34
|
+
private reducer;
|
|
35
|
+
iterations: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);
|
|
36
|
+
playoutDepth?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);
|
|
37
|
+
constructor({ enumerate, seed, objectives, game, iterations, playoutDepth, iterationCallback, }: {
|
|
38
|
+
enumerate: Game['ai']['enumerate'];
|
|
39
|
+
seed?: string | number;
|
|
40
|
+
game: Game;
|
|
41
|
+
objectives?: (G: any, ctx: Ctx, playerID?: PlayerID) => Objectives;
|
|
42
|
+
iterations?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);
|
|
43
|
+
playoutDepth?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);
|
|
44
|
+
iterationCallback?: (data: {
|
|
45
|
+
iterationCounter: number;
|
|
46
|
+
numIterations: number;
|
|
47
|
+
metadata: Node;
|
|
48
|
+
}) => void;
|
|
49
|
+
});
|
|
50
|
+
private createNode;
|
|
51
|
+
private select;
|
|
52
|
+
private expand;
|
|
53
|
+
playout({ state }: Node): any;
|
|
54
|
+
private backpropagate;
|
|
55
|
+
play(state: State, playerID: PlayerID): Promise<{
|
|
56
|
+
action: BotAction;
|
|
57
|
+
metadata: Node;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Bot } from './bot';
|
|
2
|
+
import type { Ctx, PlayerID } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Bot that picks a move at random.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RandomBot extends Bot {
|
|
7
|
+
play({ G, ctx }: {
|
|
8
|
+
G: any;
|
|
9
|
+
ctx: Ctx;
|
|
10
|
+
}, playerID: PlayerID): Promise<{
|
|
11
|
+
action: {
|
|
12
|
+
type: "MAKE_MOVE";
|
|
13
|
+
payload: {
|
|
14
|
+
type: string;
|
|
15
|
+
args: any;
|
|
16
|
+
playerID: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
type: "GAME_EVENT";
|
|
20
|
+
payload: {
|
|
21
|
+
type: string;
|
|
22
|
+
args: any;
|
|
23
|
+
playerID: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import 'svelte';
|
|
2
|
+
import type { StoreEnhancer } from 'redux';
|
|
3
|
+
import { ProcessGameConfig } from '../core/game';
|
|
4
|
+
import type Debug from './debug/Debug.svelte';
|
|
5
|
+
import type { Transport, TransportOpts } from './transport/transport';
|
|
6
|
+
import type { ActivePlayersArg, FilteredMetadata, Game, LogEntry, PlayerID, State, Store, ChatMessage } from '../types';
|
|
7
|
+
export interface DebugOpt {
|
|
8
|
+
target?: HTMLElement;
|
|
9
|
+
impl?: typeof Debug;
|
|
10
|
+
collapseOnLoad?: boolean;
|
|
11
|
+
hideToggleButton?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const createMoveDispatchers: any;
|
|
14
|
+
export declare const createEventDispatchers: any;
|
|
15
|
+
export declare const createPluginDispatchers: any;
|
|
16
|
+
export interface ClientOpts<G extends any = any, PluginAPIs extends Record<string, unknown> = Record<string, unknown>> {
|
|
17
|
+
game: Game<G, PluginAPIs>;
|
|
18
|
+
debug?: DebugOpt | boolean;
|
|
19
|
+
numPlayers?: number;
|
|
20
|
+
multiplayer?: (opts: TransportOpts) => Transport;
|
|
21
|
+
matchID?: string;
|
|
22
|
+
playerID?: PlayerID;
|
|
23
|
+
credentials?: string;
|
|
24
|
+
enhancer?: StoreEnhancer;
|
|
25
|
+
}
|
|
26
|
+
export declare type ClientState<G extends any = any> = null | (State<G> & {
|
|
27
|
+
isActive: boolean;
|
|
28
|
+
isConnected: boolean;
|
|
29
|
+
log: LogEntry[];
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Implementation of Client (see below).
|
|
33
|
+
*/
|
|
34
|
+
export declare class _ClientImpl<G extends any = any, PluginAPIs extends Record<string, unknown> = Record<string, unknown>> {
|
|
35
|
+
private gameStateOverride?;
|
|
36
|
+
private initialState;
|
|
37
|
+
readonly multiplayer: (opts: TransportOpts) => Transport;
|
|
38
|
+
private reducer;
|
|
39
|
+
private _running;
|
|
40
|
+
private subscribers;
|
|
41
|
+
private transport;
|
|
42
|
+
private manager;
|
|
43
|
+
readonly debugOpt?: DebugOpt | boolean;
|
|
44
|
+
readonly game: ReturnType<typeof ProcessGameConfig>;
|
|
45
|
+
readonly store: Store;
|
|
46
|
+
log: State['deltalog'];
|
|
47
|
+
matchID: string;
|
|
48
|
+
playerID: PlayerID | null;
|
|
49
|
+
credentials: string;
|
|
50
|
+
matchData?: FilteredMetadata;
|
|
51
|
+
moves: Record<string, (...args: any[]) => void>;
|
|
52
|
+
events: {
|
|
53
|
+
endGame?: (gameover?: any) => void;
|
|
54
|
+
endPhase?: () => void;
|
|
55
|
+
endTurn?: (arg?: {
|
|
56
|
+
next: PlayerID;
|
|
57
|
+
}) => void;
|
|
58
|
+
setPhase?: (newPhase: string) => void;
|
|
59
|
+
endStage?: () => void;
|
|
60
|
+
setStage?: (newStage: string) => void;
|
|
61
|
+
setActivePlayers?: (arg: ActivePlayersArg) => void;
|
|
62
|
+
};
|
|
63
|
+
plugins: Record<string, (...args: any[]) => void>;
|
|
64
|
+
reset: () => void;
|
|
65
|
+
undo: () => void;
|
|
66
|
+
redo: () => void;
|
|
67
|
+
sendChatMessage: (message: any) => void;
|
|
68
|
+
chatMessages: ChatMessage[];
|
|
69
|
+
constructor({ game, debug, numPlayers, multiplayer, matchID: matchID, playerID, credentials, enhancer, }: ClientOpts<G, PluginAPIs>);
|
|
70
|
+
/** Handle incoming match data from a multiplayer transport. */
|
|
71
|
+
private receiveMatchData;
|
|
72
|
+
/** Handle an incoming chat message from a multiplayer transport. */
|
|
73
|
+
private receiveChatMessage;
|
|
74
|
+
/** Handle all incoming updates from a multiplayer transport. */
|
|
75
|
+
private receiveTransportData;
|
|
76
|
+
private notifySubscribers;
|
|
77
|
+
overrideGameState(state: any): void;
|
|
78
|
+
start(): void;
|
|
79
|
+
stop(): void;
|
|
80
|
+
subscribe(fn: (state: ClientState<G>) => void): () => void;
|
|
81
|
+
getInitialState(): State<G>;
|
|
82
|
+
getState(): ClientState<G>;
|
|
83
|
+
private createDispatchers;
|
|
84
|
+
updatePlayerID(playerID: PlayerID | null): void;
|
|
85
|
+
updateMatchID(matchID: string): void;
|
|
86
|
+
updateCredentials(credentials: string): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Client
|
|
90
|
+
*
|
|
91
|
+
* boardgame.io JS client.
|
|
92
|
+
*
|
|
93
|
+
* @param {...object} game - The return value of `Game`.
|
|
94
|
+
* @param {...object} numPlayers - The number of players.
|
|
95
|
+
* @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()
|
|
96
|
+
* @param {...object} matchID - The matchID that you want to connect to.
|
|
97
|
+
* @param {...object} playerID - The playerID associated with this client.
|
|
98
|
+
* @param {...string} credentials - The authentication credentials associated with this client.
|
|
99
|
+
*
|
|
100
|
+
* Returns:
|
|
101
|
+
* A JS object that provides an API to interact with the
|
|
102
|
+
* game by dispatching moves and events.
|
|
103
|
+
*/
|
|
104
|
+
export declare function Client<G extends any = any, PluginAPIs extends Record<string, unknown> = Record<string, unknown>>(opts: ClientOpts<G, PluginAPIs>): _ClientImpl<G, PluginAPIs>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { _ClientImpl } from './client';
|
|
2
|
+
declare type SubscriptionState = {
|
|
3
|
+
client: _ClientImpl;
|
|
4
|
+
debuggableClients: _ClientImpl[];
|
|
5
|
+
};
|
|
6
|
+
declare type SubscribeCallback = (arg: SubscriptionState) => void;
|
|
7
|
+
declare type UnsubscribeCallback = () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Class to manage boardgame.io clients and limit debug panel rendering.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ClientManager {
|
|
12
|
+
private debugPanel;
|
|
13
|
+
private currentClient;
|
|
14
|
+
private clients;
|
|
15
|
+
private subscribers;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Register a client with the client manager.
|
|
19
|
+
*/
|
|
20
|
+
register(client: _ClientImpl): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregister a client from the client manager.
|
|
23
|
+
*/
|
|
24
|
+
unregister(client: _ClientImpl): void;
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe to the client manager state.
|
|
27
|
+
* Calls the passed callback each time the current client changes or a client
|
|
28
|
+
* registers/unregisters.
|
|
29
|
+
* Returns a function to unsubscribe from the state updates.
|
|
30
|
+
*/
|
|
31
|
+
subscribe(callback: SubscribeCallback): UnsubscribeCallback;
|
|
32
|
+
/**
|
|
33
|
+
* Switch to a client with a matching playerID.
|
|
34
|
+
*/
|
|
35
|
+
switchPlayerID(playerID: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Set the passed client as the active client for debugging.
|
|
38
|
+
*/
|
|
39
|
+
switchToClient(client: _ClientImpl): void;
|
|
40
|
+
/**
|
|
41
|
+
* Notify all subscribers of changes to the client manager state.
|
|
42
|
+
*/
|
|
43
|
+
private notifySubscribers;
|
|
44
|
+
/**
|
|
45
|
+
* Get the client manager state.
|
|
46
|
+
*/
|
|
47
|
+
private getState;
|
|
48
|
+
/**
|
|
49
|
+
* Get an array of the registered clients that haven’t disabled the debug panel.
|
|
50
|
+
*/
|
|
51
|
+
private getDebuggableClients;
|
|
52
|
+
/**
|
|
53
|
+
* Mount the debug panel using the passed client.
|
|
54
|
+
*/
|
|
55
|
+
private mountDebug;
|
|
56
|
+
/**
|
|
57
|
+
* Unmount the debug panel.
|
|
58
|
+
*/
|
|
59
|
+
private unmountDebug;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import type { ClientOpts, ClientState, _ClientImpl } from './client';
|
|
4
|
+
declare type WrappedBoardDelegates = 'matchID' | 'playerID' | 'credentials';
|
|
5
|
+
export declare type WrappedBoardProps = Pick<ClientOpts, WrappedBoardDelegates | 'debug'>;
|
|
6
|
+
declare type ExposedClientProps<G extends any = any> = Pick<_ClientImpl<G>, 'log' | 'moves' | 'events' | 'reset' | 'undo' | 'redo' | 'playerID' | 'matchID' | 'matchData' | 'sendChatMessage' | 'chatMessages'>;
|
|
7
|
+
export declare type BoardProps<G extends any = any> = ClientState<G> & Omit<WrappedBoardProps, keyof ExposedClientProps<G>> & ExposedClientProps<G> & {
|
|
8
|
+
isMultiplayer: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare type ReactClientOpts<G extends any = any, P extends BoardProps<G> = BoardProps<G>, PluginAPIs extends Record<string, unknown> = Record<string, unknown>> = Omit<ClientOpts<G, PluginAPIs>, WrappedBoardDelegates> & {
|
|
11
|
+
board?: React.ComponentType<P>;
|
|
12
|
+
loading?: React.ComponentType;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Client
|
|
16
|
+
*
|
|
17
|
+
* boardgame.io React client.
|
|
18
|
+
*
|
|
19
|
+
* @param {...object} game - The return value of `Game`.
|
|
20
|
+
* @param {...object} numPlayers - The number of players.
|
|
21
|
+
* @param {...object} board - The React component for the game.
|
|
22
|
+
* @param {...object} loading - (optional) The React component for the loading state.
|
|
23
|
+
* @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()
|
|
24
|
+
* @param {...object} debug - Enables the Debug UI.
|
|
25
|
+
* @param {...object} enhancer - Optional enhancer to send to the Redux store
|
|
26
|
+
*
|
|
27
|
+
* Returns:
|
|
28
|
+
* A React component that wraps board and provides an
|
|
29
|
+
* API through props for it to interact with the framework
|
|
30
|
+
* and dispatch actions such as MAKE_MOVE, GAME_EVENT, RESET,
|
|
31
|
+
* UNDO and REDO.
|
|
32
|
+
*/
|
|
33
|
+
export declare function Client<G extends any = any, P extends BoardProps<G> = BoardProps<G>, PluginAPIs extends Record<string, unknown> = Record<string, unknown>>(opts: ReactClientOpts<G, P, PluginAPIs>): {
|
|
34
|
+
new (props: Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>): {
|
|
35
|
+
client: _ClientImpl<G>;
|
|
36
|
+
unsubscribe?: () => void;
|
|
37
|
+
componentDidMount(): void;
|
|
38
|
+
componentWillUnmount(): void;
|
|
39
|
+
componentDidUpdate(prevProps: Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>): void;
|
|
40
|
+
render(): JSX.Element;
|
|
41
|
+
context: any;
|
|
42
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
43
|
+
forceUpdate(callback?: () => void): void;
|
|
44
|
+
readonly props: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>> & Readonly<{
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
}>;
|
|
47
|
+
state: Readonly<{}>;
|
|
48
|
+
refs: {
|
|
49
|
+
[key: string]: React.ReactInstance;
|
|
50
|
+
};
|
|
51
|
+
shouldComponentUpdate?(nextProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
52
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
53
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, prevState: Readonly<{}>): any;
|
|
54
|
+
componentWillMount?(): void;
|
|
55
|
+
UNSAFE_componentWillMount?(): void;
|
|
56
|
+
componentWillReceiveProps?(nextProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, nextContext: any): void;
|
|
57
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, nextContext: any): void;
|
|
58
|
+
componentWillUpdate?(nextProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, nextState: Readonly<{}>, nextContext: any): void;
|
|
59
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<Pick<ClientOpts<any, Record<string, unknown>>, "matchID" | "playerID" | "credentials" | "debug"> & Pick<P, Exclude<keyof P, "matchID" | "playerID" | "credentials" | "debug" | "log" | "moves" | "events" | "reset" | "undo" | "redo" | "matchData" | "sendChatMessage" | "chatMessages" | "plugins" | "deltalog" | "G" | "ctx" | "_undo" | "_redo" | "_stateID" | "isActive" | "isConnected" | "isMultiplayer">>>, nextState: Readonly<{}>, nextContext: any): void;
|
|
60
|
+
};
|
|
61
|
+
propTypes: {
|
|
62
|
+
matchID: PropTypes.Requireable<string>;
|
|
63
|
+
playerID: PropTypes.Requireable<string>;
|
|
64
|
+
credentials: PropTypes.Requireable<string>;
|
|
65
|
+
debug: PropTypes.Requireable<any>;
|
|
66
|
+
};
|
|
67
|
+
defaultProps: {
|
|
68
|
+
matchID: string;
|
|
69
|
+
playerID: any;
|
|
70
|
+
credentials: any;
|
|
71
|
+
debug: boolean;
|
|
72
|
+
};
|
|
73
|
+
contextType?: React.Context<any>;
|
|
74
|
+
};
|
|
75
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|