@dxos/plugin-chess 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0
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 +14 -0
- package/dist/lib/browser/{chunk-CCF24VRU.mjs → chunk-2TJN26DN.mjs} +18 -34
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-MC7L6JNC.mjs +36 -0
- package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +7 -0
- package/dist/lib/browser/chunk-SBRUTOHG.mjs +28 -0
- package/dist/lib/browser/chunk-SBRUTOHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-XAJZK6Z2.mjs +110 -0
- package/dist/lib/browser/chunk-XAJZK6Z2.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +34 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/create-AJHN4QT4.mjs +24 -0
- package/dist/lib/browser/create-AJHN4QT4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +364 -99
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/move-CN7BGBOR.mjs +36 -0
- package/dist/lib/browser/move-CN7BGBOR.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +19 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/play-YRKSZF5U.mjs +45 -0
- package/dist/lib/browser/play-YRKSZF5U.mjs.map +7 -0
- package/dist/lib/browser/print-EW7LPW4D.mjs +30 -0
- package/dist/lib/browser/print-EW7LPW4D.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/node-esm/blueprints/index.mjs +15 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs +38 -0
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7W2LXAM5.mjs +29 -0
- package/dist/lib/node-esm/chunk-7W2LXAM5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NYU5JVXP.mjs +111 -0
- package/dist/lib/node-esm/chunk-NYU5JVXP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKXLEJNZ.mjs → chunk-OIRJVY2R.mjs} +18 -34
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +35 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-QSETDT4N.mjs +25 -0
- package/dist/lib/node-esm/create-QSETDT4N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +364 -99
- 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-OTEYBHVI.mjs +37 -0
- package/dist/lib/node-esm/move-OTEYBHVI.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +20 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/play-ZLDAXADK.mjs +46 -0
- package/dist/lib/node-esm/play-ZLDAXADK.mjs.map +7 -0
- package/dist/lib/node-esm/print-UJHXAXMS.mjs +31 -0
- package/dist/lib/node-esm/print-UJHXAXMS.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -5
- package/dist/types/src/ChessPlugin.d.ts +2 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- 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 +3 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -4
- 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/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +4 -8
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +48 -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} +1 -1
- 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 +6 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +47 -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 +6 -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} +2 -9
- 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/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +51 -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 +21 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +17 -17
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +74 -43
- package/src/ChessPlugin.tsx +41 -47
- package/src/blueprints/chess-blueprint.ts +35 -0
- package/src/blueprints/index.ts +6 -0
- package/src/capabilities/artifact-definition.ts +98 -92
- package/src/capabilities/blueprint-definition.ts +9 -28
- package/src/capabilities/index.ts +8 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/react-surface.tsx +27 -15
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +37 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +32 -29
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +41 -24
- 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 +53 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +73 -0
- package/src/containers/ChessArticle/index.ts +5 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +42 -0
- package/src/containers/ChessCard/ChessCard.tsx +22 -0
- package/src/containers/ChessCard/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +2 -3
- package/src/meta.ts +3 -3
- package/src/operations/create.ts +21 -0
- package/src/operations/definitions.ts +109 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/move.ts +36 -0
- package/src/operations/play.ts +45 -0
- package/src/operations/print.ts +28 -0
- package/src/translations.ts +21 -20
- package/src/types/Chess.ts +11 -7
- package/src/types/index.ts +0 -1
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs +0 -96
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-Y5Y4YGNL.mjs +0 -11
- package/dist/lib/browser/chunk-3LPE2B5J.mjs +0 -169
- package/dist/lib/browser/chunk-3LPE2B5J.mjs.map +0 -7
- package/dist/lib/browser/chunk-5DOZV3PW.mjs +0 -294
- package/dist/lib/browser/chunk-5DOZV3PW.mjs.map +0 -7
- package/dist/lib/browser/chunk-CCF24VRU.mjs.map +0 -7
- package/dist/lib/browser/chunk-DUO4WTAM.mjs +0 -28
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs +0 -8
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KPGHK5JU.mjs +0 -25
- package/dist/lib/browser/intent-resolver-KPGHK5JU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-3YST34QI.mjs +0 -38
- package/dist/lib/browser/react-surface-3YST34QI.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs +0 -97
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-GR6OLMB6.mjs +0 -12
- package/dist/lib/node-esm/chunk-F3HFLDV5.mjs +0 -170
- package/dist/lib/node-esm/chunk-F3HFLDV5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs +0 -295
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs +0 -29
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKXLEJNZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VVXTAVIS.mjs +0 -10
- package/dist/lib/node-esm/chunk-VVXTAVIS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-ZAELGF7I.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-ZAELGF7I.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-KV2KBSIU.mjs +0 -39
- package/dist/lib/node-esm/react-surface-KV2KBSIU.mjs.map +0 -7
- 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/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 -7
- 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/Info.d.ts.map +0 -1
- package/dist/types/src/functions/create.d.ts +0 -14
- package/dist/types/src/functions/create.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/move.d.ts +0 -8
- package/dist/types/src/functions/move.d.ts.map +0 -1
- package/dist/types/src/functions/play.d.ts +0 -9
- package/dist/types/src/functions/play.d.ts.map +0 -1
- package/dist/types/src/types/ChessAction.d.ts +0 -24
- package/dist/types/src/types/ChessAction.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -22
- package/src/components/Card.stories.tsx +0 -66
- package/src/components/Chessboard.stories.tsx +0 -49
- package/src/components/ChessboardArticle.tsx +0 -68
- package/src/components/ChessboardContainer.tsx +0 -44
- package/src/functions/create.ts +0 -32
- package/src/functions/index.ts +0 -7
- package/src/functions/move.ts +0 -45
- package/src/functions/play.ts +0 -55
- package/src/types/ChessAction.ts +0 -19
- /package/dist/lib/browser/{blueprint-definition-Y5Y4YGNL.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-GR6OLMB6.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
8
|
-
|
|
9
|
-
import { type Chess } from '../types';
|
|
10
|
-
|
|
11
|
-
import { Chessboard } from './Chessboard';
|
|
12
|
-
import { ChessboardArticle } from './ChessboardArticle';
|
|
13
|
-
|
|
14
|
-
export type ChessboardContainerProps = {
|
|
15
|
-
game: Chess.Game;
|
|
16
|
-
role?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const ChessboardContainer = ({ game, role }: ChessboardContainerProps) => {
|
|
20
|
-
const space = getSpace(game);
|
|
21
|
-
if (!space) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
switch (role) {
|
|
26
|
-
case 'card--popover':
|
|
27
|
-
case 'card--intrinsic':
|
|
28
|
-
case 'card--extrinsic': {
|
|
29
|
-
return (
|
|
30
|
-
<Chessboard.Root game={game}>
|
|
31
|
-
<Chessboard.Content role={role}>
|
|
32
|
-
<Chessboard.Board />
|
|
33
|
-
</Chessboard.Content>
|
|
34
|
-
</Chessboard.Root>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
default: {
|
|
39
|
-
return <ChessboardArticle game={game} role={role} />;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default ChessboardContainer;
|
package/src/functions/create.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
import * as Schema from 'effect/Schema';
|
|
7
|
-
|
|
8
|
-
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
9
|
-
|
|
10
|
-
import { Chess } from '../types';
|
|
11
|
-
|
|
12
|
-
export default defineFunction({
|
|
13
|
-
key: 'dxos.org/function/chess/create',
|
|
14
|
-
name: 'Create Chess',
|
|
15
|
-
description: 'Creates a new chess game.',
|
|
16
|
-
inputSchema: Schema.Struct({
|
|
17
|
-
pgn: Schema.optional(
|
|
18
|
-
Schema.String.annotations({
|
|
19
|
-
description: 'Portable Game Notation.',
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
fen: Schema.optional(
|
|
23
|
-
Schema.String.annotations({
|
|
24
|
-
description: 'Forsyth-Edwards Notation.',
|
|
25
|
-
}),
|
|
26
|
-
),
|
|
27
|
-
}),
|
|
28
|
-
outputSchema: Chess.Game,
|
|
29
|
-
handler: Effect.fn(function* ({ data: { pgn, fen } }) {
|
|
30
|
-
return yield* DatabaseService.add(Chess.makeGame({ pgn, fen }));
|
|
31
|
-
}),
|
|
32
|
-
});
|
package/src/functions/index.ts
DELETED
package/src/functions/move.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
-
import * as Effect from 'effect/Effect';
|
|
7
|
-
import * as Schema from 'effect/Schema';
|
|
8
|
-
|
|
9
|
-
import { ArtifactId } from '@dxos/assistant';
|
|
10
|
-
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
11
|
-
|
|
12
|
-
import { Chess } from '../types';
|
|
13
|
-
|
|
14
|
-
export default defineFunction({
|
|
15
|
-
key: 'dxos.org/function/chess/move',
|
|
16
|
-
name: 'Move',
|
|
17
|
-
description: 'Makes a move in the given chess game.',
|
|
18
|
-
inputSchema: Schema.Struct({
|
|
19
|
-
id: ArtifactId.annotations({
|
|
20
|
-
description: 'The ID of the chess object.',
|
|
21
|
-
}),
|
|
22
|
-
move: Schema.String.annotations({
|
|
23
|
-
description: 'The move to make in the chess game.',
|
|
24
|
-
examples: ['e4', 'Bf3'],
|
|
25
|
-
}),
|
|
26
|
-
}),
|
|
27
|
-
outputSchema: Schema.Struct({
|
|
28
|
-
pgn: Schema.String.annotations({
|
|
29
|
-
description: 'The PGN of the game after the move was played.',
|
|
30
|
-
}),
|
|
31
|
-
}),
|
|
32
|
-
handler: Effect.fn(function* ({ data: { id, move } }) {
|
|
33
|
-
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Chess.Game);
|
|
34
|
-
const chess = new ChessJS();
|
|
35
|
-
if (object.pgn) {
|
|
36
|
-
chess.loadPgn(object.pgn);
|
|
37
|
-
} else if (object.fen) {
|
|
38
|
-
chess.load(object.fen);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
chess.move(move, { strict: false });
|
|
42
|
-
object.pgn = chess.pgn();
|
|
43
|
-
return { pgn: object.pgn };
|
|
44
|
-
}),
|
|
45
|
-
});
|
package/src/functions/play.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
-
import * as Effect from 'effect/Effect';
|
|
7
|
-
import * as Schema from 'effect/Schema';
|
|
8
|
-
|
|
9
|
-
import { ArtifactId } from '@dxos/assistant';
|
|
10
|
-
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
11
|
-
|
|
12
|
-
import { Chess } from '../types';
|
|
13
|
-
|
|
14
|
-
export default defineFunction({
|
|
15
|
-
key: 'dxos.org/function/chess/play',
|
|
16
|
-
name: 'Play',
|
|
17
|
-
description: 'Uses the chess engine to play the next move.',
|
|
18
|
-
inputSchema: Schema.Struct({
|
|
19
|
-
id: ArtifactId.annotations({
|
|
20
|
-
description: 'The ID of the chess object.',
|
|
21
|
-
}),
|
|
22
|
-
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
23
|
-
description: 'The side to play.',
|
|
24
|
-
defaultValue: 'any',
|
|
25
|
-
}),
|
|
26
|
-
}),
|
|
27
|
-
outputSchema: Schema.Struct({
|
|
28
|
-
pgn: Schema.String.annotations({
|
|
29
|
-
description: 'The PGN of the game after the move was played.',
|
|
30
|
-
}),
|
|
31
|
-
move: Schema.optional(Schema.String).annotations({
|
|
32
|
-
description: 'The move that was played.',
|
|
33
|
-
}),
|
|
34
|
-
}),
|
|
35
|
-
handler: Effect.fn(function* ({ data: { id, side = 'any' } }) {
|
|
36
|
-
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Chess.Game);
|
|
37
|
-
const chess = new ChessJS();
|
|
38
|
-
if (object.pgn) {
|
|
39
|
-
chess.loadPgn(object.pgn);
|
|
40
|
-
} else if (object.fen) {
|
|
41
|
-
chess.load(object.fen);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))) {
|
|
45
|
-
return { move: undefined, pgn: object.pgn! };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const moves = chess.moves();
|
|
49
|
-
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
50
|
-
|
|
51
|
-
chess.move(move, { strict: false });
|
|
52
|
-
object.pgn = chess.pgn();
|
|
53
|
-
return { move, pgn: object.pgn };
|
|
54
|
-
}),
|
|
55
|
-
});
|
package/src/types/ChessAction.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { meta } from '../meta';
|
|
8
|
-
|
|
9
|
-
import { Game } from './Chess';
|
|
10
|
-
|
|
11
|
-
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
12
|
-
input: Schema.Struct({
|
|
13
|
-
name: Schema.optional(Schema.String),
|
|
14
|
-
pgn: Schema.optional(Schema.String),
|
|
15
|
-
}),
|
|
16
|
-
output: Schema.Struct({
|
|
17
|
-
object: Game,
|
|
18
|
-
}),
|
|
19
|
-
}) {}
|
/package/dist/lib/browser/{blueprint-definition-Y5Y4YGNL.mjs.map → blueprints/index.mjs.map}
RENAMED
|
File without changes
|
/package/dist/lib/{node-esm/blueprint-definition-GR6OLMB6.mjs.map → browser/chunk-J5LGTIGS.mjs.map}
RENAMED
|
File without changes
|