@johnmorrisdotca/kumimoji 1.2.2 → 1.3.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 (76) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +80 -39
  3. package/dist/check.d.ts +26 -1
  4. package/dist/check.js +26 -1
  5. package/dist/computer.types.d.ts +24 -2
  6. package/dist/computerPlay.d.ts +45 -2
  7. package/dist/computerPlay.js +45 -2
  8. package/dist/computerTurn.d.ts +42 -3
  9. package/dist/computerTurn.js +42 -3
  10. package/dist/daily.d.ts +22 -2
  11. package/dist/daily.js +22 -2
  12. package/dist/element-define.d.ts +1 -1
  13. package/dist/element-define.js +3 -13
  14. package/dist/element.d.ts +85 -4
  15. package/dist/element.js +176 -45
  16. package/dist/embed-day.d.ts +4 -0
  17. package/dist/embed-day.js +23 -0
  18. package/dist/export.d.ts +123 -6
  19. package/dist/export.js +91 -4
  20. package/dist/generate.d.ts +14 -0
  21. package/dist/generate.js +14 -0
  22. package/dist/grid.d.ts +181 -10
  23. package/dist/grid.js +122 -7
  24. package/dist/help.d.ts +36 -3
  25. package/dist/help.js +36 -3
  26. package/dist/judge.d.ts +14 -0
  27. package/dist/judge.js +14 -0
  28. package/dist/kana.d.ts +23 -1
  29. package/dist/kana.js +23 -1
  30. package/dist/kumimoji.types.d.ts +70 -5
  31. package/dist/party.d.ts +268 -14
  32. package/dist/party.js +268 -14
  33. package/dist/party.types.d.ts +50 -2
  34. package/dist/partyKept.d.ts +74 -4
  35. package/dist/partyKept.js +74 -4
  36. package/dist/partySeats.d.ts +92 -6
  37. package/dist/partySeats.js +72 -4
  38. package/dist/partyTurns.d.ts +171 -5
  39. package/dist/partyTurns.js +171 -5
  40. package/dist/placement.d.ts +50 -2
  41. package/dist/placement.js +30 -0
  42. package/dist/play.d.ts +247 -15
  43. package/dist/play.js +237 -15
  44. package/dist/random.d.ts +34 -3
  45. package/dist/random.js +23 -2
  46. package/dist/react.d.ts +42 -4
  47. package/dist/react.js +22 -5
  48. package/dist/showcase.d.ts +83 -7
  49. package/dist/showcase.js +49 -4
  50. package/dist/strings.d.ts +54 -5
  51. package/dist/strings.js +34 -3
  52. package/dist/tableView.d.ts +151 -8
  53. package/dist/tableView.js +129 -6
  54. package/dist/tileFace.d.ts +59 -5
  55. package/dist/tileFace.js +48 -4
  56. package/dist/tileFamily.d.ts +9 -0
  57. package/dist/tileFamily.js +9 -0
  58. package/dist/tileWords.d.ts +93 -6
  59. package/dist/tileWords.js +83 -6
  60. package/dist/tileWordsModule.d.ts +11 -1
  61. package/dist/tileWordsModule.js +11 -1
  62. package/dist/tiles.constants.d.ts +99 -5
  63. package/dist/tiles.constants.js +99 -5
  64. package/dist/turn.d.ts +82 -4
  65. package/dist/turn.js +82 -4
  66. package/dist/ui/board.d.ts +60 -5
  67. package/dist/ui/board.js +28 -2
  68. package/dist/ui/mount.d.ts +41 -2
  69. package/dist/ui/mount.js +38 -1
  70. package/dist/ui/style.d.ts +6 -1
  71. package/dist/ui/style.js +6 -0
  72. package/dist/version.d.ts +9 -2
  73. package/dist/version.js +9 -2
  74. package/dist/wilds.d.ts +22 -1
  75. package/dist/wilds.js +22 -1
  76. package/package.json +64 -56
@@ -11,6 +11,16 @@ import type { KumimojiLanguage } from "./kumimoji.types.ts";
11
11
  * `loadTileWords` fetches and reads it once; `tileWords` hands back the list
12
12
  * already loaded, and refuses rather than answering for a list it does not
13
13
  * have — a check that could not read the list must not say a word is fine.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
