@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.
- package/.eslintrc.json +227 -0
- package/.github/instructions/copilot-instuctions.md +1671 -0
- package/README.md +127 -403
- package/assets/themes/alepot/theme.json +42 -0
- package/assets/themes/default/theme.json +42 -0
- package/chessboard.bundle.js +782 -119
- package/config/jest.config.js +15 -0
- package/config/rollup.config.js +35 -0
- package/dist/chessboard.cjs.js +10476 -0
- package/dist/chessboard.css +197 -0
- package/dist/chessboard.esm.js +10407 -0
- package/dist/chessboard.iife.js +10481 -0
- package/dist/chessboard.umd.js +10482 -0
- package/jest.config.js +2 -7
- package/package.json +18 -3
- package/rollup.config.js +2 -11
- package/{chessboard.move.js → src/components/Move.js} +3 -3
- package/src/components/Piece.js +273 -0
- package/{chessboard.square.js → src/components/Square.js} +60 -7
- package/src/constants/index.js +15 -0
- package/src/constants/positions.js +62 -0
- package/src/core/Chessboard.js +1930 -0
- package/src/core/ChessboardConfig.js +458 -0
- package/src/core/ChessboardFactory.js +385 -0
- package/src/core/index.js +141 -0
- package/src/errors/ChessboardError.js +133 -0
- package/src/errors/index.js +15 -0
- package/src/errors/messages.js +189 -0
- package/src/index.js +103 -0
- package/src/services/AnimationService.js +180 -0
- package/src/services/BoardService.js +156 -0
- package/src/services/CoordinateService.js +355 -0
- package/src/services/EventService.js +807 -0
- package/src/services/MoveService.js +594 -0
- package/src/services/PieceService.js +303 -0
- package/src/services/PositionService.js +237 -0
- package/src/services/ValidationService.js +673 -0
- package/src/services/index.js +14 -0
- package/src/styles/animations.css +46 -0
- package/{chessboard.css → src/styles/board.css} +3 -0
- package/src/styles/index.css +4 -0
- package/src/styles/pieces.css +66 -0
- package/src/utils/animations.js +37 -0
- package/{chess.js → src/utils/chess.js} +16 -16
- package/src/utils/coordinates.js +62 -0
- package/src/utils/cross-browser.js +150 -0
- package/src/utils/logger.js +422 -0
- package/src/utils/performance.js +311 -0
- package/src/utils/validation.js +458 -0
- package/tests/unit/chessboard-config-animations.test.js +106 -0
- package/tests/unit/chessboard-robust.test.js +163 -0
- package/tests/unit/chessboard.test.js +183 -0
- package/chessboard.config.js +0 -147
- package/chessboard.js +0 -981
- package/chessboard.piece.js +0 -115
- package/test/chessboard.test.js +0 -128
- /package/{alepot_theme → assets/themes/alepot}/bb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/bw.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/kb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/kw.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/nb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/nw.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/pb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/pw.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/qb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/qw.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/rb.svg +0 -0
- /package/{alepot_theme → assets/themes/alepot}/rw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/bb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/bw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/kb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/kw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/nb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/nw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/pb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/pw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/qb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/qw.svg +0 -0
- /package/{default_pieces → assets/themes/default}/rb.svg +0 -0
- /package/{default_pieces → assets/themes/default}/rw.svg +0 -0
- /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
|
+
}
|