@beta-gamer/react-native 0.1.12 → 0.1.19

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 CHANGED
@@ -85,7 +85,7 @@ const styles = StyleSheet.create({
85
85
 
86
86
  | Component | Props | Description |
87
87
  |-----------|-------|-------------|
88
- | `BetaGamerProvider` | `token`, `serverUrl?` | Wrap your game UI with this. Handles socket connection and theme. |
88
+ | `BetaGamerProvider` | `token`, `serverUrl?`, `socketPath?` | Wrap your game UI with this. Handles socket connection and theme. |
89
89
  | `PlayerCard` | `player`, `style?`, `nameStyle?`, `indicatorStyle?` | Player name + active-turn indicator |
90
90
  | `Timer` | `player`, `initialSeconds?`, `style?`, `textStyle?` | Live countdown clock, syncs with server |
91
91
 
@@ -93,17 +93,19 @@ const styles = StyleSheet.create({
93
93
 
94
94
  | Component | Props | Description |
95
95
  |-----------|-------|-------------|
96
- | `ChessBoard` | `style?` | Interactive chess board (WebView) |
96
+ | `ChessBoard` | `style?`, `showAfkWarning?` | Interactive chess board (WebView) |
97
97
  | `ChessMoveHistory` | `style?`, `textStyle?`, `rowStyle?` | Scrollable move list in algebraic notation |
98
98
 
99
99
  ### Other games
100
100
 
101
- | Component | Game |
102
- |-----------|------|
103
- | `CheckersBoard` | checkers |
104
- | `Connect4Board` | connect4 |
105
- | `TictactoeBoard` | tictactoe |
106
- | `SubwayRunnerGame`, `SubwayRunnerScore`, `SubwayRunnerLives` | subway-runner |
101
+ | Component | Props | Game |
102
+ |-----------|-------|------|
103
+ | `CheckersBoard` | `style?`, `showAfkWarning?` | checkers |
104
+ | `Connect4Board` | `style?`, `showAfkWarning?` | connect4 |
105
+ | `TictactoeBoard` | `style?`, `showAfkWarning?` | tictactoe |
106
+ | `SubwayRunnerGame`, `SubwayRunnerScore`, `SubwayRunnerLives` | `style?` | subway-runner |
107
+
108
+ > **`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.
107
109
 
108
110
  ## Hooks
109
111
 
package/dist/index.d.mts CHANGED
@@ -82,8 +82,9 @@ interface TimerProps {
82
82
  }
83
83
  declare function Timer({ player, initialSeconds, style, textStyle }: TimerProps): react_jsx_runtime.JSX.Element;
84
84
 
85
- declare function ChessBoard({ style }: {
85
+ declare function ChessBoard({ style, showAfkWarning }: {
86
86
  style?: ViewStyle;
87
+ showAfkWarning?: boolean;
87
88
  }): react_jsx_runtime.JSX.Element;
88
89
 
89
90
  interface ChessMoveHistoryProps {
@@ -93,16 +94,19 @@ interface ChessMoveHistoryProps {
93
94
  }
94
95
  declare function ChessMoveHistory({ style, rowStyle, textStyle }: ChessMoveHistoryProps): react_jsx_runtime.JSX.Element;
95
96
 
96
- declare function CheckersBoard({ style }: {
97
+ declare function CheckersBoard({ style, showAfkWarning }: {
97
98
  style?: ViewStyle;
99
+ showAfkWarning?: boolean;
98
100
  }): react_jsx_runtime.JSX.Element;
99
101
 
100
- declare function Connect4Board({ style }: {
102
+ declare function Connect4Board({ style, showAfkWarning }: {
101
103
  style?: ViewStyle;
104
+ showAfkWarning?: boolean;
102
105
  }): react_jsx_runtime.JSX.Element;
103
106
 
104
- declare function TictactoeBoard({ style }: {
107
+ declare function TictactoeBoard({ style, showAfkWarning }: {
105
108
  style?: ViewStyle;
109
+ showAfkWarning?: boolean;
106
110
  }): react_jsx_runtime.JSX.Element;
107
111
 
108
112
  declare function SubwayRunnerGame({ style }: {
package/dist/index.d.ts CHANGED
@@ -82,8 +82,9 @@ interface TimerProps {
82
82
  }
83
83
  declare function Timer({ player, initialSeconds, style, textStyle }: TimerProps): react_jsx_runtime.JSX.Element;
84
84
 
85
- declare function ChessBoard({ style }: {
85
+ declare function ChessBoard({ style, showAfkWarning }: {
86
86
  style?: ViewStyle;
87
+ showAfkWarning?: boolean;
87
88
  }): react_jsx_runtime.JSX.Element;
88
89
 
89
90
  interface ChessMoveHistoryProps {
@@ -93,16 +94,19 @@ interface ChessMoveHistoryProps {
93
94
  }
94
95
  declare function ChessMoveHistory({ style, rowStyle, textStyle }: ChessMoveHistoryProps): react_jsx_runtime.JSX.Element;
95
96
 
96
- declare function CheckersBoard({ style }: {
97
+ declare function CheckersBoard({ style, showAfkWarning }: {
97
98
  style?: ViewStyle;
99
+ showAfkWarning?: boolean;
98
100
  }): react_jsx_runtime.JSX.Element;
99
101
 
100
- declare function Connect4Board({ style }: {
102
+ declare function Connect4Board({ style, showAfkWarning }: {
101
103
  style?: ViewStyle;
104
+ showAfkWarning?: boolean;
102
105
  }): react_jsx_runtime.JSX.Element;
103
106
 
104
- declare function TictactoeBoard({ style }: {
107
+ declare function TictactoeBoard({ style, showAfkWarning }: {
105
108
  style?: ViewStyle;
109
+ showAfkWarning?: boolean;
106
110
  }): react_jsx_runtime.JSX.Element;
107
111
 
108
112
  declare function SubwayRunnerGame({ style }: {
package/dist/index.js CHANGED
@@ -197,20 +197,21 @@ function Timer({ player, initialSeconds = 600, style, textStyle }) {
197
197
  var import_react3 = require("react");
198
198
  var import_react_native_webview = require("react-native-webview");
199
199
  var import_jsx_runtime4 = require("react/jsx-runtime");
200
- function GameWebView({ game, style }) {
200
+ function GameWebView({ game, style, showAfkWarning = true }) {
201
201
  const { token, serverUrl, session } = useBetaGamer();
202
202
  const webViewRef = (0, import_react3.useRef)(null);
203
203
  if (session.game !== game) return null;
204
+ const uri = showAfkWarning ? `${serverUrl}/embed/${game}` : `${serverUrl}/embed/${game}?afkWarning=0`;
204
205
  const initScript = `
205
206
  window.__BG_TOKEN__ = ${JSON.stringify(token)};
206
- window.dispatchEvent(new Event('bg:ready'));
207
+ window.postMessage(JSON.stringify({ type: 'bg:init', token: ${JSON.stringify(token)} }), '*');
207
208
  true;
208
209
  `;
209
210
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
210
211
  import_react_native_webview.WebView,
211
212
  {
212
213
  ref: webViewRef,
213
- source: { uri: `${serverUrl}/embed/${game}` },
214
+ source: { uri },
214
215
  injectedJavaScriptBeforeContentLoaded: initScript,
215
216
  style: [{ flex: 1 }, style],
216
217
  allowsInlineMediaPlayback: true,
@@ -221,8 +222,8 @@ function GameWebView({ game, style }) {
221
222
 
222
223
  // src/components/chess/ChessBoard.tsx
223
224
  var import_jsx_runtime5 = require("react/jsx-runtime");
224
- function ChessBoard({ style }) {
225
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GameWebView, { game: "chess", style });
225
+ function ChessBoard({ style, showAfkWarning }) {
226
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GameWebView, { game: "chess", style, showAfkWarning });
226
227
  }
227
228
 
228
229
  // src/components/chess/ChessMoveHistory.tsx
@@ -263,20 +264,20 @@ function ChessMoveHistory({ style, rowStyle, textStyle }) {
263
264
 
264
265
  // src/components/checkers/index.tsx
265
266
  var import_jsx_runtime7 = require("react/jsx-runtime");
266
- function CheckersBoard({ style }) {
267
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(GameWebView, { game: "checkers", style });
267
+ function CheckersBoard({ style, showAfkWarning }) {
268
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(GameWebView, { game: "checkers", style, showAfkWarning });
268
269
  }
269
270
 
270
271
  // src/components/connect4/index.tsx
271
272
  var import_jsx_runtime8 = require("react/jsx-runtime");
272
- function Connect4Board({ style }) {
273
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GameWebView, { game: "connect4", style });
273
+ function Connect4Board({ style, showAfkWarning }) {
274
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GameWebView, { game: "connect4", style, showAfkWarning });
274
275
  }
275
276
 
276
277
  // src/components/tictactoe/index.tsx
277
278
  var import_jsx_runtime9 = require("react/jsx-runtime");
278
- function TictactoeBoard({ style }) {
279
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GameWebView, { game: "tictactoe", style });
279
+ function TictactoeBoard({ style, showAfkWarning }) {
280
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GameWebView, { game: "tictactoe", style, showAfkWarning });
280
281
  }
281
282
 
282
283
  // src/components/subway-runner/index.tsx
package/dist/index.mjs CHANGED
@@ -156,20 +156,21 @@ function Timer({ player, initialSeconds = 600, style, textStyle }) {
156
156
  import { useRef } from "react";
157
157
  import { WebView } from "react-native-webview";
158
158
  import { jsx as jsx4 } from "react/jsx-runtime";
159
- function GameWebView({ game, style }) {
159
+ function GameWebView({ game, style, showAfkWarning = true }) {
160
160
  const { token, serverUrl, session } = useBetaGamer();
161
161
  const webViewRef = useRef(null);
162
162
  if (session.game !== game) return null;
163
+ const uri = showAfkWarning ? `${serverUrl}/embed/${game}` : `${serverUrl}/embed/${game}?afkWarning=0`;
163
164
  const initScript = `
164
165
  window.__BG_TOKEN__ = ${JSON.stringify(token)};
165
- window.dispatchEvent(new Event('bg:ready'));
166
+ window.postMessage(JSON.stringify({ type: 'bg:init', token: ${JSON.stringify(token)} }), '*');
166
167
  true;
167
168
  `;
168
169
  return /* @__PURE__ */ jsx4(
169
170
  WebView,
170
171
  {
171
172
  ref: webViewRef,
172
- source: { uri: `${serverUrl}/embed/${game}` },
173
+ source: { uri },
173
174
  injectedJavaScriptBeforeContentLoaded: initScript,
174
175
  style: [{ flex: 1 }, style],
175
176
  allowsInlineMediaPlayback: true,
@@ -180,8 +181,8 @@ function GameWebView({ game, style }) {
180
181
 
181
182
  // src/components/chess/ChessBoard.tsx
182
183
  import { jsx as jsx5 } from "react/jsx-runtime";
183
- function ChessBoard({ style }) {
184
- return /* @__PURE__ */ jsx5(GameWebView, { game: "chess", style });
184
+ function ChessBoard({ style, showAfkWarning }) {
185
+ return /* @__PURE__ */ jsx5(GameWebView, { game: "chess", style, showAfkWarning });
185
186
  }
186
187
 
187
188
  // src/components/chess/ChessMoveHistory.tsx
@@ -222,20 +223,20 @@ function ChessMoveHistory({ style, rowStyle, textStyle }) {
222
223
 
223
224
  // src/components/checkers/index.tsx
224
225
  import { jsx as jsx7 } from "react/jsx-runtime";
225
- function CheckersBoard({ style }) {
226
- return /* @__PURE__ */ jsx7(GameWebView, { game: "checkers", style });
226
+ function CheckersBoard({ style, showAfkWarning }) {
227
+ return /* @__PURE__ */ jsx7(GameWebView, { game: "checkers", style, showAfkWarning });
227
228
  }
228
229
 
229
230
  // src/components/connect4/index.tsx
230
231
  import { jsx as jsx8 } from "react/jsx-runtime";
231
- function Connect4Board({ style }) {
232
- return /* @__PURE__ */ jsx8(GameWebView, { game: "connect4", style });
232
+ function Connect4Board({ style, showAfkWarning }) {
233
+ return /* @__PURE__ */ jsx8(GameWebView, { game: "connect4", style, showAfkWarning });
233
234
  }
234
235
 
235
236
  // src/components/tictactoe/index.tsx
236
237
  import { jsx as jsx9 } from "react/jsx-runtime";
237
- function TictactoeBoard({ style }) {
238
- return /* @__PURE__ */ jsx9(GameWebView, { game: "tictactoe", style });
238
+ function TictactoeBoard({ style, showAfkWarning }) {
239
+ return /* @__PURE__ */ jsx9(GameWebView, { game: "tictactoe", style, showAfkWarning });
239
240
  }
240
241
 
241
242
  // src/components/subway-runner/index.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beta-gamer/react-native",
3
- "version": "0.1.12",
3
+ "version": "0.1.19",
4
4
  "description": "React Native SDK for Beta Gamer GaaS — composable game components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",