@dxos/plugin-chess 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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/blueprints/index.mjs +14 -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-GPFHUDFY.mjs +110 -0
- package/dist/lib/browser/chunk-GPFHUDFY.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-JKW2ZYHP.mjs +28 -0
- package/dist/lib/browser/chunk-JKW2ZYHP.mjs.map +7 -0
- package/dist/lib/browser/chunk-MC7L6JNC.mjs +36 -0
- package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +34 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/create-UJ656WLM.mjs +24 -0
- package/dist/lib/browser/create-UJ656WLM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +367 -76
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/move-QCJSXFHW.mjs +36 -0
- package/dist/lib/browser/move-QCJSXFHW.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +19 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/play-YEOTE6KO.mjs +45 -0
- package/dist/lib/browser/play-YEOTE6KO.mjs.map +7 -0
- package/dist/lib/browser/print-LUCG4CIR.mjs +30 -0
- package/dist/lib/browser/print-LUCG4CIR.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -7
- package/dist/lib/node-esm/blueprints/index.mjs +15 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs +38 -0
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D72ZBXX6.mjs +29 -0
- package/dist/lib/node-esm/chunk-D72ZBXX6.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-LPVPGURE.mjs +111 -0
- package/dist/lib/node-esm/chunk-LPVPGURE.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 +35 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-KINGWZOM.mjs +25 -0
- package/dist/lib/node-esm/create-KINGWZOM.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +367 -76
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/move-JDR3KQ5G.mjs +37 -0
- package/dist/lib/node-esm/move-JDR3KQ5G.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +20 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/play-KIWAE5LA.mjs +46 -0
- package/dist/lib/node-esm/play-KIWAE5LA.mjs.map +7 -0
- package/dist/lib/node-esm/print-QHFZDMWC.mjs +31 -0
- package/dist/lib/node-esm/print-QHFZDMWC.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/index.d.ts +3 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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/Chessboard.stories.d.ts +48 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.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 -2
- 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/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +51 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/move.d.ts +5 -0
- package/dist/types/src/operations/move.d.ts.map +1 -0
- package/dist/types/src/operations/play.d.ts +5 -0
- package/dist/types/src/operations/play.d.ts.map +1 -0
- package/dist/types/src/operations/print.d.ts +5 -0
- package/dist/types/src/operations/print.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +22 -12
- 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 +76 -34
- package/src/ChessPlugin.tsx +42 -53
- package/src/blueprints/chess-blueprint.ts +35 -0
- package/src/blueprints/index.ts +6 -0
- package/src/capabilities/artifact-definition.ts +107 -96
- package/src/capabilities/blueprint-definition.ts +17 -0
- package/src/capabilities/index.ts +8 -4
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/react-surface.tsx +24 -14
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +37 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/Chessboard/Chessboard.tsx +180 -0
- package/src/components/Chessboard/Info.tsx +253 -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 +73 -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 -2
- package/src/meta.ts +9 -7
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +109 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/move.ts +37 -0
- package/src/operations/play.ts +46 -0
- package/src/operations/print.ts +28 -0
- package/src/translations.ts +22 -12
- 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/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.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/intent-resolver.ts +0 -26
- 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
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { type PropsWithChildren } from 'react';
|
|
2
|
-
import { type ChessType } from '../types';
|
|
3
|
-
export declare const Chess: {
|
|
4
|
-
Root: ({ game, children }: PropsWithChildren<{
|
|
5
|
-
game: ChessType;
|
|
6
|
-
}>) => React.JSX.Element | null;
|
|
7
|
-
Content: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<{
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
}>, "className"> & {
|
|
10
|
-
classNames?: import("@dxos/react-ui-types").ClassNameValue;
|
|
11
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
-
Board: React.MemoExoticComponent<({ orientation, showLabels, debug, rows, cols, classNames }: import("@dxos/react-ui-gameboard").ChessboardProps) => React.JSX.Element>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=Chess.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chess.d.ts","sourceRoot":"","sources":["../../../../src/components/Chess.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAMvF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AA4C1C,eAAO,MAAM,KAAK;+BA1CqB,iBAAiB,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;;;;;;;CA8C5E,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ChessType } from '../types';
|
|
3
|
-
declare const ChessContainer: ({ game, role }: {
|
|
4
|
-
game: ChessType;
|
|
5
|
-
role?: string;
|
|
6
|
-
}) => React.JSX.Element | null;
|
|
7
|
-
export default ChessContainer;
|
|
8
|
-
//# sourceMappingURL=ChessContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,cAAc,GAAI,gBAAgB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,6BAqDzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type Meta } from '@storybook/react-vite';
|
|
3
|
-
type StoryProps = {
|
|
4
|
-
role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
|
|
5
|
-
};
|
|
6
|
-
declare const meta: Meta<StoryProps>;
|
|
7
|
-
export default meta;
|
|
8
|
-
export declare const Popover: {
|
|
9
|
-
args: {
|
|
10
|
-
role: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare const Intrinsic: {
|
|
14
|
-
args: {
|
|
15
|
-
role: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare const Extrinsic: {
|
|
19
|
-
args: {
|
|
20
|
-
role: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=ChessContainer.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessContainer.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessContainer.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAmBlD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;CAC/D,CAAC;AA2BF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CAmC1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Color } from 'chess.js';
|
|
2
|
-
import { type FC } from 'react';
|
|
3
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
-
import { type ChessModel } from '@dxos/react-ui-gameboard';
|
|
5
|
-
export type ChessPanelProps = ThemedClassName<{
|
|
6
|
-
model: ChessModel;
|
|
7
|
-
orientation?: Color;
|
|
8
|
-
onFlip?: () => void;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const ChessPanel: FC<ChessPanelProps>;
|
|
11
|
-
//# sourceMappingURL=ChessPanel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,eAAe,EAAQ,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;IAC5C,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAiD1C,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { Chessboard } from '@dxos/react-ui-gameboard';
|
|
4
|
-
declare const meta: Meta<typeof Chessboard>;
|
|
5
|
-
type Story = StoryObj<typeof Chessboard>;
|
|
6
|
-
export default meta;
|
|
7
|
-
export declare const Default: Story;
|
|
8
|
-
//# sourceMappingURL=Chessboard.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chessboard.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Chessboard.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAa,UAAU,EAAc,MAAM,0BAA0B,CAAC;AAoB7E,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAKjC,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AAEzC,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
3
|
-
import { type ChessType } from '../types';
|
|
4
|
-
export declare const PlayerSelector: ({ space, game }: {
|
|
5
|
-
space: Space;
|
|
6
|
-
game: ChessType;
|
|
7
|
-
}) => React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=PlayerSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlayerSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/PlayerSelector.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAc,KAAK,KAAK,EAAoB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,cAAc,GAAI,iBAAiB;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,sBAuBhF,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { Type } from '@dxos/echo';
|
|
3
|
-
export declare const MoveSchema: Schema.mutable<Schema.SchemaClass<{
|
|
4
|
-
readonly source?: string | undefined;
|
|
5
|
-
readonly target?: string | undefined;
|
|
6
|
-
readonly piece?: string | undefined;
|
|
7
|
-
}, {
|
|
8
|
-
readonly source?: string | undefined;
|
|
9
|
-
readonly target?: string | undefined;
|
|
10
|
-
readonly piece?: string | undefined;
|
|
11
|
-
}, never>>;
|
|
12
|
-
export declare const ChessType: Type.obj<Schema.SchemaClass<{
|
|
13
|
-
readonly name?: string | undefined;
|
|
14
|
-
readonly playerWhite?: string | undefined;
|
|
15
|
-
readonly playerBlack?: string | undefined;
|
|
16
|
-
readonly moves?: string[] | undefined;
|
|
17
|
-
readonly pgn?: string | undefined;
|
|
18
|
-
readonly fen?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
readonly playerWhite?: string | undefined;
|
|
21
|
-
readonly playerBlack?: string | undefined;
|
|
22
|
-
readonly moves?: string[] | undefined;
|
|
23
|
-
readonly pgn?: string | undefined;
|
|
24
|
-
readonly fen?: string | undefined;
|
|
25
|
-
readonly name?: string | undefined;
|
|
26
|
-
}, never>>;
|
|
27
|
-
export interface ChessType extends Schema.Schema.Type<typeof ChessType> {
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,eAAO,MAAM,UAAU;;;;;;;;UAQtB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;UAcrB,CAAC;AACF,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC;CAAG"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
export declare namespace ChessAction {
|
|
3
|
-
const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
|
|
4
|
-
readonly _tag: Schema.tag<`${string}/action/create`>;
|
|
5
|
-
} & {
|
|
6
|
-
input: Schema.Struct<{
|
|
7
|
-
name: Schema.optional<typeof Schema.String>;
|
|
8
|
-
fen: Schema.optional<typeof Schema.String>;
|
|
9
|
-
}>;
|
|
10
|
-
output: Schema.Struct<{
|
|
11
|
-
object: import("@dxos/echo/Type").obj<Schema.SchemaClass<{
|
|
12
|
-
readonly name?: string | undefined;
|
|
13
|
-
readonly playerWhite?: string | undefined;
|
|
14
|
-
readonly playerBlack?: string | undefined;
|
|
15
|
-
readonly moves?: string[] | undefined;
|
|
16
|
-
readonly pgn?: string | undefined;
|
|
17
|
-
readonly fen?: string | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
readonly playerWhite?: string | undefined;
|
|
20
|
-
readonly playerBlack?: string | undefined;
|
|
21
|
-
readonly moves?: string[] | undefined;
|
|
22
|
-
readonly pgn?: string | undefined;
|
|
23
|
-
readonly fen?: string | undefined;
|
|
24
|
-
readonly name?: string | undefined;
|
|
25
|
-
}, never>>;
|
|
26
|
-
}>;
|
|
27
|
-
}>;
|
|
28
|
-
export class Create extends Create_base {
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,yBAAiB,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;IAC3B,MAAM,OAAO,MAAO,SAAQ,WAQ1B;KAAG;;CACN"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess } from 'chess.js';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
|
|
10
|
-
import { ChessAction, ChessType } from '../types';
|
|
11
|
-
|
|
12
|
-
export default () =>
|
|
13
|
-
contributes(
|
|
14
|
-
Capabilities.IntentResolver,
|
|
15
|
-
createResolver({
|
|
16
|
-
intent: ChessAction.Create,
|
|
17
|
-
resolve: ({ name, fen }) => {
|
|
18
|
-
const pgn = fen ? new Chess(fen).pgn() : undefined;
|
|
19
|
-
return {
|
|
20
|
-
data: {
|
|
21
|
-
object: Obj.make(ChessType, { name, fen, pgn }),
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
);
|
package/src/components/Chess.tsx
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
-
import React, { type PropsWithChildren, useCallback, useEffect, useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { log } from '@dxos/log';
|
|
9
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
-
import { ChessModel, Gameboard, Chessboard, type GameboardRootProps } from '@dxos/react-ui-gameboard';
|
|
11
|
-
|
|
12
|
-
import { type ChessType } from '../types';
|
|
13
|
-
|
|
14
|
-
const ChessRoot = ({ game, children }: PropsWithChildren<{ game: ChessType }>) => {
|
|
15
|
-
const model = useMemo(() => new ChessModel(), []);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!model || game.pgn !== model?.game.pgn()) {
|
|
18
|
-
const chess = new ChessJS();
|
|
19
|
-
if (game.pgn) {
|
|
20
|
-
try {
|
|
21
|
-
chess.loadPgn(game.pgn);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
log.catch(err, { game });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
model.initialize(chess.fen());
|
|
28
|
-
}
|
|
29
|
-
}, [game.pgn]);
|
|
30
|
-
|
|
31
|
-
const space = getSpace(game);
|
|
32
|
-
if (!space) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const handleDrop = useCallback<NonNullable<GameboardRootProps['onDrop']>>(
|
|
37
|
-
(move) => {
|
|
38
|
-
if (model.makeMove(move)) {
|
|
39
|
-
game.pgn = model.game.pgn();
|
|
40
|
-
game.fen = model.game.fen();
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false;
|
|
45
|
-
},
|
|
46
|
-
[model],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Gameboard.Root model={model} onDrop={handleDrop}>
|
|
51
|
-
{children}
|
|
52
|
-
</Gameboard.Root>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Chess = {
|
|
57
|
-
Root: ChessRoot,
|
|
58
|
-
Content: Gameboard.Content,
|
|
59
|
-
Board: Chessboard,
|
|
60
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
8
|
-
import React, { useEffect, useState } from 'react';
|
|
9
|
-
|
|
10
|
-
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
11
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import { Filter, Obj } from '@dxos/echo';
|
|
13
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
14
|
-
import { SpacePlugin } from '@dxos/plugin-space';
|
|
15
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
16
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
17
|
-
import { useClient } from '@dxos/react-client';
|
|
18
|
-
import { useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
19
|
-
import { CardContainer } from '@dxos/react-ui-stack/testing';
|
|
20
|
-
import { defaultTx } from '@dxos/react-ui-theme';
|
|
21
|
-
import { withLayout } from '@dxos/storybook-utils';
|
|
22
|
-
|
|
23
|
-
import ChessContainer from './ChessContainer';
|
|
24
|
-
import { ChessType } from '../types';
|
|
25
|
-
|
|
26
|
-
type StoryProps = {
|
|
27
|
-
role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const render: Meta<StoryProps>['render'] = ({ role }) => {
|
|
31
|
-
const _client = useClient();
|
|
32
|
-
const spaces = useSpaces();
|
|
33
|
-
const space = spaces[spaces.length - 1];
|
|
34
|
-
const games = useQuery(space, Filter.type(ChessType));
|
|
35
|
-
const [game, setGame] = useState<ChessType>();
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (games.length && !game) {
|
|
39
|
-
const board = games[0];
|
|
40
|
-
setGame(board);
|
|
41
|
-
}
|
|
42
|
-
}, [games]);
|
|
43
|
-
|
|
44
|
-
if (!game) {
|
|
45
|
-
return <span>…</span>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<CardContainer icon='ph--castle-turret--regular' role={role}>
|
|
50
|
-
<ChessContainer game={game} role={role} />
|
|
51
|
-
</CardContainer>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const meta: Meta<StoryProps> = {
|
|
56
|
-
title: 'Cards/plugin-chess',
|
|
57
|
-
render,
|
|
58
|
-
decorators: [
|
|
59
|
-
withLayout(),
|
|
60
|
-
withPluginManager({
|
|
61
|
-
plugins: [
|
|
62
|
-
ThemePlugin({ tx: defaultTx }),
|
|
63
|
-
ClientPlugin({
|
|
64
|
-
types: [ChessType],
|
|
65
|
-
onClientInitialized: async (_, client) => {
|
|
66
|
-
await client.halo.createIdentity();
|
|
67
|
-
const space = await client.spaces.create();
|
|
68
|
-
await space.waitUntilReady();
|
|
69
|
-
const game = Obj.make(ChessType, {
|
|
70
|
-
name: 'Example Chess Game',
|
|
71
|
-
playerWhite: 'Player 1',
|
|
72
|
-
playerBlack: 'Player 2',
|
|
73
|
-
moves: [],
|
|
74
|
-
pgn: '',
|
|
75
|
-
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', // Starting position
|
|
76
|
-
});
|
|
77
|
-
space.db.add(game);
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
StorybookLayoutPlugin(),
|
|
81
|
-
SpacePlugin(),
|
|
82
|
-
IntentPlugin(),
|
|
83
|
-
SettingsPlugin(),
|
|
84
|
-
],
|
|
85
|
-
}),
|
|
86
|
-
],
|
|
87
|
-
parameters: {
|
|
88
|
-
layout: 'centered',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default meta;
|
|
93
|
-
|
|
94
|
-
export const Popover = {
|
|
95
|
-
args: {
|
|
96
|
-
role: 'card--popover',
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const Intrinsic = {
|
|
101
|
-
args: {
|
|
102
|
-
role: 'card--intrinsic',
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const Extrinsic = {
|
|
107
|
-
args: {
|
|
108
|
-
role: 'card--extrinsic',
|
|
109
|
-
},
|
|
110
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
8
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
|
-
|
|
10
|
-
import { Chess } from './Chess';
|
|
11
|
-
import { PlayerSelector } from './PlayerSelector';
|
|
12
|
-
import { type ChessType } from '../types';
|
|
13
|
-
|
|
14
|
-
const containFragment = 'is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]';
|
|
15
|
-
|
|
16
|
-
const ChessContainer = ({ game, role }: { game: ChessType; role?: string }) => {
|
|
17
|
-
const space = getSpace(game);
|
|
18
|
-
|
|
19
|
-
if (!space) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
switch (role) {
|
|
24
|
-
case 'card--popover': {
|
|
25
|
-
return (
|
|
26
|
-
<Chess.Root game={game}>
|
|
27
|
-
<div role='none' className='popover-square size-container'>
|
|
28
|
-
<Chess.Board classNames={containFragment} />
|
|
29
|
-
</div>
|
|
30
|
-
</Chess.Root>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
case 'card--extrinsic': {
|
|
34
|
-
return (
|
|
35
|
-
<Chess.Root game={game}>
|
|
36
|
-
<div role='none' className='grid is-full bs-full size-container place-content-center'>
|
|
37
|
-
<Chess.Board classNames={containFragment} />
|
|
38
|
-
</div>
|
|
39
|
-
</Chess.Root>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
case 'card--intrinsic': {
|
|
43
|
-
return (
|
|
44
|
-
<Chess.Root game={game}>
|
|
45
|
-
<Chess.Board />
|
|
46
|
-
</Chess.Root>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
default: {
|
|
50
|
-
return (
|
|
51
|
-
<StackItem.Content>
|
|
52
|
-
<div role='none' className='grid grid-rows-[60px_1fr_60px] grow overflow-hidden'>
|
|
53
|
-
<div />
|
|
54
|
-
|
|
55
|
-
<div className='flex m-4 overflow-hidden'>
|
|
56
|
-
<Chess.Root game={game}>
|
|
57
|
-
<Chess.Content>
|
|
58
|
-
<Chess.Board />
|
|
59
|
-
</Chess.Content>
|
|
60
|
-
</Chess.Root>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<PlayerSelector space={space} game={game} />
|
|
64
|
-
</div>
|
|
65
|
-
</StackItem.Content>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default ChessContainer;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Color } from 'chess.js';
|
|
6
|
-
import React, { type FC } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type ThemedClassName, Icon } from '@dxos/react-ui';
|
|
9
|
-
import { type ChessModel } from '@dxos/react-ui-gameboard';
|
|
10
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
11
|
-
|
|
12
|
-
export type ChessPanelProps = ThemedClassName<{
|
|
13
|
-
model: ChessModel;
|
|
14
|
-
orientation?: Color;
|
|
15
|
-
onFlip?: () => void;
|
|
16
|
-
}>;
|
|
17
|
-
|
|
18
|
-
export const ChessPanel: FC<ChessPanelProps> = ({ classNames, model, orientation = 'w', onFlip }) => {
|
|
19
|
-
const game = model.game;
|
|
20
|
-
const history = game.history();
|
|
21
|
-
const label = game.isGameOver()
|
|
22
|
-
? game.isCheckmate()
|
|
23
|
-
? 'CHECKMATE'
|
|
24
|
-
: game.isStalemate()
|
|
25
|
-
? 'STALEMATE'
|
|
26
|
-
: 'DRAW'
|
|
27
|
-
: game.isCheck()
|
|
28
|
-
? 'CHECK'
|
|
29
|
-
: history.length
|
|
30
|
-
? `Move ${history.length}`
|
|
31
|
-
: '';
|
|
32
|
-
|
|
33
|
-
const Player = ({ color }: { color: Color }) => {
|
|
34
|
-
const turn = color === game.turn();
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div className='flex items-center'>
|
|
38
|
-
<Icon
|
|
39
|
-
icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
|
|
40
|
-
size={4}
|
|
41
|
-
classNames={mx(turn && (game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className={mx('flex flex-col', classNames)}>
|
|
49
|
-
<div className='flex items-center justify-between pl-2 pr-2 border-b' style={{ height: 32 }}>
|
|
50
|
-
<Player color={orientation === 'w' ? 'b' : 'w'} />
|
|
51
|
-
{onFlip && (
|
|
52
|
-
<button onClick={onFlip}>
|
|
53
|
-
<Icon icon='ph--arrow-u-right-down--thin' size={6} />
|
|
54
|
-
</button>
|
|
55
|
-
)}
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<div className='flex flex-col justify-center pl-2 font-thin' style={{ height: 40 }}>
|
|
59
|
-
{label}
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
<div className='flex items-center justify-between pl-2 pr-2 border-t' style={{ height: 32 }}>
|
|
63
|
-
<Player color={orientation} />
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import React, { useMemo } from 'react';
|
|
9
|
-
|
|
10
|
-
import { Gameboard, Chessboard, ChessModel } from '@dxos/react-ui-gameboard';
|
|
11
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
|
-
|
|
13
|
-
import { ChessPanel } from './ChessPanel';
|
|
14
|
-
|
|
15
|
-
const DefaultStory = () => {
|
|
16
|
-
const model = useMemo(() => new ChessModel(), []);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className='flex grow mx-8 gap-8 items-center overflow-hidden'>
|
|
20
|
-
<Gameboard.Root model={model} onDrop={(move) => model.makeMove(move)}>
|
|
21
|
-
<Gameboard.Content>
|
|
22
|
-
<Chessboard />
|
|
23
|
-
</Gameboard.Content>
|
|
24
|
-
</Gameboard.Root>
|
|
25
|
-
<ChessPanel model={model} classNames='w-[200px]' />
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const meta: Meta<typeof Chessboard> = {
|
|
31
|
-
title: 'plugins/plugin-chess/Chessboard',
|
|
32
|
-
component: Chessboard,
|
|
33
|
-
render: DefaultStory,
|
|
34
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
type Story = StoryObj<typeof Chessboard>;
|
|
38
|
-
|
|
39
|
-
export default meta;
|
|
40
|
-
|
|
41
|
-
export const Default: Story = {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { generateName } from '@dxos/display-name';
|
|
8
|
-
import { useMembers, type Space, type SpaceMember } from '@dxos/react-client/echo';
|
|
9
|
-
import { Icon, Input, Select, useThemeContext } from '@dxos/react-ui';
|
|
10
|
-
|
|
11
|
-
import { type ChessType } from '../types';
|
|
12
|
-
|
|
13
|
-
export const PlayerSelector = ({ space, game }: { space: Space; game: ChessType }) => {
|
|
14
|
-
const members = useMembers(space.key);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div role='none' className='grid grid-cols-2 gap-8'>
|
|
18
|
-
<div role='none' className='flex flex-row-reverse items-center gap-2'>
|
|
19
|
-
<PlayerSelect
|
|
20
|
-
side='white'
|
|
21
|
-
value={game.playerWhite}
|
|
22
|
-
onValueChange={(player) => (game.playerWhite = player)}
|
|
23
|
-
members={members}
|
|
24
|
-
/>
|
|
25
|
-
</div>
|
|
26
|
-
<div role='none' className='flex flex-row items-center gap-2'>
|
|
27
|
-
<PlayerSelect
|
|
28
|
-
side='black'
|
|
29
|
-
value={game.playerBlack}
|
|
30
|
-
onValueChange={(player) => (game.playerBlack = player)}
|
|
31
|
-
members={members}
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const PlayerSelect = ({
|
|
39
|
-
side,
|
|
40
|
-
value,
|
|
41
|
-
onValueChange,
|
|
42
|
-
members,
|
|
43
|
-
}: {
|
|
44
|
-
side: 'white' | 'black';
|
|
45
|
-
value: string | undefined;
|
|
46
|
-
onValueChange: (player: string) => void;
|
|
47
|
-
members: SpaceMember[];
|
|
48
|
-
}) => {
|
|
49
|
-
const { themeMode } = useThemeContext();
|
|
50
|
-
const iconFillMode =
|
|
51
|
-
(side === 'black' && themeMode === 'light') || (side === 'white' && themeMode === 'dark') ? 'fill' : undefined;
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<Input.Root>
|
|
55
|
-
<Input.Label>
|
|
56
|
-
<Icon
|
|
57
|
-
aria-label={`Chess icon for side ${side}`}
|
|
58
|
-
icon={`ph--crown-cross--${iconFillMode || 'regular'}`}
|
|
59
|
-
size={6}
|
|
60
|
-
/>
|
|
61
|
-
</Input.Label>
|
|
62
|
-
<Select.Root value={value} onValueChange={onValueChange}>
|
|
63
|
-
<Select.TriggerButton placeholder={'Select player'} />
|
|
64
|
-
<Select.Portal>
|
|
65
|
-
<Select.Content>
|
|
66
|
-
<Select.Viewport>
|
|
67
|
-
{members.map((member) => {
|
|
68
|
-
const memberKey = member.identity.identityKey.toHex();
|
|
69
|
-
const displayName = member.identity?.profile?.displayName || generateName(memberKey);
|
|
70
|
-
return (
|
|
71
|
-
<Select.Option key={memberKey} value={memberKey}>
|
|
72
|
-
{displayName}
|
|
73
|
-
</Select.Option>
|
|
74
|
-
);
|
|
75
|
-
})}
|
|
76
|
-
</Select.Viewport>
|
|
77
|
-
</Select.Content>
|
|
78
|
-
</Select.Portal>
|
|
79
|
-
</Select.Root>
|
|
80
|
-
</Input.Root>
|
|
81
|
-
);
|
|
82
|
-
};
|
package/src/types/schema.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { Type } from '@dxos/echo';
|
|
8
|
-
|
|
9
|
-
export const MoveSchema = Schema.mutable(
|
|
10
|
-
Schema.partial(
|
|
11
|
-
Schema.Struct({
|
|
12
|
-
source: Schema.String,
|
|
13
|
-
target: Schema.String,
|
|
14
|
-
piece: Schema.String,
|
|
15
|
-
}),
|
|
16
|
-
),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export const ChessType = Schema.Struct({
|
|
20
|
-
name: Schema.optional(Schema.String),
|
|
21
|
-
playerWhite: Schema.String,
|
|
22
|
-
playerBlack: Schema.String,
|
|
23
|
-
moves: Schema.mutable(Schema.Array(Schema.String)),
|
|
24
|
-
// TODO(wittjosiah): Remove. Redundant with moves.
|
|
25
|
-
pgn: Schema.String,
|
|
26
|
-
fen: Schema.String,
|
|
27
|
-
}).pipe(
|
|
28
|
-
Schema.partial,
|
|
29
|
-
Type.Obj({
|
|
30
|
-
typename: 'dxos.org/type/Chess',
|
|
31
|
-
version: '0.1.0',
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
export interface ChessType extends Schema.Schema.Type<typeof ChessType> {}
|