@alepot55/chessboardjs 2.2.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.eslintrc.json +227 -0
  2. package/.github/instructions/copilot-instuctions.md +1671 -0
  3. package/README.md +127 -403
  4. package/assets/themes/alepot/theme.json +42 -0
  5. package/assets/themes/default/theme.json +42 -0
  6. package/chessboard.bundle.js +782 -119
  7. package/config/jest.config.js +15 -0
  8. package/config/rollup.config.js +35 -0
  9. package/dist/chessboard.cjs.js +10476 -0
  10. package/dist/chessboard.css +197 -0
  11. package/dist/chessboard.esm.js +10407 -0
  12. package/dist/chessboard.iife.js +10481 -0
  13. package/dist/chessboard.umd.js +10482 -0
  14. package/jest.config.js +2 -7
  15. package/package.json +18 -3
  16. package/rollup.config.js +2 -11
  17. package/{chessboard.move.js → src/components/Move.js} +3 -3
  18. package/src/components/Piece.js +273 -0
  19. package/{chessboard.square.js → src/components/Square.js} +60 -7
  20. package/src/constants/index.js +15 -0
  21. package/src/constants/positions.js +62 -0
  22. package/src/core/Chessboard.js +1930 -0
  23. package/src/core/ChessboardConfig.js +458 -0
  24. package/src/core/ChessboardFactory.js +385 -0
  25. package/src/core/index.js +141 -0
  26. package/src/errors/ChessboardError.js +133 -0
  27. package/src/errors/index.js +15 -0
  28. package/src/errors/messages.js +189 -0
  29. package/src/index.js +103 -0
  30. package/src/services/AnimationService.js +180 -0
  31. package/src/services/BoardService.js +156 -0
  32. package/src/services/CoordinateService.js +355 -0
  33. package/src/services/EventService.js +807 -0
  34. package/src/services/MoveService.js +594 -0
  35. package/src/services/PieceService.js +303 -0
  36. package/src/services/PositionService.js +237 -0
  37. package/src/services/ValidationService.js +673 -0
  38. package/src/services/index.js +14 -0
  39. package/src/styles/animations.css +46 -0
  40. package/{chessboard.css → src/styles/board.css} +3 -0
  41. package/src/styles/index.css +4 -0
  42. package/src/styles/pieces.css +66 -0
  43. package/src/utils/animations.js +37 -0
  44. package/{chess.js → src/utils/chess.js} +16 -16
  45. package/src/utils/coordinates.js +62 -0
  46. package/src/utils/cross-browser.js +150 -0
  47. package/src/utils/logger.js +422 -0
  48. package/src/utils/performance.js +311 -0
  49. package/src/utils/validation.js +458 -0
  50. package/tests/unit/chessboard-config-animations.test.js +106 -0
  51. package/tests/unit/chessboard-robust.test.js +163 -0
  52. package/tests/unit/chessboard.test.js +183 -0
  53. package/chessboard.config.js +0 -147
  54. package/chessboard.js +0 -981
  55. package/chessboard.piece.js +0 -115
  56. package/test/chessboard.test.js +0 -128
  57. /package/{alepot_theme → assets/themes/alepot}/bb.svg +0 -0
  58. /package/{alepot_theme → assets/themes/alepot}/bw.svg +0 -0
  59. /package/{alepot_theme → assets/themes/alepot}/kb.svg +0 -0
  60. /package/{alepot_theme → assets/themes/alepot}/kw.svg +0 -0
  61. /package/{alepot_theme → assets/themes/alepot}/nb.svg +0 -0
  62. /package/{alepot_theme → assets/themes/alepot}/nw.svg +0 -0
  63. /package/{alepot_theme → assets/themes/alepot}/pb.svg +0 -0
  64. /package/{alepot_theme → assets/themes/alepot}/pw.svg +0 -0
  65. /package/{alepot_theme → assets/themes/alepot}/qb.svg +0 -0
  66. /package/{alepot_theme → assets/themes/alepot}/qw.svg +0 -0
  67. /package/{alepot_theme → assets/themes/alepot}/rb.svg +0 -0
  68. /package/{alepot_theme → assets/themes/alepot}/rw.svg +0 -0
  69. /package/{default_pieces → assets/themes/default}/bb.svg +0 -0
  70. /package/{default_pieces → assets/themes/default}/bw.svg +0 -0
  71. /package/{default_pieces → assets/themes/default}/kb.svg +0 -0
  72. /package/{default_pieces → assets/themes/default}/kw.svg +0 -0
  73. /package/{default_pieces → assets/themes/default}/nb.svg +0 -0
  74. /package/{default_pieces → assets/themes/default}/nw.svg +0 -0
  75. /package/{default_pieces → assets/themes/default}/pb.svg +0 -0
  76. /package/{default_pieces → assets/themes/default}/pw.svg +0 -0
  77. /package/{default_pieces → assets/themes/default}/qb.svg +0 -0
  78. /package/{default_pieces → assets/themes/default}/qw.svg +0 -0
  79. /package/{default_pieces → assets/themes/default}/rb.svg +0 -0
  80. /package/{default_pieces → assets/themes/default}/rw.svg +0 -0
  81. /package/{.babelrc → config/.babelrc} +0 -0
