@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -4
  3. package/dist/capabilities/index.js +65 -41
  4. package/dist/capabilities/index.js.map +3 -3
  5. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts +1 -1
  6. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts.map +1 -1
  7. package/dist/features/chess/adapters/inbound/ChessBoard.js +130 -83
  8. package/dist/features/chess/adapters/inbound/ChessBoard.js.map +1 -1
  9. package/dist/features/chess/meta.d.ts +97 -72
  10. package/dist/features/chess/meta.d.ts.map +1 -1
  11. package/dist/features/chess/meta.js +64 -40
  12. package/dist/features/chess/meta.js.map +1 -1
  13. package/dist/features/chess/public.d.ts +1 -7
  14. package/dist/features/chess/public.d.ts.map +1 -1
  15. package/dist/features/chess/public.js +0 -6
  16. package/dist/features/chess/public.js.map +1 -1
  17. package/dist/features/chess/utils/createChessBoardCellPressHandler.d.ts +6 -0
  18. package/dist/features/chess/utils/createChessBoardCellPressHandler.d.ts.map +1 -0
  19. package/dist/features/chess/utils/createChessBoardCellPressHandler.js +17 -0
  20. package/dist/features/chess/utils/createChessBoardCellPressHandler.js.map +1 -0
  21. package/dist/features/chess/utils/createChessBoardCells.d.ts +12 -0
  22. package/dist/features/chess/utils/createChessBoardCells.d.ts.map +1 -0
  23. package/dist/features/chess/utils/createChessBoardCells.js +28 -0
  24. package/dist/features/chess/utils/createChessBoardCells.js.map +1 -0
  25. package/dist/readerFree.d.ts +2 -2
  26. package/dist/readerFree.d.ts.map +1 -1
  27. package/dist/readerFree.js +1 -1
  28. package/dist/readerFree.js.map +1 -1
  29. package/dist/types/authoring.d.ts +2 -1
  30. package/dist/types/authoring.d.ts.map +1 -1
  31. package/dist/types/authoring.js.map +1 -1
  32. package/dist/types/chess.d.ts +27 -20
  33. package/dist/types/chess.d.ts.map +1 -1
  34. package/dist/types/chess.js.map +1 -1
  35. package/package.json +31 -92
  36. package/src/features/chess/adapters/inbound/ChessBoard.tsx +263 -112
  37. package/src/features/chess/meta.ts +64 -40
  38. package/src/features/chess/public.test.tsx +77 -228
  39. package/src/features/chess/public.ts +2 -9
  40. package/src/features/chess/utils/createChessBoardCellPressHandler.ts +30 -0
  41. package/src/features/chess/utils/createChessBoardCells.ts +54 -0
  42. package/src/features/chessTabletopOwnership.test.ts +3 -7
  43. package/src/features/registry/componentMeta.test.ts +12 -1
  44. package/src/readerFree.ts +3 -15
  45. package/src/types/authoring.ts +2 -1
  46. package/src/types/chess.ts +28 -21
  47. package/web-dist/chunks/Accordion-91sjb3zh.js +453 -0
  48. package/web-dist/components/chess-board/ChessBoard.js +2 -1
  49. package/web-dist/components/opening-book/OpeningBook.js +2 -1
  50. package/web-dist/manifest.json +8 -4
  51. package/dist/features/chess/utils/chessEngine.d.ts +0 -8
  52. package/dist/features/chess/utils/chessEngine.d.ts.map +0 -1
  53. package/dist/features/chess/utils/chessEngine.js +0 -71
  54. package/dist/features/chess/utils/chessEngine.js.map +0 -1
  55. package/dist/features/chess/utils/chessSquares.d.ts +0 -4
  56. package/dist/features/chess/utils/chessSquares.d.ts.map +0 -1
  57. package/dist/features/chess/utils/chessSquares.js +0 -3
  58. package/dist/features/chess/utils/chessSquares.js.map +0 -1
  59. package/dist/features/chess/utils/createBoardSquares.d.ts +0 -4
  60. package/dist/features/chess/utils/createBoardSquares.d.ts.map +0 -1
  61. package/dist/features/chess/utils/createBoardSquares.js +0 -9
  62. package/dist/features/chess/utils/createBoardSquares.js.map +0 -1
  63. package/dist/features/chess/utils/getSquareFile.d.ts +0 -4
  64. package/dist/features/chess/utils/getSquareFile.d.ts.map +0 -1
  65. package/dist/features/chess/utils/getSquareFile.js +0 -5
  66. package/dist/features/chess/utils/getSquareFile.js.map +0 -1
  67. package/dist/features/chess/utils/getSquareRank.d.ts +0 -4
  68. package/dist/features/chess/utils/getSquareRank.d.ts.map +0 -1
  69. package/dist/features/chess/utils/getSquareRank.js +0 -5
  70. package/dist/features/chess/utils/getSquareRank.js.map +0 -1
  71. package/dist/features/chess/utils/isLightSquare.d.ts +0 -4
  72. package/dist/features/chess/utils/isLightSquare.d.ts.map +0 -1
  73. package/dist/features/chess/utils/isLightSquare.js +0 -6
  74. package/dist/features/chess/utils/isLightSquare.js.map +0 -1
  75. package/src/features/chess/utils/chessEngine.test.ts +0 -35
  76. package/src/features/chess/utils/chessEngine.ts +0 -83
  77. package/src/features/chess/utils/chessSquares.ts +0 -6
  78. package/src/features/chess/utils/createBoardSquares.ts +0 -13
  79. package/src/features/chess/utils/getSquareFile.ts +0 -6
  80. package/src/features/chess/utils/getSquareRank.ts +0 -6
  81. package/src/features/chess/utils/isLightSquare.ts +0 -8
  82. package/web-dist/chunks/Accordion-xcm1qc39.js +0 -3813
