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.
- package/dist/components/PromogameGame/unity-game.js +219 -215
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -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
|
|
4
|
-
import
|
|
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 = {},
|
|
7
|
-
function
|
|
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 =
|
|
11
|
-
var i = (0, s.useState)(0), e = i[0],
|
|
12
|
-
|
|
13
|
-
return
|
|
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,
|
|
17
|
+
return [m, n];
|
|
18
18
|
var u = (0, s.useMemo)(function() {
|
|
19
|
-
return [
|
|
19
|
+
return [f, v].join("-");
|
|
20
20
|
}, [e]);
|
|
21
|
-
return [u,
|
|
21
|
+
return [u, n];
|
|
22
22
|
};
|
|
23
23
|
return M.useCanvasIdentifier = o, M;
|
|
24
24
|
}
|
|
25
|
-
var q = {}, R = {},
|
|
25
|
+
var q = {}, R = {}, W;
|
|
26
26
|
function X() {
|
|
27
|
-
return
|
|
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
|
|
30
|
-
function
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
var s =
|
|
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 (
|
|
36
|
+
if (v.isBrowserEnvironment !== !1) {
|
|
37
37
|
if (o === null) {
|
|
38
38
|
e("Idle");
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
}),
|
|
45
|
-
return
|
|
46
|
-
})) : e(
|
|
47
|
-
var
|
|
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
|
|
51
|
-
|
|
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 =
|
|
56
|
+
return q.useUnityLoader = f, q;
|
|
57
57
|
}
|
|
58
|
-
var
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
var s =
|
|
63
|
-
function
|
|
64
|
-
return t instanceof
|
|
65
|
-
|
|
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 (
|
|
69
|
-
function U(
|
|
68
|
+
return new (n || (n = Promise))(function(t, d) {
|
|
69
|
+
function U(y) {
|
|
70
70
|
try {
|
|
71
|
-
a(u.next(
|
|
72
|
-
} catch (
|
|
73
|
-
|
|
71
|
+
a(u.next(y));
|
|
72
|
+
} catch (I) {
|
|
73
|
+
d(I);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function h(y) {
|
|
77
77
|
try {
|
|
78
|
-
a(u.throw(
|
|
79
|
-
} catch (
|
|
80
|
-
|
|
78
|
+
a(u.throw(y));
|
|
79
|
+
} catch (I) {
|
|
80
|
+
d(I);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function a(
|
|
84
|
-
|
|
83
|
+
function a(y) {
|
|
84
|
+
y.done ? t(y.value) : l(y.value).then(U, h);
|
|
85
85
|
}
|
|
86
|
-
a((u = u.apply(e,
|
|
86
|
+
a((u = u.apply(e, r || [])).next());
|
|
87
87
|
});
|
|
88
|
-
},
|
|
89
|
-
var
|
|
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,
|
|
93
|
-
return
|
|
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
|
-
}),
|
|
95
|
+
}), d;
|
|
96
96
|
function U(a) {
|
|
97
|
-
return function(
|
|
98
|
-
return
|
|
97
|
+
return function(y) {
|
|
98
|
+
return h([a, y]);
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function h(a) {
|
|
102
102
|
if (u) throw new TypeError("Generator is already executing.");
|
|
103
|
-
for (;
|
|
104
|
-
if (u = 1,
|
|
105
|
-
switch (
|
|
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
|
|
111
|
+
return n.label++, { value: a[1], done: !1 };
|
|
112
112
|
case 5:
|
|
113
|
-
|
|
113
|
+
n.label++, l = a[1], a = [0];
|
|
114
114
|
continue;
|
|
115
115
|
case 7:
|
|
116
|
-
a =
|
|
116
|
+
a = n.ops.pop(), n.trys.pop();
|
|
117
117
|
continue;
|
|
118
118
|
default:
|
|
119
|
-
if (t =
|
|
120
|
-
|
|
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
|
-
|
|
124
|
+
n.label = a[1];
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
127
|
-
if (a[0] === 6 &&
|
|
128
|
-
|
|
127
|
+
if (a[0] === 6 && n.label < t[1]) {
|
|
128
|
+
n.label = t[1], t = a;
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
|
-
if (t &&
|
|
132
|
-
|
|
131
|
+
if (t && n.label < t[2]) {
|
|
132
|
+
n.label = t[2], n.ops.push(a);
|
|
133
133
|
break;
|
|
134
134
|
}
|
|
135
|
-
t[2] &&
|
|
135
|
+
t[2] && n.ops.pop(), n.trys.pop();
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
|
-
a =
|
|
139
|
-
} catch (
|
|
140
|
-
a = [6,
|
|
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(
|
|
149
|
-
var
|
|
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,
|
|
156
|
-
var
|
|
157
|
-
e.unityProvider.setLoadingProgression(
|
|
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,
|
|
160
|
-
var
|
|
159
|
+
return (0, f.useEffect)(function() {
|
|
160
|
+
var L = function() {
|
|
161
161
|
return s(void 0, void 0, void 0, function() {
|
|
162
|
-
var
|
|
163
|
-
return
|
|
164
|
-
switch (
|
|
162
|
+
var b, w, _, c, g;
|
|
163
|
+
return v(this, function(P) {
|
|
164
|
+
switch (P.label) {
|
|
165
165
|
case 0:
|
|
166
|
-
if (!u ||
|
|
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), (
|
|
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(
|
|
189
|
-
(
|
|
190
|
-
}),
|
|
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
|
|
192
|
+
return P.trys.push([1, 3, , 4]), [4, window.createUnityInstance(u, b, x)];
|
|
193
193
|
case 2:
|
|
194
|
-
return
|
|
194
|
+
return w = P.sent(), U(w), e.unityProvider.setUnityInstance(w), [3, 4];
|
|
195
195
|
case 3:
|
|
196
|
-
return
|
|
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
|
-
},
|
|
205
|
+
}, S = function() {
|
|
206
206
|
return s(void 0, void 0, void 0, function() {
|
|
207
|
-
var
|
|
208
|
-
return
|
|
209
|
-
switch (
|
|
207
|
+
var b, w, _;
|
|
208
|
+
return v(this, function(c) {
|
|
209
|
+
switch (c.label) {
|
|
210
210
|
case 0:
|
|
211
|
-
return !
|
|
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), (
|
|
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
|
|
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
|
|
225
|
-
|
|
224
|
+
return L(), function() {
|
|
225
|
+
S();
|
|
226
226
|
};
|
|
227
|
-
}, [u,
|
|
227
|
+
}, [u, d, I, e.unityProvider]), (0, f.useImperativeHandle)(r, function() {
|
|
228
228
|
return u;
|
|
229
|
-
}), (0,
|
|
230
|
-
ref:
|
|
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
|
|
238
|
+
return E.Unity = i, E;
|
|
239
239
|
}
|
|
240
|
-
var j = {},
|
|
241
|
-
function
|
|
242
|
-
if (T) return
|
|
240
|
+
var j = {}, C = {}, T;
|
|
241
|
+
function se() {
|
|
242
|
+
if (T) return C;
|
|
243
243
|
T = 1;
|
|
244
|
-
var s =
|
|
245
|
-
if (
|
|
246
|
-
(t || !(u in
|
|
247
|
-
return e.concat(t || Array.prototype.slice.call(
|
|
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(
|
|
250
|
-
var
|
|
251
|
-
for (var
|
|
252
|
-
n
|
|
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(
|
|
255
|
-
u =
|
|
254
|
+
return o.forEach(function(l) {
|
|
255
|
+
u = l.apply(void 0, s([e], r, !1));
|
|
256
256
|
}), u;
|
|
257
257
|
};
|
|
258
|
-
|
|
258
|
+
f.isBrowserEnvironment === !0 && (window.dispatchReactUnityEvent = m);
|
|
259
259
|
var i = function() {
|
|
260
|
-
var e = (0,
|
|
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(
|
|
265
|
+
function(l, t) {
|
|
266
266
|
e.current = s(s([], e.current, !0), [
|
|
267
|
-
{ eventName:
|
|
267
|
+
{ eventName: l, callback: t }
|
|
268
268
|
], !1);
|
|
269
269
|
},
|
|
270
270
|
[e]
|
|
271
|
-
),
|
|
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(
|
|
277
|
-
e.current = e.current.filter(function(
|
|
278
|
-
return
|
|
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,
|
|
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(
|
|
288
|
-
for (var t = [],
|
|
289
|
-
t[
|
|
290
|
-
var U = e.current.find(function(
|
|
291
|
-
return
|
|
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,
|
|
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:
|
|
304
|
-
removeEventListener:
|
|
303
|
+
addEventListener: r,
|
|
304
|
+
removeEventListener: n
|
|
305
305
|
};
|
|
306
306
|
};
|
|
307
|
-
return
|
|
307
|
+
return C.useEventSystem = i, C;
|
|
308
308
|
}
|
|
309
309
|
var H;
|
|
310
|
-
function
|
|
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 =
|
|
314
|
-
var m = (0, s.useState)(null), i = m[0], e = m[1],
|
|
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:
|
|
331
|
+
setIsLoaded: d,
|
|
332
332
|
setInitialisationError: a
|
|
333
|
-
}),
|
|
334
|
-
return i == null ? void 0 : i.SetFullscreen(
|
|
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
|
|
348
|
-
return (
|
|
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:
|
|
352
|
-
loadingProgression:
|
|
351
|
+
unityProvider: I.current,
|
|
352
|
+
loadingProgression: n,
|
|
353
353
|
isLoaded: t,
|
|
354
|
-
initialisationError:
|
|
355
|
-
requestFullscreen:
|
|
356
|
-
requestPointerLock:
|
|
357
|
-
sendMessage:
|
|
358
|
-
takeScreenshot:
|
|
359
|
-
unload:
|
|
360
|
-
getMetricsInfo:
|
|
361
|
-
addEventListener:
|
|
362
|
-
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 =
|
|
366
|
+
return j.useUnityContext = f, j;
|
|
367
367
|
}
|
|
368
368
|
var A = {}, Q;
|
|
369
|
-
function
|
|
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 =
|
|
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
|
|
376
|
-
var
|
|
377
|
-
typeof
|
|
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(
|
|
380
|
+
clearInterval(r);
|
|
381
381
|
};
|
|
382
|
-
}, [
|
|
382
|
+
}, [f, o.interval]), i;
|
|
383
383
|
};
|
|
384
|
-
return A.useUnityMetricsInfo =
|
|
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
|
|
390
|
+
var v = ue();
|
|
391
391
|
Object.defineProperty(s, "Unity", { enumerable: !0, get: function() {
|
|
392
|
-
return
|
|
392
|
+
return v.Unity;
|
|
393
393
|
} });
|
|
394
|
-
var
|
|
394
|
+
var f = oe();
|
|
395
395
|
Object.defineProperty(s, "useUnityContext", { enumerable: !0, get: function() {
|
|
396
|
-
return
|
|
396
|
+
return f.useUnityContext;
|
|
397
397
|
} });
|
|
398
|
-
var o =
|
|
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
|
|
406
|
-
({ className: s, gameLink:
|
|
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:
|
|
410
|
-
loadingProgression:
|
|
409
|
+
isLoaded: r,
|
|
410
|
+
loadingProgression: n,
|
|
411
411
|
UNSAFE__unityInstance: u,
|
|
412
|
-
addEventListener:
|
|
412
|
+
addEventListener: l,
|
|
413
413
|
removeEventListener: t,
|
|
414
|
-
unload:
|
|
415
|
-
getMetricsInfo: U
|
|
414
|
+
unload: d,
|
|
415
|
+
getMetricsInfo: U,
|
|
416
|
+
sendMessage: h
|
|
416
417
|
} = K.useUnityContext({
|
|
417
|
-
loaderUrl: `${
|
|
418
|
-
dataUrl: `${
|
|
419
|
-
frameworkUrl: `${
|
|
420
|
-
codeUrl: `${
|
|
421
|
-
}),
|
|
422
|
-
|
|
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:
|
|
428
|
+
unload: I,
|
|
426
429
|
getMetricsInfo: U,
|
|
427
|
-
|
|
430
|
+
sendMessage: h,
|
|
431
|
+
canvas: a.current
|
|
428
432
|
}),
|
|
429
|
-
[
|
|
433
|
+
[U, h, I]
|
|
430
434
|
), B(() => {
|
|
431
435
|
if (!(o && m))
|
|
432
436
|
return () => {
|
|
433
437
|
};
|
|
434
|
-
const
|
|
435
|
-
for (const
|
|
436
|
-
if (!
|
|
437
|
-
const
|
|
438
|
-
m == null || m(
|
|
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
|
-
|
|
444
|
+
l(w, _), b.push({ key: w, event: _ });
|
|
441
445
|
}
|
|
442
|
-
return
|
|
443
|
-
for (const { key:
|
|
444
|
-
t(
|
|
445
|
-
|
|
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,
|
|
451
|
+
}, [o, l, t, m]), B(() => {
|
|
448
452
|
window && u && (window.unityInstance = u);
|
|
449
453
|
}, [u]);
|
|
450
|
-
const [
|
|
454
|
+
const [x, L] = te(!1), { message: S } = ne("unity_channel");
|
|
451
455
|
return B(() => {
|
|
452
|
-
|
|
453
|
-
}, [
|
|
454
|
-
!(
|
|
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
|
-
(
|
|
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, !
|
|
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
|
-
|
|
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
|
}
|