@beta-gamer/react 0.1.8 → 0.1.11
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 +9 -7
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +12 -8
- package/dist/index.mjs +12 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,18 +76,20 @@ export default function GamePage({ sessionToken }: { sessionToken: string }) {
|
|
|
76
76
|
|
|
77
77
|
| Component | Props | Description |
|
|
78
78
|
|-----------|-------|-------------|
|
|
79
|
-
| `ChessBoard` | `className?` | Interactive chess board |
|
|
79
|
+
| `ChessBoard` | `className?`, `showAfkWarning?` | Interactive chess board |
|
|
80
80
|
| `ChessMoveHistory` | `className?` | Scrollable move list in algebraic notation |
|
|
81
81
|
| `ChessCapturedPieces` | `player`, `className?` | Pieces captured by the given player |
|
|
82
82
|
|
|
83
83
|
### Other games
|
|
84
84
|
|
|
85
|
-
| Component | Game |
|
|
86
|
-
|
|
87
|
-
| `CheckersBoard` | checkers |
|
|
88
|
-
| `Connect4Board
|
|
89
|
-
| `TictactoeBoard` | tictactoe |
|
|
90
|
-
| `SubwayRunnerGame`, `SubwayRunnerScore`, `SubwayRunnerLives` | subway-runner |
|
|
85
|
+
| Component | Props | Game |
|
|
86
|
+
|-----------|-------|------|
|
|
87
|
+
| `CheckersBoard` | `className?`, `showAfkWarning?` | checkers |
|
|
88
|
+
| `Connect4Board` | `className?`, `showAfkWarning?` | connect4 |
|
|
89
|
+
| `TictactoeBoard` | `className?`, `showAfkWarning?` | tictactoe |
|
|
90
|
+
| `SubwayRunnerGame`, `SubwayRunnerScore`, `SubwayRunnerLives` | `className?` | subway-runner |
|
|
91
|
+
|
|
92
|
+
> **`showAfkWarning`** (default `true`) — set to `false` to hide the built-in AFK countdown banner and implement your own using the `{game}:afk_warning` / `{game}:afk_warning_cleared` socket events.
|
|
91
93
|
|
|
92
94
|
## Hooks
|
|
93
95
|
|
package/dist/index.d.mts
CHANGED
|
@@ -85,8 +85,9 @@ declare function Timer({ player, initialSeconds, className }: TimerProps): react
|
|
|
85
85
|
|
|
86
86
|
interface ChessBoardProps {
|
|
87
87
|
className?: string;
|
|
88
|
+
showAfkWarning?: boolean;
|
|
88
89
|
}
|
|
89
|
-
declare function ChessBoard({ className }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
90
|
+
declare function ChessBoard({ className, showAfkWarning }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
90
91
|
|
|
91
92
|
interface ChessMoveHistoryProps {
|
|
92
93
|
className?: string;
|
|
@@ -101,19 +102,22 @@ interface ChessCapturedPiecesProps {
|
|
|
101
102
|
/** Shows pieces captured by the given player. */
|
|
102
103
|
declare function ChessCapturedPieces({ player, className }: ChessCapturedPiecesProps): react_jsx_runtime.JSX.Element;
|
|
103
104
|
|
|
104
|
-
declare function CheckersBoard({ className }: {
|
|
105
|
+
declare function CheckersBoard({ className, showAfkWarning }: {
|
|
105
106
|
className?: string;
|
|
107
|
+
showAfkWarning?: boolean;
|
|
106
108
|
}): react_jsx_runtime.JSX.Element | null;
|
|
107
109
|
|
|
108
|
-
declare function Connect4Board({ className }: {
|
|
110
|
+
declare function Connect4Board({ className, showAfkWarning }: {
|
|
109
111
|
className?: string;
|
|
112
|
+
showAfkWarning?: boolean;
|
|
110
113
|
}): react_jsx_runtime.JSX.Element | null;
|
|
111
114
|
declare function Connect4Score({ className }: {
|
|
112
115
|
className?: string;
|
|
113
116
|
}): react_jsx_runtime.JSX.Element;
|
|
114
117
|
|
|
115
|
-
declare function TictactoeBoard({ className }: {
|
|
118
|
+
declare function TictactoeBoard({ className, showAfkWarning }: {
|
|
116
119
|
className?: string;
|
|
120
|
+
showAfkWarning?: boolean;
|
|
117
121
|
}): react_jsx_runtime.JSX.Element | null;
|
|
118
122
|
|
|
119
123
|
declare function SubwayRunnerScore({ className }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -85,8 +85,9 @@ declare function Timer({ player, initialSeconds, className }: TimerProps): react
|
|
|
85
85
|
|
|
86
86
|
interface ChessBoardProps {
|
|
87
87
|
className?: string;
|
|
88
|
+
showAfkWarning?: boolean;
|
|
88
89
|
}
|
|
89
|
-
declare function ChessBoard({ className }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
90
|
+
declare function ChessBoard({ className, showAfkWarning }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
90
91
|
|
|
91
92
|
interface ChessMoveHistoryProps {
|
|
92
93
|
className?: string;
|
|
@@ -101,19 +102,22 @@ interface ChessCapturedPiecesProps {
|
|
|
101
102
|
/** Shows pieces captured by the given player. */
|
|
102
103
|
declare function ChessCapturedPieces({ player, className }: ChessCapturedPiecesProps): react_jsx_runtime.JSX.Element;
|
|
103
104
|
|
|
104
|
-
declare function CheckersBoard({ className }: {
|
|
105
|
+
declare function CheckersBoard({ className, showAfkWarning }: {
|
|
105
106
|
className?: string;
|
|
107
|
+
showAfkWarning?: boolean;
|
|
106
108
|
}): react_jsx_runtime.JSX.Element | null;
|
|
107
109
|
|
|
108
|
-
declare function Connect4Board({ className }: {
|
|
110
|
+
declare function Connect4Board({ className, showAfkWarning }: {
|
|
109
111
|
className?: string;
|
|
112
|
+
showAfkWarning?: boolean;
|
|
110
113
|
}): react_jsx_runtime.JSX.Element | null;
|
|
111
114
|
declare function Connect4Score({ className }: {
|
|
112
115
|
className?: string;
|
|
113
116
|
}): react_jsx_runtime.JSX.Element;
|
|
114
117
|
|
|
115
|
-
declare function TictactoeBoard({ className }: {
|
|
118
|
+
declare function TictactoeBoard({ className, showAfkWarning }: {
|
|
116
119
|
className?: string;
|
|
120
|
+
showAfkWarning?: boolean;
|
|
117
121
|
}): react_jsx_runtime.JSX.Element | null;
|
|
118
122
|
|
|
119
123
|
declare function SubwayRunnerScore({ className }: {
|
package/dist/index.js
CHANGED
|
@@ -169,7 +169,7 @@ function Timer({ player, initialSeconds = 600, className }) {
|
|
|
169
169
|
// src/components/chess/ChessBoard.tsx
|
|
170
170
|
var import_react3 = require("react");
|
|
171
171
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
172
|
-
function ChessBoard({ className }) {
|
|
172
|
+
function ChessBoard({ className, showAfkWarning = true }) {
|
|
173
173
|
const { token, serverUrl, session } = useBetaGamer();
|
|
174
174
|
const iframeRef = (0, import_react3.useRef)(null);
|
|
175
175
|
(0, import_react3.useEffect)(() => {
|
|
@@ -180,11 +180,12 @@ function ChessBoard({ className }) {
|
|
|
180
180
|
return () => iframe.removeEventListener("load", onLoad);
|
|
181
181
|
}, [token]);
|
|
182
182
|
if (session.game !== "chess") return null;
|
|
183
|
+
const src = showAfkWarning ? `${serverUrl}/embed/chess` : `${serverUrl}/embed/chess?afkWarning=0`;
|
|
183
184
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
184
185
|
"iframe",
|
|
185
186
|
{
|
|
186
187
|
ref: iframeRef,
|
|
187
|
-
src
|
|
188
|
+
src,
|
|
188
189
|
className,
|
|
189
190
|
style: { border: "none", width: "100%", height: "100%" },
|
|
190
191
|
allow: "autoplay",
|
|
@@ -261,7 +262,7 @@ function ChessCapturedPieces({ player, className }) {
|
|
|
261
262
|
// src/components/checkers/index.tsx
|
|
262
263
|
var import_react6 = require("react");
|
|
263
264
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
264
|
-
function CheckersBoard({ className }) {
|
|
265
|
+
function CheckersBoard({ className, showAfkWarning = true }) {
|
|
265
266
|
const { token, serverUrl, session } = useBetaGamer();
|
|
266
267
|
const iframeRef = (0, import_react6.useRef)(null);
|
|
267
268
|
(0, import_react6.useEffect)(() => {
|
|
@@ -272,13 +273,14 @@ function CheckersBoard({ className }) {
|
|
|
272
273
|
return () => iframe.removeEventListener("load", onLoad);
|
|
273
274
|
}, [token]);
|
|
274
275
|
if (session.game !== "checkers") return null;
|
|
275
|
-
|
|
276
|
+
const src = showAfkWarning ? `${serverUrl}/embed/checkers` : `${serverUrl}/embed/checkers?afkWarning=0`;
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Checkers" });
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
// src/components/connect4/index.tsx
|
|
279
281
|
var import_react7 = require("react");
|
|
280
282
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
281
|
-
function Connect4Board({ className }) {
|
|
283
|
+
function Connect4Board({ className, showAfkWarning = true }) {
|
|
282
284
|
const { token, serverUrl, session } = useBetaGamer();
|
|
283
285
|
const iframeRef = (0, import_react7.useRef)(null);
|
|
284
286
|
(0, import_react7.useEffect)(() => {
|
|
@@ -289,7 +291,8 @@ function Connect4Board({ className }) {
|
|
|
289
291
|
return () => iframe.removeEventListener("load", onLoad);
|
|
290
292
|
}, [token]);
|
|
291
293
|
if (session.game !== "connect4") return null;
|
|
292
|
-
|
|
294
|
+
const src = showAfkWarning ? `${serverUrl}/embed/connect4` : `${serverUrl}/embed/connect4?afkWarning=0`;
|
|
295
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Connect 4" });
|
|
293
296
|
}
|
|
294
297
|
function Connect4Score({ className }) {
|
|
295
298
|
const { gameState } = useBetaGamer();
|
|
@@ -300,7 +303,7 @@ function Connect4Score({ className }) {
|
|
|
300
303
|
// src/components/tictactoe/index.tsx
|
|
301
304
|
var import_react8 = require("react");
|
|
302
305
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
303
|
-
function TictactoeBoard({ className }) {
|
|
306
|
+
function TictactoeBoard({ className, showAfkWarning = true }) {
|
|
304
307
|
const { token, serverUrl, session } = useBetaGamer();
|
|
305
308
|
const iframeRef = (0, import_react8.useRef)(null);
|
|
306
309
|
(0, import_react8.useEffect)(() => {
|
|
@@ -311,7 +314,8 @@ function TictactoeBoard({ className }) {
|
|
|
311
314
|
return () => iframe.removeEventListener("load", onLoad);
|
|
312
315
|
}, [token]);
|
|
313
316
|
if (session.game !== "tictactoe") return null;
|
|
314
|
-
|
|
317
|
+
const src = showAfkWarning ? `${serverUrl}/embed/tictactoe` : `${serverUrl}/embed/tictactoe?afkWarning=0`;
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Tic-tac-toe" });
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
// src/components/subway-runner/index.tsx
|
package/dist/index.mjs
CHANGED
|
@@ -126,7 +126,7 @@ function Timer({ player, initialSeconds = 600, className }) {
|
|
|
126
126
|
// src/components/chess/ChessBoard.tsx
|
|
127
127
|
import { useEffect as useEffect3, useRef } from "react";
|
|
128
128
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
129
|
-
function ChessBoard({ className }) {
|
|
129
|
+
function ChessBoard({ className, showAfkWarning = true }) {
|
|
130
130
|
const { token, serverUrl, session } = useBetaGamer();
|
|
131
131
|
const iframeRef = useRef(null);
|
|
132
132
|
useEffect3(() => {
|
|
@@ -137,11 +137,12 @@ function ChessBoard({ className }) {
|
|
|
137
137
|
return () => iframe.removeEventListener("load", onLoad);
|
|
138
138
|
}, [token]);
|
|
139
139
|
if (session.game !== "chess") return null;
|
|
140
|
+
const src = showAfkWarning ? `${serverUrl}/embed/chess` : `${serverUrl}/embed/chess?afkWarning=0`;
|
|
140
141
|
return /* @__PURE__ */ jsx4(
|
|
141
142
|
"iframe",
|
|
142
143
|
{
|
|
143
144
|
ref: iframeRef,
|
|
144
|
-
src
|
|
145
|
+
src,
|
|
145
146
|
className,
|
|
146
147
|
style: { border: "none", width: "100%", height: "100%" },
|
|
147
148
|
allow: "autoplay",
|
|
@@ -218,7 +219,7 @@ function ChessCapturedPieces({ player, className }) {
|
|
|
218
219
|
// src/components/checkers/index.tsx
|
|
219
220
|
import { useEffect as useEffect6, useRef as useRef2 } from "react";
|
|
220
221
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
221
|
-
function CheckersBoard({ className }) {
|
|
222
|
+
function CheckersBoard({ className, showAfkWarning = true }) {
|
|
222
223
|
const { token, serverUrl, session } = useBetaGamer();
|
|
223
224
|
const iframeRef = useRef2(null);
|
|
224
225
|
useEffect6(() => {
|
|
@@ -229,13 +230,14 @@ function CheckersBoard({ className }) {
|
|
|
229
230
|
return () => iframe.removeEventListener("load", onLoad);
|
|
230
231
|
}, [token]);
|
|
231
232
|
if (session.game !== "checkers") return null;
|
|
232
|
-
|
|
233
|
+
const src = showAfkWarning ? `${serverUrl}/embed/checkers` : `${serverUrl}/embed/checkers?afkWarning=0`;
|
|
234
|
+
return /* @__PURE__ */ jsx7("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Checkers" });
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
// src/components/connect4/index.tsx
|
|
236
238
|
import { useEffect as useEffect7, useRef as useRef3 } from "react";
|
|
237
239
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
238
|
-
function Connect4Board({ className }) {
|
|
240
|
+
function Connect4Board({ className, showAfkWarning = true }) {
|
|
239
241
|
const { token, serverUrl, session } = useBetaGamer();
|
|
240
242
|
const iframeRef = useRef3(null);
|
|
241
243
|
useEffect7(() => {
|
|
@@ -246,7 +248,8 @@ function Connect4Board({ className }) {
|
|
|
246
248
|
return () => iframe.removeEventListener("load", onLoad);
|
|
247
249
|
}, [token]);
|
|
248
250
|
if (session.game !== "connect4") return null;
|
|
249
|
-
|
|
251
|
+
const src = showAfkWarning ? `${serverUrl}/embed/connect4` : `${serverUrl}/embed/connect4?afkWarning=0`;
|
|
252
|
+
return /* @__PURE__ */ jsx8("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Connect 4" });
|
|
250
253
|
}
|
|
251
254
|
function Connect4Score({ className }) {
|
|
252
255
|
const { gameState } = useBetaGamer();
|
|
@@ -257,7 +260,7 @@ function Connect4Score({ className }) {
|
|
|
257
260
|
// src/components/tictactoe/index.tsx
|
|
258
261
|
import { useEffect as useEffect8, useRef as useRef4 } from "react";
|
|
259
262
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
260
|
-
function TictactoeBoard({ className }) {
|
|
263
|
+
function TictactoeBoard({ className, showAfkWarning = true }) {
|
|
261
264
|
const { token, serverUrl, session } = useBetaGamer();
|
|
262
265
|
const iframeRef = useRef4(null);
|
|
263
266
|
useEffect8(() => {
|
|
@@ -268,7 +271,8 @@ function TictactoeBoard({ className }) {
|
|
|
268
271
|
return () => iframe.removeEventListener("load", onLoad);
|
|
269
272
|
}, [token]);
|
|
270
273
|
if (session.game !== "tictactoe") return null;
|
|
271
|
-
|
|
274
|
+
const src = showAfkWarning ? `${serverUrl}/embed/tictactoe` : `${serverUrl}/embed/tictactoe?afkWarning=0`;
|
|
275
|
+
return /* @__PURE__ */ jsx9("iframe", { ref: iframeRef, src, className, style: { border: "none", width: "100%", height: "100%" }, title: "Tic-tac-toe" });
|
|
272
276
|
}
|
|
273
277
|
|
|
274
278
|
// src/components/subway-runner/index.tsx
|