@dxos/react-ui-gameboard 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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 (54) hide show
  1. package/README.md +2 -0
  2. package/dist/lib/browser/index.mjs +504 -712
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +504 -712
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/Chessboard/Chessboard.d.ts +3 -3
  9. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  10. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +4 -4
  11. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Chessboard/chess.d.ts +5 -4
  13. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -1
  14. package/dist/types/src/components/Gameboard/Gameboard.d.ts +11 -8
  15. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -1
  16. package/dist/types/src/components/Gameboard/Piece.d.ts +1 -1
  17. package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -1
  18. package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -1
  19. package/dist/types/src/components/Gameboard/types.d.ts +2 -3
  20. package/dist/types/src/components/Gameboard/types.d.ts.map +1 -1
  21. package/dist/types/src/components/Gameboard/util.d.ts.map +1 -1
  22. package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts.map +1 -1
  23. package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts.map +1 -1
  24. package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts.map +1 -1
  25. package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts.map +1 -1
  26. package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts.map +1 -1
  27. package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts.map +1 -1
  28. package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts.map +1 -1
  29. package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts.map +1 -1
  30. package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts.map +1 -1
  31. package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts.map +1 -1
  32. package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts.map +1 -1
  33. package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts.map +1 -1
  34. package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts.map +1 -1
  35. package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts.map +1 -1
  36. package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts.map +1 -1
  37. package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts.map +1 -1
  38. package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts.map +1 -1
  39. package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts.map +1 -1
  40. package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts.map +1 -1
  41. package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts.map +1 -1
  42. package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts.map +1 -1
  43. package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts.map +1 -1
  44. package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts.map +1 -1
  45. package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts.map +1 -1
  46. package/dist/types/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +26 -26
  48. package/src/components/Chessboard/Chessboard.stories.tsx +10 -8
  49. package/src/components/Chessboard/Chessboard.tsx +22 -16
  50. package/src/components/Chessboard/chess.ts +13 -10
  51. package/src/components/Gameboard/Gameboard.tsx +8 -10
  52. package/src/components/Gameboard/Piece.tsx +7 -6
  53. package/src/components/Gameboard/Square.tsx +5 -3
  54. package/src/components/Gameboard/types.ts +2 -3
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-gameboard",
3
- "version": "0.8.4-main.dedc0f3",
3
+ "version": "0.8.4-main.dfabb4ec29",
4
4
  "description": "Game board.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
13
  "type": "module",
@@ -16,45 +20,41 @@
16
20
  }
17
21
  },
18
22
  "types": "dist/types/src/index.d.ts",
19
- "typesVersions": {
20
- "*": {}
21
- },
22
23
  "files": [
23
24
  "dist",
24
25
  "src"
25
26
  ],
26
27
  "dependencies": {
27
- "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
28
- "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
29
- "@preact-signals/safe-react": "^0.9.0",
30
- "@preact/signals-core": "^1.9.0",
28
+ "@atlaskit/pragmatic-drag-and-drop": "1.7.7",
29
+ "@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
30
+ "@effect-atom/atom-react": "^0.5.0",
31
31
  "@radix-ui/react-context": "1.1.1",
32
- "chess.js": "^1.4.0",
32
+ "chess.js": "^1.0.0",
33
33
  "react-resize-detector": "^11.0.1",
34
- "@dxos/debug": "0.8.4-main.dedc0f3",
35
- "@dxos/invariant": "0.8.4-main.dedc0f3",
36
- "@dxos/log": "0.8.4-main.dedc0f3",
37
- "@dxos/node-std": "0.8.4-main.dedc0f3",
38
- "@dxos/util": "0.8.4-main.dedc0f3"
34
+ "@dxos/log": "0.8.4-main.dfabb4ec29",
35
+ "@dxos/invariant": "0.8.4-main.dfabb4ec29",
36
+ "@dxos/debug": "0.8.4-main.dfabb4ec29",
37
+ "@dxos/util": "0.8.4-main.dfabb4ec29",
38
+ "@dxos/node-std": "0.8.4-main.dfabb4ec29"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@svgr/cli": "^8.1.0",
42
42
  "@types/lodash.defaultsdeep": "^4.6.6",
43
- "@types/react": "~18.2.0",
44
- "@types/react-dom": "~18.2.0",
43
+ "@types/react": "~19.2.7",
44
+ "@types/react-dom": "~19.2.3",
45
45
  "lodash.defaultsdeep": "^4.6.1",
46
- "react": "~18.2.0",
47
- "react-dom": "~18.2.0",
48
- "vite": "7.1.1",
49
- "@dxos/react-ui": "0.8.4-main.dedc0f3",
50
- "@dxos/react-ui-theme": "0.8.4-main.dedc0f3",
51
- "@dxos/storybook-utils": "0.8.4-main.dedc0f3"
46
+ "react": "~19.2.3",
47
+ "react-dom": "~19.2.3",
48
+ "vite": "^8.0.10",
49
+ "@dxos/react-ui": "0.8.4-main.dfabb4ec29",
50
+ "@dxos/storybook-utils": "0.8.4-main.dfabb4ec29",
51
+ "@dxos/ui-theme": "0.8.4-main.dfabb4ec29"
52
52
  },
