ssb-chess-mithril 2.1.0 → 2.1.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 (35) hide show
  1. package/css/chessground-examples/README.md +14 -4
  2. package/css/chessground-examples/assets/3d.css +24 -23
  3. package/css/chessground-examples/assets/chessground.css +73 -15
  4. package/css/chessground-examples/assets/examples.css +1 -1
  5. package/css/chessground-examples/assets/theme.css +37 -26
  6. package/css/chessground-examples/index.html +5 -5
  7. package/css/chessground-examples/package-lock.json +1747 -8086
  8. package/css/chessground-examples/package.json +32 -17
  9. package/css/chessground-examples/pnpm-lock.yaml +874 -0
  10. package/css/chessground-examples/rollup.config.mjs +20 -0
  11. package/css/chessground-examples/src/main.ts +81 -48
  12. package/css/chessground-examples/src/units/anim.ts +63 -42
  13. package/css/chessground-examples/src/units/basics.ts +73 -13
  14. package/css/chessground-examples/src/units/fen.ts +21 -18
  15. package/css/chessground-examples/src/units/in3d.ts +26 -26
  16. package/css/chessground-examples/src/units/perf.ts +29 -15
  17. package/css/chessground-examples/src/units/play.ts +71 -52
  18. package/css/chessground-examples/src/units/svg.ts +230 -102
  19. package/css/chessground-examples/src/units/unit.ts +47 -18
  20. package/css/chessground-examples/src/units/viewOnly.ts +11 -11
  21. package/css/chessground-examples/src/units/zh.ts +25 -23
  22. package/css/chessground-examples/src/util.ts +30 -18
  23. package/css/chessground-examples/tsconfig.json +6 -4
  24. package/css/miniboards.css +1 -0
  25. package/index.js +87 -78
  26. package/package.json +4 -4
  27. package/ui/game/PieceGraveyard.js +1 -1
  28. package/ui/game/chat.js +3 -3
  29. package/ui/game/gameHistory.js +5 -1
  30. package/ui/game/gameView.js +30 -11
  31. package/ui/miniboard/miniboard.js +8 -5
  32. package/ui/pageLayout/navigation.js +11 -7
  33. package/css/chessground-examples/gulpfile.js +0 -52
  34. package/css/chessground-examples/index.standalone.html +0 -17
  35. package/css/chessground-examples/yarn.lock +0 -3529
@@ -1,46 +1,60 @@
1
- import { Unit } from './unit';
2
- import { Chessground } from 'chessground';
1
+ import { Unit } from "./unit";
2
+ import { Chessground } from "@lichess-org/chessground";
3
3
 
4
+ export const metaSquares: Unit = {
5
+ name: "Perf: meta squares",
6
+ run(cont) {
7
+ const cg = Chessground(cont, {
8
+ fen: "k7/8/8/8/8/4K3/4P3/8 w - - 0 1",
9
+ movable: {
10
+ free: false,
11
+ dests: new Map([
12
+ ["a8", ["b8", "a7", "b7"]],
13
+ ["e3", ["f2", "f3", "f4", "e4", "d2", "d3", "d4"]],
14
+ ]),
15
+ },
16
+ });
17
+ return cg;
18
+ },
19
+ };
4
20
  export const move: Unit = {
5
- name: 'Perf: piece move',
21
+ name: "Perf: piece move",
6
22
  run(cont) {
7
23
  const cg = Chessground(cont, {
8
- animation: { duration: 500 }
24
+ animation: { duration: 500 },
9
25
  });
10
26
  const delay = 400;
11
27
  function run() {
12
28
  if (!cg.state.dom.elements.board.offsetParent) return;
13
- cg.move('e2', 'a8');
29
+ cg.move("e2", "a8");
14
30
  setTimeout(() => {
15
- cg.move('a8', 'e2');
31
+ cg.move("a8", "e2");
16
32
  setTimeout(run, delay);
17
33
  }, delay);
18
34
  }
19
35
  setTimeout(run, delay);
20
36
  return cg;
21
- }
37
+ },
22
38
  };
