@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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/containers/ChessArticle/ChessArticle.tsx
|
|
4
|
+
import { Chess as ChessJS } from "chess.js";
|
|
5
|
+
import React, { useCallback, useRef, useState } from "react";
|
|
6
|
+
import { Obj } from "@dxos/echo";
|
|
7
|
+
import { Panel, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
8
|
+
import { mx } from "@dxos/ui-theme";
|
|
9
|
+
import { Chessboard } from "#components";
|
|
10
|
+
import { meta } from "#meta";
|
|
11
|
+
import { Chess } from "#types";
|
|
12
|
+
var ChessArticle = ({ role, variant }) => {
|
|
13
|
+
const { t } = useTranslation(meta.id);
|
|
14
|
+
const [orientation, setOrientation] = useState("white");
|
|
15
|
+
const [showInfo, setShowInfo] = useState(true);
|
|
16
|
+
const controller = useRef(null);
|
|
17
|
+
const handleSelect = useCallback((index) => {
|
|
18
|
+
controller.current?.setMoveNumber(index);
|
|
19
|
+
}, []);
|
|
20
|
+
const isGameOver = (() => {
|
|
21
|
+
if (!Obj.instanceOf(Chess.State, variant) || !variant.pgn && !variant.fen) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const chess = new ChessJS();
|
|
26
|
+
if (variant.pgn) {
|
|
27
|
+
chess.loadPgn(variant.pgn);
|
|
28
|
+
} else if (variant.fen) {
|
|
29
|
+
chess.load(variant.fen);
|
|
30
|
+
}
|
|
31
|
+
return chess.isGameOver();
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
const handleNewGame = useCallback(() => {
|
|
37
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
Obj.update(variant, (variant2) => {
|
|
41
|
+
const mutable = variant2;
|
|
42
|
+
mutable.pgn = void 0;
|
|
43
|
+
mutable.fen = void 0;
|
|
44
|
+
});
|
|
45
|
+
}, [
|
|
46
|
+
variant
|
|
47
|
+
]);
|
|
48
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
52
|
+
state: variant,
|
|
53
|
+
ref: controller
|
|
54
|
+
}, /* @__PURE__ */ React.createElement(Panel.Root, {
|
|
55
|
+
role,
|
|
56
|
+
classNames: "@container"
|
|
57
|
+
}, /* @__PURE__ */ React.createElement(Panel.Toolbar, {
|
|
58
|
+
asChild: true
|
|
59
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, isGameOver && /* @__PURE__ */ React.createElement(Toolbar.Button, {
|
|
60
|
+
onClick: handleNewGame
|
|
61
|
+
}, t("new-game.button")), /* @__PURE__ */ React.createElement("div", {
|
|
62
|
+
className: "grow"
|
|
63
|
+
}), /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
64
|
+
icon: "ph--info--regular",
|
|
65
|
+
iconOnly: true,
|
|
66
|
+
label: t("toggle-info.button"),
|
|
67
|
+
classNames: mx("invisible @4xl:visible"),
|
|
68
|
+
onClick: () => setShowInfo((open) => !open)
|
|
69
|
+
}))), /* @__PURE__ */ React.createElement(Panel.Content, null, /* @__PURE__ */ React.createElement("div", {
|
|
70
|
+
className: mx("grid h-full w-full", showInfo && "@4xl:grid-cols-[1fr_320px] gap-8", role === "article" && "p-4", role === "section" && "aspect-square", role === "section" && showInfo && "@4xl:aspect-auto")
|
|
71
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
72
|
+
classNames: "border rounded-xs",
|
|
73
|
+
orientation
|
|
74
|
+
})), showInfo && /* @__PURE__ */ React.createElement("div", {
|
|
75
|
+
className: "hidden @4xl:flex flex-col justify-center items-center overflow-hidden"
|
|
76
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
77
|
+
orientation,
|
|
78
|
+
min: 8,
|
|
79
|
+
max: 8,
|
|
80
|
+
onOrientationChange: setOrientation,
|
|
81
|
+
onClose: () => setShowInfo(false),
|
|
82
|
+
onSelect: handleSelect
|
|
83
|
+
}))))));
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
ChessArticle as default
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=ChessArticle-QLLKZGPH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/containers/ChessArticle/ChessArticle.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { type GameVariantSurfaceProps } from '@dxos/plugin-game';\nimport { Panel, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Chessboard, type ChessboardController, type ChessboardInfoProps } from '#components';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nexport type ChessArticleProps = GameVariantSurfaceProps;\n\nexport const ChessArticle = ({ role, variant }: ChessArticleProps) => {\n const { t } = useTranslation(meta.id);\n const [orientation, setOrientation] = useState<Player>('white');\n const [showInfo, setShowInfo] = useState(true);\n const controller = useRef<ChessboardController>(null);\n\n const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {\n controller.current?.setMoveNumber(index);\n }, []);\n\n const isGameOver = (() => {\n if (!Obj.instanceOf(Chess.State, variant) || (!variant.pgn && !variant.fen)) {\n return false;\n }\n try {\n const chess = new ChessJS();\n if (variant.pgn) {\n chess.loadPgn(variant.pgn);\n } else if (variant.fen) {\n chess.load(variant.fen);\n }\n return chess.isGameOver();\n } catch {\n return false;\n }\n })();\n\n const handleNewGame = useCallback(() => {\n if (!Obj.instanceOf(Chess.State, variant)) {\n return;\n }\n Obj.update(variant, (variant) => {\n const mutable = variant as Obj.Mutable<typeof variant>;\n mutable.pgn = undefined;\n mutable.fen = undefined;\n });\n }, [variant]);\n\n if (!Obj.instanceOf(Chess.State, variant)) {\n return null;\n }\n\n return (\n <Chessboard.Root state={variant} ref={controller}>\n <Panel.Root role={role} classNames='@container'>\n <Panel.Toolbar asChild>\n <Toolbar.Root>\n {isGameOver && <Toolbar.Button onClick={handleNewGame}>{t('new-game.button')}</Toolbar.Button>}\n <div className='grow' />\n <Toolbar.IconButton\n icon='ph--info--regular'\n iconOnly\n label={t('toggle-info.button')}\n classNames={mx('invisible @4xl:visible')}\n onClick={() => setShowInfo((open) => !open)}\n />\n </Toolbar.Root>\n </Panel.Toolbar>\n <Panel.Content>\n <div\n className={mx(\n 'grid h-full w-full',\n showInfo && '@4xl:grid-cols-[1fr_320px] gap-8',\n role === 'article' && 'p-4',\n role === 'section' && 'aspect-square',\n role === 'section' && showInfo && '@4xl:aspect-auto',\n )}\n >\n <Chessboard.Content>\n <Chessboard.Board classNames='border rounded-xs' orientation={orientation} />\n </Chessboard.Content>\n {showInfo && (\n <div className='hidden @4xl:flex flex-col justify-center items-center overflow-hidden'>\n <Chessboard.Info\n orientation={orientation}\n min={8}\n max={8}\n onOrientationChange={setOrientation}\n onClose={() => setShowInfo(false)}\n onSelect={handleSelect}\n />\n </div>\n )}\n </div>\n </Panel.Content>\n </Panel.Root>\n </Chessboard.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,SAASC,eAAe;AACjC,OAAOC,SAASC,aAAaC,QAAQC,gBAAgB;AAErD,SAASC,WAAW;AAEpB,SAASC,OAAOC,SAASC,sBAAsB;AAE/C,SAASC,UAAU;AAEnB,SAASC,kBAAuE;AAChF,SAASC,YAAY;AACrB,SAASZ,aAAa;AAIf,IAAMa,eAAe,CAAC,EAAEC,MAAMC,QAAO,MAAqB;AAC/D,QAAM,EAAEC,EAAC,IAAKP,eAAeG,KAAKK,EAAE;AACpC,QAAM,CAACC,aAAaC,cAAAA,IAAkBd,SAAiB,OAAA;AACvD,QAAM,CAACe,UAAUC,WAAAA,IAAehB,SAAS,IAAA;AACzC,QAAMiB,aAAalB,OAA6B,IAAA;AAEhD,QAAMmB,eAAepB,YAA0D,CAACqB,UAAAA;AAC9EF,eAAWG,SAASC,cAAcF,KAAAA;EACpC,GAAG,CAAA,CAAE;AAEL,QAAMG,cAAc,MAAA;AAClB,QAAI,CAACrB,IAAIsB,WAAW5B,MAAM6B,OAAOd,OAAAA,KAAa,CAACA,QAAQe,OAAO,CAACf,QAAQgB,KAAM;AAC3E,aAAO;IACT;AACA,QAAI;AACF,YAAMC,QAAQ,IAAI/B,QAAAA;AAClB,UAAIc,QAAQe,KAAK;AACfE,cAAMC,QAAQlB,QAAQe,GAAG;MAC3B,WAAWf,QAAQgB,KAAK;AACtBC,cAAME,KAAKnB,QAAQgB,GAAG;MACxB;AACA,aAAOC,MAAML,WAAU;IACzB,QAAQ;AACN,aAAO;IACT;EACF,GAAA;AAEA,QAAMQ,gBAAgBhC,YAAY,MAAA;AAChC,QAAI,CAACG,IAAIsB,WAAW5B,MAAM6B,OAAOd,OAAAA,GAAU;AACzC;IACF;AACAT,QAAI8B,OAAOrB,SAAS,CAACA,aAAAA;AACnB,YAAMsB,UAAUtB;AAChBsB,cAAQP,MAAMQ;AACdD,cAAQN,MAAMO;IAChB,CAAA;EACF,GAAG;IAACvB;GAAQ;AAEZ,MAAI,CAACT,IAAIsB,WAAW5B,MAAM6B,OAAOd,OAAAA,GAAU;AACzC,WAAO;EACT;AAEA,SACE,sBAAA,cAACJ,WAAW4B,MAAI;IAACC,OAAOzB;IAAS0B,KAAKnB;KACpC,sBAAA,cAACf,MAAMgC,MAAI;IAACzB;IAAY4B,YAAW;KACjC,sBAAA,cAACnC,MAAMC,SAAO;IAACmC,SAAAA;KACb,sBAAA,cAACnC,QAAQ+B,MAAI,MACVZ,cAAc,sBAAA,cAACnB,QAAQoC,QAAM;IAACC,SAASV;KAAgBnB,EAAE,iBAAA,CAAA,GAC1D,sBAAA,cAAC8B,OAAAA;IAAIC,WAAU;MACf,sBAAA,cAACvC,QAAQwC,YAAU;IACjBC,MAAK;IACLC,UAAAA;IACAC,OAAOnC,EAAE,oBAAA;IACT0B,YAAYhC,GAAG,wBAAA;IACfmC,SAAS,MAAMxB,YAAY,CAAC+B,SAAS,CAACA,IAAAA;QAI5C,sBAAA,cAAC7C,MAAM8C,SAAO,MACZ,sBAAA,cAACP,OAAAA;IACCC,WAAWrC,GACT,sBACAU,YAAY,oCACZN,SAAS,aAAa,OACtBA,SAAS,aAAa,iBACtBA,SAAS,aAAaM,YAAY,kBAAA;KAGpC,sBAAA,cAACT,WAAW0C,SAAO,MACjB,sBAAA,cAAC1C,WAAW2C,OAAK;IAACZ,YAAW;IAAoBxB;OAElDE,YACC,sBAAA,cAAC0B,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACpC,WAAW4C,MAAI;IACdrC;IACAsC,KAAK;IACLC,KAAK;IACLC,qBAAqBvC;IACrBwC,SAAS,MAAMtC,YAAY,KAAA;IAC3BuC,UAAUrC;;AAS5B;",
|
|
6
|
+
"names": ["Chess", "ChessJS", "React", "useCallback", "useRef", "useState", "Obj", "Panel", "Toolbar", "useTranslation", "mx", "Chessboard", "meta", "ChessArticle", "role", "variant", "t", "id", "orientation", "setOrientation", "showInfo", "setShowInfo", "controller", "handleSelect", "index", "current", "setMoveNumber", "isGameOver", "instanceOf", "State", "pgn", "fen", "chess", "loadPgn", "load", "handleNewGame", "update", "mutable", "undefined", "Root", "state", "ref", "classNames", "asChild", "Button", "onClick", "div", "className", "IconButton", "icon", "iconOnly", "label", "open", "Content", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/containers/ChessCard/ChessCard.tsx
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Obj } from "@dxos/echo";
|
|
6
|
+
import { Chessboard } from "#components";
|
|
7
|
+
import { Chess } from "#types";
|
|
8
|
+
var ChessCard = ({ variant }) => {
|
|
9
|
+
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
13
|
+
state: variant
|
|
14
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, null)));
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
ChessCard as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=ChessCard-I5RSZZIP.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/containers/ChessCard/ChessCard.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { type GameVariantSurfaceProps } from '@dxos/plugin-game';\n\nimport { Chessboard } from '#components';\nimport { Chess } from '#types';\n\nexport type ChessCardProps = GameVariantSurfaceProps;\n\nexport const ChessCard = ({ variant }: ChessCardProps) => {\n if (!Obj.instanceOf(Chess.State, variant)) {\n return null;\n }\n\n return (\n <Chessboard.Root state={variant}>\n <Chessboard.Content>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,WAAW;AAElB,SAASC,WAAW;AAGpB,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AAIf,IAAMC,YAAY,CAAC,EAAEC,QAAO,MAAkB;AACnD,MAAI,CAACJ,IAAIK,WAAWH,MAAMI,OAAOF,OAAAA,GAAU;AACzC,WAAO;EACT;AAEA,SACE,sBAAA,cAACH,WAAWM,MAAI;IAACC,OAAOJ;KACtB,sBAAA,cAACH,WAAWQ,SAAO,MACjB,sBAAA,cAACR,WAAWS,OAAK,IAAA,CAAA,CAAA;AAIzB;",
|
|
6
|
+
"names": ["React", "Obj", "Chessboard", "Chess", "ChessCard", "variant", "instanceOf", "State", "Root", "state", "Content", "Board"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/ChessPlugin.tsx
|
|
4
|
+
import { Plugin } from "@dxos/app-framework";
|
|
5
|
+
import { AppPlugin, AppActivationEvents } from "@dxos/app-toolkit";
|
|
6
|
+
import { BlueprintDefinition, GameVariant, OperationHandler } from "#capabilities";
|
|
7
|
+
import { meta } from "#meta";
|
|
8
|
+
import { translations } from "#translations";
|
|
9
|
+
import { Chess } from "#types";
|
|
10
|
+
var ChessPlugin = Plugin.define(meta).pipe(Plugin.addModule({
|
|
11
|
+
id: "game-variant",
|
|
12
|
+
activatesOn: AppActivationEvents.SetupSchema,
|
|
13
|
+
activate: GameVariant
|
|
14
|
+
}), AppPlugin.addBlueprintDefinitionModule({
|
|
15
|
+
activate: BlueprintDefinition
|
|
16
|
+
}), AppPlugin.addOperationHandlerModule({
|
|
17
|
+
activate: OperationHandler
|
|
18
|
+
}), AppPlugin.addSchemaModule({
|
|
19
|
+
schema: [
|
|
20
|
+
Chess.State
|
|
21
|
+
]
|
|
22
|
+
}), AppPlugin.addTranslationsModule({
|
|
23
|
+
translations
|
|
24
|
+
}), Plugin.make);
|
|
25
|
+
var ChessPlugin_default = ChessPlugin;
|
|
26
|
+
export {
|
|
27
|
+
ChessPlugin,
|
|
28
|
+
ChessPlugin_default as default
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=ChessPlugin.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ChessPlugin.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin, AppActivationEvents } from '@dxos/app-toolkit';\n\nimport { BlueprintDefinition, GameVariant, OperationHandler } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Chess } from '#types';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n Plugin.addModule({\n id: 'game-variant',\n activatesOn: AppActivationEvents.SetupSchema,\n activate: GameVariant,\n }),\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,WAAWC,2BAA2B;AAE/C,SAASC,qBAAqBC,aAAaC,wBAAwB;AACnE,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,aAAa;AAEf,IAAMC,cAAcT,OAAOU,OAAOJ,IAAAA,EAAMK,KAC7CX,OAAOY,UAAU;EACfC,IAAI;EACJC,aAAaZ,oBAAoBa;EACjCC,UAAUZ;AACZ,CAAA,GACAH,UAAUgB,6BAA6B;EAAED,UAAUb;AAAoB,CAAA,GACvEF,UAAUiB,0BAA0B;EAAEF,UAAUX;AAAiB,CAAA,GACjEJ,UAAUkB,gBAAgB;EAAEC,QAAQ;IAACZ,MAAMa;;AAAO,CAAA,GAClDpB,UAAUqB,sBAAsB;EAAEf;AAAa,CAAA,GAC/CP,OAAOuB,IAAI;AAGb,IAAA,sBAAed;",
|
|
6
|
+
"names": ["Plugin", "AppPlugin", "AppActivationEvents", "BlueprintDefinition", "GameVariant", "OperationHandler", "meta", "translations", "Chess", "ChessPlugin", "define", "pipe", "addModule", "id", "activatesOn", "SetupSchema", "activate", "addBlueprintDefinitionModule", "addOperationHandlerModule", "addSchemaModule", "schema", "State", "addTranslationsModule", "make"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/ChessPlugin.node.ts
|
|
4
|
+
import { Plugin } from "@dxos/app-framework";
|
|
5
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
+
import { BlueprintDefinition, OperationHandler } from "#capabilities";
|
|
7
|
+
import { meta } from "#meta";
|
|
8
|
+
import { Chess } from "#types";
|
|
9
|
+
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
|
|
10
|
+
schema: [
|
|
11
|
+
Chess.State
|
|
12
|
+
]
|
|
13
|
+
}), AppPlugin.addBlueprintDefinitionModule({
|
|
14
|
+
activate: BlueprintDefinition
|
|
15
|
+
}), AppPlugin.addOperationHandlerModule({
|
|
16
|
+
activate: OperationHandler
|
|
17
|
+
}), Plugin.make);
|
|
18
|
+
var ChessPlugin_node_default = ChessPlugin;
|
|
19
|
+
export {
|
|
20
|
+
ChessPlugin,
|
|
21
|
+
ChessPlugin_node_default as default
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=ChessPlugin.node.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ChessPlugin.node.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { BlueprintDefinition, OperationHandler } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n/**\n * Headless variant of ChessPlugin (no React surfaces / GameVariant).\n * Used in node contexts (CLI, agents) where rendering is unavailable.\n */\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,qBAAqBC,wBAAwB;AACtD,SAASC,YAAY;AACrB,SAASC,aAAa;AAMf,IAAMC,cAAcN,OAAOO,OAAOH,IAAAA,EAAMI,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL,MAAMM;;AAAO,CAAA,GAClDV,UAAUW,6BAA6B;EAAEC,UAAUX;AAAoB,CAAA,GACvED,UAAUa,0BAA0B;EAAED,UAAUV;AAAiB,CAAA,GACjEH,OAAOe,IAAI;AAGb,IAAA,2BAAeT;",
|
|
6
|
+
"names": ["Plugin", "AppPlugin", "BlueprintDefinition", "OperationHandler", "meta", "Chess", "ChessPlugin", "define", "pipe", "addSchemaModule", "schema", "State", "addBlueprintDefinitionModule", "activate", "addOperationHandlerModule", "make"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/capabilities/blueprint-definition.ts
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { Capability } from "@dxos/app-framework";
|
|
6
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
7
|
+
import { ChessBlueprint } from "#blueprints";
|
|
8
|
+
var blueprintDefinition = Capability.makeModule(() => Effect.succeed([
|
|
9
|
+
Capability.contributes(AppCapabilities.BlueprintDefinition, ChessBlueprint)
|
|
10
|
+
]));
|
|
11
|
+
var blueprint_definition_default = blueprintDefinition;
|
|
12
|
+
export {
|
|
13
|
+
blueprint_definition_default as default
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=blueprint-definition-PZXHAYLD.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/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// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { Blueprint } from '@dxos/compute';\n\nimport { ChessBlueprint } from '#blueprints';\n\nconst blueprintDefinition = Capability.makeModule<\n [],\n Capability.Capability<typeof AppCapabilities.BlueprintDefinition>[]\n>(() => Effect.succeed([Capability.contributes(AppCapabilities.BlueprintDefinition, ChessBlueprint)]));\n\nexport default blueprintDefinition;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB;AAIhC,SAASC,sBAAsB;AAE/B,IAAMC,sBAAsBH,WAAWI,WAGrC,MAAaC,eAAQ;EAACL,WAAWM,YAAYL,gBAAgBM,qBAAqBL,cAAAA;CAAgB,CAAA;AAEpG,IAAA,+BAAeC;",
|
|
6
|
+
"names": ["Effect", "Capability", "AppCapabilities", "ChessBlueprint", "blueprintDefinition", "makeModule", "succeed", "contributes", "BlueprintDefinition"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/capabilities/index.ts
|
|
4
|
+
import { Capability } from "@dxos/app-framework";
|
|
5
|
+
var BlueprintDefinition = Capability.lazy("BlueprintDefinition", () => import("../blueprint-definition-PZXHAYLD.mjs"));
|
|
6
|
+
var GameVariant = Capability.lazy("GameVariant", () => import("../game-variant-24UKIBRM.mjs"));
|
|
7
|
+
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-EKZKFQUG.mjs"));
|
|
8
|
+
export {
|
|
9
|
+
BlueprintDefinition,
|
|
10
|
+
GameVariant,
|
|
11
|
+
OperationHandler
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/capabilities/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport type { Blueprint, OperationHandlerSet } from '@dxos/compute';\n\nexport const BlueprintDefinition = Capability.lazy('BlueprintDefinition', () => import('./blueprint-definition'));\nexport const GameVariant = Capability.lazy('GameVariant', () => import('./game-variant'));\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,kBAAkB;AAIpB,IAAMC,sBAAsBD,WAAWE,KAAK,uBAAuB,MAAM,OAAO,sCAAA,CAAA;AAChF,IAAMC,cAAcH,WAAWE,KAAK,eAAe,MAAM,OAAO,8BAAA,CAAA;AAChE,IAAME,mBAAmBJ,WAAWE,KACzC,oBACA,MAAM,OAAO,mCAAA,CAAA;",
|
|
6
|
+
"names": ["Capability", "BlueprintDefinition", "lazy", "GameVariant", "OperationHandler"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/operations/index.ts
|
|
2
|
+
import { OperationHandlerSet } from "@dxos/compute";
|
|
3
|
+
var ChessOperationHandlerSet = OperationHandlerSet.lazy(() => import("./move-RQZ7BJY3.mjs"), () => import("./play-GDGCEPQL.mjs"), () => import("./print-ZQA74KZI.mjs"));
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
ChessOperationHandlerSet
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=chunk-5UOTTW6U.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/compute';\n\nexport const ChessOperationHandlerSet = OperationHandlerSet.lazy(\n () => import('./move'),\n () => import('./play'),\n () => import('./print'),\n);\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,2BAA2B;AAE7B,IAAMC,2BAA2BD,oBAAoBE,KAC1D,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,sBAAA,CAAA;",
|
|
6
|
+
"names": ["OperationHandlerSet", "ChessOperationHandlerSet", "lazy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/types/Chess.ts
|
|
6
|
+
var Chess_exports = {};
|
|
7
|
+
__export(Chess_exports, {
|
|
8
|
+
BLUEPRINT_KEY: () => BLUEPRINT_KEY,
|
|
9
|
+
State: () => State,
|
|
10
|
+
make: () => make
|
|
11
|
+
});
|
|
12
|
+
import { Chess as ChessJS } from "chess.js";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import { BlueprintsAnnotation } from "@dxos/app-toolkit";
|
|
15
|
+
import { Annotation, Obj, Type } from "@dxos/echo";
|
|
16
|
+
import { FormInputAnnotation, SystemTypeAnnotation } from "@dxos/echo/internal";
|
|
17
|
+
import { log } from "@dxos/log";
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
|
|
19
|
+
var BLUEPRINT_KEY = "org.dxos.blueprint.chess";
|
|
20
|
+
var State = Schema.Struct({
|
|
21
|
+
pgn: Schema.String.annotations({
|
|
22
|
+
description: "Portable Game Notation."
|
|
23
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
24
|
+
fen: Schema.String.annotations({
|
|
25
|
+
description: "Forsyth-Edwards Notation."
|
|
26
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional)
|
|
27
|
+
}).pipe(
|
|
28
|
+
Type.object({
|
|
29
|
+
typename: "org.dxos.type.chess.state",
|
|
30
|
+
version: "0.1.0"
|
|
31
|
+
}),
|
|
32
|
+
Annotation.IconAnnotation.set({
|
|
33
|
+
icon: "ph--shield-chevron--regular",
|
|
34
|
+
hue: "amber"
|
|
35
|
+
}),
|
|
36
|
+
BlueprintsAnnotation.set([
|
|
37
|
+
BLUEPRINT_KEY
|
|
38
|
+
]),
|
|
39
|
+
// Implementation detail of the unified `Game` schema. The user-facing object is `Game`;
|
|
40
|
+
// this state is only ever referenced via `Game.variant`. SystemType keeps it out of the
|
|
41
|
+
// navtree's typed branches so an orphaned state object doesn't reappear after the
|
|
42
|
+
// wrapping Game is deleted.
|
|
43
|
+
SystemTypeAnnotation.set(true)
|
|
44
|
+
);
|
|
45
|
+
var make = ({ pgn, fen } = {}) => {
|
|
46
|
+
const chess = new ChessJS();
|
|
47
|
+
if (pgn) {
|
|
48
|
+
try {
|
|
49
|
+
chess.loadPgn(pgn);
|
|
50
|
+
} catch {
|
|
51
|
+
log.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 40, S: void 0 });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return Obj.make(State, {
|
|
55
|
+
pgn,
|
|
56
|
+
fen
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/types/ChessOperation.ts
|
|
61
|
+
var ChessOperation_exports = {};
|
|
62
|
+
__export(ChessOperation_exports, {
|
|
63
|
+
Move: () => Move,
|
|
64
|
+
Play: () => Play,
|
|
65
|
+
Print: () => Print
|
|
66
|
+
});
|
|
67
|
+
import * as Schema2 from "effect/Schema";
|
|
68
|
+
import { Operation } from "@dxos/compute";
|
|
69
|
+
import { Database } from "@dxos/echo";
|
|
70
|
+
import { GameRef } from "@dxos/plugin-game";
|
|
71
|
+
var Move = Operation.make({
|
|
72
|
+
meta: {
|
|
73
|
+
key: "org.dxos.function.chess.move",
|
|
74
|
+
name: "Move",
|
|
75
|
+
description: "Makes a move in the given chess game."
|
|
76
|
+
},
|
|
77
|
+
input: Schema2.Struct({
|
|
78
|
+
game: GameRef(State).annotations({
|
|
79
|
+
description: "The ID of the game object (variant must be Chess)."
|
|
80
|
+
}),
|
|
81
|
+
move: Schema2.String.annotations({
|
|
82
|
+
description: "The move to make in the chess game.",
|
|
83
|
+
examples: [
|
|
84
|
+
"e4",
|
|
85
|
+
"Bf3"
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
}),
|
|
89
|
+
output: Schema2.Struct({
|
|
90
|
+
pgn: Schema2.String.annotations({
|
|
91
|
+
description: "The PGN of the game after the move was played."
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
services: [
|
|
95
|
+
Database.Service
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
var Play = Operation.make({
|
|
99
|
+
meta: {
|
|
100
|
+
key: "org.dxos.function.chess.play",
|
|
101
|
+
name: "Play",
|
|
102
|
+
description: "Uses the chess engine to play the next move."
|
|
103
|
+
},
|
|
104
|
+
input: Schema2.Struct({
|
|
105
|
+
game: GameRef(State).annotations({
|
|
106
|
+
description: "The ID of the game object (variant must be Chess)."
|
|
107
|
+
}),
|
|
108
|
+
side: Schema2.optional(Schema2.Literal("white", "black", "any")).annotations({
|
|
109
|
+
description: "The side to play.",
|
|
110
|
+
defaultValue: "any"
|
|
111
|
+
})
|
|
112
|
+
}),
|
|
113
|
+
output: Schema2.Struct({
|
|
114
|
+
pgn: Schema2.String.annotations({
|
|
115
|
+
description: "The PGN of the game after the move was played."
|
|
116
|
+
}),
|
|
117
|
+
move: Schema2.optional(Schema2.String).annotations({
|
|
118
|
+
description: "The move that was played."
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
services: [
|
|
122
|
+
Database.Service
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
var Print = Operation.make({
|
|
126
|
+
meta: {
|
|
127
|
+
key: "org.dxos.function.chess.print",
|
|
128
|
+
name: "Print game",
|
|
129
|
+
description: "Prints the chess game to ASCII."
|
|
130
|
+
},
|
|
131
|
+
input: Schema2.Struct({
|
|
132
|
+
pgn: Schema2.optional(Schema2.String.annotations({
|
|
133
|
+
description: "Portable Game Notation."
|
|
134
|
+
})),
|
|
135
|
+
fen: Schema2.optional(Schema2.String.annotations({
|
|
136
|
+
description: "Forsyth-Edwards Notation."
|
|
137
|
+
}))
|
|
138
|
+
}),
|
|
139
|
+
output: Schema2.Struct({
|
|
140
|
+
ascii: Schema2.String
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
Chess_exports,
|
|
146
|
+
ChessOperation_exports
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=chunk-E4LZPHAQ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/Chess.ts", "../../../src/types/ChessOperation.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 { BlueprintsAnnotation } from '@dxos/app-toolkit';\nimport { Annotation, Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, SystemTypeAnnotation } from '@dxos/echo/internal';\nimport { log } from '@dxos/log';\n\nexport const BLUEPRINT_KEY = 'org.dxos.blueprint.chess';\n\n/**\n * Chess variant state. Referenced by the base `Game` object via `Game.variant`.\n * Players, name, and other game-shared fields live on the base `Game`.\n */\nexport const State = Schema.Struct({\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.state',\n version: '0.1.0',\n }),\n Annotation.IconAnnotation.set({\n icon: 'ph--shield-chevron--regular',\n hue: 'amber',\n }),\n BlueprintsAnnotation.set([BLUEPRINT_KEY]),\n // Implementation detail of the unified `Game` schema. The user-facing object is `Game`;\n // this state is only ever referenced via `Game.variant`. SystemType keeps it out of the\n // navtree's typed branches so an orphaned state object doesn't reappear after the\n // wrapping Game is deleted.\n SystemTypeAnnotation.set(true),\n);\n\nexport interface State extends Schema.Schema.Type<typeof State> {}\n\nexport const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {\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(State, {\n pgn,\n fen,\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\nimport { GameRef } from '@dxos/plugin-game';\n\nimport * as Chess from './Chess';\n\nexport const Move = Operation.make({\n meta: {\n key: 'org.dxos.function.chess.move',\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Play = Operation.make({\n meta: {\n key: 'org.dxos.function.chess.play',\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({\n description: 'The side to play.',\n defaultValue: 'any',\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n move: Schema.optional(Schema.String).annotations({\n description: 'The move that was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Print = Operation.make({\n meta: {\n key: 'org.dxos.function.chess.print',\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\n },\n input: Schema.Struct({\n pgn: Schema.optional(\n Schema.String.annotations({\n description: 'Portable Game Notation.',\n }),\n ),\n fen: Schema.optional(\n Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }),\n ),\n }),\n output: Schema.Struct({\n ascii: Schema.String,\n }),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,4BAA4B;AACrC,SAASC,YAAYC,KAAKC,YAAY;AACtC,SAASC,qBAAqBC,4BAA4B;AAC1D,SAASC,WAAW;AAEpB,IAAA,eAAaC;;AAQTC,IAAAA,QAAa,cAAA;EACf,KAAQJ,cAAAA,YAAuB;IAC/BK,aAAYC;UACVF,oBAAa,IAAA,KAAA,GAAA,eAAA;EACf,KAAQJ,cAAAA,YAAuB;IAE/BD,aAAY;EACVQ,CAAAA,EAAAA,KAAAA,oBAAU,IAAA,KAAA,GAAA,eAAA;;EACVC,KAAS,OAAA;IAEXX,UAAAA;IACEY,SAAM;;EACNC,WAAK,eAAA,IAAA;IAEPd,MAAAA;IAA0BO,KAAAA;GAAc;EACxC,qBAAA,IAAA;IACA;EACA,CAAA;;;;;uBAQc,IAAIT,IAAAA;AAAAA;AAClB,IAAS,OAAA,CAAA,EAAA,KAAA,IAAA,IAAA,CAAA,MAAA;QACP,QAAI,IAAA,QAAA;WACFiB;AACF,QAAE;AACAT,YAAIU,QAAKC,GAAAA;IACX,QAAA;AACF,UAAA,KAAA,KAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;IAEA;;SAEER,IAAAA,KAAAA,OAAAA;IACF;IACA;;;;;AC1DF;;;;;;AAMA,YAAYS,aAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,eAAe;AAIjB,IAAMC,OAAOC,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,eAAO;IACnBC,MAAMC,QAAcC,KAAK,EAAEC,YAAY;MACrCN,aAAa;IACf,CAAA;IACAO,MAAaC,eAAOF,YAAY;MAC9BN,aAAa;MACbS,UAAU;QAAC;QAAM;;IACnB,CAAA;EACF,CAAA;EACAC,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BN,aAAa;IACf,CAAA;EACF,CAAA;EACAY,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMC,OAAOpB,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,eAAO;IACnBC,MAAMC,QAAcC,KAAK,EAAEC,YAAY;MACrCN,aAAa;IACf,CAAA;IACAgB,MAAaC,iBAAgBC,gBAAQ,SAAS,SAAS,KAAA,CAAA,EAAQZ,YAAY;MACzEN,aAAa;MACbmB,cAAc;IAChB,CAAA;EACF,CAAA;EACAT,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BN,aAAa;IACf,CAAA;IACAO,MAAaU,iBAAgBT,cAAM,EAAEF,YAAY;MAC/CN,aAAa;IACf,CAAA;EACF,CAAA;EACAY,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMM,QAAQzB,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,eAAO;IACnBS,KAAYM,iBACHT,eAAOF,YAAY;MACxBN,aAAa;IACf,CAAA,CAAA;IAEFqB,KAAYJ,iBACHT,eAAOF,YAAY;MACxBN,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA;EACAU,QAAeR,eAAO;IACpBoB,OAAcd;EAChB,CAAA;AACF,CAAA;",
|
|
6
|
+
"names": ["Chess", "ChessJS", "Schema", "BlueprintsAnnotation", "Annotation", "Obj", "Type", "FormInputAnnotation", "SystemTypeAnnotation", "log", "BLUEPRINT_KEY", "description", "fen", "String", "typename", "version", "icon", "hue", "chess", "warn", "pgn", "Schema", "Operation", "Database", "GameRef", "Move", "Operation", "make", "meta", "key", "name", "description", "input", "Struct", "game", "GameRef", "State", "annotations", "move", "String", "examples", "output", "pgn", "services", "Database", "Service", "Play", "side", "optional", "Literal", "defaultValue", "Print", "fen", "ascii"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import { trim } from "@dxos/util";
|
|
3
|
+
var meta = {
|
|
4
|
+
id: "org.dxos.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-FFXSIHW6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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: 'org.dxos.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,aAAaJ;;;;EAIbK,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "icon", "iconHue", "source", "screenshots"]
|
|
7
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// src/blueprints/chess-blueprint.ts
|
|
2
|
-
import { Blueprint, Template } from "@dxos/
|
|
2
|
+
import { Blueprint, Template } from "@dxos/compute";
|
|
3
3
|
import { trim } from "@dxos/util";
|
|
4
|
-
import {
|
|
5
|
-
var BLUEPRINT_KEY = "org.dxos.blueprint.chess";
|
|
4
|
+
import { Chess, ChessOperation } from "#types";
|
|
6
5
|
var operations = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Print
|
|
6
|
+
ChessOperation.Move,
|
|
7
|
+
ChessOperation.Play,
|
|
8
|
+
ChessOperation.Print
|
|
11
9
|
];
|
|
12
10
|
var make = () => Blueprint.make({
|
|
13
|
-
key: BLUEPRINT_KEY,
|
|
11
|
+
key: Chess.BLUEPRINT_KEY,
|
|
14
12
|
name: "Chess",
|
|
15
13
|
tools: Blueprint.toolDefinitions({
|
|
16
14
|
operations
|
|
@@ -25,7 +23,7 @@ var make = () => Blueprint.make({
|
|
|
25
23
|
})
|
|
26
24
|
});
|
|
27
25
|
var blueprint = {
|
|
28
|
-
key: BLUEPRINT_KEY,
|
|
26
|
+
key: Chess.BLUEPRINT_KEY,
|
|
29
27
|
make
|
|
30
28
|
};
|
|
31
29
|
var chess_blueprint_default = blueprint;
|
|
@@ -33,4 +31,4 @@ var chess_blueprint_default = blueprint;
|
|
|
33
31
|
export {
|
|
34
32
|
chess_blueprint_default
|
|
35
33
|
};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-XWKNXG62.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/blueprints/chess-blueprint.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { Chess, ChessOperation } from '#types';\n\nconst operations = [ChessOperation.Move, ChessOperation.Play, ChessOperation.Print];\n\nconst make = () =>\n Blueprint.make({\n key: Chess.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: Blueprint.Definition = {\n key: Chess.BLUEPRINT_KEY,\n make,\n};\n\nexport default blueprint;\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAErB,SAASC,OAAOC,sBAAsB;AAEtC,IAAMC,aAAa;EAACD,eAAeE;EAAMF,eAAeG;EAAMH,eAAeI;;AAE7E,IAAMC,OAAO,MACXT,UAAUS,KAAK;EACbC,KAAKP,MAAMQ;EACXC,MAAM;EACNC,OAAOb,UAAUc,gBAAgB;IAAET;EAAW,CAAA;EAC9CU,cAAcd,SAASQ,KAAK;IAC1BO,QAAQd;;;;;;EAMV,CAAA;AACF,CAAA;AAEF,IAAMe,YAAkC;EACtCP,KAAKP,MAAMQ;EACXF;AACF;AAEA,IAAA,0BAAeQ;",
|
|
6
|
+
"names": ["Blueprint", "Template", "trim", "Chess", "ChessOperation", "operations", "Move", "Play", "Print", "make", "key", "BLUEPRINT_KEY", "name", "tools", "toolDefinitions", "instructions", "source", "blueprint"]
|
|
7
|
+
}
|