Skip to content

accept @echecs/position Position in the position prop #44

@mormubis

Description

@mormubis

the `position` prop currently accepts `string | Map<Square, Piece>` where `Piece` uses single-char types (`'w' | 'b'`, `'p' | 'n' | 'b'...`). `@echecs/position` uses full words (`'white' | 'black'`, `'pawn' | 'knight' | 'bishop'...`).

consumers with a `Position` object have to either stringify to FEN and pass a string, or manually map every piece to the short form. both work, but neither is zero-friction.

proposal

add `Position` (from `@echecs/position`) as a third accepted variant of the `position` prop:

```typescript
position?: string | Map<Square, Piece> | Position;
```

internally, detect the `Position` class and normalize to `Map<Square, Piece>` with the existing short-form types. the conversion is trivial — first char of color, first char of type (with `'knight' → 'n'` as the exception).

this adds `@echecs/position` as a peer dependency (or optional peer). the existing FEN string and Map paths stay unchanged — no breaking change for current consumers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions