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
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 (
|
|
16
|
-
return [
|
|
16
|
+
if (m !== void 0)
|
|
17
|
+
return [m, r];
|
|
17
18
|
var u = (0, s.useMemo)(function() {
|
|
18
|
-
return [v,
|
|
19
|
+
return [v, c].join("-");
|
|
19
20
|
}, [e]);
|
|
20
21
|
return [u, r];
|
|
21
22
|
};
|
|
22
|
-
return
|
|
23
|
+
return M.useCanvasIdentifier = o, M;
|
|
23
24
|
}
|
|
24
|
-
var
|
|
25
|
+
var q = {}, R = {}, z;
|
|
25
26
|
function X() {
|
|
26
|
-
return z || (z = 1, Object.defineProperty(
|
|
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
|
|
30
|
-
if (V) return
|
|
31
|
-
V = 1, Object.defineProperty(
|
|
32
|
-
var s =
|
|
33
|
-
var
|
|
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 (
|
|
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]),
|
|
54
|
+
}, [o]), i;
|
|
54
55
|
};
|
|
55
|
-
return
|
|
56
|
+
return q.useUnityLoader = v, q;
|
|
56
57
|
}
|
|
57
58
|
var W;
|
|
58
|
-
function
|
|
59
|
-
if (W) return
|
|
59
|
+
function ie() {
|
|
60
|
+
if (W) return g;
|
|
60
61
|
W = 1;
|
|
61
|
-
var s =
|
|
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(
|
|
64
|
-
|
|
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,
|
|
68
|
-
function
|
|
68
|
+
return new (r || (r = Promise))(function(t, l) {
|
|
69
|
+
function U(b) {
|
|
69
70
|
try {
|
|
70
|
-
|
|
71
|
-
} catch (
|
|
72
|
-
|
|
71
|
+
a(u.next(b));
|
|
72
|
+
} catch (w) {
|
|
73
|
+
l(w);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function _(b) {
|
|
76
77
|
try {
|
|
77
|
-
|
|
78
|
-
} catch (
|
|
79
|
-
|
|
78
|
+
a(u.throw(b));
|
|
79
|
+
} catch (w) {
|
|
80
|
+
l(w);
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
83
|
+
function a(b) {
|
|
84
|
+
b.done ? t(b.value) : d(b.value).then(U, _);
|
|
84
85
|
}
|
|
85
|
-
|
|
86
|
+
a((u = u.apply(e, n || [])).next());
|
|
86
87
|
});
|
|
87
|
-
},
|
|
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,
|
|
92
|
-
return
|
|
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
|
-
}),
|
|
95
|
-
function
|
|
96
|
-
return function(
|
|
97
|
-
return
|
|
95
|
+
}), l;
|
|
96
|
+
function U(a) {
|
|
97
|
+
return function(b) {
|
|
98
|
+
return _([a, b]);
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function _(a) {
|
|
101
102
|
if (u) throw new TypeError("Generator is already executing.");
|
|
102
|
-
for (;
|
|
103
|
-
if (u = 1, d && (t =
|
|
104
|
-
switch (d = 0, t && (
|
|
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 =
|
|
108
|
+
t = a;
|
|
108
109
|
break;
|
|
109
110
|
case 4:
|
|
110
|
-
return r.label++, { value:
|
|
111
|
+
return r.label++, { value: a[1], done: !1 };
|
|
111
112
|
case 5:
|
|
112
|
-
r.label++, d =
|
|
113
|
+
r.label++, d = a[1], a = [0];
|
|
113
114
|
continue;
|
|
114
115
|
case 7:
|
|
115
|
-
|
|
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]) && (
|
|
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 (
|
|
123
|
-
r.label =
|
|
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 (
|
|
127
|
-
r.label = t[1], t =
|
|
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(
|
|
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
|
-
|
|
138
|
-
} catch (
|
|
139
|
-
|
|
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 (
|
|
144
|
-
return { value:
|
|
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(
|
|
148
|
-
var v =
|
|
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),
|
|
156
|
-
e.unityProvider.setLoadingProgression(
|
|
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
|
|
160
|
+
var E = function() {
|
|
160
161
|
return s(void 0, void 0, void 0, function() {
|
|
161
|
-
var
|
|
162
|
-
return
|
|
163
|
-
switch (
|
|
162
|
+
var f, P, L, y, C;
|
|
163
|
+
return c(this, function(h) {
|
|
164
|
+
switch (h.label) {
|
|
164
165
|
case 0:
|
|
165
|
-
if (!u ||
|
|
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),
|
|
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(
|
|
188
|
-
(
|
|
189
|
-
}),
|
|
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
|
|
192
|
+
return h.trys.push([1, 3, , 4]), [4, window.createUnityInstance(u, f, k)];
|
|
192
193
|
case 2:
|
|
193
|
-
return
|
|
194
|
+
return P = h.sent(), U(P), e.unityProvider.setUnityInstance(P), [3, 4];
|
|
194
195
|
case 3:
|
|
195
|
-
return
|
|
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
|
-
},
|
|
205
|
+
}, I = function() {
|
|
205
206
|
return s(void 0, void 0, void 0, function() {
|
|
206
|
-
var
|
|
207
|
-
return
|
|
208
|
-
switch (
|
|
207
|
+
var f, P, L;
|
|
208
|
+
return c(this, function(y) {
|
|
209
|
+
switch (y.label) {
|
|
209
210
|
case 0:
|
|
210
|
-
return !
|
|
211
|
+
return !l || !u ? [
|
|
211
212
|
2
|
|
212
213
|
/*return*/
|
|
213
|
-
] : (console.log("React Unity WebGL: Detaching Unity instance..."), e.unityProvider.setUnityInstance(null),
|
|
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
|
|
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
|
|
224
|
-
|
|
224
|
+
return E(), function() {
|
|
225
|
+
I();
|
|
225
226
|
};
|
|
226
|
-
}, [u,
|
|
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:
|
|
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
|
|
238
|
+
return g.Unity = i, g;
|
|
238
239
|
}
|
|
239
|
-
var
|
|
240
|
-
function
|
|
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
|
|
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 =
|
|
258
|
-
var
|
|
259
|
-
var e = (0,
|
|
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,
|
|
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(
|
|
277
|
-
return
|
|
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,
|
|
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 = [],
|
|
288
|
-
t[
|
|
289
|
-
var
|
|
290
|
-
return
|
|
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
|
|
293
|
-
return
|
|
293
|
+
if (!(typeof U > "u"))
|
|
294
|
+
return U.callback.apply(U, t);
|
|
294
295
|
},
|
|
295
296
|
[e]
|
|
296
297
|
);
|
|
297
|
-
return (0,
|
|
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 =
|
|
307
|
+
return S.useEventSystem = i, S;
|
|
307
308
|
}
|
|
308
309
|
var H;
|
|
309
|
-
function
|
|
310
|
-
if (H) return
|
|
311
|
-
H = 1, Object.defineProperty(
|
|
312
|
-
var s =
|
|
313
|
-
var
|
|
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:
|
|
331
|
-
setInitialisationError:
|
|
332
|
-
}),
|
|
333
|
-
return
|
|
334
|
-
}, [
|
|
335
|
-
var
|
|
336
|
-
return (
|
|
337
|
-
}, [
|
|
338
|
-
return
|
|
339
|
-
}, [
|
|
340
|
-
var
|
|
341
|
-
return (
|
|
342
|
-
}, [
|
|
343
|
-
var
|
|
344
|
-
return (
|
|
345
|
-
}, [
|
|
346
|
-
var
|
|
347
|
-
return (
|
|
348
|
-
}, [
|
|
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:
|
|
351
|
+
unityProvider: w.current,
|
|
351
352
|
loadingProgression: r,
|
|
352
353
|
isLoaded: t,
|
|
353
|
-
initialisationError:
|
|
354
|
-
requestFullscreen:
|
|
355
|
-
requestPointerLock:
|
|
356
|
-
sendMessage:
|
|
357
|
-
takeScreenshot:
|
|
358
|
-
unload:
|
|
359
|
-
getMetricsInfo:
|
|
360
|
-
addEventListener:
|
|
361
|
-
removeEventListener:
|
|
362
|
-
UNSAFE__unityInstance:
|
|
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
|
|
366
|
+
return j.useUnityContext = v, j;
|
|
366
367
|
}
|
|
367
|
-
var
|
|
368
|
-
function
|
|
369
|
-
if (Q) return
|
|
370
|
-
Q = 1, Object.defineProperty(
|
|
371
|
-
var s =
|
|
372
|
-
var
|
|
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]),
|
|
382
|
+
}, [v, o.interval]), i;
|
|
382
383
|
};
|
|
383
|
-
return
|
|
384
|
+
return A.useUnityMetricsInfo = c, A;
|
|
384
385
|
}
|
|
385
386
|
var J;
|
|
386
|
-
function
|
|
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
|
|
390
|
+
var c = ie();
|
|
390
391
|
Object.defineProperty(s, "Unity", { enumerable: !0, get: function() {
|
|
391
|
-
return
|
|
392
|
+
return c.Unity;
|
|
392
393
|
} });
|
|
393
|
-
var v =
|
|
394
|
+
var v = se();
|
|
394
395
|
Object.defineProperty(s, "useUnityContext", { enumerable: !0, get: function() {
|
|
395
396
|
return v.useUnityContext;
|
|
396
397
|
} });
|
|
397
|
-
var o =
|
|
398
|
+
var o = oe();
|
|
398
399
|
Object.defineProperty(s, "useUnityMetricsInfo", { enumerable: !0, get: function() {
|
|
399
400
|
return o.useUnityMetricsInfo;
|
|
400
401
|
} });
|
|
401
|
-
}(
|
|
402
|
+
}(O)), O;
|
|
402
403
|
}
|
|
403
|
-
var K =
|
|
404
|
-
const
|
|
405
|
-
({ className: s, gameLink:
|
|
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:
|
|
414
|
-
getMetricsInfo:
|
|
414
|
+
unload: l,
|
|
415
|
+
getMetricsInfo: U
|
|
415
416
|
} = K.useUnityContext({
|
|
416
|
-
loaderUrl: `${
|
|
417
|
-
dataUrl: `${
|
|
418
|
-
frameworkUrl: `${
|
|
419
|
-
codeUrl: `${
|
|
420
|
-
}),
|
|
421
|
-
|
|
422
|
-
|
|
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:
|
|
425
|
-
getMetricsInfo:
|
|
426
|
-
canvas:
|
|
425
|
+
unload: l,
|
|
426
|
+
getMetricsInfo: U,
|
|
427
|
+
canvas: _.current
|
|
427
428
|
}),
|
|
428
|
-
[
|
|
429
|
-
),
|
|
430
|
-
if (!(o &&
|
|
429
|
+
[l, U]
|
|
430
|
+
), B(() => {
|
|
431
|
+
if (!(o && m))
|
|
431
432
|
return () => {
|
|
432
433
|
};
|
|
433
|
-
const
|
|
434
|
-
for (const
|
|
435
|
-
if (!
|
|
436
|
-
const
|
|
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
439
|
};
|
|
439
|
-
d(
|
|
440
|
+
d(I, f), E.push({ key: I, event: f });
|
|
440
441
|
}
|
|
441
|
-
return
|
|
442
|
-
for (const { key:
|
|
443
|
-
t(
|
|
444
|
-
|
|
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,
|
|
447
|
+
}, [o, d, t, m]), B(() => {
|
|
447
448
|
window && u && (window.unityInstance = u);
|
|
448
|
-
}, [u])
|
|
449
|
-
|
|
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:
|
|
462
|
+
ref: _,
|
|
458
463
|
id: "unity-canvas",
|
|
459
464
|
unityProvider: e,
|
|
460
|
-
className:
|
|
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
|
-
|
|
473
|
+
ye as UnityGame
|
|
469
474
|
};
|
|
@@ -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
|
+
};
|