gigaboard 1.2.3

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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/dist/board-model-BvJOtwQ3.d.cts +675 -0
  4. package/dist/board-model-BvJOtwQ3.d.ts +675 -0
  5. package/dist/canvas.cjs +8 -0
  6. package/dist/canvas.cjs.map +1 -0
  7. package/dist/canvas.d.cts +14 -0
  8. package/dist/canvas.d.ts +14 -0
  9. package/dist/canvas.js +6 -0
  10. package/dist/canvas.js.map +1 -0
  11. package/dist/chunk-3HNIF4ZE.js +3 -0
  12. package/dist/chunk-3HNIF4ZE.js.map +1 -0
  13. package/dist/chunk-44YKPXXT.js +63 -0
  14. package/dist/chunk-44YKPXXT.js.map +1 -0
  15. package/dist/chunk-5WAOEWKS.js +16 -0
  16. package/dist/chunk-5WAOEWKS.js.map +1 -0
  17. package/dist/chunk-AYVQCHSG.cjs +10 -0
  18. package/dist/chunk-AYVQCHSG.cjs.map +1 -0
  19. package/dist/chunk-B26QLI2K.cjs +18 -0
  20. package/dist/chunk-B26QLI2K.cjs.map +1 -0
  21. package/dist/chunk-B2TBDDJN.cjs +10 -0
  22. package/dist/chunk-B2TBDDJN.cjs.map +1 -0
  23. package/dist/chunk-BFN5JI3T.js +8 -0
  24. package/dist/chunk-BFN5JI3T.js.map +1 -0
  25. package/dist/chunk-BWNBPN3P.cjs +10 -0
  26. package/dist/chunk-BWNBPN3P.cjs.map +1 -0
  27. package/dist/chunk-CXDGJMYL.js +105 -0
  28. package/dist/chunk-CXDGJMYL.js.map +1 -0
  29. package/dist/chunk-EOSX5UX3.js +8 -0
  30. package/dist/chunk-EOSX5UX3.js.map +1 -0
  31. package/dist/chunk-FNRS6YJI.cjs +67 -0
  32. package/dist/chunk-FNRS6YJI.cjs.map +1 -0
  33. package/dist/chunk-G6ZFOJZR.cjs +18 -0
  34. package/dist/chunk-G6ZFOJZR.cjs.map +1 -0
  35. package/dist/chunk-HSMILJKQ.cjs +18 -0
  36. package/dist/chunk-HSMILJKQ.cjs.map +1 -0
  37. package/dist/chunk-I4BQGFP5.cjs +113 -0
  38. package/dist/chunk-I4BQGFP5.cjs.map +1 -0
  39. package/dist/chunk-J6GGNP5S.js +1104 -0
  40. package/dist/chunk-J6GGNP5S.js.map +1 -0
  41. package/dist/chunk-JQSBAWIZ.cjs +4 -0
  42. package/dist/chunk-JQSBAWIZ.cjs.map +1 -0
  43. package/dist/chunk-KW56FEBY.js +8 -0
  44. package/dist/chunk-KW56FEBY.js.map +1 -0
  45. package/dist/chunk-N7ED2MZS.cjs +10 -0
  46. package/dist/chunk-N7ED2MZS.cjs.map +1 -0
  47. package/dist/chunk-NAA5O4BT.js +16 -0
  48. package/dist/chunk-NAA5O4BT.js.map +1 -0
  49. package/dist/chunk-OQLY5GJF.js +16 -0
  50. package/dist/chunk-OQLY5GJF.js.map +1 -0
  51. package/dist/chunk-P72B3YTG.js +16 -0
  52. package/dist/chunk-P72B3YTG.js.map +1 -0
  53. package/dist/chunk-U6WAD322.js +8 -0
  54. package/dist/chunk-U6WAD322.js.map +1 -0
  55. package/dist/chunk-UUTEFNFO.cjs +1148 -0
  56. package/dist/chunk-UUTEFNFO.cjs.map +1 -0
  57. package/dist/chunk-VYSVIIZA.cjs +18 -0
  58. package/dist/chunk-VYSVIIZA.cjs.map +1 -0
  59. package/dist/core.cjs +180 -0
  60. package/dist/core.cjs.map +1 -0
  61. package/dist/core.d.cts +164 -0
  62. package/dist/core.d.ts +164 -0
  63. package/dist/core.js +3 -0
  64. package/dist/core.js.map +1 -0
  65. package/dist/create-image-piece-set-BcmRKGql.d.cts +100 -0
  66. package/dist/create-image-piece-set-BcmRKGql.d.ts +100 -0
  67. package/dist/gigachess-3BDD--yT.d.cts +22 -0
  68. package/dist/gigachess-DolQlR82.d.ts +22 -0
  69. package/dist/index.cjs +2972 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.d.cts +435 -0
  72. package/dist/index.d.ts +435 -0
  73. package/dist/index.js +2898 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/pieces/alpha.cjs +13 -0
  76. package/dist/pieces/alpha.cjs.map +1 -0
  77. package/dist/pieces/alpha.d.cts +17 -0
  78. package/dist/pieces/alpha.d.ts +17 -0
  79. package/dist/pieces/alpha.js +4 -0
  80. package/dist/pieces/alpha.js.map +1 -0
  81. package/dist/pieces/cburnett.cjs +13 -0
  82. package/dist/pieces/cburnett.cjs.map +1 -0
  83. package/dist/pieces/cburnett.d.cts +19 -0
  84. package/dist/pieces/cburnett.d.ts +19 -0
  85. package/dist/pieces/cburnett.js +4 -0
  86. package/dist/pieces/cburnett.js.map +1 -0
  87. package/dist/pieces/chesscom.cjs +14 -0
  88. package/dist/pieces/chesscom.cjs.map +1 -0
  89. package/dist/pieces/chesscom.d.cts +3 -0
  90. package/dist/pieces/chesscom.d.ts +3 -0
  91. package/dist/pieces/chesscom.js +5 -0
  92. package/dist/pieces/chesscom.js.map +1 -0
  93. package/dist/pieces/merida.cjs +13 -0
  94. package/dist/pieces/merida.cjs.map +1 -0
  95. package/dist/pieces/merida.d.cts +17 -0
  96. package/dist/pieces/merida.d.ts +17 -0
  97. package/dist/pieces/merida.js +4 -0
  98. package/dist/pieces/merida.js.map +1 -0
  99. package/dist/pieces/neo.cjs +13 -0
  100. package/dist/pieces/neo.cjs.map +1 -0
  101. package/dist/pieces/neo.d.cts +18 -0
  102. package/dist/pieces/neo.d.ts +18 -0
  103. package/dist/pieces/neo.js +4 -0
  104. package/dist/pieces/neo.js.map +1 -0
  105. package/dist/pieces.cjs +55 -0
  106. package/dist/pieces.cjs.map +1 -0
  107. package/dist/pieces.d.cts +21 -0
  108. package/dist/pieces.d.ts +21 -0
  109. package/dist/pieces.js +24 -0
  110. package/dist/pieces.js.map +1 -0
  111. package/dist/server.cjs +207 -0
  112. package/dist/server.cjs.map +1 -0
  113. package/dist/server.d.cts +60 -0
  114. package/dist/server.d.ts +60 -0
  115. package/dist/server.js +205 -0
  116. package/dist/server.js.map +1 -0
  117. package/dist/sounds/capture.mp3 +0 -0
  118. package/dist/sounds/castle.mp3 +0 -0
  119. package/dist/sounds/game-end.mp3 +0 -0
  120. package/dist/sounds/move-check.mp3 +0 -0
  121. package/dist/sounds/move-opponent.mp3 +0 -0
  122. package/dist/sounds/move-self.mp3 +0 -0
  123. package/dist/sounds/promote.mp3 +0 -0
  124. package/dist/themes/blue.cjs +12 -0
  125. package/dist/themes/blue.cjs.map +1 -0
  126. package/dist/themes/blue.d.cts +102 -0
  127. package/dist/themes/blue.d.ts +102 -0
  128. package/dist/themes/blue.js +3 -0
  129. package/dist/themes/blue.js.map +1 -0
  130. package/dist/themes/brown.cjs +12 -0
  131. package/dist/themes/brown.cjs.map +1 -0
  132. package/dist/themes/brown.d.cts +1 -0
  133. package/dist/themes/brown.d.ts +1 -0
  134. package/dist/themes/brown.js +3 -0
  135. package/dist/themes/brown.js.map +1 -0
  136. package/dist/themes/green.cjs +12 -0
  137. package/dist/themes/green.cjs.map +1 -0
  138. package/dist/themes/green.d.cts +1 -0
  139. package/dist/themes/green.d.ts +1 -0
  140. package/dist/themes/green.js +3 -0
  141. package/dist/themes/green.js.map +1 -0
  142. package/dist/themes/wood.cjs +12 -0
  143. package/dist/themes/wood.cjs.map +1 -0
  144. package/dist/themes/wood.d.cts +1 -0
  145. package/dist/themes/wood.d.ts +1 -0
  146. package/dist/themes/wood.js +3 -0
  147. package/dist/themes/wood.js.map +1 -0
  148. package/dist/themes.cjs +36 -0
  149. package/dist/themes.cjs.map +1 -0
  150. package/dist/themes.d.cts +1 -0
  151. package/dist/themes.d.ts +1 -0
  152. package/dist/themes.js +21 -0
  153. package/dist/themes.js.map +1 -0
  154. package/dist/types-Bg2xiUHE.d.cts +501 -0
  155. package/dist/types-D5eBJGzj.d.ts +501 -0
  156. package/package.json +210 -0
