react-native-chess-kit 0.1.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +168 -0
  3. package/lib/commonjs/board-background.js +49 -0
  4. package/lib/commonjs/board-background.js.map +1 -0
  5. package/lib/commonjs/board-coordinates.js +78 -0
  6. package/lib/commonjs/board-coordinates.js.map +1 -0
  7. package/lib/commonjs/board-drag-ghost.js +110 -0
  8. package/lib/commonjs/board-drag-ghost.js.map +1 -0
  9. package/lib/commonjs/board-legal-dots.js +67 -0
  10. package/lib/commonjs/board-legal-dots.js.map +1 -0
  11. package/lib/commonjs/board-piece.js +74 -0
  12. package/lib/commonjs/board-piece.js.map +1 -0
  13. package/lib/commonjs/board-pieces.js +47 -0
  14. package/lib/commonjs/board-pieces.js.map +1 -0
  15. package/lib/commonjs/board.js +188 -0
  16. package/lib/commonjs/board.js.map +1 -0
  17. package/lib/commonjs/index.js +26 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/package.json +1 -0
  20. package/lib/commonjs/types.js +6 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/commonjs/use-board-gesture.js +158 -0
  23. package/lib/commonjs/use-board-gesture.js.map +1 -0
  24. package/lib/commonjs/use-board-pieces.js +195 -0
  25. package/lib/commonjs/use-board-pieces.js.map +1 -0
  26. package/lib/commonjs/use-board-state.js +78 -0
  27. package/lib/commonjs/use-board-state.js.map +1 -0
  28. package/lib/module/board-background.js +44 -0
  29. package/lib/module/board-background.js.map +1 -0
  30. package/lib/module/board-coordinates.js +73 -0
  31. package/lib/module/board-coordinates.js.map +1 -0
  32. package/lib/module/board-drag-ghost.js +104 -0
  33. package/lib/module/board-drag-ghost.js.map +1 -0
  34. package/lib/module/board-legal-dots.js +62 -0
  35. package/lib/module/board-legal-dots.js.map +1 -0
  36. package/lib/module/board-piece.js +69 -0
  37. package/lib/module/board-piece.js.map +1 -0
  38. package/lib/module/board-pieces.js +42 -0
  39. package/lib/module/board-pieces.js.map +1 -0
  40. package/lib/module/board.js +184 -0
  41. package/lib/module/board.js.map +1 -0
  42. package/lib/module/index.js +21 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/module/package.json +1 -0
  45. package/lib/module/types.js +4 -0
  46. package/lib/module/types.js.map +1 -0
  47. package/lib/module/use-board-gesture.js +154 -0
  48. package/lib/module/use-board-gesture.js.map +1 -0
  49. package/lib/module/use-board-pieces.js +189 -0
  50. package/lib/module/use-board-pieces.js.map +1 -0
  51. package/lib/module/use-board-state.js +74 -0
  52. package/lib/module/use-board-state.js.map +1 -0
  53. package/lib/typescript/board-background.d.ts +15 -0
  54. package/lib/typescript/board-background.d.ts.map +1 -0
  55. package/lib/typescript/board-coordinates.d.ts +20 -0
  56. package/lib/typescript/board-coordinates.d.ts.map +1 -0
  57. package/lib/typescript/board-drag-ghost.d.ts +21 -0
  58. package/lib/typescript/board-drag-ghost.d.ts.map +1 -0
  59. package/lib/typescript/board-legal-dots.d.ts +16 -0
  60. package/lib/typescript/board-legal-dots.d.ts.map +1 -0
  61. package/lib/typescript/board-piece.d.ts +36 -0
  62. package/lib/typescript/board-piece.d.ts.map +1 -0
  63. package/lib/typescript/board-pieces.d.ts +22 -0
  64. package/lib/typescript/board-pieces.d.ts.map +1 -0
  65. package/lib/typescript/board.d.ts +17 -0
  66. package/lib/typescript/board.d.ts.map +1 -0
  67. package/lib/typescript/index.d.ts +4 -0
  68. package/lib/typescript/index.d.ts.map +1 -0
  69. package/lib/typescript/types.d.ts +88 -0
  70. package/lib/typescript/types.d.ts.map +1 -0
  71. package/lib/typescript/use-board-gesture.d.ts +46 -0
  72. package/lib/typescript/use-board-gesture.d.ts.map +1 -0
  73. package/lib/typescript/use-board-pieces.d.ts +23 -0
  74. package/lib/typescript/use-board-pieces.d.ts.map +1 -0
  75. package/lib/typescript/use-board-state.d.ts +35 -0
  76. package/lib/typescript/use-board-state.d.ts.map +1 -0
  77. package/package.json +73 -0
  78. package/src/board-background.tsx +46 -0
  79. package/src/board-coordinates.tsx +98 -0
  80. package/src/board-drag-ghost.tsx +132 -0
  81. package/src/board-legal-dots.tsx +73 -0
  82. package/src/board-piece.tsx +104 -0
  83. package/src/board-pieces.tsx +56 -0
  84. package/src/board.tsx +203 -0
  85. package/src/index.ts +39 -0
  86. package/src/types.ts +114 -0
  87. package/src/use-board-gesture.ts +201 -0
  88. package/src/use-board-pieces.ts +158 -0
  89. package/src/use-board-state.ts +104 -0
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBoardState = useBoardState;
7
+ var _react = require("react");
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.
17
+ */
18
+ function useBoardState(initialFen) {
19
+ const chessRef = (0, _react.useRef)(null);
20
+ if (!chessRef.current) chessRef.current = new _chess.Chess(initialFen);
21
+ const getLegalMoves = (0, _react.useCallback)(square => {
22
+ try {
23
+ const moves = chessRef.current.moves({
24
+ square: square,
25
+ verbose: true
26
+ });
27
+ return moves.map(m => ({
28
+ square: m.to,
29
+ isCapture: m.captured !== undefined
30
+ }));
31
+ } catch {
32
+ return [];
33
+ }
34
+ }, []);
35
+ const isPlayerPiece = (0, _react.useCallback)((square, pieces, player) => {
36
+ const piece = pieces.find(p => p.square === square);
37
+ if (!piece) return false;
38
+ if (player === 'both') return true;
39
+ const pieceColor = piece.color === 'w' ? 'white' : 'black';
40
+ return pieceColor === player;
41
+ }, []);
42
+ const applyMove = (0, _react.useCallback)((from, to, promotion) => {
43
+ try {
44
+ chessRef.current.move({
45
+ from: from,
46
+ to: to,
47
+ promotion: promotion
48
+ });
49
+ return {
50
+ applied: true,
51
+ fen: chessRef.current.fen()
52
+ };
53
+ } catch {
54
+ return {
55
+ applied: false
56
+ };
57
+ }
58
+ }, []);
59
+ const undoMove = (0, _react.useCallback)(() => {
60
+ const result = chessRef.current.undo();
61
+ return result ? chessRef.current.fen() : null;
62
+ }, []);
63
+ const loadFen = (0, _react.useCallback)(fen => {
64
+ chessRef.current.load(fen);
65
+ }, []);
66
+ const getFen = (0, _react.useCallback)(() => chessRef.current.fen(), []);
67
+ const getTurn = (0, _react.useCallback)(() => chessRef.current.turn(), []);
68
+ return {
69
+ getLegalMoves,
70
+ isPlayerPiece,
71
+ applyMove,
72
+ undoMove,
73
+ loadFen,
74
+ getFen,
75
+ getTurn
76
+ };
77
+ }
78
+ //# sourceMappingURL=use-board-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_chess","useBoardState","initialFen","chessRef","useRef","current","Chess","getLegalMoves","useCallback","square","moves","verbose","map","m","to","isCapture","captured","undefined","isPlayerPiece","pieces","player","piece","find","p","pieceColor","color","applyMove","from","promotion","move","applied","fen","undoMove","result","undo","loadFen","load","getFen","getTurn","turn"],"sourceRoot":"..\\..\\src","sources":["use-board-state.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAACC,UAAkB,EAAoB;EAClE,MAAMC,QAAQ,GAAG,IAAAC,aAAM,EAAQ,IAAK,CAAC;EACrC,IAAI,CAACD,QAAQ,CAACE,OAAO,EAAEF,QAAQ,CAACE,OAAO,GAAG,IAAIC,YAAK,CAACJ,UAAU,CAAC;EAE/D,MAAMK,aAAa,GAAG,IAAAC,kBAAW,EAAEC,MAAc,IAAwB;IACvE,IAAI;MACF,MAAMC,KAAK,GAAGP,QAAQ,CAACE,OAAO,CAACK,KAAK,CAAC;QAAED,MAAM,EAAEA,MAAgB;QAA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G9B,QAAQ,CAACE,OAAO,CAAC6B,IAAI,CAAC,CAAC;IACtC,OAAOD,MAAM,GAAG9B,QAAQ,CAACE,OAAO,CAAC0B,GAAG,CAAC,CAAC,GAAG,IAAI;EAC/C,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMI,OAAO,GAAG,IAAA3B,kBAAW,EAAEuB,GAAW,IAAK;IAC3C5B,QAAQ,CAACE,OAAO,CAAC+B,IAAI,CAACL,GAAG,CAAC;EAC5B,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,MAAM,GAAG,IAAA7B,kBAAW,EAAC,MAAML,QAAQ,CAACE,OAAO,CAAC0B,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;EAE5D,MAAMO,OAAO,GAAG,IAAA9B,kBAAW,EAAC,MAAML,QAAQ,CAACE,OAAO,CAACkC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;EAE9D,OAAO;IACLhC,aAAa;IACbW,aAAa;IACbQ,SAAS;IACTM,QAAQ;IACRG,OAAO;IACPE,MAAM;IACNC;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { View } from 'react-native';
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.
11
+ */
12
+ export const BoardBackground = /*#__PURE__*/React.memo(function BoardBackground({
13
+ boardSize,
14
+ lightColor,
15
+ darkColor
16
+ }) {
17
+ const squareSize = boardSize / 8;
18
+ return /*#__PURE__*/_jsx(View, {
19
+ style: {
20
+ width: boardSize,
21
+ height: boardSize,
22
+ flexDirection: 'row',
23
+ flexWrap: 'wrap'
24
+ },
25
+ children: SQUARE_INDICES.map(i => {
26
+ const row = Math.floor(i / 8);
27
+ const col = i % 8;
28
+ const isLight = (row + col) % 2 === 0;
29
+ return /*#__PURE__*/_jsx(View, {
30
+ style: {
31
+ width: squareSize,
32
+ height: squareSize,
33
+ backgroundColor: isLight ? lightColor : darkColor
34
+ }
35
+ }, i);
36
+ })
37
+ });
38
+ });
39
+
40
+ // Pre-computed array of 0-63 to avoid allocation on every render
41
+ const SQUARE_INDICES = Array.from({
42
+ length: 64
43
+ }, (_, i) => i);
44
+ //# sourceMappingURL=board-background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","jsx","_jsx","BoardBackground","memo","boardSize","lightColor","darkColor","squareSize","style","width","height","flexDirection","flexWrap","children","SQUARE_INDICES","map","i","row","Math","floor","col","isLight","backgroundColor","Array","from","length","_"],"sourceRoot":"..\\..\\src","sources":["board-background.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQpC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,gBAAGJ,KAAK,CAACK,IAAI,CAAC,SAASD,eAAeA,CAAC;EACjEE,SAAS;EACTC,UAAU;EACVC;AACoB,CAAC,EAAE;EACvB,MAAMC,UAAU,GAAGH,SAAS,GAAG,CAAC;EAEhC,oBACEH,IAAA,CAACF,IAAI;IAACS,KAAK,EAAE;MAAEC,KAAK,EAAEL,SAAS;MAAEM,MAAM,EAAEN,SAAS;MAAEO,aAAa,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAO,CAAE;IAAAC,QAAA,EAC1FC,cAAc,CAACC,GAAG,CAAEC,CAAC,IAAK;MACzB,MAAMC,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACH,CAAC,GAAG,CAAC,CAAC;MAC7B,MAAMI,GAAG,GAAGJ,CAAC,GAAG,CAAC;MACjB,MAAMK,OAAO,GAAG,CAACJ,GAAG,GAAGG,GAAG,IAAI,CAAC,KAAK,CAAC;MAErC,oBACEnB,IAAA,CAACF,IAAI;QAEHS,KAAK,EAAE;UACLC,KAAK,EAAEF,UAAU;UACjBG,MAAM,EAAEH,UAAU;UAClBe,eAAe,EAAED,OAAO,GAAGhB,UAAU,GAAGC;QAC1C;MAAE,GALGU,CAMN,CAAC;IAEN,CAAC;EAAC,CACE,CAAC;AAEX,CAAC,CAAC;;AAEF;AACA,MAAMF,cAAc,GAAGS,KAAK,CAACC,IAAI,CAAC;EAAEC,MAAM,EAAE;AAAG,CAAC,EAAE,CAACC,CAAC,EAAEV,CAAC,KAAKA,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { View, Text } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const FILES_WHITE = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
7
+ const FILES_BLACK = ['h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'];
8
+ const RANKS_WHITE = ['8', '7', '6', '5', '4', '3', '2', '1'];
9
+ const RANKS_BLACK = ['1', '2', '3', '4', '5', '6', '7', '8'];
10
+
11
+ /**
12
+ * File letters (a-h) and rank numbers (1-8) drawn on the board edges.
13
+ *
14
+ * Rendered as absolute-positioned Text components inside each corner square.
15
+ * File letters appear on the bottom rank, rank numbers on the left file.
16
+ * Colors alternate to contrast with the square behind them.
17
+ */
18
+ export const BoardCoordinates = /*#__PURE__*/React.memo(function BoardCoordinates({
19
+ boardSize,
20
+ orientation,
21
+ lightColor,
22
+ darkColor,
23
+ withLetters,
24
+ withNumbers
25
+ }) {
26
+ if (!withLetters && !withNumbers) return null;
27
+ const squareSize = boardSize / 8;
28
+ const fontSize = squareSize * 0.22;
29
+ const padding = squareSize * 0.06;
30
+ const files = orientation === 'white' ? FILES_WHITE : FILES_BLACK;
31
+ const ranks = orientation === 'white' ? RANKS_WHITE : RANKS_BLACK;
32
+ return /*#__PURE__*/_jsxs(View, {
33
+ style: {
34
+ position: 'absolute',
35
+ width: boardSize,
36
+ height: boardSize
37
+ },
38
+ pointerEvents: "none",
39
+ children: [withNumbers && ranks.map((rank, row) => {
40
+ // First column square: row 0 col 0 = light if (0+0)%2===0
41
+ const isLight = row % 2 === 0;
42
+ const textColor = isLight ? darkColor : lightColor;
43
+ return /*#__PURE__*/_jsx(Text, {
44
+ style: {
45
+ position: 'absolute',
46
+ left: padding,
47
+ top: row * squareSize + padding,
48
+ fontSize,
49
+ fontWeight: '700',
50
+ color: textColor
51
+ },
52
+ children: rank
53
+ }, `r-${rank}`);
54
+ }), withLetters && files.map((file, col) => {
55
+ // Last row (7), column col: light if (7+col)%2===0
56
+ const isLight = (7 + col) % 2 === 0;
57
+ const textColor = isLight ? darkColor : lightColor;
58
+ return /*#__PURE__*/_jsx(Text, {
59
+ style: {
60
+ position: 'absolute',
61
+ right: (7 - col) * squareSize + padding,
62
+ bottom: padding,
63
+ fontSize,
64
+ fontWeight: '700',
65
+ color: textColor,
66
+ textAlign: 'right'
67
+ },
68
+ children: file
69
+ }, `f-${file}`);
70
+ })]
71
+ });
72
+ });
73
+ //# sourceMappingURL=board-coordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","Text","jsx","_jsx","jsxs","_jsxs","FILES_WHITE","FILES_BLACK","RANKS_WHITE","RANKS_BLACK","BoardCoordinates","memo","boardSize","orientation","lightColor","darkColor","withLetters","withNumbers","squareSize","fontSize","padding","files","ranks","style","position","width","height","pointerEvents","children","map","rank","row","isLight","textColor","left","top","fontWeight","color","file","col","right","bottom","textAlign"],"sourceRoot":"..\\..\\src","sources":["board-coordinates.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAa1C,MAAMC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;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K,CAAC;MAC7B,MAAME,SAAS,GAAGD,OAAO,GAAGjB,SAAS,GAAGD,UAAU;MAElD,oBACEX,IAAA,CAACF,IAAI;QAEHsB,KAAK,EAAE;UACLC,QAAQ,EAAE,UAAU;UACpBU,IAAI,EAAEd,OAAO;UACbe,GAAG,EAAEJ,GAAG,GAAGb,UAAU,GAAGE,OAAO;UAC/BD,QAAQ;UACRiB,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEJ;QACT,CAAE;QAAAL,QAAA,EAEDE;MAAI,GAVA,KAAKA,IAAI,EAWV,CAAC;IAEX,CAAC,CAAC,EAGHd,WAAW,IACVK,KAAK,CAACQ,GAAG,CAAC,CAACS,IAAI,EAAEC,GAAG,KAAK;MACvB;MACA,MAAMP,OAAO,GAAG,CAAC,CAAC,GAAGO,GAAG,IAAI,CAAC,KAAK,CAAC;MACnC,MAAMN,SAAS,GAAGD,OAAO,GAAGjB,SAAS,GAAGD,UAAU;MAElD,oBACEX,IAAA,CAACF,IAAI;QAEHsB,KAAK,EAAE;UACLC,QAAQ,EAAE,UAAU;UACpBgB,KAAK,EAAE,CAAC,CAAC,GAAGD,GAAG,IAAIrB,UAAU,GAAGE,OAAO;UACvCqB,MAAM,EAAErB,OAAO;UACfD,QAAQ;UACRiB,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEJ,SAAS;UAChBS,SAAS,EAAE;QACb,CAAE;QAAAd,QAAA,EAEDU;MAAI,GAXA,KAAKA,IAAI,EAYV,CAAC;IAEX,CAAC,CAAC;EAAA,CACA,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import Animated, { useAnimatedStyle } from 'react-native-reanimated';
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.
12
+ */
13
+ export const BoardDragGhost = /*#__PURE__*/React.memo(function BoardDragGhost({
14
+ squareSize,
15
+ isDragging,
16
+ dragX,
17
+ dragY,
18
+ dragPieceCode,
19
+ renderPiece
20
+ }) {
21
+ const animatedStyle = useAnimatedStyle(() => {
22
+ if (!isDragging.value || !dragPieceCode.value) {
23
+ return {
24
+ opacity: 0,
25
+ transform: [{
26
+ translateX: 0
27
+ }, {
28
+ translateY: 0
29
+ }]
30
+ };
31
+ }
32
+ return {
33
+ opacity: 1,
34
+ // Center the piece on the finger, slightly above for visibility
35
+ transform: [{
36
+ translateX: dragX.value - squareSize / 2
37
+ }, {
38
+ translateY: dragY.value - squareSize
39
+ }, {
40
+ scale: 1.1
41
+ }]
42
+ };
43
+ });
44
+ return /*#__PURE__*/_jsx(Animated.View, {
45
+ style: [{
46
+ position: 'absolute',
47
+ width: squareSize,
48
+ height: squareSize,
49
+ zIndex: 100
50
+ }, animatedStyle],
51
+ pointerEvents: "none",
52
+ children: /*#__PURE__*/_jsx(DragGhostContent, {
53
+ renderPiece: renderPiece,
54
+ squareSize: squareSize,
55
+ dragPieceCode: dragPieceCode
56
+ })
57
+ });
58
+ });
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.
64
+ */
65
+ const DragGhostContent = /*#__PURE__*/React.memo(function DragGhostContent({
66
+ renderPiece,
67
+ squareSize,
68
+ dragPieceCode
69
+ }) {
70
+ // We render all 12 possible piece types and show/hide based on dragPieceCode.
71
+ // This avoids re-mounting the Image component during drag.
72
+ // Only the opacity changes — pure worklet animation.
73
+ const codes = PIECE_CODES;
74
+ return /*#__PURE__*/_jsx(_Fragment, {
75
+ children: codes.map(code => /*#__PURE__*/_jsx(GhostPieceSlot, {
76
+ code: code,
77
+ squareSize: squareSize,
78
+ dragPieceCode: dragPieceCode,
79
+ renderPiece: renderPiece
80
+ }, code))
81
+ });
82
+ });
83
+ const GhostPieceSlot = /*#__PURE__*/React.memo(function GhostPieceSlot({
84
+ code,
85
+ squareSize,
86
+ dragPieceCode,
87
+ renderPiece
88
+ }) {
89
+ const animatedStyle = useAnimatedStyle(() => ({
90
+ opacity: dragPieceCode.value === code ? 1 : 0
91
+ }));
92
+ return /*#__PURE__*/_jsx(Animated.View, {
93
+ style: [{
94
+ position: 'absolute',
95
+ width: squareSize,
96
+ height: squareSize
97
+ }, animatedStyle],
98
+ children: renderPiece(code, squareSize)
99
+ });
100
+ });
101
+
102
+ // All 12 piece codes — pre-computed to avoid allocation
103
+ const PIECE_CODES = ['wp', 'wn', 'wb', 'wr', 'wq', 'wk', 'bp', 'bn', 'bb', 'br', 'bq', 'bk'];
104
+ //# sourceMappingURL=board-drag-ghost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Animated","useAnimatedStyle","jsx","_jsx","Fragment","_Fragment","BoardDragGhost","memo","squareSize","isDragging","dragX","dragY","dragPieceCode","renderPiece","animatedStyle","value","opacity","transform","translateX","translateY","scale","View","style","position","width","height","zIndex","pointerEvents","children","DragGhostContent","codes","PIECE_CODES","map","code","GhostPieceSlot"],"sourceRoot":"..\\..\\src","sources":["board-drag-ghost.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,QAAQ,IACbC,gBAAgB,QAEX,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAYjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,gBAAGP,KAAK,CAACQ,IAAI,CAAC,SAASD,cAAcA,CAAC;EAC/DE,UAAU;EACVC,UAAU;EACVC,KAAK;EACLC,KAAK;EACLC,aAAa;EACbC;AACmB,CAAC,EAAE;EACtB,MAAMC,aAAa,GAAGb,gBAAgB,CAAC,MAAM;IAC3C,IAAI,CAACQ,UAAU,CAACM,KAAK,IAAI,CAACH,aAAa,CAAC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AW,EAAEA;IAAY,GAJpBoB,IAKN,CACF;EAAC,CACF,CAAC;AAEP,CAAC,CAAC;AAEF,MAAMC,cAAc,gBAAGnC,KAAK,CAACQ,IAAI,CAAC,SAAS2B,cAAcA,CAAC;EACxDD,IAAI;EACJzB,UAAU;EACVI,aAAa;EACbC;AAMF,CAAC,EAAE;EACD,MAAMC,aAAa,GAAGb,gBAAgB,CAAC,OAAO;IAC5Ce,OAAO,EAAEJ,aAAa,CAACG,KAAK,KAAKkB,IAAI,GAAG,CAAC,GAAG;EAC9C,CAAC,CAAC,CAAC;EAEH,oBACE9B,IAAA,CAACH,QAAQ,CAACqB,IAAI;IACZC,KAAK,EAAE,CACL;MAAEC,QAAQ,EAAE,UAAU;MAAEC,KAAK,EAAEhB,UAAU;MAAEiB,MAAM,EAAEjB;IAAW,CAAC,EAC/DM,aAAa,CACb;IAAAc,QAAA,EAEDf,WAAW,CAACoB,IAAI,EAAEzB,UAAU;EAAC,CACjB,CAAC;AAEpB,CAAC,CAAC;;AAEF;AACA,MAAMuB,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { View } from 'react-native';
5
+ import { squareToXY } from './use-board-pieces';
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.
12
+ */
13
+ export const BoardLegalDots = /*#__PURE__*/React.memo(function BoardLegalDots({
14
+ legalMoves,
15
+ squareSize,
16
+ orientation
17
+ }) {
18
+ if (legalMoves.length === 0) return null;
19
+ const dotSize = squareSize * 0.28;
20
+ const ringSize = squareSize * 0.85;
21
+ const borderWidth = squareSize * 0.08;
22
+ return /*#__PURE__*/_jsx(View, {
23
+ style: {
24
+ position: 'absolute',
25
+ width: squareSize * 8,
26
+ height: squareSize * 8
27
+ },
28
+ pointerEvents: "none",
29
+ children: legalMoves.map(move => {
30
+ const {
31
+ x,
32
+ y
33
+ } = squareToXY(move.square, squareSize, orientation);
34
+ if (move.isCapture) {
35
+ return /*#__PURE__*/_jsx(View, {
36
+ style: {
37
+ position: 'absolute',
38
+ left: x + (squareSize - ringSize) / 2,
39
+ top: y + (squareSize - ringSize) / 2,
40
+ width: ringSize,
41
+ height: ringSize,
42
+ borderRadius: ringSize / 2,
43
+ borderWidth,
44
+ borderColor: 'rgba(0, 0, 0, 0.25)'
45
+ }
46
+ }, move.square);
47
+ }
48
+ return /*#__PURE__*/_jsx(View, {
49
+ style: {
50
+ position: 'absolute',
51
+ left: x + (squareSize - dotSize) / 2,
52
+ top: y + (squareSize - dotSize) / 2,
53
+ width: dotSize,
54
+ height: dotSize,
55
+ borderRadius: dotSize / 2,
56
+ backgroundColor: 'rgba(0, 0, 0, 0.25)'
57
+ }
58
+ }, move.square);
59
+ })
60
+ });
61
+ });
62
+ //# sourceMappingURL=board-legal-dots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","squareToXY","jsx","_jsx","BoardLegalDots","memo","legalMoves","squareSize","orientation","length","dotSize","ringSize","borderWidth","style","position","width","height","pointerEvents","children","map","move","x","y","square","isCapture","left","top","borderRadius","borderColor","backgroundColor"],"sourceRoot":"..\\..\\src","sources":["board-legal-dots.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAGnC,SAASC,UAAU,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQhD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,gBAAGL,KAAK,CAACM,IAAI,CAAC,SAASD,cAAcA,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AG,CAACf,UAAU,GAAGG,OAAO,IAAI,CAAC;UACnCK,KAAK,EAAEL,OAAO;UACdM,MAAM,EAAEN,OAAO;UACfiB,YAAY,EAAEjB,OAAO,GAAG,CAAC;UACzBmB,eAAe,EAAE;QACnB;MAAE,GATGT,IAAI,CAACG,MAUX,CAAC;IAEN,CAAC;EAAC,CACE,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect } from 'react';
4
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ /**
7
+ * A single animated chess piece.
8
+ *
9
+ * Animates ONLY `transform` and `opacity` — Reanimated's fast path on Android.
10
+ * No layout properties (top/left/width/height) are animated, avoiding costly
11
+ * layout recalculations on low-end devices.
12
+ *
13
+ * During drag:
14
+ * - Original piece hides (opacity: 0) — the drag ghost shows instead
15
+ * - No position changes on the original piece during drag
16
+ *
17
+ * After a move:
18
+ * - Snaps to new position via withTiming on translateX/translateY
19
+ * - Duration controlled by user's animation speed setting
20
+ */
21
+ export const BoardPieceView = /*#__PURE__*/React.memo(function BoardPieceView({
22
+ targetX,
23
+ targetY,
24
+ squareSize,
25
+ moveDuration,
26
+ children,
27
+ activeSquare,
28
+ isDragging,
29
+ square
30
+ }) {
31
+ // Shared values for smooth animated position — written from JS, read on UI thread
32
+ const currentX = useSharedValue(targetX);
33
+ const currentY = useSharedValue(targetY);
34
+
35
+ // When target position changes (piece moved), animate to the new square.
36
+ // useEffect is the correct pattern for reacting to JS prop changes —
37
+ // useDerivedValue is meant for shared-value-to-shared-value derivation.
38
+ useEffect(() => {
39
+ currentX.value = moveDuration > 0 ? withTiming(targetX, {
40
+ duration: moveDuration
41
+ }) : targetX;
42
+ currentY.value = moveDuration > 0 ? withTiming(targetY, {
43
+ duration: moveDuration
44
+ }) : targetY;
45
+ }, [targetX, targetY, moveDuration, currentX, currentY]);
46
+ const animatedStyle = useAnimatedStyle(() => {
47
+ const isBeingDragged = isDragging.value && activeSquare.value === square;
48
+ return {
49
+ transform: [{
50
+ translateX: currentX.value
51
+ }, {
52
+ translateY: currentY.value
53
+ }],
54
+ // Hide original piece during drag — drag ghost renders on top
55
+ opacity: isBeingDragged ? 0 : 1
56
+ };
57
+ });
58
+ return /*#__PURE__*/_jsx(Animated.View, {
59
+ style: [{
60
+ position: 'absolute',
61
+ width: squareSize,
62
+ height: squareSize
63
+ }, animatedStyle],
64
+ children: children
65
+ });
66
+ },
67
+ // Custom comparator: only re-render when position or square changes
68
+ (prev, next) => prev.targetX === next.targetX && prev.targetY === next.targetY && prev.square === next.square && prev.squareSize === next.squareSize && prev.moveDuration === next.moveDuration && prev.children === next.children);
69
+ //# sourceMappingURL=board-piece.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","Animated","useAnimatedStyle","useSharedValue","withTiming","jsx","_jsx","BoardPieceView","memo","targetX","targetY","squareSize","moveDuration","children","activeSquare","isDragging","square","currentX","currentY","value","duration","animatedStyle","isBeingDragged","transform","translateX","translateY","opacity","View","style","position","width","height","prev","next"],"sourceRoot":"..\\..\\src","sources":["board-piece.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QAEL,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAmBjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,gBAAGR,KAAK,CAACS,IAAI,CACtC,SAASD,cAAcA,CAAC;EACtBE,OAAO;EACPC,OAAO;EACPC,UAAU;EACVC,YAAY;EACZC,QAAQ;EACRC,YAAY;EACZC,UAAU;EACVC;AACe,CAAC,EAAE;EAClB;EACA,MAAMC,QAAQ,GAAGd,cAAc,CAACM,OAAO,CAAC;EAC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B,MAAM,IAC3BgB,IAAI,CAACrB,UAAU,KAAKsB,IAAI,CAACtB,UAAU,IACnCqB,IAAI,CAACpB,YAAY,KAAKqB,IAAI,CAACrB,YAAY,IACvCoB,IAAI,CAACnB,QAAQ,KAAKoB,IAAI,CAACpB,QAC3B,CAAC","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { BoardPieceView } from './board-piece';
5
+ import { squareToXY } from './use-board-pieces';
6
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
7
+ /**
8
+ * Renders all pieces on the board.
9
+ *
10
+ * Each piece gets a stable key (from useBoardPieces) so React doesn't
11
+ * unmount/remount pieces that moved — it updates their position props
12
+ * and the BoardPieceView animates the transition.
13
+ */
14
+ export const BoardPiecesLayer = /*#__PURE__*/React.memo(function BoardPiecesLayer({
15
+ pieces,
16
+ squareSize,
17
+ orientation,
18
+ moveDuration,
19
+ renderPiece,
20
+ activeSquare,
21
+ isDragging
22
+ }) {
23
+ return /*#__PURE__*/_jsx(_Fragment, {
24
+ children: pieces.map(piece => {
25
+ const {
26
+ x,
27
+ y
28
+ } = squareToXY(piece.square, squareSize, orientation);
29
+ return /*#__PURE__*/_jsx(BoardPieceView, {
30
+ targetX: x,
31
+ targetY: y,
32
+ squareSize: squareSize,
33
+ moveDuration: moveDuration,
34
+ activeSquare: activeSquare,
35
+ isDragging: isDragging,
36
+ square: piece.square,
37
+ children: renderPiece(piece.code, squareSize)
38
+ }, piece.id);
39
+ })
40
+ });
41
+ });
42
+ //# sourceMappingURL=board-pieces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","BoardPieceView","squareToXY","jsx","_jsx","Fragment","_Fragment","BoardPiecesLayer","memo","pieces","squareSize","orientation","moveDuration","renderPiece","activeSquare","isDragging","children","map","piece","x","y","square","targetX","targetY","code","id"],"sourceRoot":"..\\..\\src","sources":["board-pieces.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,UAAU,QAAQ,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAYhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,gBAAGP,KAAK,CAACQ,IAAI,CAAC,SAASD,gBAAgBA,CAAC;EACnEE,MAAM;EACNC,UAAU;EACVC,WAAW;EACXC,YAAY;EACZC,WAAW;EACXC,YAAY;EACZC;AACgB,CAAC,EAAE;EACnB,oBACEX,IAAA,CAAAE,SAAA;IAAAU,QAAA,EACGP,MAAM,CAACQ,GAAG,CAAEC,KAAK,IAAK;MACrB,MAAM;QAAEC,CAAC;QAAEC;MAAE,CAAC,GAAGlB,UAAU,CAACgB,KAAK,CAACG,MAAM,EAAEX,UAAU,EAAEC,WAAW,CAAC;MAElE,oBACEP,IAAA,CAACH,cAAc;QAEbqB,OAAO,EAAEH,CAAE;QACXI,OAAO,EAAEH,CAAE;QACXV,UAAU,EAAEA,UAAW;QACvBE,YAAY,EAAEA,YAAa;QAC3BE,YAAY,EAAEA,YAAa;QAC3BC,UAAU,EAAEA,UAAW;QACvBM,MAAM,EAAEH,KAAK,CAACG,MAAO;QAAAL,QAAA,EAEpBH,WAAW,CAACK,KAAK,CAACM,IAAI,EAAEd,UAAU;MAAC,GAT/BQ,KAAK,CAACO,EAUG,CAAC;IAErB,CAAC;EAAC,CACF,CAAC;AAEP,CAAC,CAAC","ignoreList":[]}