@dxos/plugin-chess 0.8.4-main.c85a9c8dae → 0.8.4-main.d9fc60f731

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.
Files changed (240) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +526 -0
  3. package/README.md +1 -1
  4. package/dist/lib/neutral/ChessArticle-QLLKZGPH.mjs +88 -0
  5. package/dist/lib/neutral/ChessArticle-QLLKZGPH.mjs.map +7 -0
  6. package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs +19 -0
  7. package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs.map +7 -0
  8. package/dist/lib/neutral/ChessPlugin.mjs +10 -0
  9. package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
  10. package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
  11. package/dist/lib/neutral/ChessPlugin.workerd.mjs +21 -0
  12. package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +7 -0
  13. package/dist/lib/{browser/blueprint-definition-RLA7PQBB.mjs → neutral/blueprint-definition-PZXHAYLD.mjs} +4 -7
  14. package/dist/lib/neutral/blueprint-definition-PZXHAYLD.mjs.map +7 -0
  15. package/dist/lib/neutral/blueprints/index.mjs +8 -0
  16. package/dist/lib/neutral/capabilities/index.mjs +13 -0
  17. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  18. package/dist/lib/{node-esm/chunk-F5OMIM4F.mjs → neutral/chunk-7XZ4CRDL.mjs} +15 -6
  19. package/dist/lib/neutral/chunk-7XZ4CRDL.mjs.map +7 -0
  20. package/dist/lib/neutral/chunk-KMHQCP7J.mjs +148 -0
  21. package/dist/lib/neutral/chunk-KMHQCP7J.mjs.map +7 -0
  22. package/dist/lib/neutral/chunk-PJOAFP6S.mjs +41 -0
  23. package/dist/lib/neutral/chunk-PJOAFP6S.mjs.map +7 -0
  24. package/dist/lib/neutral/chunk-W2JSKHJK.mjs +8 -0
  25. package/dist/lib/neutral/chunk-W2JSKHJK.mjs.map +7 -0
  26. package/dist/lib/neutral/chunk-XWKNXG62.mjs +34 -0
  27. package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
  28. package/dist/lib/{browser/chunk-KE4FN77G.mjs → neutral/components/index.mjs} +21 -58
  29. package/dist/lib/neutral/components/index.mjs.map +7 -0
  30. package/dist/lib/neutral/containers/index.mjs +11 -0
  31. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  32. package/dist/lib/neutral/game-variant-UMYAK7LT.mjs +41 -0
  33. package/dist/lib/neutral/game-variant-UMYAK7LT.mjs.map +7 -0
  34. package/dist/lib/neutral/index.mjs +18 -0
  35. package/dist/lib/neutral/meta.json +1 -0
  36. package/dist/lib/neutral/meta.mjs +8 -0
  37. package/dist/lib/neutral/move-ORBNYB2H.mjs +37 -0
  38. package/dist/lib/neutral/move-ORBNYB2H.mjs.map +7 -0
  39. package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +13 -0
  40. package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +7 -0
  41. package/dist/lib/{browser/types → neutral/operations}/index.mjs +3 -3
  42. package/dist/lib/neutral/play-QJCLEC27.mjs +46 -0
  43. package/dist/lib/neutral/play-QJCLEC27.mjs.map +7 -0
  44. package/dist/lib/neutral/plugin.mjs +16 -0
  45. package/dist/lib/neutral/plugin.mjs.map +7 -0
  46. package/dist/lib/neutral/print-ILCRJUYI.mjs +29 -0
  47. package/dist/lib/neutral/print-ILCRJUYI.mjs.map +7 -0
  48. package/dist/lib/neutral/testing.mjs +8 -0
  49. package/dist/lib/neutral/translations.mjs +35 -0
  50. package/dist/lib/neutral/translations.mjs.map +7 -0
  51. package/dist/lib/neutral/types/index.mjs +10 -0
  52. package/dist/types/src/ChessPlugin.d.ts +1 -0
  53. package/dist/types/src/ChessPlugin.d.ts.map +1 -1
  54. package/dist/types/src/ChessPlugin.node.d.ts +8 -0
  55. package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
  56. package/dist/types/src/ChessPlugin.test.d.ts +2 -0
  57. package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
  58. package/dist/types/src/{cli/plugin.d.ts → ChessPlugin.workerd.d.ts} +2 -1
  59. package/dist/types/src/ChessPlugin.workerd.d.ts.map +1 -0
  60. package/dist/types/src/blueprints/chess-blueprint.d.ts +2 -2
  61. package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
  62. package/dist/types/src/blueprints/index.d.ts +0 -1
  63. package/dist/types/src/blueprints/index.d.ts.map +1 -1
  64. package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
  65. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  66. package/dist/types/src/capabilities/game-variant.d.ts +6 -0
  67. package/dist/types/src/capabilities/game-variant.d.ts.map +1 -0
  68. package/dist/types/src/capabilities/index.d.ts +5 -2
  69. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  70. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  71. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  72. package/dist/types/src/components/Chessboard/Chessboard.d.ts +8 -4
  73. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  74. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +57 -0
  75. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
  76. package/dist/types/src/components/Chessboard/Info.d.ts +4 -5
  77. package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -1
  78. package/dist/types/src/components/Chessboard/types.d.ts +3 -3
  79. package/dist/types/src/components/Chessboard/types.d.ts.map +1 -1
  80. package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +3 -4
  81. package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -1
  82. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +34 -24
  83. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
  84. package/dist/types/src/containers/ChessArticle/index.d.ts +1 -2
  85. package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -1
  86. package/dist/types/src/containers/ChessCard/ChessCard.d.ts +3 -4
  87. package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
  88. package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -1
  89. package/dist/types/src/containers/ChessCard/index.d.ts +1 -2
  90. package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -1
  91. package/dist/types/src/index.d.ts +0 -3
  92. package/dist/types/src/index.d.ts.map +1 -1
  93. package/dist/types/src/meta.d.ts +1 -1
  94. package/dist/types/src/meta.d.ts.map +1 -1
  95. package/dist/types/src/operations/index.d.ts +3 -0
  96. package/dist/types/src/operations/index.d.ts.map +1 -0
  97. package/dist/types/src/operations/move.d.ts +5 -0
  98. package/dist/types/src/operations/move.d.ts.map +1 -0
  99. package/dist/types/src/operations/play.d.ts +5 -0
  100. package/dist/types/src/operations/play.d.ts.map +1 -0
  101. package/dist/types/src/operations/print.d.ts +5 -0
  102. package/dist/types/src/operations/print.d.ts.map +1 -0
  103. package/dist/types/src/plugin.d.ts +4 -0
  104. package/dist/types/src/plugin.d.ts.map +1 -0
  105. package/dist/types/src/testing.d.ts +2 -0
  106. package/dist/types/src/testing.d.ts.map +1 -0
  107. package/dist/types/src/translations.d.ts +32 -23
  108. package/dist/types/src/translations.d.ts.map +1 -1
  109. package/dist/types/src/types/Chess.d.ts +10 -20
  110. package/dist/types/src/types/Chess.d.ts.map +1 -1
  111. package/dist/types/src/types/ChessOperation.d.ts +29 -0
  112. package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
  113. package/dist/types/src/types/index.d.ts +1 -0
  114. package/dist/types/src/types/index.d.ts.map +1 -1
  115. package/dist/types/tsconfig.tsbuildinfo +1 -1
  116. package/package.json +100 -56
  117. package/src/ChessPlugin.node.ts +23 -0
  118. package/src/ChessPlugin.test.ts +50 -0
  119. package/src/ChessPlugin.tsx +19 -22
  120. package/src/ChessPlugin.workerd.ts +18 -0
  121. package/src/blueprints/chess-blueprint.ts +7 -11
  122. package/src/blueprints/index.ts +0 -1
  123. package/src/capabilities/{blueprint-definition/blueprint-definition.ts → blueprint-definition.ts} +3 -1
  124. package/src/capabilities/game-variant.ts +43 -0
  125. package/src/capabilities/index.ts +10 -2
  126. package/src/capabilities/operation-handler.ts +14 -0
  127. package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
  128. package/src/components/Chessboard/Chessboard.tsx +7 -13
  129. package/src/components/Chessboard/Info.tsx +21 -74
  130. package/src/components/Chessboard/types.ts +2 -2
  131. package/src/containers/ChessArticle/ChessArticle.stories.tsx +12 -6
  132. package/src/containers/ChessArticle/ChessArticle.tsx +55 -19
  133. package/src/containers/ChessArticle/index.ts +1 -3
  134. package/src/containers/ChessCard/ChessCard.stories.tsx +10 -5
  135. package/src/containers/ChessCard/ChessCard.tsx +11 -6
  136. package/src/containers/ChessCard/index.ts +1 -3
  137. package/src/index.ts +0 -4
  138. package/src/meta.ts +10 -4
  139. package/src/operations/index.ts +11 -0
  140. package/src/operations/move.ts +36 -0
  141. package/src/operations/play.ts +45 -0
  142. package/src/operations/print.ts +28 -0
  143. package/src/plugin.ts +11 -0
  144. package/src/testing.ts +7 -0
  145. package/src/translations.ts +19 -21
  146. package/src/types/Chess.ts +21 -26
  147. package/src/types/ChessOperation.ts +88 -0
  148. package/src/types/index.ts +1 -0
  149. package/src/vite-env.d.ts +10 -0
  150. package/dist/lib/browser/ChessArticle-RI2DYAO4.mjs +0 -59
  151. package/dist/lib/browser/ChessArticle-RI2DYAO4.mjs.map +0 -7
  152. package/dist/lib/browser/ChessCard-AUMESHHE.mjs +0 -21
  153. package/dist/lib/browser/ChessCard-AUMESHHE.mjs.map +0 -7
  154. package/dist/lib/browser/blueprint-definition-RLA7PQBB.mjs.map +0 -7
  155. package/dist/lib/browser/blueprints/index.mjs +0 -11
  156. package/dist/lib/browser/chunk-66H3V2YV.mjs +0 -64
  157. package/dist/lib/browser/chunk-66H3V2YV.mjs.map +0 -7
  158. package/dist/lib/browser/chunk-AWDLDU43.mjs +0 -231
  159. package/dist/lib/browser/chunk-AWDLDU43.mjs.map +0 -7
  160. package/dist/lib/browser/chunk-H3NUMCQ6.mjs +0 -21
  161. package/dist/lib/browser/chunk-H3NUMCQ6.mjs.map +0 -7
  162. package/dist/lib/browser/chunk-KE4FN77G.mjs.map +0 -7
  163. package/dist/lib/browser/chunk-WYUTI2K4.mjs +0 -1
  164. package/dist/lib/browser/cli/index.mjs +0 -29
  165. package/dist/lib/browser/cli/index.mjs.map +0 -7
  166. package/dist/lib/browser/index.mjs +0 -94
  167. package/dist/lib/browser/index.mjs.map +0 -7
  168. package/dist/lib/browser/meta.json +0 -1
  169. package/dist/lib/browser/react-surface-7KUFGD7C.mjs +0 -50
  170. package/dist/lib/browser/react-surface-7KUFGD7C.mjs.map +0 -7
  171. package/dist/lib/node-esm/ChessArticle-6QNVYEZV.mjs +0 -60
  172. package/dist/lib/node-esm/ChessArticle-6QNVYEZV.mjs.map +0 -7
  173. package/dist/lib/node-esm/ChessCard-QK3ZMYLT.mjs +0 -22
  174. package/dist/lib/node-esm/ChessCard-QK3ZMYLT.mjs.map +0 -7
  175. package/dist/lib/node-esm/blueprint-definition-A2FFH3Z2.mjs +0 -19
  176. package/dist/lib/node-esm/blueprint-definition-A2FFH3Z2.mjs.map +0 -7
  177. package/dist/lib/node-esm/blueprints/index.mjs +0 -12
  178. package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs +0 -2
  179. package/dist/lib/node-esm/chunk-F5OMIM4F.mjs.map +0 -7
  180. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  181. package/dist/lib/node-esm/chunk-OUNGNJFP.mjs +0 -65
  182. package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +0 -7
  183. package/dist/lib/node-esm/chunk-R7FXSQ2P.mjs +0 -232
  184. package/dist/lib/node-esm/chunk-R7FXSQ2P.mjs.map +0 -7
  185. package/dist/lib/node-esm/chunk-RNPP75JE.mjs +0 -277
  186. package/dist/lib/node-esm/chunk-RNPP75JE.mjs.map +0 -7
  187. package/dist/lib/node-esm/cli/index.mjs +0 -30
  188. package/dist/lib/node-esm/cli/index.mjs.map +0 -7
  189. package/dist/lib/node-esm/index.mjs +0 -95
  190. package/dist/lib/node-esm/index.mjs.map +0 -7
  191. package/dist/lib/node-esm/meta.json +0 -1
  192. package/dist/lib/node-esm/react-surface-U3HGYR5T.mjs +0 -51
  193. package/dist/lib/node-esm/react-surface-U3HGYR5T.mjs.map +0 -7
  194. package/dist/lib/node-esm/types/index.mjs +0 -9
  195. package/dist/types/src/blueprints/functions/create.d.ts +0 -15
  196. package/dist/types/src/blueprints/functions/create.d.ts.map +0 -1
  197. package/dist/types/src/blueprints/functions/index.d.ts +0 -56
  198. package/dist/types/src/blueprints/functions/index.d.ts.map +0 -1
  199. package/dist/types/src/blueprints/functions/move.d.ts +0 -16
  200. package/dist/types/src/blueprints/functions/move.d.ts.map +0 -1
  201. package/dist/types/src/blueprints/functions/play.d.ts +0 -17
  202. package/dist/types/src/blueprints/functions/play.d.ts.map +0 -1
  203. package/dist/types/src/blueprints/functions/print.d.ts +0 -8
  204. package/dist/types/src/blueprints/functions/print.d.ts.map +0 -1
  205. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +0 -12
  206. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
  207. package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
  208. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
  209. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -6
  210. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
  211. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
  212. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
  213. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  214. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  215. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  216. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  217. package/dist/types/src/cli/index.d.ts +0 -2
  218. package/dist/types/src/cli/index.d.ts.map +0 -1
  219. package/dist/types/src/cli/plugin.d.ts.map +0 -1
  220. package/src/blueprints/functions/create.ts +0 -38
  221. package/src/blueprints/functions/index.ts +0 -17
  222. package/src/blueprints/functions/move.ts +0 -48
  223. package/src/blueprints/functions/play.ts +0 -58
  224. package/src/blueprints/functions/print.ts +0 -42
  225. package/src/capabilities/artifact-definition/artifact-definition.ts +0 -135
  226. package/src/capabilities/artifact-definition/index.ts +0 -7
  227. package/src/capabilities/blueprint-definition/index.ts +0 -7
  228. package/src/capabilities/react-surface/index.ts +0 -7
  229. package/src/capabilities/react-surface/react-surface.tsx +0 -33
  230. package/src/cli/index.ts +0 -5
  231. package/src/cli/plugin.ts +0 -27
  232. /package/dist/lib/{browser/blueprints/index.mjs.map → neutral/ChessPlugin.mjs.map} +0 -0
  233. /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
  234. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
  235. /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
  236. /package/dist/lib/{node-esm/blueprints → neutral}/index.mjs.map +0 -0
  237. /package/dist/lib/{browser/chunk-WYUTI2K4.mjs.map → neutral/meta.mjs.map} +0 -0
  238. /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
  239. /package/dist/lib/{node-esm/chunk-7XDEO6IJ.mjs.map → neutral/testing.mjs.map} +0 -0
  240. /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/types/index.mjs.map} +0 -0