@@ -0,0 +1,453 @@
1
+ 'use client';
2
+ import {
3
+ GridView2
4
+ } from "./Accordion-t0k1cjca.js";
5
+ import {
6
+ withZoraThemeScope
7
+ } from "./Accordion-vj1m2wck.js";
8
+ import {
9
+ useZoraTheme2
10
+ } from "./Accordion-srjya6dz.js";
11
+ import {
12
+ require_cjs
13
+ } from "./Accordion-xgpzh4wq.js";
14
+ import {
15
+ __toESM
16
+ } from "./Accordion-nh0cs9hq.js";
17
+
18
+ // src/features/chess/adapters/inbound/ChessBoard.tsx
19
+ var import_react_native = __toESM(require_cjs(), 1);
20
+ import React from "react";
21
+
22
+ // src/features/chess/utils/createChessBoardCellPressHandler.ts
23
+ function createChessBoardCellPressHandler({
24
+ disabled,
25
+ interactionPolicy,
26
+ onCellPress,
27
+ onMoveAttempt,
28
+ selectedCell
29
+ }) {
30
+ return (cell) => {
31
+ if (disabled || interactionPolicy === "passive")
32
+ return;
33
+ onCellPress?.(cell);
34
+ if (selectedCell === null || selectedCell === undefined || cellsEqual(selectedCell, cell)) {
35
+ return;
36
+ }
37
+ onMoveAttempt?.({ from: selectedCell, to: cell });
38
+ };
39
+ }
40
+ function cellsEqual(left, right) {
41
+ return left.column === right.column && left.row === right.row;
42
+ }
43
+
44
+ // src/features/chess/utils/createChessBoardCells.ts
45
+ var minimumDimension = 2;
46
+ var maximumDimension = 24;
47
+ function createChessBoardCells(columns, rows, orientation) {
48
+ validateChessBoardDimensions(columns, rows);
49
+ return Array.from({ length: rows }, (_, rowIndex) => Array.from({ length: columns }, (_, columnIndex) => {
50
+ const column = columnIndex + 1;
51
+ const row = rowIndex + 1;
52
+ return {
53
+ column,
54
+ height: 1,
55
+ id: `${column}:${row}`,
56
+ row,
57
+ width: 1,
58
+ x: orientation === "white" ? columnIndex : columns - column,
59
+ y: orientation === "white" ? rows - row : rowIndex
60
+ };
61
+ })).flat();
62
+ }
63
+ function validateChessBoardDimensions(columns, rows) {
64
+ if (![columns, rows].every((dimension) => Number.isInteger(dimension) && dimension >= minimumDimension && dimension <= maximumDimension)) {
65
+ throw new RangeError(`ChessBoard dimensions must be whole numbers from ${minimumDimension} through ${maximumDimension}.`);
66
+ }
67
+ }
68
+
69
+ // src/features/chess/utils/createChessBoardColorScheme.ts
70
+ function createChessBoardColorScheme(theme, overrides) {
71
+ return {
72
+ border: theme.semantics.neutral.divider,
73
+ coordinateText: theme.semantics.content.muted,
74
+ darkPiece: theme.semantics.content.default,
75
+ darkSquare: theme.semantics.neutral.surfaceHover,
76
+ darkSquareText: theme.semantics.content.muted,
77
+ lastMoveFrom: theme.semantics.warning.softBg,
78
+ lastMoveTo: theme.semantics.warning.softBg,
79
+ legalTarget: theme.semantics.success.softBg,
80
+ lightPiece: theme.semantics.content.default,
81
+ lightSquare: theme.semantics.neutral.surface,
82
+ lightSquareText: theme.semantics.content.muted,
83
+ selectedSquare: theme.semantics.action.primary.softBg,
84
+ ...overrides
85
+ };
86
+ }
87
+
88
+ // src/features/chess/adapters/inbound/ChessBoard.tsx
89
+ import { jsx, jsxs } from "react/jsx-runtime";
90
+ var symbols = new Map([
91
+ ["white:p", "♙"],
92
+ ["white:n", "♘"],
93
+ ["white:b", "♗"],
94
+ ["white:r", "♖"],
95
+ ["white:q", "♕"],
96
+ ["white:k", "♔"],
97
+ ["black:p", "♟"],
98
+ ["black:n", "♞"],
99
+ ["black:b", "♝"],
100
+ ["black:r", "♜"],
101
+ ["black:q", "♛"],
102
+ ["black:k", "♚"]
103
+ ]);
104
+ var minimumDimension2 = 2;
105
+ var maximumDimension2 = 24;
106
+ var ChessBoard2 = withZoraThemeScope(ChessBoardInner);
107
+ function ChessBoardInner({
108
+ columns = 8,
109
+ rows = 8,
110
+ pieces,
111
+ orientation = "white",
112
+ selectedCell = null,
113
+ legalTargets = [],
114
+ lastMove = null,
115
+ disabled = false,
116
+ showCoordinates = false,
117
+ resizable = false,
118
+ colorScheme,
119
+ onCellPress,
120
+ onMoveAttempt,
121
+ onDimensionsChange,
122
+ renderPiece,
123
+ interactionPolicy,
124
+ testID
125
+ }) {
126
+ const { theme } = useZoraTheme2();
127
+ const colors = createChessBoardColorScheme(theme, colorScheme);
128
+ const dimensions = React.useMemo(() => ({ columns, rows }), [columns, rows]);
129
+ const [width, setWidth] = React.useState(0);
130
+ const cells = React.useMemo(() => createChessBoardCells(columns, rows, orientation), [columns, orientation, rows]);
131
+ const piecesByCell = React.useMemo(() => new Map((pieces ?? []).map((piece) => [getCellKey(piece.cell), piece])), [pieces]);
132
+ const cellById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
133
+ const legalTargetSet = React.useMemo(() => new Set(legalTargets.map(getCellKey)), [legalTargets]);
134
+ const pressCell = createChessBoardCellPressHandler({
135
+ disabled,
136
+ interactionPolicy,
137
+ onCellPress,
138
+ onMoveAttempt,
139
+ selectedCell
140
+ });
141
+ const canResize = resizable && onDimensionsChange !== undefined && !disabled && interactionPolicy !== "passive";
142
+ const height = width * (dimensions.rows / dimensions.columns);
143
+ const cellSize = width / dimensions.columns;
144
+ return /* @__PURE__ */ jsxs(import_react_native.View, {
145
+ accessibilityLabel: "Chess board",
146
+ onLayout: (event) => setWidth(event.nativeEvent.layout.width),
147
+ style: [
148
+ styles.board,
149
+ {
150
+ aspectRatio: dimensions.columns / dimensions.rows,
151
+ borderColor: colors.border,
152
+ opacity: disabled ? 0.56 : 1
153
+ }
154
+ ],
155
+ testID,
156
+ children: [
157
+ width > 0 ? /* @__PURE__ */ jsx(GridView2, {
158
+ contentHeight: dimensions.rows,
159
+ contentWidth: dimensions.columns,
160
+ defaultViewport: { pixelsPerUnitX: cellSize, pixelsPerUnitY: cellSize },
161
+ height,
162
+ interactionPolicy: "passive",
163
+ items: cells,
164
+ overscanPixels: 0,
165
+ renderItem: (item) => {
166
+ const cell = cellById.get(item.id);
167
+ return cell === undefined ? null : renderChessBoardCell({
168
+ cell,
169
+ cellSize,
170
+ colors,
171
+ disabled: disabled || interactionPolicy === "passive",
172
+ lastMove,
173
+ legalTargetSet,
174
+ onPress: pressCell,
175
+ piece: piecesByCell.get(item.id),
176
+ renderPiece,
177
+ selectedCell,
178
+ showCoordinates,
179
+ testID
180
+ });
181
+ },
182
+ width
183
+ }) : null,
184
+ canResize ? renderChessBoardResizeActions(dimensions, onDimensionsChange, testID) : null
185
+ ]
186
+ });
187
+ }
188
+ function renderChessBoardCell({
189
+ cell,
190
+ cellSize,
191
+ colors,
192
+ disabled,
193
+ lastMove,
194
+ legalTargetSet,
195
+ onPress,
196
+ piece,
197
+ renderPiece,
198
+ selectedCell,
199
+ showCoordinates,
200
+ testID
201
+ }) {
202
+ const light = (cell.column + cell.row) % 2 === 1;
203
+ const key = getCellKey(cell);
204
+ const backgroundColor = cellsEqual2(selectedCell, cell) ? colors.selectedSquare : legalTargetSet.has(key) ? colors.legalTarget : cellsEqual2(lastMove?.from, cell) ? colors.lastMoveFrom : cellsEqual2(lastMove?.to, cell) ? colors.lastMoveTo : light ? colors.lightSquare : colors.darkSquare;
205
+ const pieceContent = piece === undefined ? null : renderPiece ? renderPiece({
206
+ cell,
207
+ color: piece.color === "white" ? colors.lightPiece : colors.darkPiece,
208
+ piece: piece.piece,
209
+ size: cellSize
210
+ }) : symbols.get(`${piece.color}:${piece.piece.toLowerCase()}`) ?? piece.piece;
211
+ const coordinate = formatCellCoordinate(cell);
212
+ return /* @__PURE__ */ jsxs(import_react_native.Pressable, {
213
+ accessibilityLabel: coordinate,
214
+ accessibilityRole: "button",
215
+ accessibilityState: { disabled },
216
+ disabled,
217
+ onPress: () => onPress(cell),
218
+ style: [styles.square, { backgroundColor }],
219
+ testID: testID === undefined ? undefined : `${testID}-cell-${coordinate}`,
220
+ children: [
221
+ showCoordinates ? /* @__PURE__ */ jsx(import_react_native.Text, {
222
+ style: [
223
+ styles.coordinate,
224
+ { color: light ? colors.lightSquareText : colors.darkSquareText }
225
+ ],
226
+ children: coordinate
227
+ }) : null,
228
+ piece === undefined ? null : /* @__PURE__ */ jsx(import_react_native.View, {
229
+ pointerEvents: "none",
230
+ style: styles.pieceContainer,
231
+ children: renderPiece ? pieceContent : /* @__PURE__ */ jsx(import_react_native.Text, {
232
+ style: [
233
+ styles.piece,
234
+ {
235
+ color: piece.color === "white" ? colors.lightPiece : colors.darkPiece,
236
+ fontSize: cellSize * 0.58,
237
+ lineHeight: cellSize * 0.7
238
+ }
239
+ ],
240
+ children: pieceContent
241
+ })
242
+ })
243
+ ]
244
+ }, key);
245
+ }
246
+ function renderChessBoardResizeActions(dimensions, onDimensionsChange, testID) {
247
+ return /* @__PURE__ */ jsxs(import_react_native.View, {
248
+ accessibilityLabel: "Chess board dimensions",
249
+ style: styles.resizeActions,
250
+ children: [
251
+ renderResizeAction("Add row", { ...dimensions, rows: dimensions.rows + 1 }, onDimensionsChange, dimensions.rows < maximumDimension2, testID),
252
+ renderResizeAction("Remove row", { ...dimensions, rows: dimensions.rows - 1 }, onDimensionsChange, dimensions.rows > minimumDimension2, testID),
253
+ renderResizeAction("Add column", { ...dimensions, columns: dimensions.columns + 1 }, onDimensionsChange, dimensions.columns < maximumDimension2, testID),
254
+ renderResizeAction("Remove column", { ...dimensions, columns: dimensions.columns - 1 }, onDimensionsChange, dimensions.columns > minimumDimension2, testID)
255
+ ]
256
+ });
257
+ }
258
+ function renderResizeAction(label, dimensions, onDimensionsChange, enabled, testID) {
259
+ return /* @__PURE__ */ jsx(import_react_native.Pressable, {
260
+ accessibilityLabel: label,
261
+ accessibilityRole: "button",
262
+ disabled: !enabled,
263
+ onPress: () => onDimensionsChange(dimensions),
264
+ testID: testID === undefined ? undefined : `${testID}-${label.toLowerCase().replace(" ", "-")}`,
265
+ children: /* @__PURE__ */ jsx(import_react_native.Text, {
266
+ children: label
267
+ })
268
+ });
269
+ }
270
+ function cellsEqual2(left, right) {
271
+ if (!left || !right)
272
+ return false;
273
+ return left.column === right.column && left.row === right.row;
274
+ }
275
+ function formatCellCoordinate(cell) {
276
+ return `${String.fromCharCode(96 + cell.column)}${cell.row}`;
277
+ }
278
+ function getCellKey(cell) {
279
+ return `${cell.column}:${cell.row}`;
280
+ }
281
+ var styles = import_react_native.StyleSheet.create({
282
+ board: {
283
+ borderRadius: 12,
284
+ borderWidth: import_react_native.StyleSheet.hairlineWidth,
285
+ overflow: "hidden",
286
+ width: "100%"
287
+ },
288
+ coordinate: {
289
+ fontSize: 9,
290
+ fontWeight: "600",
291
+ left: 3,
292
+ opacity: 0.72,
293
+ position: "absolute",
294
+ top: 2,
295
+ zIndex: 2
296
+ },
297
+ piece: { fontWeight: "600" },
298
+ pieceContainer: {
299
+ alignItems: "center",
300
+ bottom: 0,
301
+ justifyContent: "center",
302
+ left: 0,
303
+ position: "absolute",
304
+ right: 0,
305
+ top: 0
306
+ },
307
+ resizeActions: { flexDirection: "row", gap: 8, padding: 8 },
308
+ square: { alignItems: "center", justifyContent: "center", position: "relative" }
309
+ });
310
+
311
+ // src/features/chess/adapters/inbound/OpeningBook.tsx
312
+ var import_react_native2 = __toESM(require_cjs(), 1);
313
+
314
+ // src/features/chess/utils/createOpeningBookColorScheme.ts
315
+ function createOpeningBookColorScheme(theme, overrides) {
316
+ return {
317
+ border: theme.semantics.neutral.divider,
318
+ metricSurface: theme.semantics.neutral.surface,
319
+ primaryText: theme.semantics.content.default,
320
+ secondaryText: theme.semantics.content.muted,
321
+ selectedSurface: theme.semantics.action.primary.softBg,
322
+ surface: theme.semantics.neutral.surface,
323
+ surfaceHover: theme.semantics.neutral.surfaceHover,
324
+ titleText: theme.semantics.content.default,
325
+ ...overrides
326
+ };
327
+ }
328
+
329
+ // src/features/chess/adapters/inbound/OpeningBook.tsx
330
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
331
+ var OpeningBook2 = withZoraThemeScope(OpeningBookInner);
332
+ function rate(label, value) {
333
+ if (value === undefined || !Number.isFinite(value))
334
+ return;
335
+ return `${label} ${Math.round(value <= 1 ? value * 100 : value)}%`;
336
+ }
337
+ function moveKey(move) {
338
+ return move.uci ?? move.fen ?? move.san;
339
+ }
340
+ function OpeningBookInner({
341
+ moves = [],
342
+ title = "Opening book",
343
+ loading = false,
344
+ errorText,
345
+ emptyText = "No book moves for this position.",
346
+ selectedMove = null,
347
+ colorScheme,
348
+ onMovePress,
349
+ interactionPolicy,
350
+ testID
351
+ }) {
352
+ const { theme } = useZoraTheme2();
353
+ const colors = createOpeningBookColorScheme(theme, colorScheme);
354
+ const stateText = loading ? "Loading opening moves…" : errorText ?? emptyText;
355
+ const showState = loading || errorText !== undefined || moves.length === 0;
356
+ return /* @__PURE__ */ jsxs2(import_react_native2.View, {
357
+ accessibilityLabel: title,
358
+ style: [
359
+ styles2.root,
360
+ {
361
+ borderColor: colors.border,
362
+ backgroundColor: colors.surface
363
+ }
364
+ ],
365
+ testID,
366
+ children: [
367
+ /* @__PURE__ */ jsx2(import_react_native2.Text, {
368
+ style: [styles2.title, { color: colors.titleText }],
369
+ children: title
370
+ }),
371
+ !showState ? /* @__PURE__ */ jsx2(import_react_native2.View, {
372
+ style: styles2.moves,
373
+ children: moves.map((move) => {
374
+ const selected = selectedMove !== null && (selectedMove === move.san || selectedMove === move.uci || selectedMove === move.fen);
375
+ const details = [
376
+ move.eco,
377
+ move.name,
378
+ move.games === undefined ? undefined : `${move.games} games`
379
+ ].filter((part) => typeof part === "string" && part.length > 0);
380
+ const stats = [
381
+ rate("W", move.whiteWinRate),
382
+ rate("D", move.drawRate),
383
+ rate("B", move.blackWinRate)
384
+ ].filter((part) => part !== undefined);
385
+ return /* @__PURE__ */ jsxs2(import_react_native2.Pressable, {
386
+ accessibilityRole: "button",
387
+ disabled: onMovePress === undefined || interactionPolicy === "passive",
388
+ onPress: () => {
389
+ if (interactionPolicy === "passive")
390
+ return;
391
+ onMovePress?.(move);
392
+ },
393
+ style: [
394
+ styles2.move,
395
+ {
396
+ backgroundColor: selected ? colors.selectedSurface : colors.surfaceHover,
397
+ borderColor: colors.border
398
+ }
399
+ ],
400
+ testID: testID ? `${testID}-move-${move.san}` : undefined,
401
+ children: [
402
+ /* @__PURE__ */ jsxs2(import_react_native2.View, {
403
+ style: styles2.moveMain,
404
+ children: [
405
+ /* @__PURE__ */ jsx2(import_react_native2.Text, {
406
+ style: [styles2.san, { color: colors.primaryText }],
407
+ children: move.san
408
+ }),
409
+ /* @__PURE__ */ jsx2(import_react_native2.Text, {
410
+ style: [styles2.meta, { color: colors.secondaryText }],
411
+ children: details.length > 0 ? details.join(" · ") : "Book move"
412
+ })
413
+ ]
414
+ }),
415
+ stats.length > 0 ? /* @__PURE__ */ jsx2(import_react_native2.View, {
416
+ style: [styles2.metric, { backgroundColor: colors.metricSurface }],
417
+ children: /* @__PURE__ */ jsx2(import_react_native2.Text, {
418
+ style: [styles2.metricText, { color: colors.secondaryText }],
419
+ children: stats.join(" ")
420
+ })
421
+ }) : null
422
+ ]
423
+ }, moveKey(move));
424
+ })
425
+ }) : /* @__PURE__ */ jsx2(import_react_native2.Text, {
426
+ style: [styles2.stateText, { color: colors.secondaryText }],
427
+ children: stateText
428
+ })
429
+ ]
430
+ });
431
+ }
432
+ var styles2 = import_react_native2.StyleSheet.create({
433
+ root: { borderRadius: 12, borderWidth: import_react_native2.StyleSheet.hairlineWidth, gap: 10, padding: 12 },
434
+ title: { fontSize: 15, fontWeight: "700", lineHeight: 20 },
435
+ stateText: { fontSize: 13, lineHeight: 18 },
436
+ moves: { gap: 8 },
437
+ move: {
438
+ alignItems: "center",
439
+ borderRadius: 10,
440
+ borderWidth: import_react_native2.StyleSheet.hairlineWidth,
441
+ flexDirection: "row",
442
+ gap: 10,
443
+ justifyContent: "space-between",
444
+ paddingHorizontal: 10,
445
+ paddingVertical: 8
446
+ },
447
+ moveMain: { flex: 1, gap: 2 },
448
+ san: { fontSize: 16, fontWeight: "700", lineHeight: 20 },
449
+ meta: { fontSize: 12, lineHeight: 16 },
450
+ metric: { borderRadius: 999, paddingHorizontal: 8, paddingVertical: 4 },
451
+ metricText: { fontSize: 11, fontWeight: "600" }
452
+ });
453
+ export { ChessBoard2, OpeningBook2 };
@@ -1,10 +1,11 @@
1
1
  'use client';
