promogame-player 1.0.5 → 1.0.7

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.
@@ -1,38 +1,39 @@
1
- import { jsxs as O, Fragment as Y, jsx as $ } from "react/jsx-runtime";
1
+ import { jsxs as $, Fragment as Y, jsx as G } from "react/jsx-runtime";
2
2
  import * as Z from "react";
3
- import k, { useRef as G, useImperativeHandle as p, useEffect as D } from "react";
4
- import { cn as ee } from "../../utils.js";
5
- var B = {}, E = {}, x = {}, F;
6
- function te() {
7
- if (F) return x;
8
- F = 1, Object.defineProperty(x, "__esModule", { value: !0 }), x.useCanvasIdentifier = void 0;
9
- var s = k, l = 0, v = "react-unity-webgl-canvas", o = function(y) {
10
- var a = (0, s.useState)(0), e = a[0], n = a[1], r = (0, s.useCallback)(function() {
3
+ import x, { useRef as D, useImperativeHandle as p, useEffect as B, useState as ee } from "react";
4
+ import te from "../../hooks/use-broadcast-channel.js";
5
+ import { cn as re } from "../../utils.js";
6
+ var O = {}, g = {}, M = {}, F;
7
+ function ne() {
8
+ if (F) return M;
9
+ F = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.useCanvasIdentifier = void 0;
10
+ var s = x, c = 0, v = "react-unity-webgl-canvas", o = function(m) {
11
+ var i = (0, s.useState)(0), e = i[0], n = i[1], r = (0, s.useCallback)(function() {
11
12
  n(function(d) {
12
13
  return d + 1;
13
14
  });
14
15
  }, []);
15
- if (y !== void 0)
16
- return [y, r];
16
+ if (m !== void 0)
17
+ return [m, r];
17
18
  var u = (0, s.useMemo)(function() {
18
- return [v, l].join("-");
19
+ return [v, c].join("-");
19
20
  }, [e]);
20
21
  return [u, r];
21
22
  };
22
- return x.useCanvasIdentifier = o, x;
23
+ return M.useCanvasIdentifier = o, M;
23
24
  }
24
- var M = {}, q = {}, z;
25
+ var q = {}, R = {}, z;
25
26
  function X() {
26
- return z || (z = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.isBrowserEnvironment = void 0, q.isBrowserEnvironment = typeof window < "u" && typeof document < "u"), q;
27
+ return z || (z = 1, Object.defineProperty(R, "__esModule", { value: !0 }), R.isBrowserEnvironment = void 0, R.isBrowserEnvironment = typeof window < "u" && typeof document < "u"), R;
27
28
  }
28
29
  var V;
29
- function re() {
30
- if (V) return M;
31
- V = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.useUnityLoader = void 0;
32
- var s = k, l = X(), v = function(o) {
33
- var y = (0, s.useState)("Loading"), a = y[0], e = y[1];
30
+ function ae() {
31
+ if (V) return q;
32
+ V = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.useUnityLoader = void 0;
33
+ var s = x, c = X(), v = function(o) {
34
+ var m = (0, s.useState)("Loading"), i = m[0], e = m[1];
34
35
  return (0, s.useEffect)(function() {
35
- if (l.isBrowserEnvironment !== !1) {
36
+ if (c.isBrowserEnvironment !== !1) {
36
37
  if (o === null) {
37
38
  e("Idle");
38
39
  return;
@@ -50,124 +51,124 @@ function re() {
50
51
  n !== null && (n.removeEventListener("load", r), n.removeEventListener("error", r), n.remove());
51
52
  };
52
53
  }
53
- }, [o]), a;
54
+ }, [o]), i;
54
55
  };
55
- return M.useUnityLoader = v, M;
56
+ return q.useUnityLoader = v, q;
56
57
  }
57
58
  var W;
58
- function ne() {
59
- if (W) return E;
59
+ function ie() {
60
+ if (W) return g;
60
61
  W = 1;
61
- var s = E && E.__awaiter || function(e, n, r, u) {
62
+ var s = g && g.__awaiter || function(e, n, r, u) {
62
63
  function d(t) {
63
- return t instanceof r ? t : new r(function(c) {
64
- c(t);
64
+ return t instanceof r ? t : new r(function(l) {
65
+ l(t);
65
66
  });
66
67
  }
67
- return new (r || (r = Promise))(function(t, c) {
68
- function m(U) {
68
+ return new (r || (r = Promise))(function(t, l) {
69
+ function U(b) {
69
70
  try {
70
- i(u.next(U));
71
- } catch (_) {
72
- c(_);
71
+ a(u.next(b));
72
+ } catch (w) {
73
+ l(w);
73
74
  }
74
75
  }
75
- function w(U) {
76
+ function _(b) {
76
77
  try {
77
- i(u.throw(U));
78
- } catch (_) {
79
- c(_);
78
+ a(u.throw(b));
79
+ } catch (w) {
80
+ l(w);
80
81
  }
81
82
  }
82
- function i(U) {
83
- U.done ? t(U.value) : d(U.value).then(m, w);
83
+ function a(b) {
84
+ b.done ? t(b.value) : d(b.value).then(U, _);
84
85
  }
85
- i((u = u.apply(e, n || [])).next());
86
+ a((u = u.apply(e, n || [])).next());
86
87
  });
87
- }, l = E && E.__generator || function(e, n) {
88
+ }, c = g && g.__generator || function(e, n) {
88
89
  var r = { label: 0, sent: function() {
89
90
  if (t[0] & 1) throw t[1];
90
91
  return t[1];
91
- }, trys: [], ops: [] }, u, d, t, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
92
- return c.next = m(0), c.throw = m(1), c.return = m(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() {
92
+ }, trys: [], ops: [] }, u, d, t, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
93
+ return l.next = U(0), l.throw = U(1), l.return = U(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() {
93
94
  return this;
94
- }), c;
95
- function m(i) {
96
- return function(U) {
97
- return w([i, U]);
95
+ }), l;
96
+ function U(a) {
97
+ return function(b) {
98
+ return _([a, b]);
98
99
  };
99
100
  }
100
- function w(i) {
101
+ function _(a) {
101
102
  if (u) throw new TypeError("Generator is already executing.");
102
- for (; c && (c = 0, i[0] && (r = 0)), r; ) try {
103
- if (u = 1, d && (t = i[0] & 2 ? d.return : i[0] ? d.throw || ((t = d.return) && t.call(d), 0) : d.next) && !(t = t.call(d, i[1])).done) return t;
104
- switch (d = 0, t && (i = [i[0] & 2, t.value]), i[0]) {
103
+ for (; l && (l = 0, a[0] && (r = 0)), r; ) try {
104
+ if (u = 1, d && (t = a[0] & 2 ? d.return : a[0] ? d.throw || ((t = d.return) && t.call(d), 0) : d.next) && !(t = t.call(d, a[1])).done) return t;
105
+ switch (d = 0, t && (a = [a[0] & 2, t.value]), a[0]) {
105
106
  case 0:
106
107
  case 1:
107
- t = i;
108
+ t = a;
108
109
  break;
109
110
  case 4:
110
- return r.label++, { value: i[1], done: !1 };
111
+ return r.label++, { value: a[1], done: !1 };
111
112
  case 5:
112
- r.label++, d = i[1], i = [0];
113
+ r.label++, d = a[1], a = [0];
113
114
  continue;
114
115
  case 7:
115
- i = r.ops.pop(), r.trys.pop();
116
+ a = r.ops.pop(), r.trys.pop();
116
117
  continue;
117
118
  default:
118
- if (t = r.trys, !(t = t.length > 0 && t[t.length - 1]) && (i[0] === 6 || i[0] === 2)) {
119
+ if (t = r.trys, !(t = t.length > 0 && t[t.length - 1]) && (a[0] === 6 || a[0] === 2)) {
119
120
  r = 0;
120
121
  continue;
121
122
  }
122
- if (i[0] === 3 && (!t || i[1] > t[0] && i[1] < t[3])) {
123
- r.label = i[1];
123
+ if (a[0] === 3 && (!t || a[1] > t[0] && a[1] < t[3])) {
124
+ r.label = a[1];
124
125
  break;
125
126
  }
126
- if (i[0] === 6 && r.label < t[1]) {
127
- r.label = t[1], t = i;
127
+ if (a[0] === 6 && r.label < t[1]) {
128
+ r.label = t[1], t = a;
128
129
  break;
129
130
  }
130
131
  if (t && r.label < t[2]) {
131
- r.label = t[2], r.ops.push(i);
132
+ r.label = t[2], r.ops.push(a);
132
133
  break;
133
134
  }
134
135
  t[2] && r.ops.pop(), r.trys.pop();
135
136
  continue;
136
137
  }
137
- i = n.call(e, r);
138
- } catch (U) {
139
- i = [6, U], d = 0;
138
+ a = n.call(e, r);
139
+ } catch (b) {
140
+ a = [6, b], d = 0;
140
141
  } finally {
141
142
  u = t = 0;
142
143
  }
143
- if (i[0] & 5) throw i[1];
144
- return { value: i[0] ? i[1] : void 0, done: !0 };
144
+ if (a[0] & 5) throw a[1];
145
+ return { value: a[0] ? a[1] : void 0, done: !0 };
145
146
  }
146
147
  };
147
- Object.defineProperty(E, "__esModule", { value: !0 }), E.Unity = void 0;
148
- var v = k, o = te(), y = re(), a = (0, v.forwardRef)(
148
+ Object.defineProperty(g, "__esModule", { value: !0 }), g.Unity = void 0;
149
+ var v = x, o = ne(), m = ae(), i = (0, v.forwardRef)(
149
150
  /**
150
151
  * @param unityProps The Unity props provided the the Unity component.
151
152
  * @param forwardedRef The forwarded ref to the Unity component.
152
153
  * @returns The Unity canvas renderer.
153
154
  */
154
155
  function(e, n) {
155
- var r = (0, v.useState)(null), u = r[0], d = r[1], t = (0, v.useState)(null), c = t[0], m = t[1], w = (0, o.useCanvasIdentifier)(e.id), i = w[0], U = w[1], _ = (0, y.useUnityLoader)(e.unityProvider.loaderUrl), h = (0, v.useCallback)(function(L) {
156
- e.unityProvider.setLoadingProgression(L), L === 1 && e.unityProvider.setIsLoaded(!0);
156
+ var r = (0, v.useState)(null), u = r[0], d = r[1], t = (0, v.useState)(null), l = t[0], U = t[1], _ = (0, o.useCanvasIdentifier)(e.id), a = _[0], b = _[1], w = (0, m.useUnityLoader)(e.unityProvider.loaderUrl), k = (0, v.useCallback)(function(E) {
157
+ e.unityProvider.setLoadingProgression(E), E === 1 && e.unityProvider.setIsLoaded(!0);
157
158
  }, [e.unityProvider]);
158
159
  return (0, v.useEffect)(function() {
159
- var L = function() {
160
+ var E = function() {
160
161
  return s(void 0, void 0, void 0, function() {
161
- var b, g, I, f, C;
162
- return l(this, function(P) {
163
- switch (P.label) {
162
+ var f, P, L, y, C;
163
+ return c(this, function(h) {
164
+ switch (h.label) {
164
165
  case 0:
165
- if (!u || c || _ !== "Loaded")
166
+ if (!u || l || w !== "Loaded")
166
167
  return [
167
168
  2
168
169
  /*return*/
169
170
  ];
170
- console.log("React Unity WebGL: Initializing Unity instance..."), e.unityProvider.setUnityInstance(null), m(null), e.unityProvider.setLoadingProgression(0), (C = (f = e.unityProvider).setIsLoaded) === null || C === void 0 || C.call(f, !1), e.unityProvider.setInitialisationError(void 0), U(), b = {
171
+ console.log("React Unity WebGL: Initializing Unity instance..."), e.unityProvider.setUnityInstance(null), U(null), e.unityProvider.setLoadingProgression(0), (C = (y = e.unityProvider).setIsLoaded) === null || C === void 0 || C.call(y, !1), e.unityProvider.setInitialisationError(void 0), b(), f = {
171
172
  companyName: e.unityProvider.companyName,
172
173
  productName: e.unityProvider.productName,
173
174
  productVersion: e.unityProvider.productVersion,
@@ -184,15 +185,15 @@ function ne() {
184
185
  autoSyncPersistentDataPath: e.unityProvider.autoSyncPersistentDataPath,
185
186
  matchWebGLToCanvasSize: e.matchWebGLToCanvasSize,
186
187
  disabledCanvasEvents: e.disabledCanvasEvents
187
- }, Object.keys(b).forEach(function(N) {
188
- (b[N] === null || b[N] === void 0) && delete b[N];
189
- }), P.label = 1;
188
+ }, Object.keys(f).forEach(function(N) {
189
+ (f[N] === null || f[N] === void 0) && delete f[N];
190
+ }), h.label = 1;
190
191
  case 1:
191
- return P.trys.push([1, 3, , 4]), [4, window.createUnityInstance(u, b, h)];
192
+ return h.trys.push([1, 3, , 4]), [4, window.createUnityInstance(u, f, k)];
192
193
  case 2:
193
- return g = P.sent(), m(g), e.unityProvider.setUnityInstance(g), [3, 4];
194
+ return P = h.sent(), U(P), e.unityProvider.setUnityInstance(P), [3, 4];
194
195
  case 3:
195
- return I = P.sent(), console.error("React Unity WebGL: Error initializing Unity instance:", I), e.unityProvider.setInitialisationError(I), [3, 4];
196
+ return L = h.sent(), console.error("React Unity WebGL: Error initializing Unity instance:", L), e.unityProvider.setInitialisationError(L), [3, 4];
196
197
  case 4:
197
198
  return [
198
199
  2
@@ -201,18 +202,18 @@ function ne() {
201
202
  }
202
203
  });
203
204
  });
204
- }, A = function() {
205
+ }, I = function() {
205
206
  return s(void 0, void 0, void 0, function() {
206
- var b, g, I;
207
- return l(this, function(f) {
208
- switch (f.label) {
207
+ var f, P, L;
208
+ return c(this, function(y) {
209
+ switch (y.label) {
209
210
  case 0:
210
- return !c || !u ? [
211
+ return !l || !u ? [
211
212
  2
212
213
  /*return*/
213
- ] : (console.log("React Unity WebGL: Detaching Unity instance..."), e.unityProvider.setUnityInstance(null), m(null), e.unityProvider.setLoadingProgression(0), (I = (g = e.unityProvider).setIsLoaded) === null || I === void 0 || I.call(g, !1), e.unityProvider.setInitialisationError(void 0), b = document.createElement("canvas"), b.id = u.id, b.setAttribute("react-unity-webgl-role", "cleanup"), b.style.display = "none", document.body.appendChild(b), c.Module.canvas = b, m(null), [4, c.Quit()]);
214
+ ] : (console.log("React Unity WebGL: Detaching Unity instance..."), e.unityProvider.setUnityInstance(null), U(null), e.unityProvider.setLoadingProgression(0), (L = (P = e.unityProvider).setIsLoaded) === null || L === void 0 || L.call(P, !1), e.unityProvider.setInitialisationError(void 0), f = document.createElement("canvas"), f.id = u.id, f.setAttribute("react-unity-webgl-role", "cleanup"), f.style.display = "none", document.body.appendChild(f), l.Module.canvas = f, U(null), [4, l.Quit()]);
214
215
  case 1:
215
- return f.sent(), document.body.removeChild(b), [
216
+ return y.sent(), document.body.removeChild(f), [
216
217
  2
217
218
  /*return*/
218
219
  ];
@@ -220,24 +221,24 @@ function ne() {
220
221
  });
221
222
  });
222
223
  };
223
- return L(), function() {
224
- A();
224
+ return E(), function() {
225
+ I();
225
226
  };
226
- }, [u, c, _, e.unityProvider]), (0, v.useImperativeHandle)(n, function() {
227
+ }, [u, l, w, e.unityProvider]), (0, v.useImperativeHandle)(n, function() {
227
228
  return u;
228
229
  }), (0, v.createElement)("canvas", {
229
230
  ref: d,
230
- id: i,
231
+ id: a,
231
232
  style: e.style,
232
233
  className: e.className,
233
234
  tabIndex: e.tabIndex
234
235
  });
235
236
  }
236
237
  );
237
- return E.Unity = a, E;
238
+ return g.Unity = i, g;
238
239
  }
239
- var R = {}, S = {}, T;
240
- function ie() {
240
+ var j = {}, S = {}, T;
241
+ function ue() {
241
242
  if (T) return S;
242
243
  T = 1;
243
244
  var s = S && S.__spreadArray || function(e, n, r) {
@@ -246,7 +247,7 @@ function ie() {
246
247
  return e.concat(t || Array.prototype.slice.call(n));
247
248
  };
248
249
  Object.defineProperty(S, "__esModule", { value: !0 }), S.useEventSystem = void 0;
249
- var l = k, v = X(), o = [], y = function(e) {
250
+ var c = x, v = X(), o = [], m = function(e) {
250
251
  for (var n = [], r = 1; r < arguments.length; r++)
251
252
  n[r - 1] = arguments[r];
252
253
  var u = void 0;
@@ -254,9 +255,9 @@ function ie() {
254
255
  u = d.apply(void 0, s([e], n, !1));
255
256
  }), u;
256
257
  };
257
- v.isBrowserEnvironment === !0 && (window.dispatchReactUnityEvent = y);
258
- var a = function() {
259
- var e = (0, l.useRef)([]), n = (0, l.useCallback)(
258
+ v.isBrowserEnvironment === !0 && (window.dispatchReactUnityEvent = m);
259
+ var i = function() {
260
+ var e = (0, c.useRef)([]), n = (0, c.useCallback)(
260
261
  /**
261
262
  * @param eventName The name of the event to listen to.
262
263
  * @param callback The callback to invoke when the event is fired.
@@ -267,34 +268,34 @@ function ie() {
267
268
  ], !1);
268
269
  },
269
270
  [e]
270
- ), r = (0, l.useCallback)(
271
+ ), r = (0, c.useCallback)(
271
272
  /**
272
273
  * @param eventName The name of the event to remove.
273
274
  * @param callback The callback to remove.
274
275
  */
275
276
  function(d, t) {
276
- e.current = e.current.filter(function(c) {
277
- return c.eventName !== d && c.callback !== t;
277
+ e.current = e.current.filter(function(l) {
278
+ return l.eventName !== d && l.callback !== t;
278
279
  });
279
280
  },
280
281
  [e]
281
- ), u = (0, l.useCallback)(
282
+ ), u = (0, c.useCallback)(
282
283
  /**
283
284
  * @param eventName The name of the event to dispatch.
284
285
  * @param parameters The parameters to pass to the event listener.
285
286
  */
286
287
  function(d) {
287
- for (var t = [], c = 1; c < arguments.length; c++)
288
- t[c - 1] = arguments[c];
289
- var m = e.current.find(function(w) {
290
- return w.eventName === d;
288
+ for (var t = [], l = 1; l < arguments.length; l++)
289
+ t[l - 1] = arguments[l];
290
+ var U = e.current.find(function(_) {
291
+ return _.eventName === d;
291
292
  });
292
- if (!(typeof m > "u"))
293
- return m.callback.apply(m, t);
293
+ if (!(typeof U > "u"))
294
+ return U.callback.apply(U, t);
294
295
  },
295
296
  [e]
296
297
  );
297
- return (0, l.useEffect)(function() {
298
+ return (0, c.useEffect)(function() {
298
299
  return o.push(u), function() {
299
300
  o.splice(o.indexOf(u), 1);
300
301
  };
@@ -303,14 +304,14 @@ function ie() {
303
304
  removeEventListener: r
304
305
  };
305
306
  };
306
- return S.useEventSystem = a, S;
307
+ return S.useEventSystem = i, S;
307
308
  }
308
309
  var H;
309
- function ae() {
310
- if (H) return R;
311
- H = 1, Object.defineProperty(R, "__esModule", { value: !0 }), R.useUnityContext = void 0;
312
- var s = k, l = ie(), v = function(o) {
313
- var y = (0, s.useState)(null), a = y[0], e = y[1], n = (0, s.useState)(0), r = n[0], u = n[1], d = (0, s.useState)(!1), t = d[0], c = d[1], m = (0, s.useState)(), w = m[0], i = m[1], U = (0, l.useEventSystem)(), _ = (0, s.useRef)({
310
+ function se() {
311
+ if (H) return j;
312
+ H = 1, Object.defineProperty(j, "__esModule", { value: !0 }), j.useUnityContext = void 0;
313
+ var s = x, c = ue(), v = function(o) {
314
+ var m = (0, s.useState)(null), i = m[0], e = m[1], n = (0, s.useState)(0), r = n[0], u = n[1], d = (0, s.useState)(!1), t = d[0], l = d[1], U = (0, s.useState)(), _ = U[0], a = U[1], b = (0, c.useEventSystem)(), w = (0, s.useRef)({
314
315
  companyName: o.companyName,
315
316
  productName: o.productName,
316
317
  productVersion: o.productVersion,
@@ -327,49 +328,49 @@ function ae() {
327
328
  autoSyncPersistentDataPath: o.autoSyncPersistentDataPath,
328
329
  setUnityInstance: e,
329
330
  setLoadingProgression: u,
330
- setIsLoaded: c,
331
- setInitialisationError: i
332
- }), h = (0, s.useCallback)(function(f) {
333
- return a == null ? void 0 : a.SetFullscreen(f ? 1 : 0);
334
- }, [a]), L = (0, s.useCallback)(function() {
335
- var f;
336
- return (f = a == null ? void 0 : a.Module.canvas) === null || f === void 0 ? void 0 : f.requestPointerLock();
337
- }, [a]), A = (0, s.useCallback)(function(f, C, P) {
338
- return a == null ? void 0 : a.SendMessage(f, C, P);
339
- }, [a]), b = (0, s.useCallback)(function(f, C) {
340
- var P;
341
- return (P = a == null ? void 0 : a.Module.canvas) === null || P === void 0 ? void 0 : P.toDataURL(f, C);
342
- }, [a]), g = (0, s.useCallback)(function() {
343
- var f;
344
- return (f = a == null ? void 0 : a.Quit()) !== null && f !== void 0 ? f : Promise.reject();
345
- }, [a]), I = (0, s.useCallback)(function() {
346
- var f;
347
- return (f = a == null ? void 0 : a.GetMetricsInfo) === null || f === void 0 ? void 0 : f.call(a);
348
- }, [a]);
331
+ setIsLoaded: l,
332
+ setInitialisationError: a
333
+ }), k = (0, s.useCallback)(function(y) {
334
+ return i == null ? void 0 : i.SetFullscreen(y ? 1 : 0);
335
+ }, [i]), E = (0, s.useCallback)(function() {
336
+ var y;
337
+ return (y = i == null ? void 0 : i.Module.canvas) === null || y === void 0 ? void 0 : y.requestPointerLock();
338
+ }, [i]), I = (0, s.useCallback)(function(y, C, h) {
339
+ return i == null ? void 0 : i.SendMessage(y, C, h);
340
+ }, [i]), f = (0, s.useCallback)(function(y, C) {
341
+ var h;
342
+ return (h = i == null ? void 0 : i.Module.canvas) === null || h === void 0 ? void 0 : h.toDataURL(y, C);
343
+ }, [i]), P = (0, s.useCallback)(function() {
344
+ var y;
345
+ return (y = i == null ? void 0 : i.Quit()) !== null && y !== void 0 ? y : Promise.reject();
346
+ }, [i]), L = (0, s.useCallback)(function() {
347
+ var y;
348
+ return (y = i == null ? void 0 : i.GetMetricsInfo) === null || y === void 0 ? void 0 : y.call(i);
349
+ }, [i]);
349
350
  return {
350
- unityProvider: _.current,
351
+ unityProvider: w.current,
351
352
  loadingProgression: r,
352
353
  isLoaded: t,
353
- initialisationError: w,
354
- requestFullscreen: h,
355
- requestPointerLock: L,
356
- sendMessage: A,
357
- takeScreenshot: b,
358
- unload: g,
359
- getMetricsInfo: I,
360
- addEventListener: U.addEventListener,
361
- removeEventListener: U.removeEventListener,
362
- UNSAFE__unityInstance: a
354
+ initialisationError: _,
355
+ requestFullscreen: k,
356
+ requestPointerLock: E,
357
+ sendMessage: I,
358
+ takeScreenshot: f,
359
+ unload: P,
360
+ getMetricsInfo: L,
361
+ addEventListener: b.addEventListener,
362
+ removeEventListener: b.removeEventListener,
363
+ UNSAFE__unityInstance: i
363
364
  };
364
365
  };
365
- return R.useUnityContext = v, R;
366
+ return j.useUnityContext = v, j;
366
367
  }
367
- var j = {}, Q;
368
- function ue() {
369
- if (Q) return j;
370
- Q = 1, Object.defineProperty(j, "__esModule", { value: !0 }), j.useUnityMetricsInfo = void 0;
371
- var s = k, l = function(v, o) {
372
- var y = (0, s.useState)({}), a = y[0], e = y[1];
368
+ var A = {}, Q;
369
+ function oe() {
370
+ if (Q) return A;
371
+ Q = 1, Object.defineProperty(A, "__esModule", { value: !0 }), A.useUnityMetricsInfo = void 0;
372
+ var s = x, c = function(v, o) {
373
+ var m = (0, s.useState)({}), i = m[0], e = m[1];
373
374
  return (0, s.useEffect)(function() {
374
375
  var n = setInterval(function() {
375
376
  var r = v();
@@ -378,31 +379,31 @@ function ue() {
378
379
  return function() {
379
380
  clearInterval(n);
380
381
  };
381
- }, [v, o.interval]), a;
382
+ }, [v, o.interval]), i;
382
383
  };
383
- return j.useUnityMetricsInfo = l, j;
384
+ return A.useUnityMetricsInfo = c, A;
384
385
  }
385
386
  var J;
386
- function se() {
387
+ function de() {
387
388
  return J || (J = 1, function(s) {
388
389
  Object.defineProperty(s, "__esModule", { value: !0 }), s.useUnityMetricsInfo = s.useUnityContext = s.Unity = void 0;
389
- var l = ne();
390
+ var c = ie();
390
391
  Object.defineProperty(s, "Unity", { enumerable: !0, get: function() {
391
- return l.Unity;
392
+ return c.Unity;
392
393
  } });
393
- var v = ae();
394
+ var v = se();
394
395
  Object.defineProperty(s, "useUnityContext", { enumerable: !0, get: function() {
395
396
  return v.useUnityContext;
396
397
  } });
397
- var o = ue();
398
+ var o = oe();
398
399
  Object.defineProperty(s, "useUnityMetricsInfo", { enumerable: !0, get: function() {
399
400
  return o.useUnityMetricsInfo;
400
401
  } });
401
- }(B)), B;
402
+ }(O)), O;
402
403
  }
403
- var K = se();
404
- const le = Z.forwardRef(
405
- ({ className: s, gameLink: l, loadingComponent: v, registerEvents: o, onEventReceived: y }, a) => {
404
+ var K = de();
405
+ const ye = Z.forwardRef(
406
+ ({ className: s, gameLink: c, loadingComponent: v, registerEvents: o, onEventReceived: m }, i) => {
406
407
  const {
407
408
  unityProvider: e,
408
409
  isLoaded: n,
@@ -410,54 +411,58 @@ const le = Z.forwardRef(
410
411
  UNSAFE__unityInstance: u,
411
412
  addEventListener: d,
412
413
  removeEventListener: t,
413
- unload: c,
414
- getMetricsInfo: m
414
+ unload: l,
415
+ getMetricsInfo: U
415
416
  } = K.useUnityContext({
416
- loaderUrl: `${l}/Build/Build.loader.js`,
417
- dataUrl: `${l}/Build/Build.data.unityweb`,
418
- frameworkUrl: `${l}/Build/Build.framework.js.unityweb`,
419
- codeUrl: `${l}/Build/Build.wasm.unityweb`
420
- }), w = G(null), i = G([]);
421
- return p(
422
- a,
417
+ loaderUrl: `${c}/Build/Build.loader.js`,
418
+ dataUrl: `${c}/Build/Build.data.unityweb`,
419
+ frameworkUrl: `${c}/Build/Build.framework.js.unityweb`,
420
+ codeUrl: `${c}/Build/Build.wasm.unityweb`
421
+ }), _ = D(null), a = D([]);
422
+ p(
423
+ i,
423
424
  () => ({
424
- unload: c,
425
- getMetricsInfo: m,
426
- canvas: w.current
425
+ unload: l,
426
+ getMetricsInfo: U,
427
+ canvas: _.current
427
428
  }),
428
- [c, m]
429
- ), D(() => {
430
- if (!(o && y))
429
+ [l, U]
430
+ ), B(() => {
431
+ if (!(o && m))
431
432
  return () => {
432
433
  };
433
- const U = [];
434
- for (const _ of o)
435
- if (!i.current.some((h) => h.key === _)) {
436
- const h = (L) => {
437
- y == null || y(_, L);
434
+ const E = [];
435
+ for (const I of o)
436
+ if (!a.current.some((f) => f.key === I)) {
437
+ const f = (P) => {
438
+ m == null || m(I, P);
438
439
  };
439
- d(_, h), U.push({ key: _, event: h });
440
+ d(I, f), E.push({ key: I, event: f });
440
441
  }
441
- return i.current = [...i.current, ...U], () => {
442
- for (const { key: _, event: h } of i.current)
443
- t(_, h);
444
- i.current = [];
442
+ return a.current = [...a.current, ...E], () => {
443
+ for (const { key: I, event: f } of a.current)
444
+ t(I, f);
445
+ a.current = [];
445
446
  };
446
- }, [o, d, t, y]), D(() => {
447
+ }, [o, d, t, m]), B(() => {
447
448
  window && u && (window.unityInstance = u);
448
- }, [u]), /* @__PURE__ */ O(Y, { children: [
449
- !n && (v ? /* @__PURE__ */ $(v, { progress: r }) : /* @__PURE__ */ O("div", { className: "h-full w-full items-center justify-center text-center", children: [
449
+ }, [u]);
450
+ const [b, w] = ee(!1), { message: k } = te("unity_channel");
451
+ return B(() => {
452
+ k === "loading_completed" && w(!0);
453
+ }, [k]), /* @__PURE__ */ $(Y, { children: [
454
+ !(n && b) && (v ? /* @__PURE__ */ G(v, { progress: r }) : /* @__PURE__ */ $("div", { className: "h-full w-full items-center justify-center text-center", children: [
450
455
  "Loading $",
451
- r * 100,
456
+ (r >= 1 ? 0.95 : r) * 100,
452
457
  "%"
453
458
  ] })),
454
- /* @__PURE__ */ $(
459
+ /* @__PURE__ */ G(
455
460
  K.Unity,
456
461
  {
457
- ref: w,
462
+ ref: _,
458
463
  id: "unity-canvas",
459
464
  unityProvider: e,
460
- className: ee(s, !n && "hidden"),
465
+ className: re(s, !n && "hidden"),
461
466
  devicePixelRatio: (window == null ? void 0 : window.devicePixelRatio) || 1
462
467
  }
463
468
  )
@@ -465,5 +470,5 @@ const le = Z.forwardRef(
465
470
  }
466
471
  );
467
472
  export {
468
- le as UnityGame
473
+ ye as UnityGame
469
474
  };
@@ -0,0 +1,5 @@
1
+ declare const useBroadcastChannel: (channelName: string) => {
2
+ message: null;
3
+ sendMessage: (msg: string) => void;
4
+ };
5
+ export default useBroadcastChannel;
@@ -0,0 +1,14 @@
1
+ import { useState as o, useEffect as c } from "react";
2
+ const u = (a) => {
3
+ const [n, t] = o(null), e = new BroadcastChannel(a);
4
+ return c(() => (e.onmessage = (s) => {
5
+ t(s.data);
6
+ }, () => {
7
+ e.close();
8
+ }), [e]), { message: n, sendMessage: (s) => {
9
+ e.postMessage(s);
10
+ } };
11
+ };
12
+ export {
13
+ u as default
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promogame-player",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",