loading-games 1.0.1 → 2.0.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +131 -3
- package/dist/react/index.d.ts +131 -3
- package/dist/svelte/index.d.ts +130 -3
- package/dist/vue/index.d.cts +131 -3
- package/dist/vue/index.d.ts +131 -3
- package/package.json +1 -1
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,7 +1,135 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* loading-games — TypeScript Types
|
|
6
|
+
*
|
|
7
|
+
* This file is the single source of truth for all types.
|
|
8
|
+
* Re-export from here in all packages.
|
|
9
|
+
*/
|
|
10
|
+
/** All built-in game identifiers. 'random' selects a different game each time. */
|
|
11
|
+
type GameName = 'snake' | 'brick-breaker' | 'flappy' | '2048' | 'wordle-lite' | 'asteroids' | 'memory-cards' | 'whack-a-mole' | 'random';
|
|
12
|
+
/** Size presets. 'full' creates a full-viewport overlay. */
|
|
13
|
+
type GameSize = 'sm' | 'md' | 'lg' | 'full';
|
|
14
|
+
/** Animation played when loading completes and the game exits. */
|
|
15
|
+
type ExitAnimation = 'fade' | 'slide' | 'none';
|
|
16
|
+
/**
|
|
17
|
+
* Theme color tokens.
|
|
18
|
+
* All fields optional — unset values fall back to CSS variables or system defaults.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* { primary: '#6366F1', background: '#0F0F0F' }
|
|
22
|
+
*/
|
|
23
|
+
interface ThemeObject {
|
|
24
|
+
/** Main accent color — buttons, score, active game elements */
|
|
25
|
+
primary?: string;
|
|
26
|
+
/** Canvas / component background */
|
|
27
|
+
background?: string;
|
|
28
|
+
/** Card and panel surfaces */
|
|
29
|
+
surface?: string;
|
|
30
|
+
/** Primary text (labels, scores, UI) */
|
|
31
|
+
text?: string;
|
|
32
|
+
/** Secondary highlight / accent */
|
|
33
|
+
accent?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Fired on every score change via onScore callback. */
|
|
36
|
+
interface Score {
|
|
37
|
+
game: Exclude<GameName, 'random'>;
|
|
38
|
+
/** Current score in this session */
|
|
39
|
+
current: number;
|
|
40
|
+
/** All-time personal best (from localStorage) */
|
|
41
|
+
personalBest: number;
|
|
42
|
+
/** true if current just exceeded the previous personal best */
|
|
43
|
+
isNewRecord: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Fired when a game round ends (not when loading ends). */
|
|
46
|
+
interface GameResult {
|
|
47
|
+
game: Exclude<GameName, 'random'>;
|
|
48
|
+
finalScore: number;
|
|
49
|
+
/** How long the game was active in milliseconds */
|
|
50
|
+
duration: number;
|
|
51
|
+
isNewRecord: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Complete configuration for a LoadingGame instance.
|
|
55
|
+
* All fields optional — sensible defaults apply.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* {
|
|
59
|
+
* game: 'snake',
|
|
60
|
+
* active: isLoading,
|
|
61
|
+
* theme: { primary: '#6366F1', background: '#0F0F0F' },
|
|
62
|
+
* onScore: (s) => console.log(s),
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
interface LoadingGameOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Which game to render.
|
|
68
|
+
* 'random' selects a different game each activation.
|
|
69
|
+
* @default 'random'
|
|
70
|
+
*/
|
|
71
|
+
game?: GameName;
|
|
72
|
+
/**
|
|
73
|
+
* Controls whether the game is shown.
|
|
74
|
+
* Set to true when loading begins, false when it ends.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
active?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Theme color overrides.
|
|
80
|
+
* Merged with CSS variables and system color scheme.
|
|
81
|
+
*/
|
|
82
|
+
theme?: ThemeObject;
|
|
83
|
+
/**
|
|
84
|
+
* Container size preset.
|
|
85
|
+
* 'full' renders a full-viewport overlay.
|
|
86
|
+
* @default 'md'
|
|
87
|
+
*/
|
|
88
|
+
size?: GameSize;
|
|
89
|
+
/**
|
|
90
|
+
* Milliseconds to wait before showing the game.
|
|
91
|
+
* Prevents a jarring flash for fast loads.
|
|
92
|
+
* If loading completes before delay, game never renders.
|
|
93
|
+
* @default 800
|
|
94
|
+
*/
|
|
95
|
+
delay?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Minimum milliseconds to show the game once it appears.
|
|
98
|
+
* Prevents a confusing half-second flash.
|
|
99
|
+
* @default 0
|
|
100
|
+
*/
|
|
101
|
+
minDisplay?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Animation when the game exits after loading completes.
|
|
104
|
+
* @default 'fade'
|
|
105
|
+
*/
|
|
106
|
+
exitAnimation?: ExitAnimation;
|
|
107
|
+
/**
|
|
108
|
+
* Persist personal bests in localStorage.
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
saveScores?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Namespace for score storage.
|
|
114
|
+
* Allows multiple instances to maintain separate leaderboards.
|
|
115
|
+
* @default undefined (global namespace)
|
|
116
|
+
*/
|
|
117
|
+
namespace?: string;
|
|
118
|
+
/** Fires every time the score changes. */
|
|
119
|
+
onScore?: (score: Score) => void;
|
|
120
|
+
/** Fires when a game round ends (game over, not loading end). */
|
|
121
|
+
onGameOver?: (result: GameResult) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Fires when loading completes and the game has fully exited.
|
|
124
|
+
* Use this to trigger post-load UI updates.
|
|
125
|
+
*/
|
|
126
|
+
onComplete?: () => void;
|
|
127
|
+
/**
|
|
128
|
+
* Fires when loading fails.
|
|
129
|
+
* The game exits immediately, without animation.
|
|
130
|
+
*/
|
|
131
|
+
onError?: (err: Error) => void;
|
|
132
|
+
}
|
|
5
133
|
|
|
6
134
|
/**
|
|
7
135
|
* useLoadingGame — Vue 3 composable for programmatic control
|
|
@@ -154,4 +282,4 @@ declare const LoadingGame: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
154
282
|
namespace: string;
|
|
155
283
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
156
284
|
|
|
157
|
-
export { LoadingGame, type UseLoadingGameOptions, type UseLoadingGameReturn, LoadingGame as default, useLoadingGame };
|
|
285
|
+
export { type ExitAnimation, type GameName, type GameResult, type GameSize, LoadingGame, type LoadingGameOptions, type Score, type ThemeObject, type UseLoadingGameOptions, type UseLoadingGameReturn, LoadingGame as default, useLoadingGame };
|