@@ -0,0 +1,164 @@
1
+ export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-3BDD--yT.cjs';
2
+ import { c as colorOf, p as pieceTypeOf, P as PackedMove, S as SquareIndex, a as PieceType, A as AnimDescriptor, b as Arrow, d as Premove } from './board-model-BvJOtwQ3.cjs';
3
+ export { e as ArrowCustomSvg, f as ArrowLabel, B as BOARD_CELL_BB, g as BOARD_CELL_BK, h as BOARD_CELL_BN, i as BOARD_CELL_BP, j as BOARD_CELL_BQ, k as BOARD_CELL_BR, l as BOARD_CELL_EMPTY, m as BOARD_CELL_WB, n as BOARD_CELL_WK, o as BOARD_CELL_WN, q as BOARD_CELL_WP, r as BOARD_CELL_WQ, s as BOARD_CELL_WR, t as BoardCell, u as BoardModel, v as BoardModelOptions, w as BoardSnapshot, x as BoardStore, C as CancelEvent, y as ClickEvent, z as Color, D as DragController, F as DragControllerOptions, G as DragEvent, H as DragMoveEvent, I as DragStartEvent, J as DragState, K as DropEvent, E as EngineAdapter, L as LegalMoveEntry, M as LegalMoveIndex, N as LegalMoveIndexOptions, O as MOVE2_PROMO_BISHOP, Q as MOVE2_PROMO_KNIGHT, R as MOVE2_PROMO_NONE, T as MOVE2_PROMO_QUEEN, U as MOVE2_PROMO_ROOK, V as PositionHash, W as SyncPositionOptions, X as Unsubscribe, Z as ZobristKey, Y as createBoardModel, _ as createBoardStore, $ as createDragController, a0 as createLegalMoveIndex, a1 as encodeBoardCell, a2 as isEmptyCell, a3 as isSquareIndex, a4 as packMove, a5 as toSquareIndex, a6 as unpackMove, a7 as writeBoardCell } from './board-model-BvJOtwQ3.cjs';
4
+
5
+ /**
6
+ * Animation planner: diff two board snapshots and classify the change.
7
+ *
8
+ * The planner is called on every commit. Given `(prevBoard, nextBoard)` and
9
+ * optionally the packed `Move` that was played, it produces an
10
+ * `AnimDescriptor[]` describing what the UI should animate. The React layer
11
+ * feeds the descriptors into WAAPI (`element.animate(...)`) — the planner
12
+ * itself knows nothing about DOM, time, or easing.
13
+ *
14
+ * When the caller supplies the packed move we take the fast path: the kind,
15
+ * source, target, capture, promotion are all encoded in 16 bits. When no
16
+ * move is available (e.g. `load(fen)`, `reset()`, `redo()` of an arbitrary
17
+ * history entry), we fall back to a byte-level diff and classify
18
+ * conservatively as `appear` / `disappear`.
19
+ */
20
+
21
+ /**
22
+ * Plan animations for the transition `prev → next`.
23
+ *
24
+ * @param prev Previous board bytes (length 64).
25
+ * @param next New board bytes (length 64).
26
+ * @param move Optional packed move that caused the transition. Enables the
27
+ * fast path; without it the planner falls back to a byte-level diff.
28
+ */
29
+ declare function planAnimations(prev: Readonly<Uint8Array>, next: Readonly<Uint8Array>, move: PackedMove | null): AnimDescriptor[];
30
+ /**
31
+ * Lightweight, side-effect-free inspector. Used by tests to decompose a
32
+ * packed move without pulling an engine as a runtime dep.
33
+ */
34
+ declare function decodePackedMove(m: PackedMove): {
35
+ from: SquareIndex;
36
+ to: SquareIndex;
37
+ kind: "normal" | "promotion" | "en-passant" | "castle";
38
+ promotion: PieceType | null;
39
+ };
40
+ /**
41
+ * Expose colour / piece-type extraction from a `BoardCell` without re-importing
42
+ * `types.ts`. Used by the React layer when it needs to know "is this white's
43
+ * pawn?" cheaply.
44
+ */
45
+ declare const animationInspect: {
46
+ colorOf: typeof colorOf;
47
+ pieceTypeOf: typeof pieceTypeOf;
48
+ Color: {
49
+ readonly White: 0;
50
+ readonly Black: 1;
51
+ };
52
+ PieceType: {
53
+ readonly Pawn: 0;
54
+ readonly Knight: 1;
55
+ readonly Bishop: 2;
56
+ readonly Rook: 3;
57
+ readonly Queen: 4;
58
+ readonly King: 5;
59
+ };
60
+ };
61
+
62
+ /**
63
+ * Arrow set with stable identity by `(from, to, color)`.
64
+ *
65
+ * The model is intentionally tiny: it owns nothing the UI cares about (colors,
66
+ * hit-tests, rendering) beyond the three identifying fields. The renderer is
67
+ * responsible for drawing; the model is responsible for *which arrows exist*.
68
+ */
69
+
70
+ /** The arrow-set API. */
71
+ interface ArrowModel {
72
+ /** Current set of arrows, oldest first, as a frozen snapshot. */
73
+ readonly arrows: readonly Arrow[];
74
+ /** `true` if an arrow with the same `(from, to, color)` is present. */
75
+ has(arrow: Arrow): boolean;
76
+ /** Add an arrow. No-op if an identical one already exists. */
77
+ add(arrow: Arrow): void;
78
+ /** Remove an arrow. No-op if it isn't present. */
79
+ remove(arrow: Arrow): void;
80
+ /**
81
+ * Convenience: remove if present, add if not. Returns the new presence
82
+ * (`true` if the arrow is in the set after the call).
83
+ */
84
+ toggle(arrow: Arrow): boolean;
85
+ /** Drop every arrow, managed or not. */
86
+ clear(): void;
87
+ /**
88
+ * Drop only **user-drawn** arrows (anything without `managed: true`).
89
+ *
90
+ * Used by the board's reflex-clearing hooks (`clearArrowsOnClick`,
91
+ * `clearArrowsOnMove`) so engine / app-owned annotations survive the
92
+ * user's click-to-dismiss gesture. Reports `lastChanged` like every
93
+ * other mutator.
94
+ */
95
+ clearUser(): void;
96
+ /** Drop only **managed** arrows (those with `managed: true`). */
97
+ clearManaged(): void;
98
+ /**
99
+ * Atomic replace of the **managed** subset. User-drawn arrows are
100
+ * untouched. Every incoming arrow is stamped `managed: true` — callers
101
+ * don't have to set the flag explicitly, and the method's name carries
102
+ * the intent. Identity preservation works the same way as
103
+ * {@link setAll}: arrows whose identity key already exists are reused
104
+ * from the stored frozen instances so consumer `Object.is` checks stay
105
+ * cheap across commits.
106
+ */
107
+ setManaged(arrows: readonly Arrow[]): void;
108
+ /**
109
+ * Replace the entire arrow set in one atomic step. Preserves identity
110
+ * for arrows whose `(from, to, color)` tuple was already present —
111
+ * freshly-provided arrows are frozen and keyed; removed ones are
112
+ * dropped. Single `lastChanged` flag covers the whole batch.
113
+ */
114
+ setAll(arrows: readonly Arrow[]): void;
115
+ /** Whether the last call actually changed the state. */
116
+ readonly lastChanged: boolean;
117
+ }
118
+ /** Create an empty arrow model. */
119
+ declare function createArrowModel(): ArrowModel;
120
+ /** Helper: build a frozen `Arrow` literal. Validates branded types in dev. */
121
+ declare function makeArrow(from: SquareIndex, to: SquareIndex, color: string): Arrow;
122
+
123
+ /**
124
+ * Premove queue.
125
+ *
126
+ * When it isn't our turn and we drag a piece to a target, the intended move
127
+ * is queued as a `Premove`. After the opponent replies, the board model
128
+ * attempts to apply queued premoves in order; each one that is now legal
129
+ * plays, and on the first illegal premove the queue is cleared (standard
130
+ * lichess/chess.com behaviour — a busted premove discards everything after
131
+ * it too).
132
+ */
133
+
134
+ /** Premove queue API. */
135
+ interface PremoveBuffer {
136
+ /** FIFO snapshot of the current queue. */
137
+ readonly all: readonly Premove[];
138
+ /** The premove at the head of the queue, or `undefined` if empty. */
139
+ peek(): Premove | undefined;
140
+ /** Append a premove. */
141
+ push(premove: Premove): void;
142
+ /** Remove and return the head premove, or `undefined` if empty. */
143
+ shift(): Premove | undefined;
144
+ /** Drop every premove. */
145
+ clear(): void;
146
+ /** Current queue length. */
147
+ readonly length: number;
148
+ }
149
+ /** Create an empty premove buffer. */
150
+ declare function createPremoveBuffer(): PremoveBuffer;
151
+ /** Helper: build a frozen `Premove` literal with safe optional handling. */
152
+ declare function makePremove(from: SquareIndex, to: SquareIndex, promotion?: PieceType): Premove;
153
+
154
+ /**
155
+ * `gigaboard/core` — framework-agnostic state machine for Gigaboard.
156
+ *
157
+ * Zero React, zero DOM. This barrel is hand-curated; sub-modules are never
158
+ * re-exported wholesale so consumers can tree-shake aggressively.
159
+ */
160
+
161
+ /** Package version. Baked in at build time by the consumer's bundler. */
162
+ declare const PACKAGE_VERSION = "0.1.0-alpha";
163
+
164
+ export { AnimDescriptor, Arrow, type ArrowModel, PACKAGE_VERSION, PackedMove, PieceType, Premove, type PremoveBuffer, SquareIndex, animationInspect, colorOf, createArrowModel, createPremoveBuffer, decodePackedMove, makeArrow, makePremove, pieceTypeOf, planAnimations };
package/dist/core.d.ts ADDED
@@ -0,0 +1,164 @@
1
+ export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-DolQlR82.js';
2
+ import { c as colorOf, p as pieceTypeOf, P as PackedMove, S as SquareIndex, a as PieceType, A as AnimDescriptor, b as Arrow, d as Premove } from './board-model-BvJOtwQ3.js';
3
+ export { e as ArrowCustomSvg, f as ArrowLabel, B as BOARD_CELL_BB, g as BOARD_CELL_BK, h as BOARD_CELL_BN, i as BOARD_CELL_BP, j as BOARD_CELL_BQ, k as BOARD_CELL_BR, l as BOARD_CELL_EMPTY, m as BOARD_CELL_WB, n as BOARD_CELL_WK, o as BOARD_CELL_WN, q as BOARD_CELL_WP, r as BOARD_CELL_WQ, s as BOARD_CELL_WR, t as BoardCell, u as BoardModel, v as BoardModelOptions, w as BoardSnapshot, x as BoardStore, C as CancelEvent, y as ClickEvent, z as Color, D as DragController, F as DragControllerOptions, G as DragEvent, H as DragMoveEvent, I as DragStartEvent, J as DragState, K as DropEvent, E as EngineAdapter, L as LegalMoveEntry, M as LegalMoveIndex, N as LegalMoveIndexOptions, O as MOVE2_PROMO_BISHOP, Q as MOVE2_PROMO_KNIGHT, R as MOVE2_PROMO_NONE, T as MOVE2_PROMO_QUEEN, U as MOVE2_PROMO_ROOK, V as PositionHash, W as SyncPositionOptions, X as Unsubscribe, Z as ZobristKey, Y as createBoardModel, _ as createBoardStore, $ as createDragController, a0 as createLegalMoveIndex, a1 as encodeBoardCell, a2 as isEmptyCell, a3 as isSquareIndex, a4 as packMove, a5 as toSquareIndex, a6 as unpackMove, a7 as writeBoardCell } from './board-model-BvJOtwQ3.js';
4
+
5
+ /**
6
+ * Animation planner: diff two board snapshots and classify the change.
7
+ *
8
+ * The planner is called on every commit. Given `(prevBoard, nextBoard)` and
9
+ * optionally the packed `Move` that was played, it produces an
10
+ * `AnimDescriptor[]` describing what the UI should animate. The React layer
11
+ * feeds the descriptors into WAAPI (`element.animate(...)`) — the planner
12
+ * itself knows nothing about DOM, time, or easing.
13
+ *
14
+ * When the caller supplies the packed move we take the fast path: the kind,
15
+ * source, target, capture, promotion are all encoded in 16 bits. When no
16
+ * move is available (e.g. `load(fen)`, `reset()`, `redo()` of an arbitrary
17
+ * history entry), we fall back to a byte-level diff and classify
18
+ * conservatively as `appear` / `disappear`.
19
+ */
20
+
21
+ /**
22
+ * Plan animations for the transition `prev → next`.
23
+ *
24
+ * @param prev Previous board bytes (length 64).
25
+ * @param next New board bytes (length 64).
26
+ * @param move Optional packed move that caused the transition. Enables the
27
+ * fast path; without it the planner falls back to a byte-level diff.
28
+ */
29
+ declare function planAnimations(prev: Readonly<Uint8Array>, next: Readonly<Uint8Array>, move: PackedMove | null): AnimDescriptor[];
30
+ /**
31
+ * Lightweight, side-effect-free inspector. Used by tests to decompose a
32
+ * packed move without pulling an engine as a runtime dep.
33
+ */
34
+ declare function decodePackedMove(m: PackedMove): {
35
+ from: SquareIndex;
36
+ to: SquareIndex;
37
+ kind: "normal" | "promotion" | "en-passant" | "castle";
38
+ promotion: PieceType | null;
39
+ };
40
+ /**
41
+ * Expose colour / piece-type extraction from a `BoardCell` without re-importing
42
+ * `types.ts`. Used by the React layer when it needs to know "is this white's
43
+ * pawn?" cheaply.
44
+ */
45
+ declare const animationInspect: {
46
+ colorOf: typeof colorOf;
47
+ pieceTypeOf: typeof pieceTypeOf;
48
+ Color: {
49
+ readonly White: 0;
50
+ readonly Black: 1;
51
+ };
52
+ PieceType: {
53
+ readonly Pawn: 0;
54
+ readonly Knight: 1;
55
+ readonly Bishop: 2;
56
+ readonly Rook: 3;
57
+ readonly Queen: 4;
58
+ readonly King: 5;
59
+ };
60
+ };
61
+
62
+ /**
63
+ * Arrow set with stable identity by `(from, to, color)`.
64
+ *
65
+ * The model is intentionally tiny: it owns nothing the UI cares about (colors,
66
+ * hit-tests, rendering) beyond the three identifying fields. The renderer is
67
+ * responsible for drawing; the model is responsible for *which arrows exist*.
68
+ */
69
+
70
+ /** The arrow-set API. */
71
+ interface ArrowModel {
72
+ /** Current set of arrows, oldest first, as a frozen snapshot. */
73
+ readonly arrows: readonly Arrow[];
74
+ /** `true` if an arrow with the same `(from, to, color)` is present. */
75
+ has(arrow: Arrow): boolean;
76
+ /** Add an arrow. No-op if an identical one already exists. */
77
+ add(arrow: Arrow): void;
78
+ /** Remove an arrow. No-op if it isn't present. */
79
+ remove(arrow: Arrow): void;
80
+ /**
81
+ * Convenience: remove if present, add if not. Returns the new presence
82
+ * (`true` if the arrow is in the set after the call).
83
+ */
84
+ toggle(arrow: Arrow): boolean;
85
+ /** Drop every arrow, managed or not. */
86
+ clear(): void;
87
+ /**
88
+ * Drop only **user-drawn** arrows (anything without `managed: true`).
89
+ *
90
+ * Used by the board's reflex-clearing hooks (`clearArrowsOnClick`,
91
+ * `clearArrowsOnMove`) so engine / app-owned annotations survive the
92
+ * user's click-to-dismiss gesture. Reports `lastChanged` like every
93
+ * other mutator.
94
+ */
95
+ clearUser(): void;
96
+ /** Drop only **managed** arrows (those with `managed: true`). */
97
+ clearManaged(): void;
98
+ /**
99
+ * Atomic replace of the **managed** subset. User-drawn arrows are
100
+ * untouched. Every incoming arrow is stamped `managed: true` — callers
101
+ * don't have to set the flag explicitly, and the method's name carries
102
+ * the intent. Identity preservation works the same way as
103
+ * {@link setAll}: arrows whose identity key already exists are reused
104
+ * from the stored frozen instances so consumer `Object.is` checks stay
105
+ * cheap across commits.
106
+ */
107
+ setManaged(arrows: readonly Arrow[]): void;
108
+ /**
109
+ * Replace the entire arrow set in one atomic step. Preserves identity
110
+ * for arrows whose `(from, to, color)` tuple was already present —
111
+ * freshly-provided arrows are frozen and keyed; removed ones are
112
+ * dropped. Single `lastChanged` flag covers the whole batch.
113
+ */
114
+ setAll(arrows: readonly Arrow[]): void;
115
+ /** Whether the last call actually changed the state. */
116
+ readonly lastChanged: boolean;
117
+ }
118
+ /** Create an empty arrow model. */
119
+ declare function createArrowModel(): ArrowModel;
120
+ /** Helper: build a frozen `Arrow` literal. Validates branded types in dev. */
121
+ declare function makeArrow(from: SquareIndex, to: SquareIndex, color: string): Arrow;
122
+
123
+ /**
124
+ * Premove queue.
125
+ *
126
+ * When it isn't our turn and we drag a piece to a target, the intended move
127
+ * is queued as a `Premove`. After the opponent replies, the board model
128
+ * attempts to apply queued premoves in order; each one that is now legal
129
+ * plays, and on the first illegal premove the queue is cleared (standard
130
+ * lichess/chess.com behaviour — a busted premove discards everything after
131
+ * it too).
132
+ */
133
+
134
+ /** Premove queue API. */
135
+ interface PremoveBuffer {
136
+ /** FIFO snapshot of the current queue. */
137
+ readonly all: readonly Premove[];
138
+ /** The premove at the head of the queue, or `undefined` if empty. */
139
+ peek(): Premove | undefined;
140
+ /** Append a premove. */
141
+ push(premove: Premove): void;
142
+ /** Remove and return the head premove, or `undefined` if empty. */
143
+ shift(): Premove | undefined;
144
+ /** Drop every premove. */
145
+ clear(): void;
146
+ /** Current queue length. */
147
+ readonly length: number;
148
+ }
149
+ /** Create an empty premove buffer. */
150
+ declare function createPremoveBuffer(): PremoveBuffer;
151
+ /** Helper: build a frozen `Premove` literal with safe optional handling. */
152
+ declare function makePremove(from: SquareIndex, to: SquareIndex, promotion?: PieceType): Premove;
153
+
154
+ /**
155
+ * `gigaboard/core` — framework-agnostic state machine for Gigaboard.
156
+ *
157
+ * Zero React, zero DOM. This barrel is hand-curated; sub-modules are never
158
+ * re-exported wholesale so consumers can tree-shake aggressively.
159
+ */
160
+
161
+ /** Package version. Baked in at build time by the consumer's bundler. */
162
+ declare const PACKAGE_VERSION = "0.1.0-alpha";
163
+
164
+ export { AnimDescriptor, Arrow, type ArrowModel, PACKAGE_VERSION, PackedMove, PieceType, Premove, type PremoveBuffer, SquareIndex, animationInspect, colorOf, createArrowModel, createPremoveBuffer, decodePackedMove, makeArrow, makePremove, pieceTypeOf, planAnimations };
package/dist/core.js ADDED
@@ -0,0 +1,3 @@
1
+ export { BOARD_CELL_BB, BOARD_CELL_BK, BOARD_CELL_BN, BOARD_CELL_BP, BOARD_CELL_BQ, BOARD_CELL_BR, BOARD_CELL_EMPTY, BOARD_CELL_WB, BOARD_CELL_WK, BOARD_CELL_WN, BOARD_CELL_WP, BOARD_CELL_WQ, BOARD_CELL_WR, Color, MOVE2_PROMO_BISHOP, MOVE2_PROMO_KNIGHT, MOVE2_PROMO_NONE, MOVE2_PROMO_QUEEN, MOVE2_PROMO_ROOK, PACKAGE_VERSION, PieceType, animationInspect, colorOf, createArrowModel, createBoardModel, createBoardStore, createDragController, createGigachessAdapter, createLegalMoveIndex, createPremoveBuffer, decodePackedMove, encodeBoardCell, isEmptyCell, isSquareIndex, makeArrow, makePremove, packMove, pieceTypeOf, planAnimations, preloadGigachessAdapter, toSquareIndex, unpackMove, writeBoardCell } from './chunk-J6GGNP5S.js';
2
+ //# sourceMappingURL=core.js.map
3
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"core.js"}
@@ -0,0 +1,100 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ /**
4
+ * Shared piece-renderer factory.
5
+ *
6
+ * Every piece set shipped by `gigaboard/pieces` is a URL-based set — a
7
+ * thin map from board-cell → image URL. This factory builds a memoised
8
+ * {@link PieceRenderer} around such a map, so every set file is two lines
9
+ * of configuration plus a URL table.
10
+ *
11
+ * ### Why images, not inline SVG?
12
+ *
13
+ * The React packages target <15 KB gzip. Shipping 12 detailed SVG paths
14
+ * per set × 4 sets would blow that budget immediately. URL-based sets
15
+ * push the bytes onto the browser's image cache, where the pieces are
16
+ * decoded exactly once per session and shared across every board.
17
+ *
18
+ * ### Render cost
19
+ *
20
+ * One `<img>` per occupied square. The image is `pointer-events: none`
21
+ * so it never intercepts drag/click; the piece layer on the board owns
22
+ * hit testing. Each renderer is pure and does not allocate on the hot
23
+ * path — the URL lookup is a constant-time array read.
24
+ */
25
+
26
+ /** Shape a consumer's `PieceRenderer` prop expects. */
27
+ type PieceRenderer = (args: {
28
+ readonly cell: number;
29
+ readonly square: number;
30
+ }) => ReactNode;
31
+ /**
32
+ * 12-entry URL table, indexed by board cell `1..12`. Cell `0` is the
33
+ * empty square and is never looked up. Use {@link BOARD_CELL_KEY} to
34
+ * remember which index maps to which piece.
35
+ */
36
+ type PieceUrlTable = Readonly<{
37
+ /** white pawn (cell 1) */ 1: string;
38
+ /** white knight (cell 2) */ 2: string;
39
+ /** white bishop (cell 3) */ 3: string;
40
+ /** white rook (cell 4) */ 4: string;
41
+ /** white queen (cell 5) */ 5: string;
42
+ /** white king (cell 6) */ 6: string;
43
+ /** black pawn (cell 7) */ 7: string;
44
+ /** black knight (cell 8) */ 8: string;
45
+ /** black bishop (cell 9) */ 9: string;
46
+ /** black rook (cell 10) */ 10: string;
47
+ /** black queen (cell 11) */ 11: string;
48
+ /** black king (cell 12) */ 12: string;
49
+ }>;
50
+ /** Readable cell labels for the table — useful for callers building sets. */
51
+ declare const BOARD_CELL_KEY: Readonly<{
52
+ readonly wP: 1;
53
+ readonly wN: 2;
54
+ readonly wB: 3;
55
+ readonly wR: 4;
56
+ readonly wQ: 5;
57
+ readonly wK: 6;
58
+ readonly bP: 7;
59
+ readonly bN: 8;
60
+ readonly bB: 9;
61
+ readonly bR: 10;
62
+ readonly bQ: 11;
63
+ readonly bK: 12;
64
+ }>;
65
+ /**
66
+ * Build a {@link PieceRenderer} backed by a URL table. The returned
67
+ * function is referentially stable AND allocates **zero** React elements
68
+ * on the hot path: we pre-materialise one `<img>` element per piece
69
+ * code at factory time and hand out the same element for every call with
70
+ * the same cell.
71
+ *
72
+ * Why pre-materialise? The renderer is called inside `<PieceSlot/>` on
73
+ * every move that touches its square. Returning a fresh React element
74
+ * per call means React's reconciler has to shallow-diff the new element
75
+ * against the last one to decide whether DOM changed. A pool of 12
76
+ * frozen elements (one per piece code) bypasses that entirely — React
77
+ * short-circuits on identity.
78
+ */
79
+ declare function createImagePieceSet(urls: PieceUrlTable): PieceRenderer;
80
+ /**
81
+ * Helper that builds a chess.com-style PNG CDN URL for a given piece style.
82
+ *
83
+ * chess.com serves piece artwork at:
84
+ * `https://images.chesscomfiles.com/chess-themes/pieces/<style>/<size>/<colorPiece>.png`
85
+ *
86
+ * where `colorPiece` is one of `wp wn wb wr wq wk bp bn bb br bq bk`. The
87
+ * `size` options are `150` (default), `300`, etc. We pin to 150 by default
88
+ * because boards render at roughly that density on desktop, and larger
89
+ * sizes inflate page weight without perceptible benefit.
90
+ *
91
+ * @param style chess.com piece-style slug. Known values include `neo`
92
+ * (chess.com's default), `alpha`, `bases`, `cases`, `classic`,
93
+ * `club`, `condal`, `graffiti`, `leipzig`, `marble`, `maya`,
94
+ * `metal`, `modern`, `nature`, `neo_wood`, `newspaper`, `ocean`,
95
+ * `sky`, `space`, `tournament`, `vintage`, `wood`.
96
+ * @param size One of chess.com's supported pixel sizes (default 150).
97
+ */
98
+ declare function chesscomPieceUrls(style: string, size?: 150 | 300): PieceUrlTable;
99
+
100
+ export { BOARD_CELL_KEY as B, type PieceRenderer as P, type PieceUrlTable as a, createImagePieceSet as b, chesscomPieceUrls as c };
@@ -0,0 +1,100 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ /**
4
+ * Shared piece-renderer factory.
5
+ *
6
+ * Every piece set shipped by `gigaboard/pieces` is a URL-based set — a
7
+ * thin map from board-cell → image URL. This factory builds a memoised
8
+ * {@link PieceRenderer} around such a map, so every set file is two lines
9
+ * of configuration plus a URL table.
10
+ *
11
+ * ### Why images, not inline SVG?
12
+ *
13
+ * The React packages target <15 KB gzip. Shipping 12 detailed SVG paths
14
+ * per set × 4 sets would blow that budget immediately. URL-based sets
15
+ * push the bytes onto the browser's image cache, where the pieces are
16
+ * decoded exactly once per session and shared across every board.
17
+ *
18
+ * ### Render cost
19
+ *
20
+ * One `<img>` per occupied square. The image is `pointer-events: none`
21
+ * so it never intercepts drag/click; the piece layer on the board owns
22
+ * hit testing. Each renderer is pure and does not allocate on the hot
23
+ * path — the URL lookup is a constant-time array read.
24
+ */
25
+
26
+ /** Shape a consumer's `PieceRenderer` prop expects. */
27
+ type PieceRenderer = (args: {
28
+ readonly cell: number;
29
+ readonly square: number;
30
+ }) => ReactNode;
31
+ /**
32
+ * 12-entry URL table, indexed by board cell `1..12`. Cell `0` is the
33
+ * empty square and is never looked up. Use {@link BOARD_CELL_KEY} to
34
+ * remember which index maps to which piece.
35
+ */
36
+ type PieceUrlTable = Readonly<{
37
+ /** white pawn (cell 1) */ 1: string;
38
+ /** white knight (cell 2) */ 2: string;
39
+ /** white bishop (cell 3) */ 3: string;
40
+ /** white rook (cell 4) */ 4: string;
41
+ /** white queen (cell 5) */ 5: string;
42
+ /** white king (cell 6) */ 6: string;
43
+ /** black pawn (cell 7) */ 7: string;
44
+ /** black knight (cell 8) */ 8: string;
45
+ /** black bishop (cell 9) */ 9: string;
46
+ /** black rook (cell 10) */ 10: string;
47
+ /** black queen (cell 11) */ 11: string;
48
+ /** black king (cell 12) */ 12: string;
49
+ }>;
50
+ /** Readable cell labels for the table — useful for callers building sets. */
51
+ declare const BOARD_CELL_KEY: Readonly<{
52
+ readonly wP: 1;
53
+ readonly wN: 2;
54
+ readonly wB: 3;
55
+ readonly wR: 4;
56
+ readonly wQ: 5;
57
+ readonly wK: 6;
58
+ readonly bP: 7;
59
+ readonly bN: 8;
60
+ readonly bB: 9;
61
+ readonly bR: 10;
62
+ readonly bQ: 11;
63
+ readonly bK: 12;
64
+ }>;
65
+ /**
66
+ * Build a {@link PieceRenderer} backed by a URL table. The returned
67
+ * function is referentially stable AND allocates **zero** React elements
68
+ * on the hot path: we pre-materialise one `<img>` element per piece
69
+ * code at factory time and hand out the same element for every call with
70
+ * the same cell.
71
+ *
72
+ * Why pre-materialise? The renderer is called inside `<PieceSlot/>` on
73
+ * every move that touches its square. Returning a fresh React element
74
+ * per call means React's reconciler has to shallow-diff the new element
75
+ * against the last one to decide whether DOM changed. A pool of 12
76
+ * frozen elements (one per piece code) bypasses that entirely — React
77
+ * short-circuits on identity.
78
+ */
79
+ declare function createImagePieceSet(urls: PieceUrlTable): PieceRenderer;
80
+ /**
81
+ * Helper that builds a chess.com-style PNG CDN URL for a given piece style.
82
+ *
83
+ * chess.com serves piece artwork at:
84
+ * `https://images.chesscomfiles.com/chess-themes/pieces/<style>/<size>/<colorPiece>.png`
85
+ *
86
+ * where `colorPiece` is one of `wp wn wb wr wq wk bp bn bb br bq bk`. The
87
+ * `size` options are `150` (default), `300`, etc. We pin to 150 by default
88
+ * because boards render at roughly that density on desktop, and larger
89
+ * sizes inflate page weight without perceptible benefit.
90
+ *
91
+ * @param style chess.com piece-style slug. Known values include `neo`
92
+ * (chess.com's default), `alpha`, `bases`, `cases`, `classic`,
93
+ * `club`, `condal`, `graffiti`, `leipzig`, `marble`, `maya`,
94
+ * `metal`, `modern`, `nature`, `neo_wood`, `newspaper`, `ocean`,
95
+ * `sky`, `space`, `tournament`, `vintage`, `wood`.
96
+ * @param size One of chess.com's supported pixel sizes (default 150).
97
+ */
98
+ declare function chesscomPieceUrls(style: string, size?: 150 | 300): PieceUrlTable;
99
+
100
+ export { BOARD_CELL_KEY as B, type PieceRenderer as P, type PieceUrlTable as a, createImagePieceSet as b, chesscomPieceUrls as c };
@@ -0,0 +1,22 @@
1
+ import { E as EngineAdapter } from './board-model-BvJOtwQ3.cjs';
2
+
3
+ /**
4
+ * Synchronous engine adapter wrapping `gigachess`.
5
+ *
6
+ * Provides a zero-WASM, pure JavaScript chess engine adapter with instant
7
+ * synchronous initialization (<0.5 ms), incremental { lo, hi } Zobrist hashing,
8
+ * and canonical King-captures-Rook castling representation (Move2).
9
+ */
10
+
11
+ /**
12
+ * Preload gigachess sliding-attack magic tables and Polyglot Zobrist tables ahead of time.
13
+ */
14
+ declare function preloadGigachessAdapter(): Promise<void>;
15
+ /**
16
+ * Create a gigachess-backed engine adapter synchronously.
17
+ *
18
+ * @param fen Optional starting FEN.
19
+ */
20
+ declare function createGigachessAdapter(fen?: string): EngineAdapter;
21
+
22
+ export { createGigachessAdapter as c, preloadGigachessAdapter as p };
@@ -0,0 +1,22 @@
1
+ import { E as EngineAdapter } from './board-model-BvJOtwQ3.js';
2
+
3
+ /**
4
+ * Synchronous engine adapter wrapping `gigachess`.
5
+ *
6
+ * Provides a zero-WASM, pure JavaScript chess engine adapter with instant
7
+ * synchronous initialization (<0.5 ms), incremental { lo, hi } Zobrist hashing,
8
+ * and canonical King-captures-Rook castling representation (Move2).
9
+ */
10
+
11
+ /**
12
+ * Preload gigachess sliding-attack magic tables and Polyglot Zobrist tables ahead of time.
13
+ */
14
+ declare function preloadGigachessAdapter(): Promise<void>;
15
+ /**
16
+ * Create a gigachess-backed engine adapter synchronously.
17
+ *
18
+ * @param fen Optional starting FEN.
19
+ */
20
+ declare function createGigachessAdapter(fen?: string): EngineAdapter;
21
+
22
+ export { createGigachessAdapter as c, preloadGigachessAdapter as p };