@dxos/plugin-chess 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d
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-NNIOQIRP.mjs +90 -0
- package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs +38 -0
- package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-2W3S5N6C.mjs +257 -0
- package/dist/lib/browser/chunk-2W3S5N6C.mjs.map +7 -0
- package/dist/lib/browser/chunk-EJMPHRSR.mjs +94 -0
- package/dist/lib/browser/chunk-EJMPHRSR.mjs.map +7 -0
- package/dist/lib/browser/chunk-OBJAHY6H.mjs +79 -0
- package/dist/lib/browser/chunk-OBJAHY6H.mjs.map +7 -0
- package/dist/lib/browser/chunk-PE3IWOFR.mjs +28 -0
- package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +7 -0
- package/dist/lib/browser/chunk-PPBBLHAC.mjs +8 -0
- package/dist/lib/browser/chunk-PPBBLHAC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +44 -24
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-KQYYX44R.mjs → intent-resolver-JWKKRNGG.mjs} +8 -11
- package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-RIXD6RTS.mjs +38 -0
- package/dist/lib/browser/react-surface-RIXD6RTS.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -7
- package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs +91 -0
- package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs +39 -0
- package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TD2SWK2H.mjs → chunk-42EKKMOO.mjs} +3 -3
- package/dist/lib/node-esm/chunk-42EKKMOO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5APYXPBX.mjs +95 -0
- package/dist/lib/node-esm/chunk-5APYXPBX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6OWCPDUA.mjs +29 -0
- package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LCCUF5X5.mjs +80 -0
- package/dist/lib/node-esm/chunk-LCCUF5X5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QAGOXJGH.mjs +258 -0
- package/dist/lib/node-esm/chunk-QAGOXJGH.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +44 -24
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-GXK2JROQ.mjs → intent-resolver-G6XJAW6C.mjs} +8 -11
- package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-PAUEOIBL.mjs → react-surface-GGRDWZJT.mjs} +16 -21
- package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Card.stories.d.ts +49 -0
- package/dist/types/src/components/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.d.ts +32 -0
- package/dist/types/src/components/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.stories.d.ts +39 -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 +9 -0
- package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -0
- package/dist/types/src/components/ChessboardInfo.d.ts +20 -0
- package/dist/types/src/components/ChessboardInfo.d.ts.map +1 -0
- package/dist/types/src/components/ChessboardPlayers.d.ts +8 -0
- package/dist/types/src/components/ChessboardPlayers.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/functions/index.d.ts +3 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/move.d.ts +6 -0
- package/dist/types/src/functions/move.d.ts.map +1 -0
- package/dist/types/src/functions/play.d.ts +8 -0
- package/dist/types/src/functions/play.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/types/src/translations.d.ts +10 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +24 -0
- package/dist/types/src/types/Chess.d.ts.map +1 -0
- package/dist/types/src/types/ChessAction.d.ts +23 -0
- package/dist/types/src/types/ChessAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -26
- package/src/ChessPlugin.tsx +7 -7
- package/src/capabilities/artifact-definition.ts +25 -21
- package/src/capabilities/blueprint-definition.ts +34 -0
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +3 -7
- package/src/capabilities/react-surface.tsx +6 -13
- package/src/components/Card.stories.tsx +68 -0
- package/src/components/Chessboard.stories.tsx +32 -21
- package/src/components/Chessboard.tsx +101 -0
- package/src/components/ChessboardArticle.tsx +57 -0
- package/src/components/ChessboardContainer.tsx +44 -0
- package/src/components/ChessboardInfo.tsx +140 -0
- package/src/components/{PlayerSelector.tsx → ChessboardPlayers.tsx} +31 -14
- package/src/components/index.ts +2 -2
- package/src/functions/index.ts +6 -0
- package/src/functions/move.ts +43 -0
- package/src/functions/play.ts +45 -0
- package/src/index.ts +2 -0
- package/src/meta.ts +4 -2
- package/src/translations.ts +10 -2
- package/src/types/Chess.ts +56 -0
- package/src/types/ChessAction.ts +19 -0
- package/src/types/index.ts +2 -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.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.map +0 -7
- package/dist/lib/node-esm/react-surface-PAUEOIBL.mjs.map +0 -7
- 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/components/ChessComponent.tsx +0 -54
- package/src/components/ChessContainer.tsx +0 -35
- package/src/components/ChessPanel.tsx +0 -67
- package/src/types/schema.ts +0 -34
- package/src/types/types.ts +0 -20
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { ArrowURightDown, Circle } from '@phosphor-icons/react';
|
|
6
|
-
import { type Color } from 'chess.js';
|
|
7
|
-
import React, { type FC } from 'react';
|
|
8
|
-
|
|
9
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
-
import { type ChessModel } from '@dxos/react-ui-gameboard';
|
|
11
|
-
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
12
|
-
|
|
13
|
-
export type ChessPanelProps = ThemedClassName<{
|
|
14
|
-
model: ChessModel;
|
|
15
|
-
orientation?: Color;
|
|
16
|
-
onFlip?: () => void;
|
|
17
|
-
}>;
|
|
18
|
-
|
|
19
|
-
export const ChessPanel: FC<ChessPanelProps> = ({ classNames, model, orientation = 'w', onFlip }) => {
|
|
20
|
-
const game = model.game;
|
|
21
|
-
const history = game.history();
|
|
22
|
-
const label = game.isGameOver()
|
|
23
|
-
? game.isCheckmate()
|
|
24
|
-
? 'CHECKMATE'
|
|
25
|
-
: game.isStalemate()
|
|
26
|
-
? 'STALEMATE'
|
|
27
|
-
: 'DRAW'
|
|
28
|
-
: game.isCheck()
|
|
29
|
-
? 'CHECK'
|
|
30
|
-
: history.length
|
|
31
|
-
? `Move ${history.length}`
|
|
32
|
-
: '';
|
|
33
|
-
|
|
34
|
-
const Player = ({ color }: { color: Color }) => {
|
|
35
|
-
const turn = color === game.turn();
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className='flex items-center'>
|
|
39
|
-
<Circle
|
|
40
|
-
className={mx(getSize(4), turn && (game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
|
|
41
|
-
weight={turn ? 'fill' : 'thin'}
|
|
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
|
-
<ArrowURightDown weight='thin' className={getSize(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
|
-
};
|
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> {}
|
package/src/types/types.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { ChessType } from './schema';
|
|
8
|
-
import { meta } from '../meta';
|
|
9
|
-
|
|
10
|
-
export namespace ChessAction {
|
|
11
|
-
export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
|
|
12
|
-
input: Schema.Struct({
|
|
13
|
-
name: Schema.optional(Schema.String),
|
|
14
|
-
fen: Schema.optional(Schema.String),
|
|
15
|
-
}),
|
|
16
|
-
output: Schema.Struct({
|
|
17
|
-
object: ChessType,
|
|
18
|
-
}),
|
|
19
|
-
}) {}
|
|
20
|
-
}
|