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 +1 -1
- package/src/cm-chessboard/Chessboard.js +6 -6
- package/src/cm-chessboard/{core/State.js → model/ChessboardState.js} +1 -1
- package/src/cm-chessboard/{core → model}/Position.js +0 -0
- package/src/cm-chessboard/{core/View.js → view/ChessboardView.js} +4 -4
- package/src/cm-chessboard/{core/ViewAccessible.js → view/ChessboardViewAccessible.js} +3 -3
- package/src/cm-chessboard/{core → view}/PositionAnimationsQueue.js +2 -2
- package/src/cm-chessboard/{core/MoveInput.js → view/VisualMoveInput.js} +2 -2
- package/test/TestPiecesAnimation.js +4 -4
- package/test/TestPosition.js +1 -1
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* License: MIT, see file 'LICENSE'
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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
|
|
92
|
-
this.view = new
|
|
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()
|
|
File without changes
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* License: MIT, see file 'LICENSE'
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {VisualMoveInput} from "./VisualMoveInput.js"
|
|
8
8
|
import {COLOR, INPUT_EVENT_TYPE, BORDER_TYPE} from "../Chessboard.js"
|
|
9
|
-
import {Position} from "
|
|
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
|
|
50
|
+
export class ChessboardView {
|
|
51
51
|
|
|
52
52
|
constructor(chessboard) {
|
|
53
53
|
this.chessboard = chessboard
|
|
54
|
-
this.moveInput = new
|
|
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 {
|
|
6
|
+
import {ChessboardView, renderPieceTitle} from "./ChessboardView.js"
|
|
7
7
|
import {COLOR, INPUT_EVENT_TYPE} from "../Chessboard.js"
|
|
8
|
-
import {piecesTranslations} from "./
|
|
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
|
|
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 "
|
|
7
|
-
import {Svg} from "./
|
|
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 "./
|
|
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
|
|
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 {
|
|
9
|
-
import {PositionsAnimation} from "../src/cm-chessboard/
|
|
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
|
|
24
|
+
const state1 = new ChessboardState()
|
|
25
25
|
state1.setPosition("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
|
|
26
|
-
const state2 = new
|
|
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
|
package/test/TestPosition.js
CHANGED
|
@@ -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/
|
|
8
|
+
import {Position} from "../src/cm-chessboard/model/Position.js"
|
|
9
9
|
|
|
10
10
|
describe("TestPosition", () => {
|
|
11
11
|
it("should convert square to index", () => {
|