@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.
Files changed (268) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +224 -47
  3. package/dist/animation/planner.d.ts +11 -6
  4. package/dist/animation/planner.js +167 -48
  5. package/dist/animation/render/fade.d.ts +5 -5
  6. package/dist/animation/render/fade.js +4 -4
  7. package/dist/animation/render/move.d.ts +6 -6
  8. package/dist/animation/render/move.js +6 -6
  9. package/dist/animation/render/plan.d.ts +6 -6
  10. package/dist/animation/render/plan.js +3 -3
  11. package/dist/animation/render/static.d.ts +5 -5
  12. package/dist/animation/render/static.js +4 -4
  13. package/dist/animation/render/types.d.ts +1 -1
  14. package/dist/animation/types.d.ts +15 -16
  15. package/dist/animation/types.js +1 -6
  16. package/dist/extensions/animation/factory.d.ts +1 -1
  17. package/dist/extensions/animation/factory.js +1 -1
  18. package/dist/extensions/animation/types.d.ts +1 -1
  19. package/dist/extensions/factory/main.d.ts +1 -1
  20. package/dist/extensions/factory/main.js +27 -6
  21. package/dist/extensions/factory/runtime.d.ts +6 -5
  22. package/dist/extensions/factory/runtime.js +48 -4
  23. package/dist/extensions/first-party/active-target/factory.d.ts +1 -1
  24. package/dist/extensions/first-party/active-target/factory.js +9 -9
  25. package/dist/extensions/first-party/active-target/types.d.ts +2 -2
  26. package/dist/extensions/first-party/auto-promote/factory.d.ts +2 -0
  27. package/dist/extensions/first-party/auto-promote/factory.js +51 -0
  28. package/dist/extensions/first-party/auto-promote/types.d.ts +14 -0
  29. package/dist/extensions/first-party/auto-promote/types.js +2 -0
  30. package/dist/extensions/first-party/board-events/factory.d.ts +1 -1
  31. package/dist/extensions/first-party/board-events/factory.js +3 -16
  32. package/dist/extensions/first-party/board-events/types.d.ts +6 -7
  33. package/dist/extensions/first-party/common/helpers.d.ts +2 -2
  34. package/dist/extensions/first-party/common/helpers.js +1 -1
  35. package/dist/extensions/first-party/common/types.d.ts +1 -1
  36. package/dist/extensions/first-party/last-move/factory.d.ts +1 -1
  37. package/dist/extensions/first-party/last-move/factory.js +10 -10
  38. package/dist/extensions/first-party/last-move/types.d.ts +2 -2
  39. package/dist/extensions/first-party/legal-moves/factory.d.ts +1 -1
  40. package/dist/extensions/first-party/legal-moves/factory.js +7 -7
  41. package/dist/extensions/first-party/legal-moves/types.d.ts +2 -2
  42. package/dist/extensions/first-party/main-renderer/animation/factory.d.ts +3 -3
  43. package/dist/extensions/first-party/main-renderer/animation/factory.js +3 -3
  44. package/dist/extensions/first-party/main-renderer/animation/render.d.ts +3 -3
  45. package/dist/extensions/first-party/main-renderer/animation/render.js +2 -3
  46. package/dist/extensions/first-party/main-renderer/animation/types.d.ts +7 -7
  47. package/dist/extensions/first-party/main-renderer/animation/update.d.ts +2 -2
  48. package/dist/extensions/first-party/main-renderer/animation/update.js +12 -26
  49. package/dist/extensions/first-party/main-renderer/board/factory.d.ts +2 -2
  50. package/dist/extensions/first-party/main-renderer/board/factory.js +2 -2
  51. package/dist/extensions/first-party/main-renderer/board/render.d.ts +2 -2
  52. package/dist/extensions/first-party/main-renderer/board/render.js +6 -6
  53. package/dist/extensions/first-party/main-renderer/board/types.d.ts +3 -3
  54. package/dist/extensions/first-party/main-renderer/board/update.d.ts +2 -2
  55. package/dist/extensions/first-party/main-renderer/board/update.js +8 -6
  56. package/dist/extensions/first-party/main-renderer/coordinates/factory.d.ts +2 -2
  57. package/dist/extensions/first-party/main-renderer/coordinates/factory.js +1 -1
  58. package/dist/extensions/first-party/main-renderer/coordinates/render.d.ts +2 -2
  59. package/dist/extensions/first-party/main-renderer/coordinates/render.js +7 -7
  60. package/dist/extensions/first-party/main-renderer/coordinates/types.d.ts +2 -2
  61. package/dist/extensions/first-party/main-renderer/drag/factory.d.ts +3 -3
  62. package/dist/extensions/first-party/main-renderer/drag/factory.js +2 -2
  63. package/dist/extensions/first-party/main-renderer/drag/render.d.ts +2 -2
  64. package/dist/extensions/first-party/main-renderer/drag/render.js +2 -2
  65. package/dist/extensions/first-party/main-renderer/drag/types.d.ts +4 -4
  66. package/dist/extensions/first-party/main-renderer/drag/update.d.ts +2 -2
  67. package/dist/extensions/first-party/main-renderer/drag/update.js +1 -1
  68. package/dist/extensions/first-party/main-renderer/factory.d.ts +1 -1
  69. package/dist/extensions/first-party/main-renderer/factory.js +9 -9
  70. package/dist/extensions/first-party/main-renderer/normalize.d.ts +2 -3
  71. package/dist/extensions/first-party/main-renderer/normalize.js +4 -4
  72. package/dist/extensions/first-party/main-renderer/pieces/factory.d.ts +2 -2
  73. package/dist/extensions/first-party/main-renderer/pieces/factory.js +2 -2
  74. package/dist/extensions/first-party/main-renderer/pieces/render.d.ts +2 -2
  75. package/dist/extensions/first-party/main-renderer/pieces/render.js +9 -9
  76. package/dist/extensions/first-party/main-renderer/pieces/suppress.d.ts +4 -4
  77. package/dist/extensions/first-party/main-renderer/pieces/suppress.js +7 -2
  78. package/dist/extensions/first-party/main-renderer/pieces/types.d.ts +5 -5
  79. package/dist/extensions/first-party/main-renderer/pieces/update.d.ts +4 -4
  80. package/dist/extensions/first-party/main-renderer/pieces/update.js +5 -5
  81. package/dist/extensions/first-party/main-renderer/types/extension.d.ts +3 -3
  82. package/dist/extensions/first-party/main-renderer/types/extension.js +1 -1
  83. package/dist/extensions/first-party/main-renderer/types/input.d.ts +2 -2
  84. package/dist/extensions/first-party/main-renderer/types/instance.d.ts +8 -8
  85. package/dist/extensions/first-party/main-renderer/types/internal.d.ts +2 -2
  86. package/dist/extensions/first-party/main-renderer/types/template.d.ts +1 -1
  87. package/dist/extensions/first-party/promotion/factory.d.ts +3 -0
  88. package/dist/extensions/first-party/promotion/factory.js +219 -0
  89. package/dist/extensions/first-party/promotion/normalize.d.ts +3 -0
  90. package/dist/extensions/first-party/promotion/normalize.js +37 -0
  91. package/dist/extensions/first-party/promotion/types/input.d.ts +10 -0
  92. package/dist/extensions/first-party/promotion/types/internal.d.ts +12 -0
  93. package/dist/extensions/first-party/promotion/types/internal.js +22 -0
  94. package/dist/extensions/first-party/promotion/types/main.d.ts +24 -0
  95. package/dist/extensions/first-party/promotion/types/main.js +2 -0
  96. package/dist/extensions/first-party/selected-square/factory.d.ts +1 -1
  97. package/dist/extensions/first-party/selected-square/factory.js +7 -7
  98. package/dist/extensions/first-party/selected-square/types.d.ts +2 -2
  99. package/dist/extensions/index.d.ts +8 -8
  100. package/dist/extensions/index.js +6 -6
  101. package/dist/extensions/invalidation/factory.d.ts +1 -1
  102. package/dist/extensions/types/basic/events.d.ts +10 -33
  103. package/dist/extensions/types/basic/events.js +9 -5
  104. package/dist/extensions/types/basic/interaction.d.ts +21 -0
  105. package/dist/extensions/types/basic/render.d.ts +2 -2
  106. package/dist/extensions/types/basic/transient-visuals.d.ts +3 -2
  107. package/dist/extensions/types/basic/update.d.ts +3 -3
  108. package/dist/extensions/types/context/animation.d.ts +3 -3
  109. package/dist/extensions/types/context/events.d.ts +5 -0
  110. package/dist/extensions/types/context/events.js +1 -0
  111. package/dist/extensions/types/context/render.d.ts +2 -2
  112. package/dist/extensions/types/context/transient-visuals.d.ts +2 -2
  113. package/dist/extensions/types/context/ui-move.d.ts +3 -15
  114. package/dist/extensions/types/context/update.d.ts +4 -4
  115. package/dist/extensions/types/context/update.js +1 -1
  116. package/dist/extensions/types/extension.d.ts +16 -14
  117. package/dist/extensions/types/main.d.ts +16 -11
  118. package/dist/extensions/types/surface/commands.d.ts +14 -5
  119. package/dist/extensions/types/surface/events.d.ts +2 -3
  120. package/dist/extensions/types/surface/main.d.ts +4 -4
  121. package/dist/extensions/types/wrapper.d.ts +23 -22
  122. package/dist/extensions/types/wrapper.js +34 -6
  123. package/dist/extensions/update.d.ts +3 -3
  124. package/dist/extensions/update.js +2 -2
  125. package/dist/index.d.ts +4 -4
  126. package/dist/index.js +1 -1
  127. package/dist/layout/factory.d.ts +1 -1
  128. package/dist/layout/factory.js +4 -4
  129. package/dist/layout/geometry/factory.d.ts +3 -12
  130. package/dist/layout/geometry/factory.js +17 -18
  131. package/dist/layout/geometry/helpers.d.ts +5 -0
  132. package/dist/layout/geometry/helpers.js +33 -0
  133. package/dist/layout/geometry/types.d.ts +14 -13
  134. package/dist/layout/helpers.d.ts +3 -4
  135. package/dist/layout/helpers.js +5 -5
  136. package/dist/layout/mutation.d.ts +1 -1
  137. package/dist/layout/reducers.d.ts +1 -1
  138. package/dist/layout/reducers.js +10 -9
  139. package/dist/layout/types.d.ts +7 -7
  140. package/dist/mutation/pipeline.d.ts +1 -1
  141. package/dist/mutation/pipeline.js +1 -1
  142. package/dist/mutation/session.d.ts +1 -1
  143. package/dist/render/factory.d.ts +1 -1
  144. package/dist/render/factory.js +7 -7
  145. package/dist/render/mount.d.ts +1 -1
  146. package/dist/render/mount.js +4 -4
  147. package/dist/render/rendering/animation.d.ts +1 -1
  148. package/dist/render/rendering/animation.js +1 -1
  149. package/dist/render/rendering/helpers.d.ts +1 -1
  150. package/dist/render/rendering/state.d.ts +2 -2
  151. package/dist/render/rendering/state.js +9 -9
  152. package/dist/render/rendering/visuals.d.ts +2 -2
  153. package/dist/render/rendering/visuals.js +1 -1
  154. package/dist/render/scheduler/scheduler.d.ts +1 -1
  155. package/dist/render/svg/factory.d.ts +2 -2
  156. package/dist/render/svg/factory.js +1 -1
  157. package/dist/render/svg/helpers.d.ts +1 -1
  158. package/dist/render/svg/helpers.js +1 -1
  159. package/dist/render/types.d.ts +5 -5
  160. package/dist/runtime/factory/events.d.ts +3 -0
  161. package/dist/runtime/factory/events.js +18 -0
  162. package/dist/runtime/factory/helpers.d.ts +2 -2
  163. package/dist/runtime/factory/helpers.js +14 -14
  164. package/dist/runtime/factory/input.d.ts +2 -2
  165. package/dist/runtime/factory/input.js +20 -13
  166. package/dist/runtime/factory/main.d.ts +1 -1
  167. package/dist/runtime/factory/main.js +56 -16
  168. package/dist/runtime/input/adapter/event.d.ts +3 -0
  169. package/dist/runtime/input/adapter/event.js +19 -0
  170. package/dist/runtime/input/adapter/factory.d.ts +1 -1
  171. package/dist/runtime/input/adapter/factory.js +19 -38
  172. package/dist/runtime/input/adapter/helpers.d.ts +3 -5
  173. package/dist/runtime/input/adapter/helpers.js +60 -12
  174. package/dist/runtime/input/adapter/pointer.d.ts +7 -11
  175. package/dist/runtime/input/adapter/pointer.js +37 -70
  176. package/dist/runtime/input/adapter/types.d.ts +7 -4
  177. package/dist/runtime/input/adapter/types.js +6 -1
  178. package/dist/runtime/input/controller/factory.d.ts +1 -1
  179. package/dist/runtime/input/controller/factory.js +13 -12
  180. package/dist/runtime/input/controller/helpers.d.ts +2 -2
  181. package/dist/runtime/input/controller/pointer.d.ts +6 -7
  182. package/dist/runtime/input/controller/pointer.js +39 -38
  183. package/dist/runtime/input/controller/transient-visuals.d.ts +3 -3
  184. package/dist/runtime/input/controller/transient-visuals.js +12 -5
  185. package/dist/runtime/input/controller/types.d.ts +8 -7
  186. package/dist/runtime/layout.d.ts +1 -1
  187. package/dist/runtime/layout.js +2 -2
  188. package/dist/runtime/lifecycle.d.ts +2 -2
  189. package/dist/runtime/lifecycle.js +8 -8
  190. package/dist/runtime/mutation/extension-update.d.ts +1 -1
  191. package/dist/runtime/mutation/factory.d.ts +1 -1
  192. package/dist/runtime/mutation/factory.js +6 -6
  193. package/dist/runtime/mutation/interaction.d.ts +1 -1
  194. package/dist/runtime/mutation/interaction.js +3 -7
  195. package/dist/runtime/mutation/invalidation.d.ts +1 -0
  196. package/dist/runtime/mutation/invalidation.js +1 -1
  197. package/dist/runtime/mutation/last-move.d.ts +1 -1
  198. package/dist/runtime/mutation/layout.d.ts +1 -1
  199. package/dist/runtime/mutation/pipeline.d.ts +6 -6
  200. package/dist/runtime/mutation/request-render.d.ts +1 -1
  201. package/dist/runtime/mutation/request-render.js +1 -1
  202. package/dist/runtime/mutation/run.d.ts +1 -1
  203. package/dist/runtime/mutation/types.d.ts +10 -8
  204. package/dist/runtime/types/main.d.ts +8 -6
  205. package/dist/state/board/check.d.ts +3 -3
  206. package/dist/state/board/check.js +1 -1
  207. package/dist/state/board/coords.d.ts +1 -1
  208. package/dist/state/board/denormalize.d.ts +3 -3
  209. package/dist/state/board/denormalize.js +4 -4
  210. package/dist/state/board/factory.d.ts +2 -2
  211. package/dist/state/board/factory.js +4 -4
  212. package/dist/state/board/mutation.d.ts +2 -2
  213. package/dist/state/board/normalize.d.ts +2 -2
  214. package/dist/state/board/normalize.js +2 -2
  215. package/dist/state/board/piece.d.ts +1 -1
  216. package/dist/state/board/position.d.ts +2 -2
  217. package/dist/state/board/position.js +2 -2
  218. package/dist/state/board/reducers.d.ts +2 -2
  219. package/dist/state/board/reducers.js +3 -3
  220. package/dist/state/board/types/input.d.ts +1 -1
  221. package/dist/state/board/types/internal.d.ts +1 -1
  222. package/dist/state/board/types/main.d.ts +3 -3
  223. package/dist/state/board/types/output.d.ts +2 -2
  224. package/dist/state/change/{factory.d.ts → factory/main.d.ts} +1 -1
  225. package/dist/state/change/{factory.js → factory/main.js} +8 -5
  226. package/dist/state/change/factory/ui-move.d.ts +4 -0
  227. package/dist/{runtime → state/change}/factory/ui-move.js +9 -9
  228. package/dist/state/change/helpers.d.ts +6 -4
  229. package/dist/state/change/helpers.js +12 -2
  230. package/dist/state/change/mutation.d.ts +2 -2
  231. package/dist/state/change/reducers.d.ts +4 -4
  232. package/dist/state/change/reducers.js +4 -4
  233. package/dist/state/change/types/main.d.ts +18 -0
  234. package/dist/state/change/types/main.js +1 -0
  235. package/dist/state/change/types/ui-move.d.ts +25 -0
  236. package/dist/state/change/types/ui-move.js +1 -0
  237. package/dist/state/factory.d.ts +1 -1
  238. package/dist/state/factory.js +4 -4
  239. package/dist/state/interaction/factory.d.ts +1 -1
  240. package/dist/state/interaction/factory.js +7 -5
  241. package/dist/state/interaction/helpers.d.ts +4 -2
  242. package/dist/state/interaction/helpers.js +5 -2
  243. package/dist/state/interaction/movability.d.ts +3 -3
  244. package/dist/state/interaction/movability.js +2 -2
  245. package/dist/state/interaction/mutation.d.ts +1 -1
  246. package/dist/state/interaction/normalize.d.ts +2 -2
  247. package/dist/state/interaction/normalize.js +2 -2
  248. package/dist/state/interaction/reducers.d.ts +3 -3
  249. package/dist/state/interaction/reducers.js +3 -3
  250. package/dist/state/interaction/types/input.d.ts +1 -1
  251. package/dist/state/interaction/types/internal.d.ts +10 -2
  252. package/dist/state/interaction/types/main.d.ts +4 -4
  253. package/dist/state/types.d.ts +6 -6
  254. package/dist/state/view/factory.d.ts +1 -1
  255. package/dist/state/view/factory.js +2 -2
  256. package/dist/state/view/mutation.d.ts +1 -1
  257. package/dist/state/view/reducers.d.ts +2 -2
  258. package/dist/state/view/types/internal.d.ts +1 -1
  259. package/dist/state/view/types/main.d.ts +4 -4
  260. package/dist/wrapper/factory.d.ts +2 -2
  261. package/dist/wrapper/factory.js +3 -27
  262. package/dist/wrapper/types.d.ts +4 -4
  263. package/package.json +9 -5
  264. package/dist/runtime/factory/ui-move.d.ts +0 -4
  265. package/dist/runtime/types/ui-move.d.ts +0 -9
  266. package/dist/state/change/types.d.ts +0 -17
  267. /package/dist/{runtime/types/ui-move.js → extensions/first-party/promotion/types/input.js} +0 -0
  268. /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 { RenderGeometry } from '../../layout/geometry/types';
