@dxos/plugin-chess 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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-IS4PXWJD.mjs → ChessboardContainer-GNSIZKY7.mjs} +3 -4
- package/dist/lib/browser/ChessboardContainer-GNSIZKY7.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-BPWETZAA.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-BPWETZAA.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +4 -4
- package/dist/lib/browser/{chunk-7OZ7J7LF.mjs → chunk-66H3V2YV.mjs} +2 -2
- package/dist/lib/browser/chunk-66H3V2YV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DH4WQRZH.mjs → chunk-FJ4QNUZE.mjs} +34 -32
- package/dist/lib/browser/chunk-FJ4QNUZE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UUMPZ2FM.mjs → chunk-MABHE5SS.mjs} +14 -8
- package/dist/lib/browser/chunk-MABHE5SS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MV2GQK7M.mjs → chunk-QGVMZ4PK.mjs} +2 -2
- package/dist/lib/browser/cli/index.mjs +8 -7
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +18 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-GQE7XMWH.mjs → react-surface-C52R6BRL.mjs} +8 -7
- package/dist/lib/browser/react-surface-C52R6BRL.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{ChessboardContainer-S3T6OE7P.mjs → ChessboardContainer-5OVYZMIW.mjs} +3 -4
- package/dist/lib/node-esm/ChessboardContainer-5OVYZMIW.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-RYKASBIJ.mjs → blueprint-definition-7USRBNR3.mjs} +7 -7
- package/dist/lib/node-esm/blueprint-definition-7USRBNR3.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +4 -4
- package/dist/lib/node-esm/{chunk-NFDJU7XQ.mjs → chunk-4HGTAI3I.mjs} +34 -32
- package/dist/lib/node-esm/chunk-4HGTAI3I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DOBR6ILE.mjs → chunk-IFK6UAKF.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-NAYRVJR4.mjs → chunk-OUNGNJFP.mjs} +2 -2
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LKJ5GDAB.mjs → chunk-V6MKXXPO.mjs} +14 -8
- package/dist/lib/node-esm/chunk-V6MKXXPO.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +8 -7
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +18 -17
- 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-7UZLIVN6.mjs → react-surface-NW33JZ6J.mjs} +8 -7
- package/dist/lib/node-esm/react-surface-NW33JZ6J.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 +2 -2
- 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/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.map +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +1 -1
- package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -1
- package/dist/types/src/components/Info.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +4 -4
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -43
- package/src/ChessPlugin.tsx +8 -7
- package/src/blueprints/chess-blueprint.ts +14 -6
- package/src/blueprints/functions/create.ts +1 -1
- package/src/blueprints/functions/index.ts +13 -4
- package/src/blueprints/functions/move.ts +4 -5
- package/src/blueprints/functions/play.ts +4 -5
- 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 +4 -3
- package/src/cli/plugin.ts +4 -3
- package/src/components/Card.stories.tsx +1 -1
- package/src/components/Chessboard.stories.tsx +1 -1
- package/src/components/Chessboard.tsx +5 -3
- package/src/components/ChessboardArticle.tsx +2 -3
- package/src/components/ChessboardContainer.tsx +1 -1
- package/src/components/Info.tsx +10 -4
- package/src/types/Chess.ts +1 -1
- package/dist/lib/browser/ChessboardContainer-IS4PXWJD.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-7OZ7J7LF.mjs.map +0 -7
- package/dist/lib/browser/chunk-DH4WQRZH.mjs.map +0 -7
- package/dist/lib/browser/chunk-UUMPZ2FM.mjs.map +0 -7
- package/dist/lib/browser/react-surface-GQE7XMWH.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-S3T6OE7P.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-RYKASBIJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LKJ5GDAB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NAYRVJR4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NFDJU7XQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7UZLIVN6.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-MV2GQK7M.mjs.map → chunk-QGVMZ4PK.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-DOBR6ILE.mjs.map → chunk-IFK6UAKF.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.2244d791bb",
|
|
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,34 +52,35 @@
|
|
|
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-
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/echo-
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/plugin-
|
|
73
|
-
"@dxos/plugin-
|
|
74
|
-
"@dxos/plugin-
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/react-
|
|
77
|
-
"@dxos/react-
|
|
78
|
-
"@dxos/react-ui-sfx": "0.8.4-main.
|
|
79
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/types": "0.8.4-main.
|
|
82
|
-
"@dxos/
|
|
57
|
+
"effect": "3.19.16",
|
|
58
|
+
"@dxos/ai": "0.8.4-main.2244d791bb",
|
|
59
|
+
"@dxos/app-toolkit": "0.8.4-main.2244d791bb",
|
|
60
|
+
"@dxos/app-framework": "0.8.4-main.2244d791bb",
|
|
61
|
+
"@dxos/assistant": "0.8.4-main.2244d791bb",
|
|
62
|
+
"@dxos/async": "0.8.4-main.2244d791bb",
|
|
63
|
+
"@dxos/blueprints": "0.8.4-main.2244d791bb",
|
|
64
|
+
"@dxos/echo": "0.8.4-main.2244d791bb",
|
|
65
|
+
"@dxos/display-name": "0.8.4-main.2244d791bb",
|
|
66
|
+
"@dxos/echo-db": "0.8.4-main.2244d791bb",
|
|
67
|
+
"@dxos/echo-react": "0.8.4-main.2244d791bb",
|
|
68
|
+
"@dxos/functions": "0.8.4-main.2244d791bb",
|
|
69
|
+
"@dxos/invariant": "0.8.4-main.2244d791bb",
|
|
70
|
+
"@dxos/log": "0.8.4-main.2244d791bb",
|
|
71
|
+
"@dxos/operation": "0.8.4-main.2244d791bb",
|
|
72
|
+
"@dxos/plugin-client": "0.8.4-main.2244d791bb",
|
|
73
|
+
"@dxos/plugin-markdown": "0.8.4-main.2244d791bb",
|
|
74
|
+
"@dxos/plugin-graph": "0.8.4-main.2244d791bb",
|
|
75
|
+
"@dxos/plugin-space": "0.8.4-main.2244d791bb",
|
|
76
|
+
"@dxos/react-client": "0.8.4-main.2244d791bb",
|
|
77
|
+
"@dxos/react-ui-gameboard": "0.8.4-main.2244d791bb",
|
|
78
|
+
"@dxos/react-ui-sfx": "0.8.4-main.2244d791bb",
|
|
79
|
+
"@dxos/react-ui-stack": "0.8.4-main.2244d791bb",
|
|
80
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.2244d791bb",
|
|
81
|
+
"@dxos/types": "0.8.4-main.2244d791bb",
|
|
82
|
+
"@dxos/schema": "0.8.4-main.2244d791bb",
|
|
83
|
+
"@dxos/util": "0.8.4-main.2244d791bb"
|
|
83
84
|
},
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@types/react": "~19.2.7",
|
|
@@ -87,16 +88,16 @@
|
|
|
87
88
|
"react": "~19.2.3",
|
|
88
89
|
"react-dom": "~19.2.3",
|
|
89
90
|
"vite": "7.1.9",
|
|
90
|
-
"@dxos/plugin-theme": "0.8.4-main.
|
|
91
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
91
|
+
"@dxos/plugin-theme": "0.8.4-main.2244d791bb",
|
|
92
|
+
"@dxos/react-ui": "0.8.4-main.2244d791bb",
|
|
93
|
+
"@dxos/ui-theme": "0.8.4-main.2244d791bb",
|
|
94
|
+
"@dxos/storybook-utils": "0.8.4-main.2244d791bb"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"react": "~19.2.3",
|
|
97
98
|
"react-dom": "~19.2.3",
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/ui
|
|
99
|
+
"@dxos/ui-theme": "0.8.4-main.2244d791bb",
|
|
100
|
+
"@dxos/react-ui": "0.8.4-main.2244d791bb"
|
|
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,21 @@ 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
27
|
addToCollectionOnCreate: true,
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
30
|
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
32
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
33
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
33
34
|
Plugin.make,
|
|
34
35
|
);
|
|
@@ -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 = 'dxos.org/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;
|
|
@@ -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,8 +6,7 @@ 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, Type } from '@dxos/echo';
|
|
11
10
|
import { defineFunction } from '@dxos/functions';
|
|
12
11
|
|
|
13
12
|
import { Chess } from '../../types';
|
|
@@ -17,7 +16,7 @@ export default defineFunction({
|
|
|
17
16
|
name: 'Move',
|
|
18
17
|
description: 'Makes a move in the given chess game.',
|
|
19
18
|
inputSchema: Schema.Struct({
|
|
20
|
-
|
|
19
|
+
game: Type.Ref(Chess.Game).annotations({
|
|
21
20
|
description: 'The ID of the chess object.',
|
|
22
21
|
}),
|
|
23
22
|
move: Schema.String.annotations({
|
|
@@ -30,8 +29,8 @@ 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 object = yield* Database.
|
|
32
|
+
handler: Effect.fn(function* ({ data: { game, move } }) {
|
|
33
|
+
const object = yield* Database.load(game);
|
|
35
34
|
const chess = new ChessJS();
|
|
36
35
|
if (object.pgn) {
|
|
37
36
|
chess.loadPgn(object.pgn);
|
|
@@ -6,8 +6,7 @@ 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, Type } from '@dxos/echo';
|
|
11
10
|
import { defineFunction } from '@dxos/functions';
|
|
12
11
|
|
|
13
12
|
import { Chess } from '../../types';
|
|
@@ -17,7 +16,7 @@ export default defineFunction({
|
|
|
17
16
|
name: 'Play',
|
|
18
17
|
description: 'Uses the chess engine to play the next move.',
|
|
19
18
|
inputSchema: Schema.Struct({
|
|
20
|
-
|
|
19
|
+
game: Type.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);
|
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,7 +5,8 @@
|
|
|
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
12
|
import { ChessboardContainer } from '../../components';
|
|
@@ -14,8 +15,8 @@ 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
21
|
role: ['article', 'section', 'card--content'],
|
|
21
22
|
// TODO(burdon): Could this be standardized so that we don't require a subject property.
|
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,8 +13,7 @@ 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: {
|
|
@@ -22,5 +22,6 @@ export const ChessPlugin = Plugin.define(meta).pipe(
|
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
}),
|
|
25
|
+
AppPlugin.addSchemaModule({ schema: [Chess.Game] }),
|
|
25
26
|
Plugin.make,
|
|
26
27
|
);
|
|
@@ -25,7 +25,7 @@ const DefaultStory = ({ pgn }: StoryProps) => {
|
|
|
25
25
|
const meta = {
|
|
26
26
|
title: 'plugins/plugin-chess/Chessboard',
|
|
27
27
|
component: DefaultStory,
|
|
28
|
-
decorators: [withTheme, withClientProvider({ createIdentity: true })],
|
|
28
|
+
decorators: [withTheme(), withClientProvider({ createIdentity: true })],
|
|
29
29
|
parameters: {
|
|
30
30
|
layout: 'fullscreen',
|
|
31
31
|
translations,
|
|
@@ -112,7 +112,7 @@ type ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;
|
|
|
112
112
|
const Content = ({ classNames, children, role }: ContentProps) => {
|
|
113
113
|
return (
|
|
114
114
|
<Gameboard.Content
|
|
115
|
-
classNames={mx(classNames, role === 'card--popover' && 'size-container
|
|
115
|
+
classNames={mx(classNames, role === 'card--popover' && 'size-container card-square')}
|
|
116
116
|
grow={!role || role === 'card--extrinsic'}
|
|
117
117
|
contain={!role || role === 'card--extrinsic' || role === 'card--popover'}
|
|
118
118
|
>
|
|
@@ -125,11 +125,13 @@ const Content = ({ classNames, children, role }: ContentProps) => {
|
|
|
125
125
|
// Board
|
|
126
126
|
//
|
|
127
127
|
|
|
128
|
+
const BOARD_NAME = 'Chessboard.Board';
|
|
129
|
+
|
|
128
130
|
type BoardProps = NaturalChessboardProps;
|
|
129
131
|
|
|
130
132
|
const Board = (props: BoardProps) => {
|
|
131
133
|
const registry = useContext(RegistryContext);
|
|
132
|
-
const { model } = useGameboardContext<ChessModel>(
|
|
134
|
+
const { model } = useGameboardContext<ChessModel>(BOARD_NAME);
|
|
133
135
|
|
|
134
136
|
// Keyboard navigation.
|
|
135
137
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -167,7 +169,7 @@ const Board = (props: BoardProps) => {
|
|
|
167
169
|
return <NaturalChessboard ref={ref} {...props} />;
|
|
168
170
|
};
|
|
169
171
|
|
|
170
|
-
Board.displayName =
|
|
172
|
+
Board.displayName = BOARD_NAME;
|
|
171
173
|
|
|
172
174
|
//
|
|
173
175
|
// Chessboard
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-
|
|
8
|
-
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Layout, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { type Player } from '@dxos/react-ui-gameboard';
|
|
10
|
-
import { Layout } from '@dxos/react-ui-mosaic';
|
|
11
10
|
import { mx } from '@dxos/ui-theme';
|
|
12
11
|
|
|
13
12
|
import { meta } from '../meta';
|
package/src/components/Info.tsx
CHANGED
|
@@ -16,6 +16,8 @@ import { meta } from '../meta';
|
|
|
16
16
|
|
|
17
17
|
import { type ExtendedChessModel } from './Chessboard';
|
|
18
18
|
|
|
19
|
+
const INFO_NAME = 'Chessboard.Info';
|
|
20
|
+
|
|
19
21
|
export type InfoProps = ThemedClassName<
|
|
20
22
|
{
|
|
21
23
|
orientation?: Player;
|
|
@@ -26,7 +28,7 @@ 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
|
|
|
@@ -49,7 +51,9 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
49
51
|
<PlayerSelector
|
|
50
52
|
value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}
|
|
51
53
|
onValueChange={(value) => {
|
|
52
|
-
model.object
|
|
54
|
+
Obj.change(model.object, (obj) => {
|
|
55
|
+
obj.players![orientation === 'white' ? 'black' : 'white'] = value;
|
|
56
|
+
});
|
|
53
57
|
}}
|
|
54
58
|
members={members}
|
|
55
59
|
/>
|
|
@@ -76,7 +80,9 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
76
80
|
<PlayerSelector
|
|
77
81
|
value={model.object.players?.[orientation]}
|
|
78
82
|
onValueChange={(value) => {
|
|
79
|
-
model.object
|
|
83
|
+
Obj.change(model.object, (obj) => {
|
|
84
|
+
obj.players![orientation] = value;
|
|
85
|
+
});
|
|
80
86
|
}}
|
|
81
87
|
members={members}
|
|
82
88
|
/>
|
|
@@ -85,7 +91,7 @@ export const Info = ({ classNames, orientation = 'white', onOrientationChange, o
|
|
|
85
91
|
);
|
|
86
92
|
};
|
|
87
93
|
|
|
88
|
-
Info.displayName =
|
|
94
|
+
Info.displayName = INFO_NAME;
|
|
89
95
|
|
|
90
96
|
//
|
|
91
97
|
// History
|
package/src/types/Chess.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const Game = Schema.Struct({
|
|
|
22
22
|
description: 'DID of black player',
|
|
23
23
|
}),
|
|
24
24
|
),
|
|
25
|
-
}).pipe(
|
|
25
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
26
26
|
pgn: Schema.String.annotations({
|
|
27
27
|
description: 'Portable Game Notation.',
|
|
28
28
|
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ChessboardContainer.tsx", "../../../src/components/ChessboardArticle.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-framework/react';\nimport { Obj } from '@dxos/echo';\n\nimport { type Chess } from '../types';\n\nimport { Chessboard } from './Chessboard';\nimport { ChessboardArticle } from './ChessboardArticle';\n\nexport type ChessboardContainerProps = SurfaceComponentProps<Chess.Game>;\n\nexport const ChessboardContainer = ({ role, subject: game }: ChessboardContainerProps) => {\n const db = Obj.getDatabase(game);\n if (!db) {\n return null;\n }\n\n switch (role) {\n case 'card--content': {\n return (\n <Chessboard.Root game={game}>\n <Chessboard.Content>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n );\n }\n\n default: {\n return <ChessboardArticle role={role} subject={game} />;\n }\n }\n};\n\nexport default ChessboardContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-framework/react';\nimport { Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { Layout } from '@dxos/react-ui-mosaic';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '../meta';\nimport { type Chess } from '../types';\n\nimport { Chessboard, type ChessboardController, type ChessboardInfoProps } from './Chessboard';\n\nexport type ChessboardArticleProps = SurfaceComponentProps<Chess.Game>;\n\nexport const ChessboardArticle = ({ role, subject: game }: ChessboardArticleProps) => {\n const { t } = useTranslation(meta.id);\n const [orientation, setOrientation] = useState<Player>('white');\n const [open, setOpen] = useState(true);\n const controller = useRef<ChessboardController>(null);\n\n // TODO(burdon): Keyboard handler.\n const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {\n controller.current?.setMoveNumber(index);\n }, []);\n\n return (\n <Layout.Main toolbar classNames='@container'>\n <Chessboard.Root game={game} ref={controller}>\n <Toolbar.Root>\n <Toolbar.IconButton\n icon='ph--info--regular'\n iconOnly\n label={t('toggle info button')}\n disabled={open}\n classNames={mx('invisible @3xl:visible')}\n onClick={() => setOpen((open) => !open)}\n />\n </Toolbar.Root>\n <div\n className={mx(\n 'grid bs-full is-full gap-2',\n open && '@3xl:grid-cols-[1fr_320px]',\n role === 'section' && 'aspect-square',\n role === 'section' && open && '@3xl:aspect-auto',\n )}\n >\n <Chessboard.Content>\n <Chessboard.Board classNames='m-4 rounded-sm overflow-hidden' orientation={orientation} />\n </Chessboard.Content>\n {open && (\n <div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>\n <Chessboard.Info\n orientation={orientation}\n min={8}\n max={8}\n onOrientationChange={setOrientation}\n onClose={() => setOpen(false)}\n onSelect={handleSelect}\n />\n </div>\n )}\n </div>\n </Chessboard.Root>\n </Layout.Main>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,YAAW;AAGlB,SAASC,WAAW;;;ACHpB,OAAOC,SAASC,aAAaC,QAAQC,gBAAgB;AAGrD,SAASC,SAASC,sBAAsB;AAExC,SAASC,cAAc;AACvB,SAASC,UAAU;AASZ,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA0B;AAC/E,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAM,CAACC,aAAaC,cAAAA,IAAkBC,SAAiB,OAAA;AACvD,QAAM,CAACC,MAAMC,OAAAA,IAAWF,SAAS,IAAA;AACjC,QAAMG,aAAaC,OAA6B,IAAA;AAGhD,QAAMC,eAAeC,YAA0D,CAACC,UAAAA;AAC9EJ,eAAWK,SAASC,cAAcF,KAAAA;EACpC,GAAG,CAAA,CAAE;AAEL,SACE,sBAAA,cAACG,OAAOC,MAAI;IAACC,SAAAA;IAAQC,YAAW;KAC9B,sBAAA,cAACC,WAAWC,MAAI;IAACtB;IAAYuB,KAAKb;KAChC,sBAAA,cAACc,QAAQF,MAAI,MACX,sBAAA,cAACE,QAAQC,YAAU;IACjBC,MAAK;IACLC,UAAAA;IACAC,OAAO3B,EAAE,oBAAA;IACT4B,UAAUrB;IACVY,YAAYU,GAAG,wBAAA;IACfC,SAAS,MAAMtB,QAAQ,CAACD,UAAS,CAACA,KAAAA;OAGtC,sBAAA,cAACwB,OAAAA;IACCC,WAAWH,GACT,8BACAtB,QAAQ,8BACRV,SAAS,aAAa,iBACtBA,SAAS,aAAaU,QAAQ,kBAAA;KAGhC,sBAAA,cAACa,WAAWa,SAAO,MACjB,sBAAA,cAACb,WAAWc,OAAK;IAACf,YAAW;IAAiCf;OAE/DG,QACC,sBAAA,cAACwB,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACZ,WAAWe,MAAI;IACd/B;IACAgC,KAAK;IACLC,KAAK;IACLC,qBAAqBjC;IACrBkC,SAAS,MAAM/B,QAAQ,KAAA;IACvBgC,UAAU7B;;AAQ1B;;;ADtDO,IAAM8B,sBAAsB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA4B;AACnF,QAAMC,KAAKC,IAAIC,YAAYH,IAAAA;AAC3B,MAAI,CAACC,IAAI;AACP,WAAO;EACT;AAEA,UAAQH,MAAAA;IACN,KAAK,iBAAiB;AACpB,aACE,gBAAAM,OAAA,cAACC,WAAWC,MAAI;QAACN;SACf,gBAAAI,OAAA,cAACC,WAAWE,SAAO,MACjB,gBAAAH,OAAA,cAACC,WAAWG,OAAK,IAAA,CAAA,CAAA;IAIzB;IAEA,SAAS;AACP,aAAO,gBAAAJ,OAAA,cAACK,mBAAAA;QAAkBX;QAAYC,SAASC;;IACjD;EACF;AACF;AAEA,IAAA,8BAAeH;",
|
|
6
|
-
"names": ["React", "Obj", "React", "useCallback", "useRef", "useState", "Toolbar", "useTranslation", "Layout", "mx", "ChessboardArticle", "role", "subject", "game", "t", "useTranslation", "meta", "id", "orientation", "setOrientation", "useState", "open", "setOpen", "controller", "useRef", "handleSelect", "useCallback", "index", "current", "setMoveNumber", "Layout", "Main", "toolbar", "classNames", "Chessboard", "Root", "ref", "Toolbar", "IconButton", "icon", "iconOnly", "label", "disabled", "mx", "onClick", "div", "className", "Content", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect", "ChessboardContainer", "role", "subject", "game", "db", "Obj", "getDatabase", "React", "Chessboard", "Root", "Content", "Board", "ChessboardArticle"]
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
chess_blueprint_exports
|
|
3
|
-
} from "./chunk-DH4WQRZH.mjs";
|
|
4
|
-
import "./chunk-7OZ7J7LF.mjs";
|
|
5
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/blueprint-definition/blueprint-definition.ts
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
|
-
import { Capability, Common } from "@dxos/app-framework";
|
|
10
|
-
var blueprintDefinition = Capability.makeModule(() => Effect.succeed([
|
|
11
|
-
Capability.contributes(Common.Capability.Functions, chess_blueprint_exports.functions),
|
|
12
|
-
Capability.contributes(Common.Capability.BlueprintDefinition, chess_blueprint_exports.make())
|
|
13
|
-
]));
|
|
14
|
-
var blueprint_definition_default = blueprintDefinition;
|
|
15
|
-
export {
|
|
16
|
-
blueprint_definition_default as default
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=blueprint-definition-5RUGJ64Z.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/blueprint-definition/blueprint-definition.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability, Common } from '@dxos/app-framework';\n\nimport { ChessBlueprint } from '../../blueprints';\n\nexport type BlueprintCapabilities = [\n Capability.Capability<typeof Common.Capability.Functions>,\n Capability.Capability<typeof Common.Capability.BlueprintDefinition>,\n];\n\nconst blueprintDefinition = Capability.makeModule<[], BlueprintCapabilities>(() =>\n Effect.succeed([\n Capability.contributes(Common.Capability.Functions, ChessBlueprint.functions),\n Capability.contributes(Common.Capability.BlueprintDefinition, ChessBlueprint.make()),\n ]),\n);\n\nexport default blueprintDefinition;\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,YAAYC,cAAc;AASnC,IAAMC,sBAAsBC,WAAWC,WAAsC,MACpEC,eAAQ;EACbF,WAAWG,YAAYC,OAAOJ,WAAWK,WAAWC,wBAAeC,SAAS;EAC5EP,WAAWG,YAAYC,OAAOJ,WAAWQ,qBAAqBF,wBAAeG,KAAI,CAAA;CAClF,CAAA;AAGH,IAAA,+BAAeV;",
|
|
6
|
-
"names": ["Effect", "Capability", "Common", "blueprintDefinition", "Capability", "makeModule", "succeed", "contributes", "Common", "Functions", "ChessBlueprint", "functions", "BlueprintDefinition", "make"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Chess.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { log } from '@dxos/log';\n\nexport const Game = Schema.Struct({\n name: Schema.optional(Schema.String),\n players: Schema.Struct({\n white: Schema.optional(\n Schema.String.annotations({\n description: 'DID of white player',\n }),\n ),\n black: Schema.optional(\n Schema.String.annotations({\n description: 'DID of black player',\n }),\n ),\n }).pipe(Schema.mutable, FormInputAnnotation.set(false), Schema.optional),\n pgn: Schema.String.annotations({\n description: 'Portable Game Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n fen: Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Chess',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport interface Game extends Schema.Schema.Type<typeof Game> {}\n\nexport const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: string } = {}) => {\n const chess = new ChessJS();\n if (pgn) {\n try {\n chess.loadPgn(pgn);\n } catch {\n log.warn(pgn);\n }\n }\n\n return Obj.make(Game, {\n name,\n pgn,\n fen,\n players: {},\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,KAAKC,YAAY;AAC1B,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,WAAW;;AAEb,IAAMC,OAAcC,cAAO;EAChCC,MAAaC,gBAAgBC,aAAM;EACnCC,SAAgBJ,cAAO;IACrBK,OAAcH,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;IAEFC,OAAcN,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA,EAAGE,KAAYC,gBAASd,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;EACvEU,KAAYT,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;EACvDW,KAAYV,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;AACzD,CAAA,EAAGO,KACDd,KAAKmB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAnB,gBAAgBc,IAAI;EAAC;CAAO,CAAA;AAKvB,IAAMM,OAAO,CAAC,EAAEhB,MAAMW,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMK,QAAQ,IAAI1B,QAAAA;AAClB,MAAIoB,KAAK;AACP,QAAI;AACFM,YAAMC,QAAQP,GAAAA;IAChB,QAAQ;AACNd,UAAIsB,KAAKR,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOlB,IAAIuB,KAAKlB,MAAM;IACpBE;IACAW;IACAC;IACAT,SAAS,CAAC;EACZ,CAAA;AACF;",
|
|
6
|
-
"names": ["Chess", "ChessJS", "Schema", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "Struct", "name", "optional", "String", "players", "white", "annotations", "description", "black", "pipe", "mutable", "set", "pgn", "fen", "object", "typename", "version", "make", "chess", "loadPgn", "warn"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/blueprints/chess-blueprint.ts", "../../../src/blueprints/functions/index.ts", "../../../src/blueprints/functions/create.ts", "../../../src/blueprints/functions/move.ts", "../../../src/blueprints/functions/play.ts", "../../../src/blueprints/functions/print.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { type FunctionDefinition } from '@dxos/functions';\nimport { trim } from '@dxos/util';\n\nimport { create, move, play, print } from './functions';\n\nexport const Key = 'dxos.org/blueprint/chess';\n\nexport const functions: FunctionDefinition[] = [create, move, play, print];\n\nexport const make = () =>\n Blueprint.make({\n key: Key,\n name: 'Chess',\n tools: Blueprint.toolDefinitions({ functions }),\n instructions: Template.make({\n source: trim`\n You are an expert chess player.\n To analyze a game you can access the \"pgn\" property by loading the context object that represents the current game.\n You could suggest a good next move or offer to play a move.\n Don't actually make a move unless you are asked to.\n `,\n }),\n });\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport { default as create } from './create';\nexport { default as move } from './move';\nexport { default as play } from './play';\nexport { default as print } from './print';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Database } from '@dxos/echo';\nimport { defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/create',\n name: 'Create Chess',\n description: 'Creates a new chess game.',\n inputSchema: Schema.Struct({\n name: Schema.optional(\n Schema.String.annotations({\n description: 'Name of the game.',\n }),\n ),\n pgn: Schema.optional(\n Schema.String.annotations({\n description: 'Portable Game Notation.',\n }),\n ),\n fen: Schema.optional(\n Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }),\n ),\n }),\n outputSchema: Chess.Game,\n handler: Effect.fn(function* ({ data: { name, pgn, fen } }) {\n return yield* Database.Service.add(Chess.make({ name, pgn, fen }));\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ArtifactId } from '@dxos/assistant';\nimport { Database, Obj } from '@dxos/echo';\nimport { defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/move',\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n inputSchema: Schema.Struct({\n id: ArtifactId.annotations({\n description: 'The ID of the chess object.',\n }),\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n outputSchema: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n }),\n handler: Effect.fn(function* ({ data: { id, move } }) {\n const object = yield* Database.Service.resolve(ArtifactId.toDXN(id), Chess.Game);\n const chess = new ChessJS();\n if (object.pgn) {\n chess.loadPgn(object.pgn);\n } else if (object.fen) {\n chess.load(object.fen);\n }\n\n chess.move(move, { strict: false });\n const pgn = chess.pgn();\n Obj.change(object, (o) => {\n o.pgn = pgn;\n });\n return { pgn };\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ArtifactId } from '@dxos/assistant';\nimport { Database, Obj } from '@dxos/echo';\nimport { defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/play',\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n inputSchema: Schema.Struct({\n id: ArtifactId.annotations({\n description: 'The ID of the chess object.',\n }),\n side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({\n description: 'The side to play.',\n defaultValue: 'any',\n }),\n }),\n outputSchema: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n move: Schema.optional(Schema.String).annotations({\n description: 'The move that was played.',\n }),\n }),\n handler: Effect.fn(function* ({ data: { id, side = 'any' } }) {\n const object = yield* Database.Service.resolve(ArtifactId.toDXN(id), Chess.Game);\n const chess = new ChessJS();\n if (object.pgn) {\n chess.loadPgn(object.pgn);\n } else if (object.fen) {\n chess.load(object.fen);\n }\n\n if (!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))) {\n return { move: undefined, pgn: object.pgn! };\n }\n\n const moves = chess.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n\n chess.move(move, { strict: false });\n const pgn = chess.pgn();\n Obj.change(object, (o) => {\n o.pgn = pgn;\n });\n return { move, pgn };\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { defineFunction } from '@dxos/functions';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/print',\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\n inputSchema: Schema.Struct({\n pgn: Schema.optional(\n Schema.String.annotations({\n description: 'Portable Game Notation.',\n }),\n ),\n fen: Schema.optional(\n Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }),\n ),\n }),\n outputSchema: Schema.Struct({\n ascii: Schema.String,\n }),\n handler: Effect.fn(function* ({ data: { pgn, fen } }) {\n try {\n const chess = new ChessJS(fen);\n if (pgn) {\n chess.loadPgn(pgn);\n }\n return { ascii: chess.ascii() };\n } catch {\n // TODO(burdon): Error handling?\n return { ascii: '' };\n }\n }),\n});\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["Blueprint", "Template", "trim", "Effect", "Schema", "Database", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "optional", "String", "annotations", "pgn", "fen", "outputSchema", "Chess", "Game", "handler", "fn", "data", "Database", "Service", "add", "make", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "Database", "Obj", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "move", "String", "examples", "outputSchema", "pgn", "handler", "fn", "data", "object", "Database", "Service", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "strict", "Obj", "change", "o", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "Database", "Obj", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "side", "optional", "Literal", "defaultValue", "outputSchema", "pgn", "String", "move", "handler", "fn", "data", "object", "Database", "Service", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "turn", "undefined", "moves", "Math", "floor", "random", "length", "strict", "Obj", "change", "o", "Chess", "ChessJS", "Effect", "Schema", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "pgn", "optional", "String", "annotations", "fen", "outputSchema", "ascii", "handler", "fn", "data", "chess", "ChessJS", "loadPgn", "Key", "functions", "create", "move", "play", "print", "make", "Blueprint", "key", "name", "tools", "toolDefinitions", "instructions", "Template", "source", "trim"]
|
|
7
|
-
}
|