@dxos/plugin-chess 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/PLUGIN.mdl +526 -0
- package/README.md +1 -1
- package/dist/lib/neutral/ChessArticle-JHI5OXYR.mjs +88 -0
- package/dist/lib/neutral/ChessArticle-JHI5OXYR.mjs.map +7 -0
- package/dist/lib/neutral/ChessCard-4TUTIFB6.mjs +19 -0
- package/dist/lib/neutral/ChessCard-4TUTIFB6.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.mjs +10 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +13 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7XZ4CRDL.mjs +32 -0
- package/dist/lib/neutral/chunk-7XZ4CRDL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OYWDKJ5B.mjs +148 -0
- package/dist/lib/neutral/chunk-OYWDKJ5B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PJOAFP6S.mjs +41 -0
- package/dist/lib/neutral/chunk-PJOAFP6S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs +34 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YB6WZOZI.mjs +8 -0
- package/dist/lib/neutral/chunk-YB6WZOZI.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +239 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs +41 -0
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +18 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/move-6NCMKKWD.mjs +37 -0
- package/dist/lib/neutral/move-6NCMKKWD.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +13 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/play-F5L5LFLW.mjs +46 -0
- package/dist/lib/neutral/play-F5L5LFLW.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/print-GMSNKAS2.mjs +29 -0
- package/dist/lib/neutral/print-GMSNKAS2.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +39 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/ChessPlugin.d.ts +3 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/ChessPlugin.node.d.ts +8 -0
- package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.test.d.ts +2 -0
- package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -2
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/game-variant.d.ts +6 -0
- package/dist/types/src/capabilities/game-variant.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +38 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +65 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Info.d.ts +20 -0
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +5 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +64 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +5 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts +15 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +2 -0
- package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/move.d.ts +5 -0
- package/dist/types/src/operations/move.d.ts.map +1 -0
- package/dist/types/src/operations/play.d.ts +5 -0
- package/dist/types/src/operations/play.d.ts.map +1 -0
- package/dist/types/src/operations/print.d.ts +5 -0
- package/dist/types/src/operations/print.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +40 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +14 -21
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/ChessOperation.d.ts +29 -0
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -49
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +50 -0
- package/src/ChessPlugin.tsx +26 -54
- package/src/ChessPlugin.workerd.ts +18 -0
- package/src/blueprints/chess-blueprint.ts +32 -0
- package/src/blueprints/index.ts +5 -0
- package/src/capabilities/blueprint-definition.ts +12 -27
- package/src/capabilities/game-variant.ts +45 -0
- package/src/capabilities/index.ts +14 -4
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/Chessboard/Chessboard.tsx +180 -0
- package/src/components/Chessboard/Info.tsx +193 -0
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +1 -5
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +59 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +108 -0
- package/src/containers/ChessArticle/index.ts +5 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +47 -0
- package/src/containers/ChessCard/ChessCard.tsx +27 -0
- package/src/containers/ChessCard/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +1 -5
- package/src/meta.ts +13 -7
- package/src/operations/index.ts +11 -0
- package/src/operations/move.ts +36 -0
- package/src/operations/play.ts +45 -0
- package/src/operations/print.ts +28 -0
- package/src/plugin.ts +11 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +23 -18
- package/src/types/Chess.ts +28 -31
- package/src/types/ChessOperation.ts +88 -0
- package/src/types/index.ts +1 -1
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs +0 -90
- 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 +0 -79
- package/dist/lib/browser/chunk-OBJAHY6H.mjs.map +0 -7
- package/dist/lib/browser/chunk-PE3IWOFR.mjs +0 -28
- package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +0 -7
- package/dist/lib/browser/chunk-PPBBLHAC.mjs +0 -8
- package/dist/lib/browser/chunk-PPBBLHAC.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -116
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs +0 -25
- package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-RIXD6RTS.mjs +0 -38
- package/dist/lib/browser/react-surface-RIXD6RTS.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs +0 -91
- 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-42EKKMOO.mjs +0 -10
- package/dist/lib/node-esm/chunk-42EKKMOO.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 +0 -29
- package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LCCUF5X5.mjs +0 -80
- 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/lib/node-esm/index.mjs +0 -117
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs +0 -39
- package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Card.stories.d.ts +0 -49
- package/dist/types/src/components/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.d.ts +0 -32
- package/dist/types/src/components/Chessboard.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -42
- package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +0 -6
- package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +0 -9
- package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardInfo.d.ts +0 -20
- 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/dist/types/src/functions/index.d.ts +0 -3
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/move.d.ts +0 -6
- package/dist/types/src/functions/move.d.ts.map +0 -1
- package/dist/types/src/functions/play.d.ts +0 -8
- package/dist/types/src/functions/play.d.ts.map +0 -1
- package/dist/types/src/types/ChessAction.d.ts +0 -23
- package/dist/types/src/types/ChessAction.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -128
- package/src/capabilities/intent-resolver.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -23
- package/src/components/Card.stories.tsx +0 -68
- package/src/components/Chessboard.stories.tsx +0 -50
- package/src/components/Chessboard.tsx +0 -101
- package/src/components/ChessboardArticle.tsx +0 -57
- package/src/components/ChessboardContainer.tsx +0 -44
- package/src/components/ChessboardInfo.tsx +0 -140
- package/src/components/ChessboardPlayers.tsx +0 -97
- package/src/functions/index.ts +0 -6
- package/src/functions/move.ts +0 -43
- package/src/functions/play.ts +0 -45
- package/src/types/ChessAction.ts +0 -19
- /package/dist/lib/{browser/types/index.mjs.map → neutral/ChessPlugin.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/blueprints}/index.mjs.map +0 -0
package/src/meta.ts
CHANGED
|
@@ -2,18 +2,24 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { DXN } from '@dxos/keys';
|
|
7
|
+
import { meta as gameMeta } from '@dxos/plugin-game';
|
|
6
8
|
import { trim } from '@dxos/util';
|
|
7
9
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
export const meta: PluginMeta = {
|
|
11
|
-
id: CHESS_PLUGIN,
|
|
10
|
+
export const meta = Plugin.makeMeta({
|
|
11
|
+
key: DXN.make('org.dxos.plugin.chess'),
|
|
12
12
|
name: 'Chess',
|
|
13
|
+
author: 'DXOS',
|
|
13
14
|
description: trim`
|
|
14
|
-
|
|
15
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
16
|
+
Track game history and analyze moves in real-time.
|
|
15
17
|
`,
|
|
16
18
|
icon: 'ph--shield-chevron--regular',
|
|
19
|
+
iconHue: 'amber',
|
|
17
20
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',
|
|
21
|
+
spec: 'PLUGIN.mdl',
|
|
18
22
|
screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],
|
|
19
|
-
|
|
23
|
+
dependsOn: [gameMeta.id],
|
|
24
|
+
tags: ['game'],
|
|
25
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { loadGame } from '@dxos/plugin-game';
|
|
11
|
+
|
|
12
|
+
import { Chess, ChessOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Move> = ChessOperation.Move.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fn(function* ({ game, move }) {
|
|
17
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
18
|
+
const chess = new ChessJS();
|
|
19
|
+
if (variant.pgn) {
|
|
20
|
+
chess.loadPgn(variant.pgn);
|
|
21
|
+
} else if (variant.fen) {
|
|
22
|
+
chess.load(variant.fen);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
chess.move(move, { strict: false });
|
|
26
|
+
const pgn = chess.pgn();
|
|
27
|
+
Obj.update(variant, (variant) => {
|
|
28
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
29
|
+
mutable.pgn = pgn;
|
|
30
|
+
});
|
|
31
|
+
return { pgn };
|
|
32
|
+
}),
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export default handler;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { loadGame } from '@dxos/plugin-game';
|
|
11
|
+
|
|
12
|
+
import { Chess, ChessOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Play> = ChessOperation.Play.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fn(function* ({ game, side = 'any' }) {
|
|
17
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
18
|
+
const chess = new ChessJS();
|
|
19
|
+
if (variant.pgn) {
|
|
20
|
+
chess.loadPgn(variant.pgn);
|
|
21
|
+
} else if (variant.fen) {
|
|
22
|
+
chess.load(variant.fen);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (
|
|
26
|
+
!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))
|
|
27
|
+
) {
|
|
28
|
+
return { move: undefined, pgn: variant.pgn ?? '' };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const moves = chess.moves();
|
|
32
|
+
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
33
|
+
|
|
34
|
+
chess.move(move, { strict: false });
|
|
35
|
+
const pgn = chess.pgn();
|
|
36
|
+
Obj.update(variant, (variant) => {
|
|
37
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
38
|
+
mutable.pgn = pgn;
|
|
39
|
+
});
|
|
40
|
+
return { move, pgn };
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export default handler;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { ChessOperation } from '../types';
|
|
11
|
+
|
|
12
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Print> = ChessOperation.Print.pipe(
|
|
13
|
+
Operation.withHandler(
|
|
14
|
+
Effect.fn(function* ({ pgn, fen }) {
|
|
15
|
+
try {
|
|
16
|
+
const chess = new ChessJS(fen);
|
|
17
|
+
if (pgn) {
|
|
18
|
+
chess.loadPgn(pgn);
|
|
19
|
+
}
|
|
20
|
+
return { ascii: chess.ascii() };
|
|
21
|
+
} catch {
|
|
22
|
+
return { ascii: '' };
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default handler;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const ChessPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { ChessOperationHandlerSet } from './operations';
|
package/src/testing.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -2,32 +2,37 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Type } from '@dxos/echo';
|
|
5
6
|
import { type Resource } from '@dxos/react-ui';
|
|
6
7
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import { Chess } from '
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
import { Chess } from '#types';
|
|
9
10
|
|
|
10
11
|
export const translations = [
|
|
11
12
|
{
|
|
12
13
|
'en-US': {
|
|
13
|
-
[Chess.
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'button flip': 'Flip board',
|
|
14
|
+
[Type.getTypename(Chess.State)]: {
|
|
15
|
+
'typename.label': 'Chess',
|
|
16
|
+
'typename.label_zero': 'Chess games',
|
|
17
|
+
'typename.label_one': 'Chess game',
|
|
18
|
+
'typename.label_other': 'Chess games',
|
|
19
|
+
'object-name.placeholder': 'New chess game',
|
|
20
|
+
'add-object.label': 'Add chess game',
|
|
21
|
+
'rename-object.label': 'Rename chess game',
|
|
22
|
+
'delete-object.label': 'Delete chess game',
|
|
23
23
|
},
|
|
24
24
|
[meta.id]: {
|
|
25
|
-
'plugin
|
|
26
|
-
'
|
|
27
|
-
'game.
|
|
28
|
-
'game.
|
|
29
|
-
'game.
|
|
30
|
-
'game.
|
|
25
|
+
'plugin.name': 'Chess',
|
|
26
|
+
'new-game.button': 'New game',
|
|
27
|
+
'delete-game.label': 'Delete',
|
|
28
|
+
'game.checkmate.label': 'Checkmate',
|
|
29
|
+
'game.stalemate.label': 'Stalemate',
|
|
30
|
+
'game.draw.label': 'Draw',
|
|
31
|
+
'game.check.label': 'Check',
|
|
32
|
+
'select-player.button': 'Select player',
|
|
33
|
+
'toggle-info.button': 'Toggle info',
|
|
34
|
+
'close-info.button': 'Close info',
|
|
35
|
+
'flip-board.button': 'Flip board',
|
|
31
36
|
},
|
|
32
37
|
},
|
|
33
38
|
},
|
package/src/types/Chess.ts
CHANGED
|
@@ -3,42 +3,40 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
-
import
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { BlueprintsAnnotation } from '@dxos/app-toolkit';
|
|
9
|
+
import { DXN, Annotation, Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { FormInputAnnotation, HiddenAnnotation } from '@dxos/echo/Annotation';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}),
|
|
20
|
-
),
|
|
21
|
-
black: Schema.optional(
|
|
22
|
-
Schema.String.annotations({
|
|
23
|
-
description: 'DID of black player',
|
|
24
|
-
}),
|
|
25
|
-
),
|
|
26
|
-
}).pipe(Schema.mutable),
|
|
27
|
-
),
|
|
13
|
+
export const BLUEPRINT_KEY = 'org.dxos.blueprint.chess';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Chess variant state. Referenced by the base `Game` object via `Game.variant`.
|
|
17
|
+
* Players, name, and other game-shared fields live on the base `Game`.
|
|
18
|
+
*/
|
|
19
|
+
export const State = Schema.Struct({
|
|
28
20
|
pgn: Schema.String.annotations({
|
|
29
21
|
description: 'Portable Game Notation.',
|
|
30
|
-
}),
|
|
22
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
23
|
+
fen: Schema.String.annotations({
|
|
24
|
+
description: 'Forsyth-Edwards Notation.',
|
|
25
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
31
26
|
}).pipe(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
Annotation.IconAnnotation.set({ icon: 'ph--shield-chevron--regular', hue: 'amber' }),
|
|
28
|
+
BlueprintsAnnotation.set([BLUEPRINT_KEY]),
|
|
29
|
+
// Implementation detail of the unified `Game` schema. The user-facing object is `Game`;
|
|
30
|
+
// this state is only ever referenced via `Game.variant`. HiddenAnnotation keeps it out of the
|
|
31
|
+
// navtree's typed branches so an orphaned state object doesn't reappear after the
|
|
32
|
+
// wrapping Game is deleted.
|
|
33
|
+
HiddenAnnotation.set(true),
|
|
34
|
+
Type.makeObject(DXN.make('org.dxos.type.chess.state', '0.1.0')),
|
|
37
35
|
);
|
|
38
36
|
|
|
39
|
-
export
|
|
37
|
+
export type State = Type.InstanceType<typeof State>;
|
|
40
38
|
|
|
41
|
-
export const
|
|
39
|
+
export const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {
|
|
42
40
|
const chess = new ChessJS();
|
|
43
41
|
if (pgn) {
|
|
44
42
|
try {
|
|
@@ -48,9 +46,8 @@ export const makeGame = ({ name, pgn }: { name?: string; pgn?: string } = {}) =>
|
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
return Obj.make(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
pgn: chess.pgn(),
|
|
49
|
+
return Obj.make(State, {
|
|
50
|
+
pgn,
|
|
51
|
+
fen,
|
|
55
52
|
});
|
|
56
53
|
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
10
|
+
import { Database, DXN } from '@dxos/echo';
|
|
11
|
+
import { GameRef } from '@dxos/plugin-game/types';
|
|
12
|
+
|
|
13
|
+
import * as Chess from './Chess';
|
|
14
|
+
|
|
15
|
+
export const Move = Operation.make({
|
|
16
|
+
meta: {
|
|
17
|
+
key: DXN.make('org.dxos.function.chess.move'),
|
|
18
|
+
name: 'Move',
|
|
19
|
+
description: 'Makes a move in the given chess game.',
|
|
20
|
+
icon: 'ph--play--regular',
|
|
21
|
+
},
|
|
22
|
+
input: Schema.Struct({
|
|
23
|
+
game: GameRef(Chess.State).annotations({
|
|
24
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
25
|
+
}),
|
|
26
|
+
move: Schema.String.annotations({
|
|
27
|
+
description: 'The move to make in the chess game.',
|
|
28
|
+
examples: ['e4', 'Bf3'],
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
output: Schema.Struct({
|
|
32
|
+
pgn: Schema.String.annotations({
|
|
33
|
+
description: 'The PGN of the game after the move was played.',
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
services: [Database.Service],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const Play = Operation.make({
|
|
40
|
+
meta: {
|
|
41
|
+
key: DXN.make('org.dxos.function.chess.play'),
|
|
42
|
+
name: 'Play',
|
|
43
|
+
description: 'Uses the chess engine to play the next move.',
|
|
44
|
+
icon: 'ph--play--regular',
|
|
45
|
+
},
|
|
46
|
+
input: Schema.Struct({
|
|
47
|
+
game: GameRef(Chess.State).annotations({
|
|
48
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
49
|
+
}),
|
|
50
|
+
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
51
|
+
description: 'The side to play.',
|
|
52
|
+
defaultValue: 'any',
|
|
53
|
+
}),
|
|
54
|
+
}),
|
|
55
|
+
output: Schema.Struct({
|
|
56
|
+
pgn: Schema.String.annotations({
|
|
57
|
+
description: 'The PGN of the game after the move was played.',
|
|
58
|
+
}),
|
|
59
|
+
move: Schema.optional(Schema.String).annotations({
|
|
60
|
+
description: 'The move that was played.',
|
|
61
|
+
}),
|
|
62
|
+
}),
|
|
63
|
+
services: [Database.Service],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const Print = Operation.make({
|
|
67
|
+
meta: {
|
|
68
|
+
key: DXN.make('org.dxos.function.chess.print'),
|
|
69
|
+
name: 'Print game',
|
|
70
|
+
description: 'Prints the chess game to ASCII.',
|
|
71
|
+
icon: 'ph--clipboard-text--regular',
|
|
72
|
+
},
|
|
73
|
+
input: Schema.Struct({
|
|
74
|
+
pgn: Schema.optional(
|
|
75
|
+
Schema.String.annotations({
|
|
76
|
+
description: 'Portable Game Notation.',
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
fen: Schema.optional(
|
|
80
|
+
Schema.String.annotations({
|
|
81
|
+
description: 'Forsyth-Edwards Notation.',
|
|
82
|
+
}),
|
|
83
|
+
),
|
|
84
|
+
}),
|
|
85
|
+
output: Schema.Struct({
|
|
86
|
+
ascii: Schema.String,
|
|
87
|
+
}),
|
|
88
|
+
});
|
package/src/types/index.ts
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chessboard
|
|
3
|
-
} from "./chunk-2W3S5N6C.mjs";
|
|
4
|
-
import {
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-PE3IWOFR.mjs";
|
|
7
|
-
|
|
8
|
-
// src/components/ChessboardContainer.tsx
|
|
9
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
10
|
-
import React2 from "react";
|
|
11
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
12
|
-
|
|
13
|
-
// src/components/ChessboardArticle.tsx
|
|
14
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
15
|
-
import React, { useState } from "react";
|
|
16
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
17
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
18
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
19
|
-
var ChessboardArticle = ({ game }) => {
|
|
20
|
-
var _effect = _useSignals();
|
|
21
|
-
try {
|
|
22
|
-
const { t } = useTranslation(meta.id);
|
|
23
|
-
const [orientation, setOrientation] = useState("white");
|
|
24
|
-
const [open, setOpen] = useState(true);
|
|
25
|
-
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
26
|
-
classNames: "@container bs-full is-full overflow-hidden"
|
|
27
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
28
|
-
game
|
|
29
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
30
|
-
className: mx("grid grid-rows-[1fr_4rem] bs-full is-full gap-2", open && "@3xl:grid-cols-[1fr_320px]")
|
|
31
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
32
|
-
orientation
|
|
33
|
-
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
34
|
-
className: "hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden"
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
36
|
-
orientation,
|
|
37
|
-
min: 8,
|
|
38
|
-
max: 8,
|
|
39
|
-
onOrientationChange: setOrientation,
|
|
40
|
-
onClose: () => setOpen(false)
|
|
41
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
42
|
-
className: "flex justify-center items-center"
|
|
43
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Players, null, /* @__PURE__ */ React.createElement(IconButton, {
|
|
44
|
-
variant: "ghost",
|
|
45
|
-
icon: "ph--info--regular",
|
|
46
|
-
iconOnly: true,
|
|
47
|
-
label: t("button toggle info"),
|
|
48
|
-
size: 6,
|
|
49
|
-
classNames: mx("invisible", !open && "@3xl:visible"),
|
|
50
|
-
onClick: () => setOpen((open2) => !open2)
|
|
51
|
-
}))))));
|
|
52
|
-
} finally {
|
|
53
|
-
_effect.f();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/components/ChessboardContainer.tsx
|
|
58
|
-
var ChessboardContainer = ({ game, role }) => {
|
|
59
|
-
var _effect = _useSignals2();
|
|
60
|
-
try {
|
|
61
|
-
const space = getSpace(game);
|
|
62
|
-
if (!space) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
switch (role) {
|
|
66
|
-
case "card--popover":
|
|
67
|
-
case "card--intrinsic":
|
|
68
|
-
case "card--extrinsic": {
|
|
69
|
-
return /* @__PURE__ */ React2.createElement(Chessboard.Root, {
|
|
70
|
-
game
|
|
71
|
-
}, /* @__PURE__ */ React2.createElement(Chessboard.Content, {
|
|
72
|
-
role
|
|
73
|
-
}, /* @__PURE__ */ React2.createElement(Chessboard.Board, null)));
|
|
74
|
-
}
|
|
75
|
-
default: {
|
|
76
|
-
return /* @__PURE__ */ React2.createElement(ChessboardArticle, {
|
|
77
|
-
game
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} finally {
|
|
82
|
-
_effect.f();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var ChessboardContainer_default = ChessboardContainer;
|
|
86
|
-
export {
|
|
87
|
-
ChessboardContainer,
|
|
88
|
-
ChessboardContainer_default as default
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=ChessboardContainer-NNIOQIRP.mjs.map
|
|
@@ -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 { getSpace } from '@dxos/react-client/echo';\n\nimport { type Chess } from '../types';\n\nimport { Chessboard } from './Chessboard';\nimport { ChessboardArticle } from './ChessboardArticle';\n\nexport type ChessboardContainerProps = {\n game: Chess.Game;\n role?: string;\n};\n\nexport const ChessboardContainer = ({ game, role }: ChessboardContainerProps) => {\n const space = getSpace(game);\n if (!space) {\n return null;\n }\n\n switch (role) {\n case 'card--popover':\n case 'card--intrinsic':\n case 'card--extrinsic': {\n return (\n <Chessboard.Root game={game}>\n <Chessboard.Content role={role}>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n );\n }\n\n default: {\n return <ChessboardArticle game={game} />;\n }\n }\n};\n\nexport default ChessboardContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\nimport { type Chess } from '../types';\n\nimport { Chessboard } from './Chessboard';\n\nexport const ChessboardArticle = ({ game }: { game: Chess.Game }) => {\n const { t } = useTranslation(meta.id);\n const [orientation, setOrientation] = useState<Player>('white');\n const [open, setOpen] = useState(true);\n\n return (\n <StackItem.Content classNames='@container bs-full is-full overflow-hidden'>\n <Chessboard.Root game={game}>\n <div className={mx('grid grid-rows-[1fr_4rem] bs-full is-full gap-2', open && '@3xl:grid-cols-[1fr_320px]')}>\n <Chessboard.Content>\n <Chessboard.Board 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 />\n </div>\n )}\n <div className='flex justify-center items-center'>\n <Chessboard.Players>\n <IconButton\n variant='ghost'\n icon='ph--info--regular'\n iconOnly\n label={t('button toggle info')}\n size={6}\n classNames={mx('invisible', !open && '@3xl:visible')}\n onClick={() => setOpen((open) => !open)}\n />\n </Chessboard.Players>\n </div>\n </div>\n </Chessboard.Root>\n </StackItem.Content>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,gBAAgB;;;;ACFzB,OAAOC,SAASC,gBAAgB;AAEhC,SAASC,YAAYC,sBAAsB;AAE3C,SAASC,iBAAiB;AAC1B,SAASC,UAAU;AAOZ,IAAMC,oBAAoB,CAAC,EAAEC,KAAI,MAAwB;;;AAC9D,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAM,CAACC,aAAaC,cAAAA,IAAkBC,SAAiB,OAAA;AACvD,UAAM,CAACC,MAAMC,OAAAA,IAAWF,SAAS,IAAA;AAEjC,WACE,sBAAA,cAACG,UAAUC,SAAO;MAACC,YAAW;OAC5B,sBAAA,cAACC,WAAWC,MAAI;MAACd;OACf,sBAAA,cAACe,OAAAA;MAAIC,WAAWC,GAAG,mDAAmDT,QAAQ,4BAAA;OAC5E,sBAAA,cAACK,WAAWF,SAAO,MACjB,sBAAA,cAACE,WAAWK,OAAK;MAACb;SAEnBG,QACC,sBAAA,cAACO,OAAAA;MAAIC,WAAU;OACb,sBAAA,cAACH,WAAWM,MAAI;MACdd;MACAe,KAAK;MACLC,KAAK;MACLC,qBAAqBhB;MACrBiB,SAAS,MAAMd,QAAQ,KAAA;SAI7B,sBAAA,cAACM,OAAAA;MAAIC,WAAU;OACb,sBAAA,cAACH,WAAWW,SAAO,MACjB,sBAAA,cAACC,YAAAA;MACCC,SAAQ;MACRC,MAAK;MACLC,UAAAA;MACAC,OAAO5B,EAAE,oBAAA;MACT6B,MAAM;MACNlB,YAAYK,GAAG,aAAa,CAACT,QAAQ,cAAA;MACrCuB,SAAS,MAAMtB,QAAQ,CAACD,UAAS,CAACA,KAAAA;;;;;AAQlD;;;ADtCO,IAAMwB,sBAAsB,CAAC,EAAEC,MAAMC,KAAI,MAA4B;;;AAC1E,UAAMC,QAAQC,SAASH,IAAAA;AACvB,QAAI,CAACE,OAAO;AACV,aAAO;IACT;AAEA,YAAQD,MAAAA;MACN,KAAK;MACL,KAAK;MACL,KAAK,mBAAmB;AACtB,eACE,gBAAAG,OAAA,cAACC,WAAWC,MAAI;UAACN;WACf,gBAAAI,OAAA,cAACC,WAAWE,SAAO;UAACN;WAClB,gBAAAG,OAAA,cAACC,WAAWG,OAAK,IAAA,CAAA,CAAA;MAIzB;MAEA,SAAS;AACP,eAAO,gBAAAJ,OAAA,cAACK,mBAAAA;UAAkBT;;MAC5B;IACF;;;;AACF;AAEA,IAAA,8BAAeD;",
|
|
6
|
-
"names": ["React", "getSpace", "React", "useState", "IconButton", "useTranslation", "StackItem", "mx", "ChessboardArticle", "game", "t", "useTranslation", "meta", "id", "orientation", "setOrientation", "useState", "open", "setOpen", "StackItem", "Content", "classNames", "Chessboard", "Root", "div", "className", "mx", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "Players", "IconButton", "variant", "icon", "iconOnly", "label", "size", "onClick", "ChessboardContainer", "game", "role", "space", "getSpace", "React", "Chessboard", "Root", "Content", "Board", "ChessboardArticle"]
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
move_default,
|
|
3
|
-
play_default
|
|
4
|
-
} from "./chunk-EJMPHRSR.mjs";
|
|
5
|
-
import "./chunk-OBJAHY6H.mjs";
|
|
6
|
-
import "./chunk-PE3IWOFR.mjs";
|
|
7
|
-
|
|
8
|
-
// src/capabilities/blueprint-definition.ts
|
|
9
|
-
import { ToolId } from "@dxos/ai";
|
|
10
|
-
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
11
|
-
import { Blueprint, Template } from "@dxos/blueprints";
|
|
12
|
-
import { trim } from "@dxos/util";
|
|
13
|
-
var functions = [
|
|
14
|
-
move_default,
|
|
15
|
-
play_default
|
|
16
|
-
];
|
|
17
|
-
var blueprint_definition_default = () => {
|
|
18
|
-
return [
|
|
19
|
-
contributes(Capabilities.BlueprintDefinition, Blueprint.make({
|
|
20
|
-
key: "dxos.org/blueprint/chess",
|
|
21
|
-
name: "Chess",
|
|
22
|
-
instructions: Template.make({
|
|
23
|
-
source: trim`
|
|
24
|
-
You are an expert chess player.
|
|
25
|
-
You could suggest a good next move or offer to play a move.
|
|
26
|
-
Don't actually make a move unless you are asked to.
|
|
27
|
-
To analyze a game you can retrieve the "pgn" property from the context object.
|
|
28
|
-
`
|
|
29
|
-
}),
|
|
30
|
-
tools: functions.map((tool) => ToolId.make(tool.name))
|
|
31
|
-
})),
|
|
32
|
-
contributes(Capabilities.Functions, functions)
|
|
33
|
-
];
|
|
34
|
-
};
|
|
35
|
-
export {
|
|
36
|
-
blueprint_definition_default as default
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=blueprint-definition-OJQYAZGZ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/blueprint-definition.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { ToolId } from '@dxos/ai';\nimport { Capabilities, contributes } from '@dxos/app-framework';\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { trim } from '@dxos/util';\n\nimport { move, play } from '../functions';\n\nconst functions = [move, play];\n\nexport default () => {\n return [\n contributes(\n Capabilities.BlueprintDefinition,\n Blueprint.make({\n key: 'dxos.org/blueprint/chess',\n name: 'Chess',\n instructions: Template.make({\n source: trim`\n You are an expert chess player.\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 To analyze a game you can retrieve the \"pgn\" property from the context object.\n `,\n }),\n tools: functions.map((tool) => ToolId.make(tool.name)),\n }),\n ),\n contributes(Capabilities.Functions, functions),\n ];\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,SAASA,cAAc;AACvB,SAASC,cAAcC,mBAAmB;AAC1C,SAASC,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAIrB,IAAMC,YAAY;EAACC;EAAMC;;AAEzB,IAAA,+BAAe,MAAA;AACb,SAAO;IACLC,YACEC,aAAaC,qBACbC,UAAUC,KAAK;MACbC,KAAK;MACLC,MAAM;MACNC,cAAcC,SAASJ,KAAK;QAC1BK,QAAQC;;;;;;MAMV,CAAA;MACAC,OAAOd,UAAUe,IAAI,CAACC,SAASC,OAAOV,KAAKS,KAAKP,IAAI,CAAA;IACtD,CAAA,CAAA;IAEFN,YAAYC,aAAac,WAAWlB,SAAAA;;AAExC;",
|
|
6
|
-
"names": ["ToolId", "Capabilities", "contributes", "Blueprint", "Template", "trim", "functions", "move", "play", "contributes", "Capabilities", "BlueprintDefinition", "Blueprint", "make", "key", "name", "instructions", "Template", "source", "trim", "tools", "map", "tool", "ToolId", "Functions"]
|
|
7
|
-
}
|