@dxos/plugin-chess 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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/blueprints/index.mjs +9 -6
- package/dist/lib/browser/chunk-5FHUZILG.mjs +63 -0
- package/dist/lib/browser/chunk-5FHUZILG.mjs.map +7 -0
- package/dist/lib/browser/chunk-BCTL5GYK.mjs +88 -0
- package/dist/lib/browser/chunk-BCTL5GYK.mjs.map +7 -0
- package/dist/lib/browser/chunk-ORLWKOYE.mjs +26 -0
- package/dist/lib/browser/chunk-ORLWKOYE.mjs.map +7 -0
- package/dist/lib/browser/chunk-YER5TC5N.mjs +35 -0
- package/dist/lib/browser/chunk-YER5TC5N.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +27 -85
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/move-BH3WZUJH.mjs +39 -0
- package/dist/lib/browser/move-BH3WZUJH.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +17 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/play-IM4BDFSY.mjs +48 -0
- package/dist/lib/browser/play-IM4BDFSY.mjs.map +7 -0
- package/dist/lib/browser/print-M3ZO2XZT.mjs +30 -0
- package/dist/lib/browser/print-M3ZO2XZT.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +34 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/blueprints/index.mjs +9 -6
- package/dist/lib/node-esm/chunk-A3P4HC7O.mjs +89 -0
- package/dist/lib/node-esm/chunk-A3P4HC7O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-B42KRPBJ.mjs +37 -0
- package/dist/lib/node-esm/chunk-B42KRPBJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WSHXDK3W.mjs +27 -0
- package/dist/lib/node-esm/chunk-WSHXDK3W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YRW4LYGF.mjs +64 -0
- package/dist/lib/node-esm/chunk-YRW4LYGF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +27 -85
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/move-53HLCSAL.mjs +40 -0
- package/dist/lib/node-esm/move-53HLCSAL.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +18 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/play-YXXPG5SO.mjs +49 -0
- package/dist/lib/node-esm/play-YXXPG5SO.mjs.map +7 -0
- package/dist/lib/node-esm/print-L2LUM3IW.mjs +31 -0
- package/dist/lib/node-esm/print-L2LUM3IW.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +35 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/ChessPlugin.d.ts +1 -0
- 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/blueprints/chess-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -2
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- 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 +5 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +10 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- 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.d.ts → Chessboard/Chessboard.d.ts} +10 -11
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +57 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Info.d.ts → Chessboard/Info.d.ts} +5 -6
- 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 +56 -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/{components/Card.stories.d.ts → containers/ChessCard/ChessCard.stories.d.ts} +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +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 +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +24 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -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/translations.d.ts +32 -23
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +10 -19
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -48
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +49 -0
- package/src/ChessPlugin.tsx +14 -23
- package/src/blueprints/chess-blueprint.ts +14 -9
- package/src/blueprints/index.ts +2 -2
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/game-variant.ts +42 -0
- package/src/capabilities/index.ts +10 -2
- package/src/capabilities/node.ts +18 -0
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +21 -31
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +24 -77
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +1 -5
- package/src/{components/Chessboard.stories.tsx → containers/ChessArticle/ChessArticle.stories.tsx} +16 -10
- 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 +5 -3
- package/src/meta.ts +1 -1
- package/src/operations/definitions.ts +83 -0
- package/src/operations/index.ts +15 -0
- package/src/operations/move.ts +37 -0
- package/src/operations/play.ts +46 -0
- package/src/operations/print.ts +28 -0
- package/src/translations.ts +18 -21
- package/src/types/Chess.ts +25 -24
- package/dist/lib/browser/ChessboardContainer-GNSIZKY7.mjs +0 -80
- package/dist/lib/browser/ChessboardContainer-GNSIZKY7.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-YUKJZPOL.mjs +0 -19
- package/dist/lib/browser/blueprint-definition-YUKJZPOL.mjs.map +0 -7
- package/dist/lib/browser/chunk-66H3V2YV.mjs +0 -64
- package/dist/lib/browser/chunk-66H3V2YV.mjs.map +0 -7
- package/dist/lib/browser/chunk-H3NUMCQ6.mjs +0 -21
- package/dist/lib/browser/chunk-H3NUMCQ6.mjs.map +0 -7
- package/dist/lib/browser/chunk-MABHE5SS.mjs +0 -277
- package/dist/lib/browser/chunk-MABHE5SS.mjs.map +0 -7
- package/dist/lib/browser/chunk-PBRN5Q4R.mjs +0 -227
- package/dist/lib/browser/chunk-PBRN5Q4R.mjs.map +0 -7
- package/dist/lib/browser/chunk-QGVMZ4PK.mjs +0 -8
- package/dist/lib/browser/chunk-QGVMZ4PK.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -29
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/react-surface-C52R6BRL.mjs +0 -38
- package/dist/lib/browser/react-surface-C52R6BRL.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-5OVYZMIW.mjs +0 -81
- package/dist/lib/node-esm/ChessboardContainer-5OVYZMIW.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-4HZ2HWWC.mjs +0 -20
- package/dist/lib/node-esm/blueprint-definition-4HZ2HWWC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3MAU6WHB.mjs +0 -228
- package/dist/lib/node-esm/chunk-3MAU6WHB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5OMIM4F.mjs +0 -23
- package/dist/lib/node-esm/chunk-F5OMIM4F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IFK6UAKF.mjs +0 -10
- package/dist/lib/node-esm/chunk-IFK6UAKF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs +0 -65
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V6MKXXPO.mjs +0 -278
- package/dist/lib/node-esm/chunk-V6MKXXPO.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -30
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NW33JZ6J.mjs +0 -39
- package/dist/lib/node-esm/react-surface-NW33JZ6J.mjs.map +0 -7
- package/dist/types/src/blueprints/functions/create.d.ts +0 -15
- package/dist/types/src/blueprints/functions/create.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/index.d.ts +0 -5
- package/dist/types/src/blueprints/functions/index.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/move.d.ts +0 -16
- package/dist/types/src/blueprints/functions/move.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/play.d.ts +0 -17
- package/dist/types/src/blueprints/functions/play.d.ts.map +0 -1
- package/dist/types/src/blueprints/functions/print.d.ts +0 -8
- package/dist/types/src/blueprints/functions/print.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +0 -12
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -10
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts +0 -3
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/dist/types/src/components/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -46
- package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +0 -6
- package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +0 -7
- package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
- package/dist/types/src/components/Info.d.ts.map +0 -1
- package/src/blueprints/functions/create.ts +0 -38
- package/src/blueprints/functions/index.ts +0 -8
- package/src/blueprints/functions/move.ts +0 -48
- package/src/blueprints/functions/play.ts +0 -58
- package/src/blueprints/functions/print.ts +0 -42
- package/src/capabilities/artifact-definition/artifact-definition.ts +0 -135
- package/src/capabilities/artifact-definition/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -24
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -28
- package/src/cli/index.ts +0 -5
- package/src/cli/plugin.ts +0 -27
- package/src/components/Card.stories.tsx +0 -47
- package/src/components/ChessboardArticle.tsx +0 -70
- package/src/components/ChessboardContainer.tsx +0 -40
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
import { Database } from '@dxos/echo';
|
|
9
|
+
import { GameRef } from '@dxos/plugin-game/types';
|
|
10
|
+
|
|
11
|
+
import { Chess } from '../types';
|
|
12
|
+
|
|
13
|
+
export const Move = Operation.make({
|
|
14
|
+
meta: {
|
|
15
|
+
key: 'org.dxos.function.chess.move',
|
|
16
|
+
name: 'Move',
|
|
17
|
+
description: 'Makes a move in the given chess game.',
|
|
18
|
+
},
|
|
19
|
+
input: Schema.Struct({
|
|
20
|
+
game: GameRef(Chess.State).annotations({
|
|
21
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
22
|
+
}),
|
|
23
|
+
move: Schema.String.annotations({
|
|
24
|
+
description: 'The move to make in the chess game.',
|
|
25
|
+
examples: ['e4', 'Bf3'],
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
output: Schema.Struct({
|
|
29
|
+
pgn: Schema.String.annotations({
|
|
30
|
+
description: 'The PGN of the game after the move was played.',
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
services: [Database.Service],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const Play = Operation.make({
|
|
37
|
+
meta: {
|
|
38
|
+
key: 'org.dxos.function.chess.play',
|
|
39
|
+
name: 'Play',
|
|
40
|
+
description: 'Uses the chess engine to play the next move.',
|
|
41
|
+
},
|
|
42
|
+
input: Schema.Struct({
|
|
43
|
+
game: GameRef(Chess.State).annotations({
|
|
44
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
45
|
+
}),
|
|
46
|
+
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
47
|
+
description: 'The side to play.',
|
|
48
|
+
defaultValue: 'any',
|
|
49
|
+
}),
|
|
50
|
+
}),
|
|
51
|
+
output: Schema.Struct({
|
|
52
|
+
pgn: Schema.String.annotations({
|
|
53
|
+
description: 'The PGN of the game after the move was played.',
|
|
54
|
+
}),
|
|
55
|
+
move: Schema.optional(Schema.String).annotations({
|
|
56
|
+
description: 'The move that was played.',
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
services: [Database.Service],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const Print = Operation.make({
|
|
63
|
+
meta: {
|
|
64
|
+
key: 'org.dxos.function.chess.print',
|
|
65
|
+
name: 'Print game',
|
|
66
|
+
description: 'Prints the chess game to ASCII.',
|
|
67
|
+
},
|
|
68
|
+
input: Schema.Struct({
|
|
69
|
+
pgn: Schema.optional(
|
|
70
|
+
Schema.String.annotations({
|
|
71
|
+
description: 'Portable Game Notation.',
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
fen: Schema.optional(
|
|
75
|
+
Schema.String.annotations({
|
|
76
|
+
description: 'Forsyth-Edwards Notation.',
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
}),
|
|
80
|
+
output: Schema.Struct({
|
|
81
|
+
ascii: Schema.String,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
|
+
|
|
7
|
+
const Handlers = OperationHandlerSet.lazy(
|
|
8
|
+
() => import('./move'),
|
|
9
|
+
() => import('./play'),
|
|
10
|
+
() => import('./print'),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export { Move, Play, Print } from './definitions';
|
|
14
|
+
|
|
15
|
+
export const ChessHandlers = Handlers;
|
|
@@ -0,0 +1,37 @@
|
|
|
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/types';
|
|
11
|
+
|
|
12
|
+
import { Chess } from '../types';
|
|
13
|
+
import { Move } from './definitions';
|
|
14
|
+
|
|
15
|
+
const handler: Operation.WithHandler<typeof Move> = Move.pipe(
|
|
16
|
+
Operation.withHandler(
|
|
17
|
+
Effect.fn(function* ({ game, move }) {
|
|
18
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
19
|
+
const chess = new ChessJS();
|
|
20
|
+
if (variant.pgn) {
|
|
21
|
+
chess.loadPgn(variant.pgn);
|
|
22
|
+
} else if (variant.fen) {
|
|
23
|
+
chess.load(variant.fen);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
chess.move(move, { strict: false });
|
|
27
|
+
const pgn = chess.pgn();
|
|
28
|
+
Obj.update(variant, (variant) => {
|
|
29
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
30
|
+
mutable.pgn = pgn;
|
|
31
|
+
});
|
|
32
|
+
return { pgn };
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default handler;
|
|
@@ -0,0 +1,46 @@
|
|
|
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/types';
|
|
11
|
+
|
|
12
|
+
import { Chess } from '../types';
|
|
13
|
+
import { Play } from './definitions';
|
|
14
|
+
|
|
15
|
+
const handler: Operation.WithHandler<typeof Play> = Play.pipe(
|
|
16
|
+
Operation.withHandler(
|
|
17
|
+
Effect.fn(function* ({ game, side = 'any' }) {
|
|
18
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
19
|
+
const chess = new ChessJS();
|
|
20
|
+
if (variant.pgn) {
|
|
21
|
+
chess.loadPgn(variant.pgn);
|
|
22
|
+
} else if (variant.fen) {
|
|
23
|
+
chess.load(variant.fen);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (
|
|
27
|
+
!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))
|
|
28
|
+
) {
|
|
29
|
+
return { move: undefined, pgn: variant.pgn ?? '' };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const moves = chess.moves();
|
|
33
|
+
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
34
|
+
|
|
35
|
+
chess.move(move, { strict: false });
|
|
36
|
+
const pgn = chess.pgn();
|
|
37
|
+
Obj.update(variant, (variant) => {
|
|
38
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
39
|
+
mutable.pgn = pgn;
|
|
40
|
+
});
|
|
41
|
+
return { move, pgn };
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
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 { Print } from './definitions';
|
|
11
|
+
|
|
12
|
+
const handler: Operation.WithHandler<typeof Print> = 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/translations.ts
CHANGED
|
@@ -4,33 +4,30 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
8
|
-
import { Chess } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
|
+
import { Chess } from '#types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[Chess.
|
|
14
|
-
'typename
|
|
15
|
-
'typename
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'object name placeholder': 'New game',
|
|
19
|
-
'rename object label': 'Rename game',
|
|
20
|
-
'delete object label': 'Delete game',
|
|
21
|
-
'object deleted label': 'Game deleted',
|
|
13
|
+
[Chess.State.typename]: {
|
|
14
|
+
'typename.label': 'Chess',
|
|
15
|
+
'typename.label_zero': 'Chess games',
|
|
16
|
+
'typename.label_one': 'Chess game',
|
|
17
|
+
'typename.label_other': 'Chess games',
|
|
22
18
|
},
|
|
23
19
|
[meta.id]: {
|
|
24
|
-
'plugin
|
|
25
|
-
'
|
|
26
|
-
'game.
|
|
27
|
-
'game.
|
|
28
|
-
'game.
|
|
29
|
-
'game.
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
20
|
+
'plugin.name': 'Chess',
|
|
21
|
+
'new-game.button': 'New game',
|
|
22
|
+
'delete-game.label': 'Delete',
|
|
23
|
+
'game.checkmate.label': 'Checkmate',
|
|
24
|
+
'game.stalemate.label': 'Stalemate',
|
|
25
|
+
'game.draw.label': 'Draw',
|
|
26
|
+
'game.check.label': 'Check',
|
|
27
|
+
'select-player.button': 'Select player',
|
|
28
|
+
'toggle-info.button': 'Toggle info',
|
|
29
|
+
'close-info.button': 'Close info',
|
|
30
|
+
'flip-board.button': 'Flip board',
|
|
34
31
|
},
|
|
35
32
|
},
|
|
36
33
|
},
|
package/src/types/Chess.ts
CHANGED
|
@@ -5,24 +5,18 @@
|
|
|
5
5
|
import { Chess as ChessJS } from 'chess.js';
|
|
6
6
|
import * as Schema from 'effect/Schema';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { BlueprintsAnnotation } from '@dxos/app-toolkit';
|
|
9
|
+
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { FormInputAnnotation, SystemTypeAnnotation } from '@dxos/echo/internal';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
),
|
|
20
|
-
black: Schema.optional(
|
|
21
|
-
Schema.String.annotations({
|
|
22
|
-
description: 'DID of black player',
|
|
23
|
-
}),
|
|
24
|
-
),
|
|
25
|
-
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
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({
|
|
26
20
|
pgn: Schema.String.annotations({
|
|
27
21
|
description: 'Portable Game Notation.',
|
|
28
22
|
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
@@ -31,15 +25,24 @@ export const Game = Schema.Struct({
|
|
|
31
25
|
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
32
26
|
}).pipe(
|
|
33
27
|
Type.object({
|
|
34
|
-
typename: 'dxos.
|
|
35
|
-
version: '0.
|
|
28
|
+
typename: 'org.dxos.type.chess.state',
|
|
29
|
+
version: '0.1.0',
|
|
30
|
+
}),
|
|
31
|
+
Annotation.IconAnnotation.set({
|
|
32
|
+
icon: 'ph--shield-chevron--regular',
|
|
33
|
+
hue: 'amber',
|
|
36
34
|
}),
|
|
37
|
-
|
|
35
|
+
BlueprintsAnnotation.set([BLUEPRINT_KEY]),
|
|
36
|
+
// Implementation detail of the unified `Game` schema. The user-facing object is `Game`;
|
|
37
|
+
// this state is only ever referenced via `Game.variant`. SystemType keeps it out of the
|
|
38
|
+
// navtree's typed branches so an orphaned state object doesn't reappear after the
|
|
39
|
+
// wrapping Game is deleted.
|
|
40
|
+
SystemTypeAnnotation.set(true),
|
|
38
41
|
);
|
|
39
42
|
|
|
40
|
-
export interface
|
|
43
|
+
export interface State extends Schema.Schema.Type<typeof State> {}
|
|
41
44
|
|
|
42
|
-
export const make = ({
|
|
45
|
+
export const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {
|
|
43
46
|
const chess = new ChessJS();
|
|
44
47
|
if (pgn) {
|
|
45
48
|
try {
|
|
@@ -49,10 +52,8 @@ export const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: st
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
return Obj.make(
|
|
53
|
-
name,
|
|
55
|
+
return Obj.make(State, {
|
|
54
56
|
pgn,
|
|
55
57
|
fen,
|
|
56
|
-
players: {},
|
|
57
58
|
});
|
|
58
59
|
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chessboard
|
|
3
|
-
} from "./chunk-MABHE5SS.mjs";
|
|
4
|
-
import {
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-H3NUMCQ6.mjs";
|
|
7
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
8
|
-
|
|
9
|
-
// src/components/ChessboardContainer.tsx
|
|
10
|
-
import React2 from "react";
|
|
11
|
-
import { Obj } from "@dxos/echo";
|
|
12
|
-
|
|
13
|
-
// src/components/ChessboardArticle.tsx
|
|
14
|
-
import React, { useCallback, useRef, useState } from "react";
|
|
15
|
-
import { Layout, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
16
|
-
import { mx } from "@dxos/ui-theme";
|
|
17
|
-
var ChessboardArticle = ({ role, subject: game }) => {
|
|
18
|
-
const { t } = useTranslation(meta.id);
|
|
19
|
-
const [orientation, setOrientation] = useState("white");
|
|
20
|
-
const [open, setOpen] = useState(true);
|
|
21
|
-
const controller = useRef(null);
|
|
22
|
-
const handleSelect = useCallback((index) => {
|
|
23
|
-
controller.current?.setMoveNumber(index);
|
|
24
|
-
}, []);
|
|
25
|
-
return /* @__PURE__ */ React.createElement(Layout.Main, {
|
|
26
|
-
toolbar: true,
|
|
27
|
-
classNames: "@container"
|
|
28
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
29
|
-
game,
|
|
30
|
-
ref: controller
|
|
31
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
32
|
-
icon: "ph--info--regular",
|
|
33
|
-
iconOnly: true,
|
|
34
|
-
label: t("toggle info button"),
|
|
35
|
-
disabled: open,
|
|
36
|
-
classNames: mx("invisible @3xl:visible"),
|
|
37
|
-
onClick: () => setOpen((open2) => !open2)
|
|
38
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
39
|
-
className: mx("grid bs-full is-full gap-2", open && "@3xl:grid-cols-[1fr_320px]", role === "section" && "aspect-square", role === "section" && open && "@3xl:aspect-auto")
|
|
40
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
41
|
-
classNames: "m-4 rounded-sm overflow-hidden",
|
|
42
|
-
orientation
|
|
43
|
-
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
44
|
-
className: "hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden"
|
|
45
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
46
|
-
orientation,
|
|
47
|
-
min: 8,
|
|
48
|
-
max: 8,
|
|
49
|
-
onOrientationChange: setOrientation,
|
|
50
|
-
onClose: () => setOpen(false),
|
|
51
|
-
onSelect: handleSelect
|
|
52
|
-
})))));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// src/components/ChessboardContainer.tsx
|
|
56
|
-
var ChessboardContainer = ({ role, subject: game }) => {
|
|
57
|
-
const db = Obj.getDatabase(game);
|
|
58
|
-
if (!db) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
switch (role) {
|
|
62
|
-
case "card--content": {
|
|
63
|
-
return /* @__PURE__ */ React2.createElement(Chessboard.Root, {
|
|
64
|
-
game
|
|
65
|
-
}, /* @__PURE__ */ React2.createElement(Chessboard.Content, null, /* @__PURE__ */ React2.createElement(Chessboard.Board, null)));
|
|
66
|
-
}
|
|
67
|
-
default: {
|
|
68
|
-
return /* @__PURE__ */ React2.createElement(ChessboardArticle, {
|
|
69
|
-
role,
|
|
70
|
-
subject: game
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var ChessboardContainer_default = ChessboardContainer;
|
|
76
|
-
export {
|
|
77
|
-
ChessboardContainer,
|
|
78
|
-
ChessboardContainer_default as default
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=ChessboardContainer-GNSIZKY7.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 { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';\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-toolkit/ui';\nimport { Layout, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\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,QAAQC,SAASC,sBAAsB;AAEhD,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;;;ADrDO,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", "Layout", "Toolbar", "useTranslation", "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,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
chess_blueprint_exports
|
|
3
|
-
} from "./chunk-PBRN5Q4R.mjs";
|
|
4
|
-
import "./chunk-66H3V2YV.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 } from "@dxos/app-framework";
|
|
10
|
-
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
11
|
-
var blueprintDefinition = Capability.makeModule(() => Effect.succeed([
|
|
12
|
-
Capability.contributes(AppCapabilities.Functions, chess_blueprint_exports.functions),
|
|
13
|
-
Capability.contributes(AppCapabilities.BlueprintDefinition, chess_blueprint_exports.make())
|
|
14
|
-
]));
|
|
15
|
-
var blueprint_definition_default = blueprintDefinition;
|
|
16
|
-
export {
|
|
17
|
-
blueprint_definition_default as default
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=blueprint-definition-YUKJZPOL.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 } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\n\nimport { ChessBlueprint } from '../../blueprints';\n\nexport type BlueprintCapabilities = [\n Capability.Capability<typeof AppCapabilities.Functions>,\n Capability.Capability<typeof AppCapabilities.BlueprintDefinition>,\n];\n\nconst blueprintDefinition = Capability.makeModule<[], BlueprintCapabilities>(() =>\n Effect.succeed([\n Capability.contributes(AppCapabilities.Functions, ChessBlueprint.functions),\n Capability.contributes(AppCapabilities.BlueprintDefinition, ChessBlueprint.make()),\n ]),\n);\n\nexport default blueprintDefinition;\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB;AAShC,IAAMC,sBAAsBC,WAAWC,WAAsC,MACpEC,eAAQ;EACbF,WAAWG,YAAYC,gBAAgBC,WAAWC,wBAAeC,SAAS;EAC1EP,WAAWG,YAAYC,gBAAgBI,qBAAqBF,wBAAeG,KAAI,CAAA;CAChF,CAAA;AAGH,IAAA,+BAAeV;",
|
|
6
|
-
"names": ["Effect", "Capability", "AppCapabilities", "blueprintDefinition", "Capability", "makeModule", "succeed", "contributes", "AppCapabilities", "Functions", "ChessBlueprint", "functions", "BlueprintDefinition", "make"]
|
|
7
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__export
|
|
3
|
-
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
-
|
|
5
|
-
// src/types/Chess.ts
|
|
6
|
-
var Chess_exports = {};
|
|
7
|
-
__export(Chess_exports, {
|
|
8
|
-
Game: () => Game,
|
|
9
|
-
make: () => make
|
|
10
|
-
});
|
|
11
|
-
import { Chess as ChessJS } from "chess.js";
|
|
12
|
-
import * as Schema from "effect/Schema";
|
|
13
|
-
import { Obj, Type } from "@dxos/echo";
|
|
14
|
-
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
15
|
-
import { log } from "@dxos/log";
|
|
16
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
|
|
17
|
-
var Game = Schema.Struct({
|
|
18
|
-
name: Schema.optional(Schema.String),
|
|
19
|
-
players: Schema.Struct({
|
|
20
|
-
white: Schema.optional(Schema.String.annotations({
|
|
21
|
-
description: "DID of white player"
|
|
22
|
-
})),
|
|
23
|
-
black: Schema.optional(Schema.String.annotations({
|
|
24
|
-
description: "DID of black player"
|
|
25
|
-
}))
|
|
26
|
-
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
27
|
-
pgn: Schema.String.annotations({
|
|
28
|
-
description: "Portable Game Notation."
|
|
29
|
-
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
30
|
-
fen: Schema.String.annotations({
|
|
31
|
-
description: "Forsyth-Edwards Notation."
|
|
32
|
-
}).pipe(FormInputAnnotation.set(false), Schema.optional)
|
|
33
|
-
}).pipe(Type.object({
|
|
34
|
-
typename: "dxos.org/type/Chess",
|
|
35
|
-
version: "0.2.0"
|
|
36
|
-
}), LabelAnnotation.set([
|
|
37
|
-
"name"
|
|
38
|
-
]));
|
|
39
|
-
var make = ({ name, pgn, fen } = {}) => {
|
|
40
|
-
const chess = new ChessJS();
|
|
41
|
-
if (pgn) {
|
|
42
|
-
try {
|
|
43
|
-
chess.loadPgn(pgn);
|
|
44
|
-
} catch {
|
|
45
|
-
log.warn(pgn, void 0, {
|
|
46
|
-
F: __dxlog_file,
|
|
47
|
-
L: 48,
|
|
48
|
-
S: void 0,
|
|
49
|
-
C: (f, a) => f(...a)
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return Obj.make(Game, {
|
|
54
|
-
name,
|
|
55
|
-
pgn,
|
|
56
|
-
fen,
|
|
57
|
-
players: {}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
Chess_exports
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=chunk-66H3V2YV.mjs.map
|
|
@@ -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(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,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDS,KAAYR,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDU,KAAYT,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;AACzD,CAAA,EAAGO,KACDd,KAAKkB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAlB,gBAAgBa,IAAI;EAAC;CAAO,CAAA;AAKvB,IAAMM,OAAO,CAAC,EAAEf,MAAMU,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMK,QAAQ,IAAIzB,QAAAA;AAClB,MAAImB,KAAK;AACP,QAAI;AACFM,YAAMC,QAAQP,GAAAA;IAChB,QAAQ;AACNb,UAAIqB,KAAKR,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOjB,IAAIsB,KAAKjB,MAAM;IACpBE;IACAU;IACAC;IACAR,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", "set", "pgn", "fen", "object", "typename", "version", "make", "chess", "loadPgn", "warn"]
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
import { trim } from "@dxos/util";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: "dxos.org/plugin/chess",
|
|
5
|
-
name: "Chess",
|
|
6
|
-
description: trim`
|
|
7
|
-
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
8
|
-
Track game history and analyze moves in real-time.
|
|
9
|
-
`,
|
|
10
|
-
icon: "ph--shield-chevron--regular",
|
|
11
|
-
iconHue: "amber",
|
|
12
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
13
|
-
screenshots: [
|
|
14
|
-
"https://dxos.network/plugin-details-chess-dark.png"
|
|
15
|
-
]
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
meta
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=chunk-H3NUMCQ6.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/chess',\n name: 'Chess',\n description: trim`\n Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.\n Track game history and analyze moves in real-time.\n `,\n icon: 'ph--shield-chevron--regular',\n iconHue: 'amber',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',\n screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,aAAa;IAAC;;AAChB;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "screenshots"]
|
|
7
|
-
}
|