@dxos/react-ui-gameboard 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc

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/LICENSE +102 -5
  2. package/README.md +2 -0
  3. package/dist/lib/browser/index.mjs +497 -679
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/node-esm/index.mjs +497 -679
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/types/src/components/Chessboard/Chessboard.d.ts +2 -2
  10. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  11. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +2 -1
  12. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  13. package/dist/types/src/components/Chessboard/chess.d.ts +5 -4
  14. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -1
  15. package/dist/types/src/components/Gameboard/Gameboard.d.ts +10 -7
  16. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +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 +27 -27
  48. package/src/components/Chessboard/Chessboard.stories.tsx +9 -5
  49. package/src/components/Chessboard/Chessboard.tsx +19 -12
  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 +5 -3
  53. package/src/components/Gameboard/Square.tsx +5 -3
  54. package/src/components/Gameboard/types.ts +2 -3
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-gameboard",
3
- "version": "0.8.4-main.ae835ea",
3
+ "version": "0.8.4-main.bc2380dfbc",
4
4
  "description": "Game board.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
- "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "FSL-1.1-Apache-2.0",
8
12
  "author": "DXOS.org",
9
13
  "type": "module",
10
14
  "exports": {
@@ -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.12.1",
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.ae835ea",
35
- "@dxos/invariant": "0.8.4-main.ae835ea",
36
- "@dxos/node-std": "0.8.4-main.ae835ea",
37
- "@dxos/util": "0.8.4-main.ae835ea",
38
- "@dxos/log": "0.8.4-main.ae835ea"
34
+ "@dxos/debug": "0.8.4-main.bc2380dfbc",
35
+ "@dxos/invariant": "0.8.4-main.bc2380dfbc",
36
+ "@dxos/log": "0.8.4-main.bc2380dfbc",
37
+ "@dxos/util": "0.8.4-main.bc2380dfbc",
38
+ "@dxos/node-std": "0.8.4-main.bc2380dfbc"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@svgr/cli": "^8.1.0",
42
42
  "@types/lodash.defaultsdeep": "^4.6.6",
43
- "@types/react": "~19.2.2",
44
- "@types/react-dom": "~19.2.2",
43
+ "@types/react": "~19.2.7",
44
+ "@types/react-dom": "~19.2.3",
45
45
  "lodash.defaultsdeep": "^4.6.1",
46
- "react": "~19.2.0",
47
- "react-dom": "~19.2.0",
48
- "vite": "7.1.9",
49
- "@dxos/react-ui": "0.8.4-main.ae835ea",
50
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
51
- "@dxos/storybook-utils": "0.8.4-main.ae835ea"
46
+ "react": "~19.2.3",
47
+ "react-dom": "~19.2.3",
48
+ "vite": "^8.0.13",
49
+ "@dxos/storybook-utils": "0.8.4-main.bc2380dfbc",
50
+ "@dxos/ui-theme": "0.8.4-main.bc2380dfbc",
51
+ "@dxos/react-ui": "0.8.4-main.bc2380dfbc"
52
52
  },
53
53
  "peerDependencies": {
54
- "react": "^19.0.0",
55
- "react-dom": "^19.0.0",
56
- "@dxos/react-ui": "0.8.4-main.ae835ea",
57
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea"
54
+ "react": "~19.2.3",
55
+ "react-dom": "~19.2.3",
56
+ "@dxos/react-ui": "0.8.4-main.bc2380dfbc",
57
+ "@dxos/ui-theme": "0.8.4-main.bc2380dfbc"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
@@ -2,14 +2,15 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { RegistryContext } from '@effect-atom/atom-react';
5
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
7
8
 
8
9
  import { Button, Toolbar } from '@dxos/react-ui';
9
10
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
+ import { withRegistry } from '@dxos/storybook-utils';
10
12
 
11
13
  import { Gameboard, type GameboardRootProps, type Move, type Player } from '../Gameboard';
12
-
13
14
  import { ChessModel } from './chess';
14
15
  import { Chessboard, type ChessboardProps } from './Chessboard';
15
16
 
@@ -18,7 +19,8 @@ type DefaultStoryProps = Pick<ChessboardProps, 'orientation' | 'showLabels' | 'd
18
19
  };
19
20
 