23
39
  export const select: Unit = {
24
- name: 'Perf: square select',
40
+ name: "Perf: square select",
25
41
  run(cont) {
26
42
  const cg = Chessground(cont, {
27
43
  movable: {
28
44
  free: false,
29
- dests: {
30
- e2: ['e3', 'e4', 'd3', 'f3']
31
- }
32
- }
45
+ dests: new Map([["e2", ["e3", "e4", "d3", "f3"]]]),
46
+ },
33
47
  });
34
48
  const delay = 500;
35
49
  function run() {
36
50
  if (!cg.state.dom.elements.board.offsetParent) return;
37
- cg.selectSquare('e2');
51
+ cg.selectSquare("e2");
38
52
  setTimeout(() => {
39
- cg.selectSquare('d4');
53
+ cg.selectSquare("d4");
40
54
  setTimeout(run, delay);
41
55
  }, delay);
42
56
  }
43
57
  setTimeout(run, delay);
44
58
  return cg;
45
- }
59
+ },
46
60
  };
@@ -1,87 +1,87 @@
1
- import { Chess } from 'chess.js';
2
- import { Chessground } from 'chessground';
3
- import { Unit } from './unit';
4
- import { toColor, toDests, aiPlay, playOtherSide } from '../util'
1
+ import { Chess } from "chess.js";
2
+ import { Chessground } from "@lichess-org/chessground";
3
+ import { Unit } from "./unit";
4
+ import { toColor, toDests, aiPlay, playOtherSide } from "../util";
5
5
 
6
6
  export const initial: Unit = {
7
- name: 'Play legal moves from initial position',
7
+ name: "Play legal moves from initial position",
8
8
  run(el) {
9
9
  const chess = new Chess();
10
10
  const cg = Chessground(el, {
11
11
  movable: {
12
- color: 'white',
12
+ color: "white",
13
13
  free: false,
14
14
  dests: toDests(chess),
15
15
  },
16
16
  draggable: {
17
- showGhost: true
18
- }
17
+ showGhost: true,
18
+ },
19
19
  });
20
20
  cg.set({
21
- movable: { events: { after: playOtherSide(cg, chess) } }
21
+ movable: { events: { after: playOtherSide(cg, chess) } },
22
22
  });
23
23
  return cg;
24
- }
24
+ },
25
25
  };
26
26
 
27
27
  export const castling: Unit = {
28
- name: 'Castling',
28
+ name: "Castling",
29
29
  run(el) {
30
- const fen = 'rnbqk2r/pppp1ppp/5n2/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4';
30
+ const fen = "rnbqk2r/pppp1ppp/5n2/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4";
31
31
  const chess = new Chess(fen);
32
32
  const cg = Chessground(el, {
33
33
  fen: fen,
34
34
  turnColor: toColor(chess),
35
35
  movable: {
36
- color: 'white',
36
+ color: "white",
37
37
  free: false,
38
- dests: toDests(chess)
39
- }
38
+ dests: toDests(chess),
39
+ },
40
40
  });
41
41
  cg.set({
42
- movable: { events: { after: playOtherSide(cg, chess) } }
42
+ movable: { events: { after: playOtherSide(cg, chess) } },
43
43
  });
44
44
  return cg;
45
- }
45
+ },
46
46
  };
47
47
 
48
48
  export const vsRandom: Unit = {
49
- name: 'Play vs random AI',
49
+ name: "Play vs random AI",
50
50
  run(el) {
51
51
  const chess = new Chess();
52
52
  const cg = Chessground(el, {
53
53
  movable: {
54
- color: 'white',
54
+ color: "white",
55
55
  free: false,
56
- dests: toDests(chess)
57
- }
56
+ dests: toDests(chess),
57
+ },
58
58
  });
59
59
  cg.set({
60
60
  movable: {
61
61
  events: {
62
- after: aiPlay(cg, chess, 1000, false)
63
- }
64
- }
62
+ after: aiPlay(cg, chess, 1000, false),
63
+ },
64
+ },
65
65
  });
