@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,9 +1,9 @@
1
- import { createMutationPipeline } from '../../mutation/pipeline';
2
- import { extensionSystemUpdatePipe } from './extension-update';
3
- import { reconcileInteractionSelectionAfterBoardStateChange } from './interaction';
4
- import { clearLastMoveOnBoardSetPosition, updateLastMoveOnBoardMove } from './last-move';
5
- import { layoutRefreshGeometryPipe } from './layout';
6
- import { requestRenderPipe } from './request-render';
1
+ import { createMutationPipeline } from '../../mutation/pipeline.js';
2
+ import { extensionSystemUpdatePipe } from './extension-update.js';
3
+ import { reconcileInteractionSelectionAfterBoardStateChange } from './interaction.js';
4
+ import { clearLastMoveOnBoardSetPosition, updateLastMoveOnBoardMove } from './last-move.js';
5
+ import { layoutRefreshGeometryPipe } from './layout.js';
6
+ import { requestRenderPipe } from './request-render.js';
7
7
  function buildPreviousContext(current) {
8
8
  return {
9
9
  state: current.state.getSnapshot(),
@@ -1,2 +1,2 @@
1
- import { RuntimeMutationPipe } from './pipeline';
1
+ import { RuntimeMutationPipe } from './pipeline.js';
2
2
  export declare const reconcileInteractionSelectionAfterBoardStateChange: RuntimeMutationPipe;
@@ -1,14 +1,10 @@
1
- import { isEmptyPieceCode } from '../../state/board/check';
2
- import { selectedEqual } from '../../state/interaction/helpers';
1
+ import { isEmptyPieceCode } from '../../state/board/check.js';
2
+ import { selectedEqual } from '../../state/interaction/helpers.js';
3
3
  export const reconcileInteractionSelectionAfterBoardStateChange = (context, mutationSession) => {
4
4
  const { current } = context;
5
5
  if (!mutationSession.hasMutation({ prefixes: ['state.board.'] }) ||
6
6
  mutationSession.hasMutation({
7
- causes: [
8
- 'state.interaction.clear',
9
- 'runtime.interaction.dropTo',
10
- 'runtime.interaction.releaseTo'
11
- ]
7
+ causes: ['state.interaction.clear', 'runtime.interaction.completeDragTo']
12
8
  })) {
13
9
  return;
14
10
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";
1
+ export {};
2
2
  // TODO: Mark dirty layers based on upstream changes.
@@ -1,3 +1,3 @@
1
- import { RuntimeMutationPipe } from './pipeline';
1
+ import { RuntimeMutationPipe } from './pipeline.js';
2
2
  export declare const updateLastMoveOnBoardMove: RuntimeMutationPipe;
3
3
  export declare const clearLastMoveOnBoardSetPosition: RuntimeMutationPipe;
@@ -1,2 +1,2 @@
1
- import { RuntimeMutationPipe } from './pipeline';
1
+ import { RuntimeMutationPipe } from './pipeline.js';
2
2
  export declare const layoutRefreshGeometryPipe: RuntimeMutationPipe;
@@ -1,9 +1,9 @@
1
- import { ExtensionSystem } from '../../extensions/types/main';
2
- import { Layout, LayoutSnapshot } from '../../layout/types';
3
- import { MutationPipe, MutationPipeline } from '../../mutation/types';
4
- import { RenderSystem } from '../../render/types';
5
- import { RuntimeState, RuntimeStateSnapshot } from '../../state/types';
6
- import { RuntimeMutationPayloadByCause } from './types';
1
+ import { ExtensionSystem } from '../../extensions/types/main.js';
2
+ import { Layout, LayoutSnapshot } from '../../layout/types.js';
3
+ import { MutationPipe, MutationPipeline } from '../../mutation/types.js';
4
+ import { RenderSystem } from '../../render/types.js';
5
+ import { RuntimeState, RuntimeStateSnapshot } from '../../state/types.js';
6
+ import { RuntimeMutationPayloadByCause } from './types.js';
7
7
  export interface RuntimeMutationPipelineContext {
8
8
  readonly state: RuntimeState;
9
9
  readonly layout: Layout;
@@ -1,2 +1,2 @@
1
- import { RuntimeMutationPipe } from './pipeline';
1
+ import { RuntimeMutationPipe } from './pipeline.js';
2
2
  export declare const requestRenderPipe: RuntimeMutationPipe;
@@ -1,4 +1,4 @@
1
- import { isFrameRenderable } from '../../extensions/types/basic/update';
1
+ import { isFrameRenderable } from '../../extensions/types/basic/update.js';
2
2
  export const requestRenderPipe = (context) => {
3
3
  const { current } = context;
4
4
  const currentFrame = current.extensionSystem.currentFrame;
@@ -1,2 +1,2 @@
1
- import { RuntimeInternal } from '../types/main';
1
+ import { RuntimeInternal } from '../types/main.js';
2
2
  export declare function runtimeRunMutationPipeline(state: RuntimeInternal): boolean;
@@ -1,12 +1,14 @@
1
- import { LayoutMutationPayloadByCause } from '../../layout/mutation';
2
- import { MutationSession, ReadonlyMutationSession } from '../../mutation/types';
3
- import { BoardStateMutationPayloadByCause } from '../../state/board/mutation';
4
- import { ChangeStateMutationPayloadByCause } from '../../state/change/mutation';
5
- import { InteractionStateMutationPayloadByCause } from '../../state/interaction/mutation';
6
- import { ViewStateMutationPayloadByCause } from '../../state/view/mutation';
1
+ import type { LayoutMutationPayloadByCause } from '../../layout/mutation.js';
2
+ import type { MutationSession, ReadonlyMutationSession } from '../../mutation/types.js';
3
+ import type { BoardStateMutationPayloadByCause } from '../../state/board/mutation.js';
4
+ import type { ChangeStateMutationPayloadByCause } from '../../state/change/mutation.js';
5
+ import type { InteractionStateMutationPayloadByCause } from '../../state/interaction/mutation.js';
6
+ import type { DragSessionCoreOwnedSnapshot } from '../../state/interaction/types/internal.js';
7
+ import type { ViewStateMutationPayloadByCause } from '../../state/view/mutation.js';
7
8
  type RuntimeOwnMutationPayloadByCause = {
8
- 'runtime.interaction.dropTo': undefined;
9
- 'runtime.interaction.releaseTo': undefined;
9
+ 'runtime.interaction.completeDragTo': DragSessionCoreOwnedSnapshot;
10
+ 'runtime.interaction.resolveDeferredUIMoveRequest': undefined;
11
+ 'runtime.interaction.cancelDeferredUIMoveRequest': undefined;
10
12
  };
11
13
  export type RuntimeMutationPayloadByCause = BoardStateMutationPayloadByCause & ChangeStateMutationPayloadByCause & InteractionStateMutationPayloadByCause & ViewStateMutationPayloadByCause & LayoutMutationPayloadByCause & RuntimeOwnMutationPayloadByCause;
12
14
  export type RuntimeMutationSession = MutationSession<RuntimeMutationPayloadByCause>;
@@ -1,9 +1,10 @@
1
- import { AnyExtensionDefinition } from '../../extensions/types/extension';
2
- import { ExtensionRuntimeSurfaceCommands } from '../../extensions/types/surface/commands';
3
- import { RuntimeStateInitOptions } from '../../state/types';
4
- import { InputAdapter } from '../input/adapter/types';
5
- import { InteractionController } from '../input/controller/types';
6
- import { RuntimeMutationPipeline, RuntimeMutationPipelineContext } from '../mutation/pipeline';
1
+ import { AnyExtensionDefinition } from '../../extensions/types/extension.js';
2
+ import { ExtensionRuntimeSurfaceCommands } from '../../extensions/types/surface/commands.js';
3
+ import { ExtensionRuntimeSurfaceEvents } from '../../extensions/types/surface/events.js';
4
+ import { RuntimeStateInitOptions } from '../../state/types.js';
5
+ import { InputAdapter } from '../input/adapter/types.js';
6
+ import { InteractionController } from '../input/controller/types.js';
7
+ import { RuntimeMutationPipeline, RuntimeMutationPipelineContext } from '../mutation/pipeline.js';
7
8
  export type RuntimeStatus = 'constructing' | 'unmounted' | 'mounted' | 'destroyed';
8
9
  export interface RuntimeInternal extends RuntimeMutationPipelineContext {
9
10
  readonly mutation: RuntimeMutationPipeline;
@@ -19,6 +20,7 @@ export interface RuntimeInitOptions {
19
20
  }
20
21
  export interface RuntimeInitOptionsInternal extends RuntimeInitOptions {
21
22
  extensionRuntimeSurfaceCommands: ExtensionRuntimeSurfaceCommands;
23
+ extensionRuntimeSurfaceEvents: ExtensionRuntimeSurfaceEvents;
22
24
  getInternalState: GetInternalState;
23
25
  }
24
26
  /**
@@ -1,6 +1,6 @@
1
- import { Color, ColorShort, MoveRequestInput, Piece, PiecePositionInput, PiecePositionRecord, PiecePositionRecordShort, PiecePositionRecordString, PieceShort, PieceString, Role, RoleShort, SquareString } from './types/input';
2
- import { EmptyPieceCode, MoveRequest, NonEmptyPieceCode, PieceCode, RolePromotionCode, Square, SquareFile, SquareRank } from './types/internal';
3
- import { BoardStateSnapshot } from './types/main';
1
+ import { Color, ColorShort, MoveRequestInput, Piece, PiecePositionInput, PiecePositionRecord, PiecePositionRecordShort, PiecePositionRecordString, PieceShort, PieceString, Role, RoleShort, SquareString } from './types/input.js';
2
+ import { EmptyPieceCode, MoveRequest, NonEmptyPieceCode, PieceCode, RolePromotionCode, Square, SquareFile, SquareRank } from './types/internal.js';
3
+ import { BoardStateSnapshot } from './types/main.js';
4
4
  export declare function isWhitePieceCode(code: NonEmptyPieceCode): boolean;
5
5
  export declare function isBlackPieceCode(code: NonEmptyPieceCode): boolean;
6
6
  export declare function isOccupied(board: BoardStateSnapshot, sq: Square): boolean;
@@ -1,4 +1,4 @@
1
- import { SQUARE_COUNT } from './types/internal';
1
+ import { SQUARE_COUNT } from './types/internal.js';
2
2
  export function isWhitePieceCode(code) {
3
3
  return code > 0 /* PieceCode.Empty */ && code < 8 /* ColorCode.Black */;
4
4
  }
@@ -1,4 +1,4 @@
1
- import type { Square, SquareFile, SquareRank } from './types/internal';
1
+ import type { Square, SquareFile, SquareRank } from './types/internal.js';
2
2
  export declare function fileOf(sq: Square): SquareFile;
3
3
  export declare function rankOf(sq: Square): SquareRank;
4
4
  export declare function squareOf(file: SquareFile, rank: SquareRank): Square;
@@ -1,6 +1,6 @@
1
- import { ColorShort, PieceString, RolePromotionShort, RoleShort, SquareString } from './types/input';
2
- import { ColorCode, Move, MoveBase, MoveCaptured, NonEmptyPieceCode, RoleCode, RolePromotionCode, Square } from './types/internal';
3
- import { MoveBaseOutput, MoveCapturedOutput, MoveOutput } from './types/output';
1
+ import { ColorShort, PieceString, RolePromotionShort, RoleShort, SquareString } from './types/input.js';
2
+ import { ColorCode, Move, MoveBase, MoveCaptured, NonEmptyPieceCode, RoleCode, RolePromotionCode, Square } from './types/internal.js';
3
+ import { MoveBaseOutput, MoveCapturedOutput, MoveOutput } from './types/output.js';
4
4
  export declare function denormalizeSquare(sq: Square): SquareString;
5
5
  export declare function denormalizeColorShort(color: ColorCode): ColorShort;
6
6
  export declare function denormalizeRoleShort(role: RoleCode): RoleShort;
@@ -1,7 +1,7 @@
1
- import { isValidSquare } from './check';
2
- import { fileOf, rankOf } from './coords';
3
- import { fromPieceCode } from './piece';
4
- import { FILE_START, RANK_START } from './types/internal';
1
+ import { isValidSquare } from './check.js';
2
+ import { fileOf, rankOf } from './coords.js';
3
+ import { fromPieceCode } from './piece.js';
4
+ import { FILE_START, RANK_START } from './types/internal.js';
5
5
  export function denormalizeSquare(sq) {
6
6
  if (!isValidSquare(sq)) {
7
7
  throw new RangeError(`Invalid square index: ${sq}`);
@@ -1,3 +1,3 @@
1
- import { PositionInput } from './types/input';
2
- import { BoardState } from './types/main';
1
+ import { PositionInput } from './types/input.js';
2
+ import { BoardState } from './types/main.js';
3
3
  export declare function createBoardState(position?: PositionInput): BoardState;
@@ -1,8 +1,8 @@
1
1
  import { cloneDeep } from 'es-toolkit/object';
2
- import { isNormalizedMoveRequest } from './check';
3
- import { normalizeColor, normalizeMoveRequest } from './normalize';
4
- import { boardParsePiecePositionInput, boardParsePosition } from './position';
5
- import { boardMove, boardSetPosition, boardSetTurn } from './reducers';
2
+ import { isNormalizedMoveRequest } from './check.js';
3
+ import { normalizeColor, normalizeMoveRequest } from './normalize.js';
4
+ import { boardParsePiecePositionInput, boardParsePosition } from './position.js';
5
+ import { boardMove, boardSetPosition, boardSetTurn } from './reducers.js';
6
6
  function createBoardStateInternal(position) {
7
7
  const parsedPosition = boardParsePosition(position);
8
8
  return {
@@ -1,5 +1,5 @@
1
- import type { MutationSession } from '../../mutation/types';
2
- import type { MoveSnapshot } from './types/internal';
1
+ import type { MutationSession } from '../../mutation/types.js';
2
+ import type { MoveSnapshot } from './types/internal.js';
3
3
  export type BoardStateMutationPayloadByCause = {
4
4
  'state.board.setPosition': undefined;
5
5
  'state.board.setPiecePosition': undefined;
@@ -1,5 +1,5 @@
1
- import { ColorInput, MoveRequestInput, PieceInput, RoleInput, RolePromotionInput, SquareString } from './types/input';
2
- import { ColorCode, MoveRequest, PieceCode, RoleCode, RolePromotionCode, Square } from './types/internal';
1
+ import { ColorInput, MoveRequestInput, PieceInput, RoleInput, RolePromotionInput, SquareString } from './types/input.js';
2
+ import { ColorCode, MoveRequest, PieceCode, RoleCode, RolePromotionCode, Square } from './types/internal.js';
3
3
  export declare function normalizeColor(input: ColorInput): ColorCode;
4
4
  export declare function normalizeRole(input: RoleInput): RoleCode;
5
5
  export declare function normalizePiece(input: PieceInput): PieceCode;
@@ -1,5 +1,5 @@
1
- import { isPieceString, isRolePromotionCode, isValidSquare } from './check';
2
- import { FILE_START, RANK_START } from './types/internal';
1
+ import { isPieceString, isRolePromotionCode, isValidSquare } from './check.js';
2
+ import { FILE_START, RANK_START } from './types/internal.js';
3
3
  export function normalizeColor(input) {
4
4
  switch (input) {
5
5
  case 'white':
@@ -1,3 +1,3 @@
1
- import { ColorCode, NonEmptyPieceCode, PieceCode, PieceCoded, RoleCode } from './types/internal';
1
+ import { ColorCode, NonEmptyPieceCode, PieceCode, PieceCoded, RoleCode } from './types/internal.js';
2
2
  export declare function toPieceCode(role: RoleCode, color: ColorCode): PieceCode;
3
3
  export declare function fromPieceCode(code: NonEmptyPieceCode): PieceCoded;
@@ -1,4 +1,4 @@
1
- import { PiecePositionInput, PositionInput } from './types/input';
2
- import { ParsedPosition } from './types/internal';
1
+ import { PiecePositionInput, PositionInput } from './types/input.js';
2
+ import { ParsedPosition } from './types/internal.js';
3
3
  export declare function boardParsePiecePositionInput(input: PiecePositionInput): Uint8Array;
4
4
  export declare function boardParsePosition(input: PositionInput): ParsedPosition;
@@ -1,6 +1,6 @@
1
1
  import { parse } from '@echecs/fen';
2
- import { normalizeColor, normalizePiece, normalizeSquare } from './normalize';
3
- import { SQUARE_COUNT } from './types/internal';
2
+ import { normalizeColor, normalizePiece, normalizeSquare } from './normalize.js';
3
+ import { SQUARE_COUNT } from './types/internal.js';
4
4
  const START_POSITION_RECORD_STRING = {
5
5
  a1: 'wR',
6
6
  b1: 'wN',
@@ -1,5 +1,5 @@
1
- import { ColorCode, Move, MoveRequest } from './types/internal';
2
- import { BoardStateInternal } from './types/main';
1
+ import { ColorCode, Move, MoveRequest } from './types/internal.js';
2
+ import { BoardStateInternal } from './types/main.js';
3
3
  export declare function boardSetPosition(state: BoardStateInternal, pieces: Uint8Array): boolean;
4
4
  /**
5
5
  * Set active color turn.
@@ -1,6 +1,6 @@
1
- import { isEmptyPieceCode } from './check';
2
- import { denormalizeSquare } from './denormalize';
3
- import { fromPieceCode, toPieceCode } from './piece';
1
+ import { isEmptyPieceCode } from './check.js';
2
+ import { denormalizeSquare } from './denormalize.js';
3
+ import { fromPieceCode, toPieceCode } from './piece.js';
4
4
  export function boardSetPosition(state, pieces) {
5
5
  state.pieces = new Uint8Array(pieces);
6
6
  // Increment position epoch to prevent false animation across position resets
@@ -1,4 +1,4 @@
1
- import { TMoveRequest } from './template';
1
+ import { TMoveRequest } from './template.js';
2
2
  export type Color = 'white' | 'black';
3
3
  export type ColorShort = 'w' | 'b';
4
4
  export type ColorInput = Color | ColorShort;
@@ -1,5 +1,5 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
- import { TMove, TMoveBase, TMoveCaptured, TMoveRequest, TMoveRequestBase } from './template';
2
+ import { TMove, TMoveBase, TMoveCaptured, TMoveRequest, TMoveRequestBase } from './template.js';
3
3
  export type Square = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63;
4
4
  export declare const SQUARE_COUNT = 64;
5
5
  export type SquareFile = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
@@ -1,7 +1,7 @@
1
1
  import { ReadonlyDeep } from 'type-fest';
2
- import { BoardStateMutationSession } from '../mutation';
3
- import { ColorInput, MoveRequestInput, PiecePositionInput, PositionInput } from './input';
4
- import { ColorCode, Move, MoveRequest, PieceCode, Square } from './internal';
2
+ import { BoardStateMutationSession } from '../mutation.js';
3
+ import { ColorInput, MoveRequestInput, PiecePositionInput, PositionInput } from './input.js';
4
+ import { ColorCode, Move, MoveRequest, PieceCode, Square } from './internal.js';
5
5
  export interface BoardStateInternal {
6
6
  pieces: Uint8Array;
7
7
  turn: ColorCode;
@@ -1,5 +1,5 @@
1
- import { PieceString, RolePromotionShort, SquareString } from './input';
2
- import { TMove, TMoveBase, TMoveCaptured } from './template';
1
+ import { PieceString, RolePromotionShort, SquareString } from './input.js';
2
+ import { TMove, TMoveBase, TMoveCaptured } from './template.js';
3
3
  export type MoveBaseOutput = TMoveBase<SquareString, PieceString>;
4
4
  export type MoveCapturedOutput = TMoveCaptured<SquareString, PieceString>;
5
5
  export type MoveOutput = TMove<SquareString, PieceString, RolePromotionShort>;
@@ -1,2 +1,2 @@
1
- import type { ChangeState } from './types';
1
+ import { ChangeState } from '../types/main.js';
2
2
  export declare function createChangeState(): ChangeState;
@@ -1,9 +1,9 @@
1
1
  import { cloneDeep } from 'es-toolkit/object';
2
- import { changeStateSetDeferredUIMoveRequestContext, changeStateSetLastMove } from './reducers';
2
+ import { changeStateSetDeferredUIMoveRequest, changeStateSetLastMove } from '../reducers.js';
3
3
  function createChangeStateInternal() {
4
4
  return {
5
5
  lastMove: null,
6
- deferredUIMoveRequestContext: null
6
+ deferredUIMoveRequest: null
7
7
  };
8
8
  }
9
9
  export function createChangeState() {
@@ -12,17 +12,20 @@ export function createChangeState() {
12
12
  get lastMove() {
13
13
  return cloneDeep(internalState.lastMove);
14
14
  },
15
+ get deferredUIMoveRequest() {
16
+ return cloneDeep(internalState.deferredUIMoveRequest);
17
+ },
15
18
  setLastMove(move, mutationSession) {
16
19
  return mutationSession.addMutation('state.change.setLastMove', changeStateSetLastMove(internalState, move));
17
20
  },
18
21
  getSnapshot() {
19
22
  return {
20
23
  ...cloneDeep(internalState),
21
- deferredUIMoveRequestContext: internalState.deferredUIMoveRequestContext?.getSnapshot() ?? null
24
+ deferredUIMoveRequest: internalState.deferredUIMoveRequest?.getSnapshot() ?? null
22
25
  };
23
26
  },
24
- setDeferredUIMoveRequestContext(context, mutationSession) {
25
- return mutationSession.addMutation('state.change.setDeferredUIMoveRequestContext', changeStateSetDeferredUIMoveRequestContext(internalState, context));
27
+ setDeferredUIMoveRequest(request, mutationSession) {
28
+ return mutationSession.addMutation('state.change.setDeferredUIMoveRequest', changeStateSetDeferredUIMoveRequest(internalState, request));
26
29
  }
27
30
  };
28
31
  }
@@ -0,0 +1,4 @@
1
+ import { Square } from '../../board/types/internal.js';
2
+ import { MoveDestinationSnapshot } from '../../interaction/types/internal.js';
3
+ import { PendingUIMoveRequest } from '../types/ui-move.js';
4
+ export declare function createPendingUIMoveRequest(sourceSquare: Square, destination: MoveDestinationSnapshot): PendingUIMoveRequest;
@@ -1,4 +1,4 @@
1
- function createMoveRequestContextInternal(sourceSquare, destination) {
1
+ function createPendingUIMoveRequestInternal(sourceSquare, destination) {
2
2
  return {
3
3
  sourceSquare,
4
4
  destination,
@@ -6,7 +6,7 @@ function createMoveRequestContextInternal(sourceSquare, destination) {
6
6
  resolvedMoveRequest: null
7
7
  };
8
8
  }
9
- function moveRequestContextCanBeAutoResolved(state) {
9
+ function pendingUIMoveRequestCanBeAutoResolved(state) {
10
10
  return (state.status === 'unresolved' &&
11
11
  (state.destination.promotedTo === undefined || state.destination.promotedTo.length <= 1));
12
12
  }
@@ -21,11 +21,11 @@ function assertCanBeResolved(state) {
21
21
  }
22
22
  }
23
23
  function assertCanBeAutoResolved(state) {
24
- if (!moveRequestContextCanBeAutoResolved(state)) {
24
+ if (!pendingUIMoveRequestCanBeAutoResolved(state)) {
25
25
  throw new Error('Move request cannot be auto-resolved. Either it is already resolved or deferred, or it requires a promotion choice.');
26
26
  }
27
27
  }
28
- function moveRequestContextAutoResolve(state) {
28
+ function pendingUIMoveRequestAutoResolve(state) {
29
29
  assertCanBeAutoResolved(state);
30
30
  const promotedTo = state.destination.promotedTo?.length === 1 ? state.destination.promotedTo[0] : undefined;
31
31
  state.status = 'resolved';
@@ -41,8 +41,8 @@ function moveRequestContextAutoResolve(state) {
41
41
  ...(promotedTo !== undefined ? { promotedTo } : {})
42
42
  };
43
43
  }
44
- export function createUIMoveRequestContext(sourceSquare, destination) {
45
- const internalState = createMoveRequestContextInternal(sourceSquare, destination);
44
+ export function createPendingUIMoveRequest(sourceSquare, destination) {
45
+ const internalState = createPendingUIMoveRequestInternal(sourceSquare, destination);
46
46
  return {
47
47
  get status() {
48
48
  return internalState.status;
@@ -54,7 +54,7 @@ export function createUIMoveRequestContext(sourceSquare, destination) {
54
54
  return internalState.destination;
55
55
  },
56
56
  get canBeAutoResolved() {
57
- return moveRequestContextCanBeAutoResolved(internalState);
57
+ return pendingUIMoveRequestCanBeAutoResolved(internalState);
58
58
  },
59
59
  get resolvedMoveRequest() {
60
60
  return internalState.resolvedMoveRequest;
@@ -69,14 +69,14 @@ export function createUIMoveRequestContext(sourceSquare, destination) {
69
69
  internalState.resolvedMoveRequest = request;
70
70
  },
71
71
  autoresolve() {
72
- moveRequestContextAutoResolve(internalState);
72
+ pendingUIMoveRequestAutoResolve(internalState);
73
73
  },
74
74
  getSnapshot() {
75
75
  return {
76
76
  status: internalState.status,
77
77
  sourceSquare: internalState.sourceSquare,
78
78
  destination: internalState.destination,
79
- canBeAutoResolved: moveRequestContextCanBeAutoResolved(internalState),
79
+ canBeAutoResolved: pendingUIMoveRequestCanBeAutoResolved(internalState),
80
80
  resolvedMoveRequest: internalState.resolvedMoveRequest
81
81
  };
82
82
  }
@@ -1,8 +1,10 @@
1
- import { ExtensionUIMoveRequestContextSnapshot } from '../../extensions/types/context/ui-move';
2
- import type { MoveRequest, MoveRequestBase, MoveSnapshot } from '../board/types/internal';
3
- import { MoveDestinationSnapshot } from '../interaction/types/internal';
1
+ import type { MoveRequest, MoveRequestBase, MoveSnapshot } from '../board/types/internal.js';
2
+ import { MoveDestinationSnapshot } from '../interaction/types/internal.js';
3
+ import { ChangeStateSnapshot } from './types/main.js';
4
+ import { PendingUIMoveRequestSnapshot } from './types/ui-move.js';
4
5
  export declare function movesEqual(moveA: MoveSnapshot | null, moveB: MoveSnapshot | null): boolean;
5
6
  export declare function moveRequestBasesEqual(requestA: MoveRequestBase | null, requestB: MoveRequestBase | null): boolean;
6
7
  export declare function moveRequestsEqual(requestA: MoveRequest | null, requestB: MoveRequest | null): boolean;
7
8
  export declare function moveDestinationsEqual(destA: MoveDestinationSnapshot | null, destB: MoveDestinationSnapshot | null): boolean;
8
- export declare function uiMoveRequestContextsEqual(contextA: ExtensionUIMoveRequestContextSnapshot | null, contextB: ExtensionUIMoveRequestContextSnapshot | null): boolean;
9
+ export declare function pendingUIMoveRequestsEqual(contextA: PendingUIMoveRequestSnapshot | null, contextB: PendingUIMoveRequestSnapshot | null): boolean;
10
+ export declare function changeStatesEqual(stateA: ChangeStateSnapshot | null, stateB: ChangeStateSnapshot | null): boolean;
@@ -1,4 +1,4 @@
1
- import { setsEqual } from '../../helpers/util';
1
+ import { setsEqual } from '../../helpers/util.js';
2
2
  function baseMovesEqual(moveA, moveB) {
3
3
  const diffs = [
4
4
  moveA.from !== moveB.from,
@@ -69,7 +69,7 @@ export function moveDestinationsEqual(destA, destB) {
69
69
  setsEqual(new Set(destA.promotedTo ?? []), new Set(destB.promotedTo ?? [])) &&
70
70
  moveRequestBasesEqual(destA.secondary ?? null, destB.secondary ?? null));
71
71
  }
72
- export function uiMoveRequestContextsEqual(contextA, contextB) {
72
+ export function pendingUIMoveRequestsEqual(contextA, contextB) {
73
73
  if (contextA === null && contextB === null) {
74
74
  return true;
75
75
  }
@@ -84,3 +84,13 @@ export function uiMoveRequestContextsEqual(contextA, contextB) {
84
84
  contextA.canBeAutoResolved === contextB.canBeAutoResolved &&
85
85
  moveRequestsEqual(contextA.resolvedMoveRequest, contextB.resolvedMoveRequest));
86
86
  }
87
+ export function changeStatesEqual(stateA, stateB) {
88
+ if (stateA === null && stateB === null) {
89
+ return true;
90
+ }
91
+ if (stateA === null || stateB === null) {
92
+ return false;
93
+ }
94
+ return (pendingUIMoveRequestsEqual(stateA.deferredUIMoveRequest, stateB.deferredUIMoveRequest) &&
95
+ movesEqual(stateA.lastMove, stateB.lastMove));
96
+ }
@@ -1,6 +1,6 @@
1
- import type { MutationSession } from '../../mutation/types';
1
+ import type { MutationSession } from '../../mutation/types.js';
2
2
  export type ChangeStateMutationPayloadByCause = {
3
3
  'state.change.setLastMove': undefined;
4
- 'state.change.setDeferredUIMoveRequestContext': undefined;
4
+ 'state.change.setDeferredUIMoveRequest': undefined;
5
5
  };
6
6
  export type ChangeStateMutationSession = MutationSession<ChangeStateMutationPayloadByCause>;
@@ -1,5 +1,5 @@
1
- import { ExtensionUIMoveRequestContext } from '../../extensions/types/context/ui-move';
2
- import type { MoveSnapshot } from '../board/types/internal';
3
- import type { ChangeStateInternal } from './types';
1
+ import type { MoveSnapshot } from '../board/types/internal.js';
2
+ import { ChangeStateInternal } from './types/main.js';
3
+ import { PendingUIMoveRequest } from './types/ui-move.js';
4
4
  export declare function changeStateSetLastMove(state: ChangeStateInternal, move: MoveSnapshot | null): boolean;
5
- export declare function changeStateSetDeferredUIMoveRequestContext(state: ChangeStateInternal, context: ExtensionUIMoveRequestContext): boolean;
5
+ export declare function changeStateSetDeferredUIMoveRequest(state: ChangeStateInternal, request: PendingUIMoveRequest | null): boolean;
@@ -1,5 +1,5 @@
1
1
  import { cloneDeep } from 'es-toolkit/object';
2
- import { movesEqual, uiMoveRequestContextsEqual } from './helpers';
2
+ import { movesEqual, pendingUIMoveRequestsEqual } from './helpers.js';
3
3
  export function changeStateSetLastMove(state, move) {
4
4
  if (movesEqual(state.lastMove, move)) {
5
5
  return false; // No change
@@ -7,10 +7,10 @@ export function changeStateSetLastMove(state, move) {
7
7
  state.lastMove = cloneDeep(move);
8
8
  return true;
9
9
  }
10
- export function changeStateSetDeferredUIMoveRequestContext(state, context) {
11
- if (uiMoveRequestContextsEqual(state.deferredUIMoveRequestContext, context)) {
10
+ export function changeStateSetDeferredUIMoveRequest(state, request) {
11
+ if (pendingUIMoveRequestsEqual(state.deferredUIMoveRequest, request)) {
12
12
  return false; // No change
13
13
  }
14
- state.deferredUIMoveRequestContext = context;
14
+ state.deferredUIMoveRequest = request;
15
15
  return true;
16
16
  }
@@ -0,0 +1,18 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
2
+ import { MoveSnapshot } from '../../board/types/internal.js';
3
+ import type { ChangeStateMutationSession } from '../mutation.js';
4
+ import { PendingUIMoveRequest, PendingUIMoveRequestSnapshot } from './ui-move.js';
5
+ export interface ChangeStateInternal {
6
+ lastMove: MoveSnapshot | null;
7
+ deferredUIMoveRequest: PendingUIMoveRequest | null;
8
+ }
9
+ export type ChangeStateSnapshot = ReadonlyDeep<Omit<ChangeStateInternal, 'deferredUIMoveRequest'>> & {
10
+ deferredUIMoveRequest: PendingUIMoveRequestSnapshot | null;
11
+ };
12
+ export interface ChangeState {
13
+ readonly lastMove: MoveSnapshot | null;
14
+ readonly deferredUIMoveRequest: PendingUIMoveRequest | null;
15
+ setLastMove(move: MoveSnapshot | null, mutationSession: ChangeStateMutationSession): boolean;
16
+ setDeferredUIMoveRequest(request: PendingUIMoveRequest | null, mutationSession: ChangeStateMutationSession): boolean;
17
+ getSnapshot(): ChangeStateSnapshot;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { MoveRequest, RolePromotionCode, Square } from '../../board/types/internal.js';
2
+ import { MoveDestinationSnapshot } from '../../interaction/types/internal.js';
3
+ export type PendingUIMoveRequestStatus = 'unresolved' | 'deferred' | 'resolved';
4
+ export interface PendingUIMoveRequestSnapshot {
5
+ readonly status: PendingUIMoveRequestStatus;
6
+ readonly sourceSquare: Square;
7
+ readonly destination: MoveDestinationSnapshot;
8
+ readonly canBeAutoResolved: boolean;
9
+ readonly resolvedMoveRequest: MoveRequest | null;
10
+ }
11
+ export interface PendingUIMoveRequest extends PendingUIMoveRequestSnapshot {
12
+ defer(): void;
13
+ resolve(request: MoveRequest): void;
14
+ autoresolve(): void;
15
+ getSnapshot(): PendingUIMoveRequestSnapshot;
16
+ }
17
+ export interface PendingUIMoveRequestInternal {
18
+ readonly sourceSquare: Square;
19
+ readonly destination: MoveDestinationSnapshot;
20
+ status: PendingUIMoveRequestStatus;
21
+ resolvedMoveRequest: MoveRequest | null;
22
+ }
23
+ export interface DeferredUIMoveResolutionDetails {
24
+ readonly promotedTo: RolePromotionCode;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- import type { RuntimeState, RuntimeStateInitOptions } from './types';
1
+ import type { RuntimeState, RuntimeStateInitOptions } from './types.js';
2
2
  export declare function createRuntimeState(options: RuntimeStateInitOptions): RuntimeState;
@@ -1,7 +1,7 @@
1
- import { createBoardState } from './board/factory';
2
- import { createChangeState } from './change/factory';
3
- import { createInteractionState } from './interaction/factory';
4
- import { createViewState } from './view/factory';
1
+ import { createBoardState } from './board/factory.js';
2
+ import { createChangeState } from './change/factory/main.js';
3
+ import { createInteractionState } from './interaction/factory.js';
4
+ import { createViewState } from './view/factory.js';
5
5
  function createRuntimeStateInternal(options) {
6
6
  return {
7
7
  board: createBoardState(options.board ?? {}),
@@ -1,2 +1,2 @@
1
- import { InteractionState, InteractionStateInitOptions } from './types/main';
1
+ import { InteractionState, InteractionStateInitOptions } from './types/main.js';
2
2
  export declare function createInteractionState(options: InteractionStateInitOptions): InteractionState;