@dxos/react-ui-gameboard 0.8.3 → 0.8.4-main.1c7ec43d41
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/README.md +2 -0
- package/dist/lib/browser/index.mjs +705 -825
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +705 -825
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +20 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +31 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/chess.d.ts +60 -0
- package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/chess.test.d.ts +2 -0
- package/dist/types/src/components/Chessboard/chess.test.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Gameboard/Gameboard.d.ts +41 -0
- package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -0
- package/dist/types/src/{Board → components/Gameboard}/Piece.d.ts +3 -2
- package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -0
- package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -0
- package/dist/types/src/components/Gameboard/index.d.ts +4 -0
- package/dist/types/src/components/Gameboard/index.d.ts.map +1 -0
- package/dist/types/src/{Board → components/Gameboard}/types.d.ts +4 -3
- package/dist/types/src/components/Gameboard/types.d.ts.map +1 -0
- package/dist/types/src/components/Gameboard/util.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +3 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts.map +1 -1
- package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -24
- package/src/components/Chessboard/Chessboard.stories.tsx +113 -0
- package/src/components/Chessboard/Chessboard.tsx +205 -0
- package/src/components/Chessboard/chess.test.ts +19 -0
- package/src/components/Chessboard/chess.ts +325 -0
- package/src/components/Gameboard/Gameboard.tsx +139 -0
- package/src/{Board → components/Gameboard}/Piece.tsx +27 -23
- package/src/{Board → components/Gameboard}/Square.tsx +8 -6
- package/src/components/Gameboard/index.ts +8 -0
- package/src/{Board → components/Gameboard}/types.ts +5 -3
- package/src/components/index.ts +6 -0
- package/src/index.ts +1 -2
- package/dist/lib/node/index.cjs +0 -1039
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/Board/Board.d.ts +0 -15
- package/dist/types/src/Board/Board.d.ts.map +0 -1
- package/dist/types/src/Board/Container.d.ts +0 -14
- package/dist/types/src/Board/Container.d.ts.map +0 -1
- package/dist/types/src/Board/Piece.d.ts.map +0 -1
- package/dist/types/src/Board/Square.d.ts.map +0 -1
- package/dist/types/src/Board/context.d.ts +0 -10
- package/dist/types/src/Board/context.d.ts.map +0 -1
- package/dist/types/src/Board/index.d.ts +0 -8
- package/dist/types/src/Board/index.d.ts.map +0 -1
- package/dist/types/src/Board/types.d.ts.map +0 -1
- package/dist/types/src/Board/util.d.ts.map +0 -1
- package/dist/types/src/Chessboard/Chessboard.d.ts +0 -14
- package/dist/types/src/Chessboard/Chessboard.d.ts.map +0 -1
- package/dist/types/src/Chessboard/Chessboard.stories.d.ts +0 -16
- package/dist/types/src/Chessboard/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/Chessboard/chess.d.ts +0 -40
- package/dist/types/src/Chessboard/chess.d.ts.map +0 -1
- package/dist/types/src/Chessboard/index.d.ts.map +0 -1
- package/src/Board/Board.tsx +0 -86
- package/src/Board/Container.tsx +0 -25
- package/src/Board/context.ts +0 -22
- package/src/Board/index.ts +0 -12
- package/src/Chessboard/Chessboard.stories.tsx +0 -108
- package/src/Chessboard/Chessboard.tsx +0 -190
- package/src/Chessboard/chess.ts +0 -213
- /package/dist/types/src/{Chessboard → components/Chessboard}/index.d.ts +0 -0
- /package/dist/types/src/{Board → components/Gameboard}/Square.d.ts +0 -0
- /package/dist/types/src/{Board → components/Gameboard}/util.d.ts +0 -0
- /package/src/{Chessboard → components/Chessboard}/index.ts +0 -0
- /package/src/{Board → components/Gameboard}/util.ts +0 -0
|
@@ -5,22 +5,14 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
import { createContext, useContext } from "react";
|
|
10
|
-
import { raise } from "@dxos/debug";
|
|
11
|
-
var BoardContext = createContext(void 0);
|
|
12
|
-
var useBoardContext = () => {
|
|
13
|
-
return useContext(BoardContext) ?? raise(new Error("Missing BoardContext"));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// packages/ui/react-ui-gameboard/src/Board/types.ts
|
|
8
|
+
// src/components/Gameboard/types.ts
|
|
17
9
|
var locationToString = (location) => location.join("-");
|
|
18
10
|
var stringToLocation = (str) => str.split("-").map(Number);
|
|
19
11
|
var isPiece = (piece) => piece != null && typeof piece === "object" && "id" in piece && "type" in piece && "location" in piece && isLocation(piece.location);
|
|
20
12
|
var isLocation = (token) => Array.isArray(token) && token.length === 2 && token.every((val) => typeof val === "number");
|
|
21
13
|
var isEqualLocation = (l1, l2) => l1[0] === l2[0] && l1[1] === l2[1];
|
|
22
14
|
|
|
23
|
-
//
|
|
15
|
+
// src/components/Gameboard/util.ts
|
|
24
16
|
var getRelativeBounds = (container, element) => {
|
|
25
17
|
const containerRect = container.getBoundingClientRect();
|
|
26
18
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -32,360 +24,284 @@ var getRelativeBounds = (container, element) => {
|
|
|
32
24
|
};
|
|
33
25
|
};
|
|
34
26
|
|
|
35
|
-
//
|
|
36
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
27
|
+
// src/components/Gameboard/Gameboard.tsx
|
|
37
28
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
// packages/ui/react-ui-gameboard/src/Board/Container.tsx
|
|
43
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
44
|
-
import React, { forwardRef } from "react";
|
|
45
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
46
|
-
var Container = /* @__PURE__ */ forwardRef(({ children, classNames, style }, forwardedRef) => {
|
|
47
|
-
var _effect = _useSignals();
|
|
48
|
-
try {
|
|
49
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
50
|
-
ref: forwardedRef,
|
|
51
|
-
style,
|
|
52
|
-
className: "flex w-full h-full justify-center overflow-hidden"
|
|
53
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
54
|
-
className: mx("max-w-full max-h-full content-center", classNames)
|
|
55
|
-
}, children));
|
|
56
|
-
} finally {
|
|
57
|
-
_effect.f();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// packages/ui/react-ui-gameboard/src/Board/Board.tsx
|
|
62
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-gameboard/src/Board/Board.tsx";
|
|
63
|
-
var Root = ({ children, classNames, model, onDrop }) => {
|
|
64
|
-
var _effect = _useSignals2();
|
|
65
|
-
try {
|
|
66
|
-
const [dragging, setDragging] = useState(false);
|
|
67
|
-
const [promoting, setPromoting] = useState();
|
|
68
|
-
const onPromotion = useCallback((move) => {
|
|
69
|
-
log("onPromotion", {
|
|
70
|
-
move
|
|
71
|
-
}, {
|
|
72
|
-
F: __dxlog_file,
|
|
73
|
-
L: 32,
|
|
74
|
-
S: void 0,
|
|
75
|
-
C: (f, a) => f(...a)
|
|
76
|
-
});
|
|
77
|
-
setPromoting(void 0);
|
|
78
|
-
onDrop?.(move);
|
|
79
|
-
}, []);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (!model) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
return monitorForElements({
|
|
85
|
-
onDragStart: ({ source }) => {
|
|
86
|
-
log("onDragStart", {
|
|
87
|
-
source
|
|
88
|
-
}, {
|
|
89
|
-
F: __dxlog_file,
|
|
90
|
-
L: 45,
|
|
91
|
-
S: void 0,
|
|
92
|
-
C: (f, a) => f(...a)
|
|
93
|
-
});
|
|
94
|
-
setDragging(true);
|
|
95
|
-
},
|
|
96
|
-
onDrop: ({ source, location }) => {
|
|
97
|
-
log("onDrop", {
|
|
98
|
-
source,
|
|
99
|
-
location
|
|
100
|
-
}, {
|
|
101
|
-
F: __dxlog_file,
|
|
102
|
-
L: 49,
|
|
103
|
-
S: void 0,
|
|
104
|
-
C: (f, a) => f(...a)
|
|
105
|
-
});
|
|
106
|
-
const target = location.current.dropTargets[0];
|
|
107
|
-
if (!target) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const targetLocation = target.data.location;
|
|
111
|
-
const piece = source.data.piece;
|
|
112
|
-
if (!isLocation(targetLocation) || !isPiece(piece)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const move = {
|
|
116
|
-
from: piece.location,
|
|
117
|
-
to: targetLocation,
|
|
118
|
-
piece: piece.type
|
|
119
|
-
};
|
|
120
|
-
if (model.canPromote?.(move)) {
|
|
121
|
-
setPromoting({
|
|
122
|
-
...piece,
|
|
123
|
-
location: targetLocation
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
onDrop?.(move);
|
|
127
|
-
}
|
|
128
|
-
setDragging(false);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}, [
|
|
132
|
-
model
|
|
133
|
-
]);
|
|
134
|
-
return /* @__PURE__ */ React2.createElement(BoardContext.Provider, {
|
|
135
|
-
value: {
|
|
136
|
-
model,
|
|
137
|
-
dragging,
|
|
138
|
-
promoting,
|
|
139
|
-
onPromotion
|
|
140
|
-
}
|
|
141
|
-
}, /* @__PURE__ */ React2.createElement(Container, {
|
|
142
|
-
classNames: mx2("aspect-square", classNames)
|
|
143
|
-
}, children));
|
|
144
|
-
} finally {
|
|
145
|
-
_effect.f();
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
Root.displayName = "Board.Root";
|
|
149
|
-
var Board = {
|
|
150
|
-
Root
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
// packages/ui/react-ui-gameboard/src/Board/Square.tsx
|
|
154
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
155
|
-
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
156
|
-
import React3, { useRef, useState as useState2, useEffect as useEffect2, memo } from "react";
|
|
157
|
-
import { invariant } from "@dxos/invariant";
|
|
158
|
-
import { log as log2 } from "@dxos/log";
|
|
159
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
160
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-gameboard/src/Board/Square.tsx";
|
|
161
|
-
var Square = /* @__PURE__ */ memo(({ location, bounds, label, classNames }) => {
|
|
162
|
-
var _effect = _useSignals3();
|
|
163
|
-
try {
|
|
164
|
-
const ref = useRef(null);
|
|
165
|
-
const [state, setState] = useState2("idle");
|
|
166
|
-
const { model } = useBoardContext();
|
|
167
|
-
useEffect2(() => {
|
|
168
|
-
const el = ref.current;
|
|
169
|
-
invariant(el, void 0, {
|
|
170
|
-
F: __dxlog_file2,
|
|
171
|
-
L: 32,
|
|
172
|
-
S: void 0,
|
|
173
|
-
A: [
|
|
174
|
-
"el",
|
|
175
|
-
""
|
|
176
|
-
]
|
|
177
|
-
});
|
|
178
|
-
return dropTargetForElements({
|
|
179
|
-
element: el,
|
|
180
|
-
getData: () => ({
|
|
181
|
-
location
|
|
182
|
-
}),
|
|
183
|
-
canDrop: ({ source }) => {
|
|
184
|
-
log2("canDrop", {
|
|
185
|
-
source: source.data
|
|
186
|
-
}, {
|
|
187
|
-
F: __dxlog_file2,
|
|
188
|
-
L: 38,
|
|
189
|
-
S: void 0,
|
|
190
|
-
C: (f, a) => f(...a)
|
|
191
|
-
});
|
|
192
|
-
return true;
|
|
193
|
-
},
|
|
194
|
-
onDragEnter: ({ source }) => {
|
|
195
|
-
log2("onDragEnter", {
|
|
196
|
-
source: source.data
|
|
197
|
-
}, {
|
|
198
|
-
F: __dxlog_file2,
|
|
199
|
-
L: 42,
|
|
200
|
-
S: void 0,
|
|
201
|
-
C: (f, a) => f(...a)
|
|
202
|
-
});
|
|
203
|
-
const piece = source.data.piece;
|
|
204
|
-
if (!isPiece(piece)) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (model?.isValidMove({
|
|
208
|
-
from: piece.location,
|
|
209
|
-
to: location,
|
|
210
|
-
piece: piece.type
|
|
211
|
-
})) {
|
|
212
|
-
setState("validMove");
|
|
213
|
-
} else {
|
|
214
|
-
setState("invalidMove");
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
onDragLeave: () => setState("idle"),
|
|
218
|
-
onDrop: () => setState("idle")
|
|
219
|
-
});
|
|
220
|
-
}, [
|
|
221
|
-
model,
|
|
222
|
-
location
|
|
223
|
-
]);
|
|
224
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
225
|
-
ref,
|
|
226
|
-
style: bounds,
|
|
227
|
-
className: mx3("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
|
|
228
|
-
}, label && /* @__PURE__ */ React3.createElement("div", {
|
|
229
|
-
className: mx3("absolute bottom-1 left-1 text-xs text-neutral-500")
|
|
230
|
-
}, label));
|
|
231
|
-
} finally {
|
|
232
|
-
_effect.f();
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
Square.displayName = "Square";
|
|
29
|
+
import { createContext } from "@radix-ui/react-context";
|
|
30
|
+
import React3, { forwardRef, useCallback, useEffect as useEffect3, useState as useState3 } from "react";
|
|
31
|
+
import { log as log3 } from "@dxos/log";
|
|
32
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
236
33
|
|
|
237
|
-
//
|
|
238
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
34
|
+
// src/components/Gameboard/Piece.tsx
|
|
239
35
|
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
240
36
|
import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer";
|
|
241
37
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
242
|
-
import
|
|
38
|
+
import React, { memo, useEffect, useRef, useState } from "react";
|
|
243
39
|
import { createPortal } from "react-dom";
|
|
244
|
-
import { invariant
|
|
245
|
-
import { log
|
|
246
|
-
import { useDynamicRef
|
|
247
|
-
import { mx
|
|
248
|
-
var
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
L:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
});
|
|
292
|
-
setCustomNativeDragPreview({
|
|
293
|
-
getOffset: centerUnderPointer,
|
|
294
|
-
// getOffset: preserveOffsetOnSource({
|
|
295
|
-
// element: source.element,
|
|
296
|
-
// input: location.current.input,
|
|
297
|
-
// }),
|
|
298
|
-
render: ({ container }) => {
|
|
299
|
-
setPreview(container);
|
|
300
|
-
const { width, height } = el.getBoundingClientRect();
|
|
301
|
-
container.style.width = width + "px";
|
|
302
|
-
container.style.height = height + "px";
|
|
303
|
-
return () => {
|
|
304
|
-
setPreview(void 0);
|
|
305
|
-
};
|
|
306
|
-
},
|
|
307
|
-
nativeSetDragImage
|
|
308
|
-
});
|
|
309
|
-
},
|
|
310
|
-
canDrag: () => !promotingRef.current && model?.turn === piece.side,
|
|
311
|
-
onDragStart: () => setDragging(true),
|
|
312
|
-
onDrop: ({ location: { current: current2 } }) => {
|
|
313
|
-
const location = current2.dropTargets[0].data.location;
|
|
40
|
+
import { invariant } from "@dxos/invariant";
|
|
41
|
+
import { log } from "@dxos/log";
|
|
42
|
+
import { useDynamicRef } from "@dxos/react-ui";
|
|
43
|
+
import { mx } from "@dxos/ui-theme";
|
|
44
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Piece.tsx";
|
|
45
|
+
var PIECE_NAME = "Piece";
|
|
46
|
+
var Piece = /* @__PURE__ */ memo(({ classNames, Component, piece, bounds, label, onClick }) => {
|
|
47
|
+
const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
|
|
48
|
+
const promotingRef = useDynamicRef(promoting);
|
|
49
|
+
const [dragging, setDragging] = useState(false);
|
|
50
|
+
const [preview, setPreview] = useState();
|
|
51
|
+
const [current, setCurrent] = useState({});
|
|
52
|
+
const ref = useRef(null);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!model) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const el = ref.current;
|
|
58
|
+
invariant(el, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 29, S: void 0, A: ["el", ""] });
|
|
59
|
+
return draggable({
|
|
60
|
+
element: el,
|
|
61
|
+
getInitialData: () => ({
|
|
62
|
+
piece
|
|
63
|
+
}),
|
|
64
|
+
onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
|
|
65
|
+
log("onGenerateDragPreview", {
|
|
66
|
+
source: source.data
|
|
67
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 36, S: void 0 });
|
|
68
|
+
setCustomNativeDragPreview({
|
|
69
|
+
getOffset: centerUnderPointer,
|
|
70
|
+
render: ({ container }) => {
|
|
71
|
+
setPreview(container);
|
|
72
|
+
const { width, height } = el.getBoundingClientRect();
|
|
73
|
+
container.style.width = width + "px";
|
|
74
|
+
container.style.height = height + "px";
|
|
75
|
+
return () => {
|
|
76
|
+
setPreview(void 0);
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
nativeSetDragImage
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
canDrag: () => !promotingRef.current && !model.readonly && model.turn === piece.side,
|
|
83
|
+
onDragStart: () => setDragging(true),
|
|
84
|
+
onDrop: ({ location: { current: current2 } }) => {
|
|
85
|
+
try {
|
|
86
|
+
const location = current2.dropTargets[0]?.data.location;
|
|
314
87
|
if (isLocation(location)) {
|
|
315
88
|
setCurrent((current3) => ({
|
|
316
89
|
...current3,
|
|
317
90
|
location
|
|
318
91
|
}));
|
|
319
92
|
}
|
|
320
|
-
|
|
93
|
+
} catch {
|
|
321
94
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
95
|
+
setDragging(false);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}, [
|
|
99
|
+
model,
|
|
100
|
+
piece
|
|
101
|
+
]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
if (!ref.current || !bounds) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!current.location || !isEqualLocation(current.location, piece.location)) {
|
|
108
|
+
ref.current.style.transition = "top 250ms ease-out, left 250ms ease-out";
|
|
109
|
+
ref.current.style.top = bounds.top + "px";
|
|
110
|
+
ref.current.style.left = bounds.left + "px";
|
|
111
|
+
setCurrent({
|
|
112
|
+
location: piece.location,
|
|
113
|
+
bounds
|
|
114
|
+
});
|
|
115
|
+
} else if (current.bounds !== bounds) {
|
|
116
|
+
ref.current.style.transition = "none";
|
|
117
|
+
ref.current.style.top = bounds.top + "px";
|
|
118
|
+
ref.current.style.left = bounds.left + "px";
|
|
119
|
+
setCurrent({
|
|
120
|
+
location: piece.location,
|
|
121
|
+
bounds
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, [
|
|
126
|
+
current,
|
|
127
|
+
piece.location,
|
|
128
|
+
bounds
|
|
129
|
+
]);
|
|
130
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
131
|
+
ref,
|
|
132
|
+
style: {
|
|
133
|
+
width: bounds?.width,
|
|
134
|
+
height: bounds?.height
|
|
135
|
+
},
|
|
136
|
+
className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
|
|
137
|
+
onClick
|
|
138
|
+
}, /* @__PURE__ */ React.createElement(Component, {
|
|
139
|
+
className: "grow"
|
|
140
|
+
}), label && /* @__PURE__ */ React.createElement("div", {
|
|
141
|
+
className: "absolute inset-1 text-xs text-black"
|
|
142
|
+
}, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
|
|
143
|
+
className: mx(classNames)
|
|
144
|
+
}, /* @__PURE__ */ React.createElement(Component, {
|
|
145
|
+
className: "grow"
|
|
146
|
+
})), preview));
|
|
147
|
+
});
|
|
148
|
+
Piece.displayName = PIECE_NAME;
|
|
149
|
+
|
|
150
|
+
// src/components/Gameboard/Square.tsx
|
|
151
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
152
|
+
import React2, { memo as memo2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
153
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
154
|
+
import { log as log2 } from "@dxos/log";
|
|
155
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
156
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Square.tsx";
|
|
157
|
+
var SQUARE_NAME = "Square";
|
|
158
|
+
var Square = /* @__PURE__ */ memo2(({ location, bounds, label, classNames }) => {
|
|
159
|
+
const ref = useRef2(null);
|
|
160
|
+
const [state, setState] = useState2("idle");
|
|
161
|
+
const { model } = useGameboardContext(SQUARE_NAME);
|
|
162
|
+
useEffect2(() => {
|
|
163
|
+
const el = ref.current;
|
|
164
|
+
invariant2(el, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 18, S: void 0, A: ["el", ""] });
|
|
165
|
+
return dropTargetForElements({
|
|
166
|
+
element: el,
|
|
167
|
+
getData: () => ({
|
|
168
|
+
location
|
|
169
|
+
}),
|
|
170
|
+
canDrop: ({ source }) => {
|
|
171
|
+
log2("canDrop", {
|
|
172
|
+
source: source.data
|
|
173
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 25, S: void 0 });
|
|
174
|
+
return true;
|
|
175
|
+
},
|
|
176
|
+
onDragEnter: ({ source }) => {
|
|
177
|
+
log2("onDragEnter", {
|
|
178
|
+
source: source.data
|
|
179
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 31, S: void 0 });
|
|
180
|
+
const piece = source.data.piece;
|
|
181
|
+
if (!isPiece(piece)) {
|
|
330
182
|
return;
|
|
331
183
|
}
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
} else if (current.bounds !== bounds) {
|
|
341
|
-
ref.current.style.transition = "none";
|
|
342
|
-
ref.current.style.top = bounds.top + "px";
|
|
343
|
-
ref.current.style.left = bounds.left + "px";
|
|
344
|
-
setCurrent({
|
|
345
|
-
location: piece.location,
|
|
346
|
-
bounds
|
|
347
|
-
});
|
|
184
|
+
if (model?.isValidMove({
|
|
185
|
+
from: piece.location,
|
|
186
|
+
to: location,
|
|
187
|
+
piece: piece.type
|
|
188
|
+
})) {
|
|
189
|
+
setState("validMove");
|
|
190
|
+
} else {
|
|
191
|
+
setState("invalidMove");
|
|
348
192
|
}
|
|
349
|
-
});
|
|
350
|
-
}, [
|
|
351
|
-
current,
|
|
352
|
-
piece.location,
|
|
353
|
-
bounds
|
|
354
|
-
]);
|
|
355
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", {
|
|
356
|
-
ref,
|
|
357
|
-
style: {
|
|
358
|
-
width: bounds?.width,
|
|
359
|
-
height: bounds?.height
|
|
360
193
|
},
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
194
|
+
onDragLeave: () => setState("idle"),
|
|
195
|
+
onDrop: () => setState("idle")
|
|
196
|
+
});
|
|
197
|
+
}, [
|
|
198
|
+
model,
|
|
199
|
+
location
|
|
200
|
+
]);
|
|
201
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
202
|
+
ref,
|
|
203
|
+
style: bounds,
|
|
204
|
+
className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
|
|
205
|
+
}, label && /* @__PURE__ */ React2.createElement("div", {
|
|
206
|
+
className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
|
|
207
|
+
}, label));
|
|
208
|
+
});
|
|
209
|
+
Square.displayName = SQUARE_NAME;
|
|
210
|
+
|
|
211
|
+
// src/components/Gameboard/Gameboard.tsx
|
|
212
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Gameboard.tsx";
|
|
213
|
+
var [GameboardContextProvider, useRadixGameboardContext] = createContext("Gameboard");
|
|
214
|
+
var useGameboardContext = (consumerName) => {
|
|
215
|
+
return useRadixGameboardContext(consumerName);
|
|
216
|
+
};
|
|
217
|
+
var GameboardRoot = ({ children, model, onDrop }) => {
|
|
218
|
+
const [dragging, setDragging] = useState3(false);
|
|
219
|
+
const [promoting, setPromoting] = useState3();
|
|
220
|
+
const handlePromotion = useCallback((move) => {
|
|
221
|
+
log3("onPromotion", {
|
|
222
|
+
move
|
|
223
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: void 0 });
|
|
224
|
+
setPromoting(void 0);
|
|
225
|
+
onDrop?.(move);
|
|
226
|
+
}, []);
|
|
227
|
+
useEffect3(() => {
|
|
228
|
+
if (!model) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
return monitorForElements({
|
|
232
|
+
onDragStart: ({ source }) => {
|
|
233
|
+
log3("onDragStart", {
|
|
234
|
+
source
|
|
235
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 35, S: void 0 });
|
|
236
|
+
setDragging(true);
|
|
237
|
+
},
|
|
238
|
+
onDrop: ({ source, location }) => {
|
|
239
|
+
log3("onDrop", {
|
|
240
|
+
source,
|
|
241
|
+
location
|
|
242
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 41, S: void 0 });
|
|
243
|
+
const target = location.current.dropTargets[0];
|
|
244
|
+
if (!target) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const targetLocation = target.data.location;
|
|
248
|
+
const piece = source.data.piece;
|
|
249
|
+
if (!isLocation(targetLocation) || !isPiece(piece)) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const move = {
|
|
253
|
+
from: piece.location,
|
|
254
|
+
to: targetLocation,
|
|
255
|
+
piece: piece.type
|
|
256
|
+
};
|
|
257
|
+
if (model.isValidMove(move)) {
|
|
258
|
+
if (model.canPromote?.(move)) {
|
|
259
|
+
setPromoting({
|
|
260
|
+
...piece,
|
|
261
|
+
location: targetLocation
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
onDrop?.(move);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
setDragging(false);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}, [
|
|
271
|
+
model
|
|
272
|
+
]);
|
|
273
|
+
return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
|
|
274
|
+
model,
|
|
275
|
+
dragging,
|
|
276
|
+
promoting,
|
|
277
|
+
onPromotion: handlePromotion
|
|
278
|
+
}, children);
|
|
279
|
+
};
|
|
280
|
+
GameboardRoot.displayName = "Gameboard.Root";
|
|
281
|
+
var GameboardContent = /* @__PURE__ */ forwardRef(({ children, classNames, grow, contain }, forwardedRef) => {
|
|
282
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
283
|
+
role: "none",
|
|
284
|
+
className: mx3(grow && "dx-size-container dx-expander grid place-content-center", classNames),
|
|
285
|
+
ref: forwardedRef
|
|
286
|
+
}, contain ? /* @__PURE__ */ React3.createElement("div", {
|
|
287
|
+
className: "w-[min(100cqw,100cqh)] h-[min(100cqw,100cqh)]"
|
|
288
|
+
}, children) : children);
|
|
380
289
|
});
|
|
381
|
-
|
|
290
|
+
GameboardContent.displayName = "Gameboard.Content";
|
|
291
|
+
var Gameboard = {
|
|
292
|
+
Root: GameboardRoot,
|
|
293
|
+
Content: GameboardContent,
|
|
294
|
+
Piece,
|
|
295
|
+
Square
|
|
296
|
+
};
|
|
382
297
|
|
|
383
|
-
//
|
|
384
|
-
import {
|
|
385
|
-
import { Chess
|
|
298
|
+
// src/components/Chessboard/chess.ts
|
|
299
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
300
|
+
import { Chess as ChessJS } from "chess.js";
|
|
301
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
386
302
|
import { log as log4 } from "@dxos/log";
|
|
387
303
|
|
|
388
|
-
//
|
|
304
|
+
// src/gen/pieces/chess/alpha/index.ts
|
|
389
305
|
var alpha_exports = {};
|
|
390
306
|
__export(alpha_exports, {
|
|
391
307
|
BB: () => bB_default,
|
|
@@ -402,281 +318,185 @@ __export(alpha_exports, {
|
|
|
402
318
|
WR: () => wR_default
|
|
403
319
|
});
|
|
404
320
|
|
|
405
|
-
//
|
|
406
|
-
import
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
419
|
-
fill: "#101010",
|
|
420
|
-
d: "M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z"
|
|
421
|
-
}));
|
|
422
|
-
} finally {
|
|
423
|
-
_effect.f();
|
|
424
|
-
}
|
|
425
|
-
};
|
|
321
|
+
// src/gen/pieces/chess/alpha/bB.tsx
|
|
322
|
+
import * as React4 from "react";
|
|
323
|
+
var SvgBB = (props) => /* @__PURE__ */ React4.createElement("svg", {
|
|
324
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
325
|
+
viewBox: "0 0 2048 2048",
|
|
326
|
+
...props
|
|
327
|
+
}, /* @__PURE__ */ React4.createElement("path", {
|
|
328
|
+
fill: "#f9f9f9",
|
|
329
|
+
d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
|
|
330
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
331
|
+
fill: "#101010",
|
|
332
|
+
d: "M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z"
|
|
333
|
+
}));
|
|
426
334
|
var bB_default = SvgBB;
|
|
427
335
|
|
|
428
|
-
//
|
|
429
|
-
import
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}), /* @__PURE__ */ React6.createElement("path", {
|
|
442
|
-
fill: "#101010",
|
|
443
|
-
d: "M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z"
|
|
444
|
-
}));
|
|
445
|
-
} finally {
|
|
446
|
-
_effect.f();
|
|
447
|
-
}
|
|
448
|
-
};
|
|
336
|
+
// src/gen/pieces/chess/alpha/bK.tsx
|
|
337
|
+
import * as React5 from "react";
|
|
338
|
+
var SvgBK = (props) => /* @__PURE__ */ React5.createElement("svg", {
|
|
339
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
340
|
+
viewBox: "0 0 2048 2048",
|
|
341
|
+
...props
|
|
342
|
+
}, /* @__PURE__ */ React5.createElement("path", {
|
|
343
|
+
fill: "#f9f9f9",
|
|
344
|
+
d: "m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560"
|
|
345
|
+
}), /* @__PURE__ */ React5.createElement("path", {
|
|
346
|
+
fill: "#101010",
|
|
347
|
+
d: "M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z"
|
|
348
|
+
}));
|
|
449
349
|
var bK_default = SvgBK;
|
|
450
350
|
|
|
451
|
-
//
|
|
452
|
-
import
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}), /* @__PURE__ */ React7.createElement("path", {
|
|
465
|
-
fill: "#101010",
|
|
466
|
-
d: "m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276"
|
|
467
|
-
}));
|
|
468
|
-
} finally {
|
|
469
|
-
_effect.f();
|
|
470
|
-
}
|
|
471
|
-
};
|
|
351
|
+
// src/gen/pieces/chess/alpha/bN.tsx
|
|
352
|
+
import * as React6 from "react";
|
|
353
|
+
var SvgBN = (props) => /* @__PURE__ */ React6.createElement("svg", {
|
|
354
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
355
|
+
viewBox: "0 0 2048 2048",
|
|
356
|
+
...props
|
|
357
|
+
}, /* @__PURE__ */ React6.createElement("path", {
|
|
358
|
+
fill: "#f9f9f9",
|
|
359
|
+
d: "M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z"
|
|
360
|
+
}), /* @__PURE__ */ React6.createElement("path", {
|
|
361
|
+
fill: "#101010",
|
|
362
|
+
d: "m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276"
|
|
363
|
+
}));
|
|
472
364
|
var bN_default = SvgBN;
|
|
473
365
|
|
|
474
|
-
//
|
|
475
|
-
import
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}, /* @__PURE__ */ React8.createElement("path", {
|
|
485
|
-
fill: "#101010",
|
|
486
|
-
d: "M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z"
|
|
487
|
-
}));
|
|
488
|
-
} finally {
|
|
489
|
-
_effect.f();
|
|
490
|
-
}
|
|
491
|
-
};
|
|
366
|
+
// src/gen/pieces/chess/alpha/bP.tsx
|
|
367
|
+
import * as React7 from "react";
|
|
368
|
+
var SvgBP = (props) => /* @__PURE__ */ React7.createElement("svg", {
|
|
369
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
370
|
+
viewBox: "0 0 2048 2048",
|
|
371
|
+
...props
|
|
372
|
+
}, /* @__PURE__ */ React7.createElement("path", {
|
|
373
|
+
fill: "#101010",
|
|
374
|
+
d: "M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z"
|
|
375
|
+
}));
|
|
492
376
|
var bP_default = SvgBP;
|
|
493
377
|
|
|
494
|
-
//
|
|
495
|
-
import
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}), /* @__PURE__ */ React9.createElement("path", {
|
|
508
|
-
fill: "#101010",
|
|
509
|
-
d: "M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z"
|
|
510
|
-
}));
|
|
511
|
-
} finally {
|
|
512
|
-
_effect.f();
|
|
513
|
-
}
|
|
514
|
-
};
|
|
378
|
+
// src/gen/pieces/chess/alpha/bQ.tsx
|
|
379
|
+
import * as React8 from "react";
|
|
380
|
+
var SvgBQ = (props) => /* @__PURE__ */ React8.createElement("svg", {
|
|
381
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
382
|
+
viewBox: "0 0 2048 2048",
|
|
383
|
+
...props
|
|
384
|
+
}, /* @__PURE__ */ React8.createElement("path", {
|
|
385
|
+
fill: "#f9f9f9",
|
|
386
|
+
d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
|
|
387
|
+
}), /* @__PURE__ */ React8.createElement("path", {
|
|
388
|
+
fill: "#101010",
|
|
389
|
+
d: "M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z"
|
|
390
|
+
}));
|
|
515
391
|
var bQ_default = SvgBQ;
|
|
516
392
|
|
|
517
|
-
//
|
|
518
|
-
import
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}), /* @__PURE__ */ React10.createElement("path", {
|
|
531
|
-
fill: "#101010",
|
|
532
|
-
d: "M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z"
|
|
533
|
-
}));
|
|
534
|
-
} finally {
|
|
535
|
-
_effect.f();
|
|
536
|
-
}
|
|
537
|
-
};
|
|
393
|
+
// src/gen/pieces/chess/alpha/bR.tsx
|
|
394
|
+
import * as React9 from "react";
|
|
395
|
+
var SvgBR = (props) => /* @__PURE__ */ React9.createElement("svg", {
|
|
396
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
397
|
+
viewBox: "0 0 2048 2048",
|
|
398
|
+
...props
|
|
399
|
+
}, /* @__PURE__ */ React9.createElement("path", {
|
|
400
|
+
fill: "#f9f9f9",
|
|
401
|
+
d: "m674 732-76 807 851 14-75-833z"
|
|
402
|
+
}), /* @__PURE__ */ React9.createElement("path", {
|
|
403
|
+
fill: "#101010",
|
|
404
|
+
d: "M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z"
|
|
405
|
+
}));
|
|
538
406
|
var bR_default = SvgBR;
|
|
539
407
|
|
|
540
|
-
//
|
|
541
|
-
import
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}), /* @__PURE__ */ React11.createElement("path", {
|
|
554
|
-
fill: "#101010",
|
|
555
|
-
d: "M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z"
|
|
556
|
-
}));
|
|
557
|
-
} finally {
|
|
558
|
-
_effect.f();
|
|
559
|
-
}
|
|
560
|
-
};
|
|
408
|
+
// src/gen/pieces/chess/alpha/wB.tsx
|
|
409
|
+
import * as React10 from "react";
|
|
410
|
+
var SvgWB = (props) => /* @__PURE__ */ React10.createElement("svg", {
|
|
411
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
412
|
+
viewBox: "0 0 2048 2048",
|
|
413
|
+
...props
|
|
414
|
+
}, /* @__PURE__ */ React10.createElement("path", {
|
|
415
|
+
fill: "#f9f9f9",
|
|
416
|
+
d: "m948 366 1-139 148-7 1 147zM564 860c114-267 456-443 456-443s392 176 476 502c-9 209-183 332-183 332l27 221-653 6 46-233s-230-171-169-385m-101 790c175 6 355 23 425-142h92s0 190-88 246c-163 103-625 38-625 38s-15-146 196-142m631 37-36-185 102 5s22 153 315 131c381-17 318 153 318 153l-483 5z"
|
|
417
|
+
}), /* @__PURE__ */ React10.createElement("path", {
|
|
418
|
+
fill: "#101010",
|
|
419
|
+
d: "M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z"
|
|
420
|
+
}));
|
|
561
421
|
var wB_default = SvgWB;
|
|
562
422
|
|
|
563
|
-
//
|
|
564
|
-
import
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}), /* @__PURE__ */ React12.createElement("path", {
|
|
577
|
-
fill: "#101010",
|
|
578
|
-
d: "M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z"
|
|
579
|
-
}));
|
|
580
|
-
} finally {
|
|
581
|
-
_effect.f();
|
|
582
|
-
}
|
|
583
|
-
};
|
|
423
|
+
// src/gen/pieces/chess/alpha/wK.tsx
|
|
424
|
+
import * as React11 from "react";
|
|
425
|
+
var SvgWK = (props) => /* @__PURE__ */ React11.createElement("svg", {
|
|
426
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
427
|
+
viewBox: "0 0 2048 2048",
|
|
428
|
+
...props
|
|
429
|
+
}, /* @__PURE__ */ React11.createElement("path", {
|
|
430
|
+
fill: "#f9f9f9",
|
|
431
|
+
d: "m501.6 1811 48.4-354.4-260-269.2s-166.4-288.2 29.9-481C582.2 448.7 826 727.2 826 727.2l195.6-165.7 184 165.7s216.4-232.5 430.4-76 255.4 317.6 117.4 531.6c-138.1 214-250.9 280.7-250.9 280.7L1558 1811z"
|
|
432
|
+
}), /* @__PURE__ */ React11.createElement("path", {
|
|
433
|
+
fill: "#101010",
|
|
434
|
+
d: "M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z"
|
|
435
|
+
}));
|
|
584
436
|
var wK_default = SvgWK;
|
|
585
437
|
|
|
586
|
-
//
|
|
587
|
-
import
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}), /* @__PURE__ */ React13.createElement("path", {
|
|
600
|
-
fill: "#101010",
|
|
601
|
-
d: "m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z"
|
|
602
|
-
}));
|
|
603
|
-
} finally {
|
|
604
|
-
_effect.f();
|
|
605
|
-
}
|
|
606
|
-
};
|
|
438
|
+
// src/gen/pieces/chess/alpha/wN.tsx
|
|
439
|
+
import * as React12 from "react";
|
|
440
|
+
var SvgWN = (props) => /* @__PURE__ */ React12.createElement("svg", {
|
|
441
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
442
|
+
viewBox: "0 0 2048 2048",
|
|
443
|
+
...props
|
|
444
|
+
}, /* @__PURE__ */ React12.createElement("path", {
|
|
445
|
+
fill: "#f9f9f9",
|
|
446
|
+
d: "m352 861 787-569 94 148s336 103 398 388c63 286 51 974 51 974l-1088 9s-37-290 184-460c221-171 221-212 221-212s-226-71-295-16-117 138-117 138l-129-67 74-85-88-97-94 56z"
|
|
447
|
+
}), /* @__PURE__ */ React12.createElement("path", {
|
|
448
|
+
fill: "#101010",
|
|
449
|
+
d: "m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z"
|
|
450
|
+
}));
|
|
607
451
|
var wN_default = SvgWN;
|
|
608
452
|
|
|
609
|
-
//
|
|
610
|
-
import
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}), /* @__PURE__ */ React14.createElement("path", {
|
|
623
|
-
fill: "#101010",
|
|
624
|
-
d: "M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z"
|
|
625
|
-
}));
|
|
626
|
-
} finally {
|
|
627
|
-
_effect.f();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
453
|
+
// src/gen/pieces/chess/alpha/wP.tsx
|
|
454
|
+
import * as React13 from "react";
|
|
455
|
+
var SvgWP = (props) => /* @__PURE__ */ React13.createElement("svg", {
|
|
456
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
457
|
+
viewBox: "0 0 2048 2048",
|
|
458
|
+
...props
|
|
459
|
+
}, /* @__PURE__ */ React13.createElement("path", {
|
|
460
|
+
fill: "#f9f9f9",
|
|
461
|
+
d: "m734 981 196-193s-189-82-79-288c79-149 303-114 361 50 63 179-113 240-113 240l226 197Zm-235 799s-8-107 50-154c196-173 338-386 371-599l210 2c33 206 182 447 321 561 101 59 99 199 99 199z"
|
|
462
|
+
}), /* @__PURE__ */ React13.createElement("path", {
|
|
463
|
+
fill: "#101010",
|
|
464
|
+
d: "M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z"
|
|
465
|
+
}));
|
|
630
466
|
var wP_default = SvgWP;
|
|
631
467
|
|
|
632
|
-
//
|
|
633
|
-
import
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}), /* @__PURE__ */ React15.createElement("path", {
|
|
646
|
-
fill: "#101010",
|
|
647
|
-
d: "M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z"
|
|
648
|
-
}));
|
|
649
|
-
} finally {
|
|
650
|
-
_effect.f();
|
|
651
|
-
}
|
|
652
|
-
};
|
|
468
|
+
// src/gen/pieces/chess/alpha/wQ.tsx
|
|
469
|
+
import * as React14 from "react";
|
|
470
|
+
var SvgWQ = (props) => /* @__PURE__ */ React14.createElement("svg", {
|
|
471
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
472
|
+
viewBox: "0 0 2048 2048",
|
|
473
|
+
...props
|
|
474
|
+
}, /* @__PURE__ */ React14.createElement("path", {
|
|
475
|
+
fill: "#f9f9f9",
|
|
476
|
+
d: "m508.5 1815.6 48.4-356.7-216.3-554.6-135.8-20.7-16.1-126.5 112.7-43.8 78.3 73.7-18.4 99 246.2 197.8 112.8-568.3L635 428l78.3-108 112.8 43.7-23 161 223.2 474 244-490-66.8-105.9 92-92 105.9 73.6L1337 534l103.5 529.2 260-161-16-142.7 131-46 57.6 131.1-207 103.6-175 529.2 48.4 308.4z"
|
|
477
|
+
}), /* @__PURE__ */ React14.createElement("path", {
|
|
478
|
+
fill: "#101010",
|
|
479
|
+
d: "M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z"
|
|
480
|
+
}));
|
|
653
481
|
var wQ_default = SvgWQ;
|
|
654
482
|
|
|
655
|
-
//
|
|
656
|
-
import
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}), /* @__PURE__ */ React16.createElement("path", {
|
|
669
|
-
fill: "#101010",
|
|
670
|
-
d: "M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z"
|
|
671
|
-
}));
|
|
672
|
-
} finally {
|
|
673
|
-
_effect.f();
|
|
674
|
-
}
|
|
675
|
-
};
|
|
483
|
+
// src/gen/pieces/chess/alpha/wR.tsx
|
|
484
|
+
import * as React15 from "react";
|
|
485
|
+
var SvgWR = (props) => /* @__PURE__ */ React15.createElement("svg", {
|
|
486
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
487
|
+
viewBox: "0 0 2048 2048",
|
|
488
|
+
...props
|
|
489
|
+
}, /* @__PURE__ */ React15.createElement("path", {
|
|
490
|
+
fill: "#f9f9f9",
|
|
491
|
+
d: "m435 1804 16-212 152-115 51-688-148-115-7-276 210-2 4 138 198 2 7-140 212-3 14 145 193-4 5-138h204l-7 285-145 106 42 693 172 124 19 207z"
|
|
492
|
+
}), /* @__PURE__ */ React15.createElement("path", {
|
|
493
|
+
fill: "#101010",
|
|
494
|
+
d: "M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z"
|
|
495
|
+
}));
|
|
676
496
|
var wR_default = SvgWR;
|
|
677
497
|
|
|
678
|
-
//
|
|
679
|
-
var __dxlog_file4 = "/
|
|
498
|
+
// src/components/Chessboard/chess.ts
|
|
499
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Chessboard/chess.ts";
|
|
680
500
|
var ChessPieces = alpha_exports;
|
|
681
501
|
var posToLocation = (pos) => {
|
|
682
502
|
const col = pos.charCodeAt(0) - "a".charCodeAt(0);
|
|
@@ -689,6 +509,9 @@ var posToLocation = (pos) => {
|
|
|
689
509
|
var locationToPos = ([row, col]) => {
|
|
690
510
|
return String.fromCharCode(col + "a".charCodeAt(0)) + (row + 1);
|
|
691
511
|
};
|
|
512
|
+
var getRawPgn = (pgn) => {
|
|
513
|
+
return pgn.replace(/\[.*?\]/g, "").trim();
|
|
514
|
+
};
|
|
692
515
|
var styles = {
|
|
693
516
|
neutral: {
|
|
694
517
|
black: "bg-neutral-50",
|
|
@@ -715,55 +538,85 @@ var boardStyles = styles.original;
|
|
|
715
538
|
var getSquareColor = ([row, col]) => {
|
|
716
539
|
return (col + row) % 2 === 0 ? boardStyles.black : boardStyles.white;
|
|
717
540
|
};
|
|
718
|
-
var
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
L: 72,
|
|
727
|
-
S: void 0,
|
|
728
|
-
C: (f, a) => f(...a)
|
|
729
|
-
});
|
|
730
|
-
const promotion = move.promotion ? move.promotion[1].toLowerCase() : "q";
|
|
731
|
-
game.move({
|
|
732
|
-
from,
|
|
733
|
-
to,
|
|
734
|
-
promotion
|
|
735
|
-
}, {
|
|
736
|
-
strict: false
|
|
737
|
-
});
|
|
738
|
-
return game;
|
|
739
|
-
} catch (err) {
|
|
740
|
-
return null;
|
|
541
|
+
var createChess = (pgn) => {
|
|
542
|
+
const chess = new ChessJS();
|
|
543
|
+
if (pgn) {
|
|
544
|
+
try {
|
|
545
|
+
chess.loadPgn(pgn);
|
|
546
|
+
} catch {
|
|
547
|
+
log4.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 57, S: void 0 });
|
|
548
|
+
}
|
|
741
549
|
}
|
|
550
|
+
return chess;
|
|
742
551
|
};
|
|
743
552
|
var ChessModel = class {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
553
|
+
_registry;
|
|
554
|
+
_chess = new ChessJS();
|
|
555
|
+
_pieces = Atom.make({});
|
|
556
|
+
_moveIndex = Atom.make(0);
|
|
557
|
+
constructor(_registry, pgn) {
|
|
558
|
+
this._registry = _registry;
|
|
559
|
+
this.update(pgn);
|
|
560
|
+
}
|
|
561
|
+
get readonly() {
|
|
562
|
+
return this._registry.get(this._moveIndex) !== this._chess.history().length;
|
|
747
563
|
}
|
|
748
564
|
get turn() {
|
|
749
|
-
return this.
|
|
565
|
+
return this._chess.turn() === "w" ? "white" : "black";
|
|
566
|
+
}
|
|
567
|
+
get game() {
|
|
568
|
+
return this._chess;
|
|
750
569
|
}
|
|
751
570
|
get pieces() {
|
|
752
571
|
return this._pieces;
|
|
753
572
|
}
|
|
754
|
-
get
|
|
755
|
-
return this.
|
|
573
|
+
get moveIndex() {
|
|
574
|
+
return this._moveIndex;
|
|
756
575
|
}
|
|
757
576
|
get fen() {
|
|
758
|
-
return this.
|
|
577
|
+
return this._chess.fen();
|
|
759
578
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
579
|
+
/**
|
|
580
|
+
* PGN with headers.
|
|
581
|
+
*
|
|
582
|
+
* [Event "?"]
|
|
583
|
+
* [Site "?"]
|
|
584
|
+
* [Date "2025.08.05"]
|
|
585
|
+
* [Round "?"]
|
|
586
|
+
* [White "?"]
|
|
587
|
+
* [Black "?"]
|
|
588
|
+
* [Result "*"]
|
|
589
|
+
*/
|
|
590
|
+
// TODO(burdon): Update headers.
|
|
591
|
+
get pgn() {
|
|
592
|
+
return getRawPgn(this._chess.pgn());
|
|
593
|
+
}
|
|
594
|
+
setMoveIndex(index) {
|
|
595
|
+
const temp = new ChessJS();
|
|
596
|
+
const history = this._chess.history({
|
|
597
|
+
verbose: true
|
|
598
|
+
});
|
|
599
|
+
for (let i = 0; i < index && i < history.length; i++) {
|
|
600
|
+
temp.move(history[i]);
|
|
601
|
+
}
|
|
602
|
+
this._updateBoard(temp);
|
|
603
|
+
}
|
|
604
|
+
update(pgn = "") {
|
|
605
|
+
const previous = this._chess.history();
|
|
606
|
+
try {
|
|
607
|
+
this._chess.loadPgn(pgn);
|
|
608
|
+
this._chess.setHeader("Date", createDate());
|
|
609
|
+
this._chess.setHeader("Site", "dxos.org");
|
|
610
|
+
} catch {
|
|
611
|
+
}
|
|
612
|
+
const current = this._chess.history();
|
|
613
|
+
if (!isValidNextMove(previous, current)) {
|
|
614
|
+
this._registry.set(this._pieces, {});
|
|
615
|
+
}
|
|
616
|
+
this._updateBoard(this._chess);
|
|
764
617
|
}
|
|
765
618
|
isValidMove(move) {
|
|
766
|
-
return
|
|
619
|
+
return tryMove(new ChessJS(this._chess.fen()), move) !== null;
|
|
767
620
|
}
|
|
768
621
|
canPromote(move) {
|
|
769
622
|
const isPawnMove = move.piece === "BP" || move.piece === "WP";
|
|
@@ -771,47 +624,96 @@ var ChessModel = class {
|
|
|
771
624
|
return isPawnMove && isToLastRank;
|
|
772
625
|
}
|
|
773
626
|
makeMove(move) {
|
|
774
|
-
const game =
|
|
627
|
+
const game = tryMove(this._chess, move);
|
|
775
628
|
if (!game) {
|
|
776
629
|
return false;
|
|
777
630
|
}
|
|
778
|
-
this.
|
|
779
|
-
this._update();
|
|
631
|
+
this._updateBoard(this._chess);
|
|
780
632
|
return true;
|
|
781
633
|
}
|
|
782
634
|
makeRandomMove() {
|
|
783
|
-
const moves = this.
|
|
635
|
+
const moves = this._chess.moves();
|
|
784
636
|
if (!moves.length) {
|
|
785
637
|
return false;
|
|
786
638
|
}
|
|
787
639
|
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
788
|
-
this.
|
|
789
|
-
this.
|
|
640
|
+
this._chess.move(move);
|
|
641
|
+
this._updateBoard(this._chess);
|
|
790
642
|
return true;
|
|
791
643
|
}
|
|
792
644
|
/**
|
|
793
645
|
* Update pieces preserving identity.
|
|
794
646
|
*/
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
this.
|
|
798
|
-
if (!record) {
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
const { square, type, color } = record;
|
|
802
|
-
const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
|
|
803
|
-
const location = posToLocation(square);
|
|
804
|
-
pieces[locationToString(location)] = {
|
|
805
|
-
id: `${square}-${pieceType}`,
|
|
806
|
-
type: pieceType,
|
|
807
|
-
side: color === "w" ? "white" : "black",
|
|
808
|
-
location
|
|
809
|
-
};
|
|
810
|
-
}));
|
|
811
|
-
this._pieces.value = mapPieces(this._pieces.value, pieces);
|
|
647
|
+
_updateBoard(chess) {
|
|
648
|
+
this._registry.set(this._pieces, createPieceMap(chess));
|
|
649
|
+
this._registry.set(this._moveIndex, chess.history().length);
|
|
812
650
|
}
|
|
813
651
|
};
|
|
814
|
-
var
|
|
652
|
+
var tryMove = (chess, move) => {
|
|
653
|
+
const from = locationToPos(move.from);
|
|
654
|
+
const to = locationToPos(move.to);
|
|
655
|
+
try {
|
|
656
|
+
const promotion = move.promotion ? move.promotion[1].toLowerCase() : "q";
|
|
657
|
+
chess.move({
|
|
658
|
+
from,
|
|
659
|
+
to,
|
|
660
|
+
promotion
|
|
661
|
+
}, {
|
|
662
|
+
strict: false
|
|
663
|
+
});
|
|
664
|
+
return chess;
|
|
665
|
+
} catch {
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
var isValidNextMove = (previous, current) => {
|
|
670
|
+
if (current.length > previous.length + 1) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
for (let i = 0; i < previous.length; i++) {
|
|
674
|
+
if (previous[i] !== current[i]) {
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return true;
|
|
679
|
+
};
|
|
680
|
+
var createPieceMap = (chess) => {
|
|
681
|
+
const temp = new ChessJS();
|
|
682
|
+
let pieces = _createPieceMap(temp);
|
|
683
|
+
const history = chess.history({
|
|
684
|
+
verbose: true
|
|
685
|
+
});
|
|
686
|
+
for (let i = 0; i < history.length; i++) {
|
|
687
|
+
const move = history[i];
|
|
688
|
+
temp.move(move);
|
|
689
|
+
pieces = _diffPieces(pieces, _createPieceMap(temp));
|
|
690
|
+
const test = /* @__PURE__ */ new Set();
|
|
691
|
+
Object.values(pieces).forEach((piece) => {
|
|
692
|
+
invariant3(!test.has(piece.id), "Duplicate: " + piece.id, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 213, S: void 0, A: ["!test.has(piece.id)", "'Duplicate: ' + piece.id"] });
|
|
693
|
+
test.add(piece.id);
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
return pieces;
|
|
697
|
+
};
|
|
698
|
+
var _createPieceMap = (chess) => {
|
|
699
|
+
const pieces = {};
|
|
700
|
+
chess.board().flatMap((row) => row.forEach((record) => {
|
|
701
|
+
if (!record) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const { square, type, color } = record;
|
|
705
|
+
const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
|
|
706
|
+
const location = posToLocation(square);
|
|
707
|
+
pieces[locationToString(location)] = {
|
|
708
|
+
id: `${square}-${pieceType}`,
|
|
709
|
+
type: pieceType,
|
|
710
|
+
side: color === "w" ? "white" : "black",
|
|
711
|
+
location
|
|
712
|
+
};
|
|
713
|
+
}));
|
|
714
|
+
return pieces;
|
|
715
|
+
};
|
|
716
|
+
var _diffPieces = (before, after) => {
|
|
815
717
|
const difference = {
|
|
816
718
|
removed: {},
|
|
817
719
|
added: {}
|
|
@@ -834,192 +736,171 @@ var mapPieces = (before, after) => {
|
|
|
834
736
|
piece.id = previous.id;
|
|
835
737
|
}
|
|
836
738
|
}
|
|
837
|
-
log4("delta", {
|
|
838
|
-
before: Object.keys(before).length,
|
|
839
|
-
after: Object.keys(after).length,
|
|
840
|
-
removed: Object.keys(difference.removed).length,
|
|
841
|
-
added: Object.keys(difference.added).length
|
|
842
|
-
}, {
|
|
843
|
-
F: __dxlog_file4,
|
|
844
|
-
L: 205,
|
|
845
|
-
S: void 0,
|
|
846
|
-
C: (f, a) => f(...a)
|
|
847
|
-
});
|
|
848
739
|
return after;
|
|
849
740
|
};
|
|
741
|
+
var createDate = (date = /* @__PURE__ */ new Date()) => date.toISOString().slice(0, 10).replace(/-/g, ".");
|
|
850
742
|
|
|
851
|
-
//
|
|
852
|
-
import {
|
|
853
|
-
import
|
|
743
|
+
// src/components/Chessboard/Chessboard.tsx
|
|
744
|
+
import { Atom as Atom2, useAtomValue } from "@effect-atom/atom-react";
|
|
745
|
+
import React16, { forwardRef as forwardRef2, memo as memo3, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState4 } from "react";
|
|
854
746
|
import { useResizeDetector } from "react-resize-detector";
|
|
855
|
-
import {
|
|
856
|
-
import { mx as
|
|
857
|
-
import {
|
|
858
|
-
var
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
key: locationToString(location),
|
|
888
|
-
["data-location"]: locationToString(location)
|
|
889
|
-
});
|
|
747
|
+
import { useForwardedRef } from "@dxos/react-ui";
|
|
748
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
749
|
+
import { isNonNullable } from "@dxos/util";
|
|
750
|
+
var EMPTY_PIECES_ATOM = Atom2.make({});
|
|
751
|
+
var CHESSBOARD_NAME = "Chessboard";
|
|
752
|
+
var ChessboardComponent = /* @__PURE__ */ forwardRef2(({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
|
|
753
|
+
const targetRef = useForwardedRef(forwardedRef);
|
|
754
|
+
const { width, height } = useResizeDetector({
|
|
755
|
+
targetRef,
|
|
756
|
+
refreshRate: 200
|
|
757
|
+
});
|
|
758
|
+
const { model, promoting, onPromotion } = useGameboardContext(CHESSBOARD_NAME);
|
|
759
|
+
const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
|
|
760
|
+
const squares = useMemo(() => {
|
|
761
|
+
return Array.from({
|
|
762
|
+
length: rows
|
|
763
|
+
}, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
|
|
764
|
+
length: cols
|
|
765
|
+
}).map((_, col) => [
|
|
766
|
+
row,
|
|
767
|
+
col
|
|
768
|
+
]));
|
|
769
|
+
}, [
|
|
770
|
+
orientation,
|
|
771
|
+
rows,
|
|
772
|
+
cols
|
|
773
|
+
]);
|
|
774
|
+
const layout = useMemo(() => {
|
|
775
|
+
return squares.map((location) => {
|
|
776
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
777
|
+
key: locationToString(location),
|
|
778
|
+
"data-location": locationToString(location)
|
|
890
779
|
});
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const bounds = grid[locationToString(piece.location)];
|
|
919
|
-
return {
|
|
920
|
-
piece,
|
|
921
|
-
bounds
|
|
922
|
-
};
|
|
923
|
-
}).filter(isNotFalsy);
|
|
924
|
-
}, [
|
|
925
|
-
grid,
|
|
926
|
-
model?.pieces.value,
|
|
927
|
-
promoting
|
|
928
|
-
]);
|
|
929
|
-
return /* @__PURE__ */ React17.createElement("div", {
|
|
930
|
-
ref: containerRef,
|
|
931
|
-
className: "relative"
|
|
932
|
-
}, /* @__PURE__ */ React17.createElement("div", {
|
|
933
|
-
ref: gridRef,
|
|
934
|
-
className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
|
|
935
|
-
}, layout), /* @__PURE__ */ React17.createElement("div", null, locations.map((location) => /* @__PURE__ */ React17.createElement(Square, {
|
|
936
|
-
key: locationToString(location),
|
|
937
|
-
location,
|
|
938
|
-
label: showLabels ? locationToPos(location) : void 0,
|
|
939
|
-
bounds: grid[locationToString(location)],
|
|
940
|
-
classNames: getSquareColor(location)
|
|
941
|
-
}))), /* @__PURE__ */ React17.createElement("div", {
|
|
942
|
-
className: mx5(promoting && "opacity-50")
|
|
943
|
-
}, positions.map(({ bounds, piece }) => /* @__PURE__ */ React17.createElement(Piece, {
|
|
944
|
-
key: piece.id,
|
|
945
|
-
piece,
|
|
946
|
-
bounds,
|
|
947
|
-
label: debug ? piece.id : void 0,
|
|
948
|
-
orientation,
|
|
949
|
-
Component: ChessPieces[piece.type]
|
|
950
|
-
}))), /* @__PURE__ */ React17.createElement("div", null, promoting && /* @__PURE__ */ React17.createElement(PromotionSelector, {
|
|
951
|
-
grid,
|
|
952
|
-
piece: promoting,
|
|
953
|
-
onSelect: (piece) => {
|
|
954
|
-
onPromotion({
|
|
955
|
-
from: Object.values(model.pieces.value).find((p) => p.id === promoting.id).location,
|
|
956
|
-
to: piece.location,
|
|
957
|
-
piece: promoting.type,
|
|
958
|
-
promotion: piece.type
|
|
959
|
-
});
|
|
780
|
+
});
|
|
781
|
+
}, [
|
|
782
|
+
squares
|
|
783
|
+
]);
|
|
784
|
+
const [grid, setGrid] = useState4({});
|
|
785
|
+
const gridRef = useRef3(null);
|
|
786
|
+
useEffect4(() => {
|
|
787
|
+
setGrid(squares.reduce((acc, location) => {
|
|
788
|
+
const square = getSquareLocation(gridRef.current, location);
|
|
789
|
+
const bounds = getRelativeBounds(gridRef.current, square);
|
|
790
|
+
return {
|
|
791
|
+
...acc,
|
|
792
|
+
[locationToString(location)]: bounds
|
|
793
|
+
};
|
|
794
|
+
}, {}));
|
|
795
|
+
}, [
|
|
796
|
+
squares,
|
|
797
|
+
width,
|
|
798
|
+
height
|
|
799
|
+
]);
|
|
800
|
+
const positions = useMemo(() => {
|
|
801
|
+
if (!gridRef.current) {
|
|
802
|
+
return [];
|
|
803
|
+
}
|
|
804
|
+
return Object.values(pieces).map((piece) => {
|
|
805
|
+
if (piece.id === promoting?.id) {
|
|
806
|
+
return null;
|
|
960
807
|
}
|
|
961
|
-
|
|
962
|
-
} finally {
|
|
963
|
-
_effect.f();
|
|
964
|
-
}
|
|
965
|
-
});
|
|
966
|
-
Chessboard.displayName = "Chessboard";
|
|
967
|
-
var getSquareLocation = (container, location) => {
|
|
968
|
-
return container.querySelector(`[data-location="${locationToString(location)}"]`);
|
|
969
|
-
};
|
|
970
|
-
var PromotionSelector = ({ grid, piece, onSelect }) => {
|
|
971
|
-
var _effect = _useSignals17();
|
|
972
|
-
try {
|
|
973
|
-
const positions = [
|
|
974
|
-
"Q",
|
|
975
|
-
"N",
|
|
976
|
-
"R",
|
|
977
|
-
"B"
|
|
978
|
-
].map((pieceType, i) => {
|
|
979
|
-
const location = [
|
|
980
|
-
piece.location[0] + (piece.location[0] === 0 ? i : -i),
|
|
981
|
-
piece.location[1]
|
|
982
|
-
];
|
|
808
|
+
const bounds = grid[locationToString(piece.location)];
|
|
983
809
|
return {
|
|
984
|
-
piece
|
|
985
|
-
|
|
986
|
-
type: (piece.side === "black" ? "B" : "W") + pieceType,
|
|
987
|
-
side: piece.side,
|
|
988
|
-
location
|
|
989
|
-
},
|
|
990
|
-
bounds: grid[locationToString(location)]
|
|
810
|
+
piece,
|
|
811
|
+
bounds
|
|
991
812
|
};
|
|
992
|
-
});
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
813
|
+
}).filter(isNonNullable);
|
|
814
|
+
}, [
|
|
815
|
+
grid,
|
|
816
|
+
pieces,
|
|
817
|
+
promoting
|
|
818
|
+
]);
|
|
819
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
820
|
+
ref: targetRef,
|
|
821
|
+
tabIndex: 0,
|
|
822
|
+
className: mx4("dx-expander relative outline-hidden", classNames)
|
|
823
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
824
|
+
ref: gridRef,
|
|
825
|
+
className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
|
|
826
|
+
}, layout), /* @__PURE__ */ React16.createElement("div", null, squares.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
|
|
827
|
+
key: locationToString(location),
|
|
828
|
+
location,
|
|
829
|
+
label: showLabels ? locationToPos(location) : void 0,
|
|
830
|
+
bounds: grid[locationToString(location)],
|
|
831
|
+
classNames: getSquareColor(location)
|
|
832
|
+
}))), /* @__PURE__ */ React16.createElement("div", {
|
|
833
|
+
className: mx4(promoting && "opacity-50")
|
|
834
|
+
}, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
|
|
835
|
+
key: piece.id,
|
|
836
|
+
piece,
|
|
837
|
+
bounds,
|
|
838
|
+
label: debug ? piece.id : void 0,
|
|
839
|
+
orientation,
|
|
840
|
+
Component: ChessPieces[piece.type]
|
|
841
|
+
}))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
|
|
842
|
+
grid,
|
|
843
|
+
piece: promoting,
|
|
844
|
+
onSelect: (piece) => {
|
|
845
|
+
onPromotion({
|
|
846
|
+
from: Object.values(pieces).find((p) => p.id === promoting.id).location,
|
|
847
|
+
to: piece.location,
|
|
848
|
+
piece: promoting.type,
|
|
849
|
+
promotion: piece.type
|
|
997
850
|
});
|
|
851
|
+
}
|
|
852
|
+
}));
|
|
853
|
+
});
|
|
854
|
+
ChessboardComponent.displayName = CHESSBOARD_NAME;
|
|
855
|
+
var Chessboard = /* @__PURE__ */ memo3(ChessboardComponent);
|
|
856
|
+
var PromotionSelector = ({ grid, piece, onSelect }) => {
|
|
857
|
+
const positions = [
|
|
858
|
+
"Q",
|
|
859
|
+
"N",
|
|
860
|
+
"R",
|
|
861
|
+
"B"
|
|
862
|
+
].map((pieceType, i) => {
|
|
863
|
+
const location = [
|
|
864
|
+
piece.location[0] + (piece.location[0] === 0 ? i : -i),
|
|
865
|
+
piece.location[1]
|
|
866
|
+
];
|
|
867
|
+
return {
|
|
868
|
+
piece: {
|
|
869
|
+
id: `promotion-${pieceType}`,
|
|
870
|
+
type: (piece.side === "black" ? "B" : "W") + pieceType,
|
|
871
|
+
side: piece.side,
|
|
872
|
+
location
|
|
873
|
+
},
|
|
874
|
+
bounds: grid[locationToString(location)]
|
|
998
875
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
876
|
+
});
|
|
877
|
+
const handleSelect = (selected) => {
|
|
878
|
+
onSelect({
|
|
879
|
+
...piece,
|
|
880
|
+
type: selected.type
|
|
881
|
+
});
|
|
882
|
+
};
|
|
883
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
|
|
884
|
+
key: piece2.id,
|
|
885
|
+
classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
|
|
886
|
+
piece: piece2,
|
|
887
|
+
bounds,
|
|
888
|
+
Component: ChessPieces[piece2.type],
|
|
889
|
+
onClick: () => handleSelect(piece2)
|
|
890
|
+
})));
|
|
891
|
+
};
|
|
892
|
+
var getSquareLocation = (container, location) => {
|
|
893
|
+
return container.querySelector(`[data-location="${locationToString(location)}"]`);
|
|
1012
894
|
};
|
|
1013
895
|
export {
|
|
1014
|
-
Board,
|
|
1015
|
-
BoardContext,
|
|
1016
896
|
ChessModel,
|
|
1017
897
|
ChessPieces,
|
|
1018
898
|
Chessboard,
|
|
1019
|
-
|
|
1020
|
-
Piece,
|
|
1021
|
-
Square,
|
|
899
|
+
Gameboard,
|
|
1022
900
|
boardStyles,
|
|
901
|
+
createChess,
|
|
902
|
+
createPieceMap,
|
|
903
|
+
getRawPgn,
|
|
1023
904
|
getRelativeBounds,
|
|
1024
905
|
getSquareColor,
|
|
1025
906
|
isEqualLocation,
|
|
@@ -1027,9 +908,8 @@ export {
|
|
|
1027
908
|
isPiece,
|
|
1028
909
|
locationToPos,
|
|
1029
910
|
locationToString,
|
|
1030
|
-
mapPieces,
|
|
1031
911
|
posToLocation,
|
|
1032
912
|
stringToLocation,
|
|
1033
|
-
|
|
913
|
+
useGameboardContext
|
|
1034
914
|
};
|
|
1035
915
|
//# sourceMappingURL=index.mjs.map
|