kokopu-react 3.3.5 → 3.4.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 (59) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CREDITS.md +5 -1
  3. package/dist/lib/chessboard/BoardProperties.d.ts +4 -0
  4. package/dist/lib/chessboard/BoardProperties.js +1 -0
  5. package/dist/lib/chessboard/BoardProperties.js.map +1 -1
  6. package/dist/lib/chessboard/Chessboard.js +2 -1
  7. package/dist/lib/chessboard/Chessboard.js.map +1 -1
  8. package/dist/lib/chessboard/ChessboardImpl.d.ts +1 -0
  9. package/dist/lib/chessboard/ChessboardImpl.js +3 -1
  10. package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
  11. package/dist/lib/chessboard/Sound.d.ts +29 -0
  12. package/dist/lib/chessboard/Sound.js +53 -0
  13. package/dist/lib/chessboard/Sound.js.map +1 -0
  14. package/dist/lib/chessboard/sounds/move.ogg +0 -0
  15. package/dist/lib/icons/ChessPieceIcon.js +4 -4
  16. package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
  17. package/dist/lib/navigationboard/NavigationBoard.d.ts +1 -0
  18. package/dist/lib/navigationboard/NavigationBoard.js +1 -1
  19. package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
  20. package/doc_src/demo/NavigationBoardWithMoveText.txt +1 -1
  21. package/doc_src/demo/PageChessboardMove.tsx +8 -0
  22. package/doc_src/demo/PageMovetextInteraction.tsx +1 -1
  23. package/doc_src/demo/PageNavigationBoardBase.tsx +11 -1
  24. package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +4 -2
  25. package/doc_src/demo/PageSynchroNavigationBoardMovetext.tsx +1 -1
  26. package/doc_src/webpack_configuration.md +2 -1
  27. package/package.json +25 -26
  28. package/scripts/doc.styleguide.config.js +1 -1
  29. package/scripts/doc.tsconfig.json +1 -1
  30. package/scripts/test-graphic.webpack.config.js +1 -1
  31. package/scripts/test-headless.webpack.config.js +1 -1
  32. package/src/chessboard/BoardProperties.ts +6 -0
  33. package/src/chessboard/Chessboard.tsx +2 -1
  34. package/src/chessboard/ChessboardImpl.tsx +3 -0
  35. package/src/chessboard/Sound.tsx +71 -0
  36. package/src/chessboard/sounds/move.ogg +0 -0
  37. package/src/decs.d.ts +5 -0
  38. package/src/icons/ChessPieceIcon.tsx +5 -5
  39. package/src/navigationboard/NavigationBoard.tsx +1 -1
  40. package/test/01_types.js +81 -82
  41. package/test/02_chessboard_util.js +12 -12
  42. package/test/06_chessboard_animation.js +21 -3
  43. package/test/11_movetext_interaction.js +7 -7
  44. package/test/12_navigation_board_base.js +2 -2
  45. package/test/common/graphic.js +12 -3
  46. package/test/graphic_references/06_chessboard_animation/sound/with_move.png +0 -0
  47. package/test/graphic_references/06_chessboard_animation/sound/without_move.png +0 -0
  48. package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +4 -4
  49. package/test/graphic_test_app/05_chessboard_graphic/base.tsx +1 -1
  50. package/test/graphic_test_app/05_chessboard_graphic/flipped.tsx +5 -5
  51. package/test/graphic_test_app/05_chessboard_graphic/move.tsx +2 -2
  52. package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +3 -3
  53. package/test/graphic_test_app/06_chessboard_animation/base_1.tsx +6 -6
  54. package/test/graphic_test_app/06_chessboard_animation/base_2.tsx +6 -6
  55. package/test/graphic_test_app/06_chessboard_animation/base_3.tsx +6 -6
  56. package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +3 -2
  57. package/test/graphic_test_app/06_chessboard_animation/sound.tsx +52 -0
  58. package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +1 -1
  59. package/test/graphic_test_app/common/test_app.tsx +5 -4
@@ -29,10 +29,10 @@ import { Chessboard } from '../../../dist/lib/index';
29
29
  window['__kokopu_debug_freeze_motion'] = 0.09;
30
30
 
31
31
  testApp([ /* eslint-disable react/jsx-key */
32
- <Chessboard move="e4" animated={true} />,
33
- <Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
34
- <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped turnVisible={false} />,
35
- <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
36
- <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
37
- <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} turnVisible={false} />,
32
+ <Chessboard move="e4" animated />,
33
+ <Chessboard move="Nf3" animated moveArrowVisible={false} />,
34
+ <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated flipped turnVisible={false} />,
35
+ <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated />,
36
+ <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated />,
37
+ <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated turnVisible={false} />,
38
38
  ]); /* eslint-enable react/jsx-key */
@@ -29,10 +29,10 @@ import { Chessboard } from '../../../dist/lib/index';
29
29
  window['__kokopu_debug_freeze_motion'] = 0.7;
30
30
 
