kokopu-react 1.8.0 → 1.9.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 (158) hide show
  1. package/dist/lib/ArrowMarkerIcon.js +1 -29
  2. package/dist/lib/Chessboard.js +152 -298
  3. package/dist/lib/ErrorBox.js +7 -24
  4. package/dist/lib/Movetext.js +74 -178
  5. package/dist/lib/SquareMarkerIcon.js +2 -10
  6. package/dist/lib/TextMarkerIcon.js +0 -11
  7. package/dist/lib/css/movetext.css +4 -0
  8. package/dist/lib/formatmove.js +2 -14
  9. package/dist/lib/i18n.js +1 -1
  10. package/dist/lib/impl/ArrowTip.js +2 -8
  11. package/dist/lib/impl/HtmlSanitizer.js +13 -46
  12. package/dist/lib/impl/Motion.js +107 -0
  13. package/dist/lib/impl/TextSymbol.js +2 -11
  14. package/dist/lib/impl/colorsets.js +0 -2
  15. package/dist/lib/impl/piecesets.js +0 -87
  16. package/dist/lib/impl/util.js +1 -11
  17. package/dist/lib/index.js +0 -10
  18. package/dist/lib/markers.js +18 -38
  19. package/graphic_test_src/05_chessboard_move.js +2 -2
  20. package/graphic_test_src/06a_chessboard_animated_move.js +36 -0
  21. package/graphic_test_src/06b_chessboard_animated_move.js +36 -0
  22. package/graphic_test_src/06c_chessboard_animated_move.js +36 -0
  23. package/graphic_test_src/{06_chessboard_theme.js → 07_chessboard_theme.js} +0 -0
  24. package/graphic_test_src/{07_chessboard_click_squares.js → 08_chessboard_click_squares.js} +0 -0
  25. package/graphic_test_src/{08_chessboard_move_pieces.js → 09_chessboard_move_pieces.js} +0 -0
  26. package/graphic_test_src/{09_chessboard_edit_arrows.js → 10_chessboard_edit_arrows.js} +0 -0
  27. package/graphic_test_src/{10_chessboard_play_moves.js → 11_chessboard_play_moves.js} +0 -0
  28. package/graphic_test_src/{11_chessboard_play_promotions.js → 12_chessboard_play_promotions.js} +0 -0
  29. package/graphic_test_src/{12_movetext_simple.js → 13_movetext_simple.js} +0 -0
  30. package/graphic_test_src/{13_movetext_error.js → 14_movetext_error.js} +0 -0
  31. package/graphic_test_src/{14_movetext_html.js → 15_movetext_html.js} +0 -0
  32. package/graphic_test_src/{15_movetext_options.js → 16_movetext_options.js} +0 -0
  33. package/graphic_test_src/{16_movetext_interaction.js → 17_movetext_interaction.js} +0 -0
  34. package/package.json +19 -21
  35. package/scripts/docker-compose.yml +1 -1
  36. package/src/Chessboard.js +24 -20
  37. package/src/css/movetext.css +4 -0
  38. package/src/impl/ArrowTip.js +2 -2
  39. package/src/impl/Motion.js +99 -0
  40. package/test/4_chessboard_graphic.js +4 -1
  41. package/test/5_chessboard_interaction.js +5 -5
  42. package/test/6_chessboard_play_moves.js +4 -4
  43. package/test/7_movetext_graphic.js +4 -4
  44. package/test/8_movetext_interaction.js +2 -2
  45. package/test/common/graphic.js +6 -0
  46. package/test/references/06a_chessboard_animated_move/0.png +0 -0
  47. package/test/references/06a_chessboard_animated_move/1.png +0 -0
  48. package/test/references/06a_chessboard_animated_move/2.png +0 -0
  49. package/test/references/06a_chessboard_animated_move/3.png +0 -0
  50. package/test/references/06a_chessboard_animated_move/4.png +0 -0
  51. package/test/references/06a_chessboard_animated_move/5.png +0 -0
  52. package/test/references/06b_chessboard_animated_move/0.png +0 -0
  53. package/test/references/06b_chessboard_animated_move/1.png +0 -0
  54. package/test/references/06b_chessboard_animated_move/2.png +0 -0
  55. package/test/references/06b_chessboard_animated_move/3.png +0 -0
  56. package/test/references/06b_chessboard_animated_move/4.png +0 -0
  57. package/test/references/06b_chessboard_animated_move/5.png +0 -0
  58. package/test/references/06c_chessboard_animated_move/0.png +0 -0
  59. package/test/references/06c_chessboard_animated_move/1.png +0 -0
  60. package/test/references/06c_chessboard_animated_move/2.png +0 -0
  61. package/test/references/06c_chessboard_animated_move/3.png +0 -0
  62. package/test/references/06c_chessboard_animated_move/4.png +0 -0
  63. package/test/references/06c_chessboard_animated_move/5.png +0 -0
  64. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/0.png +0 -0
  65. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/1.png +0 -0
  66. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/2.png +0 -0
  67. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/3.png +0 -0
  68. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/4.png +0 -0
  69. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/5.png +0 -0
  70. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/6.png +0 -0
  71. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/7.png +0 -0
  72. package/test/references/{06_chessboard_theme → 07_chessboard_theme}/8.png +0 -0
  73. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/after_move.png +0 -0
  74. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/empty_square.png +0 -0
  75. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/null_vector.png +0 -0
  76. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/out_of_board.png +0 -0
  77. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_arrow_marker.png +0 -0
  78. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_empty.png +0 -0
  79. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_1.png +0 -0
  80. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_2.png +0 -0
  81. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_square_marker.png +0 -0
  82. package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_text_marker.png +0 -0
  83. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_1.png +0 -0
  84. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_2.png +0 -0
  85. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/edit_color_not_set.png +0 -0
  86. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/null_vector.png +0 -0
  87. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/out_of_board.png +0 -0
  88. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_arrow_marker.png +0 -0
  89. package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_square_marker.png +0 -0
  90. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/castling_move.png +0 -0
  91. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_ambiguous_king_move.png +0 -0
  92. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_1.png +0 -0
  93. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_2.png +0 -0
  94. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_non_kxr_castling.png +0 -0
  95. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_move.png +0 -0
  96. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_position.png +0 -0
  97. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/null_vector.png +0 -0
  98. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/out_of_board.png +0 -0
  99. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_1.png +0 -0
  100. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_2.png +0 -0
  101. package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/wrong_color.png +0 -0
  102. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/antichess_promotion.png +0 -0
  103. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/cancel_promotion.png +0 -0
  104. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_1.png +0 -0
  105. package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_2.png +0 -0
  106. package/test/references/{12_movetext_simple → 13_movetext_simple}/0.png +0 -0
  107. package/test/references/{12_movetext_simple → 13_movetext_simple}/1.png +0 -0
  108. package/test/references/{12_movetext_simple → 13_movetext_simple}/2.png +0 -0
  109. package/test/references/{12_movetext_simple → 13_movetext_simple}/3.png +0 -0
  110. package/test/references/{13_movetext_error → 14_movetext_error}/0.png +0 -0
  111. package/test/references/{13_movetext_error → 14_movetext_error}/1.png +0 -0
  112. package/test/references/{13_movetext_error → 14_movetext_error}/2.png +0 -0
  113. package/test/references/{13_movetext_error → 14_movetext_error}/3.png +0 -0
  114. package/test/references/{13_movetext_error → 14_movetext_error}/4.png +0 -0
  115. package/test/references/{14_movetext_html → 15_movetext_html}/0.png +0 -0
  116. package/test/references/{14_movetext_html → 15_movetext_html}/1.png +0 -0
  117. package/test/references/{14_movetext_html → 15_movetext_html}/2.png +0 -0
  118. package/test/references/{15_movetext_options → 16_movetext_options}/0.png +0 -0
  119. package/test/references/{15_movetext_options → 16_movetext_options}/1.png +0 -0
  120. package/test/references/{15_movetext_options → 16_movetext_options}/2.png +0 -0
  121. package/test/references/{15_movetext_options → 16_movetext_options}/3.png +0 -0
  122. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/0.png +0 -0
  123. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/1.png +0 -0
  124. package/test/references/{16_movetext_interaction → 17_movetext_interaction}/2.png +0 -0
  125. package/CHANGELOG.md +0 -141
  126. package/graphics/chess_sprites/cburnett/bb.svg +0 -45
  127. package/graphics/chess_sprites/cburnett/bk.svg +0 -47
  128. package/graphics/chess_sprites/cburnett/bn.svg +0 -37
  129. package/graphics/chess_sprites/cburnett/bp.svg +0 -19
  130. package/graphics/chess_sprites/cburnett/bq.svg +0 -58
  131. package/graphics/chess_sprites/cburnett/br.svg +0 -60
  132. package/graphics/chess_sprites/cburnett/bx.svg +0 -56
  133. package/graphics/chess_sprites/cburnett/wb.svg +0 -48
  134. package/graphics/chess_sprites/cburnett/wk.svg +0 -26
  135. package/graphics/chess_sprites/cburnett/wn.svg +0 -37
  136. package/graphics/chess_sprites/cburnett/wp.svg +0 -19
  137. package/graphics/chess_sprites/cburnett/wq.svg +0 -60
  138. package/graphics/chess_sprites/cburnett/wr.svg +0 -44
  139. package/graphics/chess_sprites/cburnett/wx.svg +0 -56
  140. package/graphics/chess_sprites/generate_sprites.sh +0 -135
  141. package/graphics/chess_sprites/mmonge/celtic-bx.svg +0 -112
  142. package/graphics/chess_sprites/mmonge/celtic-wx.svg +0 -111
  143. package/graphics/chess_sprites/mmonge/celtic.svg +0 -1576
  144. package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +0 -101
  145. package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +0 -100
  146. package/graphics/chess_sprites/mmonge/eyes.svg +0 -2538
  147. package/graphics/chess_sprites/mmonge/fantasy-bx.svg +0 -112
  148. package/graphics/chess_sprites/mmonge/fantasy-wx.svg +0 -111
  149. package/graphics/chess_sprites/mmonge/fantasy.svg +0 -5497
  150. package/graphics/chess_sprites/mmonge/fantasy_alt.svg +0 -3742
  151. package/graphics/chess_sprites/mmonge/freak.svg +0 -3479
  152. package/graphics/chess_sprites/mmonge/prmi.svg +0 -6776
  153. package/graphics/chess_sprites/mmonge/skulls-bx.svg +0 -124
  154. package/graphics/chess_sprites/mmonge/skulls-wx.svg +0 -111
  155. package/graphics/chess_sprites/mmonge/skulls.svg +0 -12978
  156. package/graphics/chess_sprites/mmonge/spatial.svg +0 -1223
  157. package/graphics/logo-small.svg +0 -14
  158. package/graphics/logo.svg +0 -26