66
66
  return cg;
67
- }
67
+ },
68
68
  };
69
69
 
70
70
  export const fullRandom: Unit = {
71
- name: 'Watch 2 random AIs',
71
+ name: "Watch 2 random AIs",
72
72
  run(el) {
73
73
  const chess = new Chess();
74
74
  const cg = Chessground(el, {
75
75
  animation: {
76
- duration: 1000
76
+ duration: 1000,
77
77
  },
78
78
  movable: {
79
- free: false
80
- }
79
+ free: false,
80
+ },
81
81
  });
82
82
  function makeMove() {
83
83
  if (!cg.state.dom.elements.board.offsetParent) return;
84
- const moves = chess.moves({verbose:true});
84
+ const moves = chess.moves({ verbose: true });
85
85
  const move = moves[Math.floor(Math.random() * moves.length)];
86
86
  chess.move(move.san);
87
87
  cg.move(move.from, move.to);
@@ -89,56 +89,75 @@ export const fullRandom: Unit = {
89
89
  }
90
90
  setTimeout(makeMove, 700);
91
91
  return cg;
92
- }
93
- }
92
+ },
93
+ };
94
94
 
95
95
  export const slowAnim: Unit = {
96
- name: 'Play vs random AI; slow animations',
96
+ name: "Play vs random AI; slow animations",
97
97
  run(el) {
98
98
  const chess = new Chess();
99
99
  const cg = Chessground(el, {
100
100
  animation: {
101
- duration: 5000
101
+ duration: 5000,
102
102
  },
103
103
  movable: {
104
- color: 'white',
104
+ color: "white",
105
105
  free: false,
106
- dests: toDests(chess)
107
- }
106
+ dests: toDests(chess),
107
+ },
108
108
  });
109
109
  cg.set({
110
110
  movable: {
111
111
  events: {
112
- after: aiPlay(cg, chess, 1000, false)
113
- }
114
- }
112
+ after: aiPlay(cg, chess, 1000, false),
113
+ },
114
+ },
115
115
  });
116
116
  return cg;
117
- }
117
+ },
118
118
  };
119
119
 
120
120
  export const conflictingHold: Unit = {
121
- name: 'Conflicting hold/premove',
121
+ name: "Conflicting hold/premove",
122
122
  run(el) {
123
123
  const cg = Chessground(el, {
124
- fen: '8/8/5p2/4P3/8/8/8/8',
125
- turnColor: 'black',
124
+ fen: "8/8/5p2/4P3/8/8/8/8",
125
+ turnColor: "black",
126
126
  movable: {
127
- color: 'white',
127
+ color: "white",
128
128
  free: false,
129
- dests: {e5: ['f6']}
130
- }
129
+ dests: new Map([["e5", ["f6"]]]),
130
+ },
131
131
  });
132
132
  setTimeout(() => {
133
- cg.move('f6', 'e5');
133
+ cg.move("f6", "e5");
134
134
  cg.playPremove();
135
135
  cg.set({
136
- turnColor: 'white',
136
+ turnColor: "white",
137
137
  movable: {
138
- dests: undefined
139
- }
138
+ dests: undefined,
139
+ },
140
140
  });
141
141
  }, 1000);
142
142
  return cg;
143
- }
143
+ },
144
+ };
145
+
146
+ export const jsHover: Unit = {
147
+ name: "JS hover for safari",
148
+ run(el) {
149
+ const chess = new Chess();
150
+ const cg = Chessground(el, {
151
+ movable: {
152
+ color: "white",
153
+ free: false,
154
+ dests: toDests(chess),
155
+ },
156
+ jsHover: true,
157
+ });
158
+ cg.set({
159
+ movable: { events: { after: playOtherSide(cg, chess) } },
160
+ });
161
+ return cg;
162
+ },
144
163
  };