20
21
  const DefaultStory = ({ orientation: _orientation, pgn, ...props }: DefaultStoryProps) => {
21
- const model = useMemo(() => new ChessModel(pgn), [pgn]);
22
+ const registry = useContext(RegistryContext);
23
+ const model = useMemo(() => new ChessModel(registry, pgn), [registry, pgn]);
22
24
  const [orientation, setOrientation] = useState<Player | undefined>(_orientation);
23
25
 
24
26
  const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(
@@ -52,7 +54,8 @@ const DefaultStory = ({ orientation: _orientation, pgn, ...props }: DefaultStory
52
54
  };
53
55
 
54
56
  const GridStory = () => {
55
- 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]);
56
59
  useEffect(() => {
57
60
  const i = setInterval(() => {
58
61
  const model = models[Math.floor(Math.random() * models.length)];
@@ -80,7 +83,7 @@ const meta = {
80
83
  title: 'ui/react-ui-gameboard/Chessboard',
81
84
  component: Chessboard,
82
85
  render: DefaultStory,
83
- decorators: [withTheme, withLayout({ container: 'column' })],
86
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'column' })],
84
87
  } satisfies Meta<typeof Chessboard>;
85
88
 
86
89
  export default meta;
@@ -105,5 +108,6 @@ export const Debug: Story = {
105
108
  };
106
109
 
107
110
  export const Grid = {
111
+ decorators: [withRegistry, withTheme(), withLayout({ layout: 'fullscreen' })],
108
112
  render: GridStory,
109
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
9
  import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
9
- import { mx } from '@dxos/react-ui-theme';
10
+ import { mx } from '@dxos/ui-theme';
10
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,14 +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
46
  const targetRef = useForwardedRef(forwardedRef);
41
47
  const { width, height } = useResizeDetector({ targetRef, refreshRate: 200 });
42
- 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);
43
50
 
44
51
  // Board squares.
45
52
  const squares = useMemo<Location[]>(() => {
@@ -55,7 +62,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
55
62
  <div
56
63
  key={locationToString(location)}
57
64
  {...{
58
- ['data-location' as const]: locationToString(location),
65
+ 'data-location': locationToString(location),
59
66
  }}
60
67
  />
61
68
  );
@@ -84,7 +91,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
84
91
  return [];
85
92
  }
86
93
 
87
- return Object.values(model?.pieces.value ?? {})
94
+ return Object.values(pieces)
88
95
  .map((piece) => {
89
96
  if (piece.id === promoting?.id) {
90
97
  return null;
@@ -94,10 +101,10 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
94
101
  return { piece, bounds };
95
102
  })
96
103
  .filter(isNonNullable);
97
- }, [grid, model?.pieces.value, promoting]);
104
+ }, [grid, pieces, promoting]);
98
105
 
99
106
  return (
100
- <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)}>
101
108
  {/* DOM Layout. */}
102
109
  <div ref={gridRef} className='grid grid-rows-8 grid-cols-8 aspect-square select-none'>
103
110
  {layout}
@@ -134,7 +141,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
134
141
  piece={promoting}
135
142
  onSelect={(piece) => {
136
143
  onPromotion({
137
- 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,
138
145
  to: piece.location,
139
146
  piece: promoting.type,
140
147
  promotion: piece.type,
@@ -147,7 +154,7 @@ const ChessboardComponent = forwardRef<HTMLDivElement, ChessboardProps>(
147
154
  },
148
155
  );
149
156
 
150
- ChessboardComponent.displayName = 'Chessboard';
157
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
151
158
 
152
159
  export const Chessboard = memo(ChessboardComponent);
153
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
  },
@@ -11,7 +11,7 @@ import { createPortal } from 'react-dom';
11
11
  import { invariant } from '@dxos/invariant';
12
12
  import { log } from '@dxos/log';
13
13
  import { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';
14
- import { mx } from '@dxos/react-ui-theme';
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,8 +26,10 @@ export type PieceProps = ThemedClassName<{
26
26
  onClick?: () => void;
27
27
  }>;
28
28
 
29
+ const PIECE_NAME = 'Piece';
30
+
29
31
  export const Piece = memo(({ classNames, Component, piece, bounds, label, onClick }: PieceProps) => {
30
- const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName!);
32
+ const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
31
33
  const promotingRef = useDynamicRef(promoting);
32
34
  const [dragging, setDragging] = useState(false);
33
35
  const [preview, setPreview] = useState<HTMLElement>();
@@ -134,4 +136,4 @@ export const Piece = memo(({ classNames, Component, piece, bounds, label, onClic
134
136
  );
135
137
  });
136
138
 
137
- 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
  }