gigaboard 1.5.4 → 1.7.0
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 +18 -0
- package/dist/chunk-GL2OZMOW.js +79 -0
- package/dist/chunk-GL2OZMOW.js.map +1 -0
- package/dist/chunk-KTL53IC3.cjs +82 -0
- package/dist/chunk-KTL53IC3.cjs.map +1 -0
- package/dist/{chunk-FUP2LDMO.cjs → chunk-MCD4AIR2.cjs} +11 -3
- package/dist/chunk-MCD4AIR2.cjs.map +1 -0
- package/dist/{chunk-6F3FZAG7.js → chunk-SOM6XGJO.js} +11 -3
- package/dist/chunk-SOM6XGJO.js.map +1 -0
- package/dist/core.cjs +51 -51
- package/dist/core.js +1 -1
- package/dist/index.cjs +161 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +101 -24
- package/dist/index.js.map +1 -1
- package/dist/pieces/giga-diagram.cjs +17 -0
- package/dist/pieces/giga-diagram.cjs.map +1 -0
- package/dist/pieces/giga-diagram.d.cts +11 -0
- package/dist/pieces/giga-diagram.d.ts +11 -0
- package/dist/pieces/giga-diagram.js +4 -0
- package/dist/pieces/giga-diagram.js.map +1 -0
- package/dist/pieces-svg/giga-diagram/bB.svg +23 -0
- package/dist/pieces-svg/giga-diagram/bK.svg +23 -0
- package/dist/pieces-svg/giga-diagram/bN.svg +20 -0
- package/dist/pieces-svg/giga-diagram/bP.svg +23 -0
- package/dist/pieces-svg/giga-diagram/bQ.svg +35 -0
- package/dist/pieces-svg/giga-diagram/bR.svg +20 -0
- package/dist/pieces-svg/giga-diagram/wB.svg +23 -0
- package/dist/pieces-svg/giga-diagram/wK.svg +23 -0
- package/dist/pieces-svg/giga-diagram/wN.svg +20 -0
- package/dist/pieces-svg/giga-diagram/wP.svg +23 -0
- package/dist/pieces-svg/giga-diagram/wQ.svg +35 -0
- package/dist/pieces-svg/giga-diagram/wR.svg +20 -0
- package/dist/pieces.cjs +7 -1
- package/dist/pieces.cjs.map +1 -1
- package/dist/pieces.d.cts +2 -0
- package/dist/pieces.d.ts +2 -0
- package/dist/pieces.js +4 -1
- package/dist/pieces.js.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/themes.cjs +13 -13
- package/dist/themes.js +6 -6
- package/dist/{types-Dox7oLof.d.cts → types-nvS4NLgA.d.cts} +49 -9
- package/dist/{types-4W8ULiE2.d.ts → types-pfl2aAFu.d.ts} +49 -9
- package/package.json +2 -2
- package/dist/chunk-6F3FZAG7.js.map +0 -1
- package/dist/chunk-FUP2LDMO.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMCD4AIR2_cjs = require('./chunk-MCD4AIR2.cjs');
|
|
4
4
|
var chunkN4WTPXFC_cjs = require('./chunk-N4WTPXFC.cjs');
|
|
5
5
|
require('./chunk-G6ZFOJZR.cjs');
|
|
6
6
|
require('./chunk-AYVQCHSG.cjs');
|
|
@@ -245,29 +245,29 @@ function defaultSquareLabel(square, cell) {
|
|
|
245
245
|
function cellFromKey(key) {
|
|
246
246
|
switch (key) {
|
|
247
247
|
case "P":
|
|
248
|
-
return
|
|
248
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WP;
|
|
249
249
|
case "N":
|
|
250
|
-
return
|
|
250
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WN;
|
|
251
251
|
case "B":
|
|
252
|
-
return
|
|
252
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WB;
|
|
253
253
|
case "R":
|
|
254
|
-
return
|
|
254
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WR;
|
|
255
255
|
case "Q":
|
|
256
|
-
return
|
|
256
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WQ;
|
|
257
257
|
case "K":
|
|
258
|
-
return
|
|
258
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_WK;
|
|
259
259
|
case "p":
|
|
260
|
-
return
|
|
260
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BP;
|
|
261
261
|
case "n":
|
|
262
|
-
return
|
|
262
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BN;
|
|
263
263
|
case "b":
|
|
264
|
-
return
|
|
264
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BB;
|
|
265
265
|
case "r":
|
|
266
|
-
return
|
|
266
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BR;
|
|
267
267
|
case "q":
|
|
268
|
-
return
|
|
268
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BQ;
|
|
269
269
|
case "k":
|
|
270
|
-
return
|
|
270
|
+
return chunkMCD4AIR2_cjs.BOARD_CELL_BK;
|
|
271
271
|
default:
|
|
272
272
|
return 0;
|
|
273
273
|
}
|
|
@@ -1762,7 +1762,7 @@ function pieceName(cell) {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
}
|
|
1764
1764
|
function announcementFor(lastMove, board, wasCapture) {
|
|
1765
|
-
const { from, to, kind, promotion } =
|
|
1765
|
+
const { from, to, kind, promotion } = chunkMCD4AIR2_cjs.decodePackedMove(lastMove);
|
|
1766
1766
|
if (kind === "pass") return "Passes.";
|
|
1767
1767
|
if (kind === "castle") {
|
|
1768
1768
|
const isKingside = (to & 7) > (from & 7);
|
|
@@ -1918,20 +1918,20 @@ function positionOf4(index, orientation) {
|
|
|
1918
1918
|
return { x: col * 12.5, y: row * 12.5 };
|
|
1919
1919
|
}
|
|
1920
1920
|
var CHOICE_ORDER = [
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1921
|
+
chunkMCD4AIR2_cjs.PieceType.Queen,
|
|
1922
|
+
chunkMCD4AIR2_cjs.PieceType.Knight,
|
|
1923
|
+
chunkMCD4AIR2_cjs.PieceType.Rook,
|
|
1924
|
+
chunkMCD4AIR2_cjs.PieceType.Bishop
|
|
1925
1925
|
];
|
|
1926
1926
|
var SHORTCUTS = {
|
|
1927
|
-
q:
|
|
1928
|
-
r:
|
|
1929
|
-
b:
|
|
1930
|
-
n:
|
|
1931
|
-
Q:
|
|
1932
|
-
R:
|
|
1933
|
-
B:
|
|
1934
|
-
N:
|
|
1927
|
+
q: chunkMCD4AIR2_cjs.PieceType.Queen,
|
|
1928
|
+
r: chunkMCD4AIR2_cjs.PieceType.Rook,
|
|
1929
|
+
b: chunkMCD4AIR2_cjs.PieceType.Bishop,
|
|
1930
|
+
n: chunkMCD4AIR2_cjs.PieceType.Knight,
|
|
1931
|
+
Q: chunkMCD4AIR2_cjs.PieceType.Queen,
|
|
1932
|
+
R: chunkMCD4AIR2_cjs.PieceType.Rook,
|
|
1933
|
+
B: chunkMCD4AIR2_cjs.PieceType.Bishop,
|
|
1934
|
+
N: chunkMCD4AIR2_cjs.PieceType.Knight
|
|
1935
1935
|
};
|
|
1936
1936
|
function PromotionOverlay({
|
|
1937
1937
|
from: _from,
|
|
@@ -1949,7 +1949,7 @@ function PromotionOverlay({
|
|
|
1949
1949
|
[getPromotionPieceAriaLabel, color]
|
|
1950
1950
|
);
|
|
1951
1951
|
const [activeAnnouncement, setActiveAnnouncement] = react.useState(
|
|
1952
|
-
() => getLabel(CHOICE_ORDER[0] ??
|
|
1952
|
+
() => getLabel(CHOICE_ORDER[0] ?? chunkMCD4AIR2_cjs.PieceType.Queen)
|
|
1953
1953
|
);
|
|
1954
1954
|
react.useEffect(() => {
|
|
1955
1955
|
buttonRefs.current[0]?.focus();
|
|
@@ -2047,7 +2047,7 @@ function PromotionOverlay({
|
|
|
2047
2047
|
overflow: "hidden"
|
|
2048
2048
|
},
|
|
2049
2049
|
children: CHOICE_ORDER.map((piece, index) => {
|
|
2050
|
-
const cell =
|
|
2050
|
+
const cell = chunkMCD4AIR2_cjs.encodeBoardCell(color, piece);
|
|
2051
2051
|
const label = getLabel(piece);
|
|
2052
2052
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2053
2053
|
"button",
|
|
@@ -2099,13 +2099,13 @@ var srOnlyStyle2 = {
|
|
|
2099
2099
|
};
|
|
2100
2100
|
function pieceName2(t) {
|
|
2101
2101
|
switch (t) {
|
|
2102
|
-
case
|
|
2102
|
+
case chunkMCD4AIR2_cjs.PieceType.Queen:
|
|
2103
2103
|
return "Queen";
|
|
2104
|
-
case
|
|
2104
|
+
case chunkMCD4AIR2_cjs.PieceType.Rook:
|
|
2105
2105
|
return "Rook";
|
|
2106
|
-
case
|
|
2106
|
+
case chunkMCD4AIR2_cjs.PieceType.Bishop:
|
|
2107
2107
|
return "Bishop";
|
|
2108
|
-
case
|
|
2108
|
+
case chunkMCD4AIR2_cjs.PieceType.Knight:
|
|
2109
2109
|
return "Knight";
|
|
2110
2110
|
default:
|
|
2111
2111
|
return "Piece";
|
|
@@ -2352,7 +2352,7 @@ function useArrowGesture(options) {
|
|
|
2352
2352
|
function wouldPromote(fromCell, toIndex) {
|
|
2353
2353
|
if (fromCell === 0) return false;
|
|
2354
2354
|
const pieceType = (fromCell - 1) % 6;
|
|
2355
|
-
if (pieceType !==
|
|
2355
|
+
if (pieceType !== chunkMCD4AIR2_cjs.PieceType.Pawn) return false;
|
|
2356
2356
|
const toRank = toIndex >> 3;
|
|
2357
2357
|
return toRank === 0 || toRank === 7;
|
|
2358
2358
|
}
|
|
@@ -2363,7 +2363,7 @@ function useClickToMove(model, onMove, onPromotionNeeded, enabled = true) {
|
|
|
2363
2363
|
if (model === null) return;
|
|
2364
2364
|
const snap = model.getSnapshot();
|
|
2365
2365
|
const cell = snap.board[index] ?? 0;
|
|
2366
|
-
const pieceColour = cell === 0 ? -1 : cell > 6 ?
|
|
2366
|
+
const pieceColour = cell === 0 ? -1 : cell > 6 ? chunkMCD4AIR2_cjs.Color.Black : chunkMCD4AIR2_cjs.Color.White;
|
|
2367
2367
|
if (snap.selected === null) {
|
|
2368
2368
|
if (pieceColour === snap.turn) model.selectSquare(index);
|
|
2369
2369
|
return;
|
|
@@ -2379,7 +2379,7 @@ function useClickToMove(model, onMove, onPromotionNeeded, enabled = true) {
|
|
|
2379
2379
|
onPromotionNeeded(snap.selected, index);
|
|
2380
2380
|
return;
|
|
2381
2381
|
}
|
|
2382
|
-
const played2 = model.tryMove(snap.selected, index,
|
|
2382
|
+
const played2 = model.tryMove(snap.selected, index, chunkMCD4AIR2_cjs.PieceType.Queen);
|
|
2383
2383
|
if (played2 !== null && onMove !== void 0) onMove(played2);
|
|
2384
2384
|
return;
|
|
2385
2385
|
}
|
|
@@ -2500,6 +2500,7 @@ function useDrag(options) {
|
|
|
2500
2500
|
dragLayerRef,
|
|
2501
2501
|
enabled,
|
|
2502
2502
|
activationDistance,
|
|
2503
|
+
pickupOnPointerDown = false,
|
|
2503
2504
|
onDragStart,
|
|
2504
2505
|
onDragEnd,
|
|
2505
2506
|
onDrop,
|
|
@@ -2513,8 +2514,8 @@ function useDrag(options) {
|
|
|
2513
2514
|
if (!enabled) return;
|
|
2514
2515
|
const container = containerRef.current;
|
|
2515
2516
|
if (container === null || game === null) return;
|
|
2516
|
-
|
|
2517
|
-
activationDistance ===
|
|
2517
|
+
let controller = chunkMCD4AIR2_cjs.createDragController(
|
|
2518
|
+
typeof activationDistance === "number" ? { activationDistance } : {}
|
|
2518
2519
|
);
|
|
2519
2520
|
let originEl = null;
|
|
2520
2521
|
let active = false;
|
|
@@ -2541,6 +2542,16 @@ function useDrag(options) {
|
|
|
2541
2542
|
activePointerId = null;
|
|
2542
2543
|
onDragEnd();
|
|
2543
2544
|
};
|
|
2545
|
+
const showDragGhost = (from, cell, x, y) => {
|
|
2546
|
+
const originLabel = algebraicOf2(from);
|
|
2547
|
+
originEl = container.querySelector(`[data-piece-square="${originLabel}"]`);
|
|
2548
|
+
if (originEl !== null) {
|
|
2549
|
+
originEl.style.opacity = `var(${GHOST_OPACITY_VAR}, 0.35)`;
|
|
2550
|
+
}
|
|
2551
|
+
active = true;
|
|
2552
|
+
dragLayerRef.current?.show(cell);
|
|
2553
|
+
writeTransform(x, y);
|
|
2554
|
+
};
|
|
2544
2555
|
const onPointerDown = (e) => {
|
|
2545
2556
|
if (e.button !== 0) return;
|
|
2546
2557
|
const sq = getSquareAtPoint(container, e.clientX, e.clientY, orientation);
|
|
@@ -2551,30 +2562,40 @@ function useDrag(options) {
|
|
|
2551
2562
|
if (canDrag !== void 0 && !canDrag({ square: sq, cell })) {
|
|
2552
2563
|
return;
|
|
2553
2564
|
}
|
|
2565
|
+
if (activationDistance === "adaptive" && controller.state.kind === "idle") {
|
|
2566
|
+
controller = chunkMCD4AIR2_cjs.createDragController({
|
|
2567
|
+
activationDistance: e.pointerType === "touch" ? 6 : 2
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2554
2570
|
const consumed = controller.pointerDown(sq, e.pointerId, e.clientX, e.clientY);
|
|
2555
|
-
if (consumed)
|
|
2571
|
+
if (consumed) {
|
|
2572
|
+
activePointerId = e.pointerId;
|
|
2573
|
+
if (pickupOnPointerDown) {
|
|
2574
|
+
showDragGhost(sq, cell, e.clientX, e.clientY);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2556
2577
|
};
|
|
2557
2578
|
const onPointerMove = (e) => {
|
|
2558
2579
|
const evt = controller.pointerMove(e.pointerId, e.clientX, e.clientY);
|
|
2559
|
-
if (evt === null)
|
|
2580
|
+
if (evt === null) {
|
|
2581
|
+
if (active && pickupOnPointerDown && activePointerId === e.pointerId) {
|
|
2582
|
+
writeTransform(e.clientX, e.clientY);
|
|
2583
|
+
}
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2560
2586
|
if (evt.kind === "drag-start") {
|
|
2561
2587
|
const cell = game.getSnapshot().board[evt.from] ?? 0;
|
|
2562
2588
|
if (cell === 0) {
|
|
2563
2589
|
controller.cancel();
|
|
2590
|
+
if (active) cleanup();
|
|
2564
2591
|
return;
|
|
2565
2592
|
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
if (originEl !== null) {
|
|
2569
|
-
originEl.style.opacity = `var(${GHOST_OPACITY_VAR}, 0.35)`;
|
|
2570
|
-
}
|
|
2571
|
-
active = true;
|
|
2593
|
+
if (!active) showDragGhost(evt.from, cell, e.clientX, e.clientY);
|
|
2594
|
+
else writeTransform(e.clientX, e.clientY);
|
|
2572
2595
|
try {
|
|
2573
2596
|
container.setPointerCapture(e.pointerId);
|
|
2574
2597
|
} catch {
|
|
2575
2598
|
}
|
|
2576
|
-
dragLayerRef.current?.show(cell);
|
|
2577
|
-
writeTransform(e.clientX, e.clientY);
|
|
2578
2599
|
onDragStart(evt.from, cell);
|
|
2579
2600
|
return;
|
|
2580
2601
|
}
|
|
@@ -2616,6 +2637,7 @@ function useDrag(options) {
|
|
|
2616
2637
|
dragLayerRef,
|
|
2617
2638
|
enabled,
|
|
2618
2639
|
activationDistance,
|
|
2640
|
+
pickupOnPointerDown,
|
|
2619
2641
|
onDragStart,
|
|
2620
2642
|
onDragEnd,
|
|
2621
2643
|
onDrop
|
|
@@ -2812,7 +2834,7 @@ function useLastMoveController(model, squareRefs, enabled) {
|
|
|
2812
2834
|
const lastMove = snap.lastMove;
|
|
2813
2835
|
let from = null;
|
|
2814
2836
|
let to = null;
|
|
2815
|
-
if (lastMove !== null && !
|
|
2837
|
+
if (lastMove !== null && !chunkMCD4AIR2_cjs.isNullMove(lastMove)) {
|
|
2816
2838
|
from = lastMove & 63;
|
|
2817
2839
|
to = lastMove >> 6 & 63;
|
|
2818
2840
|
}
|
|
@@ -2904,8 +2926,8 @@ var DEFAULT_MOVE_HAPTIC_PATTERNS = Object.freeze({
|
|
|
2904
2926
|
promote: "success",
|
|
2905
2927
|
gameEnd: "success"
|
|
2906
2928
|
});
|
|
2907
|
-
function classifyMoveFeedback(animations, snapshot, perspective) {
|
|
2908
|
-
if (snapshot.isGameOver) return "gameEnd";
|
|
2929
|
+
function classifyMoveFeedback(animations, snapshot, perspective, cuePolicy = "default") {
|
|
2930
|
+
if (cuePolicy === "default" && snapshot.isGameOver) return "gameEnd";
|
|
2909
2931
|
let sawPromotion = false;
|
|
2910
2932
|
let sawCastle = false;
|
|
2911
2933
|
let sawCapture = false;
|
|
@@ -2914,6 +2936,7 @@ function classifyMoveFeedback(animations, snapshot, perspective) {
|
|
|
2914
2936
|
else if (d.kind === "castle") sawCastle = true;
|
|
2915
2937
|
else if (d.kind === "capture" || d.kind === "en-passant") sawCapture = true;
|
|
2916
2938
|
}
|
|
2939
|
+
if (cuePolicy === "san-priority" && sawCapture) return "capture";
|
|
2917
2940
|
if (sawPromotion) return "promote";
|
|
2918
2941
|
if (sawCastle) return "castle";
|
|
2919
2942
|
if (snapshot.inCheck) return "moveCheck";
|
|
@@ -3051,10 +3074,22 @@ function createPools(sources, preload) {
|
|
|
3051
3074
|
return pools;
|
|
3052
3075
|
}
|
|
3053
3076
|
function useMoveSound(model, options = {}) {
|
|
3054
|
-
const {
|
|
3077
|
+
const {
|
|
3078
|
+
enabled = true,
|
|
3079
|
+
volume = 1,
|
|
3080
|
+
preload = "none",
|
|
3081
|
+
prewarm = false,
|
|
3082
|
+
onCue,
|
|
3083
|
+
trigger = "model",
|
|
3084
|
+
cuePolicy = "default",
|
|
3085
|
+
sources,
|
|
3086
|
+
perspective
|
|
3087
|
+
} = options;
|
|
3055
3088
|
const poolsRef = react.useRef(null);
|
|
3056
3089
|
const sourcesRef = react.useRef(DEFAULT_MOVE_SOUND_SOURCES);
|
|
3057
3090
|
const preloadRef = react.useRef(preload);
|
|
3091
|
+
const onCueRef = react.useRef(onCue);
|
|
3092
|
+
onCueRef.current = onCue;
|
|
3058
3093
|
const volumeRef = react.useRef(volume);
|
|
3059
3094
|
react.useEffect(() => {
|
|
3060
3095
|
volumeRef.current = volume;
|
|
@@ -3079,10 +3114,25 @@ function useMoveSound(model, options = {}) {
|
|
|
3079
3114
|
poolsRef.current = null;
|
|
3080
3115
|
}
|
|
3081
3116
|
}, [enabled]);
|
|
3117
|
+
react.useEffect(() => {
|
|
3118
|
+
if (!enabled || !prewarm || onCue) return;
|
|
3119
|
+
if (typeof window === "undefined" || typeof Audio === "undefined") return;
|
|
3120
|
+
if (poolsRef.current === null) {
|
|
3121
|
+
poolsRef.current = createPools(
|
|
3122
|
+
{ ...DEFAULT_MOVE_SOUND_SOURCES, ...sources ?? {} },
|
|
3123
|
+
preload
|
|
3124
|
+
);
|
|
3125
|
+
}
|
|
3126
|
+
}, [enabled, prewarm, onCue, preload, sources]);
|
|
3082
3127
|
const triggerMoveSound = react.useCallback(
|
|
3083
3128
|
(key) => {
|
|
3084
3129
|
if (!enabled) return;
|
|
3085
3130
|
if (typeof window === "undefined") return;
|
|
3131
|
+
const effectiveVolume = Math.max(0, Math.min(1, volumeRef.current));
|
|
3132
|
+
if (onCueRef.current) {
|
|
3133
|
+
onCueRef.current(key, effectiveVolume);
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3086
3136
|
if (typeof Audio === "undefined") return;
|
|
3087
3137
|
const pools = poolsRef.current ?? createPools(sourcesRef.current, preloadRef.current);
|
|
3088
3138
|
poolsRef.current = pools;
|
|
@@ -3091,7 +3141,7 @@ function useMoveSound(model, options = {}) {
|
|
|
3091
3141
|
pool.cursor = (pool.cursor + 1) % pool.elements.length;
|
|
3092
3142
|
const el = pool.elements[pool.cursor];
|
|
3093
3143
|
if (el === void 0) return;
|
|
3094
|
-
el.volume =
|
|
3144
|
+
el.volume = effectiveVolume;
|
|
3095
3145
|
el.currentTime = 0;
|
|
3096
3146
|
void el.play().catch(() => {
|
|
3097
3147
|
});
|
|
@@ -3099,7 +3149,7 @@ function useMoveSound(model, options = {}) {
|
|
|
3099
3149
|
[enabled]
|
|
3100
3150
|
);
|
|
3101
3151
|
react.useEffect(() => {
|
|
3102
|
-
if (!enabled || model === null) return;
|
|
3152
|
+
if (!enabled || model === null || trigger === "position") return;
|
|
3103
3153
|
let prevPly = model.getSnapshot().historyPly;
|
|
3104
3154
|
return model.subscribe(() => {
|
|
3105
3155
|
const snap = model.getSnapshot();
|
|
@@ -3108,10 +3158,15 @@ function useMoveSound(model, options = {}) {
|
|
|
3108
3158
|
return;
|
|
3109
3159
|
}
|
|
3110
3160
|
prevPly = snap.historyPly;
|
|
3111
|
-
const key = classifyMoveFeedback(
|
|
3161
|
+
const key = classifyMoveFeedback(
|
|
3162
|
+
model.lastAnimations,
|
|
3163
|
+
snap,
|
|
3164
|
+
perspectiveRef.current,
|
|
3165
|
+
cuePolicy
|
|
3166
|
+
);
|
|
3112
3167
|
triggerMoveSound(key);
|
|
3113
3168
|
});
|
|
3114
|
-
}, [enabled, model, triggerMoveSound]);
|
|
3169
|
+
}, [enabled, model, trigger, cuePolicy, triggerMoveSound]);
|
|
3115
3170
|
return triggerMoveSound;
|
|
3116
3171
|
}
|
|
3117
3172
|
var STYLE_ID3 = "gb-selection-styles";
|
|
@@ -3226,7 +3281,7 @@ var DEFAULT_POSITION_SYNC_DURATION_MS = 60;
|
|
|
3226
3281
|
var DEFAULT_POSITION_SYNC_EASING = "cubic-bezier(0.22, 0.61, 0.36, 1)";
|
|
3227
3282
|
var UCI_TRANSITION_RE = /^([a-h][1-8])([a-h][1-8])([nbrq])?$/i;
|
|
3228
3283
|
function isNullTransition(transition) {
|
|
3229
|
-
return
|
|
3284
|
+
return chunkMCD4AIR2_cjs.isNullMoveUci(transition.uci);
|
|
3230
3285
|
}
|
|
3231
3286
|
function prefersReducedMotion3() {
|
|
3232
3287
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
@@ -3299,7 +3354,7 @@ function parseTransitionMove(transition) {
|
|
|
3299
3354
|
};
|
|
3300
3355
|
}
|
|
3301
3356
|
function isPawn(cell) {
|
|
3302
|
-
return !
|
|
3357
|
+
return !chunkMCD4AIR2_cjs.isEmptyCell(cell) && chunkMCD4AIR2_cjs.pieceTypeOf(cell) === 0;
|
|
3303
3358
|
}
|
|
3304
3359
|
function controlledFeedbackDescriptors(transition, previousBoard, nextBoard) {
|
|
3305
3360
|
if (transition === null || transition === void 0) return null;
|
|
@@ -3308,25 +3363,25 @@ function controlledFeedbackDescriptors(transition, previousBoard, nextBoard) {
|
|
|
3308
3363
|
const before = transition.direction === "forward" ? previousBoard : nextBoard;
|
|
3309
3364
|
const after = transition.direction === "forward" ? nextBoard : previousBoard;
|
|
3310
3365
|
const movingPiece = before[parsed.from] ?? 0;
|
|
3311
|
-
if (
|
|
3366
|
+
if (chunkMCD4AIR2_cjs.isEmptyCell(movingPiece)) return null;
|
|
3312
3367
|
const fromFile = parsed.from & 7;
|
|
3313
3368
|
const toFile = parsed.to & 7;
|
|
3314
3369
|
const targetBefore = before[parsed.to] ?? 0;
|
|
3315
3370
|
const targetAfter = after[parsed.to] ?? 0;
|
|
3316
|
-
if (
|
|
3371
|
+
if (chunkMCD4AIR2_cjs.pieceTypeOf(movingPiece) === 5 && Math.abs(toFile - fromFile) === 2) {
|
|
3317
3372
|
return [{ kind: "castle" }];
|
|
3318
3373
|
}
|
|
3319
|
-
if (parsed.promotion !== null || isPawn(movingPiece) && (parsed.to >> 3 === 0 || parsed.to >> 3 === 7) && !
|
|
3374
|
+
if (parsed.promotion !== null || isPawn(movingPiece) && (parsed.to >> 3 === 0 || parsed.to >> 3 === 7) && !chunkMCD4AIR2_cjs.isEmptyCell(targetAfter) && chunkMCD4AIR2_cjs.pieceTypeOf(targetAfter) !== 0) {
|
|
3320
3375
|
return [{ kind: "promotion" }];
|
|
3321
3376
|
}
|
|
3322
|
-
if (!
|
|
3377
|
+
if (!chunkMCD4AIR2_cjs.isEmptyCell(targetBefore) && chunkMCD4AIR2_cjs.colorOf(targetBefore) !== chunkMCD4AIR2_cjs.colorOf(movingPiece)) {
|
|
3323
3378
|
return [{ kind: "capture" }];
|
|
3324
3379
|
}
|
|
3325
|
-
if (isPawn(movingPiece) && fromFile !== toFile &&
|
|
3380
|
+
if (isPawn(movingPiece) && fromFile !== toFile && chunkMCD4AIR2_cjs.isEmptyCell(targetBefore)) {
|
|
3326
3381
|
const capturedSquare = parsed.from & -8 | toFile;
|
|
3327
3382
|
const capturedBefore = before[capturedSquare] ?? 0;
|
|
3328
3383
|
const capturedAfter = after[capturedSquare] ?? 0;
|
|
3329
|
-
if (!
|
|
3384
|
+
if (!chunkMCD4AIR2_cjs.isEmptyCell(capturedBefore) && chunkMCD4AIR2_cjs.colorOf(capturedBefore) !== chunkMCD4AIR2_cjs.colorOf(movingPiece) && chunkMCD4AIR2_cjs.isEmptyCell(capturedAfter)) {
|
|
3330
3385
|
return [{ kind: "en-passant" }];
|
|
3331
3386
|
}
|
|
3332
3387
|
}
|
|
@@ -3408,6 +3463,8 @@ function Chessboard(props) {
|
|
|
3408
3463
|
ariaLabel,
|
|
3409
3464
|
animation,
|
|
3410
3465
|
allowDrag = true,
|
|
3466
|
+
dragActivationDistance,
|
|
3467
|
+
dragPickupOnPointerDown = false,
|
|
3411
3468
|
allowDrawingArrows = true,
|
|
3412
3469
|
clearArrowsOnMove = true,
|
|
3413
3470
|
clearArrowsOnClick = true,
|
|
@@ -3472,6 +3529,16 @@ function Chessboard(props) {
|
|
|
3472
3529
|
const previousSnapshot = game.getSnapshot();
|
|
3473
3530
|
if (game.engine.fen() === positionFen && managedArrows === void 0) {
|
|
3474
3531
|
lastControlledFeedbackFenRef.current = positionFen;
|
|
3532
|
+
if (soundOptions.trigger === "position" && previousFeedbackFen !== null && previousFeedbackFen !== positionFen) {
|
|
3533
|
+
triggerMoveSound(
|
|
3534
|
+
classifyMoveFeedback(
|
|
3535
|
+
game.lastAnimations,
|
|
3536
|
+
previousSnapshot,
|
|
3537
|
+
soundOptions.perspective,
|
|
3538
|
+
soundOptions.cuePolicy
|
|
3539
|
+
)
|
|
3540
|
+
);
|
|
3541
|
+
}
|
|
3475
3542
|
return;
|
|
3476
3543
|
}
|
|
3477
3544
|
const positionChanged = syncPositionFen(
|
|
@@ -3492,7 +3559,12 @@ function Chessboard(props) {
|
|
|
3492
3559
|
const feedbackDescriptors = controlledFeedbackDescriptors(positionTransition, previousSnapshot.board, snapshot.board) ?? game.lastAnimations;
|
|
3493
3560
|
const feedbackSnapshot = positionTransition?.direction === "backward" ? previousSnapshot : snapshot;
|
|
3494
3561
|
triggerMoveSound(
|
|
3495
|
-
classifyMoveFeedback(
|
|
3562
|
+
classifyMoveFeedback(
|
|
3563
|
+
feedbackDescriptors,
|
|
3564
|
+
feedbackSnapshot,
|
|
3565
|
+
soundOptions.perspective,
|
|
3566
|
+
soundOptions.cuePolicy
|
|
3567
|
+
)
|
|
3496
3568
|
);
|
|
3497
3569
|
triggerMoveHaptic2(
|
|
3498
3570
|
classifyMoveFeedback(feedbackDescriptors, feedbackSnapshot, hapticOptions.perspective)
|
|
@@ -3507,6 +3579,8 @@ function Chessboard(props) {
|
|
|
3507
3579
|
preserveUserArrowsOnPositionSync,
|
|
3508
3580
|
orientation,
|
|
3509
3581
|
soundOptions.perspective,
|
|
3582
|
+
soundOptions.cuePolicy,
|
|
3583
|
+
soundOptions.trigger,
|
|
3510
3584
|
triggerMoveHaptic2,
|
|
3511
3585
|
triggerMoveSound
|
|
3512
3586
|
]);
|
|
@@ -3698,6 +3772,8 @@ function Chessboard(props) {
|
|
|
3698
3772
|
containerRef,
|
|
3699
3773
|
dragLayerRef,
|
|
3700
3774
|
enabled: dragEnabled && game !== null,
|
|
3775
|
+
...dragActivationDistance !== void 0 ? { activationDistance: dragActivationDistance } : {},
|
|
3776
|
+
pickupOnPointerDown: dragPickupOnPointerDown,
|
|
3701
3777
|
onDragStart,
|
|
3702
3778
|
onDragEnd,
|
|
3703
3779
|
onDrop,
|
|
@@ -3834,15 +3910,15 @@ function useChessGame(options = {}) {
|
|
|
3834
3910
|
const { fen, ...modelOptions } = options;
|
|
3835
3911
|
const [initialModelOptions] = react.useState(() => modelOptions);
|
|
3836
3912
|
const [model, setModel] = react.useState(() => {
|
|
3837
|
-
const adapter =
|
|
3838
|
-
return
|
|
3913
|
+
const adapter = chunkMCD4AIR2_cjs.createGigachessAdapter(fen);
|
|
3914
|
+
return chunkMCD4AIR2_cjs.createBoardModel(adapter, modelOptions);
|
|
3839
3915
|
});
|
|
3840
3916
|
const prevFenRef = react.useRef(fen);
|
|
3841
3917
|
react.useEffect(() => {
|
|
3842
3918
|
if (prevFenRef.current !== fen) {
|
|
3843
3919
|
prevFenRef.current = fen;
|
|
3844
|
-
const adapter =
|
|
3845
|
-
const nextModel =
|
|
3920
|
+
const adapter = chunkMCD4AIR2_cjs.createGigachessAdapter(fen);
|
|
3921
|
+
const nextModel = chunkMCD4AIR2_cjs.createBoardModel(adapter, initialModelOptions);
|
|
3846
3922
|
setModel((prev) => {
|
|
3847
3923
|
prev.dispose();
|
|
3848
3924
|
return nextModel;
|
|
@@ -3858,63 +3934,64 @@ function useChessGame(options = {}) {
|
|
|
3858
3934
|
}
|
|
3859
3935
|
|
|
3860
3936
|
// src/index.ts
|
|
3861
|
-
var
|
|
3937
|
+
var SUPPORTS_CONFIRMED_BOARD_SOUND = true;
|
|
3938
|
+
var PACKAGE_VERSION = "1.7.0";
|
|
3862
3939
|
|
|
3863
3940
|
Object.defineProperty(exports, "Color", {
|
|
3864
3941
|
enumerable: true,
|
|
3865
|
-
get: function () { return
|
|
3942
|
+
get: function () { return chunkMCD4AIR2_cjs.Color; }
|
|
3866
3943
|
});
|
|
3867
3944
|
Object.defineProperty(exports, "NULL_MOVE_SAN", {
|
|
3868
3945
|
enumerable: true,
|
|
3869
|
-
get: function () { return
|
|
3946
|
+
get: function () { return chunkMCD4AIR2_cjs.NULL_MOVE_SAN; }
|
|
3870
3947
|
});
|
|
3871
3948
|
Object.defineProperty(exports, "NULL_MOVE_SANS", {
|
|
3872
3949
|
enumerable: true,
|
|
3873
|
-
get: function () { return
|
|
3950
|
+
get: function () { return chunkMCD4AIR2_cjs.NULL_MOVE_SANS; }
|
|
3874
3951
|
});
|
|
3875
3952
|
Object.defineProperty(exports, "NULL_MOVE_UCI", {
|
|
3876
3953
|
enumerable: true,
|
|
3877
|
-
get: function () { return
|
|
3954
|
+
get: function () { return chunkMCD4AIR2_cjs.NULL_MOVE_UCI; }
|
|
3878
3955
|
});
|
|
3879
3956
|
Object.defineProperty(exports, "NULL_MOVE_WORD", {
|
|
3880
3957
|
enumerable: true,
|
|
3881
|
-
get: function () { return
|
|
3958
|
+
get: function () { return chunkMCD4AIR2_cjs.NULL_MOVE_WORD; }
|
|
3882
3959
|
});
|
|
3883
3960
|
Object.defineProperty(exports, "PieceType", {
|
|
3884
3961
|
enumerable: true,
|
|
3885
|
-
get: function () { return
|
|
3962
|
+
get: function () { return chunkMCD4AIR2_cjs.PieceType; }
|
|
3886
3963
|
});
|
|
3887
3964
|
Object.defineProperty(exports, "createBoardModel", {
|
|
3888
3965
|
enumerable: true,
|
|
3889
|
-
get: function () { return
|
|
3966
|
+
get: function () { return chunkMCD4AIR2_cjs.createBoardModel; }
|
|
3890
3967
|
});
|
|
3891
3968
|
Object.defineProperty(exports, "createGigachessAdapter", {
|
|
3892
3969
|
enumerable: true,
|
|
3893
|
-
get: function () { return
|
|
3970
|
+
get: function () { return chunkMCD4AIR2_cjs.createGigachessAdapter; }
|
|
3894
3971
|
});
|
|
3895
3972
|
Object.defineProperty(exports, "isNullMove", {
|
|
3896
3973
|
enumerable: true,
|
|
3897
|
-
get: function () { return
|
|
3974
|
+
get: function () { return chunkMCD4AIR2_cjs.isNullMove; }
|
|
3898
3975
|
});
|
|
3899
3976
|
Object.defineProperty(exports, "isNullMoveSan", {
|
|
3900
3977
|
enumerable: true,
|
|
3901
|
-
get: function () { return
|
|
3978
|
+
get: function () { return chunkMCD4AIR2_cjs.isNullMoveSan; }
|
|
3902
3979
|
});
|
|
3903
3980
|
Object.defineProperty(exports, "isNullMoveUci", {
|
|
3904
3981
|
enumerable: true,
|
|
3905
|
-
get: function () { return
|
|
3982
|
+
get: function () { return chunkMCD4AIR2_cjs.isNullMoveUci; }
|
|
3906
3983
|
});
|
|
3907
3984
|
Object.defineProperty(exports, "packMove", {
|
|
3908
3985
|
enumerable: true,
|
|
3909
|
-
get: function () { return
|
|
3986
|
+
get: function () { return chunkMCD4AIR2_cjs.packMove; }
|
|
3910
3987
|
});
|
|
3911
3988
|
Object.defineProperty(exports, "preloadGigachessAdapter", {
|
|
3912
3989
|
enumerable: true,
|
|
3913
|
-
get: function () { return
|
|
3990
|
+
get: function () { return chunkMCD4AIR2_cjs.preloadGigachessAdapter; }
|
|
3914
3991
|
});
|
|
3915
3992
|
Object.defineProperty(exports, "unpackMove", {
|
|
3916
3993
|
enumerable: true,
|
|
3917
|
-
get: function () { return
|
|
3994
|
+
get: function () { return chunkMCD4AIR2_cjs.unpackMove; }
|
|
3918
3995
|
});
|
|
3919
3996
|
Object.defineProperty(exports, "CSS_VARS", {
|
|
3920
3997
|
enumerable: true,
|
|
@@ -3946,6 +4023,7 @@ exports.Chessboard = Chessboard;
|
|
|
3946
4023
|
exports.DEFAULT_MOVE_HAPTIC_PATTERNS = DEFAULT_MOVE_HAPTIC_PATTERNS;
|
|
3947
4024
|
exports.DEFAULT_MOVE_SOUND_SOURCES = DEFAULT_MOVE_SOUND_SOURCES;
|
|
3948
4025
|
exports.PACKAGE_VERSION = PACKAGE_VERSION;
|
|
4026
|
+
exports.SUPPORTS_CONFIRMED_BOARD_SOUND = SUPPORTS_CONFIRMED_BOARD_SOUND;
|
|
3949
4027
|
exports.algebraicOf = algebraicOf2;
|
|
3950
4028
|
exports.classifyMoveFeedback = classifyMoveFeedback;
|
|
3951
4029
|
exports.formatFenPlacement = formatFenPlacement;
|