@@ -5,14 +5,11 @@
5
5
  import { useAtomValue } from '@effect-atom/atom-react';
6
6
  import React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
7
7
 
8
- import { generateName } from '@dxos/display-name';
9
- import { Obj } from '@dxos/echo';
10
- import { type SpaceMember, useMembers } from '@dxos/react-client/echo';
11
- import { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '@dxos/react-ui';
8
+ import { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
12
9
  import { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';
13
10
  import { mx } from '@dxos/ui-theme';
14
11
 
15
- import { meta } from '../../meta';
12
+ import { meta } from '#meta';
16
13
 
17
14
  import { type ExtendedChessModel } from './types';
18
15
 
@@ -29,8 +26,6 @@ export type InfoProps = ThemedClassName<
29
26
  export const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {
30
27
  const { t } = useTranslation(meta.id);
31
28
  const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);
32
- const db = Obj.getDatabase(model.object);
33
- const members = useMembers(db?.spaceId);
34
29
 
35
30
  return (
36
31
  <div
@@ -44,20 +39,17 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
44
39
  player={orientation === 'white' ? 'black' : 'white'}
45
40
  icon={
46
41
  onClose && (
47
- <IconButton icon='ph--x--regular' iconOnly label={t('close info button')} size={4} onClick={onClose} />
42
+ <IconButton
43
+ variant='ghost'
44
+ icon='ph--x--regular'
45
+ iconOnly
46
+ label={t('close-info.button')}
47
+ size={4}
48
+ onClick={onClose}
49
+ />
48
50
  )
49
51
  }
50
- >
51
- <PlayerSelector
52
- value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}
53
- onValueChange={(value) => {
54
- Obj.change(model.object, (obj) => {
55
- obj.players![orientation === 'white' ? 'black' : 'white'] = value;
56
- });
57
- }}
58
- members={members}
59
- />
60
- </PlayerIndicator>
52
+ />
61
53
 
62
54
  <History model={model} {...props} />
63
55
 
@@ -70,23 +62,13 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
70
62
  classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}
71
63
  icon='ph--arrows-clockwise--regular'
72
64
  iconOnly
73
- label={t('flip board button')}
65
+ label={t('flip-board.button')}
74
66
  size={4}
75
67
  onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}
76
68
  />
77
69
  )