53
53
  "peerDependencies": {
54
- "react": "~18.2.0",
55
- "react-dom": "~18.2.0",
56
- "@dxos/react-ui": "0.8.4-main.dedc0f3",
57
- "@dxos/react-ui-theme": "0.8.4-main.dedc0f3"
54
+ "react": "~19.2.3",
55
+ "react-dom": "~19.2.3",
56
+ "@dxos/ui-theme": "0.8.4-main.dfabb4ec29",
57
+ "@dxos/react-ui": "0.8.4-main.dfabb4ec29"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -2,16 +2,15 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
5
+ import { RegistryContext } from '@effect-atom/atom-react';
7
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
9
8
 
10
9
  import { Button, Toolbar } from '@dxos/react-ui';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
10
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
+ import { withRegistry } from '@dxos/storybook-utils';
12
12
 
13
13
  import { Gameboard, type GameboardRootProps, type Move, type Player } from '../Gameboard';
14
-
15
14
  import { ChessModel } from './chess';
16
15
  import { Chessboard, type ChessboardProps } from './Chessboard';
17
16
 
@@ -20,7 +19,8 @@ type DefaultStoryProps = Pick<ChessboardProps, 'orientation' | 'showLabels' | 'd
20
19
  };
21
20
 
22
21
  const DefaultStory = ({ orientation: _orientation, pgn, ...props }: DefaultStoryProps) => {
23
- const model = useMemo(() => new ChessModel(pgn), [pgn]);
22
+ const registry = useContext(RegistryContext);
23
+ const model = useMemo(() => new ChessModel(registry, pgn), [registry, pgn]);
24
24
  const [orientation, setOrientation] = useState<Player | undefined>(_orientation);
25
25
 
26
26
  const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
@@ -54,7 +54,8 @@ const DefaultStory = ({ orientation: _orientation, pgn, ...props }: DefaultStory
54
54
  };
55
55
 
56
56
  const GridStory = () => {
57
- const models = useMemo(() => Array.from({ length: 9 }).map(() => new ChessModel()), []);
57
+ const registry = useContext(RegistryContext);
58
+ const models = useMemo(() => Array.from({ length: 9 }).map(() => new ChessModel(registry)), [registry]);
58
59
  useEffect(() => {
59
60
  const i = setInterval(() => {
60
61
  const model = models[Math.floor(Math.random() * models.length)];
@@ -82,7 +83,7 @@ const meta = {
82
83
  title: 'ui/react-ui-gameboard/Chessboard',
83
84
  component: Chessboard,
84
85
  render: DefaultStory,
85
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: '' })],
86
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'column' })],
86
87
  } satisfies Meta<typeof Chessboard>;
87
88
 
88
89
  export default meta;
@@ -107,5 +108,6 @@ export const Debug: Story = {
107
108
  };
108
109
 
109
110
  export const Grid = {
111
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'fullscreen' })],
110
112
  render: GridStory,
111
113
  };
@@ -2,26 +2,35 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { Atom, useAtomValue } from '@effect-atom/atom-react';
5
6
  import React, { type PropsWithChildren, forwardRef, memo, useEffect, useMemo, useRef, useState } from 'react';
6
7
  import { useResizeDetector } from 'react-resize-detector';
7
8
 
8
- import { type ThemedClassName, useForwardedRef, useTrackProps } from '@dxos/react-ui';
9
- import { mx } from '@dxos/react-ui-theme';
10
- import { isNotFalsy } from '@dxos/util';
9
+ import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
10
+ import { mx } from '@dxos/ui-theme';
11
+ import { isNonNullable } from '@dxos/util';
11
12
 
12
13
  import {
13
14
  type DOMRectBounds,
14
15
  Gameboard,
15
16
  type Location,
17
+ type PieceMap,
16
18
  type PieceRecord,
17
19
  type Player,
18
20
  getRelativeBounds,
19
21
  locationToString,
20
22
  useGameboardContext,
21
23
  } from '../Gameboard';
