@ankhorage/zora 25.11.1 → 26.0.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/CHANGELOG.md +6 -0
- package/README.md +1 -4
- package/dist/capabilities/index.js +65 -41
- package/dist/capabilities/index.js.map +3 -3
- package/dist/features/chess/adapters/inbound/ChessBoard.d.ts +1 -1
- package/dist/features/chess/adapters/inbound/ChessBoard.d.ts.map +1 -1
- package/dist/features/chess/adapters/inbound/ChessBoard.js +130 -83
- package/dist/features/chess/adapters/inbound/ChessBoard.js.map +1 -1
- package/dist/features/chess/meta.d.ts +97 -72
- package/dist/features/chess/meta.d.ts.map +1 -1
- package/dist/features/chess/meta.js +64 -40
- package/dist/features/chess/meta.js.map +1 -1
- package/dist/features/chess/public.d.ts +1 -7
- package/dist/features/chess/public.d.ts.map +1 -1
- package/dist/features/chess/public.js +0 -6
- package/dist/features/chess/public.js.map +1 -1
- package/dist/features/chess/utils/createChessBoardCellPressHandler.d.ts +6 -0
- package/dist/features/chess/utils/createChessBoardCellPressHandler.d.ts.map +1 -0
- package/dist/features/chess/utils/createChessBoardCellPressHandler.js +17 -0
- package/dist/features/chess/utils/createChessBoardCellPressHandler.js.map +1 -0
- package/dist/features/chess/utils/createChessBoardCells.d.ts +12 -0
- package/dist/features/chess/utils/createChessBoardCells.d.ts.map +1 -0
- package/dist/features/chess/utils/createChessBoardCells.js +28 -0
- package/dist/features/chess/utils/createChessBoardCells.js.map +1 -0
- package/dist/readerFree.d.ts +2 -2
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js +1 -1
- package/dist/readerFree.js.map +1 -1
- package/dist/types/authoring.d.ts +2 -1
- package/dist/types/authoring.d.ts.map +1 -1
- package/dist/types/authoring.js.map +1 -1
- package/dist/types/chess.d.ts +27 -20
- package/dist/types/chess.d.ts.map +1 -1
- package/dist/types/chess.js.map +1 -1
- package/package.json +31 -92
- package/src/features/chess/adapters/inbound/ChessBoard.tsx +263 -112
- package/src/features/chess/meta.ts +64 -40
- package/src/features/chess/public.test.tsx +77 -228
- package/src/features/chess/public.ts +2 -9
- package/src/features/chess/utils/createChessBoardCellPressHandler.ts +30 -0
- package/src/features/chess/utils/createChessBoardCells.ts +54 -0
- package/src/features/chessTabletopOwnership.test.ts +3 -7
- package/src/features/registry/componentMeta.test.ts +12 -1
- package/src/readerFree.ts +3 -15
- package/src/types/authoring.ts +2 -1
- package/src/types/chess.ts +28 -21
- package/web-dist/chunks/Accordion-91sjb3zh.js +453 -0
- package/web-dist/components/chess-board/ChessBoard.js +2 -1
- package/web-dist/components/opening-book/OpeningBook.js +2 -1
- package/web-dist/manifest.json +8 -4
- package/dist/features/chess/utils/chessEngine.d.ts +0 -8
- package/dist/features/chess/utils/chessEngine.d.ts.map +0 -1
- package/dist/features/chess/utils/chessEngine.js +0 -71
- package/dist/features/chess/utils/chessEngine.js.map +0 -1
- package/dist/features/chess/utils/chessSquares.d.ts +0 -4
- package/dist/features/chess/utils/chessSquares.d.ts.map +0 -1
- package/dist/features/chess/utils/chessSquares.js +0 -3
- package/dist/features/chess/utils/chessSquares.js.map +0 -1
- package/dist/features/chess/utils/createBoardSquares.d.ts +0 -4
- package/dist/features/chess/utils/createBoardSquares.d.ts.map +0 -1
- package/dist/features/chess/utils/createBoardSquares.js +0 -9
- package/dist/features/chess/utils/createBoardSquares.js.map +0 -1
- package/dist/features/chess/utils/getSquareFile.d.ts +0 -4
- package/dist/features/chess/utils/getSquareFile.d.ts.map +0 -1
- package/dist/features/chess/utils/getSquareFile.js +0 -5
- package/dist/features/chess/utils/getSquareFile.js.map +0 -1
- package/dist/features/chess/utils/getSquareRank.d.ts +0 -4
- package/dist/features/chess/utils/getSquareRank.d.ts.map +0 -1
- package/dist/features/chess/utils/getSquareRank.js +0 -5
- package/dist/features/chess/utils/getSquareRank.js.map +0 -1
- package/dist/features/chess/utils/isLightSquare.d.ts +0 -4
- package/dist/features/chess/utils/isLightSquare.d.ts.map +0 -1
- package/dist/features/chess/utils/isLightSquare.js +0 -6
- package/dist/features/chess/utils/isLightSquare.js.map +0 -1
- package/src/features/chess/utils/chessEngine.test.ts +0 -35
- package/src/features/chess/utils/chessEngine.ts +0 -83
- package/src/features/chess/utils/chessSquares.ts +0 -6
- package/src/features/chess/utils/createBoardSquares.ts +0 -13
- package/src/features/chess/utils/getSquareFile.ts +0 -6
- package/src/features/chess/utils/getSquareRank.ts +0 -6
- package/src/features/chess/utils/isLightSquare.ts +0 -8
- package/web-dist/chunks/Accordion-xcm1qc39.js +0 -3813
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSquareFile.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/getSquareFile.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import type { ChessSquareId } from '../../../types/chess';\n\n/*** Returns the file letter of a chess square. */\nexport function getSquareFile(square: ChessSquareId): string {\n return square[0] ?? '';\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSquareRank.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/getSquareRank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getSquareRank.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/getSquareRank.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import type { ChessSquareId } from '../../../types/chess';\n\n/*** Returns the rank number of a chess square. */\nexport function getSquareRank(square: ChessSquareId): string {\n return square[1] ?? '';\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isLightSquare.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/isLightSquare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAE5D"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const files = 'abcdefgh';
|
|
2
|
-
/*** Determines whether a chess square uses the light presentation color. */
|
|
3
|
-
export function isLightSquare(square) {
|
|
4
|
-
return (files.indexOf(square[0] ?? '') + Number(square[1]) - 1) % 2 === 1;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=isLightSquare.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isLightSquare.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/isLightSquare.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,UAAU,CAAC;AAEzB,4EAA4E;AAC5E,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type { ChessSquareId } from '../../../types/chess';\n\nconst files = 'abcdefgh';\n\n/*** Determines whether a chess square uses the light presentation color. */\nexport function isLightSquare(square: ChessSquareId): boolean {\n return (files.indexOf(square[0] ?? '') + Number(square[1]) - 1) % 2 === 1;\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
import { getLegalTargets, readChessPieces, tryMove } from './chessEngine';
|
|
4
|
-
|
|
5
|
-
const START_FEN = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1';
|
|
6
|
-
|
|
7
|
-
describe('core chess engine', () => {
|
|
8
|
-
it('reads pieces from FEN and preserves piece codes', () => {
|
|
9
|
-
const pieces = readChessPieces(START_FEN);
|
|
10
|
-
|
|
11
|
-
expect(pieces.size).toBe(32);
|
|
12
|
-
expect(pieces.get('e1')?.piece).toBe('K');
|
|
13
|
-
expect(pieces.get('e8')?.piece).toBe('k');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('returns an empty map for invalid FEN', () => {
|
|
17
|
-
expect(readChessPieces('invalid').size).toBe(0);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns legal target squares', () => {
|
|
21
|
-
expect(getLegalTargets(START_FEN, 'e2')).toEqual(['e3', 'e4']);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('returns resulting move details for legal moves', () => {
|
|
25
|
-
const result = tryMove(START_FEN, { from: 'e2', to: 'e4' });
|
|
26
|
-
|
|
27
|
-
expect(result?.san).toBe('e4');
|
|
28
|
-
expect(result?.lan).toBe('e2e4');
|
|
29
|
-
expect(result?.fen).toContain(' b ');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('returns null for invalid moves', () => {
|
|
33
|
-
expect(tryMove(START_FEN, { from: 'e2', to: 'e5' })).toBeNull();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Chess, type Move } from 'chess.js';
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
ChessMoveAttempt,
|
|
5
|
-
ChessMoveResult,
|
|
6
|
-
ChessPieceCode,
|
|
7
|
-
ChessPieceState,
|
|
8
|
-
ChessPromotionPiece,
|
|
9
|
-
ChessSquareId,
|
|
10
|
-
} from '../../../types/chess';
|
|
11
|
-
|
|
12
|
-
/*** Create a chess.js position from FEN without leaking invalid-position exceptions. */
|
|
13
|
-
function createChess(fen: string): Chess | null {
|
|
14
|
-
try {
|
|
15
|
-
return new Chess(fen);
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/*** Convert a chess.js piece into the public ZORA piece code. */
|
|
22
|
-
function toPieceCode(piece: { readonly color: 'b' | 'w'; readonly type: string }): ChessPieceCode {
|
|
23
|
-
return piece.color === 'w' ? piece.type.toUpperCase() : piece.type.toLowerCase();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/*** Normalize a chess.js promotion marker into the public promotion union. */
|
|
27
|
-
function toPromotionPiece(piece: string | undefined): ChessPromotionPiece | undefined {
|
|
28
|
-
return piece === 'q' || piece === 'r' || piece === 'b' || piece === 'n' ? piece : undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/*** Convert one successful chess.js move into the public result contract. */
|
|
32
|
-
function toMoveResult(move: Move, fen: string): ChessMoveResult {
|
|
33
|
-
return {
|
|
34
|
-
fen,
|
|
35
|
-
from: move.from,
|
|
36
|
-
lan: move.lan,
|
|
37
|
-
promotion: toPromotionPiece(move.promotion),
|
|
38
|
-
san: move.san,
|
|
39
|
-
to: move.to,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/*** Read all pieces from a FEN-backed position. Invalid FEN produces an empty position. */
|
|
44
|
-
export function readChessPieces(fen: string): ReadonlyMap<ChessSquareId, ChessPieceState> {
|
|
45
|
-
const chess = createChess(fen);
|
|
46
|
-
const pieces = new Map<ChessSquareId, ChessPieceState>();
|
|
47
|
-
if (!chess) return pieces;
|
|
48
|
-
|
|
49
|
-
for (const rank of chess.board()) {
|
|
50
|
-
for (const piece of rank) {
|
|
51
|
-
if (!piece) continue;
|
|
52
|
-
pieces.set(piece.square, {
|
|
53
|
-
color: piece.color === 'w' ? 'white' : 'black',
|
|
54
|
-
piece: toPieceCode(piece),
|
|
55
|
-
square: piece.square,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return pieces;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/*** Resolve legal destination squares from one FEN position and source square. */
|
|
63
|
-
export function getLegalTargets(fen: string, from: ChessSquareId): readonly ChessSquareId[] {
|
|
64
|
-
const chess = createChess(fen);
|
|
65
|
-
return chess ? chess.moves({ square: from, verbose: true }).map((move) => move.to) : [];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/*** Attempt one legal chess move against FEN and return the resulting position/move notation. */
|
|
69
|
-
export function tryMove(fen: string, attempt: ChessMoveAttempt): ChessMoveResult | null {
|
|
70
|
-
const chess = createChess(fen);
|
|
71
|
-
if (!chess) return null;
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
const move = chess.move({
|
|
75
|
-
from: attempt.from,
|
|
76
|
-
promotion: attempt.promotion,
|
|
77
|
-
to: attempt.to,
|
|
78
|
-
});
|
|
79
|
-
return toMoveResult(move, chess.fen());
|
|
80
|
-
} catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ChessSquareId } from '../../../types/chess';
|
|
2
|
-
|
|
3
|
-
/*** Lists every board square in ascending rank and file order. */
|
|
4
|
-
export const chessSquares: readonly ChessSquareId[] = [1, 2, 3, 4, 5, 6, 7, 8].flatMap((rank) =>
|
|
5
|
-
[...'abcdefgh'].map((file) => `${file}${rank}` as ChessSquareId),
|
|
6
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ChessBoardOrientation, ChessSquareId } from '../../../types/chess';
|
|
2
|
-
|
|
3
|
-
const files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as const;
|
|
4
|
-
const ranks = ['1', '2', '3', '4', '5', '6', '7', '8'] as const;
|
|
5
|
-
|
|
6
|
-
/*** Orders the 64 displayed squares for the selected player orientation. */
|
|
7
|
-
export function createBoardSquares(orientation: ChessBoardOrientation): readonly ChessSquareId[] {
|
|
8
|
-
const displayedRanks = orientation === 'white' ? [...ranks].reverse() : [...ranks];
|
|
9
|
-
const displayedFiles = orientation === 'white' ? [...files] : [...files].reverse();
|
|
10
|
-
return displayedRanks.flatMap((rank) =>
|
|
11
|
-
displayedFiles.map((file): ChessSquareId => `${file}${rank}`),
|
|
12
|
-
);
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ChessSquareId } from '../../../types/chess';
|
|
2
|
-
|
|
3
|
-
const files = 'abcdefgh';
|
|
4
|
-
|
|
5
|
-
/*** Determines whether a chess square uses the light presentation color. */
|
|
6
|
-
export function isLightSquare(square: ChessSquareId): boolean {
|
|
7
|
-
return (files.indexOf(square[0] ?? '') + Number(square[1]) - 1) % 2 === 1;
|
|
8
|
-
}
|