@dxos/plugin-chess 0.8.4-main.fd6878d → 0.8.4-main.fffef41
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/{ChessboardContainer-NNIOQIRP.mjs → ChessboardContainer-5YXEM4VR.mjs} +29 -23
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs.map +7 -0
- package/dist/lib/browser/chunk-5DOZV3PW.mjs +294 -0
- package/dist/lib/browser/chunk-5DOZV3PW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PE3IWOFR.mjs → chunk-DUO4WTAM.mjs} +5 -5
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OBJAHY6H.mjs → chunk-FBLAVAMY.mjs} +17 -12
- package/dist/lib/browser/chunk-FBLAVAMY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PPBBLHAC.mjs → chunk-Q5TZCIH7.mjs} +2 -2
- package/dist/lib/browser/chunk-TIIGNOGK.mjs +169 -0
- package/dist/lib/browser/chunk-TIIGNOGK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +27 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-JWKKRNGG.mjs → intent-resolver-GXZN2EBT.mjs} +5 -5
- package/dist/lib/browser/{intent-resolver-JWKKRNGG.mjs.map → intent-resolver-GXZN2EBT.mjs.map} +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-RIXD6RTS.mjs → react-surface-KTTAUHAA.mjs} +7 -7
- package/dist/lib/browser/{react-surface-RIXD6RTS.mjs.map → react-surface-KTTAUHAA.mjs.map} +1 -1
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{ChessboardContainer-FCPUV2T2.mjs → ChessboardContainer-7OQ6TOKB.mjs} +29 -23
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs +12 -0
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs +295 -0
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-6OWCPDUA.mjs → chunk-KNOOJFIR.mjs} +5 -5
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LCCUF5X5.mjs → chunk-MP3A3AGA.mjs} +17 -12
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs +170 -0
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-42EKKMOO.mjs → chunk-VVXTAVIS.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +27 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-G6XJAW6C.mjs → intent-resolver-HK5L6P6Z.mjs} +5 -5
- package/dist/lib/node-esm/{intent-resolver-G6XJAW6C.mjs.map → intent-resolver-HK5L6P6Z.mjs.map} +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-GGRDWZJT.mjs → react-surface-VO4PSY6O.mjs} +7 -7
- package/dist/lib/node-esm/{react-surface-GGRDWZJT.mjs.map → react-surface-VO4PSY6O.mjs.map} +1 -1
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/ChessPlugin.d.ts +1 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +4 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/Card.stories.d.ts +14 -41
- package/dist/types/src/components/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard.d.ts +19 -13
- package/dist/types/src/components/Chessboard.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +41 -39
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +2 -1
- package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -1
- package/dist/types/src/components/{ChessboardInfo.d.ts → Info.d.ts} +7 -6
- package/dist/types/src/components/Info.d.ts.map +1 -0
- package/dist/types/src/functions/create.d.ts +14 -0
- package/dist/types/src/functions/create.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +1 -0
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/functions/move.d.ts +3 -1
- package/dist/types/src/functions/move.d.ts.map +1 -1
- package/dist/types/src/functions/play.d.ts +2 -1
- package/dist/types/src/functions/play.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +8 -5
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/ChessAction.d.ts +3 -2
- package/dist/types/src/types/ChessAction.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -35
- package/src/ChessPlugin.tsx +47 -46
- package/src/capabilities/artifact-definition.ts +3 -2
- package/src/capabilities/blueprint-definition.ts +9 -7
- package/src/capabilities/index.ts +2 -0
- package/src/components/Card.stories.tsx +13 -15
- package/src/components/Chessboard.stories.tsx +13 -14
- package/src/components/Chessboard.tsx +104 -28
- package/src/components/ChessboardArticle.tsx +32 -21
- package/src/components/ChessboardContainer.tsx +1 -1
- package/src/components/Info.tsx +236 -0
- package/src/functions/create.ts +32 -0
- package/src/functions/index.ts +1 -0
- package/src/functions/move.ts +16 -14
- package/src/functions/play.ts +25 -15
- package/src/meta.ts +4 -4
- package/src/translations.ts +8 -6
- package/src/types/Chess.ts +23 -19
- package/src/types/ChessAction.ts +1 -1
- package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs +0 -38
- package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-2W3S5N6C.mjs +0 -257
- package/dist/lib/browser/chunk-2W3S5N6C.mjs.map +0 -7
- package/dist/lib/browser/chunk-EJMPHRSR.mjs +0 -94
- package/dist/lib/browser/chunk-EJMPHRSR.mjs.map +0 -7
- package/dist/lib/browser/chunk-OBJAHY6H.mjs.map +0 -7
- package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs +0 -39
- package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5APYXPBX.mjs +0 -95
- package/dist/lib/node-esm/chunk-5APYXPBX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LCCUF5X5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QAGOXJGH.mjs +0 -258
- package/dist/lib/node-esm/chunk-QAGOXJGH.mjs.map +0 -7
- package/dist/types/src/components/ChessboardInfo.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardPlayers.d.ts +0 -8
- package/dist/types/src/components/ChessboardPlayers.d.ts.map +0 -1
- package/src/components/ChessboardInfo.tsx +0 -140
- package/src/components/ChessboardPlayers.tsx +0 -97
- /package/dist/lib/browser/{chunk-PPBBLHAC.mjs.map → chunk-Q5TZCIH7.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-42EKKMOO.mjs.map → chunk-VVXTAVIS.mjs.map} +0 -0
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.fffef41",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
"types": "./dist/types/src/types/index.d.ts",
|
|
21
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
22
22
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./functions": {
|
|
25
|
+
"source": "./src/functions/index.ts",
|
|
26
|
+
"types": "./dist/types/src/functions/index.d.ts",
|
|
27
|
+
"browser": "./dist/lib/browser/functions/index.mjs",
|
|
28
|
+
"node": "./dist/lib/node-esm/functions/index.mjs"
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
31
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -36,45 +42,46 @@
|
|
|
36
42
|
],
|
|
37
43
|
"dependencies": {
|
|
38
44
|
"@preact-signals/safe-react": "^0.9.0",
|
|
39
|
-
"@preact/signals-core": "^1.
|
|
45
|
+
"@preact/signals-core": "^1.12.1",
|
|
40
46
|
"chess.js": "^1.0.0",
|
|
41
|
-
"effect": "3.
|
|
42
|
-
"@dxos/ai": "0.8.4-main.
|
|
43
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
44
|
-
"@dxos/assistant": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/blueprints": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/plugin-
|
|
55
|
-
"@dxos/plugin-
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/react-ui-
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
47
|
+
"effect": "3.18.3",
|
|
48
|
+
"@dxos/ai": "0.8.4-main.fffef41",
|
|
49
|
+
"@dxos/app-framework": "0.8.4-main.fffef41",
|
|
50
|
+
"@dxos/assistant": "0.8.4-main.fffef41",
|
|
51
|
+
"@dxos/display-name": "0.8.4-main.fffef41",
|
|
52
|
+
"@dxos/blueprints": "0.8.4-main.fffef41",
|
|
53
|
+
"@dxos/echo": "0.8.4-main.fffef41",
|
|
54
|
+
"@dxos/functions": "0.8.4-main.fffef41",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.fffef41",
|
|
56
|
+
"@dxos/log": "0.8.4-main.fffef41",
|
|
57
|
+
"@dxos/plugin-client": "0.8.4-main.fffef41",
|
|
58
|
+
"@dxos/async": "0.8.4-main.fffef41",
|
|
59
|
+
"@dxos/live-object": "0.8.4-main.fffef41",
|
|
60
|
+
"@dxos/plugin-graph": "0.8.4-main.fffef41",
|
|
61
|
+
"@dxos/plugin-space": "0.8.4-main.fffef41",
|
|
62
|
+
"@dxos/react-client": "0.8.4-main.fffef41",
|
|
63
|
+
"@dxos/react-ui-sfx": "0.8.4-main.fffef41",
|
|
64
|
+
"@dxos/react-ui-stack": "0.8.4-main.fffef41",
|
|
65
|
+
"@dxos/schema": "0.8.4-main.fffef41",
|
|
66
|
+
"@dxos/util": "0.8.4-main.fffef41",
|
|
67
|
+
"@dxos/react-ui-gameboard": "0.8.4-main.fffef41"
|
|
61
68
|
},
|
|
62
69
|
"devDependencies": {
|
|
63
|
-
"@types/react": "~
|
|
64
|
-
"@types/react-dom": "~
|
|
65
|
-
"react": "~
|
|
66
|
-
"react-dom": "~
|
|
67
|
-
"vite": "
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
71
|
-
"@dxos/
|
|
70
|
+
"@types/react": "~19.2.2",
|
|
71
|
+
"@types/react-dom": "~19.2.2",
|
|
72
|
+
"react": "~19.2.0",
|
|
73
|
+
"react-dom": "~19.2.0",
|
|
74
|
+
"vite": "7.1.9",
|
|
75
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.fffef41",
|
|
77
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41",
|
|
78
|
+
"@dxos/plugin-theme": "0.8.4-main.fffef41"
|
|
72
79
|
},
|
|
73
80
|
"peerDependencies": {
|
|
74
|
-
"react": "
|
|
75
|
-
"react-dom": "
|
|
76
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
77
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
81
|
+
"react": "^19.0.0",
|
|
82
|
+
"react-dom": "^19.0.0",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.fffef41",
|
|
84
|
+
"@dxos/react-ui-theme": "0.8.4-main.fffef41"
|
|
78
85
|
},
|
|
79
86
|
"publishConfig": {
|
|
80
87
|
"access": "public"
|
package/src/ChessPlugin.tsx
CHANGED
|
@@ -7,54 +7,55 @@ import { ClientEvents } from '@dxos/plugin-client';
|
|
|
7
7
|
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
8
|
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
9
9
|
|
|
10
|
-
import { BlueprintDefinition, IntentResolver, ReactSurface } from './capabilities';
|
|
10
|
+
import { BlueprintDefinition, CHESS_BLUEPRINT_KEY, IntentResolver, ReactSurface } from './capabilities';
|
|
11
11
|
import { meta } from './meta';
|
|
12
12
|
import { translations } from './translations';
|
|
13
13
|
import { Chess, ChessAction } from './types';
|
|
14
14
|
|
|
15
|
-
export const ChessPlugin = () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
export const ChessPlugin = definePlugin(meta, () => [
|
|
16
|
+
defineModule({
|
|
17
|
+
id: `${meta.id}/module/translations`,
|
|
18
|
+
activatesOn: Events.SetupTranslations,
|
|
19
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
20
|
+
}),
|
|
21
|
+
defineModule({
|
|
22
|
+
id: `${meta.id}/module/metadata`,
|
|
23
|
+
activatesOn: Events.SetupMetadata,
|
|
24
|
+
activate: () =>
|
|
25
|
+
contributes(Capabilities.Metadata, {
|
|
26
|
+
id: Chess.Game.typename,
|
|
27
|
+
metadata: {
|
|
28
|
+
icon: 'ph--shield-chevron--regular',
|
|
29
|
+
iconHue: 'amber',
|
|
30
|
+
blueprints: [CHESS_BLUEPRINT_KEY],
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
defineModule({
|
|
35
|
+
id: `${meta.id}/module/object-form`,
|
|
36
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
37
|
+
activate: () =>
|
|
38
|
+
contributes(
|
|
39
|
+
SpaceCapabilities.ObjectForm,
|
|
40
|
+
defineObjectForm({
|
|
41
|
+
objectSchema: Chess.Game,
|
|
42
|
+
getIntent: () => createIntent(ChessAction.Create),
|
|
31
43
|
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
defineModule({
|
|
51
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
52
|
-
activatesOn: Events.SetupIntentResolver,
|
|
53
|
-
activate: IntentResolver,
|
|
54
|
-
}),
|
|
55
|
-
defineModule({
|
|
56
|
-
id: `${meta.id}/module/blueprint`,
|
|
57
|
-
activatesOn: Events.SetupArtifactDefinition,
|
|
58
|
-
activate: BlueprintDefinition,
|
|
59
|
-
}),
|
|
60
|
-
]);
|
|
44
|
+
),
|
|
45
|
+
}),
|
|
46
|
+
defineModule({
|
|
47
|
+
id: `${meta.id}/module/react-surface`,
|
|
48
|
+
activatesOn: Events.SetupReactSurface,
|
|
49
|
+
activate: ReactSurface,
|
|
50
|
+
}),
|
|
51
|
+
defineModule({
|
|
52
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
53
|
+
activatesOn: Events.SetupIntentResolver,
|
|
54
|
+
activate: IntentResolver,
|
|
55
|
+
}),
|
|
56
|
+
defineModule({
|
|
57
|
+
id: `${meta.id}/module/blueprint`,
|
|
58
|
+
activatesOn: Events.SetupArtifactDefinition,
|
|
59
|
+
activate: BlueprintDefinition,
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// @ts-nocheck
|
|
7
7
|
|
|
8
8
|
import { Chess as ChessJS } from 'chess.js';
|
|
9
|
-
import
|
|
9
|
+
import * as Function from 'effect/Function';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
10
11
|
|
|
11
12
|
import { ToolResult, createTool } from '@dxos/ai';
|
|
12
13
|
import { Capabilities, type PromiseIntentDispatcher, chain, contributes, createIntent } from '@dxos/app-framework';
|
|
@@ -50,7 +51,7 @@ export default () => {
|
|
|
50
51
|
execute: async ({ pgn }, { extensions }) => {
|
|
51
52
|
invariant(extensions?.space, 'No space');
|
|
52
53
|
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
53
|
-
const intent = pipe(
|
|
54
|
+
const intent = Function.pipe(
|
|
54
55
|
createIntent(ChessAction.Create, { pgn }),
|
|
55
56
|
chain(SpaceAction.AddObject, { target: extensions.space }),
|
|
56
57
|
);
|
|
@@ -2,33 +2,35 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { ToolId } from '@dxos/ai';
|
|
6
5
|
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
7
6
|
import { Blueprint, Template } from '@dxos/blueprints';
|
|
7
|
+
import { type FunctionDefinition } from '@dxos/functions';
|
|
8
8
|
import { trim } from '@dxos/util';
|
|
9
9
|
|
|
10
|
-
import { move, play } from '../functions';
|
|
10
|
+
import { create, move, play } from '../functions';
|
|
11
11
|
|
|
12
|
-
const functions = [move, play];
|
|
12
|
+
const functions: FunctionDefinition[] = [create, move, play];
|
|
13
|
+
|
|
14
|
+
export const CHESS_BLUEPRINT_KEY = 'dxos.org/blueprint/chess';
|
|
13
15
|
|
|
14
16
|
export default () => {
|
|
15
17
|
return [
|
|
18
|
+
contributes(Capabilities.Functions, functions),
|
|
16
19
|
contributes(
|
|
17
20
|
Capabilities.BlueprintDefinition,
|
|
18
21
|
Blueprint.make({
|
|
19
|
-
key:
|
|
22
|
+
key: CHESS_BLUEPRINT_KEY,
|
|
20
23
|
name: 'Chess',
|
|
24
|
+
tools: Blueprint.toolDefinitions({ functions }),
|
|
21
25
|
instructions: Template.make({
|
|
22
26
|
source: trim`
|
|
23
27
|
You are an expert chess player.
|
|
28
|
+
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
24
29
|
You could suggest a good next move or offer to play a move.
|
|
25
30
|
Don't actually make a move unless you are asked to.
|
|
26
|
-
To analyze a game you can retrieve the "pgn" property from the context object.
|
|
27
31
|
`,
|
|
28
32
|
}),
|
|
29
|
-
tools: functions.map((tool) => ToolId.make(tool.name)),
|
|
30
33
|
}),
|
|
31
34
|
),
|
|
32
|
-
contributes(Capabilities.Functions, functions),
|
|
33
35
|
];
|
|
34
36
|
};
|
|
@@ -7,3 +7,5 @@ import { lazy } from '@dxos/app-framework';
|
|
|
7
7
|
export const BlueprintDefinition = lazy(() => import('./blueprint-definition'));
|
|
8
8
|
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
9
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
10
|
+
|
|
11
|
+
export * from './blueprint-definition';
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
9
|
import { CardContainer } from '@dxos/react-ui-stack/testing';
|
|
11
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
12
10
|
|
|
13
|
-
import { meta } from '../meta';
|
|
11
|
+
import { meta as pluginMeta } from '../meta';
|
|
14
12
|
import { Chess } from '../types';
|
|
15
13
|
|
|
16
14
|
import { Chessboard } from './Chessboard';
|
|
@@ -20,10 +18,10 @@ type DefaultStoryProps = {
|
|
|
20
18
|
game: Chess.Game;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
const
|
|
21
|
+
const meta = {
|
|
24
22
|
title: 'plugins/plugin-chess/Card',
|
|
25
23
|
render: ({ role, game }) => (
|
|
26
|
-
<CardContainer icon={
|
|
24
|
+
<CardContainer icon={pluginMeta.icon} role={role}>
|
|
27
25
|
<Chessboard.Root game={game}>
|
|
28
26
|
<Chessboard.Content role={role}>
|
|
29
27
|
<Chessboard.Board />
|
|
@@ -36,33 +34,33 @@ const storybook: Meta<DefaultStoryProps> = {
|
|
|
36
34
|
layout: 'centered',
|
|
37
35
|
},
|
|
38
36
|
tags: ['cards'],
|
|
39
|
-
}
|
|
37
|
+
} satisfies Meta<DefaultStoryProps>;
|
|
40
38
|
|
|
41
|
-
export default
|
|
39
|
+
export default meta;
|
|
42
40
|
|
|
43
41
|
const game = Chess.makeGame({
|
|
44
42
|
pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *',
|
|
45
43
|
});
|
|
46
44
|
|
|
47
|
-
type Story = StoryObj<
|
|
45
|
+
type Story = StoryObj<typeof meta>;
|
|
48
46
|
|
|
49
|
-
export const Popover = {
|
|
47
|
+
export const Popover: Story = {
|
|
50
48
|
args: {
|
|
51
49
|
role: 'card--popover',
|
|
52
50
|
game: game,
|
|
53
51
|
},
|
|
54
|
-
}
|
|
52
|
+
};
|
|
55
53
|
|
|
56
|
-
export const Intrinsic = {
|
|
54
|
+
export const Intrinsic: Story = {
|
|
57
55
|
args: {
|
|
58
56
|
role: 'card--intrinsic',
|
|
59
57
|
game: game,
|
|
60
58
|
},
|
|
61
|
-
}
|
|
59
|
+
};
|
|
62
60
|
|
|
63
|
-
export const Extrinsic = {
|
|
61
|
+
export const Extrinsic: Story = {
|
|
64
62
|
args: {
|
|
65
63
|
role: 'card--extrinsic',
|
|
66
64
|
game: game,
|
|
67
65
|
},
|
|
68
|
-
}
|
|
66
|
+
};
|
|
@@ -2,49 +2,48 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
|
|
9
7
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
10
|
import { translations } from '../translations';
|
|
13
11
|
import { Chess } from '../types';
|
|
14
12
|
|
|
15
13
|
import { ChessboardArticle } from './ChessboardArticle';
|
|
16
14
|
|
|
17
|
-
const meta
|
|
15
|
+
const meta = {
|
|
18
16
|
title: 'plugins/plugin-chess/Chessboard',
|
|
19
17
|
component: ChessboardArticle,
|
|
20
|
-
decorators: [
|
|
18
|
+
decorators: [withTheme, withClientProvider({ createIdentity: true })],
|
|
21
19
|
parameters: {
|
|
20
|
+
layout: 'fullscreen',
|
|
22
21
|
translations,
|
|
23
22
|
},
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
+
} satisfies Meta<typeof ChessboardArticle>;
|
|
27
24
|
|
|
28
25
|
export default meta;
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
31
30
|
args: {
|
|
32
31
|
game: Chess.makeGame(),
|
|
33
32
|
},
|
|
34
|
-
}
|
|
33
|
+
};
|
|
35
34
|
|
|
36
|
-
export const EndGame = {
|
|
35
|
+
export const EndGame: Story = {
|
|
37
36
|
args: {
|
|
38
37
|
game: Chess.makeGame({
|
|
39
38
|
pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 *',
|
|
40
39
|
}),
|
|
41
40
|
},
|
|
42
|
-
}
|
|
41
|
+
};
|
|
43
42
|
|
|
44
|
-
export const Promption = {
|
|
43
|
+
export const Promption: Story = {
|
|
45
44
|
args: {
|
|
46
45
|
game: Chess.makeGame({
|
|
47
46
|
pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *',
|
|
48
47
|
}),
|
|
49
48
|
},
|
|
50
|
-
}
|
|
49
|
+
};
|
|
@@ -2,23 +2,37 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import React, {
|
|
6
|
+
type PropsWithChildren,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useCallback,
|
|
9
|
+
useEffect,
|
|
10
|
+
useImperativeHandle,
|
|
11
|
+
useMemo,
|
|
12
|
+
useRef,
|
|
13
|
+
} from 'react';
|
|
14
|
+
|
|
15
|
+
import { addEventListener } from '@dxos/async';
|
|
8
16
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
17
|
import {
|
|
10
18
|
ChessModel,
|
|
11
19
|
Gameboard,
|
|
12
20
|
type GameboardRootProps,
|
|
13
|
-
Chessboard as
|
|
14
|
-
type ChessboardProps as
|
|
21
|
+
Chessboard as NaturalChessboard,
|
|
22
|
+
type ChessboardProps as NaturalChessboardProps,
|
|
23
|
+
getRawPgn,
|
|
24
|
+
useGameboardContext,
|
|
15
25
|
} from '@dxos/react-ui-gameboard';
|
|
26
|
+
import { useSoundEffect } from '@dxos/react-ui-sfx';
|
|
16
27
|
import { mx } from '@dxos/react-ui-theme';
|
|
17
28
|
|
|
18
29
|
import { type Chess } from '../types';
|
|
19
30
|
|
|
20
|
-
import {
|
|
21
|
-
|
|
31
|
+
import { Info, type InfoProps } from './Info';
|
|
32
|
+
|
|
33
|
+
export interface ChessboardController {
|
|
34
|
+
setMoveNumber(index: number): void;
|
|
35
|
+
}
|
|
22
36
|
|
|
23
37
|
export class ExtendedChessModel extends ChessModel {
|
|
24
38
|
constructor(readonly object: Chess.Game) {
|
|
@@ -30,25 +44,43 @@ export class ExtendedChessModel extends ChessModel {
|
|
|
30
44
|
// Root
|
|
31
45
|
//
|
|
32
46
|
|
|
33
|
-
type
|
|
47
|
+
type RootProps = PropsWithChildren<{
|
|
34
48
|
game: Chess.Game;
|
|
35
49
|
}>;
|
|
36
50
|
|
|
37
|
-
const
|
|
51
|
+
const Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {
|
|
38
52
|
const model = useMemo(() => new ExtendedChessModel(game), []);
|
|
53
|
+
const click = useSoundEffect('Click');
|
|
54
|
+
|
|
55
|
+
// Controller.
|
|
56
|
+
useImperativeHandle(forwardedRef, () => {
|
|
57
|
+
return {
|
|
58
|
+
setMoveNumber: (index) => model.setMoveIndex(index),
|
|
59
|
+
};
|
|
60
|
+
}, [model]);
|
|
61
|
+
|
|
62
|
+
// External change.
|
|
63
|
+
// NOTE: Warning if user has not interacted with the board.
|
|
39
64
|
useEffect(() => {
|
|
40
|
-
model.
|
|
41
|
-
|
|
65
|
+
if (model.pgn !== getRawPgn(game.pgn ?? '')) {
|
|
66
|
+
const silent = model.pgn === '*';
|
|
67
|
+
model.update(game.pgn);
|
|
68
|
+
if (!silent) {
|
|
69
|
+
void click.play();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
42
72
|
}, [game.pgn]);
|
|
43
73
|
|
|
74
|
+
// Move.
|
|
44
75
|
const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
|
|
45
76
|
(move) => {
|
|
46
|
-
if (model.makeMove(move)) {
|
|
47
|
-
|
|
48
|
-
return true;
|
|
77
|
+
if (!model.makeMove(move)) {
|
|
78
|
+
return false;
|
|
49
79
|
}
|
|
50
80
|
|
|
51
|
-
|
|
81
|
+
void click.play();
|
|
82
|
+
game.pgn = model.pgn;
|
|
83
|
+
return true;
|
|
52
84
|
},
|
|
53
85
|
[model],
|
|
54
86
|
);
|
|
@@ -58,7 +90,7 @@ const ChessboardRoot = ({ game, children }: ChessboardRootProps) => {
|
|
|
58
90
|
{children}
|
|
59
91
|
</Gameboard.Root>
|
|
60
92
|
);
|
|
61
|
-
};
|
|
93
|
+
});
|
|
62
94
|
|
|
63
95
|
//
|
|
64
96
|
// Content
|
|
@@ -66,9 +98,9 @@ const ChessboardRoot = ({ game, children }: ChessboardRootProps) => {
|
|
|
66
98
|
|
|
67
99
|
type Role = 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
|
|
68
100
|
|
|
69
|
-
type
|
|
101
|
+
type ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;
|
|
70
102
|
|
|
71
|
-
const
|
|
103
|
+
const Content = ({ classNames, children, role }: ContentProps) => {
|
|
72
104
|
return (
|
|
73
105
|
<Gameboard.Content
|
|
74
106
|
classNames={mx(classNames, role === 'card--popover' && 'size-container popover-square')}
|
|
@@ -80,22 +112,66 @@ const ChessboardContent = ({ classNames, children, role }: ChessboardContentProp
|
|
|
80
112
|
);
|
|
81
113
|
};
|
|
82
114
|
|
|
115
|
+
//
|
|
116
|
+
// Board
|
|
117
|
+
//
|
|
118
|
+
|
|
119
|
+
type BoardProps = NaturalChessboardProps;
|
|
120
|
+
|
|
121
|
+
const Board = (props: BoardProps) => {
|
|
122
|
+
const { model } = useGameboardContext<ChessModel>(Board.displayName);
|
|
123
|
+
|
|
124
|
+
// Keyboard navigation.
|
|
125
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!ref.current) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Participate in keyboard navigation (set tabIndex={0})
|
|
132
|
+
ref.current.setAttribute('data-arrow-keys', 'all');
|
|
133
|
+
|
|
134
|
+
return addEventListener(ref.current, 'keydown', (ev) => {
|
|
135
|
+
switch (ev.key) {
|
|
136
|
+
case 'ArrowUp':
|
|
137
|
+
model.setMoveIndex(0);
|
|
138
|
+
break;
|
|
139
|
+
case 'ArrowDown':
|
|
140
|
+
model.setMoveIndex(model.game.history().length);
|
|
141
|
+
break;
|
|
142
|
+
case 'ArrowLeft':
|
|
143
|
+
if (model.moveIndex.value > 0) {
|
|
144
|
+
model.setMoveIndex(model.moveIndex.value - 1);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case 'ArrowRight':
|
|
148
|
+
if (model.moveIndex.value < model.game.history().length) {
|
|
149
|
+
model.setMoveIndex(model.moveIndex.value + 1);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}, [model]);
|
|
155
|
+
|
|
156
|
+
return <NaturalChessboard ref={ref} {...props} />;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
Board.displayName = 'Chessboard.Board';
|
|
160
|
+
|
|
83
161
|
//
|
|
84
162
|
// Chessboard
|
|
85
163
|
//
|
|
86
164
|
|
|
87
165
|
export const Chessboard = {
|
|
88
|
-
Root:
|
|
89
|
-
Content:
|
|
90
|
-
Board:
|
|
91
|
-
Info:
|
|
92
|
-
Players: ChessboardPlayers,
|
|
166
|
+
Root: Root,
|
|
167
|
+
Content: Content,
|
|
168
|
+
Board: Board,
|
|
169
|
+
Info: Info,
|
|
93
170
|
};
|
|
94
171
|
|
|
95
172
|
export type {
|
|
96
|
-
ChessboardRootProps,
|
|
97
|
-
ChessboardContentProps,
|
|
98
|
-
|
|
99
|
-
ChessboardInfoProps,
|
|
100
|
-
ChessboardPlayersProps,
|
|
173
|
+
RootProps as ChessboardRootProps,
|
|
174
|
+
ContentProps as ChessboardContentProps,
|
|
175
|
+
BoardProps as ChessboardBoardProps,
|
|
176
|
+
InfoProps as ChessboardInfoProps,
|
|
101
177
|
};
|