cm-chessboard 7.4.0 → 7.4.2

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.0",
3
+ "version": "7.4.2",
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
@@ -81,7 +81,7 @@ export class Chessboard {
81
81
  this.state.orientation = this.props.orientation
82
82
  // instantiate extensions
83
83
  for (const extensionData of this.props.extensions) {
84
- this.extensions.push(new extensionData.class(this, extensionData.props))
84
+ this.addExtension(extensionData.class, extensionData.props)
85
85
  }
86
86
  this.view.redrawBoard()
87
87
  this.state.position = new Position(this.props.position)
@@ -187,9 +187,13 @@ export class Chessboard {
187
187
  this.view.visualizeInputState()
188
188
  }
189
189
 
190
+ addExtension(extensionClass, props) {
191
+ this.extensions.push(new extensionClass(this, props))
192
+ }
193
+
190
194
  destroy() {
191
195
  this.state.invokeExtensionPoints(EXTENSION_POINT.destroy)
192
- if(this.state.squareSelectEnabled) {
196
+ if (this.state.squareSelectEnabled) {
193
197
  this.disableSquareSelect()
194
198
  }
195
199
  this.positionAnimationsQueue.destroy()
@@ -39,7 +39,7 @@ const translations = {
39
39
 
40
40
  export class Accessibility extends Extension {
41
41
  constructor(chessboard, props) {
42
- super(chessboard, props)
42
+ super(chessboard)
43
43
  this.props = {
44
44
  brailleNotationInAlt: true, // show the braille notation of the position in the alt attribute of the SVG image
45
45
  movePieceForm: true, // display a form to move a piece (from, to, move)
@@ -15,7 +15,7 @@ export const ARROW_TYPE = {
15
15
 
16
16
  export class Arrows extends Extension {
17
17
  constructor(chessboard, props = {}) {
18
- super(chessboard, props)
18
+ super(chessboard)
19
19
  this.registerExtensionPoint(EXTENSION_POINT.redrawBoard, () => {
20
20
  this.onRedrawBoard()
21
21
  })
@@ -22,7 +22,7 @@ export const MARKER_TYPE = {
22
22
 
23
23
  export class Markers extends Extension {
24
24
  constructor(chessboard, props = {}) {
25
- super(chessboard, props)
25
+ super(chessboard)
26
26
  this.registerExtensionPoint(EXTENSION_POINT.redrawBoard, () => {
27
27
  this.onRedrawBoard()
28
28
  })
@@ -17,8 +17,8 @@ const DISPLAY_STATE = {
17
17
 
18
18
  export class PromotionDialog extends Extension {
19
19
 
20
- constructor(chessboard, props = {}) {
21
- super(chessboard, props)
20
+ constructor(chessboard) {
21
+ super(chessboard)
22
22
  this.registerExtensionPoint(EXTENSION_POINT.redrawBoard, this.extensionPointRedrawBoard.bind(this))
23
23
  this.registerExtensionPoint(EXTENSION_POINT.animation, this.extensionPointAnimation.bind(this))
24
24
  this.registerMethod("showPromotionDialog", this.showPromotionDialog)
@@ -10,7 +10,7 @@ import {ANIMATION_EVENT_TYPE} from "../../view/PositionAnimationsQueue.js"
10
10
  export class RenderVideo extends Extension {
11
11
 
12
12
  constructor(chessboard, props) {
13
- super(chessboard, props)
13
+ super(chessboard)
14
14
  this.props = {
15
15
  mediaType: "auto",
16
16
  safariMode: true
@@ -16,9 +16,8 @@ export const EXTENSION_POINT = {
16
16
 
17
17
  export class Extension {
18
18
 
19
- constructor(chessboard, props) {
19
+ constructor(chessboard) {
20
20
  this.chessboard = chessboard
21
- this.props = props
22
21
  }
23
22
 
24
23
  registerExtensionPoint(name, callback) {