@johnmorrisdotca/sugoroku 1.0.2 → 1.1.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 (57) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +78 -68
  3. package/dist/board.d.ts +216 -12
  4. package/dist/board.js +204 -12
  5. package/dist/colours.d.ts +80 -8
  6. package/dist/colours.js +51 -6
  7. package/dist/computer.d.ts +138 -8
  8. package/dist/computer.js +109 -7
  9. package/dist/dice.d.ts +53 -4
  10. package/dist/dice.js +42 -3
  11. package/dist/draw.d.ts +43 -3
  12. package/dist/draw.js +33 -2
  13. package/dist/element-define.d.ts +1 -1
  14. package/dist/element-define.js +4 -13
  15. package/dist/element.d.ts +233 -3
  16. package/dist/element.js +402 -48
  17. package/dist/evaluate.d.ts +76 -4
  18. package/dist/evaluate.js +65 -3
  19. package/dist/game.d.ts +408 -23
  20. package/dist/game.js +328 -18
  21. package/dist/geometry.d.ts +50 -3
  22. package/dist/geometry.js +20 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/match.d.ts +66 -4
  26. package/dist/match.js +55 -4
  27. package/dist/mount.d.ts +75 -4
  28. package/dist/mount.js +25 -3
  29. package/dist/moves.d.ts +48 -1
  30. package/dist/moves.js +35 -1
  31. package/dist/notation.d.ts +92 -4
  32. package/dist/notation.js +82 -3
  33. package/dist/playStyle.d.ts +6 -0
  34. package/dist/playStyle.js +6 -0
  35. package/dist/plays.d.ts +108 -3
  36. package/dist/plays.js +96 -3
  37. package/dist/positionId.d.ts +29 -1
  38. package/dist/positionId.js +29 -1
  39. package/dist/random.d.ts +33 -3
  40. package/dist/random.js +22 -2
  41. package/dist/record.d.ts +150 -7
  42. package/dist/record.js +94 -5
  43. package/dist/rules.d.ts +130 -10
  44. package/dist/rules.js +99 -9
  45. package/dist/side.d.ts +38 -3
  46. package/dist/side.js +30 -3
  47. package/dist/sound.d.ts +61 -3
  48. package/dist/sound.js +27 -2
  49. package/dist/strings.d.ts +42 -2
  50. package/dist/strings.js +34 -2
  51. package/dist/style.d.ts +6 -0
  52. package/dist/style.js +6 -0
  53. package/dist/variants.d.ts +113 -8
  54. package/dist/variants.js +62 -5
  55. package/dist/version.d.ts +9 -2
  56. package/dist/version.js +9 -2
  57. package/package.json +25 -18
package/dist/element.d.ts CHANGED
@@ -1,6 +1,10 @@
1
+ import { type SugorokuDrawOptions } from "./draw.ts";
2
+ import { type Position } from "./board.ts";
1
3
  import type { GameState } from "./game.ts";
2
4
  import type { Match } from "./match.ts";
3
- import { type SugorokuMount } from "./mount.ts";
5
+ import { type SugorokuMount, type SugorokuMountOptions } from "./mount.ts";
6
+ import type { Side } from "./side.ts";
7
+ import { type VariantKey } from "./variants.ts";
4
8
  /**
5
9
  * THE `<sugoroku-board>` ELEMENT: a playable backgammon board in a tag, with no
6
10
  * framework. `@johnmorrisdotca/sugoroku/element/define` defines it; this entry
@@ -30,9 +34,50 @@ import { type SugorokuMount } from "./mount.ts";
30
34
  * one steady shape whatever is on the board.
31
35
  */
32
36
  declare const ElementBase: typeof HTMLElement;
