@dxos/plugin-chess 0.7.4 → 0.7.5-labs.071a3e2
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/ChessContainer-2MMUB5S7.mjs +86 -0
- package/dist/lib/browser/ChessContainer-2MMUB5S7.mjs.map +7 -0
- package/dist/lib/browser/artifact-LGQPNR6M.mjs +174 -0
- package/dist/lib/browser/artifact-LGQPNR6M.mjs.map +7 -0
- package/dist/lib/browser/chunk-672NU6IC.mjs +8 -0
- package/dist/lib/browser/chunk-672NU6IC.mjs.map +7 -0
- package/dist/lib/browser/chunk-GKM6RRDX.mjs +69 -0
- package/dist/lib/browser/chunk-GKM6RRDX.mjs.map +7 -0
- package/dist/lib/browser/chunk-RGPTBDH7.mjs +41 -0
- package/dist/lib/browser/chunk-RGPTBDH7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +68 -623
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-VPK5QRXH.mjs +28 -0
- package/dist/lib/browser/intent-resolver-VPK5QRXH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-ZILDX6DE.mjs +42 -0
- package/dist/lib/browser/react-surface-ZILDX6DE.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -4
- package/dist/lib/node/ChessContainer-CMYJDMSG.cjs +108 -0
- package/dist/lib/node/ChessContainer-CMYJDMSG.cjs.map +7 -0
- package/dist/lib/node/artifact-IKDPRF5X.cjs +189 -0
- package/dist/lib/node/artifact-IKDPRF5X.cjs.map +7 -0
- package/dist/lib/node/chunk-3TTH3HKL.cjs +90 -0
- package/dist/lib/node/chunk-3TTH3HKL.cjs.map +7 -0
- package/dist/lib/node/chunk-TEZPML34.cjs +40 -0
- package/dist/lib/node/chunk-TEZPML34.cjs.map +7 -0
- package/dist/lib/node/chunk-YTD6SK5V.cjs +73 -0
- package/dist/lib/node/chunk-YTD6SK5V.cjs.map +7 -0
- package/dist/lib/node/index.cjs +67 -599
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-PUM2BVGU.cjs +43 -0
- package/dist/lib/node/intent-resolver-PUM2BVGU.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-KYLF2XNL.cjs +62 -0
- package/dist/lib/node/react-surface-KYLF2XNL.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +6 -7
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/ChessContainer-WV2CO5WO.mjs +87 -0
- package/dist/lib/node-esm/ChessContainer-WV2CO5WO.mjs.map +7 -0
- package/dist/lib/node-esm/artifact-3KNX2TLP.mjs +175 -0
- package/dist/lib/node-esm/artifact-3KNX2TLP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GJW6TXCL.mjs +43 -0
- package/dist/lib/node-esm/chunk-GJW6TXCL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GQA2DRUZ.mjs +71 -0
- package/dist/lib/node-esm/chunk-GQA2DRUZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YXXJHXSV.mjs +10 -0
- package/dist/lib/node-esm/chunk-YXXJHXSV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +68 -623
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-IR3YUZIG.mjs +29 -0
- package/dist/lib/node-esm/intent-resolver-IR3YUZIG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-VI6Q4BJT.mjs +43 -0
- package/dist/lib/node-esm/react-surface-VI6Q4BJT.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -4
- package/dist/types/src/ChessPlugin.d.ts +1 -3
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact.d.ts +11 -0
- package/dist/types/src/capabilities/artifact.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ChessComponent.d.ts +6 -0
- package/dist/types/src/components/ChessComponent.d.ts.map +1 -0
- package/dist/types/src/components/ChessContainer.d.ts +4 -3
- package/dist/types/src/components/ChessContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChessPanel.d.ts +11 -0
- package/dist/types/src/components/ChessPanel.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.stories.d.ts +8 -0
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/PlayerSelector.d.ts +8 -0
- package/dist/types/src/components/PlayerSelector.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +3 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +13 -9
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +18 -8
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +22 -27
- package/src/ChessPlugin.tsx +43 -89
- package/src/capabilities/artifact.ts +109 -0
- package/src/capabilities/index.ts +9 -0
- package/src/capabilities/intent-resolver.ts +26 -0
- package/src/capabilities/react-surface.tsx +29 -0
- package/src/components/ChessComponent.tsx +48 -0
- package/src/components/ChessContainer.tsx +17 -6
- package/src/components/ChessPanel.tsx +67 -0
- package/src/components/Chessboard.stories.tsx +39 -0
- package/src/components/{Chess.tsx → PlayerSelector.tsx} +3 -50
- package/src/components/index.ts +2 -0
- package/src/index.ts +3 -3
- package/src/meta.ts +4 -2
- package/src/translations.ts +2 -2
- package/src/types/schema.ts +4 -1
- package/src/types/types.ts +15 -23
- package/dist/lib/browser/chunk-2H2BTWYT.mjs +0 -15
- package/dist/lib/browser/chunk-2H2BTWYT.mjs.map +0 -7
- package/dist/lib/browser/chunk-BG7NXK4E.mjs +0 -42
- package/dist/lib/browser/chunk-BG7NXK4E.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-3VNSWSKR.cjs +0 -62
- package/dist/lib/node/chunk-3VNSWSKR.cjs.map +0 -7
- package/dist/lib/node/chunk-Q4NVPVPX.cjs +0 -38
- package/dist/lib/node/chunk-Q4NVPVPX.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -30
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-RIQ5MOYO.mjs +0 -43
- package/dist/lib/node-esm/chunk-RIQ5MOYO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WNE2FPQW.mjs +0 -17
- package/dist/lib/node-esm/chunk-WNE2FPQW.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/Chess.d.ts +0 -9
- package/dist/types/src/components/Chess.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +0 -37
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +0 -13
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/index.d.ts +0 -2
- package/dist/types/src/components/Chessboard/index.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/pieces/custom.d.ts +0 -3
- package/dist/types/src/components/Chessboard/pieces/custom.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/pieces/index.d.ts +0 -4
- package/dist/types/src/components/Chessboard/pieces/index.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/pieces/phosphor.d.ts +0 -3
- package/dist/types/src/components/Chessboard/pieces/phosphor.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard/pieces/riohacha.d.ts +0 -3
- package/dist/types/src/components/Chessboard/pieces/riohacha.d.ts.map +0 -1
- package/src/components/Chessboard/Chessboard.stories.tsx +0 -43
- package/src/components/Chessboard/Chessboard.tsx +0 -170
- package/src/components/Chessboard/index.ts +0 -5
- package/src/components/Chessboard/pieces/custom.tsx +0 -82
- package/src/components/Chessboard/pieces/index.ts +0 -7
- package/src/components/Chessboard/pieces/phosphor.tsx +0 -71
- package/src/components/Chessboard/pieces/riohacha.tsx +0 -166
|
@@ -8,20 +8,24 @@ export declare const MoveSchema: S.mutable<S.SchemaClass<{
|
|
|
8
8
|
readonly target?: string | undefined;
|
|
9
9
|
readonly piece?: string | undefined;
|
|
10
10
|
}, never>>;
|
|
11
|
-
declare const
|
|
12
|
-
|
|
13
|
-
playerBlack?: string | undefined;
|
|
14
|
-
moves?: string[] | undefined;
|
|
15
|
-
pgn?: string | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
id: string;
|
|
18
|
-
}, S.Struct.Encoded<{
|
|
11
|
+
declare const ChessType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("packages/core/echo/echo-schema/dist/types/src/object/common").TypedObjectFields<{
|
|
12
|
+
name: S.optional<typeof S.String>;
|
|
19
13
|
playerWhite: typeof S.String;
|
|
20
14
|
playerBlack: typeof S.String;
|
|
21
15
|
moves: S.mutable<S.Array$<typeof S.String>>;
|
|
22
16
|
pgn: typeof S.String;
|
|
17
|
+
fen: typeof S.String;
|
|
18
|
+
}, {
|
|
19
|
+
partial: true;
|
|
20
|
+
}>, S.Struct.Encoded<{
|
|
21
|
+
name: S.optional<typeof S.String>;
|
|
22
|
+
playerWhite: typeof S.String;
|
|
23
|
+
playerBlack: typeof S.String;
|
|
24
|
+
moves: S.mutable<S.Array$<typeof S.String>>;
|
|
25
|
+
pgn: typeof S.String;
|
|
26
|
+
fen: typeof S.String;
|
|
23
27
|
}>>;
|
|
24
|
-
export declare class
|
|
28
|
+
export declare class ChessType extends ChessType_base {
|
|
25
29
|
}
|
|
26
30
|
export {};
|
|
27
31
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,UAAU;;;;;;;;UAQtB,CAAC
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,UAAU;;;;;;;;UAQtB,CAAC;;;;;;;;;;;;;;;;;;AAEF,qBAAa,SAAU,SAAQ,cAW9B;CAAG"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { S } from '@dxos/echo-schema';
|
|
2
|
+
import { ChessType } from './schema';
|
|
3
|
+
export declare namespace ChessAction {
|
|
4
|
+
const Create_base: S.TaggedClass<Create, "dxos.org/plugin/chess/action/create", {
|
|
5
|
+
readonly _tag: S.tag<"dxos.org/plugin/chess/action/create">;
|
|
6
|
+
} & {
|
|
7
|
+
input: S.Struct<{
|
|
8
|
+
name: S.optional<typeof S.String>;
|
|
9
|
+
fen: S.optional<typeof S.String>;
|
|
10
|
+
}>;
|
|
11
|
+
output: S.Struct<{
|
|
12
|
+
object: typeof ChessType;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
export class Create extends Create_base {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
6
18
|
}
|
|
7
|
-
export
|
|
8
|
-
export type ChessPluginProvides = SurfaceProvides & IntentResolverProvides & GraphBuilderProvides & MetadataRecordsProvides & TranslationsProvides & SchemaProvides;
|
|
9
|
-
export declare const isObject: (object: unknown) => object is GameType;
|
|
19
|
+
export declare const isObject: (object: unknown) => object is typeof ChessType;
|
|
10
20
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,yBAAiB,WAAW,CAAC;;;;;;;;;;;;IAG3B,MAAM,OAAO,MAAO,SAAQ,WAQ1B;KAAG;;CACN;AAED,eAAO,MAAM,QAAQ,WAAY,OAAO,KAAG,MAAM,IAAI,OAAO,SAE3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-chess",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-labs.071a3e2",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
14
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
15
|
},
|
|
16
|
-
"./meta": {
|
|
17
|
-
"types": "./dist/types/src/meta.d.ts",
|
|
18
|
-
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
|
-
"node": "./dist/lib/node-esm/meta.mjs"
|
|
20
|
-
},
|
|
21
16
|
"./types": {
|
|
22
17
|
"types": "./dist/types/src/types/index.d.ts",
|
|
23
18
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
@@ -27,9 +22,6 @@
|
|
|
27
22
|
"types": "dist/types/src/index.d.ts",
|
|
28
23
|
"typesVersions": {
|
|
29
24
|
"*": {
|
|
30
|
-
"meta": [
|
|
31
|
-
"dist/types/src/meta.d.ts"
|
|
32
|
-
],
|
|
33
25
|
"types": [
|
|
34
26
|
"dist/types/src/types/index.d.ts"
|
|
35
27
|
]
|
|
@@ -42,19 +34,22 @@
|
|
|
42
34
|
"dependencies": {
|
|
43
35
|
"@effect/schema": "^0.75.5",
|
|
44
36
|
"@preact/signals-core": "^1.6.0",
|
|
45
|
-
"chess.js": "^1.0.0
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/async": "0.7.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/plugin-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/plugin-space": "0.7.
|
|
37
|
+
"chess.js": "^1.0.0",
|
|
38
|
+
"effect": "^3.12.3",
|
|
39
|
+
"@dxos/app-framework": "0.7.5-labs.071a3e2",
|
|
40
|
+
"@dxos/artifact": "0.7.5-labs.071a3e2",
|
|
41
|
+
"@dxos/async": "0.7.5-labs.071a3e2",
|
|
42
|
+
"@dxos/display-name": "0.7.5-labs.071a3e2",
|
|
43
|
+
"@dxos/echo-schema": "0.7.5-labs.071a3e2",
|
|
44
|
+
"@dxos/assistant": "0.7.5-labs.071a3e2",
|
|
45
|
+
"@dxos/invariant": "0.7.5-labs.071a3e2",
|
|
46
|
+
"@dxos/plugin-client": "0.7.5-labs.071a3e2",
|
|
47
|
+
"@dxos/plugin-graph": "0.7.5-labs.071a3e2",
|
|
48
|
+
"@dxos/live-object": "0.7.5-labs.071a3e2",
|
|
49
|
+
"@dxos/plugin-space": "0.7.5-labs.071a3e2",
|
|
50
|
+
"@dxos/react-client": "0.7.5-labs.071a3e2",
|
|
51
|
+
"@dxos/react-ui-gameboard": "0.7.5-labs.071a3e2",
|
|
52
|
+
"@dxos/react-ui-stack": "0.7.5-labs.071a3e2"
|
|
58
53
|
},
|
|
59
54
|
"devDependencies": {
|
|
60
55
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -63,16 +58,16 @@
|
|
|
63
58
|
"react": "~18.2.0",
|
|
64
59
|
"react-dom": "~18.2.0",
|
|
65
60
|
"vite": "5.4.7",
|
|
66
|
-
"@dxos/react-ui": "0.7.
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
61
|
+
"@dxos/react-ui": "0.7.5-labs.071a3e2",
|
|
62
|
+
"@dxos/storybook-utils": "0.7.5-labs.071a3e2",
|
|
63
|
+
"@dxos/react-ui-theme": "0.7.5-labs.071a3e2"
|
|
69
64
|
},
|
|
70
65
|
"peerDependencies": {
|
|
71
66
|
"@phosphor-icons/react": "^2.1.5",
|
|
72
67
|
"react": "~18.2.0",
|
|
73
68
|
"react-dom": "~18.2.0",
|
|
74
|
-
"@dxos/react-ui": "0.7.
|
|
75
|
-
"@dxos/react-ui-theme": "0.7.
|
|
69
|
+
"@dxos/react-ui": "0.7.5-labs.071a3e2",
|
|
70
|
+
"@dxos/react-ui-theme": "0.7.5-labs.071a3e2"
|
|
76
71
|
},
|
|
77
72
|
"publishConfig": {
|
|
78
73
|
"access": "public"
|
package/src/ChessPlugin.tsx
CHANGED
|
@@ -2,98 +2,52 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
6
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
10
|
-
import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
|
|
11
|
-
import { SpaceAction } from '@dxos/plugin-space';
|
|
12
|
-
|
|
13
|
-
import ChessContainer from './components/ChessContainer';
|
|
14
|
-
import meta, { CHESS_PLUGIN } from './meta';
|
|
8
|
+
import { Artifact, IntentResolver, ReactSurface } from './capabilities';
|
|
9
|
+
import { CHESS_PLUGIN, meta } from './meta';
|
|
15
10
|
import translations from './translations';
|
|
16
|
-
import { ChessAction,
|
|
11
|
+
import { ChessAction, ChessType } from './types';
|
|
17
12
|
|
|
18
|
-
export const ChessPlugin = ()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
export const ChessPlugin = () =>
|
|
14
|
+
definePlugin(meta, [
|
|
15
|
+
defineModule({
|
|
16
|
+
id: `${meta.id}/module/translations`,
|
|
17
|
+
activatesOn: Events.SetupTranslations,
|
|
18
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
19
|
+
}),
|
|
20
|
+
defineModule({
|
|
21
|
+
id: `${meta.id}/module/metadata`,
|
|
22
|
+
activatesOn: Events.SetupMetadata,
|
|
23
|
+
activate: () =>
|
|
24
|
+
contributes(Capabilities.Metadata, {
|
|
25
|
+
id: ChessType.typename,
|
|
26
|
+
metadata: {
|
|
27
|
+
createObject: (props: { name?: string }) => createIntent(ChessAction.Create, props),
|
|
26
28
|
placeholder: ['game title placeholder', { ns: CHESS_PLUGIN }],
|
|
27
29
|
icon: 'ph--shield-chevron--regular',
|
|
28
30
|
},
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
id: `${CHESS_PLUGIN}/create/${node.id}`,
|
|
58
|
-
data: async () => {
|
|
59
|
-
await dispatch([
|
|
60
|
-
{ plugin: CHESS_PLUGIN, action: ChessAction.CREATE },
|
|
61
|
-
{ action: SpaceAction.ADD_OBJECT, data: { target } },
|
|
62
|
-
{ action: NavigationAction.OPEN },
|
|
63
|
-
]);
|
|
64
|
-
},
|
|
65
|
-
properties: {
|
|
66
|
-
label: ['create game label', { ns: CHESS_PLUGIN }],
|
|
67
|
-
icon: 'ph--shield-chevron--regular',
|
|
68
|
-
testId: 'chessPlugin.createObject',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
translations,
|
|
77
|
-
surface: {
|
|
78
|
-
component: ({ data, role }) => {
|
|
79
|
-
switch (role) {
|
|
80
|
-
case 'article':
|
|
81
|
-
case 'section':
|
|
82
|
-
return isObject(data.object) ? <ChessContainer game={data.object} role={role} /> : null;
|
|
83
|
-
default:
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
intent: {
|
|
89
|
-
resolver: (intent) => {
|
|
90
|
-
switch (intent.action) {
|
|
91
|
-
case ChessAction.CREATE: {
|
|
92
|
-
return { data: create(GameType, {}) };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
};
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
defineModule({
|
|
34
|
+
id: `${meta.id}/module/schema`,
|
|
35
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
36
|
+
activate: () => contributes(ClientCapabilities.Schema, [ChessType]),
|
|
37
|
+
}),
|
|
38
|
+
defineModule({
|
|
39
|
+
id: `${meta.id}/module/react-surface`,
|
|
40
|
+
activatesOn: Events.SetupSurfaces,
|
|
41
|
+
activate: ReactSurface,
|
|
42
|
+
}),
|
|
43
|
+
defineModule({
|
|
44
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
45
|
+
activatesOn: Events.SetupIntents,
|
|
46
|
+
activate: IntentResolver,
|
|
47
|
+
}),
|
|
48
|
+
defineModule({
|
|
49
|
+
id: `${meta.id}/module/artifact`,
|
|
50
|
+
activatesOn: Events.Startup,
|
|
51
|
+
activate: Artifact,
|
|
52
|
+
}),
|
|
53
|
+
]);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess } from 'chess.js';
|
|
6
|
+
import { pipe } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';
|
|
10
|
+
import { createArtifactElement } from '@dxos/assistant';
|
|
11
|
+
import { isInstanceOf, ObjectId, S } from '@dxos/echo-schema';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
+
import { Filter, type Space } from '@dxos/react-client/echo';
|
|
15
|
+
|
|
16
|
+
import { ChessAction, ChessType } from '../types';
|
|
17
|
+
|
|
18
|
+
// TODO(burdon): Factor out.
|
|
19
|
+
declare global {
|
|
20
|
+
interface ToolContextExtensions {
|
|
21
|
+
space?: Space;
|
|
22
|
+
dispatch?: PromiseIntentDispatcher;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default () => {
|
|
27
|
+
const definition = defineArtifact({
|
|
28
|
+
id: 'plugin-chess',
|
|
29
|
+
instructions: `
|
|
30
|
+
Chess:
|
|
31
|
+
- If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.
|
|
32
|
+
`,
|
|
33
|
+
schema: ChessType,
|
|
34
|
+
tools: [
|
|
35
|
+
defineTool({
|
|
36
|
+
name: 'chess_new',
|
|
37
|
+
description: 'Create a new chess game. Returns the artifact definition for the game',
|
|
38
|
+
schema: S.Struct({
|
|
39
|
+
fen: S.String.annotations({ description: 'The state of the chess game in the FEN format.' }),
|
|
40
|
+
}),
|
|
41
|
+
execute: async ({ fen }, { extensions }) => {
|
|
42
|
+
invariant(extensions?.space, 'No space');
|
|
43
|
+
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
44
|
+
const intent = pipe(
|
|
45
|
+
createIntent(ChessAction.Create, { fen }),
|
|
46
|
+
chain(SpaceAction.AddObject, { target: extensions.space }),
|
|
47
|
+
);
|
|
48
|
+
const { data, error } = await extensions.dispatch(intent);
|
|
49
|
+
if (!data || error) {
|
|
50
|
+
return ToolResult.Error(error?.message ?? 'Failed to create chess game');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return ToolResult.Success(createArtifactElement(data.id));
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
defineTool({
|
|
57
|
+
name: 'chess_query',
|
|
58
|
+
description: 'Query all active chess games.',
|
|
59
|
+
schema: S.Struct({}),
|
|
60
|
+
execute: async (_, { extensions }) => {
|
|
61
|
+
invariant(extensions?.space, 'No space');
|
|
62
|
+
const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();
|
|
63
|
+
invariant(games.length > 0, 'No chess games found');
|
|
64
|
+
return ToolResult.Success(games);
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
defineTool({
|
|
68
|
+
name: 'chess_inspect',
|
|
69
|
+
description: 'Get the current state of the chess game.',
|
|
70
|
+
schema: S.Struct({ id: ObjectId }),
|
|
71
|
+
execute: async ({ id }, { extensions }) => {
|
|
72
|
+
invariant(extensions?.space, 'No space');
|
|
73
|
+
const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();
|
|
74
|
+
const game = games.find((game) => game.id === id);
|
|
75
|
+
invariant(isInstanceOf(ChessType, game));
|
|
76
|
+
return ToolResult.Success(game.fen);
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
defineTool({
|
|
80
|
+
name: 'chess_move',
|
|
81
|
+
description: 'Make a move in the chess game.',
|
|
82
|
+
schema: S.Struct({
|
|
83
|
+
id: ObjectId,
|
|
84
|
+
move: S.String.annotations({
|
|
85
|
+
description: 'The move to make in the chess game.',
|
|
86
|
+
examples: ['e4', 'Bf3'],
|
|
87
|
+
}),
|
|
88
|
+
}),
|
|
89
|
+
execute: async ({ id, move }, { extensions }) => {
|
|
90
|
+
invariant(extensions?.space, 'No space');
|
|
91
|
+
const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();
|
|
92
|
+
const game = games.find((game) => game.id === id);
|
|
93
|
+
invariant(isInstanceOf(ChessType, game));
|
|
94
|
+
const board = new Chess(game.fen);
|
|
95
|
+
try {
|
|
96
|
+
board.move(move);
|
|
97
|
+
} catch (error: any) {
|
|
98
|
+
return ToolResult.Error(error.message);
|
|
99
|
+
}
|
|
100
|
+
game.pgn = board.pgn();
|
|
101
|
+
game.fen = board.fen();
|
|
102
|
+
return ToolResult.Success(game.fen);
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return contributes(Capabilities.ArtifactDefinition, definition);
|
|
109
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const Artifact = lazy(() => import('./artifact'));
|
|
8
|
+
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
9
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess } from 'chess.js';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { create } from '@dxos/live-object';
|
|
9
|
+
|
|
10
|
+
import { ChessAction, ChessType } from '../types';
|
|
11
|
+
|
|
12
|
+
export default () =>
|
|
13
|
+
contributes(
|
|
14
|
+
Capabilities.IntentResolver,
|
|
15
|
+
createResolver({
|
|
16
|
+
intent: ChessAction.Create,
|
|
17
|
+
resolve: ({ name, fen }) => {
|
|
18
|
+
const pgn = fen ? new Chess(fen).pgn() : undefined;
|
|
19
|
+
return {
|
|
20
|
+
data: {
|
|
21
|
+
object: create(ChessType, { name, fen, pgn }),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
+
import { isInstanceOf } from '@dxos/echo-schema';
|
|
9
|
+
|
|
10
|
+
import { ChessContainer } from '../components';
|
|
11
|
+
import { ChessComponent } from '../components/ChessComponent';
|
|
12
|
+
import { CHESS_PLUGIN } from '../meta';
|
|
13
|
+
import { ChessType, isObject } from '../types';
|
|
14
|
+
|
|
15
|
+
export default () =>
|
|
16
|
+
contributes(Capabilities.ReactSurface, [
|
|
17
|
+
createSurface({
|
|
18
|
+
id: CHESS_PLUGIN,
|
|
19
|
+
role: ['article', 'section'],
|
|
20
|
+
filter: (data): data is { subject: ChessType } => isObject(data.subject),
|
|
21
|
+
component: ({ data, role }) => <ChessContainer game={data.subject} role={role} />,
|
|
22
|
+
}),
|
|
23
|
+
createSurface({
|
|
24
|
+
id: 'plugin-chess',
|
|
25
|
+
role: 'canvas-node',
|
|
26
|
+
filter: (data): data is any => isInstanceOf(ChessType, data),
|
|
27
|
+
component: ({ data }) => <ChessComponent game={data} />,
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess } from 'chess.js';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
9
|
+
import { ChessModel, Board, Chessboard, type BoardRootProps } from '@dxos/react-ui-gameboard';
|
|
10
|
+
|
|
11
|
+
import { type ChessType } from '../types';
|
|
12
|
+
|
|
13
|
+
export const ChessComponent = ({ game }: { game: ChessType }) => {
|
|
14
|
+
const model = useMemo(() => new ChessModel(), []);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!model || game.pgn !== model?.game.pgn()) {
|
|
17
|
+
const chess = new Chess();
|
|
18
|
+
if (game.pgn) {
|
|
19
|
+
chess.loadPgn(game.pgn);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
model.initialize(chess.fen());
|
|
23
|
+
}
|
|
24
|
+
}, [game.pgn]);
|
|
25
|
+
|
|
26
|
+
const space = getSpace(game);
|
|
27
|
+
if (!space) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleDrop = useCallback<NonNullable<BoardRootProps['onDrop']>>(
|
|
32
|
+
(move) => {
|
|
33
|
+
if (model.makeMove(move)) {
|
|
34
|
+
game.pgn = model.game.pgn();
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return false;
|
|
39
|
+
},
|
|
40
|
+
[model],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Board.Root model={model} onDrop={handleDrop}>
|
|
45
|
+
<Chessboard />
|
|
46
|
+
</Board.Root>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -2,22 +2,33 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { getSpace } from '@dxos/react-client/echo';
|
|
8
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { ChessComponent } from './ChessComponent';
|
|
11
|
+
import { PlayerSelector } from './PlayerSelector';
|
|
12
|
+
import { type ChessType } from '../types';
|
|
10
13
|
|
|
11
|
-
const ChessContainer = ({ game
|
|
14
|
+
const ChessContainer = ({ game }: { game: ChessType; role?: string }) => {
|
|
12
15
|
const space = getSpace(game);
|
|
13
16
|
if (!space) {
|
|
14
17
|
return null;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
return (
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
+
<StackItem.Content toolbar={false}>
|
|
22
|
+
<div role='none' className='grid grid-rows-[60px_1fr_60px] grow overflow-hidden'>
|
|
23
|
+
<div />
|
|
24
|
+
|
|
25
|
+
<div className='flex m-4 overflow-hidden'>
|
|
26
|
+
<ChessComponent game={game} />
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<PlayerSelector space={space} game={game} />
|
|
30
|
+
</div>
|
|
31
|
+
</StackItem.Content>
|
|
21
32
|
);
|
|
22
33
|
};
|
|
23
34
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ArrowURightDown, Circle } from '@phosphor-icons/react';
|
|
6
|
+
import { type Color } from 'chess.js';
|
|
7
|
+
import React, { type FC } from 'react';
|
|
8
|
+
|
|
9
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
+
import { type ChessModel } from '@dxos/react-ui-gameboard';
|
|
11
|
+
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
12
|
+
|
|
13
|
+
export type ChessPanelProps = ThemedClassName<{
|
|
14
|
+
model: ChessModel;
|
|
15
|
+
orientation?: Color;
|
|
16
|
+
onFlip?: () => void;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export const ChessPanel: FC<ChessPanelProps> = ({ classNames, model, orientation = 'w', onFlip }) => {
|
|
20
|
+
const game = model.game;
|
|
21
|
+
const history = game.history();
|
|
22
|
+
const label = game.isGameOver()
|
|
23
|
+
? game.isCheckmate()
|
|
24
|
+
? 'CHECKMATE'
|
|
25
|
+
: game.isStalemate()
|
|
26
|
+
? 'STALEMATE'
|
|
27
|
+
: 'DRAW'
|
|
28
|
+
: game.isCheck()
|
|
29
|
+
? 'CHECK'
|
|
30
|
+
: history.length
|
|
31
|
+
? `Move ${history.length}`
|
|
32
|
+
: '';
|
|
33
|
+
|
|
34
|
+
const Player = ({ color }: { color: Color }) => {
|
|
35
|
+
const turn = color === game.turn();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className='flex items-center'>
|
|
39
|
+
<Circle
|
|
40
|
+
className={mx(getSize(4), turn && (game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
|
|
41
|
+
weight={turn ? 'fill' : 'thin'}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className={mx('flex flex-col', classNames)}>
|
|
49
|
+
<div className='flex items-center justify-between pl-2 pr-2 border-b' style={{ height: 32 }}>
|
|
50
|
+
<Player color={orientation === 'w' ? 'b' : 'w'} />
|
|
51
|
+
{onFlip && (
|
|
52
|
+
<button onClick={onFlip}>
|
|
53
|
+
<ArrowURightDown weight='thin' className={getSize(6)} />
|
|
54
|
+
</button>
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div className='flex flex-col justify-center pl-2 font-thin' style={{ height: 40 }}>
|
|
59
|
+
{label}
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div className='flex items-center justify-between pl-2 pr-2 border-t' style={{ height: 32 }}>
|
|
63
|
+
<Player color={orientation} />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|