promogame-player 1.0.8 → 1.0.9

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