@@ -0,0 +1,197 @@
1
+ :root {
2
+ --dimBoard: 600px;
3
+ --pieceRatio: 0.9;
4
+
5
+ --blackSquare: #b58863;
6
+ --whiteSquare: #f0d9b5;
7
+ --highlightSquare: yellow;
8
+ --selectedSquareWhite: #ababaa;
9
+ --selectedSquareBlack: #ababaa;
10
+ --movedSquareBlack: #e9e981;
11
+ --movedSquareWhite: #f1f1a0;
12
+ --choiceSquare: white;
13
+ --coverSquare: black;
14
+ --hintColor: #ababaa;
15
+ }
16
+
17
+ .board {
18
+ display: grid;
19
+ grid-template: repeat(8, 1fr) / repeat(8, 1fr);
20
+ width: var(--dimBoard);
21
+ height: var(--dimBoard);
22
+ /* Enable hardware acceleration for better performance */
23
+ transform: translateZ(0);
24
+ will-change: auto;
25
+ }
26
+
27
+ .square {
28
+ width: calc(var(--dimBoard) / 8);
29
+ height: calc(var(--dimBoard) / 8);
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ }
34
+
35
+ .piece {
36
+ position: absolute;
37
+ z-index: 10;
38
+ width: calc(calc(var(--dimBoard) / 8) * var(--pieceRatio));
39
+ height: calc(calc(var(--dimBoard) / 8) * var(--pieceRatio));
40
+
41
+ /* No selection */
42
+ -webkit-user-select: none;
43
+ /* Safari */
44
+ -moz-user-select: none;
45
+ /* Firefox */
46
+ -ms-user-select: none;
47
+ /* IE10+/Edge */
48
+ user-select: none;
49
+ /* Standard */
50
+ }
51
+
52
+ .choicable {
53
+ z-index: 50;
54
+ }
55
+
56
+ .hint {
57
+ background: var(--hintColor);
58
+ width: calc(calc(var(--dimBoard) / 8) / 3.5);
59
+ height: calc(calc(var(--dimBoard) / 8) / 3.5);
60
+ position: absolute;
61
+ z-index: 5;
62
+ border-radius: 50%;
63
+ opacity: 0.8;
64
+ }
65
+
66
+ .catchable {
67
+ width: calc(calc(var(--dimBoard) / 8) * 0.9);
68
+ height: calc(calc(var(--dimBoard) / 8) * 0.9);
69
+ }
70
+
71
+ .blackSquare {
72
+ background: var(--blackSquare);
73
+ }
74
+
75
+ .whiteSquare {
76
+ background: var(--whiteSquare);
77
+ }
78
+
79
+ .selectedSquareWhite {
80
+ background: var(--selectedSquareWhite);
81
+ }
82
+
83
+ .selectedSquareBlack {
84
+ background: var(--selectedSquareBlack);
85
+ }
86
+
87
+ .movedSquareBlack {
88
+ background: var(--movedSquareBlack);
89
+ }
90
+
91
+ .movedSquareWhite {
92
+ background: var(--movedSquareWhite);
93
+ }
94
+
95
+ .choice {
96
+ background: var(--choiceSquare);
97
+ z-index: 30;
98
+ }
99
+
100
+ .cover {
101
+ background: var(--coverSquare);
102
+ opacity: 0.5;
103
+ z-index: 25;
104
+ }
105
+
106
+ .highlighted {
107
+ box-shadow: inset 0 0 10px var(--highlightSquare);
108
+ }/* Piece-specific styles */
109
+ .piece {
110
+ position: relative;
111
+ cursor: pointer;
112
+ /* Solo transizioni specifiche, non "all" */
113
+ transition: opacity var(--fade-time, 150ms) var(--fade-animation, ease);
114
+ z-index: 10;
115
+ /* Hint al browser per ottimizzazioni */
116
+ will-change: auto;
117
+ width: 100%;
118
+ height: 100%;
119
+ }
120
+
121
+ .piece.dragging {
122
+ position: absolute;
123
+ z-index: 100;
124
+ /* Disabilita completamente le transizioni durante il drag */
125
+ transition: none !important;
126
+ /* Hint per ottimizzazione durante drag */
127
+ will-change: left, top;
128
+ /* Scala visiva senza interferire con il posizionamento */
129
+ transform: scale(1.1);
130
+ }
131
+
132
+ .piece.fading {
133
+ opacity: 0;
134
+ transition: opacity var(--fade-time, 150ms) var(--fade-animation, ease);
135
+ }
136
+
137
+ .piece.moving {
138
+ /* Solo transizione per transform, non position */
139
+ transition: transform var(--move-time, 200ms) var(--move-animation, ease);
140
+ }
141
+
142
+ /* Piece sizing */
143
+ .piece img {
144
+ width: 100%;
145
+ height: 100%;
146
+ object-fit: contain;
147
+ /* Previene conflitti di drag dell'immagine */
148
+ pointer-events: none;
149
+ /* Migliore rendering */
150
+ image-rendering: crisp-edges;
151
+ }
152
+ /* Animation styles */
153
+ @keyframes fadeIn {
154
+ from { opacity: 0; }
155
+ to { opacity: 1; }
156
+ }
157
+
158
+ @keyframes fadeOut {
159
+ from { opacity: 1; }
160
+ to { opacity: 0; }
161
+ }
162
+
163
+ @keyframes slideIn {
164
+ from { transform: translateY(-10px); opacity: 0; }
165
+ to { transform: translateY(0); opacity: 1; }
166
+ }
167
+
168
+ @keyframes bounce {
169
+ 0%, 20%, 53%, 80%, 100% {
170
+ transform: translate3d(0, 0, 0);
171
+ }
172
+ 40%, 43% {
173
+ transform: translate3d(0, -5px, 0);
174
+ }
175
+ 70% {
176
+ transform: translate3d(0, -3px, 0);
177
+ }
178
+ 90% {
179
+ transform: translate3d(0, -1px, 0);
180
+ }
181
+ }
182
+
183
+ .fade-in {
184
+ animation: fadeIn var(--fade-time, 150ms) var(--fade-animation, ease);
185
+ }
186
+
187
+ .fade-out {
188
+ animation: fadeOut var(--fade-time, 150ms) var(--fade-animation, ease);
189
+ }
190
+
191
+ .slide-in {
192
+ animation: slideIn var(--fade-time, 150ms) var(--fade-animation, ease);
193
+ }
194
+
195
+ .bounce {
196
+ animation: bounce 1s ease;
197
+ }