3
- import type { AnimationTrackMove } from '../types';
4
- import type { PreparedMoveNode } from './types';
5
- export declare function prepareMoveTrack(track: AnimationTrackMove, geometry: RenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedMoveNode;
6
- export declare function renderMoveTrack(node: PreparedMoveNode, geometry: RenderGeometry, progress: number): void;
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.squareRect(track.fromSq);
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.size.toString(),
12
- height: r.size.toString()
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.squareRect(node.fromSq);
18
- const to = geometry.squareRect(node.toSq);
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 { RenderGeometry } from '../../layout/geometry/types';
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: RenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedNodeMap;
10
- export declare function renderAnimationPlan(nodes: PreparedNodeMap, geometry: RenderGeometry, progress: number): void;
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 { RenderGeometry } from '../../layout/geometry/types';
3
- import type { AnimationTrackStatic } from '../types';
4
- import type { PreparedStaticNode } from './types';
5
- export declare function prepareStaticTrack(track: AnimationTrackStatic, geometry: RenderGeometry, pieceUrls: PieceUrls, layer: SVGElement): PreparedStaticNode;
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.squareRect(track.sq);
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.size.toString(),
12
- height: r.size.toString()
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
- tracks: AnimationTrack[];
28
+ plan: AnimationPlan;
30
29
  startTime: number;
31
30
  duration: number;
32
31
  }
