@dxos/plugin-chess 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5

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 (233) hide show
  1. package/dist/lib/browser/blueprints/index.mjs +14 -0
  2. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-2TJN26DN.mjs +67 -0
  4. package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  6. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-JZMN24DY.mjs +28 -0
  8. package/dist/lib/browser/chunk-JZMN24DY.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-MC7L6JNC.mjs +36 -0
  10. package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-XAJZK6Z2.mjs +110 -0
  12. package/dist/lib/browser/chunk-XAJZK6Z2.mjs.map +7 -0
  13. package/dist/lib/browser/cli/index.mjs +34 -0
  14. package/dist/lib/browser/cli/index.mjs.map +7 -0
  15. package/dist/lib/browser/create-AJHN4QT4.mjs +24 -0
  16. package/dist/lib/browser/create-AJHN4QT4.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +364 -91
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/move-T2NLRBR4.mjs +36 -0
  21. package/dist/lib/browser/move-T2NLRBR4.mjs.map +7 -0
  22. package/dist/lib/browser/operations/index.mjs +19 -0
  23. package/dist/lib/browser/operations/index.mjs.map +7 -0
  24. package/dist/lib/browser/play-7VTMD3SJ.mjs +45 -0
  25. package/dist/lib/browser/play-7VTMD3SJ.mjs.map +7 -0
  26. package/dist/lib/browser/print-EW7LPW4D.mjs +30 -0
  27. package/dist/lib/browser/print-EW7LPW4D.mjs.map +7 -0
  28. package/dist/lib/browser/types/index.mjs +3 -5
  29. package/dist/lib/node-esm/blueprints/index.mjs +15 -0
  30. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-4HZWCKMR.mjs +38 -0
  32. package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  34. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-LQEDIKCV.mjs +29 -0
  36. package/dist/lib/node-esm/chunk-LQEDIKCV.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-NYU5JVXP.mjs +111 -0
  38. package/dist/lib/node-esm/chunk-NYU5JVXP.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-LCCUF5X5.mjs → chunk-OIRJVY2R.mjs} +26 -38
  40. package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +7 -0
  41. package/dist/lib/node-esm/cli/index.mjs +35 -0
  42. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  43. package/dist/lib/node-esm/create-QSETDT4N.mjs +25 -0
  44. package/dist/lib/node-esm/create-QSETDT4N.mjs.map +7 -0
  45. package/dist/lib/node-esm/index.mjs +364 -91
  46. package/dist/lib/node-esm/index.mjs.map +4 -4
  47. package/dist/lib/node-esm/meta.json +1 -1
  48. package/dist/lib/node-esm/move-5F2ANDTE.mjs +37 -0
  49. package/dist/lib/node-esm/move-5F2ANDTE.mjs.map +7 -0
  50. package/dist/lib/node-esm/operations/index.mjs +20 -0
  51. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  52. package/dist/lib/node-esm/play-W4DQCQRX.mjs +46 -0
  53. package/dist/lib/node-esm/play-W4DQCQRX.mjs.map +7 -0
  54. package/dist/lib/node-esm/print-UJHXAXMS.mjs +31 -0
  55. package/dist/lib/node-esm/print-UJHXAXMS.mjs.map +7 -0
  56. package/dist/lib/node-esm/types/index.mjs +3 -5
  57. package/dist/types/src/ChessPlugin.d.ts +2 -1
  58. package/dist/types/src/ChessPlugin.d.ts.map +1 -1
  59. package/dist/types/src/ChessPlugin.test.d.ts +2 -0
  60. package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
  61. package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
  62. package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
  63. package/dist/types/src/blueprints/index.d.ts +3 -0
  64. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
  66. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  67. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -2
  68. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  69. package/dist/types/src/capabilities/index.d.ts +5 -3
  70. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  71. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  72. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  73. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  74. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  75. package/dist/types/src/cli/index.d.ts +2 -0
  76. package/dist/types/src/cli/index.d.ts.map +1 -0
  77. package/dist/types/src/cli/plugin.d.ts +3 -0
  78. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  79. package/dist/types/src/components/Chessboard/Chessboard.d.ts +34 -0
  80. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
  81. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +48 -0
  82. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/{ChessboardInfo.d.ts → Chessboard/Info.d.ts} +8 -7
  84. package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
  85. package/dist/types/src/components/Chessboard/index.d.ts +2 -0
  86. package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
  87. package/dist/types/src/components/Chessboard/types.d.ts +8 -0
  88. package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
  89. package/dist/types/src/components/index.d.ts +0 -1
  90. package/dist/types/src/components/index.d.ts.map +1 -1
  91. package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +6 -0
  92. package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
  93. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +47 -0
  94. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
  95. package/dist/types/src/containers/ChessArticle/index.d.ts +2 -0
  96. package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
  97. package/dist/types/src/containers/ChessCard/ChessCard.d.ts +6 -0
  98. package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
  99. package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts +15 -0
  100. package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
  101. package/dist/types/src/containers/ChessCard/index.d.ts +2 -0
  102. package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
  103. package/dist/types/src/containers/index.d.ts +4 -0
  104. package/dist/types/src/containers/index.d.ts.map +1 -0
  105. package/dist/types/src/index.d.ts +2 -3
  106. package/dist/types/src/index.d.ts.map +1 -1
  107. package/dist/types/src/meta.d.ts +2 -3
  108. package/dist/types/src/meta.d.ts.map +1 -1
  109. package/dist/types/src/operations/create.d.ts +5 -0
  110. package/dist/types/src/operations/create.d.ts.map +1 -0
  111. package/dist/types/src/operations/definitions.d.ts +51 -0
  112. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  113. package/dist/types/src/operations/index.d.ts +4 -0
  114. package/dist/types/src/operations/index.d.ts.map +1 -0
  115. package/dist/types/src/operations/move.d.ts +5 -0
  116. package/dist/types/src/operations/move.d.ts.map +1 -0
  117. package/dist/types/src/operations/play.d.ts +5 -0
  118. package/dist/types/src/operations/play.d.ts.map +1 -0
  119. package/dist/types/src/operations/print.d.ts +5 -0
  120. package/dist/types/src/operations/print.d.ts.map +1 -0
  121. package/dist/types/src/translations.d.ts +21 -17
  122. package/dist/types/src/translations.d.ts.map +1 -1
  123. package/dist/types/src/types/Chess.d.ts +20 -17
  124. package/dist/types/src/types/Chess.d.ts.map +1 -1
  125. package/dist/types/src/types/index.d.ts +0 -1
  126. package/dist/types/src/types/index.d.ts.map +1 -1
  127. package/dist/types/tsconfig.tsbuildinfo +1 -1
  128. package/package.json +75 -36
  129. package/src/ChessPlugin.test.ts +65 -0
  130. package/src/ChessPlugin.tsx +42 -53
  131. package/src/blueprints/chess-blueprint.ts +35 -0
  132. package/src/blueprints/index.ts +6 -0
  133. package/src/capabilities/artifact-definition.ts +99 -92
  134. package/src/capabilities/blueprint-definition.ts +10 -27
  135. package/src/capabilities/index.ts +8 -4
  136. package/src/capabilities/operation-handler.ts +14 -0
  137. package/src/capabilities/react-surface.tsx +27 -15
  138. package/src/cli/index.ts +5 -0
  139. package/src/cli/plugin.ts +37 -0
  140. package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
  141. package/src/components/Chessboard/Chessboard.tsx +180 -0
  142. package/src/components/Chessboard/Info.tsx +253 -0
  143. package/src/components/Chessboard/index.ts +5 -0
  144. package/src/components/Chessboard/types.ts +18 -0
  145. package/src/components/index.ts +1 -5
  146. package/src/containers/ChessArticle/ChessArticle.stories.tsx +53 -0
  147. package/src/containers/ChessArticle/ChessArticle.tsx +73 -0
  148. package/src/containers/ChessArticle/index.ts +5 -0
  149. package/src/containers/ChessCard/ChessCard.stories.tsx +42 -0
  150. package/src/containers/ChessCard/ChessCard.tsx +22 -0
  151. package/src/containers/ChessCard/index.ts +5 -0
  152. package/src/containers/index.ts +8 -0
  153. package/src/index.ts +2 -3
  154. package/src/meta.ts +6 -6
  155. package/src/operations/create.ts +21 -0
  156. package/src/operations/definitions.ts +109 -0
  157. package/src/operations/index.ts +16 -0
  158. package/src/operations/move.ts +36 -0
  159. package/src/operations/play.ts +45 -0
  160. package/src/operations/print.ts +28 -0
  161. package/src/translations.ts +21 -17
  162. package/src/types/Chess.ts +29 -23
  163. package/src/types/index.ts +0 -1
  164. package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs +0 -90
  165. package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs.map +0 -7
  166. package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs +0 -38
  167. package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs.map +0 -7
  168. package/dist/lib/browser/chunk-2W3S5N6C.mjs +0 -257
  169. package/dist/lib/browser/chunk-2W3S5N6C.mjs.map +0 -7
  170. package/dist/lib/browser/chunk-EJMPHRSR.mjs +0 -94
  171. package/dist/lib/browser/chunk-EJMPHRSR.mjs.map +0 -7
  172. package/dist/lib/browser/chunk-OBJAHY6H.mjs +0 -79
  173. package/dist/lib/browser/chunk-OBJAHY6H.mjs.map +0 -7
  174. package/dist/lib/browser/chunk-PE3IWOFR.mjs +0 -28
  175. package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +0 -7
  176. package/dist/lib/browser/chunk-PPBBLHAC.mjs +0 -8
  177. package/dist/lib/browser/chunk-PPBBLHAC.mjs.map +0 -7
  178. package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs +0 -25
  179. package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs.map +0 -7
  180. package/dist/lib/browser/react-surface-RIXD6RTS.mjs +0 -38
  181. package/dist/lib/browser/react-surface-RIXD6RTS.mjs.map +0 -7
  182. package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs +0 -91
  183. package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs.map +0 -7
  184. package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs +0 -39
  185. package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs.map +0 -7
  186. package/dist/lib/node-esm/chunk-42EKKMOO.mjs +0 -10
  187. package/dist/lib/node-esm/chunk-42EKKMOO.mjs.map +0 -7
  188. package/dist/lib/node-esm/chunk-5APYXPBX.mjs +0 -95
  189. package/dist/lib/node-esm/chunk-5APYXPBX.mjs.map +0 -7
  190. package/dist/lib/node-esm/chunk-6OWCPDUA.mjs +0 -29
  191. package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +0 -7
  192. package/dist/lib/node-esm/chunk-LCCUF5X5.mjs.map +0 -7
  193. package/dist/lib/node-esm/chunk-QAGOXJGH.mjs +0 -258
  194. package/dist/lib/node-esm/chunk-QAGOXJGH.mjs.map +0 -7
  195. package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs +0 -26
  196. package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs.map +0 -7
  197. package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs +0 -39
  198. package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs.map +0 -7
  199. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  200. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  201. package/dist/types/src/components/Card.stories.d.ts +0 -49
  202. package/dist/types/src/components/Card.stories.d.ts.map +0 -1
  203. package/dist/types/src/components/Chessboard.d.ts +0 -32
  204. package/dist/types/src/components/Chessboard.d.ts.map +0 -1
  205. package/dist/types/src/components/Chessboard.stories.d.ts +0 -42
  206. package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
  207. package/dist/types/src/components/ChessboardArticle.d.ts +0 -6
  208. package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
  209. package/dist/types/src/components/ChessboardContainer.d.ts +0 -9
  210. package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
  211. package/dist/types/src/components/ChessboardInfo.d.ts.map +0 -1
  212. package/dist/types/src/components/ChessboardPlayers.d.ts +0 -8
  213. package/dist/types/src/components/ChessboardPlayers.d.ts.map +0 -1
  214. package/dist/types/src/functions/index.d.ts +0 -3
  215. package/dist/types/src/functions/index.d.ts.map +0 -1
  216. package/dist/types/src/functions/move.d.ts +0 -6
  217. package/dist/types/src/functions/move.d.ts.map +0 -1
  218. package/dist/types/src/functions/play.d.ts +0 -8
  219. package/dist/types/src/functions/play.d.ts.map +0 -1
  220. package/dist/types/src/types/ChessAction.d.ts +0 -23
  221. package/dist/types/src/types/ChessAction.d.ts.map +0 -1
  222. package/src/capabilities/intent-resolver.ts +0 -22
  223. package/src/components/Card.stories.tsx +0 -68
  224. package/src/components/Chessboard.stories.tsx +0 -50
  225. package/src/components/Chessboard.tsx +0 -101
  226. package/src/components/ChessboardArticle.tsx +0 -57
  227. package/src/components/ChessboardContainer.tsx +0 -44
  228. package/src/components/ChessboardInfo.tsx +0 -140
  229. package/src/components/ChessboardPlayers.tsx +0 -97
  230. package/src/functions/index.ts +0 -6
  231. package/src/functions/move.ts +0 -43
  232. package/src/functions/play.ts +0 -45
  233. package/src/types/ChessAction.ts +0 -19