33
- export declare class SugorokuBoard extends ElementBase {
37
+ declare class SugorokuFrame extends ElementBase {
38
+ #private;
39
+ protected frame(): void;
40
+ protected write(name: string, value: unknown): void;
41
+ /** Symbolic display size, reflected. */
42
+ get size(): string | null;
43
+ set size(value: string | null);
44
+ /** Pixel display width, reflected. */
45
+ get width(): string | null;
46
+ set width(value: string | number | null);
47
+ /** Spoken group label, reflected. */
48
+ get label(): string | null;
49
+ set label(value: string | null);
50
+ }
51
+ /** The real mounted options, checked alongside builder coverage.
52
+ * @example
53
+ * ```ts
54
+ * import { SUGOROKU_EMBED_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
55
+ * console.log(typeof SUGOROKU_EMBED_OPTION_KEYS); // object
56
+ * ```
57
+ */
58
+ export declare const SUGOROKU_EMBED_OPTION_KEYS: string[];
59
+ /** Host mount options, including custom colours, names, a match and callbacks.
60
+ * @example
61
+ * ```ts
62
+ * import type { SugorokuElementOptions } from "@johnmorrisdotca/sugoroku/element";
63
+ * const options: SugorokuElementOptions = {};
64
+ * console.log(Object.keys(options).length); // 0
65
+ * ```
66
+ */
67
+ export type SugorokuElementOptions = SugorokuMountOptions;
68
+ /** Native custom element with reflected setup and presentation.
69
+ * @example
70
+ * ```ts
71
+ * import { SugorokuBoard } from "@johnmorrisdotca/sugoroku/element";
72
+ * console.log(SugorokuBoard.observedAttributes.includes("lang")); // true
73
+ * ```
74
+ */
75
+ export declare class SugorokuBoard extends SugorokuFrame {
34
76
  #private;
35
77
  static observedAttributes: string[];
78
+ /** Host mount options; callback and look changes preserve the current game. */
79
+ get options(): SugorokuElementOptions;
80
+ set options(value: SugorokuElementOptions);
36
81
  connectedCallback(): void;
37
82
  disconnectedCallback(): void;
38
83
  attributeChangedCallback(): void;
@@ -48,9 +93,194 @@ export declare class SugorokuBoard extends ElementBase {
48
93
  double(): void;
49
94
  take(): void;
50
95
  drop(): void;
51
- beaver(): void;
96
+ /** Calling beaver() keeps the native action; assignment reflects the rule attribute. */
97
+ get beaver(): () => void;
98
+ set beaver(value: string | boolean | (() => void));
52
99
  resign(): void;
53
100
  nextGame(): void;
54
101
  newMatch(): void;
102
+ /** The `variant` attribute, reflected. */
103
+ get variant(): string | null;
104
+ set variant(value: string | number | boolean | null | undefined);
105
+ /** The `preset` attribute, reflected. */
106
+ get preset(): string | null;
107
+ set preset(value: string | number | boolean | null | undefined);
108
+ /** The `points` attribute, reflected. */
109
+ get points(): string | null;
110
+ set points(value: string | number | boolean | null | undefined);
111
+ /** The `cube` attribute, reflected. */
112
+ get cube(): string | null;
113
+ set cube(value: string | number | boolean | null | undefined);
114
+ /** The `crawford` attribute, reflected. */
115
+ get crawford(): string | null;
116
+ set crawford(value: string | number | boolean | null | undefined);
117
+ /** The `jacoby` attribute, reflected. */
118
+ get jacoby(): string | null;
119
+ set jacoby(value: string | number | boolean | null | undefined);
120
+ /** The `gammons` attribute, reflected. */
121
+ get gammons(): string | null;
122
+ set gammons(value: string | number | boolean | null | undefined);
123
+ /** The `seed` attribute, reflected. */
124
+ get seed(): string | null;
125
+ set seed(value: string | number | boolean | null | undefined);
126
+ /** The `dice` attribute, reflected. */
127
+ get dice(): string | null;
128
+ set dice(value: string | number | boolean | null | undefined);
129
+ /** The `controls` attribute, reflected. */
130
+ get controls(): string | null;
131
+ set controls(value: string | number | boolean | null | undefined);
132
+ /** The `drag` attribute, reflected. */
133
+ get drag(): string | null;
134
+ set drag(value: string | number | boolean | null | undefined);
135
+ /** The `auto-end` attribute, reflected. */
136
+ get autoEnd(): string | null;
137
+ set autoEnd(value: string | number | boolean | null | undefined);
138
+ /** The `sound` attribute, reflected. */
139
+ get sound(): string | null;
140
+ set sound(value: string | number | boolean | null | undefined);
141
+ /** The `computer-delay` attribute, reflected. */
142
+ get computerDelay(): string | null;
143
+ set computerDelay(value: string | number | boolean | null | undefined);
144
+ /** The `white` attribute, reflected. */
145
+ get white(): string | null;
146
+ set white(value: string | number | boolean | null | undefined);
147
+ /** The `black` attribute, reflected. */
148
+ get black(): string | null;
149
+ set black(value: string | number | boolean | null | undefined);
150
+ /** The `board` attribute, reflected. */
151
+ get board(): string | null;
152
+ set board(value: string | number | boolean | null | undefined);
153
+ /** The `checkers` attribute, reflected. */
154
+ get checkers(): string | null;
155
+ set checkers(value: string | number | boolean | null | undefined);
156
+ /** The `theme` attribute, reflected. */
157
+ get theme(): string | null;
158
+ set theme(value: string | number | boolean | null | undefined);
159
+ /** The `home` attribute, reflected. */
160
+ get home(): string | null;
161
+ set home(value: string | number | boolean | null | undefined);
162
+ /** The `view` attribute, reflected. */
163
+ get view(): string | null;
164
+ set view(value: string | number | boolean | null | undefined);
165
+ /** The `numbers` attribute, reflected. */
166
+ get numbers(): string | null;
167
+ set numbers(value: string | number | boolean | null | undefined);
168
+ /** The `orientation` attribute, reflected. */
169
+ get orientation(): string | null;
170
+ set orientation(value: string | number | boolean | null | undefined);
55
171
  }
172
+ /** Defines the default playable board, or a subclass under a custom tag. Server-safe and idempotent.
173
+ * @param tagName - The custom tag name; omitted to use the package default.
174
+ * @param registry - The custom-element registry; omitted outside a browser.
175
+ * @returns Nothing; existing definitions and server imports remain safe.
176
+ * @example
177
+ * ```ts
178
+ * import { defineBoard } from "@johnmorrisdotca/sugoroku/element";
179
+ * defineBoard();
180
+ * console.log(typeof defineBoard); // function
181
+ * ```
182
+ */
183
+ export declare function defineBoard(tagName?: string, registry?: CustomElementRegistry | undefined): void;
184
+ /**
185
+ * Reads a GNU position ID or bounded JSON position; null means invalid counts or input.
186
+ * @param text - Position ID, JSON position, or null for the variant's start.
187
+ * @param variant - The native variant used for checker counts and layout.
188
+ * @param turn - The on-roll side encoded by a GNU ID.
189
+ * @returns A complete position, or null for malformed or inconsistent input.
190
+ * @example
191
+ * ```ts
192
+ * import { readEmbedPosition } from "@johnmorrisdotca/sugoroku/element";
193
+ * console.log(readEmbedPosition("4HPwATDgc/ABMA")?.points[0].length);
194
+ * ```
195
+ */
196
+ export declare function readEmbedPosition(text: string | null, variant?: VariantKey, turn?: Side): Position | null;
197
+ /** Host data and all native SVG drawing choices for a position.
198
+ * @example
199
+ * ```ts
200
+ * import type { SugorokuPositionOptions } from "@johnmorrisdotca/sugoroku/element";
201
+ * const options: SugorokuPositionOptions = {};
202
+ * console.log(Object.keys(options).length); // 0
203
+ * ```
204
+ */
205
+ export type SugorokuPositionOptions = SugorokuDrawOptions & {
206
+ position?: Position;
207
+ onChange?: (position: Position) => void;
208
+ };
209
+ /** Native draw keys, checked by the shared builder.
210
+ * @example
211
+ * ```ts
212
+ * import { SUGOROKU_DRAW_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
213
+ * console.log(typeof SUGOROKU_DRAW_OPTION_KEYS); // object
214
+ * ```
215
+ */
216
+ export declare const SUGOROKU_DRAW_OPTION_KEYS: string[];
217
+ /** All host position options, checked by the builder.
218
+ * @example
219
+ * ```ts
220
+ * import { SUGOROKU_POSITION_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
221
+ * console.log(typeof SUGOROKU_POSITION_OPTION_KEYS); // object
222
+ * ```
223
+ */
224
+ export declare const SUGOROKU_POSITION_OPTION_KEYS: string[];
225
+ /** A read-only backgammon position, drawn by the native SVG writer.
226
+ * @example
227
+ * ```ts
228
+ * import { SugorokuPosition } from "@johnmorrisdotca/sugoroku/element";
229
+ * console.log(SugorokuPosition.observedAttributes.includes("lang")); // true
230
+ * ```
231
+ */
232
+ export declare class SugorokuPosition extends SugorokuFrame {
233
+ #private;
234
+ static observedAttributes: string[];
235
+ /** Structured current position, or null after an input error. */
236
+ get value(): Position | null;
237
+ /** Native drawing options and trusted host position data. */
238
+ get options(): SugorokuPositionOptions;
239
+ set options(value: SugorokuPositionOptions);
240
+ connectedCallback(): void;
241
+ disconnectedCallback(): void;
242
+ attributeChangedCallback(): void;
243
+ /** Position ID or JSON, reflected. Assign an object to serialize it. */
244
+ get position(): string | null;
245
+ set position(value: string | Position | null);
246
+ /** The `variant` attribute, reflected. */
247
+ get variant(): string | null;
248
+ set variant(value: string | number | boolean | null | undefined);
249
+ /** The `turn` attribute, reflected. */
250
+ get turn(): string | null;
251
+ set turn(value: string | number | boolean | null | undefined);
252
+ /** The `board` attribute, reflected. */
253
+ get board(): string | null;
254
+ set board(value: string | number | boolean | null | undefined);
255
+ /** The `checkers` attribute, reflected. */
256
+ get checkers(): string | null;
257
+ set checkers(value: string | number | boolean | null | undefined);
258
+ /** The `theme` attribute, reflected. */
259
+ get theme(): string | null;
260
+ set theme(value: string | number | boolean | null | undefined);
261
+ /** The `home` attribute, reflected. */
262
+ get home(): string | null;
263
+ set home(value: string | number | boolean | null | undefined);
264
+ /** The `view` attribute, reflected. */
265
+ get view(): string | null;
266
+ set view(value: string | number | boolean | null | undefined);
267
+ /** The `numbers` attribute, reflected. */
268
+ get numbers(): string | null;
269
+ set numbers(value: string | number | boolean | null | undefined);
270
+ /** The `orientation` attribute, reflected. */
271
+ get orientation(): string | null;
272
+ set orientation(value: string | number | boolean | null | undefined);
273
+ }
274
+ /** Defines a static position, or a subclass under a host's tag. Safe on a server.
275
+ * @param tagName - The custom tag name; omitted to use the package default.
276
+ * @param registry - The custom-element registry; omitted outside a browser.
277
+ * @returns Nothing; existing definitions and server imports remain safe.
278
+ * @example
279
+ * ```ts
280
+ * import { definePosition } from "@johnmorrisdotca/sugoroku/element";
281
+ * definePosition();
282
+ * console.log(typeof definePosition); // function
283
+ * ```
284
+ */
285
+ export declare function definePosition(tagName?: string, registry?: CustomElementRegistry | undefined): void;
56
286
  export {};