@dxos/plugin-chess 0.8.4-main.84f28bd → 0.8.4-main.937b3ca
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-IS4PXWJD.mjs +81 -0
- package/dist/lib/browser/ChessboardContainer-IS4PXWJD.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +11 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-7OZ7J7LF.mjs +64 -0
- package/dist/lib/browser/chunk-7OZ7J7LF.mjs.map +7 -0
- package/dist/lib/browser/chunk-DH4WQRZH.mjs +229 -0
- package/dist/lib/browser/chunk-DH4WQRZH.mjs.map +7 -0
- package/dist/lib/browser/chunk-H3NUMCQ6.mjs +21 -0
- package/dist/lib/browser/chunk-H3NUMCQ6.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-MV2GQK7M.mjs +8 -0
- package/dist/lib/browser/chunk-MV2GQK7M.mjs.map +7 -0
- package/dist/lib/browser/chunk-UUMPZ2FM.mjs +271 -0
- package/dist/lib/browser/chunk-UUMPZ2FM.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +28 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +69 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-GQE7XMWH.mjs +37 -0
- package/dist/lib/browser/react-surface-GQE7XMWH.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -7
- package/dist/lib/node-esm/ChessboardContainer-S3T6OE7P.mjs +82 -0
- package/dist/lib/node-esm/ChessboardContainer-S3T6OE7P.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-RYKASBIJ.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-RYKASBIJ.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +12 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TD2SWK2H.mjs → chunk-DOBR6ILE.mjs} +3 -3
- package/dist/lib/node-esm/chunk-DOBR6ILE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F5OMIM4F.mjs +23 -0
- package/dist/lib/node-esm/chunk-F5OMIM4F.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LKJ5GDAB.mjs +272 -0
- package/dist/lib/node-esm/chunk-LKJ5GDAB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NAYRVJR4.mjs +65 -0
- package/dist/lib/node-esm/chunk-NAYRVJR4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NFDJU7XQ.mjs +230 -0
- package/dist/lib/node-esm/chunk-NFDJU7XQ.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +29 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +69 -66
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-7UZLIVN6.mjs +38 -0
- package/dist/lib/node-esm/react-surface-7UZLIVN6.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -7
- package/dist/types/src/ChessPlugin.d.ts +2 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/chess-blueprint.d.ts +21 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts +15 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +5 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/move.d.ts +8 -0
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/play.d.ts +9 -0
- package/dist/types/src/blueprints/functions/play.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/print.d.ts +8 -0
- package/dist/types/src/blueprints/functions/print.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +3 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +2 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/Card.stories.d.ts +15 -0
- package/dist/types/src/components/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.d.ts +39 -0
- package/dist/types/src/components/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.stories.d.ts +43 -5
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +6 -0
- package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -0
- package/dist/types/src/components/ChessboardContainer.d.ts +7 -0
- package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -0
- package/dist/types/src/components/Info.d.ts +21 -0
- package/dist/types/src/components/Info.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +13 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +27 -0
- package/dist/types/src/types/Chess.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -39
- package/src/ChessPlugin.tsx +26 -52
- package/src/blueprints/chess-blueprint.ts +28 -0
- package/src/blueprints/functions/create.ts +38 -0
- package/src/blueprints/functions/index.ts +8 -0
- package/src/blueprints/functions/move.ts +49 -0
- package/src/blueprints/functions/play.ts +59 -0
- package/src/blueprints/functions/print.ts +42 -0
- package/src/blueprints/index.ts +6 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +135 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +2 -5
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +27 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +26 -0
- package/src/components/Card.stories.tsx +47 -0
- package/src/components/Chessboard.stories.tsx +36 -22
- package/src/components/Chessboard.tsx +188 -0
- package/src/components/ChessboardArticle.tsx +71 -0
- package/src/components/ChessboardContainer.tsx +40 -0
- package/src/components/Info.tsx +240 -0
- package/src/components/index.ts +2 -2
- package/src/index.ts +2 -0
- package/src/meta.ts +9 -7
- package/src/translations.ts +13 -2
- package/src/types/Chess.ts +58 -0
- package/src/types/index.ts +1 -2
- package/dist/lib/browser/ChessContainer-DL5J6VIK.mjs +0 -101
- package/dist/lib/browser/ChessContainer-DL5J6VIK.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-4AMZY5LQ.mjs +0 -182
- package/dist/lib/browser/artifact-definition-4AMZY5LQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-2VF6U52K.mjs +0 -8
- package/dist/lib/browser/chunk-2VF6U52K.mjs.map +0 -7
- package/dist/lib/browser/chunk-A3WEUKPK.mjs +0 -61
- package/dist/lib/browser/chunk-A3WEUKPK.mjs.map +0 -7
- package/dist/lib/browser/chunk-AZSYKAFK.mjs +0 -61
- package/dist/lib/browser/chunk-AZSYKAFK.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs +0 -28
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4TBVZUKU.mjs +0 -43
- package/dist/lib/browser/react-surface-4TBVZUKU.mjs.map +0 -7
- package/dist/lib/node-esm/ChessContainer-WVOL2KSE.mjs +0 -102
- package/dist/lib/node-esm/ChessContainer-WVOL2KSE.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-TT3747JB.mjs +0 -183
- package/dist/lib/node-esm/artifact-definition-TT3747JB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2DRWEDVT.mjs +0 -63
- package/dist/lib/node-esm/chunk-2DRWEDVT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs +0 -63
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TD2SWK2H.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs +0 -29
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-PAUEOIBL.mjs +0 -44
- package/dist/lib/node-esm/react-surface-PAUEOIBL.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/ChessComponent.d.ts +0 -6
- package/dist/types/src/components/ChessComponent.d.ts.map +0 -1
- package/dist/types/src/components/ChessContainer.d.ts +0 -8
- package/dist/types/src/components/ChessContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChessPanel.d.ts +0 -11
- package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
- package/dist/types/src/components/PlayerSelector.d.ts +0 -8
- package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -29
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -32
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -124
- package/src/capabilities/intent-resolver.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -30
- package/src/components/ChessComponent.tsx +0 -54
- package/src/components/ChessContainer.tsx +0 -35
- package/src/components/ChessPanel.tsx +0 -67
- package/src/components/PlayerSelector.tsx +0 -80
- package/src/types/schema.ts +0 -34
- package/src/types/types.ts +0 -20
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Chessboard
|
|
3
|
+
} from "./chunk-UUMPZ2FM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
meta
|
|
6
|
+
} from "./chunk-H3NUMCQ6.mjs";
|
|
7
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/ChessboardContainer.tsx
|
|
10
|
+
import React2 from "react";
|
|
11
|
+
import { Obj } from "@dxos/echo";
|
|
12
|
+
|
|
13
|
+
// src/components/ChessboardArticle.tsx
|
|
14
|
+
import React, { useCallback, useRef, useState } from "react";
|
|
15
|
+
import { Toolbar, useTranslation } from "@dxos/react-ui";
|
|
16
|
+
import { Layout } from "@dxos/react-ui-mosaic";
|
|
17
|
+
import { mx } from "@dxos/ui-theme";
|
|
18
|
+
var ChessboardArticle = ({ role, subject: game }) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const [orientation, setOrientation] = useState("white");
|
|
21
|
+
const [open, setOpen] = useState(true);
|
|
22
|
+
const controller = useRef(null);
|
|
23
|
+
const handleSelect = useCallback((index) => {
|
|
24
|
+
controller.current?.setMoveNumber(index);
|
|
25
|
+
}, []);
|
|
26
|
+
return /* @__PURE__ */ React.createElement(Layout.Main, {
|
|
27
|
+
toolbar: true,
|
|
28
|
+
classNames: "@container"
|
|
29
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
30
|
+
game,
|
|
31
|
+
ref: controller
|
|
32
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
33
|
+
icon: "ph--info--regular",
|
|
34
|
+
iconOnly: true,
|
|
35
|
+
label: t("toggle info button"),
|
|
36
|
+
disabled: open,
|
|
37
|
+
classNames: mx("invisible @3xl:visible"),
|
|
38
|
+
onClick: () => setOpen((open2) => !open2)
|
|
39
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
40
|
+
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")
|
|
41
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
42
|
+
classNames: "m-4 rounded-sm overflow-hidden",
|
|
43
|
+
orientation
|
|
44
|
+
})), open && /* @__PURE__ */ React.createElement("div", {
|
|
45
|
+
className: "hidden @3xl:flex flex-col p-8 justify-center items-center overflow-hidden"
|
|
46
|
+
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
47
|
+
orientation,
|
|
48
|
+
min: 8,
|
|
49
|
+
max: 8,
|
|
50
|
+
onOrientationChange: setOrientation,
|
|
51
|
+
onClose: () => setOpen(false),
|
|
52
|
+
onSelect: handleSelect
|
|
53
|
+
})))));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/components/ChessboardContainer.tsx
|
|
57
|
+
var ChessboardContainer = ({ role, subject: game }) => {
|
|
58
|
+
const db = Obj.getDatabase(game);
|
|
59
|
+
if (!db) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
switch (role) {
|
|
63
|
+
case "card--content": {
|
|
64
|
+
return /* @__PURE__ */ React2.createElement(Chessboard.Root, {
|
|
65
|
+
game
|
|
66
|
+
}, /* @__PURE__ */ React2.createElement(Chessboard.Content, null, /* @__PURE__ */ React2.createElement(Chessboard.Board, null)));
|
|
67
|
+
}
|
|
68
|
+
default: {
|
|
69
|
+
return /* @__PURE__ */ React2.createElement(ChessboardArticle, {
|
|
70
|
+
role,
|
|
71
|
+
subject: game
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var ChessboardContainer_default = ChessboardContainer;
|
|
77
|
+
export {
|
|
78
|
+
ChessboardContainer,
|
|
79
|
+
ChessboardContainer_default as default
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=ChessboardContainer-IS4PXWJD.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ChessboardContainer.tsx", "../../../src/components/ChessboardArticle.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { 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 </div>\n )}\n </div>\n </Chessboard.Root>\n </Layout.Main>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,OAAOA,YAAW;AAGlB,SAASC,WAAW;;;ACHpB,OAAOC,SAASC,aAAaC,QAAQC,gBAAgB;AAGrD,SAASC,SAASC,sBAAsB;AAExC,SAASC,cAAc;AACvB,SAASC,UAAU;AASZ,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,SAASC,KAAI,MAA0B;AAC/E,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAM,CAACC,aAAaC,cAAAA,IAAkBC,SAAiB,OAAA;AACvD,QAAM,CAACC,MAAMC,OAAAA,IAAWF,SAAS,IAAA;AACjC,QAAMG,aAAaC,OAA6B,IAAA;AAGhD,QAAMC,eAAeC,YAA0D,CAACC,UAAAA;AAC9EJ,eAAWK,SAASC,cAAcF,KAAAA;EACpC,GAAG,CAAA,CAAE;AAEL,SACE,sBAAA,cAACG,OAAOC,MAAI;IAACC,SAAAA;IAAQC,YAAW;KAC9B,sBAAA,cAACC,WAAWC,MAAI;IAACtB;IAAYuB,KAAKb;KAChC,sBAAA,cAACc,QAAQF,MAAI,MACX,sBAAA,cAACE,QAAQC,YAAU;IACjBC,MAAK;IACLC,UAAAA;IACAC,OAAO3B,EAAE,oBAAA;IACT4B,UAAUrB;IACVY,YAAYU,GAAG,wBAAA;IACfC,SAAS,MAAMtB,QAAQ,CAACD,UAAS,CAACA,KAAAA;OAGtC,sBAAA,cAACwB,OAAAA;IACCC,WAAWH,GACT,8BACAtB,QAAQ,8BACRV,SAAS,aAAa,iBACtBA,SAAS,aAAaU,QAAQ,kBAAA;KAGhC,sBAAA,cAACa,WAAWa,SAAO,MACjB,sBAAA,cAACb,WAAWc,OAAK;IAACf,YAAW;IAAiCf;OAE/DG,QACC,sBAAA,cAACwB,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACZ,WAAWe,MAAI;IACd/B;IACAgC,KAAK;IACLC,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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chess_blueprint_exports
|
|
3
|
+
} from "./chunk-DH4WQRZH.mjs";
|
|
4
|
+
import "./chunk-7OZ7J7LF.mjs";
|
|
5
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
6
|
+
|
|
7
|
+
// src/capabilities/blueprint-definition/blueprint-definition.ts
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { Capability, Common } from "@dxos/app-framework";
|
|
10
|
+
var blueprintDefinition = Capability.makeModule(() => Effect.succeed([
|
|
11
|
+
Capability.contributes(Common.Capability.Functions, chess_blueprint_exports.functions),
|
|
12
|
+
Capability.contributes(Common.Capability.BlueprintDefinition, chess_blueprint_exports.make())
|
|
13
|
+
]));
|
|
14
|
+
var blueprint_definition_default = blueprintDefinition;
|
|
15
|
+
export {
|
|
16
|
+
blueprint_definition_default as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=blueprint-definition-5RUGJ64Z.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chess_blueprint_exports,
|
|
3
|
+
functions_exports
|
|
4
|
+
} from "../chunk-DH4WQRZH.mjs";
|
|
5
|
+
import "../chunk-7OZ7J7LF.mjs";
|
|
6
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
7
|
+
export {
|
|
8
|
+
chess_blueprint_exports as ChessBlueprint,
|
|
9
|
+
functions_exports as ChessFunctions
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/types/Chess.ts
|
|
6
|
+
var Chess_exports = {};
|
|
7
|
+
__export(Chess_exports, {
|
|
8
|
+
Game: () => Game,
|
|
9
|
+
make: () => make
|
|
10
|
+
});
|
|
11
|
+
import { Chess as ChessJS } from "chess.js";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import { Obj, Type } from "@dxos/echo";
|
|
14
|
+
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
15
|
+
import { log } from "@dxos/log";
|
|
16
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
|
|
17
|
+
var Game = Schema.Struct({
|
|
18
|
+
name: Schema.optional(Schema.String),
|
|
19
|
+
players: Schema.Struct({
|
|
20
|
+
white: Schema.optional(Schema.String.annotations({
|
|
21
|
+
description: "DID of white player"
|
|
22
|
+
})),
|
|
23
|
+
black: Schema.optional(Schema.String.annotations({
|
|
24
|
+
description: "DID of black player"
|
|
25
|
+
}))
|
|
26
|
+
}).pipe(Schema.mutable, FormInputAnnotation.set(false), Schema.optional),
|
|
27
|
+
pgn: Schema.String.annotations({
|
|
28
|
+
description: "Portable Game Notation."
|
|
29
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
30
|
+
fen: Schema.String.annotations({
|
|
31
|
+
description: "Forsyth-Edwards Notation."
|
|
32
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional)
|
|
33
|
+
}).pipe(Type.object({
|
|
34
|
+
typename: "dxos.org/type/Chess",
|
|
35
|
+
version: "0.2.0"
|
|
36
|
+
}), LabelAnnotation.set([
|
|
37
|
+
"name"
|
|
38
|
+
]));
|
|
39
|
+
var make = ({ name, pgn, fen } = {}) => {
|
|
40
|
+
const chess = new ChessJS();
|
|
41
|
+
if (pgn) {
|
|
42
|
+
try {
|
|
43
|
+
chess.loadPgn(pgn);
|
|
44
|
+
} catch {
|
|
45
|
+
log.warn(pgn, void 0, {
|
|
46
|
+
F: __dxlog_file,
|
|
47
|
+
L: 48,
|
|
48
|
+
S: void 0,
|
|
49
|
+
C: (f, a) => f(...a)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return Obj.make(Game, {
|
|
54
|
+
name,
|
|
55
|
+
pgn,
|
|
56
|
+
fen,
|
|
57
|
+
players: {}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
Chess_exports
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=chunk-7OZ7J7LF.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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(Schema.mutable, 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,KAAYC,gBAASd,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;EACvEU,KAAYT,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;EACvDW,KAAYV,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBe,IAAI,KAAA,GAAeT,eAAQ;AACzD,CAAA,EAAGO,KACDd,KAAKmB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAnB,gBAAgBc,IAAI;EAAC;CAAO,CAAA;AAKvB,IAAMM,OAAO,CAAC,EAAEhB,MAAMW,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMK,QAAQ,IAAI1B,QAAAA;AAClB,MAAIoB,KAAK;AACP,QAAI;AACFM,YAAMC,QAAQP,GAAAA;IAChB,QAAQ;AACNd,UAAIsB,KAAKR,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOlB,IAAIuB,KAAKlB,MAAM;IACpBE;IACAW;IACAC;IACAT,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", "mutable", "set", "pgn", "fen", "object", "typename", "version", "make", "chess", "loadPgn", "warn"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Chess_exports
|
|
3
|
+
} from "./chunk-7OZ7J7LF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/blueprints/chess-blueprint.ts
|
|
9
|
+
var chess_blueprint_exports = {};
|
|
10
|
+
__export(chess_blueprint_exports, {
|
|
11
|
+
Key: () => Key,
|
|
12
|
+
functions: () => functions,
|
|
13
|
+
make: () => make
|
|
14
|
+
});
|
|
15
|
+
import { Blueprint, Template } from "@dxos/blueprints";
|
|
16
|
+
import { trim } from "@dxos/util";
|
|
17
|
+
|
|
18
|
+
// src/blueprints/functions/index.ts
|
|
19
|
+
var functions_exports = {};
|
|
20
|
+
__export(functions_exports, {
|
|
21
|
+
create: () => create_default,
|
|
22
|
+
move: () => move_default,
|
|
23
|
+
play: () => play_default,
|
|
24
|
+
print: () => print_default
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// src/blueprints/functions/create.ts
|
|
28
|
+
import * as Effect from "effect/Effect";
|
|
29
|
+
import * as Schema from "effect/Schema";
|
|
30
|
+
import { Database } from "@dxos/echo";
|
|
31
|
+
import { defineFunction } from "@dxos/functions";
|
|
32
|
+
var create_default = defineFunction({
|
|
33
|
+
key: "dxos.org/function/chess/create",
|
|
34
|
+
name: "Create Chess",
|
|
35
|
+
description: "Creates a new chess game.",
|
|
36
|
+
inputSchema: Schema.Struct({
|
|
37
|
+
name: Schema.optional(Schema.String.annotations({
|
|
38
|
+
description: "Name of the game."
|
|
39
|
+
})),
|
|
40
|
+
pgn: Schema.optional(Schema.String.annotations({
|
|
41
|
+
description: "Portable Game Notation."
|
|
42
|
+
})),
|
|
43
|
+
fen: Schema.optional(Schema.String.annotations({
|
|
44
|
+
description: "Forsyth-Edwards Notation."
|
|
45
|
+
}))
|
|
46
|
+
}),
|
|
47
|
+
outputSchema: Chess_exports.Game,
|
|
48
|
+
handler: Effect.fn(function* ({ data: { name, pgn, fen } }) {
|
|
49
|
+
return yield* Database.Service.add(Chess_exports.make({
|
|
50
|
+
name,
|
|
51
|
+
pgn,
|
|
52
|
+
fen
|
|
53
|
+
}));
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// src/blueprints/functions/move.ts
|
|
58
|
+
import { Chess as ChessJS } from "chess.js";
|
|
59
|
+
import * as Effect2 from "effect/Effect";
|
|
60
|
+
import * as Schema2 from "effect/Schema";
|
|
61
|
+
import { ArtifactId } from "@dxos/assistant";
|
|
62
|
+
import { Database as Database2, Obj } from "@dxos/echo";
|
|
63
|
+
import { defineFunction as defineFunction2 } from "@dxos/functions";
|
|
64
|
+
var move_default = defineFunction2({
|
|
65
|
+
key: "dxos.org/function/chess/move",
|
|
66
|
+
name: "Move",
|
|
67
|
+
description: "Makes a move in the given chess game.",
|
|
68
|
+
inputSchema: Schema2.Struct({
|
|
69
|
+
id: ArtifactId.annotations({
|
|
70
|
+
description: "The ID of the chess object."
|
|
71
|
+
}),
|
|
72
|
+
move: Schema2.String.annotations({
|
|
73
|
+
description: "The move to make in the chess game.",
|
|
74
|
+
examples: [
|
|
75
|
+
"e4",
|
|
76
|
+
"Bf3"
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
outputSchema: Schema2.Struct({
|
|
81
|
+
pgn: Schema2.String.annotations({
|
|
82
|
+
description: "The PGN of the game after the move was played."
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
handler: Effect2.fn(function* ({ data: { id, move } }) {
|
|
86
|
+
const object = yield* Database2.Service.resolve(ArtifactId.toDXN(id), Chess_exports.Game);
|
|
87
|
+
const chess = new ChessJS();
|
|
88
|
+
if (object.pgn) {
|
|
89
|
+
chess.loadPgn(object.pgn);
|
|
90
|
+
} else if (object.fen) {
|
|
91
|
+
chess.load(object.fen);
|
|
92
|
+
}
|
|
93
|
+
chess.move(move, {
|
|
94
|
+
strict: false
|
|
95
|
+
});
|
|
96
|
+
const pgn = chess.pgn();
|
|
97
|
+
Obj.change(object, (o) => {
|
|
98
|
+
o.pgn = pgn;
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
pgn
|
|
102
|
+
};
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/blueprints/functions/play.ts
|
|
107
|
+
import { Chess as ChessJS2 } from "chess.js";
|
|
108
|
+
import * as Effect3 from "effect/Effect";
|
|
109
|
+
import * as Schema3 from "effect/Schema";
|
|
110
|
+
import { ArtifactId as ArtifactId2 } from "@dxos/assistant";
|
|
111
|
+
import { Database as Database3, Obj as Obj2 } from "@dxos/echo";
|
|
112
|
+
import { defineFunction as defineFunction3 } from "@dxos/functions";
|
|
113
|
+
var play_default = defineFunction3({
|
|
114
|
+
key: "dxos.org/function/chess/play",
|
|
115
|
+
name: "Play",
|
|
116
|
+
description: "Uses the chess engine to play the next move.",
|
|
117
|
+
inputSchema: Schema3.Struct({
|
|
118
|
+
id: ArtifactId2.annotations({
|
|
119
|
+
description: "The ID of the chess object."
|
|
120
|
+
}),
|
|
121
|
+
side: Schema3.optional(Schema3.Literal("white", "black", "any")).annotations({
|
|
122
|
+
description: "The side to play.",
|
|
123
|
+
defaultValue: "any"
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
outputSchema: Schema3.Struct({
|
|
127
|
+
pgn: Schema3.String.annotations({
|
|
128
|
+
description: "The PGN of the game after the move was played."
|
|
129
|
+
}),
|
|
130
|
+
move: Schema3.optional(Schema3.String).annotations({
|
|
131
|
+
description: "The move that was played."
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
handler: Effect3.fn(function* ({ data: { id, side = "any" } }) {
|
|
135
|
+
const object = yield* Database3.Service.resolve(ArtifactId2.toDXN(id), Chess_exports.Game);
|
|
136
|
+
const chess = new ChessJS2();
|
|
137
|
+
if (object.pgn) {
|
|
138
|
+
chess.loadPgn(object.pgn);
|
|
139
|
+
} else if (object.fen) {
|
|
140
|
+
chess.load(object.fen);
|
|
141
|
+
}
|
|
142
|
+
if (!(side === "any" || chess.turn() === "w" && side === "white" || chess.turn() === "b" && side === "black")) {
|
|
143
|
+
return {
|
|
144
|
+
move: void 0,
|
|
145
|
+
pgn: object.pgn
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const moves = chess.moves();
|
|
149
|
+
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
150
|
+
chess.move(move, {
|
|
151
|
+
strict: false
|
|
152
|
+
});
|
|
153
|
+
const pgn = chess.pgn();
|
|
154
|
+
Obj2.change(object, (o) => {
|
|
155
|
+
o.pgn = pgn;
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
move,
|
|
159
|
+
pgn
|
|
160
|
+
};
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// src/blueprints/functions/print.ts
|
|
165
|
+
import { Chess as ChessJS3 } from "chess.js";
|
|
166
|
+
import * as Effect4 from "effect/Effect";
|
|
167
|
+
import * as Schema4 from "effect/Schema";
|
|
168
|
+
import { defineFunction as defineFunction4 } from "@dxos/functions";
|
|
169
|
+
var print_default = defineFunction4({
|
|
170
|
+
key: "dxos.org/function/chess/print",
|
|
171
|
+
name: "Print game",
|
|
172
|
+
description: "Prints the chess game to ASCII.",
|
|
173
|
+
inputSchema: Schema4.Struct({
|
|
174
|
+
pgn: Schema4.optional(Schema4.String.annotations({
|
|
175
|
+
description: "Portable Game Notation."
|
|
176
|
+
})),
|
|
177
|
+
fen: Schema4.optional(Schema4.String.annotations({
|
|
178
|
+
description: "Forsyth-Edwards Notation."
|
|
179
|
+
}))
|
|
180
|
+
}),
|
|
181
|
+
outputSchema: Schema4.Struct({
|
|
182
|
+
ascii: Schema4.String
|
|
183
|
+
}),
|
|
184
|
+
handler: Effect4.fn(function* ({ data: { pgn, fen } }) {
|
|
185
|
+
try {
|
|
186
|
+
const chess = new ChessJS3(fen);
|
|
187
|
+
if (pgn) {
|
|
188
|
+
chess.loadPgn(pgn);
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
ascii: chess.ascii()
|
|
192
|
+
};
|
|
193
|
+
} catch {
|
|
194
|
+
return {
|
|
195
|
+
ascii: ""
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/blueprints/chess-blueprint.ts
|
|
202
|
+
var Key = "dxos.org/blueprint/chess";
|
|
203
|
+
var functions = [
|
|
204
|
+
create_default,
|
|
205
|
+
move_default,
|
|
206
|
+
play_default,
|
|
207
|
+
print_default
|
|
208
|
+
];
|
|
209
|
+
var make = () => Blueprint.make({
|
|
210
|
+
key: Key,
|
|
211
|
+
name: "Chess",
|
|
212
|
+
tools: Blueprint.toolDefinitions({
|
|
213
|
+
functions
|
|
214
|
+
}),
|
|
215
|
+
instructions: Template.make({
|
|
216
|
+
source: trim`
|
|
217
|
+
You are an expert chess player.
|
|
218
|
+
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
219
|
+
You could suggest a good next move or offer to play a move.
|
|
220
|
+
Don't actually make a move unless you are asked to.
|
|
221
|
+
`
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
functions_exports,
|
|
227
|
+
chess_blueprint_exports
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=chunk-DH4WQRZH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
"mappings": "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",
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import { trim } from "@dxos/util";
|
|
3
|
+
var meta = {
|
|
4
|
+
id: "dxos.org/plugin/chess",
|
|
5
|
+
name: "Chess",
|
|
6
|
+
description: trim`
|
|
7
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
8
|
+
Track game history and analyze moves in real-time.
|
|
9
|
+
`,
|
|
10
|
+
icon: "ph--shield-chevron--regular",
|
|
11
|
+
iconHue: "amber",
|
|
12
|
+
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
13
|
+
screenshots: [
|
|
14
|
+
"https://dxos.network/plugin-details-chess-dark.png"
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
meta
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-H3NUMCQ6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: '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,OAAoB;EAC/BC,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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|