@dxos/plugin-chess 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
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/neutral/ChessArticle-QLLKZGPH.mjs +88 -0
- package/dist/lib/neutral/ChessArticle-QLLKZGPH.mjs.map +7 -0
- package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs +19 -0
- package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.mjs +30 -0
- package/dist/lib/neutral/ChessPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-PZXHAYLD.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-PZXHAYLD.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-5UOTTW6U.mjs +8 -0
- package/dist/lib/neutral/chunk-5UOTTW6U.mjs.map +7 -0
- package/dist/lib/neutral/chunk-E4LZPHAQ.mjs +148 -0
- package/dist/lib/neutral/chunk-E4LZPHAQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FFXSIHW6.mjs +21 -0
- package/dist/lib/neutral/chunk-FFXSIHW6.mjs.map +7 -0
- package/dist/lib/{browser/chunk-MC7L6JNC.mjs → neutral/chunk-XWKNXG62.mjs} +8 -10
- package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
- package/dist/lib/{browser → neutral/components}/index.mjs +8 -158
- 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-24UKIBRM.mjs +40 -0
- package/dist/lib/neutral/game-variant-24UKIBRM.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +18 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/move-RQZ7BJY3.mjs +37 -0
- package/dist/lib/neutral/move-RQZ7BJY3.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/{browser/types → neutral/operations}/index.mjs +3 -3
- package/dist/lib/neutral/play-GDGCEPQL.mjs +46 -0
- package/dist/lib/neutral/play-GDGCEPQL.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/print-EW7LPW4D.mjs → neutral/print-ZQA74KZI.mjs} +5 -6
- package/dist/lib/neutral/print-ZQA74KZI.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +34 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- 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/blueprints/chess-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +0 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +2 -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 +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +6 -2
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +32 -23
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Info.d.ts +4 -5
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/types.d.ts +2 -2
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +3 -4
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +32 -23
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +3 -4
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +2 -3
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/move.d.ts +3 -3
- package/dist/types/src/operations/move.d.ts.map +1 -1
- package/dist/types/src/operations/play.d.ts +3 -3
- package/dist/types/src/operations/play.d.ts.map +1 -1
- package/dist/types/src/operations/print.d.ts +3 -3
- package/dist/types/src/operations/print.d.ts.map +1 -1
- package/dist/types/src/{cli/plugin.d.ts → plugin.d.ts} +1 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -24
- 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/src/types/ChessOperation.d.ts +24 -0
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +91 -68
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +8 -10
- package/src/ChessPlugin.tsx +11 -34
- package/src/blueprints/chess-blueprint.ts +6 -9
- package/src/blueprints/index.ts +0 -1
- package/src/capabilities/blueprint-definition.ts +2 -0
- package/src/capabilities/game-variant.ts +42 -0
- package/src/capabilities/index.ts +3 -2
- package/src/capabilities/operation-handler.ts +3 -3
- package/src/components/Chessboard/Chessboard.stories.tsx +3 -3
- package/src/components/Chessboard/Chessboard.tsx +4 -4
- package/src/components/Chessboard/Info.tsx +3 -63
- package/src/components/Chessboard/types.ts +1 -1
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +9 -3
- package/src/containers/ChessArticle/ChessArticle.tsx +45 -10
- package/src/containers/ChessCard/ChessCard.stories.tsx +7 -2
- package/src/containers/ChessCard/ChessCard.tsx +10 -5
- package/src/index.ts +0 -3
- package/src/operations/index.ts +2 -7
- package/src/operations/move.ts +13 -13
- package/src/operations/play.ts +14 -14
- package/src/operations/print.ts +3 -3
- package/src/plugin.ts +11 -0
- package/src/translations.ts +6 -10
- package/src/types/Chess.ts +19 -22
- package/src/{operations/definitions.ts → types/ChessOperation.ts} +10 -34
- package/src/types/index.ts +1 -0
- package/dist/lib/browser/blueprints/index.mjs +0 -14
- package/dist/lib/browser/chunk-2TJN26DN.mjs +0 -67
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +0 -7
- package/dist/lib/browser/chunk-JZMN24DY.mjs +0 -28
- package/dist/lib/browser/chunk-JZMN24DY.mjs.map +0 -7
- package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +0 -7
- package/dist/lib/browser/chunk-XAJZK6Z2.mjs +0 -110
- package/dist/lib/browser/chunk-XAJZK6Z2.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -34
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-AJHN4QT4.mjs +0 -24
- package/dist/lib/browser/create-AJHN4QT4.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/move-T2NLRBR4.mjs +0 -36
- package/dist/lib/browser/move-T2NLRBR4.mjs.map +0 -7
- package/dist/lib/browser/operations/index.mjs +0 -19
- package/dist/lib/browser/play-7VTMD3SJ.mjs +0 -45
- package/dist/lib/browser/play-7VTMD3SJ.mjs.map +0 -7
- package/dist/lib/browser/print-EW7LPW4D.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -15
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs +0 -38
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LQEDIKCV.mjs +0 -29
- package/dist/lib/node-esm/chunk-LQEDIKCV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYU5JVXP.mjs +0 -111
- package/dist/lib/node-esm/chunk-NYU5JVXP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs +0 -68
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -35
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/create-QSETDT4N.mjs +0 -25
- package/dist/lib/node-esm/create-QSETDT4N.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -390
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/move-5F2ANDTE.mjs +0 -37
- package/dist/lib/node-esm/move-5F2ANDTE.mjs.map +0 -7
- package/dist/lib/node-esm/operations/index.mjs +0 -20
- package/dist/lib/node-esm/play-W4DQCQRX.mjs +0 -46
- package/dist/lib/node-esm/play-W4DQCQRX.mjs.map +0 -7
- package/dist/lib/node-esm/print-UJHXAXMS.mjs +0 -31
- package/dist/lib/node-esm/print-UJHXAXMS.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -9
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -12
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/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.map +0 -1
- package/dist/types/src/operations/create.d.ts +0 -5
- package/dist/types/src/operations/create.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts +0 -51
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -135
- package/src/capabilities/react-surface.tsx +0 -35
- package/src/cli/index.ts +0 -5
- package/src/cli/plugin.ts +0 -37
- package/src/operations/create.ts +0 -21
- /package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/operations → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprints → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/operations → neutral/types}/index.mjs.map +0 -0
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
5
6
|
import React, { useCallback, useRef, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { type GameVariantSurfaceProps } from '@dxos/plugin-game';
|
|
8
10
|
import { Panel, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
11
|
import { type Player } from '@dxos/react-ui-gameboard';
|
|
10
12
|
import { mx } from '@dxos/ui-theme';
|
|
11
13
|
|
|
12
14
|
import { Chessboard, type ChessboardController, type ChessboardInfoProps } from '#components';
|
|
13
15
|
import { meta } from '#meta';
|
|
14
|
-
import {
|
|
16
|
+
import { Chess } from '#types';
|
|
15
17
|
|
|
16
|
-
export type ChessArticleProps =
|
|
18
|
+
export type ChessArticleProps = GameVariantSurfaceProps;
|
|
17
19
|
|
|
18
|
-
export const ChessArticle = ({ role,
|
|
20
|
+
export const ChessArticle = ({ role, variant }: ChessArticleProps) => {
|
|
19
21
|
const { t } = useTranslation(meta.id);
|
|
20
22
|
const [orientation, setOrientation] = useState<Player>('white');
|
|
21
23
|
const [showInfo, setShowInfo] = useState(true);
|
|
@@ -25,17 +27,50 @@ export const ChessArticle = ({ role, attendableId: _attendableId, subject: game
|
|
|
25
27
|
controller.current?.setMoveNumber(index);
|
|
26
28
|
}, []);
|
|
27
29
|
|
|
30
|
+
const isGameOver = (() => {
|
|
31
|
+
if (!Obj.instanceOf(Chess.State, variant) || (!variant.pgn && !variant.fen)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const chess = new ChessJS();
|
|
36
|
+
if (variant.pgn) {
|
|
37
|
+
chess.loadPgn(variant.pgn);
|
|
38
|
+
} else if (variant.fen) {
|
|
39
|
+
chess.load(variant.fen);
|
|
40
|
+
}
|
|
41
|
+
return chess.isGameOver();
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
|
|
47
|
+
const handleNewGame = useCallback(() => {
|
|
48
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
Obj.update(variant, (variant) => {
|
|
52
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
53
|
+
mutable.pgn = undefined;
|
|
54
|
+
mutable.fen = undefined;
|
|
55
|
+
});
|
|
56
|
+
}, [variant]);
|
|
57
|
+
|
|
58
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
28
62
|
return (
|
|
29
|
-
<Chessboard.Root
|
|
63
|
+
<Chessboard.Root state={variant} ref={controller}>
|
|
30
64
|
<Panel.Root role={role} classNames='@container'>
|
|
31
65
|
<Panel.Toolbar asChild>
|
|
32
66
|
<Toolbar.Root>
|
|
67
|
+
{isGameOver && <Toolbar.Button onClick={handleNewGame}>{t('new-game.button')}</Toolbar.Button>}
|
|
68
|
+
<div className='grow' />
|
|
33
69
|
<Toolbar.IconButton
|
|
34
70
|
icon='ph--info--regular'
|
|
35
71
|
iconOnly
|
|
36
72
|
label={t('toggle-info.button')}
|
|
37
|
-
|
|
38
|
-
classNames={mx('invisible @3xl:visible')}
|
|
73
|
+
classNames={mx('invisible @4xl:visible')}
|
|
39
74
|
onClick={() => setShowInfo((open) => !open)}
|
|
40
75
|
/>
|
|
41
76
|
</Toolbar.Root>
|
|
@@ -44,17 +79,17 @@ export const ChessArticle = ({ role, attendableId: _attendableId, subject: game
|
|
|
44
79
|
<div
|
|
45
80
|
className={mx(
|
|
46
81
|
'grid h-full w-full',
|
|
47
|
-
showInfo && '@
|
|
82
|
+
showInfo && '@4xl:grid-cols-[1fr_320px] gap-8',
|
|
48
83
|
role === 'article' && 'p-4',
|
|
49
84
|
role === 'section' && 'aspect-square',
|
|
50
|
-
role === 'section' && showInfo && '@
|
|
85
|
+
role === 'section' && showInfo && '@4xl:aspect-auto',
|
|
51
86
|
)}
|
|
52
87
|
>
|
|
53
88
|
<Chessboard.Content>
|
|
54
89
|
<Chessboard.Board classNames='border rounded-xs' orientation={orientation} />
|
|
55
90
|
</Chessboard.Content>
|
|
56
91
|
{showInfo && (
|
|
57
|
-
<div className='hidden @
|
|
92
|
+
<div className='hidden @4xl:flex flex-col justify-center items-center overflow-hidden'>
|
|
58
93
|
<Chessboard.Info
|
|
59
94
|
orientation={orientation}
|
|
60
95
|
min={8}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { make as makeGame } from '@dxos/plugin-game';
|
|
8
9
|
import { CardContainer } from '@dxos/react-ui-mosaic/testing';
|
|
9
10
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
11
|
|
|
@@ -17,10 +18,14 @@ const SAMPLE_PGN =
|
|
|
17
18
|
'1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *';
|
|
18
19
|
|
|
19
20
|
const CardStory = () => {
|
|
20
|
-
const game = useMemo(() =>
|
|
21
|
+
const { game, state } = useMemo(() => {
|
|
22
|
+
const state = Chess.make({ pgn: SAMPLE_PGN });
|
|
23
|
+
const game = makeGame({ name: 'Story game', variant: state });
|
|
24
|
+
return { game, state };
|
|
25
|
+
}, []);
|
|
21
26
|
return (
|
|
22
27
|
<CardContainer role='popover' icon={pluginMeta.icon}>
|
|
23
|
-
<ChessCard
|
|
28
|
+
<ChessCard role='card--content' game={game} variant={state} />
|
|
24
29
|
</CardContainer>
|
|
25
30
|
);
|
|
26
31
|
};
|
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Obj } from '@dxos/echo';
|
|
8
|
+
import { type GameVariantSurfaceProps } from '@dxos/plugin-game';
|
|
8
9
|
|
|
9
10
|
import { Chessboard } from '#components';
|
|
10
|
-
import {
|
|
11
|
+
import { Chess } from '#types';
|
|
11
12
|
|
|
12
|
-
export type ChessCardProps =
|
|
13
|
+
export type ChessCardProps = GameVariantSurfaceProps;
|
|
14
|
+
|
|
15
|
+
export const ChessCard = ({ variant }: ChessCardProps) => {
|
|
16
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
13
19
|
|
|
14
|
-
export const ChessCard = ({ subject: game }: ChessCardProps) => {
|
|
15
20
|
return (
|
|
16
|
-
<Chessboard.Root
|
|
21
|
+
<Chessboard.Root state={variant}>
|
|
17
22
|
<Chessboard.Content>
|
|
18
23
|
<Chessboard.Board />
|
|
19
24
|
</Chessboard.Content>
|
package/src/index.ts
CHANGED
package/src/operations/index.ts
CHANGED
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { OperationHandlerSet } from '@dxos/
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
() => import('./create'),
|
|
7
|
+
export const ChessOperationHandlerSet = OperationHandlerSet.lazy(
|
|
9
8
|
() => import('./move'),
|
|
10
9
|
() => import('./play'),
|
|
11
10
|
() => import('./print'),
|
|
12
11
|
);
|
|
13
|
-
|
|
14
|
-
export { Create, Move, Play, Print } from './definitions';
|
|
15
|
-
|
|
16
|
-
export const ChessHandlers = Handlers;
|
package/src/operations/move.ts
CHANGED
|
@@ -5,28 +5,28 @@
|
|
|
5
5
|
import { Chess as ChessJS } from 'chess.js';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { loadGame } from '@dxos/plugin-game';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
import { Move } from './definitions';
|
|
12
|
+
import { Chess, ChessOperation } from '../types';
|
|
13
13
|
|
|
14
|
-
const handler: Operation.WithHandler<typeof Move> = Move.pipe(
|
|
14
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Move> = ChessOperation.Move.pipe(
|
|
15
15
|
Operation.withHandler(
|
|
16
16
|
Effect.fn(function* ({ game, move }) {
|
|
17
|
-
const
|
|
17
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
18
18
|
const chess = new ChessJS();
|
|
19
|
-
if (
|
|
20
|
-
chess.loadPgn(
|
|
21
|
-
} else if (
|
|
22
|
-
chess.load(
|
|
19
|
+
if (variant.pgn) {
|
|
20
|
+
chess.loadPgn(variant.pgn);
|
|
21
|
+
} else if (variant.fen) {
|
|
22
|
+
chess.load(variant.fen);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
chess.move(move, { strict: false });
|
|
26
26
|
const pgn = chess.pgn();
|
|
27
|
-
Obj.
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
Obj.update(variant, (variant) => {
|
|
28
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
29
|
+
mutable.pgn = pgn;
|
|
30
30
|
});
|
|
31
31
|
return { pgn };
|
|
32
32
|
}),
|
package/src/operations/play.ts
CHANGED
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
import { Chess as ChessJS } from 'chess.js';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { loadGame } from '@dxos/plugin-game';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
import { Play } from './definitions';
|
|
12
|
+
import { Chess, ChessOperation } from '../types';
|
|
13
13
|
|
|
14
|
-
const handler: Operation.WithHandler<typeof Play> = Play.pipe(
|
|
14
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Play> = ChessOperation.Play.pipe(
|
|
15
15
|
Operation.withHandler(
|
|
16
16
|
Effect.fn(function* ({ game, side = 'any' }) {
|
|
17
|
-
const
|
|
17
|
+
const { variant } = yield* loadGame(game, Chess.State);
|
|
18
18
|
const chess = new ChessJS();
|
|
19
|
-
if (
|
|
20
|
-
chess.loadPgn(
|
|
21
|
-
} else if (
|
|
22
|
-
chess.load(
|
|
19
|
+
if (variant.pgn) {
|
|
20
|
+
chess.loadPgn(variant.pgn);
|
|
21
|
+
} else if (variant.fen) {
|
|
22
|
+
chess.load(variant.fen);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (
|
|
26
26
|
!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))
|
|
27
27
|
) {
|
|
28
|
-
return { move: undefined, pgn:
|
|
28
|
+
return { move: undefined, pgn: variant.pgn ?? '' };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const moves = chess.moves();
|
|
@@ -33,9 +33,9 @@ const handler: Operation.WithHandler<typeof Play> = Play.pipe(
|
|
|
33
33
|
|
|
34
34
|
chess.move(move, { strict: false });
|
|
35
35
|
const pgn = chess.pgn();
|
|
36
|
-
Obj.
|
|
37
|
-
const
|
|
38
|
-
|
|
36
|
+
Obj.update(variant, (variant) => {
|
|
37
|
+
const mutable = variant as Obj.Mutable<typeof variant>;
|
|
38
|
+
mutable.pgn = pgn;
|
|
39
39
|
});
|
|
40
40
|
return { move, pgn };
|
|
41
41
|
}),
|
package/src/operations/print.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { Chess as ChessJS } from 'chess.js';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import { Operation } from '@dxos/
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { ChessOperation } from '../types';
|
|
11
11
|
|
|
12
|
-
const handler: Operation.WithHandler<typeof Print> = Print.pipe(
|
|
12
|
+
const handler: Operation.WithHandler<typeof ChessOperation.Print> = ChessOperation.Print.pipe(
|
|
13
13
|
Operation.withHandler(
|
|
14
14
|
Effect.fn(function* ({ pgn, fen }) {
|
|
15
15
|
try {
|
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/translations.ts
CHANGED
|
@@ -10,19 +10,15 @@ import { Chess } from '#types';
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[Chess.
|
|
14
|
-
'typename.label': '
|
|
15
|
-
'typename.label_zero': '
|
|
16
|
-
'typename.label_one': '
|
|
17
|
-
'typename.label_other': '
|
|
18
|
-
'object-name.placeholder': 'New game',
|
|
19
|
-
'add-object.label': 'Add game',
|
|
20
|
-
'rename-object.label': 'Rename game',
|
|
21
|
-
'delete-object.label': 'Delete game',
|
|
22
|
-
'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',
|
|
23
18
|
},
|
|
24
19
|
[meta.id]: {
|
|
25
20
|
'plugin.name': 'Chess',
|
|
21
|
+
'new-game.button': 'New game',
|
|
26
22
|
'delete-game.label': 'Delete',
|
|
27
23
|
'game.checkmate.label': 'Checkmate',
|
|
28
24
|
'game.stalemate.label': 'Stalemate',
|
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 { BlueprintsAnnotation } from '@dxos/app-toolkit';
|
|
8
9
|
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
9
|
-
import { FormInputAnnotation,
|
|
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,19 +25,24 @@ export const Game = Schema.Struct({
|
|
|
31
25
|
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
32
26
|
}).pipe(
|
|
33
27
|
Type.object({
|
|
34
|
-
typename: 'org.dxos.type.chess',
|
|
28
|
+
typename: 'org.dxos.type.chess.state',
|
|
35
29
|
version: '0.1.0',
|
|
36
30
|
}),
|
|
37
|
-
LabelAnnotation.set(['name']),
|
|
38
31
|
Annotation.IconAnnotation.set({
|
|
39
32
|
icon: 'ph--shield-chevron--regular',
|
|
40
33
|
hue: 'amber',
|
|
41
34
|
}),
|
|
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),
|
|
42
41
|
);
|
|
43
42
|
|
|
44
|
-
export interface
|
|
43
|
+
export interface State extends Schema.Schema.Type<typeof State> {}
|
|
45
44
|
|
|
46
|
-
export const make = ({
|
|
45
|
+
export const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {
|
|
47
46
|
const chess = new ChessJS();
|
|
48
47
|
if (pgn) {
|
|
49
48
|
try {
|
|
@@ -53,10 +52,8 @@ export const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: st
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
return Obj.make(
|
|
57
|
-
name,
|
|
55
|
+
return Obj.make(State, {
|
|
58
56
|
pgn,
|
|
59
57
|
fen,
|
|
60
|
-
players: {},
|
|
61
58
|
});
|
|
62
59
|
};
|
|
@@ -2,39 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
// @import-as-namespace
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { Operation } from '@dxos/operation';
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
9
8
|
|
|
10
|
-
import {
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
10
|
+
import { Database } from '@dxos/echo';
|
|
11
|
+
import { GameRef } from '@dxos/plugin-game';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
meta: {
|
|
14
|
-
key: 'org.dxos.function.chess.create',
|
|
15
|
-
name: 'Create Chess',
|
|
16
|
-
description: 'Creates a new chess game.',
|
|
17
|
-
},
|
|
18
|
-
input: Schema.Struct({
|
|
19
|
-
name: Schema.optional(
|
|
20
|
-
Schema.String.annotations({
|
|
21
|
-
description: 'Name of the game.',
|
|
22
|
-
}),
|
|
23
|
-
),
|
|
24
|
-
pgn: Schema.optional(
|
|
25
|
-
Schema.String.annotations({
|
|
26
|
-
description: 'Portable Game Notation.',
|
|
27
|
-
}),
|
|
28
|
-
),
|
|
29
|
-
fen: Schema.optional(
|
|
30
|
-
Schema.String.annotations({
|
|
31
|
-
description: 'Forsyth-Edwards Notation.',
|
|
32
|
-
}),
|
|
33
|
-
),
|
|
34
|
-
}),
|
|
35
|
-
output: Chess.Game,
|
|
36
|
-
services: [Database.Service],
|
|
37
|
-
});
|
|
13
|
+
import * as Chess from './Chess';
|
|
38
14
|
|
|
39
15
|
export const Move = Operation.make({
|
|
40
16
|
meta: {
|
|
@@ -43,8 +19,8 @@ export const Move = Operation.make({
|
|
|
43
19
|
description: 'Makes a move in the given chess game.',
|
|
44
20
|
},
|
|
45
21
|
input: Schema.Struct({
|
|
46
|
-
game:
|
|
47
|
-
description: 'The ID of the
|
|
22
|
+
game: GameRef(Chess.State).annotations({
|
|
23
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
48
24
|
}),
|
|
49
25
|
move: Schema.String.annotations({
|
|
50
26
|
description: 'The move to make in the chess game.',
|
|
@@ -66,8 +42,8 @@ export const Play = Operation.make({
|
|
|
66
42
|
description: 'Uses the chess engine to play the next move.',
|
|
67
43
|
},
|
|
68
44
|
input: Schema.Struct({
|
|
69
|
-
game:
|
|
70
|
-
description: 'The ID of the
|
|
45
|
+
game: GameRef(Chess.State).annotations({
|
|
46
|
+
description: 'The ID of the game object (variant must be Chess).',
|
|
71
47
|
}),
|
|
72
48
|
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
73
49
|
description: 'The side to play.',
|
package/src/types/index.ts
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
chess_blueprint_default
|
|
3
|
-
} from "../chunk-MC7L6JNC.mjs";
|
|
4
|
-
import {
|
|
5
|
-
operations_exports
|
|
6
|
-
} from "../chunk-JZMN24DY.mjs";
|
|
7
|
-
import "../chunk-XAJZK6Z2.mjs";
|
|
8
|
-
import "../chunk-2TJN26DN.mjs";
|
|
9
|
-
import "../chunk-J5LGTIGS.mjs";
|
|
10
|
-
export {
|
|
11
|
-
chess_blueprint_default as ChessBlueprint,
|
|
12
|
-
operations_exports as ChessFunctions
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,67 +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 { Annotation, 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: "org.dxos.type.chess",
|
|
35
|
-
version: "0.1.0"
|
|
36
|
-
}), LabelAnnotation.set([
|
|
37
|
-
"name"
|
|
38
|
-
]), Annotation.IconAnnotation.set({
|
|
39
|
-
icon: "ph--shield-chevron--regular",
|
|
40
|
-
hue: "amber"
|
|
41
|
-
}));
|
|
42
|
-
var make = ({ name, pgn, fen } = {}) => {
|
|
43
|
-
const chess = new ChessJS();
|
|
44
|
-
if (pgn) {
|
|
45
|
-
try {
|
|
46
|
-
chess.loadPgn(pgn);
|
|
47
|
-
} catch {
|
|
48
|
-
log.warn(pgn, void 0, {
|
|
49
|
-
F: __dxlog_file,
|
|
50
|
-
L: 52,
|
|
51
|
-
S: void 0,
|
|
52
|
-
C: (f, a) => f(...a)
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return Obj.make(Game, {
|
|
57
|
-
name,
|
|
58
|
-
pgn,
|
|
59
|
-
fen,
|
|
60
|
-
players: {}
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
Chess_exports
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=chunk-2TJN26DN.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 { Annotation, 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: 'org.dxos.type.chess',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({\n icon: 'ph--shield-chevron--regular',\n hue: 'amber',\n }),\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,YAAYC,KAAKC,YAAY;AACtC,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,GAC5BjB,WAAWuB,eAAeN,IAAI;EAC5BO,MAAM;EACNC,KAAK;AACP,CAAA,CAAA;AAKK,IAAMC,OAAO,CAAC,EAAElB,MAAMU,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMQ,QAAQ,IAAI7B,QAAAA;AAClB,MAAIoB,KAAK;AACP,QAAI;AACFS,YAAMC,QAAQV,GAAAA;IAChB,QAAQ;AACNb,UAAIwB,KAAKX,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOjB,IAAIyB,KAAKpB,MAAM;IACpBE;IACAU;IACAC;IACAR,SAAS,CAAC;EACZ,CAAA;AACF;",
|
|
6
|
-
"names": ["Chess", "ChessJS", "Schema", "Annotation", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "Struct", "name", "optional", "String", "players", "white", "annotations", "description", "black", "pipe", "set", "pgn", "fen", "object", "typename", "version", "IconAnnotation", "icon", "hue", "make", "chess", "loadPgn", "warn"]
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Create,
|
|
3
|
-
Move,
|
|
4
|
-
Play,
|
|
5
|
-
Print
|
|
6
|
-
} from "./chunk-XAJZK6Z2.mjs";
|
|
7
|
-
import {
|
|
8
|
-
__export
|
|
9
|
-
} from "./chunk-J5LGTIGS.mjs";
|
|
10
|
-
|
|
11
|
-
// src/operations/index.ts
|
|
12
|
-
var operations_exports = {};
|
|
13
|
-
__export(operations_exports, {
|
|
14
|
-
ChessHandlers: () => ChessHandlers,
|
|
15
|
-
Create: () => Create,
|
|
16
|
-
Move: () => Move,
|
|
17
|
-
Play: () => Play,
|
|
18
|
-
Print: () => Print
|
|
19
|
-
});
|
|
20
|
-
import { OperationHandlerSet } from "@dxos/operation";
|
|
21
|
-
var Handlers = OperationHandlerSet.lazy(() => import("./create-AJHN4QT4.mjs"), () => import("./move-T2NLRBR4.mjs"), () => import("./play-7VTMD3SJ.mjs"), () => import("./print-EW7LPW4D.mjs"));
|
|
22
|
-
var ChessHandlers = Handlers;
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
ChessHandlers,
|
|
26
|
-
operations_exports
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=chunk-JZMN24DY.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/operation';\n\nconst Handlers = OperationHandlerSet.lazy(\n () => import('./create'),\n () => import('./move'),\n () => import('./play'),\n () => import('./print'),\n);\n\nexport { Create, Move, Play, Print } from './definitions';\n\nexport const ChessHandlers = Handlers;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAAA;;;;;;;;AAIA,SAASA,2BAA2B;AAEpC,IAAMC,WAAWC,oBAAoBC,KACnC,MAAM,OAAO,uBAAA,GACb,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,sBAAA,CAAA;AAKR,IAAMC,gBAAgBH;",
|
|
6
|
-
"names": ["OperationHandlerSet", "Handlers", "OperationHandlerSet", "lazy", "ChessHandlers"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/blueprints/chess-blueprint.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type AppCapabilities } from '@dxos/app-toolkit';\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { trim } from '@dxos/util';\n\nimport { Create, Move, Play, Print } from '#operations';\n\nconst BLUEPRINT_KEY = 'org.dxos.blueprint.chess';\n\nconst operations = [Create, Move, Play, Print];\n\nconst make = () =>\n Blueprint.make({\n key: BLUEPRINT_KEY,\n name: 'Chess',\n tools: Blueprint.toolDefinitions({ operations }),\n instructions: Template.make({\n source: trim`\n You are an expert chess player.\n To analyze a game you can access the \"pgn\" property by loading the context object that represents the current game.\n You could suggest a good next move or offer to play a move.\n Don't actually make a move unless you are asked to.\n `,\n }),\n });\n\nconst blueprint: AppCapabilities.BlueprintDefinition = {\n key: BLUEPRINT_KEY,\n make,\n};\n\nexport default blueprint;\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAErB,SAASC,QAAQC,MAAMC,MAAMC,aAAa;AAE1C,IAAMC,gBAAgB;AAEtB,IAAMC,aAAa;EAACC;EAAQC;EAAMC;EAAMC;;AAExC,IAAMC,OAAO,MACXC,UAAUD,KAAK;EACbE,KAAKR;EACLS,MAAM;EACNC,OAAOH,UAAUI,gBAAgB;IAAEV;EAAW,CAAA;EAC9CW,cAAcC,SAASP,KAAK;IAC1BQ,QAAQC;;;;;;EAMV,CAAA;AACF,CAAA;AAEF,IAAMC,YAAiD;EACrDR,KAAKR;EACLM;AACF;AAEA,IAAA,0BAAeU;",
|
|
6
|
-
"names": ["Blueprint", "Template", "trim", "Create", "Move", "Play", "Print", "BLUEPRINT_KEY", "operations", "Create", "Move", "Play", "Print", "make", "Blueprint", "key", "name", "tools", "toolDefinitions", "instructions", "Template", "source", "trim", "blueprint"]
|
|
7
|
-
}
|