cm-chessboard 4.1.1 → 4.1.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": "4.1.1",
3
+ "version": "4.1.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",
@@ -4,10 +4,10 @@
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
6
 
7
- import {State} from "./core/State.js"
8
- import {ViewAccessible} from "./core/ViewAccessible.js"
9
- import {PositionAnimationsQueue} from "./core/PositionAnimationsQueue.js"
10
- import {Position} from "./core/Position.js"
7
+ import {ChessboardState} from "./model/ChessboardState.js"
8
+ import {Position} from "./model/Position.js"
9
+ import {ChessboardViewAccessible} from "./view/ChessboardViewAccessible.js"
10
+ import {PositionAnimationsQueue} from "./view/PositionAnimationsQueue.js"
11
11
 
12
12
  export const COLOR = {
13
13
  white: "w",
@@ -88,8 +88,8 @@ export class Chessboard {
88
88
  Object.assign(this.props.accessibility, props.accessibility)
89
89
  }
90
90
 
91
- this.state = new State()
92
- this.view = new ViewAccessible(this)
91
+ this.state = new ChessboardState()
92
+ this.view = new ChessboardViewAccessible(this)
93
93
  this.positionAnimationsQueue = new PositionAnimationsQueue(this)
94
94
  this.state.orientation = this.props.orientation
95
95
  this.view.redraw()
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import {Position} from "./Position.js"
7
7
 
8
- export class State {
8
+ export class ChessboardState {
9
9
 
10
10
  constructor() {
11
11
  this.position = new Position()
File without changes
@@ -4,9 +4,9 @@
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
6
 
7
- import {MoveInput} from "./MoveInput.js"
7
+ import {VisualMoveInput} from "./VisualMoveInput.js"
8
8
  import {COLOR, INPUT_EVENT_TYPE, BORDER_TYPE} from "../Chessboard.js"
9
- import {Position} from "./Position.js"
9
+ import {Position} from "../model/Position.js"
10
10
 
11
11
  export const piecesTranslations = {
12
12
  en: {
@@ -47,11 +47,11 @@ export function renderPieceTitle(lang, name, color = undefined) {
47
47
  return title
48
48
  }
49
49
 
50
- export class View {
50
+ export class ChessboardView {
51
51
 
52
52
  constructor(chessboard) {
53
53
  this.chessboard = chessboard
54
- this.moveInput = new MoveInput(this,
54
+ this.moveInput = new VisualMoveInput(this,
55
55
  this.moveStartCallback.bind(this),
56
56
  this.moveDoneCallback.bind(this),
57
57
  this.moveCanceledCallback.bind(this)
@@ -3,9 +3,9 @@
3
3
  * Repository: https://github.com/shaack/cm-chessboard
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
- import {View, renderPieceTitle} from "./View.js"
6
+ import {ChessboardView, renderPieceTitle} from "./ChessboardView.js"
7
7
  import {COLOR, INPUT_EVENT_TYPE} from "../Chessboard.js"
8
- import {piecesTranslations} from "./View.js"
8
+ import {piecesTranslations} from "./ChessboardView.js"
9
9
 
10
10
  const hlTranslations = {
11
11
  de: {
@@ -32,7 +32,7 @@ const hlTranslations = {
32
32
  }
33
33
  }
34
34
 
35
- export class ViewAccessible extends View {
35
+ export class ChessboardViewAccessible extends ChessboardView {
36
36
 
37
37
  constructor(chessboard, callbackAfterCreation) {
38
38
  super(chessboard, callbackAfterCreation)
@@ -3,8 +3,8 @@
3
3
  * Repository: https://github.com/shaack/cm-chessboard
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
- import {FEN_EMPTY_POSITION, Position} from "./Position.js"
7
- import {Svg} from "./View.js"
6
+ import {FEN_EMPTY_POSITION, Position} from "../model/Position.js"
7
+ import {Svg} from "./ChessboardView.js"
8
8
 
9
9
  /*
10
10
  * Thanks to markosyan for the idea to the PromiseQueue
@@ -4,7 +4,7 @@
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
6
 
7
- import {Svg} from "./View.js"
7
+ import {Svg} from "./ChessboardView.js"
8
8
 
9
9
  const STATE = {
10
10
  waitForInputStart: 0,
@@ -26,7 +26,7 @@ export const MOVE_CANCELED_REASON = {
26
26
 
27
27
  const DRAG_THRESHOLD = 4
28
28
 
29
- export class MoveInput {
29
+ export class VisualMoveInput {
30
30
 
31
31
  constructor(view, moveStartCallback, moveDoneCallback, moveCanceledCallback) {
32
32
  this.view = view
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
8
- import {State} from "../src/cm-chessboard/core/State.js"
9
- import {PositionsAnimation} from "../src/cm-chessboard/core/PositionAnimationsQueue.js"
8
+ import {ChessboardState} from "../src/cm-chessboard/model/ChessboardState.js"
9
+ import {PositionsAnimation} from "../src/cm-chessboard/view/PositionAnimationsQueue.js"
10
10
 
11
11
  describe("TestPiecesAnimation", () => {
12
12
  it("should calculate square distances", () => {
@@ -21,9 +21,9 @@ describe("TestPiecesAnimation", () => {
21
21
  })
22
22
 
23
23
  it("should seek changes", () => {
24
- const state1 = new State()
24
+ const state1 = new ChessboardState()
25
25
  state1.setPosition("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
26
- const state2 = new State()
26
+ const state2 = new ChessboardState()
27
27
  state2.setPosition("rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR")
28
28
  const previousBoard1 = state1.position.squares
29
29
  const newBoard1 = state2.position.squares
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
8
- import {Position} from "../src/cm-chessboard/core/Position.js"
8
+ import {Position} from "../src/cm-chessboard/model/Position.js"
9
9
 
10
10
  describe("TestPosition", () => {
11
11
  it("should convert square to index", () => {