@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,2 +1,2 @@
|
|
|
1
|
-
import { LegalMovesDefinition, LegalMovesInitConfig } from './types';
|
|
1
|
+
import { LegalMovesDefinition, LegalMovesInitConfig } from './types.js';
|
|
2
2
|
export declare function createLegalMoves(config?: LegalMovesInitConfig): LegalMovesDefinition;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import assert from '@ktarmyshov/assert';
|
|
2
2
|
import { toMerged } from 'es-toolkit';
|
|
3
|
-
import { clearElementChildren, createSvgElement } from '../../../render/svg/helpers';
|
|
4
|
-
import { isNonEmptyPieceCode } from '../../../state/board/check';
|
|
5
|
-
import { fromPieceCode } from '../../../state/board/piece';
|
|
6
|
-
import { isUpdateContextRenderable } from '../../types/context/update';
|
|
7
|
-
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers';
|
|
8
|
-
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types';
|
|
3
|
+
import { clearElementChildren, createSvgElement } from '../../../render/svg/helpers.js';
|
|
4
|
+
import { isNonEmptyPieceCode } from '../../../state/board/check.js';
|
|
5
|
+
import { fromPieceCode } from '../../../state/board/piece.js';
|
|
6
|
+
import { isUpdateContextRenderable } from '../../types/context/update.js';
|
|
7
|
+
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers.js';
|
|
8
|
+
import { DEFAULT_CONFIG, EXTENSION_ID, EXTENSION_SLOTS } from './types.js';
|
|
9
9
|
export function createLegalMoves(config = {}) {
|
|
10
10
|
const mergedConfig = toMerged(DEFAULT_CONFIG, config);
|
|
11
11
|
return {
|
|
@@ -70,7 +70,7 @@ function createLegalMovesInstance(config) {
|
|
|
70
70
|
fill: 'none'
|
|
71
71
|
}; // TODO: Remove, this is just for visual test
|
|
72
72
|
for (const [square, destination] of interaction.activeDestinations) {
|
|
73
|
-
const rect = geometry.
|
|
73
|
+
const rect = geometry.getSquareRect(square);
|
|
74
74
|
const circleX = rect.x + geometry.squareSize / 2;
|
|
75
75
|
const circleY = rect.y + geometry.squareSize / 2;
|
|
76
76
|
const selectedPieceCode = context.currentFrame.state.board.pieces[interaction.selected.square];
|
|
@@ -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 ["overPieces"];
|
|
5
5
|
export type ExtensionSlotsType = typeof EXTENSION_SLOTS;
|
|
6
6
|
export declare const EXTENSION_ID: "legalMoves";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionRuntimeSurface } from '../../../types/surface/main';
|
|
2
|
-
import type { PieceUrls } from '../types/internal';
|
|
3
|
-
import type { MainRendererAnimation } from './types';
|
|
1
|
+
import type { ExtensionRuntimeSurface } from '../../../types/surface/main.js';
|
|
2
|
+
import type { PieceUrls } from '../types/internal.js';
|
|
3
|
+
import type { MainRendererAnimation } from './types.js';
|
|
4
4
|
export declare function createMainRendererAnimation(config: PieceUrls, runtimeSurface: ExtensionRuntimeSurface): MainRendererAnimation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { cleanAnimationPlan } from '../../../../animation/render/plan';
|
|
2
|
-
import { getAnimationSuppressedSquares, rendererAnimationClean, rendererAnimationPrepare, rendererAnimationRender } from './render';
|
|
3
|
-
import { rendererAnimationOnUpdate } from './update';
|
|
1
|
+
import { cleanAnimationPlan } from '../../../../animation/render/plan.js';
|
|
2
|
+
import { getAnimationSuppressedSquares, rendererAnimationClean, rendererAnimationPrepare, rendererAnimationRender } from './render.js';
|
|
3
|
+
import { rendererAnimationOnUpdate } from './update.js';
|
|
4
4
|
export function createMainRendererAnimation(config, runtimeSurface) {
|
|
5
5
|
const state = {
|
|
6
6
|
config,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Square } from '../../../../state/board/types/internal';
|
|
2
|
-
import type { ExtensionCleanAnimationContext, ExtensionPrepareAnimationContext, ExtensionRenderAnimationContext } from '../../../types/context/animation';
|
|
3
|
-
import type { MainRendererAnimationInternal } from './types';
|
|
1
|
+
import type { Square } from '../../../../state/board/types/internal.js';
|
|
2
|
+
import type { ExtensionCleanAnimationContext, ExtensionPrepareAnimationContext, ExtensionRenderAnimationContext } from '../../../types/context/animation.js';
|
|
3
|
+
import type { MainRendererAnimationInternal } from './types.js';
|
|
4
4
|
export declare function rendererAnimationPrepare(state: MainRendererAnimationInternal, context: ExtensionPrepareAnimationContext, layer: SVGElement): void;
|
|
5
5
|
export declare function rendererAnimationRender(state: MainRendererAnimationInternal, context: ExtensionRenderAnimationContext): void;
|
|
6
6
|
export declare function rendererAnimationClean(state: MainRendererAnimationInternal, context: ExtensionCleanAnimationContext): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cleanAnimationPlan, prepareAnimationPlan, renderAnimationPlan } from '../../../../animation/render/plan';
|
|
1
|
+
import { cleanAnimationPlan, prepareAnimationPlan, renderAnimationPlan } from '../../../../animation/render/plan.js';
|
|
3
2
|
const EMPTY_SQUARES = new Set();
|
|
4
3
|
export function rendererAnimationPrepare(state, context, layer) {
|
|
5
4
|
for (const session of context.submittedSessions) {
|
|
@@ -38,7 +37,7 @@ export function getAnimationSuppressedSquares(state) {
|
|
|
38
37
|
const entry = state.entries.get(session.id);
|
|
39
38
|
if (!entry)
|
|
40
39
|
continue;
|
|
41
|
-
for (const sq of
|
|
40
|
+
for (const sq of entry.plan.suppressedSquares) {
|
|
42
41
|
result.add(sq);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PreparedNodeMap } from '../../../../animation/render/types';
|
|
2
|
-
import { AnimationPlan } from '../../../../animation/types';
|
|
3
|
-
import { Square } from '../../../../state/board/types/internal';
|
|
4
|
-
import { ExtensionCleanAnimationContext, ExtensionPrepareAnimationContext, ExtensionRenderAnimationContext } from '../../../types/context/animation';
|
|
5
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
6
|
-
import { ExtensionRuntimeSurface } from '../../../types/surface/main';
|
|
7
|
-
import type { PieceUrls } from '../types/internal';
|
|
1
|
+
import { PreparedNodeMap } from '../../../../animation/render/types.js';
|
|
2
|
+
import { AnimationPlan } from '../../../../animation/types.js';
|
|
3
|
+
import { Square } from '../../../../state/board/types/internal.js';
|
|
4
|
+
import { ExtensionCleanAnimationContext, ExtensionPrepareAnimationContext, ExtensionRenderAnimationContext } from '../../../types/context/animation.js';
|
|
5
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
6
|
+
import { ExtensionRuntimeSurface } from '../../../types/surface/main.js';
|
|
7
|
+
import type { PieceUrls } from '../types/internal.js';
|
|
8
8
|
export interface MainRendererAnimationEntry {
|
|
9
9
|
plan: AnimationPlan;
|
|
10
10
|
nodes: PreparedNodeMap | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
2
|
-
import type { MainRendererAnimationInternal } from './types';
|
|
1
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
2
|
+
import type { MainRendererAnimationInternal } from './types.js';
|
|
3
3
|
export declare function rendererAnimationOnUpdate(state: MainRendererAnimationInternal, context: ExtensionUpdateContext): void;
|
|
@@ -1,40 +1,26 @@
|
|
|
1
|
-
import { calculateAnimationPlan } from '../../../../animation/planner';
|
|
2
|
-
import { piecePositionsEqual } from '../../../../state/board/check';
|
|
3
|
-
import {
|
|
1
|
+
import { calculateAnimationPlan } from '../../../../animation/planner.js';
|
|
2
|
+
import { piecePositionsEqual } from '../../../../state/board/check.js';
|
|
3
|
+
import { changeStatesEqual } from '../../../../state/change/helpers.js';
|
|
4
|
+
import { isUpdateContextRenderable } from '../../../types/context/update.js';
|
|
4
5
|
const DEFAULT_ANIMATION_DURATION_MS = 180;
|
|
5
6
|
export function rendererAnimationOnUpdate(state, context) {
|
|
6
7
|
if (!isUpdateContextRenderable(context) ||
|
|
7
|
-
!context.mutation.hasMutation({ prefixes: ['state.board.'] }) ||
|
|
8
|
+
!context.mutation.hasMutation({ prefixes: ['state.board.', 'state.change.'] }) ||
|
|
8
9
|
!context.previousFrame) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (piecePositionsEqual(previousBoard, currentBoard))
|
|
12
|
+
if (piecePositionsEqual(context.previousFrame.state.board, context.currentFrame.state.board) &&
|
|
13
|
+
changeStatesEqual(context.previousFrame.state.change, context.currentFrame.state.change))
|
|
14
14
|
return;
|
|
15
|
-
//
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
context.currentFrame.state
|
|
19
|
-
exclude.push({
|
|
20
|
-
fromSq: context.currentFrame.state.change.lastMove.from,
|
|
21
|
-
toSq: context.currentFrame.state.change.lastMove.to
|
|
22
|
-
});
|
|
23
|
-
exclude.push({
|
|
24
|
-
sq: context.currentFrame.state.change.lastMove.from
|
|
25
|
-
});
|
|
26
|
-
exclude.push({
|
|
27
|
-
sq: context.currentFrame.state.change.lastMove.to
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const plan = calculateAnimationPlan(previousBoard, currentBoard, 0 /* placeholder session id for draft plan */, {
|
|
31
|
-
exclude
|
|
15
|
+
// Pass raw snapshots to the planner — it normalizes internally
|
|
16
|
+
const plan = calculateAnimationPlan({
|
|
17
|
+
previous: context.previousFrame.state,
|
|
18
|
+
current: context.currentFrame.state
|
|
32
19
|
});
|
|
33
20
|
if (plan.tracks.length === 0)
|
|
34
21
|
return;
|
|
35
22
|
const session = state.runtimeSurface.animation.submit({
|
|
36
23
|
duration: DEFAULT_ANIMATION_DURATION_MS
|
|
37
24
|
});
|
|
38
|
-
|
|
39
|
-
state.entries.set(plan.sessionId, { plan, nodes: null });
|
|
25
|
+
state.entries.set(session.id, { plan, nodes: null });
|
|
40
26
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigColorPair } from '../types/internal';
|
|
2
|
-
import { MainRendererBoard } from './types';
|
|
1
|
+
import { ConfigColorPair } from '../types/internal.js';
|
|
2
|
+
import { MainRendererBoard } from './types.js';
|
|
3
3
|
export declare function createMainRendererBoard(config: ConfigColorPair): MainRendererBoard;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rendererBoardRender } from './render';
|
|
2
|
-
import { rendererBoardOnUpdate } from './update';
|
|
1
|
+
import { rendererBoardRender } from './render.js';
|
|
2
|
+
import { rendererBoardOnUpdate } from './update.js';
|
|
3
3
|
function createMainRendererBoardInternal(config) {
|
|
4
4
|
return { config };
|
|
5
5
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
2
|
-
import { MainRendererBoardInternal } from './types';
|
|
1
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
2
|
+
import { MainRendererBoardInternal } from './types.js';
|
|
3
3
|
export declare function rendererBoardRender(state: MainRendererBoardInternal, context: ExtensionRenderContext, layer: SVGElement): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clearElementChildren, createSvgElement, isLightSquare } from '../../../../render/svg/helpers';
|
|
2
|
-
import { SQUARE_COUNT } from '../../../../state/board/types/internal';
|
|
3
|
-
import { DirtyLayer } from '../types/extension';
|
|
1
|
+
import { clearElementChildren, createSvgElement, isLightSquare } from '../../../../render/svg/helpers.js';
|
|
2
|
+
import { SQUARE_COUNT } from '../../../../state/board/types/internal.js';
|
|
3
|
+
import { DirtyLayer } from '../types/extension.js';
|
|
4
4
|
export function rendererBoardRender(state, context, layer) {
|
|
5
5
|
// Check if we need to render
|
|
6
6
|
if ((context.invalidation.dirtyLayers & DirtyLayer.Board) === 0) {
|
|
@@ -10,13 +10,13 @@ export function rendererBoardRender(state, context, layer) {
|
|
|
10
10
|
clearElementChildren(layer);
|
|
11
11
|
const { light, dark } = state.config;
|
|
12
12
|
for (let sq = 0; sq < SQUARE_COUNT; sq++) {
|
|
13
|
-
const r = geometry.
|
|
13
|
+
const r = geometry.getSquareRect(sq);
|
|
14
14
|
createSvgElement(layer, 'rect', {
|
|
15
15
|
'data-chessboard-id': `square-${sq}`,
|
|
16
16
|
x: r.x.toString(),
|
|
17
17
|
y: r.y.toString(),
|
|
18
|
-
width: r.
|
|
19
|
-
height: r.
|
|
18
|
+
width: r.width.toString(),
|
|
19
|
+
height: r.height.toString(),
|
|
20
20
|
fill: isLightSquare(sq) ? light : dark,
|
|
21
21
|
'shape-rendering': 'crispEdges'
|
|
22
22
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
2
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
3
|
-
import { ConfigColorPair } from '../types/internal';
|
|
1
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
2
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
3
|
+
import { ConfigColorPair } from '../types/internal.js';
|
|
4
4
|
export interface MainRendererBoardInternal {
|
|
5
5
|
readonly config: ConfigColorPair;
|
|
6
6
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
2
|
-
import { MainRendererBoardInternal } from './types';
|
|
1
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
2
|
+
import { MainRendererBoardInternal } from './types.js';
|
|
3
3
|
export declare function rendererBoardOnUpdate(_state: MainRendererBoardInternal, context: ExtensionUpdateContext): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { sceneRectsEqual } from '../../../../layout/geometry/helpers.js';
|
|
2
|
+
import { isFrameRenderable } from '../../../types/basic/update.js';
|
|
3
|
+
import { isUpdateContextRenderable } from '../../../types/context/update.js';
|
|
4
|
+
import { DirtyLayer } from '../types/extension.js';
|
|
4
5
|
export function rendererBoardOnUpdate(_state, context) {
|
|
5
6
|
// Check if geometry changed
|
|
6
7
|
const mutationSession = context.mutation;
|
|
@@ -12,14 +13,15 @@ export function rendererBoardOnUpdate(_state, context) {
|
|
|
12
13
|
}
|
|
13
14
|
// Ok geometry changed, let's check the board size
|
|
14
15
|
const currentGeometry = context.currentFrame.layout.geometry;
|
|
15
|
-
const
|
|
16
|
+
const currentBoardRect = currentGeometry.boardRect;
|
|
16
17
|
const currentOrientation = currentGeometry.orientation;
|
|
17
18
|
const previousGeometry = context.previousFrame && isFrameRenderable(context.previousFrame)
|
|
18
19
|
? context.previousFrame.layout.geometry
|
|
19
20
|
: null;
|
|
20
|
-
const
|
|
21
|
+
const previousBoardRect = previousGeometry?.boardRect ?? null;
|
|
21
22
|
const previousOrientation = previousGeometry?.orientation;
|
|
22
|
-
const needsRender =
|
|
23
|
+
const needsRender = sceneRectsEqual(currentBoardRect, previousBoardRect) === false ||
|
|
24
|
+
currentOrientation !== previousOrientation;
|
|
23
25
|
if (!needsRender) {
|
|
24
26
|
return; // no-op
|
|
25
27
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigColorPair } from '../types/internal';
|
|
2
|
-
import { MainRendererCoordinates } from './types';
|
|
1
|
+
import { ConfigColorPair } from '../types/internal.js';
|
|
2
|
+
import { MainRendererCoordinates } from './types.js';
|
|
3
3
|
export declare function createMainRendererCoordinates(config: ConfigColorPair): MainRendererCoordinates;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
2
|
-
import { MainRendererCoordinatesInternal } from './types';
|
|
1
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
2
|
+
import { MainRendererCoordinatesInternal } from './types.js';
|
|
3
3
|
export declare function rendererCoordinatesRender(state: MainRendererCoordinatesInternal, context: ExtensionRenderContext, layer: SVGElement): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clearElementChildren, createSvgElement, isLightSquare } from '../../../../render/svg/helpers';
|
|
2
|
-
import { squareOf } from '../../../../state/board/coords';
|
|
3
|
-
import { DirtyLayer } from '../types/extension';
|
|
1
|
+
import { clearElementChildren, createSvgElement, isLightSquare } from '../../../../render/svg/helpers.js';
|
|
2
|
+
import { squareOf } from '../../../../state/board/coords.js';
|
|
3
|
+
import { DirtyLayer } from '../types/extension.js';
|
|
4
4
|
function labelColorForSquare(sq, coordColors) {
|
|
5
5
|
return isLightSquare(sq) ? coordColors.dark : coordColors.light;
|
|
6
6
|
}
|
|
@@ -19,7 +19,7 @@ export function rendererCoordinatesRender(state, context, layer) {
|
|
|
19
19
|
const logicalRank = (geometry.orientation === 0 /* ColorCode.White */ ? 7 - visualRank : visualRank);
|
|
20
20
|
const sq = squareOf(rankFile, logicalRank);
|
|
21
21
|
const label = geometry.orientation === 0 /* ColorCode.White */ ? String(8 - visualRank) : String(1 + visualRank);
|
|
22
|
-
const r = geometry.
|
|
22
|
+
const r = geometry.getSquareRect(sq);
|
|
23
23
|
const color = labelColorForSquare(sq, coords);
|
|
24
24
|
const text = createSvgElement(layer, 'text', {
|
|
25
25
|
'data-chessboard-id': `coord-rank-${label}`,
|
|
@@ -42,12 +42,12 @@ export function rendererCoordinatesRender(state, context, layer) {
|
|
|
42
42
|
const label = geometry.orientation === 0 /* ColorCode.White */
|
|
43
43
|
? String.fromCharCode('a'.charCodeAt(0) + visualFile)
|
|
44
44
|
: String.fromCharCode('h'.charCodeAt(0) - visualFile);
|
|
45
|
-
const r = geometry.
|
|
45
|
+
const r = geometry.getSquareRect(sq);
|
|
46
46
|
const color = labelColorForSquare(sq, coords);
|
|
47
47
|
const text = createSvgElement(layer, 'text', {
|
|
48
48
|
'data-chessboard-id': `coord-file-${label}`,
|
|
49
|
-
x: (r.x + r.
|
|
50
|
-
y: (r.y + r.
|
|
49
|
+
x: (r.x + r.width - offset).toString(),
|
|
50
|
+
y: (r.y + r.height - offset).toString(),
|
|
51
51
|
'font-size': fontSize.toString(),
|
|
52
52
|
'font-family': 'sans-serif',
|
|
53
53
|
'font-weight': 'bold',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
2
|
-
import { ConfigColorPair } from '../types/internal';
|
|
1
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
2
|
+
import { ConfigColorPair } from '../types/internal.js';
|
|
3
3
|
export interface MainRendererCoordinatesInternal {
|
|
4
4
|
readonly config: ConfigColorPair;
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtensionRuntimeSurface } from '../../../types/surface/main';
|
|
2
|
-
import { PieceUrls } from '../types/internal';
|
|
3
|
-
import { MainRendererDrag } from './types';
|
|
1
|
+
import { ExtensionRuntimeSurface } from '../../../types/surface/main.js';
|
|
2
|
+
import { PieceUrls } from '../types/internal.js';
|
|
3
|
+
import { MainRendererDrag } from './types.js';
|
|
4
4
|
export declare function createMainRendererDrag(config: PieceUrls, runtimeSurface: ExtensionRuntimeSurface): MainRendererDrag;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rendererDragRenderTransientVisuals } from './render';
|
|
2
|
-
import { rendererDragOnUpdate } from './update';
|
|
1
|
+
import { rendererDragRenderTransientVisuals } from './render.js';
|
|
2
|
+
import { rendererDragOnUpdate } from './update.js';
|
|
3
3
|
function createMainRendererDragInternal(config, runtimeSurface) {
|
|
4
4
|
return { config, runtimeSurface, isDragActive: false, pieceUrl: null, pieceNode: null };
|
|
5
5
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionRenderTransientVisualsContext } from '../../../types/context/transient-visuals';
|
|
2
|
-
import { MainRendererDragInternal } from './types';
|
|
1
|
+
import { ExtensionRenderTransientVisualsContext } from '../../../types/context/transient-visuals.js';
|
|
2
|
+
import { MainRendererDragInternal } from './types.js';
|
|
3
3
|
export declare function rendererDragRenderTransientVisuals(state: MainRendererDragInternal, context: ExtensionRenderTransientVisualsContext, layer: SVGElement): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createSvgElement, updateElementAttributes } from '../../../../render/svg/helpers';
|
|
1
|
+
import { createSvgElement, updateElementAttributes } from '../../../../render/svg/helpers.js';
|
|
2
2
|
export function rendererDragRenderTransientVisuals(state, context, layer) {
|
|
3
3
|
const geometry = context.currentFrame.layout.geometry;
|
|
4
|
-
const point = context.transientInput.
|
|
4
|
+
const point = context.transientInput.boardClampedPoint;
|
|
5
5
|
const squareSize = geometry.squareSize.toString();
|
|
6
6
|
const x = (point.x - geometry.squareSize / 2).toString();
|
|
7
7
|
const y = (point.y - geometry.squareSize / 2).toString();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExtensionRenderTransientVisualsContext } from '../../../types/context/transient-visuals';
|
|
2
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
3
|
-
import { ExtensionRuntimeSurface } from '../../../types/surface/main';
|
|
4
|
-
import { PieceUrls } from '../types/internal';
|
|
1
|
+
import { ExtensionRenderTransientVisualsContext } from '../../../types/context/transient-visuals.js';
|
|
2
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
3
|
+
import { ExtensionRuntimeSurface } from '../../../types/surface/main.js';
|
|
4
|
+
import { PieceUrls } from '../types/internal.js';
|
|
5
5
|
export interface MainRendererDragInternal {
|
|
6
6
|
readonly config: PieceUrls;
|
|
7
7
|
readonly runtimeSurface: ExtensionRuntimeSurface;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
2
|
-
import { MainRendererDragInternal } from './types';
|
|
1
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
2
|
+
import { MainRendererDragInternal } from './types.js';
|
|
3
3
|
export declare function rendererDragOnUpdate(state: MainRendererDragInternal, context: ExtensionUpdateContext): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from '@ktarmyshov/assert';
|
|
2
|
-
import { isNonEmptyPieceCode } from '../../../../state/board/check';
|
|
2
|
+
import { isNonEmptyPieceCode } from '../../../../state/board/check.js';
|
|
3
3
|
export function rendererDragOnUpdate(state, context) {
|
|
4
4
|
const isLiftedDragActive = context.currentFrame.state.interaction.dragSession?.type === 'lifted-piece-drag';
|
|
5
5
|
if (isLiftedDragActive) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MainRendererDefinition, MainRendererInitOptions } from './types/extension';
|
|
1
|
+
import { MainRendererDefinition, MainRendererInitOptions } from './types/extension.js';
|
|
2
2
|
export declare function createMainRenderer(options?: MainRendererInitOptions): MainRendererDefinition;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { toMerged } from 'es-toolkit';
|
|
2
|
-
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers';
|
|
3
|
-
import { createMainRendererAnimation } from './animation/factory';
|
|
4
|
-
import { createMainRendererBoard } from './board/factory';
|
|
5
|
-
import { createMainRendererCoordinates } from './coordinates/factory';
|
|
6
|
-
import { createMainRendererDrag } from './drag/factory';
|
|
7
|
-
import { normalizeMainRendererConfig } from './normalize';
|
|
8
|
-
import { createMainRendererPieces } from './pieces/factory';
|
|
9
|
-
import { EXTENSION_ID, EXTENSION_SLOTS } from './types/extension';
|
|
10
|
-
import { DEFAULT_MAIN_RENDERER_CONFIG } from './types/internal';
|
|
2
|
+
import { extensionCreateInternalBase, extensionDestroy, extensionMount, extensionUnmount } from '../common/helpers.js';
|
|
3
|
+
import { createMainRendererAnimation } from './animation/factory.js';
|
|
4
|
+
import { createMainRendererBoard } from './board/factory.js';
|
|
5
|
+
import { createMainRendererCoordinates } from './coordinates/factory.js';
|
|
6
|
+
import { createMainRendererDrag } from './drag/factory.js';
|
|
7
|
+
import { normalizeMainRendererConfig } from './normalize.js';
|
|
8
|
+
import { createMainRendererPieces } from './pieces/factory.js';
|
|
9
|
+
import { EXTENSION_ID, EXTENSION_SLOTS } from './types/extension.js';
|
|
10
|
+
import { DEFAULT_MAIN_RENDERER_CONFIG } from './types/internal.js';
|
|
11
11
|
export function createMainRenderer(options = {}) {
|
|
12
12
|
const config = toMerged(DEFAULT_MAIN_RENDERER_CONFIG, normalizeMainRendererConfig(options));
|
|
13
13
|
return {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MainRendererConfigInput
|
|
2
|
-
import { MainRendererConfig
|
|
3
|
-
export declare function normalizePieceUrls(input: PieceUrlsInput): PieceUrls;
|
|
1
|
+
import { MainRendererConfigInput } from './types/input.js';
|
|
2
|
+
import { MainRendererConfig } from './types/internal.js';
|
|
4
3
|
export declare function normalizeMainRendererConfig(input: Partial<MainRendererConfigInput>): MainRendererConfig;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import assert from '@ktarmyshov/assert';
|
|
2
|
-
import { normalizePiece } from '../../../state/board/normalize';
|
|
3
|
-
import { ALL_NON_EMPTY_PIECE_CODES } from '../../../state/board/types/internal';
|
|
4
|
-
import { DEFAULT_MAIN_RENDERER_CONFIG } from './types/internal';
|
|
2
|
+
import { normalizePiece } from '../../../state/board/normalize.js';
|
|
3
|
+
import { ALL_NON_EMPTY_PIECE_CODES } from '../../../state/board/types/internal.js';
|
|
4
|
+
import { DEFAULT_MAIN_RENDERER_CONFIG } from './types/internal.js';
|
|
5
5
|
function assertPieceUrlsComplete(pieceUrls) {
|
|
6
6
|
for (const pieceCode of ALL_NON_EMPTY_PIECE_CODES) {
|
|
7
7
|
assert(pieceCode in pieceUrls, `Missing URL for piece code: ${pieceCode}`);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
function normalizePieceUrls(input) {
|
|
11
11
|
const normalized = {};
|
|
12
12
|
for (const [key, url] of Object.entries(input)) {
|
|
13
13
|
const pieceCode = normalizePiece(key);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PieceUrls } from '../types/internal';
|
|
2
|
-
import { MainRendererPieces } from './types';
|
|
1
|
+
import { PieceUrls } from '../types/internal.js';
|
|
2
|
+
import { MainRendererPieces } from './types.js';
|
|
3
3
|
export declare function createMainRendererPieces(config: PieceUrls): MainRendererPieces;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rendererPiecesRender } from './render';
|
|
2
|
-
import { rendererPiecesOnUpdate, rendererPiecesRefreshSuppressedSquares } from './update';
|
|
1
|
+
import { rendererPiecesRender } from './render.js';
|
|
2
|
+
import { rendererPiecesOnUpdate, rendererPiecesRefreshSuppressedSquares } from './update.js';
|
|
3
3
|
export function createMainRendererPieces(config) {
|
|
4
4
|
const state = {
|
|
5
5
|
config,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
2
|
-
import { MainRendererPiecesInternal } from './types';
|
|
1
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
2
|
+
import { MainRendererPiecesInternal } from './types.js';
|
|
3
3
|
export declare function rendererPiecesRender(state: MainRendererPiecesInternal, context: ExtensionRenderContext, layer: SVGElement): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createSvgElement, updateElementAttributes } from '../../../../render/svg/helpers';
|
|
2
|
-
import { isNonEmptyPieceCode } from '../../../../state/board/check';
|
|
3
|
-
import { SQUARE_COUNT } from '../../../../state/board/types/internal';
|
|
4
|
-
import { DirtyLayer } from '../types/extension';
|
|
1
|
+
import { createSvgElement, updateElementAttributes } from '../../../../render/svg/helpers.js';
|
|
2
|
+
import { isNonEmptyPieceCode } from '../../../../state/board/check.js';
|
|
3
|
+
import { SQUARE_COUNT } from '../../../../state/board/types/internal.js';
|
|
4
|
+
import { DirtyLayer } from '../types/extension.js';
|
|
5
5
|
export function rendererPiecesRender(state, context, layer) {
|
|
6
6
|
if ((context.invalidation.dirtyLayers & DirtyLayer.Pieces) === 0) {
|
|
7
7
|
return;
|
|
@@ -14,13 +14,13 @@ export function rendererPiecesRender(state, context, layer) {
|
|
|
14
14
|
const suppressed = state.suppressedSquares.has(sq);
|
|
15
15
|
if (isNonEmptyPieceCode(pieceCode) && !suppressed) {
|
|
16
16
|
const url = state.config[pieceCode];
|
|
17
|
-
const r = geometry.
|
|
17
|
+
const r = geometry.getSquareRect(sq);
|
|
18
18
|
if (existing !== null) {
|
|
19
19
|
updateElementAttributes(existing.root, {
|
|
20
20
|
x: r.x.toString(),
|
|
21
21
|
y: r.y.toString(),
|
|
22
|
-
width: r.
|
|
23
|
-
height: r.
|
|
22
|
+
width: r.width.toString(),
|
|
23
|
+
height: r.height.toString(),
|
|
24
24
|
href: url
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -31,8 +31,8 @@ export function rendererPiecesRender(state, context, layer) {
|
|
|
31
31
|
href: url,
|
|
32
32
|
x: r.x.toString(),
|
|
33
33
|
y: r.y.toString(),
|
|
34
|
-
width: r.
|
|
35
|
-
height: r.
|
|
34
|
+
width: r.width.toString(),
|
|
35
|
+
height: r.height.toString()
|
|
36
36
|
})
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Square } from '../../../../state/board/types/internal';
|
|
2
|
-
import { ExtensionCleanAnimationContext } from '../../../types/context/animation';
|
|
3
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
4
|
-
import { MainRendererPiecesInternal } from './types';
|
|
1
|
+
import { Square } from '../../../../state/board/types/internal.js';
|
|
2
|
+
import { ExtensionCleanAnimationContext } from '../../../types/context/animation.js';
|
|
3
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
4
|
+
import { MainRendererPiecesInternal } from './types.js';
|
|
5
5
|
export declare function calculateSuppressedSquares(_state: MainRendererPiecesInternal, context: ExtensionUpdateContext | ExtensionCleanAnimationContext, animationSuppressedSquares: ReadonlySet<Square>): ReadonlySet<Square>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export function calculateSuppressedSquares(_state, context, animationSuppressedSquares) {
|
|
2
2
|
const dragSession = context.currentFrame.state.interaction.dragSession;
|
|
3
|
-
const dragSquare = dragSession?.type === 'lifted-piece-drag' ? dragSession.sourceSquare :
|
|
3
|
+
const dragSquare = dragSession?.type === 'lifted-piece-drag' ? dragSession.sourceSquare : null;
|
|
4
4
|
const result = new Set(animationSuppressedSquares);
|
|
5
|
-
if (dragSquare !==
|
|
5
|
+
if (dragSquare !== null) {
|
|
6
6
|
result.add(dragSquare);
|
|
7
7
|
}
|
|
8
|
+
const pendingMoveRequest = context.currentFrame.state.change.deferredUIMoveRequest;
|
|
9
|
+
if (pendingMoveRequest) {
|
|
10
|
+
result.add(pendingMoveRequest.sourceSquare);
|
|
11
|
+
result.add(pendingMoveRequest.destination.to);
|
|
12
|
+
}
|
|
8
13
|
return result;
|
|
9
14
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Square } from '../../../../state/board/types/internal';
|
|
2
|
-
import { ExtensionCleanAnimationContext } from '../../../types/context/animation';
|
|
3
|
-
import { ExtensionRenderContext } from '../../../types/context/render';
|
|
4
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
5
|
-
import { PieceUrls } from '../types/internal';
|
|
1
|
+
import { Square } from '../../../../state/board/types/internal.js';
|
|
2
|
+
import { ExtensionCleanAnimationContext } from '../../../types/context/animation.js';
|
|
3
|
+
import { ExtensionRenderContext } from '../../../types/context/render.js';
|
|
4
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
5
|
+
import { PieceUrls } from '../types/internal.js';
|
|
6
6
|
type PieceNodeRecord = {
|
|
7
7
|
root: SVGImageElement;
|
|
8
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Square } from '../../../../state/board/types/internal';
|
|
2
|
-
import { ExtensionCleanAnimationContext } from '../../../types/context/animation';
|
|
3
|
-
import { ExtensionUpdateContext } from '../../../types/context/update';
|
|
4
|
-
import { MainRendererPiecesInternal } from './types';
|
|
1
|
+
import { Square } from '../../../../state/board/types/internal.js';
|
|
2
|
+
import { ExtensionCleanAnimationContext } from '../../../types/context/animation.js';
|
|
3
|
+
import { ExtensionUpdateContext } from '../../../types/context/update.js';
|
|
4
|
+
import { MainRendererPiecesInternal } from './types.js';
|
|
5
5
|
export declare function rendererPiecesOnUpdate(state: MainRendererPiecesInternal, context: ExtensionUpdateContext, animationSuppressedSquares: ReadonlySet<Square>): void;
|
|
6
6
|
export declare function rendererPiecesRefreshSuppressedSquares(state: MainRendererPiecesInternal, context: ExtensionCleanAnimationContext, animationSuppressedSquares: ReadonlySet<Square>): void;
|