@dxos/plugin-chess 0.8.4-main.fffef41 → 0.9.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/LICENSE +102 -5
- package/PLUGIN.mdl +526 -0
- package/README.md +1 -1
- package/dist/lib/neutral/ChessArticle-JHI5OXYR.mjs +88 -0
- package/dist/lib/neutral/ChessArticle-JHI5OXYR.mjs.map +7 -0
- package/dist/lib/neutral/ChessCard-4TUTIFB6.mjs +19 -0
- package/dist/lib/neutral/ChessCard-4TUTIFB6.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.mjs +10 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +13 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/{browser/chunk-DUO4WTAM.mjs → neutral/chunk-7XZ4CRDL.mjs} +15 -11
- package/dist/lib/neutral/chunk-7XZ4CRDL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-OYWDKJ5B.mjs +148 -0
- package/dist/lib/neutral/chunk-OYWDKJ5B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PJOAFP6S.mjs +41 -0
- package/dist/lib/neutral/chunk-PJOAFP6S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs +34 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YB6WZOZI.mjs +8 -0
- package/dist/lib/neutral/chunk-YB6WZOZI.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +239 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs +41 -0
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +18 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/move-6NCMKKWD.mjs +37 -0
- package/dist/lib/neutral/move-6NCMKKWD.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +13 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/play-F5L5LFLW.mjs +46 -0
- package/dist/lib/neutral/play-F5L5LFLW.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/print-GMSNKAS2.mjs +29 -0
- package/dist/lib/neutral/print-GMSNKAS2.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +39 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/ChessPlugin.d.ts +3 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/ChessPlugin.node.d.ts +8 -0
- package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.test.d.ts +2 -0
- package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/game-variant.d.ts +6 -0
- package/dist/types/src/capabilities/game-variant.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +10 -10
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +65 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Info.d.ts → Chessboard/Info.d.ts} +5 -6
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +5 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +64 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +5 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/{components/Card.stories.d.ts → containers/ChessCard/ChessCard.stories.d.ts} +2 -9
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +2 -0
- package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/move.d.ts +5 -0
- package/dist/types/src/operations/move.d.ts.map +1 -0
- package/dist/types/src/operations/play.d.ts +5 -0
- package/dist/types/src/operations/play.d.ts.map +1 -0
- package/dist/types/src/operations/print.d.ts +5 -0
- package/dist/types/src/operations/print.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +40 -22
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +12 -22
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/ChessOperation.d.ts +29 -0
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -56
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +50 -0
- package/src/ChessPlugin.tsx +24 -53
- package/src/ChessPlugin.workerd.ts +18 -0
- package/src/blueprints/chess-blueprint.ts +32 -0
- package/src/blueprints/index.ts +5 -0
- package/src/capabilities/blueprint-definition.ts +11 -28
- package/src/capabilities/game-variant.ts +45 -0
- package/src/capabilities/index.ts +14 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +35 -32
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +33 -76
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +1 -5
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +59 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +108 -0
- package/src/containers/ChessArticle/index.ts +5 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +47 -0
- package/src/containers/ChessCard/ChessCard.tsx +27 -0
- package/src/containers/ChessCard/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +1 -5
- package/src/meta.ts +10 -4
- package/src/operations/index.ts +11 -0
- package/src/operations/move.ts +36 -0
- package/src/operations/play.ts +45 -0
- package/src/operations/print.ts +28 -0
- package/src/plugin.ts +11 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +23 -20
- package/src/types/Chess.ts +23 -30
- package/src/types/ChessOperation.ts +88 -0
- package/src/types/index.ts +1 -1
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs +0 -96
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs +0 -11
- package/dist/lib/browser/chunk-5DOZV3PW.mjs +0 -294
- package/dist/lib/browser/chunk-5DOZV3PW.mjs.map +0 -7
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +0 -7
- package/dist/lib/browser/chunk-FBLAVAMY.mjs +0 -84
- package/dist/lib/browser/chunk-FBLAVAMY.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs +0 -8
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs.map +0 -7
- package/dist/lib/browser/chunk-TIIGNOGK.mjs +0 -169
- package/dist/lib/browser/chunk-TIIGNOGK.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -124
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-GXZN2EBT.mjs +0 -25
- package/dist/lib/browser/intent-resolver-GXZN2EBT.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-KTTAUHAA.mjs +0 -38
- package/dist/lib/browser/react-surface-KTTAUHAA.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs +0 -97
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs +0 -12
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs +0 -295
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs +0 -29
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs +0 -85
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs +0 -170
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VVXTAVIS.mjs +0 -10
- package/dist/lib/node-esm/chunk-VVXTAVIS.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -125
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-HK5L6P6Z.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-HK5L6P6Z.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-VO4PSY6O.mjs +0 -39
- package/dist/lib/node-esm/react-surface-VO4PSY6O.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -44
- package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +0 -7
- package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +0 -9
- package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
- package/dist/types/src/components/Info.d.ts.map +0 -1
- package/dist/types/src/functions/create.d.ts +0 -14
- package/dist/types/src/functions/create.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/move.d.ts +0 -8
- package/dist/types/src/functions/move.d.ts.map +0 -1
- package/dist/types/src/functions/play.d.ts +0 -9
- package/dist/types/src/functions/play.d.ts.map +0 -1
- package/dist/types/src/types/ChessAction.d.ts +0 -24
- package/dist/types/src/types/ChessAction.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -129
- package/src/capabilities/intent-resolver.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -23
- package/src/components/Card.stories.tsx +0 -66
- package/src/components/Chessboard.stories.tsx +0 -49
- package/src/components/ChessboardArticle.tsx +0 -68
- package/src/components/ChessboardContainer.tsx +0 -44
- package/src/functions/create.ts +0 -32
- package/src/functions/index.ts +0 -7
- package/src/functions/move.ts +0 -45
- package/src/functions/play.ts +0 -55
- package/src/types/ChessAction.ts +0 -19
- /package/dist/lib/{browser/blueprint-definition-FD4TL5EE.mjs.map → neutral/ChessPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-O7ZM3HUF.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
package/package.json
CHANGED
|
@@ -1,87 +1,147 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-chess",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#blueprints": {
|
|
17
|
+
"source": "./src/blueprints/index.ts",
|
|
18
|
+
"types": "./dist/types/src/blueprints/index.d.ts",
|
|
19
|
+
"default": "./dist/lib/neutral/blueprints/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"#capabilities": {
|
|
22
|
+
"source": "./src/capabilities/index.ts",
|
|
23
|
+
"types": "./dist/types/src/capabilities/index.d.ts",
|
|
24
|
+
"default": "./dist/lib/neutral/capabilities/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"#components": {
|
|
27
|
+
"source": "./src/components/index.ts",
|
|
28
|
+
"types": "./dist/types/src/components/index.d.ts",
|
|
29
|
+
"default": "./dist/lib/neutral/components/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"#containers": {
|
|
32
|
+
"source": "./src/containers/index.ts",
|
|
33
|
+
"types": "./dist/types/src/containers/index.d.ts",
|
|
34
|
+
"default": "./dist/lib/neutral/containers/index.mjs"
|
|
35
|
+
},
|
|
36
|
+
"#meta": {
|
|
37
|
+
"source": "./src/meta.ts",
|
|
38
|
+
"types": "./dist/types/src/meta.d.ts",
|
|
39
|
+
"default": "./dist/lib/neutral/meta.mjs"
|
|
40
|
+
},
|
|
41
|
+
"#operations": {
|
|
42
|
+
"source": "./src/operations/index.ts",
|
|
43
|
+
"types": "./dist/types/src/operations/index.d.ts",
|
|
44
|
+
"default": "./dist/lib/neutral/operations/index.mjs"
|
|
45
|
+
},
|
|
46
|
+
"#plugin": {
|
|
47
|
+
"source": {
|
|
48
|
+
"workerd": "./src/ChessPlugin.workerd.ts",
|
|
49
|
+
"node": "./src/ChessPlugin.node.ts",
|
|
50
|
+
"default": "./src/ChessPlugin.tsx"
|
|
51
|
+
},
|
|
52
|
+
"types": "./dist/types/src/ChessPlugin.d.ts",
|
|
53
|
+
"workerd": "./dist/lib/neutral/ChessPlugin.workerd.mjs",
|
|
54
|
+
"node": "./dist/lib/neutral/ChessPlugin.node.mjs",
|
|
55
|
+
"default": "./dist/lib/neutral/ChessPlugin.mjs"
|
|
56
|
+
},
|
|
57
|
+
"#translations": {
|
|
58
|
+
"source": "./src/translations.ts",
|
|
59
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
60
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
61
|
+
},
|
|
62
|
+
"#types": {
|
|
63
|
+
"source": "./src/types/index.ts",
|
|
64
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
65
|
+
"default": "./dist/lib/neutral/types/index.mjs"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
11
68
|
"exports": {
|
|
12
69
|
".": {
|
|
13
70
|
"source": "./src/index.ts",
|
|
14
71
|
"types": "./dist/types/src/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
|
|
72
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
73
|
+
},
|
|
74
|
+
"./assets/PLUGIN.mdl": "./PLUGIN.mdl",
|
|
75
|
+
"./blueprints": {
|
|
76
|
+
"source": "./src/blueprints/index.ts",
|
|
77
|
+
"types": "./dist/types/src/blueprints/index.d.ts",
|
|
78
|
+
"default": "./dist/lib/neutral/blueprints/index.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./plugin": {
|
|
81
|
+
"source": "./src/plugin.ts",
|
|
82
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
83
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
84
|
+
},
|
|
85
|
+
"./testing": {
|
|
86
|
+
"source": "./src/testing.ts",
|
|
87
|
+
"types": "./dist/types/src/testing.d.ts",
|
|
88
|
+
"default": "./dist/lib/neutral/testing.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./translations": {
|
|
91
|
+
"source": "./src/translations.ts",
|
|
92
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
93
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
17
94
|
},
|
|
18
95
|
"./types": {
|
|
19
96
|
"source": "./src/types/index.ts",
|
|
20
97
|
"types": "./dist/types/src/types/index.d.ts",
|
|
21
|
-
"
|
|
22
|
-
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
23
|
-
},
|
|
24
|
-
"./functions": {
|
|
25
|
-
"source": "./src/functions/index.ts",
|
|
26
|
-
"types": "./dist/types/src/functions/index.d.ts",
|
|
27
|
-
"browser": "./dist/lib/browser/functions/index.mjs",
|
|
28
|
-
"node": "./dist/lib/node-esm/functions/index.mjs"
|
|
98
|
+
"default": "./dist/lib/neutral/types/index.mjs"
|
|
29
99
|
}
|
|
30
100
|
},
|
|
31
101
|
"types": "dist/types/src/index.d.ts",
|
|
32
|
-
"typesVersions": {
|
|
33
|
-
"*": {
|
|
34
|
-
"types": [
|
|
35
|
-
"dist/types/src/types/index.d.ts"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
102
|
"files": [
|
|
40
103
|
"dist",
|
|
41
|
-
"src"
|
|
104
|
+
"src",
|
|
105
|
+
"PLUGIN.mdl"
|
|
42
106
|
],
|
|
43
107
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@preact/signals-core": "^1.12.1",
|
|
108
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
46
109
|
"chess.js": "^1.0.0",
|
|
47
|
-
"effect": "3.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/app-framework": "0.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/echo": "0.
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/plugin-client": "0.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/react-ui-
|
|
64
|
-
"@dxos/react-ui-stack": "0.8.4-main.fffef41",
|
|
65
|
-
"@dxos/schema": "0.8.4-main.fffef41",
|
|
66
|
-
"@dxos/util": "0.8.4-main.fffef41",
|
|
67
|
-
"@dxos/react-ui-gameboard": "0.8.4-main.fffef41"
|
|
110
|
+
"effect": "3.21.3",
|
|
111
|
+
"@dxos/async": "0.9.0",
|
|
112
|
+
"@dxos/app-framework": "0.9.0",
|
|
113
|
+
"@dxos/compute": "0.9.0",
|
|
114
|
+
"@dxos/app-toolkit": "0.9.0",
|
|
115
|
+
"@dxos/echo-react": "0.9.0",
|
|
116
|
+
"@dxos/echo": "0.9.0",
|
|
117
|
+
"@dxos/keys": "0.9.0",
|
|
118
|
+
"@dxos/log": "0.9.0",
|
|
119
|
+
"@dxos/invariant": "0.9.0",
|
|
120
|
+
"@dxos/plugin-client": "0.9.0",
|
|
121
|
+
"@dxos/plugin-game": "0.9.0",
|
|
122
|
+
"@dxos/react-ui-audio": "0.9.0",
|
|
123
|
+
"@dxos/react-client": "0.9.0",
|
|
124
|
+
"@dxos/react-ui-gameboard": "0.9.0",
|
|
125
|
+
"@dxos/util": "0.9.0",
|
|
126
|
+
"@dxos/react-ui-mosaic": "0.9.0"
|
|
68
127
|
},
|
|
69
128
|
"devDependencies": {
|
|
70
|
-
"@types/react": "~19.2.
|
|
71
|
-
"@types/react-dom": "~19.2.
|
|
72
|
-
"react": "~19.2.
|
|
73
|
-
"react-dom": "~19.2.
|
|
74
|
-
"vite": "
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
129
|
+
"@types/react": "~19.2.7",
|
|
130
|
+
"@types/react-dom": "~19.2.3",
|
|
131
|
+
"react": "~19.2.3",
|
|
132
|
+
"react-dom": "~19.2.3",
|
|
133
|
+
"vite": "^8.0.16",
|
|
134
|
+
"@dxos/plugin-testing": "0.9.0",
|
|
135
|
+
"@dxos/plugin-theme": "0.9.0",
|
|
136
|
+
"@dxos/storybook-utils": "0.9.0",
|
|
137
|
+
"@dxos/ui-theme": "0.9.0",
|
|
138
|
+
"@dxos/react-ui": "0.9.0"
|
|
79
139
|
},
|
|
80
140
|
"peerDependencies": {
|
|
81
|
-
"react": "
|
|
82
|
-
"react-dom": "
|
|
83
|
-
"@dxos/react-ui": "0.
|
|
84
|
-
"@dxos/
|
|
141
|
+
"react": "~19.2.3",
|
|
142
|
+
"react-dom": "~19.2.3",
|
|
143
|
+
"@dxos/react-ui": "0.9.0",
|
|
144
|
+
"@dxos/ui-theme": "0.9.0"
|
|
85
145
|
},
|
|
86
146
|
"publishConfig": {
|
|
87
147
|
"access": "public"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { BlueprintDefinition, OperationHandler } from '#capabilities';
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { Chess } from '#types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Headless variant of ChessPlugin (no React surfaces / GameVariant).
|
|
14
|
+
* Used in node contexts (CLI, agents) where rendering is unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
17
|
+
AppPlugin.addSchemaModule({ schema: [Chess.State] }),
|
|
18
|
+
AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),
|
|
19
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
20
|
+
Plugin.make,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default ChessPlugin;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ActivationEvents } from '@dxos/app-framework';
|
|
8
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
9
|
+
import { ClientPlugin } from '@dxos/plugin-client/plugin';
|
|
10
|
+
import { GamePlugin } from '@dxos/plugin-game/plugin';
|
|
11
|
+
import { createComposerTestApp } from '@dxos/plugin-testing/harness';
|
|
12
|
+
|
|
13
|
+
import { ChessPlugin } from '#plugin';
|
|
14
|
+
|
|
15
|
+
import { meta } from './meta';
|
|
16
|
+
import { ChessOperation } from './types';
|
|
17
|
+
|
|
18
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
19
|
+
|
|
20
|
+
describe('ChessPlugin', () => {
|
|
21
|
+
test('modules activate on the expected events', async ({ expect }) => {
|
|
22
|
+
await using harness = await createComposerTestApp({
|
|
23
|
+
plugins: [ClientPlugin({}), GamePlugin(), ChessPlugin()],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Modules expected to be active after a normal startup (headless/node variant).
|
|
27
|
+
expect(harness.manager.getActive()).toEqual(expect.arrayContaining([moduleId('schema')]));
|
|
28
|
+
|
|
29
|
+
// SetupArtifactDefinition is fired by AssistantPlugin, which can't be included here due to a workspace cycle.
|
|
30
|
+
await harness.fire(AppActivationEvents.SetupArtifactDefinition);
|
|
31
|
+
expect(harness.manager.getActive()).toContain(moduleId('BlueprintDefinition'));
|
|
32
|
+
|
|
33
|
+
// Operation handlers are not loaded on startup — SetupProcessManager fires lazily when an operation is invoked.
|
|
34
|
+
await harness.fire(ActivationEvents.SetupProcessManager);
|
|
35
|
+
expect(harness.manager.getActive()).toContain(moduleId('OperationHandler'));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('invokes the Print operation via the invoker capability', async ({ expect }) => {
|
|
39
|
+
await using harness = await createComposerTestApp({ plugins: [GamePlugin(), ChessPlugin()] });
|
|
40
|
+
const result = await harness.invoke(ChessOperation.Print, {});
|
|
41
|
+
// Empty input returns empty ASCII (handler swallows errors for malformed FEN).
|
|
42
|
+
expect(typeof result.ascii).toBe('string');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Print renders a PGN to ASCII board', async ({ expect }) => {
|
|
46
|
+
await using harness = await createComposerTestApp({ plugins: [GamePlugin(), ChessPlugin()] });
|
|
47
|
+
const { ascii } = await harness.invoke(ChessOperation.Print, { pgn: '1. e4 e5' });
|
|
48
|
+
expect(ascii).toContain('a b c d e f g h');
|
|
49
|
+
});
|
|
50
|
+
});
|
package/src/ChessPlugin.tsx
CHANGED
|
@@ -2,60 +2,31 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
|
-
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin, AppActivationEvents } from '@dxos/app-toolkit';
|
|
9
7
|
|
|
10
|
-
import { BlueprintDefinition,
|
|
11
|
-
import { meta } from '
|
|
12
|
-
import { translations } from '
|
|
13
|
-
import { Chess
|
|
8
|
+
import { BlueprintDefinition, GameVariant, OperationHandler } from '#capabilities';
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { translations } from '#translations';
|
|
11
|
+
import { Chess } from '#types';
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
activatesOn: Events.SetupMetadata,
|
|
24
|
-
activate: () =>
|
|
25
|
-
contributes(Capabilities.Metadata, {
|
|
26
|
-
id: Chess.Game.typename,
|
|
27
|
-
metadata: {
|
|
28
|
-
icon: 'ph--shield-chevron--regular',
|
|
29
|
-
iconHue: 'amber',
|
|
30
|
-
blueprints: [CHESS_BLUEPRINT_KEY],
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
34
|
-
defineModule({
|
|
35
|
-
id: `${meta.id}/module/object-form`,
|
|
36
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
37
|
-
activate: () =>
|
|
38
|
-
contributes(
|
|
39
|
-
SpaceCapabilities.ObjectForm,
|
|
40
|
-
defineObjectForm({
|
|
41
|
-
objectSchema: Chess.Game,
|
|
42
|
-
getIntent: () => createIntent(ChessAction.Create),
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
}),
|
|
46
|
-
defineModule({
|
|
47
|
-
id: `${meta.id}/module/react-surface`,
|
|
48
|
-
activatesOn: Events.SetupReactSurface,
|
|
49
|
-
activate: ReactSurface,
|
|
50
|
-
}),
|
|
51
|
-
defineModule({
|
|
52
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
53
|
-
activatesOn: Events.SetupIntentResolver,
|
|
54
|
-
activate: IntentResolver,
|
|
13
|
+
// eslint-disable-next-line import/no-relative-packages
|
|
14
|
+
import pluginSpec from '../PLUGIN.mdl?raw';
|
|
15
|
+
|
|
16
|
+
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
id: 'game-variant',
|
|
19
|
+
activatesOn: AppActivationEvents.SetupSchema,
|
|
20
|
+
activate: GameVariant,
|
|
55
21
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
22
|
+
AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),
|
|
23
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
24
|
+
AppPlugin.addPluginAssetModule({
|
|
25
|
+
asset: { pluginId: meta.id, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },
|
|
60
26
|
}),
|
|
61
|
-
])
|
|
27
|
+
AppPlugin.addSchemaModule({ schema: [Chess.State] }),
|
|
28
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
29
|
+
Plugin.make,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export default ChessPlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { OperationHandler } from '#capabilities';
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { Chess } from '#types';
|
|
11
|
+
|
|
12
|
+
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
13
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
14
|
+
AppPlugin.addSchemaModule({ schema: [Chess.State] }),
|
|
15
|
+
Plugin.make,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export default ChessPlugin;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Blueprint, Template } from '@dxos/compute';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import { Chess, ChessOperation } from '#types';
|
|
9
|
+
|
|
10
|
+
const operations = [ChessOperation.Move, ChessOperation.Play, ChessOperation.Print];
|
|
11
|
+
|
|
12
|
+
const make = () =>
|
|
13
|
+
Blueprint.make({
|
|
14
|
+
key: Chess.BLUEPRINT_KEY,
|
|
15
|
+
name: 'Chess',
|
|
16
|
+
tools: Blueprint.toolDefinitions({ operations }),
|
|
17
|
+
instructions: Template.make({
|
|
18
|
+
source: trim`
|
|
19
|
+
You are an expert chess player.
|
|
20
|
+
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
21
|
+
You could suggest a good next move or offer to play a move.
|
|
22
|
+
Don't actually make a move unless you are asked to.
|
|
23
|
+
`,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const blueprint: Blueprint.Definition = {
|
|
28
|
+
key: Chess.BLUEPRINT_KEY,
|
|
29
|
+
make,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default blueprint;
|
|
@@ -2,35 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { Blueprint, Template } from '@dxos/blueprints';
|
|
7
|
-
import { type FunctionDefinition } from '@dxos/functions';
|
|
8
|
-
import { trim } from '@dxos/util';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
9
6
|
|
|
10
|
-
import {
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
import { ChessBlueprint } from '#blueprints';
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
// NOTE: Explicit annotation required: d.ts emit cannot portably name the inferred @dxos/compute types (TS2883).
|
|
13
|
+
const blueprintDefinition: () => Effect.Effect<
|
|
14
|
+
Capability.Capability<typeof AppCapabilities.BlueprintDefinition>[],
|
|
15
|
+
never,
|
|
16
|
+
Capability.Service
|
|
17
|
+
> = () => Effect.succeed([Capability.contributes(AppCapabilities.BlueprintDefinition, ChessBlueprint)]);
|
|
15
18
|
|
|
16
|
-
export default
|
|
17
|
-
return [
|
|
18
|
-
contributes(Capabilities.Functions, functions),
|
|
19
|
-
contributes(
|
|
20
|
-
Capabilities.BlueprintDefinition,
|
|
21
|
-
Blueprint.make({
|
|
22
|
-
key: CHESS_BLUEPRINT_KEY,
|
|
23
|
-
name: 'Chess',
|
|
24
|
-
tools: Blueprint.toolDefinitions({ functions }),
|
|
25
|
-
instructions: Template.make({
|
|
26
|
-
source: trim`
|
|
27
|
-
You are an expert chess player.
|
|
28
|
-
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
29
|
-
You could suggest a good next move or offer to play a move.
|
|
30
|
-
Don't actually make a move unless you are asked to.
|
|
31
|
-
`,
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
34
|
-
),
|
|
35
|
-
];
|
|
36
|
-
};
|
|
19
|
+
export default blueprintDefinition;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Type } from '@dxos/echo';
|
|
10
|
+
import { GameCapabilities, type GameVariant } from '@dxos/plugin-game/types';
|
|
11
|
+
|
|
12
|
+
import { ChessArticle, ChessCard } from '#containers';
|
|
13
|
+
import { Chess } from '#types';
|
|
14
|
+
|
|
15
|
+
const CreateChessInput = Schema.Struct({
|
|
16
|
+
name: Schema.optional(
|
|
17
|
+
Schema.String.annotations({
|
|
18
|
+
title: 'Name',
|
|
19
|
+
description: 'Optional name for the game.',
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
pgn: Schema.optional(
|
|
23
|
+
Schema.String.annotations({
|
|
24
|
+
title: 'PGN',
|
|
25
|
+
description: 'Optional Portable Game Notation to start from.',
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const variant: GameVariant = {
|
|
31
|
+
id: Type.getTypename(Chess.State),
|
|
32
|
+
label: 'Chess',
|
|
33
|
+
icon: 'ph--shield-chevron--regular',
|
|
34
|
+
variantType: Chess.State,
|
|
35
|
+
inputSchema: CreateChessInput,
|
|
36
|
+
roles: ['white', 'black'] as const,
|
|
37
|
+
createVariant: (input) =>
|
|
38
|
+
Effect.sync(() => Chess.make({ pgn: typeof input.pgn === 'string' ? input.pgn : undefined })),
|
|
39
|
+
card: ChessCard,
|
|
40
|
+
article: ChessArticle,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Capability.makeModule(() =>
|
|
44
|
+
Effect.succeed(Capability.contributes(GameCapabilities.VariantProvider, variant)),
|
|
45
|
+
);
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import { type AppCapabilities } from '@dxos/app-toolkit';
|
|
7
|
+
import type { OperationHandlerSet } from '@dxos/compute';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// The contributed capability type references Blueprint types from @dxos/compute, so the lazy
|
|
10
|
+
// wrapper needs an explicit annotation to keep the inferred type portable (TS2883).
|
|
11
|
+
export const BlueprintDefinition: Capability.LazyCapability<
|
|
12
|
+
void,
|
|
13
|
+
Capability.Capability<typeof AppCapabilities.BlueprintDefinition>[]
|
|
14
|
+
> = Capability.lazy('BlueprintDefinition', () => import('./blueprint-definition'));
|
|
15
|
+
export const GameVariant = Capability.lazy('GameVariant', () => import('./game-variant'));
|
|
16
|
+
export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
|
|
17
|
+
'OperationHandler',
|
|
18
|
+
() => import('./operation-handler'),
|
|
19
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
import type { OperationHandlerSet } from '@dxos/compute';
|
|
7
|
+
|
|
8
|
+
import { ChessOperationHandlerSet } from '#operations';
|
|
9
|
+
|
|
10
|
+
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
11
|
+
Effect.fnUntraced(function* () {
|
|
12
|
+
return Capability.contributes(Capabilities.OperationHandler, ChessOperationHandlerSet);
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
+
import { type Player } from '@dxos/react-ui-gameboard';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { translations } from '#translations';
|
|
13
|
+
import { Chess } from '#types';
|
|
14
|
+
|
|
15
|
+
import { Chessboard, type ChessboardController, type ChessboardInfoProps } from './Chessboard';
|
|
16
|
+
|
|
17
|
+
const SAMPLE_PGN =
|
|
18
|
+
'1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 *';
|
|
19
|
+
|
|
20
|
+
const PROMOTION_PGN =
|
|
21
|
+
'1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Kf8 16. e7+ Kg8 *';
|
|
22
|
+
|
|
23
|
+
type DefaultStoryProps = {
|
|
24
|
+
pgn?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const DefaultStory = ({ pgn }: DefaultStoryProps) => {
|
|
28
|
+
const state = useMemo(() => Chess.make(pgn ? { pgn } : undefined), [pgn]);
|
|
29
|
+
const [orientation, setOrientation] = useState<Player>('white');
|
|
30
|
+
const [showInfo, setShowInfo] = useState(true);
|
|
31
|
+
const controller = useRef<ChessboardController>(null);
|
|
32
|
+
|
|
33
|
+
const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {
|
|
34
|
+
controller.current?.setMoveNumber(index);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Chessboard.Root state={state} ref={controller}>
|
|
39
|
+
<div className='flex h-full w-full gap-4 p-4 overflow-hidden'>
|
|
40
|
+
<Chessboard.Content classNames='grow'>
|
|
41
|
+
<Chessboard.Board classNames='border rounded-xs' orientation={orientation} />
|
|
42
|
+
</Chessboard.Content>
|
|
43
|
+
{showInfo && (
|
|
44
|
+
<div className='flex flex-col justify-center items-center overflow-hidden'>
|
|
45
|
+
<Chessboard.Info
|
|
46
|
+
orientation={orientation}
|
|
47
|
+
min={8}
|
|
48
|
+
max={8}
|
|
49
|
+
onOrientationChange={setOrientation}
|
|
50
|
+
onClose={() => setShowInfo(false)}
|
|
51
|
+
onSelect={handleSelect}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</Chessboard.Root>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const meta = {
|
|
61
|
+
title: 'plugins/plugin-chess/components/Chessboard',
|
|
62
|
+
component: DefaultStory,
|
|
63
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withClientProvider({ createIdentity: true })],
|
|
64
|
+
parameters: {
|
|
65
|
+
layout: 'fullscreen',
|
|
66
|
+
translations,
|
|
67
|
+
},
|
|
68
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
69
|
+
|
|
70
|
+
export default meta;
|
|
71
|
+
|
|
72
|
+
type Story = StoryObj<typeof meta>;
|
|
73
|
+
|
|
74
|
+
export const Default: Story = {
|
|
75
|
+
args: {},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const WithPgn: Story = {
|
|
79
|
+
args: {
|
|
80
|
+
pgn: SAMPLE_PGN,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Promotion: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
pgn: PROMOTION_PGN,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const NewGame: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
pgn: undefined,
|
|
93
|
+
},
|
|
94
|
+
};
|