@dxos/plugin-chess 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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/ChessArticle-UDSL3OJ4.mjs +59 -0
- package/dist/lib/browser/ChessArticle-UDSL3OJ4.mjs.map +7 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs +21 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +4 -4
- package/dist/lib/browser/{chunk-66H3V2YV.mjs → chunk-2TJN26DN.mjs} +9 -6
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO4ZNFN6.mjs → chunk-6JG4KLVU.mjs} +44 -42
- package/dist/lib/browser/chunk-6JG4KLVU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-73BDP7UV.mjs → chunk-JP6G6VR6.mjs} +30 -29
- package/dist/lib/browser/chunk-JP6G6VR6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-H3NUMCQ6.mjs → chunk-RGHZ5CDO.mjs} +2 -2
- package/dist/lib/browser/{chunk-H3NUMCQ6.mjs.map → chunk-RGHZ5CDO.mjs.map} +1 -1
- package/dist/lib/browser/chunk-WYUTI2K4.mjs +1 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +10 -10
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +25 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs +50 -0
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs +60 -0
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs.map +7 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs +22 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-SL4LBVV5.mjs → blueprint-definition-PFZMTCXY.mjs} +7 -7
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +4 -4
- package/dist/lib/node-esm/{chunk-C7IWIXCJ.mjs → chunk-46DC6W7W.mjs} +44 -42
- package/dist/lib/node-esm/chunk-46DC6W7W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs +2 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WXEPWOHT.mjs → chunk-FK7NVSOG.mjs} +30 -29
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F5OMIM4F.mjs → chunk-FYPVCMP4.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-F5OMIM4F.mjs.map → chunk-FYPVCMP4.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-OUNGNJFP.mjs → chunk-OIRJVY2R.mjs} +9 -6
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +10 -10
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +25 -28
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs +51 -0
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/chess-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/create.d.ts +1 -1
- package/dist/types/src/blueprints/functions/index.d.ts +55 -4
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/move.d.ts +9 -1
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -1
- package/dist/types/src/blueprints/functions/play.d.ts +9 -1
- package/dist/types/src/blueprints/functions/play.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +3 -6
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/components/{Chessboard.d.ts → Chessboard/Chessboard.d.ts} +3 -8
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/{Info.d.ts → Chessboard/Info.d.ts} +1 -1
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +6 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/{components/Chessboard.stories.d.ts → containers/ChessArticle/ChessArticle.stories.d.ts} +3 -2
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +3 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +6 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/{components/Card.stories.d.ts → containers/ChessCard/ChessCard.stories.d.ts} +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +3 -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 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +1 -1
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -35
- package/src/ChessPlugin.tsx +13 -10
- package/src/blueprints/chess-blueprint.ts +14 -6
- package/src/blueprints/functions/create.ts +2 -2
- package/src/blueprints/functions/index.ts +13 -4
- package/src/blueprints/functions/move.ts +11 -12
- package/src/blueprints/functions/play.ts +5 -6
- package/src/blueprints/functions/print.ts +1 -1
- package/src/blueprints/index.ts +1 -1
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +6 -12
- package/src/capabilities/react-surface/react-surface.tsx +13 -7
- package/src/cli/plugin.ts +4 -4
- package/src/components/{Chessboard.tsx → Chessboard/Chessboard.tsx} +24 -26
- package/src/components/{Info.tsx → Chessboard/Info.tsx} +12 -10
- 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/{components/Chessboard.stories.tsx → containers/ChessArticle/ChessArticle.stories.tsx} +7 -7
- package/src/containers/ChessArticle/ChessArticle.tsx +72 -0
- package/src/containers/ChessArticle/index.ts +7 -0
- package/src/{components/Card.stories.tsx → containers/ChessCard/ChessCard.stories.tsx} +9 -14
- package/src/containers/ChessCard/ChessCard.tsx +22 -0
- package/src/containers/ChessCard/index.ts +7 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +1 -1
- package/src/meta.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/Chess.ts +7 -3
- package/dist/lib/browser/ChessboardContainer-JZ4ANG4O.mjs +0 -81
- package/dist/lib/browser/ChessboardContainer-JZ4ANG4O.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-P7TYXWMF.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-P7TYXWMF.mjs.map +0 -7
- package/dist/lib/browser/chunk-66H3V2YV.mjs.map +0 -7
- package/dist/lib/browser/chunk-73BDP7UV.mjs.map +0 -7
- package/dist/lib/browser/chunk-FO4ZNFN6.mjs.map +0 -7
- package/dist/lib/browser/chunk-OW6S2SRG.mjs +0 -8
- package/dist/lib/browser/chunk-OW6S2SRG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VNOWFKC6.mjs +0 -37
- package/dist/lib/browser/react-surface-VNOWFKC6.mjs.map +0 -7
- package/dist/lib/node-esm/ChessboardContainer-7ONFYN7L.mjs +0 -82
- package/dist/lib/node-esm/ChessboardContainer-7ONFYN7L.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-SL4LBVV5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-24GJHLHM.mjs +0 -10
- package/dist/lib/node-esm/chunk-24GJHLHM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C7IWIXCJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OUNGNJFP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WXEPWOHT.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-HSHCIOAS.mjs +0 -38
- package/dist/lib/node-esm/react-surface-HSHCIOAS.mjs.map +0 -7
- 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.map +0 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +0 -6
- package/dist/types/src/components/ChessboardArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChessboardContainer.d.ts +0 -7
- package/dist/types/src/components/ChessboardContainer.d.ts.map +0 -1
- package/dist/types/src/components/Info.d.ts.map +0 -1
- package/src/components/ChessboardArticle.tsx +0 -71
- package/src/components/ChessboardContainer.tsx +0 -40
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
Chessboard
|
|
4
|
-
} from "./chunk-WXEPWOHT.mjs";
|
|
5
|
-
import {
|
|
6
|
-
meta
|
|
7
|
-
} from "./chunk-F5OMIM4F.mjs";
|
|
8
|
-
import "./chunk-HSLMI22Q.mjs";
|
|
9
|
-
|
|
10
|
-
// src/components/ChessboardContainer.tsx
|
|
11
|
-
import React2 from "react";
|
|
12
|
-
import { Obj } from "@dxos/echo";
|
|
13
|
-
|
|
14
|
-
// src/components/ChessboardArticle.tsx
|
|
15
|
-
import React, { useCallback, useRef, useState } from "react";
|
|
16
|
-
import { Toolbar, useTranslation } from "@dxos/react-ui";
|
|
17
|
-
import { Layout } from "@dxos/react-ui-mosaic";
|
|
18
|
-
import { mx } from "@dxos/ui-theme";
|
|
19
|
-
var ChessboardArticle = ({ role, subject: game }) => {
|
|
20
|
-
const { t } = useTranslation(meta.id);
|
|
21
|
-
const [orientation, setOrientation] = useState("white");
|
|
22
|
-
const [open, setOpen] = useState(true);
|
|
23
|
-
const controller = useRef(null);
|
|
24
|
-
const handleSelect = useCallback((index) => {
|
|
25
|
-
controller.current?.setMoveNumber(index);
|
|
26
|
-
}, []);
|
|
27
|
-
return /* @__PURE__ */ React.createElement(Layout.Main, {
|
|
28
|
-
toolbar: true,
|
|
29
|
-
classNames: "@container"
|
|
30
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
31
|
-
game,
|
|
32
|
-
ref: controller
|
|
33
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
34
|
-
icon: "ph--info--regular",
|
|
35
|
-
iconOnly: true,
|
|
36
|
-
label: t("toggle info button"),
|
|
37
|
-
disabled: open,
|
|
38
|
-
classNames: mx("invisible @3xl:visible"),
|
|
39
|
-
onClick: () => setOpen((open2) => !open2)
|
|
40
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
41
|
-
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")
|
|
42
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
43
|
-
classNames: "m-4 rounded-sm overflow-hidden",
|
|
44
|
-
orientation
|
|
45
|
-
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
46
|
-
className: "hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden"
|
|
47
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
48
|
-
orientation,
|
|
49
|
-
min: 8,
|
|
50
|
-
max: 8,
|
|
51
|
-
onOrientationChange: setOrientation,
|
|
52
|
-
onClose: () => setOpen(false),
|
|
53
|
-
onSelect: handleSelect
|
|
54
|
-
})))));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/components/ChessboardContainer.tsx
|
|
58
|
-
var ChessboardContainer = ({ role, subject: game }) => {
|
|
59
|
-
const db = Obj.getDatabase(game);
|
|
60
|
-
if (!db) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
switch (role) {
|
|
64
|
-
case "card--content": {
|
|
65
|
-
return /* @__PURE__ */ React2.createElement(Chessboard.Root, {
|
|
66
|
-
game
|
|
67
|
-
}, /* @__PURE__ */ React2.createElement(Chessboard.Content, null, /* @__PURE__ */ React2.createElement(Chessboard.Board, null)));
|
|
68
|
-
}
|
|
69
|
-
default: {
|
|
70
|
-
return /* @__PURE__ */ React2.createElement(ChessboardArticle, {
|
|
71
|
-
role,
|
|
72
|
-
subject: game
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var ChessboardContainer_default = ChessboardContainer;
|
|
78
|
-
export {
|
|
79
|
-
ChessboardContainer,
|
|
80
|
-
ChessboardContainer_default as default
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=ChessboardContainer-7ONFYN7L.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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 { type SurfaceComponentProps } from '@dxos/app-framework/react';\nimport { Obj } from '@dxos/echo';\n\nimport { type Chess } from '../types';\n\nimport { Chessboard } from './Chessboard';\nimport { ChessboardArticle } from './ChessboardArticle';\n\nexport type ChessboardContainerProps = SurfaceComponentProps<Chess.Game>;\n\nexport const ChessboardContainer = ({ role, subject: game }: ChessboardContainerProps) => {\n const db = Obj.getDatabase(game);\n if (!db) {\n return null;\n }\n\n switch (role) {\n case 'card--content': {\n return (\n <Chessboard.Root game={game}>\n <Chessboard.Content>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n );\n }\n\n default: {\n return <ChessboardArticle role={role} subject={game} />;\n }\n }\n};\n\nexport default ChessboardContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { type SurfaceComponentProps } from '@dxos/app-framework/react';\nimport { Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { Layout } from '@dxos/react-ui-mosaic';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '../meta';\nimport { type Chess } from '../types';\n\nimport { Chessboard, type ChessboardController, type ChessboardInfoProps } from './Chessboard';\n\nexport type ChessboardArticleProps = SurfaceComponentProps<Chess.Game>;\n\nexport const ChessboardArticle = ({ role, subject: game }: ChessboardArticleProps) => {\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 <Layout.Main 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 </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LC,KAAK;IACLC,qBAAqBjC;IACrBkC,SAAS,MAAM/B,QAAQ,KAAA;IACvBgC,UAAU7B;;AAQ1B;;;ADtDO,IAAM8B,sBAAsB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA4B;AACnF,QAAMC,KAAKC,IAAIC,YAAYH,IAAAA;AAC3B,MAAI,CAACC,IAAI;AACP,WAAO;EACT;AAEA,UAAQH,MAAAA;IACN,KAAK,iBAAiB;AACpB,aACE,gBAAAM,OAAA,cAACC,WAAWC,MAAI;QAACN;SACf,gBAAAI,OAAA,cAACC,WAAWE,SAAO,MACjB,gBAAAH,OAAA,cAACC,WAAWG,OAAK,IAAA,CAAA,CAAA;IAIzB;IAEA,SAAS;AACP,aAAO,gBAAAJ,OAAA,cAACK,mBAAAA;QAAkBX;QAAYC,SAASC;;IACjD;EACF;AACF;AAEA,IAAA,8BAAeH;",
|
|
6
|
-
"names": ["React", "Obj", "React", "useCallback", "useRef", "useState", "Toolbar", "useTranslation", "Layout", "mx", "ChessboardArticle", "role", "subject", "game", "t", "useTranslation", "meta", "id", "orientation", "setOrientation", "useState", "open", "setOpen", "controller", "useRef", "handleSelect", "useCallback", "index", "current", "setMoveNumber", "Layout", "Main", "toolbar", "classNames", "Chessboard", "Root", "ref", "Toolbar", "IconButton", "icon", "iconOnly", "label", "disabled", "mx", "onClick", "div", "className", "Content", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect", "ChessboardContainer", "role", "subject", "game", "db", "Obj", "getDatabase", "React", "Chessboard", "Root", "Content", "Board", "ChessboardArticle"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/blueprint-definition/blueprint-definition.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability, Common } from '@dxos/app-framework';\n\nimport { ChessBlueprint } from '../../blueprints';\n\nexport type BlueprintCapabilities = [\n Capability.Capability<typeof Common.Capability.Functions>,\n Capability.Capability<typeof Common.Capability.BlueprintDefinition>,\n];\n\nconst blueprintDefinition = Capability.makeModule<[], BlueprintCapabilities>(() =>\n Effect.succeed([\n Capability.contributes(Common.Capability.Functions, ChessBlueprint.functions),\n Capability.contributes(Common.Capability.BlueprintDefinition, ChessBlueprint.make()),\n ]),\n);\n\nexport default blueprintDefinition;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,YAAYC,cAAc;AASnC,IAAMC,sBAAsBC,WAAWC,WAAsC,MACpEC,eAAQ;EACbF,WAAWG,YAAYC,OAAOJ,WAAWK,WAAWC,wBAAeC,SAAS;EAC5EP,WAAWG,YAAYC,OAAOJ,WAAWQ,qBAAqBF,wBAAeG,KAAI,CAAA;CAClF,CAAA;AAGH,IAAA,+BAAeV;",
|
|
6
|
-
"names": ["Effect", "Capability", "Common", "blueprintDefinition", "Capability", "makeModule", "succeed", "contributes", "Common", "Functions", "ChessBlueprint", "functions", "BlueprintDefinition", "make"]
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/components/index.ts
|
|
4
|
-
import { lazy } from "react";
|
|
5
|
-
var ChessboardContainer = lazy(() => import("./ChessboardContainer-7ONFYN7L.mjs"));
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
ChessboardContainer
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=chunk-24GJHLHM.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './Chessboard';\n\nexport const ChessboardContainer = lazy(() => import('./ChessboardContainer'));\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,YAAY;AAId,IAAMC,sBAAsBC,KAAK,MAAM,OAAO,oCAAA,CAAA;",
|
|
6
|
-
"names": ["lazy", "ChessboardContainer", "lazy"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/blueprints/chess-blueprint.ts", "../../../src/blueprints/functions/index.ts", "../../../src/blueprints/functions/create.ts", "../../../src/blueprints/functions/move.ts", "../../../src/blueprints/functions/play.ts", "../../../src/blueprints/functions/print.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/blueprints';\nimport { type FunctionDefinition } from '@dxos/functions';\nimport { trim } from '@dxos/util';\n\nimport { create, move, play, print } from './functions';\n\nexport const Key = 'dxos.org/blueprint/chess';\n\nexport const functions: FunctionDefinition[] = [create, move, play, print];\n\nexport const make = () =>\n Blueprint.make({\n key: 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// Copyright 2024 DXOS.org\n//\n\nexport { default as create } from './create';\nexport { default as move } from './move';\nexport { default as play } from './play';\nexport { default as print } from './print';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Database } from '@dxos/echo';\nimport { 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 name: Schema.optional(\n Schema.String.annotations({\n description: 'Name of the game.',\n }),\n ),\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: { name, pgn, fen } }) {\n return yield* Database.Service.add(Chess.make({ name, 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 { Database, Obj } from '@dxos/echo';\nimport { 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* Database.Service.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 const pgn = chess.pgn();\n Obj.change(object, (o) => {\n o.pgn = pgn;\n });\n return { 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 { Database, Obj } from '@dxos/echo';\nimport { 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* Database.Service.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 const pgn = chess.pgn();\n Obj.change(object, (o) => {\n o.pgn = pgn;\n });\n return { move, 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 { defineFunction } from '@dxos/functions';\n\nexport default defineFunction({\n key: 'dxos.org/function/chess/print',\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\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: Schema.Struct({\n ascii: Schema.String,\n }),\n handler: Effect.fn(function* ({ data: { pgn, fen } }) {\n try {\n const chess = new ChessJS(fen);\n if (pgn) {\n chess.loadPgn(pgn);\n }\n return { ascii: chess.ascii() };\n } catch {\n // TODO(burdon): Error handling?\n return { ascii: '' };\n }\n }),\n});\n"],
|
|
5
|
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;AACA,aAAO;QAAEM,OAAOI,MAAMJ,MAAK;MAAG;IAChC,QAAQ;AAEN,aAAO;QAAEA,OAAO;MAAG;IACrB;EACF,CAAA;AACF,CAAA;;;AL/BO,IAAMO,MAAM;AAEZ,IAAMC,YAAkC;EAACC;EAAQC;EAAMC;EAAMC;;AAE7D,IAAMC,OAAO,MAClBC,UAAUD,KAAK;EACbE,KAAKR;EACLS,MAAM;EACNC,OAAOH,UAAUI,gBAAgB;IAAEV;EAAU,CAAA;EAC7CW,cAAcC,SAASP,KAAK;IAC1BQ,QAAQC;;;;;;EAMV,CAAA;AACF,CAAA;",
|
|
6
|
-
"names": ["Blueprint", "Template", "trim", "Effect", "Schema", "Database", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "optional", "String", "annotations", "pgn", "fen", "outputSchema", "Chess", "Game", "handler", "fn", "data", "Database", "Service", "add", "make", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "Database", "Obj", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "move", "String", "examples", "outputSchema", "pgn", "handler", "fn", "data", "object", "Database", "Service", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "strict", "Obj", "change", "o", "Chess", "ChessJS", "Effect", "Schema", "ArtifactId", "Database", "Obj", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "id", "ArtifactId", "annotations", "side", "optional", "Literal", "defaultValue", "outputSchema", "pgn", "String", "move", "handler", "fn", "data", "object", "Database", "Service", "resolve", "toDXN", "Chess", "Game", "chess", "ChessJS", "loadPgn", "fen", "load", "turn", "undefined", "moves", "Math", "floor", "random", "length", "strict", "Obj", "change", "o", "Chess", "ChessJS", "Effect", "Schema", "defineFunction", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "pgn", "optional", "String", "annotations", "fen", "outputSchema", "ascii", "handler", "fn", "data", "chess", "ChessJS", "loadPgn", "Key", "functions", "create", "move", "play", "print", "make", "Blueprint", "key", "name", "tools", "toolDefinitions", "instructions", "Template", "source", "trim"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Chess.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { log } from '@dxos/log';\n\nexport const Game = Schema.Struct({\n name: Schema.optional(Schema.String),\n players: Schema.Struct({\n white: Schema.optional(\n Schema.String.annotations({\n description: 'DID of white player',\n }),\n ),\n black: Schema.optional(\n Schema.String.annotations({\n description: 'DID of black player',\n }),\n ),\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n pgn: Schema.String.annotations({\n description: 'Portable Game Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n fen: Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Chess',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport interface Game extends Schema.Schema.Type<typeof Game> {}\n\nexport const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: string } = {}) => {\n const chess = new ChessJS();\n if (pgn) {\n try {\n chess.loadPgn(pgn);\n } catch {\n log.warn(pgn);\n }\n }\n\n return Obj.make(Game, {\n name,\n pgn,\n fen,\n players: {},\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAAA;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,KAAKC,YAAY;AAC1B,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,WAAW;;AAEb,IAAMC,OAAcC,cAAO;EAChCC,MAAaC,gBAAgBC,aAAM;EACnCC,SAAgBJ,cAAO;IACrBK,OAAcH,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;IAEFC,OAAcN,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDS,KAAYR,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDU,KAAYT,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;AACzD,CAAA,EAAGO,KACDd,KAAKkB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAlB,gBAAgBa,IAAI;EAAC;CAAO,CAAA;AAKvB,IAAMM,OAAO,CAAC,EAAEf,MAAMU,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMK,QAAQ,IAAIzB,QAAAA;AAClB,MAAImB,KAAK;AACP,QAAI;AACFM,YAAMC,QAAQP,GAAAA;IAChB,QAAQ;AACNb,UAAIqB,KAAKR,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOjB,IAAIsB,KAAKjB,MAAM;IACpBE;IACAU;IACAC;IACAR,SAAS,CAAC;EACZ,CAAA;AACF;",
|
|
6
|
-
"names": ["Chess", "ChessJS", "Schema", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "Struct", "name", "optional", "String", "players", "white", "annotations", "description", "black", "pipe", "set", "pgn", "fen", "object", "typename", "version", "make", "chess", "loadPgn", "warn"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/Chessboard.tsx", "../../../src/components/Info.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Registry, RegistryContext } from '@effect-atom/atom-react';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { Obj } from '@dxos/echo';\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/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(\n registry: Registry.Registry,\n readonly object: Chess.Game,\n ) {\n super(registry);\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 registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);\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 Obj.change(game, (g) => {\n g.pgn = model.pgn;\n });\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 registry = useContext(RegistryContext);\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 const moveIndex = registry.get(model.moveIndex);\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 (moveIndex > 0) {\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n });\n }, [registry, 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 { useAtomValue } from '@effect-atom/atom-react';\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { Obj } from '@dxos/echo';\nimport { type SpaceMember, 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/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 db = Obj.getDatabase(model.object);\n const members = useMembers(db?.spaceId);\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 Obj.change(model.object, (obj) => {\n obj.players![orientation === 'white' ? 'black' : 'white'] = value;\n });\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 Obj.change(model.object, (obj) => {\n obj.players![orientation] = value;\n });\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 moveIndex = useAtomValue(model.moveIndex);\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=\"${moveIndex - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [moveIndex]);\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 === moveIndex - 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 === moveIndex - 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,SAAwBA,uBAAuB;AAC/C,O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GF,YAAYC,SAAS,mBAAmB,+BAAA;IACvDE,MAAM,CAACF,QAAQA,SAAS;IACxBG,SAAS,CAACH,QAAQA,SAAS,qBAAqBA,SAAS;KAExD9B,QAAAA;AAGP;AAQA,IAAMkC,QAAQ,CAACC,UAAAA;AACb,QAAMxC,WAAWO,WAAWC,eAAAA;AAC5B,QAAM,EAAEC,MAAK,IAAKgC,qBAAgCF,MAAMG,WAAW;AAGnE,QAAMC,MAAMC,QAAuB,IAAA;AACnC3B,EAAAA,WAAU,MAAA;AACR,QAAI,CAAC0B,IAAIE,SAAS;AAChB;IACF;AAGAF,QAAIE,QAAQC,aAAa,mBAAmB,KAAA;AAE5C,WAAOC,iBAAiBJ,IAAIE,SAAS,WAAW,CAACG,OAAAA;AAC/C,YAAMC,YAAYjD,SAASkD,IAAIzC,MAAMwC,SAAS;AAC9C,cAAQD,GAAGG,KAAG;QACZ,KAAK;AACH1C,gBAAMO,aAAa,CAAA;AACnB;QACF,KAAK;AACHP,gBAAMO,aAAaP,MAAML,KAAKgD,QAAO,EAAGC,MAAM;AAC9C;QACF,KAAK;AACH,cAAIJ,YAAY,GAAG;AACjBxC,kBAAMO,aAAaiC,YAAY,CAAA;UACjC;AACA;QACF,KAAK;AACH,cAAIA,YAAYxC,MAAML,KAAKgD,QAAO,EAAGC,QAAQ;AAC3C5C,kBAAMO,aAAaiC,YAAY,CAAA;UACjC;AACA;MACJ;IACF,CAAA;EACF,GAAG;IAACjD;IAAUS;GAAM;AAEpB,SAAO,gBAAAqB,OAAA,cAACwB,mBAAAA;IAAkBX;IAAW,GAAGH;;AAC1C;AAEAD,MAAMG,cAAc;AAMb,IAAMa,aAAa;EACxBrD;EACA+B;EACAM;EACAiB;AACF;",
|
|
6
|
-
"names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "Obj", "ChessModel", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useSoundEffect", "mx", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "generateName", "Obj", "useMembers", "Icon", "IconButton", "Select", "useTranslation", "useGameboardContext", "mx", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "useTranslation", "meta", "id", "model", "useGameboardContext", "displayName", "db", "Obj", "getDatabase", "object", "members", "useMembers", "spaceId", "div", "className", "mx", "PlayerIndicator", "player", "icon", "IconButton", "iconOnly", "label", "size", "onClick", "PlayerSelector", "value", "players", "onValueChange", "change", "obj", "History", "min", "max", "onSelect", "moveIndex", "useAtomValue", "game", "isGameOver", "isCheckmate", "isStalemate", "isCheck", "undefined", "history", "moves", "useMemo", "reduce", "acc", "move", "index", "push", "length", "scrollerRef", "useRef", "useEffect", "current", "scrollTo", "top", "scrollHeight", "querySelector", "classList", "add", "scrollIntoView", "behavior", "remove", "ref", "style", "minHeight", "maxHeight", "map", "a", "b", "key", "data-index", "children", "turn", "Icon", "Select", "Root", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "member", "memberKey", "identity", "identityKey", "toHex", "profile", "generateName", "Option", "Arrow", "ExtendedChessModel", "ChessModel", "registry", "object", "Root", "forwardRef", "game", "children", "forwardedRef", "useContext", "RegistryContext", "model", "useMemo", "click", "useSoundEffect", "useImperativeHandle", "setMoveNumber", "index", "setMoveIndex", "useEffect", "pgn", "getRawPgn", "silent", "update", "play", "handleDrop", "useCallback", "move", "makeMove", "Obj", "change", "g", "React", "Gameboard", "onDrop", "Content", "classNames", "role", "mx", "grow", "contain", "Board", "props", "useGameboardContext", "displayName", "ref", "useRef", "current", "setAttribute", "addEventListener", "ev", "moveIndex", "get", "key", "history", "length", "NaturalChessboard", "Chessboard", "Info"]
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ChessboardContainer
|
|
4
|
-
} from "./chunk-24GJHLHM.mjs";
|
|
5
|
-
import {
|
|
6
|
-
Chess_exports
|
|
7
|
-
} from "./chunk-OUNGNJFP.mjs";
|
|
8
|
-
import "./chunk-WXEPWOHT.mjs";
|
|
9
|
-
import {
|
|
10
|
-
meta
|
|
11
|
-
} from "./chunk-F5OMIM4F.mjs";
|
|
12
|
-
import "./chunk-HSLMI22Q.mjs";
|
|
13
|
-
|
|
14
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import React from "react";
|
|
17
|
-
import { Capability, Common } from "@dxos/app-framework";
|
|
18
|
-
import { Obj } from "@dxos/echo";
|
|
19
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common.Capability.ReactSurface, [
|
|
20
|
-
Common.createSurface({
|
|
21
|
-
id: meta.id,
|
|
22
|
-
role: [
|
|
23
|
-
"article",
|
|
24
|
-
"section",
|
|
25
|
-
"card--content"
|
|
26
|
-
],
|
|
27
|
-
// TODO(burdon): Could this be standardized so that we don't require a subject property.
|
|
28
|
-
filter: (data) => Obj.instanceOf(Chess_exports.Game, data.subject),
|
|
29
|
-
component: ({ data, role }) => /* @__PURE__ */ React.createElement(ChessboardContainer, {
|
|
30
|
-
role,
|
|
31
|
-
subject: data.subject
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
])));
|
|
35
|
-
export {
|
|
36
|
-
react_surface_default as default
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=react-surface-HSHCIOAS.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { ChessboardContainer } from '../../components';\nimport { meta } from '../../meta';\nimport { Chess } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Common.Capability.ReactSurface, [\n Common.createSurface({\n id: meta.id,\n role: ['article', 'section', 'card--content'],\n // TODO(burdon): Could this be standardized so that we don't require a subject property.\n filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),\n component: ({ data, role }) => <ChessboardContainer role={role} subject={data.subject} />,\n }),\n ]),\n ),\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,WAAW;AAElB,SAASC,YAAYC,cAAc;AACnC,SAASC,WAAW;AAMpB,IAAA,wBAAeC,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YAAYC,OAAOJ,WAAWK,cAAc;EACrDD,OAAOE,cAAc;IACnBC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;MAAW;;;IAE7BC,QAAQ,CAACC,SAA0CC,IAAIC,WAAWC,cAAMC,MAAMJ,KAAKK,OAAO;IAC1FC,WAAW,CAAC,EAAEN,MAAMF,KAAI,MAAO,sBAAA,cAACS,qBAAAA;MAAoBT;MAAYO,SAASL,KAAKK;;EAChF,CAAA;CACD,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "React", "Capability", "Common", "Obj", "Capability", "makeModule", "succeed", "contributes", "Common", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Chess", "Game", "subject", "component", "ChessboardContainer"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Card.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Card.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAkB,MAAM,OAAO,CAAC;AA2BvC,QAAA,MAAM,IAAI;;;;;;;;CAQM,CAAC;AAEjB,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ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UAAU;;;;;;;CAmD/B,CAAC;AAEF,YAAY,EACV,SAAS,IAAI,mBAAmB,EAChC,YAAY,IAAI,sBAAsB,EACtC,UAAU,IAAI,oBAAoB,EAClC,SAAS,IAAI,mBAAmB,GACjC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chessboard.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Chessboard.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,KAAK,UAAU,GAAG;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,QAAA,MAAM,IAAI;;yBALqB,UAAU;;;;;;yBAZc,CAAQ,KAC5D,CAAC,IAAI,CAAC,QAAQ,CAAC;;;;;;;;;;yBAaN,CAAQ,IAAI,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;CAWS,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAIvB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
3
|
-
import { type Chess } from '../types';
|
|
4
|
-
export type ChessboardArticleProps = SurfaceComponentProps<Chess.Game>;
|
|
5
|
-
export declare const ChessboardArticle: ({ role, subject: game }: ChessboardArticleProps) => React.JSX.Element;
|
|
6
|
-
//# sourceMappingURL=ChessboardArticle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessboardArticle.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessboardArticle.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAOvE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAEvE,eAAO,MAAM,iBAAiB,GAAI,yBAAyB,sBAAsB,sBAmDhF,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
3
|
-
import { type Chess } from '../types';
|
|
4
|
-
export type ChessboardContainerProps = SurfaceComponentProps<Chess.Game>;
|
|
5
|
-
export declare const ChessboardContainer: ({ role, subject: game }: ChessboardContainerProps) => React.JSX.Element | null;
|
|
6
|
-
export default ChessboardContainer;
|
|
7
|
-
//# sourceMappingURL=ChessboardContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessboardContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessboardContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAKtC,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAEzE,eAAO,MAAM,mBAAmB,GAAI,yBAAyB,wBAAwB,6BAqBpF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../../src/components/Info.tsx"],"names":[],"mappings":"AAKA,OAAc,EAAE,KAAK,GAAG,EAAsD,MAAM,OAAO,CAAC;AAK5F,OAAO,EAA4B,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,KAAK,MAAM,EAAuB,MAAM,0BAA0B,CAAC;AAK5E,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,eAAe,CACrC;IACE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,KAAK,GAAG,UAAU,CAAC,CACnD,CAAC;AAEF,eAAO,MAAM,IAAI;0EAAmF,SAAS;;CA+D5G,CAAC;AAQF,KAAK,YAAY,GAAG,eAAe,CAAC;IAClC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
-
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import { type Player } from '@dxos/react-ui-gameboard';
|
|
10
|
-
import { Layout } from '@dxos/react-ui-mosaic';
|
|
11
|
-
import { mx } from '@dxos/ui-theme';
|
|
12
|
-
|
|
13
|
-
import { meta } from '../meta';
|
|
14
|
-
import { type Chess } from '../types';
|
|
15
|
-
|
|
16
|
-
import { Chessboard, type ChessboardController, type ChessboardInfoProps } from './Chessboard';
|
|
17
|
-
|
|
18
|
-
export type ChessboardArticleProps = SurfaceComponentProps<Chess.Game>;
|
|
19
|
-
|
|
20
|
-
export const ChessboardArticle = ({ role, subject: game }: ChessboardArticleProps) => {
|
|
21
|
-
const { t } = useTranslation(meta.id);
|
|
22
|
-
const [orientation, setOrientation] = useState<Player>('white');
|
|
23
|
-
const [open, setOpen] = useState(true);
|
|
24
|
-
const controller = useRef<ChessboardController>(null);
|
|
25
|
-
|
|
26
|
-
// TODO(burdon): Keyboard handler.
|
|
27
|
-
const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {
|
|
28
|
-
controller.current?.setMoveNumber(index);
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Layout.Main toolbar classNames='@container'>
|
|
33
|
-
<Chessboard.Root game={game} ref={controller}>
|
|
34
|
-
<Toolbar.Root>
|
|
35
|
-
<Toolbar.IconButton
|
|
36
|
-
icon='ph--info--regular'
|
|
37
|
-
iconOnly
|
|
38
|
-
label={t('toggle info button')}
|
|
39
|
-
disabled={open}
|
|
40
|
-
classNames={mx('invisible @3xl:visible')}
|
|
41
|
-
onClick={() => setOpen((open) => !open)}
|
|
42
|
-
/>
|
|
43
|
-
</Toolbar.Root>
|
|
44
|
-
<div
|
|
45
|
-
className={mx(
|
|
46
|
-
'grid bs-full is-full gap-2',
|
|
47
|
-
open && '@3xl:grid-cols-[1fr_320px]',
|
|
48
|
-
role === 'section' && 'aspect-square',
|
|
49
|
-
role === 'section' && open && '@3xl:aspect-auto',
|
|
50
|
-
)}
|
|
51
|
-
>
|
|
52
|
-
<Chessboard.Content>
|
|
53
|
-
<Chessboard.Board classNames='m-4 rounded-sm overflow-hidden' orientation={orientation} />
|
|
54
|
-
</Chessboard.Content>
|
|
55
|
-
{open && (
|
|
56
|
-
<div className='hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden'>
|
|
57
|
-
<Chessboard.Info
|
|
58
|
-
orientation={orientation}
|
|
59
|
-
min={8}
|
|
60
|
-
max={8}
|
|
61
|
-
onOrientationChange={setOrientation}
|
|
62
|
-
onClose={() => setOpen(false)}
|
|
63
|
-
onSelect={handleSelect}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
</Chessboard.Root>
|
|
69
|
-
</Layout.Main>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
|
|
10
|
-
import { type Chess } from '../types';
|
|
11
|
-
|
|
12
|
-
import { Chessboard } from './Chessboard';
|
|
13
|
-
import { ChessboardArticle } from './ChessboardArticle';
|
|
14
|
-
|
|
15
|
-
export type ChessboardContainerProps = SurfaceComponentProps<Chess.Game>;
|
|
16
|
-
|
|
17
|
-
export const ChessboardContainer = ({ role, subject: game }: ChessboardContainerProps) => {
|
|
18
|
-
const db = Obj.getDatabase(game);
|
|
19
|
-
if (!db) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
switch (role) {
|
|
24
|
-
case 'card--content': {
|
|
25
|
-
return (
|
|
26
|
-
<Chessboard.Root game={game}>
|
|
27
|
-
<Chessboard.Content>
|
|
28
|
-
<Chessboard.Board />
|
|
29
|
-
</Chessboard.Content>
|
|
30
|
-
</Chessboard.Root>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
default: {
|
|
35
|
-
return <ChessboardArticle role={role} subject={game} />;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default ChessboardContainer;
|