react-native-chess-kit 0.5.0 → 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.
- package/LICENSE +21 -21
- package/README.md +168 -168
- package/lib/commonjs/board-annotations.js +8 -8
- package/lib/commonjs/board-arrows.js +7 -7
- package/lib/commonjs/board-background.js +5 -5
- package/lib/commonjs/board-coordinates.js +8 -8
- package/lib/commonjs/board-drag-ghost.js +10 -10
- package/lib/commonjs/board-highlights.js +15 -15
- package/lib/commonjs/board-legal-dots.js +5 -5
- package/lib/commonjs/board-piece.js +25 -25
- package/lib/commonjs/board-pieces.js +6 -6
- package/lib/commonjs/board.js +24 -24
- package/lib/commonjs/promotion-picker.js +8 -8
- package/lib/commonjs/static-board.js +7 -7
- package/lib/commonjs/use-board-gesture.js +52 -33
- package/lib/commonjs/use-board-gesture.js.map +1 -1
- package/lib/commonjs/use-board-pieces.js +15 -15
- package/lib/commonjs/use-board-state.js +8 -8
- package/lib/commonjs/use-premove.js +12 -12
- package/lib/module/board-annotations.js +8 -8
- package/lib/module/board-arrows.js +7 -7
- package/lib/module/board-background.js +5 -5
- package/lib/module/board-coordinates.js +8 -8
- package/lib/module/board-drag-ghost.js +10 -10
- package/lib/module/board-highlights.js +15 -15
- package/lib/module/board-legal-dots.js +5 -5
- package/lib/module/board-piece.js +25 -25
- package/lib/module/board-pieces.js +6 -6
- package/lib/module/board.js +24 -24
- package/lib/module/promotion-picker.js +8 -8
- package/lib/module/static-board.js +7 -7
- package/lib/module/use-board-gesture.js +52 -33
- package/lib/module/use-board-gesture.js.map +1 -1
- package/lib/module/use-board-pieces.js +15 -15
- package/lib/module/use-board-state.js +8 -8
- package/lib/module/use-premove.js +12 -12
- package/lib/typescript/use-board-gesture.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/board-annotations.tsx +147 -147
- package/src/board-arrows.tsx +197 -197
- package/src/board-background.tsx +46 -46
- package/src/board-coordinates.tsx +192 -192
- package/src/board-drag-ghost.tsx +132 -132
- package/src/board-highlights.tsx +226 -226
- package/src/board-legal-dots.tsx +73 -73
- package/src/board-piece.tsx +160 -160
- package/src/board-pieces.tsx +63 -63
- package/src/board.tsx +685 -685
- package/src/constants.ts +103 -103
- package/src/index.ts +101 -101
- package/src/pieces/default-pieces.tsx +383 -383
- package/src/pieces/index.ts +1 -1
- package/src/promotion-picker.tsx +147 -147
- package/src/static-board.tsx +187 -187
- package/src/themes.ts +129 -129
- package/src/types.ts +373 -373
- package/src/use-board-gesture.ts +429 -412
- package/src/use-board-pieces.ts +158 -158
- package/src/use-board-state.ts +111 -111
- package/src/use-premove.ts +59 -59
|
@@ -9,12 +9,12 @@ var _boardPiece = require("./board-piece");
|
|
|
9
9
|
var _useBoardPieces = require("./use-board-pieces");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* Renders all pieces on the board.
|
|
14
|
-
*
|
|
15
|
-
* Each piece gets a stable key (from useBoardPieces) so React doesn't
|
|
16
|
-
* unmount/remount pieces that moved — it updates their position props
|
|
17
|
-
* and the BoardPieceView animates the transition.
|
|
12
|
+
/**
|
|
13
|
+
* Renders all pieces on the board.
|
|
14
|
+
*
|
|
15
|
+
* Each piece gets a stable key (from useBoardPieces) so React doesn't
|
|
16
|
+
* unmount/remount pieces that moved — it updates their position props
|
|
17
|
+
* and the BoardPieceView animates the transition.
|
|
18
18
|
*/
|
|
19
19
|
const BoardPiecesLayer = exports.BoardPiecesLayer = /*#__PURE__*/_react.default.memo(function BoardPiecesLayer({
|
|
20
20
|
pieces,
|
package/lib/commonjs/board.js
CHANGED
|
@@ -29,9 +29,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
29
29
|
// Check detection helper
|
|
30
30
|
// ---------------------------------------------------------------------------
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Find the king square for the side currently in check.
|
|
34
|
-
* Returns null if not in check.
|
|
32
|
+
/**
|
|
33
|
+
* Find the king square for the side currently in check.
|
|
34
|
+
* Returns null if not in check.
|
|
35
35
|
*/function detectCheckSquare(fen, isInCheck, getTurn) {
|
|
36
36
|
if (!isInCheck()) return null;
|
|
37
37
|
const turn = getTurn();
|
|
@@ -60,27 +60,27 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
60
60
|
// Board component
|
|
61
61
|
// ---------------------------------------------------------------------------
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* High-performance custom chess board built on Reanimated + Gesture Handler.
|
|
65
|
-
*
|
|
66
|
-
* Architecture:
|
|
67
|
-
* - 1 gesture handler (vs 32 in typical implementations)
|
|
68
|
-
* - ~40 components mounted (vs ~281)
|
|
69
|
-
* - ~75 native views (vs ~470)
|
|
70
|
-
* - 0 React Context providers
|
|
71
|
-
* - 0 re-renders during drag (pure worklet — only 2 shared value writes per frame)
|
|
72
|
-
*
|
|
73
|
-
* v0.2.0 layer stack (10 layers):
|
|
74
|
-
* 1. BoardBackground (64 squares)
|
|
75
|
-
* 2. BoardCoordinates (a-h, 1-8)
|
|
76
|
-
* 3. BoardHighlights (last move, check, selected, premove, custom, imperative)
|
|
77
|
-
* 4. DragTargetHighlight (animated, worklet-driven)
|
|
78
|
-
* 5. BoardLegalDots (legal move indicators)
|
|
79
|
-
* 6. BoardPiecesLayer (all pieces)
|
|
80
|
-
* 7. BoardArrows (SVG arrows + circles)
|
|
81
|
-
* 8. BoardAnnotations (text badges)
|
|
82
|
-
* 9. BoardDragGhost (floating piece)
|
|
83
|
-
* 10. PromotionPicker (modal, conditional)
|
|
63
|
+
/**
|
|
64
|
+
* High-performance custom chess board built on Reanimated + Gesture Handler.
|
|
65
|
+
*
|
|
66
|
+
* Architecture:
|
|
67
|
+
* - 1 gesture handler (vs 32 in typical implementations)
|
|
68
|
+
* - ~40 components mounted (vs ~281)
|
|
69
|
+
* - ~75 native views (vs ~470)
|
|
70
|
+
* - 0 React Context providers
|
|
71
|
+
* - 0 re-renders during drag (pure worklet — only 2 shared value writes per frame)
|
|
72
|
+
*
|
|
73
|
+
* v0.2.0 layer stack (10 layers):
|
|
74
|
+
* 1. BoardBackground (64 squares)
|
|
75
|
+
* 2. BoardCoordinates (a-h, 1-8)
|
|
76
|
+
* 3. BoardHighlights (last move, check, selected, premove, custom, imperative)
|
|
77
|
+
* 4. DragTargetHighlight (animated, worklet-driven)
|
|
78
|
+
* 5. BoardLegalDots (legal move indicators)
|
|
79
|
+
* 6. BoardPiecesLayer (all pieces)
|
|
80
|
+
* 7. BoardArrows (SVG arrows + circles)
|
|
81
|
+
* 8. BoardAnnotations (text badges)
|
|
82
|
+
* 9. BoardDragGhost (floating piece)
|
|
83
|
+
* 10. PromotionPicker (modal, conditional)
|
|
84
84
|
*/
|
|
85
85
|
const Board = exports.Board = /*#__PURE__*/(0, _react.forwardRef)(function Board({
|
|
86
86
|
fen,
|
|
@@ -27,14 +27,14 @@ function promotionPieceCode(color, piece) {
|
|
|
27
27
|
// Component
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* Promotion piece picker overlay.
|
|
32
|
-
*
|
|
33
|
-
* Appears as a vertical column of 4 pieces (Q, R, B, N) anchored to the
|
|
34
|
-
* promotion square. Expands downward when promoting on the top edge,
|
|
35
|
-
* upward when promoting on the bottom edge.
|
|
36
|
-
*
|
|
37
|
-
* A semi-transparent backdrop covers the board. Tapping outside cancels.
|
|
30
|
+
/**
|
|
31
|
+
* Promotion piece picker overlay.
|
|
32
|
+
*
|
|
33
|
+
* Appears as a vertical column of 4 pieces (Q, R, B, N) anchored to the
|
|
34
|
+
* promotion square. Expands downward when promoting on the top edge,
|
|
35
|
+
* upward when promoting on the bottom edge.
|
|
36
|
+
*
|
|
37
|
+
* A semi-transparent backdrop covers the board. Tapping outside cancels.
|
|
38
38
|
*/
|
|
39
39
|
const PromotionPicker = exports.PromotionPicker = /*#__PURE__*/_react.default.memo(function PromotionPicker({
|
|
40
40
|
square,
|
|
@@ -16,13 +16,13 @@ var _boardArrows = require("./board-arrows");
|
|
|
16
16
|
var _boardAnnotations = require("./board-annotations");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
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); }
|
|
19
|
-
/**
|
|
20
|
-
* Non-interactive chess board — optimized for lists, thumbnails, and analysis previews.
|
|
21
|
-
*
|
|
22
|
-
* No gesture handler, no drag ghost, no legal move dots.
|
|
23
|
-
* Just: background + coordinates + highlights + pieces + arrows + annotations.
|
|
24
|
-
*
|
|
25
|
-
* Significantly lighter than the full Board component.
|
|
19
|
+
/**
|
|
20
|
+
* Non-interactive chess board — optimized for lists, thumbnails, and analysis previews.
|
|
21
|
+
*
|
|
22
|
+
* No gesture handler, no drag ghost, no legal move dots.
|
|
23
|
+
* Just: background + coordinates + highlights + pieces + arrows + annotations.
|
|
24
|
+
*
|
|
25
|
+
* Significantly lighter than the full Board component.
|
|
26
26
|
*/
|
|
27
27
|
const StaticBoard = exports.StaticBoard = /*#__PURE__*/_react.default.memo(function StaticBoard({
|
|
28
28
|
fen,
|
|
@@ -38,31 +38,31 @@ function pieceColorToPlayer(color) {
|
|
|
38
38
|
// Hook
|
|
39
39
|
// ---------------------------------------------------------------------------
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
* Single centralized gesture handler for the entire board.
|
|
43
|
-
*
|
|
44
|
-
* Instead of 32 separate Gesture.Pan() handlers (one per piece), we use ONE
|
|
45
|
-
* handler on the board container. Touch -> coordinate math -> which piece.
|
|
46
|
-
*
|
|
47
|
-
* Supports three modes:
|
|
48
|
-
* - 'drag': drag piece to target square
|
|
49
|
-
* - 'click': tap source piece, then tap target square
|
|
50
|
-
* - 'both': drag or click (default)
|
|
51
|
-
*
|
|
52
|
-
* All drag position tracking uses shared values — zero JS bridge calls,
|
|
53
|
-
* zero re-renders during drag. Only the final move triggers JS via runOnJS.
|
|
54
|
-
*
|
|
55
|
-
* The gesture object is STABLE (only recreated when squareSize, orientation,
|
|
56
|
-
* gestureEnabled, player, or moveMethod change). Frequently-changing data
|
|
57
|
-
* (pieces, selectedSquare, legalMoves) is read from refs via runOnJS bridge
|
|
58
|
-
* functions, avoiding costly gesture teardown/rebuild on every move.
|
|
59
|
-
*
|
|
60
|
-
* v0.2.0 additions:
|
|
61
|
-
* - Rich callbacks (onPieceClick, onSquareClick, onPieceDragBegin, onPieceDragEnd)
|
|
62
|
-
* - Drag target square tracking (shared value for DragTargetHighlight)
|
|
63
|
-
* - Premove support (queue move when not your turn)
|
|
64
|
-
* - Haptic feedback via callback
|
|
65
|
-
* - Long press detection for onSquareLongPress
|
|
41
|
+
/**
|
|
42
|
+
* Single centralized gesture handler for the entire board.
|
|
43
|
+
*
|
|
44
|
+
* Instead of 32 separate Gesture.Pan() handlers (one per piece), we use ONE
|
|
45
|
+
* handler on the board container. Touch -> coordinate math -> which piece.
|
|
46
|
+
*
|
|
47
|
+
* Supports three modes:
|
|
48
|
+
* - 'drag': drag piece to target square
|
|
49
|
+
* - 'click': tap source piece, then tap target square
|
|
50
|
+
* - 'both': drag or click (default)
|
|
51
|
+
*
|
|
52
|
+
* All drag position tracking uses shared values — zero JS bridge calls,
|
|
53
|
+
* zero re-renders during drag. Only the final move triggers JS via runOnJS.
|
|
54
|
+
*
|
|
55
|
+
* The gesture object is STABLE (only recreated when squareSize, orientation,
|
|
56
|
+
* gestureEnabled, player, or moveMethod change). Frequently-changing data
|
|
57
|
+
* (pieces, selectedSquare, legalMoves) is read from refs via runOnJS bridge
|
|
58
|
+
* functions, avoiding costly gesture teardown/rebuild on every move.
|
|
59
|
+
*
|
|
60
|
+
* v0.2.0 additions:
|
|
61
|
+
* - Rich callbacks (onPieceClick, onSquareClick, onPieceDragBegin, onPieceDragEnd)
|
|
62
|
+
* - Drag target square tracking (shared value for DragTargetHighlight)
|
|
63
|
+
* - Premove support (queue move when not your turn)
|
|
64
|
+
* - Haptic feedback via callback
|
|
65
|
+
* - Long press detection for onSquareLongPress
|
|
66
66
|
*/
|
|
67
67
|
function useBoardGesture({
|
|
68
68
|
squareSize,
|
|
@@ -139,6 +139,7 @@ function useBoardGesture({
|
|
|
139
139
|
const legalSquares = new Set(currentLegalMoves.map(m => m.square));
|
|
140
140
|
if (canClick && currentSelected && legalSquares.has(square)) {
|
|
141
141
|
cbs.onPieceMoved(currentSelected, square);
|
|
142
|
+
// Clear optimistic worklet value — move is complete
|
|
142
143
|
activeSquare.value = null;
|
|
143
144
|
isDragging.value = false;
|
|
144
145
|
dragPieceCode.value = null;
|
|
@@ -146,6 +147,15 @@ function useBoardGesture({
|
|
|
146
147
|
rich?.onHaptic?.('move');
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
150
|
+
|
|
151
|
+
// Chess.com-style deselect: tapping the already-selected piece toggles it off
|
|
152
|
+
if (canClick && currentSelected === square) {
|
|
153
|
+
cbs.onSelectionCleared();
|
|
154
|
+
activeSquare.value = null;
|
|
155
|
+
dragPieceCode.value = null;
|
|
156
|
+
dragTargetSquare.value = null;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
149
159
|
if (isPlayerPiece && piece) {
|
|
150
160
|
// Premove: player piece but not their turn
|
|
151
161
|
if (premovesEnabled && !isOwnTurn) {
|
|
@@ -162,9 +172,7 @@ function useBoardGesture({
|
|
|
162
172
|
return;
|
|
163
173
|
}
|
|
164
174
|
// First tap: select the piece for premove
|
|
165
|
-
activeSquare.value
|
|
166
|
-
dragX.value = touchX;
|
|
167
|
-
dragY.value = touchY;
|
|
175
|
+
// activeSquare.value / dragX.value / dragY.value already set by onBegin worklet
|
|
168
176
|
dragPieceCode.value = piece.code;
|
|
169
177
|
cbs.onPieceSelected(square);
|
|
170
178
|
rich?.onPieceClick?.(square, piece.code);
|
|
@@ -173,9 +181,7 @@ function useBoardGesture({
|
|
|
173
181
|
}
|
|
174
182
|
|
|
175
183
|
// Normal case: tapped/started dragging a player piece on their turn
|
|
176
|
-
activeSquare.value
|
|
177
|
-
dragX.value = touchX;
|
|
178
|
-
dragY.value = touchY;
|
|
184
|
+
// activeSquare.value / dragX.value / dragY.value already set by onBegin worklet
|
|
179
185
|
dragPieceCode.value = piece.code;
|
|
180
186
|
draggedPieceRef.current = {
|
|
181
187
|
square,
|
|
@@ -201,6 +207,8 @@ function useBoardGesture({
|
|
|
201
207
|
dragTargetSquare.value = null;
|
|
202
208
|
return;
|
|
203
209
|
}
|
|
210
|
+
|
|
211
|
+
// Clear the optimistic worklet value — no valid piece here
|
|
204
212
|
activeSquare.value = null;
|
|
205
213
|
dragPieceCode.value = null;
|
|
206
214
|
dragTargetSquare.value = null;
|
|
@@ -255,9 +263,13 @@ function useBoardGesture({
|
|
|
255
263
|
} else {
|
|
256
264
|
callbacksRef.current.onPieceMoved(fromSquare, toSquare);
|
|
257
265
|
}
|
|
266
|
+
|
|
267
|
+
// Move completed — clear selection
|
|
268
|
+
activeSquare.value = null;
|
|
269
|
+
dragPieceCode.value = null;
|
|
258
270
|
}
|
|
259
|
-
|
|
260
|
-
|
|
271
|
+
// When fromSquare === toSquare (tap with no movement), keep selection alive
|
|
272
|
+
// so the user can complete a click-to-move on the next tap.
|
|
261
273
|
}, [squareSize, orientation, activeSquare, isDragging, dragPieceCode, dragTargetSquare, premovesEnabled]);
|
|
262
274
|
|
|
263
275
|
// Long press handler (separate gesture, composed with pan)
|
|
@@ -277,6 +289,13 @@ function useBoardGesture({
|
|
|
277
289
|
.onBegin(e => {
|
|
278
290
|
'worklet';
|
|
279
291
|
|
|
292
|
+
// Set shared values IMMEDIATELY on the UI thread so onStart can read them
|
|
293
|
+
// synchronously. xyToSquare is tagged 'worklet' — safe to call here.
|
|
294
|
+
// handleBegin (JS thread) will CLEAR activeSquare if the square is invalid.
|
|
295
|
+
const sq = (0, _useBoardPieces.xyToSquare)(e.x, e.y, squareSize, orientation);
|
|
296
|
+
activeSquare.value = sq;
|
|
297
|
+
dragX.value = e.x;
|
|
298
|
+
dragY.value = e.y;
|
|
280
299
|
// Bridge to JS for piece lookup + selection logic
|
|
281
300
|
(0, _reactNativeReanimated.runOnJS)(handleBegin)(e.x, e.y);
|
|
282
301
|
}).onStart(e => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNativeGestureHandler","_reactNativeReanimated","_useBoardPieces","isPieceTurn","pieceColor","currentTurn","pieceColorToPlayer","color","useBoardGesture","squareSize","orientation","gestureEnabled","player","moveMethod","pieces","callbacks","richCallbacks","premoveCallbacks","premovesEnabled","selectedSquare","legalMoves","activeSquare","useSharedValue","dragX","dragY","isDragging","dragPieceCode","dragTargetSquare","gestureState","piecesRef","useRef","current","selectedSquareRef","legalMovesRef","callbacksRef","richCallbacksRef","premoveCallbacksRef","currentTurnRef","draggedPieceRef","handleBegin","useCallback","touchX","touchY","square","xyToSquare","currentPieces","currentSelected","currentLegalMoves","cbs","rich","canClick","piece","find","p","isPlayerPiece","turn","isOwnTurn","legalSquares","Set","map","m","has","onPieceMoved","value","onHaptic","onPremoveSet","from","to","onSelectionCleared","code","onPieceSelected","onPieceClick","onSquareClick","handleDragStart","dragged","onPieceDragBegin","handleDragUpdate","handleEnd","fromSquare","toSquare","onPieceDragEnd","handleLongPress","onSquareLongPress","canDrag","lastDragTargetCol","lastDragTargetRow","gesture","useMemo","Gesture","Pan","enabled","minDistance","onBegin","e","runOnJS","x","y","onStart","onUpdate","col","Math","max","min","floor","row","onEnd","onFinalize"],"sourceRoot":"..\\..\\src","sources":["use-board-gesture.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAeA,IAAAG,eAAA,GAAAH,OAAA;AAEA;AACA;AACA;;AAQA;;AAUA;;AAKA;AACA;AACA;;AA2BA;AACA;AACA;;AAEA;AACA,SAASI,WAAWA,CAACC,UAAqB,EAAEC,WAAsB,EAAW;EAC3E,OAAOD,UAAU,KAAKC,WAAW;AACnC;;AAEA;AACA,SAASC,kBAAkBA,CAACC,KAAgB,EAAc;EACxD,OAAOA,KAAK,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;AAC1C;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAC;EAC9BC,UAAU;EACVC,WAAW;EACXC,cAAc;EACdC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,SAAS;EACTC,aAAa;EACbC,gBAAgB;EAChBC,eAAe,GAAG,KAAK;EACvBC,cAAc;EACdC,UAAU;EACVf;AACqB,CAAC,EAAyB;EAC/C;EACA,MAAMgB,YAAY,GAAG,IAAAC,qCAAc,EAAgB,IAAI,CAAC;EACxD,MAAMC,KAAK,GAAG,IAAAD,qCAAc,EAAC,CAAC,CAAC;EAC/B,MAAME,KAAK,GAAG,IAAAF,qCAAc,EAAC,CAAC,CAAC;EAC/B,MAAMG,UAAU,GAAG,IAAAH,qCAAc,EAAC,KAAK,CAAC;EACxC,MAAMI,aAAa,GAAG,IAAAJ,qCAAc,EAAgB,IAAI,CAAC;EACzD,MAAMK,gBAAgB,GAAG,IAAAL,qCAAc,EAAgB,IAAI,CAAC;EAE5D,MAAMM,YAA0B,GAAG;IACjCP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,IAAI,CAACpE,UAAU,CAACsC,KAAK,IAAI,CAAC1C,YAAY,CAAC0C,KAAK,EAAE;MAC9C,IAAA+B,8BAAO,EAACjB,SAAS,CAAC,CAACgB,CAAC,CAACE,CAAC,EAAEF,CAAC,CAACG,CAAC,CAAC;IAC9B,CAAC,CAAC,CACDU,UAAU,CAAC,MAAM;MAChB,SAAS;;MACT;MACAjF,UAAU,CAACsC,KAAK,GAAG,KAAK;MACxBpC,gBAAgB,CAACoC,KAAK,GAAG,IAAI;MAC7BqB,iBAAiB,CAACrB,KAAK,GAAG,CAAC,CAAC;MAC5BsB,iBAAiB,CAACtB,KAAK,GAAG,CAAC,CAAC;IAC9B,CAAC,CAAC;EACN,CAAC,EAAE,CACDpD,cAAc,EACdwE,OAAO,EACP1E,UAAU,EACV8B,WAAW,EACXkC,eAAe,EACfG,gBAAgB,EAChBC,SAAS;EACT;EACAxD,YAAY,EACZE,KAAK,EACLC,KAAK,EACLC,UAAU,EACVE,gBAAgB,EAChByD,iBAAiB,EACjBC,iBAAiB,CAClB,CAAC;;EAEF;EACA;EACA;;EAEA,OAAO;IAAEC,OAAO;IAAE1D;EAAa,CAAC;AAClC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNativeGestureHandler","_reactNativeReanimated","_useBoardPieces","isPieceTurn","pieceColor","currentTurn","pieceColorToPlayer","color","useBoardGesture","squareSize","orientation","gestureEnabled","player","moveMethod","pieces","callbacks","richCallbacks","premoveCallbacks","premovesEnabled","selectedSquare","legalMoves","activeSquare","useSharedValue","dragX","dragY","isDragging","dragPieceCode","dragTargetSquare","gestureState","piecesRef","useRef","current","selectedSquareRef","legalMovesRef","callbacksRef","richCallbacksRef","premoveCallbacksRef","currentTurnRef","draggedPieceRef","handleBegin","useCallback","touchX","touchY","square","xyToSquare","currentPieces","currentSelected","currentLegalMoves","cbs","rich","canClick","piece","find","p","isPlayerPiece","turn","isOwnTurn","legalSquares","Set","map","m","has","onPieceMoved","value","onHaptic","onSelectionCleared","onPremoveSet","from","to","code","onPieceSelected","onPieceClick","onSquareClick","handleDragStart","dragged","onPieceDragBegin","handleDragUpdate","handleEnd","fromSquare","toSquare","onPieceDragEnd","handleLongPress","onSquareLongPress","canDrag","lastDragTargetCol","lastDragTargetRow","gesture","useMemo","Gesture","Pan","enabled","minDistance","onBegin","e","sq","x","y","runOnJS","onStart","onUpdate","col","Math","max","min","floor","row","onEnd","onFinalize"],"sourceRoot":"..\\..\\src","sources":["use-board-gesture.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAeA,IAAAG,eAAA,GAAAH,OAAA;AAEA;AACA;AACA;;AAQA;;AAUA;;AAKA;AACA;AACA;;AA2BA;AACA;AACA;;AAEA;AACA,SAASI,WAAWA,CAACC,UAAqB,EAAEC,WAAsB,EAAW;EAC3E,OAAOD,UAAU,KAAKC,WAAW;AACnC;;AAEA;AACA,SAASC,kBAAkBA,CAACC,KAAgB,EAAc;EACxD,OAAOA,KAAK,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;AAC1C;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAC;EAC9BC,UAAU;EACVC,WAAW;EACXC,cAAc;EACdC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,SAAS;EACTC,aAAa;EACbC,gBAAgB;EAChBC,eAAe,GAAG,KAAK;EACvBC,cAAc;EACdC,UAAU;EACVf;AACqB,CAAC,EAAyB;EAC/C;EACA,MAAMgB,YAAY,GAAG,IAAAC,qCAAc,EAAgB,IAAI,CAAC;EACxD,MAAMC,KAAK,GAAG,IAAAD,qCAAc,EAAC,CAAC,CAAC;EAC/B,MAAME,KAAK,GAAG,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AAO;IAAEC,OAAO;IAAE1D;EAAa,CAAC;AAClC","ignoreList":[]}
|
|
@@ -59,9 +59,9 @@ const FEN_PIECE_MAP = {
|
|
|
59
59
|
};
|
|
60
60
|
const FILES = 'abcdefgh';
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Parse the piece-placement part of a FEN string into an array of pieces.
|
|
64
|
-
* Pure function — no React dependencies, suitable for worklets if needed.
|
|
62
|
+
/**
|
|
63
|
+
* Parse the piece-placement part of a FEN string into an array of pieces.
|
|
64
|
+
* Pure function — no React dependencies, suitable for worklets if needed.
|
|
65
65
|
*/
|
|
66
66
|
function parseFenPieces(fen) {
|
|
67
67
|
const placement = fen.split(' ')[0];
|
|
@@ -91,9 +91,9 @@ function parseFenPieces(fen) {
|
|
|
91
91
|
return pieces;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
/**
|
|
95
|
-
* Convert square notation to pixel coordinates (top-left corner).
|
|
96
|
-
* Orientation-aware: flips the board when playing as black.
|
|
94
|
+
/**
|
|
95
|
+
* Convert square notation to pixel coordinates (top-left corner).
|
|
96
|
+
* Orientation-aware: flips the board when playing as black.
|
|
97
97
|
*/
|
|
98
98
|
function squareToXY(square, squareSize, orientation) {
|
|
99
99
|
'worklet';
|
|
@@ -109,9 +109,9 @@ function squareToXY(square, squareSize, orientation) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/**
|
|
113
|
-
* Convert pixel coordinates to a square notation string.
|
|
114
|
-
* Clamps to board bounds. Orientation-aware.
|
|
112
|
+
/**
|
|
113
|
+
* Convert pixel coordinates to a square notation string.
|
|
114
|
+
* Clamps to board bounds. Orientation-aware.
|
|
115
115
|
*/
|
|
116
116
|
function xyToSquare(x, y, squareSize, orientation) {
|
|
117
117
|
'worklet';
|
|
@@ -126,12 +126,12 @@ function xyToSquare(x, y, squareSize, orientation) {
|
|
|
126
126
|
return `${files[fileIdx]}${rankIdx + 1}`;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* Manages the piece list derived from FEN, with stable IDs for React keys.
|
|
131
|
-
*
|
|
132
|
-
* Stable IDs prevent unmount/remount cycles when pieces change position.
|
|
133
|
-
* A piece keeps its ID as long as it exists on the board — only capture
|
|
134
|
-
* (removal) or promotion (code change) creates a new ID.
|
|
129
|
+
/**
|
|
130
|
+
* Manages the piece list derived from FEN, with stable IDs for React keys.
|
|
131
|
+
*
|
|
132
|
+
* Stable IDs prevent unmount/remount cycles when pieces change position.
|
|
133
|
+
* A piece keeps its ID as long as it exists on the board — only capture
|
|
134
|
+
* (removal) or promotion (code change) creates a new ID.
|
|
135
135
|
*/
|
|
136
136
|
function useBoardPieces(fen) {
|
|
137
137
|
// Track piece-code counters across renders for stable ID assignment
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useBoardState = useBoardState;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _chess = require("chess.js");
|
|
9
|
-
/**
|
|
10
|
-
* Manages the internal chess.js instance for legal move validation.
|
|
11
|
-
*
|
|
12
|
-
* This mirrors the visual board state. When the parent passes a new FEN,
|
|
13
|
-
* the internal chess.js is synced. Legal move queries and move application
|
|
14
|
-
* happen against this instance.
|
|
15
|
-
*
|
|
16
|
-
* The chess.js instance lives in a ref — no React state, no re-renders.
|
|
9
|
+
/**
|
|
10
|
+
* Manages the internal chess.js instance for legal move validation.
|
|
11
|
+
*
|
|
12
|
+
* This mirrors the visual board state. When the parent passes a new FEN,
|
|
13
|
+
* the internal chess.js is synced. Legal move queries and move application
|
|
14
|
+
* happen against this instance.
|
|
15
|
+
*
|
|
16
|
+
* The chess.js instance lives in a ref — no React state, no re-renders.
|
|
17
17
|
*/
|
|
18
18
|
function useBoardState(initialFen) {
|
|
19
19
|
const chessRef = (0, _react.useRef)(null);
|
|
@@ -5,18 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.usePremove = usePremove;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
/**
|
|
9
|
-
* Manages a single premove queue (one premove at a time).
|
|
10
|
-
*
|
|
11
|
-
* Premoves work like lichess:
|
|
12
|
-
* 1. When it's not your turn, you can drag/click a move — it queues as a premove
|
|
13
|
-
* 2. The premove squares are highlighted with a distinct color
|
|
14
|
-
* 3. When your turn begins (FEN changes and it's now your turn), the premove
|
|
15
|
-
* is automatically attempted via the board's internal chess.js
|
|
16
|
-
* 4. If the premove is legal, it's applied; if not, it's silently discarded
|
|
17
|
-
*
|
|
18
|
-
* The board.tsx orchestrates this: it calls consumePremove() in a useEffect
|
|
19
|
-
* that watches the FEN (turn change), then attempts the move.
|
|
8
|
+
/**
|
|
9
|
+
* Manages a single premove queue (one premove at a time).
|
|
10
|
+
*
|
|
11
|
+
* Premoves work like lichess:
|
|
12
|
+
* 1. When it's not your turn, you can drag/click a move — it queues as a premove
|
|
13
|
+
* 2. The premove squares are highlighted with a distinct color
|
|
14
|
+
* 3. When your turn begins (FEN changes and it's now your turn), the premove
|
|
15
|
+
* is automatically attempted via the board's internal chess.js
|
|
16
|
+
* 4. If the premove is legal, it's applied; if not, it's silently discarded
|
|
17
|
+
*
|
|
18
|
+
* The board.tsx orchestrates this: it calls consumePremove() in a useEffect
|
|
19
|
+
* that watches the FEN (turn change), then attempts the move.
|
|
20
20
|
*/
|
|
21
21
|
function usePremove() {
|
|
22
22
|
const [premove, setPremoveState] = (0, _react.useState)(null);
|
|
@@ -13,11 +13,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
// Annotations layer
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Text annotation badges on chess squares (!, ?, !!, ??, etc.).
|
|
18
|
-
*
|
|
19
|
-
* Each annotation appears as a small colored badge at the top-right
|
|
20
|
-
* corner of the target square. Positioned absolutely, pointer-events none.
|
|
16
|
+
/**
|
|
17
|
+
* Text annotation badges on chess squares (!, ?, !!, ??, etc.).
|
|
18
|
+
*
|
|
19
|
+
* Each annotation appears as a small colored badge at the top-right
|
|
20
|
+
* corner of the target square. Positioned absolutely, pointer-events none.
|
|
21
21
|
*/
|
|
22
22
|
export const BoardAnnotations = /*#__PURE__*/React.memo(function BoardAnnotations({
|
|
23
23
|
boardSize,
|
|
@@ -76,9 +76,9 @@ export const BoardAnnotations = /*#__PURE__*/React.memo(function BoardAnnotation
|
|
|
76
76
|
// Standalone export for advanced consumers
|
|
77
77
|
// ---------------------------------------------------------------------------
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* Single annotation badge component.
|
|
81
|
-
* Exported for consumers who build their own overlay layers.
|
|
79
|
+
/**
|
|
80
|
+
* Single annotation badge component.
|
|
81
|
+
* Exported for consumers who build their own overlay layers.
|
|
82
82
|
*/
|
|
83
83
|
export const Annotation = /*#__PURE__*/React.memo(function Annotation({
|
|
84
84
|
square,
|
|
@@ -47,13 +47,13 @@ function calculateArrowPath(from, to, shortenBy) {
|
|
|
47
47
|
// Combined arrows + shapes SVG layer
|
|
48
48
|
// ---------------------------------------------------------------------------
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* SVG overlay for arrows and shapes drawn on the board.
|
|
52
|
-
*
|
|
53
|
-
* Uses a percentage-based 100x100 viewBox so coordinates map cleanly
|
|
54
|
-
* to the 8x8 grid (each square = 12.5 x 12.5 units).
|
|
55
|
-
*
|
|
56
|
-
* Renders above the pieces layer so arrows are always visible.
|
|
50
|
+
/**
|
|
51
|
+
* SVG overlay for arrows and shapes drawn on the board.
|
|
52
|
+
*
|
|
53
|
+
* Uses a percentage-based 100x100 viewBox so coordinates map cleanly
|
|
54
|
+
* to the 8x8 grid (each square = 12.5 x 12.5 units).
|
|
55
|
+
*
|
|
56
|
+
* Renders above the pieces layer so arrows are always visible.
|
|
57
57
|
*/
|
|
58
58
|
export const BoardArrows = /*#__PURE__*/React.memo(function BoardArrows({
|
|
59
59
|
boardSize,
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* 64 static colored squares forming the chess board grid.
|
|
8
|
-
*
|
|
9
|
-
* These are plain Views with backgroundColor — no animations, no gesture
|
|
10
|
-
* handlers. They never re-render after mount unless the board theme changes.
|
|
6
|
+
/**
|
|
7
|
+
* 64 static colored squares forming the chess board grid.
|
|
8
|
+
*
|
|
9
|
+
* These are plain Views with backgroundColor — no animations, no gesture
|
|
10
|
+
* handlers. They never re-render after mount unless the board theme changes.
|
|
11
11
|
*/
|
|
12
12
|
export const BoardBackground = /*#__PURE__*/React.memo(function BoardBackground({
|
|
13
13
|
boardSize,
|
|
@@ -8,14 +8,14 @@ const FILES_BLACK = ['h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'];
|
|
|
8
8
|
const RANKS_WHITE = ['8', '7', '6', '5', '4', '3', '2', '1'];
|
|
9
9
|
const RANKS_BLACK = ['1', '2', '3', '4', '5', '6', '7', '8'];
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* File letters (a-h) and rank numbers (1-8) drawn on or around the board.
|
|
13
|
-
*
|
|
14
|
-
* Two modes:
|
|
15
|
-
* - **inside** (default): absolute-positioned inside each edge square, colors
|
|
16
|
-
* alternate to contrast with the square behind them.
|
|
17
|
-
* - **outside**: rendered in a gutter area around the board. Rank numbers to
|
|
18
|
-
* the left, file letters along the bottom. Uses the dark square color.
|
|
11
|
+
/**
|
|
12
|
+
* File letters (a-h) and rank numbers (1-8) drawn on or around the board.
|
|
13
|
+
*
|
|
14
|
+
* Two modes:
|
|
15
|
+
* - **inside** (default): absolute-positioned inside each edge square, colors
|
|
16
|
+
* alternate to contrast with the square behind them.
|
|
17
|
+
* - **outside**: rendered in a gutter area around the board. Rank numbers to
|
|
18
|
+
* the left, file letters along the bottom. Uses the dark square color.
|
|
19
19
|
*/
|
|
20
20
|
export const BoardCoordinates = /*#__PURE__*/React.memo(function BoardCoordinates({
|
|
21
21
|
boardSize,
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
5
5
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* Floating piece that follows the user's finger during drag.
|
|
8
|
-
*
|
|
9
|
-
* Only ONE instance exists — not one per piece. It reads drag position
|
|
10
|
-
* from shared values on the UI thread, so zero JS bridge calls and
|
|
11
|
-
* zero re-renders while dragging.
|
|
6
|
+
/**
|
|
7
|
+
* Floating piece that follows the user's finger during drag.
|
|
8
|
+
*
|
|
9
|
+
* Only ONE instance exists — not one per piece. It reads drag position
|
|
10
|
+
* from shared values on the UI thread, so zero JS bridge calls and
|
|
11
|
+
* zero re-renders while dragging.
|
|
12
12
|
*/
|
|
13
13
|
export const BoardDragGhost = /*#__PURE__*/React.memo(function BoardDragGhost({
|
|
14
14
|
squareSize,
|
|
@@ -57,10 +57,10 @@ export const BoardDragGhost = /*#__PURE__*/React.memo(function BoardDragGhost({
|
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
* Inner content that renders the actual piece image.
|
|
62
|
-
* Separate component so the Animated.View wrapper doesn't need
|
|
63
|
-
* to re-render when the piece code changes — it uses shared value.
|
|
60
|
+
/**
|
|
61
|
+
* Inner content that renders the actual piece image.
|
|
62
|
+
* Separate component so the Animated.View wrapper doesn't need
|
|
63
|
+
* to re-render when the piece code changes — it uses shared value.
|
|
64
64
|
*/
|
|
65
65
|
const DragGhostContent = /*#__PURE__*/React.memo(function DragGhostContent({
|
|
66
66
|
renderPiece,
|
|
@@ -13,15 +13,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
// Static highlights (View-based, no animation needed)
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Renders all board square highlights as a single layer.
|
|
18
|
-
*
|
|
19
|
-
* Combines multiple highlight sources (last move, check, selected piece,
|
|
20
|
-
* premoves, custom, and imperative) into one flat list of colored rectangles.
|
|
21
|
-
* Rendered between the background and pieces layers.
|
|
22
|
-
*
|
|
23
|
-
* Uses plain Views (not Animated) because highlights change discretely
|
|
24
|
-
* on move events, not during animation frames.
|
|
16
|
+
/**
|
|
17
|
+
* Renders all board square highlights as a single layer.
|
|
18
|
+
*
|
|
19
|
+
* Combines multiple highlight sources (last move, check, selected piece,
|
|
20
|
+
* premoves, custom, and imperative) into one flat list of colored rectangles.
|
|
21
|
+
* Rendered between the background and pieces layers.
|
|
22
|
+
*
|
|
23
|
+
* Uses plain Views (not Animated) because highlights change discretely
|
|
24
|
+
* on move events, not during animation frames.
|
|
25
25
|
*/
|
|
26
26
|
export const BoardHighlights = /*#__PURE__*/React.memo(function BoardHighlights({
|
|
27
27
|
boardSize,
|
|
@@ -125,9 +125,9 @@ export const BoardHighlights = /*#__PURE__*/React.memo(function BoardHighlights(
|
|
|
125
125
|
// Drag target highlight (Animated, updates on UI thread during drag)
|
|
126
126
|
// ---------------------------------------------------------------------------
|
|
127
127
|
|
|
128
|
-
/**
|
|
129
|
-
* Highlight on the square currently under the dragged piece.
|
|
130
|
-
* Uses Reanimated shared values for zero-JS-bridge updates during drag.
|
|
128
|
+
/**
|
|
129
|
+
* Highlight on the square currently under the dragged piece.
|
|
130
|
+
* Uses Reanimated shared values for zero-JS-bridge updates during drag.
|
|
131
131
|
*/
|
|
132
132
|
export const DragTargetHighlight = /*#__PURE__*/React.memo(function DragTargetHighlight({
|
|
133
133
|
squareSize,
|
|
@@ -177,9 +177,9 @@ export const DragTargetHighlight = /*#__PURE__*/React.memo(function DragTargetHi
|
|
|
177
177
|
// Standalone SquareHighlight (exported for advanced consumers)
|
|
178
178
|
// ---------------------------------------------------------------------------
|
|
179
179
|
|
|
180
|
-
/**
|
|
181
|
-
* Single square highlight component.
|
|
182
|
-
* Exported for consumers who build their own overlay layers.
|
|
180
|
+
/**
|
|
181
|
+
* Single square highlight component.
|
|
182
|
+
* Exported for consumers who build their own overlay layers.
|
|
183
183
|
*/
|
|
184
184
|
export const SquareHighlight = /*#__PURE__*/React.memo(function SquareHighlight({
|
|
185
185
|
square,
|
|
@@ -4,11 +4,11 @@ import React from 'react';
|
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import { squareToXY } from './use-board-pieces';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
/**
|
|
8
|
-
* Legal move indicator dots, rendered only when a piece is selected.
|
|
9
|
-
*
|
|
10
|
-
* Dots are CONDITIONALLY rendered (only for actual legal move squares,
|
|
11
|
-
* typically 5-15) instead of always mounting 64 invisible dot views.
|
|
7
|
+
/**
|
|
8
|
+
* Legal move indicator dots, rendered only when a piece is selected.
|
|
9
|
+
*
|
|
10
|
+
* Dots are CONDITIONALLY rendered (only for actual legal move squares,
|
|
11
|
+
* typically 5-15) instead of always mounting 64 invisible dot views.
|
|
12
12
|
*/
|
|
13
13
|
export const BoardLegalDots = /*#__PURE__*/React.memo(function BoardLegalDots({
|
|
14
14
|
legalMoves,
|