@mirasen/chessboard 1.3.0 → 1.3.1
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mirasen/chessboard
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- be0386f: Calibrate the default mobile drag piece scale and add board-level desktop/mobile config presets.
|
|
8
|
+
|
|
9
|
+
The mobile main-renderer drag preset now uses a larger lifted piece scale while preserving the existing bottom anchor and offset.
|
|
10
|
+
|
|
11
|
+
The root package now also exports `DefaultChessboardDesktopConfig` and `DefaultChessboardMobileConfig`, which combine the matching interaction defaults with the matching main-renderer defaults for easier desktop/mobile preset usage.
|
|
12
|
+
|
|
13
|
+
- be0386f: Calibrate the default mobile drag piece scale.
|
|
14
|
+
|
|
15
|
+
The mobile main-renderer drag preset now uses a larger lifted piece scale, making touch dragging feel closer to common mobile chessboard behavior while keeping the existing bottom anchor and offset.
|
|
16
|
+
|
|
3
17
|
## 1.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ Rules and legality still belong to your game layer. Use the built-in `chess.js`
|
|
|
74
74
|
- Real built-in chess interaction
|
|
75
75
|
- Built-in circles and arrows with live add/remove previews
|
|
76
76
|
- **Easy game/rules integration** — connect your own game model, or use the built-in `chess.js` adapter
|
|
77
|
-
- Works on desktop and mobile out of the box, with pointer-based mouse and
|
|
77
|
+
- Works on desktop and mobile out of the box, with pointer-based mouse/touch interaction and tunable drag behavior
|
|
78
78
|
- State-diff animation beyond simple move events
|
|
79
79
|
- Extension-driven architecture
|
|
80
80
|
- First-party baseline extensions
|
|
@@ -266,6 +266,68 @@ Movability controls how the board accepts user-initiated moves.
|
|
|
266
266
|
- `free` — user moves are accepted without legal destination filtering
|
|
267
267
|
- `strict` — user moves are accepted only when the target is allowed by the destinations provided by your app/rules layer
|
|
268
268
|
|
|
269
|
+
### Desktop and mobile drag tuning
|
|
270
|
+
|
|
271
|
+
The board exposes interaction-level and renderer-level drag configuration so you can tune mouse-first and touch-first surfaces without replacing the built-in interaction model.
|
|
272
|
+
|
|
273
|
+
Interaction config controls when lifted-piece drag becomes active:
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
const board = createBoard({
|
|
277
|
+
element
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
board.setInteractionConfig({
|
|
281
|
+
drag: {
|
|
282
|
+
liftedActivation: {
|
|
283
|
+
thresholdPx: 5
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Use `thresholdPx: 0` for immediate desktop-style drag activation, or a small threshold for mobile/touch UIs where the piece should not jump on the first tiny pointer movement.
|
|
290
|
+
|
|
291
|
+
The first-party renderer controls how the lifted piece looks while dragging:
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
board.extensions.renderer.setConfig({
|
|
295
|
+
drag: {
|
|
296
|
+
pieceScale: 2,
|
|
297
|
+
pieceAnchor: 'bottom',
|
|
298
|
+
pieceAnchorOffsetY: 0.14
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
For convenience, the root package ships board-level presets that combine the interaction feel and renderer visuals for a desktop- or mobile-style board. Apply both parts together:
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
import { DefaultChessboardMobileConfig } from '@mirasen/chessboard';
|
|
307
|
+
|
|
308
|
+
board.setInteractionConfig(DefaultChessboardMobileConfig.interaction);
|
|
309
|
+
|
|
310
|
+
board.extensions.renderer.setConfig({
|
|
311
|
+
drag: DefaultChessboardMobileConfig.renderer.drag
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
`DefaultChessboardDesktopConfig` is the matching desktop preset. If you only want the renderer half, the lower-level `DefaultMainRendererDesktopConfig` and `DefaultMainRendererMobileConfig` building blocks are still exported from `@mirasen/chessboard/extensions`.
|
|
316
|
+
|
|
317
|
+
### Animation tuning
|
|
318
|
+
|
|
319
|
+
The first-party renderer exposes animation duration config:
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
board.extensions.renderer.setConfig({
|
|
323
|
+
animation: {
|
|
324
|
+
durationMs: 0
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Set `animation.durationMs` to `0` when you want position updates to render instantly without creating movement animations.
|
|
330
|
+
|
|
269
331
|
### Advanced: explicit extension lists
|
|
270
332
|
|
|
271
333
|
Most users can rely on the default first-party extension baseline. Use an explicit extension list only when you want to control which built-in or custom extensions are installed.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import type { MainRendererConfigPublic } from './extensions/first-party/main-renderer/types/public.js';
|
|
2
|
+
import { DefaultInteractionDesktopConfig, DefaultInteractionMobileConfig } from './state/interaction/config.js';
|
|
3
|
+
import type { InteractionConfig } from './state/interaction/types/config.js';
|
|
1
4
|
export type { ColorInput, MoveRequestInput, PiecePositionRecordString, PositionInput } from './state/board/types/input.js';
|
|
2
5
|
export type { MoveOutput } from './state/board/types/output.js';
|
|
3
6
|
export type { MovabilityInput, MoveDestinationInput } from './state/interaction/types/input.js';
|
|
4
7
|
export { createBoard } from './wrapper/factory.js';
|
|
5
8
|
export type { Chessboard, ChessboardExtensionInput, ChessboardInitOptions } from './wrapper/types.js';
|
|
9
|
+
export interface ChessboardConfig {
|
|
10
|
+
readonly interaction: InteractionConfig;
|
|
11
|
+
readonly renderer: MainRendererConfigPublic;
|
|
12
|
+
}
|
|
13
|
+
export { DefaultInteractionDesktopConfig, DefaultInteractionMobileConfig };
|
|
14
|
+
export declare const DefaultChessboardDesktopConfig: ChessboardConfig;
|
|
15
|
+
export declare const DefaultChessboardMobileConfig: ChessboardConfig;
|
package/dist/index.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { DefaultMainRendererDesktopConfig, DefaultMainRendererMobileConfig } from './extensions/index.js';
|
|
2
|
+
import { DefaultInteractionDesktopConfig, DefaultInteractionMobileConfig } from './state/interaction/config.js';
|
|
1
3
|
export { createBoard } from './wrapper/factory.js';
|
|
4
|
+
export { DefaultInteractionDesktopConfig, DefaultInteractionMobileConfig };
|
|
5
|
+
export const DefaultChessboardDesktopConfig = {
|
|
6
|
+
interaction: DefaultInteractionDesktopConfig,
|
|
7
|
+
renderer: DefaultMainRendererDesktopConfig
|
|
8
|
+
};
|
|
9
|
+
export const DefaultChessboardMobileConfig = {
|
|
10
|
+
interaction: DefaultInteractionMobileConfig,
|
|
11
|
+
renderer: DefaultMainRendererMobileConfig
|
|
12
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface InteractionConfigDragLiftedActivation {
|
|
2
|
-
thresholdPx: number;
|
|
2
|
+
readonly thresholdPx: number;
|
|
3
3
|
}
|
|
4
4
|
export interface InteractionConfigDrag {
|
|
5
|
-
liftedActivation: InteractionConfigDragLiftedActivation;
|
|
5
|
+
readonly liftedActivation: InteractionConfigDragLiftedActivation;
|
|
6
6
|
}
|
|
7
7
|
export interface InteractionConfig {
|
|
8
|
-
drag: InteractionConfigDrag;
|
|
8
|
+
readonly drag: InteractionConfigDrag;
|
|
9
9
|
}
|
package/package.json
CHANGED