@@ -4,100 +4,59 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _reactDraggable = _interopRequireDefault(require("react-draggable"));
13
-
14
- var _reactMotion = require("react-motion");
15
-
16
10
  var _kokopu = require("kokopu");
17
-
18
11
  var _colorsets2 = _interopRequireDefault(require("./impl/colorsets"));
19
-
20
12
  var _piecesets2 = _interopRequireDefault(require("./impl/piecesets"));
21
-
22
13
  var _ArrowTip = _interopRequireDefault(require("./impl/ArrowTip"));
23
-
14
+ var _Motion = _interopRequireDefault(require("./impl/Motion"));
24
15
  var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
25
-
26
16
  var _ErrorBox = _interopRequireDefault(require("./ErrorBox"));
27
-
28
17
  var _i18n = _interopRequireDefault(require("./i18n"));
29
-
30
18
  var _markers = require("./markers");
31
-
32
19
  var _util = require("./impl/util");
33
-
34
20
  require("./css/chessboard.css");
35
-
36
21
  require("./css/arrow.css");
37
-
38
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
-
40
23
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
41
-
42
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
43
-
44
25
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
45
-
46
26
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
47
-
48
27
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
49
-
50
28
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
51
-
52
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
53
-
54
30
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
-
56
31
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
57
-
58
32
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
59
-
60
33
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
61
-
62
34
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
63
-
64
35
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
65
-
66
36
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
67
-
68
37
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
69
-
70
38
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
71
-
72
39
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
73
-
74
40
  var TURN_FLAG_SPACING_FACTOR = 0.1;
75
41
  var RANK_COORDINATE_WIDTH_FACTOR = 1;
76
42
  var FILE_COORDINATE_HEIGHT_FACTOR = 1.4;
77
43
  var HOVER_MARKER_THICKNESS_FACTOR = 0.1;
78
44
  var STROKE_THICKNESS_FACTOR = 0.15;
79
45
  var ARROW_TIP_OFFSET_FACTOR = 0.3;
80
- var ANIMATION_SPEED = {
81
- stiffness: 700,
82
- damping: 40
83
- };
46
+ var MOTION_DURATION = 150;
84
47
  var RANK_LABELS = '12345678';
85
48
  var FILE_LABELS = 'abcdefgh';
49
+
86
50
  /**
87
51
  * SVG image representing a chessboard diagram. Optionally, the user may interact with the board (move pieces, click on squares...).
88
52
  * Annotations such as square markers or arrows can also be added to the board.
89
53
  */