@@ -1,23 +0,0 @@
1
- import { Schema } from 'effect';
2
- declare const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
3
- readonly _tag: Schema.tag<`${string}/action/create`>;
4
- } & {
5
- input: Schema.Struct<{
6
- name: Schema.optional<typeof Schema.String>;
7
- pgn: Schema.optional<typeof Schema.String>;
8
- }>;
9
- output: Schema.Struct<{
10
- object: import("@dxos/echo/Type").obj<Schema.Struct<{
11
- name: Schema.optional<typeof Schema.String>;
12
- players: Schema.optional<Schema.mutable<Schema.Struct<{
13
- white: Schema.optional<Schema.SchemaClass<string, string, never>>;
14
- black: Schema.optional<Schema.SchemaClass<string, string, never>>;
15
- }>>>;
16
- pgn: Schema.SchemaClass<string, string, never>;
17
- }>>;
18
- }>;
19
- }>;
20
- export declare class Create extends Create_base {
21
- }
22
- export {};
23
- //# sourceMappingURL=ChessAction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChessAction.d.ts","sourceRoot":"","sources":["../../../../src/types/ChessAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;AAMhC,qBAAa,MAAO,SAAQ,WAQ1B;CAAG"}
@@ -1,22 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
6
-
7
- import { Chess, ChessAction } from '../types';
8
-
9
- export default () =>
10
- contributes(
11
- Capabilities.IntentResolver,
12
- createResolver({
13
- intent: ChessAction.Create,
14
- resolve: ({ name, pgn }) => {
15
- return {
16
- data: {
17
- object: Chess.makeGame({ name, pgn }),
18
- },
19
- };
20
- },
21
- }),
22
- );
@@ -1,68 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React from 'react';
9
-
10
- import { CardContainer } from '@dxos/react-ui-stack/testing';
11
- import { withTheme } from '@dxos/storybook-utils';
12
-
13
- import { meta } from '../meta';
14
- import { Chess } from '../types';
15
-
16
- import { Chessboard } from './Chessboard';
17
-
18
- type DefaultStoryProps = {
19
- role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
20
- game: Chess.Game;
21
- };
22
-
23
- const storybook: Meta<DefaultStoryProps> = {
24
- title: 'plugins/plugin-chess/Card',
25
- render: ({ role, game }) => (
26
- <CardContainer icon={meta.icon} role={role}>
27
- <Chessboard.Root game={game}>
28
- <Chessboard.Content role={role}>
29
- <Chessboard.Board />
30
- </Chessboard.Content>
31
- </Chessboard.Root>
32
- </CardContainer>
33
- ),
34
- decorators: [withTheme],
35
- parameters: {
36
- layout: 'centered',
37
- },
38
- tags: ['cards'],
39
- };
40
-
41
- export default storybook;
42
-
43
- const game = Chess.makeGame({
44
- pgn: '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 *',
45
- });
46
-
47
- type Story = StoryObj<DefaultStoryProps>;
48
-
49
- export const Popover = {
50
- args: {
51
- role: 'card--popover',
52
- game: game,
53
- },
54
- } satisfies Story;
55
-
56
- export const Intrinsic = {
57
- args: {
58
- role: 'card--intrinsic',
59
- game: game,
60
- },
61
- } satisfies Story;
62
-
63
- export const Extrinsic = {
64
- args: {
65
- role: 'card--extrinsic',
66
- game: game,
67
- },
68
- } satisfies Story;
@@ -1,50 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type StoryObj } from '@storybook/react-vite';
8
-
9
- import { withClientProvider } from '@dxos/react-client/testing';
10
- import { withLayout, withTheme } from '@dxos/storybook-utils';
11
-
12
- import { translations } from '../translations';
13
- import { Chess } from '../types';
14
-
15
- import { ChessboardArticle } from './ChessboardArticle';
16
-
17
- const meta: Meta<typeof ChessboardArticle> = {
18
- title: 'plugins/plugin-chess/Chessboard',
19
- component: ChessboardArticle,
20
- decorators: [withClientProvider({ createIdentity: true }), withTheme, withLayout({ fullscreen: true })],
21
- parameters: {
22
- translations,
23
- },
24
- };
25
-
26
- type Story = StoryObj<typeof meta>;
27
-
28
- export default meta;
29
-
30
- export const Default = {
31
- args: {
32
- game: Chess.makeGame(),
33
- },
34
- } satisfies Story;
35
-
36
- export const EndGame = {
37
- args: {
38
- game: Chess.makeGame({
39
- pgn: '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 *',
40
- }),
41
- },
42
- } satisfies Story;
43
-
44
- export const Promption = {
45
- args: {
46
- game: Chess.makeGame({
47
- pgn: '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 *',
48
- }),
49
- },
50
- } satisfies Story;
@@ -1,101 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { type PropsWithChildren, useCallback, useEffect, useMemo } from 'react';
6
-
7
- import { log } from '@dxos/log';
8
- import { type ThemedClassName } from '@dxos/react-ui';
9
- import {
10
- ChessModel,
11
- Gameboard,
12
- type GameboardRootProps,
13
- Chessboard as NativeChessboard,
14
- type ChessboardProps as NativeChessboardProps,
15
- } from '@dxos/react-ui-gameboard';
16
- import { mx } from '@dxos/react-ui-theme';
17
-
18
- import { type Chess } from '../types';
19
-
20
- import { ChessboardInfo, type ChessboardInfoProps } from './ChessboardInfo';
21
- import { ChessboardPlayers, type ChessboardPlayersProps } from './ChessboardPlayers';
22
-
23
- export class ExtendedChessModel extends ChessModel {
24
- constructor(readonly object: Chess.Game) {
25
- super();
26
- }
27
- }
28
-
29
- //
30
- // Root
31
- //
32
-
33
- type ChessboardRootProps = PropsWithChildren<{
34
- game: Chess.Game;
35
- }>;
36
-
37
- const ChessboardRoot = ({ game, children }: ChessboardRootProps) => {
38
- const model = useMemo(() => new ExtendedChessModel(game), []);
39
- useEffect(() => {
40
- model.update(game.pgn);
41
- log('update', { pgn: game.pgn });
42
- }, [game.pgn]);
43
-
44
- const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
45
- (move) => {
46
- if (model.makeMove(move)) {
47
- game.pgn = model.pgn;
48
- return true;
49
- }
50
-
51
- return false;
52
- },
53
- [model],
54
- );
55
-
56
- return (
57
- <Gameboard.Root model={model} onDrop={handleDrop}>
58
- {children}
59
- </Gameboard.Root>
60
- );
61
- };
62
-
63
- //
64
- // Content
65
- //
66
-
67
- type Role = 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
68
-
69
- type ChessboardContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;
70
-
71
- const ChessboardContent = ({ classNames, children, role }: ChessboardContentProps) => {
72
- return (
73
- <Gameboard.Content
74
- classNames={mx(classNames, role === 'card--popover' && 'size-container popover-square')}
75
- grow={!role || role === 'card--extrinsic'}
76
- contain={!role || role === 'card--extrinsic' || role === 'card--popover'}
77
- >
78
- {children}
79
- </Gameboard.Content>
80
- );
81
- };
82
-
83
- //
84
- // Chessboard
85
- //
86
-
87
- export const Chessboard = {
88
- Root: ChessboardRoot,
89
- Content: ChessboardContent,
90
- Board: NativeChessboard,
91
- Info: ChessboardInfo,
92
- Players: ChessboardPlayers,
93
- };
94
-
95
- export type {
96
- ChessboardRootProps,
97
- ChessboardContentProps,
98
- NativeChessboardProps as ChessboardBoardProps,
99
- ChessboardInfoProps,
100
- ChessboardPlayersProps,
101
- };
@@ -1,57 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { useState } from 'react';
6
-
7
- import { IconButton, useTranslation } from '@dxos/react-ui';
8
- import { type Player } from '@dxos/react-ui-gameboard';
9
- import { StackItem } from '@dxos/react-ui-stack';
10
- import { mx } from '@dxos/react-ui-theme';
11
-
12
- import { meta } from '../meta';
13
- import { type Chess } from '../types';
14
-
15
- import { Chessboard } from './Chessboard';
16
-
17
- export const ChessboardArticle = ({ game }: { game: Chess.Game }) => {
18
- const { t } = useTranslation(meta.id);
19
- const [orientation, setOrientation] = useState<Player>('white');
20
- const [open, setOpen] = useState(true);
21
-
22
- return (
23
- <StackItem.Content classNames='@container bs-full is-full overflow-hidden'>
24
- <Chessboard.Root game={game}>
25
- <div className={mx('grid grid-rows-[1fr_4rem] bs-full is-full gap-2', open && '@3xl:grid-cols-[1fr_320px]')}>
26
- <Chessboard.Content>
27
- <Chessboard.Board orientation={orientation} />
28
- </Chessboard.Content>
29
- {open && (
30
- <div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>
31
- <Chessboard.Info
32
- orientation={orientation}
33
- min={8}
34
- max={8}
35
- onOrientationChange={setOrientation}
36
- onClose={() => setOpen(false)}
37
- />
38
- </div>
39
- )}
40
- <div className='flex justify-center items-center'>
41
- <Chessboard.Players>
42
- <IconButton
43
- variant='ghost'
44
- icon='ph--info--regular'
45
- iconOnly
46
- label={t('button toggle info')}
47
- size={6}
48
- classNames={mx('invisible', !open && '@3xl:visible')}
49
- onClick={() => setOpen((open) => !open)}
50
- />
51
- </Chessboard.Players>
52
- </div>
53
- </div>
54
- </Chessboard.Root>
55
- </StackItem.Content>
56
- );
57
- };
@@ -1,44 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { getSpace } from '@dxos/react-client/echo';
8
-
9
- import { type Chess } from '../types';
10
-
11
- import { Chessboard } from './Chessboard';
12
- import { ChessboardArticle } from './ChessboardArticle';
13
-
14
- export type ChessboardContainerProps = {
15
- game: Chess.Game;
16
- role?: string;
17
- };
18
-
19
- export const ChessboardContainer = ({ game, role }: ChessboardContainerProps) => {
20
- const space = getSpace(game);
21
- if (!space) {
22
- return null;
23
- }
24
-
25
- switch (role) {
26
- case 'card--popover':
27
- case 'card--intrinsic':
28
- case 'card--extrinsic': {
29
- return (
30
- <Chessboard.Root game={game}>
31
- <Chessboard.Content role={role}>
32
- <Chessboard.Board />
33
- </Chessboard.Content>
34
- </Chessboard.Root>
35
- );
36
- }
37
-
38
- default: {
39
- return <ChessboardArticle game={game} />;
40
- }
41
- }
42
- };
43
-
44
- export default ChessboardContainer;
@@ -1,140 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
6
-
7
- import { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
8
- import { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';
9
- import { mx } from '@dxos/react-ui-theme';
10
-
11
- import { meta } from '../meta';
12
-
13
- import { type ExtendedChessModel } from './Chessboard';
14
-
15
- export type ChessboardInfoProps = ThemedClassName<
16
- {
17
- orientation?: Player;
18
- onOrientationChange?: (orientation: Player) => void;
19
- onClose?: () => void;
20
- } & Pick<HistoryProps, 'min' | 'max'>
21
- >;
22
-
23
- export const ChessboardInfo = ({
24
- classNames,
25
- orientation = 'white',
26
- onOrientationChange,
27
- onClose,
28
- ...props
29
- }: ChessboardInfoProps) => {
30
- const { t } = useTranslation(meta.id);
31
- const { model } = useGameboardContext<ExtendedChessModel>(ChessboardInfo.displayName);
32
-
33
- return (
34
- <div
35
- className={mx(
36
- 'grid grid-rows-[min-content_1fr_min-content] is-full min-is-[16rem] overflow-hidden bg-inputSurface p-2 rounded',
37
- classNames,
38
- )}
39
- >
40
- <PlayerIndicator
41
- model={model}
42
- player={orientation === 'white' ? 'black' : 'white'}
43
- title={model.object.players?.[orientation === 'white' ? 'black' : 'white']}
44
- >
45
- {onClose && <IconButton icon='ph--x--regular' iconOnly label={t('button flip')} size={4} onClick={onClose} />}
46
- </PlayerIndicator>
47
- <History model={model} {...props} />
48
- <PlayerIndicator model={model} player={orientation} title={model.object.players?.[orientation]}>
49
- {onOrientationChange && (
50
- <IconButton
51
- icon='ph--arrows-down-up--regular'
52
- iconOnly
53
- label={t('button flip')}
54
- size={6}
55
- classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}
56
- onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}
57
- />
58
- )}
59
- </PlayerIndicator>
60
- </div>
61
- );
62
- };
63
-
64
- ChessboardInfo.displayName = 'Chessboard.Info';
65
-
66
- type HistoryProps = ThemedClassName<{ model: ExtendedChessModel; min?: number; max?: number }>;
67
-
68
- const History = ({ classNames, model, min, max }: HistoryProps) => {
69
- const { t } = useTranslation(meta.id);
70
- const label = model.game.isGameOver()
71
- ? model.game.isCheckmate()
72
- ? t('game.checkmate')
73
- : model.game.isStalemate()
74
- ? t('game.stalemate')
75
- : t('game.draw')
76
- : model.game.isCheck()
77
- ? t('game.check')
78
- : undefined;
79
-
80
- const history = model.game.history();
81
- const moves = useMemo(
82
- () =>
83
- history.reduce((acc, move, index) => {
84
- if (index % 2 === 0) {
85
- acc.push([move]);
86
- } else {
87
- acc[acc.length - 1].push(move);
88
- }
89
- return acc;
90
- }, [] as string[][]),
91
- [history.length],
92
- );
93
-
94
- const scrollerRef = useRef<HTMLDivElement>(null);
95
- useEffect(() => {
96
- scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });
97
- }, [history.length]);
98
-
99
- return (
100
- <div
101
- ref={scrollerRef}
102
- className={mx('overflow-y-scroll', classNames)}
103
- style={{
104
- minHeight: min === undefined ? 'auto' : `${min * 24}px`,
105
- maxHeight: max === undefined ? 'auto' : `${max * 24}px`,
106
- }}
107
- >
108
- {moves.map(([a, b], index) => (
109
- <div key={index} className='grid grid-cols-[3rem_1fr_1fr] pis-4 leading-1'>
110
- <div className='content-center text-xs text-subdued'>{index + 1}</div>
111
- <div>{a}</div>
112
- <div>{b}</div>
113
- </div>
114
- ))}
115
- {label && <div className='text-center'>{label}</div>}
116
- </div>
117
- );
118
- };
119
-
120
- const PlayerIndicator = ({
121
- children,
122
- model,
123
- player,
124
- title,
125
- }: PropsWithChildren<{ model: ExtendedChessModel; player: Player; title?: string }>) => {
126
- const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');
127
- return (
128
- <div className='grid grid-cols-[2rem_1fr_2rem] gap-1 bs-[--rail-size] pis-1 pie-1 flex items-center overflow-hidden'>
129
- <div className='place-items-center'>
130
- <Icon
131
- icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
132
- size={6}
133
- classNames={mx(turn && (model.game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
134
- />
135
- </div>
136
- <div className='truncate'>{title}</div>
137
- {children}
138
- </div>
139
- );
140
- };
@@ -1,97 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { type PropsWithChildren } from 'react';
6
-
7
- import { generateName } from '@dxos/display-name';
8
- import { type SpaceMember, getSpace, useMembers } from '@dxos/react-client/echo';
9
- import { Icon, Input, Select, useThemeContext } from '@dxos/react-ui';
10
- import { type ThemedClassName } from '@dxos/react-ui';
11
- import { useGameboardContext } from '@dxos/react-ui-gameboard';
12
- import { mx } from '@dxos/react-ui-theme';
13
-
14
- import { type Chess } from '../types';
15
-
16
- import { type ExtendedChessModel } from './Chessboard';
17
-
18
- export type ChessboardPlayersProps = ThemedClassName<PropsWithChildren>;
19
-
20
- export const ChessboardPlayers = ({ classNames, children }: ChessboardPlayersProps) => {
21
- const { model } = useGameboardContext<ExtendedChessModel>(ChessboardPlayers.displayName);
22
- const members = useMembers(getSpace(model.object)?.key);
23
- const players: Chess.Game['players'] = model.object.players;
24
- if (!players) {
25
- return null;
26
- }
27
-
28
- return (
29
- <div role='none' className={mx('grid grid-cols-[1fr_min-content_1fr] pis-2 pie-2 overflow-hidden', classNames)}>
30
- <div role='none' className='flex flex-row-reverse items-center gap-2'>
31
- <PlayerSelect
32
- side='white'
33
- value={players.white}
34
- onValueChange={(player) => (players.white = player)}
35
- members={members}
36
- />
37
- </div>
38
- <div className='flex flex-row justify-center items-center'>{children}</div>
39
- <div role='none' className='flex flex-row items-center gap-2'>
40
- <PlayerSelect
41
- side='black'
42
- value={players.black}
43
- onValueChange={(player) => (players.black = player)}
44
- members={members}
45
- />
46
- </div>
47
- </div>
48
- );
49
- };
50
-
51
- ChessboardPlayers.displayName = 'Chessboard.Players';
52
-
53
- const PlayerSelect = ({
54
- side,
55
- value,
56
- onValueChange,
57
- members,
58
- }: {
59
- side: 'white' | 'black';
60
- value: string | undefined;
61
- onValueChange: (player: string) => void;
62
- members: SpaceMember[];
63
- }) => {
64
- const { themeMode } = useThemeContext();
65
- const iconFillMode =
66
- (side === 'black' && themeMode === 'light') || (side === 'white' && themeMode === 'dark') ? 'fill' : undefined;
67
-
68
- return (
69
- <Input.Root>
70
- <Input.Label>
71
- <Icon
72
- aria-label={`Chess icon for side ${side}`}
73
- icon={`ph--crown-cross--${iconFillMode || 'regular'}`}
74
- size={6}
75
- />
76
- </Input.Label>
77
- <Select.Root value={value} onValueChange={onValueChange}>
78
- <Select.TriggerButton placeholder={'Select player'} />
79
- <Select.Portal>
80
- <Select.Content>
81
- <Select.Viewport>
82
- {members.map((member) => {
83
- const memberKey = member.identity.identityKey.toHex();
84
- const displayName = member.identity?.profile?.displayName || generateName(memberKey);
85
- return (
86
- <Select.Option key={memberKey} value={memberKey}>
87
- {displayName}
88
- </Select.Option>
89
- );
90
- })}
91
- </Select.Viewport>
92
- </Select.Content>
93
- </Select.Portal>
94
- </Select.Root>
95
- </Input.Root>
96
- );
97
- };
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export { default as move } from './move';
6
- export { default as play } from './play';
@@ -1,43 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Chess as ChessJS } from 'chess.js';
6
- import { Effect, Schema } from 'effect';
7
-
8
- import { ArtifactId } from '@dxos/assistant';
9
- import { DatabaseService, defineFunction } from '@dxos/functions';
10
-
11
- import { Chess } from '../types';
12
-
13
- export default defineFunction({
14
- name: 'dxos.org/function/chess/move',
15
- description: 'Makes a move in the given chess game.',
16
- inputSchema: Schema.Struct({
17
- id: ArtifactId.annotations({
18
- description: 'The ID of the chess object.',
19
- }),
20
- move: Schema.String.annotations({
21
- description: 'The move to make in the chess game.',
22
- examples: ['e4', 'Bf3'],
23
- }),
24
- }),
25
- outputSchema: Schema.Boolean.annotations({
26
- description: 'False if the move was invalid.',
27
- }),
28
- handler: Effect.fn(function* ({ data: { id, move } }) {
29
- const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Chess.Game);
30
-
31
- // TODO(burdon): Avoid using try/catch inside Effect generators.
32
- // Use Effect's error handling mechanisms instead (e.g., Effect.try, Effect.tryPromise, Effect.catchAll, Effect.catchTag)
33
- try {
34
- const chess = new ChessJS();
35
- chess.loadPgn(object.pgn);
36
- chess.move(move, { strict: false });
37
- object.pgn = chess.pgn();
38
- return true;
39
- } catch {
40
- return false;
41
- }
42
- }),
43
- });