kokopu-react 1.3.1 → 1.5.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/lib/ArrowMarkerIcon.js +5 -7
  4. package/dist/lib/Chessboard.js +23 -33
  5. package/dist/lib/ErrorBox.js +85 -5
  6. package/dist/lib/Movetext.js +839 -0
  7. package/dist/lib/SquareMarkerIcon.js +1 -1
  8. package/dist/lib/TextMarkerIcon.js +12 -11
  9. package/dist/lib/css/arrow.css +1 -1
  10. package/dist/lib/css/chessboard.css +6 -1
  11. package/dist/lib/css/error_box.css +13 -2
  12. package/dist/lib/css/fonts.css +34 -0
  13. package/dist/lib/css/movetext.css +117 -0
  14. package/dist/lib/css/{label.css → symbol.css} +6 -2
  15. package/dist/lib/fonts/chessalpha.woff +0 -0
  16. package/dist/lib/fonts/chessalpha.woff2 +0 -0
  17. package/dist/lib/i18n.js +17 -2
  18. package/dist/lib/impl/ArrowTip.js +3 -8
  19. package/dist/lib/impl/HtmlSanitizer.js +171 -0
  20. package/dist/lib/impl/TextSymbol.js +98 -0
  21. package/dist/lib/impl/colorsets.js +1 -1
  22. package/dist/lib/impl/piecesets.js +1 -1
  23. package/dist/lib/impl/util.js +6 -6
  24. package/dist/lib/index.js +32 -24
  25. package/dist/lib/markers.js +10 -10
  26. package/doc_src/demo/PageChessboardBase.js +1 -1
  27. package/doc_src/demo/{PageChessboardEdition.js → PageChessboardInteraction.js} +4 -5
  28. package/doc_src/demo/PageChessboardMove.js +1 -1
  29. package/doc_src/demo/PageChessboardSmallScreens.js +1 -1
  30. package/doc_src/demo/PageMovetextBase.js +214 -0
  31. package/doc_src/demo/PageMovetextInteraction.js +155 -0
  32. package/doc_src/demo/demo.css +8 -1
  33. package/doc_src/demo/game-1.pgn +23 -0
  34. package/doc_src/demo/game-2.pgn +22 -0
  35. package/doc_src/demo/game-invalid.pgn +10 -0
  36. package/doc_src/demo/util.js +1 -1
  37. package/doc_src/examples/Movetext.md +15 -0
  38. package/doc_src/home.md +2 -0
  39. package/doc_src/theming/LogoRenderer.js +1 -1
  40. package/doc_src/theming/kokopu-react-favicon.png +0 -0
  41. package/doc_src/theming/theming.css +1 -1
  42. package/graphic_test_app/01_marker_icons.js +6 -4
  43. package/graphic_test_app/02_chessboard_simple.js +1 -1
  44. package/graphic_test_app/03_chessboard_flipped.js +1 -1
  45. package/graphic_test_app/04_chessboard_annotations.js +2 -2
  46. package/graphic_test_app/05_chessboard_move.js +1 -1
  47. package/graphic_test_app/06_chessboard_theme.js +1 -1
  48. package/graphic_test_app/07_chessboard_click_squares.js +1 -1
  49. package/graphic_test_app/08_chessboard_move_pieces.js +1 -1
  50. package/graphic_test_app/09_chessboard_edit_arrows.js +1 -1
  51. package/graphic_test_app/10_chessboard_play_moves.js +1 -1
  52. package/graphic_test_app/11_chessboard_play_promotions.js +1 -1
  53. package/graphic_test_app/12_movetext_simple.js +41 -0
  54. package/graphic_test_app/13_movetext_error.js +38 -0
  55. package/graphic_test_app/14_movetext_html.js +40 -0
  56. package/graphic_test_app/15_movetext_options.js +42 -0
  57. package/graphic_test_app/16_movetext_interaction.js +42 -0
  58. package/graphic_test_app/common/dummy.pgn +8 -0
  59. package/graphic_test_app/common/games.pgn +167 -0
  60. package/graphic_test_app/common/heartbeat.txt +1 -0
  61. package/graphic_test_app/common/test_app.css +20 -4
  62. package/graphic_test_app/common/test_app.js +6 -6
  63. package/package.json +26 -25
  64. package/scripts/test_graphic/clean-graphic-output.js +1 -1
  65. package/scripts/test_graphic/docker-compose.yml +1 -1
  66. package/scripts/test_graphic/webpack-config.js +8 -3
  67. package/scripts/test_headless.webpack-config.js +3 -2
  68. package/src/ArrowMarkerIcon.js +2 -2
  69. package/src/Chessboard.js +11 -11
  70. package/src/ErrorBox.js +80 -1
  71. package/src/Movetext.js +616 -0
  72. package/src/SquareMarkerIcon.js +1 -1
  73. package/src/TextMarkerIcon.js +7 -7
  74. package/src/css/arrow.css +1 -1
  75. package/src/css/chessboard.css +6 -1
  76. package/src/css/error_box.css +13 -2
  77. package/src/css/fonts.css +34 -0
  78. package/src/css/movetext.css +117 -0
  79. package/src/css/{label.css → symbol.css} +6 -2
  80. package/src/fonts/chessalpha.woff +0 -0
  81. package/src/fonts/chessalpha.woff2 +0 -0
  82. package/src/i18n.js +12 -1
  83. package/src/impl/ArrowTip.js +3 -7
  84. package/src/impl/HtmlSanitizer.js +120 -0
  85. package/src/impl/TextSymbol.js +76 -0
  86. package/src/impl/colorsets.js +1 -1
  87. package/src/impl/piecesets.js +1 -1
  88. package/src/impl/util.js +2 -2
  89. package/src/index.js +2 -1
  90. package/src/markers.js +8 -7
  91. package/test/1_markers.js +20 -1
  92. package/test/2_chessboard_util.js +1 -1
  93. package/test/3_marker_icons_graphic.js +2 -2
  94. package/test/4_chessboard_graphic.js +1 -1
  95. package/test/5_chessboard_interaction.js +1 -1
  96. package/test/6_chessboard_play_moves.js +1 -1
  97. package/test/7_movetext_graphic.js +43 -0
  98. package/test/8_movetext_interaction.js +99 -0
  99. package/test/common/graphic.js +2 -2
  100. package/test/references/01_marker_icons/10.png +0 -0
  101. package/test/references/01_marker_icons/9.png +0 -0
  102. package/test/references/04_chessboard_annotations/4.png +0 -0
  103. package/test/references/04_chessboard_annotations/5.png +0 -0
  104. package/test/references/05_chessboard_move/3.png +0 -0
  105. package/test/references/12_movetext_simple/0.png +0 -0
  106. package/test/references/12_movetext_simple/1.png +0 -0
  107. package/test/references/12_movetext_simple/2.png +0 -0
  108. package/test/references/12_movetext_simple/3.png +0 -0
  109. package/test/references/13_movetext_error/0.png +0 -0
  110. package/test/references/13_movetext_error/1.png +0 -0
  111. package/test/references/13_movetext_error/2.png +0 -0
  112. package/test/references/13_movetext_error/3.png +0 -0
  113. package/test/references/14_movetext_html/0.png +0 -0
  114. package/test/references/14_movetext_html/1.png +0 -0
  115. package/test/references/14_movetext_html/2.png +0 -0
  116. package/test/references/15_movetext_options/0.png +0 -0
  117. package/test/references/15_movetext_options/1.png +0 -0
  118. package/test/references/15_movetext_options/2.png +0 -0
  119. package/test/references/15_movetext_options/3.png +0 -0
  120. package/test/references/16_movetext_interaction/0.png +0 -0
  121. package/test/references/16_movetext_interaction/1.png +0 -0
  122. package/test/references/16_movetext_interaction/2.png +0 -0
  123. package/graphic_test_app/common/healthcheck.txt +0 -1
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -0,0 +1,43 @@
1
+ /******************************************************************************
2
+ * *
3
+ * This file is part of Kokopu-React, a JavaScript chess library. *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
+ * *
6
+ * This program is free software: you can redistribute it and/or *
7
+ * modify it under the terms of the GNU Lesser General Public License *
8
+ * as published by the Free Software Foundation, either version 3 of *
9
+ * the License, or (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General *
17
+ * Public License along with this program. If not, see *
18
+ * <http://www.gnu.org/licenses/>. *
19
+ * *
20
+ ******************************************************************************/
21
+
22
+
23
+ const { openBrowser, closeBrowser, itChecksScreenshots } = require('./common/graphic');
24
+
25
+
26
+ describe('Movetext graphic', function() {
27
+
28
+ const browserContext = {};
29
+
30
+ before(async function() {
31
+ await openBrowser(this, browserContext);
32
+ });
33
+
34
+ after(async function() {
35
+ await closeBrowser(browserContext);
36
+ });
37
+
38
+ itChecksScreenshots(browserContext, '12_movetext_simple', [ 'game-0', 'game-1', 'game-2', 'game-3' ]);
39
+ itChecksScreenshots(browserContext, '13_movetext_error', [ 'wrong-game-index', 'pgn-parsing-error-1', 'pgn-parsing-error-2', 'wrong type' ]);
40
+ itChecksScreenshots(browserContext, '14_movetext_html', [ 'html-in-headers', 'html-in-comments', 'filtered-tags-and-attributes' ]);
41
+ itChecksScreenshots(browserContext, '15_movetext_options', [ 'localized-piece-symbols', 'custom-piece-symbols', 'figurine-piece-symbols-and-diagram-options',
42
+ 'hidden-diagrams' ]);
43
+ });
@@ -0,0 +1,99 @@
1
+ /******************************************************************************
2
+ * *
3
+ * This file is part of Kokopu-React, a JavaScript chess library. *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
+ * *
6
+ * This program is free software: you can redistribute it and/or *
7
+ * modify it under the terms of the GNU Lesser General Public License *
8
+ * as published by the Free Software Foundation, either version 3 of *
9
+ * the License, or (at your option) any later version. *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
+ * GNU Lesser General Public License for more details. *
15
+ * *
16
+ * You should have received a copy of the GNU Lesser General *
17
+ * Public License along with this program. If not, see *
18
+ * <http://www.gnu.org/licenses/>. *
19
+ * *
20
+ ******************************************************************************/
21
+
22
+
23
+ const { openBrowser, closeBrowser, itCustom, setSandbox, compareSandbox, takeScreenshot, compareScreenshot } = require('./common/graphic');
24
+ const { By, Key } = require('selenium-webdriver');
25
+
26
+
27
+ describe('Movetext interaction', function() {
28
+
29
+ const browserContext = {};
30
+
31
+ before(async function() {
32
+ await openBrowser(this, browserContext);
33
+ });
34
+
35
+ after(async function() {
36
+ await closeBrowser(browserContext);
37
+ });
38
+
39
+ function itCheckClickMove(itemIndex, label, targets) {
40
+ itCustom(browserContext, '16_movetext_interaction', itemIndex, label, async function(element) {
41
+ let actions = browserContext.driver.actions({ async: true });
42
+ await setSandbox(browserContext, '');
43
+ for (let i = 0; i < targets.length; ++i) {
44
+ let target = targets[i];
45
+ let moveElement = await element.findElement(By.xpath(`.//span[text()='${target.searchedText}']`));
46
+ await actions.move({ origin: moveElement }).click().perform();
47
+ if (i === 0) {
48
+ await takeScreenshot(browserContext, itemIndex, element);
49
+ await compareScreenshot(browserContext, itemIndex);
50
+ }
51
+ await compareSandbox(browserContext, target.expectedText);
52
+ }
53
+ });
54
+ }
55
+
56
+ itCheckClickMove(0, 'click on disabled', [
57
+ { searchedText: 'Nf6', expectedText: '' },
58
+ { searchedText: 'Qc2', expectedText: '' },
59
+ ]);
60
+
61
+ itCheckClickMove(1, 'click on unselected', [
62
+ { searchedText: 'cxd5', expectedText: 'move selected: 5w' },
63
+ ]);
64
+
65
+ itCheckClickMove(2, 'click on with variations 1', [
66
+ { searchedText: 'Bb5', expectedText: 'move selected: undefined' },
67
+ { searchedText: 'Nc6', expectedText: 'move selected: 1b-v0-2b' },
68
+ ]);
69
+
70
+ function itCheckKeyboardActions(itemIndex, label, expectedOnGoFirst, expectedOnGoPrevious, expectedOnGoNext, expectedOnGoLast) {
71
+ itCustom(browserContext, '16_movetext_interaction', itemIndex, label, async function(element) {
72
+ let focusFieldElement = await element.findElement(By.className('kokopu-focusField'));
73
+
74
+ await setSandbox(browserContext, '');
75
+ await focusFieldElement.sendKeys(Key.HOME);
76
+ await compareSandbox(browserContext, expectedOnGoFirst);
77
+
78
+ await setSandbox(browserContext, '');
79
+ await focusFieldElement.sendKeys(Key.ARROW_LEFT);
80
+ await compareSandbox(browserContext, expectedOnGoPrevious);
81
+
82
+ await setSandbox(browserContext, '');
83
+ await focusFieldElement.sendKeys(Key.ARROW_RIGHT);
84
+ await compareSandbox(browserContext, expectedOnGoNext);
85
+
86
+ await setSandbox(browserContext, '');
87
+ await focusFieldElement.sendKeys(Key.END);
88
+ await compareSandbox(browserContext, expectedOnGoLast);
89
+ });
90
+ }
91
+
92
+ itCheckKeyboardActions(1, 'key on unselected', '', '', '', '');
93
+ itCheckKeyboardActions(2, 'key on with variations 1', 'move selected: start', 'move selected: 1b-v0-2b', 'move selected: 1b-v0-3w-v0-3b', 'move selected: 1b-v0-3w-v0-4w');
94
+ itCheckKeyboardActions(3, 'key on with variations 2', 'move selected: start', 'move selected: 1b-v0-2w', 'move selected: 1b-v0-3w', 'move selected: 1b-v0-3w');
95
+ itCheckKeyboardActions(4, 'key on start selected', '', '', 'move selected: 1w', 'move selected: 6b');
96
+ itCheckKeyboardActions(5, 'key on first selected', 'move selected: start', 'move selected: start', 'move selected: 1b', 'move selected: 6b');
97
+ itCheckKeyboardActions(6, 'key on last selected', 'move selected: start', 'move selected: 6w', '', '');
98
+ itCheckKeyboardActions(7, 'key on invalid selection', '', '', '', '');
99
+ });
@@ -1,7 +1,7 @@
1
1
  /******************************************************************************
2
2
  * *
3
3
  * This file is part of Kokopu-React, a JavaScript chess library. *
4
- * Copyright (C) 2021 Yoann Le Montagner <yo35 -at- melix.net> *
4
+ * Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
5
5
  * *
6
6
  * This program is free software: you can redistribute it and/or *
7
7
  * modify it under the terms of the GNU Lesser General Public License *
@@ -49,7 +49,7 @@ exports.openBrowser = async function(mochaContext, browserContext) {
49
49
  // Start the browser and ensure it can fetch something.
50
50
  let capabilities = Capabilities.firefox();
51
51
  let driver = new Builder().usingServer('http://localhost:4444').withCapabilities(capabilities).build();
52
- await driver.get('file:///app/build/test_graphic/healthcheck.txt').catch(reason => {
52
+ await driver.get('file:///app/build/test_graphic/heartbeat.txt').catch(reason => {
53
53
  return Promise.reject(reason.message.includes('ECONNREFUSED') ? new Error(UNREACHABLE_TEST_CLIENT_MESSAGE) : reason);
54
54
  });
55
55
 
@@ -1 +0,0 @@
1
- I'm healthy...