@dxos/plugin-chess 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/dist/lib/browser/ChessArticle-RI2DYAO4.mjs +59 -0
- package/dist/lib/browser/ChessArticle-RI2DYAO4.mjs.map +7 -0
- package/dist/lib/browser/ChessCard-AUMESHHE.mjs +21 -0
- package/dist/lib/browser/ChessCard-AUMESHHE.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-RLA7PQBB.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-RLA7PQBB.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +11 -0
- package/dist/lib/browser/{chunk-M63HYNXU.mjs → chunk-66H3V2YV.mjs} +18 -38
- package/dist/lib/browser/chunk-66H3V2YV.mjs.map +7 -0
- package/dist/lib/browser/chunk-AWDLDU43.mjs +231 -0
- package/dist/lib/browser/chunk-AWDLDU43.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WSUUPPDK.mjs → chunk-H3NUMCQ6.mjs} +4 -9
- package/dist/lib/browser/chunk-H3NUMCQ6.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-KE4FN77G.mjs +276 -0
- package/dist/lib/browser/chunk-KE4FN77G.mjs.map +7 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs +1 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +29 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +47 -76
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-7KUFGD7C.mjs +50 -0
- package/dist/lib/browser/react-surface-7KUFGD7C.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/node-esm/ChessArticle-6QNVYEZV.mjs +60 -0
- package/dist/lib/node-esm/ChessArticle-6QNVYEZV.mjs.map +7 -0
- package/dist/lib/node-esm/ChessCard-QK3ZMYLT.mjs +22 -0
- package/dist/lib/node-esm/ChessCard-QK3ZMYLT.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-A2FFH3Z2.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-A2FFH3Z2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +12 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs +2 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5C2OYL2B.mjs → chunk-F5OMIM4F.mjs} +4 -8
- package/dist/lib/node-esm/chunk-F5OMIM4F.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7YK5RFHY.mjs → chunk-OUNGNJFP.mjs} +18 -38
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-R7FXSQ2P.mjs +232 -0
- package/dist/lib/node-esm/chunk-R7FXSQ2P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RNPP75JE.mjs +277 -0
- package/dist/lib/node-esm/chunk-RNPP75JE.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +30 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +47 -76
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-U3HGYR5T.mjs +51 -0
- package/dist/lib/node-esm/react-surface-U3HGYR5T.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -5
- package/dist/types/src/ChessPlugin.d.ts +2 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- 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/functions/create.d.ts +15 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +56 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/move.d.ts +16 -0
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/play.d.ts +17 -0
- package/dist/types/src/blueprints/functions/play.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/print.d.ts +8 -0
- package/dist/types/src/blueprints/functions/print.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +3 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +1 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +3 -7
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/{Info.d.ts → Chessboard/Info.d.ts} +1 -1
- 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 +6 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/{components/Chessboard.stories.d.ts → containers/ChessArticle/ChessArticle.stories.d.ts} +8 -6
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +3 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +6 -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 +3 -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 +2 -2
- 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/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +18 -18
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -43
- package/src/ChessPlugin.tsx +26 -51
- package/src/blueprints/chess-blueprint.ts +36 -0
- package/src/{functions → blueprints/functions}/create.ts +10 -4
- package/src/blueprints/functions/index.ts +17 -0
- package/src/{functions → blueprints/functions}/move.ts +15 -12
- package/src/{functions → blueprints/functions}/play.ts +11 -8
- package/src/blueprints/functions/print.ts +42 -0
- package/src/blueprints/index.ts +6 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +135 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +1 -6
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +33 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +27 -0
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +35 -26
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +27 -17
- 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 +53 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +72 -0
- package/src/containers/ChessArticle/index.ts +7 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +42 -0
- package/src/containers/ChessCard/ChessCard.tsx +22 -0
- package/src/containers/ChessCard/index.ts +7 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +2 -2
- package/src/meta.ts +5 -3
- package/src/translations.ts +1 -0
- package/src/types/Chess.ts +22 -30
- package/src/types/index.ts +0 -1
- package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs +0 -96
- package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-UVRFUJYE.mjs +0 -11
- package/dist/lib/browser/chunk-E5NQWXQ7.mjs +0 -306
- package/dist/lib/browser/chunk-E5NQWXQ7.mjs.map +0 -7
- package/dist/lib/browser/chunk-KQOVCG7Z.mjs +0 -8
- package/dist/lib/browser/chunk-KQOVCG7Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-M63HYNXU.mjs.map +0 -7
- package/dist/lib/browser/chunk-VA5TW6SD.mjs +0 -169
- package/dist/lib/browser/chunk-VA5TW6SD.mjs.map +0 -7
- package/dist/lib/browser/chunk-WSUUPPDK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs +0 -25
- package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-OLAZCU2E.mjs +0 -38
- package/dist/lib/browser/react-surface-OLAZCU2E.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs +0 -97
- package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-Z47C4EEX.mjs +0 -12
- package/dist/lib/node-esm/chunk-5C2OYL2B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7YK5RFHY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C55L2OCJ.mjs +0 -10
- package/dist/lib/node-esm/chunk-C55L2OCJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DWGG7IGH.mjs +0 -307
- package/dist/lib/node-esm/chunk-DWGG7IGH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SW5N5XNV.mjs +0 -170
- package/dist/lib/node-esm/chunk-SW5N5XNV.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-FIKCDZ5L.mjs +0 -39
- package/dist/lib/node-esm/react-surface-FIKCDZ5L.mjs.map +0 -7
- 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/blueprint-definition.d.ts +0 -6
- package/dist/types/src/capabilities/blueprint-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.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/blueprint-definition.ts +0 -36
- 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 -69
- package/src/components/ChessboardContainer.tsx +0 -44
- package/src/functions/index.ts +0 -7
- package/src/types/ChessAction.ts +0 -19
- /package/dist/lib/browser/{blueprint-definition-UVRFUJYE.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-Z47C4EEX.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
|
|
12
|
+
import { ChessArticle, ChessCard } from '../../containers';
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
|
+
import { Chess } from '../../types';
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(() =>
|
|
17
|
+
Effect.succeed(
|
|
18
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
19
|
+
Surface.create({
|
|
20
|
+
id: meta.id,
|
|
21
|
+
role: ['article', 'section'],
|
|
22
|
+
filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),
|
|
23
|
+
component: ({ data, role }) => <ChessArticle role={role} subject={data.subject} />,
|
|
24
|
+
}),
|
|
25
|
+
Surface.create({
|
|
26
|
+
id: meta.id,
|
|
27
|
+
role: ['card--content'],
|
|
28
|
+
filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),
|
|
29
|
+
component: ({ data, role }) => <ChessCard role={role} subject={data.subject} />,
|
|
30
|
+
}),
|
|
31
|
+
]),
|
|
32
|
+
),
|
|
33
|
+
);
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
9
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
10
|
+
|
|
11
|
+
import { meta } from '../meta';
|
|
12
|
+
import { Chess } from '../types';
|
|
13
|
+
|
|
14
|
+
// TODO(wittjosiah): Factor out shared modules.
|
|
15
|
+
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
16
|
+
AppPlugin.addMetadataModule({
|
|
17
|
+
metadata: {
|
|
18
|
+
id: Chess.Game.typename,
|
|
19
|
+
metadata: {
|
|
20
|
+
createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,
|
|
21
|
+
addToCollectionOnCreate: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
26
|
+
Plugin.make,
|
|
27
|
+
);
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
5
6
|
import React, {
|
|
6
7
|
type PropsWithChildren,
|
|
7
8
|
forwardRef,
|
|
8
9
|
useCallback,
|
|
10
|
+
useContext,
|
|
9
11
|
useEffect,
|
|
10
12
|
useImperativeHandle,
|
|
11
13
|
useMemo,
|
|
@@ -13,9 +15,10 @@ import React, {
|
|
|
13
15
|
} from 'react';
|
|
14
16
|
|
|
15
17
|
import { addEventListener } from '@dxos/async';
|
|
18
|
+
import { useObject } from '@dxos/echo-react';
|
|
16
19
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
17
20
|
import {
|
|
18
|
-
ChessModel,
|
|
21
|
+
type ChessModel,
|
|
19
22
|
Gameboard,
|
|
20
23
|
type GameboardRootProps,
|
|
21
24
|
Chessboard as NaturalChessboard,
|
|
@@ -24,22 +27,17 @@ import {
|
|
|
24
27
|
useGameboardContext,
|
|
25
28
|
} from '@dxos/react-ui-gameboard';
|
|
26
29
|
import { useSoundEffect } from '@dxos/react-ui-sfx';
|
|
27
|
-
import { mx } from '@dxos/
|
|
30
|
+
import { mx } from '@dxos/ui-theme';
|
|
28
31
|
|
|
29
|
-
import { type Chess } from '
|
|
32
|
+
import { type Chess } from '../../types';
|
|
30
33
|
|
|
31
34
|
import { Info, type InfoProps } from './Info';
|
|
35
|
+
import { ExtendedChessModel } from './types';
|
|
32
36
|
|
|
33
37
|
export interface ChessboardController {
|
|
34
38
|
setMoveNumber(index: number): void;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
export class ExtendedChessModel extends ChessModel {
|
|
38
|
-
constructor(readonly object: Chess.Game) {
|
|
39
|
-
super();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
41
|
//
|
|
44
42
|
// Root
|
|
45
43
|
//
|
|
@@ -49,8 +47,10 @@ type RootProps = PropsWithChildren<{
|
|
|
49
47
|
}>;
|
|
50
48
|
|
|
51
49
|
const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {
|
|
52
|
-
const
|
|
50
|
+
const registry = useContext(RegistryContext);
|
|
51
|
+
const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);
|
|
53
52
|
const click = useSoundEffect('Click');
|
|
53
|
+
const [pgn, updatePgn] = useObject(game, 'pgn');
|
|
54
54
|
|
|
55
55
|
// Controller.
|
|
56
56
|
useImperativeHandle(forwardedRef, () => {
|
|
@@ -59,17 +59,21 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
59
59
|
};
|
|
60
60
|
}, [model]);
|
|
61
61
|
|
|
62
|
+
// TODO(wittjosiah): Rather than useEffect to sync ECHO object to model, create an alternative model implementation.
|
|
63
|
+
// This model would take the ECHO object and derive game state directly from that.
|
|
64
|
+
// Mutation methods would mutate the ECHO object and other state would be derived from that.
|
|
65
|
+
|
|
62
66
|
// External change.
|
|
63
67
|
// NOTE: Warning if user has not interacted with the board.
|
|
64
68
|
useEffect(() => {
|
|
65
|
-
if (model.pgn !== getRawPgn(
|
|
69
|
+
if (model.pgn !== getRawPgn(pgn ?? '')) {
|
|
66
70
|
const silent = model.pgn === '*';
|
|
67
|
-
model.update(
|
|
71
|
+
model.update(pgn);
|
|
68
72
|
if (!silent) {
|
|
69
73
|
void click.play();
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
}, [
|
|
76
|
+
}, [pgn]);
|
|
73
77
|
|
|
74
78
|
// Move.
|
|
75
79
|
const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
|
|
@@ -79,7 +83,7 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
void click.play();
|
|
82
|
-
|
|
86
|
+
updatePgn(() => model.pgn);
|
|
83
87
|
return true;
|
|
84
88
|
},
|
|
85
89
|
[model],
|
|
@@ -96,16 +100,17 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
96
100
|
// Content
|
|
97
101
|
//
|
|
98
102
|
|
|
99
|
-
type Role = 'card--
|
|
103
|
+
type Role = 'card--content';
|
|
100
104
|
|
|
101
105
|
type ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;
|
|
102
106
|
|
|
103
107
|
const Content = ({ classNames, children, role }: ContentProps) => {
|
|
104
108
|
return (
|
|
105
109
|
<Gameboard.Content
|
|
106
|
-
classNames={mx(
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
classNames={mx(
|
|
111
|
+
classNames,
|
|
112
|
+
role === 'card--content' ? 'dx-size-container dx-card-square' : 'flex flex-col justify-center',
|
|
113
|
+
)}
|
|
109
114
|
>
|
|
110
115
|
{children}
|
|
111
116
|
</Gameboard.Content>
|
|
@@ -116,10 +121,13 @@ const Content = ({ classNames, children, role }: ContentProps) => {
|
|
|
116
121
|
// Board
|
|
117
122
|
//
|
|
118
123
|
|
|
124
|
+
const BOARD_NAME = 'Chessboard.Board';
|
|
125
|
+
|
|
119
126
|
type BoardProps = NaturalChessboardProps;
|
|
120
127
|
|
|
121
128
|
const Board = (props: BoardProps) => {
|
|
122
|
-
const
|
|
129
|
+
const registry = useContext(RegistryContext);
|
|
130
|
+
const { model } = useGameboardContext<ChessModel>(BOARD_NAME);
|
|
123
131
|
|
|
124
132
|
// Keyboard navigation.
|
|
125
133
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -132,6 +140,7 @@ const Board = (props: BoardProps) => {
|
|
|
132
140
|
ref.current.setAttribute('data-arrow-keys', 'all');
|
|
133
141
|
|
|
134
142
|
return addEventListener(ref.current, 'keydown', (ev) => {
|
|
143
|
+
const moveIndex = registry.get(model.moveIndex);
|
|
135
144
|
switch (ev.key) {
|
|
136
145
|
case 'ArrowUp':
|
|
137
146
|
model.setMoveIndex(0);
|
|
@@ -140,23 +149,23 @@ const Board = (props: BoardProps) => {
|
|
|
140
149
|
model.setMoveIndex(model.game.history().length);
|
|
141
150
|
break;
|
|
142
151
|
case 'ArrowLeft':
|
|
143
|
-
if (
|
|
144
|
-
model.setMoveIndex(
|
|
152
|
+
if (moveIndex > 0) {
|
|
153
|
+
model.setMoveIndex(moveIndex - 1);
|
|
145
154
|
}
|
|
146
155
|
break;
|
|
147
156
|
case 'ArrowRight':
|
|
148
|
-
if (
|
|
149
|
-
model.setMoveIndex(
|
|
157
|
+
if (moveIndex < model.game.history().length) {
|
|
158
|
+
model.setMoveIndex(moveIndex + 1);
|
|
150
159
|
}
|
|
151
160
|
break;
|
|
152
161
|
}
|
|
153
162
|
});
|
|
154
|
-
}, [model]);
|
|
163
|
+
}, [registry, model]);
|
|
155
164
|
|
|
156
|
-
return <NaturalChessboard ref={ref}
|
|
165
|
+
return <NaturalChessboard {...props} ref={ref} />;
|
|
157
166
|
};
|
|
158
167
|
|
|
159
|
-
Board.displayName =
|
|
168
|
+
Board.displayName = BOARD_NAME;
|
|
160
169
|
|
|
161
170
|
//
|
|
162
171
|
// Chessboard
|
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
5
6
|
import React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
|
|
6
7
|
|
|
7
8
|
import { generateName } from '@dxos/display-name';
|
|
8
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { type SpaceMember, useMembers } from '@dxos/react-client/echo';
|
|
9
11
|
import { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
10
12
|
import { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';
|
|
11
|
-
import { mx } from '@dxos/
|
|
13
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
14
|
|
|
13
|
-
import { meta } from '
|
|
15
|
+
import { meta } from '../../meta';
|
|
14
16
|
|
|
15
|
-
import { type ExtendedChessModel } from './
|
|
17
|
+
import { type ExtendedChessModel } from './types';
|
|
18
|
+
|
|
19
|
+
const INFO_NAME = 'Chessboard.Info';
|
|
16
20
|
|
|
17
21
|
export type InfoProps = ThemedClassName<
|
|
18
22
|
{
|
|
@@ -24,13 +28,14 @@ export type InfoProps = ThemedClassName<
|
|
|
24
28
|
|
|
25
29
|
export const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {
|
|
26
30
|
const { t } = useTranslation(meta.id);
|
|
27
|
-
const { model } = useGameboardContext<ExtendedChessModel>(
|
|
28
|
-
const
|
|
31
|
+
const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);
|
|
32
|
+
const db = Obj.getDatabase(model.object);
|
|
33
|
+
const members = useMembers(db?.spaceId);
|
|
29
34
|
|
|
30
35
|
return (
|
|
31
36
|
<div
|
|
32
37
|
className={mx(
|
|
33
|
-
'grid grid-rows-[min-content_1fr_min-content]
|
|
38
|
+
'grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden bg-group-surface rounded-xs',
|
|
34
39
|
classNames,
|
|
35
40
|
)}
|
|
36
41
|
>
|
|
@@ -46,7 +51,9 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
46
51
|
<PlayerSelector
|
|
47
52
|
value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}
|
|
48
53
|
onValueChange={(value) => {
|
|
49
|
-
model.object
|
|
54
|
+
Obj.change(model.object, (obj) => {
|
|
55
|
+
obj.players![orientation === 'white' ? 'black' : 'white'] = value;
|
|
56
|
+
});
|
|
50
57
|
}}
|
|
51
58
|
members={members}
|
|
52
59
|
/>
|
|
@@ -73,7 +80,9 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
73
80
|
<PlayerSelector
|
|
74
81
|
value={model.object.players?.[orientation]}
|
|
75
82
|
onValueChange={(value) => {
|
|
76
|
-
model.object
|
|
83
|
+
Obj.change(model.object, (obj) => {
|
|
84
|
+
obj.players![orientation] = value;
|
|
85
|
+
});
|
|
77
86
|
}}
|
|
78
87
|
members={members}
|
|
79
88
|
/>
|
|
@@ -82,7 +91,7 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
82
91
|
);
|
|
83
92
|
};
|
|
84
93
|
|
|
85
|
-
Info.displayName =
|
|
94
|
+
Info.displayName = INFO_NAME;
|
|
86
95
|
|
|
87
96
|
//
|
|
88
97
|
// History
|
|
@@ -97,6 +106,7 @@ type HistoryProps = ThemedClassName<{
|
|
|
97
106
|
|
|
98
107
|
const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
|
|
99
108
|
const { t } = useTranslation(meta.id);
|
|
109
|
+
const moveIndex = useAtomValue(model.moveIndex);
|
|
100
110
|
const label = model.game.isGameOver()
|
|
101
111
|
? model.game.isCheckmate()
|
|
102
112
|
? t('game.checkmate label')
|
|
@@ -130,28 +140,28 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
|
|
|
130
140
|
}, [history.length]);
|
|
131
141
|
|
|
132
142
|
useEffect(() => {
|
|
133
|
-
const div = scrollerRef.current?.querySelector(`[data-index="${
|
|
143
|
+
const div = scrollerRef.current?.querySelector(`[data-index="${moveIndex - 1}"]`);
|
|
134
144
|
scrollerRef.current?.classList.add('scrollbar-none');
|
|
135
145
|
div?.scrollIntoView({ behavior: 'smooth' });
|
|
136
146
|
scrollerRef.current?.classList.remove('scrollbar-none');
|
|
137
|
-
}, [
|
|
147
|
+
}, [moveIndex]);
|
|
138
148
|
|
|
139
149
|
return (
|
|
140
150
|
<div
|
|
141
151
|
ref={scrollerRef}
|
|
142
|
-
className={mx('overflow-y-
|
|
152
|
+
className={mx('overflow-y-auto', classNames)}
|
|
143
153
|
style={{
|
|
144
154
|
minHeight: min === undefined ? 'auto' : `${min * 24}px`,
|
|
145
155
|
maxHeight: max === undefined ? 'auto' : `${max * 24}px`,
|
|
146
156
|
}}
|
|
147
157
|
>
|
|
148
158
|
{moves.map(([a, b], index) => (
|
|
149
|
-
<div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2
|
|
159
|
+
<div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4 leading-1'>
|
|
150
160
|
<div className='content-center text-xs text-subdued'>{index + 1}</div>
|
|
151
161
|
{a && (
|
|
152
162
|
<div
|
|
153
163
|
data-index={a.index}
|
|
154
|
-
className={mx('
|
|
164
|
+
className={mx('ps-2 cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}
|
|
155
165
|
onClick={() => onSelect?.(a.index + 1)}
|
|
156
166
|
>
|
|
157
167
|
{a.move}
|
|
@@ -160,7 +170,7 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
|
|
|
160
170
|
{b && (
|
|
161
171
|
<div
|
|
162
172
|
data-index={b.index}
|
|
163
|
-
className={mx('
|
|
173
|
+
className={mx('ps-2 cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}
|
|
164
174
|
onClick={() => onSelect?.(b.index + 1)}
|
|
165
175
|
>
|
|
166
176
|
{b.move}
|
|
@@ -186,7 +196,7 @@ type PlayerIndicatorProps = PropsWithChildren<{
|
|
|
186
196
|
const PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {
|
|
187
197
|
const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');
|
|
188
198
|
return (
|
|
189
|
-
<div className='grid grid-cols-[2rem_1fr_2rem] gap-2
|
|
199
|
+
<div className='grid grid-cols-[2rem_1fr_2rem] gap-2 h-(--dx-rail-size) px-1 flex items-center overflow-hidden'>
|
|
190
200
|
<div className='place-items-center'>
|
|
191
201
|
<Icon
|
|
192
202
|
icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Registry } from '@effect-atom/atom-react';
|
|
6
|
+
|
|
7
|
+
import { ChessModel } from '@dxos/react-ui-gameboard';
|
|
8
|
+
|
|
9
|
+
import { type Chess } from '../../types';
|
|
10
|
+
|
|
11
|
+
export class ExtendedChessModel extends ChessModel {
|
|
12
|
+
constructor(
|
|
13
|
+
registry: Registry.Registry,
|
|
14
|
+
readonly object: Chess.Game,
|
|
15
|
+
) {
|
|
16
|
+
super(registry);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
|
|
11
|
+
import { translations } from '../../translations';
|
|
12
|
+
import { Chess } from '../../types';
|
|
13
|
+
|
|
14
|
+
import { ChessArticle } from './ChessArticle';
|
|
15
|
+
|
|
16
|
+
type StoryProps = {
|
|
17
|
+
pgn?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const DefaultStory = ({ pgn }: StoryProps) => {
|
|
21
|
+
const game = useMemo(() => Chess.make(pgn ? { pgn } : undefined), [pgn]);
|
|
22
|
+
return <ChessArticle subject={game} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const meta = {
|
|
26
|
+
title: 'plugins/plugin-chess/containers/ChessArticle',
|
|
27
|
+
component: DefaultStory,
|
|
28
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withClientProvider({ createIdentity: true })],
|
|
29
|
+
parameters: {
|
|
30
|
+
layout: 'fullscreen',
|
|
31
|
+
translations,
|
|
32
|
+
},
|
|
33
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
|
|
37
|
+
type Story = StoryObj<typeof meta>;
|
|
38
|
+
|
|
39
|
+
export const Default: Story = {
|
|
40
|
+
args: {},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const EndGame: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
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 *',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Promption: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
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 *',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Panel, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { type Player } from '@dxos/react-ui-gameboard';
|
|
10
|
+
import { mx } from '@dxos/ui-theme';
|
|
11
|
+
|
|
12
|
+
import { Chessboard, type ChessboardController, type ChessboardInfoProps } from '../../components';
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
|
+
import { type Chess } from '../../types';
|
|
15
|
+
|
|
16
|
+
export type ChessArticleProps = SurfaceComponentProps<Chess.Game>;
|
|
17
|
+
|
|
18
|
+
export const ChessArticle = ({ role, subject: game }: ChessArticleProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const [orientation, setOrientation] = useState<Player>('white');
|
|
21
|
+
const [open, setOpen] = useState(true);
|
|
22
|
+
const controller = useRef<ChessboardController>(null);
|
|
23
|
+
|
|
24
|
+
const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {
|
|
25
|
+
controller.current?.setMoveNumber(index);
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Chessboard.Root game={game} ref={controller}>
|
|
30
|
+
<Panel.Root role={role} classNames='@container'>
|
|
31
|
+
<Panel.Toolbar asChild>
|
|
32
|
+
<Toolbar.Root>
|
|
33
|
+
<Toolbar.IconButton
|
|
34
|
+
icon='ph--info--regular'
|
|
35
|
+
iconOnly
|
|
36
|
+
label={t('toggle info button')}
|
|
37
|
+
disabled={open}
|
|
38
|
+
classNames={mx('invisible @3xl:visible')}
|
|
39
|
+
onClick={() => setOpen((open) => !open)}
|
|
40
|
+
/>
|
|
41
|
+
</Toolbar.Root>
|
|
42
|
+
</Panel.Toolbar>
|
|
43
|
+
<Panel.Content>
|
|
44
|
+
<div
|
|
45
|
+
className={mx(
|
|
46
|
+
'grid h-full w-full gap-2',
|
|
47
|
+
open && '@3xl:grid-cols-[1fr_320px]',
|
|
48
|
+
role === 'section' && 'aspect-square',
|
|
49
|
+
role === 'section' && open && '@3xl:aspect-auto',
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<Chessboard.Content>
|
|
53
|
+
<Chessboard.Board classNames='m-4 rounded-xs overflow-hidden' orientation={orientation} />
|
|
54
|
+
</Chessboard.Content>
|
|
55
|
+
{open && (
|
|
56
|
+
<div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>
|
|
57
|
+
<Chessboard.Info
|
|
58
|
+
orientation={orientation}
|
|
59
|
+
min={8}
|
|
60
|
+
max={8}
|
|
61
|
+
onOrientationChange={setOrientation}
|
|
62
|
+
onClose={() => setOpen(false)}
|
|
63
|
+
onSelect={handleSelect}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
</Panel.Content>
|
|
69
|
+
</Panel.Root>
|
|
70
|
+
</Chessboard.Root>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
import { CardContainer } from '@dxos/react-ui-mosaic/testing';
|
|
10
|
+
|
|
11
|
+
import { meta as pluginMeta } from '../../meta';
|
|
12
|
+
import { Chess } from '../../types';
|
|
13
|
+
|
|
14
|
+
import { ChessCard } from './ChessCard';
|
|
15
|
+
|
|
16
|
+
const SAMPLE_PGN =
|
|
17
|
+
'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
|
+
const CardStory = () => {
|
|
20
|
+
const game = useMemo(() => Chess.make({ pgn: SAMPLE_PGN }), []);
|
|
21
|
+
return (
|
|
22
|
+
<CardContainer role='popover' icon={pluginMeta.icon}>
|
|
23
|
+
<ChessCard subject={game} />
|
|
24
|
+
</CardContainer>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const meta = {
|
|
29
|
+
title: 'plugins/plugin-chess/containers/ChessCard',
|
|
30
|
+
render: () => <CardStory />,
|
|
31
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: 'fullscreen',
|
|
34
|
+
},
|
|
35
|
+
tags: ['cards'],
|
|
36
|
+
} satisfies Meta;
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
|
|
40
|
+
type Story = StoryObj<typeof meta>;
|
|
41
|
+
|
|
42
|
+
export const Popover: Story = {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
|
|
9
|
+
import { Chessboard } from '../../components';
|
|
10
|
+
import { type Chess } from '../../types';
|
|
11
|
+
|
|
12
|
+
export type ChessCardProps = SurfaceComponentProps<Chess.Game>;
|
|
13
|
+
|
|
14
|
+
export const ChessCard = ({ subject: game }: ChessCardProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<Chessboard.Root game={game}>
|
|
17
|
+
<Chessboard.Content>
|
|
18
|
+
<Chessboard.Board />
|
|
19
|
+
</Chessboard.Content>
|
|
20
|
+
</Chessboard.Root>
|
|
21
|
+
);
|
|
22
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export * from './blueprints';
|
|
5
6
|
export * from './capabilities';
|
|
6
|
-
export * from './components';
|
|
7
|
-
export * from './functions';
|
|
7
|
+
export * from './components/Chessboard';
|
|
8
8
|
export * from './meta';
|
|
9
9
|
export * from './types';
|
|
10
10
|
|
package/src/meta.ts
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/chess',
|
|
10
10
|
name: 'Chess',
|
|
11
11
|
description: trim`
|
|
12
|
-
|
|
12
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
13
|
+
Track game history and analyze moves in real-time.
|
|
13
14
|
`,
|
|
14
15
|
icon: 'ph--shield-chevron--regular',
|
|
16
|
+
iconHue: 'amber',
|
|
15
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',
|
|
16
18
|
screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],
|
|
17
19
|
};
|