@dxos/react-ui-gameboard 0.8.4-main.b97322e → 0.8.4-main.bc674ce
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/dist/lib/browser/index.mjs +733 -788
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +733 -788
- 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 +30 -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 +38 -0
- package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -0
- package/dist/types/src/{Gameboard → 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/{Gameboard → components/Gameboard}/types.d.ts +3 -2
- 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/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 +27 -22
- package/src/{Chessboard → components/Chessboard}/Chessboard.stories.tsx +33 -30
- package/src/{Chessboard → components/Chessboard}/Chessboard.tsx +67 -57
- package/src/components/Chessboard/chess.test.ts +19 -0
- package/src/components/Chessboard/chess.ts +325 -0
- package/src/components/Gameboard/Gameboard.tsx +145 -0
- package/src/{Gameboard → components/Gameboard}/Piece.tsx +25 -23
- package/src/{Gameboard → components/Gameboard}/Square.tsx +5 -5
- package/src/{Gameboard → components/Gameboard}/index.ts +0 -3
- package/src/{Gameboard → components/Gameboard}/types.ts +4 -2
- package/src/components/index.ts +6 -0
- package/src/index.ts +1 -2
- package/dist/types/src/Chessboard/Chessboard.d.ts +0 -15
- 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/dist/types/src/Gameboard/Gameboard.d.ts +0 -23
- package/dist/types/src/Gameboard/Gameboard.d.ts.map +0 -1
- package/dist/types/src/Gameboard/Piece.d.ts.map +0 -1
- package/dist/types/src/Gameboard/Square.d.ts.map +0 -1
- package/dist/types/src/Gameboard/context.d.ts +0 -10
- package/dist/types/src/Gameboard/context.d.ts.map +0 -1
- package/dist/types/src/Gameboard/index.d.ts +0 -7
- package/dist/types/src/Gameboard/index.d.ts.map +0 -1
- package/dist/types/src/Gameboard/types.d.ts.map +0 -1
- package/dist/types/src/Gameboard/util.d.ts.map +0 -1
- package/src/Chessboard/chess.ts +0 -213
- package/src/Gameboard/Gameboard.tsx +0 -103
- package/src/Gameboard/context.ts +0 -22
- /package/dist/types/src/{Chessboard → components/Chessboard}/index.d.ts +0 -0
- /package/dist/types/src/{Gameboard → components/Gameboard}/Square.d.ts +0 -0
- /package/dist/types/src/{Gameboard → components/Gameboard}/util.d.ts +0 -0
- /package/src/{Chessboard → components/Chessboard}/index.ts +0 -0
- /package/src/{Gameboard → components/Gameboard}/util.ts +0 -0
|
@@ -4,22 +4,14 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/Gameboard/
|
|
8
|
-
import { createContext, useContext } from "react";
|
|
9
|
-
import { raise } from "@dxos/debug";
|
|
10
|
-
var GameboardContext = createContext(void 0);
|
|
11
|
-
var useBoardContext = () => {
|
|
12
|
-
return useContext(GameboardContext) ?? raise(new Error("Missing BoardContext"));
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/Gameboard/types.ts
|
|
7
|
+
// src/components/Gameboard/types.ts
|
|
16
8
|
var locationToString = (location) => location.join("-");
|
|
17
9
|
var stringToLocation = (str) => str.split("-").map(Number);
|
|
18
10
|
var isPiece = (piece) => piece != null && typeof piece === "object" && "id" in piece && "type" in piece && "location" in piece && isLocation(piece.location);
|
|
19
11
|
var isLocation = (token) => Array.isArray(token) && token.length === 2 && token.every((val) => typeof val === "number");
|
|
20
12
|
var isEqualLocation = (l1, l2) => l1[0] === l2[0] && l1[1] === l2[1];
|
|
21
13
|
|
|
22
|
-
// src/Gameboard/util.ts
|
|
14
|
+
// src/components/Gameboard/util.ts
|
|
23
15
|
var getRelativeBounds = (container, element) => {
|
|
24
16
|
const containerRect = container.getBoundingClientRect();
|
|
25
17
|
const elementRect = element.getBoundingClientRect();
|
|
@@ -31,70 +23,281 @@ var getRelativeBounds = (container, element) => {
|
|
|
31
23
|
};
|
|
32
24
|
};
|
|
33
25
|
|
|
34
|
-
// src/Gameboard/Gameboard.tsx
|
|
35
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
26
|
+
// src/components/Gameboard/Gameboard.tsx
|
|
36
27
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
37
|
-
import
|
|
28
|
+
import { createContext } from "@radix-ui/react-context";
|
|
29
|
+
import React3, { forwardRef, useCallback, useEffect as useEffect3, useState as useState3 } from "react";
|
|
30
|
+
import { log as log3 } from "@dxos/log";
|
|
31
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
32
|
+
|
|
33
|
+
// src/components/Gameboard/Piece.tsx
|
|
34
|
+
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
35
|
+
import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer";
|
|
36
|
+
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
37
|
+
import React, { memo, useEffect, useRef, useState } from "react";
|
|
38
|
+
import { createPortal } from "react-dom";
|
|
39
|
+
import { invariant } from "@dxos/invariant";
|
|
38
40
|
import { log } from "@dxos/log";
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
import { useDynamicRef } from "@dxos/react-ui";
|
|
42
|
+
import { mx } from "@dxos/ui-theme";
|
|
43
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Piece.tsx";
|
|
44
|
+
var Piece = /* @__PURE__ */ memo(({ classNames, Component, piece, bounds, label, onClick }) => {
|
|
45
|
+
const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName);
|
|
46
|
+
const promotingRef = useDynamicRef(promoting);
|
|
47
|
+
const [dragging, setDragging] = useState(false);
|
|
48
|
+
const [preview, setPreview] = useState();
|
|
49
|
+
const [current, setCurrent] = useState({});
|
|
50
|
+
const ref = useRef(null);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!model) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const el = ref.current;
|
|
56
|
+
invariant(el, void 0, {
|
|
57
|
+
F: __dxlog_file,
|
|
58
|
+
L: 45,
|
|
59
|
+
S: void 0,
|
|
60
|
+
A: [
|
|
61
|
+
"el",
|
|
62
|
+
""
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
return draggable({
|
|
66
|
+
element: el,
|
|
67
|
+
getInitialData: () => ({
|
|
68
|
+
piece
|
|
69
|
+
}),
|
|
70
|
+
onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
|
|
71
|
+
log("onGenerateDragPreview", {
|
|
72
|
+
source: source.data
|
|
73
|
+
}, {
|
|
74
|
+
F: __dxlog_file,
|
|
75
|
+
L: 51,
|
|
76
|
+
S: void 0,
|
|
77
|
+
C: (f, a) => f(...a)
|
|
78
|
+
});
|
|
79
|
+
setCustomNativeDragPreview({
|
|
80
|
+
getOffset: centerUnderPointer,
|
|
81
|
+
render: ({ container }) => {
|
|
82
|
+
setPreview(container);
|
|
83
|
+
const { width, height } = el.getBoundingClientRect();
|
|
84
|
+
container.style.width = width + "px";
|
|
85
|
+
container.style.height = height + "px";
|
|
86
|
+
return () => {
|
|
87
|
+
setPreview(void 0);
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
nativeSetDragImage
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
canDrag: () => !promotingRef.current && !model.readonly && model.turn === piece.side,
|
|
94
|
+
onDragStart: () => setDragging(true),
|
|
95
|
+
onDrop: ({ location: { current: current2 } }) => {
|
|
96
|
+
try {
|
|
97
|
+
const location = current2.dropTargets[0]?.data.location;
|
|
98
|
+
if (isLocation(location)) {
|
|
99
|
+
setCurrent((current3) => ({
|
|
100
|
+
...current3,
|
|
101
|
+
location
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
setDragging(false);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}, [
|
|
110
|
+
model,
|
|
111
|
+
piece
|
|
112
|
+
]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
requestAnimationFrame(() => {
|
|
115
|
+
if (!ref.current || !bounds) {
|
|
60
116
|
return;
|
|
61
117
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
118
|
+
if (!current.location || !isEqualLocation(current.location, piece.location)) {
|
|
119
|
+
ref.current.style.transition = "top 250ms ease-out, left 250ms ease-out";
|
|
120
|
+
ref.current.style.top = bounds.top + "px";
|
|
121
|
+
ref.current.style.left = bounds.left + "px";
|
|
122
|
+
setCurrent({
|
|
123
|
+
location: piece.location,
|
|
124
|
+
bounds
|
|
125
|
+
});
|
|
126
|
+
} else if (current.bounds !== bounds) {
|
|
127
|
+
ref.current.style.transition = "none";
|
|
128
|
+
ref.current.style.top = bounds.top + "px";
|
|
129
|
+
ref.current.style.left = bounds.left + "px";
|
|
130
|
+
setCurrent({
|
|
131
|
+
location: piece.location,
|
|
132
|
+
bounds
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}, [
|
|
137
|
+
current,
|
|
138
|
+
piece.location,
|
|
139
|
+
bounds
|
|
140
|
+
]);
|
|
141
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
142
|
+
ref,
|
|
143
|
+
style: {
|
|
144
|
+
width: bounds?.width,
|
|
145
|
+
height: bounds?.height
|
|
146
|
+
},
|
|
147
|
+
className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
|
|
148
|
+
onClick
|
|
149
|
+
}, /* @__PURE__ */ React.createElement(Component, {
|
|
150
|
+
className: "grow"
|
|
151
|
+
}), label && /* @__PURE__ */ React.createElement("div", {
|
|
152
|
+
className: "absolute inset-1 text-xs text-black"
|
|
153
|
+
}, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
|
|
154
|
+
className: mx(classNames)
|
|
155
|
+
}, /* @__PURE__ */ React.createElement(Component, {
|
|
156
|
+
className: "grow"
|
|
157
|
+
})), preview));
|
|
158
|
+
});
|
|
159
|
+
Piece.displayName = "Piece";
|
|
160
|
+
|
|
161
|
+
// src/components/Gameboard/Square.tsx
|
|
162
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
163
|
+
import React2, { memo as memo2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
164
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
165
|
+
import { log as log2 } from "@dxos/log";
|
|
166
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
167
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Square.tsx";
|
|
168
|
+
var Square = /* @__PURE__ */ memo2(({ location, bounds, label, classNames }) => {
|
|
169
|
+
const ref = useRef2(null);
|
|
170
|
+
const [state, setState] = useState2("idle");
|
|
171
|
+
const { model } = useGameboardContext(Square.displayName);
|
|
172
|
+
useEffect2(() => {
|
|
173
|
+
const el = ref.current;
|
|
174
|
+
invariant2(el, void 0, {
|
|
175
|
+
F: __dxlog_file2,
|
|
176
|
+
L: 32,
|
|
177
|
+
S: void 0,
|
|
178
|
+
A: [
|
|
179
|
+
"el",
|
|
180
|
+
""
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
return dropTargetForElements({
|
|
184
|
+
element: el,
|
|
185
|
+
getData: () => ({
|
|
186
|
+
location
|
|
187
|
+
}),
|
|
188
|
+
canDrop: ({ source }) => {
|
|
189
|
+
log2("canDrop", {
|
|
190
|
+
source: source.data
|
|
191
|
+
}, {
|
|
192
|
+
F: __dxlog_file2,
|
|
193
|
+
L: 38,
|
|
194
|
+
S: void 0,
|
|
195
|
+
C: (f, a) => f(...a)
|
|
196
|
+
});
|
|
197
|
+
return true;
|
|
198
|
+
},
|
|
199
|
+
onDragEnter: ({ source }) => {
|
|
200
|
+
log2("onDragEnter", {
|
|
201
|
+
source: source.data
|
|
202
|
+
}, {
|
|
203
|
+
F: __dxlog_file2,
|
|
204
|
+
L: 42,
|
|
205
|
+
S: void 0,
|
|
206
|
+
C: (f, a) => f(...a)
|
|
207
|
+
});
|
|
208
|
+
const piece = source.data.piece;
|
|
209
|
+
if (!isPiece(piece)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (model?.isValidMove({
|
|
213
|
+
from: piece.location,
|
|
214
|
+
to: location,
|
|
215
|
+
piece: piece.type
|
|
216
|
+
})) {
|
|
217
|
+
setState("validMove");
|
|
218
|
+
} else {
|
|
219
|
+
setState("invalidMove");
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
onDragLeave: () => setState("idle"),
|
|
223
|
+
onDrop: () => setState("idle")
|
|
224
|
+
});
|
|
225
|
+
}, [
|
|
226
|
+
model,
|
|
227
|
+
location
|
|
228
|
+
]);
|
|
229
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
230
|
+
ref,
|
|
231
|
+
style: bounds,
|
|
232
|
+
className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
|
|
233
|
+
}, label && /* @__PURE__ */ React2.createElement("div", {
|
|
234
|
+
className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
|
|
235
|
+
}, label));
|
|
236
|
+
});
|
|
237
|
+
Square.displayName = "Square";
|
|
238
|
+
|
|
239
|
+
// src/components/Gameboard/Gameboard.tsx
|
|
240
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Gameboard.tsx";
|
|
241
|
+
var [GameboardContextProvider, useRadixGameboardContext] = createContext("Gameboard");
|
|
242
|
+
var useGameboardContext = (consumerName) => {
|
|
243
|
+
return useRadixGameboardContext(consumerName);
|
|
244
|
+
};
|
|
245
|
+
var GameboardRoot = ({ children, model, moveNumber, onDrop }) => {
|
|
246
|
+
const [dragging, setDragging] = useState3(false);
|
|
247
|
+
const [promoting, setPromoting] = useState3();
|
|
248
|
+
const handlePromotion = useCallback((move) => {
|
|
249
|
+
log3("onPromotion", {
|
|
250
|
+
move
|
|
251
|
+
}, {
|
|
252
|
+
F: __dxlog_file3,
|
|
253
|
+
L: 53,
|
|
254
|
+
S: void 0,
|
|
255
|
+
C: (f, a) => f(...a)
|
|
256
|
+
});
|
|
257
|
+
setPromoting(void 0);
|
|
258
|
+
onDrop?.(move);
|
|
259
|
+
}, []);
|
|
260
|
+
useEffect3(() => {
|
|
261
|
+
if (!model) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
return monitorForElements({
|
|
265
|
+
onDragStart: ({ source }) => {
|
|
266
|
+
log3("onDragStart", {
|
|
267
|
+
source
|
|
268
|
+
}, {
|
|
269
|
+
F: __dxlog_file3,
|
|
270
|
+
L: 66,
|
|
271
|
+
S: void 0,
|
|
272
|
+
C: (f, a) => f(...a)
|
|
273
|
+
});
|
|
274
|
+
setDragging(true);
|
|
275
|
+
},
|
|
276
|
+
onDrop: ({ source, location }) => {
|
|
277
|
+
log3("onDrop", {
|
|
278
|
+
source,
|
|
279
|
+
location
|
|
280
|
+
}, {
|
|
281
|
+
F: __dxlog_file3,
|
|
282
|
+
L: 70,
|
|
283
|
+
S: void 0,
|
|
284
|
+
C: (f, a) => f(...a)
|
|
285
|
+
});
|
|
286
|
+
const target = location.current.dropTargets[0];
|
|
287
|
+
if (!target) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const targetLocation = target.data.location;
|
|
291
|
+
const piece = source.data.piece;
|
|
292
|
+
if (!isLocation(targetLocation) || !isPiece(piece)) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const move = {
|
|
296
|
+
from: piece.location,
|
|
297
|
+
to: targetLocation,
|
|
298
|
+
piece: piece.type
|
|
299
|
+
};
|
|
300
|
+
if (model.isValidMove(move)) {
|
|
98
301
|
if (model.canPromote?.(move)) {
|
|
99
302
|
setPromoting({
|
|
100
303
|
...piece,
|
|
@@ -103,277 +306,42 @@ var GameboardRoot = ({ children, model, onDrop }) => {
|
|
|
103
306
|
} else {
|
|
104
307
|
onDrop?.(move);
|
|
105
308
|
}
|
|
106
|
-
setDragging(false);
|
|
107
309
|
}
|
|
108
|
-
|
|
109
|
-
}, [
|
|
110
|
-
model
|
|
111
|
-
]);
|
|
112
|
-
return /* @__PURE__ */ React.createElement(GameboardContext.Provider, {
|
|
113
|
-
value: {
|
|
114
|
-
model,
|
|
115
|
-
dragging,
|
|
116
|
-
promoting,
|
|
117
|
-
onPromotion
|
|
310
|
+
setDragging(false);
|
|
118
311
|
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
312
|
+
});
|
|
313
|
+
}, [
|
|
314
|
+
model
|
|
315
|
+
]);
|
|
316
|
+
return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
|
|
317
|
+
model,
|
|
318
|
+
dragging,
|
|
319
|
+
promoting,
|
|
320
|
+
onPromotion: handlePromotion
|
|
321
|
+
}, children);
|
|
123
322
|
};
|
|
124
323
|
GameboardRoot.displayName = "Gameboard.Root";
|
|
125
|
-
var GameboardContent = /* @__PURE__ */ forwardRef(({ children, classNames,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
className: mx("max-w-full max-h-full content-center aspect-square", classNames)
|
|
134
|
-
}, children));
|
|
135
|
-
} finally {
|
|
136
|
-
_effect.f();
|
|
137
|
-
}
|
|
324
|
+
var GameboardContent = /* @__PURE__ */ forwardRef(({ children, classNames, grow, contain }, forwardedRef) => {
|
|
325
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
326
|
+
role: "none",
|
|
327
|
+
className: mx3(grow && "grid is-full bs-full size-container place-content-center", classNames),
|
|
328
|
+
ref: forwardedRef
|
|
329
|
+
}, contain ? /* @__PURE__ */ React3.createElement("div", {
|
|
330
|
+
className: "is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]"
|
|
331
|
+
}, children) : children);
|
|
138
332
|
});
|
|
333
|
+
GameboardContent.displayName = "Gameboard.Content";
|
|
139
334
|
var Gameboard = {
|
|
140
335
|
Root: GameboardRoot,
|
|
141
|
-
Content: GameboardContent
|
|
336
|
+
Content: GameboardContent,
|
|
337
|
+
Piece,
|
|
338
|
+
Square
|
|
142
339
|
};
|
|
143
340
|
|
|
144
|
-
// src/
|
|
145
|
-
import {
|
|
146
|
-
import {
|
|
147
|
-
import
|
|
148
|
-
import { invariant } from "@dxos/invariant";
|
|
149
|
-
import { log as log2 } from "@dxos/log";
|
|
150
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
151
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/Gameboard/Square.tsx";
|
|
152
|
-
var Square = /* @__PURE__ */ memo(({ location, bounds, label, classNames }) => {
|
|
153
|
-
var _effect = _useSignals2();
|
|
154
|
-
try {
|
|
155
|
-
const ref = useRef(null);
|
|
156
|
-
const [state, setState] = useState2("idle");
|
|
157
|
-
const { model } = useBoardContext();
|
|
158
|
-
useEffect2(() => {
|
|
159
|
-
const el = ref.current;
|
|
160
|
-
invariant(el, void 0, {
|
|
161
|
-
F: __dxlog_file2,
|
|
162
|
-
L: 32,
|
|
163
|
-
S: void 0,
|
|
164
|
-
A: [
|
|
165
|
-
"el",
|
|
166
|
-
""
|
|
167
|
-
]
|
|
168
|
-
});
|
|
169
|
-
return dropTargetForElements({
|
|
170
|
-
element: el,
|
|
171
|
-
getData: () => ({
|
|
172
|
-
location
|
|
173
|
-
}),
|
|
174
|
-
canDrop: ({ source }) => {
|
|
175
|
-
log2("canDrop", {
|
|
176
|
-
source: source.data
|
|
177
|
-
}, {
|
|
178
|
-
F: __dxlog_file2,
|
|
179
|
-
L: 38,
|
|
180
|
-
S: void 0,
|
|
181
|
-
C: (f, a) => f(...a)
|
|
182
|
-
});
|
|
183
|
-
return true;
|
|
184
|
-
},
|
|
185
|
-
onDragEnter: ({ source }) => {
|
|
186
|
-
log2("onDragEnter", {
|
|
187
|
-
source: source.data
|
|
188
|
-
}, {
|
|
189
|
-
F: __dxlog_file2,
|
|
190
|
-
L: 42,
|
|
191
|
-
S: void 0,
|
|
192
|
-
C: (f, a) => f(...a)
|
|
193
|
-
});
|
|
194
|
-
const piece = source.data.piece;
|
|
195
|
-
if (!isPiece(piece)) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if (model?.isValidMove({
|
|
199
|
-
from: piece.location,
|
|
200
|
-
to: location,
|
|
201
|
-
piece: piece.type
|
|
202
|
-
})) {
|
|
203
|
-
setState("validMove");
|
|
204
|
-
} else {
|
|
205
|
-
setState("invalidMove");
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
onDragLeave: () => setState("idle"),
|
|
209
|
-
onDrop: () => setState("idle")
|
|
210
|
-
});
|
|
211
|
-
}, [
|
|
212
|
-
model,
|
|
213
|
-
location
|
|
214
|
-
]);
|
|
215
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
216
|
-
ref,
|
|
217
|
-
style: bounds,
|
|
218
|
-
className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
|
|
219
|
-
}, label && /* @__PURE__ */ React2.createElement("div", {
|
|
220
|
-
className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
|
|
221
|
-
}, label));
|
|
222
|
-
} finally {
|
|
223
|
-
_effect.f();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
Square.displayName = "Square";
|
|
227
|
-
|
|
228
|
-
// src/Gameboard/Piece.tsx
|
|
229
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
230
|
-
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
231
|
-
import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer";
|
|
232
|
-
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
233
|
-
import React3, { useState as useState3, useRef as useRef2, useEffect as useEffect3, memo as memo2 } from "react";
|
|
234
|
-
import { createPortal } from "react-dom";
|
|
235
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
236
|
-
import { log as log3 } from "@dxos/log";
|
|
237
|
-
import { useDynamicRef, useTrackProps } from "@dxos/react-ui";
|
|
238
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
239
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/Gameboard/Piece.tsx";
|
|
240
|
-
var Piece = /* @__PURE__ */ memo2(({ classNames, piece, orientation, bounds, label, Component }) => {
|
|
241
|
-
var _effect = _useSignals3();
|
|
242
|
-
try {
|
|
243
|
-
useTrackProps({
|
|
244
|
-
classNames,
|
|
245
|
-
piece,
|
|
246
|
-
orientation,
|
|
247
|
-
bounds,
|
|
248
|
-
label,
|
|
249
|
-
Component
|
|
250
|
-
}, Piece.displayName, false);
|
|
251
|
-
const { model } = useBoardContext();
|
|
252
|
-
const { dragging: isDragging, promoting } = useBoardContext();
|
|
253
|
-
const promotingRef = useDynamicRef(promoting);
|
|
254
|
-
const [dragging, setDragging] = useState3(false);
|
|
255
|
-
const [preview, setPreview] = useState3();
|
|
256
|
-
const [current, setCurrent] = useState3({});
|
|
257
|
-
const ref = useRef2(null);
|
|
258
|
-
useEffect3(() => {
|
|
259
|
-
const el = ref.current;
|
|
260
|
-
invariant2(el, void 0, {
|
|
261
|
-
F: __dxlog_file3,
|
|
262
|
-
L: 44,
|
|
263
|
-
S: void 0,
|
|
264
|
-
A: [
|
|
265
|
-
"el",
|
|
266
|
-
""
|
|
267
|
-
]
|
|
268
|
-
});
|
|
269
|
-
return draggable({
|
|
270
|
-
element: el,
|
|
271
|
-
getInitialData: () => ({
|
|
272
|
-
piece
|
|
273
|
-
}),
|
|
274
|
-
onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {
|
|
275
|
-
log3("onGenerateDragPreview", {
|
|
276
|
-
source: source.data
|
|
277
|
-
}, {
|
|
278
|
-
F: __dxlog_file3,
|
|
279
|
-
L: 50,
|
|
280
|
-
S: void 0,
|
|
281
|
-
C: (f, a) => f(...a)
|
|
282
|
-
});
|
|
283
|
-
setCustomNativeDragPreview({
|
|
284
|
-
getOffset: centerUnderPointer,
|
|
285
|
-
// getOffset: preserveOffsetOnSource({
|
|
286
|
-
// element: source.element,
|
|
287
|
-
// input: location.current.input,
|
|
288
|
-
// }),
|
|
289
|
-
render: ({ container }) => {
|
|
290
|
-
setPreview(container);
|
|
291
|
-
const { width, height } = el.getBoundingClientRect();
|
|
292
|
-
container.style.width = width + "px";
|
|
293
|
-
container.style.height = height + "px";
|
|
294
|
-
return () => {
|
|
295
|
-
setPreview(void 0);
|
|
296
|
-
};
|
|
297
|
-
},
|
|
298
|
-
nativeSetDragImage
|
|
299
|
-
});
|
|
300
|
-
},
|
|
301
|
-
canDrag: () => !promotingRef.current && model?.turn === piece.side,
|
|
302
|
-
onDragStart: () => setDragging(true),
|
|
303
|
-
onDrop: ({ location: { current: current2 } }) => {
|
|
304
|
-
const location = current2.dropTargets[0].data.location;
|
|
305
|
-
if (isLocation(location)) {
|
|
306
|
-
setCurrent((current3) => ({
|
|
307
|
-
...current3,
|
|
308
|
-
location
|
|
309
|
-
}));
|
|
310
|
-
}
|
|
311
|
-
setDragging(false);
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}, [
|
|
315
|
-
model,
|
|
316
|
-
piece
|
|
317
|
-
]);
|
|
318
|
-
useEffect3(() => {
|
|
319
|
-
requestAnimationFrame(() => {
|
|
320
|
-
if (!ref.current || !bounds) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if (!current.location || !isEqualLocation(current.location, piece.location)) {
|
|
324
|
-
ref.current.style.transition = "top 400ms ease-out, left 400ms ease-out";
|
|
325
|
-
ref.current.style.top = bounds.top + "px";
|
|
326
|
-
ref.current.style.left = bounds.left + "px";
|
|
327
|
-
setCurrent({
|
|
328
|
-
location: piece.location,
|
|
329
|
-
bounds
|
|
330
|
-
});
|
|
331
|
-
} else if (current.bounds !== bounds) {
|
|
332
|
-
ref.current.style.transition = "none";
|
|
333
|
-
ref.current.style.top = bounds.top + "px";
|
|
334
|
-
ref.current.style.left = bounds.left + "px";
|
|
335
|
-
setCurrent({
|
|
336
|
-
location: piece.location,
|
|
337
|
-
bounds
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
}, [
|
|
342
|
-
current,
|
|
343
|
-
piece.location,
|
|
344
|
-
bounds
|
|
345
|
-
]);
|
|
346
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", {
|
|
347
|
-
ref,
|
|
348
|
-
style: {
|
|
349
|
-
width: bounds?.width,
|
|
350
|
-
height: bounds?.height
|
|
351
|
-
},
|
|
352
|
-
className: mx3(
|
|
353
|
-
"absolute",
|
|
354
|
-
classNames,
|
|
355
|
-
// orientation === 'black' && '_rotate-180',
|
|
356
|
-
dragging && "opacity-20",
|
|
357
|
-
isDragging && "pointer-events-none"
|
|
358
|
-
)
|
|
359
|
-
}, /* @__PURE__ */ React3.createElement(Component, {
|
|
360
|
-
className: "grow"
|
|
361
|
-
}), label && /* @__PURE__ */ React3.createElement("div", {
|
|
362
|
-
className: "absolute inset-1 text-xs text-black"
|
|
363
|
-
}, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React3.createElement("div", {
|
|
364
|
-
className: mx3(classNames)
|
|
365
|
-
}, /* @__PURE__ */ React3.createElement(Component, {
|
|
366
|
-
className: "grow"
|
|
367
|
-
})), preview));
|
|
368
|
-
} finally {
|
|
369
|
-
_effect.f();
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
Piece.displayName = "Piece";
|
|
373
|
-
|
|
374
|
-
// src/Chessboard/chess.ts
|
|
375
|
-
import { signal } from "@preact/signals-core";
|
|
376
|
-
import { Chess, validateFen } from "chess.js";
|
|
341
|
+
// src/components/Chessboard/chess.ts
|
|
342
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
343
|
+
import { Chess as ChessJS } from "chess.js";
|
|
344
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
377
345
|
import { log as log4 } from "@dxos/log";
|
|
378
346
|
|
|
379
347
|
// src/gen/pieces/chess/alpha/index.ts
|
|
@@ -394,280 +362,184 @@ __export(alpha_exports, {
|
|
|
394
362
|
});
|
|
395
363
|
|
|
396
364
|
// src/gen/pieces/chess/alpha/bB.tsx
|
|
397
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
398
365
|
import * as React4 from "react";
|
|
399
|
-
var SvgBB = (props) => {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
fill: "#101010",
|
|
411
|
-
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"
|
|
412
|
-
}));
|
|
413
|
-
} finally {
|
|
414
|
-
_effect.f();
|
|
415
|
-
}
|
|
416
|
-
};
|
|
366
|
+
var SvgBB = (props) => /* @__PURE__ */ React4.createElement("svg", {
|
|
367
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
368
|
+
viewBox: "0 0 2048 2048",
|
|
369
|
+
...props
|
|
370
|
+
}, /* @__PURE__ */ React4.createElement("path", {
|
|
371
|
+
fill: "#f9f9f9",
|
|
372
|
+
d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
|
|
373
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
374
|
+
fill: "#101010",
|
|
375
|
+
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"
|
|
376
|
+
}));
|
|
417
377
|
var bB_default = SvgBB;
|
|
418
378
|
|
|
419
379
|
// src/gen/pieces/chess/alpha/bK.tsx
|
|
420
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
421
380
|
import * as React5 from "react";
|
|
422
|
-
var SvgBK = (props) => {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
fill: "#101010",
|
|
434
|
-
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"
|
|
435
|
-
}));
|
|
436
|
-
} finally {
|
|
437
|
-
_effect.f();
|
|
438
|
-
}
|
|
439
|
-
};
|
|
381
|
+
var SvgBK = (props) => /* @__PURE__ */ React5.createElement("svg", {
|
|
382
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
383
|
+
viewBox: "0 0 2048 2048",
|
|
384
|
+
...props
|
|
385
|
+
}, /* @__PURE__ */ React5.createElement("path", {
|
|
386
|
+
fill: "#f9f9f9",
|
|
387
|
+
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"
|
|
388
|
+
}), /* @__PURE__ */ React5.createElement("path", {
|
|
389
|
+
fill: "#101010",
|
|
390
|
+
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"
|
|
391
|
+
}));
|
|
440
392
|
var bK_default = SvgBK;
|
|
441
393
|
|
|
442
394
|
// src/gen/pieces/chess/alpha/bN.tsx
|
|
443
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
444
395
|
import * as React6 from "react";
|
|
445
|
-
var SvgBN = (props) => {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
fill: "#101010",
|
|
457
|
-
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"
|
|
458
|
-
}));
|
|
459
|
-
} finally {
|
|
460
|
-
_effect.f();
|
|
461
|
-
}
|
|
462
|
-
};
|
|
396
|
+
var SvgBN = (props) => /* @__PURE__ */ React6.createElement("svg", {
|
|
397
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
398
|
+
viewBox: "0 0 2048 2048",
|
|
399
|
+
...props
|
|
400
|
+
}, /* @__PURE__ */ React6.createElement("path", {
|
|
401
|
+
fill: "#f9f9f9",
|
|
402
|
+
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"
|
|
403
|
+
}), /* @__PURE__ */ React6.createElement("path", {
|
|
404
|
+
fill: "#101010",
|
|
405
|
+
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"
|
|
406
|
+
}));
|
|
463
407
|
var bN_default = SvgBN;
|
|
464
408
|
|
|
465
409
|
// src/gen/pieces/chess/alpha/bP.tsx
|
|
466
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
467
410
|
import * as React7 from "react";
|
|
468
|
-
var SvgBP = (props) => {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
fill: "#101010",
|
|
477
|
-
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"
|
|
478
|
-
}));
|
|
479
|
-
} finally {
|
|
480
|
-
_effect.f();
|
|
481
|
-
}
|
|
482
|
-
};
|
|
411
|
+
var SvgBP = (props) => /* @__PURE__ */ React7.createElement("svg", {
|
|
412
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
413
|
+
viewBox: "0 0 2048 2048",
|
|
414
|
+
...props
|
|
415
|
+
}, /* @__PURE__ */ React7.createElement("path", {
|
|
416
|
+
fill: "#101010",
|
|
417
|
+
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"
|
|
418
|
+
}));
|
|
483
419
|
var bP_default = SvgBP;
|
|
484
420
|
|
|
485
421
|
// src/gen/pieces/chess/alpha/bQ.tsx
|
|
486
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
487
422
|
import * as React8 from "react";
|
|
488
|
-
var SvgBQ = (props) => {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
fill: "#101010",
|
|
500
|
-
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"
|
|
501
|
-
}));
|
|
502
|
-
} finally {
|
|
503
|
-
_effect.f();
|
|
504
|
-
}
|
|
505
|
-
};
|
|
423
|
+
var SvgBQ = (props) => /* @__PURE__ */ React8.createElement("svg", {
|
|
424
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
425
|
+
viewBox: "0 0 2048 2048",
|
|
426
|
+
...props
|
|
427
|
+
}, /* @__PURE__ */ React8.createElement("path", {
|
|
428
|
+
fill: "#f9f9f9",
|
|
429
|
+
d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
|
|
430
|
+
}), /* @__PURE__ */ React8.createElement("path", {
|
|
431
|
+
fill: "#101010",
|
|
432
|
+
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"
|
|
433
|
+
}));
|
|
506
434
|
var bQ_default = SvgBQ;
|
|
507
435
|
|
|
508
436
|
// src/gen/pieces/chess/alpha/bR.tsx
|
|
509
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
510
437
|
import * as React9 from "react";
|
|
511
|
-
var SvgBR = (props) => {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
fill: "#101010",
|
|
523
|
-
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"
|
|
524
|
-
}));
|
|
525
|
-
} finally {
|
|
526
|
-
_effect.f();
|
|
527
|
-
}
|
|
528
|
-
};
|
|
438
|
+
var SvgBR = (props) => /* @__PURE__ */ React9.createElement("svg", {
|
|
439
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
440
|
+
viewBox: "0 0 2048 2048",
|
|
441
|
+
...props
|
|
442
|
+
}, /* @__PURE__ */ React9.createElement("path", {
|
|
443
|
+
fill: "#f9f9f9",
|
|
444
|
+
d: "m674 732-76 807 851 14-75-833z"
|
|
445
|
+
}), /* @__PURE__ */ React9.createElement("path", {
|
|
446
|
+
fill: "#101010",
|
|
447
|
+
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"
|
|
448
|
+
}));
|
|
529
449
|
var bR_default = SvgBR;
|
|
530
450
|
|
|
531
451
|
// src/gen/pieces/chess/alpha/wB.tsx
|
|
532
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
533
452
|
import * as React10 from "react";
|
|
534
|
-
var SvgWB = (props) => {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
fill: "#101010",
|
|
546
|
-
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"
|
|
547
|
-
}));
|
|
548
|
-
} finally {
|
|
549
|
-
_effect.f();
|
|
550
|
-
}
|
|
551
|
-
};
|
|
453
|
+
var SvgWB = (props) => /* @__PURE__ */ React10.createElement("svg", {
|
|
454
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
455
|
+
viewBox: "0 0 2048 2048",
|
|
456
|
+
...props
|
|
457
|
+
}, /* @__PURE__ */ React10.createElement("path", {
|
|
458
|
+
fill: "#f9f9f9",
|
|
459
|
+
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"
|
|
460
|
+
}), /* @__PURE__ */ React10.createElement("path", {
|
|
461
|
+
fill: "#101010",
|
|
462
|
+
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"
|
|
463
|
+
}));
|
|
552
464
|
var wB_default = SvgWB;
|
|
553
465
|
|
|
554
466
|
// src/gen/pieces/chess/alpha/wK.tsx
|
|
555
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
556
467
|
import * as React11 from "react";
|
|
557
|
-
var SvgWK = (props) => {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
fill: "#101010",
|
|
569
|
-
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"
|
|
570
|
-
}));
|
|
571
|
-
} finally {
|
|
572
|
-
_effect.f();
|
|
573
|
-
}
|
|
574
|
-
};
|
|
468
|
+
var SvgWK = (props) => /* @__PURE__ */ React11.createElement("svg", {
|
|
469
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
470
|
+
viewBox: "0 0 2048 2048",
|
|
471
|
+
...props
|
|
472
|
+
}, /* @__PURE__ */ React11.createElement("path", {
|
|
473
|
+
fill: "#f9f9f9",
|
|
474
|
+
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"
|
|
475
|
+
}), /* @__PURE__ */ React11.createElement("path", {
|
|
476
|
+
fill: "#101010",
|
|
477
|
+
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"
|
|
478
|
+
}));
|
|
575
479
|
var wK_default = SvgWK;
|
|
576
480
|
|
|
577
481
|
// src/gen/pieces/chess/alpha/wN.tsx
|
|
578
|
-
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
579
482
|
import * as React12 from "react";
|
|
580
|
-
var SvgWN = (props) => {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
fill: "#101010",
|
|
592
|
-
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"
|
|
593
|
-
}));
|
|
594
|
-
} finally {
|
|
595
|
-
_effect.f();
|
|
596
|
-
}
|
|
597
|
-
};
|
|
483
|
+
var SvgWN = (props) => /* @__PURE__ */ React12.createElement("svg", {
|
|
484
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
485
|
+
viewBox: "0 0 2048 2048",
|
|
486
|
+
...props
|
|
487
|
+
}, /* @__PURE__ */ React12.createElement("path", {
|
|
488
|
+
fill: "#f9f9f9",
|
|
489
|
+
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"
|
|
490
|
+
}), /* @__PURE__ */ React12.createElement("path", {
|
|
491
|
+
fill: "#101010",
|
|
492
|
+
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"
|
|
493
|
+
}));
|
|
598
494
|
var wN_default = SvgWN;
|
|
599
495
|
|
|
600
496
|
// src/gen/pieces/chess/alpha/wP.tsx
|
|
601
|
-
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
602
497
|
import * as React13 from "react";
|
|
603
|
-
var SvgWP = (props) => {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
fill: "#101010",
|
|
615
|
-
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"
|
|
616
|
-
}));
|
|
617
|
-
} finally {
|
|
618
|
-
_effect.f();
|
|
619
|
-
}
|
|
620
|
-
};
|
|
498
|
+
var SvgWP = (props) => /* @__PURE__ */ React13.createElement("svg", {
|
|
499
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
500
|
+
viewBox: "0 0 2048 2048",
|
|
501
|
+
...props
|
|
502
|
+
}, /* @__PURE__ */ React13.createElement("path", {
|
|
503
|
+
fill: "#f9f9f9",
|
|
504
|
+
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"
|
|
505
|
+
}), /* @__PURE__ */ React13.createElement("path", {
|
|
506
|
+
fill: "#101010",
|
|
507
|
+
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"
|
|
508
|
+
}));
|
|
621
509
|
var wP_default = SvgWP;
|
|
622
510
|
|
|
623
511
|
// src/gen/pieces/chess/alpha/wQ.tsx
|
|
624
|
-
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
625
512
|
import * as React14 from "react";
|
|
626
|
-
var SvgWQ = (props) => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
fill: "#101010",
|
|
638
|
-
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"
|
|
639
|
-
}));
|
|
640
|
-
} finally {
|
|
641
|
-
_effect.f();
|
|
642
|
-
}
|
|
643
|
-
};
|
|
513
|
+
var SvgWQ = (props) => /* @__PURE__ */ React14.createElement("svg", {
|
|
514
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
515
|
+
viewBox: "0 0 2048 2048",
|
|
516
|
+
...props
|
|
517
|
+
}, /* @__PURE__ */ React14.createElement("path", {
|
|
518
|
+
fill: "#f9f9f9",
|
|
519
|
+
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"
|
|
520
|
+
}), /* @__PURE__ */ React14.createElement("path", {
|
|
521
|
+
fill: "#101010",
|
|
522
|
+
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"
|
|
523
|
+
}));
|
|
644
524
|
var wQ_default = SvgWQ;
|
|
645
525
|
|
|
646
526
|
// src/gen/pieces/chess/alpha/wR.tsx
|
|
647
|
-
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
648
527
|
import * as React15 from "react";
|
|
649
|
-
var SvgWR = (props) => {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
fill: "#101010",
|
|
661
|
-
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"
|
|
662
|
-
}));
|
|
663
|
-
} finally {
|
|
664
|
-
_effect.f();
|
|
665
|
-
}
|
|
666
|
-
};
|
|
528
|
+
var SvgWR = (props) => /* @__PURE__ */ React15.createElement("svg", {
|
|
529
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
530
|
+
viewBox: "0 0 2048 2048",
|
|
531
|
+
...props
|
|
532
|
+
}, /* @__PURE__ */ React15.createElement("path", {
|
|
533
|
+
fill: "#f9f9f9",
|
|
534
|
+
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"
|
|
535
|
+
}), /* @__PURE__ */ React15.createElement("path", {
|
|
536
|
+
fill: "#101010",
|
|
537
|
+
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"
|
|
538
|
+
}));
|
|
667
539
|
var wR_default = SvgWR;
|
|
668
540
|
|
|
669
|
-
// src/Chessboard/chess.ts
|
|
670
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/Chessboard/chess.ts";
|
|
541
|
+
// src/components/Chessboard/chess.ts
|
|
542
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Chessboard/chess.ts";
|
|
671
543
|
var ChessPieces = alpha_exports;
|
|
672
544
|
var posToLocation = (pos) => {
|
|
673
545
|
const col = pos.charCodeAt(0) - "a".charCodeAt(0);
|
|
@@ -680,6 +552,9 @@ var posToLocation = (pos) => {
|
|
|
680
552
|
var locationToPos = ([row, col]) => {
|
|
681
553
|
return String.fromCharCode(col + "a".charCodeAt(0)) + (row + 1);
|
|
682
554
|
};
|
|
555
|
+
var getRawPgn = (pgn) => {
|
|
556
|
+
return pgn.replace(/\[.*?\]/g, "").trim();
|
|
557
|
+
};
|
|
683
558
|
var styles = {
|
|
684
559
|
neutral: {
|
|
685
560
|
black: "bg-neutral-50",
|
|
@@ -706,55 +581,90 @@ var boardStyles = styles.original;
|
|
|
706
581
|
var getSquareColor = ([row, col]) => {
|
|
707
582
|
return (col + row) % 2 === 0 ? boardStyles.black : boardStyles.white;
|
|
708
583
|
};
|
|
709
|
-
var
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
game.move({
|
|
723
|
-
from,
|
|
724
|
-
to,
|
|
725
|
-
promotion
|
|
726
|
-
}, {
|
|
727
|
-
strict: false
|
|
728
|
-
});
|
|
729
|
-
return game;
|
|
730
|
-
} catch (err) {
|
|
731
|
-
return null;
|
|
584
|
+
var createChess = (pgn) => {
|
|
585
|
+
const chess = new ChessJS();
|
|
586
|
+
if (pgn) {
|
|
587
|
+
try {
|
|
588
|
+
chess.loadPgn(pgn);
|
|
589
|
+
} catch {
|
|
590
|
+
log4.warn(pgn, void 0, {
|
|
591
|
+
F: __dxlog_file4,
|
|
592
|
+
L: 76,
|
|
593
|
+
S: void 0,
|
|
594
|
+
C: (f, a) => f(...a)
|
|
595
|
+
});
|
|
596
|
+
}
|
|
732
597
|
}
|
|
598
|
+
return chess;
|
|
733
599
|
};
|
|
734
600
|
var ChessModel = class {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
601
|
+
_registry;
|
|
602
|
+
_chess = new ChessJS();
|
|
603
|
+
_pieces = Atom.make({});
|
|
604
|
+
_moveIndex = Atom.make(0);
|
|
605
|
+
constructor(_registry, pgn) {
|
|
606
|
+
this._registry = _registry;
|
|
607
|
+
this.update(pgn);
|
|
608
|
+
}
|
|
609
|
+
get readonly() {
|
|
610
|
+
return this._registry.get(this._moveIndex) !== this._chess.history().length;
|
|
738
611
|
}
|
|
739
612
|
get turn() {
|
|
740
|
-
return this.
|
|
613
|
+
return this._chess.turn() === "w" ? "white" : "black";
|
|
614
|
+
}
|
|
615
|
+
get game() {
|
|
616
|
+
return this._chess;
|
|
741
617
|
}
|
|
742
618
|
get pieces() {
|
|
743
619
|
return this._pieces;
|
|
744
620
|
}
|
|
745
|
-
get
|
|
746
|
-
return this.
|
|
621
|
+
get moveIndex() {
|
|
622
|
+
return this._moveIndex;
|
|
747
623
|
}
|
|
748
624
|
get fen() {
|
|
749
|
-
return this.
|
|
625
|
+
return this._chess.fen();
|
|
750
626
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
627
|
+
/**
|
|
628
|
+
* PGN with headers.
|
|
629
|
+
*
|
|
630
|
+
* [Event "?"]
|
|
631
|
+
* [Site "?"]
|
|
632
|
+
* [Date "2025.08.05"]
|
|
633
|
+
* [Round "?"]
|
|
634
|
+
* [White "?"]
|
|
635
|
+
* [Black "?"]
|
|
636
|
+
* [Result "*"]
|
|
637
|
+
*/
|
|
638
|
+
// TODO(burdon): Update headers.
|
|
639
|
+
get pgn() {
|
|
640
|
+
return getRawPgn(this._chess.pgn());
|
|
641
|
+
}
|
|
642
|
+
setMoveIndex(index) {
|
|
643
|
+
const temp = new ChessJS();
|
|
644
|
+
const history = this._chess.history({
|
|
645
|
+
verbose: true
|
|
646
|
+
});
|
|
647
|
+
for (let i = 0; i < index && i < history.length; i++) {
|
|
648
|
+
temp.move(history[i]);
|
|
649
|
+
}
|
|
650
|
+
this._updateBoard(temp);
|
|
651
|
+
}
|
|
652
|
+
update(pgn = "") {
|
|
653
|
+
const previous = this._chess.history();
|
|
654
|
+
try {
|
|
655
|
+
this._chess.loadPgn(pgn);
|
|
656
|
+
this._chess.setHeader("Date", createDate());
|
|
657
|
+
this._chess.setHeader("Site", "dxos.org");
|
|
658
|
+
} catch {
|
|
659
|
+
}
|
|
660
|
+
const current = this._chess.history();
|
|
661
|
+
if (!isValidNextMove(previous, current)) {
|
|
662
|
+
this._registry.set(this._pieces, {});
|
|
663
|
+
}
|
|
664
|
+
this._updateBoard(this._chess);
|
|
755
665
|
}
|
|
756
666
|
isValidMove(move) {
|
|
757
|
-
return
|
|
667
|
+
return tryMove(new ChessJS(this._chess.fen()), move) !== null;
|
|
758
668
|
}
|
|
759
669
|
canPromote(move) {
|
|
760
670
|
const isPawnMove = move.piece === "BP" || move.piece === "WP";
|
|
@@ -762,47 +672,104 @@ var ChessModel = class {
|
|
|
762
672
|
return isPawnMove && isToLastRank;
|
|
763
673
|
}
|
|
764
674
|
makeMove(move) {
|
|
765
|
-
const game =
|
|
675
|
+
const game = tryMove(this._chess, move);
|
|
766
676
|
if (!game) {
|
|
767
677
|
return false;
|
|
768
678
|
}
|
|
769
|
-
this.
|
|
770
|
-
this._update();
|
|
679
|
+
this._updateBoard(this._chess);
|
|
771
680
|
return true;
|
|
772
681
|
}
|
|
773
682
|
makeRandomMove() {
|
|
774
|
-
const moves = this.
|
|
683
|
+
const moves = this._chess.moves();
|
|
775
684
|
if (!moves.length) {
|
|
776
685
|
return false;
|
|
777
686
|
}
|
|
778
687
|
const move = moves[Math.floor(Math.random() * moves.length)];
|
|
779
|
-
this.
|
|
780
|
-
this.
|
|
688
|
+
this._chess.move(move);
|
|
689
|
+
this._updateBoard(this._chess);
|
|
781
690
|
return true;
|
|
782
691
|
}
|
|
783
692
|
/**
|
|
784
693
|
* Update pieces preserving identity.
|
|
785
694
|
*/
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
this.
|
|
789
|
-
if (!record) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
const { square, type, color } = record;
|
|
793
|
-
const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
|
|
794
|
-
const location = posToLocation(square);
|
|
795
|
-
pieces[locationToString(location)] = {
|
|
796
|
-
id: `${square}-${pieceType}`,
|
|
797
|
-
type: pieceType,
|
|
798
|
-
side: color === "w" ? "white" : "black",
|
|
799
|
-
location
|
|
800
|
-
};
|
|
801
|
-
}));
|
|
802
|
-
this._pieces.value = mapPieces(this._pieces.value, pieces);
|
|
695
|
+
_updateBoard(chess) {
|
|
696
|
+
this._registry.set(this._pieces, createPieceMap(chess));
|
|
697
|
+
this._registry.set(this._moveIndex, chess.history().length);
|
|
803
698
|
}
|
|
804
699
|
};
|
|
805
|
-
var
|
|
700
|
+
var tryMove = (chess, move) => {
|
|
701
|
+
const from = locationToPos(move.from);
|
|
702
|
+
const to = locationToPos(move.to);
|
|
703
|
+
try {
|
|
704
|
+
const promotion = move.promotion ? move.promotion[1].toLowerCase() : "q";
|
|
705
|
+
chess.move({
|
|
706
|
+
from,
|
|
707
|
+
to,
|
|
708
|
+
promotion
|
|
709
|
+
}, {
|
|
710
|
+
strict: false
|
|
711
|
+
});
|
|
712
|
+
return chess;
|
|
713
|
+
} catch {
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
var isValidNextMove = (previous, current) => {
|
|
718
|
+
if (current.length > previous.length + 1) {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
for (let i = 0; i < previous.length; i++) {
|
|
722
|
+
if (previous[i] !== current[i]) {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return true;
|
|
727
|
+
};
|
|
728
|
+
var createPieceMap = (chess) => {
|
|
729
|
+
const temp = new ChessJS();
|
|
730
|
+
let pieces = _createPieceMap(temp);
|
|
731
|
+
const history = chess.history({
|
|
732
|
+
verbose: true
|
|
733
|
+
});
|
|
734
|
+
for (let i = 0; i < history.length; i++) {
|
|
735
|
+
const move = history[i];
|
|
736
|
+
temp.move(move);
|
|
737
|
+
pieces = _diffPieces(pieces, _createPieceMap(temp));
|
|
738
|
+
const test = /* @__PURE__ */ new Set();
|
|
739
|
+
Object.values(pieces).forEach((piece) => {
|
|
740
|
+
invariant3(!test.has(piece.id), "Duplicate: " + piece.id, {
|
|
741
|
+
F: __dxlog_file4,
|
|
742
|
+
L: 255,
|
|
743
|
+
S: void 0,
|
|
744
|
+
A: [
|
|
745
|
+
"!test.has(piece.id)",
|
|
746
|
+
"'Duplicate: ' + piece.id"
|
|
747
|
+
]
|
|
748
|
+
});
|
|
749
|
+
test.add(piece.id);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
return pieces;
|
|
753
|
+
};
|
|
754
|
+
var _createPieceMap = (chess) => {
|
|
755
|
+
const pieces = {};
|
|
756
|
+
chess.board().flatMap((row) => row.forEach((record) => {
|
|
757
|
+
if (!record) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const { square, type, color } = record;
|
|
761
|
+
const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
|
|
762
|
+
const location = posToLocation(square);
|
|
763
|
+
pieces[locationToString(location)] = {
|
|
764
|
+
id: `${square}-${pieceType}`,
|
|
765
|
+
type: pieceType,
|
|
766
|
+
side: color === "w" ? "white" : "black",
|
|
767
|
+
location
|
|
768
|
+
};
|
|
769
|
+
}));
|
|
770
|
+
return pieces;
|
|
771
|
+
};
|
|
772
|
+
var _diffPieces = (before, after) => {
|
|
806
773
|
const difference = {
|
|
807
774
|
removed: {},
|
|
808
775
|
added: {}
|
|
@@ -825,191 +792,170 @@ var mapPieces = (before, after) => {
|
|
|
825
792
|
piece.id = previous.id;
|
|
826
793
|
}
|
|
827
794
|
}
|
|
828
|
-
log4("delta", {
|
|
829
|
-
before: Object.keys(before).length,
|
|
830
|
-
after: Object.keys(after).length,
|
|
831
|
-
removed: Object.keys(difference.removed).length,
|
|
832
|
-
added: Object.keys(difference.added).length
|
|
833
|
-
}, {
|
|
834
|
-
F: __dxlog_file4,
|
|
835
|
-
L: 205,
|
|
836
|
-
S: void 0,
|
|
837
|
-
C: (f, a) => f(...a)
|
|
838
|
-
});
|
|
839
795
|
return after;
|
|
840
796
|
};
|
|
797
|
+
var createDate = (date = /* @__PURE__ */ new Date()) => date.toISOString().slice(0, 10).replace(/-/g, ".");
|
|
841
798
|
|
|
842
|
-
// src/Chessboard/Chessboard.tsx
|
|
843
|
-
import {
|
|
844
|
-
import React16, {
|
|
799
|
+
// src/components/Chessboard/Chessboard.tsx
|
|
800
|
+
import { Atom as Atom2, useAtomValue } from "@effect-atom/atom-react";
|
|
801
|
+
import React16, { forwardRef as forwardRef2, memo as memo3, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState4 } from "react";
|
|
845
802
|
import { useResizeDetector } from "react-resize-detector";
|
|
846
|
-
import {
|
|
847
|
-
import { mx as mx4 } from "@dxos/
|
|
848
|
-
import {
|
|
849
|
-
var
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
878
|
-
key: locationToString(location),
|
|
879
|
-
["data-location"]: locationToString(location)
|
|
880
|
-
});
|
|
803
|
+
import { useForwardedRef } from "@dxos/react-ui";
|
|
804
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
805
|
+
import { isNonNullable } from "@dxos/util";
|
|
806
|
+
var EMPTY_PIECES_ATOM = Atom2.make({});
|
|
807
|
+
var ChessboardComponent = /* @__PURE__ */ forwardRef2(({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
|
|
808
|
+
const targetRef = useForwardedRef(forwardedRef);
|
|
809
|
+
const { width, height } = useResizeDetector({
|
|
810
|
+
targetRef,
|
|
811
|
+
refreshRate: 200
|
|
812
|
+
});
|
|
813
|
+
const { model, promoting, onPromotion } = useGameboardContext(Chessboard.displayName);
|
|
814
|
+
const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
|
|
815
|
+
const squares = useMemo(() => {
|
|
816
|
+
return Array.from({
|
|
817
|
+
length: rows
|
|
818
|
+
}, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
|
|
819
|
+
length: cols
|
|
820
|
+
}).map((_, col) => [
|
|
821
|
+
row,
|
|
822
|
+
col
|
|
823
|
+
]));
|
|
824
|
+
}, [
|
|
825
|
+
orientation,
|
|
826
|
+
rows,
|
|
827
|
+
cols
|
|
828
|
+
]);
|
|
829
|
+
const layout = useMemo(() => {
|
|
830
|
+
return squares.map((location) => {
|
|
831
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
832
|
+
key: locationToString(location),
|
|
833
|
+
["data-location"]: locationToString(location)
|
|
881
834
|
});
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
},
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const bounds = grid[locationToString(piece.location)];
|
|
910
|
-
return {
|
|
911
|
-
piece,
|
|
912
|
-
bounds
|
|
913
|
-
};
|
|
914
|
-
}).filter(isNotFalsy);
|
|
915
|
-
}, [
|
|
916
|
-
grid,
|
|
917
|
-
model?.pieces.value,
|
|
918
|
-
promoting
|
|
919
|
-
]);
|
|
920
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
921
|
-
ref: containerRef,
|
|
922
|
-
className: mx4("relative", classNames)
|
|
923
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
924
|
-
ref: gridRef,
|
|
925
|
-
className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
|
|
926
|
-
}, layout), /* @__PURE__ */ React16.createElement("div", null, locations.map((location) => /* @__PURE__ */ React16.createElement(Square, {
|
|
927
|
-
key: locationToString(location),
|
|
928
|
-
location,
|
|
929
|
-
label: showLabels ? locationToPos(location) : void 0,
|
|
930
|
-
bounds: grid[locationToString(location)],
|
|
931
|
-
classNames: getSquareColor(location)
|
|
932
|
-
}))), /* @__PURE__ */ React16.createElement("div", {
|
|
933
|
-
className: mx4(promoting && "opacity-50")
|
|
934
|
-
}, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Piece, {
|
|
935
|
-
key: piece.id,
|
|
936
|
-
piece,
|
|
937
|
-
bounds,
|
|
938
|
-
label: debug ? piece.id : void 0,
|
|
939
|
-
orientation,
|
|
940
|
-
Component: ChessPieces[piece.type]
|
|
941
|
-
}))), /* @__PURE__ */ React16.createElement("div", null, promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
|
|
942
|
-
grid,
|
|
943
|
-
piece: promoting,
|
|
944
|
-
onSelect: (piece) => {
|
|
945
|
-
onPromotion({
|
|
946
|
-
from: Object.values(model.pieces.value).find((p) => p.id === promoting.id).location,
|
|
947
|
-
to: piece.location,
|
|
948
|
-
piece: promoting.type,
|
|
949
|
-
promotion: piece.type
|
|
950
|
-
});
|
|
835
|
+
});
|
|
836
|
+
}, [
|
|
837
|
+
squares
|
|
838
|
+
]);
|
|
839
|
+
const [grid, setGrid] = useState4({});
|
|
840
|
+
const gridRef = useRef3(null);
|
|
841
|
+
useEffect4(() => {
|
|
842
|
+
setGrid(squares.reduce((acc, location) => {
|
|
843
|
+
const square = getSquareLocation(gridRef.current, location);
|
|
844
|
+
const bounds = getRelativeBounds(gridRef.current, square);
|
|
845
|
+
return {
|
|
846
|
+
...acc,
|
|
847
|
+
[locationToString(location)]: bounds
|
|
848
|
+
};
|
|
849
|
+
}, {}));
|
|
850
|
+
}, [
|
|
851
|
+
squares,
|
|
852
|
+
width,
|
|
853
|
+
height
|
|
854
|
+
]);
|
|
855
|
+
const positions = useMemo(() => {
|
|
856
|
+
if (!gridRef.current) {
|
|
857
|
+
return [];
|
|
858
|
+
}
|
|
859
|
+
return Object.values(pieces).map((piece) => {
|
|
860
|
+
if (piece.id === promoting?.id) {
|
|
861
|
+
return null;
|
|
951
862
|
}
|
|
952
|
-
|
|
953
|
-
} finally {
|
|
954
|
-
_effect.f();
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
Chessboard.displayName = "Chessboard";
|
|
958
|
-
var getSquareLocation = (container, location) => {
|
|
959
|
-
return container.querySelector(`[data-location="${locationToString(location)}"]`);
|
|
960
|
-
};
|
|
961
|
-
var PromotionSelector = ({ grid, piece, onSelect }) => {
|
|
962
|
-
var _effect = _useSignals16();
|
|
963
|
-
try {
|
|
964
|
-
const positions = [
|
|
965
|
-
"Q",
|
|
966
|
-
"N",
|
|
967
|
-
"R",
|
|
968
|
-
"B"
|
|
969
|
-
].map((pieceType, i) => {
|
|
970
|
-
const location = [
|
|
971
|
-
piece.location[0] + (piece.location[0] === 0 ? i : -i),
|
|
972
|
-
piece.location[1]
|
|
973
|
-
];
|
|
863
|
+
const bounds = grid[locationToString(piece.location)];
|
|
974
864
|
return {
|
|
975
|
-
piece
|
|
976
|
-
|
|
977
|
-
type: (piece.side === "black" ? "B" : "W") + pieceType,
|
|
978
|
-
side: piece.side,
|
|
979
|
-
location
|
|
980
|
-
},
|
|
981
|
-
bounds: grid[locationToString(location)]
|
|
865
|
+
piece,
|
|
866
|
+
bounds
|
|
982
867
|
};
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
868
|
+
}).filter(isNonNullable);
|
|
869
|
+
}, [
|
|
870
|
+
grid,
|
|
871
|
+
pieces,
|
|
872
|
+
promoting
|
|
873
|
+
]);
|
|
874
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
875
|
+
ref: targetRef,
|
|
876
|
+
tabIndex: 0,
|
|
877
|
+
className: mx4("relative outline-none", classNames)
|
|
878
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
879
|
+
ref: gridRef,
|
|
880
|
+
className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
|
|
881
|
+
}, layout), /* @__PURE__ */ React16.createElement("div", null, squares.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
|
|
882
|
+
key: locationToString(location),
|
|
883
|
+
location,
|
|
884
|
+
label: showLabels ? locationToPos(location) : void 0,
|
|
885
|
+
bounds: grid[locationToString(location)],
|
|
886
|
+
classNames: getSquareColor(location)
|
|
887
|
+
}))), /* @__PURE__ */ React16.createElement("div", {
|
|
888
|
+
className: mx4(promoting && "opacity-50")
|
|
889
|
+
}, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
|
|
890
|
+
key: piece.id,
|
|
891
|
+
piece,
|
|
892
|
+
bounds,
|
|
893
|
+
label: debug ? piece.id : void 0,
|
|
894
|
+
orientation,
|
|
895
|
+
Component: ChessPieces[piece.type]
|
|
896
|
+
}))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
|
|
897
|
+
grid,
|
|
898
|
+
piece: promoting,
|
|
899
|
+
onSelect: (piece) => {
|
|
900
|
+
onPromotion({
|
|
901
|
+
from: Object.values(pieces).find((p) => p.id === promoting.id).location,
|
|
902
|
+
to: piece.location,
|
|
903
|
+
piece: promoting.type,
|
|
904
|
+
promotion: piece.type
|
|
988
905
|
});
|
|
906
|
+
}
|
|
907
|
+
}));
|
|
908
|
+
});
|
|
909
|
+
ChessboardComponent.displayName = "Chessboard";
|
|
910
|
+
var Chessboard = /* @__PURE__ */ memo3(ChessboardComponent);
|
|
911
|
+
var PromotionSelector = ({ grid, piece, onSelect }) => {
|
|
912
|
+
const positions = [
|
|
913
|
+
"Q",
|
|
914
|
+
"N",
|
|
915
|
+
"R",
|
|
916
|
+
"B"
|
|
917
|
+
].map((pieceType, i) => {
|
|
918
|
+
const location = [
|
|
919
|
+
piece.location[0] + (piece.location[0] === 0 ? i : -i),
|
|
920
|
+
piece.location[1]
|
|
921
|
+
];
|
|
922
|
+
return {
|
|
923
|
+
piece: {
|
|
924
|
+
id: `promotion-${pieceType}`,
|
|
925
|
+
type: (piece.side === "black" ? "B" : "W") + pieceType,
|
|
926
|
+
side: piece.side,
|
|
927
|
+
location
|
|
928
|
+
},
|
|
929
|
+
bounds: grid[locationToString(location)]
|
|
989
930
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
931
|
+
});
|
|
932
|
+
const handleSelect = (selected) => {
|
|
933
|
+
onSelect({
|
|
934
|
+
...piece,
|
|
935
|
+
type: selected.type
|
|
936
|
+
});
|
|
937
|
+
};
|
|
938
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
|
|
939
|
+
key: piece2.id,
|
|
940
|
+
classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
|
|
941
|
+
piece: piece2,
|
|
942
|
+
bounds,
|
|
943
|
+
Component: ChessPieces[piece2.type],
|
|
944
|
+
onClick: () => handleSelect(piece2)
|
|
945
|
+
})));
|
|
946
|
+
};
|
|
947
|
+
var getSquareLocation = (container, location) => {
|
|
948
|
+
return container.querySelector(`[data-location="${locationToString(location)}"]`);
|
|
1003
949
|
};
|
|
1004
950
|
export {
|
|
1005
951
|
ChessModel,
|
|
1006
952
|
ChessPieces,
|
|
1007
953
|
Chessboard,
|
|
1008
954
|
Gameboard,
|
|
1009
|
-
GameboardContext,
|
|
1010
|
-
Piece,
|
|
1011
|
-
Square,
|
|
1012
955
|
boardStyles,
|
|
956
|
+
createChess,
|
|
957
|
+
createPieceMap,
|
|
958
|
+
getRawPgn,
|
|
1013
959
|
getRelativeBounds,
|
|
1014
960
|
getSquareColor,
|
|
1015
961
|
isEqualLocation,
|
|
@@ -1017,9 +963,8 @@ export {
|
|
|
1017
963
|
isPiece,
|
|
1018
964
|
locationToPos,
|
|
1019
965
|
locationToString,
|
|
1020
|
-
mapPieces,
|
|
1021
966
|
posToLocation,
|
|
1022
967
|
stringToLocation,
|
|
1023
|
-
|
|
968
|
+
useGameboardContext
|
|
1024
969
|
};
|
|
1025
970
|
//# sourceMappingURL=index.mjs.map
|