@dxos/plugin-chess 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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-JOCAWL5W.mjs → ChessboardContainer-SZMONNHG.mjs} +4 -5
- package/dist/lib/browser/{ChessboardContainer-JOCAWL5W.mjs.map → ChessboardContainer-SZMONNHG.mjs.map} +3 -3
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs +11 -0
- package/dist/lib/browser/{chunk-WSUUPPDK.mjs → chunk-DUO4WTAM.mjs} +4 -2
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3WEALY7P.mjs → chunk-FBLAVAMY.mjs} +12 -12
- package/dist/lib/browser/chunk-FBLAVAMY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NR4YFUK7.mjs → chunk-R6KK3WAS.mjs} +5 -17
- package/dist/lib/browser/{chunk-NR4YFUK7.mjs.map → chunk-R6KK3WAS.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-4ULSTPL6.mjs → chunk-TIIGNOGK.mjs} +11 -8
- package/dist/lib/browser/chunk-TIIGNOGK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2EN3CBLB.mjs → chunk-WLXUZMHC.mjs} +2 -2
- package/dist/lib/browser/index.mjs +21 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-PMP36Y5B.mjs → intent-resolver-GXZN2EBT.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-TSLFLTXN.mjs → react-surface-EVJLBV6U.mjs} +5 -5
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{ChessboardContainer-XAVVBRFW.mjs → ChessboardContainer-GAIIADOA.mjs} +4 -5
- package/dist/lib/node-esm/{ChessboardContainer-XAVVBRFW.mjs.map → ChessboardContainer-GAIIADOA.mjs.map} +3 -3
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs +12 -0
- package/dist/lib/node-esm/{chunk-7PHZFXU5.mjs → chunk-FKRBFLJC.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-VVTQFCUK.mjs → chunk-IVEIH4ER.mjs} +5 -17
- package/dist/lib/node-esm/{chunk-VVTQFCUK.mjs.map → chunk-IVEIH4ER.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-5C2OYL2B.mjs → chunk-KNOOJFIR.mjs} +4 -2
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LMXETYDF.mjs → chunk-MP3A3AGA.mjs} +12 -12
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AR3TI5LX.mjs → chunk-RTCAAOLF.mjs} +11 -8
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-5P7Y2ZKB.mjs → intent-resolver-HK5L6P6Z.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-AN4SMEDU.mjs → react-surface-4PRNWQ2V.mjs} +5 -5
- package/dist/lib/node-esm/types/index.mjs +2 -2
- 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 +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/components/Card.stories.d.ts +11 -2
- package/dist/types/src/components/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +8 -8
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/functions/create.d.ts +1 -1
- package/dist/types/src/functions/create.d.ts.map +1 -1
- package/dist/types/src/functions/move.d.ts.map +1 -1
- package/dist/types/src/functions/play.d.ts.map +1 -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 +29 -30
- package/src/ChessPlugin.tsx +3 -2
- package/src/capabilities/artifact-definition.ts +3 -2
- package/src/capabilities/blueprint-definition.ts +3 -3
- package/src/components/Card.stories.tsx +2 -2
- package/src/components/ChessboardArticle.tsx +1 -1
- package/src/components/Info.tsx +4 -4
- package/src/functions/create.ts +2 -1
- package/src/functions/move.ts +2 -1
- package/src/functions/play.ts +2 -1
- package/src/meta.ts +3 -1
- package/src/translations.ts +8 -8
- package/src/types/Chess.ts +20 -26
- package/src/types/ChessAction.ts +1 -1
- package/dist/lib/browser/blueprint-definition-LC4GNYMG.mjs +0 -11
- package/dist/lib/browser/chunk-3WEALY7P.mjs.map +0 -7
- package/dist/lib/browser/chunk-4ULSTPL6.mjs.map +0 -7
- package/dist/lib/browser/chunk-WSUUPPDK.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-FBGRWYEW.mjs +0 -12
- package/dist/lib/node-esm/chunk-5C2OYL2B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AR3TI5LX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LMXETYDF.mjs.map +0 -7
- /package/dist/lib/browser/{blueprint-definition-LC4GNYMG.mjs.map → blueprint-definition-FD4TL5EE.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-2EN3CBLB.mjs.map → chunk-WLXUZMHC.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-PMP36Y5B.mjs.map → intent-resolver-GXZN2EBT.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-TSLFLTXN.mjs.map → react-surface-EVJLBV6U.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-FBGRWYEW.mjs.map → blueprint-definition-O7ZM3HUF.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-7PHZFXU5.mjs.map → chunk-FKRBFLJC.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-5P7Y2ZKB.mjs.map → intent-resolver-HK5L6P6Z.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-AN4SMEDU.mjs.map → react-surface-4PRNWQ2V.mjs.map} +0 -0
package/dist/lib/browser/{ChessboardContainer-JOCAWL5W.mjs → ChessboardContainer-SZMONNHG.mjs}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Chessboard
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R6KK3WAS.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";
|
|
@@ -27,8 +27,7 @@ var ChessboardArticle = ({ game, role }) => {
|
|
|
27
27
|
controller.current?.setMoveNumber(index);
|
|
28
28
|
}, []);
|
|
29
29
|
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
30
|
-
toolbar: true
|
|
31
|
-
classNames: "@container bs-full is-full overflow-hidden"
|
|
30
|
+
toolbar: true
|
|
32
31
|
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
33
32
|
game,
|
|
34
33
|
ref: controller
|
|
@@ -94,4 +93,4 @@ export {
|
|
|
94
93
|
ChessboardContainer,
|
|
95
94
|
ChessboardContainer_default as default
|
|
96
95
|
};
|
|
97
|
-
//# sourceMappingURL=ChessboardContainer-
|
|
96
|
+
//# sourceMappingURL=ChessboardContainer-SZMONNHG.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { IconButton, 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
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,gBAAgB;;;;ACFzB,OAAOC,SAASC,aAAaC,QAAQC,gBAAgB;AAErD,SAASC,YAAYC,SAASC,sBAAsB;AAEpD,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;
|
|
6
|
-
"names": ["React", "getSpace", "React", "useCallback", "useRef", "useState", "IconButton", "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", "
|
|
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 { IconButton, 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>\n <Chessboard.Root game={game} ref={controller}>\n <Toolbar.Root>\n <IconButton\n variant='ghost'\n icon='ph--info--regular'\n iconOnly\n label={t('toggle info button')}\n size={6}\n classNames={mx('invisible', !open && '@3xl:visible')}\n onClick={() => setOpen((open) => !open)}\n />\n </Toolbar.Root>\n <div\n className={mx(\n 'grid _grid-rows-[1fr_4rem] 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)}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AAA,cAACd,WAAWgB,MAAI;MACd/B;MACAgC,KAAK;MACLC,KAAK;MACLC,qBAAqBjC;MACrBkC,SAAS,MAAM/B,QAAQ,KAAA;MACvBgC,UAAU7B;;;;;AAQ1B;;;ADlDO,IAAM8B,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", "IconButton", "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", "Chessboard", "Root", "ref", "Toolbar", "IconButton", "variant", "icon", "iconOnly", "label", "size", "classNames", "mx", "onClick", "div", "className", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect", "ChessboardContainer", "game", "role", "space", "getSpace", "React", "Chessboard", "Root", "Content", "Board", "ChessboardArticle"]
|
|
7
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
|
|
@@ -10,9 +10,11 @@ var meta = {
|
|
|
10
10
|
id: "dxos.org/plugin/chess",
|
|
11
11
|
name: "Chess",
|
|
12
12
|
description: trim`
|
|
13
|
-
|
|
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.
|
|
14
15
|
`,
|
|
15
16
|
icon: "ph--shield-chevron--regular",
|
|
17
|
+
iconHue: "amber",
|
|
16
18
|
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
17
19
|
screenshots: [
|
|
18
20
|
"https://dxos.network/plugin-details-chess-dark.png"
|
|
@@ -23,4 +25,4 @@ export {
|
|
|
23
25
|
__export,
|
|
24
26
|
meta
|
|
25
27
|
};
|
|
26
|
-
//# 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,SAASC,WAAW;AACpB,SAASC,sBAAsB;;AAExB,IAAMC,OAAcC,cAAO;EAChCC,MAAaC,gB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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,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) {
|
|
@@ -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-R6KK3WAS.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-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;AAC1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C7C;AACA;QACJ;MACF,CAAA;IACF,GAAG;MAACzC;KAAM;AAEV,WAAO,gBAAAkB,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
|
}
|
|
@@ -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,7 +8,8 @@ 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",
|
|
@@ -33,7 +34,8 @@ var create_default = defineFunction({
|
|
|
33
34
|
|
|
34
35
|
// src/functions/move.ts
|
|
35
36
|
import { Chess as ChessJS } from "chess.js";
|
|
36
|
-
import
|
|
37
|
+
import * as Effect2 from "effect/Effect";
|
|
38
|
+
import * as Schema2 from "effect/Schema";
|
|
37
39
|
import { ArtifactId } from "@dxos/assistant";
|
|
38
40
|
import { DatabaseService as DatabaseService2, defineFunction as defineFunction2 } from "@dxos/functions";
|
|
39
41
|
var move_default = defineFunction2({
|
|
@@ -77,7 +79,8 @@ var move_default = defineFunction2({
|
|
|
77
79
|
|
|
78
80
|
// src/functions/play.ts
|
|
79
81
|
import { Chess as ChessJS2 } from "chess.js";
|
|
80
|
-
import
|
|
82
|
+
import * as Effect3 from "effect/Effect";
|
|
83
|
+
import * as Schema3 from "effect/Schema";
|
|
81
84
|
import { ArtifactId as ArtifactId2 } from "@dxos/assistant";
|
|
82
85
|
import { DatabaseService as DatabaseService3, defineFunction as defineFunction3 } from "@dxos/functions";
|
|
83
86
|
var play_default = defineFunction3({
|
|
@@ -129,17 +132,17 @@ var play_default = defineFunction3({
|
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
// src/capabilities/blueprint-definition.ts
|
|
132
|
-
var BLUEPRINT_KEY = "dxos.org/blueprint/chess";
|
|
133
135
|
var functions = [
|
|
134
136
|
create_default,
|
|
135
137
|
move_default,
|
|
136
138
|
play_default
|
|
137
139
|
];
|
|
140
|
+
var CHESS_BLUEPRINT_KEY = "dxos.org/blueprint/chess";
|
|
138
141
|
var blueprint_definition_default = (() => {
|
|
139
142
|
return [
|
|
140
143
|
contributes(Capabilities.Functions, functions),
|
|
141
144
|
contributes(Capabilities.BlueprintDefinition, Blueprint.make({
|
|
142
|
-
key:
|
|
145
|
+
key: CHESS_BLUEPRINT_KEY,
|
|
143
146
|
name: "Chess",
|
|
144
147
|
tools: Blueprint.toolDefinitions({
|
|
145
148
|
functions
|
|
@@ -160,7 +163,7 @@ export {
|
|
|
160
163
|
create_default,
|
|
161
164
|
move_default,
|
|
162
165
|
play_default,
|
|
163
|
-
|
|
166
|
+
CHESS_BLUEPRINT_KEY,
|
|
164
167
|
blueprint_definition_default
|
|
165
168
|
};
|
|
166
|
-
//# 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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O;QAAEO,MAAMgB;QAAWlB,KAAKM,OAAON;MAAK;IAC7C;AAEA,UAAMmB,QAAQP,MAAMO,MAAK;AACzB,UAAMjB,OAAOiB,MAAMC,KAAKC,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,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-SZMONNHG.mjs"));
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
ChessboardContainer
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-WLXUZMHC.mjs.map
|
|
@@ -1,29 +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-WLXUZMHC.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-R6KK3WAS.mjs";
|
|
18
18
|
import {
|
|
19
19
|
meta
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DUO4WTAM.mjs";
|
|
21
21
|
|
|
22
22
|
// src/capabilities/index.ts
|
|
23
23
|
import { lazy } from "@dxos/app-framework";
|
|
24
|
-
var BlueprintDefinition = lazy(() => import("./blueprint-definition-
|
|
25
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
26
|
-
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-EVJLBV6U.mjs"));
|
|
27
27
|
|
|
28
28
|
// src/ChessPlugin.tsx
|
|
29
29
|
import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from "@dxos/app-framework";
|
|
@@ -42,19 +42,19 @@ var translations = [
|
|
|
42
42
|
"typename label_other": "Games",
|
|
43
43
|
"object name placeholder": "New game",
|
|
44
44
|
"rename object label": "Rename game",
|
|
45
|
-
"delete object label": "Delete game"
|
|
46
|
-
"toggle info button": "Toggle info",
|
|
47
|
-
"close info button": "Close info",
|
|
48
|
-
"flip board button": "Flip board",
|
|
49
|
-
"select player button": "Select player"
|
|
45
|
+
"delete object label": "Delete game"
|
|
50
46
|
},
|
|
51
47
|
[meta.id]: {
|
|
52
48
|
"plugin name": "Chess",
|
|
53
49
|
"delete game label": "Delete",
|
|
54
|
-
"game.checkmate": "Checkmate",
|
|
55
|
-
"game.stalemate": "Stalemate",
|
|
56
|
-
"game.draw": "Draw",
|
|
57
|
-
"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"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -74,8 +74,9 @@ var ChessPlugin = definePlugin(meta, () => [
|
|
|
74
74
|
id: Chess_exports.Game.typename,
|
|
75
75
|
metadata: {
|
|
76
76
|
icon: "ph--shield-chevron--regular",
|
|
77
|
+
iconHue: "amber",
|
|
77
78
|
blueprints: [
|
|
78
|
-
|
|
79
|
+
CHESS_BLUEPRINT_KEY
|
|
79
80
|
]
|
|
80
81
|
}
|
|
81
82
|
})
|
|
@@ -105,8 +106,8 @@ var ChessPlugin = definePlugin(meta, () => [
|
|
|
105
106
|
})
|
|
106
107
|
]);
|
|
107
108
|
export {
|
|
108
|
-
BLUEPRINT_KEY,
|
|
109
109
|
BlueprintDefinition,
|
|
110
|
+
CHESS_BLUEPRINT_KEY,
|
|
110
111
|
Chess_exports as Chess,
|
|
111
112
|
ChessAction_exports as ChessAction,
|
|
112
113
|
ChessPlugin,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/capabilities/index.ts", "../../../src/ChessPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const BlueprintDefinition = lazy(() => import('./blueprint-definition'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './blueprint-definition';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from '@dxos/app-framework';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,YAAY;AAEd,IAAMC,sBAAsBC,KAAK,MAAM,OAAO,qCAAA,CAAA;AAC9C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,eAAeF,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ACJ9C,SAASG,cAAcC,QAAQC,aAAaC,cAAcC,cAAcC,oBAAoB;AAC5F,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;;;ACE1B,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,cAAMC,KAAKC,QAAQ,GAAG;QACrB,kBAAkB;QAClB,uBAAuB;QACvB,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,uBAAuB;QACvB,uBAAuB;
|
|
6
|
-
"names": ["lazy", "BlueprintDefinition", "lazy", "IntentResolver", "ReactSurface", "Capabilities", "Events", "contributes", "createIntent", "defineModule", "definePlugin", "ClientEvents", "SpaceCapabilities", "defineObjectForm", "translations", "Chess", "Game", "typename", "meta", "id", "ChessPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "Chess", "Game", "typename", "metadata", "icon", "blueprints", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const BlueprintDefinition = lazy(() => import('./blueprint-definition'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './blueprint-definition';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from '@dxos/app-framework';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport { BlueprintDefinition, CHESS_BLUEPRINT_KEY, IntentResolver, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { Chess, ChessAction } from './types';\n\nexport const ChessPlugin = definePlugin(meta, () => [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: Chess.Game.typename,\n metadata: {\n icon: 'ph--shield-chevron--regular',\n iconHue: 'amber',\n blueprints: [CHESS_BLUEPRINT_KEY],\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: Chess.Game,\n getIntent: () => createIntent(ChessAction.Create),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/blueprint`,\n activatesOn: Events.SetupArtifactDefinition,\n activate: BlueprintDefinition,\n }),\n]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { Chess } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [Chess.Game.typename]: {\n 'typename label': 'Game',\n 'typename label_zero': 'Games',\n 'typename label_one': 'Game',\n 'typename label_other': 'Games',\n 'object name placeholder': 'New game',\n 'rename object label': 'Rename game',\n 'delete object label': 'Delete game',\n },\n [meta.id]: {\n 'plugin name': 'Chess',\n 'delete game label': 'Delete',\n 'game.checkmate label': 'Checkmate',\n 'game.stalemate label': 'Stalemate',\n 'game.draw label': 'Draw',\n 'game.check label': 'Check',\n 'select player button': 'Select player',\n 'toggle info button': 'Toggle info',\n 'close info button': 'Close info',\n 'flip board button': 'Flip board',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
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b,cAAMC;MACpBa,WAAW,MAAMC,aAAaC,oBAAYC,MAAM;IAClD,CAAA,CAAA;EAEN,CAAA;EACA7B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO2B;IACpBzB,UAAU0B;EACZ,CAAA;EACA/B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO6B;IACpB3B,UAAU4B;EACZ,CAAA;EACAjC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO+B;IACpB7B,UAAU8B;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["lazy", "BlueprintDefinition", "lazy", "IntentResolver", "ReactSurface", "Capabilities", "Events", "contributes", "createIntent", "defineModule", "definePlugin", "ClientEvents", "SpaceCapabilities", "defineObjectForm", "translations", "Chess", "Game", "typename", "meta", "id", "ChessPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "Chess", "Game", "typename", "metadata", "icon", "iconHue", "blueprints", "CHESS_BLUEPRINT_KEY", "ClientEvents", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "getIntent", "createIntent", "ChessAction", "Create", "SetupReactSurface", "ReactSurface", "SetupIntentResolver", "IntentResolver", "SetupArtifactDefinition", "BlueprintDefinition"]
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChessAction_exports,
|
|
3
3
|
Chess_exports
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-FBLAVAMY.mjs";
|
|
5
|
+
import "./chunk-DUO4WTAM.mjs";
|
|
6
6
|
|
|
7
7
|
// src/capabilities/intent-resolver.ts
|
|
8
8
|
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
@@ -22,4 +22,4 @@ var intent_resolver_default = (() => contributes(Capabilities.IntentResolver, cr
|
|
|
22
22
|
export {
|
|
23
23
|
intent_resolver_default as default
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=intent-resolver-
|
|
25
|
+
//# sourceMappingURL=intent-resolver-GXZN2EBT.mjs.map
|