22
-
23
24
  import { type ChessModel, type ChessPiece, ChessPieces, boardStyles, getSquareColor, locationToPos } from './chess';
24
25
 
26
+ /** Fallback atom for when model is undefined. */
27
+ const EMPTY_PIECES_ATOM = Atom.make<PieceMap<ChessPiece>>({});
28
+
29
+ /**
30
+ * Chessboard layout.
31
+ */
32
+ const CHESSBOARD_NAME = 'Chessboard';
33
+
25
34
  export type ChessboardProps = ThemedClassName<
26
35
  PropsWithChildren<{
27
36
  orientation?: Player;
@@ -32,15 +41,12 @@ export type ChessboardProps = ThemedClassName<
32
41
  }>
33
42
  >;
34
43
 
35
- /**
36
- * Chessboard layout.
37
- */
38
44
  const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
39
45
  ({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
40
- useTrackProps({ orientation, showLabels, debug }, Chessboard.displayName, false);
41
46
  const targetRef = useForwardedRef(forwardedRef);
42
47
  const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
43
- const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(Chessboard.displayName!);
48
+ const { model, promoting, onPromotion } = useGameboardContext<ChessModel>(CHESSBOARD_NAME);
49
+ const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
44
50
 
45
51
  // Board squares.
46
52
  const squares = useMemo<Location[]>(() => {
@@ -56,7 +62,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
56
62
  <div
57
63
  key={locationToString(location)}
58
64
  {...{
59
- ['data-location' as const]: locationToString(location),
65
+ 'data-location': locationToString(location),
60
66
  }}
61
67
  />
62
68
  );
@@ -85,7 +91,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
85
91
  return [];
86
92
  }
87
93
 
88
- return Object.values(model?.pieces.value ?? {})
94
+ return Object.values(pieces)
89
95
  .map((piece) => {
90
96
  if (piece.id === promoting?.id) {
91
97
  return null;
@@ -94,11 +100,11 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
94
100
  const bounds = grid[locationToString(piece.location)];
95
101
  return { piece, bounds };
96
102
  })
97
- .filter(isNotFalsy);
98
- }, [grid, model?.pieces.value, promoting]);
103
+ .filter(isNonNullable);
104
+ }, [grid, pieces, promoting]);
99
105
 