18
+ * import type { TileWords } from "@johnmorrisdotca/kumimoji";
19
+ *
20
+ * const words = await loadTileWordsFromModule("english");
21
+ * const value: TileWords = words;
22
+ * console.log(value);
23
+ * ```
14
24
  */
15
25
  export type TileWords = {
16
26
  language: KumimojiLanguage;
@@ -43,13 +53,57 @@ export type TileWords = {
43
53
  /** Internal tile code for a visible letter or mora. */
44
54
  codeOf: (face: string) => string | null;
45
55
  };
46
- /** Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest. */
56
+ /** Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest.
57
+ *
58
+ * @param packed - The front-coded words of one fixed length.
59
+ * @param length - The game length or decoded word length, as declared.
60
+ * @returns Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest.
61
+ * @example
62
+ * ```ts
63
+ * import { unpackLength } from "@johnmorrisdotca/kumimoji";
64
+ *
65
+ * console.log(unpackLength("0cat2r",3));
66
+ * ```
67
+ */
47
68
  export declare function unpackLength(packed: string, length: number): string[];
48
- /** The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words. */
69
+ /** The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words.
70
+ *
71
+ * @param data - The packed language-list data to decode.
72
+ * @returns The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words.
73
+ * @example
74
+ * ```ts
75
+ * import { unpackTileWords } from "@johnmorrisdotca/kumimoji";
76
+ *
77
+ * console.log(unpackTileWords({3:"0cat2r"}).allowed.has("cat"));
78
+ * ```
79
+ */
49
80
  export declare function unpackTileWords(data: Readonly<Record<number, string>>): TileWords;
50
- /** Used by `tileWordsModule.ts` only: how to read a list where there is no browser. */
81
+ /** Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
82
+ *
83
+ * @param source - The asynchronous loader that supplies the language word list.
84
+ * @returns Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
85
+ * @example
86
+ * ```ts
87
+ * import { loadTileWords, readTileWordsWith, tileWordsFrom } from "@johnmorrisdotca/kumimoji";
88
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
89
+ *
90
+ * readTileWordsWith(async language => tileWordsFrom(language,{3:"0cat2r"}));
91
+ * console.log((await loadTileWords("english")).allowed.has("cat"));
92
+ * ```
93
+ */
51
94
  export declare function readTileWordsWith(source: (language: KumimojiLanguage) => Promise<TileWords>): void;
52
- /** A list read from its module, for `tileWordsModule.ts`. */
95
+ /** A list read from its module, for `tileWordsModule.ts`.
96
+ *
97
+ * @param language - The English or Japanese tile language.
98
+ * @param data - The packed language-list data to decode.
99
+ * @returns A list read from its module, for `tileWordsModule.ts`.
100
+ * @example
101
+ * ```ts
102
+ * import { tileWordsFrom } from "@johnmorrisdotca/kumimoji";
103
+ *
104
+ * console.log(tileWordsFrom("english",{3:"0cat2r"}).allowed.size);
105
+ * ```
106
+ */
53
107
  export declare function tileWordsFrom(language: KumimojiLanguage, data: unknown): TileWords;
54
108
  /**
55
109
  * THE LIST, ONCE. In a browser (or its worker) it arrives as its own script,
@@ -64,9 +118,42 @@ export declare function tileWordsFrom(language: KumimojiLanguage, data: unknown)
64
118
  * branch, and the import with it, is gone before anything is traced. The
65
119
  * server reads the list through `tileWordsModule.ts` instead, which only the
66
120
  * server's own checks and the tests import.
121
+ *
122
+ * @param language - The English or Japanese tile language.
123
+ * @returns THE LIST, ONCE. In a browser (or its worker) it arrives as its own script, fetched by the dynamic import below the first time a Kumimoji needs it.
124
+ * @example
125
+ * ```ts
126
+ * import { loadTileWords } from "@johnmorrisdotca/kumimoji";
127
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
128
+ *
129
+ * await loadTileWordsFromModule("english");
130
+ * console.log((await loadTileWords("english")).allowed.size);
131
+ * ```
67
132
  */
68
133
  export declare function loadTileWords(language?: KumimojiLanguage): Promise<TileWords>;
69
- /** The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer. */
134
+ /** The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer.
135
+ *
136
+ * @param language - The English or Japanese tile language.
137
+ * @returns The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer.
138
+ * @example
139
+ * ```ts
140
+ * import { tileWords } from "@johnmorrisdotca/kumimoji";
141
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
142
+ *
143
+ * await loadTileWordsFromModule("english");
144
+ * console.log(tileWords("english").allowed.has("cat"));
145
+ * ```
146
+ */
70
147
  export declare function tileWords(language?: KumimojiLanguage): TileWords;
71
- /** Whether the list has been fetched yet, for a page to say "loading" rather than throw. */
148
+ /** Whether the list has been fetched yet, for a page to say "loading" rather than throw.
149
+ *
150
+ * @param language - The English or Japanese tile language.
151
+ * @returns Whether the list has been fetched yet, for a page to say "loading" rather than throw.
152
+ * @example
153
+ * ```ts
154
+ * import { tileWordsReady } from "@johnmorrisdotca/kumimoji";
155
+ *
156
+ * console.log(tileWordsReady("english"));
157
+ * ```
158
+ */
72
159
  export declare function tileWordsReady(language?: KumimojiLanguage): boolean;
package/dist/tileWords.js CHANGED
@@ -2,7 +2,18 @@ import { tileKana } from "./kana.js";
2
2
  import { KANA_TILE_START, KANA_WILD_START, kanaTileCode, tileFace } from "./tileFace.js";
3
3
  import { JAPANESE_TILE_MIX, TILE_MIX } from "./tiles.constants.js";
4
4
  const loaded = new Map();
5
- /** Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest. */
5
+ /** Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest.
6
+ *
7
+ * @param packed - The front-coded words of one fixed length.
8
+ * @param length - The game length or decoded word length, as declared.
9
+ * @returns Front-coded words of one length read back (see `scripts/tile-words.mjs`): a shared-prefix character, then the rest.
10
+ * @example
11
+ * ```ts
12
+ * import { unpackLength } from "@johnmorrisdotca/kumimoji";
13
+ *
14
+ * console.log(unpackLength("0cat2r",3));
15
+ * ```
16
+ */
6
17
  export function unpackLength(packed, length) {
7
18
  const words = [];
8
19
  const text = packed.replace(/\s+/g, "");
@@ -18,7 +29,17 @@ export function unpackLength(packed, length) {
18
29
  }
19
30
  return words;
20
31
  }
21
- /** The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words. */
32
+ /** The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words.
33
+ *
34
+ * @param data - The packed language-list data to decode.
35
+ * @returns The English list read from its packed data: every word, the words by length, the set's mix, and the functions that turn tiles into words.
36
+ * @example
37
+ * ```ts
38
+ * import { unpackTileWords } from "@johnmorrisdotca/kumimoji";
39
+ *
40
+ * console.log(unpackTileWords({3:"0cat2r"}).allowed.has("cat"));
41
+ * ```
42
+ */
22
43
  export function unpackTileWords(data) {
23
44
  const byLength = new Map();
24
45
  const allowed = new Set();
@@ -111,11 +132,34 @@ function unpackJapaneseWords(data) {
111
132
  * loader that imports them (`tileWordsModule.ts`). Null until one does.
112
133
  */
113
134
  let fromModule = null;
114
- /** Used by `tileWordsModule.ts` only: how to read a list where there is no browser. */
135
+ /** Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
136
+ *
137
+ * @param source - The asynchronous loader that supplies the language word list.
138
+ * @returns Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
139
+ * @example
140
+ * ```ts
141
+ * import { loadTileWords, readTileWordsWith, tileWordsFrom } from "@johnmorrisdotca/kumimoji";
142
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
143
+ *
144
+ * readTileWordsWith(async language => tileWordsFrom(language,{3:"0cat2r"}));
145
+ * console.log((await loadTileWords("english")).allowed.has("cat"));
146
+ * ```
147
+ */
115
148
  export function readTileWordsWith(source) {
116
149
  fromModule = source;
117
150
  }
118
- /** A list read from its module, for `tileWordsModule.ts`. */
151
+ /** A list read from its module, for `tileWordsModule.ts`.
152
+ *
153
+ * @param language - The English or Japanese tile language.
154
+ * @param data - The packed language-list data to decode.
155
+ * @returns A list read from its module, for `tileWordsModule.ts`.
156
+ * @example
157
+ * ```ts
158
+ * import { tileWordsFrom } from "@johnmorrisdotca/kumimoji";
159
+ *
160
+ * console.log(tileWordsFrom("english",{3:"0cat2r"}).allowed.size);
161
+ * ```
162
+ */
119
163
  export function tileWordsFrom(language, data) {
120
164
  return language === "english"
121
165
  ? unpackTileWords(data)
@@ -134,6 +178,17 @@ export function tileWordsFrom(language, data) {
134
178
  * branch, and the import with it, is gone before anything is traced. The
135
179
  * server reads the list through `tileWordsModule.ts` instead, which only the
136
180
  * server's own checks and the tests import.
181
+ *
182
+ * @param language - The English or Japanese tile language.
183
+ * @returns THE LIST, ONCE. In a browser (or its worker) it arrives as its own script, fetched by the dynamic import below the first time a Kumimoji needs it.
184
+ * @example
185
+ * ```ts
186
+ * import { loadTileWords } from "@johnmorrisdotca/kumimoji";
187
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
188
+ *
189
+ * await loadTileWordsFromModule("english");
190
+ * console.log((await loadTileWords("english")).allowed.size);
191
+ * ```
137
192
  */
138
193
  export async function loadTileWords(language = "english") {
139
194
  const already = loaded.get(language);
@@ -153,14 +208,36 @@ export async function loadTileWords(language = "english") {
153
208
  loaded.set(language, words);
154
209
  return words;
155
210
  }
156
- /** The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer. */
211
+ /** The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer.
212
+ *
213
+ * @param language - The English or Japanese tile language.
214
+ * @returns The list already loaded, for judging and dealing. Throws where `loadTileWords` has not yet fetched it: a check that cannot read the list must not answer.
215
+ * @example
216
+ * ```ts
217
+ * import { tileWords } from "@johnmorrisdotca/kumimoji";
218
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
219
+ *
220
+ * await loadTileWordsFromModule("english");
221
+ * console.log(tileWords("english").allowed.has("cat"));
222
+ * ```
223
+ */
157
224
  export function tileWords(language = "english") {
158
225
  const words = loaded.get(language);
159
226
  if (words === undefined)
160
227
  throw new Error(`The ${language} Kumimoji words have not been loaded (loadTileWords).`);
161
228
  return words;
162
229
  }
163
- /** Whether the list has been fetched yet, for a page to say "loading" rather than throw. */
230
+ /** Whether the list has been fetched yet, for a page to say "loading" rather than throw.
231
+ *
232
+ * @param language - The English or Japanese tile language.
233
+ * @returns Whether the list has been fetched yet, for a page to say "loading" rather than throw.
234
+ * @example
235
+ * ```ts
236
+ * import { tileWordsReady } from "@johnmorrisdotca/kumimoji";
237
+ *
238
+ * console.log(tileWordsReady("english"));
239
+ * ```
240
+ */
164
241
  export function tileWordsReady(language = "english") {
165
242
  return loaded.has(language);
166
243
  }
@@ -1,4 +1,14 @@
1
1
  import { type TileWords } from "./tileWords.ts";
2
2
  import type { KumimojiLanguage } from "./kumimoji.types.ts";
3
- /** The list, read from its module: `loadTileWords` for a caller with no browser. */
3
+ /** The list, read from its module: `loadTileWords` for a caller with no browser.
4
+ *
5
+ * @param language - The English or Japanese tile language.
6
+ * @returns The list, read from its module: `loadTileWords` for a caller with no browser.
7
+ * @example
8
+ * ```ts
9
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
10
+ *
11
+ * console.log((await loadTileWordsFromModule("english")).allowed.size);
12
+ * ```
13
+ */
4
14
  export declare function loadTileWordsFromModule(language?: KumimojiLanguage): Promise<TileWords>;
@@ -7,7 +7,17 @@ import { loadTileWords, readTileWordsWith, tileWordsFrom } from "./tileWords.js"
7
7
  * lists for the browser's sake (see `loadTileWords`).
8
8
  */
9
9
  readTileWordsWith(async (language) => tileWordsFrom(language, language === "english" ? (await import("./words.en.data.js")).TILE_WORDS_EN : (await import("./words.ja.data.js")).TILE_WORDS_JA));
10
- /** The list, read from its module: `loadTileWords` for a caller with no browser. */
10
+ /** The list, read from its module: `loadTileWords` for a caller with no browser.
11
+ *
12
+ * @param language - The English or Japanese tile language.
13
+ * @returns The list, read from its module: `loadTileWords` for a caller with no browser.
14
+ * @example
15
+ * ```ts
16
+ * import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
17
+ *
18
+ * console.log((await loadTileWordsFromModule("english")).allowed.size);
19
+ * ```
20
+ */
11
21
  export function loadTileWordsFromModule(language = "english") {
12
22
  return loadTileWords(language);
13
23
  }
@@ -14,6 +14,12 @@ import type { KumimojiLength } from "./kumimoji.types.ts";
14
14
  *
15
15
  * To tune the letters, change the counts here. The total is checked by
16
16
  * `tiles.test.ts`, so an edit that loses a tile says so.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { TILE_MIX } from "@johnmorrisdotca/kumimoji";
21
+ * console.log(TILE_MIX);
22
+ * ```
17
23
  */