78
70
  }
79
- >
80
- <PlayerSelector
81
- value={model.object.players?.[orientation]}
82
- onValueChange={(value) => {
83
- Obj.change(model.object, (obj) => {
84
- obj.players![orientation] = value;
85
- });
86
- }}
87
- members={members}
88
- />
89
- </PlayerIndicator>
71
+ />
90
72
  </div>
91
73
  );
92
74
  };
@@ -109,12 +91,12 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
109
91
  const moveIndex = useAtomValue(model.moveIndex);
110
92
  const label = model.game.isGameOver()
111
93
  ? model.game.isCheckmate()
112
- ? t('game.checkmate label')
94
+ ? t('game.checkmate.label')
113
95
  : model.game.isStalemate()
114
- ? t('game.stalemate label')
115
- : t('game.draw label')
96
+ ? t('game.stalemate.label')
97
+ : t('game.draw.label')
116
98
  : model.game.isCheck()
117
- ? t('game.check label')
99
+ ? t('game.check.label')
118
100
  : undefined;
119
101
 
120
102
  const history = model.game.history();
@@ -156,12 +138,12 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
156
138
  }}
157
139
  >
158
140
  {moves.map(([a, b], index) => (
159
- <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4 leading-1'>
141
+ <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4'>
160
142
  <div className='content-center text-xs text-subdued'>{index + 1}</div>
161
143
  {a && (
162
144
  <div
163
145
  data-index={a.index}
164
- className={mx('ps-2 cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}
146
+ className={mx('ps-2 text-sm cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}
165
147
  onClick={() => onSelect?.(a.index + 1)}
166
148
  >
167
149
  {a.move}
@@ -170,7 +152,7 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
170
152
  {b && (
171
153
  <div
172
154
  data-index={b.index}
173
- className={mx('ps-2 cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}
155
+ className={mx('ps-2 text-sm cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}
174
156
  onClick={() => onSelect?.(b.index + 1)}
175
157
  >
176
158
  {b.move}
@@ -201,7 +183,7 @@ const PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps
201
183
  <Icon
202
184
  icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
203
185
  size={6}
204
- classNames={mx(turn && (model.game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
186
+ classNames={mx(turn && (model.game.isCheckmate() ? 'text-error-500' : 'text-success-text'))}
205
187
  />
206
188
  </div>
207
189
  <div className='truncate overflow-hidden items-center'>{children}</div>
@@ -209,38 +191,3 @@ const PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps
209
191
  </div>
210
192
  );
211
193
  };
212
-
213
- //
214
- // PlayerSelector
215
- //
216
-
217
- type PlayerSelectorProps = {
218
- value?: string;
219
- onValueChange: (player: string) => void;
220
- members: SpaceMember[];
221
- };
222
-
223
- const PlayerSelector = ({ value, onValueChange, members }: PlayerSelectorProps) => {
224
- const { t } = useTranslation(meta.id);
225
- return (
226
- <Select.Root value={value} onValueChange={onValueChange}>
227
- <Select.TriggerButton placeholder={t('select player button')} />
228
- <Select.Portal>
229
- <Select.Content>
230
- <Select.Viewport>
231
- {members.map((member) => {
232
- const memberKey = member.identity.identityKey.toHex();
233
- const displayName = member.identity?.profile?.displayName || generateName(memberKey);
234
- return (
235
- <Select.Option key={memberKey} value={memberKey}>
236
- {displayName}
237
- </Select.Option>
238
- );
239
- })}
240
- </Select.Viewport>
241
- <Select.Arrow />
242
- </Select.Content>
243
- </Select.Portal>
244
- </Select.Root>
245
- );
246
- };
@@ -6,12 +6,12 @@ import { type Registry } from '@effect-atom/atom-react';
6
6
 
7
7
  import { ChessModel } from '@dxos/react-ui-gameboard';
8
8
 
9
- import { type Chess } from '../../types';
9
+ import { type Chess } from '#types';
10
10
 
11
11
  export class ExtendedChessModel extends ChessModel {
12
12
  constructor(
13
13
  registry: Registry.Registry,
14
- readonly object: Chess.Game,
14
+ readonly object: Chess.State,
15
15
  ) {
16
16
  super(registry);
17
17
  }
@@ -5,21 +5,27 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useMemo } from 'react';
7
7
 
8
+ import { type Obj } from '@dxos/echo';
9
+ import { make as makeGame } from '@dxos/plugin-game';
8
10
  import { withClientProvider } from '@dxos/react-client/testing';
9
11
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
12
 
11
- import { translations } from '../../translations';
12
- import { Chess } from '../../types';
13
+ import { translations } from '#translations';
14
+ import { Chess } from '#types';
13
15
 
14
16
  import { ChessArticle } from './ChessArticle';
15
17
 
16
- type StoryProps = {
18
+ type DefaultStoryProps = {
17
19
  pgn?: string;
18
20
  };
19
21
 
20
- const DefaultStory = ({ pgn }: StoryProps) => {
21
- const game = useMemo(() => Chess.make(pgn ? { pgn } : undefined), [pgn]);
22
- return <ChessArticle subject={game} />;
22
+ const DefaultStory = ({ pgn }: DefaultStoryProps) => {
23
+ const { game, state } = useMemo(() => {
24
+ const state = Chess.make(pgn ? { pgn } : undefined);
25
+ const game = makeGame({ name: 'Story game', variant: state as Obj.Unknown });
26
+ return { game, state };
27
+ }, [pgn]);
28
+ return <ChessArticle role='article' attendableId='story' game={game} variant={state} />;
23
29
  };
24
30
 
25
31
  const meta = {
@@ -2,64 +2,100 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Chess as ChessJS } from 'chess.js';
5
6
  import React, { useCallback, useRef, useState } from 'react';
6
7
 
7
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
8
+ import { Obj } from '@dxos/echo';
9
+ import { type GameVariantSurfaceProps } from '@dxos/plugin-game';
8
10
  import { Panel, Toolbar, useTranslation } from '@dxos/react-ui';
9
11
  import { type Player } from '@dxos/react-ui-gameboard';
10
12
  import { mx } from '@dxos/ui-theme';
11
13
 
12
- import { Chessboard, type ChessboardController, type ChessboardInfoProps } from '../../components';
13
- import { meta } from '../../meta';
14
- import { type Chess } from '../../types';
14
+ import { Chessboard, type ChessboardController, type ChessboardInfoProps } from '#components';
15
+ import { meta } from '#meta';
16
+ import { Chess } from '#types';
15
17
 
16
- export type ChessArticleProps = SurfaceComponentProps<Chess.Game>;
18
+ export type ChessArticleProps = GameVariantSurfaceProps;
17
19
 
18
- export const ChessArticle = ({ role, subject: game }: ChessArticleProps) => {
20
+ export const ChessArticle = ({ role, variant }: ChessArticleProps) => {
19
21
  const { t } = useTranslation(meta.id);
20
22
  const [orientation, setOrientation] = useState<Player>('white');
21
- const [open, setOpen] = useState(true);
23
+ const [showInfo, setShowInfo] = useState(true);
22
24
  const controller = useRef<ChessboardController>(null);
23
25
 
24
26
  const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {
25
27
  controller.current?.setMoveNumber(index);
26
28
  }, []);
27
29
 
30
+ const isGameOver = (() => {
31
+ if (!Obj.instanceOf(Chess.State, variant) || (!variant.pgn && !variant.fen)) {
32
+ return false;
33
+ }
34
+ try {
35
+ const chess = new ChessJS();
36
+ if (variant.pgn) {
37
+ chess.loadPgn(variant.pgn);
38
+ } else if (variant.fen) {
39
+ chess.load(variant.fen);
40
+ }
41
+ return chess.isGameOver();
42
+ } catch {
43
+ return false;
44
+ }
45
+ })();
46
+
47
+ const handleNewGame = useCallback(() => {
48
+ if (!Obj.instanceOf(Chess.State, variant)) {
49
+ return;
50
+ }
51
+ Obj.update(variant, (variant) => {
52
+ const mutable = variant as Obj.Mutable<typeof variant>;
53
+ mutable.pgn = undefined;
54
+ mutable.fen = undefined;
55
+ });
56
+ }, [variant]);
57
+
58
+ if (!Obj.instanceOf(Chess.State, variant)) {
59
+ return null;
60
+ }
61
+
28
62
  return (
29
- <Chessboard.Root game={game} ref={controller}>
63
+ <Chessboard.Root state={variant} ref={controller}>
30
64
  <Panel.Root role={role} classNames='@container'>
31
65
  <Panel.Toolbar asChild>
32
66
  <Toolbar.Root>
67
+ {isGameOver && <Toolbar.Button onClick={handleNewGame}>{t('new-game.button')}</Toolbar.Button>}
68
+ <div className='grow' />
33
69
  <Toolbar.IconButton
34
70
  icon='ph--info--regular'
35
71
  iconOnly
36
- label={t('toggle info button')}
37
- disabled={open}
38
- classNames={mx('invisible @3xl:visible')}
39
- onClick={() => setOpen((open) => !open)}
72
+ label={t('toggle-info.button')}
73
+ classNames={mx('invisible @4xl:visible')}
74
+ onClick={() => setShowInfo((open) => !open)}
40
75
  />
41
76
  </Toolbar.Root>
42
77
  </Panel.Toolbar>
43
78
  <Panel.Content>
44
79
  <div
45
80
  className={mx(
46
- 'grid h-full w-full gap-2',
47
- open && '@3xl:grid-cols-[1fr_320px]',
81
+ 'grid h-full w-full',
82
+ showInfo && '@4xl:grid-cols-[1fr_320px] gap-8',
83
+ role === 'article' && 'p-4',
48
84
  role === 'section' && 'aspect-square',
49
- role === 'section' && open && '@3xl:aspect-auto',
85
+ role === 'section' && showInfo && '@4xl:aspect-auto',
50
86
  )}
51
87
  >
52
88
  <Chessboard.Content>
53
- <Chessboard.Board classNames='m-4 rounded-xs overflow-hidden' orientation={orientation} />
89
+ <Chessboard.Board classNames='border rounded-xs' orientation={orientation} />
54
90
  </Chessboard.Content>
55
- {open && (
56
- <div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>
91
+ {showInfo && (
92
+ <div className='hidden @4xl:flex flex-col justify-center items-center overflow-hidden'>
57
93
  <Chessboard.Info
58
94
  orientation={orientation}
59
95
  min={8}
60
96
  max={8}
61
97
  onOrientationChange={setOrientation}
62
- onClose={() => setOpen(false)}
98
+ onClose={() => setShowInfo(false)}
63
99
  onSelect={handleSelect}
64
100
  />
65
101
  </div>
@@ -2,6 +2,4 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
- import { ChessArticle } from './ChessArticle';
6
-
7
- export default ChessArticle;
5
+ export { ChessArticle as default } from './ChessArticle';
@@ -5,11 +5,12 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useMemo } from 'react';
7
7
 
8
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
8
+ import { make as makeGame } from '@dxos/plugin-game';
9
9
  import { CardContainer } from '@dxos/react-ui-mosaic/testing';
10
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
11
 
11
- import { meta as pluginMeta } from '../../meta';
12
- import { Chess } from '../../types';
12
+ import { meta as pluginMeta } from '#meta';
13
+ import { Chess } from '#types';
13
14
 
14
15
  import { ChessCard } from './ChessCard';
15
16
 
@@ -17,10 +18,14 @@ const SAMPLE_PGN =
17
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 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *';
18
19
 
19
20
  const CardStory = () => {
20
- const game = useMemo(() => Chess.make({ pgn: SAMPLE_PGN }), []);
21
+ const { game, state } = useMemo(() => {
22
+ const state = Chess.make({ pgn: SAMPLE_PGN });
23
+ const game = makeGame({ name: 'Story game', variant: state });
24
+ return { game, state };
25
+ }, []);
21
26
  return (
22
27
  <CardContainer role='popover' icon={pluginMeta.icon}>
23
- <ChessCard subject={game} />
28
+ <ChessCard role='card--content' game={game} variant={state} />
24
29
  </CardContainer>
25
30
  );
26
31
  };
@@ -4,16 +4,21 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
7
+ import { Obj } from '@dxos/echo';
8
+ import { type GameVariantSurfaceProps } from '@dxos/plugin-game';
8
9
 
9
- import { Chessboard } from '../../components';
10
- import { type Chess } from '../../types';
10
+ import { Chessboard } from '#components';
11
+ import { Chess } from '#types';
11
12
 
12
- export type ChessCardProps = SurfaceComponentProps<Chess.Game>;
13
+ export type ChessCardProps = GameVariantSurfaceProps;
14
+
15
+ export const ChessCard = ({ variant }: ChessCardProps) => {
16
+ if (!Obj.instanceOf(Chess.State, variant)) {
17
+ return null;
18
+ }
13
19
 
14
- export const ChessCard = ({ subject: game }: ChessCardProps) => {
15
20
  return (
16
- <Chessboard.Root game={game}>
21
+ <Chessboard.Root state={variant}>
17
22
  <Chessboard.Content>
18
23
  <Chessboard.Board />
19
24
  </Chessboard.Content>
@@ -2,6 +2,4 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
- import { ChessCard } from './ChessCard';
6
-
7
- export default ChessCard;
5
+ export { ChessCard as default } from './ChessCard';
package/src/index.ts CHANGED
@@ -3,9 +3,5 @@
3
3
  //
4
4
 
5
5
  export * from './blueprints';
6
- export * from './capabilities';
7
- export * from './components/Chessboard';
8
6
  export * from './meta';
9
7
  export * from './types';
10
-
11
- export * from './ChessPlugin';
package/src/meta.ts CHANGED
@@ -2,12 +2,15 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Plugin } from '@dxos/app-framework';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { DXN } from '@dxos/keys';
7
+ import { meta as gameMeta } from '@dxos/plugin-game';
6
8
  import { trim } from '@dxos/util';
7
9
 
8
- export const meta: Plugin.Meta = {
9
- id: 'dxos.org/plugin/chess',
10
+ export const meta = Plugin.makeMeta({
11
+ key: DXN.make('org.dxos.plugin.chess'),
10
12
  name: 'Chess',
13
+ author: 'DXOS',
11
14
  description: trim`
12
15
  Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
13
16
  Track game history and analyze moves in real-time.
@@ -15,5 +18,8 @@ export const meta: Plugin.Meta = {
15
18
  icon: 'ph--shield-chevron--regular',
16
19
  iconHue: 'amber',
17
20
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',
21
+ spec: 'PLUGIN.mdl',
18
22
  screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],
19
- };
23
+ dependsOn: [gameMeta.id],
24
+ tags: ['game'],
25
+ });
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { OperationHandlerSet } from '@dxos/compute';
6
+
7
+ export const ChessOperationHandlerSet = OperationHandlerSet.lazy(
8
+ () => import('./move'),
9
+ () => import('./play'),
10
+ () => import('./print'),
11
+ );
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Chess as ChessJS } from 'chess.js';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { Operation } from '@dxos/compute';
9
+ import { Obj } from '@dxos/echo';
10
+ import { loadGame } from '@dxos/plugin-game';
11
+
12
+ import { Chess, ChessOperation } from '../types';
13
+
14
+ const handler: Operation.WithHandler<typeof ChessOperation.Move> = ChessOperation.Move.pipe(
15
+ Operation.withHandler(
16
+ Effect.fn(function* ({ game, move }) {
17
+ const { variant } = yield* loadGame(game, Chess.State);
18
+ const chess = new ChessJS();
19
+ if (variant.pgn) {
20
+ chess.loadPgn(variant.pgn);
21
+ } else if (variant.fen) {
22
+ chess.load(variant.fen);
23
+ }
24
+
25
+ chess.move(move, { strict: false });
26
+ const pgn = chess.pgn();
27
+ Obj.update(variant, (variant) => {
28
+ const mutable = variant as Obj.Mutable<typeof variant>;
29
+ mutable.pgn = pgn;
30
+ });
31
+ return { pgn };
32
+ }),
33
+ ),
34
+ );
35
+
36
+ export default handler;
@@ -0,0 +1,45 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Chess as ChessJS } from 'chess.js';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { Operation } from '@dxos/compute';
9
+ import { Obj } from '@dxos/echo';
10
+ import { loadGame } from '@dxos/plugin-game';
11
+
12
+ import { Chess, ChessOperation } from '../types';
13
+
14
+ const handler: Operation.WithHandler<typeof ChessOperation.Play> = ChessOperation.Play.pipe(
15
+ Operation.withHandler(
16
+ Effect.fn(function* ({ game, side = 'any' }) {
17
+ const { variant } = yield* loadGame(game, Chess.State);
18
+ const chess = new ChessJS();
19
+ if (variant.pgn) {
20
+ chess.loadPgn(variant.pgn);
21
+ } else if (variant.fen) {
22
+ chess.load(variant.fen);
23
+ }
24
+
25
+ if (
26
+ !(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))
27
+ ) {
28
+ return { move: undefined, pgn: variant.pgn ?? '' };
29
+ }
30
+
31
+ const moves = chess.moves();
32
+ const move = moves[Math.floor(Math.random() * moves.length)];
33
+
34
+ chess.move(move, { strict: false });
35
+ const pgn = chess.pgn();
36
+ Obj.update(variant, (variant) => {
37
+ const mutable = variant as Obj.Mutable<typeof variant>;
38
+ mutable.pgn = pgn;
39
+ });
40
+ return { move, pgn };
41
+ }),
42
+ ),
43
+ );
44
+
45
+ export default handler;
@@ -0,0 +1,28 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Chess as ChessJS } from 'chess.js';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { Operation } from '@dxos/compute';
9
+
10
+ import { ChessOperation } from '../types';
11
+
12
+ const handler: Operation.WithHandler<typeof ChessOperation.Print> = ChessOperation.Print.pipe(
13
+ Operation.withHandler(
14
+ Effect.fn(function* ({ pgn, fen }) {
15
+ try {
16
+ const chess = new ChessJS(fen);
17
+ if (pgn) {
18
+ chess.loadPgn(pgn);
19
+ }
20
+ return { ascii: chess.ascii() };
21
+ } catch {
22
+ return { ascii: '' };
23
+ }
24
+ }),
25
+ ),
26
+ );
27
+
28
+ export default handler;
package/src/plugin.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
9
+ export const ChessPlugin = Plugin.lazy(meta, () => import('#plugin'));
10
+
11
+ export { ChessOperationHandlerSet } from './operations';
package/src/testing.ts ADDED
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // Eager re-export of `ChessPlugin`. See `@dxos/plugin-testing/src/core.ts`
6
+ // for the rationale.
7
+ export * from './ChessPlugin';
@@ -2,35 +2,33 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Type } from '@dxos/echo';
5
6
  import { type Resource } from '@dxos/react-ui';
6
7
 
7
- import { meta } from './meta';
8
- import { Chess } from './types';
8
+ import { meta } from '#meta';
9
+ import { Chess } from '#types';
9
10
 
10
11
  export const translations = [
11
12
  {
12
13
  'en-US': {
13
- [Chess.Game.typename]: {
14
- 'typename label': 'Game',
15
- 'typename label_zero': 'Games',
16
- 'typename label_one': 'Game',
17
- 'typename label_other': 'Games',
18
- 'object name placeholder': 'New game',
19
- 'rename object label': 'Rename game',
20
- 'delete object label': 'Delete game',
21
- 'object deleted label': 'Game deleted',
14
+ [Type.getTypename(Chess.State)]: {
15
+ 'typename.label': 'Chess',
16
+ 'typename.label_zero': 'Chess games',
17
+ 'typename.label_one': 'Chess game',
18
+ 'typename.label_other': 'Chess games',
22
19
  },
23
20
  [meta.id]: {
24
- 'plugin name': 'Chess',
25
- 'delete game label': 'Delete',
26
- 'game.checkmate label': 'Checkmate',
27
- 'game.stalemate label': 'Stalemate',
28
- 'game.draw label': 'Draw',
29
- 'game.check label': 'Check',
30
- 'select player button': 'Select player',
31
- 'toggle info button': 'Toggle info',
32
- 'close info button': 'Close info',
33
- 'flip board button': 'Flip board',
21
+ 'plugin.name': 'Chess',
22
+ 'new-game.button': 'New game',
23
+ 'delete-game.label': 'Delete',
24
+ 'game.checkmate.label': 'Checkmate',
25
+ 'game.stalemate.label': 'Stalemate',
26
+ 'game.draw.label': 'Draw',
27
+ 'game.check.label': 'Check',
28
+ 'select-player.button': 'Select player',
29
+ 'toggle-info.button': 'Toggle info',
30
+ 'close-info.button': 'Close info',
31
+ 'flip-board.button': 'Flip board',
34
32
  },
35
33
  },
36
34
  },