@johnmorrisdotca/kumimoji 1.2.2 → 1.3.1
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.
- package/CHANGELOG.md +33 -1
- package/CONTRIBUTING.md +11 -2
- package/README.md +80 -39
- package/dist/check.d.ts +26 -1
- package/dist/check.js +30 -3
- package/dist/computer.types.d.ts +24 -2
- package/dist/computerPlay.d.ts +45 -2
- package/dist/computerPlay.js +56 -6
- package/dist/computerTurn.d.ts +42 -3
- package/dist/computerTurn.js +47 -5
- package/dist/daily.d.ts +22 -2
- package/dist/daily.js +23 -3
- package/dist/element-define.d.ts +1 -1
- package/dist/element-define.js +3 -13
- package/dist/element.d.ts +85 -4
- package/dist/element.js +359 -77
- package/dist/embed-day.d.ts +4 -0
- package/dist/embed-day.js +23 -0
- package/dist/export.d.ts +123 -6
- package/dist/export.js +109 -9
- package/dist/generate.d.ts +14 -0
- package/dist/generate.js +32 -5
- package/dist/grid.d.ts +181 -10
- package/dist/grid.js +148 -11
- package/dist/help.d.ts +36 -3
- package/dist/help.js +36 -3
- package/dist/index.d.ts +22 -22
- package/dist/index.js +22 -22
- package/dist/judge.d.ts +14 -0
- package/dist/judge.js +14 -0
- package/dist/kana.d.ts +23 -1
- package/dist/kana.js +62 -7
- package/dist/kumimoji.types.d.ts +70 -5
- package/dist/party.d.ts +268 -14
- package/dist/party.js +296 -19
- package/dist/party.types.d.ts +50 -2
- package/dist/partyKept.d.ts +74 -4
- package/dist/partyKept.js +127 -12
- package/dist/partySeats.d.ts +92 -6
- package/dist/partySeats.js +83 -8
- package/dist/partyTurns.d.ts +171 -5
- package/dist/partyTurns.js +187 -8
- package/dist/placement.d.ts +50 -2
- package/dist/placement.js +35 -2
- package/dist/play.d.ts +247 -15
- package/dist/play.js +251 -18
- package/dist/random.d.ts +34 -3
- package/dist/random.js +23 -2
- package/dist/react.d.ts +42 -4
- package/dist/react.js +54 -7
- package/dist/showcase.d.ts +83 -7
- package/dist/showcase.js +61 -7
- package/dist/strings.d.ts +54 -5
- package/dist/strings.js +34 -3
- package/dist/tableView.d.ts +151 -8
- package/dist/tableView.js +129 -6
- package/dist/tileFace.d.ts +59 -5
- package/dist/tileFace.js +48 -4
- package/dist/tileFamily.d.ts +9 -0
- package/dist/tileFamily.js +9 -0
- package/dist/tileWords.d.ts +93 -6
- package/dist/tileWords.js +94 -12
- package/dist/tileWordsModule.d.ts +12 -2
- package/dist/tileWordsModule.js +14 -2
- package/dist/tiles.constants.d.ts +99 -5
- package/dist/tiles.constants.js +171 -13
- package/dist/turn.d.ts +82 -4
- package/dist/turn.js +88 -5
- package/dist/ui/board.d.ts +60 -5
- package/dist/ui/board.js +44 -4
- package/dist/ui/draw.d.ts +62 -0
- package/dist/ui/draw.js +229 -0
- package/dist/ui/mount.d.ts +41 -2
- package/dist/ui/mount.js +190 -265
- package/dist/ui/style.d.ts +6 -1
- package/dist/ui/style.js +6 -0
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/version.d.ts +9 -2
- package/dist/version.js +9 -2
- package/dist/wilds.d.ts +22 -1
- package/dist/wilds.js +25 -3
- package/package.json +68 -61
package/dist/tileWords.d.ts
CHANGED
|
@@ -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();
|
|
@@ -30,7 +51,7 @@ export function unpackTileWords(data) {
|
|
|
30
51
|
}
|
|
31
52
|
const letters = [...Object.keys(TILE_MIX)];
|
|
32
53
|
const assigned = new Map(letters.map((letter) => [letter.toUpperCase(), letter]));
|
|
33
|
-
const soundOf = (tile) =>
|
|
54
|
+
const soundOf = (tile) => tile === "*" ? null : (assigned.get(tile) ?? (/^[a-z]$/.test(tile) ? tile : null));
|
|
34
55
|
const isWild = (tile) => tile === "*" || assigned.has(tile);
|
|
35
56
|
return {
|
|
36
57
|
language: "english",
|
|
@@ -73,8 +94,12 @@ function unpackJapaneseWords(data) {
|
|
|
73
94
|
allowed.add([...word].map((tile) => tileFace(tile).glyph).join(""));
|
|
74
95
|
}
|
|
75
96
|
const mix = new Map(Object.entries(JAPANESE_TILE_MIX).map(([face, count]) => [kanaTileCode(face), count]));
|
|
76
|
-
const isTile = (tile) => tile.length === 1 &&
|
|
77
|
-
|
|
97
|
+
const isTile = (tile) => tile.length === 1 &&
|
|
98
|
+
tile.codePointAt(0) - KANA_TILE_START >= 0 &&
|
|
99
|
+
tile.codePointAt(0) - KANA_TILE_START < kana.length;
|
|
100
|
+
const isAssignedWild = (tile) => tile.length === 1 &&
|
|
101
|
+
tile.codePointAt(0) - KANA_WILD_START >= 0 &&
|
|
102
|
+
tile.codePointAt(0) - KANA_WILD_START < kana.length;
|
|
78
103
|
const isWild = (tile) => tile === "*" || isAssignedWild(tile);
|
|
79
104
|
const soundOf = (tile) => (isTile(tile) || isAssignedWild(tile) ? tileFace(tile).glyph : null);
|
|
80
105
|
const identity = (tile) => (isWild(tile) ? "*" : isTile(tile) ? tileFace(tile).glyph : null);
|
|
@@ -111,11 +136,34 @@ function unpackJapaneseWords(data) {
|
|
|
111
136
|
* loader that imports them (`tileWordsModule.ts`). Null until one does.
|
|
112
137
|
*/
|
|
113
138
|
let fromModule = null;
|
|
114
|
-
/** Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
|
|
139
|
+
/** Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
|
|
140
|
+
*
|
|
141
|
+
* @param source - The asynchronous loader that supplies the language word list.
|
|
142
|
+
* @returns Used by `tileWordsModule.ts` only: how to read a list where there is no browser.
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* import { loadTileWords, readTileWordsWith, tileWordsFrom } from "@johnmorrisdotca/kumimoji";
|
|
146
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
147
|
+
*
|
|
148
|
+
* readTileWordsWith(async language => tileWordsFrom(language,{3:"0cat2r"}));
|
|
149
|
+
* console.log((await loadTileWords("english")).allowed.has("cat"));
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
115
152
|
export function readTileWordsWith(source) {
|
|
116
153
|
fromModule = source;
|
|
117
154
|
}
|
|
118
|
-
/** A list read from its module, for `tileWordsModule.ts`.
|
|
155
|
+
/** A list read from its module, for `tileWordsModule.ts`.
|
|
156
|
+
*
|
|
157
|
+
* @param language - The English or Japanese tile language.
|
|
158
|
+
* @param data - The packed language-list data to decode.
|
|
159
|
+
* @returns A list read from its module, for `tileWordsModule.ts`.
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { tileWordsFrom } from "@johnmorrisdotca/kumimoji";
|
|
163
|
+
*
|
|
164
|
+
* console.log(tileWordsFrom("english",{3:"0cat2r"}).allowed.size);
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
119
167
|
export function tileWordsFrom(language, data) {
|
|
120
168
|
return language === "english"
|
|
121
169
|
? unpackTileWords(data)
|
|
@@ -134,6 +182,17 @@ export function tileWordsFrom(language, data) {
|
|
|
134
182
|
* branch, and the import with it, is gone before anything is traced. The
|
|
135
183
|
* server reads the list through `tileWordsModule.ts` instead, which only the
|
|
136
184
|
* server's own checks and the tests import.
|
|
185
|
+
*
|
|
186
|
+
* @param language - The English or Japanese tile language.
|
|
187
|
+
* @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.
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* import { loadTileWords } from "@johnmorrisdotca/kumimoji";
|
|
191
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
192
|
+
*
|
|
193
|
+
* await loadTileWordsFromModule("english");
|
|
194
|
+
* console.log((await loadTileWords("english")).allowed.size);
|
|
195
|
+
* ```
|
|
137
196
|
*/
|
|
138
197
|
export async function loadTileWords(language = "english") {
|
|
139
198
|
const already = loaded.get(language);
|
|
@@ -141,9 +200,10 @@ export async function loadTileWords(language = "english") {
|
|
|
141
200
|
return already;
|
|
142
201
|
let words;
|
|
143
202
|
if (typeof window !== "undefined") {
|
|
144
|
-
words =
|
|
145
|
-
|
|
146
|
-
|
|
203
|
+
words =
|
|
204
|
+
language === "english"
|
|
205
|
+
? unpackTileWords((await import("./words.en.data.js")).TILE_WORDS_EN)
|
|
206
|
+
: unpackJapaneseWords((await import("./words.ja.data.js")).TILE_WORDS_JA);
|
|
147
207
|
}
|
|
148
208
|
else {
|
|
149
209
|
if (fromModule === null)
|
|
@@ -153,14 +213,36 @@ export async function loadTileWords(language = "english") {
|
|
|
153
213
|
loaded.set(language, words);
|
|
154
214
|
return words;
|
|
155
215
|
}
|
|
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.
|
|
216
|
+
/** 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.
|
|
217
|
+
*
|
|
218
|
+
* @param language - The English or Japanese tile language.
|
|
219
|
+
* @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.
|
|
220
|
+
* @example
|
|
221
|
+
* ```ts
|
|
222
|
+
* import { tileWords } from "@johnmorrisdotca/kumimoji";
|
|
223
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
224
|
+
*
|
|
225
|
+
* await loadTileWordsFromModule("english");
|
|
226
|
+
* console.log(tileWords("english").allowed.has("cat"));
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
157
229
|
export function tileWords(language = "english") {
|
|
158
230
|
const words = loaded.get(language);
|
|
159
231
|
if (words === undefined)
|
|
160
232
|
throw new Error(`The ${language} Kumimoji words have not been loaded (loadTileWords).`);
|
|
161
233
|
return words;
|
|
162
234
|
}
|
|
163
|
-
/** Whether the list has been fetched yet, for a page to say "loading" rather than throw.
|
|
235
|
+
/** Whether the list has been fetched yet, for a page to say "loading" rather than throw.
|
|
236
|
+
*
|
|
237
|
+
* @param language - The English or Japanese tile language.
|
|
238
|
+
* @returns Whether the list has been fetched yet, for a page to say "loading" rather than throw.
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { tileWordsReady } from "@johnmorrisdotca/kumimoji";
|
|
242
|
+
*
|
|
243
|
+
* console.log(tileWordsReady("english"));
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
164
246
|
export function tileWordsReady(language = "english") {
|
|
165
247
|
return loaded.has(language);
|
|
166
248
|
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { type TileWords } from "./tileWords.ts";
|
|
2
1
|
import type { KumimojiLanguage } from "./kumimoji.types.ts";
|
|
3
|
-
|
|
2
|
+
import { type TileWords } from "./tileWords.ts";
|
|
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>;
|
package/dist/tileWordsModule.js
CHANGED
|
@@ -6,8 +6,20 @@ import { loadTileWords, readTileWordsWith, tileWordsFrom } from "./tileWords.js"
|
|
|
6
6
|
* page's components never import it, so no page's server function carries the
|
|
7
7
|
* lists for the browser's sake (see `loadTileWords`).
|
|
8
8
|
*/
|
|
9
|
-
readTileWordsWith(async (language) => tileWordsFrom(language, language === "english"
|
|
10
|
-
|
|
9
|
+
readTileWordsWith(async (language) => tileWordsFrom(language, language === "english"
|
|
10
|
+
? (await import("./words.en.data.js")).TILE_WORDS_EN
|
|
11
|
+
: (await import("./words.ja.data.js")).TILE_WORDS_JA));
|
|
12
|
+
/** The list, read from its module: `loadTileWords` for a caller with no browser.
|
|
13
|
+
*
|
|
14
|
+
* @param language - The English or Japanese tile language.
|
|
15
|
+
* @returns The list, read from its module: `loadTileWords` for a caller with no browser.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { loadTileWordsFromModule } from "@johnmorrisdotca/kumimoji/words";
|
|
19
|
+
*
|
|
20
|
+
* console.log((await loadTileWordsFromModule("english")).allowed.size);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
11
23
|
export function loadTileWordsFromModule(language = "english") {
|
|
12
24
|
return loadTileWords(language);
|
|
13
25
|
}
|
|
@@ -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;
|