@dxos/react-ui-gameboard 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77

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.
Files changed (67) hide show
  1. package/dist/lib/browser/index.mjs +420 -337
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +420 -337
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/Chessboard/Chessboard.d.ts +20 -0
  8. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
  9. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +33 -0
  10. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
  11. package/dist/types/src/components/Chessboard/chess.d.ts +59 -0
  12. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -0
  13. package/dist/types/src/components/Chessboard/chess.test.d.ts +2 -0
  14. package/dist/types/src/components/Chessboard/chess.test.d.ts.map +1 -0
  15. package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
  16. package/dist/types/src/components/Gameboard/Gameboard.d.ts +38 -0
  17. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -0
  18. package/dist/types/src/{Gameboard → components/Gameboard}/Piece.d.ts +3 -2
  19. package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -0
  20. package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -0
  21. package/dist/types/src/components/Gameboard/index.d.ts +4 -0
  22. package/dist/types/src/components/Gameboard/index.d.ts.map +1 -0
  23. package/dist/types/src/{Gameboard → components/Gameboard}/types.d.ts +2 -0
  24. package/dist/types/src/components/Gameboard/types.d.ts.map +1 -0
  25. package/dist/types/src/components/Gameboard/util.d.ts.map +1 -0
  26. package/dist/types/src/components/index.d.ts +3 -0
  27. package/dist/types/src/components/index.d.ts.map +1 -0
  28. package/dist/types/src/index.d.ts +1 -2
  29. package/dist/types/src/index.d.ts.map +1 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +23 -22
  32. package/src/{Chessboard → components/Chessboard}/Chessboard.stories.tsx +29 -27
  33. package/src/{Chessboard → components/Chessboard}/Chessboard.tsx +58 -54
  34. package/src/components/Chessboard/chess.test.ts +19 -0
  35. package/src/components/Chessboard/chess.ts +322 -0
  36. package/src/components/Gameboard/Gameboard.tsx +140 -0
  37. package/src/{Gameboard → components/Gameboard}/Piece.tsx +24 -22
  38. package/src/{Gameboard → components/Gameboard}/Square.tsx +4 -4
  39. package/src/{Gameboard → components/Gameboard}/index.ts +0 -3
  40. package/src/{Gameboard → components/Gameboard}/types.ts +3 -0
  41. package/src/components/index.ts +6 -0
  42. package/src/index.ts +1 -2
  43. package/dist/types/src/Chessboard/Chessboard.d.ts +0 -15
  44. package/dist/types/src/Chessboard/Chessboard.d.ts.map +0 -1
  45. package/dist/types/src/Chessboard/Chessboard.stories.d.ts +0 -16
  46. package/dist/types/src/Chessboard/Chessboard.stories.d.ts.map +0 -1
  47. package/dist/types/src/Chessboard/chess.d.ts +0 -40
  48. package/dist/types/src/Chessboard/chess.d.ts.map +0 -1
  49. package/dist/types/src/Chessboard/index.d.ts.map +0 -1
  50. package/dist/types/src/Gameboard/Gameboard.d.ts +0 -23
  51. package/dist/types/src/Gameboard/Gameboard.d.ts.map +0 -1
  52. package/dist/types/src/Gameboard/Piece.d.ts.map +0 -1
  53. package/dist/types/src/Gameboard/Square.d.ts.map +0 -1
  54. package/dist/types/src/Gameboard/context.d.ts +0 -10
  55. package/dist/types/src/Gameboard/context.d.ts.map +0 -1
  56. package/dist/types/src/Gameboard/index.d.ts +0 -7
  57. package/dist/types/src/Gameboard/index.d.ts.map +0 -1
  58. package/dist/types/src/Gameboard/types.d.ts.map +0 -1
  59. package/dist/types/src/Gameboard/util.d.ts.map +0 -1
  60. package/src/Chessboard/chess.ts +0 -213
  61. package/src/Gameboard/Gameboard.tsx +0 -103
  62. package/src/Gameboard/context.ts +0 -22
  63. /package/dist/types/src/{Chessboard → components/Chessboard}/index.d.ts +0 -0
  64. /package/dist/types/src/{Gameboard → components/Gameboard}/Square.d.ts +0 -0
  65. /package/dist/types/src/{Gameboard → components/Gameboard}/util.d.ts +0 -0
  66. /package/src/{Chessboard → components/Chessboard}/index.ts +0 -0
  67. /package/src/{Gameboard → components/Gameboard}/util.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-gameboard",