90
-
91
54
  var Chessboard = /*#__PURE__*/function (_React$Component) {
92
55
  _inherits(Chessboard, _React$Component);
93
-
94
56
  var _super = _createSuper(Chessboard);
95
-
96
57
  function Chessboard(props) {
97
58
  var _this;
98
-
99
59
  _classCallCheck(this, Chessboard);
100
-
101
60
  _this = _super.call(this, props);
102
61
  _this.state = {
103
62
  inhibitedSquare: '-',
@@ -107,32 +66,31 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
107
66
  windowWidth: window.innerWidth
108
67
  };
109
68
  _this.arrowTipIdSuffix = (0, _util.generateRandomId)();
110
-
111
- _this.windowResizeListener = function () {
112
- return _this.handleWindowResize();
113
- };
114
-
115
69
  return _this;
116
70
  }
117
-
118
71
  _createClass(Chessboard, [{
119
72
  key: "componentDidMount",
120
73
  value: function componentDidMount() {
74
+ var _this2 = this;
75
+ this.windowResizeListener = function () {
76
+ return _this2.handleWindowResize();
77
+ };
121
78
  window.addEventListener('resize', this.windowResizeListener);
122
79
  }
123
80
  }, {
124
81
  key: "componentWillUnmount",
125
82
  value: function componentWillUnmount() {
126
- window.removeEventListener('resize', this.windowResizeListener);
83
+ if (this.windowResizeListener) {
84
+ window.removeEventListener('resize', this.windowResizeListener);
85
+ this.windowResizeListener = null;
86
+ }
127
87
  }
128
88
  }, {
129
89
  key: "render",
130
90
  value: function render() {
131
- var _this2 = this;
132
-
91
+ var _this3 = this;
133
92
  // Compute the current position.
134
93
  var info = this.getPositionAndMoveInfo();
135
-
136
94
  if (info.positionError) {
137
95
  return /*#__PURE__*/_react["default"].createElement(_ErrorBox["default"], {
138
96
  title: _i18n["default"].INVALID_FEN_ERROR_TITLE,
@@ -144,38 +102,37 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
144
102
  message: info.message
145
103
  });
146
104
  }
147
-
148
105
  var position = info.position,
149
- move = info.move,
150
- positionBefore = info.positionBefore; // Compute the attributes.
106
+ move = info.move,
107
+ positionBefore = info.positionBefore;
151
108
 
109
+ // Compute the attributes.
152
110
  var squareSize = this.getSquareSize();
153
111
  var coordinateVisible = this.isCoordinateVisible();
154
112
  var fontSize = computeCoordinateFontSize(squareSize);
155
113
  var colorset = _colorsets2["default"][this.props.colorset];
156
114
  var pieceset = _piecesets2["default"][this.props.pieceset];
157
-
158
115
  if (isNaN(squareSize) || !colorset || !pieceset) {
159
116
  return undefined;
160
- } // Render the squares.
161
-
117
+ }
162
118
 
119
+ // Render the squares.
163
120
  var squares = [];
164
121
  (0, _kokopu.forEachSquare)(function (sq) {
165
- return squares.push(_this2.renderSquare(squareSize, colorset, sq));
166
- }); // Render coordinates.
122
+ return squares.push(_this3.renderSquare(squareSize, colorset, sq));
123
+ });
167
124
 
125
+ // Render coordinates.
168
126
  var rankCoordinates = [];
169
127
  var fileCoordinates = [];
170
-
171
128
  if (coordinateVisible) {
172
129
  for (var c = 0; c < 8; ++c) {
173
130
  rankCoordinates.push(this.renderRankCoordinate(squareSize, fontSize, c));
174
131
  fileCoordinates.push(this.renderFileCoordinate(squareSize, fontSize, c));
175
132
  }
176
- } // Render the whole canvas.
177
-
133
+ }
178
134
 
135
+ // Render the whole canvas.
179
136
  var xmin = coordinateVisible ? Math.round(-RANK_COORDINATE_WIDTH_FACTOR * fontSize) : 0;
180
137
  var ymin = 0;
181
138
  var xmax = 9 * squareSize + Math.round(TURN_FLAG_SPACING_FACTOR * squareSize);
@@ -191,62 +148,55 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
191
148
  }, {
192
149
  key: "renderBoardContent",
193
150
  value: function renderBoardContent(position, positionBefore, move, squareSize, colorset, pieceset) {
194
- var _this3 = this;
195
-
151
+ var _this4 = this;
196
152
  if (move && this.props.animated) {
197
- return /*#__PURE__*/_react["default"].createElement(_reactMotion.Motion, {
198
- key: move.toString(),
199
- defaultStyle: {
200
- alpha: 0
201
- },
202
- style: {
203
- alpha: (0, _reactMotion.spring)(1, ANIMATION_SPEED)
204
- }
205
- }, function (currentStyle) {
206
- return currentStyle.alpha >= 1 ? _this3.renderBoardContentStill(position, move, squareSize, colorset, pieceset) : _this3.renderBoardContentAnimated(positionBefore, move, currentStyle.alpha, squareSize, colorset, pieceset);
153
+ var key = positionBefore.variant() + '|' + positionBefore.fen() + '|' + move.toString();
154
+ return /*#__PURE__*/_react["default"].createElement(_Motion["default"], {
155
+ key: key,
156
+ duration: MOTION_DURATION
157
+ }, function (motionCursor) {
158
+ return motionCursor === 1 ? _this4.renderBoardContentStill(position, move, squareSize, colorset, pieceset) : _this4.renderBoardContentAnimated(positionBefore, move, motionCursor, squareSize, colorset, pieceset);
207
159
  });
208
160
  } else {
209
161
  return this.renderBoardContentStill(position, move, squareSize, colorset, pieceset);
210
162
  }
211
163
  }
164
+
212
165
  /**
213
166
  * Render the board content during the animation.
214
167
  */
215
-
216
168
  }, {
217
169
  key: "renderBoardContentAnimated",
218
- value: function renderBoardContentAnimated(positionBefore, move, alpha, squareSize, colorset, pieceset) {
219
- var _this4 = this;
220
-
170
+ value: function renderBoardContentAnimated(positionBefore, move, motionCursor, squareSize, colorset, pieceset) {
171
+ var _this5 = this;
221
172
  var pieces = [];
222
173
  (0, _kokopu.forEachSquare)(function (sq) {
223
- return pieces.push(_this4.renderPieceAnimated(positionBefore, move, alpha, squareSize, pieceset, sq));
174
+ return pieces.push(_this5.renderPieceAnimated(positionBefore, move, motionCursor, squareSize, pieceset, sq));
224
175
  });
225
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pieces, this.renderMoveArrow(move, alpha, squareSize, colorset), this.renderTurnFlag((0, _kokopu.oppositeColor)(positionBefore.turn()), squareSize, pieceset));
176
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pieces, this.renderMoveArrow(move, motionCursor, squareSize, colorset), this.renderTurnFlag((0, _kokopu.oppositeColor)(positionBefore.turn()), squareSize, pieceset));
226
177
  }
178
+
227
179
  /**
228
180
  * Render the board content when the animation has been completed (or if there is no animation).
229
181
  */
230
-
231
182
  }, {
232
183
  key: "renderBoardContentStill",
233
184
  value: function renderBoardContentStill(position, move, squareSize, colorset, pieceset) {
234
- var _this5 = this;
235
-
185
+ var _this6 = this;
236
186
  // Compute the annotations.
237
187
  var sqm = parseMarkers(this.props.squareMarkers, _markers.parseSquareMarkers, _util.isValidSquare, _util.isValidColor);
238
188
  var txtm = parseMarkers(this.props.textMarkers, _markers.parseTextMarkers, _util.isValidSquare, function (value) {
239
189
  return value && (0, _util.isValidSymbol)(value.symbol) && (0, _util.isValidColor)(value.color);
240
190
  });
241
- var arm = parseMarkers(this.props.arrowMarkers, _markers.parseArrowMarkers, _util.isValidVector, _util.isValidColor); // Render the square-related objects.
191
+ var arm = parseMarkers(this.props.arrowMarkers, _markers.parseArrowMarkers, _util.isValidVector, _util.isValidColor);
242
192
 
193
+ // Render the square-related objects.
243
194
  var pieces = [];
244
195
  var handles = [];
245
196
  (0, _kokopu.forEachSquare)(function (sq) {
246
- pieces.push(_this5.renderPiece(position, squareSize, pieceset, sq));
247
-
248
- if (_this5.props.interactionMode) {
249
- handles.push(_this5.renderSquareHandle(position, squareSize, sq));
197
+ pieces.push(_this6.renderPiece(position, squareSize, pieceset, sq));
198
+ if (_this6.props.interactionMode) {
199
+ handles.push(_this6.renderSquareHandle(position, squareSize, sq));
250
200
  }
251
201
  });
252
202
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.renderSquareMarkers(sqm, squareSize, colorset), this.renderHoveredSquare(squareSize, colorset), pieces, this.renderTextMarkers(txtm, squareSize, colorset), this.renderArrowMarkers(arm, squareSize, colorset), this.renderMoveArrow(move, 1, squareSize, colorset), handles, this.renderPromotionDrawer(position, squareSize, colorset, pieceset), this.renderDraggedPiece(position, squareSize, pieceset), this.renderDraggedArrow(squareSize, colorset), this.renderTurnFlag(position.turn(), squareSize, pieceset));
@@ -255,9 +205,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
255
205
  key: "renderSquare",
256
206
  value: function renderSquare(squareSize, colorset, sq) {
257
207
  var _this$getSquareCoordi = this.getSquareCoordinates(squareSize, sq),
258
- x = _this$getSquareCoordi.x,
259
- y = _this$getSquareCoordi.y;
260
-
208
+ x = _this$getSquareCoordi.x,
209
+ y = _this$getSquareCoordi.y;
261
210
  return /*#__PURE__*/_react["default"].createElement("rect", {
262
211
  key: sq,
263
212
  x: x,
@@ -273,11 +222,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
273
222
  if (this.state.hoveredSquare === '-') {
274
223
  return undefined;
275
224
  }
276
-
277
225
  var _this$getSquareCoordi2 = this.getSquareCoordinates(squareSize, this.state.hoveredSquare),
278
- x = _this$getSquareCoordi2.x,
279
- y = _this$getSquareCoordi2.y;
280
-
226
+ x = _this$getSquareCoordi2.x,
227
+ y = _this$getSquareCoordi2.y;
281
228
  var thickness = Math.max(2, Math.round(HOVER_MARKER_THICKNESS_FACTOR * squareSize));
282
229
  var size = squareSize - thickness;
283
230
  var color = this.isEditArrowModeEnabled() ? this.props.editedArrowColor : this.props.moveArrowColor;
@@ -295,15 +242,12 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
295
242
  key: "renderPiece",
296
243
  value: function renderPiece(position, squareSize, pieceset, sq) {
297
244
  var cp = position.square(sq);
298
-
299
245
  if (cp === '-' || this.state.inhibitedSquare === sq) {
300
246
  return undefined;
301
247
  }
302
-
303
248
  var _this$getSquareCoordi3 = this.getSquareCoordinates(squareSize, sq),
304
- x = _this$getSquareCoordi3.x,
305
- y = _this$getSquareCoordi3.y;
306
-
249
+ x = _this$getSquareCoordi3.x,
250
+ y = _this$getSquareCoordi3.y;
307
251
  return /*#__PURE__*/_react["default"].createElement("image", {
308
252
  key: 'piece-' + sq,
309
253
  x: x,
@@ -315,37 +259,30 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
315
259
  }
316
260
  }, {
317
261
  key: "renderPieceAnimated",
318
- value: function renderPieceAnimated(positionBefore, move, alpha, squareSize, pieceset, sq) {
262
+ value: function renderPieceAnimated(positionBefore, move, motionCursor, squareSize, pieceset, sq) {
319
263
  var cp = positionBefore.square(sq);
320
-
321
264
  if (cp === '-' || move.to() === sq || move.isEnPassant() && move.enPassantSquare() === sq) {
322
265
  return undefined;
323
266
  }
324
-
325
267
  var _this$getSquareCoordi4 = this.getSquareCoordinates(squareSize, sq),
326
- x = _this$getSquareCoordi4.x,
327
- y = _this$getSquareCoordi4.y;
328
-
268
+ x = _this$getSquareCoordi4.x,
269
+ y = _this$getSquareCoordi4.y;
329
270
  if (sq === move.from()) {
330
271
  var _this$getSquareCoordi5 = this.getSquareCoordinates(squareSize, move.to()),
331
- xTo = _this$getSquareCoordi5.x,
332
- yTo = _this$getSquareCoordi5.y;
333
-
334
- x = xTo * alpha + x * (1 - alpha);
335
- y = yTo * alpha + y * (1 - alpha);
336
-
337
- if (move.isPromotion() && alpha > 0.8) {
272
+ xTo = _this$getSquareCoordi5.x,
273
+ yTo = _this$getSquareCoordi5.y;
274
+ x = xTo * motionCursor + x * (1 - motionCursor);
275
+ y = yTo * motionCursor + y * (1 - motionCursor);
276
+ if (move.isPromotion() && motionCursor > 0.8) {
338
277
  cp = move.coloredPromotion();
339
278
  }
340
279
  } else if (move.isCastling() && sq === move.rookFrom()) {
341
280
  var _this$getSquareCoordi6 = this.getSquareCoordinates(squareSize, move.rookTo()),
342
- _xTo = _this$getSquareCoordi6.x,
343
- _yTo = _this$getSquareCoordi6.y;
344
-
345
- x = _xTo * alpha + x * (1 - alpha);
346
- y = _yTo * alpha + y * (1 - alpha);
281
+ _xTo = _this$getSquareCoordi6.x,
282
+ _yTo = _this$getSquareCoordi6.y;
283
+ x = _xTo * motionCursor + x * (1 - motionCursor);
284
+ y = _yTo * motionCursor + y * (1 - motionCursor);
347
285
  }
348
-
349
286
  return /*#__PURE__*/_react["default"].createElement("image", {
350
287
  key: 'piece-' + sq,
351
288
  x: x,
@@ -361,11 +298,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
361
298
  if (!(this.isMovePieceModeEnabled() || this.isPlayMoveModeEnabled()) || this.state.draggedSquare === '-') {
362
299
  return undefined;
363
300
  }
364
-
365
301
  var _this$getSquareCoordi7 = this.getSquareCoordinates(squareSize, this.state.draggedSquare),
366
- x = _this$getSquareCoordi7.x,
367
- y = _this$getSquareCoordi7.y;
368
-
302
+ x = _this$getSquareCoordi7.x,
303
+ y = _this$getSquareCoordi7.y;
369
304
  x = Math.min(Math.max(x + this.state.dragPosition.x, 0), 7 * squareSize);
370
305
  y = Math.min(Math.max(y + this.state.dragPosition.y, 0), 7 * squareSize);
371
306
  var cp = position.square(this.state.draggedSquare);
@@ -384,14 +319,11 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
384
319
  if (!this.isEditArrowModeEnabled() || this.state.draggedSquare === '-') {
385
320
  return undefined;
386
321
  }
387
-
388
322
  var strokeWidth = squareSize * STROKE_THICKNESS_FACTOR;
389
323
  var arrowTipId = this.getArrowTipId(this.props.editedArrowColor);
390
-
391
324
  var _this$getSquareCoordi8 = this.getSquareCoordinates(squareSize, this.state.draggedSquare),
392
- x = _this$getSquareCoordi8.x,
393
- y = _this$getSquareCoordi8.y;
394
-
325
+ x = _this$getSquareCoordi8.x,
326
+ y = _this$getSquareCoordi8.y;
395
327
  var xFrom = x + squareSize / 2;
396
328
  var yFrom = y + squareSize / 2;
397
329
  var xTo = Math.min(Math.max(x + this.state.dragPosition.x + this.state.cursorOffset.x, squareSize / 2), 15 * squareSize / 2);
@@ -410,18 +342,14 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
410
342
  }, {
411
343
  key: "renderPromotionDrawer",
412
344
  value: function renderPromotionDrawer(position, squareSize, colorset, pieceset) {
413
- var _this6 = this;
414
-
345
+ var _this7 = this;
415
346
  if (!this.state.promotionDrawer) {
416
347
  return undefined;
417
348
  }
418
-
419
349
  var _this$getSquareCoordi9 = this.getSquareCoordinates(squareSize, this.state.promotionDrawer.origin),
420
- x = _this$getSquareCoordi9.x,
421
- y = _this$getSquareCoordi9.y;
422
-
350
+ x = _this$getSquareCoordi9.x,
351
+ y = _this$getSquareCoordi9.y;
423
352
  var inverted = position.turn() === (this.props.flipped ? 'w' : 'b'); // false==top-to-bottom true==bottom-to-top
424
-
425
353
  var y0 = inverted ? y - squareSize * (this.state.promotionDrawer.buttons.length - 1) : y;
426
354
  var buttons = this.state.promotionDrawer.buttons.map(function (p, i) {
427
355
  var cp = position.turn() + p;
@@ -434,7 +362,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
434
362
  height: squareSize,
435
363
  href: pieceset[cp],
436
364
  onClick: function onClick() {
437
- return _this6.handleDrawerButtonClicked(p);
365
+ return _this7.handleDrawerButtonClicked(p);
438
366
  }
439
367
  });
440
368
  });
@@ -445,7 +373,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
445
373
  width: squareSize * 8,
446
374
  height: squareSize * 8,
447
375
  onClick: function onClick() {
448
- return _this6.handleDrawerCancelButtonClicked();
376
+ return _this7.handleDrawerCancelButtonClicked();
449
377
  }
450
378
  }), /*#__PURE__*/_react["default"].createElement("rect", {
451
379
  x: x,
@@ -465,16 +393,13 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
465
393
  }, {
466
394
  key: "renderSquareHandle",
467
395
  value: function renderSquareHandle(position, squareSize, sq) {
468
- var _this7 = this;
469
-
396
+ var _this8 = this;
470
397
  var _this$getSquareCoordi10 = this.getSquareCoordinates(squareSize, sq),
471
- x = _this$getSquareCoordi10.x,
472
- y = _this$getSquareCoordi10.y;
473
-
398
+ x = _this$getSquareCoordi10.x,
399
+ y = _this$getSquareCoordi10.y;
474
400
  var dragEnabledForMovePieces = this.isMovePieceModeEnabled() && position.square(sq) !== '-';
475
401
  var dragEnabledForEditArrows = this.isEditArrowModeEnabled();
476
402
  var dragEnabledForPlayMoves = this.isPlayMoveModeEnabled() && position.isLegal() && position.square(sq).startsWith(position.turn()) && !this.state.promotionDrawer;
477
-
478
403
  if (dragEnabledForMovePieces || dragEnabledForEditArrows || dragEnabledForPlayMoves) {
479
404
  var dragPosition = this.state.draggedSquare === sq ? this.state.dragPosition : {
480
405
  x: 0,
@@ -485,13 +410,13 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
485
410
  key: 'handle-' + sq,
486
411
  position: dragPosition,
487
412
  onStart: function onStart(evt) {
488
- return _this7.handleDragStart(sq, evt);
413
+ return _this8.handleDragStart(sq, evt);
489
414
  },
490
415
  onDrag: function onDrag(_, dragData) {
491
- return _this7.handleDrag(sq, dragData);
416
+ return _this8.handleDrag(sq, dragData);
492
417
  },
493
418
  onStop: function onStop(_, dragData) {
494
- return _this7.handleDragStop(sq, dragData);
419
+ return _this8.handleDragStop(sq, dragData);
495
420
  }
496
421
  }, /*#__PURE__*/_react["default"].createElement("rect", {
497
422
  className: classNames.join(' '),
@@ -509,7 +434,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
509
434
  width: squareSize,
510
435
  height: squareSize,
511
436
  onClick: function onClick() {
512
- return _this7.handleSquareClicked(sq);
437
+ return _this8.handleSquareClicked(sq);
513
438
  }
514
439
  });
515
440
  } else {
@@ -519,18 +444,15 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
519
444
  }, {
520
445
  key: "renderSquareMarkers",
521
446
  value: function renderSquareMarkers(sqm, squareSize, colorset) {
522
- var _this8 = this;
523
-
447
+ var _this9 = this;
524
448
  var result = [];
525
449
  Object.entries(sqm).forEach(function (_ref) {
526
450
  var _ref2 = _slicedToArray(_ref, 2),
527
- sq = _ref2[0],
528
- color = _ref2[1];
529
-
530
- var _this8$getSquareCoord = _this8.getSquareCoordinates(squareSize, sq),
531
- x = _this8$getSquareCoord.x,
532
- y = _this8$getSquareCoord.y;
533
-
451
+ sq = _ref2[0],
452
+ color = _ref2[1];
453
+ var _this9$getSquareCoord = _this9.getSquareCoordinates(squareSize, sq),
454
+ x = _this9$getSquareCoord.x,
455
+ y = _this9$getSquareCoord.y;
534
456
  result.push( /*#__PURE__*/_react["default"].createElement("rect", {
535
457
  key: 'sqm-' + sq,
536
458
  className: "kokopu-annotation",
@@ -546,18 +468,15 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
546
468
  }, {
547
469
  key: "renderTextMarkers",
548
470
  value: function renderTextMarkers(txtm, squareSize, colorset) {
549
- var _this9 = this;
550
-
471
+ var _this10 = this;
551
472
  var result = [];
552
473
  Object.entries(txtm).forEach(function (_ref3) {
553
474
  var _ref4 = _slicedToArray(_ref3, 2),
554
- sq = _ref4[0],
555
- value = _ref4[1];
556
-
557
- var _this9$getSquareCoord = _this9.getSquareCoordinates(squareSize, sq),
558
- x = _this9$getSquareCoord.x,
559
- y = _this9$getSquareCoord.y;
560
-
475
+ sq = _ref4[0],
476
+ value = _ref4[1];
477
+ var _this10$getSquareCoor = _this10.getSquareCoordinates(squareSize, sq),
478
+ x = _this10$getSquareCoor.x,
479
+ y = _this10$getSquareCoor.y;
561
480
  x += squareSize / 2;
562
481
  y += squareSize / 2;
563
482
  result.push( /*#__PURE__*/_react["default"].createElement("g", {
@@ -576,39 +495,31 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
576
495
  }, {
577
496
  key: "renderArrowMarkers",
578
497
  value: function renderArrowMarkers(arm, squareSize, colorset) {
579
- var _this10 = this;
580
-
498
+ var _this11 = this;
581
499
  var result = [];
582
500
  var strokeWidth = squareSize * STROKE_THICKNESS_FACTOR;
583
501
  Object.entries(arm).forEach(function (_ref5) {
584
502
  var _ref6 = _slicedToArray(_ref5, 2),
585
- vect = _ref6[0],
586
- color = _ref6[1];
587
-
503
+ vect = _ref6[0],
504
+ color = _ref6[1];
588
505
  var from = vect.substring(0, 2);
589
506
  var to = vect.substring(2, 4);
590
-
591
507
  if (from === to) {
592
508
  return;
593
509
  }
594
-
595
- var _this10$getSquareCoor = _this10.getSquareCoordinates(squareSize, from),
596
- xFrom = _this10$getSquareCoor.x,
597
- yFrom = _this10$getSquareCoor.y;
598
-
599
- var _this10$getSquareCoor2 = _this10.getSquareCoordinates(squareSize, to),
600
- xTo = _this10$getSquareCoor2.x,
601
- yTo = _this10$getSquareCoor2.y;
602
-
510
+ var _this11$getSquareCoor = _this11.getSquareCoordinates(squareSize, from),
511
+ xFrom = _this11$getSquareCoor.x,
512
+ yFrom = _this11$getSquareCoor.y;
513
+ var _this11$getSquareCoor2 = _this11.getSquareCoordinates(squareSize, to),
514
+ xTo = _this11$getSquareCoor2.x,
515
+ yTo = _this11$getSquareCoor2.y;
603
516
  xFrom += squareSize / 2;
604
517
  yFrom += squareSize / 2;
605
518
  xTo += squareSize / 2;
606
519
  yTo += squareSize / 2;
607
520
  xTo += Math.sign(xFrom - xTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
608
521
  yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
609
-
610
- var arrowTipId = _this10.getArrowTipId(color);
611
-
522
+ var arrowTipId = _this11.getArrowTipId(color);
612
523
  result.push( /*#__PURE__*/_react["default"].createElement("line", {
613
524
  key: 'arm-' + vect,
614
525
  className: "kokopu-annotation kokopu-arrow",
@@ -625,28 +536,24 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
625
536
  }
626
537
  }, {
627
538
  key: "renderMoveArrow",
628
- value: function renderMoveArrow(move, alpha, squareSize, colorset) {
629
- if (!move || alpha < 0.1 || !this.props.moveArrowVisible || move.from() === move.to()) {
539
+ value: function renderMoveArrow(move, motionCursor, squareSize, colorset) {
540
+ if (!move || motionCursor < 0.1 || !this.props.moveArrowVisible || move.from() === move.to()) {
630
541
  return undefined;
631
542
  }
632
-
633
543
  var _this$getSquareCoordi11 = this.getSquareCoordinates(squareSize, move.from()),
634
- xFrom = _this$getSquareCoordi11.x,
635
- yFrom = _this$getSquareCoordi11.y;
636
-
544
+ xFrom = _this$getSquareCoordi11.x,
545
+ yFrom = _this$getSquareCoordi11.y;
637
546
  xFrom += squareSize / 2;
638
547
  yFrom += squareSize / 2;
639
-
640
548
  var _this$getSquareCoordi12 = this.getSquareCoordinates(squareSize, move.to()),
641
- xTo = _this$getSquareCoordi12.x,
642
- yTo = _this$getSquareCoordi12.y;
643
-
549
+ xTo = _this$getSquareCoordi12.x,
550
+ yTo = _this$getSquareCoordi12.y;
644
551
  xTo += squareSize / 2;
645
552
  yTo += squareSize / 2;
646
553
  xTo += Math.sign(xFrom - xTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
647
554
  yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
648
- var x = xTo * alpha + xFrom * (1 - alpha);
649
- var y = yTo * alpha + yFrom * (1 - alpha);
555
+ var x = xTo * motionCursor + xFrom * (1 - motionCursor);
556
+ var y = yTo * motionCursor + yFrom * (1 - motionCursor);
650
557
  var color = this.props.moveArrowColor;
651
558
  return /*#__PURE__*/_react["default"].createElement("line", {
652
559
  className: "kokopu-annotation kokopu-arrow",
@@ -738,11 +645,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
738
645
  key: "handleDrag",
739
646
  value: function handleDrag(sq, dragData) {
740
647
  var squareSize = this.getSquareSize();
741
-
742
648
  var _this$getSquareCoordi13 = this.getSquareCoordinates(squareSize, sq),
743
- x = _this$getSquareCoordi13.x,
744
- y = _this$getSquareCoordi13.y;
745
-
649
+ x = _this$getSquareCoordi13.x,
650
+ y = _this$getSquareCoordi13.y;
746
651
  var targetSq = this.getSquareAt(squareSize, x + dragData.x + this.state.cursorOffset.x, y + dragData.y + this.state.cursorOffset.y);
747
652
  this.setState({
748
653
  hoveredSquare: targetSq,
@@ -756,46 +661,38 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
756
661
  key: "handleDragStop",
757
662
  value: function handleDragStop(sq, dragData) {
758
663
  var squareSize = this.getSquareSize();
759
-
760
664
  var _this$getSquareCoordi14 = this.getSquareCoordinates(squareSize, sq),
761
- x = _this$getSquareCoordi14.x,
762
- y = _this$getSquareCoordi14.y;
763
-
665
+ x = _this$getSquareCoordi14.x,
666
+ y = _this$getSquareCoordi14.y;
764
667
  var targetSq = this.getSquareAt(squareSize, x + dragData.x + this.state.cursorOffset.x, y + dragData.y + this.state.cursorOffset.y);
765
668
  this.setState({
766
669
  inhibitedSquare: '-',
767
670
  draggedSquare: '-',
768
671
  hoveredSquare: '-'
769
672
  });
770
-
771
673
  if (sq === targetSq || targetSq === '-') {
772
674
  return;
773
675
  }
774
-
775
676
  if (this.isMovePieceModeEnabled() && this.props.onPieceMoved) {
776
677
  this.props.onPieceMoved(sq, targetSq);
777
678
  } else if (this.isEditArrowModeEnabled() && this.props.onArrowEdited) {
778
679
  this.props.onArrowEdited(sq, targetSq);
779
680
  } else if (this.isPlayMoveModeEnabled()) {
780
681
  var _this$getPositionAndM = this.getPositionAndMoveInfo(),
781
- position = _this$getPositionAndM.position;
782
-
682
+ position = _this$getPositionAndM.position;
783
683
  var info = position.isMoveLegal(sq, targetSq);
784
-
785
684
  if (!info) {
786
685
  return;
787
686
  }
788
-
789
687
  switch (info.status) {
790
688
  // Regular move.
791
689
  case 'regular':
792
690
  if (this.props.onMovePlayed) {
793
691
  this.props.onMovePlayed(position.notation(info()));
794
692
  }
795
-
796
693
  break;
797
- // Promotion move.
798
694
 
695
+ // Promotion move.
799
696
  case 'promotion':
800
697
  this.setState({
801
698
  inhibitedSquare: sq,
@@ -808,9 +705,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
808
705
  }
809
706
  });
810
707
  break;
708
+
811
709
  // Other cases are not supposed to happen.
812
710
  // istanbul ignore next
813
-
814
711
  default:
815
712
  break;
816
713
  }
@@ -832,7 +729,6 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
832
729
  inhibitedSquare: '-',
833
730
  promotionDrawer: false
834
731
  });
835
-
836
732
  if (this.props.onMovePlayed) {
837
733
  this.props.onMovePlayed(builder(piece));
838
734
  }
@@ -844,37 +740,37 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
844
740
  this.props.onSquareClicked(sq);
845
741
  }
846
742
  }
743
+
847
744
  /**
848
745
  * Whether the "move piece" mode is enabled or not.
849
746
  */
850
-
851
747
  }, {
852
748
  key: "isMovePieceModeEnabled",
853
749
  value: function isMovePieceModeEnabled() {
854
750
  return this.props.interactionMode === 'movePieces';
855
751
  }
752
+
856
753
  /**
857
754
  * Whether the "play move" mode is enabled or not.
858
755
  */
859
-
860
756
  }, {
861
757
  key: "isPlayMoveModeEnabled",
862
758
  value: function isPlayMoveModeEnabled() {
863
759
  return this.props.interactionMode === 'playMoves';
864
760
  }
761
+
865
762
  /**
866
763
  * Whether the "edit arrow" mode is enabled or not.
867
764
  */
868
-
869
765
  }, {
870
766
  key: "isEditArrowModeEnabled",
871
767
  value: function isEditArrowModeEnabled() {
872
768
  return this.props.interactionMode === 'editArrows' && (0, _util.isValidColor)(this.props.editedArrowColor);
873
769
  }
770
+
874
771
  /**
875
772
  * Return the (sanitized) square size.
876
773
  */
877
-
878
774
  }, {
879
775
  key: "getSquareSize",
880
776
  value: function getSquareSize() {
@@ -882,27 +778,26 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
882
778
  var limit = computeSmallScreenLimits('squareSize', this.props.smallScreenLimits, this.state.windowWidth);
883
779
  return isNaN(limit) ? squareSize : (0, _util.sanitizeInteger)(limit, _util.MIN_SQUARE_SIZE, squareSize);
884
780
  }
781
+
885
782
  /**
886
783
  * Whether the file/rank coordinates are visible or not.
887
784
  */
888
-
889
785
  }, {
890
786
  key: "isCoordinateVisible",
891
787
  value: function isCoordinateVisible() {
892
788
  var limit = computeSmallScreenLimits('coordinateVisible', this.props.smallScreenLimits, this.state.windowWidth);
893
789
  return this.props.coordinateVisible && (limit === undefined || limit);
894
790
  }
791
+
895
792
  /**
896
793
  * Return the (x,y) coordinates of the given square in the SVG canvas.
897
794
  */
898
-
899
795
  }, {
900
796
  key: "getSquareCoordinates",
901
797
  value: function getSquareCoordinates(squareSize, sq) {
902
798
  var _squareToCoordinates = (0, _kokopu.squareToCoordinates)(sq),
903
- file = _squareToCoordinates.file,
904
- rank = _squareToCoordinates.rank;
905
-
799
+ file = _squareToCoordinates.file,
800
+ rank = _squareToCoordinates.rank;
906
801
  var x = this.props.flipped ? (7 - file) * squareSize : file * squareSize;
907
802
  var y = this.props.flipped ? rank * squareSize : (7 - rank) * squareSize;
908
803
  return {
@@ -910,36 +805,34 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
910
805
  y: y
911
806
  };
912
807
  }
808
+
913
809
  /**
914
810
  * Return information regarding the currently displayed position and move, or parsing error message if something went wrong.
915
811
  */
916
-
917
812
  }, {
918
813
  key: "getPositionAndMoveInfo",
919
814
  value: function getPositionAndMoveInfo() {
920
815
  // Parse the position.
921
816
  var positionInfo = parsePosition(this.props.position);
922
-
923
817
  if (positionInfo.error) {
924
818
  return {
925
819
  positionError: true,
926
820
  moveError: true,
927
821
  message: positionInfo.message
928
822
  };
929
- } // Nothing else to do if no move is defined.
930
-
823
+ }
931
824
 
825
+ // Nothing else to do if no move is defined.
932
826
  if (!this.props.move) {
933
827
  return {
934
828
  positionError: false,
935
829
  moveError: false,
936
830
  position: positionInfo.position
937
831
  };
938
- } // Parse the move.
939
-
832
+ }
940
833
 
834
+ // Parse the move.
941
835
  var moveInfo = parseMove(positionInfo.position, this.props.move);
942
-
943
836
  if (moveInfo.error) {
944
837
  return {
945
838
  positionError: false,
@@ -947,9 +840,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
947
840
  message: moveInfo.message,
948
841
  positionBefore: positionInfo.position
949
842
  };
950
- } // Compute the position after the move and return the result.
951
-
843
+ }
952
844
 
845
+ // Compute the position after the move and return the result.
953
846
  var positionAfter = new _kokopu.Position(positionInfo.position);
954
847
  positionAfter.play(moveInfo.move);
955
848
  return {
@@ -960,10 +853,10 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
960
853
  position: positionAfter
961
854
  };
962
855
  }
856
+
963
857
  /**
964
858
  * Return the square at the given location.
965
859
  */
966
-
967
860
  }, {
968
861
  key: "getSquareAt",
969
862
  value: function getSquareAt(squareSize, x, y) {
@@ -971,15 +864,16 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
971
864
  var rank = this.props.flipped ? Math.floor(y / squareSize) : 7 - Math.floor(y / squareSize);
972
865
  return file >= 0 && file < 8 && rank >= 0 && rank < 8 ? (0, _kokopu.coordinatesToSquare)(file, rank) : '-';
973
866
  }
867
+
974
868
  /**
975
869
  * Return the DOM ID of an arrow tip with the given color.
976
870
  */
977
-
978
871
  }, {
979
872
  key: "getArrowTipId",
980
873
  value: function getArrowTipId(color) {
981
874
  return 'kokopu-arrowTip-' + color + '-' + this.arrowTipIdSuffix;
982
875
  }
876
+
983
877
  /**
984
878
  * Return the size of the chessboard, assuming it is built with the given attributes.
985
879
  *
@@ -989,7 +883,6 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
989
883
  * @returns {{width:number, height:number}}
990
884
  * @public
991
885
  */
992
-
993
886
  }], [{
994
887
  key: "size",
995
888
  value: function size(squareSize, coordinateVisible, smallScreenLimits) {
@@ -997,29 +890,26 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
997
890
  if (typeof window !== 'undefined') {
998
891
  var squareSizeLimit = computeSmallScreenLimits('squareSize', smallScreenLimits, window.innerWidth);
999
892
  var coordinateVisibleLimit = computeSmallScreenLimits('coordinateVisible', smallScreenLimits, window.innerWidth);
1000
-
1001
893
  if (!isNaN(squareSizeLimit)) {
1002
894
  squareSize = (0, _util.sanitizeInteger)(squareSizeLimit, _util.MIN_SQUARE_SIZE, squareSize);
1003
895
  }
1004
-
1005
896
  coordinateVisible = coordinateVisible && (coordinateVisibleLimit === undefined || coordinateVisibleLimit);
1006
- } // Compute the dimensions.
1007
-
897
+ }
1008
898
 
899
+ // Compute the dimensions.
1009
900
  var width = 9 * squareSize + Math.round(TURN_FLAG_SPACING_FACTOR * squareSize);
1010
901
  var height = 8 * squareSize;
1011
-
1012
902
  if (coordinateVisible) {
1013
903
  var fontSize = computeCoordinateFontSize(squareSize);
1014
904
  width += Math.round(RANK_COORDINATE_WIDTH_FACTOR * fontSize);
1015
905
  height += Math.round(FILE_COORDINATE_HEIGHT_FACTOR * fontSize);
1016
906
  }
1017
-
1018
907
  return {
1019
908
  width: width,
1020
909
  height: height
1021
910
  };
1022
911
  }
912
+
1023
913
  /**
1024
914
  * Return the maximum square size that would allow the chessboard to fit in a rectangle of size `width x height`.
1025
915
  *
@@ -1030,95 +920,88 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
1030
920
  * @returns {number}
1031
921
  * @public
1032
922
  */
1033
-
1034
923
  }, {
1035
924
  key: "adaptSquareSize",
1036
925
  value: function adaptSquareSize(width, height, coordinateVisible, smallScreenLimits) {
1037
- var maxSquareSize = _util.MAX_SQUARE_SIZE; // Enforce small-screen limits, if any.
926
+ var maxSquareSize = _util.MAX_SQUARE_SIZE;
1038
927
 
928
+ // Enforce small-screen limits, if any.
1039
929
  if (typeof window !== 'undefined') {
1040
930
  var squareSizeLimit = computeSmallScreenLimits('squareSize', smallScreenLimits, window.innerWidth);
1041
931
  var coordinateVisibleLimit = computeSmallScreenLimits('coordinateVisible', smallScreenLimits, window.innerWidth);
1042
-
1043
932
  if (!isNaN(squareSizeLimit)) {
1044
933
  maxSquareSize = (0, _util.sanitizeInteger)(squareSizeLimit, _util.MIN_SQUARE_SIZE, maxSquareSize);
1045
934
  }
1046
-
1047
935
  coordinateVisible = coordinateVisible && (coordinateVisibleLimit === undefined || coordinateVisibleLimit);
1048
936
  }
1049
-
1050
937
  function isAdapted(squareSize) {
1051
938
  var actualWidth = 9 * squareSize + Math.round(TURN_FLAG_SPACING_FACTOR * squareSize);
1052
939
  var actualHeight = 8 * squareSize;
1053
-
1054
940
  if (coordinateVisible) {
1055
941
  var fontSize = computeCoordinateFontSize(squareSize);
1056
942
  actualWidth += Math.round(RANK_COORDINATE_WIDTH_FACTOR * fontSize);
1057
943
  actualHeight += Math.round(FILE_COORDINATE_HEIGHT_FACTOR * fontSize);
1058
944
  }
1059
-
1060
945
  return actualWidth <= width && actualHeight <= height;
1061
- } // Check min/max bounds.
1062
-
946
+ }
1063
947
 
948
+ // Check min/max bounds.
1064
949
  if (isAdapted(maxSquareSize)) {
1065
950
  return maxSquareSize;
1066
951
  } else if (!isAdapted(_util.MIN_SQUARE_SIZE)) {
1067
952
  return _util.MIN_SQUARE_SIZE;
1068
- } // Dichotomic search, between a (inclusive) and b (exclusive).
1069
-
953
+ }
1070
954
 
955
+ // Dichotomic search, between a (inclusive) and b (exclusive).
1071
956
  var a = _util.MIN_SQUARE_SIZE;
1072
957
  var b = maxSquareSize;
1073
-
1074
958
  while (a + 1 < b) {
1075
959
  var mid = Math.floor((a + b) / 2);
1076
-
1077
960
  if (isAdapted(mid)) {
1078
961
  a = mid;
1079
962
  } else {
1080
963
  b = mid;
1081
964
  }
1082
965
  }
1083
-
1084
966
  return a;
1085
967
  }
968
+
1086
969
  /**
1087
970
  * Minimum square size (inclusive).
1088
971
  *
1089
972
  * @returns {number}
1090
973
  * @public
1091
974
  */
1092
-
1093
975
  }, {
1094
976
  key: "minSquareSize",
1095
977
  value: function minSquareSize() {
1096
978
  return _util.MIN_SQUARE_SIZE;
1097
979
  }
980
+
1098
981
  /**
1099
982
  * Maximum square size (inclusive).
1100
983
  *
1101
984
  * @returns {number}
1102
985
  * @public
1103
986
  */
1104
-
1105
987
  }, {
1106
988
  key: "maxSquareSize",
1107
989
  value: function maxSquareSize() {
1108
990
  return _util.MAX_SQUARE_SIZE;
1109
991
  }
992
+
1110
993
  /**
1111
994
  * Available colorsets for theming.
1112
995
  *
1113
996
  * @returns {Object.<string, { w: string, b: string, cb: string, cg: string, cr: string, cy: string }>}
1114
997
  * @public
1115
998
  */
1116
-
1117
999
  }, {
1118
1000
  key: "colorsets",
1119
1001
  value: function colorsets() {
1120
1002
  return _colorsets2["default"];
1121
1003
  }
1004
+
1122
1005
  /**
1123
1006
  * Available piecesets for theming.
1124
1007
  *
@@ -1126,17 +1009,14 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
1126
1009
  * wb: string, wk: string, wn: string, wp: string, wq: string, wr: string, wx: string }>}
1127
1010
  * @public
1128
1011
  */
1129
-
1130
1012
  }, {
1131
1013
  key: "piecesets",
1132
1014
  value: function piecesets() {
1133
1015
  return _piecesets2["default"];
1134
1016
  }
1135
1017
  }]);
1136
-
1137
1018
  return Chessboard;
1138
1019
  }(_react["default"].Component);
1139
-
1140
1020
  exports["default"] = Chessboard;
1141
1021
  Chessboard.propTypes = {
1142
1022
  /**
@@ -1149,19 +1029,16 @@ Chessboard.propTypes = {
1149
1029
  * `'chess960:nrkbqrbn/pppppppp/8/8/8/8/PPPPPPPP/NRKBQRBN w KQkq - 0 1'`.
1150
1030
  */
1151
1031
  position: _propTypes["default"].oneOfType([_propTypes["default"].instanceOf(_kokopu.Position), _propTypes["default"].string]),
1152
-
1153
1032
  /**
1154
1033
  * Displayed move (optional), defined either as a [kokopu.MoveDescriptor](https://kokopu.yo35.org/docs/current/classes/MoveDescriptor.html) object
1155
1034
  * or as a [SAN string](https://en.wikipedia.org/wiki/Algebraic_notation_(chess)) (e.g. `'Nf3'`). In both cases, it must represent
1156
1035
  * a legal move in position defined in attribute `position`.
1157
1036
  */
1158
1037
  move: _propTypes["default"].oneOfType([_propTypes["default"].instanceOf(_kokopu.MoveDescriptor), _propTypes["default"].string]),
1159
-
1160
1038
  /**
1161
1039
  * Square markers, defined as a "square -> color" struct (e.g. `{ e4: 'g', d5: 'r' }`) or as a comma-separated CSL string (e.g. `'Rd5,Ge4'`).
1162
1040
  */
1163
1041
  squareMarkers: _propTypes["default"].oneOfType([_propTypes["default"].objectOf(_propTypes["default"].oneOf(['b', 'g', 'r', 'y'])), _propTypes["default"].string]),
1164
-
1165
1042
  /**
1166
1043
  * Text markers, defined as a "square -> (symbol, color)" struct (e.g. `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }}`)
1167
1044
  * or as a comma-separated CTL string (e.g. `'Rzd5,GAe4'`).
@@ -1170,53 +1047,43 @@ Chessboard.propTypes = {
1170
1047
  symbol: _propTypes["default"].string.isRequired,
1171
1048
  color: _propTypes["default"].oneOf(['b', 'g', 'r', 'y']).isRequired
1172
1049
  })), _propTypes["default"].string]),
1173
-
1174
1050
  /**
1175
1051
  * Arrow markers, defined as a "squareFromSquareTo -> color" struct (e.g. `{ e2e4: 'g', g8f6: 'r', g8h6: 'y' }`)
1176
1052
  * or as a comma-separated CAL string (e.g. `'Ge2e4,Rg8f6,Yg8h6'`).
1177
1053
  */
1178
1054
  arrowMarkers: _propTypes["default"].oneOfType([_propTypes["default"].objectOf(_propTypes["default"].oneOf(['b', 'g', 'r', 'y'])), _propTypes["default"].string]),
1179
-
1180
1055
  /**
1181
1056
  * Whether the board is flipped (i.e. seen from Black's point of view) or not.
1182
1057
  */
1183
1058
  flipped: _propTypes["default"].bool,
1184
-
1185
1059
  /**
1186
1060
  * Size of the squares (in pixels). Must be an integer between `Chessboard.minSquareSize()` and `Chessboard.maxSquareSize()`.
1187
1061
  */
1188
1062
  squareSize: _propTypes["default"].number,
1189
-
1190
1063
  /**
1191
1064
  * Whether the row and column coordinates are visible or not.
1192
1065
  */
1193
1066
  coordinateVisible: _propTypes["default"].bool,
1194
-
1195
1067
  /**
1196
1068
  * Whether moves are highlighted with an arrow or not.
1197
1069
  */
1198
1070
  moveArrowVisible: _propTypes["default"].bool,
1199
-
1200
1071
  /**
1201
1072
  * Color of the move arrow.
1202
1073
  */
1203
1074
  moveArrowColor: _propTypes["default"].oneOf(['b', 'g', 'r', 'y']),
1204
-
1205
1075
  /**
1206
1076
  * Whether moves are animated or not.
1207
1077
  */
1208
1078
  animated: _propTypes["default"].bool,
1209
-
1210
1079
  /**
1211
1080
  * Color theme ID.
1212
1081
  */
1213
1082
  colorset: _propTypes["default"].oneOf(Object.keys(_colorsets2["default"])),
1214
-
1215
1083
  /**
1216
1084
  * Piece theme ID.
1217
1085
  */
1218
1086
  pieceset: _propTypes["default"].oneOf(Object.keys(_piecesets2["default"])),
1219
-
1220
1087
  /**
1221
1088
  * Limits applicable on small-screen devices. For instance, if set to
1222
1089
  * ```
@@ -1235,7 +1102,6 @@ Chessboard.propTypes = {
1235
1102
  squareSize: _propTypes["default"].number,
1236
1103
  coordinateVisible: _propTypes["default"].bool
1237
1104
  })),
1238
-
1239
1105
  /**
1240
1106
  * Type of action allowed with the mouse on the chessboard. If undefined, then the user cannot interact with the component.
1241
1107
  *
@@ -1245,12 +1111,10 @@ Chessboard.propTypes = {
1245
1111
  * - `'playMoves'` allows the user to play legal chess moves (thus no interaction is possible if the displayed position is not legal).
1246
1112
  */
1247
1113
  interactionMode: _propTypes["default"].oneOf(['movePieces', 'clickSquares', 'editArrows', 'playMoves']),
1248
-
1249
1114
  /**
1250
1115
  * Color of the edited arrow (only used if `interactionMode` is set to `'editArrows'`).
1251
1116
  */
1252
1117
  editedArrowColor: _propTypes["default"].oneOf(['b', 'g', 'r', 'y']),
1253
-
1254
1118
  /**
1255
1119
  * Callback invoked when a piece is moved through drag&drop (only if `interactionMode` is set to `'movePieces'`).
1256
1120
  *
@@ -1258,14 +1122,12 @@ Chessboard.propTypes = {
1258
1122
  * @param {string} to Target square (e.g. `'f3'`).
1259
1123
  */
1260
1124
  onPieceMoved: _propTypes["default"].func,
1261
-
1262
1125
  /**
1263
1126
  * Callback invoked when the user clicks on a square (only if `interactionMode` is set to `'clickSquares'`).
1264
1127
  *
1265
1128
  * @param {string} square Clicked square (e.g. `e4`).
1266
1129
  */
1267
1130
  onSquareClicked: _propTypes["default"].func,
1268
-
1269
1131
  /**
1270
1132
  * Callback invoked when an arrow is dragged (only if `interactionMode` is set to `'editArrows'`).
1271
1133
  *
@@ -1273,7 +1135,6 @@ Chessboard.propTypes = {
1273
1135
  * @param {string} to Target square (e.g. `'f3'`).
1274
1136
  */
1275
1137
  onArrowEdited: _propTypes["default"].func,
1276
-
1277
1138
  /**
1278
1139
  * Callback invoked when a move is played (only if `interactionMode` is set to `'playMoves'`).
1279
1140
  *
@@ -1292,15 +1153,14 @@ Chessboard.defaultProps = {
1292
1153
  colorset: 'original',
1293
1154
  pieceset: 'cburnett'
1294
1155
  };
1156
+
1295
1157
  /**
1296
1158
  * Compute the limit applicable to the given window width.
1297
1159
  */
1298
-
1299
1160
  function computeSmallScreenLimits(key, smallScreenLimits, windowWidth) {
1300
1161
  if (!(smallScreenLimits instanceof Array)) {
1301
1162
  return undefined;
1302
1163
  }
1303
-
1304
1164
  var applicableLimits = smallScreenLimits.filter(function (limit) {
1305
1165
  return limit && key in limit && windowWidth <= limit.width;
1306
1166
  }).sort(function (la, lb) {
@@ -1308,19 +1168,17 @@ function computeSmallScreenLimits(key, smallScreenLimits, windowWidth) {
1308
1168
  });
1309
1169
  return applicableLimits.length > 0 ? applicableLimits[0][key] : undefined;
1310
1170
  }
1171
+
1311
1172
  /**
1312
1173
  * Return the font size to use for coordinates assuming the given square size.
1313
1174
  */
1314
-
1315
-
1316
1175
  function computeCoordinateFontSize(squareSize) {
1317
1176
  return squareSize <= 32 ? 8 : 8 + (squareSize - 32) * 0.2;
1318
1177
  }
1178
+
1319
1179
  /**
1320
1180
  * Try to interpret the given object as a chess position.
1321
1181
  */
1322
-
1323
-
1324
1182
  function parsePosition(position) {
1325
1183
  if (position instanceof _kokopu.Position) {
1326
1184
  return {
@@ -1351,11 +1209,10 @@ function parsePosition(position) {
1351
1209
  };
1352
1210
  }
1353
1211
  }
1212
+
1354
1213
  /**
1355
1214
  * Try to interpret the given object `move` as a move descriptor based on the given position.
1356
1215
  */
1357
-
1358
-
1359
1216
  function parseMove(position, move) {
1360
1217
  if (move instanceof _kokopu.MoveDescriptor) {
1361
1218
  return {
@@ -1386,11 +1243,10 @@ function parseMove(position, move) {
1386
1243
  };
1387
1244
  }
1388
1245
  }
1246
+
1389
1247
  /**
1390
1248
  * Try to interpret the given object as a list of markers.
1391
1249
  */
1392
-
1393
-
1394
1250
  function parseMarkers(markers, parse, isValidKey, isValidValue) {
1395
1251
  if (typeof markers === 'string') {
1396
1252
  return parse(markers);
@@ -1398,15 +1254,13 @@ function parseMarkers(markers, parse, isValidKey, isValidValue) {
1398
1254
  var result = {};
1399
1255
  Object.entries(markers).filter(function (_ref7) {
1400
1256
  var _ref8 = _slicedToArray(_ref7, 2),
1401
- key = _ref8[0],
1402
- value = _ref8[1];
1403
-
1257
+ key = _ref8[0],
1258
+ value = _ref8[1];
1404
1259
  return isValidKey(key) && isValidValue(value);
1405
1260
  }).forEach(function (_ref9) {
1406
1261
  var _ref10 = _slicedToArray(_ref9, 2),
1407
- key = _ref10[0],
1408
- value = _ref10[1];
1409
-
1262
+ key = _ref10[0],
1263
+ value = _ref10[1];
1410
1264
  result[key] = value;
1411
1265
  });
1412
1266
  return result;