2
+ import"../../chunks/Accordion-t0k1cjca.js";
2
3
  import"../../chunks/Accordion-6wrr910w.js";
3
4
  import"../../chunks/Accordion-vj1m2wck.js";
4
5
  import {
5
6
  ChessBoard2,
6
7
  OpeningBook2
7
- } from "../../chunks/Accordion-xcm1qc39.js";
8
+ } from "../../chunks/Accordion-91sjb3zh.js";
8
9
  import"../../chunks/Accordion-srjya6dz.js";
9
10
  import"../../chunks/Accordion-xgpzh4wq.js";
10
11
  export {
@@ -1,10 +1,11 @@
1
1
  'use client';
2
+ import"../../chunks/Accordion-t0k1cjca.js";
2
3
  import"../../chunks/Accordion-6wrr910w.js";
3
4
  import"../../chunks/Accordion-vj1m2wck.js";
4
5
  import {
5
6
  ChessBoard2,
6
7
  OpeningBook2
7
- } from "../../chunks/Accordion-xcm1qc39.js";
8
+ } from "../../chunks/Accordion-91sjb3zh.js";
8
9
  import"../../chunks/Accordion-srjya6dz.js";
9
10
  import"../../chunks/Accordion-xgpzh4wq.js";
10
11
  export {
@@ -870,12 +870,14 @@
870
870
  "components/chess-board/index.js",
871
871
  "components/chess-board/index.d.ts",
872
872
  "chunks/Accordion-6wrr910w.js",
873
+ "chunks/Accordion-91sjb3zh.js",
873
874
  "chunks/Accordion-fcczvwgg.js",
874
875
  "chunks/Accordion-nh0cs9hq.js",
875
876
  "chunks/Accordion-srjya6dz.js",
877
+ "chunks/Accordion-t0k1cjca.js",
876
878
  "chunks/Accordion-vj1m2wck.js",
877
- "chunks/Accordion-xcm1qc39.js",
878
- "chunks/Accordion-xgpzh4wq.js"
879
+ "chunks/Accordion-xgpzh4wq.js",
880
+ "chunks/Accordion-zypyr9xw.js"
879
881
  ],