3
- "version": "0.8.4-main.67995b8",
3
+ "version": "0.8.4-main.a4bbb77",
4
4
  "description": "Game board.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -9,10 +9,10 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
+ "source": "./src/index.ts",
12
13
  "types": "./dist/types/src/index.d.ts",
13
14
  "browser": "./dist/lib/browser/index.mjs",
14
- "node": "./dist/lib/node-esm/index.mjs",
15
- "source": "./src/index.ts"
15
+ "node": "./dist/lib/node-esm/index.mjs"
16
16
  }
17
17
  },
18
18
  "types": "dist/types/src/index.d.ts",
@@ -27,33 +27,34 @@
27
27
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
28
28
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
29
29
  "@preact-signals/safe-react": "^0.9.0",
30
- "@preact/signals-core": "^1.9.0",
31
- "chess.js": "^1.0.0",
30
+ "@preact/signals-core": "^1.12.1",
31
+ "@radix-ui/react-context": "1.1.1",
32
+ "chess.js": "^1.4.0",
32
33
  "react-resize-detector": "^11.0.1",
33
- "@dxos/debug": "0.8.4-main.67995b8",
34
- "@dxos/invariant": "0.8.4-main.67995b8",
35
- "@dxos/log": "0.8.4-main.67995b8",
36
- "@dxos/node-std": "0.8.4-main.67995b8",
37
- "@dxos/util": "0.8.4-main.67995b8"
34
+ "@dxos/debug": "0.8.4-main.a4bbb77",
35
+ "@dxos/invariant": "0.8.4-main.a4bbb77",
36
+ "@dxos/log": "0.8.4-main.a4bbb77",
37
+ "@dxos/node-std": "0.8.4-main.a4bbb77",
38
+ "@dxos/util": "0.8.4-main.a4bbb77"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@svgr/cli": "^8.1.0",
41
42
  "@types/lodash.defaultsdeep": "^4.6.6",
42
- "@types/react": "~18.2.0",
43
- "@types/react-dom": "~18.2.0",
43
+ "@types/react": "~19.2.0",
44
+ "@types/react-dom": "~19.2.0",
44
45
  "lodash.defaultsdeep": "^4.6.1",
45
- "react": "~18.2.0",
46
- "react-dom": "~18.2.0",
47
- "vite": "5.4.7",
48
- "@dxos/react-ui": "0.8.4-main.67995b8",
49
- "@dxos/react-ui-theme": "0.8.4-main.67995b8",
50
- "@dxos/storybook-utils": "0.8.4-main.67995b8"
46
+ "react": "~19.2.0",
47
+ "react-dom": "~19.2.0",
48
+ "vite": "7.1.9",
49
+ "@dxos/react-ui": "0.8.4-main.a4bbb77",
50
+ "@dxos/react-ui-theme": "0.8.4-main.a4bbb77",
51
+ "@dxos/storybook-utils": "0.8.4-main.a4bbb77"
51
52
  },
52
53
  "peerDependencies": {
53
- "react": "~18.2.0",
54
- "react-dom": "~18.2.0",
55
- "@dxos/react-ui": "0.8.4-main.67995b8",
56
- "@dxos/react-ui-theme": "0.8.4-main.67995b8"
54
+ "react": "^19.0.0",
55
+ "react-dom": "^19.0.0",
56
+ "@dxos/react-ui": "0.8.4-main.a4bbb77",
57
+ "@dxos/react-ui-theme": "0.8.4-main.a4bbb77"
57
58
  },
