@connectorvol/tree 1.1.0 → 1.2.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/package.json +30 -29
- package/dist/(classes)/chessTree.svelte.d.ts +0 -51
- package/dist/(classes)/chessTree.svelte.js +0 -160
- package/dist/(components)/ImportToPgn.svelte +0 -16
- package/dist/(components)/ImportToPgn.svelte.d.ts +0 -7
- package/dist/(components)/Move.svelte +0 -285
- package/dist/(components)/Move.svelte.d.ts +0 -14
- package/dist/(components)/MoveWithIcon.svelte +0 -48
- package/dist/(components)/MoveWithIcon.svelte.d.ts +0 -14
- package/dist/(components)/PieceIcon.svelte +0 -44
- package/dist/(components)/PieceIcon.svelte.d.ts +0 -15
- package/dist/(components)/TreeViewer.svelte +0 -82
- package/dist/(components)/TreeViewer.svelte.d.ts +0 -17
- package/dist/(components)/TreeViewerPanelManager.svelte +0 -246
- package/dist/(components)/TreeViewerPanelManager.svelte.d.ts +0 -13
- package/dist/(constants)/png.d.ts +0 -11
- package/dist/(constants)/png.js +0 -126
- package/dist/(models)/chessTreeNode.d.ts +0 -15
- package/dist/(models)/chessTreeNode.js +0 -1
- package/dist/(models)/pgnNodeCustomData.d.ts +0 -10
- package/dist/(models)/pgnNodeCustomData.js +0 -1
- package/dist/(utils)/context.d.ts +0 -13
- package/dist/(utils)/context.js +0 -17
- package/dist/(utils)/createPgnFromTree.d.ts +0 -2
- package/dist/(utils)/createPgnFromTree.js +0 -5
- package/dist/(utils)/parseSanMove.d.ts +0 -27
- package/dist/(utils)/parseSanMove.js +0 -84
- package/dist/(utils)/scrollToActiveMove.d.ts +0 -7
- package/dist/(utils)/scrollToActiveMove.js +0 -72
- package/dist/(utils)/scrollToStart.d.ts +0 -6
- package/dist/(utils)/scrollToStart.js +0 -46
- package/dist/(utils)/transformNag.d.ts +0 -1
- package/dist/(utils)/transformNag.js +0 -34
- package/dist/(utils)/transformPgnToChessNode.d.ts +0 -7
- package/dist/(utils)/transformPgnToChessNode.js +0 -56
- package/dist/components/ui/button/button.svelte +0 -82
- package/dist/components/ui/button/button.svelte.d.ts +0 -64
- package/dist/components/ui/button/index.d.ts +0 -2
- package/dist/components/ui/button/index.js +0 -4
- package/dist/components/ui/button-group/button-group-separator.svelte +0 -20
- package/dist/components/ui/button-group/button-group-separator.svelte.d.ts +0 -13
- package/dist/components/ui/button-group/button-group-text.svelte +0 -30
- package/dist/components/ui/button-group/button-group-text.svelte.d.ts +0 -11
- package/dist/components/ui/button-group/button-group.svelte +0 -46
- package/dist/components/ui/button-group/button-group.svelte.d.ts +0 -26
- package/dist/components/ui/button-group/index.d.ts +0 -4
- package/dist/components/ui/button-group/index.js +0 -6
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte +0 -38
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte.d.ts +0 -9
- package/dist/components/ui/context-menu/context-menu-content.svelte +0 -25
- package/dist/components/ui/context-menu/context-menu-content.svelte.d.ts +0 -7
- package/dist/components/ui/context-menu/context-menu-group-heading.svelte +0 -21
- package/dist/components/ui/context-menu/context-menu-group-heading.svelte.d.ts +0 -7
- package/dist/components/ui/context-menu/context-menu-group.svelte +0 -7
- package/dist/components/ui/context-menu/context-menu-group.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/context-menu-item.svelte +0 -27
- package/dist/components/ui/context-menu/context-menu-item.svelte.d.ts +0 -8
- package/dist/components/ui/context-menu/context-menu-label.svelte +0 -24
- package/dist/components/ui/context-menu/context-menu-label.svelte.d.ts +0 -8
- package/dist/components/ui/context-menu/context-menu-radio-group.svelte +0 -16
- package/dist/components/ui/context-menu/context-menu-radio-group.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte +0 -31
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/context-menu-separator.svelte +0 -17
- package/dist/components/ui/context-menu/context-menu-separator.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte +0 -20
- package/dist/components/ui/context-menu/context-menu-shortcut.svelte.d.ts +0 -5
- package/dist/components/ui/context-menu/context-menu-sub-content.svelte +0 -20
- package/dist/components/ui/context-menu/context-menu-sub-content.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +0 -29
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte.d.ts +0 -8
- package/dist/components/ui/context-menu/context-menu-trigger.svelte +0 -7
- package/dist/components/ui/context-menu/context-menu-trigger.svelte.d.ts +0 -4
- package/dist/components/ui/context-menu/index.d.ts +0 -16
- package/dist/components/ui/context-menu/index.js +0 -19
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +0 -41
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +0 -9
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +0 -27
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +0 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +0 -22
- package/dist/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +0 -8
- package/dist/components/ui/dropdown-menu/dropdown-menu-group.svelte +0 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-group.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +0 -27
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +0 -8
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte +0 -24
- package/dist/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +0 -8
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +0 -16
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +0 -31
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte +0 -17
- package/dist/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +0 -20
- package/dist/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +0 -5
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +0 -20
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +0 -29
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +0 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +0 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +0 -4
- package/dist/components/ui/dropdown-menu/index.js +0 -17
- package/dist/components/ui/separator/index.d.ts +0 -2
- package/dist/components/ui/separator/index.js +0 -4
- package/dist/components/ui/separator/separator.svelte +0 -21
- package/dist/components/ui/separator/separator.svelte.d.ts +0 -4
- package/dist/components/ui/sonner/index.d.ts +0 -1
- package/dist/components/ui/sonner/index.js +0 -1
- package/dist/components/ui/sonner/sonner.svelte +0 -13
- package/dist/components/ui/sonner/sonner.svelte.d.ts +0 -4
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -7
- package/dist/utils.d.ts +0 -12
- package/dist/utils.js +0 -5
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PgnNodeCustomData } from "./pgnNodeCustomData.js";
|
|
2
|
-
/**
|
|
3
|
-
* Данная модель используется для хранения дерева в виде объекта.
|
|
4
|
-
*/
|
|
5
|
-
export type ChessTreeNode = {
|
|
6
|
-
id: string;
|
|
7
|
-
children: ChessTreeNode[];
|
|
8
|
-
parentId?: string;
|
|
9
|
-
data: PgnNodeCustomData;
|
|
10
|
-
};
|
|
11
|
-
export type TChessTree = {
|
|
12
|
-
moves: ChessTreeNode;
|
|
13
|
-
headers: Map<string, string>;
|
|
14
|
-
comments?: string[];
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Comment } from "@connectorvol/chessops/pgn";
|
|
2
|
-
import type { PgnNodeData } from "@connectorvol/chessops/pgn";
|
|
3
|
-
export type PgnNodeCustomData = PgnNodeData & {
|
|
4
|
-
fen: string;
|
|
5
|
-
san: string;
|
|
6
|
-
ply: number;
|
|
7
|
-
fullMoves: number;
|
|
8
|
-
/** Возвращает результат парсинга первого комментария (кэш для производительности) */
|
|
9
|
-
parsedFirstComment?: Comment | null;
|
|
10
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ChessTree } from "../(classes)/chessTree.svelte.js";
|
|
2
|
-
interface GameContext {
|
|
3
|
-
chessTree: ChessTree;
|
|
4
|
-
onSelectNode: () => void;
|
|
5
|
-
onDeleteVariant: () => void;
|
|
6
|
-
setChessFen: (fen: string) => void;
|
|
7
|
-
setChessboardFen: (animationTime?: number) => void;
|
|
8
|
-
/** Возвращает true, если клик по ходу в дереве переключает текущий узел и доску */
|
|
9
|
-
selectable: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function initGameContext(chessTree: ChessTree, onSelectNode: () => void, onDeleteVariant: () => void, setChessFen: (fen: string) => void, setChessboardFen: (animationTime?: number) => void, selectable?: boolean): void;
|
|
12
|
-
export declare function getGameContext(): GameContext;
|
|
13
|
-
export {};
|
package/dist/(utils)/context.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getContext, setContext } from "svelte";
|
|
2
|
-
import { ChessTree } from "../(classes)/chessTree.svelte.js";
|
|
3
|
-
// import { Game } from '../(classes)/game.svelte.js';
|
|
4
|
-
const CHESS_TREE = "chessTree";
|
|
5
|
-
export function initGameContext(chessTree, onSelectNode, onDeleteVariant, setChessFen, setChessboardFen, selectable = true) {
|
|
6
|
-
setContext(CHESS_TREE, {
|
|
7
|
-
chessTree,
|
|
8
|
-
onSelectNode,
|
|
9
|
-
onDeleteVariant,
|
|
10
|
-
setChessFen,
|
|
11
|
-
setChessboardFen,
|
|
12
|
-
selectable,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export function getGameContext() {
|
|
16
|
-
return getContext(CHESS_TREE);
|
|
17
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Color, PieceType } from "@connectorvol/shared";
|
|
2
|
-
/**
|
|
3
|
-
* Представляет информацию о ходе, извлеченную из SAN нотации
|
|
4
|
-
*/
|
|
5
|
-
export interface ParsedSanMove {
|
|
6
|
-
/** Возвращает тип фигуры */
|
|
7
|
-
pieceType: PieceType;
|
|
8
|
-
/** Возвращает цвет фигуры */
|
|
9
|
-
color: Color;
|
|
10
|
-
/** Возвращает true если это рокировка */
|
|
11
|
-
isCastling: boolean;
|
|
12
|
-
/** Возвращает true если это взятие */
|
|
13
|
-
isCapture: boolean;
|
|
14
|
-
/** Возвращает true если это шах */
|
|
15
|
-
isCheck: boolean;
|
|
16
|
-
/** Возвращает true если это мат */
|
|
17
|
-
isCheckmate: boolean;
|
|
18
|
-
/** Возвращает координаты назначения (например, "f3", "e4") */
|
|
19
|
-
destination?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Представляет функцию для парсинга SAN нотации в информацию о ходе
|
|
23
|
-
* @param san - SAN нотация хода (например, "Nf3", "exd4", "O-O")
|
|
24
|
-
* @param ply - Номер полухода для определения цвета фигуры
|
|
25
|
-
* @returns Объект с информацией о ходе
|
|
26
|
-
*/
|
|
27
|
-
export declare function parseSanMove(san: string, ply: number): ParsedSanMove;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Color, PieceType } from "@connectorvol/shared";
|
|
2
|
-
/**
|
|
3
|
-
* Представляет функцию для парсинга SAN нотации в информацию о ходе
|
|
4
|
-
* @param san - SAN нотация хода (например, "Nf3", "exd4", "O-O")
|
|
5
|
-
* @param ply - Номер полухода для определения цвета фигуры
|
|
6
|
-
* @returns Объект с информацией о ходе
|
|
7
|
-
*/
|
|
8
|
-
export function parseSanMove(san, ply) {
|
|
9
|
-
const color = ply % 2 === 1 ? Color.WHITE : Color.BLACK;
|
|
10
|
-
let cleanSan = san;
|
|
11
|
-
const isCheck = san.includes("+");
|
|
12
|
-
const isCheckmate = san.includes("#");
|
|
13
|
-
if (isCheck || isCheckmate) {
|
|
14
|
-
// Удаляем символы шаха и мата для анализа
|
|
15
|
-
cleanSan = san.replace(/[+#]$/, "");
|
|
16
|
-
}
|
|
17
|
-
// Проверяем рокировку
|
|
18
|
-
if (cleanSan === "O-O" || cleanSan === "O-O-O") {
|
|
19
|
-
return {
|
|
20
|
-
pieceType: PieceType.KING,
|
|
21
|
-
color,
|
|
22
|
-
isCastling: true,
|
|
23
|
-
isCapture: false,
|
|
24
|
-
isCheck,
|
|
25
|
-
isCheckmate,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
// Определяем тип фигуры по первому символу
|
|
29
|
-
let pieceType;
|
|
30
|
-
let moveNotation = cleanSan;
|
|
31
|
-
if (cleanSan[0] >= "A" && cleanSan[0] <= "Z") {
|
|
32
|
-
// Ход фигуры (не пешки)
|
|
33
|
-
switch (cleanSan[0]) {
|
|
34
|
-
case "K":
|
|
35
|
-
pieceType = PieceType.KING;
|
|
36
|
-
break;
|
|
37
|
-
case "Q":
|
|
38
|
-
pieceType = PieceType.QUEEN;
|
|
39
|
-
break;
|
|
40
|
-
case "R":
|
|
41
|
-
pieceType = PieceType.ROOK;
|
|
42
|
-
break;
|
|
43
|
-
case "B":
|
|
44
|
-
pieceType = PieceType.BISHOP;
|
|
45
|
-
break;
|
|
46
|
-
case "N":
|
|
47
|
-
pieceType = PieceType.KNIGHT;
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
pieceType = PieceType.PAWN;
|
|
51
|
-
}
|
|
52
|
-
moveNotation = cleanSan.slice(1);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Ход пешки
|
|
56
|
-
pieceType = PieceType.PAWN;
|
|
57
|
-
}
|
|
58
|
-
// Определяем взятие
|
|
59
|
-
const isCapture = moveNotation.includes("x");
|
|
60
|
-
// Извлекаем координаты назначения
|
|
61
|
-
let destination = "";
|
|
62
|
-
if (isCapture) {
|
|
63
|
-
// После 'x' идут координаты назначения
|
|
64
|
-
const xIndex = moveNotation.indexOf("x");
|
|
65
|
-
destination = moveNotation.slice(xIndex + 1);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
// Последние 2 символа - координаты назначения
|
|
69
|
-
destination = moveNotation.slice(-2);
|
|
70
|
-
}
|
|
71
|
-
// Обрабатываем превращение пешки
|
|
72
|
-
if (destination.includes("=")) {
|
|
73
|
-
destination = destination.split("=")[0];
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
pieceType,
|
|
77
|
-
color,
|
|
78
|
-
destination,
|
|
79
|
-
isCastling: false,
|
|
80
|
-
isCapture,
|
|
81
|
-
isCheck,
|
|
82
|
-
isCheckmate,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const ACTIVE_MOVE_CLASS = "active-move-in-tree-viewer";
|
|
2
|
-
/**
|
|
3
|
-
* Представляет функцию для автоматического скролла до активного хода, если он не виден
|
|
4
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
5
|
-
* @param behavior - Поведение скролла ('smooth' | 'instant' | 'auto')
|
|
6
|
-
*/
|
|
7
|
-
export declare function scrollToActiveMoveIfNeeded(containerId?: string, behavior?: ScrollBehavior): void;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export const ACTIVE_MOVE_CLASS = "active-move-in-tree-viewer";
|
|
2
|
-
/**
|
|
3
|
-
* Представляет функцию для плавного скролла до активного хода в дереве ходов
|
|
4
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
5
|
-
* @param behavior - Поведение скролла ('smooth' | 'instant' | 'auto')
|
|
6
|
-
*/
|
|
7
|
-
function scrollToActiveMove(containerId = "tree-viewer-container", behavior = "instant") {
|
|
8
|
-
const container = document.getElementById(containerId);
|
|
9
|
-
if (!container) {
|
|
10
|
-
console.warn(`Контейнер с ID "${containerId}" не найден`);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
// Ищем активный элемент по классу outline-primary
|
|
14
|
-
const activeElement = container.querySelector(`.${ACTIVE_MOVE_CLASS}`);
|
|
15
|
-
if (!activeElement) {
|
|
16
|
-
console.warn("Активный ход не найден в дереве");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// Получаем позицию элемента относительно контейнера
|
|
20
|
-
const containerRect = container.getBoundingClientRect();
|
|
21
|
-
const elementRect = activeElement.getBoundingClientRect();
|
|
22
|
-
// Вычисляем текущую позицию скролла
|
|
23
|
-
const currentScrollTop = container.scrollTop;
|
|
24
|
-
const currentScrollLeft = container.scrollLeft;
|
|
25
|
-
// Вычисляем целевую позицию скролла
|
|
26
|
-
const targetScrollTop = currentScrollTop +
|
|
27
|
-
elementRect.top -
|
|
28
|
-
containerRect.top -
|
|
29
|
-
containerRect.height / 2 +
|
|
30
|
-
elementRect.height / 2;
|
|
31
|
-
const targetScrollLeft = currentScrollLeft +
|
|
32
|
-
elementRect.left -
|
|
33
|
-
containerRect.left -
|
|
34
|
-
containerRect.width / 2 +
|
|
35
|
-
elementRect.width / 2;
|
|
36
|
-
// Выполняем скролл
|
|
37
|
-
container.scrollTo({
|
|
38
|
-
top: Math.max(0, targetScrollTop),
|
|
39
|
-
left: Math.max(0, targetScrollLeft),
|
|
40
|
-
behavior,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Представляет функцию для проверки, виден ли активный ход в контейнере
|
|
45
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
46
|
-
* @returns Возвращает true, если активный ход полностью виден
|
|
47
|
-
*/
|
|
48
|
-
function isActiveMoveVisible(containerId = "tree-viewer-container") {
|
|
49
|
-
const container = document.getElementById(containerId);
|
|
50
|
-
if (!container)
|
|
51
|
-
return false;
|
|
52
|
-
const activeElement = container.querySelector(".outline-primary");
|
|
53
|
-
if (!activeElement)
|
|
54
|
-
return false;
|
|
55
|
-
const containerRect = container.getBoundingClientRect();
|
|
56
|
-
const elementRect = activeElement.getBoundingClientRect();
|
|
57
|
-
// Проверяем, что элемент полностью виден в контейнере
|
|
58
|
-
return (elementRect.top >= containerRect.top &&
|
|
59
|
-
elementRect.bottom <= containerRect.bottom &&
|
|
60
|
-
elementRect.left >= containerRect.left &&
|
|
61
|
-
elementRect.right <= containerRect.right);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Представляет функцию для автоматического скролла до активного хода, если он не виден
|
|
65
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
66
|
-
* @param behavior - Поведение скролла ('smooth' | 'instant' | 'auto')
|
|
67
|
-
*/
|
|
68
|
-
export function scrollToActiveMoveIfNeeded(containerId = "tree-viewer-container", behavior = "instant") {
|
|
69
|
-
if (!isActiveMoveVisible(containerId)) {
|
|
70
|
-
scrollToActiveMove(containerId, behavior);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Представляет функцию для скролла к началу дерева ходов (первый видимый ход)
|
|
3
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
4
|
-
* @param behavior - Поведение скролла ('smooth' | 'instant' | 'auto')
|
|
5
|
-
*/
|
|
6
|
-
export declare function scrollToStart(containerId?: string, behavior?: ScrollBehavior): void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Представляет функцию для скролла к началу дерева ходов (первый видимый ход)
|
|
3
|
-
* @param containerId - ID контейнера с деревом ходов
|
|
4
|
-
* @param behavior - Поведение скролла ('smooth' | 'instant' | 'auto')
|
|
5
|
-
*/
|
|
6
|
-
export function scrollToStart(containerId = "tree-viewer-container", behavior = "instant") {
|
|
7
|
-
const container = document.getElementById(containerId);
|
|
8
|
-
if (!container) {
|
|
9
|
-
console.warn(`Контейнер с ID "${containerId}" не найден`);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
// Ищем первый элемент с data-node-id (первый видимый ход)
|
|
13
|
-
const firstMoveElement = container.querySelector("[data-node-id]");
|
|
14
|
-
if (!firstMoveElement) {
|
|
15
|
-
// Если нет ходов с data-node-id, скроллим в самое начало контейнера
|
|
16
|
-
container.scrollTo({
|
|
17
|
-
top: 0,
|
|
18
|
-
left: 0,
|
|
19
|
-
behavior,
|
|
20
|
-
});
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// Получаем позицию элемента относительно контейнера
|
|
24
|
-
const containerRect = container.getBoundingClientRect();
|
|
25
|
-
const elementRect = firstMoveElement.getBoundingClientRect();
|
|
26
|
-
// Вычисляем текущую позицию скролла
|
|
27
|
-
const currentScrollTop = container.scrollTop;
|
|
28
|
-
const currentScrollLeft = container.scrollLeft;
|
|
29
|
-
// Вычисляем целевую позицию скролла
|
|
30
|
-
const targetScrollTop = currentScrollTop +
|
|
31
|
-
elementRect.top -
|
|
32
|
-
containerRect.top -
|
|
33
|
-
containerRect.height / 2 +
|
|
34
|
-
elementRect.height / 2;
|
|
35
|
-
const targetScrollLeft = currentScrollLeft +
|
|
36
|
-
elementRect.left -
|
|
37
|
-
containerRect.left -
|
|
38
|
-
containerRect.width / 2 +
|
|
39
|
-
elementRect.width / 2;
|
|
40
|
-
// Выполняем скролл
|
|
41
|
-
container.scrollTo({
|
|
42
|
-
top: Math.max(0, targetScrollTop),
|
|
43
|
-
left: Math.max(0, targetScrollLeft),
|
|
44
|
-
behavior,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function transformNag(nag: number): string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export function transformNag(nag) {
|
|
2
|
-
if (nag === undefined)
|
|
3
|
-
return "";
|
|
4
|
-
switch (nag) {
|
|
5
|
-
case 1:
|
|
6
|
-
return "!";
|
|
7
|
-
case 2:
|
|
8
|
-
return "?";
|
|
9
|
-
case 3:
|
|
10
|
-
return "!!";
|
|
11
|
-
case 5:
|
|
12
|
-
return "!?";
|
|
13
|
-
case 6:
|
|
14
|
-
return "?!";
|
|
15
|
-
case 7:
|
|
16
|
-
// TODO: Переделать на нормальное отображение
|
|
17
|
-
return "only move";
|
|
18
|
-
case 10:
|
|
19
|
-
return "=";
|
|
20
|
-
case 13:
|
|
21
|
-
return "∞";
|
|
22
|
-
case 14:
|
|
23
|
-
return "⩲";
|
|
24
|
-
case 16:
|
|
25
|
-
return "±";
|
|
26
|
-
case 18:
|
|
27
|
-
return "+-";
|
|
28
|
-
case 40:
|
|
29
|
-
return "→";
|
|
30
|
-
default: {
|
|
31
|
-
return "not implemented " + nag;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { makeFen } from "@connectorvol/chessops/fen";
|
|
2
|
-
import { parseComment, parsePgn, startingPosition, transform } from "@connectorvol/chessops/pgn";
|
|
3
|
-
import { makeSanAndPlay, parseSan } from "@connectorvol/chessops/san";
|
|
4
|
-
import { calculatePly, generateId } from "@connectorvol/shared";
|
|
5
|
-
export function transformPgnToChessNode(pgn) {
|
|
6
|
-
const games = parsePgn(pgn);
|
|
7
|
-
const game = games[0];
|
|
8
|
-
const position = startingPosition(game.headers).unwrap();
|
|
9
|
-
const initialFen = makeFen(position.toSetup());
|
|
10
|
-
const moves = transform(game.moves, position, (pos, node) => {
|
|
11
|
-
const move = parseSan(pos, node.san);
|
|
12
|
-
if (!move) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const san = makeSanAndPlay(pos, move); // Mutating pos!
|
|
16
|
-
const fen = makeFen(pos.toSetup());
|
|
17
|
-
const { halfMoves, fullMoves } = calculatePly(fen);
|
|
18
|
-
const firstComment = node.comments?.[0];
|
|
19
|
-
return {
|
|
20
|
-
...node,
|
|
21
|
-
san,
|
|
22
|
-
fen,
|
|
23
|
-
ply: halfMoves,
|
|
24
|
-
fullMoves,
|
|
25
|
-
parsedFirstComment: firstComment ? parseComment(firstComment) : null,
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
const rootNode = {
|
|
29
|
-
children: moves.children,
|
|
30
|
-
data: { fen: initialFen, san: "", ply: 0, fullMoves: 0 },
|
|
31
|
-
id: "",
|
|
32
|
-
parentId: undefined,
|
|
33
|
-
};
|
|
34
|
-
setParentIdAndId(rootNode);
|
|
35
|
-
return {
|
|
36
|
-
rootNode: structuredClone({
|
|
37
|
-
moves: rootNode,
|
|
38
|
-
headers: game.headers,
|
|
39
|
-
comments: game.comments,
|
|
40
|
-
}),
|
|
41
|
-
initialFen,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function setParentIdAndId(rootNode) {
|
|
45
|
-
const stack = [
|
|
46
|
-
{ node: rootNode, parentId: undefined },
|
|
47
|
-
];
|
|
48
|
-
while (stack.length > 0) {
|
|
49
|
-
const { node, parentId } = stack.pop();
|
|
50
|
-
node.id = generateId();
|
|
51
|
-
node.parentId = parentId;
|
|
52
|
-
for (let i = node.children.length - 1; i >= 0; i--) {
|
|
53
|
-
stack.push({ node: node.children[i], parentId: node.id });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
-
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
|
4
|
-
import { type VariantProps, tv } from "tailwind-variants";
|
|
5
|
-
|
|
6
|
-
export const buttonVariants = tv({
|
|
7
|
-
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
8
|
-
variants: {
|
|
9
|
-
variant: {
|
|
10
|
-
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
11
|
-
destructive:
|
|
12
|
-
"bg-destructive shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white",
|
|
13
|
-
outline:
|
|
14
|
-
"bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border",
|
|
15
|
-
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
16
|
-
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
17
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
-
},
|
|
19
|
-
size: {
|
|
20
|
-
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
21
|
-
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
22
|
-
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
23
|
-
icon: "size-9",
|
|
24
|
-
"icon-sm": "size-8",
|
|
25
|
-
"icon-lg": "size-10",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
defaultVariants: {
|
|
29
|
-
variant: "default",
|
|
30
|
-
size: "default",
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|
35
|
-
export type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
|
36
|
-
|
|
37
|
-
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
38
|
-
WithElementRef<HTMLAnchorAttributes> & {
|
|
39
|
-
variant?: ButtonVariant;
|
|
40
|
-
size?: ButtonSize;
|
|
41
|
-
};
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
let {
|
|
46
|
-
class: className,
|
|
47
|
-
variant = "default",
|
|
48
|
-
size = "default",
|
|
49
|
-
ref = $bindable(null),
|
|
50
|
-
href = undefined,
|
|
51
|
-
type = "button",
|
|
52
|
-
disabled,
|
|
53
|
-
children,
|
|
54
|
-
...restProps
|
|
55
|
-
}: ButtonProps = $props();
|
|
56
|
-
</script>
|
|
57
|
-
|
|
58
|
-
{#if href}
|
|
59
|
-
<a
|
|
60
|
-
bind:this={ref}
|
|
61
|
-
data-slot="button"
|
|
62
|
-
class={cn(buttonVariants({ variant, size }), className)}
|
|
63
|
-
href={disabled ? undefined : href}
|
|
64
|
-
aria-disabled={disabled}
|
|
65
|
-
role={disabled ? "link" : undefined}
|
|
66
|
-
tabindex={disabled ? -1 : undefined}
|
|
67
|
-
{...restProps}
|
|
68
|
-
>
|
|
69
|
-
{@render children?.()}
|
|
70
|
-
</a>
|
|
71
|
-
{:else}
|
|
72
|
-
<button
|
|
73
|
-
bind:this={ref}
|
|
74
|
-
data-slot="button"
|
|
75
|
-
class={cn(buttonVariants({ variant, size }), className)}
|
|
76
|
-
{type}
|
|
77
|
-
{disabled}
|
|
78
|
-
{...restProps}
|
|
79
|
-
>
|
|
80
|
-
{@render children?.()}
|
|
81
|
-
</button>
|
|
82
|
-
{/if}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type WithElementRef } from "../../../utils.js";
|
|
2
|
-
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
|
3
|
-
import { type VariantProps } from "tailwind-variants";
|
|
4
|
-
export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
5
|
-
variant: {
|
|
6
|
-
default: string;
|
|
7
|
-
destructive: string;
|
|
8
|
-
outline: string;
|
|
9
|
-
secondary: string;
|
|
10
|
-
ghost: string;
|
|
11
|
-
link: string;
|
|
12
|
-
};
|
|
13
|
-
size: {
|
|
14
|
-
default: string;
|
|
15
|
-
sm: string;
|
|
16
|
-
lg: string;
|
|
17
|
-
icon: string;
|
|
18
|
-
"icon-sm": string;
|
|
19
|
-
"icon-lg": string;
|
|
20
|
-
};
|
|
21
|
-
}, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
22
|
-
variant: {
|
|
23
|
-
default: string;
|
|
24
|
-
destructive: string;
|
|
25
|
-
outline: string;
|
|
26
|
-
secondary: string;
|
|
27
|
-
ghost: string;
|
|
28
|
-
link: string;
|
|
29
|
-
};
|
|
30
|
-
size: {
|
|
31
|
-
default: string;
|
|
32
|
-
sm: string;
|
|
33
|
-
lg: string;
|
|
34
|
-
icon: string;
|
|
35
|
-
"icon-sm": string;
|
|
36
|
-
"icon-lg": string;
|
|
37
|
-
};
|
|
38
|
-
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
39
|
-
variant: {
|
|
40
|
-
default: string;
|
|
41
|
-
destructive: string;
|
|
42
|
-
outline: string;
|
|
43
|
-
secondary: string;
|
|
44
|
-
ghost: string;
|
|
45
|
-
link: string;
|
|
46
|
-
};
|
|
47
|
-
size: {
|
|
48
|
-
default: string;
|
|
49
|
-
sm: string;
|
|
50
|
-
lg: string;
|
|
51
|
-
icon: string;
|
|
52
|
-
"icon-sm": string;
|
|
53
|
-
"icon-lg": string;
|
|
54
|
-
};
|
|
55
|
-
}, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", unknown, unknown, undefined>>;
|
|
56
|
-
export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|
57
|
-
export type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
|
58
|
-
export type ButtonProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
|
|
59
|
-
variant?: ButtonVariant;
|
|
60
|
-
size?: ButtonSize;
|
|
61
|
-
};
|
|
62
|
-
declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
|
|
63
|
-
type Button = ReturnType<typeof Button>;
|
|
64
|
-
export default Button;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn } from "../../../utils.js";
|
|
3
|
-
import type { ComponentProps } from "svelte";
|
|
4
|
-
import { Separator } from "../separator/index.js";
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
ref = $bindable(null),
|
|
8
|
-
class: className,
|
|
9
|
-
orientation = "vertical",
|
|
10
|
-
...restProps
|
|
11
|
-
}: ComponentProps<typeof Separator> = $props();
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<Separator
|
|
15
|
-
bind:ref
|
|
16
|
-
data-slot="button-group-separator"
|
|
17
|
-
{orientation}
|
|
18
|
-
class={cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className)}
|
|
19
|
-
{...restProps}
|
|
20
|
-
/>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare const ButtonGroupSeparator: import("svelte").Component<Omit<{
|
|
2
|
-
orientation?: import("bits-ui").Orientation;
|
|
3
|
-
decorative?: boolean;
|
|
4
|
-
}, "child" | "children"> & {
|
|
5
|
-
child?: import("svelte").Snippet<[{
|
|
6
|
-
props: Record<string, unknown>;
|
|
7
|
-
}]> | undefined;
|
|
8
|
-
children?: import("svelte").Snippet<[]> | undefined;
|
|
9
|
-
style?: import("bits-ui").StyleProperties | string | null | undefined;
|
|
10
|
-
ref?: HTMLElement | null | undefined;
|
|
11
|
-
} & import("bits-ui").Without<import("bits-ui").BitsPrimitiveDivAttributes, import("bits-ui").SeparatorRootPropsWithoutHTML>, {}, "ref">;
|
|
12
|
-
type ButtonGroupSeparator = ReturnType<typeof ButtonGroupSeparator>;
|
|
13
|
-
export default ButtonGroupSeparator;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
ref = $bindable(null),
|
|
8
|
-
class: className,
|
|
9
|
-
child,
|
|
10
|
-
...restProps
|
|
11
|
-
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
12
|
-
child?: Snippet<[{ props: Record<string, unknown> }]>;
|
|
13
|
-
} = $props();
|
|
14
|
-
|
|
15
|
-
const mergedProps = $derived({
|
|
16
|
-
...restProps,
|
|
17
|
-
class: cn(
|
|
18
|
-
"bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
19
|
-
className
|
|
20
|
-
),
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
{#if child}
|
|
25
|
-
{@render child({ props: mergedProps })}
|
|
26
|
-
{:else}
|
|
27
|
-
<div bind:this={ref} {...mergedProps}>
|
|
28
|
-
{@render mergedProps.children?.()}
|
|
29
|
-
</div>
|
|
30
|
-
{/if}
|