react-native-chess-kit 0.4.2 → 0.5.1

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 (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +168 -168
  3. package/lib/commonjs/board-annotations.js +8 -8
  4. package/lib/commonjs/board-arrows.js +7 -7
  5. package/lib/commonjs/board-background.js +5 -5
  6. package/lib/commonjs/board-coordinates.js +78 -11
  7. package/lib/commonjs/board-coordinates.js.map +1 -1
  8. package/lib/commonjs/board-drag-ghost.js +10 -10
  9. package/lib/commonjs/board-highlights.js +15 -15
  10. package/lib/commonjs/board-legal-dots.js +5 -5
  11. package/lib/commonjs/board-piece.js +25 -25
  12. package/lib/commonjs/board-pieces.js +6 -6
  13. package/lib/commonjs/board.js +76 -35
  14. package/lib/commonjs/board.js.map +1 -1
  15. package/lib/commonjs/constants.js +4 -1
  16. package/lib/commonjs/constants.js.map +1 -1
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/promotion-picker.js +8 -8
  19. package/lib/commonjs/static-board.js +51 -16
  20. package/lib/commonjs/static-board.js.map +1 -1
  21. package/lib/commonjs/use-board-gesture.js +52 -33
  22. package/lib/commonjs/use-board-gesture.js.map +1 -1
  23. package/lib/commonjs/use-board-pieces.js +15 -15
  24. package/lib/commonjs/use-board-state.js +8 -8
  25. package/lib/commonjs/use-premove.js +12 -12
  26. package/lib/module/board-annotations.js +8 -8
  27. package/lib/module/board-arrows.js +7 -7
  28. package/lib/module/board-background.js +5 -5
  29. package/lib/module/board-coordinates.js +79 -12
  30. package/lib/module/board-coordinates.js.map +1 -1
  31. package/lib/module/board-drag-ghost.js +10 -10
  32. package/lib/module/board-highlights.js +15 -15
  33. package/lib/module/board-legal-dots.js +5 -5
  34. package/lib/module/board-piece.js +25 -25
  35. package/lib/module/board-pieces.js +6 -6
  36. package/lib/module/board.js +77 -36
  37. package/lib/module/board.js.map +1 -1
  38. package/lib/module/constants.js +3 -0
  39. package/lib/module/constants.js.map +1 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/promotion-picker.js +8 -8
  42. package/lib/module/static-board.js +52 -17
  43. package/lib/module/static-board.js.map +1 -1
  44. package/lib/module/use-board-gesture.js +52 -33
  45. package/lib/module/use-board-gesture.js.map +1 -1
  46. package/lib/module/use-board-pieces.js +15 -15
  47. package/lib/module/use-board-state.js +8 -8
  48. package/lib/module/use-premove.js +12 -12
  49. package/lib/typescript/board-coordinates.d.ts +10 -4
  50. package/lib/typescript/board-coordinates.d.ts.map +1 -1
  51. package/lib/typescript/board.d.ts.map +1 -1
  52. package/lib/typescript/constants.d.ts +2 -0
  53. package/lib/typescript/constants.d.ts.map +1 -1
  54. package/lib/typescript/index.d.ts +1 -1
  55. package/lib/typescript/index.d.ts.map +1 -1
  56. package/lib/typescript/static-board.d.ts.map +1 -1
  57. package/lib/typescript/types.d.ts +23 -3
  58. package/lib/typescript/types.d.ts.map +1 -1
  59. package/lib/typescript/use-board-gesture.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/board-annotations.tsx +147 -147
  62. package/src/board-arrows.tsx +197 -197
  63. package/src/board-background.tsx +46 -46
  64. package/src/board-coordinates.tsx +192 -98
  65. package/src/board-drag-ghost.tsx +132 -132
  66. package/src/board-highlights.tsx +226 -226
  67. package/src/board-legal-dots.tsx +73 -73
  68. package/src/board-piece.tsx +160 -160
  69. package/src/board-pieces.tsx +63 -63
  70. package/src/board.tsx +685 -641
  71. package/src/constants.ts +103 -100
  72. package/src/index.ts +101 -100
  73. package/src/pieces/default-pieces.tsx +383 -383
  74. package/src/pieces/index.ts +1 -1
  75. package/src/promotion-picker.tsx +147 -147
  76. package/src/static-board.tsx +187 -150
  77. package/src/themes.ts +129 -129
  78. package/src/types.ts +373 -352
  79. package/src/use-board-gesture.ts +429 -412
  80. package/src/use-board-pieces.ts +158 -158
  81. package/src/use-board-state.ts +111 -111
  82. package/src/use-premove.ts +59 -59
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 anas-asghar4831
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 anas-asghar4831
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,168 +1,168 @@
1
- # react-native-chess-kit
2
-
3
- High-performance chess board for React Native. Built for 60fps on budget Android devices.
4
-
5
- ## Performance
6
-
7
- | Metric | react-native-chess-kit | expo-chessboard |
8
- |--------|----------------------|-----------------|
9
- | Gesture handlers | 1 (centralized) | 32 (one per piece) |
10
- | Mounted components | ~40 | ~281 |
11
- | Native views | ~75 | ~470 |
12
- | React Context providers | 0 | 8 |
13
- | Re-renders during drag | 0 | Per-frame |
14
-
15
- Zero React re-renders during drag -- all animation runs on the UI thread via Reanimated worklets. Pieces animate only `transform` + `opacity` (Reanimated's fast path). Stable piece IDs survive position changes without unmount/remount cycles.
16
-
17
- ## Installation
18
-
19
- ```bash
20
- npm install react-native-chess-kit
21
- ```
22
-
23
- ### Peer dependencies
24
-
25
- ```bash
26
- npm install react-native-reanimated react-native-gesture-handler chess.js
27
- ```
28
-
29
- | Package | Version |
30
- |---------|---------|
31
- | react-native-reanimated | >= 3.0.0 |
32
- | react-native-gesture-handler | >= 2.0.0 |
33
- | chess.js | >= 1.0.0 |
34
- | react | >= 18.0.0 |
35
- | react-native | >= 0.70.0 |
36
-
37
- ## Usage
38
-
39
- ```tsx
40
- import { useRef } from 'react';
41
- import { Board } from 'react-native-chess-kit';
42
- import type { BoardRef } from 'react-native-chess-kit';
43
-
44
- function ChessScreen() {
45
- const boardRef = useRef<BoardRef>(null);
46
-
47
- return (
48
- <Board
49
- ref={boardRef}
50
- fen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
51
- orientation="white"
52
- boardSize={360}
53
- gestureEnabled={true}
54
- player="white"
55
- colors={{ light: '#eeeed2', dark: '#769656' }}
56
- moveDuration={200}
57
- withLetters={true}
58
- withNumbers={true}
59
- showLegalMoves={true}
60
- moveMethod="both"
61
- onMove={({ from, to }) => {
62
- console.log(`Moved from ${from} to ${to}`);
63
- }}
64
- />
65
- );
66
- }
67
- ```
68
-
69
- ## Props
70
-
71
- | Prop | Type | Default | Description |
72
- |------|------|---------|-------------|
73
- | `fen` | `string` | required | Board position in FEN notation |
74
- | `orientation` | `'white' \| 'black'` | required | Which color is at the bottom |
75
- | `boardSize` | `number` | required | Board width/height in pixels |
76
- | `gestureEnabled` | `boolean` | required | Whether touch interaction is enabled |
77
- | `player` | `'white' \| 'black' \| 'both'` | required | Which side can move pieces |
78
- | `colors` | `{ light: string, dark: string }` | required | Square colors |
79
- | `moveDuration` | `number` | required | Animation duration in ms (0 = instant) |
80
- | `withLetters` | `boolean` | required | Show file labels (a-h) |
81
- | `withNumbers` | `boolean` | required | Show rank numbers (1-8) |
82
- | `showLegalMoves` | `boolean` | required | Show legal move dots on piece selection |
83
- | `moveMethod` | `'drag' \| 'click' \| 'both'` | required | How the user moves pieces |
84
- | `onMove` | `(info: { from, to }) => void` | optional | Called after a move gesture completes |
85
- | `renderPiece` | `(code, size) => ReactElement` | optional | Custom piece renderer |
86
-
87
- ## Ref API
88
-
89
- ```ts
90
- const boardRef = useRef<BoardRef>(null);
91
-
92
- // Programmatic move (e.g. opponent's move, puzzle auto-play)
93
- boardRef.current?.move({ from: 'e2', to: 'e4' });
94
-
95
- // Highlight a square
96
- boardRef.current?.highlight('e4', 'rgba(255, 255, 0, 0.5)');
97
-
98
- // Clear all highlights
99
- boardRef.current?.clearHighlights();
100
-
101
- // Reset to a new position
102
- boardRef.current?.resetBoard('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
103
-
104
- // Undo the last visual move (snap back)
105
- boardRef.current?.undo();
106
- ```
107
-
108
- ## Custom Piece Rendering
109
-
110
- Use `renderPiece` to provide your own piece images:
111
-
112
- ```tsx
113
- import { Image } from 'expo-image';
114
-
115
- const PIECE_IMAGES = {
116
- wp: require('./assets/pieces/wp.png'),
117
- wn: require('./assets/pieces/wn.png'),
118
- // ... etc
119
- };
120
-
121
- <Board
122
- renderPiece={(code, size) => (
123
- <Image
124
- source={PIECE_IMAGES[code]}
125
- style={{ width: size, height: size }}
126
- cachePolicy="memory-disk"
127
- />
128
- )}
129
- // ... other props
130
- />
131
- ```
132
-
133
- ## Exports
134
-
135
- ```ts
136
- // Component
137
- export { Board } from 'react-native-chess-kit';
138
-
139
- // Types
140
- export type {
141
- BoardRef,
142
- BoardProps,
143
- BoardColors,
144
- BoardPiece,
145
- ChessColor,
146
- MoveMethod,
147
- GestureState,
148
- LegalMoveTarget,
149
- ParsedPiece,
150
- } from 'react-native-chess-kit';
151
-
152
- // Utilities (useful for overlay positioning)
153
- export { squareToXY, xyToSquare } from 'react-native-chess-kit';
154
- ```
155
-
156
- ## Architecture
157
-
158
- The board follows the chess.com / lichess pattern:
159
-
160
- - **Single gesture handler** at the board level (not per-piece)
161
- - **Reanimated shared values** for drag state (zero JS thread work during drag)
162
- - **Stable piece IDs** via smart FEN diffing (pieces survive position changes)
163
- - **chess.js** for internal legal move validation
164
- - **Worklet-only animation** using transform + opacity (Reanimated fast path)
165
-
166
- ## License
167
-
168
- MIT
1
+ # react-native-chess-kit
2
+
3
+ High-performance chess board for React Native. Built for 60fps on budget Android devices.
4
+
5
+ ## Performance
6
+
7
+ | Metric | react-native-chess-kit | expo-chessboard |
8
+ |--------|----------------------|-----------------|
9
+ | Gesture handlers | 1 (centralized) | 32 (one per piece) |
10
+ | Mounted components | ~40 | ~281 |
11
+ | Native views | ~75 | ~470 |
12
+ | React Context providers | 0 | 8 |
13
+ | Re-renders during drag | 0 | Per-frame |
14
+
15
+ Zero React re-renders during drag -- all animation runs on the UI thread via Reanimated worklets. Pieces animate only `transform` + `opacity` (Reanimated's fast path). Stable piece IDs survive position changes without unmount/remount cycles.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install react-native-chess-kit
21
+ ```
22
+
23
+ ### Peer dependencies
24
+
25
+ ```bash
26
+ npm install react-native-reanimated react-native-gesture-handler chess.js
27
+ ```
28
+
29
+ | Package | Version |
30
+ |---------|---------|
31
+ | react-native-reanimated | >= 3.0.0 |
32
+ | react-native-gesture-handler | >= 2.0.0 |
33
+ | chess.js | >= 1.0.0 |
34
+ | react | >= 18.0.0 |
35
+ | react-native | >= 0.70.0 |
36
+
37
+ ## Usage
38
+
39
+ ```tsx
40
+ import { useRef } from 'react';
41
+ import { Board } from 'react-native-chess-kit';
42
+ import type { BoardRef } from 'react-native-chess-kit';
43
+
44
+ function ChessScreen() {
45
+ const boardRef = useRef<BoardRef>(null);
46
+
47
+ return (
48
+ <Board
49
+ ref={boardRef}
50
+ fen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
51
+ orientation="white"
52
+ boardSize={360}
53
+ gestureEnabled={true}
54
+ player="white"
55
+ colors={{ light: '#eeeed2', dark: '#769656' }}
56
+ moveDuration={200}
57
+ withLetters={true}
58
+ withNumbers={true}
59
+ showLegalMoves={true}
60
+ moveMethod="both"
61
+ onMove={({ from, to }) => {
62
+ console.log(`Moved from ${from} to ${to}`);
63
+ }}
64
+ />
65
+ );
66
+ }
67
+ ```
68
+
69
+ ## Props
70
+
71
+ | Prop | Type | Default | Description |
72
+ |------|------|---------|-------------|
73
+ | `fen` | `string` | required | Board position in FEN notation |
74
+ | `orientation` | `'white' \| 'black'` | required | Which color is at the bottom |
75
+ | `boardSize` | `number` | required | Board width/height in pixels |
76
+ | `gestureEnabled` | `boolean` | required | Whether touch interaction is enabled |
77
+ | `player` | `'white' \| 'black' \| 'both'` | required | Which side can move pieces |
78
+ | `colors` | `{ light: string, dark: string }` | required | Square colors |
79
+ | `moveDuration` | `number` | required | Animation duration in ms (0 = instant) |
80
+ | `withLetters` | `boolean` | required | Show file labels (a-h) |
81
+ | `withNumbers` | `boolean` | required | Show rank numbers (1-8) |
82
+ | `showLegalMoves` | `boolean` | required | Show legal move dots on piece selection |
83
+ | `moveMethod` | `'drag' \| 'click' \| 'both'` | required | How the user moves pieces |
84
+ | `onMove` | `(info: { from, to }) => void` | optional | Called after a move gesture completes |
85
+ | `renderPiece` | `(code, size) => ReactElement` | optional | Custom piece renderer |
86
+
87
+ ## Ref API
88
+
89
+ ```ts
90
+ const boardRef = useRef<BoardRef>(null);
91
+
92
+ // Programmatic move (e.g. opponent's move, puzzle auto-play)
93
+ boardRef.current?.move({ from: 'e2', to: 'e4' });
94
+
95
+ // Highlight a square
96
+ boardRef.current?.highlight('e4', 'rgba(255, 255, 0, 0.5)');
97
+
98
+ // Clear all highlights
99
+ boardRef.current?.clearHighlights();
100
+
101
+ // Reset to a new position
102
+ boardRef.current?.resetBoard('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
103
+
104
+ // Undo the last visual move (snap back)
105
+ boardRef.current?.undo();
106
+ ```
107
+
108
+ ## Custom Piece Rendering
109
+
110
+ Use `renderPiece` to provide your own piece images:
111
+
112
+ ```tsx
113
+ import { Image } from 'expo-image';
114
+
115
+ const PIECE_IMAGES = {
116
+ wp: require('./assets/pieces/wp.png'),
117
+ wn: require('./assets/pieces/wn.png'),
118
+ // ... etc
119
+ };
120
+
121
+ <Board
122
+ renderPiece={(code, size) => (
123
+ <Image
124
+ source={PIECE_IMAGES[code]}
125
+ style={{ width: size, height: size }}
126
+ cachePolicy="memory-disk"
127
+ />
128
+ )}
129
+ // ... other props
130
+ />
131
+ ```
132
+
133
+ ## Exports
134
+
135
+ ```ts
136
+ // Component
137
+ export { Board } from 'react-native-chess-kit';
138
+
139
+ // Types
140
+ export type {
141
+ BoardRef,
142
+ BoardProps,
143
+ BoardColors,
144
+ BoardPiece,
145
+ ChessColor,
146
+ MoveMethod,
147
+ GestureState,
148
+ LegalMoveTarget,
149
+ ParsedPiece,
150
+ } from 'react-native-chess-kit';
151
+
152
+ // Utilities (useful for overlay positioning)
153
+ export { squareToXY, xyToSquare } from 'react-native-chess-kit';
154
+ ```
155
+
156
+ ## Architecture
157
+
158
+ The board follows the chess.com / lichess pattern:
159
+
160
+ - **Single gesture handler** at the board level (not per-piece)
161
+ - **Reanimated shared values** for drag state (zero JS thread work during drag)
162
+ - **Stable piece IDs** via smart FEN diffing (pieces survive position changes)
163
+ - **chess.js** for internal legal move validation
164
+ - **Worklet-only animation** using transform + opacity (Reanimated fast path)
165
+
166
+ ## License
167
+
168
+ MIT
@@ -18,11 +18,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
18
18
  // Annotations layer
19
19
  // ---------------------------------------------------------------------------
20
20
 
21
- /**
22
- * Text annotation badges on chess squares (!, ?, !!, ??, etc.).
23
- *
24
- * Each annotation appears as a small colored badge at the top-right
25
- * corner of the target square. Positioned absolutely, pointer-events none.
21
+ /**
22
+ * Text annotation badges on chess squares (!, ?, !!, ??, etc.).
23
+ *
24
+ * Each annotation appears as a small colored badge at the top-right
25
+ * corner of the target square. Positioned absolutely, pointer-events none.
26
26
  */
27
27
  const BoardAnnotations = exports.BoardAnnotations = /*#__PURE__*/_react.default.memo(function BoardAnnotations({
28
28
  boardSize,
@@ -81,9 +81,9 @@ const BoardAnnotations = exports.BoardAnnotations = /*#__PURE__*/_react.default.
81
81
  // Standalone export for advanced consumers
82
82
  // ---------------------------------------------------------------------------
83
83
 
84
- /**
85
- * Single annotation badge component.
86
- * Exported for consumers who build their own overlay layers.
84
+ /**
85
+ * Single annotation badge component.
86
+ * Exported for consumers who build their own overlay layers.
87
87
  */
88
88
  const Annotation = exports.Annotation = /*#__PURE__*/_react.default.memo(function Annotation({
89
89
  square,
@@ -52,13 +52,13 @@ function calculateArrowPath(from, to, shortenBy) {
52
52
  // Combined arrows + shapes SVG layer
53
53
  // ---------------------------------------------------------------------------
54
54
 
55
- /**
56
- * SVG overlay for arrows and shapes drawn on the board.
57
- *
58
- * Uses a percentage-based 100x100 viewBox so coordinates map cleanly
59
- * to the 8x8 grid (each square = 12.5 x 12.5 units).
60
- *
61
- * Renders above the pieces layer so arrows are always visible.
55
+ /**
56
+ * SVG overlay for arrows and shapes drawn on the board.
57
+ *
58
+ * Uses a percentage-based 100x100 viewBox so coordinates map cleanly
59
+ * to the 8x8 grid (each square = 12.5 x 12.5 units).
60
+ *
61
+ * Renders above the pieces layer so arrows are always visible.
62
62
  */
63
63
  const BoardArrows = exports.BoardArrows = /*#__PURE__*/_react.default.memo(function BoardArrows({
64
64
  boardSize,
@@ -8,11 +8,11 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- /**
12
- * 64 static colored squares forming the chess board grid.
13
- *
14
- * These are plain Views with backgroundColor — no animations, no gesture
15
- * handlers. They never re-render after mount unless the board theme changes.
11
+ /**
12
+ * 64 static colored squares forming the chess board grid.
13
+ *
14
+ * These are plain Views with backgroundColor — no animations, no gesture
15
+ * handlers. They never re-render after mount unless the board theme changes.
16
16
  */
17
17
  const BoardBackground = exports.BoardBackground = /*#__PURE__*/_react.default.memo(function BoardBackground({
18
18
  boardSize,
@@ -13,12 +13,14 @@ const FILES_BLACK = ['h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'];
13
13
  const RANKS_WHITE = ['8', '7', '6', '5', '4', '3', '2', '1'];
14
14
  const RANKS_BLACK = ['1', '2', '3', '4', '5', '6', '7', '8'];
15
15
 
16
- /**
17
- * File letters (a-h) and rank numbers (1-8) drawn on the board edges.
18
- *
19
- * Rendered as absolute-positioned Text components inside each corner square.
20
- * File letters appear on the bottom rank, rank numbers on the left file.
21
- * Colors alternate to contrast with the square behind them.
16
+ /**
17
+ * File letters (a-h) and rank numbers (1-8) drawn on or around the board.
18
+ *
19
+ * Two modes:
20
+ * - **inside** (default): absolute-positioned inside each edge square, colors
21
+ * alternate to contrast with the square behind them.
22
+ * - **outside**: rendered in a gutter area around the board. Rank numbers to
23
+ * the left, file letters along the bottom. Uses the dark square color.
22
24
  */
23
25
  const BoardCoordinates = exports.BoardCoordinates = /*#__PURE__*/_react.default.memo(function BoardCoordinates({
24
26
  boardSize,
@@ -26,14 +28,81 @@ const BoardCoordinates = exports.BoardCoordinates = /*#__PURE__*/_react.default.
26
28
  lightColor,
27
29
  darkColor,
28
30
  withLetters,
29
- withNumbers
31
+ withNumbers,
32
+ position = 'inside',
33
+ gutterWidth = 0
30
34
  }) {
31
35
  if (!withLetters && !withNumbers) return null;
32
36
  const squareSize = boardSize / 8;
33
- const fontSize = squareSize * 0.22;
34
- const padding = squareSize * 0.06;
35
37
  const files = orientation === 'white' ? FILES_WHITE : FILES_BLACK;
36
38
  const ranks = orientation === 'white' ? RANKS_WHITE : RANKS_BLACK;
39
+
40
+ // ── Outside mode: labels in gutter area around the board ──
41
+ if (position === 'outside') {
42
+ const fontSize = gutterWidth * 0.65;
43
+ const textColor = darkColor;
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
45
+ children: [withNumbers && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
46
+ style: {
47
+ position: 'absolute',
48
+ left: 0,
49
+ top: 0,
50
+ width: gutterWidth,
51
+ height: boardSize
52
+ },
53
+ pointerEvents: "none",
54
+ children: ranks.map((rank, row) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
55
+ style: {
56
+ position: 'absolute',
57
+ top: row * squareSize,
58
+ width: gutterWidth,
59
+ height: squareSize,
60
+ alignItems: 'center',
61
+ justifyContent: 'center'
62
+ },
63
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
64
+ style: {
65
+ fontSize,
66
+ fontWeight: '600',
67
+ color: textColor
68
+ },
69
+ children: rank
70
+ })
71
+ }, `r-${rank}`))
72
+ }), withLetters && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
73
+ style: {
74
+ position: 'absolute',
75
+ left: withNumbers ? gutterWidth : 0,
76
+ bottom: 0,
77
+ width: boardSize,
78
+ height: gutterWidth
79
+ },
80
+ pointerEvents: "none",
81
+ children: files.map((file, col) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
82
+ style: {
83
+ position: 'absolute',
84
+ left: col * squareSize,
85
+ width: squareSize,
86
+ height: gutterWidth,
87
+ alignItems: 'center',
88
+ justifyContent: 'center'
89
+ },
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
91
+ style: {
92
+ fontSize,
93
+ fontWeight: '600',
94
+ color: textColor
95
+ },
96
+ children: file
97
+ })
98
+ }, `f-${file}`))
99
+ })]
100
+ });
101
+ }
102
+
103
+ // ── Inside mode (default): absolute-positioned inside edge squares ──
104
+ const fontSize = squareSize * 0.22;
105
+ const padding = squareSize * 0.06;
37
106
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
38
107
  style: {
39
108
  position: 'absolute',
@@ -42,7 +111,6 @@ const BoardCoordinates = exports.BoardCoordinates = /*#__PURE__*/_react.default.
42
111
  },
43
112
  pointerEvents: "none",
44
113
  children: [withNumbers && ranks.map((rank, row) => {
45
- // First column square: row 0 col 0 = light if (0+0)%2===0
46
114
  const isLight = row % 2 === 0;
47
115
  const textColor = isLight ? darkColor : lightColor;
48
116
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
@@ -57,7 +125,6 @@ const BoardCoordinates = exports.BoardCoordinates = /*#__PURE__*/_react.default.
57
125
  children: rank
58
126
  }, `r-${rank}`);
59
127
  }), withLetters && files.map((file, col) => {
60
- // Last row (7), column col: light if (7+col)%2===0
61
128
  const isLight = (7 + col) % 2 === 0;
62
129
  const textColor = isLight ? darkColor : lightColor;
63
130
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","FILES_WHITE","FILES_BLACK","RANKS_WHITE","RANKS_BLACK","BoardCoordinates","exports","React","memo","boardSize","orientation","lightColor","darkColor","withLetters","withNumbers","squareSize","fontSize","padding","files","ranks","jsxs","View","style","position","width","height","pointerEvents","children","map","rank","row","isLight","textColor","jsx","Text","left","top","fontWeight","color","file","col","right","bottom","textAlign"],"sourceRoot":"..\\..\\src","sources":["board-coordinates.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA0C,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAa1C,MAAMG,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAMC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAMC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAMC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,gBAAGE,cAAK,CAACC,IAAI,CAAC,SAASH,gBAAgBA,CAAC;EACnEI,SAAS;EACTC,WAAW;EACXC,UAAU;EAC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AO,GAAG,CAAC,CAAC,GAAGS,GAAG,IAAI,CAAC,KAAK,CAAC;MACnC,MAAMR,SAAS,GAAGD,OAAO,GAAGnB,SAAS,GAAGD,UAAU;MAElD,oBACE,IAAAd,WAAA,CAAAoC,GAAA,EAACrC,YAAA,CAAAsC,IAAI;QAEHZ,KAAK,EAAE;UACLC,QAAQ,EAAE,UAAU;UACpBkB,KAAK,EAAE,CAAC,CAAC,GAAGD,GAAG,IAAIzB,UAAU,GAAGE,OAAO;UACvCyB,MAAM,EAAEzB,OAAO;UACfD,QAAQ;UACRqB,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEN,SAAS;UAChBW,SAAS,EAAE;QACb,CAAE;QAAAhB,QAAA,EAEDY;MAAI,GAXA,KAAKA,IAAI,EAYV,CAAC;IAEX,CAAC,CAAC;EAAA,CACA,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","FILES_WHITE","FILES_BLACK","RANKS_WHITE","RANKS_BLACK","BoardCoordinates","exports","React","memo","boardSize","orientation","lightColor","darkColor","withLetters","withNumbers","position","gutterWidth","squareSize","files","ranks","fontSize","textColor","jsxs","Fragment","children","jsx","View","style","left","top","width","height","pointerEvents","map","rank","row","alignItems","justifyContent","Text","fontWeight","color","bottom","file","col","padding","isLight","right","textAlign"],"sourceRoot":"..\\..\\src","sources":["board-coordinates.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA0C,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAiB1C,MAAMG,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,E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AI,GAVA,KAAKA,IAAI,EAWV,CAAC;IAEX,CAAC,CAAC,EAGHrB,WAAW,IACVK,KAAK,CAACe,GAAG,CAAC,CAACS,IAAI,EAAEC,GAAG,KAAK;MACvB,MAAME,OAAO,GAAG,CAAC,CAAC,GAAGF,GAAG,IAAI,CAAC,KAAK,CAAC;MACnC,MAAMtB,SAAS,GAAGwB,OAAO,GAAGjC,SAAS,GAAGD,UAAU;MAElD,oBACE,IAAAd,WAAA,CAAA4B,GAAA,EAAC7B,YAAA,CAAA0C,IAAI;QAEHX,KAAK,EAAE;UACLZ,QAAQ,EAAE,UAAU;UACpB+B,KAAK,EAAE,CAAC,CAAC,GAAGH,GAAG,IAAI1B,UAAU,GAAG2B,OAAO;UACvCH,MAAM,EAAEG,OAAO;UACfxB,QAAQ;UACRmB,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEnB,SAAS;UAChB0B,SAAS,EAAE;QACb,CAAE;QAAAvB,QAAA,EAEDkB;MAAI,GAXA,KAAKA,IAAI,EAYV,CAAC;IAEX,CAAC,CAAC;EAAA,CACA,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
@@ -9,12 +9,12 @@ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reani
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- /**
13
- * Floating piece that follows the user's finger during drag.
14
- *
15
- * Only ONE instance exists — not one per piece. It reads drag position
16
- * from shared values on the UI thread, so zero JS bridge calls and
17
- * zero re-renders while dragging.
12
+ /**
13
+ * Floating piece that follows the user's finger during drag.
14
+ *
15
+ * Only ONE instance exists — not one per piece. It reads drag position
16
+ * from shared values on the UI thread, so zero JS bridge calls and
17
+ * zero re-renders while dragging.
18
18
  */
19
19
  const BoardDragGhost = exports.BoardDragGhost = /*#__PURE__*/_react.default.memo(function BoardDragGhost({
20
20
  squareSize,
@@ -63,10 +63,10 @@ const BoardDragGhost = exports.BoardDragGhost = /*#__PURE__*/_react.default.memo
63
63
  });
64
64
  });
65
65
 
66
- /**
67
- * Inner content that renders the actual piece image.
68
- * Separate component so the Animated.View wrapper doesn't need
69
- * to re-render when the piece code changes — it uses shared value.
66
+ /**
67
+ * Inner content that renders the actual piece image.
68
+ * Separate component so the Animated.View wrapper doesn't need
69
+ * to re-render when the piece code changes — it uses shared value.
70
70
  */
71
71
  const DragGhostContent = /*#__PURE__*/_react.default.memo(function DragGhostContent({
72
72
  renderPiece,