@dxos/plugin-chess 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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-UDSL3OJ4.mjs +59 -0
- package/dist/lib/browser/ChessArticle-UDSL3OJ4.mjs.map +7 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs +21 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +4 -4
- package/dist/lib/browser/{chunk-66H3V2YV.mjs → chunk-2TJN26DN.mjs} +9 -6
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO4ZNFN6.mjs → chunk-6JG4KLVU.mjs} +44 -42
- package/dist/lib/browser/chunk-6JG4KLVU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-73BDP7UV.mjs → chunk-JP6G6VR6.mjs} +30 -29
- package/dist/lib/browser/chunk-JP6G6VR6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-H3NUMCQ6.mjs → chunk-RGHZ5CDO.mjs} +2 -2
- package/dist/lib/browser/{chunk-H3NUMCQ6.mjs.map → chunk-RGHZ5CDO.mjs.map} +1 -1
- 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 +10 -10
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +25 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs +50 -0
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs +60 -0
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs.map +7 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs +22 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-SL4LBVV5.mjs → blueprint-definition-PFZMTCXY.mjs} +7 -7
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +4 -4
- package/dist/lib/node-esm/{chunk-C7IWIXCJ.mjs → chunk-46DC6W7W.mjs} +44 -42
- package/dist/lib/node-esm/chunk-46DC6W7W.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-WXEPWOHT.mjs → chunk-FK7NVSOG.mjs} +30 -29
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F5OMIM4F.mjs → chunk-FYPVCMP4.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-F5OMIM4F.mjs.map → chunk-FYPVCMP4.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-OUNGNJFP.mjs → chunk-OIRJVY2R.mjs} +9 -6
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +10 -10
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +25 -28
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs +51 -0
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/chess-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/create.d.ts +1 -1
- package/dist/types/src/blueprints/functions/index.d.ts +55 -4
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/move.d.ts +9 -1
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/play.d.ts +9 -1
- package/dist/types/src/blueprints/functions/play.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +3 -6
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +3 -8
- 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} +3 -2
- 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} +1 -1
- 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 +1 -1
- package/dist/types/src/index.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 +1 -1
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -35
- package/src/ChessPlugin.tsx +13 -10
- package/src/blueprints/chess-blueprint.ts +14 -6
- package/src/blueprints/functions/create.ts +2 -2
- package/src/blueprints/functions/index.ts +13 -4
- package/src/blueprints/functions/move.ts +11 -12
- package/src/blueprints/functions/play.ts +5 -6
- package/src/blueprints/functions/print.ts +1 -1
- package/src/blueprints/index.ts +1 -1
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +6 -12
- package/src/capabilities/react-surface/react-surface.tsx +13 -7
- package/src/cli/plugin.ts +4 -4
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +24 -26
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +12 -10
- 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/{components/Chessboard.stories.tsx → containers/ChessArticle/ChessArticle.stories.tsx} +7 -7
- package/src/containers/ChessArticle/ChessArticle.tsx +72 -0
- package/src/containers/ChessArticle/index.ts +7 -0
- package/src/{components/Card.stories.tsx → containers/ChessCard/ChessCard.stories.tsx} +9 -14
- 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 +1 -1
- package/src/meta.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/Chess.ts +7 -3
- package/dist/lib/browser/ChessboardContainer-JZ4ANG4O.mjs +0 -81
- package/dist/lib/browser/ChessboardContainer-JZ4ANG4O.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-P7TYXWMF.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-P7TYXWMF.mjs.map +0 -7
- package/dist/lib/browser/chunk-66H3V2YV.mjs.map +0 -7
- package/dist/lib/browser/chunk-73BDP7UV.mjs.map +0 -7
- package/dist/lib/browser/chunk-FO4ZNFN6.mjs.map +0 -7
- package/dist/lib/browser/chunk-OW6S2SRG.mjs +0 -8
- package/dist/lib/browser/chunk-OW6S2SRG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VNOWFKC6.mjs +0 -37
- package/dist/lib/browser/react-surface-VNOWFKC6.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-7ONFYN7L.mjs +0 -82
- package/dist/lib/node-esm/ChessboardContainer-7ONFYN7L.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-SL4LBVV5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-24GJHLHM.mjs +0 -10
- package/dist/lib/node-esm/chunk-24GJHLHM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C7IWIXCJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WXEPWOHT.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-HSHCIOAS.mjs +0 -38
- package/dist/lib/node-esm/react-surface-HSHCIOAS.mjs.map +0 -7
- 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 -6
- package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +0 -7
- package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
- package/dist/types/src/components/Info.d.ts.map +0 -1
- package/src/components/ChessboardArticle.tsx +0 -71
- package/src/components/ChessboardContainer.tsx +0 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-chess",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.c351d160a8",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -52,51 +52,52 @@
|
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@automerge/automerge": "3.2.3",
|
|
55
|
-
"@effect-atom/atom-react": "^0.
|
|
55
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
56
56
|
"chess.js": "^1.0.0",
|
|
57
|
-
"effect": "3.19.
|
|
58
|
-
"@dxos/ai": "0.8.4-main.
|
|
59
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/echo-
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/functions": "0.8.4-main.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
71
|
-
"@dxos/operation": "0.8.4-main.
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/plugin-graph": "0.8.4-main.
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/plugin-space": "0.8.4-main.
|
|
76
|
-
"@dxos/react-ui-gameboard": "0.8.4-main.
|
|
77
|
-
"@dxos/react-
|
|
78
|
-
"@dxos/react-ui-
|
|
79
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
80
|
-
"@dxos/schema": "0.8.4-main.
|
|
81
|
-
"@dxos/util": "0.8.4-main.
|
|
82
|
-
"@dxos/
|
|
57
|
+
"effect": "3.19.16",
|
|
58
|
+
"@dxos/ai": "0.8.4-main.c351d160a8",
|
|
59
|
+
"@dxos/app-framework": "0.8.4-main.c351d160a8",
|
|
60
|
+
"@dxos/assistant": "0.8.4-main.c351d160a8",
|
|
61
|
+
"@dxos/app-toolkit": "0.8.4-main.c351d160a8",
|
|
62
|
+
"@dxos/blueprints": "0.8.4-main.c351d160a8",
|
|
63
|
+
"@dxos/async": "0.8.4-main.c351d160a8",
|
|
64
|
+
"@dxos/display-name": "0.8.4-main.c351d160a8",
|
|
65
|
+
"@dxos/echo-db": "0.8.4-main.c351d160a8",
|
|
66
|
+
"@dxos/echo-react": "0.8.4-main.c351d160a8",
|
|
67
|
+
"@dxos/echo": "0.8.4-main.c351d160a8",
|
|
68
|
+
"@dxos/functions": "0.8.4-main.c351d160a8",
|
|
69
|
+
"@dxos/invariant": "0.8.4-main.c351d160a8",
|
|
70
|
+
"@dxos/plugin-client": "0.8.4-main.c351d160a8",
|
|
71
|
+
"@dxos/operation": "0.8.4-main.c351d160a8",
|
|
72
|
+
"@dxos/log": "0.8.4-main.c351d160a8",
|
|
73
|
+
"@dxos/plugin-graph": "0.8.4-main.c351d160a8",
|
|
74
|
+
"@dxos/plugin-markdown": "0.8.4-main.c351d160a8",
|
|
75
|
+
"@dxos/plugin-space": "0.8.4-main.c351d160a8",
|
|
76
|
+
"@dxos/react-ui-gameboard": "0.8.4-main.c351d160a8",
|
|
77
|
+
"@dxos/react-client": "0.8.4-main.c351d160a8",
|
|
78
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.c351d160a8",
|
|
79
|
+
"@dxos/react-ui-stack": "0.8.4-main.c351d160a8",
|
|
80
|
+
"@dxos/schema": "0.8.4-main.c351d160a8",
|
|
81
|
+
"@dxos/util": "0.8.4-main.c351d160a8",
|
|
82
|
+
"@dxos/react-ui-sfx": "0.8.4-main.c351d160a8",
|
|
83
|
+
"@dxos/types": "0.8.4-main.c351d160a8"
|
|
83
84
|
},
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@types/react": "~19.2.7",
|
|
86
87
|
"@types/react-dom": "~19.2.3",
|
|
87
88
|
"react": "~19.2.3",
|
|
88
89
|
"react-dom": "~19.2.3",
|
|
89
|
-
"vite": "7.1.
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
90
|
+
"vite": "^7.1.11",
|
|
91
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
92
|
+
"@dxos/storybook-utils": "0.8.4-main.c351d160a8",
|
|
93
|
+
"@dxos/plugin-theme": "0.8.4-main.c351d160a8",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"react": "~19.2.3",
|
|
97
98
|
"react-dom": "~19.2.3",
|
|
98
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
99
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
99
|
+
"@dxos/react-ui": "0.8.4-main.c351d160a8",
|
|
100
|
+
"@dxos/ui-theme": "0.8.4-main.c351d160a8"
|
|
100
101
|
},
|
|
101
102
|
"publishConfig": {
|
|
102
103
|
"access": "public"
|
package/src/ChessPlugin.tsx
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
|
|
9
|
+
import { Plugin } from '@dxos/app-framework';
|
|
10
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
11
|
+
import { Annotation } from '@dxos/echo';
|
|
8
12
|
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
9
13
|
|
|
10
14
|
import { ChessBlueprint } from './blueprints';
|
|
@@ -14,21 +18,20 @@ import { translations } from './translations';
|
|
|
14
18
|
import { Chess } from './types';
|
|
15
19
|
|
|
16
20
|
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),
|
|
22
|
+
AppPlugin.addMetadataModule({
|
|
19
23
|
metadata: {
|
|
20
24
|
id: Chess.Game.typename,
|
|
21
25
|
metadata: {
|
|
22
|
-
icon:
|
|
23
|
-
iconHue: '
|
|
24
|
-
blueprints: [ChessBlueprint.
|
|
26
|
+
icon: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).icon,
|
|
27
|
+
iconHue: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).hue ?? 'white',
|
|
28
|
+
blueprints: [ChessBlueprint.key],
|
|
25
29
|
createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,
|
|
26
|
-
addToCollectionOnCreate: true,
|
|
27
30
|
},
|
|
28
31
|
},
|
|
29
32
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
34
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
35
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
33
36
|
Plugin.make,
|
|
34
37
|
);
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type AppCapabilities } from '@dxos/app-toolkit';
|
|
5
6
|
import { Blueprint, Template } from '@dxos/blueprints';
|
|
6
|
-
import { type FunctionDefinition } from '@dxos/functions';
|
|
7
7
|
import { trim } from '@dxos/util';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { ChessFunctions } from './functions';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const BLUEPRINT_KEY = 'org.dxos.blueprint.chess';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const functions = Object.values(ChessFunctions);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const make = () =>
|
|
16
16
|
Blueprint.make({
|
|
17
|
-
key:
|
|
17
|
+
key: BLUEPRINT_KEY,
|
|
18
18
|
name: 'Chess',
|
|
19
19
|
tools: Blueprint.toolDefinitions({ functions }),
|
|
20
20
|
instructions: Template.make({
|
|
@@ -26,3 +26,11 @@ export const make = () =>
|
|
|
26
26
|
`,
|
|
27
27
|
}),
|
|
28
28
|
});
|
|
29
|
+
|
|
30
|
+
const blueprint: AppCapabilities.BlueprintDefinition = {
|
|
31
|
+
key: BLUEPRINT_KEY,
|
|
32
|
+
functions,
|
|
33
|
+
make,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default blueprint;
|
|
@@ -11,7 +11,7 @@ import { defineFunction } from '@dxos/functions';
|
|
|
11
11
|
import { Chess } from '../../types';
|
|
12
12
|
|
|
13
13
|
export default defineFunction({
|
|
14
|
-
key: 'dxos.
|
|
14
|
+
key: 'org.dxos.function.chess.create',
|
|
15
15
|
name: 'Create Chess',
|
|
16
16
|
description: 'Creates a new chess game.',
|
|
17
17
|
inputSchema: Schema.Struct({
|
|
@@ -33,6 +33,6 @@ export default defineFunction({
|
|
|
33
33
|
}),
|
|
34
34
|
outputSchema: Chess.Game,
|
|
35
35
|
handler: Effect.fn(function* ({ data: { name, pgn, fen } }) {
|
|
36
|
-
return yield* Database.
|
|
36
|
+
return yield* Database.add(Chess.make({ name, pgn, fen }));
|
|
37
37
|
}),
|
|
38
38
|
});
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import Create from './create';
|
|
6
|
+
import Move from './move';
|
|
7
|
+
import Play from './play';
|
|
8
|
+
import Print from './print';
|
|
9
|
+
|
|
10
|
+
export { Create, Move, Play, Print };
|
|
11
|
+
|
|
12
|
+
export const ChessFunctions = {
|
|
13
|
+
Create,
|
|
14
|
+
Move,
|
|
15
|
+
Play,
|
|
16
|
+
Print,
|
|
17
|
+
};
|
|
@@ -6,18 +6,17 @@ import { Chess as ChessJS } from 'chess.js';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { Database, Obj } from '@dxos/echo';
|
|
9
|
+
import { Database, Obj, Ref } from '@dxos/echo';
|
|
11
10
|
import { defineFunction } from '@dxos/functions';
|
|
12
11
|
|
|
13
12
|
import { Chess } from '../../types';
|
|
14
13
|
|
|
15
14
|
export default defineFunction({
|
|
16
|
-
key: 'dxos.
|
|
15
|
+
key: 'org.dxos.function.chess.move',
|
|
17
16
|
name: 'Move',
|
|
18
17
|
description: 'Makes a move in the given chess game.',
|
|
19
18
|
inputSchema: Schema.Struct({
|
|
20
|
-
|
|
19
|
+
game: Ref.Ref(Chess.Game).annotations({
|
|
21
20
|
description: 'The ID of the chess object.',
|
|
22
21
|
}),
|
|
23
22
|
move: Schema.String.annotations({
|
|
@@ -30,19 +29,19 @@ export default defineFunction({
|
|
|
30
29
|
description: 'The PGN of the game after the move was played.',
|
|
31
30
|
}),
|
|
32
31
|
}),
|
|
33
|
-
handler: Effect.fn(function* ({ data: {
|
|
34
|
-
const
|
|
32
|
+
handler: Effect.fn(function* ({ data: { game, move } }) {
|
|
33
|
+
const obj = yield* Database.load(game);
|
|
35
34
|
const chess = new ChessJS();
|
|
36
|
-
if (
|
|
37
|
-
chess.loadPgn(
|
|
38
|
-
} else if (
|
|
39
|
-
chess.load(
|
|
35
|
+
if (obj.pgn) {
|
|
36
|
+
chess.loadPgn(obj.pgn);
|
|
37
|
+
} else if (obj.fen) {
|
|
38
|
+
chess.load(obj.fen);
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
chess.move(move, { strict: false });
|
|
43
42
|
const pgn = chess.pgn();
|
|
44
|
-
Obj.change(
|
|
45
|
-
|
|
43
|
+
Obj.change(obj, (obj) => {
|
|
44
|
+
obj.pgn = pgn;
|
|
46
45
|
});
|
|
47
46
|
return { pgn };
|
|
48
47
|
}),
|
|
@@ -6,18 +6,17 @@ import { Chess as ChessJS } from 'chess.js';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { Database, Obj } from '@dxos/echo';
|
|
9
|
+
import { Database, Obj, Ref } from '@dxos/echo';
|
|
11
10
|
import { defineFunction } from '@dxos/functions';
|
|
12
11
|
|
|
13
12
|
import { Chess } from '../../types';
|
|
14
13
|
|
|
15
14
|
export default defineFunction({
|
|
16
|
-
key: 'dxos.
|
|
15
|
+
key: 'org.dxos.function.chess.play',
|
|
17
16
|
name: 'Play',
|
|
18
17
|
description: 'Uses the chess engine to play the next move.',
|
|
19
18
|
inputSchema: Schema.Struct({
|
|
20
|
-
|
|
19
|
+
game: Ref.Ref(Chess.Game).annotations({
|
|
21
20
|
description: 'The ID of the chess object.',
|
|
22
21
|
}),
|
|
23
22
|
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
@@ -33,8 +32,8 @@ export default defineFunction({
|
|
|
33
32
|
description: 'The move that was played.',
|
|
34
33
|
}),
|
|
35
34
|
}),
|
|
36
|
-
handler: Effect.fn(function* ({ data: {
|
|
37
|
-
const object = yield* Database.
|
|
35
|
+
handler: Effect.fn(function* ({ data: { game, side = 'any' } }) {
|
|
36
|
+
const object = yield* Database.load(game);
|
|
38
37
|
const chess = new ChessJS();
|
|
39
38
|
if (object.pgn) {
|
|
40
39
|
chess.loadPgn(object.pgn);
|
|
@@ -9,7 +9,7 @@ import * as Schema from 'effect/Schema';
|
|
|
9
9
|
import { defineFunction } from '@dxos/functions';
|
|
10
10
|
|
|
11
11
|
export default defineFunction({
|
|
12
|
-
key: 'dxos.
|
|
12
|
+
key: 'org.dxos.function.chess.print',
|
|
13
13
|
name: 'Print game',
|
|
14
14
|
description: 'Prints the chess game to ASCII.',
|
|
15
15
|
inputSchema: Schema.Struct({
|
package/src/blueprints/index.ts
CHANGED
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { Capability
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
|
|
9
10
|
import { ChessBlueprint } from '../../blueprints';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Capability.Capability<typeof
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const blueprintDefinition = Capability.makeModule<[], BlueprintCapabilities>(() =>
|
|
17
|
-
Effect.succeed([
|
|
18
|
-
Capability.contributes(Common.Capability.Functions, ChessBlueprint.functions),
|
|
19
|
-
Capability.contributes(Common.Capability.BlueprintDefinition, ChessBlueprint.make()),
|
|
20
|
-
]),
|
|
21
|
-
);
|
|
12
|
+
const blueprintDefinition = Capability.makeModule<
|
|
13
|
+
[],
|
|
14
|
+
Capability.Capability<typeof AppCapabilities.BlueprintDefinition>[]
|
|
15
|
+
>(() => Effect.succeed([Capability.contributes(AppCapabilities.BlueprintDefinition, ChessBlueprint)]));
|
|
22
16
|
|
|
23
17
|
export default blueprintDefinition;
|
|
@@ -5,22 +5,28 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
10
|
import { Obj } from '@dxos/echo';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
+
import { ChessArticle, ChessCard } from '../../containers';
|
|
12
13
|
import { meta } from '../../meta';
|
|
13
14
|
import { Chess } from '../../types';
|
|
14
15
|
|
|
15
16
|
export default Capability.makeModule(() =>
|
|
16
17
|
Effect.succeed(
|
|
17
|
-
Capability.contributes(
|
|
18
|
-
|
|
18
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
19
|
+
Surface.create({
|
|
19
20
|
id: meta.id,
|
|
20
|
-
role: ['article', 'section'
|
|
21
|
-
// TODO(burdon): Could this be standardized so that we don't require a subject property.
|
|
21
|
+
role: ['article', 'section'],
|
|
22
22
|
filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),
|
|
23
|
-
component: ({ data, role }) => <
|
|
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} />,
|
|
24
30
|
}),
|
|
25
31
|
]),
|
|
26
32
|
),
|
package/src/cli/plugin.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
8
9
|
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
9
10
|
|
|
10
11
|
import { meta } from '../meta';
|
|
@@ -12,15 +13,14 @@ import { Chess } from '../types';
|
|
|
12
13
|
|
|
13
14
|
// TODO(wittjosiah): Factor out shared modules.
|
|
14
15
|
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
15
|
-
|
|
16
|
-
Common.Plugin.addMetadataModule({
|
|
16
|
+
AppPlugin.addMetadataModule({
|
|
17
17
|
metadata: {
|
|
18
18
|
id: Chess.Game.typename,
|
|
19
19
|
metadata: {
|
|
20
20
|
createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,
|
|
21
|
-
addToCollectionOnCreate: true,
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
}),
|
|
24
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
25
25
|
Plugin.make,
|
|
26
26
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
6
|
import React, {
|
|
7
7
|
type PropsWithChildren,
|
|
8
8
|
forwardRef,
|
|
@@ -15,10 +15,10 @@ import React, {
|
|
|
15
15
|
} from 'react';
|
|
16
16
|
|
|
17
17
|
import { addEventListener } from '@dxos/async';
|
|
18
|
-
import {
|
|
18
|
+
import { useObject } from '@dxos/echo-react';
|
|
19
19
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
20
20
|
import {
|
|
21
|
-
ChessModel,
|
|
21
|
+
type ChessModel,
|
|
22
22
|
Gameboard,
|
|
23
23
|
type GameboardRootProps,
|
|
24
24
|
Chessboard as NaturalChessboard,
|
|
@@ -29,23 +29,15 @@ import {
|
|
|
29
29
|
import { useSoundEffect } from '@dxos/react-ui-sfx';
|
|
30
30
|
import { mx } from '@dxos/ui-theme';
|
|
31
31
|
|
|
32
|
-
import { type Chess } from '
|
|
32
|
+
import { type Chess } from '../../types';
|
|
33
33
|
|
|
34
34
|
import { Info, type InfoProps } from './Info';
|
|
35
|
+
import { ExtendedChessModel } from './types';
|
|
35
36
|
|
|
36
37
|
export interface ChessboardController {
|
|
37
38
|
setMoveNumber(index: number): void;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export class ExtendedChessModel extends ChessModel {
|
|
41
|
-
constructor(
|
|
42
|
-
registry: Registry.Registry,
|
|
43
|
-
readonly object: Chess.Game,
|
|
44
|
-
) {
|
|
45
|
-
super(registry);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
41
|
//
|
|
50
42
|
// Root
|
|
51
43
|
//
|
|
@@ -58,6 +50,7 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
58
50
|
const registry = useContext(RegistryContext);
|
|
59
51
|
const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);
|
|
60
52
|
const click = useSoundEffect('Click');
|
|
53
|
+
const [pgn, updatePgn] = useObject(game, 'pgn');
|
|
61
54
|
|
|
62
55
|
// Controller.
|
|
63
56
|
useImperativeHandle(forwardedRef, () => {
|
|
@@ -66,17 +59,21 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
66
59
|
};
|
|
67
60
|
}, [model]);
|
|
68
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
|
+
|
|
69
66
|
// External change.
|
|
70
67
|
// NOTE: Warning if user has not interacted with the board.
|
|
71
68
|
useEffect(() => {
|
|
72
|
-
if (model.pgn !== getRawPgn(
|
|
69
|
+
if (model.pgn !== getRawPgn(pgn ?? '')) {
|
|
73
70
|
const silent = model.pgn === '*';
|
|
74
|
-
model.update(
|
|
71
|
+
model.update(pgn);
|
|
75
72
|
if (!silent) {
|
|
76
73
|
void click.play();
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
|
-
}, [
|
|
76
|
+
}, [pgn]);
|
|
80
77
|
|
|
81
78
|
// Move.
|
|
82
79
|
const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
|
|
@@ -86,9 +83,7 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
void click.play();
|
|
89
|
-
|
|
90
|
-
g.pgn = model.pgn;
|
|
91
|
-
});
|
|
86
|
+
updatePgn(() => model.pgn);
|
|
92
87
|
return true;
|
|
93
88
|
},
|
|
94
89
|
[model],
|
|
@@ -105,16 +100,17 @@ const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, fo
|
|
|
105
100
|
// Content
|
|
106
101
|
//
|
|
107
102
|
|
|
108
|
-
type Role = 'card--
|
|
103
|
+
type Role = 'card--content';
|
|
109
104
|
|
|
110
105
|
type ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;
|
|
111
106
|
|
|
112
107
|
const Content = ({ classNames, children, role }: ContentProps) => {
|
|
113
108
|
return (
|
|
114
109
|
<Gameboard.Content
|
|
115
|
-
classNames={mx(
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
classNames={mx(
|
|
111
|
+
classNames,
|
|
112
|
+
role === 'card--content' ? 'dx-size-container dx-card-square' : 'flex flex-col justify-center',
|
|
113
|
+
)}
|
|
118
114
|
>
|
|
119
115
|
{children}
|
|
120
116
|
</Gameboard.Content>
|
|
@@ -125,11 +121,13 @@ const Content = ({ classNames, children, role }: ContentProps) => {
|
|
|
125
121
|
// Board
|
|
126
122
|
//
|
|
127
123
|
|
|
124
|
+
const BOARD_NAME = 'Chessboard.Board';
|
|
125
|
+
|
|
128
126
|
type BoardProps = NaturalChessboardProps;
|
|
129
127
|
|
|
130
128
|
const Board = (props: BoardProps) => {
|
|
131
129
|
const registry = useContext(RegistryContext);
|
|
132
|
-
const { model } = useGameboardContext<ChessModel>(
|
|
130
|
+
const { model } = useGameboardContext<ChessModel>(BOARD_NAME);
|
|
133
131
|
|
|
134
132
|
// Keyboard navigation.
|
|
135
133
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -164,10 +162,10 @@ const Board = (props: BoardProps) => {
|
|
|
164
162
|
});
|
|
165
163
|
}, [registry, model]);
|
|
166
164
|
|
|
167
|
-
return <NaturalChessboard ref={ref}
|
|
165
|
+
return <NaturalChessboard {...props} ref={ref} />;
|
|
168
166
|
};
|
|
169
167
|
|
|
170
|
-
Board.displayName =
|
|
168
|
+
Board.displayName = BOARD_NAME;
|
|
171
169
|
|
|
172
170
|
//
|
|
173
171
|
// Chessboard
|
|
@@ -12,9 +12,11 @@ import { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '
|
|
|
12
12
|
import { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';
|
|
13
13
|
import { mx } from '@dxos/ui-theme';
|
|
14
14
|
|
|
15
|
-
import { meta } from '
|
|
15
|
+
import { meta } from '../../meta';
|
|
16
16
|
|
|
17
|
-
import { type ExtendedChessModel } from './
|
|
17
|
+
import { type ExtendedChessModel } from './types';
|
|
18
|
+
|
|
19
|
+
const INFO_NAME = 'Chessboard.Info';
|
|
18
20
|
|
|
19
21
|
export type InfoProps = ThemedClassName<
|
|
20
22
|
{
|
|
@@ -26,14 +28,14 @@ export type InfoProps = ThemedClassName<
|
|
|
26
28
|
|
|
27
29
|
export const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {
|
|
28
30
|
const { t } = useTranslation(meta.id);
|
|
29
|
-
const { model } = useGameboardContext<ExtendedChessModel>(
|
|
31
|
+
const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);
|
|
30
32
|
const db = Obj.getDatabase(model.object);
|
|
31
33
|
const members = useMembers(db?.spaceId);
|
|
32
34
|
|
|
33
35
|
return (
|
|
34
36
|
<div
|
|
35
37
|
className={mx(
|
|
36
|
-
'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',
|
|
37
39
|
classNames,
|
|
38
40
|
)}
|
|
39
41
|
>
|
|
@@ -89,7 +91,7 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
89
91
|
);
|
|
90
92
|
};
|
|
91
93
|
|
|
92
|
-
Info.displayName =
|
|
94
|
+
Info.displayName = INFO_NAME;
|
|
93
95
|
|
|
94
96
|
//
|
|
95
97
|
// History
|
|
@@ -154,12 +156,12 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
|
|
|
154
156
|
}}
|
|
155
157
|
>
|
|
156
158
|
{moves.map(([a, b], index) => (
|
|
157
|
-
<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'>
|
|
158
160
|
<div className='content-center text-xs text-subdued'>{index + 1}</div>
|
|
159
161
|
{a && (
|
|
160
162
|
<div
|
|
161
163
|
data-index={a.index}
|
|
162
|
-
className={mx('
|
|
164
|
+
className={mx('ps-2 cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}
|
|
163
165
|
onClick={() => onSelect?.(a.index + 1)}
|
|
164
166
|
>
|
|
165
167
|
{a.move}
|
|
@@ -168,7 +170,7 @@ const History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {
|
|
|
168
170
|
{b && (
|
|
169
171
|
<div
|
|
170
172
|
data-index={b.index}
|
|
171
|
-
className={mx('
|
|
173
|
+
className={mx('ps-2 cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}
|
|
172
174
|
onClick={() => onSelect?.(b.index + 1)}
|
|
173
175
|
>
|
|
174
176
|
{b.move}
|
|
@@ -194,12 +196,12 @@ type PlayerIndicatorProps = PropsWithChildren<{
|
|
|
194
196
|
const PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {
|
|
195
197
|
const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');
|
|
196
198
|
return (
|
|
197
|
-
<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'>
|
|
198
200
|
<div className='place-items-center'>
|
|
199
201
|
<Icon
|
|
200
202
|
icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
|
|
201
203
|
size={6}
|
|
202
|
-
classNames={mx(turn && (model.game.isCheckmate() ? 'text-
|
|
204
|
+
classNames={mx(turn && (model.game.isCheckmate() ? 'text-error-500' : 'text-success-text'))}
|
|
203
205
|
/>
|
|
204
206
|
</div>
|
|
205
207
|
<div className='truncate overflow-hidden items-center'>{children}</div>
|
|
@@ -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
|
+
}
|