@mirasen/chessboard 0.1.0 → 1.0.0-rc.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/CHANGELOG.md +16 -0
- package/README.md +224 -47
- package/dist/animation/planner.d.ts +11 -6
- package/dist/animation/planner.js +167 -48
- package/dist/animation/render/fade.d.ts +5 -5
- package/dist/animation/render/fade.js +4 -4
- package/dist/animation/render/move.d.ts +6 -6
- package/dist/animation/render/move.js +6 -6
- package/dist/animation/render/plan.d.ts +6 -6
- package/dist/animation/render/plan.js +3 -3
- package/dist/animation/render/static.d.ts +5 -5
- package/dist/animation/render/static.js +4 -4
- package/dist/animation/render/types.d.ts +1 -1
- package/dist/animation/types.d.ts +15 -16
- package/dist/animation/types.js +1 -6
- package/dist/extensions/animation/factory.d.ts +1 -1
- package/dist/extensions/animation/factory.js +1 -1
- package/dist/extensions/animation/types.d.ts +1 -1
- package/dist/extensions/factory/main.d.ts +1 -1
- package/dist/extensions/factory/main.js +27 -6
- package/dist/extensions/factory/runtime.d.ts +6 -5
- package/dist/extensions/factory/runtime.js +48 -4
- package/dist/extensions/first-party/active-target/factory.d.ts +1 -1
- package/dist/extensions/first-party/active-target/factory.js +9 -9
- package/dist/extensions/first-party/active-target/types.d.ts +2 -2
- package/dist/extensions/first-party/auto-promote/factory.d.ts +2 -0
- package/dist/extensions/first-party/auto-promote/factory.js +51 -0
- package/dist/extensions/first-party/auto-promote/types.d.ts +14 -0
- package/dist/extensions/first-party/auto-promote/types.js +2 -0
- package/dist/extensions/first-party/board-events/factory.d.ts +1 -1
- package/dist/extensions/first-party/board-events/factory.js +3 -16
- package/dist/extensions/first-party/board-events/types.d.ts +6 -7
- package/dist/extensions/first-party/common/helpers.d.ts +2 -2
- package/dist/extensions/first-party/common/helpers.js +1 -1
- package/dist/extensions/first-party/common/types.d.ts +1 -1
- package/dist/extensions/first-party/last-move/factory.d.ts +1 -1
- package/dist/extensions/first-party/last-move/factory.js +10 -10
- package/dist/extensions/first-party/last-move/types.d.ts +2 -2
- package/dist/extensions/first-party/legal-moves/factory.d.ts +1 -1
- package/dist/extensions/first-party/legal-moves/factory.js +7 -7
- package/dist/extensions/first-party/legal-moves/types.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/animation/factory.d.ts +3 -3
- package/dist/extensions/first-party/main-renderer/animation/factory.js +3 -3
- package/dist/extensions/first-party/main-renderer/animation/render.d.ts +3 -3
- package/dist/extensions/first-party/main-renderer/animation/render.js +2 -3
- package/dist/extensions/first-party/main-renderer/animation/types.d.ts +7 -7
- package/dist/extensions/first-party/main-renderer/animation/update.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/animation/update.js +12 -26
- package/dist/extensions/first-party/main-renderer/board/factory.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/board/factory.js +2 -2
- package/dist/extensions/first-party/main-renderer/board/render.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/board/render.js +6 -6
- package/dist/extensions/first-party/main-renderer/board/types.d.ts +3 -3
- package/dist/extensions/first-party/main-renderer/board/update.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/board/update.js +8 -6
- package/dist/extensions/first-party/main-renderer/coordinates/factory.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/coordinates/factory.js +1 -1
- package/dist/extensions/first-party/main-renderer/coordinates/render.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/coordinates/render.js +7 -7
- package/dist/extensions/first-party/main-renderer/coordinates/types.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/drag/factory.d.ts +3 -3
- package/dist/extensions/first-party/main-renderer/drag/factory.js +2 -2
- package/dist/extensions/first-party/main-renderer/drag/render.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/drag/render.js +2 -2
- package/dist/extensions/first-party/main-renderer/drag/types.d.ts +4 -4
- package/dist/extensions/first-party/main-renderer/drag/update.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/drag/update.js +1 -1
- package/dist/extensions/first-party/main-renderer/factory.d.ts +1 -1
- package/dist/extensions/first-party/main-renderer/factory.js +9 -9
- package/dist/extensions/first-party/main-renderer/normalize.d.ts +2 -3
- package/dist/extensions/first-party/main-renderer/normalize.js +4 -4
- package/dist/extensions/first-party/main-renderer/pieces/factory.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/pieces/factory.js +2 -2
- package/dist/extensions/first-party/main-renderer/pieces/render.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/pieces/render.js +9 -9
- package/dist/extensions/first-party/main-renderer/pieces/suppress.d.ts +4 -4
- package/dist/extensions/first-party/main-renderer/pieces/suppress.js +7 -2
- package/dist/extensions/first-party/main-renderer/pieces/types.d.ts +5 -5
- package/dist/extensions/first-party/main-renderer/pieces/update.d.ts +4 -4
- package/dist/extensions/first-party/main-renderer/pieces/update.js +5 -5
- package/dist/extensions/first-party/main-renderer/types/extension.d.ts +3 -3
- package/dist/extensions/first-party/main-renderer/types/extension.js +1 -1
- package/dist/extensions/first-party/main-renderer/types/input.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/types/instance.d.ts +8 -8
- package/dist/extensions/first-party/main-renderer/types/internal.d.ts +2 -2
- package/dist/extensions/first-party/main-renderer/types/template.d.ts +1 -1
- package/dist/extensions/first-party/promotion/factory.d.ts +3 -0
- package/dist/extensions/first-party/promotion/factory.js +219 -0
- package/dist/extensions/first-party/promotion/normalize.d.ts +3 -0
- package/dist/extensions/first-party/promotion/normalize.js +37 -0
- package/dist/extensions/first-party/promotion/types/input.d.ts +10 -0
- package/dist/extensions/first-party/promotion/types/internal.d.ts +12 -0
- package/dist/extensions/first-party/promotion/types/internal.js +22 -0
- package/dist/extensions/first-party/promotion/types/main.d.ts +24 -0
- package/dist/extensions/first-party/promotion/types/main.js +2 -0
- package/dist/extensions/first-party/selected-square/factory.d.ts +1 -1
- package/dist/extensions/first-party/selected-square/factory.js +7 -7
- package/dist/extensions/first-party/selected-square/types.d.ts +2 -2
- package/dist/extensions/index.d.ts +8 -8
- package/dist/extensions/index.js +6 -6
- package/dist/extensions/invalidation/factory.d.ts +1 -1
- package/dist/extensions/types/basic/events.d.ts +10 -33
- package/dist/extensions/types/basic/events.js +9 -5
- package/dist/extensions/types/basic/interaction.d.ts +21 -0
- package/dist/extensions/types/basic/render.d.ts +2 -2
- package/dist/extensions/types/basic/transient-visuals.d.ts +3 -2
- package/dist/extensions/types/basic/update.d.ts +3 -3
- package/dist/extensions/types/context/animation.d.ts +3 -3
- package/dist/extensions/types/context/events.d.ts +5 -0
- package/dist/extensions/types/context/events.js +1 -0
- package/dist/extensions/types/context/render.d.ts +2 -2
- package/dist/extensions/types/context/transient-visuals.d.ts +2 -2
- package/dist/extensions/types/context/ui-move.d.ts +3 -15
- package/dist/extensions/types/context/update.d.ts +4 -4
- package/dist/extensions/types/context/update.js +1 -1
- package/dist/extensions/types/extension.d.ts +16 -14
- package/dist/extensions/types/main.d.ts +16 -11
- package/dist/extensions/types/surface/commands.d.ts +14 -5
- package/dist/extensions/types/surface/events.d.ts +2 -3
- package/dist/extensions/types/surface/main.d.ts +4 -4
- package/dist/extensions/types/wrapper.d.ts +23 -22
- package/dist/extensions/types/wrapper.js +34 -6
- package/dist/extensions/update.d.ts +3 -3
- package/dist/extensions/update.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/layout/factory.d.ts +1 -1
- package/dist/layout/factory.js +4 -4
- package/dist/layout/geometry/factory.d.ts +3 -12
- package/dist/layout/geometry/factory.js +17 -18
- package/dist/layout/geometry/helpers.d.ts +5 -0
- package/dist/layout/geometry/helpers.js +33 -0
- package/dist/layout/geometry/types.d.ts +14 -13
- package/dist/layout/helpers.d.ts +3 -4
- package/dist/layout/helpers.js +5 -5
- package/dist/layout/mutation.d.ts +1 -1
- package/dist/layout/reducers.d.ts +1 -1
- package/dist/layout/reducers.js +10 -9
- package/dist/layout/types.d.ts +7 -7
- package/dist/mutation/pipeline.d.ts +1 -1
- package/dist/mutation/pipeline.js +1 -1
- package/dist/mutation/session.d.ts +1 -1
- package/dist/render/factory.d.ts +1 -1
- package/dist/render/factory.js +7 -7
- package/dist/render/mount.d.ts +1 -1
- package/dist/render/mount.js +4 -4
- package/dist/render/rendering/animation.d.ts +1 -1
- package/dist/render/rendering/animation.js +1 -1
- package/dist/render/rendering/helpers.d.ts +1 -1
- package/dist/render/rendering/state.d.ts +2 -2
- package/dist/render/rendering/state.js +9 -9
- package/dist/render/rendering/visuals.d.ts +2 -2
- package/dist/render/rendering/visuals.js +1 -1
- package/dist/render/scheduler/scheduler.d.ts +1 -1
- package/dist/render/svg/factory.d.ts +2 -2
- package/dist/render/svg/factory.js +1 -1
- package/dist/render/svg/helpers.d.ts +1 -1
- package/dist/render/svg/helpers.js +1 -1
- package/dist/render/types.d.ts +5 -5
- package/dist/runtime/factory/events.d.ts +3 -0
- package/dist/runtime/factory/events.js +18 -0
- package/dist/runtime/factory/helpers.d.ts +2 -2
- package/dist/runtime/factory/helpers.js +14 -14
- package/dist/runtime/factory/input.d.ts +2 -2
- package/dist/runtime/factory/input.js +20 -13
- package/dist/runtime/factory/main.d.ts +1 -1
- package/dist/runtime/factory/main.js +56 -16
- package/dist/runtime/input/adapter/event.d.ts +3 -0
- package/dist/runtime/input/adapter/event.js +19 -0
- package/dist/runtime/input/adapter/factory.d.ts +1 -1
- package/dist/runtime/input/adapter/factory.js +19 -38
- package/dist/runtime/input/adapter/helpers.d.ts +3 -5
- package/dist/runtime/input/adapter/helpers.js +60 -12
- package/dist/runtime/input/adapter/pointer.d.ts +7 -11
- package/dist/runtime/input/adapter/pointer.js +37 -70
- package/dist/runtime/input/adapter/types.d.ts +7 -4
- package/dist/runtime/input/adapter/types.js +6 -1
- package/dist/runtime/input/controller/factory.d.ts +1 -1
- package/dist/runtime/input/controller/factory.js +13 -12
- package/dist/runtime/input/controller/helpers.d.ts +2 -2
- package/dist/runtime/input/controller/pointer.d.ts +6 -7
- package/dist/runtime/input/controller/pointer.js +39 -38
- package/dist/runtime/input/controller/transient-visuals.d.ts +3 -3
- package/dist/runtime/input/controller/transient-visuals.js +12 -5
- package/dist/runtime/input/controller/types.d.ts +8 -7
- package/dist/runtime/layout.d.ts +1 -1
- package/dist/runtime/layout.js +2 -2
- package/dist/runtime/lifecycle.d.ts +2 -2
- package/dist/runtime/lifecycle.js +8 -8
- package/dist/runtime/mutation/extension-update.d.ts +1 -1
- package/dist/runtime/mutation/factory.d.ts +1 -1
- package/dist/runtime/mutation/factory.js +6 -6
- package/dist/runtime/mutation/interaction.d.ts +1 -1
- package/dist/runtime/mutation/interaction.js +3 -7
- package/dist/runtime/mutation/invalidation.d.ts +1 -0
- package/dist/runtime/mutation/invalidation.js +1 -1
- package/dist/runtime/mutation/last-move.d.ts +1 -1
- package/dist/runtime/mutation/layout.d.ts +1 -1
- package/dist/runtime/mutation/pipeline.d.ts +6 -6
- package/dist/runtime/mutation/request-render.d.ts +1 -1
- package/dist/runtime/mutation/request-render.js +1 -1
- package/dist/runtime/mutation/run.d.ts +1 -1
- package/dist/runtime/mutation/types.d.ts +10 -8
- package/dist/runtime/types/main.d.ts +8 -6
- package/dist/state/board/check.d.ts +3 -3
- package/dist/state/board/check.js +1 -1
- package/dist/state/board/coords.d.ts +1 -1
- package/dist/state/board/denormalize.d.ts +3 -3
- package/dist/state/board/denormalize.js +4 -4
- package/dist/state/board/factory.d.ts +2 -2
- package/dist/state/board/factory.js +4 -4
- package/dist/state/board/mutation.d.ts +2 -2
- package/dist/state/board/normalize.d.ts +2 -2
- package/dist/state/board/normalize.js +2 -2
- package/dist/state/board/piece.d.ts +1 -1
- package/dist/state/board/position.d.ts +2 -2
- package/dist/state/board/position.js +2 -2
- package/dist/state/board/reducers.d.ts +2 -2
- package/dist/state/board/reducers.js +3 -3
- package/dist/state/board/types/input.d.ts +1 -1
- package/dist/state/board/types/internal.d.ts +1 -1
- package/dist/state/board/types/main.d.ts +3 -3
- package/dist/state/board/types/output.d.ts +2 -2
- package/dist/state/change/{factory.d.ts → factory/main.d.ts} +1 -1
- package/dist/state/change/{factory.js → factory/main.js} +8 -5
- package/dist/state/change/factory/ui-move.d.ts +4 -0
- package/dist/{runtime → state/change}/factory/ui-move.js +9 -9
- package/dist/state/change/helpers.d.ts +6 -4
- package/dist/state/change/helpers.js +12 -2
- package/dist/state/change/mutation.d.ts +2 -2
- package/dist/state/change/reducers.d.ts +4 -4
- package/dist/state/change/reducers.js +4 -4
- package/dist/state/change/types/main.d.ts +18 -0
- package/dist/state/change/types/main.js +1 -0
- package/dist/state/change/types/ui-move.d.ts +25 -0
- package/dist/state/change/types/ui-move.js +1 -0
- package/dist/state/factory.d.ts +1 -1
- package/dist/state/factory.js +4 -4
- package/dist/state/interaction/factory.d.ts +1 -1
- package/dist/state/interaction/factory.js +7 -5
- package/dist/state/interaction/helpers.d.ts +4 -2
- package/dist/state/interaction/helpers.js +5 -2
- package/dist/state/interaction/movability.d.ts +3 -3
- package/dist/state/interaction/movability.js +2 -2
- package/dist/state/interaction/mutation.d.ts +1 -1
- package/dist/state/interaction/normalize.d.ts +2 -2
- package/dist/state/interaction/normalize.js +2 -2
- package/dist/state/interaction/reducers.d.ts +3 -3
- package/dist/state/interaction/reducers.js +3 -3
- package/dist/state/interaction/types/input.d.ts +1 -1
- package/dist/state/interaction/types/internal.d.ts +10 -2
- package/dist/state/interaction/types/main.d.ts +4 -4
- package/dist/state/types.d.ts +6 -6
- package/dist/state/view/factory.d.ts +1 -1
- package/dist/state/view/factory.js +2 -2
- package/dist/state/view/mutation.d.ts +1 -1
- package/dist/state/view/reducers.d.ts +2 -2
- package/dist/state/view/types/internal.d.ts +1 -1
- package/dist/state/view/types/main.d.ts +4 -4
- package/dist/wrapper/factory.d.ts +2 -2
- package/dist/wrapper/factory.js +3 -27
- package/dist/wrapper/types.d.ts +4 -4
- package/package.json +9 -5
- package/dist/runtime/factory/ui-move.d.ts +0 -4
- package/dist/runtime/types/ui-move.d.ts +0 -9
- package/dist/state/change/types.d.ts +0 -17
- /package/dist/{runtime/types/ui-move.js → extensions/first-party/promotion/types/input.js} +0 -0
- /package/dist/{state/change/types.js → extensions/types/basic/interaction.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnimationTrackMove } from '../types';
|
|
4
|
-
import type { PreparedMoveNode } from './types';
|
|
5
|
-
export declare function prepareMoveTrack(track: AnimationTrackMove, geometry:
|
|
6
|
-
export declare function renderMoveTrack(node: PreparedMoveNode, geometry:
|
|
1
|
+
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal.js';
|
|
2
|
+
import type { SceneRenderGeometry } from '../../layout/geometry/types.js';
|
|
3
|
+
import type { AnimationTrackMove } from '../types.js';
|
|
4
|
+
import type { PreparedMoveNode } from './types.js';
|
|
5
|
+
export declare function prepareMoveTrack(track: AnimationTrackMove, geometry: SceneRenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedMoveNode;
|
|
6
|
+
export declare function renderMoveTrack(node: PreparedMoveNode, geometry: SceneRenderGeometry, progress: number): void;
|
|
7
7
|
export declare function cleanMoveTrack(node: PreparedMoveNode): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSvgElement, updateElementAttributes } from '../../render/svg/helpers';
|
|
1
|
+
import { createSvgElement, updateElementAttributes } from '../../render/svg/helpers.js';
|
|
2
2
|
export function prepareMoveTrack(track, geometry, pieceUrls, layer) {
|
|
3
|
-
const r = geometry.
|
|
3
|
+
const r = geometry.getSquareRect(track.fromSq);
|
|
4
4
|
const url = pieceUrls[track.pieceCode];
|
|
5
5
|
const root = createSvgElement(layer, 'image', {
|
|
6
6
|
'data-chessboard-id': `animation-move-${track.id}`,
|
|
@@ -8,14 +8,14 @@ export function prepareMoveTrack(track, geometry, pieceUrls, layer) {
|
|
|
8
8
|
href: url,
|
|
9
9
|
x: r.x.toString(),
|
|
10
10
|
y: r.y.toString(),
|
|
11
|
-
width: r.
|
|
12
|
-
height: r.
|
|
11
|
+
width: r.width.toString(),
|
|
12
|
+
height: r.height.toString()
|
|
13
13
|
});
|
|
14
14
|
return { ...track, root };
|
|
15
15
|
}
|
|
16
16
|
export function renderMoveTrack(node, geometry, progress) {
|
|
17
|
-
const from = geometry.
|
|
18
|
-
const to = geometry.
|
|
17
|
+
const from = geometry.getSquareRect(node.fromSq);
|
|
18
|
+
const to = geometry.getSquareRect(node.toSq);
|
|
19
19
|
const x = from.x + (to.x - from.x) * progress;
|
|
20
20
|
const y = from.y + (to.y - from.y) * progress;
|
|
21
21
|
updateElementAttributes(node.root, {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnimationPlan } from '../types';
|
|
4
|
-
import type { PreparedNodeMap } from './types';
|
|
1
|
+
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal.js';
|
|
2
|
+
import type { SceneRenderGeometry } from '../../layout/geometry/types.js';
|
|
3
|
+
import type { AnimationPlan } from '../types.js';
|
|
4
|
+
import type { PreparedNodeMap } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Prepare all tracks in the plan — creates SVG nodes in `layer` for each track.
|
|
7
7
|
* Returns a map keyed by track id for use in render/clean passes.
|
|
8
8
|
*/
|
|
9
|
-
export declare function prepareAnimationPlan(plan: AnimationPlan, geometry:
|
|
10
|
-
export declare function renderAnimationPlan(nodes: PreparedNodeMap, geometry:
|
|
9
|
+
export declare function prepareAnimationPlan(plan: AnimationPlan, geometry: SceneRenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedNodeMap;
|
|
10
|
+
export declare function renderAnimationPlan(nodes: PreparedNodeMap, geometry: SceneRenderGeometry, progress: number): void;
|
|
11
11
|
/**
|
|
12
12
|
* Clean up all track nodes — removes SVG elements from the DOM.
|
|
13
13
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { cleanFadeTrack, prepareFadeTrack, renderFadeTrack } from './fade';
|
|
2
|
-
import { cleanMoveTrack, prepareMoveTrack, renderMoveTrack } from './move';
|
|
3
|
-
import { cleanStaticTrack, prepareStaticTrack, renderStaticTrack } from './static';
|
|
1
|
+
import { cleanFadeTrack, prepareFadeTrack, renderFadeTrack } from './fade.js';
|
|
2
|
+
import { cleanMoveTrack, prepareMoveTrack, renderMoveTrack } from './move.js';
|
|
3
|
+
import { cleanStaticTrack, prepareStaticTrack, renderStaticTrack } from './static.js';
|
|
4
4
|
/**
|
|
5
5
|
* Prepare all tracks in the plan — creates SVG nodes in `layer` for each track.
|
|
6
6
|
* Returns a map keyed by track id for use in render/clean passes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnimationTrackStatic } from '../types';
|
|
4
|
-
import type { PreparedStaticNode } from './types';
|
|
5
|
-
export declare function prepareStaticTrack(track: AnimationTrackStatic, geometry:
|
|
1
|
+
import type { PieceUrls } from '../../extensions/first-party/main-renderer/types/internal.js';
|
|
2
|
+
import type { SceneRenderGeometry } from '../../layout/geometry/types.js';
|
|
3
|
+
import type { AnimationTrackStatic } from '../types.js';
|
|
4
|
+
import type { PreparedStaticNode } from './types.js';
|
|
5
|
+
export declare function prepareStaticTrack(track: AnimationTrackStatic, geometry: SceneRenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedStaticNode;
|
|
6
6
|
export declare function renderStaticTrack(_node: PreparedStaticNode): void;
|
|
7
7
|
export declare function cleanStaticTrack(node: PreparedStaticNode): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSvgElement } from '../../render/svg/helpers';
|
|
1
|
+
import { createSvgElement } from '../../render/svg/helpers.js';
|
|
2
2
|
export function prepareStaticTrack(track, geometry, pieceUrls, layer) {
|
|
3
|
-
const r = geometry.
|
|
3
|
+
const r = geometry.getSquareRect(track.sq);
|
|
4
4
|
const url = pieceUrls[track.pieceCode];
|
|
5
5
|
const root = createSvgElement(layer, 'image', {
|
|
6
6
|
'data-chessboard-id': `animation-static-${track.id}`,
|
|
@@ -8,8 +8,8 @@ export function prepareStaticTrack(track, geometry, pieceUrls, layer) {
|
|
|
8
8
|
href: url,
|
|
9
9
|
x: r.x.toString(),
|
|
10
10
|
y: r.y.toString(),
|
|
11
|
-
width: r.
|
|
12
|
-
height: r.
|
|
11
|
+
width: r.width.toString(),
|
|
12
|
+
height: r.height.toString()
|
|
13
13
|
});
|
|
14
14
|
return { ...track, root };
|
|
15
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnimationTrack, AnimationTrackFade, AnimationTrackMove, AnimationTrackStatic } from '../types';
|
|
1
|
+
import type { AnimationTrack, AnimationTrackFade, AnimationTrackMove, AnimationTrackStatic } from '../types.js';
|
|
2
2
|
/** Prepared node for a move track — holds the SVG image and its track. */
|
|
3
3
|
export interface PreparedMoveNode extends AnimationTrackMove {
|
|
4
4
|
root: SVGImageElement;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import type { NonEmptyPieceCode, Square } from '../state/board/types/internal';
|
|
2
|
+
import type { NonEmptyPieceCode, Square } from '../state/board/types/internal.js';
|
|
3
|
+
import { BoardStateSnapshot } from '../state/board/types/main.js';
|
|
4
|
+
import { ChangeStateSnapshot } from '../state/change/types/main.js';
|
|
5
|
+
import { InteractionStateSnapshot } from '../state/interaction/types/main.js';
|
|
3
6
|
export interface AnimationTrackMove {
|
|
4
7
|
id: number;
|
|
5
8
|
pieceCode: NonEmptyPieceCode;
|
|
@@ -20,27 +23,23 @@ export interface AnimationTrackStatic {
|
|
|
20
23
|
effect: 'static';
|
|
21
24
|
}
|
|
22
25
|
export type AnimationTrack = AnimationTrackMove | AnimationTrackFade | AnimationTrackStatic;
|
|
23
|
-
export interface AnimationPlan {
|
|
24
|
-
sessionId: number;
|
|
25
|
-
tracks: AnimationTrack[];
|
|
26
|
-
}
|
|
27
26
|
export interface AnimationSession {
|
|
28
27
|
id: number;
|
|
29
|
-
|
|
28
|
+
plan: AnimationPlan;
|
|
30
29
|
startTime: number;
|
|
31
30
|
duration: number;
|
|
32
31
|
}
|
|
33
32
|
export type AnimationSessionSnapshot = ReadonlyDeep<AnimationSession>;
|
|
34
|
-
export interface
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
export interface AnimationPlanningSnapshot {
|
|
34
|
+
readonly board: BoardStateSnapshot;
|
|
35
|
+
readonly change: ChangeStateSnapshot;
|
|
36
|
+
readonly interaction: InteractionStateSnapshot;
|
|
37
37
|
}
|
|
38
|
-
export interface
|
|
39
|
-
|
|
38
|
+
export interface AnimationPlanningInput {
|
|
39
|
+
previous: AnimationPlanningSnapshot;
|
|
40
|
+
current: AnimationPlanningSnapshot;
|
|
40
41
|
}
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export interface CalculateAnimationTracksOptions {
|
|
45
|
-
exclude?: AnimationTrackExclude[];
|
|
42
|
+
export interface AnimationPlan {
|
|
43
|
+
readonly tracks: readonly AnimationTrack[];
|
|
44
|
+
readonly suppressedSquares: ReadonlySet<Square>;
|
|
46
45
|
}
|
package/dist/animation/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionAnimationControllerInternalSurface, ExtensionAnimationSessionInternalSurface, ExtensionAnimationSessionSubmitOptions } from '../types/basic/animation';
|
|
1
|
+
import { ExtensionAnimationControllerInternalSurface, ExtensionAnimationSessionInternalSurface, ExtensionAnimationSessionSubmitOptions } from '../types/basic/animation.js';
|
|
2
2
|
export declare function createExtensionAnimationSession(id: number, options: ExtensionAnimationSessionSubmitOptions): ExtensionAnimationSessionInternalSurface;
|
|
3
3
|
export declare function createExtensionAnimationController(): ExtensionAnimationControllerInternalSurface;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtensionAnimationSessionInternalSurface, ExtensionAnimationSessionStatus } from '../types/basic/animation';
|
|
1
|
+
import { ExtensionAnimationSessionInternalSurface, ExtensionAnimationSessionStatus } from '../types/basic/animation.js';
|
|
2
2
|
export interface ExtensionAnimationSessionInternal {
|
|
3
3
|
readonly id: number;
|
|
4
4
|
readonly startTime: DOMHighResTimeStamp;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ExtensionSystem, ExtensionSystemInitOptions } from '../types/main';
|
|
1
|
+
import { ExtensionSystem, ExtensionSystemInitOptions } from '../types/main.js';
|
|
2
2
|
export declare function createExtensionSystem(options: ExtensionSystemInitOptions): ExtensionSystem;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import assert from '@ktarmyshov/assert';
|
|
2
|
+
import { createExtensionAnimationController } from '../animation/factory.js';
|
|
3
|
+
import { createExtensionInvalidationState } from '../invalidation/factory.js';
|
|
4
|
+
import { extensionSystemUpdateState, extensionSystemUpdateUIMoveRequest } from '../update.js';
|
|
5
|
+
import { createExtensionRuntimeSurface } from './runtime.js';
|
|
5
6
|
function createExtensionSystemInternal(getInternalState, options) {
|
|
6
7
|
const extensions = new Map();
|
|
7
8
|
const extensionsArray = options.extensions ?? [];
|
|
8
9
|
for (const extensionDef of extensionsArray) {
|
|
10
|
+
if (extensionDef.id === 'core') {
|
|
11
|
+
throw new Error('Extension id "core" is reserved and cannot be used by extensions');
|
|
12
|
+
}
|
|
9
13
|
if (extensions.has(extensionDef.id)) {
|
|
10
14
|
throw new Error(`Duplicate extension id found: ${extensionDef.id}`);
|
|
11
15
|
}
|
|
12
16
|
const instance = extensionDef.createInstance({
|
|
13
|
-
runtimeSurface: createExtensionRuntimeSurface(getInternalState, options.extensionRuntimeSurfaceCommands, extensionDef)
|
|
17
|
+
runtimeSurface: createExtensionRuntimeSurface(getInternalState, options.extensionRuntimeSurfaceCommands, options.extensionRuntimeSurfaceEvents, extensionDef)
|
|
14
18
|
});
|
|
15
19
|
const record = {
|
|
16
20
|
id: extensionDef.id,
|
|
@@ -72,6 +76,23 @@ export function createExtensionSystem(options) {
|
|
|
72
76
|
onUIMoveRequest(context) {
|
|
73
77
|
extensionSystemUpdateUIMoveRequest(internalState, context);
|
|
74
78
|
},
|
|
79
|
+
onEvent(context) {
|
|
80
|
+
const subscribers = internalState.eventSubscribers.get(context.rawEvent.type);
|
|
81
|
+
if (subscribers) {
|
|
82
|
+
for (const extensionId of subscribers) {
|
|
83
|
+
const extensionRec = internalState.extensions.get(extensionId);
|
|
84
|
+
if (extensionRec) {
|
|
85
|
+
extensionRec.instance.onEvent?.(context);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
completeDrag(session) {
|
|
91
|
+
const extensionRec = internalState.extensions.get(session.owner);
|
|
92
|
+
assert(extensionRec, `Extension record not found for completing drag session with owner ${session.owner}`);
|
|
93
|
+
assert(extensionRec.instance.completeDrag, `Extension instance does not have a completeDrag handler for completing drag session with owner ${session.owner}`);
|
|
94
|
+
extensionRec.instance.completeDrag(session);
|
|
95
|
+
},
|
|
75
96
|
onUnmount() {
|
|
76
97
|
internalState.transientVisualsSubscribers.clear();
|
|
77
98
|
internalState.eventSubscribers.clear();
|
|
@@ -84,7 +105,7 @@ export function createExtensionSystem(options) {
|
|
|
84
105
|
onDestroy() {
|
|
85
106
|
// We assume that the onUnmout was already called by runtime, but let's still validate
|
|
86
107
|
for (const extensionRec of internalState.extensions.values()) {
|
|
87
|
-
extensionRec.instance.destroy();
|
|
108
|
+
extensionRec.instance.destroy?.();
|
|
88
109
|
const onUnmountCalled = [
|
|
89
110
|
extensionRec.invalidation.dirtyLayers === 0,
|
|
90
111
|
extensionRec.animation.getAll().length === 0
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AnyExtensionDefinition } from '../types/extension';
|
|
2
|
-
import type { GetInternalState } from '../types/main';
|
|
3
|
-
import type { ExtensionRuntimeSurfaceCommands } from '../types/surface/commands';
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import type { AnyExtensionDefinition } from '../types/extension.js';
|
|
2
|
+
import type { GetInternalState } from '../types/main.js';
|
|
3
|
+
import type { ExtensionRuntimeSurfaceCommands } from '../types/surface/commands.js';
|
|
4
|
+
import { ExtensionRuntimeSurfaceEvents } from '../types/surface/events.js';
|
|
5
|
+
import type { ExtensionRuntimeSurface } from '../types/surface/main.js';
|
|
6
|
+
export declare function createExtensionRuntimeSurface(getInternalState: GetInternalState, commands: ExtensionRuntimeSurfaceCommands, events: ExtensionRuntimeSurfaceEvents, extensionDef: AnyExtensionDefinition): ExtensionRuntimeSurface;
|
|
@@ -33,11 +33,55 @@ function createExtensionRuntimeSurfaceAnimation(getInternalState, extensionDef)
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
// @ts-expect-error We will implement events later, for now we just return empty object for it to satisfy the interface
|
|
36
|
+
function createExtensionRuntimeSurfaceEvents(getInternalState, runtimeSurfaceEvents, extensionDef) {
|
|
38
37
|
return {
|
|
39
|
-
|
|
38
|
+
subscribeEvent(type) {
|
|
39
|
+
const internalState = getInternalState();
|
|
40
|
+
const extensionRec = internalState.extensions.get(extensionDef.id);
|
|
41
|
+
assert(extensionRec, 'Extension record not found for subscribing to events');
|
|
42
|
+
assert(extensionRec.instance.onEvent, 'Extension instance does not have an onEvent handler for subscribing to events');
|
|
43
|
+
let subscribers = internalState.eventSubscribers.get(type);
|
|
44
|
+
if (!subscribers) {
|
|
45
|
+
subscribers = new Set();
|
|
46
|
+
internalState.eventSubscribers.set(type, subscribers);
|
|
47
|
+
}
|
|
48
|
+
subscribers.add(extensionDef.id);
|
|
49
|
+
runtimeSurfaceEvents.subscribeEvent(type);
|
|
50
|
+
},
|
|
51
|
+
unsubscribeEvent(type) {
|
|
52
|
+
const internalState = getInternalState();
|
|
53
|
+
const subscribers = internalState.eventSubscribers.get(type);
|
|
54
|
+
if (subscribers) {
|
|
55
|
+
subscribers.delete(extensionDef.id);
|
|
56
|
+
if (subscribers.size === 0) {
|
|
57
|
+
internalState.eventSubscribers.delete(type);
|
|
58
|
+
runtimeSurfaceEvents.unsubscribeEvent(type);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function createExtensionRuntimeSurfaceCommands(getInternalState, runtimeSurfaceCommands, extensionDef) {
|
|
65
|
+
return {
|
|
66
|
+
...runtimeSurfaceCommands,
|
|
67
|
+
startDrag(session) {
|
|
68
|
+
const internalState = getInternalState();
|
|
69
|
+
const extensionRec = internalState.extensions.get(extensionDef.id);
|
|
70
|
+
assert(extensionRec, 'Extension record not found for starting drag session');
|
|
71
|
+
assert(extensionRec.instance.completeDrag, 'Extension instance does not have a completeDrag handler for starting drag session');
|
|
72
|
+
const extSession = {
|
|
73
|
+
owner: extensionDef.id,
|
|
74
|
+
...session
|
|
75
|
+
};
|
|
76
|
+
return runtimeSurfaceCommands.startDrag(extSession);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function createExtensionRuntimeSurface(getInternalState, commands, events, extensionDef) {
|
|
81
|
+
return {
|
|
82
|
+
commands: createExtensionRuntimeSurfaceCommands(getInternalState, commands, extensionDef),
|
|
40
83
|
animation: createExtensionRuntimeSurfaceAnimation(getInternalState, extensionDef),
|
|
41
|
-
transientVisuals: createExtensionRuntimeSurfaceTransientVisuals(getInternalState, extensionDef)
|
|
84
|
+
transientVisuals: createExtensionRuntimeSurfaceTransientVisuals(getInternalState, extensionDef),
|
|
85
|
+
events: createExtensionRuntimeSurfaceEvents(getInternalState, events, extensionDef)
|
|
42
86
|
};
|
|
43
87
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ActiveTargetDefinition, ActiveTargetInitConfig } from './types';
|
|
1
|
+
import { ActiveTargetDefinition, ActiveTargetInitConfig } from './types.js';
|
|
2
2
|
export declare function createActiveTarget(config?: ActiveTargetInitConfig): ActiveTargetDefinition;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from '@ktarmyshov/assert';
|
|
2
2
|
import { toMerged } from 'es-toolkit';
|
|
3
|
-
import { createSvgElement, updateElementAttributes } from '../../../render/svg/helpers';
|
|
4
|
-
import { isUpdateContextRenderable } from '../../types/context/update';
|
|
5
|
-
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers';
|
|
6
|
-
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types';
|
|
3
|
+
import { createSvgElement, updateElementAttributes } from '../../../render/svg/helpers.js';
|
|
4
|
+
import { isUpdateContextRenderable } from '../../types/context/update.js';
|
|
5
|
+
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers.js';
|
|
6
|
+
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types.js';
|
|
7
7
|
export function createActiveTarget(config = {}) {
|
|
8
8
|
const mergedConfig = toMerged(DEFAULT_CONFIG, config);
|
|
9
9
|
return {
|
|
@@ -60,19 +60,19 @@ function createActiveTargetInstance(config) {
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
const geometry = context.currentFrame.layout.geometry;
|
|
63
|
-
const r = geometry.
|
|
63
|
+
const r = geometry.getSquareRect(square);
|
|
64
64
|
const rectAttributes = {
|
|
65
65
|
x: r.x.toString(),
|
|
66
66
|
y: r.y.toString(),
|
|
67
|
-
width: r.
|
|
68
|
-
height: r.
|
|
67
|
+
width: r.width.toString(),
|
|
68
|
+
height: r.height.toString(),
|
|
69
69
|
fill: internalState.config.squareColor.color,
|
|
70
70
|
'fill-opacity': internalState.config.squareColor.opacity.toString(),
|
|
71
71
|
'shape-rendering': 'crispEdges'
|
|
72
72
|
};
|
|
73
73
|
const radius = geometry.squareSize * internalState.config.halo.radiusRatio;
|
|
74
|
-
const centerX = r.x + r.
|
|
75
|
-
const centerY = r.y + r.
|
|
74
|
+
const centerX = r.x + r.width / 2;
|
|
75
|
+
const centerY = r.y + r.height / 2;
|
|
76
76
|
const haloAttributes = {
|
|
77
77
|
cx: centerX.toString(),
|
|
78
78
|
cy: centerY.toString(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PartialDeep } from 'type-fest';
|
|
2
|
-
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension';
|
|
3
|
-
import { ExtensionInternal, OpaqueColor } from '../common/types';
|
|
2
|
+
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension.js';
|
|
3
|
+
import { ExtensionInternal, OpaqueColor } from '../common/types.js';
|
|
4
4
|
export declare const EXTENSION_SLOTS: readonly ["underPieces", "overPieces"];
|
|
5
5
|
export type ExtensionSlotsType = typeof EXTENSION_SLOTS;
|
|
6
6
|
export declare const EXTENSION_ID: "activeTarget";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { extensionCreateInternalBase } from '../common/helpers.js';
|
|
2
|
+
import { EXTENSION_ID, EXTENSION_SLOTS } from './types.js';
|
|
3
|
+
export function createAutoPromote() {
|
|
4
|
+
return {
|
|
5
|
+
id: EXTENSION_ID,
|
|
6
|
+
slots: EXTENSION_SLOTS,
|
|
7
|
+
createInstance() {
|
|
8
|
+
return createAutoPromoteInstance();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function createAutoPromoteInternal() {
|
|
13
|
+
return {
|
|
14
|
+
...extensionCreateInternalBase(),
|
|
15
|
+
toQueen: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createAutoPromoteInstancePublic(state) {
|
|
19
|
+
return {
|
|
20
|
+
get toQueen() {
|
|
21
|
+
return state.toQueen;
|
|
22
|
+
},
|
|
23
|
+
set toQueen(value) {
|
|
24
|
+
state.toQueen = value;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createAutoPromoteInstance() {
|
|
29
|
+
const internalState = createAutoPromoteInternal();
|
|
30
|
+
const publicInterface = createAutoPromoteInstancePublic(internalState);
|
|
31
|
+
return {
|
|
32
|
+
id: EXTENSION_ID,
|
|
33
|
+
onUIMoveRequest(context) {
|
|
34
|
+
if (!internalState.toQueen)
|
|
35
|
+
return;
|
|
36
|
+
// Check if we can promote to queen
|
|
37
|
+
const pendingRequest = context.request;
|
|
38
|
+
const activeDestination = pendingRequest.destination;
|
|
39
|
+
if (activeDestination.promotedTo?.includes(5 /* RoleCode.Queen */)) {
|
|
40
|
+
pendingRequest.resolve({
|
|
41
|
+
from: pendingRequest.sourceSquare,
|
|
42
|
+
to: activeDestination.to,
|
|
43
|
+
promotedTo: 5 /* RoleCode.Queen */
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
getPublic() {
|
|
48
|
+
return publicInterface;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExtensionSlotSvgRoots } from '../../types/basic/mount.js';
|
|
2
|
+
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension.js';
|
|
3
|
+
export declare const EXTENSION_SLOTS: readonly [];
|
|
4
|
+
export type ExtensionSlotsType = typeof EXTENSION_SLOTS;
|
|
5
|
+
export declare const EXTENSION_ID: "autoPromote";
|
|
6
|
+
export type AutoPromoteDefinition = ExtensionDefinition<typeof EXTENSION_ID, typeof EXTENSION_SLOTS, AutoPromotePublic>;
|
|
7
|
+
export interface AutoPromotePublic {
|
|
8
|
+
toQueen: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type AutoPromoteInstance = ExtensionInstance<typeof EXTENSION_ID, typeof EXTENSION_SLOTS, AutoPromotePublic>;
|
|
11
|
+
export type AutoPromoteSlotRoots = ExtensionSlotSvgRoots<typeof EXTENSION_SLOTS>;
|
|
12
|
+
export interface AutoPromoteInstanceInternal {
|
|
13
|
+
toQueen: boolean;
|
|
14
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BoardEventsDefinition } from './types';
|
|
1
|
+
import { BoardEventsDefinition } from './types.js';
|
|
2
2
|
export declare function createBoardEvents(): BoardEventsDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { denormalizeMove } from '../../../state/board/denormalize';
|
|
2
|
-
import { extensionCreateInternalBase
|
|
3
|
-
import { EXTENSION_ID, EXTENSION_SLOTS } from './types';
|
|
1
|
+
import { denormalizeMove } from '../../../state/board/denormalize.js';
|
|
2
|
+
import { extensionCreateInternalBase } from '../common/helpers.js';
|
|
3
|
+
import { EXTENSION_ID, EXTENSION_SLOTS } from './types.js';
|
|
4
4
|
export function createBoardEvents() {
|
|
5
5
|
return {
|
|
6
6
|
id: EXTENSION_ID,
|
|
@@ -17,10 +17,6 @@ function createBoardEventsInternal() {
|
|
|
17
17
|
onRawUpdate: null
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function extensionClean(state) {
|
|
21
|
-
state.onUIMove = null;
|
|
22
|
-
state.onRawUpdate = null;
|
|
23
|
-
}
|
|
24
20
|
function createBoardEventsInstancePublic(state) {
|
|
25
21
|
return {
|
|
26
22
|
setOnUIMove(callback) {
|
|
@@ -36,7 +32,6 @@ function createBoardEventsInstance() {
|
|
|
36
32
|
const publicInterface = createBoardEventsInstancePublic(internalState);
|
|
37
33
|
return {
|
|
38
34
|
id: EXTENSION_ID,
|
|
39
|
-
mount() { },
|
|
40
35
|
onUpdate(context) {
|
|
41
36
|
if (internalState.onRawUpdate) {
|
|
42
37
|
internalState.onRawUpdate({
|
|
@@ -52,14 +47,6 @@ function createBoardEventsInstance() {
|
|
|
52
47
|
},
|
|
53
48
|
getPublic() {
|
|
54
49
|
return publicInterface;
|
|
55
|
-
},
|
|
56
|
-
unmount() {
|
|
57
|
-
extensionUnmount(internalState);
|
|
58
|
-
extensionClean(internalState);
|
|
59
|
-
},
|
|
60
|
-
destroy() {
|
|
61
|
-
extensionDestroy(internalState);
|
|
62
|
-
extensionClean(internalState);
|
|
63
50
|
}
|
|
64
51
|
};
|
|
65
52
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RuntimeReadonlyMutationSession } from '../../../runtime/mutation/types';
|
|
2
|
-
import { MoveOutput } from '../../../state/board/types/output';
|
|
3
|
-
import { ExtensionSlotSvgRoots } from '../../types/basic/mount';
|
|
4
|
-
import { UpdateFrameSnapshot } from '../../types/basic/update';
|
|
5
|
-
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension';
|
|
6
|
-
import { ExtensionInternal } from '../common/types';
|
|
1
|
+
import { RuntimeReadonlyMutationSession } from '../../../runtime/mutation/types.js';
|
|
2
|
+
import { MoveOutput } from '../../../state/board/types/output.js';
|
|
3
|
+
import { ExtensionSlotSvgRoots } from '../../types/basic/mount.js';
|
|
4
|
+
import { UpdateFrameSnapshot } from '../../types/basic/update.js';
|
|
5
|
+
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension.js';
|
|
7
6
|
export declare const EXTENSION_SLOTS: readonly [];
|
|
8
7
|
export type ExtensionSlotsType = typeof EXTENSION_SLOTS;
|
|
9
8
|
export declare const EXTENSION_ID: "events";
|
|
@@ -21,7 +20,7 @@ export interface BoardEventsPublic {
|
|
|
21
20
|
}
|
|
22
21
|
export type BoardEventsInstance = ExtensionInstance<typeof EXTENSION_ID, typeof EXTENSION_SLOTS, BoardEventsPublic>;
|
|
23
22
|
export type BoardEventsSlotRoots = ExtensionSlotSvgRoots<typeof EXTENSION_SLOTS>;
|
|
24
|
-
export interface BoardEventsInstanceInternal
|
|
23
|
+
export interface BoardEventsInstanceInternal {
|
|
25
24
|
onUIMove: OnUIMoveCallback | null;
|
|
26
25
|
onRawUpdate: OnRawUpdateCallback | null;
|
|
27
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtensionSlotName } from '../../types/basic/mount';
|
|
2
|
-
import { ExtensionInternal } from './types';
|
|
1
|
+
import { ExtensionSlotName } from '../../types/basic/mount.js';
|
|
2
|
+
import { ExtensionInternal } from './types.js';
|
|
3
3
|
export declare function extensionCreateInternalBase<TSlots extends readonly ExtensionSlotName[]>(): ExtensionInternal<TSlots>;
|
|
4
4
|
export declare function extensionIsMounted<TSlots extends readonly ExtensionSlotName[]>(state: ExtensionInternal<TSlots>): boolean;
|
|
5
5
|
export declare function extensionIsDestroyed<TSlots extends readonly ExtensionSlotName[]>(state: ExtensionInternal<TSlots>): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtensionSlotName, ExtensionSlotSvgRoots } from '../../types/basic/mount';
|
|
1
|
+
import { ExtensionSlotName, ExtensionSlotSvgRoots } from '../../types/basic/mount.js';
|
|
2
2
|
export interface ExtensionInternal<TSlots extends readonly ExtensionSlotName[]> {
|
|
3
3
|
slotRoots: ExtensionSlotSvgRoots<TSlots> | null;
|
|
4
4
|
destroyed: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LastMoveDefinition, LastMoveInitConfig } from './types';
|
|
1
|
+
import { LastMoveDefinition, LastMoveInitConfig } from './types.js';
|
|
2
2
|
export declare function createLastMove(config?: LastMoveInitConfig): LastMoveDefinition;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import assert from '@ktarmyshov/assert';
|
|
2
2
|
import { toMerged } from 'es-toolkit';
|
|
3
|
-
import { createSvgElement, updateElementAttributes } from '../../../render/svg/helpers';
|
|
4
|
-
import { isUpdateContextRenderable } from '../../types/context/update';
|
|
5
|
-
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers';
|
|
6
|
-
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types';
|
|
3
|
+
import { createSvgElement, updateElementAttributes } from '../../../render/svg/helpers.js';
|
|
4
|
+
import { isUpdateContextRenderable } from '../../types/context/update.js';
|
|
5
|
+
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers.js';
|
|
6
|
+
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types.js';
|
|
7
7
|
export function createLastMove(config = {}) {
|
|
8
8
|
const mergedConfig = toMerged(DEFAULT_CONFIG, config);
|
|
9
9
|
return {
|
|
@@ -57,13 +57,13 @@ function createLastMoveInstance(config) {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
const geometry = context.currentFrame.layout.geometry;
|
|
60
|
-
const rFrom = geometry.
|
|
61
|
-
const rTo = geometry.
|
|
60
|
+
const rFrom = geometry.getSquareRect(fromSq);
|
|
61
|
+
const rTo = geometry.getSquareRect(toSq);
|
|
62
62
|
const rectFromAttributes = {
|
|
63
63
|
x: rFrom.x.toString(),
|
|
64
64
|
y: rFrom.y.toString(),
|
|
65
|
-
width: rFrom.
|
|
66
|
-
height: rFrom.
|
|
65
|
+
width: rFrom.width.toString(),
|
|
66
|
+
height: rFrom.height.toString(),
|
|
67
67
|
fill: internalState.config.color,
|
|
68
68
|
'fill-opacity': internalState.config.opacity.toString(),
|
|
69
69
|
'shape-rendering': 'crispEdges'
|
|
@@ -71,8 +71,8 @@ function createLastMoveInstance(config) {
|
|
|
71
71
|
const rectToAttributes = {
|
|
72
72
|
x: rTo.x.toString(),
|
|
73
73
|
y: rTo.y.toString(),
|
|
74
|
-
width: rTo.
|
|
75
|
-
height: rTo.
|
|
74
|
+
width: rTo.width.toString(),
|
|
75
|
+
height: rTo.height.toString(),
|
|
76
76
|
fill: internalState.config.color,
|
|
77
77
|
'fill-opacity': internalState.config.opacity.toString(),
|
|
78
78
|
'shape-rendering': 'crispEdges'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PartialDeep } from 'type-fest';
|
|
2
|
-
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension';
|
|
3
|
-
import { ExtensionInternal, OpaqueColor } from '../common/types';
|
|
2
|
+
import { ExtensionDefinition, ExtensionInstance } from '../../types/extension.js';
|
|
3
|
+
import { ExtensionInternal, OpaqueColor } from '../common/types.js';
|
|
4
4
|
export declare const EXTENSION_SLOTS: readonly ["underPieces"];
|
|
5
5
|
export type ExtensionSlotsType = typeof EXTENSION_SLOTS;
|
|
6
6
|
export declare const EXTENSION_ID: "lastMove";
|