33
32
  export type AnimationSessionSnapshot = ReadonlyDeep<AnimationSession>;
34
- export interface AnimationTrackMoveExclude {
35
- fromSq: Square;
36
- toSq: Square;
33
+ export interface AnimationPlanningSnapshot {
34
+ readonly board: BoardStateSnapshot;
35
+ readonly change: ChangeStateSnapshot;
36
+ readonly interaction: InteractionStateSnapshot;
37
37
  }
38
- export interface AnimationTrackSquareExclude {
39
- sq: Square;
38
+ export interface AnimationPlanningInput {
39
+ previous: AnimationPlanningSnapshot;
40
+ current: AnimationPlanningSnapshot;
40
41
  }
41
- export type AnimationTrackExclude = AnimationTrackMoveExclude | AnimationTrackSquareExclude;
42
- export declare function isMoveExclude(e: AnimationTrackExclude): e is AnimationTrackMoveExclude;
43
- export declare function isSquareExclude(e: AnimationTrackExclude): e is AnimationTrackSquareExclude;
44
- export interface CalculateAnimationTracksOptions {
45
- exclude?: AnimationTrackExclude[];
42
+ export interface AnimationPlan {
43
+ readonly tracks: readonly AnimationTrack[];
44
+ readonly suppressedSquares: ReadonlySet<Square>;
46
45
  }
@@ -1,6 +1 @@
1
- export function isMoveExclude(e) {
2
- return 'fromSq' in e && 'toSq' in e;
3
- }
4
- export function isSquareExclude(e) {
5
- return 'sq' in e && !('fromSq' in e) && !('toSq' in e);
6
- }
1
+ export {};
@@ -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 { ANIMATION_SESSION_STATUS_ALL } from '../types/basic/animation';
1
+ import { ANIMATION_SESSION_STATUS_ALL } from '../types/basic/animation.js';
2
2
  function createExtensionAnimationSessionInternal(id, options) {
3
3
  return {
4
4
  id,
@@ -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 { createExtensionAnimationController } from '../animation/factory';
2
- import { createExtensionInvalidationState } from '../invalidation/factory';
3
- import { extensionSystemUpdateState, extensionSystemUpdateUIMoveRequest } from '../update';
4
- import { createExtensionRuntimeSurface } from './runtime';
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 type { ExtensionRuntimeSurface } from '../types/surface/main';
5
- export declare function createExtensionRuntimeSurface(getInternalState: GetInternalState, commands: ExtensionRuntimeSurfaceCommands, extensionDef: AnyExtensionDefinition): ExtensionRuntimeSurface;
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
- export function createExtensionRuntimeSurface(getInternalState, commands, extensionDef) {
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
- commands,
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.squareRect(square);
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.size.toString(),
68
- height: r.size.toString(),
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.size / 2;
75
- const centerY = r.y + r.size / 2;
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,2 @@
1
+ import { AutoPromoteDefinition } from './types.js';
2
+ export declare function createAutoPromote(): AutoPromoteDefinition;
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export const EXTENSION_SLOTS = [];
2
+ export const EXTENSION_ID = 'autoPromote';
@@ -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, extensionDestroy, extensionUnmount } from '../common/helpers';
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 extends ExtensionInternal<ExtensionSlotsType> {
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,5 +1,5 @@
1
1
  import assert from '@ktarmyshov/assert';
2
- import { clearElementChildren } from '../../../render/svg/helpers';
2
+ import { clearElementChildren } from '../../../render/svg/helpers.js';
3
3
  export function extensionCreateInternalBase() {
4
4
  return {
5
5
  slotRoots: null,
@@ -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.squareRect(fromSq);
61
- const rTo = geometry.squareRect(toSq);
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.size.toString(),
66
- height: rFrom.size.toString(),
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.size.toString(),
75
- height: rTo.size.toString(),
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";