@dxos/plugin-chess 0.8.4-main.ead640a → 0.8.4-main.effb148878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/PLUGIN.mdl +526 -0
- package/README.md +1 -1
- package/dist/lib/neutral/ChessArticle-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 +10 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-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-2MAUPQEP.mjs +148 -0
- package/dist/lib/neutral/chunk-2MAUPQEP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-47NTXLZ4.mjs +8 -0
- package/dist/lib/neutral/chunk-47NTXLZ4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HVIKFYAW.mjs +29 -0
- package/dist/lib/neutral/chunk-HVIKFYAW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-V4UMIQ6K.mjs +31 -0
- package/dist/lib/neutral/chunk-V4UMIQ6K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs +34 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +239 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/game-variant-UMYAK7LT.mjs +41 -0
- package/dist/lib/neutral/game-variant-UMYAK7LT.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/meta.mjs.map +7 -0
- package/dist/lib/neutral/move-CSQAYS6C.mjs +37 -0
- package/dist/lib/neutral/move-CSQAYS6C.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +13 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/play-MAQS65O7.mjs +46 -0
- package/dist/lib/neutral/play-MAQS65O7.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/print-EAPXOLGE.mjs +29 -0
- package/dist/lib/neutral/print-EAPXOLGE.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +35 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/ChessPlugin.d.ts +3 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/ChessPlugin.node.d.ts +8 -0
- package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.test.d.ts +2 -0
- package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -5
- 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 +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/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +10 -10
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +57 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Info.d.ts → Chessboard/Info.d.ts} +5 -6
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +5 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +56 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +5 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/{components/Card.stories.d.ts → containers/ChessCard/ChessCard.stories.d.ts} +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 +1 -4
- 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/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/move.d.ts +5 -0
- package/dist/types/src/operations/move.d.ts.map +1 -0
- package/dist/types/src/operations/play.d.ts +5 -0
- package/dist/types/src/operations/play.d.ts.map +1 -0
- package/dist/types/src/operations/print.d.ts +5 -0
- package/dist/types/src/operations/print.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -22
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +12 -22
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/ChessOperation.d.ts +29 -0
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +117 -58
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +50 -0
- package/src/ChessPlugin.tsx +19 -54
- package/src/ChessPlugin.workerd.ts +18 -0
- package/src/blueprints/chess-blueprint.ts +32 -0
- package/src/blueprints/index.ts +5 -0
- package/src/capabilities/blueprint-definition.ts +11 -28
- package/src/capabilities/game-variant.ts +43 -0
- package/src/capabilities/index.ts +9 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +34 -31
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +34 -77
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +1 -5
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +59 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +108 -0
- package/src/containers/ChessArticle/index.ts +5 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +47 -0
- package/src/containers/ChessCard/ChessCard.tsx +27 -0
- package/src/containers/ChessCard/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +1 -5
- package/src/meta.ts +12 -4
- package/src/operations/index.ts +11 -0
- package/src/operations/move.ts +36 -0
- package/src/operations/play.ts +45 -0
- package/src/operations/print.ts +28 -0
- package/src/plugin.ts +11 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +19 -20
- package/src/types/Chess.ts +29 -39
- package/src/types/ChessOperation.ts +88 -0
- package/src/types/index.ts +1 -1
- package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs +0 -96
- package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-UVRFUJYE.mjs +0 -11
- package/dist/lib/browser/chunk-E5NQWXQ7.mjs +0 -306
- package/dist/lib/browser/chunk-E5NQWXQ7.mjs.map +0 -7
- package/dist/lib/browser/chunk-KQOVCG7Z.mjs +0 -8
- package/dist/lib/browser/chunk-KQOVCG7Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-M63HYNXU.mjs +0 -84
- package/dist/lib/browser/chunk-M63HYNXU.mjs.map +0 -7
- package/dist/lib/browser/chunk-VA5TW6SD.mjs +0 -169
- package/dist/lib/browser/chunk-VA5TW6SD.mjs.map +0 -7
- package/dist/lib/browser/chunk-WSUUPPDK.mjs +0 -26
- package/dist/lib/browser/chunk-WSUUPPDK.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -124
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs +0 -25
- package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-OLAZCU2E.mjs +0 -38
- package/dist/lib/browser/react-surface-OLAZCU2E.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs +0 -97
- package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-Z47C4EEX.mjs +0 -12
- package/dist/lib/node-esm/chunk-5C2OYL2B.mjs +0 -27
- package/dist/lib/node-esm/chunk-5C2OYL2B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7YK5RFHY.mjs +0 -85
- package/dist/lib/node-esm/chunk-7YK5RFHY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C55L2OCJ.mjs +0 -10
- package/dist/lib/node-esm/chunk-C55L2OCJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DWGG7IGH.mjs +0 -307
- package/dist/lib/node-esm/chunk-DWGG7IGH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SW5N5XNV.mjs +0 -170
- package/dist/lib/node-esm/chunk-SW5N5XNV.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -125
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-FIKCDZ5L.mjs +0 -39
- package/dist/lib/node-esm/react-surface-FIKCDZ5L.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -44
- 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/artifact-definition.ts +0 -129
- package/src/capabilities/intent-resolver.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -23
- package/src/components/Card.stories.tsx +0 -66
- package/src/components/Chessboard.stories.tsx +0 -49
- package/src/components/ChessboardArticle.tsx +0 -69
- 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-UVRFUJYE.mjs.map → neutral/ChessPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-Z47C4EEX.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/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,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,21 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/ChessPlugin.workerd.ts
|
|
4
|
+
import { Plugin } from "@dxos/app-framework";
|
|
5
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
+
import { OperationHandler } from "#capabilities";
|
|
7
|
+
import { meta } from "#meta";
|
|
8
|
+
import { Chess } from "#types";
|
|
9
|
+
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addOperationHandlerModule({
|
|
10
|
+
activate: OperationHandler
|
|
11
|
+
}), AppPlugin.addSchemaModule({
|
|
12
|
+
schema: [
|
|
13
|
+
Chess.State
|
|
14
|
+
]
|
|
15
|
+
}), Plugin.make);
|
|
16
|
+
var ChessPlugin_workerd_default = ChessPlugin;
|
|
17
|
+
export {
|
|
18
|
+
ChessPlugin,
|
|
19
|
+
ChessPlugin_workerd_default as default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ChessPlugin.workerd.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ChessPlugin.workerd.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { OperationHandler } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,wBAAwB;AACjC,SAASC,YAAY;AACrB,SAASC,aAAa;AAEf,IAAMC,cAAcL,OAAOM,OAAOH,IAAAA,EAAMI,KAC7CN,UAAUO,0BAA0B;EAAEC,UAAUP;AAAiB,CAAA,GACjED,UAAUS,gBAAgB;EAAEC,QAAQ;IAACP,MAAMQ;;AAAO,CAAA,GAClDZ,OAAOa,IAAI;AAGb,IAAA,8BAAeR;",
|
|
6
|
+
"names": ["Plugin", "AppPlugin", "OperationHandler", "meta", "Chess", "ChessPlugin", "define", "pipe", "addOperationHandlerModule", "activate", "addSchemaModule", "schema", "State", "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-UMYAK7LT.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,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 { DXN, 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
|
+
Annotation.IconAnnotation.set({
|
|
29
|
+
icon: "ph--shield-chevron--regular",
|
|
30
|
+
hue: "amber"
|
|
31
|
+
}),
|
|
32
|
+
BlueprintsAnnotation.set([
|
|
33
|
+
BLUEPRINT_KEY
|
|
34
|
+
]),
|
|
35
|
+
// Implementation detail of the unified `Game` schema. The user-facing object is `Game`;
|
|
36
|
+
// this state is only ever referenced via `Game.variant`. SystemType keeps it out of the
|
|
37
|
+
// navtree's typed branches so an orphaned state object doesn't reappear after the
|
|
38
|
+
// wrapping Game is deleted.
|
|
39
|
+
SystemTypeAnnotation.set(true),
|
|
40
|
+
Type.makeObject(DXN.make("org.dxos.type.chess.state", "0.1.0"))
|
|
41
|
+
);
|
|
42
|
+
var make = ({ pgn, fen } = {}) => {
|
|
43
|
+
const chess = new ChessJS();
|
|
44
|
+
if (pgn) {
|
|
45
|
+
try {
|
|
46
|
+
chess.loadPgn(pgn);
|
|
47
|
+
} catch {
|
|
48
|
+
log.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 37, S: void 0 });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return Obj.make(State, {
|
|
52
|
+
pgn,
|
|
53
|
+
fen
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/types/ChessOperation.ts
|
|
58
|
+
var ChessOperation_exports = {};
|
|
59
|
+
__export(ChessOperation_exports, {
|
|
60
|
+
Move: () => Move,
|
|
61
|
+
Play: () => Play,
|
|
62
|
+
Print: () => Print
|
|
63
|
+
});
|
|
64
|
+
import * as Schema2 from "effect/Schema";
|
|
65
|
+
import { Operation } from "@dxos/compute";
|
|
66
|
+
import { Database } from "@dxos/echo";
|
|
67
|
+
import { GameRef } from "@dxos/plugin-game";
|
|
68
|
+
var Move = Operation.make({
|
|
69
|
+
meta: {
|
|
70
|
+
key: "org.dxos.function.chess.move",
|
|
71
|
+
name: "Move",
|
|
72
|
+
description: "Makes a move in the given chess game.",
|
|
73
|
+
icon: "ph--play--regular"
|
|
74
|
+
},
|
|
75
|
+
input: Schema2.Struct({
|
|
76
|
+
game: GameRef(State).annotations({
|
|
77
|
+
description: "The ID of the game object (variant must be Chess)."
|
|
78
|
+
}),
|
|
79
|
+
move: Schema2.String.annotations({
|
|
80
|
+
description: "The move to make in the chess game.",
|
|
81
|
+
examples: [
|
|
82
|
+
"e4",
|
|
83
|
+
"Bf3"
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
output: Schema2.Struct({
|
|
88
|
+
pgn: Schema2.String.annotations({
|
|
89
|
+
description: "The PGN of the game after the move was played."
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
services: [
|
|
93
|
+
Database.Service
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
var Play = Operation.make({
|
|
97
|
+
meta: {
|
|
98
|
+
key: "org.dxos.function.chess.play",
|
|
99
|
+
name: "Play",
|
|
100
|
+
description: "Uses the chess engine to play the next move.",
|
|
101
|
+
icon: "ph--play--regular"
|
|
102
|
+
},
|
|
103
|
+
input: Schema2.Struct({
|
|
104
|
+
game: GameRef(State).annotations({
|
|
105
|
+
description: "The ID of the game object (variant must be Chess)."
|
|
106
|
+
}),
|
|
107
|
+
side: Schema2.optional(Schema2.Literal("white", "black", "any")).annotations({
|
|
108
|
+
description: "The side to play.",
|
|
109
|
+
defaultValue: "any"
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
output: Schema2.Struct({
|
|
113
|
+
pgn: Schema2.String.annotations({
|
|
114
|
+
description: "The PGN of the game after the move was played."
|
|
115
|
+
}),
|
|
116
|
+
move: Schema2.optional(Schema2.String).annotations({
|
|
117
|
+
description: "The move that was played."
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
services: [
|
|
121
|
+
Database.Service
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
var Print = Operation.make({
|
|
125
|
+
meta: {
|
|
126
|
+
key: "org.dxos.function.chess.print",
|
|
127
|
+
name: "Print game",
|
|
128
|
+
description: "Prints the chess game to ASCII.",
|
|
129
|
+
icon: "ph--clipboard-text--regular"
|
|
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-2MAUPQEP.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 { DXN, 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 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 Type.makeObject(DXN.make('org.dxos.type.chess.state', '0.1.0')),\n);\n\nexport type State = Type.InstanceType<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 icon: 'ph--play--regular',\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 icon: 'ph--play--regular',\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 icon: 'ph--clipboard-text--regular',\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,KAAKC,YAAYC,KAAKC,YAAY;AAC3C,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/BH,aAAWU;EACTC,CAAAA,EAAAA,KAAM,oBAAA,IAAA,KAAA,GAAA,eAAA;;EACNC,WAAK,eAAA,IAAA;IAEPd,MAAAA;IAA0BQ,KAAAA;GAAc;EACxC,qBAAA,IAAA;IACA;EACA,CAAA;;;;;uBASc,IAAIV,IAAAA;EAAAA,KAAAA,WAAAA,IAAAA,KAAAA,6BAAAA,OAAAA,CAAAA;AAAAA;AAClB,IAAS,OAAA,CAAA,EAAA,KAAA,IAAA,IAAA,CAAA,MAAA;QACP,QAAI,IAAA,QAAA;WACFiB;AACF,QAAE;AACAR,YAAIS,QAAKC,GAAAA;IACX,QAAA;AACF,UAAA,KAAA,KAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;IAEA;;SAEEP,IAAAA,KAAAA,OAAAA;IACF;IACA;;;;;ACvDF;;;;;;AAMA,YAAYQ,aAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,eAAe;AAIjB,IAAMC,OAAOC,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;IACbC,MAAM;EACR;EACAC,OAAcC,eAAO;IACnBC,MAAMC,QAAcC,KAAK,EAAEC,YAAY;MACrCP,aAAa;IACf,CAAA;IACAQ,MAAaC,eAAOF,YAAY;MAC9BP,aAAa;MACbU,UAAU;QAAC;QAAM;;IACnB,CAAA;EACF,CAAA;EACAC,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BP,aAAa;IACf,CAAA;EACF,CAAA;EACAa,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMC,OAAOrB,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;IACbC,MAAM;EACR;EACAC,OAAcC,eAAO;IACnBC,MAAMC,QAAcC,KAAK,EAAEC,YAAY;MACrCP,aAAa;IACf,CAAA;IACAiB,MAAaC,iBAAgBC,gBAAQ,SAAS,SAAS,KAAA,CAAA,EAAQZ,YAAY;MACzEP,aAAa;MACboB,cAAc;IAChB,CAAA;EACF,CAAA;EACAT,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BP,aAAa;IACf,CAAA;IACAQ,MAAaU,iBAAgBT,cAAM,EAAEF,YAAY;MAC/CP,aAAa;IACf,CAAA;EACF,CAAA;EACAa,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMM,QAAQ1B,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;IACbC,MAAM;EACR;EACAC,OAAcC,eAAO;IACnBS,KAAYM,iBACHT,eAAOF,YAAY;MACxBP,aAAa;IACf,CAAA,CAAA;IAEFsB,KAAYJ,iBACHT,eAAOF,YAAY;MACxBP,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA;EACAW,QAAeR,eAAO;IACpBoB,OAAcd;EAChB,CAAA;AACF,CAAA;",
|
|
6
|
+
"names": ["Chess", "ChessJS", "Schema", "BlueprintsAnnotation", "DXN", "Annotation", "Obj", "Type", "FormInputAnnotation", "SystemTypeAnnotation", "log", "BLUEPRINT_KEY", "description", "fen", "String", "IconAnnotation", "icon", "hue", "chess", "warn", "pgn", "Schema", "Operation", "Database", "GameRef", "Move", "Operation", "make", "meta", "key", "name", "description", "icon", "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,8 @@
|
|
|
1
|
+
// src/operations/index.ts
|
|
2
|
+
import { OperationHandlerSet } from "@dxos/compute";
|
|
3
|
+
var ChessOperationHandlerSet = OperationHandlerSet.lazy(() => import("./move-CSQAYS6C.mjs"), () => import("./play-MAQS65O7.mjs"), () => import("./print-EAPXOLGE.mjs"));
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
ChessOperationHandlerSet
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=chunk-47NTXLZ4.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,29 @@
|
|
|
1
|
+
// src/ChessPlugin.tsx
|
|
2
|
+
import { Plugin } from "@dxos/app-framework";
|
|
3
|
+
import { AppPlugin, AppActivationEvents } from "@dxos/app-toolkit";
|
|
4
|
+
import { BlueprintDefinition, GameVariant, OperationHandler } from "#capabilities";
|
|
5
|
+
import { meta } from "#meta";
|
|
6
|
+
import { translations } from "#translations";
|
|
7
|
+
import { Chess } from "#types";
|
|
8
|
+
var ChessPlugin = Plugin.define(meta).pipe(Plugin.addModule({
|
|
9
|
+
id: "game-variant",
|
|
10
|
+
activatesOn: AppActivationEvents.SetupSchema,
|
|
11
|
+
activate: GameVariant
|
|
12
|
+
}), AppPlugin.addBlueprintDefinitionModule({
|
|
13
|
+
activate: BlueprintDefinition
|
|
14
|
+
}), AppPlugin.addOperationHandlerModule({
|
|
15
|
+
activate: OperationHandler
|
|
16
|
+
}), AppPlugin.addSchemaModule({
|
|
17
|
+
schema: [
|
|
18
|
+
Chess.State
|
|
19
|
+
]
|
|
20
|
+
}), AppPlugin.addTranslationsModule({
|
|
21
|
+
translations
|
|
22
|
+
}), Plugin.make);
|
|
23
|
+
var ChessPlugin_default = ChessPlugin;
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
ChessPlugin,
|
|
27
|
+
ChessPlugin_default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-HVIKFYAW.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,31 @@
|
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import { meta as gameMeta } from "@dxos/plugin-game";
|
|
3
|
+
import { trim } from "@dxos/util";
|
|
4
|
+
var meta = {
|
|
5
|
+
id: "org.dxos.plugin.chess",
|
|
6
|
+
name: "Chess",
|
|
7
|
+
author: "DXOS",
|
|
8
|
+
description: trim`
|
|
9
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
10
|
+
Track game history and analyze moves in real-time.
|
|
11
|
+
`,
|
|
12
|
+
icon: "ph--shield-chevron--regular",
|
|
13
|
+
iconHue: "amber",
|
|
14
|
+
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
15
|
+
spec: "PLUGIN.mdl",
|
|
16
|
+
screenshots: [
|
|
17
|
+
"https://dxos.network/plugin-details-chess-dark.png"
|
|
18
|
+
],
|
|
19
|
+
dependsOn: [
|
|
20
|
+
gameMeta.id
|
|
21
|
+
],
|
|
22
|
+
version: "0.8.3",
|
|
23
|
+
tags: [
|
|
24
|
+
"game"
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
meta
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-V4UMIQ6K.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 { meta as gameMeta } from '@dxos/plugin-game';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.chess',\n name: 'Chess',\n author: 'DXOS',\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 spec: 'PLUGIN.mdl',\n screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],\n dependsOn: [gameMeta.id],\n version: '0.8.3',\n tags: ['game'],\n};\n"],
|
|
5
|
+
"mappings": ";AAKA,SAASA,QAAQC,gBAAgB;AACjC,SAASC,YAAY;AAEd,IAAMF,OAAoB;EAC/BG,IAAI;EACJC,MAAM;EACNC,QAAQ;EACRC,aAAaJ;;;;EAIbK,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,MAAM;EACNC,aAAa;IAAC;;EACdC,WAAW;IAACX,SAASE;;EACrBU,SAAS;EACTC,MAAM;IAAC;;AACT;",
|
|
6
|
+
"names": ["meta", "gameMeta", "trim", "id", "name", "author", "description", "icon", "iconHue", "source", "spec", "screenshots", "dependsOn", "version", "tags"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/blueprints/chess-blueprint.ts
|
|
2
|
+
import { Blueprint, Template } from "@dxos/compute";
|
|
3
|
+
import { trim } from "@dxos/util";
|
|
4
|
+
import { Chess, ChessOperation } from "#types";
|
|
5
|
+
var operations = [
|
|
6
|
+
ChessOperation.Move,
|
|
7
|
+
ChessOperation.Play,
|
|
8
|
+
ChessOperation.Print
|
|
9
|
+
];
|
|
10
|
+
var make = () => Blueprint.make({
|
|
11
|
+
key: Chess.BLUEPRINT_KEY,
|
|
12
|
+
name: "Chess",
|
|
13
|
+
tools: Blueprint.toolDefinitions({
|
|
14
|
+
operations
|
|
15
|
+
}),
|
|
16
|
+
instructions: Template.make({
|
|
17
|
+
source: trim`
|
|
18
|
+
You are an expert chess player.
|
|
19
|
+
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
20
|
+
You could suggest a good next move or offer to play a move.
|
|
21
|
+
Don't actually make a move unless you are asked to.
|
|
22
|
+
`
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
var blueprint = {
|
|
26
|
+
key: Chess.BLUEPRINT_KEY,
|
|
27
|
+
make
|
|
28
|
+
};
|
|
29
|
+
var chess_blueprint_default = blueprint;
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
chess_blueprint_default
|
|
33
|
+
};
|
|
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
|
+
}
|