@mirasen/chessboard 1.3.0 → 1.3.2

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,34 @@
1
1
  # @mirasen/chessboard
2
2
 
3
+ ## 1.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 41c2799: dependabot: directory '/', update @sveltejs/kit
8
+ - 41c2799: dependabot: directory '/', update es-toolkit
9
+ - 41c2799: dependabot: directory '/', update eslint-plugin-svelte
10
+ - 41c2799: dependabot: directory '/', update svelte
11
+ - 41c2799: dependabot: directory '/', update typescript-eslint
12
+ - 00b1e4f: dependabot: directory '/', update vite
13
+ - 857a1b5: dependabot: directory '/examples/sveltekit', update prettier-plugin-svelte from 3.5.2 to 4.0.1
14
+ - 1226db9: Fix mobile lifted-piece drag clipping near board edges.
15
+
16
+ Scaled mobile drag visuals can intentionally extend outside the board viewport so the dragged piece stays visible under the user's finger. The root SVG and SvelteKit example container now allow those board-local overlay visuals to remain visible without changing layout geometry, pointer mapping, or drag behavior.
17
+
18
+ ## 1.3.1
19
+
20
+ ### Patch Changes
21
+
22
+ - be0386f: Calibrate the default mobile drag piece scale and add board-level desktop/mobile config presets.
23
+
24
+ The mobile main-renderer drag preset now uses a larger lifted piece scale while preserving the existing bottom anchor and offset.
25
+
26
+ 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.
27
+
28
+ - be0386f: Calibrate the default mobile drag piece scale.
29
+
30
+ 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.
31
+
3
32
  ## 1.3.0
4
33
 
5
34
  ### Minor Changes
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  # @mirasen/chessboard
8
8
 
9
- A framework-agnostic TypeScript chessboard platform with real chess interaction built in and an extension-driven architecture.
9
+ A production-grade, framework-agnostic TypeScript chessboard platform with real chess interaction built in and an extension-driven architecture.
10
10
 
11
11
  ## Try it live (including annotations)
12
12
 
@@ -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 touch interaction
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.
@@ -43,7 +43,7 @@ export const DefaultMainRendererDesktopConfig = {
43
43
  export const DefaultMainRendererMobileConfig = {
44
44
  ...cloneDeep(DefaultMainRendererConfigPart),
45
45
  drag: {
46
- pieceScale: 1.5,
46
+ pieceScale: 2,
47
47
  pieceAnchor: 'bottom',
48
48
  pieceAnchorOffsetY: 0.14
49
49
  },
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
+ };
@@ -7,6 +7,9 @@ export function createSvgRoots(options) {
7
7
  svgRoot.style.setProperty('touch-action', 'pinch-zoom');
8
8
  svgRoot.style.setProperty('-webkit-touch-callout', 'none');
9
9
  svgRoot.style.setProperty('-webkit-tap-highlight-color', 'transparent');
10
+ // Don't clip board-local overlay visuals (e.g. mobile lifted drag piece
11
+ // scaled above the top rank) at the SVG viewport.
12
+ svgRoot.style.setProperty('overflow', 'visible');
10
13
  // Create children in the correct order
11
14
  const board = createSvgElement(svgRoot, 'g', { 'data-chessboard-id': 'board-root' });
12
15
  const coordinates = createSvgElement(svgRoot, 'g', {
@@ -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirasen/chessboard",
3
- "description": "Framework-agnostic TypeScript chessboard platform with real chess interaction built in.",
4
- "version": "1.3.0",
3
+ "description": "Production-grade framework-agnostic TypeScript chessboard platform with real chess interaction built in.",
4
+ "version": "1.3.2",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Mirasen"
@@ -97,7 +97,7 @@
97
97
  "rimraf": "^6.0.1",
98
98
  "serve": "^14.2.6",
99
99
  "typescript": "^6.0.3",
100
- "typescript-eslint": "^8.57.0",
100
+ "typescript-eslint": "^8.60.0",
101
101
  "vitest": "^4.0.18"
102
102
  },
103
103
  "engines": {
@@ -105,7 +105,7 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "@ktarmyshov/assert": "^0.1.9",
108
- "es-toolkit": "^1.45.1",
108
+ "es-toolkit": "^1.47.0",
109
109
  "type-fest": "^5.5.0"
110
110
  },
111
111
  "peerDependencies": {