100
106
  return (
101
- <div ref={targetRef} tabIndex={0} className={mx('relative outline-none', classNames)}>
107
+ <div ref={targetRef} tabIndex={0} className={mx('dx-expander relative outline-hidden', classNames)}>
102
108
  {/* DOM Layout. */}
103
109
  <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>
104
110
  {layout}
@@ -135,7 +141,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
135
141
  piece={promoting}
136
142
  onSelect={(piece) => {
137
143
  onPromotion({
138
- from: Object.values(model.pieces.value).find((p) => p.id === promoting.id)!.location,
144
+ from: Object.values(pieces).find((p) => p.id === promoting.id)!.location,
139
145
  to: piece.location,
140
146
  piece: promoting.type,
141
147
  promotion: piece.type,
@@ -148,7 +154,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
148
154
  },
149
155
  );
150
156
 
151
- ChessboardComponent.displayName = 'Chessboard';
157
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
152
158
 
153
159
  export const Chessboard = memo(ChessboardComponent);
154
160
 
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type ReadonlySignal, signal } from '@preact/signals-core';
5
+ import { Atom, type Registry } from '@effect-atom/atom-react';
6
6
  import { Chess as ChessJS } from 'chess.js';
7
7
  import { type FC, type SVGProps } from 'react';
8
8
 
@@ -85,15 +85,18 @@ export const createChess = (pgn?: string): ChessJS => {
85
85
  */
86
86
  export class ChessModel implements GameboardModel<ChessPiece> {
87
87
  private readonly _chess = new ChessJS();
88
- private readonly _pieces = signal<PieceMap<ChessPiece>>({});
89
- private readonly _moveIndex = signal(0);
88
+ private readonly _pieces = Atom.make<PieceMap<ChessPiece>>({});
89
+ private readonly _moveIndex = Atom.make(0);
90
90
 
91
- constructor(pgn?: string) {
91
+ constructor(
92
+ private readonly _registry: Registry.Registry,
93
+ pgn?: string,
94
+ ) {
92
95
  this.update(pgn);
93
96
  }
94
97
 
95
98
  get readonly(): boolean {
96
- return this._moveIndex.value !== this._chess.history().length;
99
+ return this._registry.get(this._moveIndex) !== this._chess.history().length;
97
100
  }
98
101
 
99
102
  get turn(): Player {
@@ -104,11 +107,11 @@ export class ChessModel implements GameboardModel<ChessPiece> {
104
107
  return this._chess;
105
108
  }
106
109
 
107
- get pieces(): ReadonlySignal<PieceMap<ChessPiece>> {
110
+ get pieces(): Atom.Atom<PieceMap<ChessPiece>> {
108
111
  return this._pieces;
109
112
  }
110
113
 
111
- get moveIndex(): ReadonlySignal<number> {
114
+ get moveIndex(): Atom.Atom<number> {
112
115
  return this._moveIndex;
113
116
  }
114
117
 
@@ -158,7 +161,7 @@ export class ChessModel implements GameboardModel<ChessPiece> {
158
161
 
159
162
  const current = this._chess.history();
160
163
  if (!isValidNextMove(previous, current)) {
161
- this._pieces.value = {};
164
+ this._registry.set(this._pieces, {});
162
165
  }
163
166
 
164
167
  this._updateBoard(this._chess);
@@ -201,8 +204,8 @@ export class ChessModel implements GameboardModel<ChessPiece> {
201
204
  * Update pieces preserving identity.
202
205
  */
203
206
  private _updateBoard(chess: ChessJS): void {
204
- this._pieces.value = createPieceMap(chess);
205
- this._moveIndex.value = chess.history().length;
207
+ this._registry.set(this._pieces, createPieceMap(chess));
208
+ this._registry.set(this._moveIndex, chess.history().length);
206
209
  }
207
210
  }
208
211
 
@@ -8,13 +8,13 @@ import React, { type PropsWithChildren, forwardRef, useCallback, useEffect, useS
8
8
 
9
9
  import { log } from '@dxos/log';
10
10
  import { type ThemedClassName } from '@dxos/react-ui';
11
- import { mx } from '@dxos/react-ui-theme';
11
+ import { mx } from '@dxos/ui-theme';
12
12
 
13
13
  import { Piece, type PieceProps } from './Piece';
14
14
  import { Square, type SquareProps } from './Square';
15
15
  import { type GameboardModel, type Move, type PieceRecord, isLocation, isPiece } from './types';
16
16
 
17
- export type GameboardContextValue<M extends GameboardModel> = {
17
+ export type GameboardContextValue<M extends GameboardModel<any>> = {
18
18
  model: M;
19
19
  dragging?: boolean; // TODO(burdon): Change to PieceRecord.
20
20
  promoting?: PieceRecord;
@@ -23,7 +23,7 @@ export type GameboardContextValue<M extends GameboardModel> = {
23
23
 
24
24
  const [GameboardContextProvider, useRadixGameboardContext] = createContext<GameboardContextValue<any>>('Gameboard');
25
25
 
26
- const useGameboardContext = <M extends GameboardModel>(consumerName: string): GameboardContextValue<M> => {
26
+ const useGameboardContext = <M extends GameboardModel<any>>(consumerName: string): GameboardContextValue<M> => {
27
27
  return useRadixGameboardContext(consumerName);
28
28
  };
29
29
 
@@ -31,20 +31,19 @@ const useGameboardContext = <M extends GameboardModel>(consumerName: string): Ga
31
31
  // Root
32
32
  //
33
33
 
34
- type GameboardRootProps<M extends GameboardModel> = PropsWithChildren<{
34
+ type GameboardRootProps<M extends GameboardModel<any>> = PropsWithChildren<{
35
35
  model?: M;
36
- moveNumber?: number;
37
36
  onDrop?: (move: Move) => boolean;
38
37
  }>;
39
38
 
40
39
  /**
41
40
  * Generic board container.
42
41
  */
43
- const GameboardRoot = <M extends GameboardModel>({ children, model, moveNumber, onDrop }: GameboardRootProps<M>) => {
42
+ const GameboardRoot = <M extends GameboardModel<any>>({ children, model, onDrop }: GameboardRootProps<M>) => {
44
43
  const [dragging, setDragging] = useState(false);
45
44
  const [promoting, setPromoting] = useState<PieceRecord | undefined>();
46
45
 
47
- const handlePromotion = useCallback<GameboardContextValue<M>['onPromotion']>((move) => {
46
+ const handlePromotion = useCallback<GameboardContextValue<GameboardModel<any>>['onPromotion']>((move) => {
48
47
  log('onPromotion', { move });
49
48
  setPromoting(undefined);
50
49
  onDrop?.(move);
@@ -107,11 +106,10 @@ const GameboardContent = forwardRef<HTMLDivElement, GameboardContentProps>(
107
106
  ({ children, classNames, grow, contain }, forwardedRef) => {
108
107
  return (
109
108
  <div
110
- role='none'
111
- className={mx(grow && 'grid is-full bs-full size-container place-content-center', classNames)}
109
+ className={mx(grow && 'dx-size-container dx-expander grid place-content-center', classNames)}
112
110
  ref={forwardedRef}
113
111
  >
114
- {contain ? <div className='is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]'>{children}</div> : children}
112
+ {contain ? <div className='w-[min(100cqw,100cqh)] h-[min(100cqw,100cqh)]'>{children}</div> : children}
115
113
  </div>
116
114
  );
117
115
  },
@@ -10,8 +10,8 @@ import { createPortal } from 'react-dom';
10
10
 
11
11
  import { invariant } from '@dxos/invariant';
12
12
  import { log } from '@dxos/log';
13
- import { type ThemedClassName, useDynamicRef, useTrackProps } from '@dxos/react-ui';
14
- import { mx } from '@dxos/react-ui-theme';
13
+ import { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';
14
+ import { mx } from '@dxos/ui-theme';
15
15
 
16
16
  import { useGameboardContext } from './Gameboard';
17
17
  import { type Location, type PieceRecord, type Player, isEqualLocation, isLocation } from './types';
@@ -26,9 +26,10 @@ export type PieceProps = ThemedClassName<{
26
26
  onClick?: () => void;
27
27
  }>;
28
28
 
29
- export const Piece = memo(({ classNames, Component, piece, orientation, bounds, label, onClick }: PieceProps) => {
30
- useTrackProps({ classNames, Component, piece, orientation, bounds, label }, Piece.displayName, false);
31
- const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName!);
29
+ const PIECE_NAME = 'Piece';
30
+
31
+ export const Piece = memo(({ classNames, Component, piece, bounds, label, onClick }: PieceProps) => {
32
+ const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
32
33
  const promotingRef = useDynamicRef(promoting);
33
34
  const [dragging, setDragging] = useState(false);
34
35
  const [preview, setPreview] = useState<HTMLElement>();
@@ -135,4 +136,4 @@ export const Piece = memo(({ classNames, Component, piece, orientation, bounds,
135
136
  );
136
137
  });
137
138
 
138
- Piece.displayName = 'Piece';
139
+ Piece.displayName = PIECE_NAME;
@@ -8,7 +8,7 @@ import React, { memo, useEffect, useRef, useState } from 'react';
8
8
  import { invariant } from '@dxos/invariant';
9
9
  import { log } from '@dxos/log';
10
10
  import { type ThemedClassName } from '@dxos/react-ui';
11
- import { mx } from '@dxos/react-ui-theme';
11
+ import { mx } from '@dxos/ui-theme';
12
12
 
13
13
  import { useGameboardContext } from './Gameboard';
14
14
  import { type Location, isPiece } from './types';
@@ -22,10 +22,12 @@ export type SquareProps = ThemedClassName<{
22
22
  label?: string;
23
23
  }>;
24
24
 
25
+ const SQUARE_NAME = 'Square';
26
+
25
27
  export const Square = memo(({ location, bounds, label, classNames }: SquareProps) => {
26
28
  const ref = useRef<HTMLDivElement>(null);
27
29
  const [state, setState] = useState<HoveredState>('idle');
28
- const { model } = useGameboardContext(Square.displayName!);
30
+ const { model } = useGameboardContext(SQUARE_NAME);
29
31
 
30
32
  useEffect(() => {
31
33
  const el = ref.current;
@@ -71,4 +73,4 @@ export const Square = memo(({ location, bounds, label, classNames }: SquareProps
71
73
  );
72
74
  });
73
75
 
74
- Square.displayName = 'Square';
76
+ Square.displayName = SQUARE_NAME;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type ReadonlySignal } from '@preact/signals-core';
5
+ import { type Atom } from '@effect-atom/atom-react';
6
6
 
7
7
  // TODO(burdon): Don't make this assumption.
8
8
  export type Player = 'black' | 'white';
@@ -54,8 +54,7 @@ export const isEqualLocation = (l1: Location, l2: Location): boolean => l1[0] ==
54
54
  export interface GameboardModel<T extends PieceType = PieceType> {
55
55
  readonly: boolean;
56
56
  turn: Player;
57
- /** @reactive */
58
- pieces: ReadonlySignal<PieceMap<T>>;
57
+ pieces: Atom.Atom<PieceMap<T>>;
59
58
  isValidMove: (move: Move) => boolean;
60
59
  canPromote?: (move: Move) => boolean;
61
60
  }