18
24
  export declare const TILE_MIX: Readonly<Record<string, number>>;
19
25
  /**
@@ -29,9 +35,22 @@ export declare const TILE_MIX: Readonly<Record<string, number>>;
29
35
  * Fixed here rather than taken from the monthly dictionary refresh, which
30
36
  * prints what it measures beside this table (`scripts/word-lists-ja.mjs`): a
31
37
  * kept game's bag is checked against these counts.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { JAPANESE_TILE_MIX } from "@johnmorrisdotca/kumimoji";
42
+ * console.log(JAPANESE_TILE_MIX);
43
+ * ```
32
44
  */
33
45
  export declare const JAPANESE_TILE_MIX: Readonly<Record<string, number>>;
34
- /** The whole set, counted from the table. */
46
+ /** The whole set, counted from the table.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { TILE_MIX_TOTAL } from "@johnmorrisdotca/kumimoji";
51
+ * console.log(TILE_MIX_TOTAL);
52
+ * ```
53
+ */
35
54
  export declare const TILE_MIX_TOTAL: number;
36
55
  /**
37
56
  * THERE IS NO BOARD. John, 2026-09-26: "curious if we just have a large board
@@ -40,6 +59,12 @@ export declare const TILE_MIX_TOTAL: number;
40
59
  * grows with them (`tableView.ts`), so a grid is as wide and as tall as its
41
60
  * player builds it. This is only the most a finished grid may measure either
42
61
  * way before the check refuses it unread: fifty tiles in one line is fifty.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { KUMIMOJI_GRID_MOST } from "@johnmorrisdotca/kumimoji";
66
+ * console.log(KUMIMOJI_GRID_MOST);
67
+ * ```
43
68
  */
