@dxos/plugin-chess 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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-LWRZPLQL.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-LWRZPLQL.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +4 -4
- 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-FO4ZNFN6.mjs → chunk-VK2W2UDJ.mjs} +44 -42
- package/dist/lib/browser/chunk-VK2W2UDJ.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/{chunk-66H3V2YV.mjs → chunk-YJ2NLHEY.mjs} +3 -3
- package/dist/lib/browser/{chunk-66H3V2YV.mjs.map → chunk-YJ2NLHEY.mjs.map} +1 -1
- 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 +21 -26
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-M7QMAFTB.mjs +50 -0
- package/dist/lib/browser/react-surface-M7QMAFTB.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-CJZXRDEQ.mjs} +7 -7
- package/dist/lib/node-esm/blueprint-definition-CJZXRDEQ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +4 -4
- 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-C7IWIXCJ.mjs → chunk-G3QQRYZC.mjs} +44 -42
- package/dist/lib/node-esm/chunk-G3QQRYZC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OUNGNJFP.mjs → chunk-J6AJLY2O.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-OUNGNJFP.mjs.map → chunk-J6AJLY2O.mjs.map} +1 -1
- 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 +21 -26
- 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-DKM6ICBU.mjs +51 -0
- package/dist/lib/node-esm/react-surface-DKM6ICBU.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/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -44
- package/src/ChessPlugin.tsx +8 -8
- 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 +2 -2
- 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-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-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.6fa680abb7",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"browser": "./dist/lib/browser/index.mjs",
|
|
18
|
-
"node": "./dist/lib/node-esm/index.mjs",
|
|
19
17
|
"source": "./src/index.ts",
|
|
20
|
-
"types": "./dist/types/src/index.d.ts"
|
|
18
|
+
"types": "./dist/types/src/index.d.ts",
|
|
19
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
20
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
21
21
|
},
|
|
22
22
|
"./blueprints": {
|
|
23
|
-
"browser": "./dist/lib/browser/blueprints/index.mjs",
|
|
24
|
-
"node": "./dist/lib/node-esm/blueprints/index.mjs",
|
|
25
23
|
"source": "./src/blueprints/index.ts",
|
|
26
|
-
"types": "./dist/types/src/blueprints/index.d.ts"
|
|
24
|
+
"types": "./dist/types/src/blueprints/index.d.ts",
|
|
25
|
+
"browser": "./dist/lib/browser/blueprints/index.mjs",
|
|
26
|
+
"node": "./dist/lib/node-esm/blueprints/index.mjs"
|
|
27
27
|
},
|
|
28
28
|
"./cli": {
|
|
29
29
|
"source": "./src/cli/index.ts",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"node": "./dist/lib/node-esm/cli/index.mjs"
|
|
33
33
|
},
|
|
34
34
|
"./types": {
|
|
35
|
-
"browser": "./dist/lib/browser/types/index.mjs",
|
|
36
|
-
"node": "./dist/lib/node-esm/types/index.mjs",
|
|
37
35
|
"source": "./src/types/index.ts",
|
|
38
|
-
"types": "./dist/types/src/types/index.d.ts"
|
|
36
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
37
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
38
|
+
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -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/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/echo
|
|
66
|
-
"@dxos/echo-
|
|
67
|
-
"@dxos/functions": "0.8.4-main.
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/operation": "0.8.4-main.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
73
|
-
"@dxos/plugin-
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/react-ui-
|
|
77
|
-
"@dxos/react-ui-
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
57
|
+
"effect": "3.19.16",
|
|
58
|
+
"@dxos/ai": "0.8.4-main.6fa680abb7",
|
|
59
|
+
"@dxos/app-framework": "0.8.4-main.6fa680abb7",
|
|
60
|
+
"@dxos/assistant": "0.8.4-main.6fa680abb7",
|
|
61
|
+
"@dxos/app-toolkit": "0.8.4-main.6fa680abb7",
|
|
62
|
+
"@dxos/async": "0.8.4-main.6fa680abb7",
|
|
63
|
+
"@dxos/display-name": "0.8.4-main.6fa680abb7",
|
|
64
|
+
"@dxos/blueprints": "0.8.4-main.6fa680abb7",
|
|
65
|
+
"@dxos/echo": "0.8.4-main.6fa680abb7",
|
|
66
|
+
"@dxos/echo-db": "0.8.4-main.6fa680abb7",
|
|
67
|
+
"@dxos/functions": "0.8.4-main.6fa680abb7",
|
|
68
|
+
"@dxos/invariant": "0.8.4-main.6fa680abb7",
|
|
69
|
+
"@dxos/log": "0.8.4-main.6fa680abb7",
|
|
70
|
+
"@dxos/operation": "0.8.4-main.6fa680abb7",
|
|
71
|
+
"@dxos/echo-react": "0.8.4-main.6fa680abb7",
|
|
72
|
+
"@dxos/plugin-client": "0.8.4-main.6fa680abb7",
|
|
73
|
+
"@dxos/plugin-graph": "0.8.4-main.6fa680abb7",
|
|
74
|
+
"@dxos/plugin-space": "0.8.4-main.6fa680abb7",
|
|
75
|
+
"@dxos/plugin-markdown": "0.8.4-main.6fa680abb7",
|
|
76
|
+
"@dxos/react-ui-gameboard": "0.8.4-main.6fa680abb7",
|
|
77
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.6fa680abb7",
|
|
78
|
+
"@dxos/react-client": "0.8.4-main.6fa680abb7",
|
|
79
|
+
"@dxos/react-ui-sfx": "0.8.4-main.6fa680abb7",
|
|
80
|
+
"@dxos/react-ui-stack": "0.8.4-main.6fa680abb7",
|
|
81
|
+
"@dxos/schema": "0.8.4-main.6fa680abb7",
|
|
82
|
+
"@dxos/util": "0.8.4-main.6fa680abb7",
|
|
83
|
+
"@dxos/types": "0.8.4-main.6fa680abb7"
|
|
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/plugin-theme": "0.8.4-main.
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
90
|
+
"vite": "^7.1.11",
|
|
91
|
+
"@dxos/plugin-theme": "0.8.4-main.6fa680abb7",
|
|
92
|
+
"@dxos/react-ui": "0.8.4-main.6fa680abb7",
|
|
93
|
+
"@dxos/storybook-utils": "0.8.4-main.6fa680abb7",
|
|
94
|
+
"@dxos/ui-theme": "0.8.4-main.6fa680abb7"
|
|
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.6fa680abb7",
|
|
100
|
+
"@dxos/ui-theme": "0.8.4-main.6fa680abb7"
|
|
100
101
|
},
|
|
101
102
|
"publishConfig": {
|
|
102
103
|
"access": "public"
|
package/src/ChessPlugin.tsx
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 { ChessBlueprint } from './blueprints';
|
|
@@ -14,21 +15,20 @@ import { translations } from './translations';
|
|
|
14
15
|
import { Chess } from './types';
|
|
15
16
|
|
|
16
17
|
export const ChessPlugin = Plugin.define(meta).pipe(
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),
|
|
19
|
+
AppPlugin.addMetadataModule({
|
|
19
20
|
metadata: {
|
|
20
21
|
id: Chess.Game.typename,
|
|
21
22
|
metadata: {
|
|
22
23
|
icon: 'ph--shield-chevron--regular',
|
|
23
24
|
iconHue: 'amber',
|
|
24
|
-
blueprints: [ChessBlueprint.
|
|
25
|
+
blueprints: [ChessBlueprint.key],
|
|
25
26
|
createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,
|
|
26
|
-
addToCollectionOnCreate: true,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
31
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
32
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
33
33
|
Plugin.make,
|
|
34
34
|
);
|
|
@@ -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
|