packing-bingo 0.4.0 → 0.6.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.
- package/README.md +114 -24
- package/dist/{chunk-BAA2CFUA.js → chunk-A5JVNVWS.js} +821 -95
- package/dist/core.cjs +825 -97
- package/dist/core.d.cts +141 -5
- package/dist/core.d.ts +141 -5
- package/dist/core.js +7 -3
- package/dist/index.cjs +842 -103
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +24 -9
- package/dist/packing-bingo.global.js +127 -30
- package/package.json +4 -1
package/dist/core.d.cts
CHANGED
|
@@ -35,6 +35,56 @@ interface Messages {
|
|
|
35
35
|
shuffle: string;
|
|
36
36
|
soundOn: string;
|
|
37
37
|
soundOff: string;
|
|
38
|
+
/** The big line on the gray start screen over the card (with the `ready` option). */
|
|
39
|
+
readyTitle?: string;
|
|
40
|
+
/** A line under it; empty (not shown) by default. */
|
|
41
|
+
readyPrompt?: string;
|
|
42
|
+
/** Volume reminder on the start screen; an empty string hides it. */
|
|
43
|
+
soundHint?: string;
|
|
44
|
+
/** Android Do Not Disturb reminder; hidden when vibration is disabled or this is empty. */
|
|
45
|
+
vibrationHint?: string;
|
|
46
|
+
/** The "tap to start" cue on the start screen. */
|
|
47
|
+
readyTap?: string;
|
|
48
|
+
/** Shown after the 3, 2, 1 countdown, as the stopwatch starts. */
|
|
49
|
+
readyGo?: string;
|
|
50
|
+
/** Label of the stopwatch, read out by screen readers. */
|
|
51
|
+
time?: string;
|
|
52
|
+
/** Before the finishing time on the perfect card. */
|
|
53
|
+
statTime?: string;
|
|
54
|
+
/** Floats up with the points for the clear time (`speedBonus`). */
|
|
55
|
+
speedBonus?: (points: number) => string;
|
|
56
|
+
/** Label of the mode switch, read out by screen readers. */
|
|
57
|
+
modeLabel?: string;
|
|
58
|
+
/** The mode switch's choice for the normal card. */
|
|
59
|
+
modeNormal?: string;
|
|
60
|
+
/** The mode switch's choice for the infinite mode. */
|
|
61
|
+
modeInfinite?: string;
|
|
62
|
+
/** The big word that sweeps over the card when the normal mode is chosen. */
|
|
63
|
+
normalTitle?: string;
|
|
64
|
+
/** The line under it. */
|
|
65
|
+
normalSub?: string;
|
|
66
|
+
/** The big word that sweeps over the card when the infinite mode is chosen. */
|
|
67
|
+
infiniteTitle?: string;
|
|
68
|
+
/** The line under it, also shown in the start screen's badge in the infinite mode. */
|
|
69
|
+
infiniteSub?: string;
|
|
70
|
+
/** The rule, shown on the start screen in the infinite mode; an empty string hides it. */
|
|
71
|
+
infiniteRule?: string;
|
|
72
|
+
/** The button that ends an infinite game and shows its results. */
|
|
73
|
+
finish?: string;
|
|
74
|
+
/** Title of the infinite game's results. */
|
|
75
|
+
finishTitle?: string;
|
|
76
|
+
/** Text inside the round medal on those results; `\n` starts a new line. */
|
|
77
|
+
finishStamp?: string;
|
|
78
|
+
/** Before the time played on those results. */
|
|
79
|
+
finishTime?: string;
|
|
80
|
+
/** The results' button that starts a new infinite game. */
|
|
81
|
+
again?: string;
|
|
82
|
+
/** @deprecated Ignored since 0.6.0: the pre-play popup became the start screen (see `readyTitle`). */
|
|
83
|
+
playTitle?: string;
|
|
84
|
+
/** @deprecated Ignored since 0.6.0. */
|
|
85
|
+
playStart?: string;
|
|
86
|
+
/** @deprecated Ignored since 0.6.0. */
|
|
87
|
+
playSkip?: string;
|
|
38
88
|
stamp: string;
|
|
39
89
|
/** Text on the FREE square in the center (with `free`). */
|
|
40
90
|
free: string;
|
|
@@ -77,14 +127,37 @@ declare const en: Messages;
|
|
|
77
127
|
* For other sizes, use `bingoLines(size, free)`.
|
|
78
128
|
*/
|
|
79
129
|
declare const LINES: readonly (readonly number[])[];
|
|
130
|
+
/**
|
|
131
|
+
* "normal": the packing card. "infinite": an endless game on the same squares; completed lines
|
|
132
|
+
* clear so they can be filled again. It never touches the packing checks.
|
|
133
|
+
*/
|
|
134
|
+
type BingoMode = "normal" | "infinite";
|
|
80
135
|
interface PackingBingoState {
|
|
81
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* One boolean per item, row by row (the FREE square is not included). In the infinite mode,
|
|
138
|
+
* the squares of that game, not the packing checks.
|
|
139
|
+
*/
|
|
82
140
|
checked: boolean[];
|
|
83
141
|
/** The completed lines, as indices into `bingoLines(size, free)`. */
|
|
84
142
|
lines: number[];
|
|
85
143
|
score: number;
|
|
86
144
|
maxCombo: number;
|
|
145
|
+
/** Every item is checked (always false in the infinite mode). */
|
|
87
146
|
complete: boolean;
|
|
147
|
+
/** The mode on the card. */
|
|
148
|
+
mode: BingoMode;
|
|
149
|
+
/** Lines completed in this infinite game (each one clears); 0 in the normal mode. */
|
|
150
|
+
cleared: number;
|
|
151
|
+
/** The infinite game was ended with FINISH (its squares are locked until a new game). */
|
|
152
|
+
finished: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* In the infinite mode, the packing card waiting behind the game: its checks and arrangement,
|
|
155
|
+
* as they will be when the card switches back. Null in the normal mode.
|
|
156
|
+
*/
|
|
157
|
+
packing: {
|
|
158
|
+
checked: boolean[];
|
|
159
|
+
order: number[];
|
|
160
|
+
} | null;
|
|
88
161
|
/** Squares per side. */
|
|
89
162
|
size: number;
|
|
90
163
|
/** Whether the center is a FREE square. */
|
|
@@ -94,16 +167,34 @@ interface PackingBingoState {
|
|
|
94
167
|
* is shuffled. Line `k` holds the items `bingoLines(size, free)[k].map((s) => order[s])`.
|
|
95
168
|
*/
|
|
96
169
|
order: number[];
|
|
170
|
+
/** The stopwatch in milliseconds: running since the countdown (or the first tap), frozen once the card is complete. */
|
|
171
|
+
time: number;
|
|
97
172
|
}
|
|
98
173
|
interface BingoEvent {
|
|
99
174
|
/** Lines (indices into `bingoLines(size, free)`, which is LINES for 4×4) completed by this change. */
|
|
100
175
|
newLines: number[];
|
|
176
|
+
/** Lines complete on the card; in the infinite mode, lines completed in this game. */
|
|
101
177
|
totalLines: number;
|
|
102
178
|
score: number;
|
|
179
|
+
/** The mode it happened in. */
|
|
180
|
+
mode: BingoMode;
|
|
103
181
|
}
|
|
104
182
|
interface PerfectEvent {
|
|
105
183
|
score: number;
|
|
106
184
|
maxCombo: number;
|
|
185
|
+
/** The stopwatch when the card was completed, in milliseconds; null if this game was not timed. */
|
|
186
|
+
time: number | null;
|
|
187
|
+
/** Points `score` got for the clear time (see `speedBonus`); 0 if none were given. */
|
|
188
|
+
speedBonus: number;
|
|
189
|
+
}
|
|
190
|
+
/** An infinite game ended with FINISH. */
|
|
191
|
+
interface FinishEvent {
|
|
192
|
+
score: number;
|
|
193
|
+
maxCombo: number;
|
|
194
|
+
/** Lines completed in the game. */
|
|
195
|
+
lines: number;
|
|
196
|
+
/** The stopwatch when it ended, in milliseconds. */
|
|
197
|
+
time: number;
|
|
107
198
|
}
|
|
108
199
|
interface PackingBingoOptions {
|
|
109
200
|
/**
|
|
@@ -153,7 +244,7 @@ interface PackingBingoOptions {
|
|
|
153
244
|
*/
|
|
154
245
|
defaultOrder?: readonly number[];
|
|
155
246
|
/**
|
|
156
|
-
* Buzz on phones (default true):
|
|
247
|
+
* Buzz on phones (default true): escalating combo taps and distinct patterns for a reach, a bingo, a
|
|
157
248
|
* perfect card and a shuffle where the Vibration API exists (Android), and the system tap
|
|
158
249
|
* haptic on iPhone (iOS 18 and later), which only follows a real tap.
|
|
159
250
|
*/
|
|
@@ -163,11 +254,36 @@ interface PackingBingoOptions {
|
|
|
163
254
|
* M PLUS Rounded 1c, load them on the page (see the README's フォント section).
|
|
164
255
|
*/
|
|
165
256
|
fonts?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Start each game on a see-through dark screen over the whole card ("Are you ready?" with the
|
|
259
|
+
* volume and Do Not Disturb reminders); a tap counts down 3, 2, 1 and starts the stopwatch
|
|
260
|
+
* (default true). With false, the stopwatch starts on the first tap.
|
|
261
|
+
*/
|
|
262
|
+
ready?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Let a tap on a stamped square take the stamp off again (default false). By default a
|
|
265
|
+
* stamped square stays stamped when tapped; `reset()`, `setChecked` and controlled `checked`
|
|
266
|
+
* can still clear it.
|
|
267
|
+
*/
|
|
268
|
+
uncheck?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* The mode to start in (default "normal"). "infinite" is an endless game on the same squares:
|
|
271
|
+
* every completed line clears after its celebration, so it can be filled again, and the
|
|
272
|
+
* score keeps growing. It neither changes nor saves the packing checks, and calls no
|
|
273
|
+
* `onChange`; switching back to "normal" brings the packing card back as it was.
|
|
274
|
+
*/
|
|
275
|
+
mode?: BingoMode;
|
|
276
|
+
/** Show the NORMAL / ∞ INFINITE switch in the header (default true). */
|
|
277
|
+
modeSwitch?: boolean;
|
|
166
278
|
/** Pre-fill a few items and show demo buttons. */
|
|
167
279
|
demo?: boolean;
|
|
168
280
|
onChange?: (checked: boolean[]) => void;
|
|
169
281
|
onBingo?: (event: BingoEvent) => void;
|
|
170
282
|
onPerfect?: (event: PerfectEvent) => void;
|
|
283
|
+
/** The mode was changed, with the switch or `setMode`. */
|
|
284
|
+
onModeChange?: (mode: BingoMode) => void;
|
|
285
|
+
/** An infinite game was ended with the 🏁 FINISH button or `finish()`. */
|
|
286
|
+
onFinish?: (event: FinishEvent) => void;
|
|
171
287
|
}
|
|
172
288
|
interface PackingBingoInstance {
|
|
173
289
|
/**
|
|
@@ -177,21 +293,41 @@ interface PackingBingoInstance {
|
|
|
177
293
|
setChecked(next: readonly boolean[], options?: {
|
|
178
294
|
animate?: boolean;
|
|
179
295
|
}): void;
|
|
180
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* Clear the card and score (calls onChange), and put the items back in their own squares.
|
|
298
|
+
* In the infinite mode, like the reset button, it starts a new infinite game instead.
|
|
299
|
+
*/
|
|
181
300
|
reset(): void;
|
|
182
301
|
/**
|
|
183
302
|
* Move the items to random squares, as the 🔀 button does. Checks stay with their items; lines
|
|
184
303
|
* the new arrangement happens to complete count as done but earn no points.
|
|
185
304
|
*/
|
|
186
305
|
shuffle(): void;
|
|
306
|
+
/**
|
|
307
|
+
* Switch modes, as the switch does (with its animation). Each switch starts a new game: the
|
|
308
|
+
* stopwatch and score start over, and the packing checks and arrangement are kept.
|
|
309
|
+
*/
|
|
310
|
+
setMode(mode: BingoMode): void;
|
|
311
|
+
/**
|
|
312
|
+
* End a running infinite game, as the 🏁 FINISH button does: stop the stopwatch, lock the
|
|
313
|
+
* squares and show the results. Does nothing in the normal mode or before the game starts.
|
|
314
|
+
*/
|
|
315
|
+
finish(): void;
|
|
187
316
|
getState(): PackingBingoState;
|
|
188
317
|
/** Redraw the status text, e.g. after functions in `messages` start returning something else. */
|
|
189
318
|
refresh(): void;
|
|
190
319
|
/** Stop everything and remove the card from the container. */
|
|
191
320
|
destroy(): void;
|
|
192
321
|
}
|
|
322
|
+
/** Stopwatch text: 0:12.3 (or 1:02:03.4 past an hour); `digits` decimals of a second. */
|
|
323
|
+
declare function formatTime(ms: number, digits?: number): string;
|
|
324
|
+
/**
|
|
325
|
+
* Points for clearing a card of `items` items in `ms` milliseconds: 1000 per item per second,
|
|
326
|
+
* so it has no ceiling. Halving the time doubles it.
|
|
327
|
+
*/
|
|
328
|
+
declare function speedBonus(items: number, ms: number): number;
|
|
193
329
|
/** Render a packing bingo card into `container`. Call only in the browser. */
|
|
194
330
|
declare function createPackingBingo(container: HTMLElement, options?: PackingBingoOptions): PackingBingoInstance;
|
|
195
331
|
|
|
196
|
-
export { DEFAULT_ITEMS, LINES, bingoLines, createPackingBingo, en, ja };
|
|
197
|
-
export type { BingoEvent, BingoItem, Messages, PackingBingoInstance, PackingBingoOptions, PackingBingoState, PerfectEvent };
|
|
332
|
+
export { DEFAULT_ITEMS, LINES, bingoLines, createPackingBingo, en, formatTime, ja, speedBonus };
|
|
333
|
+
export type { BingoEvent, BingoItem, BingoMode, FinishEvent, Messages, PackingBingoInstance, PackingBingoOptions, PackingBingoState, PerfectEvent };
|
package/dist/core.d.ts
CHANGED
|
@@ -35,6 +35,56 @@ interface Messages {
|
|
|
35
35
|
shuffle: string;
|
|
36
36
|
soundOn: string;
|
|
37
37
|
soundOff: string;
|
|
38
|
+
/** The big line on the gray start screen over the card (with the `ready` option). */
|
|
39
|
+
readyTitle?: string;
|
|
40
|
+
/** A line under it; empty (not shown) by default. */
|
|
41
|
+
readyPrompt?: string;
|
|
42
|
+
/** Volume reminder on the start screen; an empty string hides it. */
|
|
43
|
+
soundHint?: string;
|
|
44
|
+
/** Android Do Not Disturb reminder; hidden when vibration is disabled or this is empty. */
|
|
45
|
+
vibrationHint?: string;
|
|
46
|
+
/** The "tap to start" cue on the start screen. */
|
|
47
|
+
readyTap?: string;
|
|
48
|
+
/** Shown after the 3, 2, 1 countdown, as the stopwatch starts. */
|
|
49
|
+
readyGo?: string;
|
|
50
|
+
/** Label of the stopwatch, read out by screen readers. */
|
|
51
|
+
time?: string;
|
|
52
|
+
/** Before the finishing time on the perfect card. */
|
|
53
|
+
statTime?: string;
|
|
54
|
+
/** Floats up with the points for the clear time (`speedBonus`). */
|
|
55
|
+
speedBonus?: (points: number) => string;
|
|
56
|
+
/** Label of the mode switch, read out by screen readers. */
|
|
57
|
+
modeLabel?: string;
|
|
58
|
+
/** The mode switch's choice for the normal card. */
|
|
59
|
+
modeNormal?: string;
|
|
60
|
+
/** The mode switch's choice for the infinite mode. */
|
|
61
|
+
modeInfinite?: string;
|
|
62
|
+
/** The big word that sweeps over the card when the normal mode is chosen. */
|
|
63
|
+
normalTitle?: string;
|
|
64
|
+
/** The line under it. */
|
|
65
|
+
normalSub?: string;
|
|
66
|
+
/** The big word that sweeps over the card when the infinite mode is chosen. */
|
|
67
|
+
infiniteTitle?: string;
|
|
68
|
+
/** The line under it, also shown in the start screen's badge in the infinite mode. */
|
|
69
|
+
infiniteSub?: string;
|
|
70
|
+
/** The rule, shown on the start screen in the infinite mode; an empty string hides it. */
|
|
71
|
+
infiniteRule?: string;
|
|
72
|
+
/** The button that ends an infinite game and shows its results. */
|
|
73
|
+
finish?: string;
|
|
74
|
+
/** Title of the infinite game's results. */
|
|
75
|
+
finishTitle?: string;
|
|
76
|
+
/** Text inside the round medal on those results; `\n` starts a new line. */
|
|
77
|
+
finishStamp?: string;
|
|
78
|
+
/** Before the time played on those results. */
|
|
79
|
+
finishTime?: string;
|
|
80
|
+
/** The results' button that starts a new infinite game. */
|
|
81
|
+
again?: string;
|
|
82
|
+
/** @deprecated Ignored since 0.6.0: the pre-play popup became the start screen (see `readyTitle`). */
|
|
83
|
+
playTitle?: string;
|
|
84
|
+
/** @deprecated Ignored since 0.6.0. */
|
|
85
|
+
playStart?: string;
|
|
86
|
+
/** @deprecated Ignored since 0.6.0. */
|
|
87
|
+
playSkip?: string;
|
|
38
88
|
stamp: string;
|
|
39
89
|
/** Text on the FREE square in the center (with `free`). */
|
|
40
90
|
free: string;
|
|
@@ -77,14 +127,37 @@ declare const en: Messages;
|
|
|
77
127
|
* For other sizes, use `bingoLines(size, free)`.
|
|
78
128
|
*/
|
|
79
129
|
declare const LINES: readonly (readonly number[])[];
|
|
130
|
+
/**
|
|
131
|
+
* "normal": the packing card. "infinite": an endless game on the same squares; completed lines
|
|
132
|
+
* clear so they can be filled again. It never touches the packing checks.
|
|
133
|
+
*/
|
|
134
|
+
type BingoMode = "normal" | "infinite";
|
|
80
135
|
interface PackingBingoState {
|
|
81
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* One boolean per item, row by row (the FREE square is not included). In the infinite mode,
|
|
138
|
+
* the squares of that game, not the packing checks.
|
|
139
|
+
*/
|
|
82
140
|
checked: boolean[];
|
|
83
141
|
/** The completed lines, as indices into `bingoLines(size, free)`. */
|
|
84
142
|
lines: number[];
|
|
85
143
|
score: number;
|
|
86
144
|
maxCombo: number;
|
|
145
|
+
/** Every item is checked (always false in the infinite mode). */
|
|
87
146
|
complete: boolean;
|
|
147
|
+
/** The mode on the card. */
|
|
148
|
+
mode: BingoMode;
|
|
149
|
+
/** Lines completed in this infinite game (each one clears); 0 in the normal mode. */
|
|
150
|
+
cleared: number;
|
|
151
|
+
/** The infinite game was ended with FINISH (its squares are locked until a new game). */
|
|
152
|
+
finished: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* In the infinite mode, the packing card waiting behind the game: its checks and arrangement,
|
|
155
|
+
* as they will be when the card switches back. Null in the normal mode.
|
|
156
|
+
*/
|
|
157
|
+
packing: {
|
|
158
|
+
checked: boolean[];
|
|
159
|
+
order: number[];
|
|
160
|
+
} | null;
|
|
88
161
|
/** Squares per side. */
|
|
89
162
|
size: number;
|
|
90
163
|
/** Whether the center is a FREE square. */
|
|
@@ -94,16 +167,34 @@ interface PackingBingoState {
|
|
|
94
167
|
* is shuffled. Line `k` holds the items `bingoLines(size, free)[k].map((s) => order[s])`.
|
|
95
168
|
*/
|
|
96
169
|
order: number[];
|
|
170
|
+
/** The stopwatch in milliseconds: running since the countdown (or the first tap), frozen once the card is complete. */
|
|
171
|
+
time: number;
|
|
97
172
|
}
|
|
98
173
|
interface BingoEvent {
|
|
99
174
|
/** Lines (indices into `bingoLines(size, free)`, which is LINES for 4×4) completed by this change. */
|
|
100
175
|
newLines: number[];
|
|
176
|
+
/** Lines complete on the card; in the infinite mode, lines completed in this game. */
|
|
101
177
|
totalLines: number;
|
|
102
178
|
score: number;
|
|
179
|
+
/** The mode it happened in. */
|
|
180
|
+
mode: BingoMode;
|
|
103
181
|
}
|
|
104
182
|
interface PerfectEvent {
|
|
105
183
|
score: number;
|
|
106
184
|
maxCombo: number;
|
|
185
|
+
/** The stopwatch when the card was completed, in milliseconds; null if this game was not timed. */
|
|
186
|
+
time: number | null;
|
|
187
|
+
/** Points `score` got for the clear time (see `speedBonus`); 0 if none were given. */
|
|
188
|
+
speedBonus: number;
|
|
189
|
+
}
|
|
190
|
+
/** An infinite game ended with FINISH. */
|
|
191
|
+
interface FinishEvent {
|
|
192
|
+
score: number;
|
|
193
|
+
maxCombo: number;
|
|
194
|
+
/** Lines completed in the game. */
|
|
195
|
+
lines: number;
|
|
196
|
+
/** The stopwatch when it ended, in milliseconds. */
|
|
197
|
+
time: number;
|
|
107
198
|
}
|
|
108
199
|
interface PackingBingoOptions {
|
|
109
200
|
/**
|
|
@@ -153,7 +244,7 @@ interface PackingBingoOptions {
|
|
|
153
244
|
*/
|
|
154
245
|
defaultOrder?: readonly number[];
|
|
155
246
|
/**
|
|
156
|
-
* Buzz on phones (default true):
|
|
247
|
+
* Buzz on phones (default true): escalating combo taps and distinct patterns for a reach, a bingo, a
|
|
157
248
|
* perfect card and a shuffle where the Vibration API exists (Android), and the system tap
|
|
158
249
|
* haptic on iPhone (iOS 18 and later), which only follows a real tap.
|
|
159
250
|
*/
|
|
@@ -163,11 +254,36 @@ interface PackingBingoOptions {
|
|
|
163
254
|
* M PLUS Rounded 1c, load them on the page (see the README's フォント section).
|
|
164
255
|
*/
|
|
165
256
|
fonts?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Start each game on a see-through dark screen over the whole card ("Are you ready?" with the
|
|
259
|
+
* volume and Do Not Disturb reminders); a tap counts down 3, 2, 1 and starts the stopwatch
|
|
260
|
+
* (default true). With false, the stopwatch starts on the first tap.
|
|
261
|
+
*/
|
|
262
|
+
ready?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Let a tap on a stamped square take the stamp off again (default false). By default a
|
|
265
|
+
* stamped square stays stamped when tapped; `reset()`, `setChecked` and controlled `checked`
|
|
266
|
+
* can still clear it.
|
|
267
|
+
*/
|
|
268
|
+
uncheck?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* The mode to start in (default "normal"). "infinite" is an endless game on the same squares:
|
|
271
|
+
* every completed line clears after its celebration, so it can be filled again, and the
|
|
272
|
+
* score keeps growing. It neither changes nor saves the packing checks, and calls no
|
|
273
|
+
* `onChange`; switching back to "normal" brings the packing card back as it was.
|
|
274
|
+
*/
|
|
275
|
+
mode?: BingoMode;
|
|
276
|
+
/** Show the NORMAL / ∞ INFINITE switch in the header (default true). */
|
|
277
|
+
modeSwitch?: boolean;
|
|
166
278
|
/** Pre-fill a few items and show demo buttons. */
|
|
167
279
|
demo?: boolean;
|
|
168
280
|
onChange?: (checked: boolean[]) => void;
|
|
169
281
|
onBingo?: (event: BingoEvent) => void;
|
|
170
282
|
onPerfect?: (event: PerfectEvent) => void;
|
|
283
|
+
/** The mode was changed, with the switch or `setMode`. */
|
|
284
|
+
onModeChange?: (mode: BingoMode) => void;
|
|
285
|
+
/** An infinite game was ended with the 🏁 FINISH button or `finish()`. */
|
|
286
|
+
onFinish?: (event: FinishEvent) => void;
|
|
171
287
|
}
|
|
172
288
|
interface PackingBingoInstance {
|
|
173
289
|
/**
|
|
@@ -177,21 +293,41 @@ interface PackingBingoInstance {
|
|
|
177
293
|
setChecked(next: readonly boolean[], options?: {
|
|
178
294
|
animate?: boolean;
|
|
179
295
|
}): void;
|
|
180
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* Clear the card and score (calls onChange), and put the items back in their own squares.
|
|
298
|
+
* In the infinite mode, like the reset button, it starts a new infinite game instead.
|
|
299
|
+
*/
|
|
181
300
|
reset(): void;
|
|
182
301
|
/**
|
|
183
302
|
* Move the items to random squares, as the 🔀 button does. Checks stay with their items; lines
|
|
184
303
|
* the new arrangement happens to complete count as done but earn no points.
|
|
185
304
|
*/
|
|
186
305
|
shuffle(): void;
|
|
306
|
+
/**
|
|
307
|
+
* Switch modes, as the switch does (with its animation). Each switch starts a new game: the
|
|
308
|
+
* stopwatch and score start over, and the packing checks and arrangement are kept.
|
|
309
|
+
*/
|
|
310
|
+
setMode(mode: BingoMode): void;
|
|
311
|
+
/**
|
|
312
|
+
* End a running infinite game, as the 🏁 FINISH button does: stop the stopwatch, lock the
|
|
313
|
+
* squares and show the results. Does nothing in the normal mode or before the game starts.
|
|
314
|
+
*/
|
|
315
|
+
finish(): void;
|
|
187
316
|
getState(): PackingBingoState;
|
|
188
317
|
/** Redraw the status text, e.g. after functions in `messages` start returning something else. */
|
|
189
318
|
refresh(): void;
|
|
190
319
|
/** Stop everything and remove the card from the container. */
|
|
191
320
|
destroy(): void;
|
|
192
321
|
}
|
|
322
|
+
/** Stopwatch text: 0:12.3 (or 1:02:03.4 past an hour); `digits` decimals of a second. */
|
|
323
|
+
declare function formatTime(ms: number, digits?: number): string;
|
|
324
|
+
/**
|
|
325
|
+
* Points for clearing a card of `items` items in `ms` milliseconds: 1000 per item per second,
|
|
326
|
+
* so it has no ceiling. Halving the time doubles it.
|
|
327
|
+
*/
|
|
328
|
+
declare function speedBonus(items: number, ms: number): number;
|
|
193
329
|
/** Render a packing bingo card into `container`. Call only in the browser. */
|
|
194
330
|
declare function createPackingBingo(container: HTMLElement, options?: PackingBingoOptions): PackingBingoInstance;
|
|
195
331
|
|
|
196
|
-
export { DEFAULT_ITEMS, LINES, bingoLines, createPackingBingo, en, ja };
|
|
197
|
-
export type { BingoEvent, BingoItem, Messages, PackingBingoInstance, PackingBingoOptions, PackingBingoState, PerfectEvent };
|
|
332
|
+
export { DEFAULT_ITEMS, LINES, bingoLines, createPackingBingo, en, formatTime, ja, speedBonus };
|
|
333
|
+
export type { BingoEvent, BingoItem, BingoMode, FinishEvent, Messages, PackingBingoInstance, PackingBingoOptions, PackingBingoState, PerfectEvent };
|
package/dist/core.js
CHANGED
|
@@ -5,13 +5,17 @@ import {
|
|
|
5
5
|
bingoLines,
|
|
6
6
|
createPackingBingo,
|
|
7
7
|
en,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
formatTime,
|
|
9
|
+
ja,
|
|
10
|
+
speedBonus
|
|
11
|
+
} from "./chunk-A5JVNVWS.js";
|
|
10
12
|
export {
|
|
11
13
|
DEFAULT_ITEMS,
|
|
12
14
|
LINES,
|
|
13
15
|
bingoLines,
|
|
14
16
|
createPackingBingo,
|
|
15
17
|
en,
|
|
16
|
-
|
|
18
|
+
formatTime,
|
|
19
|
+
ja,
|
|
20
|
+
speedBonus
|
|
17
21
|
};
|