cm-chessboard 7.4.2 → 7.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "7.4.2",
3
+ "version": "7.4.4",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
package/src/Chessboard.js CHANGED
@@ -188,9 +188,21 @@ export class Chessboard {
188
188
  }
189
189
 
190
190
  addExtension(extensionClass, props) {
191
+ if(this.hasExtension(extensionClass)) {
192
+ throw Error("extension \"" + extensionClass.name + "\" already added")
193
+ }
191
194
  this.extensions.push(new extensionClass(this, props))
192
195
  }
193
196
 
197
+ hasExtension(extensionClass) {
198
+ for (const extension of this.extensions) {
199
+ if (extension instanceof extensionClass) {
200
+ return true
201
+ }
202
+ }
203
+ return false
204
+ }
205
+
194
206
  destroy() {
195
207
  this.state.invokeExtensionPoints(EXTENSION_POINT.destroy)
196
208
  if (this.state.squareSelectEnabled) {
@@ -302,6 +302,9 @@ export class ChessboardView {
302
302
  // enable and disable move input //
303
303
 
304
304
  enableMoveInput(eventHandler, color = undefined) {
305
+ if(this.moveInputCallback) {
306
+ throw Error("moveInput already enabled")
307
+ }
305
308
  if (color === COLOR.white) {
306
309
  this.chessboard.state.inputWhiteEnabled = true
307
310
  } else if (color === COLOR.black) {