kokopu-react 1.11.0 → 2.0.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/.eslintrc.yml +84 -0
- package/.nycrc.yml +0 -1
- package/README.md +1 -1
- package/{src/css/chessboard.css → dist/lib/chessboard/Chessboard.css} +2 -2
- package/dist/lib/chessboard/Chessboard.d.ts +171 -0
- package/dist/lib/chessboard/Chessboard.js +365 -0
- package/dist/lib/chessboard/Chessboard.js.map +1 -0
- package/dist/lib/chessboard/ChessboardImpl.d.ts +119 -0
- package/dist/lib/chessboard/ChessboardImpl.js +471 -0
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -0
- package/dist/lib/chessboard/Draggable.d.ts +62 -0
- package/dist/lib/chessboard/Draggable.js +157 -0
- package/dist/lib/chessboard/Draggable.js.map +1 -0
- package/dist/lib/chessboard/Motion.d.ts +28 -0
- package/dist/lib/chessboard/Motion.js +74 -0
- package/dist/lib/chessboard/Motion.js.map +1 -0
- package/dist/lib/chessboard/colorsets.d.ts +5 -0
- package/dist/lib/{impl → chessboard}/colorsets.js +43 -47
- package/dist/lib/chessboard/colorsets.js.map +1 -0
- package/dist/lib/chessboard/piecesets.d.ts +5 -0
- package/dist/lib/chessboard/piecesets.js +214 -0
- package/dist/lib/chessboard/piecesets.js.map +1 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-bx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wr.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/cburnett-wx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-bx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wr.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/celtic-wx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-spatial-bx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-spatial-wx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/eyes-wr.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-bx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wr.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/fantasy-wx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-bx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wr.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/skulls-wx.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-bb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-bk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-bn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-bp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-bq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-br.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wb.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wk.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wn.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wp.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wq.png +0 -0
- package/dist/lib/{sprites → chessboard/sprites}/spatial-wr.png +0 -0
- package/dist/lib/{css/error_box.css → errorbox/ErrorBox.css} +2 -2
- package/dist/lib/errorbox/ErrorBox.d.ts +28 -0
- package/dist/lib/errorbox/ErrorBox.js +84 -0
- package/dist/lib/errorbox/ErrorBox.js.map +1 -0
- package/dist/lib/exception.d.ts +18 -0
- package/dist/lib/exception.js +40 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/i18n.d.ts +18 -0
- package/dist/lib/i18n.js +20 -33
- package/dist/lib/i18n.js.map +1 -0
- package/{src/css/symbol.css → dist/lib/icons/AnnotationSymbolShape.css} +2 -2
- package/dist/lib/icons/AnnotationSymbolShape.d.ts +30 -0
- package/dist/lib/{impl/ArrowTip.js → icons/AnnotationSymbolShape.js} +21 -35
- package/dist/lib/icons/AnnotationSymbolShape.js.map +1 -0
- package/dist/lib/icons/ArrowMarkerIcon.d.ts +20 -0
- package/dist/lib/icons/ArrowMarkerIcon.js +53 -0
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -0
- package/dist/lib/icons/ArrowTip.d.ts +16 -0
- package/dist/lib/icons/ArrowTip.js +29 -0
- package/dist/lib/icons/ArrowTip.js.map +1 -0
- package/dist/lib/icons/SquareMarkerIcon.d.ts +18 -0
- package/{src/i18n.js → dist/lib/icons/SquareMarkerIcon.js} +24 -23
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -0
- package/dist/lib/icons/TextMarkerIcon.d.ts +23 -0
- package/dist/lib/icons/TextMarkerIcon.js +45 -0
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -0
- package/{src/css → dist/lib/icons}/arrow.css +2 -2
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +31 -105
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/{css/movetext.css → movetext/Movetext.css} +2 -2
- package/dist/lib/movetext/Movetext.d.ts +136 -0
- package/dist/lib/movetext/Movetext.js +167 -0
- package/dist/lib/movetext/Movetext.js.map +1 -0
- package/dist/lib/movetext/MovetextImpl.d.ts +85 -0
- package/dist/lib/movetext/MovetextImpl.js +411 -0
- package/dist/lib/movetext/MovetextImpl.js.map +1 -0
- package/dist/lib/{fonts → movetext/fonts}/chessalpha.woff +0 -0
- package/dist/lib/{fonts → movetext/fonts}/chessalpha.woff2 +0 -0
- package/dist/lib/{css → movetext}/fonts.css +4 -4
- package/dist/lib/movetext/htmlFilter.d.ts +7 -0
- package/dist/lib/movetext/htmlFilter.js +169 -0
- package/dist/lib/movetext/htmlFilter.js.map +1 -0
- package/dist/lib/movetext/moveFormatter.d.ts +20 -0
- package/dist/lib/movetext/moveFormatter.js +93 -0
- package/dist/lib/movetext/moveFormatter.js.map +1 -0
- package/dist/lib/sanitization.d.ts +6 -0
- package/dist/lib/sanitization.js +39 -0
- package/dist/lib/sanitization.js.map +1 -0
- package/dist/lib/types.d.ts +151 -0
- package/dist/lib/types.js +162 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/util.d.ts +2 -0
- package/dist/lib/util.js +36 -0
- package/dist/lib/util.js.map +1 -0
- package/doc_src/demo/{PageChessboardBase.js → PageChessboardBase.tsx} +30 -24
- package/doc_src/demo/{PageChessboardInteraction.js → PageChessboardInteraction.tsx} +95 -66
- package/doc_src/demo/{PageChessboardMove.js → PageChessboardMove.tsx} +66 -54
- package/doc_src/demo/{PageChessboardSmallScreens.js → PageChessboardSmallScreens.tsx} +23 -14
- package/doc_src/demo/{PageMovetextBase.js → PageMovetextBase.tsx} +62 -49
- package/doc_src/demo/{PageMovetextInteraction.js → PageMovetextInteraction.tsx} +58 -43
- package/doc_src/demo/decs.d.ts +31 -0
- package/doc_src/demo/demo.css +2 -2
- package/doc_src/demo/{util.js → util.ts} +3 -3
- package/doc_src/migrate_to_2.md +26 -0
- package/doc_src/theming/LogoRenderer.js +5 -5
- package/doc_src/theming/theming.css +8 -2
- package/package.json +31 -24
- package/scripts/docker-compose.yml +1 -1
- package/scripts/test-graphic.tsconfig.json +7 -0
- package/scripts/test-graphic.webpack.config.js +33 -17
- package/scripts/test-headless.webpack.config.js +6 -10
- package/{dist/lib/css/chessboard.css → src/chessboard/Chessboard.css} +2 -2
- package/src/chessboard/Chessboard.tsx +575 -0
- package/src/chessboard/ChessboardImpl.tsx +632 -0
- package/src/chessboard/Draggable.tsx +252 -0
- package/src/{impl/Motion.js → chessboard/Motion.tsx} +37 -27
- package/src/chessboard/colorsets.ts +134 -0
- package/src/chessboard/piecesets.ts +229 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-bx.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wr.png +0 -0
- package/src/{sprites → chessboard/sprites}/cburnett-wx.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-bx.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wr.png +0 -0
- package/src/{sprites → chessboard/sprites}/celtic-wx.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-spatial-bx.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-spatial-wx.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/eyes-wr.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-bx.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wr.png +0 -0
- package/src/{sprites → chessboard/sprites}/fantasy-wx.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-bx.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wr.png +0 -0
- package/src/{sprites → chessboard/sprites}/skulls-wx.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-bb.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-bk.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-bn.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-bp.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-bq.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-br.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wb.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wk.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wn.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wp.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wq.png +0 -0
- package/src/{sprites → chessboard/sprites}/spatial-wr.png +0 -0
- package/src/decs.d.ts +26 -0
- package/src/{css/error_box.css → errorbox/ErrorBox.css} +2 -2
- package/src/errorbox/ErrorBox.tsx +129 -0
- package/src/exception.ts +51 -0
- package/src/i18n.ts +43 -0
- package/{dist/lib/css/symbol.css → src/icons/AnnotationSymbolShape.css} +2 -2
- package/src/{impl/TextSymbol.js → icons/AnnotationSymbolShape.tsx} +32 -30
- package/src/{ArrowMarkerIcon.js → icons/ArrowMarkerIcon.tsx} +39 -36
- package/src/{impl/ArrowTip.js → icons/ArrowTip.tsx} +20 -20
- package/src/{SquareMarkerIcon.js → icons/SquareMarkerIcon.tsx} +35 -28
- package/src/{TextMarkerIcon.js → icons/TextMarkerIcon.tsx} +40 -32
- package/{dist/lib/css → src/icons}/arrow.css +2 -2
- package/src/index.ts +38 -0
- package/src/{css/movetext.css → movetext/Movetext.css} +2 -2
- package/src/movetext/Movetext.tsx +278 -0
- package/src/movetext/MovetextImpl.tsx +493 -0
- package/src/{fonts → movetext/fonts}/chessalpha.woff +0 -0
- package/src/{fonts → movetext/fonts}/chessalpha.woff2 +0 -0
- package/src/{css → movetext}/fonts.css +4 -4
- package/src/movetext/htmlFilter.tsx +188 -0
- package/src/{formatmove.js → movetext/moveFormatter.tsx} +39 -26
- package/src/sanitization.ts +51 -0
- package/src/types.ts +311 -0
- package/src/util.ts +39 -0
- package/test/.eslintrc.yml +3 -3
- package/test/{1_markers.js → 01_types.js} +89 -4
- package/test/{2_chessboard_util.js → 02_chessboard_util.js} +16 -7
- package/test/{3_marker_icons_graphic.js → 03_error_box_graphic.js} +20 -14
- package/test/04_marker_icons_graphic.js +49 -0
- package/test/05_chessboard_graphic.js +92 -0
- package/test/06_chessboard_animation.js +71 -0
- package/test/07_chessboard_interaction.js +130 -0
- package/test/08_chessboard_play_moves.js +98 -0
- package/test/{7_movetext_graphic.js → 09_movetext_graphic.js} +32 -16
- package/test/{8_movetext_interaction.js → 10_movetext_interaction.js} +18 -23
- package/test/common/graphic.js +67 -33
- package/test/graphic_references/03_error_box_graphic/base/cut_beginning_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_end_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_on_line_breaks.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/error_index_not_integer.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/full.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/minimal.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/negative_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/single_character_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/too_large_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/localization/default.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/colorized_arrow.png +0 -0
- package/test/{references/01_marker_icons/1.png → graphic_references/04_marker_icons_graphic/base/colorized_square.png} +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/colorized_symbol.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/colorized_text.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/default_arrow.png +0 -0
- package/test/{references/01_marker_icons/0.png → graphic_references/04_marker_icons_graphic/base/default_square.png} +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/default_text.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/invalid_arrow_size.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/invalid_square_size.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/invalid_symbol.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/invalid_text_size.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/wrapped_arrow.png +0 -0
- package/test/{references/01_marker_icons/2.png → graphic_references/04_marker_icons_graphic/base/wrapped_square.png} +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/wrapped_symbol.png +0 -0
- package/test/graphic_references/04_marker_icons_graphic/base/wrapped_text.png +0 -0
- package/test/{references/04_chessboard_annotations/4.png → graphic_references/05_chessboard_graphic/annotations/overlap.png} +0 -0
- package/test/{references/04_chessboard_annotations/5.png → graphic_references/05_chessboard_graphic/annotations/overlap_and_flip.png} +0 -0
- package/test/{references/04_chessboard_annotations/0.png → graphic_references/05_chessboard_graphic/annotations/with_coordinates.png} +0 -0
- package/test/{references/04_chessboard_annotations/1.png → graphic_references/05_chessboard_graphic/annotations/with_coordinates_and_flip.png} +0 -0
- package/test/{references/04_chessboard_annotations/2.png → graphic_references/05_chessboard_graphic/annotations/without_coordinates.png} +0 -0
- package/test/{references/04_chessboard_annotations/3.png → graphic_references/05_chessboard_graphic/annotations/without_coordinates_and_flip.png} +0 -0
- package/test/{references/02_chessboard_simple/0.png → graphic_references/05_chessboard_graphic/base/default.png} +0 -0
- package/test/{references/02_chessboard_simple/1.png → graphic_references/05_chessboard_graphic/base/empty.png} +0 -0
- package/test/{references/02_chessboard_simple/3.png → graphic_references/05_chessboard_graphic/base/from_fen.png} +0 -0
- package/test/{references/02_chessboard_simple/4.png → graphic_references/05_chessboard_graphic/base/from_kokopu_object.png} +0 -0
- package/test/{references/02_chessboard_simple/2.png → graphic_references/05_chessboard_graphic/base/parsing_error.png} +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/wrong_position_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960_with_move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant_with_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/special_code.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_with_std_initial_position.png +0 -0
- package/test/{references/03_chessboard_flipped/2.png → graphic_references/05_chessboard_graphic/chess_variants/variant_without_std_initial_position.png} +0 -0
- package/test/{references/03_chessboard_flipped/0.png → graphic_references/05_chessboard_graphic/flipped/default.png} +0 -0
- package/test/{references/03_chessboard_flipped/1.png → graphic_references/05_chessboard_graphic/flipped/empty.png} +0 -0
- package/test/{references/03_chessboard_flipped/3.png → graphic_references/05_chessboard_graphic/flipped/from_fen.png} +0 -0
- package/test/{references/03_chessboard_flipped/4.png → graphic_references/05_chessboard_graphic/flipped/from_kokopu_object.png} +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/parsing_error.png +0 -0
- package/test/{references/05_chessboard_move/4.png → graphic_references/05_chessboard_graphic/move/capture.png} +0 -0
- package/test/{references/05_chessboard_move/5.png → graphic_references/05_chessboard_graphic/move/castling_move.png} +0 -0
- package/test/{references/05_chessboard_move/0.png → graphic_references/05_chessboard_graphic/move/default.png} +0 -0
- package/test/{references/05_chessboard_move/6.png → graphic_references/05_chessboard_graphic/move/en-passant.png} +0 -0
- package/test/{references/05_chessboard_move/1.png → graphic_references/05_chessboard_graphic/move/no_move_arrow.png} +0 -0
- package/test/{references/05_chessboard_move/2.png → graphic_references/05_chessboard_graphic/move/parsing_error.png} +0 -0
- package/test/{references/05_chessboard_move/7.png → graphic_references/05_chessboard_graphic/move/promotion.png} +0 -0
- package/test/{references/05_chessboard_move/3.png → graphic_references/05_chessboard_graphic/move/with_forced_move_arrow_and_flip.png} +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_arrow_color_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_type.png +0 -0
- package/test/{references/07_chessboard_theme/3.png → graphic_references/05_chessboard_graphic/theme/custom_1.png} +0 -0
- package/test/{references/07_chessboard_theme/4.png → graphic_references/05_chessboard_graphic/theme/custom_2.png} +0 -0
- package/test/{references/07_chessboard_theme/5.png → graphic_references/05_chessboard_graphic/theme/custom_3.png} +0 -0
- package/test/{references/07_chessboard_theme/6.png → graphic_references/05_chessboard_graphic/theme/custom_4.png} +0 -0
- package/test/{references/07_chessboard_theme/7.png → graphic_references/05_chessboard_graphic/theme/custom_5.png} +0 -0
- package/test/{references/07_chessboard_theme/8.png → graphic_references/05_chessboard_graphic/theme/custom_6.png} +0 -0
- package/test/{references/07_chessboard_theme/0.png → graphic_references/05_chessboard_graphic/theme/default.png} +0 -0
- package/test/{references/07_chessboard_theme/1.png → graphic_references/05_chessboard_graphic/theme/large.png} +0 -0
- package/test/{references/07_chessboard_theme/2.png → graphic_references/05_chessboard_graphic/theme/small.png} +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_colorset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_pieceset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_square_size_type.png +0 -0
- package/test/{references/06a_chessboard_animated_move/2.png → graphic_references/06_chessboard_animation/base_1/capture.png} +0 -0
- package/test/{references/06a_chessboard_animated_move/3.png → graphic_references/06_chessboard_animation/base_1/castling_move.png} +0 -0
- package/test/{references/06a_chessboard_animated_move/4.png → graphic_references/06_chessboard_animation/base_1/en-passant.png} +0 -0
- package/test/{references/06a_chessboard_animated_move/0.png → graphic_references/06_chessboard_animation/base_1/move_1.png} +0 -0
- package/test/{references/06a_chessboard_animated_move/1.png → graphic_references/06_chessboard_animation/base_1/move_2.png} +0 -0
- package/test/{references/06a_chessboard_animated_move/5.png → graphic_references/06_chessboard_animation/base_1/promotion.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/2.png → graphic_references/06_chessboard_animation/base_2/capture.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/3.png → graphic_references/06_chessboard_animation/base_2/castling_move.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/4.png → graphic_references/06_chessboard_animation/base_2/en-passant.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/0.png → graphic_references/06_chessboard_animation/base_2/move_1.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/1.png → graphic_references/06_chessboard_animation/base_2/move_2.png} +0 -0
- package/test/{references/06b_chessboard_animated_move/5.png → graphic_references/06_chessboard_animation/base_2/promotion.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/2.png → graphic_references/06_chessboard_animation/base_3/capture.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/3.png → graphic_references/06_chessboard_animation/base_3/castling_move.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/4.png → graphic_references/06_chessboard_animation/base_3/en-passant.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/0.png → graphic_references/06_chessboard_animation/base_3/move_1.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/1.png → graphic_references/06_chessboard_animation/base_3/move_2.png} +0 -0
- package/test/{references/06c_chessboard_animated_move/5.png → graphic_references/06_chessboard_animation/base_3/promotion.png} +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/final_state.png +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/initial_state.png +0 -0
- package/test/{references/10_chessboard_edit_arrows → graphic_references/07_chessboard_interaction/edit_arrows}/base_1.png +0 -0
- package/test/{references/10_chessboard_edit_arrows → graphic_references/07_chessboard_interaction/edit_arrows}/base_2.png +0 -0
- package/test/{references/10_chessboard_edit_arrows/null_vector.png → graphic_references/07_chessboard_interaction/edit_arrows/from_==_to.png} +0 -0
- package/test/{references/10_chessboard_edit_arrows → graphic_references/07_chessboard_interaction/edit_arrows}/out_of_board.png +0 -0
- package/test/{references/10_chessboard_edit_arrows → graphic_references/07_chessboard_interaction/edit_arrows}/over_arrow_marker.png +0 -0
- package/test/{references/10_chessboard_edit_arrows → graphic_references/07_chessboard_interaction/edit_arrows}/over_square_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/edit_color_not_set.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/wrong_interaction_mode.png +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/after_move.png +0 -0
- package/test/{references/09_chessboard_move_pieces/null_vector.png → graphic_references/07_chessboard_interaction/move_pieces/from_==_to.png} +0 -0
- package/test/{references/09_chessboard_move_pieces/empty_square.png → graphic_references/07_chessboard_interaction/move_pieces/move_empty_square.png} +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/out_of_board.png +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/over_arrow_marker.png +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/over_empty.png +0 -0
- package/test/{references/09_chessboard_move_pieces/over_non_empty_1.png → graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_1.png} +0 -0
- package/test/{references/09_chessboard_move_pieces/over_non_empty_2.png → graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_2.png} +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/over_square_marker.png +0 -0
- package/test/{references/09_chessboard_move_pieces → graphic_references/07_chessboard_interaction/move_pieces}/over_text_marker.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/castling_move.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/chess960_ambiguous_king_move.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/chess960_castling_move_1.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/chess960_castling_move_2.png +0 -0
- package/test/{references/11_chessboard_play_moves/chess960_non_kxr_castling.png → graphic_references/08_chessboard_play_moves/base/chess960_non-kxr_castling.png} +0 -0
- package/test/{references/11_chessboard_play_moves/null_vector.png → graphic_references/08_chessboard_play_moves/base/from_==_to.png} +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/illegal_move.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/illegal_position.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/out_of_board.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/regular_move_1.png +0 -0
- package/test/{references/11_chessboard_play_moves → graphic_references/08_chessboard_play_moves/base}/regular_move_2.png +0 -0
- package/test/{references/10_chessboard_edit_arrows/edit_color_not_set.png → graphic_references/08_chessboard_play_moves/base/wrong_color_moved.png} +0 -0
- package/test/{references/12_chessboard_play_promotions → graphic_references/08_chessboard_play_moves/promotions}/antichess_promotion.png +0 -0
- package/test/{references/12_chessboard_play_promotions → graphic_references/08_chessboard_play_moves/promotions}/cancel_promotion.png +0 -0
- package/test/{references/12_chessboard_play_promotions → graphic_references/08_chessboard_play_moves/promotions}/regular_promotion_1.png +0 -0
- package/test/{references/12_chessboard_play_promotions → graphic_references/08_chessboard_play_moves/promotions}/regular_promotion_2.png +0 -0
- package/test/{references/13_movetext_simple/0.png → graphic_references/09_movetext_graphic/base/game_1.png} +0 -0
- package/test/{references/13_movetext_simple/1.png → graphic_references/09_movetext_graphic/base/game_2.png} +0 -0
- package/test/{references/13_movetext_simple/2.png → graphic_references/09_movetext_graphic/base/game_3.png} +0 -0
- package/test/{references/13_movetext_simple/3.png → graphic_references/09_movetext_graphic/base/game_4.png} +0 -0
- package/test/{references/14_movetext_error/2.png → graphic_references/09_movetext_graphic/error/pgn_parsing_error_1.png} +0 -0
- package/test/{references/14_movetext_error/3.png → graphic_references/09_movetext_graphic/error/pgn_parsing_error_2.png} +0 -0
- package/test/{references/14_movetext_error/0.png → graphic_references/09_movetext_graphic/error/wrong_game_index_1.png} +0 -0
- package/test/{references/14_movetext_error/1.png → graphic_references/09_movetext_graphic/error/wrong_game_index_2.png} +0 -0
- package/test/graphic_references/09_movetext_graphic/error/wrong_game_index_type.png +0 -0
- package/test/graphic_references/09_movetext_graphic/error/wrong_game_type.png +0 -0
- package/test/{references/15_movetext_html/2.png → graphic_references/09_movetext_graphic/html/filtered_tags_and_attributes.png} +0 -0
- package/test/{references/15_movetext_html/1.png → graphic_references/09_movetext_graphic/html/html_in_comments.png} +0 -0
- package/test/{references/15_movetext_html/0.png → graphic_references/09_movetext_graphic/html/html_in_headers.png} +0 -0
- package/test/{references/16_movetext_options/1.png → graphic_references/09_movetext_graphic/options/custom_piece_symbols.png} +0 -0
- package/test/{references/16_movetext_options/2.png → graphic_references/09_movetext_graphic/options/figurine_piece_symbols_and_diagram_options.png} +0 -0
- package/test/{references/16_movetext_options/3.png → graphic_references/09_movetext_graphic/options/hidden_diagrams.png} +0 -0
- package/test/{references/16_movetext_options/0.png → graphic_references/09_movetext_graphic/options/localized_piece_symbols.png} +0 -0
- package/test/graphic_references/09_movetext_graphic/options/wrong_diagram_options_1.png +0 -0
- package/test/graphic_references/09_movetext_graphic/options/wrong_diagram_options_2.png +0 -0
- package/test/graphic_references/10_movetext_interaction/error/wrong_interaction_mode.png +0 -0
- package/test/{references/17_movetext_interaction/0.png → graphic_references/10_movetext_interaction/select_moves/click_on_disabled.png} +0 -0
- package/test/{references/17_movetext_interaction/1.png → graphic_references/10_movetext_interaction/select_moves/click_on_unselected.png} +0 -0
- package/test/{references/17_movetext_interaction/2.png → graphic_references/10_movetext_interaction/select_moves/click_on_with_variations.png} +0 -0
- package/test/graphic_test_app/.eslintrc.yml +5 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +46 -0
- package/{scripts/clean-graphic-output.js → test/graphic_test_app/03_error_box_graphic/localization.tsx} +10 -7
- package/{graphic_test_src/01_marker_icons.js → test/graphic_test_app/04_marker_icons_graphic/base.tsx} +15 -7
- package/{graphic_test_src/04_chessboard_annotations.js → test/graphic_test_app/05_chessboard_graphic/annotations.tsx} +23 -14
- package/{graphic_test_src/02_chessboard_simple.js → test/graphic_test_app/05_chessboard_graphic/base.tsx} +6 -6
- package/test/graphic_test_app/05_chessboard_graphic/chess_variants.tsx +35 -0
- package/{graphic_test_src/03_chessboard_flipped.js → test/graphic_test_app/05_chessboard_graphic/flipped.tsx} +5 -5
- package/{graphic_test_src/05_chessboard_move.js → test/graphic_test_app/05_chessboard_graphic/move.tsx} +9 -8
- package/{graphic_test_src/07_chessboard_theme.js → test/graphic_test_app/05_chessboard_graphic/theme.tsx} +14 -11
- package/{graphic_test_src/06a_chessboard_animated_move.js → test/graphic_test_app/06_chessboard_animation/base_1.tsx} +5 -5
- package/{graphic_test_src/06b_chessboard_animated_move.js → test/graphic_test_app/06_chessboard_animation/base_2.tsx} +5 -5
- package/{graphic_test_src/06c_chessboard_animated_move.js → test/graphic_test_app/06_chessboard_animation/base_3.tsx} +5 -5
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +49 -0
- package/{graphic_test_src/08_chessboard_click_squares.js → test/graphic_test_app/07_chessboard_interaction/click_squares.tsx} +7 -6
- package/{graphic_test_src/10_chessboard_edit_arrows.js → test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx} +7 -7
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +30 -0
- package/{graphic_test_src/09_chessboard_move_pieces.js → test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx} +7 -6
- package/{graphic_test_src/11_chessboard_play_moves.js → test/graphic_test_app/08_chessboard_play_moves/base.tsx} +6 -6
- package/{graphic_test_src/12_chessboard_play_promotions.js → test/graphic_test_app/08_chessboard_play_moves/promotions.tsx} +6 -6
- package/{graphic_test_src/13_movetext_simple.js → test/graphic_test_app/09_movetext_graphic/base.tsx} +8 -8
- package/{graphic_test_src/14_movetext_error.js → test/graphic_test_app/09_movetext_graphic/error.tsx} +10 -9
- package/{graphic_test_src/15_movetext_html.js → test/graphic_test_app/09_movetext_graphic/html.tsx} +7 -7
- package/{graphic_test_src/16_movetext_options.js → test/graphic_test_app/09_movetext_graphic/options.tsx} +9 -6
- package/test/graphic_test_app/10_movetext_interaction/error.tsx +31 -0
- package/{graphic_test_src/17_movetext_interaction.js → test/graphic_test_app/10_movetext_interaction/select_moves.tsx} +7 -7
- package/test/graphic_test_app/common/decs.d.ts +26 -0
- package/{graphic_test_src → test/graphic_test_app}/common/dummy.pgn +0 -0
- package/{graphic_test_src → test/graphic_test_app}/common/games.pgn +1 -1
- package/{graphic_test_src → test/graphic_test_app}/common/heartbeat.txt +0 -0
- package/{graphic_test_src → test/graphic_test_app}/common/smiley.png +0 -0
- package/{graphic_test_src → test/graphic_test_app}/common/test_app.css +11 -2
- package/{graphic_test_src/common/test_app.js → test/graphic_test_app/common/test_app.tsx} +62 -14
- package/tsconfig.json +15 -0
- package/.babelrc +0 -3
- package/dist/lib/ArrowMarkerIcon.js +0 -85
- package/dist/lib/Chessboard.js +0 -1276
- package/dist/lib/ErrorBox.js +0 -125
- package/dist/lib/Movetext.js +0 -805
- package/dist/lib/SquareMarkerIcon.js +0 -69
- package/dist/lib/TextMarkerIcon.js +0 -74
- package/dist/lib/formatmove.js +0 -107
- package/dist/lib/impl/DraggableHandle.js +0 -268
- package/dist/lib/impl/HtmlSanitizer.js +0 -145
- package/dist/lib/impl/Motion.js +0 -109
- package/dist/lib/impl/TextSymbol.js +0 -89
- package/dist/lib/impl/piecesets.js +0 -219
- package/dist/lib/impl/util.js +0 -71
- package/dist/lib/markers.js +0 -144
- package/doc_src/.eslintrc.yml +0 -2
- package/src/Chessboard.js +0 -1034
- package/src/ErrorBox.js +0 -132
- package/src/Movetext.js +0 -671
- package/src/impl/DraggableHandle.js +0 -232
- package/src/impl/HtmlSanitizer.js +0 -126
- package/src/impl/colorsets.js +0 -119
- package/src/impl/piecesets.js +0 -218
- package/src/impl/util.js +0 -68
- package/src/index.js +0 -31
- package/src/markers.js +0 -115
- package/test/4_chessboard_graphic.js +0 -49
- package/test/5_chessboard_interaction.js +0 -135
- package/test/6_chessboard_play_moves.js +0 -107
- package/test/references/01_marker_icons/10.png +0 -0
- package/test/references/01_marker_icons/3.png +0 -0
- package/test/references/01_marker_icons/4.png +0 -0
- package/test/references/01_marker_icons/5.png +0 -0
- package/test/references/01_marker_icons/6.png +0 -0
- package/test/references/01_marker_icons/7.png +0 -0
- package/test/references/01_marker_icons/8.png +0 -0
- package/test/references/01_marker_icons/9.png +0 -0
- package/test/references/02_chessboard_simple/5.png +0 -0
- package/test/references/05_chessboard_move/8.png +0 -0
- package/test/references/11_chessboard_play_moves/wrong_color.png +0 -0
- package/test/references/14_movetext_error/4.png +0 -0
package/src/impl/util.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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
|
-
export const MIN_SQUARE_SIZE = 12;
|
|
24
|
-
export const MAX_SQUARE_SIZE = 96;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export function generateRandomId() {
|
|
28
|
-
let buffer = new Uint32Array(8);
|
|
29
|
-
crypto.getRandomValues(buffer);
|
|
30
|
-
let result = '';
|
|
31
|
-
for (let i = 0; i < buffer.length; ++i) {
|
|
32
|
-
result += buffer[i].toString(16);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export function fillPlaceholder(message, ...placeholderValues) {
|
|
39
|
-
return message.replace(/{(\d+)}/g, (match, placeholder) => {
|
|
40
|
-
const placeholderIndex = Number(placeholder);
|
|
41
|
-
return placeholderIndex < placeholderValues.length ? placeholderValues[placeholderIndex] : match;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export function sanitizeInteger(input, min, max) {
|
|
47
|
-
return Math.min(Math.max(Math.round(input), min), max);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export function isValidSquare(sq) {
|
|
52
|
-
return /^[a-h][1-8]$/.test(sq);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export function isValidVector(vect) {
|
|
57
|
-
return /^[a-h][1-8][a-h][1-8]$/.test(vect);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export function isValidColor(color) {
|
|
62
|
-
return color === 'b' || color === 'g' || color === 'r' || color === 'y';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export function isValidSymbol(symbol) {
|
|
67
|
-
return /^(?:[A-Za-z0-9]|plus|times|dot|circle)$/.test(symbol);
|
|
68
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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
|
-
export { flattenSquareMarkers, parseSquareMarkers, flattenTextMarkers, parseTextMarkers, flattenArrowMarkers, parseArrowMarkers } from './markers';
|
|
24
|
-
export { formatMove, moveFormatter } from './formatmove';
|
|
25
|
-
export { default as i18n } from './i18n';
|
|
26
|
-
export { default as Chessboard } from './Chessboard';
|
|
27
|
-
export { default as ErrorBox } from './ErrorBox';
|
|
28
|
-
export { default as Movetext } from './Movetext';
|
|
29
|
-
export { default as SquareMarkerIcon } from './SquareMarkerIcon';
|
|
30
|
-
export { default as TextMarkerIcon } from './TextMarkerIcon';
|
|
31
|
-
export { default as ArrowMarkerIcon } from './ArrowMarkerIcon';
|
package/src/markers.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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
|
-
import { isValidSquare, isValidVector, isValidColor, isValidSymbol } from './impl/util';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Transform a set of square markers defined as a "square -> color" struct into a comma-separated string.
|
|
28
|
-
*
|
|
29
|
-
* @param {object} markers For example: `{ e4: 'g', d5: 'r' }`
|
|
30
|
-
* @returns {string} For example: `'Gd5,Ge4'`
|
|
31
|
-
*/
|
|
32
|
-
export function flattenSquareMarkers(markers) {
|
|
33
|
-
return Object.entries(markers)
|
|
34
|
-
.filter(([ sq, color ]) => isValidSquare(sq) && isValidColor(color))
|
|
35
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
36
|
-
.map(([ sq, color ]) => color.toUpperCase() + sq)
|
|
37
|
-
.join(',');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Transform a set of text markers defined as a "square -> (symbol, color)" struct into a comma-separated string.
|
|
43
|
-
*
|
|
44
|
-
* @param {object} markers For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
|
|
45
|
-
* @returns {string} For example: `'Rzd5,GAe4,Y(plus)h3'`
|
|
46
|
-
*/
|
|
47
|
-
export function flattenTextMarkers(markers) {
|
|
48
|
-
return Object.entries(markers)
|
|
49
|
-
.filter(([ sq, desc ]) => isValidSquare(sq) && desc && isValidColor(desc.color) && isValidSymbol(desc.symbol))
|
|
50
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
51
|
-
.map(([ sq, desc ]) => desc.color.toUpperCase() + (desc.symbol.length === 1 ? desc.symbol : '(' + desc.symbol + ')') + sq)
|
|
52
|
-
.join(',');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Transform a set of arrow markers defined as a "squareFromSquareTo -> color" struct into a comma-separated string.
|
|
58
|
-
*
|
|
59
|
-
* @param {object} markers For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
|
|
60
|
-
* @returns {string} For example: `'Ge2e4,Rg8f6,Bg8h6'`
|
|
61
|
-
*/
|
|
62
|
-
export function flattenArrowMarkers(markers) {
|
|
63
|
-
return Object.entries(markers)
|
|
64
|
-
.filter(([ vect, color ]) => isValidVector(vect) && isValidColor(color))
|
|
65
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
66
|
-
.map(([ vect, color ]) => color.toUpperCase() + vect)
|
|
67
|
-
.join(',');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
function parseMarkers(markers, tokenParser) {
|
|
72
|
-
let result = {};
|
|
73
|
-
markers.split(',').map(token => tokenParser(token.trim())).filter(marker => marker).forEach(({ key, value }) => { result[key] = value; });
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Parse a set of square markers defined as a comma-separated string into a "square -> color" struct.
|
|
80
|
-
*
|
|
81
|
-
* @param {string} markers For example: `'Gd5,Ge4'`
|
|
82
|
-
* @returns {object} For example: `{ e4: 'g', d5: 'r' }`
|
|
83
|
-
*/
|
|
84
|
-
export function parseSquareMarkers(markers) {
|
|
85
|
-
return parseMarkers(markers, token => {
|
|
86
|
-
return /^([BGRY])([a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Parse a set of text markers defined as a comma-separated string into a "square -> (symbol, color)" struct.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} markers For example: `'Rzd5,GAe4,Y(plus)h3'`
|
|
95
|
-
* @returns {object} For example: `{ e4: { symbol: 'A', color: 'g' }, d5: { symbol: 'z', color: 'r' }, h3: { symbol: 'plus', color: 'y' } }`
|
|
96
|
-
*/
|
|
97
|
-
export function parseTextMarkers(markers) {
|
|
98
|
-
return parseMarkers(markers, token => {
|
|
99
|
-
return /^([BGRY])(?:([A-Za-z0-9])|\((plus|times|dot|circle)\))([a-h][1-8])$/.test(token) ?
|
|
100
|
-
{ key: RegExp.$4, value: { symbol: RegExp.$2 || RegExp.$3, color: RegExp.$1.toLowerCase() } } : undefined;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Parse a set of arrow markers defined as a comma-separated string into a "squareFromSquareTo -> color" struct.
|
|
107
|
-
*
|
|
108
|
-
* @param {string} markers For example: `'Ge2e4,Rg8f6,Bg8h6'`
|
|
109
|
-
* @returns {object} For example: `{ e2e4: 'g', g8f6: 'r', g8h6: 'b' }`
|
|
110
|
-
*/
|
|
111
|
-
export function parseArrowMarkers(markers) {
|
|
112
|
-
return parseMarkers(markers, token => {
|
|
113
|
-
return /^([BGRY])([a-h][1-8][a-h][1-8])$/.test(token) ? { key: RegExp.$2, value: RegExp.$1.toLowerCase() } : undefined;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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('Chessboard 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, '02_chessboard_simple', [ 'default', 'empty', 'invalid', 'from FEN', 'from Kokopu object', 'wrong type' ]);
|
|
39
|
-
itChecksScreenshots(browserContext, '03_chessboard_flipped', [ 'default', 'empty', 'invalid', 'from FEN', 'from Kokopu object' ]);
|
|
40
|
-
itChecksScreenshots(browserContext, '04_chessboard_annotations', [ 'with coordinates', 'with coordinates & flip', 'without coordinates', 'without coordinates & flip',
|
|
41
|
-
'overlap', 'overlap & flip' ]);
|
|
42
|
-
itChecksScreenshots(browserContext, '05_chessboard_move', [ 'default', 'no move arrow', 'invalid', 'with forced move arrow & flip', 'capture', 'castling move',
|
|
43
|
-
'en-passant', 'promotion', 'wrong type' ]);
|
|
44
|
-
itChecksScreenshots(browserContext, '06a_chessboard_animated_move', [ 'move 1', 'move 2', 'capture', 'castling move', 'en-pssant', 'promotion' ]);
|
|
45
|
-
itChecksScreenshots(browserContext, '06b_chessboard_animated_move', [ 'move 1', 'move 2', 'capture', 'castling move', 'en-pssant', 'promotion' ]);
|
|
46
|
-
itChecksScreenshots(browserContext, '06c_chessboard_animated_move', [ 'move 1', 'move 2', 'capture', 'castling move', 'en-pssant', 'promotion' ]);
|
|
47
|
-
itChecksScreenshots(browserContext, '07_chessboard_theme', [ 'default', 'large', 'small', 'custom 1', 'custom 2', 'custom 3',
|
|
48
|
-
'custom 4', 'custom 5', 'custom 6' ]);
|
|
49
|
-
});
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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
|
-
|
|
25
|
-
|
|
26
|
-
describe('Chessboard interaction', 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
|
-
function itCheckClickSquare(itemIndex, label, targets) {
|
|
39
|
-
itCustom(browserContext, '08_chessboard_click_squares', itemIndex, label, async function(element) {
|
|
40
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
41
|
-
let area = await element.getRect();
|
|
42
|
-
for (let i = 0; i < targets.length; ++i) {
|
|
43
|
-
let target = targets[i];
|
|
44
|
-
await actions.move({ x: area.x + target.x, y: area.y + target.y }).click().perform();
|
|
45
|
-
await compareSandbox(browserContext, target.expectedText);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
itCheckClickSquare(0, 'default', [
|
|
51
|
-
{ x: 225, y: 75, expectedText: 'square clicked: e7' },
|
|
52
|
-
{ x: 25, y: 375, expectedText: 'square clicked: a1' },
|
|
53
|
-
{ x: 325, y: 175, expectedText: 'square clicked: g5' },
|
|
54
|
-
]);
|
|
55
|
-
itCheckClickSquare(1, 'with flip', [
|
|
56
|
-
{ x: 325, y: 175, expectedText: 'square clicked: b4' },
|
|
57
|
-
]);
|
|
58
|
-
itCheckClickSquare(2, 'over annotations', [
|
|
59
|
-
{ x: 25, y: 25, expectedText: 'square clicked: a8' },
|
|
60
|
-
{ x: 75, y: 125, expectedText: 'square clicked: b6' },
|
|
61
|
-
{ x: 175, y: 125, expectedText: 'square clicked: d6' },
|
|
62
|
-
{ x: 75, y: 225, expectedText: 'square clicked: b4' },
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
function itCheckMovePiece(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName, expectedText) {
|
|
66
|
-
itCustom(browserContext, '09_chessboard_move_pieces', itemIndex, label, async function(element) {
|
|
67
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
68
|
-
let area = await element.getRect();
|
|
69
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
70
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
71
|
-
await actions.release().perform();
|
|
72
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
73
|
-
await compareSandbox(browserContext, expectedText);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
itCheckMovePiece(0, 'over empty', 275, 385, 225, 175, 'over_empty', 'piece moved: f1 -> e5');
|
|
78
|
-
itCheckMovePiece(0, 'over non-empty 1', 280, 365, 75, 75, 'over_non_empty_1', 'piece moved: f1 -> b7');
|
|
79
|
-
itCheckMovePiece(0, 'over non-empty 2', 130, 75, 225, 375, 'over_non_empty_2', 'piece moved: c7 -> e1');
|
|
80
|
-
itCheckMovePiece(1, 'over square marker', 10, 325, 275, 175, 'over_square_marker', 'piece moved: h7 -> c4');
|
|
81
|
-
itCheckMovePiece(1, 'over text marker', 225, 25, 10, 135, 'over_text_marker', 'piece moved: d1 -> h3');
|
|
82
|
-
itCheckMovePiece(1, 'over arrow marker', 325, 25, 315, 260, 'over_arrow_marker', 'piece moved: b1 -> b6');
|
|
83
|
-
itCheckMovePiece(2, 'after move', 225, 225, 75, 260, 'after_move', 'piece moved: e4 -> b3');
|
|
84
|
-
|
|
85
|
-
function itCheckNonMovePiece(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName) {
|
|
86
|
-
itCustom(browserContext, '09_chessboard_move_pieces', itemIndex, label, async function(element) {
|
|
87
|
-
await setSandbox(browserContext, imageBaseName); // can be any value as long as it is unique among other test-cases
|
|
88
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
89
|
-
let area = await element.getRect();
|
|
90
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
91
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
92
|
-
await actions.release().perform();
|
|
93
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
94
|
-
await compareSandbox(browserContext, imageBaseName);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
itCheckNonMovePiece(0, 'move empty square', 175, 225, 275, 75, 'empty_square');
|
|
99
|
-
itCheckNonMovePiece(0, 'from == to', 75, 375, 80, 360, 'null_vector');
|
|
100
|
-
itCheckNonMovePiece(0, 'out of board', 175, 25, 500, 210, 'out_of_board');
|
|
101
|
-
|
|
102
|
-
function itCheckEditArrow(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName, expectedText) {
|
|
103
|
-
itCustom(browserContext, '10_chessboard_edit_arrows', itemIndex, label, async function(element) {
|
|
104
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
105
|
-
let area = await element.getRect();
|
|
106
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
107
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
108
|
-
await actions.release().perform();
|
|
109
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
110
|
-
await compareSandbox(browserContext, expectedText);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
itCheckEditArrow(0, 'base 1', 325, 275, 110, 140, 'base_1', 'arrow edited: g3 -> c6');
|
|
115
|
-
itCheckEditArrow(0, 'base 2', 260, 10, 175, 375, 'base_2', 'arrow edited: f8 -> d1');
|
|
116
|
-
itCheckEditArrow(1, 'over square marker', 275, 125, 275, 230, 'over_square_marker', 'arrow edited: c3 -> c5');
|
|
117
|
-
itCheckEditArrow(1, 'over arrow marker', 40, 110, 125, 290, 'over_arrow_marker', 'arrow edited: h3 -> f6');
|
|
118
|
-
|
|
119
|
-
function itCheckNonEditArrow(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName) {
|
|
120
|
-
itCustom(browserContext, '10_chessboard_edit_arrows', itemIndex, label, async function(element) {
|
|
121
|
-
await setSandbox(browserContext, imageBaseName); // can be any value as long as it is unique among other test-cases
|
|
122
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
123
|
-
let area = await element.getRect();
|
|
124
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
125
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
126
|
-
await actions.release().perform();
|
|
127
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
128
|
-
await compareSandbox(browserContext, imageBaseName);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
itCheckNonEditArrow(2, 'edit color not set', 125, 175, 325, 225, 'edit_color_not_set');
|
|
133
|
-
itCheckNonEditArrow(0, 'from == to', 275, 225, 290, 210, 'null_vector');
|
|
134
|
-
itCheckNonEditArrow(0, 'out of board', 175, 225, 500, 280, 'out_of_board');
|
|
135
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/******************************************************************************
|
|
2
|
-
* *
|
|
3
|
-
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
-
* Copyright (C) 2021-2023 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
|
-
|
|
25
|
-
|
|
26
|
-
describe('Chessboard play moves', 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
|
-
function itCheckPlayMove(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName, expectedText) {
|
|
39
|
-
itCustom(browserContext, '11_chessboard_play_moves', itemIndex, label, async function(element) {
|
|
40
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
41
|
-
let area = await element.getRect();
|
|
42
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
43
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
44
|
-
await actions.release().perform();
|
|
45
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
46
|
-
await compareSandbox(browserContext, expectedText);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
itCheckPlayMove(0, 'regular move 1', 225, 335, 220, 225, 'regular_move_1', 'move played: e4');
|
|
51
|
-
itCheckPlayMove(1, 'regular move 2', 275, 225, 135, 85, 'regular_move_2', 'move played: Bxf2+');
|
|
52
|
-
itCheckPlayMove(1, 'castling move', 175, 375, 75, 375, 'castling_move', 'move played: O-O');
|
|
53
|
-
itCheckPlayMove(3, 'chess960 castling move 1', 275, 375, 75, 375, 'chess960_castling_move_1', 'move played: O-O-O');
|
|
54
|
-
itCheckPlayMove(3, 'chess960 castling move 2', 275, 375, 375, 375, 'chess960_castling_move_2', 'move played: O-O');
|
|
55
|
-
itCheckPlayMove(3, 'chess960 ambiguous king move', 275, 375, 320, 375, 'chess960_ambiguous_king_move', 'move played: Kg1');
|
|
56
|
-
|
|
57
|
-
function itCheckNonPlayMove(itemIndex, label, xFrom, yFrom, xTo, yTo, imageBaseName) {
|
|
58
|
-
itCustom(browserContext, '11_chessboard_play_moves', itemIndex, label, async function(element) {
|
|
59
|
-
await setSandbox(browserContext, imageBaseName); // can be any value as long as it is unique among other test-cases
|
|
60
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
61
|
-
let area = await element.getRect();
|
|
62
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).perform();
|
|
63
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
64
|
-
await actions.release().perform();
|
|
65
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
66
|
-
await compareSandbox(browserContext, imageBaseName);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
itCheckNonPlayMove(2, 'illegal position', 225, 325, 225, 225, 'illegal_position');
|
|
71
|
-
itCheckNonPlayMove(0, 'wrong color moved', 75, 25, 125, 125, 'wrong_color');
|
|
72
|
-
itCheckNonPlayMove(0, 'illegal move', 75, 375, 125, 225, 'illegal_move');
|
|
73
|
-
itCheckNonPlayMove(0, 'from == to', 75, 375, 85, 365, 'null_vector');
|
|
74
|
-
itCheckNonPlayMove(0, 'out of board', 325, 375, 450, 285, 'out_of_board');
|
|
75
|
-
itCheckNonPlayMove(3, 'chess960 non-KxR castling', 275, 375, 130, 375, 'chess960_non_kxr_castling');
|
|
76
|
-
|
|
77
|
-
function itCheckPlayPromotion(itemIndex, label, xFrom, yFrom, xTo, yTo, xPromo, yPromo, imageBaseName, expectedText) {
|
|
78
|
-
itCustom(browserContext, '12_chessboard_play_promotions', itemIndex, label, async function(element) {
|
|
79
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
80
|
-
let area = await element.getRect();
|
|
81
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).release().perform();
|
|
82
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
83
|
-
await actions.move({ x: area.x + xPromo, y: area.y + yPromo }).click().perform();
|
|
84
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
85
|
-
await compareSandbox(browserContext, expectedText);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
itCheckPlayPromotion(0, 'regular promotion 1', 75, 75, 75, 25, 60, 10, 'regular_promotion_1', 'promotion move played: b8=Q');
|
|
90
|
-
itCheckPlayPromotion(1, 'regular promotion 2', 75, 325, 25, 375, 15, 280, 'regular_promotion_2', 'promotion move played: bxa1=B');
|
|
91
|
-
itCheckPlayPromotion(2, 'antichess promotion', 325, 325, 325, 375, 325, 175, 'antichess_promotion', 'promotion move played: b8=K');
|
|
92
|
-
|
|
93
|
-
function itCheckNonPlayPromotion(itemIndex, label, xFrom, yFrom, xTo, yTo, xPromo, yPromo, imageBaseName) {
|
|
94
|
-
itCustom(browserContext, '12_chessboard_play_promotions', itemIndex, label, async function(element) {
|
|
95
|
-
await setSandbox(browserContext, imageBaseName); // can be any value as long as it is unique among other test-cases
|
|
96
|
-
let actions = browserContext.driver.actions({ async: true });
|
|
97
|
-
let area = await element.getRect();
|
|
98
|
-
await actions.move({ x: area.x + xFrom, y: area.y + yFrom }).press().move({ x: area.x + xTo, y: area.y + yTo }).release().perform();
|
|
99
|
-
await takeScreenshot(browserContext, imageBaseName, element);
|
|
100
|
-
await actions.move({ x: area.x + xPromo, y: area.y + yPromo }).click().perform();
|
|
101
|
-
await compareScreenshot(browserContext, imageBaseName);
|
|
102
|
-
await compareSandbox(browserContext, imageBaseName);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
itCheckNonPlayPromotion(1, 'cancel promotion', 75, 325, 75, 375, 190, 220, 'cancel_promotion');
|
|
107
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|