880
882
  "sourceKind": "public"
881
883
  },
@@ -2372,12 +2374,14 @@
2372
2374
  "components/opening-book/index.js",
2373
2375
  "components/opening-book/index.d.ts",
2374
2376
  "chunks/Accordion-6wrr910w.js",
2377
+ "chunks/Accordion-91sjb3zh.js",
2375
2378
  "chunks/Accordion-fcczvwgg.js",
2376
2379
  "chunks/Accordion-nh0cs9hq.js",
2377
2380
  "chunks/Accordion-srjya6dz.js",
2381
+ "chunks/Accordion-t0k1cjca.js",
2378
2382
  "chunks/Accordion-vj1m2wck.js",
2379
- "chunks/Accordion-xcm1qc39.js",
2380
- "chunks/Accordion-xgpzh4wq.js"
2383
+ "chunks/Accordion-xgpzh4wq.js",
2384
+ "chunks/Accordion-zypyr9xw.js"
2381
2385
  ],
2382
2386
  "sourceKind": "public"
2383
2387
  },
@@ -1,8 +0,0 @@
1
- import type { ChessMoveAttempt, ChessMoveResult, ChessPieceState, ChessSquareId } from '../../../types/chess';
2
- /*** Read all pieces from a FEN-backed position. Invalid FEN produces an empty position. */
3
- export declare function readChessPieces(fen: string): ReadonlyMap<ChessSquareId, ChessPieceState>;
4
- /*** Resolve legal destination squares from one FEN position and source square. */
5
- export declare function getLegalTargets(fen: string, from: ChessSquareId): readonly ChessSquareId[];
6
- /*** Attempt one legal chess move against FEN and return the resulting position/move notation. */
7
- export declare function tryMove(fen: string, attempt: ChessMoveAttempt): ChessMoveResult | null;
8
- //# sourceMappingURL=chessEngine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chessEngine.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/chessEngine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,eAAe,EAEf,aAAa,EACd,MAAM,sBAAsB,CAAC;AAiC9B,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,aAAa,EAAE,eAAe,CAAC,CAgBxF;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,CAG1F;AAED,iGAAiG;AACjG,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,GAAG,IAAI,CActF"}
@@ -1,71 +0,0 @@
1
- import { Chess } from 'chess.js';
2
- /*** Create a chess.js position from FEN without leaking invalid-position exceptions. */
3
- function createChess(fen) {
4
- try {
5
- return new Chess(fen);
6
- }
7
- catch {
8
- return null;
9
- }
10
- }
11
- /*** Convert a chess.js piece into the public ZORA piece code. */
12
- function toPieceCode(piece) {
13
- return piece.color === 'w' ? piece.type.toUpperCase() : piece.type.toLowerCase();
14
- }
15
- /*** Normalize a chess.js promotion marker into the public promotion union. */
16
- function toPromotionPiece(piece) {
17
- return piece === 'q' || piece === 'r' || piece === 'b' || piece === 'n' ? piece : undefined;
18
- }
19
- /*** Convert one successful chess.js move into the public result contract. */
20
- function toMoveResult(move, fen) {
21
- return {
22
- fen,
23
- from: move.from,
24
- lan: move.lan,
25
- promotion: toPromotionPiece(move.promotion),
26
- san: move.san,
27
- to: move.to,
28
- };
29
- }
30
- /*** Read all pieces from a FEN-backed position. Invalid FEN produces an empty position. */
31
- export function readChessPieces(fen) {
32
- const chess = createChess(fen);
33
- const pieces = new Map();
34
- if (!chess)
35
- return pieces;
36
- for (const rank of chess.board()) {
37
- for (const piece of rank) {
38
- if (!piece)
39
- continue;
40
- pieces.set(piece.square, {
41
- color: piece.color === 'w' ? 'white' : 'black',
42
- piece: toPieceCode(piece),
43
- square: piece.square,
44
- });
45
- }
46
- }
47
- return pieces;
48
- }
49
- /*** Resolve legal destination squares from one FEN position and source square. */
50
- export function getLegalTargets(fen, from) {
51
- const chess = createChess(fen);
52
- return chess ? chess.moves({ square: from, verbose: true }).map((move) => move.to) : [];
53
- }
54
- /*** Attempt one legal chess move against FEN and return the resulting position/move notation. */
55
- export function tryMove(fen, attempt) {
56
- const chess = createChess(fen);
57
- if (!chess)
58
- return null;
59
- try {
60
- const move = chess.move({
61
- from: attempt.from,
62
- promotion: attempt.promotion,
63
- to: attempt.to,
64
- });
65
- return toMoveResult(move, chess.fen());
66
- }
67
- catch {
68
- return null;
69
- }
70
- }
71
- //# sourceMappingURL=chessEngine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chessEngine.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/chessEngine.ts"],"names":[],"mappings":"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","sourcesContent":["import { Chess, type Move } from 'chess.js';\n\nimport type {\n ChessMoveAttempt,\n ChessMoveResult,\n ChessPieceCode,\n ChessPieceState,\n ChessPromotionPiece,\n ChessSquareId,\n} from '../../../types/chess';\n\n/*** Create a chess.js position from FEN without leaking invalid-position exceptions. */\nfunction createChess(fen: string): Chess | null {\n try {\n return new Chess(fen);\n } catch {\n return null;\n }\n}\n\n/*** Convert a chess.js piece into the public ZORA piece code. */\nfunction toPieceCode(piece: { readonly color: 'b' | 'w'; readonly type: string }): ChessPieceCode {\n return piece.color === 'w' ? piece.type.toUpperCase() : piece.type.toLowerCase();\n}\n\n/*** Normalize a chess.js promotion marker into the public promotion union. */\nfunction toPromotionPiece(piece: string | undefined): ChessPromotionPiece | undefined {\n return piece === 'q' || piece === 'r' || piece === 'b' || piece === 'n' ? piece : undefined;\n}\n\n/*** Convert one successful chess.js move into the public result contract. */\nfunction toMoveResult(move: Move, fen: string): ChessMoveResult {\n return {\n fen,\n from: move.from,\n lan: move.lan,\n promotion: toPromotionPiece(move.promotion),\n san: move.san,\n to: move.to,\n };\n}\n\n/*** Read all pieces from a FEN-backed position. Invalid FEN produces an empty position. */\nexport function readChessPieces(fen: string): ReadonlyMap<ChessSquareId, ChessPieceState> {\n const chess = createChess(fen);\n const pieces = new Map<ChessSquareId, ChessPieceState>();\n if (!chess) return pieces;\n\n for (const rank of chess.board()) {\n for (const piece of rank) {\n if (!piece) continue;\n pieces.set(piece.square, {\n color: piece.color === 'w' ? 'white' : 'black',\n piece: toPieceCode(piece),\n square: piece.square,\n });\n }\n }\n return pieces;\n}\n\n/*** Resolve legal destination squares from one FEN position and source square. */\nexport function getLegalTargets(fen: string, from: ChessSquareId): readonly ChessSquareId[] {\n const chess = createChess(fen);\n return chess ? chess.moves({ square: from, verbose: true }).map((move) => move.to) : [];\n}\n\n/*** Attempt one legal chess move against FEN and return the resulting position/move notation. */\nexport function tryMove(fen: string, attempt: ChessMoveAttempt): ChessMoveResult | null {\n const chess = createChess(fen);\n if (!chess) return null;\n\n try {\n const move = chess.move({\n from: attempt.from,\n promotion: attempt.promotion,\n to: attempt.to,\n });\n return toMoveResult(move, chess.fen());\n } catch {\n return null;\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- import type { ChessSquareId } from '../../../types/chess';
2
- /*** Lists every board square in ascending rank and file order. */
3
- export declare const chessSquares: readonly ChessSquareId[];
4
- //# sourceMappingURL=chessSquares.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chessSquares.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/chessSquares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,kEAAkE;AAClE,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EAEhD,CAAC"}
@@ -1,3 +0,0 @@
1
- /*** Lists every board square in ascending rank and file order. */
2
- export const chessSquares = [1, 2, 3, 4, 5, 6, 7, 8].flatMap((rank) => [...'abcdefgh'].map((file) => `${file}${rank}`));
3
- //# sourceMappingURL=chessSquares.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chessSquares.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/chessSquares.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,MAAM,CAAC,MAAM,YAAY,GAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9F,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAmB,CAAC,CACjE,CAAC","sourcesContent":["import type { ChessSquareId } from '../../../types/chess';\n\n/*** Lists every board square in ascending rank and file order. */\nexport const chessSquares: readonly ChessSquareId[] = [1, 2, 3, 4, 5, 6, 7, 8].flatMap((rank) =>\n [...'abcdefgh'].map((file) => `${file}${rank}` as ChessSquareId),\n);\n"]}
@@ -1,4 +0,0 @@
1
- import type { ChessBoardOrientation, ChessSquareId } from '../../../types/chess';
2
- /*** Orders the 64 displayed squares for the selected player orientation. */
3
- export declare function createBoardSquares(orientation: ChessBoardOrientation): readonly ChessSquareId[];
4
- //# sourceMappingURL=createBoardSquares.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBoardSquares.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/createBoardSquares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKjF,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,qBAAqB,GAAG,SAAS,aAAa,EAAE,CAM/F"}
@@ -1,9 +0,0 @@
1
- const files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
2
- const ranks = ['1', '2', '3', '4', '5', '6', '7', '8'];
3
- /*** Orders the 64 displayed squares for the selected player orientation. */
4
- export function createBoardSquares(orientation) {
5
- const displayedRanks = orientation === 'white' ? [...ranks].reverse() : [...ranks];
6
- const displayedFiles = orientation === 'white' ? [...files] : [...files].reverse();
7
- return displayedRanks.flatMap((rank) => displayedFiles.map((file) => `${file}${rank}`));
8
- }
9
- //# sourceMappingURL=createBoardSquares.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBoardSquares.js","sourceRoot":"","sources":["../../../../src/features/chess/utils/createBoardSquares.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAChE,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAEhE,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB,CAAC,WAAkC;IACnE,MAAM,cAAc,GAAG,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IACnF,MAAM,cAAc,GAAG,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACnF,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACrC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAiB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["import type { ChessBoardOrientation, ChessSquareId } from '../../../types/chess';\n\nconst files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as const;\nconst ranks = ['1', '2', '3', '4', '5', '6', '7', '8'] as const;\n\n/*** Orders the 64 displayed squares for the selected player orientation. */\nexport function createBoardSquares(orientation: ChessBoardOrientation): readonly ChessSquareId[] {\n const displayedRanks = orientation === 'white' ? [...ranks].reverse() : [...ranks];\n const displayedFiles = orientation === 'white' ? [...files] : [...files].reverse();\n return displayedRanks.flatMap((rank) =>\n displayedFiles.map((file): ChessSquareId => `${file}${rank}`),\n );\n}\n"]}
@@ -1,4 +0,0 @@
1
- import type { ChessSquareId } from '../../../types/chess';
2
- /*** Returns the file letter of a chess square. */
3
- export declare function getSquareFile(square: ChessSquareId): string;
4
- //# sourceMappingURL=getSquareFile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSquareFile.d.ts","sourceRoot":"","sources":["../../../../src/features/chess/utils/getSquareFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE3D"}