31
31
  testApp([ /* eslint-disable react/jsx-key */
32
- <Chessboard move="e4" animated={true} />,
33
- <Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
34
- <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped turnVisible={false} />,
35
- <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
36
- <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
37
- <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} turnVisible={false} />,
32
+ <Chessboard move="e4" animated />,
33
+ <Chessboard move="Nf3" animated moveArrowVisible={false} />,
34
+ <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated flipped turnVisible={false} />,
35
+ <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated />,
36
+ <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated />,
37
+ <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated turnVisible={false} />,
38
38
  ]); /* eslint-enable react/jsx-key */
@@ -29,10 +29,10 @@ import { Chessboard } from '../../../dist/lib/index';
29
29
  window['__kokopu_debug_freeze_motion'] = 0.91;
30
30
 
31
31
  testApp([ /* eslint-disable react/jsx-key */
32
- <Chessboard move="e4" animated={true} />,
33
- <Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
34
- <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped turnVisible={false} />,
35
- <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
36
- <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
37
- <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} turnVisible={false} />,
32
+ <Chessboard move="e4" animated />,
33
+ <Chessboard move="Nf3" animated moveArrowVisible={false} />,
34
+ <Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated flipped turnVisible={false} />,
35
+ <Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated />,
36
+ <Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated />,
37
+ <Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated turnVisible={false} />,
38
38
  ]); /* eslint-enable react/jsx-key */
@@ -34,15 +34,16 @@ function TestComponent() {
34
34
 
35
35
  function onClick() {
36
36
  window['__kokopu_debug_freeze_motion'] = 0.6;
37
+ window['__kokopu_debug_sound'] = '';
37
38
  setClicked(true);
38
39
  }
39
40
 
40
41
  return (
41
42
  <>
42
43
  <div>
43
- <Chessboard position={position} move={move} animated={true} />
44
+ <Chessboard position={position} move={move} animated sound />
44
45
  </div>
45
- {clicked ? undefined : <button id="chessboard-action-button" onClick={onClick}>Click here</button>}
46
+ {clicked ? undefined : <button id="chessboard-actionButton" onClick={onClick}>Click here</button>}
46
47
  </>
47
48
  );
48
49
  }
@@ -0,0 +1,52 @@
1
+ /*!
2
+ * -------------------------------------------------------------------------- *
3
+ * *
4
+ * Kokopu-React - A React-based library of chess-related components. *
5
+ * <https://www.npmjs.com/package/kokopu-react> *
6
+ * Copyright (C) 2021-2026 Yoann Le Montagner <yo35 -at- melix.net> *
7
+ * *
8
+ * Kokopu-React is free software: you can redistribute it and/or *
9
+ * modify it under the terms of the GNU Lesser General Public License *
10
+ * as published by the Free Software Foundation, either version 3 of *
11
+ * the License, or (at your option) any later version. *
12
+ * *
13
+ * Kokopu-React is distributed in the hope that it will be useful, *
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
+ * GNU Lesser General Public License for more details. *
17
+ * *
18
+ * You should have received a copy of the GNU Lesser General *
19
+ * Public License along with this program. If not, see *
20
+ * <http://www.gnu.org/licenses/>. *
21
+ * *
22
+ * -------------------------------------------------------------------------- */
23
+
24
+
25
+ import * as React from 'react';
26
+ import { testApp } from '../common/test_app';
27
+ import { Chessboard } from '../../../dist/lib/index';
28
+
29
+
30
+ /**
31
+ * REMARK: do NOT display the chessboards by default, because:
32
+ * - we want to know which one plays the sound,
33
+ * - there could be some issues with the auto-play policies of browsers.
34
+ */
35
+ function TestComponent({ move }: { move?: string }) {
36
+
37
+ const [ clicked, setClicked ] = React.useState(false);
38
+
39
+ function onClick() {
40
+ window['__kokopu_debug_sound'] = '';
41
+ setClicked(true);
42
+ }
43
+
44
+ const id = `chessboard-actionButton-${move === undefined ? 'noMove' : 'withMove'}`;
45
+ return clicked ? <Chessboard move={move} sound /> : <button id={id} onClick={onClick}>Click here</button>;
46
+ }
47
+
48
+
49
+ testApp([ /* eslint-disable react/jsx-key */
50
+ <TestComponent />,
51
+ <TestComponent move="e4" />,
52
+ ]); /* eslint-enable react/jsx-key */
@@ -85,5 +85,5 @@ testApp([ /* eslint-disable react/jsx-key */
85
85
  }}
86
86
  />,
87
87
  <NavigationBoardWithIsPlayingController />,
88
- <NavigationBoard game={pgn} playButtonVisible initialNodeId="20b" isPlaying={true} />,
88
+ <NavigationBoard game={pgn} playButtonVisible initialNodeId="20b" isPlaying />,
89
89
  ]); /* eslint-enable react/jsx-key */
@@ -28,12 +28,13 @@ import { createRoot } from 'react-dom/client';
28
28
  import './test_app.css';
29
29
 
30
30
 
31
- // This global variable allows to freeze animations in an intermediate stage.
31
+ // These global variables are used for testing purposes.
32
+ /* eslint-disable camelcase */
32
33
  declare global {
33
- interface Window {
34
- __kokopu_debug_freeze_motion: number,
35
- }
34
+ var __kokopu_debug_freeze_motion: number;
35
+ var __kokopu_debug_sound: string;
36
36
  }
37
+ /* eslint-enable */
37
38
 
38
39
 
39
40
  interface TestItemContainerProps {