@dxos/react-ui-gameboard 0.10.0 → 0.11.0
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/index.mjs +854 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/src/components/Chessboard/chess.d.ts +1 -1
- package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -1
- package/dist/types/src/components/Gameboard/Gameboard.d.ts +1 -9
- package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -1
- package/dist/types/src/components/Gameboard/GameboardContext.d.ts +12 -0
- package/dist/types/src/components/Gameboard/GameboardContext.d.ts.map +1 -0
- package/dist/types/src/components/Gameboard/index.d.ts +1 -0
- package/dist/types/src/components/Gameboard/index.d.ts.map +1 -1
- package/dist/types/src/components/Gameboard/types.d.ts +1 -1
- package/dist/types/src/components/Gameboard/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/components/Chessboard/chess.ts +2 -2
- package/src/components/Gameboard/Gameboard.tsx +1 -16
- package/src/components/Gameboard/GameboardContext.ts +24 -0
- package/src/components/Gameboard/Piece.tsx +1 -1
- package/src/components/Gameboard/Square.tsx +1 -1
- package/src/components/Gameboard/index.ts +2 -0
- package/src/components/Gameboard/types.ts +1 -1
- package/dist/lib/browser/index.mjs +0 -913
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -914
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-gameboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Game board.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
".": {
|
|
16
16
|
"source": "./src/index.ts",
|
|
17
17
|
"types": "./dist/types/src/index.d.ts",
|
|
18
|
-
"
|
|
19
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
18
|
+
"import": "./dist/lib/index.mjs"
|
|
20
19
|
}
|
|
21
20
|
},
|
|
22
21
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -27,15 +26,16 @@
|
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
29
28
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
29
|
+
"@effect-atom/atom": "^0.5.3",
|
|
30
30
|
"@effect-atom/atom-react": "^0.5.0",
|
|
31
31
|
"@radix-ui/react-context": "1.1.1",
|
|
32
32
|
"chess.js": "^1.0.0",
|
|
33
33
|
"react-resize-detector": "^11.0.1",
|
|
34
|
-
"@dxos/debug": "0.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
34
|
+
"@dxos/debug": "0.11.0",
|
|
35
|
+
"@dxos/log": "0.11.0",
|
|
36
|
+
"@dxos/node-std": "0.11.0",
|
|
37
|
+
"@dxos/util": "0.11.0",
|
|
38
|
+
"@dxos/invariant": "0.11.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@svgr/cli": "^8.1.0",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"lodash.defaultsdeep": "^4.6.1",
|
|
46
46
|
"react": "~19.2.7",
|
|
47
47
|
"react-dom": "~19.2.7",
|
|
48
|
-
"vite": "^8.
|
|
49
|
-
"@dxos/react-ui": "0.
|
|
50
|
-
"@dxos/storybook-utils": "0.
|
|
51
|
-
"@dxos/ui-theme": "0.
|
|
48
|
+
"vite": "^8.1.4",
|
|
49
|
+
"@dxos/react-ui": "0.11.0",
|
|
50
|
+
"@dxos/storybook-utils": "0.11.0",
|
|
51
|
+
"@dxos/ui-theme": "0.11.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "~19.2.7",
|
|
55
55
|
"react-dom": "~19.2.7",
|
|
56
|
-
"@dxos/react-ui": "0.
|
|
57
|
-
"@dxos/ui-theme": "0.
|
|
56
|
+
"@dxos/react-ui": "^0.11.0",
|
|
57
|
+
"@dxos/ui-theme": "^0.11.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Atom, type Registry } from '@effect-atom/atom
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom';
|
|
6
6
|
import { Chess as ChessJS } from 'chess.js';
|
|
7
7
|
import { type FC, type SVGProps } from 'react';
|
|
8
8
|
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
|
|
12
|
-
import * as Alpha from '../../gen/pieces/chess/alpha';
|
|
12
|
+
import * as Alpha from '../../gen/pieces/chess/alpha/index';
|
|
13
13
|
import {
|
|
14
14
|
type GameboardModel,
|
|
15
15
|
type Location,
|
|
@@ -3,30 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
6
|
-
import { createContext } from '@radix-ui/react-context';
|
|
7
6
|
import React, { type PropsWithChildren, forwardRef, useCallback, useEffect, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { log } from '@dxos/log';
|
|
10
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
10
|
import { mx } from '@dxos/ui-theme';
|
|
12
11
|
|
|
12
|
+
import { GameboardContextProvider, type GameboardContextValue } from './GameboardContext';
|
|
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<any>> = {
|
|
18
|
-
model: M;
|
|
19
|
-
dragging?: boolean; // TODO(burdon): Change to PieceRecord.
|
|
20
|
-
promoting?: PieceRecord;
|
|
21
|
-
onPromotion: (move: Move) => void;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const [GameboardContextProvider, useRadixGameboardContext] = createContext<GameboardContextValue<any>>('Gameboard');
|
|
25
|
-
|
|
26
|
-
const useGameboardContext = <M extends GameboardModel<any>>(consumerName: string): GameboardContextValue<M> => {
|
|
27
|
-
return useRadixGameboardContext(consumerName);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
17
|
//
|
|
31
18
|
// Root
|
|
32
19
|
//
|
|
@@ -128,8 +115,6 @@ export const Gameboard = {
|
|
|
128
115
|
Square,
|
|
129
116
|
};
|
|
130
117
|
|
|
131
|
-
export { useGameboardContext };
|
|
132
|
-
|
|
133
118
|
export type {
|
|
134
119
|
GameboardContentProps,
|
|
135
120
|
PieceProps as GameboardPieceProps,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext } from '@radix-ui/react-context';
|
|
6
|
+
|
|
7
|
+
import { type GameboardModel, type Move, type PieceRecord } from './types';
|
|
8
|
+
|
|
9
|
+
// Kept out of `Gameboard.tsx`: react-refresh only fast-refreshes a module whose exports are all
|
|
10
|
+
// components, so a context and its hook exported beside them force a full page reload on every edit.
|
|
11
|
+
|
|
12
|
+
export type GameboardContextValue<M extends GameboardModel<any>> = {
|
|
13
|
+
model: M;
|
|
14
|
+
dragging?: boolean; // TODO(burdon): Change to PieceRecord.
|
|
15
|
+
promoting?: PieceRecord;
|
|
16
|
+
onPromotion: (move: Move) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const [GameboardContextProvider, useRadixGameboardContext] =
|
|
20
|
+
createContext<GameboardContextValue<any>>('Gameboard');
|
|
21
|
+
|
|
22
|
+
export const useGameboardContext = <M extends GameboardModel<any>>(consumerName: string): GameboardContextValue<M> => {
|
|
23
|
+
return useRadixGameboardContext(consumerName);
|
|
24
|
+
};
|
|
@@ -13,7 +13,7 @@ import { log } from '@dxos/log';
|
|
|
13
13
|
import { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';
|
|
14
14
|
import { mx } from '@dxos/ui-theme';
|
|
15
15
|
|
|
16
|
-
import { useGameboardContext } from './
|
|
16
|
+
import { useGameboardContext } from './GameboardContext';
|
|
17
17
|
import { type Location, type PieceRecord, type Player, isEqualLocation, isLocation } from './types';
|
|
18
18
|
import { type DOMRectBounds } from './util';
|
|
19
19
|
|
|
@@ -10,7 +10,7 @@ import { log } from '@dxos/log';
|
|
|
10
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
import { useGameboardContext } from './
|
|
13
|
+
import { useGameboardContext } from './GameboardContext';
|
|
14
14
|
import { type Location, isPiece } from './types';
|
|
15
15
|
import { type DOMRectBounds } from './util';
|
|
16
16
|
|