@dxos/plugin-chess 0.8.4-main.c1de068 → 0.8.4-main.c351d160a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/ChessArticle-UDSL3OJ4.mjs +59 -0
- package/dist/lib/browser/ChessArticle-UDSL3OJ4.mjs.map +7 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs +21 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +11 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-2TJN26DN.mjs +67 -0
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
- package/dist/lib/browser/chunk-6JG4KLVU.mjs +231 -0
- package/dist/lib/browser/chunk-6JG4KLVU.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-JP6G6VR6.mjs +276 -0
- package/dist/lib/browser/chunk-JP6G6VR6.mjs.map +7 -0
- package/dist/lib/browser/chunk-RGHZ5CDO.mjs +21 -0
- package/dist/lib/browser/chunk-RGHZ5CDO.mjs.map +7 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs +1 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +28 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +64 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs +50 -0
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -7
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs +60 -0
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs.map +7 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs +22 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.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-46DC6W7W.mjs +232 -0
- package/dist/lib/node-esm/chunk-46DC6W7W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs +2 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs +277 -0
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FYPVCMP4.mjs +23 -0
- package/dist/lib/node-esm/chunk-FYPVCMP4.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-OIRJVY2R.mjs +68 -0
- package/dist/lib/node-esm/chunk-OIRJVY2R.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 +64 -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-TIYEREGW.mjs +51 -0
- package/dist/lib/node-esm/react-surface-TIYEREGW.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 +4 -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 +56 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/move.d.ts +16 -0
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/play.d.ts +17 -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 +6 -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/Chessboard/Chessboard.d.ts +34 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Info.d.ts +21 -0
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +6 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +47 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +3 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +6 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts +15 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +3 -0
- package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- 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 +12 -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 +61 -34
- package/src/ChessPlugin.tsx +29 -52
- package/src/blueprints/chess-blueprint.ts +36 -0
- package/src/blueprints/functions/create.ts +38 -0
- package/src/blueprints/functions/index.ts +17 -0
- package/src/blueprints/functions/move.ts +48 -0
- package/src/blueprints/functions/play.ts +58 -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 +17 -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 +33 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +26 -0
- package/src/components/Chessboard/Chessboard.tsx +186 -0
- package/src/components/Chessboard/Info.tsx +246 -0
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +2 -6
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +53 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +72 -0
- package/src/containers/ChessArticle/index.ts +7 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +42 -0
- package/src/containers/ChessCard/ChessCard.tsx +22 -0
- package/src/containers/ChessCard/index.ts +7 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +3 -1
- package/src/meta.ts +9 -7
- package/src/translations.ts +12 -2
- package/src/types/Chess.ts +62 -0
- package/src/types/index.ts +1 -2
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs +0 -129
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A2FSM255.mjs +0 -182
- package/dist/lib/browser/artifact-definition-A2FSM255.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-KDADGLPC.mjs +0 -8
- package/dist/lib/browser/chunk-KDADGLPC.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZXH3N4NA.mjs +0 -66
- package/dist/lib/browser/chunk-ZXH3N4NA.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-PLUCWIYP.mjs +0 -36
- package/dist/lib/browser/react-surface-PLUCWIYP.mjs.map +0 -7
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs +0 -130
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs +0 -183
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-27D3JA3K.mjs +0 -68
- package/dist/lib/node-esm/chunk-27D3JA3K.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-QFINI7CC.mjs +0 -10
- package/dist/lib/node-esm/chunk-QFINI7CC.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-NGLNIWN3.mjs +0 -37
- package/dist/lib/node-esm/react-surface-NGLNIWN3.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/Chess.d.ts +0 -14
- package/dist/types/src/components/Chess.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/ChessContainer.stories.d.ts +0 -23
- package/dist/types/src/components/ChessContainer.stories.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/Chessboard.stories.d.ts +0 -8
- package/dist/types/src/components/Chessboard.stories.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 -23
- package/src/components/Chess.tsx +0 -60
- package/src/components/ChessContainer.stories.tsx +0 -110
- package/src/components/ChessContainer.tsx +0 -71
- package/src/components/ChessPanel.tsx +0 -67
- package/src/components/Chessboard.stories.tsx +0 -41
- package/src/components/PlayerSelector.tsx +0 -82
- package/src/types/schema.ts +0 -34
- package/src/types/types.ts +0 -20
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
meta
|
|
3
|
+
} from "./chunk-RGHZ5CDO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/Chessboard/Chessboard.tsx
|
|
6
|
+
import { RegistryContext } from "@effect-atom/atom-react";
|
|
7
|
+
import React2, { forwardRef, useCallback, useContext, useEffect as useEffect2, useImperativeHandle, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
8
|
+
import { addEventListener } from "@dxos/async";
|
|
9
|
+
import { useObject } from "@dxos/echo-react";
|
|
10
|
+
import { Gameboard, Chessboard as NaturalChessboard, getRawPgn, useGameboardContext as useGameboardContext2 } from "@dxos/react-ui-gameboard";
|
|
11
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
12
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
13
|
+
|
|
14
|
+
// src/components/Chessboard/Info.tsx
|
|
15
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
16
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
17
|
+
import { generateName } from "@dxos/display-name";
|
|
18
|
+
import { Obj } from "@dxos/echo";
|
|
19
|
+
import { useMembers } from "@dxos/react-client/echo";
|
|
20
|
+
import { Icon, IconButton, Select, useTranslation } from "@dxos/react-ui";
|
|
21
|
+
import { useGameboardContext } from "@dxos/react-ui-gameboard";
|
|
22
|
+
import { mx } from "@dxos/ui-theme";
|
|
23
|
+
var INFO_NAME = "Chessboard.Info";
|
|
24
|
+
var Info = ({ classNames, orientation = "white", onOrientationChange, onClose, ...props }) => {
|
|
25
|
+
const { t } = useTranslation(meta.id);
|
|
26
|
+
const { model } = useGameboardContext(INFO_NAME);
|
|
27
|
+
const db = Obj.getDatabase(model.object);
|
|
28
|
+
const members = useMembers(db?.spaceId);
|
|
29
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
30
|
+
className: mx("grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden bg-group-surface rounded-xs", classNames)
|
|
31
|
+
}, /* @__PURE__ */ React.createElement(PlayerIndicator, {
|
|
32
|
+
model,
|
|
33
|
+
player: orientation === "white" ? "black" : "white",
|
|
34
|
+
icon: onClose && /* @__PURE__ */ React.createElement(IconButton, {
|
|
35
|
+
icon: "ph--x--regular",
|
|
36
|
+
iconOnly: true,
|
|
37
|
+
label: t("close info button"),
|
|
38
|
+
size: 4,
|
|
39
|
+
onClick: onClose
|
|
40
|
+
})
|
|
41
|
+
}, /* @__PURE__ */ React.createElement(PlayerSelector, {
|
|
42
|
+
value: model.object.players?.[orientation === "white" ? "black" : "white"],
|
|
43
|
+
onValueChange: (value) => {
|
|
44
|
+
Obj.change(model.object, (obj) => {
|
|
45
|
+
obj.players[orientation === "white" ? "black" : "white"] = value;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
members
|
|
49
|
+
})), /* @__PURE__ */ React.createElement(History, {
|
|
50
|
+
model,
|
|
51
|
+
...props
|
|
52
|
+
}), /* @__PURE__ */ React.createElement(PlayerIndicator, {
|
|
53
|
+
model,
|
|
54
|
+
player: orientation,
|
|
55
|
+
icon: onOrientationChange && /* @__PURE__ */ React.createElement(IconButton, {
|
|
56
|
+
classNames: mx("transition duration-200 ease-linear", orientation === "white" && "rotate-180"),
|
|
57
|
+
icon: "ph--arrows-clockwise--regular",
|
|
58
|
+
iconOnly: true,
|
|
59
|
+
label: t("flip board button"),
|
|
60
|
+
size: 4,
|
|
61
|
+
onClick: () => onOrientationChange(orientation === "white" ? "black" : "white")
|
|
62
|
+
})
|
|
63
|
+
}, /* @__PURE__ */ React.createElement(PlayerSelector, {
|
|
64
|
+
value: model.object.players?.[orientation],
|
|
65
|
+
onValueChange: (value) => {
|
|
66
|
+
Obj.change(model.object, (obj) => {
|
|
67
|
+
obj.players[orientation] = value;
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
members
|
|
71
|
+
})));
|
|
72
|
+
};
|
|
73
|
+
Info.displayName = INFO_NAME;
|
|
74
|
+
var History = ({ classNames, model, min, max, onSelect }) => {
|
|
75
|
+
const { t } = useTranslation(meta.id);
|
|
76
|
+
const moveIndex = useAtomValue(model.moveIndex);
|
|
77
|
+
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;
|
|
78
|
+
const history = model.game.history();
|
|
79
|
+
const moves = useMemo(() => history.reduce((acc, move, index) => {
|
|
80
|
+
if (index % 2 === 0) {
|
|
81
|
+
acc.push([
|
|
82
|
+
{
|
|
83
|
+
index,
|
|
84
|
+
move
|
|
85
|
+
}
|
|
86
|
+
]);
|
|
87
|
+
} else {
|
|
88
|
+
acc[acc.length - 1].push({
|
|
89
|
+
index,
|
|
90
|
+
move
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return acc;
|
|
94
|
+
}, []), [
|
|
95
|
+
history.length
|
|
96
|
+
]);
|
|
97
|
+
const scrollerRef = useRef(null);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
scrollerRef.current?.scrollTo({
|
|
100
|
+
top: scrollerRef.current.scrollHeight
|
|
101
|
+
});
|
|
102
|
+
}, [
|
|
103
|
+
history.length
|
|
104
|
+
]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const div = scrollerRef.current?.querySelector(`[data-index="${moveIndex - 1}"]`);
|
|
107
|
+
scrollerRef.current?.classList.add("scrollbar-none");
|
|
108
|
+
div?.scrollIntoView({
|
|
109
|
+
behavior: "smooth"
|
|
110
|
+
});
|
|
111
|
+
scrollerRef.current?.classList.remove("scrollbar-none");
|
|
112
|
+
}, [
|
|
113
|
+
moveIndex
|
|
114
|
+
]);
|
|
115
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
116
|
+
ref: scrollerRef,
|
|
117
|
+
className: mx("overflow-y-auto", classNames),
|
|
118
|
+
style: {
|
|
119
|
+
minHeight: min === void 0 ? "auto" : `${min * 24}px`,
|
|
120
|
+
maxHeight: max === void 0 ? "auto" : `${max * 24}px`
|
|
121
|
+
}
|
|
122
|
+
}, moves.map(([a, b], index) => /* @__PURE__ */ React.createElement("div", {
|
|
123
|
+
key: index,
|
|
124
|
+
className: "grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4 leading-1"
|
|
125
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
126
|
+
className: "content-center text-xs text-subdued"
|
|
127
|
+
}, index + 1), a && /* @__PURE__ */ React.createElement("div", {
|
|
128
|
+
"data-index": a.index,
|
|
129
|
+
className: mx("ps-2 cursor-pointer", a.index === moveIndex - 1 && "bg-primary-500"),
|
|
130
|
+
onClick: () => onSelect?.(a.index + 1)
|
|
131
|
+
}, a.move), b && /* @__PURE__ */ React.createElement("div", {
|
|
132
|
+
"data-index": b.index,
|
|
133
|
+
className: mx("ps-2 cursor-pointer", b.index === moveIndex - 1 && "bg-primary-500"),
|
|
134
|
+
onClick: () => onSelect?.(b.index + 1)
|
|
135
|
+
}, b.move))), label && /* @__PURE__ */ React.createElement("div", {
|
|
136
|
+
className: "text-center"
|
|
137
|
+
}, label));
|
|
138
|
+
};
|
|
139
|
+
var PlayerIndicator = ({ children, model, player, icon }) => {
|
|
140
|
+
const turn = player === (model.game.turn() === "w" ? "white" : "black");
|
|
141
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
142
|
+
className: "grid grid-cols-[2rem_1fr_2rem] gap-2 h-(--dx-rail-size) px-1 flex items-center overflow-hidden"
|
|
143
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
144
|
+
className: "place-items-center"
|
|
145
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
146
|
+
icon: turn ? "ph--circle--fill" : "ph--circle--thin",
|
|
147
|
+
size: 6,
|
|
148
|
+
classNames: mx(turn && (model.game.isCheckmate() ? "text-error-500" : "text-success-text"))
|
|
149
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
150
|
+
className: "truncate overflow-hidden items-center"
|
|
151
|
+
}, children), icon);
|
|
152
|
+
};
|
|
153
|
+
var PlayerSelector = ({ value, onValueChange, members }) => {
|
|
154
|
+
const { t } = useTranslation(meta.id);
|
|
155
|
+
return /* @__PURE__ */ React.createElement(Select.Root, {
|
|
156
|
+
value,
|
|
157
|
+
onValueChange
|
|
158
|
+
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
159
|
+
placeholder: t("select player button")
|
|
160
|
+
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, members.map((member) => {
|
|
161
|
+
const memberKey = member.identity.identityKey.toHex();
|
|
162
|
+
const displayName = member.identity?.profile?.displayName || generateName(memberKey);
|
|
163
|
+
return /* @__PURE__ */ React.createElement(Select.Option, {
|
|
164
|
+
key: memberKey,
|
|
165
|
+
value: memberKey
|
|
166
|
+
}, displayName);
|
|
167
|
+
})), /* @__PURE__ */ React.createElement(Select.Arrow, null))));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/components/Chessboard/types.ts
|
|
171
|
+
import { ChessModel } from "@dxos/react-ui-gameboard";
|
|
172
|
+
var ExtendedChessModel = class extends ChessModel {
|
|
173
|
+
object;
|
|
174
|
+
constructor(registry, object) {
|
|
175
|
+
super(registry), this.object = object;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// src/components/Chessboard/Chessboard.tsx
|
|
180
|
+
var Root = /* @__PURE__ */ forwardRef(({ game, children }, forwardedRef) => {
|
|
181
|
+
const registry = useContext(RegistryContext);
|
|
182
|
+
const model = useMemo2(() => new ExtendedChessModel(registry, game), [
|
|
183
|
+
registry
|
|
184
|
+
]);
|
|
185
|
+
const click = useSoundEffect("Click");
|
|
186
|
+
const [pgn, updatePgn] = useObject(game, "pgn");
|
|
187
|
+
useImperativeHandle(forwardedRef, () => {
|
|
188
|
+
return {
|
|
189
|
+
setMoveNumber: (index) => model.setMoveIndex(index)
|
|
190
|
+
};
|
|
191
|
+
}, [
|
|
192
|
+
model
|
|
193
|
+
]);
|
|
194
|
+
useEffect2(() => {
|
|
195
|
+
if (model.pgn !== getRawPgn(pgn ?? "")) {
|
|
196
|
+
const silent = model.pgn === "*";
|
|
197
|
+
model.update(pgn);
|
|
198
|
+
if (!silent) {
|
|
199
|
+
void click.play();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, [
|
|
203
|
+
pgn
|
|
204
|
+
]);
|
|
205
|
+
const handleDrop = useCallback((move) => {
|
|
206
|
+
if (!model.makeMove(move)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
void click.play();
|
|
210
|
+
updatePgn(() => model.pgn);
|
|
211
|
+
return true;
|
|
212
|
+
}, [
|
|
213
|
+
model
|
|
214
|
+
]);
|
|
215
|
+
return /* @__PURE__ */ React2.createElement(Gameboard.Root, {
|
|
216
|
+
model,
|
|
217
|
+
onDrop: handleDrop
|
|
218
|
+
}, children);
|
|
219
|
+
});
|
|
220
|
+
var Content = ({ classNames, children, role }) => {
|
|
221
|
+
return /* @__PURE__ */ React2.createElement(Gameboard.Content, {
|
|
222
|
+
classNames: mx2(classNames, role === "card--content" ? "dx-size-container dx-card-square" : "flex flex-col justify-center")
|
|
223
|
+
}, children);
|
|
224
|
+
};
|
|
225
|
+
var BOARD_NAME = "Chessboard.Board";
|
|
226
|
+
var Board = (props) => {
|
|
227
|
+
const registry = useContext(RegistryContext);
|
|
228
|
+
const { model } = useGameboardContext2(BOARD_NAME);
|
|
229
|
+
const ref = useRef2(null);
|
|
230
|
+
useEffect2(() => {
|
|
231
|
+
if (!ref.current) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
ref.current.setAttribute("data-arrow-keys", "all");
|
|
235
|
+
return addEventListener(ref.current, "keydown", (ev) => {
|
|
236
|
+
const moveIndex = registry.get(model.moveIndex);
|
|
237
|
+
switch (ev.key) {
|
|
238
|
+
case "ArrowUp":
|
|
239
|
+
model.setMoveIndex(0);
|
|
240
|
+
break;
|
|
241
|
+
case "ArrowDown":
|
|
242
|
+
model.setMoveIndex(model.game.history().length);
|
|
243
|
+
break;
|
|
244
|
+
case "ArrowLeft":
|
|
245
|
+
if (moveIndex > 0) {
|
|
246
|
+
model.setMoveIndex(moveIndex - 1);
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
case "ArrowRight":
|
|
250
|
+
if (moveIndex < model.game.history().length) {
|
|
251
|
+
model.setMoveIndex(moveIndex + 1);
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}, [
|
|
257
|
+
registry,
|
|
258
|
+
model
|
|
259
|
+
]);
|
|
260
|
+
return /* @__PURE__ */ React2.createElement(NaturalChessboard, {
|
|
261
|
+
...props,
|
|
262
|
+
ref
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
Board.displayName = BOARD_NAME;
|
|
266
|
+
var Chessboard = {
|
|
267
|
+
Root,
|
|
268
|
+
Content,
|
|
269
|
+
Board,
|
|
270
|
+
Info
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
Chessboard
|
|
275
|
+
};
|
|
276
|
+
//# sourceMappingURL=chunk-JP6G6VR6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Chessboard/Chessboard.tsx", "../../../src/components/Chessboard/Info.tsx", "../../../src/components/Chessboard/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { useObject } from '@dxos/echo-react';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\nimport { useSoundEffect } from '@dxos/react-ui-sfx';\nimport { mx } from '@dxos/ui-theme';\n\nimport { type Chess } from '../../types';\n\nimport { Info, type InfoProps } from './Info';\nimport { ExtendedChessModel } from './types';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n game: Chess.Game;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(game, 'pgn');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // TODO(wittjosiah): Rather than useEffect to sync ECHO object to model, create an alternative model implementation.\n // This model would take the ECHO object and derive game state directly from that.\n // Mutation methods would mutate the ECHO object and other state would be derived from that.\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [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 updatePgn(() => 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--content';\n\ntype ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;\n\nconst Content = ({ classNames, children, role }: ContentProps) => {\n return (\n <Gameboard.Content\n classNames={mx(\n classNames,\n role === 'card--content' ? 'dx-size-container dx-card-square' : 'flex flex-col justify-center',\n )}\n >\n {children}\n </Gameboard.Content>\n );\n};\n\n//\n// Board\n//\n\nconst BOARD_NAME = 'Chessboard.Board';\n\ntype BoardProps = NaturalChessboardProps;\n\nconst Board = (props: BoardProps) => {\n const registry = useContext(RegistryContext);\n const { model } = useGameboardContext<ChessModel>(BOARD_NAME);\n\n // Keyboard navigation.\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n // Participate in keyboard navigation (set tabIndex={0})\n ref.current.setAttribute('data-arrow-keys', 'all');\n\n return addEventListener(ref.current, 'keydown', (ev) => {\n const moveIndex = registry.get(model.moveIndex);\n switch (ev.key) {\n case 'ArrowUp':\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (moveIndex > 0) {\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n });\n }, [registry, model]);\n\n return <NaturalChessboard {...props} ref={ref} />;\n};\n\nBoard.displayName = BOARD_NAME;\n\n//\n// Chessboard\n//\n\nexport const Chessboard = {\n Root: Root,\n Content: Content,\n Board: Board,\n Info: Info,\n};\n\nexport type {\n RootProps as ChessboardRootProps,\n ContentProps as ChessboardContentProps,\n BoardProps as ChessboardBoardProps,\n InfoProps as ChessboardInfoProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { Obj } from '@dxos/echo';\nimport { type SpaceMember, useMembers } from '@dxos/react-client/echo';\nimport { Icon, IconButton, Select, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '../../meta';\n\nimport { type ExtendedChessModel } from './types';\n\nconst INFO_NAME = 'Chessboard.Info';\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_NAME);\n const db = Obj.getDatabase(model.object);\n const members = useMembers(db?.spaceId);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden bg-group-surface rounded-xs',\n classNames,\n )}\n >\n <PlayerIndicator\n model={model}\n player={orientation === 'white' ? 'black' : 'white'}\n icon={\n onClose && (\n <IconButton icon='ph--x--regular' iconOnly label={t('close info button')} size={4} onClick={onClose} />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}\n onValueChange={(value) => {\n Obj.change(model.object, (obj) => {\n obj.players![orientation === 'white' ? 'black' : 'white'] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\n\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip board button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n >\n <PlayerSelector\n value={model.object.players?.[orientation]}\n onValueChange={(value) => {\n Obj.change(model.object, (obj) => {\n obj.players![orientation] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\n </div>\n );\n};\n\nInfo.displayName = INFO_NAME;\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.id);\n const moveIndex = useAtomValue(model.moveIndex);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate label')\n : model.game.isStalemate()\n ? t('game.stalemate label')\n : t('game.draw label')\n : model.game.isCheck()\n ? t('game.check label')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${moveIndex - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [moveIndex]);\n\n return (\n <div\n ref={scrollerRef}\n className={mx('overflow-y-auto', classNames)}\n style={{\n minHeight: min === undefined ? 'auto' : `${min * 24}px`,\n maxHeight: max === undefined ? 'auto' : `${max * 24}px`,\n }}\n >\n {moves.map(([a, b], index) => (\n <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-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('ps-2 cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(a.index + 1)}\n >\n {a.move}\n </div>\n )}\n {b && (\n <div\n data-index={b.index}\n className={mx('ps-2 cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(b.index + 1)}\n >\n {b.move}\n </div>\n )}\n </div>\n ))}\n {label && <div className='text-center'>{label}</div>}\n </div>\n );\n};\n\n//\n// PlayerIndicator\n//\n\ntype PlayerIndicatorProps = PropsWithChildren<{\n model: ExtendedChessModel;\n player: Player;\n icon?: JSX.Element;\n}>;\n\nconst PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {\n const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');\n return (\n <div className='grid grid-cols-[2rem_1fr_2rem] gap-2 h-(--dx-rail-size) px-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-error-500' : 'text-success-text'))}\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", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Registry } from '@effect-atom/atom-react';\n\nimport { ChessModel } from '@dxos/react-ui-gameboard';\n\nimport { type Chess } from '../../types';\n\nexport class ExtendedChessModel extends ChessModel {\n constructor(\n registry: Registry.Registry,\n readonly object: Chess.Game,\n ) {\n super(registry);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,uBAAuB;AAChC,OAAOC,UAELC,YACAC,aACAC,YACAC,aAAAA,YACAC,qBACAC,WAAAA,UACAC,UAAAA,eACK;AAEP,SAASC,wBAAwB;AACjC,SAASC,iBAAiB;AAE1B,SAEEC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;AACP,SAASC,sBAAsB;AAC/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,IAAK+B,qBAAgCH,UAAAA;AAGlD,QAAMI,MAAMC,QAAuB,IAAA;AACnCrB,EAAAA,WAAU,MAAA;AACR,QAAI,CAACoB,IAAIE,SAAS;AAChB;IACF;AAGAF,QAAIE,QAAQC,aAAa,mBAAmB,KAAA;AAE5C,WAAOC,iBAAiBJ,IAAIE,SAAS,WAAW,CAACG,OAAAA;AAC/C,YAAMC,YAAYzC,SAAS0C,IAAIvC,MAAMsC,SAAS;AAC9C,cAAQD,GAAGG,KAAG;QACZ,KAAK;AACHxC,gBAAMW,aAAa,CAAA;AACnB;QACF,KAAK;AACHX,gBAAMW,aAAaX,MAAMN,KAAK+C,QAAO,EAAGC,MAAM;AAC9C;QACF,KAAK;AACH,cAAIJ,YAAY,GAAG;AACjBtC,kBAAMW,aAAa2B,YAAY,CAAA;UACjC;AACA;QACF,KAAK;AACH,cAAIA,YAAYtC,MAAMN,KAAK+C,QAAO,EAAGC,QAAQ;AAC3C1C,kBAAMW,aAAa2B,YAAY,CAAA;UACjC;AACA;MACJ;IACF,CAAA;EACF,GAAG;IAACzC;IAAUG;GAAM;AAEpB,SAAO,gBAAAqB,OAAA,cAACsB,mBAAAA;IAAmB,GAAGb;IAAOE;;AACvC;AAEAH,MAAMe,cAAchB;AAMb,IAAMiB,aAAa;EACxBrD;EACAgC;EACAK;EACAiB;AACF;",
|
|
6
|
+
"names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "useObject", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useSoundEffect", "mx", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "generateName", "Obj", "useMembers", "Icon", "IconButton", "Select", "useTranslation", "useGameboardContext", "mx", "INFO_NAME", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "useTranslation", "meta", "id", "model", "useGameboardContext", "db", "Obj", "getDatabase", "object", "members", "useMembers", "spaceId", "div", "className", "mx", "PlayerIndicator", "player", "icon", "IconButton", "iconOnly", "label", "size", "onClick", "PlayerSelector", "value", "players", "onValueChange", "change", "obj", "History", "displayName", "min", "max", "onSelect", "moveIndex", "useAtomValue", "game", "isGameOver", "isCheckmate", "isStalemate", "isCheck", "undefined", "history", "moves", "useMemo", "reduce", "acc", "move", "index", "push", "length", "scrollerRef", "useRef", "useEffect", "current", "scrollTo", "top", "scrollHeight", "querySelector", "classList", "add", "scrollIntoView", "behavior", "remove", "ref", "style", "minHeight", "maxHeight", "map", "a", "b", "key", "data-index", "children", "turn", "Icon", "Select", "Root", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "member", "memberKey", "identity", "identityKey", "toHex", "profile", "generateName", "Option", "Arrow", "ChessModel", "ExtendedChessModel", "ChessModel", "registry", "object", "Root", "forwardRef", "game", "children", "forwardedRef", "registry", "useContext", "RegistryContext", "model", "useMemo", "ExtendedChessModel", "click", "useSoundEffect", "pgn", "updatePgn", "useObject", "useImperativeHandle", "setMoveNumber", "index", "setMoveIndex", "useEffect", "getRawPgn", "silent", "update", "play", "handleDrop", "useCallback", "move", "makeMove", "React", "Gameboard", "onDrop", "Content", "classNames", "role", "mx", "BOARD_NAME", "Board", "props", "useGameboardContext", "ref", "useRef", "current", "setAttribute", "addEventListener", "ev", "moveIndex", "get", "key", "history", "length", "NaturalChessboard", "displayName", "Chessboard", "Info"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import { trim } from "@dxos/util";
|
|
3
|
+
var meta = {
|
|
4
|
+
id: "org.dxos.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-RGHZ5CDO.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: 'org.dxos.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 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-WYUTI2K4.mjs.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Chess_exports
|
|
3
|
+
} from "../chunk-2TJN26DN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
meta
|
|
6
|
+
} from "../chunk-RGHZ5CDO.mjs";
|
|
7
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
8
|
+
|
|
9
|
+
// src/cli/plugin.ts
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import { Plugin } from "@dxos/app-framework";
|
|
12
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
13
|
+
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addMetadataModule({
|
|
14
|
+
metadata: {
|
|
15
|
+
id: Chess_exports.Game.typename,
|
|
16
|
+
metadata: {
|
|
17
|
+
createObject: (props) => Effect.sync(() => Chess_exports.make(props))
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}), AppPlugin.addSchemaModule({
|
|
21
|
+
schema: [
|
|
22
|
+
Chess_exports.Game
|
|
23
|
+
]
|
|
24
|
+
}), Plugin.make);
|
|
25
|
+
export {
|
|
26
|
+
ChessPlugin
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/plugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { meta } from '../meta';\nimport { Chess } from '../types';\n\n// TODO(wittjosiah): Factor out shared modules.\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n Plugin.make,\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAOnB,IAAMC,cAAcC,OAAOC,OAAOC,IAAAA,EAAMC,KAC7CC,UAAUC,kBAAkB;EAC1BC,UAAU;IACRC,IAAIC,cAAMC,KAAKC;IACfJ,UAAU;MACRK,cAAe,CAACC,UAAiBC,YAAK,MAAML,cAAMM,KAAKF,KAAAA,CAAAA;IACzD;EACF;AACF,CAAA,GACAR,UAAUW,gBAAgB;EAAEC,QAAQ;IAACR,cAAMC;;AAAM,CAAA,GACjDT,OAAOc,IAAI;",
|
|
6
|
+
"names": ["Effect", "Plugin", "AppPlugin", "ChessPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addMetadataModule", "metadata", "id", "Chess", "Game", "typename", "createObject", "props", "sync", "make", "addSchemaModule", "schema"]
|
|
7
|
+
}
|
|
@@ -1,97 +1,95 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
chess_blueprint_default,
|
|
3
|
+
functions_exports
|
|
4
|
+
} from "./chunk-6JG4KLVU.mjs";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
Chessboard
|
|
7
|
+
} from "./chunk-JP6G6VR6.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Chess_exports
|
|
10
|
+
} from "./chunk-2TJN26DN.mjs";
|
|
10
11
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
meta
|
|
13
|
+
} from "./chunk-RGHZ5CDO.mjs";
|
|
14
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
15
|
+
|
|
16
|
+
// src/capabilities/blueprint-definition/index.ts
|
|
17
|
+
import { Capability } from "@dxos/app-framework";
|
|
18
|
+
var BlueprintDefinition = Capability.lazy("BlueprintDefinition", () => import("./blueprint-definition-OSNXLHYU.mjs"));
|
|
13
19
|
|
|
14
|
-
// src/capabilities/index.ts
|
|
15
|
-
import {
|
|
16
|
-
var
|
|
17
|
-
var IntentResolver = lazy(() => import("./intent-resolver-KQYYX44R.mjs"));
|
|
18
|
-
var ReactSurface = lazy(() => import("./react-surface-PLUCWIYP.mjs"));
|
|
20
|
+
// src/capabilities/react-surface/index.ts
|
|
21
|
+
import { Capability as Capability2 } from "@dxos/app-framework";
|
|
22
|
+
var ReactSurface = Capability2.lazy("ReactSurface", () => import("./react-surface-WD7BYDFB.mjs"));
|
|
19
23
|
|
|
20
24
|
// src/ChessPlugin.tsx
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
+
import * as Effect from "effect/Effect";
|
|
26
|
+
import * as Option from "effect/Option";
|
|
27
|
+
import { Plugin } from "@dxos/app-framework";
|
|
28
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
29
|
+
import { Annotation } from "@dxos/echo";
|
|
25
30
|
|
|
26
31
|
// src/translations.ts
|
|
27
32
|
var translations = [
|
|
28
33
|
{
|
|
29
34
|
"en-US": {
|
|
30
|
-
[
|
|
35
|
+
[Chess_exports.Game.typename]: {
|
|
31
36
|
"typename label": "Game",
|
|
32
37
|
"typename label_zero": "Games",
|
|
33
38
|
"typename label_one": "Game",
|
|
34
39
|
"typename label_other": "Games",
|
|
35
40
|
"object name placeholder": "New game",
|
|
41
|
+
"add object label": "Add game",
|
|
36
42
|
"rename object label": "Rename game",
|
|
37
|
-
"delete object label": "Delete game"
|
|
43
|
+
"delete object label": "Delete game",
|
|
44
|
+
"object deleted label": "Game deleted"
|
|
38
45
|
},
|
|
39
46
|
[meta.id]: {
|
|
40
47
|
"plugin name": "Chess",
|
|
41
|
-
"delete game label": "Delete"
|
|
48
|
+
"delete game label": "Delete",
|
|
49
|
+
"game.checkmate label": "Checkmate",
|
|
50
|
+
"game.stalemate label": "Stalemate",
|
|
51
|
+
"game.draw label": "Draw",
|
|
52
|
+
"game.check label": "Check",
|
|
53
|
+
"select player button": "Select player",
|
|
54
|
+
"toggle info button": "Toggle info",
|
|
55
|
+
"close info button": "Close info",
|
|
56
|
+
"flip board button": "Flip board"
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
60
|
];
|
|
46
61
|
|
|
47
62
|
// src/ChessPlugin.tsx
|
|
48
|
-
var ChessPlugin = ()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}),
|
|
72
|
-
defineModule({
|
|
73
|
-
id: `${meta.id}/module/react-surface`,
|
|
74
|
-
activatesOn: Events.SetupReactSurface,
|
|
75
|
-
activate: ReactSurface
|
|
76
|
-
}),
|
|
77
|
-
defineModule({
|
|
78
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
79
|
-
activatesOn: Events.SetupIntentResolver,
|
|
80
|
-
activate: IntentResolver
|
|
81
|
-
}),
|
|
82
|
-
defineModule({
|
|
83
|
-
id: `${meta.id}/module/artifact-definition`,
|
|
84
|
-
activatesOn: Events.SetupArtifactDefinition,
|
|
85
|
-
activate: ArtifactDefinition
|
|
86
|
-
})
|
|
87
|
-
]);
|
|
63
|
+
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addBlueprintDefinitionModule({
|
|
64
|
+
activate: BlueprintDefinition
|
|
65
|
+
}), AppPlugin.addMetadataModule({
|
|
66
|
+
metadata: {
|
|
67
|
+
id: Chess_exports.Game.typename,
|
|
68
|
+
metadata: {
|
|
69
|
+
icon: Annotation.IconAnnotation.get(Chess_exports.Game).pipe(Option.getOrThrow).icon,
|
|
70
|
+
iconHue: Annotation.IconAnnotation.get(Chess_exports.Game).pipe(Option.getOrThrow).hue ?? "white",
|
|
71
|
+
blueprints: [
|
|
72
|
+
chess_blueprint_default.key
|
|
73
|
+
],
|
|
74
|
+
createObject: (props) => Effect.sync(() => Chess_exports.make(props))
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}), AppPlugin.addSchemaModule({
|
|
78
|
+
schema: [
|
|
79
|
+
Chess_exports.Game
|
|
80
|
+
]
|
|
81
|
+
}), AppPlugin.addSurfaceModule({
|
|
82
|
+
activate: ReactSurface
|
|
83
|
+
}), AppPlugin.addTranslationsModule({
|
|
84
|
+
translations
|
|
85
|
+
}), Plugin.make);
|
|
88
86
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
BlueprintDefinition,
|
|
88
|
+
Chess_exports as Chess,
|
|
89
|
+
chess_blueprint_default as ChessBlueprint,
|
|
90
|
+
functions_exports as ChessFunctions,
|
|
93
91
|
ChessPlugin,
|
|
94
|
-
|
|
92
|
+
Chessboard,
|
|
95
93
|
ReactSurface,
|
|
96
94
|
meta
|
|
97
95
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/index.ts", "../../../src/ChessPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/capabilities/blueprint-definition/index.ts", "../../../src/capabilities/react-surface/index.ts", "../../../src/ChessPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const BlueprintDefinition = Capability.lazy('BlueprintDefinition', () => import('./blueprint-definition'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Option from 'effect/Option';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Annotation } from '@dxos/echo';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { ChessBlueprint } from './blueprints';\nimport { BlueprintDefinition, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { Chess } from './types';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n icon: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).icon,\n iconHue: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).hue ?? 'white',\n blueprints: [ChessBlueprint.key],\n createObject: ((props) => Effect.sync(() => Chess.make(props))) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\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 'add object label': 'Add game',\n 'rename object label': 'Rename game',\n 'delete object label': 'Delete game',\n 'object deleted label': 'Game deleted',\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
|
+
"mappings": ";;;;;;;;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CAAA,GACjDR,UAAU0B,iBAAiB;EAAExB,UAAUyB;AAAa,CAAA,GACpD3B,UAAU4B,sBAAsB;EAAEC;AAAa,CAAA,GAC/CjC,OAAO2B,IAAI;",
|
|
6
|
+
"names": ["Capability", "BlueprintDefinition", "Capability", "lazy", "Capability", "ReactSurface", "Capability", "lazy", "Effect", "Option", "Plugin", "AppPlugin", "Annotation", "translations", "Chess", "Game", "typename", "meta", "id", "ChessPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addBlueprintDefinitionModule", "activate", "BlueprintDefinition", "addMetadataModule", "metadata", "id", "Chess", "Game", "typename", "icon", "Annotation", "IconAnnotation", "get", "getOrThrow", "iconHue", "hue", "blueprints", "ChessBlueprint", "key", "createObject", "props", "sync", "make", "addSchemaModule", "schema", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations"]
|
|
7
7
|
}
|