cm-chessboard 7.3.16 → 7.4.0
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/README.md +3 -3
- package/examples/destroy-many-boards.html +2 -2
- package/examples/different-styles.html +2 -2
- package/examples/enable-input.html +3 -3
- package/examples/extensions/accessibility-extension.html +3 -3
- package/examples/extensions/arrows-extension.html +2 -2
- package/examples/extensions/markers-extension.html +3 -3
- package/examples/extensions/promotion-dialog-extension.html +3 -3
- package/examples/extensions/render-video-extension.html +3 -3
- package/examples/many-boards.html +1 -1
- package/examples/pieces-animation.html +2 -2
- package/examples/responsive-board.html +2 -2
- package/examples/simple-boards.html +2 -2
- package/examples/test-getPiece.html +1 -1
- package/examples/validate-moves.html +4 -4
- package/index.html +2 -2
- package/package.json +3 -3
- package/src/{cm-chessboard/Chessboard.js → Chessboard.js} +1 -1
- package/src/{cm-chessboard/view → view}/ChessboardView.js +1 -1
- package/test/TestBoard.js +2 -2
- package/test/TestChessboard.js +2 -2
- package/test/TestMarkers.js +2 -2
- package/test/TestPiecesAnimation.js +3 -3
- package/test/TestPosition.js +1 -1
- /package/src/{cm-chessboard/extensions → extensions}/accessibility/Accessibility.js +0 -0
- /package/src/{cm-chessboard/extensions → extensions}/arrows/Arrows.js +0 -0
- /package/src/{cm-chessboard/extensions → extensions}/markers/Markers.js +0 -0
- /package/src/{cm-chessboard/extensions → extensions}/promotion-dialog/PromotionDialog.js +0 -0
- /package/src/{cm-chessboard/extensions → extensions}/render-video/RenderVideo.js +0 -0
- /package/src/{cm-chessboard/lib → lib}/I18n.js +0 -0
- /package/src/{cm-chessboard/lib → lib}/Svg.js +0 -0
- /package/src/{cm-chessboard/lib → lib}/Utils.js +0 -0
- /package/src/{cm-chessboard/model → model}/ChessboardState.js +0 -0
- /package/src/{cm-chessboard/model → model}/Extension.js +0 -0
- /package/src/{cm-chessboard/model → model}/Position.js +0 -0
- /package/src/{cm-chessboard/view → view}/PositionAnimationsQueue.js +0 -0
- /package/src/{cm-chessboard/view → view}/VisualMoveInput.js +0 -0
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ The core of cm-chessboard is small, fast and reduced to the essentials. You can
|
|
|
41
41
|
|
|
42
42
|
**Option 2:** Download the code from [GitHub](https://github.com/shaack/cm-chessboard).
|
|
43
43
|
|
|
44
|
-
**Option 3:** Use it via CDN https://cdn.jsdelivr.net/npm/cm-chessboard@7/src/
|
|
44
|
+
**Option 3:** Use it via CDN https://cdn.jsdelivr.net/npm/cm-chessboard@7/src/Chessboard.js
|
|
45
45
|
|
|
46
46
|
After installation, copy the sprite in `cm-chessboard/assets/images/` to your projects `assets/images/`
|
|
47
47
|
folder. If you put the sprite somewhere else you have to configure the location
|
|
@@ -56,14 +56,14 @@ dependencies.
|
|
|
56
56
|
Preconditions for using cm-chessboard in a web page:
|
|
57
57
|
|
|
58
58
|
1. **include the css:** `assets/styles/cm-chessboard.css`
|
|
59
|
-
2. **import the ES6 module:** `import {Chessboard} from "PATH/TO/src/
|
|
59
|
+
2. **import the ES6 module:** `import {Chessboard} from "PATH/TO/src/Chessboard.js"`
|
|
60
60
|
|
|
61
61
|
Example, showing a FEN:
|
|
62
62
|
|
|
63
63
|
```html
|
|
64
64
|
|
|
65
65
|
<script type="module">
|
|
66
|
-
import {Chessboard} from "./src/
|
|
66
|
+
import {Chessboard} from "./src/Chessboard.js"
|
|
67
67
|
|
|
68
68
|
new Chessboard(document.getElementById("containerId"),
|
|
69
69
|
{position: "rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR"})
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
<h2>Stress Test: Create and destroy 5,000 responsive boards</h2>
|
|
30
30
|
<div id="boards"></div>
|
|
31
31
|
<script type="module">
|
|
32
|
-
import {Chessboard} from "../src/
|
|
33
|
-
import {FEN} from "../src/
|
|
32
|
+
import {Chessboard} from "../src/Chessboard.js"
|
|
33
|
+
import {FEN} from "../src/model/Position.js"
|
|
34
34
|
import {Chess} from "https://cdn.jsdelivr.net/npm/chess.mjs@1/src/chess.mjs/Chess.js"
|
|
35
35
|
|
|
36
36
|
const boardsDiv = document.getElementById("boards")
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
<div class="board" id="board8"></div>
|
|
21
21
|
<div class="board" id="board9"></div>
|
|
22
22
|
<script type="module">
|
|
23
|
-
import {Chessboard, BORDER_TYPE} from "../src/
|
|
24
|
-
import {FEN} from "../src/
|
|
23
|
+
import {Chessboard, BORDER_TYPE} from "../src/Chessboard.js"
|
|
24
|
+
import {FEN} from "../src/model/Position.js"
|
|
25
25
|
|
|
26
26
|
new Chessboard(document.getElementById("board1"), {
|
|
27
27
|
position: FEN.start,
|
|
@@ -45,9 +45,9 @@ function inputHandler(event) {
|
|
|
45
45
|
</button>
|
|
46
46
|
<div id="output" style="width: 100%; overflow: hidden"></div>
|
|
47
47
|
<script type="module">
|
|
48
|
-
import {INPUT_EVENT_TYPE, Chessboard} from "../src/
|
|
49
|
-
import {FEN} from "../src/
|
|
50
|
-
import {MARKER_TYPE, Markers} from "../src/
|
|
48
|
+
import {INPUT_EVENT_TYPE, Chessboard} from "../src/Chessboard.js"
|
|
49
|
+
import {FEN} from "../src/model/Position.js"
|
|
50
|
+
import {MARKER_TYPE, Markers} from "../src/extensions/markers/Markers.js"
|
|
51
51
|
|
|
52
52
|
window.board = new Chessboard(document.getElementById("board"), {
|
|
53
53
|
position: FEN.start,
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
onclick="window.switchOrientation()">Switch Orientation
|
|
35
35
|
</button>
|
|
36
36
|
<script type="module">
|
|
37
|
-
import {Chessboard} from "../../src/
|
|
38
|
-
import {Accessibility} from "../../src/
|
|
39
|
-
import {Markers} from "../../src/
|
|
37
|
+
import {Chessboard} from "../../src/Chessboard.js"
|
|
38
|
+
import {Accessibility} from "../../src/extensions/accessibility/Accessibility.js"
|
|
39
|
+
import {Markers} from "../../src/extensions/markers/Markers.js"
|
|
40
40
|
|
|
41
41
|
const chessboard = new Chessboard(document.getElementById("board"), {
|
|
42
42
|
position: "rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR w Gkq - 4 11",
|
|
@@ -43,8 +43,8 @@ console.log(chessboard.getArrows())
|
|
|
43
43
|
</p>
|
|
44
44
|
|
|
45
45
|
<script type="module">
|
|
46
|
-
import {ARROW_TYPE, Arrows} from "../../src/
|
|
47
|
-
import {Chessboard} from "../../src/
|
|
46
|
+
import {ARROW_TYPE, Arrows} from "../../src/extensions/arrows/Arrows.js"
|
|
47
|
+
import {Chessboard} from "../../src/Chessboard.js"
|
|
48
48
|
|
|
49
49
|
const chessboard = new Chessboard(document.getElementById("board"), {
|
|
50
50
|
position: "rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR w Gkq - 4 11",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
<div style="clear: both"></div>
|
|
18
18
|
<button onclick="window.removeDots()">Remove dots</button>
|
|
19
19
|
<script type="module">
|
|
20
|
-
import {Chessboard, SQUARE_SELECT_TYPE} from "../../src/
|
|
21
|
-
import {FEN} from "../../src/
|
|
22
|
-
import {MARKER_TYPE, Markers} from "../../src/
|
|
20
|
+
import {Chessboard, SQUARE_SELECT_TYPE} from "../../src/Chessboard.js"
|
|
21
|
+
import {FEN} from "../../src/model/Position.js"
|
|
22
|
+
import {MARKER_TYPE, Markers} from "../../src/extensions/markers/Markers.js"
|
|
23
23
|
|
|
24
24
|
const board1 = new Chessboard(document.getElementById("board1"), {
|
|
25
25
|
position: FEN.start,
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
onclick="window.switchOrientation()">Switch Orientation
|
|
21
21
|
</button>
|
|
22
22
|
<script type="module">
|
|
23
|
-
import {Chessboard, COLOR, INPUT_EVENT_TYPE} from "../../src/
|
|
24
|
-
import {PromotionDialog} from "../../src/
|
|
25
|
-
import {Markers} from "../../src/
|
|
23
|
+
import {Chessboard, COLOR, INPUT_EVENT_TYPE} from "../../src/Chessboard.js"
|
|
24
|
+
import {PromotionDialog} from "../../src/extensions/promotion-dialog/PromotionDialog.js"
|
|
25
|
+
import {Markers} from "../../src/extensions/markers/Markers.js"
|
|
26
26
|
|
|
27
27
|
const position = "4k3/1P6/8/8/6r1/8/8/2R1K3 w - - 0 1"
|
|
28
28
|
const chessboard = new Chessboard(document.getElementById("chessboard"), {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
<br/>
|
|
18
18
|
<a href="" style="visibility: hidden" id="download-link">Download video</a>
|
|
19
19
|
<script type="module">
|
|
20
|
-
import {RenderVideo} from "../../src/
|
|
21
|
-
import {Chessboard} from "../../src/
|
|
22
|
-
import {FEN} from "../../src/
|
|
20
|
+
import {RenderVideo} from "../../src/extensions/render-video/RenderVideo.js"
|
|
21
|
+
import {Chessboard} from "../../src/Chessboard.js"
|
|
22
|
+
import {FEN} from "../../src/model/Position.js"
|
|
23
23
|
|
|
24
24
|
const boardElement = document.getElementById("board")
|
|
25
25
|
const chessboard = new Chessboard(boardElement, {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<div id="boards"></div>
|
|
23
23
|
<!--suppress JSUnresolvedFunction -->
|
|
24
24
|
<script type="module">
|
|
25
|
-
import {Chessboard} from "../src/
|
|
25
|
+
import {Chessboard} from "../src/Chessboard.js"
|
|
26
26
|
import {Chess} from "https://cdn.jsdelivr.net/npm/chess.mjs@1/src/chess.mjs/Chess.js"
|
|
27
27
|
|
|
28
28
|
const boardsDiv = document.getElementById("boards")
|
|
@@ -44,8 +44,8 @@ await board.movePiece("c3", "d5")
|
|
|
44
44
|
await board.movePiece("d5", "f4")
|
|
45
45
|
</pre>
|
|
46
46
|
<script type="module">
|
|
47
|
-
import {Chessboard, PIECE} from "../src/
|
|
48
|
-
import {FEN} from "../src/
|
|
47
|
+
import {Chessboard, PIECE} from "../src/Chessboard.js"
|
|
48
|
+
import {FEN} from "../src/model/Position.js"
|
|
49
49
|
|
|
50
50
|
const board = new Chessboard(document.getElementById("board"),
|
|
51
51
|
{
|
|
@@ -18,8 +18,8 @@ new Chessboard(document.getElementById("board"), {
|
|
|
18
18
|
})
|
|
19
19
|
</pre>
|
|
20
20
|
<script type="module">
|
|
21
|
-
import {Chessboard} from "../src/
|
|
22
|
-
import {FEN} from "../src/
|
|
21
|
+
import {Chessboard} from "../src/Chessboard.js"
|
|
22
|
+
import {FEN} from "../src/model/Position.js"
|
|
23
23
|
|
|
24
24
|
new Chessboard(document.getElementById("board"), {
|
|
25
25
|
position: FEN.start,
|
|
@@ -24,8 +24,8 @@ new Chessboard(document.getElementById("board2"), {
|
|
|
24
24
|
})
|
|
25
25
|
</pre>
|
|
26
26
|
<script type="module">
|
|
27
|
-
import {COLOR, Chessboard, BORDER_TYPE} from "../src/
|
|
28
|
-
import {FEN} from "../src/
|
|
27
|
+
import {COLOR, Chessboard, BORDER_TYPE} from "../src/Chessboard.js"
|
|
28
|
+
import {FEN} from "../src/model/Position.js"
|
|
29
29
|
|
|
30
30
|
new Chessboard(document.getElementById("board1"), {
|
|
31
31
|
position: FEN.start,
|
|
@@ -9,7 +9,7 @@ Board:
|
|
|
9
9
|
<div id="board"></div>
|
|
10
10
|
|
|
11
11
|
<script type="module">
|
|
12
|
-
import { Chessboard } from '../src/
|
|
12
|
+
import { Chessboard } from '../src/Chessboard.js'
|
|
13
13
|
|
|
14
14
|
const board = new Chessboard(document.getElementById('board'), {
|
|
15
15
|
position: 'start',
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
<div id="output"></div>
|
|
18
18
|
|
|
19
19
|
<script type="module">
|
|
20
|
-
import {INPUT_EVENT_TYPE, COLOR, Chessboard, BORDER_TYPE} from "../src/
|
|
21
|
-
import {MARKER_TYPE, Markers} from "../src/
|
|
22
|
-
import {PromotionDialog} from "../src/
|
|
23
|
-
import {Accessibility} from "../src/
|
|
20
|
+
import {INPUT_EVENT_TYPE, COLOR, Chessboard, BORDER_TYPE} from "../src/Chessboard.js"
|
|
21
|
+
import {MARKER_TYPE, Markers} from "../src/extensions/markers/Markers.js"
|
|
22
|
+
import {PromotionDialog} from "../src/extensions/promotion-dialog/PromotionDialog.js"
|
|
23
|
+
import {Accessibility} from "../src/extensions/accessibility/Accessibility.js"
|
|
24
24
|
import {Chess} from "https://cdn.jsdelivr.net/npm/chess.mjs@1/src/chess.mjs/Chess.js"
|
|
25
25
|
|
|
26
26
|
const chess = new Chess()
|
package/index.html
CHANGED
|
@@ -37,8 +37,8 @@ It works, it is cool and it is easy to use. 👍</p>
|
|
|
37
37
|
<h2>Chessboard</h2>
|
|
38
38
|
<div class="board" id="board"></div>
|
|
39
39
|
<script type="module">
|
|
40
|
-
import {Chessboard} from "./src/
|
|
41
|
-
import {FEN} from "./src/
|
|
40
|
+
import {Chessboard} from "./src/Chessboard.js"
|
|
41
|
+
import {FEN} from "./src/model/Position.js"
|
|
42
42
|
import {Chess} from "https://cdn.jsdelivr.net/npm/chess.mjs@1/src/chess.mjs/Chess.js"
|
|
43
43
|
|
|
44
44
|
const chess = new Chess()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cm-chessboard",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chess",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"widget"
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
|
-
"module": "./src/
|
|
17
|
-
"browser": "./src/
|
|
16
|
+
"module": "./src/Chessboard.js",
|
|
17
|
+
"browser": "./src/Chessboard.js",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "tput setaf 4;echo 'Run test/index.html in your browser for unit testing.'; echo ''; exit 0"
|
|
20
20
|
},
|
|
@@ -170,7 +170,7 @@ export class Chessboard {
|
|
|
170
170
|
this.context.addEventListener("contextmenu", this.squareSelectListener)
|
|
171
171
|
this.context.addEventListener("mousedown", this.squareSelectListener)
|
|
172
172
|
this.context.addEventListener("mouseup", this.squareSelectListener)
|
|
173
|
-
this.context.addEventListener("touchstart", this.squareSelectListener)
|
|
173
|
+
this.context.addEventListener("touchstart", this.squareSelectListener, {passive: false})
|
|
174
174
|
this.context.addEventListener("touchend", this.squareSelectListener)
|
|
175
175
|
this.state.squareSelectEnabled = true
|
|
176
176
|
this.view.visualizeInputState()
|
|
@@ -38,7 +38,7 @@ export class ChessboardView {
|
|
|
38
38
|
this.pointerDownListener = this.pointerDownHandler.bind(this)
|
|
39
39
|
this.pointerDownListener = this.pointerDownHandler.bind(this)
|
|
40
40
|
this.context.addEventListener("mousedown", this.pointerDownListener)
|
|
41
|
-
this.context.addEventListener("touchstart", this.pointerDownListener)
|
|
41
|
+
this.context.addEventListener("touchstart", this.pointerDownListener, {passive: false})
|
|
42
42
|
|
|
43
43
|
this.createSvgAndGroups()
|
|
44
44
|
this.updateMetrics()
|
package/test/TestBoard.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {Chessboard} from "../src/
|
|
9
|
-
import {FEN} from "../src/
|
|
8
|
+
import {Chessboard} from "../src/Chessboard.js"
|
|
9
|
+
import {FEN} from "../src/model/Position.js"
|
|
10
10
|
|
|
11
11
|
describe("TestBoard", () => {
|
|
12
12
|
|
package/test/TestChessboard.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {PIECE, Chessboard} from "../src/
|
|
9
|
-
import {FEN} from "../src/
|
|
8
|
+
import {PIECE, Chessboard} from "../src/Chessboard.js"
|
|
9
|
+
import {FEN} from "../src/model/Position.js"
|
|
10
10
|
|
|
11
11
|
describe("TestChessboard", () => {
|
|
12
12
|
|
package/test/TestMarkers.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {Chessboard} from "../src/
|
|
9
|
-
import {MARKER_TYPE, Markers} from "../src/
|
|
8
|
+
import {Chessboard} from "../src/Chessboard.js"
|
|
9
|
+
import {MARKER_TYPE, Markers} from "../src/extensions/markers/Markers.js"
|
|
10
10
|
|
|
11
11
|
describe("TestMarkers", () => {
|
|
12
12
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {ChessboardState} from "../src/
|
|
9
|
-
import {PositionsAnimation} from "../src/
|
|
10
|
-
import {Position} from "../src/
|
|
8
|
+
import {ChessboardState} from "../src/model/ChessboardState.js"
|
|
9
|
+
import {PositionsAnimation} from "../src/view/PositionAnimationsQueue.js"
|
|
10
|
+
import {Position} from "../src/model/Position.js"
|
|
11
11
|
|
|
12
12
|
describe("TestPiecesAnimation", () => {
|
|
13
13
|
it("should calculate square distances", () => {
|
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/
|
|
8
|
+
import {Position} from "../src/model/Position.js"
|
|
9
9
|
|
|
10
10
|
describe("TestPosition", () => {
|
|
11
11
|
it("should convert square to index", () => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|