58
59
  "publishConfig": {
59
60
  "access": "public"
@@ -2,31 +2,30 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import type { Meta, StoryObj } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
9
7
 
10
- import { log } from '@dxos/log';
11
8
  import { Button, Toolbar } from '@dxos/react-ui';
12
- import { withLayout, withTheme } from '@dxos/storybook-utils';
9
+ import { withTheme } from '@dxos/react-ui/testing';
10
+
11
+ import { Gameboard, type GameboardRootProps, type Move, type Player } from '../Gameboard';
13
12
 
14
- import { Chessboard, type ChessboardProps } from './Chessboard';
15
13
  import { ChessModel } from './chess';
16
- import { Gameboard, type GameboardRootProps, type Player, type Move } from '../Gameboard';
14
+ import { Chessboard, type ChessboardProps } from './Chessboard';
17
15
 
18
- type RenderProps = Pick<ChessboardProps, 'orientation' | 'showLabels' | 'debug'> & {
19
- fen: string;
16
+ type DefaultStoryProps = Pick<ChessboardProps, 'orientation' | 'showLabels' | 'debug'> & {
17
+ pgn?: string;
20
18
  };
21
19
 
22
- const DefaultStory = ({ fen, orientation: _orientation, ...props }: RenderProps) => {
23
- const model = useMemo(() => new ChessModel(fen), [fen]);
20
+ const DefaultStory = ({ orientation: _orientation, pgn, ...props }: DefaultStoryProps) => {
21
+ const model = useMemo(() => new ChessModel(pgn), [pgn]);
24
22
  const [orientation, setOrientation] = useState<Player | undefined>(_orientation);
25
23
 
26
- const handleDrop = useCallback<NonNullable<GameboardRootProps['onDrop']>>(
24
+ const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
27
25
  (move: Move) => {
28
- log.info('handleDrop', { move });
29
- return model.makeMove(move);
26
+ const result = model.makeMove(move);
27
+ console.log(model.pgn);
28
+ return result;
30
29
  },
31
30
  [model],
32
31
  );
@@ -34,7 +33,7 @@ const DefaultStory = ({ fen, orientation: _orientation, ...props }: RenderProps)
34
33
  return (
35
34
  <div className='flex flex-col grow gap-2 overflow-hidden'>
36
35
  <Toolbar.Root>
37
- <Button onClick={() => model.initialize()}>Reset</Button>
36
+ <Button onClick={() => model.update()}>Reset</Button>
38
37
  <Button onClick={() => model.makeRandomMove()}>Move</Button>
39
38
  <div className='grow'></div>
40
39
  <Button
@@ -44,7 +43,7 @@ const DefaultStory = ({ fen, orientation: _orientation, ...props }: RenderProps)
44
43
  </Button>
45
44
  </Toolbar.Root>
46
45
  <Gameboard.Root model={model} onDrop={handleDrop}>
47
- <Gameboard.Content>
46
+ <Gameboard.Content grow contain>
48
47
  <Chessboard orientation={orientation} {...props} />
49
48
  </Gameboard.Content>
50
49
  </Gameboard.Root>
@@ -52,7 +51,7 @@ const DefaultStory = ({ fen, orientation: _orientation, ...props }: RenderProps)
52
51
  );
53
52
  };
54
53
 
55
- const Grid = (props: RenderProps) => {
54
+ const GridStory = () => {
56
55
  const models = useMemo(() => Array.from({ length: 9 }).map(() => new ChessModel()), []);
57
56
  useEffect(() => {
58
57
  const i = setInterval(() => {
@@ -77,34 +76,37 @@ const Grid = (props: RenderProps) => {
77
76
  );
78
77
  };
79
78
 
80
- const meta: Meta<typeof DefaultStory> = {
79
+ const meta = {
81
80
  title: 'ui/react-ui-gameboard/Chessboard',
82
81
  component: Chessboard,
83
82
  render: DefaultStory,
84
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: '' })],
85
- };
83
+ decorators: [withTheme],
84
+ parameters: {
85
+ layout: 'column',
86
+ },
87
+ } satisfies Meta<typeof Chessboard>;
86
88
 
87
89
  export default meta;
88
90
 
89
- type Story = StoryObj<typeof DefaultStory>;
91
+ type Story = StoryObj<typeof meta>;
90
92
 
91
93
  export const Default: Story = {};
92
94
 
93
95
  export const Promotion: Story = {
94
96
  args: {
95
- fen: '4k3/7P/8/8/8/8/1p6/4K3 w - - 0 1',
97
+ pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Kf8 16. e7+ Kg8 *',
96
98
  },
97
99
  };
98
100
 
99
101
  export const Debug: Story = {
100
102
  args: {
101
- debug: true,
102
- showLabels: true,
103
+ pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 *',
103
104
  orientation: 'black',
104
- fen: 'q3k1nr/1pp1nQpp/3p4/1P2p3/4P3/B1PP1b2/B5PP/5K2 b k - 0 17',
105
+ showLabels: true,
106
+ debug: true,
105
107
  },
106
108
  };
107
109
 
108
- export const Nine: Story = {
109
- render: Grid,
110
+ export const Grid = {
111
+ render: GridStory,
110
112
  };
@@ -2,26 +2,26 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { type PropsWithChildren, useRef, useMemo, useEffect, useState, memo } from 'react';
5
+ import React, { type PropsWithChildren, forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
6
6
  import { useResizeDetector } from 'react-resize-detector';
7
7
 
8
- import { type ThemedClassName, useTrackProps } from '@dxos/react-ui';
8
+ import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
9
9
  import { mx } from '@dxos/react-ui-theme';
10
- import { isNotFalsy } from '@dxos/util';
10
+ import { isTruthy } from '@dxos/util';
11
11
 
12
- import { boardStyles, type ChessPiece, ChessPieces, getSquareColor, locationToPos } from './chess';
13
12
  import {
14
13
  type DOMRectBounds,
14
+ Gameboard,
15
15
  type Location,
16
16
  type PieceRecord,
17
17
  type Player,
18
- Piece,
19
- Square,
20
18
  getRelativeBounds,
21
19
  locationToString,
22
- useBoardContext,
20
+ useGameboardContext,
23
21
  } from '../Gameboard';
24
22
 
23
+ import { type ChessModel, type ChessPiece, ChessPieces, boardStyles, getSquareColor, locationToPos } from './chess';
24
+
25
25
  export type ChessboardProps = ThemedClassName<
26
26
  PropsWithChildren<{
27
27
  orientation?: Player;
@@ -35,13 +35,14 @@ export type ChessboardProps = ThemedClassName<
35
35
  /**
36
36
  * Chessboard layout.
37
37
  */
38
- export const Chessboard = memo(
39
- ({ orientation, showLabels, debug, rows = 8, cols = 8, classNames }: ChessboardProps) => {
40
- useTrackProps({ orientation, showLabels, debug }, Chessboard.displayName, false);
41
- const { ref: containerRef, width, height } = useResizeDetector({ refreshRate: 200 });
42
- const { model, promoting, onPromotion } = useBoardContext();
43
-
44
- const locations = useMemo<Location[]>(() => {
38
+ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
39
+ ({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
40
+ const targetRef = useForwardedRef(forwardedRef);
41
+ const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
42
+ const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(Chessboard.displayName!);
43
+
44
+ // Board squares.
45
+ const squares = useMemo<Location[]>(() => {
45
46
  return Array.from({ length: rows }, (_, i) => (orientation === 'black' ? i : rows - 1 - i)).flatMap((row) =>
46
47
  Array.from({ length: cols }).map((_, col) => [row, col] as Location),
47
48
  );
@@ -49,7 +50,7 @@ export const Chessboard = memo(
49
50
 
50
51
  // Use DOM grid layout to position squares.
51
52
  const layout = useMemo(() => {
52
- return locations.map((location) => {
53
+ return squares.map((location) => {
53
54
  return (
54
55
  <div
55
56
  key={locationToString(location)}
@@ -59,14 +60,14 @@ export const Chessboard = memo(
59
60
  />
60
61
  );
61
62
  });
62
- }, [locations]);
63
+ }, [squares]);
63
64
 
64
65
  // Build map of square locations to bounds.
65
66
  const [grid, setGrid] = useState<Record<string, DOMRectBounds>>({});
66
67
  const gridRef = useRef<HTMLDivElement>(null);
67
68
  useEffect(() => {
68
69
  setGrid(
69
- locations.reduce(
70
+ squares.reduce(
70
71
  (acc, location) => {
71
72
  const square = getSquareLocation(gridRef.current!, location)!;
72
73
  const bounds = getRelativeBounds(gridRef.current!, square);
@@ -75,7 +76,7 @@ export const Chessboard = memo(
75
76
  {} as Record<string, DOMRectBounds>,
76
77
  ),
77
78
  );
78
- }, [locations, width, height]);
79
+ }, [squares, width, height]);
79
80
 
80
81
  // Get the bounds of each square and piece.
81
82
  const positions = useMemo<{ piece: PieceRecord; bounds: DOMRectBounds }[]>(() => {
@@ -92,17 +93,19 @@ export const Chessboard = memo(
92
93
  const bounds = grid[locationToString(piece.location)];
93
94
  return { piece, bounds };
94
95
  })
95
- .filter(isNotFalsy);
96
+ .filter(isTruthy);
96
97
  }, [grid, model?.pieces.value, promoting]);
97
98
 
98
99
  return (
99
- <div ref={containerRef} className={mx('relative', classNames)}>
100
+ <div ref={targetRef} tabIndex={0} className={mx('relative outline-none', classNames)}>
101
+ {/* DOM Layout. */}
100
102
  <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>
101
103
  {layout}
102
104
  </div>
105
+ {/* Squares. */}
103
106
  <div>
104
- {locations.map((location) => (
105
- <Square
107
+ {squares.map((location) => (
108
+ <Gameboard.Square
106
109
  key={locationToString(location)}
107
110
  location={location}
108
111
  label={showLabels ? locationToPos(location) : undefined}
@@ -111,9 +114,10 @@ export const Chessboard = memo(
111
114
  />
112
115
  ))}
113
116
  </div>
117
+ {/* Pieces. */}
114
118
  <div className={mx(promoting && 'opacity-50')}>
115
119
  {positions.map(({ bounds, piece }) => (
116
- <Piece
120
+ <Gameboard.Piece
117
121
  key={piece.id}
118
122
  piece={piece}
119
123
  bounds={bounds}
@@ -123,32 +127,29 @@ export const Chessboard = memo(
123
127
  />
124
128
  ))}
125
129
  </div>
126
- <div>
127
- {promoting && (
128
- <PromotionSelector
129
- grid={grid}
130
- piece={promoting}
131
- onSelect={(piece) => {
132
- onPromotion({
133
- from: Object.values(model!.pieces.value).find((p) => p.id === promoting.id)!.location,
134
- to: piece.location,
135
- piece: promoting.type,
136
- promotion: piece.type,
137
- });
138
- }}
139
- />
140
- )}
141
- </div>
130
+ {/* Promotion selector. */}
131
+ {promoting && (
132
+ <PromotionSelector
133
+ grid={grid}
134
+ piece={promoting}
135
+ onSelect={(piece) => {
136
+ onPromotion({
137
+ from: Object.values(model.pieces.value).find((p) => p.id === promoting.id)!.location,
138
+ to: piece.location,
139
+ piece: promoting.type,
140
+ promotion: piece.type,
141
+ });
142
+ }}
143
+ />
144
+ )}
142
145
  </div>
143
146
  );
144
147
  },
145
148
  );
146
149
 
147
- Chessboard.displayName = 'Chessboard';
150
+ ChessboardComponent.displayName = 'Chessboard';
148
151
 
149
- const getSquareLocation = (container: HTMLElement, location: Location): HTMLElement | null => {
150
- return container.querySelector(`[data-location="${locationToString(location)}"]`);
151
- };
152
+ export const Chessboard = memo(ChessboardComponent);
152
153
 
153
154
  const PromotionSelector = ({
154
155
  grid,
@@ -176,19 +177,22 @@ const PromotionSelector = ({
176
177
  onSelect({ ...piece, type: selected.type });
177
178
  };
178
179
 
179
- // TODO(burdon): Circle.
180
180
  return (
181
- <div>
181
+ <>
182
182
  {positions.map(({ piece, bounds }) => (
183
- <div key={piece.id} style={bounds} onClick={() => handleSelect(piece)}>
184
- <Piece
185
- piece={piece}
186
- bounds={bounds}
187
- Component={ChessPieces[piece.type as ChessPiece]}
188
- classNames={mx('border-2 border-neutral-700 rounded-full', boardStyles.promotion)}
189
- />
190
- </div>
183
+ <Gameboard.Piece
184
+ key={piece.id}
185
+ classNames={mx('border-2 border-neutral-700 rounded-full', boardStyles.promotion)}
186
+ piece={piece}
187
+ bounds={bounds}
188
+ Component={ChessPieces[piece.type as ChessPiece]}
189
+ onClick={() => handleSelect(piece)}
190
+ />
191
191
  ))}
192
- </div>
192
+ </>
193
193
  );
194
194
  };
195
+
196
+ const getSquareLocation = (container: HTMLElement, location: Location): HTMLElement | null => {
197
+ return container.querySelector(`[data-location="${locationToString(location)}"]`);
198
+ };
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Chess as ChessJS } from 'chess.js';
6
+ import { describe, it } from 'vitest';
7
+
8
+ import { createPieceMap } from './chess';
9
+
10
+ describe('ChessModel', () => {
11
+ it('should update pieces', ({ expect }) => {
12
+ const chess = new ChessJS();
13
+ chess.loadPgn(
14
+ '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 *',
15
+ );
16
+ const pieces = createPieceMap(chess);
17
+ expect(pieces).to.exist;
18
+ });
19
+ });