44
69
  export declare const KUMIMOJI_GRID_MOST = 60;
45
70
  /**
@@ -47,6 +72,12 @@ export declare const KUMIMOJI_GRID_MOST = 60;
47
72
  * 2026-09-26: "you were given seven or 11 starting tiles". Three is for the
48
73
  * browser tests alone — a game that can be finished in a few presses — and is
49
74
  * never offered on the set-up screen.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { KUMIMOJI_HANDS } from "@johnmorrisdotca/kumimoji";
79
+ * console.log(KUMIMOJI_HANDS);
80
+ * ```
50
81
  */
51
82
  export declare const KUMIMOJI_HANDS: {
52
83
  readonly tiny: 3;
@@ -56,21 +87,72 @@ export declare const KUMIMOJI_HANDS: {
56
87
  /**
57
88
  * SHORT GAME TOTALS, by opening hand. Medium and Full derive from the tile
58
89
  * inventory in `kumimojiTileCount`; these stay the existing Short lengths.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { KUMIMOJI_BAG } from "@johnmorrisdotca/kumimoji";
94
+ * console.log(KUMIMOJI_BAG);
95
+ * ```
59
96
  */
60
97
  export declare const KUMIMOJI_BAG: Readonly<Record<number, number>>;
61
- /** Wild tiles per original 40/50-tile game, included within the bag total. */
98
+ /** Wild tiles per original 40/50-tile game, included within the bag total.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { KUMIMOJI_WILDS } from "@johnmorrisdotca/kumimoji";
103
+ * console.log(KUMIMOJI_WILDS);
104
+ * ```
105
+ */
62
106
  export declare const KUMIMOJI_WILDS: Readonly<Record<number, Readonly<Record<"easy" | "medium" | "hard", number>>>>;
63
- /** Tile count for a selected length and inventory size. Double supplies two sets. */
107
+ /** Tile count for a selected length and inventory size. Double supplies two sets.
108
+ *
109
+ * @param hand - The hand size or tile codes, as declared by the function signature.
110
+ * @param length - The game length or decoded word length, as declared.
111
+ * @param setSize - The number of physical tiles in the language set.
112
+ * @param doubleSet - Whether to use two English tile sets.
113
+ * @returns Tile count for a selected length and inventory size. Double supplies two sets.
114
+ * @example
115
+ * ```ts
116
+ * import { kumimojiTileCount } from "@johnmorrisdotca/kumimoji";
117
+ *
118
+ * console.log(kumimojiTileCount(7,"short"));
119
+ * ```
120
+ */
64
121
  export declare function kumimojiTileCount(hand: number, length: KumimojiLength, setSize?: number, doubleSet?: boolean): number;
65
- /** Wilds scale with the bag; doubling the tile set doubles the wild count too. */
122
+ /** Wilds scale with the bag; doubling the tile set doubles the wild count too.
123
+ *
124
+ * @param hand - The hand size or tile codes, as declared by the function signature.
125
+ * @param level - The difficulty that determines the wildcard allowance.
126
+ * @param totalTiles - The total number of physical tiles in this bag.
127
+ * @returns Wilds scale with the bag; doubling the tile set doubles the wild count too.
128
+ * @example
129
+ * ```ts
130
+ * import { kumimojiWildCount, kumimojiTileCount } from "@johnmorrisdotca/kumimoji";
131
+ *
132
+ * console.log(kumimojiWildCount(7,"easy",kumimojiTileCount(7,"short")));
133
+ * ```
134
+ */
66
135
  export declare function kumimojiWildCount(hand: number, level: "easy" | "medium" | "hard", totalTiles: number): number;
67
- /** How many tiles one Draw takes from the bag, once the hand is used and the grid is sound. */
136
+ /** How many tiles one Draw takes from the bag, once the hand is used and the grid is sound.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { KUMIMOJI_DRAW } from "@johnmorrisdotca/kumimoji";
141
+ * console.log(KUMIMOJI_DRAW);
142
+ * ```
143
+ */
68
144
  export declare const KUMIMOJI_DRAW = 1;
69
145
  /**
70
146
  * THE TRADE: one awkward tile back into the bag for three new ones — the
71
147
  * classic way out of a hand of Q, X and J. The tile given back goes to the
72
148
  * bottom of the bag, so it comes round again before the end; offered only
73
149
  * while the bag has three to give.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * import { KUMIMOJI_TRADE } from "@johnmorrisdotca/kumimoji";
154
+ * console.log(KUMIMOJI_TRADE);
155
+ * ```
74
156
  */
75
157
  export declare const KUMIMOJI_TRADE: {
76
158
  readonly give: 1;
@@ -82,6 +164,12 @@ export declare const KUMIMOJI_TRADE: {
82
164
  * speed, which falls away evenly until a game that took half a minute a tile
83
165
  * earns no speed at all. A Classic game of fifty tiles in ten minutes is
84
166
  * 500 + 300 = 800. The time is the browser's clock, as every solo time here is.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { KUMIMOJI_SCORE } from "@johnmorrisdotca/kumimoji";
171
+ * console.log(KUMIMOJI_SCORE);
172
+ * ```
85
173
  */
86
174
  export declare const KUMIMOJI_SCORE: {
87
175
  readonly tile: 10;
@@ -99,6 +187,12 @@ export declare const KUMIMOJI_SCORE: {
99
187
  * set, and chooses it when the count reaches it (John, 2026-09-28: "when having
100
188
  * 6 or more players, we should recommend the double size 288 version"); in
101
189
  * Japanese, which has no Double, the Full game instead.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * import { KUMIMOJI_PARTY } from "@johnmorrisdotca/kumimoji";
194
+ * console.log(KUMIMOJI_PARTY);
195
+ * ```
102
196
  */
103
197
  export declare const KUMIMOJI_PARTY: {
104
198
  readonly least: 2;
@@ -13,6 +13,12 @@
13
13
  *
14
14
  * To tune the letters, change the counts here. The total is checked by
15
15
  * `tiles.test.ts`, so an edit that loses a tile says so.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { TILE_MIX } from "@johnmorrisdotca/kumimoji";
20
+ * console.log(TILE_MIX);
21
+ * ```
16
22
  */
17
23
  export const TILE_MIX = {
18
24
  a: 13, b: 3, c: 3, d: 6, e: 18, f: 3, g: 4, h: 3, i: 12, j: 2, k: 2, l: 5, m: 3,
@@ -31,6 +37,12 @@ export const TILE_MIX = {
31
37
  * Fixed here rather than taken from the monthly dictionary refresh, which
32
38
  * prints what it measures beside this table (`scripts/word-lists-ja.mjs`): a
33
39
  * kept game's bag is checked against these counts.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import { JAPANESE_TILE_MIX } from "@johnmorrisdotca/kumimoji";
44
+ * console.log(JAPANESE_TILE_MIX);
45
+ * ```
34
46
  */
35
47
  export const JAPANESE_TILE_MIX = {
36
48
  あ: 2, い: 11, う: 12, え: 1, お: 2, か: 7, き: 6, く: 6, け: 3, こ: 4,
@@ -39,7 +51,14 @@ export const JAPANESE_TILE_MIX = {
39
51
  ま: 2, み: 1, む: 1, め: 1, も: 1, や: 2, ゆ: 4, よ: 6, ら: 1, り: 3,
40
52
  る: 3, れ: 1, ろ: 1, わ: 1, ん: 11,
41
53
  };
42
- /** The whole set, counted from the table. */
54
+ /** The whole set, counted from the table.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { TILE_MIX_TOTAL } from "@johnmorrisdotca/kumimoji";
59
+ * console.log(TILE_MIX_TOTAL);
60
+ * ```
61
+ */
43
62
  export const TILE_MIX_TOTAL = Object.values(TILE_MIX).reduce((sum, count) => sum + count, 0);
44
63
  /**
45
64
  * THERE IS NO BOARD. John, 2026-09-26: "curious if we just have a large board
@@ -48,6 +67,12 @@ export const TILE_MIX_TOTAL = Object.values(TILE_MIX).reduce((sum, count) => sum
48
67
  * grows with them (`tableView.ts`), so a grid is as wide and as tall as its
49
68
  * player builds it. This is only the most a finished grid may measure either
50
69
  * way before the check refuses it unread: fifty tiles in one line is fifty.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { KUMIMOJI_GRID_MOST } from "@johnmorrisdotca/kumimoji";
74
+ * console.log(KUMIMOJI_GRID_MOST);
75
+ * ```
51
76
  */
52
77
  export const KUMIMOJI_GRID_MOST = 60;
53
78
  /**
@@ -55,24 +80,56 @@ export const KUMIMOJI_GRID_MOST = 60;
55
80
  * 2026-09-26: "you were given seven or 11 starting tiles". Three is for the
56
81
  * browser tests alone — a game that can be finished in a few presses — and is
57
82
  * never offered on the set-up screen.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { KUMIMOJI_HANDS } from "@johnmorrisdotca/kumimoji";
87
+ * console.log(KUMIMOJI_HANDS);
88
+ * ```
58
89
  */
59
90
  export const KUMIMOJI_HANDS = { tiny: 3, quick: 7, classic: 11 };
60
91
  /**
61
92
  * SHORT GAME TOTALS, by opening hand. Medium and Full derive from the tile
62
93
  * inventory in `kumimojiTileCount`; these stay the existing Short lengths.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { KUMIMOJI_BAG } from "@johnmorrisdotca/kumimoji";
98
+ * console.log(KUMIMOJI_BAG);
99
+ * ```
63
100
  */
64
101
  export const KUMIMOJI_BAG = {
65
102
  [KUMIMOJI_HANDS.tiny]: 5,
66
103
  [KUMIMOJI_HANDS.quick]: 40,
67
104
  [KUMIMOJI_HANDS.classic]: 50,
68
105
  };
69
- /** Wild tiles per original 40/50-tile game, included within the bag total. */
106
+ /** Wild tiles per original 40/50-tile game, included within the bag total.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { KUMIMOJI_WILDS } from "@johnmorrisdotca/kumimoji";
111
+ * console.log(KUMIMOJI_WILDS);
112
+ * ```
113
+ */
70
114
  export const KUMIMOJI_WILDS = {
71
115
  [KUMIMOJI_HANDS.tiny]: { easy: 0, medium: 0, hard: 0 },
72
116
  [KUMIMOJI_HANDS.quick]: { easy: 6, medium: 3, hard: 0 },
73
117
  [KUMIMOJI_HANDS.classic]: { easy: 8, medium: 4, hard: 0 },
74
118
  };
75
- /** Tile count for a selected length and inventory size. Double supplies two sets. */
119
+ /** Tile count for a selected length and inventory size. Double supplies two sets.
120
+ *
121
+ * @param hand - The hand size or tile codes, as declared by the function signature.
122
+ * @param length - The game length or decoded word length, as declared.
123
+ * @param setSize - The number of physical tiles in the language set.
124
+ * @param doubleSet - Whether to use two English tile sets.
125
+ * @returns Tile count for a selected length and inventory size. Double supplies two sets.
126
+ * @example
127
+ * ```ts
128
+ * import { kumimojiTileCount } from "@johnmorrisdotca/kumimoji";
129
+ *
130
+ * console.log(kumimojiTileCount(7,"short"));
131
+ * ```
132
+ */
76
133
  export function kumimojiTileCount(hand, length, setSize = TILE_MIX_TOTAL, doubleSet = false) {
77
134
  const short = KUMIMOJI_BAG[hand];
78
135
  if (short === undefined)
@@ -89,7 +146,19 @@ export function kumimojiTileCount(hand, length, setSize = TILE_MIX_TOTAL, double
89
146
  return Math.floor(available / 2);
90
147
  return available;
91
148
  }
92
- /** Wilds scale with the bag; doubling the tile set doubles the wild count too. */
149
+ /** Wilds scale with the bag; doubling the tile set doubles the wild count too.
150
+ *
151
+ * @param hand - The hand size or tile codes, as declared by the function signature.
152
+ * @param level - The difficulty that determines the wildcard allowance.
153
+ * @param totalTiles - The total number of physical tiles in this bag.
154
+ * @returns Wilds scale with the bag; doubling the tile set doubles the wild count too.
155
+ * @example
156
+ * ```ts
157
+ * import { kumimojiWildCount, kumimojiTileCount } from "@johnmorrisdotca/kumimoji";
158
+ *
159
+ * console.log(kumimojiWildCount(7,"easy",kumimojiTileCount(7,"short")));
160
+ * ```
161
+ */
93
162
  export function kumimojiWildCount(hand, level, totalTiles) {
94
163
  const short = KUMIMOJI_BAG[hand];
95
164
  const wilds = KUMIMOJI_WILDS[hand];
@@ -99,13 +168,26 @@ export function kumimojiWildCount(hand, level, totalTiles) {
99
168
  throw new Error(`Invalid Kumimoji tile count: ${totalTiles}.`);
100
169
  return Math.round((wilds[level] * totalTiles) / short);
101
170
  }
102
- /** How many tiles one Draw takes from the bag, once the hand is used and the grid is sound. */
171
+ /** How many tiles one Draw takes from the bag, once the hand is used and the grid is sound.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * import { KUMIMOJI_DRAW } from "@johnmorrisdotca/kumimoji";
176
+ * console.log(KUMIMOJI_DRAW);
177
+ * ```
178
+ */
103
179
  export const KUMIMOJI_DRAW = 1;
104
180
  /**
105
181
  * THE TRADE: one awkward tile back into the bag for three new ones — the
106
182
  * classic way out of a hand of Q, X and J. The tile given back goes to the
107
183
  * bottom of the bag, so it comes round again before the end; offered only
108
184
  * while the bag has three to give.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * import { KUMIMOJI_TRADE } from "@johnmorrisdotca/kumimoji";
189
+ * console.log(KUMIMOJI_TRADE);
190
+ * ```
109
191
  */
110
192
  export const KUMIMOJI_TRADE = { give: 1, take: 3 };
111
193
  /**
@@ -114,6 +196,12 @@ export const KUMIMOJI_TRADE = { give: 1, take: 3 };
114
196
  * speed, which falls away evenly until a game that took half a minute a tile
115
197
  * earns no speed at all. A Classic game of fifty tiles in ten minutes is
116
198
  * 500 + 300 = 800. The time is the browser's clock, as every solo time here is.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * import { KUMIMOJI_SCORE } from "@johnmorrisdotca/kumimoji";
203
+ * console.log(KUMIMOJI_SCORE);
204
+ * ```
117
205
  */
118
206
  export const KUMIMOJI_SCORE = { tile: 10, slowestMsATile: 30000 };
119
207
  /**
@@ -128,5 +216,11 @@ export const KUMIMOJI_SCORE = { tile: 10, slowestMsATile: 30000 };
128
216
  * set, and chooses it when the count reaches it (John, 2026-09-28: "when having
129
217
  * 6 or more players, we should recommend the double size 288 version"); in
130
218
  * Japanese, which has no Double, the Full game instead.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * import { KUMIMOJI_PARTY } from "@johnmorrisdotca/kumimoji";
223
+ * console.log(KUMIMOJI_PARTY);
224
+ * ```
131
225
  */
132
226
  export const KUMIMOJI_PARTY = { least: 2, most: 8, nameMost: 20, doubleFrom: 6 };