@dxos/plugin-chess 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{ChessboardContainer-LIZDOGHI.mjs → ChessboardContainer-5YXEM4VR.mjs} +9 -10
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs +11 -0
- package/dist/lib/browser/{chunk-EKNL3H3U.mjs → chunk-5DOZV3PW.mjs} +7 -19
- package/dist/lib/browser/{chunk-EKNL3H3U.mjs.map → chunk-5DOZV3PW.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-PE3IWOFR.mjs → chunk-DUO4WTAM.mjs} +5 -5
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-T275KG4U.mjs → chunk-FBLAVAMY.mjs} +12 -12
- package/dist/lib/browser/chunk-FBLAVAMY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KD4I5VTZ.mjs → chunk-Q5TZCIH7.mjs} +2 -2
- package/dist/lib/browser/{chunk-KYO4ODJJ.mjs → chunk-TIIGNOGK.mjs} +19 -13
- package/dist/lib/browser/chunk-TIIGNOGK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +22 -23
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-DA5H5633.mjs → intent-resolver-GXZN2EBT.mjs} +5 -5
- package/dist/lib/browser/{intent-resolver-DA5H5633.mjs.map → intent-resolver-GXZN2EBT.mjs.map} +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-MIMI6LPO.mjs → react-surface-KTTAUHAA.mjs} +7 -7
- package/dist/lib/browser/{react-surface-MIMI6LPO.mjs.map → react-surface-KTTAUHAA.mjs.map} +1 -1
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{ChessboardContainer-XWVQ5K7N.mjs → ChessboardContainer-7OQ6TOKB.mjs} +9 -10
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs +12 -0
- package/dist/lib/node-esm/{chunk-EGBWRJWH.mjs → chunk-F4C2HVZL.mjs} +7 -19
- package/dist/lib/node-esm/{chunk-EGBWRJWH.mjs.map → chunk-F4C2HVZL.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-6OWCPDUA.mjs → chunk-KNOOJFIR.mjs} +5 -5
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5DYLCQBR.mjs → chunk-MP3A3AGA.mjs} +12 -12
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A34JOK3K.mjs → chunk-RTCAAOLF.mjs} +19 -13
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q5LJYIMO.mjs → chunk-VVXTAVIS.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +22 -23
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PODONUD3.mjs → intent-resolver-HK5L6P6Z.mjs} +5 -5
- package/dist/lib/node-esm/{intent-resolver-PODONUD3.mjs.map → intent-resolver-HK5L6P6Z.mjs.map} +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-XMKFR5BC.mjs → react-surface-VO4PSY6O.mjs} +7 -7
- package/dist/lib/node-esm/{react-surface-XMKFR5BC.mjs.map → react-surface-VO4PSY6O.mjs.map} +1 -1
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/ChessPlugin.d.ts +1 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.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/components/Card.stories.d.ts +11 -3
- package/dist/types/src/components/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +9 -9
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -1
- package/dist/types/src/functions/create.d.ts +2 -2
- package/dist/types/src/functions/create.d.ts.map +1 -1
- package/dist/types/src/functions/move.d.ts +1 -1
- package/dist/types/src/functions/move.d.ts.map +1 -1
- package/dist/types/src/functions/play.d.ts +1 -1
- package/dist/types/src/functions/play.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +2 -2
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/src/types/ChessAction.d.ts +1 -1
- package/dist/types/src/types/ChessAction.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -37
- package/src/ChessPlugin.tsx +47 -47
- package/src/capabilities/artifact-definition.ts +3 -2
- package/src/capabilities/blueprint-definition.ts +3 -3
- package/src/components/Card.stories.tsx +3 -5
- package/src/components/Chessboard.stories.tsx +3 -4
- package/src/components/ChessboardArticle.tsx +6 -7
- package/src/components/Info.tsx +6 -6
- package/src/functions/create.ts +4 -2
- package/src/functions/move.ts +4 -2
- package/src/functions/play.ts +4 -2
- package/src/meta.ts +4 -4
- package/src/translations.ts +8 -8
- package/src/types/Chess.ts +20 -26
- package/src/types/ChessAction.ts +1 -1
- package/dist/lib/browser/ChessboardContainer-LIZDOGHI.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-RVS32T67.mjs +0 -11
- package/dist/lib/browser/chunk-KYO4ODJJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +0 -7
- package/dist/lib/browser/chunk-T275KG4U.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-XWVQ5K7N.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-F57ZSRAG.mjs +0 -12
- package/dist/lib/node-esm/chunk-5DYLCQBR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-A34JOK3K.mjs.map +0 -7
- /package/dist/lib/browser/{blueprint-definition-RVS32T67.mjs.map → blueprint-definition-FD4TL5EE.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-KD4I5VTZ.mjs.map → chunk-Q5TZCIH7.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-F57ZSRAG.mjs.map → blueprint-definition-O7ZM3HUF.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Q5LJYIMO.mjs.map → chunk-VVXTAVIS.mjs.map} +0 -0
package/dist/lib/browser/{ChessboardContainer-LIZDOGHI.mjs → ChessboardContainer-5YXEM4VR.mjs}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Chessboard
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5DOZV3PW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
meta
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DUO4WTAM.mjs";
|
|
7
7
|
|
|
8
8
|
// src/components/ChessboardContainer.tsx
|
|
9
9
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
@@ -13,7 +13,7 @@ import { getSpace } from "@dxos/react-client/echo";
|
|
|
13
13
|
// src/components/ChessboardArticle.tsx
|
|
14
14
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
15
15
|
import React, { useCallback, useRef, useState } from "react";
|
|
16
|
-
import {
|
|
16
|
+
import { Toolbar, useTranslation } from "@dxos/react-ui";
|
|
17
17
|
import { StackItem } from "@dxos/react-ui-stack";
|
|
18
18
|
import { mx } from "@dxos/react-ui-theme";
|
|
19
19
|
var ChessboardArticle = ({ game, role }) => {
|
|
@@ -28,20 +28,19 @@ var ChessboardArticle = ({ game, role }) => {
|
|
|
28
28
|
}, []);
|
|
29
29
|
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
30
30
|
toolbar: true,
|
|
31
|
-
classNames: "@container
|
|
31
|
+
classNames: "@container"
|
|
32
32
|
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
33
33
|
game,
|
|
34
34
|
ref: controller
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(IconButton, {
|
|
36
|
-
variant: "ghost",
|
|
35
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
37
36
|
icon: "ph--info--regular",
|
|
38
37
|
iconOnly: true,
|
|
39
38
|
label: t("toggle info button"),
|
|
40
|
-
|
|
41
|
-
classNames: mx("invisible
|
|
39
|
+
disabled: open,
|
|
40
|
+
classNames: mx("invisible @3xl:visible"),
|
|
42
41
|
onClick: () => setOpen((open2) => !open2)
|
|
43
42
|
})), /* @__PURE__ */ React.createElement("div", {
|
|
44
|
-
className: mx("grid
|
|
43
|
+
className: mx("grid bs-full is-full gap-2", open && "@3xl:grid-cols-[1fr_320px]", role === "section" && "aspect-square", role === "section" && open && "@3xl:aspect-auto")
|
|
45
44
|
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
46
45
|
classNames: "m-4 rounded-sm overflow-hidden",
|
|
47
46
|
orientation
|
|
@@ -94,4 +93,4 @@ export {
|
|
|
94
93
|
ChessboardContainer,
|
|
95
94
|
ChessboardContainer_default as default
|
|
96
95
|
};
|
|
97
|
-
//# sourceMappingURL=ChessboardContainer-
|
|
96
|
+
//# sourceMappingURL=ChessboardContainer-5YXEM4VR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ChessboardContainer.tsx", "../../../src/components/ChessboardArticle.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { type Chess } from '../types';\n\nimport { Chessboard } from './Chessboard';\nimport { ChessboardArticle } from './ChessboardArticle';\n\nexport type ChessboardContainerProps = {\n game: Chess.Game;\n role?: string;\n};\n\nexport const ChessboardContainer = ({ game, role }: ChessboardContainerProps) => {\n const space = getSpace(game);\n if (!space) {\n return null;\n }\n\n switch (role) {\n case 'card--popover':\n case 'card--intrinsic':\n case 'card--extrinsic': {\n return (\n <Chessboard.Root game={game}>\n <Chessboard.Content role={role}>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n );\n }\n\n default: {\n return <ChessboardArticle game={game} role={role} />;\n }\n }\n};\n\nexport default ChessboardContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\nimport { type Chess } from '../types';\n\nimport { Chessboard, type ChessboardController, type ChessboardInfoProps } from './Chessboard';\n\nexport const ChessboardArticle = ({ game, role }: { game: Chess.Game; role?: string }) => {\n const { t } = useTranslation(meta.id);\n const [orientation, setOrientation] = useState<Player>('white');\n const [open, setOpen] = useState(true);\n const controller = useRef<ChessboardController>(null);\n\n // TODO(burdon): Keyboard handler.\n const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {\n controller.current?.setMoveNumber(index);\n }, []);\n\n return (\n <StackItem.Content toolbar classNames='@container'>\n <Chessboard.Root game={game} ref={controller}>\n <Toolbar.Root>\n <Toolbar.IconButton\n icon='ph--info--regular'\n iconOnly\n label={t('toggle info button')}\n disabled={open}\n classNames={mx('invisible @3xl:visible')}\n onClick={() => setOpen((open) => !open)}\n />\n </Toolbar.Root>\n <div\n className={mx(\n 'grid bs-full is-full gap-2',\n open && '@3xl:grid-cols-[1fr_320px]',\n role === 'section' && 'aspect-square',\n role === 'section' && open && '@3xl:aspect-auto',\n )}\n >\n <Chessboard.Content>\n <Chessboard.Board classNames='m-4 rounded-sm overflow-hidden' orientation={orientation} />\n </Chessboard.Content>\n {open && (\n <div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>\n <Chessboard.Info\n orientation={orientation}\n min={8}\n max={8}\n onOrientationChange={setOrientation}\n onClose={() => setOpen(false)}\n onSelect={handleSelect}\n />\n </div>\n )}\n </div>\n </Chessboard.Root>\n </StackItem.Content>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,gBAAgB;;;;ACFzB,OAAOC,SAASC,aAAaC,QAAQC,gBAAgB;AAErD,SAASC,SAASC,sBAAsB;AAExC,SAASC,iBAAiB;AAC1B,SAASC,UAAU;AAOZ,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAAuC;;;AACnF,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAM,CAACC,aAAaC,cAAAA,IAAkBC,SAAiB,OAAA;AACvD,UAAM,CAACC,MAAMC,OAAAA,IAAWF,SAAS,IAAA;AACjC,UAAMG,aAAaC,OAA6B,IAAA;AAGhD,UAAMC,eAAeC,YAA0D,CAACC,UAAAA;AAC9EJ,iBAAWK,SAASC,cAAcF,KAAAA;IACpC,GAAG,CAAA,CAAE;AAEL,WACE,sBAAA,cAACG,UAAUC,SAAO;MAACC,SAAAA;MAAQC,YAAW;OACpC,sBAAA,cAACC,WAAWC,MAAI;MAACvB;MAAYwB,KAAKb;OAChC,sBAAA,cAACc,QAAQF,MAAI,MACX,sBAAA,cAACE,QAAQC,YAAU;MACjBC,MAAK;MACLC,UAAAA;MACAC,OAAO3B,EAAE,oBAAA;MACT4B,UAAUrB;MACVY,YAAYU,GAAG,wBAAA;MACfC,SAAS,MAAMtB,QAAQ,CAACD,UAAS,CAACA,KAAAA;SAGtC,sBAAA,cAACwB,OAAAA;MACCC,WAAWH,GACT,8BACAtB,QAAQ,8BACRR,SAAS,aAAa,iBACtBA,SAAS,aAAaQ,QAAQ,kBAAA;OAGhC,sBAAA,cAACa,WAAWH,SAAO,MACjB,sBAAA,cAACG,WAAWa,OAAK;MAACd,YAAW;MAAiCf;SAE/DG,QACC,sBAAA,cAACwB,OAAAA;MAAIC,WAAU;OACb,sBAAA,cAACZ,WAAWc,MAAI;MACd9B;MACA+B,KAAK;MACLC,KAAK;MACLC,qBAAqBhC;MACrBiC,SAAS,MAAM9B,QAAQ,KAAA;MACvB+B,UAAU5B;;;;;AAQ1B;;;ADjDO,IAAM6B,sBAAsB,CAAC,EAAEC,MAAMC,KAAI,MAA4B;;;AAC1E,UAAMC,QAAQC,SAASH,IAAAA;AACvB,QAAI,CAACE,OAAO;AACV,aAAO;IACT;AAEA,YAAQD,MAAAA;MACN,KAAK;MACL,KAAK;MACL,KAAK,mBAAmB;AACtB,eACE,gBAAAG,OAAA,cAACC,WAAWC,MAAI;UAACN;WACf,gBAAAI,OAAA,cAACC,WAAWE,SAAO;UAACN;WAClB,gBAAAG,OAAA,cAACC,WAAWG,OAAK,IAAA,CAAA,CAAA;MAIzB;MAEA,SAAS;AACP,eAAO,gBAAAJ,OAAA,cAACK,mBAAAA;UAAkBT;UAAYC;;MACxC;IACF;;;;AACF;AAEA,IAAA,8BAAeF;",
|
|
6
|
+
"names": ["React", "getSpace", "React", "useCallback", "useRef", "useState", "Toolbar", "useTranslation", "StackItem", "mx", "ChessboardArticle", "game", "role", "t", "useTranslation", "meta", "id", "orientation", "setOrientation", "useState", "open", "setOpen", "controller", "useRef", "handleSelect", "useCallback", "index", "current", "setMoveNumber", "StackItem", "Content", "toolbar", "classNames", "Chessboard", "Root", "ref", "Toolbar", "IconButton", "icon", "iconOnly", "label", "disabled", "mx", "onClick", "div", "className", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect", "ChessboardContainer", "game", "role", "space", "getSpace", "React", "Chessboard", "Root", "Content", "Board", "ChessboardArticle"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHESS_BLUEPRINT_KEY,
|
|
3
|
+
blueprint_definition_default
|
|
4
|
+
} from "./chunk-TIIGNOGK.mjs";
|
|
5
|
+
import "./chunk-FBLAVAMY.mjs";
|
|
6
|
+
import "./chunk-DUO4WTAM.mjs";
|
|
7
|
+
export {
|
|
8
|
+
CHESS_BLUEPRINT_KEY,
|
|
9
|
+
blueprint_definition_default as default
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=blueprint-definition-FD4TL5EE.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
meta
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DUO4WTAM.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/Chessboard.tsx
|
|
6
6
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
@@ -72,7 +72,7 @@ var History = ({ classNames, model, min, max, onSelect }) => {
|
|
|
72
72
|
var _effect = _useSignals();
|
|
73
73
|
try {
|
|
74
74
|
const { t } = useTranslation(meta.id);
|
|
75
|
-
const label = model.game.isGameOver() ? model.game.isCheckmate() ? t("game.checkmate") : model.game.isStalemate() ? t("game.stalemate") : t("game.draw") : model.game.isCheck() ? t("game.check") : void 0;
|
|
75
|
+
const label = model.game.isGameOver() ? model.game.isCheckmate() ? t("game.checkmate label") : model.game.isStalemate() ? t("game.stalemate label") : t("game.draw label") : model.game.isCheck() ? t("game.check label") : void 0;
|
|
76
76
|
const history = model.game.history();
|
|
77
77
|
const moves = useMemo(() => history.reduce((acc, move, index) => {
|
|
78
78
|
if (index % 2 === 0) {
|
|
@@ -112,7 +112,7 @@ var History = ({ classNames, model, min, max, onSelect }) => {
|
|
|
112
112
|
]);
|
|
113
113
|
return /* @__PURE__ */ React.createElement("div", {
|
|
114
114
|
ref: scrollerRef,
|
|
115
|
-
className: mx("overflow-y-
|
|
115
|
+
className: mx("overflow-y-auto", classNames),
|
|
116
116
|
style: {
|
|
117
117
|
minHeight: min === void 0 ? "auto" : `${min * 24}px`,
|
|
118
118
|
maxHeight: max === void 0 ? "auto" : `${max * 24}px`
|
|
@@ -142,7 +142,7 @@ var PlayerIndicator = ({ children, model, player, icon }) => {
|
|
|
142
142
|
try {
|
|
143
143
|
const turn = player === (model.game.turn() === "w" ? "white" : "black");
|
|
144
144
|
return /* @__PURE__ */ React.createElement("div", {
|
|
145
|
-
className: "grid grid-cols-[2rem_1fr_2rem] gap-2 bs-[--rail-size]
|
|
145
|
+
className: "grid grid-cols-[2rem_1fr_2rem] gap-2 bs-[--rail-size] pli-1 flex items-center overflow-hidden"
|
|
146
146
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
147
147
|
className: "place-items-center"
|
|
148
148
|
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
@@ -179,22 +179,10 @@ var PlayerSelector = ({ value, onValueChange, members }) => {
|
|
|
179
179
|
};
|
|
180
180
|
|
|
181
181
|
// src/components/Chessboard.tsx
|
|
182
|
-
function _define_property(obj, key, value) {
|
|
183
|
-
if (key in obj) {
|
|
184
|
-
Object.defineProperty(obj, key, {
|
|
185
|
-
value,
|
|
186
|
-
enumerable: true,
|
|
187
|
-
configurable: true,
|
|
188
|
-
writable: true
|
|
189
|
-
});
|
|
190
|
-
} else {
|
|
191
|
-
obj[key] = value;
|
|
192
|
-
}
|
|
193
|
-
return obj;
|
|
194
|
-
}
|
|
195
182
|
var ExtendedChessModel = class extends ChessModel {
|
|
183
|
+
object;
|
|
196
184
|
constructor(object) {
|
|
197
|
-
super(),
|
|
185
|
+
super(), this.object = object;
|
|
198
186
|
}
|
|
199
187
|
};
|
|
200
188
|
var Root = /* @__PURE__ */ forwardRef(({ game, children }, forwardedRef) => {
|
|
@@ -303,4 +291,4 @@ export {
|
|
|
303
291
|
ExtendedChessModel,
|
|
304
292
|
Chessboard
|
|
305
293
|
};
|
|
306
|
-
//# sourceMappingURL=chunk-
|
|
294
|
+
//# sourceMappingURL=chunk-5DOZV3PW.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Chessboard.tsx", "../../../src/components/Info.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\nimport { useSoundEffect } from '@dxos/react-ui-sfx';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Chess } from '../types';\n\nimport { Info, type InfoProps } from './Info';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\nexport class ExtendedChessModel extends ChessModel {\n constructor(readonly object: Chess.Game) {\n super();\n }\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n game: Chess.Game;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {\n const model = useMemo(() => new ExtendedChessModel(game), []);\n const click = useSoundEffect('Click');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(game.pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(game.pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [game.pgn]);\n\n // Move.\n const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(\n (move) => {\n if (!model.makeMove(move)) {\n return false;\n }\n\n void click.play();\n game.pgn = model.pgn;\n return true;\n },\n [model],\n );\n\n return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {children}\n </Gameboard.Root>\n );\n});\n\n//\n// Content\n//\n\ntype Role = 'card--popover' | 'card--intrinsic' | 'card--extrinsic';\n\ntype ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;\n\nconst Content = ({ classNames, children, role }: ContentProps) => {\n return (\n <Gameboard.Content\n classNames={mx(classNames, role === 'card--popover' && 'size-container popover-square')}\n grow={!role || role === 'card--extrinsic'}\n contain={!role || role === 'card--extrinsic' || role === 'card--popover'}\n >\n {children}\n </Gameboard.Content>\n );\n};\n\n//\n// Board\n//\n\ntype BoardProps = NaturalChessboardProps;\n\nconst Board = (props: BoardProps) => {\n const { model } = useGameboardContext<ChessModel>(Board.displayName);\n\n // Keyboard navigation.\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n // Participate in keyboard navigation (set tabIndex={0})\n ref.current.setAttribute('data-arrow-keys', 'all');\n\n return addEventListener(ref.current, 'keydown', (ev) => {\n switch (ev.key) {\n case 'ArrowUp':\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (model.moveIndex.value > 0) {\n model.setMoveIndex(model.moveIndex.value - 1);\n }\n break;\n case 'ArrowRight':\n if (model.moveIndex.value < model.game.history().length) {\n model.setMoveIndex(model.moveIndex.value + 1);\n }\n break;\n }\n });\n }, [model]);\n\n return <NaturalChessboard ref={ref} {...props} />;\n};\n\nBoard.displayName = 'Chessboard.Board';\n\n//\n// Chessboard\n//\n\nexport const Chessboard = {\n Root: Root,\n Content: Content,\n Board: Board,\n Info: Info,\n};\n\nexport type {\n RootProps as ChessboardRootProps,\n ContentProps as ChessboardContentProps,\n BoardProps as ChessboardBoardProps,\n InfoProps as ChessboardInfoProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { type SpaceMember, getSpace, useMembers } from '@dxos/react-client/echo';\nimport { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\n\nimport { type ExtendedChessModel } from './Chessboard';\n\nexport type InfoProps = ThemedClassName<\n {\n orientation?: Player;\n onOrientationChange?: (orientation: Player) => void;\n onClose?: () => void;\n } & Pick<HistoryProps, 'min' | 'max' | 'onSelect'>\n>;\n\nexport const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {\n const { t } = useTranslation(meta.id);\n const { model } = useGameboardContext<ExtendedChessModel>(Info.displayName);\n const members = useMembers(getSpace(model.object)?.key);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] is-full min-is-[18rem] p-2 overflow-hidden bg-groupSurface rounded-sm',\n classNames,\n )}\n >\n <PlayerIndicator\n model={model}\n player={orientation === 'white' ? 'black' : 'white'}\n icon={\n onClose && (\n <IconButton icon='ph--x--regular' iconOnly label={t('close info button')} size={4} onClick={onClose} />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}\n onValueChange={(value) => {\n model.object.players![orientation === 'white' ? 'black' : 'white'] = value;\n }}\n members={members}\n />\n </PlayerIndicator>\n\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip board button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation]}\n onValueChange={(value) => {\n model.object.players![orientation] = value;\n }}\n members={members}\n />\n </PlayerIndicator>\n </div>\n );\n};\n\nInfo.displayName = 'Chessboard.Info';\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.id);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate')\n : model.game.isStalemate()\n ? t('game.stalemate')\n : t('game.draw')\n : model.game.isCheck()\n ? t('game.check')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${model.moveIndex.value - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [model.moveIndex.value]);\n\n return (\n <div\n ref={scrollerRef}\n className={mx('overflow-y-scroll', classNames)}\n style={{\n minHeight: min === undefined ? 'auto' : `${min * 24}px`,\n maxHeight: max === undefined ? 'auto' : `${max * 24}px`,\n }}\n >\n {moves.map(([a, b], index) => (\n <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 pis-4 leading-1'>\n <div className='content-center text-xs text-subdued'>{index + 1}</div>\n {a && (\n <div\n data-index={a.index}\n className={mx('pis-2 cursor-pointer', a.index === model.moveIndex.value - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(a.index + 1)}\n >\n {a.move}\n </div>\n )}\n {b && (\n <div\n data-index={b.index}\n className={mx('pis-2 cursor-pointer', b.index === model.moveIndex.value - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(b.index + 1)}\n >\n {b.move}\n </div>\n )}\n </div>\n ))}\n {label && <div className='text-center'>{label}</div>}\n </div>\n );\n};\n\n//\n// PlayerIndicator\n//\n\ntype PlayerIndicatorProps = PropsWithChildren<{\n model: ExtendedChessModel;\n player: Player;\n icon?: JSX.Element;\n}>;\n\nconst PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {\n const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');\n return (\n <div className='grid grid-cols-[2rem_1fr_2rem] gap-2 bs-[--rail-size] pis-1 pie-1 flex items-center overflow-hidden'>\n <div className='place-items-center'>\n <Icon\n icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}\n size={6}\n classNames={mx(turn && (model.game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}\n />\n </div>\n <div className='truncate overflow-hidden items-center'>{children}</div>\n {icon}\n </div>\n );\n};\n\n//\n// PlayerSelector\n//\n\ntype PlayerSelectorProps = {\n value?: string;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n};\n\nconst PlayerSelector = ({ value, onValueChange, members }: PlayerSelectorProps) => {\n const { t } = useTranslation(meta.id);\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={t('select player button')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {members.map((member) => {\n const memberKey = member.identity.identityKey.toHex();\n const displayName = member.identity?.profile?.displayName || generateName(memberKey);\n return (\n <Select.Option key={memberKey} value={memberKey}>\n {displayName}\n </Select.Option>\n );\n })}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,UAELC,YACAC,aACAC,aAAAA,YACAC,qBACAC,WAAAA,UACAC,UAAAA,eACK;AAEP,SAASC,wBAAwB;AAEjC,SACEC,YACAC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;AACP,SAASC,sBAAsB;AAC/B,SAASC,MAAAA,WAAU;;;;ACtBnB,OAAOC,SAA2CC,WAAWC,SAASC,cAAc;AAEpF,SAASC,oBAAoB;AAC7B,SAA2BC,UAAUC,kBAAkB;AACvD,SAASC,MAAMC,YAAYC,QAA8BC,sBAAsB;AAC/E,SAAsBC,2BAA2B;AACjD,SAASC,UAAU;AAcZ,IAAMC,OAAO,CAAC,EAAEC,YAAYC,cAAc,SAASC,qBAAqBC,SAAS,GAAGC,MAAAA,MAAkB;;;AAC3G,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAM,EAAEC,MAAK,IAAKC,oBAAwCX,KAAKY,WAAW;AAC1E,UAAMC,UAAUC,WAAWC,SAASL,MAAMM,MAAM,GAAGC,GAAAA;AAEnD,WACE,sBAAA,cAACC,OAAAA;MACCC,WAAWC,GACT,sHACAnB,UAAAA;OAGF,sBAAA,cAACoB,iBAAAA;MACCX;MACAY,QAAQpB,gBAAgB,UAAU,UAAU;MAC5CqB,MACEnB,WACE,sBAAA,cAACoB,YAAAA;QAAWD,MAAK;QAAiBE,UAAAA;QAASC,OAAOpB,EAAE,mBAAA;QAAsBqB,MAAM;QAAGC,SAASxB;;OAIhG,sBAAA,cAACyB,gBAAAA;MACCC,OAAOpB,MAAMM,OAAOe,UAAU7B,gBAAgB,UAAU,UAAU,OAAA;MAClE8B,eAAe,CAACF,UAAAA;AACdpB,cAAMM,OAAOe,QAAS7B,gBAAgB,UAAU,UAAU,OAAA,IAAW4B;MACvE;MACAjB;SAIJ,sBAAA,cAACoB,SAAAA;MAAQvB;MAAe,GAAGL;QAE3B,sBAAA,cAACgB,iBAAAA;MACCX;MACAY,QAAQpB;MACRqB,MACEpB,uBACE,sBAAA,cAACqB,YAAAA;QACCvB,YAAYmB,GAAG,uCAAuClB,gBAAgB,WAAW,YAAA;QACjFqB,MAAK;QACLE,UAAAA;QACAC,OAAOpB,EAAE,mBAAA;QACTqB,MAAM;QACNC,SAAS,MAAMzB,oBAAoBD,gBAAgB,UAAU,UAAU,OAAA;;OAK7E,sBAAA,cAAC2B,gBAAAA;MACCC,OAAOpB,MAAMM,OAAOe,UAAU7B,WAAAA;MAC9B8B,eAAe,CAACF,UAAAA;AACdpB,cAAMM,OAAOe,QAAS7B,WAAAA,IAAe4B;MACvC;MACAjB;;;;;AAKV;AAEAb,KAAKY,cAAc;AAanB,IAAMqB,UAAU,CAAC,EAAEhC,YAAYS,OAAOwB,KAAKC,KAAKC,SAAQ,MAAgB;;;AACtE,UAAM,EAAE9B,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAMiB,QAAQhB,MAAM2B,KAAKC,WAAU,IAC/B5B,MAAM2B,KAAKE,YAAW,IACpBjC,EAAE,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\nimport { useSoundEffect } from '@dxos/react-ui-sfx';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Chess } from '../types';\n\nimport { Info, type InfoProps } from './Info';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\nexport class ExtendedChessModel extends ChessModel {\n constructor(readonly object: Chess.Game) {\n super();\n }\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n game: Chess.Game;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {\n const model = useMemo(() => new ExtendedChessModel(game), []);\n const click = useSoundEffect('Click');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(game.pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(game.pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [game.pgn]);\n\n // Move.\n const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(\n (move) => {\n if (!model.makeMove(move)) {\n return false;\n }\n\n void click.play();\n game.pgn = model.pgn;\n return true;\n },\n [model],\n );\n\n return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {children}\n </Gameboard.Root>\n );\n});\n\n//\n// Content\n//\n\ntype Role = 'card--popover' | 'card--intrinsic' | 'card--extrinsic';\n\ntype ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;\n\nconst Content = ({ classNames, children, role }: ContentProps) => {\n return (\n <Gameboard.Content\n classNames={mx(classNames, role === 'card--popover' && 'size-container popover-square')}\n grow={!role || role === 'card--extrinsic'}\n contain={!role || role === 'card--extrinsic' || role === 'card--popover'}\n >\n {children}\n </Gameboard.Content>\n );\n};\n\n//\n// Board\n//\n\ntype BoardProps = NaturalChessboardProps;\n\nconst Board = (props: BoardProps) => {\n const { model } = useGameboardContext<ChessModel>(Board.displayName);\n\n // Keyboard navigation.\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n // Participate in keyboard navigation (set tabIndex={0})\n ref.current.setAttribute('data-arrow-keys', 'all');\n\n return addEventListener(ref.current, 'keydown', (ev) => {\n switch (ev.key) {\n case 'ArrowUp':\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (model.moveIndex.value > 0) {\n model.setMoveIndex(model.moveIndex.value - 1);\n }\n break;\n case 'ArrowRight':\n if (model.moveIndex.value < model.game.history().length) {\n model.setMoveIndex(model.moveIndex.value + 1);\n }\n break;\n }\n });\n }, [model]);\n\n return <NaturalChessboard ref={ref} {...props} />;\n};\n\nBoard.displayName = 'Chessboard.Board';\n\n//\n// Chessboard\n//\n\nexport const Chessboard = {\n Root: Root,\n Content: Content,\n Board: Board,\n Info: Info,\n};\n\nexport type {\n RootProps as ChessboardRootProps,\n ContentProps as ChessboardContentProps,\n BoardProps as ChessboardBoardProps,\n InfoProps as ChessboardInfoProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { type SpaceMember, getSpace, useMembers } from '@dxos/react-client/echo';\nimport { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../meta';\n\nimport { type ExtendedChessModel } from './Chessboard';\n\nexport type InfoProps = ThemedClassName<\n {\n orientation?: Player;\n onOrientationChange?: (orientation: Player) => void;\n onClose?: () => void;\n } & Pick<HistoryProps, 'min' | 'max' | 'onSelect'>\n>;\n\nexport const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {\n const { t } = useTranslation(meta.id);\n const { model } = useGameboardContext<ExtendedChessModel>(Info.displayName);\n const members = useMembers(getSpace(model.object)?.key);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] is-full min-is-[18rem] p-2 overflow-hidden bg-groupSurface rounded-sm',\n classNames,\n )}\n >\n <PlayerIndicator\n model={model}\n player={orientation === 'white' ? 'black' : 'white'}\n icon={\n onClose && (\n <IconButton icon='ph--x--regular' iconOnly label={t('close info button')} size={4} onClick={onClose} />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}\n onValueChange={(value) => {\n model.object.players![orientation === 'white' ? 'black' : 'white'] = value;\n }}\n members={members}\n />\n </PlayerIndicator>\n\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip board button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation]}\n onValueChange={(value) => {\n model.object.players![orientation] = value;\n }}\n members={members}\n />\n </PlayerIndicator>\n </div>\n );\n};\n\nInfo.displayName = 'Chessboard.Info';\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.id);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate label')\n : model.game.isStalemate()\n ? t('game.stalemate label')\n : t('game.draw label')\n : model.game.isCheck()\n ? t('game.check label')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${model.moveIndex.value - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [model.moveIndex.value]);\n\n return (\n <div\n ref={scrollerRef}\n className={mx('overflow-y-auto', classNames)}\n style={{\n minHeight: min === undefined ? 'auto' : `${min * 24}px`,\n maxHeight: max === undefined ? 'auto' : `${max * 24}px`,\n }}\n >\n {moves.map(([a, b], index) => (\n <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 pis-4 leading-1'>\n <div className='content-center text-xs text-subdued'>{index + 1}</div>\n {a && (\n <div\n data-index={a.index}\n className={mx('pis-2 cursor-pointer', a.index === model.moveIndex.value - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(a.index + 1)}\n >\n {a.move}\n </div>\n )}\n {b && (\n <div\n data-index={b.index}\n className={mx('pis-2 cursor-pointer', b.index === model.moveIndex.value - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(b.index + 1)}\n >\n {b.move}\n </div>\n )}\n </div>\n ))}\n {label && <div className='text-center'>{label}</div>}\n </div>\n );\n};\n\n//\n// PlayerIndicator\n//\n\ntype PlayerIndicatorProps = PropsWithChildren<{\n model: ExtendedChessModel;\n player: Player;\n icon?: JSX.Element;\n}>;\n\nconst PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {\n const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');\n return (\n <div className='grid grid-cols-[2rem_1fr_2rem] gap-2 bs-[--rail-size] pli-1 flex items-center overflow-hidden'>\n <div className='place-items-center'>\n <Icon\n icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}\n size={6}\n classNames={mx(turn && (model.game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}\n />\n </div>\n <div className='truncate overflow-hidden items-center'>{children}</div>\n {icon}\n </div>\n );\n};\n\n//\n// PlayerSelector\n//\n\ntype PlayerSelectorProps = {\n value?: string;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n};\n\nconst PlayerSelector = ({ value, onValueChange, members }: PlayerSelectorProps) => {\n const { t } = useTranslation(meta.id);\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={t('select player button')} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {members.map((member) => {\n const memberKey = member.identity.identityKey.toHex();\n const displayName = member.identity?.profile?.displayName || generateName(memberKey);\n return (\n <Select.Option key={memberKey} value={memberKey}>\n {displayName}\n </Select.Option>\n );\n })}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,OAAOA,UAELC,YACAC,aACAC,aAAAA,YACAC,qBACAC,WAAAA,UACAC,UAAAA,eACK;AAEP,SAASC,wBAAwB;AAEjC,SACEC,YACAC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;AACP,SAASC,sBAAsB;AAC/B,SAASC,MAAAA,WAAU;;;;ACtBnB,OAAOC,SAA2CC,WAAWC,SAASC,cAAc;AAEpF,SAASC,oBAAoB;AAC7B,SAA2BC,UAAUC,kBAAkB;AACvD,SAASC,MAAMC,YAAYC,QAA8BC,sBAAsB;AAC/E,SAAsBC,2BAA2B;AACjD,SAASC,UAAU;AAcZ,IAAMC,OAAO,CAAC,EAAEC,YAAYC,cAAc,SAASC,qBAAqBC,SAAS,GAAGC,MAAAA,MAAkB;;;AAC3G,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAM,EAAEC,MAAK,IAAKC,oBAAwCX,KAAKY,WAAW;AAC1E,UAAMC,UAAUC,WAAWC,SAASL,MAAMM,MAAM,GAAGC,GAAAA;AAEnD,WACE,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B,OAAA,cAACwB,mBAAAA;MAAkBX;MAAW,GAAGH;;;;;AAC1C;AAEAD,MAAMG,cAAc;AAMb,IAAMa,aAAa;EACxBhD;EACA0B;EACAM;EACAiB;AACF;",
|
|
6
6
|
"names": ["React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "ChessModel", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useSoundEffect", "mx", "React", "useEffect", "useMemo", "useRef", "generateName", "getSpace", "useMembers", "Icon", "IconButton", "Select", "useTranslation", "useGameboardContext", "mx", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "useTranslation", "meta", "id", "model", "useGameboardContext", "displayName", "members", "useMembers", "getSpace", "object", "key", "div", "className", "mx", "PlayerIndicator", "player", "icon", "IconButton", "iconOnly", "label", "size", "onClick", "PlayerSelector", "value", "players", "onValueChange", "History", "min", "max", "onSelect", "game", "isGameOver", "isCheckmate", "isStalemate", "isCheck", "undefined", "history", "moves", "useMemo", "reduce", "acc", "move", "index", "push", "length", "scrollerRef", "useRef", "useEffect", "current", "scrollTo", "top", "scrollHeight", "querySelector", "moveIndex", "classList", "add", "scrollIntoView", "behavior", "remove", "ref", "style", "minHeight", "maxHeight", "map", "a", "b", "data-index", "children", "turn", "Icon", "Select", "Root", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "member", "memberKey", "identity", "identityKey", "toHex", "profile", "generateName", "Option", "Arrow", "ExtendedChessModel", "ChessModel", "object", "Root", "forwardRef", "game", "children", "forwardedRef", "model", "useMemo", "click", "useSoundEffect", "useImperativeHandle", "setMoveNumber", "index", "setMoveIndex", "useEffect", "pgn", "getRawPgn", "silent", "update", "play", "handleDrop", "useCallback", "move", "makeMove", "React", "Gameboard", "onDrop", "Content", "classNames", "role", "mx", "grow", "contain", "Board", "props", "useGameboardContext", "displayName", "ref", "useRef", "current", "setAttribute", "addEventListener", "ev", "key", "history", "length", "moveIndex", "value", "NaturalChessboard", "Chessboard", "Info"]
|
|
7
7
|
}
|
|
@@ -6,14 +6,15 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/meta.ts
|
|
8
8
|
import { trim } from "@dxos/util";
|
|
9
|
-
var CHESS_PLUGIN = "dxos.org/plugin/chess";
|
|
10
9
|
var meta = {
|
|
11
|
-
id:
|
|
10
|
+
id: "dxos.org/plugin/chess",
|
|
12
11
|
name: "Chess",
|
|
13
12
|
description: trim`
|
|
14
|
-
|
|
13
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
14
|
+
Track game history and analyze moves in real-time.
|
|
15
15
|
`,
|
|
16
16
|
icon: "ph--shield-chevron--regular",
|
|
17
|
+
iconHue: "amber",
|
|
17
18
|
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
18
19
|
screenshots: [
|
|
19
20
|
"https://dxos.network/plugin-details-chess-dark.png"
|
|
@@ -22,7 +23,6 @@ var meta = {
|
|
|
22
23
|
|
|
23
24
|
export {
|
|
24
25
|
__export,
|
|
25
|
-
CHESS_PLUGIN,
|
|
26
26
|
meta
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-DUO4WTAM.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 PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/chess',\n name: 'Chess',\n description: trim`\n Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.\n Track game history and analyze moves in real-time.\n `,\n icon: 'ph--shield-chevron--regular',\n iconHue: 'amber',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',\n screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "screenshots"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export,
|
|
3
3
|
meta
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DUO4WTAM.mjs";
|
|
5
5
|
|
|
6
6
|
// src/types/Chess.ts
|
|
7
7
|
var Chess_exports = {};
|
|
@@ -10,28 +10,28 @@ __export(Chess_exports, {
|
|
|
10
10
|
makeGame: () => makeGame
|
|
11
11
|
});
|
|
12
12
|
import { Chess as ChessJS } from "chess.js";
|
|
13
|
-
import
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
14
|
import { Obj, Type } from "@dxos/echo";
|
|
15
|
-
import { LabelAnnotation } from "@dxos/echo
|
|
15
|
+
import { FormAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
16
16
|
import { log } from "@dxos/log";
|
|
17
17
|
import { ItemAnnotation } from "@dxos/schema";
|
|
18
18
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
|
|
19
19
|
var Game = Schema.Struct({
|
|
20
20
|
name: Schema.optional(Schema.String),
|
|
21
|
-
players: Schema.
|
|
21
|
+
players: Schema.Struct({
|
|
22
22
|
white: Schema.optional(Schema.String.annotations({
|
|
23
23
|
description: "DID of white player"
|
|
24
24
|
})),
|
|
25
25
|
black: Schema.optional(Schema.String.annotations({
|
|
26
26
|
description: "DID of black player"
|
|
27
27
|
}))
|
|
28
|
-
}).pipe(Schema.mutable)),
|
|
29
|
-
pgn: Schema.
|
|
28
|
+
}).pipe(Schema.mutable, FormAnnotation.set(false), Schema.optional),
|
|
29
|
+
pgn: Schema.String.annotations({
|
|
30
30
|
description: "Portable Game Notation."
|
|
31
|
-
})),
|
|
32
|
-
fen: Schema.
|
|
31
|
+
}).pipe(FormAnnotation.set(false), Schema.optional),
|
|
32
|
+
fen: Schema.String.annotations({
|
|
33
33
|
description: "Forsyth-Edwards Notation."
|
|
34
|
-
}))
|
|
34
|
+
}).pipe(FormAnnotation.set(false), Schema.optional)
|
|
35
35
|
}).pipe(Type.Obj({
|
|
36
36
|
typename: "dxos.org/type/Chess",
|
|
37
37
|
version: "0.2.0"
|
|
@@ -46,7 +46,7 @@ var makeGame = ({ name, pgn, fen } = {}) => {
|
|
|
46
46
|
} catch {
|
|
47
47
|
log.warn(pgn, void 0, {
|
|
48
48
|
F: __dxlog_file,
|
|
49
|
-
L:
|
|
49
|
+
L: 50,
|
|
50
50
|
S: void 0,
|
|
51
51
|
C: (f, a) => f(...a)
|
|
52
52
|
});
|
|
@@ -65,7 +65,7 @@ var ChessAction_exports = {};
|
|
|
65
65
|
__export(ChessAction_exports, {
|
|
66
66
|
Create: () => Create
|
|
67
67
|
});
|
|
68
|
-
import
|
|
68
|
+
import * as Schema2 from "effect/Schema";
|
|
69
69
|
var Create = class extends Schema2.TaggedClass()(`${meta.id}/action/create`, {
|
|
70
70
|
input: Schema2.Struct({
|
|
71
71
|
name: Schema2.optional(Schema2.String),
|
|
@@ -81,4 +81,4 @@ export {
|
|
|
81
81
|
Chess_exports,
|
|
82
82
|
ChessAction_exports
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-FBLAVAMY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/Chess.ts", "../../../src/types/ChessAction.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { FormAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { log } from '@dxos/log';\nimport { ItemAnnotation } from '@dxos/schema';\n\nexport const Game = Schema.Struct({\n name: Schema.optional(Schema.String),\n players: Schema.Struct({\n white: Schema.optional(\n Schema.String.annotations({\n description: 'DID of white player',\n }),\n ),\n black: Schema.optional(\n Schema.String.annotations({\n description: 'DID of black player',\n }),\n ),\n }).pipe(Schema.mutable, FormAnnotation.set(false), Schema.optional),\n pgn: Schema.String.annotations({\n description: 'Portable Game Notation.',\n }).pipe(FormAnnotation.set(false), Schema.optional),\n fen: Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }).pipe(FormAnnotation.set(false), Schema.optional),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Chess',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ItemAnnotation.set(true),\n);\n\nexport interface Game extends Schema.Schema.Type<typeof Game> {}\n\nexport const makeGame = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: string } = {}) => {\n const chess = new ChessJS();\n if (pgn) {\n try {\n chess.loadPgn(pgn);\n } catch {\n log.warn(pgn);\n }\n }\n\n return Obj.make(Game, {\n name,\n players: {},\n pgn,\n fen,\n });\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { meta } from '../meta';\n\nimport { Game } from './Chess';\n\nexport class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n pgn: Schema.optional(Schema.String),\n }),\n output: Schema.Struct({\n object: Game,\n }),\n}) {}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,KAAKC,YAAY;AAC1B,SAASC,gBAAgBC,uBAAuB;AAChD,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A,EAAA;AAAI;",
|
|
6
|
+
"names": ["Chess", "ChessJS", "Schema", "Obj", "Type", "FormAnnotation", "LabelAnnotation", "log", "ItemAnnotation", "Game", "Struct", "name", "optional", "String", "players", "white", "annotations", "description", "black", "pipe", "mutable", "set", "pgn", "fen", "typename", "version", "makeGame", "chess", "loadPgn", "warn", "make", "Schema", "Create", "TaggedClass", "meta", "id", "input", "Struct", "name", "optional", "String", "pgn", "output", "object", "Game"]
|
|
7
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/components/index.ts
|
|
2
2
|
import { lazy } from "react";
|
|
3
|
-
var ChessboardContainer = lazy(() => import("./ChessboardContainer-
|
|
3
|
+
var ChessboardContainer = lazy(() => import("./ChessboardContainer-5YXEM4VR.mjs"));
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
ChessboardContainer
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-Q5TZCIH7.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Chess_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FBLAVAMY.mjs";
|
|
4
4
|
|
|
5
5
|
// src/capabilities/blueprint-definition.ts
|
|
6
6
|
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
@@ -8,10 +8,12 @@ import { Blueprint, Template } from "@dxos/blueprints";
|
|
|
8
8
|
import { trim } from "@dxos/util";
|
|
9
9
|
|
|
10
10
|
// src/functions/create.ts
|
|
11
|
-
import
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
12
13
|
import { DatabaseService, defineFunction } from "@dxos/functions";
|
|
13
14
|
var create_default = defineFunction({
|
|
14
|
-
|
|
15
|
+
key: "dxos.org/function/chess/create",
|
|
16
|
+
name: "Create Chess",
|
|
15
17
|
description: "Creates a new chess game.",
|
|
16
18
|
inputSchema: Schema.Struct({
|
|
17
19
|
pgn: Schema.optional(Schema.String.annotations({
|
|
@@ -32,11 +34,13 @@ var create_default = defineFunction({
|
|
|
32
34
|
|
|
33
35
|
// src/functions/move.ts
|
|
34
36
|
import { Chess as ChessJS } from "chess.js";
|
|
35
|
-
import
|
|
37
|
+
import * as Effect2 from "effect/Effect";
|
|
38
|
+
import * as Schema2 from "effect/Schema";
|
|
36
39
|
import { ArtifactId } from "@dxos/assistant";
|
|
37
40
|
import { DatabaseService as DatabaseService2, defineFunction as defineFunction2 } from "@dxos/functions";
|
|
38
41
|
var move_default = defineFunction2({
|
|
39
|
-
|
|
42
|
+
key: "dxos.org/function/chess/move",
|
|
43
|
+
name: "Move",
|
|
40
44
|
description: "Makes a move in the given chess game.",
|
|
41
45
|
inputSchema: Schema2.Struct({
|
|
42
46
|
id: ArtifactId.annotations({
|
|
@@ -75,11 +79,13 @@ var move_default = defineFunction2({
|
|
|
75
79
|
|
|
76
80
|
// src/functions/play.ts
|
|
77
81
|
import { Chess as ChessJS2 } from "chess.js";
|
|
78
|
-
import
|
|
82
|
+
import * as Effect3 from "effect/Effect";
|
|
83
|
+
import * as Schema3 from "effect/Schema";
|
|
79
84
|
import { ArtifactId as ArtifactId2 } from "@dxos/assistant";
|
|
80
85
|
import { DatabaseService as DatabaseService3, defineFunction as defineFunction3 } from "@dxos/functions";
|
|
81
86
|
var play_default = defineFunction3({
|
|
82
|
-
|
|
87
|
+
key: "dxos.org/function/chess/play",
|
|
88
|
+
name: "Play",
|
|
83
89
|
description: "Uses the chess engine to play the next move.",
|
|
84
90
|
inputSchema: Schema3.Struct({
|
|
85
91
|
id: ArtifactId2.annotations({
|
|
@@ -126,17 +132,17 @@ var play_default = defineFunction3({
|
|
|
126
132
|
});
|
|
127
133
|
|
|
128
134
|
// src/capabilities/blueprint-definition.ts
|
|
129
|
-
var BLUEPRINT_KEY = "dxos.org/blueprint/chess";
|
|
130
135
|
var functions = [
|
|
131
136
|
create_default,
|
|
132
137
|
move_default,
|
|
133
138
|
play_default
|
|
134
139
|
];
|
|
135
|
-
var
|
|
140
|
+
var CHESS_BLUEPRINT_KEY = "dxos.org/blueprint/chess";
|
|
141
|
+
var blueprint_definition_default = (() => {
|
|
136
142
|
return [
|
|
137
143
|
contributes(Capabilities.Functions, functions),
|
|
138
144
|
contributes(Capabilities.BlueprintDefinition, Blueprint.make({
|
|
139
|
-
key:
|
|
145
|
+
key: CHESS_BLUEPRINT_KEY,
|
|
140
146
|
name: "Chess",
|
|
141
147
|
tools: Blueprint.toolDefinitions({
|
|
142
148
|
functions
|
|
@@ -151,13 +157,13 @@ var blueprint_definition_default = () => {
|
|
|
151
157
|
})
|
|
152
158
|
}))
|
|
153
159
|
];
|
|
154
|
-
};
|
|
160
|
+
});
|
|
155
161
|
|
|
156
162
|
export {
|
|
157
163
|
create_default,
|
|
158
164
|
move_default,
|
|
159
165
|
play_default,
|
|
160
|
-
|
|
166
|
+
CHESS_BLUEPRINT_KEY,
|
|
161
167
|
blueprint_definition_default
|
|
162
168
|
};
|
|
163
|
-
//# sourceMappingURL=chunk-
|
|
169
|
+
//# sourceMappingURL=chunk-TIIGNOGK.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/blueprint-definition.ts", "../../../src/functions/create.ts", "../../../src/functions/move.ts", "../../../src/functions/play.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes } from '@dxos/app-framework';\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { type FunctionDefinition } from '@dxos/functions';\nimport { trim } from '@dxos/util';\n\nimport { create, move, play } from '../functions';\n\nconst functions: FunctionDefinition[] = [create, move, play];\n\nexport const CHESS_BLUEPRINT_KEY = 'dxos.org/blueprint/chess';\n\nexport default () => {\n return [\n contributes(Capabilities.Functions, functions),\n contributes(\n Capabilities.BlueprintDefinition,\n Blueprint.make({\n key: CHESS_BLUEPRINT_KEY,\n name: 'Chess',\n tools: Blueprint.toolDefinitions({ functions }),\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 ),\n ];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { DatabaseService, defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/create',\n name: 'Create Chess',\n description: 'Creates a new chess game.',\n inputSchema: 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 outputSchema: Chess.Game,\n handler: Effect.fn(function* ({ data: { pgn, fen } }) {\n return yield* DatabaseService.add(Chess.makeGame({ pgn, fen }));\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ArtifactId } from '@dxos/assistant';\nimport { DatabaseService, defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/move',\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n inputSchema: Schema.Struct({\n id: ArtifactId.annotations({\n description: 'The ID of the chess object.',\n }),\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n outputSchema: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n }),\n handler: Effect.fn(function* ({ data: { id, move } }) {\n const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Chess.Game);\n const chess = new ChessJS();\n if (object.pgn) {\n chess.loadPgn(object.pgn);\n } else if (object.fen) {\n chess.load(object.fen);\n }\n\n chess.move(move, { strict: false });\n object.pgn = chess.pgn();\n return { pgn: object.pgn };\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { ArtifactId } from '@dxos/assistant';\nimport { DatabaseService, defineFunction } from '@dxos/functions';\n\nimport { Chess } from '../types';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/play',\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n inputSchema: Schema.Struct({\n id: ArtifactId.annotations({\n description: 'The ID of the chess object.',\n }),\n side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({\n description: 'The side to play.',\n defaultValue: 'any',\n }),\n }),\n outputSchema: 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 handler: Effect.fn(function* ({ data: { id, side = 'any' } }) {\n const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Chess.Game);\n const chess = new ChessJS();\n if (object.pgn) {\n chess.loadPgn(object.pgn);\n } else if (object.fen) {\n chess.load(object.fen);\n }\n\n if (!(side === 'any' || (chess.turn() === 'w' && side === 'white') || (chess.turn() === 'b' && side === 'black'))) {\n return { move: undefined, pgn: object.pgn! };\n }\n\n const moves = chess.moves();\n const move = moves[Math.floor(Math.random() * moves.length)];\n\n chess.move(move, { strict: false });\n object.pgn = chess.pgn();\n return { move, pgn: object.pgn };\n }),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,cAAcC,mBAAmB;AAC1C,SAASC,WAAWC,gBAAgB;AAEpC,SAASC,YAAY;;;ACHrB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,iBAAiBC,sBAAsB;AAIhD,IAAA,iBAAeC,eAAe;EA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C,MAAMD,KAAKE,OAAM,IAAKH,MAAMI,MAAM,CAAA;AAE1DX,UAAMV,KAAKA,MAAM;MAAEsB,QAAQ;IAAM,CAAA;AACjClB,WAAON,MAAMY,MAAMZ,IAAG;AACtB,WAAO;MAAEE;MAAMF,KAAKM,OAAON;IAAI;EACjC,CAAA;AACF,CAAA;;;AH3CA,IAAMyB,YAAkC;EAACC;EAAQC;EAAMC;;AAEhD,IAAMC,sBAAsB;AAEnC,IAAA,gCAAe,MAAA;AACb,SAAO;IACLC,YAAYC,aAAaC,WAAWP,SAAAA;IACpCK,YACEC,aAAaE,qBACbC,UAAUC,KAAK;MACbC,KAAKP;MACLQ,MAAM;MACNC,OAAOJ,UAAUK,gBAAgB;QAAEd;MAAU,CAAA;MAC7Ce,cAAcC,SAASN,KAAK;QAC1BO,QAAQC;;;;;;MAMV,CAAA;IACF,CAAA,CAAA;;AAGN;",
|
|
6
|
+
"names": ["Capabilities", "contributes", "Blueprint", "Template", "trim", "Effect", "Schema", "DatabaseService", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "pgn", "optional", "String", "annotations", "fen", "outputSchema", "Chess", "Game", "handler", "fn", "data", "DatabaseService", "add", "makeGame", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "DatabaseService", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "move", "String", "examples", "outputSchema", "pgn", "handler", "fn", "data", "object", "DatabaseService", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "strict", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "DatabaseService", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "side", "optional", "Literal", "defaultValue", "outputSchema", "pgn", "String", "move", "handler", "fn", "data", "object", "DatabaseService", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "turn", "undefined", "moves", "Math", "floor", "random", "length", "strict", "functions", "create", "move", "play", "CHESS_BLUEPRINT_KEY", "contributes", "Capabilities", "Functions", "BlueprintDefinition", "Blueprint", "make", "key", "name", "tools", "toolDefinitions", "instructions", "Template", "source", "trim"]
|
|
7
|
+
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CHESS_BLUEPRINT_KEY,
|
|
3
3
|
create_default,
|
|
4
4
|
move_default,
|
|
5
5
|
play_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TIIGNOGK.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ChessboardContainer
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q5TZCIH7.mjs";
|
|
10
10
|
import {
|
|
11
11
|
ChessAction_exports,
|
|
12
12
|
Chess_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FBLAVAMY.mjs";
|
|
14
14
|
import {
|
|
15
15
|
Chessboard,
|
|
16
16
|
ExtendedChessModel
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5DOZV3PW.mjs";
|
|
18
18
|
import {
|
|
19
|
-
CHESS_PLUGIN,
|
|
20
19
|
meta
|
|
21
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DUO4WTAM.mjs";
|
|
22
21
|
|
|
23
22
|
// src/capabilities/index.ts
|
|
24
23
|
import { lazy } from "@dxos/app-framework";
|
|
25
|
-
var BlueprintDefinition = lazy(() => import("./blueprint-definition-
|
|
26
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
27
|
-
var ReactSurface = lazy(() => import("./react-surface-
|
|
24
|
+
var BlueprintDefinition = lazy(() => import("./blueprint-definition-FD4TL5EE.mjs"));
|
|
25
|
+
var IntentResolver = lazy(() => import("./intent-resolver-GXZN2EBT.mjs"));
|
|
26
|
+
var ReactSurface = lazy(() => import("./react-surface-KTTAUHAA.mjs"));
|
|
28
27
|
|
|
29
28
|
// src/ChessPlugin.tsx
|
|
30
29
|
import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from "@dxos/app-framework";
|
|
@@ -43,26 +42,26 @@ var translations = [
|
|
|
43
42
|
"typename label_other": "Games",
|
|
44
43
|
"object name placeholder": "New game",
|
|
45
44
|
"rename object label": "Rename game",
|
|
46
|
-
"delete object label": "Delete game"
|
|
47
|
-
"toggle info button": "Toggle info",
|
|
48
|
-
"close info button": "Close info",
|
|
49
|
-
"flip board button": "Flip board",
|
|
50
|
-
"select player button": "Select player"
|
|
45
|
+
"delete object label": "Delete game"
|
|
51
46
|
},
|
|
52
47
|
[meta.id]: {
|
|
53
48
|
"plugin name": "Chess",
|
|
54
49
|
"delete game label": "Delete",
|
|
55
|
-
"game.checkmate": "Checkmate",
|
|
56
|
-
"game.stalemate": "Stalemate",
|
|
57
|
-
"game.draw": "Draw",
|
|
58
|
-
"game.check": "Check"
|
|
50
|
+
"game.checkmate label": "Checkmate",
|
|
51
|
+
"game.stalemate label": "Stalemate",
|
|
52
|
+
"game.draw label": "Draw",
|
|
53
|
+
"game.check label": "Check",
|
|
54
|
+
"select player button": "Select player",
|
|
55
|
+
"toggle info button": "Toggle info",
|
|
56
|
+
"close info button": "Close info",
|
|
57
|
+
"flip board button": "Flip board"
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
];
|
|
63
62
|
|
|
64
63
|
// src/ChessPlugin.tsx
|
|
65
|
-
var ChessPlugin = () =>
|
|
64
|
+
var ChessPlugin = definePlugin(meta, () => [
|
|
66
65
|
defineModule({
|
|
67
66
|
id: `${meta.id}/module/translations`,
|
|
68
67
|
activatesOn: Events.SetupTranslations,
|
|
@@ -75,8 +74,9 @@ var ChessPlugin = () => definePlugin(meta, [
|
|
|
75
74
|
id: Chess_exports.Game.typename,
|
|
76
75
|
metadata: {
|
|
77
76
|
icon: "ph--shield-chevron--regular",
|
|
77
|
+
iconHue: "amber",
|
|
78
78
|
blueprints: [
|
|
79
|
-
|
|
79
|
+
CHESS_BLUEPRINT_KEY
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
})
|
|
@@ -106,9 +106,8 @@ var ChessPlugin = () => definePlugin(meta, [
|
|
|
106
106
|
})
|
|
107
107
|
]);
|
|
108
108
|
export {
|
|
109
|
-
BLUEPRINT_KEY,
|
|
110
109
|
BlueprintDefinition,
|
|
111
|
-
|
|
110
|
+
CHESS_BLUEPRINT_KEY,
|
|
112
111
|
Chess_exports as Chess,
|
|
113
112
|
ChessAction_exports as ChessAction,
|
|
114
113
|
ChessPlugin,
|