@beta-gamer/angular 0.1.2 → 0.1.3
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 +66 -14
- package/dist/index.d.mts +122 -25
- package/dist/index.d.ts +122 -25
- package/dist/index.js +149 -94
- package/dist/index.mjs +148 -93
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,16 @@ import { BetaGamerService, ChessBoardComponent } from '@beta-gamer/angular';
|
|
|
43
43
|
@Component({
|
|
44
44
|
standalone: true,
|
|
45
45
|
imports: [ChessBoardComponent],
|
|
46
|
-
template:
|
|
46
|
+
template: `
|
|
47
|
+
<bg-chess-board
|
|
48
|
+
style="width:100%;height:500px"
|
|
49
|
+
[showCoords]="true"
|
|
50
|
+
[showLastMove]="true"
|
|
51
|
+
[showLegalMoves]="true"
|
|
52
|
+
orientation="auto"
|
|
53
|
+
(onLeave)="handleLeave()"
|
|
54
|
+
/>
|
|
55
|
+
`,
|
|
47
56
|
})
|
|
48
57
|
export class AppComponent implements OnInit {
|
|
49
58
|
private svc = inject(BetaGamerService);
|
|
@@ -51,6 +60,10 @@ export class AppComponent implements OnInit {
|
|
|
51
60
|
ngOnInit() {
|
|
52
61
|
this.svc.init('<SESSION_TOKEN>', 'https://api.beta-gamer.com');
|
|
53
62
|
}
|
|
63
|
+
|
|
64
|
+
handleLeave() {
|
|
65
|
+
// navigate away or show a lobby screen
|
|
66
|
+
}
|
|
54
67
|
}
|
|
55
68
|
```
|
|
56
69
|
|
|
@@ -61,9 +74,11 @@ export class AppComponent implements OnInit {
|
|
|
61
74
|
Injectable service — call `init()` once with the session token.
|
|
62
75
|
|
|
63
76
|
```ts
|
|
64
|
-
svc.init(token: string, serverUrl?: string, socketPath?: string)
|
|
77
|
+
svc.init(token: string, serverUrl?: string, socketPath?: string, connectSocket?: boolean)
|
|
65
78
|
```
|
|
66
79
|
|
|
80
|
+
> **`connectSocket`** (default `true`) — set to `false` when using only board components. Board components load the game in an iframe with their own socket. A second socket with the same token causes duplicate connections and AFK/turn bugs.
|
|
81
|
+
|
|
67
82
|
| Signal | Type | Description |
|
|
68
83
|
|--------|------|-------------|
|
|
69
84
|
| `svc.session` | `Signal<Session>` | Current session (game, matchType, players) |
|
|
@@ -77,27 +92,64 @@ All components are standalone — import only what you need.
|
|
|
77
92
|
|
|
78
93
|
### Shared (all games)
|
|
79
94
|
|
|
80
|
-
| Component | Selector |
|
|
81
|
-
|
|
95
|
+
| Component | Selector | Inputs | Description |
|
|
96
|
+
|-----------|----------|--------|-------------|
|
|
82
97
|
| `PlayerCardComponent` | `<bg-player-card>` | `[player]` (`"self"` \| `"opponent"`) | Player name + active-turn indicator |
|
|
83
98
|
| `TimerComponent` | `<bg-timer>` | `[player]`, `[initialSeconds]?` | Live countdown clock |
|
|
84
99
|
|
|
85
|
-
### Chess
|
|
100
|
+
### Chess — `ChessBoardComponent`
|
|
86
101
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
| `
|
|
102
|
+
Selector: `<bg-chess-board>`
|
|
103
|
+
|
|
104
|
+
| Input | Type | Default | Description |
|
|
105
|
+
|-------|------|---------|-------------|
|
|
106
|
+
| `[serverUrl]` | `string` | `'https://api.beta-gamer.com'` | Base URL of the Beta Gamer server |
|
|
107
|
+
| `[showAfkWarning]` | `boolean` | `true` | Show the built-in AFK countdown banner |
|
|
108
|
+
| `[showCoords]` | `boolean` | `true` | Show rank/file labels (a–h, 1–8) around the board |
|
|
109
|
+
| `[showLastMove]` | `boolean` | `true` | Highlight the from/to squares of the last move |
|
|
110
|
+
| `[showLegalMoves]` | `boolean` | `true` | Show dots on squares where the selected piece can legally move |
|
|
111
|
+
| `[orientation]` | `'white' \| 'black' \| 'auto'` | `'auto'` | Which color is at the bottom. `'auto'` uses the color assigned in `game:started` |
|
|
112
|
+
| `(onLeave)` | `EventEmitter<void>` | — | Emitted when the player taps Leave or exits the game-over modal |
|
|
113
|
+
|
|
114
|
+
### Checkers — `CheckersBoardComponent`
|
|
115
|
+
|
|
116
|
+
Selector: `<bg-checkers-board>`
|
|
117
|
+
|
|
118
|
+
| Input | Type | Default | Description |
|
|
119
|
+
|-------|------|---------|-------------|
|
|
120
|
+
| `[serverUrl]` | `string` | `'https://api.beta-gamer.com'` | Base URL of the Beta Gamer server |
|
|
121
|
+
| `[showAfkWarning]` | `boolean` | `true` | Show the built-in AFK countdown banner |
|
|
122
|
+
| `[showLastMove]` | `boolean` | `true` | Highlight the from/to squares of the last move |
|
|
123
|
+
| `[orientation]` | `'red' \| 'black' \| 'auto'` | `'auto'` | Which color is at the bottom. `'auto'` uses the color assigned in `game:started` |
|
|
124
|
+
| `(onLeave)` | `EventEmitter<void>` | — | Emitted when the player taps Leave or exits the game-over modal |
|
|
125
|
+
|
|
126
|
+
### Connect 4 — `Connect4BoardComponent`
|
|
127
|
+
|
|
128
|
+
Selector: `<bg-connect4-board>`
|
|
129
|
+
|
|
130
|
+
| Input | Type | Default | Description |
|
|
131
|
+
|-------|------|---------|-------------|
|
|
132
|
+
| `[serverUrl]` | `string` | `'https://api.beta-gamer.com'` | Base URL of the Beta Gamer server |
|
|
133
|
+
| `[showAfkWarning]` | `boolean` | `true` | Show the built-in AFK countdown banner |
|
|
134
|
+
| `(onLeave)` | `EventEmitter<void>` | — | Emitted when the player taps Leave or exits the game-over modal |
|
|
135
|
+
|
|
136
|
+
### Tic-tac-toe — `TictactoeBoardComponent`
|
|
137
|
+
|
|
138
|
+
Selector: `<bg-tictactoe-board>`
|
|
139
|
+
|
|
140
|
+
| Input | Type | Default | Description |
|
|
141
|
+
|-------|------|---------|-------------|
|
|
142
|
+
| `[serverUrl]` | `string` | `'https://api.beta-gamer.com'` | Base URL of the Beta Gamer server |
|
|
143
|
+
| `[showAfkWarning]` | `boolean` | `true` | Show the built-in AFK countdown banner |
|
|
144
|
+
| `(onLeave)` | `EventEmitter<void>` | — | Emitted when the player taps Leave or exits the game-over modal |
|
|
92
145
|
|
|
93
|
-
### Other
|
|
146
|
+
### Other components
|
|
94
147
|
|
|
95
148
|
| Component | Selector | Inputs | Game |
|
|
96
149
|
|-----------|----------|--------|------|
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
150
|
+
| `ChessMoveHistoryComponent` | `<bg-chess-move-history>` | — | chess |
|
|
151
|
+
| `ChessCapturedPiecesComponent` | `<bg-chess-captured-pieces>` | `[player]` | chess |
|
|
99
152
|
| `Connect4ScoreComponent` | `<bg-connect4-score>` | — | connect4 |
|
|
100
|
-
| `TictactoeBoardComponent` | `<bg-tictactoe-board>` | `[serverUrl]?`, `[showAfkWarning]?` | tictactoe |
|
|
101
153
|
| `SubwayRunnerGameComponent` | `<bg-subway-runner-game>` | — | subway-runner |
|
|
102
154
|
| `SubwayRunnerScoreComponent` | `<bg-subway-runner-score>` | — | subway-runner |
|
|
103
155
|
| `SubwayRunnerLivesComponent` | `<bg-subway-runner-lives>` | — | subway-runner |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _socket_io_component_emitter from '@socket.io/component-emitter';
|
|
2
2
|
import * as _angular_core from '@angular/core';
|
|
3
|
-
import { OnDestroy, OnInit, AfterViewInit, ElementRef } from '@angular/core';
|
|
3
|
+
import { OnDestroy, OnInit, AfterViewInit, EventEmitter, ElementRef } from '@angular/core';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
|
|
6
6
|
type GameType = 'chess' | 'checkers' | 'connect4' | 'tictactoe' | 'subway-runner';
|
|
@@ -41,23 +41,55 @@ interface GameState {
|
|
|
41
41
|
declare class BetaGamerService implements OnDestroy {
|
|
42
42
|
private _socket;
|
|
43
43
|
private _token;
|
|
44
|
+
/** Decoded session token payload — null until `init()` is called */
|
|
44
45
|
readonly session: _angular_core.WritableSignal<SessionTokenPayload | null>;
|
|
46
|
+
/** Live game state updated by server events */
|
|
45
47
|
readonly gameState: _angular_core.WritableSignal<GameState>;
|
|
46
48
|
get token(): string;
|
|
49
|
+
/** The active socket.io connection — available after `init()` with `connectSocket=true` */
|
|
47
50
|
get socket(): Socket<_socket_io_component_emitter.DefaultEventsMap, _socket_io_component_emitter.DefaultEventsMap> | null;
|
|
48
|
-
|
|
51
|
+
/**
|
|
52
|
+
* @description Initialises the service with a session token.
|
|
53
|
+
* Decodes the token, sets up reactive state, and optionally connects the socket.
|
|
54
|
+
*
|
|
55
|
+
* @param token - JWT session token from your backend
|
|
56
|
+
* @param serverUrl - Base URL of the Beta Gamer server
|
|
57
|
+
* @param socketPath - socket.io path (default `/socket.io`)
|
|
58
|
+
* @param connectSocket - Set false to skip socket connection (e.g. for SSR or testing)
|
|
59
|
+
*/
|
|
60
|
+
init(token: string, serverUrl?: string, socketPath?: string, connectSocket?: boolean): void;
|
|
49
61
|
ngOnDestroy(): void;
|
|
50
62
|
}
|
|
51
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @description Displays a player's display name and active-turn indicator.
|
|
66
|
+
* Styled entirely by the consumer via `data-active` and `data-player` attributes.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <bg-player-card player="self" />
|
|
70
|
+
* <bg-player-card player="opponent" />
|
|
71
|
+
*/
|
|
52
72
|
declare class PlayerCardComponent {
|
|
73
|
+
/** Which player to display — `self` = players[0], `opponent` = players[1] */
|
|
53
74
|
player: 'self' | 'opponent';
|
|
54
75
|
private svc;
|
|
55
76
|
get displayName(): string;
|
|
56
77
|
get isActive(): boolean;
|
|
57
78
|
}
|
|
58
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @description Live countdown clock that syncs with the server via `game:clock` socket events.
|
|
82
|
+
* Falls back to a local 1s interval when the game is active.
|
|
83
|
+
* Renders a `data-low` attribute when under 30 seconds for easy CSS targeting.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* <bg-timer player="self" [initialSeconds]="600" />
|
|
87
|
+
*/
|
|
88
|
+
|
|
59
89
|
declare class TimerComponent implements OnInit, OnDestroy {
|
|
90
|
+
/** Which player's clock to display */
|
|
60
91
|
player: 'self' | 'opponent';
|
|
92
|
+
/** Starting value in seconds (e.g. 600 = 10 min) */
|
|
61
93
|
initialSeconds: number;
|
|
62
94
|
seconds: number;
|
|
63
95
|
private interval;
|
|
@@ -67,66 +99,131 @@ declare class TimerComponent implements OnInit, OnDestroy {
|
|
|
67
99
|
ngOnDestroy(): void;
|
|
68
100
|
}
|
|
69
101
|
|
|
70
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @description Shared base class for all iframe-based game board components.
|
|
104
|
+
*
|
|
105
|
+
* Handles the full iframe lifecycle:
|
|
106
|
+
* - Injects the session token into the iframe on load via postMessage
|
|
107
|
+
* - Listens for `bg:leave` messages from the embed and emits `onLeave`
|
|
108
|
+
* - Cleans up the message listener on destroy
|
|
109
|
+
*
|
|
110
|
+
* Subclasses only need to define their embed URL and any game-specific inputs.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
declare abstract class EmbedBoardBase implements AfterViewInit, OnDestroy {
|
|
114
|
+
/** Base URL of the Beta Gamer server hosting the embed pages */
|
|
71
115
|
serverUrl: string;
|
|
72
|
-
|
|
116
|
+
/** Emitted when the player clicks Leave inside the embed */
|
|
117
|
+
onLeave: EventEmitter<void>;
|
|
73
118
|
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
74
|
-
svc: BetaGamerService;
|
|
75
|
-
|
|
119
|
+
protected svc: BetaGamerService;
|
|
120
|
+
/** Subclasses return the full embed URL including query params */
|
|
121
|
+
abstract get embedUrl(): string;
|
|
122
|
+
private messageHandler;
|
|
76
123
|
ngAfterViewInit(): void;
|
|
124
|
+
ngOnDestroy(): void;
|
|
125
|
+
/** Builds a query string from a params object, omitting undefined values */
|
|
126
|
+
protected buildQuery(params: Record<string, string | undefined>): string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @description Chess board embed component.
|
|
131
|
+
* Renders the chess game inside an iframe served by the Beta Gamer embed server.
|
|
132
|
+
* Supports orientation, coordinate display, last-move highlight, and legal move hints.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
declare class ChessBoardComponent extends EmbedBoardBase {
|
|
136
|
+
showAfkWarning: boolean;
|
|
137
|
+
showCoords: boolean;
|
|
138
|
+
showLastMove: boolean;
|
|
139
|
+
showLegalMoves: boolean;
|
|
140
|
+
orientation: 'white' | 'black' | 'auto';
|
|
141
|
+
get embedUrl(): string;
|
|
77
142
|
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @description Displays the chess move history in algebraic notation.
|
|
146
|
+
* Styled entirely by the consumer via the `data-role="move-history"` attribute.
|
|
147
|
+
*/
|
|
78
148
|
declare class ChessMoveHistoryComponent {
|
|
79
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @description Displays pieces captured by a given player.
|
|
153
|
+
* Styled entirely by the consumer via the `data-role="captured-pieces"` attribute.
|
|
154
|
+
*/
|
|
80
155
|
declare class ChessCapturedPiecesComponent {
|
|
81
156
|
}
|
|
82
157
|
|
|
83
|
-
|
|
84
|
-
|
|
158
|
+
/**
|
|
159
|
+
* @description Checkers board embed component.
|
|
160
|
+
* Supports orientation (red/black/auto) and last-move highlight toggle.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
declare class CheckersBoardComponent extends EmbedBoardBase {
|
|
85
164
|
showAfkWarning: boolean;
|
|
86
|
-
|
|
87
|
-
|
|
165
|
+
showLastMove: boolean;
|
|
166
|
+
orientation: 'red' | 'black' | 'auto';
|
|
88
167
|
get embedUrl(): string;
|
|
89
|
-
ngAfterViewInit(): void;
|
|
90
168
|
}
|
|
91
169
|
|
|
92
|
-
|
|
93
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @description Connect 4 board embed component.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
declare class Connect4BoardComponent extends EmbedBoardBase {
|
|
94
175
|
showAfkWarning: boolean;
|
|
95
|
-
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
96
|
-
svc: BetaGamerService;
|
|
97
176
|
get embedUrl(): string;
|
|
98
|
-
ngAfterViewInit(): void;
|
|
99
177
|
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @description Displays the current score for each player in a Connect 4 session.
|
|
181
|
+
* Reads from `gameState().scores` — styled entirely by the consumer via data attributes.
|
|
182
|
+
*/
|
|
100
183
|
declare class Connect4ScoreComponent {
|
|
101
|
-
svc
|
|
184
|
+
private svc;
|
|
102
185
|
get scores(): {
|
|
103
186
|
id: string;
|
|
104
187
|
score: unknown;
|
|
105
188
|
}[];
|
|
106
189
|
}
|
|
107
190
|
|
|
108
|
-
|
|
109
|
-
|
|
191
|
+
/**
|
|
192
|
+
* @description Tic-tac-toe board embed component.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
declare class TictactoeBoardComponent extends EmbedBoardBase {
|
|
110
196
|
showAfkWarning: boolean;
|
|
111
|
-
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
112
|
-
svc: BetaGamerService;
|
|
113
197
|
get embedUrl(): string;
|
|
114
|
-
ngAfterViewInit(): void;
|
|
115
198
|
}
|
|
116
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @description Subway Runner game embed component.
|
|
202
|
+
*/
|
|
203
|
+
|
|
117
204
|
declare class SubwayRunnerGameComponent implements AfterViewInit {
|
|
118
205
|
serverUrl: string;
|
|
119
206
|
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
120
|
-
svc: BetaGamerService;
|
|
207
|
+
protected svc: BetaGamerService;
|
|
121
208
|
get embedUrl(): string;
|
|
122
209
|
ngAfterViewInit(): void;
|
|
123
210
|
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @description Displays the current score in a Subway Runner session.
|
|
214
|
+
* Reads from `gameState().score`. Style via `data-role="score"`.
|
|
215
|
+
*/
|
|
124
216
|
declare class SubwayRunnerScoreComponent {
|
|
125
|
-
svc
|
|
217
|
+
private svc;
|
|
126
218
|
get score(): any;
|
|
127
219
|
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @description Displays the remaining lives in a Subway Runner session.
|
|
223
|
+
* Reads from `gameState().lives`. Style via `data-role="lives"`.
|
|
224
|
+
*/
|
|
128
225
|
declare class SubwayRunnerLivesComponent {
|
|
129
|
-
svc
|
|
226
|
+
private svc;
|
|
130
227
|
get lives(): any;
|
|
131
228
|
}
|
|
132
229
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _socket_io_component_emitter from '@socket.io/component-emitter';
|
|
2
2
|
import * as _angular_core from '@angular/core';
|
|
3
|
-
import { OnDestroy, OnInit, AfterViewInit, ElementRef } from '@angular/core';
|
|
3
|
+
import { OnDestroy, OnInit, AfterViewInit, EventEmitter, ElementRef } from '@angular/core';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
|
|
6
6
|
type GameType = 'chess' | 'checkers' | 'connect4' | 'tictactoe' | 'subway-runner';
|
|
@@ -41,23 +41,55 @@ interface GameState {
|
|
|
41
41
|
declare class BetaGamerService implements OnDestroy {
|
|
42
42
|
private _socket;
|
|
43
43
|
private _token;
|
|
44
|
+
/** Decoded session token payload — null until `init()` is called */
|
|
44
45
|
readonly session: _angular_core.WritableSignal<SessionTokenPayload | null>;
|
|
46
|
+
/** Live game state updated by server events */
|
|
45
47
|
readonly gameState: _angular_core.WritableSignal<GameState>;
|
|
46
48
|
get token(): string;
|
|
49
|
+
/** The active socket.io connection — available after `init()` with `connectSocket=true` */
|
|
47
50
|
get socket(): Socket<_socket_io_component_emitter.DefaultEventsMap, _socket_io_component_emitter.DefaultEventsMap> | null;
|
|
48
|
-
|
|
51
|
+
/**
|
|
52
|
+
* @description Initialises the service with a session token.
|
|
53
|
+
* Decodes the token, sets up reactive state, and optionally connects the socket.
|
|
54
|
+
*
|
|
55
|
+
* @param token - JWT session token from your backend
|
|
56
|
+
* @param serverUrl - Base URL of the Beta Gamer server
|
|
57
|
+
* @param socketPath - socket.io path (default `/socket.io`)
|
|
58
|
+
* @param connectSocket - Set false to skip socket connection (e.g. for SSR or testing)
|
|
59
|
+
*/
|
|
60
|
+
init(token: string, serverUrl?: string, socketPath?: string, connectSocket?: boolean): void;
|
|
49
61
|
ngOnDestroy(): void;
|
|
50
62
|
}
|
|
51
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @description Displays a player's display name and active-turn indicator.
|
|
66
|
+
* Styled entirely by the consumer via `data-active` and `data-player` attributes.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <bg-player-card player="self" />
|
|
70
|
+
* <bg-player-card player="opponent" />
|
|
71
|
+
*/
|
|
52
72
|
declare class PlayerCardComponent {
|
|
73
|
+
/** Which player to display — `self` = players[0], `opponent` = players[1] */
|
|
53
74
|
player: 'self' | 'opponent';
|
|
54
75
|
private svc;
|
|
55
76
|
get displayName(): string;
|
|
56
77
|
get isActive(): boolean;
|
|
57
78
|
}
|
|
58
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @description Live countdown clock that syncs with the server via `game:clock` socket events.
|
|
82
|
+
* Falls back to a local 1s interval when the game is active.
|
|
83
|
+
* Renders a `data-low` attribute when under 30 seconds for easy CSS targeting.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* <bg-timer player="self" [initialSeconds]="600" />
|
|
87
|
+
*/
|
|
88
|
+
|
|
59
89
|
declare class TimerComponent implements OnInit, OnDestroy {
|
|
90
|
+
/** Which player's clock to display */
|
|
60
91
|
player: 'self' | 'opponent';
|
|
92
|
+
/** Starting value in seconds (e.g. 600 = 10 min) */
|
|
61
93
|
initialSeconds: number;
|
|
62
94
|
seconds: number;
|
|
63
95
|
private interval;
|
|
@@ -67,66 +99,131 @@ declare class TimerComponent implements OnInit, OnDestroy {
|
|
|
67
99
|
ngOnDestroy(): void;
|
|
68
100
|
}
|
|
69
101
|
|
|
70
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @description Shared base class for all iframe-based game board components.
|
|
104
|
+
*
|
|
105
|
+
* Handles the full iframe lifecycle:
|
|
106
|
+
* - Injects the session token into the iframe on load via postMessage
|
|
107
|
+
* - Listens for `bg:leave` messages from the embed and emits `onLeave`
|
|
108
|
+
* - Cleans up the message listener on destroy
|
|
109
|
+
*
|
|
110
|
+
* Subclasses only need to define their embed URL and any game-specific inputs.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
declare abstract class EmbedBoardBase implements AfterViewInit, OnDestroy {
|
|
114
|
+
/** Base URL of the Beta Gamer server hosting the embed pages */
|
|
71
115
|
serverUrl: string;
|
|
72
|
-
|
|
116
|
+
/** Emitted when the player clicks Leave inside the embed */
|
|
117
|
+
onLeave: EventEmitter<void>;
|
|
73
118
|
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
74
|
-
svc: BetaGamerService;
|
|
75
|
-
|
|
119
|
+
protected svc: BetaGamerService;
|
|
120
|
+
/** Subclasses return the full embed URL including query params */
|
|
121
|
+
abstract get embedUrl(): string;
|
|
122
|
+
private messageHandler;
|
|
76
123
|
ngAfterViewInit(): void;
|
|
124
|
+
ngOnDestroy(): void;
|
|
125
|
+
/** Builds a query string from a params object, omitting undefined values */
|
|
126
|
+
protected buildQuery(params: Record<string, string | undefined>): string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @description Chess board embed component.
|
|
131
|
+
* Renders the chess game inside an iframe served by the Beta Gamer embed server.
|
|
132
|
+
* Supports orientation, coordinate display, last-move highlight, and legal move hints.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
declare class ChessBoardComponent extends EmbedBoardBase {
|
|
136
|
+
showAfkWarning: boolean;
|
|
137
|
+
showCoords: boolean;
|
|
138
|
+
showLastMove: boolean;
|
|
139
|
+
showLegalMoves: boolean;
|
|
140
|
+
orientation: 'white' | 'black' | 'auto';
|
|
141
|
+
get embedUrl(): string;
|
|
77
142
|
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @description Displays the chess move history in algebraic notation.
|
|
146
|
+
* Styled entirely by the consumer via the `data-role="move-history"` attribute.
|
|
147
|
+
*/
|
|
78
148
|
declare class ChessMoveHistoryComponent {
|
|
79
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @description Displays pieces captured by a given player.
|
|
153
|
+
* Styled entirely by the consumer via the `data-role="captured-pieces"` attribute.
|
|
154
|
+
*/
|
|
80
155
|
declare class ChessCapturedPiecesComponent {
|
|
81
156
|
}
|
|
82
157
|
|
|
83
|
-
|
|
84
|
-
|
|
158
|
+
/**
|
|
159
|
+
* @description Checkers board embed component.
|
|
160
|
+
* Supports orientation (red/black/auto) and last-move highlight toggle.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
declare class CheckersBoardComponent extends EmbedBoardBase {
|
|
85
164
|
showAfkWarning: boolean;
|
|
86
|
-
|
|
87
|
-
|
|
165
|
+
showLastMove: boolean;
|
|
166
|
+
orientation: 'red' | 'black' | 'auto';
|
|
88
167
|
get embedUrl(): string;
|
|
89
|
-
ngAfterViewInit(): void;
|
|
90
168
|
}
|
|
91
169
|
|
|
92
|
-
|
|
93
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @description Connect 4 board embed component.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
declare class Connect4BoardComponent extends EmbedBoardBase {
|
|
94
175
|
showAfkWarning: boolean;
|
|
95
|
-
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
96
|
-
svc: BetaGamerService;
|
|
97
176
|
get embedUrl(): string;
|
|
98
|
-
ngAfterViewInit(): void;
|
|
99
177
|
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @description Displays the current score for each player in a Connect 4 session.
|
|
181
|
+
* Reads from `gameState().scores` — styled entirely by the consumer via data attributes.
|
|
182
|
+
*/
|
|
100
183
|
declare class Connect4ScoreComponent {
|
|
101
|
-
svc
|
|
184
|
+
private svc;
|
|
102
185
|
get scores(): {
|
|
103
186
|
id: string;
|
|
104
187
|
score: unknown;
|
|
105
188
|
}[];
|
|
106
189
|
}
|
|
107
190
|
|
|
108
|
-
|
|
109
|
-
|
|
191
|
+
/**
|
|
192
|
+
* @description Tic-tac-toe board embed component.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
declare class TictactoeBoardComponent extends EmbedBoardBase {
|
|
110
196
|
showAfkWarning: boolean;
|
|
111
|
-
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
112
|
-
svc: BetaGamerService;
|
|
113
197
|
get embedUrl(): string;
|
|
114
|
-
ngAfterViewInit(): void;
|
|
115
198
|
}
|
|
116
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @description Subway Runner game embed component.
|
|
202
|
+
*/
|
|
203
|
+
|
|
117
204
|
declare class SubwayRunnerGameComponent implements AfterViewInit {
|
|
118
205
|
serverUrl: string;
|
|
119
206
|
iframeRef: ElementRef<HTMLIFrameElement>;
|
|
120
|
-
svc: BetaGamerService;
|
|
207
|
+
protected svc: BetaGamerService;
|
|
121
208
|
get embedUrl(): string;
|
|
122
209
|
ngAfterViewInit(): void;
|
|
123
210
|
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @description Displays the current score in a Subway Runner session.
|
|
214
|
+
* Reads from `gameState().score`. Style via `data-role="score"`.
|
|
215
|
+
*/
|
|
124
216
|
declare class SubwayRunnerScoreComponent {
|
|
125
|
-
svc
|
|
217
|
+
private svc;
|
|
126
218
|
get score(): any;
|
|
127
219
|
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @description Displays the remaining lives in a Subway Runner session.
|
|
223
|
+
* Reads from `gameState().lives`. Style via `data-role="lives"`.
|
|
224
|
+
*/
|
|
128
225
|
declare class SubwayRunnerLivesComponent {
|
|
129
|
-
svc
|
|
226
|
+
private svc;
|
|
130
227
|
get lives(): any;
|
|
131
228
|
}
|
|
132
229
|
|