kokopu-react 1.6.0 → 1.7.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/.nycrc.yml +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/lib/Chessboard.js +21 -13
- package/dist/lib/impl/colorsets.js +44 -44
- package/dist/lib/impl/util.js +1 -1
- package/dist/lib/markers.js +7 -7
- package/doc_src/demo/PageChessboardInteraction.js +4 -3
- package/doc_src/demo/PageChessboardMove.js +36 -5
- package/doc_src/demo/demo.css +4 -0
- package/{graphic_test_app → graphic_test_src}/01_marker_icons.js +0 -0
- package/{graphic_test_app → graphic_test_src}/02_chessboard_simple.js +0 -0
- package/{graphic_test_app → graphic_test_src}/03_chessboard_flipped.js +0 -0
- package/{graphic_test_app → graphic_test_src}/04_chessboard_annotations.js +8 -8
- package/{graphic_test_app → graphic_test_src}/05_chessboard_move.js +4 -4
- package/{graphic_test_app → graphic_test_src}/06_chessboard_theme.js +2 -2
- package/{graphic_test_app → graphic_test_src}/07_chessboard_click_squares.js +0 -0
- package/{graphic_test_app → graphic_test_src}/08_chessboard_move_pieces.js +1 -1
- package/{graphic_test_app → graphic_test_src}/09_chessboard_edit_arrows.js +0 -0
- package/{graphic_test_app → graphic_test_src}/10_chessboard_play_moves.js +1 -1
- package/{graphic_test_app → graphic_test_src}/11_chessboard_play_promotions.js +0 -0
- package/{graphic_test_app → graphic_test_src}/12_movetext_simple.js +0 -0
- package/{graphic_test_app → graphic_test_src}/13_movetext_error.js +0 -0
- package/{graphic_test_app → graphic_test_src}/14_movetext_html.js +0 -0
- package/{graphic_test_app → graphic_test_src}/15_movetext_options.js +0 -4
- package/{graphic_test_app → graphic_test_src}/16_movetext_interaction.js +0 -0
- package/{graphic_test_app → graphic_test_src}/common/dummy.pgn +0 -0
- package/{graphic_test_app → graphic_test_src}/common/games.pgn +0 -0
- package/{graphic_test_app → graphic_test_src}/common/heartbeat.txt +0 -0
- package/{graphic_test_app → graphic_test_src}/common/smiley.png +0 -0
- package/{graphic_test_app → graphic_test_src}/common/test_app.css +0 -0
- package/{graphic_test_app → graphic_test_src}/common/test_app.js +3 -2
- package/graphics/chess_sprites/cburnett/bb.svg +45 -0
- package/graphics/chess_sprites/cburnett/bk.svg +47 -0
- package/graphics/chess_sprites/cburnett/bn.svg +37 -0
- package/graphics/chess_sprites/cburnett/bp.svg +19 -0
- package/graphics/chess_sprites/cburnett/bq.svg +58 -0
- package/graphics/chess_sprites/cburnett/br.svg +60 -0
- package/graphics/chess_sprites/cburnett/bx.svg +56 -0
- package/graphics/chess_sprites/cburnett/wb.svg +48 -0
- package/graphics/chess_sprites/cburnett/wk.svg +26 -0
- package/graphics/chess_sprites/cburnett/wn.svg +37 -0
- package/graphics/chess_sprites/cburnett/wp.svg +19 -0
- package/graphics/chess_sprites/cburnett/wq.svg +60 -0
- package/graphics/chess_sprites/cburnett/wr.svg +44 -0
- package/graphics/chess_sprites/cburnett/wx.svg +56 -0
- package/graphics/chess_sprites/generate_sprites.sh +135 -0
- package/graphics/chess_sprites/mmonge/celtic-bx.svg +112 -0
- package/graphics/chess_sprites/mmonge/celtic-wx.svg +111 -0
- package/graphics/chess_sprites/mmonge/celtic.svg +1576 -0
- package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +101 -0
- package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +100 -0
- package/graphics/chess_sprites/mmonge/eyes.svg +2538 -0
- package/graphics/chess_sprites/mmonge/fantasy-bx.svg +112 -0
- package/graphics/chess_sprites/mmonge/fantasy-wx.svg +111 -0
- package/graphics/chess_sprites/mmonge/fantasy.svg +5497 -0
- package/graphics/chess_sprites/mmonge/fantasy_alt.svg +3742 -0
- package/graphics/chess_sprites/mmonge/freak.svg +3479 -0
- package/graphics/chess_sprites/mmonge/prmi.svg +6776 -0
- package/graphics/chess_sprites/mmonge/skulls-bx.svg +124 -0
- package/graphics/chess_sprites/mmonge/skulls-wx.svg +111 -0
- package/graphics/chess_sprites/mmonge/skulls.svg +12978 -0
- package/graphics/chess_sprites/mmonge/spatial.svg +1223 -0
- package/package.json +21 -19
- package/scripts/{test_graphic/clean-graphic-output.js → clean-graphic-output.js} +1 -1
- package/scripts/{test_graphic/docker-compose.yml → docker-compose.yml} +3 -3
- package/scripts/{test_graphic/webpack-config.js → test-graphic.webpack.config.js} +7 -6
- package/scripts/{test_headless.webpack-config.js → test-headless.webpack.config.js} +2 -1
- package/src/Chessboard.js +21 -13
- package/src/impl/colorsets.js +44 -44
- package/src/impl/util.js +1 -1
- package/src/markers.js +7 -7
- package/test/1_markers.js +14 -14
- package/test/common/graphic.js +2 -2
- package/test/references/04_chessboard_annotations/0.png +0 -0
- package/test/references/04_chessboard_annotations/1.png +0 -0
- package/test/references/04_chessboard_annotations/2.png +0 -0
- package/test/references/04_chessboard_annotations/3.png +0 -0
- package/test/references/04_chessboard_annotations/4.png +0 -0
- package/test/references/04_chessboard_annotations/5.png +0 -0
- package/test/references/05_chessboard_move/4.png +0 -0
- package/test/references/05_chessboard_move/5.png +0 -0
- package/test/references/05_chessboard_move/6.png +0 -0
- package/test/references/06_chessboard_theme/0.png +0 -0
- package/test/references/06_chessboard_theme/1.png +0 -0
- package/test/references/06_chessboard_theme/2.png +0 -0
- package/test/references/06_chessboard_theme/3.png +0 -0
- package/test/references/06_chessboard_theme/4.png +0 -0
- package/test/references/06_chessboard_theme/5.png +0 -0
- package/test/references/06_chessboard_theme/6.png +0 -0
- package/test/references/06_chessboard_theme/7.png +0 -0
- package/test/references/06_chessboard_theme/8.png +0 -0
- package/test/references/08_chessboard_move_pieces/over_arrow_marker.png +0 -0
- package/test/references/08_chessboard_move_pieces/over_square_marker.png +0 -0
- package/test/references/08_chessboard_move_pieces/over_text_marker.png +0 -0
- package/test/references/09_chessboard_edit_arrows/base_1.png +0 -0
- package/test/references/09_chessboard_edit_arrows/base_2.png +0 -0
- package/test/references/09_chessboard_edit_arrows/null_vector.png +0 -0
- package/test/references/09_chessboard_edit_arrows/over_arrow_marker.png +0 -0
- package/test/references/09_chessboard_edit_arrows/over_square_marker.png +0 -0
- package/test/references/10_chessboard_play_moves/castling_move.png +0 -0
- package/test/references/10_chessboard_play_moves/regular_move_2.png +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokopu-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A React-based library to create and display chessboard and chess-related components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chess",
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/lib",
|
|
20
20
|
"doc_src",
|
|
21
|
-
"
|
|
21
|
+
"graphic_test_src",
|
|
22
22
|
"graphics",
|
|
23
|
-
"scripts/
|
|
24
|
-
"scripts/
|
|
23
|
+
"scripts/clean-graphic-output.js",
|
|
24
|
+
"scripts/docker-compose.yml",
|
|
25
|
+
"scripts/test-graphic.webpack.config.js",
|
|
26
|
+
"scripts/test-headless.webpack.config.js",
|
|
25
27
|
"src",
|
|
26
28
|
"test",
|
|
27
29
|
".babelrc",
|
|
@@ -30,49 +32,49 @@
|
|
|
30
32
|
],
|
|
31
33
|
"dependencies": {
|
|
32
34
|
"htmlparser2": "^8.0.1",
|
|
33
|
-
"kokopu": "^2.
|
|
35
|
+
"kokopu": "^2.9.0",
|
|
34
36
|
"prop-types": "^15.8.1",
|
|
35
|
-
"react": "^
|
|
37
|
+
"react": "^18.2.0",
|
|
36
38
|
"react-draggable": "^4.4.5",
|
|
37
39
|
"react-motion": "^0.5.2"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@babel/cli": "^7.17.10",
|
|
41
|
-
"@babel/core": "^7.18.
|
|
43
|
+
"@babel/core": "^7.18.5",
|
|
42
44
|
"@babel/preset-env": "^7.18.2",
|
|
43
45
|
"@babel/preset-react": "^7.17.12",
|
|
44
|
-
"@emotion/react": "^11.9.
|
|
45
|
-
"@emotion/styled": "^11.
|
|
46
|
-
"@mui/material": "^5.8.
|
|
46
|
+
"@emotion/react": "^11.9.3",
|
|
47
|
+
"@emotion/styled": "^11.9.3",
|
|
48
|
+
"@mui/material": "^5.8.5",
|
|
47
49
|
"babel-loader": "^8.2.5",
|
|
48
50
|
"babel-plugin-istanbul": "^6.1.1",
|
|
49
51
|
"copy-webpack-plugin": "^11.0.0",
|
|
50
52
|
"coveralls": "^3.1.1",
|
|
51
53
|
"css-loader": "^6.7.1",
|
|
52
|
-
"eslint": "^8.
|
|
54
|
+
"eslint": "^8.18.0",
|
|
53
55
|
"eslint-plugin-react": "^7.30.0",
|
|
54
56
|
"html-webpack-plugin": "^5.5.0",
|
|
55
57
|
"img-diff-js": "^0.5.2",
|
|
56
58
|
"mocha": "^10.0.0",
|
|
57
59
|
"null-loader": "^4.0.1",
|
|
58
60
|
"nyc": "^15.1.0",
|
|
59
|
-
"react-dom": "^
|
|
61
|
+
"react-dom": "^18.2.0",
|
|
60
62
|
"react-styleguidist": "^11.2.0",
|
|
61
63
|
"selenium-webdriver": "^4.1.2",
|
|
62
|
-
"ssh2-sftp-client": "^
|
|
64
|
+
"ssh2-sftp-client": "^9.0.1",
|
|
63
65
|
"style-loader": "^3.3.1",
|
|
64
66
|
"unit.js": "^2.1.1",
|
|
65
|
-
"webpack": "^5.
|
|
66
|
-
"webpack-cli": "^4.
|
|
67
|
+
"webpack": "^5.73.0",
|
|
68
|
+
"webpack-cli": "^4.10.0"
|
|
67
69
|
},
|
|
68
70
|
"scripts": {
|
|
69
|
-
"lint": "eslint doc_src
|
|
70
|
-
"preunit": "webpack --config scripts/
|
|
71
|
+
"lint": "eslint doc_src graphic_test_src src test",
|
|
72
|
+
"preunit": "webpack --config scripts/test-headless.webpack.config.js && webpack --config scripts/test-graphic.webpack.config.js && node scripts/clean-graphic-output.js",
|
|
71
73
|
"unit": "nyc mocha --bail --sort",
|
|
72
74
|
"test": "npm run lint && npm run unit",
|
|
73
75
|
"publish_coverage": "nyc report --reporter=text-lcov | coveralls",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
+
"test_env:start": "docker-compose -p kokopu-react-test-env -f scripts/docker-compose.yml up -d",
|
|
77
|
+
"test_env:stop": "docker-compose -p kokopu-react-test-env -f scripts/docker-compose.yml down",
|
|
76
78
|
"build": "make -f scripts/build.mk",
|
|
77
79
|
"clean": "make -f scripts/build.mk clean",
|
|
78
80
|
"start": "styleguidist server --open --config scripts/styleguide.config.js",
|
|
@@ -5,10 +5,10 @@ services:
|
|
|
5
5
|
image: selenium/standalone-firefox:4.1.4-20220427
|
|
6
6
|
shm_size: '2gb'
|
|
7
7
|
ports:
|
|
8
|
-
- 4444:4444 #
|
|
9
|
-
- 7900:7900 #
|
|
8
|
+
- 4444:4444 # http://localhost:4444 (driver)
|
|
9
|
+
- 7900:7900 # http://localhost:7900 (VNC, pass: secret)
|
|
10
10
|
volumes:
|
|
11
11
|
- type: bind
|
|
12
|
-
source:
|
|
12
|
+
source: ..
|
|
13
13
|
target: /app
|
|
14
14
|
read_only: true
|
|
@@ -25,11 +25,11 @@ const path = require('path');
|
|
|
25
25
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
26
26
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
27
27
|
|
|
28
|
-
// List all the JS files in /
|
|
29
|
-
var items = fs.readdirSync('./
|
|
28
|
+
// List all the JS files in /graphic_test_src, each of them corresponding to a entry.
|
|
29
|
+
var items = fs.readdirSync('./graphic_test_src').filter(filename => path.extname(filename) === '.js').map(filename => path.basename(filename, '.js')).sort();
|
|
30
30
|
var entries = {};
|
|
31
31
|
items.forEach(item => {
|
|
32
|
-
entries[item] = `./
|
|
32
|
+
entries[item] = `./graphic_test_src/${item}`;
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
// Define the outputs.
|
|
@@ -40,16 +40,17 @@ var plugins = items.map(item => new HtmlWebpackPlugin({
|
|
|
40
40
|
}));
|
|
41
41
|
plugins.push(new CopyWebpackPlugin({
|
|
42
42
|
patterns: [
|
|
43
|
-
{ from: './
|
|
44
|
-
{ from: './
|
|
43
|
+
{ from: './graphic_test_src/common/heartbeat.txt', to: 'heartbeat.txt' },
|
|
44
|
+
{ from: './graphic_test_src/common/smiley.png', to: 'smiley.png' },
|
|
45
45
|
],
|
|
46
46
|
}));
|
|
47
47
|
|
|
48
48
|
module.exports = {
|
|
49
49
|
mode: 'development',
|
|
50
|
+
devtool: 'inline-source-map',
|
|
50
51
|
entry: entries,
|
|
51
52
|
output: {
|
|
52
|
-
path: path.resolve(__dirname, '
|
|
53
|
+
path: path.resolve(__dirname, '../build/test_graphic'),
|
|
53
54
|
hashFunction: "xxhash64", // FIXME The default hash function used by Webpack has been removed from OpenSSL.
|
|
54
55
|
},
|
|
55
56
|
plugins: plugins,
|
|
@@ -24,8 +24,9 @@ const path = require('path');
|
|
|
24
24
|
|
|
25
25
|
module.exports = {
|
|
26
26
|
mode: 'development',
|
|
27
|
+
devtool: 'inline-source-map',
|
|
27
28
|
entry: {
|
|
28
|
-
index: './src/index
|
|
29
|
+
index: './src/index',
|
|
29
30
|
},
|
|
30
31
|
output: {
|
|
31
32
|
path: path.resolve(__dirname, '../build/test_headless'),
|
package/src/Chessboard.js
CHANGED
|
@@ -123,10 +123,10 @@ export default class Chessboard extends React.Component {
|
|
|
123
123
|
return (
|
|
124
124
|
<svg className="kokopu-chessboard" viewBox={viewBox} width={xmax - xmin} height={ymax - ymin}>
|
|
125
125
|
<defs>
|
|
126
|
+
{this.renderArrowTip(colorset, 'b')}
|
|
126
127
|
{this.renderArrowTip(colorset, 'g')}
|
|
127
128
|
{this.renderArrowTip(colorset, 'r')}
|
|
128
129
|
{this.renderArrowTip(colorset, 'y')}
|
|
129
|
-
{this.renderArrowTip(colorset, 'highlight')}
|
|
130
130
|
</defs>
|
|
131
131
|
{squares}
|
|
132
132
|
{rankCoordinates}
|
|
@@ -213,7 +213,8 @@ export default class Chessboard extends React.Component {
|
|
|
213
213
|
let { x, y } = this.getSquareCoordinates(squareSize, this.state.hoveredSquare);
|
|
214
214
|
let thickness = Math.max(2, Math.round(HOVER_MARKER_THICKNESS_FACTOR * squareSize));
|
|
215
215
|
let size = squareSize - thickness;
|
|
216
|
-
|
|
216
|
+
let color = this.props.interactionMode === 'editArrows' ? this.props.editedArrowColor : this.props.moveArrowColor;
|
|
217
|
+
return <rect className="kokopu-hoveredSquare" x={x + thickness/2} y={y + thickness/2} width={size} height={size} stroke={colorset['c' + color]} strokeWidth={thickness} />;
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
renderPiece(position, squareSize, pieceset, sq) {
|
|
@@ -272,7 +273,7 @@ export default class Chessboard extends React.Component {
|
|
|
272
273
|
return (
|
|
273
274
|
<line
|
|
274
275
|
className="kokopu-annotation kokopu-arrow kokopu-arrowDraggable kokopu-dragging" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
|
|
275
|
-
stroke={colorset[this.props.editedArrowColor]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
276
|
+
stroke={colorset['c' + this.props.editedArrowColor]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
276
277
|
/>
|
|
277
278
|
);
|
|
278
279
|
}
|
|
@@ -335,7 +336,7 @@ export default class Chessboard extends React.Component {
|
|
|
335
336
|
let result = [];
|
|
336
337
|
Object.entries(sqm).forEach(([ sq, color ]) => {
|
|
337
338
|
let { x, y } = this.getSquareCoordinates(squareSize, sq);
|
|
338
|
-
result.push(<rect key={'sqm-' + sq} className="kokopu-annotation" x={x} y={y} width={squareSize} height={squareSize} fill={colorset[color]} />);
|
|
339
|
+
result.push(<rect key={'sqm-' + sq} className="kokopu-annotation" x={x} y={y} width={squareSize} height={squareSize} fill={colorset['c' + color]} />);
|
|
339
340
|
});
|
|
340
341
|
return result;
|
|
341
342
|
}
|
|
@@ -348,7 +349,7 @@ export default class Chessboard extends React.Component {
|
|
|
348
349
|
y += squareSize / 2;
|
|
349
350
|
result.push(
|
|
350
351
|
<g key={'txtm-' + sq} className="kokopu-annotation">
|
|
351
|
-
<TextSymbol x={x} y={y} size={squareSize} symbol={value.symbol} color={colorset[value.color]} />
|
|
352
|
+
<TextSymbol x={x} y={y} size={squareSize} symbol={value.symbol} color={colorset['c' + value.color]} />
|
|
352
353
|
</g>
|
|
353
354
|
);
|
|
354
355
|
});
|
|
@@ -376,7 +377,7 @@ export default class Chessboard extends React.Component {
|
|
|
376
377
|
result.push(
|
|
377
378
|
<line
|
|
378
379
|
key={'arm-' + vect} className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={xTo} y2={yTo}
|
|
379
|
-
stroke={colorset[color]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
380
|
+
stroke={colorset['c' + color]} strokeWidth={strokeWidth} markerEnd={`url(#${arrowTipId})`}
|
|
380
381
|
/>
|
|
381
382
|
);
|
|
382
383
|
});
|
|
@@ -397,16 +398,17 @@ export default class Chessboard extends React.Component {
|
|
|
397
398
|
yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
|
|
398
399
|
let x = xTo * alpha + xFrom * (1 - alpha);
|
|
399
400
|
let y = yTo * alpha + yFrom * (1 - alpha);
|
|
401
|
+
let color = this.props.moveArrowColor;
|
|
400
402
|
return (
|
|
401
403
|
<line
|
|
402
|
-
className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={x} y2={y} stroke={colorset['
|
|
403
|
-
strokeWidth={squareSize * STROKE_THICKNESS_FACTOR} markerEnd={`url(#${this.getArrowTipId(
|
|
404
|
+
className="kokopu-annotation kokopu-arrow" x1={xFrom} y1={yFrom} x2={x} y2={y} stroke={colorset['c' + color]}
|
|
405
|
+
strokeWidth={squareSize * STROKE_THICKNESS_FACTOR} markerEnd={`url(#${this.getArrowTipId(color)})`}
|
|
404
406
|
/>
|
|
405
407
|
);
|
|
406
408
|
}
|
|
407
409
|
|
|
408
410
|
renderArrowTip(colorset, color) {
|
|
409
|
-
return <ArrowTip id={this.getArrowTipId(color)} color={colorset[color]} />;
|
|
411
|
+
return <ArrowTip id={this.getArrowTipId(color)} color={colorset['c' + color]} />;
|
|
410
412
|
}
|
|
411
413
|
|
|
412
414
|
renderTurnFlag(turn, squareSize, pieceset) {
|
|
@@ -735,7 +737,7 @@ export default class Chessboard extends React.Component {
|
|
|
735
737
|
/**
|
|
736
738
|
* Available colorsets for theming.
|
|
737
739
|
*
|
|
738
|
-
* @returns {Object.<string, {w: string, b: string,
|
|
740
|
+
* @returns {Object.<string, { w: string, b: string, cb: string, cg: string, cr: string, cy: string }>}
|
|
739
741
|
* @public
|
|
740
742
|
*/
|
|
741
743
|
static colorsets() {
|
|
@@ -745,8 +747,8 @@ export default class Chessboard extends React.Component {
|
|
|
745
747
|
/**
|
|
746
748
|
* Available piecesets for theming.
|
|
747
749
|
*
|
|
748
|
-
* @returns {Object.<string, {bb: string, bk: string, bn: string, bp: string, bq: string, br: string, bx: string,
|
|
749
|
-
*
|
|
750
|
+
* @returns {Object.<string, { bb: string, bk: string, bn: string, bp: string, bq: string, br: string, bx: string,
|
|
751
|
+
* wb: string, wk: string, wn: string, wp: string, wq: string, wr: string, wx: string }>}
|
|
750
752
|
* @public
|
|
751
753
|
*/
|
|
752
754
|
static piecesets() {
|
|
@@ -834,6 +836,11 @@ Chessboard.propTypes = {
|
|
|
834
836
|
*/
|
|
835
837
|
moveArrowVisible: PropTypes.bool,
|
|
836
838
|
|
|
839
|
+
/**
|
|
840
|
+
* Color of the move arrow.
|
|
841
|
+
*/
|
|
842
|
+
moveArrowColor: PropTypes.oneOf([ 'b', 'g', 'r', 'y' ]),
|
|
843
|
+
|
|
837
844
|
/**
|
|
838
845
|
* Whether moves are animated or not.
|
|
839
846
|
*/
|
|
@@ -881,7 +888,7 @@ Chessboard.propTypes = {
|
|
|
881
888
|
/**
|
|
882
889
|
* Color of the edited arrow (only used if `interactionMode` is set to `'editArrows'`).
|
|
883
890
|
*/
|
|
884
|
-
editedArrowColor: PropTypes.oneOf([ 'g', 'r', 'y' ]),
|
|
891
|
+
editedArrowColor: PropTypes.oneOf([ 'b', 'g', 'r', 'y' ]),
|
|
885
892
|
|
|
886
893
|
/**
|
|
887
894
|
* Callback invoked when a piece is moved through drag&drop (only if `interactionMode` is set to `'movePieces'`).
|
|
@@ -921,6 +928,7 @@ Chessboard.defaultProps = {
|
|
|
921
928
|
squareSize: 40,
|
|
922
929
|
coordinateVisible: true,
|
|
923
930
|
moveArrowVisible: true,
|
|
931
|
+
moveArrowColor: 'b',
|
|
924
932
|
animated: false,
|
|
925
933
|
colorset: 'original',
|
|
926
934
|
pieceset: 'cburnett',
|
package/src/impl/colorsets.js
CHANGED
|
@@ -25,42 +25,42 @@ export default {
|
|
|
25
25
|
original: {
|
|
26
26
|
b: '#b5876b',
|
|
27
27
|
w: '#f0dec7',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
cb: '#04f',
|
|
29
|
+
cg: '#0e0',
|
|
30
|
+
cr: '#d00',
|
|
31
|
+
cy: '#db0',
|
|
32
32
|
},
|
|
33
33
|
gray: {
|
|
34
34
|
b: '#bbbbbb',
|
|
35
35
|
w: '#f8f8f8',
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
cb: '#04f',
|
|
37
|
+
cg: '#0a0',
|
|
38
|
+
cr: '#d00',
|
|
39
|
+
cy: '#a90',
|
|
40
40
|
},
|
|
41
41
|
scid: {
|
|
42
42
|
b: '#7389b6',
|
|
43
43
|
w: '#f3f3f3',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
cb: '#04f',
|
|
45
|
+
cg: '#0e0',
|
|
46
|
+
cr: '#d00',
|
|
47
|
+
cy: '#db0',
|
|
48
48
|
},
|
|
49
49
|
wikipedia: {
|
|
50
50
|
b: '#d18b47',
|
|
51
51
|
w: '#ffce9e',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
cb: '#04f',
|
|
53
|
+
cg: '#0e0',
|
|
54
|
+
cr: '#d00',
|
|
55
|
+
cy: '#db0',
|
|
56
56
|
},
|
|
57
57
|
xboard: {
|
|
58
58
|
b: '#77a26d',
|
|
59
59
|
w: '#c8c365',
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
cb: '#04f',
|
|
61
|
+
cg: '#0f0',
|
|
62
|
+
cr: '#d00',
|
|
63
|
+
cy: '#ff0',
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
/*
|
|
@@ -70,50 +70,50 @@ export default {
|
|
|
70
70
|
coral: {
|
|
71
71
|
b: 'rgb(112,162,163)',
|
|
72
72
|
w: 'rgb(177,228,185)',
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
cb: '#04f',
|
|
74
|
+
cg: '#080',
|
|
75
|
+
cr: '#d00',
|
|
76
|
+
cy: '#ff0',
|
|
77
77
|
},
|
|
78
78
|
dusk: {
|
|
79
79
|
b: 'rgb(112,102,119)',
|
|
80
80
|
w: 'rgb(204,183,174)',
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
cb: '#04f',
|
|
82
|
+
cg: '#3f3',
|
|
83
|
+
cr: '#f20',
|
|
84
|
+
cy: '#ff0',
|
|
85
85
|
},
|
|
86
86
|
emerald: {
|
|
87
87
|
b: 'rgb(111,143,114)',
|
|
88
88
|
w: 'rgb(173,189,143)',
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
cb: '#04f',
|
|
90
|
+
cg: '#6f6',
|
|
91
|
+
cr: '#d00',
|
|
92
|
+
cy: '#ff0',
|
|
93
93
|
},
|
|
94
94
|
marine: {
|
|
95
95
|
b: 'rgb(111,115,210)',
|
|
96
96
|
w: 'rgb(157,172,255)',
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
cb: '#04f',
|
|
98
|
+
cg: '#6f6',
|
|
99
|
+
cr: '#f50',
|
|
100
|
+
cy: '#ff0',
|
|
101
101
|
},
|
|
102
102
|
sandcastle: {
|
|
103
103
|
b: 'rgb(184,139,74)',
|
|
104
104
|
w: 'rgb(227,193,111)',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
cb: '#04f',
|
|
106
|
+
cg: '#0c3',
|
|
107
|
+
cr: '#d02',
|
|
108
|
+
cy: '#ff0',
|
|
109
109
|
},
|
|
110
110
|
wheat: {
|
|
111
111
|
b: 'rgb(187,190,100)',
|
|
112
112
|
w: 'rgb(234,240,206)',
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
cb: '#04f',
|
|
114
|
+
cg: '#0c3',
|
|
115
|
+
cr: '#d00',
|
|
116
|
+
cy: '#ff3',
|
|
117
117
|
},
|
|
118
118
|
|
|
119
119
|
};
|
package/src/impl/util.js
CHANGED
package/src/markers.js
CHANGED
|
@@ -56,8 +56,8 @@ export function flattenTextMarkers(markers) {
|
|
|
56
56
|
/**
|
|
57
57
|
* Transform a set of arrow markers defined as a "squareFromSquareTo -> color" struct into a comma-separated string.
|
|
58
58
|
*
|
|
59
|
-
* @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: '
|
|
60
|
-
* @returns {string} For example: `'Ge2e4,Rg8f6,
|
|
59
|
+
* @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
|
|
60
|
+
* @returns {string} For example: `'Ge2e4,Rg8f6,Bg8h6'`
|
|
61
61
|
*/
|
|
62
62
|
export function flattenArrowMarkers(markers) {
|
|
63
63
|
return Object.entries(markers)
|
|
@@ -83,7 +83,7 @@ function parseMarkers(markers, tokenParser) {
|
|
|
83
83
|
*/
|
|
84
84
|
export function parseSquareMarkers(markers) {
|
|
85
85
|
return parseMarkers(markers, token => {
|
|
86
|
-
return /^([
|
|
86
|
+
return /^([BGRY])([a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -96,7 +96,7 @@ export function parseSquareMarkers(markers) {
|
|
|
96
96
|
*/
|
|
97
97
|
export function parseTextMarkers(markers) {
|
|
98
98
|
return parseMarkers(markers, token => {
|
|
99
|
-
return /^([
|
|
99
|
+
return /^([BGRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
|
|
100
100
|
{ key: RegExp.$4, value: { symbol: RegExp.$2 || RegExp.$3, color: RegExp.$1.toLowerCase() } } : undefined;
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -105,11 +105,11 @@ export function parseTextMarkers(markers) {
|
|
|
105
105
|
/**
|
|
106
106
|
* Parse a set of arrow markers defined as a comma-separated string into a "squareFromSquareTo -> color" struct.
|
|
107
107
|
*
|
|
108
|
-
* @param {string} markers For example: `'Ge2e4,Rg8f6,
|
|
109
|
-
* @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: '
|
|
108
|
+
* @param {string} markers For example: `'Ge2e4,Rg8f6,Bg8h6'`
|
|
109
|
+
* @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
|
|
110
110
|
*/
|
|
111
111
|
export function parseArrowMarkers(markers) {
|
|
112
112
|
return parseMarkers(markers, token => {
|
|
113
|
-
return /^([
|
|
113
|
+
return /^([BGRY])([a-h][1-8][a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
|
|
114
114
|
});
|
|
115
115
|
}
|
package/test/1_markers.js
CHANGED
|
@@ -28,7 +28,7 @@ describe('Flatten square markers', () => {
|
|
|
28
28
|
|
|
29
29
|
it('Re4', () => { test.value(flattenSquareMarkers({ e4: 'r' })).is('Re4'); });
|
|
30
30
|
it('Gd3,Yh8', () => { test.value(flattenSquareMarkers({ h8: 'y', d3: 'g' })).is('Gd3,Yh8'); });
|
|
31
|
-
it('Ga1,Yc5,Rd2,
|
|
31
|
+
it('Ga1,Yc5,Rd2,Bh7,Yh8', () => { test.value(flattenSquareMarkers({ c5: 'y', h8: 'y', a1: 'g', h7: 'b', d2: 'r' })).is('Ga1,Yc5,Rd2,Bh7,Yh8'); });
|
|
32
32
|
it('<empty>', () => { test.value(flattenSquareMarkers({})).is(''); });
|
|
33
33
|
|
|
34
34
|
it('Wrong square', () => { test.value(flattenSquareMarkers({ e1: 'r', k9: 'g', whatever: 'y' })).is('Re1'); });
|
|
@@ -40,13 +40,13 @@ describe('Parse square markers', () => {
|
|
|
40
40
|
|
|
41
41
|
it('Re4', () => { test.value(parseSquareMarkers('Re4')).is({ e4: 'r' }); });
|
|
42
42
|
it('Gd3,Yh8', () => { test.value(parseSquareMarkers('Gd3,Yh8')).is({ h8: 'y', d3: 'g' }); });
|
|
43
|
-
it('Ga1,Yc5,Rd2,
|
|
43
|
+
it('Ga1,Yc5,Rd2,Bh7,Yh8', () => { test.value(parseSquareMarkers(' Ga1, Yh8,Yc5 ,Rd2, Bh7 ')).is({ c5: 'y', h8: 'y', a1: 'g', h7: 'b', d2: 'r' }); });
|
|
44
44
|
it('<empty>', () => { test.value(parseSquareMarkers('')).is({}); });
|
|
45
45
|
it('<blank>', () => { test.value(parseSquareMarkers(' ')).is({}); });
|
|
46
46
|
|
|
47
47
|
it('Wrong square', () => { test.value(parseSquareMarkers('Rg9,Ye1')).is({ e1: 'y' }); });
|
|
48
48
|
it('Duplicated square', () => { test.value(parseSquareMarkers('Ra3,Ya3')).is({ a3: 'y' }); });
|
|
49
|
-
it('Wrong color', () => { test.value(parseSquareMarkers('Ga6,
|
|
49
|
+
it('Wrong color', () => { test.value(parseSquareMarkers('Ga6,Cg5')).is({ a6: 'g' }); });
|
|
50
50
|
it('Wrong format', () => { test.value(parseSquareMarkers('Something Ra2 invalid, Ye4, G g3')).is({ e4: 'y' }); });
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -58,13 +58,13 @@ describe('Flatten text markers', () => {
|
|
|
58
58
|
h8: { symbol: '1', color: 'y' },
|
|
59
59
|
d3: { symbol: 'z', color: 'g' },
|
|
60
60
|
})).is('Gzd3,Y1h8'); });
|
|
61
|
-
it('G2a1,YMc5,RLd2,Rxh7,
|
|
61
|
+
it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => { test.value(flattenTextMarkers({
|
|
62
62
|
c5: { symbol: 'M', color: 'y' },
|
|
63
|
-
h8: { symbol: 'w', color: '
|
|
63
|
+
h8: { symbol: 'w', color: 'b' },
|
|
64
64
|
a1: { symbol: '2', color: 'g' },
|
|
65
65
|
h7: { symbol: 'x', color: 'r' },
|
|
66
66
|
d2: { symbol: 'L', color: 'r' },
|
|
67
|
-
})).is('G2a1,YMc5,RLd2,Rxh7,
|
|
67
|
+
})).is('G2a1,YMc5,RLd2,Rxh7,Bwh8'); });
|
|
68
68
|
it('Multi-character symbols', () => { test.value(flattenTextMarkers({
|
|
69
69
|
a1: { symbol: 'A', color: 'y' },
|
|
70
70
|
a7: { symbol: 'plus', color: 'g' },
|
|
@@ -104,9 +104,9 @@ describe('Parse text markers', () => {
|
|
|
104
104
|
h8: { symbol: '1', color: 'y' },
|
|
105
105
|
d3: { symbol: 'z', color: 'g' },
|
|
106
106
|
}); });
|
|
107
|
-
it('G2a1,YMc5,RLd2,Rxh7,
|
|
107
|
+
it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => { test.value(parseTextMarkers(' G2a1, Rxh7 ,YMc5 ,RLd2,Bwh8 ')).is({
|
|
108
108
|
c5: { symbol: 'M', color: 'y' },
|
|
109
|
-
h8: { symbol: 'w', color: '
|
|
109
|
+
h8: { symbol: 'w', color: 'b' },
|
|
110
110
|
a1: { symbol: '2', color: 'g' },
|
|
111
111
|
h7: { symbol: 'x', color: 'r' },
|
|
112
112
|
d2: { symbol: 'L', color: 'r' },
|
|
@@ -123,7 +123,7 @@ describe('Parse text markers', () => {
|
|
|
123
123
|
|
|
124
124
|
it('Wrong square', () => { test.value(parseTextMarkers('RHg9,Yxe1')).is({ e1: { symbol: 'x', color: 'y' } }); });
|
|
125
125
|
it('Duplicated square', () => { test.value(parseTextMarkers('Rka3,Gba3')).is({ a3: { symbol: 'b', color: 'g' } }); });
|
|
126
|
-
it('Wrong color', () => { test.value(parseTextMarkers('G3a6,
|
|
126
|
+
it('Wrong color', () => { test.value(parseTextMarkers('G3a6,CAg5')).is({ a6: { symbol: '3', color: 'g' } }); });
|
|
127
127
|
it('Wrong symbol', () => { test.value(parseTextMarkers('Rb2,RAg5,G.d3,Yabcde7')).is({ g5: { symbol: 'A', color: 'r' } }); });
|
|
128
128
|
it('Wrong multi-character symbol', () => { test.value(parseTextMarkers('RZb2,Y(whatever)e4')).is({ b2: { symbol: 'Z', color: 'r' } }); });
|
|
129
129
|
it('Wrong format', () => { test.value(parseTextMarkers('Something RHa2 invalid, Yqe4, G g3')).is({ e4: { symbol: 'q', color: 'y' } }); });
|
|
@@ -134,8 +134,8 @@ describe('Flatten arrow markers', () => {
|
|
|
134
134
|
|
|
135
135
|
it('Re4d6', () => { test.value(flattenArrowMarkers({ e4d6: 'r' })).is('Re4d6'); });
|
|
136
136
|
it('Gd3b4,Yh8h7', () => { test.value(flattenArrowMarkers({ h8h7: 'y', d3b4: 'g' })).is('Gd3b4,Yh8h7'); });
|
|
137
|
-
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,
|
|
138
|
-
.is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,
|
|
137
|
+
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => { test.value(flattenArrowMarkers({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' }))
|
|
138
|
+
.is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5'); });
|
|
139
139
|
it('<empty>', () => { test.value(flattenArrowMarkers({})).is(''); });
|
|
140
140
|
|
|
141
141
|
it('Wrong vector', () => { test.value(flattenArrowMarkers({ e1c2: 'r', a1b9: 'g', c0d2: 'r', i3d4: 'r', f2k3: 'g', whatever: 'y' })).is('Re1c2'); });
|
|
@@ -147,13 +147,13 @@ describe('Parse arrow markers', () => {
|
|
|
147
147
|
|
|
148
148
|
it('Re4d6', () => { test.value(parseArrowMarkers('Re4d6')).is({ e4d6: 'r' }); });
|
|
149
149
|
it('Gd3b4,Yh8h7', () => { test.value(parseArrowMarkers('Gd3b4,Yh8h7')).is({ h8h7: 'y', d3b4: 'g' }); });
|
|
150
|
-
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,
|
|
151
|
-
.is({ c5a1: 'y', h8c5: '
|
|
150
|
+
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => { test.value(parseArrowMarkers(' Bh8c5,Ga1h8 , Yc5a1 , Rd2d2,Rh7h8 '))
|
|
151
|
+
.is({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' }); });
|
|
152
152
|
it('<empty>', () => { test.value(parseArrowMarkers('')).is({}); });
|
|
153
153
|
it('<blank>', () => { test.value(parseArrowMarkers(' ')).is({}); });
|
|
154
154
|
|
|
155
155
|
it('Wrong vector', () => { test.value(parseArrowMarkers('Re1c2,Ga1b9,Rc0d2,Ri3d4,Gf2k3')).is({ e1c2: 'r' }); });
|
|
156
156
|
it('Duplicated vector', () => { test.value(parseArrowMarkers('Ya3b4,Ra3b4')).is({ a3b4: 'r' }); });
|
|
157
|
-
it('Wrong color', () => { test.value(parseArrowMarkers('Ga6c5,
|
|
157
|
+
it('Wrong color', () => { test.value(parseArrowMarkers('Ga6c5,Cg5e2')).is({ a6c5: 'g' }); });
|
|
158
158
|
it('Wrong format', () => { test.value(parseArrowMarkers('Something Rb1a2 invalid, Ye4c7, G g3b1')).is({ e4c7: 'y' }); });
|
|
159
159
|
});
|
package/test/common/graphic.js
CHANGED
|
@@ -34,8 +34,8 @@ const coverageDir = rootDir + '/build/.nyc_output';
|
|
|
34
34
|
const UNREACHABLE_TEST_CLIENT_MESSAGE =
|
|
35
35
|
'Cannot reach the dockerized selenium webbrowser used for graphic tests (probably because the test environment is not running).\n' +
|
|
36
36
|
'\n' +
|
|
37
|
-
'Use command `npm run
|
|
38
|
-
'Do not forget to run `npm run
|
|
37
|
+
'Use command `npm run test_env:start` to start the test environment.\n' +
|
|
38
|
+
'Do not forget to run `npm run test_env:stop` when finished.\n';
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|