@beta-gamer/react 0.1.7 → 0.1.10
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.d.mts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -41,6 +41,7 @@ interface GameState {
|
|
|
41
41
|
|
|
42
42
|
interface BetaGamerContextValue {
|
|
43
43
|
token: string;
|
|
44
|
+
serverUrl: string;
|
|
44
45
|
session: SessionTokenPayload;
|
|
45
46
|
socket: Socket | null;
|
|
46
47
|
gameState: GameState;
|
|
@@ -85,10 +86,6 @@ declare function Timer({ player, initialSeconds, className }: TimerProps): react
|
|
|
85
86
|
interface ChessBoardProps {
|
|
86
87
|
className?: string;
|
|
87
88
|
}
|
|
88
|
-
/**
|
|
89
|
-
* The chess board — handles all game rendering and move input internally.
|
|
90
|
-
* Place this anywhere in your layout. Style the container via className.
|
|
91
|
-
*/
|
|
92
89
|
declare function ChessBoard({ className }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
93
90
|
|
|
94
91
|
interface ChessMoveHistoryProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ interface GameState {
|
|
|
41
41
|
|
|
42
42
|
interface BetaGamerContextValue {
|
|
43
43
|
token: string;
|
|
44
|
+
serverUrl: string;
|
|
44
45
|
session: SessionTokenPayload;
|
|
45
46
|
socket: Socket | null;
|
|
46
47
|
gameState: GameState;
|
|
@@ -85,10 +86,6 @@ declare function Timer({ player, initialSeconds, className }: TimerProps): react
|
|
|
85
86
|
interface ChessBoardProps {
|
|
86
87
|
className?: string;
|
|
87
88
|
}
|
|
88
|
-
/**
|
|
89
|
-
* The chess board — handles all game rendering and move input internally.
|
|
90
|
-
* Place this anywhere in your layout. Style the container via className.
|
|
91
|
-
*/
|
|
92
89
|
declare function ChessBoard({ className }: ChessBoardProps): react_jsx_runtime.JSX.Element | null;
|
|
93
90
|
|
|
94
91
|
interface ChessMoveHistoryProps {
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
|
|
|
99
99
|
setSocket(null);
|
|
100
100
|
};
|
|
101
101
|
}, [token, serverUrl, session.game, socketPath]);
|
|
102
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetaGamerContext.Provider, { value: { token, session, socket, gameState, theme: session.theme ?? {} }, children });
|
|
102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetaGamerContext.Provider, { value: { token, serverUrl, session, socket, gameState, theme: session.theme ?? {} }, children });
|
|
103
103
|
}
|
|
104
104
|
function useBetaGamer() {
|
|
105
105
|
const ctx = (0, import_react.useContext)(BetaGamerContext);
|
|
@@ -170,7 +170,7 @@ function Timer({ player, initialSeconds = 600, className }) {
|
|
|
170
170
|
var import_react3 = require("react");
|
|
171
171
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
172
172
|
function ChessBoard({ className }) {
|
|
173
|
-
const { token, session } = useBetaGamer();
|
|
173
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
174
174
|
const iframeRef = (0, import_react3.useRef)(null);
|
|
175
175
|
(0, import_react3.useEffect)(() => {
|
|
176
176
|
const iframe = iframeRef.current;
|
|
@@ -184,7 +184,7 @@ function ChessBoard({ className }) {
|
|
|
184
184
|
"iframe",
|
|
185
185
|
{
|
|
186
186
|
ref: iframeRef,
|
|
187
|
-
src: `${
|
|
187
|
+
src: `${serverUrl}/embed/chess`,
|
|
188
188
|
className,
|
|
189
189
|
style: { border: "none", width: "100%", height: "100%" },
|
|
190
190
|
allow: "autoplay",
|
|
@@ -262,7 +262,7 @@ function ChessCapturedPieces({ player, className }) {
|
|
|
262
262
|
var import_react6 = require("react");
|
|
263
263
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
264
264
|
function CheckersBoard({ className }) {
|
|
265
|
-
const { token, session } = useBetaGamer();
|
|
265
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
266
266
|
const iframeRef = (0, import_react6.useRef)(null);
|
|
267
267
|
(0, import_react6.useEffect)(() => {
|
|
268
268
|
const iframe = iframeRef.current;
|
|
@@ -272,14 +272,14 @@ function CheckersBoard({ className }) {
|
|
|
272
272
|
return () => iframe.removeEventListener("load", onLoad);
|
|
273
273
|
}, [token]);
|
|
274
274
|
if (session.game !== "checkers") return null;
|
|
275
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("iframe", { ref: iframeRef, src: `${
|
|
275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("iframe", { ref: iframeRef, src: `${serverUrl}/embed/checkers`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Checkers" });
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
// src/components/connect4/index.tsx
|
|
279
279
|
var import_react7 = require("react");
|
|
280
280
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
281
281
|
function Connect4Board({ className }) {
|
|
282
|
-
const { token, session } = useBetaGamer();
|
|
282
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
283
283
|
const iframeRef = (0, import_react7.useRef)(null);
|
|
284
284
|
(0, import_react7.useEffect)(() => {
|
|
285
285
|
const iframe = iframeRef.current;
|
|
@@ -289,7 +289,7 @@ function Connect4Board({ className }) {
|
|
|
289
289
|
return () => iframe.removeEventListener("load", onLoad);
|
|
290
290
|
}, [token]);
|
|
291
291
|
if (session.game !== "connect4") return null;
|
|
292
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("iframe", { ref: iframeRef, src: `${
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("iframe", { ref: iframeRef, src: `${serverUrl}/embed/connect4`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Connect 4" });
|
|
293
293
|
}
|
|
294
294
|
function Connect4Score({ className }) {
|
|
295
295
|
const { gameState } = useBetaGamer();
|
|
@@ -301,7 +301,7 @@ function Connect4Score({ className }) {
|
|
|
301
301
|
var import_react8 = require("react");
|
|
302
302
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
303
303
|
function TictactoeBoard({ className }) {
|
|
304
|
-
const { token, session } = useBetaGamer();
|
|
304
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
305
305
|
const iframeRef = (0, import_react8.useRef)(null);
|
|
306
306
|
(0, import_react8.useEffect)(() => {
|
|
307
307
|
const iframe = iframeRef.current;
|
|
@@ -311,7 +311,7 @@ function TictactoeBoard({ className }) {
|
|
|
311
311
|
return () => iframe.removeEventListener("load", onLoad);
|
|
312
312
|
}, [token]);
|
|
313
313
|
if (session.game !== "tictactoe") return null;
|
|
314
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("iframe", { ref: iframeRef, src: `${
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("iframe", { ref: iframeRef, src: `${serverUrl}/embed/tictactoe`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Tic-tac-toe" });
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
// src/components/subway-runner/index.tsx
|
package/dist/index.mjs
CHANGED
|
@@ -56,7 +56,7 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
|
|
|
56
56
|
setSocket(null);
|
|
57
57
|
};
|
|
58
58
|
}, [token, serverUrl, session.game, socketPath]);
|
|
59
|
-
return /* @__PURE__ */ jsx(BetaGamerContext.Provider, { value: { token, session, socket, gameState, theme: session.theme ?? {} }, children });
|
|
59
|
+
return /* @__PURE__ */ jsx(BetaGamerContext.Provider, { value: { token, serverUrl, session, socket, gameState, theme: session.theme ?? {} }, children });
|
|
60
60
|
}
|
|
61
61
|
function useBetaGamer() {
|
|
62
62
|
const ctx = useContext(BetaGamerContext);
|
|
@@ -127,7 +127,7 @@ function Timer({ player, initialSeconds = 600, className }) {
|
|
|
127
127
|
import { useEffect as useEffect3, useRef } from "react";
|
|
128
128
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
129
129
|
function ChessBoard({ className }) {
|
|
130
|
-
const { token, session } = useBetaGamer();
|
|
130
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
131
131
|
const iframeRef = useRef(null);
|
|
132
132
|
useEffect3(() => {
|
|
133
133
|
const iframe = iframeRef.current;
|
|
@@ -141,7 +141,7 @@ function ChessBoard({ className }) {
|
|
|
141
141
|
"iframe",
|
|
142
142
|
{
|
|
143
143
|
ref: iframeRef,
|
|
144
|
-
src: `${
|
|
144
|
+
src: `${serverUrl}/embed/chess`,
|
|
145
145
|
className,
|
|
146
146
|
style: { border: "none", width: "100%", height: "100%" },
|
|
147
147
|
allow: "autoplay",
|
|
@@ -219,7 +219,7 @@ function ChessCapturedPieces({ player, className }) {
|
|
|
219
219
|
import { useEffect as useEffect6, useRef as useRef2 } from "react";
|
|
220
220
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
221
221
|
function CheckersBoard({ className }) {
|
|
222
|
-
const { token, session } = useBetaGamer();
|
|
222
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
223
223
|
const iframeRef = useRef2(null);
|
|
224
224
|
useEffect6(() => {
|
|
225
225
|
const iframe = iframeRef.current;
|
|
@@ -229,14 +229,14 @@ function CheckersBoard({ className }) {
|
|
|
229
229
|
return () => iframe.removeEventListener("load", onLoad);
|
|
230
230
|
}, [token]);
|
|
231
231
|
if (session.game !== "checkers") return null;
|
|
232
|
-
return /* @__PURE__ */ jsx7("iframe", { ref: iframeRef, src: `${
|
|
232
|
+
return /* @__PURE__ */ jsx7("iframe", { ref: iframeRef, src: `${serverUrl}/embed/checkers`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Checkers" });
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
// src/components/connect4/index.tsx
|
|
236
236
|
import { useEffect as useEffect7, useRef as useRef3 } from "react";
|
|
237
237
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
238
238
|
function Connect4Board({ className }) {
|
|
239
|
-
const { token, session } = useBetaGamer();
|
|
239
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
240
240
|
const iframeRef = useRef3(null);
|
|
241
241
|
useEffect7(() => {
|
|
242
242
|
const iframe = iframeRef.current;
|
|
@@ -246,7 +246,7 @@ function Connect4Board({ className }) {
|
|
|
246
246
|
return () => iframe.removeEventListener("load", onLoad);
|
|
247
247
|
}, [token]);
|
|
248
248
|
if (session.game !== "connect4") return null;
|
|
249
|
-
return /* @__PURE__ */ jsx8("iframe", { ref: iframeRef, src: `${
|
|
249
|
+
return /* @__PURE__ */ jsx8("iframe", { ref: iframeRef, src: `${serverUrl}/embed/connect4`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Connect 4" });
|
|
250
250
|
}
|
|
251
251
|
function Connect4Score({ className }) {
|
|
252
252
|
const { gameState } = useBetaGamer();
|
|
@@ -258,7 +258,7 @@ function Connect4Score({ className }) {
|
|
|
258
258
|
import { useEffect as useEffect8, useRef as useRef4 } from "react";
|
|
259
259
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
260
260
|
function TictactoeBoard({ className }) {
|
|
261
|
-
const { token, session } = useBetaGamer();
|
|
261
|
+
const { token, serverUrl, session } = useBetaGamer();
|
|
262
262
|
const iframeRef = useRef4(null);
|
|
263
263
|
useEffect8(() => {
|
|
264
264
|
const iframe = iframeRef.current;
|
|
@@ -268,7 +268,7 @@ function TictactoeBoard({ className }) {
|
|
|
268
268
|
return () => iframe.removeEventListener("load", onLoad);
|
|
269
269
|
}, [token]);
|
|
270
270
|
if (session.game !== "tictactoe") return null;
|
|
271
|
-
return /* @__PURE__ */ jsx9("iframe", { ref: iframeRef, src: `${
|
|
271
|
+
return /* @__PURE__ */ jsx9("iframe", { ref: iframeRef, src: `${serverUrl}/embed/tictactoe`, className, style: { border: "none", width: "100%", height: "100%" }, title: "Tic-tac-toe" });
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
// src/components/subway-runner/index.tsx
|