@beta-gamer/react-native 0.1.9 → 0.1.18

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 CHANGED
@@ -42,6 +42,7 @@ interface GameState {
42
42
 
43
43
  interface BetaGamerContextValue {
44
44
  token: string;
45
+ serverUrl: string;
45
46
  session: SessionTokenPayload;
46
47
  socket: Socket | null;
47
48
  gameState: GameState;
package/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ interface GameState {
42
42
 
43
43
  interface BetaGamerContextValue {
44
44
  token: string;
45
+ serverUrl: string;
45
46
  session: SessionTokenPayload;
46
47
  socket: Socket | null;
47
48
  gameState: GameState;
package/dist/index.js CHANGED
@@ -124,7 +124,7 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
124
124
  setSocket(null);
125
125
  };
126
126
  }, [token, serverUrl, socketPath, session.game]);
127
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetaGamerContext.Provider, { value: { token, session, socket, gameState, theme: session.theme ?? {} }, children });
127
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BetaGamerContext.Provider, { value: { token, serverUrl, session, socket, gameState, theme: session.theme ?? {} }, children });
128
128
  }
129
129
  function useBetaGamer() {
130
130
  const ctx = (0, import_react.useContext)(BetaGamerContext);
@@ -197,21 +197,20 @@ 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
- var BASE_URL = "https://api.beta-gamer.com";
201
200
  function GameWebView({ game, style }) {
202
- const { token, session } = useBetaGamer();
201
+ const { token, serverUrl, session } = useBetaGamer();
203
202
  const webViewRef = (0, import_react3.useRef)(null);
204
203
  if (session.game !== game) return null;
205
204
  const initScript = `
206
205
  window.__BG_TOKEN__ = ${JSON.stringify(token)};
207
- window.dispatchEvent(new Event('bg:ready'));
206
+ window.postMessage(JSON.stringify({ type: 'bg:init', token: ${JSON.stringify(token)} }), '*');
208
207
  true;
209
208
  `;
210
209
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
211
210
  import_react_native_webview.WebView,
212
211
  {
213
212
  ref: webViewRef,
214
- source: { uri: `${BASE_URL}/embed/${game}` },
213
+ source: { uri: `${serverUrl}/embed/${game}` },
215
214
  injectedJavaScriptBeforeContentLoaded: initScript,
216
215
  style: [{ flex: 1 }, style],
217
216
  allowsInlineMediaPlayback: true,
package/dist/index.mjs CHANGED
@@ -83,7 +83,7 @@ function BetaGamerProvider({ token, serverUrl = "https://api.beta-gamer.com", so
83
83
  setSocket(null);
84
84
  };
85
85
  }, [token, serverUrl, socketPath, session.game]);
86
- return /* @__PURE__ */ jsx(BetaGamerContext.Provider, { value: { token, session, socket, gameState, theme: session.theme ?? {} }, children });
86
+ return /* @__PURE__ */ jsx(BetaGamerContext.Provider, { value: { token, serverUrl, session, socket, gameState, theme: session.theme ?? {} }, children });
87
87
  }
88
88
  function useBetaGamer() {
89
89
  const ctx = useContext(BetaGamerContext);
@@ -156,21 +156,20 @@ 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
- var BASE_URL = "https://api.beta-gamer.com";
160
159
  function GameWebView({ game, style }) {
161
- const { token, session } = useBetaGamer();
160
+ const { token, serverUrl, session } = useBetaGamer();
162
161
  const webViewRef = useRef(null);
163
162
  if (session.game !== game) return null;
164
163
  const initScript = `
165
164
  window.__BG_TOKEN__ = ${JSON.stringify(token)};
166
- window.dispatchEvent(new Event('bg:ready'));
165
+ window.postMessage(JSON.stringify({ type: 'bg:init', token: ${JSON.stringify(token)} }), '*');
167
166
  true;
168
167
  `;
169
168
  return /* @__PURE__ */ jsx4(
170
169
  WebView,
171
170
  {
172
171
  ref: webViewRef,
173
- source: { uri: `${BASE_URL}/embed/${game}` },
172
+ source: { uri: `${serverUrl}/embed/${game}` },
174
173
  injectedJavaScriptBeforeContentLoaded: initScript,
175
174
  style: [{ flex: 1 }, style],
176
175
  allowsInlineMediaPlayback: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beta-gamer/react-native",
3
- "version": "0.1.9",
3
+ "version": "0.1.18",
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",